diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java index a7d4fa6..501361f 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java @@ -1,6 +1,7 @@ package com.lyms.platform.operate.web.facade; import com.lyms.hospitalapi.dzfy.DzfyHisService; +import com.lyms.hospitalapi.pojo.QhdDjq; import com.lyms.hospitalapi.zcfy.ZcPrenatalService; import com.lyms.platform.beans.MsgRequest; import com.lyms.platform.biz.SequenceConstant; @@ -12,17 +13,14 @@ import com.lyms.platform.common.constants.ErrorCodeConstants; import com.lyms.platform.common.dao.BaseQuery; import com.lyms.platform.common.dao.operator.MongoQuery; import com.lyms.platform.common.enums.*; -import com.lyms.platform.common.result.BaseListResponse; -import com.lyms.platform.common.result.BaseObjectResponse; -import com.lyms.platform.common.result.BaseResponse; +import com.lyms.platform.common.result.*; import com.lyms.platform.common.utils.*; import com.lyms.platform.common.utils.BeanUtils; +import com.lyms.platform.common.utils.HttpClientUtil; import com.lyms.platform.operate.web.request.*; import com.lyms.platform.operate.web.result.*; import com.lyms.platform.operate.web.service.ITrackDownService; -import com.lyms.platform.operate.web.utils.InitDataUtils; -import com.lyms.platform.operate.web.utils.MongoUtil; -import com.lyms.platform.operate.web.utils.ResolveUtils; +import com.lyms.platform.operate.web.utils.*; import com.lyms.platform.permission.model.Organization; import com.lyms.platform.permission.model.PatientService; import com.lyms.platform.permission.model.PatientServiceQuery; @@ -397,6 +395,12 @@ public class AntenatalExaminationFacade { return resp; } else { couponService.use(autoMatchFacade.getHospitalId(userId), antExAddRequest.getCouponCode(), userId, model.getId()); + + //秦皇岛妇幼使用完优惠劵后需要把对应优惠劵插入到秦皇岛妇幼his + if ("216".equals(hospitalId)) + { + qhdCouponUse( hospitalId, antExAddRequest.getCouponCode(), userId); + } } } operateLogFacade.addAddOptLog(userId, Integer.parseInt(hospitalId), model, OptActionEnums.ADD.getId(), "添加复诊"); @@ -500,17 +504,15 @@ public class AntenatalExaminationFacade { try { //处方计划 - if (antExamModel.getNextCheckTime() != null) - { - saveCheckItem(antExamModel.getNextCheckTime(),patients); + if (antExamModel.getNextCheckTime() != null) { + saveCheckItem(antExamModel.getNextCheckTime(), patients); } } catch (Exception e) { e.printStackTrace(); } try { //处方计划 - if (antExamModel.getCheckDate() != null) - { + if (antExamModel.getCheckDate() != null) { saveCheckActual(antExamModel.getCheckDate(), patients); } } catch (Exception e) { @@ -519,10 +521,9 @@ public class AntenatalExaminationFacade { try { //处方计划 - if (antExamModel.getNextCheckTime() != null) - { + if (antExamModel.getNextCheckTime() != null) { patients = patientsService.findOnePatientById(antExamModel.getParentId()); - updateTrackCount(antExamModel.getCheckDate(), antExamModel.getNextCheckTime(),patients); + updateTrackCount(antExamModel.getCheckDate(), antExamModel.getNextCheckTime(), patients); } } catch (Exception e) { e.printStackTrace(); @@ -1091,43 +1092,46 @@ public class AntenatalExaminationFacade { patientsService.updateNextCheckTime(excAddRequest.getNextCheckTime(), patients.getId()); patientsService.updatePatient(patients); } catch (Exception e) { - e.printStackTrace(); } try { //修改的时候设置最新的高危/冗余筛查结果和下次产检预约时间 updateLastRisk(patients.getId()); } catch (Exception e) { - e.printStackTrace(); } try { //修改最后一次定义高危的时间 updateLastRhTime(patients.getId(), hospitalId); } catch (Exception e) { - e.printStackTrace(); } try { // 修改最后一次产检时间 setLashCTimes(excAddRequest.getParentId()); } catch (Exception e) { - e.printStackTrace(); } try { - /** 把优惠券设置为已使用状态 */ - couponService.use(hospitalId, excAddRequest.getCouponCode(), userId, excAddRequest.getId()); + if (StringUtils.isNotEmpty(excAddRequest.getCouponCode())) + { + /** 把优惠券设置为已使用状态 */ + couponService.use(hospitalId, excAddRequest.getCouponCode(), userId, excAddRequest.getId()); + + //秦皇岛妇幼使用完优惠劵后需要把对应优惠劵插入到秦皇岛妇幼his + if ("216".equals(hospitalId)) + { + qhdCouponUse( hospitalId, excAddRequest.getCouponCode(), userId); + } + } } catch (Exception e) { - e.printStackTrace(); + } try { //冗余到产检表 antenatalExaminationService.updateAntExRecord(excAddRequest.getId(), 1); } catch (Exception e) { - e.printStackTrace(); } try { //修改数据 syncMaster(excAddRequest.getParentId(), excAddRequest.getNextCheckTime()); } catch (Exception e) { - e.printStackTrace(); } try { //聊城东昌府医院初诊的身高更新到随心测 @@ -1135,7 +1139,6 @@ public class AntenatalExaminationFacade { measureInfoFacade.updateHeight(excAddRequest.getParentId(), hospitalId, excAddRequest.getHeight()); } } catch (Exception e) { - e.printStackTrace(); } try { if (CollectionUtils.isNotEmpty(excAddRequest.getOtherHighRisk())) { @@ -1143,7 +1146,6 @@ public class AntenatalExaminationFacade { highRiskFacade.dispHospHighRiskUse(JsonUtil.array2JsonString(excAddRequest.getOtherHighRisk())); } } catch (Exception e) { - e.printStackTrace(); } try { @@ -1152,7 +1154,6 @@ public class AntenatalExaminationFacade { createSendMsg(patients.getId()); } } catch (Exception e) { - e.printStackTrace(); } //诸城市妇幼保健院 @@ -1169,7 +1170,6 @@ public class AntenatalExaminationFacade { saveCheckItem(DateUtil.parseYMD(excAddRequest.getNextCheckTime()),patients); } } catch (Exception e) { - e.printStackTrace(); } try { //处方计划 @@ -1178,7 +1178,6 @@ public class AntenatalExaminationFacade { saveCheckActual(DateUtil.parseYMD(excAddRequest.getCheckTime()), patients); } } catch (Exception e) { - e.printStackTrace(); } try { @@ -1188,12 +1187,97 @@ public class AntenatalExaminationFacade { saveTrackCount(DateUtil.parseYMD(excAddRequest.getNextCheckTime()), patients); } } catch (Exception e) { - e.printStackTrace(); } } }); } + private void qhdCouponUse(String hospitalId,String code,Integer userId) + { + //获取优惠劵类型 + Map param = new HashMap<>(); + param.put("hospitalId",hospitalId); + param.put("code", code); + Map couponInfo = couponService.findCouponByCode(param); + + if (couponInfo == null || couponInfo.size() == 0) + { + return ; + } + + PatientsQuery patientsQuery = new PatientsQuery(); + patientsQuery.setPid(couponInfo.get("pId")); + patientsQuery.setYn(YnEnums.YES.getId()); + + List list = patientsService.queryPatient1(patientsQuery, "created"); + QhdDjq model = new QhdDjq(); + if (CollectionUtils.isNotEmpty(list)) + { + Patients patient = list.get(0); + model.setPatName(patient.getUsername()); + model.setPatIdCardNo(patient.getCardNo()); + model.setPatCardNo(patient.getVcCardNo()); + model.setPatPhoneNumber(patient.getPhone()); + model.setTokenCardNo(code); + model.setCardStatus("1");//1 正常 9作废 默认1(必须填写) + model.setLmpDate(DateUtil.getyyyy_MM_dd_hms(patient.getLastMenses())); + + AntExChuQuery antExChuQuery1 = new AntExChuQuery(); + antExChuQuery1.setParentId(patient.getId()); + antExChuQuery1.setYn(YnEnums.YES.getId()); + List data = antenatalExaminationService.queryAntExChu(antExChuQuery1); + Integer gravidity = 1; //孕次 + if (CollectionUtils.isNotEmpty(data)) + { + AntExChuModel chuModel = data.get(0); + if (chuModel != null && chuModel.getPregnancyTimes() != null) + { + gravidity = chuModel.getPregnancyTimes(); + } + } + + model.setGravidity(String.valueOf(gravidity)); + Object order = couponInfo.get("couponOrder"); + model.setSerialNumber(order == null ? "0" : order.toString()); + + String hospital = ""; + if (org.apache.commons.lang.StringUtils.isNotEmpty(couponInfo.get("createHospitalId"))) { + Organization organization = organizationService.getOrganization(Integer.parseInt(couponInfo.get("createHospitalId"))); + if (organization != null && organization.getYn() == YnEnums.YES.getId()) { + hospital = organization.getName(); + String areaId = organization.getAreaId(); + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(areaId); + String areaName = basicConfig.getName(); + model.setAreaFrom(areaName); + } + } + model.setPostHos(hospital); + + String checkDoctor = CommonsHelper.getUserName(patient.getBookbuildingDoctor(), usersService); + + model.setPostDoc(checkDoctor); + model.setApplyInfo("产检"); + model.setApplyTime(DateUtil.getyyyy_MM_dd_hms(new Date())); + model.setRemark(""); + Users users = usersService.getUsers(userId); + if (users != null) { + model.setWorkerId(users.getAccount()); + } + else + { + model.setWorkerId(""); + } + } + + System.out.println(model.toString()); + +// String result = HospitalCouponPrintUtils.qhdCouponUse(model); +// if("0".equals(result)){ +// int count = couponService.updateCouponStatus(param); +// System.out.println("update coupon count " + count); +// } + } + public void saveTrackCount(Date nextCheckTime,Patients patients) { TrackCountRecord record = new TrackCountRecord();