|  | @ -2,12 +2,15 @@ package com.yihu.jw.hospital.prescription.service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.ObjectMapper;
 | 
	
		
			
				|  |  | import com.yihu.jw.dict.dao.BaseDictJobTitleDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.dict.dao.BaseJobCategoryDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.dict.dao.DictDeptDescDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.dict.dao.DictHospitalDeptDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.service.BaseDoctorInfoService;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.area.BaseDrugStoreDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.dict.BaseJobCategoryDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.dict.DictDeptDescDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
	
	
		
			
				|  | @ -127,6 +130,8 @@ import java.text.ParseException;
 | 
	
		
			
				|  |  | import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import static javafx.scene.input.KeyCode.L;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * Created by Trick on 2019/5/17.
 | 
	
		
			
				|  |  |  */
 | 
	
	
		
			
				|  | @ -274,6 +279,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     private BaseNatAppointmentDao baseNatAppointmentDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PayInfoNoticeService payInfoNoticeService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseJobCategoryDao jobCategoryDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -10708,9 +10715,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             businessDO.setPayType(1);
 | 
	
		
			
				|  |  |             businessDO.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |             businessOrderDao.save(businessDO);
 | 
	
		
			
				|  |  |             logger.info("更新建档信息");
 | 
	
		
			
				|  |  |             BaseJobCategoryDO jobCategoryDO =jobCategoryDao.findByName(firstJobName);
 | 
	
		
			
				|  |  |             Float zy= 0f;
 | 
	
		
			
				|  |  |             if (jobCategoryDO!=null){
 | 
	
		
			
				|  |  |                 zy=Float.parseFloat(jobCategoryDO.getId()+"");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             ykyyEntranceService.updatePatientJd(patientId,address,mobile,zy,demoFlag);
 | 
	
		
			
				|  |  |             //同步眼科医院
 | 
	
		
			
				|  |  |             logger.info("开始同步眼科医院");
 | 
	
		
			
				|  |  |             ykyyEntranceService.saveKsjc(baseNatAppointmentDO,demoFlag);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //预约成功后发送支付模板消息
 | 
	
		
			
				|  |  |             sendYktemplateMessage(baseNatAppointmentDO.getId(),false);
 | 
	
		
			
				|  |  |             logger.info("结束同步眼科医院");
 | 
	
	
		
			
				|  | @ -10832,6 +10847,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     BeanUtils.copyProperties(config, newConfig);
 | 
	
		
			
				|  |  |                     newConfig.setFirst(config.getFirst().replace("key1",userName));
 | 
	
		
			
				|  |  |                     newConfig.setKeyword1("核酸检测预约单支付");
 | 
	
		
			
				|  |  |                     if ("3".equalsIgnoreCase(baseNatAppointmentDO.getHospitalFlag())){
 | 
	
		
			
				|  |  |                         newConfig.setKeyword2("厦门大学附属厦门眼科中心思北院区");
 | 
	
		
			
				|  |  |                     }else {
 | 
	
		
			
				|  |  |                         newConfig.setKeyword2("厦门大学附属厦门眼科中心五缘院区");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     newConfig.setKeyword3(map.get("doctorName")==null?"":map.get("doctorName").toString());
 | 
	
		
			
				|  |  |                     newConfig.setKeyword4(userName);
 | 
	
		
			
				|  |  |                     newConfig.setKeyword5(DateUtil.dateToStrLong(baseNatAppointmentDO.getAppointmentTime()));
 | 
	
	
		
			
				|  | @ -10857,6 +10877,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     BeanUtils.copyProperties(configPayNotice, newPayNotice);
 | 
	
		
			
				|  |  |                     newPayNotice.setFirst(configPayNotice.getFirst().replace("key1",userName));
 | 
	
		
			
				|  |  |                     newPayNotice.setKeyword1("核酸检测预约单支付");
 | 
	
		
			
				|  |  |                     if ("3".equalsIgnoreCase(baseNatAppointmentDO.getHospitalFlag())){
 | 
	
		
			
				|  |  |                         newPayNotice.setKeyword2("厦门大学附属厦门眼科中心思北院区");
 | 
	
		
			
				|  |  |                     }else {
 | 
	
		
			
				|  |  |                         newPayNotice.setKeyword2("厦门大学附属厦门眼科中心五缘院区");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     newPayNotice.setKeyword3(map.get("doctorName")==null?"":map.get("doctorName").toString());
 | 
	
		
			
				|  |  |                     newPayNotice.setRemark(configPayNotice.getRemark());
 | 
	
		
			
				|  |  |                     newPayNotice.setUrl(configPayNotice.getUrl()+baseNatAppointmentDO.getId());
 | 
	
	
		
			
				|  | @ -10895,6 +10920,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 "t.pay_status as \"payStatus\"," +
 | 
	
		
			
				|  |  |                 "t.medicare as \"medicare\","+
 | 
	
		
			
				|  |  |                 "t.voucher_no as \"voucherNo\","+
 | 
	
		
			
				|  |  |                 "t.dept as \"dept\","+
 | 
	
		
			
				|  |  |                 "t.dept_name as \"deptName\","+
 | 
	
		
			
				|  |  |                 "t.id as \"id\"," +
 | 
	
		
			
				|  |  |                 "t.card_no_type as \"cardNoType\"," +
 | 
	
		
			
				|  |  |                 "t.appointment_time as \"appointmentTime\" " +
 | 
	
	
		
			
				|  | @ -11004,54 +11031,71 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             try {
 | 
	
		
			
				|  |  |                 BaseNatAppointmentDO baseNatAppointmentDO = baseNatAppointmentDao.findOne(id);
 | 
	
		
			
				|  |  |                 if (null!=baseNatAppointmentDO){
 | 
	
		
			
				|  |  |                     res = entranceService.BS10145("3150000","0001",DateUtil.dateToStrLong(baseNatAppointmentDO.getAppointmentTime()),baseNatAppointmentDO.getMedicare(),baseNatAppointmentDO.getName(),baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getMobile(),baseNatAppointmentDO.getAmpm(),demoFlag);
 | 
	
		
			
				|  |  |                     logger.info("核酸检测预约取消"+res);
 | 
	
		
			
				|  |  |                     com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(res);
 | 
	
		
			
				|  |  |                     Boolean flag = false;
 | 
	
		
			
				|  |  |                     if (jsonObject!=null){
 | 
	
		
			
				|  |  |                         com.alibaba.fastjson.JSONObject object = jsonObject.getJSONObject("MsgInfo");
 | 
	
		
			
				|  |  |                         String Msg = object.getString("Msg");
 | 
	
		
			
				|  |  |                         if (Msg.contains("Error")){
 | 
	
		
			
				|  |  |                             throw new Exception(Msg);
 | 
	
		
			
				|  |  |                         }else {
 | 
	
		
			
				|  |  |                             baseNatAppointmentDO.setIsSuccess("-1");
 | 
	
		
			
				|  |  |                             baseNatAppointmentDO.setCancelReson("患者本人取消");
 | 
	
		
			
				|  |  |                             baseNatAppointmentDO.setCancelTime(new Date());
 | 
	
		
			
				|  |  |                             baseNatAppointmentDO.setCancelBy(patientId);
 | 
	
		
			
				|  |  |                             baseNatAppointmentDao.save(baseNatAppointmentDO);
 | 
	
		
			
				|  |  |                             if (StringUtils.isNoneBlank(baseNatAppointmentDO.getRealOrder())){
 | 
	
		
			
				|  |  |                                 //删除处方
 | 
	
		
			
				|  |  |                                 logger.info("删除处方开始");
 | 
	
		
			
				|  |  |                                 net.sf.json.JSONObject jsondate = new JSONObject();
 | 
	
		
			
				|  |  |                                 jsondate.put("checkPart","鼻/咽拭子");
 | 
	
		
			
				|  |  |                                 jsondate.put("cardNo",baseNatAppointmentDO.getMedicare());
 | 
	
		
			
				|  |  |                                 jsondate.put("chargeFlag","2");
 | 
	
		
			
				|  |  |                                 jsondate.put("chargeCode","361322");
 | 
	
		
			
				|  |  |                                 jsondate.put("icdCode","Z00.000");
 | 
	
		
			
				|  |  |                                 jsondate.put("socialNo",baseNatAppointmentDO.getCardNo());
 | 
	
		
			
				|  |  |                                 jsondate.put("tellPhone",baseNatAppointmentDO.getMobile());
 | 
	
		
			
				|  |  |                                 jsondate.put("address1",baseNatAppointmentDO.getProvinceName());
 | 
	
		
			
				|  |  |                                 jsondate.put("address2",baseNatAppointmentDO.getCityName());
 | 
	
		
			
				|  |  |                                 jsondate.put("address3",baseNatAppointmentDO.getTownName());
 | 
	
		
			
				|  |  |                                 jsondate.put("address4",baseNatAppointmentDO.getStreetName());
 | 
	
		
			
				|  |  |                                 jsondate.put("address5",2);
 | 
	
		
			
				|  |  |                                 jsondate.put("area",baseNatAppointmentDO.getAddress());
 | 
	
		
			
				|  |  |                                 jsondate.put("winNo",6);
 | 
	
		
			
				|  |  |                                 jsondate.put("target",2);
 | 
	
		
			
				|  |  |                                 jsondate.put("quantity",1);
 | 
	
		
			
				|  |  |                                 jsondate.put("serialNo",baseNatAppointmentDO.getRegisterNo());
 | 
	
		
			
				|  |  |                                 jsondate.put("dept",baseNatAppointmentDO.getDept());
 | 
	
		
			
				|  |  |                                 jsondate.put("doctor",baseNatAppointmentDO.getDoctorId());
 | 
	
		
			
				|  |  |                                 jsondate.put("realOrder",baseNatAppointmentDO.getRealOrder());
 | 
	
		
			
				|  |  |                                 JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |                                 array.add(jsondate);
 | 
	
		
			
				|  |  |                                 JSONObject object1  = entranceService.BS10112(array.toString(),demoFlag);
 | 
	
		
			
				|  |  |                                 logger.info("删除处方结束");
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                     if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |                         res = entranceService.BS10145("3150000","0001",DateUtil.dateToStrLong(baseNatAppointmentDO.getAppointmentTime()),baseNatAppointmentDO.getMedicare(),baseNatAppointmentDO.getName(),baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getMobile(),baseNatAppointmentDO.getAmpm(),demoFlag);
 | 
	
		
			
				|  |  |                         logger.info("核酸检测预约取消"+res);
 | 
	
		
			
				|  |  |                         com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(res);
 | 
	
		
			
				|  |  |                         Boolean flag = false;
 | 
	
		
			
				|  |  |                         if (jsonObject!=null){
 | 
	
		
			
				|  |  |                             com.alibaba.fastjson.JSONObject object = jsonObject.getJSONObject("MsgInfo");
 | 
	
		
			
				|  |  |                             String Msg = object.getString("Msg");
 | 
	
		
			
				|  |  |                             if (Msg.contains("Error")){
 | 
	
		
			
				|  |  |                                 throw new Exception(Msg);
 | 
	
		
			
				|  |  |                             }else {
 | 
	
		
			
				|  |  |                                 baseNatAppointmentDO.setIsSuccess("-1");
 | 
	
		
			
				|  |  |                                 baseNatAppointmentDO.setCancelReson("患者本人取消");
 | 
	
		
			
				|  |  |                                 baseNatAppointmentDO.setCancelTime(new Date());
 | 
	
		
			
				|  |  |                                 baseNatAppointmentDO.setCancelBy(patientId);
 | 
	
		
			
				|  |  |                                 baseNatAppointmentDao.save(baseNatAppointmentDO);
 | 
	
		
			
				|  |  |                                 if (StringUtils.isNoneBlank(baseNatAppointmentDO.getRealOrder())){
 | 
	
		
			
				|  |  |                                     //删除处方
 | 
	
		
			
				|  |  |                                     logger.info("删除处方开始");
 | 
	
		
			
				|  |  |                                     net.sf.json.JSONObject jsondate = new JSONObject();
 | 
	
		
			
				|  |  |                                     jsondate.put("checkPart","鼻/咽拭子");
 | 
	
		
			
				|  |  |                                     jsondate.put("cardNo",baseNatAppointmentDO.getMedicare());
 | 
	
		
			
				|  |  |                                     jsondate.put("chargeFlag","2");
 | 
	
		
			
				|  |  |                                     jsondate.put("chargeCode","361322");
 | 
	
		
			
				|  |  |                                     jsondate.put("icdCode","Z00.000");
 | 
	
		
			
				|  |  |                                     jsondate.put("socialNo",baseNatAppointmentDO.getCardNo());
 | 
	
		
			
				|  |  |                                     jsondate.put("tellPhone",baseNatAppointmentDO.getMobile());
 | 
	
		
			
				|  |  |                                     jsondate.put("address1",baseNatAppointmentDO.getProvinceName());
 | 
	
		
			
				|  |  |                                     jsondate.put("address2",baseNatAppointmentDO.getCityName());
 | 
	
		
			
				|  |  |                                     jsondate.put("address3",baseNatAppointmentDO.getTownName());
 | 
	
		
			
				|  |  |                                     jsondate.put("address4",baseNatAppointmentDO.getStreetName());
 | 
	
		
			
				|  |  |                                     jsondate.put("address5",2);
 | 
	
		
			
				|  |  |                                     jsondate.put("area",baseNatAppointmentDO.getAddress());
 | 
	
		
			
				|  |  |                                     jsondate.put("winNo",6);
 | 
	
		
			
				|  |  |                                     jsondate.put("target",2);
 | 
	
		
			
				|  |  |                                     jsondate.put("quantity",1);
 | 
	
		
			
				|  |  |                                     jsondate.put("serialNo",baseNatAppointmentDO.getRegisterNo());
 | 
	
		
			
				|  |  |                                     jsondate.put("dept",baseNatAppointmentDO.getDept());
 | 
	
		
			
				|  |  |                                     jsondate.put("doctor",baseNatAppointmentDO.getDoctorId());
 | 
	
		
			
				|  |  |                                     jsondate.put("realOrder",baseNatAppointmentDO.getRealOrder());
 | 
	
		
			
				|  |  |                                     JSONArray array = new JSONArray();
 | 
	
		
			
				|  |  |                                     array.add(jsondate);
 | 
	
		
			
				|  |  |                                     JSONObject object1  = entranceService.BS10112(array.toString(),demoFlag);
 | 
	
		
			
				|  |  |                                     logger.info("删除处方结束");
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }else if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |                         baseNatAppointmentDO.setIsSuccess("-1");
 | 
	
		
			
				|  |  |                         baseNatAppointmentDO.setCancelReson("患者本人取消");
 | 
	
		
			
				|  |  |                         baseNatAppointmentDO.setCancelTime(new Date());
 | 
	
		
			
				|  |  |                         baseNatAppointmentDO.setCancelBy(patientId);
 | 
	
		
			
				|  |  |                         baseNatAppointmentDao.save(baseNatAppointmentDO);
 | 
	
		
			
				|  |  |                         if (StringUtils.isNoneBlank(baseNatAppointmentDO.getRealOrder())){
 | 
	
		
			
				|  |  |                             logger.info("同步his订单状态"+baseNatAppointmentDO.getRealOrder());
 | 
	
		
			
				|  |  |                             String updateJcsq = "update V_EMR_JCSQ set ZFBZ = 1 where yjxh = "+baseNatAppointmentDO.getRealOrder();
 | 
	
		
			
				|  |  |                             ykyyEntranceService.updateHisStatus(updateJcsq);
 | 
	
		
			
				|  |  |                             String update01sq = "update V_MS_YJ01 set ZFPB = 1 where yjxh = "+baseNatAppointmentDO.getRealOrder();
 | 
	
		
			
				|  |  |                             ykyyEntranceService.updateHisStatus(update01sq);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             } catch (Exception e) {
 |