需求:
我们之前把采购单交给监督单位审核了,审通过的采购单就要受理。供货商决定采购单发不发货。
如下:
这张单子里面的就是采购单详细表,这儿查出来的数据就只是特定于这个供货商的采购单详细表,一个区域里面只有一个供货商,有好几个医院,每个医院有好多个采购单。那么就是一个供货商有好几个采购单。供货商要看着每一个采购单的明细表才会去处理这个数据要不要发货。
我们先写Mapper:
我们写sql时要参考:
Mapper.xml如下:
<!-- 采购单药品明细查询列表 --> <select id="findYycgdmxList" parameterType="yycg.business.pojo.vo.YycgdQueryVo" resultType="yycg.business.pojo.vo.YycgdmxCustom"> <!-- 引入分页头 --> <include refid="yycg.base.commonSql.page_start" /> select yycgdmx.id yycgdmxid, useryy.id useryyid, useryy.mc useryymc, yycgd.bm yycgdbm, yycgd.mc yycgdmc, yycgd.cjtime, (select info from dictinfo where typecode = ‘010‘ and dictcode = yycgd.zt) yycgdztmc, ypxx.id, ypxx.bm, ypxx.mc, ypxx.jx, ypxx.gg, ypxx.zhxs, ypxx.scqymc, ypxx.spmc, ypxx.jyzt, (select info from dictinfo where ypxx.jyzt = dictcode and typecode = ‘003‘) jyztmc, yycgdmx.zbjg, yycgdmx.jyjg, yycgdmx.cgl, yycgdmx.cgje, yycgdmx.cgzt, (select info from dictinfo where typecode = ‘011‘ and dictcode = yycgdmx.cgzt) cgztmc, usergys.mc usergysmc, usergys.id usergysid from yycgdmx${businessyear} yycgdmx, yycgd${businessyear} yycgd, useryy, ypxx, usergys where yycgdmx.yycgdid = yycgd.id and yycgd.useryyid = useryy.id and yycgdmx.ypxxid = ypxx.id and yycgdmx.usergysid = usergys.id <!-- 只查询某个采购单下药品明细 --> <include refid="query_yycgdmx_where" /> <!-- 采购单查询条件 --> <include refid="query_yycgd_where" /> <!-- 药品查询条件 --> <include refid="yycg.business.dao.mapper.YpxxMapperCustom.query_ypxx_where" /> <!-- 分页尾部 --> <include refid="yycg.base.commonSql.page_end" /> </select>
我们之前写过findYycgdmxList。我们这次要做的就是扩展查询条件,使的之前的findYycgdmxList可以继续用。
<!-- 采购单药品明细查询列表总数 --> <select id="findYycgdmxCount" parameterType="yycg.business.pojo.vo.YycgdQueryVo" resultType="int"> select count(*) from yycgdmx${businessyear} yycgdmx, yycgd${businessyear} yycgd, useryy, ypxx, usergys where yycgdmx.yycgdid = yycgd.id and yycgd.useryyid = useryy.id and yycgdmx.ypxxid = ypxx.id and yycgdmx.usergysid = usergys.id <!-- 只查询某个采购单下药品明细 --> <include refid="query_yycgdmx_where" /> <!-- 采购单查询条件 --> <include refid="query_yycgd_where" /> <!-- 药品查询条件 --> <include refid="yycg.business.dao.mapper.YpxxMapperCustom.query_ypxx_where" /> </select>
findYycgdmxCount是对应查数量的,用来分页用的。
Service 如下:
@Override public List<YycgdmxCustom> findDisposeYycgdList(String usergysid, String year, YycgdQueryVo yycgdQueryVo) throws Exception { yycgdQueryVo = yycgdQueryVo != null ? yycgdQueryVo : new YycgdQueryVo(); // 供货商只允许查询自己供应的采购药品信息 // 设置供货商id YycgdmxCustom yycgdmxCustom = yycgdQueryVo.getYycgdmxCustom(); yycgdmxCustom = yycgdmxCustom != null ? yycgdmxCustom : new YycgdmxCustom(); yycgdmxCustom.setUsergysid(usergysid); // 采购药品明细状态为“未确认送货” String cgzt = "1"; yycgdmxCustom.setCgzt(cgzt); yycgdQueryVo.setYycgdmxCustom(yycgdmxCustom); // 采购单为审核通过 String zt = "3"; YycgdCustom yycgdCustom = yycgdQueryVo.getYycgdCustom(); yycgdCustom = yycgdCustom != null ? yycgdCustom : new YycgdCustom(); yycgdCustom.setZt(zt); yycgdQueryVo.setYycgdCustom(yycgdCustom); // 设置年份 yycgdQueryVo.setBusinessyear(year); return yycgdMapperCustom.findYycgdmxList(yycgdQueryVo); } @Override public int findDisposeYycgdCount(String usergysid, String year, YycgdQueryVo yycgdQueryVo) throws Exception { yycgdQueryVo = yycgdQueryVo != null ? yycgdQueryVo : new YycgdQueryVo(); // 供货商只允许查询自己供应的采购药品信息 // 设置供货商id YycgdmxCustom yycgdmxCustom = yycgdQueryVo.getYycgdmxCustom(); yycgdmxCustom = yycgdmxCustom != null ? yycgdmxCustom : new YycgdmxCustom(); yycgdmxCustom.setUsergysid(usergysid); // 采购药品明细状态为“未确认送货” String cgzt = "1"; yycgdmxCustom.setCgzt(cgzt); yycgdQueryVo.setYycgdmxCustom(yycgdmxCustom); // 采购单为审核通过 String zt = "3"; YycgdCustom yycgdCustom = yycgdQueryVo.getYycgdCustom(); yycgdCustom = yycgdCustom != null ? yycgdCustom : new YycgdCustom(); yycgdCustom.setZt(zt); yycgdQueryVo.setYycgdCustom(yycgdCustom); // 设置年份 yycgdQueryVo.setBusinessyear(year); return yycgdMapperCustom.findYycgdmxCount(yycgdQueryVo); }
Action层:
// 采购单受理页面 @RequestMapping("/disposeyycgd") public String disposeyycgd(Model model) throws Exception { // 当前年份 model.addAttribute("year", MyUtil.get_YYYY(MyUtil.getDate())); return "/business/cgd/disposeyycgd"; } // 采购单受理列表结果集,json @RequestMapping("/disposeyycgd_result") public @ResponseBody DataGridResultInfo disposeyycgd_result(// HttpSession session, ActiveUser activeUser, String year,// 年份 YycgdQueryVo yycgdQueryVo,// 查询条件 int page, int rows) throws Exception { // 供货商id String usergysid = activeUser.getSysid();// 单位id // 列表的总数 int total = cgdService.findDisposeYycgdCount(usergysid, year, yycgdQueryVo); // 分页参数 PageQuery pageQuery = new PageQuery(); pageQuery.setPageParams(total, rows, page); yycgdQueryVo.setPageQuery(pageQuery);// 设置分页参数 // 分页查询列表 List<YycgdmxCustom> list = cgdService.findDisposeYycgdList(usergysid, year, yycgdQueryVo); DataGridResultInfo dataGridResultInfo = new DataGridResultInfo(); dataGridResultInfo.setTotal(total); dataGridResultInfo.setRows(list); return dataGridResultInfo; }
调试通过。
时间: 2024-10-26 07:00:40