|
@@ -6,7 +6,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
|
|
|
-import thyyxxk.wxservice_server.constant.Constants;
|
|
|
import thyyxxk.wxservice_server.dao.PatientCardsDao;
|
|
|
import thyyxxk.wxservice_server.entity.ResultVo;
|
|
|
import thyyxxk.wxservice_server.entity.analyzeidcard.IdCardAnalyzeResult;
|
|
@@ -72,63 +71,56 @@ public class PatientCardsService {
|
|
|
|
|
|
public ResultVo<HashMap<String, Object>> bindPatientId(IdCardAnalyzeResult param) {
|
|
|
log.info("绑定就诊卡:{}", param);
|
|
|
- final List<IdCardAnalyzeResult> list;
|
|
|
- if (param.getCardType() == 0) {
|
|
|
- list = dao.getPatientBaseInfoByPatientId(param.getCardNo());
|
|
|
- } else if (param.getCardType() == 1) {
|
|
|
- list = dao.getPatientBaseInfoByMzCardNo(param.getCardNo());
|
|
|
- } else {
|
|
|
- list = dao.getPatientBaseInfoBySocialNo(param.getCardNo());
|
|
|
- }
|
|
|
+ String column = param.getCardType() == 0 ? "patient_id" :
|
|
|
+ (param.getCardType() == 1 ? "ic_card_no" : "social_no");
|
|
|
+ List<IdCardAnalyzeResult> list = dao.selectMzPatientBriefInfo(column, param.getCardNo());
|
|
|
if (null == list || list.isEmpty()) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到对应的就诊卡信息!");
|
|
|
- } else {
|
|
|
- HashMap<String, Object> map = new HashMap<>(Constants.Capacity.TWO);
|
|
|
- if (list.size() == 1) {
|
|
|
- IdCardAnalyzeResult temp = list.get(0);
|
|
|
- if (param.getName().trim().equals(temp.getName())) {
|
|
|
- param.setPatientId(temp.getPatientId());
|
|
|
- param.setIcCardNo(temp.getIcCardNo());
|
|
|
- param.setSocialNo(temp.getSocialNo());
|
|
|
- final int count = dao.isThisCardBindBefore(param.getPatientId(), param.getOpenId());
|
|
|
- if (count > 0) {
|
|
|
- dao.bindPatientCardAgain(param);
|
|
|
- } else {
|
|
|
- if (dao.validBindCount(param.getOpenId()) == 0) {
|
|
|
- param.setIsDefault(1);
|
|
|
- } else {
|
|
|
- param.setIsDefault(0);
|
|
|
- }
|
|
|
- dao.bindPatientCard(param);
|
|
|
- }
|
|
|
- map.put("code", 0);
|
|
|
- map.put("cards", dao.getBindPatientCard(param.getOpenId()));
|
|
|
- log.info("绑定就诊卡成功:{}", param);
|
|
|
- String msgContent = "{\"touser\":\"\",\"data\":" +
|
|
|
- "{\"keyword3\":{\"color\":\"#173177\",\"value\":\"" + temp.getIcCardNo() + "\"}," +
|
|
|
- "\"keyword4\":{\"color\":\"#173177\",\"value\":\"" +
|
|
|
- DateUtil.formatDatetime(new Date(), "yyyy-MM-dd HH:mm:ss") + "\"}," +
|
|
|
- "\"keyword1\":{\"color\":\"#173177\",\"value\":\"" + param.getName() + "\"}," +
|
|
|
- "\"keyword2\":{\"color\":\"#173177\",\"value\":\"门诊就诊卡\"}," +
|
|
|
- "\"remark\":{\"color\":\"#FF0000\",\"value\":\"感谢您的使用,祝您健康!\"}," +
|
|
|
- "\"first\":{\"color\":\"#FF0000\",\"value\":\"您好,您已成功绑定就诊卡!\"}}," +
|
|
|
- "\"template_id\":\"3bXASQD7J9t8qkJ1x-zIrutOCIadP9neI-dXQOBIQQk\"," +
|
|
|
- "\"url\":\"\"}";
|
|
|
- PushMessageParam pojo = new PushMessageParam();
|
|
|
- pojo.setCardNo(temp.getIcCardNo());
|
|
|
- pojo.setMsgContext(JSONObject.parseObject(msgContent));
|
|
|
- pushWxMessageService.pushMessage(pojo);
|
|
|
- return ResultVoUtil.success(map);
|
|
|
- } else {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "就诊卡姓名信息不匹配!");
|
|
|
- }
|
|
|
- } else {
|
|
|
- map.put("code", 1);
|
|
|
- map.put("cards", list);
|
|
|
- log.info("绑定就诊卡: 身份证{} 有多张就诊卡:{}", param.getCardNo(), list);
|
|
|
- return ResultVoUtil.success(map);
|
|
|
+ }
|
|
|
+ if (list.size() > 1) {
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("code", 1);
|
|
|
+ map.put("cards", list);
|
|
|
+ return ResultVoUtil.success(map);
|
|
|
+ }
|
|
|
+ IdCardAnalyzeResult mzPatientMi = list.get(0);
|
|
|
+ if (param.getName().trim().equals(mzPatientMi.getName())) {
|
|
|
+ param.setPatientId(mzPatientMi.getPatientId());
|
|
|
+ param.setIcCardNo(mzPatientMi.getIcCardNo());
|
|
|
+ param.setSocialNo(mzPatientMi.getSocialNo());
|
|
|
+ int historyBindCount = dao.selectHistoryBindCount(param.getPatientId(), param.getOpenId());
|
|
|
+ if (historyBindCount > 0) {
|
|
|
+ dao.unfrozenPatientCard(param);
|
|
|
+ return ResultVoUtil.success(bindCardSuccess(param));
|
|
|
}
|
|
|
+ int validBindCount = dao.selectValidBindCount(param.getOpenId());
|
|
|
+ param.setIsDefault(validBindCount == 0 ? 1 : 0);
|
|
|
+ dao.bindPatientCard(param);
|
|
|
+ return ResultVoUtil.success(bindCardSuccess(param));
|
|
|
}
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "就诊卡姓名信息不匹配!");
|
|
|
+ }
|
|
|
+
|
|
|
+ private HashMap<String, Object> bindCardSuccess(IdCardAnalyzeResult param) {
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("code", 0);
|
|
|
+ map.put("cards", dao.getBindPatientCard(param.getOpenId()));
|
|
|
+ log.info("绑定就诊卡成功:{}", param);
|
|
|
+ String msgContent = "{\"touser\":\"\",\"data\":" +
|
|
|
+ "{\"keyword3\":{\"color\":\"#173177\",\"value\":\"" + param.getIcCardNo() + "\"}," +
|
|
|
+ "\"keyword4\":{\"color\":\"#173177\",\"value\":\"" +
|
|
|
+ DateUtil.formatDatetime(new Date(), "yyyy-MM-dd HH:mm:ss") + "\"}," +
|
|
|
+ "\"keyword1\":{\"color\":\"#173177\",\"value\":\"" + param.getName() + "\"}," +
|
|
|
+ "\"keyword2\":{\"color\":\"#173177\",\"value\":\"门诊就诊卡\"}," +
|
|
|
+ "\"remark\":{\"color\":\"#FF0000\",\"value\":\"感谢您的使用,祝您健康!\"}," +
|
|
|
+ "\"first\":{\"color\":\"#FF0000\",\"value\":\"您好,您已成功绑定就诊卡!\"}}," +
|
|
|
+ "\"template_id\":\"3bXASQD7J9t8qkJ1x-zIrutOCIadP9neI-dXQOBIQQk\"," +
|
|
|
+ "\"url\":\"\"}";
|
|
|
+ PushMessageParam pojo = new PushMessageParam();
|
|
|
+ pojo.setCardNo(param.getIcCardNo());
|
|
|
+ pojo.setMsgContext(JSONObject.parseObject(msgContent));
|
|
|
+ pushWxMessageService.pushMessage(pojo);
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
public ResultVo<String> setDefaultCard(String patientId, String openId) {
|
|
@@ -148,7 +140,7 @@ public class PatientCardsService {
|
|
|
|
|
|
public ResultVo<List<IdCardAnalyzeResult>> relieveBindCard(IdCardAnalyzeResult param) {
|
|
|
log.info("解除就诊卡绑定:{}", param);
|
|
|
- dao.unBindPatientCard(param.getPatientId(), param.getOpenId());
|
|
|
+ dao.frozenPatientCard(param.getPatientId(), param.getOpenId());
|
|
|
return ResultVoUtil.success(dao.getBindPatientCard(param.getOpenId()));
|
|
|
}
|
|
|
|
|
@@ -158,7 +150,7 @@ public class PatientCardsService {
|
|
|
pojo.setCardNo(param.getCardNo());
|
|
|
String msgContent;
|
|
|
if (param.getActionType() == 1) {
|
|
|
- dao.updateCardNo(param.getCardNo(), param.getOldCardNo());
|
|
|
+ dao.updateIcCardNo(param.getCardNo(), param.getOldCardNo());
|
|
|
msgContent = "{\"touser\":\"\",\"data\":" +
|
|
|
"{\"keyword3\":{\"color\":\"#173177\",\"value\":\"" + param.getCardNo() + "\"}," +
|
|
|
"\"keyword1\":{\"color\":\"#173177\",\"value\":\"" + dao.selectPatientNameByCardNo(param.getCardNo()) + "\"}," +
|