Browse Source

Merge branch '2.0' of http://27.154.233.186:10080/Amoy2/wlyy2.0 into 2.0

 Conflicts:
	business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
wangzhinan 1 year ago
parent
commit
5e33556fed
90 changed files with 12741 additions and 558 deletions
  1. 434 346
      business/base-service/src/main/java/com/yihu/jw/complaint/BaseComplaintService.java
  2. 25 0
      business/base-service/src/main/java/com/yihu/jw/device/dao/DevicePatientHealthIndexDao.java
  3. 21 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  4. 9 2
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/team/WlyyPatientLabelDao.java
  5. 13 0
      business/base-service/src/main/java/com/yihu/jw/label/WlyyPatientLabelLogDao.java
  6. 18 16
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  7. 60 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/PatientHealthGuidanceDao.java
  8. 8 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/PatientHealthGuidanceRecordDao.java
  9. 16 0
      business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java
  10. 9 0
      business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java
  11. 63 0
      business/im-service/src/main/java/com/yihu/jw/im/util/SendPatientUtil.java
  12. 173 0
      common/common-entity/src/db/2024.sql
  13. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/complaint/BaseComplaintDO.java
  14. 11 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java
  15. 53 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/PatientDoctorRelationEntity.java
  16. 44 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceHealthyInfoMapping.java
  17. 1 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/label/WlyyPatientLabelDO.java
  18. 79 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/label/WlyyPatientLabelLogDO.java
  19. 12 1
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/article/KnowledgeCategoryDO.java
  20. 145 0
      common/common-entity/src/main/java/com/yihu/jw/entity/patient/PatientHealthGuidance.java
  21. 135 0
      common/common-entity/src/main/java/com/yihu/jw/entity/patient/PatientHealthGuidanceRecord.java
  22. 223 0
      common/common-entity/src/main/java/com/yihu/jw/entity/scheme/DoctorSchemeBloodPressure.java
  23. 269 0
      common/common-entity/src/main/java/com/yihu/jw/entity/scheme/DoctorSchemeBloodSugger.java
  24. 62 0
      common/common-entity/src/main/java/com/yihu/jw/entity/scheme/DoctorSwitch.java
  25. 86 0
      common/common-entity/src/main/java/com/yihu/jw/entity/scheme/PatientSchemeList.java
  26. 108 0
      common/common-entity/src/main/java/com/yihu/jw/entity/scheme/TrackPatient.java
  27. 52 0
      common/common-entity/src/main/java/com/yihu/jw/entity/scheme/vo/DoctorSchemeBloodPressureVO.java
  28. 52 0
      common/common-entity/src/main/java/com/yihu/jw/entity/scheme/vo/DoctorSchemeBloodSuggerVO.java
  29. 102 0
      common/common-entity/src/main/java/com/yihu/jw/entity/template/DoctorGuidanceTemp.java
  30. 86 0
      common/common-entity/src/main/java/com/yihu/jw/entity/template/DoctorGuidanceTempLabel.java
  31. 91 0
      common/common-entity/src/main/java/com/yihu/jw/entity/template/DoctorTeamGuidanceDetail.java
  32. 130 0
      common/common-entity/src/main/java/com/yihu/jw/entity/template/DoctorTeamGuidanceTemplate.java
  33. 212 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/conf/SystemConf.java
  34. 447 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/patient/PatientVO.java
  35. 73 0
      common/common-util/src/main/java/com/yihu/jw/util/SqlReplaceService.java
  36. 39 0
      common/common-util/src/main/java/com/yihu/jw/util/common/CommonUtil.java
  37. 3 0
      starter/mysql-starter/src/main/java/com/yihu/jw/mysql/query/BaseJpaService.java
  38. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/patient/BasePatientEndpoint.java
  39. 1 1
      svr/svr-base/src/main/resources/bootstrap.yml
  40. 8 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceIntegratedController.java
  41. 10 2
      svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/service/ResourceBrowseService.java
  42. 169 146
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/complaint/BaseComplaintEndPoint.java
  43. 38 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java
  44. 0 6
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/team/DoctorTeamEndpoint.java
  45. 3 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeCategoryService.java
  46. 1 1
      svr/svr-internet-hospital/src/main/resources/bootstrap.yml
  47. 108 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/LabelController.java
  48. 143 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/service/LabelService.java
  49. 3 1
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/service/ConsultService.java
  50. 1 1
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/WlyyDoorServiceOrderService.java
  51. 414 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/ChronicDiseaseController.java
  52. 19 13
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/DoctorHealthController.java
  53. 601 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/DoctorHealthEduArticleController.java
  54. 299 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/DoctorHealthGuidanceController.java
  55. 4 1
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientDeviceController.java
  56. 14 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/dao/DoctorSwitchDao.java
  57. 31 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/dao/DoctoreSchemeBloodPressureDao.java
  58. 33 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/dao/DoctrorSchemeBloodSuggerDao.java
  59. 1 1
      business/base-service/src/main/java/com/yihu/jw/health/FoodCompDao.java
  60. 1 1
      business/base-service/src/main/java/com/yihu/jw/health/MedicinesDao.java
  61. 2 2
      business/base-service/src/main/java/com/yihu/jw/health/PatientHealthRecordDietDao.java
  62. 2 2
      business/base-service/src/main/java/com/yihu/jw/health/PatientHealthRecordMedicationDao.java
  63. 1 1
      business/base-service/src/main/java/com/yihu/jw/health/PatientHealthRecordSportsDao.java
  64. 30 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/dao/PatientSchemeListDao.java
  65. 1 1
      business/base-service/src/main/java/com/yihu/jw/health/SportsDao.java
  66. 1 1
      business/base-service/src/main/java/com/yihu/jw/health/SportsTypeDao.java
  67. 30 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/dao/TrackPatientDao.java
  68. 1 1
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/MedicinesService.java
  69. 437 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientHealthGuidanceService.java
  70. 1 1
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientHealthRecordService.java
  71. 2 2
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/SportsService.java
  72. 2225 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/scheme/DoctorSchemeService.java
  73. 2403 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/vo/MedicalDetailVo.java
  74. 44 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/vo/MedicalQvo.java
  75. 46 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/vo/MedicalVo.java
  76. 2 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationInfoService.java
  77. 14 4
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationManageService.java
  78. 59 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/controller/DoctorFeldsherTemplateController.java
  79. 235 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/controller/DoctorGuidanceTempController.java
  80. 131 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/controller/DoctorGuidanceTempLabelController.java
  81. 202 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/controller/DoctorRegistrationTempController.java
  82. 323 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/controller/DoctorTeamGuidanceController.java
  83. 47 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/dao/DoctorGuidanceTempDao.java
  84. 38 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/dao/DoctorGuidanceTempLabelDao.java
  85. 22 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/dao/DoctorTeamGuidanceDetailDao.java
  86. 83 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/dao/DoctorTeamGuidanceTemplateDao.java
  87. 140 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/service/DoctorFeldsherTemplateService.java
  88. 87 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/service/DoctorGuidanceTempLableService.java
  89. 304 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/service/DoctorGuidanceTempService.java
  90. 560 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/service/DoctorTeamGuidanceService.java

+ 434 - 346
business/base-service/src/main/java/com/yihu/jw/complaint/BaseComplaintService.java

@ -26,6 +26,7 @@ import com.yihu.jw.wechat.enterprise.EnterpriseService;
import org.apache.commons.lang3.StringUtils;
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;
@ -59,6 +60,8 @@ public class BaseComplaintService {
    private EnterpriseService enterpriseService;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Value("${wechat.id}")
    private String wxId;
    @Value("${wechat.flag}")
@ -88,7 +91,7 @@ public class BaseComplaintService {
            baseComplaintDictDao.save(baseComplaintDictDO);
        }
        List<BaseComplaintDoctorDO> baseComplaintDoctorDOs = baseComplaintDoctorDao.findbyComplaintId(id);
        for (BaseComplaintDoctorDO baseComplaintDoctorDO:baseComplaintDoctorDOs){
        for (BaseComplaintDoctorDO baseComplaintDoctorDO : baseComplaintDoctorDOs) {
            baseComplaintDoctorDO.setIsDel("0");
        }
        baseComplaintDoctorDao.saveAll(baseComplaintDoctorDOs);
@ -116,28 +119,28 @@ public class BaseComplaintService {
    @Transactional
    public void createOrUpdateComplainDoctor(String id, String complaintId, String doctorList) throws Exception {
        JSONArray jsonArray = JSON.parseArray(doctorList);
        for (int i=0;i<jsonArray.size();i++){
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject jsonObject = jsonArray.getJSONObject(i);
            String doctor = jsonObject.getString("doctor");
            String deptCode = jsonObject.getString("deptCode");
            String deptName = "";
            String doctorName = "";
            BaseComplaintDoctorDO preDoctor= baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
//            BaseComplaintDoctorDO preDoctor = baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
            BaseDoctorDO baseDoctorDO = baseDoctorDao.findByIdAndDel(doctor);
            List<BaseDoctorRoleDO> baseDoctorRoleDOs = baseDoctorRoleDao.findByDoctorCode(doctor);
            if (baseDoctorRoleDOs==null||baseDoctorRoleDOs.size()==0){
            if (baseDoctorRoleDOs == null || baseDoctorRoleDOs.size() == 0) {
                BaseDoctorRoleDO baseDoctorRoleDO = new BaseDoctorRoleDO();
                baseDoctorRoleDO.setDoctorCode(doctor);
                baseDoctorRoleDO.setRoleCode("specialist");
                baseDoctorRoleDao.save(baseDoctorRoleDO);
            }else if (baseDoctorRoleDOs!=null){
                Boolean addRoleFlag=true;//是否为对应医生添加专科医生角色表示 true即为添加
                for (BaseDoctorRoleDO baseDoctorRoleDO :baseDoctorRoleDOs){
                    if (baseDoctorRoleDO.getRoleCode().equalsIgnoreCase("specialist")){
                        addRoleFlag=false;
            } else if (baseDoctorRoleDOs != null) {
                Boolean addRoleFlag = true;//是否为对应医生添加专科医生角色表示 true即为添加
                for (BaseDoctorRoleDO baseDoctorRoleDO : baseDoctorRoleDOs) {
                    if (baseDoctorRoleDO.getRoleCode().equalsIgnoreCase("specialist")) {
                        addRoleFlag = false;
                    }
                }
                if(addRoleFlag){
                if (addRoleFlag) {
                    BaseDoctorRoleDO baseDoctorRoleDO = new BaseDoctorRoleDO();
                    baseDoctorRoleDO.setDoctorCode(doctor);
                    baseDoctorRoleDO.setRoleCode("specialist");
@ -147,9 +150,9 @@ public class BaseComplaintService {
            if (null != baseDoctorDO) {
                doctorName = baseDoctorDO.getName();
            }
            if (preDoctor!=null){
                throw new Exception("医生"+doctorName+"已有负责的投诉类型");
            }
//            if (preDoctor!=null){
//                throw new Exception("医生"+doctorName+"已有负责的投诉类型");
//            }
            List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDeptCodeDoctorCode(deptCode, doctor);
            if (baseDoctorHospitalDO != null && baseDoctorHospitalDO.size() > 0) {
                deptName = baseDoctorHospitalDO.get(0).getDeptName();
@ -167,6 +170,7 @@ public class BaseComplaintService {
            }
        }
    }
    //删除管理医生
    public BaseComplaintDoctorDO deleteDoctorComplain(String id) {
        BaseComplaintDoctorDO baseComplaintDoctorDO = baseComplaintDoctorDao.findByDelAndId(id);
@ -178,7 +182,7 @@ public class BaseComplaintService {
        return baseComplaintDoctorDO;
    }
    public MixEnvelop findComplaintDoctor(String doctor,String doctorName, String deptName, String complaintType, Integer page, Integer pageSize) {
    public MixEnvelop findComplaintDoctor(String doctor, String doctorName, String deptName, String complaintType, Integer page, Integer pageSize) {
        String sql = "select t.id as \"id\"," +
                " t.complaint_id as \"complaintId\"," +
                " t.doctor as \"doctor\"," +
@ -216,30 +220,74 @@ public class BaseComplaintService {
        return mixEnvelop;
    }
    /**
     * 去重医生
     */
    public MixEnvelop findComplaintDoctorNew(String doctor, String doctorName, String deptName, String complaintType, Integer page, Integer pageSize) {
        String sql = "select " +
                " t.doctor as \"doctor\"," +
                " t.doctor_name as \"doctorName\"," +
                " t.dept as \"dept\"," +
                " t.dept_name as \"deptName\"," +
                " t.is_del as \"isDel\"," +
                " t.create_time as \"createTime\"," +
                " t.update_time as \"updateTime\"," +
                " d.photo as \"photo\"," +
                " group_concat(b.name)  as \"name\" " +
                " from base_complaint_doctor t " +
                " INNER join base_complaint_dict b on t.complaint_id=b.id " +
                " INNER join base_doctor d on t.doctor=d.id" +
                "  where t.is_del='1'";
        if (StringUtils.isNoneBlank(doctorName)) {
            sql += " and t.doctor_name like '%" + doctorName + "%'";
        }
        if (StringUtils.isNoneBlank(deptName)) {
            sql += " and t.dept_name like '%" + deptName + "%'";
        }
        if (StringUtils.isNoneBlank(complaintType)) {
            sql += " and t.complaint_id = '" + complaintType + "'";
        }
        if (StringUtils.isNoneBlank(doctor)) {
            sql += " and t.doctor = '" + doctor + "'";
        }
        sql += "order by t.create_time desc";
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, page, pageSize);
        List<Map<String, Object>> listCount = hibenateUtils.createSQLQuery(sql);
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setTotalCount(listCount == null ? 0 : listCount.size());
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setDetailModelList(list);
        return mixEnvelop;
    }
    public BaseComplaintDoctorDO findOneDoctorComplain(String id) {
        BaseComplaintDoctorDO baseComplaintDoctorDO = baseComplaintDoctorDao.findByDelAndId(id);
        return baseComplaintDoctorDO;
    }
    /*
     * 患者举报接口
     * */
    public BaseComplaintDO patiemtComplaint(String json) throws Exception{
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO= wlyyHospitalSysDictDao.findById("complaintOpenControl").orElse(null);
        if (wlyyHospitalSysDictDO!=null){
            if (!"1".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
    public BaseComplaintDO patiemtComplaint(String json) throws Exception {
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("complaintOpenControl").orElse(null);
        if (wlyyHospitalSysDictDO != null) {
            if (!"1".equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())) {
                throw new Exception("投诉通道已关闭");
            }
        }else {
        } else {
            throw new Exception("投诉通道已关闭");
        }
        BaseComplaintDO baseComplaintDO =objectMapper.readValue(json,BaseComplaintDO.class);
        BaseComplaintDO baseComplaintDO = objectMapper.readValue(json, BaseComplaintDO.class);
        BaseComplaintDictDO baseComplaintDictDO = baseComplaintDictDao.findByIdAndIsDel(baseComplaintDO.getComplaintId());
        if (baseComplaintDictDO!=null){
        if (baseComplaintDictDO != null) {
            baseComplaintDO.setComplaintName(baseComplaintDictDO.getName());
        }
        if (StringUtils.isNoneBlank(baseComplaintDO.getVisitDept())){
            DictHospitalDeptDO dictHospitalDeptDO=dictHospitalDeptDao.findByCode(baseComplaintDO.getVisitDept());
            if (dictHospitalDeptDO!=null){
        if (StringUtils.isNoneBlank(baseComplaintDO.getVisitDept())) {
            DictHospitalDeptDO dictHospitalDeptDO = dictHospitalDeptDao.findByCode(baseComplaintDO.getVisitDept());
            if (dictHospitalDeptDO != null) {
                baseComplaintDO.setVisitDeptName(dictHospitalDeptDO.getName());
            }
        }
@ -256,7 +304,7 @@ public class BaseComplaintService {
        baseComplaintDO.setStatus("0");
        baseComplaintDO.setCreateTime(new Date());
        baseComplaintDO.setDefaultdoctor("defalutDoctor");
        baseComplaintDO=  baseComplaintDao.save(baseComplaintDO);
        baseComplaintDO = baseComplaintDao.save(baseComplaintDO);
        BaseComplaintOperateLogDO baseComplaintOperateLogDO = new BaseComplaintOperateLogDO();
        baseComplaintOperateLogDO.setOperateFrom(baseComplaintDO.getPatient());
        baseComplaintOperateLogDO.setStatus("0");
@ -265,25 +313,26 @@ public class BaseComplaintService {
        baseComplaintOperateLogDO.setCreateTime(new Date());
        baseComplaintOperateDao.save(baseComplaintOperateLogDO);
        try {
            List<BaseComplaintDoctorDO> doctorList=baseComplaintDoctorDao.findbyComplaintId(baseComplaintDO.getComplaintId());
            for (BaseComplaintDoctorDO baseComplaintDoctorDO:doctorList){
                String url="https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/complaint/detail?id="+baseComplaintDO.getId();
                enterpriseService.sendTWMesByDoctor("zsyy",baseComplaintDoctorDO.getDoctor(),"投诉反馈","您收到一条投诉反馈,点击查看。",url);
            List<BaseComplaintDoctorDO> doctorList = baseComplaintDoctorDao.findbyComplaintId(baseComplaintDO.getComplaintId());
            for (BaseComplaintDoctorDO baseComplaintDoctorDO : doctorList) {
                String url = "https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/complaint/detail?id=" + baseComplaintDO.getId();
                enterpriseService.sendTWMesByDoctor("zsyy", baseComplaintDoctorDO.getDoctor(), "投诉反馈", "您收到一条投诉反馈,点击查看。", url);
            }
        }catch (Exception e){
        } catch (Exception e) {
        }
       return baseComplaintDao.save(baseComplaintDO);
        return baseComplaintDao.save(baseComplaintDO);
    }
    /*
     * 医生转交
     * */
    public BaseComplaintDO passTo(String id,String complaintId,String doctor,String operator,String reason){
    public BaseComplaintDO passTo(String id, String complaintId, String doctor, String operator, String reason) {
        BaseComplaintDO baseComplaintDO = baseComplaintDao.findById(id).orElse(null);
        BaseComplaintOperateLogDO baseComplaintOperateLogDO = new BaseComplaintOperateLogDO();
        String doctorName="";
        String complaitTypeName="";
        if (null!=baseComplaintDO){
        String doctorName = "";
        String complaitTypeName = "";
        if (null != baseComplaintDO) {
            baseComplaintOperateLogDO.setOperateFrom(operator);
            baseComplaintOperateLogDO.setReason(reason);
            baseComplaintOperateLogDO.setOperateTo(doctor);
@ -300,35 +349,36 @@ public class BaseComplaintService {
                baseComplaintDO.setAcceptorName(doctorName);
            }
            baseComplaintDO.setAcceptor(doctor);*/
            if ("1".equalsIgnoreCase(baseComplaintDO.getStatus())){
            if ("1".equalsIgnoreCase(baseComplaintDO.getStatus())) {
                baseComplaintDO.setStatus("0");
            }
            baseComplaintDO.setDefaultdoctor(doctor);
            baseComplaintDO.setComplaintId(complaintId);
            baseComplaintDO.setPassto(doctor);
            BaseComplaintDictDO baseComplaintDictDO = baseComplaintDictDao.findByIdAndIsDel(complaintId);
            if (baseComplaintDictDO!=null){
                complaitTypeName=baseComplaintDictDO.getName();
            if (baseComplaintDictDO != null) {
                complaitTypeName = baseComplaintDictDO.getName();
                baseComplaintDO.setComplaintName(complaitTypeName);
            }
            baseComplaintDO= baseComplaintDao.save(baseComplaintDO);
            baseComplaintDO = baseComplaintDao.save(baseComplaintDO);
            try {
                /*List<BaseComplaintDoctorDO> doctorList=baseComplaintDoctorDao.findbyComplaintId(baseComplaintDO.getComplaintId());
                for (BaseComplaintDoctorDO baseComplaintDoctorDO:doctorList)*/
                String url="https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/complaint/detail?id="+baseComplaintDO.getId();
                enterpriseService.sendTWMesByDoctor("zsyy",doctor,"投诉反馈","您收到一条投诉反馈,点击查看。",url);
                String url = "https://hlwyy.xmzsh.com/hlwyy/ims-app-web/#/complaint/detail?id=" + baseComplaintDO.getId();
                enterpriseService.sendTWMesByDoctor("zsyy", doctor, "投诉反馈", "您收到一条投诉反馈,点击查看。", url);
            }catch (Exception e){
            } catch (Exception e) {
            }
            return baseComplaintDO;
        }
        return null;
    }
    //接受投诉
    public BaseComplaintDO doctorAccept(String id,String doctor) throws Exception{
    public BaseComplaintDO doctorAccept(String id, String doctor) throws Exception {
        BaseComplaintDO baseComplaintDO = baseComplaintDao.findById(id).orElse(null);
        if (baseComplaintDO!=null){
        if (baseComplaintDO != null) {
            baseComplaintDO.setStatus("1");
            BaseDoctorDO baseDoctorDO = baseDoctorDao.findByIdAndDel(doctor);
            if (null != baseDoctorDO) {
@ -352,10 +402,11 @@ public class BaseComplaintService {
        }*/
        return baseComplaintDO;
    }
    //反馈投诉
    public BaseComplaintDO dealComplaint(String id,String operator,String content,String imgUrl ,String deptCode) throws  Exception{
    public BaseComplaintDO dealComplaint(String id, String operator, String content, String imgUrl, String deptCode) throws Exception {
        BaseComplaintDO baseComplaintDO = baseComplaintDao.findById(id).orElse(null);
        if (baseComplaintDO!=null){
        if (baseComplaintDO != null) {
            baseComplaintDO.setDealTime(new Date());
            baseComplaintDO.setFeedBack(content);
            baseComplaintDO.setFeedImg(imgUrl);
@ -388,14 +439,14 @@ public class BaseComplaintService {
    }
    //查询投诉列表
    public MixEnvelop findComplaintList(String role,String doctor,String status,String patientName,String patientId,String keyWord,String complaintId,
                                  String startTime,String endTime,Integer page ,Integer pageSize){
    public MixEnvelop findComplaintList(String role, String doctor, String status, String patientName, String patientId, String keyWord, String complaintId,
                                        String startTime, String endTime, Integer page, Integer pageSize) {
        MixEnvelop mixEnvelop = new MixEnvelop();
        Boolean queryAll=false;
        if ("admin".equalsIgnoreCase(role)){
            queryAll=true;
        Boolean queryAll = false;
        if ("admin".equalsIgnoreCase(role)) {
            queryAll = true;
        }
        String sql="select DISTINCT t.id as \"id\"," +
        String sql = "select DISTINCT t.id as \"id\"," +
                " t.complaint_id as \"complaintId\"," +
                " t.complaint_name as \"complaintName\"," +
                " t.complaint_content as \"complaintContent\"," +
@ -427,18 +478,34 @@ public class BaseComplaintService {
                " t.passto as \"passto\"," +
                " t.acceptor_name as \"acceptorName\"" +
                " from base_complaint t  " +
                " left join base_patient b on t.patient=b.id " ;
        sql+=" left join base_complaint_operate_log g on t.id=g.relation_code where t.is_del='1 '";
        if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
            sql+=" and  g.status='3' ";
                " left join base_patient b on t.patient=b.id ";
        sql += " left join base_complaint_operate_log g on t.id=g.relation_code where t.is_del='1' ";
        //排除撤销的
        sql += " and t.status<>'-1' ";
        if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
            sql += " and  g.status='3' ";
        }/*else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){
            sql+=" and  g.status='1' ";
        }
        else if (StringUtils.isNoneBlank(status)&&"2".equalsIgnoreCase(status)){
            sql+=" and  g.status='2' ";
        }*/
        if (!queryAll){
            BaseComplaintDoctorDO baseComplaintDoctorDO= baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
        boolean flag = false;
        if (!queryAll) {
            //原本的
//            BaseComplaintDoctorDO baseComplaintDoctorDO = baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
            String complaint = "";
            String dbSql = " SELECT t.complaint_id from base_complaint_doctor t where t.is_del='1' and t.doctor='" + doctor + "'";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(dbSql);
            if (!list.isEmpty()) {
                for (Map<String, Object> map : list) {
                    if (String.valueOf(map.get("complaint_id")).equalsIgnoreCase("808080eb7a194099017a1943fa820004")) {
                        complaint = String.valueOf(map.get("complaint_id"));
                    }
                }
            }
            /*List<BaseComplaintOperateLogDO> logList =baseComplaintOperateDao.findbyOperateFrom(doctor);
            String types= "";
            if (logList!=null&&logList.size()>0){
@ -450,100 +517,100 @@ public class BaseComplaintService {
                    }
                }
            }*/
            String complaint="";
            if (baseComplaintDoctorDO!=null){
                if (baseComplaintDoctorDO.getComplaintId().equalsIgnoreCase("808080eb7a194099017a1943fa820004")){
                    complaint=baseComplaintDoctorDO.getComplaintId();
                }
            }
//            if (baseComplaintDoctorDO != null) {
//                if (baseComplaintDoctorDO.getComplaintId().equalsIgnoreCase("808080eb7a194099017a1943fa820004")) {
//                    complaint = baseComplaintDoctorDO.getComplaintId();
//                }
//            }
            //complaint=complaint+","+types;
            if (StringUtils.isNoneBlank(complaint)){
                if (!StringUtils.isNoneBlank(status)){
                    sql+=" and t.status !='-1'";
                    sql+=" and (t.defaultdoctor ='defalutDoctor' or t.defaultdoctor='"+doctor+"')";
            if (StringUtils.isNoneBlank(complaint)) {
                if (!StringUtils.isNoneBlank(status)) {
                    sql += " and t.status !='-1'";
                    sql += " and (t.defaultdoctor ='defalutDoctor' or t.defaultdoctor='" + doctor + "')";
                }
                if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
                    sql+=" and g.operate_from='"+doctor+"'";
                }else {
                    sql+=" and t.complaint_id='"+complaint+"'";
                if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
                    sql += " and g.operate_from='" + doctor + "'";
                } else {
                    sql += " and t.complaint_id='" + complaint + "'";
                }
                if (!StringUtils.isNoneBlank(status)){
                    sql+=" or (g.operate_from='"+doctor+"'  and g.status='3')";
                if (!StringUtils.isNoneBlank(status)) {
                    sql += " or (g.operate_from='" + doctor + "'  and g.status='3')";
                }
                if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
                    sql+=" and g.operate_from='"+doctor+"'";
                }else if (StringUtils.isNoneBlank(status)&&"0".equalsIgnoreCase(status)){
                    sql+=" and t.status='0' and (t.passto='"+doctor+"' or t.passto is null )";
                } else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){
                    sql+="  and t.status='1' and t.acceptor='"+doctor+"' ";
                } else if (StringUtils.isNoneBlank(status)&&"2".equalsIgnoreCase(status)){
                    sql+=" and t.status='2' and t.operator='"+doctor+"' ";
                if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
                    sql += " and g.operate_from='" + doctor + "'";
                } else if (StringUtils.isNoneBlank(status) && "0".equalsIgnoreCase(status)) {
                    sql += " and t.status='0' and (t.passto='" + doctor + "' or t.passto is null )";
                } else if (StringUtils.isNoneBlank(status) && "1".equalsIgnoreCase(status)) {
                    sql += "  and t.status='1' and t.acceptor='" + doctor + "' ";
                } else if (StringUtils.isNoneBlank(status) && "2".equalsIgnoreCase(status)) {
                    sql += " and t.status='2' and t.operator='" + doctor + "' ";
                }
                //sql+=" and t.complaint_id in ('"+complaint.replace(",","','")+"')";
            }else {
                if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
                    sql+=" and g.operate_from='"+doctor+"'";
                }else if (StringUtils.isNoneBlank(status)&&"0".equalsIgnoreCase(status)){
                    sql+=" and t.status='0' and t.passto='"+doctor+"'";
                } else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){
                    sql+="  and t.status='1' and t.acceptor='"+doctor+"' ";
                } else if (StringUtils.isNoneBlank(status)&&"2".equalsIgnoreCase(status)){
                    sql+=" and t.status='2' and t.operator='"+doctor+"' ";
            } else {
                if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
                    sql += " and g.operate_from='" + doctor + "'";
                } else if (StringUtils.isNoneBlank(status) && "0".equalsIgnoreCase(status)) {
                    sql += " and t.status='0' and t.passto='" + doctor + "'";
                } else if (StringUtils.isNoneBlank(status) && "1".equalsIgnoreCase(status)) {
                    sql += "  and t.status='1' and t.acceptor='" + doctor + "' ";
                } else if (StringUtils.isNoneBlank(status) && "2".equalsIgnoreCase(status)) {
                    sql += " and t.status='2' and t.operator='" + doctor + "' ";
                } else {
                    sql+=" and t.id IN (select col.relation_code from base_complaint_operate_log col where col.operate_to = '"+doctor+"'  )";
                    sql += " and t.id IN (select col.relation_code from base_complaint_operate_log col where col.operate_to = '" + doctor + "'  )";
                }
            }
            //complaint=complaint+","+types;
        }else {
            if (StringUtils.isNoneBlank(complaintId)){
        } else {
            if (StringUtils.isNoneBlank(complaintId)) {
                //sql+=" and t.complaint_id in ('"+complaint.replace(",","','")+"')";
                sql+=" and t.complaint_id='"+complaintId+"'";
                sql += " and t.complaint_id='" + complaintId + "'";
            }
            if (StringUtils.isNoneBlank(status)){
                sql+=" and t.status ='"+status+"'";
            if (StringUtils.isNoneBlank(status)) {
                sql += " and t.status ='" + status + "'";
            }
        }
        if (StringUtils.isNoneBlank(patientName)){
            sql+=" and t.patient_name like '%"+patientName+"%'";
        if (StringUtils.isNoneBlank(patientName)) {
            sql += " and t.patient_name like '%" + patientName + "%'";
        }
        if (StringUtils.isNoneBlank(patientId)){
            sql+=" and t.patient ='"+patientId+"'";
        if (StringUtils.isNoneBlank(patientId)) {
            sql += " and t.patient ='" + patientId + "'";
        }
        if (StringUtils.isNoneBlank(keyWord)){
            sql+=" and (t.patient_idcard like '%"+keyWord+"%' or t.patient_name like '%"+keyWord+"%')";
        if (StringUtils.isNoneBlank(keyWord)) {
            sql += " and (t.patient_idcard like '%" + keyWord + "%' or t.patient_name like '%" + keyWord + "%')";
        }
        if (StringUtils.isNotBlank(startTime)){
            if("xm_ykyy_wx".equals(wxId)){
                if (flag){
                    sql+=" and t.create_time > '"+startTime+"'";
                }else {
                    sql+=" and t.create_time > to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
        if (StringUtils.isNotBlank(startTime)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag) {
                    sql += " and t.create_time > '" + startTime + "'";
                } else {
                    sql += " and t.create_time > to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
                }
            }else{
                sql+=" and t.create_time > '"+startTime+"'";
            } else {
                sql += " and t.create_time > '" + startTime + "'";
            }
        }
        if (StringUtils.isNotBlank(endTime)){
            if("xm_ykyy_wx".equals(wxId)){
                if (flag){
                    sql+="  and t.create_time<='" + endTime + "'";
                }else {
                    sql+="  and t.create_time<= to_date('" + endTime + "','yyyy-mm-dd hh24:mi:ss')";
        if (StringUtils.isNotBlank(endTime)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag) {
                    sql += "  and t.create_time<='" + endTime + "'";
                } else {
                    sql += "  and t.create_time<= to_date('" + endTime + "','yyyy-mm-dd hh24:mi:ss')";
                }
            }else{
                sql+="  and t.create_time<='" + endTime + "'";
            } else {
                sql += "  and t.create_time<='" + endTime + "'";
            }
        }
        sql+=" order by t.create_time desc ";
        System.out.println("sql"+sql);
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,page,pageSize);
        String sqlcount = "SELECT COUNT(1) AS \"total\" FROM ("+sql+") q";
        sql += " order by t.create_time desc ";
        System.out.println("sql" + sql);
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, page, pageSize);
        String sqlcount = "SELECT COUNT(1) AS \"total\" FROM (" + sql + ") q";
        Long count = 0L;
        List<Map<String,Object>> total = hibenateUtils.createSQLQuery(sqlcount);
        if(total!=null){
        List<Map<String, Object>> total = hibenateUtils.createSQLQuery(sqlcount);
        if (total != null) {
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            count = hibenateUtils.objTransformLong(total.get(0).get("total"));
        }
@ -553,32 +620,30 @@ public class BaseComplaintService {
        mixEnvelop.setCurrPage(page);
        return mixEnvelop;
    }
    public BaseComplaintDO  findOnePaitentComplaint(String id){
    public BaseComplaintDO findOnePaitentComplaint(String id) {
        BaseComplaintDO baseComplaintDO = baseComplaintDao.findById(id).orElse(null);
        BasePatientDO basePatientDO=basePatientDao.findById(baseComplaintDO.getPatient()).orElse(null);
        if (null!=basePatientDO){
        BasePatientDO basePatientDO = basePatientDao.findById(baseComplaintDO.getPatient()).orElse(null);
        if (null != basePatientDO) {
            baseComplaintDO.setMobile(basePatientDO.getMobile());
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO =wlyyHospitalSysDictDao.findById("latestFeedBackTime").orElse(null);
        Integer timeOut=15;
        if (wlyyHospitalSysDictDO!=null){
            timeOut =Integer.parseInt(wlyyHospitalSysDictDO.getDictValue());
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("latestFeedBackTime").orElse(null);
        Integer timeOut = 15;
        if (wlyyHospitalSysDictDO != null) {
            timeOut = Integer.parseInt(wlyyHospitalSysDictDO.getDictValue());
        }
        long latestDate=baseComplaintDO.getCreateTime().getTime()+timeOut*24*60*60*1000;
        baseComplaintDO.setLatestFeedTime( (new Date(latestDate)));
        baseComplaintDO.setVisitTypeName(baseComplaintDO.getVisitType().equalsIgnoreCase("1")?"门诊":"住院");
        long latestDate = baseComplaintDO.getCreateTime().getTime() + timeOut * 24 * 60 * 60 * 1000;
        baseComplaintDO.setLatestFeedTime((new Date(latestDate)));
        baseComplaintDO.setVisitTypeName(baseComplaintDO.getVisitType().equalsIgnoreCase("1") ? "门诊" : "住院");
        return baseComplaintDO;
    }
    //查询投诉列表
    public MixEnvelop findPatientComplaintList(String status,String patientName,String patientId,
                                        String startTime,String endTime,String complaintType,Integer page ,Integer pageSize){
    public MixEnvelop findPatientComplaintList(String status, String patientName, String patientId,
                                               String startTime, String endTime, String complaintType, Integer page, Integer pageSize) {
        MixEnvelop mixEnvelop = new MixEnvelop();
        String sql="select t.id as \"id\"," +
        String sql = "select t.id as \"id\"," +
                " t.complaint_id as \"complaintId\"," +
                " t.complaint_name as \"complaintName\"," +
                " t.complaint_content as \"complaintContent\"," +
@ -611,46 +676,46 @@ public class BaseComplaintService {
                " from base_complaint t " +
                " left join base_patient b on t.patient=b.id" +
                " where t.is_del='1'";
        if (StringUtils.isNoneBlank(status)){
            sql+=" and t.status ='"+status+"'";
        if (StringUtils.isNoneBlank(status)) {
            sql += " and t.status ='" + status + "'";
        }
        if (StringUtils.isNoneBlank(patientName)){
            sql+=" and t.patient_name like '%"+patientName+"%'";
        if (StringUtils.isNoneBlank(patientName)) {
            sql += " and t.patient_name like '%" + patientName + "%'";
        }
        if (StringUtils.isNoneBlank(patientId)){
            sql+=" and t.patient ='"+patientId+"'";
        if (StringUtils.isNoneBlank(patientId)) {
            sql += " and t.patient ='" + patientId + "'";
        }
        if (StringUtils.isNoneBlank(complaintType)){
            sql+=" and t.complaint_id ='"+complaintType+"'";
        if (StringUtils.isNoneBlank(complaintType)) {
            sql += " and t.complaint_id ='" + complaintType + "'";
        }
        if (StringUtils.isNotBlank(startTime)){
            if("xm_ykyy_wx".equals(wxId)){
                if (flag){
                    sql+=" and t.create_time > '"+startTime+"'";
                }else {
                    sql+=" and t.create_time > to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
        if (StringUtils.isNotBlank(startTime)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag) {
                    sql += " and t.create_time > '" + startTime + "'";
                } else {
                    sql += " and t.create_time > to_date('" + startTime + "', 'yyyy-mm-dd hh24:mi:ss') ";
                }
            }else{
                sql+=" and t.create_time > '"+startTime+"'";
            } else {
                sql += " and t.create_time > '" + startTime + "'";
            }
        }
        if (StringUtils.isNotBlank(endTime)){
            if("xm_ykyy_wx".equals(wxId)){
                if (flag){
                    sql+="  and t.create_time<='" + endTime + "'";
                }else {
                    sql+="  and t.create_time<= to_date('" + endTime + "','yyyy-mm-dd hh24:mi:ss')";
        if (StringUtils.isNotBlank(endTime)) {
            if ("xm_ykyy_wx".equals(wxId)) {
                if (flag) {
                    sql += "  and t.create_time<='" + endTime + "'";
                } else {
                    sql += "  and t.create_time<= to_date('" + endTime + "','yyyy-mm-dd hh24:mi:ss')";
                }
            }else{
                sql+="  and t.create_time<='" + endTime + "'";
            } else {
                sql += "  and t.create_time<='" + endTime + "'";
            }
        }
        sql+=" order by t.create_time desc ";
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,page,pageSize);
        String sqlcount = "SELECT COUNT(1) AS \"total\" FROM ("+sql+") q";
        sql += " order by t.create_time desc ";
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, page, pageSize);
        String sqlcount = "SELECT COUNT(1) AS \"total\" FROM (" + sql + ") q";
        Long count = 0L;
        List<Map<String,Object>> total = hibenateUtils.createSQLQuery(sqlcount);
        if(total!=null){
        List<Map<String, Object>> total = hibenateUtils.createSQLQuery(sqlcount);
        if (total != null) {
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            count = hibenateUtils.objTransformLong(total.get(0).get("total"));
        }
@ -660,153 +725,168 @@ public class BaseComplaintService {
        mixEnvelop.setCurrPage(page);
        return mixEnvelop;
    }
    /*
    * 查询投诉数量*/
    public Map<String,Object> findComplaintCount(String doctor,String role){
        BaseComplaintDoctorDO baseComplaintDoctorDO=baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
        Integer complaints=0;
        Integer recieve=0;
        Integer deal=0;
        Integer cacel=0;
        Integer passto=0;
        Integer total=0;
        if (baseComplaintDoctorDO!=null){
                Boolean queryAll=false;
                if ("admin".equalsIgnoreCase(role)){
                    queryAll=true;
     * 查询投诉数量*/
    public Map<String, Object> findComplaintCount(String doctor, String role) {
//        BaseComplaintDoctorDO baseComplaintDoctorDO = baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
        String sql = " SELECT t.complaint_id from base_complaint_doctor t where t.is_del='1' and t.doctor='" + doctor + "'";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        Integer complaints = 0;
        Integer recieve = 0;
        Integer deal = 0;
        Integer cacel = 0;
        Integer passto = 0;
        Integer total = 0;
        boolean flag = false;
        System.out.println("数据==>" + JSON.toJSONString(list));
        if (list != null && list.size() > 0) {
            Boolean queryAll = false;
            if ("admin".equalsIgnoreCase(role)) {
                queryAll = true;
            }
            for (Map<String, Object> map : list) {
                String complaint_id = String.valueOf(map.get("complaint_id"));
                if ("808080eb7a194099017a1943fa820004".equalsIgnoreCase(complaint_id)) {
                    flag = true;
                }
                if (!queryAll){
                    if ("808080eb7a194099017a1943fa820004".equalsIgnoreCase(baseComplaintDoctorDO.getComplaintId())) {
                        complaints = getCountByStatus(doctor,"0",role);
                        recieve = getCountByStatus(doctor,"1",role);
                        deal = getCountByStatus(doctor,"2",role);
                        passto = getCountByPassto(doctor);
                        total = getCountByStatus(doctor,"",role);
                    }else{
                        complaints=getCountByStatus(doctor,"0",role);
                        recieve=getCountByStatus(doctor,"1",role);
                        deal=getCountByStatus(doctor,"2",role);
                        passto=getCountByPassto(doctor);
                        total=getCountByStatus(doctor,"",role);
                    }
                    //cacel=baseComplaintDao.getCountByStatusAndComplaintId("-1",baseComplaintDoctorDO.getComplaintId());
                }else {
                    complaints=baseComplaintDao.getCountByStatus("0");
                    recieve=baseComplaintDao.getCountByStatus("1");
                    deal=baseComplaintDao.getCountByStatus("2");
                    cacel=baseComplaintDao.getCountByStatus("-1");
                    total = complaints+recieve+deal+cacel;
            }
            if (!queryAll) {
//                if ("808080eb7a194099017a1943fa820004".equalsIgnoreCase(baseComplaintDoctorDO.getComplaintId())) {
                if (flag) {
                    complaints = getCountByStatus(doctor, "0", role);
                    recieve = getCountByStatus(doctor, "1", role);
                    deal = getCountByStatus(doctor, "2", role);
                    passto = getCountByPassto(doctor);
                    total = getCountByStatus(doctor, "", role);
                } else {
                    complaints = getCountByStatus(doctor, "0", role);
                    recieve = getCountByStatus(doctor, "1", role);
                    deal = getCountByStatus(doctor, "2", role);
                    passto = getCountByPassto(doctor);
                    total = getCountByStatus(doctor, "", role);
                }
                //cacel=baseComplaintDao.getCountByStatusAndComplaintId("-1",baseComplaintDoctorDO.getComplaintId());
            } else {
                complaints = baseComplaintDao.getCountByStatus("0");
                recieve = baseComplaintDao.getCountByStatus("1");
                deal = baseComplaintDao.getCountByStatus("2");
                cacel = baseComplaintDao.getCountByStatus("-1");
                total = complaints + recieve + deal + cacel;
            }
        }
        Map map=new HashMap();
        map.put("complaints",complaints);
        map.put("recieve",recieve);
        map.put("deal",deal);
        map.put("passto",passto);
        map.put("cacel",cacel);
        map.put("total",total);
        Map map = new HashMap();
        map.put("complaints", complaints);
        map.put("recieve", recieve);
        map.put("deal", deal);
        map.put("passto", passto);
        map.put("cacel", cacel);
        map.put("total", total);
        return map;
    }
    public Integer getCountByPassto(String doctor){
        String sql ="select count(1) as \"total\" from (select  DISTINCT t.id   from base_complaint t left join base_complaint_operate_log b" +
    public Integer getCountByPassto(String doctor) {
        String sql = "select count(1) as \"total\" from (select  DISTINCT t.id   from base_complaint t left join base_complaint_operate_log b" +
                " on t.id=b.relation_code where t.is_del='1' and b.status='3'";
        if (StringUtils.isNoneBlank(doctor)){
            sql+=" and b.operate_from='"+doctor+"'";
        if (StringUtils.isNoneBlank(doctor)) {
            sql += " and b.operate_from='" + doctor + "'";
        }
        sql+=") m";
        List<Map<String,Object>> listcount=hibenateUtils.createSQLQuery(sql);
        Integer count=0;
        if (listcount!=null&&listcount.size()>0){
            count=Integer.valueOf(listcount.get(0).get("total").toString());
        sql += ") m";
        List<Map<String, Object>> listcount = hibenateUtils.createSQLQuery(sql);
        Integer count = 0;
        if (listcount != null && listcount.size() > 0) {
            count = Integer.valueOf(listcount.get(0).get("total").toString());
        }
        return count;
    }
    public Integer getCountByStatus(String doctor,String status,String role){
        Boolean queryAll=false;
        if ("admin".equalsIgnoreCase(role)){
            queryAll=true;
    public Integer getCountByStatus(String doctor, String status, String role) {
        Boolean queryAll = false;
        if ("admin".equalsIgnoreCase(role)) {
            queryAll = true;
        }
        String sql="select count(1)  as \"count\" from (select DISTINCT t.id  "+
        String sql = "select count(1)  as \"count\" from (select DISTINCT t.id  " +
                "  from base_complaint t  " +
                " left join base_patient b on t.patient=b.id " ;
                " left join base_patient b on t.patient=b.id ";
        sql+=" left join base_complaint_operate_log g on t.id=g.relation_code where t.is_del='1' ";
        if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
            sql+="  and g.status='3' ";
        sql += " left join base_complaint_operate_log g on t.id=g.relation_code where t.is_del='1' ";
        if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
            sql += "  and g.status='3' ";
        } /*else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){
            sql+=" and  g.status='1' ";
        }
        else if (StringUtils.isNoneBlank(status)&&"2".equalsIgnoreCase(status)){
            sql+=" and  g.status='2' ";
        }*/
        if (!queryAll){
            BaseComplaintDoctorDO baseComplaintDoctorDO= baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
            /*List<BaseComplaintOperateLogDO> logList =baseComplaintOperateDao.findbyOperateFrom(doctor);
            String types= "";
            if (logList!=null&&logList.size()>0){
                for (int i=0;i<logList.size();i++){
                    if (i==logList.size()-1){
                        types+=logList.get(i).getComplaintTo();
                    }else {
                        types+=logList.get(i).getComplaintTo()+",";
        if (!queryAll) {
            //原本的
//            BaseComplaintDoctorDO baseComplaintDoctorDO = baseComplaintDoctorDao.findbyDoctorAndDel(doctor);
            List<Map<String, Object>> list = getComplaintList(doctor);
            String complaint = "";
            if (!list.isEmpty()) {
                for (Map<String, Object> map : list) {
                    String complaint_id = String.valueOf(map.get("complaint_id"));
                    if (complaint_id.equalsIgnoreCase("808080eb7a194099017a1943fa820004")) {
                        complaint = complaint_id;
                    }
                }
            }*/
            String complaint="";
            if (baseComplaintDoctorDO!=null){
                if (baseComplaintDoctorDO.getComplaintId().equalsIgnoreCase("808080eb7a194099017a1943fa820004")){
                    complaint=baseComplaintDoctorDO.getComplaintId();
                }
            }
            //complaint=complaint+","+types;
            if (StringUtils.isNoneBlank(complaint)){
                if (!StringUtils.isNoneBlank(status)){
                    sql+=" and t.status !='-1'";
                    sql+=" and (t.defaultdoctor ='defalutDoctor' or t.defaultdoctor='"+doctor+"')";
            if (StringUtils.isNoneBlank(complaint)) {
                if (!StringUtils.isNoneBlank(status)) {
                    sql += " and t.status !='-1'";
                    sql += " and (t.defaultdoctor ='defalutDoctor' or t.defaultdoctor='" + doctor + "')";
                }
                if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
                    sql+=" and g.operate_from='"+doctor+"'";
                }else {
                    sql+=" and t.complaint_id='"+complaint+"'";
                if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
                    sql += " and g.operate_from='" + doctor + "'";
                } else {
                    sql += " and t.complaint_id='" + complaint + "'";
                }
               if (!StringUtils.isNoneBlank(status)){
                   sql+=" or (g.operate_from='"+doctor+"'  and g.status='3')";
                if (!StringUtils.isNoneBlank(status)) {
                    sql += " or (g.operate_from='" + doctor + "'  and g.status='3')";
                }
                if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
                    sql+=" and g.operate_from='"+doctor+"'";
                }else if (StringUtils.isNoneBlank(status)&&"0".equalsIgnoreCase(status)){
                    sql+=" and t.status='0' and (t.passto='"+doctor+"' or t.passto is null )";
                } else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){
                    sql+="  and t.status='1' and t.acceptor='"+doctor+"' ";
                } else if (StringUtils.isNoneBlank(status)&&"2".equalsIgnoreCase(status)){
                    sql+=" and t.status='2' and t.operator='"+doctor+"' ";
                if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
                    sql += " and g.operate_from='" + doctor + "'";
                } else if (StringUtils.isNoneBlank(status) && "0".equalsIgnoreCase(status)) {
                    sql += " and t.status='0' and (t.passto='" + doctor + "' or t.passto is null )";
                } else if (StringUtils.isNoneBlank(status) && "1".equalsIgnoreCase(status)) {
                    sql += "  and t.status='1' and t.acceptor='" + doctor + "' ";
                } else if (StringUtils.isNoneBlank(status) && "2".equalsIgnoreCase(status)) {
                    sql += " and t.status='2' and t.operator='" + doctor + "' ";
                }
                //sql+=" and t.complaint_id in ('"+complaint.replace(",","','")+"')";
            }else {
                if (StringUtils.isNoneBlank(status)&&"3".equalsIgnoreCase(status)){
                    sql+=" and g.operate_from='"+doctor+"'";
                }else if (StringUtils.isNoneBlank(status)&&"0".equalsIgnoreCase(status)){
                    sql+=" and t.status='0' and t.passto='"+doctor+"'";
                } else if (StringUtils.isNoneBlank(status)&&"1".equalsIgnoreCase(status)){
                    sql+="  and t.status='1' and t.acceptor='"+doctor+"' ";
                } else if (StringUtils.isNoneBlank(status)&&"2".equalsIgnoreCase(status)){
                    sql+=" and t.status='2' and t.operator='"+doctor+"' ";
            } else {
                if (StringUtils.isNoneBlank(status) && "3".equalsIgnoreCase(status)) {
                    sql += " and g.operate_from='" + doctor + "'";
                } else if (StringUtils.isNoneBlank(status) && "0".equalsIgnoreCase(status)) {
                    sql += " and t.status='0' and t.passto='" + doctor + "'";
                } else if (StringUtils.isNoneBlank(status) && "1".equalsIgnoreCase(status)) {
                    sql += "  and t.status='1' and t.acceptor='" + doctor + "' ";
                } else if (StringUtils.isNoneBlank(status) && "2".equalsIgnoreCase(status)) {
                    sql += " and t.status='2' and t.operator='" + doctor + "' ";
                } else {
                    sql+=" and t.id IN (select col.relation_code from base_complaint_operate_log col where col.operate_to = '"+doctor+"'  )";
                    sql += " and t.id IN (select col.relation_code from base_complaint_operate_log col where col.operate_to = '" + doctor + "'  )";
                }
            }
            if (!StringUtils.isNoneBlank(status)){
                sql+=" and t.status !='-1'";
            if (!StringUtils.isNoneBlank(status)) {
                sql += " and t.status !='-1'";
            }
            //complaint=complaint+","+types;
        }
        System.out.println("sql"+sql);
        System.out.println("sql" + sql);
        Integer count = 0;
        sql+=")g";
        List<Map<String,Object>> total = hibenateUtils.createSQLQuery(sql);
        if(total!=null&&total.size()>0){
        sql += ")g";
        List<Map<String, Object>> total = hibenateUtils.createSQLQuery(sql);
        if (total != null && total.size() > 0) {
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            count = Integer.valueOf(total.get(0).get("count").toString());
        }
@ -815,46 +895,48 @@ public class BaseComplaintService {
    /*
     * 查询投诉数量*/
    public Map<String,Object> findComplaintCountPatient(String patient){
        Integer complaints=0;
        Integer recieve=0;
        Integer deal=0;
        Integer cacel=0;
        complaints=baseComplaintDao.getCountByStatusByPatient("0",patient);
        recieve=baseComplaintDao.getCountByStatusByPatient("1",patient);
        deal=baseComplaintDao.getCountByStatusByPatient("2",patient);
        cacel=baseComplaintDao.getCountByStatusByPatient("-1",patient);
        Integer total = complaints+recieve+deal+cacel;
        Map map=new HashMap();
        map.put("complaints",complaints);
        map.put("recieve",recieve);
        map.put("deal",deal);
        map.put("cacel",cacel);
        map.put("total",total);
    public Map<String, Object> findComplaintCountPatient(String patient) {
        Integer complaints = 0;
        Integer recieve = 0;
        Integer deal = 0;
        Integer cacel = 0;
        complaints = baseComplaintDao.getCountByStatusByPatient("0", patient);
        recieve = baseComplaintDao.getCountByStatusByPatient("1", patient);
        deal = baseComplaintDao.getCountByStatusByPatient("2", patient);
        cacel = baseComplaintDao.getCountByStatusByPatient("-1", patient);
        Integer total = complaints + recieve + deal + cacel;
        Map map = new HashMap();
        map.put("complaints", complaints);
        map.put("recieve", recieve);
        map.put("deal", deal);
        map.put("cacel", cacel);
        map.put("total", total);
        return map;
    }
    public BaseComplaintDO  cancelPaitentComplaint(String id,String patient) throws  Exception{
    public BaseComplaintDO cancelPaitentComplaint(String id, String patient) throws Exception {
        BaseComplaintDO baseComplaintDO = baseComplaintDao.findById(id).orElse(null);
       if (baseComplaintDO!=null){
           if ("0".equalsIgnoreCase(baseComplaintDO.getStatus())){
               baseComplaintDO.setStatus("-1");
               baseComplaintDO=baseComplaintDao.save(baseComplaintDO);
               BaseComplaintOperateLogDO baseComplaintOperateLogDO = new BaseComplaintOperateLogDO();
               baseComplaintOperateLogDO.setOperateFrom(patient);
               baseComplaintOperateLogDO.setStatus("-1");
               baseComplaintOperateLogDO.setOperateType("居民撤销投诉");
               baseComplaintOperateLogDO.setRelationCode(baseComplaintDO.getId());
               baseComplaintOperateLogDO.setCreateTime(new Date());
               baseComplaintOperateDao.save(baseComplaintOperateLogDO);
           }else {
               throw new Exception("不允许撤销");
           }
       }
       return baseComplaintDO;
        if (baseComplaintDO != null) {
            if ("0".equalsIgnoreCase(baseComplaintDO.getStatus())) {
                baseComplaintDO.setStatus("-1");
                baseComplaintDO = baseComplaintDao.save(baseComplaintDO);
                BaseComplaintOperateLogDO baseComplaintOperateLogDO = new BaseComplaintOperateLogDO();
                baseComplaintOperateLogDO.setOperateFrom(patient);
                baseComplaintOperateLogDO.setStatus("-1");
                baseComplaintOperateLogDO.setOperateType("居民撤销投诉");
                baseComplaintOperateLogDO.setRelationCode(baseComplaintDO.getId());
                baseComplaintOperateLogDO.setCreateTime(new Date());
                baseComplaintOperateDao.save(baseComplaintOperateLogDO);
            } else {
                throw new Exception("不允许撤销");
            }
        }
        return baseComplaintDO;
    }
    public List<Map<String,Object>> findComplaintOperateLog(String complaintId){
        String sql ="select t.id as \"id\"," +
    public List<Map<String, Object>> findComplaintOperateLog(String complaintId) {
        String sql = "select t.id as \"id\"," +
                " p.name as \"complaintNameFrom\" ," +
                " n.name as \"complaintNameto\", " +
                " t.operate_from as \"operateFrom\" ," +
@ -868,51 +950,57 @@ public class BaseComplaintService {
                " from base_complaint_operate_log t left join base_complaint c" +
                " on t.relation_code=c.id" +
                " left join base_complaint_dict p on t.complaint_from= p.id" +
                " left join base_complaint_dict n on t.complaint_to=n.id where 1=1 " ;
        if (StringUtils.isNoneBlank(complaintId)){
            sql+=" and t.relation_code='"+complaintId+"'";
        }
        sql+=" order by t.create_time desc";
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
        List<WlyyHospitalSysDictDO> typeList=wlyyHospitalSysDictDao.findByDictName("complaintStatus");
        for (Map<String,Object> map:list){
            if (map.get("operateFrom")!=null){
                if (map.get("status")!=null){
                    for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:typeList){
                        if (map.get("status").toString().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){
                            map.put("operateType",wlyyHospitalSysDictDO.getDictValue());
                " left join base_complaint_dict n on t.complaint_to=n.id where 1=1 ";
        if (StringUtils.isNoneBlank(complaintId)) {
            sql += " and t.relation_code='" + complaintId + "'";
        }
        sql += " order by t.create_time desc";
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
        List<WlyyHospitalSysDictDO> typeList = wlyyHospitalSysDictDao.findByDictName("complaintStatus");
        for (Map<String, Object> map : list) {
            if (map.get("operateFrom") != null) {
                if (map.get("status") != null) {
                    for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO : typeList) {
                        if (map.get("status").toString().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())) {
                            map.put("operateType", wlyyHospitalSysDictDO.getDictValue());
                        }
                    }
                    if ("0".equalsIgnoreCase(map.get("status").toString())||"-1".equalsIgnoreCase(map.get("status").toString())){
                    if ("0".equalsIgnoreCase(map.get("status").toString()) || "-1".equalsIgnoreCase(map.get("status").toString())) {
                        BasePatientDO basePatientDO = basePatientDao.findById(map.get("operateFrom").toString()).orElse(null);
                        if (basePatientDO!=null){
                            map.put("operateFromName",basePatientDO.getName());
                        if (basePatientDO != null) {
                            map.put("operateFromName", basePatientDO.getName());
                        }
                    }else {
                        BaseDoctorDO baseDoctorDO= baseDoctorDao.findByIdAndDel(map.get("operateFrom").toString());
                        if (baseDoctorDO!=null){
                            map.put("operateFromName",baseDoctorDO.getName());
                    } else {
                        BaseDoctorDO baseDoctorDO = baseDoctorDao.findByIdAndDel(map.get("operateFrom").toString());
                        if (baseDoctorDO != null) {
                            map.put("operateFromName", baseDoctorDO.getName());
                        }
                        List<BaseDoctorHospitalDO> baseDoctorHospitalDO= baseDoctorHospitalDao.findByDoctorCode(map.get("operateFrom").toString());
                        if (baseDoctorHospitalDO!=null&&baseDoctorHospitalDO.size()>0){
                            map.put("operateFromDeptName",baseDoctorHospitalDO.get(0).getDeptName());
                        List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(map.get("operateFrom").toString());
                        if (baseDoctorHospitalDO != null && baseDoctorHospitalDO.size() > 0) {
                            map.put("operateFromDeptName", baseDoctorHospitalDO.get(0).getDeptName());
                        }
                    }
                }
            }
            if (map.get("operateTo")!=null){
                BaseDoctorDO baseDoctorDO= baseDoctorDao.findByIdAndDel(map.get("operateTo").toString());
                if (baseDoctorDO!=null){
                    map.put("operateToName",baseDoctorDO.getName());
            if (map.get("operateTo") != null) {
                BaseDoctorDO baseDoctorDO = baseDoctorDao.findByIdAndDel(map.get("operateTo").toString());
                if (baseDoctorDO != null) {
                    map.put("operateToName", baseDoctorDO.getName());
                }
                List<BaseDoctorHospitalDO> baseDoctorHospitalDO= baseDoctorHospitalDao.findByDoctorCode(map.get("operateTo").toString());
                if (baseDoctorHospitalDO!=null&&baseDoctorHospitalDO.size()>0){
                    map.put("operateToDeptName",baseDoctorHospitalDO.get(0).getDeptName());
                List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(map.get("operateTo").toString());
                if (baseDoctorHospitalDO != null && baseDoctorHospitalDO.size() > 0) {
                    map.put("operateToDeptName", baseDoctorHospitalDO.get(0).getDeptName());
                }
            }
        }
    return list;
        return list;
    }
    public List<Map<String, Object>> getComplaintList(String doctorCode) {
        String sql = " SELECT t.complaint_id from base_complaint_doctor t where t.is_del='1' and t.doctor='" + doctorCode + "'";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
}

+ 25 - 0
business/base-service/src/main/java/com/yihu/jw/device/dao/DevicePatientHealthIndexDao.java

@ -11,4 +11,29 @@ import java.util.List;
public interface DevicePatientHealthIndexDao
		extends PagingAndSortingRepository<DevicePatientHealthIndex, Long>, JpaSpecificationExecutor<DevicePatientHealthIndex> {
	@Query(value= " select * from device.wlyy_patient_health_index where type in (1,2) and record_date BETWEEN ?1 AND ?2  AND user in (select p.code from wlyy.wlyy_patient p INNER JOIN wlyy.wlyy_sign_family s on s.patient = p.code RIGHT JOIN wlyy.wlyy_sign_patient_label_info sp on sp.patient = p.code where  s.status > 0 AND s.admin_team_code = ?3 and (s.doctor = ?4 or s.doctor_health =?4) and sp.status = 1 and sp.label_type = 3 and (sp.label = 1 or sp.label = 2))",nativeQuery = true)
	List<DevicePatientHealthIndex> findByTeamcodeAndRecordDate(Date start, Date end,String teamcode,String doctorcode);
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from device.wlyy_patient_health_index a where a.user = ?1 and a.record_date >= ?2 and a.record_date <= ?3 and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d') order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit ?4 ,?5",nativeQuery = true)
	List<String> findDateList(String patient,Date start ,Date end,int currentSize,int pageSize);
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from device.wlyy_patient_health_index a where a.user = ?1 and a.type=?2 and a.record_date >= ?3 and a.record_date <= ?4 and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d') order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit ?5 ,?6",nativeQuery = true)
	List<String> findDateList(String patient,int type,Date start ,Date end,int currentSize,int pageSize);
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from device.wlyy_patient_health_index a where a.user = ?1 and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d') order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit ?2 ,?3",nativeQuery = true)
	List<String> findDateList1(String patient,int currentSize,int pageSize);
	@Query(value= "SELECT DISTINCT\n" +
			"	a.* \n" +
			"FROM\n" +
			"	wlyy_patient_health_index  a \n" +
			"	INNER JOIN base_patient b ON a.`user`=b.id \n" +
			"	INNER JOIN base_patient_doctor_relation c ON b.id=c.patient_id\n" +
			"WHERE\n" +
			"	a.type IN ('1', '2' ) \n" +
			"	AND a.record_date BETWEEN ?1 AND ?2 \n" +
			"	AND c.doctor_id =?3 \n" +
			"	AND b.disease IN('1','2','3')\n" +
			"	AND b.disease_condition IN ('1','2','1,2')",nativeQuery = true)
	List<DevicePatientHealthIndex> findByDoctor(Date start, Date end, String doctorcode);
}

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

@ -4847,6 +4847,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            } else {
                rs.put("scoreList", null);
            }
            rs.put("doctorLable",findDoctorLabel(doctor));
        }
        return rs;
@ -5028,11 +5030,30 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                rs.put("authPw", baseDoctorService.findDoctorPwlimitDate(doctor));
            }
            //医生标签
            rs.put("doctorLable", findDoctorLabel(doctor));
        }
        return rs;
    }
    //获取医生标签
    public String findDoctorLabel(String doctor){
        String sql = "SELECT GROUP_CONCAT(name) doctorLable from ( " +
                " SELECT CONCAT(di.name,'专病医生') name from base_disease_hospital di " +
                " INNER JOIN base_doctor_hospital d on d.del=1 and FIND_IN_SET(d.dept_code,di.dept) " +
                " WHERE di.`status`=1 and d.doctor_code='"+doctor+"' " +
                " UNION " +
                " SELECT CONCAT(t.name,'成员') name from base_team t,base_team_member m " +
                " WHERE t.del='1' and t.id=m.team_code and m.del='1' " +
                " and m.doctor_code='"+doctor+"') a ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list.size()>0){
            return list.get(0).get("doctorLable")+"";
        }
        return "";
    }
    /**
     * 居民取消复诊或者医生拒绝接诊
     *

+ 9 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/dao/team/WlyyPatientLabelDao.java

@ -1,10 +1,10 @@
package com.yihu.jw.base.dao.team;
package com.yihu.jw.label;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
@ -17,6 +17,13 @@ public interface WlyyPatientLabelDao extends JpaRepository<WlyyPatientLabelDO, S
    @Query("delete WlyyPatientLabelDO a where a.patient=?1 and a.labelType=?2")
    int deleteByPatientAndLabelType(String patient, String labelType) throws Exception;
    @Modifying
    @Query("delete WlyyPatientLabelDO a where a.patient=?1")
    int deleteByPatient(String patiente) throws Exception;
    @Query("from WlyyPatientLabelDO w where  w.patient=?1 group by w.labelType,w.labelCode order by w.czrq desc")
    List<WlyyPatientLabelDO> findByPatient(String patient);
    @Query("from WlyyPatientLabelDO w where  w.patient=?1 and w.labelCode=?2 and w.labelType=?3 ")
    List<WlyyPatientLabelDO> findByPatient(String patient, String labelCode, String labelType);
}

+ 13 - 0
business/base-service/src/main/java/com/yihu/jw/label/WlyyPatientLabelLogDao.java

@ -0,0 +1,13 @@
package com.yihu.jw.label;
import com.yihu.jw.entity.care.label.WlyyPatientLabelLogDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
 * Created by yeshijie on 2024/3/4.
 */
public interface WlyyPatientLabelLogDao extends JpaRepository<WlyyPatientLabelLogDO, String>,
        JpaSpecificationExecutor<WlyyPatientLabelLogDO> {
}

+ 18 - 16
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -1764,26 +1764,28 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    public JSONObject selectOrderTime(String relationCode){
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("PAY_TIME").get();
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("PAY_TIME").orElse(null);
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(relationCode);
        Date createDate;
        Calendar calendar = Calendar.getInstance();
        if (businessOrderDO!=null){
            createDate = businessOrderDO.getCreateTime();
            calendar.add(Calendar.MINUTE,Integer.parseInt(wlyyHospitalSysDictDO.getDictCode()));
            Date createDate = businessOrderDO.getCreateTime();
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(createDate);
            if (businessOrderDO.getOrderCategory().equalsIgnoreCase("4")){
                calendar.add(Calendar.MINUTE,Integer.parseInt(wlyyHospitalSysDictDO.getPyCode()));
            }else {
                calendar.add(Calendar.MINUTE,Integer.parseInt(wlyyHospitalSysDictDO.getDictCode()));
            }
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String time = sdf.format(calendar.getTime());
            JSONObject object = new JSONObject();
            object.put("endTime",time);
            object.put("createTime",businessOrderDO.getCreateTime());
            return object;
        }else {
            calendar.add(Calendar.MINUTE,Integer.parseInt(wlyyHospitalSysDictDO.getPyCode()));
            WlyyPrescriptionDO prescriptionDO = prescriptionDao.findById(relationCode).get();
            calendar.setTime(prescriptionDO.getCreateTime());
            createDate =prescriptionDO.getCreateTime();
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String time = sdf.format(calendar.getTime());
        JSONObject object = new JSONObject();
        object.put("endTime",time);
        object.put("createTime",createDate);
        return object;
            return null;
        }
    }

+ 60 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/PatientHealthGuidanceDao.java

@ -0,0 +1,60 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.patient.PatientHealthGuidance;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
public interface PatientHealthGuidanceDao extends PagingAndSortingRepository<PatientHealthGuidance, Long>, JpaSpecificationExecutor<PatientHealthGuidance> {
    @Query("select b.name, b.photo, a.id, a.content, a.createTime,b.level,a.readStatus from PatientHealthGuidance a, BaseDoctorDO b where a.patient = ?1 and a.doctor = b.id and a.del = '1' order by a.id desc")
    Page<Object> findByPatient(String patient, PageRequest pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.createTime,b.level,a.readStatus from PatientHealthGuidance a, BaseDoctorDO b where a.patient = ?1 and a.doctor = b.id and a.id < ?2 and a.del = '1' order by a.id desc")
    Page<Object> findByPatient(String patient, long id, PageRequest pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, BasePatientDO b where a.doctor = ?1 and a.patient = b.id and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, PageRequest pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, BasePatientDO b where a.doctor = ?1 and a.id < ?2 and a.patient = b.id and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, long id, PageRequest pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, BasePatientDO b where a.doctor = ?1 and a.patient = ?2 and a.patient = b.id and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, String patient, PageRequest pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, BasePatientDO b where a.doctor = ?1 and a.patient = ?2 and a.patient = b.id and a.id < ?3 and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, String patient, long id, PageRequest pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, BasePatientDO b where a.doctor = ?1 and a.czrq between ?2 and ?3 and a.patient = b.id and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, Date begin, Date end, PageRequest pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, BasePatientDO b where a.doctor = ?1 and a.czrq between ?2 and ?3 and a.id < ?4 and a.patient = b.id and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, Date begin, Date end, long id, PageRequest pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, BasePatientDO b where a.doctor = ?1 and a.patient = ?2 and a.czrq between ?3 and ?4 and a.patient = b.id and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, String patient, Date begin, Date end, PageRequest pageRequest);
    @Query("select b.name, b.photo, a.id, a.content, a.czrq from PatientHealthGuidance a, BasePatientDO b where a.doctor = ?1 and a.patient = ?2 and a.czrq between ?3 and ?4 and a.id < ?5 and a.patient = b.id and a.del = '1' order by a.id desc")
    Page<Object> findByDoctor(String doctor, String patient, Date begin, Date end, long id, PageRequest pageRequest);
    //查找昨天的健康指导
    @Query("SELECT a FROM PatientHealthGuidance a WHERE unix_timestamp(a.czrq)>=unix_timestamp(?1) and unix_timestamp(a.czrq)<unix_timestamp(?2) ")
    List<PatientHealthGuidance> findByCzrqyYesterday(String yesterday, String now);
    @Query("SELECT count(a) from PatientHealthGuidance a WHERE  a.patient=?2 and a.doctor=?1 ")
    Integer findbydoctorAndPatient(String doctor, String patientCode);
//    @Query("select b.name, b.photo, a.id, substring(a.content, 1, 50) as content, a.createTime,b.level,b.id,a.adminTeamCode,a.readStatus from PatientHealthGuidance a, BaseDoctorDO b where a.doctor = b.id and a.patient = ?1 and a.adminTeamCode = ?2 and a.del = '1'")
//    Page<Object> findByPatientAndTeamCode(String patient, Long teamCode, PageRequest pageable);
}

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

@ -0,0 +1,8 @@
package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.patient.PatientHealthGuidanceRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface PatientHealthGuidanceRecordDao extends PagingAndSortingRepository<PatientHealthGuidanceRecord, Long>, JpaSpecificationExecutor<PatientHealthGuidanceRecord> {
}

+ 16 - 0
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java

@ -3,6 +3,7 @@ package com.yihu.jw.patient.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.hospital.prescription.WlyyInspectionDO;
@ -882,4 +883,19 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
        return null;
    }
    /**
     * 获取慢病关联的居民
     */
    public List<BasePatientDO> findAllPatient(String doctorId) {
        String sql="SELECT DISTINCT a.*\n" +
                "FROM\n" +
                "	base_patient a \n" +
                "	INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "WHERE 1=1\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND a.disease IN ('1','2','1,2','2,1')\n" +
                "AND b.doctor_id ='"+doctorId+"'";
        List<BasePatientDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BasePatientDO.class));
        return list;
    }
}

+ 9 - 0
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -7898,4 +7898,13 @@ public class StatisticsEsService {
        }
        return resultMap;
    }
    public Map<String, Object> getChronicDiseaseData() {
        String param = "";
        JSONObject re = wlyyHttpService.sendWlyyMesGet("getChronicDiseaseData", param);
        System.out.println("re==>" + JSON.toJSONString(re));
        System.out.println(JSON.toJSONString(re));
        return re;
    }
}

+ 63 - 0
business/im-service/src/main/java/com/yihu/jw/im/util/SendPatientUtil.java

@ -0,0 +1,63 @@
package com.yihu.jw.im.util;
import com.alibaba.fastjson.JSONArray;
import org.json.JSONObject;
import java.util.Objects;
public class SendPatientUtil extends  Thread {
	private String from;
	private String fromName;
	private String to;
	private String contentType;
	private String content;
	private String title;
	private String type;
	private String teamCode;
	private ImUtil imUtill;
	public SendPatientUtil(String from, String fromName, String to, String contentType, String content, String title, String type, String teamCode, ImUtil imUtill){
		this.from = from;
		this.fromName = fromName;
		this.to = to;
		this.contentType = contentType;
		this.content = content;
		this.title = title;
		this.type = type;
		this.teamCode =teamCode;
		this.imUtill=imUtill;
	}
	public String sendToPatient(String from,String fromName,String to,String contentType,String content,String title,String type,String teamCode){
		JSONArray jsonArray = imUtill.getParticipants(to + "_" + teamCode + "_" + type);
		com.alibaba.fastjson.JSONObject participants = new com.alibaba.fastjson.JSONObject();
		for(Object object:jsonArray){
			JSONObject jsonObject = (JSONObject)object;
			participants.put(jsonObject.getString("id"),jsonObject.get("role"));
		}
		if(Objects.isNull(participants.get(from))){
			participants.put(from,0);
		}
		if(Objects.isNull(participants.get(to))){
			participants.put(from,0);
		}
		participants.put(to,0);
		if(!"4".equals(contentType)){
			contentType = "0";
		}
		com.alibaba.fastjson.JSONObject sessionJson = ImUtil.createSession(participants, ImUtil.SESSION_TYPE_MUC, title, to + "_" + teamCode + "_" + type);
		if("-1".equals(sessionJson.getString("status"))){
			throw  new RuntimeException(sessionJson.getString("message"));
		}
		com.alibaba.fastjson.JSONObject session = sessionJson.getJSONObject("data");
		return ImUtil.sendImMsg(from,fromName,session.getString("id"),contentType,content,"1");
	}
	@Override
	public void run(){
		this.sendToPatient(from,fromName,to,contentType,content,title,type,teamCode);
	}
}

File diff suppressed because it is too large
+ 173 - 0
common/common-entity/src/db/2024.sql


+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/complaint/BaseComplaintDO.java

@ -31,7 +31,7 @@ public class BaseComplaintDO  extends UuidIdentityEntity {
    private String idcardBack;//'身份证背面地址'
    private String imgUrl;//'投诉图片地址多个逗号隔开'
    private String isDel;//'0删除1正常'
    private String status;//'0已投诉1已接收2已反馈'
    private String status;//'0已投诉1已接收2已反馈'  -1撤销投诉
    private String mobile;//
    private String visitTypeName;//
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -303,12 +303,23 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    private String verifyCode;//眼科token
    private String disease ;//'疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病',
    // 病情:0绿标,1黄标,2红标
    private Integer diseaseCondition;
    //外部数据-年龄数据
    private Integer age;
    public String getDisease() {
        return disease;
    }
    public void setDisease(String disease) {
        this.disease = disease;
    }
    @Column(name = "medical_state")
    public String getMedicalState() {
        return medicalState;

+ 53 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/PatientDoctorRelationEntity.java

@ -0,0 +1,53 @@
package com.yihu.jw.entity.base.patient;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * @author suqinyi
 * @Date 2024/3/5
 */
@Entity
@Table(name = "base_patient_doctor_relation")
public class PatientDoctorRelationEntity extends IdEntity {
    private String patientId;  //患者id
    private String doctorId; // 医生id
    private String sourceType;//来源类型,1线上就诊 , 2i健康签约
    private Date createTime;//创建时间
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public String getDoctorId() {
        return doctorId;
    }
    public void setDoctorId(String doctorId) {
        this.doctorId = doctorId;
    }
    public String getSourceType() {
        return sourceType;
    }
    public void setSourceType(String sourceType) {
        this.sourceType = sourceType;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 44 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceHealthyInfoMapping.java

@ -0,0 +1,44 @@
package com.yihu.jw.entity.care.device;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * @author yeshijie on 2018/1/12.
 */
@Entity
@Table(name = "wlyy_device_healthy_info_mapping")
public class DeviceHealthyInfoMapping extends IdEntity {
    private Long indexId;//如果和id不一致,那是旧体征信息表id
    private String rid;//es的rowkey
    private Date createTime;//创建时间
    public Long getIndexId() {
        return indexId;
    }
    public void setIndexId(Long indexId) {
        this.indexId = indexId;
    }
    public String getRid() {
        return rid;
    }
    public void setRid(String rid) {
        this.rid = rid;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 1 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/label/WlyyPatientLabelDO.java

@ -18,6 +18,7 @@ public class WlyyPatientLabelDO extends UuidIdentityEntity {
    // 标签名称
    private String labelName;
    // 标签类型 1.服务类型 2居民标签 3老人标签
    //三院 1健康情况 2疾病类型 3专病类型 4自定义标签
    private String labelType;
    // 是否系统标签
    private Integer isSystem;

+ 79 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/label/WlyyPatientLabelLogDO.java

@ -0,0 +1,79 @@
package com.yihu.jw.entity.care.label;
import com.yihu.jw.entity.IdEntityWithCreateTime;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 标签修改日志记录表
 * Created by yeshijie on 2024/3/4.
 */
@Entity
@Table(name = "wlyy_patient_label_log")
public class WlyyPatientLabelLogDO extends IdEntityWithCreateTime {
    private String patient;
    private String doctor;
    private String doctorName;
    private String labelCode;//标签编码
    private String labelName;//标签名称
    private String labelType;//标签类型
    private String jobTitle;//职称
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    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 getLabelCode() {
        return labelCode;
    }
    public void setLabelCode(String labelCode) {
        this.labelCode = labelCode;
    }
    public String getLabelName() {
        return labelName;
    }
    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }
    public String getLabelType() {
        return labelType;
    }
    public void setLabelType(String labelType) {
        this.labelType = labelType;
    }
    public String getJobTitle() {
        return jobTitle;
    }
    public void setJobTitle(String jobTitle) {
        this.jobTitle = jobTitle;
    }
}

+ 12 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/article/KnowledgeCategoryDO.java

@ -3,6 +3,7 @@ package com.yihu.jw.entity.hospital.article;
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;
@ -21,7 +22,8 @@ public class KnowledgeCategoryDO extends UuidIdentityEntity {
	private Date updateTime;  // 编辑时间
	private Integer del;    // 是否删除,1正常,0删除'
	private String pid;   // 父id
	
	private Integer isCheck;   // 是否开启审核1开启 0关闭, 默认开启
	
	public String getName() {
		return name;
@ -62,4 +64,13 @@ public class KnowledgeCategoryDO extends UuidIdentityEntity {
	public void setPid(String pid) {
		this.pid = pid;
	}
	@Column(name = "is_check")
	public Integer getIsCheck() {
		return isCheck;
	}
	public void setIsCheck(Integer isCheck) {
		this.isCheck = isCheck;
	}
}

+ 145 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/patient/PatientHealthGuidance.java

@ -0,0 +1,145 @@
package com.yihu.jw.entity.patient;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 健康指导
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_patient_health_guidance")
public class PatientHealthGuidance extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -4187769034437765691L;
	// 患者标识
	private String patient;
	// 医生标识
	private String doctor;
	// 指导内容
	private String content;
	// 咨询图片URL,多图以逗号分隔
	private String images;
	// 咨询语音URL
	private String voice;
	// 作废标识:1正常,0作废
	private String del;
	// 添加时间
	private Date czrq;
	// 签约类型 1三师 2家庭
	private Integer signType;
	// 行政团队
	private Long adminTeamCode;
//	指导阅读状态
	private int readStatus;
//	指导创建时间
	private Date createTime;
	//签约表Code
	private String signCode;
	public Date getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	public int getReadStatus() {
		return readStatus;
	}
	public void setReadStatus(int readStatus) {
		this.readStatus = readStatus;
	}
	public String getPatient() {
		return patient;
	}
	public void setPatient(String patient) {
		this.patient = patient;
	}
	public String getDoctor() {
		return doctor;
	}
	public void setDoctor(String doctor) {
		this.doctor = doctor;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
	@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;
	}
	public String getImages() {
		return images;
	}
	public void setImages(String images) {
		this.images = images;
	}
	public String getVoice() {
		return voice;
	}
	public void setVoice(String voice) {
		this.voice = voice;
	}
	public Integer getSignType() {
		return signType;
	}
	public void setSignType(Integer signType) {
		this.signType = signType;
	}
	public Long getAdminTeamCode() {
		return adminTeamCode;
	}
	public void setAdminTeamCode(Long adminTeamCode) {
		this.adminTeamCode = adminTeamCode;
	}
	public String getSignCode() {
		return signCode;
	}
	public void setSignCode(String signCode) {
		this.signCode = signCode;
	}
}

+ 135 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/patient/PatientHealthGuidanceRecord.java

@ -0,0 +1,135 @@
package com.yihu.jw.entity.patient;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 健康指导记录本
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_patient_health_guidance_record")
public class PatientHealthGuidanceRecord extends IdEntity {
    private static final long serialVersionUID = -4187769034437765691L;
    private String code;
    // 患者标识
    private String patient;
    // 患者标识
    private String patientOpenid;
    // 医生标识
    private String doctor;
    // 指导内容
    private String content;
    // 咨询图片URL,多图以逗号分隔
    private String images;
    // 咨询语音URL
    private String voice;
    // 作废标识:1正常,0作废
    private Integer del;
    // 行政团队
    private Long adminTeamCode;
    //	指导阅读状态
    private int readStatus;
    //	指导创建时间
    private Date createTime;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "read_status")
    public int getReadStatus() {
        return readStatus;
    }
    public void setReadStatus(int readStatus) {
        this.readStatus = readStatus;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "patient_openid")
    public String getPatientOpenid() {
        return patientOpenid;
    }
    public void setPatientOpenid(String patientOpenid) {
        this.patientOpenid = patientOpenid;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getImages() {
        return images;
    }
    public void setImages(String images) {
        this.images = images;
    }
    public String getVoice() {
        return voice;
    }
    public void setVoice(String voice) {
        this.voice = voice;
    }
    @Column(name = "admin_team_code")
    public Long getAdminTeamCode() {
        return adminTeamCode;
    }
    public void setAdminTeamCode(Long adminTeamCode) {
        this.adminTeamCode = adminTeamCode;
    }
}

+ 223 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/scheme/DoctorSchemeBloodPressure.java

@ -0,0 +1,223 @@
package com.yihu.jw.entity.scheme;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.sql.Time;
import java.sql.Timestamp;
/**
 * 医生监测方案-血压
 * @author huangwenjie
 * @date 2017/9/7 20:14
 */
@Entity
@Table(name = "wlyy_doctor_scheme_blood_pressure")
public class DoctorSchemeBloodPressure extends IdEntity {
    private String name;                //方案名称
    private String code;
    private String doctorcode;          //医生CODE
    private Short dayofweek;            //星期几
    private Short earlyMorning;
    private Time earlyMorningTime;
    private Short morning;
    private Time morningTime;
    private Short noon;
    private Time noonTime;
    private Short afterNoon;
    private Time afterNoonTime;
    private Short night;
    private Time nightTime;
    private Timestamp createTime;      //创建时间
    private Short alertTag;            //是否提醒用户
    private String content;            //方案说明
    private Integer del;          //0为正常,1为删除
    @Basic
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Basic
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Basic
    @Column(name = "doctorcode")
    public String getDoctorcode() {
        return doctorcode;
    }
    public void setDoctorcode(String doctorcode) {
        this.doctorcode = doctorcode;
    }
    @Basic
    @Column(name = "dayofweek")
    public Short getDayofweek() {
        return dayofweek;
    }
    public void setDayofweek(Short dayofweek) {
        this.dayofweek = dayofweek;
    }
    @Basic
    @Column(name = "early_morning")
    public Short getEarlyMorning() {
        return earlyMorning;
    }
    public void setEarlyMorning(Short earlyMorning) {
        this.earlyMorning = earlyMorning;
    }
    @Basic
    @Column(name = "early_morning_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getEarlyMorningTime() {
        return earlyMorningTime;
    }
    public void setEarlyMorningTime(Time earlyMorningTime) {
        this.earlyMorningTime = earlyMorningTime;
    }
    @Basic
    @Column(name = "morning")
    public Short getMorning() {
        return morning;
    }
    public void setMorning(Short morning) {
        this.morning = morning;
    }
    @Basic
    @Column(name = "morning_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getMorningTime() {
        return morningTime;
    }
    public void setMorningTime(Time morningTime) {
        this.morningTime = morningTime;
    }
    @Basic
    @Column(name = "noon")
    public Short getNoon() {
        return noon;
    }
    public void setNoon(Short noon) {
        this.noon = noon;
    }
    @Basic
    @Column(name = "noon_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getNoonTime() {
        return noonTime;
    }
    public void setNoonTime(Time noonTime) {
        this.noonTime = noonTime;
    }
    @Basic
    @Column(name = "after_noon")
    public Short getAfterNoon() {
        return afterNoon;
    }
    public void setAfterNoon(Short afterNoon) {
        this.afterNoon = afterNoon;
    }
    @Basic
    @Column(name = "after_noon_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getAfterNoonTime() {
        return afterNoonTime;
    }
    public void setAfterNoonTime(Time afterNoonTime) {
        this.afterNoonTime = afterNoonTime;
    }
    @Basic
    @Column(name = "night")
    public Short getNight() {
        return night;
    }
    public void setNight(Short night) {
        this.night = night;
    }
    @Basic
    @Column(name = "night_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getNightTime() {
        return nightTime;
    }
    public void setNightTime(Time nightTime) {
        this.nightTime = nightTime;
    }
    @Basic
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Timestamp getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }
    @Basic
    @Column(name = "alert_tag")
    public Short getAlertTag() {
        return alertTag;
    }
    public void setAlertTag(Short alertTag) {
        this.alertTag = alertTag;
    }
    @Basic
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 269 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/scheme/DoctorSchemeBloodSugger.java

@ -0,0 +1,269 @@
package com.yihu.jw.entity.scheme;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.sql.Time;
import java.sql.Timestamp;
/**
 * 医生监测方案-血糖
 * @author huangwenjie
 * @date 2017/9/7 20:14
 */
@Entity
@Table(name = "wlyy_doctor_scheme_blood_sugger")
public class DoctorSchemeBloodSugger extends IdEntity {
    private String name;                    //方案名称
    private String code;
    private String doctorcode;
    private Short dayofweek;                //星期几:1-7,1代表周日,7代表周六
    private Short beforeBreakfast;
    private Time beforeBreakfastTime;
    private Short afterBreakfast;
    private Time afterBreakfastTime;
    private Short beforeLunch;
    private Time beforeLunchTime;
    private Short afterLunch;
    private Time afterLunchTime;
    private Short beforeDinner;
    private Time beforeDinnerTime;
    private Short afterDinner;
    private Time afterDinnerTime;
    private Short beforeSleep;
    private Time beforeSleepTime;
    private Timestamp createTime;
    private Short alertTag;                 //是否提醒用户
    private String content;                 //方案说明
    private Integer del;          //0为正常,1为删除
    @Basic
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Basic
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Basic
    @Column(name = "doctorcode")
    public String getDoctorcode() {
        return doctorcode;
    }
    public void setDoctorcode(String doctorcode) {
        this.doctorcode = doctorcode;
    }
    @Basic
    @Column(name = "dayofweek")
    public Short getDayofweek() {
        return dayofweek;
    }
    public void setDayofweek(Short dayofweek) {
        this.dayofweek = dayofweek;
    }
    @Basic
    @Column(name = "before_breakfast")
    public Short getBeforeBreakfast() {
        return beforeBreakfast;
    }
    public void setBeforeBreakfast(Short beforeBreakfast) {
        this.beforeBreakfast = beforeBreakfast;
    }
    @Basic
    @Column(name = "before_breakfast_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getBeforeBreakfastTime() {
        return beforeBreakfastTime;
    }
    public void setBeforeBreakfastTime(Time beforeBreakfastTime) {
        this.beforeBreakfastTime = beforeBreakfastTime;
    }
    @Basic
    @Column(name = "after_breakfast")
    public Short getAfterBreakfast() {
        return afterBreakfast;
    }
    public void setAfterBreakfast(Short afterBreakfast) {
        this.afterBreakfast = afterBreakfast;
    }
    @Basic
    @Column(name = "after_breakfast_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getAfterBreakfastTime() {
        return afterBreakfastTime;
    }
    public void setAfterBreakfastTime(Time afterBreakfastTime) {
        this.afterBreakfastTime = afterBreakfastTime;
    }
    @Basic
    @Column(name = "before_lunch")
    public Short getBeforeLunch() {
        return beforeLunch;
    }
    public void setBeforeLunch(Short beforeLunch) {
        this.beforeLunch = beforeLunch;
    }
    @Basic
    @Column(name = "before_lunch_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getBeforeLunchTime() {
        return beforeLunchTime;
    }
    public void setBeforeLunchTime(Time beforeLunchTime) {
        this.beforeLunchTime = beforeLunchTime;
    }
    @Basic
    @Column(name = "after_lunch")
    public Short getAfterLunch() {
        return afterLunch;
    }
    public void setAfterLunch(Short afterLunch) {
        this.afterLunch = afterLunch;
    }
    @Basic
    @Column(name = "after_lunch_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getAfterLunchTime() {
        return afterLunchTime;
    }
    public void setAfterLunchTime(Time afterLunchTime) {
        this.afterLunchTime = afterLunchTime;
    }
    @Basic
    @Column(name = "before_dinner")
    public Short getBeforeDinner() {
        return beforeDinner;
    }
    public void setBeforeDinner(Short beforeDinner) {
        this.beforeDinner = beforeDinner;
    }
    @Basic
    @Column(name = "before_dinner_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getBeforeDinnerTime() {
        return beforeDinnerTime;
    }
    public void setBeforeDinnerTime(Time beforeDinnerTime) {
        this.beforeDinnerTime = beforeDinnerTime;
    }
    @Basic
    @Column(name = "after_dinner")
    public Short getAfterDinner() {
        return afterDinner;
    }
    public void setAfterDinner(Short afterDinner) {
        this.afterDinner = afterDinner;
    }
    @Basic
    @Column(name = "after_dinner_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getAfterDinnerTime() {
        return afterDinnerTime;
    }
    public void setAfterDinnerTime(Time afterDinnerTime) {
        this.afterDinnerTime = afterDinnerTime;
    }
    @Basic
    @Column(name = "before_sleep")
    public Short getBeforeSleep() {
        return beforeSleep;
    }
    public void setBeforeSleep(Short beforeSleep) {
        this.beforeSleep = beforeSleep;
    }
    @Basic
    @Column(name = "before_sleep_time")
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+08:00")
    public Time getBeforeSleepTime() {
        return beforeSleepTime;
    }
    public void setBeforeSleepTime(Time beforeSleepTime) {
        this.beforeSleepTime = beforeSleepTime;
    }
    @Basic
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Timestamp getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }
    @Basic
    @Column(name = "alert_tag")
    public Short getAlertTag() {
        return alertTag;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public void setAlertTag(Short alertTag) {
        this.alertTag = alertTag;
    }
    @Basic
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
}

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

@ -0,0 +1,62 @@
package com.yihu.jw.entity.scheme;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2018/1/4.
 */
@Entity
@Table(name = "wlyy_doctor_switch")
public class DoctorSwitch extends IdEntity {
    private String doctor;//关联医生
    private String alertPatientSwitch;//0不自动跟踪居民,1自动跟踪预警居民
    private String dispatchOrderSwitch; // 0关闭分派订单功能,1开启分派订单功能
    private Date createTime;//创建时间
    private Date updateTime;//更新时间
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getAlertPatientSwitch() {
        return alertPatientSwitch;
    }
    public void setAlertPatientSwitch(String alertPatientSwitch) {
        this.alertPatientSwitch = alertPatientSwitch;
    }
    public String getDispatchOrderSwitch() {
        return dispatchOrderSwitch;
    }
    public void setDispatchOrderSwitch(String dispatchOrderSwitch) {
        this.dispatchOrderSwitch = dispatchOrderSwitch;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 86 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/scheme/PatientSchemeList.java

@ -0,0 +1,86 @@
package com.yihu.jw.entity.scheme;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 患者-医生监测方案关联关系表
 * @author huangwenjie
 * @date 2017/9/7 20:07
 */
@Entity
@Table(name = "wlyy_patient_scheme_list")
public class PatientSchemeList extends IdEntity {
    private String code;
    private String patientcode;
    private String schemecode;
    private Integer type;//方案类型:1为血糖,2为血压
    private String doctorcode;
    private Date createTime;
    @Basic
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Basic
    @Column(name = "patientcode")
    public String getPatientcode() {
        return patientcode;
    }
    public void setPatientcode(String patientcode) {
        this.patientcode = patientcode;
    }
    @Basic
    @Column(name = "schemecode")
    public String getSchemecode() {
        return schemecode;
    }
    public void setSchemecode(String schemecode) {
        this.schemecode = schemecode;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Basic
    @Column(name = "doctorcode")
    public String getDoctorcode() {
        return doctorcode;
    }
    public void setDoctorcode(String doctorcode) {
        this.doctorcode = doctorcode;
    }
    @Basic
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 108 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/scheme/TrackPatient.java

@ -0,0 +1,108 @@
package com.yihu.jw.entity.scheme;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2018/1/4.
 */
@Entity
@Table(name = "wlyy_track_patient")
public class TrackPatient extends IdEntity {
    private String patientCode;//关联居民code,医生的重点关注对象
    private String patientName;//患者姓名
    private String doctorCode;//所属医生
    private String doctorName;//所属医生名
    private Integer teamCode;//居民签约团队
    private String idcard;//身份证号
    private String ssc;//社保卡号
    private String del;//删除
    private Date createTime;//创建时间
    private Date updateTime;//更新时间
    public String getPatientCode() {
        return patientCode;
    }
    public void setPatientCode(String patientCode) {
        this.patientCode = patientCode;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    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 Integer getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(Integer teamCode) {
        this.teamCode = teamCode;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
}

+ 52 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/scheme/vo/DoctorSchemeBloodPressureVO.java

@ -0,0 +1,52 @@
package com.yihu.jw.entity.scheme.vo;
import com.yihu.jw.entity.scheme.DoctorSchemeBloodPressure;
import java.util.List;
/**
 * 医生血压监测VO类
 * @author huangwenjie
 * @date 2017/9/13 21:28
 */
public class DoctorSchemeBloodPressureVO {
    private String                          code;
    private String                          name;       //名字
    private String                          content;    //说明
    private List<DoctorSchemeBloodPressure> list;       //详情
    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;
    }
    public List<DoctorSchemeBloodPressure> getList() {
        return list;
    }
    public void setList(List<DoctorSchemeBloodPressure> list) {
        this.list = list;
    }
}

+ 52 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/scheme/vo/DoctorSchemeBloodSuggerVO.java

@ -0,0 +1,52 @@
package com.yihu.jw.entity.scheme.vo;
import com.yihu.jw.entity.scheme.DoctorSchemeBloodSugger;
import java.util.List;
/**
 * 医生血糖VO类
 * @author huangwenjie
 * @date 2017/9/13 21:40
 */
public class DoctorSchemeBloodSuggerVO {
    private String                          code;
    private String                          name;       //名字
    private String                          content;    //说明
    private List<DoctorSchemeBloodSugger> list;       //详情
    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;
    }
    public List<DoctorSchemeBloodSugger> getList() {
        return list;
    }
    public void setList(List<DoctorSchemeBloodSugger> list) {
        this.list = list;
    }
}

+ 102 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/template/DoctorGuidanceTemp.java

@ -0,0 +1,102 @@
package com.yihu.jw.entity.template;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by lyr-pc on 2017/2/3.
 */
@Entity
@Table(name = "wlyy_doctor_guidance_temp")
public class DoctorGuidanceTemp extends IdEntity{
    // 模板编码
    private String code;
    // 所属医生 system为系统标签
    private String owner;
    // 内容
    private String content;
    // 发送次数
    private Integer sendTimes;
    // 创建时间
    private Date createTime;
    // 最后一次发送时间
    private Date lastTime;
//    模板名称
    private String modelName;
//    图片地址
    private String imagesUrl;
    public String getModelName() {
        return modelName;
    }
    public void setModelName(String modelName) {
        this.modelName = modelName;
    }
    public String getImagesUrl() {
        return imagesUrl;
    }
    public void setImagesUrl(String imagesUrl) {
        this.imagesUrl = imagesUrl;
    }
    public String getCode() {
        return code;
    }
//=================
    public void setCode(String code) {
        this.code = code;
    }
    public String getOwner() {
        return owner;
    }
    public void setOwner(String owner) {
        this.owner = owner;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public Integer getSendTimes() {
        return sendTimes;
    }
    public void setSendTimes(Integer sendTimes) {
        this.sendTimes = sendTimes;
    }
    @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;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getLastTime() {
        return lastTime;
    }
    public void setLastTime(Date lastTime) {
        this.lastTime = lastTime;
    }
}

+ 86 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/template/DoctorGuidanceTempLabel.java

@ -0,0 +1,86 @@
package com.yihu.jw.entity.template;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by 刘文彬 on 2018/5/17.
 */
@Entity
@Table(name = "wlyy_doctor_guidance_temp_label")
public class DoctorGuidanceTempLabel extends IdEntity {
    private String code;//业务编码
    private String name;//标签名称
    private Date createTime;// 创建时间
    private String doctorCode;//创建人code
    private Integer del;//作废标识1、正常 ,0、作废
    private Integer teamId;//医生团队Id
    @Column(name = "code", length = 50)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "name", length = 100)
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @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 = "doctor_code", length = 50)
    public String getDoctorCode() {
        return doctorCode;
    }
    public void setDoctorCode(String doctorCode) {
        this.doctorCode = doctorCode;
    }
    @Column(name = "del", length = 2)
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    @Column(name = "team_id", length = 11)
    public Integer getTeamId() {
        return teamId;
    }
    public void setTeamId(Integer teamId) {
        this.teamId = teamId;
    }
    public DoctorGuidanceTempLabel(String code, String name) {
        this.code = code;
        this.name = name;
    }
    public DoctorGuidanceTempLabel() {
    }
}

+ 91 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/template/DoctorTeamGuidanceDetail.java

@ -0,0 +1,91 @@
package com.yihu.jw.entity.template;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Reece on 2017/6/8.
 */
@Entity
@Table(name = "wlyy_team_guidance_detail")
public class DoctorTeamGuidanceDetail extends IdEntity {
    //    指导模板编码
    private String code;
    //    所属医生
    private String creater;
    //    模板名称(前端限10 后端限50)
    private String title;
    //    指导内容
    private String content;
    //    健康指导图片URL,多图以逗号分隔(至多9图)
    private String imagesUrl;
    //            创建时间
    private Date createTime;
    //    操作时间
    private Date czrq;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getCreater() {
        return creater;
    }
    public void setCreater(String creater) {
        this.creater = creater;
    }
    @Column(name = "title", length = 50)
    public String getTitle() {
        return title;
    }
    @Column(name = "title", length = 50)
    public void setTitle(String title) {
        this.title = title;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getImagesUrl() {
        return imagesUrl;
    }
    public void setImagesUrl(String imagesUrl) {
        this.imagesUrl = imagesUrl;
    }
    @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;
    }
    @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;
    }
}

+ 130 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/template/DoctorTeamGuidanceTemplate.java

@ -0,0 +1,130 @@
package com.yihu.jw.entity.template;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Reece on 2017/6/8.
 * 医生端团队健康指导模板 团队与模板对应关系
 */
@Entity
@Table(name = "wlyy_team_guidance_template")
public class DoctorTeamGuidanceTemplate extends IdEntity {
    //    团队ID
    private int teamId;
    //    团队ID名称
    private String teamName;
    //    团队指导模板code
    private String teamTemplateCode;
    //    团队模板创建者
    private String creater;
    //     团队模板的标题
    private String title;
    //        团队内该模板被使用次数
    private int useTimes;
    //  模板创建时间
    private Date createTime;
    //        操作时间
    private Date czrq;
    //        团队内的团队模板状态  0删除  1正常
    private int del;
    private String labelCode;//指导标签code
    private String labelName;//指导标签name
    public String getTeamName() {
        return teamName;
    }
    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }
    public int getTeamId() {
        return teamId;
    }
    public void setTeamId(int teamId) {
        this.teamId = teamId;
    }
    public String getTeamTemplateCode() {
        return teamTemplateCode;
    }
    public void setTeamTemplateCode(String teamTemplateCode) {
        this.teamTemplateCode = teamTemplateCode;
    }
    public String getCreater() {
        return creater;
    }
    public void setCreater(String creater) {
        this.creater = creater;
    }
    @Column(name = "title", length = 50)
    public String getTitle() {
        return title;
    }
    @Column(name = "title", length = 50)
    public void setTitle(String title) {
        this.title = title;
    }
    public int getUseTimes() {
        return useTimes;
    }
    public void setUseTimes(int useTimes) {
        this.useTimes = useTimes;
    }
    @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;
    }
    @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;
    }
    public int getDel() {
        return del;
    }
    public void setDel(int del) {
        this.del = del;
    }
    public String getLabelCode() {
        return labelCode;
    }
    public void setLabelCode(String labelCode) {
        this.labelCode = labelCode;
    }
    public String getLabelName() {
        return labelName;
    }
    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }
}

+ 212 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/conf/SystemConf.java

@ -0,0 +1,212 @@
package com.yihu.jw.restmodel.conf;
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;
    //未认证
    public static final int NOT_CERTIFIED = 996;
    //未修改默认密码
    public static final int NOT_UPD_PWD = 995;
    // 文件保存临时路径
    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");
    }
    /**************************************************************************************/
    /**************************************************************************************/
}

+ 447 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/patient/PatientVO.java

@ -0,0 +1,447 @@
package com.yihu.jw.restmodel.patient;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
 * 居民VO类
 * @author huangwenjie
 * @date 2017/11/21 08:57
 */
public class PatientVO {
	
	// 业务主键
	private String code;
	// 身份证号
	private String idcard;
	// 登录密码
	private String password;
	private String salt;
	// 姓名
	private String name;
	// 生日
	private Date birthday;
	// 性別,1男,2女
	private Integer sex;
	// 手機號
	private String mobile;
	// (基卫)手機號
	private String mobileRemarks;
	// 聯繫電話
	private String phone;
	// 社保卡號
	private String ssc;
	// 頭像HTTP地址
	private String photo;
	// 省代碼
	private String province;
	// 城市代碼
	private String city;
	// 區縣代碼
	private String town;
	// 街道代码
	private String street;
	// 省名
	private String provinceName;
	// 市名
	private String cityName;
	// 區縣名
	private String townName;
	// 街道名称
	private String streetName;
	// 地址
	private String address;
	// 疾病类型,0健康,1高血压,2糖尿病,(1,2)高血压+糖尿病
	private String disease;
	private Integer diseasesum;
	// 病情:0绿标,1黄标,2红标
	private Integer diseaseCondition;
	// 病历记录总数
	private Integer recordAmount;
	// 總積分
	private Integer points;
	// 更新時間
	private Date czrq;
	// 微信编号
	private String openid;
	//微信时间
	private Date openidTime;
	// 用户状态:1正常,0禁用,-1恶意注册,2审核中
	private Integer status;
	// 居委会字段id
	private String sickVillage;
	// 居委会字段名称
	private String sickVillageName;
	//	绑定电子社保卡主体(本人为本人code,共济为操作人code)
	private String principalCode;
	//	是否绑定电子社保卡
	private Integer sicardStatus;
	//	绑定电子社保卡时间
	private Date sicardTime;
	//是否分配过微信标签  1分配过 0或者空没有
	private Integer isWxtag;
	//微信iagId
	private Integer wxtagid;
	//居民预警状态:0为标准,1为预警状态
	private Integer standardStatus;
	//档案状态(-2冻结 1未管理 2死亡3 正常4 高危)
	private String archiveStatus;
	//设备类型(1血糖,2血压,3血糖+血压)
	private String deviceType;
	//医疗保险号
	private String medicareNumber;
	//专病类型,专病名称
	private String specialistDisease;
	private String specialistDiseaseName;
	
	public String getCode() {
		return code;
	}
	
	public void setCode(String code) {
		this.code = code;
	}
	
	public String getIdcard() {
		return idcard;
	}
	
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	
	public String getPassword() {
		return password;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getSalt() {
		return salt;
	}
	
	public void setSalt(String salt) {
		this.salt = salt;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	public Date getBirthday() {
		return birthday;
	}
	
	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	
	public Integer getSex() {
		return sex;
	}
	
	public void setSex(Integer sex) {
		this.sex = sex;
	}
	
	public String getMobile() {
		return mobile;
	}
	
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	
	public String getMobileRemarks() {
		return mobileRemarks;
	}
	
	public void setMobileRemarks(String mobileRemarks) {
		this.mobileRemarks = mobileRemarks;
	}
	
	public String getPhone() {
		return phone;
	}
	
	public void setPhone(String phone) {
		this.phone = phone;
	}
	
	public String getSsc() {
		return ssc;
	}
	
	public void setSsc(String ssc) {
		this.ssc = ssc;
	}
	
	public String getPhoto() {
		return photo;
	}
	
	public void setPhoto(String photo) {
		this.photo = photo;
	}
	
	public String getProvince() {
		return province;
	}
	
	public void setProvince(String province) {
		this.province = province;
	}
	
	public String getCity() {
		return city;
	}
	
	public void setCity(String city) {
		this.city = city;
	}
	
	public String getTown() {
		return town;
	}
	
	public void setTown(String town) {
		this.town = town;
	}
	
	public String getStreet() {
		return street;
	}
	
	public void setStreet(String street) {
		this.street = street;
	}
	
	public String getProvinceName() {
		return provinceName;
	}
	
	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}
	
	public String getCityName() {
		return cityName;
	}
	
	public void setCityName(String cityName) {
		this.cityName = cityName;
	}
	
	public String getTownName() {
		return townName;
	}
	
	public void setTownName(String townName) {
		this.townName = townName;
	}
	
	public String getStreetName() {
		return streetName;
	}
	
	public void setStreetName(String streetName) {
		this.streetName = streetName;
	}
	
	public String getAddress() {
		return address;
	}
	
	public void setAddress(String address) {
		this.address = address;
	}
	
	public Integer getDiseaseCondition() {
		return diseaseCondition;
	}
	
	public void setDiseaseCondition(Integer diseaseCondition) {
		this.diseaseCondition = diseaseCondition;
	}
	
	public Integer getRecordAmount() {
		return recordAmount;
	}
	
	public void setRecordAmount(Integer recordAmount) {
		this.recordAmount = recordAmount;
	}
	
	public Integer getPoints() {
		return points;
	}
	
	public void setPoints(Integer points) {
		this.points = points;
	}
	@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;
	}
	
	public String getOpenid() {
		return openid;
	}
	
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getOpenidTime() {
		return openidTime;
	}
	
	public void setOpenidTime(Date openidTime) {
		this.openidTime = openidTime;
	}
	
	public Integer getStatus() {
		return status;
	}
	
	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public String getSickVillage() {
		return sickVillage;
	}
	
	public void setSickVillage(String sickVillage) {
		this.sickVillage = sickVillage;
	}
	
	public String getSickVillageName() {
		return sickVillageName;
	}
	
	public void setSickVillageName(String sickVillageName) {
		this.sickVillageName = sickVillageName;
	}
	
	public String getPrincipalCode() {
		return principalCode;
	}
	
	public void setPrincipalCode(String principalCode) {
		this.principalCode = principalCode;
	}
	
	public Integer getSicardStatus() {
		return sicardStatus;
	}
	
	public void setSicardStatus(Integer sicardStatus) {
		this.sicardStatus = sicardStatus;
	}
	
	public Date getSicardTime() {
		return sicardTime;
	}
	
	public void setSicardTime(Date sicardTime) {
		this.sicardTime = sicardTime;
	}
	
	public Integer getIsWxtag() {
		return isWxtag;
	}
	
	public void setIsWxtag(Integer isWxtag) {
		this.isWxtag = isWxtag;
	}
	
	public Integer getWxtagid() {
		return wxtagid;
	}
	
	public void setWxtagid(Integer wxtagid) {
		this.wxtagid = wxtagid;
	}
	
	public Integer getStandardStatus() {
		return standardStatus;
	}
	
	public void setStandardStatus(Integer standardStatus) {
		this.standardStatus = standardStatus;
	}
	
	public String getDeviceType() {
		return deviceType;
	}
	
	public void setDeviceType(String deviceType) {
		this.deviceType = deviceType;
	}
	
	public String getDisease() {
		return disease;
	}
	
	public void setDisease(String disease) {
		this.disease = disease;
	}
	
	public Integer getDiseasesum() {
		return diseasesum;
	}
	
	public void setDiseasesum(Integer diseasesum) {
		this.diseasesum = diseasesum;
	}
	public String getMedicareNumber() {
		return medicareNumber;
	}
	public void setMedicareNumber(String medicareNumber) {
		this.medicareNumber = medicareNumber;
	}
	public String getArchiveStatus() {
		return archiveStatus;
	}
	public void setArchiveStatus(String archiveStatus) {
		this.archiveStatus = archiveStatus;
	}
	public String getSpecialistDisease() {
		return specialistDisease;
	}
	public void setSpecialistDisease(String specialistDisease) {
		this.specialistDisease = specialistDisease;
	}
	public String getSpecialistDiseaseName() {
		return specialistDiseaseName;
	}
	public void setSpecialistDiseaseName(String specialistDiseaseName) {
		this.specialistDiseaseName = specialistDiseaseName;
	}
}

+ 73 - 0
common/common-util/src/main/java/com/yihu/jw/util/SqlReplaceService.java

@ -0,0 +1,73 @@
package com.yihu.jw.util;
import com.yihu.jw.entity.util.AesEncryptUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 * Created by liub on 2021/2/3.
 */
@Service
public class SqlReplaceService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     *
     * @param sql select i.* from tableName i where 1=1
     * @param tableAlias i 表别名添加顺序与Map<tableName,DataBaseName>添加的顺序一致
     * @param tableList Map<tableName,DataBaseName>
     * @param encryptColumnList i.idcard
     * @param decryptColumnList i.name
     * @return
     */
//    public String sqlReplace(String sql, List<String> tableAlias, List<Map<String,String>> tableList, List<String> encryptColumnList, List<String> decryptColumnList) {
//
//        if (tableList.size() > 1) {
//            sql = sqlReplace(sql, tableAlias.subList(1, tableAlias.size()), tableList.subList(1, tableList.size()), encryptColumnList, decryptColumnList);
//        }
//        sql = sql.replace("from", "FROM");
//        String sqlSelect = sql.substring(0, sql.indexOf("FROM"));
//        String sqlWHERE = sql.substring(sql.indexOf("FROM"));
//        String tableAlia = tableAlias.size()>0?tableAlias.get(0):"";
//        if (tableList.size() > 0 && tableAlias.size() > 0) {
//            Map<String, String> tab = tableList.get(0);
//            String tableName = "";
//            String tableSchema = "";
//            for (Map.Entry<String, String> vo : tab.entrySet()) {
//                tableName = vo.getKey();
//                tableSchema = vo.getValue();
//            }
//            String sqlColumn = "select COLUMN_NAME from information_schema.COLUMNS where table_name = '" + tableName + "' and table_schema = '" + tableSchema+"'";
//            List<String> columns = jdbcTemplate.queryForList(sqlColumn, String.class);
//            StringBuilder sqlReplaceStringBulider = new StringBuilder();
//            for (String tmp : columns) {
//                sqlReplaceStringBulider.append(tableAlia + "." + tmp + " "+tmp+",");
//            }
//            if (sqlReplaceStringBulider.length() > 0) {
//                sqlReplaceStringBulider.deleteCharAt(sqlReplaceStringBulider.length() - 1);
//            }
//            String sqlReplaceString = sqlReplaceStringBulider.toString();
//            sqlSelect=sqlSelect.replace(tableAlia + ".*", sqlReplaceString);
//        }
//
//        for (String encry : encryptColumnList) {
//            if (encry.contains(tableAlia+".")){
//                sqlSelect= sqlSelect.replace(encry, "to_base64(AES_ENCRYPT(" + encry + ",'" + AesEncryptUtils.DBKEY + "'))");
//            }
//        }
//        for (String decry : decryptColumnList) {
//            if (decry.contains(tableAlia+".")){
//                sqlSelect= sqlSelect.replace(decry, "AES_DECRYPT(from_base64(" + decry + "),'" + AesEncryptUtils.DBKEY + "')");
//            }
//        }
//
//        return sqlSelect + sqlWHERE;
//    }
}

+ 39 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/CommonUtil.java

@ -338,4 +338,43 @@ public class CommonUtil {
            return fileUrls;
        }
    }
    /**
     * 校验图片本地路径掺杂网络路径,统一返回网路路径
     *
     * @param images
     * @throws Exception
     */
    public  String validateImages(String images) throws Exception {
        String imagePath = "";
        String imageUrls = "";
        String imageRow = "";
        String[] imgs = images.split(",");
        for (String image : imgs) {
            if (image.contains("group1")) {
                imageUrls += image + ",";
            } else {
                try {
                    imageRow += copyTempImage(image) + ",";
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        imagePath += imageUrls + imageRow;
        imagePath = imagePath.substring(0, imagePath.length() - 1);
        return imagePath;
    }
    public String getSubString(String content, int min, int max) {
        if (StringUtils.isBlank(content)) {
            return "";
        } else if (content.length() <= max) {
            return content;
        } else {
            return content.substring(min, max);
        }
    }
}

+ 3 - 0
starter/mysql-starter/src/main/java/com/yihu/jw/mysql/query/BaseJpaService.java

@ -1,5 +1,6 @@
package com.yihu.jw.mysql.query;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.lang.SpringContext;
import org.hibernate.query.Query;
import org.hibernate.Session;
@ -349,4 +350,6 @@ public abstract class BaseJpaService<T, R extends CrudRepository> {
        }
        return buffer.toString();
    }
}

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/patient/BasePatientEndpoint.java

@ -7,7 +7,6 @@ import com.yihu.jw.base.dao.servicePackage.ServicePackageRecordDao;
import com.yihu.jw.base.dao.servicePackage.ServicePackageSignRecordDao;
import com.yihu.jw.base.dao.sign.ArchiveDao;
import com.yihu.jw.base.dao.team.BaseTeamDao;
import com.yihu.jw.base.dao.team.WlyyPatientLabelDao;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.contant.CommonContant;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
@ -18,6 +17,7 @@ import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.base.team.BaseTeamDO;
import com.yihu.jw.entity.care.archive.ArchiveDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.label.WlyyPatientLabelDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.restmodel.base.patient.BasePatientVO;

+ 1 - 1
svr/svr-base/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name: svr-base
    name: svr-base --
  cloud:
    config:
      failFast: true

+ 8 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/resource/ResourceIntegratedController.java

@ -436,16 +436,22 @@ public class ResourceIntegratedController extends EnvelopRestEndpoint {
            @RequestParam(value = "resourcesCode", required = true) String resourcesCode,
            @ApiParam(name = "metaData", value = "数据元")
            @RequestParam(value = "metaData", required = true) String metaData,
            @ApiParam(name = "page", value = "数据元")
            @RequestParam(value = "page", required = false) Integer page,
            @ApiParam(name = "rows", value = "数据元")
            @RequestParam(value = "rows", required = false) Integer rows,
            @ApiParam(name = "type", value = "类型 1全部 2当前页(默认全部)", required = false)
            @RequestParam(value = "type", required = false) String type,
            @ApiParam(name = "searchParams", value = "查询条件")
            @RequestParam(value = "searchParams", required = false) String searchParams, HttpServletResponse response) {
        try {
            int pageNum = 1;
            int size = 99999;
            if("2".equals(type)){
                size = 50;
                size = rows;
                pageNum = page;
            }
            Page<Map<String, Object>> result = resourceBrowseService.getCustomizeDataMysql(resourcesCode,metaData,searchParams,1, size);
            Page<Map<String, Object>> result = resourceBrowseService.getCustomizeDataMysql(resourcesCode,metaData,searchParams,pageNum, size);
            List<Map<String, Object>> listMap = result.toList();
            //导出
            String fileName = "档案数据导出";

+ 10 - 2
svr/svr-basic/src/main/java/com/yihu/jw/basic/resource/service/ResourceBrowseService.java

@ -504,6 +504,9 @@ public class ResourceBrowseService extends BaseJpaService {
    public Page<Map<String, Object>> getCustomizeDataMysql(String resourcesCodes, String metaData, String queryCondition, Integer page, Integer size) throws Exception {
        //获取资源编码列表
        List<String> codeList = (List<String>) objectMapper.readValue(resourcesCodes, List.class);
        if(codeList.size()>3){
            throw new ApiException( "不允许同时选择超过3个资源");
        }
        String tableName = "";
        String paramSql = "";
        String where = "";
@ -758,8 +761,13 @@ public class ResourceBrowseService extends BaseJpaService {
                }
                String cond = String.valueOf(item.get("condition")).trim();
                String value = String.valueOf(item.get("value"));
                stringBuffer.append(" "+andOr+" "+field+cond+"'"+value+"' ");
            }
                if(value.contains(",")){
                    value = value.replaceAll(",","','");
                    stringBuffer.append(" "+andOr+" "+field+" in ('"+value+"') ");
                }else {
                    stringBuffer.append(" "+andOr+" "+field+cond+"'"+value+"' ");
                }
                           }
        }
        return stringBuffer;
    }

+ 169 - 146
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/complaint/BaseComplaintEndPoint.java

@ -12,13 +12,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/complaint" )
@RequestMapping("/complaint")
@Api(tags = "投诉管理员管理", description = "互联网医院")
public class BaseComplaintEndPoint  extends EnvelopRestEndpoint {
public class BaseComplaintEndPoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseComplaintService baseComplaintService;
    /**
     * 新增修改投诉类型字典
     *
     * @return
     */
    @GetMapping(value = "/createOrUpdateDict")
@ -28,290 +30,307 @@ public class BaseComplaintEndPoint  extends EnvelopRestEndpoint {
                                      @ApiParam(name = "name", value = "name", required = false)
                                      @RequestParam(value = "name", required = false) String name) throws Exception {
        try {
            return success(baseComplaintService.createOrUpdateDict(id,name)) ;
        }catch (Exception e){
            return success(baseComplaintService.createOrUpdateDict(id, name));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 删除字典
     *
     * @return
     */
    @GetMapping(value = "/deleteComplaintDict")
    @ApiOperation(value = "删除字典", notes = "删除字典")
    public Envelop deleteComplaintDict(@ApiParam(name = "id", value = "id", required = false)
                                      @RequestParam(value = "id", required = false) String id) throws Exception {
                                       @RequestParam(value = "id", required = false) String id) throws Exception {
        try {
            return success(baseComplaintService.deleteDict(id)) ;
        }catch (Exception e){
            return success(baseComplaintService.deleteDict(id));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 查询单条字典
     *
     * @return
     */
    @GetMapping(value = "/findOneComplaintDict")
    @ApiOperation(value = "查询单条字典", notes = "查询单条字典")
    public Envelop findOneComplaintDict(@ApiParam(name = "id", value = "id", required = false)
                                       @RequestParam(value = "id", required = false) String id) throws Exception {
                                        @RequestParam(value = "id", required = false) String id) throws Exception {
        try {
            return success(baseComplaintService.findOneDict(id)) ;
        }catch (Exception e){
            return success(baseComplaintService.findOneDict(id));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 查询字典列表
     *
     * @return
     */
    @GetMapping(value = "/findComplaintDictList")
    @ApiOperation(value = "查询字典列表", notes = "查询字典列表")
    public Envelop findComplaintDictList(@ApiParam(name = "name", value = "name", required = false)
                                        @RequestParam(value = "name", required = false) String name) throws Exception {
                                         @RequestParam(value = "name", required = false) String name) throws Exception {
        try {
            return success(baseComplaintService.findAll(name)) ;
        }catch (Exception e){
            return success(baseComplaintService.findAll(name));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 新增修改投诉管理医生
     *
     * @return
     */
    @GetMapping(value = "/createOrUpdateComplainDoctor")
    @ApiOperation(value = "新增修改投诉管理医生", notes = "新增修改投诉管理医生")
    public Envelop createOrUpdateComplainDoctor(@ApiParam(name = "id", value = "id", required = false)
                                      @RequestParam(value = "id", required = false) String id,
                                      @ApiParam(name = "complaintId", value = "complaintId", required = false)
                                      @RequestParam(value = "complaintId", required = false) String complaintId,
                                                @ApiParam(name = "doctorList", value = "doctorList", required = false)
                                                    @RequestParam(value = "doctorList", required = false) String doctorList,
                                                @ApiParam(name = "deptCode", value = "deptCode", required = false)
                                                    @RequestParam(value = "deptCode", required = false) String deptCode) throws Exception {
    public Envelop createOrUpdateComplainDoctor(
            @ApiParam(name = "id", value = "id", required = false) @RequestParam(value = "id", required = false) String id,
            @ApiParam(name = "complaintId", value = "complaintId", required = false) @RequestParam(value = "complaintId", required = false) String complaintId,
            @ApiParam(name = "doctorList", value = "doctorList", required = false) @RequestParam(value = "doctorList", required = false) String doctorList,
            @ApiParam(name = "deptCode", value = "deptCode", required = false) @RequestParam(value = "deptCode", required = false) String deptCode
    ) throws Exception {
        try {
            baseComplaintService.createOrUpdateComplainDoctor( id, complaintId , doctorList);
            return success() ;
        }catch (Exception e){
            baseComplaintService.createOrUpdateComplainDoctor(id, complaintId, doctorList);
            return success();
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 删除医生
     *
     * @return
     */
    @GetMapping(value = "/deleteComplaintDoctor")
    @ApiOperation(value = "删除医生", notes = "删除医生")
    public Envelop deleteComplaintDoctor(@ApiParam(name = "id", value = "id", required = false)
                                       @RequestParam(value = "id", required = false) String id) throws Exception {
                                         @RequestParam(value = "id", required = false) String id) throws Exception {
        try {
            return success(baseComplaintService.deleteDoctorComplain(id)) ;
        }catch (Exception e){
            return success(baseComplaintService.deleteDoctorComplain(id));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 查询管理医生单条
     *
     * @return
     */
    @GetMapping(value = "/findOneComplaintDoctor")
    @ApiOperation(value = "查询管理医生单条", notes = "查询管理医生单条")
    public Envelop findOneComplaintDoctor(@ApiParam(name = "id", value = "id", required = false)
                                        @RequestParam(value = "id", required = false) String id) throws Exception {
                                          @RequestParam(value = "id", required = false) String id) throws Exception {
        try {
            return success(baseComplaintService.findOneDoctorComplain(id)) ;
        }catch (Exception e){
            return success(baseComplaintService.findOneDoctorComplain(id));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 查询医生列表
     *
     * @return
     */
    @GetMapping(value = "/findComplaintDoctorList")
    @ApiOperation(value = "查询医生列表", notes = "查询医生列表")
    public MixEnvelop findComplaintDoctorList(@ApiParam(name = "doctorName", value = "doctorName", required = false)
                                         @RequestParam(value = "doctorName", required = false) String doctorName,
                                              @ApiParam(name = "doctor", value = "doctor", required = false)
                                              @RequestParam(value = "doctor", required = false) String doctor,
                                              @ApiParam(name = "deptName", value = "deptName", required = false)
                                           @RequestParam(value = "deptName", required = false) String deptName,
                                              @ApiParam(name = "complaintType", value = "complaintType", required = false)
                                               @RequestParam(value = "complaintType", required = false) String complaintType,
                                              @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
                                           ) throws Exception {
    public MixEnvelop findComplaintDoctorList(
            @ApiParam(name = "doctorName", value = "doctorName", required = false) @RequestParam(value = "doctorName", required = false) String doctorName,
            @ApiParam(name = "doctor", value = "doctor", required = false) @RequestParam(value = "doctor", required = false) String doctor,
            @ApiParam(name = "deptName", value = "deptName", required = false) @RequestParam(value = "deptName", required = false) String deptName,
            @ApiParam(name = "complaintType", value = "complaintType", required = false) @RequestParam(value = "complaintType", required = false) String complaintType,
            @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
    ) throws Exception {
        try {
            return baseComplaintService.findComplaintDoctor(doctor, doctorName, deptName, complaintType, page, pageSize);
        } catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    /**
     * 查询医生列表
     *
     * @return
     */
    @GetMapping(value = "/findComplaintDoctorNew")
    @ApiOperation(value = "查询医生列表", notes = "查询医生列表")
    public MixEnvelop findComplaintDoctorNew(
            @ApiParam(name = "doctorName", value = "doctorName", required = false) @RequestParam(value = "doctorName", required = false) String doctorName,
            @ApiParam(name = "doctor", value = "doctor", required = false) @RequestParam(value = "doctor", required = false) String doctor,
            @ApiParam(name = "deptName", value = "deptName", required = false) @RequestParam(value = "deptName", required = false) String deptName,
            @ApiParam(name = "complaintType", value = "complaintType", required = false) @RequestParam(value = "complaintType", required = false) String complaintType,
            @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
    ) throws Exception {
        try {
            return baseComplaintService.findComplaintDoctor(doctor,doctorName,deptName,complaintType,page,pageSize) ;
        }catch (Exception e){
            return baseComplaintService.findComplaintDoctorNew(doctor, doctorName, deptName, complaintType, page, pageSize);
        } catch (Exception e) {
            return failedMixEnvelopException(e);
        }
    }
    /**
     * 患者投诉
     *
     * @return
     */
    @PostMapping(value = "/patiemtComplaint")
    @ApiOperation(value = "患者投诉", notes = "患者投诉")
    public Envelop patiemtComplaint(@ApiParam(name = "json", value = "json", required = false)
                                          @RequestParam(value = "json", required = false) String json) throws Exception {
                                    @RequestParam(value = "json", required = false) String json) throws Exception {
        try {
            return success(baseComplaintService.patiemtComplaint(json)) ;
        }catch (Exception e){
            return success(baseComplaintService.patiemtComplaint(json));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 转交投诉
     *
     * @return
     */
    @PostMapping(value = "/passTo")
    @ApiOperation(value = "转交投诉", notes = "转交投诉")
    public Envelop passTo(@ApiParam(name = "id", value = "id", required = false)
                                    @RequestParam(value = "id", required = false) String id,
                          @ApiParam(name = "complaintId", value = "complaintId", required = false)
                          @RequestParam(value = "complaintId", required = false) String complaintId,
                          @ApiParam(name = "doctor", value = "doctor", required = false)
                              @RequestParam(value = "doctor", required = false) String doctor,
                          @ApiParam(name = "reason", value = "reason", required = false)
                              @RequestParam(value = "reason", required = false) String reason,
                          @ApiParam(name = "operator", value = "operator", required = false)
                              @RequestParam(value = "operator", required = false) String operator) throws Exception {
    public Envelop passTo(
            @ApiParam(name = "id", value = "id", required = false) @RequestParam(value = "id", required = false) String id,
            @ApiParam(name = "complaintId", value = "complaintId", required = false) @RequestParam(value = "complaintId", required = false) String complaintId,
            @ApiParam(name = "doctor", value = "doctor", required = false) @RequestParam(value = "doctor", required = false) String doctor,
            @ApiParam(name = "reason", value = "reason", required = false) @RequestParam(value = "reason", required = false) String reason,
            @ApiParam(name = "operator", value = "operator", required = false) @RequestParam(value = "operator", required = false) String operator
    ) throws Exception {
        try {
            return success(baseComplaintService.passTo(id,complaintId,doctor,operator,reason)) ;
        }catch (Exception e){
            return success(baseComplaintService.passTo(id, complaintId, doctor, operator, reason));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 接受
     *
     * @return
     */
    @GetMapping(value = "/doctorAccept")
    @ApiOperation(value = "接受投诉", notes = "接受投诉")
    public Envelop doctorAccept(@ApiParam(name = "id", value = "id", required = false)
                          @RequestParam(value = "id", required = false) String id,
                          @ApiParam(name = "doctor", value = "doctor", required = false)
                          @RequestParam(value = "doctor", required = false) String doctor) throws Exception {
    public Envelop doctorAccept(
            @ApiParam(name = "id", value = "id", required = false) @RequestParam(value = "id", required = false) String id,
            @ApiParam(name = "doctor", value = "doctor", required = false) @RequestParam(value = "doctor", required = false) String doctor
    ) throws Exception {
        try {
            return success(baseComplaintService.doctorAccept(id,doctor)) ;
        }catch (Exception e){
            return success(baseComplaintService.doctorAccept(id, doctor));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 反馈投诉
     *
     * @return
     */
    @GetMapping(value = "/dealComplaint")
    @ApiOperation(value = "反馈投诉", notes = "反馈投诉")
    public Envelop dealComplaint(@ApiParam(name = "id", value = "id", required = false)
                                @RequestParam(value = "id", required = false) String id,
                                 @ApiParam(name = "operator", value = "operator", required = false)
                                 @RequestParam(value = "operator", required = false) String operator,
                                 @ApiParam(name = "content", value = "content", required = false)
                                     @RequestParam(value = "content", required = false) String content,
                                 @ApiParam(name = "imgUrl", value = "imgUrl", required = false)
                                     @RequestParam(value = "imgUrl", required = false) String imgUrl,
                                 @ApiParam(name = "deptCode", value = "deptCode", required = false)
                                     @RequestParam(value = "deptCode", required = false) String deptCode,
                                @ApiParam(name = "doctor", value = "doctor", required = false)
                                @RequestParam(value = "doctor", required = false) String doctor) throws Exception {
    public Envelop dealComplaint(
            @ApiParam(name = "id", value = "id", required = false) @RequestParam(value = "id", required = false) String id,
            @ApiParam(name = "operator", value = "operator", required = false) @RequestParam(value = "operator", required = false) String operator,
            @ApiParam(name = "content", value = "content", required = false) @RequestParam(value = "content", required = false) String content,
            @ApiParam(name = "imgUrl", value = "imgUrl", required = false) @RequestParam(value = "imgUrl", required = false) String imgUrl,
            @ApiParam(name = "deptCode", value = "deptCode", required = false) @RequestParam(value = "deptCode", required = false) String deptCode,
            @ApiParam(name = "doctor", value = "doctor", required = false) @RequestParam(value = "doctor", required = false) String doctor
    ) throws Exception {
        try {
            return success(baseComplaintService.dealComplaint(id,operator,content,imgUrl,deptCode)) ;
        }catch (Exception e){
            return success(baseComplaintService.dealComplaint(id, operator, content, imgUrl, deptCode));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 反馈投诉
     *
     * @return
     */
    @GetMapping(value = "/findComplaintList")
    @ApiOperation(value = "查询投诉建议列表", notes = "查询投诉建议列表")
    public Envelop findComplaintList(@ApiParam(name = "doctor", value = "doctor", required = false)
                                 @RequestParam(value = "doctor", required = false) String doctor,
                                 @ApiParam(name = "status", value = "status", required = false)
                                 @RequestParam(value = "status", required = false) String status,
                                     @ApiParam(name = "role", value = "role", required = false)
                                         @RequestParam(value = "role", required = false) String role,
                                 @ApiParam(name = "patientName", value = "patientName", required = false)
                                 @RequestParam(value = "patientName", required = false) String patientName,
                                 @ApiParam(name = "patientId", value = "patientId", required = false)
                                 @RequestParam(value = "patientId", required = false) String patientId,
                                 @ApiParam(name = "keyWord", value = "keyWord", required = false)
                                 @RequestParam(value = "keyWord", required = false) String keyWord,
                                     @ApiParam(name = "complaintId", value = "complaintId", required = false)
                                         @RequestParam(value = "complaintId", required = false) String complaintId,
                                     @ApiParam(name = "endTime", value = "endTime", required = false)
                                         @RequestParam(value = "endTime", required = false) String endTime,
                                     @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,
                                 @ApiParam(name = "startTime", value = "startTime", required = false)
                                 @RequestParam(value = "startTime", required = false) String startTime) throws Exception {
    public Envelop findComplaintList(
            @ApiParam(name = "doctor", value = "doctor", required = false) @RequestParam(value = "doctor", required = false) String doctor,
            @ApiParam(name = "status", value = "status", required = false) @RequestParam(value = "status", required = false) String status,
            @ApiParam(name = "role", value = "role", required = false) @RequestParam(value = "role", required = false) String role,
            @ApiParam(name = "patientName", value = "patientName", required = false) @RequestParam(value = "patientName", required = false) String patientName,
            @ApiParam(name = "patientId", value = "patientId", required = false) @RequestParam(value = "patientId", required = false) String patientId,
            @ApiParam(name = "keyWord", value = "keyWord", required = false) @RequestParam(value = "keyWord", required = false) String keyWord,
            @ApiParam(name = "complaintId", value = "complaintId", required = false) @RequestParam(value = "complaintId", required = false) String complaintId,
            @ApiParam(name = "endTime", value = "endTime", required = false) @RequestParam(value = "endTime", required = false) String endTime,
            @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,
            @ApiParam(name = "startTime", value = "startTime", required = false) @RequestParam(value = "startTime", required = false) String startTime
    ) throws Exception {
        try {
            if (!StringUtils.isNotBlank(doctor)){
                doctor=getUID();
            if (!StringUtils.isNotBlank(doctor)) {
                doctor = getUID();
            }
            return success(baseComplaintService.findComplaintList(role, doctor, status, patientName, patientId, keyWord,complaintId,
                     startTime, endTime, page , pageSize)) ;
        }catch (Exception e){
            return success(baseComplaintService.findComplaintList(role, doctor, status, patientName, patientId, keyWord, complaintId,
                    startTime, endTime, page, pageSize));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 查询投诉建议单挑
     *
     * @return
     */
    @GetMapping(value = "/findOnePaitentComplaint")
    @ApiOperation(value = "查询投诉建议单条", notes = "查询投诉建议单条")
    public Envelop findOnePaitentComplaint(@ApiParam(name = "id", value = "id", required = false)
                                          @RequestParam(value = "id", required = false) String id) throws Exception {
                                           @RequestParam(value = "id", required = false) String id) throws Exception {
        try {
            return success(baseComplaintService.findOnePaitentComplaint(id)) ;
        }catch (Exception e){
            return success(baseComplaintService.findOnePaitentComplaint(id));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 居民反馈查询
     *
     * @return
     */
    @GetMapping(value = "/findPatientComplaintList")
    @ApiOperation(value = "查询投诉建议列表", notes = "查询投诉建议列表")
    public Envelop findPatientComplaintList(
                                     @ApiParam(name = "status", value = "status", required = false)
                                     @RequestParam(value = "status", required = false) String status,
                                     @ApiParam(name = "patientName", value = "patientName", required = false)
                                     @RequestParam(value = "patientName", required = false) String patientName,
                                     @ApiParam(name = "patientId", value = "patientId", required = false)
                                     @RequestParam(value = "patientId", required = false) String patientId,
                                     @ApiParam(name = "complaintType", value = "complaintType", required = false)
                                     @RequestParam(value = "complaintType", required = false) String complaintType,
                                     @ApiParam(name = "endTime", value = "endTime", required = false)
                                     @RequestParam(value = "endTime", required = false) String endTime,
                                     @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,
                                     @ApiParam(name = "startTime", value = "startTime", required = false)
                                     @RequestParam(value = "startTime", required = false) String startTime) throws Exception {
            @ApiParam(name = "status", value = "status", required = false) @RequestParam(value = "status", required = false) String status,
            @ApiParam(name = "patientName", value = "patientName", required = false) @RequestParam(value = "patientName", required = false) String patientName,
            @ApiParam(name = "patientId", value = "patientId", required = false) @RequestParam(value = "patientId", required = false) String patientId,
            @ApiParam(name = "complaintType", value = "complaintType", required = false) @RequestParam(value = "complaintType", required = false) String complaintType,
            @ApiParam(name = "endTime", value = "endTime", required = false) @RequestParam(value = "endTime", required = false) String endTime,
            @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,
            @ApiParam(name = "startTime", value = "startTime", required = false) @RequestParam(value = "startTime", required = false) String startTime
    ) throws Exception {
        try {
            return success(baseComplaintService.findPatientComplaintList(  status, patientName, patientId,
                    startTime, endTime,complaintType, page , pageSize)) ;
        }catch (Exception e){
            return success(baseComplaintService.findPatientComplaintList(status, patientName, patientId,
                    startTime, endTime, complaintType, page, pageSize));
        } catch (Exception e) {
            return failedException(e);
        }
    }
@ -319,63 +338,67 @@ public class BaseComplaintEndPoint  extends EnvelopRestEndpoint {
    /**
     * 查询投诉建议单挑
     *
     * @return
     */
    @GetMapping(value = "/findComplaintCount")
    @ApiOperation(value = "查询投诉建议数量", notes = "查询投诉建议单挑")
    public Envelop findComplaintCount(@ApiParam(name = "doctor", value = "doctor", required = false)
                                      @RequestParam(value = "doctor", required = false) String doctor,
                                      @ApiParam(name = "role", value = "role", required = false)
                                      @RequestParam(value = "role", required = false) String role) throws Exception {
    public Envelop findComplaintCount(
            @ApiParam(name = "doctor", value = "doctor", required = false) @RequestParam(value = "doctor", required = false) String doctor,
            @ApiParam(name = "role", value = "role", required = false) @RequestParam(value = "role", required = false) String role) throws Exception {
        try {
            return success(baseComplaintService.findComplaintCount(doctor,role)) ;
        }catch (Exception e){
            return success(baseComplaintService.findComplaintCount(doctor, role));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 查询投诉建议单挑
     *
     * @return
     */
    @GetMapping(value = "/findComplaintCountByPatient")
    @ApiOperation(value = "患者查询投诉建议数量", notes = "患者查询投诉建议数量")
    public Envelop findComplaintCountByPatient(@ApiParam(name = "patient", value = "patient", required = false)
                                      @RequestParam(value = "patient", required = false) String patient) throws Exception {
                                               @RequestParam(value = "patient", required = false) String patient) throws Exception {
        try {
            return success(baseComplaintService.findComplaintCountPatient(patient)) ;
        }catch (Exception e){
            return success(baseComplaintService.findComplaintCountPatient(patient));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 居民撤销反馈
     *
     * @return
     */
    @GetMapping(value = "/cancelPatientComplaint")
    @ApiOperation(value = "居民撤销反馈", notes = "居民撤销反馈")
    public Envelop cancelPatientComplaint(@ApiParam(name = "id", value = "id", required = false)
                                               @RequestParam(value = "id", required = false) String id,
                                          @RequestParam(value = "id", required = false) String id,
                                          @ApiParam(name = "patient", value = "patient", required = false)
                                          @RequestParam(value = "patient", required = false) String patient) throws Exception {
        try {
            return success(baseComplaintService.cancelPaitentComplaint(id,patient)) ;
        }catch (Exception e){
            return success(baseComplaintService.cancelPaitentComplaint(id, patient));
        } catch (Exception e) {
            return failedException(e);
        }
    }
    /**
     * 查询进度
     *
     * @return
     */
    @GetMapping(value = "/findComplaintOperateLog")
    @ApiOperation(value = "查询反馈进度", notes = "查询反馈进度")
    public Envelop findComplaintOperateLog(@ApiParam(name = "id", value = "id", required = false)
                                          @RequestParam(value = "id", required = false) String id) throws Exception {
                                           @RequestParam(value = "id", required = false) String id) throws Exception {
        try {
            return success(baseComplaintService.findComplaintOperateLog(id)) ;
        }catch (Exception e){
            return success(baseComplaintService.findComplaintOperateLog(id));
        } catch (Exception e) {
            return failedException(e);
        }
    }

+ 38 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java

@ -1843,6 +1843,44 @@ class EsStatisticsEndpoint extends EnvelopRestEndpoint {
    }
    /**
     * 获取同安签约的慢病数据
     *  /wlyygc/tongan/hospital/getChronicDiseaseData
     */
    @GetMapping(value = "/getChronicDiseaseData")
    @ApiOperation(value = "获取同安签约的慢病数据")
    public Envelop getChronicDiseaseData() {
        try {
            System.out.println("调用==>获取同安签约的慢病数据");
            Map<String, Object> result = statisticsEsService.getChronicDiseaseData();
            return success(result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("系统繁忙");
        }
    }
    /**
     * 将i健康慢病签约数据创建成用户
     */
    @GetMapping(value = "/createPatient")
    @ApiOperation(value = "将i健康慢病签约数据创建成用户")
    public Envelop createPatient() {
        try {
            System.out.println("调用==>将i健康慢病签约数据创建成用户");
            Map<String, Object> result = statisticsEsService.getChronicDiseaseData();
            Object data = result.get("data");
            //循环创建用户
            return success(result);
        } catch (Exception e) {
            e.printStackTrace();
            return failed("系统繁忙");
        }
    }
}

+ 0 - 6
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/team/DoctorTeamEndpoint.java

@ -1,8 +1,6 @@
package com.yihu.jw.hospital.endpoint.team;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.team.service.TeamService;
import com.yihu.jw.wlyy.service.WlyyBusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -20,12 +18,8 @@ import org.springframework.web.bind.annotation.RestController;
@Api(value = "医生团队",  tags = {"医生团队"})
public class DoctorTeamEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private TeamService teamService;
    @Autowired
    private WlyyBusinessService wlyyBusinessService;
    @Autowired
    private BasePatientDao patientDao;
    private static final String TONGAN_TOWN = "350212";
    @GetMapping(value = "doctorInfo")

+ 3 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeCategoryService.java

@ -48,6 +48,9 @@ public class KnowledgeCategoryService extends BaseJpaService<KnowledgeCategoryDO
			knowledgeCategoryDO.setDel(one.getDel());
			knowledgeCategoryDO.setUpdateTime(new Date());
		}
		if(knowledgeCategoryDO.getIsCheck()==null){
			knowledgeCategoryDO.setIsCheck(1);
		}
		return knowledgeCategoryDao.save(knowledgeCategoryDO);
	}
	

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

@ -1,6 +1,6 @@
spring:
  application:
    name:  svr-internet-hospital
    name:  svr-internet-hospital--
  cloud:
    config:
      failFast: true

+ 108 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/LabelController.java

@ -0,0 +1,108 @@
package com.yihu.jw.hospital.module.common;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.hospital.module.common.service.LabelService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.entity.ServiceException;
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.web.bind.annotation.*;
import java.util.List;
/**
 * Created by yeshijie on 2024/3/4.
 */
@RestController
@RequestMapping("patientLable")
@Api(tags = "居民标签")
public class LabelController extends EnvelopRestEndpoint {
    @Autowired
    private LabelService labelService;
    @GetMapping(value = "patientLabelLogPage")
    @ApiOperation(value = "查询标签新增日志", notes = "查询标签新增日志")
    public Envelop patientLabelLogPage(@ApiParam(name = "patient", value = "居民id")
                                       @RequestParam(value = "patient", required = false) String patient,
                                       @ApiParam(name = "doctor", value = "医生id")
                                       @RequestParam(value = "doctor", required = false) String doctor,
                                       @ApiParam(name = "labelType", value = "标签类型")
                                       @RequestParam(value = "labelType", required = false) String labelType,
                                       @ApiParam(name = "page", value = "第几页")
                                       @RequestParam(value = "page", required = true) Integer page,
                                       @ApiParam(name = "size", value = "每页大小")
                                       @RequestParam(value = "size", required = true) Integer size) {
        try {
            return labelService.patientLabelLogPage(patient, doctor, labelType, page, size);
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping(value = "existDisease")
    @ApiOperation(value = "查询专病的康复管理未执行完成数量")
    public ObjEnvelop existDisease(@ApiParam(name = "patient", value = "居民id")
                                    @RequestParam(value = "patient", required = true) String patient,
                                    @ApiParam(name = "disease", value = "专病id")
                                    @RequestParam(value = "disease", required = true) String disease) {
        try {
            return ObjEnvelop.getSuccess("查询成功", labelService.existDisease(patient,disease));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "findPatientLabel")
    @ApiOperation(value = "查询居民标签列表")
    public ListEnvelop findPatientLabel(@ApiParam(name = "patient", value = "居民id")
                                        @RequestParam(value = "patient", required = true) String patient) {
        try {
            return ListEnvelop.getSuccess("查询成功", labelService.findByPatient(patient));
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @PostMapping(value = "savePatientLabel")
    @ApiOperation(value = "保存居民标签", notes = "保存居民标签")
    public Envelop savePatientLabel(@ApiParam(name = "patient", value = "居民ID")
                                    @RequestParam(value = "patient", required = true) String patient,
                                    @ApiParam(name = "doctor", value = "医生ID")
                                    @RequestParam(value = "doctor", required = true) String doctor,
                                    @ApiParam(name = "labelDOS", value = "标签集合",required = false)
                                    @RequestParam(value = "labelDOS", required = false) String labelDOS) {
        try {
            List<WlyyPatientLabelDO> labels = null;
            if(StringUtils.isNotBlank(labelDOS)){
                labels = JSONObject.parseArray(labelDOS,WlyyPatientLabelDO.class);
            }
            labelService.savePatientLabel(labels,patient,doctor);
            return success("保存成功");
        } catch (Exception e) {
            return failedException2(e);
        }
    }
    @PostMapping(value = "addLabelDict")
    @ApiOperation(value = "添加自定义标签字典", notes = "添加自定义标签字典")
    public ObjEnvelop addLabelDict(@ApiParam(name = "labelName", value = "标签名称")
                                   @RequestParam(value = "labelName", required = true) String labelName) {
        try {
            return success(labelService.addLabelDict(labelName));
        }catch (ServiceException se){
            return ObjEnvelop.getError(se.getMessage());
        }catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
}

+ 143 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/common/service/LabelService.java

@ -0,0 +1,143 @@
package com.yihu.jw.hospital.module.common.service;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelLogDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.label.WlyyPatientLabelDao;
import com.yihu.jw.label.WlyyPatientLabelLogDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.entity.ServiceException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.*;
/**
 * Created by yeshijie on 2024/3/4.
 */
@Service
public class LabelService {
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private WlyyPatientLabelDao patientLabelDao;
    @Autowired
    private WlyyPatientLabelLogDao logDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public List<WlyyPatientLabelDO> findByPatient(String patient){
        return patientLabelDao.findByPatient(patient);
    }
    //查询专病的康复管理未执行完成数量
    public int existDisease(String patient,String disease){
        String sql = "SELECT COUNT(id) from wlyy_patient_rehabilitation_plan " +
                " WHERE patient='"+patient+"' and disease ='"+disease+"' and `status` in (1,3)";
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }
    //添加专病标签
    public void addDiseaseLable(String patient,String disease,String diseaseName){
        try {
            if(patientLabelDao.findByPatient(patient,disease,"3").size()==0){
                WlyyPatientLabelDO label = new WlyyPatientLabelDO();
                label.setCzrq(new Date());
                label.setIsSystem(0);
                label.setPatient(patient);
                label.setLabelCode(disease);
                label.setLabelName(diseaseName);
                label.setLabelType("3");
                patientLabelDao.save(label);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    //查询标签新增日志
    public PageEnvelop patientLabelLogPage(String patient, String doctor, String labelType, int page, int size){
        String sql = "select * ";
        String countSql = "select count(*) ";
        String filter = " from wlyy_patient_label_log where 1=1 ";
        String orderBy = " order by create_time desc limit "+(page-1)*size+","+size;
        if(StringUtils.isNotBlank(patient)){
            filter += " and patient = '"+patient+"' ";
        }
        if(StringUtils.isNotBlank(doctor)){
            filter += " and doctor = '"+doctor+"' ";
        }
        if(StringUtils.isNotBlank(labelType)){
            filter += " and label_type = '"+labelType+"' ";
        }
        List<WlyyPatientLabelLogDO> logDOS = jdbcTemplate.query(sql+filter+orderBy,new BeanPropertyRowMapper<>(WlyyPatientLabelLogDO.class));
        Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",logDOS,page,size,count);
    }
    //保存居民标签
    public void savePatientLabel(List<WlyyPatientLabelDO> labelDOS, String patient,String doctor) throws Exception{
        List<WlyyPatientLabelDO> patientLabelDOS = patientLabelDao.findByPatient(patient);
        Map<String,String> map = new HashMap<>();
        for (WlyyPatientLabelDO label:patientLabelDOS){
            String labelCode = label.getLabelCode();
            String labelType = label.getLabelType();
            map.put(labelType+"_"+labelCode,label.getLabelName());
        }
        patientLabelDao.deleteByPatient(patient);
        List<WlyyPatientLabelLogDO> labelLogDOS = new ArrayList<>();
        Date now = new Date();
        BaseDoctorDO doctorDO = doctorDao.findByIdAndDel(doctor);
        if(labelDOS!=null&&labelDOS.size()>0){
            for (WlyyPatientLabelDO label:labelDOS){
                label.setPatient(patient);
                label.setCzrq(new Date());
                label.setIsSystem(0);
                String key = label.getLabelType()+"_"+label.getLabelCode();
                if(!map.containsKey(key)){
                    WlyyPatientLabelLogDO logDO = new WlyyPatientLabelLogDO();
                    logDO.setCreateTime(now);
                    logDO.setPatient(patient);
                    logDO.setDoctor(doctor);
                    logDO.setDoctorName(doctorDO.getName());
                    logDO.setLabelCode(label.getLabelCode());
                    logDO.setLabelName(label.getLabelName());
                    logDO.setLabelType(label.getLabelType());
                    logDO.setJobTitle(doctorDO.getJobTitleName());
                    labelLogDOS.add(logDO);
                }
            }
            patientLabelDao.saveAll(labelDOS);
            if(labelLogDOS.size()>0){
                logDao.saveAll(labelLogDOS);
            }
        }
    }
    //添加自定义标签字典
    public WlyyHospitalSysDictDO addLabelDict(String labelName) throws Exception{
        if(StringUtils.isBlank(labelName)){
            throw new ServiceException("请填写分组名称");
        }
        labelName = labelName.trim();
        List<WlyyHospitalSysDictDO> dictDOList = wlyyHospitalSysDictDao.findByDictNameAndDictCode("patient_lable_custom",labelName);
        if(dictDOList.size()>0){
            throw new ServiceException("该分组已存在");
        }
        WlyyHospitalSysDictDO dictDO = new WlyyHospitalSysDictDO();
        dictDO.setDictValue(labelName);
        dictDO.setDictCode(labelName);
        dictDO.setDictName("patient_lable_custom");
        dictDO = wlyyHospitalSysDictDao.save(dictDO);
        return dictDO;
    }
}

+ 3 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/service/ConsultService.java

@ -2,9 +2,11 @@
package com.yihu.jw.hospital.module.consult.service;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.im.util.SendPatientUtil;
import com.yihu.jw.order.dao.ConsultOrderDao;
import com.yihu.jw.util.http.HttpClientUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -147,7 +149,7 @@ public class ConsultService {
//    public void sendMucMessageBySingnType(String doctor, String doctorName, String patient, String content, String contentType, String title) {
//        Doctor d = doctorDao.findByCode(doctor);
//        BaseDoctorDO d = doctorDao.findById(doctor).orElse(null)
//        SignFamily signFamily = signFamilyDao.findByPatient(patient);//当前签约团队
//        if (signFamily == null) {
//            List<SignFamily> signFamilys = signFamilyDao.findLastJySignByPatient(patient, 2);//获取旧的家庭签约关系

+ 1 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/WlyyDoorServiceOrderService.java

@ -654,7 +654,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
    /**
     * 创建上门服务工单
     */
    @Transactional(rollbackFor = Exception.class)
//    @Transactional(rollbackFor = Exception.class)
    public JSONObject create(String jsonData) throws Exception {
        logger.info("创建上门服务jsonData参数:" + jsonData);

+ 414 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/ChronicDiseaseController.java

@ -0,0 +1,414 @@
package com.yihu.jw.hospital.module.health.controller;
import com.yihu.jw.entity.scheme.vo.DoctorSchemeBloodPressureVO;
import com.yihu.jw.entity.scheme.vo.DoctorSchemeBloodSuggerVO;
import com.yihu.jw.hospital.module.health.service.scheme.DoctorSchemeService;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
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;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author suqinyi
 * @Date 2024/2/26
 */
@RestController
@RequestMapping(value = "/doctor/scheme")
@Api(value = "慢病管理", description = "慢病管理", tags = {"慢病管理"})
public class ChronicDiseaseController extends EnvelopRestEndpoint {
    @Autowired
    private DoctorSchemeService doctorSchemeService;
    /**
     * 获取i健康的数据-同安签约居民,并且是三院关系的,有慢病的
     */
    @RequestMapping(value = "getSignPatientDataByIjk", method = RequestMethod.GET)
    @ApiOperation("获取i健康的数据-同安签约居民,并且是三院关系的,有慢病的")
    public String getSignPatientDataByIjk() {
        return null;
    }
    @RequestMapping(value = "getDoctorSwitchTrackPatient", method = RequestMethod.GET)
    @ApiOperation("医生跟踪预警居民开关接口")
    public String getDoctorSwitchTrackPatient(
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = false) String doctorId) {
        try {
            if (StringUtils.isBlank(doctorId)) {
                doctorId = getUID();
            }
            return write(200, "查询成功", "data", doctorSchemeService.getDoctorSwitchTrackPatient(doctorId));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "setDoctorSwitchTrackPatient", method = RequestMethod.POST)
    @ApiOperation("医生跟踪预警居民开关接口")
    public String setDoctorSwitchTrackPatient(
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = false) String doctorId,
            @ApiParam(name = "state", value = "0不自动跟踪居民,1自动跟踪预警居民") @RequestParam(value = "state", required = true) String state
    ) {
        try {
            if (StringUtils.isBlank(doctorId)) {
                doctorId = getUID();
            }
            return write(200, "操作成功", "data", doctorSchemeService.setDoctorSwitchTrackPatient(doctorId, state));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/slowdisease/get/teaminfos", method = RequestMethod.GET)
    @ApiOperation("医生端-获取慢病管理居民管理端数据")
    public String getDiseasePatientCodes(
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = false) String doctorId,
            @ApiParam(name = "getcolor", value = "是否获取颜色标签") @RequestParam(value = "getcolor", required = true, defaultValue = "1") int getcolor,
            @ApiParam(name = "getstands", value = "是否获取预警人数数据") @RequestParam(value = "getstands", required = true, defaultValue = "1") int getstands,
            @ApiParam(name = "gethealthindex", value = "是否获取体征数据") @RequestParam(value = "gethealthindex", required = true, defaultValue = "1") int gethealthindex,
            @ApiParam(name = "startdate", value = "体征数据开始时间yyyy-mm-dd hh:mm:ss") @RequestParam(value = "startdate", required = false, defaultValue = "2017-9-10 00:00:00") String startdate,
            @ApiParam(name = "enddate", value = "体征数据结束时间yyyy-mm-dd hh:mm:ss") @RequestParam(value = "enddate", required = false, defaultValue = "2017-9-16 23:59:59") String enddate) {
        try {
            if (StringUtils.isBlank(doctorId)) {
                doctorId = getUID();
            }
            com.alibaba.fastjson.JSONObject result = doctorSchemeService.getSlowDiseaseTeaminfos(null, getcolor, getstands, gethealthindex, startdate, enddate, doctorId);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/get/disease/patientcodes", method = RequestMethod.GET)
    @ApiOperation("医生端-根据居民标签/病情/设备绑定状态查询团队居民CODE列表")
    public String getDiseasePatientCodes(
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = false, defaultValue = "") String doctorId,
            @ApiParam(name = "disease", value = "疾病类型,-1全部,0健康,1高血压,2糖尿病,3高血压+糖尿病", defaultValue = "-1") @RequestParam(value = "disease", required = true) Integer disease,
            @ApiParam(name = "diseaseCondition", value = "居民标签:0绿标,1黄标,2红标", defaultValue = "0,1,2") @RequestParam(value = "diseaseCondition", required = true) String diseaseCondition,
            @ApiParam(name = "deviceType", value = "设备类型:-1全部,0未绑定,1已绑定", defaultValue = "-1") @RequestParam(value = "deviceType", required = true) Integer deviceType,
            @ApiParam(name = "trackFlag", value = "过滤跟踪居民:1为过滤跟踪,不传或其他值为不过滤", defaultValue = "-1") @RequestParam(value = "trackFlag", required = false) String trackFlag
    ) {
        try {
            if (StringUtils.isBlank(doctorId)) {
                doctorId = getUID();
            }
            List<String> result = doctorSchemeService.getPatientsByDiseaseConditionDiseaseDeviceType(null, disease, diseaseCondition, deviceType, doctorId, trackFlag);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/get/bloodsugger/list", method = RequestMethod.GET)
    @ApiOperation("医生获取自己的血糖监测方案列表")
    public String getDoctorSchemeBloodSuggerList(
            @ApiParam(name = "doctorcode", value = "医生CODE") @RequestParam(value = "doctorcode", required = true) String doctorcode) {
        try {
            List<DoctorSchemeBloodSuggerVO> result = doctorSchemeService.getDoctorScheBloodSuggerList(doctorcode);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            //日志文件中记录异常信息
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/get/bloodpressure/list", method = RequestMethod.GET)
    @ApiOperation("医生获取自己的血压监测方案列表")
    public String getDoctorSchemeBloodPressureList(
            @ApiParam(name = "doctorcode", value = "医生CODE") @RequestParam(value = "doctorcode", required = true) String doctorcode) {
        try {
            List<DoctorSchemeBloodPressureVO> result = doctorSchemeService.getDoctorSchemeBloodPressureList(doctorcode);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/post/save/bloodpressure", method = RequestMethod.POST)
    @ApiOperation("医生保存血压监测方案")
    public String saveDoctorSchemeBloodPressure(
            @ApiParam(name = "data", value = "JSON数据") @RequestParam(value = "data", required = true) String data) {
        try {
            doctorSchemeService.saveDoctorSchemeBloodPressure(data);
            return write(200, "操作成功");
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/post/save/bloodsugger", method = RequestMethod.POST)
    @ApiOperation("医生保存血糖监测方案")
    public String saveDoctorSchemeBloodSugger(
            @ApiParam(name = "data", value = "JSON数据") @RequestParam(value = "data", required = true) String data) {
        try {
            doctorSchemeService.saveDoctorSchemeBloodSugger(data);
            return write(200, "操作成功");
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/post/save/patient/scheme", method = RequestMethod.POST)
    @ApiOperation("医生保存居民的血糖监测方案")
    public String savePatientScheme(
            @ApiParam(name = "doctorcode", value = "医生CODE") @RequestParam(value = "doctorcode", required = true) String doctorcode,
            @ApiParam(name = "schemecode", value = "方案CODE") @RequestParam(value = "schemecode", required = true) String schemecode,
            @ApiParam(name = "type", value = "血糖1、血压2") @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "patientcodes", value = "用户CODE,多个用逗号拼接") @RequestParam(value = "patientcodes", required = true) String patientcodes) {
        try {
            doctorSchemeService.savePatientScheme(doctorcode, schemecode, type, patientcodes);
            return write(200, "操作成功");
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/post/del/scheme", method = RequestMethod.POST)
    @ApiOperation("医生删除监测方案")
    public String doctorDelScheme(
            @ApiParam(name = "schemecode", value = "方案CODE") @RequestParam(value = "schemecode", required = true) String schemecode,
            @ApiParam(name = "type", value = "血糖1、血压2") @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "doctorcode", value = "医生CODE") @RequestParam(value = "doctorcode", required = true) String doctorcode) {
        try {
            doctorSchemeService.delDoctorScheme(doctorcode, schemecode, type);
            return write(200, "操作成功");
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "getPatientHealthIndex", method = RequestMethod.GET)
    @ApiOperation("获取最近一周血糖情况/血压情况")
    public String getPatientHealthIndex(@ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient,
                                        @ApiParam(name = "startDate", value = "开始时间,YYYY-MM-dd") @RequestParam(value = "startDate", required = true) String startDate,
                                        @ApiParam(name = "endDate", value = "结束时间,YYYY-MM-dd") @RequestParam(value = "endDate", required = true) String endDate,
                                        @ApiParam(name = "type", value = "0血糖,1.血压") @RequestParam(value = "type", required = true) String type) {
        try {
            return write(200, "查询成功", "data", doctorSchemeService.getPatientHealthIndex(patient, startDate, endDate, type));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "getTrackPatientInfo", method = RequestMethod.GET)
    @ApiOperation("获取:微信运动,身高体重,血糖监测方案,血压监测方案")
    public String getTrackPatientInfo(@ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient) {
        try {
            return write(200, "查询成功", "data", doctorSchemeService.getTrackPatientInfo(patient));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "getControlObjectives", method = RequestMethod.GET)
    @ApiOperation("获取控制目标,血压,血糖")
    public String getControlObjectives(@ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient) {
        try {
            return write(200, "查询成功", "data", doctorSchemeService.getControlObjectives(patient));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "getBodyInfo", method = RequestMethod.GET)
    @ApiOperation("获取身高体重详情列表")
    public String getBodyInfo(@ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient,
                              @ApiParam(name = "startDate", value = "开始时间,YYYY-MM-dd") @RequestParam(value = "startDate", required = true) String startDate,
                              @ApiParam(name = "endDate", value = "结束时间,YYYY—MM-dd") @RequestParam(value = "endDate", required = true) String endDate,
                              @ApiParam(name = "page", value = "起始页") @RequestParam(value = "page", required = true) Integer page,
                              @ApiParam(name = "size", value = "每页大小") @RequestParam(value = "size", required = true) Integer size) {
        try {
            return write(200, "查询成功", "data", doctorSchemeService.getBodyInfo(patient, startDate, endDate, page, size));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "getTrackPatientCountTitle", method = RequestMethod.GET)
    @ApiOperation("获取重点跟踪居民数,近一周增加数")
    public String getTrackPatientCountTitle(
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = true) String doctorId,
            @ApiParam(name = "startDate", value = "开始时间") @RequestParam(value = "startDate", required = true) String startDate,
            @ApiParam(name = "endDate", value = "结束时间") @RequestParam(value = "endDate", required = true) String endDate) {
        try {
            if (StringUtils.isNotBlank(doctorId)) {
                doctorId = getUID();
            }
            return write(200, "查询成功", "data", doctorSchemeService.getTrackPatientCountTitle(doctorId, startDate, endDate));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "getTrackPatientServerCount", method = RequestMethod.GET)
    @ApiOperation("团队医生下,居民近一周服务情况接口")
    public String getTrackPatientServerCount(
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = false) String doctorId,
            @ApiParam(name = "startDate", value = "开始时间") @RequestParam(value = "startDate", required = true) String startDate,
            @ApiParam(name = "endDate", value = "结束时间") @RequestParam(value = "endDate", required = true) String endDate) {
        try {
            if (StringUtils.isBlank(doctorId)) {
                doctorId = getUID();
            }
            return write(200, "查询成功", "data", doctorSchemeService.getTrackPatientServerCount(null, doctorId, startDate, endDate));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "getPatientHealthIndexByTeam", method = RequestMethod.GET)
    @ApiOperation("获取医生团队最近一周血糖情况/血压情况")
    public String getPatientHealthIndexByTeam(
            @ApiParam(name = "startDate", value = "开始时间,YYYY-MM-dd") @RequestParam(value = "startDate", required = true) String startDate,
            @ApiParam(name = "endDate", value = "结束时间,YYYY-MM-dd") @RequestParam(value = "endDate", required = true) String endDate,
            @ApiParam(name = "type", value = "0血糖,1.血压") @RequestParam(value = "type", required = true) String type,
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = true) String doctorId) {
        try {
            if (StringUtils.isBlank(doctorId)) {
                doctorId = getUID();
            }
            return write(200, "查询成功", "data", doctorSchemeService.getPatientHealthIndexNew(startDate, endDate, type, doctorId));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "getTrackPatientAimByteam", method = RequestMethod.GET)
    @ApiOperation(" 获取团队医生下,居民近一周控制目标情况")
    public String getTrackPatientAimByteam(
            @ApiParam(name = "doctorId", value = "团队Code") @RequestParam(value = "doctorId", required = true) String doctorId,
            @ApiParam(name = "startDate", value = "开始时间,YYYY-MM-dd") @RequestParam(value = "startDate", required = true) String startDate,
            @ApiParam(name = "endDate", value = "结束时间,YYYY-MM-dd") @RequestParam(value = "endDate", required = true) String endDate) {
        try {
            if (StringUtils.isBlank(doctorId)){
                doctorId=getUID();
            }
            return write(200, "查询成功", "data", doctorSchemeService.getTrackPatientAimByteam(doctorId,startDate, endDate));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "getDeviceStateByTeam", method = RequestMethod.GET)
    @ApiOperation("获取团队医生下,居民设备绑定情况")
    public String getDeviceStateByTeam(
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = false) String doctorId) {
        try {
            if (StringUtils.isBlank(doctorId)){
                doctorId=getUID();
            }
            return write(200, "查询成功", "data", doctorSchemeService.getDeviceStateByTeam(doctorId));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "setPatientAim", method = RequestMethod.POST)
    @ApiOperation("批量控制目标设置")
    public String setPatientAim(@ApiParam(name = "patient", value = "患者code,用“,”分割") @RequestParam(value = "patient", required = true) String patient,
                                @ApiParam(name = "suggerJson", value = "血糖目标实体") @RequestParam(value = "suggerJson", required = true) String suggerJson,
                                @ApiParam(name = "pressureJson", value = "血压目标实体") @RequestParam(value = "pressureJson", required = true) String pressureJson,
                                @ApiParam(name = "sportJson", value = "运动目标实体") @RequestParam(value = "sportJson", required = true) String sportJson) {
        try {
            return write(200, "操作成功", "data", doctorSchemeService.setPatientAim(patient, suggerJson, pressureJson, sportJson));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "setSinglePatientAim", method = RequestMethod.POST)
    @ApiOperation("批量控制目标设置")
    public String setSinglePatientAim(@ApiParam(name = "patient", value = "患者code") @RequestParam(value = "patient", required = true) String patient,
                                      @ApiParam(name = "suggerJson", value = "血糖目标实体") @RequestParam(value = "suggerJson", required = true) String suggerJson,
                                      @ApiParam(name = "pressureJson", value = "血压目标实体") @RequestParam(value = "pressureJson", required = true) String pressureJson,
                                      @ApiParam(name = "sportJson", value = "运动目标实体") @RequestParam(value = "sportJson", required = true) String sportJson) {
        try {
            return write(200, "操作成功", "data", doctorSchemeService.setSinglePatientAim(patient, suggerJson, pressureJson, sportJson));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "getTrackPatientIndexCountList", method = RequestMethod.GET)
    @ApiOperation("获取关注居民测量数据列表")
    public String getTrackPatientIndexCountList(@ApiParam(name = "teamCode", value = "团队ID") @RequestParam(value = "teamCode", required = true) Integer teamCode,
                                                @ApiParam(name = "type", value = "1.糖尿病,其他为高血压") @RequestParam(value = "type", required = true) String type,
                                                @ApiParam(name = "startDate", value = "开始时间,YYYY-MM-dd") @RequestParam(value = "startDate", required = true) String startDate,
                                                @ApiParam(name = "endDate", value = "结束时间,YYYY-MM-dd") @RequestParam(value = "endDate", required = true) String endDate,
                                                @ApiParam(name = "keyword", value = "姓名模糊匹配,身份证号") @RequestParam(value = "keyword", required = false) String keyword,
                                                @ApiParam(name = "page", value = "起始页,1开始") @RequestParam(value = "page", required = true) Integer page,
                                                @ApiParam(name = "size", value = "每页大小") @RequestParam(value = "size", required = true) Integer size) {
        try {
            return write(200, "查询成功", "data", doctorSchemeService.getTrackPatientIndexCountList(getUID(), teamCode, type, startDate, endDate, keyword, page, size));
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    // --------------------------------------------------------
    /**
     * 获取红黄绿标高血压糖尿病的指标人数
     */
    @RequestMapping(value = "getLabelCount", method = RequestMethod.GET)
    @ApiOperation("获取红黄绿标高血压糖尿病的指标人数")
    public String getLabelCount(
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = false) String doctorId) {
        try {
            if (StringUtils.isBlank(doctorId)) {
                doctorId = getUID();
            }
            HashMap<String, Object> result = doctorSchemeService.getLabelCount(doctorId);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "getLabelDetail", method = RequestMethod.GET)
    @ApiOperation("获取红黄绿标高血压糖尿病明细")
    public String getLabelDetail(
            @ApiParam(name = "doctorId", value = "医生id") @RequestParam(value = "doctorId", required = false) String doctorId,
            @ApiParam(name = "labelType", value = "1高血压 2糖尿病 空全部") @RequestParam(value = "labelType", required = false) String labelType,
            @ApiParam(name = "searchContent", value = "检索内容") @RequestParam(value = "labelType", required = false) String searchContent,
            @ApiParam(name = "page", value = "页码") @RequestParam(value = "page", required = false) int page,
            @ApiParam(name = "pageSize", value = "数量") @RequestParam(value = "pageSize", required = false) int pageSize
    ) {
        try {
            if (StringUtils.isBlank(doctorId)) {
                doctorId = getUID();
            }
            List<Map<String, Object>> result = doctorSchemeService.getLabelDetail(doctorId, labelType, searchContent, page, pageSize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
}

+ 19 - 13
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/DoctorHealthController.java

@ -8,7 +8,9 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.hospital.module.common.BaseController;
import com.yihu.jw.hospital.module.health.service.PatientHealthIndexService;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.util.entity.ServiceException;
import com.yihu.jw.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -31,6 +33,8 @@ public class DoctorHealthController extends BaseController {
	private PatientHealthIndexService healthIndexService;
	@Autowired
	private JdbcTemplate jdbcTemplate;
	@Autowired
	BasePatientService patientService;
	@RequestMapping(value = "recent",method = RequestMethod.GET)
@ -560,20 +564,23 @@ public class DoctorHealthController extends BaseController {
	@RequestMapping(value = "savastandbyteamcode",method = RequestMethod.POST)
	@ApiOperation("医生保存团队下所有居民的预警方案")
	public String doctorSaveStandardByTeamCode(
			@ApiParam("团队代码") @RequestParam String teamcode,
			@ApiParam("预警值Json") @RequestParam String json) {
			@ApiParam("团队代码") @RequestParam String doctorId,
			@ApiParam("预警值Json") @RequestParam String json
	) {
		try {
			JSONArray array = new JSONArray(json);
			if (StringUtils.isEmpty(teamcode) || array == null || array.length() == 0) {
			if (StringUtils.isEmpty(doctorId) || array == null || array.length() == 0) {
				return error(-1, "保存失败!");
			}
			List<BasePatientDO> patients = new ArrayList<>();
			if (StringUtils.isBlank(doctorId)){
				doctorId=getUID();
			}
			List<BasePatientDO> patients = patientService.findAllPatient(doctorId);
			System.out.println("数量==>"+patients.size());
			if(!patients.isEmpty()){
				// 生成数据对象
				//生成数据对象
				List<PatientHealthStandard> list = new ArrayList<>();
				//保存患者的数据时,同时医生的预警值方案
				List<DoctorHealthStandard> doclist = new ArrayList<>();
@ -585,7 +592,7 @@ public class DoctorHealthController extends BaseController {
					for (BasePatientDO patient: patients) {
						PatientHealthStandard standard = new PatientHealthStandard();
						standard.setDoctor(getUID());
						standard.setDoctor(doctorId);
						standard.setMaxValue1(obj.has("max_value1") ? NumberUtils.toDouble(obj.getString("max_value1"), 0) : 0);
						standard.setMaxValue2(obj.has("max_value2") ? NumberUtils.toDouble(obj.getString("max_value2"), 0) : 0);
						standard.setMinValue1(obj.has("min_value1") ? NumberUtils.toDouble(obj.getString("min_value1"), 0) : 0);
@ -596,9 +603,8 @@ public class DoctorHealthController extends BaseController {
						list.add(standard);
					}
					DoctorHealthStandard doctorHealthStandard = new DoctorHealthStandard();
					doctorHealthStandard.setDoctor(getUID());
					doctorHealthStandard.setDoctor(doctorId);
					doctorHealthStandard.setMaxValue1(obj.has("max_value1") ? NumberUtils.toDouble(obj.getString("max_value1"), 0) : 0);
					doctorHealthStandard.setMaxValue2(obj.has("max_value2") ? NumberUtils.toDouble(obj.getString("max_value2"), 0) : 0);
					doctorHealthStandard.setMinValue1(obj.has("min_value1") ? NumberUtils.toDouble(obj.getString("min_value1"), 0) : 0);
@ -616,19 +622,19 @@ public class DoctorHealthController extends BaseController {
					return error(-1, "保存失败!");
				}
				Iterable<DoctorHealthStandard> dociterable = healthIndexService.saveDocStandard(doclist, getUID());
				Iterable<DoctorHealthStandard> dociterable = healthIndexService.saveDocStandard(doclist, doctorId);
				if (dociterable == null || dociterable.iterator() == null || !dociterable.iterator().hasNext()) {
					return error(-1, "保存失败!");
				}
			}
			return write(200, "保存成功");
		} catch (Exception e) {
			return invalidUserException(e, -1, "操作失败!");
		}
	}
	@RequestMapping(value = "/getHealthDateAll",method = RequestMethod.GET)
	@ApiOperation("医生端--查询所有有数据的日期")
	public String getHealthDateAll(@ApiParam(value = "居民code)", name = "patientCode") @RequestParam(value = "patientCode",required = true)String patientCode,

+ 601 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/DoctorHealthEduArticleController.java

@ -0,0 +1,601 @@
package com.yihu.jw.hospital.module.health.controller;//package com.yihu.jw.hospital.endpoint.health;
//
//import com.yihu.wlyy.aop.ObserverRequired;
//import com.yihu.wlyy.entity.doctor.profile.Doctor;
//import com.yihu.wlyy.entity.education.*;
//import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
//import com.yihu.wlyy.entity.patient.Patient;
//import com.yihu.wlyy.entity.patient.SignFamily;
//import com.yihu.wlyy.logs.BusinessLogs;
//import com.yihu.wlyy.repository.patient.SignFamilyDao;
//import com.yihu.wlyy.service.ServiceException;
//import com.yihu.wlyy.service.app.consult.ConsultService;
//import com.yihu.wlyy.service.app.health.*;
//import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
//import com.yihu.wlyy.service.common.account.DoctorService;
//import com.yihu.wlyy.service.common.account.PatientService;
//import com.yihu.wlyy.task.PushMsgTask;
//import com.yihu.wlyy.util.DateUtil;
//import com.yihu.wlyy.util.ImUtill;
//import com.yihu.wlyy.web.WeixinBaseController;
//import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.apache.commons.lang3.StringUtils;
//import org.htmlparser.Parser;
//import org.htmlparser.util.ParserException;
//import org.htmlparser.visitors.TextExtractingVisitor;
//import org.json.JSONArray;
//import org.json.JSONObject;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.domain.Page;
//import org.springframework.http.MediaType;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.*;
//
///**
// * 医生端:健康教育控制类
// *
// * @author George
// */
//@Controller
//@RestController
//@RequestMapping(value = "/doctor/health/edu", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//@Api(description = "健康教育")
//public class DoctorHealthEduArticleController extends WeixinBaseController {
//
//    private Logger logger = LoggerFactory.getLogger(DoctorHealthEduArticleController.class);
//    @Autowired
//    private HealthEduArticleService healthEduArticleService;
//    @Autowired
//    private DoctorService doctorService;
//    @Autowired
//    private HealthEduArticleOpHistoryService healthEduArticleOpHistoryService;
//
//    @Autowired
//    private SignPatientLabelInfoService signPatientLabelInfoService;
//
//    @Autowired
//    private HealthEduArticlePatientService healthEduArticlePatientService;
//
//    @Autowired
//    private HealthEduArticleDoctorService healthEduArticleDoctorService;
//
//    @Autowired
//    private HealthEduArticleLabelService healthEduArticleLabelService;
//
//    @Autowired
//    private PatientService patientService;
//
//    @Autowired
//    SignFamilyDao signFamilyDao;
//
//    @Autowired
//    ConsultService consultService;
//    @Autowired
//    WeiXinOpenIdUtils weiXinOpenIdUtils;
//    @Autowired
//    private PushMsgTask pushMsgTask;
//
//
//    /**
//     * 查询
//     *
//     * @param pagesize 分页大小
//     * @param wheaType 文章类型
//     * @return 列表
//     */
//    @ApiOperation("查询健康教育")
//    @RequestMapping(value = "list",method = {RequestMethod.GET, RequestMethod.POST})
//    @ResponseBody
//    public String list(@RequestParam(value = "page", required = true) int page,
//                       @RequestParam(value = "pagesize", required = true) int pagesize,
//                       @RequestParam(value = "wheaType", required = true) int wheaType,
//                       @RequestParam(value = "filter", required = false) String filter,
//                       @RequestParam(value = "patient", required = false) String patient) {
//        try {
//            List<Map<String, Object>> list = healthEduArticleService.findAll(page, pagesize, filter, getUID(), patient,wheaType);
//            JSONArray jsonArray = new JSONArray();
//            if (list != null) {
//                for (Map<String, Object> map : list) {
//                    JSONObject json = new JSONObject();
//                    json.put("id", map.get("id"));
//                    // 文章标识
//                    json.put("code", map.get("code"));
//                    // 文章标题
//                    json.put("title", map.get("title"));
//                    // 文章查看URL
//                    json.put("url", map.get("url"));
//                    // 文章简介
//                    //json.put("content", parsrHtml(map.get("content").toString()));
//                    json.put("content", String.valueOf(map.get("content"))==null?"":map.get("content"));
//                    // 添加日期
//                    json.put("czrq", DateUtil.dateToStrLong((Date) map.get("czrq")));
//
//                    json.put("keyword", map.get("keyword") == null ? "" : map.get("keyword"));
//
//                    json.put("send", map.get("send"));
//                    //阅读量
//                    json.put("readAmount", map.get("readAmount"));
//                    //收藏量
//                    json.put("collectionAmount", map.get("collectionAmount"));
//                    //转发量
//                    json.put("repeatAmount", map.get("repeatAmount"));
//
//                    json.put("collection", map.get("collection"));
//                    jsonArray.put(json);
//                }
//            }
//            return write(200, "查询成功", "list", jsonArray);
//        } catch (Exception ex) {
//            return invalidUserException(ex, -1, "查询失败!");
//        }
//    }
//
//    /**
//     * 查询发送给居民的文章列表
//     *
//     * @param pagesize 分页大小
//     * @return 列表
//     */
//    @RequestMapping(value = "list_by_team", method = {RequestMethod.GET, RequestMethod.POST})
//    @ResponseBody
//    @ApiOperation(value = "查询发送给居民的文章列表")
//    public String listByTeam(@RequestParam @ApiParam(value = "第几页") int page,
//                             @RequestParam @ApiParam(value = "页大小") int pagesize,
//                             @RequestParam @ApiParam(value = "居民code") String patient,
//                             @RequestParam @ApiParam(value = "团队code") Long teamCode) {
//        try {
//            if (StringUtils.isEmpty(patient)) {
//                return error(-1, "请输入需查询的居民");
//            }
//            if (teamCode == null || teamCode < 1) {
//                return error(-1, "请输入需查询的居民的团队");
//            }
//            page = page > 0 ? page - 1 : 0;
//            List<Map<String, Object>> list = healthEduArticleService.findByPatientAndTeam(patient, teamCode, page, pagesize);
//            JSONArray jsonArray = new JSONArray();
//            if (list != null) {
//                for (Map<String, Object> map : list) {
//                    JSONObject json = new JSONObject();
//                    // 文章标识
//                    json.put("doctorCode", map.get("code"));
//                    // 文章标识
//                    json.put("doctorName", map.get("name"));
//                    // 文章标识
//                    json.put("doctorPhoto", map.get("photo"));
//                    // 文章标识
//                    json.put("code", map.get("article"));
//                    // 文章标题
//                    json.put("title", map.get("title"));
//                    // 文章查看URL
//                    json.put("url", map.get("url"));
//                    // 文章简介
//                    //json.put("content", parsrHtml(map.get("content").toString()));
//                    json.put("content", map.get("content").toString());
//
//                    json.put("read", map.get("is_read"));
//
//                    json.put("attached_content", map.get("attached_content"));
//                    // 发送日期
//                    json.put("czrq", DateUtil.dateToStrLong((Date) map.get("czrq")));
//                    // 发送团队
//                    json.put("adminTeamCode", map.get("admin_team_code"));
//                    jsonArray.put(json);
//                }
//            }
//            return write(200, "查询成功", "data", jsonArray);
//        } catch (Exception ex) {
//            return invalidUserException(ex, -1, "查询失败!");
//        }
//    }
//
//    /**
//     * 查询医生收藏列表
//     *
//     * @param pagesize 分页大小
//     * @return 列表
//     */
//    @RequestMapping(value = "listDoctor",method = RequestMethod.POST)
//    @ApiOperation("查询医生收藏列表")
//    @ResponseBody
//    public String listDoctor(@RequestParam(value = "page", required = true) int page, @RequestParam(value = "pagesize", required = true) int pagesize, @RequestParam(value = "filter", required = false) String filter, @RequestParam(value = "patient", required = false) String patient, @RequestParam(value = "wheaType", required = false) Integer wheaType) {
//        try {
//            List<Map<String, Object>> list = healthEduArticleDoctorService.list(page, pagesize, filter, getUID(), patient,wheaType);
//            JSONArray jsonArray = new JSONArray();
//            for (Map<String, Object> map : list) {
//                JSONObject json = new JSONObject();
//                json.put("id", map.get("id"));
//                // 文章标识
//                json.put("code", map.get("article"));
//                // 文章标题
//                json.put("title", map.get("title"));
//                // 文章查看URL
//                json.put("url", map.get("url"));
//
//                // 文章简介
//                //json.put("content", parsrHtml(map.get("content").toString()));
//                json.put("content", map.get("content").toString());
//                // 添加日期
//                json.put("czrq", DateUtil.dateToStrLong((Date) map.get("czrq")));
//
//                json.put("keyword", map.get("keyword"));
//
//                json.put("send", map.get("send"));
//                //阅读量
//                json.put("readAmount", map.get("readAmount"));
//                //收藏量
//                json.put("collectionAmount", map.get("collectionAmount"));
//                //转发量
//                json.put("repeatAmount", map.get("repeatAmount"));
//                //是否收藏(医生收藏的列表肯定是收藏的无需额外校验)
//                json.put("collection", 1);
//
//                jsonArray.put(json);
//            }
//            return write(200, "查询成功", "list", jsonArray);
//        } catch (Exception ex) {
//            return invalidUserException(ex, -1, "查询失败!");
//        }
//    }
//
//    /**
//     * 查询标签列表
//     *
//     * @param pagesize 分页大小
//     * @return 列表
//     */
//    @RequestMapping(value = "listLabel",method = RequestMethod.POST)
//    @ApiOperation("查询标签列表")
//    @ResponseBody
//    public String listLabel(@RequestParam(value = "page", required = true) int page, @RequestParam(value = "pagesize", required = true) int pagesize, @RequestParam(value = "type", required = false, defaultValue = "0") int type) {
//        try {
//            Page<HealthEduArticleLabel> list = healthEduArticleLabelService.findAll(page, pagesize, type, getUID());
//            return write(200, "查询成功", "list", list);
//        } catch (Exception ex) {
//            error(ex);
//            return invalidUserException(ex, -1, "查询失败!");
//        }
//    }
//
//    /**
//     * 查询文章列表
//     *
//     * @param code 数据文章唯一标示code
//     * @return 列表
//     */
//    @RequestMapping(value = "article",method = RequestMethod.POST)
//    @ResponseBody
//    @ApiOperation("查询文章列表")
//    public String article(@RequestParam(value = "code", required = true) String code) {
//        try {
//            //获取单条文章记录
//            HealthEduArticle healthEduArticle = healthEduArticleService.findArticleByCode(code);
//            int isRead = healthEduArticleOpHistoryService.countByUserStatus(getUID(), HealthEduArticleOpHistory.READ_STATUS);
//            //插入文章读取状态第一次阅读记录浏览数量
//            if (isRead == 0) {
//                //更新浏览量
//                healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.READ_STATUS, healthEduArticle.getCode(), healthEduArticle.getTitle(), getUID());
//            }
//            JSONObject json = new JSONObject();
//            json.put("id", healthEduArticle.getId());
//            // 文章标识
//            json.put("code", healthEduArticle.getCode());
//            // 文章标题
//            json.put("title", healthEduArticle.getTitle());
//
//            json.put("url", healthEduArticle.getUrl() == null ? "" : healthEduArticle.getUrl());
//            // 文章内容
//            json.put("content", healthEduArticle.getContent());
//            // 添加日期
//            json.put("czrq", DateUtil.dateToStrLong(healthEduArticle.getCzrq()));
//            int readAmount = healthEduArticleOpHistoryService.countReadAmount(code);
//            json.put("readAmount", readAmount);
//            HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(healthEduArticle.getCode(), getUID());
//            if (healthEduArticleDoctor == null) {
//                json.put("collection", 0);
//            } else {
//                json.put("collection", 1);
//            }
//            return write(200, "查询成功", "data", json);
//        } catch (Exception ex) {
//            return invalidUserException(ex, -1, "查询失败!");
//        }
//    }
//
//
//    /**
//     * 发送文章给患者
//     *
//     * @param code    文章标识,多个以逗号分隔
//     * @param patient 患者标识,多个以逗号分隔
//     * @param group   所选群组,多个用逗号分隔
//     * @param  attachedContent 附加内容
//     * @return
//     */
//    @RequestMapping(value = "send",method = RequestMethod.POST)
//    @ApiOperation("发送文章给患者")
//    @ResponseBody
//    @ObserverRequired
//    public String send(@RequestParam(value = "code") String code,
//                       @RequestParam(value = "patient", required = false) String patient,
//                       @RequestParam(value = "group", required = false, defaultValue = "") String group,
//                       @RequestParam(value = "labelType", required = false) String labelType,
//                       @RequestParam(value = "teamCode", required = false) long teamCode,
//                       @RequestParam(value = "attachedContent", required = false) String attachedContent) {
//        try {
//            List<HealthEduArticlePatient> list = new ArrayList<HealthEduArticlePatient>();
//            if (StringUtils.isEmpty(code)) {
//                return error(-1, "请至少选择一篇文章!");
//            }
//            if (StringUtils.isEmpty(patient) && StringUtils.isEmpty(group)) {
//                return error(-1, "请至少选择一个患者!");
//            }
//            String[] articles = code.split(",");
//            String[] patients = patient.split(",");
//            String[] groups = group.split(",");
//            if (articles.length == 0) {
//                return error(-1, "请至少选择一篇文章!");
//            }
//            if (patients.length == 0 && groups.length == 0) {
//                return error(-1, "请至少选择一个患者!");
//            }
//            Map<String, HealthEduArticle> maps = new HashMap<String, HealthEduArticle>();
//            Set<String> patientSet = new HashSet<>();
//            if (StringUtils.isNotBlank(group) && groups.length > 0) {
//                //递归患者数据
//                for (String g : groups) {
//                    getPatientByGroup(g, labelType, teamCode, patientSet, 0, 100);
//                }
//            }
//            //去重操作
//            for (String p : patients) {
//                if (StringUtils.isNotBlank(p)) {
//                    patientSet.add(p);
//                }
//            }
//            if (patientSet.size() == 0) {
//                return error(-1, "请至少选择一个患者!");
//            }
//            // 查询医生信息
//            Doctor doctor = doctorService.findDoctorByCode(getUID());
//            String msgHead = doctor.getName() + "医生给您发来了一篇患教文章";
//            String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
//            if(StringUtils.isNotBlank(attachedContent)){
//                endMsg = attachedContent;
//            }
//            Map<String, Map<String, Object>> msgs = new HashMap<>();
//            String batchNo = UUID.randomUUID().toString();
//            Date createTime = new Date();
//            for (String p : patientSet) {
//                try{
//                    Patient patientTemp = patientService.findByCode(p);
//                    SignFamily signFamily = signFamilyDao.findByjiatingPatient(p);
//                    if (signFamily == null) {
//                        throw new Exception("can not find patient's family sign info");
//                    }
//                    for (String a : articles) {
//                        // 查询文章信息
//                        HealthEduArticle temp = maps.get(a);
//                        if (temp == null) {
//                            temp = healthEduArticleService.findArticleByCode(a);
//                            // 添加到缓存
//                            maps.put(a, temp);
//                        }
//
//                        HealthEduArticlePatient heap = new HealthEduArticlePatient();
//                        // 设置文章标识
//                        heap.setArticle(a);
//                        // 设置文章简介
//                        //heap.setContent(temp.getContent());
//                        // 设置文章标题
//                        //heap.setTitle(temp.getTitle());
//                        // 设置文章查看URL
//                        //heap.setUrl(temp.getUrl());
//                        // 设置发送时间
//                        heap.setCzrq(new Date());
//                        // 设置医生标识
//                        heap.setDoctor(doctor.getCode());
//                        // 设置医生姓名
//                        heap.setDoctorName(doctor.getName());
//                        // 设置患者标识
//                        heap.setPatient(p);
//                        // 设置为示读
//                        heap.setRead(1);
//                        // 签约类型
//                        heap.setSignType(2);
//                        // 行政团队
//                        heap.setAdminTeamCode(signFamily.getAdminTeamId());
//                        //附加内容
//                        heap.setAttachedContent(attachedContent);
//                        //批次号记录发送批次
//                        heap.setBatchNo(batchNo);
//                        //创建时间
//                        heap.setCzrq(createTime);
//                        heap.setSignCode(patientService.getSignCodeByPatient(p));
//                        heap.setSendType(1);//i健康推送
//                        heap.setTitle(temp.getTitle());
//                        list.add(heap);
//                        consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, "{\"title\":\"" + temp.getTitle()+ "\",\"type\":0,\"id\":\"" + temp.getCode() + "\",\"img\":\"" + temp.getUrl() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patientTemp.getName());
//                        if(StringUtils.isNotBlank(attachedContent)){
//                            //发送备注
//                            consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p, attachedContent, ImUtill.CONTENT_TYPE_TEXT, patientTemp.getName());
//                        }
//                        // 推送消息给微信端
//                        JSONObject json = new JSONObject();
//                        json.put("first", patientTemp.getName() + ",您好!\n" + msgHead);
//                        json.put("toUser", p);
//                        json.put("article", temp.getCode() + "");
//                        json.put("title", temp.getTitle());
//                        json.put("doctorName", doctor.getName());
//                        json.put("represented",p);//被代理人
//                        json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
//                        json.put("remark", endMsg);
//                        Map<String, Object> content = new HashMap<>();
//                        content.put("openid", patientTemp.getOpenid());
//                        content.put("name", patientTemp.getName());
//                        content.put("json", json);
//                        content.put("code",patientTemp.getCode());
//                        msgs.put(patientTemp.getCode(), content);
//                    }
//                } catch (ServiceException se) {
//                    return write(-1,se.getMessage());
//                } catch (Exception e){
//                    logger.info("eduArticle_doctor:"+doctor.getCode()+" patient:"+p +" error:"+e.getMessage());
//                    error(e);
//                }
//            }
//            // 保存到数据库
//            int row = healthEduArticleService.send(list);
//            if (row <= 0) {
//                return error(-1, "发送失败!");
//            } else {
//                for (String key : msgs.keySet()) {
//
//                    Map<String, Object> map = msgs.get(key);
//                    String openid = (String)map.get("openid");
//                    if(StringUtils.isNotBlank(openid)){
//                        pushMsgTask.putWxMsg(getAccessToken(), 9,
//                                map.get("openid") == null ? "" : map.get("openid").toString(),
//                                map.get("name") == null ? "" : map.get("name").toString(),
//                                (JSONObject) map.get("json"));
//                    }else {
//                        //发送代理人
//                        JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId((String) map.get("code"), openid);
//                        if (jsonArray != null && jsonArray.length() > 0) {
//                            Patient p = patientService.findByCode((String) map.get("code"));
//                            for (int i = 0; i < jsonArray.length(); i++) {
//                                JSONObject j = jsonArray.getJSONObject(i);
//                                Patient member = (Patient) j.get("member");
//                                JSONObject data = (JSONObject) map.get("json");
//                                data.remove("toUser");
//                                data.put("toUser", member.getCode());
//                                String first = (String) data.get("first");
//                                data.remove("first");
//                                data.put("first", weiXinOpenIdUtils.getTitleMes(p, j.isNull("relation") ? 1 : j.getInt("relation"), p.getName()));
//                                if (StringUtils.isNotBlank(member.getOpenid())) {
//                                    pushMsgTask.putWxMsg(getAccessToken(), 9, member.getOpenid(), p.getName(), data);
//                                }
//                            }
//                        }
//                    }
//
//                }
//                for (HealthEduArticlePatient heap : list) {
//                    BusinessLogs.info(BusinessLogs.BusinessType.article, getUID(), heap.getPatient(), new JSONObject(heap));
//                }
//                return success("发送成功!");
//            }
//        } catch (Exception e) {
//            return errorResult(e);
//        }
//    }
//
//    private void getPatientByGroup(String labelCode, String labelType, Long teamCode, Set<String> patientSet, int page, int pagesize) throws Exception {
//        JSONArray result = signPatientLabelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize, false, "",false,null,null,null);
//        for (Object o : result) {
//            JSONObject json = (JSONObject) o;
//            String patient = (String) json.get("code");
//            patientSet.add(patient);
//        }
//        if (result.length() == 100) {
//            getPatientByGroup(labelCode, labelType, teamCode, patientSet, page + 1, pagesize);
//        }
//    }
//
//    /**
//     * 文章收藏
//     *
//     * @param article 文章CODE
//     * @return
//     */
//
//    @RequestMapping(value = "collectionArticle",method = RequestMethod.POST)
//    @ApiOperation("文章收藏")
//    @ResponseBody
//    @ObserverRequired
//    public String collectionArticle(@RequestParam(value = "article", required = true) String article) {
//        HealthEduArticleDoctor healthEduArticleDoctor = healthEduArticleDoctorService.findByArticle(article, getUID());
//        if (healthEduArticleDoctor != null) {
//            return error(-1, "收藏失败,该文章已经收藏!");
//        }
//        HealthEduArticle healthEduArticle = healthEduArticleService.findArticleByCode(article);
//        healthEduArticleDoctor = new HealthEduArticleDoctor();
//        try {
//            BeanUtils.copyProperties(healthEduArticle, healthEduArticleDoctor);
//            healthEduArticleDoctor.setDoctor(getUID());
//            healthEduArticleDoctor.setArticle(healthEduArticle.getCode());
//            healthEduArticleDoctorService.save(healthEduArticleDoctor);
//            //更新收藏量
//            healthEduArticleOpHistoryService.saveByStatus(HealthEduArticleOpHistory.COLLECTION_STATUS, healthEduArticle.getCode(), healthEduArticle.getTitle(), getUID());
//            return success("收藏成功!");
//        } catch (Exception e) {
//            return errorResult(e);
//        }
//    }
//
//    /**
//     * 文章取消收藏
//     *
//     * @param article 文章CODE
//     * @return
//     */
//    @RequestMapping(value = "uncollectionArticle",method = RequestMethod.POST)
//    @ApiOperation("文章取消收藏")
//    @ResponseBody
//    @ObserverRequired
//    public String uncollectionArticle(@RequestParam(value = "article", required = true) String article) {
//        try {
//            healthEduArticleDoctorService.delete(article, getUID());
//
//            return success("取消收藏成功!");
//        } catch (Exception e) {
//            return errorResult(e);
//        }
//    }
//
//
//    @RequestMapping(value = "logs",method = RequestMethod.POST)
//    @ApiOperation("查询多个患者文章 ")
//    @ResponseBody
//    public String getPatientHealthLogs(@RequestParam(value = "page", required = true) int page, @RequestParam(value = "pagesize", required = true) int pagesize){
//       try{
//           List<Map<String,Object>> result  =  healthEduArticlePatientService.findByDoctor(getUID(),page,pagesize);
//           return write(200,"查询成功!","list",result);
//       }catch (Exception e){
//           return write(-1,"查询失败!");
//       }
//    }
//    @RequestMapping(value = "log",method = RequestMethod.POST)
//    @ApiOperation("查询单个患者文章")
//    @ResponseBody
//    public String getPatientHealthLog(@RequestParam(value = "article", required = true) String article, @RequestParam(value = "batchNo", required = false) String batchNo){
//        try{
//            List<Map<String,Object>> result  =   healthEduArticlePatientService.findByBatchNo(getUID(),article,batchNo);
//            return write(200,"查询成功!","list",result);
//        }catch (Exception e){
//            return errorResult(e);
//        }
//    }
//
//    private String parsrHtml(String html) {
//        html = ("<span>" + html + "</span>");//拼接一个HTML标签,防止纯文字字符串转换在linux下面出现的异常。
//        Parser parser = null;
//        try {
//            parser = new Parser(html);
//            TextExtractingVisitor visitor = new TextExtractingVisitor();
//            parser.visitAllNodesWith(visitor);
//            return StringUtils.isNotBlank(visitor.getExtractedText()) ? visitor.getExtractedText() : "内容为图集,请点击查看";
//        } catch (ParserException e) {
//            return html;//纯文本内容会转换失败,直接返回文本内容
//        }
//
//    }
//
//}

+ 299 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/DoctorHealthGuidanceController.java

@ -0,0 +1,299 @@
package com.yihu.jw.hospital.module.health.controller;//package com.yihu.jw.hospital.endpoint.health;
//
//import com.yihu.wlyy.aop.ObserverRequired;
//import com.yihu.wlyy.entity.doctor.profile.Doctor;
//import com.yihu.wlyy.entity.patient.Patient;
//import com.yihu.wlyy.entity.patient.PatientHealthGuidance;
//import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
//import com.yihu.wlyy.logs.BusinessLogs;
//import com.yihu.wlyy.service.ServiceException;
//import com.yihu.wlyy.service.app.consult.ConsultService;
//import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
//import com.yihu.wlyy.service.common.account.DoctorService;
//import com.yihu.wlyy.service.common.account.PatientService;
//import com.yihu.wlyy.service.template.DoctorGuidanceTempService;
//import com.yihu.wlyy.service.template.DoctorTeamGuidanceService;
//import com.yihu.wlyy.util.CommonUtil;
//import com.yihu.wlyy.web.WeixinBaseController;
//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.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//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 George
// */
//@Controller
//@RequestMapping(value = "/doctor/health/guidance", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//@Api(description = "健康指导")
//public class DoctorHealthGuidanceController extends WeixinBaseController {
//
//    private static final Logger logger = LoggerFactory.getLogger(DoctorHealthGuidanceController.class);
//
//    @Autowired
//    private PatientHealthGuidanceService patientHealthGuidanceService;
//
//    @Autowired
//    private DoctorService doctorService;
//
//    @Autowired
//    private PatientService patientService;
//
//    @Autowired
//    private ConsultService consultService;
//    @Autowired
//    private CommonUtil CommonUtil;
//    //======================
//    @Autowired
//    DoctorGuidanceTempService doctorGuidanceTempService;
//    @Autowired
//    private DoctorTeamGuidanceService doctorTeamGuidanceService;
////	=======================
//
//    /**
//     * 获取某个健康指导
//     *
//     * @param id
//     * @return
//     */
//    @RequestMapping(value = "/id", method = RequestMethod.POST)
//    @ApiOperation("获取某个健康指导")
//    @ResponseBody
//    public String getHealthGuidance(@RequestParam String id) {
//        Long idl = Long.parseLong(id);
//        try {
//            if (idl == null || idl < 1) {
//                return error(-1, "参数错误");
//            }
//
//            JSONObject guidance = patientHealthGuidanceService.findById(idl);
//            return write(200, "查询成功", "data", guidance);
//        } catch (Exception e) {
//            return errorResult(e);
//        }
//    }
//
//	/*/**
//     * 添加患者健康指导
//	 * @param patient 患者标识
//	 * @param content 指导内容
//	 * @return
//	 */
//	/*@RequestMapping(value = "add")
//	@ResponseBody
//	public String add(String patient, String content, @RequestParam(required = false) String images, @RequestParam(required = false) String voice) {
//		try {
//			PatientHealthGuidance guidance = new PatientHealthGuidance();
//			guidance.setContent(content);
//			guidance.setDoctor(getUID());
//			guidance.setPatient(patient);
//			Doctor doctor = doctorService.findDoctorByCode(getUID());
//			if (StringUtils.isNotEmpty(images)) {
//				images = CommonUtil.copyTempImage(images);
//			}
//			guidance.setImages(images);
//
//			if (StringUtils.isNotEmpty(voice)) {
//				images = CommonUtil.copyTempVoice(voice);
//			}
//			guidance.setVoice(voice);
//
//			// 保存
//			if (patientHealthGuidanceService.add(guidance, getAccessToken()) != null) {
//				Patient p = patientService.findByCode(patient);
//				consultService.sendMucMessageBySingnType(getUID(),doctor.getName(),patient,content,"1",p.getName());
//				BusinessLogs.info(BusinessLogs.BusinessType.guidance, patient, new JSONObject(guidance));
//				return success("保存成功!");
//			} else {
//				return error(-1, "保存失败!");
//			}
//		} catch (Exception e) {
//			error(e);
//			return error(-1, "保存失败!");
//		}
//	}*/
//    //  ====================修改代码========================
//
//    /**
//     * 添加患者健康指导(modelCode不为空判断为使用模板)
//     *
//     * @param patient   患者标识
//     * @param content   指导内容
//     * @param modelCode 指导模板编码
//     * @param images    指导图片
//     * @param voice     指导语音
//     * @return
//     */
//    @RequestMapping(value = "/add", method = RequestMethod.POST)
//    @ApiOperation("添加患者健康指导")
//    @ResponseBody
//    @ObserverRequired
//    public String add(@RequestParam String patient,
//                      @RequestParam String content,
//                      @RequestParam(required = false) String modelCode,
//                      @RequestParam(required = false) String images,
//                      @RequestParam(required = false) String voice,
//                      @RequestParam(required = false) String tzCode) {
//
//        String imageUrls = "";
//        String imageRow = "";
//        JSONObject resultMap = new JSONObject();
//        Patient p = patientService.findByCode(patient);
//        if(null==p||(null!=p.getArchiveStatus()&&2==p.getArchiveStatus())){
//            resultMap.put("id","");
//            resultMap.put("msg","居民不存在,或者居民档案状态为死亡。");
//            return write(200,"保存成功!","data",resultMap);
//        }
//        if (StringUtils.isBlank(modelCode) || "undefined".equals(modelCode)) {
////			不使用模板指导,旧版手工指导
//            try {
//                PatientHealthGuidance guidance = new PatientHealthGuidance();
//                guidance.setContent(content);
//                guidance.setDoctor(getUID());
//                guidance.setPatient(patient);
////				找到当前医生
//                Doctor doctor = doctorService.findDoctorByCode(getUID());
//
//                if (StringUtils.isNotEmpty(images)) {
//                    images = CommonUtil.validateImages(images);
//                }
//                logger.info("========================================> "+images);
//                guidance.setImages(images);
//
//                // 保存到居民端健康指导
//                PatientHealthGuidance pp = patientHealthGuidanceService.add(guidance, getAccessToken(),tzCode, null) ;
//                if (pp != null) {
//                    String imcotent = "{\"title\":\"健康指导\",\"type\":2,\"id\":\"" + guidance.getId() + "\",\"img\":\"" + guidance.getImages() + "\",\"content\":\"" + CommonUtil.getSubString(guidance.getContent(), 0, 30) + "\"}";
//                    consultService.sendMucMessageBySingnType(getUID(), doctor.getName(), patient, imcotent, "4", p.getName());
//                    BusinessLogs.info(BusinessLogs.BusinessType.guidance, getUID(), patient, new JSONObject(guidance));
//                    resultMap.put("id",pp.getId());
//                    return write(200,"保存成功!","data",resultMap);
//                } else {
//                    return error(-1, "居民签约已到期,请使用文字回复。");
//                }
//            } catch (ServiceException se) {
//                return write(-1,se.getMessage());
//            } catch (Exception e) {
//                return errorResult(e);
//            }
//        } else {
//            try {
//                DoctorGuidanceTemp guidanceTemp = doctorGuidanceTempService.findByCode(modelCode);
//                PatientHealthGuidance guidance = new PatientHealthGuidance();
//                guidance.setContent(content);
//                guidance.setDoctor(getUID());
//                guidance.setPatient(patient);
//                Doctor doctor = doctorService.findDoctorByCode(getUID());
//                if (StringUtils.isNotEmpty(images)) {
//                    images = CommonUtil.validateImages(images);
//                }
//
//                logger.info("========================================> "+images);
//                guidance.setImages(images);
//
//                // 保存
//                PatientHealthGuidance pp = patientHealthGuidanceService.add(guidance, getAccessToken(),tzCode, guidanceTemp.getModelName()) ;
//                if (pp != null) {
//                    String sendImgs = "";
//                    if (StringUtils.isNotBlank(images)) {
//                        sendImgs = images;
//                    }
//                    String imcotent = "{\"title\":\"健康指导\",\"type\":2,\"id\":\"" + guidance.getId() + "\",\"img\":\"" + sendImgs + "\",\"content\":\"" + CommonUtil.getSubString(guidance.getContent(), 0, 30) + "\"}";
//                    consultService.sendMucMessageBySingnType(getUID(), doctor.getName(), patient, imcotent, "4", p.getName());
//                    BusinessLogs.info(BusinessLogs.BusinessType.guidance, getUID(), patient, new JSONObject(guidance));
//                    //发送成功记录模板发送次数
//                    doctorGuidanceTempService.countSend(modelCode);
//                    resultMap.put("id",pp.getId());
//                    return write(200,"保存成功!","data",resultMap);
//                } else {
//                    return error(-1, "居民签约已到期,请使用文字回复。");
//                }
//            } catch (ServiceException se) {
//                return write(-1,se.getMessage());
//            } catch (Exception e) {
//                return errorResult(e);
//            }
//        }
//    }
//    //  ============================================
//
//    /**
//     * 查询患者的健康指导
//     *
//     * @param patient  患者标识
//     * @param begin    开始时间
//     * @param end      结束时间
//     * @param id       指导编码
//     * @param pagesize 展示页数
//     * @return
//     */
//    @RequestMapping(value = "/list", method = {RequestMethod.POST, RequestMethod.GET})
//    @ApiOperation("添加患者健康指导")
//    @ResponseBody
//    public String list(@RequestParam(required = false) String patient,
//                       @RequestParam(required = false) String begin,
//                       @RequestParam(required = false) String end,
//                       @RequestParam String id,
//                       @RequestParam String pagesize) {
//        try {
//            Long idl = Long.parseLong(id);
//            int page = Integer.parseInt(pagesize);
//            if (StringUtils.isNotEmpty(begin)) {
//                begin = begin + " 00:00:00";
//            }
//            if (StringUtils.isNotEmpty(end)) {
//                end = end + " 23:59:59";
//            }
//            JSONArray array = patientHealthGuidanceService.findPatientGuidanceByDoctor(getUID(), patient, begin, end, idl, page);
//            return write(200, "查询成功!", "list", array);
//        } catch (Exception e) {
//            return errorResult(e);
//        }
//    }
//
//
//    /**
//     * 查询患者的健康指导
//     *
//     * @param patient
//     * @param teamCode
//     * @param page
//     * @param pagesize
//     * @return
//     */
//    @RequestMapping(value = "list_by_team", method = {RequestMethod.GET, RequestMethod.POST})
//    @ResponseBody
//    @ApiOperation(value = "查询居民健康指导记录")
//    public String list(@RequestParam @ApiParam(value = "居民code") String patient,
//                       @RequestParam @ApiParam(value = "团队Code") Long teamCode,
//                       @RequestParam @ApiParam(value = "第几页") int page,
//                       @RequestParam @ApiParam(value = "页大小") int pagesize) {
//        try {
//            if (StringUtils.isEmpty(patient)) {
//                return error(-1, "请输入需查询的居民");
//            }
//            if (teamCode == null || teamCode < 1) {
//                return error(-1, "请输入需查询的居民的团队");
//            }
//            page = page > 0 ? page - 1 : 0;
//            JSONArray result = patientHealthGuidanceService.findByPatientAndGuidanceAndTeam(patient, teamCode, page, pagesize);
//            return write(200, "查询成功!", "data", result);
//        } catch (Exception e) {
//            return errorResult(e);
//        }
//    }
//
//}

+ 4 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientDeviceController.java

@ -182,7 +182,10 @@ public class PatientDeviceController extends BaseController {
                return write(-1,"sn码不能为空!");
            }
            // 设置患者标识
            device.setUser(getRepUID());
            if(StringUtils.isBlank(device.getUser())){
                device.setUser(getRepUID());
            }
//            device.setUser(getUID());
            //患者和设备是否首绑
            Map<String,Object> checkMap = patientDeviceService.checkBindingFirstAndType(device);

+ 14 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/dao/DoctorSwitchDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.hospital.module.health.dao;
import com.yihu.jw.entity.scheme.DoctorSwitch;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/1/5.
 */
public interface DoctorSwitchDao extends PagingAndSortingRepository<DoctorSwitch, Long>, JpaSpecificationExecutor<DoctorSwitch> {
    public DoctorSwitch findByDoctor(String doctor);
}

+ 31 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/dao/DoctoreSchemeBloodPressureDao.java

@ -0,0 +1,31 @@
package com.yihu.jw.hospital.module.health.dao;
import com.yihu.jw.entity.scheme.DoctorSchemeBloodPressure;
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 java.util.List;
/**
 * 血压监测方案底层相关方法
 * @author huangwenjie
 * @date 2017/9/13 20:24
 */
public interface DoctoreSchemeBloodPressureDao extends
        PagingAndSortingRepository<DoctorSchemeBloodPressure, Long>,
        JpaSpecificationExecutor<DoctorSchemeBloodPressure> {
    @Query(value =" select * from wlyy_doctor_scheme_blood_pressure where (doctorcode=?1 or code = 'default') and del != 1 ORDER BY create_time desc,code,dayofweek asc",nativeQuery = true)
    List<DoctorSchemeBloodPressure> getListByDoctorcode(String doctorCode);
    @Query(" from DoctorSchemeBloodPressure p where p.code=?1 and p.del != 1 order by p.doctorcode,p.code desc,p.dayofweek asc")
    List<DoctorSchemeBloodPressure> findByCode(String code);
    @Modifying
    @Query("update DoctorSchemeBloodPressure set del=?1 where doctorcode=?2 and code=?3")
    void updateDelStatus(int del, String doctorcode, String schemecode);
}

+ 33 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/dao/DoctrorSchemeBloodSuggerDao.java

@ -0,0 +1,33 @@
package com.yihu.jw.hospital.module.health.dao;
import com.yihu.jw.entity.scheme.DoctorSchemeBloodSugger;
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 javax.persistence.Entity;
import javax.persistence.Table;
import java.util.List;
/**
 * 医生血糖监测方案底层相关方法
 * @author huangwenjie
 * @date 2017/9/13 20:08
 */
public interface DoctrorSchemeBloodSuggerDao extends
        PagingAndSortingRepository<DoctorSchemeBloodSugger, Long>,
        JpaSpecificationExecutor<DoctorSchemeBloodSugger> {
    @Query(value =" select * from wlyy_doctor_scheme_blood_sugger where (doctorcode=?1 or code = 'default') and del != 1 ORDER BY create_time desc,code,dayofweek asc",nativeQuery = true)
    List<DoctorSchemeBloodSugger> getListByDoctorcode(String doctorCode);
    @Query(" from DoctorSchemeBloodSugger p where p.code=?1 and p.del != 1 order by p.doctorcode,p.code desc,p.dayofweek asc")
    List<DoctorSchemeBloodSugger> findByCode(String code);
    @Modifying
    @Query("update DoctorSchemeBloodSugger set del=?1 where doctorcode=?2 and code=?3")
    void updateDelStatus(int del, String doctorcode, String schemecode);
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/health/FoodCompDao.java

@ -1,4 +1,4 @@
package com.yihu.jw.health;
package com.yihu.jw.hospital.module.health.dao;
import com.yihu.jw.entity.base.health.FoodComp;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/health/MedicinesDao.java

@ -3,7 +3,7 @@
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.health;
package com.yihu.jw.hospital.module.health.dao;
import com.yihu.jw.entity.base.health.Medicines;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

+ 2 - 2
business/base-service/src/main/java/com/yihu/jw/health/PatientHealthRecordDietDao.java

@ -1,4 +1,4 @@
package com.yihu.jw.health;
package com.yihu.jw.hospital.module.health.dao;
import com.yihu.jw.entity.base.health.PatientHealthRecordDiet;
import org.springframework.data.domain.Page;
@ -26,7 +26,7 @@ public interface PatientHealthRecordDietDao extends PagingAndSortingRepository<P
    //	修改饮食记录
    @Modifying
    @Query("update PatientHealthRecordDiet a set a.recordDate = ?2,a.content = ?3,a.images= ?4 where a.id= ?1 ")
    void modifyDiet(long id,Date value1, String value2, String value3);
    void modifyDiet(long id, Date value1, String value2, String value3);
    //	删除饮食记录
    @Modifying

+ 2 - 2
business/base-service/src/main/java/com/yihu/jw/health/PatientHealthRecordMedicationDao.java

@ -1,4 +1,4 @@
package com.yihu.jw.health;
package com.yihu.jw.hospital.module.health.dao;
import com.yihu.jw.entity.base.health.PatientHealthRecordMedication;
import org.springframework.data.domain.Page;
@ -26,7 +26,7 @@ public interface PatientHealthRecordMedicationDao extends PagingAndSortingReposi
    //	修改用药记录
    @Modifying
    @Query("update PatientHealthRecordMedication a set a.recordDate = ?2,a.medicines = ?3,a.medicinesName= ?4 where a.id= ?1 ")
    void modifyMedication(long id, Date value1, String value2,String medicationName);
    void modifyMedication(long id, Date value1, String value2, String medicationName);
    //	删除用药记录
    @Modifying

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/health/PatientHealthRecordSportsDao.java

@ -1,4 +1,4 @@
package com.yihu.jw.health;
package com.yihu.jw.hospital.module.health.dao;
import com.yihu.jw.entity.base.health.PatientHealthRecordSports;
import org.springframework.data.domain.Page;

+ 30 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/dao/PatientSchemeListDao.java

@ -0,0 +1,30 @@
package com.yihu.jw.hospital.module.health.dao;
import com.yihu.jw.entity.scheme.PatientSchemeList;
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 java.util.List;
/**
 * 监测方案关联关系表
 * @author huangwenjie
 * @date 2017/9/13 23:21
 */
public interface PatientSchemeListDao extends
        PagingAndSortingRepository<PatientSchemeList, Long>,
        JpaSpecificationExecutor<PatientSchemeList> {
    @Modifying
    @Query("delete PatientSchemeList where patientcode=?1 and type=?2")
    void delByPatientCode(String patientcode, int i);
    List<PatientSchemeList> findByPatientcodeAndSchemecodeAndType(String patientcode, String schemecode, Integer type);
    List<PatientSchemeList> findBySchemecode(String schemecode);
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/health/SportsDao.java

@ -3,7 +3,7 @@
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.health;
package com.yihu.jw.hospital.module.health.dao;
import com.yihu.jw.entity.base.health.Sports;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/health/SportsTypeDao.java

@ -3,7 +3,7 @@
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.health;
package com.yihu.jw.hospital.module.health.dao;
import com.yihu.jw.entity.base.health.SportsType;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

+ 30 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/dao/TrackPatientDao.java

@ -0,0 +1,30 @@
package com.yihu.jw.hospital.module.health.dao;
import com.yihu.jw.entity.scheme.TrackPatient;
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 Trick on 2018/1/4.
 */
public interface TrackPatientDao extends PagingAndSortingRepository<TrackPatient, String>, JpaSpecificationExecutor<TrackPatient> {
    public TrackPatient findByDoctorCodeAndPatientCode(String doctorCode, String patientCode);
    public List<TrackPatient> findByDoctorCodeAndTeamCodeAndDel(String doctorCode, Integer teamCode, String del);
    List<TrackPatient> findByDoctorCodeAndDel(String doctorCode, String del);
    @Query(value= "SELECT DISTINCT a.*\n" +
            "FROM wlyy_track_patient a  \n" +
            "INNER JOIN base_patient b ON a.patient_code=b.id \n" +
            "INNER JOIN base_patient_doctor_relation c ON b.id=c.patient_id  \n" +
            "WHERE 1=1\n" +
            "AND c.doctor_id=?1 \n" +
            "AND a.del=?2 ",nativeQuery = true)
    List<TrackPatient> findByDoctor(String doctor,String del);
}

+ 1 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/MedicinesService.java

@ -2,7 +2,7 @@ package com.yihu.jw.hospital.module.health.service;
import com.yihu.jw.entity.base.health.Medicines;
import com.yihu.jw.health.MedicinesDao;
import com.yihu.jw.hospital.module.health.dao.MedicinesDao;
import com.yihu.jw.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

+ 437 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientHealthGuidanceService.java

@ -0,0 +1,437 @@
package com.yihu.jw.hospital.module.health.service;
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.PatientHealthGuidance;
import com.yihu.jw.entity.patient.PatientHealthGuidanceRecord;
import com.yihu.jw.entity.util.TransforSqlUtl;
import com.yihu.jw.hospital.module.wx.dao.WechatTemplateConfigDao;
import com.yihu.jw.hospital.task.PushMsgTask;
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
import com.yihu.jw.hospital.utils.WeiXinOpenIdUtils;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.PatientHealthGuidanceDao;
import com.yihu.jw.patient.dao.PatientHealthGuidanceRecordDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * 健康指导业务处理类
 * @author George
 *
 */
@Component
@Transactional(rollbackFor = Exception.class)
public class PatientHealthGuidanceService {
	@Autowired
	private BaseDoctorDao doctorDao;
	@Autowired
	private BasePatientDao patientDao;
	@Autowired
    JdbcTemplate jdbcTemplate;
	@Autowired
	WeiXinOpenIdUtils weiXinOpenIdUtils;
	@Autowired
	private BasePatientService patientService;
	@Autowired
	private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
	@Autowired
	private PushMsgTask pushMsgTask;
	@Autowired
	private WechatTemplateConfigDao templateConfigDao;
	@Autowired
	private PatientHealthGuidanceDao patientHealthGuidanceDao;
	@Autowired
	private PatientHealthGuidanceRecordDao patientHealthGuidanceRecordDao;
	//	@Autowired
//	SignFamilyDao signFamilyDao;
	public JSONObject findById(Long id){
		PatientHealthGuidance guidance = patientHealthGuidanceDao.findById(id).orElse(null);
		if(guidance != null){
			JSONObject obj = new JSONObject(guidance);
			BaseDoctorDO doc = doctorDao.findById(guidance.getDoctor()).orElse(null);
			BasePatientDO p = patientDao.findById(guidance.getPatient()).orElse(null);
			obj.put("doctorName",doc.getName());
			obj.put("photo",doc.getPhoto());
			obj.put("name",doc.getName());
			obj.put("level",doc.getLevel());
			obj.put("patientName",p.getName());
			obj.put("czrq",guidance.getCzrq()!= null ? DateUtil.dateToStr(guidance.getCzrq(),DateUtil.YYYY_MM_DD_HH_MM) :"");
			return obj;
		}else{
			return null;
		}
	}
	/**
	 * 更改健康指导阅读状态
	 * @param id
	 * @return
	 */
	public void modifyStatus(String id,String type) {
		if("1".equals(type)){
//            一键设置居民未读指导
			String sql = "UPDATE wlyy_patient_health_guidance wphg " +
					"SET wphg .read_status = 1  "+
					"WHERE wphg.patient = ?";
			jdbcTemplate.update(sql,id);
		}else {
			String sql = "UPDATE wlyy_patient_health_guidance wphg " +
					"SET wphg .read_status = 1  " +
					"WHERE wphg.id = ?";
			jdbcTemplate.update(sql, id);
		}
	}
	/**
	 * 保存健康指导
	 * @param guidance
	 * @param modelName
	 * @return
	 */
	public PatientHealthGuidance add(PatientHealthGuidance guidance, String accessToken, String tzCode, String modelName) throws Exception {
		BaseDoctorDO doctor = doctorDao.findById(guidance.getDoctor()).orElse(null);
		BasePatientDO patient = patientDao.findById(guidance.getPatient()).orElse(null);
//		//家庭医生
//		SignFamily signFamily = signFamilyDao.findByjiatingPatient(guidance.getPatient());
//		//家庭医生不存在
//		if(signFamily == null){
//			 return null;
//		}
		guidance.setCzrq(new Date());
		guidance.setCreateTime(new Date());
		guidance.setDel("1");
//		guidance.setAdminTeamCode(signFamily.getAdminTeamId());
		guidance.setSignType(2);
		//保存签约CODE
//		guidance.setSignCode(patientService.getSignCodeByPatient(patient.getCode()));
		guidance = patientHealthGuidanceDao.save(guidance);
		String openId = null;
//		String name = null;
		JSONObject json = new JSONObject();
		//判定openId是否为空空,如果为空,查找他家人的openId
		if(StringUtils.isNotBlank(patient.getOpenid())){
			json.put("first", "健康指导提醒");
			//name = patient.getName();
			openId = patient.getOpenid();
		}
//		else{
//			JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(patient.getCode());
//			Patient member = (Patient)j.get("member");
//			openId = member.getOpenid();
//			//name = member.getName();
//			if (StringUtils.isNotEmpty(openId)) {
//				json.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.getInt("relation"), patient.getName()) + "健康指导提醒");
//			}
//		}
		if (guidance != null ) {
			json.put("toUser", patient.getId());
			json.put("represented",patient.getId());//被代理人
			json.put("id", guidance.getId());
			json.put("date", DateUtil.getStringDate());
//			json.put("orgName", doctor.getHospitalName());
			json.put("doctorName", doctor.getName());
//			json.put("content", "您好!医生给您发来了一份新的健康指导。");
			json.put("content", "《" + modelName + "》");
			json.put("remark", "请点击查看");
			if(StringUtils.isNotEmpty(openId)){
				//保存健康指导推送记录
				PatientHealthGuidanceRecord guidanceRecord = new PatientHealthGuidanceRecord();
				guidanceRecord.setCode(getCode());
				guidanceRecord.setPatient(patient.getId());
				guidanceRecord.setPatientOpenid(openId);
				guidanceRecord.setDoctor(doctor.getId());
				guidanceRecord.setContent(guidance.getContent());
				guidanceRecord.setDel(1);
				guidanceRecord.setImages(guidance.getImages());
				guidanceRecord.setVoice(guidance.getVoice());
				guidanceRecord.setReadStatus(0);
//				guidanceRecord.setAdminTeamCode(signFamily.getAdminTeamId());
				guidanceRecord.setCreateTime(new Date());
				patientHealthGuidanceRecordDao.save(guidanceRecord);
				// 推送消息到微信端
				pushMsgTask.putWxMsg(accessToken, 4, openId, patient.getName(), json);
			}else {
				//发送代理人
				JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient.getId(), patient.getOpenid());
				if (jsonArray != null && jsonArray.length() > 0) {
					for (int i = 0; i < jsonArray.length(); i++) {
						JSONObject j = jsonArray.getJSONObject(i);
						BasePatientDO member = (BasePatientDO) j.get("member");
						//保存健康指导推送记录
						PatientHealthGuidanceRecord guidanceRecord = new PatientHealthGuidanceRecord();
						guidanceRecord.setCode(getCode());
						guidanceRecord.setPatient(patient.getId());
						guidanceRecord.setPatientOpenid(member.getOpenid());
						guidanceRecord.setDoctor(doctor.getId());
						guidanceRecord.setContent(guidance.getContent());
						guidanceRecord.setDel(1);
						guidanceRecord.setImages(guidance.getImages());
						guidanceRecord.setVoice(guidance.getVoice());
						guidanceRecord.setReadStatus(0);
//						guidanceRecord.setAdminTeamCode(signFamily.getAdminTeamId());
						guidanceRecord.setCreateTime(new Date());
						patientHealthGuidanceRecordDao.save(guidanceRecord);
						JSONObject data = json;
						data.remove("toUser");
						data.put("toUser", member.getId());
						//String first = (String) json.get("first");
						data.remove("first");
						data.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.getInt("relation"), patient.getName()) + "健康指导提醒");
						pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 4, member.getOpenid(), patient.getName(), data);
					}
				}
			}
		}
		if(StringUtils.isNotEmpty(tzCode)&&!"undefined".equals(tzCode)){
			String sql = " select * from device.wlyy_patient_health_index i where id in ("+tzCode+")";
//			sql = TransforSqlUtl.wlyy_patient_health_index(sql);
			List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
			long h24 = 1000*60*60*24+10;
			for(Map<String, Object> one :list){
				if(one.get("manage_result")!=null&&((Integer)one.get("manage_result")==1||(Integer)one.get("manage_result")==2)) {
					continue;
				}
				String tempSql="";
				Date temp =(Date)one.get("czrq");
				if( new Date().getTime()-temp.getTime()<=h24){//有效干预
					tempSql = "update device.wlyy_patient_health_index set manage_result=1 where id="+one.get("id");
				}else{//无效干预
					tempSql = "update device.wlyy_patient_health_index set manage_result=2 where id="+one.get("id");
				}
				jdbcTemplate.execute(tempSql);
			}
			String tempSql="update wlyy.wlyy_message a set a.has_read = 0,a.over='0' where a.tz_code in ("+tzCode+") and a.type=2 ";
			jdbcTemplate.execute(tempSql);
		}
		return guidance;
	}
	/**
	 * 查询医生为患者添加的健康指导
	 * @param doctor 医生标识
	 * @param patient 患者标识
	 * @param id
	 * @param pagesize 分页大小
	 * @return
	 */
	public JSONArray findPatientGuidanceByDoctor(String doctor, String patient, String beginStr, String endStr, long id, int pagesize) {
		Date begin = DateUtil.strToDateLong(beginStr);
		Date end = DateUtil.strToDateLong(endStr);
		JSONArray array = new JSONArray();
		Page<Object> page = null;
		PageRequest pageRequest =  PageRequest.of(0, pagesize);
		if (id > 0) {
			if (StringUtils.isNotEmpty(patient)) {
				if (begin != null && end != null) {
					page = patientHealthGuidanceDao.findByDoctor(doctor, patient, begin, end, id, pageRequest);
				} else {
					page = patientHealthGuidanceDao.findByDoctor(doctor, patient, id, pageRequest);
				}
			} else {
				if (begin != null && end != null) {
					page = patientHealthGuidanceDao.findByDoctor(doctor, begin, end, id, pageRequest);
				} else {
					page = patientHealthGuidanceDao.findByDoctor(doctor, id, pageRequest);
				}
			}
		} else {
			if (StringUtils.isNotEmpty(patient)) {
				if (begin != null && end != null) {
					page = patientHealthGuidanceDao.findByDoctor(doctor, patient, begin, end, pageRequest);
				} else {
					page = patientHealthGuidanceDao.findByDoctor(doctor, patient, pageRequest);
				}
			} else {
				if (begin != null && end != null) {
					page = patientHealthGuidanceDao.findByDoctor(doctor, begin, end, pageRequest);
				} else {
					page = patientHealthGuidanceDao.findByDoctor(doctor, pageRequest);
				}
			}
		}
		if (page != null) {
			for (Object obj : page) {
				Object[] temp = (Object[]) obj;
				if (temp == null || temp.length != 5) {
					continue;
				}
				JSONObject json = new JSONObject();
				json.put("name", temp[0]);
				json.put("photo", temp[1]);
				json.put("id", temp[2]);
				json.put("content", temp[3]);
				json.put("czrq", DateUtil.dateToStrLong((Date) temp[4]));
				array.put(json);
			}
		}
		return array;
	}
	/**
	 * 健康指导查询
	 *
	 * @param patient
	 * @param teamCode
	 * @param page
	 * @param pageSize
	 * @return
	 */
	public JSONArray findByPatientAndGuidanceAndTeam(String patient, long teamCode, int page, int pageSize){
		Sort sort =  Sort.by(Sort.Direction.DESC,"createTime");
		PageRequest pageRequest =  PageRequest.of(page, pageSize, sort);
//		Page<Object> result = patientHealthGuidanceDao.findByPatientAndTeamCode(patient,teamCode,pageRequest);
		Page<Object> result =null;
		JSONArray array = new JSONArray();
		if (result != null) {
			for (Object obj : result) {
				Object[] temp = (Object[]) obj;
				JSONObject json = new JSONObject();
				json.put("doctorCode", temp[6]);
				json.put("doctorName", temp[0]);
				json.put("doctorPhoto", temp[1]);
				json.put("id", temp[2]);
				json.put("content", temp[3]);
				json.put("createTime", DateUtil.dateToStrLong((Date) temp[4]));
				json.put("adminTeamCode", temp[7]);
				json.put("readStatus", temp[8]);
				json.put("total", result.getTotalElements());
				array.put(json);
			}
		}
		return array;
	}
	/**
	 * 查询患者的健康指导
	 * @param patient 患者标识
	 * @param id
	 * @param pagesize 分页大小
	 * @return
	 */
	public JSONArray findGuidanceByPatient(String patient, long id, int pagesize) {
		JSONArray array = new JSONArray();
		// 分页信息
		PageRequest pageRequest =  PageRequest.of(0, pagesize);
		Page<Object> page = null;
		if (id > 0) {
			page = patientHealthGuidanceDao.findByPatient(patient, id, pageRequest);
		} else {
			page = patientHealthGuidanceDao.findByPatient(patient, pageRequest);
		}
		if (page != null) {
			for (Object obj : page) {
				Object[] temp = (Object[]) obj;
				if (temp == null || temp.length != 7) {
					continue;
				}
//				控制返回内容50字以内
				String content = temp[3].toString();
				String contain = "";
				if(content.length()>50){
					contain = content.substring(0,50);
				}else {
					contain = content.substring(0,content.length()-1);
				}
				JSONObject json = new JSONObject();
				json.put("name", temp[0]);
				json.put("photo", temp[1]);
				json.put("id", temp[2]);
				json.put("content", contain);
				json.put("createTime", DateUtil.dateToStrLong((Date) temp[4]));
				json.put("level", temp[5]);
				json.put("readStatus", temp[6]);
				array.put(json);
			}
		}
		return array;
	}
	public Integer findGuidanceByPatient(String patientCode, String doctor) {
		return patientHealthGuidanceDao.findbydoctorAndPatient(doctor,patientCode);
	}
	
	public JSONArray getPatientHealthGuidance(String idcard, String page, String pageSize) throws Exception {
		BasePatientDO patient = patientDao.findByIdcard(idcard);
		
		if(patient == null || StringUtils.isBlank(patient.getId())){
			throw new RuntimeException("找不到该身份证号的居民!");
		}
		
		JSONArray array = new JSONArray();
		// 分页信息,排序
		Sort sort =  Sort.by(Sort.Direction.DESC,"createTime");
		// 分页信息
		PageRequest pageRequest =  PageRequest.of(Integer.valueOf(page) - 1, Integer.valueOf(pageSize), sort);
		Page<Object> pageObj = null;
		pageObj = patientHealthGuidanceDao.findByPatient(patient.getId(), pageRequest);
		if (page != null) {
			for (Object obj : pageObj) {
				Object[] temp = (Object[]) obj;
				if (temp == null || temp.length != 7) {
					continue;
				}
//				控制返回内容50字以内
				String content = temp[3].toString();
				String contain = "";
				if(content.length()>50){
					contain = content.substring(0,50);
				}else {
					contain = content.substring(0,content.length()-1);
				}
				JSONObject json = new JSONObject();
				json.put("name", temp[0]);
				json.put("photo", temp[1]);
				json.put("id", temp[2]);
				json.put("content", contain);
				json.put("contentAll", content);
				json.put("createTime", DateUtil.dateToStrLong((Date) temp[4]));
				json.put("level", temp[5]);
				json.put("readStatus", temp[6]);
				array.put(json);
			}
		}
		return array;
	}
	public String getCode() {
		return UUID.randomUUID().toString().replaceAll("-", "");
	}
}

+ 1 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/PatientHealthRecordService.java

@ -2,7 +2,7 @@ package com.yihu.jw.hospital.module.health.service;
import com.yihu.jw.entity.base.health.*;
import com.yihu.jw.health.*;
import com.yihu.jw.hospital.module.health.dao.*;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;

+ 2 - 2
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/SportsService.java

@ -3,8 +3,8 @@ package com.yihu.jw.hospital.module.health.service;
import com.yihu.jw.entity.base.health.Sports;
import com.yihu.jw.entity.base.health.SportsType;
import com.yihu.jw.health.SportsDao;
import com.yihu.jw.health.SportsTypeDao;
import com.yihu.jw.hospital.module.health.dao.SportsDao;
import com.yihu.jw.hospital.module.health.dao.SportsTypeDao;
import com.yihu.jw.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

+ 2225 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/service/scheme/DoctorSchemeService.java

@ -0,0 +1,2225 @@
package com.yihu.jw.hospital.module.health.service.scheme;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.device.dao.DevicePatientHealthIndexDao;
import com.yihu.jw.device.dao.PatientAimBloodPressureDao;
import com.yihu.jw.device.dao.PatientAimBloodSuggerDao;
import com.yihu.jw.device.dao.PatientAimSportsDao;
import com.yihu.jw.entity.base.device.PatientAimBloodPressure;
import com.yihu.jw.entity.base.device.PatientAimBloodSugger;
import com.yihu.jw.entity.base.device.PatientAimSports;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.scheme.*;
import com.yihu.jw.entity.scheme.vo.DoctorSchemeBloodPressureVO;
import com.yihu.jw.entity.scheme.vo.DoctorSchemeBloodSuggerVO;
import com.yihu.jw.hospital.module.health.dao.*;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.patient.PatientVO;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.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.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
 * 医生监测方案相关业务层方法
 *
 * @author huangwenjie
 * @date 2017/9/13 15:46
 */
@Service
@Transactional
public class DoctorSchemeService {
    private static Logger logger = LoggerFactory.getLogger(DoctorSchemeService.class);
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    private DoctrorSchemeBloodSuggerDao doctroSchemeBloodSuggerDao;
    @Autowired
    private DoctoreSchemeBloodPressureDao doctoreSchemeBloodPressureDao;
    @Autowired
    private JpaTransactionManager transactionManager;
    @Autowired
    private PatientSchemeListDao patientSchemeListDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private DevicePatientHealthIndexDao devicePatientHealthIndexDao;
    @Autowired
    private PatientAimBloodSuggerDao patientAimBloodSuggerDao;
    @Autowired
    private PatientAimBloodPressureDao patientAimBloodPressureDao;
    @Autowired
    private DoctorSwitchDao doctorSwitchDao;
    @Autowired
    private TrackPatientDao trackPatientDao;
    @Autowired
    private PatientAimSportsDao patientAimSportsDao;
    @Value("${im.data_base_name}")
    private String im_dataBase_name;
    /**
     * 根据团队CODE/居民标签/病情/设备绑定状态查询团队具名CODE列表
     *
     * @param teamCode         团队CODE
     * @param disease          病情
     * @param diseaseCondition 居民标签
     * @param deviceType       设备绑定状态
     * @return
     * @author huangwenjie
     * @date 2017/9/13 16:23
     */
    public List<String> getPatientsByDiseaseConditionDiseaseDeviceType(String teamCode, Integer disease, String diseaseCondition, Integer deviceType, String doctorcode, String trackFlag) throws Exception {
        String sql = "SELECT  a.id\n" +
                "FROM base_patient a \n" +
                "INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n";
        //1.4.2加入跟踪居民过滤
        if (StringUtils.isNotBlank(trackFlag) && "1".equals(trackFlag)) {
            sql = sql + " INNER JOIN wlyy_track_patient tp ON tp.patient_code = a.id ";
        }
        if (-1 != deviceType) {
            sql = sql + " LEFT JOIN wlyy_patient_device dev on dev.user = a.id ";
        }
        sql += "WHERE 1=1\n";
        //疾病类型,-1全部,0健康,1高血压,2糖尿病,3高血压+糖尿病
        if (-1 == disease) {
            sql += " AND a.disease IN ('1','2','1,2','2,1') ";
        } else {
            if (disease == 3) {
                sql += " AND a.disease IN ('1,2','2,1') ";
            } else {
                sql += " and a.disease ='" + disease + "' ";
            }
        }
        if (StringUtils.isNotBlank(diseaseCondition) && !"-1".equals(diseaseCondition)) {
            sql += " AND a.disease_condition IN (" + diseaseCondition + ") ";
        }
        if (-1 != deviceType) {
            if (0 == deviceType) {
                sql = sql + " and dev.user is null ";
            } else {
                sql = sql + " and dev.user is not null ";
            }
        }
        sql += " AND b.doctor_id ='" + doctorcode + "' ";
        //1.4.2加入跟踪居民过滤
        if (StringUtils.isNotBlank(trackFlag) && "1".equals(trackFlag)) {
            sql += " AND tp.del='1' AND tp.doctor_code = '" + doctorcode + "' ";
        }
        List<String> result = jdbcTemplate.queryForList(sql, new Object[]{}, String.class);
        return result;
    }
    /**
     * 获取医生的血糖监测方案,根据创建时间降序排序,系统方案放最后
     *
     * @param doctorcode
     * @return
     * @throws Exception
     */
    public List<DoctorSchemeBloodSuggerVO> getDoctorScheBloodSuggerList(String doctorcode) throws Exception {
        List<DoctorSchemeBloodSuggerVO> result = new ArrayList<>();
        HashMap<String, List<DoctorSchemeBloodSugger>> mapresult = new HashMap<>();
        LinkedList<String> keys = new LinkedList<>();
        List<DoctorSchemeBloodSugger> schemelist = doctroSchemeBloodSuggerDao.getListByDoctorcode(doctorcode);
        if (!schemelist.isEmpty()) {
            for (DoctorSchemeBloodSugger doctorSchemeBloodSugger : schemelist) {
                if (keys.contains(doctorSchemeBloodSugger.getCode())) {
                    mapresult.get(doctorSchemeBloodSugger.getCode()).add(doctorSchemeBloodSugger);
                } else {
                    List<DoctorSchemeBloodSugger> list = new ArrayList<>();
                    list.add(doctorSchemeBloodSugger);
                    mapresult.put(doctorSchemeBloodSugger.getCode(), list);
                    keys.add(doctorSchemeBloodSugger.getCode());
                }
            }
            for (String key : keys) {
                DoctorSchemeBloodSuggerVO doctorSchemeBloodSuggerVO = new DoctorSchemeBloodSuggerVO();
                doctorSchemeBloodSuggerVO.setCode(key);
                doctorSchemeBloodSuggerVO.setName(mapresult.get(key).get(0).getName());
                doctorSchemeBloodSuggerVO.setContent(mapresult.get(key).get(0).getContent());
                doctorSchemeBloodSuggerVO.setList(mapresult.get(key));
                result.add(doctorSchemeBloodSuggerVO);
            }
        }
        return result;
    }
    /**
     * 获取医生的血压监测方案,根据创建时间降序排序,系统方案放最后
     *
     * @param doctorcode
     * @return
     * @throws Exception
     */
    public List<DoctorSchemeBloodPressureVO> getDoctorSchemeBloodPressureList(String doctorcode) throws Exception {
        List<DoctorSchemeBloodPressureVO> result = new ArrayList<>();
        HashMap<String, List<DoctorSchemeBloodPressure>> mapresult = new HashMap<>();
        List<DoctorSchemeBloodPressure> schemelist = doctoreSchemeBloodPressureDao.getListByDoctorcode(doctorcode);
        LinkedList<String> keys = new LinkedList<>();
        if (!schemelist.isEmpty()) {
            for (DoctorSchemeBloodPressure doctorSchemeBloodPressure : schemelist) {
                if (keys.contains(doctorSchemeBloodPressure.getCode())) {
                    mapresult.get(doctorSchemeBloodPressure.getCode()).add(doctorSchemeBloodPressure);
                } else {
                    List<DoctorSchemeBloodPressure> list = new ArrayList<>();
                    list.add(doctorSchemeBloodPressure);
                    mapresult.put(doctorSchemeBloodPressure.getCode(), list);
                    keys.add(doctorSchemeBloodPressure.getCode());
                }
            }
            for (String key : keys) {
                DoctorSchemeBloodPressureVO doctorSchemeBloodPressureVO = new DoctorSchemeBloodPressureVO();
                doctorSchemeBloodPressureVO.setCode(key);
                doctorSchemeBloodPressureVO.setName(mapresult.get(key).get(0).getName());
                doctorSchemeBloodPressureVO.setContent(mapresult.get(key).get(0).getContent());
                doctorSchemeBloodPressureVO.setList(mapresult.get(key));
                result.add(doctorSchemeBloodPressureVO);
            }
        }
        return result;
    }
    /**
     * 医生保存血糖监测方案
     *
     * @param data
     * @throws Exception
     */
    public void saveDoctorSchemeBloodSugger(String data) throws Exception {
        JSONObject dataObj = JSON.parseObject(data);
        List<DoctorSchemeBloodSugger> results = new ArrayList<>();
        String code = dataObj.getString("code");
        if (StringUtils.isBlank(code)) {
            code = UUID.randomUUID().toString();
        }
        String name = dataObj.getString("name");
        String content = dataObj.getString("content");
        String doctorcode = dataObj.getString("doctorcode");
        JSONArray datalist = dataObj.getJSONArray("list");
        for (int i = 0; i < datalist.size(); i++) {
            DoctorSchemeBloodSugger doctorSchemeBloodSugger = new DoctorSchemeBloodSugger();
            long id = 0;
            if (datalist.getJSONObject(i).containsKey("id")) {
                id = datalist.getJSONObject(i).getLong("id");
            }
            if (id != 0) {
                doctorSchemeBloodSugger.setId(datalist.getJSONObject(i).getLong("id"));
            }
            doctorSchemeBloodSugger.setName(name);
            doctorSchemeBloodSugger.setCode(code);
            doctorSchemeBloodSugger.setDoctorcode(doctorcode);
            doctorSchemeBloodSugger.setDayofweek(datalist.getJSONObject(i).getShort("dayofweek"));
            doctorSchemeBloodSugger.setBeforeBreakfast(datalist.getJSONObject(i).getShort("beforeBreakfast"));
            doctorSchemeBloodSugger.setBeforeBreakfastTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeBreakfastTime")));
            doctorSchemeBloodSugger.setAfterBreakfast(datalist.getJSONObject(i).getShort("afterBreakfast"));
            doctorSchemeBloodSugger.setAfterBreakfastTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterBreakfastTime")));
            doctorSchemeBloodSugger.setBeforeLunch(datalist.getJSONObject(i).getShort("beforeLunch"));
            doctorSchemeBloodSugger.setBeforeLunchTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeLunchTime")));
            doctorSchemeBloodSugger.setAfterLunch(datalist.getJSONObject(i).getShort("afterLunch"));
            doctorSchemeBloodSugger.setAfterLunchTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterLunchTime")));
            doctorSchemeBloodSugger.setBeforeDinner(datalist.getJSONObject(i).getShort("beforeDinner"));
            doctorSchemeBloodSugger.setBeforeDinnerTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeDinnerTime")));
            doctorSchemeBloodSugger.setAfterDinner(datalist.getJSONObject(i).getShort("afterDinner"));
            doctorSchemeBloodSugger.setAfterDinnerTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterDinnerTime")));
            doctorSchemeBloodSugger.setBeforeSleep(datalist.getJSONObject(i).getShort("beforeSleep"));
            doctorSchemeBloodSugger.setBeforeSleepTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("beforeSleepTime")));
            doctorSchemeBloodSugger.setAlertTag(datalist.getJSONObject(i).getShort("alertTag"));
            doctorSchemeBloodSugger.setContent(content);
            doctorSchemeBloodSugger.setCreateTime(DateUtil.getNowTimestamp());
            doctorSchemeBloodSugger.setDel(0);
            results.add(doctorSchemeBloodSugger);
        }
        if (!results.isEmpty()) {
            doctroSchemeBloodSuggerDao.saveAll(results);
        }
    }
    /**
     * 医生保存血压监测方案
     *
     * @param data
     * @throws Exception
     */
    public void saveDoctorSchemeBloodPressure(String data) throws Exception {
        JSONObject dataObj = JSON.parseObject(data);
        List<DoctorSchemeBloodPressure> results = new ArrayList<>();
        String code = dataObj.getString("code");
        if (StringUtils.isBlank(code)) {
            code = UUID.randomUUID().toString();
        }
        String name = dataObj.getString("name");
        String content = dataObj.getString("content");
        String doctorcode = dataObj.getString("doctorcode");
        JSONArray datalist = dataObj.getJSONArray("list");
        for (int i = 0; i < datalist.size(); i++) {
            DoctorSchemeBloodPressure doctorSchemeBloodPressure = new DoctorSchemeBloodPressure();
            long id = 0;
            if (datalist.getJSONObject(i).containsKey("id")) {
                id = datalist.getJSONObject(i).getLong("id");
            }
            if (id != 0) {
                doctorSchemeBloodPressure.setId(datalist.getJSONObject(i).getLong("id"));
            }
            doctorSchemeBloodPressure.setName(name);
            doctorSchemeBloodPressure.setCode(code);
            doctorSchemeBloodPressure.setDoctorcode(doctorcode);
            doctorSchemeBloodPressure.setDayofweek(datalist.getJSONObject(i).getShort("dayofweek"));
            doctorSchemeBloodPressure.setEarlyMorning(datalist.getJSONObject(i).getShort("earlyMorning"));
            doctorSchemeBloodPressure.setEarlyMorningTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("earlyMorningTime")));
            doctorSchemeBloodPressure.setMorning(datalist.getJSONObject(i).getShort("morning"));
            doctorSchemeBloodPressure.setMorningTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("morningTime")));
            doctorSchemeBloodPressure.setNoon(datalist.getJSONObject(i).getShort("noon"));
            doctorSchemeBloodPressure.setNoonTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("noonTime")));
            doctorSchemeBloodPressure.setAfterNoon(datalist.getJSONObject(i).getShort("afterNoon"));
            doctorSchemeBloodPressure.setAfterNoonTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("afterNoonTime")));
            doctorSchemeBloodPressure.setNight(datalist.getJSONObject(i).getShort("night"));
            doctorSchemeBloodPressure.setNightTime(DateUtil.hhmmStrToTime(datalist.getJSONObject(i).getString("nightTime")));
            doctorSchemeBloodPressure.setAlertTag(datalist.getJSONObject(i).getShort("alertTag"));
            doctorSchemeBloodPressure.setContent(content);
            doctorSchemeBloodPressure.setCreateTime(DateUtil.getNowTimestamp());
            doctorSchemeBloodPressure.setDel(0);
            results.add(doctorSchemeBloodPressure);
        }
        if (!results.isEmpty()) {
            doctoreSchemeBloodPressureDao.saveAll(results);
        }
    }
    /**
     * 医生保存居民监测方案
     *
     * @param doctorcode
     * @param schemecode
     * @param patientcodes
     * @param type
     * @throws Exception
     */
    @Transactional
    public void savePatientScheme(String doctorcode, String schemecode, String type, String patientcodes) throws Exception {
        List<String> patientcodeList = new ArrayList<>();
        String[] codes = patientcodes.split(",");
        if (patientcodes.contains(",")) {
            for (String code : codes) {
                patientcodeList.add(code);
            }
        } else {
            patientcodeList.add(patientcodes);
        }
        if (!patientcodeList.isEmpty()) {
            //使用事务控制批量更新
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
            try {
                for (String patientcode : patientcodeList) {
                    patientSchemeListDao.delByPatientCode(patientcode, Integer.parseInt(type));
                    PatientSchemeList patientSchemeListObj = new PatientSchemeList();
                    patientSchemeListObj.setCode(UUID.randomUUID().toString());
                    patientSchemeListObj.setPatientcode(patientcode);
                    patientSchemeListObj.setSchemecode(schemecode);
                    patientSchemeListObj.setDoctorcode(doctorcode);
                    patientSchemeListObj.setType(Integer.parseInt(type));
                    patientSchemeListObj.setCreateTime(DateUtil.getNowTimestamp());
                    patientSchemeListDao.save(patientSchemeListObj);
                }
                //事务提交
                transactionManager.commit(status);
            } catch (Exception ex) {
                ex.printStackTrace();
                //报错事务回滚
                transactionManager.rollback(status);
            }
        }
    }
    /**
     * 医生端-获取慢病管理居民管理端数据
     *
     * @param teamCode
     * @param getcolor
     * @param getstands
     * @param gethealthindex
     * @param startdate
     * @param enddate
     * @return
     */
    public JSONObject getSlowDiseaseTeaminfos(String teamCode, int getcolor, int getstands, int gethealthindex, String startdate, String enddate, String doctorcode) throws Exception {
        List<PatientVO> patients = new ArrayList<>();
        String patientsql = "SELECT DISTINCT\n" +
                "	a.id 'code',\n" +
                "	a.standard_status ,\n" +
                "	a.disease,\n" +
                "	a.disease_condition \n" +
                "FROM\n" +
                "	base_patient a \n" +
                "	INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "WHERE 1=1\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND a.disease IN ('1','2','1,2','2,1')\n" +
                "AND b.doctor_id ='" + doctorcode + "'";
        patients = jdbcTemplate.query(patientsql, new BeanPropertyRowMapper(PatientVO.class));
        JSONObject result = new JSONObject();
        JSONObject green = new JSONObject();//绿标
        JSONObject yellow = new JSONObject();//黄标
        JSONObject red = new JSONObject();//红标
        JSONObject pressure_standard = new JSONObject();//血压预警
        JSONObject sugar_standard = new JSONObject();//血糖预警
        JSONObject pressure_count = new JSONObject();//血压体征总数
        JSONObject pressure_unusual_ount = new JSONObject();//血压体征总数
        JSONObject sugar_count = new JSONObject();//血糖体征总数
        JSONObject sugar_unusual_count = new JSONObject();//血糖体征总数
        int count = patients.size();
        //绿标居民
        List<PatientVO> green_patients = new ArrayList<>();
        //黄标居民
        List<PatientVO> yellow_patients = new ArrayList<>();
        //红标居民
        List<PatientVO> red_patients = new ArrayList<>();
        //高血压居民预警居民CODE
        List<String> bloodpressure_patientcodes = new ArrayList<>();
        //高血糖居民预警居民CODE
        List<String> bloodsugar_patientcodes = new ArrayList<>();
        if (!patients.isEmpty()) {
            for (PatientVO patient : patients) {
                //获取居民颜色标签
                if (1 == getcolor && patient.getDiseaseCondition() != null) {
                    switch (patient.getDiseaseCondition()) {
                        case 0:
                            green_patients.add(patient);
                            break;
                        case 1:
                            yellow_patients.add(patient);
                            break;
                        case 2:
                            red_patients.add(patient);
                            break;
                    }
                }
                //获取预警居民CODES
                if (1 == getstands && (patient.getStandardStatus() != null && patient.getStandardStatus() == 1)) {
                    if (patient.getDisease() != null) {
                        if ("1".equals(patient.getDisease()) || "1,2".equals(patient.getDisease()) || "2,1".equals(patient.getDisease())) {
                            bloodpressure_patientcodes.add(patient.getCode());
                        }
                        if ("2".equals(patient.getDisease()) || "1,2".equals(patient.getDisease()) || "2,1".equals(patient.getDisease())) {
                            bloodsugar_patientcodes.add(patient.getCode());
                        }
                    }
                }
            }
        }
        if (1 == getcolor) {
            result.put("greencount", green_patients.size());
            result.put("yellowcount", yellow_patients.size());
            result.put("redcount", red_patients.size());
        }
        if (1 == getstands) {
            result.put("pressure_standard", bloodpressure_patientcodes);
            result.put("sugar_standard", bloodsugar_patientcodes);
        }
        if (1 == gethealthindex) {
            Date start = DateUtil.strToDate(startdate);
            Date end = DateUtil.strToDate(enddate);
//            List<DevicePatientHealthIndex> devicePatientHealthIndices = devicePatientHealthIndexDao.findByTeamcodeAndRecordDate(start,end,teamCode,doctorcode);
            List<DevicePatientHealthIndex> devicePatientHealthIndices = devicePatientHealthIndexDao.findByDoctor(start, end, doctorcode);
            int sugar = 0;
            int sugar_unusual = 0;
            int pressure = 0;
            int pressure_unusual = 0;
            if (!devicePatientHealthIndices.isEmpty()) {
                for (DevicePatientHealthIndex devicePatientHealthIndex : devicePatientHealthIndices) {
                    if (1 == devicePatientHealthIndex.getType()) {
                        sugar++;
                        if (devicePatientHealthIndex.getStatus() != null && 0 == devicePatientHealthIndex.getStatus()) {
                            sugar_unusual++;
                        }
                    }
                    if (2 == devicePatientHealthIndex.getType()) {
                        pressure++;
                        if (devicePatientHealthIndex.getStatus() != null && 0 == devicePatientHealthIndex.getStatus()) {
                            pressure_unusual++;
                        }
                    }
                }
            }
            result.put("pressure_count", pressure);
            result.put("pressure_unusual_count", pressure_unusual);
            result.put("sugar_count", sugar);
            result.put("sugar_unusual_count", sugar_unusual);
        }
        //1.4.2 重点关注居民
        List<TrackPatient> list = trackPatientDao.findByDoctor(doctorcode, "1");
        if (list != null && list.size() > 0) {
            result.put("trackPatientCount", list.size());
        } else {
            result.put("trackPatientCount", 0);
        }
        return result;
    }
    /**
     * 删除医生监测方案
     *
     * @param doctorcode
     * @param schemecode
     * @param type
     */
    @Transactional
    public void delDoctorScheme(String doctorcode, String schemecode, String type) throws Exception {
        if ("1".equals(type)) {
            doctroSchemeBloodSuggerDao.updateDelStatus(1, doctorcode, schemecode);
        }
        if ("2".equals(type)) {
            doctoreSchemeBloodPressureDao.updateDelStatus(1, doctorcode, schemecode);
        }
        List<PatientSchemeList> list = patientSchemeListDao.findBySchemecode(schemecode);
        if (list != null && list.size() > 0) {
            patientSchemeListDao.deleteAll(list);
        }
    }
    public Map<String, Object> getPatientHealthIndex(String patient, String startDate, String endDate, String type) {
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
        String highSql = "SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS highCount " +
                " FROM " +
                " ( " +
                " SELECT " +
                " COUNT(1) AS befHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(1,3,5,7) " +
                " AND i.value1 > 7 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user ='" + patient + "'" +
                " ) bf, " +
                " (  " +
                " SELECT " +
                " COUNT(1) AS aftHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(2,4,6) " +
                " AND i.value1 > 11.1 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user ='" + patient + "'" +
                " ) aft";
        String stdSql = "SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS stdCount " +
                " FROM " +
                " ( " +
                " SELECT " +
                " COUNT(1) AS befHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(1,3,5,7) " +
                " AND i.value1 <= 7 " +
                " AND i.value1 >= 4 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user ='" + patient + "'" +
                " ) bf, " +
                " (  " +
                " SELECT " +
                " COUNT(1) AS aftHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(2,4,6) " +
                " AND i.value1 <= 11.1 " +
                " AND i.value1 >= 4 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user ='" + patient + "'" +
                " ) aft";
        String lowSql = "SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS lowCount " +
                " FROM " +
                " ( " +
                " SELECT " +
                " COUNT(1) AS befHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(1,3,5,7) " +
                " AND i.value1 < 4 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user ='" + patient + "'" +
                " ) bf, " +
                " (  " +
                " SELECT " +
                " COUNT(1) AS aftHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(2,4,6) " +
                " AND i.value1 < 4 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user ='" + patient + "'" +
                " ) aft";
        String pHighSql = "SELECT " +
                " count(1) AS highCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = '2' " +
                " AND i.value1 > 139 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user ='" + patient + "'";
        String pStdSql = "SELECT " +
                " count(1) AS stdCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = '2' " +
                " AND i.value1 <= 139 " +
                " AND i.value1 >= 90 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user ='" + patient + "'";
        String pLowSql = "SELECT " +
                " count(1) AS lowCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = '2' " +
                " AND i.value1 < 90 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user ='" + patient + "'";
        Map<String, Object> rs = new HashedMap();
        //0血檀
        if ("0".equals(type)) {
            //1.高
            List<Map<String, Object>> high = jdbcTemplate.queryForList(highSql);
            if (high != null && high.size() > 0) {
                Map<String, Object> h = high.get(0);
                rs.put("highCount", h.get("highCount"));
            }
            //2.正常
            List<Map<String, Object>> std = jdbcTemplate.queryForList(stdSql);
            if (std != null && std.size() > 0) {
                Map<String, Object> st = std.get(0);
                rs.put("stdCount", st.get("stdCount"));
            }
            //3.偏低
            List<Map<String, Object>> low = jdbcTemplate.queryForList(lowSql);
            if (low != null && low.size() > 0) {
                Map<String, Object> lw = low.get(0);
                rs.put("lowCount", lw.get("lowCount"));
            }
            //其他血压
        } else {
            //1.高
            List<Map<String, Object>> high = jdbcTemplate.queryForList(pHighSql);
            if (high != null && high.size() > 0) {
                Map<String, Object> h = high.get(0);
                rs.put("highCount", h.get("highCount"));
            }
            //2.正常
            List<Map<String, Object>> std = jdbcTemplate.queryForList(pStdSql);
            if (std != null && std.size() > 0) {
                Map<String, Object> st = std.get(0);
                rs.put("stdCount", st.get("stdCount"));
            }
            //3.偏低
            List<Map<String, Object>> low = jdbcTemplate.queryForList(pLowSql);
            if (low != null && low.size() > 0) {
                Map<String, Object> lw = low.get(0);
                rs.put("lowCount", lw.get("lowCount"));
            }
        }
        return rs;
    }
    public Map<String, Object> getPatientHealthIndexNew(String startDate, String endDate, String type, String doctor) {
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
        String highSql = "SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS highCount " +
                " FROM " +
                " ( " +
                " SELECT " +
                " COUNT(1) AS befHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(1,3,5,7) " +
                " AND i.value1 > 7 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (" +
                "SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )" +
                " ) bf, " +
                " (  " +
                " SELECT " +
                " COUNT(1) AS aftHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(2,4,6) " +
                " AND i.value1 > 11.1 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )" +
                " ) aft";
        String stdSql = "SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS stdCount " +
                " FROM " +
                " ( " +
                " SELECT " +
                " COUNT(1) AS befHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(1,3,5,7) " +
                " AND i.value1 <= 7 " +
                " AND i.value1 >= 4 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )" +
                " ) bf, " +
                " (  " +
                " SELECT " +
                " COUNT(1) AS aftHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(2,4,6) " +
                " AND i.value1 <= 11.1 " +
                " AND i.value1 >= 4 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )" +
                " ) aft";
        String lowSql = "SELECT  " +
                " (bf.befHighCount + aft.aftHighCount) AS lowCount " +
                " FROM " +
                " ( " +
                " SELECT " +
                " COUNT(1) AS befHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(1,3,5,7) " +
                " AND i.value1 < 4 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )" +
                " ) bf, " +
                " (  " +
                " SELECT " +
                " COUNT(1) AS aftHighCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.type = '1' " +
                " AND i.del = '1' " +
                " AND i.value2 in(2,4,6) " +
                " AND i.value1 < 4 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )" +
                " ) aft";
        String pHighSql = "SELECT " +
                " count(1) AS highCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = '2' " +
                " AND i.value1 > 139 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )";
        String pStdSql = "SELECT " +
                " count(1) AS stdCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = '2' " +
                " AND i.value1 <= 139 " +
                " AND i.value1 >= 90 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' )";
        String pLowSql = "SELECT " +
                " count(1) AS lowCount " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = '2' " +
                " AND i.value1 < 90 " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " AND i.user IN (SELECT t.patient_code FROM wlyy.wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "')";
        Map<String, Object> rs = new HashedMap();
        //0血檀
        if ("0".equals(type)) {
            //1.高
            List<Map<String, Object>> high = jdbcTemplate.queryForList(highSql);
            if (high != null && high.size() > 0) {
                Map<String, Object> h = high.get(0);
                rs.put("highCount", h.get("highCount"));
            }
            //2.正常
            List<Map<String, Object>> std = jdbcTemplate.queryForList(stdSql);
            if (std != null && std.size() > 0) {
                Map<String, Object> st = std.get(0);
                rs.put("stdCount", st.get("stdCount"));
            }
            //3.偏低
            List<Map<String, Object>> low = jdbcTemplate.queryForList(lowSql);
            if (low != null && low.size() > 0) {
                Map<String, Object> lw = low.get(0);
                rs.put("lowCount", lw.get("lowCount"));
            }
            //其他血压
        } else {
            //1.高
            List<Map<String, Object>> high = jdbcTemplate.queryForList(pHighSql);
            if (high != null && high.size() > 0) {
                Map<String, Object> h = high.get(0);
                rs.put("highCount", h.get("highCount"));
            }
            //2.正常
            List<Map<String, Object>> std = jdbcTemplate.queryForList(pStdSql);
            if (std != null && std.size() > 0) {
                Map<String, Object> st = std.get(0);
                rs.put("stdCount", st.get("stdCount"));
            }
            //3.偏低
            List<Map<String, Object>> low = jdbcTemplate.queryForList(pLowSql);
            if (low != null && low.size() > 0) {
                Map<String, Object> lw = low.get(0);
                rs.put("lowCount", lw.get("lowCount"));
            }
        }
        return rs;
    }
    public Map<String, Object> getTrackPatientInfo(String patient) {
        Map<String, Object> rs = new HashedMap();
        rs.put("wxSport", 0);
        String hsql = "SELECT " +
                " i.value1 AS weight, " +
                " i.value2 AS height, " +
                " i.value3 AS BMI " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = '3'  " +
                " AND i.user ='" + patient + "'" +
                " ORDER BY " +
                " i.record_date DESC LIMIT 0,1";
        String xtSchSql = "SELECT " +
                " l.*," +
                " s.name " +
                " FROM " +
                " wlyy_patient_scheme_list l JOIN wlyy_doctor_scheme_blood_sugger s ON s.code = l.schemecode  " +
                " WHERE " +
                " l.type = 1 " +
                " AND l.patientcode = '" + patient + "'";
        String xySchSql = "SELECT " +
                " l.*," +
                " s.name " +
                " FROM " +
                " wlyy_patient_scheme_list l JOIN wlyy_doctor_scheme_blood_pressure s ON s.code = l.schemecode" +
                " WHERE " +
                " l.type = 2 " +
                " AND l.patientcode = '" + patient + "'";
        List<Map<String, Object>> hList = jdbcTemplate.queryForList(hsql);
        if (hList != null && hList.size() > 0) {
            Map<String, Object> body = hList.get(0);
            rs.put("body", body);
        } else {
            rs.put("body", null);
        }
        List<Map<String, Object>> xtList = jdbcTemplate.queryForList(xtSchSql);
        if (xtList != null && xtList.size() > 0) {
            rs.put("sugger", xtList.get(0));
        } else {
            rs.put("sugger", null);
        }
        List<Map<String, Object>> xyList = jdbcTemplate.queryForList(xySchSql);
        if (xyList != null && xyList.size() > 0) {
            rs.put("pressure", xyList.get(0));
        } else {
            rs.put("pressure", null);
        }
        return rs;
    }
    public Map<String, Object> getControlObjectives(String patient) {
        Map<String, Object> rs = new HashedMap();
        PatientAimBloodSugger patientAimBloodSugger = patientAimBloodSuggerDao.findByPatientcode(patient);
        PatientAimBloodPressure patientAimBloodPressure = patientAimBloodPressureDao.findByPatientcode(patient);
        PatientAimSports patientAimSports = patientAimSportsDao.getPatientAimSportsByPatientCode(patient);
        rs.put("patientAimBloodSugger", patientAimBloodSugger);
        rs.put("patientAimBloodPressure", patientAimBloodPressure);
        rs.put("patientAimSports", patientAimSports);
        return rs;
    }
    public List<Map<String, Object>> getBodyInfo(String patient, String startDate, String endDate, Integer page, Integer size) {
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
        String sql = "SELECT " +
                " i.record_date, " +
                " i.value1 AS weight, " +
                " i.value2 AS height, " +
                " i.value3 AS BMI " +
                " FROM " +
                " device.wlyy_patient_health_index i " +
                " WHERE " +
                " i.del = '1' " +
                " AND i.type = 3 " +
                " AND i.`user` = '" + patient + "' " +
                " AND i.record_date >='" + startDate + "'" +
                " AND i.record_date <='" + endDate + "'" +
                " ORDER BY " +
                " i.record_date DESC LIMIT " + (page - 1) * size + "," + size;
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
    public String setDoctorSwitchTrackPatient(String doctor, String state) {
        DoctorSwitch doctorSwitch = doctorSwitchDao.findByDoctor(doctor);
        if (doctorSwitch != null) {
            doctorSwitch.setAlertPatientSwitch(state);
        } else {
            DoctorSwitch dw = new DoctorSwitch();
            dw.setDoctor(doctor);
            dw.setAlertPatientSwitch(state);
            dw.setCreateTime(new Date());
            doctorSwitchDao.save(dw);
        }
        return "0";
    }
    public Map<String, Object> getDoctorSwitchTrackPatient(String doctor) {
        DoctorSwitch doctorSwitch = doctorSwitchDao.findByDoctor(doctor);
        Map<String, Object> rs = new HashedMap();
        if (doctorSwitch != null) {
            rs.put("alertPatientSwitch", doctorSwitch.getAlertPatientSwitch());
        } else {
            DoctorSwitch dw = new DoctorSwitch();
            dw.setDoctor(doctor);
            dw.setAlertPatientSwitch("0");
            dw.setCreateTime(new Date());
            doctorSwitchDao.save(dw);
            rs.put("alertPatientSwitch", "0");
        }
        return rs;
    }
    public Map<String, Object> getTrackPatientCountTitle(String doctor, String startDate, String endDate) {
//        List<TrackPatient> trackPatients = trackPatientDao.findByDoctorCodeAndTeamCodeAndDel(doctor, teamCode, "1");
        List<TrackPatient> trackPatients = trackPatientDao.findByDoctor(doctor, "1");
        Map<String, Object> rs = new HashedMap();
        rs.put("trackPatientCount", trackPatients.size());
        String sql = "SELECT " +
                " COUNT(1) AS total " +
                " FROM " +
                " wlyy_track_patient t " +
                " WHERE " +
                " t.del='1' " +
                " AND t.doctor_code = '" + doctor + "' " +
//                " AND t.team_code = " + teamCode +
                " AND t.create_time >= '" + startDate + " 00:00:00' " +
                " AND t.create_time <= '" + endDate + " 23:59:59'";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        if (list != null && list.size() > 0) {
            Long total = (Long) list.get(0).get("total");
            rs.put("trackPatientAddCount", total);
        } else {
            rs.put("trackPatientAddCount", 0);
        }
        return rs;
    }
    public Map<String, Object> getTrackPatientServerCount(Long teamCode, String doctor, String startDate, String endDate) {
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
        Map<String, Object> rs = new HashedMap();
        //咨询
        rs.put("consultCount", getConsultByteam(teamCode, doctor, startDate, endDate));
        //随访
        rs.put("followupCount", getFollowByTeam(teamCode, doctor, startDate, endDate));
        //获取健康指导
        rs.put("guidanceCount", getGuidanceByTeam(teamCode, doctor, startDate, endDate));
        //获取待预约
        rs.put("reservationCount", getReservationByteam(teamCode, doctor, startDate, endDate));
        //续方审核
        rs.put("reviewedCount", getPresCount(teamCode, doctor, startDate, endDate));
        return rs;
    }
    /**
     * 获取咨询数
     *
     * @param id
     * @param startDate
     * @param endDate
     * @return
     */
    public Long getConsultByteam(Long id, String doctor, String startDate, String endDate) {
        String imDataBaseName = im_dataBase_name;
        //咨询量
        String consult_sql = "SELECT " +
                "  COUNT(1) consultCount " +
                "  FROM " +
                " wlyy_admin_team_member m JOIN(" +
                " SELECT d.id,t.create_time FROM " +
                "  " + imDataBaseName + ".Topics t, " +
                "  " + imDataBaseName + ".Participants p, " +
                "  " + imDataBaseName + ".Doctors d, " +
                "  Wlyy_Consult_Team c, " +
                "  " + imDataBaseName + ".Patients s " +
                "  WHERE " +
                "  d.id = p.participant_id " +
                " AND c.type <> 8  " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND p.session_id = t.session_id " +
                " AND c.admin_team_code =" + id +
                " AND t.create_time >= '" + startDate + "' " +
                " AND t.create_time <= '" + endDate + "'" +
                " AND c.patient IN(" +
                "  SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' AND t.team_code = " + id +
                " )" +
                " )c ON c.id = m.doctor_code " +
                " WHERE " +
                " m.team_id = " + id +
                " AND m.doctor_code ='" + doctor + "'";
        //获取咨詢數
        Map<String, Object> consultCout = jdbcTemplate.queryForMap(consult_sql);
        if (consultCout.get("consultCount") == null) {
            consultCout.put("consultCount", 0);
        }
        return (Long) consultCout.get("consultCount");
    }
    public Long getReservationByteam(Long id, String doctor, String startDate, String endDate) {
        //获取待预约
        String reservation_sql = "SELECT COUNT(1) AS reservationCount FROM wlyy_patient_reservation  w WHERE w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "' " +
                " AND w.doctor ='" + doctor + "' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' AND t.team_code = " + id + ") ";
        //获取待预约
        Map<String, Object> reservationCout = jdbcTemplate.queryForMap(reservation_sql);
        if (reservationCout.get("reservationCount") == null) {
            reservationCout.put("reservationCount", 0);
        }
        return (Long) reservationCout.get("reservationCount");
    }
    public Long getEduArticleByTeam(Long id, String doctor, String startDate, String endDate) {
        //获取健康教育
        String article_sql = "SELECT COUNT(1) AS articleCount FROM wlyy_health_edu_article_patient w WHERE  w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "'" +
                " AND w.doctor ='" + doctor + "' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' AND t.team_code = " + id + ") ";
        //获取健康教育
        Map<String, Object> articleCout = jdbcTemplate.queryForMap(article_sql);
        if (articleCout.get("articleCount") == null) {
            articleCout.put("articleCount", 0);
        }
        return (Long) articleCout.get("articleCount");
    }
    public Long getGuidanceByTeam(Long id, String doctor, String startDate, String endDate) {
        //获取健康指导
        String guidance_sql = "SELECT COUNT(1) AS guidanceCount  FROM wlyy_patient_health_guidance w WHERE w.admin_team_code =" + id + " AND w.czrq <='" + endDate + "' AND w.czrq >='" + startDate + "' " +
                " AND w.doctor ='" + doctor + "' AND w.patient IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' AND t.team_code = " + id + ") ";
        //获取健康指导
        Map<String, Object> guidanceCout = jdbcTemplate.queryForMap(guidance_sql);
        if (guidanceCout.get("guidanceCount") == null) {
            guidanceCout.put("guidanceCount", 0);
        }
        return (Long) guidanceCout.get("guidanceCount");
    }
    public Long getFollowByTeam(Long id, String doctor, String startDate, String endDate) {
        //随访数目
        String followup_sql = "SELECT COUNT(1) AS followupCount from wlyy_followup w WHERE w.admin_team_code=" + id + " AND  w.create_time >='" + startDate + "' AND w.create_time<='" + endDate + "' " +
                " AND w.doctor_code ='" + doctor + "' AND w.patient_code IN (SELECT t.patient_code FROM wlyy_track_patient t WHERE t.del='1' AND t.doctor_code ='" + doctor + "' AND t.team_code = " + id + ") ";
        //随访数目
        Map<String, Object> followupCout = jdbcTemplate.queryForMap(followup_sql);
        if (followupCout.get("followupCount") == null) {
            followupCout.put("followupCount", 0);
        }
        return (Long) followupCout.get("followupCount");
    }
    public Long getPresCount(Long id, String doctor, String startDate, String endDate) {
        String sql = "SELECT " +
                " count(1) AS reviewedCount " +
                " FROM " +
                " wlyy_prescription p " +
                " JOIN wlyy_prescription_reviewed r ON r.prescription_code = p.`code` " +
                " WHERE " +
                " r.doctor = '" + doctor + "' " +
                " AND p.admin_team_id = " + id +
                " AND r.reviewed_time >= '" + startDate + "' " +
                " AND r.reviewed_time <= '" + endDate + "' " +
                " AND p.patient IN ( " +
                " SELECT t.patient_code " +
                " FROM wlyy_track_patient t " +
                " WHERE t.del='1' AND t.doctor_code ='" + doctor + "' " +
                " AND t.team_code = " + id + ")";
        //审核数目
        Map<String, Object> reviewedCount = jdbcTemplate.queryForMap(sql);
        if (reviewedCount.get("reviewedCount") == null) {
            reviewedCount.put("reviewedCount", 0);
        }
        return (Long) reviewedCount.get("reviewedCount");
    }
    public Map<String, Object> getTrackPatientAimByteam(String doctor, String startDate, String endDate) {
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
        String presSql = "SELECT " +
                " COUNT(1) AS dbCount " +
                " FROM " +
                " ( " +
                "  SELECT " +
                "   i.`user`, " +
                "   COUNT(1) AS total " +
                "  FROM " +
                "   device.wlyy_patient_health_index i " +
                "    WHERE  " +
                "   i.`user` in  " +
                "    ( " +
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='" + doctor + "'   ) " +
                "  AND i.del ='1' " +
                "  AND i.type = 2  " +
                "  AND i.record_date >= '" + startDate + "' " +
                "  AND i.record_date <= '" + endDate + "' " +
                "  GROUP BY " +
                "   i.`user` " +
                " ) tt " +
                " LEFT JOIN  " +
                " ( " +
                " SELECT " +
                "  i.`user`, " +
                "  COUNT(1) AS dbtotal " +
                " FROM " +
                "  device.wlyy_patient_health_index i " +
                " JOIN wlyy_patient_aim_blood_pressure p ON p.patientcode = i.`user` " +
                " WHERE " +
                "  i.`user` in  " +
                "    ( " +
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='" + doctor + "'   ) " +
                "  AND i.value1 <= cast(p.sbp as SIGNED INTEGER) " +
                "  AND i.value1 >= cast(p.sbp_min as SIGNED INTEGER) " +
                "  AND i.del ='1'  " +
                "  AND i.type = 2   " +
                "  AND i.record_date >= '" + startDate + "' " +
                "  AND i.record_date <= '" + endDate + "' " +
                " GROUP BY " +
                "  i.`user` " +
                " ) dbt ON tt.`user`=dbt.`user` " +
                " WHERE dbt.dbtotal/tt.total > 0.7";
        Map<String, Object> rs = new HashedMap();
        List<Map<String, Object>> presTotal = jdbcTemplate.queryForList(presSql);
        if (presTotal != null && presTotal.size() > 0) {
            rs.put("dbPresCount", presTotal.get(0).get("dbCount"));
        } else {
            rs.put("dbPresCount", 0);
        }
        //血糖达标数量
        List<Map<String, Object>> cqXT = jdbcTemplate.queryForList(getXTAimSQL(doctor, startDate, endDate));
        Long dbSuggerCount;
        if (cqXT != null && cqXT.size() > 0) {
            dbSuggerCount = (Long) cqXT.get(0).get("total");
        } else {
            dbSuggerCount = 0L;
        }
        rs.put("dbSuggerCount", dbSuggerCount);
        return rs;
    }
    /**
     * @param doctor
     * @param teamCode
     * @param startDate
     * @param endDate
     * @param state     0 餐前,1餐_后
     * @return
     */
    public String getXTSql(String doctor, Long teamCode, String startDate, String endDate, String state) {
        String value1 = "cast(p.fbg as SIGNED INTEGER)";
        String value1min = "cast(p.fbg_min as SIGNED INTEGER)";
        String value2 = "1,3,5,7";
        if ("1".equals(state)) {
            value2 = "2,4,6";
            value1 = "cast(p.hpg AS SIGNED INTEGER)";
            value1min = "cast(p.hpg_min AS SIGNED INTEGER)";
        }
        //餐前血糖达标数
        String xtSql = "SELECT " +
                " tt.`user` " +
                " FROM " +
                " ( " +
                "  SELECT " +
                "   i.`user`, " +
                "   COUNT(1) AS total " +
                "  FROM " +
                "   device.wlyy_patient_health_index i " +
                "    WHERE  " +
                "   i.`user` in  " +
                "    ( " +
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='" + doctor + "' AND p.team_code =" + teamCode +
                "    ) " +
                "  AND i.del ='1' " +
                "  AND i.value2 in(" + value2 + ") " +
                "  AND i.type = 1  " +
                "  AND i.record_date >= '" + startDate + "' " +
                "  AND i.record_date <= '" + endDate + "' " +
                "  GROUP BY " +
                "   i.`user` " +
                " ) tt " +
                " LEFT JOIN  " +
                " ( " +
                " SELECT " +
                "  i.`user`, " +
                "  COUNT(1) AS dbtotal " +
                " FROM " +
                "  device.wlyy_patient_health_index i " +
                " JOIN wlyy_patient_aim_blood_sugger p ON p.patientcode = i.`user` " +
                " WHERE " +
                "  i.`user` in  " +
                "    ( " +
                "     SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='" + doctor + "' AND p.team_code =" + teamCode +
                "    ) " +
                "  AND " +
                "  i.value1 <= " + value1 +
                "  AND  " +
                "  i.value1 >= " + value1min +
                "  AND i.value2 in(" + value2 + ") " +
                "  AND i.del ='1'  " +
                "  AND i.type = 1   " +
                "  AND i.record_date >= '" + startDate + "' " +
                "  AND i.record_date <= '" + endDate + "' " +
                " GROUP BY " +
                "  i.`user` " +
                " ) dbt ON tt.`user`=dbt.`user` " +
                " WHERE dbt.dbtotal/tt.total > 0.7";
        return xtSql;
    }
    public String getXTAimSQL(String doctor,  String startDate, String endDate) {
        String sql = "SELECT " +
                " COUNT(1) total " +
                " FROM " +
                " ( " +
                "  SELECT " +
                "   i.`user`, " +
                "   COUNT(1) AS total " +
                "  FROM " +
                "   device.wlyy_patient_health_index i " +
                "  WHERE " +
                "   i.`user` IN ( " +
                "    SELECT " +
                "     p.patient_code AS `user` " +
                "    FROM " +
                "     wlyy_track_patient p " +
                "    WHERE " +
                "     p.del = '1' " +
                "    AND p.doctor_code = '" + doctor + "' " +
//                "    AND p.team_code = " + teamCode +
                "   ) " +
                "  AND i.del = '1' " +
                "  AND i.type = 1 " +
                "  AND i.record_date >= '" + startDate + "' " +
                "  AND i.record_date <= '" + endDate + "' " +
                "  GROUP BY " +
                "   i.`user` " +
                " ) tt " +
                " LEFT JOIN ( " +
                " SELECT " +
                "  i.`user`, " +
                "  COUNT(1) AS dbtotal " +
                " FROM " +
                "  device.wlyy_patient_health_index i " +
                " JOIN wlyy_patient_aim_blood_sugger p ON p.patientcode = i.`user` " +
                " WHERE " +
                "  i.`user` IN ( " +
                "   SELECT " +
                "    p.patient_code AS `user` " +
                "   FROM " +
                "    wlyy_track_patient p " +
                "   WHERE " +
                "    p.del = '1' " +
                "   AND p.doctor_code = '" + doctor + "' " +
//                "   AND p.team_code = " + teamCode +
                "  ) " +
                " AND i.value1 <= cast(p.fbg AS SIGNED INTEGER) " +
                " AND i.value1 >= cast(p.fbg_min AS SIGNED INTEGER) " +
                " AND i.value2 IN (1,3,5,7)  " +
                " AND i.del = '1' " +
                " AND i.type = 1 " +
                " AND i.record_date >= '" + startDate + "' " +
                " AND i.record_date <= '" + endDate + "' " +
                " GROUP BY " +
                "  i.`user` " +
                " ) dbt ON tt.`user` = dbt.`user`  " +
                " LEFT JOIN ( " +
                " SELECT " +
                "  i.`user`, " +
                "  COUNT(1) AS dbtotal " +
                " FROM " +
                "  device.wlyy_patient_health_index i " +
                " JOIN wlyy_patient_aim_blood_sugger p ON p.patientcode = i.`user` " +
                " WHERE " +
                "  i.`user` IN ( " +
                "   SELECT " +
                "    p.patient_code AS `user` " +
                "   FROM " +
                "    wlyy_track_patient p " +
                "   WHERE " +
                "    p.del = '1' " +
                "   AND p.doctor_code = '" + doctor + "' " +
//                "   AND p.team_code =  " + teamCode +
                "  ) " +
                " AND i.value1 <= cast(p.hpg AS SIGNED INTEGER) " +
                " AND i.value1 >= cast(p.hpg_min AS SIGNED INTEGER) " +
                " AND i.value2 IN (2,4,6)  " +
                " AND i.del = '1' " +
                " AND i.type = 1 " +
                " AND i.record_date >= '" + startDate + "' " +
                " AND i.record_date <= '" + endDate + "' " +
                " GROUP BY " +
                "  i.`user` " +
                " ) cht ON tt.`user` = cht.`user` " +
                " WHERE " +
                " (IFNULL(dbt.dbtotal,0)+IFNULL(cht.dbtotal,0))/ tt.total > 0.7";
        return sql;
    }
    public Map<String, Object> getDeviceStateByTeam(String doctor) {
        String sql = "SELECT " +
                " COUNT(1) AS total " +
                " FROM " +
                " wlyy_patient_device d JOIN  " +
                " wlyy_track_patient t ON t.patient_code = d.`user` " +
                " WHERE  " +
                " t.del='1' " +
                " AND d.category_code = ? " +
                " AND t.doctor_code = '" + doctor + "' ";
//                " AND t.team_code = " + teamCode;
        Map<String, Object> rs = new HashedMap();
        //血糖仪
        List<Map<String, Object>> xt = jdbcTemplate.queryForList(sql, new Object[]{"1"});
        if (xt != null && xt.size() > 0) {
            rs.put("suggerDevCount", xt.get(0).get("total"));
        } else {
            rs.put("suggerDevCount", 0);
        }
        //血压计
        List<Map<String, Object>> xh = jdbcTemplate.queryForList(sql, new Object[]{"2"});
        if (xh != null && xh.size() > 0) {
            rs.put("presDevCount", xh.get(0).get("total"));
        } else {
            rs.put("presDevCount", 0);
        }
        return rs;
    }
    public String setSinglePatientAim(String patient, String suggerJson, String presJson, String sportJson) {
        PatientAimBloodSugger sugger = patientAimBloodSuggerDao.findByPatientcode(patient);
        if (sugger != null) {
            patientAimBloodSuggerDao.delete(sugger);
        }
        PatientAimBloodPressure pres = patientAimBloodPressureDao.findByPatientcode(patient);
        if (pres != null) {
            patientAimBloodPressureDao.delete(pres);
        }
        PatientAimSports sport = patientAimSportsDao.getPatientAimSportsByPatientCode(patient);
        if (sport != null) {
            patientAimSportsDao.delete(sport);
        }
        net.sf.json.JSONObject sj = net.sf.json.JSONObject.fromObject(suggerJson);
        net.sf.json.JSONObject pj = net.sf.json.JSONObject.fromObject(presJson);
        net.sf.json.JSONObject spj = net.sf.json.JSONObject.fromObject(sportJson);
        PatientAimBloodSugger patientAimBloodSugger = (PatientAimBloodSugger) net.sf.json.JSONObject.toBean(sj, PatientAimBloodSugger.class);
        PatientAimBloodPressure patientAimBloodPressure = (PatientAimBloodPressure) net.sf.json.JSONObject.toBean(pj, PatientAimBloodPressure.class);
        PatientAimSports patientAimSports = (PatientAimSports) net.sf.json.JSONObject.toBean(spj, PatientAimSports.class);
        patientAimBloodSugger.setPatientcode(patient);
        patientAimBloodSugger.setCode(getCode());
        patientAimBloodSugger.setCreateTime(new Date());
        patientAimBloodSuggerDao.save(patientAimBloodSugger);
        patientAimBloodPressure.setPatientcode(patient);
        patientAimBloodPressure.setCode(getCode());
        patientAimBloodPressure.setCreateTime(new Date());
        patientAimBloodPressureDao.save(patientAimBloodPressure);
        patientAimSports.setPatientcode(patient);
        patientAimSports.setCode(getCode());
        patientAimSports.setCreateTime(new Date());
        patientAimSportsDao.save(patientAimSports);
        return "1";
    }
    public String setPatientAim(String patients, String suggerJson, String presJson, String sportJson) {
        if (StringUtils.isNotBlank(patients)) {
            String[] patient = patients.split(",");
            for (String p : patient) {
                PatientAimBloodSugger sugger = patientAimBloodSuggerDao.findByPatientcode(p);
                if (sugger != null) {
                    patientAimBloodSuggerDao.delete(sugger);
                }
                PatientAimBloodPressure pres = patientAimBloodPressureDao.findByPatientcode(p);
                if (pres != null) {
                    patientAimBloodPressureDao.delete(pres);
                }
                PatientAimSports sport = patientAimSportsDao.getPatientAimSportsByPatientCode(p);
                if (sport != null) {
                    patientAimSportsDao.delete(sport);
                }
                net.sf.json.JSONObject sj = net.sf.json.JSONObject.fromObject(suggerJson);
                net.sf.json.JSONObject pj = net.sf.json.JSONObject.fromObject(presJson);
                net.sf.json.JSONObject spj = net.sf.json.JSONObject.fromObject(sportJson);
                PatientAimBloodSugger patientAimBloodSugger = (PatientAimBloodSugger) net.sf.json.JSONObject.toBean(sj, PatientAimBloodSugger.class);
                PatientAimBloodPressure patientAimBloodPressure = (PatientAimBloodPressure) net.sf.json.JSONObject.toBean(pj, PatientAimBloodPressure.class);
                PatientAimSports patientAimSports = (PatientAimSports) net.sf.json.JSONObject.toBean(spj, PatientAimSports.class);
                patientAimBloodSugger.setPatientcode(p);
                patientAimBloodSugger.setCode(getCode());
                patientAimBloodSugger.setCreateTime(new Date());
                patientAimBloodSuggerDao.save(patientAimBloodSugger);
                patientAimBloodPressure.setPatientcode(p);
                patientAimBloodPressure.setCode(getCode());
                patientAimBloodPressure.setCreateTime(new Date());
                patientAimBloodPressureDao.save(patientAimBloodPressure);
                patientAimSports.setPatientcode(p);
                patientAimSports.setCode(getCode());
                patientAimSports.setCreateTime(new Date());
                patientAimSportsDao.save(patientAimSports);
            }
        }
        return "0";
    }
    public Map<String, Object> getPatientScheme(String patient, String type) {
        Map<String, Object> rs = new HashedMap();
        String sql = null;
        if ("1".equals(type)) {
            sql = "SELECT " +
                    " s.* " +
                    " FROM " +
                    " wlyy_patient_scheme_list l " +
                    " JOIN wlyy_doctor_scheme_blood_sugger s ON s. CODE = l.schemecode " +
                    " WHERE " +
                    " l.type = 1  " +
                    " AND l.patientcode='" + patient + "'" +
                    " ORDER BY s.dayofweek ASC";
        } else {
            sql = "SELECT " +
                    " s.* " +
                    " FROM " +
                    " wlyy_patient_scheme_list l " +
                    " JOIN wlyy_doctor_scheme_blood_pressure s ON s. CODE = l.schemecode " +
                    " WHERE " +
                    " l.type = 2 " +
                    " AND l.patientcode='" + patient + "'" +
                    " ORDER BY s.dayofweek ASC";
        }
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        if (list != null && list.size() > 0) {
            rs.put("code", list.get(0).get("code"));
            rs.put("name", list.get(0).get("name"));
            rs.put("content", list.get(0).get("content"));
            rs.put("list", list);
        }
        return rs;
    }
    public List<Map<String, Object>> getTrackPatientIndexCountList(String doctor, Integer teamCode, String type, String startDate, String endDate, String keyword, Integer page, Integer size) {
        startDate = startDate + " 00:00:00";
        endDate = endDate + " 23:59:59";
        // /血糖查询
        if ("1".equals(type)) {
            List<Map<String, Object>> list = jdbcTemplate.queryForList(getXTTrackPatientIndexCountListSql(doctor, teamCode, startDate, endDate, keyword, page, size));
            return list;
        } else {
            List<Map<String, Object>> list = jdbcTemplate.queryForList(getXYTrackPatientIndexCountListSql(doctor, teamCode, startDate, endDate, keyword, page, size));
            return list;
        }
    }
    public String getXTTrackPatientIndexCountListSql(String doctor, Integer teamCode, String startDate, String endDate, String keyword, Integer page, Integer size) {
        String sql = "SELECT  " +
                " tt1.patient_code, " +
                " tt1.highCount, " +
                " tt2.lowCount, " +
                " tt3.stdCount, " +
                " p.`name`, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                " p.photo, " +
                " p.idcard," +
                " p.sex " +
                " FROM " +
                " " +
                "( " +
                " " +
                " SELECT " +
                " t1.patient_code, " +
                " t2.total + t1.total AS highCount " +
                " FROM " +
                " ( " +
                "  SELECT " +
                "   t.patient_code, " +
                "   IFNULL(pid.total, 0) AS total " +
                "  FROM " +
                "   ( " +
                "    SELECT " +
                "     tp.patient_code " +
                "    FROM " +
                "     wlyy_track_patient tp " +
                "    WHERE " +
                "     tp.del = '1' " +
                "    AND tp.doctor_code = '" + doctor + "' " +
                "    AND tp.team_code = " + teamCode +
                "   ) t " +
                "  LEFT JOIN ( " +
                "   SELECT " +
                "    i. USER, " +
                "    COUNT(1) AS total " +
                "   FROM " +
                "    device.wlyy_patient_health_index i " +
                "   WHERE " +
                "    i.del = '1' " +
                "   AND i.type = 1 " +
                "   AND i.value2 IN (2, 4, 6) " +
                "   AND i.value1 > 11.1 " +
                "   AND i.record_date >='" + startDate + "'" +
                "   AND i.record_date <='" + endDate + "'" +
                "   GROUP BY " +
                "    i. USER " +
                "  ) pid ON pid. USER = t.patient_code " +
                " ) t1  " +
                " " +
                " JOIN  " +
                " " +
                " ( " +
                " SELECT " +
                "  t.patient_code, " +
                "  IFNULL(pid.total, 0) AS total " +
                " FROM " +
                "  ( " +
                "   SELECT " +
                "    tp.patient_code " +
                "   FROM " +
                "    wlyy_track_patient tp " +
                "   WHERE " +
                "    tp.del = '1' " +
                "   AND tp.doctor_code = '" + doctor + "' " +
                "   AND tp.team_code =" + teamCode +
                "  ) t " +
                " LEFT JOIN ( " +
                "  SELECT " +
                "   i. USER, " +
                "   COUNT(1) AS total " +
                "  FROM " +
                "   device.wlyy_patient_health_index i " +
                "  WHERE " +
                "   i.del = '1' " +
                "  AND i.type = 1 " +
                "  AND i.value2 IN (1, 3, 5, 7) " +
                "  AND i.value1 > 7 " +
                "  AND i.record_date >='" + startDate + "'" +
                "  AND i.record_date <='" + endDate + "'" +
                "  GROUP BY " +
                "   i. USER " +
                " ) pid ON pid. USER = t.patient_code " +
                ") t2 ON t1.patient_code = t2.patient_code " +
                " " +
                ") tt1  " +
                " " +
                " JOIN  " +
                " " +
                "( " +
                "  SELECT " +
                " t1.patient_code, " +
                " t1.total + t2.total AS lowCount " +
                " FROM " +
                " ( " +
                "  SELECT " +
                "   t.patient_code, " +
                "   IFNULL(pid.total, 0) AS total " +
                "  FROM " +
                "   ( " +
                "    SELECT " +
                "     tp.patient_code " +
                "    FROM " +
                "     wlyy_track_patient tp " +
                "    WHERE " +
                "     tp.del = '1' " +
                "    AND tp.doctor_code = '" + doctor + "' " +
                "    AND tp.team_code =  " + teamCode +
                "   ) t " +
                "  LEFT JOIN ( " +
                "   SELECT " +
                "    i. USER, " +
                "    COUNT(1) AS total " +
                "   FROM " +
                "    device.wlyy_patient_health_index i " +
                "   WHERE " +
                "    i.del = '1' " +
                "   AND i.type = 1 " +
                "   AND i.value2 IN (2, 4, 6) " +
                "   AND i.value1 < 4 " +
                "  AND i.record_date >='" + startDate + "'" +
                "  AND i.record_date <='" + endDate + "'" +
                "   GROUP BY " +
                "    i. USER " +
                "  ) pid ON pid. USER = t.patient_code " +
                " ) t1  " +
                " " +
                " JOIN  " +
                " " +
                "( " +
                " SELECT " +
                "  t.patient_code, " +
                "  IFNULL(pid.total, 0) AS total " +
                " FROM " +
                "  ( " +
                "   SELECT " +
                "    tp.patient_code " +
                "   FROM " +
                "    wlyy_track_patient tp " +
                "   WHERE " +
                "    tp.del = '1' " +
                "   AND tp.doctor_code = '" + doctor + "' " +
                "   AND tp.team_code =  " + teamCode +
                "  ) t " +
                " LEFT JOIN ( " +
                "  SELECT " +
                "   i. USER, " +
                "   COUNT(1) AS total " +
                "  FROM " +
                "   device.wlyy_patient_health_index i " +
                "  WHERE " +
                "   i.del = '1' " +
                "  AND i.type = 1 " +
                "  AND i.value2 IN (1, 3, 5, 7) " +
                "  AND i.value1 < 4 " +
                "  AND i.record_date >='" + startDate + "'" +
                "  AND i.record_date <='" + endDate + "'" +
                "  GROUP BY " +
                "   i. USER " +
                " ) pid ON pid. USER = t.patient_code " +
                ") t2 ON t1.patient_code = t2.patient_code " +
                " " +
                ") tt2 ON tt1.patient_code = tt2.patient_code  " +
                " " +
                "JOIN  " +
                " " +
                "( " +
                "   " +
                " SELECT " +
                " t1.patient_code, " +
                " t1.total + t2.total AS stdCount " +
                " FROM " +
                " ( " +
                "  SELECT " +
                "   t.patient_code, " +
                "   IFNULL(pid.total, 0) AS total " +
                "  FROM " +
                "   ( " +
                "    SELECT " +
                "     tp.patient_code " +
                "    FROM " +
                "     wlyy_track_patient tp " +
                "    WHERE " +
                "     tp.del = '1' " +
                "    AND tp.doctor_code = '" + doctor + "' " +
                "    AND tp.team_code = " + teamCode +
                "   ) t " +
                "  LEFT JOIN ( " +
                "   SELECT " +
                "    i. USER, " +
                "    COUNT(1) AS total " +
                "   FROM " +
                "    device.wlyy_patient_health_index i " +
                "   WHERE " +
                "    i.del = '1' " +
                "   AND i.type = 1 " +
                "   AND i.value2 IN (2, 4, 6) " +
                "   AND i.value1 >= 4 " +
                "   AND i.value1 <= 11.1 " +
                "  AND i.record_date >='" + startDate + "'" +
                "  AND i.record_date <='" + endDate + "'" +
                "   GROUP BY " +
                "    i. USER " +
                "  ) pid ON pid. USER = t.patient_code " +
                " ) t1  " +
                " " +
                " JOIN  " +
                " " +
                " ( " +
                " SELECT " +
                "  t.patient_code, " +
                "  IFNULL(pid.total, 0) AS total " +
                " FROM " +
                "  ( " +
                "   SELECT " +
                "    tp.patient_code " +
                "   FROM " +
                "    wlyy_track_patient tp " +
                "   WHERE " +
                "    tp.del = '1' " +
                "   AND tp.doctor_code = '" + doctor + "' " +
                "   AND tp.team_code = " + teamCode +
                "  ) t " +
                " LEFT JOIN ( " +
                "  SELECT " +
                "   i. USER, " +
                "   COUNT(1) AS total " +
                "  FROM " +
                "   device.wlyy_patient_health_index i " +
                "  WHERE " +
                "   i.del = '1' " +
                "  AND i.type = 1 " +
                "  AND i.value2 IN (1, 3, 5, 7) " +
                "  AND i.value1 >= 4 " +
                "  AND i.value1 <= 7 " +
                "  AND i.record_date >='" + startDate + "'" +
                "  AND i.record_date <='" + endDate + "'" +
                "  GROUP BY " +
                "   i. USER " +
                " ) pid ON pid. USER = t.patient_code " +
                " ) t2 ON t1.patient_code = t2.patient_code " +
                " " +
                " )tt3 ON tt1.patient_code = tt3.patient_code " +
                " " +
                " JOIN wlyy_patient p On tt1.patient_code =p.code";
        if (StringUtils.isNotBlank(keyword)) {
            BasePatientDO p = patientDao.findByIdcard(keyword);
            if (p != null) {
                sql = sql + " WHERE p.idcard ='" + keyword + "'";
            } else {
                sql = sql + " WHERE p.name like '%" + keyword + "%' ";
            }
        }
        sql += " ORDER BY highCount DESC LIMIT " + (page - 1) * size + "," + size;
        return sql;
    }
    public String getXYTrackPatientIndexCountListSql(String doctor, Integer teamCode, String startDate, String endDate, String keyword, Integer page, Integer size) {
        String sql = "SELECT  " +
                " t1.patient_code, " +
                " t1.total AS lowCount, " +
                " t2.total AS stdCount, " +
                " t3.total AS highCount, " +
                " p.`name`, " +
                " IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age, " +
                " p.photo, " +
                " p.sex" +
                " FROM " +
                " " +
                " ( " +
                "  SELECT " +
                "   t.patient_code, " +
                "   IFNULL(pid.total, 0) AS total " +
                "  FROM " +
                "   ( " +
                "    SELECT " +
                "     tp.patient_code " +
                "    FROM " +
                "     wlyy_track_patient tp " +
                "    WHERE " +
                "     tp.del = '1' " +
                "   AND tp.doctor_code = '" + doctor + "' " +
                "   AND tp.team_code = " + teamCode +
                "   ) t " +
                "  LEFT JOIN ( " +
                "   SELECT " +
                "    i. USER, " +
                "    COUNT(1) AS total " +
                "   FROM " +
                "    device.wlyy_patient_health_index i " +
                "   WHERE " +
                "    i.del = '1' " +
                "   AND i.type = 2 " +
                "   AND i.value1 < 90 " +
                "  AND i.record_date >='" + startDate + "'" +
                "  AND i.record_date <='" + endDate + "'" +
                "   GROUP BY " +
                "    i. USER " +
                "  ) pid ON pid. USER = t.patient_code " +
                " ) t1  " +
                " JOIN " +
                " ( " +
                "  SELECT " +
                "   t.patient_code, " +
                "   IFNULL(pid.total, 0) AS total " +
                "  FROM " +
                "   ( " +
                "    SELECT " +
                "     tp.patient_code " +
                "    FROM " +
                "     wlyy_track_patient tp " +
                "    WHERE " +
                "     tp.del = '1' " +
                "   AND tp.doctor_code = '" + doctor + "' " +
                "   AND tp.team_code = " + teamCode +
                "   ) t " +
                "  LEFT JOIN ( " +
                "   SELECT " +
                "    i. USER, " +
                "    COUNT(1) AS total " +
                "   FROM " +
                "    device.wlyy_patient_health_index i " +
                "   WHERE " +
                "    i.del = '1' " +
                "   AND i.type = 2 " +
                "   AND i.value1 >= 90 " +
                "   AND i.value1 <=139 " +
                "  AND i.record_date >='" + startDate + "'" +
                "  AND i.record_date <='" + endDate + "'" +
                "   GROUP BY " +
                "    i. USER " +
                "  ) pid ON pid. USER = t.patient_code " +
                "  " +
                " ) t2 ON t1.patient_code = t2.patient_code " +
                " JOIN  " +
                " ( " +
                "  SELECT " +
                "   t.patient_code, " +
                "   IFNULL(pid.total, 0) AS total " +
                "  FROM " +
                "   ( " +
                "    SELECT " +
                "     tp.patient_code " +
                "    FROM " +
                "     wlyy_track_patient tp " +
                "    WHERE " +
                "     tp.del = '1' " +
                "   AND tp.doctor_code = '" + doctor + "' " +
                "   AND tp.team_code = " + teamCode +
                "   ) t " +
                "  LEFT JOIN ( " +
                "   SELECT " +
                "    i. USER, " +
                "    COUNT(1) AS total " +
                "   FROM " +
                "    device.wlyy_patient_health_index i " +
                "   WHERE " +
                "    i.del = '1' " +
                "   AND i.type = 2 " +
                "   AND i.value1 >139 " +
                "  AND i.record_date >='" + startDate + "'" +
                "  AND i.record_date <='" + endDate + "'" +
                "   GROUP BY " +
                "    i. USER " +
                "  ) pid ON pid. USER = t.patient_code " +
                " ) t3 ON t1.patient_code = t3.patient_code " +
                " JOIN wlyy_patient p ON t1.patient_code = p.`code`";
        if (StringUtils.isNotBlank(keyword)) {
            BasePatientDO p = patientDao.findByIdcard(keyword);
            if (p != null) {
                sql = sql + " WHERE p.idcard ='" + keyword + "'";
            } else {
                sql = sql + " WHERE p.name like '%" + keyword + "%' ";
            }
        }
        sql += " ORDER BY highCount DESC LIMIT " + (page - 1) * size + "," + size;
        return sql;
    }
    public Map<String, Object> getDefaultScheme(String type) {
        Map<String, Object> rs = new HashedMap();
        //1. 血糖2.血压
        if ("1".equals(type)) {
            String sql = " SELECT p.* FROM wlyy_doctor_scheme_blood_sugger p where p.code='default' and p.del=0 order by p.doctorcode,p.code desc,p.dayofweek asc";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
            rs.put("code", "default");
            rs.put("name", list.get(0).get("name"));
            rs.put("content", list.get(0).get("content"));
            rs.put("list", list);
        } else {
            String sql = " SELECT p.* FROM wlyy_doctor_scheme_blood_pressure p where p.code='default' and p.del=0 order by p.doctorcode,p.code desc,p.dayofweek asc";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
            rs.put("code", "default");
            rs.put("name", list.get(0).get("name"));
            rs.put("content", list.get(0).get("content"));
            rs.put("list", list);
        }
        return rs;
    }
    @Transactional
    public String setPatientDefaultScheme(String patient, String type) {
        PatientSchemeList pl = new PatientSchemeList();
        if ("1".equals(type)) {
            List<PatientSchemeList> list = patientSchemeListDao.findByPatientcodeAndSchemecodeAndType(patient, "default", 1);
            if (list != null && list.size() > 0) {
                return "-1";
            }
            pl.setType(1);
        } else {
            List<PatientSchemeList> list = patientSchemeListDao.findByPatientcodeAndSchemecodeAndType(patient, "default", 2);
            if (list != null && list.size() > 0) {
                return "-1";
            }
            pl.setType(2);
        }
        pl.setPatientcode(patient);
        pl.setCode(getCode());
        pl.setSchemecode("default");
        pl.setCreateTime(new Date());
        patientSchemeListDao.save(pl);
        return "0";
    }
    /**
     * 查看指定医生是否开启分派订单功能
     *
     * @param doctor
     * @return
     */
    public String findDispatchStatusByDoctor(String doctor) {
        DoctorSwitch doctorSwitch = doctorSwitchDao.findByDoctor(doctor);
        if (null == doctorSwitch) {
            return "0";
        }
        return StringUtils.isNotEmpty(doctorSwitch.getDispatchOrderSwitch()) ? doctorSwitch.getDispatchOrderSwitch() : "0";
    }
    /**
     * 修改指定医生的分派订单开关,不存在该医生的开关,则创建
     *
     * @param doctor
     * @param dispatchOrderStatus
     */
    public void updateDispatchStatusByDoctor(String doctor, String dispatchOrderStatus) {
        DoctorSwitch doctorSwitch = doctorSwitchDao.findByDoctor(doctor);
        if (null != doctorSwitch) {
            doctorSwitch.setDispatchOrderSwitch(dispatchOrderStatus);
            doctorSwitch.setUpdateTime(new Date());
        } else {
            doctorSwitch = new DoctorSwitch();
            doctorSwitch.setDoctor(doctor);
            doctorSwitch.setDispatchOrderSwitch(dispatchOrderStatus);
            doctorSwitch.setCreateTime(new Date());
        }
        doctorSwitchDao.save(doctorSwitch);
    }
    public JSONObject patientsByDoctorAndLabelCode(String labelCode, String doctorCode) {//1,2改变。
        StringBuilder sqlLabelStr = new StringBuilder();
        sqlLabelStr.append(" sp.label in ('").append(labelCode.replace(",", "','")).append("') ");
        List<PatientVO> patients = new ArrayList<>();
        String patientsql = "select * from (select p.code,p.standard_status,p.disease_condition,group_concat(DISTINCT sp.label order by sp.label asc ) as disease from wlyy_patient p " +
                "  LEFT JOIN wlyy_sign_family s on s.patient = p.code " +
                "  RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code and sp.label_type = 3 and " + sqlLabelStr.toString() + " and sp.status =1" +
                " WHERE s.status > 0 and (s.doctor = '" + doctorCode + "' or s.doctor_health ='" + doctorCode + "') GROUP BY p.code " +
                "order by sp.label asc)tmp where tmp.disease='" + labelCode + "'";
        patients = jdbcTemplate.query(patientsql, new BeanPropertyRowMapper(PatientVO.class));
        JSONObject result = new JSONObject();
        //绿标居民
        List<PatientVO> green_patients = new ArrayList<>();
        //黄标居民
        List<PatientVO> yellow_patients = new ArrayList<>();
        //红标居民
        List<PatientVO> red_patients = new ArrayList<>();
        if (!patients.isEmpty()) {
            for (PatientVO patient : patients) {
                //获取居民颜色标签
                if (patient.getDiseaseCondition() != null) {
                    switch (patient.getDiseaseCondition()) {
                        case 0:
                            green_patients.add(patient);
                            break;
                        case 1:
                            yellow_patients.add(patient);
                            break;
                        case 2:
                            red_patients.add(patient);
                            break;
                    }
                }
            }
        }
        result.put("greencount", green_patients.size());
        result.put("yellowcount", yellow_patients.size());
        result.put("redcount", red_patients.size());
        // 重点关注居民
        List<TrackPatient> list = trackPatientDao.findByDoctorCodeAndDel(doctorCode, "1");
        if (list != null && list.size() > 0) {
            result.put("trackPatientCount", list.size());
        } else {
            result.put("trackPatientCount", 0);
        }
        return result;
    }
    public String getCode() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
    public static ExecutorService execute = Executors.newFixedThreadPool(20);
    /**
     * 获取红黄绿标高血压糖尿病的指标人数
     * disease 1高血压,2糖尿病,3高血压+糖尿病
     * 预警数量   a.standard_status='1'
     *
     * @return
     */
    public HashMap<String, Object> getLabelCount(String doctorId) throws ExecutionException, InterruptedException {
        // 高血压预警
        String sql01 = "SELECT count(DISTINCT  a.id)\n" +
                "FROM base_patient a \n" +
                "INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "WHERE 1=1\n" +
                "AND a.standard_status='1'\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND a.disease IN ('1','3') \n" +
                "AND b.doctor_id ='" + doctorId + "'";
        // 高血压
        String sql02 = "SELECT count(DISTINCT  a.id)\n" +
                "FROM base_patient a \n" +
                "INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "WHERE 1=1\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND a.disease IN ('1','3') \n" +
                "AND b.doctor_id ='" + doctorId + "'";
        // 糖尿病预警
        String sql03 = "SELECT count(DISTINCT  a.id)\n" +
                "FROM base_patient a \n" +
                "INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "WHERE 1=1\n" +
                "AND a.standard_status='1'\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND a.disease IN ('2','3') \n" +
                "AND b.doctor_id ='" + doctorId + "'";
        // 糖尿病
        String sql04 = "SELECT count(DISTINCT  a.id)\n" +
                "FROM base_patient a \n" +
                "INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "WHERE 1=1\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND a.disease IN ('2','3') \n" +
                "AND b.doctor_id ='" + doctorId + "'";
        CompletableFuture<Integer> future01 = CompletableFuture.supplyAsync(() -> {
            Integer count = jdbcTemplate.queryForObject(sql01, Integer.class);
            return count;
        }, execute);
        CompletableFuture<Integer> future02 = CompletableFuture.supplyAsync(() -> {
            Integer count = jdbcTemplate.queryForObject(sql02, Integer.class);
            return count;
        }, execute);
        CompletableFuture<Integer> future03 = CompletableFuture.supplyAsync(() -> {
            Integer count = jdbcTemplate.queryForObject(sql03, Integer.class);
            return count;
        }, execute);
        CompletableFuture<Integer> future04 = CompletableFuture.supplyAsync(() -> {
            Integer count = jdbcTemplate.queryForObject(sql04, Integer.class);
            return count;
        }, execute);
        CompletableFuture.allOf(future01, future02, future03, future04).get();
        Integer count1 = future01.get();// 高血压预警
        Integer count2 = future02.get();// 高血压
        Integer count3 = future03.get();// 糖尿病预警
        Integer count4 = future04.get();// 糖尿病
        HashMap<String, Object> map = new HashMap<>();
        map.put("gxy_yj", count1);// 高血压预警
        map.put("gxy", count2);// 高血压预警
        map.put("tnb_yj", count3);// 高血压预警
        map.put("tnb", count4);// 高血压预警
        return map;
    }
    /**
     * labelType 1高血压 2糖尿病
     */
    public List<Map<String, Object>> getLabelDetail(String doctorId, String labelType, String searchContent, int page, int pageSize) {
        String sql = "SELECTDISTINCT a.id,a.`name`,a.idcard,a.mobile,a.ssc, TIMESTAMPDIFF(YEAR, a.birthday, CURDATE()) AS age ,a.sex \n" +
                "FROM base_patient a \n" +
                "INNER JOIN base_patient_doctor_relation b ON a.id=b.patient_id\n" +
                "WHERE 1=1\n" +
                "AND a.disease_condition IN('1','2','3')\n" +
                "AND b.doctor_id ='" + doctorId + "'";
        if (StringUtils.isNotBlank(labelType)) {
            if ("1".equals(labelType)) {
                sql += "AND a.disease IN ('1','3') \n";
            }
            if ("2".equals(labelType)) {
                sql += "AND a.disease IN ('2','3') \n";
            }
        }
        if (StringUtils.isNotBlank(searchContent)) {
            sql += " AND a.`name` LIKE '%" + searchContent + "%' ";
        }
        sql += " LIMIT  " + (page - 1) * pageSize + "," + pageSize + "";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
}

+ 2403 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/vo/MedicalDetailVo.java

@ -0,0 +1,2403 @@
package com.yihu.jw.hospital.module.health.vo;
import java.util.List;
/**
 * @author suqinyi
 * @Date 2023/6/12
 */
public class MedicalDetailVo {
    private String medicalNo;
    private String medicalInfoId;
    private String skinOthers;
    private String renalOthers;
    private String fastingPlasmaGlucoseDL;
    private String abdoShiftingDull;
    private String eyegroundException;
    private String abdoHepatomegalyOth;
    private String electrocardiogram;
    private String typeBUltrasonic;
    private String height;
    private String abdoMassesOthers;
    private String liverFunctionTotalBilirubin;
    private String bloodFatHdlc;
    private String heartChf;
    private String renalDn;
    private String bloodRoutineOthers;
    private String eyeDiseaseCataract;
    private String vulvaException;
    private String poisonOthers;
    private String cardiacSouffle;
    private String heartPrecordialpain;
    private String isDryOut;
    private String poisonPhysicalfactor;
    private String healthGuidanceOther;
    private String hazardLoseWeight;
    private String poisonDustPreStr;
    private String breastOthersStr;
    private String angiosisUndiscovered;
    private String bloodPressureLeftD;
    private String vulva;
    private String renalFunctionBun;
    private String cvdSah;
    private String sclera;
    private String ket;
    private String renalFunctionCreatinine;
    private String audition;
    private String miniMentalStateExamination;
    private String drinkOthers;
    private String hardeningFrequency;
    private String occupationalDiseaseWorkTime;
    private String asymptomatic;
    private String abdoHepatomegaly;
    private String fastingPlasmaGlucoseL;
    private String visionRightEye;
    private String symptomBreastBursting;
    private String poisonChemicalPreStr;
    private String eatHobbySugar;
    private String lips;
    private String vaginaException;
    private String everyHardeningTime;
    private String upcr;
    private String angiosisOthers;
    private String occupationalDisease;
    private String motorFunction;
    private String corporeityQiDepression;
    private String heartOthers;
    private String cvdOthers;
    private String poisonChemical;
    private String lungBreathSoundExcep;
    private String angiosisDa;
    private String corpus;
    private String cervicalPapSmears;
    private String breastOthers;
    private String elderlyAffectiveState;
    private String cvdIschemicStroke;
    private String lymphNodeRrmprt;
    private String isExaminationExcep;
    private String symptomPalpitation;
    private String heartOthersStr;
    private String hardeningMode;
    private String cxr;
    private String lymphNodeNotTouch;
    private String lymphNodeClavicle;
    private String elderlyHealthStatus;
    private String othersSystemDisease;
    private String symptomDazzle;
    private String symptomJointGall;
    private String lungBarrelChest;
    private String symptomChestPain;
    private String abdoPressPain;
    private String symptomWeightLoss;
    private String occDiseaseTrades;
    private String fundamentFingerpOth;
    private String weight;
    private String symptomUrinaryUrgency;
    private String drinkFrequency;
    private String poisonOthersPreStr;
    private String dentitiondentureNormal;
    private String glycolatedHemoglobin;
    private String bloodFatLdlc;
    private String hazardHealthDrink;
    private String othersSystemDiseaseStr;
    private String poisonOthersIspre;
    private String dorsumOfFootArteriopalmus;
    private String renalFunctionNatremia;
    private String breastMastectomy;
    private String proteinuria;
    private String symptomDysuria;
    private String corporeityTeBing;
    private String bloodFatTriglyceride;
    private String urinaryOccultBlood;
    private String doctorName;
    private String symptomDiarrhea;
    private String poisonRadiogenPreStr;
    private String abdoSplenomegalyOth;
    private String breastAbnormalLactation;
    private String dentitiondentureDentalCaries;
    private String symptomChronicCough;
    private String symptomOther;
    private String stoolOccultBlood;
    private String renalFailure;
    private String symptomDizziness;
    private String respiratoryRate;
    private String lungRhonchusException;
    private String beginSmokingAge;
    private String abdoMasses;
    private String eatMeatdietFlash;
    private String poisonPhysicalPreStr;
    private String renalFunctionBloodPotassium;
    private String platelet;
    private String liverFunctionSgot;
    private String uricAcid;
    private String renalCgn;
    private String assistantInvesOth;
    private String symptomHandFootNumbness;
    private String papilledema;
    private String eatHobbyOil;
    private String symptomTinnitus;
    private String abdoSplenomegaly;
    private String retinalHemorrhage;
    private String corporeityYangDeficiency;
    private String liverFunctionCb;
    private String healthGuidanceOtherStr;
    private String pulseFrequency;
    private String elderlyDepressionCheck;
    private String dryOutAge;
    private String smokingCircumstance;
    private String heartUndiscovered;
    private String cvdUndiscovered;
    private String drinkRedWine;
    private String eyeDiseaseOthers;
    private String quitSmokingAge;
    private String cardiacSouffleOthers;
    private String hazardOthersStr;
    private String scleraOthers;
    private String lungRhonchus;
    private String urineRoutineOthers;
    private String symptomHeadache;
    private String eatVegetarianFlash;
    private String cvdOthersStr;
    private String symptomConstipation;
    private String breastNotTroubleFind;
    private String poisonRadiogen;
    private String leukocyte;
    private String waist;
    private String cvdCerebralHemorrhage;
    private String corpusException;
    private String abdoShiftingDullOth;
    private String nervousSystemDiseaseStr;
    private String drinkOthersStr;
    private String skin;
    private String cervicalPapSmearsExcep;
    private String healthGuidanceInhospital;
    private String hazardOthers;
    private String healthRegularFollowUp;
    private String hazardVaccination;
    private String poisonChemicalIspre;
    private String abdoPressPainOth;
    private String healthGuidanceSlowDisease;
    private String bloodPressureRigthD;
    private String cervix;
    private String poisonDustIspre;
    private String breastMasses;
    private String attachmentException;
    private String nervousSystemDisease;
    private String hazardHardening;
    private String cervixException;
    private String symptomPolyuria;
    private String lungBreathSound;
    private String symptomDyspnea;
    private String cxrException;
    private String everyAlcohol_tolerance;
    private String microalbuminuria;
    private String corporeityYinDeficiency;
    private String fundamentFingerp;
    private String elderlyCognitiveFun;
    private String dentitiondentureMissTeeth;
    private String hbsag;
    private String eyeground;
    private String renalAgn;
    private String cardiacRhythm;
    private String bmi;
    private String oneYearIsTemulentia;
    private String corporeityQiAsthenia;
    private String pharyngealportionYes;
    private String straightenVisionRightEye;
    private String symptomExpectoration;
    private String hazardVaccinationStr;
    private String bloodFatTc;
    private String symptomChestStuffiness;
    private String lymphNodeOthers;
    private String bodyTemperature;
    private String typeBUltrasonicExcep;
    private String immersionFoot;
    private String renalOthersStr;
    private String beginDrinkAge;
    private String symptomNauseaVomiting;
    private String corporeityGentle;
    private String corporeityDampHeat;
    private String orgName;
    private String vagina;
    private String heartAnginaPectoris;
    private String urineSugar;
    private String poisonRadiogenIspre;
    private String drinkWhiteSpirits;
    private String bloodPressureRigthU;
    private String liverFunctionAlbumin;
    private String visionLeftEye;
    private String straightenVisionLeftEye;
    private String heartRate;
    private String symptomPolydipsia;
    private String bloodPressureLeftU;
    private String physicalExaminationOth;
    private String dailySmokingQuantity;
    private String drinkYellowWine;
    private String drinkBeer;
    private String eatHobbySalt;
    private String pharyngealportionAdd;
    private String symptomOtherStr;
    private String elderlySelfCare;
    private String dentitiondentureDenture;
    private String angiosisOthersStr;
    private String eyeDiseaseOthersStr;
    private String hazardQuitSmocking;
    private String symptomLackOfPower;
    private String lymphNode;
    private String angiosisOcclusionArteries;
    private String hemoglobin;
    private String eyeDiseaseUndiscovered;
    private String insistHardeningTime;
    private String renalUndiscovered;
    private String attachment;
    private String healthGuidanceReview;
    private String liverFunctionSalt;
    private String cvdTia;
    private String medicalTime;
    private String hazardFood;
    private String symptomBlurredVision;
    private String corporeityPhlegmDamp;
    private String hazardLoseWeightTarget;
    private String poisonPhysicalIspre;
    private String corporeityHaemostasis;
    private String heartCoronaryArtery;
    private String poisonDust;
    private String pharyngealportionNo;
    private String eatClitocybineEqualization;
    private String heartMyocardialInfarction;
    private String electrocardiogramExcep;
    private List<String> fpList;
    private List<String> examinationList;
//    private List<String> inhospitalList;
//    private List<String> niVaccinationList;
    //    private List<String> drugList;
//    private String[] drugList;
    public String getSkinOthers() {
        return skinOthers;
    }
    public void setSkinOthers(String skinOthers) {
        this.skinOthers = skinOthers;
    }
    public String getRenalOthers() {
        return renalOthers;
    }
    public void setRenalOthers(String renalOthers) {
        this.renalOthers = renalOthers;
    }
    public String getFastingPlasmaGlucoseDL() {
        return fastingPlasmaGlucoseDL;
    }
    public void setFastingPlasmaGlucoseDL(String fastingPlasmaGlucoseDL) {
        this.fastingPlasmaGlucoseDL = fastingPlasmaGlucoseDL;
    }
    public String getAbdoShiftingDull() {
        return abdoShiftingDull;
    }
    public void setAbdoShiftingDull(String abdoShiftingDull) {
        this.abdoShiftingDull = abdoShiftingDull;
    }
    public String getEyegroundException() {
        return eyegroundException;
    }
    public void setEyegroundException(String eyegroundException) {
        this.eyegroundException = eyegroundException;
    }
    public String getAbdoHepatomegalyOth() {
        return abdoHepatomegalyOth;
    }
    public void setAbdoHepatomegalyOth(String abdoHepatomegalyOth) {
        this.abdoHepatomegalyOth = abdoHepatomegalyOth;
    }
    public String getElectrocardiogram() {
        return electrocardiogram;
    }
    public void setElectrocardiogram(String electrocardiogram) {
        this.electrocardiogram = electrocardiogram;
    }
    public String getTypeBUltrasonic() {
        return typeBUltrasonic;
    }
    public void setTypeBUltrasonic(String typeBUltrasonic) {
        this.typeBUltrasonic = typeBUltrasonic;
    }
    public String getHeight() {
        return height;
    }
    public void setHeight(String height) {
        this.height = height;
    }
    public String getAbdoMassesOthers() {
        return abdoMassesOthers;
    }
    public void setAbdoMassesOthers(String abdoMassesOthers) {
        this.abdoMassesOthers = abdoMassesOthers;
    }
    public String getLiverFunctionTotalBilirubin() {
        return liverFunctionTotalBilirubin;
    }
    public void setLiverFunctionTotalBilirubin(String liverFunctionTotalBilirubin) {
        this.liverFunctionTotalBilirubin = liverFunctionTotalBilirubin;
    }
    public String getBloodFatHdlc() {
        return bloodFatHdlc;
    }
    public void setBloodFatHdlc(String bloodFatHdlc) {
        this.bloodFatHdlc = bloodFatHdlc;
    }
    public String getHeartChf() {
        return heartChf;
    }
    public void setHeartChf(String heartChf) {
        this.heartChf = heartChf;
    }
    public String getRenalDn() {
        return renalDn;
    }
    public void setRenalDn(String renalDn) {
        this.renalDn = renalDn;
    }
    public String getBloodRoutineOthers() {
        return bloodRoutineOthers;
    }
    public void setBloodRoutineOthers(String bloodRoutineOthers) {
        this.bloodRoutineOthers = bloodRoutineOthers;
    }
    public String getEyeDiseaseCataract() {
        return eyeDiseaseCataract;
    }
    public void setEyeDiseaseCataract(String eyeDiseaseCataract) {
        this.eyeDiseaseCataract = eyeDiseaseCataract;
    }
    public String getVulvaException() {
        return vulvaException;
    }
    public void setVulvaException(String vulvaException) {
        this.vulvaException = vulvaException;
    }
    public String getPoisonOthers() {
        return poisonOthers;
    }
    public void setPoisonOthers(String poisonOthers) {
        this.poisonOthers = poisonOthers;
    }
    public String getCardiacSouffle() {
        return cardiacSouffle;
    }
    public void setCardiacSouffle(String cardiacSouffle) {
        this.cardiacSouffle = cardiacSouffle;
    }
    public String getHeartPrecordialpain() {
        return heartPrecordialpain;
    }
    public void setHeartPrecordialpain(String heartPrecordialpain) {
        this.heartPrecordialpain = heartPrecordialpain;
    }
    public String getIsDryOut() {
        return isDryOut;
    }
    public void setIsDryOut(String isDryOut) {
        this.isDryOut = isDryOut;
    }
    public String getPoisonPhysicalfactor() {
        return poisonPhysicalfactor;
    }
    public void setPoisonPhysicalfactor(String poisonPhysicalfactor) {
        this.poisonPhysicalfactor = poisonPhysicalfactor;
    }
    public String getHealthGuidanceOther() {
        return healthGuidanceOther;
    }
    public void setHealthGuidanceOther(String healthGuidanceOther) {
        this.healthGuidanceOther = healthGuidanceOther;
    }
    public String getHazardLoseWeight() {
        return hazardLoseWeight;
    }
    public void setHazardLoseWeight(String hazardLoseWeight) {
        this.hazardLoseWeight = hazardLoseWeight;
    }
    public String getPoisonDustPreStr() {
        return poisonDustPreStr;
    }
    public void setPoisonDustPreStr(String poisonDustPreStr) {
        this.poisonDustPreStr = poisonDustPreStr;
    }
    public String getBreastOthersStr() {
        return breastOthersStr;
    }
    public void setBreastOthersStr(String breastOthersStr) {
        this.breastOthersStr = breastOthersStr;
    }
    public String getAngiosisUndiscovered() {
        return angiosisUndiscovered;
    }
    public void setAngiosisUndiscovered(String angiosisUndiscovered) {
        this.angiosisUndiscovered = angiosisUndiscovered;
    }
    public String getBloodPressureLeftD() {
        return bloodPressureLeftD;
    }
    public void setBloodPressureLeftD(String bloodPressureLeftD) {
        this.bloodPressureLeftD = bloodPressureLeftD;
    }
    public String getVulva() {
        return vulva;
    }
    public void setVulva(String vulva) {
        this.vulva = vulva;
    }
    public String getRenalFunctionBun() {
        return renalFunctionBun;
    }
    public void setRenalFunctionBun(String renalFunctionBun) {
        this.renalFunctionBun = renalFunctionBun;
    }
    public String getCvdSah() {
        return cvdSah;
    }
    public void setCvdSah(String cvdSah) {
        this.cvdSah = cvdSah;
    }
    public String getSclera() {
        return sclera;
    }
    public void setSclera(String sclera) {
        this.sclera = sclera;
    }
    public String getKet() {
        return ket;
    }
    public void setKet(String ket) {
        this.ket = ket;
    }
    public String getRenalFunctionCreatinine() {
        return renalFunctionCreatinine;
    }
    public void setRenalFunctionCreatinine(String renalFunctionCreatinine) {
        this.renalFunctionCreatinine = renalFunctionCreatinine;
    }
    public String getAudition() {
        return audition;
    }
    public void setAudition(String audition) {
        this.audition = audition;
    }
    public String getMiniMentalStateExamination() {
        return miniMentalStateExamination;
    }
    public void setMiniMentalStateExamination(String miniMentalStateExamination) {
        this.miniMentalStateExamination = miniMentalStateExamination;
    }
    public String getDrinkOthers() {
        return drinkOthers;
    }
    public void setDrinkOthers(String drinkOthers) {
        this.drinkOthers = drinkOthers;
    }
    public String getHardeningFrequency() {
        return hardeningFrequency;
    }
    public void setHardeningFrequency(String hardeningFrequency) {
        this.hardeningFrequency = hardeningFrequency;
    }
    public String getOccupationalDiseaseWorkTime() {
        return occupationalDiseaseWorkTime;
    }
    public void setOccupationalDiseaseWorkTime(String occupationalDiseaseWorkTime) {
        this.occupationalDiseaseWorkTime = occupationalDiseaseWorkTime;
    }
    public String getAsymptomatic() {
        return asymptomatic;
    }
    public void setAsymptomatic(String asymptomatic) {
        this.asymptomatic = asymptomatic;
    }
    public String getAbdoHepatomegaly() {
        return abdoHepatomegaly;
    }
    public void setAbdoHepatomegaly(String abdoHepatomegaly) {
        this.abdoHepatomegaly = abdoHepatomegaly;
    }
    public String getFastingPlasmaGlucoseL() {
        return fastingPlasmaGlucoseL;
    }
    public void setFastingPlasmaGlucoseL(String fastingPlasmaGlucoseL) {
        this.fastingPlasmaGlucoseL = fastingPlasmaGlucoseL;
    }
    public String getVisionRightEye() {
        return visionRightEye;
    }
    public void setVisionRightEye(String visionRightEye) {
        this.visionRightEye = visionRightEye;
    }
    public String getSymptomBreastBursting() {
        return symptomBreastBursting;
    }
    public void setSymptomBreastBursting(String symptomBreastBursting) {
        this.symptomBreastBursting = symptomBreastBursting;
    }
    public String getPoisonChemicalPreStr() {
        return poisonChemicalPreStr;
    }
    public void setPoisonChemicalPreStr(String poisonChemicalPreStr) {
        this.poisonChemicalPreStr = poisonChemicalPreStr;
    }
    public String getEatHobbySugar() {
        return eatHobbySugar;
    }
    public void setEatHobbySugar(String eatHobbySugar) {
        this.eatHobbySugar = eatHobbySugar;
    }
    public String getLips() {
        return lips;
    }
    public void setLips(String lips) {
        this.lips = lips;
    }
    public String getVaginaException() {
        return vaginaException;
    }
    public void setVaginaException(String vaginaException) {
        this.vaginaException = vaginaException;
    }
    public String getEveryHardeningTime() {
        return everyHardeningTime;
    }
    public void setEveryHardeningTime(String everyHardeningTime) {
        this.everyHardeningTime = everyHardeningTime;
    }
    public String getUpcr() {
        return upcr;
    }
    public void setUpcr(String upcr) {
        this.upcr = upcr;
    }
    public String getAngiosisOthers() {
        return angiosisOthers;
    }
    public void setAngiosisOthers(String angiosisOthers) {
        this.angiosisOthers = angiosisOthers;
    }
    public String getOccupationalDisease() {
        return occupationalDisease;
    }
    public void setOccupationalDisease(String occupationalDisease) {
        this.occupationalDisease = occupationalDisease;
    }
    public String getMotorFunction() {
        return motorFunction;
    }
    public void setMotorFunction(String motorFunction) {
        this.motorFunction = motorFunction;
    }
    public String getCorporeityQiDepression() {
        return corporeityQiDepression;
    }
    public void setCorporeityQiDepression(String corporeityQiDepression) {
        this.corporeityQiDepression = corporeityQiDepression;
    }
    public String getHeartOthers() {
        return heartOthers;
    }
    public void setHeartOthers(String heartOthers) {
        this.heartOthers = heartOthers;
    }
    public String getCvdOthers() {
        return cvdOthers;
    }
    public void setCvdOthers(String cvdOthers) {
        this.cvdOthers = cvdOthers;
    }
    public String getPoisonChemical() {
        return poisonChemical;
    }
    public void setPoisonChemical(String poisonChemical) {
        this.poisonChemical = poisonChemical;
    }
    public String getLungBreathSoundExcep() {
        return lungBreathSoundExcep;
    }
    public void setLungBreathSoundExcep(String lungBreathSoundExcep) {
        this.lungBreathSoundExcep = lungBreathSoundExcep;
    }
    public String getAngiosisDa() {
        return angiosisDa;
    }
    public void setAngiosisDa(String angiosisDa) {
        this.angiosisDa = angiosisDa;
    }
    public String getCorpus() {
        return corpus;
    }
    public void setCorpus(String corpus) {
        this.corpus = corpus;
    }
    public String getCervicalPapSmears() {
        return cervicalPapSmears;
    }
    public void setCervicalPapSmears(String cervicalPapSmears) {
        this.cervicalPapSmears = cervicalPapSmears;
    }
    public String getBreastOthers() {
        return breastOthers;
    }
    public void setBreastOthers(String breastOthers) {
        this.breastOthers = breastOthers;
    }
    public String getElderlyAffectiveState() {
        return elderlyAffectiveState;
    }
    public void setElderlyAffectiveState(String elderlyAffectiveState) {
        this.elderlyAffectiveState = elderlyAffectiveState;
    }
    public String getCvdIschemicStroke() {
        return cvdIschemicStroke;
    }
    public void setCvdIschemicStroke(String cvdIschemicStroke) {
        this.cvdIschemicStroke = cvdIschemicStroke;
    }
    public String getLymphNodeRrmprt() {
        return lymphNodeRrmprt;
    }
    public void setLymphNodeRrmprt(String lymphNodeRrmprt) {
        this.lymphNodeRrmprt = lymphNodeRrmprt;
    }
    public String getIsExaminationExcep() {
        return isExaminationExcep;
    }
    public void setIsExaminationExcep(String isExaminationExcep) {
        this.isExaminationExcep = isExaminationExcep;
    }
    public String getSymptomPalpitation() {
        return symptomPalpitation;
    }
    public void setSymptomPalpitation(String symptomPalpitation) {
        this.symptomPalpitation = symptomPalpitation;
    }
    public String getHeartOthersStr() {
        return heartOthersStr;
    }
    public void setHeartOthersStr(String heartOthersStr) {
        this.heartOthersStr = heartOthersStr;
    }
    public String getHardeningMode() {
        return hardeningMode;
    }
    public void setHardeningMode(String hardeningMode) {
        this.hardeningMode = hardeningMode;
    }
    public String getCxr() {
        return cxr;
    }
    public void setCxr(String cxr) {
        this.cxr = cxr;
    }
    public String getLymphNodeNotTouch() {
        return lymphNodeNotTouch;
    }
    public void setLymphNodeNotTouch(String lymphNodeNotTouch) {
        this.lymphNodeNotTouch = lymphNodeNotTouch;
    }
    public String getLymphNodeClavicle() {
        return lymphNodeClavicle;
    }
    public void setLymphNodeClavicle(String lymphNodeClavicle) {
        this.lymphNodeClavicle = lymphNodeClavicle;
    }
    public String getElderlyHealthStatus() {
        return elderlyHealthStatus;
    }
    public void setElderlyHealthStatus(String elderlyHealthStatus) {
        this.elderlyHealthStatus = elderlyHealthStatus;
    }
    public String getOthersSystemDisease() {
        return othersSystemDisease;
    }
    public void setOthersSystemDisease(String othersSystemDisease) {
        this.othersSystemDisease = othersSystemDisease;
    }
    public String getSymptomDazzle() {
        return symptomDazzle;
    }
    public void setSymptomDazzle(String symptomDazzle) {
        this.symptomDazzle = symptomDazzle;
    }
    public String getSymptomJointGall() {
        return symptomJointGall;
    }
    public void setSymptomJointGall(String symptomJointGall) {
        this.symptomJointGall = symptomJointGall;
    }
    public String getLungBarrelChest() {
        return lungBarrelChest;
    }
    public void setLungBarrelChest(String lungBarrelChest) {
        this.lungBarrelChest = lungBarrelChest;
    }
    public String getSymptomChestPain() {
        return symptomChestPain;
    }
    public void setSymptomChestPain(String symptomChestPain) {
        this.symptomChestPain = symptomChestPain;
    }
    public String getAbdoPressPain() {
        return abdoPressPain;
    }
    public void setAbdoPressPain(String abdoPressPain) {
        this.abdoPressPain = abdoPressPain;
    }
    public String getSymptomWeightLoss() {
        return symptomWeightLoss;
    }
    public void setSymptomWeightLoss(String symptomWeightLoss) {
        this.symptomWeightLoss = symptomWeightLoss;
    }
    public String getOccDiseaseTrades() {
        return occDiseaseTrades;
    }
    public void setOccDiseaseTrades(String occDiseaseTrades) {
        this.occDiseaseTrades = occDiseaseTrades;
    }
    public String getFundamentFingerpOth() {
        return fundamentFingerpOth;
    }
    public void setFundamentFingerpOth(String fundamentFingerpOth) {
        this.fundamentFingerpOth = fundamentFingerpOth;
    }
    public String getWeight() {
        return weight;
    }
    public void setWeight(String weight) {
        this.weight = weight;
    }
    public String getSymptomUrinaryUrgency() {
        return symptomUrinaryUrgency;
    }
    public void setSymptomUrinaryUrgency(String symptomUrinaryUrgency) {
        this.symptomUrinaryUrgency = symptomUrinaryUrgency;
    }
    public String getDrinkFrequency() {
        return drinkFrequency;
    }
    public void setDrinkFrequency(String drinkFrequency) {
        this.drinkFrequency = drinkFrequency;
    }
    public String getPoisonOthersPreStr() {
        return poisonOthersPreStr;
    }
    public void setPoisonOthersPreStr(String poisonOthersPreStr) {
        this.poisonOthersPreStr = poisonOthersPreStr;
    }
    public String getDentitiondentureNormal() {
        return dentitiondentureNormal;
    }
    public void setDentitiondentureNormal(String dentitiondentureNormal) {
        this.dentitiondentureNormal = dentitiondentureNormal;
    }
    public String getGlycolatedHemoglobin() {
        return glycolatedHemoglobin;
    }
    public void setGlycolatedHemoglobin(String glycolatedHemoglobin) {
        this.glycolatedHemoglobin = glycolatedHemoglobin;
    }
    public String getBloodFatLdlc() {
        return bloodFatLdlc;
    }
    public void setBloodFatLdlc(String bloodFatLdlc) {
        this.bloodFatLdlc = bloodFatLdlc;
    }
    public String getHazardHealthDrink() {
        return hazardHealthDrink;
    }
    public void setHazardHealthDrink(String hazardHealthDrink) {
        this.hazardHealthDrink = hazardHealthDrink;
    }
    public String getOthersSystemDiseaseStr() {
        return othersSystemDiseaseStr;
    }
    public void setOthersSystemDiseaseStr(String othersSystemDiseaseStr) {
        this.othersSystemDiseaseStr = othersSystemDiseaseStr;
    }
    public String getPoisonOthersIspre() {
        return poisonOthersIspre;
    }
    public void setPoisonOthersIspre(String poisonOthersIspre) {
        this.poisonOthersIspre = poisonOthersIspre;
    }
    public String getDorsumOfFootArteriopalmus() {
        return dorsumOfFootArteriopalmus;
    }
    public void setDorsumOfFootArteriopalmus(String dorsumOfFootArteriopalmus) {
        this.dorsumOfFootArteriopalmus = dorsumOfFootArteriopalmus;
    }
    public String getRenalFunctionNatremia() {
        return renalFunctionNatremia;
    }
    public void setRenalFunctionNatremia(String renalFunctionNatremia) {
        this.renalFunctionNatremia = renalFunctionNatremia;
    }
    public String getBreastMastectomy() {
        return breastMastectomy;
    }
    public void setBreastMastectomy(String breastMastectomy) {
        this.breastMastectomy = breastMastectomy;
    }
    public String getProteinuria() {
        return proteinuria;
    }
    public void setProteinuria(String proteinuria) {
        this.proteinuria = proteinuria;
    }
    public String getSymptomDysuria() {
        return symptomDysuria;
    }
    public void setSymptomDysuria(String symptomDysuria) {
        this.symptomDysuria = symptomDysuria;
    }
    public String getCorporeityTeBing() {
        return corporeityTeBing;
    }
    public void setCorporeityTeBing(String corporeityTeBing) {
        this.corporeityTeBing = corporeityTeBing;
    }
    public String getBloodFatTriglyceride() {
        return bloodFatTriglyceride;
    }
    public void setBloodFatTriglyceride(String bloodFatTriglyceride) {
        this.bloodFatTriglyceride = bloodFatTriglyceride;
    }
    public String getUrinaryOccultBlood() {
        return urinaryOccultBlood;
    }
    public void setUrinaryOccultBlood(String urinaryOccultBlood) {
        this.urinaryOccultBlood = urinaryOccultBlood;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getSymptomDiarrhea() {
        return symptomDiarrhea;
    }
    public void setSymptomDiarrhea(String symptomDiarrhea) {
        this.symptomDiarrhea = symptomDiarrhea;
    }
    public String getPoisonRadiogenPreStr() {
        return poisonRadiogenPreStr;
    }
    public void setPoisonRadiogenPreStr(String poisonRadiogenPreStr) {
        this.poisonRadiogenPreStr = poisonRadiogenPreStr;
    }
    public String getAbdoSplenomegalyOth() {
        return abdoSplenomegalyOth;
    }
    public void setAbdoSplenomegalyOth(String abdoSplenomegalyOth) {
        this.abdoSplenomegalyOth = abdoSplenomegalyOth;
    }
    public String getBreastAbnormalLactation() {
        return breastAbnormalLactation;
    }
    public void setBreastAbnormalLactation(String breastAbnormalLactation) {
        this.breastAbnormalLactation = breastAbnormalLactation;
    }
    public String getDentitiondentureDentalCaries() {
        return dentitiondentureDentalCaries;
    }
    public void setDentitiondentureDentalCaries(String dentitiondentureDentalCaries) {
        this.dentitiondentureDentalCaries = dentitiondentureDentalCaries;
    }
    public String getSymptomChronicCough() {
        return symptomChronicCough;
    }
    public void setSymptomChronicCough(String symptomChronicCough) {
        this.symptomChronicCough = symptomChronicCough;
    }
    public String getSymptomOther() {
        return symptomOther;
    }
    public void setSymptomOther(String symptomOther) {
        this.symptomOther = symptomOther;
    }
    public String getStoolOccultBlood() {
        return stoolOccultBlood;
    }
    public void setStoolOccultBlood(String stoolOccultBlood) {
        this.stoolOccultBlood = stoolOccultBlood;
    }
    public String getRenalFailure() {
        return renalFailure;
    }
    public void setRenalFailure(String renalFailure) {
        this.renalFailure = renalFailure;
    }
    public String getSymptomDizziness() {
        return symptomDizziness;
    }
    public void setSymptomDizziness(String symptomDizziness) {
        this.symptomDizziness = symptomDizziness;
    }
    public String getRespiratoryRate() {
        return respiratoryRate;
    }
    public void setRespiratoryRate(String respiratoryRate) {
        this.respiratoryRate = respiratoryRate;
    }
    public String getLungRhonchusException() {
        return lungRhonchusException;
    }
    public void setLungRhonchusException(String lungRhonchusException) {
        this.lungRhonchusException = lungRhonchusException;
    }
    public String getBeginSmokingAge() {
        return beginSmokingAge;
    }
    public void setBeginSmokingAge(String beginSmokingAge) {
        this.beginSmokingAge = beginSmokingAge;
    }
    public String getAbdoMasses() {
        return abdoMasses;
    }
    public void setAbdoMasses(String abdoMasses) {
        this.abdoMasses = abdoMasses;
    }
    public String getEatMeatdietFlash() {
        return eatMeatdietFlash;
    }
    public void setEatMeatdietFlash(String eatMeatdietFlash) {
        this.eatMeatdietFlash = eatMeatdietFlash;
    }
    public String getPoisonPhysicalPreStr() {
        return poisonPhysicalPreStr;
    }
    public void setPoisonPhysicalPreStr(String poisonPhysicalPreStr) {
        this.poisonPhysicalPreStr = poisonPhysicalPreStr;
    }
    public String getRenalFunctionBloodPotassium() {
        return renalFunctionBloodPotassium;
    }
    public void setRenalFunctionBloodPotassium(String renalFunctionBloodPotassium) {
        this.renalFunctionBloodPotassium = renalFunctionBloodPotassium;
    }
    public String getPlatelet() {
        return platelet;
    }
    public void setPlatelet(String platelet) {
        this.platelet = platelet;
    }
    public String getLiverFunctionSgot() {
        return liverFunctionSgot;
    }
    public void setLiverFunctionSgot(String liverFunctionSgot) {
        this.liverFunctionSgot = liverFunctionSgot;
    }
    public String getUricAcid() {
        return uricAcid;
    }
    public void setUricAcid(String uricAcid) {
        this.uricAcid = uricAcid;
    }
    public String getRenalCgn() {
        return renalCgn;
    }
    public void setRenalCgn(String renalCgn) {
        this.renalCgn = renalCgn;
    }
    public String getAssistantInvesOth() {
        return assistantInvesOth;
    }
    public void setAssistantInvesOth(String assistantInvesOth) {
        this.assistantInvesOth = assistantInvesOth;
    }
    public String getSymptomHandFootNumbness() {
        return symptomHandFootNumbness;
    }
    public void setSymptomHandFootNumbness(String symptomHandFootNumbness) {
        this.symptomHandFootNumbness = symptomHandFootNumbness;
    }
    public String getPapilledema() {
        return papilledema;
    }
    public void setPapilledema(String papilledema) {
        this.papilledema = papilledema;
    }
    public String getEatHobbyOil() {
        return eatHobbyOil;
    }
    public void setEatHobbyOil(String eatHobbyOil) {
        this.eatHobbyOil = eatHobbyOil;
    }
    public String getSymptomTinnitus() {
        return symptomTinnitus;
    }
    public void setSymptomTinnitus(String symptomTinnitus) {
        this.symptomTinnitus = symptomTinnitus;
    }
    public String getAbdoSplenomegaly() {
        return abdoSplenomegaly;
    }
    public void setAbdoSplenomegaly(String abdoSplenomegaly) {
        this.abdoSplenomegaly = abdoSplenomegaly;
    }
    public String getRetinalHemorrhage() {
        return retinalHemorrhage;
    }
    public void setRetinalHemorrhage(String retinalHemorrhage) {
        this.retinalHemorrhage = retinalHemorrhage;
    }
    public String getCorporeityYangDeficiency() {
        return corporeityYangDeficiency;
    }
    public void setCorporeityYangDeficiency(String corporeityYangDeficiency) {
        this.corporeityYangDeficiency = corporeityYangDeficiency;
    }
    public String getLiverFunctionCb() {
        return liverFunctionCb;
    }
    public void setLiverFunctionCb(String liverFunctionCb) {
        this.liverFunctionCb = liverFunctionCb;
    }
    public String getHealthGuidanceOtherStr() {
        return healthGuidanceOtherStr;
    }
    public void setHealthGuidanceOtherStr(String healthGuidanceOtherStr) {
        this.healthGuidanceOtherStr = healthGuidanceOtherStr;
    }
    public String getPulseFrequency() {
        return pulseFrequency;
    }
    public void setPulseFrequency(String pulseFrequency) {
        this.pulseFrequency = pulseFrequency;
    }
    public String getElderlyDepressionCheck() {
        return elderlyDepressionCheck;
    }
    public void setElderlyDepressionCheck(String elderlyDepressionCheck) {
        this.elderlyDepressionCheck = elderlyDepressionCheck;
    }
    public String getDryOutAge() {
        return dryOutAge;
    }
    public void setDryOutAge(String dryOutAge) {
        this.dryOutAge = dryOutAge;
    }
    public String getSmokingCircumstance() {
        return smokingCircumstance;
    }
    public void setSmokingCircumstance(String smokingCircumstance) {
        this.smokingCircumstance = smokingCircumstance;
    }
    public String getHeartUndiscovered() {
        return heartUndiscovered;
    }
    public void setHeartUndiscovered(String heartUndiscovered) {
        this.heartUndiscovered = heartUndiscovered;
    }
    public String getCvdUndiscovered() {
        return cvdUndiscovered;
    }
    public void setCvdUndiscovered(String cvdUndiscovered) {
        this.cvdUndiscovered = cvdUndiscovered;
    }
    public String getDrinkRedWine() {
        return drinkRedWine;
    }
    public void setDrinkRedWine(String drinkRedWine) {
        this.drinkRedWine = drinkRedWine;
    }
    public String getEyeDiseaseOthers() {
        return eyeDiseaseOthers;
    }
    public void setEyeDiseaseOthers(String eyeDiseaseOthers) {
        this.eyeDiseaseOthers = eyeDiseaseOthers;
    }
    public String getQuitSmokingAge() {
        return quitSmokingAge;
    }
    public void setQuitSmokingAge(String quitSmokingAge) {
        this.quitSmokingAge = quitSmokingAge;
    }
    public String getCardiacSouffleOthers() {
        return cardiacSouffleOthers;
    }
    public void setCardiacSouffleOthers(String cardiacSouffleOthers) {
        this.cardiacSouffleOthers = cardiacSouffleOthers;
    }
    public String getHazardOthersStr() {
        return hazardOthersStr;
    }
    public void setHazardOthersStr(String hazardOthersStr) {
        this.hazardOthersStr = hazardOthersStr;
    }
    public String getScleraOthers() {
        return scleraOthers;
    }
    public void setScleraOthers(String scleraOthers) {
        this.scleraOthers = scleraOthers;
    }
    public String getLungRhonchus() {
        return lungRhonchus;
    }
    public void setLungRhonchus(String lungRhonchus) {
        this.lungRhonchus = lungRhonchus;
    }
    public String getUrineRoutineOthers() {
        return urineRoutineOthers;
    }
    public void setUrineRoutineOthers(String urineRoutineOthers) {
        this.urineRoutineOthers = urineRoutineOthers;
    }
    public String getSymptomHeadache() {
        return symptomHeadache;
    }
    public void setSymptomHeadache(String symptomHeadache) {
        this.symptomHeadache = symptomHeadache;
    }
    public String getEatVegetarianFlash() {
        return eatVegetarianFlash;
    }
    public void setEatVegetarianFlash(String eatVegetarianFlash) {
        this.eatVegetarianFlash = eatVegetarianFlash;
    }
    public String getCvdOthersStr() {
        return cvdOthersStr;
    }
    public void setCvdOthersStr(String cvdOthersStr) {
        this.cvdOthersStr = cvdOthersStr;
    }
    public String getSymptomConstipation() {
        return symptomConstipation;
    }
    public void setSymptomConstipation(String symptomConstipation) {
        this.symptomConstipation = symptomConstipation;
    }
    public String getBreastNotTroubleFind() {
        return breastNotTroubleFind;
    }
    public void setBreastNotTroubleFind(String breastNotTroubleFind) {
        this.breastNotTroubleFind = breastNotTroubleFind;
    }
    public String getPoisonRadiogen() {
        return poisonRadiogen;
    }
    public void setPoisonRadiogen(String poisonRadiogen) {
        this.poisonRadiogen = poisonRadiogen;
    }
    public String getLeukocyte() {
        return leukocyte;
    }
    public void setLeukocyte(String leukocyte) {
        this.leukocyte = leukocyte;
    }
    public String getWaist() {
        return waist;
    }
    public void setWaist(String waist) {
        this.waist = waist;
    }
    public String getCvdCerebralHemorrhage() {
        return cvdCerebralHemorrhage;
    }
    public void setCvdCerebralHemorrhage(String cvdCerebralHemorrhage) {
        this.cvdCerebralHemorrhage = cvdCerebralHemorrhage;
    }
    public String getCorpusException() {
        return corpusException;
    }
    public void setCorpusException(String corpusException) {
        this.corpusException = corpusException;
    }
    public String getAbdoShiftingDullOth() {
        return abdoShiftingDullOth;
    }
    public void setAbdoShiftingDullOth(String abdoShiftingDullOth) {
        this.abdoShiftingDullOth = abdoShiftingDullOth;
    }
    public String getNervousSystemDiseaseStr() {
        return nervousSystemDiseaseStr;
    }
    public void setNervousSystemDiseaseStr(String nervousSystemDiseaseStr) {
        this.nervousSystemDiseaseStr = nervousSystemDiseaseStr;
    }
    public String getDrinkOthersStr() {
        return drinkOthersStr;
    }
    public void setDrinkOthersStr(String drinkOthersStr) {
        this.drinkOthersStr = drinkOthersStr;
    }
    public String getSkin() {
        return skin;
    }
    public void setSkin(String skin) {
        this.skin = skin;
    }
    public String getCervicalPapSmearsExcep() {
        return cervicalPapSmearsExcep;
    }
    public void setCervicalPapSmearsExcep(String cervicalPapSmearsExcep) {
        this.cervicalPapSmearsExcep = cervicalPapSmearsExcep;
    }
    public String getHealthGuidanceInhospital() {
        return healthGuidanceInhospital;
    }
    public void setHealthGuidanceInhospital(String healthGuidanceInhospital) {
        this.healthGuidanceInhospital = healthGuidanceInhospital;
    }
    public String getHazardOthers() {
        return hazardOthers;
    }
    public void setHazardOthers(String hazardOthers) {
        this.hazardOthers = hazardOthers;
    }
    public String getHealthRegularFollowUp() {
        return healthRegularFollowUp;
    }
    public void setHealthRegularFollowUp(String healthRegularFollowUp) {
        this.healthRegularFollowUp = healthRegularFollowUp;
    }
    public String getHazardVaccination() {
        return hazardVaccination;
    }
    public void setHazardVaccination(String hazardVaccination) {
        this.hazardVaccination = hazardVaccination;
    }
    public String getPoisonChemicalIspre() {
        return poisonChemicalIspre;
    }
    public void setPoisonChemicalIspre(String poisonChemicalIspre) {
        this.poisonChemicalIspre = poisonChemicalIspre;
    }
    public String getAbdoPressPainOth() {
        return abdoPressPainOth;
    }
    public void setAbdoPressPainOth(String abdoPressPainOth) {
        this.abdoPressPainOth = abdoPressPainOth;
    }
    public String getHealthGuidanceSlowDisease() {
        return healthGuidanceSlowDisease;
    }
    public void setHealthGuidanceSlowDisease(String healthGuidanceSlowDisease) {
        this.healthGuidanceSlowDisease = healthGuidanceSlowDisease;
    }
    public String getBloodPressureRigthD() {
        return bloodPressureRigthD;
    }
    public void setBloodPressureRigthD(String bloodPressureRigthD) {
        this.bloodPressureRigthD = bloodPressureRigthD;
    }
    public String getCervix() {
        return cervix;
    }
    public void setCervix(String cervix) {
        this.cervix = cervix;
    }
    public String getPoisonDustIspre() {
        return poisonDustIspre;
    }
    public void setPoisonDustIspre(String poisonDustIspre) {
        this.poisonDustIspre = poisonDustIspre;
    }
    public String getBreastMasses() {
        return breastMasses;
    }
    public void setBreastMasses(String breastMasses) {
        this.breastMasses = breastMasses;
    }
    public String getAttachmentException() {
        return attachmentException;
    }
    public void setAttachmentException(String attachmentException) {
        this.attachmentException = attachmentException;
    }
    public String getNervousSystemDisease() {
        return nervousSystemDisease;
    }
    public void setNervousSystemDisease(String nervousSystemDisease) {
        this.nervousSystemDisease = nervousSystemDisease;
    }
    public String getHazardHardening() {
        return hazardHardening;
    }
    public void setHazardHardening(String hazardHardening) {
        this.hazardHardening = hazardHardening;
    }
    public String getCervixException() {
        return cervixException;
    }
    public void setCervixException(String cervixException) {
        this.cervixException = cervixException;
    }
    public String getSymptomPolyuria() {
        return symptomPolyuria;
    }
    public void setSymptomPolyuria(String symptomPolyuria) {
        this.symptomPolyuria = symptomPolyuria;
    }
    public String getLungBreathSound() {
        return lungBreathSound;
    }
    public void setLungBreathSound(String lungBreathSound) {
        this.lungBreathSound = lungBreathSound;
    }
    public String getSymptomDyspnea() {
        return symptomDyspnea;
    }
    public void setSymptomDyspnea(String symptomDyspnea) {
        this.symptomDyspnea = symptomDyspnea;
    }
    public String getCxrException() {
        return cxrException;
    }
    public void setCxrException(String cxrException) {
        this.cxrException = cxrException;
    }
    public String getEveryAlcohol_tolerance() {
        return everyAlcohol_tolerance;
    }
    public void setEveryAlcohol_tolerance(String everyAlcohol_tolerance) {
        this.everyAlcohol_tolerance = everyAlcohol_tolerance;
    }
    public String getMicroalbuminuria() {
        return microalbuminuria;
    }
    public void setMicroalbuminuria(String microalbuminuria) {
        this.microalbuminuria = microalbuminuria;
    }
    public String getCorporeityYinDeficiency() {
        return corporeityYinDeficiency;
    }
    public void setCorporeityYinDeficiency(String corporeityYinDeficiency) {
        this.corporeityYinDeficiency = corporeityYinDeficiency;
    }
    public String getFundamentFingerp() {
        return fundamentFingerp;
    }
    public void setFundamentFingerp(String fundamentFingerp) {
        this.fundamentFingerp = fundamentFingerp;
    }
    public String getElderlyCognitiveFun() {
        return elderlyCognitiveFun;
    }
    public void setElderlyCognitiveFun(String elderlyCognitiveFun) {
        this.elderlyCognitiveFun = elderlyCognitiveFun;
    }
    public String getDentitiondentureMissTeeth() {
        return dentitiondentureMissTeeth;
    }
    public void setDentitiondentureMissTeeth(String dentitiondentureMissTeeth) {
        this.dentitiondentureMissTeeth = dentitiondentureMissTeeth;
    }
    public String getHbsag() {
        return hbsag;
    }
    public void setHbsag(String hbsag) {
        this.hbsag = hbsag;
    }
    public String getEyeground() {
        return eyeground;
    }
    public void setEyeground(String eyeground) {
        this.eyeground = eyeground;
    }
    public String getRenalAgn() {
        return renalAgn;
    }
    public void setRenalAgn(String renalAgn) {
        this.renalAgn = renalAgn;
    }
    public String getCardiacRhythm() {
        return cardiacRhythm;
    }
    public void setCardiacRhythm(String cardiacRhythm) {
        this.cardiacRhythm = cardiacRhythm;
    }
    public String getBmi() {
        return bmi;
    }
    public void setBmi(String bmi) {
        this.bmi = bmi;
    }
    public String getOneYearIsTemulentia() {
        return oneYearIsTemulentia;
    }
    public void setOneYearIsTemulentia(String oneYearIsTemulentia) {
        this.oneYearIsTemulentia = oneYearIsTemulentia;
    }
    public String getCorporeityQiAsthenia() {
        return corporeityQiAsthenia;
    }
    public void setCorporeityQiAsthenia(String corporeityQiAsthenia) {
        this.corporeityQiAsthenia = corporeityQiAsthenia;
    }
    public String getPharyngealportionYes() {
        return pharyngealportionYes;
    }
    public void setPharyngealportionYes(String pharyngealportionYes) {
        this.pharyngealportionYes = pharyngealportionYes;
    }
    public String getStraightenVisionRightEye() {
        return straightenVisionRightEye;
    }
    public void setStraightenVisionRightEye(String straightenVisionRightEye) {
        this.straightenVisionRightEye = straightenVisionRightEye;
    }
    public String getSymptomExpectoration() {
        return symptomExpectoration;
    }
    public void setSymptomExpectoration(String symptomExpectoration) {
        this.symptomExpectoration = symptomExpectoration;
    }
    public String getHazardVaccinationStr() {
        return hazardVaccinationStr;
    }
    public void setHazardVaccinationStr(String hazardVaccinationStr) {
        this.hazardVaccinationStr = hazardVaccinationStr;
    }
    public String getBloodFatTc() {
        return bloodFatTc;
    }
    public void setBloodFatTc(String bloodFatTc) {
        this.bloodFatTc = bloodFatTc;
    }
    public String getSymptomChestStuffiness() {
        return symptomChestStuffiness;
    }
    public void setSymptomChestStuffiness(String symptomChestStuffiness) {
        this.symptomChestStuffiness = symptomChestStuffiness;
    }
    public String getLymphNodeOthers() {
        return lymphNodeOthers;
    }
    public void setLymphNodeOthers(String lymphNodeOthers) {
        this.lymphNodeOthers = lymphNodeOthers;
    }
    public String getBodyTemperature() {
        return bodyTemperature;
    }
    public void setBodyTemperature(String bodyTemperature) {
        this.bodyTemperature = bodyTemperature;
    }
    public String getTypeBUltrasonicExcep() {
        return typeBUltrasonicExcep;
    }
    public void setTypeBUltrasonicExcep(String typeBUltrasonicExcep) {
        this.typeBUltrasonicExcep = typeBUltrasonicExcep;
    }
    public String getImmersionFoot() {
        return immersionFoot;
    }
    public void setImmersionFoot(String immersionFoot) {
        this.immersionFoot = immersionFoot;
    }
    public String getRenalOthersStr() {
        return renalOthersStr;
    }
    public void setRenalOthersStr(String renalOthersStr) {
        this.renalOthersStr = renalOthersStr;
    }
    public String getBeginDrinkAge() {
        return beginDrinkAge;
    }
    public void setBeginDrinkAge(String beginDrinkAge) {
        this.beginDrinkAge = beginDrinkAge;
    }
    public String getSymptomNauseaVomiting() {
        return symptomNauseaVomiting;
    }
    public void setSymptomNauseaVomiting(String symptomNauseaVomiting) {
        this.symptomNauseaVomiting = symptomNauseaVomiting;
    }
    public String getCorporeityGentle() {
        return corporeityGentle;
    }
    public void setCorporeityGentle(String corporeityGentle) {
        this.corporeityGentle = corporeityGentle;
    }
    public String getCorporeityDampHeat() {
        return corporeityDampHeat;
    }
    public void setCorporeityDampHeat(String corporeityDampHeat) {
        this.corporeityDampHeat = corporeityDampHeat;
    }
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    public String getVagina() {
        return vagina;
    }
    public void setVagina(String vagina) {
        this.vagina = vagina;
    }
    public String getHeartAnginaPectoris() {
        return heartAnginaPectoris;
    }
    public void setHeartAnginaPectoris(String heartAnginaPectoris) {
        this.heartAnginaPectoris = heartAnginaPectoris;
    }
    public String getUrineSugar() {
        return urineSugar;
    }
    public void setUrineSugar(String urineSugar) {
        this.urineSugar = urineSugar;
    }
    public String getPoisonRadiogenIspre() {
        return poisonRadiogenIspre;
    }
    public void setPoisonRadiogenIspre(String poisonRadiogenIspre) {
        this.poisonRadiogenIspre = poisonRadiogenIspre;
    }
    public String getDrinkWhiteSpirits() {
        return drinkWhiteSpirits;
    }
    public void setDrinkWhiteSpirits(String drinkWhiteSpirits) {
        this.drinkWhiteSpirits = drinkWhiteSpirits;
    }
    public String getBloodPressureRigthU() {
        return bloodPressureRigthU;
    }
    public void setBloodPressureRigthU(String bloodPressureRigthU) {
        this.bloodPressureRigthU = bloodPressureRigthU;
    }
    public String getLiverFunctionAlbumin() {
        return liverFunctionAlbumin;
    }
    public void setLiverFunctionAlbumin(String liverFunctionAlbumin) {
        this.liverFunctionAlbumin = liverFunctionAlbumin;
    }
    public String getVisionLeftEye() {
        return visionLeftEye;
    }
    public void setVisionLeftEye(String visionLeftEye) {
        this.visionLeftEye = visionLeftEye;
    }
    public String getStraightenVisionLeftEye() {
        return straightenVisionLeftEye;
    }
    public void setStraightenVisionLeftEye(String straightenVisionLeftEye) {
        this.straightenVisionLeftEye = straightenVisionLeftEye;
    }
    public String getHeartRate() {
        return heartRate;
    }
    public void setHeartRate(String heartRate) {
        this.heartRate = heartRate;
    }
    public String getSymptomPolydipsia() {
        return symptomPolydipsia;
    }
    public void setSymptomPolydipsia(String symptomPolydipsia) {
        this.symptomPolydipsia = symptomPolydipsia;
    }
    public String getBloodPressureLeftU() {
        return bloodPressureLeftU;
    }
    public void setBloodPressureLeftU(String bloodPressureLeftU) {
        this.bloodPressureLeftU = bloodPressureLeftU;
    }
    public String getPhysicalExaminationOth() {
        return physicalExaminationOth;
    }
    public void setPhysicalExaminationOth(String physicalExaminationOth) {
        this.physicalExaminationOth = physicalExaminationOth;
    }
    public String getDailySmokingQuantity() {
        return dailySmokingQuantity;
    }
    public void setDailySmokingQuantity(String dailySmokingQuantity) {
        this.dailySmokingQuantity = dailySmokingQuantity;
    }
    public String getDrinkYellowWine() {
        return drinkYellowWine;
    }
    public void setDrinkYellowWine(String drinkYellowWine) {
        this.drinkYellowWine = drinkYellowWine;
    }
    public String getDrinkBeer() {
        return drinkBeer;
    }
    public void setDrinkBeer(String drinkBeer) {
        this.drinkBeer = drinkBeer;
    }
    public String getEatHobbySalt() {
        return eatHobbySalt;
    }
    public void setEatHobbySalt(String eatHobbySalt) {
        this.eatHobbySalt = eatHobbySalt;
    }
    public String getPharyngealportionAdd() {
        return pharyngealportionAdd;
    }
    public void setPharyngealportionAdd(String pharyngealportionAdd) {
        this.pharyngealportionAdd = pharyngealportionAdd;
    }
    public String getSymptomOtherStr() {
        return symptomOtherStr;
    }
    public void setSymptomOtherStr(String symptomOtherStr) {
        this.symptomOtherStr = symptomOtherStr;
    }
    public String getElderlySelfCare() {
        return elderlySelfCare;
    }
    public void setElderlySelfCare(String elderlySelfCare) {
        this.elderlySelfCare = elderlySelfCare;
    }
    public String getDentitiondentureDenture() {
        return dentitiondentureDenture;
    }
    public void setDentitiondentureDenture(String dentitiondentureDenture) {
        this.dentitiondentureDenture = dentitiondentureDenture;
    }
    public String getAngiosisOthersStr() {
        return angiosisOthersStr;
    }
    public void setAngiosisOthersStr(String angiosisOthersStr) {
        this.angiosisOthersStr = angiosisOthersStr;
    }
    public String getEyeDiseaseOthersStr() {
        return eyeDiseaseOthersStr;
    }
    public void setEyeDiseaseOthersStr(String eyeDiseaseOthersStr) {
        this.eyeDiseaseOthersStr = eyeDiseaseOthersStr;
    }
    public String getHazardQuitSmocking() {
        return hazardQuitSmocking;
    }
    public void setHazardQuitSmocking(String hazardQuitSmocking) {
        this.hazardQuitSmocking = hazardQuitSmocking;
    }
    public String getSymptomLackOfPower() {
        return symptomLackOfPower;
    }
    public void setSymptomLackOfPower(String symptomLackOfPower) {
        this.symptomLackOfPower = symptomLackOfPower;
    }
    public String getLymphNode() {
        return lymphNode;
    }
    public void setLymphNode(String lymphNode) {
        this.lymphNode = lymphNode;
    }
    public String getAngiosisOcclusionArteries() {
        return angiosisOcclusionArteries;
    }
    public void setAngiosisOcclusionArteries(String angiosisOcclusionArteries) {
        this.angiosisOcclusionArteries = angiosisOcclusionArteries;
    }
    public String getHemoglobin() {
        return hemoglobin;
    }
    public void setHemoglobin(String hemoglobin) {
        this.hemoglobin = hemoglobin;
    }
    public String getEyeDiseaseUndiscovered() {
        return eyeDiseaseUndiscovered;
    }
    public void setEyeDiseaseUndiscovered(String eyeDiseaseUndiscovered) {
        this.eyeDiseaseUndiscovered = eyeDiseaseUndiscovered;
    }
    public String getInsistHardeningTime() {
        return insistHardeningTime;
    }
    public void setInsistHardeningTime(String insistHardeningTime) {
        this.insistHardeningTime = insistHardeningTime;
    }
    public String getRenalUndiscovered() {
        return renalUndiscovered;
    }
    public void setRenalUndiscovered(String renalUndiscovered) {
        this.renalUndiscovered = renalUndiscovered;
    }
    public String getAttachment() {
        return attachment;
    }
    public void setAttachment(String attachment) {
        this.attachment = attachment;
    }
    public String getHealthGuidanceReview() {
        return healthGuidanceReview;
    }
    public void setHealthGuidanceReview(String healthGuidanceReview) {
        this.healthGuidanceReview = healthGuidanceReview;
    }
    public String getLiverFunctionSalt() {
        return liverFunctionSalt;
    }
    public void setLiverFunctionSalt(String liverFunctionSalt) {
        this.liverFunctionSalt = liverFunctionSalt;
    }
    public String getCvdTia() {
        return cvdTia;
    }
    public void setCvdTia(String cvdTia) {
        this.cvdTia = cvdTia;
    }
    public String getMedicalTime() {
        return medicalTime;
    }
    public void setMedicalTime(String medicalTime) {
        this.medicalTime = medicalTime;
    }
    public String getHazardFood() {
        return hazardFood;
    }
    public void setHazardFood(String hazardFood) {
        this.hazardFood = hazardFood;
    }
    public String getSymptomBlurredVision() {
        return symptomBlurredVision;
    }
    public void setSymptomBlurredVision(String symptomBlurredVision) {
        this.symptomBlurredVision = symptomBlurredVision;
    }
    public String getCorporeityPhlegmDamp() {
        return corporeityPhlegmDamp;
    }
    public void setCorporeityPhlegmDamp(String corporeityPhlegmDamp) {
        this.corporeityPhlegmDamp = corporeityPhlegmDamp;
    }
    public String getHazardLoseWeightTarget() {
        return hazardLoseWeightTarget;
    }
    public void setHazardLoseWeightTarget(String hazardLoseWeightTarget) {
        this.hazardLoseWeightTarget = hazardLoseWeightTarget;
    }
    public String getPoisonPhysicalIspre() {
        return poisonPhysicalIspre;
    }
    public void setPoisonPhysicalIspre(String poisonPhysicalIspre) {
        this.poisonPhysicalIspre = poisonPhysicalIspre;
    }
    public String getCorporeityHaemostasis() {
        return corporeityHaemostasis;
    }
    public void setCorporeityHaemostasis(String corporeityHaemostasis) {
        this.corporeityHaemostasis = corporeityHaemostasis;
    }
    public String getHeartCoronaryArtery() {
        return heartCoronaryArtery;
    }
    public void setHeartCoronaryArtery(String heartCoronaryArtery) {
        this.heartCoronaryArtery = heartCoronaryArtery;
    }
    public String getPoisonDust() {
        return poisonDust;
    }
    public void setPoisonDust(String poisonDust) {
        this.poisonDust = poisonDust;
    }
    public String getPharyngealportionNo() {
        return pharyngealportionNo;
    }
    public void setPharyngealportionNo(String pharyngealportionNo) {
        this.pharyngealportionNo = pharyngealportionNo;
    }
    public String getEatClitocybineEqualization() {
        return eatClitocybineEqualization;
    }
    public void setEatClitocybineEqualization(String eatClitocybineEqualization) {
        this.eatClitocybineEqualization = eatClitocybineEqualization;
    }
    public String getHeartMyocardialInfarction() {
        return heartMyocardialInfarction;
    }
    public void setHeartMyocardialInfarction(String heartMyocardialInfarction) {
        this.heartMyocardialInfarction = heartMyocardialInfarction;
    }
    public String getElectrocardiogramExcep() {
        return electrocardiogramExcep;
    }
    public void setElectrocardiogramExcep(String electrocardiogramExcep) {
        this.electrocardiogramExcep = electrocardiogramExcep;
    }
    public String getMedicalInfoId() {
        return medicalInfoId;
    }
    public void setMedicalInfoId(String medicalInfoId) {
        this.medicalInfoId = medicalInfoId;
    }
//    public List<String> getInhospitalList() {
//        return inhospitalList;
//    }
//
//    public void setInhospitalList(List<String> inhospitalList) {
//        this.inhospitalList = inhospitalList;
//    }
    public List<String> getFpList() {
        return fpList;
    }
    public void setFpList(List<String> fpList) {
        this.fpList = fpList;
    }
    public List<String> getExaminationList() {
        return examinationList;
    }
    public void setExaminationList(List<String> examinationList) {
        this.examinationList = examinationList;
    }
//    public List<String> getNiVaccinationList() {
//        return niVaccinationList;
//    }
//
//    public void setNiVaccinationList(List<String> niVaccinationList) {
//        this.niVaccinationList = niVaccinationList;
//    }
//    public String[] getDrugList() {
//        return drugList;
//    }
//
//    public void setDrugList(String[] drugList) {
//        this.drugList = drugList;
//    }
    public String getMedicalNo() {
        return medicalNo;
    }
    public void setMedicalNo(String medicalNo) {
        this.medicalNo = medicalNo;
    }
}

+ 44 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/vo/MedicalQvo.java

@ -0,0 +1,44 @@
package com.yihu.jw.hospital.module.health.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * @author suqinyi
 * @Date 2023/6/9
 */
@ApiModel(description = "查询Qvo")
public class MedicalQvo {
    @ApiModelProperty(value = "地区编码")
    private String areaCode;
    @ApiModelProperty(value = "patientId")
    private String patientId;
    @ApiModelProperty(value = "是否测试")
    private String g;
    public String getAreaCode() {
        return areaCode;
    }
    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode;
    }
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public String getG() {
        return g;
    }
    public void setG(String g) {
        this.g = g;
    }
}

+ 46 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/vo/MedicalVo.java

@ -0,0 +1,46 @@
package com.yihu.jw.hospital.module.health.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * @author suqinyi
 * @Date 2023/6/9
 */
@ApiModel(description = "体检vo")
public class MedicalVo {
    @ApiModelProperty(value = "机构名称", required = true, access = "response")
    private String orgName;
    @ApiModelProperty(value = "体检id", required = true, access = "response")
    private String medicalNo;
    @ApiModelProperty(value = "体检时间", required = true, access = "response")
    private String medicalTime;
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    public String getMedicalNo() {
        return medicalNo;
    }
    public void setMedicalNo(String medicalNo) {
        this.medicalNo = medicalNo;
    }
    public String getMedicalTime() {
        return medicalTime;
    }
    public void setMedicalTime(String medicalTime) {
        this.medicalTime = medicalTime;
    }
}

+ 2 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationInfoService.java

@ -1022,6 +1022,7 @@ public class RehabilitationInfoService {
     */
    public List<Map<String, Object>> getDetpAndDoctor(String doctorName, String deptCode, String deptName, String type, String disease) {
        List<Map<String, Object>> list = null;
        //疾病科室
        if ("1".equals(type)) {
            String sql = "SELECT  DISTINCT b.id 'diseaseId' ,b.`name` 'diseaseName',a.*  " +
                    "FROM " +
@ -1036,6 +1037,7 @@ public class RehabilitationInfoService {
            }
            list = jdbcTemplate.queryForList(sql);
        }
        //医生id,医生姓名
        if ("2".equals(type)) {
            String sql = "SELECT b.id 'doctorId',b.`name` 'doctorName' FROM base_doctor_hospital a  " +
                    "INNER JOIN base_doctor  b ON a.doctor_code=b.id  " +

+ 14 - 4
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationManageService.java

@ -14,6 +14,7 @@ import com.yihu.jw.entity.specialist.RehabilitationServiceItemDO;
import com.yihu.jw.entity.specialist.SpecialistPatientRelationDO;
import com.yihu.jw.entity.specialist.rehabilitation.*;
import com.yihu.jw.entity.util.TransforSqlUtl;
import com.yihu.jw.hospital.module.common.service.LabelService;
import com.yihu.jw.hospital.module.followup.dao.FollowUpDao;
import com.yihu.jw.hospital.module.followup.service.FollowUpService;
import com.yihu.jw.hospital.module.rehabilitation.dao.*;
@ -97,6 +98,8 @@ public class RehabilitationManageService {
    private FollowUpService followUpService;
    @Autowired
    private FollowUpDao followupDao;
    @Autowired
    private LabelService labelService;
    //近期康复记录
    public Envelop recentServiceItemPlanRecords(String patient, Integer page, Integer size) {
@ -173,6 +176,9 @@ public class RehabilitationManageService {
            infoDO.setStatus(7);
            rehabilitationPatientInfoDao.save(infoDO);
        }
        //添加专病标签
        labelService.addDiseaseLable(planDO1.getPatient(),planDO1.getDisease(),planDO1.getDiseaseName());
    }
    public List<ServiceItemPlanDO> addServicePlan(Map<String, String> serviceItemMap, PatientRehabilitationPlanDO planDO,
@ -3037,10 +3043,14 @@ public class RehabilitationManageService {
    public void cancelPlan(String orderId) {
        String sql = "select id from base_service_item_plan where relation_code='" + orderId + "'";
        String itemId = jdbcTemplate.queryForObject(sql, String.class);
        String updateSql = "update base_service_item_plan q set q.status='0' where id='" + itemId + "'";
        jdbcTemplate.execute(updateSql);
        System.out.println("执行sql==>" + updateSql);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        if (!list.isEmpty()){
            Map<String, Object> map = list.get(0);
            String updateSql = "update base_service_item_plan q set q.status='0' where id='" + map.get("id").toString() + "'";
            jdbcTemplate.execute(updateSql);
            System.out.println("执行sql==>" + updateSql);
        }
    }

+ 59 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/controller/DoctorFeldsherTemplateController.java

@ -0,0 +1,59 @@
package com.yihu.jw.hospital.module.template.controller;
import com.yihu.jw.hospital.module.common.BaseController;
import com.yihu.jw.hospital.module.template.service.DoctorFeldsherTemplateService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * 医生健康指导模板
 * <p>
 * Created by Reece on 2017/9/14.
 */
@RestController
@RequestMapping(value = "/doctor/feldsher")
@Api(description = "医生健康指导模板")
public class DoctorFeldsherTemplateController extends BaseController {
    @Autowired
    private DoctorFeldsherTemplateService feldsherTemplateService;
    /**
     * @param doctorCode   医生code
     * @param sessionId    会话Id
     * @param sessionType  会话类型
     * @param businessType 消息类型
     * @param from         发送者
     * @param content      消息内容
     * @return
     */
    @RequestMapping(value = "/sendDoctorTemplate", method = RequestMethod.GET)
    @ApiOperation(value = "医生助手给医生发送模板消息")
    public String sendDoctorTemplate(@RequestParam @ApiParam(value = "医生code") String doctorCode,
                                     @RequestParam @ApiParam(value = "会话Id", required = false) String sessionId,
                                     @RequestParam @ApiParam(value = "会话类型", required = false) String sessionType,
                                     @RequestParam @ApiParam(value = "消息类型") String businessType,
                                     @RequestParam @ApiParam(value = "发送者", required = false) String from,
                                     @RequestParam @ApiParam(value = "消息内容") String content) {
        try {
            Boolean flag = feldsherTemplateService.sendDoctorTemplate(doctorCode, sessionId, sessionType, businessType, from, content);
            if (flag){
                return write(200, "发送成功!");
            }else {
                return write( -1, "发送失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return invalidUserException(e, -1, "发送失败!");
        }
    }
}

+ 235 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/controller/DoctorGuidanceTempController.java

@ -0,0 +1,235 @@
package com.yihu.jw.hospital.module.template.controller;
import com.yihu.jw.entity.template.DoctorGuidanceTemp;
import com.yihu.jw.hospital.module.common.BaseController;
import com.yihu.jw.hospital.module.template.dao.DoctorGuidanceTempDao;
import com.yihu.jw.hospital.module.template.service.DoctorGuidanceTempService;
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.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
 * 医生健康指导模板
 * <p>
 * Created by lyr on 2017/2/3.
 */
@RestController
@RequestMapping(value = "/doctor/guidance_temp")
@Api(description = "医生健康指导模板")
public class DoctorGuidanceTempController extends BaseController {
    @Autowired
    DoctorGuidanceTempService guidanceTempService;
    @Autowired
    DoctorGuidanceTempDao guidanceTempDao;
    /**
     * 查询单个模板详情
     *
     * @return
     */
    @RequestMapping(value = "/listDetail", method = RequestMethod.GET)
    @ApiOperation(value = "查询单个模板详情")
    public String listDetail(@RequestParam @ApiParam(value = "指导模板编码") String modelCode) {
        JSONObject temp = null;
        try {
            temp = guidanceTempService.listDetail(modelCode);
        } catch (Exception e) {
            e.printStackTrace();
            return invalidUserException(e, -1, "查询失败!");
        }
        return write(200, "查询成功!", "data", temp);
    }
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation(value = "添加指导模板")
   
    public String add(@RequestParam @ApiParam(value = "指导内容") String content,
                      @RequestParam @ApiParam(value = "模板名称") String modelName,
                      @RequestParam(required = false) @ApiParam(value = "图片内容") String imagesUrl) {
        try {
            if (StringUtils.isEmpty(content)) {
                return error(-1, "内容不能为空");
            }
            if (modelName.length() < 1 || modelName.length() > 10) {
                return error(-1, "模板名称不能为空且在10字之内");
            }
            //        验证模板名称唯一性
            List<DoctorGuidanceTemp> templates = guidanceTempDao.findByTitle(getUID(), modelName);
            if (templates != null && templates.size() != 0) {
                return error(-1, "模板名称与现有模板重复,请修改");
            }
            DoctorGuidanceTemp temp = guidanceTempService.add(getUID(), content, modelName, imagesUrl);
            if (temp != null) {
                return write(200, "添加成功","modelCode",temp.getCode());
            } else {
                return write(-1, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
    /**
     * 修改指导模板
     *
     * @param code
     * @param content
     * @return
     */
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    @ApiOperation(value = "修改指导模板")
   
    public String modify(@RequestParam @ApiParam(value = "指导编码") String code,
                         @RequestParam @ApiParam(value = "模板标题") String modelName,
                         @RequestParam @ApiParam(value = "指导内容") String content,
                         @RequestParam(required = false) @ApiParam(value = "图片地址") String imagesUrl
    ) {
        try {
            if (StringUtils.isEmpty(code)) {
                return error(-1, "请指定需修改的模板");
            }
            if (StringUtils.isEmpty(content)) {
                return error(-1, "内容不能为空");
            }
            if (StringUtils.isEmpty(modelName) || modelName.length() > 10) {
                return error(-1, "内容10个汉字之内且不能为空");
            }
//            验证模板名称唯一性 还要去除掉其本身  (判断查出来的和要修改的同名)
            List<DoctorGuidanceTemp> templates = guidanceTempDao.findByTitle(getUID(), modelName);
            for (DoctorGuidanceTemp teamplate : templates) {
                if (!code.equals(teamplate.getCode())) {
//                        不是修改同一个模板
                    return error(-1, "模板名称与现有模板重复,请修改");
                }
            }
            DoctorGuidanceTemp temp = guidanceTempService.modify(code, modelName, content, imagesUrl);
            if (temp != null) {
                return write(200, "修改成功");
            } else {
                return write(-1, "修改失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "修改失败");
        }
    }
    /**
     * 删除指导模板
     *
     * @param code
     * @return
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ApiOperation(value = "删除指导模板")
   
    public String delete(@RequestParam @ApiParam(value = "指导编码") String code) {
        try {
            if (StringUtils.isEmpty(code)) {
                return error(-1, "请指定需删除的模板");
            }
            int result = guidanceTempService.delete(code);
            if (result == 1) {
                return write(200, "删除成功");
            } else {
                return write(-1, "删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "删除失败");
        }
    }
    /**
     * 查询指导模板
     *
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation(value = "查询指导模板")
    public String list(
                       @RequestParam(required = false, defaultValue = "")
                       @ApiParam(value = "搜索关键字") String filter,
                       @RequestParam(required = false, defaultValue = "")
                       @ApiParam(value = "模板类型 1:系统 2:自定义 为空:所有") String type,
                       @RequestParam(defaultValue = "10") String pageSize,
                       @RequestParam(defaultValue = "1") @ApiParam(value = "当前页码") String pageNo) {
        try {
            int pagesize = Integer.parseInt(pageSize);
            int pageno = Integer.parseInt(pageNo) - 1;
            List<Map<String, Object>> temps = guidanceTempService.list(getUID(),filter, type, pagesize, pageno);
            if (temps == null || temps.size() < 1) {
                return write(200, "查询成功", "data", new JSONArray());
            } else {
                return write(200, "查询成功", "data", new JSONArray(temps));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 根据模板类型、文章标题模糊搜索指导模板
     * (自定义即个人模板)
     * @param filter  搜索关键字
     * @param type  模板类型
     * @param type  teamId
     * @param pageSize 页展示数量
     * @param pageNo  当前页码
     * @return
     */
    @RequestMapping(value = "/search", method = RequestMethod.GET)
    @ApiOperation(value = "模糊搜索指导模板")
    public String searchByTitle(
                        @RequestParam(required = true, defaultValue = "")
                        @ApiParam(value = "搜索关键字") String filter,
                        @RequestParam(required = true, defaultValue = "")
                        @ApiParam(value = "模板类型 1:系统 2:个人 3:团队摸版") String type,
                        @RequestParam(defaultValue = "10")
                        @ApiParam(value = "页展示数量") String pageSize,
                        @RequestParam(defaultValue = "1") @ApiParam(value = "当前页码") String pageNo) {
        try {
            int pagesize = Integer.parseInt(pageSize);
            int pageno = Integer.parseInt(pageNo) - 1;
            List<Map<String, Object>> temps = null;
            if (StringUtils.isNotEmpty(type) && StringUtils.isNotEmpty(filter)){
                temps = guidanceTempService.listByTitle(filter,type,pagesize, pageno);
            }else {
                return error(-1, "模板类型不能为空!");
            }
            if (temps == null || temps.size() < 1) {
                return write(200, "查询成功!", "data", new JSONArray());
            } else {
                return write(200, "查询成功!", "data", new JSONArray(temps));
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
}

+ 131 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/controller/DoctorGuidanceTempLabelController.java

@ -0,0 +1,131 @@
package com.yihu.jw.hospital.module.template.controller;
import com.yihu.jw.entity.template.DoctorGuidanceTempLabel;
import com.yihu.jw.hospital.module.common.BaseController;
import com.yihu.jw.hospital.module.template.dao.DoctorGuidanceTempLabelDao;
import com.yihu.jw.hospital.module.template.service.DoctorGuidanceTempLableService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * Created by 刘文彬 on 2018/5/18.
 */
@RestController
@RequestMapping(value = "/doctor/guidance_temp/lable")
@Api(description = "医生健康指导模板标签")
public class DoctorGuidanceTempLabelController extends BaseController {
    @Autowired
    private DoctorGuidanceTempLableService doctorGuidanceTempLableService;
    @Autowired
    private DoctorGuidanceTempLabelDao doctorGuidanceTempLableDao;
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation(value = "添加指导模板标签")
    
    public String save(@ApiParam(name = "name", value = "标签名称", required = true)
                        @RequestParam(value = "name", required = true) String name,
                        @ApiParam(name = "teamId", value = "医生团队id", required = true)
                        @RequestParam(value = "teamId", required = true) Integer teamId){
        try{
            DoctorGuidanceTempLabel doctorGuidanceTempLabel = doctorGuidanceTempLableDao.findByNameWithDel(teamId,name);
            if(doctorGuidanceTempLabel!=null){
                return error(-1,"标签名称已存在!");
            }
            DoctorGuidanceTempLabel doctorGuidanceTempLable = doctorGuidanceTempLableService.save(getUID(),name,teamId);
            if(doctorGuidanceTempLable!=null){
                return write(200,"保存标签成功!","data",doctorGuidanceTempLable);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"保存标签失败!");
        }
        return error(-1,"保存标签失败!");
    }
    @RequestMapping(value = "/findAllList", method = RequestMethod.GET)
    @ApiOperation(value = "根据团队id获取标签")
    
    public String findAllList(@ApiParam(name = "teamId", value = "医生团队id", required = true)
                               @RequestParam(value = "teamId", required = true) Integer teamId){
        try{
            List<DoctorGuidanceTempLabel> list = doctorGuidanceTempLableService.findByDoctorCode(teamId);
            if (list == null || list.size() < 1) {
                return write(200, "查询成功!");
            } else {
                return write(200, "查询成功!", "data", list);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "/findAllListByPage", method = RequestMethod.GET)
    @ApiOperation(value = "根据团队id获取标签(分页)")
    public String findAllListByPage(@ApiParam(name = "pageSize", value = "每页总数", required = true)
                              @RequestParam(value = "pageSize", required = true,defaultValue = "10") int pageSize,
                              @ApiParam(name = "pageNo", value = "当前页", required = true)
                              @RequestParam(value = "pageNo", required = true,defaultValue = "1") int pageNo,
                              @ApiParam(name = "teamId", value = "医生团队id", required = true)
                              @RequestParam(value = "teamId", required = true) Integer teamId){
        try{
            List<DoctorGuidanceTempLabel> list = doctorGuidanceTempLableService.findByDoctorCode(teamId, pageSize, pageNo);
            if (list == null || list.size() < 1) {
                return write(200, "查询成功!");
            } else {
                return write(200, "查询成功!", "data", list);
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "/deleteLabel", method = RequestMethod.POST)
    @ApiOperation(value = "删除健康指导模板标签")
    
    public String deleteLabel(@ApiParam(name = "code", value = "标签code", required = true)
                              @RequestParam(value = "code", required = true) String code){
        try {
            boolean b = doctorGuidanceTempLableService.delete(code);
            if(b){
                return success("删除成功!");
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"删除成功!");
        }
        return error(-1,"删除成功!");
    }
    @RequestMapping(value = "/updateLabel", method = RequestMethod.POST)
    @ApiOperation(value = "修改健康指导模板标签")
    
    public String updateLabel(@ApiParam(name = "code", value = "标签code", required = true)
                              @RequestParam(value = "code", required = true) String code,
                              @ApiParam(name = "name", value = "标签名称", required = true)
                              @RequestParam(value = "name", required = true) String name){
        try {
            boolean b = doctorGuidanceTempLableService.updateName(code,name);
            if(b){
                return success("修改成功!");
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"修改失败!");
        }
        return error(-1,"修改失败!");
    }
}

+ 202 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/controller/DoctorRegistrationTempController.java

@ -0,0 +1,202 @@
package com.yihu.jw.hospital.module.template.controller;
import com.yihu.jw.entity.door.DoctorRegistration;
import com.yihu.jw.entity.door.DoctorRegistrationTemp;
import com.yihu.jw.hospital.module.common.BaseController;
import com.yihu.jw.hospital.module.door.dao.DoctorRegistrationTempDao;
import com.yihu.jw.hospital.module.door.service.DoctorRegistrationTempService;
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.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 医生登记服务模板
 * Created by wangpeiqiang on 2019/3/12.
 */
@RestController
@RequestMapping(value = "/doctor/registration_temp")
@Api(description = "医生登记服务模板")
public class DoctorRegistrationTempController extends BaseController {
    @Autowired
    DoctorRegistrationTempDao doctorRegistrationTempDao;
    @Autowired
    DoctorRegistrationTempService doctorRegistrationTempService;
    @RequestMapping(value = "/getRegistrationTempData", method = RequestMethod.GET)
    @ApiOperation(value = "查询模板分类列表")
    public String getRegistrationTempData(@RequestParam(required = false, defaultValue = "")
                                          @ApiParam(value = "搜索关键字") String filter) {
        try {
            Map<String, Object> map = new HashMap<String, Object>();
            List<Map<String, Object>> registrationTemp = this.doctorRegistrationTempService.getRegistrationTempData(filter);
            map.put("registrationTemp", registrationTemp);
            if (map == null || map.size() < 1) {
                return write(200, "查询成功!");
            } else {
                return write(200, "查询成功!", "data", map);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getListByDoctorCode", method = RequestMethod.GET)
    @ApiOperation(value = "根据医生code查询模板分类列表")
    public String getListByDoctorCode(@RequestParam(required = false, defaultValue = "")
                                      @ApiParam(value = "搜索关键字") String filter) {
        try {
            Map<String, Object> map = new HashMap<String, Object>();
            List<Map<String, Object>> allList = this.doctorRegistrationTempService.getListByDoctorCode(getUID(), filter);
            map.put("allList", allList);
            if (map == null || map.size() < 1) {
                return write(200, "查询成功!");
            } else {
                return write(200, "查询成功!", "data", map);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
    /**
     * 查询单个模板详情
     *
     * @return
     */
    @RequestMapping(value = "/listDetail", method = RequestMethod.GET)
    @ApiOperation(value = "查询单个模板详情")
    public String listDetail(@RequestParam @ApiParam(value = "登记服务模板编码") String modelCode) {
        JSONObject temp = null;
        try {
            temp = doctorRegistrationTempService.listDetail(modelCode);
        } catch (Exception e) {
            e.printStackTrace();
            return invalidUserException(e, -1, "查询失败!");
        }
        return write(200, "查询成功!", "data", temp);
    }
    @RequestMapping(value = "/findAllRegistrationList", method = RequestMethod.GET)
    @ApiOperation(value = "查询所有一级模板列表")
    public String findAllList() {
        try {
            List<DoctorRegistration> list = doctorRegistrationTempService.findAllRegistrationList();
            if (list == null || list.size() < 1) {
                return write(200, "查询成功!");
            } else {
                return write(200, "查询成功!", "data", list);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation(value = "添加登记服务模板")
    public String add(
            @ApiParam(name = "content", value = "内容", required = true)
            @RequestParam(value = "content", required = true) String content,
            @ApiParam(name = "registration", value = "一级模板Code", required = true)
            @RequestParam(value = "registration", required = true) String registration) {
        try {
            if (StringUtils.isEmpty(content)) {
                return error(-1, "内容不能为空");
            }
            if (StringUtils.isEmpty(registration)) {
                return error(-1, "一级模板code不能为空");
            }
            DoctorRegistrationTemp temp = doctorRegistrationTempService.add(getUID(), content, registration);
            if (temp != null) {
                return write(200, "添加成功", "data", temp);
            } else {
                return write(-1, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
    /**
     * 修改登记服务模板
     *
     * @param code
     * @param content
     * @return
     */
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    @ApiOperation(value = "修改登记服务模板")
    public String modify(@RequestParam @ApiParam(value = "登记服务编码") String code,
                         @RequestParam @ApiParam(value = "内容") String content
    ) {
        try {
            if (StringUtils.isEmpty(code)) {
                return error(-1, "请指定需修改的模板");
            }
            if (StringUtils.isEmpty(content)) {
                return error(-1, "内容不能为空");
            }
            DoctorRegistrationTemp temp = doctorRegistrationTempService.modify(code, content);
            if (temp != null) {
                return write(200, "修改成功");
            } else {
                return write(-1, "修改失败");
            }
        }  catch (Exception e) {
            e.printStackTrace();
            return error(-1, "修改失败");
        }
    }
    /**
     * 删除登记服务模板
     *
     * @param code
     * @return
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ApiOperation(value = "删除登记服务模板")
    public String delete(@RequestParam @ApiParam(value = "登记服务编码") String code) {
        try {
            if (StringUtils.isEmpty(code)) {
                return error(-1, "请指定需删除的模板");
            }
            int result = doctorRegistrationTempService.delete(code);
            if (result == 1) {
                return write(200, "删除成功");
            } else {
                return write(-1, "删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "删除失败");
        }
    }
}

+ 323 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/controller/DoctorTeamGuidanceController.java

@ -0,0 +1,323 @@
package com.yihu.jw.hospital.module.template.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.template.DoctorGuidanceTemp;
import com.yihu.jw.entity.template.DoctorTeamGuidanceTemplate;
import com.yihu.jw.hospital.module.common.BaseController;
import com.yihu.jw.hospital.module.template.dao.DoctorGuidanceTempDao;
import com.yihu.jw.hospital.module.template.service.DoctorTeamGuidanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
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;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * 医生端、后端团队指导模板控制类
 */
@Controller
@RequestMapping(value = "/doctor/team/guidance", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端&后端团队指导模板")
public class DoctorTeamGuidanceController extends BaseController {
    @Autowired
    private DoctorTeamGuidanceService doctorTeamGuidanceService;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    DoctorGuidanceTempDao guidanceTempDao;
    /**
     * 获取医生所属的所有团队
     *
     * @return
     */
//    @RequestMapping(value = "/getDoctorTeams", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation("获取医生所属的所有团队")
//    public String getHealthIndexHistory(@RequestParam(required = false, defaultValue = "") @ApiParam(value = "搜索关键字") String filter) {
//        try {
//            String doctorCode = getUID();
//            List teamList = doctorTeamGuidanceService.getDoctorTeams(doctorCode,filter);
//            return write(200, "获取医生所属团队成功!", "teamList", teamList);
//        } catch (Exception e) {
//            return invalidUserException(e, -1, e.getMessage());
//        }
//    }
    /**
     * 获取医生所属的所有团队
     *
     * @return
     */
//    @RequestMapping(value = "/findDoctorLeaderTeam", method = RequestMethod.GET)
//    @ResponseBody
//    @ApiOperation("获取团队长所属的团队长团队")
//    public String findDoctorLeaderTeam(@RequestParam(required = false, defaultValue = "") @ApiParam(value = "搜索关键字") String filter) {
//        try {
//            String doctorCode = getUID();
//            List teamList = doctorTeamGuidanceService.findDoctorLeaderTeam(doctorCode,filter);
//            return write(200, "获取医生所属团队成功!", "teamList", teamList);
//        } catch (Exception e) {
//            return invalidUserException(e, -1, e.getMessage());
//        }
//    }
    /**
     * 根据医生所属的单个团队获取团队模板列表
     *
     * @param teamId
     * @return
     */
    @RequestMapping(value = "/getTeamGuidanceList", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取单个团队模板列表")
    public String getTeamGuidanceList(
                                      @RequestParam(required = false, defaultValue = "")
                                      @ApiParam(value = "搜索关键字") String filter,
                                      @RequestParam(required = false, defaultValue = "")
                                      @ApiParam(value = "团队ID") Integer teamId,
                                      @RequestParam int pageNo,
                                      @RequestParam int pageSize) {
        try {
            List list = doctorTeamGuidanceService.getTeamGuidanceList(getUID(),filter,teamId, pageNo - 1, pageSize);
            return write(200, "获取团队模板列表成功!", "templateList", list);
        } catch (Exception e) {
            return invalidUserException(e, -1, e.getMessage());
        }
    }
    /**
     * 根据团队模板编码获取单个模板详情
     *
     * @return
     */
    @RequestMapping(value = "/getTeamGuidanceDetail", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取单个模板详情")
    public String getTeamGuidanceDetail(
            @ApiParam(value = "团队编码")
            @RequestParam int teamId,
            @ApiParam(value = "团队模板编码")
            @RequestParam String teamTemplateCode) {
        try {
            JSONObject guidanceDetail = doctorTeamGuidanceService.getTeamGuidanceDetail(teamId, teamTemplateCode);
            return write(200, "获取模板详情成功!", "guidanceDetail", guidanceDetail);
        } catch (Exception e) {
            return invalidUserException(e, -1, e.getMessage());
        }
    }
    /**
     * 新增团队模板
     *
     * @param title    模板标题要排重,团队内不可重复
     * @param teamInfo 该模板所属的团队ID及名称 可能会有多个
     * @param content  模板内容,前端限10000,后端无限制
     * @param images   多图以,分隔,取值1-9图,
     * @return
     */
    @RequestMapping(value = "/saveTeamGuidance", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("新增团队模板")
    
    public String saveTeamGuidance(
            @ApiParam(value = "团队模板标题")
            @RequestParam String title,
            @ApiParam(value = "所属团队ID及名称json串", defaultValue = "[{\"teamName\":\"一农\",\"teamId\":212},{\"teamName\":\"一\",\"teamId\":21}]")
            @RequestParam String teamInfo,
            @ApiParam(value = "模板内容")
            @RequestParam String content,
            @ApiParam(value = "图片路径")
            @RequestParam(required = false) String images,
            @ApiParam(value = "指导标签")
            @RequestParam(required = false,defaultValue = "") String labelCode
    ) {
        try {
//            前端参数校验
            String doctor = getUID();
            JSONArray teams = new JSONArray(teamInfo);
            String guidanceCode = doctorTeamGuidanceService.saveTeamGuidance(doctor, title, teams, content, images,labelCode);
            return write(200, "保存团队模板成功!","guidanceCode",guidanceCode);
        }catch (Exception e) {
            return invalidUserException(e, -1, e.getMessage());
        }
    }
    /**
     * 修改团队模板
     *
     * @param saveAsGuidance 团队模板是否保存为个人模板 0否 1是
     * @param title          模板标题要排重,团队内不可重复
     * @param teamInfo       该模板所属的团队ID及名称 可能会有多个
     * @param content        模板内容,前端限10000,后端无限制
     * @param images         多图以,分隔,取值0-9图,
     * @return
     */
    @RequestMapping(value = "/modifyTeamGuidance", method = RequestMethod.POST)
    @ResponseBody
    
    @ApiOperation("修改团队模板")
    public String modifyTeamGuidance(
            @ApiParam(value = "团队模板团队模板是否保存为个人模板", defaultValue = "0")
            @RequestParam int saveAsGuidance,
            @ApiParam(value = "要修改的团队模板编号")
            @RequestParam String guidanceCode,
            @ApiParam(value = "团队模板标题")
            @RequestParam String title,
            @ApiParam(value = "所属团队ID及名称json串", defaultValue = "[{\"teamName\":\"一农\",\"teamId\":212},{\"teamName\":\"一\",\"teamId\":21}]")
            @RequestParam String teamInfo,
            @ApiParam(value = "模板内容")
            @RequestParam String content,
            @ApiParam(value = "是否团队长")
            @RequestParam String isLeader,
            @ApiParam(value = "图片路径")
            @RequestParam(required = false) String images,
            @ApiParam(value = "指导标签")
            @RequestParam(required = false,defaultValue = "") String labelCode) {
        try {
//            新增修改权限,只有创建者和团队长才能修改
            String result = "";
            Boolean isRepeat = false;
            String doctor = getUID();
            List<DoctorGuidanceTemp> templates = guidanceTempDao.findByTitle(doctor, title);
            if (templates != null && templates.size() != 0) {
                isRepeat = true;
                result = "个人模板标题重复";
            }
            JSONArray teams = new JSONArray(teamInfo);
            doctorTeamGuidanceService.modifyTeamGuidance(doctor, isLeader, saveAsGuidance, isRepeat, guidanceCode, title, teams, content, images,labelCode);
            String str = "";
            return write(200, "修改团队模板成功!", "result", result);
        } catch (Exception e) {
            return invalidUserException(e, -1, e.getMessage());
        }
    }
    /**
     * 删除团队所属的团队模板
     *
     * @param deleteAll    0否 1是
     * @param teamId
     * @param guidanceCode
     * @return
     */
    @RequestMapping(value = "/deleteTeamGuidance", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("删除团队所属的团队模板")
    
    public String deleteTeamGuidance(
            @ApiParam(value = "是否删除存在该模板的所有团队") @RequestParam int deleteAll,
            @ApiParam(value = "团队ID") @RequestParam(required = false) Integer teamId,
            @ApiParam(value = "团队模板编码") @RequestParam String guidanceCode
    ) {
        try {
            String doctor = getUID();
            doctorTeamGuidanceService.deleteTeamGuidance(doctor, deleteAll, teamId, guidanceCode);
            return write(200, "删除模板成功!");
        } catch (Exception e) {
            return invalidUserException(e, -1, e.getMessage());
        }
    }
    /**
     * 发送团队模板给居民
     *
     * @param patient
     * @param content
     * @param guidanceCode
     * @param images
     * @return
     */
//    @RequestMapping(value = "/sendTeamGuidance", method = RequestMethod.POST)
//    @ResponseBody
//    @ApiOperation("发送团队模板给居民")
//    public String sendTeamGuidance(
//            @ApiParam(value = "要发送的居民code") @RequestParam String patient,
//            @ApiParam(value = "团队模板内容") @RequestParam String content,
//            @ApiParam(value = "团队id") @RequestParam String teamId,
//            @ApiParam(value = "团队模板code") @RequestParam String guidanceCode,
//            @ApiParam(value = "团队模板图片") @RequestParam(required = false) String images,
//            @ApiParam(value = "异常指标数据的ids,多条用逗号分割") @RequestParam(required = false) String tzCode
//    ) {
//        try {
//            String accessToken = getAccessToken();
//            String doctor = getUID();
//            JSONArray teams = new JSONArray(teamId);
//            List<PatientHealthGuidance> list = new ArrayList<>();
//            for (Object team : teams) {
//                JSONObject teamJson = new JSONObject(team.toString());
//                int teamCode = teamJson.getInt("teamId");
//                list.add(doctorTeamGuidanceService.sendTeamGuidance(accessToken, doctor, patient, content, guidanceCode, images,teamCode,tzCode));
//            }
//            PatientHealthGuidance p = null;
//            for(PatientHealthGuidance one:list){
//                if(one!=null){
//                    p=one;
//                    break;
//                }
//            }
//            JSONObject jsonObject = new JSONObject();
//            jsonObject.put("id",p.getId());
//            return write(200, "发送成功!","data",jsonObject);
//        } catch (Exception e) {
//            return invalidUserException(e, -1, e.getMessage());
//        }
//    }
    /**
     * 根据医生所属的单个团队获取团队模板标签列表
     *
     * @param teamId
     * @return
     */
    @RequestMapping(value = "/getTeamGuidanceLabelList", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("根据单个团队标签获取团队模板列表")
    public String getTeamGuidanceListByLabel(
            @RequestParam(required = true)
            @ApiParam(value = "团队ID") Integer teamId,
            @RequestParam(required = false)
            @ApiParam(value = "团队模板标签code") String labelCode,
            @RequestParam(value = "pageNo", required = true,defaultValue = "1") int pageNo,
            @RequestParam(value = "pageSize", required = true,defaultValue = "10") int pageSize) {
        try {
            List<DoctorTeamGuidanceTemplate> list = doctorTeamGuidanceService.getGuidanceByTeamIdAndLabelCode(teamId,labelCode, pageNo , pageSize);
            return write(200, "获取团队模板列表成功!", "data", list);
        } catch (Exception e) {
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "/getTeamGuidanceListByLabelWithFilter", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("根据单个团队标签过滤条件获取团队模板列表")
    public String getTeamGuidanceListByLabelWithFilter(@RequestParam(value = "teamId",required = true)
                                                        @ApiParam(value = "团队ID") Integer teamId,
                                                       @RequestParam(value = "filter",required = true)
                                                       @ApiParam(value = "过滤条件") String filter){
        try{
            Map<String,List<DoctorTeamGuidanceTemplate>> map = doctorTeamGuidanceService.getTeamGuidanceListByLabelWithFilter(teamId ,filter);
            return write(200, "查询成功!","data",map);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败!");
        }
    }
}

+ 47 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/dao/DoctorGuidanceTempDao.java

@ -0,0 +1,47 @@
package com.yihu.jw.hospital.module.template.dao;
import com.yihu.jw.entity.template.DoctorGuidanceTemp;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by lyr-pc on 2017/2/3.
 */
public interface DoctorGuidanceTempDao extends PagingAndSortingRepository<DoctorGuidanceTemp, Long> {
    DoctorGuidanceTemp findByCode(String code);
    int deleteByCode(String code);
    @Query("select t from DoctorGuidanceTemp t where t.owner = ?1 order by t.sendTimes desc ,t.createTime desc")
    Page<DoctorGuidanceTemp> findByOwner(String owner, Pageable pageRequest);
//    Page<List<DoctorGuidanceTemp>> findByOwner(String owner, Pageable pageRequest);
    @Query("select t from DoctorGuidanceTemp t where t.owner = ?1 or t.owner = 'system' order by t.sendTimes desc ,t.createTime desc")
    Page<DoctorGuidanceTemp> findByOwnerAndSystem(String owner, Pageable pageRequest);
    //    Page<List<DoctorGuidanceTemp>> findByOwnerAndSystem(String owner, Pageable pageRequest);
    //验证医生健康指导模板标题是否重复
    @Query("select t from DoctorGuidanceTemp t where t.owner = ?1 and t.modelName = ?2 ")
    List<DoctorGuidanceTemp> findByTitle(String owner, String title);
    //根据模板文章标题模糊搜索系统指导模板
    @Query(value = "select t from DoctorGuidanceTemp t where t.owner = 'system' and t.modelName like ?1 order by t.sendTimes desc ,t.createTime desc ")
    Page<DoctorGuidanceTemp> listByTileSystem(String filter, Pageable pageRequest);
    //根据模板文章标题模糊搜索个人指导模板
    @Query(value = "select t from DoctorGuidanceTemp t where t.owner != 'system' and t.modelName like ?1 order by t.sendTimes desc ,t.createTime desc ")
    Page<DoctorGuidanceTemp> listByTile(String filter, Pageable pageRequest);
    //根据模板文章标题模糊搜索个人指导模板
    @Query(value = "select t from DoctorGuidanceTemp t where t.owner = ?1 and t.modelName like ?2 order by t.sendTimes desc ,t.createTime desc ")
    Page<DoctorGuidanceTemp> listOwnerByTile(String owner, String filter, Pageable pageRequest);
    @Query("select t from DoctorGuidanceTemp t where (t.owner = 'system' or t.owner = ?1) and t.modelName like ?2 order by t.sendTimes desc ,t.createTime desc ")
    Page<DoctorGuidanceTemp> listByTileAll(String owner, String filter, Pageable pageRequest);
}

+ 38 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/dao/DoctorGuidanceTempLabelDao.java

@ -0,0 +1,38 @@
package com.yihu.jw.hospital.module.template.dao;
import com.yihu.jw.entity.template.DoctorGuidanceTempLabel;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by 刘文彬 on 2018/5/18.
 */
public interface DoctorGuidanceTempLabelDao extends PagingAndSortingRepository<DoctorGuidanceTempLabel, Long> {
    @Query("select t from DoctorGuidanceTempLabel t where t.teamId = ?1 and t.del=1")
    Page<DoctorGuidanceTempLabel> findByTeamId(Integer teamId, Pageable pageRequest);
    @Query("select t from DoctorGuidanceTempLabel t where t.teamId = ?1 and t.del=1 order by t.createTime desc ")
    List<DoctorGuidanceTempLabel> findByTeamId(Integer teamId);
    @Query("select t from DoctorGuidanceTempLabel t where t.teamId=?1 and  t.name = ?2 and t.del=1 ")
    DoctorGuidanceTempLabel findByNameWithDel(Integer teamId, String name);
    @Query("select t from DoctorGuidanceTempLabel t where t.code = ?1 ")
    DoctorGuidanceTempLabel findByCode(String code);
    @Modifying
    @Query(value = "update DoctorGuidanceTempLabel p set p.del=?1 where p.code=?2 ")
    int updateDel(int del, String code);
    @Modifying
    @Query(value = "update DoctorGuidanceTempLabel p set p.name=?1 where p.code=?2 ")
    int updateName(String name, String code);
}

+ 22 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/dao/DoctorTeamGuidanceDetailDao.java

@ -0,0 +1,22 @@
package com.yihu.jw.hospital.module.template.dao;
import com.yihu.jw.entity.template.DoctorTeamGuidanceDetail;
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;
/**
 * Created by Reece on 2017/6/8.
 */
public interface DoctorTeamGuidanceDetailDao extends PagingAndSortingRepository<DoctorTeamGuidanceDetail, Long>, JpaSpecificationExecutor<DoctorTeamGuidanceDetail> {
    //根据模板编码获取有效的模板详情
    @Query("select distinct t from DoctorTeamGuidanceDetail t,DoctorTeamGuidanceTemplate a where t.code = a.teamTemplateCode and a.del = 1 and t.code = ?1 ")
    DoctorTeamGuidanceDetail findGuidanceDetail(String guidanceCode);
    //根据模板编码更改模板详情
    @Modifying
    @Query("update DoctorTeamGuidanceDetail t set t.title = ?1,t.content = ?2,t.imagesUrl = ?3 where t.code = ?4 ")
    int modifyTeamGuidanceDetail(String title, String content, String image, String guidance);
}

+ 83 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/dao/DoctorTeamGuidanceTemplateDao.java

@ -0,0 +1,83 @@
package com.yihu.jw.hospital.module.template.dao;
import com.yihu.jw.entity.template.DoctorTeamGuidanceTemplate;
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 java.util.List;
/**
 * Created by Reece on 2017/6/8.
 */
public interface DoctorTeamGuidanceTemplateDao extends PagingAndSortingRepository<DoctorTeamGuidanceTemplate, Long>, JpaSpecificationExecutor<DoctorTeamGuidanceTemplate> {
    //    新增团队模板时团队内标题排重
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.title = ?1 and t.teamId = ?2 ")
    List<DoctorTeamGuidanceTemplate> distinctByTeamTitle(String title, int teamId);
    //    根据团队ID获取团队内的模板列表(带分页和创建时间倒序)
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.teamId = ?1 ")
    List<DoctorTeamGuidanceTemplate> findGuidanceByTeamId(int teamId, Pageable request);
    //    根据团队ID获取团队内的模板列表(带分页和创建时间倒序)
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.teamId = ?1 ")
    List<DoctorTeamGuidanceTemplate> countGuidanceByTeamId(int teamId);
    //    由模板编码获取拥有该模板的团队信息
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.teamTemplateCode = ?1 ")
    List<DoctorTeamGuidanceTemplate> getTeamsByGuidance(String guidanceCode);
    //    根据团队ID及模板编码删除团队所属的团队模板
    @Modifying
    @Query("update DoctorTeamGuidanceTemplate t set t.del = 0 where t.teamId = ?1 and t.teamTemplateCode =?2 ")
    int deleteTeamGuidance(int teamId, String guidanceCode);
    //  根据模板编码更改团队模板对应表
    @Modifying
    @Query("update DoctorTeamGuidanceTemplate t set t.title = ?3,t.labelCode=?4,t.labelName=?5 where t.del = 1 and t.teamId = ?1 and t.teamTemplateCode =?2 ")
    int modifyTeamGuidance(int teamId, String guidanceCode, String title, String labelCode, String labelName);
    //  每给居民发送一次团队指导,使用数量加1
    @Modifying
    @Query("update DoctorTeamGuidanceTemplate t set t.useTimes = t.useTimes+1 where t.del = 1 and t.teamId = ?1 and t.teamTemplateCode =?2 ")
    int countSend(int teamId, String guidanceCode);
    //  批量删除(失效)该模板所在的所有团队关系
    @Modifying
    @Query("update DoctorTeamGuidanceTemplate t set t.useTimes =  0 ,t.del = 0 where t.teamId = ?1 and t.teamTemplateCode =?2 ")
    int deleteByTeam(int teamId, String guidanceCode);
    // 根据模板文章标题模糊搜索团队指导模板
    @Query("SELECT b FROM DoctorTeamGuidanceDetail a, DoctorTeamGuidanceTemplate b WHERE a.code = b.teamTemplateCode  " +
            " AND b.del = 1 AND b.title LIKE ?1 order by b.useTimes desc ,b.createTime desc ")
    Page<DoctorTeamGuidanceTemplate> listByTile(String title, Pageable pageRequest);
    // 根据模板文章标题模糊搜索团队指导模板
    @Query("SELECT b FROM DoctorTeamGuidanceDetail a, DoctorTeamGuidanceTemplate b WHERE a.code = b.teamTemplateCode  " +
            " AND b.del = 1 AND b.teamId = ?1 AND b.title LIKE ?2 order by b.useTimes desc ,b.createTime desc ")
    List<DoctorTeamGuidanceTemplate> countTeamListByTile(int teamId, String title);
    // 根据模板文章标题模糊搜索团队指导模板
    @Query("SELECT b FROM DoctorTeamGuidanceDetail a, DoctorTeamGuidanceTemplate b WHERE a.code = b.teamTemplateCode  " +
            " AND b.del = 1  AND b.creater = ?1  AND b.title LIKE ?2 GROUP BY b.teamId order by b.useTimes desc ,b.createTime desc ")
    List<DoctorTeamGuidanceTemplate> countTeamListByTile(String doctor, String title);
    // 根据模板文章标题模糊搜索团队指导模板
    @Query("SELECT b FROM DoctorTeamGuidanceTemplate b ,DoctorTeamGuidanceDetail a WHERE a.code = b.teamTemplateCode  " +
            " AND b.del = 1 AND b.teamId = ?1 AND b.title LIKE ?2 ")
    List<DoctorTeamGuidanceTemplate> getListByTile(int teamId, String title, Pageable pageRequest);
    // 根据模板文章标题模糊搜索团队指导模板(不分页)
    @Query("SELECT b FROM DoctorTeamGuidanceTemplate b WHERE   " +
            " b.del = 1 AND b.teamId = ?1 AND b.title LIKE ?2 ")
    List<DoctorTeamGuidanceTemplate> getListByTile(int teamId, String title);
    //    根据团队ID获取团队内的模板列表(带分页和创建时间倒序)
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.teamId = ?1 and t.labelCode= ?2")
    List<DoctorTeamGuidanceTemplate> findGuidanceByTeamIdAndLabelCode(int teamId, String labelCode, Pageable request);
}

+ 140 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/service/DoctorFeldsherTemplateService.java

@ -0,0 +1,140 @@
package com.yihu.jw.hospital.module.template.service;
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.wechat.WechatTemplateConfig;
import com.yihu.jw.hospital.module.wx.dao.WechatTemplateConfigDao;
import com.yihu.jw.hospital.task.PushMsgTask;
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
import com.yihu.jw.hospital.utils.WeiXinOpenIdUtils;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * 医生助手相关模板消息
 * <p>
 * Created by Reece on 2017/9/7/007.
 */
@Service
@Transactional
public class DoctorFeldsherTemplateService {
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private ImUtil imUtill;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    private static final Logger logger = LoggerFactory.getLogger(DoctorFeldsherTemplateService.class);
    /**
     * 医生为居民设置监测方案后实时为居民推送信息变更通知消息提醒
     *
     * @param patient 居民code
     * @param url     带参数的跳转URL
     * @throws Exception
     */
    public void sendChangeTemplate(String patient, String url) throws Exception {
        BasePatientDO people = patientDao.findById(patient).orElse(null);
        String openId = people.getOpenid();
        String name = people.getName();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        JSONArray jsonArray = null;
        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_change", "jcfa");
        String first = templateConfig.getFirst();
        first = first.replace("key1", (name == null ? "" : name));
        String remark = templateConfig.getRemark();
        String keyword3 = templateConfig.getKeyword3();
        JSONObject sendJson = new JSONObject();
        /*String first = name + "您好,您的家庭医生已为您设置了血糖(血压)监测方案,请按照方案及时测量及上传您的体征数据。";
        String remark = "您可使用详情查看方案内容";*/
        sendJson.put("keyword1", name);
        sendJson.put("keyword2", dateFormat.format(new Date()));
//        sendJson.put("keyword3", "血糖(血压)监测方案");
        sendJson.put("keyword3", keyword3);
        sendJson.put("first", first);
        sendJson.put("remark", remark);
        sendJson.put("url", url);//带参数的模板跳转链接
        pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 10, openId, name, sendJson);
        //发送代理人
        jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
        if (jsonArray != null && jsonArray.length() > 0) {
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject j = jsonArray.getJSONObject(i);
                BasePatientDO member = (BasePatientDO) j.get("member");
                int start = url.indexOf("&toUser=");
                int end = url.indexOf("&", start + 1);
                String touser = url.substring(start, end);
                url = url.replace(touser, "&toUser=" + member.getId());
                //name患者姓名
                sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
                sendJson.put("url", url);
                pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 10, member.getOpenid(), name, sendJson);
            }
        }
        logger.info("sendJson: " + sendJson);
    }
    /**
     * 拼装医生助手 医生类模板消息并发送
     *
     * @param doctorCode   医生code
     * @param sessionId    会话Id
     * @param sessionType  会话类型
     * @param businessType 消息类型
     * @param from         发送者
     * @param content      消息内容
     * @return
     */
    public Boolean sendDoctorTemplate(String doctorCode, String sessionId, String sessionType, String businessType, String from, String content) {
        try {
            String remark = "请进入手机APP查看,如尚未安装APP请点击详情下载安装";
            String url = "www.baidu.com";
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
            JSONObject sendJson = new JSONObject();
            BaseDoctorDO doctor = doctorDao.findById(doctorCode).orElse(null);
            String doctorName = doctor.getName();
            String doctorOpenId = doctor.getOpenid();
            String first = businessType;
            sendJson.put("keyword1", content);
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url);//带参数的模板跳转链接
            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, doctorOpenId, doctorName, sendJson);
            logger.info("sendJson: " + sendJson);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}

+ 87 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/service/DoctorGuidanceTempLableService.java

@ -0,0 +1,87 @@
package com.yihu.jw.hospital.module.template.service;
import com.yihu.jw.entity.template.DoctorGuidanceTempLabel;
import com.yihu.jw.hospital.module.template.dao.DoctorGuidanceTempLabelDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
 * Created by 刘文彬 on 2018/5/18.
 */
@Service
public class DoctorGuidanceTempLableService  {
    @Autowired
    private DoctorGuidanceTempLabelDao doctorGuidanceTempLableDao;
    /**
     * 保存
     * @param doctorCode
     * @param name
     */
    @Transactional
    public DoctorGuidanceTempLabel save(String doctorCode, String name, Integer teamId)throws Exception{
        DoctorGuidanceTempLabel one = new DoctorGuidanceTempLabel();
        one.setCode(getCode());
        one.setCreateTime(new Date());
        one.setDoctorCode(doctorCode);
        one.setName(name);
        one.setTeamId(teamId);
        one.setDel(1);
        return doctorGuidanceTempLableDao.save(one);
    }
    public List<DoctorGuidanceTempLabel> findByDoctorCode(Integer teamId, int pageSize, int pageNo) throws Exception{
        Sort sort = Sort.by(Sort.Direction.DESC, "createTime");
        pageNo=pageNo-1;
        PageRequest pageRequest =  PageRequest.of(pageNo, pageSize,sort);
        Page<DoctorGuidanceTempLabel> page =  doctorGuidanceTempLableDao.findByTeamId(teamId,pageRequest);
        List<DoctorGuidanceTempLabel> newList = new ArrayList<>();
        if(pageNo==0){
            newList.add(0,new DoctorGuidanceTempLabel("","未分组"));
        }
        newList.addAll(page.getContent());
        return newList;
    }
    public List<DoctorGuidanceTempLabel> findByDoctorCode(Integer teamId) throws Exception{
        List<DoctorGuidanceTempLabel> list =  doctorGuidanceTempLableDao.findByTeamId(teamId);
        List<DoctorGuidanceTempLabel> newList = new ArrayList<>();
        newList.add(0,new DoctorGuidanceTempLabel("","未分组"));
        newList.addAll(list);
        return newList;
    }
    @Transactional
    public boolean delete(String code) throws Exception{
        int temp = doctorGuidanceTempLableDao.updateDel(0,code);
        if(temp>0){
            return true;
        }
        return false;
    }
    @Transactional
    public boolean updateName(String code,String name) throws Exception{
        int temp = doctorGuidanceTempLableDao.updateName(name,code);
        if(temp>0){
            return true;
        }
        return false;
    }
    public String getCode() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
}

+ 304 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/service/DoctorGuidanceTempService.java

@ -0,0 +1,304 @@
package com.yihu.jw.hospital.module.template.service;
import com.yihu.jw.entity.template.DoctorGuidanceTemp;
import com.yihu.jw.entity.template.DoctorTeamGuidanceTemplate;
import com.yihu.jw.hospital.module.template.dao.DoctorGuidanceTempDao;
import com.yihu.jw.hospital.module.template.dao.DoctorTeamGuidanceTemplateDao;
import com.yihu.jw.util.common.CommonUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * 医生健康指导模板
 * <p>
 * Created by lyr-pc on 2017/2/3.
 */
@Service
@Transactional
public class DoctorGuidanceTempService  {
    @Autowired
    DoctorGuidanceTempDao guidanceTempDao;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    private DoctorTeamGuidanceTemplateDao doctorTeamGuidanceTemplateDao;
    @Autowired
    private CommonUtil CommonUtil;
    /**
     * 记录医生健康指导模板使用次数
     *
     * @param modelCode 健康指导模板编码
     */
    public void countSend(String modelCode) {
        synchronized (this) {
            String sql = "UPDATE wlyy_doctor_guidance_temp  " +
                    "SET send_times=send_times+1 " +
                    "WHERE CODE=?";
            jdbcTemplate.update(sql, modelCode);
        }
    }
    /**
     * 查询单个指导模板详情
     *
     * @param modelCode
     * @return
     * @throws Exception
     */
    public JSONObject listDetail(String modelCode) throws Exception {
        String sql = "SELECT wdgt.`model_name`,wdgt.`content`,wdgt.`images_url`,wdgt.`create_time`,wdgt.`send_times` " +
                "FROM wlyy_doctor_guidance_temp wdgt " +
                "WHERE wdgt.`code`=?";
        Map temp = (Map) jdbcTemplate.queryForMap(sql, modelCode);
        String modelName = (String) temp.get("model_name");
        String content = (String) temp.get("content");
        String imagesUrl = (String) temp.get("images_url");
//        多图按逗号分割保存成数组
        String[] imagesArray = null;
        if (imagesUrl != null) {
            imagesArray = imagesUrl.split(",");
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date createTime = (Date) temp.get("create_time");
        String dateTime = sdf.format(createTime);
        String sendTimes = (String) temp.get("send_times").toString();
        JSONObject json = new JSONObject();
        json.put("modelName", modelName);
        json.put("content", content);
        json.put("imagesUrls", imagesArray);
        json.put("createTime", dateTime);
        json.put("sendTimes", sendTimes);
        return json;
    }
    /**
     * 添加指导模板
     *
     * @param doctor  医生
     * @param content 指导内容
     * @return
     */
    public DoctorGuidanceTemp add(String doctor, String content, String modelName, String imagesUrl) throws Exception{
        DoctorGuidanceTemp guidanceTemp = new DoctorGuidanceTemp();
        String imageUrls = "";
        String imageRow = "";
        guidanceTemp.setCode(getCode());
        guidanceTemp.setOwner(doctor);
        guidanceTemp.setContent(content);
        guidanceTemp.setSendTimes(0);
        guidanceTemp.setCreateTime(new Date());
        guidanceTemp.setModelName(modelName);
        if (StringUtils.isNotEmpty(imagesUrl)) {
            imagesUrl = CommonUtil.validateImages(imagesUrl);
        }
        guidanceTemp.setImagesUrl(imagesUrl);
        return guidanceTempDao.save(guidanceTemp);
    }
    /**
     * 修改指导模板
     *
     * @param code    模板编码
     * @param content 指导内容
     * @return
     */
    public DoctorGuidanceTemp modify(String code, String modelName, String content, String imagesUrl) throws Exception {
        DoctorGuidanceTemp guidanceTemp = guidanceTempDao.findByCode(code);
        String imageUrls = "";
        String imageRow = "";
        if (guidanceTemp == null) {
            throw new RuntimeException("模板不存在");
        }
        guidanceTemp.setModelName(modelName);
        guidanceTemp.setContent(content);
        if (imagesUrl == null || "".equals(imagesUrl)) {
            imagesUrl = null;
        } else {
            String[] images = imagesUrl.split(",");
            for (String image : images) {
                if (image.contains("group1")) {
                    imageUrls += image + ",";
                } else {
                    try {
                        imageRow += CommonUtil.copyTempImage(image) + ",";
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            imagesUrl = imageUrls + imageRow;
            imagesUrl = imagesUrl.substring(0, imagesUrl.length() - 1);
        }
        guidanceTemp.setImagesUrl(imagesUrl);
        return guidanceTempDao.save(guidanceTemp);
    }
    /**
     * 删除指导模板
     *
     * @param code 模板编码
     * @return
     */
    public int delete(String code) throws Exception {
        String[] codes = code.split(",");
        if (codes != null && codes.length > 0) {
            for (String temp : codes) {
                String sql = "SELECT t.owner FROM wlyy_doctor_guidance_temp t WHERE t.code=?";
                String owner = jdbcTemplate.queryForObject(sql, String.class, temp);
                if (!"system".equals(owner)) {
                    guidanceTempDao.deleteByCode(temp);
                }
            }
        }
        return 1;
    }
    /**
     * 查询指导模板
     *
     * @param doctor 医生
     * @param type   模板类型
     * @return
     */
    public List<Map<String, Object>> list(String doctor,String filter, String type, int pageSize, int pageNo) throws Exception {
        Page<DoctorGuidanceTemp> temps = null;
        PageRequest pageRequest =  PageRequest.of(pageNo, pageSize);
        List<Map<String, Object>> listMap = new ArrayList<>();
        if (StringUtils.isEmpty(filter)){
            if (type.equals("1")) {
                temps = guidanceTempDao.findByOwner("system", pageRequest);
            } else if (type.equals("2")) {
                temps = guidanceTempDao.findByOwner(doctor, pageRequest);
            } else {
                temps = guidanceTempDao.findByOwnerAndSystem(doctor, pageRequest);
            }
        }else {
            if (type.equals("1")) {
                temps = guidanceTempDao.listByTileSystem("%"+filter+"%", pageRequest);
            } else if (type.equals("2")) {
                temps = guidanceTempDao.listOwnerByTile(doctor,"%"+filter+"%", pageRequest);
            } else {
                temps = guidanceTempDao.listByTileAll(doctor,"%"+filter+"%", pageRequest);
            }
        }
        List<DoctorGuidanceTemp> list = temps.getContent();
        for (int i = 0; i < list.size(); i++) {
            DoctorGuidanceTemp dgt = list.get(i);
            Map<String, Object> tem = new HashMap<>();
            tem.put("code", dgt.getCode());
            tem.put("owner", dgt.getOwner());
            tem.put("sendTimes", dgt.getSendTimes());
            tem.put("lastTime", dgt.getLastTime());
            tem.put("modelName", dgt.getModelName());
            if(i == 0) {
                tem.put("total", temps.getTotalElements());
                tem.put("pages", temps.getTotalPages());
            }
            listMap.add(tem);
        }
        return listMap;
    }
    /**
     * 根据模板类型、文章标题模糊搜索指导模板
     *
     * @param filter 搜索关键字
     * @param type 1:系统 2:个人 3:团队摸版
     * @param pageSize
     * @param pageNo
     * @return
     * @throws Exception
     */
    public List<Map<String, Object>> listByTitle(String filter,String type, int pageSize, int pageNo) throws Exception {
        PageRequest pageRequest = PageRequest.of(pageNo, pageSize);
        List<Map<String, Object>> listMap = new ArrayList<>();
        if ("1".equals(type)) {
            Page<DoctorGuidanceTemp> temps = guidanceTempDao.listByTileSystem("%"+filter+"%", pageRequest);
            List<DoctorGuidanceTemp> list = temps.getContent();
            for (int i = 0; i < list.size(); i++) {
                DoctorGuidanceTemp dgt = list.get(i);
                Map<String, Object> tem = new HashMap<>();
                tem.put("code", dgt.getCode());
                tem.put("owner", dgt.getOwner());
                tem.put("sendTimes", dgt.getSendTimes());
                tem.put("lastTime", dgt.getLastTime());
                tem.put("modelName", dgt.getModelName());
                listMap.add(tem);
            }
        } else if ("2".equals(type)) {
            Page<DoctorGuidanceTemp> temps = guidanceTempDao.listByTile("%"+filter+"%", pageRequest);
            List<DoctorGuidanceTemp> list = temps.getContent();
            for (int i = 0; i < list.size(); i++) {
                DoctorGuidanceTemp dgt = list.get(i);
                Map<String, Object> tem = new HashMap<>();
                tem.put("code", dgt.getCode());
                tem.put("owner", dgt.getOwner());
                tem.put("sendTimes", dgt.getSendTimes());
                tem.put("lastTime", dgt.getLastTime());
                tem.put("modelName", dgt.getModelName());
                listMap.add(tem);
            }
        } else if("3".equals(type)){
            Page<DoctorTeamGuidanceTemplate> temps = doctorTeamGuidanceTemplateDao.listByTile("%"+filter+"%", pageRequest);
            List<DoctorTeamGuidanceTemplate> list = temps.getContent();
            for (int i = 0; i < list.size(); i++) {
                DoctorTeamGuidanceTemplate dgt = list.get(i);
                Map<String, Object> tem = new HashMap<>();
                tem.put("teamId", dgt.getTeamId());
                tem.put("teamName", dgt.getTeamName());
                tem.put("code", dgt.getTeamTemplateCode());
                tem.put("owner", dgt.getCreater());
                tem.put("sendTimes", dgt.getUseTimes());
                tem.put("lastTime", dgt.getCzrq());
                tem.put("modelName", dgt.getTitle());
                listMap.add(tem);
            }
        }
        return listMap;
    }
    /**
     * 根据code获取详情
     * @param code
     * @return
     */
    public DoctorGuidanceTemp findByCode(String code) {
        return guidanceTempDao.findByCode(code);
    }
    public String getCode() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
}

+ 560 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/template/service/DoctorTeamGuidanceService.java

@ -0,0 +1,560 @@
package com.yihu.jw.hospital.module.template.service;
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.PatientHealthGuidance;
import com.yihu.jw.entity.template.DoctorGuidanceTemp;
import com.yihu.jw.entity.template.DoctorGuidanceTempLabel;
import com.yihu.jw.entity.template.DoctorTeamGuidanceDetail;
import com.yihu.jw.entity.template.DoctorTeamGuidanceTemplate;
import com.yihu.jw.hospital.module.consult.service.ConsultService;
import com.yihu.jw.hospital.module.health.service.PatientHealthGuidanceService;
import com.yihu.jw.hospital.module.template.dao.DoctorGuidanceTempDao;
import com.yihu.jw.hospital.module.template.dao.DoctorGuidanceTempLabelDao;
import com.yihu.jw.hospital.module.template.dao.DoctorTeamGuidanceDetailDao;
import com.yihu.jw.hospital.module.template.dao.DoctorTeamGuidanceTemplateDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.CommonUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by Reece on 2017/6/8.
 */
@Service
@Transactional
public class DoctorTeamGuidanceService  {
    @Autowired
    private DoctorTeamGuidanceTemplateDao doctorTeamGuidanceTemplateDao;
    @Autowired
    private DoctorTeamGuidanceDetailDao doctorTeamGuidanceDetailDao;
    @Autowired
    private DoctorGuidanceTempDao doctorGuidanceTempDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BasePatientDao patientDao;
    
    @Autowired
    private ConsultService consultService;
    @Autowired
    DoctorGuidanceTempDao guidanceTempDao;
    @Autowired
    private CommonUtil CommonUtil;
    @Autowired
    private DoctorGuidanceTempLabelDao doctorGuidanceTempLableDao;
    
    @Autowired
    private PatientHealthGuidanceService patientHealthGuidanceService;
    /**
     * 新增团队指导模板
     *
     * @param title
     * @param teams
     * @param content
     * @param images
     */
    public String saveTeamGuidance(String doctor, String title, JSONArray teams, String content, String images, String labelCode) throws Exception {
        String templateCode = getCode();
        Date nowDate = new Date();
        //指导标签
        DoctorGuidanceTempLabel doctorGuidanceTempLable =  doctorGuidanceTempLableDao.findByCode(labelCode);
        String labelName = "未分组";
        if(doctorGuidanceTempLable!=null){
            labelName = doctorGuidanceTempLable.getName();
        }
        for (Object team : teams) {
            JSONObject teamJson = new JSONObject(team.toString());
            int teamId = teamJson.getInt("teamId");
            String teamName = teamJson.getString("teamName");
            //             团队内标题排重
            List<DoctorTeamGuidanceTemplate> teamGuidanceTemplates = doctorTeamGuidanceTemplateDao.distinctByTeamTitle(title, teamId);
            if (teamGuidanceTemplates.size() == 0) {
                DoctorTeamGuidanceTemplate doctorTeamGuidanceTemplate = new DoctorTeamGuidanceTemplate();
                doctorTeamGuidanceTemplate.setCreater(doctor);
                doctorTeamGuidanceTemplate.setCreateTime(nowDate);
                doctorTeamGuidanceTemplate.setCzrq(nowDate);
                doctorTeamGuidanceTemplate.setDel(1);
                doctorTeamGuidanceTemplate.setTeamId(teamId);
                doctorTeamGuidanceTemplate.setTeamName(teamName);
                doctorTeamGuidanceTemplate.setTitle(title);
                doctorTeamGuidanceTemplate.setTeamTemplateCode(templateCode);
                doctorTeamGuidanceTemplate.setUseTimes(0);
                doctorTeamGuidanceTemplate.setLabelCode(labelCode);
                doctorTeamGuidanceTemplate.setLabelName(labelName);
                doctorTeamGuidanceTemplateDao.save(doctorTeamGuidanceTemplate);
            } else {
                throw new RuntimeException(teamName + ":团队标题重复!");
            }
        }
//            团队内标题不重复保存到团队模板详情表团队模板表
        DoctorTeamGuidanceDetail doctorTeamGuidanceDetail = new DoctorTeamGuidanceDetail();
        doctorTeamGuidanceDetail.setCode(templateCode);
        doctorTeamGuidanceDetail.setTitle(title);
        doctorTeamGuidanceDetail.setCreater(doctor);
        doctorTeamGuidanceDetail.setContent(content);
        doctorTeamGuidanceDetail.setCreateTime(nowDate);
        doctorTeamGuidanceDetail.setCzrq(nowDate);
        doctorTeamGuidanceDetail.setImagesUrl(images);
        doctorTeamGuidanceDetailDao.save(doctorTeamGuidanceDetail);
        return templateCode;
    }
    /**
     * 修改团队模板
     *
     * @param guidanceCode
     * @param title
     * @param teams
     * @param content
     * @param images
     * @throws Exception
     */
    public void modifyTeamGuidance(String doctor, String isLeader, int saveAsGuidance, Boolean isRepeat , String guidanceCode, String title,
                                   JSONArray teams, String content, String images, String labelCode) throws Exception {
//        首先身份验证
        DoctorTeamGuidanceDetail guidanceDetail = doctorTeamGuidanceDetailDao.findGuidanceDetail(guidanceCode);
        String creater = guidanceDetail.getCreater();
        Date nowDate = new Date();
        DoctorGuidanceTempLabel doctorGuidanceTempLable =  doctorGuidanceTempLableDao.findByCode(labelCode);
        String labelName = "未分组";
        if(doctorGuidanceTempLable!=null){
            labelName = doctorGuidanceTempLable.getName();
        }
//        图片地址需要处理
        String image = "";
        if (StringUtils.isNotEmpty(images)) {
            image = validateImages(images);
        }
        if (saveAsGuidance == 1) {
            //      保存为个人模板 去除个人模板标题重复 个人模板重复和修改是分开的互不影响
            //        验证模板名称唯一性
            List<DoctorGuidanceTemp> templates = guidanceTempDao.findByTitle(doctor, title);
            DoctorGuidanceTemp doctorGuidanceTemp = new DoctorGuidanceTemp();
            if (!isRepeat) {
                doctorGuidanceTemp.setCode(getCode());
                doctorGuidanceTemp.setImagesUrl(image);
                doctorGuidanceTemp.setCreateTime(nowDate);
                doctorGuidanceTemp.setContent(content);
                doctorGuidanceTemp.setModelName(title);
                doctorGuidanceTemp.setOwner(doctor);
                doctorGuidanceTemp.setLastTime(nowDate);
                doctorGuidanceTemp.setSendTimes(1);
                doctorGuidanceTempDao.save(doctorGuidanceTemp);
            }
            if ((!doctor.equals(creater)) && (!"1".equals(isLeader))) {
                throw new RuntimeException("没有修改权限");
            }
            //                        数据库中拥有该模板的所有团队
            List<DoctorTeamGuidanceTemplate> teamIds = doctorTeamGuidanceTemplateDao.getTeamsByGuidance(guidanceCode);
            List teamList = new ArrayList();
            List tempTeams = new ArrayList();
            for (DoctorTeamGuidanceTemplate team : teamIds) {
                teamList.add(team.getTeamId());
            }
            for (Object team : teams) {
                JSONObject teamJson = new JSONObject(team.toString());
                int teamId = teamJson.getInt("teamId");
                tempTeams.add(teamId);
                String teamName = teamJson.getString("teamName");
//                    团队内模板标题要去重复(去掉自身)
                List<DoctorTeamGuidanceTemplate> list = doctorTeamGuidanceTemplateDao.distinctByTeamTitle(title, teamId);
                if (list.size() <= 1) {
//                        直接失效原有团队模板对应关系  在重新新增以前没有的团队关系 发送次数要归0
                    if (teamList.contains(teamId)) {
//                            数据库有
                        doctorTeamGuidanceTemplateDao.modifyTeamGuidance(teamId, guidanceCode, title,labelCode,labelName);
                    } else if (!teamList.contains(teamId)) {
                        //                        现在有,而数据库没有 要新增
                        DoctorTeamGuidanceTemplate doctorTeamGuidanceTemplate = new DoctorTeamGuidanceTemplate();
                        doctorTeamGuidanceTemplate.setCreater(doctor);
                        doctorTeamGuidanceTemplate.setCreateTime(nowDate);
                        doctorTeamGuidanceTemplate.setCzrq(nowDate);
                        doctorTeamGuidanceTemplate.setDel(1);
                        doctorTeamGuidanceTemplate.setTeamId(teamId);
                        doctorTeamGuidanceTemplate.setTeamName(teamName);
                        doctorTeamGuidanceTemplate.setTitle(title);
                        doctorTeamGuidanceTemplate.setTeamTemplateCode(guidanceCode);
                        doctorTeamGuidanceTemplate.setUseTimes(0);
                        doctorTeamGuidanceTemplate.setLabelCode(labelCode);
                        doctorTeamGuidanceTemplate.setLabelName(labelName);
                        doctorTeamGuidanceTemplateDao.save(doctorTeamGuidanceTemplate);
                    }
                } else {
                    
                    throw new RuntimeException(teamName + ":团队标题重复!");
                }
                //                直接修改团队模板后修改模板团队对应表
                doctorTeamGuidanceDetailDao.modifyTeamGuidanceDetail(title, content, image, guidanceCode);
            }
//                            数据库有,而现在没有
            teamList.removeAll(tempTeams);
            for (Object team : teamList) {
                doctorTeamGuidanceTemplateDao.deleteTeamGuidance(Integer.parseInt(team.toString()), guidanceCode);
            }
        } else if (saveAsGuidance == 0) {
            if ((!doctor.equals(creater)) && (!"1".equals(isLeader))) {
                throw new RuntimeException("没有修改权限");
            }
            //                        数据库中拥有该模板的所有团队
            List<DoctorTeamGuidanceTemplate> teamIds = doctorTeamGuidanceTemplateDao.getTeamsByGuidance(guidanceCode);
            List teamList = new ArrayList();
            List tempTeams = new ArrayList();
            for (DoctorTeamGuidanceTemplate team : teamIds) {
                teamList.add(team.getTeamId());
            }
            for (Object team : teams) {
                JSONObject teamJson = new JSONObject(team.toString());
                int teamId = teamJson.getInt("teamId");
                tempTeams.add(teamId);
                String teamName = teamJson.getString("teamName");
//                    团队内模板标题要去重复(去掉自身)
                List<DoctorTeamGuidanceTemplate> list = doctorTeamGuidanceTemplateDao.distinctByTeamTitle(title, teamId);
                if (list.size() <= 1) {
//                        直接失效原有团队模板对应关系  在重新新增以前没有的团队关系 发送次数要归0
                    if (teamList.contains(teamId)) {
//                            数据库有
                        doctorTeamGuidanceTemplateDao.modifyTeamGuidance(teamId, guidanceCode, title,labelCode,labelName);
                    } else if (!teamList.contains(teamId)) {
                        //                        现在有,而数据库没有 要新增
                        DoctorTeamGuidanceTemplate doctorTeamGuidanceTemplate = new DoctorTeamGuidanceTemplate();
                        doctorTeamGuidanceTemplate.setCreater(doctor);
                        doctorTeamGuidanceTemplate.setCreateTime(nowDate);
                        doctorTeamGuidanceTemplate.setCzrq(nowDate);
                        doctorTeamGuidanceTemplate.setDel(1);
                        doctorTeamGuidanceTemplate.setTeamId(teamId);
                        doctorTeamGuidanceTemplate.setTeamName(teamName);
                        doctorTeamGuidanceTemplate.setTitle(title);
                        doctorTeamGuidanceTemplate.setTeamTemplateCode(guidanceCode);
                        doctorTeamGuidanceTemplate.setUseTimes(0);
                        doctorTeamGuidanceTemplate.setLabelCode(labelCode);
                        doctorTeamGuidanceTemplate.setLabelName(labelName);
                        doctorTeamGuidanceTemplateDao.save(doctorTeamGuidanceTemplate);
                    }
                } else {
                    throw new RuntimeException(teamName + ":团队标题重复!");
                }
                //                直接修改团队模板后修改模板团队对应表
                doctorTeamGuidanceDetailDao.modifyTeamGuidanceDetail(title, content, image, guidanceCode);
            }
//                            数据库有,而现在没有
            teamList.removeAll(tempTeams);
            for (Object team : teamList) {
                doctorTeamGuidanceTemplateDao.deleteTeamGuidance(Integer.parseInt(team.toString()), guidanceCode);
            }
        }
    }
    /**
     * 根据医生所属的单个团队获取团队模板列表
     *
     * @param doctor
     * @param filter
     * @param teamId
     * @param pageNo
     * @param pageSize
     * @return
     * @throws Exception
     */
    public List getTeamGuidanceList(String doctor, String filter, Integer teamId, int pageNo, int pageSize) throws Exception {
        Sort sort =  Sort.by(Sort.Direction.DESC, "useTimes","createTime");
        PageRequest request =  PageRequest.of(pageNo, pageSize, sort);
        List list = new ArrayList();
        List<DoctorTeamGuidanceTemplate> listGuidances = null;
        if (StringUtils.isEmpty(filter)){
            listGuidances = doctorTeamGuidanceTemplateDao.findGuidanceByTeamId(teamId, request);
        }else {
            listGuidances = doctorTeamGuidanceTemplateDao.getListByTile(teamId,"%"+filter+"%", request);
        }
        for (DoctorTeamGuidanceTemplate guidance : listGuidances) {
            Map map = new HashMap();
            String title = guidance.getTitle();
            int useTimes = guidance.getUseTimes();
            String teamTemplateCode = guidance.getTeamTemplateCode();
            map.put("teamTemplateCode", teamTemplateCode);
            map.put("title", title);
            map.put("useTimes", useTimes);
            map.put("createTime", guidance.getCreateTime());
            list.add(map);
        }
        return list;
    }
//    /**
//     * 获取此医生所在的团队列表。
//     *
//     * @param doctorCode
//     * @param filter 搜索关键字
//     * @return
//     */
//    public List getDoctorTeams(String doctorCode,String filter) throws Exception{
//        List teamList = null;
//        try {
//            List<AdminTeam> doctorTeams = memberDao.findDoctorTeams(doctorCode);
//            teamList = new ArrayList();
//
//            for (AdminTeam AdminTeam : doctorTeams){
//                Map map = new HashMap();
//                String teamName = AdminTeam.getName();
//                Long teamId = AdminTeam.getId();
//                map.put("teamName", teamName);
//                map.put("teamId", teamId);
//
//                if (StringUtils.isNotEmpty(filter)){
//                    List<DoctorTeamGuidanceTemplate> guidances = doctorTeamGuidanceTemplateDao.countTeamListByTile(Integer.valueOf(teamId.toString()),"%"+filter+"%");
//                    map.put("amount", guidances.size());
//                }else {
//                    List<DoctorTeamGuidanceTemplate> listGuidances = doctorTeamGuidanceTemplateDao.countGuidanceByTeamId(Integer.valueOf(teamId.toString()));
//                    map.put("amount", listGuidances.size());
//                }
//                teamList.add(map);
//            }
//        } catch (NumberFormatException e) {
//            e.printStackTrace();
//        }
//
//        return teamList;
//    }
//    /**
//     * 获取此医生所在的团队列表。
//     *
//     * @param doctorCode
//     * @param filter 搜索关键字
//     * @return
//     */
//    public List findDoctorLeaderTeam(String doctorCode,String filter) throws Exception{
//        List teamList = null;
//        try {
//            List<AdminTeam> doctorTeams = memberDao.findDoctorLeaderTeam(doctorCode);
//            teamList = new ArrayList();
//
//            for (AdminTeam AdminTeam : doctorTeams){
//                Map map = new HashMap();
//                String teamName = AdminTeam.getName();
//                Long teamId = AdminTeam.getId();
//                map.put("teamName", teamName);
//                map.put("teamId", teamId);
//
//                if (StringUtils.isNotEmpty(filter)){
//                    List<DoctorTeamGuidanceTemplate> guidances = doctorTeamGuidanceTemplateDao.countTeamListByTile(Integer.valueOf(teamId.toString()),"%"+filter+"%");
//                    map.put("amount", guidances.size());
//                }else {
//                    List<DoctorTeamGuidanceTemplate> listGuidances = doctorTeamGuidanceTemplateDao.countGuidanceByTeamId(Integer.valueOf(teamId.toString()));
//                    map.put("amount", listGuidances.size());
//                }
//                teamList.add(map);
//            }
//        } catch (NumberFormatException e) {
//            e.printStackTrace();
//        }
//
//        return teamList;
//    }
    /**
     * 根据团队模板编码获取单个 有效的 模板详情
     *
     * @param guidanceCode
     * @return
     * @throws Exception
     */
    public JSONObject getTeamGuidanceDetail(int teamId, String guidanceCode) throws Exception {
        JSONObject jsonObject = new JSONObject();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String createTime = "";
        String czrq = "";
        DoctorTeamGuidanceDetail guidanceDetail = doctorTeamGuidanceDetailDao.findGuidanceDetail(guidanceCode);
        List<DoctorTeamGuidanceTemplate> doctorTeamGuidanceTemplate = doctorTeamGuidanceTemplateDao.getTeamsByGuidance(guidanceCode);
        List teamList = new ArrayList();
        for (DoctorTeamGuidanceTemplate teamGuidanceTemplate : doctorTeamGuidanceTemplate) {
            Map map = new HashMap();
            map.put("teamId", teamGuidanceTemplate.getTeamId());
            map.put("teamName", teamGuidanceTemplate.getTeamName());
            if (teamGuidanceTemplate.getTeamId() == teamId) {
                jsonObject.put("useTimes", teamGuidanceTemplate.getUseTimes());
            }
            teamList.add(map);
        }
        Date create = guidanceDetail.getCreateTime();
        Date cztime = guidanceDetail.getCzrq();
        if (create != null) {
            createTime = sdf.format(create);
        }
        if (cztime != null) {
            czrq = sdf.format(cztime);
        }
        jsonObject.put("id", guidanceDetail.getId() != null ? guidanceDetail.getId() : "");
        jsonObject.put("code", guidanceDetail.getCode() != null ? guidanceDetail.getCode() : "");
        jsonObject.put("creater", guidanceDetail.getCreater() != null ? guidanceDetail.getCreater() : "");
        jsonObject.put("title", guidanceDetail.getTitle() != null ? guidanceDetail.getTitle() : "");
        jsonObject.put("content", guidanceDetail.getContent() != null ? guidanceDetail.getContent() : "");
        jsonObject.put("imagesUrl", guidanceDetail.getImagesUrl() != null ? guidanceDetail.getImagesUrl() : "");
        jsonObject.put("createTime", createTime);
        jsonObject.put("czrq", czrq);
        jsonObject.put("teamList", teamList);
        String labelCode = doctorTeamGuidanceTemplate.get(0).getLabelCode();
        String labelName = doctorTeamGuidanceTemplate.get(0).getLabelName();
        jsonObject.put("labelCode", labelCode);
        jsonObject.put("labelName", labelName);
        return jsonObject;
    }
    /**
     * 删除团队所属的团队模板
     *
     * @param teamId
     * @param guidanceCode
     * @throws Exception
     */
    public void deleteTeamGuidance(String doctor, int deteleAll, Integer teamId, String guidanceCode) throws Exception {
        String str = "";
        if (deteleAll == 0) {
            doctorTeamGuidanceTemplateDao.deleteTeamGuidance(teamId, guidanceCode);
        } else {
//            删除该医生所有团队内该模板
//            List<AdminTeam> teams = memberDao.findDoctorTeams(doctor);
//            for (AdminTeam team : teams) {
//                int teamCode = team.getId().intValue();
//                doctorTeamGuidanceTemplateDao.deleteTeamGuidance(teamCode, guidanceCode);
//            }
            doctorTeamGuidanceTemplateDao.deleteTeamGuidance(123, guidanceCode);
        }
    }
    /**
     * 给居民发送团队模板
     *
     * @param accessToken
     * @param patient
     * @param content
     * @param guidanceCode
     * @param images
     * @throws Exception
     */
    public PatientHealthGuidance sendTeamGuidance(String accessToken, String dc, String patient, String content, String guidanceCode, String images, int teamId, String tzCode) throws Exception {
        String image = "";
        if (StringUtils.isNotEmpty(images)) {
            image = validateImages(images);
        }
        List<DoctorTeamGuidanceTemplate> guidanceTemplate = doctorTeamGuidanceTemplateDao.getTeamsByGuidance(guidanceCode);
        PatientHealthGuidance guidance = new PatientHealthGuidance();
        guidance.setContent(content);
        guidance.setDoctor(dc);
        guidance.setPatient(patient);
        BaseDoctorDO doctor = doctorDao.findById(dc).orElse(null);
        guidance.setImages(image);
        // 保存
        PatientHealthGuidance guidance1 = patientHealthGuidanceService.add(guidance, accessToken, tzCode, guidanceTemplate.get(0).getTitle());
        if (guidance1 != null) {
            String sendImgs = "";
            if (StringUtils.isNotBlank(image)) {
                sendImgs = image;
            }
            BasePatientDO p = patientDao.findById(patient).orElse(null);
            String imcotent = "{\"title\":\"健康指导\",\"type\":2,\"id\":\"" +
                    guidance.getId() + "\",\"img\":\"" + sendImgs + "\",\"content\":\"" +
                    CommonUtil.getSubString(guidance.getContent(), 0, 30) + "\"}";
            // todo 这个选注释掉了 -- 还没改完 20240306
//            consultService.sendMucMessageBySingnType(dc, doctor.getName(), patient, imcotent, "4", p.getName());
//            BusinessLogs.info(BusinessLogs.BusinessType.guidance, dc, patient, new JSONObject(guidance));
            //发送成功记录模板发送次数
            doctorTeamGuidanceTemplateDao.countSend(teamId, guidanceCode);
            return guidance1;
        }
        return null;
    }
    /**
     * 校验图片本地路径掺杂网络路径,统一返回网路路径
     *
     * @param images
     * @throws Exception
     */
    public  String validateImages(String images) throws Exception {
        String imagePath = "";
        String imageUrls = "";
        String imageRow = "";
        String[] imgs = images.split(",");
        for (String image : imgs) {
            if (image.contains("group1")) {
                imageUrls += image + ",";
            } else {
                try {
                    imageRow += CommonUtil.copyTempImage(image) + ",";
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        imagePath += imageUrls + imageRow;
        imagePath = imagePath.substring(0, imagePath.length() - 1);
        return imagePath;
    }
    public List<DoctorTeamGuidanceTemplate> getGuidanceByTeamIdAndLabelCode( Integer teamId,String labelCode, int pageNo, int pageSize) throws Exception {
        Sort sort = Sort.by(Sort.Direction.DESC, "useTimes","createTime");
        pageNo = pageNo -1;
        PageRequest request =  PageRequest.of(pageNo, pageSize, sort);
        List<DoctorTeamGuidanceTemplate> list = doctorTeamGuidanceTemplateDao.findGuidanceByTeamIdAndLabelCode(teamId,labelCode,request);
        return list;
    }
    public Map<String,List<DoctorTeamGuidanceTemplate>> getTeamGuidanceListByLabelWithFilter(Integer teamId , String filter) throws Exception {
        List<DoctorTeamGuidanceTemplate>  listGuidances = doctorTeamGuidanceTemplateDao.getListByTile(teamId,"%"+filter+"%");
        Map<String,List<DoctorTeamGuidanceTemplate>> map= new HashMap<>();
        for(DoctorTeamGuidanceTemplate one:listGuidances){
            if(map.containsKey(one.getLabelName()!=null?one.getLabelName():"未分组")){
                List<DoctorTeamGuidanceTemplate> temp = map.get(one.getLabelName()!=null?one.getLabelName():"未分组");
                temp.add(one);
            }else{
                map.put(one.getLabelName()!=null?one.getLabelName():"未分组",new ArrayList<>(Arrays.asList(one)));
            }
        }
        return map;
    }
    public String getCode() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
}