首页 > 代码库 > 查询功能实现

查询功能实现

1、根据酒检表“执勤民警(zqmj)、处理时间(clsj)”字段查询数据,zqmj字段值和视频数据表中(police_id)字段相同并且clsj在视频数据表中(import_time)和(capture_time)之间取出值

Action:

@RequiresPermissions("jcjl:o_play.do")
    @RequestMapping("/jcjl/o_play.do")
    public String play(Integer id, String path, String name,
            HttpServletRequest request, ModelMap model) {
        CmsJcjl cmsJcjl = wfMng.findById(id.toString());
        List<CmsZfysj> bean = zmanager.findByZqmj(cmsJcjl.getZqmj(),
                cmsJcjl.getClsj());

        if (bean.size() == 1) {
            CmsZfysj cmsZfysj = bean.get(0);
            if (cmsZfysj.getPath() != null && !cmsZfysj.getPath().equals("")) {
                model.addAttribute("path", cmsZfysj.getPath());
                model.addAttribute("videoPath", cmsZfysj.getPath());
                System.out.println(cmsZfysj.getPath());
            }
            if (cmsZfysj.getName() != null && !cmsZfysj.getName().equals("")) {
                model.addAttribute("name", cmsZfysj.getName());
                System.out.println(cmsZfysj.getName());
            }

        }
        return "jcjl/play";
    }

Daoimpl

@SuppressWarnings("unchecked")
    public List<CmsZfysj> findByZqmj(String zqmj, Date clsj) {
        Finder f = Finder.create("from CmsZfysj bean where 1=1 ");
        if (null != zqmj && !"".equals(zqmj)) {
            f.append(" and bean.police_id like :zqmj");
            f.setParam("zqmj", "%" + zqmj + "%");
        }
        if (null != clsj && !"".equals(clsj)) {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            f.append(" and TO_CHAR(bean.import_time,‘yyyy-MM-dd‘) >= ‘"
                    + df.format(clsj) + "‘");
        }
        if (null != clsj && !"".equals(clsj)) {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            f.append(" and TO_CHAR(bean.capture_time,‘yyyy-MM-dd‘) <= ‘"
                    + df.format(clsj) + "‘");
        }
        return find(f);
    }

 

查询功能实现