123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- package thyyxxk.webserver.service.datamodify;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import thyyxxk.webserver.config.exception.ExceptionEnum;
- import thyyxxk.webserver.dao.his.datamodify.YzActOrderDao;
- import thyyxxk.webserver.entity.ResultVo;
- import thyyxxk.webserver.entity.datamodify.TYzActOrderModify;
- import thyyxxk.webserver.entity.datamodify.YzActOrder;
- import thyyxxk.webserver.utils.ResultVoUtil;
- import thyyxxk.webserver.utils.StringUtil;
- import thyyxxk.webserver.utils.TokenUtil;
- import thyyxxk.webserver.websocket.WebSocketServer;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * <p>
- * 医嘱修改服务类
- * </p>
- *
- * @author 肖蟾
- * @since 2021-03-08
- */
- @Service
- @Slf4j
- public class YzActOrderModifyService {
- private final YzActOrderDao dao;
- private static final String DATE_FORMAT = "yyyy-MM-dd HH:ss:mm";
- @Autowired
- public YzActOrderModifyService(YzActOrderDao dao) {
- this.dao = dao;
- }
- /**
- * 根据医嘱号 来查询 符合条件的数据
- *
- * @param param 医嘱号 和 住院号查询
- * @return 返回医嘱号和医嘱名称
- */
- public ResultVo<List<YzActOrder>> queryYz(YzActOrder param) {
- QueryWrapper<YzActOrder> qw = new QueryWrapper<>();
- log.info("医嘱修改申请查询 --> 医嘱号:{},住院号:{}", param.getActOrderNo(), param.getInpatientNo());
- if (param.getActOrderNo() != null) {
- qw.eq("a.act_order_no", param.getActOrderNo());
- }
- if (StringUtil.notBlank(param.getInpatientNo())) {
- qw.eq("a.inpatient_no", param.getInpatientNo());
- }
- List<YzActOrder> list = dao.listQueryYz(qw);
- if (list.size() > 0) {
- return ResultVoUtil.success(list);
- }
- return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
- }
- /**
- * 提交医嘱修改申请 这里是多个医嘱修改
- *
- * @param param 提交申请的信息
- * @return 返回提示
- */
- public ResultVo<Boolean> yzModifyApply(TYzActOrderModify param) {
- log.info("申请医嘱修改 --> 申请人:{},数据:{}",
- TokenUtil.getTokenUserId(), JSON.toJSONStringWithDateFormat(param, DATE_FORMAT));
- List<TYzActOrderModify> insertList = new ArrayList<>();
- List<TYzActOrderModify> updateList = new ArrayList<>();
- for (TYzActOrderModify pojo : param.getList()) {
- if (dao.chaKansfCunZai(pojo.getActOrderNo()) == 0) {
- insertList.add(pojo);
- } else {
- updateList.add(pojo);
- }
- }
- if (insertList.size() > 0) {
- dao.yzActOrderModifyInsert(param, insertList);
- }
- if (updateList.size() > 0) {
- dao.yzActOrderModifyUpdate(param, updateList);
- }
- //这里是通知有权限的人
- sendMessage();
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "申请成功,已通知审核人员。<br />可以在上方查看审核状态 (•‾̑⌣‾̑•)✧˖°");
- }
- /**
- * 根据 人员的 code 来查看他申请的医嘱
- *
- * @param code 编码
- * @return 返回这个人 申请修改的医嘱
- */
- public ResultVo<List<TYzActOrderModify>> chaKanZhuangTai(String code) {
- log.info("根据人员的code查询医嘱修改申请:{}", code);
- return ResultVoUtil.success(dao.queryZhuangTai(code));
- }
- /**
- * 单个医嘱修改
- *
- * @param param 要修改的信息
- * @return 返回提示成功
- */
- public ResultVo<String> danGeShenQing(TYzActOrderModify param) {
- param.setProposer(TokenUtil.getTokenUserId());
- log.info("申请医嘱修改 --> 申请人:{},数据:{}", param.getProposer(), JSON.toJSONStringWithDateFormat(param, DATE_FORMAT));
- if (dao.chaKansfCunZai(param.getActOrderNo()) == 0) {
- dao.danGeShenQingInsert(param);
- } else {
- dao.danGeShenQingUpdate(param);
- }
- sendMessage();
- return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "申请成功,已通知审核人员。<br />可以在上方查看审核状态 (•‾̑⌣‾̑•)✧˖°");
- }
- /**
- * 通知有医嘱修改审核权限的人
- */
- private void sendMessage() {
- List<String> admins = dao.selectAdmins();
- JSONObject obj = new JSONObject();
- obj.put("name", "systemNotification");
- obj.put("message", String.format("用户【%s】提交了医嘱修改申请,请前往审核页面查看。", dao.getUserName(TokenUtil.getTokenUserId())));
- String message = obj.toJSONString();
- admins.forEach(code -> WebSocketServer.sendMessageByUserCode(code, message));
- }
- }
|