Переглянути джерело

Merge branch 'dev-1.1.4' into 'dev-1.1.4'

优化住院汇总发药打印以及药品账页字典维护

See merge request lihong/thmz_system!47
huangshuhua 1 рік тому
батько
коміт
669a1af6c9

+ 194 - 0
src/main/java/cn/hnthyy/thmz/Utils/DecimalUtil.java

@@ -0,0 +1,194 @@
+package cn.hnthyy.thmz.Utils;
+
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.DecimalFormat;
+
+/**
+ * @ClassName DecimalUtil
+ * @Author hsh
+ * @Date 2024/2/4 11:10
+ * @Version 1.0
+ * @Description BigDecimal计算工具
+ **/
+public class DecimalUtil {
+
+    public static String add(String a, String b) {
+        if (StringUtils.isBlank(a)) {
+            a = "0";
+        }
+        if (StringUtils.isBlank(b)) {
+            b = "0";
+        }
+        BigDecimal ad = new BigDecimal(a);
+        BigDecimal bd = new BigDecimal(b);
+        return ad.add(bd).setScale(2, RoundingMode.HALF_UP).toString();
+    }
+
+    public static String add(String a, String b, String c) {
+        if (StringUtils.isBlank(a)) {
+            a = "0";
+        }
+        if (StringUtils.isBlank(b)) {
+            b = "0";
+        }
+        if (StringUtils.isBlank(c)) {
+            c = "0";
+        }
+        BigDecimal ad = new BigDecimal(a);
+        BigDecimal bd = new BigDecimal(b);
+        BigDecimal cd = new BigDecimal(c);
+        return ad.add(bd).add(cd).setScale(2, RoundingMode.HALF_UP).toString();
+    }
+
+    public static String add1(String a, String b) {
+        if (StringUtils.isBlank(a)) {
+            a = "0";
+        }
+        if (StringUtils.isBlank(b)) {
+            b = "0";
+        }
+        BigDecimal ad = new BigDecimal(a);
+        BigDecimal bd = new BigDecimal(b);
+        return ad.add(bd).setScale(0, RoundingMode.HALF_UP).toString();
+    }
+
+    public static String minus(String a, String b) {
+        if (StringUtils.isBlank(a)) {
+            a = "0";
+        }
+        if (StringUtils.isBlank(b)) {
+            b = "0";
+        }
+        BigDecimal ad = new BigDecimal(a);
+        BigDecimal bd = new BigDecimal(b);
+        return ad.subtract(bd).setScale(2, RoundingMode.HALF_UP).toString();
+    }
+
+    public static Double minusDouble(Double a, Double b) {
+        if (null == a) {
+            a = 0d;
+        }
+        if (null == b) {
+            b = 0d;
+        }
+        BigDecimal ad = new BigDecimal(a);
+        BigDecimal bd = new BigDecimal(b);
+        return ad.subtract(bd).setScale(2, RoundingMode.HALF_UP).doubleValue();
+    }
+
+    public static BigDecimal divide(BigDecimal a, BigDecimal b) {
+        return a.divide(b, 0, RoundingMode.HALF_UP);
+    }
+
+    public static BigDecimal divide(BigDecimal a, BigDecimal b, int scale) {
+        return a.divide(b, scale, RoundingMode.HALF_UP);
+    }
+
+    public static String percentage(String a, String b) {
+        if (compare(a, "0") == 0) {
+            return "0.00%";
+        }
+        if (compare(b, "0") == 0) {
+            return "无法计算";
+        }
+        BigDecimal ad = new BigDecimal(a);
+        BigDecimal bd = new BigDecimal(b);
+        BigDecimal adb = ad.divide(bd, 4, RoundingMode.CEILING);
+        return adb.multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP) + "%";
+    }
+
+    public static String minusLink(String a, String b, String c, String d) {
+        if (StringUtils.isBlank(a)) {
+            a = "0";
+        }
+        if (StringUtils.isBlank(b)) {
+            b = "0";
+        }
+        if (StringUtils.isBlank(c)) {
+            c = "0";
+        }
+        if (StringUtils.isBlank(d)) {
+            d = "0";
+        }
+        BigDecimal ad = new BigDecimal(a);
+        BigDecimal bd = new BigDecimal(b);
+        BigDecimal cd = new BigDecimal(c);
+        BigDecimal dd = new BigDecimal(d);
+        return ad.subtract(bd).subtract(cd).subtract(dd).setScale(2, RoundingMode.HALF_UP).toString();
+    }
+
+    public static BigDecimal add(BigDecimal a, BigDecimal b) {
+        if (null == a) {
+            a = BigDecimal.ZERO;
+        }
+        if (null == b) {
+            b = BigDecimal.ZERO;
+        }
+        return a.add(b).setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public static BigDecimal minus(BigDecimal a, BigDecimal b) {
+        if (null == a) {
+            a = BigDecimal.ZERO;
+        }
+        if (null == b) {
+            b = BigDecimal.ZERO;
+        }
+        return a.subtract(b).setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public static String divide(String a, String b, int scale) {
+        BigDecimal ad = new BigDecimal(a);
+        BigDecimal bd = new BigDecimal(b);
+        return ad.divide(bd, scale, RoundingMode.DOWN).toString();
+    }
+
+    public static String moneyYuanToFen(BigDecimal fee) {
+        BigDecimal hundred = new BigDecimal("100");
+        return fee.multiply(hundred).setScale(0, RoundingMode.CEILING).toPlainString();
+    }
+
+    public static String getPercent(int x, int total) {
+        double v = (double) x / (double) total;
+        DecimalFormat df = new DecimalFormat("0.00%");
+        return df.format(v);
+    }
+
+    public static String getPercent(double x, double total) {
+        if (x == 0 && total == 0) {
+            return "0.00%";
+        }
+        String result;
+        double v = x / total;
+        DecimalFormat df = new DecimalFormat("0.00%");
+        result = df.format(v);
+        return result;
+    }
+
+    public static int compare(String a, String b) {
+        if (StringUtils.isBlank(a)) {
+            a = "0";
+        }
+        if (StringUtils.isBlank(b)) {
+            b = "0";
+        }
+        BigDecimal d1 = new BigDecimal(a);
+        BigDecimal d2 = new BigDecimal(b);
+        return d1.compareTo(d2);
+    }
+
+    public static BigDecimal multiply(BigDecimal a, BigDecimal b) {
+        if (null == a) {
+            a = BigDecimal.ZERO;
+        }
+        if (null == b) {
+            b = BigDecimal.ZERO;
+        }
+        return a.multiply(b).setScale(2, RoundingMode.HALF_UP);
+    }
+    
+}

+ 1 - 0
src/main/java/cn/hnthyy/thmz/entity/his/yp/YpSummaryPrint.java

@@ -29,6 +29,7 @@ public class YpSummaryPrint {
     private String printFlag;
     private String result;
     private String createDate;
+    // 打印数量
     private BigDecimal amount;
     private BigDecimal realAmount;
 

+ 3 - 0
src/main/java/cn/hnthyy/thmz/entity/his/yp/YpZdDict.java

@@ -289,4 +289,7 @@ public class YpZdDict {
      * 抗肿瘤药物级别:1、普通使用级;2、限制使用级
      **/
     private Integer antitumorLevel;
+
+    @NotColumn
+    private String groupNo;
 }

+ 2 - 2
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpBaseMapper.java

@@ -131,12 +131,12 @@ public interface YpBaseMapper {
             "  ( charge_code , serial , group_no , drugname , py_code , d_code , specification , specification2 , pack_retprice , retprice , pack_size ," +
             "   drug_flag , infusion , class_code , dosage , concentration , vol_unit , mini_unit , pack_unit , self_flag , separate_flag , suprice_flag ," +
             "   country_flag , drug_kind , drug_id_link , drug_id , weight , weigh_unit , volum , serial_new , mz_bill_item , zy_bill_item )" +
-            " select code , serial , '11' , name , py_code , d_code , LEFT(specification,10)specification , LEFT(specification2,10)specification2 , pack_retprice , retprice , pack_size ," +
+            " select code , serial , #{groupNo} , name , py_code , d_code , LEFT(specification,10)specification , LEFT(specification2,10)specification2 , pack_retprice , retprice , pack_size ," +
             "       drug_flag , infusion_flag , class_code , dosage , concentration , vol_unit , mini_unit , pack_unit , self_flag , separate_flag ," +
             "       suprice_flag , country_flag , right ( drug_kind , 2 ) , drug_id , rtrim ( ltrim ( drug_id ) ) + rtrim ( ltrim ( dosage ) ) ," +
             "       weight , weigh_unit , volum , serial , bill_item_mz , bill_item_zy" +
             " from yp_zd_dict where code =#{code} and serial =#{serial}")
-    int insertYpBaseSync(@Param("code") String code, @Param("serial") String serial);
+    int insertYpBaseSync(@Param("code") String code, @Param("serial") String serial, @Param("groupNo") String groupNo);
 
 
     /**

+ 83 - 35
src/main/java/cn/hnthyy/thmz/service/impl/his/yf/YfWardPrescriptionServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.hnthyy.thmz.service.impl.his.yf;
 
+import cn.hnthyy.thmz.Utils.DecimalUtil;
 import cn.hnthyy.thmz.Utils.ListSizeControlUtil;
 import cn.hnthyy.thmz.common.Constants;
 import cn.hnthyy.thmz.entity.MzException;
@@ -9,10 +10,20 @@ import cn.hnthyy.thmz.entity.his.yp.YpBaseYf;
 import cn.hnthyy.thmz.entity.his.yp.YpSummaryPrint;
 import cn.hnthyy.thmz.entity.his.yp.YpYzSendRecord;
 import cn.hnthyy.thmz.entity.his.yp.YpZdDict;
-import cn.hnthyy.thmz.entity.his.yz.*;
+import cn.hnthyy.thmz.entity.his.yz.YzActOrderCy;
+import cn.hnthyy.thmz.entity.his.yz.YzActOrderCyDetail;
+import cn.hnthyy.thmz.entity.his.yz.YzSupplyType;
+import cn.hnthyy.thmz.entity.his.yz.YzYpPageNo;
+import cn.hnthyy.thmz.entity.his.yz.YzYpZyOrder;
 import cn.hnthyy.thmz.entity.his.zd.ZdCommon;
 import cn.hnthyy.thmz.entity.his.zd.ZdUnitCode;
-import cn.hnthyy.thmz.entity.his.zy.*;
+import cn.hnthyy.thmz.entity.his.zy.APatientMi;
+import cn.hnthyy.thmz.entity.his.zy.Prescription;
+import cn.hnthyy.thmz.entity.his.zy.YpZyPatient;
+import cn.hnthyy.thmz.entity.his.zy.ZyActpatient;
+import cn.hnthyy.thmz.entity.his.zy.ZyDetailCharge;
+import cn.hnthyy.thmz.entity.his.zy.ZyDrug;
+import cn.hnthyy.thmz.entity.his.zy.ZyLedgerFile;
 import cn.hnthyy.thmz.mapper.his.ResponceTypeMapper;
 import cn.hnthyy.thmz.mapper.his.mz.EmployeeMapper;
 import cn.hnthyy.thmz.mapper.his.mz.MzPharmacyMapper;
@@ -21,10 +32,23 @@ import cn.hnthyy.thmz.mapper.his.yp.YpMzFytjMapper;
 import cn.hnthyy.thmz.mapper.his.yp.YpYzSendRecordMapper;
 import cn.hnthyy.thmz.mapper.his.yp.YpZdDictMapper;
 import cn.hnthyy.thmz.mapper.his.yp.YpZdManufactoryMapper;
-import cn.hnthyy.thmz.mapper.his.yz.*;
+import cn.hnthyy.thmz.mapper.his.yz.YzActOrderCyDetailMapper;
+import cn.hnthyy.thmz.mapper.his.yz.YzActOrderCyMapper;
+import cn.hnthyy.thmz.mapper.his.yz.YzActOrderMapper;
+import cn.hnthyy.thmz.mapper.his.yz.YzInactOrderMapper;
+import cn.hnthyy.thmz.mapper.his.yz.YzOrderFrequencyMapper;
+import cn.hnthyy.thmz.mapper.his.yz.YzSupplyTypeMapper;
+import cn.hnthyy.thmz.mapper.his.yz.YzYpPageNoMapper;
+import cn.hnthyy.thmz.mapper.his.yz.YzYpZyOrderMapper;
 import cn.hnthyy.thmz.mapper.his.zd.MzYshZdFysmMapper;
 import cn.hnthyy.thmz.mapper.his.zd.ZdUnitCodeMapper;
-import cn.hnthyy.thmz.mapper.his.zy.*;
+import cn.hnthyy.thmz.mapper.his.zy.APatientMiMapper;
+import cn.hnthyy.thmz.mapper.his.zy.PrescriptionMapper;
+import cn.hnthyy.thmz.mapper.his.zy.YpZyPatientMapper;
+import cn.hnthyy.thmz.mapper.his.zy.ZyActpatientMapper;
+import cn.hnthyy.thmz.mapper.his.zy.ZyDetailChargeMapper;
+import cn.hnthyy.thmz.mapper.his.zy.ZyDrugMapper;
+import cn.hnthyy.thmz.mapper.his.zy.ZyLedgerFileMapper;
 import cn.hnthyy.thmz.service.his.yf.YfWardPrescriptionService;
 import cn.hnthyy.thmz.service.his.yz.YzSequenceService;
 import cn.hnthyy.thmz.vo.YfWardVo;
@@ -46,7 +70,13 @@ import org.springframework.transaction.annotation.Transactional;
 import java.math.BigDecimal;
 import java.text.NumberFormat;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
 import java.util.stream.Collectors;
 
 /**
@@ -1112,45 +1142,63 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
         if(null == summaryData || summaryData.isEmpty()){
             return resultMap;
         }
-        List<YfWardVo> yfWardVos;
-        if ("A".equals(vo.getPageClass())) {//医技科室领药
-            yfWardVos = queryZyDrug(vo.getPageNo(), vo.getSubmitFlag());
-        } else {
-            yfWardVos = queryYzYpOrder(vo.getPageNo(), vo.getPageClass(), vo.getSubmitFlag());
+        List<YfWardVo> yfWardVos = new ArrayList<>();
+        String pageNo = vo.getPageNo();
+        String[] pageNos = pageNo.split("/");
+        for (String page :pageNos) {
+            List<YfWardVo> ds;
+            if ("A".equals(vo.getPageClass())) {//医技科室领药
+                ds = queryZyDrug(page, vo.getSubmitFlag());
+            } else {
+                ds = queryYzYpOrder(page, vo.getPageClass(), vo.getSubmitFlag());
+            }
+            if(null != ds && !ds.isEmpty()){
+                yfWardVos.addAll(ds);
+            }
+        }
+
+        if(yfWardVos.isEmpty()){
+            return resultMap;
         }
+        Map<String, Map<String, List<YfWardVo>>> map = yfWardVos.stream().collect(
+                Collectors.groupingBy(YfWardVo::getChargeCode, Collectors.groupingBy(YfWardVo::getSerial)));
         String msg = "";
         boolean flag = false;
         int pid = 1;
         for(YpSummaryPrint ypPrint : summaryData){
             String chargeCode = ypPrint.getChargeCode();
             String serial = ypPrint.getSerial();
-            BigDecimal amount = ypPrint.getAmount();
-            for (YfWardVo yf : yfWardVos){
-                if(chargeCode.equals(yf.getChargeCode()) && serial.equals(yf.getSerial())){
-                    if(amount.doubleValue() == yf.getAmount()){
-                        ypPrint.setResult("正常");
-                    } else {
-                        if(StringUtils.isBlank(msg)){
-                            msg += "有误差,实际发药数量: " + yf.getAmount() + ", 打印数量: " + amount + " 。。。";
-                        }
-                        ypPrint.setResult("有误差,实际发药数量: " + yf.getAmount() + ", 打印数量: " + amount);
-                        if(!flag){
-                            flag = true;
-                        }
-                    }
-                    ypPrint.setId(String.valueOf(System.currentTimeMillis()));
-                    ypPrint.setSort(pid);
-                    ypPrint.setPageNo(vo.getPageNo());
-                    ypPrint.setPageClass(vo.getPageClass());
-                    ypPrint.setSubmitFlag(String.valueOf(vo.getSubmitFlag()));
-                    ypPrint.setPrintFlag(vo.getPrintFlag());
-                    // 医嘱实际发药量
-                    ypPrint.setRealAmount(BigDecimal.valueOf(yf.getAmount()));
-                    ypPrint.setCreateDate(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
-                    pid ++;
-                    break;
+            BigDecimal printAmount = ypPrint.getAmount();
+            Map<String, List<YfWardVo>> ff = map.get(chargeCode);
+            List<YfWardVo> data = ff.get(serial);
+            if(data.isEmpty()){
+                continue;
+            }
+            BigDecimal realAmount = BigDecimal.ZERO;
+            for (YfWardVo yf : data){
+                realAmount = DecimalUtil.add(realAmount, BigDecimal.valueOf(yf.getAmount()));
+            }
+            if(realAmount.compareTo(printAmount) != 0){
+                if(!flag){
+                    flag = true;
                 }
+                if(StringUtils.isBlank(msg)){
+                    msg += "有误差,实际发药数量: " + realAmount + ", 打印数量: " + printAmount + " 。。。";
+                }
+                ypPrint.setResult("有误差,实际发药数量: " + realAmount + ", 打印数量: " + printAmount);
+            } else {
+                ypPrint.setResult("正常");
             }
+            ypPrint.setId(String.valueOf(System.currentTimeMillis()));
+            ypPrint.setSort(pid);
+            ypPrint.setPageNo(pageNo);
+            ypPrint.setPageClass(vo.getPageClass());
+            ypPrint.setSubmitFlag(String.valueOf(vo.getSubmitFlag()));
+            ypPrint.setPrintFlag(vo.getPrintFlag());
+            // 医嘱实际发药量
+            ypPrint.setRealAmount(realAmount);
+            ypPrint.setCreateDate(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
+            pid ++;
         }
         if(StringUtils.isNotBlank(msg)) {
             vo.setMessage(msg);

+ 1 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/yp/YpZdDictServiceImpl.java

@@ -168,7 +168,7 @@ public class YpZdDictServiceImpl implements YpZdDictService {
                 ypZdDictMapper.insertYpZdDictSql(changedFieldsOfSql);
             }
             ypPrintNameMapper.insertYpPrintName(new YpPrintName(ypZdDict.getCode(),ypZdDict.getName(),ypZdDict.getPyCode(),ypZdDict.getWbCode(),"T"));
-            if(ypBaseMapper.insertYpBaseSync(ypZdDict.getCode(), serial)!=1){
+            if(ypBaseMapper.insertYpBaseSync(ypZdDict.getCode(), serial, ypZdDict.getGroupNo())!=1){
                 throw new MzException("初始化药库库存异常!");
             }
         }

+ 1 - 1
src/main/resources/static/js/yf/ward_prescription.js

@@ -1985,7 +1985,7 @@ function saveSummaryData(printFlag, summaryData) {
         dataType: "json",
         headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
         data: JSON.stringify({
-            pageNo: $("#pageNoSearch").val(),
+            pageNo: hzFlag === 0 ? pageNo : pageNos,
             pageClass: pageClass,
             submitFlag: $("#submitFlagSearch").val(),
             printFlag: printFlag,

+ 1 - 0
src/main/resources/static/js/yk/drug_info.js

@@ -40,6 +40,7 @@ $(function () {
         $.each(data, function (i, item) {
             formObject[item.name] = item.value;
         });
+        formObject.groupNo = groupYk
         if(validator.checkAll($("#dataForm")) && formValidator(formObject)){
             request({
                 url: '/saveYpZdDict',