|
@@ -14,11 +14,15 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import thyyxxk.sizyfeeoprnsystm.pojo.*;
|
|
|
+import thyyxxk.sizyfeeoprnsystm.pojo.socketmsg.Message;
|
|
|
+import thyyxxk.sizyfeeoprnsystm.pojo.socketmsg.SocketMsg;
|
|
|
+import thyyxxk.sizyfeeoprnsystm.pojo.socketmsg.SocketTask;
|
|
|
import thyyxxk.sizyfeeoprnsystm.utils.*;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* @author dj
|
|
@@ -33,8 +37,8 @@ public class SiZyFeeService {
|
|
|
private final SiLogDao logDao;
|
|
|
private final ExecService exec;
|
|
|
private final RedisLikeService redis;
|
|
|
- @Value("${upld-notify-url}")
|
|
|
- private String upldNotifyUrl;
|
|
|
+ @Value("${socket-api}")
|
|
|
+ private String socketApi;
|
|
|
|
|
|
private static final ConcurrentHashMap<String, CodeName> uploadingMap;
|
|
|
private static final ConcurrentHashMap<String, CodeName> staffMap;
|
|
@@ -90,12 +94,18 @@ public class SiZyFeeService {
|
|
|
}
|
|
|
|
|
|
public ResultVo<String> uploadMultiplePatientFees(List<Overview> overviews) {
|
|
|
+ String sid = overviews.get(0).getStaffId();
|
|
|
+ SocketTask socketTask = new SocketTask();
|
|
|
+ socketTask.setUserCode(sid);
|
|
|
+ socketTask.setTextInside(true);
|
|
|
+ socketTask.setId("feeupload"+sid);
|
|
|
+
|
|
|
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());
|
|
|
+ sendUpdatePatientIndexMsg(socketTask,i + 1, overviews.size());
|
|
|
if (uploadingMap.containsKey(overview.getInpatientNo())) {
|
|
|
String message = "该患者正在其他机器上传,操作人是" +
|
|
|
uploadingMap.get(overview.getInpatientNo()).getStaff();
|
|
@@ -104,7 +114,7 @@ public class SiZyFeeService {
|
|
|
}
|
|
|
uploadingMap.put(overview.getInpatientNo(), staffMap.get(overview.getStaffId()));
|
|
|
try {
|
|
|
- ResultVo<String> resVo = uploadFeeDetail(overview);
|
|
|
+ ResultVo<String> resVo = uploadFeeDetail(overview, socketTask);
|
|
|
sendDuringUpload(overview, resVo.getCode() == ExceptionEnum.SUCCESS.getCode() ?
|
|
|
resVo.getData() : resVo.getMessage());
|
|
|
} catch (Exception e) {
|
|
@@ -116,29 +126,29 @@ public class SiZyFeeService {
|
|
|
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> response = ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR);
|
|
|
- try {
|
|
|
- response = uploadFeeDetail(overview);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("上传费用异常", e);
|
|
|
- response.setMessage("医保中心出错:" + e.getMessage());
|
|
|
- } finally {
|
|
|
- uploadingMap.remove(overview.getInpatientNo());
|
|
|
- }
|
|
|
- return response;
|
|
|
- }
|
|
|
+// 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> response = ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR);
|
|
|
+// try {
|
|
|
+// response = uploadFeeDetail(overview);
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("上传费用异常", e);
|
|
|
+// response.setMessage("医保中心出错:" + e.getMessage());
|
|
|
+// } finally {
|
|
|
+// uploadingMap.remove(overview.getInpatientNo());
|
|
|
+// }
|
|
|
+// return response;
|
|
|
+// }
|
|
|
|
|
|
- public ResultVo<String> uploadFeeDetail(Overview o) {
|
|
|
+ public ResultVo<String> uploadFeeDetail(Overview o, SocketTask socketTask) {
|
|
|
if (null == o.getLedgerSn()) {
|
|
|
Integer ledger = zyDao.selectMaxLedgerSn(o.getInpatientNo(), o.getAdmissTimes());
|
|
|
if (null == ledger) {
|
|
@@ -157,7 +167,7 @@ public class SiZyFeeService {
|
|
|
zyDao.hisRecount(o.getInpatientNo(), o.getAdmissTimes(), o.getLedgerSn());
|
|
|
zyDao.fillReferPhysician(o.getInpatientNo(), o.getAdmissTimes());
|
|
|
ZyPatientInfo zyPtnt = zyDao.selectPatientInfo(o.getInpatientNo());
|
|
|
- zyPtnt.setSid(o.getSid());
|
|
|
+ zyPtnt.setSid(o.getStaffId());
|
|
|
zyPtnt.setStaffId(o.getStaffId());
|
|
|
zyPtnt.setLedgerSn(o.getLedgerSn());
|
|
|
zyPtnt.setMdtrtId(siPatInfo.getMdtrtId());
|
|
@@ -192,9 +202,9 @@ public class SiZyFeeService {
|
|
|
int index = 0;
|
|
|
int feeSize = allPositiveFees.size() + allNegativeFees.size();
|
|
|
|
|
|
- int[] pstvres = prepareUploadFees(allPositiveFees, index, feeSize, zyPtnt, o.getSid());
|
|
|
+ int[] pstvres = prepareUploadFees(allPositiveFees, index, feeSize, zyPtnt, socketTask);
|
|
|
index = pstvres[0];
|
|
|
- int[] ngtvres = prepareUploadFees(allNegativeFees, index, feeSize, zyPtnt, o.getSid());
|
|
|
+ int[] ngtvres = prepareUploadFees(allNegativeFees, index, feeSize, zyPtnt, socketTask);
|
|
|
index = ngtvres[0];
|
|
|
|
|
|
if (pstvres[1] == 1 || ngtvres[1] == 1) {
|
|
@@ -203,8 +213,8 @@ public class SiZyFeeService {
|
|
|
allNegativeFees = allFees.get("negative");
|
|
|
|
|
|
log.info("医保中心数据有遗漏,继续上传遗漏部分。");
|
|
|
- index = prepareUploadFees(allPositiveFees, index, feeSize, zyPtnt, o.getSid())[0];
|
|
|
- prepareUploadFees(allNegativeFees, index, feeSize, zyPtnt, o.getSid());
|
|
|
+ index = prepareUploadFees(allPositiveFees, index, feeSize, zyPtnt, socketTask)[0];
|
|
|
+ prepareUploadFees(allNegativeFees, index, feeSize, zyPtnt, socketTask);
|
|
|
}
|
|
|
return hospitalizationPreSettlement(zyPtnt, o);
|
|
|
}
|
|
@@ -236,16 +246,13 @@ 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, SocketTask socketTask) {
|
|
|
int[] result = new int[] {0,0};
|
|
|
if (feeQueue.isEmpty()) {
|
|
|
return result;
|
|
|
}
|
|
|
JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.UPLOAD_HOSPITALIZATION_FEE_DETAILS,
|
|
|
p.getAdmdvs(), p.getStaffId());
|
|
|
- JSONObject socketMessage = new JSONObject();
|
|
|
- socketMessage.put("name", "updateProgress");
|
|
|
- socketMessage.put("percentage", 0);
|
|
|
List<FeeDtle> tempList = new ArrayList<>();
|
|
|
RestTemplate template = new RestTemplate();
|
|
|
while (!feeQueue.isEmpty()) {
|
|
@@ -293,9 +300,9 @@ public class SiZyFeeService {
|
|
|
result[1] = 1;
|
|
|
}
|
|
|
tempList.clear();
|
|
|
- socketMessage.replace("percentage", makePercentage(index, feeSize));
|
|
|
- template.postForObject(upldNotifyUrl + "/sendById",
|
|
|
- new PureCodeName(sid, socketMessage.toJSONString()), String.class);
|
|
|
+
|
|
|
+ socketTask.setPercentage(makePercentage(index, feeSize));
|
|
|
+ sendTaskProgress(socketTask, template);
|
|
|
}
|
|
|
}
|
|
|
if (!tempList.isEmpty()) {
|
|
@@ -304,54 +311,60 @@ public class SiZyFeeService {
|
|
|
if (upldres[1] > 0) {
|
|
|
result[1] = 1;
|
|
|
}
|
|
|
- socketMessage.replace("percentage", makePercentage(index, feeSize));
|
|
|
- template.postForObject(upldNotifyUrl + "/sendById",
|
|
|
- new PureCodeName(sid, socketMessage.toJSONString()), String.class);
|
|
|
+ socketTask.setPercentage(makePercentage(index, feeSize));
|
|
|
+ sendTaskProgress(socketTask, template);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private void sendTaskProgress(SocketTask socketTask, RestTemplate template) {
|
|
|
+ JSONObject js = new JSONObject();
|
|
|
+ js.put("mode", "SINGLE");
|
|
|
+ js.put("sid", socketTask.getUserCode());
|
|
|
+ js.put("msg", SocketMsg.socketVo(Message.backgroundTask, JSONObject.toJSONString(socketTask)));
|
|
|
+ template.postForObject(socketApi, js, String.class);
|
|
|
+ }
|
|
|
+
|
|
|
private void sendDoctorNoSiCodeMessage(ZyPatientInfo p, RestTemplate template, String doctor, Integer feedetlSn) {
|
|
|
String message = String.format("【流水号:%d】%s医师没有医保赋码,请联系医保科。", feedetlSn, doctor);
|
|
|
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 sendUpdatePatientIndexMsg(SocketTask socketTask, int index, int total) {
|
|
|
+ socketTask.setName("费用上传(共" + total + "人,正在上传第" + index + "人)");
|
|
|
+ socketTask.setPercentage(0);
|
|
|
+ JSONObject js = new JSONObject();
|
|
|
+ js.put("mode", "SINGLE");
|
|
|
+ js.put("sid", socketTask.getUserCode());
|
|
|
+ js.put("msg", SocketMsg.socketVo(Message.backgroundTask, JSONObject.toJSONString(socketTask)));
|
|
|
+ new RestTemplate().postForObject(socketApi, js, String.class);
|
|
|
}
|
|
|
|
|
|
private void sendUploadResponse(ZyPatientInfo p, RestTemplate template, String message) {
|
|
|
- JSONObject socketMsg = new JSONObject();
|
|
|
- socketMsg.put("name", "uploadFeeResponse");
|
|
|
- socketMsg.put("patNo", p.getInpatientNo());
|
|
|
- socketMsg.put("patName", p.getName());
|
|
|
- socketMsg.put("times", p.getAdmissTimes());
|
|
|
- socketMsg.put("ledgerSn", p.getLedgerSn());
|
|
|
- socketMsg.put("message", message);
|
|
|
- socketMsg.put("title", String.format("住院号:【%s】,住院次数:【%d】,账页号:【%d】。",
|
|
|
- p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn()));
|
|
|
- template.postForObject(upldNotifyUrl + "/sendById",
|
|
|
- new PureCodeName(p.getSid(), socketMsg.toJSONString()), String.class);
|
|
|
+ sendUploadResMsg(message, template, p.getInpatientNo(), p.getName(), p.getAdmissTimes(), p.getLedgerSn(), p.getStaffId());
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
+ sendUploadResMsg(message, template, overview.getInpatientNo(), overview.getName(), overview.getAdmissTimes(), overview.getLedgerSn(), overview.getStaffId());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void sendUploadResMsg(String message, RestTemplate template, String inpatientNo, String name, Integer admissTimes, Integer ledgerSn, String sid) {
|
|
|
+ JSONObject msg = new JSONObject();
|
|
|
+ msg.put("name", "uploadFeeResponse");
|
|
|
+ msg.put("patNo", inpatientNo);
|
|
|
+ msg.put("patName", name);
|
|
|
+ msg.put("times", admissTimes);
|
|
|
+ msg.put("ledgerSn", ledgerSn);
|
|
|
+ msg.put("message", message);
|
|
|
+ msg.put("title", String.format("住院号:【%s】,住院次数:【%d】,账页号:【%d】。",
|
|
|
+ inpatientNo, admissTimes, ledgerSn));
|
|
|
+
|
|
|
+ JSONObject js = new JSONObject();
|
|
|
+ js.put("mode", "SINGLE");
|
|
|
+ js.put("sid", sid);
|
|
|
+ js.put("msg", SocketMsg.socketVo(Message.MEDINS_FEE_UPLOAD_PROGRESS, msg));
|
|
|
+ template.postForObject(socketApi, js, String.class);
|
|
|
}
|
|
|
|
|
|
private int[] executeUploadFees(JSONObject input, List<FeeDtle> fees, ZyPatientInfo p) {
|