|
@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.net.HttpURLConnection;
|
|
@ -79,6 +80,10 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
|
|
|
public static String entranceUrl = "http://192.168.101.2:10024/dsyy/";
|
|
|
@Autowired
|
|
|
private HttpClientUtil httpClientUtil;
|
|
|
@Autowired
|
|
|
private PrescriptionDao prescriptionDao;
|
|
|
@Autowired
|
|
|
private PrescriptionExpressageService sfexpressService;
|
|
|
//=============查询视图========================
|
|
|
|
|
|
/**
|
|
@ -1157,4 +1162,165 @@ public class DsyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
|
|
|
}
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 顺丰下订单后同步his
|
|
|
* @param outpatientId
|
|
|
* @param realorder
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject sfToHis(String outpatientId,String realorder) throws Exception {
|
|
|
WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId).get();
|
|
|
String registerNo = outpatientDO.getRegisterNo();
|
|
|
List<WlyyPrescriptionExpressageDO> prescriptionExpressageDOS = prescriptionExpressageDao.findByOutpatientId(outpatientId);
|
|
|
WlyyPrescriptionExpressageDO expressageDO = new WlyyPrescriptionExpressageDO();
|
|
|
if (prescriptionExpressageDOS!=null&&prescriptionExpressageDOS.size()!=0){
|
|
|
expressageDO = prescriptionExpressageDOS.get(0);
|
|
|
}
|
|
|
if (expressageDO!=null){
|
|
|
if (expressageDO.getOneselfPickupFlg()==0){
|
|
|
Object result=getSFExpressInfoNew(registerNo,realorder,"");
|
|
|
String re = result.toString();
|
|
|
if (re!=null){
|
|
|
JSONObject object = JSONObject.parseObject(re);
|
|
|
if (object.getString("code").equalsIgnoreCase("SUCCESS"));
|
|
|
JSONArray jsonArray = object.getJSONArray("result");
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(0);
|
|
|
String sfOrder = jsonObject.getString("mainMailNo");
|
|
|
String address = expressageDO.getProvinceName()+expressageDO.getCityName()+expressageDO.getTownName()+expressageDO.getStreetName()+expressageDO.getAddress();
|
|
|
String phone = expressageDO.getMobile();
|
|
|
String remark = expressageDO.getRemark();
|
|
|
String cardNo = outpatientDO.getCardNo();
|
|
|
String isExpress = "是";
|
|
|
if (expressageDO.getOneselfPickupFlg()==1){
|
|
|
isExpress = "否";
|
|
|
}
|
|
|
return sendDispensingToHisToHospital(registerNo,cardNo,isExpress,sfOrder,address,phone,remark);
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据门诊唯一号,处方号,到顺丰下单,下单成功返回面单信息--心脏和眼科
|
|
|
*
|
|
|
* @param admNo 门诊唯一号
|
|
|
* @param realOrder 处方号
|
|
|
* @return
|
|
|
*/
|
|
|
public Object getSFExpressInfoNew(String admNo, String realOrder, String wxId) throws Exception {
|
|
|
|
|
|
//根据门诊唯一号取就诊记录
|
|
|
// List<WlyyOutpatientDO> wlyyOutpatientDOs = outpatientDao.findByAdmNo(admNo);
|
|
|
|
|
|
if (StringUtils.isNoneBlank(realOrder)){
|
|
|
String str[] = realOrder.split(";");
|
|
|
Object result = "";
|
|
|
for (int i=0;i<str.length;i++){
|
|
|
WlyyPrescriptionDO wlyyPrescriptionDOS = new WlyyPrescriptionDO();
|
|
|
if(StringUtils.isNoneBlank(admNo)){
|
|
|
wlyyPrescriptionDOS = prescriptionDao.findByAdmNoAndRealOrder(admNo,str[i]);
|
|
|
}else {
|
|
|
List<WlyyPrescriptionDO> wlyyPrescriptionDOList = prescriptionDao.findByRealOrderList(str[i]);
|
|
|
if (wlyyPrescriptionDOList!=null&&wlyyPrescriptionDOList.size()!=0){
|
|
|
wlyyPrescriptionDOS =wlyyPrescriptionDOList.get(0);
|
|
|
}
|
|
|
}
|
|
|
System.out.println("获取顺丰物流面单信息:wlyyPrescriptionDOS != null=" + wlyyPrescriptionDOS != null);
|
|
|
if (wlyyPrescriptionDOS != null) {
|
|
|
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);
|
|
|
System.out.println("获取顺丰物流面单信息:2");
|
|
|
BasePatientDO basePatientDO = patientDao.findById(wlyyPrescriptionDOS.getPatientCode()).get();
|
|
|
//如果该处方的快递单号已生成,则说明已经下单成功,不需要重复下单,直接返回面单信息
|
|
|
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");
|
|
|
|
|
|
}
|
|
|
wlyyPrescriptionDOS.setStatus(31);
|
|
|
prescriptionDao.save(wlyyPrescriptionDOS);
|
|
|
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.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 = object;
|
|
|
System.out.println("获取顺丰物流面单信息:8");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
System.out.println("获取顺丰物流面单信息:9");
|
|
|
|
|
|
}
|
|
|
return result;
|
|
|
}else {
|
|
|
return "处方号未空!";
|
|
|
}
|
|
|
}
|
|
|
}
|