lighter 3 лет назад
Родитель
Сommit
770183c451

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>10.2.8</version>
+    <version>10.2.9</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
     <properties>

+ 38 - 8
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiZyDao.java

@@ -1,11 +1,11 @@
 package thyyxxk.webserver.dao.his.medicalinsurance;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.*;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyPatientInfo;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.*;
 
 import java.util.Date;
+import java.util.LinkedList;
 import java.util.List;
 
 /**
@@ -118,9 +118,8 @@ public interface SiZyDao {
     ZyPatientInfo selectPatientInfo(@Param("inpatientNo") String inpatientNo);
 
     /**
-     * 获取未上传至医保中心的费用明细
+     * 获取未上传至医保中心的收费费用明细
      *
-     * @param iPage       分页信息
      * @param inpatientNo 住院号
      * @param admissTimes 住院次数
      * @param ledgerSn    账页号
@@ -145,11 +144,42 @@ public interface SiZyDao {
             "bilgDrName=isnull(isnull((select rtrim(name) from a_employee_mi where code=doctor_code), " +
             "(select rtrim(name) from a_employee_mi where code=refer_physician)),(select rtrim(name) from a_employee_mi where code=op_id_code)) " +
             "from zy_detail_charge a where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes} and " +
-            "ledger_sn=#{ledgerSn} and isnull(trans_flag_yb,0) in ('',0)")
-    IPage<FeeDtle> selectNotUploadedFees(IPage<FeeDtle> iPage,
-                                                @Param("inpatientNo") String inpatientNo,
-                                                @Param("admissTimes") int admissTimes,
-                                                @Param("ledgerSn") int ledgerSn);
+            "ledger_sn=#{ledgerSn} and charge_amount>0 and isnull(trans_flag_yb,0) in ('',0)")
+    LinkedList<FeeDtle> selectNotUploadedPositiveFees(@Param("inpatientNo") String inpatientNo,
+                                                      @Param("admissTimes") int admissTimes,
+                                                      @Param("ledgerSn") int ledgerSn);
+
+    /**
+     * 获取未上传至医保中心的退费费用明细
+     *
+     * @param inpatientNo 住院号
+     * @param admissTimes 住院次数
+     * @param ledgerSn    账页号
+     * @return 费用明细
+     */
+    @Select("select detail_sn as feedetlSn, " +
+            "order_no as drordNo, " +
+            "initFeedetlSn=case when ori_detail_sn=-1 then null else ori_detail_sn end, " +
+            "charge_date as feeOcurTime, " +
+            "charge_code_mx as medinsListCodg, " +
+            "charge_fee as detItemFeeSumamt, " +
+            "charge_amount as cnt, " +
+            "pric=charge_fee/charge_amount, " +
+            "ward_code as bilgDeptCodg, " +
+            "hospApprFlag=case when yb_self_flag='1' then '2' else '1' end," +
+            "mdtrtId=(select mdtrt_id from t_si_pat_info b where b.pat_no=inpatient_no and b.times=admiss_times and b.ledger_sn=a.ledger_sn), " +
+            "psnNo=(select psn_no from t_si_pat_info b where b.pat_no=inpatient_no and b.times=admiss_times and b.ledger_sn=a.ledger_sn), " +
+            "medType=(select med_type from t_si_pat_info b where b.pat_no=inpatient_no and b.times=admiss_times and b.ledger_sn=a.ledger_sn), " +
+            "medListCodg=isnull((select max(national_code) from yp_zd_dict where code=charge_code_mx),(select max(national_code) from zd_charge_item where code=charge_code_mx)), " +
+            "bilgDeptName=(select name from zd_unit_code where code=ward_code), " +
+            "bilgDrCodg=isnull(isnull(doctor_code,refer_physician), op_id_code), " +
+            "bilgDrName=isnull(isnull((select rtrim(name) from a_employee_mi where code=doctor_code), " +
+            "(select rtrim(name) from a_employee_mi where code=refer_physician)),(select rtrim(name) from a_employee_mi where code=op_id_code)) " +
+            "from zy_detail_charge a where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes} and " +
+            "ledger_sn=#{ledgerSn} and charge_amount<0 and ori_detail_sn is not null and isnull(trans_flag_yb,0) in ('',0)")
+    LinkedList<FeeDtle> selectNotUploadedNegativeFees(@Param("inpatientNo") String inpatientNo,
+                                                      @Param("admissTimes") int admissTimes,
+                                                      @Param("ledgerSn") int ledgerSn);
 
     /**
      * 更新住院费用表的上传状态

+ 33 - 41
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiZyService.java

@@ -3,13 +3,10 @@ package thyyxxk.webserver.service.medicalinsurance;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
-import thyyxxk.webserver.constants.Capacity;
 import thyyxxk.webserver.constants.sidicts.*;
 import thyyxxk.webserver.constants.YesOrNo;
 import thyyxxk.webserver.dao.his.medicalinsurance.*;
@@ -29,6 +26,7 @@ import thyyxxk.webserver.websocket.WebSocketServer;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Queue;
 
 /**
  * @description: 住院医保交易
@@ -198,55 +196,49 @@ public class SiZyService {
         p.setMdtrtId(siPatInfo.getMdtrtId());
         p.setPsnNo(siPatInfo.getPsnNo());
         p.setMedType(siPatInfo.getMedType());
-        int currentPage = 1;
-        final int pageSize = 100;
-        IPage<FeeDtle> iPage = new Page<>(currentPage, pageSize);
-        iPage = dao.selectNotUploadedFees(iPage, o.getInpatientNo(), o.getAdmissTimes(), o.getLedgerSn());
-        if (null == iPage || iPage.getTotal() == 0) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有需要上传的费用。");
+        Queue<FeeDtle> allPositiveFees = dao.selectNotUploadedPositiveFees(o.getInpatientNo(), o.getAdmissTimes(), o.getLedgerSn());
+        Queue<FeeDtle> allNegativeFees = dao.selectNotUploadedNegativeFees(o.getInpatientNo(), o.getAdmissTimes(), o.getLedgerSn());
+        if (allPositiveFees.size() == 0 && allNegativeFees.size() == 0) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,
+                    "此患者没有符合上传条件的费用(上传条件:收费需要匹配,即医保码不能为空;退费需要有对应的收费流水号)。");
         }
         int index = 0;
-        int feeSize = (int) iPage.getTotal();
-        while (iPage.getRecords().size() > 0) {
-            // 没匹配的直接移出去
-            iPage.getRecords().removeIf(itm -> StringUtil.isBlank(itm.getMedListCodg()));
-            prepareUploadFees(iPage.getRecords(), p);
-            index += iPage.getTotal();
-            JSONObject socketMessage = new JSONObject();
-            socketMessage.put("name", "updateProgress");
-            socketMessage.put("percentage", makePercentage(index, feeSize));
-            WebSocketServer.sendMessage(o.getSid(), socketMessage.toJSONString());
-            iPage = new Page<>(currentPage+=1, pageSize);
-            iPage = dao.selectNotUploadedFees(iPage, o.getInpatientNo(), o.getAdmissTimes(), o.getLedgerSn());
-        }
+        int feeSize = allPositiveFees.size() + allNegativeFees.size();
+        prepareUploadFees(allPositiveFees, index, feeSize, p, o.getSid());
+        prepareUploadFees(allNegativeFees, index, feeSize, p, o.getSid());
         return hospitalizationPreSettlement(p);
     }
 
-    private int makePercentage(int index, int size) {
-        float per = (float)index / (float)size;
-        return (int) (per * 100);
-    }
-
-    private void prepareUploadFees(List<FeeDtle> fees, ZyPatientInfo p) {
-        if (fees.size() == 0) {
-            return;
-        }
+    private void prepareUploadFees(Queue<FeeDtle> feeQueue, int index, int feeSize, ZyPatientInfo p, String sid) {
         JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_HOSPITALIZATION_FEE_DETAILS);
-        if (fees.size() <= Capacity.TWENTY) {
-            executeUploadFees(input, fees, p);
-        } else {
-            List<FeeDtle> tempList = new ArrayList<>();
-            for (FeeDtle item : fees) {
-                tempList.add(item);
-                if (tempList.size() == Capacity.TWENTY) {
+        JSONObject socketMessage = new JSONObject();
+        socketMessage.put("name", "updateProgress");
+        socketMessage.put("percentage", 0);
+        List<FeeDtle> tempList = new ArrayList<>();
+        while (feeQueue.size() > 0) {
+            FeeDtle feeDtle = feeQueue.poll();
+            index ++;
+            assert feeDtle != null;
+            if (StringUtil.notBlank(feeDtle.getMedListCodg())) {
+                tempList.add(feeDtle);
+                if (tempList.size() == 100) {
                     executeUploadFees(input, tempList, p);
                     tempList.clear();
+                    socketMessage.replace("percentage", makePercentage(index, feeSize));
+                    WebSocketServer.sendMessage(sid, socketMessage.toJSONString());
                 }
             }
-            if (!tempList.isEmpty()) {
-                executeUploadFees(input, tempList, p);
-            }
         }
+        if (tempList.size() > 0) {
+            executeUploadFees(input, tempList, p);
+            socketMessage.replace("percentage", makePercentage(index, feeSize));
+            WebSocketServer.sendMessage(sid, socketMessage.toJSONString());
+        }
+    }
+
+    private int makePercentage(int index, int size) {
+        float per = (float)index / (float)size;
+        return (int) (per * 100);
     }
 
     private void executeUploadFees(JSONObject input, List<FeeDtle> fees, ZyPatientInfo p) {