Browse Source

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

# Conflicts:
#	business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java
mengkang 4 years ago
parent
commit
5b44fc4d11
42 changed files with 1577 additions and 142 deletions
  1. 6 2
      business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/PatientMappingService.java
  2. 8 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionEmrDao.java
  3. 165 16
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  4. 61 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java
  5. 1 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java
  6. 48 12
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java
  7. 7 0
      business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java
  8. 4 2
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  9. 1 0
      business/base-service/src/main/java/com/yihu/jw/utils/hibernate/HibenateUtils.java
  10. 1 0
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatInfoService.java
  11. 4 0
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WxTemplateService.java
  12. 3 1
      common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java
  13. 62 0
      common/common-entity/src/main/java/com/yihu/jw/entity/UuidIdentityEntityWithTime.java
  14. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/module/ModuleDO.java
  15. 100 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceInventoryWarningDO.java
  16. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/product/IotProductBaseInfoDO.java
  17. 6 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  18. 5 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java
  19. 12 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionVO.java
  20. 45 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/common/BaseTimeVO.java
  21. 87 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotDeviceInventoryWarningVO.java
  22. 3 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  23. 2 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/utils/RSAUtils.java
  24. 9 6
      svr/svr-base/src/main/java/com/yihu/jw/base/service/org/BaseOrgService.java
  25. 18 18
      svr/svr-base/src/main/java/com/yihu/jw/base/service/team/BaseTeamService.java
  26. 15 15
      svr/svr-base/src/main/java/com/yihu/jw/base/service/user/UserService.java
  27. 32 29
      svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java
  28. 25 2
      svr/svr-internet-hospital-entrance/src/main/resources/application.yml
  29. 3 2
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/ykyy/UnSettledHISPrescriptionJob.java
  30. 3 3
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/ykyy/UpdateStatusByPayTimeJob.java
  31. 474 0
      svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java
  32. 28 7
      svr/svr-internet-hospital-job/src/main/resources/application.yml
  33. 65 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  34. 109 16
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  35. 1 1
      svr/svr-iot-job/src/main/java/com/yihu/jw/service/device/InventoryWarningService.java
  36. 30 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceInventoryController.java
  37. 9 5
      svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java
  38. 13 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceInventoryWarningDao.java
  39. 30 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceInventoryService.java
  40. 76 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceInventoryWarningService.java
  41. 3 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistPatientRelationDao.java
  42. 1 1
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java

+ 6 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/mapping/service/PatientMappingService.java

@ -1,9 +1,11 @@
package com.yihu.jw.hospital.mapping.service;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
import net.sf.json.JSONArray;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
@ -34,6 +36,8 @@ public class PatientMappingService {
    private YkyyEntranceService ykyyEntranceService;
    @Autowired
    private EntranceService entranceService;
    @Autowired
    private BasePatientMedicareCardDao patientMedicareCardDao;
    @Value("${demo.flag}")
    private boolean demoFlag;
@ -78,11 +82,11 @@ public class PatientMappingService {
        BasePatientDO patientDO = basePatientDao.findById(patient);
        logger.info("patientDO:"+patientDO.toString());
        PatientMappingDO patientMappingDO = patientMappingDao.findByIdcardAndSource(patientDO.getIdcard(),"1");
        PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",patient,"1");
        if(patientMappingDO!=null){
            return patientMappingDO.getMappingCode();
        }
        com.alibaba.fastjson.JSONArray rs = ykyyEntranceService.findHisPatient(patientDO.getIdcard());
        com.alibaba.fastjson.JSONArray rs = ykyyEntranceService.findHisPatient(patientMedicareCardDO.getCode());
        if(rs!=null&&rs.size()>0){
            //获取居民信息

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

@ -18,5 +18,13 @@ public interface PrescriptionEmrDao extends PagingAndSortingRepository<WlyyPresc
    @Query("select a from WlyyPrescriptionEmrDO a where a.prescriptionId = ?1 and a.del=1 ")
    List<WlyyPrescriptionEmrDO> findByPrescriptionId(String prescriptionId);
    @Query("select a from WlyyPrescriptionEmrDO a where a.prescriptionId = ?1 and a.del=1 ")
    WlyyPrescriptionEmrDO findEmrByPrescriptionId(String prescriptionId);
    @Modifying
    @Query("update WlyyPrescriptionEmrDO p set p.del=0 where p.prescriptionId=?1")
    void deleteByPrescriptionId(String prescriptionId);
}

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

@ -200,6 +200,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    private BaseUserAgent userAgent;
    @Autowired
    private WlyyHospitalSysDictDao hospitalSysDictDao;
    @Value("${demo.flag}")
@ -451,6 +453,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                //检查检验信息
                List<WlyyInspectionVO> inspectionVOs = new ArrayList<>();
                vo.setInspectionVOs(convertToModels(wlyyInspectionDao.findByPrescriptionId(vo.getId(),1),inspectionVOs,WlyyInspectionVO.class));
                //电子病历
                vo.setWlyyPrescriptionEmrDO(prescriptionEmrDao.findEmrByPrescriptionId(vo.getId()));
            }
        }
        rs.put("prescriptions",prescriptionVOs);
@ -1832,7 +1837,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param diagnosisJson
     * @return
     */
    public Map<String, Object> makeDiagnosis(String outPatientId, String advice, String type, String infoJsons, String diagnosisJson, String inspectionJson) throws Exception {
    public Map<String, Object> makeDiagnosis(String outPatientId, String advice, String type, String infoJsons, String diagnosisJson, String inspectionJson,String emrJson) throws Exception {
        Map<String, Object> result = new HashedMap();
@ -1901,6 +1906,27 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        outpatientDao.save(outpatientDO);
        //============================下诊断end==============================================================
        //=====================电子病历=================================================start
        prescriptionEmrDao.deleteByPrescriptionId(prescription.getId());
        if (StringUtils.isNotBlank(emrJson)) {
            WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO = com.alibaba.fastjson.JSONObject.parseObject(emrJson,WlyyPrescriptionEmrDO.class);
            wlyyPrescriptionEmrDO.setDel(1);
            wlyyPrescriptionEmrDO.setPrescriptionId(prescription.getId());
            prescriptionEmrDao.save(wlyyPrescriptionEmrDO);
        }
        //=====================电子病历=================================================end
        //=====================保存日志 start=========================================================
        List<WlyyPrescriptionCheckDO> prescriptionCheckDOS = prescriptionCheckDao.findByStatus(prescription.getId(),5);
        if (prescriptionCheckDOS==null || prescriptionCheckDOS.size() ==0){
            savePrescriptionCheck(prescription.getDoctor(),"开具处方",5,prescription.getId());
        }
        if (prescriptionDOs != null && prescriptionDOs.size() > 0) {
            savePrescriptionCheck(prescription.getDoctor(),"处方修改",3,prescription.getId());
        }
        //=====================保存日志 end=========================================================
        //判断是否有检查检验或药品开方
        if ("1".equals(type)) {
@ -1968,19 +1994,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            }
            //=====================检查检验=======================================================================
            //保存挂号费用
            prescription.setRegFee(getChargeFee(outpatientDO.getDoctor()));
            //=====================保存日志 start=========================================================
            List<WlyyPrescriptionCheckDO> prescriptionCheckDOS = prescriptionCheckDao.findByStatus(prescription.getId(),5);
            if (prescriptionCheckDOS==null || prescriptionCheckDOS.size() ==0){
                savePrescriptionCheck(prescription.getDoctor(),"开具处方",5,prescription.getId());
            }
            if (prescriptionDOs != null && prescriptionDOs.size() > 0) {
                savePrescriptionCheck(prescription.getDoctor(),"处方修改",3,prescription.getId());
            }
            //=====================保存日志 end=========================================================
            //保存费用
            prescriptionDao.save(prescription);
            if (wechatId.equalsIgnoreCase("xm_ykyy_wx")){
@ -3949,6 +3966,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public Map<String,Object> findPatientInfo(String patient){
        Map<String,Object> rs = new HashedMap();
        BasePatientDO basePatientDO = basePatientDao.findById(patient);
        PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",patient,"1");
        rs.put("id",patient);
        rs.put("name",basePatientDO.getName());
        rs.put("sex",basePatientDO.getSex());
@ -3961,6 +3979,51 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        rs.put("idcard",basePatientDO.getIdcard());
        rs.put("age",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
        rs.put("mobile",basePatientDO.getMobile());
        if (patientMedicareCardDO!=null){
            rs.put("ssc",patientMedicareCardDO.getCode());
        }else {
            rs.put("ssc","");
        }
        return rs;
    }
    public Map<String,Object> updatePatientInfo(String patient,String name,String idcard,String ssc){
        Map<String,Object> rs = new HashedMap();
        BasePatientDO basePatientDO = basePatientDao.findById(patient);
        PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",patient,"1");
        basePatientDO.setName(name);
        basePatientDO.setIdcard(idcard);
        basePatientDO = basePatientDao.save(basePatientDO);
        if (patientMedicareCardDO!=null){
            patientMedicareCardDO.setCode(ssc);
            patientMedicareCardDO=basePatientMedicareCardDao.save(patientMedicareCardDO);
        }else {
            patientMedicareCardDO = new PatientMedicareCardDO();
            patientMedicareCardDO.setCode(ssc);
            patientMedicareCardDO.setType("A_01");
            patientMedicareCardDO.setParentType("A");
            patientMedicareCardDO.setDel("1");
            patientMedicareCardDO.setPatientCode(patient);
            patientMedicareCardDO=basePatientMedicareCardDao.save(patientMedicareCardDO);
        }
        rs.put("id",patient);
        rs.put("name",basePatientDO.getName());
        rs.put("sex",basePatientDO.getSex());
        rs.put("provinceCode",basePatientDO.getProvinceCode());
        rs.put("provinceName",basePatientDO.getProvinceName());
        rs.put("cityCode",basePatientDO.getCityCode());
        rs.put("cityName",basePatientDO.getCityName());
        rs.put("townCode",basePatientDO.getTownCode());
        rs.put("townName",basePatientDO.getTownName());
        rs.put("idcard",basePatientDO.getIdcard());
        rs.put("age",IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
        rs.put("mobile",basePatientDO.getMobile());
        if (patientMedicareCardDO!=null){
            rs.put("ssc",patientMedicareCardDO.getCode());
        }else {
            rs.put("ssc","");
        }
        return rs;
    }
@ -4048,6 +4111,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "room.patient_id=patient.id " +
                "AND room.outpatient_id=outpatient.id " +
                "AND consult.relation_code=outpatient.id " +
                "AND outpatient.pay_status=1 " +
                "AND consult.status = 0 ";
        if(StringUtils.isNoneBlank(doctor)){
            sql = sql +"AND room.doctor='"+doctor+"' " +
@ -4114,6 +4178,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "room.patient_id=patient.id " +
                "AND room.outpatient_id=outpatient.id " +
                "AND outpatient.status = 0 " +
                "AND outpatient.pay_status = 1 " +
                "AND room.doctor='"+doctor+"' " +
                "AND room.reservation_time is not null " +
                "AND room.consult_type= 2 ";/* +
@ -4261,7 +4326,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    
        //根据门诊唯一号取就诊记录
//        List<WlyyOutpatientDO> wlyyOutpatientDOs = outpatientDao.findByAdmNo(admNo);
        
        WlyyPrescriptionDO wlyyPrescriptionDOS = prescriptionDao.findByAdmNoAndRealOrder(admNo,realOrder);
        
        Object result = "";
@ -4362,7 +4427,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "base_patient patient " +
                "WHERE " +
                "outpatient.patient=patient.id " +
                "AND outpatient.status <> -1 " +
                "AND outpatient.status in (0,1) " +
                "AND outpatient.doctor='"+doctor+"' " +
                "AND outpatient.pay_status = 1 " +
                "AND outpatient.outpatient_type= '"+outpatient_type+"' ";
@ -5557,6 +5622,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                age = IdCardUtil.getAgeForIdcard(prescriptionDO.getIdcard());
                gender=IdCardUtil.getSexForIdcard(prescriptionDO.getIdcard());
            }
            BasePatientDO patientDO = basePatientDao.findById(prescriptionDO.getPatientCode());
            data.put("name",prescriptionDO.getPatientName());
            data.put("age",age);
            data.put("gender",gender);
@ -5567,6 +5633,27 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                systemMessageDO.setTitle("审方通过");
                data.put("message","审方通过");
                data.put("message","您为"+prescriptionDO.getPatientName()+"("+age+"岁 "+gender+")开具的处方已审核通过。");
                /**
                 *  * @param userName      推送人姓名
                 * @param idCard        推送人身份证
                 * @param phone         推送人手机号
                 * @param title         推送标题
                 * @param url           跳转链接
                 * @param content       内容简介
                 * @param contentString 内容明细串
                 */
               /* String idCard = "";
                String phone = "";
                String title="";
                String url = "https://hlwyy.xmzsh.com/ims-wx/#/returnVisit/record?outpatientId="+prescriptionDO.getOutpatientId();
                String content = "";
                String contentString = "";
                if (patientDO!=null){
                    idCard = patientDO.getIdcard();
                    phone = patientDO.getMobile();
                    title = patientDO.getName()+",您好!医生已为您开具处方,请及时支付";
                }
                entranceService.ehospitalNotice(prescriptionDO.getPatientName())*/
            } else if (status==1) {
                systemMessageDO.setType("8");
                systemMessageDO.setTitle("审方退回");
@ -5694,8 +5781,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public List<WlyyPrescriptionEmrDO> findByPrescriptionId(String  prescriptionId){
        return prescriptionEmrDao.findByPrescriptionId(prescriptionId);
    }
    
    
    /**
     * 保存排班规则
     * @param advicesJson
@ -5706,7 +5793,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        wlyyConsultAdviceDao.save(advices);
        return true;
    }
    
    /**
     * 获取咨询建议
     * @param consultcode
@ -5717,6 +5804,68 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    public String readOutPatient(String registerSn) throws Exception {
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("HAI_TAI_URL");
        if (wlyyHospitalSysDictDO!=null){
            url = wlyyHospitalSysDictDO.getDictCode();
        }
        String xmlStr = "<?xml version=\"1.0\" encoding=\"GBK\"?>\n" +
                "<HtRequest>\n";
        xmlStr+="<REGISTER_SN>"+registerSn+"</REGISTER_SN>";
        String reqTime = DateUtil.dateToStr(new Date(),"yyyyMMddHHmmssSSS");
        xmlStr+="<REQ_TIME>"+reqTime+"</REQ_TIME>";
        xmlStr+="</HtRequest>";
        String returnValue = "";
        Map<String, String> params = new HashedMap();
        params.put("type","readOutPatient");
        params.put("xmlStr",xmlStr);
        returnValue = com.yihu.jw.utils.WebserviceUtil.post(url,
                "http://business.htemr.haitaiinc.com",
                "manageOutRegister",
                params);
        logger.info("调用电子病历查询接口请求成功,返回值xmlstr:" + returnValue);
        return returnValue;
    }
    public String writeOutPatient(String registerSn,String chiefComplaint,String hpi,String elapsemhis,String bodycheck,String assistanTcheck) throws Exception {
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("HAI_TAI_URL");
        if (wlyyHospitalSysDictDO!=null){
            url = wlyyHospitalSysDictDO.getDictCode();
        }
        String xmlStr = "<?xml version=\"1.0\" encoding=\"GBK\"?>\n" +
                "<HtRequest>\n";
        xmlStr+="<REGISTER_SN>"+registerSn+"</REGISTER_SN>";
        String reqTime = DateUtil.dateToStr(new Date(),"yyyyMMddHHmmssSSS");
        xmlStr+="<REQ_TIME>"+reqTime+"</REQ_TIME>";
        xmlStr+="<OUTPATIENT_INFO>";
        xmlStr+="<CHIEF_COMPLAINT>"+chiefComplaint+"</CHIEF_COMPLAINT>";
        xmlStr+="<HPI>"+hpi+"</HPI>";
        xmlStr+="<ELAPSEMHIS>"+elapsemhis+"</ELAPSEMHIS>";
        xmlStr+="<BODYCHECK>"+bodycheck+"</BODYCHECK>";
        xmlStr+="<ASSISTANTCHECK>"+assistanTcheck+"</ASSISTANTCHECK>";
        xmlStr+="</OUTPATIENT_INFO>";
        xmlStr+="</HtRequest>";
        String returnValue = "";
        Map<String, String> params = new HashedMap();
        params.put("type","writeOutPatient");
        params.put("xmlStr",xmlStr);
        returnValue = com.yihu.jw.utils.WebserviceUtil.post(url,
                "http://business.htemr.haitaiinc.com",
                "manageOutRegister",
                params);
        logger.info("调用电子病历写入接口请求成功,返回值xmlstr:" + returnValue);
        return returnValue;
    }
    /**
     * 关注医生
     * @param doctorId

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

@ -9,16 +9,22 @@ import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
import com.yihu.jw.entity.hospital.doctor.BaseDoctorZsInfoDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionEmrDO;
import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.DoctorZsInfoDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionEmrDao;
import com.yihu.jw.hospital.prescription.service.entrance.util.ConvertUtil;
import com.yihu.jw.hospital.prescription.service.entrance.util.MqSdkUtil;
import com.yihu.jw.hospital.prescription.service.entrance.util.WebserviceUtil;
@ -31,6 +37,8 @@ import com.yihu.jw.util.idcard.IdCardUtil;
import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.xml.XMLSerializer;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.XMLType;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
@ -43,7 +51,12 @@ import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
@ -116,6 +129,12 @@ public class EntranceService {
    private PrescriptionDao prescriptionDao;
    @Autowired
    private DoctorZsInfoDao doctorZsInfoDao;
    @Autowired
    private WlyyHospitalSysDictDao hospitalSysDictDao;
    @Autowired
    private PrescriptionEmrDao prescriptionEmrDao;
    @Autowired
    private OutpatientDao outpatientDao;
    private static String entranceUrl="http://172.16.100.240:10023/mqsdk/";
//    private static String entranceUrl="http://localhost:10023/mqsdk/";
@ -2650,4 +2669,46 @@ public class EntranceService {
//=====================hospital应用调用entrance应用============end=================
/*
    *
     * 请求海康接口方法
     * @param method
     * @param type
     * @param xmlStr
     * @return
     * @throws Exception
    public String sendHaiTaiMethod(String method,String type,String xmlStr) throws Exception {
        String url = "";
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("HAI_TAI_URL");
        if (wlyyHospitalSysDictDO!=null){
            url = wlyyHospitalSysDictDO.getDictCode();
        }
        if (!StringUtils.isNoneBlank(url)){
            throw new Exception("url 不存在!");
        }
        logger.info("请求参数:method"+method+"==type"+type+"==="+xmlStr);
        String result = null;
        try {
            org.apache.axis.client.Service service = new org.apache.axis.client.Service();
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(new URL(url));
            call.setOperationName(new QName(url, method)); // 设置要调用哪个方法
            call.addParameter("type", XMLType.XSD_STRING, ParameterMode.IN);
            call.addParameter("xmlStr",XMLType.XSD_STRING, ParameterMode.IN);
            call.setReturnType(XMLType.XSD_STRING);
            String xml = (String)call.invoke(new Object[]{type,xmlStr});
            logger.info("返回值:"+xml);
            XMLSerializer xmlSerializer = new XMLSerializer();
            result = xmlSerializer.read(xml).toString();
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
*/
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java

@ -883,7 +883,7 @@ public class XzzxEntranceService{
            condition +="<dept>"+dept+"</dept>";
        }
        if (!StringUtils.isEmpty(sickId)&&!sickId.equalsIgnoreCase("null")){
            condition += "<sickId>"+sickId+"</sickId>";
            condition += "<sickid>"+sickId+"</sickid>";
        }
        if (!StringUtils.isEmpty(clinicclass)&&!clinicclass.equalsIgnoreCase("null")){

+ 48 - 12
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java

@ -15,6 +15,7 @@ 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.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.score.BaseEvaluateDO;
import com.yihu.jw.entity.base.score.BaseEvaluateScoreDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
@ -31,6 +32,7 @@ import com.yihu.jw.hospital.prescription.dao.PrescriptionDiagnosisDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
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.WlyyPrescriptionDiagnosisVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
@ -131,6 +133,8 @@ public class YkyyEntranceService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private DictDoctorDutyDao dictDoctorDutyDao;
    @Autowired
    private BasePatientMedicareCardDao patientMedicareCardDao;
    @Autowired
    private YkyyService ykyyService;
@ -1101,17 +1105,17 @@ public class YkyyEntranceService {
                "yp.pzwh as \"pzwh\""+  " FROM " +
                "V_ZKSG_MZ_YPXX yp where 1=1 ";
        if (StringUtils.isNoneBlank(ypdm)){
            sql+=" and yp.ypdm like '%"+ypdm+"%' ";
            sql+=" and lower(yp.ypdm) like '%"+ypdm.toLowerCase()+"%' ";
        }
        if (StringUtils.isNoneBlank(ypmc)){
            sql+=" and yp.ypmc like '%"+ypmc+"%' ";
            sql+=" and lower(yp.ypmc) like '%"+ypmc.toLowerCase()+"%' ";
        }
        if (StringUtils.isNoneBlank(kusl)){
            sql+=" and yp.kusl like '%"+kusl+"%' ";
            sql+=" and lower(yp.kusl) like '%"+kusl.toLowerCase()+"%' ";
        }
        if (StringUtils.isNoneBlank(pydm)){
            sql+=" and yp.pydm like '%"+pydm+"%' ";
            sql+=" and lower(yp.pydm) like '%"+pydm.toLowerCase()+"%' ";
        }
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
@ -1175,7 +1179,7 @@ public class YkyyEntranceService {
                "FROM\n" +
                "\tV_ZKSG_JCXM_MZ mz where 1=1 ";
        if (StringUtils.isNoneBlank(pydm)){
            sql+=" and pydm = '%"+pydm+"%'";
            sql+=" and lower(pydm) = '%"+pydm.toLowerCase()+"%'";
        }
        /*List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);*/
        JSONArray array = new JSONArray();
@ -1201,7 +1205,7 @@ public class YkyyEntranceService {
    public JSONArray findSypc(String pcbm) throws Exception {
        String sql = "select s.pcbm as \"pcbm\",s.pcmc as \"pcmc\",s.pcmc1 as \"pcmc1\" from v_hlw_sypc s where 1=1 ";
        if (StringUtils.isNoneBlank(pcbm)){
            sql+=" and s.pcbm='"+pcbm+"' ";
            sql+=" and lower(s.pcbm)='"+pcbm.toLowerCase()+"' ";
        }
        /*List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
        return list;*/
@ -1227,7 +1231,7 @@ public class YkyyEntranceService {
    public JSONArray findYpyf(String pydm) throws Exception {
        String sql = "select y.ypyf as \"ypyf\",y.pydm as \"pydm\",y.xmmc as \"xmmc\" from v_hlw_ypyf y where 1=1  and y.pydm is not null";
        if (StringUtils.isNoneBlank(pydm)){
            sql+=" and y.pydm='"+pydm+"' ";
            sql+=" and lower(y.pydm)='"+pydm.toLowerCase()+"' ";
        }
        /*List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
        return list;*/
@ -1249,11 +1253,11 @@ public class YkyyEntranceService {
    /**
     * 获取his病人信息
     * @param idcard
     * @param ssc
     * @return
     * @throws Exception
     */
    public JSONArray findHisPatient(String idcard) throws Exception {
    public JSONArray findHisPatient(String ssc) throws Exception {
        String sql = "SELECT\n" +
                "\tx.brid AS \"brid\",\n" +
                "\tx.mzhm AS \"mzhm\",\n" +
@ -1271,7 +1275,7 @@ public class YkyyEntranceService {
                "FROM\n" +
                "\tV_ZKSG_BRCX x\n" +
                "WHERE\n" +
                "\tx.sfzh = '"+idcard+"' ";
                "\tx.jzkh = '"+ssc+"' ";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
@ -1316,7 +1320,7 @@ public class YkyyEntranceService {
        String sql = "select i.code as \"code\",i.name as \"name\",i.disea_reason as \"disea_reason\",i.death_reason as \"death_reason\",i.py_code as \"py_code\",i.flag as \"flag\",i.add_code as \"add_code\",i.emr as \"emr\" from v_hlw_icd10 i";
        JSONArray array = new JSONArray();
        if (StringUtils.isNoneBlank(pyCode)){
            sql +="  where i.py_code like '%"+pyCode+"%'";
            sql +="  where lower(i.py_code) like '%"+pyCode.toLowerCase()+"%'";
        }
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
@ -1467,6 +1471,9 @@ public class YkyyEntranceService {
        DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
        String patient = wlyyPrescriptionVO.getPatientCode();
        PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
        BasePatientDO patientDO = basePatientDao.findById(patient);
        PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",patient,"1");
        Integer GHXH = 0;
        //挂号明细表HLW_GHMX
@ -1496,7 +1503,7 @@ public class YkyyEntranceService {
        hlwGhmxDO.setYSDM(doctorMappingDO.getMappingCode());//医生代码
        hlwGhmxDO.setJZYS(doctorMappingDO.getMappingCode());//接诊医生
        //病人性质
        JSONArray jsonArray = findHisPatient(patientMappingDO.getIdcard());
        JSONArray jsonArray = findHisPatient(patientMedicareCardDO.getCode());
        if(jsonArray!=null&&jsonArray.size()>0){
            //获取居民信息
            JSONObject json = jsonArray.getJSONObject(0);
@ -1554,6 +1561,16 @@ public class YkyyEntranceService {
        }
        Integer icd10Flag = 0;
        //诊断删除v_hlwys_mz_jzls
        if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getAdmNo())){
            String deleteSql = "delete from v_hlwys_mz_jzls where jzxh = '"+wlyyPrescriptionVO.getAdmNo()+"'";
            Map<String,Object> params = new HashedMap();
            params.put("sql",deleteSql);
            HttpResponse response = HttpUtils.doGet(updateUrl,params);
            if (response.getStatus()==200){
                logger.info("表v_hlwys_mz_jzls删除成功!");
            }
        }
        List<WlyyPrescriptionDiagnosisDO> diagnosisDOs = prescriptionDiagnosisDao.findByPrescriptionId(code,1);
        if(diagnosisDOs!=null&&diagnosisDOs.size()>0){
            WlyyPrescriptionDiagnosisDO diagnosisDO = diagnosisDOs.get(0);
@ -1610,6 +1627,16 @@ public class YkyyEntranceService {
                logger.info("表hlwYsMzJzLsDO同步成功!");
            }
            //删除疾病诊断表HLWYS_MZ_JBZD
            if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getAdmNo())){
                String deleteSql = "delete from v_hlwys_mz_jbzd where jzxh = '"+wlyyPrescriptionVO.getAdmNo()+"'";
                Map<String,Object> params = new HashedMap();
                params.put("sql",deleteSql);
                HttpResponse response = HttpUtils.doGet(updateUrl,params);
                if (response.getStatus()==200){
                    logger.info("表v_hlwys_mz_jbzd删除成功!");
                }
            }
            //疾病诊断表HLWYS_MZ_JBZD
            HlwYsMzJbzdDO hlwYsMzJbzdDO = new HlwYsMzJbzdDO();
            //hlwYsMzJbzdDO.setJLBH(0);
@ -1748,6 +1775,15 @@ public class YkyyEntranceService {
                if (StringUtils.isEmpty(cfsb)){
                    throw new Exception("添加失败");
                }
                if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getRealOrder())){
                    String deleteSql = "delete from v_ms_dd02 where cfsb = '"+wlyyPrescriptionVO.getRealOrder()+"'";
                    Map<String,Object> params1 = new HashedMap();
                    params1.put("sql",deleteSql);
                    HttpResponse response = HttpUtils.doGet(updateUrl,params1);
                    if (response.getStatus()==200){
                        logger.info("表v_ms_dd02删除成功!");
                    }
                }
                List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS =wlyyPrescriptionVO.getInfoVOs();
                for (WlyyPrescriptionInfoVO wlyyPrescriptionInfoVO:wlyyPrescriptionInfoVOS){
                    try {

+ 7 - 0
business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java

@ -834,6 +834,13 @@ public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO,
                String msg = "";
                String msgType = "";
                if (map.get("content_type").toString().equalsIgnoreCase("2")){
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("sender","系统");
                    jsonObject.put("msg","病情描述");
                    jsonObject.put("msg_type","0");
                    jsonObject.put("receiver","系统");
                    jsonObject.put("send_time",DateUtil.dateToStr(DateUtil.strToDate(map.get("timestamp").toString(),"yyyy-MM-dd HH:mm:ss"),"yyyy-MM-dd HH:mm:ss"));
                    array.add(jsonObject);
                    msg = consultUpNsOnlineImg(map.get("content").toString(),map.get("id").toString());
                    msgType = "1";
                }else if (map.get("content_type").toString().equalsIgnoreCase("1")){

+ 4 - 2
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -392,8 +392,10 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        if(!StringUtils.isNoneBlank(tradeType)){
            throw new Exception("tradeType is null :the tradeType is "+tradeType);
        }
        if(!StringUtils.isNoneBlank(openId)){
            throw new Exception("openId is null :the openId is "+openId);
        if (tradeType.equalsIgnoreCase("JSAPI")){
            if(!StringUtils.isNoneBlank(openId)){
                throw new Exception("openId is null :the openId is "+openId);
            }
        }
        if(!StringUtils.isNoneBlank(ourTradeNo)){
            throw new Exception("ourTradeNo is null :the ourTradeNo is "+ourTradeNo);

+ 1 - 0
business/base-service/src/main/java/com/yihu/jw/utils/hibernate/HibenateUtils.java

@ -185,4 +185,5 @@ public class HibenateUtils {
    }
}

+ 1 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatInfoService.java

@ -98,6 +98,7 @@ public class WechatInfoService {
                String token_url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket";
                String params = "access_token=" + token + "&type=jsapi";
                String result = HttpUtil.sendGet(token_url, params);
                System.out.println("result:"+result);
                JSONObject json = new JSONObject(result);
                System.out.println("getticket:"+result);
                if (json.has("ticket")) {

+ 4 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/service/WxTemplateService.java

@ -99,6 +99,8 @@ public class WxTemplateService {
    private BaseDoctorDao doctorDao;
    @Autowired
    private PrescriptionLogService prescriptionLogService;
    
    
    /**
@ -195,6 +197,8 @@ public class WxTemplateService {
                            String prescriptionId = pre.get(0).get("ID").toString();
                            String doctorName = pre.get(0).get("DOCTOR_NAME").toString();
                            //判断是否发送过
                            String countSql = "SELECT id from WX_PUSH_LOG w WHERE w.RECEIVER = '"+patientDO.getId()
                                    +"' and w.OPENID = '"+prescriptionId+"' and w.scene = 'djsxxtz' and w.WECHAT_ID='"+wechatId+"'";

+ 3 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java

@ -25,7 +25,9 @@ public abstract class IntegerIdentityEntity implements Serializable {
//==========mysql 环境 id策略 end======================================================
//==========Oracle 环境id策略 =========================================================
/*    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")*/
/*
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")
*/
//==========Oracle 环境id策略 =========================================================
    public Integer getId() {
        return id;

+ 62 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/UuidIdentityEntityWithTime.java

@ -0,0 +1,62 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.util.Date;
/**
 * 统一定义id的entity基类.
 * 主键生成策略是UUID
 * 还包含业务表用的 创建时间 ,修改时间
 * @author calvin
 */
// JPA 基类的标识
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class UuidIdentityEntityWithTime extends UuidIdentityEntity {
    //创建时间
	@CreatedDate
	protected Date createTime;
    //更新时间 数据库设置自动更新
    @LastModifiedDate
	protected Date updateTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time", nullable = false, length = 0,updatable = false)
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	@Column(name = "update_time", nullable = false, length = 0)
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/module/ModuleDO.java

@ -237,7 +237,7 @@ public class ModuleDO extends UuidIdentityEntityWithOperator {
		this.isMust = isMust;
	}
	@Column(name = "level")
	@Column(name = "module_level")
	public Integer getLevel() {
		return level;
	}

+ 100 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/device/IotDeviceInventoryWarningDO.java

@ -0,0 +1,100 @@
package com.yihu.jw.entity.iot.device;
import com.yihu.jw.entity.UuidIdentityEntityWithTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 设备库存预警设置
 * @author yeshijie on 2020/06/01.
 */
@Entity
@Table(name = "iot_device_inventory_warning")
public class IotDeviceInventoryWarningDO extends UuidIdentityEntityWithTime implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "product_id")
    private String productId;//产品id
    @Column(name = "product_name")
    private String productName;//设备名称
    @Column(name = "hospital")
    private String hospital;//归属社区
    @Column(name = "hospital_name")
    private String hospitalName;//归属社区名称 单位
    @Column(name = "inventory_upper")
    private Integer inventoryUpper;//库存上限提醒值 -- 库存字段,无效-移到 IotDeviceInventoryWarningDO
    @Column(name = "inventory_floor")
    private Integer inventoryFloor;//库存下限提醒值
    @Column(name = "del")
    private Integer del;//删除标志(1有效,0删除)
    public String getProductName() {
        return productName;
    }
    public void setProductName(String productName) {
        this.productName = productName;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getProductId() {
        return productId;
    }
    public void setProductId(String productId) {
        this.productId = productId;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public Integer getInventoryUpper() {
        return inventoryUpper;
    }
    public void setInventoryUpper(Integer inventoryUpper) {
        this.inventoryUpper = inventoryUpper;
    }
    public Integer getInventoryFloor() {
        return inventoryFloor;
    }
    public void setInventoryFloor(Integer inventoryFloor) {
        this.inventoryFloor = inventoryFloor;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/iot/product/IotProductBaseInfoDO.java

@ -78,7 +78,7 @@ public class IotProductBaseInfoDO extends UuidIdentityEntityWithOperator impleme
    @Column(name = "category_code")
    private String categoryCode;//设备类型标识
    @Column(name = "inventory_upper")
    private Integer inventoryUpper;//库存上限提醒值
    private Integer inventoryUpper;//库存上限提醒值 -- 库存字段,无效-移到 IotDeviceInventoryWarningDO
    @Column(name = "inventory_floor")
    private Integer inventoryFloor;//库存下限提醒值

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

@ -43,6 +43,10 @@ public class BaseHospitalRequestMapping {
         * 获取门诊记录
         */
        public static final String findOutpatientList = "/findOutpatientList";
        /**
         * 修改居民信息
         */
        public static final String updatePatientInfo = "/updatePatientInfo";
        /**
         * 查询单条门诊记录接口
@ -425,6 +429,8 @@ public class BaseHospitalRequestMapping {
         */
        public static final String attentionDoctor="/attentionDoctor";
        public static final String findAllAttentionDoctor="/findAllAttentionDoctor";
        public static final String findHisEmr="/findHisEmr";
    }

+ 5 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/iot/IotRequestMapping.java

@ -231,6 +231,11 @@ public class IotRequestMapping {
        public static final String getDeviceInventoryLog = "getDeviceInventoryLog";
        public static final String getDeviceInventoryLogDetail = "getDeviceInventoryLogDetail";
        //预警
        public static final String getInventoryWarningHospital = "getInventoryWarningHospital";
        public static final String getInventoryWarningName = "getInventoryWarningName";
        //设备调拨
        public static final String getDeviceTransfersList = "getDeviceTransfersList";
        public static final String createDeviceTransfers = "createDeviceTransfers";

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

@ -1,6 +1,7 @@
package com.yihu.jw.restmodel.hospital.prescription;
import com.yihu.jw.entity.hospital.prescription.WlyyInspectionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionEmrDO;
import com.yihu.jw.restmodel.UuidIdentityVOWithOperator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -370,6 +371,9 @@ public class WlyyPrescriptionVO extends UuidIdentityVOWithOperator {
    @ApiModelProperty(value = "检查检验", example = "模块1")
    private List<WlyyInspectionVO> inspectionVOs;
    @ApiModelProperty(value = "电子病历", example = "模块1")
    private WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO;
    public String getOutpatientId() {
        return outpatientId;
    }
@ -823,4 +827,12 @@ public class WlyyPrescriptionVO extends UuidIdentityVOWithOperator {
    public void setPayType(Integer payType) {
        this.payType = payType;
    }
    public WlyyPrescriptionEmrDO getWlyyPrescriptionEmrDO() {
        return wlyyPrescriptionEmrDO;
    }
    public void setWlyyPrescriptionEmrDO(WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO) {
        this.wlyyPrescriptionEmrDO = wlyyPrescriptionEmrDO;
    }
}

+ 45 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/common/BaseTimeVO.java

@ -0,0 +1,45 @@
package com.yihu.jw.restmodel.iot.common;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
 * @author yeshijie on 2020/6/1.
 */
public class BaseTimeVO {
    protected String id;  // 非业务主键
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    protected Date createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    protected Date updateTime;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 87 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotDeviceInventoryWarningVO.java

@ -0,0 +1,87 @@
package com.yihu.jw.restmodel.iot.device;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.yihu.jw.restmodel.iot.common.BaseTimeVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
/**
 * 设备库存预警设置
 * @author yeshijie on 2020/6/1.
 */
@JsonInclude(JsonInclude.Include.ALWAYS)
@ApiModel(value = "设备库存预警设置", description = "设备库存预警设置")
public class IotDeviceInventoryWarningVO extends BaseTimeVO implements Serializable {
    @ApiModelProperty("产品id")
    private String productId;
    @ApiModelProperty("设备名称")
    private String productName;
    @ApiModelProperty("归属社区")
    private String hospital;
    @ApiModelProperty("归属社区名称")
    private String hospitalName;
    @ApiModelProperty("库存上限提醒值")
    private Integer inventoryUpper;
    @ApiModelProperty("库存下限提醒值")
    private Integer inventoryFloor;
    @ApiModelProperty("删除标志(1有效,0删除)")
    private Integer del;//
    public String getProductId() {
        return productId;
    }
    public void setProductId(String productId) {
        this.productId = productId;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getProductName() {
        return productName;
    }
    public void setProductName(String productName) {
        this.productName = productName;
    }
    public Integer getInventoryUpper() {
        return inventoryUpper;
    }
    public void setInventoryUpper(Integer inventoryUpper) {
        this.inventoryUpper = inventoryUpper;
    }
    public Integer getInventoryFloor() {
        return inventoryFloor;
    }
    public void setInventoryFloor(Integer inventoryFloor) {
        this.inventoryFloor = inventoryFloor;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

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

@ -226,10 +226,13 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        String wechatId = parameters.get("wechatId");
        //更新患者openId
        BaseLoginLogDO baseLoginLogDO = new BaseLoginLogDO();
        logger.info("gengxin开始");
        if (!StringUtils.isEmpty(openid) && !"undefined".equalsIgnoreCase(openid) && ("3".equals(loginType)||"4".equalsIgnoreCase(loginType))) {
            baseLoginLogDO.setOpenid(openid);
            logger.info("gengxin进入"+openid);
            userDetailsService.updateOpenId(openid, wlyyUserSimple.getId());
            if (!StringUtils.isEmpty(wechatId)&& !"undefined".equalsIgnoreCase(wechatId)){
                logger.info("gengxin进入"+wechatId);
                userDetailsService.updateOpenIdAndWechatId(openid,wlyyUserSimple.getId(),wechatId);
            }
        }

+ 2 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/utils/RSAUtils.java

@ -49,11 +49,13 @@ public class RSAUtils {
        try {
            Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
            Cipher cipher = Cipher.getInstance("RSA/None/PKCS1Padding", "BC");
            System.out.println("keyPair.getPublic():"+keyPair.getPublic());
            RSAPrivateKey pbk = (RSAPrivateKey)keyPair.getPrivate();
            cipher.init(Cipher.DECRYPT_MODE, pbk);
            byte[] plainText = cipher.doFinal(string);
            return plainText;
        }catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }

+ 9 - 6
svr/svr-base/src/main/java/com/yihu/jw/base/service/org/BaseOrgService.java

@ -14,6 +14,7 @@ import com.yihu.jw.entity.base.org.BaseOrgSaasDO;
import com.yihu.jw.entity.base.org.BaseOrgUserDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -65,6 +66,9 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private HibenateUtils hibenateUtils;
    /**
     * 机构基础信息列表
@ -77,7 +81,7 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;
        String codeOrNameValue = null == codeOrName ? "" : codeOrName;
        String sql = "select id,code,name,case del when 1 then '有效' else '失效' end as status,concat(province_name,city_name,town_name,address) as address " +
        String sql = "select id as \"id\",code as \"code\",name as \"name\",case del when 1 then '有效' else '失效' end as status as \"del\",concat(province_name,city_name,town_name,address) as \"address\" " +
                " from base_org " +
                " where " +
                " ((code like '{code}' or ''='{code}')  and (del = '{orgStatus}' or ''='{orgStatus}'))" +
@ -85,13 +89,12 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
                " ((name like '{name}' or ''='{name}') and (del = '{orgStatus}' or ''='{orgStatus}'))" +
                " and" +
                " (del = '{orgStatus}' or ''='{orgStatus}')" +
                "  order by create_time desc limit {start},{end}";
                "  order by create_time desc ";
        String finalSql = sql
                .replace("{code}", "%" + codeOrNameValue + "%")
                .replace("{name}", "%" + codeOrNameValue + "%")
                .replace("{orgStatus}", null == orgStatus ? "" : orgStatus).replace("{start}", String.valueOf(start))
                .replace("{end}", String.valueOf(end));
                .replace("{orgStatus}", null == orgStatus ? "" : orgStatus);
        String countSql = "SELECT count(id)" +
                " FROM base_org " +
@ -105,7 +108,7 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
                .replace("{code}", "%" + codeOrNameValue + "%")
                .replace("{name}", "%" + codeOrNameValue + "%")
                .replace("{orgStatus}", null == orgStatus ? "" : orgStatus);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(finalSql);
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(finalSql,page,size);
        Integer count = jdbcTemplate.queryForObject(finalCountSql, Integer.class);
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
@ -267,7 +270,7 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
    public String getOrgAreaTree(String saasId){
        StringBuffer sql = new StringBuffer("SELECT t.* from base_org b,org_tree t,base_org_saas o ")
                .append("WHERE o.saasid='").append(saasId).append("' AND o.org_code = b.`code` AND ")
                .append("(b.`code`= t.`code` or b.city_code=t.`code` or b.province_code = t.`code` or b.town_code=t.`code`)");
                .append("(b.code= t.code or b.city_code=t.code or b.province_code = t.code or b.town_code=t.code)");
        List<TreeNode> treeNodes = new ArrayList<>();
        treeNodes.addAll(jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(OrgTree.class)));

+ 18 - 18
svr/svr-base/src/main/java/com/yihu/jw/base/service/team/BaseTeamService.java

@ -19,6 +19,7 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.team.BaseTeamMemberDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -62,6 +63,8 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
    @Autowired
    private OrgTreeService orgTreeService;
    @Autowired
    private HibenateUtils hibenateUtils;
    /**
     * 新增团队
@ -239,12 +242,12 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
        //获取该机构下的医生列表
        String sql = " SELECT " +
                "  hos.doctor_code AS doctorCode," +
                "  doc.name AS doctorName," +
                "  org.code  AS orgCode," +
                "  org.name     AS orgName," +
                "  dept.code    AS deptCode," +
                "  dept.name    AS deptName" +
                "  hos.doctor_code AS \"doctorCode\"," +
                "  doc.name AS \"doctorName\"," +
                "  org.code  AS \"orgCode\"," +
                "  org.name     AS \"orgName\"," +
                "  dept.code    AS \"deptCode\"," +
                "  dept.name    AS \"deptName\"" +
                " FROM " +
                "  base_doctor_hospital hos," +
                "  dict_hospital_dept dept," +
@ -302,18 +305,18 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
     */
    public JSONObject getTeamInfoList(String teamName,String orgCode,String status,int page,int size,JSONObject userAgent) throws Exception {
        JSONObject result = new JSONObject();
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;
      /*  int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;*/
        String teamNameValue = null == teamName ? "" : teamName;
        String orgCodeValue = null == orgCode ? "" : orgCode;
        String statusValue = null == status ? "" : status;
        String sql = " " +
                "SELECT " +
                "  team.id as teamId, " +
                "  team.name as name, " +
                "  case team.del when 0 then '已失效' when 1 then '生效中' end status, " +
                "  org.name as orgName " +
                "  team.id as \"teamId\", " +
                "  team.name as \"name\", " +
                "  case team.del when 0 then '已失效' when 1 then '生效中' end status as \"del\", " +
                "  org.name as \"orgName\" " +
                "FROM " +
                "  base_team team, " +
                "  base_org org " +
@ -322,15 +325,12 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
                "  and (team.name like '{teamName}' or '' ='{teamName}') " +
                "  and (team.org_code = '{orgCode}' or '' = '{orgCode}') " +
                "  and ( team.del = '{status}' or '' = '{status}') " +
                " ORDER BY team.create_time DESC " +
                " limit {start},{end} ";
                " ORDER BY team.create_time DESC " ;
        String finalSql = sql
                .replace("{teamName}","%" + teamNameValue + "%")
                .replace("{orgCode}",orgCodeValue)
                .replace("{status}",statusValue)
                .replace("{start}", String.valueOf(start))
                .replace("{end}", String.valueOf(end));
                .replace("{status}",statusValue);
        String countSql = "SELECT " +
                "  count(team.id) " +
@ -347,7 +347,7 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
                .replace("{orgCode}",orgCodeValue)
                .replace("{status}",statusValue);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(finalSql);
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(finalSql,page,size);
        int count = jdbcTemplate.queryForObject(finalCountSql,Integer.class);
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));

+ 15 - 15
svr/svr-base/src/main/java/com/yihu/jw/base/service/user/UserService.java

@ -21,6 +21,7 @@ import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.apache.commons.collections.map.HashedMap;
@ -69,6 +70,8 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
    
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Value("${configDefault.saasId}")
    private String defaultSaasId;
@ -622,20 +625,20 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
     */
    public JSONObject userInfoList(String name,String saasid,String roleId,int page,int size) throws Exception {
        JSONObject result = new JSONObject();
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;
   /*     int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;*/
        String realName = null == name ? "" : name;
        String saasidValue = null == saasid ? "" : saasid;
        String roleIdValue = null == roleId ? "" : roleId;
        String sql = "SELECT " +
                "  user.id as id, " +
                "  user.name as realName, " +
                "  user.username as username, " +
                "  case user.enabled when 0 then '已失效' when 1 then '生效中' end status, " +
                "  user.mobile, " +
                "  saas.name as saasName, " +
                "  role.name as roleName " +
                "  user.id as \"id\", " +
                "  user.name as \"realName\", " +
                "  user.username as \"username\", " +
                "  case user.enabled when 0 then '已失效' when 1 then '生效中' end status as \"enabled\", " +
                "  user.mobile as \"mobile\", " +
                "  saas.name as \"saasName\", " +
                "  role.name as \"roleName\" " +
                " FROM " +
                "  base_user user, " +
                "  base_saas saas, " +
@ -647,14 +650,11 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
                " and (user.name like '{realName}' or '' ='{realName}') " +
                "  and (saas.id = '{saasid}' or '' = '{saasid}') " +
                "  and ( user.role_id = '{roleId}' or '' = '{roleId}') " +
                " ORDER BY user.create_time DESC" +
                "  limit {start},{end} ";
                " ORDER BY user.create_time DESC";
        String finalSql = sql
                .replace("{realName}","%" + realName + "%")
                .replace("{saasid}",saasidValue)
                .replace("{roleId}",roleIdValue)
                .replace("{start}",String.valueOf(start))
                .replace("{end}",String.valueOf(end));
                .replace("{roleId}",roleIdValue);
        String countSql = "SELECT " +
                "  count(user.id) " +
@ -674,7 +674,7 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
                .replace("{saasid}",  saasidValue )
                .replace("{roleId}",  roleIdValue );
        List<Map<String, Object>> list = jdbcTemplate.queryForList(finalSql);
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(finalSql,page,size);
        Integer count = jdbcTemplate.queryForObject(finalCountSql, Integer.class);
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));

+ 32 - 29
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java

@ -11,6 +11,7 @@ import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.wechat.WeiXinMessageUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.dao.WxTemplateDao;
@ -56,33 +57,35 @@ public class WechatService {
    private WxAccessTokenService wxAccessTokenService;
    @Autowired
    private UserAgent userAgent;
    @Autowired
    private HibenateUtils hibenateUtils;
    //====================微信与租户管理=======================
    public MixEnvelop getWxWechatList(String name,String saasName,Integer status,Integer publicType,Integer page,Integer size){
        String sql = "SELECT " +
                " w.id, " +
                " w.name, " +
                " w.`status`, " +
                " w.type, " +
                " w.public_type AS publicType," +
                " w.token," +
                " w.enc_type AS encType," +
                " w.type," +
                " w.app_id AS appId," +
                " w.app_secret AS appSecret," +
                " w.app_origin_id AS appOriginId," +
                " w.base_url AS baseUrl," +
                " w.user_name AS userName," +
                " w.password," +
                " w.remark," +
                " w.create_time AS createTime," +
                " w.create_user AS createUser," +
                " w.create_user_name AS createUserName," +
                " w.update_time AS updateTime," +
                " w.update_user AS updateUser," +
                " w.update_user_name AS updateUserName" +
                " w.id AS \"id\", " +
                " w.name as \"name\", " +
                " w.status AS \"status\", " +
                " w.type as \"type\", " +
                " w.public_type AS \"publicType\"," +
                " w.token AS \"token\"," +
                " w.enc_type AS \"encType\"," +
                " w.type as \"type\"," +
                " w.app_id AS \"appId\"," +
                " w.app_secret AS \"appSecret\"," +
                " w.app_origin_id AS \"appOriginId\"," +
                " w.base_url AS \"baseUrl\"," +
                " w.user_name AS \"userName\"," +
                " w.password AS \"password\"," +
                " w.remark AS \"remark\"," +
                " w.create_time AS \"createTime\"," +
                " w.create_user AS \"createUser\"," +
                " w.create_user_name AS \"createUserName\"," +
                " w.update_time AS \"updateTime\"," +
                " w.update_user AS \"updateUser\"," +
                " w.update_user_name AS \"updateUserName\"" +
                " FROM " +
                " wx_wechat w ";
        if (StringUtils.isNotBlank(saasName)) {
@ -135,7 +138,7 @@ public class WechatService {
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(countSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
            count = Long.parseLong(rstotal.get(0).get("total").toString()) ;
        }
        return MixEnvelop.getSuccessListWithPage(BaseRequestMapping.WeChat.api_success, list, page, size, count);
@ -143,8 +146,8 @@ public class WechatService {
    public List<WxSaasVO> getWxSaasVOs(String id){
        String sql ="SELECT " +
                " bs.`name` AS saasName, " +
                " bs.id AS saasid" +
                " bs.`name` AS \"saasName\", " +
                " bs.id AS \"saasid\"" +
                " FROM " +
                " wx_wechat_saas s " +
                " JOIN base_saas bs ON bs.id = s.saas_id " +
@ -248,7 +251,7 @@ public class WechatService {
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
            count = Long.parseLong(rstotal.get(0).get("total").toString());
        }
        String sql = "SELECT " +
@ -343,7 +346,7 @@ public class WechatService {
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sqlTotal);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
            count = Long.parseLong(rstotal.get(0).get("total").toString()) ;
        }
        String sql = "SELECT " +
@ -481,7 +484,7 @@ public class WechatService {
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
            count =Long.parseLong(rstotal.get(0).get("total").toString()) ;
        }
        String sql = "SELECT " +
@ -576,7 +579,7 @@ public class WechatService {
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
            count = Long.parseLong(rstotal.get(0).get("total").toString()) ;
        }
        String sql = "SELECT " +
@ -635,7 +638,7 @@ public class WechatService {
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
            count = Long.parseLong(rstotal.get(0).get("total").toString());
        }
        String sql ="SELECT " +

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

@ -93,6 +93,12 @@ testPattern:
  sign: 0
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
---
spring:
  profiles: jwtest
@ -127,6 +133,11 @@ wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段  # todo 待配置
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
---
spring:
  profiles: jwprod
@ -163,7 +174,6 @@ express:
  sf_code: WH000102
  sf_check_word: TGUQASFNAZyjt9112
---
# 眼科医院前置机
spring:
@ -205,6 +215,10 @@ wlyy:
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段  # todo 待配置
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code:
  sf_check_word:
---
# 眼科医院前置机
spring:
@ -246,6 +260,10 @@ wlyy:
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code:
  sf_check_word:
---
#心脏中心前置机配置
spring:
@ -278,4 +296,9 @@ testPattern:
wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: xm_xzzx_wx  # base库中,wx_wechat 的id字段
  id: xm_xzzx_wx  # base库中,wx_wechat 的id字段
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code:
  sf_check_word:

+ 3 - 2
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/ykyy/UnSettledHISPrescriptionJob.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.job.DataUploadJob;
import com.yihu.jw.service.channel.UnSettledHISPrescriptionService;
import com.yihu.jw.util.wechat.WeiXinMessageUtils;
import com.yihu.jw.wechat.service.WxTemplateService;
import org.quartz.DisallowConcurrentExecution;
@ -27,13 +28,13 @@ public class UnSettledHISPrescriptionJob implements Job{
    private static final Logger logger = LoggerFactory.getLogger(UnSettledHISPrescriptionJob.class);
    @Autowired
    private WxTemplateService wxTemplateService;
    private UnSettledHISPrescriptionService unSettledHISPrescription;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("START========UnSettledHISPrescriptionJob========");
        try {
            wxTemplateService.unSettledHISPrescription();
            unSettledHISPrescription.unSettledHISPrescription();
            logger.info("END========UnSettledHISPrescriptionJob 执行结束========");
        }catch (Exception e){

+ 3 - 3
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/ykyy/UpdateStatusByPayTimeJob.java

@ -1,6 +1,6 @@
package com.yihu.jw.job.ykyy;
import com.yihu.jw.wechat.service.WxTemplateService;
import com.yihu.jw.service.channel.UnSettledHISPrescriptionService;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
@ -23,13 +23,13 @@ public class UpdateStatusByPayTimeJob implements Job{
    private static final Logger logger = LoggerFactory.getLogger(UpdateStatusByPayTimeJob.class);
    @Autowired
    private WxTemplateService wxTemplateService;
    private UnSettledHISPrescriptionService unSettledHISPrescriptionService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("START========UpdateStatusByPayTimeJob========");
        try {
            wxTemplateService.updateStatusByPayTime();
            unSettledHISPrescriptionService.updateStatusByPayTime();
            logger.info("END========UpdateStatusByPayTimeJob 执行结束========");
        }catch (Exception e){

+ 474 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java

@ -0,0 +1,474 @@
package com.yihu.jw.service.channel;
import com.alibaba.fastjson.JSON;
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.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDiagnosisDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionLogService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.oauth.OauthSsoService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.dao.ConsultOrderDao;
import com.yihu.jw.order.dao.ConsultTeamOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionDiagnosisVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
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.wechat.WeixinMessagePushUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
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.service.WxAccessTokenService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.net.URLEncoder;
import java.util.*;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
@Service
public class UnSettledHISPrescriptionService {
    private Logger logger= LoggerFactory.getLogger(UnSettledHISPrescriptionService.class);
    @Autowired
    private WxTemplateConfigDao wxTemplateConfigDao;
    @Autowired
    private WxTemplateDao wxTemplateDao;
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Autowired
    private WeixinMessagePushUtils weixinMessagePushUtils;
    @Value("${wechat.id}")
    private String wechatId;
    
    @Autowired
    private BasePatientDao basePatientDao;
    
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    
    @Autowired
    private OauthSsoService oauthSsoService;
    
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    @Autowired
    private YkyyEntranceService ykyyEntranceService;
    @Autowired
    private WxPushLogDao wxPushLogDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private WlyyHospitalSysDictDao hospitalSysDictDao;
    @Autowired
    private ConsultOrderDao consultOrderDao;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    @Autowired
    private ConsultTeamOrderDao consultTeamOrderDao;
    @Autowired
    private OutpatientDao outpatientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private PrescriptionLogService prescriptionLogService;
    @Autowired
    private ImService imService;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    
    
    /**
     * 发送微信模版消息-小程序视频
     * @param sender_id 发送者ID
     * @param sender_name 发送者姓名
     * @param reciver_id 接收者ID
     * @param reciver_name 接收者姓名
     * @param session_id 会话ID
     */
    public String sendWeTempMesMiniProgram(String sender_id, String sender_name, String reciver_id, String reciver_name,String session_id)throws Exception {
        BasePatientDO basePatientDO = basePatientDao.findById(reciver_id);
        if(basePatientDO!=null){
            List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,reciver_id);
            if(ps.isEmpty()){
                logger.info("该用户"+reciver_name+"没有openid,无法推送模版消息,用户ID:"+reciver_id+"wechatId:"+wechatId);
            }else{
                for (BasePatientWechatDo basePatientWechatDo:ps){
                    if("xm_xzzx_wx".equals(wechatId)){
                        String getAuthCode = oauthSsoService.getSsoPublic(wechatId,basePatientDO.getId());
    
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("name",basePatientDO.getName());
                        jsonObject.put("idcard",basePatientDO.getIdcard());
                        jsonObject.put("mobile",basePatientDO.getMobile());
                        jsonObject.put("openid",basePatientWechatDo.getOpenid());
                        String authCode = jsonObject.toJSONString();
                        String jm = URLEncoder.encode(RSAEncrypt.encrypt(authCode,getAuthCode),"utf-8");
                        String miniprogramUrl = "pages/room/room?patientCode="+reciver_id+"&doctorName="+sender_name+"&role=patient&roomID="+session_id+"&template=1v1&debugMode=false&cloudenv=PRO&authCode="+jm+"&code="+wechatId+"&appId="+basePatientDO.getId();
                        //心脏中心模版消息推送接口
                        logger.info("心脏中心小程序跳转URL:"+miniprogramUrl);
                        xzzxEntranceService.sendXCXMes(wechatId,
                                basePatientDO.getId(),
                                basePatientDO.getIdcard(),
                                sender_name+"主任医生已向您发起视频通话邀请,请点击详情进入视频诊室。",
                                "点击消息进入视频诊室接听视频通话,开始视频咨询",
                                "",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");
                        weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),basePatientWechatDo.getOpenid(),config);
                    }
                }
            }
        }else{
            throw new Exception("接收者ID错误,无法找到该账号");
        }
        return "success";
    }
    /**
     * 查询HIS的01表中的审方状态,如果已审方,且未结算,则推送一条模板消息给居民,让居民进行支付结算。
     */
    public void unSettledHISPrescription() throws Exception{
        if("xm_ykyy_wx".equals(wechatId)){
            //获取审核失败
            JSONArray jsonArray = ykyyEntranceService.getNoUnsettledPrescription();
            if(jsonArray!=null&&jsonArray.size()>0) {
                for (int i = 0; i<jsonArray.size(); i++){
                    JSONObject json = jsonArray.getJSONObject(i);
                    String cfsb = json.getString("CFSB");
                    //查找对应的处方
                    String sql = "SELECT w.OUTPATIENT_ID,w.ID,w.DOCTOR_NAME from WLYY_PRESCRIPTION w WHERE REAL_ORDER = '"+cfsb+"' ORDER BY w.CREATE_TIME desc";
                    List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
                    if(pre!=null && pre.size()>0){
                        String prescriptionId = pre.get(0).get("ID").toString();
                        //修改处方状态
                        String updateSql = "update WLYY_PRESCRIPTION set status = 11 where id = '"+prescriptionId+"'";
                        hibenateUtils.updateBySql(updateSql);
                    }
                }
            }
            //获取已审核未结算的处方
            JSONArray array = ykyyEntranceService.getUnsettledPrescription();
            //发送模板
            if(array!=null&&array.size()>0) {
                for (int i = 0; i<array.size(); i++){
                    JSONObject json = array.getJSONObject(i);
                    String brid = json.getString("BRID");
                    String cfsb = json.getString("CFSB");
                    //查找居民信息
                    BasePatientDO patientDO = ykyyEntranceService.findPatientByMapingCode(brid);
                    if(patientDO!=null){
                        //查找对应的处方
                        String sql = "SELECT w.OUTPATIENT_ID,w.ID,w.DOCTOR_NAME from WLYY_PRESCRIPTION w WHERE REAL_ORDER = '"+cfsb+"' ORDER BY w.CREATE_TIME desc";
                        List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
                        if(pre!=null && pre.size()>0){
                            String outpatientId = pre.get(0).get("OUTPATIENT_ID").toString();
                            String prescriptionId = pre.get(0).get("ID").toString();
                            String doctorName = pre.get(0).get("DOCTOR_NAME").toString();
                            //判断是否发送过
                            String countSql = "SELECT id from WX_PUSH_LOG w WHERE w.RECEIVER = '"+patientDO.getId()
                                    +"' and w.OPENID = '"+prescriptionId+"' and w.scene = 'djsxxtz' and w.WECHAT_ID='"+wechatId+"'";
                            List<Map<String, Object>> count = hibenateUtils.createSQLQuery(countSql);
                            if(count==null || count.size() == 0){
                                List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,patientDO.getId());
                                if(ps.isEmpty()){
                                    logger.info("该用户"+patientDO.getName()+"没有openid,无法推送模版消息,用户ID:"+patientDO.getId()+"wechatId:"+wechatId);
                                }else{
                                    //修改处方状态
                                    String updateSql = "update WLYY_PRESCRIPTION set status = 20 where id = '"+prescriptionId+"' and status = 10";
                                    hibenateUtils.updateBySql(updateSql);
                                    prescriptionLogService.addPrescriptionLog(prescriptionId,20,2,"system","system","",new Date());
                                    ps.stream().forEach(one->{
                                        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_unsettled_notice","djsxxtz",1);
                                        WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
                                        BeanUtils.copyProperties(config,newConfig);
                                        newConfig.setFirst(config.getFirst().replace("key1",patientDO.getName()));
                                        newConfig.setUrl(config.getUrl()+""+outpatientId);
                                        newConfig.setKeyword3(doctorName);
                                        WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
                                        logger.info("=======setUrl========"+newConfig.getUrl());
                                        weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(),one.getOpenid(),newConfig);
                                    });
                                    //保存发送模板记录,
                                    WxPushLogDO wxPushLogDO = new WxPushLogDO();
                                    wxPushLogDO.setCreateTime(new Date());
                                    wxPushLogDO.setOpenid(prescriptionId);
                                    wxPushLogDO.setReceiver(patientDO.getId());
                                    wxPushLogDO.setWechatId(wechatId);
                                    wxPushLogDO.setReceiverName(patientDO.getName());
                                    wxPushLogDO.setScene("djsxxtz");
                                    wxPushLogDao.save(wxPushLogDO);
                                }
                                WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(prescriptionId);
                                JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);
                                logger.info("wlyyPrescriptionDO参数入参"+object.toJSONString());
                                WlyyPrescriptionVO prescriptionVO = JSONObject.toJavaObject(object,WlyyPrescriptionVO.class);
                                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
                                List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS = new ArrayList<>();
                                for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:wlyyPrescriptionInfoDOS){
                                    JSONObject jsonObject = (JSONObject) JSONObject.toJSON(wlyyPrescriptionInfoDO);
                                    logger.info("wlyyPrescriptionInfoDO参数入参"+jsonObject.toJSONString());
                                    WlyyPrescriptionInfoVO prescriptionInfoVO = JSONObject.toJavaObject(jsonObject,WlyyPrescriptionInfoVO.class);
                                    wlyyPrescriptionInfoVOS.add(prescriptionInfoVO);
                                }
                                prescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOS);
                                List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = prescriptionDiagnosisDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
                                List<WlyyPrescriptionDiagnosisVO> wlyyPrescriptionDiagnosisVOS = new ArrayList<>();
                                for (WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO:wlyyPrescriptionDiagnosisDOS){
                                    JSONObject jsonObject = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDiagnosisDO);
                                    logger.info("wlyyPrescriptionDiagnosisDO参数入参"+jsonObject.toJSONString());
                                    WlyyPrescriptionDiagnosisVO prescriptionDiagnosisVO = JSONObject.toJavaObject(jsonObject,WlyyPrescriptionDiagnosisVO.class);
                                    wlyyPrescriptionDiagnosisVOS.add(prescriptionDiagnosisVO);
                                }
                                prescriptionVO.setDiagnosisVOs(wlyyPrescriptionDiagnosisVOS);
                                imService.pushPrescriptionImMessage(prescriptionVO);
                            }
                        }
                    }
                }
            }
        }
    }
    public void updateStatusByPayTime() throws Exception{
        if("xm_ykyy_wx".equals(wechatId)){
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("PAY_TIME");
            if (wlyyHospitalSysDictDO!=null){
                String remind = wlyyHospitalSysDictDO.getDictValue();
                String close = wlyyHospitalSysDictDO.getDictCode();
                List<BusinessOrderDO> businessOrderDOS = businessOrderDao.selectByStatus(0);
                //关闭处理
                for (BusinessOrderDO businessOrderDO:businessOrderDOS){
                    Calendar cal= Calendar.getInstance();
                    cal.setTime(businessOrderDO.getCreateTime());
                    cal.add(Calendar.MINUTE,Integer.parseInt(close));
                    Long now = new Date().getTime();
                    Long min = cal.getTime().getTime();
                    logger.info("关闭处理cal="+cal);
                    if (min==now){
                        String orderCategory = businessOrderDO.getOrderCategory();
                        String relationCode = businessOrderDO.getRelationCode();
                        if (orderCategory.equalsIgnoreCase("1")){
                            ConsultTeamDo consultTeamDo = consultTeamOrderDao.findByConsult(relationCode);
                            consultTeamDo.setStatus(-1);
                            consultTeamOrderDao.save(consultTeamDo);
                        }else if (orderCategory.equalsIgnoreCase("2")){
                            WlyyOutpatientDO outpatientDO = outpatientDao.findById(relationCode);
                            outpatientDO.setStatus("-1");
                            outpatientDao.save(outpatientDO);
                        }
                    }
                }
                //提醒处理
                for (BusinessOrderDO businessOrderDO:businessOrderDOS){
                    String orderCategory = businessOrderDO.getOrderCategory();
                    String relationCode = businessOrderDO.getRelationCode();
                    String orderType =businessOrderDO.getOrderType()+"";
                    String doctor = businessOrderDO.getDoctor();
                    String patient= businessOrderDO.getPatient();
                    Calendar cal= Calendar.getInstance();
                    cal.setTime(businessOrderDO.getCreateTime());
                    cal.add(Calendar.MINUTE,Integer.parseInt(remind));
                    Long now = new Date().getTime();
                    Long min = cal.getTime().getTime();
                    logger.info("提醒处理cal="+cal);
                    if (min==now){
                        //判断是否发送过
                        String countSql = "SELECT id from WX_PUSH_LOG w WHERE w.RECEIVER = '"+patient
                                +"' and w.OPENID = '"+relationCode+"' and w.scene = 'zxzfts' and w.WECHAT_ID='"+wechatId+"'";
                        List<Map<String, Object>> count = hibenateUtils.createSQLQuery(countSql);
                        if(count==null || count.size() == 0){
                            BasePatientDO patientDO = basePatientDao.findById(patient);
                            BaseDoctorDO doctorDO = doctorDao.findById(doctor);
                            List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,patient);
                            if(ps.isEmpty()){
                                logger.info("该用户"+patientDO.getName()+"没有openid,无法推送模版消息,用户ID:"+patientDO.getId()+"wechatId:"+wechatId);
                            }else{
                                ps.stream().forEach(one->{
                                    WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_unsettled_notice","zxzfts",1);
                                    WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
                                    BeanUtils.copyProperties(config,newConfig);
                                    String name = "";
                                    String condition="";
                                    if (orderCategory.equalsIgnoreCase("1")){
                                        if (orderType.equalsIgnoreCase("1")){
                                            name="图文咨询";
                                        }else if (orderType.equalsIgnoreCase("3")){
                                            name="视频咨询";
                                        }
                                        condition = "&consultCode="+relationCode;
                                    }else if (orderCategory.equalsIgnoreCase("2")){
                                        if (orderType.equalsIgnoreCase("1")){
                                            name="图文咨询";
                                        }else if (orderType.equalsIgnoreCase("3")){
                                            name="视频咨询";
                                        }
                                        condition = "&outpatientId="+relationCode;
                                    }
                                    newConfig.setFirst(config.getFirst().replace("key1",patientDO.getName()).replace("key2",name));
                                    newConfig.setUrl(config.getUrl()+""+condition);
                                    newConfig.setKeyword3(doctorDO.getName());
                                    newConfig.setKeyword1(name);
                                    WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
                                    logger.info("=======setUrl========"+newConfig.getUrl());
                                    weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(),one.getOpenid(),newConfig);
                                });
                                //保存发送模板记录,
                                WxPushLogDO wxPushLogDO = new WxPushLogDO();
                                wxPushLogDO.setCreateTime(new Date());
                                wxPushLogDO.setOpenid(relationCode);
                                wxPushLogDO.setReceiver(patientDO.getId());
                                wxPushLogDO.setWechatId(wechatId);
                                wxPushLogDO.setReceiverName(patientDO.getName());
                                wxPushLogDO.setScene("zxzfts");
                                wxPushLogDao.save(wxPushLogDO);
                            }
                        }
                    }
                }
            }
        }
    }
    
    public String sendWeTempMesTest(String wechatId,String openid)throws Exception{
        WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_survey","test",1);
        config.setFirst(config.getFirst().replace("key1","小明"));
        config.setKeyword2("2018-08-21");
        weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),openid,config);
        return "success";
    }
    
    public Envelop getAllTemp(String wechatId){
        String url ="https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token="+wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken();
        String result = HttpUtil.sendGet(url);
        JSONObject tempJsons = JSON.parseObject(result);
        //获取所有本地模板
        List<String> localTemps = findAllTempDos(wechatId);
        //解析公众号模板
        JSONArray temps = tempJsons.getJSONArray("template_list");
        List<WxTemplateDO> savelist = new ArrayList<>();
        if(temps!=null&&!temps.isEmpty()){
            for(int i=0;i<temps.size();i++){
                JSONObject tp = (JSONObject) temps.get(i);
                String tpid = tp.getString("template_id");
                if(!localTemps.contains(tpid)){
                    WxTemplateDO wxTemplateDO = new WxTemplateDO();
                    wxTemplateDO.setWechatId(wechatId);
                    wxTemplateDO.setTemplateId(tpid);
                    wxTemplateDO.setTitle(tp.getString("title"));
                    wxTemplateDO.setContent(tp.getString("content"));
                    wxTemplateDO.setStatus(1);
                    wxTemplateDO.setCreateTime(new Date());
                    savelist.add(wxTemplateDO);
                }
            }
            wxTemplateDao.save(savelist);
        }
        return Envelop.getSuccess(BaseRequestMapping.WeChat.api_success);
    }
    public List<String> findAllTempDos(String wechatId){
        List<WxTemplateDO> list =  wxTemplateDao.findByWxId(wechatId);
        List<String> rs = new ArrayList<>();
        if(list!=null&&list.size()>0){
            for(WxTemplateDO wxTemplateDO:list){
                rs.add(wxTemplateDO.getTemplateId());
            }
        }
        return rs;
    }
    
    /**
     * 发送微信模版消息
     * @param userName
     * @param senderName
     * @param idCard
     * @param phone
     * @param title
     * @param content
     * @param contentString
     * @param url
     */
    public String sendWxTemple(String userName, String senderName,
                             String idCard, String phone, String title,
                             String content, String contentString,
                             String url) throws Exception{
        BasePatientDO basePatientDO = basePatientDao.findByIdcard(idCard);
        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 = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_im_notice","zxtx",1);
                        config.setFirst(config.getFirst().replace("key1",userName));
                        config.setKeyword1(contentString);
                        config.setKeyword2(DateUtil.dateToStrLong(new Date()));
                        config.setUrl(url);
                        weixinMessagePushUtils.putWxMsg(wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken(),basePatientWechatDo.getOpenid(),config);
                }
            }
        }else{
            throw new Exception("接收者ID错误,无法找到该账号");
        }
        return "success";
    }
}

+ 28 - 7
svr/svr-internet-hospital-job/src/main/resources/application.yml

@ -89,7 +89,10 @@ fastDFS:
  fastdfs_file_url: http://172.26.0.110:8888/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
---
spring:
@ -119,7 +122,10 @@ wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
---
spring:
@ -157,7 +163,10 @@ wlyy:
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
---
spring:
  profiles: jwOracleProd
@ -193,7 +202,10 @@ wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
---
spring:
@ -223,7 +235,10 @@ wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
---
@ -254,7 +269,10 @@ wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk
---
spring:
@ -284,4 +302,7 @@ wlyy:
  url: http://www.xmtyw.cn/wlyytest/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
express:
  sf_url: http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService
  sf_code: JKZL
  sf_check_word: QkeIfIvQdheqIv2cVSgAUnBU29lfNbVk

+ 65 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -8,18 +8,27 @@ import com.yihu.jw.doctor.service.BaseDoctorInfoService;
import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
import com.yihu.jw.entity.base.dict.DictJobTitleDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.hospital.prescription.dao.OauthYlzConfigDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.service.consult.SysDictService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.common.XMLUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.service.WechatInfoService;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
@ -43,6 +52,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -84,6 +94,12 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    private OauthYlzConfigDao oauthYlzConfigDao;
    @Autowired
    private HospitalDeptService hospitalDeptService;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
@ -322,13 +338,39 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    @ResponseBody
    @ApiOperation("微信支付结果通知")
    @RequestMapping(value = "/notify", method = {RequestMethod.GET, RequestMethod.POST})
    public Map<String, String> wxPayNotify(HttpServletRequest request, HttpServletResponse response) throws IOException {
    public Map<String, String> wxPayNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String result = "";
        String inputLine;
        while ((inputLine = request.getReader().readLine()) != null) {
            result += inputLine;
        }
        request.getReader().close();
        //im处方发消息
        Map<String,Object> wxrs =  XMLUtil.xmltoMap(result);
        if("SUCCESS".equals(wxrs.get("return_code").toString())){
            // 我方 订单号+时间差
            String seqNo = wxrs.get("out_trade_no")+"";
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(seqNo);
            if (businessOrderDO.getStatus()!=1){
                if (businessOrderDO!=null&&businessOrderDO.getOrderCategory().equalsIgnoreCase("4")){
                    WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(businessOrderDO.getRelationCode());
                    JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);
                    logger.info("wlyyPrescriptionDO参数入参"+object.toJSONString());
                    WlyyPrescriptionVO prescriptionVO = JSONObject.toJavaObject(object,WlyyPrescriptionVO.class);
                    List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
                    List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS = new ArrayList<>();
                    for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:wlyyPrescriptionInfoDOS){
                        JSONObject jsonObject1 = (JSONObject) JSONObject.toJSON(wlyyPrescriptionInfoDO);
                        logger.info("wlyyPrescriptionInfoDO参数入参"+jsonObject1.toJSONString());
                        WlyyPrescriptionInfoVO prescriptionInfoVO = JSONObject.toJavaObject(jsonObject1,WlyyPrescriptionInfoVO.class);
                        wlyyPrescriptionInfoVOS.add(prescriptionInfoVO);
                    }
                    prescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOS);
                    prescriptionVO.setPayStatus(1);
                    imService.pushPrescriptionImMessage(prescriptionVO);
                }
            }
        }
        Map<String, String> map = businessOrderService.getWxPayResultNotify(result);
        return map;
@ -379,7 +421,29 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
                    JSONObject param = jsonObject.getJSONObject("param");
                    logger.info("param"+params);
                    String traceNo = param.getString("outChargeNo");
                    //im处方发消息
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(traceNo);
                    if (businessOrderDO.getStatus()!=1){
                        if (businessOrderDO!=null&&businessOrderDO.getOrderCategory().equalsIgnoreCase("4")){
                            WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(businessOrderDO.getRelationCode());
                            JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);
                            logger.info("wlyyPrescriptionDO参数入参"+object.toJSONString());
                            WlyyPrescriptionVO prescriptionVO = JSONObject.toJavaObject(object,WlyyPrescriptionVO.class);
                            List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
                            List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS = new ArrayList<>();
                            for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:wlyyPrescriptionInfoDOS){
                                JSONObject jsonObject1 = (JSONObject) JSONObject.toJSON(wlyyPrescriptionInfoDO);
                                logger.info("wlyyPrescriptionInfoDO参数入参"+jsonObject1.toJSONString());
                                WlyyPrescriptionInfoVO prescriptionInfoVO = JSONObject.toJavaObject(jsonObject1,WlyyPrescriptionInfoVO.class);
                                wlyyPrescriptionInfoVOS.add(prescriptionInfoVO);
                            }
                            prescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOS);
                            prescriptionVO.setPayStatus(1);
                            imService.pushPrescriptionImMessage(prescriptionVO);
                        }
                    }
                    businessOrderService.updatePayStatus(traceNo);
                    response.getWriter().write("SUCCESS");
                }
            }

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

@ -7,6 +7,8 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.*;
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;
@ -17,6 +19,8 @@ import com.yihu.jw.hospital.service.SystemMessage.HospitalSystemMessageService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionDiagnosisVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.im.ConsultVO;
import com.yihu.jw.restmodel.web.*;
@ -36,6 +40,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -79,7 +84,11 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    
    @Autowired
    private BusinessOrderService businessOrderService;
    
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    @Value("${demo.flag}")
    private boolean demoFlag;
    
@ -352,8 +361,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                    @ApiParam(name = "diagnosisJson", value = "诊断json")
                                    @RequestParam(value = "diagnosisJson", required = true)String diagnosisJson,
                                    @ApiParam(name = "inspectionJson", value = "检查检验")
                                    @RequestParam(value = "inspectionJson", required = false)String inspectionJson)throws Exception {
        Map<String,Object> result = prescriptionService.makeDiagnosis(outPatientId,advice,type,infoJsons,diagnosisJson,inspectionJson);
                                    @RequestParam(value = "inspectionJson", required = false)String inspectionJson,
                                    @ApiParam(name = "emrJson", value = "电子病历")
                                        @RequestParam(value = "emrJson", required = false)String emrJson)throws Exception {
        Map<String,Object> result = prescriptionService.makeDiagnosis(outPatientId,advice,type,infoJsons,diagnosisJson,inspectionJson,emrJson);
        try {
            
            com.alibaba.fastjson.JSONObject msgObj = new com.alibaba.fastjson.JSONObject();
@ -678,7 +689,21 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        return success(prescriptionService.findPatientInfo(patient));
        
    }
    
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.updatePatientInfo)
    @ApiOperation(value = "修改居民信息", notes = "修改居民信息")
    public ObjEnvelop findPatientInfo(@ApiParam(name = "patient", value = "居民ID")
                                      @RequestParam(value = "patient", required = true)String patient,
                                      @ApiParam(name = "name", value = "居民名称")
                                      @RequestParam(value = "name", required = true)String name,
                                      @ApiParam(name = "ssc", value = "社保卡")
                                      @RequestParam(value = "ssc", required = true)String ssc,
                                      @ApiParam(name = "idcard", value = "居民身份证")
                                       @RequestParam(value = "idcard", required = true)String idcard){
        return success(prescriptionService.updatePatientInfo(patient,name,idcard,ssc));
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.saveDoctorOnlineWork)
    @ApiOperation(value = "保存在线排班", notes = "保存在线排班")
    public Envelop saveDoctorOnlineWork(@ApiParam(name = "onlineWorkJson", value = "保存在线排班json")
@ -975,13 +1000,13 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                        consult.put("session_id", consult.get("patientId").toString()+"_"+ consult.get("generalDoctor").toString()+"_"+ consult.get("doctorCode").toString()+"_15");
                    }else{}
                }else if("9".equals(type)){//图文复诊
                    consult.put("session_id", consult.get("patientId")!=null?consult.get("patientId").toString():null+"_"+consult.get("outpatientid")!=null?consult.get("outpatientid").toString():null+"_9");
                    consult.put("session_id", consult.get("patientId")!=null?consult.get("patientId").toString():null+"_"+consult.get("outpatientId")!=null?consult.get("outpatientId").toString():null+"_9");
                    consult.put("type",type);
                }else if("16".equals(type)){//视频复诊
                    consult.put("session_id", consult.get("patientId")!=null?consult.get("patientId").toString():null+"_"+consult.get("outpatientid")!=null?consult.get("outpatientid").toString():null+"_16");
                    consult.put("session_id", consult.get("patientId")!=null?consult.get("patientId").toString():null+"_"+consult.get("outpatientId")!=null?consult.get("outpatientId").toString():null+"_16");
                    consult.put("type",type);
                }else if("12".equals(type)){//协同门诊
                    consult.put("session_id", consult.get("patientId")!=null?consult.get("patientId").toString():null+"_"+consult.get("outpatientid")!=null?consult.get("outpatientid").toString():null+"_12");
                    consult.put("session_id", consult.get("patientId")!=null?consult.get("patientId").toString():null+"_"+consult.get("outpatientId")!=null?consult.get("outpatientId").toString():null+"_12");
                    consult.put("type",type);
                }else{}
                
@ -1285,12 +1310,38 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        try {
            WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionService.findPrescriptionDo(prescriptionId);
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(wlyyPrescriptionDO.getOutpatientId());
            com.alibaba.fastjson.JSONObject msgObj = new com.alibaba.fastjson.JSONObject();
            msgObj.put("outpatientid",wlyyPrescriptionDO.getOutpatientId());
            msgObj.put("prescriptionId",prescriptionId);
            msgObj.put("reason",reason);
            String immsg = imService.pushPrescriptionBackMsg(msgObj,operate,operateName,wlyyPrescriptionDO.getOutpatientId(),wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType());
            System.out.println("发送诊断消息成功:"+immsg);
            if (status==1){
                com.alibaba.fastjson.JSONObject msgObj = new com.alibaba.fastjson.JSONObject();
                msgObj.put("outpatientid",wlyyPrescriptionDO.getOutpatientId());
                msgObj.put("prescriptionId",prescriptionId);
                msgObj.put("reason",reason);
                String immsg = imService.pushPrescriptionBackMsg(msgObj,operate,operateName,wlyyPrescriptionDO.getOutpatientId(),wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType());
                System.out.println("发送诊断消息成功:"+immsg);
            }else if (status==2){
                JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);
                System.out.println("wlyyPrescriptionDO参数入参"+object.toJSONString());
                WlyyPrescriptionVO prescriptionVO = JSONObject.toJavaObject(object,WlyyPrescriptionVO.class);
                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
                List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS = new ArrayList<>();
                for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:wlyyPrescriptionInfoDOS){
                    JSONObject jsonObject = (JSONObject) JSONObject.toJSON(wlyyPrescriptionInfoDO);
                    System.out.println("wlyyPrescriptionInfoDO参数入参"+jsonObject.toJSONString());
                    WlyyPrescriptionInfoVO prescriptionInfoVO = JSONObject.toJavaObject(jsonObject,WlyyPrescriptionInfoVO.class);
                    wlyyPrescriptionInfoVOS.add(prescriptionInfoVO);
                }
                prescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOS);
                List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOS = prescriptionDiagnosisDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
                List<WlyyPrescriptionDiagnosisVO> wlyyPrescriptionDiagnosisVOS = new ArrayList<>();
                for (WlyyPrescriptionDiagnosisDO wlyyPrescriptionDiagnosisDO:wlyyPrescriptionDiagnosisDOS){
                    JSONObject jsonObject = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDiagnosisDO);
                    System.out.println("wlyyPrescriptionDiagnosisDO参数入参"+jsonObject.toJSONString());
                    WlyyPrescriptionDiagnosisVO prescriptionDiagnosisVO = JSONObject.toJavaObject(jsonObject,WlyyPrescriptionDiagnosisVO.class);
                    wlyyPrescriptionDiagnosisVOS.add(prescriptionDiagnosisVO);
                }
                prescriptionVO.setDiagnosisVOs(wlyyPrescriptionDiagnosisVOS);
                imService.pushPrescriptionImMessage(prescriptionVO);
            }
        }catch (Exception e){
            System.out.println("发送诊断消息失败:"+e.getMessage());
//            e.printStackTrace();
@ -1407,7 +1458,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.saveEmr)
   /* @PostMapping(value= BaseHospitalRequestMapping.Prescription.saveEmr)
    @ApiOperation("创建电子病历")
    public ObjEnvelop saveEmr(
            @ApiParam(name = "emrJson", value = "emrJson", required = true)
@ -1418,7 +1469,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    }*/
    /**
@ -1469,5 +1520,47 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
//                                         @RequestParam(value = "pagesize",required = false) Integer pagesize) {
//        return prescriptionService.findAllAttentionDoctor(keyWord,outPatient,jobTitleCode,shift,page,pagesize);
//    }
    
    /**
     * 查询his电子病历
     * @param registerSn
     * @return
     * @throws Exception
     */
    @GetMapping(value= BaseHospitalRequestMapping.Prescription.findHisEmr)
    @ApiOperation("查询电子病历")
    public ObjEnvelop findHisEmr(
            @ApiParam(name = "registerSn", value = "registerSn", required = true)
            @RequestParam(required = true)String registerSn) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",prescriptionService.readOutPatient(registerSn));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.saveEmr)
    @ApiOperation("写入his电子病历")
    public ObjEnvelop findHisEmr(
            @ApiParam(name = "registerSn", value = "registerSn", required = true)
            @RequestParam(required = true)String registerSn,
            @ApiParam(name = "chiefComplaint", value = "chiefComplaint", required = true)
            @RequestParam(required = true)String chiefComplaint,
            @ApiParam(name = "hpi", value = "hpi", required = true)
            @RequestParam(required = true)String hpi,
            @ApiParam(name = "elapsemhis", value = "elapsemhis", required = true)
            @RequestParam(required = true)String elapsemhis,
            @ApiParam(name = "bodycheck", value = "bodycheck", required = true)
            @RequestParam(required = true)String bodycheck,
            @ApiParam(name = "assistanTcheck", value = "assistanTcheck", required = true)
            @RequestParam(required = true)String assistanTcheck) throws Exception {
        //String registerSn,String chiefComplaint,String hpi,String elapsemhis,String bodycheck,String assistanTcheck
        try {
            return ObjEnvelop.getSuccess("ok",prescriptionService.writeOutPatient(registerSn,chiefComplaint,hpi,elapsemhis,bodycheck,assistanTcheck));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
}

+ 1 - 1
svr/svr-iot-job/src/main/java/com/yihu/jw/service/device/InventoryWarningService.java

@ -24,7 +24,7 @@ public class InventoryWarningService {
    public void remind() {
        String sql = "select d.product_id,d.`name`,d.category_code,d.category_name,d.manufacturer_id,d.manufacturer_name,d.hospital,d.hospital_name,count(d.id) inventoryCount ,p.inventory_floor,p.inventory_upper " +
                "FROM `iot_device` d LEFT JOIN iot_product_base_info p on d.product_id = p.id and p.del = 1 where p.del=1 and is_grant=0 GROUP BY d.product_id, d.manufacturer_id, d.hospital, d.category_code ";
                "FROM `iot_device` d LEFT JOIN iot_device_inventory_warning p on d.product_id = p.product_id and p.del = 1 where d.del=1 and is_grant=0 GROUP BY d.product_id, d.manufacturer_id, d.hospital, d.category_code ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> map : list){
            Integer inventoryCount = map.get("inventoryCount") == null ? 0: Integer.parseInt(map.get("inventoryCount") + "");

+ 30 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/device/IotDeviceInventoryController.java

@ -1,8 +1,11 @@
package com.yihu.iot.controller.device;
import com.yihu.iot.service.device.IotDeviceInventoryService;
import com.yihu.iot.service.device.IotDeviceInventoryWarningService;
import com.yihu.jw.restmodel.iot.device.IotDeviceInventoryLogVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceInventoryWarningVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceVO;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.iot.IotRequestMapping;
@ -22,6 +25,8 @@ public class IotDeviceInventoryController extends EnvelopRestEndpoint {
    @Autowired
    private IotDeviceInventoryService deviceInventoryService;
    @Autowired
    private IotDeviceInventoryWarningService deviceInventoryWarningService;
    @GetMapping(value = IotRequestMapping.Device.getDeviceInventoryList)
    @ApiOperation(value = "获取设备库存列表", notes = "获取设备库存列表")
@ -92,4 +97,29 @@ public class IotDeviceInventoryController extends EnvelopRestEndpoint {
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.Device.getInventoryWarningHospital)
    @ApiOperation(value = "库存预警,获取单位接口", notes = "库存预警,获取单位接口")
    public MixEnvelop getInventoryWarningHospital() {
        try {
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find, deviceInventoryService.getInventoryWarningHospital());
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = IotRequestMapping.Device.getInventoryWarningName)
    @ApiOperation(value = "库存预警,获取设备名称接口", notes = "库存预警,获取设备名称接口")
    public MixEnvelop getInventoryWarningName(@ApiParam(name = "hospital", value = "单位code")
                                                  @RequestParam(value = "hospital", required = true) String hospital) {
        try {
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find, deviceInventoryService.getInventoryWarningName(hospital));
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 9 - 5
svr/svr-iot/src/main/java/com/yihu/iot/controller/product/IotProductController.java

@ -1,9 +1,12 @@
package com.yihu.iot.controller.product;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.service.device.IotDeviceInventoryWarningService;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.product.IotProductBaseInfoService;
import com.yihu.jw.entity.iot.device.IotDeviceInventoryWarningDO;
import com.yihu.jw.entity.iot.product.IotProductBaseInfoDO;
import com.yihu.jw.restmodel.iot.device.IotDeviceInventoryWarningVO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.iot.product.IotMaintenanceUnitVO;
@ -35,6 +38,8 @@ public class IotProductController extends EnvelopRestEndpoint {
    private IotSystemDictService iotSystemDictService;
    @Autowired
    private HttpServletRequest request;
    @Autowired
    private IotDeviceInventoryWarningService deviceInventoryWarningService;
    @GetMapping(value = IotRequestMapping.Product.findProductPage)
@ -203,14 +208,13 @@ public class IotProductController extends EnvelopRestEndpoint {
    @GetMapping(value = IotRequestMapping.Product.setInventoryById)
    @ApiOperation(value = "根据产品id设置库存上下限预警值")
    public MixEnvelop<IotProductVO, IotProductVO> setInventoryById(@ApiParam(name = "jsonData", value = "设置库存预警提醒json数组", defaultValue = "[]")
    public MixEnvelop<IotDeviceInventoryWarningVO, IotDeviceInventoryWarningVO> setInventoryById(@ApiParam(name = "jsonData", value = "设置库存预警提醒json数组", defaultValue = "[]")
                                                                       @RequestParam(value = "jsonData", required = true)String jsonData) {
        try {
            List<IotProductBaseInfoDO> productBaseInfoDOList = iotProductBaseInfoService.setInventoryById(jsonData);
            List<IotDeviceInventoryWarningDO> doList = deviceInventoryWarningService.setInventoryById(jsonData);
            //DO转VO
            List<IotProductBaseInfoVO> productVOList = convertToModels(productBaseInfoDOList,new ArrayList<>(productBaseInfoDOList.size()),IotProductBaseInfoVO.class);
            iotProductBaseInfoService.translateDictForList(productVOList);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_update, productVOList);
            List<IotDeviceInventoryWarningVO> voList = convertToModels(doList,new ArrayList<>(doList.size()),IotDeviceInventoryWarningVO.class);
            return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_update, voList);
        } catch (Exception e) {
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());

+ 13 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceInventoryWarningDao.java

@ -0,0 +1,13 @@
package com.yihu.iot.dao.device;
import com.yihu.jw.entity.iot.device.IotDeviceInventoryWarningDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2020/6/1.
 */
public interface IotDeviceInventoryWarningDao extends PagingAndSortingRepository<IotDeviceInventoryWarningDO,String>,JpaSpecificationExecutor<IotDeviceInventoryWarningDO> {
}

+ 30 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceInventoryService.java

@ -7,11 +7,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.iot.dao.device.IotDeviceDao;
import com.yihu.iot.dao.device.IotDeviceInventoryLogDao;
import com.yihu.iot.dao.device.IotDeviceOrderDao;
import com.yihu.iot.service.common.MyJdbcTemplate;
import com.yihu.jw.entity.iot.device.IotDeviceDO;
import com.yihu.jw.entity.iot.device.IotDeviceInventoryLogDO;
import com.yihu.jw.entity.iot.device.IotDeviceOrderDO;
import com.yihu.jw.restmodel.iot.device.IotDeviceInventoryLogVO;
import com.yihu.jw.restmodel.iot.device.IotDeviceVO;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.mysql.query.BaseJpaService;
@ -40,6 +42,8 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
    private IotDeviceOrderDao deviceOrderDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private MyJdbcTemplate myJdbcTemplate;
    /**
     * 获取库存列表接口
@ -75,6 +79,32 @@ public class IotDeviceInventoryService extends BaseJpaService<IotDeviceInventory
        }
    }
    /**
     * 库存预警,获取单位接口
     * @return
     */
    public MixEnvelop getInventoryWarningHospital() {
        String sql = "select d.hospital,d.hospital_name FROM `iot_device` d where del=1 and is_grant=0 GROUP BY d.hospital";
        List<JSONObject> list = myJdbcTemplate.queryJson(sql,new Object[]{});
        return MixEnvelop.getSuccessList(IotRequestMapping.Common.message_success_find, list);
    }
    /**
     * 库存预警,获取设备名称接口
     * @param hospital
     * @return
     */
    public MixEnvelop getInventoryWarningName(String hospital) {
        String sql = "select d.product_id,d.name FROM `iot_device` d where del=1 and is_grant=0 ";
        if (StringUtils.isNotBlank(hospital)) {
            sql += "and hospital = '" + hospital + "' ";
        }
        sql += "GROUP BY d.product_id ";
        List<JSONObject> list = myJdbcTemplate.queryJson(sql,new Object[]{});
        return MixEnvelop.getSuccessList(IotRequestMapping.Common.message_success_find, list);
    }
    public Integer updateInventory(String jsonData) {
        List<IotDeviceDO> deviceDOList = new ArrayList<>();
        JSONArray jsonArray = JSONArray.parseArray(jsonData);

+ 76 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceInventoryWarningService.java

@ -0,0 +1,76 @@
package com.yihu.iot.service.device;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.iot.dao.device.IotDeviceInventoryWarningDao;
import com.yihu.jw.entity.iot.device.IotDeviceInventoryWarningDO;
import com.yihu.jw.entity.iot.product.IotProductBaseInfoDO;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Created by yeshijie on 2020/6/1.
 */
@Service
public class IotDeviceInventoryWarningService extends BaseJpaService<IotDeviceInventoryWarningDO,IotDeviceInventoryWarningDao> {
    @Autowired
    private IotDeviceInventoryWarningDao deviceInventoryWarningDao;
    /**
     * 设置库存上下限提醒值
     * @param jsonData
     * @return
     */
    public List<IotDeviceInventoryWarningDO> setInventoryById(String jsonData) {
        List<IotDeviceInventoryWarningDO> list = new ArrayList();
        JSONArray jsonArray = JSONArray.parseArray(jsonData);
        for (Object object : jsonArray){
            JSONObject jsonObject = (JSONObject) object;
            String id  = jsonObject.getString("id");
            String hospital  = jsonObject.getString("hospital");
            String hospitalName  = jsonObject.getString("hospitalName");
            String produceName  = jsonObject.getString("produceName");
            Integer inventoryUpper = jsonObject.getInteger("inventoryUpper");
            Integer inventoryFloor = jsonObject.getInteger("inventoryFloor");
            IotDeviceInventoryWarningDO warningDO = new IotDeviceInventoryWarningDO();
            warningDO.setDel(1);
            warningDO.setHospital(hospital);
            warningDO.setHospitalName(hospitalName);
            warningDO.setInventoryFloor(inventoryFloor);
            warningDO.setInventoryUpper(inventoryUpper);
            warningDO.setProductId(id);
            warningDO.setProductName(produceName);
            warningDO.setCreateTime(new Date());
            list.add(warningDO);
        }
        deviceInventoryWarningDao.save(list);
        return list;
    }
    /**
     * 新增预警
     * @return
     */
    public IotDeviceInventoryWarningDO addInventoryWarning(String hospital,String hospitalName,Integer inventoryFloor
            ,Integer inventoryUpper,String productId,String produceName){
        IotDeviceInventoryWarningDO warningDO = new IotDeviceInventoryWarningDO();
        warningDO.setDel(1);
        warningDO.setHospital(hospital);
        warningDO.setHospitalName(hospitalName);
        warningDO.setInventoryFloor(inventoryFloor);
        warningDO.setInventoryUpper(inventoryUpper);
        warningDO.setProductId(productId);
        warningDO.setProductName(produceName);
        warningDO.setCreateTime(new Date());
        deviceInventoryWarningDao.save(warningDO);
        return warningDO;
    }
}

+ 3 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistPatientRelationDao.java

@ -26,4 +26,7 @@ public interface SpecialistPatientRelationDao extends PagingAndSortingRepository
    @Modifying
    @Query("update SpecialistPatientRelationDO p set p.doctor = ?2, p.doctorName=?3 where p.patient=?1 and p.signStatus='1' and p.status>=0 ")
    void updateSpecialistByPatient(String patient, String doctor, String doctorName);
    @Query("select p from SpecialistPatientRelationDO p where p.teamCode=?1 and p.patient =?2 and p.status>=0 and p.signStatus=1")
    public SpecialistPatientRelationDO findByTeamCodeAndPatient(Integer teamCode,String patient);
}

+ 1 - 1
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java

@ -1369,7 +1369,7 @@ public class RehabilitationManageService {
        Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);//计划总服务项目数
        Integer finishedCount = rehabilitationDetailDao.findByStatusAndPlanId(1,planId);
        PatientRehabilitationPlanDO p =patientRehabilitationPlanDao.findById(planId);
        SpecialistPatientRelationDO specialistPatientRelationDO = specialistPatientRelationDao.findByDoctorAndPatient(p.getCreateUser(),p.getPatient());
        SpecialistPatientRelationDO specialistPatientRelationDO = specialistPatientRelationDao.findByTeamCodeAndPatient(p.getTeamCode(), p.getPatient());
        resultMap.put("allCount",allCount);
        resultMap.put("finishedCount",finishedCount);
        resultMap.put("specialistPatientRelationDO",specialistPatientRelationDO);