瀏覽代碼

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

wangjun 4 年之前
父節點
當前提交
e7cb726c27
共有 33 個文件被更改,包括 2235 次插入312 次删除
  1. 786 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/TnPrescriptionService.java
  2. 642 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/TnyyEntranceService.java
  3. 5 4
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/useragent/BaseUserAgent.java
  4. 128 10
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WxTemplateService.java
  5. 1 1
      gateway/ag-basic/pom.xml
  6. 14 1
      gateway/ag-basic/src/main/resources/application.yml
  7. 9 0
      gateway/ag-basic/src/main/resources/bootstrap.yml
  8. 2 2
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  9. 30 1
      server/svr-authentication/src/main/resources/application.yml
  10. 10 1
      server/svr-authentication/src/main/resources/bootstrap.yml
  11. 15 1
      server/svr-configuration/src/main/resources/bootstrap.yml
  12. 46 0
      svr/svr-base/src/main/resources/application.yml
  13. 8 0
      svr/svr-base/src/main/resources/bootstrap.yml
  14. 3 4
      svr/svr-door-serivce/sql/初始sql.sql
  15. 120 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoctorController.java
  16. 99 238
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/ConsultController.java
  17. 1 1
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorCommentController.java
  18. 1 1
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorCommentDoctorController.java
  19. 1 1
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorConclusionController.java
  20. 1 1
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorDoctorController.java
  21. 1 1
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorDoctorFeeController.java
  22. 1 1
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorFeeDetailController.java
  23. 1 1
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorPatientConfirmLogController.java
  24. 6 15
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorServiceOrderController.java
  25. 12 9
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/WlyyDoorServiceOrderService.java
  26. 7 7
      svr/svr-door-serivce/src/main/resources/application.yml
  27. 1 1
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/TnyyController.java
  28. 51 2
      svr/svr-internet-hospital-entrance/src/main/resources/application.yml
  29. 41 0
      svr/svr-internet-hospital-job/src/main/resources/application.yml
  30. 40 7
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  31. 52 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/tnyy/TnyyController.java
  32. 91 0
      svr/svr-internet-hospital/src/main/resources/application.yml
  33. 9 1
      svr/svr-internet-hospital/src/main/resources/bootstrap.yml

+ 786 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/TnPrescriptionService.java

@ -0,0 +1,786 @@
package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao;
import com.yihu.jw.hospital.drugstore.dao.BaseDrugStoreDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.mapping.service.PatientMappingService;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionExpressageDao;
import com.yihu.jw.hospital.prescription.service.entrance.TnyyEntranceService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2019/5/17.
 */
@Service
@Transactional
public class TnPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, PrescriptionDao> {
    private static final Logger logger = LoggerFactory.getLogger(TnPrescriptionService.class);
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private HospitalWaitingRoomDao hospitalWaitingRoomDao;
    @Autowired
    private PatientMappingService patientMappingService;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private PatientRegisterTimeDao patientRegisterTimeDao;
    @Autowired
    private TnyyEntranceService tnyyEntranceService;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    @Autowired
    private WechatDao wechatDao;
    @Autowired
    private BasePatientWechatDao patientWechatDao;
    @Autowired
    private BusinessOrderService businessOrderService;
    @Autowired
    private BaseDrugStoreDao baseDrugStoreDao;
    @Autowired
    private BasePatientMedicareCardDao basePatientMedicareCardDao;
    @Autowired
    private PatientMappingDao patientMappingDao;
    @Autowired
    private DictHospitalDeptDao dictHospitalDeptDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private BaseDoctorRoleDao doctorRoleDao;
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    @Autowired
    private WlyyChargeDictDao wlyyChargeDictDao;
    @Autowired
    private WlyyHospitalSysDictDao hospitalSysDictDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Value("${demo.flag}")
    private boolean demoFlag;
    @Value("${wechat.flag}")
    private boolean flag;
    @Value("${pay.flag}")
    private boolean payFlag;
    @Value("${wechat.id}")
    private String wechatId;
    @Autowired
    private YkyyService ykyyService;
    /**
     * 获取居民就诊记录接口
     * @param patient
     * @param startTime
     * @param endTime
     * @param demoFlag
     * @return
     * @throws Exception
     */
    public  List<WlyyOutpatientVO> findOutpatientList(String patient, String cardNo, String startTime, String endTime, boolean demoFlag, String ksdm)throws Exception{
        logger.info("findOutpatientList patient:"+patient);
        String patNo ="";
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        if(StringUtils.isNotBlank(cardNo)){
            BasePatientDO patientDO = basePatientDao.findByIdAndDel(patient,"1");
            /*JSONArray res = ykyyEntranceService.findPatientCodeByCardNo(cardNo,false);
            if(res !=null&&res.size()>0){
                JSONObject object = (JSONObject) res.get(0);
                if (object.get("brid")!=null){
                    patNo = object.get("brid").toString();
                }
            }*/
            JSONArray res = tnyyEntranceService.selectPatientMappingCode(patientDO.getIdcard());
            if (res!=null&&res.size()!=0){
                JSONObject object = res.getJSONObject(0);
                patNo = object.getString("BRID");
            }
            if(!StringUtils.isBlank(patNo)){
                if (patientMappingDO!=null){
                    patientMappingDO.setMappingCode(patNo);
                }else {
                    patientMappingDO = new PatientMappingDO();
                    patientMappingDO.setMappingCode(patNo);
                    patientMappingDO.setCreateTime(new Date());
                    patientMappingDO.setSource("1");
                    patientMappingDO.setPatient(patient);
                    patientMappingDO.setIdcard(patientDO.getIdcard());
                    patientMappingDO.setPatientName(patientDO.getName());
                }
                patientMappingDao.save(patientMappingDO);
            }
        }else {
            if (patientMappingDO!=null){
                patNo = patientMappingDO.getMappingCode();
            }
        }
        if(StringUtils.isBlank(patNo)){
            return null;
        }
        logger.info("findOutpatientList patNo "+patNo);
        return tnyyEntranceService.BS30025(patNo,null,startTime,endTime,demoFlag,ksdm);
    }
    /**
     *
     */
    public List<WlyyPrescriptionVO> findOriginPrescriptionList(String registerSn, String patient, String realOrder, String admNo, boolean demoFlag)throws Exception{
        String patNo =patientMappingService.findHisPatNoByPatient(patient,null);
        if(StringUtils.isBlank(patNo)){
            return null;
        }
        //BS16017(String REGISTER_SN,String realOrder,String PAT_NO,String ADM_NO,boolean demoFlag) throws Exception {
        logger.info("findOriginPrescriptionList: registerSn:"+registerSn+" patient"+patient+" patNo:"+patNo+" realOrder:"+realOrder+" admNo:"+admNo);
        return tnyyEntranceService.findMS_CF01And02(admNo,demoFlag);
    }
    /**
     * 获取居民就诊记录接口
     * @param patient
     * @return
     * @throws Exception
     */
    public  WlyyOutpatientVO findOutpatientInfo(String patient,String conNo, boolean demoFlag,String ksdm)throws Exception{
        logger.info("findOutpatientList patient:"+patient);
        String patNo =patientMappingService.findYkyyPatNoByPatient(patient,demoFlag);
        if(StringUtils.isBlank(patNo)){
            return null;
        }
        logger.info("findOutpatientList patNo "+patNo);
        List<WlyyOutpatientVO> wlyyOutpatientVOS = tnyyEntranceService.BS30025(patNo,conNo,null,null,demoFlag,ksdm);
        if (wlyyOutpatientVOS!=null&&wlyyOutpatientVOS.size()!=0){
            WlyyOutpatientVO outpatientVO = wlyyOutpatientVOS.get(0);
            BasePatientDO patientDO = basePatientDao.findById(patient);
            outpatientVO.setSex(patientDO.getSex()+"");
            outpatientVO.setBirthday(patientDO.getBirthday());
            outpatientVO.setIdcard(patientDO.getIdcard());
            return outpatientVO;
        }
       return null;
    }
    /**
     * 发起图文和视频复诊
     *
     * @param outpatientJson
     * @param expressageJson
     * @return
     * @throws Exception
     *//*
    public WlyyOutpatientDO appointmentRevisit(String outpatientJson, String expressageJson, String registerJson, String chargeType) throws Exception {
        //1.保存就诊实体
        WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson, WlyyOutpatientDO.class);
        BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient());
        BaseDoctorDO doctorDO = doctorDao.findById(outpatientDO.getDoctor());
        outpatientDO.setMjz("mz");
        outpatientDO.setStatus("0");
        outpatientDO.setCreateTime(new Date());
        outpatientDO.setIdcard(patientDO.getIdcard());
        outpatientDO.setCreateTime(new Date());
        if (!payFlag){
            outpatientDO.setPayStatus(1);
        }else {
            outpatientDO.setPayStatus(0);
        }
        if (outpatientDO.getRegisterDate() == null) {
            outpatientDO.setRegisterDate(new Date());
        }
        WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
        BusinessOrderDO businessOrderDO = new BusinessOrderDO();
        if("3".equalsIgnoreCase(outpatient.getOutpatientType())){
            businessOrderDO.setRelationCode(outpatient.getId());
            businessOrderDO.setRelationName("专家咨询费");
            businessOrderDO.setDescription("专家咨询费");
            businessOrderDO.setRematk(outpatient.getDescription());
            businessOrderDO.setPatient(outpatient.getConsumer());
            businessOrderDO.setPatientName(outpatient.getConsumerName());
            businessOrderDO.setDoctor(outpatient.getDoctor());
            if (outpatientDO.getType().equalsIgnoreCase("1")) {
                businessOrderDO.setOrderType(1);
                businessOrderDO.setOrderCategory("1");
            } else if (outpatientDO.getType().equalsIgnoreCase("2")) {
                businessOrderDO.setOrderType(17);
                businessOrderDO.setOrderCategory("1");
            }
        }else {
            businessOrderDO.setRelationCode(outpatient.getId());
            businessOrderDO.setRelationName("复诊-诊查费");
            businessOrderDO.setDescription("复诊-诊查费");
            businessOrderDO.setRematk(outpatient.getDescription());
            businessOrderDO.setPatient(outpatient.getConsumer());
            businessOrderDO.setPatientName(outpatient.getConsumerName());
            businessOrderDO.setDoctor(outpatient.getDoctor());
            if (outpatientDO.getType().equalsIgnoreCase("1")) {
                businessOrderDO.setOrderType(1);
                businessOrderDO.setOrderCategory("2");
            } else if (outpatientDO.getType().equalsIgnoreCase("2")) {
                businessOrderDO.setOrderType(3);
                businessOrderDO.setOrderCategory("3");
            }
        }
        WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("WX_MONEY");
        Double price = 0.0;
        String chargeType1 = null;
        if (doctorDO!=null){
            if (outpatient.getOutpatientType().equalsIgnoreCase("1")){
                if(outpatientDO.getType().equalsIgnoreCase("1")){
                    chargeType1 = doctorDO.getTwfzChargeType();
                }else if(outpatientDO.getType().equalsIgnoreCase("2")){
                    chargeType1 = doctorDO.getSpfzChargeType();
                }
            }else if (outpatient.getOutpatientType().equalsIgnoreCase("3")){
                if(outpatientDO.getType().equalsIgnoreCase("1")){
                    chargeType1 = doctorDO.getTwzxChargeType();
                }else if(outpatientDO.getType().equalsIgnoreCase("2")){
                    chargeType1 = doctorDO.getSpzxChargeType();
                }
            }else if (outpatient.getOutpatientType().equalsIgnoreCase("2")){
                chargeType1 = doctorDO.getXtfzChargeType();
            }
            if(doctorDO!=null){
                if (StringUtils.isNoneBlank(chargeType1)){
                    WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeType(chargeType1);
                    if (chargeDictDO!=null){
                        price = chargeDictDO.getReqFee();
                    }else {
                        price = Double.parseDouble(hospitalSysDictDO.getDictValue());
                    }
                }
            }else {
                price = Double.parseDouble(hospitalSysDictDO.getDictValue());
            }
        }else {
            if (StringUtils.isNoneBlank(chargeType)){
                WlyyChargeDictDO chargeDictDO = wlyyChargeDictDao.findByChargeType(chargeType);
                if (chargeDictDO!=null){
                    price = chargeDictDO.getReqFee();
                }else {
                    price = Double.parseDouble(hospitalSysDictDO.getDictValue());
                }
            }
        }
        *//*if (doctorDO != null && StringUtils.isNoneBlank(doctorDO.getFee())) {
            price = Double.parseDouble(doctorDO.getFee());
        }else {
            price = Double.parseDouble(hospitalSysDictDO.getDictValue());
        }*//*
        if (price == 0.0) {
            outpatientDO.setPayStatus(1);
        } else {
            outpatientDO.setPayStatus(0);
        }
        businessOrderDO.setPayPrice(price*100);
        if (!flag){
            businessOrderDO = businessOrderService.saveOrder(businessOrderDO);
        }
        WlyyPatientRegisterTimeDO registerTimeDO = null;
        try {
            //如果是视频预约咨询
            if (StringUtils.isNotBlank(registerJson)) {
                registerTimeDO = objectMapper.readValue(registerJson, WlyyPatientRegisterTimeDO.class);
                registerTimeDO.setOutpatientId(outpatient.getId());
                registerTimeDO.setCreateTime(new Date());
                patientRegisterTimeDao.save(registerTimeDO);
            }
        } catch (Exception e) {
            throw new RuntimeException("号源已经被预约,请选择其他号源");
        }
        if ("3".equalsIgnoreCase(outpatient.getOutpatientType())){
        }else {
            //2.物流信息
            WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
            expressageDO.setDel(1);
            expressageDO.setCreateTime(new Date());
            expressageDO.setOutpatientId(outpatient.getId());
            prescriptionExpressageDao.save(expressageDO);
            if (0==expressageDO.getOneselfPickupFlg()){
                if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                    String drugCode= expressageDO.getHospitalCode()==null?"5550":expressageDO.getHospitalCode();
                    expressageDO.setHospitalCode(drugCode);
                }
                System.out.println("进入物流信息");
                expressageDO.setDel(1);
                expressageDO.setCreateTime(new Date());
                expressageDO.setOutpatientId(outpatient.getId());
                prescriptionExpressageDao.save(expressageDO);
            }else {
                System.out.println("写入自取信息");
                String drugStoreCode = expressageDO.getHospitalCode();
                BaseDrugStoreDO baseDrugStoreDO = baseDrugStoreDao.findDrugByid(drugStoreCode);
                if (null!=baseDrugStoreDO){
                    expressageDO.setCityCode(baseDrugStoreDO.getCityCode());
                    expressageDO.setCityName(baseDrugStoreDO.getCityName());
                    expressageDO.setProvinceCode(baseDrugStoreDO.getProvinceCode());
                    expressageDO.setProvinceName(baseDrugStoreDO.getProvinceName());
                    expressageDO.setTownCode(baseDrugStoreDO.getTownCode());
                    expressageDO.setTownName(baseDrugStoreDO.getTownName());
                    expressageDO.setHospitalCode(baseDrugStoreDO.getDrugStoreCode());
                    expressageDO.setHospitalName(baseDrugStoreDO.getHospitalName());
                    expressageDO.setHospitalAddress(baseDrugStoreDO.getAddress());
                }
                expressageDO.setDel(1);
                expressageDO.setCreateTime(new Date());
                expressageDO.setOutpatientId(outpatient.getId());
                prescriptionExpressageDao.save(expressageDO);
            }
        }
        //3.创建候诊室
        createRoom(outpatient, chargeType);
        return outpatient;
    }
    *//**
     * 创建候诊室
     *
     * @param outpatientDO
     * @return
     *//*
    public Boolean createRoom(WlyyOutpatientDO outpatientDO, String chargeType) {
        WlyyHospitalWaitingRoomDO waitingRoom = new WlyyHospitalWaitingRoomDO();
        waitingRoom.setDept(outpatientDO.getDept());
        waitingRoom.setDeptName(outpatientDO.getDeptName());
        waitingRoom.setHospital(outpatientDO.getHospital());
        waitingRoom.setHospitalName(outpatientDO.getHospitalName());
        //是否是有协同门诊医生
        if (StringUtils.isNotBlank(outpatientDO.getGeneralDoctor())) {
            waitingRoom.setGeneralDoctor(outpatientDO.getGeneralDoctor());
            waitingRoom.setGeneralDoctorName(outpatientDO.getGeneralDoctorName());
        }
        waitingRoom.setPatientId(outpatientDO.getConsumer());
        waitingRoom.setPatientName(outpatientDO.getConsumerName());
        waitingRoom.setReservationTime(outpatientDO.getRegisterDate());
        waitingRoom.setVisitStatus(0);
        //设置复诊类型
        waitingRoom.setReservationType(StringUtils.isNotBlank(outpatientDO.getOutpatientType()) ? Integer.parseInt(outpatientDO.getOutpatientType()) : 1);
        waitingRoom.setSort(0);
        waitingRoom.setConsultType(Integer.parseInt(outpatientDO.getType()));
        if (StringUtils.isNotBlank(outpatientDO.getDoctor())) {
            waitingRoom.setDoctor(outpatientDO.getDoctor());
            waitingRoom.setDoctorName(outpatientDO.getDoctorName());
        }
        waitingRoom.setOutpatientId(outpatientDO.getId());
        waitingRoom.setCreateTime(new Date());
        if (StringUtils.isNotBlank(chargeType)) {
            waitingRoom.setChargeType(chargeType);
        }
        hospitalWaitingRoomDao.save(waitingRoom);
        return true;
    }*/
    /**
     * 获取药品
     *
     `prescription_id` varchar(50) DEFAULT NULL COMMENT '处方code 关联表wlyy_prescription code',
     `drug_no` varchar(50) DEFAULT NULL COMMENT '药品编号',
     `drug_name` varchar(50) DEFAULT NULL COMMENT '药品名称',
     `disp_deposite` varchar(50) DEFAULT NULL COMMENT '库房号',
     `dosage` varchar(50) DEFAULT NULL COMMENT '药量',
     `quantity` varchar(50) DEFAULT NULL COMMENT '数量',
     `unit` varchar(50) DEFAULT NULL COMMENT '用量单位',
     `unit_name` varchar(50) DEFAULT NULL COMMENT '用量单位中文',
     `pack_unit` varchar(50) DEFAULT NULL COMMENT '包装单位',
     `pack_unit_name` varchar(50) DEFAULT NULL COMMENT '包装单位名称',
     `usage_code` varchar(50) DEFAULT NULL COMMENT '频率code',
     `usage_name` varchar(50) DEFAULT NULL COMMENT '频次名称',
     `supply_code` varchar(50) DEFAULT NULL COMMENT '用法',
     `supply_name` varchar(50) DEFAULT NULL COMMENT '用法名称',
     `days` varchar(50) DEFAULT NULL COMMENT '天数',
     `frequency` varchar(50) DEFAULT NULL COMMENT '组号',
     `serial` varchar(50) DEFAULT NULL COMMENT '药品序列号',
     `group_no` varchar(50) DEFAULT NULL COMMENT '库房号',
     `specification` varchar(50) DEFAULT NULL COMMENT '规格(10mgx10片/盒)',
     `pack_retprice` double(10,4) DEFAULT NULL COMMENT '包装价格',
     `herbal_count` varchar(10) DEFAULT NULL COMMENT '草药数量',
     `post_count` varchar(10) DEFAULT NULL COMMENT '贴数',
     `comm` varchar(50) DEFAULT NULL COMMENT '中药用法',
     `del` int(2) DEFAULT '1' COMMENT '1可用 0删除',
     `drug_place` varchar(100) DEFAULT NULL COMMENT '药品产地',
     `pack_quantity` int(11) DEFAULT NULL COMMENT '包装数量',
     PRIMARY KEY (`id`),
     */
    public JSONArray getDrugDictionary(String chargeCode, String pyKey, String winNo, String groupNo,String oupatientId) throws Exception {
        String hisCode = "";
        if (StringUtils.isNotEmpty(oupatientId)){
            List<WlyyPrescriptionExpressageDO> wlyyPrescriptionExpressageDOS = prescriptionExpressageDao.findByOutpatientIdAndOneSelfPick(oupatientId);
            if (wlyyPrescriptionExpressageDOS.size()>0){
                hisCode = wlyyPrescriptionExpressageDOS.get(0).getHospitalCode();
            }
        }
        JSONArray mapList = new JSONArray();
        mapList = tnyyEntranceService.findTnYpxx(chargeCode, null, null, pyKey,hisCode);
        JSONArray array = new JSONArray();
        for (int i=0;i<mapList.size();i++){
            JSONObject map = mapList.getJSONObject(i);
            JSONObject object = new JSONObject();
            object.put("charge_code",map.get("YPXH"));
            object.put("drugname",map.get("YPMC"));
            object.put("specification",map.get("YPGG"));
            object.put("pack_unit_name",map.get("JLDW"));
            object.put("yfdw",map.get("YFDW"));
            object.put("pack_size",map.get("YFBZ"));
         /*   object.put("yfsx",map.get("yfsx"));//药房属性*/
            object.put("ypjl",map.get("YPJL"));//药剂量
            object.put("jldw",map.get("JLDW"));//剂量单位
            object.put("py_code",map.get("PYDM"));//拼音代码
            object.put("fyfs",map.get("FYFS"));//发药方式
            object.put("supply_code",map.get("GYFF"));//给药方式
            object.put("yfzf",map.get("YFZF"));//药房作废
            object.put("supply_name",map.get("GYFF"));//给药方式名称
/*            object.put("ybfl",map.get("ybfl"));//医保分类*/
            object.put("retprice",map.get("LSJG"));//零售价格
            object.put("kcsl",map.get("KCSL"));//库存
            object.put("ypcd",map.get("YPCD"));//产地
            object.put("zfpb",map.get("ZFPB"));//作废判别
            object.put("jbywbz",map.get("jbywbz"));//基本药物标志
            if (map.get("XTSB")!=null){
                if (map.getString("XTSB").equalsIgnoreCase("1")){
                    object.put("group_no",81);
                }else {
                    object.put("group_no",82);
                }
            }
           /* object.put("ydyp",map.get("ydyp"));//药店药品
            object.put("ypmc2",map.get("ypmc2"));//药品名称2
            object.put("t",map.get("pzwh"));//药品批文*/
            array.add(object);
        }
        return array;
    }
    /**
     * 获取药品用法
     */
    public JSONArray getDrugUse(String pyKey,boolean demoFlag) throws Exception {
        JSONArray mapList = new JSONArray();
        mapList = tnyyEntranceService.findYpyf(pyKey);
        JSONArray array = new JSONArray();
        for (int i=0;i<mapList.size();i++){
            JSONObject map = mapList.getJSONObject(i);
            JSONObject object = new JSONObject();
            object.put("supply_code",map.get("YPYF"));
            object.put("supply_name",map.get("XMMC"));
            object.put("ypyf",map.get("YPYF"));
            array.add(object);
        }
        return array;
    }
    /**
     * 医院频次
     *
     * @return
     */
    public JSONArray getDrugFrequency(boolean demoFlag) throws Exception {
        JSONArray mapList = new JSONArray();
        mapList= tnyyEntranceService.findSypc(null);
        JSONArray array = new JSONArray();
        for (int i=0;i<mapList.size();i++){
            JSONObject map = mapList.getJSONObject(i);
            JSONObject object = new JSONObject();
            object.put("FREQ_CODE",map.get("PCBM"));
            object.put("FREQ_NAME",map.get("PCMC"));
            object.put("MRSC",map.get("MRCS"));
            array.add(object);
        }
        return array;
    }
   /* *//**
     * 获取检查检验
     *  "action": "select",
     "name": "丙型肝炎RNA测定(全自动荧光定量分析)",
     "charge_unit": "项",
     "charge_amount": "150",
     "py_code": "BXGYRNAC",
     "d_code": "GGEORNAI",
     "code": "393333",
     "exec_unit": "2160000",
     "win_no": "0",
     "exec_unit_name": "检验科"
     *
     * @return
     *//*
    public JSONArray getInspectionDictionary(String pyKey, String codes, String winNo) throws Exception {
        JSONArray mapList = ykyyEntranceService.findYkJcxm(pyKey);
        JSONArray array = new JSONArray();
        for (int i=0;i<mapList.size();i++){
            JSONObject map = mapList.getJSONObject(i);
            JSONObject object = new JSONObject();
            object.put("name",map.get("xmmc"));
            object.put("code",map.get("zlxmid"));
            object.put("py_code",map.get("pydm"));
            object.put("wbdm",map.get("wbdm"));
            object.put("jxdm",map.get("jxdm"));
            object.put("qtdm",map.get("qtdm"));
            object.put("ydyzlb",map.get("ydyzlb"));
            object.put("mlbh",map.get("mlbh"));
            object.put("zxpc",map.get("zxpc"));
            object.put("jfpc",map.get("jfpc"));
            object.put("jsfs",map.get("jsfs"));
            object.put("jszq",map.get("jszq"));
            object.put("charge_unit",map.get("jsdw"));
            object.put("syxb",map.get("syxb"));
            object.put("mxsy",map.get("mxsy"));
            object.put("zysy",map.get("zysy"));//住院使用
            object.put("tjsy",map.get("tjsy"));
            object.put("zxlb",map.get("zxlb"));//执行类别
            object.put("exec_unit",map.get("zxks"));//执行科室
            object.put("zxgzid",map.get("zxgzid"));//执行规则
            object.put("ywzx",map.get("ywzx"));
            object.put("zxap",map.get("zxap"));
            object.put("cpzx",map.get("cpzx"));
            object.put("szzx",map.get("szzx"));
            object.put("jjlx",map.get("jjlx"));
            object.put("ycxzsl",map.get("ycxzsl"));
            object.put("yblx",map.get("yblx"));
            object.put("zxbz",map.get("zxbz"));
            object.put("txid",map.get("txid"));
            object.put("bgbh",map.get("bgbh"));
            object.put("czsy",map.get("czsy"));
            object.put("lzsy",map.get("lzsy"));
            object.put("lccs",map.get("lccs"));
            object.put("bwbz",map.get("bwbz"));
            object.put("yblb",map.get("yblb"));
            array.add(object);
        }
        return array;
    }*/
    /**
     * 获取卡记录
     *  "PAT_NO": "P5616242-0  ",
     "CARD_NO": "D40136791",
     "CARD_STAT": "旧卡停用",
     "OP_DATE": "2011-09-27 15:35:57",
     "CARD_TYPE": "2",
     "CARD_TYPE_NAME": "社保卡",
     "social_no": "350211198411053024"
     * @param
     * @return
     * @throws Exception
     *//*
    public JSONArray findPatientCard(String patient)throws Exception{
        BasePatientDO patientDO = basePatientDao.findById(patient);
        if (patientDO!=null){
            //JSONArray res = ykyyEntranceService.findHisCard(patientDO.getIdcard(),demoFlag);
            JSONArray rs = new JSONArray();
            *//*if(res !=null){
                for (int i =0;i<res.size();i++){
                    JSONObject object = (JSONObject) res.get(i);
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("PAT_NO",object.get("pat_no"));
                    jsonObject.put("CARD_NO",object.get("card_no"));
                    jsonObject.put("OP_DATE",object.get("op_date"));
                    jsonObject.put("CARD_STAT",object.get("card_stat"));
                    jsonObject.put("CARD_TYPE",object.get("card_type"));
                    jsonObject.put("CARD_TYPE_NAME",object.get("card_type_name"));
                    rs.add(jsonObject);
                }
            }*//*
            List<PatientMedicareCardDO> list  = basePatientMedicareCardDao.findByPatientCode(patientDO.getId());
            PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patientDO.getId());
            if (list!=null&&list.size()>0){
                for (PatientMedicareCardDO patientMedicareCardDO :list){
                    JSONObject jsonObject = new JSONObject();
                    if (null!=patientMappingDO){
                        jsonObject.put("PAT_NO",patientMappingDO.getMappingCode());
                    }else {
                        JSONArray res = ykyyEntranceService.findPatientCodeByCardNo(patientMedicareCardDO.getCode(),false);
                        patientMappingDO = new PatientMappingDO();
                        if(res !=null&&res.size()>0){
                            JSONObject object = (JSONObject) res.get(0);
                            if (object.get("pat_no")!=null){
                                jsonObject.put("PAT_NO",object.get("pat_no").toString());
                            }
                            if (object.get("brid")!=null){
                                jsonObject.put("BRID",object.get("brid").toString());
                                patientMappingDO.setMappingCode(object.get("brid").toString());
                                patientMappingDO.setPatient(patient);
                                patientMappingDO.setPatientName(patientDO.getName());
                                patientMappingDO.setIdcard(patientDO.getIdcard());
                                patientMappingDO.setSource("1");
                                patientMappingDO.setCreateTime(new Date());
                                patientMappingDao.save(patientMappingDO);
                            }
                        }
                    }
                    jsonObject.put("CARD_NO",patientMedicareCardDO.getCode());
                    jsonObject.put("OP_DATE","");
                    jsonObject.put("CARD_STAT","正常");
                    jsonObject.put("CARD_TYPE","2");
                    jsonObject.put("CARD_TYPE_NAME","社保卡");
                    rs.add(jsonObject);
                }
                return rs;
            }
        }
        return null;
    }*/
    public JSONArray synYkICD10() throws Exception {
        JSONArray jsonArray = tnyyEntranceService.synYkICD10();
        return jsonArray;
    }
    /**
     *
     * 处方下单
     *
     * @return
     * @throws Exception
     */
    public Map<String,Object> savePrescriptionOrder(String code,Double price,String tradeType,String wechatId,String appletCode) throws Exception {
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        Map<String,Object> map = new HashedMap();
        if(wxWechatDO==null){
            throw new Exception("can't find wechat:the wxId is "+wechatId);
        }
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(code);
        if (businessOrderDO!=null){
            List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
            String openId = "";
            if (StringUtils.isNotBlank(appletCode)){
                logger.info("appletCode不为空"+appletCode);
                Map<String,Object> objectMap = checkApplets(appletCode,wxWechatDO.getApplets(),wxWechatDO.getAppletsSecret());
                if (objectMap!=null){
                    openId = objectMap.get("openid").toString();
                    logger.info("appletCode"+appletCode);
                    logger.info("openid"+openId);
                }
            }else {
                logger.info("appletCode为空"+appletCode);
                List<BasePatientWechatDo> patientWechatDo = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
                if (patientWechatDo!=null&&patientWechatDo.size()!=0){
                    openId = patientWechatDo.get(0).getOpenid();
                }
            }
            String url = wxWechatDO.getBaseUrl();
            String notifyUrl =url;
            String totalFee =businessOrderDO.getPayPrice().intValue()+"";
            map = businessOrderService.unifiedorder(wechatId,businessOrderDO.getDescription(),totalFee, tradeType,openId,businessOrderDO.getOrderNo(),notifyUrl,businessOrderDO.getPatient());
        }
        return map;
    }
    public Map<String, Object> checkApplets(String code,String appid,String appSecret) throws Exception {
        HttpUtils httpUtils = new HttpUtils();
        Map<String, Object> param = new HashedMap();
        param.put("appid", appid);
        param.put("secret", appSecret);
        param.put("js_code", code);
        param.put("grant_type", "authorization_code");
        HttpResponse response = httpUtils.doGet("https://api.weixin.qq.com/sns/jscode2session", param);
        org.json.JSONObject rs = new org.json.JSONObject(response.getContent());
        Map<String, Object> res = new HashedMap();
        logger.info("checkApplets:"+response.getContent());
        if (rs.has("openid")){
            res.put("openid", rs.getString("openid"));
            res.put("sessionKey", rs.getString("session_key"));
        }
        return res;
    }
    /**
     * 获取诊断
     *
     * @param pyKey
     * @return
     * @throws Exception
     */
    public JSONArray getICD10(String pyKey,boolean demoFlag) throws Exception {
        JSONArray array = tnyyEntranceService.findIcd10(pyKey,demoFlag);
        return array;
    }
}

+ 642 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/TnyyEntranceService.java

@ -1,13 +1,48 @@
package com.yihu.jw.hospital.prescription.service.entrance;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.dict.DictIcd10DO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.hospital.dict.YkDictIcd10Dao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.restmodel.hospital.prescription.*;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
import com.yihu.utils.security.MD5;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.signature.qual.IdentifierOrArray;
import org.checkerframework.checker.units.qual.A;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static com.yihu.jw.util.common.PwdUtil.randomString;
/**
 * Created by wangzhinan on 2020/12/24.
 */
@ -15,8 +50,615 @@ import java.util.Map;
@Transactional
public class TnyyEntranceService {
    private static Logger logger = LoggerFactory.getLogger(TnyyEntranceService.class);
    private final static String url="http://10.9.1.247:10023/ykyy/createSQLQuery";
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private DictHospitalDeptDao hospitalDeptDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private BaseDoctorRoleDao baseDoctorRoleDao;
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    @Autowired
    private YkDictIcd10Dao ykDictIcd10Dao;
    private final static String orgCode ="350211A5004";
    @Autowired
    private PatientMappingDao patientMappingDao;
    //同步科室
    public String updateTnyyDept() throws Exception {
        String sql = "select KSDM,KSMC,PYDM,PLSX,JGBM from GY_KSDM ";
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("updateTnyyDept:"+sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if(status!=null&&status == 200){
            JSONArray array = rs.getJSONArray("detailModelList");
            logger.info("dept size:"+array.size());
            for (int i=0;i<array.size();i++){
                JSONObject deptObj = array.getJSONObject(i);
                String ksdm = deptObj.getString("KSDM");
                String jgbm = deptObj.getString("JGBM");
                String ksmc = deptObj.getString("KSMC");
                List<DictHospitalDeptDO> list = hospitalDeptDao.findByOrgCodeAndCode(jgbm,ksdm);
                if (list!=null&&list.size()!=0){
                    DictHospitalDeptDO dictHospitalDeptDO = list.get(0);
                    dictHospitalDeptDO.setCode(ksdm);
                    dictHospitalDeptDO.setName(ksmc);
                    dictHospitalDeptDO.setOrgCode(jgbm);
                    hospitalDeptDao.save(dictHospitalDeptDO);
                }else {
                    //新增科室
                    DictHospitalDeptDO dictHospitalDeptDO = new DictHospitalDeptDO();
                    dictHospitalDeptDO.setCode(ksdm);
                    dictHospitalDeptDO.setName(ksmc);
                    dictHospitalDeptDO.setOrgCode(jgbm);
                    dictHospitalDeptDO.setCreateTime(new Date());
                    dictHospitalDeptDO.setConsultDeptFlag("1");
                    hospitalDeptDao.save(dictHospitalDeptDO);
                }
            }
        }
        return "success";
    }
    //更新泰安医生信息
    public String updateTnyyDoctor(String idCard)throws Exception{
        String sql ="select sfzh,LXDH,YGDM,KSDM,YGXM,YGXB,CSNY,YSJJ from GY_YGDM where ZFPB=1 and sfzh is not null ";
        if (StringUtils.isNoneBlank(idCard)){
            sql +=" and sfzh ='"+idCard+"' ";
        }
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if(status!=null&&status == 200){
            JSONArray array = rs.getJSONArray("detailModelList");
            logger.info("doctor size:"+array.size());
            if(array!=null&&array.size()>0) {
                for (int i = 0; i < array.size(); i++) {
                    JSONObject doctorJson = array.getJSONObject(i);
                    String idcard = doctorJson.getString("sfzh");
                    //过滤身份证脏数据
                    if(idcard.length()>=15){
                        List<BaseDoctorDO> doctorDOs = baseDoctorDao.findByIdcard(idcard);
                        if(doctorDOs!=null&&doctorDOs.size()>0){
                            BaseDoctorDO doctor = doctorDOs.get(0);
                            String salt = randomString(5);
                            String pw = idcard.substring(idcard.length() - 6);
                            doctor.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                            doctor.setSalt(salt);
                            /*doctor.setJobTitleCode(doctorJson.getString("jobtitlecode"));
                            doctor.setJobTitleName(doctorJson.getString("jobTitleName"));*/
//                            doctor.setExpertise(doctorJson.getString("expertise"));
//                            doctor.setIntroduce(doctorJson.getString("introduce"));
//                            doctor.setMobile(doctorJson.getString("mobile"));
                            BaseDoctorDO temp = baseDoctorDao.save(doctor);
                            List<BaseDoctorHospitalDO> hospitalDOs = baseDoctorHospitalDao.findByOrgCodeAndDeptCodeAndDoctorCode(orgCode,doctorJson.getString("KSDM"),doctor.getId());
                            if(hospitalDOs!=null&&hospitalDOs.size()>0){
                                //机构信息部门信息
                                BaseDoctorHospitalDO hospitalDO = hospitalDOs.get(0);
                                hospitalDO.setDeptCode(doctorJson.getString("KSDM"));
                                hospitalDO.setDel("1");
                                baseDoctorHospitalDao.save(hospitalDO);
                            }
                        }else{
                            //新增医生
                            BaseDoctorDO doctor = new BaseDoctorDO();
                            doctor.setName(doctorJson.getString("YGXM"));
                            doctor.setIdcard(idcard);
                            doctor.setSex(Integer.parseInt(IdCardUtil.getSexForIdcard_new(idcard)));
                            doctor.setBirthday(IdCardUtil.getBirthdayForIdcard(idcard));
                            doctor.setProvinceCode("350000");
                            doctor.setProvinceName("福建省");
                            doctor.setTownCode("350203");
                            doctor.setTownName("思明区");
                            doctor.setCityCode("350200");
                            doctor.setCityName("厦门市");
//                            doctor.setExpertise(doctorJson.getString("expertise"));
//                            doctor.setIntroduce(doctorJson.getString("introduce"));
//                            doctor.setMobile(doctorJson.getString("mobile"));
                            //认证信息设置
                            String salt = randomString(5);
                            String pw = idcard.substring(idcard.length() - 6);
                            doctor.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
                            doctor.setSalt(salt);
                            doctor.setDel("1");
                            doctor.setEnabled(1);
                            doctor.setLocked(0);
                            doctor.setCreateTime(new Date());
                    /*        doctor.setJobTitleCode(doctorJson.getString("jobtitlecode"));
                            doctor.setJobTitleName(doctorJson.getString("jobTitleName"));*/
                            BaseDoctorDO temp = baseDoctorDao.save(doctor);
                            //机构信息部门信息
                            BaseDoctorHospitalDO hospitalDO = new BaseDoctorHospitalDO();
                            hospitalDO.setDoctorCode(temp.getId());
                            hospitalDO.setOrgCode(orgCode);
                            hospitalDO.setOrgName("泰安中医院");
                            hospitalDO.setDeptCode(doctorJson.getString("KSDM"));
                            hospitalDO.setDel("1");
                            baseDoctorHospitalDao.save(hospitalDO);
                            //保存角色
                            BaseDoctorRoleDO role = new BaseDoctorRoleDO();
                            role.setDoctorCode(temp.getId());
                            role.setRoleCode("specialist");
                            baseDoctorRoleDao.save(role);
                            //保存mapping
                            DoctorMappingDO mappingDO = new DoctorMappingDO();
                            mappingDO.setIdcard(idcard);
                            mappingDO.setDoctor(temp.getId());
                            mappingDO.setDoctorName(temp.getName());
                            mappingDO.setOrgCode(orgCode);
                            mappingDO.setOrgName("泰安中医院");
                            mappingDO.setMappingCode(doctorJson.getString("YGDM"));
                            mappingDO.setMappingName(temp.getName());
                            mappingDO.setCreateTime(new Date());
                            doctorMappingDao.save(mappingDO);
                        }
                    }
                }
            }
        }
        return "success";
    }
    public JSONArray selectPatientMappingCode(String idcard) throws Exception {
        String sql = "SELECT a.BRID,a.BRXM from MS_BRDA a WHERE a.SFZH = '"+idcard+"' ";
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("selectPatientMappingCode:"+sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        JSONArray array = new JSONArray();
        if(status!=null&&status == 200){
            array = rs.getJSONArray("detailModelList");
            logger.info("patient size:"+array.size());
        }
        return array;
    }
    /**
     * 查询药品信息
     * @param ypdm
     * @param ypmc
     * @param kusl
     * @return
     */
    public JSONArray findTnYpxx(String ypdm,String ypmc,String kusl,String pydm ,String hisCode) throws Exception {
        String sql ="SELECT yp.YPXH,yp.XTSB,yp.YPMC,yp.YPGG,yp.YFGG,yp.BFGG,yp.YPSX,yp.TSYP,yp.YPDW,yp.ZXDW,yp.ZXBZ,yp.YFBZ,yp.YFDW,yp.BFBZ," +
                "yp.BFDW,yp.ZFPB,yp.YLXZ,yp.FYFS,yp.PYDM,yp.YPBH,yp.MESS,yp.GYFF,yp.TYPE,yp.YPDM,yp.YPJL,yp.JLDW,yp.YKZF,yp.YFZF,yp.ZXCD,yp.YCYL," +
                "kc.YPCD,kc.LSJG,kc.KCSL  FROM  YK_TYPK yp,YK_KCMX kc where 1=1 and kc.YPXH=yp.YPXH ";
        if (StringUtils.isNoneBlank(ypdm)){
            sql+=" and lower(YPDM) like '%"+ypdm.toLowerCase()+"%' ";
        }
        if (StringUtils.isNoneBlank(ypmc)){
            sql+=" and lower(YPMC) like '%"+ypmc.toLowerCase()+"%' ";
        }
        if (StringUtils.isNoneBlank(pydm)){
            sql+=" and lower(PYDM) like '%"+pydm.toLowerCase()+"%' ";
        }
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("ypxx:"+sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            array = rs.getJSONArray("detailModelList");
        }
       /* List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);*/
        return array;
    }
    /**
     * 获取频次
     * @return
     */
    public JSONArray findSypc(String pcbm) throws Exception {
        String sql = "select s.PCBM,s.PCMC,s.MRCS,s.MZCS,s.YFBM,s.JGRS  from GY_SYPC s where 1=1 ";
        if (StringUtils.isNoneBlank(pcbm)){
            sql+=" and lower(s.pcbm)='"+pcbm.toLowerCase()+"' ";
        }
        /*List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
        return list;*/
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("sypc:"+sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            array = rs.getJSONArray("detailModelList");
        }
        return array;
    }
    /**
     * 获取用法
     * @return
     */
    public JSONArray findYpyf(String pydm) throws Exception {
        String sql = "select y.YPYF,y.PYDM,y.XMMC,y.XMLB,y.FYXH from ZY_YPYF y where 1=1  and y.PYDM is not null";
        if (StringUtils.isNoneBlank(pydm)){
            sql+=" and lower(y.PYDM)='"+pydm.toLowerCase()+"' ";
        }
        /*List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
        return list;*/
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("ypyf:"+sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            array = rs.getJSONArray("detailModelList");
        }
        return array;
    }
    /**
     * 获取icd10
     * @return
     * @throws Exception
     */
    public JSONArray synYkICD10() throws Exception {
        String sql = "select i.JBXH,i.JBMC,i.PYDM, from GY_JBBM i";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("ICD10:"+sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            array = rs.getJSONArray("detailModelList");
            ykDictIcd10Dao.deleteAll();
            for (int i=0;i<array.size();i++){
                JSONObject object = array.getJSONObject(i);
                DictIcd10DO dictIcd10DO = new DictIcd10DO();
                dictIcd10DO.setCode(object.getString("JBXH"));
                dictIcd10DO.setName(object.getString("JBMC"));
                dictIcd10DO.setDescription(object.getString("PYDM"));
                ykDictIcd10Dao.save(dictIcd10DO);
            }
        }
        return array;
    }
    /**
     * 获取诊断
     * @param pyCode
     * @param demoFlag
     * @return
     * @throws Exception
     */
    public JSONArray findIcd10(String pyCode,boolean demoFlag) throws Exception {
        String sql = "select i.JBXH as code ,i.JBMC as name,i.PYDM as pydm from GY_JBBM i ";
        JSONArray array = new JSONArray();
        if (StringUtils.isNoneBlank(pyCode)){
            sql +="  where lower(i.PYDM) like '%"+pyCode.toLowerCase()+"%'";
        }
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("ICD10:"+sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            array = rs.getJSONArray("detailModelList");
        }
        return array;
    }
    /**
     * HIS就诊患者历史查询
     * @throws Exception
     */
    public JSONArray findV_ZKSG_HZCX_HIS(String brid,String conNo,String startTime,String endTime,String ksdm) throws Exception{
        String sql = "SELECT h.JZXH,h.GHXH,h.BRBH,h.KSDM,h.YSDM,h.ZYZD,h.KSSJ,h.JSSJ,h.JZZT,h.FZRQ,h.GHFZ,ks.KSMC,yg.YGXM  from YS_MZ_JZLS h,GY_KSDM ks,GY_YGDM yg WHERE yg.YGDM=h.YSDM and ks.KSDM=h.KSDM and  h.BRBH = "+brid+" ";
        if(!StringUtil.isBlank(conNo)){
            sql += " and h.JZXH = " + conNo;
        }
        if(!StringUtil.isBlank(startTime)){
            sql += " and  h.KSSJ  >= '"+startTime+"' ";
        }
        if(!StringUtil.isBlank(endTime)){
            sql += " and h.KSSJ  <= '"+endTime+"' ";
        }if(!StringUtil.isBlank(ksdm)){
            sql += " and h.KSDM = " + ksdm;
        }
        sql += " order by h.KSSJ desc";
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if(status!=null&&status == 200){
            return rs.getJSONArray("detailModelList");
        }
        return new JSONArray();
    }
    /**
     * 患者门诊就诊记录
     * 使用时间查询的话,很可能会超时。时间没有索引,所以超时时间需要加长
     *
     * @param PAT_NO    居民唯一号 一个居民在该医院只有一个号,该接口必须输入的参数
     * @param conNo     就诊次数,使用居民唯一号+就诊次数获取唯一一条就诊记录
     *                  // *  @param admNo 就诊唯一号 每一次就诊都有一个唯一号:居民号+就诊次数,查询确定的一条就诊记录时需要传,否则传null
     *                  // *  @param registerSn 挂号流水号,查询确定的一条就诊记录时需要传,否则传null
     * @param startTime 开始时间 (查询一段时间内就诊记录开始时间,查询就诊记录列表时需要传,否则传null)
     * @param endTime   结束时间 (查询一段时间内就诊记录结束时间,查询就诊记录列表时需要传,否则传null)
     * @return
     * @throws Exception
     */
    public List<WlyyOutpatientVO> BS30025(String PAT_NO, String conNo, String startTime, String endTime, boolean demoFlag, String ksdm) throws Exception {
        String fid = "BS30025";
        logger.info("EntranceService " + fid + " PAT_NO :" + PAT_NO + " conNo:" + conNo + " startTime:" + startTime + " endTime:" + endTime);
        String resp = "";
        String orgCode = "350211A5004";
        String orgName = "厦门大学附属厦门眼科中心";
        //居民id转化
        PatientMappingDO patientMappingDO = patientMappingDao.findByMappingCodeAndSource(PAT_NO,"1");
        if(patientMappingDO == null){
            return null;
        }
//KSSJ,h.BRID,h.BRXM,h.SJHM,h.JZKH,h.SFZH,h.BRXZ,h.YSDM,h.KDYS" +
//                ",h.KSDM,h.KSMC,h.ZDMC,h.JZXH
        JSONArray jsonArray = new JSONArray();
        jsonArray = findV_ZKSG_HZCX_HIS(patientMappingDO.getMappingCode(),conNo,startTime,endTime,ksdm);
        //查找眼科数据
        if (jsonArray.size() == 0) {
            return null;
        }
        List<WlyyOutpatientVO> wlyyOutpatientVOS = new ArrayList<>();
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jsonObjectMgsInfo = jsonArray.getJSONObject(i);
            if (null != jsonObjectMgsInfo) {
                WlyyOutpatientVO wlyyOutpatientVO = new WlyyOutpatientVO();
                wlyyOutpatientVO.setHospital(orgCode);
                wlyyOutpatientVO.setHospitalName(orgName);
                wlyyOutpatientVO.setWinNo("6");
                wlyyOutpatientVO.setAdmNo(null == jsonObjectMgsInfo.get("JZXH") ? "" : jsonObjectMgsInfo.get("JZXH") + "");
                //wlyyOutpatientVO.setRegisterNo(null == jsonObjectMgsInfo.get("REGISTER_SN") ? "" : jsonObjectMgsInfo.get("REGISTER_SN") + "");
                wlyyOutpatientVO.setDept(null == jsonObjectMgsInfo.get("KSDM") ? "" : jsonObjectMgsInfo.get("KSDM") + "");
                wlyyOutpatientVO.setDeptName(null == jsonObjectMgsInfo.get("KSMC") ? "" : jsonObjectMgsInfo.get("KSMC") + "");
                wlyyOutpatientVO.setPatient(patientMappingDO.getPatient());
                wlyyOutpatientVO.setPatientName(patientMappingDO.getPatientName());
                wlyyOutpatientVO.setConNo(null == jsonObjectMgsInfo.get("JZXH") ? "" : jsonObjectMgsInfo.get("JZXH") + "");
                String doctor = null == jsonObjectMgsInfo.get("YSDM") ? "" : jsonObjectMgsInfo.get("YSDM") + "";
                //转化医生
                String mappingCode = doctor.trim();
                String doctorCode = "";
                if (StringUtils.isNotBlank(mappingCode)) {
                    List<DoctorMappingDO> mappingDOs = doctorMappingDao.findByOrgCodeAndMappingCode(orgCode, mappingCode);
                    if (mappingDOs != null && mappingDOs.size() > 0) {
                        doctorCode = mappingDOs.get(0).getDoctor();
                    }
                }
                wlyyOutpatientVO.setDoctor(doctorCode);
                wlyyOutpatientVO.setDoctorName(null == jsonObjectMgsInfo.get("YGXM") ? "" : jsonObjectMgsInfo.get("YGXM") + "");
//                wlyyOutpatientVO.setMjz(null == jsonObjectMgsInfo.get("MJZ") ? "" : jsonObjectMgsInfo.get("MJZ") + "");
                String icdName = null == jsonObjectMgsInfo.get("ZYZD") ? "" : jsonObjectMgsInfo.get("ZYZD") + "";
//                wlyyOutpatientVO.setIcd10(icdcodes);
                wlyyOutpatientVO.setIcd10Name(icdName);
                String admDate = null == jsonObjectMgsInfo.get("KSSJ") ? "" : jsonObjectMgsInfo.get("KSSJ") + "";
                String conDate = null == jsonObjectMgsInfo.get("KSSJ") ? "" : jsonObjectMgsInfo.get("KSSJ") + "";
                wlyyOutpatientVO.setAdmDate(DateUtil.strToDate(admDate, DateUtil.YYYY_MM_DD_HH_MM_SS_));
                wlyyOutpatientVO.setConDate(DateUtil.strToDate(conDate, DateUtil.YYYY_MM_DD_HH_MM_SS_));
                List<WlyyInspectionVO> inspectionVOList = new ArrayList<>();
                /*JSONArray array = findV_ZKSG_JCCX(PAT_NO,wlyyOutpatientVO.getAdmNo(),demoFlag);
                for (int j=0;j<array.size();j++){
                    JSONObject object = array.getJSONObject(j);
                    String ksdm1 = object.getString("ksdm");//科室代码
                    String fymc = object.getString("fymc");//费用名称
                    String fydj = object.getString("fydj");//单价
                    String fysl = object.getString("fysl");//数量
                    String fyhj = object.getString("fyhj");//金额
                    String jzxh = object.getString("jzxh");//就诊序号
                    String zxks = object.getString("zxks");//执行科室
                    WlyyInspectionVO wlyyInspectionVO = new WlyyInspectionVO();
                    wlyyInspectionVO.setName(fymc);
                    wlyyInspectionVO.setDeptName(zxks);
                    wlyyInspectionVO.setDept(ksdm1);
                    wlyyInspectionVO.setQuantity(Integer.parseInt(fysl));
                    inspectionVOList.add(wlyyInspectionVO);
                }
                wlyyOutpatientVO.setInspectionVOS(inspectionVOList);*/
                wlyyOutpatientVOS.add(wlyyOutpatientVO);
            }
        }
        return wlyyOutpatientVOS;
    }
    /**
     * HIS处方记录
     * @throws Exception
     */
    public List<WlyyPrescriptionVO> findMS_CF01And02(String admNo, boolean demoFlag) throws Exception{
        List<WlyyPrescriptionVO> wlyyPrescriptionVOList = new ArrayList<>();
        //处方数据
        String msd01 = "SELECT d.CFLX,d.BRID,d.BRXM,d.FPHM,d.MZXH,d.JZKH,d.JZXH,d.CFSB,d.CFHM,d.KSDM  FROM MS_CF01 d WHERE d.JZXH = '"+admNo+"'";
        JSONObject rs = new JSONObject();
        String content="";
        Map<String,Object> params = new HashedMap();
        params.put("sql",msd01);
        HttpResponse response = HttpUtils.doGet(url,params);
        content = response.getContent();
        logger.info("response:"+content);
        rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if(status!=null&&status == 200){
            JSONArray array =rs.getJSONArray("detailModelList");
            logger.info("precription:"+rs.getJSONArray("detailModelList"));
            for (int j=0;j<array.size();j++){
                WlyyPrescriptionVO wlyyPrescriptionVO = new WlyyPrescriptionVO();
                JSONObject object = array.getJSONObject(j);
                wlyyPrescriptionVO.setType(object.getInteger("CFLX"));/*
                wlyyPrescriptionVO.setOrderNo(object.getString("scddh"));*//*
                wlyyPrescriptionVO.setPayStatus(object.getInteger("fkzt"));*/
                wlyyPrescriptionVO.setPatientName(object.getString("BRXM"));
                String brid = object.getString("BRID");
                if (StringUtils.isNoneBlank(brid)){
                    PatientMappingDO mappingDO = patientMappingDao.findByMappingCode(brid);
                    if (mappingDO!=null){
                        wlyyPrescriptionVO.setPatientCode(mappingDO.getPatient());
                    }
                }
                wlyyPrescriptionVO.setSsc(object.getString("JZKH"));/*
                wlyyPrescriptionVO.setOrderId(object.getString("guid"));*/
                wlyyPrescriptionVO.setAdmNo(object.getString("JZXH"));
                wlyyPrescriptionVO.setRealOrder(object.getString("CFSB"));
                wlyyPrescriptionVO.setDept(object.getString("KSDM"));
                wlyyPrescriptionVO.setOriginRealOrder(object.getString("CFHM"));
                String msd02 = "SELECT d.YPXH,d.YPCD,d.YPSL,d.YPDJ,d.YFDW,d.YFDW,d.MRCS,d.YFBZ,d.YPYF,d.YYTS,d.SBXH,d.YFGG  FROM V_MS_DD02 d WHERE d.CFSB = '"+wlyyPrescriptionVO.getRealOrder()+"'";
                JSONObject rs1 =new JSONObject();
                Map<String,Object> params1 = new HashedMap();
                params1.put("sql",msd02);
                HttpResponse response1 = HttpUtils.doGet(url,params1);
                String content1 = response1.getContent();
                logger.info("response:"+content);
                rs1 = JSON.parseObject(content1);
                Integer status1 = rs1.getInteger("status");
                List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS = new ArrayList<>();
                if(status1!=null&&status1 == 200){
                    JSONArray array1 =  rs1.getJSONArray("detailModelList");
                    logger.info("info"+rs1.getJSONArray("detailModelList"));
                    for (int i =0;i<array1.size();i++){
                        JSONObject object1 = array1.getJSONObject(i);
                        WlyyPrescriptionInfoVO prescriptionInfoVO = new WlyyPrescriptionInfoVO();
                        String sql = "SELECT YPXH ,YPMC  from YK_TYPK WHERE YPXH='"+object1.getString("YPXH")+"' ";
                        JSONObject rs4 = new JSONObject();
                        Map<String,Object> params4 = new HashedMap();
                        params4.put("sql",sql);
                        HttpResponse response4 = HttpUtils.doGet(url,params4);
                        String content4 = response4.getContent();
                        logger.info("response:"+content4);
                        rs4 = JSON.parseObject(content4);
                        Integer status4 = rs4.getInteger("status");
                        if(status4!=null&&status4 == 200){
                            JSONArray array4 =  rs4.getJSONArray("detailModelList");
                            logger.info("info"+rs4.getJSONArray("detailModelList"));
                            if (array4!=null&&array4.size()!=0){
                                JSONObject jsonObject = array4.getJSONObject(0);
                                prescriptionInfoVO.setDrugName(jsonObject.getString("YPMC"));
                            }
                        }
                        prescriptionInfoVO.setDrugNo(object1.getString("YPXH"));
                        prescriptionInfoVO.setDrugPlace(object1.getString("YPCD"));
                        prescriptionInfoVO.setQuantity(object1.getString("YPSL"));
                        prescriptionInfoVO.setPackRetprice(object1.getDouble("YPDJ"));
                        prescriptionInfoVO.setPackUnitName(object1.getString("YFDW"));
                        prescriptionInfoVO.setUnitName(object1.getString("YFDW"));
                        prescriptionInfoVO.setDosage(object1.getString("MRCS"));
                        prescriptionInfoVO.setPackQuantity(object1.getInteger("YFBZ"));
                        prescriptionInfoVO.setUsageCode(object1.getString("YPYF"));
                        prescriptionInfoVO.setDays(object1.getString("YYTS"));
                     /*   prescriptionInfoVO.setYpyf(object1.getInteger("ypyf"));*/
                        prescriptionInfoVO.setHisCode(object1.getInteger("SBXH"));
                        prescriptionInfoVO.setSpecification(object1.getString("YFGG"));
                        wlyyPrescriptionInfoVOS.add(prescriptionInfoVO);
                    }
                }
                wlyyPrescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOS);
                List<WlyyPrescriptionDiagnosisVO> diagnosisVOS = new ArrayList<>();
                String mz = "SELECT ICD AS \"icd\",MSZD AS \"mszd\",JZXH AS \"jzxh\" FROM v_hlwys_mz_jbzd WHERE jzxh = '"+admNo+"'";
                JSONObject rs2 =new JSONObject();
                Map<String,Object> params2 = new HashedMap();
                params2.put("sql",mz);
                HttpResponse response2 = HttpUtils.doGet(url,params2);
                String content2 = response2.getContent();
                logger.info("response:"+content2);
                rs2 = JSON.parseObject(content2);
                Integer status2 = rs2.getInteger("status");
                if(status2!=null&&status2 == 200){
                    JSONArray array2 = rs2.getJSONArray("detailModelList");
                    for (int i=0;i<array2.size();i++){
                        JSONObject object2 = array2.getJSONObject(i);
                        WlyyPrescriptionDiagnosisVO diagnosisVO = new WlyyPrescriptionDiagnosisVO();
                        diagnosisVO.setCode(object2.getString("icd"));
                        diagnosisVO.setName(object2.getString("mszd"));
                        diagnosisVOS.add(diagnosisVO);
                    }
                }
                wlyyPrescriptionVO.setDiagnosisVOs(diagnosisVOS);
                wlyyPrescriptionVOList.add(wlyyPrescriptionVO);
            }
        }
        return wlyyPrescriptionVOList;
    }
    public List<Map<String,Object>> queryBySql(String sql){
        List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);

+ 5 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/useragent/BaseUserAgent.java

@ -32,7 +32,7 @@ public class BaseUserAgent {
            return json.getString("uid");
        } catch (Exception e) {
            return null;
            return e.getMessage();
        }
    }
@ -52,7 +52,7 @@ public class BaseUserAgent {
            String uname = java.net.URLDecoder.decode(info,"UTF-8");
            return uname;
        } catch (Exception e) {
            return null;
            return e.getMessage();
        }
    }
@ -72,7 +72,7 @@ public class BaseUserAgent {
            return json.getString("roleid");
        } catch (Exception e) {
            return null;
            return e.getMessage();
        }
    }
@ -83,8 +83,9 @@ public class BaseUserAgent {
            JSONObject user = JSON.parseObject(userAgent);
            return user;
        }catch (Exception e){
            return null;
            e.printStackTrace();
        }
        return null;
    }
}

+ 128 - 10
business/base-service/src/main/java/com/yihu/jw/wechat/service/WxTemplateService.java

@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.*;
@ -25,18 +24,20 @@ import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.utils.CheckSumBuilder;
import com.yihu.jw.utils.RSAEncrypt;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WxPushLogDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.dao.WxTemplateDao;
import com.yihu.jw.wechat.dao.*;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -94,11 +95,15 @@ public class WxTemplateService {
    @Autowired
    private ConsultTeamOrderDao consultTeamOrderDao;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private PrescriptionLogService prescriptionLogService;
    @Autowired
    private WechatDao wechatDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private OutpatientDao outpatientDao;
    
@ -140,8 +145,32 @@ public class WxTemplateService {
                                "",miniprogramUrl,"wx53f6bb4ac081d840");
                    }else{
                        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_consult_notice","spthtx",1);
                        config.setFirst(config.getFirst().replace("key1",sender_name));
                        config.setPagepath(config.getPagepath()+""+reciver_id+"&doctorName="+sender_name+"&role=patient&roomID="+session_id+"&template=1v1&debugMode=false&cloudenv=PRO");
                        BaseDoctorDO doctorDO = doctorDao.findById(sender_id);
                        String titleName = "";
                        if (doctorDO!=null){
                            titleName = doctorDO.getJobTitleName();
                        }
                        String miniprogramUrl = "";
                        config.setFirst(config.getFirst().replace("key1",sender_name+titleName));
                        if (wechatId.equalsIgnoreCase("xm_ykyy_wx")){
                            String token = yxToken(reciver_id,reciver_name);
                            miniprogramUrl = "pages/room/yunxin?role=patient&token="+token+"&uid="+basePatientDO.getId();
                            config.setPagepath(miniprogramUrl);
                        }
                        ConsultTeamDo consultDo = consultTeamOrderDao.findByConsult(session_id);
                        WlyyOutpatientDO wlyyOutpatientDO = new WlyyOutpatientDO();
                        if (consultDo!=null){
                            wlyyOutpatientDO = outpatientDao.findById(consultDo.getRelationCode());
                        }
                        if (wlyyOutpatientDO!=null){
                            config.setKeyword2(config.getKeyword2()+DateUtil.dateToStrLong(wlyyOutpatientDO.getCreateTime()));
                            config.setKeyword3(config.getKeyword3()+wlyyOutpatientDO.getIcd10Name());
                        }
                        WxWechatDO wechatDO = wechatDao.findById(wechatId);
                        if (wechatDO!=null){
                            config.setAppid(wechatDO.getApplets());
                        }
                        config.setKeyword1(config.getKeyword1()+doctorDO.getName());
                        weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),basePatientWechatDo.getOpenid(),config);
                    }
                }
@ -155,6 +184,55 @@ public class WxTemplateService {
        return "success";
    }
    public String yxToken(String userId,String channelName){
        WlyyHospitalSysDictDO sysDictDO = hospitalSysDictDao.findById("YXAPPKEY");
        WlyyHospitalSysDictDO hospitalSysDictDO =  hospitalSysDictDao.findById("YXAPPSECRET");
        if (sysDictDO==null){
            return  "找不到对应的key";
        }
        String appKey = sysDictDO.getDictValue();
        String appSecret = hospitalSysDictDO.getDictValue();
        String nonce =  randomInt(10);
        String curTime = String.valueOf((new Date()).getTime() / 1000L);
        String checkSum = CheckSumBuilder.getCheckSum(appSecret, nonce ,curTime);//参考 计算CheckSum的java代码
        String url = "https://api.netease.im/nimserver/user/getToken.action";
        Map<String,Object> httpPost = new HashedMap();
        // 设置请求的header
        httpPost.put("AppKey", appKey);
        httpPost.put("Nonce", nonce);
        httpPost.put("CurTime", curTime);
        httpPost.put("CheckSum", checkSum);
        httpPost.put("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair("uid", userId));
        nvps.add(new BasicNameValuePair("channelName",channelName));
        String response = httpClientUtil.headerPost(url,nvps,"UTF-8",httpPost);
        logger.info("返回日志"+response);
        if(StringUtils.isNoneBlank(response)){
            com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(response);
            if (jsonObject.getString("code").equalsIgnoreCase("200")){
                return jsonObject.getString("token");
            }
        }
        return null;
    }
    /**
     * 获取指定长度的随机数字字符串
     * @param length
     * @return
     */
    public String randomInt(int length) {
        String str = "0123456789";
        StringBuffer buffer = new StringBuffer();
        Random random = new Random();
        for(int i = 0; i < length; ++i) {
            int pos = random.nextInt(str.length());
            buffer.append(str.charAt(pos));
        }
        return buffer.toString();
    }
    /**
     * 查询HIS的01表中的审方状态,如果已审方,且未结算,则推送一条模板消息给居民,让居民进行支付结算。
     */
@ -436,4 +514,44 @@ public class WxTemplateService {
        }
        return "success";
    }
    /**
     * 发送微信模版消息
     * @param userName
     * @param senderName
     * @param idCard
     * @param phone
     * @param title
     * @param content
     * @param contentString
     * @param url
     */
    public String sendAppletWxTemple(String userName, String senderName,
                               String idCard, String phone, String title,
                               String content, String contentString,
                               String url,String pagePath) throws Exception{
        BasePatientDO basePatientDO = basePatientDao.findByIdcard(idCard);
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        if(basePatientDO!=null){
            List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,basePatientDO.getId());
            if(ps.isEmpty()){
                logger.info("该用户"+basePatientDO.getName()+"没有openid,无法推送模版消息,用户ID:"+basePatientDO.getId()+"wechatId:"+wechatId);
            }else{
                for (BasePatientWechatDo basePatientWechatDo:ps){
                    WxTemplateConfigDO config = new WxTemplateConfigDO();
                    config.setFirst(config.getFirst().replace("key1",userName));
                    config.setKeyword1(contentString);
                    config.setKeyword2(DateUtil.dateToStrLong(new Date()));
                    config.setUrl(url);
                    config.setAppid(wxWechatDO.getApplets());
                    config.setPagepath(pagePath);
                    weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),basePatientWechatDo.getOpenid(),config);
                }
            }
        }else{
            throw new Exception("接收者ID错误,无法找到该账号");
        }
        return "success";
    }
}

+ 1 - 1
gateway/ag-basic/pom.xml

@ -12,7 +12,7 @@
    <artifactId>ag-basic</artifactId>
    <version>${parent.version}</version>
    <packaging>war</packaging>
    <packaging>jar</packaging>
    <dependencies>
        <!-- 支持Tomcat启动 -->

+ 14 - 1
gateway/ag-basic/src/main/resources/application.yml

@ -211,4 +211,17 @@ spring:
    password: jkzlehr
  redis:
    host: 172.26.0.190 # Redis server host.
    port: 6379 # Redis server port.
    port: 6379 # Redis server port.
---
spring:
  profiles: tnJwprod
  datasource:
     url: jdbc:mysql://10.9.1.247:3306/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
     username: wlyy
     password: qY#j2n5O
  redis:
     host: 10.9.1.247 # Redis server host.
     port: 6380  # Redis server port.
     password: Kb6wKDQP1W4

+ 9 - 0
gateway/ag-basic/src/main/resources/bootstrap.yml

@ -112,3 +112,12 @@ spring:
    config:
      uri: ${wlyy-spring.config.uri:http://172.26.0.194:1221}
      label: ${wlyy-spring.config.label:jwdev}
---
spring:
  profiles: tnJwprod
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}

+ 2 - 2
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -1500,11 +1500,11 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            throw new InvalidRequestException("client_id is null");
        }
        if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
       /* if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
            //验证码正确
        } else {
            return ObjEnvelop.getError("验证码错误!");
        }
        }*/
        if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            try {
                List<BasePatientDO> basePatientDOS =basePatientDao.findByMobileAndDel(mobile,"1");

+ 30 - 1
server/svr-authentication/src/main/resources/application.yml

@ -345,4 +345,33 @@ testPattern:
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
---
spring:
  profiles: tnJwprod
  datasource:
    url: jdbc:mysql://10.9.1.247:3306/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    username: wlyy
    password: qY#j2n5O
  redis:
    host: 10.9.1.247 # Redis server host.
    port: 6380 # Redis server port.
    password: Kb6wKDQP1W4
  ##发现服务
iHealth:
  user-info-uri: http://www.xmtyw.cn/wlyy/iHealth/userInfo
zhongshanHospital:
  user-info-uri: http://laptop-u738dn2p:10023/mqsdk/getUserInfoByOpenid
fastDFS:
  fastdfs_file_url: http://10.9.1.247:22122
wlyy:
  url: http://www.xmtyw.cn/wlyy/
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: sd_tnzyy_wx  # base库中,wx_wechat 的id字段

+ 10 - 1
server/svr-authentication/src/main/resources/bootstrap.yml

@ -113,4 +113,13 @@ spring:
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://172.26.0.194:1221}
      label: ${wlyy.spring.config.label:jwdev}
      label: ${wlyy.spring.config.label:jwdev}
---
spring:
  profiles: tnJwprod
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}

+ 15 - 1
server/svr-configuration/src/main/resources/bootstrap.yml

@ -164,4 +164,18 @@ spring:
        git:
          uri: ${wlyy.spring.config.git.uri:http://192.168.1.220:10080/Amoy2/wlyy2.0.config.git}
          basedir: /usr/local/wlyy2.0-config
        default-label: ${wlyy.spring.config.git.label:jwdev}
        default-label: ${wlyy.spring.config.git.label:jwdev}
---
spring:
  profiles: tnJwprod
##git配置
  cloud:
    config:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      server:
        git:
          uri: ${wlyy.spring.config.git.uri:http://127.0.0.1:3001/jkzl/wlyy2.0.config.git}
          basedir: /usr/local/wlyy2.0-config
        default-label: ${wlyy.spring.config.git.label:master}

+ 46 - 0
svr/svr-base/src/main/resources/application.yml

@ -540,3 +540,49 @@ wechat:
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
---
spring:
  profiles: tnJwprod
  datasource:
    url: jdbc:mysql://10.9.1.247:3306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: wlyy
    password: qY#j2n5O
  elasticsearch:
    cluster-name: jkzl #集群名 默认elasticsearch
    cluster-nodes: 192.0.33.26:9200 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    client-transport-sniff: false
    jest:
      uris: http://10.9.1.247:9200
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
  activemq:
    broker-url: tcp://10.9.1.247:9103
    user: jkzl
    password: jkzlehr
  redis:
    host: 10.9.1.247 # Redis server host.
    port: 6380 # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:
  fastdfs_file_url: http://10.9.1.247:8888/
demo:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
wlyy:
  url: http://ehr.yihu.com/wlyy/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
im:
  im_list_get: http://10.9.1.247:3000/
---

+ 8 - 0
svr/svr-base/src/main/resources/bootstrap.yml

@ -94,3 +94,11 @@ spring:
    config:
      uri: ${wlyy.spring.config.uri:http://172.26.0.194:1221}
      label: ${wlyy.spring.config.label:jwdev}
---
spring:
  profiles: tnJwprod
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}

+ 3 - 4
svr/svr-door-serivce/sql/初始sql.sql

@ -501,7 +501,7 @@ CREATE TABLE `wlyy_sign_family` (
  `openid` varchar(50) DEFAULT NULL COMMENT '患者微信公众号openid',
  `name` varchar(50) NOT NULL COMMENT '患者姓名',
  `idcard` varchar(50) NOT NULL COMMENT '身份证号',
  `ssc` varchar(20) NOT NULL COMMENT '社保卡号',
  `ssc` varchar(20) NULL COMMENT '社保卡号',
  `mobile` varchar(100) DEFAULT NULL COMMENT '手机号',
  `emer_mobile` varchar(15) DEFAULT NULL COMMENT '紧急联系人手机号',
  `hospital` varchar(50) NOT NULL COMMENT '签约医院标识',
@ -567,9 +567,8 @@ CREATE TABLE `wlyy_sign_family` (
  KEY `idx_hospital` (`hospital`,`sign_year`,`status`,`expenses_status`) USING BTREE,
  KEY `idx_apply_date` (`apply_date`) USING BTREE,
  KEY `idx_expenses_time` (`status`,`expenses_time`,`expenses_status`,`sign_year`,`type`,`id`,`code`,`idcard`,`hospital`,`admin_team_code`,`patient`,`server_type`) USING BTREE,
  KEY `idx_type` (`type`,`status`,`expenses_status`,`apply_date`,`sign_year`) USING BTREE,
  KEY `idx_ssc` (`ssc`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4108667 DEFAULT CHARSET=utf8mb4 COMMENT='家庭签约/三师签约';
  KEY `idx_type` (`type`,`status`,`expenses_status`,`apply_date`,`sign_year`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='家庭签约/三师签约';

+ 120 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoctorController.java

@ -0,0 +1,120 @@
package com.yihu.jw.door.controller.doctor;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.door.controller.BaseController;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by yeshijie on 2020/12/30.
 */
@RestController
@RequestMapping(value = "/doctor", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-基础信息")
public class DoctorController extends BaseController {
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    /**
     * 医生基本信息查询接口
     *
     * @return
     */
    @ApiOperation("医生基本信息查询接口")
    @GetMapping(value = "baseinfo")
    public String baseinfo(
            @RequestParam(required = false) String code) {
        try {
            if (StringUtils.isEmpty(code)) {
                code = getUID();
            }
            BaseDoctorDO temp = doctorDao.findById(code);
//            Integer leader = doctorAdminTeamDao.findLeader(code);
//            Hospital hospital = hospitalDao.findByCode(temp.getHospital());
            if (temp != null) {
                JSONObject json = new JSONObject();
                // 设置区县code
//                json.put("town", temp.getTown());
                // 设置医生手机号码
                json.put("mobile", temp.getMobile());
                // 设置医生标识
                json.put("code", temp.getId());
                // 设置医生姓名
                json.put("name", temp.getName());
                // 设置医生头像
                json.put("photo", temp.getPhoto());
                // 设置医生性别
                json.put("sex", temp.getSex());
                // 设置省名称
                json.put("provinceName", temp.getProvinceName());
                // 设置城市名称
                json.put("cityName", temp.getCityName());
                // 设置医院名称
//                json.put("hospitalName", temp.getHospitalName());
                // 设置医院
//                json.put("hospital", temp.getHospital());
                // 设置医院等级1.三甲,2.二甲,3.1级以下
//                json.put("hosLevel", hospital.getHosLevel());
                // 设置部门名称
//                json.put("deptName", StringUtils.isNotEmpty(temp.getDeptName()) ? temp.getDeptName() : "");
                // 设置职称code
                json.put("jobCode", StringUtils.isNotEmpty(temp.getJobTitleCode()) ? temp.getJobTitleCode() : "");
                // 设置职称
                json.put("jobName", StringUtils.isNotEmpty(temp.getJobTitleName()) ? temp.getJobTitleName() : "");
                // 设置医生专长
                json.put("expertise", StringUtils.isNotEmpty(temp.getExpertise()) ? temp.getExpertise() : "");
                // 设置医生简介
                json.put("introduce", StringUtils.isNotEmpty(temp.getIntroduce()) ? temp.getIntroduce() : "");
                // 二维码地址
                json.put("qrcode", temp.getQrcode());
                // 咨询统计
//                Map<String, Long> consultCount = consultTeamService.getAllCount(code);
                // 咨询总数
//                json.put("consultAmount", consultCount.get("all"));
//                // 当天咨询数
//                json.put("consultAmountToday", consultCount.get("today"));
                //身份类型
                json.put("level", "1");
                //身份证号
                json.put("idcard", temp.getIdcard());
                //是否认证
                json.put("isCertified", temp.getIscertified());
                //是否名医
                json.put("isFamous", temp.getIsFamous());
                //是否医生提示 提示过是1 其他都是0
                json.put("isPasswordPrompt", StringUtils.isEmpty(temp.getIsPasswordPrompt()) ? "0" : temp.getIsPasswordPrompt());
                //获取医生角色和区域权限
//                List<Map<String, String>> roleMap = roleService.getUserRoleAndArea(temp.getCode());
//                json.put("userRole", roleMap);
                //获取医生后台管理员系统角色,用于判断是否是居民上门服务业务中的调度员
//                json.put("doctorRole",roleService.findManageUserRole(temp.getCode()));
//                是否团队长
//                json.put("isLeader", leader == null ? "0" : "1");
//                团队长所管辖的团队code 一个团队长只管辖一个团队
//                json.put("adminTeamCode", leader);
                return write(200, "医生信息查询成功!", "data", json);
            } else {
                return error(-1, "医生信息查询失败!");
            }
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "医生信息查询失败!");
        }
    }
}

+ 99 - 238
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/ConsultController.java

@ -1,238 +1,99 @@
//package com.yihu.jw.door.controller.patient;
//
//import com.alibaba.fastjson.JSONObject;
//import com.yihu.jw.door.controller.BaseController;
//import com.yihu.jw.door.service.consult.ConsultTeamService;
//import com.yihu.jw.entity.base.im.ConsultTeamDo;
//import com.yihu.jw.entity.base.im.ConsultTeamLogDo;
//import com.yihu.jw.entity.patient.Patient;
//import com.yihu.jw.im.dao.ConsultTeamDao;
//import com.yihu.jw.im.util.ImUtil;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.http.NameValuePair;
//import org.apache.http.message.BasicNameValuePair;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//
///**
// * Created by yeshijie on 2020/12/29.
// */
//@RestController
//@RequestMapping(value = "/patient/consult", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//@Api(description = "患者端-患者咨询")
//public class ConsultController extends BaseController {
//
//    @Autowired
//    private ConsultTeamService consultTeamService;
//    @Autowired
//    private ConsultTeamDao consultTeamDao;
//    @Autowired
//    private ImUtil imUtil;
//    @Autowired
//    private JdbcTemplate jdbcTemplate;
//
//    /**
//     * 三师咨询追问接口
//     *
//     * @param consult 咨询标识
//     * @param content 追问内容
//     * @param type    追问内容类型:1文字,2图片,3语音  ... (im消息类型)
//     * @return
//     */
//    @RequestMapping(value = "append")
//    @ResponseBody
//    @ApiOperation("三师咨询追问接口")
//    public String append(
//            @RequestParam String consult,
//            @RequestParam String content,
//            @RequestParam int type,
//            @RequestParam(required = false, defaultValue = "0") Integer times) {
//        try {
//            List<ConsultTeamLogDo> logs = new ArrayList<ConsultTeamLogDo>();
//            ConsultTeamDo consultModel = consultTeamDao.findByConsult(consult);
//
//            if (consultModel == null) {
//                return error(-1, "咨询记录不存在!");
//            }
//
//            if (consultModel.getEndMsgId() != null) {
//                return error(-1, "咨询已结束");
//            }
//
//            String[] arr = null;
//            if (type == 3) {
//                String path = fetchWxVoices();
//                JSONObject obj = new JSONObject();
//                // 将临时语音拷贝到正式存储路径下
//                if (StringUtils.isNotEmpty(path)) {
//                    content = CommonUtil.copyTempVoice(path);
//                    obj.put("path", content);
//                    obj.put("times", times);
//                    content = obj.toString();
//                }
//                ConsultTeamLogDo log = new ConsultTeamLogDo();
//                log.setConsult(consult);
//                log.setContent(content);
//                log.setDel("1");
//                log.setChatType(type);
//                log.setType(type);
//                logs.add(log);
//            } else if (type == 2) {
//                // 图片消息
//                content = fetchWxImages();
//                // 将临时图片拷贝到正式存储路径下
//                if (StringUtils.isNotEmpty(content)) {
//                    content = CommonUtil.copyTempImage(content);
//                }
//                if (StringUtils.isEmpty(content)) {
//                    return error(-1, "图片上传失败!");
//                }
//                String[] images = content.split(",");
//                for (String image : images) {
//                    ConsultTeamLogDo log = new ConsultTeamLogDo();
//                    log.setConsult(consult);
//                    log.setContent(image);
//                    log.setDel("1");
//                    log.setChatType(type);
//                    log.setType(type);
//                    logs.add(log);
//                }
//            } else {
//                ConsultTeamLogDo log = new ConsultTeamLogDo();
//                log.setConsult(consult);
//                log.setContent(content);
//                log.setDel("1");
//                log.setChatType(type);
//                log.setType(type);
//                logs.add(log);
//
//                arr = new String[]{content};
//            }
////            Patient patient = patientDao.findByCode(getUID());
//            Patient patient = patientDao.findByCode(getRepUID());
//            int i = 0;
//            List<String> failed = new ArrayList<>();
//
//            String agent = getUID()==getRepUID()?null:getUID();
//            for (ConsultTeamLogDo log : logs) {
//                String response = imUtil.sendTopicIM(getRepUID(), patient.getName(), consult, String.valueOf(log.getType()), log.getContent(),agent);
//
//                if (StringUtils.isNotEmpty(response)) {
//                    JSONObject resObj = new JSONObject(response);
//                    if (resObj.getInteger("status") == -1) {
//                        return invalidUserException(new RuntimeException(resObj.getString("message")), -1, "追问失败!" + resObj.getString("message"));
//                    }
//                    failed.add(String.valueOf(resObj.get("data")));
//                    try {
//                        String sql = "";
//                        if (consultModel.getType() == 2){
//                            //家庭咨询
//                            sql = "SELECT t.participant_id FROM " + im +
//                                    ".participants t where t.session_id = '" +
//                                    patient.getCode() + "_" + consultModel.getTeam() + "_" + consultModel.getType() +
//                                    "' and t.participant_role = 0";
//                        }else if (consultModel.getType() == 8 || consultModel.getType() == 9 || consultModel.getType() == 11){
//                            //8-续方咨询 9-在线复诊咨询 11-上门预约服务
//                            sql = "SELECT t.participant_id FROM " + im +
//                                    ".participants t where t.session_id = '" +
//                                    patient.getCode() + "_" + consultModel.getConsult() + "_" + consultModel.getType() +
//                                    "' and t.participant_role = 0";
//                        }else if(consultModel.getType() == 18){
//                            //康复咨询
//                            sql = "SELECT t.participant_id FROM " + im +
//                                    ".participants t where t.session_id = '(SELECT session_id from "+im+".topics WHERE id='"+consultModel.getConsult()+"')' and t.participant_role = 0";
//                        }
//
//                        if(StringUtils.isEmpty(sql)){
//                            return write(-1, "追问失败!", "data", "不存在该类型!【type】:" + type);
//                        }
//                        List<Map<String, Object>> participants = jdbcTemplate.queryForList(sql);
//
//                        for (Map<String, Object> participant : participants) {
////                          //有居民、健管、全科
//                            String doctorCode = participant.get("participant_id").toString();
//                            if (doctorCode.equals(patient.getCode())) {
//                                continue;
//                            }
//
//                        }
//                    } catch (Exception e) {
//                        e.printStackTrace();
//                    }
//
//                }
//            }
//            return write(200, "追问成功!", "data", failed);
//        } catch (Exception e) {
//            error(e);
//            return invalidUserException(e, -1, "追问失败!");
//        }
//    }
//
//
//    /**
//     * 网络咨询咨询日志查询
//     *
//     * @param consult  咨询标识
//     * @param pagesize 每页显示数,默认为10
//     * @return
//     */
//    @GetMapping(value = "loglist")
//    @ApiOperation("网络咨询咨询日志查询")
//    public String loglist(@RequestParam String consult, @RequestParam int page, @RequestParam int pagesize) {
//        try {
//            ConsultTeamDo consultModel = consultTeamDao.findByConsult(consult);
//            if (consultModel == null) {
//                return error(-1, "咨询记录不存在!");
//            }
//            JSONObject messageObj = imUtil.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, getRepUID());
//
//            return write(200, "查询成功", "list", messageObj);
//        } catch (Exception e) {
//            error(e);
//            return invalidUserException(e, -1, "查询失败!");
//        }
//    }
//
//    @GetMapping(value = "getTopic")
//    public String getTopic(String consult){
//        try{
//            return success(imUtil.getTopic(consult).get("data").toString());
//        }catch (Exception e){
//            error(e);
//            return error(-1,e.getMessage());
//        }
//    }
//
//    @GetMapping(value = "getConsult")
//    public String getConsult(String consult){
//        try{
//            ConsultTeamDo consultTeam = consultTeamDao.findByConsult(consult);
//            return write(200, "查询成功", "data", consultTeam);
//        }catch (Exception e){
//            error(e);
//            return error(-1,e.getMessage());
//        }
//    }
//
//    @GetMapping(value = "queryByRelationCode")
//    @ApiOperation("根据关联业务code查询咨询记录")
//    public String queryByRelationCode(@ApiParam(name = "code", value = "咨询关联业务code") @RequestParam(value = "code", required = true) String code){
//        try{
//            ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(code);
//            return write(200, "提交成功", "data", consultTeam);
//        }catch (Exception e){
//            error(e);
//            return error(-1,"添加失败");
//        }
//    }
//}
package com.yihu.jw.door.controller.patient;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.door.controller.BaseController;
import com.yihu.jw.door.service.consult.ConsultTeamService;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
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.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by yeshijie on 2020/12/29.
 */
@RestController
@RequestMapping(value = "/patient/consult", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "患者端-患者咨询")
public class ConsultController extends BaseController {
    private static final Logger logger = LoggerFactory.getLogger(ConsultController.class);
    @Autowired
    private ConsultTeamService consultTeamService;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private ImUtil imUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 网络咨询咨询日志查询
     *
     * @param consult  咨询标识
     * @param pagesize 每页显示数,默认为10
     * @return
     */
    @GetMapping(value = "loglist")
    @ApiOperation("网络咨询咨询日志查询")
    public String loglist(@RequestParam String consult, @RequestParam int page, @RequestParam int pagesize) {
        try {
            ConsultTeamDo consultModel = consultTeamDao.findByConsult(consult);
            if (consultModel == null) {
                return error(-1, "咨询记录不存在!");
            }
            JSONObject messageObj = imUtil.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, getRepUID());
            return write(200, "查询成功", "list", messageObj);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "查询失败!");
        }
    }
    @GetMapping(value = "getTopic")
    public String getTopic(String consult){
        try{
            return success(imUtil.getTopic(consult).get("data").toString());
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    @GetMapping(value = "getConsult")
    public String getConsult(String consult){
        try{
            ConsultTeamDo consultTeam = consultTeamDao.findByConsult(consult);
            return write(200, "查询成功", "data", consultTeam);
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    @GetMapping(value = "queryByRelationCode")
    @ApiOperation("根据关联业务code查询咨询记录")
    public String queryByRelationCode(@ApiParam(name = "code", value = "咨询关联业务code") @RequestParam(value = "code", required = true) String code){
        try{
            ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(code);
            return write(200, "提交成功", "data", consultTeam);
        }catch (Exception e){
            error(e);
            return error(-1,"添加失败");
        }
    }
}

+ 1 - 1
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorCommentController.java

@ -30,7 +30,7 @@ import java.util.List;
*/
@RestController
@RequestMapping(value = "/wlyyDoorComment")
@Api(value = "服务工单评价管理", description = "服务工单评价管理服务接口") //, tags = {"健康商城-服务工单评价管理服务接口"}
@Api(value = "服务工单评价管理", description = "服务工单评价管理服务接口")
public class WlyyDoorCommentController extends EnvelopRestEndpoint {
    @Autowired

+ 1 - 1
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorCommentDoctorController.java

@ -30,7 +30,7 @@ import java.util.List;
*/
@RestController
@RequestMapping(value = "/wlyyDoorCommentDoctor")
@Api(value = "服务工单中的医生评价管理", description = "服务工单中的医生评价管理服务接口") //, tags = {"健康商城-服务工单中的医生评价管理服务接口"}
@Api(value = "服务工单中的医生评价管理", description = "服务工单中的医生评价管理服务接口")
public class WlyyDoorCommentDoctorController extends EnvelopRestEndpoint {
    @Autowired

+ 1 - 1
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorConclusionController.java

@ -30,7 +30,7 @@ import java.util.List;
*/
@RestController
@RequestMapping(value = "/wlyyDoorConclusion")
@Api(value = "工单服务小结管理", description = "工单服务小结管理服务接口") //, tags = {"健康商城-工单服务小结管理服务接口"}
@Api(value = "工单服务小结管理", description = "工单服务小结管理服务接口")
public class WlyyDoorConclusionController extends EnvelopRestEndpoint {
    @Autowired

+ 1 - 1
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorDoctorController.java

@ -30,7 +30,7 @@ import java.util.List;
*/
@RestController
@RequestMapping(value = "/wlyyDoorDoctor")
@Api(value = "服务工单关联的医护人员管理", description = "服务工单关联的医护人员管理服务接口") //, tags = {"健康商城-服务工单关联的医护人员管理服务接口"}
@Api(value = "服务工单关联的医护人员管理", description = "服务工单关联的医护人员管理服务接口")
public class WlyyDoorDoctorController extends EnvelopRestEndpoint {
    @Autowired

+ 1 - 1
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorDoctorFeeController.java

@ -30,7 +30,7 @@ import java.util.List;
*/
@RestController
@RequestMapping(value = "/wlyyDoorDoctorFee")
@Api(value = "医生出诊费用字典管理", description = "医生出诊费用字典管理服务接口") //, tags = {"健康商城-医生出诊费用字典管理服务接口"}
@Api(value = "医生出诊费用字典管理", description = "医生出诊费用字典管理服务接口")
public class WlyyDoorDoctorFeeController extends EnvelopRestEndpoint {
    @Autowired

+ 1 - 1
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorFeeDetailController.java

@ -30,7 +30,7 @@ import java.util.List;
*/
@RestController
@RequestMapping(value = "/wlyyDoorFeeDetail")
@Api(value = "服务工单价格明细(服务项价格,医生出诊费用)管理", description = "服务工单价格明细(服务项价格,医生出诊费用)管理服务接口") //, tags = {"健康商城-服务工单价格明细(服务项价格,医生出诊费用)管理服务接口"}
@Api(value = "服务工单价格明细(服务项价格,医生出诊费用)管理", description = "服务工单价格明细(服务项价格,医生出诊费用)管理服务接口")
public class WlyyDoorFeeDetailController extends EnvelopRestEndpoint {
    @Autowired

+ 1 - 1
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorPatientConfirmLogController.java

@ -30,7 +30,7 @@ import java.util.List;
*/
@RestController
@RequestMapping(value = "/wlyyDoorPatientConfirmLog")
@Api(value = "服务工单居民确认操作日志记录管理", description = "服务工单居民确认操作日志记录管理服务接口") //, tags = {"健康商城-服务工单居民确认操作日志记录管理服务接口"}
@Api(value = "服务工单居民确认操作日志记录管理", description = "服务工单居民确认操作日志记录管理服务接口")
public class WlyyDoorPatientConfirmLogController extends EnvelopRestEndpoint {
    @Autowired

+ 6 - 15
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/WlyyDoorServiceOrderController.java

@ -12,8 +12,8 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
@ -33,7 +33,7 @@ import java.util.Map;
 */
@RestController
@RequestMapping(value = "/patient/wlyyDoorServiceOrder")
@Api(value = "上门服务工单管理", description = "上门服务工单管理服务接口") //, tags = {"健康商城-上门服务工单管理服务接口"}
@Api(value = "上门服务工单管理", description = "上门服务工单管理服务接口")
public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
    @Autowired
@ -45,13 +45,6 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
    private WlyyDoorPrescriptionService doorPrescriptionService;
    @Value("${wechat.appId}")
    private String appId;
    @Value("${wechat.appSecret}")
    private String appSecret;
    @Value("${wechat.accId}")
    private String accId;
    @PostMapping(value = "qucikSendIM")
    @ApiOperation(value = "通过IM向客户端推送消息")
    public Envelop qucikSendIM(
@ -62,7 +55,6 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
            @ApiParam(name = "content", value = "消息内容json", required = true) @RequestParam String content
    ) {
        int result = wlyyDoorServiceOrderService.qucikSendIM(orderId, sendId, sendName, contentType, content);
        if (result == -1) {
            return failed("发送失败!");
@ -170,12 +162,12 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
    @ApiOperation(value = "生成二维码接口")
    public Envelop twoDimensionalCode(
            @ApiParam(name = "id", value = "工单id") @RequestParam(value = "id", required = true) String id) {
/*        if (wlyyDoorServiceOrderService.twoDimensionalCode(id, weiXinAccessTokenUtils.getAccessToken()) != null){
            return success("获取二维码成功",200,wlyyDoorServiceOrderService.twoDimensionalCode(id, weiXinAccessTokenUtils.getAccessToken()));
        String url = wlyyDoorServiceOrderService.twoDimensionalCode(id);
       if (StringUtils.isNotEmpty(url)){
            return success("获取二维码成功",200,url);
        }else {
            return failed("获取二维码失败,请确认工单",-1);
        }*/
        return null;
        }
    }
    @PostMapping(value = "updateOrderInfo")
@ -253,7 +245,6 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
        return success(result.get(ResponseContant.resultMsg));
    }
    @GetMapping(value = "queryDoctorList")

+ 12 - 9
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/WlyyDoorServiceOrderService.java

@ -633,8 +633,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        if ( StringUtils.isNotBlank(orderDO.getDoctor())) {
            orderDO.setStatus(2);
/*            orderDO.setDoctor(signFamily.getDoctor());
            orderDO.setDoctorName(signFamily.getDoctorName());*/
            orderDO.setDoctorName(orderDO.getExpectedDoctorName());
            this.save(orderDO);
            WlyyDoorServiceOrderDO wlyyDoorServiceOrder = wlyyDoorServiceOrderDao.findOne(orderDO.getId());
            //新增工单医生关联关系
@ -642,7 +641,13 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            // 给服务医生发接单消息
            this.createMessage(orderDO.getId(),orderDO.getProxyPatient(),orderDO.getDoctor(),407,"服务工单待接单","您有新的服务工单,请前往处理");
            //发送智能助手消息
            sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
//            sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
            //发送 预约卡片信息(2101类型)
            JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
            orderInfoContent.put("re_msg_type",0);//居民预约
            this.qucikSendIM(orderDO.getId(), "system", "智能助手", "2101", orderInfoContent.toJSONString());
            result.put(ResponseContant.resultFlag, ResponseContant.success);
            result.put(ResponseContant.resultMsg, consultTeam);
            return  result;
@ -659,7 +664,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            this.createMessage(orderDO.getId(),"system",dispatcher,430,"居民提交工单申请",orderDO.getPatientName() + "提交了服务工单"+orderDO.getNumber()+"申请");
        }
        //给机构调度员发送医生助手消息
        String  dispatcherSql = "SELECT m.doctor_code FROM base_doctor_role m " +
/*        String  dispatcherSql = "SELECT m.doctor_code FROM base_doctor_role m " +
                "JOIN base_doctor_role_dict r ON m.role_code = r.code " +
                "JOIN base_doctor_hospital o ON m.doctor_code = o.doctor_code WHERE " +
                " r.code = 'dispatcher' and o.del=1 and o.org_code = '"+orderDO.getHospital()+"'";
@ -667,7 +672,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        List<Map<String, Object>> dispatcherList = jdbcTemplate.queryForList(dispatcherSql);
        for(Map<String, Object> map : dispatcherList) {
            sendWeixinMessage(3, map.get("doctor_code") + "", orderDO.getPatient());
        }
        }*/
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, consultTeam);
@ -676,7 +681,6 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        orderInfoContent.put("re_msg_type",0);//居民预约
        this.qucikSendIM(orderDO.getId(), "system", "智能助手", "2101", orderInfoContent.toJSONString());
        if(StringUtils.isNoneBlank(orderDO.getDoctor())){
            //服务医生修改,直接转派
            BaseDoctorDO transDoctor = doctorDao.findById(orderDO.getDoctor());
@ -1012,10 +1016,9 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
    /**
     * 生成二維碼
     * @param id
     * @param token
     * @return
     */
    public String twoDimensionalCode(String id , String token) {
    public String twoDimensionalCode(String id ) {
        JSONObject orderJson = new JSONObject();
        List<WlyyDoorServiceOrderDO> orderList = this.findByField("id", id);
        if (orderList.size()>0){
@ -1031,7 +1034,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
                try {
                    ObjectNode imgNode = fastDFSUtil.upload(ipt, "png", "plan_service_qrcode" + System.currentTimeMillis());
                    JSONObject json = JSONObject.parseObject(imgNode.toString());
                    tempPaths.add(json.getString("fid"));
                    tempPaths.add(json.getString("fileId"));
                    String urls = "";
                    for (String image : tempPaths) {
                        if (urls.length() == 0) {

+ 7 - 7
svr/svr-door-serivce/src/main/resources/application.yml

@ -105,9 +105,8 @@ wechat:
  flag: false #演示环境  true走Mysql数据库  false走Oracle
im:
  im_list_get: http://172.26.0.118:3000/
  #im_list_get: http://192.168.131.24:3000/
  data_base_name: ichat
  im_list_get: http://172.26.0.105:3000/
  data_base_name: im_internet_hospital
es:
  pwflag: 1 # 1需要密码,2不需要密码
  index:
@ -159,11 +158,11 @@ spring:
    host: 172.26.0.253 # Redis server host.
    port: 6379 # Redis server port.
fastDFS:
  fastdfs_file_url: http://172.26.0.110:80/
  fastdfs_file_url: http://172.26.0.110:8888/
fast-dfs:
  tracker-server: 172.26.0.110:22122
  public-server: http://172.26.0.110:80/
  public-server: http://172.26.0.110:8888/
server:
  server_url: http://ehr.yihu.com/wlyy/
@ -185,8 +184,9 @@ wechat:
  flag: false #演示环境  true走Mysql数据库  false走Oracle
im:
  im_list_get: http://172.26.0.118:3000/
  data_base_name: im_new
  im_list_get: http://172.26.0.105:3000/
  data_base_name: im_internet_hospital
es:
  pwflag: 1 # 1需要密码,2不需要密码
  index:

+ 1 - 1
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/TnyyController.java

@ -26,7 +26,7 @@ public class TnyyController extends EnvelopRestEndpoint {
    @GetMapping(value = "/queryBySql")
    @ApiOperation(value = "视图统一查询")
    public ListEnvelop createSQLQuery(@ApiParam(name = "sql", value = "sql语句", required = true)
    public ListEnvelop queryBySql(@ApiParam(name = "sql", value = "sql语句", required = true)
                                      @RequestParam(value = "sql",required = true)String sql){
        return success(tnyyEntranceService.queryBySql(sql));
    }

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

@ -369,9 +369,9 @@ express:
---
# sql前置機
# sqlserverce测试环境
spring:
  profiles: sqlServerProd
  profiles: sqlServerTest
  datasource:
    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    url: jdbc:sqlserver://192.168.131.125:1433;DatabaseName=base
@ -386,6 +386,55 @@ spring:
    database-platform: org.hibernate.dialect.SQLServer2008Dialect
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: false
#支付支付
pay:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://172.16.1.42:3000/
  data_base_name: im
fastDFS:
  fastdfs_file_url: http://192.0.33.26:8888/
fast-dfs:
  tracker-server: 192.168.103.159:22122 #服务器地址
#是否开启i健康接口 0关闭,1开启
testPattern:
  sign: 0
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
  flag: false #演示环境  true走Mysql数据库  false走Oracle
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: WH000091
  sf_check_word: SFAHKAOFAAITyjt7890
---
# sqlserverce正式环境
spring:
  profiles: tnJwprod
  datasource:
    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    url: jdbc:sqlserver://10.9.1.246:1433;DatabaseName=tazyy
    username: sa
    password: jsjzx@1234
  jpa:
    properties:
      hibernate:
        default_schema: dbo
      naming:
        physical-strategy: com.ford.configuration.UpperTableStrategy
    database-platform: org.hibernate.dialect.SQLServer2008Dialect
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: false

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

@ -339,3 +339,44 @@ express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code:
  sf_check_word:
---
spring:
  profiles: tnJwprod
  datasource:
    url: jdbc:mysql://10.9.1.247:3306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true&useSSL=false #jdbc:mysql://192.0.33.27:3306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: wlyy
    password: qY#j2n5O
hlwyyEntrance:
  url: http://172.16.1.42:10023
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: false
#支付支付
pay:
  flag: true
hospital:
  url: https://wx.xmzsh.com #https://172.16.1.34
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://10.9.1.247:3000/
  data_base_name: im
fastDFS:
  fastdfs_file_url: http://10.9.1.247:8888/
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
  flag: false #演示环境  true走Mysql数据库  false走Oracle
  ids: sd_tnzyy_wx
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: WH000091
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
jobs:
  schedule: 0 */30 * * * ?

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

@ -22,11 +22,9 @@ import com.yihu.jw.hospital.mapping.service.PatientMappingService;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDiagnosisDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.hospital.prescription.service.InspectionService;
import com.yihu.jw.hospital.prescription.service.PrescriptionLogService;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.prescription.service.WorkTimeService;
import com.yihu.jw.hospital.prescription.service.*;
import com.yihu.jw.hospital.prescription.service.entrance.DoctorPreSignService;
import com.yihu.jw.hospital.prescription.service.entrance.TnyyEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.service.SystemMessage.HospitalSystemMessageService;
import com.yihu.jw.im.dao.ConsultDao;
@ -117,6 +115,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    private ConsultDao consultDao;
    @Autowired
    private HospitalSystemMessageService hospitalSystemMessageService;
    @Autowired
    private TnyyEntranceService tnyyEntranceService;
    @Autowired
    private TnPrescriptionService tnPrescriptionService;
    @Value("${demo.flag}")
    private boolean demoFlag;
@ -141,7 +143,15 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                              @RequestParam(value = "cardNo",required = false)String cardNo) throws Exception {
        startTime = startTime+" 00:00:00";
        endTime =endTime+" 23:59:59";
        List<WlyyOutpatientVO> vos = prescriptionService.findOutpatientList(patient, startTime, endTime, demoFlag,ksdm,cardNo);
        List<WlyyOutpatientVO> vos = new ArrayList<>();
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
            vos = prescriptionService.findOutpatientList(patient, startTime, endTime, demoFlag,ksdm,cardNo);
        }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
            vos = tnPrescriptionService.findOutpatientList(patient, cardNo,startTime, endTime, demoFlag,ksdm);
        }else {
            return ListEnvelop.getError("尚未开发!");
        }
        return success(vos);
    }
    
@ -151,7 +161,14 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                         @RequestParam(value = "patient",required = false) String patient,
                                         @ApiParam(name = "conNo", value = "就诊次数")
                                         @RequestParam(value = "conNo",required = false) String conNo)throws Exception{
        WlyyOutpatientVO obj = prescriptionService.findOutpatientInfo(patient,conNo);
        WlyyOutpatientVO obj = new WlyyOutpatientVO();
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
            obj = prescriptionService.findOutpatientInfo(patient,conNo);
        }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
            obj = tnPrescriptionService.findOutpatientInfo(patient,conNo,demoFlag,null);
        }else {
            return ObjEnvelop.getError("尚未开发!");
        }
        return success(obj);
    }
    
@ -166,7 +183,15 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "admNo",required = false) String admNo,
            @ApiParam(name = "realOrder", value = "处方号")
            @RequestParam(value = "realOrder",required = false) String realOrder) throws Exception {
        List<WlyyPrescriptionVO> obj = prescriptionService.findOriginPrescriptionList(registerSn, patNo, realOrder, admNo,demoFlag);
        List<WlyyPrescriptionVO> obj = new ArrayList<>();
        if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
            obj= prescriptionService.findOriginPrescriptionList(registerSn, patNo, realOrder, admNo,demoFlag);
        }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
            obj= tnPrescriptionService.findOriginPrescriptionList(registerSn, patNo, realOrder, admNo,demoFlag);
        }else {
            return ListEnvelop.getError("尚未开发!");
        }
        return success(obj);
    }
    
@ -396,6 +421,8 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            return success(prescriptionService.getICD10(pyKey));
        }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
            return success(xzzxEntranceService.selectIcd10Dict(pyKey));
        }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
            return success(tnPrescriptionService.getICD10(pyKey,false));
        }else {
            return ListEnvelop.getError("尚未开发!");
        }
@ -418,6 +445,8 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            return success(prescriptionService.getDrugDictionary(drugNo,pyKey,winNo,groupNo));
        }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
            return success(xzzxEntranceService.selectDrugDict(pyKey));
        }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
            return success(tnPrescriptionService.getDrugDictionary(drugNo,pyKey,null,null,null));
        }else {
            return ListEnvelop.getError("尚未开发!");
        }
@ -434,6 +463,8 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            return success(prescriptionService.getDrugUse(drugNo,pyKey));
        }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
            return success(xzzxEntranceService.selectMedicineUsed(pyKey));
        }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
            return success(tnPrescriptionService.getDrugUse(pyKey,demoFlag));
        }else {
            return ListEnvelop.getError("尚未开发!");
        }
@ -448,6 +479,8 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
            return success(prescriptionService.getDrugFrequency());
        }else if (wxId.equalsIgnoreCase("xm_xzzx_wx")){
            return success(xzzxEntranceService.selectFrequencyDict());
        }else if (wxId.equalsIgnoreCase("sd_tnzyy_wx")){
            return success(tnPrescriptionService.getDrugFrequency(demoFlag));
        }else {
            return ListEnvelop.getError("尚未开发!");
        }

+ 52 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/tnyy/TnyyController.java

@ -0,0 +1,52 @@
package com.yihu.jw.hospital.endpoint.tnyy;
import com.yihu.jw.hospital.prescription.service.TnPrescriptionService;
import com.yihu.jw.hospital.prescription.service.entrance.TnyyEntranceService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Trick on 2020/1/19.
 */
@RestController
@RequestMapping(value ="/tnyy")
@Api(value = "泰安中医院", description = "泰安中医院", tags = {"泰安中医院"})
public class TnyyController extends EnvelopRestEndpoint {
    @Autowired
    private TnyyEntranceService tnyyEntranceService;
    @Autowired
    private TnPrescriptionService prescriptionService;
    @GetMapping(value = "/getDeptInfo")
    @ApiOperation(value = "获取部门信息", notes = "获取部门信息")
    public ObjEnvelop getDeptInfo(@ApiParam(name = "code", value = "code", required = false)
                                  @RequestParam(value = "code",required = false)String code)throws Exception{
        return ObjEnvelop.getSuccess("ok",tnyyEntranceService.updateTnyyDept());
    }
    @GetMapping(value = "/updateTnyyDoctor")
    @ApiOperation(value = "获取医生信息", notes = "获取医生信息")
    public ObjEnvelop updateTnyyDoctor(@ApiParam(name = "idcard", value = "idcard", required = false)
                                  @RequestParam(value = "idcard",required = false)String idcard)throws Exception{
        return ObjEnvelop.getSuccess("ok",tnyyEntranceService.updateTnyyDoctor(idcard));
    }
    @GetMapping(value = "/synYkICD10")
    @ApiOperation(value = "获取icd10信息", notes = "获取icd10信息")
    public ObjEnvelop synYkICD10()throws Exception{
        return ObjEnvelop.getSuccess("ok",prescriptionService.synYkICD10());
    }
}

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

@ -864,5 +864,96 @@ express:
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
---
spring:
  profiles: tnJwprod
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://10.9.1.247:3306/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
    username: wlyy
    password: qY#j2n5O
#  elasticsearch:
#    cluster-name: jkzl #集群名 默认elasticsearch
#    cluster-nodes: 192.0.33.26:9200 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
#    client-transport-sniff: false
#    jest:
#      uris: http://192.0.33.26:9300
#      connection-timeout: 60000 # Connection timeout in milliseconds.
#      multi-threaded: true # Enable connection requests from multiple execution threads.
  activemq:
    broker-url: tcp://59.61.92.90:9103
    user: jkzl
    password: jkzlehr
  redis:
    host: 10.9.1.247 # Redis server host.
    port: 6380 # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:
  fastdfs_file_url: https://hlwyy.xmzsh.com/fastdfs/
fast-dfs:
  tracker-server: 10.9.1.247:22122 #服务器地址
wechat:
  id: sd_tnzyy_wx  # base库中,wx_wechat 的id字段  # todo 待配置
  flag: true #演示环境  true走Mysql数据库  false走Oracle
# 短信验证码发送的客户端标识,居民端
sms:
  clientId: EwC0iRSrcP #todo 待配置
myFamily:
  qrCodeFailurTime: 2
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: true
#支付支付
pay:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://10.9.1.247:3000/
  data_base_name: im
es:
  pwflag: 1 # 1需要密码,2不需要密码
  index:
    Statistics: hlw_quota_prod
  type:
    Statistics: hlw_quota_prod
  host:  http://10.9.1.247:9200
  tHost: 10.9.1.247:9300
  clusterName: jkzl
  user: lion
  password: jkzlehr
  securityUser: lion:jkzlehr
# 上传文件临时路径配置
FileTempPath:
  upload_temp_path : /var/local/temp
  image_path : /var/local/upload/images
  voice_path : /var/local/upload/voice
  chat_file_path : /var/local/upload/chat
#文件服务器上传配置 0本地,1.I健康,2.内网调用
testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
qywx:
  url: https://hlwyy.xmzsh.com/hlwyy
  id: zsyy
express:
  sf_url: https://mrds-admin.sf-express.com:443
  sf_code: WH000102
  sf_check_word: TGUQASFNAZyjt9112
---

+ 9 - 1
svr/svr-internet-hospital/src/main/resources/bootstrap.yml

@ -88,4 +88,12 @@ spring:
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://172.26.0.194:1221}
      label: ${wlyy.spring.config.label:jwdev}
      label: ${wlyy.spring.config.label:jwdev}
---
spring:
  profiles: tnJwprod
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}