Browse Source

代码优化。

lighter 4 years ago
parent
commit
2d5af5db62

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>hnthyyxxk</groupId>
     <artifactId>cssyb-uploadfees</artifactId>
-    <version>0.5</version>
+    <version>0.6</version>
     <name>cssyb-uploadfees</name>
     <description>cssyb upload fees.</description>
 

+ 3 - 2
src/main/java/hnthyyxxk/cssybuploadfees/pojo/Fee.java

@@ -2,9 +2,11 @@ package hnthyyxxk.cssybuploadfees.pojo;
 
 import lombok.Data;
 
+/**
+ * @author dj
+ */
 @Data
 public class Fee {
-    // 项目药品公共字段
     private Integer detailSn;
     private String chargeDate;
     private String chargeCode;
@@ -17,6 +19,5 @@ public class Fee {
     private String amount;
     private String statusFlag;
 
-    // 药品独有字段
     private String chargeAmount;
 }

+ 3 - 0
src/main/java/hnthyyxxk/cssybuploadfees/pojo/UploadFeeParam.java

@@ -2,6 +2,9 @@ package hnthyyxxk.cssybuploadfees.pojo;
 
 import lombok.Data;
 
+/**
+ * @author dj
+ */
 @Data
 public class UploadFeeParam {
     private String sid;

+ 17 - 12
src/main/java/hnthyyxxk/cssybuploadfees/service/UploadFeeService.java

@@ -21,6 +21,9 @@ import java.util.*;
 
 import static hnthyyxxk.cssybuploadfees.utils.DTool.betweenAutoUpload;
 
+/**
+ * @author dj
+ */
 @Slf4j
 @Service
 public class UploadFeeService {
@@ -65,7 +68,7 @@ public class UploadFeeService {
         if (null == param.getSid()) {
             return DJRet.fail(ExceptionEnum.LOGICAL_ERROR, "未检测到连接id,请刷新页面。");
         }
-        if (!param.getSid().equals("autoUpload") && DTool.betweenAutoUpload()) {
+        if (!"autoUpload".equals(param.getSid()) && DTool.betweenAutoUpload()) {
             return DJRet.fail(ExceptionEnum.LOGICAL_ERROR, "01:55:00 至 08:00:00 为自动上传时间,请勿在此时间段内做上传操作!");
         }
         param.setFeeSize(dao.queryFeeSize(param.getInpatientNo(), param.getAdmissTimes()));
@@ -88,40 +91,42 @@ public class UploadFeeService {
         Queue<Fee> fees = flag == 1 ?
                 dao.getCssybProjectFee(param.getInpatientNo(), param.getAdmissTimes()) :
                 dao.getCssybMedicineFee(param.getInpatientNo(), param.getAdmissTimes());
-
         SimpleResponse response = new SimpleResponse();
         if (null == fees || fees.isEmpty()) {
             response.setCode(0);
             return response;
         }
-
         List<Integer> refundDetailSn = new ArrayList<>();
         JSONObject socketMsg = new JSONObject();
-
         while (!fees.isEmpty()) {
             Fee fee = fees.poll();
-            if (null == fee.getYbCode() || fee.getYbCode().trim().equals("")) {
+            if (null == fee.getYbCode() || "".equals(fee.getYbCode().trim())) {
                 String message = "项目/药品【" + fee.getName() + "】未匹配,请联系物价科进行匹配,内线电话:2104";
                 sendUploadFeeResponse(param.getInpatientNo(), param.getName(),
                         fee.getDetailSn(), message, param.getSid());
             }
-            fee.setAmount(flag == 1 ? fee.getAmount() : fee.getChargeAmount());
-            if (fee.getAmount().startsWith("-") && !refundDetailSn.contains(fee.getDetailSn())) {
+            String amount = fee.getAmount();
+            if (null == amount || "".equals(amount.trim())) {
+                amount = fee.getChargeAmount();
+            }
+            if (null == amount || "".equals(amount.trim())) {
+                log.info("项目/药品数量不正确:{}", fee);
+                continue;
+            }
+            if (amount.startsWith("-") && !refundDetailSn.contains(fee.getDetailSn())) {
                 refundDetailSn.add(fee.getDetailSn());
                 fees.offer(fee);
                 log.info("退费项目,安排到末尾 >>> {}", fee);
                 continue;
             }
-            fee.setPrice(DTool.mathDivide(fee.getChargeFee(), fee.getAmount()));
+            fee.setPrice(DTool.mathDivide(fee.getChargeFee(), amount));
             log.info("[ 操作员:{} ] - [ 患者{} ] - 费用上传>>> {}", param.getStaffId(),
                     param.getMainInfo(), JSON.toJSONString(fee));
             String stmt = getUploadFuncId(param.getYbType().trim()) + "^43010150145^" + param.getStaffId() + "^^" +
                     SnowFlakeId.getInstance().nextId() + "^0000^" + param.getYbJlh() + "|" + fee.getYbClass() + "|" +
                     fee.getYbBillCode() + "|" + fee.getDetailSn() + "|" + formatChargeDate(fee.getChargeDate()) + "|"
                     + fee.getChargeCode() + "|" + fee.getYbCode() + "|" + fee.getName() + "|" +
-                    fee.getPrice() + "|" + fee.getAmount() +
-                    "|||||||||||||" + fee.getStatusFlag() + "|^";
-
+                    fee.getPrice() + "|" + amount + "|||||||||||||" + fee.getStatusFlag() + "|^";
             response = executeSybTrade(param.getStaffId(), stmt);
             log.info("[ 操作员:{} ] - [ 患者{} ] - 费用上传回执>>> {}", param.getStaffId(), param.getMainInfo(), response);
             if ((response.getCode() == 0) || (response.getMessage().contains("主键重复"))) {
@@ -202,7 +207,7 @@ public class UploadFeeService {
     }
 
     private String getUploadFuncId(String ybType) {
-        final boolean isGs = ybType.equals("42") || ybType.equals("44");
+        final boolean isGs = "42".equals(ybType) || "44".equals(ybType);
         return isGs ? "2330" : "2310";
     }
 

+ 3 - 0
src/main/java/hnthyyxxk/cssybuploadfees/utils/MsgProducer.java

@@ -4,6 +4,9 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+/**
+ * @author dj
+ */
 @Component
 public class MsgProducer {