소스 검색

no message

xiaochan 1 년 전
부모
커밋
7f6073f8a4

+ 0 - 2
src/main/java/thyyxxk/webserver/entity/hospitalizationCosts/ZyDetailRefundParam.java

@@ -37,8 +37,6 @@ public class ZyDetailRefundParam {
     private String refundFlag;
 
 
-
-
     public List<Integer> getDetailSn() {
         List<Integer> detailSn = new ArrayList<>();
         for (ZyDetailChargeTable item : list) {

+ 26 - 11
src/main/java/thyyxxk/webserver/service/hospitalizationCosts/HospitalizationCostsService.java

@@ -2,10 +2,9 @@ package thyyxxk.webserver.service.hospitalizationCosts;
 
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import jdk.nashorn.internal.runtime.RewriteException;
 import lombok.Data;
+import lombok.Getter;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.poi.ss.formula.udf.IndexedUDFFinder;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import thyyxxk.webserver.config.Assertion;
@@ -70,6 +69,22 @@ public class HospitalizationCostsService implements Assertion {
         }
     }
 
+    @Getter
+    public enum RefundStatus {
+        REFUNDS(-1, "退费数据"),
+        APPLY_FOR_A_REFUND(-2, "申请退药"),
+        REFUSAL_TO_RETURN_THE_DRUG(-3, "拒绝退药");
+
+        private final int code;
+        private final String name;
+
+        RefundStatus(int code, String name) {
+            this.code = code;
+            this.name = name;
+        }
+
+    }
+
     public HospitalizationCostsService(HospitalizationCostsDao dao, RedisLikeService redisLikeService, XiangMuLuRuDao luRuDao, PublicServer publicServer) {
         this.dao = dao;
         this.redisLikeService = redisLikeService;
@@ -142,16 +157,16 @@ public class HospitalizationCostsService implements Assertion {
                 item.setSerial("00");
             }
             // -3 退药申请,拒绝退药申请是可以重新申请的
-            if (item.getOriDetailSn() != null && item.getOriDetailSn().equals(-3)) {
+            if (item.getOriDetailSn() != null && item.getOriDetailSn().equals(RefundStatus.REFUSAL_TO_RETURN_THE_DRUG.getCode())) {
                 item.setOriDetailSn(null);
             }
-            if (item.getOriDetailSn() != null && item.getOriDetailSn().equals(-2)) {
+            if (item.getOriDetailSn() != null && item.getOriDetailSn().equals(RefundStatus.APPLY_FOR_A_REFUND.code)) {
                 sb.append("该药品在申请退药。");
             }
             if (item.getOriDetailSn() != null) {
                 sb.append("该数据为退费数据。");
             }
-            if (BigUtils.bigXiaoYu(item.getChargeFee(), 0) || BigUtils.bigXiaoYu(item.getChargeAmount(), 0)) {
+            if (BigUtils.bigXiaoYu(item.getChargeFee(), BigDecimal.ZERO) || BigUtils.bigXiaoYu(item.getChargeAmount(),  BigDecimal.ZERO)) {
                 sb.append("该数据为负数。");
             }
             if (StringUtil.isBlank(item.getExecUnit())) {
@@ -168,7 +183,7 @@ public class HospitalizationCostsService implements Assertion {
                     sb.append("请对应的执行科室或申请科室退费。");
                 }
                 // 只退费设置
-                refundOnly.add(setDefaultValuesAndAutoincrements(item, maxDetailSn, -1));
+                refundOnly.add(setDefaultValuesAndAutoincrements(item, maxDetailSn, RefundStatus.REFUNDS.code));
             } else {
                 // 药品判断
                 // 医技科室录入的费用
@@ -176,15 +191,15 @@ public class HospitalizationCostsService implements Assertion {
                     if (!deptList.contains(item.getExecUnit())) {
                         sb.append("此药品为医技科室录入,请对应的医技科室退费。");
                     }
-                    refundOnly.add(setDefaultValuesAndAutoincrements(item, maxDetailSn, -1));
-                    medicalTechnologyDrugReturnForm.add(setDefaultValuesAndAutoincrements(item, maxDetailSn, -1));
+                    refundOnly.add(setDefaultValuesAndAutoincrements(item, maxDetailSn, RefundStatus.REFUNDS.code));
+                    medicalTechnologyDrugReturnForm.add(setDefaultValuesAndAutoincrements(item, maxDetailSn, RefundStatus.REFUNDS.code));
                 } else {
                     // 仅退费不退药品
                     if ("refundOnly".equals(param.getRefundFlag())) {
-                        refundOnly.add(setDefaultValuesAndAutoincrements(item, maxDetailSn, -1));
+                        refundOnly.add(setDefaultValuesAndAutoincrements(item, maxDetailSn, RefundStatus.REFUNDS.code));
                     } else {
                         // 退费又退药.不需要向refundOnly中添加数据,且oriDetailSn 要设置为 -2 代表申请退费
-                        generateAReturnOrder.add(setDefaultValuesAndAutoincrements(item, maxDetailSn, -2));
+                        generateAReturnOrder.add(setDefaultValuesAndAutoincrements(item, maxDetailSn, RefundStatus.APPLY_FOR_A_REFUND.code));
                     }
 
                     OrderInfo order = orderCacheOnce.get(orderNo, (key) -> dao.selectDrugClassByOrderNo(new BigDecimal(orderNo)));
@@ -334,7 +349,7 @@ public class HospitalizationCostsService implements Assertion {
 
         for (ZyDetailChargeTable item : list) {
             maxDetailSn += 1;
-            refundOnly.add(setDefaultValuesAndAutoincrements(item, maxDetailSn, -1));
+            refundOnly.add(setDefaultValuesAndAutoincrements(item, maxDetailSn, RefundStatus.REFUNDS.code));
         }
 
         // 直接退费

+ 53 - 0
src/main/java/thyyxxk/webserver/utils/EntityCopy.java

@@ -1,14 +1,19 @@
 package thyyxxk.webserver.utils;
 
+import cn.hutool.core.util.ReflectUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
+import thyyxxk.webserver.entity.login.UserInfo;
 
 import java.beans.BeanInfo;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
+import java.lang.reflect.Field;
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -21,6 +26,54 @@ import java.util.List;
 @Slf4j
 public class EntityCopy {
 
+    @Data
+    public static class Tes {
+        private Integer code;
+        private String empTitCode;
+    }
+
+    public static void main(String[] args) {
+        UserInfo userInfo = new UserInfo();
+        userInfo.setCodeRs("123");
+
+        Tes userInfo1 = new Tes();
+        userInfo1.setCode(1);
+        userInfo1.setEmpTitCode("1222");
+
+        CopyV2(userInfo, userInfo1);
+
+        System.out.println(userInfo);
+        System.out.println(userInfo1);
+    }
+
+    /**
+     * 根据字段名,把右边的值,set到左边的对象中
+     * @param dest 目标
+     * @param source 来源
+     */
+    public static void CopyV2(Object dest, Object source) {
+        if (source == null || dest == null) {
+            return;
+        }
+        Map<String, Field> sourceFields = ReflectUtil.getFieldMap(source.getClass());
+        Map<String, Field> destFields = ReflectUtil.getFieldMap(dest.getClass());
+
+        for (Map.Entry<String, Field> field : sourceFields.entrySet()) {
+            if (destFields.containsKey(field.getKey())) {
+                Object fieldValue = ReflectUtil.invoke(source, StringUtil.getMethodName(field.getKey()));
+
+                Field field1 = destFields.get(field.getKey());
+                if (!field1.getType().equals(field.getValue().getType())) {
+                    continue;
+                }
+
+                if (fieldValue != null) {
+                    ReflectUtil.invoke(dest, StringUtil.setMethodName(field.getKey()), fieldValue);
+                }
+            }
+        }
+    }
+
     /**
      * @param source
      * @param dest

+ 7 - 2
src/main/java/thyyxxk/webserver/utils/ToolExcel.java

@@ -14,6 +14,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class ToolExcel {
+
     public ToolExcel() {
     }
 
@@ -54,11 +55,15 @@ public class ToolExcel {
         }
     }
 
+    /**
+     * 注意如果是 map 类型的数组,第一个数据的 字段需要和title保持相同
+     *
+     * @param data     数据
+     * @param response 请求
+     */
     public void exportExcel(Iterable<?> data, HttpServletResponse response) {
-
         setCellDateFormat();
         setCellWeight();
-
         writer.setOnlyAlias(true);
         writer.write(data, true);