Browse Source

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

wangjun 3 years ago
parent
commit
255580eb02
100 changed files with 8530 additions and 226 deletions
  1. 55 0
      business/base-service/src/main/java/com/yihu/jw/hospital/dict/service/WlyyHospitalSysDictService.java
  2. 18 0
      business/base-service/src/main/java/com/yihu/jw/hospital/message/dao/SystemMessageDao.java
  3. 19 0
      business/base-service/src/main/java/com/yihu/jw/rehabilitation/DoctorPatientRelationDao.java
  4. 10 0
      business/base-service/src/main/java/com/yihu/jw/rehabilitation/PatientMedicalRecordsDao.java
  5. 193 0
      business/base-service/src/main/java/com/yihu/jw/rehabilitation/service/DoctorPatientRelationService.java
  6. 15 0
      business/base-service/src/main/java/com/yihu/jw/security/RSADao.java
  7. 258 0
      business/base-service/src/main/java/com/yihu/jw/sign/dao/MessagesDao.java
  8. 26 0
      business/base-service/src/main/java/com/yihu/jw/team/BaseDoctorTeamDao.java
  9. 42 0
      business/base-service/src/main/java/com/yihu/jw/team/BaseDoctorTeamMemberDao.java
  10. 3 0
      business/base-service/src/main/java/com/yihu/jw/wechat/dao/JsapiTicketDao.java
  11. 8 0
      business/base-service/src/main/java/com/yihu/jw/wechat/dao/WxAccessTokenDao.java
  12. 1 0
      business/base-service/src/mqConfig/mqdata/event1.json
  13. 1 0
      business/base-service/src/mqConfig/mqdata/event2.json
  14. 8 0
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultDao.java
  15. 27 0
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamDao.java
  16. 17 1
      business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java
  17. 6 0
      common/common-entity/pom.xml
  18. 8 0
      common/common-entity/sql记录
  19. 124 124
      common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java
  20. 0 3
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxAccessTokenDO.java
  21. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/Device.java
  22. 71 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceInfo.java
  23. 89 0
      common/common-entity/src/main/java/com/yihu/jw/entity/followup/BusinessMapping.java
  24. 2 1
      common/common-entity/src/main/java/com/yihu/jw/entity/followup/Followup.java
  25. 73 0
      common/common-entity/src/main/java/com/yihu/jw/entity/followup/FollowupContent.java
  26. 81 0
      common/common-entity/src/main/java/com/yihu/jw/entity/followup/FollowupMapping.java
  27. 117 0
      common/common-entity/src/main/java/com/yihu/jw/entity/followup/FollowupSign.java
  28. 77 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/AdminTeamFunction.java
  29. 48 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/AdminTeamMemberAuthority.java
  30. 49 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/AdminTeamMemberRole.java
  31. 77 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/AdminTeamRole.java
  32. 119 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/Frequency.java
  33. 46 9
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/SystemMessageDO.java
  34. 131 0
      common/common-entity/src/main/java/com/yihu/jw/entity/patient/PatientEvent.java
  35. 120 0
      common/common-entity/src/main/java/com/yihu/jw/entity/rehabilitation/RehabilitationguidanceDO.java
  36. 141 0
      common/common-entity/src/main/java/com/yihu/jw/entity/rehabilitation/RehabilitationguidancePatientDO.java
  37. 72 0
      common/common-entity/src/main/java/com/yihu/jw/entity/rehabilitation/SpecialDiseaseMessagesDO.java
  38. 406 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/DoctorPatientRelationDO.java
  39. 20 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistPatientRelationDO.java
  40. 233 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/PatientMedicalRecordsDO.java
  41. 21 3
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/PatientRehabilitationPlanDO.java
  42. 73 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationAdviceDO.java
  43. 31 0
      common/common-entity/src/main/java/com/yihu/jw/entity/util/RSA.java
  44. 208 0
      common/common-entity/src/main/java/com/yihu/jw/entity/util/SystemConf.java
  45. 72 0
      common/common-entity/src/main/java/com/yihu/jw/entity/wlyyinfo/WechatTag.java
  46. 74 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/rehabilitation/RehabilitationRequestMapping.java
  47. 20 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/endpoint/EnvelopRestEndpoint.java
  48. 88 0
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  49. 3 0
      gateway/ag-basic/src/main/resources/application.yml
  50. 13 8
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  51. 7 0
      server/svr-authentication/src/main/resources/application.yml
  52. 4 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java
  53. 41 9
      svr/svr-base/src/main/java/com/yihu/jw/base/service/order/PayService.java
  54. 5 5
      svr/svr-base/src/main/java/com/yihu/jw/base/service/org/BaseOrgService.java
  55. 7 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DeviceDetailDao.java
  56. 9 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DeviceInfoDao.java
  57. 7 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DevicePatientHealthIndexDao.java
  58. 60 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/Result.java
  59. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java
  60. 0 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java
  61. 33 11
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PayEndpoint.java
  62. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  63. 27 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceDetailService.java
  64. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/DoctorDoorCoachOrderService.java
  65. 10 7
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java
  66. 28 7
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  67. 86 18
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/pay/PayService.java
  68. 8 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  69. 102 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/WxpayUtil.java
  70. 12 2
      svr/svr-cloud-care/src/main/resources/application.yml
  71. 7 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DeviceDetailDao.java
  72. 9 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DeviceInfoDao.java
  73. 7 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DevicePatientHealthIndexDao.java
  74. 1 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java
  75. 52 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceUploadController.java
  76. 60 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/Result.java
  77. 348 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceUploadService.java
  78. 1 1
      svr/svr-cloud-job/src/main/resources/application.yml
  79. 97 5
      svr/svr-rehabilitation/pom.xml
  80. 8 1
      svr/svr-rehabilitation/src/main/java/com/yihu/SvrRehabilitationApplication.java
  81. 14 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/aop/ObserverRequired.java
  82. 89 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/aop/ObserverRequiredAOP.java
  83. 22 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/aop/ServicesAuth.java
  84. 5 1
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/config/jpa/HibernateProperties.java
  85. 5 1
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/config/jpa/RehabilitationJpa.java
  86. 71 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/DiagnosisInformationController.java
  87. 318 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/RehabilitationPlanController.java
  88. 3 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/RehabilitationPlanningController.java
  89. 299 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/consult/ConsultController.java
  90. 124 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/consult/DoctorConsultController.java
  91. 166 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/doctor/DoctorRehabilitaionInfoController.java
  92. 1065 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/doctor/DoctorRehabilitationManageController.java
  93. 465 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/doctor/DoctorRehabilitationPlanController.java
  94. 534 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/followUp/DoctorFollowUpController.java
  95. 80 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/followUp/DoctorPhthisisFollowupController.java
  96. 378 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/followUp/DoctorVisitDetailController.java
  97. 48 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/message/DoctorMessageController.java
  98. 348 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/patient/PatientRehabilitationManageController.java
  99. 21 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/dao/FrequencyDao.java
  100. 0 0
      svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/dao/GuidanceMessageLogDao.java

+ 55 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/dict/service/WlyyHospitalSysDictService.java

@ -21,6 +21,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.eval.MissingArgEval;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
@ -40,6 +41,8 @@ public class WlyyHospitalSysDictService extends BaseJpaService<WlyyHospitalSysDi
    private BaseDoctorDao baseDoctorDao;
    @Value("${wechat.id}")
    private String wechatId;
    @Autowired
    private StringRedisTemplate redisTemplate;
    //查字典
    public MixEnvelop findDictsByNameCode(String modelName,String name,String code,String value,Integer page ,Integer pageSize){
        String  sql = "select t.id as \"id\"," +
@ -401,4 +404,56 @@ public class WlyyHospitalSysDictService extends BaseJpaService<WlyyHospitalSysDi
        return mixEnvelop;
    }
    /**
     * 字典转译
     *
     * @param dictName
     * @param code
     * @return
     */
    public String getDictValue(String dictName, String code) {
        String re = "";
        /*try {
            if (!StringUtils.isEmpty(code)) {
                //判断该字典redis是否存在
                String exit = redisTemplate.opsForValue().get("systemDict:" + dictName);
                if (!StringUtils.isEmpty(exit)) {
                    re = redisTemplate.opsForValue().get("systemDict:" + dictName + ":" + code);
                    if(StringUtils.isEmpty(re)){
                        WlyyHospitalSysDictDO wlyyHospitalSysDictDO= wlyyHospitalSysDictDao.findOneByDictNameAndDictCode(dictName,code);
                        if (wlyyHospitalSysDictDO!=null){
                            re =wlyyHospitalSysDictDO.getDictValue();
                        }
//                        if (!StringUtils.isEmpty(re)) {
//                            redisTemplate.opsForValue().set("systemDict:" + dictName + ":" + code, re);
//                        }
                    }
                } else {
                    List<WlyyHospitalSysDictDO> list = wlyyHospitalSysDictDao.findByDictName(dictName);
                    if (list != null && list.size() > 0) {
                        redisTemplate.opsForValue().set("systemDict:" + dictName, "1");
                        for (WlyyHospitalSysDictDO item : list) {
                            redisTemplate.opsForValue().set("systemDict:" + dictName + ":" + item.getDictCode(), item.getDictValue());
                            if (code.equals(item.getDictCode())) {
                                re = item.getDictValue();
                            }
                        }
                    }
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }*/
        if (StringUtils.isNoneBlank(code)){
            WlyyHospitalSysDictDO wlyyHospitalSysDictDO= wlyyHospitalSysDictDao.findOneByDictNameAndDictCode(dictName,code);
            if (wlyyHospitalSysDictDO!=null){
                re =wlyyHospitalSysDictDO.getDictValue();
                System.out.println("re"+re);
            }
        }
        return re;
    }
}

+ 18 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/message/dao/SystemMessageDao.java

@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
@ -36,4 +37,21 @@ public interface SystemMessageDao extends PagingAndSortingRepository<SystemMessa
    int orderMessageDelByType(String doctor, String orderId,String type);
    SystemMessageDO findByRelationCodeAndReceiver(String relationCode,String receiver);
    @Query("update SystemMessageDO a set a.isRead=0,a.over = '0' where a.id = ?1")
    @Modifying
    Integer setSpecialistById(String id);
    @Query("update SystemMessageDO a set a.isRead = 0 where a.id = ?1" )
    @Modifying
    Integer setSpecialistReadById(String id);
    @Query("update SystemMessageDO a set a.isRead = 0,a.over = '0' where a.receiver = ?1 and a.type = ?2 and (a.createTime > ?3 and a.createTime< ?4)")
    @Modifying
    void setMessageOverByType(String doctor, Integer type, Date start, Date end);
}

+ 19 - 0
business/base-service/src/main/java/com/yihu/jw/rehabilitation/DoctorPatientRelationDao.java

@ -0,0 +1,19 @@
package com.yihu.jw.rehabilitation;
import com.yihu.jw.entity.specialist.DoctorPatientRelationDO;
import com.yihu.jw.entity.specialist.rehabilitation.GuidanceMessageLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface DoctorPatientRelationDao extends PagingAndSortingRepository<DoctorPatientRelationDO, String>, JpaSpecificationExecutor<DoctorPatientRelationDO> {
    @Query("from DoctorPatientRelationDO t where t.doctor =?1 and t.patient =?2")
    List<DoctorPatientRelationDO> findByDoctorAndPatient(String doctor,String patient);
    @Query("from DoctorPatientRelationDO t where t.doctor =?1 and t.patient =?2 and t.dischargeRecord = ?3")
    DoctorPatientRelationDO findByDoctorAndPatientAndCode(String doctor,String patient,String code);
}

+ 10 - 0
business/base-service/src/main/java/com/yihu/jw/rehabilitation/PatientMedicalRecordsDao.java

@ -0,0 +1,10 @@
package com.yihu.jw.rehabilitation;
import com.yihu.jw.entity.specialist.rehabilitation.PatientMedicalRecordsDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface PatientMedicalRecordsDao extends PagingAndSortingRepository<PatientMedicalRecordsDO, String>, JpaSpecificationExecutor<PatientMedicalRecordsDO> {
}

+ 193 - 0
business/base-service/src/main/java/com/yihu/jw/rehabilitation/service/DoctorPatientRelationService.java

@ -0,0 +1,193 @@
package com.yihu.jw.rehabilitation.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.patient.Patient;
import com.yihu.jw.entity.specialist.DoctorPatientRelationDO;
import com.yihu.jw.entity.specialist.rehabilitation.PatientMedicalRecordsDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.rehabilitation.DoctorPatientRelationDao;
import com.yihu.jw.rehabilitation.PatientMedicalRecordsDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@Service
public class DoctorPatientRelationService <T, R extends CrudRepository> extends BaseJpaService<DoctorPatientRelationDO, DoctorPatientRelationDao> {
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private DoctorPatientRelationDao doctorPatientRelationDao;
    @Autowired
    private PatientMedicalRecordsDao patientMedicalRecordsDao;
    public MixEnvelop findDoctorPatients(String doctor, String patient, String patientName, String isdeal, String idcard,Integer page , Integer pageSize){
        MixEnvelop mixEnvelop = new MixEnvelop();
        String sql = "select t.id as \"id\"," +
                " t.discharge_record as \"dischargeRecord\"," +
                " t.doctor as \"doctor\"," +
                " t.doctor_name as \"doctorName\"," +
                " t.patient as \"patient\"," +
                " t.patient_name as \"patientName\"," +
                " t.create_time as \"createTime\"," +
                " t.isdeal as \"isdeal\"," +
                " b.idcard as \"idcard\"," +
                " t.status as \"status\"," +
                " t.relation_type as \"relationType\"" +
                " from wlyy_doctor_patient_relation t " +
                " left join base_patient b on t.patient = b.id where 1=1";
        if (StringUtils.isNoneBlank(doctor)){
            sql+=" and t.doctor='"+doctor+"'";
        }
        if (StringUtils.isNoneBlank(patient)){
            sql+=" and t.patient='"+patient+"'";
        }
        if (StringUtils.isNoneBlank(patientName)){
            sql+=" and t.patient_name like '%"+patientName+"%'";
        }
        if (StringUtils.isNoneBlank(isdeal)){
            sql+=" and t.isdeal = '"+isdeal+"'";
        }
        if (StringUtils.isNoneBlank(idcard)){
            sql+=" and b.idcard = '"+idcard+"'";
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,page,pageSize);
        for (Map<String,Object> map:list){
            String sex = map.get("idcard")==null?"未知": IdCardUtil.getSexForIdcard_new(map.get("idcard").toString());
            Integer age = map.get("idcard")==null?0: IdCardUtil.getAgeForIdcard(map.get("idcard").toString());
            map.put("sex",sex);
            map.put("age",age);
        }
        mixEnvelop.setDetailModelList(list);
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setTotalCount(list==null?0:list.size());
        return mixEnvelop;
    }
    public void saveSingleDoctorPatientRelation(String json,String relationType) throws  Exception{
        JSONObject jsonObject = JSON.parseObject(json);
        String doctor = jsonObject.getString("doctor");
        String idCard = jsonObject.getString("idCard");
        String patientName = jsonObject.getString("patientName");
        String patientRecord = jsonObject.getString("patientRecord");
        String reOutpatientId = jsonObject.getString("reOutatientId");
        String recordCode="";
        BasePatientDO basePatientDO = basePatientDao.findByIdcard(idCard);
        BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
        if (null==basePatientDO){
            basePatientDO.setIdcard(idCard);
            basePatientDO.setName(patientName);
            String salt = UUID.randomUUID().toString().substring(0,5);
            String pw = idCard.substring(idCard.length()-6,idCard.length());
            basePatientDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
            basePatientDO.setDel("1");
            basePatientDO.setLocked(0);
            basePatientDO.setEnabled(1);
            basePatientDO.setSex(Integer.valueOf(IdCardUtil.getSexForIdcard_new(idCard)));
            basePatientDO.setSalt(salt);
            basePatientDO.setBirthday(IdCardUtil.getBirthdayForIdcard(idCard));
            basePatientDO.setCreateTime(new Date());
            basePatientDO=basePatientDao.save(basePatientDO);
        }
        //保存医生居民关系映射表
        if ("1".equalsIgnoreCase(relationType)){
            //创建创建对应的出院记录
            PatientMedicalRecordsDO patientMedicalRecordsDO=objectMapper.readValue(patientRecord, PatientMedicalRecordsDO.class);
            patientMedicalRecordsDO = patientMedicalRecordsDao.save(patientMedicalRecordsDO);
            recordCode=patientMedicalRecordsDO.getCode();
        }else if ("2".equalsIgnoreCase(relationType)){
            recordCode=reOutpatientId;
        }
        DoctorPatientRelationDO doctorPatientRelationDO = doctorPatientRelationDao.findByDoctorAndPatientAndCode(doctor,basePatientDO.getId(),recordCode);
        if (doctorPatientRelationDO==null){
            doctorPatientRelationDO = new DoctorPatientRelationDO();
        }
        doctorPatientRelationDO.setPatient(basePatientDO.getId());
        doctorPatientRelationDO.setPatientName(basePatientDO.getName());
        doctorPatientRelationDO.setDoctor(doctor);
        doctorPatientRelationDO.setDoctorName(baseDoctorDO==null?"":baseDoctorDO.getName());
        doctorPatientRelationDO.setIsdeal("0");
        doctorPatientRelationDO.setStatus("0");
        doctorPatientRelationDO.setRelationType(relationType);
        doctorPatientRelationDO.setDischargeRecord(recordCode);
        doctorPatientRelationDO.setCreateTime(new Date());
        doctorPatientRelationDao.save(doctorPatientRelationDO);
    }
    public void savePatientDisease(){
    }
    /**
     *
     * @param patientInfo
     * @param doctorCode
     * @return
     */
    public JSONObject getPatientByIdcardOrSsc(String patientInfo, String doctorCode) {
        JSONObject data = new JSONObject();
        BasePatientDO patientList = basePatientDao.findByIdcardAndDel(patientInfo,"1");
        BasePatientDO patient = null;
        String recordCode="123";
        if(patientList==null){
            //未找到居民,从健康档案添加居民
            patient = new BasePatientDO();//todo 调用医院查询居民接口
            patient.setName("测试");
            patient.setSex(1);
            patient.setIdcard("210555111199992525");
            patient.setPhone("18877777777");
            basePatientDao.save(patient);
        }else{
            patient = patientList;
        }
        if(patient==null){
            data.put("status", -1);
            data.put("msg", "未查询到患者");
            return data;
        }
        BaseDoctorDO doctor = baseDoctorDao.findById(doctorCode);
        DoctorPatientRelationDO doctorPatientRelationDO = doctorPatientRelationDao.findByDoctorAndPatientAndCode(doctorCode,patient.getId(),recordCode);
        if (doctorPatientRelationDO==null){
            doctorPatientRelationDO = new DoctorPatientRelationDO();
        }
        doctorPatientRelationDO.setPatient(patient.getId());
        doctorPatientRelationDO.setPatientName(patient.getName());
        doctorPatientRelationDO.setDoctor(doctorCode);
        doctorPatientRelationDO.setDoctorName(doctor==null?"":doctor.getName());
        doctorPatientRelationDO.setIsdeal("0");
        doctorPatientRelationDO.setStatus("0");
        doctorPatientRelationDO.setRelationType("");
        doctorPatientRelationDO.setDischargeRecord("");
        doctorPatientRelationDO.setCreateTime(new Date());
        doctorPatientRelationDao.save(doctorPatientRelationDO);
        data.put("status",200);
        return data;
    }
}

+ 15 - 0
business/base-service/src/main/java/com/yihu/jw/security/RSADao.java

@ -0,0 +1,15 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.security;
import com.yihu.jw.entity.util.RSA;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface RSADao extends PagingAndSortingRepository<RSA, Long>, JpaSpecificationExecutor<RSA> {
	
}

+ 258 - 0
business/base-service/src/main/java/com/yihu/jw/sign/dao/MessagesDao.java

@ -0,0 +1,258 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.sign.dao;
import com.yihu.jw.entity.patient.Message;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
public interface MessagesDao extends PagingAndSortingRepository<Message, Long>, JpaSpecificationExecutor<Message> {
    @Query("select count(1) from Message a where a.type in(1,101) and a.read= 1 and a.receiver=?1 ")
    Integer amountUnreadByReceiver(String doctor);
    @Query("select a from Message a where a.type in(1,101) and a.read= 1 and a.receiver=?1 order by a.czrq desc")
    Page<Message> amountUnreadLastByReceiver(String doctor, Pageable pageRequest);
    @Query("select count(1) from Message a where a.type =2 and a.read= 1 and a.receiver=?1 ")
    Integer amountUnreadHealthByReceiver(String doctor);
    @Query("select a from Message a where a.type =2 and a.read= 1 and a.receiver=?1 order by a.czrq desc")
    List<Message> amountUnreadHealthLastByReceiver(String doctor, Pageable pageRequest);
    @Modifying
    @Query("update Message a set a.read = 0,a.over='0' where a.id = ?1")
    int read(long msgid);
    @Modifying
    @Query("update Message a set a.read = 0 where a.id = ?1")
    int updateReadById(long msgid);
    @Modifying
    @Query("update Message a set a.read = 0,a.over='1' where a.code = ?1")
    int read(String msgCode);
    @Query("SELECT a FROM Message a WHERE a.sender=?1 AND a.receiver = ?2 and a.signStatus = ?3 and a.read=1 ORDER BY czrq DESC")
    List<Message> findUnreadSign(String sender, String receiver, String signStatus);
    @Query(" from Message a where a.read = 1 and over ='1' and a.sender = ?1 and a.receiver=?2 and a.signStatus='1'")
    List<Message> findByPatient(String patient, String doctor);
    @Query(" from Message a where a.read = 1 and over ='1' and a.sender = ?1 and a.receiver=?2 ")
    List<Message> findByPatientRenew(String patient, String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.sender=?2 and a.tzType=?3  and a.over=1 order by a.createTime desc")
    List<Message> getHealthIndexMessageByPatient(String doctor, String patient, String type, Pageable pageRequest);
    //查询医生下的签约居民未读体征异常消息
    @Query("SELECT a FROM Message a WHERE a.sender=?1 AND a.receiver = ?2 AND a.type = 2 and a.del = '1' and a.read=1 ORDER BY czrq DESC")
    List<Message> findUnreadHealthIndex(String sender, String receiver);
    @Modifying
    @Query("update Message a set a.read = 0 where a.receiver = ?1 and a.sender=?2 and a.tzType=?3")
    int updateHealthIndexMessageByPatient(String doctor, String patient, String type);
    @Query("select a from Message a where a.read= 1 and a.receiver = ?1 and a.type not in (1,2,6,7,12,101,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,32,33,301,401,402,403,407,408,409,430,431,432,434,435) and (a.over = 1 or a.over is null) order by a.czrq desc")
    List<Message> getSystemMessageUnread(String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.prescriptionStatus=?2 and a.type in (6,7,33) order by a.createTime desc")
    List<Message> getSysTemMessageByPrescription(String doctor, String prescriptionStatus);
    @Query("select a from Message a where a.receiver = ?1 and a.prescriptionStatus=?2 and a.type =31 order by a.createTime desc")
    List<Message> getSysTemMessageByExamination(String doctor, String prescriptionStatus);
    @Query("select a from Message a where a.receiver = ?1 and a.type not in (1,2,6,7,12,101,14,15,301,16,17,18,19,20,21,22,23,24,25,26,27,28,29,32,33,401,402,403,407,408,409,430,431,432,434,435) and (a.del = '1' or a.del is null) and (a.over = 1 or a.over is null) ")
    List<Message> getSystemMessage(String doctor, Pageable pageRequest);
    @Query("select a from Message a where a.receiver = ?1 and ((a.type=?2 and a.prescriptionStatus='0') or a.type = 33 )")
    List<Message> getPrescriptionMessage(String doctor, Integer type, Pageable pageRequest);
    @Query("select count(a) from Message a where a.read = 0 and a.over ='0'  and a.receiver=?1 and a.type=?2 ")
    int findMessageNum(String doctor, Integer type);
    @Modifying
    @Query("update Message a set a.prescriptionStatus=?2 where a.relationCode = ?1 and a.type=?3 ")
    int updatePreScriptionMessage(String relationCode, String prescriptionStatus, Integer type);
    @Query("update Message a set a.read = 0,a.over = '0' where a.relationCode = ?1 and a.type = ?2")
    @Modifying
    @Transactional
    int updateMessageByRelationCode(String relationCode, Integer type);
    @Query("update Message a set a.read = 0,a.over = '0' where a.receiver = ?1 and a.type = ?2")
    @Modifying
    int setMessageReaded(String doctor, Integer type);
    @Query("update Message a set a.read = 0,a.over = '0' where a.receiver = ?1 and a.id = ?2")
    @Modifying
    int setMessageReadedById(String doctor, Long id);
    @Query("update Message a set a.read = 0 where a.receiver = ?1 and a.id = ?2")
    @Modifying
    int setMessageById(String doctor, Long id);
    @Query("update Message a set a.read = 0,a.over = '0' where a.receiver = ?1 and a.type not in (1,2,6,7)")
    @Modifying
    int setSysMessageReaded(String doctor);
    @Query("from Message a where a.receiver = ?1 and relationCode = ?2 and a.type=?3 ")
    List<Message> findByReceiverAndRelationCode(String receiver, String relationCode, Integer type);
    //查询患者最近7天的体征异常记录
    @Query(value = "SELECT COUNT(1) FROM wlyy_message WHERE type = '2' and sender = ?1 and create_time>=date_add(now(),interval -7 day) ", nativeQuery = true)
    int findTzMessage(String patient);
    //根据续方关联code查询团队长分配健管师消息
    @Query("from Message a where a.type = 8 and a.state=0 and a.del='1' and a.over='0' and relationCode = ?1  ")
    Message findByRelationCode(String relationCode);
    @Query("from Message a where a.type IN(24,25,26,27,12) and a.del='1' and a.over='1' and receiver = ?1  order by a.createTime desc")
    List<Message> findByReceiverCallService(String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.type=?2 and a.over='1' and a.read=1 order by a.createTime desc")
    List<Message> getMessageByType(String doctor, Integer type, Pageable pageRequest);
    @Query("from Message a where a.type = 12 and a.del='1' and a.over='1' and relationCode = ?1  ")
    List<Message> findByCallServiceRelationCode(String relationCode);
    @Query(" select a from Message a where a.type IN (15,30) and a.del='1' and a.read=1 and a.receiver=?1 and a.over='1' order by a.createTime desc ")
    List<Message> findEduArticle1(String receiver);
    @Query(" select a from Message a where a.type=?2 and a.del='1' and a.read=1 and a.receiver=?1 and a.over='1' order by a.createTime desc ")
    List<Message> findEduArticle(String receiver, Integer type);
    @Query(" select a from Message a where a.type=?2 and a.del='1'  and a.receiver=?1 ")
    List<Message> findEduArticle(String receiver, Integer type, Pageable pageRequest);
    @Query(" select a from Message a where a.type IN (15,30)and a.del='1'  and a.receiver=?1 ")
    List<Message> findEduArticle1(String receiver, Pageable pageRequest);
    @Modifying
    @Query("delete from Message a   where a.receiver = ?1 and a.data = ?2 and a.type in (14,15,30) ")
    int setMessageDel(String doctor, String articleCode);
    @Modifying
    @Query("delete from Message a   where  a.data = ?1 and a.type in (14,15,30) ")
    int setMessageDel1(String articleCode);
    @Modifying
    @Query("delete from Message a   where a.receiver = ?1 and a.relationCode = ?2 and a.type in (14,15,30) ")
    int setMessageDel2(String doctor, String refinementCode);
    @Modifying
    @Query("delete from Message a   where a.receiver = ?1 and a.relationCode = ?2 and a.type ='407'")
    int orderMessageDel(String doctor, String orderId);
    @Query(" select a from Message a where a.type=?2 and a.del='1' and a.read=1 and a.receiver=?1 and a.over='1' order by a.createTime desc ")
    List<Message> findUnReadByReceiverAndType(String receiver, Integer type);
    @Query("select a from Message a where a.read = 1 and a.receiver = ?1 and a.state = 1 and a.over = ?2 and a.type in (16,20,22,23) order by a.czrq desc")
    List<Message> getSpecialistApply(String receiver, String over);
    @Query("select a from Message a where a.receiver = ?1 and a.state = 1 and a.type = 17 order by a.czrq desc")
    List<Message> getFamilyTransfer(String receiver);
    @Query("select a from Message a where a.read = 1 and a.receiver = ?1 and a.state = 1 and a.type = 18 order by a.czrq desc")
    List<Message> getFamilySign(String receiver);
    @Query("select a from Message a where a.receiver = ?1 and a.state = 1 and a.type in(18,19,20,21,22,23,29)")
    List<Message> selectFamilySign(String receiver, Pageable pageableRequest);
    @Query("select a from Message a where a.read= ?2 and a.receiver = ?1 and a.state = 1 and a.over = ?3 and a.type = 17 order by a.czrq desc")
    List<Message> getFamilyTransferReadAndOver(String receiver, Integer read, String over);
    @Query("select a from Message a where a.receiver = ?1 and a.type=31 and a.read= ?2 and a.over = ?3 and a.prescriptionStatus='0' ")
    List<Message> getExaminationMessage(String doctor, Integer read, String over);
    @Query("select a from Message a where a.receiver = ?1 and a.state = 1 and a.over = ?2 and a.type in (16,20,22,23) order by a.czrq desc")
    List<Message> getSpecialistUntreated(String receiver, String over, Pageable pageable);
    @Query("select a from Message a where  a.receiver = ?1 and a.state = 1 and a.over = ?2 and a.type in (19,21,29) order by a.czrq desc")
    List<Message> getSpecialistMessages(String receiver, String over, Pageable pageable);
    @Query("select a from Message a where a.read= ?2 and a.receiver = ?1 and a.state = 1 and a.over = ?3 and a.type in (17) order by a.czrq desc")
    List<Message> getTransferMessage(String receiver, Integer read, String over, Pageable pageable);
    @Query("select a from Message a where a.code = ?1")
    Message findByCode(String code);
    @Query("select a from Message a where a.relationCode = ?1 and a.receiver = ?2 and a.type = ?3")
    Message findOldMessage(String orderId, String receiver, int type);
    @Query("select a from Message a where a.read = 1 and a.receiver = ?1 and a.state = 1 and a.type in (19,21,29) order by a.czrq desc")
    List<Message> getSpecialistUnRead(String receiver);
    @Query("select a from Message a where a.read = 1 and a.receiver = ?1 and a.state = 1 and a.type in (18,19,20,21,22,23,29) order by a.czrq desc")
    List<Message> getSpecialistUnRead2(String receiver);
    @Query("update Message a set a.read=0,a.over = '0' where a.id = ?1")
    @Modifying
    int setSpecialistById(Long id);
    @Query("update Message a set a.read = 0 where a.id = ?1")
    @Modifying
    int setSpecialistReadById(Long id);
    @Query("select a from Message a where a.read = 1 and a.receiver = ?1 and a.state = 1 and a.type in (24,25,26,27,12,32) order by a.czrq desc")
    List<Message> getSynergyService(String receiver);
    @Query("select a from Message a where  a.receiver = ?1 and a.state = 1 and a.type in (12,32,24,25,26,27) order by a.czrq desc")
    List<Message> getSynergyMessages(String receiver, Pageable pageable);
    @Query("update Message a set a.read = 0 where a.receiver = ?1 and a.type in (12,32,24,25,26,27)")
    @Modifying
    int setSynergyMessagesByRead(String doctor);
    @Query("select a from Message a where  a.receiver = ?1 and a.type = 28  and a.state = 1 and a.del = '1' and a.createTime > ?2 order by a.czrq desc")
    List<Message> findBirthdayReminder(String doctor, Date now);
    @Query("select a from Message a where  a.receiver = ?1 and a.over = 1 and a.type in (17) order by a.czrq desc")
    List<Message> getTransferMessageByPCIM(String receiver, Pageable pageable);
    @Query("select a from Message a where  a.receiver = ?1 and a.over = 1 and a.type in(?2)  order by a.czrq desc")
    List<Message> getPCIMFamilyServer(String receiver, String types, Pageable pageable);
    @Query(" select a from Message a where a.type IN (401,402) and a.del='1' and a.read=1 and a.receiver=?1 and a.over='1' order by a.createTime desc ")
    List<Message> findDoorOrder(String receiver);
    @Query(" select a from Message a where a.type IN (408,407,403,409) and a.del='1' and a.receiver=?1 and a.over='1' order by a.createTime desc ")
    List<Message> findDoorByOrder(String receiver);
    @Query("select a from Message a where  a.receiver = ?1 and a.state = 1 and a.over = ?2 and a.type in (?3) order by a.czrq desc")
    List<Message> findWaitingMessages(String receiver, String over, List<Integer> typeList, Pageable pageable);
    //获取资质申请审核有效的未结束已发送的消息
    @Query("select a from Message a where a.type in (401,408) and a.del='1' and a.over='1' and a.state=1  and relationCode = ?1  ")
    List<Message> findMessageByRelationCode(String relationCode);
/*    //获取资质申请审核有效的未结束已发送的消息
    @Query("select a from Message a where a.type = 401 and a.del='1' and a.over='1' and a.state=1  and a.relationCode = ?1 ")
    List<Message> findMessageByRelationCodeAndReceiver(String relationCode);*/
    List<Message> queryByRelationCodeAndTypeIn(String relationCode, Integer[] type);
    @Query("select a from Message a where a.receiver = ?1 and a.type=?2 and  a.over='1' order by a.createTime desc")
    List<Message> getMessageByReceiverByType(String receiver, Integer type, Pageable pageRequest);
    @Query("update Message a set a.read = 0,a.over = '0' where a.receiver = ?1 and a.type = ?2 and (a.createTime > ?3 and a.createTime< ?4)")
    @Modifying
    void setMessageOverByType(String doctor, Integer type, Date start, Date end);
    @Query("update Message a set a.read = 0,a.over = '0' where a.receiver = ?1 and a.relationCode = ?2 and a.type=?3 ")
    @Modifying
    void updateByReceiverAndRelationCode(String receiver, String relationCode, Integer type);
}

+ 26 - 0
business/base-service/src/main/java/com/yihu/jw/team/BaseDoctorTeamDao.java

@ -0,0 +1,26 @@
package com.yihu.jw.team;
import com.yihu.jw.entity.base.team.BaseTeamDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
import java.util.Map;
/**
 * 
 * 团队信息 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseDoctorTeamDao extends PagingAndSortingRepository<BaseTeamDO, String>, JpaSpecificationExecutor<BaseTeamDO>  {
    @Query("select orgCode as code,orgName as name from BaseTeamDO")
    List<Map<String,Object>> getTeamOrgList();
 }

+ 42 - 0
business/base-service/src/main/java/com/yihu/jw/team/BaseDoctorTeamMemberDao.java

@ -0,0 +1,42 @@
package com.yihu.jw.team;
import com.yihu.jw.entity.base.team.BaseTeamMemberDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
 * 
 * 团队成员 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseDoctorTeamMemberDao extends PagingAndSortingRepository<BaseTeamMemberDO, String>, JpaSpecificationExecutor<BaseTeamMemberDO>  {
    @Query("select doc.name as name,doc.idcard as idcard ,doc.id as doctorCode from BaseDoctorDO doc where doc.id in (select team.doctorCode from BaseTeamMemberDO team where team.teamCode = ?1)")
    List<Map<String,Object>> getTeamMemberList(String teamCode);
    @Query("select id from BaseTeamMemberDO where teamCode = ?1")
    Set<Object> findIdListByTeamCode(String teamCode);
    List<BaseTeamMemberDO> findByTeamCode(String teamCode);
    @Query("from BaseTeamMemberDO  t where t.doctorCode = ?1 and t.del ='1'")
    List<BaseTeamMemberDO> findUseDoctorCode(String doctorCode);
    @Query("from BaseTeamMemberDO  t where t.doctorCode = ?1 and t.del ='1'")
    List<BaseTeamMemberDO> findUseDoctorCodeAndDel(String doctorCode);
    @Query("from BaseTeamMemberDO  t where t.doctorCode = ?1 and t.teamCode=?2 and t.del ='1'")
    BaseTeamMemberDO findUseDoctorCodeAndTeamCode(String doctorCode, String teamCode);
}

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/dao/JsapiTicketDao.java

@ -9,4 +9,7 @@ public interface JsapiTicketDao extends PagingAndSortingRepository<JsApiTicket,
    @Query("select p from JsApiTicket p where p.acc_id = ?1 order by p.add_timestamp desc")
    Iterable<JsApiTicket> findJsapiTicket(String accId);
}

+ 8 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/dao/WxAccessTokenDao.java

@ -19,4 +19,12 @@ public interface WxAccessTokenDao extends PagingAndSortingRepository<WxAccessTok
    @Modifying
    @Query("delete from WxAccessTokenDO p where p.wechatId=?1 ")
    void deleteByWechatId(String wechatId);
    @Query("select p from WxAccessTokenDO p where p.code = ?1 order by p.addTimestamp desc")
    Iterable<WxAccessTokenDO> findAccessToken(String accId);
    @Modifying
    @Query("delete from WxAccessTokenDO p where p.code=?1 ")
    void deleteByAccId(String accId);
}

File diff suppressed because it is too large
+ 1 - 0
business/base-service/src/mqConfig/mqdata/event1.json


File diff suppressed because it is too large
+ 1 - 0
business/base-service/src/mqConfig/mqdata/event2.json


+ 8 - 0
business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultDao.java

@ -1,6 +1,8 @@
package com.yihu.jw.im.dao;
import com.yihu.jw.entity.base.im.ConsultDo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -32,4 +34,10 @@ public interface ConsultDao extends PagingAndSortingRepository<ConsultDo, String
	ConsultDo queryByRelationCode(String relationCode);
	ConsultDo queryByIdAndType(String id,Integer type);
	/*@Query(value = "select a.id,a.type,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.evaluate,a.relation_code from wlyy_consult a,wlyy_consult_team b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.type=?3 and a.symptoms like ?2 order by a.czrq desc",nativeQuery = true)
	Page<Object> findByPatientAndType(String patient, String title, Integer type, Pageable pageRequest);
	@Query(value = "select a.id,a.type,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.evaluate,a.relation_code  from wlyy_consult a,wlyy_consult_team b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.type=?2 order by a.czrq desc",nativeQuery = true)
	Page<Object> findByPatientAndType(String patient,Integer type, Pageable pageRequest);*/
}

+ 27 - 0
business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamDao.java

@ -2,6 +2,8 @@ package com.yihu.jw.im.dao;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import org.hibernate.validator.constraints.LuhnCheck;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
@ -32,4 +34,29 @@ public interface ConsultTeamDao  extends PagingAndSortingRepository<ConsultTeamD
	ConsultTeamDo queryByRelationCode(String relationCode);
	List<ConsultTeamDo> findByTypeAndDel(Integer type,String del);
	// 患者咨询列表(未结束)
	@Query("select a from ConsultTeamDo a where a.patient = ?1 and a.status=0 and a.del = '1'")
	Page<ConsultTeamDo> findNotFinishedBypatient(String patient, Pageable pageRequest);
	@Query("select a from ConsultTeamDo a where a.patient = ?1 and a.id = ?2 and a.status=0 and a.del = '1' and a.type<>8")
	Page<ConsultTeamDo> findNotFinishedBypatient(String patient, String  id, Pageable pageRequest);
	// 患者咨询列表(已结束)
	@Query("select a from ConsultTeamDo a where a.patient=?1 and a.status=1 and a.del = '1' and a.type<>8")
	Page<ConsultTeamDo> findFinishedBypatient(String patient, Pageable pageRequest);
	@Query("select a from ConsultTeamDo a where a.patient=?1 and a.id = ?2 and a.status=1 and a.del = '1' and a.type<>8")
	Page<ConsultTeamDo> findFinishedBypatient(String patient, String id, Pageable pageRequest);
	// 患者咨询列表(已取消)
	@Query("select a from ConsultTeamDo a where a.patient=?1 and a.status=-1 and a.del = '1' and a.type<>8")
	Page<ConsultTeamDo> findCancelBypatient(String patient, Pageable pageRequest);
	@Query("select a from ConsultTeamDo a where a.patient=?1 and a.id =?2 and a.status=-1 and a.del = '1' and a.type<>8")
	Page<ConsultTeamDo> findCancelBypatient(String patient, String id, Pageable pageRequest);
	// 取消三师咨询
	@Modifying
	@Query("update ConsultTeamDo a set a.status = -1 where a.consult = ?1 and a.status <> 1")
	int cancel(String consult);
}

+ 17 - 1
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -754,6 +754,7 @@ public class ImUtil {
	public static final String SESSION_TYPE_GROUP = "3";
	public static final String SESSION_TYPE_SYSTEM = "0";
	public static final String SESSION_TYPE_PRESCRIPTION = "8";//续方
	public static final String SESSION_TYPE_KANGFU = "18";//续方
	public static final String SESSION_TYPE_EXAMINATION = "9";//在线复诊-图文
	public static final String SESSION_TYPE_ONDOOR_NURSING = "11";//上门护理
	public static final String SESSION_TYPE_COLLABORATION_HOSPITAL = "12";///互联网医院协同门诊
@ -802,7 +803,7 @@ public class ImUtil {
//			return 0;
//		}
	}
	
	/**
	 *获取所有会话未读消息数。
	 * @param userid
@ -836,4 +837,19 @@ public class ImUtil {
//		}
	}
	/**
	 * 获取会话未读消息数量
	 * @param sessionId
	 * @param userId
	 * @return
	 */
	public JSONObject getSessionUnreadMessageCount(String sessionId, String userId) {
		String url = im_host + "api/v2/sessions/" + sessionId + "/unread_message_count?user_id=" + userId;
		try {
			String ret = HttpClientUtil.get(url, "utf-8");
			return  JSONObject.parseObject(ret);
		} catch (Exception e) {
			throw new RuntimeException("获取会话成员!sessionId =" + sessionId);
		}
	}
}

+ 6 - 0
common/common-entity/pom.xml

@ -27,5 +27,11 @@
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>RELEASE</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</project>

+ 8 - 0
common/common-entity/sql记录

@ -1087,3 +1087,11 @@ alter table base.base_life_care_order add column pay_status TINYINT(2) DEFAULT n
alter table base.base_business_order_refund add column refuse_desc varchar(255) DEFAULT null COMMENT '拒绝退款说明';
ALTER table base.base_business_order_pay add column last_pay_time BIGINT(13) COMMENT '截至支付日期'
ALTER table base.base_business_order_pay add INDEX index_status_last_pay(status,last_pay_time)
-- 2021-07-12
ALTER table base.dm_device add column need_register tinyint(2) DEFAULT '0' COMMENT '是否需要注册 0否 1是'
ALTER TABLE wlyy_patient_rehabilitation_plan add COLUMN  `admin_team_code` int(11) DEFAULT NULL COMMENT '家签行政团队Id';
-- 2021-07-12 lb
ALTER table base.dm_device modify column need_register varchar(255) DEFAULT NULL COMMENT '注册至iot接口,为空表示不注册'

+ 124 - 124
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java

@ -11,173 +11,173 @@ import java.util.Date;
/**
* 医生基本信息实体
*
* @author Administrator on  2018年09月05日
*
*/
 * 医生基本信息实体
 *
 * @author Administrator on  2018年09月05日
 *
 */
@Entity
@Table(name = "base_doctor")
public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
    /**
	 * 密码
	 */
	private String password;
     * 密码
     */
    private String password;
    /**
	 * 
	 */
	private String salt;
     *
     */
    private String salt;
    /**
	 * 姓名
	 */
	private String name;
     * 姓名
     */
    private String name;
    /**
	 * 性别(1男,2女) 用国家标准字典
	 */
	private Integer sex;
     * 性别(1男,2女) 用国家标准字典
     */
    private Integer sex;
    /**
	 * 医生专长
	 */
	private String expertise;
     * 医生专长
     */
    private String expertise;
    /**
	 * 医生介绍
	 */
	private String introduce;
     * 医生介绍
     */
    private String introduce;
    /**
	 *  身份证
	 */
	private String idcard;
     *  身份证
     */
    private String idcard;
    /**
	 * 生日
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	private Date birthday;
     * 生日
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date birthday;
    /**
	 * 头像http地址
	 */
	private String photo;
     * 头像http地址
     */
    private String photo;
    /**
	 * 手机号
	 */
	private String mobile;
     * 手机号
     */
    private String mobile;
    /**
	 * 医生二维码
	 */
	private String qrcode;
     * 医生二维码
     */
    private String qrcode;
    /**
	 * 省代码
	 */
	private String provinceCode;
     * 省代码
     */
    private String provinceCode;
    /**
	 * 省名称
	 */
	private String provinceName;
     * 省名称
     */
    private String provinceName;
    /**
	 * 市代码
	 */
	private String cityCode;
     * 市代码
     */
    private String cityCode;
    /**
	 * 市名称
	 */
	private String cityName;
     * 市名称
     */
    private String cityName;
    /**
	 * 区县代码
	 */
	private String townCode;
     * 区县代码
     */
    private String townCode;
    /**
	 * 区县名称
	 */
	private String townName;
     * 区县名称
     */
    private String townName;
    /**
	 * 街道代码
	 */
	private String streetCode;
     * 街道代码
     */
    private String streetCode;
    /**
	 * 街道名称
	 */
	private String streetName;
     * 街道名称
     */
    private String streetName;
    /**
	 * 资格是否认证通过,1是,0否
	 */
	private String iscertified;
     * 资格是否认证通过,1是,0否
     */
    private String iscertified;
    /**
	 * 是否是名医,1是,0否
	 */
	private Integer isFamous;
     * 是否是名医,1是,0否
     */
    private Integer isFamous;
    /**
	 * 是否提示设置密码  1 提示过 0未提示
	 */
	private String isPasswordPrompt;
     * 是否提示设置密码  1 提示过 0未提示
     */
    private String isPasswordPrompt;
    /**
	 * 名称拼音首字母
	 */
	private String spell;
     * 名称拼音首字母
     */
    private String spell;
    /**
	 * CA证书过期时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	private Date certifiedOvertime;
     * CA证书过期时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date certifiedOvertime;
    /**
	 * CA证书编号
	 */
	private String certificateNum;
     * CA证书编号
     */
    private String certificateNum;
    /**
	 * 用户微信openid
	 */
	private String openid;
     * 用户微信openid
     */
    private String openid;
	/**
	 * 职称代码
	 */
	private String jobTitleCode;
    /**
     * 职称代码
     */
    private String jobTitleCode;
	/**
	 * 职称名称
	 */
	private String jobTitleName;
    /**
     * 职称名称
     */
    private String jobTitleName;
    /**
     * 号别字典
     */
    private String chargeType;
    /**
	 * 作废标识,1正常,0作废
	 */
	private String del;
     * 作废标识,1正常,0作废
     */
    private String del;
    /**
     * 是否锁定:0可用;1锁定
     */
	private Integer locked;
    private Integer locked;
    /**
     * 账号是否可用,1为可用;0为不可用
     */
	private Integer enabled;
    private Integer enabled;
    /**
@ -373,7 +373,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.password = password;
    }
	@Column(name = "salt")
    @Column(name = "salt")
    public String getSalt() {
        return salt;
    }
@ -381,7 +381,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.salt = salt;
    }
	@Column(name = "name")
    @Column(name = "name")
    public String getName() {
        return name;
    }
@ -389,7 +389,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.name = name;
    }
	@Column(name = "sex")
    @Column(name = "sex")
    public Integer getSex() {
        return sex;
    }
@ -397,7 +397,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.sex = sex;
    }
	@Column(name = "expertise")
    @Column(name = "expertise")
    public String getExpertise() {
        return expertise;
    }
@ -405,7 +405,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.expertise = expertise;
    }
	@Column(name = "introduce")
    @Column(name = "introduce")
    public String getIntroduce() {
        return introduce;
    }
@ -413,7 +413,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.introduce = introduce;
    }
	@Column(name = "idcard")
    @Column(name = "idcard")
    public String getIdcard() {
        return idcard;
    }
@ -421,7 +421,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.idcard = idcard;
    }
	@Column(name = "birthday")
    @Column(name = "birthday")
    public Date getBirthday() {
        return birthday;
    }
@ -429,7 +429,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.birthday = birthday;
    }
	@Column(name = "photo")
    @Column(name = "photo")
    public String getPhoto() {
        return photo;
    }
@ -437,7 +437,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.photo = photo;
    }
	@Column(name = "mobile")
    @Column(name = "mobile")
    public String getMobile() {
        return mobile;
    }
@ -445,7 +445,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.mobile = mobile;
    }
	@Column(name = "qrcode")
    @Column(name = "qrcode")
    public String getQrcode() {
        return qrcode;
    }
@ -453,7 +453,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.qrcode = qrcode;
    }
	@Column(name = "province_code")
    @Column(name = "province_code")
    public String getProvinceCode() {
        return provinceCode;
    }
@ -461,7 +461,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.provinceCode = provinceCode;
    }
	@Column(name = "province_name")
    @Column(name = "province_name")
    public String getProvinceName() {
        return provinceName;
    }
@ -469,7 +469,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.provinceName = provinceName;
    }
	@Column(name = "city_code")
    @Column(name = "city_code")
    public String getCityCode() {
        return cityCode;
    }
@ -477,7 +477,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.cityCode = cityCode;
    }
	@Column(name = "city_name")
    @Column(name = "city_name")
    public String getCityName() {
        return cityName;
    }
@ -485,7 +485,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.cityName = cityName;
    }
	@Column(name = "town_code")
    @Column(name = "town_code")
    public String getTownCode() {
        return townCode;
    }
@ -493,7 +493,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.townCode = townCode;
    }
	@Column(name = "town_name")
    @Column(name = "town_name")
    public String getTownName() {
        return townName;
    }
@ -501,7 +501,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.townName = townName;
    }
	@Column(name = "street_code")
    @Column(name = "street_code")
    public String getStreetCode() {
        return streetCode;
    }
@ -509,7 +509,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.streetCode = streetCode;
    }
	@Column(name = "street_name")
    @Column(name = "street_name")
    public String getStreetName() {
        return streetName;
    }
@ -517,7 +517,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.streetName = streetName;
    }
	@Column(name = "iscertified")
    @Column(name = "iscertified")
    public String getIscertified() {
        return iscertified;
    }
@ -525,7 +525,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.iscertified = iscertified;
    }
	@Column(name = "is_famous")
    @Column(name = "is_famous")
    public Integer getIsFamous() {
        return isFamous;
    }
@ -533,7 +533,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.isFamous = isFamous;
    }
	@Column(name = "is_password_prompt")
    @Column(name = "is_password_prompt")
    public String getIsPasswordPrompt() {
        return isPasswordPrompt;
    }
@ -541,7 +541,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.isPasswordPrompt = isPasswordPrompt;
    }
	@Column(name = "spell")
    @Column(name = "spell")
    public String getSpell() {
        return spell;
    }
@ -549,7 +549,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.spell = spell;
    }
	@Column(name = "certified_overtime")
    @Column(name = "certified_overtime")
    public Date getCertifiedOvertime() {
        return certifiedOvertime;
    }
@ -557,7 +557,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.certifiedOvertime = certifiedOvertime;
    }
	@Column(name = "certificate_num")
    @Column(name = "certificate_num")
    public String getCertificateNum() {
        return certificateNum;
    }
@ -565,7 +565,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.certificateNum = certificateNum;
    }
	@Column(name = "openid")
    @Column(name = "openid")
    public String getOpenid() {
        return openid;
    }
@ -573,7 +573,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
        this.openid = openid;
    }
	@Column(name = "del")
    @Column(name = "del")
    public String getDel() {
        return del;
    }

+ 0 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxAccessTokenDO.java

@ -59,9 +59,6 @@ public class WxAccessTokenDO extends UuidIdentityEntity implements java.io.Seria
		return this.expiresIn;
	}
	public void setExpiresIn(Long expiresIn) {
		this.expiresIn = expiresIn;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "czrq", nullable = false, length = 0)

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/Device.java

@ -27,6 +27,7 @@ public class Device extends IdEntity {
	private Date czrq;
	private String del;
	private String serviceTopic;//设备所属专题 防走失 preventLost
	private String needRegister;//设备是否注册iot(脉搏波血压计)
	@Column(name="category_code")
	public String getCategoryCode() {
@ -117,4 +118,12 @@ public class Device extends IdEntity {
	public void setServiceTopic(String serviceTopic) {
		this.serviceTopic = serviceTopic;
	}
	public String getNeedRegister() {
		return needRegister;
	}
	public void setNeedRegister(String needRegister) {
		this.needRegister = needRegister;
	}
}

+ 71 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceInfo.java

@ -0,0 +1,71 @@
package com.yihu.jw.entity.care.device;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.sql.Timestamp;
import java.util.Date;
/**
 * Created by lingfeng on 2016/8/19.
 */
@Entity
@Table(name = "wlyy_devices_data_record")
public class DeviceInfo extends IdEntity {
    private String deviceData;
    private String deviceType;
    private Timestamp pushDate;
    private String status;
    // Constructors
    /** default constructor */
    public DeviceInfo() {
    }
    /** full constructor */
    public DeviceInfo(String deviceData, String deviceType,
                      Timestamp pushDate, String status) {
        this.deviceData = deviceData;
        this.deviceType = deviceType;
        this.pushDate = pushDate;
        this.status = status;
    }
    @Column(name = "device_data")
    public String getDeviceData() {
        return deviceData;
    }
    public void setDeviceData(String deviceData) {
        this.deviceData = deviceData;
    }
    @Column(name = "device_type")
    public String getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
    @Column(name = "push_date")
    public Date getPushDate() {
        return pushDate;
    }
    public void setPushDate(Timestamp pushDate) {
        this.pushDate = pushDate;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
}

+ 89 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/followup/BusinessMapping.java

@ -0,0 +1,89 @@
package com.yihu.jw.entity.followup;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 随访记录映射表
 * @author huangwenjie
 * @date 2017/10/23 14:02
 */
@Entity
@Table(name = "wlyy_business_mapping")
public class BusinessMapping extends IntegerIdentityEntity {
	private String code;
	private Integer businessId;
	private Integer businessType;
	private Integer needUpload;
	private Date createTime;
	private Date updateTime;
	
	@Basic
	@Column(name = "code")
	public String getCode() {
		return code;
	}
	
	public void setCode(String code) {
		this.code = code;
	}
	
	@Basic
	@Column(name = "need_upload")
	public Integer getNeedUpload() {
		return needUpload;
	}
	
	public void setNeedUpload(Integer needUpload) {
		this.needUpload = needUpload;
	}
	
	@Basic
	@Column(name = "create_time")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return createTime;
	}
	
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	@Basic
	@Column(name = "update_time")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+08:00")
	public Date getUpdateTime() {
		return updateTime;
	}
	
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Basic
	@Column(name = "business_id")
	public Integer getBusinessId() {
		return businessId;
	}
	public void setBusinessId(Integer businessId) {
		this.businessId = businessId;
	}
	@Basic
	@Column(name = "business_type")
	public Integer getBusinessType() {
		return businessType;
	}
	public void setBusinessType(Integer businessType) {
		this.businessType = businessType;
	}
}

+ 2 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/followup/Followup.java

@ -1,6 +1,7 @@
package com.yihu.jw.entity.followup;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.iot.gateway.IdEntity;
@ -17,7 +18,7 @@ import java.util.Map;
@Entity
@Table(name = "wlyy_followup")
@SequenceGenerator(name="id_generated", sequenceName="wlyy_followup")
public class Followup extends IdEntity {
public class Followup extends IntegerIdentityEntity {
	//随访编号【基卫】
	private String followupNo;

+ 73 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/followup/FollowupContent.java

@ -0,0 +1,73 @@
package com.yihu.jw.entity.followup;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.util.Date;
/**
 * 随访面访详情
 * @author hzp add 2016-12-07
 *
 */
@Entity
@Table(name = "wlyy_followup_content")
@SequenceGenerator(name="id_generated", sequenceName="seq_wlyy_followup_drugs")
public class FollowupContent extends IntegerIdentityEntity {
	//随访ID
	private Long followupId;
	//随访项目【字典FOLLOWUP_PROJECT】
	private String followupProject;
	//随访项目问题
	private String followupKey;
	//随访项目回答
	private String followupValue;
	//创建时间
	private Date createTime;
	public Long getFollowupId() {
		return followupId;
	}
	public void setFollowupId(Long followupId) {
		this.followupId = followupId;
	}
	public String getFollowupProject() {
		return followupProject;
	}
	public void setFollowupProject(String followupProject) {
		this.followupProject = followupProject;
	}
	public String getFollowupKey() {
		return followupKey;
	}
	public void setFollowupKey(String followupKey) {
		this.followupKey = followupKey;
	}
	public String getFollowupValue() {
		return followupValue;
	}
	public void setFollowupValue(String followupValue) {
		this.followupValue = followupValue;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
}

+ 81 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/followup/FollowupMapping.java

@ -0,0 +1,81 @@
package com.yihu.jw.entity.followup;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.*;
import java.sql.Timestamp;
/**
 * 随访记录映射表
 * @author huangwenjie
 * @date 2017/10/23 14:02
 */
@Entity
@Table(name = "wlyy_followup_mapping")
@SequenceGenerator(name="id_generated", sequenceName="seq_wlyy_followup_mapping")
public class FollowupMapping extends IntegerIdentityEntity {
	private String code;
	private Integer followupId;
	private Integer needUpload;
	private Timestamp createTime;
	private Timestamp updateTime;
	private String errmsg;
	@Basic
	@Column(name = "code")
	public String getCode() {
		return code;
	}
	
	public void setCode(String code) {
		this.code = code;
	}
	
	@Basic
	@Column(name = "followup_id")
	public Integer getFollowupId() {
		return followupId;
	}
	
	public void setFollowupId(Integer followupId) {
		this.followupId = followupId;
	}
	
	@Basic
	@Column(name = "need_upload")
	public Integer getNeedUpload() {
		return needUpload;
	}
	
	public void setNeedUpload(Integer needUpload) {
		this.needUpload = needUpload;
	}
	
	@Basic
	@Column(name = "create_time")
	public Timestamp getCreateTime() {
		return createTime;
	}
	
	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}
	
	@Basic
	@Column(name = "update_time")
	public Timestamp getUpdateTime() {
		return updateTime;
	}
	
	public void setUpdateTime(Timestamp updateTime) {
		this.updateTime = updateTime;
	}
	public String getErrmsg() {
		return errmsg;
	}
	public void setErrmsg(String errmsg) {
		this.errmsg = errmsg;
	}
}

+ 117 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/followup/FollowupSign.java

@ -0,0 +1,117 @@
package com.yihu.jw.entity.followup;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2019/4/22.
 */
@Entity
@Table(name = "wlyy_followup_sign")
public class FollowupSign extends IntegerIdentityEntity {
    private String code;//
    private Integer followupId;//随访id',
    private String type;//签到方式1.定位,2.拍照,3.门牌',
    private String doctor;//医生',
    private String doctorName;//医生姓名',
    private String longitude;//经度',
    private String latitude;//纬度',
    private String address;//地址',
    private String img;//图片地址“,”分割',
    private Date createTime;//创建时间',
    private Integer del; //是否删除1为删除,0.为正常
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public Integer getFollowupId() {
        return followupId;
    }
    public void setFollowupId(Integer followupId) {
        this.followupId = followupId;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getLongitude() {
        return longitude;
    }
    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }
    public String getLatitude() {
        return latitude;
    }
    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 77 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/AdminTeamFunction.java

@ -0,0 +1,77 @@
package com.yihu.jw.entity.hospital.doctor;
import com.yihu.jw.entity.iot.gateway.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * @author Sand
 */
@Entity
@Table(name = "dr_admin_team_function")
public class AdminTeamFunction extends IdEntity {
    private String name;
    private String code;
    private boolean avaliable;
    private Date createTime;
    private String creator;
    private String remarks;
    public String getName() {
        return name;
    }
    @Column(name = "name")
    public void setName(String name) {
        this.name = name;
    }
    public String getCode() {
        return code;
    }
    @Column(name = "code")
    public void setCode(String code) {
        this.code = code;
    }
    public boolean isAvaliable() {
        return avaliable;
    }
    @Column(name = "avaliable")
    public void setAvaliable(boolean avaliable) {
        this.avaliable = avaliable;
    }
    public Date getCreateTime() {
        return createTime;
    }
    @Column(name = "create_time")
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getCreator() {
        return creator;
    }
    @Column(name = "creator")
    public void setCreator(String creator) {
        this.creator = creator;
    }
    public String getRemarks() {
        return remarks;
    }
    @Column(name = "remarks")
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }
}

+ 48 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/AdminTeamMemberAuthority.java

@ -0,0 +1,48 @@
package com.yihu.jw.entity.hospital.doctor;
import com.yihu.jw.entity.iot.gateway.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 成员权限。
 *
 * @author Sand
 */
@Entity
@Table(name = "dr_admin_team_member_authority")
public class AdminTeamMemberAuthority extends IdEntity {
    private long teamdId;
    private long roleId;
    private long functionId;
    public long getTeamdId() {
        return teamdId;
    }
    @Column(name = "team_id")
    public void setTeamdId(long teamdId) {
        this.teamdId = teamdId;
    }
    public long getRoleId() {
        return roleId;
    }
    @Column(name = "role_id")
    public void setRoleId(long roleId) {
        this.roleId = roleId;
    }
    public long getFunctionId() {
        return functionId;
    }
    @Column(name = "function_id")
    public void setFunctionId(long functionId) {
        this.functionId = functionId;
    }
}

+ 49 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/AdminTeamMemberRole.java

@ -0,0 +1,49 @@
package com.yihu.jw.entity.hospital.doctor;
import com.yihu.jw.entity.iot.gateway.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 团队成员角色。
 *
 * @author Sand
 */
@Entity
@Table(name = "dr_admin_team_member_role")
public class AdminTeamMemberRole extends IdEntity {
    private long teamId;
    private long doctorId;
    private long roleId;
    public long getTeamId() {
        return teamId;
    }
    @Column(name = "team_id")
    public void setTeamId(long teamId) {
        this.teamId = teamId;
    }
    public long getDoctorId() {
        return doctorId;
    }
    @Column(name = "doctor_id")
    public void setDoctorId(long doctorId) {
        this.doctorId = doctorId;
    }
    public long getRoleId() {
        return roleId;
    }
    @Column(name = "role_id")
    public void setRoleId(long roleId) {
        this.roleId = roleId;
    }
}

+ 77 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/AdminTeamRole.java

@ -0,0 +1,77 @@
package com.yihu.jw.entity.hospital.doctor;
import com.yihu.jw.entity.iot.gateway.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * @author Sand
 */
@Entity
@Table(name = "dr_admin_team_role")
public class AdminTeamRole extends IdEntity {
    private String name;
    private boolean avaliable;
    private Date createTime;
    private long creatorId;
    private int multiply;
    private String remarks;
    public String getName() {
        return name;
    }
    @Column(name = "name")
    public void setName(String name) {
        this.name = name;
    }
    public boolean isAvaliable() {
        return avaliable;
    }
    @Column(name = "avaliable")
    public void setAvaliable(boolean avaliable) {
        this.avaliable = avaliable;
    }
    public Date getCreateTime() {
        return createTime;
    }
    @Column(name = "create_time")
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public long getCreatorId() {
        return creatorId;
    }
    @Column(name = "creator_id")
    public void setCreatorId(long creatorId) {
        this.creatorId = creatorId;
    }
    public int getMultiply() {
        return multiply;
    }
    @Column(name = "multiply")
    public void setMultiply(int multiply) {
        this.multiply = multiply;
    }
    public String getRemarks() {
        return remarks;
    }
    @Column(name = "remarks")
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }
}

+ 119 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/doctor/Frequency.java

@ -0,0 +1,119 @@
package com.yihu.jw.entity.hospital.doctor;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.iot.gateway.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by wzn54 on 2019/1/17.
 */
@Entity
@Table(name = "wlyy_frequency")
public class Frequency extends IdEntity {
    private String code;//医属频次编码
    private String name;//医属频次名称
    private Integer count;//频次次数
    private Integer number;//频次数目
    private String unit;//频次单位
    private String time;//时间段
    private String description;//执行表达式
    private Integer del;//删除标志(0、删除,1、正常)
    private Date createTime;//创建时间
    private Date updateTime;//修改时间
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "count")
    public Integer getCount() {
        return count;
    }
    public void setCount(Integer count) {
        this.count = count;
    }
    @Column(name = "number")
    public Integer getNumber() {
        return number;
    }
    public void setNumber(Integer number) {
        this.number = number;
    }
    @Column(name = "unit")
    public String getUnit() {
        return unit;
    }
    public void setUnit(String unit) {
        this.unit = unit;
    }
    @Column(name = "time")
    public String getTime() {
        return time;
    }
    public void setTime(String time) {
        this.time = time;
    }
    @Column(name = "description")
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 46 - 9
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/SystemMessageDO.java

@ -61,7 +61,6 @@ public class SystemMessageDO extends UuidIdentityEntity {
     */
    private String del;
    private String over;//是否操作结束 是否操作结束 1否,0是
    private String code;
    /**
     *已读时间
     */
@ -73,6 +72,52 @@ public class SystemMessageDO extends UuidIdentityEntity {
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date createTime;
    private String content;
    private Integer state;
    private Integer readonly;
    private String reason;
    private String senderPhoto;
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @Column(name = "state")
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
    @Column(name = "readonly")
    public Integer getReadonly() {
        return readonly;
    }
    public void setReadonly(Integer readonly) {
        this.readonly = readonly;
    }
    @Column(name = "reason")
    public String getReason() {
        return reason;
    }
    public void setReason(String reason) {
        this.reason = reason;
    }
    @Column(name = "sender_photo")
    public String getSenderPhoto() {
        return senderPhoto;
    }
    public void setSenderPhoto(String senderPhoto) {
        this.senderPhoto = senderPhoto;
    }
    @Column(name = "type")
    public String getType() {
        return type;
@ -177,12 +222,4 @@ public class SystemMessageDO extends UuidIdentityEntity {
    public void setOver(String over) {
        this.over = over;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
}

+ 131 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/patient/PatientEvent.java

@ -0,0 +1,131 @@
package com.yihu.jw.entity.patient;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 患者就诊事件
 */
@Entity
@Table(name = "wlyy_patient_event")
public class PatientEvent extends UuidIdentityEntity implements Serializable {
	// 患者代码
	private String patient;
	// 就诊时间
	private Date eventDate;
	// 就诊类型
	private String eventType;
	// 机构代码
	private String orgCode;
	// 机构名称
	private String orgName;
	// 科室代码
	private String deptCode;
	// 科室名称
	private String deptName;
	// 医生代码
	private String doctorCode;
	// 医生名称
	private String doctorName;
	// 诊断
	private String dianosis;
	// 创建时间
	private Date createTime;
	public String getPatient() {
		return patient;
	}
	public void setPatient(String patient) {
		this.patient = patient;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getEventDate() {
		return eventDate;
	}
	public void setEventDate(Date eventDate) {
		this.eventDate = eventDate;
	}
	public String getEventType() {
		return eventType;
	}
	public void setEventType(String eventType) {
		this.eventType = eventType;
	}
	public String getOrgCode() {
		return orgCode;
	}
	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}
	public String getOrgName() {
		return orgName;
	}
	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}
	public String getDeptCode() {
		return deptCode;
	}
	public void setDeptCode(String deptCode) {
		this.deptCode = deptCode;
	}
	public String getDeptName() {
		return deptName;
	}
	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}
	public String getDoctorCode() {
		return doctorCode;
	}
	public void setDoctorCode(String doctorCode) {
		this.doctorCode = doctorCode;
	}
	public String getDoctorName() {
		return doctorName;
	}
	public void setDoctorName(String doctorName) {
		this.doctorName = doctorName;
	}
	public String getDianosis() {
		return dianosis;
	}
	public void setDianosis(String dianosis) {
		this.dianosis = dianosis;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
}

+ 120 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/rehabilitation/RehabilitationguidanceDO.java

@ -0,0 +1,120 @@
package com.yihu.jw.entity.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import com.yihu.jw.entity.iot.gateway.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by hmf on 2020/2/26.
 */
@Entity
@Table(name = "wlyy_rehabilitation_guidance")
public class RehabilitationguidanceDO extends IntegerIdentityEntity {
    private String code;
    private String title;//模板名称
    private String content;//模板内容
    private String createUser;//创建医生code,该字段为空即系统模板
    private String createUserName;//创建医生名称
    private Integer type;//指导类型0、冠心病,1、脑卒中,2、慢性前列腺,3肺癌
    private String typeName;//指导类型0、冠心病,1、脑卒中,2、慢性前列腺,3肺癌
    private Integer useCount;//使用次数
    private Date czrq;//操作时间
    private Integer del;//删除标志(1正常,0删除)
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
    @Column(name = "create_user")
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @Column(name = "create_user_name")
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @Column(name = "title")
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "use_count")
    public Integer getUseCount() {
        return useCount;
    }
    public void setUseCount(Integer useCount) {
        this.useCount = useCount;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    @Column(name = "type_name")
    public String getTypeName() {
        return typeName;
    }
    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }
}

+ 141 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/rehabilitation/RehabilitationguidancePatientDO.java

@ -0,0 +1,141 @@
package com.yihu.jw.entity.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
 * Created by hmf on 2020/2/26.
 */
@Entity
@Table(name = "wlyy_rehabilitation_guidance_patient")
public class RehabilitationguidancePatientDO extends IntegerIdentityEntity {
    private String patient;
    private String name;
    private String article;//模板code
    private String doctor;//模板内容
    private String doctorName;//创建医生code,该字段为空即系统模板
    private Integer isRead;//是否已读
    private String attachedContent;//康复指导内容
    private String attachedTitle;//康复指导标题
    private Integer sendStatus;//发送状态(1成功0失败)
    private String relationCode;//业务关联
    private Date czrq;//操作时间
    @Transient
    private String photo;//图片
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "article")
    public String getArticle() {
        return article;
    }
    public void setArticle(String article) {
        this.article = article;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "is_read")
    public Integer getIsRead() {
        return isRead;
    }
    public void setIsRead(Integer isRead) {
        this.isRead = isRead;
    }
    @Column(name = "attached_content")
    public String getAttachedContent() {
        return attachedContent;
    }
    public void setAttachedContent(String attachedContent) {
        this.attachedContent = attachedContent;
    }
    @Column(name = "attached_title")
    public String getAttachedTitle() {
        return attachedTitle;
    }
    public void setAttachedTitle(String attachedTitle) {
        this.attachedTitle = attachedTitle;
    }
    @Column(name = "send_status")
    public Integer getSendStatus() {
        return sendStatus;
    }
    public void setSendStatus(Integer sendStatus) {
        this.sendStatus = sendStatus;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "relation_code")
    public String getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
    @Transient
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
}

+ 72 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/rehabilitation/SpecialDiseaseMessagesDO.java

@ -0,0 +1,72 @@
package com.yihu.jw.entity.rehabilitation;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/***
 * @ClassName: SpecialDiseaseMessages
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/4/20 9:42
 */
@Entity
@Table(name = "wlyy_special_disease_messages")
public class SpecialDiseaseMessagesDO extends IdEntity {
    private String name;
    private String address;
    private String result;
    private String createTime;
    private String code;
    private String codeType;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public String getResult() {
        return result;
    }
    public void setResult(String result) {
        this.result = result;
    }
    public String getCreateTime() {
        return createTime;
    }
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getCodeType() {
        return codeType;
    }
    public void setCodeType(String codeType) {
        this.codeType = codeType;
    }
}

+ 406 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/DoctorPatientRelationDO.java

@ -0,0 +1,406 @@
package com.yihu.jw.entity.specialist;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
@Entity
@Table(name = "wlyy_doctor_patient_relation")
public class DoctorPatientRelationDO extends UuidIdentityEntity {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "discharge_record")
    private String dischargeRecord;//最新出院记录
    @Column(name = "doctor")
    private String doctor;//专科医生
    @Column(name = "doctor_name")
    private String doctorName;//专科医生姓名
    @Column(name = "patient")
    private String patient;// 居民(患者)
    @Column(name = "patient_name")
    private String patientName;//居民(患者)姓名
    @Column(name = "health_assistant")
    private String healthAssistant;//计管师
    @Column(name = "health_assistant_name")
    private String healthAssistantName;//计管师
    @Column(name = "sign_status")
    private String signStatus;//居民与专科医生签约状态: -2 医生拒绝,-1 已经取消,0待审核,1同意',
    @Column(name = "status")
    private String status;//1.已经分配,0,待分配,-1失效
    @Column(name = "pk_code")
    private String pkCode; //服务包code
    @Column(name = "sign_code")
    private String signCode;//签约code
    @Column(name = "sign_doctor")
    private String signDoctor;//签约医生
    @Column(name = "sign_doctor_name")
//    @Convert(converter = StringFStringEncryptConverter.class)
    private String signDoctorName;//签约医生
    @Column(name = "health_doctor")
    private String healthDoctor;//健康管理师
    @Column(name = "health_doctor_name")
//    @Convert(converter = StringFStringEncryptConverter.class)
    private String healthDoctorName;//健康管理师姓名
    @Column(name = "sign_year")
    private String signYear;//签约年度
    @Column(name = "team_code")
    private String teamCode;//专科医生签约团队',
    @Column(name = "sign_date")
    private Date signDate;//签约日期
    @Column(name = "remark")
    private String remark;//记录专科医生审核原因等
    @Column(name = "sign_certificate")
    private String signCertificate;//签约证明
    @Column(name = "health_status_code")
    private String healthStatusCode;//健康状况编码
    @Column(name = "disease_code")
    private String diseaseCode;//签约疾病编码,多个使用逗号隔开
    @Column(name = "is_manage")
    private Integer isManage;//是否管理(1管理0未管理)
    @Column(name = "manage_user")
    private String manageUser;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "manage_time")
    private Date manageTime;
    private Date createTime;
    private String createUser;
    private String createUserName;
    private Date updateTime;
    private String updateUser;
    private String updateUserName;
    private String remindTime;
    @Column(name = "isdeal")
    private String isdeal;
    @Column(name = "relation_type")
    private String relationType;//relation_type
    private String dept;
    private String deptName;
    @Column(name = "dept")
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    @Column(name = "dept_name")
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    public String getIsdeal() {
        return isdeal;
    }
    public void setIsdeal(String isdeal) {
        this.isdeal = isdeal;
    }
    public String getRelationType() {
        return relationType;
    }
    public void setRelationType(String relationType) {
        this.relationType = relationType;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getDischargeRecord() {
        return dischargeRecord;
    }
    public void setDischargeRecord(String dischargeRecord) {
        this.dischargeRecord = dischargeRecord;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    //    @Convert(converter = StringFStringEncryptConverter.class)
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    //    @Convert(converter = StringFStringEncryptConverter.class)
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getSignCode() {
        return signCode;
    }
    public void setSignCode(String signCode) {
        this.signCode = signCode;
    }
    public String getSignDoctor() {
        return signDoctor;
    }
    public void setSignDoctor(String signDoctor) {
        this.signDoctor = signDoctor;
    }
    //    @Convert(converter = StringFStringEncryptConverter.class)
    public String getSignDoctorName() {
        return signDoctorName;
    }
    public void setSignDoctorName(String signDoctorName) {
        this.signDoctorName = signDoctorName;
    }
    public String getHealthDoctor() {
        return healthDoctor;
    }
    public void setHealthDoctor(String healthDoctor) {
        this.healthDoctor = healthDoctor;
    }
    //    @Convert(converter = StringFStringEncryptConverter.class)
    public String getHealthDoctorName() {
        return healthDoctorName;
    }
    public void setHealthDoctorName(String healthDoctorName) {
        this.healthDoctorName = healthDoctorName;
    }
    public String getSignYear() {
        return signYear;
    }
    public void setSignYear(String signYear) {
        this.signYear = signYear;
    }
    public Date getSignDate() {
        return signDate;
    }
    public void setSignDate(Date signDate) {
        this.signDate = signDate;
    }
    public String getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(String teamCode) {
        this.teamCode = teamCode;
    }
    public String getHealthAssistant() {
        return healthAssistant;
    }
    public void setHealthAssistant(String healthAssistant) {
        this.healthAssistant = healthAssistant;
    }
    //    @Convert(converter = StringFStringEncryptConverter.class)
    public String getHealthAssistantName() {
        return healthAssistantName;
    }
    public void setHealthAssistantName(String healthAssistantName) {
        this.healthAssistantName = healthAssistantName;
    }
    public String getPkCode() {
        return pkCode;
    }
    public void setPkCode(String pkCode) {
        this.pkCode = pkCode;
    }
    public String getSignStatus() {
        return signStatus;
    }
    public void setSignStatus(String signStatus) {
        this.signStatus = signStatus;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getSignCertificate() {
        return signCertificate;
    }
    public void setSignCertificate(String signCertificate) {
        this.signCertificate = signCertificate;
    }
    public String getHealthStatusCode() {
        return healthStatusCode;
    }
    public void setHealthStatusCode(String healthStatusCode) {
        this.healthStatusCode = healthStatusCode;
    }
    public String getDiseaseCode() {
        return diseaseCode;
    }
    public void setDiseaseCode(String diseaseCode) {
        this.diseaseCode = diseaseCode;
    }
    public Integer getIsManage() {
        return isManage;
    }
    public void setIsManage(Integer isManage) {
        this.isManage = isManage;
    }
    public String getManageUser() {
        return manageUser;
    }
    public void setManageUser(String manageUser) {
        this.manageUser = manageUser;
    }
    public Date getManageTime() {
        return manageTime;
    }
    public void setManageTime(Date manageTime) {
        this.manageTime = manageTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    //    @Convert(converter = StringFStringEncryptConverter.class)
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getUpdateUser() {
        return updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    //    @Convert(converter = StringFStringEncryptConverter.class)
    public String getUpdateUserName() {
        return updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    public String getRemindTime() {
        return remindTime;
    }
    public void setRemindTime(String remindTime) {
        this.remindTime = remindTime;
    }
}

+ 20 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistPatientRelationDO.java

@ -99,6 +99,26 @@ public class SpecialistPatientRelationDO extends UuidIdentityEntity implements S
    private String updateUser;
    private String updateUserName;
    private String remindTime;
    @Column(name = "isdeal")
    private String isdeal;
    @Column(name = "relation_type")
    private String relationType;//relation_type
    public String getIsdeal() {
        return isdeal;
    }
    public void setIsdeal(String isdeal) {
        this.isdeal = isdeal;
    }
    public String getRelationType() {
        return relationType;
    }
    public void setRelationType(String relationType) {
        this.relationType = relationType;
    }
    public String getSaasId() {
        return saasId;

+ 233 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/PatientMedicalRecordsDO.java

@ -0,0 +1,233 @@
package com.yihu.jw.entity.specialist.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * create by hmf on 2020/02/27 居民住院病历
 */
@Entity
@Table(name = "wlyy_patient_medical_records_rehabilitation")
public class PatientMedicalRecordsDO extends UuidIdentityEntity {
    private String code;
    private String patient;//居民code
    private String patientName;//居民姓名
    private String hospital;//诊疗医院code
    private String hospitalName;//诊疗医院名称
    private String dischargeDiagnosis;//出院诊断code,多个用逗号隔开
    private String dischargeDiagnosisName;//出院诊断名称,多个用逗号隔开
    private String admittingDiagnosis;//入院诊断code,多个用逗号隔开
    private String admittingDiagnosisName;//入院诊断名称,多个用逗号隔开
    private String advice;//医嘱小结
    private Date admissionTime;//入院时间
    private Date dischargeTime;//出院时间
    private String images;//病历图片,多个用逗号隔开
    private Date createTime;//创建时间
    private String createUser;//创建者
    private String createUserName;//创建者
    private String event;//健康档案病历eventID
    private String dataFrom;//病历来源:1基位,2app,3中山医院,4智业六家医院
    private String jwpatient;//基位居民code 获取病历详情用
    private String diseaseCode;//专病code
    private String diseaseName;//专病名称
    private int  patientReadStatus;
    private int  doctorReadStatus;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    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 getDischargeDiagnosis() {
        return dischargeDiagnosis;
    }
    public void setDischargeDiagnosis(String dischargeDiagnosis) {
        this.dischargeDiagnosis = dischargeDiagnosis;
    }
    public String getDischargeDiagnosisName() {
        return dischargeDiagnosisName;
    }
    public void setDischargeDiagnosisName(String dischargeDiagnosisName) {
        this.dischargeDiagnosisName = dischargeDiagnosisName;
    }
    public String getAdmittingDiagnosis() {
        return admittingDiagnosis;
    }
    public void setAdmittingDiagnosis(String admittingDiagnosis) {
        this.admittingDiagnosis = admittingDiagnosis;
    }
    public String getAdmittingDiagnosisName() {
        return admittingDiagnosisName;
    }
    public void setAdmittingDiagnosisName(String admittingDiagnosisName) {
        this.admittingDiagnosisName = admittingDiagnosisName;
    }
    public String getImages() {
        return images;
    }
    public void setImages(String images) {
        this.images = images;
    }
    public String getAdvice() {
        return advice;
    }
    public void setAdvice(String advice) {
        this.advice = advice;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getAdmissionTime() {
        return admissionTime;
    }
    public void setAdmissionTime(Date admissionTime) {
        this.admissionTime = admissionTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getDischargeTime() {
        return dischargeTime;
    }
    public void setDischargeTime(Date dischargeTime) {
        this.dischargeTime = dischargeTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    public String getEvent() {
        return event;
    }
    public void setEvent(String event) {
        this.event = event;
    }
    public String getDataFrom() {
        return dataFrom;
    }
    public void setDataFrom(String dataFrom) {
        this.dataFrom = dataFrom;
    }
    public String getJwpatient() {
        return jwpatient;
    }
    public void setJwpatient(String jwpatient) {
        this.jwpatient = jwpatient;
    }
    @Column(name = "disease_code")
    public String getDiseaseCode() {
        return diseaseCode;
    }
    public void setDiseaseCode(String diseaseCode) {
        this.diseaseCode = diseaseCode;
    }
    @Column(name = "disease_name")
    public String getDiseaseName() {
        return diseaseName;
    }
    public void setDiseaseName(String diseaseName) {
        this.diseaseName = diseaseName;
    }
    @Column(name = "patient_read_status")
    public int getPatientReadStatus() {
        return patientReadStatus;
    }
    public void setPatientReadStatus(int patientReadStatus) {
        this.patientReadStatus = patientReadStatus;
    }
    @Column(name = "doctor_read_status")
    public int getDoctorReadStatus() {
        return doctorReadStatus;
    }
    public void setDoctorReadStatus(int doctorReadStatus) {
        this.doctorReadStatus = doctorReadStatus;
    }
}

+ 21 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/PatientRehabilitationPlanDO.java

@ -2,11 +2,8 @@ package com.yihu.jw.entity.specialist.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.entity.util.StringFStringEncryptConverter;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
@ -61,6 +58,18 @@ public class PatientRehabilitationPlanDO extends UuidIdentityEntity implements S
    private String updateUserName;
    private String healthStatusCode;//健康情况
    private String isVerify;
    private Long adminTeamCode;//家签行政团队Id
    @Column(name = "is_verify")
    public String getIsVerify() {
        return isVerify;
    }
    public void setIsVerify(String isVerify) {
        this.isVerify = isVerify;
    }
    @Column(name = "saas_id")
    public String getSaasId() {
@ -275,4 +284,13 @@ public class PatientRehabilitationPlanDO extends UuidIdentityEntity implements S
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    @Column(name = "admin_team_code")
    public Long getAdminTeamCode() {
        return adminTeamCode;
    }
    public void setAdminTeamCode(Long adminTeamCode) {
        this.adminTeamCode = adminTeamCode;
    }
}

+ 73 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationAdviceDO.java

@ -0,0 +1,73 @@
package com.yihu.jw.entity.specialist.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.iot.gateway.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by hmf on 2020/2/26.
 */
@Entity
@Table(name = "wlyy_rehabilitation_advice")
public class RehabilitationAdviceDO extends IdEntity {
    private String code;
    private String name;//模板时间
    private String content;//模板内容
    private String createUser;//创建医生code,该字段为空即系统模板
    private String createUserName;//创建医生名称
    private Date createTime;//操作时间
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
}

+ 31 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/util/RSA.java

@ -0,0 +1,31 @@
package com.yihu.jw.entity.util;
import com.yihu.jw.entity.iot.gateway.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
/**
 * 非对象算法加密信息
 * @author George
 *
 */
@Entity
@Table(name = "dm_rsa")
public class RSA extends IdEntity {
	private static final long serialVersionUID = 7832717679571844202L;
	
	private byte[] data;
	@Lob
	public byte[] getData() {
	    return data;
	}
	
	public void setData(byte[] data){
		this.data = data;
	}
}

+ 208 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/util/SystemConf.java

@ -0,0 +1,208 @@
package com.yihu.jw.entity.util;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
@Component
public class SystemConf {
    // 别处登录
    public static final int LOGIN_OTHER = 999;
    // 登录超时
    public static final int LOGIN_TIMEOUT = 998;
    // 未登录
    public static final int NOT_LOGIN = 997;
    // 文件保存临时路径
    private static final String TEMP_PATH = "upload_temp_path";
    // 血糖餐前最小值
    public static final double HEALTH_STANDARD_ST_MIN_BEFORE = 4;
    // 血糖餐前最大值
    public static final double HEALTH_STANDARD_ST_MAX_BEFORE = 7;
    // 血糖餐后最小值
    public static final double HEALTH_STANDARD_ST_MIN_AFTER = 4;
    // 血糖餐后最大值
    public static final double HEALTH_STANDARD_ST_MAX_AFTER = 11.1;
    // 舒张压最小值
    public static final double HEALTH_STANDARD_SZY_MIN = 60;
    // 舒张压最大值
    public static final double HEALTH_STANDARD_SZY_MAX = 90;
    // 收缩压最小值
    public static final double HEALTH_STANDARD_SSY_MIN = 90;
    // 收缩压最大值
    public static final double HEALTH_STANDARD_SSY_MAX = 140;
    // 同一手机号大最短信数
    public static final int MAX_SMS_MOBILE = 5;
    // 发送短信验证码间隔(分钟)
    public static final int SMS_INTERVAL = 2;
    private static Object lock = new Object();
    // 全局系统配置信息
    private static SystemConf systemConf;
    // 系统配置文件
    private Properties systemProperties;
    //im列表
    private String imListGet;
    public static SystemConf getInstance() {
        if (systemConf == null) {
            synchronized (lock) {
                systemConf = new SystemConf();
            }
        }
        return systemConf;
    }
    /**
     * 加载系统配置文件
     *
     * @return
     */
    public Properties getSystemProperties() {
        if (systemProperties == null) {
            InputStream is = null;
            try {
                is = this.getClass().getResourceAsStream("/system.properties");
                systemProperties = new Properties();
                systemProperties.load(is);
            } catch (IOException e1) {
                e1.printStackTrace();
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return systemProperties;
    }
    /**
     * 短信接口地址
     */
    public String getSmsUrl() {
        return getSystemProperties().getProperty("yihu_sms_url");
    }
    /**
     * 短信企业编号
     */
    public String getSmsCode() {
        return getSystemProperties().getProperty("yihu_sms_code");
    }
    /**
     * 短信用户名
     */
    public String getSmsName() {
        return getSystemProperties().getProperty("yihu_sms_name");
    }
    /**
     * 短信登录密码
     */
    public String getSmsPassword() {
        return getSystemProperties().getProperty("yihu_sms_password");
    }
    ;
    /**
     * 挂号接口地址
     */
    public String getGuahaoUrl() {
        return getSystemProperties().getProperty("yihu_guahao_url");
    }
    /**
     * 挂号接口对接appid
     */
    public String getGuahaoAppid() {
        return getSystemProperties().getProperty("yihu_guahao_appid");
    }
    /**
     * 挂号接口对接app secret
     */
    public String getGuahaoSecret() {
        return getSystemProperties().getProperty("yihu_guahao_secret");
    }
    /**
     * 获取文件保存的临时路径
     *
     * @return
     */
    public String getTempPath() {
        return getSystemProperties().getProperty(TEMP_PATH);
    }
    /**
     * 获取图片存在地址
     *
     * @return
     */
    /**
     * 获取服务全路径
     *
     * @return
     */
    /******************************** 挂号配置 ********************************************/
    /**
     * 获取厦门预约服务地址
     */
    public String getXMGuahaoUrl() {
        return getSystemProperties().getProperty("guahao_url");
    }
    /**
     * 获取厦门预约服务命名空间
     */
    public String getXMGuahaoNamespace() {
        return getSystemProperties().getProperty("guahao_namespace");
    }
    /****************************************************************************************/
    /********************************* EHR配置 **********************************************/
    /**
     * 是否启用EHR演示
     */
    public Boolean getEhrUsed() {
        return Boolean.valueOf(getSystemProperties().getProperty("ehr_used"));
    }
    /**
     * EHR档案服务地址
     */
    public String getEhrServices() {
        return getSystemProperties().getProperty("ehr_services");
    }
    /**
     * EHR底层地址
     */
    public String getEhrServicesBase() {
        return getSystemProperties().getProperty("ehr_services_base");
    }
    /**************************************************************************************/
    /**************************************************************************************/
}

+ 72 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/wlyyinfo/WechatTag.java

@ -0,0 +1,72 @@
package com.yihu.jw.entity.wlyyinfo;
import com.yihu.jw.entity.iot.gateway.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by chenweida on 2017/8/4.
 */
@Entity
@Table(name = "wx_tag")
public class WechatTag extends IdEntity {
    private Integer tagId;
    private String tagName;
    private Date createTime;
    private Integer del;
    private String townCode;//区code
    private String townName;//区名称
    public Integer getTagId() {
        return tagId;
    }
    public void setTagId(Integer tagId) {
        this.tagId = tagId;
    }
    public String getTagName() {
        return tagName;
    }
    public void setTagName(String tagName) {
        this.tagName = tagName;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getTownCode() {
        return townCode;
    }
    public void setTownCode(String townCode) {
        this.townCode = townCode;
    }
    public String getTownName() {
        return townName;
    }
    public void setTownName(String townName) {
        this.townName = townName;
    }
}

+ 74 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/rehabilitation/RehabilitationRequestMapping.java

@ -32,6 +32,80 @@ public class RehabilitationRequestMapping {
        public static final String findInformationPage = "findInformationPage";
    }
    public static class DoctorRehabilitationInfo {
        public static final String Perfix = "/rehabilitationInfo";
        public static final String createAdvice = "/createAdvice";
        public static final String deleteAdvice = "/deleteAdvice";
        public static final String getAdviceListByDoctor = "/getAdviceListByDoctor";
        public static final String sendWxMsgRemindSign = "/sendWxMsgRemindSign";
        public static final String findInformationById = "findInformationById";
        public static final String findInformationByPatientId = "findInformationByPatientId";
        public static final String findInformationPage = "findInformationPage";
    }
    public static class DoctorRehabilitationPlan {
        public static final String Perfix = "/rehabilitationPlan";
        public static final String createRehabilitationPlan = "/createRehabilitationPlan";
        public static final String createServiceQrCode = "/createServiceQrCode";
        public static final String checkAfterQrCode = "/checkAfterQrCode";
        public static final String saveRehabilitationOperateRecord = "/saveRehabilitationOperateRecord";
        public static final String updatePlanStatusById = "/updatePlanStatusById";
        public static final String updatePatientImgById = "/updatePatientImgById";
        public static final String findServicePackageItem = "/findServicePackageItem";
        public static final String findServiceItemInBase = "/findServiceItemInBase";
        public static final String findDoctorByTeams = "/findDoctorByTeams";
        public static final String findDoctorTeams = "/findDoctorTeams";
        public static final String findDoctorPatients = "/findDoctorPatients";
    }
    public static class PatientRehabilitationManage {
        public static final String Perfix = "/patientRehabilitationManage";
        public static final String patientRehabilitationDetail = "/patientRehabilitationDetail";
        public static final String calendarPlanDetail = "/calendarPlanDetail";
        public static final String serviceDoctorList = "/serviceDoctorList";
        public static final String calendarPlanDetailList = "/calendarPlanDetailList";
        public static final String sendMessageIm = "/sendMessageIm";
        public static final String checkAfterQrCode = "/checkAfterQrCode";
        public static final String saveRehabilitationOperateRecord = "/saveRehabilitationOperateRecord";
        public static final String recentPlanDetailRecord = "/recentPlanDetailRecord";
        public static final String serviceItemList = "/serviceItemList";
        public static final String serviceItem = "/serviceItem";
        public static final String planSchedule = "/planSchedule";
        public static final String updatePatientImgById = "/updatePatientImgById";
        public static final String getServiceItemsAfterStop = "/getServiceItemsAfterStop";
    }
    public static class DoctorRehabilitationManage {
        public static final String perfix = "/rehabilitationManage";
        public static final String findRehabilitationPlanList = "/findRehabilitationPlanList";
        public static final String findRehabilitationPlanDetailList = "/findRehabilitationPlanDetailList";
        public static final String calendarPlanDetail = "/calendarPlanDetail";
        public static final String calendarPlanDetailList = "/calendarPlanDetailList";
        public static final String serviceItemList = "/serviceItemList";
        public static final String serviceItem = "/serviceItem";
        public static final String saveGuidanceMessage = "/saveGuidanceMessage";
        public static final String updateStatusRehabilitationOperate = "/updateStatusRehabilitationOperate";
        public static final String patientRehabilitationDetail = "/patientRehabilitationDetail";
        public static final String recentPlanDetailRecord = "/recentPlanDetailRecord";
        public static final String serviceDoctorList = "/serviceDoctorList";
        public static final String appCalendarPlanDetailList = "/appCalendarPlanDetailList";
        public static final String updatePlanDetailStatusById = "/updatePlanDetailStatusById";
        public static final String planSchedule = "/planSchedule";
        public static final String patientCount = "/patientCount";
        public static final String sendToFamilyDoctor = "/sendToFamilyDoctor";
        public static final String getServiceItemsAfterStop = "/getServiceItemsAfterStop";
        public static final String selectFrequencys = "/selectFrequencys";
        public static final String updateNoteAndImageRehabilitationOperate = "/updateNoteAndImageRehabilitationOperate";
        public static final String updatePlanDetailExecuteTimeById = "/updatePlanDetailExecuteTimeById";
    }
    public static class TreatmentProgram {
        public static final String treatmentProgram = api_rehabilitation_common + "/treatmentProgram";

+ 20 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/endpoint/EnvelopRestEndpoint.java

@ -436,7 +436,26 @@ public abstract class EnvelopRestEndpoint extends Exception {
        return links.toString();
    }
    /**
     * 获取被代理人code,若没有则返回当前登录者
     * @return
     */
    public String getRepUID(){
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            String userAgent = request.getHeader("userAgent");
            if (org.apache.commons.lang3.StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = JSONObject.parseObject(userAgent);
            if(!json.containsKey("represented")){
                return json.getString("uid");
            }
            return json.getString("represented");
        } catch (Exception e) {
            return null;
        }
    }
    public String getUID() {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();

+ 88 - 0
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -723,6 +723,40 @@ public class DateUtil {
        return str;
    }
    /**
     * 日期比较大小
     * @param s1
     * @param s2
     * @return
     */
    public static long compareDate(java.util.Date s1, java.util.Date s2) {
        try {
            return compareDate(YYYY_MM_DD, dateToStrShort(s1), dateToStrShort(s2));
        } catch (Exception e) {
            return -1;
        }
    }
    /**
     * 字符串日期比较大小
     * @param format
     * @param s1
     * @param s2
     * @return
     */
    public static long compareDate(String format, String s1, String s2) {
        SimpleDateFormat f = new SimpleDateFormat(format);
        try {
            return f.parse(s1).getTime() - f.parse(s2).getTime();
        } catch (Exception e) {
            return -1;
        }
    }
    /**
     * 两个时间之间的天数
     *
@ -1012,6 +1046,49 @@ public class DateUtil {
        return nousedate;
    }
    /**
     *时间字符串转为 时间戳
     * @param str
     * @param format
     * @return
     */
    public static Timestamp toTimestamp(String str, String format) {
        if (str == null) {
            return null;
        }
        try {
            return new Timestamp(stringToDate(str, format).getTime());
        } catch (Exception e) {
            return null;
        }
    }
    /**
     *时间字符串转为 时间戳
     * @param str
     * @param
     * @return
     */
    public static Timestamp toTimestamp(String str) {
        if (str == null) {
            return null;
        }
        try {
            return Timestamp.valueOf(str.trim());
        } catch (IllegalArgumentException iae) {
            return null;
        }
    }
    public static long compareDateTime(java.util.Date s1, java.util.Date s2) {
        return s1.getTime() - s2.getTime();
    }
    /**
     *  日期加减天数
     * @param date 时间
@ -1268,4 +1345,15 @@ public class DateUtil {
        return lDate;
    }
    public static String getDateFromDateTime(String dateTime) {
        if (dateTime == null || dateTime.length() < YYYY_MM_DD.length()) {
            return null;
        }
        return dateTime.substring(0, 10);
    }
}

+ 3 - 0
gateway/ag-basic/src/main/resources/application.yml

@ -83,6 +83,9 @@ zuul:
    svr-cloud-care:
      path: /cloudCare/**
      serviceId: svr-cloud-care
    svr-rehabilitation:
      path: /rehabilitation/**
      serviceId: svr-rehabilitation
#---
#spring:

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

@ -154,6 +154,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private BaseDoctorDao doctorDao;
    @Value("${wechat.id}")
    private String wechatId;
    @Value("${kick.eachOther}")
    private String kickEachOther;
    @Autowired
    private XzzxService xzzxService;
    @Autowired
@ -329,15 +331,18 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        /*如果是移动端登陆则移除之前的token,
        在网关处通过HTTP状态码告知前端是过期(402)还是账号在别处登陆(403),
        实现同一账号只能在一处登陆*/
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
            tokenStore.removeAccessToken(token.getValue());
            tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
            token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
        }
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        if("1".equals(kickEachOther)){
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            if (request.getHeader("login-device") != null && (request.getHeader("login-device").equalsIgnoreCase("mobile")||request.getHeader("login-device").equalsIgnoreCase("pc"))) {
                tokenStore.removeAccessToken(token.getValue());
                tokenStore.removeRefreshToken(token.getRefreshToken().getValue());
                token = getTokenGranter().grant(tokenRequest.getGrantType(), tokenRequest);
            }
            if (token == null) {
                throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
            }
        }
        WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
        wlyyUserSimple.setAccessToken(token.getValue());
        wlyyUserSimple.setTokenType(token.getTokenType());

+ 7 - 0
server/svr-authentication/src/main/resources/application.yml

@ -53,6 +53,10 @@ fast-dfs:
    init-size: 5
    max-size: 20
    wait-time: 500
kick:
    ##互踢 1开通 0关闭
    eachOther: 1
---
spring:
  profiles: jwdev
@ -406,6 +410,9 @@ testPattern:
wechat:
  id: hz_yyyzh_wx  # base库中,wx_wechat 的id字段
kick:
    ##互踢 1开通 0关闭
    eachOther: 0
---
spring:
  profiles: wjwProd

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java

@ -746,6 +746,10 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                 baseDoctorHospitalService.delete(hospitalIdList.toArray());
             }
         }
         else {//全部移除
            List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(baseDoctorDO.getId());
             baseDoctorHospitalDao.delete(doctorHospitalDOS);
         }
        if (!StringUtils.isEmpty(teamCode)){
            String[] teamCodeList = teamCode.split(",");
            List<BaseTeamMemberDO> tmlist = baseTeamMemberDao.findUseDoctorCode(baseDoctorDO.getId());

+ 41 - 9
svr/svr-base/src/main/java/com/yihu/jw/base/service/order/PayService.java

@ -2,11 +2,14 @@ package com.yihu.jw.base.service.order;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.common.WxPayHttpLogDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.pay.dao.WxPayHttpLogDao;
import com.yihu.jw.pay.service.CloudCarePayService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
@ -14,10 +17,12 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@ -38,6 +43,12 @@ public class PayService {
    private BasePatientDao patientDao;
    @Autowired
    private CloudCarePayService payService;
    @Autowired
    private BusinessOrderService businessOrderService;
    @Value("${wechat.id}")
    public String wechatId;
    @Autowired
    private WxPayHttpLogDao wxPayHttpLogDao;
    /**
     * 订单列表
@ -99,8 +110,8 @@ public class PayService {
                                    Integer page,Integer pageSize){
        page = page>0?page-1:0;
        String sql = " select pay.patient,pay.patient_name,pay.order_no,pay.order_type,pay.order_category,pay.relation_code, " +
                " pay.relation_name,pay.description,pay.pay_type,pay.pay_price,pay.yk_order_id,DATE_FORMAT(re.create_time,'%Y-%m-%d %H:%i:%S') create_time, " +
                " re.enclosure,re.refund_desc,re.`status` from base_business_order_pay pay inner JOIN base_business_order_refund re on  " +
                " pay.relation_name,pay.description payDescription,pay.pay_type,pay.pay_price,pay.yk_order_id,DATE_FORMAT(re.create_time,'%Y-%m-%d %H:%i:%S') create_time, " +
                " re.enclosure,re.refund_desc description,re.refuse_desc,re.`status` from base_business_order_pay pay inner JOIN base_business_order_refund re on  " +
                " pay.order_no = re.order_no where pay.status>=3  ";
        String sqlCount = "select count(re.id) from base_business_order_pay pay inner JOIN " +
                " base_business_order_refund re on pay.order_no = re.order_no where pay.status>=3 ";
@ -167,7 +178,7 @@ public class PayService {
        businessOrderRefundDO.setRefuseDesc(refuseDesc);
        businessOrderDao.save(businessOrderDO);
        businessOrderRefundDao.save(businessOrderRefundDO);
        result.put(ResponseContant.resultFlag, ResponseContant.fail);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, "success");
        return result;
    }
@ -205,16 +216,37 @@ public class PayService {
        }
        businessOrderDO.setStatus(4);
        businessOrderRefundDO.setStatus(3);
        //退款流程
        payService.orderRefund(orderNo);
        businessOrderRefundDO.setStatus(2);
        businessOrderDao.save(businessOrderDO);
        businessOrderRefundDao.save(businessOrderRefundDO);
        result.put(ResponseContant.resultFlag, ResponseContant.fail);
        //退款流程
        Integer orderPrice = new BigDecimal(businessOrderRefundDO.getOrderPrice()*100).intValue();
        Integer refundPrice1 = new BigDecimal(businessOrderRefundDO.getRefundPrice()*100).intValue();
        Map<String,Object> map = businessOrderService.refund(wechatId,businessOrderRefundDO.getOrderNo(),businessOrderRefundDO.getOutRefundNo(),orderPrice.toString(),refundPrice1.toString(),businessOrderRefundDO.getRefundDesc());
        log.info("map"+map);
        addHttpLog("1",businessOrderDO.getOrderNo(),null,map.toString());
        if (!map.get("return_code").toString().equalsIgnoreCase("SUCCESS")){
            //退款申请提交成功
            throw new Exception(map.get("return_msg").toString());
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, "success");
        return result;
    }
    /**
     * 添加支付日志
     * @param type
     * @param orderNo
     * @param res
     * @param req
     */
    public void addHttpLog(String type,String orderNo,String res,String req){
        WxPayHttpLogDO logDO = new WxPayHttpLogDO();
        logDO.setType(type);
        logDO.setOrderNo(orderNo);
        logDO.setOrderReq(req);
        logDO.setOrderRes(res);
        wxPayHttpLogDao.save(logDO);
    }
}

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

@ -208,7 +208,7 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
    public JSONObject queryOneById(String id) throws JsonProcessingException {
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(id)){
            result.put("msg","org not exist for id:"+id);
            result.put("msg","该机构不存在 id:"+id);
            result.put("response",ConstantUtils.FAIL);
            return result;
        }
@ -236,7 +236,7 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
            String mobile = orgAdminJson.getString("mobile");
            String adminName = orgAdminJson.getString("orgAdmin");
            if(StringUtils.isEmpty(mobile)){
                return "paramter for admin is null";
                return "联系电话不能为空!";
            }
            baseOrgDO.setOrgAdmin(adminName);
            baseOrgDO.setAdminMobile(mobile);
@ -268,7 +268,7 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
        }else{
            BaseOrgDO oldBaseOrgDO = baseOrgDao.findOne(baseOrgDO.getId());
            if(null == oldBaseOrgDO){
                return "no exist this org";
                return "机构不存在";
            }
            if(!baseOrgDO.getCode().equalsIgnoreCase(oldBaseOrgDO.getCode()) || !baseOrgDO.getName().equalsIgnoreCase(oldBaseOrgDO.getName())){
                orgTreeService.updateOrgTreeNode(oldBaseOrgDO,baseOrgDO,OrgTree.Level.org.getLevelValue());
@ -309,13 +309,13 @@ public class BaseOrgService extends BaseJpaService<BaseOrgDO, BaseOrgDao> {
    public String enableOrDisableOrg(String id,String del){
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(id) || StringUtils.isEmpty(del)){
            result.put("msg","parameter id or del is null");
            result.put("msg","参数id or del 为空");
            result.put("response",ConstantUtils.FAIL);
            return result.toJSONString();
        }
        BaseOrgDO baseOrgDO = baseOrgDao.findOne(id);
        if( null == baseOrgDO ){
            result.put("msg","org not exist for id:" + id);
            result.put("msg","该机构不存在 id:" + id);
            result.put("response",ConstantUtils.FAIL);
            return result.toJSONString();
        }

+ 7 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DeviceDetailDao.java

@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author yeshijie on 2018/1/10.
 */
@ -13,4 +15,9 @@ public interface DeviceDetailDao extends PagingAndSortingRepository<DeviceDetail
    @Query(value = "select a.* from wlyy_devices a where a.device_code=?1 limit 0,1",nativeQuery = true)
    DeviceDetail findBySn(String sn);
    List<DeviceDetail> findByDeviceCode(String deviceCode);
    @Query("select a from DeviceDetail a where a.deviceCode = ?1 and a.manufacturerCode = ?2")
    DeviceDetail findByDeviceCodeAndManufacturerCode(String deviceCode,String manufacturerCode);
}

+ 9 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DeviceInfoDao.java

@ -0,0 +1,9 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.DeviceInfo;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;
@Transactional
public interface DeviceInfoDao extends CrudRepository<DeviceInfo, Long> {
}

+ 7 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DevicePatientHealthIndexDao.java

@ -67,4 +67,11 @@ public interface DevicePatientHealthIndexDao
	@Query("select count(a) from DevicePatientHealthIndex a where a.recordDate >= ?1 and a.recordDate <= ?2 and a.type in (1,2) and a.status = ?3 and a.del = '1' and user = ?4")
	int getCountByTimeAndStatus(Date start, Date end, int status, String patientCode);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.deviceSn = ?2 and a.value1 = ?3 and a.type = ?4 and a.recordDate >= ?5 and a.recordDate<=?6 and a.del = '1' ")
	List<DevicePatientHealthIndex> findByTypeInHalfMinute(String patient, String deviceSn, String value1, Integer type, Date minDate,Date maxDate);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.deviceSn = ?2 and a.value1 = ?3 and a.value2=?7 and a.value3=?8 and a.type = ?4 and a.recordDate >= ?5 and a.recordDate<=?6 and a.del = '1' ")
	List<DevicePatientHealthIndex> findByTypeInHalfMinuteAllValue(String patient, String deviceSn, String value1, Integer type, Date minDate,Date maxDate,String value2,String value3);
}

+ 60 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/Result.java

@ -0,0 +1,60 @@
package com.yihu.jw.care.endpoint;
import java.util.Map;
public class Result {
    protected boolean successFlg = true;
    protected String message;
    protected Map<String, Object> objectMap;
    public boolean isSuccessFlg() {
        return successFlg;
    }
    public void setSuccessFlg(boolean successFlg) {
        this.successFlg = successFlg;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public Map<String, Object> getObjectMap() {
        return objectMap;
    }
    public void setObjectMap(Map<String, Object> objectMap) {
        this.objectMap = objectMap;
    }
    /**
     * 错误消息
     */
    public static Result error(String message) {
        Result re= new Result();
        re.successFlg = false;
        re.message = message;
        return re;
    }
    /**
     * 成功消息
     */
    public static Result success(String message) {
        Result re= new Result();
        re.successFlg = true;
        re.message = message;
        return re;
    }
    public static Result authError(String message) {
        Result re= new Result();
        re.successFlg = false;
        re.message = message;
        return re;
    }
}

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java

@ -120,6 +120,8 @@ public class PadDeviceController extends BaseController {
                if (flagDevice == false){
                    return write(-1,"请填写投放地址");
                }
                //注册设备地址
                deviceDetailService.registerToWlyy(device);
            }
            //修改设备表中{"1":"0", "2":"0"}的绑定次数 和其他绑定信息
            deviceDetailService.updateAfterBinding(device,new Date(),flag);

+ 0 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java

@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.aop.RedisLock;
import com.yihu.jw.care.aop.ServicesAuth;
import com.yihu.jw.care.aop.ServicesAuthAOP;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.patient.CarePatientService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
@ -37,8 +36,6 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
    private CarePatientService patientService;
    @Autowired
    private WlyyPatientLabelDao patientLabelDao;
    @Autowired
    ServicesAuthAOP servicesAuthAOP;
    public int num = 20;
    @GetMapping(value = "testException")

+ 33 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PayEndpoint.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.exception.BusinessException;
import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
import com.yihu.jw.care.service.pay.PayService;
import com.yihu.jw.care.util.WxpayUtil;
import com.yihu.jw.care.util.XMLUtil;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
@ -22,6 +23,7 @@ import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
@ -43,6 +45,8 @@ public class PayEndpoint extends EnvelopRestEndpoint {
    private Logger log = LoggerFactory.getLogger(PatientDoorCoachOrderService.class);
    @Value("${wechat.apiKey}")
    public String apiKey;
    @Autowired
    private PayService payService;
    @Autowired
@ -84,9 +88,15 @@ public class PayEndpoint extends EnvelopRestEndpoint {
    @GetMapping("orderInfo")
    @ApiOperation(value = "订单详情")
    public ObjEnvelop orderInfo(@ApiParam(name = "id", value = "订单id") @RequestParam(value = "id", required = true) Integer id) {
    public ObjEnvelop orderInfo(@ApiParam(name = "id", value = "订单id")
                                    @RequestParam(value = "id", required = false) Integer id,
                                @ApiParam(name = "orderId", value = "工单id")
                                @RequestParam(value = "orderId", required = false) String orderId) {
        try {
            JSONObject json = payService.orderInfo(id);
            if(StringUtil.isBlank(orderId)&&id==null){
                return ObjEnvelop.getError("入参有误",-1);
            }
            JSONObject json = payService.orderInfo(id,orderId);
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
@ -228,9 +238,9 @@ public class PayEndpoint extends EnvelopRestEndpoint {
//            orderDO.setResponseParam(paramsJson);
            // 判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额),
            String totalFee = params.get("total_fee");
            BigDecimal payTotalFee = new BigDecimal(totalFee).setScale(2).divide(new BigDecimal(100), BigDecimal.ROUND_HALF_EVEN);
            BigDecimal payTotalFee = new BigDecimal(totalFee);
            log.info("【微信支付】支付金额:{}", payTotalFee);
            if (new BigDecimal(orderDO.getPayPrice()).compareTo(payTotalFee) != 0) {
            if (new BigDecimal(orderDO.getPayPrice()*100).compareTo(payTotalFee) != 0) {
                //通知资金与实际资金不对称,可能是攻击行为!
                orderDO.setRematk("通知资金与实际资金不对称,可能是攻击行为!");
                businessOrderDao.save(orderDO);
@ -251,6 +261,7 @@ public class PayEndpoint extends EnvelopRestEndpoint {
        }
    }
    /**
     * 微信支付退款回调
     *
@ -270,25 +281,36 @@ public class PayEndpoint extends EnvelopRestEndpoint {
            // 支付校验
            String returnCode = params.get("return_code");
            if (!"SUCCESS".equalsIgnoreCase(returnCode)) {
                log.info("【微信支付退款】订单失败");
                log.info("【微信支付退款1】订单失败");
                return XMLUtil.setXML("FAIL", "退款失败");
            }
            String req_info = params.get("req_info");
            //解密
            String desReqInfo = WxpayUtil.getRefundDecrypt(req_info,apiKey);
            Map<String, String> desParams = XMLUtil.doXMLParse(desReqInfo);
            if(!"SUCCESS".equals(desParams.get("refund_status"))){
                log.info("【微信支付退款2】订单失败");
                return XMLUtil.setXML("FAIL", "退款失败");
            }
            // 商户需要验证该通知数据中的out_trade_no是否为商户系统中创建的订单号
            String outTradeNo = params.get("out_trade_no");
            String outTradeNo = desParams.get("out_trade_no");
            String payWaterId = outTradeNo.split("_")[0];
            payService.addHttpLog("2",payWaterId,paramsJson,null);
            payService.addHttpLog("2",payWaterId,desReqInfo,null);
            BusinessOrderRefundDO orderDO = orderRefundDao.selectByOrderNo(payWaterId);
            if (orderDO == null) {
                log.error("退款订单不存在");
                return XMLUtil.setXML("SUCCESS", "OK");
            }
            orderDO.setOutRefundNo(params.get("refund_id"));
            if (!(orderDO.getOutRefundNo().contains("CAREDISPATCHER"))){
                orderDO.setOutRefundNo(desParams.get("refund_id"));
            }
//            orderDO.setResponseParam(paramsJson);
            // 判断total_amount是否确实为该订单的实际金额(即商户订单创建时的金额),
            String totalFee = params.get("refund_fee");
            BigDecimal payTotalFee = new BigDecimal(totalFee).setScale(2).divide(new BigDecimal(100), BigDecimal.ROUND_HALF_EVEN);
            String totalFee = desParams.get("refund_fee");
            BigDecimal payTotalFee = new BigDecimal(totalFee);
            log.info("【微信支付退款】支付金额:{}", payTotalFee);
            if (new BigDecimal(orderDO.getRefundPrice()).compareTo(payTotalFee) != 0) {
            if (new BigDecimal(orderDO.getRefundPrice()*100).compareTo(payTotalFee) != 0) {
                //通知资金与实际资金不对称,可能是攻击行为!
                log.info("通知资金与实际资金不对称,可能是攻击行为!");
                return XMLUtil.setXML("SUCCESS", "OK");

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java

@ -548,4 +548,16 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value="findAllAgedPatient")
    @ApiOperation(value = "获取所有老人根据身份证或姓名")
    public ListEnvelop findAllPatient(@ApiParam(name="name",value = "姓名或身份证",required = false)
                                          @RequestParam(value = "name")String name){
        try {
            return ListEnvelop.getSuccess("查询成功",servicePackageService.findAllAgedPatient(name));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
}

+ 27 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceDetailService.java

@ -13,13 +13,18 @@ import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -43,6 +48,10 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
	private PatientDeviceDao patientDeviceDao;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	@Autowired
	private HttpClientUtil httpClientUtil;
	@Value("${cloudCare.deviceUrl}")
	private String cloudDeviceUrl;
	/**
@ -182,4 +191,22 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
	public DeviceDetail findByDeviceSn(String deviceSn){
		return deviceDetailDao.findBySn(deviceSn);
	}
	/**
	 * 注册设备,通过iot项目进行数据推送
	 * @return
	 */
	public void registerToWlyy(DevicePatientDevice device){
		//判断设备类型
		Device deviceDO = deviceDao.findOne(device.getDeviceId());
		if (StringUtils.isNotBlank(deviceDO.getNeedRegister())){
			// 设备注册至iot后 通过iot将设备数据转发
			String url = "http://www.cityihealth.com:43210/deviceManage/register";
			List<NameValuePair> params = new ArrayList<>();
			params.add(new BasicNameValuePair("deviceSN", device.getDeviceSn()));
			params.add(new BasicNameValuePair("pushAddress", cloudDeviceUrl+"/"+deviceDO.getNeedRegister()));
			String response = httpClientUtil.post(url, params,"UTF-8");
			//注册日志
		}
	}
}

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/DoctorDoorCoachOrderService.java

@ -299,8 +299,8 @@ public class DoctorDoorCoachOrderService {
            String statusName = "";
            switch (statustemp){
                case -1:statusName="已取消";break;
                case 1:statusName="待服务";break;
                case 2:statusName="待服务";break;
                case 1:statusName="待接单";break;
                case 2:statusName="待接单";break;
                case 3:statusName="待服务";break;
                case 4:statusName="待服务";break;
                case 5:statusName="待服务";break;

+ 10 - 7
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java

@ -174,7 +174,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                });
        if(bool){
            String failMsg = "当前服务对象存在未完成的上门预约,请先完成该服务!";
            String failMsg = "当前服务对象存在未支付或未完成的上门预约,无法再次申请!";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
@ -865,6 +865,9 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                logger.error(failMsg);
                return result;
            }
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderDO.getId());
            businessOrderDO.setStatus(2);
            businessOrderDao.save(businessOrderDO);
        }else{//调度员拒单,此时工单已支付抵达调度员
            try {
                if (orderDO.getStatus() > BaseDoorCoachOrderDO.Status.waitForPay.getType()&&1==orderDO.getPayWay()){
@ -873,7 +876,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                        if (1 == businessOrderDO.getStatus()){
                            //退款流程
                            try {
                                payService.orderRefund(businessOrderDO.getOrderNo(),"调度员拒单退款");
                                payService.dispatcherOrderRefund(businessOrderDO.getOrderNo(),"调度员拒单退款");
                                orderDO.setPayStatus(2);
                            }catch (Exception e){
                                e.printStackTrace();
@ -1287,9 +1290,9 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                }
            }
        }
        all = waitForAccept+waitForServe+served+cancel;
        all = waitForPay+waitForAccept+waitForServe+served+cancel;
        map.put("all",all);
        map.put("waitForPay",waitForAccept);
        map.put("waitForPay",waitForPay);
        map.put("waitForAccept",waitForAccept);
        map.put("waitForServe",waitForServe);
        map.put("served",served);
@ -1375,11 +1378,11 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            switch (statustemp){
                case -1:statusName="已取消";break;
                case 0:statusName="待付款";break;
                case 1:statusName="待服务";break;
                case 2:statusName="待服务";break;
                case 1:statusName="待接单";break;
                case 2:statusName="待接单";break;
                case 3:statusName="待服务";break;
                case 4:statusName="待服务";break;
                case 5:statusName="已完成";break;
                case 5:statusName="待服务";break;
                case 6:statusName="已完成";break;
            }

+ 28 - 7
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java

@ -16,6 +16,7 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareCancelLogDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareFeeDetailDO;
@ -182,7 +183,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        String sql = "SELECT a.status, COUNT(DISTINCT a.id) as num FROM base_life_care_order a " ;
        sql +=  "  WHERE  a.hospital = ? group BY a.status";
        sql +=  "  WHERE  a.hospital = ? and a.pay_status>0 and a.status<>0 group BY a.status";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, hospital);
        Map<String, Integer> map = new HashMap<>();
        //状态 待服务 1、已完成 2 、已取消 -1 已签到 3
@ -247,7 +248,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
                " LEFT JOIN base_patient p ON o.patient = p.id ) "+
                " WHERE " +
                "  o.hospital = '{hospital}' " +buffer+
                " AND ( o.`status` = {status} OR -100 = {status} ) " +
                " AND ( o.`status` = {status} OR -100 = {status} ) and o.pay_status>0 and o.status<>0 " +
                " ORDER BY o.create_time desc " +
                " LIMIT {start},{end};";
@ -263,7 +264,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
                " LEFT JOIN base_patient p ON o.patient = p.id " +
                " WHERE  " +
                "  o.hospital = '{hospital}' " +buffer+
                " AND (o.`status` = {status} or -100 = {status})";
                " AND (o.`status` = {status} or -100 = {status}) and o.pay_status>0 and o.status<>0 ";
        String finqlCountSql = countSql.replace("{hospital}", hospital)
                .replace("{status}", String.valueOf(status));
@ -412,6 +413,9 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
            logger.error(failMsg);
            return result;
        }
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderDO.getId());
        businessOrderDO.setStatus(2);
        businessOrderDao.save(businessOrderDO);
//        if(orderDO.getStatus().equals(LifeCareOrderDO.Status.complete.getType())){
//            result.put(ResponseContant.resultFlag, ResponseContant.fail);
//            String failMsg = "只有医生服务前的工单才可取消";
@ -466,7 +470,6 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
    @Transactional(rollbackFor = Exception.class)
    public JSONObject create(String jsonData,String proxyPatient) {
        logger.info("申请生活照料jsonData参数:" + jsonData);
        proxyPatient = "808080eb78d3ce030178edeb4346002b";
        JSONObject result = new JSONObject();
        JSONObject jsonObjectParam;
        LifeCareOrderDO orderDO = null;
@ -475,6 +478,18 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
            orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), LifeCareOrderDO.class);
            //存在未支付的订单不能发起
            boolean bool = lifeCareOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
                    new Integer[]{
                            BaseDoorCoachOrderDO.Status.waitForPay.getType()
                    });
            if(bool){
                String failMsg = "当前服务对象存在未支付或未完成,无法再次申请!";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, failMsg);
                logger.error(failMsg);
                return result;
            }
            Integer type = orderDO.getType();
            if (type==1||type==2){
                //本人或家人代发起
@ -488,8 +503,14 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
                orderDO.setProxyPatient(proxyPatient);
                orderDO.setProxyPatientName(doctorDO.getName());
                orderDO.setProxyPatientPhone(doctorDO.getMobile());
                List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,orderDO.getPatient());
                if (basePatientWechatDos.size()>0){
                    JSONObject json = new JSONObject();
                    String openId = basePatientWechatDos.get(0).getOpenid();
                    messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","shzldzf",openId,null,null,"请在30分钟内完成支付",3,json,
                            DateUtil.dateToChineseDate(new Date()),"助老员已为您代预约生活照料","待支付");
                }
            }
            //todo 代发起时推送待支付模板给患者
        } catch (Exception e) {
            e.printStackTrace();
@ -675,7 +696,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        String sql = "select ord.id,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') createTime,DATE_FORMAT(ord.patient_expected_serve_time,'%Y-%m-%d %H:%i:%S') serveTime,ord.status,ord.hospital,ord.hospital_name hospitalName" +
                ",ord.doctor,ord.doctor_name doctorName,ord.expected_doctor_name expectedDoctorName,group_concat(Distinct fee.name SEPARATOR '、') serveItems" +
                " from base_life_care_order ord LEFT JOIN base_life_care_fee_detail fee on ord.id = fee.order_id " +
                "and fee.`status`<>3 where ord.patient = '"+patient+"' ";
                "and fee.`status`<>3 where ord.patient = '"+patient+"' and ord.status<>0 ";
        String fliter = "";
       if (status != null){
           fliter += " and ord.status = "+status;
@ -694,7 +715,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        String sql = "select ord.id,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') createTime,DATE_FORMAT(ord.patient_expected_serve_time,'%Y-%m-%d %H:%i:%S') serveTime,ord.status,ord.hospital,ord.hospital_name hospitalName" +
                ",ord.doctor,ord.doctor_name doctorName,ord.expected_doctor_name expectedDoctorName,group_concat(Distinct fee.name SEPARATOR '、') serveItems" +
                " from base_life_care_order ord LEFT JOIN base_life_care_fee_detail fee on ord.id = fee.order_id " +
                "and fee.`status`<>3 where ord.patient = '"+patient+"' ";
                "and fee.`status`<>3 where ord.patient = '"+patient+"' and ord.status<>0  ";
        String fliter = "";
        if (status != null){
            fliter += " and ord.status = "+status;

+ 86 - 18
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/pay/PayService.java

@ -44,9 +44,10 @@ import org.springframework.util.Assert;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.*;
import static jxl.biff.FormatRecord.logger;
/**
 * Created with IntelliJ IDEA.
@ -188,10 +189,16 @@ public class PayService {
     * 订单详情接口
     * @param id
     */
    public JSONObject orderInfo(Integer id){
    public JSONObject orderInfo(Integer id,String orderId){
        JSONObject resJson = new JSONObject();
        resJson.put("id",id);
        BusinessOrderDO businessOrderDO = businessOrderDao.findOne(id);
        BusinessOrderDO businessOrderDO;
        if(StringUtil.isBlank(orderId)){
            businessOrderDO = businessOrderDao.findOne(id);
        }else{
            businessOrderDO = businessOrderDao.selectByRelationCode(orderId);
        }
        resJson.put("id",businessOrderDO.getId());
        resJson.put("orderId",businessOrderDO.getRelationCode());
        String type = businessOrderDO.getOrderCategory();
        Integer status = businessOrderDO.getStatus();
        resJson.put("orderCategory",type);
@ -239,12 +246,12 @@ public class PayService {
        }
        if("3".equals(type)){
            BaseDoorCoachOrderDO orderDO = baseDoorCoachOrderDao.findOne(orderId);
            if(!"6".equals(orderDO.getStatus())){
            if(6!=orderDO.getStatus()){
                return "工单为已完成状态时,才可申请退款";
            }
        }else if("4".equals(type)){
            LifeCareOrderDO orderDO = lifeCareOrderDao.findOne(orderId);
            if(!"2".equals(orderDO.getStatus())){
            if(2!=orderDO.getStatus()){
                return "工单为已完成状态时,才可申请退款";
            }
        }
@ -353,7 +360,7 @@ public class PayService {
            result.put(ResponseContant.resultMsg, "工单未创建支付订单");
            return result;
        }
        JSONObject payInfo = orderInfo(businessOrderDO.getId());
        JSONObject payInfo = orderInfo(businessOrderDO.getId(),null);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, payInfo);
        return result;
@ -397,12 +404,62 @@ public class PayService {
        orderRefundDO.setPatientName(patientDO.getName());
        orderRefundDO.setRefundDesc(description);
        orderRefundDO = orderRefundDao.save(orderRefundDO);
        Integer orderPrice = orderRefundDO.getOrderPrice().intValue();
        Integer refundPrice1 = orderRefundDO.getRefundPrice().intValue();
        Integer orderPrice = new BigDecimal(orderRefundDO.getOrderPrice()*100).intValue();
        Integer refundPrice1 = new BigDecimal(orderRefundDO.getRefundPrice()*100).intValue();
        Map<String,Object> map = businessOrderService.refund(wechatId,orderRefundDO.getOrderNo(),orderRefundDO.getOutRefundNo(),orderPrice.toString(),refundPrice1.toString(),orderRefundDO.getRefundDesc());
        log.info("map"+map);
        addHttpLog("1",businessOrderDO.getOrderNo(),null,map.toString());
        if (!map.get("return_code").toString().equalsIgnoreCase("SUCCESS")){
            //退款申请提交成功
            throw new Exception(map.get("return_msg").toString());
        }
    }
    /**
     * 调度员拒单工单微信退款(不生成售后数据)
     * @param orderNo
     * @param description
     * @return
     * @throws Exception
     */
    public void dispatcherOrderRefund(String orderNo,String description) throws Exception {
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        if (wxWechatDO==null){
            throw new Exception("this wechatId is null");
        }
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo);
        if (businessOrderDO==null){
            throw new Exception("this orderId not exit");
        }
        BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
        if (patientDO==null){
            throw new Exception("this patient not exit");
        }
        BusinessOrderRefundDO orderRefundDO = orderRefundDao.selectByOrderNo(orderNo);
        if (orderRefundDO==null){
            orderRefundDO = new BusinessOrderRefundDO();
        }
        orderRefundDO.setCreateTime(new Date());
        orderRefundDO.setUpdateTime(new Date());
        orderRefundDO.setStatus(1);
        orderRefundDO.setOrderNo(orderNo);
        orderRefundDO.setOrderPrice(businessOrderDO.getPayPrice());
        orderRefundDO.setRefundPrice(businessOrderDO.getPayPrice());
        orderRefundDO.setAppId(wxWechatDO.getAppId());
        orderRefundDO.setMchId(wxWechatDO.getMchId());
        orderRefundDO.setOutRefundNo("CAREDISPATCHER"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
        orderRefundDO.setPatient(businessOrderDO.getPatient());
        orderRefundDO.setPatientName(patientDO.getName());
        orderRefundDO.setRefundDesc(description);
        orderRefundDO = orderRefundDao.save(orderRefundDO);
        Integer orderPrice = new BigDecimal(orderRefundDO.getOrderPrice()*100).intValue();
        Integer refundPrice1 = new BigDecimal(orderRefundDO.getRefundPrice()*100).intValue();
        Map<String,Object> map = businessOrderService.refund(wechatId,orderRefundDO.getOrderNo(),orderRefundDO.getOutRefundNo(),orderPrice.toString(),refundPrice1.toString(),orderRefundDO.getRefundDesc());
        logger.info("map"+map);
        log.info("map"+map);
        addHttpLog("1",businessOrderDO.getOrderNo(),null,map.toString());
        if (map.get("return_code").toString().equalsIgnoreCase("SUCCESS")){
        if (!map.get("return_code").toString().equalsIgnoreCase("SUCCESS")){
            //退款申请提交成功
            throw new Exception(map.get("return_msg").toString());
        }
@ -469,13 +526,15 @@ public class PayService {
     */
    @Transactional(rollbackFor = Exception.class)
    public void refundNotify(BusinessOrderRefundDO orderDO) {
        log.error("【支付通知】请求,payWater:{}", orderDO);
        log.error("【退款通知】请求,getOrderNo:{}", orderDO.getOrderNo());
        String type = "";
        //防止重复支付
        if (orderDO.getStatus()!=1) {
        if (!(orderDO.getStatus()==1||orderDO.getStatus()==3)) {//待退款或同意退款
            log.error("【退款通知】请求,getStatus:{}", orderDO.getStatus());
            return;
        }
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderDO.getOrderNo());
        type = businessOrderDO.getOrderCategory();
        switch (type){
            case "1":
                //desc = "招生报名";
@ -494,8 +553,17 @@ public class PayService {
            default:
                break;
        }
        orderDO.setStatus(2);
        orderDO.setRefundTime(new Date());
        if (orderDO.getOutRefundNo().contains("CAREDISPATCHER")){//调度员拒单时 不生成售后订单
            businessOrderDO.setStatus(2);
            orderRefundDao.delete(orderDO.getId());
        }else {
            businessOrderDO.setStatus(4);
            orderRefundDao.save(orderDO);
        }
        businessOrderDao.save(businessOrderDO);
        log.info("【退款通知】成功,type:{}", type);
    }
@ -534,7 +602,7 @@ public class PayService {
        reqMap.put("mch_id", mchId);
        reqMap.put("nonce_str", noceStr);
        // 此路径是微信服务器调用支付结果通知路径
        reqMap.put("notify_url", serverUrl+"pay/open/wxPayNotify");
        reqMap.put("notify_url", "https://zhyzh.hzxc.gov.cn/cloudCare/pay/open/wxPayNotify");
        reqMap.put("out_trade_no", businessOrderDO.getOrderNo());
        reqMap.put("spbill_create_ip", IpUtil.getOneIpAddress(request));
        reqMap.put("product_id", businessOrderDO.getOrderNo());
@ -614,7 +682,7 @@ public class PayService {
        reqMap.put("mch_id", mchId);
        reqMap.put("nonce_str", noceStr);
        // 此路径是微信服务器调用支付结果通知路径
        reqMap.put("notify_url", serverUrl+"pay/open/wxPayNotify");
        reqMap.put("notify_url", "https://zhyzh.hzxc.gov.cn/cloudCare/pay/open/wxPayNotify");
        reqMap.put("out_trade_no", businessOrderDO.getOrderNo());
        reqMap.put("spbill_create_ip", IpUtil.getOneIpAddress(request));
        reqMap.put("product_id", businessOrderDO.getOrderNo());
@ -700,7 +768,7 @@ public class PayService {
                break;
        }
        Date date = new Date();
        Long lastPayTime = date.getTime()+60*30;
        Long lastPayTime = date.getTime()+1000*60*30;//订单截至支付日期
        businessOrderDO.setDescription(desc);
        businessOrderDO.setRelationCode(relationCode);

+ 8 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -555,4 +555,12 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        }
        return jdbcTemplate.queryForList(sql);
    }
    public List<Map<String,Object>> findAllAgedPatient(String name){
        String sql ="SELECT distinct p.id,p.name,p.sex,p.idcard,p.photo,p.mobile from base_patient p where p.archive_type=1 and p.del=1  ";
        if (StringUtils.isNotBlank(name)){
            sql+=" and (p.name like '%"+name+"%' or p.idcard like '%"+name+"%') ";
        }
        return jdbcTemplate.queryForList(sql);
    }
}

File diff suppressed because it is too large
+ 102 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/WxpayUtil.java


+ 12 - 2
svr/svr-cloud-care/src/main/resources/application.yml

@ -183,6 +183,9 @@ systemSetting:
base:
  url: http://172.17.110.212:10020/
  hospitalUrl: http://172.26.0.107:10022/
cloudCare:
  deviceUrl: http://172.26.0.107:9112/
---
spring:
  profiles: jwtest
@ -288,6 +291,9 @@ systemSetting:
base:
  url: http://172.17.110.212:10020/
  hospitalUrl: http://172.26.0.107:10022/
cloudCare:
  deviceUrl: http://172.26.0.107:9112/
---
spring:
  profiles: jwprod
@ -396,7 +402,8 @@ base:
  url: http://172.17.110.212:10020/
  hospitalUrl: http://172.26.0.107:10022/
cloudCare:
  deviceUrl: http://172.26.0.107:9112/
---
spring:
  profiles: hzprod
@ -501,4 +508,7 @@ systemSetting:
  isApplication: 0 # 是否需要资质申请 1需要 0 不需要
base:
  hospitalUrl: http://127.0.0.7:10022/
  hospitalUrl: http://127.0.0.7:10022/
cloudCare:
  deviceUrl: https://zhyzh.hzxc.gov.cn/device/

+ 7 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DeviceDetailDao.java

@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author yeshijie on 2018/1/10.
 */
@ -13,4 +15,9 @@ public interface DeviceDetailDao extends PagingAndSortingRepository<DeviceDetail
    @Query(value = "select a.* from wlyy_devices a where a.device_code=?1 limit 0,1",nativeQuery = true)
    DeviceDetail findBySn(String sn);
    List<DeviceDetail> findByDeviceCode(String deviceCode);
    @Query("select a from DeviceDetail a where a.deviceCode = ?1 and a.manufacturerCode = ?2")
    DeviceDetail findByDeviceCodeAndManufacturerCode(String deviceCode,String manufacturerCode);
}

+ 9 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DeviceInfoDao.java

@ -0,0 +1,9 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.DeviceInfo;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;
@Transactional
public interface DeviceInfoDao extends CrudRepository<DeviceInfo, Long> {
}

+ 7 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DevicePatientHealthIndexDao.java

@ -67,4 +67,11 @@ public interface DevicePatientHealthIndexDao
	@Query("select count(a) from DevicePatientHealthIndex a where a.recordDate >= ?1 and a.recordDate <= ?2 and a.type in (1,2) and a.status = ?3 and a.del = '1' and user = ?4")
	int getCountByTimeAndStatus(Date start, Date end, int status, String patientCode);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.deviceSn = ?2 and a.value1 = ?3 and a.type = ?4 and a.recordDate >= ?5 and a.recordDate<=?6 and a.del = '1' ")
	List<DevicePatientHealthIndex> findByTypeInHalfMinute(String patient, String deviceSn, String value1, Integer type, Date minDate,Date maxDate);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.deviceSn = ?2 and a.value1 = ?3 and a.value2=?7 and a.value3=?8 and a.type = ?4 and a.recordDate >= ?5 and a.recordDate<=?6 and a.del = '1' ")
	List<DevicePatientHealthIndex> findByTypeInHalfMinuteAllValue(String patient, String deviceSn, String value1, Integer type, Date minDate,Date maxDate,String value2,String value3);
}

+ 1 - 1
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java

@ -24,7 +24,7 @@ import java.util.Map;
 */
@RestController
@RequestMapping("/device")
@Api(value = "设备相关服务", description = "设备相关服务")
@Api(value = "爱牵挂设备相关服务", description = "设备相关服务")
public class DeviceController {
    private static Logger logger = LoggerFactory.getLogger(DeviceController.class);

+ 52 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceUploadController.java

@ -0,0 +1,52 @@
package com.yihu.jw.care.endpoint;
import com.yihu.jw.care.service.DeviceUploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Bing on 2021/7/7.
 */
@RestController
@Api(description = "第三放设备数据推送接口")
@RequestMapping(value = "/deviceData")
public class DeviceUploadController {
    //设备需要注册后才能推送至注册时地址,否则统一推送至默认地址
    //注册地址(post): http://www.cityihealth.com:43210/deviceManage/register?deviceSN=设备SN码&pushAddress=设备推送地址完整地址
    //
    private static Logger logger = LoggerFactory.getLogger(DeviceUploadController.class);
    @Autowired
    private DeviceUploadService deviceUploadService;
    @ApiOperation("设备数据接收接口(标准协议)")
    @RequestMapping(value = "/upload", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public Result uploadDevicesData(
            @ApiParam(value="推送类型(44代表体征推送)",defaultValue = "44")
            @RequestParam(value = "typeId", required = false)  Integer typeId ,
            @ApiParam(value="体征数据",defaultValue =
                    "{\"button\":\"1\",\"data\":\"1.81\",\"deviceSn\":\"16C000337\",\"deviceType\":2,\"id\":2377," +
                            "\"manufacturerCode\":\"threeNod\",\"manufacturerName\":\"三诺\",\"sendTime\":\"2017-03-13 13:47:42\"," +
                            "\"state\":0,\"unit\":\"mmol/L\",\"uploadTime\":\"2017-03-13 13:46:59\"}")
            @RequestParam(value = "data", required = true)  String data)
    {
        try{
            logger.info("typeId="+typeId+";data="+data);
            return deviceUploadService.uploadDevicesData(data);
        }
        catch (Exception ex)
        {
            return Result.error("Device data incoming failure!"+ex.getMessage());
        }
    }
}

+ 60 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/Result.java

@ -0,0 +1,60 @@
package com.yihu.jw.care.endpoint;
import java.util.Map;
public class Result {
    protected boolean successFlg = true;
    protected String message;
    protected Map<String, Object> objectMap;
    public boolean isSuccessFlg() {
        return successFlg;
    }
    public void setSuccessFlg(boolean successFlg) {
        this.successFlg = successFlg;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public Map<String, Object> getObjectMap() {
        return objectMap;
    }
    public void setObjectMap(Map<String, Object> objectMap) {
        this.objectMap = objectMap;
    }
    /**
     * 错误消息
     */
    public static Result error(String message) {
        Result re= new Result();
        re.successFlg = false;
        re.message = message;
        return re;
    }
    /**
     * 成功消息
     */
    public static Result success(String message) {
        Result re= new Result();
        re.successFlg = true;
        re.message = message;
        return re;
    }
    public static Result authError(String message) {
        Result re= new Result();
        re.successFlg = false;
        re.message = message;
        return re;
    }
}

+ 348 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceUploadService.java

@ -0,0 +1,348 @@
package com.yihu.jw.care.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.DeviceInfoDao;
import com.yihu.jw.care.dao.device.DevicePatientHealthIndexDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.endpoint.Result;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DeviceInfo;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/7/7.
 */
@Service
public class DeviceUploadService {
    private static Logger logger = LoggerFactory.getLogger(DeviceUploadService.class);
    @Autowired
    private DeviceInfoDao deviceInfoDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private DevicePatientHealthIndexDao patientHealthIndexDao;
    public Result uploadDevicesData(String dataJson) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            Map<String, Object> map = objectMapper.readValue(dataJson, Map.class);
            String deviceSn = map.get("deviceSn").toString();//设备唯一码
            Integer deviceType = Integer.parseInt(map.get("deviceType").toString());//设备类型1:血压 2:血糖
            String data = map.get("data").toString();//体征值(血糖:data=血糖值   血压:data=收缩压,舒张压,脉搏)
            String uploadTime = map.get("uploadTime").toString();//体征上传时间yyyy-MM-dd HH:mm:ss
            String manufacturerCode = map.get("manufacturerCode").toString();//厂商代码
            String manufacturerName = map.get("manufacturerName").toString();//厂商名称
            String unit = map.get("unit").toString();//单位mmol/L,mmHg
            String sendTime = map.get("sendTime").toString();//发送时间yyyy-MM-dd HH:mm:ss
            String userType = map.get("button").toString();//按键号 即 userType
            String measurementType=null==map.get("measurementType")?"":map.get("measurementType").toString(); //单个设备的测量类型,deviceType=4智能手表:1心率,2血压
            JSONObject json = new JSONObject();
            json.put("deviceSn", deviceSn);
            json.put("deviceType", deviceType);
            json.put("data", data);
            json.put("uploadTime", uploadTime);//三诺的上传时间
            json.put("manufacturerCode", manufacturerCode);
            json.put("manufacturerName", manufacturerName);
            json.put("unit", unit);
            json.put("sendTime", sendTime);//三诺的测量时间
            json.put("userType", userType);
            json.put("measurementType", measurementType);
            String type = deviceType + "";
            if (1 == deviceType) {
                type = "2";
            } else if (2 == deviceType) {
                type = "1";
                userType = "-1";
            }
            DeviceInfo deviceInfo = new DeviceInfo();
            deviceInfo.setDeviceData(dataJson);
            deviceInfo.setDeviceType(type);
            deviceInfo.setPushDate(DateUtil.getNowTimestamp());
            deviceInfo.setStatus("1");
            deviceInfoDao.save(deviceInfo);
            DevicePatientHealthIndex result = null;
            if(type.equalsIgnoreCase("1")){
                if (Double.parseDouble(data)>=1){
                    result = savePatientDeviceData(deviceSn, type, data, uploadTime, userType, json,measurementType);
                }else {
                    logger.info("This blood device data below 1.0:====="+dataJson);
                    throw new Exception("This blood device data below 1.0 ");
                }
            }else {
                result = savePatientDeviceData(deviceSn, type, data, uploadTime, userType, json,measurementType);
            }
            if (result == null) {
                logger.info("This device is not relate patient!:====="+dataJson);
                throw new Exception("This device is not relate patient!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return Result.success("Device data incoming success");
    }
    /**
     * 保存设备数据
     * @param type 设备类型 4 智能手表
     * @param userType 用户身份:-1 单用户
     * @param measurementType 单设备多功能类型 type=4时,measurementType=1心率,measurementType=2血压
     */
    public DevicePatientHealthIndex savePatientDeviceData(String deviceSn, String type, String data, String uploadTime, String userType, JSONObject json, String measurementType) throws Exception {
        Date currentTime = DateUtil.getNowTimestamp();
        Date time = currentTime;
        if (!StringUtil.isEmpty(uploadTime)) {
            //设备重新开机启动会有默认时间,相隔很远.
            time = DateUtil.toTimestamp(uploadTime, DateUtil.YYYY_MM_DD_HH_MM_SS);
            Date monthTime = DateUtil.getNextMonthReturnDate( currentTime,-12);
            if (DateUtil.compareDate(time, monthTime) < 0) {
                time = currentTime;
            }
        }
        if (StringUtil.isStrEmpty(userType)) {
            userType = "-1";
        }
        DevicePatientDevice device = null;
        DeviceDetail deviceDetail = null;
        List<DeviceDetail> deviceDetails = deviceDetailDao.findByDeviceCode(deviceSn);
        if (deviceDetails != null || deviceDetails.size()!=0){
            deviceDetail = deviceDetails.get(0);
            if (deviceDetail.getGrantOrgCode() != null&& deviceDetail.getGrantOrgCode().equals("3502050300")){
                List<DevicePatientDevice> patientDeviceList =  patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
                if (patientDeviceList != null&&patientDeviceList.size()==1) {
                    device = patientDeviceList.get(0);
                }else if(patientDeviceList != null&&patientDeviceList.size()==2){
                    for (int i=0;i<patientDeviceList.size();i++){
                        if(userType.equals(patientDeviceList.get(i).getUserType())){
                            device = patientDeviceList.get(i);
                            break;
                        }
                    }
                }
            }else {
                device = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn, type, userType);
            }
        }
        if (device != null) {
        /*//根据设备获取患者(设备只绑定一个人的时候,不判断按键)
        if (device!=null) {*/
            /************设备数据重复推送处理 start**********************/
            String value1 = data;
            String value2="";
            String value3="";
            if("2".equals(type)){
                String[] value = data.split(",");
                if (value.length > 0) {
                    value1 = value[0];     //收缩压
                    value2 = value[1];
                    value3 = value[2];
                }
            }else if("4".equals(type)){
                if(StringUtils.isNotBlank(measurementType)&&"2".equals(measurementType)){
                    type="2";
                    String[] value = data.split(",");
                    if (value.length > 0) {
                        value1 = value[0];     //收缩压
                        value2 = value[1];
                        /* value3 = value[2];*/
                    }
                }else {
                    //心率
                    type="5";
                }
            }
            if (value1.equals(value2) && value2.equals(value3)){
                return null;
            }
//            List<PatientHealthIndex> list = patientHealthIndexDao.findByType(device.getUser(),deviceSn,value1,Integer.parseInt(type),time);
            /*long maxtime = time.getTime()+30*1000;
            long mintime = time.getTime()-30*1000;*/
            Date minDate = DateUtil.getPreDays(time,-3);
            Date maxDate = DateUtil.getPreDays(time,3);
            List<DevicePatientHealthIndex> list = ioTfindByType(device.getUser(),deviceSn,value1,value2,value3,Integer.parseInt(type),time,minDate,maxDate);
            if(list!=null&&list.size()>0){
                return null;
            }
            /************设备数据重复推送处理 end**********************/
            DevicePatientHealthIndex obj = new DevicePatientHealthIndex();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            obj.setCzrq(sdf.parse(json.getString("sendTime")));//创建时间取三诺的测量时间记录
            obj.setDeviceSn(deviceSn);
            obj.setDel("1");
            obj.setRecordDate(sdf.parse(json.getString("uploadTime")));    //记录时间取上传时间
            obj.setSortDate(time);      //排序时间
//            obj.setManageResult(0);//默认数据是医生未干预状态
            String user = device.getUser();
            obj.setUser(user);
//            obj.setButton(userType);
            obj.setIdcard(device.getUserIdcard());
            obj.setStatus(0);
            //  1血糖 2血压 3体重 4腰围,5心率
            switch (type) {
                case "1":
                    obj.setType(1);
                    obj.setValue1(data);     //血糖值
                    obj.setValue2(formatBloodSuger(user,deviceSn,DateUtil.dateToStr(time, DateUtil.YYYY_MM_DD_HH_MM_SS)));
                    break;
                case "2":
                    obj.setType(2);
                    String[] value = data.split(",");
                    if (value.length > 0) {
                        obj.setValue1(value[0]);     //收缩压
                    }
                    if (value.length > 1) {
                        obj.setValue2(value[1]);     //舒张压
                    }
                    if (value.length > 2) {
                        obj.setValue3(value[2]);     //脉搏
                    }
                    if (value.length > 3) {
                        obj.setValue4(value[3]);     //有无心率不齐
                    }
                    break;
                case "3":
                    obj.setType(3);
                    obj.setValue1(data); //体重
                    break;
                case "4":
                    obj.setType(4);
                    obj.setValue1(data);  //腰围
                    break;
                case "5":
                    obj.setType(5);
                    obj.setValue1(data);  //心率
                    break;
                default:
                    throw new Exception("Can not support the metric!");
            }
            //新增字段处理
            BasePatientDO patient = patientDao.findById(user);
            if(patient!=null){
                obj.setName(patient.getName());
            }
            if(deviceDetail!=null){
                obj.setHospital(deviceDetail.getGrantOrgCode());
                obj.setHospitalName(deviceDetail.getOrgName());
            }
//            obj = patientHealthIndexDao.save(obj);
            obj = patientHealthIndexDao.save(obj);
            return obj;
        }
        return null;
    }
    /**
     * 查找重复数据
     * @param user
     * @param deviceSn
     * @param value1
     * @param type
     * @param time
     * @return
     */
    public List<DevicePatientHealthIndex> ioTfindByType(String user,String deviceSn,String value1,String value2,String value3,Integer type,Date time,Date timeMin,Date timeMax){
       List<DevicePatientHealthIndex> list = new ArrayList<>();
       if (type==1){
           list =  patientHealthIndexDao.findByTypeInHalfMinute(user,deviceSn,value1,type,timeMin,timeMax);
       }else if (type==2){
           list = patientHealthIndexDao.findByTypeInHalfMinuteAllValue(user,deviceSn,value1,type,timeMin,timeMax,value2,value3);
       }
       return list;
    }
    /**
     * 血糖测量时间段
     * @param user
     * @param deviceSN
     * @param dateTime
     * @return
     */
    private String formatBloodSuger(String user,String deviceSN,String dateTime) {
        String fastingStart = "00:00:00";
        String fastingEnd = "07:59:59";
        String afterBreakFastStart = "08:00:00";
        String afterBreakFastEnd = "09:59:59";
        String beforeLunchStart = "10:00:00";
        String beforeLunchEnd = "11:59:59";
        String afterLunchStart = "12:00:00";
        String afterLunchEnd = "13:59:59";
        String beforeDinnerStart = "14:00:00";
        String beforeDinnerEnd = "17:59:59";
        String afterDinnerStart = "18:00:00";
        String afterDinnerEnd = "19:59:59";
        String beforeSleepStart = "20:00:00";
        String beforeSleepEnd = "23:59:59";
        if (isInArea(dateTime, fastingStart,fastingEnd)) {
            return "1";//"空腹血糖"
        }
        if (isInArea(dateTime, afterBreakFastStart,afterBreakFastEnd)) {
            return "2";//"早餐后血糖"
        }
        if (isInArea(dateTime, beforeLunchStart,beforeLunchEnd)) {
            return "3";//"午餐前血糖"
        }
        if (isInArea(dateTime, afterLunchStart,afterLunchEnd)) {
            return "4";//"午餐后血糖"
        }
        if (isInArea(dateTime, beforeDinnerStart,beforeDinnerEnd)) {
            return "5";//"晚餐前血糖"
        }
        if (isInArea(dateTime, afterDinnerStart,afterDinnerEnd)) {
            return "6";//"晚餐后血糖"
        }
        if (isInArea(dateTime, beforeSleepStart,beforeSleepEnd)) {
            return "7";//"睡前血糖"
        }
        return "1";//"空腹血糖"
    }
    // 判断时间是否在对应时间段
    private Boolean isInArea(String time,String begin,String end) {
        String date = DateUtil.getDateFromDateTime(time);
        Long beginTime = DateUtil.compareDateTime(DateUtil.toTimestamp(time), DateUtil.toTimestamp(date + " " + begin ));
        Long endTime = DateUtil.compareDateTime(DateUtil.toTimestamp(time), DateUtil.toTimestamp(date + " " + end ));
        if (beginTime > 0 && endTime < 0) {
            return true;
        } else {
            return false;
        }
    }
}

+ 1 - 1
svr/svr-cloud-job/src/main/resources/application.yml

@ -170,7 +170,7 @@ spring:
    user: admin
    password: admin
  redis:
    host: 172.26.0.13 # Redis server host.
    host: 10.18.43.40 # Redis server host.
    port: 6379  # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:

+ 97 - 5
svr/svr-rehabilitation/pom.xml

@ -102,22 +102,114 @@
			<artifactId>mysql-starter</artifactId>
			<version>2.0.0</version>
		</dependency>
		<dependency>
			<groupId>com.yihu.jw</groupId>
			<artifactId>base-service</artifactId>
			<version>2.0.0</version>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>com.yihu.jw</groupId>
			<artifactId>im-service</artifactId>
			<version>2.0.0</version>
		</dependency>
		<dependency>
			<groupId>com.yihu.jw</groupId>
			<artifactId>es-service</artifactId>
			<version>2.0.0</version>
		</dependency>
		<dependency>
			<groupId>org.springside</groupId>
			<artifactId>springside-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springside</groupId>
			<artifactId>springside-core</artifactId>
			<version>4.2.3-GA</version>
		</dependency>
	</dependencies>
	<build>
		<finalName>svr-rehabilitation</finalName>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin </artifactId>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<archive>
						<!-- 生成的jar中,不要包含pom.xml和pom.properties这两个文件 -->
						<addMavenDescriptor>false</addMavenDescriptor>
						<manifest>
							<!-- 是否要把第三方jar加入到类构建路径 -->
							<addClasspath>true</addClasspath>
							<!-- 外部依赖jar包的最终位置 -->
							<classpathPrefix>lib/</classpathPrefix>
							<mainClass>com.yihu.SvrRehabilitationApplication</mainClass>
						</manifest>
					</archive>
				</configuration>
			</plugin>
			<!--拷贝依赖到jar外面的lib目录-->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-lib</id>
						<phase>package</phase>
						<goals>
							<goal>copy-dependencies</goal>
						</goals>
						<configuration>
							<!-- 依赖包输出目录,将来不打进jar包里 -->
							<outputDirectory>${project.build.directory}/lib</outputDirectory>
							<excludeTransitive>false</excludeTransitive>
							<stripVersion>false</stripVersion>
							<includeScope>runtime</includeScope>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<!--指定配置文件,将resources打成外部resource-->
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
					<archive>
						<!-- 指定配置文件目录,这样jar运行时会去找到同目录下的resources文件夹下查找 -->
						<manifestEntries>
							<Class-Path>resources/</Class-Path>
						</manifestEntries>
					</archive>
					<!-- 打包时忽略的文件(也就是不打进jar包里的文件) -->
					<excludes>
						<exclude>**/*.yml</exclude>
						<exclude>**/*.xml</exclude>
					</excludes>
				</configuration>
			</plugin>
			<!-- 拷贝资源文件 外面的resource目录-->
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-dependencies</id>
						<phase>package</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<!-- 资源文件输出目录 -->
							<outputDirectory>${project.build.directory}/resources</outputDirectory>
							<resources>
								<resource>
									<directory>src/main/resources</directory>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

+ 8 - 1
svr/svr-rehabilitation/src/main/java/com/yihu/SvrRehabilitationApplication.java

@ -2,13 +2,20 @@ package com.yihu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
@EnableJpaAuditing
@SpringBootApplication
public class SvrRehabilitationApplication {
public class SvrRehabilitationApplication extends SpringBootServletInitializer {
	public static void main(String[] args) {
		SpringApplication.run(SvrRehabilitationApplication.class, args);
	}
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		return builder.sources(SvrRehabilitationApplication.class);
	}
}

+ 14 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/aop/ObserverRequired.java

@ -0,0 +1,14 @@
package com.yihu.rehabilitation.aop;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
 * Created by Trick on 2017/6/24.
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ObserverRequired {
}

+ 89 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/aop/ObserverRequiredAOP.java

@ -0,0 +1,89 @@
package com.yihu.rehabilitation.aop;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.json.JSONObject;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
/**
 * Created by Trick on 2017/6/24..
 */
@Aspect
@Component
public class ObserverRequiredAOP {
    //Controller层切点路径
    @Pointcut("execution(* com.yihu.rehabilitation..*.*(..))")
    public void controllerAspect() {
    }
    public ObserverRequiredAOP() {
        //System.out.println("Observer---------------------------------------");
    }
    @Around("controllerAspect() && @annotation(com.yihu.rehabilitation.aop.ObserverRequired)")
    public Object checkToken(ProceedingJoinPoint point) throws Throwable {
        Object o = null;
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
        String error = "";
        try {
            response.setCharacterEncoding("UTF-8");
            JSONObject json = getAgent(request);
            String observer = json.has("observer") ? json.getString("observer") : "";
            if(StringUtils.isNotBlank(observer)&&"1".equals(observer)){
                PrintWriter writer=response.getWriter();
                writer.write(error(403, "该操作没有权限"));
                writer.flush();
                return o;
            }
        }catch (Exception e){
            //return o;
        }
         o = point.proceed();
        return o;
    }
    public String write(int code, String msg) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            return json.toString();
        } catch (Exception e) {
            return null;
        }
    }
    public String error(int code, String msg) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            return json.toString();
        } catch (Exception e) {
            return null;
        }
    }
    public JSONObject getAgent(HttpServletRequest request) {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            System.out.println("userAgent:" + userAgent);
            return new JSONObject(userAgent);
        } catch (Exception e) {
            return null;
        }
    }
}

+ 22 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/aop/ServicesAuth.java

@ -0,0 +1,22 @@
package com.yihu.rehabilitation.aop;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
 * 使用该注解必须带item。注解的方法参数必须有patientId
 * 服务项权限控制
 * Created by yeshijie on 2021/3/5.
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ServicesAuth {
    /**
     * 服务项code
     * @return
     */
    String item();
}

+ 5 - 1
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/config/jpa/HibernateProperties.java

@ -1,3 +1,4 @@
/*
package com.yihu.rehabilitation.config.jpa;
import org.springframework.beans.factory.annotation.Value;
@ -6,9 +7,11 @@ import org.springframework.stereotype.Component;
import java.util.Properties;
*/
/**
 * Created by chenweida on 2017/4/6.
 */
 *//*
@Component
@RefreshScope
public class HibernateProperties {
@ -27,3 +30,4 @@ public class HibernateProperties {
        return properties;
    }
}
*/

+ 5 - 1
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/config/jpa/RehabilitationJpa.java

@ -1,3 +1,4 @@
/*
package com.yihu.rehabilitation.config.jpa;
@ -17,9 +18,11 @@ import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import java.util.Properties;
*/
/**
 * Created by humingfen on 2018/4/27.
 */
 *//*
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
@ -56,3 +59,4 @@ public class RehabilitationJpa {
        return new JpaTransactionManager(builder);
    }
}
*/

+ 71 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/DiagnosisInformationController.java

@ -0,0 +1,71 @@
package com.yihu.rehabilitation.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.specialist.rehabilitation.PatientDiagnosisInformationDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.rehabilitation.service.DiagnosisInformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
/**
 * Created by humingfen on 2019/2/11.
 */
@RestController
@RequestMapping("/diagnosisInformation")
@Api(tags = "诊疗信息管理相关操作", description = "诊疗信息相关操作")
public class DiagnosisInformationController extends EnvelopRestEndpoint {
    @Autowired
    private DiagnosisInformationService diagnosisInformationService;
    @PostMapping(value = SpecialistMapping.diagnosisInformation.createDiagnosisInformation)
    @ApiOperation(value = "诊疗信息创建")
    public Envelop createDiagnosisInformation(@ApiParam(name = "diagnosisInformationJson", value = "实体JSON")
                                                       @RequestParam(value = "diagnosisInformationJson")String diagnosisInformationJson){
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
            PatientDiagnosisInformationDO diagnosisInformationDO = objectMapper.readValue(diagnosisInformationJson, PatientDiagnosisInformationDO.class);
            return diagnosisInformationService.createDiagnosisInformation(diagnosisInformationDO);
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = SpecialistMapping.diagnosisInformation.findDiagnosisInformationByPlanId)
    @ApiOperation(value = "根据康复计划id查找诊疗信息")
    public Envelop findDiagnosisInformationByPlanId(@ApiParam(name = "planId", value = "康复计划id")
                                              @RequestParam(value = "planId") String planId){
        try {
            return diagnosisInformationService.findDiagnosisInformationByPlanId(planId);
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = SpecialistMapping.diagnosisInformation.findDiagnosisInformationByPatient)
    @ApiOperation(value = "查找居民诊疗信息记录")
    public Envelop findDiagnosisInformationByPatient(@ApiParam(name = "patient", value = "居民code")
                                                    @RequestParam(value = "patient") String patient,
                                                     @ApiParam(name = "page", value = "第几页")
                                                     @RequestParam(value = "page") Integer page,
                                                     @ApiParam(name = "size", value = "行数")
                                                         @RequestParam(value = "size") Integer size){
        try {
            return diagnosisInformationService.findDiagnosisInformationByPatient(patient, page, size);
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
}

File diff suppressed because it is too large
+ 318 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/RehabilitationPlanController.java


+ 3 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/RehabilitationPlanningController.java

@ -6,6 +6,7 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.rehabilitation.RehabilitationPlanningVO;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.rehabilitation.service.RehabilitationPlanningService;
import com.yihu.rehabilitation.service.RehabilitationTreatmentProgramService;
import io.swagger.annotations.Api;
@ -116,4 +117,6 @@ public class RehabilitationPlanningController extends EnvelopRestEndpoint {
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 299 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/consult/ConsultController.java

@ -0,0 +1,299 @@
package com.yihu.rehabilitation.controller.consult;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.patient.Patient;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.message.service.MessageService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.rehabilitation.dao.SignFamilyDao;
import com.yihu.rehabilitation.service.consult.ConsultTeamService;
import com.yihu.rehabilitation.util.BusinessLogs;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 患者端:三师咨询控制类
 *
 * @author George
 */
@Controller
@RequestMapping(value = "/patient/consult", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
@Api(description = "患者端-患者咨询")
public class ConsultController extends EnvelopRestEndpoint {
    @Autowired
    private ConsultTeamService consultTeamService;
    /**
     * 三师咨询添加接口
     *
     * @param type     咨询类型:1三师咨询,2家庭医生咨询,18康复咨询
     * @param when     发病时间
     * @param symptoms 主要症状
     * @param images   图片URL地址,多图以逗号分隔
     * @param voice    语音URL地址
     * @return
     */
    @RequestMapping(value = "add")
    @ResponseBody
    @ApiOperation("三师咨询添加接口")
    public Envelop add(@RequestParam(required = false) Integer type,
                       @RequestParam(required = false) String when,
                       @RequestParam String symptoms,
                       @RequestParam(required = false) String images,
                       @RequestParam(required = false) String voice,
                       @RequestParam(required = false) Long guidance,
                       @RequestParam(required = false) String doctor) {
        try {
            System.out.println("guidance1="+guidance);
            System.out.println("symptoms="+symptoms);
            if (type == null) {
                type = 1;
            }
            if (type != 1 && type != 2 && type !=18&&(StringUtils.isNoneBlank(doctor)&&type==18)) {
                return failed( "无效请求!");
            }
            ConsultTeamDo consult = new ConsultTeamDo();
            // 设置咨询类型:1三师咨询,2家庭医生咨询  6.名医咨询  18,康复咨询
            consult.setType(type);
            // 设置发病时间
            consult.setWhen(when);
            // 设置主要症状
            consult.setSymptoms(symptoms);
            // 设置咨询图片URL
            consult.setImages(images);
            // 设置咨询语音URL
            consult.setVoice(voice);
            consult.setDoctor(doctor);
            consult.setIsAuthentication(0);
            consult.setIsRefinement(0);
            // 设置关联咨询
            if (guidance != null && guidance > 0) {
                consult.setGuidance(guidance);
            }
            System.out.println("guidance2="+guidance);
            // 保存到数据库
            int res = 0;
            JSONArray dts = null;
            synchronized (getUID().intern()){//新增同步方法。设备保存写在service层但是不生效,写在controller层才生效
                JSONObject re;
                if(type==18){//康复咨询
                    re = consultTeamService.addRecoverConsult(consult,getRepUID(),getUID());
                }
                else{
                    re = consultTeamService.addTeamConsult(consult,getRepUID(), getUID());
                }
                res = re.getInt("status");
                dts = re.has("doctor")?re.getJSONArray("doctor"):null;
            }
            if (res == -1) {
                return failed( "家庭签约信息不存在或已过期,无法进行家庭医生咨询!");
            } else if (res == -2) {
                return failed("家庭签约信息不存在或已过期,无法进行三师医生咨询!");
            }else if (res == -3) {
                return failed( "还有咨询未结束,不允许再次提交咨询!");
            }
//            Doctor doctor = doctorService.findDoctorByCode(consult.getDoctor());
            //创建咨询讨论组
            // JSONObject jo= talkGroupService.createConsultTalkGroup(consult.getDoctor(), doctor.getName(), doctor.getHospital(), doctor.getHospitalName(),
            //        consult.getPatient(), consult.getName(), consult.getConsult());
            // consult.setGroupCode(jo.getString("groupCode"));
            //更新讨论组
            //consultTeamService.save(consult);
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getRepUID(), getUID(), new JSONObject(consult));
            return success("提交成功",  consult);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedException(ex);
        }
    }
    @RequestMapping(value = "intoTopic",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("进入咨询")
    public Envelop intoTopic(@RequestParam(required = true) String consult){
        try{
            int result = consultTeamService.intoTopic(consult,getRepUID(),getUID());
            if(result==-1){
                return failed("该咨询不是进行中");
            }
            JSONObject json = new JSONObject();
            json.put("consult",consult);
            json.put("content","进入咨询");
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getRepUID(), getUID(), json);
            return success("进入成功");
        }catch (Exception e){
            e.printStackTrace();
            return failed("请求失败");
        }
    }
    /**
     * 查询与某个医生是否存在未结束的咨询
     *
     * @param doctor 医生
     * @return
     */
    @ApiOperation("查询与某个医生是否存在未结束的咨询")
    @RequestMapping(value = "/is_consult_unfinished",method = RequestMethod.POST)
    @ResponseBody
    public Envelop isExistsUnfinishedConsult(@RequestParam(required = false) String patient,
                                             @RequestParam(required = true) String doctor) {
        try {
            JSONObject result = new JSONObject();
            List<Map<String,Object>> consults = consultTeamService.getUnfinishedConsult(StringUtils.isEmpty(patient) ? getUID() : patient, doctor);
            if (consults != null && consults.size() > 0) {
                return success("查询成功",  consults.get(0).get("consult"));
            } else {
                return failed( "查询成功" );
            }
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 获取患者发起咨询时可选择的专科医生团队列表,
     * @param patientCode 患者code
     * @return
     */
    @RequestMapping(value = "getConsultDoctorForConsulting",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取咨询医生团队列表列表")
    public Envelop getConsultDoctorForConsulting(@RequestParam("patientCode")String patientCode){
        try {
            return success("查询成功",consultTeamService.getConsultDoctorForConsulting(patientCode));
        }catch (Exception e){
            e.printStackTrace();
            return failedException(e);
        }
    }
    /**
     * 查询患者三师咨询咨询列表
     *
     * @param status   咨询状态(0未结束,1已结束,-1 已取消)
     * @param pagesize 页数
     * @return 查询结果
     */
    @RequestMapping(value = "list")
    @ResponseBody
    @ApiOperation("查询患者三师咨询咨询列表")
    public Envelop list(int status, String id, int pagesize) {
        try {
            Page<ConsultTeamDo> consults = consultTeamService.findByPatient(getRepUID(), status, id, pagesize);
            JSONArray jsonArray = new JSONArray();
            if (consults != null) {
                for (ConsultTeamDo consult : consults) {
                    if (consult == null) {
                        continue;
                    }
                    JSONObject json = new JSONObject();
                    json.put("id", consult.getId());
                    // 设置咨询标志
                    json.put("code", consult.getConsult());
                    // 设置咨询类型:0公共咨询,1指定医生,2三师咨询
                    json.put("type", consult.getType());
                    // 设置标题
                    json.put("title", consult.getSymptoms());
                    // 设置发病时间
                    json.put("when", consult.getWhen());
                    // 设置患者未读数量
                    json.put("patientRead", consult.getPatientRead());
                    // 设置状态
                    json.put("status", consult.getStatus());
                    // 设置患者评价标识
                    json.put("comment", consult.getComment());
                    // 设置关联指导
                    json.put("guidance", consult.getGuidance());
                    // 设置咨询或回复时间
                    json.put("time", DateUtil.dateToStr(consult.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
                    jsonArray.put(json);
                }
            }
            return success( "查询成功",  jsonArray);
        } catch (Exception ex) {
            ex.printStackTrace();
            return failedException(ex);
        }
    }
    /**
     * 患者取消三师咨询
     *
     * @param consult
     * @return
     */
    @RequestMapping(value = "cancel")
    @ResponseBody
    @ApiOperation("患者取消三师咨询")
    public Envelop cancel(String consult) {
        try {
            int row = consultTeamService.cancel(consult);
            if (row > 0) {
                return success("咨询已取消!");
            } else {
                return failed( "咨询不能取消!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    /**
     * 修改状态为1的咨询记录为结束
     *
     * @param code 咨询标识
     * @return
     */
    @RequestMapping(value = "finish")
    @ResponseBody
    @ApiOperation("修改状态为1的咨询记录为结束")
    public Envelop finish(@RequestParam(required = true) String code) {
        try {
            int row = consultTeamService.finishConsult(code, getRepUID(), 1);
            if (row > 0) {
                return success("操作成功!");
            }else if(row == -2) {
                return failed( "续方未审核,不能结束续方咨询!");
            }  else {
                return failed( "操作失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
}

+ 124 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/consult/DoctorConsultController.java

@ -0,0 +1,124 @@
package com.yihu.rehabilitation.controller.consult;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.patient.Patient;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.message.service.MessageService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.rehabilitation.aop.ObserverRequired;
import com.yihu.rehabilitation.dao.SignFamilyDao;
import com.yihu.rehabilitation.service.consult.ConsultTeamService;
import com.yihu.rehabilitation.service.followUp.FollowUpService;
import com.yihu.rehabilitation.util.BusinessLogs;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 医生端:三师咨询控制类
 *
 * @author George
 */
@RestController
@RequestMapping(value = "/doctor/consult", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "三师咨询")
public class DoctorConsultController extends EnvelopRestEndpoint {
    @Autowired
    private ConsultTeamService consultTeamService;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private SystemMessageService messageService;
    @Autowired
    protected HttpServletRequest request;
    @RequestMapping(value = "getKangFuConsultList",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取续方咨询列表")
    public Envelop getKangFuConsultList(@ApiParam(name = "title", value = "咨询标题") @RequestParam(required = false) String title,
                                        @ApiParam(name = "patient", value = "居民CODE") @RequestParam(required = false) String patient,
                                        @ApiParam(name = "id", value = "第几页") @RequestParam(required = true) Integer id,
                                        @ApiParam(name = "pagesize", value = "页面大小") @RequestParam(required = true) int pagesize){
        try {
            JSONArray array = new JSONArray();
//            Page<Object> data = consultTeamService.findConsultRecordByType("a663d0cf7f8c4d38a8327cedc921e65f", id, pagesize,8, title);//8表示续方咨询
            List<Map<String,Object>> data = consultTeamService.findConsultRecordByType(patient, id, pagesize,18, title);//18表示康复咨询
            BasePatientDO patientobj = basePatientDao.findById(patient);
            if (data != null) {
                for (Map<String,Object> consult : data) {
                    if (consult == null) {
                        continue;
                    }
                    JSONObject json = new JSONObject();
                    json.put("id", consult.get("id"));
                    // 设置咨询类型:1三师咨询,2视频咨询,3图文咨询,4公共咨询,5病友圈,8 续方咨询  18康复咨询
                    json.put("type", consult.get("type"));
                    // 设置咨询标识
                    json.put("code", consult.get("relation_code"));
                    // 设置显示标题
                    json.put("title", consult.get("title"));
                    json.put("patientName", patientobj.getName());
                    json.put("patientPhoto", patientobj.getPhoto());
                    // 设置主诉
                    json.put("symptoms", consult.get("symptoms"));
                    // 咨询状态
                    json.put("status", consult.get("status"));
                    // 设置咨询日期
                    json.put("czrq", DateUtil.dateToStrLong((Date) consult.get("czrq")));
                    // 咨询状态
                    json.put("doctorCode",consult.get("doctor"));
                    json.put("evaluate", consult.get("evaluate"));
                    array.put(json);
                }
            }
            return success( "查询成功!",  array);
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @RequestMapping(value = "evaluateStatus")
    @ResponseBody
    public Envelop statuss(String consult) {
        try {
            ConsultTeamDo ct = consultTeamService.findByCode(consult);
            if (ct == null) {
                return failed( "获取状态失败!");
            } else {
                return success( "获取状态成功!",  ct.getEvaluate());
            }
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
}

+ 166 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/doctor/DoctorRehabilitaionInfoController.java

@ -0,0 +1,166 @@
package com.yihu.rehabilitation.controller.doctor;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.specialist.rehabilitation.PatientMedicalRecordsDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationAdviceDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
import com.yihu.rehabilitation.aop.ObserverRequired;
import com.yihu.rehabilitation.service.RehabilitationInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.List;
@RestController
@RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationInfo.Perfix, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-康复下转管理")
public class DoctorRehabilitaionInfoController extends EnvelopRestEndpoint {
    @Autowired
    private RehabilitationInfoService rehabilitationInfoService;
    @Autowired
    private ObjectMapper objectMapper;
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationInfo.createAdvice, method = RequestMethod.POST)
    @ApiOperation("创建/编辑康复建议模板")
    @ObserverRequired
    public Envelop createAdvice(@ApiParam(name = "doctorCode", value = "医生code", required = false)
                               @RequestParam(value = "doctorCode", required = false) String doctorCode,
                                @ApiParam(name = "code", value = "模板code")
                               @RequestParam(value = "code", required = false) String code,
                                @ApiParam(name = "name", value = "模板名称", required = true)
                               @RequestParam(value = "name", required = true) String name,
                                @ApiParam(name = "content", value = "模板内容", required = true)
                               @RequestParam(value = "content", required = true) String content) {
        try {
            if (StringUtils.isBlank(doctorCode)) {
                doctorCode = getUID();
            }
            rehabilitationInfoService.createAdvice(doctorCode, code, name, content);
            return success("操作成功");
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationInfo.deleteAdvice, method = RequestMethod.POST)
    @ApiOperation("删除康复建议模板")
    @ObserverRequired
    public Envelop deleteAdvice(@ApiParam(name = "id", value = "模板id")
                               @RequestParam(value = "id", required = false) Long id) {
        try {
            rehabilitationInfoService.deleteAdvice(id);
            return success("操作成功");
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }
    @RequestMapping(value =  RehabilitationRequestMapping.DoctorRehabilitationInfo.getAdviceListByDoctor, method = RequestMethod.GET)
    @ApiOperation("获取医生创建康复建议模板及系统模板")
    public Envelop getAdviceListByDoctor(@ApiParam(name = "doctorCode", value = "医生code", required = false)
                                        @RequestParam(value = "doctorCode", required = false) String doctorCode) {
        try {
            if (StringUtils.isBlank(doctorCode)) {
                doctorCode = getUID();
            }
            List<RehabilitationAdviceDO> list = rehabilitationInfoService.getAdviceListByDoctor(doctorCode);
            return success("操作成功",list);
        } catch (Exception e) {
           e.printStackTrace();
            return failed(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationInfo.sendWxMsgRemindSign, method = RequestMethod.POST)
    @ApiOperation("发送微信模板提醒签约消息")
    public Envelop sendWxTemplate(@ApiParam(name = "patient", value = "居民code", required = false)
                                 @RequestParam(value = "patient", required = false)String patient,
                                 @ApiParam(name = "wxId", value = "微信id", required = false)
                                 @RequestParam(value = "wxId", required = false)String wxId,
                                  @ApiParam(name = "scene", value = "模板code", required = false)
                                      @RequestParam(value = "scene", required = false)String scene){
        try {
            rehabilitationInfoService.sendSFWxTemplate(patient,wxId,scene);
            return success("发送成功");
        } catch (Exception e) {
           e.printStackTrace();
            return failed("发送失败");
        }
    }
    @RequestMapping(value = "createMedicalRecords", method = RequestMethod.POST)
    @ApiOperation("添加编辑住院病历")
    @ObserverRequired
    public Envelop createMedicalRecords(@ApiParam(name = "doctorCode", value = "医生code", required = false)
                                       @RequestParam(value = "doctorCode", required = false) String doctorCode,
                                       @ApiParam(name = "patient", value = "居民code")
                                       @RequestParam String patient,
                                       @ApiParam(name = "patientName", value = "居民姓名")
                                       @RequestParam String patientName,
                                       @ApiParam(name = "jsonData", value = "住院病历相关数据")
                                       @RequestParam(value = "jsonData", required = true) String jsonData,
                                       @ApiParam(name = "id", value = "模板id,编辑时传入")
                                       @RequestParam(value = "id", required = false) String id) {
        try {
            if (StringUtils.isBlank(doctorCode)) {
                doctorCode = getUID();
            }
            System.out.println("111doctorid"+doctorCode);
            objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
            PatientMedicalRecordsDO patientMedicalRecordsDO = objectMapper.readValue(jsonData, PatientMedicalRecordsDO.class);
            System.out.println("实体转换完成");
            return success( "添加成功", rehabilitationInfoService.createMedicalRecords(doctorCode, patient, patientName, patientMedicalRecordsDO, id));
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }
    @RequestMapping(value = "getRehabilitationPatientList", method = RequestMethod.GET)
    @ApiOperation("获取康复下转居民列表")
    public Envelop getRehabilitationPatientList(@ApiParam(name = "idcard", value = "身份证", required = false)
                                               @RequestParam(value = "idcard", required = false) String idcard,
                                               @ApiParam(name = "isTurnDown", value = "是否已下转 -2:未下转未家签,-1未下转 0未下转全部,;1已下转(未接收);2已下转(已接收);3已下转全部;03已下转全部+未下转全部", defaultValue = "0",required = false)
                                               @RequestParam(value = "isTurnDown", required = false,defaultValue = "3") String isTurnDown,
                                                @ApiParam(name = "doctor", value = "",required = false)
                                                    @RequestParam(value = "doctor", required = false,defaultValue = "3") String doctor) {
        try {
            JSONObject result = rehabilitationInfoService.getRehabilitationPatientList(idcard, doctor,isTurnDown);
            return success( "请求成功", result);
        } catch (Exception e) {
            return failed("请求失败");
        }
    }
    @RequestMapping(value = "/getIcd10Info", method = RequestMethod.GET)
    @ApiOperation(value = "获取诊断结果")
    public Envelop getIcd10Info(@RequestParam(required = false)
                                @ApiParam(value = "诊断结果关键字", name = "nameKey") String nameKey,
                                @ApiParam(value = "页码", name = "page",defaultValue = "1",required = true)
                                @RequestParam(value = "page") Integer page,
                                @ApiParam(value = "每页数目", name = "pageSize",defaultValue = "15",required = true)
                                @RequestParam(value = "pageSize") Integer pageSize) {
        try {
            return success("操作成功!", rehabilitationInfoService.getIcd10Info(nameKey, page, pageSize).toString());
        } catch (Exception e) {
            return failed( "查询失败!");
        }
    }
}

+ 1065 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/doctor/DoctorRehabilitationManageController.java

@ -0,0 +1,1065 @@
package com.yihu.rehabilitation.controller.doctor;
import com.netflix.discovery.converters.Auto;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.rehabilitation.RehabilitationguidancePatientDO;
import com.yihu.jw.entity.specialist.rehabilitation.PatientMedicalRecordsDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationOperateRecordsDO;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.rehabilitation.aop.ObserverRequired;
import com.yihu.rehabilitation.service.RehabilitationGuidanceService;
import com.yihu.rehabilitation.service.RehabilitationManageService;
import com.yihu.rehabilitation.service.RehabilitationPlanService;
import com.yihu.rehabilitation.service.message.RehabilitationMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
 * Created by 刘文彬 on 2018/8/30.
 */
@RestController
@RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.perfix)
@Api(description = "医生端-康复管理")
public class DoctorRehabilitationManageController extends EnvelopRestEndpoint {
    @Autowired
    private RehabilitationManageService rehabilitationManageService;
    @Autowired
    private ImUtil imUtill;
    @Autowired
    private RehabilitationPlanService rehabilitationPlanService;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private RehabilitationMessageService rehabilitationMessageService;
    @Autowired
    private RehabilitationGuidanceService rehabilitationGuidanceService;
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.findRehabilitationPlanList, method = RequestMethod.GET)
    @ApiOperation("康复管理-康复计划列表")
    public MixEnvelop findRehabilitationPlanList(@ApiParam(name = "doctorCode", value = "医生code", required = false)
                                             @RequestParam(value = "doctorCode", required = false)String doctorCode,
//                                             @ApiParam(name = "doctorType", value = "医生类型(1、专科医生,2、家庭医生)", required = true)
//                                             @RequestParam(value = "doctorType", required = true)Integer doctorType,
                                                 @ApiParam(name = "patientCondition", value = "居民条件,可以按身份证或者居民名称模糊匹配", required = false)
                                             @RequestParam(value = "patientCondition", required = false)String patientCondition,
                                                 @ApiParam(name = "diseaseCode", value = "疾病类型code", required = false)
                                             @RequestParam(value = "diseaseCode", required = false)String diseaseCode,
                                                 @ApiParam(name = "planType", value = "安排类型(1康复计划,2转社区医院,3转家庭病床)", required = false)
                                             @RequestParam(value = "planType", required = false)Integer planType,
                                                 @ApiParam(name = "todaybacklog", value = "今日待办(1、今日待办,2、全部)", required = false)
                                             @RequestParam(value = "todaybacklog", required = false,defaultValue = "1")Integer todaybacklog,
                                                 @ApiParam(name = "page", value = "第几页,从1开始", required = true)
                                             @RequestParam(value = "page", required = false,defaultValue = "1")Integer page,
                                                 @ApiParam(name = "pageSize", value = "每页分页大小", required = true)
                                             @RequestParam(value = "pageSize", required = false,defaultValue = "10")Integer pageSize) {
        try {
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getUID();
            }
            return  rehabilitationManageService.findRehabilitationPlan(doctorCode,diseaseCode,planType,todaybacklog,patientCondition,page,pageSize);
        } catch (Exception e) {
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.findRehabilitationPlanDetailList, method = RequestMethod.GET)
    @ApiOperation("康复管理-康复计划详情列表")
    public ObjEnvelop findRehabilitationPlanDetailList(@ApiParam(name = "doctorCode", value = "医生code", required = false)
                                                   @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                                       @ApiParam(name = "patientCode", value = "居民code", required = true)
                                                   @RequestParam(value = "patientCode", required = true)String patientCode){
        try {
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getUID();
            }
            return rehabilitationManageService.findRehabilitationPlanDetailList(doctorCode,patientCode);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("请求失败");
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.calendarPlanDetail, method = RequestMethod.GET)
    @ApiOperation("康复管理-康复计划按日历展示")
    public ObjEnvelop calendarPlanDetail(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)")
                                     @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
                                     @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)")
                                     @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
                                     @ApiParam(name = "planId", value = "计划id", required = true)
                                     @RequestParam(value = "planId")String planId,
                                     @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)", required = false)
                                     @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                     @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false)
                                     @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                         @ApiParam(name = "taskExecutor", value = "1是本人任务", required = false)
                                             @RequestParam(value = "taskExecutor", required = false)String taskExecutor,
                                     @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                     @RequestParam(value = "status", required = false)Integer status){
        try {
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getUID();
            }
            return rehabilitationManageService.calendarPlanDetail(executeStartTime,executeEndTime,planId,searchTask,status,doctorCode,taskExecutor);
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping("calendarPlanDetailBypatient")
    @ApiOperation("康复管理-康复计划按日历展示")
    public ObjEnvelop calendarPlanDetailBypatient(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                                      @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
                                                  @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                                      @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
                                                  @ApiParam(name = "patient", value = "患者code", required = true)
                                                      @RequestParam(value = "patient", required = true)String patient,
                                                  @ApiParam(name = "searchTask", value = "快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊)", required = false)
                                                      @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                                  @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false)
                                                      @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                                  @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                                      @RequestParam(value = "status", required = false)Integer status,
                                                  @ApiParam(name="taskExecutor",value = "任务执行人:0全部;1我的任务:2他人任务",required = false)
                                                      @RequestParam(value = "taskExecutor",required = false,defaultValue = "0")String taskExecutor){
        try {
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getUID();
            }
            return rehabilitationManageService.calendarPlanDetailByPatient(executeStartTime,executeEndTime,patient,searchTask,status,doctorCode,"1");
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = "calendarPlanDetailListBypatient", method = RequestMethod.GET)
    @ApiOperation("康复管理--某患者的康复计划按列表展示")
    public ObjEnvelop calendarPlanDetailListBypatient(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                                  @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
                                                  @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                                  @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
                                                  @ApiParam(name = "patient", value = "患者code", required = true)
                                                  @RequestParam(value = "patient", required = true)String patient,
                                                  @ApiParam(name = "searchTask", value = "快速查找任务:(1电话/短信关怀,2康复咨询,3健康监测,4上门服务,5康复指导,6康复随访,7康复复诊)", required = false)
                                                  @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                                  @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false)
                                                  @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                                  @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                                  @RequestParam(value = "status", required = false)Integer status,
                                                  @ApiParam(name="taskExecutor",value = "任务执行人:0全部;1我的任务:2他人任务",required = false)
                                                  @RequestParam(value = "taskExecutor",required = false,defaultValue = "0")String taskExecutor){
        try {
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getUID();
            }
            return rehabilitationManageService.calendarPlanDetailListByPatient(executeStartTime,executeEndTime,patient,searchTask,status,doctorCode,taskExecutor);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "请求失败");
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.calendarPlanDetailList, method = RequestMethod.GET)
    @ApiOperation("康复管理-康复计划按列表展示")
    public ObjEnvelop calendarPlanDetailList(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                     @RequestParam(value = "executeStartTime", required = true)String executeStartTime,
                                     @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                     @RequestParam(value = "executeEndTime", required = true)String executeEndTime,
                                     @ApiParam(name = "planId", value = "计划id", required = true)
                                     @RequestParam(value = "planId", required = true)String planId,
                                     @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)", required = false)
                                     @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                     @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false)
                                     @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                     @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                     @RequestParam(value = "status", required = false)Integer status,
                                         @ApiParam(name = "taskExecutor", value = "", required = false)
                                             @RequestParam(value = "taskExecutor", required = false)String taskExecutor){
        try {
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getUID();
            }
            return rehabilitationManageService.calendarPlanDetailList( planId, searchTask, status, doctorCode, executeStartTime, executeEndTime,taskExecutor);
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.serviceItemList, method = RequestMethod.GET)
    @ApiOperation("康复管理-多个康复计划服务项目内容列表")
    public ObjEnvelop serviceItemList(@ApiParam(name = "planDetailIds", value = "康复计划多个服务项目id(多个‘,’分隔)", required = true)
                                                   @RequestParam(value = "planDetailIds", required = true)String planDetailIds,
                                  @ApiParam(name = "doctorCode", value = "医生code", required = false)
                                  @RequestParam(value = "doctorCode", required = false)String doctorCode){
        try {
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getUID();
            }
            return  rehabilitationManageService.serviceItemList(planDetailIds,doctorCode);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.serviceItem, method = RequestMethod.GET)
    @ApiOperation("康复管理-康复计划服务项目确认详情页")
    public ObjEnvelop serviceItem(@ApiParam(name = "planDetailId", value = "康复计划服务项目id", required = true)
                              @RequestParam(value = "planDetailId", required = true)String planDetailId,
                              @ApiParam(name = "doctorCode", value = "医生code", required = false)
                              @RequestParam(value = "doctorCode", required = false)String doctorCode,
                              @ApiParam(name = "recordId", value = "记录id", required = false)
                                  @RequestParam(value = "recordId", required = false)String recordId){
        try {
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getUID();
            }
            return rehabilitationManageService.serviceItem(planDetailId,doctorCode,recordId);
        } catch (Exception e) {
          e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.saveGuidanceMessage, method = RequestMethod.POST)
    @ApiOperation("康复管理-保存指导留言")
    public Envelop saveGuidanceMessage(@ApiParam(name = "messageId", value = "消息id", required = true)
                                      @RequestParam(value = "messageId", required = true)String messageId,
//                                      @ApiParam(name = "patientCode", value = "居民code", required = true)
//                                      @RequestParam(value = "patientCode", required = false)String patientCode,
                                      @ApiParam(name = "doctorCode", value = "医生code", required = false)
                                      @RequestParam(value = "doctorCode", required = false)String doctorCode,
//                                      @ApiParam(name = "doctorType", value = "医生类型(1、专科医生,2、家庭医生)", required = true)
//                                      @RequestParam(value = "doctorType", required = true)Integer doctorType,
                                      @ApiParam(name = "content", value = "聊天内容", required = true)
                                      @RequestParam(value = "content", required = true)String content,
                                      @ApiParam(name = "planDetailId", value = "服务项目id", required = true)
                                      @RequestParam(value = "planDetailId", required = true)String planDetailId,
                                      @ApiParam(name = "contentType", value = "内容类型(1,6,8 - 文本, 2,9- 图片, 3 - 语音, 4-文章, 5,7系统消息。12-语音 18-居民名片, 19-聊天记录)", required = true)
                                      @RequestParam(value = "contentType", required = true)Integer contentType){
        try {
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getUID();
            }
            return  rehabilitationManageService.saveGuidanceMessage(messageId,doctorCode,content,planDetailId,contentType);
        } catch (Exception e) {
          e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.updateStatusRehabilitationOperate, method = RequestMethod.POST)
    @ApiOperation("康复管理-更新康复计划操作完成日志状态")
    public Envelop updateStatusRehabilitationOperate(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)
                                                    @RequestParam(value = "planDetailId", required = true)String planDetailId,
                                                    @ApiParam(name = "status", value = "状态", required = true)
                                                    @RequestParam(value = "status", required = true)Integer status){
        return rehabilitationManageService.updateStatusRehabilitationOperate(status,planDetailId);
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.patientRehabilitationDetail, method = RequestMethod.GET)
    @ApiOperation("康复管理-居民详情页")
    public ObjEnvelop patientRehabilitationDetail(@ApiParam(name = "patientCode", value = "居民code", required = true)
                                              @RequestParam(value = "patientCode", required = true)String patientCode){
        return rehabilitationManageService.patientRehabilitationDetail(patientCode);
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.recentPlanDetailRecord, method = RequestMethod.GET)
    @ApiOperation("康复管理-近期康复相关记录")
    public ObjEnvelop recentPlanDetailRecord(@ApiParam(name = "patientCode", value = "居民code", required = true)
                                         @RequestParam(value = "patientCode", required = true)String patientCode,
                                         @ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                         @RequestParam(value = "startTime", required = false)String startTime,
                                         @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                         @RequestParam(value = "endTime", required = false)String endTime,
                                         @ApiParam(name = "page", value = "第几页,从1开始", required = true)
                                         @RequestParam(value = "page", required = false,defaultValue = "1")Integer page,
                                         @ApiParam(name = "pageSize", value = "每页分页大小", required = true)
                                        @RequestParam(value = "pageSize", required = false,defaultValue = "10")Integer pageSize){
        try {
            return  rehabilitationManageService.recentPlanDetailRecord(patientCode,startTime,endTime,page,pageSize);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.serviceDoctorList, method = RequestMethod.GET)
    @ApiOperation("康复管理-医生端居民详情服务医生列表")
    public ObjEnvelop serviceDoctorList(@ApiParam(name = "patientCode", value = "居民code", required = true)
                                    @RequestParam(value = "patientCode", required = true)String patientCode){
        try {
            return  rehabilitationManageService.serviceDoctorList(patientCode);
        } catch (Exception e) {
           e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.appCalendarPlanDetailList, method = RequestMethod.GET)
    @ApiOperation("康复管理-app端、微信端计划的服务项目列表")
    public ObjEnvelop appCalendarPlanDetailList(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                            @RequestParam(value = "executeStartTime", required = true)String executeStartTime,
                                            @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                            @RequestParam(value = "executeEndTime", required = true)String executeEndTime,
                                            @ApiParam(name = "planId", value = "计划id", required = true)
                                            @RequestParam(value = "planId", required = true)String planId,
                                            @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、随访,3、复诊,4、健康教育)", required = false)
                                            @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                            @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                            @RequestParam(value = "status", required = false)Integer status){
        try {
            return  rehabilitationManageService.appCalendarPlanDetailList(planId,searchTask,status,executeStartTime,executeEndTime);
        } catch (Exception e) {
           e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.DoctorRehabilitationManage.updateNoteAndImageRehabilitationOperate)
    @ApiOperation(value = "康复计划完成时更新服务完成笔记和图片接口并且确认完成")
    public ObjEnvelop updateNoteAndImageRehabilitationOperate(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)@RequestParam(value = "planDetailId", required = true)String planDetailId,
                                                              @ApiParam(name = "node", value = "服务完成笔记", required = true)@RequestParam(value = "node", required = false)String node,
                                                              @ApiParam(name = "image", value = "相关记录图片,json格式", required = true)@RequestParam(value = "image", required = false)String image,
                                                              @ApiParam(name = "relationCode", value = "业务code", required = true)@RequestParam(value = "relationCode", required = false)String relationCode,
                                                              @ApiParam(name = "status", value = "是否确认完成 0未确认 1确认", required = true)@RequestParam(value = "status", required = false)String status){
        try {
            Map<String,Object> map = rehabilitationManageService.updateNodeAndRelationRecordImg(node,image,status,planDetailId,relationCode);
            return ObjEnvelop.getSuccess(SpecialistMapping.api_success,map);
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value =  RehabilitationRequestMapping.DoctorRehabilitationManage.updatePlanDetailStatusById)
    @ApiOperation(value = "康复管理-更新康复计划项目状态")
    public Envelop updatePlanDetailStatusById(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)
                                              @RequestParam(value = "planDetailId", required = true)String planDetailId,
                                              @ApiParam(name = "status", value = "状态", required = true)
                                              @RequestParam(value = "status", required = true)Integer status){
        try {
            return rehabilitationManageService.updatePlanDetailStatusById(status,planDetailId);
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value =  RehabilitationRequestMapping.DoctorRehabilitationManage.updatePlanDetailExecuteTimeById)
    @ApiOperation(value = "康复管理-修改康复计划项目执行时间")
    public Envelop updatePlanDetailExecuteTimeById(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)
                                                   @RequestParam(value = "planDetailId", required = true)String planDetailId,
                                                   @ApiParam(name = "executeTime", value = "状态", required = true)
                                                   @RequestParam(value = "executeTime", required = true)String executeTime){
        try {
            Date date = DateUtil.strToDateLong(executeTime);
            return rehabilitationManageService.updatePlanDetailExecuteTimeById(date,planDetailId);
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value =  RehabilitationRequestMapping.DoctorRehabilitationManage.planSchedule, method = RequestMethod.GET)
    @ApiOperation("康复管理-计划总进度")
    public ObjEnvelop planSchedule(@ApiParam(name = "planId", value = "计划id", required = true)
                               @RequestParam(value = "planId", required = true)String planId,
                               @ApiParam(name = "patientCode", value = "居民code", required = true)
                               @RequestParam(value = "patientCode", required = true)String patientCode){
        try {
            return rehabilitationManageService.planSchedule(planId,patientCode);
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value =  RehabilitationRequestMapping.DoctorRehabilitationManage.patientCount)
    @ApiOperation(value = "医生已计划数,已完成计划数(居民数)")
    public ObjEnvelop patientCount(@ApiParam(name = "doctorCode", value = "医生code", required = true)
                                   @RequestParam(value = "doctorCode", required = true)String doctorCode){
        try {
            return rehabilitationManageService.patientCount(doctorCode);
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value =  RehabilitationRequestMapping.DoctorRehabilitationManage.sendToFamilyDoctor)
    @ApiOperation(value = "给家医发送居民的康复计划")
    public Envelop sendBusinessCard(@ApiParam(name = "doctorCode", value = "专医code")
                                    @RequestParam(value = "doctorCode", required = true) String doctorCode,
                                    @ApiParam(name = "doctorName", value = "专医名字")
                                    @RequestParam(value = "doctorName", required = true) String doctorName,
                                    @ApiParam(name = "sessionId", value = "会话id", defaultValue = "")
                                    @RequestParam(value = "sessionId", required = true) String sessionId,
                                    @ApiParam(name = "businessType", value = "businessType", defaultValue = "1")
                                    @RequestParam(value = "businessType", required = true) String businessType,
                                    @ApiParam(name = "contentJsonStr", value = "contentJsonStr")
                                    @RequestParam(value = "contentJsonStr", required = true) String contentJsonStr){
        try {
            imUtill.sendImMsg(doctorCode,doctorName,sessionId,ImUtil.ContentType.Rehabilitation.getValue(),contentJsonStr,businessType,"");
            return Envelop.getSuccess(SpecialistMapping.api_success);
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value =  RehabilitationRequestMapping.DoctorRehabilitationManage.getServiceItemsAfterStop)
    @ApiOperation(value = "康复管理-中止康复计划结算项目清单")
    public ObjEnvelop getServiceItemsAfterStop(@ApiParam(name = "planId", value = "康复计划id", required = true)
                                               @RequestParam(value = "planId", required = true)String planId){
        try {
            return ObjEnvelop.getSuccess("操作成功",rehabilitationManageService.getServiceItemsAfterStop(planId));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    /**
     * 康复管理-频次列表
     *
     * @return
     */
    @RequestMapping(value =  RehabilitationRequestMapping.DoctorRehabilitationManage.selectFrequencys, method = RequestMethod.GET)
    @ApiOperation("康复管理-频次列表")
    public MixEnvelop selectFrequencys(){
        try {
            return MixEnvelop.getSuccess("操作成功",rehabilitationManageService.selectFrequences());
        } catch (Exception e) {
            return MixEnvelop.getError( e.getMessage());
        }
    }
    @RequestMapping(value = "selectAllPlaneByPatient",method = RequestMethod.GET)
    @ApiOperation("获取居民所有康复计划")
    public Envelop getPatientAllRehabilitationPlan(@ApiParam(name = "patient",value = "居民Code", required = true)
                                                  @RequestParam(value = "patient",required = true)String patient){
        try {
            return success("获取成功",  rehabilitationManageService.getPatientAllRehabilitationPlan(patient));
        }catch (Exception e){
            return failed( "请求失败");
        }
    }
    @RequestMapping(value = "selectByGuidance", method = RequestMethod.GET)
    @ApiOperation("康复管理-根据计划查询指导留言")
    public Envelop selectByGuidance(@ApiParam(name = "planId", value = "计划id", required = false)
                                   @RequestParam(value = "planId", required = true)String planId,
                                   @ApiParam(name = "itemCode", value = "服务项目code", required = true)
                                   @RequestParam(value = "itemCode", required = true)String itemCode){
        try {
            List<Map<String,Object>> mapList = rehabilitationManageService.selectByGuidance(planId,itemCode);
            return success("获取成功",  mapList);
        } catch (Exception e) {
            return failed( "请求失败");
        }
    }
    @RequestMapping(value = "manageAllPlanByPatient",method = RequestMethod.POST)
    @ApiOperation("一键确认管理居民所有的康复计划")
    public Envelop manageAllPlanByPatient(@ApiParam(name="patient",value = "患者code",required = true)
                                         @RequestParam(value = "patient",required = true)String patient){
        try {
            return  success("操作成功",rehabilitationManageService.manageAllPlanByPatient(patient,getUID()));
        }catch (Exception e){
            return failed( "请求失败");
        }
    }
    @PostMapping(value = "planDetailAfterCall")
    @ApiOperation(value = "康复管理-电话关怀拨打后生成记录对应怪坏记录")
    public MixEnvelop<RehabilitationOperateRecordsDO,RehabilitationOperateRecordsDO> planDetailAfterCall(
            @ApiParam(name = "planDetailId", value = "planDetailId", required = false)
            @RequestParam(value = "planDetailId", required = false)String planDetailId,
            @ApiParam(name = "doctorCode", value = "doctorCode", required = false)
            @RequestParam(value = "doctorCode", required = false)String doctorCode,
            @ApiParam(name = "doctorName", value = "doctorName", required = false)
            @RequestParam(value = "doctorName", required = false)String  doctorName){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("doctorCode",doctorCode);
        jsonObject.put("doctorName",doctorName);
        jsonObject.put("rehabilitationDetailId",planDetailId);
        try {
            return MixEnvelop.getSuccess(SpecialistMapping.api_success,rehabilitationManageService.planDetailAfterCall(jsonObject.toString()));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = "/dailyJobSendMessage", method = RequestMethod.POST)
    @ApiOperation("康复管理-康复计划每天8点,16点发送服务进展的job")
    @ObserverRequired
    public Envelop dailyJobSendMessage(@ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                      @RequestParam(value = "startTime", required = true)String startTime,
                                      @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                      @RequestParam(value = "endTime", required = true)String endTime,
                                      @ApiParam(name = "type", value = "8点:23,16点:22", required = true)
                                      @RequestParam(value = "type", required = true)Integer type){
        try {
            rehabilitationManageService.dailyJobSendMessage(startTime,endTime,type);
            return success( "发送成功");
        } catch (Exception e) {
            return failed( "发送失败");
        }
    }
    @RequestMapping(value = "/tomorrowJobSendMessage", method = RequestMethod.POST)
    @ApiOperation("康复管理-康复计划每天15点发送明天服务定时提醒的job")
    @ObserverRequired
    public Envelop tomorrowJobSendMessage(@ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                         @RequestParam(value = "startTime", required = true)String startTime,
                                         @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                         @RequestParam(value = "endTime", required = true)String endTime,
                                         @ApiParam(name = "type", value = "15点:23", required = true)
                                         @RequestParam(value = "type", required = true)Integer type){
        try {
            rehabilitationManageService.tomorrowJobSendMessage(startTime,endTime,type);
            return success( "发送成功");
        } catch (Exception e) {
            return failed( "发送失败");
        }
    }
    @RequestMapping(value = "/dailyByJobSendMessage", method = RequestMethod.POST)
    @ApiOperation("康复管理-康复计划每15分钟服务进展提醒")
    @ObserverRequired
    public Envelop dailyByJobSendMessage(@ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                        @RequestParam(value = "startTime", required = true)String startTime,
                                        @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                        @RequestParam(value = "endTime", required = true)String endTime,
                                        @ApiParam(name = "type", value = "15分钟,22", required = true)
                                        @RequestParam(value = "type", required = true)Integer type){
        try {
            rehabilitationManageService.dailyByJobSendMessage(startTime,endTime,type);
            return success( "发送成功");
        } catch (Exception e) {
            return failed( "发送失败");
        }
    }
    @RequestMapping(value = "/dailyJobReserve", method = RequestMethod.POST)
    @ApiOperation("康复管理-10天、7天、5天、当天(0)康复服务预约复诊通知")
    @ObserverRequired
    public Envelop dailyJobReserve(@ApiParam(name = "num", value = "10天、7天、5天、当天康复服务预约复诊通知", required = false)
                                  @RequestParam(value = "num", required = false)Integer num){
        try {
            if(num!=null){
                rehabilitationManageService.dailyJobReserve(num,20);
            }else{
                Integer[] days = {10,7,5,0};
                for(Integer one : days){
                    rehabilitationManageService.dailyJobReserve(one,20);
                }
            }
            return success( "发送成功");
        } catch (Exception e) {
            return failed( "发送失败");
        }
    }
    @RequestMapping(value = "selectByMedicalCode", method = RequestMethod.GET)
    @ApiOperation("获取医院病历")
    public Envelop selectByMedicalCode(@ApiParam(name = "medical", value = "住院code", required = true)
                                      @RequestParam(value = "medical", required = true)String medical){
        try {
            List<PatientMedicalRecordsDO> result = rehabilitationManageService.selectByMedicalCode(medical);
            try {
                String sql = "UPDATE `wlyy_patient_medical_records_rehabilitation` SET `doctor_read_status`='1' WHERE (`code`='"+medical+"') ";
                jdbcTemplate.update(sql);
            }catch (Exception e){
                e.printStackTrace();
            }
            return success("操作成功", result);
        } catch (Exception e) {
            return failed( "请求失败");
        }
    }
    @RequestMapping(value = "getPlanDetailForModifing",method = RequestMethod.GET)
    @ApiOperation(value = "根据planId、模板id获取计划列表")
    public Envelop getPlanDetailForModifing(@ApiParam(name = "planId",value = "康复计划id",required = true)
                                           @RequestParam(value = "planId",required = true) String planId,
                                           @ApiParam(name = "templateId",value = "模板Id,不传默认为系统模板",required = false)
                                           @RequestParam(value = "templateId",required = false) String templateId){
        try {
            return success("查询成功",rehabilitationManageService.getPlanDetailForModifing(planId, templateId));
        }catch (Exception e){
            return failed("查询失败");
        }
    }
    @RequestMapping(value = "selectPlanServerDoctor", method = RequestMethod.POST)
    @ApiOperation("康复管理-康复计划的服务医生")
    public Envelop selectPlanServerDoctor(@ApiParam(name = "planId", value = "康复计划ID")@RequestParam(value = "planId", required = true)String planId){
        try {
            String doctorCode = getUID();
            return success("查询成功",rehabilitationManageService.selectPlanServerDoctor(planId,doctorCode));
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "查询失败");
        }
    }
    @RequestMapping(value = "selectBySpecialistDoctor", method = RequestMethod.GET)
    @ApiOperation("康复管理-获取专科居民")
    public String selectBySpecialistDoctor(@ApiParam(name = "doctorCode", value = "医生code", required = false)
                                           @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                           @ApiParam(name = "doctorType", value = "医生类型(1专科2家医)", required = false)
                                           @RequestParam(value = "doctorType", required = false)String doctorType,
                                           @ApiParam(name = "patientInfo", value = "身份证或者姓名", required = false)
                                           @RequestParam(value = "patientInfo", required = false)String patientInfo,
                                           @ApiParam(name = "diseaseCode", value = "疾病类型code", required = false)
                                           @RequestParam(value = "diseaseCode", required = false)String diseaseCode,
                                           @ApiParam(name = "level", value = "1市2区3社区", required = false)
                                           @RequestParam(value = "level", required = false)String level,
                                           @ApiParam(name = "area", value = "区域", required = false)
                                           @RequestParam(value = "area", required = false)String area,
                                           @ApiParam(name = "page", value = "第几页,从1开始", required = true)
                                           @RequestParam(value = "page", required = false,defaultValue = "1")Integer page,
                                           @ApiParam(name = "pageSize", value = "每页分页大小", required = true)
                                           @RequestParam(value = "pageSize", required = false,defaultValue = "10")Integer pageSize,
                                           @ApiParam(name = "filterPlan", value = "是否过滤康复计划,1过滤,0或者放空不过滤", required = false)
                                           @RequestParam(value = "filterPlan", required = false)String filterPlan,
                                           @ApiParam(name = "turnDownState", value = "下转状态 0全部;1已下转;2已接受;3未下转", required = false)
                                           @RequestParam(value="turnDownState", required = false,defaultValue = "0")String turnDownState
    ) {
        try {
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getUID();
            }
            JSONObject result = rehabilitationManageService.selectBySpecialistDoctor1(level,area,doctorCode,diseaseCode,page,pageSize,doctorType,patientInfo,filterPlan,turnDownState);
            JSONArray showList = result.getJSONArray("showList");
            JSONObject turnDownStateObj = result.getJSONObject("turnDownState");
            JSONObject json = new JSONObject();
            json.put("status", 200);
            json.put("msg", "获取成功");
            json.put("data",showList);
            json.put("data2",turnDownStateObj);
            return json.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return "请求失败";
        }
    }
    @RequestMapping(value = "createSpecialDoctorQrCode", method = RequestMethod.POST)
    @ApiOperation("康复管理-生成康复下转专科医生二维码")
    @ObserverRequired
    public Envelop createSpecialDoctorQrCode(
            @ApiParam(name = "doctorCode", value = "医生code")@RequestParam(value = "doctorCode", required = true)String doctorCode,
            @ApiParam(name = "teamCode", value = "团队CODE")@RequestParam(value = "teamCode", required = true)String teamCode,
            @ApiParam(name = "teamName", value = "团队名称")@RequestParam(value = "teamName", required = true)String teamName
    ){
        try {
            return success("获取二维码成功!", rehabilitationManageService.createSpecialDoctorQrCode(doctorCode,teamCode,teamName));
        } catch (Exception e) {
            return failed( "请求二维码失败");
        }
    }
    @RequestMapping(value = "selectAllCompleteServiceItemsByPatient",method = RequestMethod.GET)
    @ApiOperation("康复计划主页动态")
    public Envelop selectAllCompleteServiceItemsByPatient(@ApiParam(name = "patient",value = "居民Code", required = true)
                                                         @RequestParam(value = "patient",required = true)String patient){
        try {
            return success("获取成功", rehabilitationManageService.selectAllCompleteServiceItemsByPatient(patient));
        }catch (Exception e){
            return failed("请求失败");
        }
    }
    @RequestMapping(value = "calendarPlanDetailItems", method = RequestMethod.GET)
    @ApiOperation("康复管理-康复计划服务项目按列表展示")
    public Envelop calendarPlanDetailItems(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                          @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
                                          @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                          @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
                                          @ApiParam(name = "planId", value = "计划id", required = true)
                                          @RequestParam(value = "planId", required = true)String planId,
                                          @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)", required = false)
                                          @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                          @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false)
                                          @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                          @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                          @RequestParam(value = "status", required = false)Integer status){
        try {
            if(!StringUtils.isNotEmpty(doctorCode)){
                doctorCode = getUID();
            }
            List<Map<String,Object>> result = rehabilitationManageService.calendarPlanDetailItems(executeStartTime,executeEndTime,planId,searchTask,status,doctorCode);
            return success( "获取成功", result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "请求失败");
        }
    }
    @RequestMapping(value = "confirmManage", method = RequestMethod.GET)
    @ApiOperation("康复管理-确认管理")
    public Envelop confirmManage(@ApiParam(name = "doctor", value = "签约医生code", required = true)
                                @RequestParam(value = "doctor", required = true) String signDoctor,
                                @ApiParam(name = "patient", value = "居民code", required = true)
                                @RequestParam(value = "patient", required = true) String patient,
                                @ApiParam(name = "specialist", value = "专医code", required = true)
                                @RequestParam(value = "specialist", required = true) String specialist,
                                @ApiParam(name = "relationId", value = "签约关系id", required = true)
                                @RequestParam(value = "relationId", required = false) String relationId,
                                @ApiParam(name = "planId", value = "计划id", required = true)
                                @RequestParam(value = "planId", required = false) String planId) {
        try {
            rehabilitationManageService.confirmManage(patient,signDoctor,specialist,relationId,planId);
            return success("请求成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "请求失败");
        }
    }
    @RequestMapping(value = "selectByPlanDetaiId", method = RequestMethod.GET)
    @ApiOperation("康复管理-获取操作记录")
    public Envelop selectByPlanDetaiId(@ApiParam(name = "patient", value = "居民code", required = true)
                                      @RequestParam(value = "patient", required = false)String patient,
                                      @ApiParam(name = "planId", value = "计划id", required = true)
                                      @RequestParam(value = "planId", required = true)String planId,
                                      @ApiParam(name = "code", value = "服务项目code", required = true)
                                      @RequestParam(value = "code", required = true)String code,
                                      @ApiParam(name = "page", value = "", required = false)
                                      @RequestParam(value = "page", required = false)Integer page,
                                      @ApiParam(name = "pagesize", value = "", required = false)
                                      @RequestParam(value = "pagesize", required = false)Integer pagesize){
        try {
            return success("获取成功",  rehabilitationManageService.selectByPlanDetaiId(patient,planId,code,page,pagesize).toString());
        } catch (Exception e) {
            e.printStackTrace();
            return failed("请求失败");
        }
    }
    /*@GetMapping(value = "selectRelationCode")
    @ResponseBody
    @ApiOperation("业务关联code")
    public Envelop selectRelationCode(@ApiParam(name = "relationCode", value = "业务关联code",required = true)
                                     @RequestParam String relationCode) {
        try {
            return success("请求成功!",wlyyDoorServiceOrderService.selectRelationCode(relationCode));
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "请求失败");
        }
    }*/
    @RequestMapping(value = "getServiceItemList", method = RequestMethod.GET)
    @ApiOperation("康复管理-获取服务项目列表")
    public Envelop getServiceItemList(@ApiParam(name = "name", value = "服务项目名称", required = false)
                                     @RequestParam(value = "name", required = false) String name) {
        try {
            return success( "请求成功!", rehabilitationManageService.getServiceItemList(name));
        } catch (Exception e) {
            e.printStackTrace();
            return failed("请求失败");
        }
    }
    @ApiOperation("获取居民最近的一次住院病历")//wlyy_patient_medical_records_rehabilitation
    @RequestMapping(value = "getNewRehabilitation", method = RequestMethod.GET)
    public Envelop getNewRehabilitation(
            @ApiParam(name = "patientCode", value = "居民code", required = true)
            @RequestParam(value = "patientCode", required = true)String patientCode){
        try {
            List<PatientMedicalRecordsDO> result = rehabilitationManageService.getNewRehabilitation(patientCode,getUID());
            return success("获取成功", result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "请求失败");
        }
    }
    @RequestMapping(value = "selectPlanByPatient", method = RequestMethod.GET)
    @ApiOperation("康复管理-根据居民code查找康复计划")
    public Envelop calendarPlanDetailItems(@ApiParam(name = "patient", value = "居民code", required = false)
                                          @RequestParam(value = "patient", required = false)String patient,
                                          @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                          @RequestParam(value = "status", required = false)Integer status,
                                          @ApiParam(name = "planId", value = "计划id", required = false)
                                          @RequestParam(value = "planId", required = false)String planId){
        try {
            List<Map<String,Object>> result = rehabilitationManageService.selectPlanByPatient(patient,status,planId,getUID());
            return success("获取成功",  result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "请求失败");
        }
    }
    /**
     *
     * @param patient 居民code
     * @param doctor 专科医生code
     * @param type 1康复指导2康复下转3复诊提醒4上门服务提醒5家签提醒
     * @param relationCode 业务关联code
     * @param planId 计划id
     * @return
     */
    @RequestMapping(value = "sendSpecialistWeixinMessage", method = RequestMethod.GET)
    @ApiOperation("康复管理-发送微信模板消息")
    @ObserverRequired
    public Envelop sendSpecialistWeixinMessage(@ApiParam(name = "patient", value = "居民code", required = true)
                                              @RequestParam(value = "patient", required = true) String patient,
                                              @ApiParam(name = "doctor", value = "医生code", required = true)
                                              @RequestParam(value = "doctor", required = true) String doctor,
                                              @ApiParam(name = "type", value = "发送类型", required = true)
                                              @RequestParam(value = "type", required = true) Integer type,
                                              @ApiParam(name = "relationCode", value = "业务code", required = false)
                                              @RequestParam(value = "relationCode", required = true) String relationCode,
                                              @ApiParam(name = "planId", value = "计划id", required = false)
                                              @RequestParam(value = "planId", required = true) String planId,
                                              @ApiParam(name = "reservationType", value = "复诊类型:1线上,2线下,3远程", required = false)
                                              @RequestParam(value = "reservationType", required = false) String reservationType) {
        try {
            rehabilitationMessageService.sendSpecialistWeixinMessage(patient,doctor,type,relationCode,planId,reservationType);
            return success("请求成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("请求失败");
        }
    }
    @RequestMapping(value = "selectType", method = RequestMethod.GET)
    @ApiOperation("康复管理-查看指导列表标题")
    public Envelop selectType(@ApiParam(name="planId",value = "根据计划id取该计划对应疾病的指导",required = false)
                             @RequestParam(value = "planId",required = false)String planId) {
        try {
            return success("请求成功!",  rehabilitationGuidanceService.selectType(planId));
        } catch (Exception e) {
            e.printStackTrace();
            return failed("请求失败");
        }
    }
    @RequestMapping(value = "sendGuidance", method = RequestMethod.POST)
    @ApiOperation("康复管理-发送康复指导")
    public Envelop selectType(@ApiParam(name = "json", value = "康复指导json", required = true)
                             @RequestParam(value = "json", required = true) String json,
                             @ApiParam(name = "planId", value = "计划ID", required = true)
                             @RequestParam(value = "planId", required = true) String planId) {
        try {
            com.alibaba.fastjson.JSONArray array = com.alibaba.fastjson.JSONArray.parseArray(json);
            List<RehabilitationguidancePatientDO> rehabilitationguidancePatientDOS = new ArrayList<>();
            for (int i=0;i<array.size();i++){
                com.alibaba.fastjson.JSONObject object = array.getJSONObject(i);
                RehabilitationguidancePatientDO rehabilitationguidancePatientDO = objectMapper.readValue(object.toJSONString(),RehabilitationguidancePatientDO.class);
                rehabilitationguidancePatientDOS.add(rehabilitationguidancePatientDO);
            }
            return success( "请求成功!",  rehabilitationGuidanceService.sendGuidanceToPatient(rehabilitationguidancePatientDOS,planId));
        } catch (Exception e) {
           e.printStackTrace();
            return failed( "请求失败");
        }
    }
    @RequestMapping(value = "selectGuidances", method = RequestMethod.GET)
    @ApiOperation("康复管理-查看指导列表")
    public Envelop selectType(@ApiParam(name = "type", value = "康复指导类型", required = false)
                             @RequestParam(value = "type", required = false) Integer type,
                             @ApiParam(name = "id", value = "康复指导模板id", required = false)
                             @RequestParam(value = "id", required = false) String id,
                             @ApiParam(name = "title", value = "康复指导名称", required = false)
                             @RequestParam(value = "title", required = false) String title,
                             @ApiParam(name = "planId", value = "计划id", required = false)
                             @RequestParam(value = "planId", required = false) String planId,
                             @ApiParam(name = "page", value = "页码", required = false)
                             @RequestParam(value = "page", required = false, defaultValue ="1") Integer page,
                             @ApiParam(name = "pagesize", value = "每页大小", required = false)
                             @RequestParam(value = "pagesize", required = false,defaultValue = "15") Integer pagesize) {
        try {
            return success( "请求成功!", rehabilitationGuidanceService.select(title,type,id,planId,page,pagesize));
        } catch (Exception e) {
           e.printStackTrace();
            return failed("请求失败");
        }
    }
    @RequestMapping(value = "selectPatientGuidances", method = RequestMethod.GET)
    @ApiOperation("康复管理-查看指导列表")
    public Envelop selectPatientGuidances(@ApiParam(name = "patient", value = "居民code", required = false)
                                         @RequestParam(value = "patient", required = false) String patient,
                                         @ApiParam(name = "code", value = "康复指导模板code", required = false)
                                         @RequestParam(value = "code", required = false) String code,
                                         @ApiParam(name = "doctor", value = "医生code", required = false)
                                         @RequestParam(value = "doctor", required = false) String doctor,
                                         @ApiParam(name = "page", value = "页码", required = false)
                                         @RequestParam(value = "page", required = false) Integer page,
                                         @ApiParam(name = "pagesize", value = "每页大小", required = false)
                                         @RequestParam(value = "pagesize", required = false) Integer pagesize) {
        try {
            return success( "请求成功!", rehabilitationGuidanceService.selectPatientGuidances(patient,doctor,code,page,pagesize));
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "请求失败");
        }
    }
    @RequestMapping(value = "selectByRelationCode", method = RequestMethod.GET)
    @ApiOperation("康复管理-根据业务code查找康复指导")
    public Envelop selectByRelationCode(@ApiParam(name = "relationCode", value = "业务关联code", required = false)
                                       @RequestParam(value = "relationCode", required = false) String relationCode,
                                       @ApiParam(name = "patient", value = "居民code", required = false)
                                       @RequestParam(value = "patient", required = false) String patient,
                                       @ApiParam(name = "doctor", value = "医生code", required = false)
                                       @RequestParam(value = "doctor", required = false) String doctor) {
        try {
            return success( "请求成功!", rehabilitationGuidanceService.selectByRelationCode(patient,doctor,relationCode));
        } catch (Exception e) {
          e.printStackTrace();
            return failed( "请求失败");
        }
    }
    @RequestMapping(value = "selectPlanDetailByPlanId", method = RequestMethod.GET)
    @ApiOperation("康复管理-查看其它服务计划")
    public Envelop selectPlanDetailByPlanId(@ApiParam(name = "planId", value = "计划id", required = true)
                                            @RequestParam(value = "planId", required = true) String planId,
                                            @ApiParam(name = "planDetailId", value = "计划详情id", required = true)
                                            @RequestParam(value = "planDetailId", required = true) String planDetailId,
                                            @ApiParam(name = "itemId", value = "服务项目code", required = true)
                                            @RequestParam(value = "itemId", required = true) String itemId) {
        try {
            return success( "请求成功!",rehabilitationManageService.selectPlanDetailByPlan(planId,planDetailId,itemId));
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "请求失败");
        }
    }
    @PostMapping(value = "appointmentConsultation")
    @ApiOperation("预约协诊")
    public ObjEnvelop appointmentConsultation(@ApiParam(name = "patient", value = "居民code", required = true)
                                          @RequestParam(value = "patient", required = true) String patient,
                                          @ApiParam(name = "doctor", value = "医生code-家医", required = true)
                                          @RequestParam(value = "doctor", required = true) String doctor,
                                          @ApiParam(name = "doctorName", value = "医生姓名-家医", required = true)
                                          @RequestParam(value = "doctorName", required = true) String doctorName,
                                          @ApiParam(name = "appointmentDoctor", value = "医生code-专科", required = true)
                                          @RequestParam(value = "appointmentDoctor", required = true) String appointmentDoctor,
                                          @ApiParam(name = "appointmentDoctorName", value = "医生姓名-专科", required = true)
                                          @RequestParam(value = "appointmentDoctorName", required = true) String appointmentDoctorName,
                                          @ApiParam(name = "sendTime", value = "发送时间", required = true)
                                          @RequestParam(value = "sendTime", required = true) String sendTime,
                                          @ApiParam(name = "planDetailId", value = "计划明细id", required = true)
                                          @RequestParam(value = "planDetailId", required = true) String planDetailId){
        try {
            return rehabilitationManageService.appointmentConsultation(patient,doctor,doctorName,appointmentDoctor,appointmentDoctorName,sendTime,planDetailId,getUID());
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "请求失败");
        }
    }
    @RequestMapping(value = "updateRelationCodeByDetailId", method = RequestMethod.POST)
    @ApiOperation("康复管理-服务项目关联关系")
    @ObserverRequired
    public Envelop updateRelationCodeByDetailId(@ApiParam(name = "planDetailId", value = "康复计划项目明细ID")@RequestParam(value = "planDetailId", required = true)String planDetailId,
                                               @ApiParam(name = "relationCode", value = "业务关联code", required = false)@RequestParam(value = "relationCode", required = false)String relationCode){
        try {
            Integer result = rehabilitationManageService.updateRelationCodeByDetailId(planDetailId,relationCode);
            if (result==1){
                return success( "更新日志成功!");
            }else {
                return failed( "更新日志失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "更新日志失败");
        }
    }
}

+ 465 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/doctor/DoctorRehabilitationPlanController.java

@ -0,0 +1,465 @@
package com.yihu.rehabilitation.controller.doctor;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.patient.Patient;
import com.yihu.jw.entity.rehabilitation.SpecialDiseaseMessagesDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationOperateRecordsDO;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.rehabilitation.service.DoctorPatientRelationService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.yihu.rehabilitation.aop.ObserverRequired;
import com.yihu.rehabilitation.dao.SpecialDiseaseMessagesDao;
import com.yihu.rehabilitation.service.PatientRecordService;
import com.yihu.rehabilitation.service.RehabilitationPlanService;
import com.yihu.rehabilitation.service.ZsRehabilitationInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.persistence.criteria.CriteriaBuilder;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by humingfen on 2018/8/22.
 */
@RestController
@RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationPlan.Perfix,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-康复服务套餐管理")
public class DoctorRehabilitationPlanController extends EnvelopRestEndpoint {
    @Autowired
    private RehabilitationPlanService rehabilitationPlanService;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private PatientRecordService patientRecordService;
    @Autowired
    private ZsRehabilitationInfoService zsRehabilitationInfoService;
    @Autowired
    private DoctorPatientRelationService doctorPatientRelationService;
    @Autowired
    private SpecialDiseaseMessagesDao specialDiseaseMessagesDao;
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Value("${demo.flag}")
    private Boolean demoFlag;
    @Value("${wechat.id}")
    private String  wxId;
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationPlan.createRehabilitationPlan, method = RequestMethod.POST)
    @ApiOperation(value = "创建居民康复计划")
    @ObserverRequired
    public ObjEnvelop createRehabilitationPlan(@ApiParam(name = "doctor", value = "医生标识")
                                           @RequestParam(required = false)String doctor,
                                               @ApiParam(name = "json", value = "康复计划json")
                                           @RequestParam(required = true) String json){
        try {
            if(!StringUtils.isNotBlank(doctor)){
                doctor = getUID();
            }
            BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
            JSONObject object = new JSONObject(json);
            JSONArray array = object.getJSONArray("detail");
            Set<String> list = new HashSet<>();
            for(int i=0;i<array.length();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                String hospitalServiceItemId = jsonObject.getString("hospitalServiceItemId");
                String frequencyCode = jsonObject.getString("frequencyCode");
                Long timeType = jsonObject.getLong("timeType");
                String executeTimes =jsonObject.getString("executeTimes");
                String str[] = executeTimes.split(",");
                for (int j=i+1;j<array.length();j++){
                    JSONObject jsonObject1 = array.getJSONObject(j);
                    String hospitalServiceItemId1 = jsonObject1.getString("hospitalServiceItemId");
                    String frequencyCode1 = jsonObject1.getString("frequencyCode");
                    Long timeType1 = jsonObject1.getLong("timeType");
                    String executeTimes1 =jsonObject1.getString("executeTimes");
                    if (hospitalServiceItemId.equalsIgnoreCase(hospitalServiceItemId1)&&frequencyCode.equalsIgnoreCase(frequencyCode1)&&timeType.equals(timeType1)){
                        for (int z=0;z<str.length;z++){
                            if (executeTimes1.contains(str[z])){
                                list.add(hospitalServiceItemId);
                            }
                        }
                    }
                }
            }
            if (list != null && list.size()!=0){
                return ObjEnvelop.getError("计划创建失败!您设置了重复项目时间,请修改后生成!",-1);
            }
            return  ObjEnvelop.getSuccess("获取成功",rehabilitationPlanService.createRehabilitationPlan(json,baseDoctorDO),200);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    /*@RequestMapping(value = "/findTemplateList", method = RequestMethod.GET)
    @ApiOperation(value = "获取康复服务套餐模板列表")
    public String templateList(@ApiParam(name = "doctor", value = "医生标识")
                               @RequestParam(required = false)String doctor,
                               @ApiParam(name = "patient", value = "居民标识")
                               @RequestParam(required = false)String patient){
        try {
            if(!StringUtils.isNotBlank(doctor)){
                doctor = getUID();
            }
            return write(200, "获取成功", "data", rehabilitationPlanService.findTemplateInfo(doctor, patient));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }*/
    @PostMapping(value = RehabilitationRequestMapping.DoctorRehabilitationPlan.createServiceQrCode)
    @ApiOperation(value = "根据康复计划明细id和医生code生成服务码")
    public MixEnvelop<String,String> createServiceQrCode(@ApiParam(name = "planDetailId", value = "康复计划项目明细ID")@RequestParam(value = "planDetailId", required = true)String planDetailId,
                                                         @ApiParam(name = "doctorCode", value = "医生code")@RequestParam(value = "doctorCode", required = true)String doctorCode){
        try {
            return rehabilitationPlanService.createServiceQrCode(planDetailId,doctorCode);
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value =RehabilitationRequestMapping.DoctorRehabilitationPlan.checkAfterQrCode)
    @ApiOperation(value = "居民扫码后验证是否是关联的居民扫码")
    public MixEnvelop<Map<String,Object>,Map<String,Object>> checkAfterQrCode(@ApiParam(name = "planDetailId", value = "康复计划项目明细ID")@RequestParam(value = "planDetailId", required = true)String planDetailId,
                                                                              @ApiParam(name = "patientCode", value = "居民端登录的居民code")@RequestParam(value = "patientCode", required = true)String patientCode){
        try {
            String message="";
            Boolean flag = true;
            Map<String,Object> map = rehabilitationPlanService.checkAfterQrCode(planDetailId,patientCode);
            int result = Integer.valueOf(String.valueOf(map.get("code")));
            if (result==200){
                message = "验证成功!";
            }
            if (result==-1){
                message = "请相关居民扫描二维码";
                flag=false;
            }
            if (result==-10000){
                message = "相关康复管理数据错误,请联系工作人员!";
                flag=false;
            }
            map.put("flag",flag);
            map.remove("code");
            return MixEnvelop.getSuccess(message,map);
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.DoctorRehabilitationPlan.saveRehabilitationOperateRecord, method = RequestMethod.POST)
    @ApiOperation("康复管理-新增operateRecord")
    public MixEnvelop saveRehabilitationOperateRecord(@ApiParam(name = "dataJson", value = "实体json",defaultValue = "{\"rehabilitationDetailId\":\"402803f6657f195301657f4fbd3c0001\",\"patientCode\":\"00\",\"patientName\":\"11\",\"doctorCode\":\"22\",\"doctorName\":\"33\",\"node\":\"jjjjjj\",\"relationRecordType\":\"4\",\"relation_record_code\":\"55\",\"relationRecordImg\":\"666666\",\"status\":\"0\"}")@RequestParam(value = "dataJson", required = true)String dataJson){
        try {
            JSONObject json = new JSONObject(dataJson);
            if(json.has("patientCode")){
                BasePatientDO patient = basePatientDao.findById(json.get("patientCode")+"");
                json.put("patientName",patient!=null?patient.getName():"");
                json.put("patientName",patient!=null?patient.getName():"");
                try {
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    SpecialDiseaseMessagesDO diseaseMessages = new SpecialDiseaseMessagesDO();
                    diseaseMessages.setCode(patient.getId());
                    diseaseMessages.setName(patient.getName());
                    diseaseMessages.setAddress(patient.getAddress());
                    diseaseMessages.setCodeType("2");
                    diseaseMessages.setCreateTime(sdf.format(new Date()));
                    diseaseMessages.setResult("完成电话短信关怀");
                    specialDiseaseMessagesDao.save(diseaseMessages);
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
            if(json.has("doctorCode")){
                BaseDoctorDO doctor = baseDoctorDao.findById(json.get("doctorCode")+"");
                json.put("doctorName",doctor!=null?doctor.getName():"");
            }
            RehabilitationOperateRecordsDO rehabilitationOperateRecordsDO= toEntity(json.toString(), RehabilitationOperateRecordsDO.class);
            return MixEnvelop.getSuccess(SpecialistMapping.api_success,rehabilitationPlanService.saveRehabilitationRecord(rehabilitationOperateRecordsDO));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.DoctorRehabilitationPlan.updatePlanStatusById)
    @ApiOperation(value = "康复管理-更新康复计划状态")
    public MixEnvelop updatePlanStatusById(@ApiParam(name = "planId", value = "康复计划id", required = true)
                                           @RequestParam(value = "planId", required = true)String planId,
                                           @ApiParam(name = "status", value = "状态", required = true)
                                           @RequestParam(value = "status", required = true)Integer status,
                                           @ApiParam(name = "abortReason", value = "中止原因", required = true)
                                           @RequestParam(value = "abortReason", required = false)String abortReason){
        try {
            if(status!=0){
                return rehabilitationPlanService.updatePlanStatusById(status,planId);
            }else {
                return rehabilitationPlanService.abortPlanById(planId,abortReason);
            }
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.DoctorRehabilitationPlan.updatePatientImgById)
    @ApiOperation(value = "更新康复计划居民签名照/证件照")
    public Envelop updatePatientImgById(@ApiParam(name = "planId", value = "康复计划id", required = true)
                                        @RequestParam(value = "planId")String planId,
                                        @ApiParam(name = "patientImg", value = "居民签名/证件照地址",required = true)
                                        @RequestParam(value = "patientImg")String patientImg){
        try {
            return rehabilitationPlanService.updatePatientImgById(planId, patientImg);
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.DoctorRehabilitationPlan.findServicePackageItem)
    @ApiOperation(value = "查询康复计划项目")
    public ObjEnvelop findServicePackageItem(@ApiParam(name = "doctorId", value = "医生id", required = true)
                                        @RequestParam(value = "doctorId")String doctorId){
        try {
            return rehabilitationPlanService.findServiceItemByDoctor(doctorId);
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.DoctorRehabilitationPlan.findDoctorTeams)
    @ApiOperation(value = "查询医生团队")
    public ObjEnvelop findDoctorTeams(@ApiParam(name = "doctor", value = "医生id", required = false)
                                             @RequestParam(value = "doctor", required = false)String doctor){
        try {
            return ObjEnvelop.getSuccess("操作成功",rehabilitationPlanService.findDoctorTeams(doctor));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.DoctorRehabilitationPlan.findDoctorByTeams)
    @ApiOperation(value = "根据团队查询医生列表")
    public ObjEnvelop findDoctorByTeams(@ApiParam(name = "teamCode", value = "团队id", required = false)
                                            @RequestParam(value = "teamCode", required = false)String teamCode){
        try {
            return ObjEnvelop.getSuccess("操作成功",rehabilitationPlanService.findDoctorByTeams( teamCode));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = RehabilitationRequestMapping.DoctorRehabilitationPlan.findDoctorPatients)
    @ApiOperation(value = "根据团队查询医生列表")
    public MixEnvelop findDoctorPatients(@ApiParam(name = "doctor", value = "医生id", required = false)
                                        @RequestParam(value = "doctor", required = false)String doctor,
                                         @ApiParam(name = "patient", value = "患者id", required = false)
                                         @RequestParam(value = "patient", required = false)String patient,
                                         @ApiParam(name = "patientName", value = "患者姓名", required = false)
                                             @RequestParam(value = "patientName", required = false)String patientName,
                                         @ApiParam(name = "isDeal", value = "是否下转1是0否", required = false)
                                             @RequestParam(value = "isDeal", required = false)String isDeal,
                                         @ApiParam(name = "idcard", value = "是否下转1是0否", required = false)
                                             @RequestParam(value = "idcard", required = false)String idcard,
                                         @ApiParam(name = "page", value = "page", required = false)
                                             @RequestParam(value = "page", required = false)Integer page,
                                         @ApiParam(name = "pageSize", value = "pageSize", required = false)
                                             @RequestParam(value = "pageSize", required = false) Integer pageSize){
        try {
            return doctorPatientRelationService.findDoctorPatients(doctor,patient,patientName,isDeal,idcard,page,pageSize);
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = "getPatientByIdcardOrSsc", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("根据患者身份证或社保卡号进行搜索添加出院记录")
    public Envelop getPatientByIdcardOrSsc(@ApiParam(name = "patientInfo", value = "居民身份证或者社保卡", required = true)
                                          @RequestParam(value = "patientInfo")String patientInfo) {
        try {
            com.alibaba.fastjson.JSONObject object = doctorPatientRelationService.getPatientByIdcardOrSsc(patientInfo, getUID());
            if(object.getInteger("status") == 200) {
                return success("添加成功!", object.get("data"));
            }else {
                return failed( object.getString("msg"));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return failed("添加失败!");
        }
    }
    @RequestMapping(value = "/updateRehabilitationPlan", method = RequestMethod.POST)
    @ApiOperation(value = "编辑居民康复计划")
    public Envelop updateRehabilitationPlan(@ApiParam(name = "doctor", value = "医生标识")
                                           @RequestParam(required = false)String doctor,
                                           @ApiParam(name = "json", value = "康复计划json")
                                           @RequestParam(required = true) String json,
                                           @ApiParam(name = "updateStatus", value = "修改类型:0单个服务的修改(默认),1整个计划修改")
                                           @RequestParam(required = false,defaultValue = "0") String updateStatus){
        try {
            if(!StringUtils.isNotBlank(doctor)){
                doctor = getUID();
            }
            BaseDoctorDO d = baseDoctorDao.findById(doctor);
            JSONObject object = new JSONObject(json);
            JSONArray array = object.getJSONArray("detail");//获取服务内容
            Set<String> list = new HashSet<>();
            for(int i=0;i<array.length();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                String hospitalServiceItemId = jsonObject.getString("hospitalServiceItemId");//服务id
                String frequencyCode = jsonObject.getString("frequencyCode");
                Long timeType = jsonObject.getLong("timeType");
                String executeTimes =jsonObject.getString("executeTimes");
                String str[] = executeTimes.split(",");
                for (int j=i+1;j<array.length();j++){
                    JSONObject jsonObject1 = array.getJSONObject(j);
                    String hospitalServiceItemId1 = jsonObject1.getString("hospitalServiceItemId");
                    String frequencyCode1 = jsonObject1.getString("frequencyCode");
                    Long timeType1 = jsonObject1.getLong("timeType");
                    String executeTimes1 =jsonObject1.getString("executeTimes");
                    if (hospitalServiceItemId.equalsIgnoreCase(hospitalServiceItemId1)&&frequencyCode.equalsIgnoreCase(frequencyCode1)&&timeType.equals(timeType1)){
                        for (int z=0;z<str.length;z++){
                            if (executeTimes1.contains(str[z])){//时间与之前项目时间相同
                                list.add(hospitalServiceItemId);
                            }
                        }
                    }
                }
            }
            if (list != null && list.size()!=0){
                return failed( "计划创建失败!您设置了重复项目时间,请修改后生成!");
            }
            return success("获取成功", rehabilitationPlanService.updateRehabilitationPlan(json,d,updateStatus));
        } catch (Exception e) {
            e.printStackTrace();
            return failed("请求失败");
        }
    }
    @RequestMapping(value = "getRehabilitationPlanLog",method = RequestMethod.GET)
    @ApiOperation(value = "获取康复计划修改记录")
    public Envelop getRehabilitationPlanLog(@ApiParam(name = "planId",value = "康复计划Id",required = true)
                                           @RequestParam(value = "planId",required = true) String planId){
        try {
            return success("获取成功",rehabilitationPlanService.getRehabilitationPlanLog(planId));
        }catch (Exception e){
            return failed("请求失败");
        }
    }
    /**
     * 查询居民信息
     *
     * @param patient 患者
     * @return
     */
    @GetMapping(value = "/patient")
    @ApiOperation("查询居民信息")
    public Envelop getPatient(String patient) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return failed( "居民不能为空");
            }
            JSONObject p = rehabilitationPlanService.getPatient(patient,getUID());
            return success( "查询成功",  p);
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "居民不能为空");
        }
    }
    @RequestMapping(value = "/findTemplateDetail", method = RequestMethod.GET)
    @ApiOperation(value = "获取康复服务套餐模板明细")
    public Envelop findTemplateDetail(@ApiParam(name = "templateId", value = "模板id")
                                     @RequestParam(required = true)String templateId){
        try {
            return success( "获取成功", rehabilitationPlanService.findTemplateDetailInfo(templateId));
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "请求失败");
        }
    }
    @ApiOperation("获取门诊记录/住院记录(基卫+APP)")
    @RequestMapping(value = "/event", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public Envelop getAllEvent(@ApiParam(name = "patient", value = "患者代码", defaultValue = "")
                              @RequestParam(value = "patient", required = false) String patient,
                              @ApiParam(name = "type", value = "类型", defaultValue = "")
                              @RequestParam(value = "type", required = false) String type,
                              @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                              @RequestParam(value = "page", required = true) String page,
                              @ApiParam(name = "pageSize", value = "每页几行", defaultValue = "10")
                              @RequestParam(value = "pageSize", required = true) String pageSize,
                              @ApiParam(name = "lastTime", value = "最后一条时间", defaultValue = "2010-10-10 00:00:00")
                              @RequestParam(value = "lastTime", required = false) String lastTime) {
        try {
            if(demoFlag){
                String res;
                switch (type){
                    case "1":
                    case "2":
                        res = patientRecordService.getJosnFileResullt("event"+type);
                        break;
                    default:
                        return success("获取成功");
                }
                return success(res);
            }else {
                List<Map<String, String>> result = patientRecordService.getAllEvent(patient, type, page, pageSize, lastTime);
                return success("获取就诊记录成功!", result);
            }
        } catch (Exception e) {
            e.printStackTrace();
            if (e.getMessage().indexOf("卡号尚未在医疗机构注册过") > 0) {
                return failed("对不起,您的社保卡有变更,请改天再试");
            } else if (e.getMessage().startsWith("error")) {
                return failed( e.getMessage());
            } else {
                return failed("获取门/急诊数据失败!");
            }
        }
    }
    @RequestMapping(value = "sendWxMsg", method = RequestMethod.POST)
    @ApiOperation("发送微信模板消息")
    public Envelop sendWxTemplate(@ApiParam(name = "planId", value = "康复计划id", required = true)
                                 @RequestParam(value = "planId")String planId){
        try {
            JSONObject jsonObject = rehabilitationPlanService.getServiceItemsAfterStop(planId);
            rehabilitationPlanService.sendWxTemplate(wxAccessTokenService.getWxAccessTokenById(wxId).getAccessToken(), planId, getUID(), jsonObject);
            return success( "发送成功!");
        } catch (Exception e) {
           e.printStackTrace();
            return failed("发送失败");
        }
    }
}

+ 534 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/followUp/DoctorFollowUpController.java

@ -0,0 +1,534 @@
package com.yihu.rehabilitation.controller.followUp;
import com.alibaba.fastjson.JSON;
import com.yihu.jw.entity.followup.Followup;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.rehabilitation.aop.ObserverRequired;
import com.yihu.rehabilitation.service.followUp.FollowUpService;
import com.yihu.rehabilitation.service.followUp.FollowupDrugsService;
import com.yihu.rehabilitation.util.BusinessLogs;
import com.yihu.rehabilitation.vo.FollowupContentESDO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
/**
 * 医生端:随访接口
 *
 * @author hzp add 2016-12-07
 */
@Controller
@RequestMapping(value = "/doctor/followup", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-随访接口")
public class DoctorFollowUpController  extends EnvelopRestEndpoint {
   @Autowired
    private FollowUpService followUpService;
   @Autowired
   private JdbcTemplate jdbcTemplate;
   @Autowired
   private FollowupDrugsService followupDrugsService;
    @ApiOperation("新增随访计划(批量)")
    @RequestMapping(value = "/addFollowupPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    @ObserverRequired
    public Envelop addFollowupPlan(@ApiParam(name = "patient", value = "患者代码", defaultValue = "443a196ef8744536a531260eb26c05d7")
                                  @RequestParam(value = "patient", required = true) String patient,
                                   @ApiParam(name = "data", value = "随访计划列表json", defaultValue = "[{\"date\":\"2016-12-16 20:00:00\",\"type\":\"10\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"},{\"date\":\"2016-12-17 15:00:00\",\"type\":\"3\",\"doctor\":\"64de9952-5b15-11e6-8344-fa163e8aee56\"}]")
                                  @RequestParam(value = "data", required = true) String data) {
        try {
            Iterable<Followup> followups = followUpService.addFollowupPlan(getUID(), patient, data);
            if (followups != null) {
                for (Followup followup : followups) {
                    BusinessLogs.info(BusinessLogs.BusinessType.followup, getUID(), followup.getPatientCode(), new JSONObject(followup));
                }
            }
            return success( "新增随访计划成功!",followups);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("新增随访计划失败!" );
        }
    }
    @ApiOperation("获取随访信息")
    @RequestMapping(value = "/getFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public Envelop getFollowup(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                              @RequestParam(value = "id", required = true) String id) {
        try {
            Map<String, String> response = followUpService.getFollowup(id);
            try {
                String sql = "UPDATE `wlyy_followup` SET `doctor_read_status`='1' WHERE (`id`="+id+") ";
                jdbcTemplate.update(sql);
            }catch (Exception e){
                e.printStackTrace();
            }
            return success( "获取随访信息成功!", response);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("获取随访信息失败!" + e.getMessage());
        }
    }
    @RequestMapping(value = "/isFirstTimeFollowup",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("判断居民该类别随访是否为第一次")
    @ResponseBody
    public Envelop isFirstTimeFollowup(@ApiParam(name = "patient", value = "居民code", defaultValue = "")
                                      @RequestParam(value = "patient", required = true)String patient,
                                      @ApiParam(name = "followupClass", value = "随访类别", defaultValue = "")
                                      @RequestParam(value = "followupClass", required = true)String followupClass,
                                      @ApiParam(name = "followupId", value = "随访类别", defaultValue = "")
                                      @RequestParam(value = "followupId", required = true)Integer followupId) {
        try {
            return success( "操作成功!",followUpService.isFirstTimeFollowup(getUID(),patient,followupClass,followupId));
        }catch (Exception e){
            //日志文件中记录异常信息
          e.printStackTrace();
            //返回接口异常信息处理结果
            return failed( "操作失败!");
        }
    }
    @ApiOperation("开始随访记录")
    @RequestMapping(value = "/startFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    @ObserverRequired
    public Envelop startFollowup(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                @RequestParam(value = "id", required = true) String id,
                                @ApiParam(name = "followupNo", value = "随访记录编码")
                                @RequestParam(value = "followupNo", required = false) String followupNo,
                                @ApiParam(name = "date", value = "随访时间", defaultValue = "2016-12-14 20:00:00")
                                @RequestParam(value = "date", required = true) String date,
                                @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                                @RequestParam(value = "followupType", required = true) String followupType,
                                @ApiParam(name = "followupClass", value = "随访类别【1.高血压 2.糖尿病,3高糖】", defaultValue = "1")
                                @RequestParam(value = "followupClass", required = true) String followupClass,
                                @ApiParam(name = "followupManagerStatus", value = "随访管理状态【字典FOLLOWUP_MANAGER_STATUS】", defaultValue = "1")
                                @RequestParam(value = "followupManagerStatus", required = false) String followupManagerStatus,
                                @ApiParam(name = "plandate", value = "下次随访时间", defaultValue = "2016-12-14 20:00:00")
                                @RequestParam(value = "plandate", required = false) String plandate,
                                @ApiParam(name = "prescriptioncode", value = "续方CODE", defaultValue = "")
                                @RequestParam(value = "prescriptioncode", required = false) String prescriptioncode) {
        try {
            Followup followup = followUpService.startFollowup( id, followupNo, date, followupType, followupClass, followupManagerStatus,plandate,prescriptioncode);
            followUpService.getNotStartFollowup(getUID(), followup.getFollowupPlanDate());
            return success( "开始随访记录成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("开始随访记录失败!" + e.getMessage());
        }
    }
    @ApiOperation("获取上次随访")
    @RequestMapping(value = "/getLastFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Envelop getLastFollowup(@ApiParam(name = "doctor", value = "医生代码", defaultValue = "443a196ef8744536a531260eb26c05d7")
                                  @RequestParam(value = "doctor", required = true) String doctor,
                                  @ApiParam(name = "patient", value = "患者代码", defaultValue = "P20161008001")
                                  @RequestParam(value = "patient", required = true) String patient,
                                  @ApiParam(name = "followClass", value = "随访类别", defaultValue = "1")
                                  @RequestParam(value = "followClass", required = true) String followClass) {
        try {
            Map<String, String> response = followUpService.getLastFollowup(doctor, patient, followClass);
            return success( "获取上次随访成功!",response);
        } catch (Exception e) {
          e.printStackTrace();
            return failed("获取上次随访失败!" + e.getMessage());
        }
    }
    @ApiOperation("复制上次随访数据")
    @RequestMapping(value = "/copyFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Envelop copyFollowup(@ApiParam(name = "id", value = "本地随访ID", defaultValue = "")
                               @RequestParam(value = "id", required = true) Long id,
                               @ApiParam(name = "fromId", value = "拷贝随访记录ID", defaultValue = "")
                               @RequestParam(value = "fromId", required = true) Long fromId) {
        try {
            followUpService.copyFollowup(id, fromId);
            return success( "复制上次随访成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("复制上次随访失败!" + e.getMessage());
        }
    }
    @ApiOperation("保存全部随访表单数据")
    @RequestMapping(value = "/saveAllFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    @ObserverRequired
    public Envelop saveAllFollowupProjectData(@ApiParam(name = "id", value = "随访记录ID")
                                             @RequestParam(value = "id", required = true) String id,
                                             @ApiParam(name = "followupNo", value = "随访记录编码")
                                             @RequestParam(value = "followupNo", required = false) String followupNo,
                                             @ApiParam(name = "date", value = "随访时间", defaultValue = "2016-12-14 20:00:00")
                                             @RequestParam(value = "date", required = false) String date,
                                             @ApiParam(name = "followupType", value = "随访方式【字典FOLLOWUP_WAY_DICT】", defaultValue = "12")
                                             @RequestParam(value = "followupType", required = false) String followupType,
                                             @ApiParam(name = "followupClass", value = "随访类别【1.高血压 2.糖尿病,3高糖】", defaultValue = "1")
                                             @RequestParam(value = "followupClass", required = false) String followupClass,
                                             @ApiParam(name = "followupManagerStatus", value = "随访管理状态【字典FOLLOWUP_MANAGER_STATUS】", defaultValue = "1")
                                             @RequestParam(value = "followupManagerStatus", required = false) String followupManagerStatus,
                                             @ApiParam(name = "plandate", value = "下次随访时间", defaultValue = "2016-12-14 20:00:00")
                                             @RequestParam(value = "plandate", required = false) String plandate,
                                             @ApiParam(name = "prescriptioncode", value = "续方CODE")
                                             @RequestParam(value = "prescriptioncode", required = false) String prescriptioncode,
                                             @ApiParam(name = "followupProjectData", value = "随访项目数据", defaultValue = "{\"WEIGHT\":\"76\",\"WEIGHT_EXP\":\"60\",\"BMI\":\"11\"}")
                                             @RequestParam(value = "followupProjectData", required = true) String followupProjectData) {
        try {
            JSONObject jsonObject = new JSONObject(followupProjectData);
            Followup followup = followUpService.startFollowup(id, followupNo, date, followupType, followupClass, followupManagerStatus, plandate, prescriptioncode);
            followUpService.finishFollowup(id);
            followUpService.saveAllFollowupProjectData(id, jsonObject.getJSONObject("followupProjectData").toString());
            followupDrugsService.saveFollowupDrugs(id,jsonObject.getJSONArray("drugsData").toString());
            return success( "保存随访项目数据成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("保存随访项目数据失败!" + e.getMessage());
        }
    }
    @RequestMapping(value = "/updateFollowStatus",produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ApiOperation("完成随访")
    @ResponseBody
    public Envelop  updateFollowStatus(@ApiParam(name = "followupId", value = "随访ID", defaultValue = "")
                                      @RequestParam(value = "followupId", required = true) Integer followupId,
                                      @ApiParam(name = "isFlag", value = "标识第一次还是N次肺结核(第一次0,n次为1)", defaultValue = "")
                                      @RequestParam(value = "isFlag", required = false)Integer isFlag)throws Exception {
        try {
            return success( "操作成功!",followUpService.updateFollowStatus(followupId,isFlag));
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed( "操作失败!");
        }
    }
    @RequestMapping(value = "/urlAnalysis",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("门牌解析上门地址")
    @ResponseBody
    public Envelop urlAnalysis(@ApiParam(name = "url", value = "地址解析", defaultValue = "")
                              @RequestParam(value = "url", required = true)String url)throws Exception {
        try {
            return success( "操作成功!",followUpService.urlAnalysis(url));
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed( "操作失败!");
        }
    }
    @RequestMapping(value = "/saveFollowupSign",produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ApiOperation("签到")
    @ResponseBody
    public Envelop saveFollowupSign(@ApiParam(name = "jsonSign", value = "签到", defaultValue = "")
                                   @RequestParam(value = "jsonSign", required = true)String jsonSign)throws Exception {
        try {
            return success("操作成功!",followUpService.saveFollowupSign(jsonSign));
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed( "操作失败!");
        }
    }
    @RequestMapping(value = "/updateFollowupSign",produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ApiOperation("更新签到")
    @ResponseBody
    public Envelop updateFollowupSign(@ApiParam(name = "jsonSign", value = "签到", defaultValue = "")
                                     @RequestParam(value = "jsonSign", required = true)String jsonSign)throws Exception {
        try {
            return success( "操作成功!",followUpService.updateFollowupSign(jsonSign));
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed( "操作失败!");
        }
    }
    @RequestMapping(value = "/findByFollowupId",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("签约详情")
    @ResponseBody
    public Envelop findByFollowupId(@ApiParam(name = "followupId", value = "签到", defaultValue = "")
                                   @RequestParam(value = "followupId", required = true)Integer followupId) {
        try {
            return success("操作成功!",followUpService.findByFollowupId(followupId));
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed( "操作失败!");
        }
    }
    @RequestMapping(value = "/findFollowupInfo",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取随访详情")
    @ResponseBody
    public Envelop findFollowupInfo(@ApiParam(name = "followupId", value = "随访ID", defaultValue = "")
                                   @RequestParam(value = "followupId", required = true)Integer followupId) {
        try {
            return success( "操作成功!",followUpService.findFollowupInfo(followupId));
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed( "操作失败!");
        }
    }
    @RequestMapping(value = "/delFollowup",produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ApiOperation("删除随访访视")
    @ResponseBody
    public Envelop delFollowup(@ApiParam(name = "followupId", value = "随访ID", defaultValue = "")
                              @RequestParam(value = "followupId", required = true)Integer followupId)throws Exception {
        try {
            Followup followup = followUpService.delFollowup(followupId);
            followUpService.getNotStartFollowup(getUID(), followup.getFollowupPlanDate());
            return success("操作成功!", true);
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed( "操作失败!"+e.getMessage());
        }
    }
    @RequestMapping(value = "/saveFollowup",produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ApiOperation("保存随访访视")
    @ResponseBody
    public Envelop saveFollowup(@ApiParam(name = "jsonFollowup", value = "创建访视json", defaultValue = "")
                               @RequestParam(value = "jsonFollowup", required = true)String jsonFollowup){
        try {
            return success( "操作成功!",followUpService.saveFollowup(jsonFollowup));
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed( "操作失败!"+e.getMessage());
        }
    }
    @RequestMapping(value = "/findPatientFollowList",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取居民随访列表")
    @ResponseBody
    public Envelop findPatientFollowList(@ApiParam(name = "patient", value = "居民code", defaultValue = "")
                                        @RequestParam(value = "patient", required = true)String patient,
                                        @ApiParam(name = "doctor", value = "医生code", defaultValue = "")
                                        @RequestParam(value = "doctor", required = true)String doctor){
        try {
            return success("操作成功!",followUpService.findPatientFollowList(patient,doctor));
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed( "操作失败!");
        }
    }
    @RequestMapping(value = "/findPatientInfo",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取居民单条信息")
    @ResponseBody
    public Envelop findPatientInfo(@ApiParam(name = "patient", value = "居民code", defaultValue = "")
                                  @RequestParam(value = "patient", required = true)String patient) {
        try {
            return success( "操作成功!",followUpService.findPatientInfo(patient));
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed("操作失败!");
        }
    }
    @RequestMapping(value = "/findFollowUpPatient",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取可随访居民列表")
    @ResponseBody
    public Envelop findFollowUpPatient(@ApiParam(name = "namekey", value = "居民姓名模糊", defaultValue = "")
                                      @RequestParam(value = "namekey", required = false)String namekey,
                                      @ApiParam(name = "labelCode", value = "标签code", defaultValue = "1")
                                      @RequestParam(value = "labelCode", required = false)String labelCode,
                                      @ApiParam(name = "doctor", value = "医生", defaultValue = "zjm20190214")
                                      @RequestParam(value = "doctor", required = true)String doctor,
                                      @ApiParam(name = "page", value = "页数,1开始", defaultValue = "1")
                                      @RequestParam(value = "page", required = true)Integer page,
                                      @ApiParam(name = "size", value = "每页大小", defaultValue = "10")
                                      @RequestParam(value = "size", required = true)Integer size)throws Exception {
        try {
            return success( "操作成功!",followUpService.findFollowUpPatient(namekey,doctor,labelCode,page,size));
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed("操作失败!");
        }
    }
    @RequestMapping(value = "/findLabelListWithCount",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取随访标签列表带居民数")
    @ResponseBody
    public Envelop findLabelListWithCount(){
        try {
            return success("操作成功!",followUpService.findLabelListWithCount());
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed( "操作失败!");
        }
    }
    @RequestMapping(value = "/findFollowupList",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取访视列表形式")
    @ResponseBody
    public Envelop findFollowupList(@ApiParam(name = "doctor", value = "医生", defaultValue = "zjm20190214")
                                   @RequestParam(value = "doctor", required = true) String doctor,
                                   @ApiParam(name = "patient", value = "居民")
                                   @RequestParam(value = "patient", required = false) String patient,
                                   @ApiParam(name = "followupClass", value = "随访类别,多类别“,”分割")
                                   @RequestParam(value = "followupClass", required = false) String followupClass,
                                   @ApiParam(name = "patientName", value = "居民姓名")
                                   @RequestParam(value = "patientName", required = false) String patientName,
                                   @ApiParam(value = "开始时间,格式(yyyy-MM-dd)", name = "startDate",required = false)
                                   @RequestParam(value = "startDate", required = false) String startDate,
                                   @ApiParam(value = "结束时间,格式(yyyy-MM-dd)", name = "endDate",required = false)
                                   @RequestParam(value = "endDate", required = false) String endDate,
                                   @ApiParam(name = "flag", value = "区分上门访视(1-是)")
                                   @RequestParam(value = "flag", required = false) String flag,
                                   @ApiParam(name = "type", value = "")
                                   @RequestParam(value = "type", required = false) Integer type){
        try {
            return success( "操作成功!",followUpService.findFollowupList(doctor,patient,followupClass,patientName,startDate,endDate,flag,type));
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed("操作失败!");
        }
    }
    @RequestMapping(value = "/findFollowupByMonth",produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ApiOperation("获取访视计划按月日历形式")
    @ResponseBody
    public Envelop findFollowupByMonth(@ApiParam(name = "doctor", value = "医生", defaultValue = "zjm20190214")
                                      @RequestParam(value = "doctor", required = true) String doctor,
                                      @ApiParam(name = "patient", value = "居民")
                                      @RequestParam(value = "patient", required = false) String patient,
                                      @ApiParam(name = "followupClass", value = "随访类别,多类别“,”分割")
                                      @RequestParam(value = "followupClass", required = false) String followupClass,
                                      @ApiParam(name = "patientName", value = "居民姓名")
                                      @RequestParam(value = "patientName", required = false) String patientName,
                                      @ApiParam(value = "开始时间,格式(yyyy-MM-dd)", name = "startDate",required = false)
                                      @RequestParam(value = "startDate", required = false) String startDate,
                                      @ApiParam(value = "结束时间,格式(yyyy-MM-dd)", name = "endDate",required = false)
                                      @RequestParam(value = "endDate", required = false) String endDate,
                                      @ApiParam(name = "flag", value = "区分上门访视(1-是)")
                                      @RequestParam(value = "flag", required = false) String flag,
                                      @ApiParam(name = "type", value = "区分随访计划1、新增随访2、临时随访3、入户随访")
                                      @RequestParam(value = "type", required = false) Integer type){
        try {
            return success("操作成功!",followUpService.findFollowupByMonth(doctor,patient,followupClass,patientName,startDate,endDate,flag,type));
        }catch (Exception e){
            //日志文件中记录异常信息
            e.printStackTrace();
            //返回接口异常信息处理结果
            return failed( "操作失败!");
        }
    }
    @RequestMapping(value = "/getContinuedPrescriptionAsDoctor", method = RequestMethod.GET)
    @ApiOperation(value = "续方详情")
    public Envelop getContinuedPrescriptionAsDoctor(@RequestParam(required = true) @ApiParam(value = "续方CODE", name = "code") String code,
                                                   @RequestParam(required = true) @ApiParam(value = "团队长标识:1:是;2否", name = "type") String type) {
        try {
            return success( "查询成功!", followUpService.getContinuedPrescriptionAsDoctor(code));
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "查询失败!");
        }
    }
    @ApiOperation("获取随访项目列表")
    @RequestMapping(value = "/getFollowupProject", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public Envelop getFollowupProject(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                                     @RequestParam(value = "id", required = true) String id) {
        try {
            List<Map<String, String>> list = followUpService.getFollowupProject(id);
            return success( "获取随访项目列表成功!",  list);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("获取随访项目列表失败!" + e.getMessage());
        }
    }
    @ApiOperation("完成随访记录")
    @RequestMapping(value = "/finishFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    @ObserverRequired
    public Envelop finishFollowup(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "")
                                 @RequestParam(value = "id", required = true) String id) {
        try {
            followUpService.finishFollowup(id);
            return success("完成随访记录成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("完成随访记录失败!" + e.getMessage());
        }
    }
    @ApiOperation("获取随访项目数据")
    @RequestMapping(value = "/getFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public Envelop getFollowupProjectData(@ApiParam(name = "id", value = "随访记录ID", defaultValue = "4")
                                         @RequestParam(value = "id", required = true) String id,
                                         @ApiParam(name = "followupProject", value = "随访项目")
                                         @RequestParam(value = "followupProject", required = false) String followupProject) {
        try {
//            Map<String, String> response = followUpService.getFollowupProjectData(id, followupProject);
            //修改为通过ES查询---2017.11.01--huangwenjie
            FollowupContentESDO followupContentESDO = followUpService.esGetFollowupProjectDataList(id, followupProject);
            String jsonString = JSON.toJSONString(followupContentESDO);
            Map maps = (Map)JSON.parse(jsonString);
            return success( "获取随访项目数据成功!", maps);
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "获取随访项目数据失败!" + e.getMessage());
        }
    }
}

+ 80 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/followUp/DoctorPhthisisFollowupController.java

@ -0,0 +1,80 @@
package com.yihu.wlyy.web.doctor.followup;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.app.followup.PhthisisFollowupService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * 医生端:肺结核随访服务控制器
 *
 * @author lith on 2019-05-05
 */
@RestController
@RequestMapping(value = "/doctor/phthisis", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(value = "医生端-肺结核随访记录服务")
public class DoctorPhthisisFollowupController extends BaseController {
    @Autowired
    private PhthisisFollowupService phthisisFollowupService;
    @PostMapping(value = "/saveFirst")
    @ApiOperation(value = "保存第一次肺结核随访数据")
    public String saveFirstFollowup(@ApiParam(name = "jsonData", value = "随访json") @RequestParam(value = "jsonData", required = true) String jsonData) {
        StringBuilder errMsg = new StringBuilder();
        try {
            if(!phthisisFollowupService.saveFirstFollowup(jsonData,errMsg)){
                return error( -1, "保存第一次肺结核随访数据失败," + errMsg);
            }
        } catch (Exception e) {
            return errorResult(e);
        }
        return write(200, "保存第一次肺结核随访数据成功!");
    }
    @PostMapping(value = "/saveNTimes")
    @ApiOperation("保存第n次肺结核随访数据")
    public String saveNTimesFollowup(@ApiParam(name = "jsonData", value = "随访json") @RequestParam(value = "jsonData", required = true) String jsonData) {
        StringBuilder errMsg = new StringBuilder();
        try {
            if(!phthisisFollowupService.saveNTimesFollowup(jsonData,errMsg)){
                return error( -1, "保存第n次肺结核随访数据失败," + errMsg);
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "保存第n次肺结核随访数据失败," + e.getMessage());
        }
        return write(200, "保存第n次肺结核随访数据成功!");
    }
    @GetMapping(value = "/getFirst")
    @ApiOperation("查询第一次肺结核随访数据详情")
    public String queryFirst(@ApiParam(name = "followupId", value = "随访记录ID")
                                         @RequestParam(value = "followupId", required = true) String followupId) {
        try {
            JSONObject firstFollowupES = phthisisFollowupService.queryFirstByFollowupId(followupId);
            return write(200, "查询成功!", "data", firstFollowupES);
        } catch (Exception e) {
            return invalidUserException(e, -1, "查询失败!" + e.getMessage());
        }
    }
    @GetMapping(value = "/getNTimes")
    @ApiOperation("查询第n次肺结核随访数据详情")
    public String queryNTimes(@ApiParam(name = "followupId", value = "随访记录ID")
                                         @RequestParam(value = "followupId", required = true) String followupId) {
        try {
            List<JSONObject> ntimesFollowups = phthisisFollowupService.queryNTimesByFollowupId(followupId);
            return write(200, "查询成功!", "data", ntimesFollowups);
        } catch (Exception e) {
            return invalidUserException(e, -1, "查询失败!" + e.getMessage());
        }
    }
}

+ 378 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/followUp/DoctorVisitDetailController.java

@ -0,0 +1,378 @@
package com.yihu.rehabilitation.controller.followUp;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.rehabilitation.aop.ObserverRequired;
import com.yihu.rehabilitation.service.followUp.VisitDetailService;
import com.yihu.rehabilitation.vo.entity.FollowupSevereMentalDisorderES;
import com.yihu.rehabilitation.vo.entity.NewbornFamilyVisitRecordES;
import com.yihu.rehabilitation.vo.entity.OlderPeopleHealthCheckRecordES;
import com.yihu.rehabilitation.vo.entity.PostpartumVisitRecordES;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * 医生端:访视详情表单接口
 *
 * @author hmf on 2019-04-23
 */
@Controller
@RequestMapping(value = "/doctor/visitDetail", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-访视详情表单接口")
public class DoctorVisitDetailController extends EnvelopRestEndpoint {
    @Autowired
    private VisitDetailService visitDetailService;
    @ApiOperation("保存孕产妇访视详情")
    @RequestMapping(value = "/savePostpartumVisitDetails", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Envelop savePostpartumVisitDetails(@ApiParam(name = "followupId", value = "随访记录ID")
                                             @RequestParam(value = "followupId", required = true) String followupId,
                                              @ApiParam(name = "followupProject", value = "随访项目")
                                             @RequestParam(value = "followupProject", required = false) String followupProject,
                                              @ApiParam(name = "postpartumVisitDetails", value = "孕产妇访视详情数据")
                                             @RequestParam(value = "postpartumVisitDetails", required = true) String postpartumVisitDetails) {
        try {
            visitDetailService.savePostpartumVisitDetails(followupId, followupProject, postpartumVisitDetails, getUID());
            return success("保存孕产妇访视详情数据成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("保存孕产妇访视详情数据失败!" + e.getMessage());
        }
    }
    @ApiOperation("获取孕产妇访视详情")
    @RequestMapping(value = "/getPostpartumVisitDetails", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ObserverRequired
    public Envelop getFollowupProjectData(@ApiParam(name = "followupId", value = "随访记录ID")
                                         @RequestParam(value = "followupId", required = true) String followupId,
                                         @ApiParam(name = "followupProject", value = "随访项目")
                                         @RequestParam(value = "followupProject", required = false) String followupProject) {
        try {
            PostpartumVisitRecordES postpartumVisitRecord = visitDetailService.getPostpartumVisitRecord(followupId, followupProject);
            return success("获取孕产妇访视详情成功!", postpartumVisitRecord);
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("保存严重精神障碍患者随访记录")
    @RequestMapping(value = "/saveFollowupSevereMentalDisorder", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Envelop saveFollowupSevereMentalDisorder(@ApiParam(name = "followupId", value = "随访记录ID")
                                             @RequestParam(value = "followupId", required = true) String followupId,
                                             @ApiParam(name = "followupProject", value = "随访项目")
                                             @RequestParam(value = "followupProject", required = false) String followupProject,
                                             @ApiParam(name = "severeMentalDisorderData", value = "严重精神障碍患者详情数据")
                                             @RequestParam(value = "severeMentalDisorderData", required = true) String severeMentalDisorderData) {
        try {
            visitDetailService.saveFollowupSevereMentalDisorder(followupId, followupProject, severeMentalDisorderData, getUID());
            return success( "保存严重精神障碍患者随访记录成功!");
        } catch (Exception e) {
           e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("获取严重精神障碍患者随访记录")
    @RequestMapping(value = "/getFollowupSevereMentalDisorder", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ObserverRequired
    public Envelop getFollowupSevereMentalDisorder(@ApiParam(name = "followupId", value = "随访记录ID")
                                         @RequestParam(value = "followupId", required = true) String followupId,
                                         @ApiParam(name = "followupProject", value = "随访项目")
                                         @RequestParam(value = "followupProject", required = false) String followupProject) {
        try {
            FollowupSevereMentalDisorderES severeMentalDisorderES = visitDetailService.getFollowupSevereMentalDisorder(followupId, followupProject);
            return success( "获取严重精神障碍患者随访记录成功!", severeMentalDisorderES);
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("保存老人健康体检随访记录")
    @RequestMapping(value = "/saveOlderPeopleHealthCheckRecord", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Envelop saveOlderPeopleHealthCheckRecord(@ApiParam(name = "followupId", value = "随访记录ID")
                                             @RequestParam(value = "followupId", required = true) String followupId,
                                             @ApiParam(name = "followupProject", value = "随访项目")
                                             @RequestParam(value = "followupProject", required = false) String followupProject,
                                             @ApiParam(name = "olderPeopleHealthCheckData", value = "老人健康体检随访记录")
                                             @RequestParam(value = "olderPeopleHealthCheckData", required = true) String olderPeopleHealthCheckData,
                                             @ApiParam(name = "bdStatus", value = "登记健康体检表状态(0-可编辑  1-不可编辑)")
                                             @RequestParam(value = "bdStatus", required = false) Integer bdStatus,
                                             @ApiParam(name = "pgStatus", value = "老年人生活自理能力评估表状态(0-可编辑  1-不可编辑)")
                                             @RequestParam(value = "pgStatus", required = false) Integer pgStatus ) {
        try {
            visitDetailService.saveOlderPeopleHealthCheckRecord(followupId, followupProject, olderPeopleHealthCheckData, getUID(),bdStatus,pgStatus);
            return success( "保存老人健康体检随访记录成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("获取老人健康体检随访记录")
    @RequestMapping(value = "/getOlderPeopleHealthCheckRecord", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ObserverRequired
    public Envelop getOlderPeopleHealthCheckRecord(@ApiParam(name = "followupId", value = "随访记录ID")
                                         @RequestParam(value = "followupId", required = true) String followupId,
                                         @ApiParam(name = "followupProject", value = "随访项目")
                                         @RequestParam(value = "followupProject", required = false) String followupProject) {
        try {
            OlderPeopleHealthCheckRecordES olderPeopleHealthCheckRecord = visitDetailService.getOlderPeopleHealthCheckRecord(followupId, followupProject);
            return success( "获取老人随访服务随访成功!",  olderPeopleHealthCheckRecord);
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("保存新生儿家庭访视记录")
    @RequestMapping(value = "/saveNewbornFamilyVisitRecord", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Envelop saveNewbornFamilyVisitRecord(@ApiParam(name = "followupId", value = "随访记录ID")
                                                   @RequestParam(value = "followupId", required = true) String followupId,
                                                   @ApiParam(name = "followupProject", value = "随访项目")
                                                   @RequestParam(value = "followupProject", required = false) String followupProject,
                                                   @ApiParam(name = "newbornFamilyVisitRecordData", value = "新生儿家庭访视记录")
                                                   @RequestParam(value = "newbornFamilyVisitRecordData", required = true) String newbornFamilyVisitRecordData) {
        try {
            visitDetailService.saveNewbornFamilyVisitRecord(followupId, followupProject, newbornFamilyVisitRecordData, getUID());
            return success( "保存新生儿家庭访视记录成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("获取新生儿家庭访视记录")
    @RequestMapping(value = "/getNewbornFamilyVisitRecord", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ObserverRequired
    public Envelop getNewbornFamilyVisitRecord(@ApiParam(name = "followupId", value = "随访记录ID")
                                                  @RequestParam(value = "followupId", required = true) String followupId,
                                                  @ApiParam(name = "followupProject", value = "随访项目")
                                                  @RequestParam(value = "followupProject", required = false) String followupProject) {
        try {
            NewbornFamilyVisitRecordES newbornFamilyVisitRecordES = visitDetailService.getNewbornFamilyVisitRecord(followupId, followupProject);
            return success( "获取新生儿家庭访视记录成功!", newbornFamilyVisitRecordES);
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("获取上次填写内容")
    @RequestMapping(value = "/getLastVisitRecord", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public Envelop getLastVisitRecord(@ApiParam(name = "patientCode", value = "居民code")
                                         @RequestParam(value = "patientCode", required = true) String patientCode,
                                         @ApiParam(name = "followupClass", value = "随访类别(5.产后 6.新生儿 7.严重精神病 8.80岁以上老人 9.肺结核)")
                                         @RequestParam(value = "followupClass") String followupClass) {
        try {
            JSONObject jsonObject = visitDetailService.getLastVisitRecord(patientCode, followupClass);
            return success("获取上次随访记录成功!", jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("保存慢性妇科炎症日常随访")
    @RequestMapping(value = "/saveGynecologicalInflammationDaily", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Envelop saveGynecologicalInflammationDaily(@ApiParam(name = "followupId", value = "随访记录ID")
                                                         @RequestParam(value = "followupId", required = true) String followupId,
                                                     @ApiParam(name = "jsonData", value = "随访表单数据", defaultValue = "{\"followup\":{\"followupDate\":\"2020-03-17\"},\"content\":{\"referralHospital\":\"2\",\"hospitalOrg\":\"\",\"hospitalOrgName\":\"医院\",\"illnessBetter\":\"1\",\"currentStatus\":\"2\",\"followClass\":\"1\"}}")
                                                   @RequestParam(value = "jsonData", required = true) String jsonData) {
        try {
            return success("保存慢性妇科炎症日常随访成功!",  visitDetailService.saveGynecologicalInflammationDaily(followupId, jsonData, getUID()));
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("获取慢性妇科炎症日常随访")
    @RequestMapping(value = "/getGynecologicalInflammationDaily", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ObserverRequired
    public Envelop getGynecologicalInflammationDaily(@ApiParam(name = "followupId", value = "随访记录ID")
                                              @RequestParam(value = "followupId", required = true) String followupId) {
        try {
            JSONObject jsonObject = visitDetailService.getGynecologicalInflammationDaily(followupId);
            return success("获取慢性妇科炎症日常随访成功!",  jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    /**
     * type:
     * BreastFollowup //4.慢性乳腺疾病日常随访
     * CerebralApoplexyFollowup //7.脑卒中日常随访
     * CoronaryFollowup//1.冠心病日常随访
     * FattyLiverFollowUp//8.脂肪肝日常随访
     * NephropathyFollowup//5.慢性肾病日常随访
     * ProstateFollowup//3.慢性前列腺疾病日常随访
     * @param followupId
     * @param type
     * @return
     */
    @ApiOperation("获取随访病种日常随访")
    @RequestMapping(value = "/selectFollowupDiseaseById", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ObserverRequired
    public Envelop selectFollowupDiseaseById(@ApiParam(name = "followupId", value = "随访记录ID")
                                                    @RequestParam(value = "followupId", required = true) String followupId,
                                                    @ApiParam(name = "type", value = "病种类型")
                                                    @RequestParam(value = "type", required = true) String type) {
        try {
            JSONObject jsonObject = visitDetailService.selectFollowupDiseaseById(followupId,type);
            return success( "获取随访病种日常随访成功!", jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    /**
     *
     * type:
     * BreastFollowup //4.慢性乳腺疾病日常随访
     * CerebralApoplexyFollowup //7.脑卒中日常随访
     * CoronaryFollowup//1.冠心病日常随访
     * FattyLiverFollowUp//8.脂肪肝日常随访
     * NephropathyFollowup//5.慢性肾病日常随访
     * ProstateFollowup//3.慢性前列腺疾病日常随访
     *
     * @param followupId
     * @param jsonData
     * @param type
     * @return
     */
    @ApiOperation("保存各类病种日常随访")
    @RequestMapping(value = "/saveFollowupDiseaseArchives", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Envelop saveFollowupDiseaseArchives(@ApiParam(name = "followupId", value = "随访记录ID")
                                                     @RequestParam(value = "followupId", required = true) String followupId,
                                                     @ApiParam(name = "jsonData", value = "随访表单数据", defaultValue = "{\"followup\":{\"followupDate\":\"2020-03-17\"},\"content\":{\"referralHospital\":\"2\",\"hospitalOrg\":\"\",\"hospitalOrgName\":\"医院\",\"illnessBetter\":\"1\",\"currentStatus\":\"2\",\"followClass\":\"1\"}}")
                                                     @RequestParam(value = "jsonData", required = true) String jsonData,
                                                     @ApiParam(name = "type", value = "随访记录类型")
                                                         @RequestParam(value = "type", required = true) String type) {
        try {
            visitDetailService.saveFollowupDiseaseArchives(followupId, jsonData, getUID(),type);
            return success( "保存日常随访成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("保存慢性妇科炎症随访档案")
    @RequestMapping(value = "/saveGynecologicalInflammationFollowupArchives", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Envelop saveGynecologicalInflammationFollowupArchives(@ApiParam(name = "followupId", value = "随访记录ID")
                                                     @RequestParam(value = "followupId", required = true) String followupId,
                                                     @ApiParam(name = "jsonData", value = "随访表单数据", defaultValue = "{\"followup\":{\"followupDate\":\"2020-03-17\"},\"content\":{\"referralHospital\":\"2\",\"hospitalOrg\":\"\",\"hospitalOrgName\":\"医院\",\"illnessBetter\":\"1\",\"currentStatus\":\"2\",\"followClass\":\"1\"}}")
                                                     @RequestParam(value = "jsonData", required = true) String jsonData) {
        try {
            return success( "保存慢性妇科炎症随访档案成功!", visitDetailService.saveGynecologicalInflammationFollowupArchives(followupId, jsonData, getUID()));
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("获取慢性妇科炎症随访档案")
    @RequestMapping(value = "/getGynecologicalInflammationFollowupArchives", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ObserverRequired
    public Envelop getGynecologicalInflammationFollowupArchives(@ApiParam(name = "followupId", value = "随访记录ID")
                                                    @RequestParam(value = "followupId", required = true) String followupId) {
        try {
            JSONObject jsonObject = visitDetailService.getGynecologicalInflammationFollowupArchives(followupId);
            return success("获取慢性妇科炎症随访档案成功!",jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("保存慢性阻塞性肺病--首次问卷")
    @RequestMapping(value = "/saveCOPDFirstTimeQuestionnaire", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Envelop saveCOPDFirstTimeQuestionnaire(@ApiParam(name = "followupId", value = "随访记录ID")
                                                     @RequestParam(value = "followupId", required = true) String followupId,
                                                     @ApiParam(name = "jsonData", value = "随访表单数据")
                                                     @RequestParam(value = "jsonData", required = true) String jsonData) {
        try {
            return success( "保存慢性阻塞性肺病--首次问卷成功!", visitDetailService.saveCOPDFirstTimeQuestionnaire(followupId, jsonData, getUID()));
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("获取慢性阻塞性肺病--首次问卷")
    @RequestMapping(value = "/getCOPDFirstTimeQuestionnaire", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ObserverRequired
    public Envelop getCOPDFirstTimeQuestionnaire(@ApiParam(name = "followupId", value = "随访记录ID")
                                                    @RequestParam(value = "followupId", required = true) String followupId) {
        try {
            JSONObject jsonObject = visitDetailService.getCOPDFirstTimeQuestionnaire(followupId);
            return success("获取慢性阻塞性肺病--首次问卷成功!",  jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("保存慢性阻塞性肺病--日常随访")
    @RequestMapping(value = "/saveCOPDDailyFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public Envelop saveCOPDDailyFollowup(@ApiParam(name = "followupId", value = "随访记录ID")
                                                 @RequestParam(value = "followupId", required = true) String followupId,
                                                 @ApiParam(name = "jsonData", value = "随访表单数据")
                                                 @RequestParam(value = "jsonData", required = true) String jsonData) {
        try {
            return success( "保存慢性阻塞性肺病--日常随访成功!", visitDetailService.saveCOPDDailyFollowup(followupId, jsonData, getUID()));
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
    @ApiOperation("获取慢性阻塞性肺病--日常随访")
    @RequestMapping(value = "/getCOPDDailyFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    @ObserverRequired
    public Envelop getCOPDDailyFollowup(@ApiParam(name = "followupId", value = "随访记录ID")
                                                @RequestParam(value = "followupId", required = true) String followupId) {
        try {
            JSONObject jsonObject = visitDetailService.getCOPDDailyFollowup(followupId);
            return success( "获取慢性阻塞性肺病--日常随访成功!",  jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return failedException(e);
        }
    }
}

+ 48 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/message/DoctorMessageController.java

@ -0,0 +1,48 @@
package com.yihu.rehabilitation.controller.message;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.rehabilitation.service.message.RehabilitationMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping(value = "/doctor/message",produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
@Api(description = "医生端-消息")
public class DoctorMessageController extends EnvelopRestEndpoint {
    @Autowired
    private RehabilitationMessageService messageService;
    /**
     * 设置待办消息已处理
     *
     * @param id
     * @param type
     * @return
     */
    @RequestMapping(value = "setSpecialistOver",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("设置待办消息已处理" )
    public Envelop setSpecialistOver(@ApiParam(name = "id",value = "消息id")
                                    @RequestParam(value = "id")String  id,
                                     @ApiParam(name = "type",value = "消息类型")
                                    @RequestParam(value = "type")Integer type) {
        try {
            return success( "获取消息总数成功!",  messageService.setSpecialistOver(id,type));
        } catch (Exception e) {
          e.printStackTrace();
            return failed( e.getMessage());
        }
    }
}

+ 348 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/controller/patient/PatientRehabilitationManageController.java

@ -0,0 +1,348 @@
package com.yihu.rehabilitation.controller.patient;
/**
 * Created by 刘文彬 on 2018/8/31.
 */
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.specialist.rehabilitation.PatientMedicalRecordsDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationOperateRecordsDO;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.rehabilitation.RehabilitationRequestMapping;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.rehabilitation.service.RehabilitationManageService;
import com.yihu.rehabilitation.service.RehabilitationPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * Created by 刘文彬 on 2018/8/30.
 */
@RestController
@RequestMapping(value =  RehabilitationRequestMapping.PatientRehabilitationManage.Perfix, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "居民端-康复管理")
public class PatientRehabilitationManageController extends EnvelopRestEndpoint {
    @Autowired
    private RehabilitationManageService rehabilitationManageService;
    @Autowired
    private ImUtil imUtill;
    @Autowired
    private RehabilitationPlanService rehabilitationPlanService;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @RequestMapping(value = RehabilitationRequestMapping.PatientRehabilitationManage.patientRehabilitationDetail, method = RequestMethod.GET)
    @ApiOperation("康复管理-微信端-居民详情页")
    public ObjEnvelop patientRehabilitationDetail(){
        try {
            return  rehabilitationManageService.patientRehabilitationDetail(getUID());
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.PatientRehabilitationManage.calendarPlanDetail, method = RequestMethod.GET)
    @ApiOperation("康复管理-康复计划按日历展示")
    public ObjEnvelop calendarPlanDetail(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                     @RequestParam(value = "executeStartTime", required = true)String executeStartTime,
                                     @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                     @RequestParam(value = "executeEndTime", required = true)String executeEndTime,
                                     @ApiParam(name = "planId", value = "计划id", required = true)
                                     @RequestParam(value = "planId", required = true)String planId,
                                     @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、健康教育,3、复诊,4、随访)", required = false)
                                     @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                     @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                     @RequestParam(value = "status", required = false)Integer status){
        try {
            return rehabilitationManageService.calendarPlanDetail(executeStartTime,executeEndTime,planId,searchTask,status,null,null);
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.PatientRehabilitationManage.serviceDoctorList, method = RequestMethod.GET)
    @ApiOperation("康复管理-微信端居民服务医生列表")
    public ObjEnvelop serviceDoctorList(){
        try {
            return rehabilitationManageService.serviceDoctorList(getUID());
        } catch (Exception e) {
           e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.PatientRehabilitationManage.calendarPlanDetailList, method = RequestMethod.GET)
    @ApiOperation("康复管理-康复计划按列表展示")
    public ObjEnvelop calendarPlanDetailList(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                         @RequestParam(value = "executeStartTime", required = true)String executeStartTime,
                                         @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                                         @RequestParam(value = "executeEndTime", required = true)String executeEndTime,
                                         @ApiParam(name = "planId", value = "计划id", required = true)
                                         @RequestParam(value = "planId", required = true)String planId,
                                         @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、健康教育,3、复诊,4、随访)", required = false)
                                         @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                         @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                         @RequestParam(value = "status", required = false)Integer status){
        try {
            return rehabilitationManageService.calendarPlanDetailList( planId, searchTask, status, null, executeStartTime, executeEndTime, null);
        } catch (Exception e) {
           e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.PatientRehabilitationManage.sendMessageIm, method = RequestMethod.POST)
    @ApiOperation("康复管理-扫描二维码发送消息")
    public Envelop sendMessageIm(@ApiParam(name = "sendId", value = "发送者id")@RequestParam(value = "sendId", required = true)String sendId,
                                @ApiParam(name = "receiverId", value = "接受者id", required = true)@RequestParam(value = "receiverId", required = true)String receiverId,
                                @ApiParam(name = "content", value = "内容", required = true)@RequestParam(value = "content", required = true)String content){
        try {
            imUtill.sendMessage(sendId,receiverId,"1",content);
            return success("发送成功");
        } catch (Exception e) {
            e.printStackTrace();
            return failed("发送失败");
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.PatientRehabilitationManage.checkAfterQrCode, method = RequestMethod.POST)
    @ApiOperation("康复管理-居民扫码后验证是否是关联的居民扫码")
    public ObjEnvelop checkAfterQrCode(@ApiParam(name = "planDetailId", value = "康复计划项目明细ID")@RequestParam(value = "planDetailId", required = true)String planDetailId,
                                    @ApiParam(name = "patientCode", value = "居民端登录的居民code")@RequestParam(value = "patientCode", required = true)String patientCode){
        try {
            return ObjEnvelop.getSuccess( "操作成功",rehabilitationPlanService.checkAfterQrCode(planDetailId,patientCode));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.PatientRehabilitationManage.saveRehabilitationOperateRecord, method = RequestMethod.POST)
    @ApiOperation("康复管理-新增operateRecord")
    public MixEnvelop saveRehabilitationOperateRecord(@ApiParam(name = "dataJson", value = "实体json",defaultValue = "{\"rehabilitationDetailId\":\"402803f6657f195301657f4fbd3c0001\",\"patientCode\":\"00\",\"patientName\":\"11\",\"doctorCode\":\"22\",\"doctorName\":\"33\",\"node\":\"jjjjjj\",\"relationRecordType\":\"4\",\"relation_record_code\":\"55\",\"relationRecordImg\":\"666666\",\"status\":\"0\"}")@RequestParam(value = "dataJson", required = true)String dataJson){
        try {
            JSONObject json = new JSONObject(dataJson);
            if(json.has("patientCode")){
                BasePatientDO patient = basePatientDao.findById(json.get("patientCode")+"");
                json.put("patientName",patient!=null?patient.getName():"");
            }
            if(json.has("doctorCode")){
                BaseDoctorDO doctor = baseDoctorDao.findById(json.get("doctorCode")+"");
                json.put("doctorName",doctor!=null?doctor.getName():"");
            }
            RehabilitationOperateRecordsDO rehabilitationOperateRecordsDO= toEntity(json.toString(), RehabilitationOperateRecordsDO.class);
            return MixEnvelop.getSuccess(SpecialistMapping.api_success,rehabilitationPlanService.saveRehabilitationRecord(rehabilitationOperateRecordsDO));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.PatientRehabilitationManage.recentPlanDetailRecord, method = RequestMethod.GET)
    @ApiOperation("康复管理-近期康复相关记录")
    public ObjEnvelop recentPlanDetailRecord(@ApiParam(name = "patientCode", value = "居民code", required = false)
                                         @RequestParam(value = "patientCode", required = false)String patientCode,
                                         @ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                         @RequestParam(value = "startTime", required = false)String startTime,
                                         @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                         @RequestParam(value = "endTime", required = false)String endTime,
                                         @ApiParam(name = "page", value = "第几页,从1开始", required = true)
                                         @RequestParam(value = "page", required = false,defaultValue = "1")Integer page,
                                         @ApiParam(name = "pageSize", value = "每页分页大小", required = true)
                                         @RequestParam(value = "pageSize", required = false,defaultValue = "10")Integer pageSize){
        try {
            if(!StringUtils.isNotEmpty(patientCode)){
                patientCode = getUID();
            }
            return rehabilitationManageService.recentPlanDetailRecord(patientCode,startTime,endTime,page,pageSize);
        } catch (Exception e) {
           e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.PatientRehabilitationManage.serviceItemList, method = RequestMethod.GET)
    @ApiOperation("康复管理-多个康复计划服务项目内容列表")
    public ObjEnvelop serviceItemList(@ApiParam(name = "planDetailIds", value = "康复计划多个服务项目id(多个‘,’分隔)", required = true)
                                  @RequestParam(value = "planDetailIds", required = true)String planDetailIds){
        try {
            return rehabilitationManageService.serviceItemList(planDetailIds,null);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.PatientRehabilitationManage.serviceItem, method = RequestMethod.GET)
    @ApiOperation("康复管理-康复计划服务项目确认详情页")
    public ObjEnvelop serviceItem(@ApiParam(name = "planDetailId", value = "康复计划服务项目id", required = true)
                              @RequestParam(value = "planDetailId", required = true)String planDetailId){
        try {
            return rehabilitationManageService.serviceItem(planDetailId,null,"");
        } catch (Exception e) {
           e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = RehabilitationRequestMapping.PatientRehabilitationManage.planSchedule, method = RequestMethod.GET)
    @ApiOperation("康复管理-计划总进度")
    public ObjEnvelop planSchedule(@ApiParam(name = "planId", value = "计划id", required = true)
                               @RequestParam(value = "planId", required = true)String planId,
                               @ApiParam(name = "patientCode", value = "居民code", required = false)
                               @RequestParam(value = "patientCode", required = false)String patientCode){
        try {
            if(!StringUtils.isNotEmpty(patientCode)){
                patientCode = getUID();
            }
            return rehabilitationManageService.planSchedule(planId,patientCode);
        } catch (Exception e) {
           e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value =RehabilitationRequestMapping.PatientRehabilitationManage.updatePatientImgById, method = RequestMethod.POST)
    @ApiOperation("更新康复计划居民签名照/证件照")
    public Envelop updatePatientImgById(@ApiParam(name = "planId", value = "康复计划id", required = true)
                                       @RequestParam(value = "planId")String planId,
                                       @ApiParam(name = "patientImg", value = "居民签名/证件照地址")
                                       @RequestParam(value = "patientImg")String patientImg){
        try {
            rehabilitationPlanService.updatePatientImgById(planId, patientImg);
            return success("操作成功");
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }
    @GetMapping(value = RehabilitationRequestMapping.PatientRehabilitationManage.getServiceItemsAfterStop)
    @ApiOperation(value = "康复管理-中止康复计划结算项目清单")
    public ObjEnvelop getServiceItemsAfterStop(@ApiParam(name = "planId", value = "康复计划id", required = true)
                                               @RequestParam(value = "planId", required = true)String planId){
        try {
            return ObjEnvelop.getSuccess("操作成功",rehabilitationManageService.getServiceItemsAfterStop(planId));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @RequestMapping(value = "selectPlanDetailByPlanId", method = RequestMethod.GET)
    @ApiOperation("康复管理-查看其它服务计划")
    public Envelop selectPlanDetailByPlanId(@ApiParam(name = "planId", value = "计划id", required = true)
                                           @RequestParam(value = "planId", required = true) String planId,
                                           @ApiParam(name = "planDetailId", value = "计划详情id", required = true)
                                           @RequestParam(value = "planDetailId", required = true) String planDetailId,
                                           @ApiParam(name = "itemId", value = "服务项目code", required = true)
                                           @RequestParam(value = "itemId", required = true) String itemId) {
        try {
            return success( "请求成功!",rehabilitationManageService.selectPlanDetailByPlan(planId,planDetailId,itemId));
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "请求失败");
        }
    }
    @RequestMapping(value = "selectPlanByPatient", method = RequestMethod.GET)
    @ApiOperation("康复管理-根据居民code查找康复计划")
    public Envelop calendarPlanDetailItems(@ApiParam(name = "patient", value = "居民code", required = false)
                                           @RequestParam(value = "patient", required = false)String patient,
                                           @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                           @RequestParam(value = "status", required = false)Integer status,
                                           @ApiParam(name = "planId", value = "计划id", required = false)
                                           @RequestParam(value = "planId", required = false)String planId){
        try {
            List<Map<String,Object>> result = rehabilitationManageService.selectPlanByPatient(patient,status,planId,"");
            return success("获取成功",  result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "请求失败");
        }
    }
    @RequestMapping(value = "calendarPlanDetailItems", method = RequestMethod.GET)
    @ApiOperation("康复管理-康复计划服务项目按列表展示")
    public Envelop calendarPlanDetailItems(@ApiParam(name = "executeStartTime", value = "日历开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                           @RequestParam(value = "executeStartTime", required = false)String executeStartTime,
                                           @ApiParam(name = "executeEndTime", value = "日历结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = false)
                                           @RequestParam(value = "executeEndTime", required = false)String executeEndTime,
                                           @ApiParam(name = "planId", value = "计划id", required = true)
                                           @RequestParam(value = "planId", required = true)String planId,
                                           @ApiParam(name = "searchTask", value = "快速查找任务:(1、我的任务,2、健康教育,3、健康指导,4、随访,5、复诊)", required = false)
                                           @RequestParam(value = "searchTask", required = false)Integer searchTask,
                                           @ApiParam(name = "doctorCode", value = "医生code(专科医生、家庭医生)", required = false)
                                           @RequestParam(value = "doctorCode", required = false)String doctorCode,
                                           @ApiParam(name = "status", value = "任务状态(0未完成,1已完成,2已预约)", required = false)
                                           @RequestParam(value = "status", required = false)Integer status){
        try {
            List<Map<String,Object>> result = rehabilitationManageService.calendarPlanDetailItems(executeStartTime,executeEndTime,planId,searchTask,status,"");
            return success( "获取成功", result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "请求失败");
        }
    }
    @RequestMapping(value = "selectByMedicalCode", method = RequestMethod.GET)
    @ApiOperation("获取医院病历")
    public Envelop selectByMedicalCode(@ApiParam(name = "medical", value = "住院code", required = true)
                                       @RequestParam(value = "medical", required = true)String medical){
        try {
            List<PatientMedicalRecordsDO> result = rehabilitationManageService.selectByMedicalCode(medical);
            try {
                String sql = "UPDATE `wlyy_patient_medical_records_rehabilitation` SET `patient_read_status`='1' WHERE (`code`='"+medical+"') ";
                jdbcTemplate.update(sql);
            }catch (Exception e){
                e.printStackTrace();
            }
            return success("操作成功", result);
        } catch (Exception e) {
            return failed( "请求失败");
        }
    }
}

+ 21 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/dao/FrequencyDao.java

@ -0,0 +1,21 @@
package com.yihu.rehabilitation.dao;
import com.yihu.jw.entity.hospital.doctor.Frequency;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by wzn54 on 2019/1/17.
 */
public interface FrequencyDao extends PagingAndSortingRepository<Frequency, Long>, JpaSpecificationExecutor<Frequency> {
    @Query("select f from Frequency f where  f.del=1")
    List<Frequency> findByDel();
    @Query("select f from Frequency  f where f.del=1 and f.code=?1 ")
    Frequency findByCode(String code);
}

+ 0 - 0
svr/svr-rehabilitation/src/main/java/com/yihu/rehabilitation/dao/GuidanceMessageLogDao.java


Some files were not shown because too many files changed in this diff