|
@@ -105,8 +105,6 @@ public class SiZyFeeService {
|
|
|
p.setPsnNo(siPatInfo.getPsnNo());
|
|
|
p.setMedType(siPatInfo.getMedType());
|
|
|
p.setAdmdvs(siPatInfo.getInsuplcAdmdvs());
|
|
|
-
|
|
|
- Queue<FeeDtle> allPositiveFees, allNegativeFees;
|
|
|
if (o.getMidSetl()) {
|
|
|
List<Integer> notAllowedSns = zyDao.selectNotAllowedSnForMidSetl(o.getInpatientNo(), o.getAdmissTimes(),
|
|
|
o.getLedgerSn(), o.getEndtime());
|
|
@@ -125,6 +123,37 @@ public class SiZyFeeService {
|
|
|
revokeUploadFees(p);
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+ Map<String, Queue<FeeDtle>> allFees = getAllFeesNotUploaded(o);
|
|
|
+ Queue<FeeDtle> allPositiveFees = allFees.get("positive");
|
|
|
+ Queue<FeeDtle> allNegativeFees = allFees.get("negative");
|
|
|
+ if (allPositiveFees.size() == 0 && allNegativeFees.size() == 0) {
|
|
|
+ return hospitalizationPreSettlement(p, o);
|
|
|
+ }
|
|
|
+ int index = 0;
|
|
|
+ int feeSize = allPositiveFees.size() + allNegativeFees.size();
|
|
|
+
|
|
|
+ int[] pstvres = prepareUploadFees(allPositiveFees, index, feeSize, p, o.getSid());
|
|
|
+ index = pstvres[0];
|
|
|
+ int[] ngtvres = prepareUploadFees(allNegativeFees, index, feeSize, p, o.getSid());
|
|
|
+ index = ngtvres[0];
|
|
|
+
|
|
|
+ if (pstvres[1] == 1 || ngtvres[1] == 1) {
|
|
|
+ allFees = getAllFeesNotUploaded(o);
|
|
|
+ allPositiveFees = allFees.get("positive");
|
|
|
+ allNegativeFees = allFees.get("negative");
|
|
|
+
|
|
|
+ log.info("医保中心数据有遗漏,继续上传遗漏部分。");
|
|
|
+ index = prepareUploadFees(allPositiveFees, index, feeSize, p, o.getSid())[0];
|
|
|
+ prepareUploadFees(allNegativeFees, index, feeSize, p, o.getSid());
|
|
|
+ }
|
|
|
+
|
|
|
+ return hospitalizationPreSettlement(p, o);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Queue<FeeDtle>> getAllFeesNotUploaded(Overview o) {
|
|
|
+ Queue<FeeDtle> allPositiveFees, allNegativeFees;
|
|
|
+ if (o.getMidSetl()) {
|
|
|
allPositiveFees = zyDao.selectNotUploadedPositiveFeesForMidSetl(o.getInpatientNo(), o.getAdmissTimes(),
|
|
|
o.getLedgerSn(), o.getBegntime(), o.getEndtime());
|
|
|
allNegativeFees = zyDao.selectNotUploadedNegativeFeesForMidSetl(o.getInpatientNo(), o.getAdmissTimes(),
|
|
@@ -137,15 +166,10 @@ public class SiZyFeeService {
|
|
|
allNegativeFees = zyDao.selectNotUploadedNegativeFees(o.getInpatientNo(), o.getAdmissTimes(),
|
|
|
o.getLedgerSn(), today);
|
|
|
}
|
|
|
-
|
|
|
- if (allPositiveFees.size() == 0 && allNegativeFees.size() == 0) {
|
|
|
- return hospitalizationPreSettlement(p, o);
|
|
|
- }
|
|
|
- int index = 0;
|
|
|
- int feeSize = allPositiveFees.size() + allNegativeFees.size();
|
|
|
- index = prepareUploadFees(allPositiveFees, index, feeSize, p, o.getSid());
|
|
|
- prepareUploadFees(allNegativeFees, index, feeSize, p, o.getSid());
|
|
|
- return hospitalizationPreSettlement(p, o);
|
|
|
+ Map<String, Queue<FeeDtle>> result = new HashMap<>();
|
|
|
+ result.put("positive", allPositiveFees);
|
|
|
+ result.put("negative", allNegativeFees);
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
private String getTodayEndTime() {
|
|
@@ -154,7 +178,11 @@ public class SiZyFeeService {
|
|
|
return date + " 23:59:59.999";
|
|
|
}
|
|
|
|
|
|
- private int prepareUploadFees(Queue<FeeDtle> feeQueue, int index, int feeSize, ZyPatientInfo p, String sid) {
|
|
|
+ private int[] prepareUploadFees(Queue<FeeDtle> feeQueue, int index, int feeSize, ZyPatientInfo p, String sid) {
|
|
|
+ int[] result = new int[] {0,0};
|
|
|
+ if (feeQueue.size() == 0) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.UPLOAD_HOSPITALIZATION_FEE_DETAILS,
|
|
|
p.getAdmdvs(), p.getStaffId());
|
|
|
JSONObject socketMessage = new JSONObject();
|
|
@@ -167,33 +195,37 @@ public class SiZyFeeService {
|
|
|
assert feeDtle != null;
|
|
|
tempList.add(feeDtle);
|
|
|
if (tempList.size() == 100) {
|
|
|
- executeUploadFees(input, tempList, p);
|
|
|
+ int[] upldres = executeUploadFees(input, tempList, p);
|
|
|
+ index += upldres[0];
|
|
|
+ if (upldres[1] > 0) {
|
|
|
+ result[1] = 1;
|
|
|
+ }
|
|
|
tempList.clear();
|
|
|
- index += 100;
|
|
|
socketMessage.replace("percentage", makePercentage(index, feeSize));
|
|
|
template.postForObject(upldNotifyUrl + "/sendById",
|
|
|
new PureCodeName(sid, socketMessage.toJSONString()), String.class);
|
|
|
}
|
|
|
}
|
|
|
if (tempList.size() > 0) {
|
|
|
- executeUploadFees(input, tempList, p);
|
|
|
- index += tempList.size();
|
|
|
+ int[] upldres = executeUploadFees(input, tempList, p);
|
|
|
+ index += upldres[0];
|
|
|
+ if (upldres[1] > 0) {
|
|
|
+ result[1] = 1;
|
|
|
+ }
|
|
|
socketMessage.replace("percentage", makePercentage(index, feeSize));
|
|
|
template.postForObject(upldNotifyUrl + "/sendById",
|
|
|
new PureCodeName(sid, socketMessage.toJSONString()), String.class);
|
|
|
}
|
|
|
- return index;
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
- private void executeUploadFees(JSONObject input, List<FeeDtle> fees, ZyPatientInfo p) {
|
|
|
+ private int[] executeUploadFees(JSONObject input, List<FeeDtle> fees, ZyPatientInfo p) {
|
|
|
String ref = JSONArray.toJSONString(fees);
|
|
|
input.getJSONObject("input").put("feedetail", JSONArray.parse(ref));
|
|
|
JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_HOSPITALIZATION_FEE_DETAILS);
|
|
|
log.info("【操作员:{}】,医保费用上传结果:{}", p.getStaffId(), result);
|
|
|
- RestTemplate template = new RestTemplate();
|
|
|
if (null != result) {
|
|
|
if (result.getIntValue(RESULT_CODE) == 0) {
|
|
|
- zyDao.updateTransFlag(p.getInpatientNo(), p.getAdmissTimes(), fees);
|
|
|
JSONArray array = result.getJSONObject(OUTPUT).getJSONArray("result");
|
|
|
List<SiChargeTemp> tempList = new ArrayList<>();
|
|
|
for (int i = 0; i < array.size(); i++) {
|
|
@@ -204,8 +236,11 @@ public class SiZyFeeService {
|
|
|
chrgtemp.setLedgerSn(p.getLedgerSn());
|
|
|
tempList.add(chrgtemp);
|
|
|
}
|
|
|
+ zyDao.updateTransFlag(p.getInpatientNo(), p.getAdmissTimes(), tempList);
|
|
|
zyDao.insertSiChargeTempFeeBatch(tempList);
|
|
|
+ return new int[] {tempList.size(), fees.size() - tempList.size()};
|
|
|
} else {
|
|
|
+ RestTemplate template = new RestTemplate();
|
|
|
String message = result.getString(ERROR_MESSAGE);
|
|
|
JSONObject socketMsg = new JSONObject();
|
|
|
socketMsg.put("name", "uploadFeeResponse");
|
|
@@ -218,8 +253,10 @@ public class SiZyFeeService {
|
|
|
p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn()));
|
|
|
template.postForObject(upldNotifyUrl + "/sendById",
|
|
|
new PureCodeName(p.getSid(), socketMsg.toJSONString()), String.class);
|
|
|
+ return new int[] {fees.size(), 0};
|
|
|
}
|
|
|
}
|
|
|
+ return new int[]{0, 0};
|
|
|
}
|
|
|
|
|
|
public ResultVo<String> hospitalizationPreSettlement(ZyPatientInfo p, Overview o) {
|