Browse Source

增加摆药机的选择

WANGJIALIANG 3 years ago
parent
commit
0780a95b8e

+ 136 - 97
src/main/java/cn/hnthyy/thmz/controller/yf/YfWardPrescriptionController.java

@@ -9,6 +9,7 @@ import cn.hnthyy.thmz.entity.his.yp.YpBaseYf;
 import cn.hnthyy.thmz.entity.his.yp.YpZdDict;
 import cn.hnthyy.thmz.entity.his.yz.YzYpPageNo;
 import cn.hnthyy.thmz.entity.his.zd.ZdUnitCode;
+import cn.hnthyy.thmz.entity.his.zy.YpZyPatient;
 import cn.hnthyy.thmz.entity.thmz.User;
 import cn.hnthyy.thmz.service.his.ResponceTypeService;
 import cn.hnthyy.thmz.service.his.mz.EmployeeService;
@@ -77,6 +78,7 @@ public class YfWardPrescriptionController {
 
     /**
      * 查询病房请领单
+     *
      * @param yzYpPageNoVo
      * @return
      */
@@ -95,15 +97,15 @@ public class YfWardPrescriptionController {
                 ZdUnitCode zdUnitCode = zdUnitCodeService.queryByCode(yzYpPageNo.getWardCode());
                 yzYpPageNo.setWardName(zdUnitCode.getName());
                 Employee employee;
-                if(StringUtils.isNotBlank(yzYpPageNo.getCancelSubmitName())){
+                if (StringUtils.isNotBlank(yzYpPageNo.getCancelSubmitName())) {
                     employee = employeeService.queryByUserCode(yzYpPageNo.getCancelSubmitName());
                     yzYpPageNo.setCancelSubName(employee.getEmployeeName());
                 }
-                if(StringUtils.isNotBlank(yzYpPageNo.getContirmId())){
+                if (StringUtils.isNotBlank(yzYpPageNo.getContirmId())) {
                     employee = employeeService.queryByUserCode(yzYpPageNo.getContirmId());
                     yzYpPageNo.setContirmName(employee.getEmployeeName());
                 }
-                if(StringUtils.isNotBlank(yzYpPageNo.getSubmitName())){
+                if (StringUtils.isNotBlank(yzYpPageNo.getSubmitName())) {
                     employee = employeeService.queryByUserCode(yzYpPageNo.getSubmitName());
                     yzYpPageNo.setSubName(employee.getEmployeeName());
                 }
@@ -115,7 +117,7 @@ public class YfWardPrescriptionController {
         } catch (Exception e) {
             e.printStackTrace();
             resultMap.put("code", -1);
-            resultMap.put("message", "查询病房请领单列表失败"+e);
+            resultMap.put("message", "查询病房请领单列表失败" + e);
             log.error("查询病房请领单列表失败,系统异常,错误信息{}", e);
             return resultMap;
         }
@@ -123,13 +125,14 @@ public class YfWardPrescriptionController {
 
     /**
      * 查询病房请领单药品汇总
-     *  @param pageNo 药单编码
+     *
+     * @param pageNo    药单编码
      * @param pageClass 药单类型编码
      * @return
      */
     @UserLoginToken
     @RequestMapping(value = "/getZyDrugCount", method = {RequestMethod.GET})
-    public Map<String, Object> getZyDrugCount(@RequestParam String pageNo,@RequestParam String pageClass,@RequestParam Integer submitFlag) {
+    public Map<String, Object> getZyDrugCount(@RequestParam String pageNo, @RequestParam String pageClass, @RequestParam Integer submitFlag) {
         Map<String, Object> resultMap = new HashMap<>();
         try {
             if (StringUtils.isBlank(pageNo) || StringUtils.isBlank(pageClass)) {
@@ -138,15 +141,15 @@ public class YfWardPrescriptionController {
                 return resultMap;
             }
             List<YfWardVo> yfWardVos;
-            if(pageClass.equals("A")){//医技科室领药
+            if (pageClass.equals("A")) {//医技科室领药
                 yfWardVos = yfWardPrescriptionService.queryZyDrug(pageNo, submitFlag);
-            }else{
-                yfWardVos = yfWardPrescriptionService.queryYzYpOrder(pageNo, pageClass.equals("T") ? "1" : "0",submitFlag);
+            } else {
+                yfWardVos = yfWardPrescriptionService.queryYzYpOrder(pageNo, pageClass.equals("T") ? "1" : "0", submitFlag);
             }
             yfWardVos.forEach(yfWardVo -> {
                 YpZdDict ypZdDict = ypZdDictService.queryYpZdDictByCodeAndSerial(yfWardVo.getChargeCode(), yfWardVo.getSerial());
                 YpBaseYf ypBaseYf = ypBaseYfService.queryYpBaseYf(yfWardVo.getChargeCode(), yfWardVo.getSerial(), yfWardVo.getGroupNo());
-                if(ypZdDict.getManuCode() != null){
+                if (ypZdDict.getManuCode() != null) {
                     String manufactory = ypZdManufactoryService.queryYpZdManufactoryByCode(ypZdDict.getManuCode());
                     yfWardVo.setManufactory(manufactory);
                 }
@@ -164,7 +167,7 @@ public class YfWardPrescriptionController {
         } catch (Exception e) {
             e.printStackTrace();
             resultMap.put("code", -1);
-            resultMap.put("message", "查询病房请领单药品汇总失败"+e);
+            resultMap.put("message", "查询病房请领单药品汇总失败" + e);
             log.error("查询病房请领单药品汇总失败,系统异常,错误信息{}", e);
             return resultMap;
         }
@@ -172,26 +175,27 @@ public class YfWardPrescriptionController {
 
     /**
      * 查询病房请领单药品明细
-     *  @param pageNo 药单编码
-     * @param pageClass 药单类型编码
+     *
+     * @param pageNo     药单编码
+     * @param pageClass  药单类型编码
      * @param submitFlag 药单状态
      * @return
      */
     @UserLoginToken
     @RequestMapping(value = "/getZyDrugDetail", method = {RequestMethod.GET})
-    public Map<String, Object> getZyDrugDetail(@RequestParam String pageNo,@RequestParam String pageClass,@RequestParam Integer submitFlag) {
+    public Map<String, Object> getZyDrugDetail(@RequestParam String pageNo, @RequestParam String pageClass, @RequestParam Integer submitFlag) {
         Map<String, Object> resultMap = new HashMap<>();
         try {
             String[] pageNos = pageNo.split("/");
-            if (pageNos.length==0 || StringUtils.isBlank(pageClass)) {
+            if (pageNos.length == 0 || StringUtils.isBlank(pageClass)) {
                 resultMap.put("code", -1);
                 resultMap.put("message", "请领单号和药单类型参数不能为空");
                 return resultMap;
             }
-            List<YfWardVo> yfWardVos = yfWardPrescriptionService.getDetail(pageNo,pageClass,submitFlag==3?"0":"1,3,4");
+            List<YfWardVo> yfWardVos = yfWardPrescriptionService.getDetail(pageNo, pageClass, submitFlag == 3 ? "0" : "1,3,4");
             for (int i = 0; i < yfWardVos.size(); i++) {
                 YfWardVo yfWardVo = yfWardVos.get(i);
-                if(pageClass.equals("5")){
+                if (pageClass.equals("5")) {
                     long now = new Date().getTime();
                     List<String> strings = yzOrderFrequencyService.queryTimeByCode(yfWardVo.getFrequCode());
                     String kssj = "";
@@ -200,27 +204,27 @@ public class YfWardPrescriptionController {
                         String s = strings.get(j);
                         SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
                         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm");
-                        long newD = sdf.parse(sdfDate.format(new Date())+" "+s).getTime();
+                        long newD = sdf.parse(sdfDate.format(new Date()) + " " + s).getTime();
                         int sj = Integer.parseInt(s.split(":")[0]);
-                        if(newD > now){
-                            if(sj >= 12){
-                                if(sj >= 13){
-                                    kssj += sj-12+"p";
-                                }else{
-                                    kssj+=sj+"p";
+                        if (newD > now) {
+                            if (sj >= 12) {
+                                if (sj >= 13) {
+                                    kssj += sj - 12 + "p";
+                                } else {
+                                    kssj += sj + "p";
                                 }
-                            }else{
-                                kssj += sj+"a";
+                            } else {
+                                kssj += sj + "a";
                             }
                         }
-                        if(sj >= 12){
-                            if(sj >= 13){
-                                jssj += sj-12+"p";
-                            }else{
-                                jssj+=sj+"p";
+                        if (sj >= 12) {
+                            if (sj >= 13) {
+                                jssj += sj - 12 + "p";
+                            } else {
+                                jssj += sj + "p";
                             }
-                        }else{
-                            jssj += sj+"a";
+                        } else {
+                            jssj += sj + "a";
                         }
                     }
                     yfWardVo.setKssj(kssj);
@@ -234,7 +238,7 @@ public class YfWardPrescriptionController {
         } catch (Exception e) {
             e.printStackTrace();
             resultMap.put("code", -1);
-            resultMap.put("message", "查询病房请领单药品明细失败"+e);
+            resultMap.put("message", "查询病房请领单药品明细失败" + e);
             log.error("查询病房请领单药品明细失败,系统异常,错误信息{}", e);
             return resultMap;
         }
@@ -243,77 +247,78 @@ public class YfWardPrescriptionController {
 
     /**
      * 查询口服单打印数据
-     *  @param pageNo 药单编码
-     * @param pageClass 药单类型编码
+     *
+     * @param pageNo     药单编码
+     * @param pageClass  药单类型编码
      * @param submitFlag 药单状态
      * @return
      */
     @UserLoginToken
     @RequestMapping(value = "/getOralPrintData", method = {RequestMethod.GET})
-    public Map<String, Object> getOralPrintData(@RequestParam String pageNo,@RequestParam String pageClass,@RequestParam Integer submitFlag) {
+    public Map<String, Object> getOralPrintData(@RequestParam String pageNo, @RequestParam String pageClass, @RequestParam Integer submitFlag) {
         Map<String, Object> resultMap = new HashMap<>();
         try {
             String[] pageNos = pageNo.split("/");
-            if (pageNos.length==0 || StringUtils.isBlank(pageClass)) {
+            if (pageNos.length == 0 || StringUtils.isBlank(pageClass)) {
                 resultMap.put("code", -1);
                 resultMap.put("message", "请领单号和药单类型参数不能为空");
                 return resultMap;
             }
-            List<YfWardVo> yfWardVos = yfWardPrescriptionService.getDetail(pageNo,pageClass,submitFlag==3?"0":"0,1,3,4");
-            Map<String,List<YfWardVo>> results = new HashMap<>();
+            List<YfWardVo> yfWardVos = yfWardPrescriptionService.getDetail(pageNo, pageClass, submitFlag == 3 ? "0" : "0,1,3,4");
+            Map<String, List<YfWardVo>> results = new HashMap<>();
             List<YfWardVo> byjList = new ArrayList<>();
             List<YfWardVo> list = new ArrayList<>();
             //病人单个药品统计
             Map<String, Double> countMap = yfWardVos.stream().collect(Collectors.groupingBy(yfWardVo -> yfWardVo.getInpatientNo()
-                    + "_" + yfWardVo.getChargeCode()+ "_" + yfWardVo.getSerial(), Collectors.summingDouble(YfWardVo::getAmount)));
+                    + "_" + yfWardVo.getChargeCode() + "_" + yfWardVo.getSerial(), Collectors.summingDouble(YfWardVo::getAmount)));
             Map<String, Set<Date>> occTimeMap = yfWardVos.stream().collect(Collectors.groupingBy(yfWardVo -> yfWardVo.getInpatientNo()
-                    + "_" + yfWardVo.getChargeCode()+ "_" + yfWardVo.getSerial(), Collectors.mapping(YfWardVo::getOccTime,Collectors.toSet())));
+                    + "_" + yfWardVo.getChargeCode() + "_" + yfWardVo.getSerial(), Collectors.mapping(YfWardVo::getOccTime, Collectors.toSet())));
             //根据病人药品分组
             Map<String, List<YfWardVo>> groupMap = yfWardVos.stream().collect(Collectors.groupingBy(yfWardVo -> yfWardVo.getInpatientNo()
-                    + "_" + yfWardVo.getChargeCode()+ "_" + yfWardVo.getSerial()));
-            for (List<YfWardVo> y:groupMap.values()) {
+                    + "_" + yfWardVo.getChargeCode() + "_" + yfWardVo.getSerial()));
+            for (List<YfWardVo> y : groupMap.values()) {
                 YfWardVo yfWardVo = y.get(0);
-                yfWardVo.setAmount(countMap.get(yfWardVo.getInpatientNo()+ "_" + yfWardVo.getChargeCode()+ "_" + yfWardVo.getSerial()));
+                yfWardVo.setAmount(countMap.get(yfWardVo.getInpatientNo() + "_" + yfWardVo.getChargeCode() + "_" + yfWardVo.getSerial()));
                 Set<Date> dates = occTimeMap.get(yfWardVo.getInpatientNo() + "_" + yfWardVo.getChargeCode() + "_" + yfWardVo.getSerial());
                 String kssj = "";
                 String jssj = "";
-                for (Date date:dates) {
-                    int h = Integer.parseInt(DateUtil.pase(date,"yyyy-MM-dd HH:mm").toString().substring(11,13));
-                    Date d = DateUtil.pase(date,"yyyy-MM-dd");
-                    Date performanceDate = DateUtil.pase(yfWardVo.getPerformanceTime(),"yyyy-MM-dd");
-                    if(h >= 12){
-                        if(h >= 13){
-                            if(d.getTime()==performanceDate.getTime()){
-                                kssj+=h-12+"p";
-                            }else{
-                                jssj+=h-12+"p";
+                for (Date date : dates) {
+                    int h = Integer.parseInt(DateUtil.pase(date, "yyyy-MM-dd HH:mm").toString().substring(11, 13));
+                    Date d = DateUtil.pase(date, "yyyy-MM-dd");
+                    Date performanceDate = DateUtil.pase(yfWardVo.getPerformanceTime(), "yyyy-MM-dd");
+                    if (h >= 12) {
+                        if (h >= 13) {
+                            if (d.getTime() == performanceDate.getTime()) {
+                                kssj += h - 12 + "p";
+                            } else {
+                                jssj += h - 12 + "p";
                             }
-                        }else{
-                            if(d.getTime()==performanceDate.getTime()){
-                                kssj += h+"p";
-                            }else{
-                                jssj += h+"p";
+                        } else {
+                            if (d.getTime() == performanceDate.getTime()) {
+                                kssj += h + "p";
+                            } else {
+                                jssj += h + "p";
                             }
                         }
-                    }else{
-                        if(d.getTime()==performanceDate.getTime()){
-                            kssj += h+"a";
-                        }else{
-                            jssj += h+"a";
+                    } else {
+                        if (d.getTime() == performanceDate.getTime()) {
+                            kssj += h + "a";
+                        } else {
+                            jssj += h + "a";
                         }
                     }
                 }
                 yfWardVo.setKssj(kssj);
                 yfWardVo.setJssj(jssj);
                 yfWardVo.setPerformanceTime(yfWardVo.getPerformanceTime());
-                if(yfWardVo.getByjFlag() == 0){
+                if (yfWardVo.getByjFlag() == 0) {
                     list.add(yfWardVo);
-                }else{
+                } else {
                     byjList.add(yfWardVo);
                 }
             }
-            results.put("byjList",byjList.stream().sorted(Comparator.comparing(YfWardVo::getInpatientNo)).collect(Collectors.toList()));
-            results.put("list",list.stream().sorted(Comparator.comparing(YfWardVo::getInpatientNo)).collect(Collectors.toList()));
+            results.put("byjList", byjList.stream().sorted(Comparator.comparing(YfWardVo::getInpatientNo)).collect(Collectors.toList()));
+            results.put("list", list.stream().sorted(Comparator.comparing(YfWardVo::getInpatientNo)).collect(Collectors.toList()));
             resultMap.put("code", 0);
             resultMap.put("message", "查询病房请领单药品明细信息成功");
             resultMap.put("data", results);
@@ -321,7 +326,7 @@ public class YfWardPrescriptionController {
         } catch (Exception e) {
             e.printStackTrace();
             resultMap.put("code", -1);
-            resultMap.put("message", "查询病房请领单药品明细失败"+e);
+            resultMap.put("message", "查询病房请领单药品明细失败" + e);
             log.error("查询病房请领单药品明细失败,系统异常,错误信息{}", e);
             return resultMap;
         }
@@ -329,16 +334,17 @@ public class YfWardPrescriptionController {
 
     /**
      * 查询病房近期(三天)请领单药品汇总
-     * @param groupNo 药房编码
-     * @param pageNo 药单号
-     *  @param wardCode 病室编码
+     *
+     * @param groupNo   药房编码
+     * @param pageNo    药单号
+     * @param wardCode  病室编码
      * @param pageClass 药单类型编码
      * @return
      */
     @UserLoginToken
     @RequestMapping(value = "/getYzYpOrderWard", method = {RequestMethod.GET})
-    public Map<String, Object> getYzYpOrderWard(@RequestParam String groupNo,@RequestParam String pageNo
-            ,@RequestParam String wardCode,@RequestParam String pageClass) {
+    public Map<String, Object> getYzYpOrderWard(@RequestParam String groupNo, @RequestParam String pageNo
+            , @RequestParam String wardCode, @RequestParam String pageClass) {
         Map<String, Object> resultMap = new HashMap<>();
         try {
             if (StringUtils.isBlank(wardCode) || StringUtils.isBlank(pageClass)) {
@@ -356,7 +362,7 @@ public class YfWardPrescriptionController {
                 resultMap.put("message", "药单号参数不能为空");
                 return resultMap;
             }
-            YzYpPageNo yzYpPageNo= yfWardPrescriptionService.queryYzYpPageNoByPageNo(pageNo);
+            YzYpPageNo yzYpPageNo = yfWardPrescriptionService.queryYzYpPageNoByPageNo(pageNo);
             List<YfWardVo> yfWardVos = yfWardPrescriptionService.queryYzYpOrderWard(groupNo, yzYpPageNo.getWardCode(), pageClass);
             yfWardVos.forEach(yfWardVo -> {
                 YpZdDict ypZdDict = ypZdDictService.queryYpZdDictByCodeAndSerial(yfWardVo.getChargeCode(), yfWardVo.getSerial());
@@ -373,13 +379,13 @@ public class YfWardPrescriptionController {
             String pageNos = yfWardPrescriptionService.queryYzYpPageNoStr(groupNo, wardCode, pageClass);
             resultMap.put("code", 0);
             resultMap.put("message", "查询病房近期(三天)请领单药品汇总信息成功");
-            resultMap.put("data", yfWardVos.stream().sorted(Comparator.comparing(YfWardVo::getLocation,Comparator.nullsLast(String::compareTo))).collect(Collectors.toList()));
+            resultMap.put("data", yfWardVos.stream().sorted(Comparator.comparing(YfWardVo::getLocation, Comparator.nullsLast(String::compareTo))).collect(Collectors.toList()));
             resultMap.put("pageNos", pageNos);
             return resultMap;
         } catch (Exception e) {
             e.printStackTrace();
             resultMap.put("code", -1);
-            resultMap.put("message", "查询病房近期(三天)请领单药品汇总失败"+e);
+            resultMap.put("message", "查询病房近期(三天)请领单药品汇总失败" + e);
             log.error("查询病房近期(三天)请领单药品汇总失败,系统异常,错误信息{}", e);
             return resultMap;
         }
@@ -387,15 +393,16 @@ public class YfWardPrescriptionController {
 
     /**
      * 查询病房近期(三天)请领单药品汇总
-     * @param groupNo 药房编码
-     *  @param wardCode 病室编码
+     *
+     * @param groupNo   药房编码
+     * @param wardCode  病室编码
      * @param pageClass 药单类型编码
      * @return
      */
     @UserLoginToken
     @RequestMapping(value = "/queryYzYpPageNoStr", method = {RequestMethod.GET})
-    public Map<String, Object> queryYzYpPageNoStr(@RequestParam String groupNo,@RequestParam String wardCode
-            ,@RequestParam String pageClass) {
+    public Map<String, Object> queryYzYpPageNoStr(@RequestParam String groupNo, @RequestParam String wardCode
+            , @RequestParam String pageClass) {
         Map<String, Object> resultMap = new HashMap<>();
         try {
             if (StringUtils.isBlank(wardCode) || StringUtils.isBlank(pageClass)) {
@@ -416,7 +423,7 @@ public class YfWardPrescriptionController {
         } catch (Exception e) {
             e.printStackTrace();
             resultMap.put("code", -1);
-            resultMap.put("message", "查询三天内同病室的请领单号('/'号拼接)失败"+e);
+            resultMap.put("message", "查询三天内同病室的请领单号('/'号拼接)失败" + e);
             log.error("查询三天内同病室的请领单号('/'号拼接)失败,系统异常,错误信息{}", e);
             return resultMap;
         }
@@ -424,6 +431,7 @@ public class YfWardPrescriptionController {
 
     /**
      * 领药单确认发药
+     *
      * @param yfSendWardVo
      * @return
      */
@@ -433,40 +441,70 @@ public class YfWardPrescriptionController {
         Map<String, Object> resultMap = new HashMap<>();
         User tokenUser = TokenUtil.getUser(httpServletRequest);
         try {
-            if(yfSendWardVo.getYzYpZyOrders().size() == 0){
+            if (yfSendWardVo.getYzYpZyOrders().size() == 0) {
                 resultMap.put("code", -1);
                 resultMap.put("message", "保存领药单发药数据失败,可保存数据为空");
                 return resultMap;
             }
-            return yfWardPrescriptionService.sendWard(yfSendWardVo.getYzYpZyOrders(),yfSendWardVo.getPageNo(),tokenUser.getUserIdCode());
+            return yfWardPrescriptionService.sendWard(yfSendWardVo.getYzYpZyOrders(), yfSendWardVo.getPageNo(), tokenUser.getUserIdCode());
         } catch (Exception e) {
             e.printStackTrace();
             resultMap.put("code", -1);
-            resultMap.put("message", "保存领药单发药数据失败"+e);
+            resultMap.put("message", "保存领药单发药数据失败" + e);
             log.error("保存领药单发药数据失败,系统异常,错误信息{}", e);
             return resultMap;
         }
     }
 
+    /**
+     * 使用摆药机
+     *
+     * @param ypZyPatients
+     * @return
+     */
+    @UserLoginToken
+    @RequestMapping(value = "/savePrescriptionByj", method = {RequestMethod.POST})
+    public Map<String, Object> savePrescriptionByj(@RequestBody List<YpZyPatient> ypZyPatients) {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            if (yfWardPrescriptionService.savePrescription(ypZyPatients) > 0) {
+                resultMap.put("code", 0);
+                resultMap.put("message", "使用摆药机成功");
+            } else {
+                resultMap.put("code", -1);
+                resultMap.put("message", "使用摆药机失败");
+            }
+            return resultMap;
+        } catch (Exception e) {
+            e.printStackTrace();
+            resultMap.put("code", -1);
+            resultMap.put("message", "使用摆药机失败" + e);
+            log.error("使用摆药机失败,系统异常,错误信息{}", e);
+            return resultMap;
+        }
+    }
+
 
     /**
      * 查询打印口服药品标签数据
-     *  @param pageNo 药单编码
+     *
+     * @param pageNo     药单编码
      * @param submitFlag 药单状态
+     * @param isByj      是否使用摆药机,是就去除摆药机已打印的药品数据
      * @return
      */
     @UserLoginToken
     @RequestMapping(value = "/getLabelPrintDatas", method = {RequestMethod.GET})
-    public Map<String, Object> getLabelPrintDatas(@RequestParam String pageNo,@RequestParam Integer submitFlag) {
+    public Map<String, Object> getLabelPrintDatas(@RequestParam String pageNo, @RequestParam Integer submitFlag, @RequestParam Integer isByj) {
         Map<String, Object> resultMap = new HashMap<>();
         try {
             String[] pageNos = pageNo.split("/");
-            if (pageNos.length==0) {
+            if (pageNos.length == 0) {
                 resultMap.put("code", -1);
                 resultMap.put("message", "请领单号参数不能为空");
                 return resultMap;
             }
-            List<YfWardVo> yfWardVos = yfWardPrescriptionService.getLabelPrintDatas(pageNo,submitFlag);
+            List<YfWardVo> yfWardVos = yfWardPrescriptionService.getLabelPrintDatas(pageNo, submitFlag, isByj);
             resultMap.put("code", 0);
             resultMap.put("message", "查询打印口服药品标签数据成功");
             resultMap.put("data", yfWardVos);
@@ -474,20 +512,21 @@ public class YfWardPrescriptionController {
         } catch (Exception e) {
             e.printStackTrace();
             resultMap.put("code", -1);
-            resultMap.put("message", "查询打印口服药品标签数据失败"+e);
+            resultMap.put("message", "查询打印口服药品标签数据失败" + e);
             log.error("查询打印口服药品标签数据失败,系统异常,错误信息{}", e);
             return resultMap;
         }
     }
 
     /**
-     *  药单撤销提交
-     *  @param pageNo 药单编码
+     * 药单撤销提交
+     *
+     * @param pageNo 药单编码
      * @return
      */
     @UserLoginToken
     @RequestMapping(value = "/cancelWardPrescriptionSubmit", method = {RequestMethod.GET})
-    public Map<String, Object> cancelWardPrescriptionSubmit(@RequestParam String pageNo,@RequestParam String pageClass, HttpServletRequest httpServletRequest) throws MzException {
+    public Map<String, Object> cancelWardPrescriptionSubmit(@RequestParam String pageNo, @RequestParam String pageClass, HttpServletRequest httpServletRequest) throws MzException {
         Map<String, Object> resultMap = new HashMap<>();
         User tokenUser = TokenUtil.getUser(httpServletRequest);
         try {
@@ -501,10 +540,10 @@ public class YfWardPrescriptionController {
                 resultMap.put("message", "药单类型参数不能为空");
                 return resultMap;
             }
-            if(yfWardPrescriptionService.cancelWardPrescriptionSubmit(pageNo,pageClass,tokenUser.getUserIdCode()) == 1){
+            if (yfWardPrescriptionService.cancelWardPrescriptionSubmit(pageNo, pageClass, tokenUser.getUserIdCode()) == 1) {
                 resultMap.put("code", 0);
                 resultMap.put("message", "药单撤销提交成功");
-            }else{
+            } else {
                 resultMap.put("code", -1);
                 resultMap.put("message", "药单撤销提交失败");
             }
@@ -512,7 +551,7 @@ public class YfWardPrescriptionController {
         } catch (Exception e) {
             e.printStackTrace();
             resultMap.put("code", -1);
-            resultMap.put("message", "药单撤销提交失败"+e);
+            resultMap.put("message", "药单撤销提交失败" + e);
             log.error("药单撤销提交失败,系统异常,错误信息{}", e);
             return resultMap;
         }

+ 10 - 1
src/main/java/cn/hnthyy/thmz/service/his/yf/YfWardPrescriptionService.java

@@ -3,6 +3,7 @@ package cn.hnthyy.thmz.service.his.yf;
 import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.his.yz.YzYpPageNo;
 import cn.hnthyy.thmz.entity.his.yz.YzYpZyOrder;
+import cn.hnthyy.thmz.entity.his.zy.YpZyPatient;
 import cn.hnthyy.thmz.vo.YfWardVo;
 import cn.hnthyy.thmz.vo.YzYpPageNoVo;
 
@@ -88,6 +89,13 @@ public interface YfWardPrescriptionService {
      */
     Map<String, Object> sendWard(List<YzYpZyOrder> yzYpZyOrders,String pageNo,String userCode) throws MzException;
 
+    /**
+     * 确认发药插入摆药机中间表
+     * @param ypZyPatients
+     * @return
+     */
+    int savePrescription(List<YpZyPatient> ypZyPatients);
+
     /**
      * 查询药单详细
      * @param pageNo
@@ -101,9 +109,10 @@ public interface YfWardPrescriptionService {
      * 查询口服药标签打印数据
      * @param pageNo
      * @param submitFlag
+     * @param isByj
      * @return
      */
-    List<YfWardVo> getLabelPrintDatas(String pageNo, Integer submitFlag);
+    List<YfWardVo> getLabelPrintDatas(String pageNo, Integer submitFlag, Integer isByj);
 
     /**
      * 撤销提交请领单

+ 111 - 112
src/main/java/cn/hnthyy/thmz/service/impl/his/yf/YfWardPrescriptionServiceImpl.java

@@ -99,12 +99,12 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
     private ZyDetailChargeMapper zyDetailChargeMapper;
 
     @Override
-    public List<YzYpPageNoVo> queryYzYpPageNo(YzYpPageNoVo yzYpPageNoVo){
+    public List<YzYpPageNoVo> queryYzYpPageNo(YzYpPageNoVo yzYpPageNoVo) {
         List<YzYpPageNoVo> yzYpPageNoVos = new ArrayList<>();
         List<YzYpPageNo> yzYpPageNos = yzYpPageNoMapper.selectYzYpPageNo(yzYpPageNoVo);
         yzYpPageNos.forEach(yzYpPageNo -> {
             YzYpPageNoVo vo = new YzYpPageNoVo();
-            BeanUtils.copyProperties(yzYpPageNo,vo);
+            BeanUtils.copyProperties(yzYpPageNo, vo);
             yzYpPageNoVos.add(vo);
         });
         return yzYpPageNoVos;
@@ -117,25 +117,25 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
 
     @Override
     public String queryYzYpPageNoStr(String groupNo, String wardCode, String pageClass) {
-        String reslutStr="";
+        String reslutStr = "";
         String[] strings = yzYpPageNoMapper.selectYzYpPageNos(groupNo, wardCode, pageClass);
         for (int i = 0; i < strings.length; i++) {
-            if(i==0){
-                reslutStr=strings[i];
-            }else{
-                reslutStr+="/"+strings[i];
+            if (i == 0) {
+                reslutStr = strings[i];
+            } else {
+                reslutStr += "/" + strings[i];
             }
         }
         return reslutStr;
     }
 
     @Override
-    public List<YfWardVo> queryZyDrug(String pageNo,Integer submitFlag) {
+    public List<YfWardVo> queryZyDrug(String pageNo, Integer submitFlag) {
         List<YfWardVo> yfWardVos = new ArrayList<>();
-        List<ZyDrug> zyDrugs = zyDrugMapper.selectZyDrugByPageNo(pageNo, submitFlag==3?"1":"0");
+        List<ZyDrug> zyDrugs = zyDrugMapper.selectZyDrugByPageNo(pageNo, submitFlag == 3 ? "1" : "0");
         zyDrugs.forEach(zyDrug -> {
             YfWardVo vo = new YfWardVo();
-            BeanUtils.copyProperties(zyDrug,vo);
+            BeanUtils.copyProperties(zyDrug, vo);
             yfWardVos.add(vo);
         });
         return yfWardVos;
@@ -144,10 +144,10 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
     @Override
     public List<YfWardVo> queryZyDrugDetail(String pageNo, String submitFlag) {
         List<YfWardVo> yfWardVos = new ArrayList<>();
-        List<ZyDrug> zyDrugs = zyDrugMapper.selectZyDrugDetailByPageNo(pageNo,submitFlag.equals("0")?"1":null);//通过普通药单的状态去调整医技明细状态查询
+        List<ZyDrug> zyDrugs = zyDrugMapper.selectZyDrugDetailByPageNo(pageNo, submitFlag.equals("0") ? "1" : null);//通过普通药单的状态去调整医技明细状态查询
         zyDrugs.forEach(zyDrug -> {
             YfWardVo vo = new YfWardVo();
-            BeanUtils.copyProperties(zyDrug,vo);
+            BeanUtils.copyProperties(zyDrug, vo);
             vo.setOccTime(zyDrug.getChargeDate());
             yfWardVos.add(vo);
         });
@@ -158,31 +158,31 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
     public List<YfWardVo> queryYzYpOrder(String pageNo, String isTy, Integer submitFlag) {
         List<YfWardVo> yfWardVos = new ArrayList<>();
         List<YzYpZyOrder> yzYpZyOrders;
-        if("1".equals(isTy)){
-            yzYpZyOrders = yzYpZyOrderMapper.selectYzYpOrderTy(pageNo,submitFlag==3?"0":"1,3,4");
-        }else{
-            yzYpZyOrders = yzYpZyOrderMapper.selectYzYpOrderFy(pageNo,submitFlag==3?"0":"1,3,4");
+        if ("1".equals(isTy)) {
+            yzYpZyOrders = yzYpZyOrderMapper.selectYzYpOrderTy(pageNo, submitFlag == 3 ? "0" : "1,3,4");
+        } else {
+            yzYpZyOrders = yzYpZyOrderMapper.selectYzYpOrderFy(pageNo, submitFlag == 3 ? "0" : "1,3,4");
         }
         yzYpZyOrders.forEach(yzYpZyOrder -> {
             YfWardVo vo = new YfWardVo();
-            BeanUtils.copyProperties(yzYpZyOrder,vo);
+            BeanUtils.copyProperties(yzYpZyOrder, vo);
             yfWardVos.add(vo);
         });
         return yfWardVos;
     }
 
     @Override
-    public List<YfWardVo> queryYzYpOrderDetail(String pageNo, String isTy, String submitFlag){
+    public List<YfWardVo> queryYzYpOrderDetail(String pageNo, String isTy, String submitFlag) {
         List<YfWardVo> yfWardVos = new ArrayList<>();
         List<YzYpZyOrder> yzYpZyOrders;
-        if("1".equals(isTy)){
-            yzYpZyOrders = yzYpZyOrderMapper.selectYzYpOrderTyDetail(pageNo,submitFlag);//0:已发药
-        }else{
-            yzYpZyOrders = yzYpZyOrderMapper.selectYzYpOrderFyDetail(pageNo,submitFlag);
+        if ("1".equals(isTy)) {
+            yzYpZyOrders = yzYpZyOrderMapper.selectYzYpOrderTyDetail(pageNo, submitFlag);//0:已发药
+        } else {
+            yzYpZyOrders = yzYpZyOrderMapper.selectYzYpOrderFyDetail(pageNo, submitFlag);
         }
         yzYpZyOrders.forEach(yzYpZyOrder -> {
             YfWardVo vo = new YfWardVo();
-            BeanUtils.copyProperties(yzYpZyOrder,vo);
+            BeanUtils.copyProperties(yzYpZyOrder, vo);
             yfWardVos.add(vo);
         });
         return yfWardVos;
@@ -194,7 +194,7 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
         List<YzYpZyOrder> yzYpZyOrders = yzYpZyOrderMapper.selectYzYpOrderWard(groupNo, wardCode, pageClass);
         yzYpZyOrders.forEach(yzYpZyOrder -> {
             YfWardVo vo = new YfWardVo();
-            BeanUtils.copyProperties(yzYpZyOrder,vo);
+            BeanUtils.copyProperties(yzYpZyOrder, vo);
             yfWardVos.add(vo);
         });
         return yfWardVos;
@@ -202,65 +202,65 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
-    public Map<String, Object> sendWard(List<YzYpZyOrder> yzYpZyOrders,String pageNo,String userCode) throws MzException {
+    public Map<String, Object> sendWard(List<YzYpZyOrder> yzYpZyOrders, String pageNo, String userCode) throws MzException {
         Map<String, Object> resultMap = new HashMap<>();
         String[] pageNos = pageNo.split("/");
         List<YzYpZyOrder> yyzos;
-        int count =0;
+        int count = 0;
         for (int j = 0; j < pageNos.length; j++) {
             List<YpZyPatient> ypZyPatients = new ArrayList<>();
             String pageNoStr = pageNos[j];
-            if(yzYpZyOrders.get(0).getPageClass().equals("A")){//医技药单
+            if (yzYpZyOrders.get(0).getPageClass().equals("A")) {//医技药单
                 count = zyDrugMapper.selectDrugCountByPageNo(pageNoStr);
-            }else if(!yzYpZyOrders.get(0).getPageClass().equals("T")){
+            } else if (!yzYpZyOrders.get(0).getPageClass().equals("T")) {
                 count = yzYpZyOrderMapper.selectDrugCountByPageNo(Integer.parseInt(pageNoStr));
             }
-            if(StringUtils.isBlank(yzYpZyOrders.get(0).getName())){//判断前端传值是否为明细
+            if (StringUtils.isBlank(yzYpZyOrders.get(0).getName())) {//判断前端传值是否为明细
                 List<YfWardVo> yfWardVos = getDetail(pageNoStr, yzYpZyOrders.get(0).getPageClass(), "1,3,4");
                 List<YzYpZyOrder> yyzo = new ArrayList<>();
                 Set<String> chargeCodes = yzYpZyOrders.parallelStream().map(YzYpZyOrder::getChargeCode).distinct().collect(Collectors.toSet());
-                Set<String> zeroChargeCodes = yzYpZyOrders.parallelStream().filter(yzYpZyOrder -> yzYpZyOrder.getAmount()==0).map(YzYpZyOrder::getChargeCode).distinct().collect(Collectors.toSet());
+                Set<String> zeroChargeCodes = yzYpZyOrders.parallelStream().filter(yzYpZyOrder -> yzYpZyOrder.getAmount() == 0).map(YzYpZyOrder::getChargeCode).distinct().collect(Collectors.toSet());
                 for (int i = 0; i < yfWardVos.size(); i++) {
-                    if(!chargeCodes.contains(yfWardVos.get(i).getChargeCode())){
+                    if (!chargeCodes.contains(yfWardVos.get(i).getChargeCode())) {
                         yfWardVos.remove(i);
                         i--;
-                    }else{
+                    } else {
                         YzYpZyOrder yzYpZyOrder = new YzYpZyOrder();
-                        BeanUtils.copyProperties(yfWardVos.get(i),yzYpZyOrder);
+                        BeanUtils.copyProperties(yfWardVos.get(i), yzYpZyOrder);
                         yzYpZyOrder.setOldAmount(yzYpZyOrder.getAmount());
-                        if(zeroChargeCodes.contains(yfWardVos.get(i).getChargeCode())){
+                        if (zeroChargeCodes.contains(yfWardVos.get(i).getChargeCode())) {
                             yzYpZyOrder.setAmount(0);
                         }
                         yyzo.add(yzYpZyOrder);
                     }
                 }
                 yyzos = yyzo;
-            }else{
+            } else {
                 yyzos = yzYpZyOrders;
             }
             int i = 0;
-            for ( ; i < yyzos.size(); i++) {//传发药和拒发到后台,合计等于药单总数时删除药单
+            for (; i < yyzos.size(); i++) {//传发药和拒发到后台,合计等于药单总数时删除药单
                 YzYpZyOrder yzYpZyOrder = yyzos.get(i);
                 YpZyPatient ypZyPatient = new YpZyPatient();
-                BeanUtils.copyProperties(yzYpZyOrder,ypZyPatient);
-                if(ypZyPatient.getAlwaysFlag()==null){
+                BeanUtils.copyProperties(yzYpZyOrder, ypZyPatient);
+                if (ypZyPatient.getAlwaysFlag() == null) {
                     ypZyPatient.setAlwaysFlag("");
                 }
                 ypZyPatient.setOrderDate(yzYpZyOrder.getOccTime());
                 ypZyPatient.setSectionCode("");
-                if(yzYpZyOrder.getPageClass().equals("A")){
+                if (yzYpZyOrder.getPageClass().equals("A")) {
                     ypZyPatient.setAcctSign("2");
-                }else{
-                    ypZyPatient.setAcctSign(yzYpZyOrder.getAmount()==0?"2":"0");
+                } else {
+                    ypZyPatient.setAcctSign(yzYpZyOrder.getAmount() == 0 ? "2" : "0");
                 }
-                ypZyPatient.setOutSeri(i+1);
+                ypZyPatient.setOutSeri(i + 1);
                 ypZyPatient.setKeeper(userCode);
                 ypZyPatient.setTotalFlag("");
                 ypZyPatient.setConfirmTime(new Date());
                 ypZyPatient.setJyFlag("0");
                 ypZyPatient.setPageType(yzYpZyOrder.getPageClass());
                 String supplyCode = "";
-                switch (yzYpZyOrder.getPageClass()){
+                switch (yzYpZyOrder.getPageClass()) {
                     case "1":
                         supplyCode = "c";
                         break;
@@ -291,14 +291,14 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
                         supplyCode = "t";
                         break;
                 }
-                if(yzYpZyOrder.getAmount()==0){//拒发
+                if (yzYpZyOrder.getAmount() == 0) {//拒发
                     supplyCode = "w";
                 }
                 ypZyPatient.setSupplyCode(supplyCode);
-                if(yzYpZyOrder.getPageClass().equals("4") || yzYpZyOrder.getPageClass().equals("3")){//基数药、大输液
+                if (yzYpZyOrder.getPageClass().equals("4") || yzYpZyOrder.getPageClass().equals("3")) {//基数药、大输液
                     ypZyPatientMapper.updateYpZyPatient(ypZyPatient);
-                }else{
-                    if(yzYpZyOrder.getPageClass().equals("A")){//医技
+                } else {
+                    if (yzYpZyOrder.getPageClass().equals("A")) {//医技
                         ZyDetailCharge zyDetailCharge = new ZyDetailCharge();
                         zyDetailCharge.setInpatientNo(ypZyPatient.getInpatientNo());
                         zyDetailCharge.setAdmissTimes(ypZyPatient.getAdmissTimes());
@@ -306,52 +306,48 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
                         zyDetailCharge.setChargeDate(ypZyPatient.getOrderDate());
                         List<ZyDetailCharge> zyDetailCharges = zyDetailChargeMapper.selectZyDetailChargeList(zyDetailCharge);
                         String zySerialNo = "";
-                        if(zyDetailCharges.size() >0){
+                        if (zyDetailCharges.size() > 0) {
                             zySerialNo = zyDetailCharges.get(0).getZySerialNo();
-                        }else{
+                        } else {
                             log.info("未查询到该病人的住院流水号[{}]", JSONObject.valueToString(zyDetailCharge));
                         }
                         ypZyPatient.setZySerialNo(zySerialNo);
                         String execUnit = zyDrugMapper.selectExecUnitPageNo(pageNoStr);
                         ypZyPatient.setSectionCode(execUnit);
-                    }else{
-                        if(ypZyPatient.getAmount() != 0){
+                    } else {
+                        if (ypZyPatient.getAmount() != 0) {
                             ypZyPatients.add(ypZyPatient);
                         }
                     }
                     ypZyPatientMapper.insertYpZyPatient(ypZyPatient);
                 }
-                if(ypZyPatient.getAmount() != 0){
-                    if(1 != ypBaseYfMapper.updateStockAmount(ypZyPatient.getChargeCode(), ypZyPatient.getSerial()
-                            ,ypZyPatient.getGroupNo(), -ypZyPatient.getAmount(), BigDecimal.valueOf(-ypZyPatient.getAmount() * ypZyPatient.getRetprice()))){
+                if (ypZyPatient.getAmount() != 0) {
+                    if (1 != ypBaseYfMapper.updateStockAmount(ypZyPatient.getChargeCode(), ypZyPatient.getSerial()
+                            , ypZyPatient.getGroupNo(), -ypZyPatient.getAmount(), BigDecimal.valueOf(-ypZyPatient.getAmount() * ypZyPatient.getRetprice()))) {
                         throw new MzException("保存住院病人发药记录失败,更新库存异常");
                     }
-
                 }
-                if(yzYpZyOrder.getPageClass().equals("A")){//医技药单
-                    if(0 == zyDrugMapper.updateZyDrugConfirm(ypZyPatient.getAmount()==0?"2":"1",userCode,ypZyPatient.getAmount()==0?"2":"1",yzYpZyOrder.getInpatientNo(),yzYpZyOrder.getAdmissTimes(),yzYpZyOrder.getLedgerSn(),yzYpZyOrder.getDetailSn())){
+                if (yzYpZyOrder.getPageClass().equals("A")) {//医技药单
+                    if (0 == zyDrugMapper.updateZyDrugConfirm(ypZyPatient.getAmount() == 0 ? "2" : "1", userCode, ypZyPatient.getAmount() == 0 ? "2" : "1", yzYpZyOrder.getInpatientNo(), yzYpZyOrder.getAdmissTimes(), yzYpZyOrder.getLedgerSn(), yzYpZyOrder.getDetailSn())) {
                         throw new MzException("保存住院病人发药记录失败,修改医技药品发药状态异常");
                     }
-                }else{
+                } else {
                     YzYpZyOrder y = new YzYpZyOrder();
-                    y.setStatusFlag(ypZyPatient.getAmount()==0?"2":"0");
+                    y.setStatusFlag(ypZyPatient.getAmount() == 0 ? "2" : "0");
                     y.setInpatientNo(yzYpZyOrder.getInpatientNo());
                     y.setActOrderNo(yzYpZyOrder.getActOrderNo());
                     y.setChargeCode(yzYpZyOrder.getChargeCode());
                     y.setOccTime(yzYpZyOrder.getOccTime());
-                    if(1 != yzYpZyOrderMapper.updateStatusFlag(y)){
+                    if (1 != yzYpZyOrderMapper.updateStatusFlag(y)) {
                         throw new MzException("保存住院病人发药记录失败,修改医嘱药品发药状态异常");
                     }
                 }
             }
-            /*if(ypZyPatients.size() > 0){
-                saveZyDetailCharge(ypZyPatients);
-            }*/
-            if (yzYpZyOrders.get(0).getPageClass().equals("5") || yzYpZyOrders.get(0).getPageClass().equals("6")){
-                savePrescription(ypZyPatients);
+            if (i == count || yzYpZyOrders.get(0).getPageClass().equals("T")) {
+                yzYpPageNoMapper.updateYzYpPageNo(Integer.parseInt(pageNoStr), 3, userCode);
             }
-            if(i == count || yzYpZyOrders.get(0).getPageClass().equals("T")){
-                yzYpPageNoMapper.updateYzYpPageNo(Integer.parseInt(pageNoStr), 3,userCode);
+            if (yzYpZyOrders.get(0).getPageClass().equals("5") || yzYpZyOrders.get(0).getPageClass().equals("6")) {
+                resultMap.put("data", ypZyPatients);
             }
         }
         resultMap.put("code", 0);
@@ -361,9 +357,10 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
 
     /**
      * 确认发药费用上账
+     *
      * @param ypZyPatients
      */
-    public void saveZyDetailCharge(List<YpZyPatient> ypZyPatients){
+    public void saveZyDetailCharge(List<YpZyPatient> ypZyPatients) {
         List<ZyDetailCharge> zyDetailCharges = new ArrayList<>();
         int maxDetailSn = zyDetailChargeMapper.selectMaxDetailSn(ypZyPatients.get(0).getInpatientNo(), ypZyPatients.get(0).getAdmissTimes());
         for (YpZyPatient ypZyPatient : ypZyPatients) {
@@ -375,15 +372,15 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
             zyDetailCharge.setDetailSn(maxDetailSn);
             zyDetailCharge.setChargeDate(ypZyPatient.getOrderDate());
             zyDetailCharge.setOpIdCode(ypZyPatient.getDrawer());
-            YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(ypZyPatient.getChargeCode(),ypZyPatient.getSerial());
+            YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(ypZyPatient.getChargeCode(), ypZyPatient.getSerial());
             zyDetailCharge.setChargeCode(Constants.BILL_ITEM_CODE_prev + ypZdDict.getBillItemZy().substring(1));
-            zyDetailCharge.setInfantFlag(ypZyPatient.getInpatientNo().indexOf("$")==-1?"0":"1");
+            zyDetailCharge.setInfantFlag(ypZyPatient.getInpatientNo().indexOf("$") == -1 ? "0" : "1");
             zyDetailCharge.setChargeStatus("2");
-            zyDetailCharge.setChargeAmount(ypZyPatient.getAmount()+"");
-            zyDetailCharge.setChargeFee((ypZyPatient.getAmount()*ypZyPatient.getRetprice())+"");
-            zyDetailCharge.setSelfFlag(ypZdDict.getSelfFlag()==null?"0":ypZdDict.getSelfFlag());
-            zyDetailCharge.setSeparateFlag(ypZdDict.getSeparateFlag()==null?"0":ypZdDict.getSeparateFlag());
-            zyDetailCharge.setSuppressFlag(ypZdDict.getSupriceFlag()==null?"0":ypZdDict.getSupriceFlag());
+            zyDetailCharge.setChargeAmount(ypZyPatient.getAmount() + "");
+            zyDetailCharge.setChargeFee((ypZyPatient.getAmount() * ypZyPatient.getRetprice()) + "");
+            zyDetailCharge.setSelfFlag(ypZdDict.getSelfFlag() == null ? "0" : ypZdDict.getSelfFlag());
+            zyDetailCharge.setSeparateFlag(ypZdDict.getSeparateFlag() == null ? "0" : ypZdDict.getSeparateFlag());
+            zyDetailCharge.setSuppressFlag(ypZdDict.getSupriceFlag() == null ? "0" : ypZdDict.getSupriceFlag());
             YzActOrder yzActOrder = yzActOrderMapper.selectYzActOrderByActOrderNo(ypZyPatient.getActOrderNo());
             ZyActpatient zyActpatient = zyActpatientMapper.selectByInpatientNo("zy_actpatient", ypZyPatient.getInpatientNo(), ypZyPatient.getAdmissTimes());
             zyDetailCharge.setWardCode(zyActpatient.getZkWard());
@@ -405,22 +402,24 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
 
     /**
      * 确认发药插入摆药机中间表
+     *
      * @param ypZyPatients
      * @return
      */
-    public void savePrescription(List<YpZyPatient> ypZyPatients) {
+    public int savePrescription(List<YpZyPatient> ypZyPatients) {
+        int flag = 0;
         int seqNo = 0;
         for (int i = 0; i < ypZyPatients.size(); i++) {
             Prescription prescription = new Prescription();
             YpZyPatient ypZyPatient = ypZyPatients.get(i);
-            if(ypZyPatient.getDrugClass().equals("d")){
+            if (ypZyPatient.getDrugClass().equals("d")) {
                 YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(ypZyPatient.getChargeCode(), ypZyPatient.getSerial());
-                if(ypZdDict.getByjFlag() == 1){
+                if (ypZdDict.getByjFlag() == 1) {
                     SimpleDateFormat smf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                     prescription.setWardName(zdUnitCodeMapper.selectByCode(ypZyPatient.getDeptCode()).getName());
                     String confirmTime = smf.format(ypZyPatient.getConfirmTime());
-                    prescription.setPrescriptionNo(confirmTime.split(" ")[0].replace("-","")+
-                            confirmTime.split(" ")[1].replace(":","").replace(".",""));
+                    prescription.setPrescriptionNo(confirmTime.split(" ")[0].replace("-", "") +
+                            confirmTime.split(" ")[1].replace(":", "").replace(".", ""));
                     prescription.setSeqNo(seqNo++);
                     prescription.setPatientId(ypZyPatient.getInpatientNo());
                     prescription.setWardCd(ypZyPatient.getDeptCode());
@@ -429,28 +428,28 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
                     prescription.setDoctorName(employeeMapper.selectByUserCode(ypZyPatient.getDoctorName()).getEmployeeName());
                     prescription.setTakeDate(ypZyPatient.getOrderDate());
                     String orderDate = smf.format(ypZyPatient.getOrderDate());
-                    String takeTime = orderDate.split(" ")[1].substring(0,5).replace(":","");
+                    String takeTime = orderDate.split(" ")[1].substring(0, 5).replace(":", "");
                     prescription.setTakeTime(takeTime);
                     prescription.setDrugCd(ypZyPatient.getChargeCode());
                     prescription.setFreqDescDetailCode(takeTime);
-                    prescription.setFreqDescDetail(orderDate.split(" ")[1].substring(0,5));
+                    prescription.setFreqDescDetail(orderDate.split(" ")[1].substring(0, 5));
                     prescription.setMakeRecTime(ypZyPatient.getConfirmTime());
-                    if(ypZyPatient.getAlwaysFlag().equals("a")){
+                    if (ypZyPatient.getAlwaysFlag().equals("a")) {
                         prescription.setIoFlg("2");
-                    }else if(ypZyPatient.getAlwaysFlag().equals("t")){
+                    } else if (ypZyPatient.getAlwaysFlag().equals("t")) {
                         prescription.setIoFlg("3");
                     }
-                    prescription.setHisId(ypZyPatient.getPageNo()+"");
+                    prescription.setHisId(ypZyPatient.getPageNo() + "");
                     YzActOrder yzActOrder = yzActOrderMapper.selectYzActOrderByActOrderNo(ypZyPatient.getActOrderNo());
                     prescription.setPrescriptionDate(yzActOrder.getStartTime());
                     prescription.setDrugName(yzActOrder.getOrderName());
                     prescription.setPrescriptionDose(yzActOrder.getDose());
                     prescription.setPrescriptionUnit(mzPharmacyMapper.selectYpUnitName(yzActOrder.getDoseUnit()));
                     prescription.setDispensedUnit(mzPharmacyMapper.selectYpUnitName(yzActOrder.getMiniUnit()));
-                    if((yzActOrder.getDoseUnit().equals("01") || yzActOrder.getDoseUnit().equals("03"))
-                            && (yzActOrder.getMiniUnit().equals("01") && yzActOrder.getMiniUnit().equals("03"))){
+                    if ((yzActOrder.getDoseUnit().equals("01") || yzActOrder.getDoseUnit().equals("03"))
+                            && (yzActOrder.getMiniUnit().equals("01") && yzActOrder.getMiniUnit().equals("03"))) {
                         prescription.setAmountPerPackage(Double.parseDouble("1"));
-                    }else{
+                    } else {
                         prescription.setAmountPerPackage(ypZdDict.getWeight().doubleValue());
                     }
                     prescription.setDispenseDays(1);
@@ -460,22 +459,24 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
                     APatientMi aPatientMi = aPatientMiMapper.selectPatientMiByInPatientNo(ypZyPatient.getInpatientNo());
                     prescription.setPatientName(aPatientMi.getName());
                     prescription.setBirthday(aPatientMi.getBirthDate());
-                    prescription.setSex(aPatientMi.getSex()); prescriptionMapper.insertPrescription(prescription);
+                    prescription.setSex(aPatientMi.getSex());
+                    flag = prescriptionMapper.insertPrescription(prescription);
                 }
             }
         }
+        return flag;
     }
 
     @Override
     public List<YfWardVo> getDetail(String pageNo, String pageClass, String submitFlag) {
         List<YfWardVo> yfWardVos = new ArrayList<>();
         String[] pageNos = pageNo.split("/");
-        if(pageClass.equals("A")){//医技科室领药
-            yfWardVos = queryZyDrugDetail(pageNos[0],submitFlag);
-        }else{
+        if (pageClass.equals("A")) {//医技科室领药
+            yfWardVos = queryZyDrugDetail(pageNos[0], submitFlag);
+        } else {
             for (String no : pageNos) {
                 List<YfWardVo> t = queryYzYpOrderDetail(no, pageClass.equals("T") ? "1" : "0", submitFlag);
-                if(t.size() > 0){
+                if (t.size() > 0) {
                     yfWardVos.addAll(t);
                 }
             }
@@ -488,14 +489,14 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
                 zyActpatient = zyActpatientMapper.selectByInpatientNo(ZyActpatient.ZY_INACTPATIENT, yfWardVo.getInpatientNo(), yfWardVo.getAdmissTimes());
             }
 
-            if(!pageClass.equals("A")){//非医技科室领药
+            if (!pageClass.equals("A")) {//非医技科室领药
                 YzActOrder yzActOrder = yzActOrderMapper.selectYzActOrderByActOrderNo(yfWardVo.getActOrderNo());
-                if(yzActOrder != null){
+                if (yzActOrder != null) {
                     yfWardVo.setInstruction(yzActOrder.getInstruction());
                     yfWardVo.setSupplyName(yzSupplyTypeMapper.selectSupplyNameByCode(yzActOrder.getSupplyCode()));
                 }
                 //毒麻药单,长期口服,临时口服,统领单
-                if(pageClass.equals("2") || pageClass.equals("5") || pageClass.equals("6") || pageClass.equals("7")){
+                if (pageClass.equals("2") || pageClass.equals("5") || pageClass.equals("6") || pageClass.equals("7")) {
                     yfWardVo.setFrequCode(yzActOrder.getFrequCode());
                     yfWardVo.setDose(yzActOrder.getDose());
                     yfWardVo.setDoseUnit(mzPharmacyMapper.selectYpUnitName(yzActOrder.getDoseUnit()));
@@ -523,33 +524,31 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
     }
 
     @Override
-    public List<YfWardVo> getLabelPrintDatas(String pageNo, Integer submitFlag) {
+    public List<YfWardVo> getLabelPrintDatas(String pageNo, Integer submitFlag, Integer isByj) {
         List<YfWardVo> yfWardVos = new ArrayList<>();
         String[] pageNos = pageNo.split("/");
         for (String no : pageNos) {
             List<YfWardVo> t = queryYzYpOrderDetail(no, "0", "0,1,2,3,4");
-            if(t.size() > 0){
+            if (t.size() > 0) {
                 yfWardVos.addAll(t);
             }
         }
         for (int i = 0; i < yfWardVos.size(); i++) {
             YfWardVo yfWardVo = yfWardVos.get(i);
             YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(yfWardVo.getChargeCode(), yfWardVo.getSerial());
-            if(((yfWardVo.getPageClass().equals("5")||yfWardVo.getPageClass().equals("6")) && (submitFlag == 3 || ypZdDict.getByjFlag() == 0))//口服单
-                    || ((!yfWardVo.getPageClass().equals("5")&&!yfWardVo.getPageClass().equals("6")) && "d".equals(yfWardVo.getDrugClass()))//非口服单的口服药
-            ){
+            if ((isByj == 0 && "d".equals(yfWardVo.getDrugClass())) || (isByj == 1 && ypZdDict.getByjFlag() == 0)) {//口服药
                 YzActOrder yzActOrder = yzActOrderMapper.selectYzActOrderByActOrderNo(yfWardVo.getActOrderNo());
                 yfWardVo.setDose(yzActOrder.getDose());
                 String ypUnitName = mzPharmacyMapper.selectYpUnitName(yzActOrder.getDoseUnit());
                 yfWardVo.setDoseUnit(ypUnitName);
                 String dosage;
-                if(yzActOrder.getDoseUnit().equals(yzActOrder.getDrugVolUnit())){
-                    dosage = yzActOrder.getDose()/yzActOrder.getDrugVolume()+"";
-                }else{
-                    dosage = yzActOrder.getDose()/yzActOrder.getDrugWeight()+"";
+                if (yzActOrder.getDoseUnit().equals(yzActOrder.getDrugVolUnit())) {
+                    dosage = yzActOrder.getDose() / yzActOrder.getDrugVolume() + "";
+                } else {
+                    dosage = yzActOrder.getDose() / yzActOrder.getDrugWeight() + "";
                 }
-                if(yzActOrder.getDrugWeight() <= 0 || Double.parseDouble(dosage) < 1){
-                    dosage = NumberFormat.getInstance().format(yfWardVo.getDose())+ypUnitName;
+                if (yzActOrder.getDrugWeight() <= 0 || Double.parseDouble(dosage) < 1) {
+                    dosage = NumberFormat.getInstance().format(yfWardVo.getDose()) + ypUnitName;
                 }
                 yfWardVo.setDosage(dosage);
                 APatientMi aPatientMi = aPatientMiMapper.selectPatientMiByInPatientNo(yfWardVo.getInpatientNo());
@@ -558,7 +557,7 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
                 yfWardVo.setName(aPatientMi.getName());
                 yfWardVo.setDrugName(ypZdDict.getName());
                 yfWardVo.setSpecification(ypZdDict.getSpecification());
-            }else{
+            } else {
                 yfWardVos.remove(i);
                 i--;
             }
@@ -569,13 +568,13 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
     @Override
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     public int cancelWardPrescriptionSubmit(String pageNo, String pageClass, String userIdCode) throws MzException {
-        int i=1;
-        if(pageClass.equals("A")){
+        int i = 1;
+        if (pageClass.equals("A")) {
             i = zyDrugMapper.selectIsInitFlag(pageNo);
-        }else if(!pageClass.equals("T")){
+        } else if (!pageClass.equals("T")) {
             i = yzYpZyOrderMapper.selectIsInitFlag(pageNo);
         }
-        if(i == 0){
+        if (i == 0) {
             throw new MzException("撤销药单失败,药单含有非初始和拒发状态的药品!");
         }
         return yzYpPageNoMapper.updateSubmitCancelFlag(pageNo, userIdCode);

File diff suppressed because it is too large
+ 329 - 257
src/main/resources/static/js/yf/ward_prescription.js


Some files were not shown because too many files changed in this diff