1.1 供货商药品目录控制
1.1.1 需求
监管单位查询所有要控制的供货商药品目录信息,选择控制状态,提交控制状态。
以监管单位(卫生局)登陆:
第一步:查询所有要控制的供货商药品目录
提交控制状态:
根据供货商id和药品id更新供货商药品供货状态(1:正常,2:暂停)。
1.1.2 实现
1.1.2.1 Dao:
1、监管单位查询所有供货商药品目录信息
Sql:
主查询表:供货商药品目录控制表
关联查询表:供货商信息、药品信息。
Sql:
2、提交控制状态
根据供货商id和药品id更新供货商药品目录控制表状态(1:正常,2:暂停)
自定义mapper
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="yycg.business.dao.mapper.GysypmlControlMapperCustom">
<select id="findgysypmlcontrol" resultType="yycg.business.pojo.vo.GysypmlCustom" parameterType="yycg.business.pojo.vo.GysypmlQueryVo">
<!-- 分页头 -->
<if test="pageQuery!=null">
select page_2.*
from (select page_1.*, rownum page_num
from
(
</if>
select gysypml_control.id gysypmlcontrolid,
gysypml_control.ypxxid,
gysypml_control.usergysid,
usergys.mc usergysmc,
gysypml_control.control,
(select info
from dictinfo
where typecode = '008'
and dictcode = gysypml_control.control) controlmc,
ypxx.id,
ypxx.bm,
ypxx.mc,
ypxx.jx,
ypxx.gg,
ypxx.zhxs,
ypxx.scqymc,
ypxx.spmc,
ypxx.zbjg,
ypxx.jyzt,
(select info
from dictinfo
where ypxx.jyzt = dictcode
and typecode = '003') jyztmc
from usergys, gysypml_control, ypxx
where
gysypml_control.usergysid = usergys.id
and gysypml_control.ypxxid = ypxx.id
<include refid="yycg.business.dao.mapper.GysypmlMapperCustom.query_gysypmlcontrol_where" />
<!-- 药品查询条件 -->
<include refid="yycg.business.dao.mapper.YpxxMapperCustom.query_ypxx_where" />
<!-- 分页尾 -->
<if test="pageQuery!=null">
) page_1
<![CDATA[ where rownum <= ${pageQuery.PageQuery_end}) page_2 where page_2.page_num >= ${pageQuery.PageQuery_start} ]]>
</if>
</select>
<select id="findgysypmlcontrolcount" resultType="int" parameterType="yycg.business.pojo.vo.GysypmlQueryVo">
select count(*)
from usergys, gysypml_control, ypxx
where
gysypml_control.usergysid = usergys.id
and gysypml_control.ypxxid = ypxx.id
<include refid="yycg.business.dao.mapper.GysypmlMapperCustom.query_gysypmlcontrol_where" />
<!-- 药品查询条件 -->
<include refid="yycg.business.dao.mapper.YpxxMapperCustom.query_ypxx_where" />
</select>
</mapper>
1.1.2.2 Service
1、监管单位查询所有供货商药品目录信息
接口功能:监管单位查询所有供货商药品目录信息
接口参数:查询条件(GysypmlQueryVo)
接口实现:调用mapper查询数据
1、 提交控制状态(只处理单个记录)
接口功能:根据供货商id和药品id更新控制状态(1:正常,2:暂停)
接口参数:供货商id和药品id、控制状态(1:正常,2:暂停)
接口实现:
校验:
供货商id和药品id在供货商药品目录控制表存在,不存在是无法更新的。
控制状态值合法性,不是1就是2(1:正常,2:暂停)
执行更新:
根据供货商id和药品id更新控制状态
// 更新控制其药品供应状态 通过usergysid和ypxxid来查询gysypml
@Override
public void updateGysypmlControl(String usergysid, String ypxxid,
String control,String advice) throws Exception {
// 查询药品目录是否存在
GysypmlControl gysypmlControl = this
.findGysypmlControlByUsergysidAndYpxxid(usergysid, ypxxid);
if (gysypmlControl == null) {// 不存在抛异常
ResultUtil.throwExcepion(ResultUtil.createFail(Config.MESSAGE, 902,
null));
} else {
// 检验控制信息是否合法
if (control.equals("1") || control.equals("2")) {
// 数据正确 更新
gysypmlControl.setControl(control);
gysypmlControl.setAdvice(advice);
gysypmlControlMapper.updateByPrimaryKey(gysypmlControl);
} else {
// 错误抛异常
ResultUtil.throwExcepion(ResultUtil.createFail(Config.MESSAGE,
711, null));
}
}
}
// 抽取方法 通过usergysid和ypxxid来查询gysypml 是否存在 (添加一条药品用到)
public GysypmlControl findGysypmlControlByUsergysidAndYpxxid(
String usergysid, String ypxxid) throws Exception {
GysypmlControlExample gysypmlControlExample = new GysypmlControlExample();
GysypmlControlExample.Criteria criteria = gysypmlControlExample
.createCriteria();
criteria.andUsergysidEqualTo(usergysid);
criteria.andYpxxidEqualTo(ypxxid);
List<GysypmlControl> list = gysypmlControlMapper
.selectByExample(gysypmlControlExample);
if (list != null && list.size() == 1) {
return list.get(0);
}
return null;
}
1.1.2.3 Action
1、 监管单位控制供货商药品目录查询列表
按照通用代码模版写。
2、 提交供货商药品目录控制状态
参考供货商药品目录添加提交的方法。
方法参数:
int[] indexs页面选中行的序号
GysypmlQueryVo (页面提交的业务数据)
// 药品信息控制显示
@RequestMapping("/querygysypmlcontrol")
public String querygysypmlcontrol(Model model) throws Exception {
// 药品类别
List<Dictinfo> yplblist = systemConfigService.findDictinfoByType("001");
// 药品交易状态
List<Dictinfo> jyztlist = systemConfigService.findDictinfoByType("003");
// 供货状态
List<Dictinfo> controllist = systemConfigService
.findDictinfoByType("008");
model.addAttribute("controllist", controllist);
model.addAttribute("jyztlist", jyztlist);
model.addAttribute("yplblist", yplblist);
return "/business/ypml/querygysypmlcontrol";
}
// 药品控制信息查询返回
@RequestMapping("/querygysypmlcontrol_result")
public @ResponseBody
DataGridResultInfo querygysypmlcontrol_result(int page, int rows,
GysypmlQueryVo gysypmlQueryVo) throws Exception {
// 取总数
int total = ypmlService.findgysypmlcontrolcount(gysypmlQueryVo);
// 分页参数
PageQuery pageQuery = new PageQuery();
pageQuery.setPageParams(total, rows, page);
gysypmlQueryVo.setPageQuery(pageQuery);
// 新建列表
List<GysypmlCustom> list = ypmlService
.findgysypmlcontrol(gysypmlQueryVo);
DataGridResultInfo dataGridResultInfo = new DataGridResultInfo();
dataGridResultInfo.setTotal(total);
dataGridResultInfo.setRows(list);
return dataGridResultInfo;
}
// 药品控制提交按钮
@RequestMapping("/gysypmlcontrolsubmit")
public @ResponseBody
SubmitResultInfo gysypmlcontrolsubmit(int[] indexs,
GysypmlQueryVo gysypmlQueryVo) throws Exception {
int count = indexs.length;
int success_count = 0;
int count_error = 0;
// 记录错误信息
List<ResultInfo> message_error = new ArrayList<ResultInfo>();
// 获取药品信息记录的供应商信息和药品信息
List<GysypmlControl> list = gysypmlQueryVo.getGysypmls();
for (int i = 0; i < count; i++) {
ResultInfo resultInfo = null;
GysypmlControl gysypmlControl = list.get(indexs[i]);
String usergysid = gysypmlControl.getUsergysid();
String ypxxid = gysypmlControl.getId();
String control = gysypmlControl.getControl();
String advice=gysypmlControl.getAdvice();
try {
ypmlService.updateGysypmlControl(usergysid, ypxxid, control,advice);
} catch (Exception e) {
e.printStackTrace();
if (e instanceof ExceptionResultInfo) {// 自定义异常类
resultInfo = ((ExceptionResultInfo) e).getResultInfo();
} else {
// 构造未知错误
resultInfo = ResultUtil.createFail(Config.MESSAGE, 900,
null);
}
}
if (resultInfo == null) {
// 执行成功
success_count++;
} else {
count_error++;
// 记录失败原因
message_error.add(resultInfo);
}
}
return ResultUtil.createSubmitResult(
ResultUtil.createSuccess(Config.MESSAGE, 907, new Object[] {
success_count, count_error }), message_error);
}
1.1.2.4 页面
参考:供货商药品目录添加提交的页面