Bladeren bron

药品计划申请与审核优化

hsh 4 maanden geleden
bovenliggende
commit
b90810b613

+ 5 - 0
src/main/java/thyyxxk/webserver/controller/medicine/YpPlanController.java

@@ -55,4 +55,9 @@ public class YpPlanController {
         return service.updateYpPlanAuditData(info);
     }
 
+    @PostMapping("/saveYpPlanDetail")
+    public ResultVo<Map<String, Object>> saveYpPlanDetail(@RequestBody @Validated List<YpPlanDetail> list){
+        return service.saveYpPlanDetail(list);
+    }
+
 }

+ 1 - 4
src/main/java/thyyxxk/webserver/dao/his/dictionary/BedDeptDictDao.java

@@ -193,7 +193,7 @@ public interface BedDeptDictDao {
     List<Map<String, Object>> selectSmallDept(@Param("text") String text);
 
     @Select(" select * from zd_dept_all where dept_id = #{deptId}  ")
-    Map<String, Object> selectSmallDeptByCode(@Param("deptId") String deptId);
+    Map<String, Object> selectSmallDeptByCode(@Param("deptId") Integer deptId);
 
     @Update("<script>" +
             "update zd_dept_all " +
@@ -204,9 +204,6 @@ public interface BedDeptDictDao {
             "<if test=\"smallDept != null and smallDept != '' \">" +
             "small_dept = #{smallDept}, " +
             "</if>" +
-            "<if test=\"deptId != null and deptId != '' \">" +
-            "dept_id = #{deptId}, " +
-            "</if>" +
             "</trim>" +
             "where dept_id = #{deptId} " +
             "</script>")

+ 3 - 3
src/main/java/thyyxxk/webserver/dao/his/highreport/AllStatisticsDao.java

@@ -118,9 +118,9 @@ public interface AllStatisticsDao {
             " and d.parent_code = e.code  " +
             " and a.charge_date >= #{startTime}   " +
             " and a.charge_date <= #{endTime}   " +
-            " and a.charge_status >= 2 )   " +
-            " and a.inpatient_no= f.inpatient_no   " +
-            " and a.admiss_times= f.admiss_times   " +
+            " and a.charge_status >= 2   " +
+            " and a.inpatient_no = f.inpatient_no   " +
+            " and a.admiss_times = f.admiss_times   " +
             " group by  " +
             "   z.name,  " +
             "   z.code,  " +

+ 3 - 3
src/main/java/thyyxxk/webserver/dao/his/medicine/YpPlanDetailDao.java

@@ -16,7 +16,7 @@ public interface YpPlanDetailDao extends BaseMapper<YpPlanDetail> {
     @Select(" select * from yp_plan_detail ")
     List<YpPlanDetail> selectYpPlanDetail(YpPlanDetail detail);
 
-    @Select(" select * from yp_plan_detail where file_id = #{fileId}  ")
+    @Select(" select * from yp_plan_detail where file_id = #{fileId} ")
     List<YpPlanDetail> selectYpPlanDetailById(@Param("fileId") String fileId);
 
     @Delete(" delete from yp_plan_detail where file_id = #{fileId} ")
@@ -24,11 +24,11 @@ public interface YpPlanDetailDao extends BaseMapper<YpPlanDetail> {
 
     @Insert({"<script>" +
             " insert into yp_plan_detail (file_id, remark, drug_name, specification, pack_retprice, buy_price, amount, manu_name, " +
-            " amount3, amount7, amount14, amount30, amount60, days, buy_amount, unit, buy_fee, content, imp_date) values " +
+            " amount3, amount7, amount14, amount30, amount60, days, buy_amount, unit, buy_fee, content, imp_date, supply_name, buy_money, pack_retprice1, buy_price1) values " +
             "<foreach collection='list' item='item' separator=','>" +
             " (#{item.fileId}, #{item.remark}, #{item.drugName}, #{item.specification}, #{item.packRetprice}, #{item.buyPrice}, #{item.amount}, #{item.manuName}, " +
             " #{item.amount3}, #{item.amount7}, #{item.amount14}, #{item.amount30}, #{item.amount60}, #{item.days}, #{item.buyAmount}, #{item.unit}, #{item.buyFee}, " +
-            " #{item.content}, #{item.impDate})" +
+            " #{item.content}, #{item.impDate}, #{item.supplyName}, #{item.buyMoney}, #{item.packRetprice1}, #{item.buyPrice1})" +
             "</foreach>" +
             "</script>"})
     int insertList(List<YpPlanDetail> list);

+ 3 - 0
src/main/java/thyyxxk/webserver/dao/his/medicine/YpPlanInfoDao.java

@@ -57,6 +57,9 @@ public interface YpPlanInfoDao extends BaseMapper<YpPlanInfo> {
     @Update("<script>" +
             "update yp_plan_info " +
             "<trim prefix=\"set\" suffixOverrides=\",\">" +
+            "<if test=\"totalFee != null \">" +
+            "total_fee = #{totalFee}, " +
+            "</if>" +
             "<if test=\"type == 1 \">" +
             "trial_audit = #{trialAudit}, trial_content = #{trialContent}, trial_id = #{trialId}, trial_name = #{trialName}, " +
             "</if>" +

+ 10 - 1
src/main/java/thyyxxk/webserver/entity/medicine/YpPlanDetail.java

@@ -1,6 +1,7 @@
 package thyyxxk.webserver.entity.medicine;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -38,8 +39,16 @@ public class YpPlanDetail implements Serializable {
     private String days; // 可用天数
     private BigDecimal buyAmount; // 采购计划
     private String unit; // 单位
-    private BigDecimal buyFee;// 购入金额
+    private BigDecimal buyFee;// 购入金额(作废)
     private String content; // 主任意见
     private String impDate; // 导入时间
+    private String supplyName; // 药品供应商
+    private BigDecimal buyMoney; // 购入金额(启用新的)
+    private String packRetprice1; // 零售价(启用新的)
+    private String buyPrice1; // 购入价(启用新的)
+    @TableField(exist = false)
+    private String chargeCode;
+    @TableField(exist = false)
+    private String drugKind;
 
 }

+ 1 - 1
src/main/java/thyyxxk/webserver/service/dictionary/BedDeptDictService.java

@@ -226,7 +226,7 @@ public class BedDeptDictService {
     public ResultVo<Map<String, Object>> saveSmallDept(Map<String, Object> smallMap){
         String dept = String.valueOf(smallMap.get("dept"));
         String smallDept = String.valueOf(smallMap.get("smallDept"));
-        String deptId = String.valueOf(smallMap.get("deptId"));
+        Integer deptId = (Integer) smallMap.get("deptId");
         if(StringUtil.isBlank(dept) || StringUtil.isBlank(smallDept)){
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "小科室或者病区为空,请检查!");
         }

+ 67 - 32
src/main/java/thyyxxk/webserver/service/medicine/YpPlanService.java

@@ -108,9 +108,8 @@ public class YpPlanService {
             // 计算购入总金额
             BigDecimal totalFee = BigDecimal.ZERO;
             for(YpPlanDetail d : list){
-                totalFee = DecimalUtil.add(totalFee, d.getBuyAmount());
+                totalFee = DecimalUtil.add(totalFee, d.getBuyMoney());
             }
-            System.out.println("总金额:" + totalFee);
             info.setTotalFee(totalFee);
             UserInfo user = redis.getUserInfoByCode(TokenUtil.getInstance().getTokenUserId());
             info.setApplyId(user.getCode());
@@ -118,7 +117,7 @@ public class YpPlanService {
             int c = callSavePlanDetail(info, list);
         } catch (IOException e) {
             log.info("导入药品计划出错:" + e.getMessage());
-            throw new RuntimeException(e);
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "导入药品计划出错:" + e.getMessage());
         }
         return ResultVoUtil.success(map);
     }
@@ -135,15 +134,7 @@ public class YpPlanService {
         if (null != listLs && !listLs.isEmpty()) {
             detailDao.deleteYpPlanDetailById(info.getFileId());
         }
-        int sum = 0;
-        int cs = (int) Math.ceil((double) list.size() / BATCH_SIZE);
-        for(int i = 0; i < cs; i++ ){
-            int start = i * BATCH_SIZE;
-            int end = Math.min(start + BATCH_SIZE, list.size());
-            List<YpPlanDetail> l = list.subList(start, end);
-            sum = sum + detailDao.insertList(l);
-        }
-        return sum;
+        return countNum(list);
     }
 
     /**
@@ -183,46 +174,54 @@ public class YpPlanService {
                 }
                 YpPlanDetail imp = new YpPlanDetail();
                 String[] stirs = str.toString().split("_");
-                imp.setRemark(stirs[0]);
-                imp.setDrugName(stirs[1]);
-                imp.setSpecification(stirs[2]);
-                if(StringUtil.notBlank(stirs[3])){
-                    imp.setPackRetprice(new BigDecimal(stirs[3]));
+                if("硫酸氢氯吡格雷片(波立维)".equals(stirs[2])){
+                    log.info("硫酸氢氯吡格雷片(波立维)购入价: " + new BigDecimal(stirs[5]));
                 }
+                imp.setRemark(stirs[0]);
+                imp.setSupplyName(stirs[1]);
+                imp.setDrugName(stirs[2]);
+                imp.setSpecification(stirs[3]);
                 if(StringUtil.notBlank(stirs[4])){
-                    imp.setBuyPrice(new BigDecimal(stirs[4]));
+                    imp.setPackRetprice(new BigDecimal(stirs[4]));
+                    imp.setPackRetprice1(stirs[4]);
                 }
                 if(StringUtil.notBlank(stirs[5])){
-                    imp.setAmount(new BigDecimal(stirs[5]));
+                    imp.setBuyPrice(new BigDecimal(stirs[5]));
+                    imp.setBuyPrice1(stirs[5]);
                 }
-                imp.setManuName(stirs[6]);
-                if(StringUtil.notBlank(stirs[7])){
-                    imp.setAmount3(new BigDecimal(stirs[7]));
+                if(StringUtil.notBlank(stirs[6])){
+                    imp.setAmount(new BigDecimal(stirs[6]));
                 }
+                imp.setManuName(stirs[7]);
                 if(StringUtil.notBlank(stirs[8])){
-                    imp.setAmount7(new BigDecimal(stirs[8]));
+                    imp.setAmount3(new BigDecimal(stirs[8]));
                 }
                 if(StringUtil.notBlank(stirs[9])){
-                    imp.setAmount14(new BigDecimal(stirs[9]));
+                    imp.setAmount7(new BigDecimal(stirs[9]));
                 }
                 if(StringUtil.notBlank(stirs[10])){
-                    imp.setAmount30(new BigDecimal(stirs[10]));
+                    imp.setAmount14(new BigDecimal(stirs[10]));
                 }
                 if(StringUtil.notBlank(stirs[11])){
-                    imp.setAmount60(new BigDecimal(stirs[11]));
+                    imp.setAmount30(new BigDecimal(stirs[11]));
                 }
-                imp.setDays(stirs[12]);
-                if(StringUtil.notBlank(stirs[13])){
-                    imp.setBuyAmount(new BigDecimal(stirs[13]));
+                if(StringUtil.notBlank(stirs[12])){
+                    imp.setAmount60(new BigDecimal(stirs[12]));
                 }
-                imp.setUnit(stirs[14]);
+                imp.setDays(stirs[13]);
+                if(StringUtil.notBlank(stirs[14])){
+                    imp.setBuyAmount(new BigDecimal(stirs[14]));
+                }
+                imp.setUnit(stirs[15]);
                 if(null == imp.getBuyPrice() || null == imp.getBuyAmount()){
                     imp.setBuyFee(BigDecimal.ZERO);
+                    imp.setBuyMoney(BigDecimal.ZERO);
                 } else {
                     imp.setBuyFee(DecimalUtil.multiply(imp.getBuyPrice(), imp.getBuyAmount()));
+                    imp.setBuyMoney(DecimalUtil.multiply(imp.getBuyPrice(), imp.getBuyAmount()));
                 }
-                if(stirs.length == 17 && StringUtil.notBlank(stirs[16])){
-                    imp.setContent(stirs[16]);
+                if(stirs.length == 18 && StringUtil.notBlank(stirs[17])){
+                    imp.setContent(stirs[17]);
                 }
                 imp.setFileId(fileId);
                 // 常量
@@ -320,6 +319,31 @@ public class YpPlanService {
         }
         int d = infoDao.updateYpPlanAuditById(info);
         if(d > 0){
+            map.put("cg", "药品计划意见审核成功!");
+            return ResultVoUtil.success(map);
+        } else {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "药品计划意见审核失败!");
+        }
+    }
+
+    /**
+     * @Description 药品计划审核时确认计划数量以及金额
+     * @Author hsh
+     * @param list 药品计划数量以及金额
+     * @return map
+     * @Date 2025/3/27 10:45
+     */
+    public ResultVo<Map<String, Object>> saveYpPlanDetail(List<YpPlanDetail> list){
+        Map<String, Object> map = new HashMap<>();
+        if(null == list || list.isEmpty()){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "药品计划明细不存在,药品计划审核失败!");
+        }
+        List<YpPlanDetail> listLs = detailDao.selectYpPlanDetailById(list.get(0).getFileId());
+        if (null != listLs && !listLs.isEmpty()) {
+            detailDao.deleteYpPlanDetailById(list.get(0).getFileId());
+        }
+        int c = countNum(list);
+        if(c > 0){
             map.put("cg", "药品计划审核成功!");
             return ResultVoUtil.success(map);
         } else {
@@ -327,4 +351,15 @@ public class YpPlanService {
         }
     }
 
+    private int countNum(List<YpPlanDetail> list) {
+        int c = 0;
+        int cs = (int) Math.ceil((double) list.size() / BATCH_SIZE);
+        for(int i = 0; i < cs; i++ ){
+            int start = i * BATCH_SIZE;
+            int end = Math.min(start + BATCH_SIZE, list.size());
+            List<YpPlanDetail> l = list.subList(start, end);
+            c = c + detailDao.insertList(l);
+        }
+        return c;
+    }
 }