|
@ -1,11 +1,13 @@
|
|
|
package com.yihu.wlyy.service.app.express;
|
|
|
|
|
|
import com.yihu.wlyy.entity.dict.DmExpressagePriceEntity;
|
|
|
import com.yihu.wlyy.entity.organization.Hospital;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.Prescription;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressageLog;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
|
|
|
import com.yihu.wlyy.repository.dict.DmExpressagePriceDao;
|
|
|
import com.yihu.wlyy.repository.organization.HospitalDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageLogDao;
|
|
@ -79,6 +81,9 @@ public class SFExpressService extends BaseService {
|
|
|
@Autowired
|
|
|
private PrescriptionExpressageDao prescriptionExpressageDao;
|
|
|
|
|
|
@Autowired
|
|
|
private HospitalDao hospitalDao;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 组装请求参数,发送请求
|
|
@ -178,7 +183,12 @@ public class SFExpressService extends BaseService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public PrescriptionExpressage postSFOrderService(PrescriptionExpressage sfexpress_obj) throws Exception {
|
|
|
String xml = SFUtils.postSFOrderService(sfexpress_obj,sf_code);
|
|
|
|
|
|
//获取医生所处的医院详细地址,作为寄件人地址
|
|
|
Prescription prescription = prescriptionDao.findByCode(sfexpress_obj.getPrescriptionCode());
|
|
|
Hospital hospital = hospitalDao.findByCode(prescription.getHospital());
|
|
|
|
|
|
String xml = SFUtils.postSFOrderService(sfexpress_obj,hospital,sf_code);
|
|
|
String re = this.SFExpressPost(xml);
|
|
|
|
|
|
//xml验证
|
|
@ -206,7 +216,7 @@ public class SFExpressService extends BaseService {
|
|
|
throw new Exception("顺丰快递下订单失败:派送地址不可派送");
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isNotBlank(mailno)){
|
|
|
if(StringUtils.isBlank(mailno)){
|
|
|
logger.info("顺丰快递下订单失败:未获取到快递单号!"+sfexpress_obj.getPrescriptionCode());
|
|
|
throw new Exception("顺丰快递下订单失败:未获取到快递单号!");
|
|
|
}
|
|
@ -466,7 +476,7 @@ public class SFExpressService extends BaseService {
|
|
|
* @param d_city 城市名称
|
|
|
* @return
|
|
|
*/
|
|
|
public DmExpressagePriceEntity getSFExpressPrice(String d_province, String d_city) {
|
|
|
public DmExpressagePriceEntity getSFExpressPrice(String d_province, String d_city) throws Exception{
|
|
|
String end_address_name = "";
|
|
|
|
|
|
if("厦门市".equals(d_city)){
|
|
@ -481,4 +491,80 @@ public class SFExpressService extends BaseService {
|
|
|
DmExpressagePriceEntity sfprice = dmExpressagePriceDao.getExprePriceEntityByCodeAndEndAdressName("shunfeng",end_address_name);
|
|
|
return sfprice;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据处方快递订单号判断是否下单成功
|
|
|
* 如果下单成功,保存处方物流记录,保存配送日志
|
|
|
* @param sfexpress_obj
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public boolean sfOrderSearchService(PrescriptionExpressage sfexpress_obj) throws Exception{
|
|
|
|
|
|
boolean go_on = false;
|
|
|
|
|
|
String xml = SFUtils.sfOrderSearchService(sfexpress_obj.getCode(),sf_code);
|
|
|
String re = this.SFExpressPost(xml);
|
|
|
|
|
|
try {
|
|
|
//xml验证
|
|
|
verificationResponXml(re,"订单处理失败!");
|
|
|
|
|
|
Document doc = DocumentHelper.parseText(re);
|
|
|
String headvalue = doc.selectSingleNode("/Response/Head").getText();
|
|
|
if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
|
|
|
//是否能派送:1:人工确认;2:可收派;3:不可以收派
|
|
|
String filter_result = "";
|
|
|
String orderid = "";//业务订单号
|
|
|
String mailno = "";//顺丰运单号
|
|
|
|
|
|
//错误代对应的文字
|
|
|
Document redoc = doc.selectSingleNode("/Response/Body/Orderresponse").getDocument();
|
|
|
Element root = redoc.getRootElement();
|
|
|
List<?> child = root.elements();
|
|
|
for (Object o : child) {
|
|
|
Element e = (Element) o;
|
|
|
filter_result = e.attributeValue("filter_result");
|
|
|
orderid = e.attributeValue("orderid");
|
|
|
mailno = e.attributeValue("mailno");
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isBlank(mailno)){
|
|
|
logger.info("顺丰快递下订单失败:未获取到快递单号!"+sfexpress_obj.getPrescriptionCode());
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isNotBlank(filter_result) && "3".equals(filter_result)){
|
|
|
logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getPrescriptionCode());
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
sfexpress_obj.setMailno(mailno);
|
|
|
}
|
|
|
|
|
|
//如果成功获取到快递单号,则保存处方物流记录,保存配送日志
|
|
|
|
|
|
//保存处方物流记录
|
|
|
prescriptionExpressageDao.save(sfexpress_obj);
|
|
|
|
|
|
//保存配送日志
|
|
|
PrescriptionLog prescriptionLog = new PrescriptionLog();
|
|
|
prescriptionLog.setPrescriptionCode(sfexpress_obj.getPrescriptionCode());
|
|
|
prescriptionLog.setCode(UUID.randomUUID().toString());
|
|
|
prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.sf.getValue());
|
|
|
prescriptionLog.setCreateTime(new Date());
|
|
|
prescriptionLog.setFlag(1);
|
|
|
prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
|
|
|
prescriptionLogDao.save(prescriptionLog);
|
|
|
|
|
|
|
|
|
}catch (Exception ex){
|
|
|
logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getPrescriptionCode());
|
|
|
//如果订单处理失败,则可以继续下单
|
|
|
go_on = true;
|
|
|
}
|
|
|
|
|
|
return go_on;
|
|
|
|
|
|
}
|
|
|
}
|