|
@ -3,11 +3,13 @@ package com.yihu.jw.hospital.prescription.service;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.yihu.jw.entity.base.org.BaseOrgDO;
|
|
import com.yihu.jw.entity.base.org.BaseOrgDO;
|
|
|
|
import com.yihu.jw.entity.base.patient.BaseMedicalRecordCopyingApplyDO;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.hospital.prescription.*;
|
|
import com.yihu.jw.entity.hospital.prescription.*;
|
|
import com.yihu.jw.hospital.prescription.dao.*;
|
|
import com.yihu.jw.hospital.prescription.dao.*;
|
|
import com.yihu.jw.hospital.prescription.service.entrance.util.SFUtils;
|
|
import com.yihu.jw.hospital.prescription.service.entrance.util.SFUtils;
|
|
import com.yihu.jw.org.dao.BaseOrgDao;
|
|
import com.yihu.jw.org.dao.BaseOrgDao;
|
|
|
|
import com.yihu.jw.patient.dao.BaseMedicalRecordCopyingApplyDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.utils.sfutils.HttpClientUtils;
|
|
import com.yihu.jw.utils.sfutils.HttpClientUtils;
|
|
@ -90,6 +92,8 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
|
|
private PrescriptionLogDao prescriptionLogDao;
|
|
private PrescriptionLogDao prescriptionLogDao;
|
|
@Autowired
|
|
@Autowired
|
|
PrescriptionService prescriptionService;
|
|
PrescriptionService prescriptionService;
|
|
|
|
@Autowired
|
|
|
|
private BaseMedicalRecordCopyingApplyDao medicalRecordCopyingApplyDao;
|
|
|
|
|
|
private PrescriptionExpressageService(){}
|
|
private PrescriptionExpressageService(){}
|
|
|
|
|
|
@ -99,6 +103,9 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
|
|
this.sf_check_word = sf_check_word;
|
|
this.sf_check_word = sf_check_word;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public List<WlyyPrescriptionExpressageDO> findByRelationCode(String relationCode,String relationType){
|
|
|
|
return prescriptionExpressageDao.findByRelationCode(relationCode, relationType);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 组装请求参数,发送请求
|
|
* 组装请求参数,发送请求
|
|
@ -200,6 +207,53 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 向顺丰快递下订单
|
|
|
|
* @param sfexpress_obj
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public WlyyPrescriptionExpressageDO postSFOrderServiceCommon(WlyyPrescriptionExpressageDO sfexpress_obj) throws Exception {
|
|
|
|
|
|
|
|
//获取医生所处的医院详细地址,作为寄件人地址
|
|
|
|
String orgId = "";
|
|
|
|
String patientId = "";
|
|
|
|
String depositumInfo = "";
|
|
|
|
if("1".equals(sfexpress_obj.getRelationType())){
|
|
|
|
BaseMedicalRecordCopyingApplyDO applyDO = medicalRecordCopyingApplyDao.findById(sfexpress_obj.getRelationCode()).orElse(null);
|
|
|
|
patientId = applyDO.getPatientId();
|
|
|
|
orgId = applyDO.getHospital();
|
|
|
|
depositumInfo = "病例";
|
|
|
|
}
|
|
|
|
BaseOrgDO hospital = baseOrgDao.findByCode(orgId);
|
|
|
|
BasePatientDO basePatientDO = basePatientDao.findById(patientId).orElse(null);
|
|
|
|
|
|
|
|
JSONObject params = SFUtils.postSFOrderServiceV2(sfexpress_obj,hospital,basePatientDO,depositumInfo);
|
|
|
|
String re = this.SFExpressPostV2(params);
|
|
|
|
//xml验证
|
|
|
|
logger.info("顺丰快递下订单:re"+re);
|
|
|
|
verificationResponV2(re);
|
|
|
|
|
|
|
|
JSONObject respone = JSONObject.parseObject(re);
|
|
|
|
|
|
|
|
String mailno = "";//顺丰运单号
|
|
|
|
String bspOrderNo = "";//顺丰业务号
|
|
|
|
|
|
|
|
JSONArray successResult = respone.getJSONObject("result").getJSONArray("successResult");
|
|
|
|
|
|
|
|
if(!successResult.isEmpty()){
|
|
|
|
JSONObject object = successResult.getJSONObject(0);
|
|
|
|
mailno = object.getString("mailNo");
|
|
|
|
bspOrderNo = object.getString("bspOrderNo");
|
|
|
|
}
|
|
|
|
|
|
|
|
logger.info("顺丰快递下订单:mailno"+mailno);
|
|
|
|
|
|
|
|
sfexpress_obj.setMailno(mailno);
|
|
|
|
sfexpress_obj.setBspOrderNo(bspOrderNo);
|
|
|
|
return sfexpress_obj;
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 向顺丰快递下订单
|
|
* 向顺丰快递下订单
|
|
* @param sfexpress_obj
|
|
* @param sfexpress_obj
|
|
@ -213,7 +267,7 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
|
|
BaseOrgDO hospital = baseOrgDao.findByCode(outpatientDO.getHospital());
|
|
BaseOrgDO hospital = baseOrgDao.findByCode(outpatientDO.getHospital());
|
|
BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient()).orElse(null);
|
|
BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient()).orElse(null);
|
|
|
|
|
|
JSONObject params = SFUtils.postSFOrderServiceV2(sfexpress_obj,hospital,basePatientDO);
|
|
|
|
|
|
JSONObject params = SFUtils.postSFOrderServiceV2(sfexpress_obj,hospital,basePatientDO,"药品");
|
|
String re = this.SFExpressPostV2(params);
|
|
String re = this.SFExpressPostV2(params);
|
|
//xml验证
|
|
//xml验证
|
|
logger.info("顺丰快递下订单:re"+re);
|
|
logger.info("顺丰快递下订单:re"+re);
|
|
@ -280,11 +334,6 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
public String postOrderConfirmService(WlyyPrescriptionExpressageDO sfexpress_obj) throws Exception {
|
|
public String postOrderConfirmService(WlyyPrescriptionExpressageDO sfexpress_obj) throws Exception {
|
|
|
|
|
|
//获取医生所处的医院详细地址,作为寄件人地址
|
|
|
|
WlyyOutpatientDO outpatientDO = outpatientDao.findById(sfexpress_obj.getOutpatientId()).orElse(null);
|
|
|
|
BaseOrgDO hospital = baseOrgDao.findByCode(outpatientDO.getHospital());
|
|
|
|
|
|
|
|
String xml = SFUtils.SFOrderConfirmXml(sf_code,sfexpress_obj.getId(),sfexpress_obj.getMailno(),2);
|
|
String xml = SFUtils.SFOrderConfirmXml(sf_code,sfexpress_obj.getId(),sfexpress_obj.getMailno(),2);
|
|
logger.info("顺丰快递取消订单请求:xml"+xml);
|
|
logger.info("顺丰快递取消订单请求:xml"+xml);
|
|
String re = this.SFExpressPost(xml);
|
|
String re = this.SFExpressPost(xml);
|
|
@ -747,7 +796,9 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
|
|
|
|
|
|
//如果成功获取到快递单号,则保存处方物流记录,保存配送日志
|
|
//如果成功获取到快递单号,则保存处方物流记录,保存配送日志
|
|
//修改处方状态为配送中
|
|
//修改处方状态为配送中
|
|
prescriptionDao.updateStatus(sfexpress_obj.getOutpatientId(),65);
|
|
|
|
|
|
if(StringUtils.isNotBlank(sfexpress_obj.getOutpatientId())){
|
|
|
|
prescriptionDao.updateStatus(sfexpress_obj.getOutpatientId(),65);
|
|
|
|
}
|
|
|
|
|
|
//保存处方物流记录
|
|
//保存处方物流记录
|
|
prescriptionExpressageDao.save(sfexpress_obj);
|
|
prescriptionExpressageDao.save(sfexpress_obj);
|
|
@ -755,6 +806,8 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
|
|
//保存配送日志
|
|
//保存配送日志
|
|
WlyyOutpatientExpressageLogDO outpatiExpressLog = new WlyyOutpatientExpressageLogDO();
|
|
WlyyOutpatientExpressageLogDO outpatiExpressLog = new WlyyOutpatientExpressageLogDO();
|
|
outpatiExpressLog.setOutpatientId(sfexpress_obj.getOutpatientId());
|
|
outpatiExpressLog.setOutpatientId(sfexpress_obj.getOutpatientId());
|
|
|
|
outpatiExpressLog.setRelationCode(sfexpress_obj.getRelationCode());
|
|
|
|
outpatiExpressLog.setRelationType(sfexpress_obj.getRelationType());
|
|
outpatiExpressLog.setId(UUID.randomUUID().toString());
|
|
outpatiExpressLog.setId(UUID.randomUUID().toString());
|
|
outpatiExpressLog.setType(8);
|
|
outpatiExpressLog.setType(8);
|
|
outpatiExpressLog.setCreateTime(new Date());
|
|
outpatiExpressLog.setCreateTime(new Date());
|
|
@ -846,13 +899,17 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
|
|
public void updatePrescriptionExpressage(WlyyPrescriptionExpressageDO prescriptionExpressage) throws Exception {
|
|
public void updatePrescriptionExpressage(WlyyPrescriptionExpressageDO prescriptionExpressage) throws Exception {
|
|
|
|
|
|
//修改门诊处方状态为配送配送中
|
|
//修改门诊处方状态为配送配送中
|
|
prescriptionDao.updateStatus(prescriptionExpressage.getId(), 32);
|
|
|
|
|
|
if(StringUtils.isNotBlank(prescriptionExpressage.getOutpatientId())){
|
|
|
|
prescriptionDao.updateStatus(prescriptionExpressage.getId(), 32);
|
|
|
|
}
|
|
|
|
|
|
//保存处方物流记录
|
|
//保存处方物流记录
|
|
prescriptionExpressageDao.save(prescriptionExpressage);
|
|
prescriptionExpressageDao.save(prescriptionExpressage);
|
|
|
|
|
|
//保存门诊配送日志
|
|
//保存门诊配送日志
|
|
WlyyOutpatientExpressageLogDO prescriptionLog = new WlyyOutpatientExpressageLogDO();
|
|
WlyyOutpatientExpressageLogDO prescriptionLog = new WlyyOutpatientExpressageLogDO();
|
|
|
|
prescriptionLog.setRelationCode(prescriptionExpressage.getRelationCode());
|
|
|
|
prescriptionLog.setRelationType(prescriptionExpressage.getRelationType());
|
|
prescriptionLog.setOutpatientId(prescriptionExpressage.getOutpatientId());
|
|
prescriptionLog.setOutpatientId(prescriptionExpressage.getOutpatientId());
|
|
// 类型: -1 失效 1HIS对接 2易联众对接 3创建处方 4 审核 5付款 6 配送 7完成 8物流对接
|
|
// 类型: -1 失效 1HIS对接 2易联众对接 3创建处方 4 审核 5付款 6 配送 7完成 8物流对接
|
|
prescriptionLog.setType(8);
|
|
prescriptionLog.setType(8);
|