|  | @ -158,9 +158,12 @@ import java.text.DecimalFormat;
 | 
	
		
			
				|  |  | import java.text.ParseException;
 | 
	
		
			
				|  |  | import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | import java.time.Duration;
 | 
	
		
			
				|  |  | import java.time.LocalDate;
 | 
	
		
			
				|  |  | import java.time.LocalTime;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | import java.util.concurrent.TimeUnit;
 | 
	
		
			
				|  |  | import java.util.regex.Matcher;
 | 
	
		
			
				|  |  | import java.util.regex.Pattern;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
	
		
			
				|  | @ -1244,6 +1247,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 expressageDO.setDel(1);
 | 
	
		
			
				|  |  |                 expressageDO.setType(1);
 | 
	
		
			
				|  |  |                 expressageDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                 expressageDO.setOutpatientId(outpatient.getId());
 | 
	
		
			
				|  |  |                 prescriptionExpressageDao.save(expressageDO);
 | 
	
	
		
			
				|  | @ -3404,6 +3408,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(prescriptionDO.getRealOrder())) {
 | 
	
		
			
				|  |  |             json.put("realOrder", prescriptionDO.getRealOrder());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         json.put("bqbm",prescriptionDO.getDiseaseCode());
 | 
	
		
			
				|  |  |         json.put("cardNo", outpatientDO.getCardNo());
 | 
	
		
			
				|  |  |         json.put("doctor", doctorMappingDO.getMappingCode());
 | 
	
		
			
				|  |  |         json.put("dept", outpatientDO.getDept());
 | 
	
	
		
			
				|  | @ -3654,7 +3659,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @param size
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public MixEnvelop findExpressageList(String status, String oneselfPickupFlg, String nameKey, String startTime, String endTime, Integer page, Integer size, String wxId,String patientName) {
 | 
	
		
			
				|  |  |     public MixEnvelop findExpressageList(String status, String oneselfPickupFlg, String nameKey, String startTime, String endTime, Integer page, Integer size, String wxId,String patientName,Integer type) {
 | 
	
		
			
				|  |  |         String totalSql = "SELECT " +
 | 
	
		
			
				|  |  |                 " COUNT(1) AS \"total\" " +
 | 
	
		
			
				|  |  |                 " FROM " +
 | 
	
	
		
			
				|  | @ -3672,6 +3677,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(nameKey)) {
 | 
	
		
			
				|  |  |             totalSql += " AND e.name like '%" + nameKey + "%' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (type!=null)  {
 | 
	
		
			
				|  |  |             totalSql += " AND e.sf_type ='"+type+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(patientName)) {
 | 
	
		
			
				|  |  |             totalSql += " AND o.patient_name like '%" + patientName + "%' ";
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -3738,6 +3746,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql = sql + " e.name as \"name\", " +
 | 
	
		
			
				|  |  |                 " e.oneself_pickup_flg AS \"oneselfPickupFlg\", " +
 | 
	
		
			
				|  |  |                 " e.sf_type AS \"type\", " +
 | 
	
		
			
				|  |  |                 " o.id AS \"outpatientId\", " +
 | 
	
		
			
				|  |  |                 " o.icd10_name AS \"icd10Name\", " +
 | 
	
		
			
				|  |  |                 " o.medical_state AS \"medicalState\", " +
 | 
	
	
		
			
				|  | @ -3768,6 +3777,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(patientName)) {
 | 
	
		
			
				|  |  |             sql += " AND o.patient_name like '%" + patientName + "%' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (type!=null) {
 | 
	
		
			
				|  |  |             sql += " AND e.sf_type ='"+type+"' ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(startTime)) {
 | 
	
		
			
				|  |  |             if ("xm_ykyy_wx".equals(wxId)) {
 | 
	
		
			
				|  |  |                 if (flag){
 | 
	
	
		
			
				|  | @ -6058,6 +6070,142 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 顺丰同城物流模版消息
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param outpatientId
 | 
	
		
			
				|  |  |      * @param prescriptionId
 | 
	
		
			
				|  |  |      * @param remindMsg
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void sendSFTcWxTemplate(String outpatientId,String prescriptionId,String remindMsg){
 | 
	
		
			
				|  |  |         String contentMsg = "";
 | 
	
		
			
				|  |  |         String first = "";
 | 
	
		
			
				|  |  |         String remark = "";
 | 
	
		
			
				|  |  |         String patientId = "";
 | 
	
		
			
				|  |  |         String drugName = "";
 | 
	
		
			
				|  |  |         String patienName = "";
 | 
	
		
			
				|  |  |         String mailNo ="";
 | 
	
		
			
				|  |  |         String msgUrl ="";
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionId);
 | 
	
		
			
				|  |  |         WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId,1);
 | 
	
		
			
				|  |  |         if (wlyyOutpatientDO!=null){
 | 
	
		
			
				|  |  |             patientId = wlyyOutpatientDO.getConsumer();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (wlyyPrescriptionInfoDOS!=null&&wlyyPrescriptionInfoDOS.size()>0){
 | 
	
		
			
				|  |  |             drugName = wlyyPrescriptionInfoDOS.get(0).getDrugName();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionExpressageDO> wlyyPrescriptionExpressageDOS =prescriptionExpressageDao.findByOutpatientId(outpatientId);
 | 
	
		
			
				|  |  |         if (wlyyPrescriptionExpressageDOS!=null&&wlyyPrescriptionExpressageDOS.size()>0){
 | 
	
		
			
				|  |  |             mailNo = wlyyPrescriptionExpressageDOS.get(0).getMailno();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         BasePatientDO basePatientDO = basePatientDao.findById(patientId);
 | 
	
		
			
				|  |  |         if (basePatientDO!=null){
 | 
	
		
			
				|  |  |             patienName = basePatientDO.getName();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)||"sd_tnzyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |             List<BasePatientWechatDo> ps = new ArrayList<BasePatientWechatDo>();
 | 
	
		
			
				|  |  |             if (StringUtils.isNotEmpty(outpatientId)){
 | 
	
		
			
				|  |  |                 ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId, patientId);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (ps.isEmpty()) {
 | 
	
		
			
				|  |  |                 logger.info("该用户" + patienName + "没有openid,无法推送模版消息,用户ID:" + patientId + "wechatId:" + wechatId);
 | 
	
		
			
				|  |  |                 return;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
 | 
	
		
			
				|  |  |             String scene = "sfxxtx";
 | 
	
		
			
				|  |  |             WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_sf_msg_notice", scene, 1);
 | 
	
		
			
				|  |  |             BeanUtils.copyProperties(config, newConfig);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             newConfig.setFirst(config.getFirst().replace("key1",remindMsg));
 | 
	
		
			
				|  |  |             newConfig.setKeyword1(config.getKeyword1().replace("key1",patienName).replace("key2",drugName));
 | 
	
		
			
				|  |  |             newConfig.setKeyword2("顺丰快递");
 | 
	
		
			
				|  |  |             newConfig.setKeyword3(mailNo);
 | 
	
		
			
				|  |  |             newConfig.setKeyword4(remindMsg);
 | 
	
		
			
				|  |  |             newConfig.setRemark(config.getRemark());
 | 
	
		
			
				|  |  |             String path = "returnVisit/logistics?outpatientId="+outpatientId+"&prescriptionCode="+prescriptionId+"&realOrder="+prescriptionDO.getRealOrder();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             newConfig.setPagepath(newConfig.getPagepath()+ URLEncoder.encode(path));
 | 
	
		
			
				|  |  |             newConfig.setUrl(newConfig.getUrl().replace("key1",outpatientId).replace("key2",prescriptionId));
 | 
	
		
			
				|  |  |             logger.info("=======setUrl========" + newConfig.getUrl());
 | 
	
		
			
				|  |  |             WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
 | 
	
		
			
				|  |  |             for (BasePatientWechatDo one : ps) {
 | 
	
		
			
				|  |  |                 logger.info("发送的消息="+ com.alibaba.fastjson.JSONObject.toJSONString(newConfig));
 | 
	
		
			
				|  |  |                 try {
 | 
	
		
			
				|  |  |                     logger.info("调用眼科微信模板消息接口的入参:AccessToken="+wxAccessTokenDO.getAccessToken()+"---Openid="+one.getOpenid());
 | 
	
		
			
				|  |  |                     weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), one.getOpenid(), newConfig);
 | 
	
		
			
				|  |  |                     logger.info("发送成功");
 | 
	
		
			
				|  |  |                 } catch (Exception e) {
 | 
	
		
			
				|  |  |                     e.printStackTrace();
 | 
	
		
			
				|  |  |                     logger.info("发送失败,error="+e.getMessage());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 //保存发送模板记录,
 | 
	
		
			
				|  |  |                 WxPushLogDO wxPushLogDO = new WxPushLogDO();
 | 
	
		
			
				|  |  |                 wxPushLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                 wxPushLogDO.setOpenid(one.getOpenid());
 | 
	
		
			
				|  |  |                 wxPushLogDO.setReceiver(patientId);
 | 
	
		
			
				|  |  |                 wxPushLogDO.setWechatId(wechatId);
 | 
	
		
			
				|  |  |                 wxPushLogDO.setReceiverName(patienName);
 | 
	
		
			
				|  |  |                 wxPushLogDO.setScene(scene);
 | 
	
		
			
				|  |  |                 wxPushLogDao.save(wxPushLogDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //发送极光消息推送
 | 
	
		
			
				|  |  |             wxTempalteJPush("logistics_remind",wlyyOutpatientDO,null,drugName,mailNo,remindMsg,prescriptionId);
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             first = "您好,您的处方订单物流"+remindMsg;
 | 
	
		
			
				|  |  |             contentMsg = "药品订单"+remindMsg;
 | 
	
		
			
				|  |  |             logger.info("推送物流模板消息参数first:"+first+"====contentMsg:"+contentMsg);
 | 
	
		
			
				|  |  |             msgUrl="/ims-wx/index.html#/returnVisit/logistics?type=2&outpatientId="+outpatientId+"&prescriptionCode="+prescriptionId+"&realOrder="+prescriptionDO.getRealOrder();
 | 
	
		
			
				|  |  |             String responseMsg = "";
 | 
	
		
			
				|  |  |             if ("xm_xzzx_wx".equalsIgnoreCase(wechatId)) {
 | 
	
		
			
				|  |  |                 //String prefix="https://www.xmheart.com";
 | 
	
		
			
				|  |  |                 String prefix = "https://ih.xmheart.com/hlwyy";
 | 
	
		
			
				|  |  |                 if(StringUtils.isNotEmpty(outpatientId)){
 | 
	
		
			
				|  |  |                     responseMsg = xzzxEntranceService.sendMes(wechatId,
 | 
	
		
			
				|  |  |                             patientId,
 | 
	
		
			
				|  |  |                             basePatientDO.getIdcard(),
 | 
	
		
			
				|  |  |                             first,
 | 
	
		
			
				|  |  |                             contentMsg,
 | 
	
		
			
				|  |  |                             remark,
 | 
	
		
			
				|  |  |                             prefix+msgUrl);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 logger.info("url="+prefix+msgUrl);
 | 
	
		
			
				|  |  |                 String msg="first:"+first+"contentMsg:"+contentMsg+"remark:"+remark;
 | 
	
		
			
				|  |  |                 logger.info("发送的信息="+msg);
 | 
	
		
			
				|  |  |                 logger.info("心脏模板消息发送返回结果:"+responseMsg);
 | 
	
		
			
				|  |  |             } else if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)) {
 | 
	
		
			
				|  |  |                 String prefix = "https://hlwyy.xmzsh.com";
 | 
	
		
			
				|  |  |                 if (StringUtils.isNotEmpty(outpatientId)) {
 | 
	
		
			
				|  |  |                     responseMsg = entranceService.ehospitalNotice(
 | 
	
		
			
				|  |  |                             patienName,
 | 
	
		
			
				|  |  |                             basePatientDO.getIdcard(),
 | 
	
		
			
				|  |  |                             basePatientDO.getMobile(),
 | 
	
		
			
				|  |  |                             first,
 | 
	
		
			
				|  |  |                             prefix + msgUrl,
 | 
	
		
			
				|  |  |                             contentMsg,
 | 
	
		
			
				|  |  |                             remark
 | 
	
		
			
				|  |  |                     );
 | 
	
		
			
				|  |  |                     logger.info("中山发送模板消息返回结果="+responseMsg);
 | 
	
		
			
				|  |  |                     System.out.println("结束发送模板消息");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //保存发送模板记录,
 | 
	
		
			
				|  |  |             WxPushLogDO wxPushLogDO = new WxPushLogDO();
 | 
	
		
			
				|  |  |             wxPushLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             wxPushLogDO.setReceiver(patientId);
 | 
	
		
			
				|  |  |             wxPushLogDO.setWechatId(wechatId);
 | 
	
		
			
				|  |  |             wxPushLogDO.setReceiverName(patienName);
 | 
	
		
			
				|  |  |             wxPushLogDO.setRequest(first+contentMsg+msgUrl);
 | 
	
		
			
				|  |  |             wxPushLogDO.setResponse(responseMsg);
 | 
	
		
			
				|  |  |             wxPushLogDO.setTempName("顺丰推送的物流消息");
 | 
	
		
			
				|  |  |             wxPushLogDao.save(wxPushLogDO);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     //核算检测预约模板消息
 | 
	
		
			
				|  |  |     public void sendNatWxTemplat(String name,String idcard,String mobile,String time,String orderNo,String relationName){
 | 
	
		
			
				|  |  |         String first = "";
 | 
	
	
		
			
				|  | @ -8495,139 +8643,27 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @param realOrder 处方号
 | 
	
		
			
				|  |  |      * @
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     public Object getSFExpressInfo(String admNo, String realOrder, String wxId) throws Exception {
 | 
	
		
			
				|  |  |         synchronized(realOrder.intern()){
 | 
	
		
			
				|  |  |             List<WlyyPrescriptionDO> wlyyPrescriptionDOList = prescriptionDao.findByRealOrderList(realOrder);
 | 
	
		
			
				|  |  |             Object result = "";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //根据门诊唯一号取就诊记录
 | 
	
		
			
				|  |  | //        List<WlyyOutpatientDO> wlyyOutpatientDOs = outpatientDao.findByAdmNo(admNo);
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDO> wlyyPrescriptionDOList = prescriptionDao.findByRealOrderList(realOrder);
 | 
	
		
			
				|  |  |         Object result = "";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         System.out.println("获取顺丰物流面单信息:wlyyPrescriptionDOS != null=" + wlyyPrescriptionDOList != null);
 | 
	
		
			
				|  |  |         if (wlyyPrescriptionDOList != null&&wlyyPrescriptionDOList.size()!=0) {
 | 
	
		
			
				|  |  |             WlyyPrescriptionDO wlyyPrescriptionDOS = wlyyPrescriptionDOList.get(0);
 | 
	
		
			
				|  |  |             List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpatientId", wlyyPrescriptionDOS.getOutpatientId());
 | 
	
		
			
				|  |  |             WlyyPrescriptionExpressageDO sfexpress_obj = null;
 | 
	
		
			
				|  |  |             System.out.println("获取顺丰物流面单信息:CollectionUtils.isEmpty(expressageDOList)=" + CollectionUtils.isEmpty(expressageDOList));
 | 
	
		
			
				|  |  |             if (CollectionUtils.isEmpty(expressageDOList)) {
 | 
	
		
			
				|  |  |                 throw new Exception("顺丰快递下单失败,未找到该处方的派送地址!");
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 System.out.println("获取顺丰物流面单信息:1");
 | 
	
		
			
				|  |  |                 sfexpress_obj = expressageDOList.get(0);
 | 
	
		
			
				|  |  |                 if (sfexpress_obj.getType() == 2) {
 | 
	
		
			
				|  |  |                     com.alibaba.fastjson.JSONObject sfJsonObject = new com.alibaba.fastjson.JSONObject();
 | 
	
		
			
				|  |  |                     sfJsonObject.put("mailno", sfexpress_obj.getMailno());
 | 
	
		
			
				|  |  |                     sfJsonObject.put("mailtype", "同城快递");
 | 
	
		
			
				|  |  |                     if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
 | 
	
		
			
				|  |  |                         sfJsonObject.put("j_name", "厦门大学附属中山医院");
 | 
	
		
			
				|  |  |                         sfJsonObject.put("j_phone", "4003008888");
 | 
	
		
			
				|  |  |                         sfJsonObject.put("j_townName", "思明区");
 | 
	
		
			
				|  |  |                         sfJsonObject.put("j_address", "湖滨南路201-209号");
 | 
	
		
			
				|  |  |                     } else if (wxId.equalsIgnoreCase("xm_ykyy_wx")) {
 | 
	
		
			
				|  |  |                         sfJsonObject.put("j_name", "厦门大学附属中山医院");
 | 
	
		
			
				|  |  |                         sfJsonObject.put("j_phone", "4003008888");
 | 
	
		
			
				|  |  |                         sfJsonObject.put("j_townName", "思明区");
 | 
	
		
			
				|  |  |                         sfJsonObject.put("j_address", "湖滨南路201-209号");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     sfJsonObject.put("j_provinceName", "福建省");
 | 
	
		
			
				|  |  |                     sfJsonObject.put("j_cityName", "厦门市");
 | 
	
		
			
				|  |  |                     sfJsonObject.put("d_name", sfexpress_obj.getName());
 | 
	
		
			
				|  |  |                     sfJsonObject.put("d_provinceName", sfexpress_obj.getProvinceName());
 | 
	
		
			
				|  |  |                     sfJsonObject.put("d_cityName", sfexpress_obj.getCityName());
 | 
	
		
			
				|  |  |                     sfJsonObject.put("d_townName", sfexpress_obj.getTownName());
 | 
	
		
			
				|  |  |                     sfJsonObject.put("d_address",sfexpress_obj.getStreetName()+sfexpress_obj.getAddress());
 | 
	
		
			
				|  |  |                     sfJsonObject.put("d_phone", sfexpress_obj.getMobile());
 | 
	
		
			
				|  |  |                     sfJsonObject.put("express_type", 11);
 | 
	
		
			
				|  |  |                     sfJsonObject.put("pay_method", 2);
 | 
	
		
			
				|  |  |                     sfJsonObject.put("receive_time", "");
 | 
	
		
			
				|  |  |                     sfJsonObject.put("dispensaryType", 2);
 | 
	
		
			
				|  |  |                     result = sfJsonObject;
 | 
	
		
			
				|  |  |                     System.out.println("获取顺丰物流面单信息:8");
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     List<WlyyPrescriptionDO> wlyyPrescriptionDOS1 = prescriptionDao.findByOutpatientId(wlyyPrescriptionDOS.getOutpatientId());
 | 
	
		
			
				|  |  |                     if (wlyyPrescriptionDOS.getStatus()<31){
 | 
	
		
			
				|  |  |                         if (StringUtils.isNoneBlank(sfexpress_obj.getMailno())&&wlyyPrescriptionDOS1.size()>1){
 | 
	
		
			
				|  |  |                             String orderNo = "";
 | 
	
		
			
				|  |  |                             for (WlyyPrescriptionDO prescriptionDO:wlyyPrescriptionDOS1){
 | 
	
		
			
				|  |  |                                 if (!prescriptionDO.getRealOrder().equalsIgnoreCase(wlyyPrescriptionDOS.getRealOrder())){
 | 
	
		
			
				|  |  |                                     orderNo = prescriptionDO.getRealOrder();
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                             throw new Exception("已存在地址"+sfexpress_obj.getAddress()+"、电话"+sfexpress_obj.getMobile()+"的快递单(单号"+orderNo+"),请将此处方与其打包一起。");
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     String sql = "SELECT\n" +
 | 
	
		
			
				|  |  |                             "\tpe.outpatient_id as outpatientId,\n" +
 | 
	
		
			
				|  |  |                             "\tpe.mailno as mailno,\n" +
 | 
	
		
			
				|  |  |                             "\tpe.address as address,\n" +
 | 
	
		
			
				|  |  |                             "\tpe.mobile as mobile\n" +
 | 
	
		
			
				|  |  |                             "FROM\n" +
 | 
	
		
			
				|  |  |                             "\twlyy_prescription_expressage pe\n" +
 | 
	
		
			
				|  |  |                             "WHERE\n" +
 | 
	
		
			
				|  |  |                             " pe.create_time >= '"+DateUtil.getStringDateShort()+" 00:00:00'\n" +
 | 
	
		
			
				|  |  |                             "AND pe.create_time <= '"+DateUtil.getStringDateShort()+" 23:59:59'\n" +
 | 
	
		
			
				|  |  |                             "AND pe.mailno IS NOT NULL\n" +
 | 
	
		
			
				|  |  |                             "and pe.address ='"+sfexpress_obj.getAddress()+"'\n" +
 | 
	
		
			
				|  |  |                             "and pe.mobile = '"+sfexpress_obj.getMobile()+"' ";
 | 
	
		
			
				|  |  |                     List<Map<String,Object>> maps = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |                     if (maps!=null&&maps.size()!=0){
 | 
	
		
			
				|  |  |                         Map<String,Object> map = maps.get(0);
 | 
	
		
			
				|  |  |                         if (wlyyPrescriptionDOS.getStatus()<31){
 | 
	
		
			
				|  |  |                             if (!map.get("outpatientId").toString().equalsIgnoreCase(wlyyPrescriptionDOS.getOutpatientId())){
 | 
	
		
			
				|  |  |                                 String mailNo= map.get("mailno").toString();
 | 
	
		
			
				|  |  |                                 /*       sfexpress_obj.setMailno(mailNo);*/
 | 
	
		
			
				|  |  |                                 sfexpressService.updatePrescriptionExpressage(sfexpress_obj);
 | 
	
		
			
				|  |  |                                 List<WlyyPrescriptionDO> wlyyPrescriptionDOS2 = prescriptionDao.findByOutpatientId(map.get("outpatientId").toString());
 | 
	
		
			
				|  |  |                                 String orderNo = "";
 | 
	
		
			
				|  |  |                                 for (WlyyPrescriptionDO wlyyPrescriptionDO:wlyyPrescriptionDOS2){
 | 
	
		
			
				|  |  |                                     orderNo +=wlyyPrescriptionDO.getRealOrder()+" ";
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                                 throw new Exception("已存在地址"+map.get("address")+"、电话"+map.get("mobile")+"的快递单(单号"+orderNo+"),请将此处方与其打包一起。");
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     System.out.println("获取顺丰物流面单信息:2");
 | 
	
		
			
				|  |  |                     //如果该处方的快递单号已生成,则说明已经下单成功,不需要重复下单,直接返回面单信息
 | 
	
		
			
				|  |  |                     System.out.println("获取顺丰物流面单信息:3");
 | 
	
		
			
				|  |  |                     if (org.apache.commons.lang.StringUtils.isNotBlank(sfexpress_obj.getMailno())) {
 | 
	
		
			
				|  |  |                         //处方已下单成功
 | 
	
		
			
				|  |  |                         System.out.println("获取顺丰物流面单信息:4");
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         //如果该处方的快递单号未生成,则继续下单
 | 
	
		
			
				|  |  |                         //根据业务订单号判断是否已经下单成功
 | 
	
		
			
				|  |  |                         //--2020.05.20--顺丰V2.0接口已不提供查询接口,直接单下单--START
 | 
	
		
			
				|  |  | //                    boolean go_on = sfexpressService.sfOrderSearchService(sfexpress_obj);
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //                    //如果该业务订单号未下单成功过,则重新下单
 | 
	
		
			
				|  |  | //                    if(go_on){
 | 
	
		
			
				|  |  | //                        //请求顺丰接口下单,成功下单后,返回快递单号
 | 
	
		
			
				|  |  | //                        sfexpress_obj = sfexpressService.postSFOrderService(sfexpress_obj);
 | 
	
		
			
				|  |  | //                        //保存快递单号和增加处方物流记录为配送
 | 
	
		
			
				|  |  | //                        sfexpressService.updatePrescriptionExpressage(sfexpress_obj);
 | 
	
		
			
				|  |  | //                    }
 | 
	
		
			
				|  |  |                         //--2020.05.20--顺丰V2.0接口已不提供查询接口,直接单下单--END
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         //请求顺丰接口下单,成功下单后,返回快递单号
 | 
	
		
			
				|  |  |                         sfexpress_obj = sfexpressService.postSFOrderService(sfexpress_obj);
 | 
	
		
			
				|  |  |                         System.out.println("获取顺丰物流面单信息:5");
 | 
	
		
			
				|  |  |                         //保存快递单号和增加处方物流记录为配送
 | 
	
		
			
				|  |  |                         sfexpressService.updatePrescriptionExpressage(sfexpress_obj);
 | 
	
		
			
				|  |  |                         System.out.println("获取顺丰物流面单信息:6");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     for (WlyyPrescriptionDO prescriptionDO:wlyyPrescriptionDOList){
 | 
	
		
			
				|  |  |                         prescriptionDO.setStatus(31);
 | 
	
		
			
				|  |  |                         prescriptionDao.save(prescriptionDO);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     if (sfexpress_obj != null && StringUtils.isNoneBlank(sfexpress_obj.getMailno())) {
 | 
	
		
			
				|  |  |                         com.alibaba.fastjson.JSONObject object = sfexpressService.postSFOrderQueryService(sfexpress_obj);
 | 
	
		
			
				|  |  |                         System.out.println("获取顺丰物流面单信息7-1"+object.toJSONString());
 | 
	
		
			
				|  |  |                         System.out.println("获取顺丰物流面单信息:7");
 | 
	
		
			
				|  |  |             System.out.println("获取顺丰物流面单信息:wlyyPrescriptionDOS != null=" + wlyyPrescriptionDOList != null);
 | 
	
		
			
				|  |  |             if (wlyyPrescriptionDOList != null&&wlyyPrescriptionDOList.size()!=0) {
 | 
	
		
			
				|  |  |                 WlyyPrescriptionDO wlyyPrescriptionDOS = wlyyPrescriptionDOList.get(0);
 | 
	
		
			
				|  |  |                 List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpatientId", wlyyPrescriptionDOS.getOutpatientId());
 | 
	
		
			
				|  |  |                 WlyyPrescriptionExpressageDO sfexpress_obj = null;
 | 
	
		
			
				|  |  |                 System.out.println("获取顺丰物流面单信息:CollectionUtils.isEmpty(expressageDOList)=" + CollectionUtils.isEmpty(expressageDOList));
 | 
	
		
			
				|  |  |                 if (CollectionUtils.isEmpty(expressageDOList)) {
 | 
	
		
			
				|  |  |                     throw new Exception("顺丰快递下单失败,未找到该处方的派送地址!");
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     System.out.println("获取顺丰物流面单信息:1");
 | 
	
		
			
				|  |  |                     sfexpress_obj = expressageDOList.get(0);
 | 
	
		
			
				|  |  |                     if (sfexpress_obj.getType()!=null&&sfexpress_obj.getType() == 2) {
 | 
	
		
			
				|  |  |                         com.alibaba.fastjson.JSONObject sfJsonObject = new com.alibaba.fastjson.JSONObject();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         sfJsonObject.put("mailno", sfexpress_obj.getMailno());
 | 
	
		
			
				|  |  |                         sfJsonObject.put("mailtype", "标准快递");
 | 
	
		
			
				|  |  |                         sfJsonObject.put("destcode", object.getString("destRouteLabel"));
 | 
	
		
			
				|  |  |                         sfJsonObject.put("mailtype", "同城快递");
 | 
	
		
			
				|  |  |                         if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
 | 
	
		
			
				|  |  |                             sfJsonObject.put("j_name", "厦门大学附属中山医院");
 | 
	
		
			
				|  |  |                             sfJsonObject.put("j_phone", "4003008888");
 | 
	
	
		
			
				|  | @ -8652,16 +8688,134 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                         sfJsonObject.put("pay_method", 2);
 | 
	
		
			
				|  |  |                         sfJsonObject.put("receive_time", "");
 | 
	
		
			
				|  |  |                         sfJsonObject.put("dispensaryType", 2);
 | 
	
		
			
				|  |  |                         sfJsonObject.put("destcode","592AH-002A");
 | 
	
		
			
				|  |  |                         for (WlyyPrescriptionDO prescriptionDO:wlyyPrescriptionDOList){
 | 
	
		
			
				|  |  |                             prescriptionDO.setStatus(32);
 | 
	
		
			
				|  |  |                             prescriptionDao.save(prescriptionDO);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         result = sfJsonObject;
 | 
	
		
			
				|  |  |                         System.out.println("获取顺丰物流面单信息:8");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     }else {
 | 
	
		
			
				|  |  |                         List<WlyyPrescriptionDO> wlyyPrescriptionDOS1 = prescriptionDao.findByOutpatientId(wlyyPrescriptionDOS.getOutpatientId());
 | 
	
		
			
				|  |  |                         if (wlyyPrescriptionDOS.getStatus()<31){
 | 
	
		
			
				|  |  |                             if (StringUtils.isNoneBlank(sfexpress_obj.getMailno())&&wlyyPrescriptionDOS1.size()>1){
 | 
	
		
			
				|  |  |                                 String orderNo = "";
 | 
	
		
			
				|  |  |                                 for (WlyyPrescriptionDO prescriptionDO:wlyyPrescriptionDOS1){
 | 
	
		
			
				|  |  |                                     if (!prescriptionDO.getRealOrder().equalsIgnoreCase(wlyyPrescriptionDOS.getRealOrder())){
 | 
	
		
			
				|  |  |                                         orderNo = prescriptionDO.getRealOrder();
 | 
	
		
			
				|  |  |                                     }
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                                 throw new Exception("已存在地址"+sfexpress_obj.getAddress()+"、电话"+sfexpress_obj.getMobile()+"的快递单(单号"+orderNo+"),请将此处方与其打包一起。");
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         String sql = "SELECT\n" +
 | 
	
		
			
				|  |  |                                 "\tpe.outpatient_id as outpatientId,\n" +
 | 
	
		
			
				|  |  |                                 "\tpe.mailno as mailno,\n" +
 | 
	
		
			
				|  |  |                                 "\tpe.address as address,\n" +
 | 
	
		
			
				|  |  |                                 "\tpe.mobile as mobile\n" +
 | 
	
		
			
				|  |  |                                 "FROM\n" +
 | 
	
		
			
				|  |  |                                 "\twlyy_prescription_expressage pe\n" +
 | 
	
		
			
				|  |  |                                 "WHERE\n" +
 | 
	
		
			
				|  |  |                                 " pe.create_time >= '"+DateUtil.getStringDateShort()+" 00:00:00'\n" +
 | 
	
		
			
				|  |  |                                 "AND pe.create_time <= '"+DateUtil.getStringDateShort()+" 23:59:59'\n" +
 | 
	
		
			
				|  |  |                                 "AND pe.mailno IS NOT NULL\n" +
 | 
	
		
			
				|  |  |                                 "and pe.address ='"+sfexpress_obj.getAddress()+"'\n" +
 | 
	
		
			
				|  |  |                                 "and pe.mobile = '"+sfexpress_obj.getMobile()+"' ";
 | 
	
		
			
				|  |  |                         List<Map<String,Object>> maps = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |                         if (maps!=null&&maps.size()!=0){
 | 
	
		
			
				|  |  |                             Map<String,Object> map = maps.get(0);
 | 
	
		
			
				|  |  |                             if (wlyyPrescriptionDOS.getStatus()<31){
 | 
	
		
			
				|  |  |                                 if (!map.get("outpatientId").toString().equalsIgnoreCase(wlyyPrescriptionDOS.getOutpatientId())){
 | 
	
		
			
				|  |  |                                     String mailNo= map.get("mailno").toString();
 | 
	
		
			
				|  |  |                                     /*       sfexpress_obj.setMailno(mailNo);*/
 | 
	
		
			
				|  |  |                                     sfexpressService.updatePrescriptionExpressage(sfexpress_obj);
 | 
	
		
			
				|  |  |                                     List<WlyyPrescriptionDO> wlyyPrescriptionDOS2 = prescriptionDao.findByOutpatientId(map.get("outpatientId").toString());
 | 
	
		
			
				|  |  |                                     String orderNo = "";
 | 
	
		
			
				|  |  |                                     for (WlyyPrescriptionDO wlyyPrescriptionDO:wlyyPrescriptionDOS2){
 | 
	
		
			
				|  |  |                                         orderNo +=wlyyPrescriptionDO.getRealOrder()+" ";
 | 
	
		
			
				|  |  |                                     }
 | 
	
		
			
				|  |  |                                     throw new Exception("已存在地址"+map.get("address")+"、电话"+map.get("mobile")+"的快递单(单号"+orderNo+"),请将此处方与其打包一起。");
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         System.out.println("获取顺丰物流面单信息:2");
 | 
	
		
			
				|  |  |                         //如果该处方的快递单号已生成,则说明已经下单成功,不需要重复下单,直接返回面单信息
 | 
	
		
			
				|  |  |                         System.out.println("获取顺丰物流面单信息:3");
 | 
	
		
			
				|  |  |                         if (org.apache.commons.lang.StringUtils.isNotBlank(sfexpress_obj.getMailno())) {
 | 
	
		
			
				|  |  |                             //处方已下单成功
 | 
	
		
			
				|  |  |                             System.out.println("获取顺丰物流面单信息:4");
 | 
	
		
			
				|  |  |                         } else {
 | 
	
		
			
				|  |  |                             //如果该处方的快递单号未生成,则继续下单
 | 
	
		
			
				|  |  |                             //根据业务订单号判断是否已经下单成功
 | 
	
		
			
				|  |  |                             //--2020.05.20--顺丰V2.0接口已不提供查询接口,直接单下单--START
 | 
	
		
			
				|  |  | //                    boolean go_on = sfexpressService.sfOrderSearchService(sfexpress_obj);
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //                    //如果该业务订单号未下单成功过,则重新下单
 | 
	
		
			
				|  |  | //                    if(go_on){
 | 
	
		
			
				|  |  | //                        //请求顺丰接口下单,成功下单后,返回快递单号
 | 
	
		
			
				|  |  | //                        sfexpress_obj = sfexpressService.postSFOrderService(sfexpress_obj);
 | 
	
		
			
				|  |  | //                        //保存快递单号和增加处方物流记录为配送
 | 
	
		
			
				|  |  | //                        sfexpressService.updatePrescriptionExpressage(sfexpress_obj);
 | 
	
		
			
				|  |  | //                    }
 | 
	
		
			
				|  |  |                             //--2020.05.20--顺丰V2.0接口已不提供查询接口,直接单下单--END
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             //请求顺丰接口下单,成功下单后,返回快递单号
 | 
	
		
			
				|  |  |                             sfexpress_obj = sfexpressService.postSFOrderService(sfexpress_obj);
 | 
	
		
			
				|  |  |                             System.out.println("获取顺丰物流面单信息:5");
 | 
	
		
			
				|  |  |                             //保存快递单号和增加处方物流记录为配送
 | 
	
		
			
				|  |  |                             sfexpressService.updatePrescriptionExpressage(sfexpress_obj);
 | 
	
		
			
				|  |  |                             System.out.println("获取顺丰物流面单信息:6");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         for (WlyyPrescriptionDO prescriptionDO:wlyyPrescriptionDOList){
 | 
	
		
			
				|  |  |                             prescriptionDO.setStatus(31);
 | 
	
		
			
				|  |  |                             prescriptionDao.save(prescriptionDO);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         if (sfexpress_obj != null && StringUtils.isNoneBlank(sfexpress_obj.getMailno())) {
 | 
	
		
			
				|  |  |                             com.alibaba.fastjson.JSONObject object = sfexpressService.postSFOrderQueryService(sfexpress_obj);
 | 
	
		
			
				|  |  |                             System.out.println("获取顺丰物流面单信息7-1"+object.toJSONString());
 | 
	
		
			
				|  |  |                             System.out.println("获取顺丰物流面单信息:7");
 | 
	
		
			
				|  |  |                             com.alibaba.fastjson.JSONObject sfJsonObject = new com.alibaba.fastjson.JSONObject();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             sfJsonObject.put("mailno", sfexpress_obj.getMailno());
 | 
	
		
			
				|  |  |                             sfJsonObject.put("mailtype", "标准快递");
 | 
	
		
			
				|  |  |                             sfJsonObject.put("destcode", object.getString("destRouteLabel"));
 | 
	
		
			
				|  |  |                             if (wxId.equalsIgnoreCase("xm_zsyy_wx")) {
 | 
	
		
			
				|  |  |                                 sfJsonObject.put("j_name", "厦门大学附属中山医院");
 | 
	
		
			
				|  |  |                                 sfJsonObject.put("j_phone", "4003008888");
 | 
	
		
			
				|  |  |                                 sfJsonObject.put("j_townName", "思明区");
 | 
	
		
			
				|  |  |                                 sfJsonObject.put("j_address", "湖滨南路201-209号");
 | 
	
		
			
				|  |  |                             } else if (wxId.equalsIgnoreCase("xm_ykyy_wx")) {
 | 
	
		
			
				|  |  |                                 sfJsonObject.put("j_name", "厦门大学附属中山医院");
 | 
	
		
			
				|  |  |                                 sfJsonObject.put("j_phone", "4003008888");
 | 
	
		
			
				|  |  |                                 sfJsonObject.put("j_townName", "思明区");
 | 
	
		
			
				|  |  |                                 sfJsonObject.put("j_address", "湖滨南路201-209号");
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             sfJsonObject.put("j_provinceName", "福建省");
 | 
	
		
			
				|  |  |                             sfJsonObject.put("j_cityName", "厦门市");
 | 
	
		
			
				|  |  |                             sfJsonObject.put("d_name", sfexpress_obj.getName());
 | 
	
		
			
				|  |  |                             sfJsonObject.put("d_provinceName", sfexpress_obj.getProvinceName());
 | 
	
		
			
				|  |  |                             sfJsonObject.put("d_cityName", sfexpress_obj.getCityName());
 | 
	
		
			
				|  |  |                             sfJsonObject.put("d_townName", sfexpress_obj.getTownName());
 | 
	
		
			
				|  |  |                             sfJsonObject.put("d_address",sfexpress_obj.getStreetName()+sfexpress_obj.getAddress());
 | 
	
		
			
				|  |  |                             sfJsonObject.put("d_phone", sfexpress_obj.getMobile());
 | 
	
		
			
				|  |  |                             sfJsonObject.put("express_type", 11);
 | 
	
		
			
				|  |  |                             sfJsonObject.put("pay_method", 2);
 | 
	
		
			
				|  |  |                             sfJsonObject.put("receive_time", "");
 | 
	
		
			
				|  |  |                             sfJsonObject.put("dispensaryType", 2);
 | 
	
		
			
				|  |  |                             result = sfJsonObject;
 | 
	
		
			
				|  |  |                             System.out.println("获取顺丰物流面单信息:8");
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             System.out.println("获取顺丰物流面单信息:9");
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         System.out.println("获取顺丰物流面单信息:9");
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -11684,7 +11838,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         if (patientDO==null){
 | 
	
		
			
				|  |  |             return PageEnvelop.getError("找不到该患者",-1);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         StringBuffer sql = new StringBuffer(" SELECT DISTINCT b.*, c.oneself_pickup_flg,f.job_title_code,f.job_title_name  FROM (SELECT a.* FROM wlyy_prescription a left join wlyy_outpatient o ON o.id=a.outpatient_id  WHERE o.consumer = '");
 | 
	
		
			
				|  |  |         StringBuffer sql = new StringBuffer(" SELECT DISTINCT b.*, c.oneself_pickup_flg,c.sf_type as \"type\",f.job_title_code,f.job_title_name  FROM (SELECT a.* FROM wlyy_prescription a left join wlyy_outpatient o ON o.id=a.outpatient_id  WHERE o.consumer = '");
 | 
	
		
			
				|  |  |         StringBuffer countSql = new StringBuffer("select COUNT(DISTINCT b.id) count FROM (SELECT a.* FROM wlyy_prescription a left join wlyy_outpatient o ON o.id=a.outpatient_id  WHERE o.consumer = '");
 | 
	
		
			
				|  |  |         /*if (consumerflag){
 | 
	
		
			
				|  |  |             sql.append(" WHERE o.consumer = '");
 | 
	
	
		
			
				|  | @ -16990,18 +17144,129 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @param type
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String updateExpressInfo(String realOrder,Integer type){
 | 
	
		
			
				|  |  |     @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     public String updateExpressInfo(String realOrder,Integer type) throws Exception {
 | 
	
		
			
				|  |  |         String res = "";
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findByRealOrder(realOrder);
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionExpressageDO> expressageDOS = prescriptionExpressageDao.findByOutpatientId(prescriptionDO.getOutpatientId());
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO expressageDO = expressageDOS.get(0);
 | 
	
		
			
				|  |  |         if(type==1){
 | 
	
		
			
				|  |  |             expressageDO.setType(1);
 | 
	
		
			
				|  |  |             expressageDO.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             res = sfUtils.createorder(realOrder);
 | 
	
		
			
				|  |  |         synchronized(realOrder.intern()){
 | 
	
		
			
				|  |  |             if (StringUtils.isNoneBlank(expressageDO.getMailno())){
 | 
	
		
			
				|  |  |                 throw new Exception("已下单,请勿重新下单");
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 if(type==1){
 | 
	
		
			
				|  |  |                     expressageDO.setType(1);
 | 
	
		
			
				|  |  |                     expressageDO.setOneselfPickupFlg(0);
 | 
	
		
			
				|  |  |                     expressageDO.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     if(!selectTime()){
 | 
	
		
			
				|  |  |                         throw new Exception("当前时间段不支持同城配送。");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     else {
 | 
	
		
			
				|  |  |                         res = sfUtils.createorder(realOrder);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return res;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public void routeInfo(String json,Integer flag){
 | 
	
		
			
				|  |  |         com.alibaba.fastjson.JSONObject obj = com.alibaba.fastjson.JSONObject.parseObject(json);
 | 
	
		
			
				|  |  |         String orderId = obj.getString("sf_order_id");
 | 
	
		
			
				|  |  |         String order_status =obj.getString("order_status");
 | 
	
		
			
				|  |  |         String status_desc  =obj.getString("status_desc");
 | 
	
		
			
				|  |  |         String msgContent = unicodeToStr(status_desc);
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO expressageDO = prescriptionExpressageDao.findByPrescriptionExpressBspOrderNo(orderId);
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDO> prescriptionDOS = prescriptionDao.findByOutpatientId(expressageDO.getOutpatientId());
 | 
	
		
			
				|  |  |         if(flag==1){
 | 
	
		
			
				|  |  |         } else if (flag==2) {
 | 
	
		
			
				|  |  |             String cancel_reason = obj.getString("cancel_reason");
 | 
	
		
			
				|  |  |             String cancel_code = obj.getString("cancel_code");
 | 
	
		
			
				|  |  |             msgContent +=unicodeToStr(cancel_reason);
 | 
	
		
			
				|  |  |         } else if(flag==3){
 | 
	
		
			
				|  |  |             prescriptionDao.updateStatusByOutPatientId( 100,new Date(),expressageDO.getOutpatientId());
 | 
	
		
			
				|  |  |             for (WlyyPrescriptionDO prescriptionDO:prescriptionDOS){
 | 
	
		
			
				|  |  |                 if (prescriptionDO.getStatus()>=32){
 | 
	
		
			
				|  |  |                     WlyyPrescriptionLogDO prescriptionLogDO = new WlyyPrescriptionLogDO();
 | 
	
		
			
				|  |  |                     prescriptionLogDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                     prescriptionLogDO.setStatus(100);
 | 
	
		
			
				|  |  |                     prescriptionLogDO.setOutpatientId(prescriptionDO.getOutpatientId());
 | 
	
		
			
				|  |  |                     prescriptionLogDO.setPrescriptionCode(prescriptionDO.getPatientCode());
 | 
	
		
			
				|  |  |                     prescriptionLogDO.setUserCode(prescriptionDO.getPatientCode());
 | 
	
		
			
				|  |  |                     prescriptionLogDO.setUserName(prescriptionDO.getPatientName());
 | 
	
		
			
				|  |  |                     prescriptionLogDO.setUserType(1);
 | 
	
		
			
				|  |  |                     prescriptionLogDO.setDatajson("处方完成");
 | 
	
		
			
				|  |  |                     prescriptionLogDao.save(prescriptionLogDO);
 | 
	
		
			
				|  |  |                     logger.info("更新处方日志");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         for (WlyyPrescriptionDO prescriptionDO:prescriptionDOS){
 | 
	
		
			
				|  |  |             sendSFTcWxTemplate(prescriptionDO.getOutpatientId(),prescriptionDO.getId(),msgContent);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     private String unicodeToStr(String unicodeCodePoints){
 | 
	
		
			
				|  |  |         java.util.regex.Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
 | 
	
		
			
				|  |  |         Matcher matcher = pattern.matcher(unicodeCodePoints);
 | 
	
		
			
				|  |  |         char ch;
 | 
	
		
			
				|  |  |         while (matcher.find()) {
 | 
	
		
			
				|  |  |             ch = (char) Integer.parseInt(matcher.group(2), 16);
 | 
	
		
			
				|  |  |             unicodeCodePoints = unicodeCodePoints.replace(matcher.group(1), ch + "");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return unicodeCodePoints;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 查询是否符合时间内的同城配送标识
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public boolean selectTime(){
 | 
	
		
			
				|  |  |         WlyyHospitalSysDictDO sysDictDO = hospitalSysDictDao.findById("sftcTimeLimit");
 | 
	
		
			
				|  |  |         boolean flag =false;
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(sysDictDO.getDictValue())){
 | 
	
		
			
				|  |  |             com.alibaba.fastjson.JSONObject obj = com.alibaba.fastjson.JSONObject.parseObject(sysDictDO.getDictValue());
 | 
	
		
			
				|  |  |             String amStartStr = DateUtil.getStringDateShort()+" "+obj.getString("amStartDate");
 | 
	
		
			
				|  |  |             String sftcFlag = obj.getString("sftcFlag");
 | 
	
		
			
				|  |  |             String amEndStr = DateUtil.getStringDateShort()+" "+obj.getString("amEndDate");
 | 
	
		
			
				|  |  |             String pmStartStr = DateUtil.getStringDateShort()+" "+obj.getString("pmStartDate");
 | 
	
		
			
				|  |  |             String pmEndStr = DateUtil.getStringDateShort()+" "+obj.getString("pmEndDate");
 | 
	
		
			
				|  |  |             Date nowDate = new Date();
 | 
	
		
			
				|  |  |             Date amStartDate = DateUtil.strToDateLong(amStartStr);
 | 
	
		
			
				|  |  |             Date amEndDate = DateUtil.strToDateLong(amEndStr);
 | 
	
		
			
				|  |  |             Date pmStartDate = DateUtil.strToDateLong(pmStartStr);
 | 
	
		
			
				|  |  |             Date pmEndDate = DateUtil.strToDateLong(pmEndStr);
 | 
	
		
			
				|  |  |             if (sftcFlag.equalsIgnoreCase("1")){
 | 
	
		
			
				|  |  |                 LocalDate today = LocalDate.now();
 | 
	
		
			
				|  |  |                 int dayOfWeek = today.getDayOfWeek().getValue();
 | 
	
		
			
				|  |  |                 System.out.println(dayOfWeek+"=====================");
 | 
	
		
			
				|  |  |                 if (dayOfWeek==6) {
 | 
	
		
			
				|  |  |                     if (amStartDate.compareTo(nowDate) < 0 && amEndDate.compareTo(nowDate) > 0) {
 | 
	
		
			
				|  |  |                         flag = true;
 | 
	
		
			
				|  |  |                     }else{
 | 
	
		
			
				|  |  |                         flag=false;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }else if(dayOfWeek==7){
 | 
	
		
			
				|  |  |                     flag=false;
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     if (amStartDate.compareTo(nowDate)<0&&amEndDate.compareTo(nowDate)>0){
 | 
	
		
			
				|  |  |                         flag = true;
 | 
	
		
			
				|  |  |                     } else if (pmStartDate.compareTo(nowDate)<0&&pmEndDate.compareTo(nowDate)>0) {
 | 
	
		
			
				|  |  |                         flag = true;
 | 
	
		
			
				|  |  |                     }else {
 | 
	
		
			
				|  |  |                         flag = false;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 flag=false;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return flag;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |