Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

zdm 5 years ago
parent
commit
86c3fb4270
25 changed files with 1815 additions and 764 deletions
  1. 15 0
      business/base-service/src/main/java/com/yihu/jw/hospital/mapping/dao/DoctorMappingDao.java
  2. 26 0
      business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/DoctorMappingService.java
  3. 2 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java
  4. 2 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionDao.java
  5. 2 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionExpressageLogDao.java
  6. 0 2
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionInfoDao.java
  7. 721 638
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageService.java
  8. 342 12
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  9. 28 5
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/util/SFUtils.java
  10. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictHospitalDeptDO.java
  11. 0 13
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/consult/WlyyHospitalWaitingRoomDO.java
  12. 126 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/mapping/DoctorMappingDO.java
  13. 18 3
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyExpressagePriceDO.java
  14. 15 1
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientDO.java
  15. 2 1
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientExpressageLogDO.java
  16. 42 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionInfoDO.java
  17. 37 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  18. 38 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionInfoVO.java
  19. 27 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/config/bean/BeanConfig.java
  20. 209 79
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/expressage/ExpressageEndpoint.java
  21. 5 5
      svr/svr-internet-hospital-entrance/src/main/resources/application.yml
  22. 2 2
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/config/JpaConfig.java
  23. 72 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/file_upload/FileUploadEndpoint.java
  24. 78 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  25. 5 0
      svr/svr-internet-hospital/src/main/resources/application.yml

+ 15 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/mapping/dao/DoctorMappingDao.java

@ -0,0 +1,15 @@
package com.yihu.jw.hospital.mapping.dao;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2019/6/10.
 */
public interface DoctorMappingDao extends PagingAndSortingRepository<DoctorMappingDO, String>, JpaSpecificationExecutor<DoctorMappingDO> {
    List<DoctorMappingDO> findByDoctorAndOrgCode(String doctor,String orgCode);
}

+ 26 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/DoctorMappingService.java

@ -0,0 +1,26 @@
package com.yihu.jw.hospital.mapping.service;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by Trick on 2019/6/10.
 */
@Service
public class DoctorMappingService {
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    public DoctorMappingDO findMappingCode(String doctor,String orgCode){
        List<DoctorMappingDO> list = doctorMappingDao.findByDoctorAndOrgCode(doctor,orgCode);
        if(list!=null&&list.size()>0){
            return list.get(0);
        }
        return null;
    }
}

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java

@ -2,6 +2,7 @@ package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -14,4 +15,5 @@ public interface OutpatientDao extends PagingAndSortingRepository<WlyyOutpatient
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.status in(0,1)")
    @Query("from WlyyOutpatientDO a where a.patient = ?1 and a.status in(0,1)")
    List<WlyyOutpatientDO> findByPatientList(String patient);
    List<WlyyOutpatientDO> findByPatientList(String patient);
}
}

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionDao.java

@ -28,4 +28,6 @@ public interface PrescriptionDao extends PagingAndSortingRepository<WlyyPrescrip
    void updateStatus(String id, Integer status, Date date);
    void updateStatus(String id, Integer status, Date date);
    List<WlyyPrescriptionDO> findByOutpatientId(String outpatientId);
    List<WlyyPrescriptionDO> findByOutpatientId(String outpatientId);
    List<WlyyPrescriptionDO> findById(String id);
}
}

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionExpressageLogDao.java

@ -1,5 +1,6 @@
package com.yihu.jw.hospital.prescription.dao;
package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageLogDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -12,5 +13,6 @@ import java.util.List;
public interface PrescriptionExpressageLogDao extends PagingAndSortingRepository<WlyyPrescriptionExpressageLogDO, String>, JpaSpecificationExecutor<WlyyPrescriptionExpressageLogDO> {
public interface PrescriptionExpressageLogDao extends PagingAndSortingRepository<WlyyPrescriptionExpressageLogDO, String>, JpaSpecificationExecutor<WlyyPrescriptionExpressageLogDO> {
    List<WlyyPrescriptionExpressageLogDO> queryByOutpatientId(String outpatientId);
    List<WlyyPrescriptionExpressageLogDO> queryByOutpatientId(String outpatientId);
    List<WlyyPrescriptionExpressageLogDO> queryByOutpatientIdOrderByCreateTimeDesc(String outpatientId);
}
}

+ 0 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionInfoDao.java

@ -1,9 +1,7 @@
package com.yihu.jw.hospital.prescription.dao;
package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
import java.util.List;

+ 721 - 638
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageService.java

@ -1,638 +1,721 @@
//package com.yihu.jw.hospital.prescription.service;
//
//import com.yihu.jw.entity.base.org.BaseOrgDO;
//import com.yihu.jw.entity.hospital.prescription.*;
//import com.yihu.jw.hospital.prescription.dao.*;
//import com.yihu.jw.hospital.prescription.service.entrance.util.SFUtils;
//import com.yihu.jw.org.dao.BaseOrgDao;
//import com.yihu.jw.util.date.DateUtil;
//import com.yihu.jw.util.http.HttpClientKit;
//import com.yihu.mysql.query.BaseJpaService;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.http.NameValuePair;
//import org.apache.http.message.BasicNameValuePair;
//import org.dom4j.Document;
//import org.dom4j.DocumentHelper;
//import org.dom4j.Element;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.orm.jpa.JpaTransactionManager;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.TransactionDefinition;
//import org.springframework.transaction.TransactionStatus;
//import org.springframework.transaction.support.DefaultTransactionDefinition;
//
//import java.util.*;
//
///**
// *  门诊物流服务
// * lith 2019.06.04
// */
//
//@Service
//public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescriptionExpressageDO, PrescriptionExpressageDao> {
//    private static Logger logger = LoggerFactory.getLogger(PrescriptionExpressageService.class);
//
////    //顺丰快递接口请求地址
////    //@Value("${express.sf_url}")
////    private String sf_url;
////
////    //顺丰快递接口接入编码
////    //@Value("${express.sf_code}")
////    private String sf_code;
////
////    //顺丰快递接口checkword
////    //@Value("${express.sf_check_word}")
////    private String sf_check_word;
//
//    @Autowired
//    private SFUtils SFUtils;
//
//    @Autowired
//    private JpaTransactionManager transactionManager;
//
//    //处方日志
//    @Autowired
//    private WlyyOutpatientExpressageLogDao outpatientExpressageLogDao;
//
//    @Autowired
//    private PrescriptionDao prescriptionDao;
//
//    @Autowired
//    private WlyyExpressagePriceDao expressagePriceDao;
//
//    @Autowired
//    private PrescriptionExpressageLogDao prescriptionExpressageLogDao;
//
//    @Autowired
//    private PrescriptionExpressageDao prescriptionExpressageDao;
//
//    @Autowired
//    private BaseOrgDao baseOrgDao;
//
//
//    /**
//     * 组装请求参数,发送请求
//     * @param xml
//     * @return
//     * @throws Exception
//     */
//    private String SFExpressPost(String xml)throws Exception{
//        String verifyCode = SFUtils.verifyCodeSFXmlStr(xml,sf_check_word);
//        List<NameValuePair> params = new ArrayList<>();
//        params.add(new BasicNameValuePair("xml", xml));
//        params.add(new BasicNameValuePair("verifyCode", verifyCode));
//        String re = HttpClientKit.post(sf_url, params, "UTF-8");
//        return re;
//    }
//
//    /**
//     * 校验返回的xml报文
//     * @param responseXml
//     * @param title
//     */
//    private void verificationResponXml(String responseXml,String title) throws Exception {
//        String error = "";
//        if (StringUtils.isBlank(responseXml)) {
//            // 如果返回的XML报文为空,请求也算失败
//            //保存http日志
//            error = title + ",返回的XML为空!";
//            logger.info(error);
//            throw new Exception(error);
//        }else{
////          报错的报文示例<Response service="ScopeService"><Head>ERR</Head><ERROR code="8014">校验码错误 </ERROR></Response>
//            Document doc = DocumentHelper.parseText(responseXml);
//            String headvalue = doc.selectSingleNode("/Response/Head").getText();
//            if(StringUtils.isNotBlank(headvalue) && "ERR".equals(headvalue)){
//                //错误代码
//                String errorCode = "";
//                //错误代对应的文字
//                String errorMessage = doc.selectSingleNode("/Response/ERROR").getText();
//                Document error_doc = doc.selectSingleNode("/Response/ERROR").getDocument();
//                Element root = error_doc.getRootElement();
//                List<?> child = root.elements();
//                for (Object o : child){
//                    Element e = (Element) o;
//                    errorCode = e.attributeValue("code");
//                }
//                error = title+","+errorCode+","+errorMessage;
//                logger.info(error);
//                throw new Exception(error);
//            }
//        }
//    }
//
//
//    /**
//     * 查询派送地址是否属于顺丰的派送范围
//     * @param d_address 派送地址
//     * @return
//     */
//    public Boolean getSFOrderFilterService(String d_address) throws Exception {
//
//        boolean result = false;
//
//        String xml = SFUtils.getSFOrderFilterXml(d_address,sf_code,"","","","");
//
//        String re = this.SFExpressPost(xml);
//
////        String re = "<Response service=\"OrderFilterService\"><Head>OK</Head><Body><OrderFilterResponse orderid=\"TE201407020016\" filter_result=\"2\" origincode=\"755\" remark=\"2\"/></Body></Response>";
//
//        //xml验证
//        verificationResponXml(re,"查询派送地址是否有效失败!");
//
//
//        Document doc = DocumentHelper.parseText(re);
//        String headvalue = doc.selectSingleNode("/Response/Head").getText();
//        Element root = doc.getRootElement();
//        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
//            //是否能派送:1:人工确认;2:可收派;3:不可以收派
//            String filter_result = "";
//
//            Element firstWorldElement = root.element("Body");
//
//            List<Element> elements = firstWorldElement.elements();
//
//            for (Element o : elements){
//                filter_result = o.attributeValue("filter_result");
//            }
//
//            if(StringUtils.isNotBlank(filter_result) && "2".equals(filter_result)){
//                result = true;
//            }
//        }
//        return result;
//
//
//    }
//
//    /**
//     * 向顺丰快递下订单
//     * @param sfexpress_obj
//     * @return
//     * @throws Exception
//     */
//    public WlyyPrescriptionExpressageDO postSFOrderService(WlyyPrescriptionExpressageDO sfexpress_obj) throws Exception {
//
//        //获取医生所处的医院详细地址,作为寄件人地址
//        WlyyPrescriptionDO prescription = prescriptionDao.findOne(sfexpress_obj.getOutpatientId());
//        BaseOrgDO hospital = baseOrgDao.findByCode(prescription.getHospital());
//
//        String xml = SFUtils.postSFOrderService(sfexpress_obj,hospital,sf_code);
//        logger.info("顺丰快递下订单:xml"+xml);
//        String re = this.SFExpressPost(xml);
////        String re = "<Response service=\"OrderService\"><Head>OK</Head><Body><OrderResponse filter_result=\"2\" destcode=\"592\" mailno=\"444844978335\" origincode=\"592\" orderid=\"6daa6baec5fd4b65a1b023a8b60e2e91\"/></Body></Response>";
//
//        //xml验证
//        logger.info("顺丰快递下订单:re"+re);
//        verificationResponXml(re,"向顺丰快递下订单失败!");
//
//        Document doc = DocumentHelper.parseText(re);
//        String headvalue = doc.selectSingleNode("/Response/Head").getText();
//        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
//            Element root = doc.getRootElement();
//            if (root.element("Body") != null)     //包含OrderResponse节点
//            {
//                root = root.element("Body");
//            }
//
//            //是否能派送:1:人工确认;2:可收派;3:不可以收派
//            String filter_result = "";
//            String orderid = "";//业务订单号
//            String mailno = "";//顺丰运单号
//            String destCode = "";//目的地区域代码
//            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");
//                destCode = e.attributeValue("destcode");
//            }
//            if(StringUtils.isNotBlank(filter_result) && "3".equals(filter_result)){
//                logger.info("顺丰快递下订单失败:派送地址不可派送,门诊编号:"+sfexpress_obj.getOutpatientId());
//                throw new Exception("顺丰快递下订单失败:派送地址不可派送");
//            }
//
//            if(StringUtils.isBlank(mailno)){
//                logger.info("顺丰快递下订单失败:未获取到快递单号!门诊编号:"+sfexpress_obj.getOutpatientId());
//                throw new Exception("顺丰快递下订单失败:未获取到快递单号!");
//            }
//            sfexpress_obj.setMailno(mailno);
//            sfexpress_obj.setCityCode(destCode);
//        }
//        return sfexpress_obj;
//    }
//
//
//    /**
//     * 调用顺丰接口获取物流路由日志,与本地匹配,进行增量修改,并返回完整日志列表
//     * @param prescription
//     * @param sfexpress_obj
//     * @param sfexpresslogList
//     * @return
//     */
//    public List<WlyyPrescriptionExpressageLogDO> getRoutInfos(WlyyPrescriptionDO prescription, WlyyPrescriptionExpressageDO sfexpress_obj, List<WlyyPrescriptionExpressageLogDO> sfexpresslogList) throws Exception {
//        String xml = SFUtils.getRoutInfos(sfexpress_obj,sf_code);
//        String re = this.SFExpressPost(xml);
//        //xml验证
//        verificationResponXml(re,"查询顺丰快递路由信息失败!");
//        Document doc = DocumentHelper.parseText(re);
//        String headvalue = doc.selectSingleNode("/Response/Head").getText();
//        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
//            Element root = doc.getRootElement();
//            if (root.element("Body") != null)     //取报文根节点
//            {
//                root = root.element("Body");
//            }
//            List<?> child = root.elements();
//            String mailno = "";
//            Map<String,List<WlyyPrescriptionExpressageLogDO>> wayroutlsit = new HashMap<>();
//            for (Object o : child) {
//                Element e = (Element) o;
//                mailno = e.attributeValue("mailno");
//                //判断快递单号不为空,且和我们本地的一致
//                if(StringUtils.isNotBlank(mailno) &&
//                        sfexpress_obj.getMailno().equals(mailno)){
//
//                    //解析报文,结合本地数据返回最终的日志结果
//                    return this.xmltologlist(e,sfexpresslogList,sfexpress_obj);
//                }else{
//                    continue;
//                }
//            }
//        }
//        return null;
//    }
//
//    private List<WlyyPrescriptionExpressageLogDO> xmltologlist(Element e, List<WlyyPrescriptionExpressageLogDO> sfexpresslogList, WlyyPrescriptionExpressageDO sfexpress_obj)throws Exception{
//
//        //获取本地所有路由信息的时间集
//        Set<String> routAcceptTimeSet = new HashSet<>();
//        for (WlyyPrescriptionExpressageLogDO log: sfexpresslogList) {
//            routAcceptTimeSet.add(DateUtil.dateToStrLong(log.getAcceptTime()));
//        }
//
//        List<?> child = e.elements();
//
//        List<WlyyPrescriptionExpressageLogDO> newroutinfolist = new ArrayList<>();
//
//        //用于判断新节点是否包含了"已收件"的节点
//        boolean isContainEndRoutInfo = false;
//
//        for (Object o : child) {
//            Element routinfoe = (Element) o;
//            String accept_time = routinfoe.attributeValue("accept_time");
//            String accept_address = routinfoe.attributeValue("accept_address");
//            String accept_remark = routinfoe.attributeValue("remark");
//            String opcode = routinfoe.attributeValue("opcode");
//
//            //和时间集作比对,过滤已存在的
//            if(!routAcceptTimeSet.contains(accept_time)){
//                WlyyPrescriptionExpressageLogDO newlogobj = new WlyyPrescriptionExpressageLogDO();
//                newlogobj.setAcceptTime(DateUtil.strToDate(accept_time));
//                newlogobj.setAcceptAddress(accept_address);
//                newlogobj.setAcceptRemark(accept_remark);
//                newlogobj.setOpCode(opcode);
//                newlogobj.setId(UUID.randomUUID().toString().replace("-",""));
//                newlogobj.setOutpatientId(sfexpress_obj.getOutpatientId());
//                newlogobj.setExpressageId(sfexpress_obj.getId());
//                newlogobj.setCreateTime(new Date());
//                newroutinfolist.add(newlogobj);
//                sfexpresslogList.add(newlogobj);
//                //aopcode=80,为已签收
//                if("80".equals(opcode)){
//                    isContainEndRoutInfo = true;
//                }
//            }
//        }
//
//
//        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
//        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
//        TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
//        try {
//
//            //如果有新增的路由信息,则添加到数据库
//            if(!newroutinfolist.isEmpty()){
//                prescriptionExpressageLogDao.save(newroutinfolist);
//            }
//
//            //如果路由信息节点包含了"已收件"节点,这修改处方派送状态为完成,增加物流派送日志为完成
//            if(isContainEndRoutInfo){
//                //修改处方状态为完成
//                prescriptionDao.updateStatus(sfexpress_obj.getId(), 100,new Date());
//
//                //保存门诊处方配送成功的日志
//                WlyyOutpatientExpressageLogDO outpatiExpressLog = new WlyyOutpatientExpressageLogDO();
//                outpatiExpressLog.setOutpatientId(sfexpress_obj.getOutpatientId());
//                outpatiExpressLog.setId(UUID.randomUUID().toString());
//                outpatiExpressLog.setType(8);
//                outpatiExpressLog.setCreateTime(new Date());
//                outpatiExpressLog.setFlag(1);
//                outpatiExpressLog.setStatus(100);
//                outpatientExpressageLogDao.save(outpatiExpressLog);
//            }
//
//            //事务提交
//            transactionManager.commit(status);
//        } catch (Exception ex) {
//            //报错事务回滚
//            transactionManager.rollback(status);
//        }
//
//
//        return sfexpresslogList;
//    }
//
//    /**
//     * 解析顺丰推送过来的路由信息,和本地数据匹配并进行增量更新)
//     * @param xml
//     * @return
//     * @throws Exception
//     */
//    public void SFRoutePushService(String xml) throws Exception{
//        Document doc = DocumentHelper.parseText(xml);
//        Element root = doc.getRootElement();
//        if (root.element("Body") != null)     //包含WaybillRoute节点
//        {
//            root = root.element("Body");
//        }
//        List<?> child = root.elements();
//
//        Map<String,List<WlyyPrescriptionExpressageLogDO>> wayroutlsit = new HashMap<>();
//        for (Object o : child) {
//            Element routinfoe = (Element) o;
//            WlyyPrescriptionExpressageLogDO sflog = new WlyyPrescriptionExpressageLogDO();
//            String accept_time = routinfoe.attributeValue("accepttime");
//            String accept_address = routinfoe.attributeValue("acceptaddress");
//            String accept_remark = routinfoe.attributeValue("remark");
//            String opcode = routinfoe.attributeValue("opcode");
//            String mailno = routinfoe.attributeValue("mailno");
//            String orderid = routinfoe.attributeValue("orderid");
//
//            sflog.setAcceptTime(DateUtil.strToDate(accept_time));
//            sflog.setAcceptAddress(accept_address);
//            sflog.setAcceptRemark(accept_remark);
//            sflog.setOpCode(opcode);
//            sflog.setExpressageId(orderid);
//            sflog.setId(UUID.randomUUID().toString());
//            sflog.setCreateTime(new Date());
//            if(wayroutlsit.keySet().contains(mailno)){
//                wayroutlsit.get(mailno).add(sflog);
//            }else{
//                List<WlyyPrescriptionExpressageLogDO> newsflogs = new ArrayList<>();
//                newsflogs.add(sflog);
//                wayroutlsit.put(mailno,newsflogs);
//            }
//        }
//
//        if(!wayroutlsit.keySet().isEmpty()){
//            for (String mailno:wayroutlsit.keySet()) {
//                List<WlyyPrescriptionExpressageLogDO> pushSFLogs = wayroutlsit.get(mailno);
//                //同一个快递单号的执行一个事务操作
//                this.saveSFPushRoutInfos(mailno,pushSFLogs);
//            }
//        }
//    }
//
//    /**
//     * 同一个快递单号的执行一个事务操作
//     * @param mailno
//     * @param pushSFLogs
//     */
//    public void saveSFPushRoutInfos(String mailno,List<WlyyPrescriptionExpressageLogDO> pushSFLogs){
//
//        //根据快递单号获取处方配送详细信息
//        WlyyPrescriptionExpressageDO sfexpress = prescriptionExpressageDao.findByPrescriptionExpressMailno(mailno);
//        //根据快递单号获取本地的路由信息
//        List<WlyyPrescriptionExpressageLogDO> localroutinfos = prescriptionExpressageLogDao.queryByOutpatientId(sfexpress.getOutpatientId());
//        //需要增量更新到本地的路由信息集合
//        List<WlyyPrescriptionExpressageLogDO> newroutinfolist = new ArrayList<>();
//
//        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
//        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事务隔离级别,开启新事务
//        TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
//        try {
//
//            //用于判断新节点是否包含了"已收件"的节点
//            boolean isContainEndRoutInfo = false;
//
//            //获取本地所有路由信息的时间集
//            Set<String> routAcceptTimeSet = new HashSet<>();
//            for (WlyyPrescriptionExpressageLogDO log: localroutinfos) {
//                routAcceptTimeSet.add(DateUtil.dateToStrLong(log.getAcceptTime()));
//            }
//
//            for (WlyyPrescriptionExpressageLogDO pushlog: pushSFLogs) {
//
//                //判断是否有已收件的路由节点
//                if("80".equals(pushlog.getOpCode())){
//                    isContainEndRoutInfo = true;
//                }
//
//                if(routAcceptTimeSet.contains(DateUtil.dateToStrLong(pushlog.getAcceptTime()))){
//                    continue;
//                }else{
//                    pushlog.setOutpatientId(sfexpress.getOutpatientId());
//                    newroutinfolist.add(pushlog);
//                }
//            }
//
//            //如果有新增的路由信息,则添加到数据库
//            if(!newroutinfolist.isEmpty()){
//                prescriptionExpressageLogDao.save(newroutinfolist);
//            }
//
//            //如果路由信息节点包含了"已收件"节点,则修改处方状态为完成,增加物流派送日志为完成
//            if(isContainEndRoutInfo){
//                //修改处方状态为完成
//                prescriptionDao.updateStatus(sfexpress.getOutpatientId(), 100,new Date());
//
//                //保存配送成功的日志
//                WlyyOutpatientExpressageLogDO outpatiExpressLog = new WlyyOutpatientExpressageLogDO();
//                outpatiExpressLog.setOutpatientId(sfexpress.getOutpatientId());
//                outpatiExpressLog.setId(UUID.randomUUID().toString());
//                outpatiExpressLog.setType(8);
//                outpatiExpressLog.setCreateTime(new Date());
//                outpatiExpressLog.setFlag(1);
//                outpatiExpressLog.setStatus(100);
//                outpatientExpressageLogDao.save(outpatiExpressLog);
//            }
//            //事务提交
//            transactionManager.commit(status);
//        } catch (Exception ex) {
//            //报错事务回滚
//            transactionManager.rollback(status);
//        }
//
//
//    }
//
//    /**
//     * 根据收寄地址获取快递费用
//     * @param d_province 省份名称
//     * @param d_city     城市名称
//     * @return
//     */
//    public WlyyExpressagePriceDO getSFExpressPrice(String d_province, String d_city) throws Exception{
//        String end_address_name = "";
//
//        if("厦门市".equals(d_city)){
//            end_address_name = "同城";
//        }else{
//            if("福建省".equals(d_province)){
//                end_address_name = "省内";
//            }else{
//                end_address_name = d_province;
//            }
//        }
//        end_address_name = "%"+end_address_name.replaceAll("省","").replaceAll("市","")+"%";
//        WlyyExpressagePriceDO sfprice =  expressagePriceDao.getExprePriceByIdAndEndAdressName("shunfeng",end_address_name);
//        return sfprice;
//    }
//
//    /**
//     * 根据处方快递订单号判断是否下单成功
//     * 如果下单成功,保存处方物流记录,保存配送日志
//     * @param sfexpress_obj
//     * @return
//     * @throws Exception
//     */
//    public boolean sfOrderSearchService(WlyyPrescriptionExpressageDO sfexpress_obj)  throws Exception{
//
//        boolean go_on = false;
//
//        String xml = SFUtils.sfOrderSearchService(sfexpress_obj.getId(),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 = "";//顺丰运单号
//                String destCode = "";//目的地区域代码
//
//                //错误代对应的文字
//                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");
//                    destCode = e.attributeValue("destCode");
//                }
//
//                if(StringUtils.isBlank(mailno)){
//                    logger.info("顺丰快递下订单失败:未获取到快递单号!"+sfexpress_obj.getOutpatientId());
//                    return true;
//                }
//
//                if(StringUtils.isNotBlank(filter_result) && "3".equals(filter_result)){
//                    logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getOutpatientId());
//                    return true;
//                }
//
//                sfexpress_obj.setMailno(mailno);
//                sfexpress_obj.setCityCode(destCode);
//            }
//
//            //如果成功获取到快递单号,则保存处方物流记录,保存配送日志
//            //修改处方状态为配送中
//            prescriptionDao.updateStatus(sfexpress_obj.getOutpatientId(),65);
//
//            //保存处方物流记录
//            prescriptionExpressageDao.save(sfexpress_obj);
//
//            //保存配送日志
//            WlyyOutpatientExpressageLogDO outpatiExpressLog = new WlyyOutpatientExpressageLogDO();
//            outpatiExpressLog.setOutpatientId(sfexpress_obj.getOutpatientId());
//            outpatiExpressLog.setId(UUID.randomUUID().toString());
//            outpatiExpressLog.setType(8);
//            outpatiExpressLog.setCreateTime(new Date());
//            outpatiExpressLog.setFlag(1);
//            outpatiExpressLog.setStatus(100);
//            outpatientExpressageLogDao.save(outpatiExpressLog);
//
//
//        }catch (Exception ex){
//            logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getOutpatientId());
//            //如果订单处理失败,则可以继续下单
//            go_on = true;
//        }
//
//        return go_on;
//
//    }
//
//    public boolean sfOrderSearchServiceJustSearch(WlyyPrescriptionExpressageDO sfexpress_obj)  throws Exception{
//
//        String xml = SFUtils.sfOrderSearchService(sfexpress_obj.getId(),sf_code);
//        String re = this.SFExpressPost(xml);
//
//        boolean reslut = false;
//
//        try {
//            //xml验证
//            verificationResponXml(re,"订单处理失败!");
//
//            Document doc = DocumentHelper.parseText(re);
//            String headvalue = doc.selectSingleNode("/Response/Head").getText();
//            if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
//                Element root = doc.getRootElement();
//                if (root.element("Body") != null)     //包含OrderResponse节点
//                {
//                    root = root.element("Body");
//                }
//
//                //是否能派送:1:人工确认;2:可收派;3:不可以收派
//                String filter_result = "";
//                String orderid = "";//业务订单号
//                String mailno = "";//顺丰运单号
//                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.isNotBlank(filter_result) && "3".equals(filter_result)){
//                    logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getOutpatientId());
//                    throw new Exception("顺丰快递下订单失败:派送地址不可派送");
//                }
//
//                if(StringUtils.isBlank(mailno)){
//                    logger.info("顺丰快递下订单失败:未获取到快递单号!"+sfexpress_obj.getOutpatientId());
//                    throw new Exception("顺丰快递下订单失败:未获取到快递单号!");
//                }
//            }
//
//
//
//        }catch (Exception ex){
//            logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getOutpatientId());
//            //如果订单处理失败,则可以继续下单
//            throw new Exception(ex.getMessage());
//        }
//
//        return reslut;
//    }
//
//    public String getRoutInfosSearch(WlyyPrescriptionExpressageDO sfexpress_obj)throws Exception {
//        String xml = SFUtils.getRoutInfos(sfexpress_obj,sf_code);
//        String re = this.SFExpressPost(xml);
//
//        return xml;
//    }
//
//}
package com.yihu.jw.hospital.prescription.service;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.util.SFUtils;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientKit;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.util.*;
/**
 *  门诊物流服务
 * lith 2019.06.04
 */
public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescriptionExpressageDO, PrescriptionExpressageDao> {
    private static Logger logger = LoggerFactory.getLogger(PrescriptionExpressageService.class);
    //顺丰快递接口请求地址
    private String sf_url;
    //顺丰快递接口接入编码
    private String sf_code;
    //顺丰快递接口checkword
    private String sf_check_word;
    @Autowired
    private SFUtils SFUtils;
    @Autowired
    private JpaTransactionManager transactionManager;
    //处方日志
    @Autowired
    private WlyyOutpatientExpressageLogDao outpatientExpressageLogDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private WlyyExpressagePriceDao expressagePriceDao;
    @Autowired
    private PrescriptionExpressageLogDao prescriptionExpressageLogDao;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private BaseOrgDao baseOrgDao;
    @Autowired
    private OutpatientDao outpatientDao;
    private PrescriptionExpressageService(){}
    public PrescriptionExpressageService(String sf_url,String sf_code,String sf_check_word){
        this.sf_url = sf_url;
        this.sf_code = sf_code;
        this.sf_check_word = sf_check_word;
    }
    /**
     * 组装请求参数,发送请求
     * @param xml
     * @return
     * @throws Exception
     */
    private String SFExpressPost(String xml)throws Exception{
        String verifyCode = SFUtils.verifyCodeSFXmlStr(xml,sf_check_word);
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("xml", xml));
        params.add(new BasicNameValuePair("verifyCode", verifyCode));
        String re = HttpClientKit.post(sf_url, params, "UTF-8");
        return re;
    }
    /**
     * 校验返回的xml报文
     * @param responseXml
     * @param title
     */
    private void verificationResponXml(String responseXml,String title) throws Exception {
        String error = "";
        if (StringUtils.isBlank(responseXml)) {
            // 如果返回的XML报文为空,请求也算失败
            //保存http日志
            error = title + ",返回的XML为空!";
            logger.info(error);
            throw new Exception(error);
        }else{
//          报错的报文示例<Response service="ScopeService"><Head>ERR</Head><ERROR code="8014">校验码错误 </ERROR></Response>
            Document doc = DocumentHelper.parseText(responseXml);
            String headvalue = doc.selectSingleNode("/Response/Head").getText();
            if(StringUtils.isNotBlank(headvalue) && "ERR".equals(headvalue)){
                //错误代码
                String errorCode = "";
                //错误代对应的文字
                String errorMessage = doc.selectSingleNode("/Response/ERROR").getText();
                Document error_doc = doc.selectSingleNode("/Response/ERROR").getDocument();
                Element root = error_doc.getRootElement();
                List<?> child = root.elements();
                for (Object o : child){
                    Element e = (Element) o;
                    errorCode = e.attributeValue("code");
                }
                error = title+","+errorCode+","+errorMessage;
                logger.info(error);
                throw new Exception(error);
            }
        }
    }
    /**
     * 查询派送地址是否属于顺丰的派送范围
     * @param d_address 派送地址
     * @return
     */
    public Boolean getSFOrderFilterService(String d_address) throws Exception {
        boolean result = false;
        String xml = SFUtils.getSFOrderFilterXml(d_address,sf_code,"","","","");
        String re = this.SFExpressPost(xml);
//        String re = "<Response service=\"OrderFilterService\"><Head>OK</Head><Body><OrderFilterResponse orderid=\"TE201407020016\" filter_result=\"2\" origincode=\"755\" remark=\"2\"/></Body></Response>";
        //xml验证
        verificationResponXml(re,"查询派送地址是否有效失败!");
        Document doc = DocumentHelper.parseText(re);
        String headvalue = doc.selectSingleNode("/Response/Head").getText();
        Element root = doc.getRootElement();
        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
            //是否能派送:1:人工确认;2:可收派;3:不可以收派
            String filter_result = "";
            Element firstWorldElement = root.element("Body");
            List<Element> elements = firstWorldElement.elements();
            for (Element o : elements){
                filter_result = o.attributeValue("filter_result");
            }
            if(StringUtils.isNotBlank(filter_result) && "2".equals(filter_result)){
                result = true;
            }
        }
        return result;
    }
    /**
     * 向顺丰快递下订单
     * @param sfexpress_obj
     * @return
     * @throws Exception
     */
    public WlyyPrescriptionExpressageDO postSFOrderService(WlyyPrescriptionExpressageDO sfexpress_obj) throws Exception {
        //获取医生所处的医院详细地址,作为寄件人地址
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(sfexpress_obj.getOutpatientId());
        BaseOrgDO hospital = baseOrgDao.findByCode(outpatientDO.getHospital());
        String xml = SFUtils.postSFOrderService(sfexpress_obj,hospital,sf_code);
        logger.info("顺丰快递下订单:xml"+xml);
        String re = this.SFExpressPost(xml);
//        String re = "<Response service=\"OrderService\"><Head>OK</Head><Body><OrderResponse filter_result=\"2\" destcode=\"592\" mailno=\"444844978335\" origincode=\"592\" orderid=\"6daa6baec5fd4b65a1b023a8b60e2e91\"/></Body></Response>";
        //xml验证
        logger.info("顺丰快递下订单:re"+re);
        verificationResponXml(re,"向顺丰快递下订单失败!");
        Document doc = DocumentHelper.parseText(re);
        String headvalue = doc.selectSingleNode("/Response/Head").getText();
        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
            Element root = doc.getRootElement();
            if (root.element("Body") != null)     //包含OrderResponse节点
            {
                root = root.element("Body");
            }
            //是否能派送:1:人工确认;2:可收派;3:不可以收派
            String filter_result = "";
            String orderid = "";//业务订单号
            String mailno = "";//顺丰运单号
            String destCode = "";//目的地区域代码
            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");
                destCode = e.attributeValue("destcode");
            }
            if(StringUtils.isNotBlank(filter_result) && "3".equals(filter_result)){
                logger.info("顺丰快递下订单失败:派送地址不可派送,门诊编号:"+sfexpress_obj.getOutpatientId());
                throw new Exception("顺丰快递下订单失败:派送地址不可派送");
            }
            if(StringUtils.isBlank(mailno)){
                logger.info("顺丰快递下订单失败:未获取到快递单号!门诊编号:"+sfexpress_obj.getOutpatientId());
                throw new Exception("顺丰快递下订单失败:未获取到快递单号!");
            }
            sfexpress_obj.setMailno(mailno);
            sfexpress_obj.setCityCode(destCode);
        }
        return sfexpress_obj;
    }
    /**
     * 向顺丰快递取消订单
     * @param sfexpress_obj
     * @return
     * @throws Exception
     */
    public String postOrderConfirmService(WlyyPrescriptionExpressageDO sfexpress_obj) throws Exception {
        //获取医生所处的医院详细地址,作为寄件人地址
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(sfexpress_obj.getOutpatientId());
        BaseOrgDO hospital = baseOrgDao.findByCode(outpatientDO.getHospital());
        String xml = SFUtils.SFOrderConfirmXml(sf_code,sfexpress_obj.getId(),sfexpress_obj.getMailno(),2);
        logger.info("顺丰快递取消订单请求:xml"+xml);
        String re = this.SFExpressPost(xml);
//        String re = "<Response service=\"OrderService\"><Head>OK</Head><Body><OrderResponse filter_result=\"2\" destcode=\"592\" mailno=\"444844978335\" origincode=\"592\" orderid=\"6daa6baec5fd4b65a1b023a8b60e2e91\"/></Body></Response>";
        //xml验证
        logger.info("顺丰快递取消订单结果:re"+re);
        verificationResponXml(re,"顺丰快递取消订单失败!");
        Document doc = DocumentHelper.parseText(re);
        String headvalue = doc.selectSingleNode("/Response/Head").getText();
        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
            Element root = doc.getRootElement();
            if (root.element("Body") != null)     //包含OrderResponse节点
            {
                root = root.element("Body");
            }
            String res_status = "";
            List<?> child = root.elements();
            for (Object o : child) {
                Element e = (Element) o;
                // 1:客户订单号与顺丰运单不匹配 2 :操作成功
                res_status = e.attributeValue("res_status");
            }
            if(StringUtils.isNotBlank(res_status) && !"2".equals(res_status)){
                logger.info("顺丰快递取消订单失败:门诊编号:"+sfexpress_obj.getOutpatientId());
                throw new Exception("顺丰快递取消订单失败:客户订单号与顺丰运单不匹配");
            }
        }
        return "取消成功";
    }
    /**
     * 调用顺丰接口获取物流路由日志,与本地匹配,进行增量修改,并返回完整日志列表
     * @param prescription
     * @param sfexpress_obj
     * @param sfexpresslogList
     * @return
     */
    public List<WlyyPrescriptionExpressageLogDO> getRoutInfos(WlyyPrescriptionDO prescription, WlyyPrescriptionExpressageDO sfexpress_obj, List<WlyyPrescriptionExpressageLogDO> sfexpresslogList) throws Exception {
        String xml = SFUtils.getRoutInfos(sfexpress_obj,sf_code);
        String re = this.SFExpressPost(xml);
        //xml验证
        verificationResponXml(re,"查询顺丰快递路由信息失败!");
        Document doc = DocumentHelper.parseText(re);
        String headvalue = doc.selectSingleNode("/Response/Head").getText();
        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
            Element root = doc.getRootElement();
            if (root.element("Body") != null)     //取报文根节点
            {
                root = root.element("Body");
            }
            List<?> child = root.elements();
            String mailno = "";
            Map<String,List<WlyyPrescriptionExpressageLogDO>> wayroutlsit = new HashMap<>();
            for (Object o : child) {
                Element e = (Element) o;
                mailno = e.attributeValue("mailno");
                //判断快递单号不为空,且和我们本地的一致
                if(StringUtils.isNotBlank(mailno) &&
                        sfexpress_obj.getMailno().equals(mailno)){
                    //解析报文,结合本地数据返回最终的日志结果
                    return this.xmltologlist(e,sfexpresslogList,sfexpress_obj);
                }else{
                    continue;
                }
            }
        }
        return null;
    }
    private List<WlyyPrescriptionExpressageLogDO> xmltologlist(Element e, List<WlyyPrescriptionExpressageLogDO> sfexpresslogList, WlyyPrescriptionExpressageDO sfexpress_obj)throws Exception{
        //获取本地所有路由信息的时间集
        Set<String> routAcceptTimeSet = new HashSet<>();
        for (WlyyPrescriptionExpressageLogDO log: sfexpresslogList) {
            routAcceptTimeSet.add(DateUtil.dateToStrLong(log.getAcceptTime()));
        }
        List<?> child = e.elements();
        List<WlyyPrescriptionExpressageLogDO> newroutinfolist = new ArrayList<>();
        //用于判断新节点是否包含了"已收件"的节点
        boolean isContainEndRoutInfo = false;
        for (Object o : child) {
            Element routinfoe = (Element) o;
            String accept_time = routinfoe.attributeValue("accept_time");
            String accept_address = routinfoe.attributeValue("accept_address");
            String accept_remark = routinfoe.attributeValue("remark");
            String opcode = routinfoe.attributeValue("opcode");
            //和时间集作比对,过滤已存在的
            if(!routAcceptTimeSet.contains(accept_time)){
                WlyyPrescriptionExpressageLogDO newlogobj = new WlyyPrescriptionExpressageLogDO();
                newlogobj.setAcceptTime(DateUtil.strToDate(accept_time));
                newlogobj.setAcceptAddress(accept_address);
                newlogobj.setAcceptRemark(accept_remark);
                newlogobj.setOpCode(opcode);
                newlogobj.setId(UUID.randomUUID().toString().replace("-",""));
                newlogobj.setOutpatientId(sfexpress_obj.getOutpatientId());
                newlogobj.setExpressageId(sfexpress_obj.getId());
                newlogobj.setCreateTime(new Date());
                newroutinfolist.add(newlogobj);
                sfexpresslogList.add(newlogobj);
                //aopcode=80,为已签收
                if("80".equals(opcode)){
                    isContainEndRoutInfo = true;
                }
            }
        }
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
        TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
        try {
            //如果有新增的路由信息,则添加到数据库
            if(!newroutinfolist.isEmpty()){
                prescriptionExpressageLogDao.save(newroutinfolist);
            }
            //如果路由信息节点包含了"已收件"节点,这修改处方派送状态为完成,增加物流派送日志为完成
            if(isContainEndRoutInfo){
                //修改处方状态为完成
                prescriptionDao.updateStatus(sfexpress_obj.getId(), 100,new Date());
                //保存门诊处方配送成功的日志
                WlyyOutpatientExpressageLogDO outpatiExpressLog = new WlyyOutpatientExpressageLogDO();
                outpatiExpressLog.setOutpatientId(sfexpress_obj.getOutpatientId());
                outpatiExpressLog.setId(UUID.randomUUID().toString());
                outpatiExpressLog.setType(8);
                outpatiExpressLog.setCreateTime(new Date());
                outpatiExpressLog.setFlag(1);
                outpatiExpressLog.setStatus(100);
                outpatientExpressageLogDao.save(outpatiExpressLog);
            }
            //事务提交
            transactionManager.commit(status);
        } catch (Exception ex) {
            //报错事务回滚
            transactionManager.rollback(status);
        }
        return sfexpresslogList;
    }
    /**
     * 解析顺丰推送过来的路由信息,和本地数据匹配并进行增量更新)
     * @param xml
     * @return
     * @throws Exception
     */
    public void SFRoutePushService(String xml) throws Exception{
        Document doc = DocumentHelper.parseText(xml);
        Element root = doc.getRootElement();
        if (root.element("Body") != null)     //包含WaybillRoute节点
        {
            root = root.element("Body");
        }
        List<?> child = root.elements();
        Map<String,List<WlyyPrescriptionExpressageLogDO>> wayroutlsit = new HashMap<>();
        for (Object o : child) {
            Element routinfoe = (Element) o;
            WlyyPrescriptionExpressageLogDO sflog = new WlyyPrescriptionExpressageLogDO();
            String accept_time = routinfoe.attributeValue("accepttime");
            String accept_address = routinfoe.attributeValue("acceptaddress");
            String accept_remark = routinfoe.attributeValue("remark");
            String opcode = routinfoe.attributeValue("opcode");
            String mailno = routinfoe.attributeValue("mailno");
            String orderid = routinfoe.attributeValue("orderid");
            sflog.setAcceptTime(DateUtil.strToDate(accept_time));
            sflog.setAcceptAddress(accept_address);
            sflog.setAcceptRemark(accept_remark);
            sflog.setOpCode(opcode);
            sflog.setExpressageId(orderid);
            sflog.setId(UUID.randomUUID().toString());
            sflog.setCreateTime(new Date());
            if(wayroutlsit.keySet().contains(mailno)){
                wayroutlsit.get(mailno).add(sflog);
            }else{
                List<WlyyPrescriptionExpressageLogDO> newsflogs = new ArrayList<>();
                newsflogs.add(sflog);
                wayroutlsit.put(mailno,newsflogs);
            }
        }
        if(!wayroutlsit.keySet().isEmpty()){
            for (String mailno:wayroutlsit.keySet()) {
                List<WlyyPrescriptionExpressageLogDO> pushSFLogs = wayroutlsit.get(mailno);
                //同一个快递单号的执行一个事务操作
                this.saveSFPushRoutInfos(mailno,pushSFLogs);
            }
        }
    }
    /**
     * 同一个快递单号的执行一个事务操作
     * @param mailno
     * @param pushSFLogs
     */
    public void saveSFPushRoutInfos(String mailno,List<WlyyPrescriptionExpressageLogDO> pushSFLogs){
        //根据快递单号获取处方配送详细信息
        WlyyPrescriptionExpressageDO sfexpress = prescriptionExpressageDao.findByPrescriptionExpressMailno(mailno);
        //根据快递单号获取本地的路由信息
        List<WlyyPrescriptionExpressageLogDO> localroutinfos = prescriptionExpressageLogDao.queryByOutpatientId(sfexpress.getOutpatientId());
        //需要增量更新到本地的路由信息集合
        List<WlyyPrescriptionExpressageLogDO> newroutinfolist = new ArrayList<>();
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事务隔离级别,开启新事务
        TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
        try {
            //用于判断新节点是否包含了"已收件"的节点
            boolean isContainEndRoutInfo = false;
            //获取本地所有路由信息的时间集
            Set<String> routAcceptTimeSet = new HashSet<>();
            for (WlyyPrescriptionExpressageLogDO log: localroutinfos) {
                routAcceptTimeSet.add(DateUtil.dateToStrLong(log.getAcceptTime()));
            }
            for (WlyyPrescriptionExpressageLogDO pushlog: pushSFLogs) {
                //判断是否有已收件的路由节点
                if("80".equals(pushlog.getOpCode())){
                    isContainEndRoutInfo = true;
                }
                if(routAcceptTimeSet.contains(DateUtil.dateToStrLong(pushlog.getAcceptTime()))){
                    continue;
                }else{
                    pushlog.setOutpatientId(sfexpress.getOutpatientId());
                    newroutinfolist.add(pushlog);
                }
            }
            //如果有新增的路由信息,则添加到数据库
            if(!newroutinfolist.isEmpty()){
                prescriptionExpressageLogDao.save(newroutinfolist);
            }
            //如果路由信息节点包含了"已收件"节点,则修改处方状态为完成,增加物流派送日志为完成
            if(isContainEndRoutInfo){
                //修改处方状态为完成
                prescriptionDao.updateStatus(sfexpress.getOutpatientId(), 100,new Date());
                //保存配送成功的日志
                WlyyOutpatientExpressageLogDO outpatiExpressLog = new WlyyOutpatientExpressageLogDO();
                outpatiExpressLog.setOutpatientId(sfexpress.getOutpatientId());
                outpatiExpressLog.setId(UUID.randomUUID().toString());
                outpatiExpressLog.setType(8);
                outpatiExpressLog.setCreateTime(new Date());
                outpatiExpressLog.setFlag(1);
                outpatiExpressLog.setStatus(100);
                outpatientExpressageLogDao.save(outpatiExpressLog);
            }
            //事务提交
            transactionManager.commit(status);
        } catch (Exception ex) {
            //报错事务回滚
            transactionManager.rollback(status);
        }
    }
    /**
     * 根据收寄地址获取快递费用
     * @param d_province 省份名称
     * @param d_city     城市名称
     * @return
     */
    public WlyyExpressagePriceDO getSFExpressPrice(String d_province, String d_city) throws Exception{
        String end_address_name = "";
        if("厦门市".equals(d_city)){
            end_address_name = "同城";
        }else{
            if("福建省".equals(d_province)){
                end_address_name = "省内";
            }else{
                end_address_name = d_province;
            }
        }
        end_address_name = "%"+end_address_name.replaceAll("省","").replaceAll("市","")+"%";
        WlyyExpressagePriceDO sfprice =  expressagePriceDao.getExprePriceByIdAndEndAdressName("shunfeng",end_address_name);
        return sfprice;
    }
    /**
     * 根据处方快递订单号判断是否下单成功
     * 如果下单成功,保存处方物流记录,保存配送日志
     * @param sfexpress_obj
     * @return
     * @throws Exception
     */
    public boolean sfOrderSearchService(WlyyPrescriptionExpressageDO sfexpress_obj)  throws Exception{
        boolean go_on = false;
        String xml = SFUtils.sfOrderSearchService(sfexpress_obj.getId(),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 = "";//顺丰运单号
                String destCode = "";//目的地区域代码
                //错误代对应的文字
                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");
                    destCode = e.attributeValue("destCode");
                }
                if(StringUtils.isBlank(mailno)){
                    logger.info("顺丰快递下订单失败:未获取到快递单号!"+sfexpress_obj.getOutpatientId());
                    return true;
                }
                if(StringUtils.isNotBlank(filter_result) && "3".equals(filter_result)){
                    logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getOutpatientId());
                    return true;
                }
                sfexpress_obj.setMailno(mailno);
                sfexpress_obj.setCityCode(destCode);
            }
            //如果成功获取到快递单号,则保存处方物流记录,保存配送日志
            //修改处方状态为配送中
            prescriptionDao.updateStatus(sfexpress_obj.getOutpatientId(),65);
            //保存处方物流记录
            prescriptionExpressageDao.save(sfexpress_obj);
            //保存配送日志
            WlyyOutpatientExpressageLogDO outpatiExpressLog = new WlyyOutpatientExpressageLogDO();
            outpatiExpressLog.setOutpatientId(sfexpress_obj.getOutpatientId());
            outpatiExpressLog.setId(UUID.randomUUID().toString());
            outpatiExpressLog.setType(8);
            outpatiExpressLog.setCreateTime(new Date());
            outpatiExpressLog.setFlag(1);
            outpatiExpressLog.setStatus(100);
            outpatientExpressageLogDao.save(outpatiExpressLog);
        }catch (Exception ex){
            logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getOutpatientId());
            //如果订单处理失败,则可以继续下单
            go_on = true;
        }
        return go_on;
    }
    public boolean sfOrderSearchServiceJustSearch(WlyyPrescriptionExpressageDO sfexpress_obj)  throws Exception{
        String xml = SFUtils.sfOrderSearchService(sfexpress_obj.getId(),sf_code);
        String re = this.SFExpressPost(xml);
        boolean reslut = false;
        try {
            //xml验证
            verificationResponXml(re,"订单处理失败!");
            Document doc = DocumentHelper.parseText(re);
            String headvalue = doc.selectSingleNode("/Response/Head").getText();
            if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
                Element root = doc.getRootElement();
                if (root.element("Body") != null)     //包含OrderResponse节点
                {
                    root = root.element("Body");
                }
                //是否能派送:1:人工确认;2:可收派;3:不可以收派
                String filter_result = "";
                String orderid = "";//业务订单号
                String mailno = "";//顺丰运单号
                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.isNotBlank(filter_result) && "3".equals(filter_result)){
                    logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getOutpatientId());
                    throw new Exception("顺丰快递下订单失败:派送地址不可派送");
                }
                if(StringUtils.isBlank(mailno)){
                    logger.info("顺丰快递下订单失败:未获取到快递单号!"+sfexpress_obj.getOutpatientId());
                    throw new Exception("顺丰快递下订单失败:未获取到快递单号!");
                }
            }
        }catch (Exception ex){
            logger.info("顺丰快递下订单失败:派送地址不可派送,处方编号:"+sfexpress_obj.getOutpatientId());
            //如果订单处理失败,则可以继续下单
            throw new Exception(ex.getMessage());
        }
        return reslut;
    }
    public String getRoutInfosSearch(WlyyPrescriptionExpressageDO sfexpress_obj)throws Exception {
        String xml = SFUtils.getRoutInfos(sfexpress_obj,sf_code);
        String re = this.SFExpressPost(xml);
        return xml;
    }
    /**
     * 1,保存快递单号增
     * 2,加处方物流记录为配送
     * 3,修改处方状态为配送配送中
     *
     * @param prescriptionExpressage
     * @throws Exception
     */
    @Transactional
    public void updatePrescriptionExpressage(WlyyPrescriptionExpressageDO prescriptionExpressage) throws Exception {
        //修改门诊处方状态为配送配送中
        prescriptionDao.updateStatus(prescriptionExpressage.getId(), 32);
        //保存处方物流记录
        prescriptionExpressageDao.save(prescriptionExpressage);
        //保存门诊配送日志
        WlyyOutpatientExpressageLogDO prescriptionLog = new WlyyOutpatientExpressageLogDO();
        prescriptionLog.setOutpatientId(prescriptionExpressage.getOutpatientId());
        // 类型: -1 失效 1HIS对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成 8物流对接
        prescriptionLog.setType(8);
        // -2 患者自己取消 -1 审核不通过 , 0 审核中, 10 审核通过/待支付 ,21支付失败  20 配药中/支付成功, 21 等待领药 ,30 配送中 ,100配送成功/已完成
        prescriptionLog.setStatus(30);
        prescriptionLog.setCreateTime(new Date());
        prescriptionLog.setFlag(1);
        outpatientExpressageLogDao.save(prescriptionLog);
    }
}

+ 342 - 12
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -10,9 +10,12 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.consult.dao.DoctorClinicRoomConsultDao;
import com.yihu.jw.hospital.consult.dao.DoctorClinicRoomConsultDao;
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.service.DoctorMappingService;
import com.yihu.jw.hospital.mapping.service.PatientMappingService;
import com.yihu.jw.hospital.mapping.service.PatientMappingService;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
@ -32,6 +35,7 @@ import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JSONObject;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -66,6 +70,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    @Autowired
    private PrescriptionExpressageLogDao prescriptionExpressageLogDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    @Autowired
    private DoctorClinicRoomConsultDao doctorClinicRoomConsultDao;
    private DoctorClinicRoomConsultDao doctorClinicRoomConsultDao;
@ -80,6 +86,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    @Autowired
    private PatientMappingService patientMappingService;
    private PatientMappingService patientMappingService;
    @Autowired
    @Autowired
    private DoctorMappingService doctorMappingService;
    @Autowired
    private OutpatientDao outpatientDao;
    private OutpatientDao outpatientDao;
    @Autowired
    @Autowired
    private ObjectMapper objectMapper;
    private ObjectMapper objectMapper;
@ -119,15 +127,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    }
    /**
    /**
     * 原处方记录列表
     * @param registerSn
     * @param patNo
     * @param admNo
     * @param demoFlag
     * @return
     * @throws Exception
     *
     */
     */
    public List<WlyyPrescriptionVO> findOriginPrescriptionList(String registerSn,String patNo,String admNo,boolean demoFlag)throws Exception{
    public List<WlyyPrescriptionVO> findOriginPrescriptionList(String registerSn,String patient,String admNo,boolean demoFlag)throws Exception{
        String patNo =patientMappingService.findHisPatNoByPatient(patient);
        return entranceService.BS16017(registerSn,patNo,admNo,null,demoFlag);
        return entranceService.BS16017(registerSn,patNo,admNo,null,demoFlag);
    }
    }
@ -185,7 +188,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                " o.origin_adm_no AS originAdmNo, " +
                " o.origin_adm_no AS originAdmNo, " +
                " o.register_no AS registerNo, " +
                " o.register_no AS registerNo, " +
                " o.origin_register_no AS originRegisterNo, " +
                " o.origin_register_no AS originRegisterNo, " +
                " o.hos" +
                " o.hospital," +
                " o.hospital_name AS hospitalName," +
                " o.win_no AS winNo," +
                " o.type," +
                " o.dept AS dept, " +
                " o.dept AS dept, " +
                " o.dept_name AS deptName, " +
                " o.dept_name AS deptName, " +
                " o.patient AS patient, " +
                " o.patient AS patient, " +
@ -227,7 +233,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param outpatientId
     * @param outpatientId
     * @return
     * @return
     */
     */
    public com.alibaba.fastjson.JSONObject findReOutpatientInfo(String outpatientId){
    public com.alibaba.fastjson.JSONObject findReOutpatientInfo(String outpatientId,String prescriptionId){
        com.alibaba.fastjson.JSONObject rs = new com.alibaba.fastjson.JSONObject();
        com.alibaba.fastjson.JSONObject rs = new com.alibaba.fastjson.JSONObject();
        //复诊信息
        //复诊信息
@ -243,9 +249,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        PatientMedicareCardDO cardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.MedicareCard.getType(),outpatientDO.getPatient(),"1");
        PatientMedicareCardDO cardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.MedicareCard.getType(),outpatientDO.getPatient(),"1");
        rs.put("ssc",cardDO);
        rs.put("ssc",cardDO);
        rs.put("age",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
        rs.put("age",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
        rs.put("address",basePatientDO.getAddress());
        rs.put("mobile",basePatientDO.getMobile());
        //获取处方信息
        //获取处方信息
        List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outpatientId);
        List<WlyyPrescriptionDO> prescriptionDOs = null;
        if(StringUtils.isNotBlank(prescriptionId)){
            prescriptionDOs = prescriptionDao.findById(prescriptionId);
        }else{
            prescriptionDOs = prescriptionDao.findByOutpatientId(outpatientId);
        }
        List<WlyyPrescriptionVO> prescriptionVOs = new ArrayList<>();
        List<WlyyPrescriptionVO> prescriptionVOs = new ArrayList<>();
        if(prescriptionDOs!=null&&prescriptionDOs.size()>0){
        if(prescriptionDOs!=null&&prescriptionDOs.size()>0){
            convertToModels(prescriptionDOs,prescriptionVOs,WlyyPrescriptionVO.class);
            convertToModels(prescriptionDOs,prescriptionVOs,WlyyPrescriptionVO.class);
@ -269,6 +283,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }else{
        }else{
            rs.put("expressage",null);
            rs.put("expressage",null);
        }
        }
        //物流配送新
        List<WlyyPrescriptionExpressageLogDO>  expressageLogDOs = prescriptionExpressageLogDao.queryByOutpatientIdOrderByCreateTimeDesc(outpatientId);
        List<WlyyPrescriptionExpressageLogVO> expressageLogVOs = new ArrayList<>();
        if(expressageLogDOs!=null&&expressageLogDOs.size()>0){
            rs.put("expressageLogs",convertToModels(expressageLogDOs,expressageLogVOs, WlyyPrescriptionExpressageLogVO.class));
        }else{
            rs.put("expressageLogs",null);
        }
        return rs;
        return rs;
    }
    }
@ -451,6 +475,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson,WlyyPrescriptionExpressageDO.class);
        WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson,WlyyPrescriptionExpressageDO.class);
        expressageDO.setDel(1);
        expressageDO.setDel(1);
        expressageDO.setCreateTime(new Date());
        expressageDO.setCreateTime(new Date());
        expressageDO.setOutpatientId(outpatient.getId());
        prescriptionExpressageDao.save(expressageDO);
        prescriptionExpressageDao.save(expressageDO);
        //3.创建候诊室
        //3.创建候诊室
@ -647,5 +672,310 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return list;
        return list;
    }
    }
//    public JSONArray find
    /**
     * 挂号
     * @return
     */
    public net.sf.json.JSONObject registerOutPatient(String outPatientId,String doctor)throws Exception{
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
        DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(doctor,outpatientDO.getHospital());
        if(doctorMappingDO==null){
            throw new RuntimeException("未找到医生映射信息");
        }
        net.sf.json.JSONObject rs = entranceService.BS10111(outpatientDO.getCardNo(),doctorMappingDO.getMappingCode(),outpatientDO.getDept(),null,outpatientDO.getWinNo(),demoFlag);
        String rsCode = (String)rs.get("@RESULT");
        if("0".equals(rsCode)){
            //存储挂号号
            String serialNo = (String)rs.get("serial_no");
            outpatientDO.setRegisterNo(serialNo);
        }
        return rs;
    }
    /**
     * 获取诊断
     * @param pyKey
     * @return
     * @throws Exception
     */
    public JSONArray getICD10(String pyKey)throws Exception{
        return entranceService.MS25001(pyKey,demoFlag);
    }
    /**
     * 获取药品
     * @return
     */
    public JSONArray getDrugDictionary(String chargeCode,String pyKey,String winNo)throws Exception{
        return entranceService.MS53001(chargeCode,pyKey,null,winNo,"0",demoFlag);
    }
    /**
     * 获取药品用法
     */
    public JSONArray getDrugUse(String pyKey)throws Exception{
        return entranceService.BS10110(null,pyKey,demoFlag);
    }
    /**
     * 医院频次
     * @return
     */
    public JSONArray getDrugFrequency()throws Exception{
        return entranceService.MS30012(demoFlag);
    }
    /**
     *
     * @param outPatientId
     * @param advice
     * @param type 1带处方,2不带处方
     * @param infoJsons
     * @param diagnosisJson
     * @return
     */
    public Map<String,Object> makeDiagnosis(String outPatientId,String advice,String type,String infoJsons,String diagnosisJson)throws Exception{
        Map<String,Object> result = new HashedMap();
        //获取门诊记录
        WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
        outpatientDO.setAdvice(advice);
        //创建处方记录
        List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outPatientId);
        WlyyPrescriptionDO prescriptionDO = null;
        if(prescriptionDOs!=null&&prescriptionDOs.size()>0){
            prescriptionDO = prescriptionDOs.get(0);
        }else{
            prescriptionDO = new WlyyPrescriptionDO();
        }
        prescriptionDO.setStatus(10);
        prescriptionDO.setPatientCode(outpatientDO.getPatient());
        prescriptionDO.setPatientName(outpatientDO.getPatientName());
        prescriptionDO.setDoctor(outpatientDO.getDoctor());
        prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
        WlyyPrescriptionDO prescription = prescriptionDao.save(prescriptionDO);
        //下诊断
        //删除之前诊断
        List<WlyyPrescriptionDiagnosisDO> ds = prescriptionDiagnosisDao.findByPrescriptionId(prescription.getId());
        prescriptionDiagnosisDao.delete(ds);
        List<WlyyPrescriptionDiagnosisDO> diagnosisDOs = (List<WlyyPrescriptionDiagnosisDO>) com.alibaba.fastjson.JSONArray.parseArray(diagnosisJson, WlyyPrescriptionDiagnosisDO.class);
        String Icd10 = "";
        String Icd10Name = "";
        for(WlyyPrescriptionDiagnosisDO diagnosisDO:diagnosisDOs){
            if("1".equals(diagnosisDO.getType())){
                Icd10 = diagnosisDO.getCode()+","+Icd10;
                Icd10Name+=diagnosisDO.getName()+","+Icd10Name;
            }else {
                Icd10+=diagnosisDO.getCode()+",";
                Icd10Name+=diagnosisDO.getName()+",";
            }
            diagnosisDO.setPrescriptionId(prescription.getId());
        }
        prescriptionDiagnosisDao.save(diagnosisDOs);
        Icd10 = Icd10.substring(0,Icd10.length()-1);
        Icd10Name = Icd10Name.substring(0,Icd10Name.length()-1);
        outpatientDO.setIcd10(Icd10);
        outpatientDO.setIcd10Name(Icd10Name);
        outpatientDao.save(outpatientDO);
        //判断是否需药品,有药品到his开处方,没有药品直接下诊断开方
        if("1".equals(type)){
            //doctor转换为his医生
            DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(),outpatientDO.getHospital());
            if(doctorMappingDO==null){
                throw new RuntimeException("未找到医生映射信息");
            }
            //删除原有药品信息
            List<WlyyPrescriptionInfoDO> oldInfos = prescriptionInfoDao.findByPrescriptionId(prescription.getId());
            if(oldInfos!=null&&oldInfos.size()>0){
                prescriptionInfoDao.delete(oldInfos);
            }
            if(StringUtils.isNotBlank(infoJsons)){
                //药品
                List<WlyyPrescriptionInfoDO> infoDOs = (List<WlyyPrescriptionInfoDO>) com.alibaba.fastjson.JSONArray.parseArray(infoJsons, WlyyPrescriptionInfoDO.class);
                //his处方拼接开方条件
                com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
                for(WlyyPrescriptionInfoDO info:infoDOs){
                    info.setDel(1);
                    info.setPrescriptionId(prescription.getId());
                    com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
                    json.put("cardNo",outpatientDO.getCardNo());
                    json.put("doctor",doctorMappingDO.getMappingCode());
                    json.put("dept",outpatientDO.getDept());
                    json.put("chargeCode",info.getDrugNo());
                    json.put("winNo",outpatientDO.getWinNo());
                    json.put("chargeFlag",1);
                    json.put("quantity",info.getQuantity());
                    json.put("serialNo",outpatientDO.getRegisterNo());
                    json.put("groupNo",info.getGroupNo());
                    json.put("serial",info.getSerial());
                    String Icd10s[] = Icd10.split(",");
                    for(int i=0;i<Icd10s.length;i++){
                        if(i==0){
                            json.put("icdCode",Icd10s[i]);
                        }else if(i==1){
                            json.put("diagTwo",Icd10s[i]);
                        }else if(i==2){
                            json.put("diagThree",Icd10s[i]);
                        }else if(i==3){
                            json.put("diagFour",Icd10s[i]);
                        }else if(i==4){
                            json.put("diagFive",Icd10s[i]);
                        }
                    }
                    json.put("dosage",info.getDosage());
                    json.put("unit",info.getUnit());
                    json.put("usage",info.getUsage());
                    json.put("supplyCode",info.getSupplyCode());
                    json.put("days ",info.getDays());
                    json.put("frequency",info.getFrequency());
                    jsonData.add(json);
                }
                //保存处方
                prescriptionInfoDao.save(infoDOs);
                //调用his开方接口
                net.sf.json.JSONObject jsonObject = entranceService.BS10112(jsonData.toJSONString(),demoFlag);
                //判断返回结果
                String rs = jsonObject.getString("@RESULT");
                if("0".equals(rs)){
                    String admNo = jsonObject.getString("@ADM_NO");
                    String realOrder = jsonObject.getString("@real_order");
                    prescription.setAdmNo(admNo);
                    prescription.setRealOrder(realOrder);
                    prescriptionDao.save(prescription);
                    outpatientDO.setAdmNo(admNo);
                    outpatientDao.save(outpatientDO);
                    result.put("code",1);
                    result.put("mes","开方提交成功");
                    return result;
                }else{
                    //开方失败
                    prescription.setStatus(13);
                    prescriptionDao.save(prescription);
                    result.put("code",-1);
                    result.put("mes","开方提交失败");
                    return result;
                }
            }else{
                result.put("code",-2);
                result.put("mes","参数错误,药品参数错误");
                return result;
            }
        }else{
            //
            outpatientDO.setStatus("2");
            outpatientDao.save(outpatientDO);
            result.put("code",1);
            result.put("mes","诊断完成");
            return result;
        }
    }
    /**
     * 订单查询
     * @param status
     * @param oneselfPickupFlg
     * @param nameKey
     * @param startTime
     * @param endTime
     * @param page
     * @param size
     * @return
     */
    public MixEnvelop findExpressageList(String status,String oneselfPickupFlg,String nameKey,String startTime,String endTime,Integer page,Integer size){
        String totalSql="SELECT " +
                " COUNT(1) AS total " +
                " FROM " +
                " wlyy_outpatient o " +
                " JOIN wlyy_prescription p ON p.outpatient_id = o.id " +
                " JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id" +
                " WHERE" +
                " 1=1";
        if(StringUtils.isNotBlank(status)){
            totalSql+=" AND p.status in("+status+")";
        }
        if(StringUtils.isNotBlank(oneselfPickupFlg)){
            totalSql+=" AND e.oneself_pickup_flg ="+oneselfPickupFlg;
        }
        if(StringUtils.isNotBlank(nameKey)){
            totalSql+=" AND e.name like '%"+nameKey+"%'";
        }
        if(StringUtils.isNotBlank(startTime)){
            totalSql+=" AND e.create_time >='"+startTime+" 00:00:00'";
        }
        if(StringUtils.isNotBlank(endTime)){
            totalSql+=" AND e.create_time <='"+endTime+" 23:59:59'";
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
        }
        String sql ="SELECT " +
                " e.create_time AS createTime, " +
                " e.`name`, " +
                " e.oneself_pickup_flg AS oneselfPickupFlg, " +
                " o.id AS outpatientId, " +
                " o.icd10_name AS icd10Name, " +
                " p.`status`, " +
                " p.id AS prescriptionId ," +
                " e.id AS expressageId" +
                " FROM " +
                " wlyy_outpatient o " +
                " JOIN wlyy_prescription p ON p.outpatient_id = o.id " +
                " JOIN wlyy_prescription_expressage e ON e.outpatient_id = o.id " +
                " WHERE" +
                " 1=1";
        if(StringUtils.isNotBlank(status)){
            sql+=" AND p.status in("+status+")";
        }
        if(StringUtils.isNotBlank(oneselfPickupFlg)){
            sql+=" AND e.oneself_pickup_flg ="+oneselfPickupFlg;
        }
        if(StringUtils.isNotBlank(nameKey)){
            sql+=" AND e.name like '%"+nameKey+"%'";
        }
        if(StringUtils.isNotBlank(startTime)){
            sql+=" AND e.create_time >='"+startTime+" 00:00:00'";
        }
        if(StringUtils.isNotBlank(endTime)){
            sql+=" AND e.create_time <='"+endTime+" 23:59:59'";
        }
        sql += " LIMIT " + (page - 1) * size + "," + size + "";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count);
    }
    public Boolean setMailno(String mailno,String expressageId){
        WlyyPrescriptionExpressageDO expressageDO =  prescriptionExpressageDao.findOne(expressageId);
        expressageDO.setMailno(mailno);
        prescriptionExpressageDao.save(expressageDO);
        return true;
    }
}
}

+ 28 - 5
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/util/SFUtils.java

@ -10,6 +10,7 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import sun.misc.BASE64Encoder;
import sun.misc.BASE64Encoder;
@ -35,11 +36,6 @@ public class SFUtils {
    @Autowired
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    private PrescriptionInfoDao prescriptionInfoDao;
    /**
    /**
     * 生成接口校验码
     * 生成接口校验码
     * 1.先把XML报文与checkword前后连接。
     * 1.先把XML报文与checkword前后连接。
@ -203,6 +199,33 @@ public class SFUtils {
    }
    }
    /**
     * 订单确认/取消
     * @param sf_code
     * @param orderid
     * @param mailno
     * @param dealtype
     * @return
     */
    public String SFOrderConfirmXml(String sf_code,String orderid ,String mailno,int dealtype){
        //head 传入接口接入码
        StringBuilder xml = new StringBuilder("<Request service='OrderConfirmService' lang='zh-cn'><Head>"+sf_code+"</Head><Body>");
        xml.append("<OrderConfirm ");
        //订单号
        if(StringUtils.isNotBlank(orderid)){
            xml.append("orderid='"+orderid+"' ");
        }
        //派送订单号,必填
        xml.append("mailno='" + mailno + "'/> ");
        xml.append("dealtype='" + dealtype + "'/>");
        xml.append("/></OrderConfirm>");
        xml.append("</Body></Request>");
        return xml.toString();
    }
    /**
    /**
     * 顺丰路由查询
     * 顺丰路由查询
     * @param sfexpress_obj
     * @param sfexpress_obj

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/DictHospitalDeptDO.java

@ -44,7 +44,6 @@ public class DictHospitalDeptDO extends IntegerIdentityEntity {
    /**
    /**
     * 6总部7金榜8夏禾
     * 6总部7金榜8夏禾
     */
     */
    @Autowired
    private String deptTypeCode;
    private String deptTypeCode;
@ -80,6 +79,7 @@ public class DictHospitalDeptDO extends IntegerIdentityEntity {
        this.createTime = createTime;
        this.createTime = createTime;
    }
    }
    @Column(name = "dept_type_code")
    public String getDeptTypeCode() {
    public String getDeptTypeCode() {
        return deptTypeCode;
        return deptTypeCode;
    }
    }

+ 0 - 13
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/consult/WlyyHospitalWaitingRoomDO.java

@ -19,11 +19,6 @@ import java.util.Date;
@Table(name = "wlyy_hospital_waiting_room")
@Table(name = "wlyy_hospital_waiting_room")
public class WlyyHospitalWaitingRoomDO extends UuidIdentityEntity {
public class WlyyHospitalWaitingRoomDO extends UuidIdentityEntity {
    /**
	 * 
	 */
	private String saasId;
    /**
    /**
	 * 诊室ID
	 * 诊室ID
	 */
	 */
@ -107,14 +102,6 @@ public class WlyyHospitalWaitingRoomDO extends UuidIdentityEntity {
    private Date createTime;
    private Date createTime;
	@Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
	@Column(name = "clinicroom_id")
	@Column(name = "clinicroom_id")
    public String getClinicroomId() {
    public String getClinicroomId() {
        return clinicroomId;
        return clinicroomId;

+ 126 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/mapping/DoctorMappingDO.java

@ -0,0 +1,126 @@
package com.yihu.jw.entity.hospital.mapping;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2019/6/10.
 */
@Entity
@Table(name = "base_doctor_mapping")
public class DoctorMappingDO extends UuidIdentityEntity {
    private String doctor;//医生code',
    private String doctor_name;//医生名称',
    private String idcard;//身份证号',
    private String orgCode;//机构code',
    private String orgName;//机构名称',
    private String mappingCode;//映射code',
    private String mappingName;//映射名称',
    private String mappingDept;//映射部门',
    private String mappingDeptName;//映射部门名称',
    private String mappingJob;//映射职称',
    private String mappingJobName;//映射职称名称',
    private Date createTime;//创建时间',
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctor_name() {
        return doctor_name;
    }
    public void setDoctor_name(String doctor_name) {
        this.doctor_name = doctor_name;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    public String getMappingCode() {
        return mappingCode;
    }
    public void setMappingCode(String mappingCode) {
        this.mappingCode = mappingCode;
    }
    public String getMappingName() {
        return mappingName;
    }
    public void setMappingName(String mappingName) {
        this.mappingName = mappingName;
    }
    public String getMappingDept() {
        return mappingDept;
    }
    public void setMappingDept(String mappingDept) {
        this.mappingDept = mappingDept;
    }
    public String getMappingDeptName() {
        return mappingDeptName;
    }
    public void setMappingDeptName(String mappingDeptName) {
        this.mappingDeptName = mappingDeptName;
    }
    public String getMappingJob() {
        return mappingJob;
    }
    public void setMappingJob(String mappingJob) {
        this.mappingJob = mappingJob;
    }
    public String getMappingJobName() {
        return mappingJobName;
    }
    public void setMappingJobName(String mappingJobName) {
        this.mappingJobName = mappingJobName;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 18 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyExpressagePriceDO.java

@ -1,6 +1,6 @@
package com.yihu.jw.entity.hospital.prescription;
package com.yihu.jw.entity.hospital.prescription;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Table;
@ -14,7 +14,14 @@ import javax.persistence.Table;
*/
*/
@Entity
@Entity
@Table(name = "wlyy_expressage_price")
@Table(name = "wlyy_expressage_price")
public class WlyyExpressagePriceDO extends UuidIdentityEntityWithOperator {
public class WlyyExpressagePriceDO extends UuidIdentityEntity {
    /**
	 * 不同类型快递code
	 */
	private String code;
    /**
    /**
	 * 起始地址名称
	 * 起始地址名称
@ -46,8 +53,16 @@ public class WlyyExpressagePriceDO extends UuidIdentityEntityWithOperator {
	 */
	 */
	private Integer continueWeightPrice;
	private Integer continueWeightPrice;
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@Column(name = "start_address_name")
    @Column(name = "start_address_name")
    public String getStartAddressName() {
    public String getStartAddressName() {
        return startAddressName;
        return startAddressName;
    }
    }

+ 15 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientDO.java

@ -114,6 +114,11 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
	 */
	 */
	private String icd10Name;
	private String icd10Name;
    /**
     * 医嘱
     */
    private String advice;
    /**
    /**
	 * 挂号时间
	 * 挂号时间
	 */
	 */
@ -285,7 +290,16 @@ public class WlyyOutpatientDO extends UuidIdentityEntity {
        this.icd10Name = icd10Name;
        this.icd10Name = icd10Name;
    }
    }
	@Column(name = "adm_date")
    @Column(name = "advice")
    public String getAdvice() {
        return advice;
    }
    public void setAdvice(String advice) {
        this.advice = advice;
    }
    @Column(name = "adm_date")
    public Date getAdmDate() {
    public Date getAdmDate() {
        return admDate;
        return admDate;
    }
    }

+ 2 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyOutpatientExpressageLogDO.java

@ -1,6 +1,7 @@
package com.yihu.jw.entity.hospital.prescription;
package com.yihu.jw.entity.hospital.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Entity;
@ -16,7 +17,7 @@ import java.util.Date;
*/
*/
@Entity
@Entity
@Table(name = "wlyy_outpatient_expressage_log")
@Table(name = "wlyy_outpatient_expressage_log")
public class WlyyOutpatientExpressageLogDO extends UuidIdentityEntityWithOperator {
public class WlyyOutpatientExpressageLogDO extends UuidIdentityEntity {
    /**
    /**
	 * 
	 * 

+ 42 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/WlyyPrescriptionInfoDO.java

@ -72,6 +72,21 @@ public class WlyyPrescriptionInfoDO extends UuidIdentityEntity {
     */
     */
    private String frequency;
    private String frequency;
    /**
     * 药品收费码
     */
    private String serial;
    /**
     * 库房号
     */
    private String groupNo;
    /**
     * 规格
     */
    private String specification;
    /**
    /**
     * 1可用 0删除
     * 1可用 0删除
     */
     */
@ -166,6 +181,33 @@ public class WlyyPrescriptionInfoDO extends UuidIdentityEntity {
        this.frequency = frequency;
        this.frequency = frequency;
    }
    }
    @Column(name = "serial")
    public String getSerial() {
        return serial;
    }
    public void setSerial(String serial) {
        this.serial = serial;
    }
    @Column(name = "group_no")
    public String getGroupNo() {
        return groupNo;
    }
    public void setGroupNo(String groupNo) {
        this.groupNo = groupNo;
    }
    @Column(name = "specification")
    public String getSpecification() {
        return specification;
    }
    public void setSpecification(String specification) {
        this.specification = specification;
    }
    @Column(name = "del")
    @Column(name = "del")
    public Integer getDel() {
    public Integer getDel() {
        return del;
        return del;

+ 37 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -75,7 +75,44 @@ public class BaseHospitalRequestMapping {
         */
         */
        public static final String findDoctorByHospitalAndDept = "/findDoctorByHospitalAndDept";
        public static final String findDoctorByHospitalAndDept = "/findDoctorByHospitalAndDept";
        /**
         * 挂号
         */
        public static final String registerOutPatient ="/registerOutPatient";
        /**
         * 获取ICD10诊断编码
         */
        public static final String getICD10 ="/getICD10";
        /**
         * 获取药品字典
         */
        public static final String getDrugDictionary ="/getDrugDictionary";
        /**
         * 获取用药方式
         */
        public static final String getDrugUse ="/getDrugUse";
        /**
         * 获取用药频次
         */
        public static final String getDrugFrequency="/getDrugFrequency";
        /**
         * 下诊断
         */
        public static final String makeDiagnosis="/makeDiagnosis";
        /**
         * 获取订单列表
         */
        public static final String findExpressageList="/findExpressageList";
        /**
         * 设置订单
         */
        public static final String setMailno="/setMailno";
        //=================end=======================================
        //=================end=======================================
        /**
        /**

+ 38 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionInfoVO.java

@ -87,6 +87,21 @@ public class WlyyPrescriptionInfoVO extends UuidIdentityVOWithOperator {
    @ApiModelProperty(value = "组数", example = "模块1")
    @ApiModelProperty(value = "组数", example = "模块1")
    private String frequency;
    private String frequency;
    /**
     * 药品收费码
     */
    @ApiModelProperty(value = "药品收费码", example = "模块1")
    private String serial;
    /**
     * 库房号
     */
    @ApiModelProperty(value = "库房号", example = "模块1")
    private String groupNo;
    @ApiModelProperty(value = "规格", example = "模块1")
    private String specification;
    /**
    /**
     * 1可用 0删除
     * 1可用 0删除
     */
     */
@ -178,4 +193,27 @@ public class WlyyPrescriptionInfoVO extends UuidIdentityVOWithOperator {
        this.del = del;
        this.del = del;
    }
    }
    public String getSerial() {
        return serial;
    }
    public void setSerial(String serial) {
        this.serial = serial;
    }
    public String getGroupNo() {
        return groupNo;
    }
    public void setGroupNo(String groupNo) {
        this.groupNo = groupNo;
    }
    public String getSpecification() {
        return specification;
    }
    public void setSpecification(String specification) {
        this.specification = specification;
    }
}
}

+ 27 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/config/bean/BeanConfig.java

@ -0,0 +1,27 @@
package com.yihu.jw.entrance.config.bean;
import com.yihu.jw.hospital.prescription.service.PrescriptionExpressageService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class BeanConfig {
    //顺丰快递接口请求地址
    @Value("${express.sf_url}")
    private String sf_url;
    //顺丰快递接口接入编码
    @Value("${express.sf_code}")
    private String sf_code;
    //顺丰快递接口checkword
    @Value("${express.sf_check_word}")
    private String sf_check_word;
    @Bean(name = "prescriptionExpressageService")
    PrescriptionExpressageService prescriptionExpressageService(){
        return new PrescriptionExpressageService(sf_url,sf_code,sf_check_word);
    }
}

+ 209 - 79
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/expressage/ExpressageEndpoint.java

@ -1,79 +1,209 @@
//package com.yihu.jw.entrance.controller.expressage;
//
//import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
//import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
//import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
//import com.yihu.jw.hospital.prescription.service.PrescriptionExpressageService;
//import com.yihu.jw.hospital.prescription.service.PrescriptionService;
//import com.yihu.jw.restmodel.web.Envelop;
//import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
//import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.util.CollectionUtils;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.net.URLDecoder;
//import java.util.List;
//
//@RestController
//@RequestMapping(value = BaseHospitalRequestMapping.Expressage.PREFIX)
//@Api(value = "门诊处方快递物流管理器", description = "门诊处方快递物流管理器", tags = {"wlyy基础服务 - 门诊处方快递物流管理服务接口"})
//public class ExpressageEndpoint extends EnvelopRestEndpoint {
//    private static Logger logger = LoggerFactory.getLogger(ExpressageEndpoint.class);
//
//    @Autowired
//    private PrescriptionExpressageService sfexpressService;
//
//    @Autowired
//    private PrescriptionExpressageService prescriptionExpressageService;
//
//    private String successxml = "<Response service='RoutePushService'><Head>OK</Head></Response>";
//    private String failedxml = "<Response service='RoutePushService'><Head>ERR</Head><ERROR code='-1'>系统发生数据错误或运行时异常</ERROR></Response>";
//
//    @RequestMapping(value="/routepushservice",method = RequestMethod.POST)
//    @ApiOperation("接受顺丰推送过来的路由信息")
//    public Envelop SFRoutePushService (
//            @ApiParam(name="content", value="入参报文") @RequestParam(value = "content",required = true) String content){
//        try {
//            content = URLDecoder.decode(content,"utf-8");
//            logger.info("顺丰路由信息推送,xml="+content);
//            sfexpressService.SFRoutePushService(content);
//            return success(successxml);
//        }catch (Exception e){
//            logger.error("接收顺丰路由信息推送失败,入参xml:"+content);
//            //日志文件中记录异常信息
//            //返回接口异常信息处理结果
//            return failed(failedxml);
//        }
//    }
//
//    @RequestMapping(value="/sfrouteserviceSearch",method = RequestMethod.GET)
//    @ApiOperation("通过门诊编号查询顺丰物流派送记录")
//    public Envelop SFRouteServiceSearch(@ApiParam(name="outpatientId", value="门诊编号") @RequestParam(value = "outpatientId",required = true) String outpatientId){
//        try {
//            List<WlyyPrescriptionExpressageDO> expressageDOList = prescriptionExpressageService.findByField("outpatientId",outpatientId);
//            if(CollectionUtils.isEmpty(expressageDOList)){
//                return failed("当前门诊没有物流信息!");
//            }
//            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
//            String result  = sfexpressService.getRoutInfosSearch(sfexpress_obj);
//            return success(result);
//        }catch (Exception e){
//            //日志文件中记录异常信息
//            //返回接口异常信息处理结果
//            return failed( "查询失败,"+e.getMessage());
//        }
//
//    }
//
//
//
//}
package com.yihu.jw.entrance.controller.expressage;
import com.yihu.jw.entity.hospital.prescription.WlyyExpressagePriceDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionExpressageService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.net.URLDecoder;
import java.util.List;
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.Expressage.PREFIX)
@Api(value = "门诊处方快递物流管理器", description = "门诊处方快递物流管理器", tags = {"wlyy基础服务 - 门诊处方快递物流管理服务接口"})
public class ExpressageEndpoint extends EnvelopRestEndpoint {
    private static Logger logger = LoggerFactory.getLogger(ExpressageEndpoint.class);
    @Autowired
    private PrescriptionExpressageService sfexpressService;
    @Autowired
    private OutpatientDao outpatientDao;
    private String successxml = "<Response service='RoutePushService'><Head>OK</Head></Response>";
    private String failedxml = "<Response service='RoutePushService'><Head>ERR</Head><ERROR code='-1'>系统发生数据错误或运行时异常</ERROR></Response>";
    @RequestMapping(value="/routepushservice",method = RequestMethod.POST)
    @ApiOperation("接受顺丰推送过来的路由信息")
    public Envelop SFRoutePushService (
            @ApiParam(name="content", value="入参报文") @RequestParam(value = "content",required = true) String content){
        try {
            content = URLDecoder.decode(content,"utf-8");
            logger.info("顺丰路由信息推送,xml="+content);
            sfexpressService.SFRoutePushService(content);
            return success(successxml);
        }catch (Exception e){
            logger.error("接收顺丰路由信息推送失败,入参xml:"+content);
            //日志文件中记录异常信息
            //返回接口异常信息处理结果
            return failed(failedxml);
        }
    }
    @RequestMapping(value="/sfrouteserviceSearch",method = RequestMethod.GET)
    @ApiOperation("通过门诊编号查询顺丰物流派送记录")
    public Envelop SFRouteServiceSearch(@ApiParam(name="outpatientId", value="门诊编号") @RequestParam(value = "outpatientId",required = true) String outpatientId){
        try {
            List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpatientId",outpatientId);
            if(CollectionUtils.isEmpty(expressageDOList)){
                return failed("当前门诊没有物流信息!");
            }
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            String result  = sfexpressService.getRoutInfosSearch(sfexpress_obj);
            return success(result);
        }catch (Exception e){
            //返回接口异常信息处理结果
            return failed( "查询失败,"+e.getMessage());
        }
    }
    @RequestMapping(value = "/getsfexpressprice", method = RequestMethod.GET)
    @ApiOperation("根据收寄地址获取快递费用")
    public Envelop SFExpressPrice(
//            @ApiParam(name = "j_city", value = "寄方地址(城市),默认为厦门", defaultValue = "厦门")
//            @RequestParam(value = "j_city", required = false) String j_city,
            @ApiParam(name = "d_province", value = "收方地址(省份)")
            @RequestParam(value = "d_province", required = false) String d_province,
            @ApiParam(name = "d_city", value = "收方地址(城市)")
            @RequestParam(value = "d_city", required = false) String d_city){
        try {
            WlyyExpressagePriceDO expreprice = sfexpressService.getSFExpressPrice(d_province,d_city);
            return success(expreprice);
        }catch (Exception e){
            //返回接口异常信息处理结果
            return failed("获取快递费用,"+e.getMessage());
        }
    }
    @RequestMapping(value = "/sforderfilterservice", method = RequestMethod.GET)
    @ApiOperation("查询派送地址是否属于顺丰的派送范围")
    public Envelop SFOrderFilterService(
            @ApiParam(name = "d_address", value = "派送地址", defaultValue = "福建省厦门市思明区软件园二期望海路55号")
            @RequestParam(value = "d_address", required = true) String d_address){
        try {
            boolean result = sfexpressService.getSFOrderFilterService(d_address);
            if(result){
                return success("地址可派送!");
            }else{
                return failed("地址不可派送!");
            }
        }catch (Exception e){
            return failed("异常:"+e.getMessage());
        }
    }
    @RequestMapping(value="/sforderservice",method = RequestMethod.POST)
    @ApiOperation("向顺丰快递下订单")
    public Envelop SFOrderService(
            @ApiParam(name="outpatientId", value="门诊编号") @RequestParam(value = "outpatientId",required = true) String outpatientId){
        try {
            List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpatientId",outpatientId);
            if(CollectionUtils.isEmpty(expressageDOList)){
                return failed("顺丰快递下单失败,未找到该处方的派送地址!");
            }else{
                WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
                //如果该处方的快递单号已生成,则说明已经下单成功,不需要重复下单,直接返回成功
                if(StringUtils.isNotBlank(sfexpress_obj.getMailno())){
                    return success("顺丰快递下单成功!");
                }else{
                    //如果该处方的快递单号未生成,则继续下单
                    //由于下单前已经判断过是否派送,这里不再重复判断----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);
                        //保存快递单号和增加处方物流记录为配送
                        sfexpressService.updatePrescriptionExpressage(sfexpress_obj);
                    }
                    return success("顺丰快递下单成功!");
                }
            }
        }catch (Exception e){
            //返回接口异常信息处理结果
            return failed(e.getMessage());
        }
    }
    @RequestMapping(value="/sfgetorderinfoservice",method = RequestMethod.GET)
    @ApiOperation("通过门诊编号查询顺丰快递单信息(不包含物流记录)")
    public Envelop SFGetOrderInfo(
            @ApiParam(name="outpatientId", value="门诊编号") @RequestParam(value = "outpatientId",required = true) String outpatientId){
        try {
            List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpaitentId",outpatientId);
            if(CollectionUtils.isEmpty(expressageDOList)){
                return failed( "查询失败,");
            }
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            return success(sfexpress_obj);
        }catch (Exception e) {
            return failed("查询失败," + e.getMessage());
        }
    }
    @RequestMapping(value="/sfordersearchservice",method = RequestMethod.GET)
    @ApiOperation("通过门诊编号查询顺丰快递是否下单成功")
    public Envelop SFOrderSearchService(
            @ApiParam(name="outpatientId", value="门诊编号") @RequestParam(value = "outpatientId",required = true) String outpatientId){
        List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpaitentId",outpatientId);
        if(CollectionUtils.isEmpty(expressageDOList)){
            return failed( "查询失败,");
        }
        try {
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            boolean go_on = sfexpressService.sfOrderSearchServiceJustSearch(sfexpress_obj);
            return success(go_on);
        }catch (Exception e) {
            return failed("查询失败," + e.getMessage());
        }
    }
    @RequestMapping(value="/sforderConfirm",method = RequestMethod.GET)
    @ApiOperation("通过快递单号取消快递")
    public Envelop sforderConfirm(
            @ApiParam(name="mailno", value="快递单号") @RequestParam(value = "mailno",required = true) String mailno){
        List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("mailno",mailno);
        if(CollectionUtils.isEmpty(expressageDOList)){
            return failed( "当前快递单号的门诊不存在,");
        }
        try {
            WlyyPrescriptionExpressageDO sfexpress_obj = expressageDOList.get(0);
            String result = sfexpressService.postOrderConfirmService(sfexpress_obj);
            return success(result);
        }catch (Exception e) {
            return failed("异常," + e.getMessage());
        }
    }
}

+ 5 - 5
svr/svr-internet-hospital-entrance/src/main/resources/application.yml

@ -1,6 +1,7 @@
#通用的配置不用区分环境变量
#通用的配置不用区分环境变量
server:
server:
  port: ${server.svr-internet-hospital-entrance-port}
#  port: ${server.svr-internet-hospital-entrance-port}
  port: 10023
spring:
spring:
  datasource:
  datasource:
@ -39,10 +40,9 @@ configDefault: # 默认配置
  saasId: xmjkzl_saasId
  saasId: xmjkzl_saasId
express:
express:
  sf_url: http://218.17.248.244:11080/bsp-oisp/sfexpressService
  #  sf_url: https://bsp-ois.sit.sf-express.com:9443/bsp-ois/sfexpressServic
  sf_code: SDDF
  sf_check_word: ttzlgGyOQu4L
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
---
---
spring:
spring:

+ 2 - 2
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/config/JpaConfig.java

@ -1,4 +1,4 @@
package com.yihu.jw.entrance.config;
package com.yihu.jw.hospital.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Configuration;
@ -8,7 +8,7 @@ import org.springframework.orm.jpa.JpaTransactionManager;
public class JpaConfig {
public class JpaConfig {
    @Bean
    @Bean
    public JpaTransactionManager jpaTransactionManager(){
    public JpaTransactionManager transactionManager(){
        return new JpaTransactionManager();
        return new JpaTransactionManager();
    }
    }
}
}

+ 72 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/file_upload/FileUploadEndpoint.java

@ -0,0 +1,72 @@
package com.yihu.jw.hospital.endpoint.file_upload;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream;
/**
 * 文件上传公共类
 */
@RestController
@RequestMapping(BaseRequestMapping.FileUpload.PREFIX)
@Api(tags = "文件上传相关操作", description = "文件上传相关操作")
public class FileUploadEndpoint extends EnvelopRestEndpoint {
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Autowired
    FileUploadService fileUploadService;
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_IMG)
    @ApiOperation(value = "文件流上传图片", notes = "文件流上传图片")
    public ObjEnvelop<UploadVO> uploadImg(@ApiParam(value = "文件", required = true)
                                       @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        // 得到文件的完整名称  xxx.txt
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = fileUploadService.uploadImg(inputStream,originalFilename,file.getSize(),fastdfs_file_url);
        return success("上传成功", uploadVO);
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM_ATTACHMENT)
    @ApiOperation(value = "文件流上传附件", notes = "文件流上传附件")
    public ObjEnvelop<UploadVO> uploadAttachment(@ApiParam(value = "文件", required = true)
                                       @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = fileUploadService.uploadAttachment(inputStream,originalFilename,file.getSize(),fastdfs_file_url);
        return success("上传成功", uploadVO);
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STREAM)
    @ApiOperation(value = "文件流上传文件", notes = "文件流上传文件")
    public ObjEnvelop<UploadVO> uploadStream(@ApiParam(value = "文件", required = true)
                                                 @RequestParam(value = "file", required = true) MultipartFile file) throws Exception{
        // 得到文件的完整名称  xxx.txt
        String originalFilename = file.getOriginalFilename();
        InputStream inputStream = file.getInputStream();
        UploadVO uploadVO = fileUploadService.uploadStream(inputStream,originalFilename,fastdfs_file_url);
        return success("上传成功", uploadVO);
    }
    @PostMapping(value = BaseRequestMapping.FileUpload.UPLOAD_STRING)
    @ApiOperation(value = "base64上传图片",notes = "base64上传图片")
    public ObjEnvelop<UploadVO> uploadImages(@ApiParam(name = "jsonData", value = "头像转化后的输入流")
                                                 @RequestBody String jsonData) throws Exception {
        UploadVO uploadVO = fileUploadService.uploadImages(jsonData,fastdfs_file_url);
        return success("上传成功", uploadVO);
    }
}

+ 78 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -127,8 +127,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findReOutpatientInfo)
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findReOutpatientInfo)
    @ApiOperation(value = "查询复诊记录,处方,居民信息,物流(单条)", notes = "查询复诊记录,处方,居民信息,物流(单条)")
    @ApiOperation(value = "查询复诊记录,处方,居民信息,物流(单条)", notes = "查询复诊记录,处方,居民信息,物流(单条)")
    public ObjEnvelop findReOutpatientInfo(@ApiParam(name = "outpatientId", value = "复诊ID")
    public ObjEnvelop findReOutpatientInfo(@ApiParam(name = "outpatientId", value = "复诊ID")
                                           @RequestParam(value = "outpatientId", required = true) String outpatientId)throws Exception{
        com.alibaba.fastjson.JSONObject obj =  prescriptionService.findReOutpatientInfo(outpatientId);
                                           @RequestParam(value = "outpatientId", required = true) String outpatientId,
                                           @ApiParam(name = "prescriptionId", value = "处方ID")
                                           @RequestParam(value = "prescriptionId", required = false) String prescriptionId)throws Exception{
        com.alibaba.fastjson.JSONObject obj =  prescriptionService.findReOutpatientInfo(outpatientId,prescriptionId);
        return success(obj);
        return success(obj);
    }
    }
@ -201,8 +203,82 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        return success(BaseHospitalRequestMapping.Prescription.api_success,prescriptionService.appointmentRevisit(outpatientJson,expressageJson));
        return success(BaseHospitalRequestMapping.Prescription.api_success,prescriptionService.appointmentRevisit(outpatientJson,expressageJson));
    }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getICD10)
    @ApiOperation(value = "获取ICD10诊断编码", notes = "获取ICD10诊断编码")
    public ListEnvelop getICD10(@ApiParam(name = "pyKey", value = "拼音关键字")
                                @RequestParam(value = "pyKey", required = false)String pyKey)throws Exception {
        return success(prescriptionService.getICD10(pyKey));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDrugDictionary)
    @ApiOperation(value = "获取药品字典", notes = "获取药品字典")
    public ListEnvelop getDrugDictionary(@ApiParam(name = "drugNo", value = "药品编码")
                                         @RequestParam(value = "drugNo", required = false)String drugNo,
                                         @ApiParam(name = "pyKey", value = "拼音关键字")
                                         @RequestParam(value = "pyKey", required = false)String pyKey,
                                         @ApiParam(name = "winNo", value = "分部编码")
                                         @RequestParam(value = "winNo", required = false)String winNo)throws Exception {
        return success(prescriptionService.getDrugDictionary(drugNo,pyKey,winNo));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDrugUse)
    @ApiOperation(value = "获取用法", notes = "获取用法")
    public ListEnvelop getDrugUse(@ApiParam(name = "pyKey", value = "拼音关键字")
                                  @RequestParam(value = "pyKey", required = false)String pyKey)throws Exception {
        return success(prescriptionService.getDrugUse(pyKey));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getDrugFrequency)
    @ApiOperation(value = "获取用药频次", notes = "获取用药频次")
    public ListEnvelop getDrugFrequency()throws Exception {
        return success(prescriptionService.getDrugFrequency());
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.makeDiagnosis)
    @ApiOperation(value = "下诊断", notes = "下诊断")
    public ObjEnvelop makeDiagnosis(@ApiParam(name = "outPatientId", value = "门诊编号")
                                            @RequestParam(value = "outPatientId", required = false)String outPatientId,
                                            @ApiParam(name = "advice", value = "医嘱")
                                            @RequestParam(value = "advice", required = false)String advice,
                                            @ApiParam(name = "type", value = "1带药品,2不带药品")
                                            @RequestParam(value = "type", required = false)String type,
                                            @ApiParam(name = "infoJsons", value = "药品json")
                                            @RequestParam(value = "infoJsons", required = false)String infoJsons,
                                            @ApiParam(name = "diagnosisJson", value = "诊断json")
                                            @RequestParam(value = "diagnosisJson", required = false)String diagnosisJson)throws Exception {
        return success(prescriptionService.makeDiagnosis(outPatientId,advice,type,infoJsons,diagnosisJson));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findExpressageList)
    @ApiOperation(value = "获取订单列表", notes = "获取订单列表")
    public MixEnvelop findExpressageList(@ApiParam(name = "status", value = "流程状态,多状态用‘,’分割")
                                         @RequestParam(value = "status", required = false)String status,
                                         @ApiParam(name = "oneselfPickupFlg", value = "是否自取 1是 0否")
                                         @RequestParam(value = "oneselfPickupFlg", required = false)String oneselfPickupFlg,
                                         @ApiParam(name = "nameKey", value = "配送员名称")
                                         @RequestParam(value = "nameKey", required = false)String nameKey,
                                         @ApiParam(name = "startTime", value = "开始时间,yyyy-MM-dd")
                                         @RequestParam(value = "startTime", required = false)String startTime,
                                         @ApiParam(name = "endTime", value = "结束时间,yyyy-MM-dd")
                                         @RequestParam(value = "endTime", required = false)String endTime,
                                         @ApiParam(name = "page", value = "第几页,1开始")
                                         @RequestParam(value = "page", required = false)Integer page,
                                         @ApiParam(name = "size", value = "每页大小")
                                         @RequestParam(value = "size", required = false)Integer size) {
        return prescriptionService.findExpressageList(status,oneselfPickupFlg,nameKey,startTime,endTime,page,size);
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.setMailno)
    @ApiOperation(value = "设置订单编号", notes = "设置订单编号")
    public ObjEnvelop setMailno(@ApiParam(name = "mailno", value = "订单号")
                                @RequestParam(value = "mailno", required = false)String mailno,
                                @ApiParam(name = "expressageId", value = "订单id")
                                @RequestParam(value = "expressageId", required = false)String expressageId) {
        return success(prescriptionService.setMailno(mailno,expressageId));
    }
    //===========
    //===========

+ 5 - 0
svr/svr-internet-hospital/src/main/resources/application.yml

@ -72,6 +72,11 @@ fast-dfs:
configDefault: # 默认配置
configDefault: # 默认配置
  saasId: xmjkzl_saasId
  saasId: xmjkzl_saasId
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
---
---
spring:
spring:
  profiles: jwdev
  profiles: jwdev