|  | @ -57,6 +57,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | import org.springframework.util.CollectionUtils;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.io.IOException;
 | 
	
		
			
				|  |  | import java.io.OutputStream;
 | 
	
	
		
			
				|  | @ -118,6 +119,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     private WlyyDoctorClinicRoomDao wlyyDoctorClinicRoomDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorHospitalDao baseDoctorHospitalDao;
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionExpressageService sfexpressService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -2455,4 +2459,70 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 根据门诊唯一号,处方号,到顺丰下单,下单成功返回面单信息
 | 
	
		
			
				|  |  |      * @param admNo 门诊唯一号
 | 
	
		
			
				|  |  |      * @param realOrder 处方号
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getSFExpressInfo(String admNo,String realOrder)throws Exception {
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |         //根据门诊唯一号取就诊记录
 | 
	
		
			
				|  |  |         List<WlyyOutpatientDO> wlyyOutpatientDOs = outpatientDao.findByDoctor(admNo);
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |         String result = "";
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |         if(!wlyyOutpatientDOs.isEmpty() && wlyyOutpatientDOs.size()>0){
 | 
	
		
			
				|  |  |             List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpatientId",wlyyOutpatientDOs.get(0).getId());
 | 
	
		
			
				|  |  |             WlyyPrescriptionExpressageDO sfexpress_obj = null;
 | 
	
		
			
				|  |  |             if(CollectionUtils.isEmpty(expressageDOList)){
 | 
	
		
			
				|  |  |                 throw new Exception("顺丰快递下单失败,未找到该处方的派送地址!");
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 sfexpress_obj = expressageDOList.get(0);
 | 
	
		
			
				|  |  |                 //如果该处方的快递单号已生成,则说明已经下单成功,不需要重复下单,直接返回面单信息
 | 
	
		
			
				|  |  |                 if(org.apache.commons.lang.StringUtils.isNotBlank(sfexpress_obj.getMailno())){
 | 
	
		
			
				|  |  |                     //处方已下单成功
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     //如果该处方的快递单号未生成,则继续下单
 | 
	
		
			
				|  |  |                     //根据业务订单号判断是否已经下单成功
 | 
	
		
			
				|  |  |                     boolean go_on = sfexpressService.sfOrderSearchService(sfexpress_obj);
 | 
	
		
			
				|  |  |             
 | 
	
		
			
				|  |  |                     //如果该业务订单号未下单成功过,则重新下单
 | 
	
		
			
				|  |  |                     if(go_on){
 | 
	
		
			
				|  |  |                         //请求顺丰接口下单,成功下单后,返回快递单号
 | 
	
		
			
				|  |  |                         sfexpress_obj = sfexpressService.postSFOrderService(sfexpress_obj);
 | 
	
		
			
				|  |  |                         //保存快递单号和增加处方物流记录为配送
 | 
	
		
			
				|  |  |                         sfexpressService.updatePrescriptionExpressage(sfexpress_obj);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 
 | 
	
		
			
				|  |  |                 if(sfexpress_obj != null && StringUtils.isNoneBlank(sfexpress_obj.getMailno())){
 | 
	
		
			
				|  |  |                     com.alibaba.fastjson.JSONObject sfJsonObject = new com.alibaba.fastjson.JSONObject();
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |                     sfJsonObject.put("mailno", sfexpress_obj.getMailno());
 | 
	
		
			
				|  |  |                     sfJsonObject.put("mailtype", "标准快递");
 | 
	
		
			
				|  |  |                     sfJsonObject.put("destcode", "592");
 | 
	
		
			
				|  |  |                     sfJsonObject.put("j_name", "厦门大学附属中山医院");
 | 
	
		
			
				|  |  |                     sfJsonObject.put("j_provinceName", "福建省");
 | 
	
		
			
				|  |  |                     sfJsonObject.put("j_cityName", "厦门市");
 | 
	
		
			
				|  |  |                     sfJsonObject.put("j_townName", "思明区");
 | 
	
		
			
				|  |  |                     sfJsonObject.put("j_address", "湖滨南路201-209号");
 | 
	
		
			
				|  |  |                     sfJsonObject.put("j_phone", "4003008888");
 | 
	
		
			
				|  |  |                     sfJsonObject.put("d_name", sfexpress_obj.getName());
 | 
	
		
			
				|  |  |                     sfJsonObject.put("d_provinceName", sfexpress_obj.getProvinceName());
 | 
	
		
			
				|  |  |                     sfJsonObject.put("d_cityName", sfexpress_obj.getCityName());
 | 
	
		
			
				|  |  |                     sfJsonObject.put("d_address", sfexpress_obj.getAddress());
 | 
	
		
			
				|  |  |                     sfJsonObject.put("d_phone",sfexpress_obj.getMobile());
 | 
	
		
			
				|  |  |                     sfJsonObject.put("express_type",11);
 | 
	
		
			
				|  |  |                     sfJsonObject.put("pay_method",2);
 | 
	
		
			
				|  |  |                     sfJsonObject.put("dispensaryType",2);
 | 
	
		
			
				|  |  |                     result = sfJsonObject.toJSONString();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |