|
@@ -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) {
|