ソースを参照

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

Conflicts:
	patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/express/SFExpressService.java
chenweida 7 年 前
コミット
30e7bfe7f2

+ 4 - 5
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -250,19 +250,18 @@ public class PrescriptionInfoService extends BaseService {
    public void setSQL(StringBuffer pre_sql,List<Object> params,String state,String startDate,String endDate,String nameKeyword){
        if(StringUtils.isNotBlank(state)){
            pre_sql.append(" AND pr.status = ?");
            params.add(state);
            pre_sql.append(" AND pr.status IN ("+state+")");
        }
        if(StringUtils.isNotBlank(startDate)){
            pre_sql.append(" AND pr.create_time >= ?");
            pre_sql.append(" AND pr.create_time >= ? ");
            params.add(startDate);
        }
        if(StringUtils.isNotBlank(endDate)){
            pre_sql.append(" AND pr.create_time <= ?");
            pre_sql.append(" AND pr.create_time <= ? ");
            params.add(endDate);
        }
        if(StringUtils.isNotBlank(nameKeyword)){
            pre_sql.append(" AND pr.patient_name like ?");
            pre_sql.append(" AND pr.patient_name like ? ");
            params.add("%"+nameKeyword+"%");
        }
        pre_sql.append(" GROUP BY pr.code ORDER BY pr.create_time DESC");

+ 9 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/organization/Hospital.java

@ -31,6 +31,7 @@ public class Hospital extends IdEntity {
	private String photo;           //医院图片
	private String roadCode;        //街道编码
	private String centerSite;      //中心/站点
	private String phone;			//联系电话
	public String getDel() {
		return del;
@ -153,4 +154,12 @@ public class Hospital extends IdEntity {
	public void setCenterSite(String centerSite) {
		this.centerSite = centerSite;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
}

+ 89 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/express/SFExpressService.java

@ -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;
    }
}

+ 30 - 23
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SFUtils.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.util;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
@ -21,14 +22,6 @@ public class SFUtils {
    private static Logger logger = LoggerFactory.getLogger(SFUtils.class);
    private String j_company;       //寄件方公司名称
    private String j_contact;       //寄件方联系人
    private String j_tel;           //寄件方联系电话
    private String j_province;      //寄件方所在省份
    private String j_city;          //寄件方所在城市名称
    private String j_county;        //寄件人所在县/区
    private String j_address;       //寄件方详细地址,包括省市县/区
    @Autowired
    private PrescriptionInfoService prescriptionInfoService;
@ -109,9 +102,10 @@ public class SFUtils {
    /**
     * 向顺丰快递下订单
     * @param sfexpress_obj
     * @param hospital
     * @return
     */
    public String postSFOrderService(PrescriptionExpressage sfexpress_obj,String sf_code) {
    public String postSFOrderService(PrescriptionExpressage sfexpress_obj, Hospital hospital, String sf_code) {
        //head 传入接口接入码
        StringBuilder xml = new StringBuilder("<Request service='OrderService' lang='zh-cn'><Head>"+sf_code+"</Head><Body>");
        xml.append("<Order ");
@ -121,32 +115,32 @@ public class SFUtils {
         * --------寄方参数------
         */
        //寄件方公司名称
        if(StringUtils.isNotBlank(j_company)){
            xml.append("j_company='"+j_company+"' ");
        if(StringUtils.isNotBlank(hospital.getName())){
            xml.append("j_company='"+hospital.getName()+"' ");
        }
        //寄方联系人
        if(StringUtils.isNotBlank(j_contact)){
            xml.append("j_contact='"+j_contact+"' ");
        if(StringUtils.isNotBlank(hospital.getName())){
            xml.append("j_contact='"+hospital.getName()+"' ");
        }
        //寄件方联系电话
        if(StringUtils.isNotBlank(j_tel)){
            xml.append("j_tel='"+j_tel+"' ");
        if(StringUtils.isNotBlank(hospital.getPhone())){
            xml.append("j_tel='"+hospital.getPhone()+"' ");
        }
        //寄方所在省份
        if(StringUtils.isNotBlank(j_province)){
            xml.append("j_province='"+j_province+"' ");
        if(StringUtils.isNotBlank(hospital.getProvinceName())){
            xml.append("j_province='"+hospital.getProvinceName()+"' ");
        }
        //寄方所在城市
        if(StringUtils.isNotBlank(j_city)){
            xml.append("j_city='"+j_city+"' ");
        if(StringUtils.isNotBlank(hospital.getCityName())){
            xml.append("j_city='"+hospital.getCityName()+"' ");
        }
        //寄方所在县/区
        if(StringUtils.isNotBlank(j_county)){
            xml.append("j_county='"+j_county+"' ");
        if(StringUtils.isNotBlank(hospital.getTownName())){
            xml.append("j_county='"+hospital.getTownName()+"' ");
        }
        //寄件方详细地址,包括省市县/区
        if(StringUtils.isNotBlank(j_address)){
            xml.append("j_address='"+j_address+"' ");
        if(StringUtils.isNotBlank(hospital.getAddress())){
            xml.append("j_address='"+hospital.getAddress()+"' ");
        }
        /**
         * --------收方参数------
@ -197,4 +191,17 @@ public class SFUtils {
        xml.append("</Body></Request>");
        return xml.toString();
    }
    /**
     * 订单结果查询接口
     * @param sfexpress_objCode
     * @param sf_code
     * @return
     */
    public String sfOrderSearchService(String sfexpress_objCode, String sf_code) {
        StringBuilder xml = new StringBuilder("<Request service='OrderSearchService' lang='zh-cn'><Head>"+sf_code+"</Head><Body>");
        xml.append("<OrderSearch orderid='"+sfexpress_objCode+"'/>");
        xml.append("</Body></Request>");
        return xml.toString();
    }
}

+ 9 - 39
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/express/SFExpressController.java

@ -77,25 +77,7 @@ public class SFExpressController extends BaseController {
    @ApiOperation("向顺丰快递下订单")
    @ObserverRequired
    public String SFOrderService(
            @ApiParam(name="prescriptionCode", value="处方编号") @RequestParam(value = "prescriptionCode",required = true) String prescriptionCode
//            @ApiParam(name="j_company", value="寄件方公司名称") @RequestParam(value = "j_company") String j_company,
//            @ApiParam(name="j_contact", value="寄件方联系人") @RequestParam(value = "j_contact") String j_contact,
//            @ApiParam(name="j_tel", value="寄件方联系电话") @RequestParam(value = "j_tel") String j_tel,
//            @ApiParam(name="j_mobile", value="寄件方手机") @RequestParam(value = "j_mobile") String j_mobile,
//            @ApiParam(name="j_province", value="寄件方所在省份") @RequestParam(value = "j_province") String j_province,
//            @ApiParam(name="j_city", value="寄件方所在城市名称") @RequestParam(value = "j_city") String j_city,
//            @ApiParam(name="j_county", value="寄件人所在县/区") @RequestParam(value = "j_county") String j_county,
//            @ApiParam(name="j_address", value="寄件方详细地址,不包括省市区") @RequestParam(value = "j_address") String j_address,
//            @ApiParam(name="d_company", value="到件方公司名称") @RequestParam(value = "d_company") String d_company,
//            @ApiParam(name="d_contact", value="到件方联系人") @RequestParam(value = "d_contact") String d_contact,
//            @ApiParam(name="d_tel", value="到件方联系电话") @RequestParam(value = "d_tel") String d_tel,
//            @ApiParam(name="d_mobile", value="到件方手机") @RequestParam(value = "d_mobile") String d_mobile,
//            @ApiParam(name="d_province", value="到件方所在省份") @RequestParam(value = "d_province") String d_province,
//            @ApiParam(name="d_city", value="到件方所在城市名称") @RequestParam(value = "d_city") String d_city,
//            @ApiParam(name="d_county", value="到件方所在县/区") @RequestParam(value = "d_county") String d_county,
//            @ApiParam(name="d_address", value="到件方完整的详细地址") @RequestParam(value = "d_address") String d_address
    ){
            @ApiParam(name="prescriptionCode", value="处方编号") @RequestParam(value = "prescriptionCode",required = true) String prescriptionCode){
        try {
            PrescriptionExpressage sfexpress_obj = prescriptionExpressageService.findByPrescriptionCode(prescriptionCode);
@ -108,33 +90,21 @@ public class SFExpressController extends BaseController {
                }else{
                //如果该处方的快递单号未生成,则继续下单
                    //先判断地址是否可派送---由于下订单前已判断是否能否派送
                    boolean delivery = sfexpressService.getSFOrderFilterService(sfexpress_obj.getProvinceName()+sfexpress_obj.getCityName()+sfexpress_obj.getTownName()+sfexpress_obj.getAddress());
                    if(delivery){
//                sfexpress_obj.setCode("SF"+UUID.randomUUID().toString().replace("-",""));
//                sfexpress_obj.setPrescriptionCode(prescriptionCode);
//                sfexpress_obj.setName(sfexpress_obj.getName());
//                sfexpress_obj.setPhone(sfexpress_obj.getPhone());
//                sfexpress_obj.setMobile(d_mobile);
//                sfexpress_obj.setProvinceName(d_province);
//                sfexpress_obj.setCityName(d_city);
//                sfexpress_obj.setTownName(d_county);
//                sfexpress_obj.setAddress(d_address);
//                sfexpress_obj.setHospitalName("顺丰速递");
//                sfexpress_obj.setOneselfPickupFlg(0);//是否自取 1是 0否
//                sfexpress_obj.setCreateTime(DateUtil.getNowDate());
                    //由于下单前已经判断过是否派送,这里不再重复判断----huangwenjie-2017.08.04
                    //先判断地址是否可派送boolean delivery = sfexpressService.getSFOrderFilterService(sfexpress_obj.getProvinceName()+sfexpress_obj.getCityName()+sfexpress_obj.getTownName()+sfexpress_obj.getAddress());
                    //根据业务订单号判断是否已经下单成功
                    boolean go_on = sfexpressService.sfOrderSearchService(sfexpress_obj);
                    //如果该业务订单号未下单成功过,则重新下单
                    if(go_on){
                        //请求顺丰接口下单,成功下单后,返回快递单号
                        sfexpress_obj = sfexpressService.postSFOrderService(sfexpress_obj);
                        //保存快递单号和增加处方物流记录为配送
                        prescriptionExpressageService.updatePrescriptionExpressage(sfexpress_obj);
                        return write(200, "顺丰快递下单成功!");
                    }else{
                        return write(-1, "顺丰快递下单失败,地址不可派送!");
                    }
                    return write(200, "顺丰快递下单成功!");
                }
            }
        }catch (Exception e){