|
@@ -37,6 +37,14 @@ public class SiZyFeeService {
|
|
|
@Value("${upld-notify-url}")
|
|
|
private String upldNotifyUrl;
|
|
|
|
|
|
+ private static final ConcurrentHashMap<String, CodeName> uploadingMap;
|
|
|
+ private static final ConcurrentHashMap<String, CodeName> staffMap;
|
|
|
+
|
|
|
+ static {
|
|
|
+ uploadingMap = new ConcurrentHashMap<>();
|
|
|
+ staffMap = new ConcurrentHashMap<>();
|
|
|
+ }
|
|
|
+
|
|
|
@Autowired
|
|
|
public SiZyFeeService(SiZyDao zyDao, SiLogDao logDao, ExecService exec, RedisLikeService redis) {
|
|
|
this.zyDao = zyDao;
|
|
@@ -82,6 +90,54 @@ public class SiZyFeeService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public ResultVo<String> uploadMultiplePatientFees(List<Overview> overviews) {
|
|
|
+ for (int i = 0; i < overviews.size(); i++) {
|
|
|
+ Overview overview = overviews.get(i);
|
|
|
+ if (!staffMap.containsKey(overview.getStaffId())) {
|
|
|
+ staffMap.put(overview.getStaffId(), zyDao.selectStaff(overview.getStaffId()));
|
|
|
+ }
|
|
|
+ sendUpdatePatientIndexMsg(i + 1, overview.getSid());
|
|
|
+ if (uploadingMap.containsKey(overview.getInpatientNo())) {
|
|
|
+ String message = "该患者正在其他机器上传,操作人是" +
|
|
|
+ uploadingMap.get(overview.getInpatientNo()).getStaff();
|
|
|
+ sendDuringUpload(overview, message);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ uploadingMap.put(overview.getInpatientNo(), staffMap.get(overview.getStaffId()));
|
|
|
+ try {
|
|
|
+ ResultVo<String> resVo = uploadFeeDetail(overview);
|
|
|
+ sendDuringUpload(overview, resVo.getCode() == ExceptionEnum.SUCCESS.getCode() ?
|
|
|
+ resVo.getData() : resVo.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ uploadingMap.remove(overview.getInpatientNo());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultVo<String> uploadSinglePatientFees(Overview overview) {
|
|
|
+ if (uploadingMap.containsKey(overview.getInpatientNo())) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者正在其他机器上传,操作人是" +
|
|
|
+ uploadingMap.get(overview.getInpatientNo()).getStaff());
|
|
|
+ }
|
|
|
+ if (!staffMap.containsKey(overview.getStaffId())) {
|
|
|
+ staffMap.put(overview.getStaffId(), zyDao.selectStaff(overview.getStaffId()));
|
|
|
+ }
|
|
|
+ uploadingMap.put(overview.getInpatientNo(), staffMap.get(overview.getStaffId()));
|
|
|
+ ResultVo<String> resultVo;
|
|
|
+ try {
|
|
|
+ resultVo = uploadFeeDetail(overview);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ resultVo = ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR);
|
|
|
+ } finally {
|
|
|
+ uploadingMap.remove(overview.getInpatientNo());
|
|
|
+ }
|
|
|
+ return resultVo;
|
|
|
+ }
|
|
|
+
|
|
|
public ResultVo<String> uploadFeeDetail(Overview o) {
|
|
|
if (null == o.getLedgerSn()) {
|
|
|
Integer ledger = zyDao.selectMaxLedgerSn(o.getInpatientNo(), o.getAdmissTimes());
|
|
@@ -100,14 +156,14 @@ public class SiZyFeeService {
|
|
|
beforeUpload(o);
|
|
|
zyDao.hisRecount(o.getInpatientNo(), o.getAdmissTimes(), o.getLedgerSn());
|
|
|
zyDao.fillReferPhysician(o.getInpatientNo(), o.getAdmissTimes());
|
|
|
- ZyPatientInfo p = zyDao.selectPatientInfo(o.getInpatientNo());
|
|
|
- p.setSid(o.getSid());
|
|
|
- p.setStaffId(o.getStaffId());
|
|
|
- p.setLedgerSn(o.getLedgerSn());
|
|
|
- p.setMdtrtId(siPatInfo.getMdtrtId());
|
|
|
- p.setPsnNo(siPatInfo.getPsnNo());
|
|
|
- p.setMedType(siPatInfo.getMedType());
|
|
|
- p.setAdmdvs(siPatInfo.getInsuplcAdmdvs());
|
|
|
+ ZyPatientInfo zyPtnt = zyDao.selectPatientInfo(o.getInpatientNo());
|
|
|
+ zyPtnt.setSid(o.getSid());
|
|
|
+ zyPtnt.setStaffId(o.getStaffId());
|
|
|
+ zyPtnt.setLedgerSn(o.getLedgerSn());
|
|
|
+ zyPtnt.setMdtrtId(siPatInfo.getMdtrtId());
|
|
|
+ zyPtnt.setPsnNo(siPatInfo.getPsnNo());
|
|
|
+ zyPtnt.setMedType(siPatInfo.getMedType());
|
|
|
+ zyPtnt.setAdmdvs(siPatInfo.getInsuplcAdmdvs());
|
|
|
if (o.getMidSetl()) {
|
|
|
List<Integer> notAllowedSns = zyDao.selectNotAllowedSnForMidSetl(o.getInpatientNo(), o.getAdmissTimes(),
|
|
|
o.getLedgerSn(), o.getEndtime());
|
|
@@ -116,14 +172,14 @@ public class SiZyFeeService {
|
|
|
for (int sn : notAllowedSns) {
|
|
|
tempSns.add(sn);
|
|
|
if (tempSns.size() == 100) {
|
|
|
- p.setDetailSns(tempSns);
|
|
|
- revokeUploadFees(p);
|
|
|
+ zyPtnt.setDetailSns(tempSns);
|
|
|
+ revokeUploadFees(zyPtnt);
|
|
|
tempSns.clear();
|
|
|
}
|
|
|
}
|
|
|
if (tempSns.size() > 0) {
|
|
|
- p.setDetailSns(tempSns);
|
|
|
- revokeUploadFees(p);
|
|
|
+ zyPtnt.setDetailSns(tempSns);
|
|
|
+ revokeUploadFees(zyPtnt);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -131,14 +187,14 @@ public class SiZyFeeService {
|
|
|
Queue<FeeDtle> allPositiveFees = allFees.get("positive");
|
|
|
Queue<FeeDtle> allNegativeFees = allFees.get("negative");
|
|
|
if (allPositiveFees.size() == 0 && allNegativeFees.size() == 0) {
|
|
|
- return hospitalizationPreSettlement(p, o);
|
|
|
+ return hospitalizationPreSettlement(zyPtnt, o);
|
|
|
}
|
|
|
int index = 0;
|
|
|
int feeSize = allPositiveFees.size() + allNegativeFees.size();
|
|
|
|
|
|
- int[] pstvres = prepareUploadFees(allPositiveFees, index, feeSize, p, o.getSid());
|
|
|
+ int[] pstvres = prepareUploadFees(allPositiveFees, index, feeSize, zyPtnt, o.getSid());
|
|
|
index = pstvres[0];
|
|
|
- int[] ngtvres = prepareUploadFees(allNegativeFees, index, feeSize, p, o.getSid());
|
|
|
+ int[] ngtvres = prepareUploadFees(allNegativeFees, index, feeSize, zyPtnt, o.getSid());
|
|
|
index = ngtvres[0];
|
|
|
|
|
|
if (pstvres[1] == 1 || ngtvres[1] == 1) {
|
|
@@ -147,11 +203,10 @@ public class SiZyFeeService {
|
|
|
allNegativeFees = allFees.get("negative");
|
|
|
|
|
|
log.info("医保中心数据有遗漏,继续上传遗漏部分。");
|
|
|
- index = prepareUploadFees(allPositiveFees, index, feeSize, p, o.getSid())[0];
|
|
|
- prepareUploadFees(allNegativeFees, index, feeSize, p, o.getSid());
|
|
|
+ index = prepareUploadFees(allPositiveFees, index, feeSize, zyPtnt, o.getSid())[0];
|
|
|
+ prepareUploadFees(allNegativeFees, index, feeSize, zyPtnt, o.getSid());
|
|
|
}
|
|
|
-
|
|
|
- return hospitalizationPreSettlement(p, o);
|
|
|
+ return hospitalizationPreSettlement(zyPtnt, o);
|
|
|
}
|
|
|
|
|
|
private Map<String, Queue<FeeDtle>> getAllFeesNotUploaded(Overview o) {
|
|
@@ -261,6 +316,15 @@ public class SiZyFeeService {
|
|
|
sendUploadResponse(p, template, message);
|
|
|
}
|
|
|
|
|
|
+ private void sendUpdatePatientIndexMsg(int index, String sid) {
|
|
|
+ JSONObject socketMsg = new JSONObject();
|
|
|
+ socketMsg.put("name", "updatePatientIndex");
|
|
|
+ socketMsg.put("patientIndex", index);
|
|
|
+ RestTemplate template = new RestTemplate();
|
|
|
+ template.postForObject(upldNotifyUrl + "/sendById",
|
|
|
+ new PureCodeName(sid, socketMsg.toJSONString()), String.class);
|
|
|
+ }
|
|
|
+
|
|
|
private void sendUploadResponse(ZyPatientInfo p, RestTemplate template, String message) {
|
|
|
JSONObject socketMsg = new JSONObject();
|
|
|
socketMsg.put("name", "uploadFeeResponse");
|
|
@@ -275,6 +339,21 @@ public class SiZyFeeService {
|
|
|
new PureCodeName(p.getSid(), socketMsg.toJSONString()), String.class);
|
|
|
}
|
|
|
|
|
|
+ private void sendDuringUpload(Overview overview, String message) {
|
|
|
+ RestTemplate template = new RestTemplate();
|
|
|
+ JSONObject socketMsg = new JSONObject();
|
|
|
+ socketMsg.put("name", "uploadFeeResponse");
|
|
|
+ socketMsg.put("patNo", overview.getInpatientNo());
|
|
|
+ socketMsg.put("patName", overview.getName());
|
|
|
+ socketMsg.put("times", overview.getAdmissTimes());
|
|
|
+ socketMsg.put("ledgerSn", overview.getLedgerSn());
|
|
|
+ socketMsg.put("message", message);
|
|
|
+ socketMsg.put("title", String.format("住院号:【%s】,住院次数:【%d】,账页号:【%d】。",
|
|
|
+ overview.getInpatientNo(), overview.getAdmissTimes(), overview.getLedgerSn()));
|
|
|
+ template.postForObject(upldNotifyUrl + "/sendById",
|
|
|
+ new PureCodeName(overview.getSid(), socketMsg.toJSONString()), String.class);
|
|
|
+ }
|
|
|
+
|
|
|
private int[] executeUploadFees(JSONObject input, List<FeeDtle> fees, ZyPatientInfo p) {
|
|
|
String ref = JSONArray.toJSONString(fees);
|
|
|
input.getJSONObject("input").put("feedetail", JSONArray.parse(ref));
|