瀏覽代碼

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

wangjun 3 年之前
父節點
當前提交
a8c13e084d
共有 100 個文件被更改,包括 3042 次插入751 次删除
  1. 159 1
      business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java
  2. 3 0
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultTeamDao.java
  3. 2 1
      business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java
  4. 16 0
      common/common-entity/sql记录
  5. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageItemDO.java
  6. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/system/SystemDictEntryDO.java
  7. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/course/DoctorPatientTmpDO.java
  8. 19 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java
  9. 0 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/sign/CapacityAssessmentRecordDO.java
  10. 6 0
      common/common-entity/src/main/java/com/yihu/jw/entity/job/QuartzJobConfig.java
  11. 12 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/course/DoctorPatientTmpDao.java
  12. 2 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/system/SystemDictEntryDao.java
  13. 6 8
      svr/svr-base/src/main/java/com/yihu/jw/base/service/course/RecruitStudentsRecordService.java
  14. 16 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageItemService.java
  15. 12 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageService.java
  16. 156 0
      svr/svr-base/src/main/java/com/yihu/jw/base/util/EntranceUtil.java
  17. 5 1
      svr/svr-cloud-care/pom.xml
  18. 13 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/WebSocketConfig.java
  19. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/CourseSalesOrderRecordDao.java
  20. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/DoctorPatientTmpDao.java
  21. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/RecruitStudentsRecordDao.java
  22. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DevicePatientHealthIndexDao.java
  23. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/doorCoach/BaseDoorCoachOrderDao.java
  24. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  25. 58 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java
  26. 1 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java
  27. 11 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java
  28. 28 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  29. 64 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java
  30. 139 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/StatisticsEndpoint.java
  31. 196 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java
  32. 51 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PcManageWebSocketServer.java
  33. 4 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/securrity/SecuMonOrderEndpoint.java
  34. 14 8
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  35. 6 15
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultService.java
  36. 32 28
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/CourseService.java
  37. 6 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/RecruitStudentService.java
  38. 101 22
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  39. 3 10
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/DoctorDoorCoachOrderService.java
  40. 24 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  41. 22 12
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  42. 15 13
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java
  43. 28 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  44. 396 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java
  45. 79 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsUtilService.java
  46. 196 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java
  47. 40 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PcManageWebSocketService.java
  48. 267 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/EntranceUtil.java
  49. 41 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/vo/NumVo.java
  50. 2 2
      svr/svr-cloud-care/src/main/resources/application.yml
  51. 3 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  52. 100 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java
  53. 34 0
      svr/svr-statistics-es/doc/sql/初始统计数据.txt
  54. 0 192
      svr/svr-statistics-es/doc/sql/统计相关表数据备份20171121.txt
  55. 69 30
      svr/svr-statistics-es/pom.xml
  56. 0 245
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/compute/ComputeHelper.java
  57. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/Application.java
  58. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/AsyncConfig.java
  59. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/DataSourceConfig.java
  60. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/MVCConfig.java
  61. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/SwaggerConfig.java
  62. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/WebSecurityConfig.java
  63. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/jpa/HibernateProperties.java
  64. 3 3
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/jpa/WlyyJpa.java
  65. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/quartz/JobFactory.java
  66. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/quartz/SchedulerConfig.java
  67. 2 2
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/war/ServletInitializer.java
  68. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/controller/BaseController.java
  69. 2 2
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/controller/ExtractDataController.java
  70. 3 3
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/controller/JobController.java
  71. 6 6
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/controller/QueryController.java
  72. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/dao/JobConfigDao.java
  73. 2 2
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/dao/QuartzJobConfigDao.java
  74. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/dao/QuartzJobLogDao.java
  75. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/dao/QuotaDao.java
  76. 2 2
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/dao/WlyyDimensionQuotaDao.java
  77. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/dao/WlyyQuotaResultDao.java
  78. 2 2
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/cache/Cache.java
  79. 360 0
      svr/svr-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/compute/ComputeHelper.java
  80. 3 3
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/convert/Convert.java
  81. 5 3
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/convert/ConvertHelper.java
  82. 58 0
      svr/svr-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/AgeConvert.java
  83. 4 4
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/convert/wlyy/ConsultTypeConvert.java
  84. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/convert/wlyy/model/HealthLable.java
  85. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/convert/wlyy/model/PrescriptionDisease.java
  86. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/convert/wlyy/model/ServerType.java
  87. 5 5
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/extract/ExtractHelper.java
  88. 2 2
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/extract/db/DBExtract.java
  89. 2 2
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/extract/db/DBPageExtract.java
  90. 3 3
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/extract/db/Data2Save.java
  91. 5 5
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/extract/db/ESExtract.java
  92. 4 4
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/filter/FilterHelper.java
  93. 2 2
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/filter/filter/NotNullFilter.java
  94. 4 4
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/save/SaveHelper.java
  95. 1 1
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/save/es/ElasticFactory.java
  96. 2 2
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/save/es/ElastricSearchSave.java
  97. 2 2
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/job/business/CacheCleanJob.java
  98. 22 44
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/job/business/CurrentMysqlToEsQuotaJob.java
  99. 20 19
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/job/business/EsToEsQuotaJob.java
  100. 0 0
      svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/job/business/MysqlToEsQuotaJob.java

+ 159 - 1
business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java

@ -899,7 +899,7 @@ public class ElasticsearchUtil {
     * @return
     * @throws Exception
     */
    public List findDateAllQuotaLevel1(String startDate, String endDate, String area, int level, String index, String timeLevel, String interval, String lowLevel) throws Exception {
    public List findDateAllQuotaLevel1(String startDate, String endDate, String area, int level, String index, String timeLevel, String interval, String lowLevel,String areaLevel) throws Exception {
        //时间格式转换  yyyy-MM-dd转成 2017-07-17T00:00:00+0800
        if (StringUtils.isNotEmpty(startDate)) {
@ -939,6 +939,164 @@ public class ElasticsearchUtil {
            groupBy.append("  group by city,cityName,slaveKey1,slaveKey1Name");
        }
        if (StringUtils.isNotEmpty(area)) {
            if (SaveModel.doctorLevel.equals(level + "")) {
                sql.append(" doctor='" + area + "'");
            }else if (SaveModel.deptLevel.equals(level + "")) {
                sql.append(" dept='" + area + "'");
            } else if (SaveModel.OrgLevel.equals(level + "")) {
                sql.append(" hospital='" + area + "'");
            } else if (SaveModel.townLevel.equals(level + "")) {
                sql.append(" town='" + area + "'");
            } else if (SaveModel.cityLevel.equals(level + "")) {
                sql.append(" city='" + area + "'");
            }
            sql.append(" and ");
        }
        sql.append(" quotaCode='" + index + "'  ");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='"+areaLevel+"'");
        if (StringUtils.isNotEmpty(startDate)) {
            sql.append(" and quotaDate>='" + startDate + "'");
        }
        if (StringUtils.isNotEmpty(endDate)) {
            sql.append(" and quotaDate<='" + endDate + "'");
        }
        //根据时间维度分组
        if (StringUtils.isNotEmpty(interval)) {
            if (SaveModel.interval_month.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='month','time_zone'='+08:00','alias'='quotaDate') ");
            } else if (SaveModel.interval_week.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='week','time_zone'='+08:00','alias'='quotaDate') ");
            } else if (SaveModel.interval_day.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='1d','time_zone'='+08:00','alias'='quotaDate') ");
            }
        }
        sql.append(groupBy);
        return excute(sql.toString(), SaveModel.class, "", "");
    }
    public List findDateAllQuotaLevel2(String startDate, String endDate, String area, int level, String index, String timeLevel, String interval, String lowLevel,String areaLevel) throws Exception {
        //时间格式转换  yyyy-MM-dd转成 2017-07-17T00:00:00+0800
        if (StringUtils.isNotEmpty(startDate)) {
            if (startDate.length() > 10) {
                startDate = changeTime(startDate);
            } else {
                startDate = changeDate(startDate);
            }
        }
        if (StringUtils.isNotEmpty(endDate)) {
            if (endDate.length() > 10) {
                endDate = changeTime(endDate);
            } else {
                endDate = changeDate(endDate);
            }
        }
        StringBuffer sql = new StringBuffer();
        StringBuffer groupBy = new StringBuffer();
        String low_level = level + "";
        if (StringUtils.isNotEmpty(lowLevel)) {
            low_level = lowLevel;
        }
        if (SaveModel.doctorLevel.equals(low_level)) {
            sql.append("select doctor as doctor,doctorName as doctorName,slaveKey2 as slaveKey2,slaveKey2Name as slaveKey2Name,sum(result1) as result1, sum(result2) as result2 from " + esIndex + " where ");
            groupBy.append("  group by doctor,doctorName,slaveKey2,slaveKey2Name");
        }else if (SaveModel.deptLevel.equals(low_level)) {
            sql.append("select dept as dept,deptName as deptName,slaveKey2 as slaveKey2,slaveKey2Name as slaveKey2Name,sum(result1) as result1, sum(result2) as result2 from " + esIndex + " where ");
            groupBy.append("  group by dept,deptName,slaveKey2,slaveKey2Name");
        } else if (SaveModel.OrgLevel.equals(low_level)) {
            sql.append("select hospital as hospital,hospitalName as hospitalName,slaveKey2 as slaveKey2,slaveKey2Name as slaveKey2Name,sum(result1) as result1,sum(result2) as result2 from " + esIndex + " where ");
            groupBy.append("  group by hospital,hospitalName,slaveKey2,slaveKey2Name");
        } else if (SaveModel.townLevel.equals(low_level)) {
            sql.append("select town as town,townName as townName,slaveKey2 as slaveKey2,slaveKey2Name as slaveKey2Name,sum(result1) as result1,sum(result2) as result2 from " + esIndex + " where ");
            groupBy.append("  group by town,townName,slaveKey2,slaveKey2Name");
        } else if (SaveModel.cityLevel.equals(low_level)) {
            sql.append("select city as city,cityName as cityName,slaveKey2 as slaveKey2,slaveKey2Name as slaveKey2Name,sum(result1) as result1,sum(result2) as result2 from " + esIndex + " where ");
            groupBy.append("  group by city,cityName,slaveKey2,slaveKey2Name");
        }
        if (StringUtils.isNotEmpty(area)) {
            if (SaveModel.doctorLevel.equals(level + "")) {
                sql.append(" doctor='" + area + "'");
            }else if (SaveModel.deptLevel.equals(level + "")) {
                sql.append(" dept='" + area + "'");
            } else if (SaveModel.OrgLevel.equals(level + "")) {
                sql.append(" hospital='" + area + "'");
            } else if (SaveModel.townLevel.equals(level + "")) {
                sql.append(" town='" + area + "'");
            } else if (SaveModel.cityLevel.equals(level + "")) {
                sql.append(" city='" + area + "'");
            }
            sql.append(" and ");
        }
        sql.append(" quotaCode='" + index + "'  ");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='"+areaLevel+"'");
        if (StringUtils.isNotEmpty(startDate)) {
            sql.append(" and quotaDate>='" + startDate + "'");
        }
        if (StringUtils.isNotEmpty(endDate)) {
            sql.append(" and quotaDate<='" + endDate + "'");
        }
        //根据时间维度分组
        if (StringUtils.isNotEmpty(interval)) {
            if (SaveModel.interval_month.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='month','time_zone'='+08:00','alias'='quotaDate') ");
            } else if (SaveModel.interval_week.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='week','time_zone'='+08:00','alias'='quotaDate') ");
            } else if (SaveModel.interval_day.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='1d','time_zone'='+08:00','alias'='quotaDate') ");
            }
        }
        sql.append(groupBy);
        return excute(sql.toString(), SaveModel.class, "", "");
    }
    public List findDateAllQuotaLevel3(String startDate, String endDate, String area, int level, String index, String timeLevel, String interval, String lowLevel) throws Exception {
        //时间格式转换  yyyy-MM-dd转成 2017-07-17T00:00:00+0800
        if (StringUtils.isNotEmpty(startDate)) {
            if (startDate.length() > 10) {
                startDate = changeTime(startDate);
            } else {
                startDate = changeDate(startDate);
            }
        }
        if (StringUtils.isNotEmpty(endDate)) {
            if (endDate.length() > 10) {
                endDate = changeTime(endDate);
            } else {
                endDate = changeDate(endDate);
            }
        }
        StringBuffer sql = new StringBuffer();
        StringBuffer groupBy = new StringBuffer();
        String low_level = level + "";
        if (StringUtils.isNotEmpty(lowLevel)) {
            low_level = lowLevel;
        }
        if (SaveModel.doctorLevel.equals(low_level)) {
            sql.append("select doctor as doctor,doctorName as doctorName,slaveKey3 as slaveKey3,slaveKey3Name as slaveKey3Name,sum(result1) as result1, sum(result2) as result2 from " + esIndex + " where ");
            groupBy.append("  group by doctor,doctorName,slaveKey3,slaveKey3Name");
        }else if (SaveModel.deptLevel.equals(low_level)) {
            sql.append("select dept as dept,deptName as deptName,slaveKey3 as slaveKey3,slaveKey3Name as slaveKey3Name,sum(result1) as result1, sum(result2) as result2 from " + esIndex + " where ");
            groupBy.append("  group by dept,deptName,slaveKey3,slaveKey3Name");
        } else if (SaveModel.OrgLevel.equals(low_level)) {
            sql.append("select hospital as hospital,hospitalName as hospitalName,slaveKey3 as slaveKey3,slaveKey3Name as slaveKey3Name,sum(result1) as result1,sum(result2) as result2 from " + esIndex + " where ");
            groupBy.append("  group by hospital,hospitalName,slaveKey3,slaveKey3Name");
        } else if (SaveModel.townLevel.equals(low_level)) {
            sql.append("select town as town,townName as townName,slaveKey3 as slaveKey3,slaveKey3Name as slaveKey3Name,sum(result1) as result1,sum(result2) as result2 from " + esIndex + " where ");
            groupBy.append("  group by town,townName,slaveKey3,slaveKey3Name");
        } else if (SaveModel.cityLevel.equals(low_level)) {
            sql.append("select city as city,cityName as cityName,slaveKey3 as slaveKey3,slaveKey3Name as slaveKey3Name,sum(result1) as result1,sum(result2) as result2 from " + esIndex + " where ");
            groupBy.append("  group by city,cityName,slaveKey3,slaveKey3Name");
        }
        if (StringUtils.isNotEmpty(area)) {
            if (SaveModel.doctorLevel.equals(level + "")) {
                sql.append(" doctor='" + area + "'");

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

@ -1,6 +1,7 @@
package com.yihu.jw.im.dao;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import org.hibernate.validator.constraints.LuhnCheck;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
@ -29,4 +30,6 @@ public interface ConsultTeamDao  extends PagingAndSortingRepository<ConsultTeamD
	Integer  countByTime(int type, String doctor, Date startTime, Date endTime);
	ConsultTeamDo queryByRelationCode(String relationCode);
	List<ConsultTeamDo> findByTypeAndDel(Integer type,String del);
}

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

@ -758,7 +758,8 @@ public class ImUtil {
	public static final String SESSION_TYPE_EMERGENCY_ASSISTANCE = "20";//紧急救助
	public static final String SESSION_TYPE_DOOR_COACH = "21";//上门辅导(上门预约)
	public static final String SESSION_TYPE_SECURITY_WARN = "22";//安防咨询
	public static final String SESSION_TYPE_ONLINE = "23";//在线咨询
	public static final String SESSION_TYPE_ONLINE = "23";//新生儿在线咨询
	public static final String SESSION_TYPE_ONLINEAged = "24";//老人在线咨询
	public static final String CONTENT_TYPE_TEXT = "1";
	

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

@ -1031,3 +1031,19 @@ CREATE TABLE `base_doctor_patient_tmp` (
  KEY `patient` (`patient`),
  KEY `type_doc_code` (`type`,`doctor_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='教师医生通讯录埋点数据';
-- 2021-06-10
alter table base.base_service_package_item add column topic_item varchar(50) default null COMMENT '服务项所属专题(base_system_dict_entry remark字段) security 安防服务专题';
--2021-06-11
ALTER table base.base_security_monitoring_order add column topic_item varchar(50) default "preventLost" COMMENT '安防工单所属专题 base_system_dict_entry表service_item';
ALTER TABLE base.base_security_monitoring_order ADD INDEX idx_topIt(topic_item);
ALTER table base_capacity_assessment_record add column age tinyint(4) default  COMMENT '年龄';
ALTER TABLE base.base_doctor_patient_tmp MODIFY COLUMN  doctor_code varchar(50) DEFAULT NULL COMMENT 'type=(1,2,4为医生id) ';
ALTER TABLE base.base_doctor_patient_tmp ADD COLUMN org_code varchar(50) DEFAULT NULL COMMENT 'type=(3为机构code)';
ALTER TABLE base_security_monitoring_order add column scene_img VARCHAR(1000) default null COMMENT '工单发起时的现场照片';

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageItemDO.java

@ -29,6 +29,7 @@ public class ServicePackageItemDO extends UuidIdentityEntity implements java.io.
    private String teamName;//'服务团队名称'
    private String createTime;//
    private String dictId;//
    private String topicItem;//所属专题 security 安防专题
    @Column(name = "dict_id")
    public String getDictId() {
        return dictId;
@ -153,4 +154,13 @@ public class ServicePackageItemDO extends UuidIdentityEntity implements java.io.
    public void setDelName(String delName) {
        this.delName = delName;
    }
    @Column(name = "topic_item")
    public String getTopicItem() {
        return topicItem;
    }
    public void setTopicItem(String topicItem) {
        this.topicItem = topicItem;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/system/SystemDictEntryDO.java

@ -27,7 +27,7 @@ public class SystemDictEntryDO extends UuidIdentityEntity {
	//排序
	private Integer sort;
	//备注
	private String remark;
	private String remark;//dictCode为service_item时 该字段为服务项所对应专题
	@Column(name = "dict_code", nullable = false, length = 50)
	public String getDictCode() {

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/course/DoctorPatientTmpDO.java

@ -17,6 +17,7 @@ public class DoctorPatientTmpDO extends UuidIdentityEntityWithCreateTime {
    private Integer type; //1在线咨询,2上门辅导,3入学报名,4购买课程
    private String relationCode; //1:咨询code,2上门辅导工单id,3入学订单id,4课程订单id
    private String doctorCode;// type=(1,2,4为医生id;3机构code)
    private String orgCode;// type=(1,2,4为医生id;3机构code)
    private Integer status; //入学字段 1已入学,0未入学
    private Integer del;
@ -52,6 +53,14 @@ public class DoctorPatientTmpDO extends UuidIdentityEntityWithCreateTime {
        this.doctorCode = doctorCode;
    }
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    public Integer getStatus() {
        return status;
    }

+ 19 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java

@ -318,8 +318,10 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    private String serviceStatus;//服务类型 1-预约项目 2-即时项目
    private String orderInfo;//工单详情 0-未推送 1-未确认 2-已确认
    private String doctorConfirmFinishImg;
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警 4监控器发起
    private Integer emergencyCancel;// 紧急预警工单误报警原因 字典emergency_cancel
    private String topicItem;//安防工单所属专题 base_system_dict_entry表service_item
    private String sceneImg;//现场照片
    /**
     * 医生确认医生结束服务时间
@ -709,4 +711,20 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    public void setEmergencyCancel(Integer emergencyCancel) {
        this.emergencyCancel = emergencyCancel;
    }
    public String getTopicItem() {
        return topicItem;
    }
    public void setTopicItem(String topicItem) {
        this.topicItem = topicItem;
    }
    public String getSceneImg() {
        return sceneImg;
    }
    public void setSceneImg(String sceneImg) {
        this.sceneImg = sceneImg;
    }
}

+ 0 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/sign/CapacityAssessmentRecordDO.java

@ -301,7 +301,6 @@ public class CapacityAssessmentRecordDO extends UuidIdentityEntityWithCreateTime
        this.signTime = signTime;
    }
    @Transient
    public Integer getAge() {
        return age;
    }

+ 6 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/job/QuartzJobConfig.java

@ -134,6 +134,7 @@ public class QuartzJobConfig implements java.io.Serializable {
		this.del = del;
	}
	@Column(name = "sql")
	public String getSql() {
		return sql;
	}
@ -142,6 +143,7 @@ public class QuartzJobConfig implements java.io.Serializable {
		this.sql = sql;
	}
	@Column(name = "sql_count")
	public String getSqlCount() {
		return sqlCount;
	}
@ -150,6 +152,7 @@ public class QuartzJobConfig implements java.io.Serializable {
		this.sqlCount = sqlCount;
	}
	@Column(name = "sql_day")
	public String getSqlDay() {
		return sqlDay;
	}
@ -158,6 +161,7 @@ public class QuartzJobConfig implements java.io.Serializable {
		this.sqlDay = sqlDay;
	}
	@Column(name = "sql_year")
	public String getSqlYear() {
		return sqlYear;
	}
@ -166,6 +170,7 @@ public class QuartzJobConfig implements java.io.Serializable {
		this.sqlYear = sqlYear;
	}
	@Column(name = "cache_key")
	public String getCacheKey() {
		return cacheKey;
	}
@ -174,6 +179,7 @@ public class QuartzJobConfig implements java.io.Serializable {
		this.cacheKey = cacheKey;
	}
	@Column(name = "extract_type")
	public String getExtractType() {
		return extractType;
	}

+ 12 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/course/DoctorPatientTmpDao.java

@ -2,9 +2,12 @@ package com.yihu.jw.base.dao.course;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
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 Bing on 2021/6/7.
 */
@ -15,4 +18,13 @@ public interface DoctorPatientTmpDao extends PagingAndSortingRepository<DoctorPa
    @Query(value = "select count(1) from DoctorPatientTmpDO t where t.patient=?1 and t.doctorCode = ?2 and t.type=?3")
    Integer findByPatientAndDoctorCodeAndType(String patient,String doctorCode,Integer type);
    @Query(value = "select count(1) from DoctorPatientTmpDO t where t.patient=?1 and t.orgCode = ?2 and t.type=?3 and t.status=?4 and t.del=1")
    Integer findByPatientAndOrgCodeAndTypeAndStatus(String patient,String orgCode,Integer type,Integer status);
    List<DoctorPatientTmpDO> queryByPatientAndTypeIn(String patient,Integer[] type);
    @Modifying
    @Query(value = "update DoctorPatientTmpDO t set t.del=0 where 1=1")
    void deleteAll();
}

+ 2 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/system/SystemDictEntryDao.java

@ -28,4 +28,6 @@ public interface SystemDictEntryDao extends PagingAndSortingRepository<SystemDic
    boolean existsBySaasIdAndCode(String saasid,String code);
    Integer countBySaasIdAndCodeNot(String saasid,String code);
    SystemDictEntryDO findByDictCodeAndCode(String dictCode, String code);
}

+ 6 - 8
svr/svr-base/src/main/java/com/yihu/jw/base/service/course/RecruitStudentsRecordService.java

@ -1,11 +1,10 @@
package com.yihu.jw.base.service.course;
import com.yihu.jw.base.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.base.dao.course.PatientOrderRefundDao;
import com.yihu.jw.base.dao.course.RecruitStudentsDao;
import com.yihu.jw.base.dao.course.RecruitStudentsRecordDao;
import com.yihu.jw.base.util.EntranceUtil;
import com.yihu.jw.base.util.WxMessageUtil;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import com.yihu.jw.entity.care.course.PatientOrderRefundDO;
import com.yihu.jw.entity.care.course.RecruitStudentsDO;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
@ -37,7 +36,7 @@ public class RecruitStudentsRecordService extends BaseJpaService<RecruitStudents
    @Autowired
    private WxMessageUtil wxMessageUtil;
    @Autowired
    private DoctorPatientTmpDao doctorPatientTmpDao;
    private EntranceUtil entranceUtil;
    /**
     * 退费操作
@ -62,6 +61,7 @@ public class RecruitStudentsRecordService extends BaseJpaService<RecruitStudents
    public int leaveSchool(String id){
       int ret = recruitStudentsRecordDao.updateStatus(id);
        entranceUtil.deleteRecord(id);
       return ret;
    }
@ -87,12 +87,9 @@ public class RecruitStudentsRecordService extends BaseJpaService<RecruitStudents
            }else{
                re += recruitStudentsRecordDO.getPatientName()+",";
            }
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
            if (tmpDO!=null){
                tmpDO.setStatus(1);
                doctorPatientTmpDao.save(tmpDO);
            }
        }
        entranceUtil.updateStatus2(1,idStr);
        recruitStudentsRecordDao.save(list);
        wxMessageUtil.sengdWxTemplates(list);
//        if(re.length()>0){
@ -116,6 +113,7 @@ public class RecruitStudentsRecordService extends BaseJpaService<RecruitStudents
                list.add(recruitStudentsRecordDO);
            }
        }
        entranceUtil.deleteRecord2(idStr);
        recruitStudentsRecordDao.save(list);
    }

+ 16 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageItemService.java

@ -2,10 +2,12 @@ package com.yihu.jw.base.service.servicePackage;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.dao.servicePackage.ServicePackageItemDao;
import com.yihu.jw.base.dao.system.SystemDictEntryDao;
import com.yihu.jw.base.dao.team.BaseTeamDao;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageItemDO;
import com.yihu.jw.entity.base.system.SystemDictEntryDO;
import com.yihu.jw.entity.base.team.BaseTeamDO;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.util.date.DateUtil;
@ -30,6 +32,8 @@ public class ServicePackageItemService extends BaseJpaService<ServicePackageItem
    private BaseOrgDao  baseOrgDao;
    @Autowired
    private BaseTeamDao baseTeamDao;
    @Autowired
    private SystemDictEntryDao systemDictEntryDao;
    public JSONObject create(ServicePackageItemDO itemDO){
        JSONObject result = new JSONObject();
@ -48,6 +52,12 @@ public class ServicePackageItemService extends BaseJpaService<ServicePackageItem
            itemDO.setTeamName(baseTeamDO.getName());
        }
        if(StringUtil.isEmpty(itemDO.getId())){
            SystemDictEntryDO systemDictEntryDO = systemDictEntryDao.findByDictCodeAndCode("service_item",itemDO.getCode());
            if (systemDictEntryDO!=null){
                if (StringUtils.isNotBlank(systemDictEntryDO.getRemark())){//服务项所属专题不为空
                    itemDO.setTopicItem(systemDictEntryDO.getRemark());
                }
            }
            //新增
            List<ServicePackageItemDO> itemDOList = servicePackageItemDao.findByTeamCode(itemDO.getTeamCode(),itemDO.getCode());
            if(itemDOList!=null&&itemDOList.size()>0){
@ -61,6 +71,12 @@ public class ServicePackageItemService extends BaseJpaService<ServicePackageItem
            servicePackageItemDao.save(itemDO);
        }else{
            //修改
            SystemDictEntryDO systemDictEntryDO = systemDictEntryDao.findByDictCodeAndCode("service_item",itemDO.getCode());
            if (systemDictEntryDO!=null){
                if (StringUtils.isNotBlank(systemDictEntryDO.getRemark())){//服务项所属专题不为空
                    itemDO.setTopicItem(systemDictEntryDO.getRemark());
                }
            }
            ServicePackageItemDO oldItemDO = servicePackageItemDao.findOne(itemDO.getId());
            oldItemDO.setName(itemDO.getName());
            oldItemDO.setDel(itemDO.getDel());

+ 12 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageService.java

@ -4,16 +4,19 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.dao.servicePackage.ServicePackageDao;
import com.yihu.jw.base.dao.servicePackage.ServicePackageItemDao;
import com.yihu.jw.base.dao.servicePackage.ServicePackageSignRecordDao;
import com.yihu.jw.base.dao.system.SystemDictEntryDao;
import com.yihu.jw.base.dao.team.BaseTeamDao;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageItemDO;
import com.yihu.jw.entity.base.system.SystemDictEntryDO;
import com.yihu.jw.entity.base.team.BaseTeamDO;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
@ -43,6 +46,8 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    private BaseOrgDao baseOrgDao;
    @Autowired
    private BaseTeamDao baseTeamDao;
    @Autowired
    private SystemDictEntryDao systemDictEntryDao;
    @Autowired
    private ServicePackageSignRecordDao servicePackageSignRecordDao;
@ -85,6 +90,13 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
            itemDO1.setDictId(itemDO.getId());
            itemDO1.setServicePackageId(servicePackageDO.getId());
            itemDO1.setCreateTime(DateUtil.getStringDate());
            SystemDictEntryDO systemDictEntryDO = systemDictEntryDao.findByDictCodeAndCode("service_item",itemDO.getCode());
            if (systemDictEntryDO!=null){
                if (StringUtils.isNotBlank(systemDictEntryDO.getRemark())){//服务项所属专题不为空
                    itemDO1.setTopicItem(systemDictEntryDO.getRemark());
                }
            }
            itemDOs.add(itemDO1);
        }
        servicePackageItemDao.save(itemDOs);

+ 156 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/util/EntranceUtil.java

@ -0,0 +1,156 @@
package com.yihu.jw.base.util;
import com.yihu.jw.base.dao.course.CourseDao;
import com.yihu.jw.base.dao.course.CourseSalesOrderRecordDao;
import com.yihu.jw.base.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.base.dao.course.RecruitStudentsRecordDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.care.course.CourseDO;
import com.yihu.jw.entity.care.course.CourseSalesOrderRecordDO;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
 * 教师与新生儿 入学关系更新工具
 * Created by Bing on 2021/6/11.
 */
@Component
public class EntranceUtil {
    @Autowired
    private DoctorPatientTmpDao doctorPatientTmpDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    /**
     *
     * @param patient
     * @param type
     * @param del
     * @param doctorCode
     * @param orgCode
     * @param relationCode
     */
    public void newRecord(String patient,Integer type,Integer del,String doctorCode,String orgCode,String relationCode){
        if (1==type||2==type){//在线咨询与上门辅导不重复保存
            if (doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(patient,doctorCode,type)!=0){
                return ;
            }
        }
        DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
        tmpDO.setPatient(patient);
        tmpDO.setType(type);
        tmpDO.setDel(del);
        tmpDO.setStatus(0);
        if (StringUtils.isBlank(orgCode)){
            List<BaseDoctorHospitalDO> list = doctorHospitalDao.findByDoctorCode(doctorCode);
            if (list.size()>0){
                orgCode = list.get(0).getOrgCode();
            }
        }
        if (doctorPatientTmpDao.findByPatientAndOrgCodeAndTypeAndStatus(patient,orgCode,3,1)!=0){
            tmpDO.setDel(0);
        }
        tmpDO.setOrgCode(orgCode);
        tmpDO.setDoctorCode(doctorCode);
        tmpDO.setRelationCode(relationCode);
        doctorPatientTmpDao.save(tmpDO);
    }
    /**
     * 更新状态 状态为1 已入学,将该幼儿咨询、上门、课程数据失效
     * @param relationCode
     */
    public void updateStatus(Integer status,String relationCode){
        DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(relationCode);
        if (tmpDO!=null){
            tmpDO.setStatus(status);
            doctorPatientTmpDao.save(tmpDO);
            if (status==1){//入学后 将该幼儿咨询、上门、课程数据失效
                List<DoctorPatientTmpDO> list = doctorPatientTmpDao.queryByPatientAndTypeIn(tmpDO.getPatient(),new Integer[]{1,2,4});
                List<String> relationCodes  = list.stream().map(DoctorPatientTmpDO::getRelationCode).collect(Collectors.toList());
                deleteRecord2List(relationCodes);
            }
        }
    }
    /**
     * 更新状态
     * @param relationCode
     */
    public void updateStatus2(Integer status,String[] relationCode) {
        List<DoctorPatientTmpDO> list = new ArrayList<>();
        List<String>relationCodes = new ArrayList<>();
        for (String id : relationCode) {
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
            if (tmpDO != null) {
                tmpDO.setStatus(status);
                list.add(tmpDO);
                if (status==1){//入学后 将该幼儿咨询、上门、课程数据失效
                    List<DoctorPatientTmpDO> listTmp = doctorPatientTmpDao.queryByPatientAndTypeIn(tmpDO.getPatient(),new Integer[]{1,2,4});
                    List<String> relationCodeTmp  = list.stream().map(DoctorPatientTmpDO::getRelationCode).collect(Collectors.toList());
                    relationCodes.addAll(relationCodeTmp);
                }
            }
        }
        doctorPatientTmpDao.save(list);
        deleteRecord2List(relationCodes);
    }
    /**
     * 删除记录 单条
     * @param relationCode
     */
    public void deleteRecord(String relationCode){
        DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(relationCode);
        if (tmpDO!=null){
            tmpDO.setDel(0);
            doctorPatientTmpDao.save(tmpDO);
        }
        doctorPatientTmpDao.save(tmpDO);
    }
    /**
     * 删除记录
     * @param relationCode
     */
    public void deleteRecord2(String[] relationCode){
        List<DoctorPatientTmpDO> list = new ArrayList<>();
        for (String id : relationCode) {
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
            if (tmpDO!=null){
                tmpDO.setDel(0);
            }
        }
        doctorPatientTmpDao.save(list);
    }
    /**
     * 删除记录
     * @param relationCode
     */
    public void deleteRecord2List(List<String> relationCode){
        List<DoctorPatientTmpDO> list = new ArrayList<>();
        for (String id : relationCode) {
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
            if (tmpDO!=null){
                tmpDO.setDel(0);
            }
        }
        doctorPatientTmpDao.save(list);
    }
}

+ 5 - 1
svr/svr-cloud-care/pom.xml

@ -30,7 +30,7 @@
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
<!--            <scope>provided</scope>-->
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
@ -203,6 +203,10 @@
            <version>RELEASE</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>
        <!--   poi xml导入导出工具 end -->
        <!--基础业务组件-->

+ 13 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/WebSocketConfig.java

@ -0,0 +1,13 @@
package com.yihu.jw.care.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
@Configuration
public class WebSocketConfig {
    @Bean
    public ServerEndpointExporter serverEndpointExporter(){
        return new ServerEndpointExporter();
    }
}

+ 3 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/CourseSalesOrderRecordDao.java

@ -4,6 +4,8 @@ import com.yihu.jw.entity.care.course.CourseSalesOrderRecordDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 *
@ -14,4 +16,5 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface CourseSalesOrderRecordDao extends PagingAndSortingRepository<CourseSalesOrderRecordDO, String>
        , JpaSpecificationExecutor<CourseSalesOrderRecordDO> {
    List<CourseSalesOrderRecordDO> findByStatus(String status);
}

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/DoctorPatientTmpDao.java

@ -2,9 +2,12 @@ package com.yihu.jw.care.dao.course;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
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 Bing on 2021/6/7.
 */
@ -15,4 +18,13 @@ public interface DoctorPatientTmpDao extends PagingAndSortingRepository<DoctorPa
    @Query(value = "select count(1) from DoctorPatientTmpDO t where t.patient=?1 and t.doctorCode = ?2 and t.type=?3")
    Integer findByPatientAndDoctorCodeAndType(String patient,String doctorCode,Integer type);
    @Query(value = "select count(1) from DoctorPatientTmpDO t where t.patient=?1 and t.orgCode = ?2 and t.type=?3 and t.status=?4 and t.del=1")
    Integer findByPatientAndOrgCodeAndTypeAndStatus(String patient,String orgCode,Integer type,Integer status);
    List<DoctorPatientTmpDO> queryByPatientAndTypeIn(String patient,Integer[] type);
    @Modifying
    @Query(value = "update DoctorPatientTmpDO t set t.del=0 where 1=1")
    void deleteAll();
}

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/RecruitStudentsRecordDao.java

@ -19,4 +19,6 @@ public interface RecruitStudentsRecordDao extends PagingAndSortingRepository<Rec
    List<RecruitStudentsRecordDO> findByRecruitStudentsIdAndStatus(String recruitStudentsId, String status);
    List<RecruitStudentsRecordDO> findByOrgCodeAndStatus(String orgCode, String status);
    List<RecruitStudentsRecordDO> findByDelAndStatus(Integer del,String status);
}

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

@ -58,7 +58,7 @@ public interface DevicePatientHealthIndexDao
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from 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 * from 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)
	@Query(value= " select * from 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_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 * from wlyy_patient_health_index where user = ?1 and type = ?2 ORDER BY record_date desc limit 0 ,5",nativeQuery = true)

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/doorCoach/BaseDoorCoachOrderDao.java

@ -50,4 +50,6 @@ public interface BaseDoorCoachOrderDao extends PagingAndSortingRepository<BaseDo
    @Query("select o from BaseDoorCoachOrderDO o where o.doctor = ?1 and o.status in (1,2,3,4,5)")
    List<BaseDoorCoachOrderDO> getUnFinishOrderByDoctor(String doctor);
    List<BaseDoorCoachOrderDO> queryByStatusIn(Integer[] status);
}

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

@ -173,8 +173,8 @@ public class PatientDeviceController extends BaseController {
    @RequestMapping(value = "patientDeviceListByTopic", method = RequestMethod.GET)
    public ListEnvelop patientDeviceListByTopic(@ApiParam(name = "patient", value = "patient", defaultValue = "patient")
                                                @RequestParam(value = "patient", required = true) String patient,
                                                @ApiParam(name = "topic", value = "专题CODE;preventLost防走失", defaultValue = "preventLost")
                                                @RequestParam(value = "topic", required = true) String topic) {
                                                @ApiParam(name = "topic", value = "专题CODE;preventLost防走失,preventFall防跌倒", defaultValue = "preventLost")
                                                @RequestParam(value = "topic", required = false) String topic) {
        try {
            return ListEnvelop.getSuccess("查询成功",  patientDeviceService.patientDeviceListByTopic(patient,topic));
        } catch (Exception ex) {

+ 58 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java

@ -6,6 +6,7 @@ import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.service.doctor.CareDoctorService;
import com.yihu.jw.care.service.doorCoach.DoctorDoorCoachOrderService;
import com.yihu.jw.care.service.sign.CapacityAssessmentRecordService;
import com.yihu.jw.care.util.EntranceUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -39,6 +40,8 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
    private CapacityAssessmentRecordService capacityAssessmentRecordService;
    @Autowired
    private ConsultTeamService consultTeamService;
    @Autowired
    private EntranceUtil entranceUtil;
    @GetMapping(value = "doctorPage")
    @ApiOperation(value = "获取医生记录分页")
@ -208,4 +211,59 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "/getArchiveList")
    @ApiOperation(value = "管理员获取居民档案列表")
    public PageEnvelop getArchiveList(@ApiParam(name="type",value = "档案类型,1老人 2新生儿")
                                      @RequestParam(value = "type",required = false,defaultValue = "2")Integer type,
                                      @ApiParam(name = "signStatus",value = "签约状况 -1全部,0未签约,1已签约 ")
                                      @RequestParam(value = "signStatus",required = false,defaultValue = "-1")Integer signStatus,
                                      @ApiParam(name = "name", value = "居民姓名", required = false)
                                      @RequestParam(value = "name",required = false) String name,
                                      @ApiParam(name = "page")
                                      @RequestParam(value = "page",required = true)Integer page,
                                      @ApiParam(name = "size")
                                      @RequestParam(value = "size",required = true)Integer size){
        try {
            return doctorService.getArchiveList(type, signStatus,name,page, size);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "/getArchiveNum")
    @ApiOperation(value = "管理员获取居民tab数量")
    public ObjEnvelop getArchiveNum(){
        try {
            return ObjEnvelop.getSuccess("查询成功",doctorService.getArchiveNum()) ;
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "/initEntranceData")
    @ApiOperation(value = "初始化新生儿未入学埋点数据")
    public Envelop initEntranceData(){
        try {
            entranceUtil.initData();
            return Envelop.getSuccess("操作成功");
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("操作失败");
        }
    }
    @GetMapping(value = "/deleteEntranceData")
    @ApiOperation(value = "删除新生儿未入学埋点数据")
    public Envelop deleteEntranceData(){
        try {
            entranceUtil.deleteAll();
            return Envelop.getSuccess("操作成功");
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("操作失败");
        }
    }
}

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

@ -249,4 +249,5 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
            return ObjEnvelop.getError("获取失败");
        }
    }
}

+ 11 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java

@ -35,9 +35,11 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop createOrder(@ApiParam(name="jsonData",value = "json数据",required = true)
                               @RequestParam(value = "jsonData")String jsonData,
                               @ApiParam(name="orderSource",value = "工单来源工单发起来源状态 1APP 2手环 3居家报警")
                               @RequestParam(value = "orderSource",defaultValue = "1") Integer orderSource){
                               @RequestParam(value = "orderSource",defaultValue = "1") Integer orderSource,
                               @ApiParam(name="warnStr",value = "紧急预警弹框字段")
                               @RequestParam(value = "warnStr",defaultValue = "疑似离开安全区域",required = false) String warnStr){
        try {
            JSONObject result = securityMonitoringOrderService.createOrder(jsonData,orderSource);
            JSONObject result = securityMonitoringOrderService.createOrder(jsonData,orderSource,warnStr);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
@ -60,6 +62,8 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
                                            @RequestParam(value = "patient",required = false)String patient,
                                            @ApiParam(name="status",value = "工单状态-1已取消1待处置2前往居民定位3已签到4已登记小结5待补录6待评价7已完成")
                                            @RequestParam(value = "status",required = false)String status,
                                            @ApiParam(name = "topicItem", value = "专题code,security安防相关专题", required = false)
                                            @RequestParam(value = "topicItem",required = false) String topicItem,
                                            @ApiParam(name="page",value = "page",required = true)
                                            @RequestParam(value = "page")Integer page,
                                            @ApiParam(name="pageSize",value = "pageSize",required = true)
@ -67,7 +71,7 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
        try {
            page = page>1?page-1:0;
            return securityMonitoringOrderService.getSecurityOrderList(doctor,serverDoctor,patientName, patient, status, page, pageSize);
            return securityMonitoringOrderService.getSecurityOrderList(doctor,serverDoctor,patientName, patient, status, topicItem,page, pageSize);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
@ -288,10 +292,12 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getSecurityServerDoctor")
    @ApiOperation(value = "获取安防监护服务人员")//
    public ListEnvelop getSecurityServerDoctor(@ApiParam(name="patient",value = "patient",required = true)
                                             @RequestParam(value = "patient")String patient){
                                             @RequestParam(value = "patient")String patient,
                                             @ApiParam(name = "topicItem", value = "专题code,security安防相关专题", required = false)
                                             @RequestParam(value = "topicItem",required = false,defaultValue = "preventLost") String topicItem){
        try {
            return ListEnvelop.getSuccess("查询成功",securityMonitoringOrderService.getSecurityServerDoctor(patient));
            return ListEnvelop.getSuccess("查询成功",securityMonitoringOrderService.getSecurityServerDoctor(patient,topicItem));
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");

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

@ -172,6 +172,34 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "servicePackageByTopicType")
    @ApiOperation(value = "根据服务专题获取服务项目")
    public ObjEnvelop servicePackageByTopicType (
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(value = "patient") String patient,
            @ApiParam(name = "topicType", value = "专题类型,security安防相关专题", required = true)
            @RequestParam(value = "topicType") String topicType) throws Exception {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.servicePackageByTopicType(patient,topicType));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "servicePackageByPatient")
    @ApiOperation(value = "获取患者所有服务包")
    public ObjEnvelop servicePackageByPatient (
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(value = "patient") String patient) throws Exception {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.servicePackageByPatient(patient));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @PostMapping(value = "servicePackageSign")
    @ApiOperation(value = "分配服务包-签约")
    @ObserverRequired

+ 64 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java

@ -0,0 +1,64 @@
package com.yihu.jw.care.endpoint.statistics;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.statistics.StatisticsService;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/6/16
 * @Description:
 */
@RestController
@RequestMapping(value = "open/statistics")
@Api(value = "大屏-统计相关", description = "大屏-统计相关", tags = {"大屏-统计相关"})
public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private StatisticsService statisticsService;
    @GetMapping(value = "statisticsTotalAmount")
    @ApiOperation(value = "统计总数")
    public ObjEnvelop statisticsTotalAmount(
            @RequestParam(required = true) String endDate) {
        try {
            JSONObject result = statisticsService.statisticsTotalAmount(endDate);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "serviceRankingAnalysis")
    @ApiOperation(value = "服务排名分析")
    public ListEnvelop serviceRankingAnalysis(
            @RequestParam(required = true) String endDate,@RequestParam(required = true) String orgType) {
        try {
            return success(statisticsService.serviceRankingAnalysis(endDate,orgType));
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "realTimeData")
    @ApiOperation(value = "大屏实时数据")
    public ObjEnvelop realTimeData() {
        try {
            JSONObject result = statisticsService.realTimeData();
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
}

+ 139 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/StatisticsEndpoint.java

@ -1,10 +1,14 @@
package com.yihu.jw.care.endpoint.statistics;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.statistics.StatisticsService;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -22,6 +26,141 @@ public class StatisticsEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private StatisticsService statisticsService;
    @GetMapping(value = "statisticsTotalAmount")
    @ApiOperation(value = "统计总数")
    public ObjEnvelop statisticsTotalAmount(
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index,
            @ApiParam(name="type",value="类型:1本周,2本月",defaultValue = "")@RequestParam(required = false) String type) {
        try {
            JSONObject result = statisticsService.statisticsTotalAmount(endDate, area, level, index, type);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "consultAnalysis")
    @ApiOperation(value = "在线咨询分析")
    public ObjEnvelop consultAnalysis(
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @ApiParam(name="type",value="类型:1幼儿,2老人",defaultValue = "")@RequestParam(required = false) String type) {
        try {
            JSONObject result = statisticsService.consultAnalysis(endDate, area, level, type);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "patientAnalysis")
    @ApiOperation(value = "居民分析")
    public ObjEnvelop patientAnalysis(
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @ApiParam(name="index",value="42幼儿,37老人",defaultValue = "")@RequestParam(required = true) String index) {
        try {
            JSONObject result = statisticsService.patientAnalysis(endDate, area, level, index);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "addLine")
    @ApiOperation(value = "通用折线图")
    public ListEnvelop addLine(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index,
            @RequestParam(required = false) String timeLevel,
            @RequestParam(required = false) String interval,
            @RequestParam(required = false) String lowLevel) {
        try {
            JSONArray result = statisticsService.addLine(startDate,endDate, area, level, index, timeLevel,interval,lowLevel);
            return success(result);
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "capacityAssessment")
    @ApiOperation(value = "能力评估评估类型")
    public ListEnvelop capacityAssessment(
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level) {
        try {
            JSONArray result = statisticsService.capacityAssessment(endDate, area, level);
            return success(result);
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "doorCoachItems")
    @ApiOperation(value = "上门辅导服务项目")
    public ListEnvelop doorCoachItems(
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level) {
        try {
            JSONArray result = statisticsService.doorCoachItems(endDate, area, level);
            return success(result);
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "lifeCareItems")
    @ApiOperation(value = "生活照料服务项目")
    public ListEnvelop lifeCareItems(
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level) {
        try {
            JSONArray result = statisticsService.lifeCareItems(endDate, area, level);
            return success(result);
        } catch (Exception e) {
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "lifeCareAnalysis")
    @ApiOperation(value = "生活照料分析")
    public ObjEnvelop lifeCareAnalysis(
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level) {
        try {
            JSONObject result = statisticsService.lifeCareAnalysis(endDate, area, level);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "doorCoachAnalysis")
    @ApiOperation(value = "上门辅导分析")
    public ObjEnvelop doorCoachAnalysis(
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level) {
        try {
            JSONObject result = statisticsService.doorCoachAnalysis(endDate, area, level);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    /**
     * 统计首页头部数据
     * @param startDate

+ 196 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java

@ -0,0 +1,196 @@
package com.yihu.jw.care.endpoint.third.platForm;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
import com.yihu.jw.care.service.doorCoach.DoctorDoorCoachOrderService;
import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.care.service.third.PatientInfoPlatFormService;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Bing on 2021/6/16.
 * 管理端pc端 居民详情大屏
 */
@RestController
@RequestMapping(value = "/cloudCare/noLogin/patientInfoForm")
@Api(description = "管理端pc端 居民详情大屏")
public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private PatientInfoPlatFormService patientInfoPlatFormService;
    @Autowired
    private PatientDoorCoachOrderService patientDoorCoachOrderService;
    @Autowired
    private DoctorDoorCoachOrderService doctorDoorCoachOrderService;
    @Autowired
    private LifeCareOrderService lifeCareOrderService;
    @Autowired
    private SecurityMonitoringOrderService securityMonitoringOrderService;
    @Autowired
    private EmergencyAssistanceService assistanceService;
    @GetMapping(value = "getPatientInfo")
    @ApiParam("获取居民详情页")
    public ObjEnvelop getPatientInfo(@ApiParam(name="patient",value = "居民id",required = true)
                                     @RequestParam(value = "patient")String patient,
                                     @ApiParam(name="patientType",value="患者类型 1老人 2 新生儿")
                                     @RequestParam(name = "patientType",required = false,defaultValue = "1")Integer patientType){
        try {
            return ObjEnvelop.getSuccess("查询成功",patientInfoPlatFormService.getPatientInfo(patient,patientType));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
        }
    }
    @GetMapping(value = "getPatientEvent")
    @ApiParam("获取就诊事件")
    public ObjEnvelop getPatientEvent(@ApiParam(name="patient",value = "居民id",required = true)
                                     @RequestParam(value = "patient")String patient,
                                     @ApiParam(name="patientType",value="患者类型 1老人 2 新生儿")
                                     @RequestParam(name = "patientType",required = false,defaultValue = "1")Integer patientType,
                                     @ApiParam(name="page",value="page")
                                     @RequestParam(name = "page")Integer page,
                                     @ApiParam(name="pageSize",value="pageSize")
                                     @RequestParam(name = "pageSize")Integer pageSize){
        try {
            return ObjEnvelop.getSuccess("查询成功",patientInfoPlatFormService.getPatientEvent(patient,patientType,page,pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
        }
    }
    @GetMapping(value = "getServiceOrder")
    @ApiParam("获取服务工单列表")
    public ObjEnvelop getServiceOrder(@ApiParam(name="patient",value = "居民id",required = true)
                                     @RequestParam(value = "patient")String patient,
                                     @ApiParam(name="patientType",value="患者类型 1老人 2 新生儿")
                                     @RequestParam(name = "patientType",required = false,defaultValue = "1")Integer patientType,
                                     @ApiParam(name="page",value="page")
                                     @RequestParam(name = "page")Integer page,
                                     @ApiParam(name="pageSize",value="pageSize")
                                     @RequestParam(name = "pageSize")Integer pageSize){
        try {
            return ObjEnvelop.getSuccess("查询成功",patientInfoPlatFormService.getServiceOrder(patient,patientType,page,pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
        }
    }
    @GetMapping(value = "getHealthIndexInfo")
    @ApiParam("获取居民体征信息")
    public ObjEnvelop getHealthIndexInfo(@ApiParam(name="patient",value="患者代码",defaultValue = "eb0b478fbe9245428ecf63cd7517206f")
                                             @RequestParam(value="patient",required = true) String patient,
                                         @ApiParam(name="type",value="指标类型",defaultValue = "1")
                                             @RequestParam(value="type",required = true) int type,
                                         @ApiParam(name="gi_type",value="就餐类型",defaultValue = "1")
                                             @RequestParam(value = "gi_type",required = false) int gi_type,
                                         @ApiParam(name="begin",value="开始时间",defaultValue = "2017-05-22 00:00:00")
                                             @RequestParam(value="begin",required = true) String begin,
                                         @ApiParam(name="end",value="结束时间",defaultValue = "2017-06-02 00:00:00")
                                             @RequestParam(value="end",required = true) String end){
        try {
            return ObjEnvelop.getSuccess("查询成功",patientInfoPlatFormService.getHealthIndexInfo(patient,type,gi_type,begin,end));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
        }
    }
    @GetMapping("getDoorCoachByOrderId")
    @ApiOperation(value = "根据工单id获取相应的工单,如果为空,则获取该患者当前最新一条的工单")
    public ObjEnvelop getByOrderId(
            @ApiParam(value = "patientCode", name = "patientCode")
            @RequestParam(value = "patientCode", required = true) String patientCode,
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = false) String orderId) {
        try {
            // 没有提供工单id的情况下,则获取该医生当前最新一条的工单
            if (StringUtils.isEmpty(orderId)) {
                // 根据接单医生code获取最近一次服务orderId
                orderId = patientDoorCoachOrderService.getOrderIdByPatient(patientCode);
                if (StringUtils.isEmpty(orderId)) {
                    return ObjEnvelop.getSuccess( "获取失败, 该患者暂无工单",null);
                }
            }
            // 根据orderId获取工单信息
            BaseDoorCoachOrderDO baseDoorCoachOrderDO = doctorDoorCoachOrderService.getDoorServiceOrderById(orderId);
            return ObjEnvelop.getSuccess( "获取成功",  baseDoorCoachOrderDO);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败, 该医生暂无工单!" + e.getMessage());
        }
    }
    @GetMapping("getLifeCareByOrderId")
    @ApiOperation(value = "根据工单id获取相应的工单")
    public ObjEnvelop getByOrderId(
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId) {
        try {
            // 根据orderId获取工单信息
            LifeCareOrderDO doorServiceOrderDO = lifeCareOrderService.getServiceOrderById(orderId);
            return ObjEnvelop.getSuccess("获取成功", doorServiceOrderDO);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败" ,-1);
        }
    }
    @GetMapping(value = "getSecurityOrderDetail")
    @ApiOperation(value = "获取安防工单详情")//
    public ObjEnvelop getSecurityOrderDetail(@ApiParam(name="orderId",value = "orderId",required = true)
                                             @RequestParam(value = "orderId")String orderId,
                                             @ApiParam(name="doctor",value = "doctor",required = false)
                                             @RequestParam(value = "doctor",required = false)String doctor){
        try {
            JSONObject result = securityMonitoringOrderService.getSecurityOrderDetail(orderId,doctor);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
            return ObjEnvelop.getSuccess("创建成功",result.getJSONObject("resultMsg"));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "patientGetOrderDetail")
    @ApiOperation(value = "患者查看救助详情")//仅只能查看已完成
    public ObjEnvelop patientGetOrderDetail(@ApiParam(name="orderId",value = "工单id")
                                            @RequestParam(value = "orderId") String orderId,
                                            @ApiParam(name="patient",value = "patient")
                                            @RequestParam(value = "patient") String patient
    ){
        try {
            JSONObject result = assistanceService.patientGetOrderDetail(orderId,patient);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            return ObjEnvelop.getSuccess("查询成功",result.getJSONObject("resultMsg"));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
}

+ 51 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PcManageWebSocketServer.java

@ -0,0 +1,51 @@
package com.yihu.jw.care.endpoint.third.platForm;
import com.yihu.jw.care.service.third.PcManageWebSocketService;
import org.springframework.web.bind.annotation.RestController;
import javax.websocket.*;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
/**
 * Created by Bing on 2021/6/17.
 *
 * @ServerEndpoint 注解是一个类层次的注解,它的功能主要是将目前的类定义成一个websocket服务器端,
 */
@RestController
@ServerEndpoint("/cloudCare/noLogin/pcManage/websocket")
public class PcManageWebSocketServer {
    //与某个客户端的连接会话,需要通过它来给客户端发送数据
    private Session session;
    @OnOpen
    public void onOpen(Session session){
        this.session = session;
        PcManageWebSocketService.add(this);
    }
    public void sendMessage(String message) throws IOException {
        this.session.getBasicRemote().sendText(message);
    }
    @OnClose
    public void onClose(){
        PcManageWebSocketService.remove(this);
    }
    @OnMessage
    public void onMessage(String message, Session session) {
        System.out.println("来自客户端的消息:" + message);
    }
    @OnError
    public void onError(Session session, Throwable error){
        System.out.println("发生错误");
        error.printStackTrace();
    }
}

+ 4 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/securrity/SecuMonOrderEndpoint.java

@ -31,9 +31,11 @@ public class SecuMonOrderEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop createOrder(@ApiParam(name="jsonData",value = "json数据",required = true)
                                  @RequestParam(value = "jsonData")String jsonData,
                                  @ApiParam(name="orderSource",value = "工单来源工单发起来源状态 1APP 2手环 3居家报警")
                                  @RequestParam(value = "orderSource",defaultValue = "1") Integer orderSource){
                                  @RequestParam(value = "orderSource",defaultValue = "1") Integer orderSource,
                                  @ApiParam(name="warnStr",value = "紧急预警弹框字段")
                                  @RequestParam(value = "warnStr",defaultValue = "疑似离开安全区域",required = false) String warnStr){
        try {
            JSONObject result = securityMonitoringOrderService.createOrder(jsonData,orderSource);
            JSONObject result = securityMonitoringOrderService.createOrder(jsonData,orderSource,warnStr);
            if (result.getIntValue("resultFlag") == 0) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }

+ 14 - 8
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -11,10 +11,12 @@ import com.yihu.jw.care.dao.security.EmergencyWarnDoctorResponseDao;
import com.yihu.jw.care.dao.sign.ServicePackageItemDao;
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.endpoint.third.platForm.PcManageWebSocketServer;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.service.third.PcManageWebSocketService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
@ -98,6 +100,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    @Autowired
    private DictService dictService;
    /**
     * 新建居民紧急救助
     * @param patient
@ -202,21 +205,24 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            }
        }
        //推送socket给医生
        JSONObject message = new JSONObject();
        message.put("session_id",assistanceDO.getSessionId());
        message.put("sender_name",assistanceDO.getPatientName());
        message.put("content_notice",assistanceDO.getPatientName()+" 发起紧急救助!");
        message.put("sender_code",assistanceDO.getPatient());
        message.put("OrderType",20);
        message.put("order_id",assistanceDO.getId());
        message.put("content_type",40);
        for (BaseDoctorDO doctorDO:doctorDOS){
            JSONObject message = new JSONObject();
            message.put("session_id",assistanceDO.getSessionId());
            message.put("sender_name",assistanceDO.getPatientName());
            message.put("content_notice",assistanceDO.getPatientName()+" 发起紧急救助!");
            message.put("sender_code",assistanceDO.getPatient());
            message.put("OrderType",20);
            message.put("order_id",assistanceDO.getId());
            message.put("content_type",40);
            try {
                imUtill.sendMDTSocketMessageToDoctor(doctorDO.getId(),message.toString());
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        //pc管理端端推送消息
        PcManageWebSocketService.broadCast(message.toString());
        emergencyAssistanceDao.save(assistanceDO);
        return getOrderDetail(assistanceDO.getId(),null);
    }

+ 6 - 15
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultService.java

@ -3,6 +3,7 @@ package com.yihu.jw.care.service.consult;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.care.util.EntranceUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -72,7 +73,7 @@ public class ConsultService {
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private DoctorPatientTmpDao doctorPatientTmpDao;
    private EntranceUtil entranceUtil;
    /**
     * 获取居民该机构的最近一次在线咨询
@ -225,7 +226,7 @@ public class ConsultService {
        List<Map<String,Object>> result = hibenateUtils.createSQLQuery(sql,page,pagesize);
        Map<String,Integer> unreadNum = new HashedMap();
        for (Map<String,Object> map:result){
            if(type.equals(ImUtil.SESSION_TYPE_ONLINE)){
            if(type.equals(ImUtil.SESSION_TYPE_ONLINE)||type.equals(ImUtil.SESSION_TYPE_ONLINEAged)){
                String sessionId = patient+"_"+String.valueOf(map.get("doctorCode"))+"_"+type;
                //新增未读消息数量
                if(unreadNum.containsKey(sessionId)){
@ -459,7 +460,7 @@ public class ConsultService {
                }
            }
            if(type.equals(ImUtil.SESSION_TYPE_ONLINE)){
            if(type.equals(ImUtil.SESSION_TYPE_ONLINE)||type.equals(ImUtil.SESSION_TYPE_ONLINEAged)){
                String sessionId = String.valueOf(map.get("patient"))+"_"+doctor+"_"+type;
                //新增未读消息数量
                Integer count = imUtil.UserSessionsUnreadMessageCount(sessionId,doctor);
@ -560,7 +561,7 @@ public class ConsultService {
        JSONObject messages = imUtil.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), jsonObject.toJSONString(), consult.getImages(), doctor);
        users.put(patient, 0);
        users.put(doctor, 0);
        String session_type = ImUtil.SESSION_TYPE_ONLINE;
        String session_type = ct.getType()+"";//SESSION_TYPE
        String sessionId = patient + "_" + doctor + "_" + ct.getType();
        JSONObject obj = imUtil.createTopics(sessionId, consult.getId(), tempPatient.getName(), users, messages, session_type);
        if (obj == null) {
@ -589,20 +590,10 @@ public class ConsultService {
        }
        if (ct.getType()==23){
            if(doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(patient,doctor,1)==0){
                DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
                tmpDO.setDoctorCode(doctor);
                tmpDO.setPatient(patient);
                tmpDO.setType(1);
                tmpDO.setDel(1);
                tmpDO.setRelationCode(ct.getConsult());
                doctorPatientTmpDao.save(tmpDO);
            }
            entranceUtil.newRecord(patient,1,1,doctor,null,ct.getConsult());
        }
        // 保存医生咨询信息
        // 添加咨询转发记录
        // 添加医生咨询日志

+ 32 - 28
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/CourseService.java

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.course.*;
import com.yihu.jw.care.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.care.util.EntranceUtil;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -21,6 +22,7 @@ import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.idcard.IdCardUtil;
import com.yihu.jw.utils.StringUtil;
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;
@ -71,7 +73,7 @@ public class CourseService {
    @Autowired
    private MessageUtil messageUtil;
    @Autowired
    private DoctorPatientTmpDao doctorPatientTmpDao;
    private EntranceUtil entranceUtil;
    public String getOrderNo(String type){
        return type + System.currentTimeMillis()+(int)(Math.random() * 900)+100 +"";
@ -91,10 +93,7 @@ public class CourseService {
                return "只有待支付的订单才能取消";
            }
            recordDO.setStatus("7");
            recruitStudentsRecordDao.save(recordDO);
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(recordDO.getId());
            tmpDO.setDel(0);
            doctorPatientTmpDao.save(tmpDO);
            entranceUtil.deleteRecord(recordDO.getId());
        }else  if("2".equals(type)){
            //课程
@ -103,11 +102,7 @@ public class CourseService {
                return "只有待支付的订单才能取消";
            }
            recordDO.setStatus("7");
            courseSalesOrderRecordDao.save(recordDO);
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(recordDO.getId());
            tmpDO.setDel(0);
            doctorPatientTmpDao.save(tmpDO);
            entranceUtil.deleteRecord(recordDO.getId());
        }
        return null;
    }
@ -654,7 +649,7 @@ public class CourseService {
                object.put("allCourse","");//课程
            }
            String sql3 = "SELECT *  FROM base_doctor d,base_doctor_hospital dh\n" +
            String sql3 = "SELECT *, d.id as doctorCode  FROM base_doctor d,base_doctor_hospital dh\n" +
                    "WHERE d.doctor_level = 3 AND d.locked = 0 AND d.enabled = 1 AND d.del = 1 AND d.id = dh.doctor_code AND dh.del = 1 AND dh.org_code = '"+mapList.get(0).get("code")+"'" ;
            List<Map<String , Object >> bmapList = jdbcTemplate.queryForList(sql3);
            if (bmapList.size() > 0){
@ -703,11 +698,21 @@ public class CourseService {
    public JSONObject getTecInfoById(String doctor,String orgCode,int page,int size){
        JSONObject object = new JSONObject();
        //老师的基本信息
        String sql = "SELECT d.id,d.name,d.job_title_code jobTitleCode,d.job_title_name jobTitleName,dh.org_code orgCode,dh.org_name orgName\n" +
        String sql = "SELECT d.id,d.introduce,d.name,d.photo,d.sex,d.idcard,d.job_title_code jobTitleCode,d.job_title_name jobTitleName,dh.org_code orgCode,dh.org_name orgName\n" +
                "FROM base_doctor d,base_doctor_hospital dh\n" +
                "WHERE d.id = '"+doctor+"' AND dh.org_code = '"+orgCode+"' AND d.enabled = 1 AND d.locked = 0 AND d.del = 1 AND dh.del = 1 AND dh.doctor_code = d.id";
        List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql);
        object.put("doctorInfo",mapList.get(0));
        if (mapList.size()>0){
            String idcard = mapList.get(0).get("idcard").toString();
            if (StringUtils.isNotBlank(idcard)){
                Integer age = IdCardUtil.getAgeForIdcard(idcard);
                mapList.get(0).put("age",age);
            }
            else {
                mapList.get(0).put("age",null);
            }
        }
        object.put("doctorInfo",mapList.size()>0?mapList.get(0):null);
        if (mapList.size() > 0){
            page = page - 1;
            size = (page+1)*size;
@ -812,14 +817,7 @@ public class CourseService {
        //这个机构收到新的在线报名申请时,给机构联系人发送一条短信
        messageUtil.sendOnlineRegistSms(recruitStudentsDO.getOrgCode());
        DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
        tmpDO.setPatient(recordDO.getPatient());
        tmpDO.setType(3);
        tmpDO.setStatus(0);//未入取
        tmpDO.setDel(1);
        tmpDO.setDoctorCode(recordDO.getOrgCode());
        tmpDO.setRelationCode(recordDO.getId());
        doctorPatientTmpDao.save(tmpDO);
        entranceUtil.newRecord(recordDO.getPatient(),3,1,null,recordDO.getOrgCode(),recordDO.getId());
        return result;
    }
@ -856,15 +854,21 @@ public class CourseService {
        recordDO.setOrderNo(getOrderNo("2"));
        courseSalesOrderRecordDao.save(recordDO);
        DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
        tmpDO.setPatient(recordDO.getPatient());
        tmpDO.setType(4);
        tmpDO.setDel(1);
        tmpDO.setDoctorCode(courseDO.getDoctor());
        tmpDO.setRelationCode(recordDO.getId());
        doctorPatientTmpDao.save(tmpDO);
        entranceUtil.newRecord(recordDO.getPatient(),4,1,courseDO.getDoctor(),null,recordDO.getId());
        return recordDO;
    }
    /**
     * 获取新生儿被录取机构列表
     * @param patient
     * @return
     */
    public List<Map<String,Object>> getEntranceOrgList(String patient){
        String sql = "select sr.id,sr.patient,sr.org_code,org.`name`,org.photo from base_recruit_students_record sr " +
                " inner JOIN base_org org on sr.org_code = org.`code` where sr.patient = '"+patient+"' and sr.`status`=2 \n" +
                "GROUP BY sr.org_code";
        return jdbcTemplate.queryForList(sql);
    }
}

+ 6 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/RecruitStudentService.java

@ -3,6 +3,7 @@ package com.yihu.jw.care.service.course;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.course.RecruitStudentsDao;
import com.yihu.jw.care.dao.course.RecruitStudentsRecordDao;
import com.yihu.jw.care.util.EntranceUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
@ -41,6 +42,8 @@ public class RecruitStudentService {
    private RecruitStudentsDao recruitStudentsDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private EntranceUtil entranceUtil;
    /**
     * 在线报名-已报名数量
@ -150,6 +153,7 @@ public class RecruitStudentService {
        }
        recruitStudentsRecordDO.setStatus("2");
        recruitStudentsRecordDao.save(recruitStudentsRecordDO);
        entranceUtil.updateStatus(1,id);
        return null;
    }
@ -184,6 +188,8 @@ public class RecruitStudentService {
        }
        recruitStudentsRecordDO.setStatus("4");
        recruitStudentsRecordDao.save(recruitStudentsRecordDO);
        entranceUtil.deleteRecord(id);
        return null;
    }
}

+ 101 - 22
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java

@ -310,26 +310,25 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        return result;
    }
    //已入学未入学统一从base_doctor_patient_tmp该表查询
    //未入学:发起咨询的幼儿列表、发起上门辅导的幼儿列表、已报名但是未录取的幼儿
    public PageEnvelop getTeacherChildren(String doctor,int searchType,String name,int page,int size){
        page = page>0?page-1:0;
        List<Map<String,Object>> list = new ArrayList<>();
        //未入学
        String sql0 = "select * from  " +
                " (select Distinct patient,'1' as type from base_doctor_patient_tmp where type=1 and doctor_code='"+doctor+"' and del=1 " +
        String sql0 = "select Distinct patient,'1' as type from base_doctor_patient_tmp where type=1 and doctor_code='"+doctor+"' and del=1 " +
                " UNION " +
                " select Distinct patient,'2' as type from base_doctor_patient_tmp where type=2 and doctor_code='"+doctor+"' and del=1 " +
                " UNION " +
                " select Distinct patient,'4' as type from base_doctor_patient_tmp where type=4 and doctor_code='"+doctor+"' and del=1 " +
                " UNION " +
                " select tmp.patient,'3' as type from base_doctor_patient_tmp tmp INNER JOIN base_doctor_hospital dh on dh.org_code = tmp.doctor_code " +
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=0)B where  " +
                " not EXISTS (select DISTINCT rsr.patient  from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` " +
                " and org.del=1  INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where rsr.patient=B.patient and " +
                " dh.doctor_code='"+doctor+"'   and rsr.del<>0  and rsr.`status` = 2 )";
                " select tmp.patient,'3' as type from base_doctor_patient_tmp tmp INNER JOIN base_doctor_hospital dh on dh.org_code = tmp.org_code " +
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=0 ";
        //已入学
        String sql1=" select DISTINCT rsr.patient,null as type from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` " +
                "and org.del=1 INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where dh.doctor_code='"+doctor+"' " +
                "and rsr.del<>0  and rsr.`status` = 2   ";
        String sql1=" select tmp.patient,'3' as type from base_doctor_patient_tmp tmp INNER JOIN base_doctor_hospital dh on dh.org_code = tmp.org_code " +
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=1   ";
        String sql = "select p.id,p.name,p.photo,p.sex,p.idcard,p.openid,p.mobile,group_concat(tmp.type) type,group_concat( pd.category_code) deviceType from ( {sqlReplace} )tmp " +
                " Inner JOIN base_patient p on tmp.patient  = p.id " +
                " LEFT JOIN wlyy_patient_device pd on pd.`user`=p.id and pd.category_code BETWEEN 1 and 2 GROUP BY p.id limit "+page*size+","+size;
@ -383,22 +382,18 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    public Map<String,Long> getTeacherChildrenCount(String doctor){
        Map<String,Long> result = new HashMap<>();
        //未入学 (发起咨询的幼儿列表,发起上门辅导的幼儿列表,已报名但是未录取的幼儿)
        String sql0 = "select * from  " +
                " (select Distinct patient from base_doctor_patient_tmp where type=1 and doctor_code='"+doctor+"' and del=1 " +
        //未入学
        String sql0 = "select Distinct patient,'1' as type from base_doctor_patient_tmp where type=1 and doctor_code='"+doctor+"' and del=1 " +
                " UNION " +
                " select Distinct patient from base_doctor_patient_tmp where type=2 and doctor_code='"+doctor+"' and del=1 " +
                " select Distinct patient,'2' as type from base_doctor_patient_tmp where type=2 and doctor_code='"+doctor+"' and del=1 " +
                " UNION " +
                " select Distinct patient from base_doctor_patient_tmp where type=4 and doctor_code='"+doctor+"' and del=1 " +
                " select Distinct patient,'4' as type from base_doctor_patient_tmp where type=4 and doctor_code='"+doctor+"' and del=1 " +
                " UNION " +
                " select tmp.patient from base_doctor_patient_tmp tmp INNER JOIN base_doctor_hospital dh on dh.org_code = tmp.doctor_code " +
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=0)B where  " +
                " not EXISTS (select DISTINCT rsr.patient  from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` " +
                " and org.del=1  INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where rsr.patient=B.patient and " +
                " dh.doctor_code='"+doctor+"'   and rsr.del<>0  and rsr.`status` = 2 )";
                " select tmp.patient,'3' as type from base_doctor_patient_tmp tmp INNER JOIN base_doctor_hospital dh on dh.org_code = tmp.org_code " +
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=0 ";
        //已入学
        String sql1=" select DISTINCT rsr.patient from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` " +
                "and org.del=1 INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where dh.doctor_code='"+doctor+"' " +
                "and rsr.del<>0  and rsr.`status` = 2   ";
        String sql1=" select tmp.patient,'3' as type from base_doctor_patient_tmp tmp INNER JOIN base_doctor_hospital dh on dh.org_code = tmp.org_code " +
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=1   ";
        String sqlcpunt = "select count(Distinct p.id) from ( {sqlReplace} )tmp Inner JOIN base_patient p on tmp.patient  = p.id " +
                " LEFT JOIN wlyy_patient_device pd on pd.`user`=p.id and pd.category_code BETWEEN 1 and 2  ";
@ -428,4 +423,88 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
//        }
    }
    public PageEnvelop getArchiveList(Integer type,Integer signStatus,String name,Integer page,Integer size){
        page = page>0?page-1:0;
        String countSql  ="select count(DISTINCT p.id) from base_patient p where 1=1 ";
        String sql = "select DISTINCT p.id,p.name,p.sex,p.photo,p.idcard,null as sign_status from base_patient p where 1=1 ";
        String sqlCondition = "";
        if (null!=signStatus&&1==type){
            countSql  ="select count(DISTINCT p.id) from base_patient p,wlyy_archive a where a.patient = p.id ";
            sql = "select DISTINCT p.id,p.name,p.sex,p.photo,p.idcard,a.sign_status as sign_status from base_patient p,wlyy_archive a where a.patient = p.id ";
            if (0==signStatus){//未签约
                sqlCondition +=" and NOT EXISTS(select sr.id from base_service_package_sign_record sr " +
                        " INNER JOIN base_service_package_record pr on sr.id = pr.sign_id and sr.status=1 " +
                        " INNER JOIN base_service_package pack on pr.service_package_id = pack.id and pack.del=1 " +
                        " where sr.patient = p.id) ";
            }
            else if (1==signStatus){//已签约
                sqlCondition +=" and EXISTS(select sr.id from base_service_package_sign_record sr " +
                        " INNER JOIN base_service_package_record pr on sr.id = pr.sign_id and sr.status=1 " +
                        " INNER JOIN base_service_package pack on pr.service_package_id = pack.id and pack.del=1 " +
                        " where sr.patient = p.id) ";
            }
        }
        if (null!=type){//档案类型
            sqlCondition +=" and p.del=1 and p.archive_type="+type+" ";
        }
        if (StringUtils.isNotBlank(name)){
            sqlCondition +=" and p.name like '%"+name+"%' ";
        }
        if(1==type){
            sqlCondition += " order by a.sign_status desc ";
        }
        Long count = jdbcTemplate.queryForObject(countSql+sqlCondition,Long.class);
        sqlCondition +=" limit "+page*size+","+size;
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql+sqlCondition);
        for (Map<String,Object>tmp:result){
            String idcard= tmp.get("idcard").toString();
            if (StringUtils.isNotBlank(idcard)){
                try {
                    Integer age = IdCardUtil.getAgeForIdcard(idcard);
                    tmp.put("age",age);
                }catch (Exception e){
                    tmp.put("age",null);
                }
            }else {
                tmp.put("age",null);
            }
        }
        return PageEnvelop.getSuccessListWithPage("查询成功",result,page,size,count);
    }
    public JSONObject getArchiveNum(){
        JSONObject result = new JSONObject();
        String countSql  ="select count(DISTINCT p.id) from base_patient p where 1=1 ";
        String sqlCondition = "";
        //老人
       String sqlCondition_unSign =" and NOT EXISTS(select sr.id from base_service_package_sign_record sr " +
                " INNER JOIN base_service_package_record pr on sr.id = pr.sign_id and sr.status=1 " +
                " INNER JOIN base_service_package pack on pr.service_package_id = pack.id and pack.del=1 " +
                " where sr.patient = p.id) and p.del=1 and p.archive_type=1 ";
        //已签约
       String sqlCondition_sign =" and EXISTS(select sr.id from base_service_package_sign_record sr " +
                " INNER JOIN base_service_package_record pr on sr.id = pr.sign_id and sr.status=1 " +
                " INNER JOIN base_service_package pack on pr.service_package_id = pack.id and pack.del=1 " +
                " where sr.patient = p.id) and p.del=1 and p.archive_type=1 ";
       //新生儿
        sqlCondition +=" and p.del=1 and p.archive_type="+2+" ";//新生儿
        Long count_children = jdbcTemplate.queryForObject(countSql+sqlCondition,Long.class);
        Long count_sign = jdbcTemplate.queryForObject(countSql+sqlCondition_sign,Long.class);
        Long count_unSign = jdbcTemplate.queryForObject(countSql+sqlCondition_unSign,Long.class);
        result.put("count_children",count_children);
        result.put("count_sign",count_sign);
        result.put("count_unSign",count_unSign);
        result.put("count_agedAll",count_sign+count_unSign);
        return result;
    }
}

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

@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.doorCoach.*;
import com.yihu.jw.care.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.util.EntranceUtil;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -121,7 +122,7 @@ public class DoctorDoorCoachOrderService {
    @Autowired
    private BaseDoctorRoleDao baseDoctorRoleDao;
    @Autowired
    private DoctorPatientTmpDao doctorPatientTmpDao;
    private EntranceUtil entranceUtil;
    /**
     * 根据id获取服务工单信息
@ -457,15 +458,7 @@ public class DoctorDoorCoachOrderService {
        }
        //  待接单消息设为已操作, 434 医生接单-- 王五接受了服务工单12345678
        messageUtil.updateDoorCoachMessage(doorServiceOrder,new String[]{"703","707"},"734",null,null);
        if(doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(doorServiceOrder.getPatient(),doorServiceOrder.getDoctor(),2)==0){
            DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
            tmpDO.setDoctorCode(doorServiceOrder.getDoctor());
            tmpDO.setPatient(doorServiceOrder.getPatient());
            tmpDO.setType(2);
            tmpDO.setDel(1);
            tmpDO.setRelationCode(doorServiceOrder.getId());
            doctorPatientTmpDao.save(tmpDO);
        }
        entranceUtil.newRecord(doorServiceOrder.getPatient(),2,1,doorServiceOrder.getDoctor(),null,doorServiceOrder.getId());
    }

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

@ -608,6 +608,30 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
    }
    public JSONObject getPatientOrderList2(String patient, Integer status, int page, int size) {
        page = page>0?page-1:0;
        String sqlCount = "select count(ord.id) from  base_life_care_order ord where ord.patient = '"+patient+"' ";
        String sql = "select ord.id,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') createTime,DATE_FORMAT(ord.patient_expected_serve_time,'%Y-%m-%d %H:%i:%S') serveTime,ord.status,ord.hospital,ord.hospital_name hospitalName" +
                ",ord.doctor,ord.doctor_name doctorName,ord.expected_doctor_name expectedDoctorName,group_concat(Distinct fee.name SEPARATOR '、') serveItems" +
                " from base_life_care_order ord LEFT JOIN base_life_care_fee_detail fee on ord.id = fee.order_id " +
                "and fee.`status`<>3 where ord.patient = '"+patient+"' ";
        String fliter = "";
        if (status != null){
            fliter += " and ord.status = "+status;
        }
        Long count = jdbcTemplate.queryForObject(sqlCount+fliter,Long.class);
        fliter += " group by ord.id order by ord.create_time desc limit "+page*size+","+size;
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql+fliter);
        JSONObject object = new JSONObject();
        object.put("total",count);
        object.put("detailModelList",result);
        object.put("currPage",page);
        object.put("pageSize",size);
        return object;
    }
    /**
     * 签到保存
     * @param orderId

+ 22 - 12
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java

@ -8,11 +8,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.security.*;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.endpoint.third.platForm.PcManageWebSocketServer;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.service.third.PcManageWebSocketService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.entity.base.im.ConsultDo;
@ -105,7 +107,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
    public JSONObject createOrder(String jsonData,Integer orderSource) throws Exception {
    public JSONObject createOrder(String jsonData,Integer orderSource,String warnStr) throws Exception {
        logger.info("创建安防工单jsonData参数:" + jsonData);
        JSONObject result = new JSONObject();
@ -205,21 +207,23 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            }
        }
        //推送socket给医生  推送紧急预警
        JSONObject message = new JSONObject();
        message.put("session_id",sessionId);
        message.put("sender_name",orderDO.getPatientName());
        message.put("content_notice",orderDO.getPatientName()+" "+warnStr+"!");
        message.put("sender_code",orderDO.getPatient());
        message.put("OrderType",22);
        message.put("order_id",orderDO.getId());
        message.put("content_type",40);
        for (BaseDoctorDO doctorDO:doctorDOS){
            JSONObject message = new JSONObject();
            message.put("session_id",sessionId);
            message.put("sender_name",orderDO.getPatientName());
            message.put("content_notice",orderDO.getPatientName()+" 疑似离开安全区域!");
            message.put("sender_code",orderDO.getPatient());
            message.put("OrderType",22);
            message.put("order_id",orderDO.getId());
            message.put("content_type",40);
            try {
                imUtil.sendMDTSocketMessageToDoctor(doctorDO.getId(),message.toString());
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        //pc管理端端推送消息
        PcManageWebSocketService.broadCast(message.toString());
        result.put("resultFlag", 1);
        result.put("resultMsg",orderDO);
@ -295,6 +299,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            map.put("inFenceStatus",false);
            map.put("inFenceName","疑似超出安全区域");
            emergencyOrderVO.setInformation(map);
        }
        if(4==orderDO.getOrderSource()){//todo 监控画面
        }
        //通知对象
        List<Map<String,Object>> noticePersons = new ArrayList<>();
@ -432,7 +439,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return result;
    }
    public PageEnvelop getSecurityOrderList(String doctor, String serverDoctor, String patientName, String patient, String status, Integer page, Integer pageSize){
    public PageEnvelop getSecurityOrderList(String doctor, String serverDoctor, String patientName, String patient, String status,String topicItem, Integer page, Integer pageSize){
        String sqlCount = "select count(ord.id) from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
                "where 1=1 ";
        String fliter = "  ";
@ -457,6 +464,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        if (StringUtils.isNotBlank(status)){
            fliter+=" and ord.status='"+Integer.parseInt(status)+"' ";
        }
        if (StringUtils.isNotBlank(topicItem)){
            fliter+=" and ord.topic_item='"+topicItem+"' ";
        }
        Long count = jdbcTemplate.queryForObject(sqlCount+fliter,Long.class);
        fliter+=" order by ord.create_time desc limit " + (page*pageSize) + "," + pageSize;
        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql+fliter);
@ -1003,11 +1013,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return doorServiceOrder;
    }
    public List<Map<String,Object>> getSecurityServerDoctor(String patient){
    public List<Map<String,Object>> getSecurityServerDoctor(String patient,String topicItem){
        //获取患者签约防走失服务的团队
        String sql="SELECT DISTINCT i.team_code from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id   and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = '"+patient+"' and i.code='preventLost'";
                "and  sr.patient  = '"+patient+"' and i.code='"+topicItem+"'";
        List<String> teams = jdbcTemplate.queryForList(sql,String.class);
        List<Map<String,Object>> result = new ArrayList<>();
        if (teams.size()==0){

+ 15 - 13
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java

@ -98,7 +98,9 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
    public CapacityAssessmentRecordDO findAssessmentById(String id)  {
        CapacityAssessmentRecordDO recordDO = capacityAssessmentRecordDao.findOne(id);
        BasePatientDO basePatientDO = patientDao.findById(recordDO.getPatient());
        recordDO.setAge(IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
        if(recordDO.getAge()==null){
            recordDO.setAge(IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard()));
        }
        recordDO.setPhoto(basePatientDO.getPhoto());
        recordDO.setSexName(dictService.fingByNameAndCode(ConstantUtil.DICT_SEX,String.valueOf(recordDO.getSex())));
        recordDO.setServicePackageStatusName(dictService.fingByNameAndCode(ConstantUtil.DICT_SERVICEPACKAGESTATUS,String.valueOf(recordDO.getServicePackageStatus())));
@ -137,15 +139,6 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
            int c = Integer.valueOf(map.get("count").toString());
            res.put(String.valueOf(map.get("level_conclusion")),c);
        }
//        String sql2 = "SELECT COUNT(DISTINCT ar.id) from base_patient ar, " +
//                "base_service_package_sign_record sr,base_service_package_record r,  " +
//                "                base_service_package_item i,base_team_member m  " +
//                "                WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id  " +
//                "                and i.del = 1 and m.team_code = i.team_code and ar.id = sr.patient and ar.archive_type = 2 " +
//                "                and m.doctor_code = '"+doctorId+"' and m.del = '1' and sr.`status`=1";
//        Integer count = jdbcTemplate.queryForObject(sql2,Integer.class);
//        res.put("10",count);
        return res;
    }
@ -216,7 +209,16 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
        JSONObject result = new JSONObject();
        JSONObject jsonObject = JSONObject.parseObject(jsonData);
        CapacityAssessmentRecordDO recordDO = JSONObject.parseObject(jsonObject.getJSONObject("assessment").toJSONString(), CapacityAssessmentRecordDO.class);
        if(recordDO.getAge()==null){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"年龄必填");
            return result;
        }
        if(recordDO.getSex()==null){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"性别必填");
            return result;
        }
        if(isCapacityAssessment(recordDO.getPatient())==0){
            String year = DateUtil.getNowYear()+"";
            JSONObject obj = getAssessmentItemDetail(recordDO.getPatient(),0,year);
@ -229,7 +231,7 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
                String id = tmp.containsKey("id")?tmp.getString("id"):"";
                if (StringUtils.isBlank(id)){
                    result.put(ResponseContant.resultFlag, ResponseContant.fail);
                    result.put(ResponseContant.resultMsg,"患者存在未完成的评估表"+key);
                    result.put(ResponseContant.resultMsg,"居民存在未完成的评估表"+key);
                    finishFlag=false;
                    break;
                }
@ -262,7 +264,7 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
        }
        else{
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"患者今年已做过能力评估报告,不可重复操作");
            result.put(ResponseContant.resultMsg,"居民今年已做过能力评估报告,不可重复操作");
        }
        if(StringUtils.isNotBlank(recordDO.getPatient())){
            BasePatientDO patientDO= patientDao.findById(recordDO.getPatient());

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

@ -479,6 +479,34 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        return result;
    }
    /**
     * 获取患者签约服务包
     * @param patient
     * @return
     */
    public List<Map<String, Object>> servicePackageByPatient(String patient)
    {
       String sql="select  DISTINCT pack.*,CASE WHEN pack.type=1 THEN '养老服务' WHEN pack.type=2 THEN '医疗服务'\n" +
                "WHEN pack.type=3 THEN '安防监护' WHEN pack.type=4 THEN '慢病管理' ELSE pack.type\n" +
                "END as 'typeName' from base_service_package_record re, base_service_package_item item,base_service_package pack  \n" +
                "where re.service_package_id = item.service_package_id and item.service_package_id = pack.id and pack.del=1  and re.sign_id in (\n" +
                "select rd.id from base_service_package_sign_record rd  where rd.patient='"+patient+"' and rd.status=1) ";
        List<Map<String,Object>> resultSql = jdbcTemplate.queryForList(sql);
        return resultSql;
    }
    public List<Map<String, Object>> servicePackageByTopicType(String patient, String topicType)
    {
        String sql="\n" +
                "select  DISTINCT item.code serverItem,item.name,pack.introduce,pack.type packageType,pack.`name` packageName \n" +
                "from base_service_package_record re, base_service_package_item item,base_service_package pack \n" +
                "where re.service_package_id = item.service_package_id and item.service_package_id = pack.id\n" +
                " and pack.del=1 and  item.topic_item='"+topicType+"' and re.sign_id in (\n" +
                "select rd.id from base_service_package_sign_record rd  where rd.patient='"+patient+"' and rd.status=1) GROUP BY item.code; ";
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        return result;
    }
    public List<Map<String,Object>> getServerDoctorByPackage(String packageId,String serverItem){
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,\n" +
                "CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile\n" +

+ 396 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java

@ -1,9 +1,17 @@
package com.yihu.jw.care.service.statistics;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.vo.NumVo;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.es.util.ElasticsearchUtil;
import com.yihu.jw.es.util.SaveModel;
import com.yihu.jw.org.dao.BaseOrgDao;
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;
@ -11,7 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Calendar;
import java.util.*;
import java.util.stream.Collectors;
/**
 *
@ -26,14 +35,397 @@ public class StatisticsService {
    private ElasticsearchUtil elasticsearchUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private DictHospitalDeptDao hospitalDeptDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BaseOrgDao orgDao;
    @Autowired
    private StatisticsUtilService statisticsUtilService;
    private static final String defalutArea = "330100";
    /**
     * 统计首页头部数据
     * @param area
     * @param startDate
     * 2 市  3区  4医院 5、科室 6医生
     */
    private static final Integer defalutLevel = 2;
    /**
     * 统计总数
     * @param endDate
     * @return
     * @throws Exception
     */
    public JSONObject statisticsTotalAmount( String endDate) throws Exception {
        JSONObject res = new JSONObject();
        String index = "28,31,35,37,39,41,43,44";
        String[] indexes = index.split(",");
        for(String ind:indexes){
            //总量
            SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, ind, SaveModel.timeLevel_DDL);
            res.put("index_"+ind,saveModel.getResult2().longValue());
        }
        //评估类型
        res.put("capacityAssessment",capacityAssessment(endDate,defalutArea,defalutLevel));
        return res;
    }
    /**
     * 服务排名分析
     * @param endDate
     * @param orgType
     */
    public List<NumVo> serviceRankingAnalysis(String endDate, String orgType) throws Exception {
        String index = "28,35";
        if("3".equals(orgType)){
            index = "31,39,44";
        }
        String[] indexes = index.split(",");
        Map<String,NumVo> map = new HashedMap();
        for(String ind:indexes){
            //总量
            List<SaveModel> saveModels = elasticsearchUtil.findDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, ind, SaveModel.timeLevel_DDL,null,SaveModel.OrgLevel);
            for (SaveModel saveModel:saveModels){
                String orgCode = saveModel.getHospital();
                if(StringUtils.isBlank(orgCode)){
                    continue;
                }
                if(map.containsKey(orgCode)){
                    NumVo numVo = map.get(orgCode);
                    Long num = saveModel.getResult2().longValue()+numVo.getNum();
                    numVo.setNum(num);
                }else{
                    NumVo numVo = new NumVo();
                    numVo.setCode(orgCode);
                    numVo.setName(saveModel.getHospitalName());
                    numVo.setNum(saveModel.getResult2().longValue());
                    map.put(orgCode,numVo);
                }
            }
        }
        List<NumVo> list = new ArrayList<>();
        for (String key:map.keySet()){
            list.add(map.get(key));
        }
        list=list.stream().sorted(Comparator.comparing(NumVo::getNum).reversed()).collect(Collectors.toList());
        return list;
    }
    /**
     * 大屏实时数据 半小时刷新一次只能查数据库
     */
    public JSONObject realTimeData() throws Exception{
        JSONObject json = new JSONObject();
        //幼儿数
        String sql = "SELECT COUNT(DISTINCT patient) from base_doctor_patient_tmp WHERE del = 1 ";
        Integer childNum = jdbcTemplate.queryForObject(sql,Integer.class);
        json.put("childNum",childNum);
        //幼儿 服务次数
        String startDate = DateUtil.getNowYear()+"-01-01 00:00:00";
        String endDate = DateUtil.getStringDate();
        String sql28 = "SELECT COUNT(o.consult) FROM wlyy_consult_team o WHERE o.type = 23 and o.czrq >='"+startDate+"' ";
        String sql35 = "SELECT COUNT(o.patient) FROM base_door_coach_order o WHERE o.`status`=6  and o.update_time>='"+startDate+"' ";
        Integer num28 = jdbcTemplate.queryForObject(sql28,Integer.class);
        Integer num35 = jdbcTemplate.queryForObject(sql35,Integer.class);
        Integer childServiceNum = num28+num35;
        json.put("childServiceNum",childServiceNum);
        //老人 服务次数
        String sql31 = "SELECT COUNT(o.consult) FROM wlyy_consult_team o WHERE o.type = 24 and o.czrq >='"+startDate+"' ";
        String sql39 = "SELECT COUNT(o.patient) FROM base_life_care_order o WHERE o.`status`=2 and o.update_time>='"+startDate+"' ";
        String sql44 = "SELECT COUNT(o.id) FROM base_life_care_order o WHERE o.`status`>0 and o.type = 3 and o.update_time>='"+startDate+"' ";
        Integer num31 = jdbcTemplate.queryForObject(sql31,Integer.class);
        Integer num39 = jdbcTemplate.queryForObject(sql39,Integer.class);
        Integer num44 = jdbcTemplate.queryForObject(sql44,Integer.class);
        Integer olderServiceNum = num31 + num39 + num44;
        json.put("olderServiceNum",olderServiceNum);
        String signSql = " SELECT COUNT(sr.id) " +
                " FROM " +
                "  base_service_package_sign_record sr " +
                " WHERE " +
                "  sr.STATUS = 1 ";
        //当前签约老人数
        Integer signNum = jdbcTemplate.queryForObject(signSql,Integer.class);
        json.put("signNum",signNum);
        return json;
    }
    /**
     * 统计总数
     * @param endDate
     * @param area
     * @param level 2 市  3区  4医院 5、科室 6医生
     * @param index
     * @param type
     * @return
     * @throws Exception
     */
    public JSONObject statisticsTotalAmount( String endDate, String area, int level, String index, String type) throws Exception {
        JSONObject res = new JSONObject();
        String[] indexes = index.split(",");
        for(String ind:indexes){
            //总量
            SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, ind, SaveModel.timeLevel_DDL);
            res.put("index_"+ind+"_total",saveModel.getResult2().longValue());
            if(StringUtils.isNotBlank(type)){
                //周/月 增量
                String start = statisticsUtilService.calStart(endDate,type);
                SaveModel saveModelAdd = elasticsearchUtil.findOneDateQuotaLevel0(start, endDate, area, level, ind, SaveModel.timeLevel_ZL);
                res.put("index_"+ind+"_add",saveModelAdd.getResult2().longValue());
            }
        }
        return res;
    }
    /**
     * 咨询分析
     * type 1幼儿 2老人
     */
    public JSONObject consultAnalysis(String endDate, String area, int level, String type) throws Exception{
        JSONObject res = new JSONObject();
        String totalIndex = "28";
        String noReplyIndex = "29";
        String inTimeIndex = "30";
        if("2".equals(type)){
            totalIndex = "31";
            noReplyIndex = "32";
            inTimeIndex = "33";
        }
        //咨询总数
        SaveModel saveModel1 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, totalIndex, SaveModel.timeLevel_DDL);
        //未回复数
        SaveModel saveModel2 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, noReplyIndex, SaveModel.timeLevel_DDL);
        //及时回复数
        SaveModel saveModel3 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, inTimeIndex, SaveModel.timeLevel_DDL);
        res.put("total",saveModel1.getResult2().longValue());
        res.put("noReply",saveModel2.getResult2().longValue());
        res.put("inTime",saveModel3.getResult2().longValue());
        res.put("noReplyRate",statisticsUtilService.getTwoRange(saveModel2.getResult2(),saveModel1.getResult2()));
        res.put("inTimeRate",statisticsUtilService.getTwoRange(saveModel3.getResult2(),saveModel1.getResult2()));
        return res;
    }
    /**
     * 上门辅导分析
     */
    public JSONObject doorCoachAnalysis(String endDate, String area, int level) throws Exception{
        JSONObject res = new JSONObject();
        String totalIndex = "34";
        String noReplyIndex = "35";
        String inTimeIndex = "36";
        //幼儿数
        SaveModel saveModel1 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, totalIndex, SaveModel.timeLevel_DDL);
        //工单数
        SaveModel saveModel2 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, noReplyIndex, SaveModel.timeLevel_DDL);
        //服务费用
        SaveModel saveModel3 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, inTimeIndex, SaveModel.timeLevel_DDL);
        res.put("patientNum",saveModel1.getResult2().longValue());
        res.put("orderNum",saveModel2.getResult2().longValue());
        res.put("fee",saveModel3.getResult1());
        //服务项目分析
        JSONArray jsonArray = new JSONArray();
        List<SaveModel> list = statisticsUtilService.findDateAllQuotaLevel1Sort(endDate,endDate,area,level,inTimeIndex,SaveModel.timeLevel_DDL,null,null);
        for(int i=0;(i<list.size()&&i<5);i++){
            SaveModel saveModel = list.get(i);
            JSONObject json = new JSONObject();
            json.put("num",saveModel.getResult2().longValue());
            json.put("code",saveModel.getSlaveKey1());
            json.put("name",saveModel.getSlaveKey1Name());
            jsonArray.add(json);
        }
        res.put("items",jsonArray);
        return res;
    }
    /**
     * 上门辅导服务项目
     */
    public JSONArray doorCoachItems(String endDate, String area, int level) throws Exception{
        //服务项目分析
        JSONArray jsonArray = new JSONArray();
        List<SaveModel> list = statisticsUtilService.findDateAllQuotaLevel1Sort(endDate,endDate,area,level,"36",SaveModel.timeLevel_DDL,null,null);
        for(int i=0;i<list.size();i++){
            SaveModel saveModel = list.get(i);
            JSONObject json = new JSONObject();
            json.put("num",saveModel.getResult2().longValue());
            json.put("code",saveModel.getSlaveKey1());
            json.put("name",saveModel.getSlaveKey1Name());
            jsonArray.add(json);
        }
        return jsonArray;
    }
    /**
     * 通用增量趋势接口
     */
    public JSONArray addLine(String startDate,String endDate, String area, int level,String index,String timeLevel,String interval,String lowLevel)throws Exception{
        List<SaveModel> list = elasticsearchUtil.findDateQuotaLevel0(startDate,endDate,area,level,index,timeLevel,interval,lowLevel);
        JSONArray result = new JSONArray();
        for (SaveModel saveModel : list) {
            JSONObject range = new JSONObject();
            range.put("range", DateUtil.dateToStr(saveModel.getQuotaDate(), "yyyy-MM-dd"));
            range.put("amount", saveModel.getResult2());
            result.add(range);
        }
        return result;
    }
    /**
     * 居民分析
     */
    public JSONObject patientAnalysis(String endDate, String area, int level,String index) throws Exception{
        JSONObject res = new JSONObject();
        String areaLevel = "6";
        if("42".equals(index)){
            areaLevel = "4";
            //新生儿
            //是否入学
            List<SaveModel> statusList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL,null,null,areaLevel);
            JSONArray statusArray = new JSONArray();
            for(int i=0;i<statusList.size();i++){
                SaveModel saveModel = statusList.get(i);
                JSONObject json = new JSONObject();
                json.put("num",saveModel.getResult2().longValue());
                json.put("code",saveModel.getSlaveKey1());
                json.put("name",saveModel.getSlaveKey1Name());
                statusArray.add(json);
            }
            res.put("statusList",statusArray);
        }else{
            //老人
            //能力评估
            List<SaveModel> levelList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL,null,null,areaLevel);
            JSONArray levelArray = new JSONArray();
            for(int i=0;i<levelList.size();i++){
                SaveModel saveModel = levelList.get(i);
                JSONObject json = new JSONObject();
                json.put("num",saveModel.getResult2().longValue());
                json.put("code",saveModel.getSlaveKey1());
                json.put("name",saveModel.getSlaveKey1Name());
                levelArray.add(json);
            }
            res.put("levelList",levelArray);
            //年龄分布
            List<SaveModel> ageList = elasticsearchUtil.findDateAllQuotaLevel3(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL,null,null);
            JSONArray ageArray = new JSONArray();
            for(int i=0;i<ageList.size();i++){
                SaveModel saveModel = ageList.get(i);
                JSONObject json = new JSONObject();
                json.put("num",saveModel.getResult2().longValue());
                json.put("code",saveModel.getSlaveKey3());
                json.put("name",saveModel.getSlaveKey3Name());
                ageArray.add(json);
            }
            res.put("ageList",ageArray);
        }
        //性别
        List<SaveModel> sexList = elasticsearchUtil.findDateAllQuotaLevel2(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL,null,null,areaLevel);
        JSONArray sexArray = new JSONArray();
        for(int i=0;i<sexList.size();i++){
            SaveModel saveModel = sexList.get(i);
            JSONObject json = new JSONObject();
            json.put("num",saveModel.getResult2().longValue());
            json.put("code",saveModel.getSlaveKey2());
            json.put("name",saveModel.getSlaveKey2Name());
            sexArray.add(json);
        }
        res.put("sexList",sexArray);
        return res;
    }
    /**
     * 生活照料分析
     */
    public JSONObject lifeCareAnalysis(String endDate, String area, int level) throws Exception{
        JSONObject res = new JSONObject();
        String totalIndex = "38";
        String noReplyIndex = "39";
        String inTimeIndex = "40";
        //老人数
        SaveModel saveModel1 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, totalIndex, SaveModel.timeLevel_DDL);
        //工单数
        SaveModel saveModel2 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, noReplyIndex, SaveModel.timeLevel_DDL);
        //服务费用
        SaveModel saveModel3 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, inTimeIndex, SaveModel.timeLevel_DDL);
        res.put("patientNum",saveModel1.getResult2().longValue());
        res.put("orderNum",saveModel2.getResult2().longValue());
        res.put("fee",saveModel3.getResult1());
        //服务项目分析
        JSONArray jsonArray = new JSONArray();
        List<SaveModel> list = statisticsUtilService.findDateAllQuotaLevel1Sort(endDate,endDate,area,level,inTimeIndex,SaveModel.timeLevel_DDL,null,null);
        for(int i=0;(i<list.size()&&i<5);i++){
            SaveModel saveModel = list.get(i);
            JSONObject json = new JSONObject();
            json.put("num",saveModel.getResult2().longValue());
            json.put("code",saveModel.getSlaveKey1());
            json.put("name",saveModel.getSlaveKey1Name());
            jsonArray.add(json);
        }
        res.put("items",jsonArray);
        return res;
    }
    /**
     * 生活照料服务项目
     */
    public JSONArray lifeCareItems(String endDate, String area, int level) throws Exception{
        //服务项目分析
        JSONArray jsonArray = new JSONArray();
        List<SaveModel> list = statisticsUtilService.findDateAllQuotaLevel1Sort(endDate,endDate,area,level,"40",SaveModel.timeLevel_DDL,null,null);
        for(int i=0;i<list.size();i++){
            SaveModel saveModel = list.get(i);
            JSONObject json = new JSONObject();
            json.put("num",saveModel.getResult2().longValue());
            json.put("code",saveModel.getSlaveKey1());
            json.put("name",saveModel.getSlaveKey1Name());
            jsonArray.add(json);
        }
        return jsonArray;
    }
    /**
     * 能力评估评估类型
     */
    public JSONArray capacityAssessment(String endDate, String area, int level) throws Exception{
        //评估类型
        JSONArray jsonArray = new JSONArray();
        List<SaveModel> list = statisticsUtilService.findDateAllQuotaLevel1Sort(endDate,endDate,area,level,"37",SaveModel.timeLevel_DDL,null,null);
        for(int i=0;i<list.size();i++){
            SaveModel saveModel = list.get(i);
            JSONObject json = new JSONObject();
            json.put("num",saveModel.getResult2().longValue());
            json.put("code",saveModel.getSlaveKey1());
            json.put("name",saveModel.getSlaveKey1Name());
            jsonArray.add(json);
        }
        return jsonArray;
    }
        /**
         * 统计首页头部数据
         * @param area
         * @param startDate
         * @param endDate
         */
    public JSONObject indexTopNum(String area,String startDate,String endDate,Integer level){
        JSONObject re = new JSONObject();
        String signSql = " SELECT COUNT(sr.id) " +

+ 79 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsUtilService.java

@ -0,0 +1,79 @@
package com.yihu.jw.care.service.statistics;
import com.yihu.jw.es.util.ElasticsearchUtil;
import com.yihu.jw.es.util.SaveModel;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/6/11
 * @Description:
 */
@Service
public class StatisticsUtilService {
    @Autowired
    private ElasticsearchUtil elasticsearchUtil;
    public List<SaveModel> findDateAllQuotaLevel1Sort(String startDate, String endDate, String area, int level, String index, String timeLevel, String interval, String lowLevel) throws Exception {
        List<SaveModel> list = elasticsearchUtil.findDateAllQuotaLevel1(startDate,endDate,area,level,index,timeLevel,interval,lowLevel,"6");
        list.sort((a, b) -> Double.compare(b.getResult2(), a.getResult2()));
        return list;
    }
    /**
     * 计算开始时间
     * @param endDate
     * @param type 1周,2月
     * @return
     */
    public String calStart(String endDate,String type){
        if(StringUtils.isEmpty(endDate)){
            return endDate;
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(DateUtil.strToDate(endDate));
        if("1".equals(type)){
            if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){
                cal.add(Calendar.DAY_OF_WEEK,-1);
            }
            cal.set(Calendar.DAY_OF_WEEK,Calendar.MONDAY);
        }else{
            cal.set(Calendar.DAY_OF_MONTH,1);
        }
        return DateUtil.dateToStrShort(cal.getTime());
    }
    public Double getDoubleRange(Double first, Double second) {
        if (second == 0 && first > 0) {
            return 100.0;
        } else if (second == 0 && first == 0) {
            return 0.0;
        }
        Double size =first / second;
        DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
        Double filesize = Double.parseDouble(df.format(size));
        return filesize ;
    }
    public String getTwoRange(Double first, Double second) {
        if (second == 0 && first > 0) {
            return "100%";
        } else if (second == 0 && first == 0) {
            return "0%";
        }
        Double size = (first * 100) / second;
        DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
        String filesize = df.format(size);
        return filesize + "%";
    }
}

+ 196 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java

@ -0,0 +1,196 @@
package com.yihu.jw.care.service.third;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.course.CourseService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import org.apache.commons.lang.StringUtils;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * Created by Bing on 2021/6/16.
 */
@Service
public class PatientInfoPlatFormService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private ServicePackageService servicePackageService;
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
    private WlyyPatientLabelDao patientLabelDao;
    @Autowired
    private SecurityMonitoringOrderService securityMonitoringOrderService;
    @Autowired
    private CourseService courseService;
    @Autowired
    private LifeCareOrderService lifeCareOrderService;
    @Autowired
    private PatientDoorCoachOrderService patientDoorCoachOrderService;
    @Autowired
    private PatientHealthIndexService healthIndexService;
    /**
     * 老人--基本信息
     * @param patient
     * @param patientType 1老人 2新生儿
     * @return
     */
    public JSONObject getPatientInfo(String patient,Integer patientType){
        JSONObject result = new JSONObject();
        JSONObject tmp = new JSONObject();
        BasePatientDO patientDO = patientDao.findById(patient);
        if (patientDO!=null){
            tmp.put("name",patientDO.getName());
            tmp.put("sex",patientDO.getSex());
            tmp.put("address",patientDO.getAddress());
            tmp.put("address",patientDO.getAddress());
            tmp.put("patient",patientDO.getId());
            String idcard = patientDO.getIdcard();
            if (StringUtils.isNotBlank(idcard)){
                Integer age = IdCardUtil.getAgeForIdcard(idcard);
                tmp.put("age",age);
            }else {
                tmp.put("age",null);
            }
            //标签类型
            List<String> labelList = new ArrayList<>();
            Integer sex = patientDO.getSex();
            String sexName = sex!=null?(1==sex?"男":"女"):"未知";
            labelList.add(sexName);
            List<WlyyPatientLabelDO> labelDOS = patientLabelDao.findByPatient(patient);
            List<String> labeltmp = labelDOS.stream().map(WlyyPatientLabelDO::getLabelName).collect(Collectors.toList());
            labelList.addAll(labeltmp);
            tmp.put("patientLabel",labelList);
            result.put("patientInfo",tmp);//基本信息
            result.put("patientDevices",getDevices(patient,patientType));//健康设备
            if (1==patientType){
                result.put("signService",getSignService(patient));//签约服务
                result.put("MonitoringInfo",getPatientMonitoringInfo(patient));//安防监护信息
            }
            if (2==patientType){
                result.put("signService",getSignService(patient));//入园机构列表(报名且录取机构)
                result.put("MonitoringInfo",getMonitoringInfo(patient)); //新生儿入院信息
            }
            return result;
        }
        return null;
    }
    /**
     * 老人--获取签约服务
     * @param patient
     * @return
     */
    public List<Map<String,Object>> getSignService(String patient){
       List<Map<String,Object>> list =  servicePackageService.servicePackageByPatient(patient);
        return list;
    }
    /**
     * 新生儿--获取入园机构列表(报名且录取机构)
     * @param patient
     * @return
     */
    public List<Map<String,Object>> getEntranceOrgList(String patient){
        List<Map<String,Object>> list =  courseService.getEntranceOrgList(patient);
        return list;
    }
    /**
     * 老人/新生儿--获取健康设备
     * @param patient
     * @return
     */
    public List<Map<String,Object>> getDevices(String patient,Integer patientType){
        List<Map<String,Object>> list = patientDeviceService.patientDeviceListByTopic(patient,null);
        return list;
    }
    /**
     * 老人/新生儿--获取就诊事件  暂无
     * @param patient
     * @return
     */
    public JSONObject getPatientEvent(String patient,Integer patientType,Integer page,Integer pageSize){
        return null;
    }
    /**
     * 老人/新生儿--患病情况 暂无
     * @param patient
     * @param patientType
     * @return
     */
    public JSONObject getIllnessInfo(String patient,Integer patientType){
        return null;
    }
    /**
     * 老人/新生儿--服务工单列表
     * @param patient
     * @param patientType
     * @return
     */
    public JSONObject getServiceOrder(String patient, Integer patientType, Integer page, Integer pageSize) throws Exception {
        if (1==patientType){//老人 生活照料
            return lifeCareOrderService.getPatientOrderList2(patient,null,page,pageSize);
        }
        if (2==patientType){//新生儿 上门辅导
            return patientDoorCoachOrderService.getDoorOrderList(null,null,null,null,
                    null,null,null,null,patient,page,pageSize, null);
        }
        return null;
    }
    /**
     * 老人/新生儿-- 体征信息
     * 老人:血糖、血压、身高体重、心率
     * 新生儿:体温
     * @param patient
     * @return
     */
    public JSONArray getHealthIndexInfo(String patient, int type, int gi_type, String begin, String end){
       return healthIndexService.findChartByPatient(patient,type,gi_type,begin,end);//图表
    }
    /**
     * 老人-- 安防监护信息
     * @param patient
     * @return
     */
    public JSONObject getPatientMonitoringInfo(String patient){
        return securityMonitoringOrderService.patientMonitoringInfo(patient);
    }
    /**
     * 新生儿-- 入园监护 暂无
     * @param patient
     * @return
     */
    public JSONObject getMonitoringInfo(String patient){
        return null;
    }
}

+ 40 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PcManageWebSocketService.java

@ -0,0 +1,40 @@
package com.yihu.jw.care.service.third;
import com.yihu.jw.care.endpoint.third.platForm.PcManageWebSocketServer;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
/**
 * Created by Bing on 2021/6/17.
 */
@Service
public class PcManageWebSocketService {
    private static Collection<PcManageWebSocketServer> servers = Collections.synchronizedCollection(new ArrayList<PcManageWebSocketServer>());
    public static void broadCast(String msg){
        for (PcManageWebSocketServer serverTmp : servers) {
            try {
                serverTmp.sendMessage(msg);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    public static int getTotal(){
        return servers.size();
    }
    public static void add(PcManageWebSocketServer server){
        System.out.println("有新连接加入! 当前总连接数是:"+ servers.size());
        servers.add(server);
    }
    public static void remove(PcManageWebSocketServer server){
        System.out.println("有连接退出! 当前总连接数是:"+ servers.size());
        servers.remove(server);
    }
}

+ 267 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/EntranceUtil.java

@ -0,0 +1,267 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.course.CourseDao;
import com.yihu.jw.care.dao.course.CourseSalesOrderRecordDao;
import com.yihu.jw.care.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.care.dao.course.RecruitStudentsRecordDao;
import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachOrderDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.care.course.CourseDO;
import com.yihu.jw.entity.care.course.CourseSalesOrderRecordDO;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.im.dao.ConsultTeamDao;
import io.swagger.models.auth.In;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.swing.table.TableModel;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
 * 教师与新生儿 入学关系更新工具
 * Created by Bing on 2021/6/11.
 */
@Component
public class EntranceUtil {
    @Autowired
    private DoctorPatientTmpDao doctorPatientTmpDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private RecruitStudentsRecordDao recruitStudentsRecordDao;
    @Autowired
    private BaseDoorCoachOrderDao doorCoachOrderDao;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private CourseDao courseDao;
    @Autowired
    private CourseSalesOrderRecordDao courseSalesOrderRecordDao;
    /**
     *
     * @param patient
     * @param type
     * @param del
     * @param doctorCode
     * @param orgCode
     * @param relationCode
     */
    public void newRecord(String patient,Integer type,Integer del,String doctorCode,String orgCode,String relationCode){
        if (1==type||2==type){//在线咨询与上门辅导不重复保存
            if (doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(patient,doctorCode,type)!=0){
                return ;
            }
        }
        DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
        tmpDO.setPatient(patient);
        tmpDO.setType(type);
        tmpDO.setDel(del);
        tmpDO.setStatus(0);
        if (StringUtils.isBlank(orgCode)){
            List<BaseDoctorHospitalDO> list = doctorHospitalDao.findByDoctorCode(doctorCode);
            if (list.size()>0){
                orgCode = list.get(0).getOrgCode();
            }
        }
        if (doctorPatientTmpDao.findByPatientAndOrgCodeAndTypeAndStatus(patient,orgCode,3,1)!=0){
            tmpDO.setDel(0);
        }
        tmpDO.setOrgCode(orgCode);
        tmpDO.setDoctorCode(doctorCode);
        tmpDO.setRelationCode(relationCode);
        doctorPatientTmpDao.save(tmpDO);
    }
    /**
     * 更新状态 状态为1 已入学,将该幼儿咨询、上门、课程数据失效
     * @param relationCode
     */
    public void updateStatus(Integer status,String relationCode){
        DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(relationCode);
        if (tmpDO!=null){
            tmpDO.setStatus(status);
            doctorPatientTmpDao.save(tmpDO);
            if (status==1){//入学后 将该幼儿咨询、上门、课程数据失效
                List<DoctorPatientTmpDO> list = doctorPatientTmpDao.queryByPatientAndTypeIn(tmpDO.getPatient(),new Integer[]{1,2,4});
                List<String> relationCodes  = list.stream().map(DoctorPatientTmpDO::getRelationCode).collect(Collectors.toList());
                deleteRecord2List(relationCodes);
            }
        }
    }
    /**
     * 更新状态
     * @param relationCode
     */
    public void updateStatus2(Integer status,String[] relationCode) {
        List<DoctorPatientTmpDO> list = new ArrayList<>();
        List<String>relationCodes = new ArrayList<>();
        for (String id : relationCode) {
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
            if (tmpDO != null) {
                tmpDO.setStatus(status);
                list.add(tmpDO);
                if (status==1){//入学后 将该幼儿咨询、上门、课程数据失效
                    List<DoctorPatientTmpDO> listTmp = doctorPatientTmpDao.queryByPatientAndTypeIn(tmpDO.getPatient(),new Integer[]{1,2,4});
                    List<String> relationCodeTmp  = list.stream().map(DoctorPatientTmpDO::getRelationCode).collect(Collectors.toList());
                    relationCodes.addAll(relationCodeTmp);
                }
            }
        }
        doctorPatientTmpDao.save(list);
        deleteRecord2List(relationCodes);
    }
    /**
     * 删除记录 单条
     * @param relationCode
     */
    public void deleteRecord(String relationCode){
        DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(relationCode);
        if (tmpDO!=null){
            tmpDO.setDel(0);
            doctorPatientTmpDao.save(tmpDO);
        }
        doctorPatientTmpDao.save(tmpDO);
    }
    /**
     * 删除记录
     * @param relationCode
     */
    public void deleteRecord2(String[] relationCode){
        List<DoctorPatientTmpDO> list = new ArrayList<>();
        for (String id : relationCode) {
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
            if (tmpDO!=null){
                tmpDO.setDel(0);
            }
        }
        doctorPatientTmpDao.save(list);
    }
    /**
     * 删除记录
     * @param relationCode
     */
    public void deleteRecord2List(List<String> relationCode){
        List<DoctorPatientTmpDO> list = new ArrayList<>();
        for (String id : relationCode) {
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
            if (tmpDO!=null){
                tmpDO.setDel(0);
            }
        }
        doctorPatientTmpDao.save(list);
    }
    /**
     * 初始化数据
     */
    public void initData(){
        List<DoctorPatientTmpDO> saveList = new ArrayList<>();
        //入学
        List<RecruitStudentsRecordDO> enList = recruitStudentsRecordDao.findByDelAndStatus(1,"2");
        List<String> patients = enList.stream().map(RecruitStudentsRecordDO::getPatient).collect(Collectors.toList());
        for (RecruitStudentsRecordDO tmp:enList){
            DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
            tmpDO.setPatient(tmp.getPatient());
            tmpDO.setType(3);
            tmpDO.setDel(1);
            tmpDO.setStatus(1);
            tmpDO.setOrgCode(tmp.getOrgCode());
            tmpDO.setRelationCode(tmp.getId());
            saveList.add(tmpDO);
        }
        //上门
        List<BaseDoorCoachOrderDO> doorlist = doorCoachOrderDao.queryByStatusIn(new Integer[]{3,4,5,6,});
        for (BaseDoorCoachOrderDO tmp:doorlist){
            DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
            tmpDO.setPatient(tmp.getPatient());
            tmpDO.setType(2);
            if (patients.contains(tmp.getPatient())){
                tmpDO.setDel(0);
            }
            else {
                tmpDO.setDel(1);
            }
            tmpDO.setStatus(0);
            tmpDO.setDoctorCode(tmp.getDoctor());
            tmpDO.setOrgCode(tmp.getHospital());
            tmpDO.setRelationCode(tmp.getId());
            saveList.add(tmpDO);
        }
        //咨询
        List<ConsultTeamDo> consultList = consultTeamDao.findByTypeAndDel(23,"1");
        for (ConsultTeamDo tmp:consultList){
            DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
            tmpDO.setPatient(tmp.getPatient());
            tmpDO.setType(1);
            if (patients.contains(tmp.getPatient())){
                tmpDO.setDel(0);
            }
            else {
                tmpDO.setDel(1);
            }
            tmpDO.setStatus(0);
            tmpDO.setDoctorCode(tmp.getDoctor());
            if (StringUtils.isNotBlank(tmp.getDoctor())){
                List<BaseDoctorHospitalDO> list = doctorHospitalDao.findByDoctorCode(tmp.getDoctor());
                if (list.size()>0){
                    tmpDO.setOrgCode(list.get(0).getOrgCode());
                }
            }
            tmpDO.setRelationCode(tmp.getConsult());
            saveList.add(tmpDO);
        }
        //课程
        List<CourseSalesOrderRecordDO> courseList = courseSalesOrderRecordDao.findByStatus("2");
        for (CourseSalesOrderRecordDO tmp:courseList){
            DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
            tmpDO.setPatient(tmp.getPatient());
            tmpDO.setType(4);
            if (patients.contains(tmp.getPatient())){
                tmpDO.setDel(0);
            }
            else {
                tmpDO.setDel(1);
            }
            tmpDO.setStatus(0);
            CourseDO courseDO = courseDao.findOne(tmp.getCourseId());
            if (courseDO!=null){
                tmpDO.setDoctorCode(courseDO.getDoctor());
            }
            tmpDO.setOrgCode(tmp.getOrgCode());
            tmpDO.setRelationCode(tmp.getId());
            saveList.add(tmpDO);
        }
        for (DoctorPatientTmpDO tmp:saveList){
            if (1==tmp.getType()||2==tmp.getType()){//在线咨询与上门辅导不重复保存
                if (doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(tmp.getPatient(),tmp.getDoctorCode(),tmp.getType())!=0){
                    continue;
                }
            }
            doctorPatientTmpDao.save(tmp);
        }
    }
    /**
     * 清除所有数据
     */
    public void deleteAll(){
        doctorPatientTmpDao.deleteAll();
    }
}

+ 41 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/vo/NumVo.java

@ -0,0 +1,41 @@
package com.yihu.jw.care.vo;
import java.io.Serializable;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/6/16
 * @Description:
 */
public class NumVo implements Serializable{
    private Long num;
    private String code;
    private String name;
    public Long getNum() {
        return num;
    }
    public void setNum(Long num) {
        this.num = num;
    }
    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;
    }
}

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

@ -245,8 +245,8 @@ es:
  type:
    Statistics: hlw_quota_test
    FollowUpContent: wlyy_followup_content
  host:  http://172.26.0.55:9000
  tHost: 172.26.0.55:9300
  host:  http://172.26.0.112:9000
  tHost: 172.26.0.112:9300
  clusterName: jkzl
  securityUser: lion:jkzlehr
  user: lion

+ 3 - 1
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

@ -263,15 +263,17 @@ public class DeviceService {
                                jsonObject.put("patient",patientDO.getId());
                                jsonObject.put("patientName",patientDO.getName());
                                jsonObject.put("patientPhone",patientDO.getMobile());
                                jsonObject.put("serveDesc","疑似离开安全区域");
                                jsonObject.put("serveDesc","疑似离开安全区域!");
                                jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
                                jsonObject.put("serveAddress",address.replace(" ",""));
                                jsonObject.put("serveLat",lat);
                                jsonObject.put("serveLon",lon);
                                jsonObject.put("topicItem","preventLost");
                                JSONObject jsonObjectParam = new JSONObject();
                                jsonObjectParam.put("order", jsonObject);
                                map.put("jsonData", jsonObjectParam.toJSONString());
                                map.put("orderSource", 2);
                                map.put("warnStr", "疑似离开安全区域");
                                content = com.alibaba.fastjson.JSONObject.toJSONString(map);
                                postParams = AesEncryptUtils.agEncrypt(content);

+ 100 - 1
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java

@ -3,17 +3,28 @@ package com.yihu.jw.care.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.config.YsConfig;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.encode.Base64;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import javax.servlet.http.HttpServletRequest;
import java.security.Security;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -24,6 +35,16 @@ public class YsDeviceService {
    private static Logger logger = LoggerFactory.getLogger(YsDeviceService.class);
    private Map<String,String> msgType = new HashMap<>();
    @Value("${cloudCare.url}")
    private String cloudCareUrl;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
     * 消息推送
@ -51,16 +72,94 @@ public class YsDeviceService {
        JSONObject result = new JSONObject();
        try {
            String decodeStr = messageDecrypt(message,YsConfig.msgDataKey);
            decodeStr = StringEscapeUtils.unescapeJava(decodeStr);
            result = JSONObject.parseObject(decodeStr);
            JSONArray tmpArr = result.getJSONObject("eps").getJSONArray("alert");
            boolean fallFlag = false;
            String deviceSN = null;
            String sceneUrl = "";
            for (int i=0;i<tmpArr.size();i++){
                JSONObject tmpObj = tmpArr.getJSONObject(i);
                String msgType = tmpObj.getString("msgType");
                if (this.msgType.containsKey(msgType)){
                    tmpObj.put("msgTypeName",this.msgType.get(msgType));
                }
                if ("10005".equals(msgType)){//报警消息
                    String bodyStr = tmpObj.getString("body");
                    if (StringUtils.isNotBlank(bodyStr)){
                        JSONObject bodyJsonObj = JSONObject.parseObject(bodyStr);
                        if (bodyJsonObj!=null&&bodyJsonObj.containsKey("body")){
                            JSONObject bodyJsonObj2 = bodyJsonObj.getJSONObject("body");
                            if (bodyJsonObj2!=null&&bodyJsonObj2.containsKey("alarmType")){
                                String alarmType = bodyJsonObj2.getString("alarmType");
                                if ("tumble_detection".equals(alarmType)){//tumble_detection跌倒类型    //有人出现SmartHumanDet
                                    fallFlag = true;
                                    deviceSN = bodyJsonObj2.getString("devSerial");//设备SN
                                    if (bodyJsonObj2.containsKey("pictureList")&&bodyJsonObj2.getJSONArray("pictureList")!=null){
                                        JSONArray pictureList = bodyJsonObj2.getJSONArray("pictureList");
                                        if (pictureList.size()>0){
                                            JSONObject tmp = pictureList.getJSONObject(0);
                                            sceneUrl = tmp.getString("url");//现场照片
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (fallFlag){//发起安防工单
                String lat = "";
                String lon = "";
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(deviceSN);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
                    Map<String, String> json = null;
                    if (org.apache.commons.lang.StringUtils.isNotBlank(deviceDO.getSosAddress())) {
                        json = LatitudeUtils.getGeocoderLatitude(deviceDO.getSosAddress().replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
                    }
                    if (json != null) {
                        lat = json.get("lat").toString();
                        lon = json.get("lng").toString();
                    }
                    BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
                    String  url = cloudCareUrl+"/cloudCare/noLogin/security/createOrder";
                    Map map = new HashMap<String, String>();
                    map = new HashMap();
                    String sql ="select DISTINCT item.org_code,item.org_name\n" +
                            " from base_service_package_sign_record sr,base_service_package_record pr,base_service_package_item item ,base_service_package pack\n" +
                            "where pr.patient = '"+patientDO.getId()+"' and sr.id = pr.sign_id and pr.service_package_id = item.service_package_id \tand  item.`code`='preventFall'  and item.service_package_id = pack.id \n" +
                            "  and pack.del=1";
                    List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("patient",patientDO.getId());
                    jsonObject.put("patientName",patientDO.getName());
                    jsonObject.put("patientPhone",patientDO.getMobile());
                    jsonObject.put("serveDesc","疑似跌倒!");
                    jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
                    jsonObject.put("serveAddress",deviceDO.getSosAddress());
                    jsonObject.put("serveLat",lat);
                    jsonObject.put("serveLon",lon);
                    jsonObject.put("topicItem","preventFall");
                    jsonObject.put("sceneImg",sceneUrl);
                    JSONObject jsonObjectParam = new JSONObject();
                    jsonObjectParam.put("order", jsonObject);
                    map.put("jsonData", jsonObjectParam.toJSONString());
                    map.put("orderSource", 4);
                    map.put("warnStr", "疑似跌倒");
                    String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
                    String postParams = AesEncryptUtils.agEncrypt(content);
                    String response = httpClientUtil.postBodyRawForm(url,postParams);
                    result = com.alibaba.fastjson.JSONObject.parseObject(response);
                    JSONObject jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
                    System.out.println(jsonObjectData.toJSONString());
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        logger.info("萤石摄像机消息推送:"+result.toString());
        return result;
@ -75,7 +174,7 @@ public class YsDeviceService {
     * @return
     * @throws Exception
     */
    public String messageDecrypt(String sSrc, String sKey) throws Exception {
    public static String messageDecrypt(String sSrc, String sKey) throws Exception {
        try {
            byte[] raw = sKey.getBytes("utf-8");
            Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

+ 34 - 0
svr/svr-statistics-es/doc/sql/初始统计数据.txt

@ -0,0 +1,34 @@
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f4d23c0179f4f6fd9c0001', NULL, 'quota_org_type', '28', '4', '', '1', NULL, '2021-06-10 16:08:18.076', '123', NULL, '2021-06-10 16:08:18.076', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f4d23c0179f4f729170002', NULL, 'quota_org_type', '29', '4', '', '2', NULL, '2021-06-10 16:08:29.207', '123', NULL, '2021-06-10 16:08:29.207', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f4d23c0179f4f754fc0003', NULL, 'quota_org_type', '30', '4', '', '3', NULL, '2021-06-10 16:08:40.444', '123', NULL, '2021-06-10 16:08:40.444', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f4d23c0179f4f7ab640004', NULL, 'quota_org_type', '31', '3', '', '4', NULL, '2021-06-10 16:09:02.564', '123', NULL, '2021-06-10 16:09:02.564', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f4d23c0179f4f7d0ec0005', NULL, 'quota_org_type', '32', '3', '', '5', NULL, '2021-06-10 16:09:12.172', '123', NULL, '2021-06-10 16:09:12.172', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f4d23c0179f4f7f09e0006', NULL, 'quota_org_type', '33', '3', '', '6', NULL, '2021-06-10 16:09:20.286', '123', NULL, '2021-06-10 16:09:20.286', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f4d23c0179f4f837f30007', NULL, 'quota_org_type', '34', '4', '', '7', NULL, '2021-06-10 16:09:38.547', '123', NULL, '2021-06-10 16:09:38.547', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f4d23c0179f4f856d40008', NULL, 'quota_org_type', '35', '4', '', '8', NULL, '2021-06-10 16:09:46.452', '123', NULL, '2021-06-10 16:09:46.452', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f4d23c0179f4f884be0009', NULL, 'quota_org_type', '36', '4', '', '9', NULL, '2021-06-10 16:09:58.205', '123', NULL, '2021-06-10 16:09:58.205', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d12f670007', NULL, 'quota_org_type', '37', '3', '', '37', NULL, '2021-06-11 14:45:06.535', '123', NULL, '2021-06-11 14:45:06.535', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d155bc0008', NULL, 'quota_org_type', '38', '3', '', '38', NULL, '2021-06-11 14:45:16.348', '123', NULL, '2021-06-11 14:45:16.348', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d17e420009', NULL, 'quota_org_type', '39', '3', '', '3', NULL, '2021-06-11 14:45:26.722', '123', NULL, '2021-06-11 14:45:26.722', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d19ec9000a', NULL, 'quota_org_type', '40', '3', '', '40', NULL, '2021-06-11 14:45:35.049', '123', NULL, '2021-06-11 14:45:35.049', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d19ec9001a', NULL, 'quota_org_type', '41', '3', '', '41', NULL, '2021-06-11 14:45:35.049', '123', NULL, '2021-06-11 14:45:35.049', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f9fbb6017a12c67cab0001', NULL, 'quota_org_type', '42', '4', '', '42', NULL, '2021-06-16 11:03:55.819', '123', NULL, '2021-06-16 11:03:55.819', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f9fbb6017a143681370005', NULL, 'quota_org_type', '43', '3', '', '43', NULL, '2021-06-16 17:45:54.231', '123', NULL, '2021-06-16 17:45:54.231', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f9fbb6017a1436b1ea0006', NULL, 'quota_org_type', '44', '3', '', '44', NULL, '2021-06-16 17:46:06.698', '123', NULL, '2021-06-16 17:46:06.698', '123', NULL, '', '统计机构类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d2be41000c', NULL, 'quota_age', '0', '60岁以下', '', '0', NULL, '2021-06-11 14:46:48.641', '123', NULL, '2021-06-11 14:46:48.641', '123', NULL, '', '统计年龄类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d30558000d', NULL, 'quota_age', '1', '60-65', '', '1', NULL, '2021-06-11 14:47:06.84', '123', NULL, '2021-06-11 14:47:06.84', '123', NULL, '', '统计年龄类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d32af6000e', NULL, 'quota_age', '2', '66-70', '', '2', NULL, '2021-06-11 14:47:16.469', '123', NULL, '2021-06-11 14:47:16.469', '123', NULL, '', '统计年龄类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d3585f000f', NULL, 'quota_age', '3', '71-75', '', '3', NULL, '2021-06-11 14:47:28.094', '123', NULL, '2021-06-11 14:47:28.094', '123', NULL, '', '统计年龄类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d3897e0010', NULL, 'quota_age', '4', '76-80', '', '4', NULL, '2021-06-11 14:47:40.67', '123', NULL, '2021-06-11 14:47:40.67', '123', NULL, '', '统计年龄类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9d3b5fb0011', NULL, 'quota_age', '5', '80岁以上', '', '5', NULL, '2021-06-11 14:47:52.058', '123', NULL, '2021-06-11 14:47:52.058', '123', NULL, '', '统计年龄类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9cfce630005', NULL, 'quota_sex', '1', '男', '', '1', NULL, '2021-06-11 14:43:36.162', '123', NULL, '2021-06-11 14:43:36.162', '123', NULL, '', '统计性别');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f8cbf90179f9cfe9e00006', NULL, 'quota_sex', '2', '女', '', '2', NULL, '2021-06-11 14:43:43.2', '123', NULL, '2021-06-11 14:43:43.2', '123', NULL, '', '统计性别');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f9fbb6017a12cc48d60003', NULL, 'is_add_school', '1', '已入学', '', '1', NULL, '2021-06-16 11:10:15.766', '123', NULL, '2021-06-16 11:10:15.766', '123', NULL, '', '是否入学');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('808080eb79f9fbb6017a12cc703a0004', NULL, 'is_add_school', '0', '未入学', '', '2', NULL, '2021-06-16 11:10:25.849', '123', NULL, '2021-06-16 11:10:25.849', '123', NULL, '', '是否入学');

文件差異過大導致無法顯示
+ 0 - 192
svr/svr-statistics-es/doc/sql/统计相关表数据备份20171121.txt


+ 69 - 30
svr/svr-statistics-es/pom.xml

@ -308,23 +308,11 @@
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator-docs</artifactId>
        </dependency>
        <!--<dependency>-->
        <!--<groupId>org.springframework.boot</groupId>-->
        <!--<artifactId>spring-boot-devtools</artifactId>-->
        <!--<version>${version.spring-boot}</version>-->
        <!--</dependency>-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
@ -418,37 +406,88 @@
        <!--<artifactId>spring-boot-starter-data-elasticsearch</artifactId>-->
        <!--<version>1.3.5.RELEASE</version>-->
        <!--</dependency>-->
        <!--oracle驱动-->
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>svr-statistics-es</finalName>
        <plugins>
            <!--打成war包需要的配置-->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <archive>
                        <!-- 生成的jar中,不要包含pom.xml和pom.properties这两个文件 -->
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <manifest>
                            <!-- 是否要把第三方jar加入到类构建路径 -->
                            <addClasspath>true</addClasspath>
                            <!-- 外部依赖jar包的最终位置 -->
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>com.yihu.wlyy.Application</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!--拷贝依赖到jar外面的lib目录-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-lib</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <!-- 依赖包输出目录,将来不打进jar包里 -->
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <excludeTransitive>false</excludeTransitive>
                            <stripVersion>false</stripVersion>
                            <includeScope>runtime</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--指定配置文件,将resources打成外部resource-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <archive>
                        <!-- 指定配置文件目录,这样jar运行时会去找到同目录下的resources文件夹下查找 -->
                        <manifestEntries>
                            <Class-Path>resources/</Class-Path>
                        </manifestEntries>
                    </archive>
                    <!-- 打包时忽略的文件(也就是不打进jar包里的文件) -->
                    <excludes>
                        <exclude>**/*.yml</exclude>
                        <exclude>**/*.xml</exclude>
                    </excludes>
                </configuration>
                <version>3.1</version>
            </plugin>
            <!-- 拷贝资源文件 外面的resource目录-->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <!-- 资源文件输出目录 -->
                            <outputDirectory>${project.build.directory}/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

+ 0 - 245
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/compute/ComputeHelper.java

@ -1,245 +0,0 @@
package com.yihu.jw.statistics.etl.compute;
import com.yihu.jw.statistics.util.DateUtil;
import com.yihu.jw.statistics.vo.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import java.util.*;
/**
 * Created by chenweida on 2017/6/1.
 */
@Component
@Scope("prototype")
public class ComputeHelper {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * @param dataModels      过滤之后的数据
     * @param dimensionQuotas 指标的维度
     * @param wlyyJobCongId
     * @param endTime
     * @return
     */
    public List<SaveModel> compute(List<DataModel> dataModels, List<BaseDimensionQuota> dimensionQuotas, String wlyyJobCongId, String endTime, String timeLevel) {
        try {
            //得到全部团队
            List<BaseDoctorDO> doctors = findAllDoctor();
            //计算数据 返回map key 根据团队和维度拼凑在map中的key   1-2-1  如果维度是长度是0返回团队id 1
            Map<String, List<DataModel>> computeMap = computeDataModel(dimensionQuotas, dataModels);
            //初始化map并且设置统计出来的数目
            List<SaveModel> savemodels = initAndSetResult(doctors, dimensionQuotas, computeMap, wlyyJobCongId, endTime, timeLevel);
            return savemodels;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * //计算数据 返回map
     *
     * @param dataModels      过滤过后的元数据
     * @param dimensionQuotas 该指标的维度
     * @return
     */
    private Map<String, List<DataModel>> computeDataModel(List<BaseDimensionQuota> dimensionQuotas, List<DataModel> dataModels) {
        Map<String, List<DataModel>> returnMap = new HashMap<>();
        dataModels.stream().forEach(one -> {
            String key = getKey(one, dimensionQuotas.size());
            List<DataModel> sms = new ArrayList<DataModel>();
            if (returnMap.containsKey(key)) {
                sms = returnMap.get(key);
            }
            sms.add(one);
            returnMap.put(key, sms);
        });
        return returnMap;
    }
    /**
     * 获取key  根据团队和维度拼凑在map中的key   1-2-1  如果维度是长度是0返回团队id 1
     *
     * @param one
     * @param size
     * @return
     */
    private String getKey(DataModel one, int size) {
        try {
            if (size > 0) {
                StringBuffer str = new StringBuffer(one.getDoctor());
                for (int i = 1; i <= size; i++) {
                    String invokeKey = (String) DataModel.class.getMethod("getSlaveKey" + i).invoke(one);
                    str.append("-" + invokeKey);
                }
                return str.toString();
            } else {
                return one.getDoctor();
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 得到全部医生
     *
     * @return
     */
    private List<BaseDoctorDO> findAllDoctor() {
        String sql = "SELECT " +
                "bd.id AS code , " +
                "bd.name ," +
                "bdh.dept_code," +
                "hd.name AS dept_name," +
                "bdh.org_code," +
                "bdh.org_name," +
                "o.town_code," +
                "o.town_name" +
                " FROM " +
                "base_doctor_hospital bdh, " +
                "base_doctor bd," +
                "base_org o," +
                "dict_hospital_dept hd " +
                " WHERE bdh.doctor_code = bd.id  " +
                "AND hd.code= bdh.dept_code " +
                "AND o.code = bdh.org_code " +
                "AND bdh.del=1 AND hd.CONSULT_DEPT_FLAG='1' AND bd.job_title_code IN('1201','1301','1401','1101','066','067','061','1310','061','065','1','2','3','4')";
        List<BaseDoctorDO> doctorDOS = jdbcTemplate.query(sql, new BeanPropertyRowMapper(BaseDoctorDO.class));
        return doctorDOS;
    }
    public static void main(String[] args) {
        System.out.println("3502060200".substring(0, 8));
    }
    /**
     * 初始化map
     */
    private List<SaveModel> initAndSetResult(List<BaseDoctorDO> doctors, List<BaseDimensionQuota> dimensionQuotas, Map<String, List<DataModel>> countMap, String wlyyJobCongId, String endTime, String timeLevel) throws Exception {
        List<SaveModel> returnList = new ArrayList<>();
        Map<String, SaveModel> lastMaps = new HashMap<>();
        //初始化医生的数据
        for (int i = 0; i < doctors.size(); i++) {
            BaseDoctorDO one = doctors.get(i);
            //排除测试机构
            if (one.getOrgCode().length() >= 11) {
                SaveModel saveModel = new SaveModel();
                saveModel.setCity("350200");
                saveModel.setCityName("厦门市");
                saveModel.setTown(one.getTownCode());
                saveModel.setTownName(one.getTownName());
                //把末尾不是00的机构转换成00
                String orgCode = one.getOrgCode();
                saveModel.setHospital(orgCode);
                saveModel.setHospitalName(one.getOrgName());
                saveModel.setDoctor(one.getCode());
                saveModel.setDoctorName(one.getName());
                saveModel.setDept(one.getDeptCode());
                saveModel.setDeptName(one.getDeptName());
                saveModel.setQuotaCode(wlyyJobCongId);
                saveModel.setCreateTime(new Date());
                saveModel.setTimeLevel(timeLevel);
                saveModel.setAreaLevel("6");//医生
                saveModel.setQuotaDate(DateUtil.strToDate(endTime, "yyyy-MM-dd"));
                lastMaps.put(one.getCode(), saveModel);
            }
        }
        //根据维度初始化数据
            for (int i = 0; i < dimensionQuotas.size(); i++) {
                Map<String, SaveModel> mapTemp = new HashMap<>();
                BaseDimensionQuota dimensionQuota = dimensionQuotas.get(i);
//                List<DictModel> dictModels = jdbcTemplate.query(dimensionQuota.getDictSql(), new BeanPropertyRowMapper(DictModel.class));
                List<Map<String, Object>> listMap = jdbcTemplate.queryForList(dimensionQuota.getDictSql());
                for (Map.Entry<String, SaveModel> oneSaveModel : lastMaps.entrySet()) {
                    for (int j = 0; j < listMap.size(); j++) {
                        SaveModel saveModelTemp = new SaveModel();
                        Map<String, Object> dictModel = listMap.get(j);
                        BeanUtils.copyProperties(oneSaveModel.getValue(), saveModelTemp);
                        SaveModel.class.getMethod("setSlaveKey" + (i + 1) + "Name", String.class).invoke(saveModelTemp, dictModel.get("name"));
                        SaveModel.class.getMethod("setSlaveKey" + (i + 1), String.class).invoke(saveModelTemp, dictModel.get("code"));
                        //根据维度生成新的key
                        StringBuffer strKey = new StringBuffer(oneSaveModel.getKey() + "-" + dictModel.get("code"));
                        mapTemp.put(strKey.toString(), saveModelTemp);
                    }
                }
            //如果字典长度是0 抛出异常
            if (listMap.size() == 0) {
                throw new Exception("dict size:0,sql:" + dimensionQuota.getDictSql());
            }
            lastMaps = mapTemp;
        }
//        for (int i = 0; i < dimensionQuotas.size(); i++) {
//            Map<String, SaveModel> mapTemp = new HashMap<>();
//            BaseDimensionQuota dimensionQuota = dimensionQuotas.get(i);
//            List<DictModel> dictModels = jdbcTemplate.query(dimensionQuota.getDictSql(), new BeanPropertyRowMapper(DictModel.class));
//            for (Map.Entry<String, SaveModel> oneSaveModel : lastMaps.entrySet()) {
//                for (int j = 0; j < dictModels.size(); j++) {
//                    SaveModel saveModelTemp = new SaveModel();
//                    DictModel dictModel = dictModels.get(j);
//
//                    BeanUtils.copyProperties(oneSaveModel.getValue(), saveModelTemp);
//                    SaveModel.class.getMethod("setSlaveKey" + (i + 1) + "Name", String.class).invoke(saveModelTemp, dictModel.getName());
//                    SaveModel.class.getMethod("setSlaveKey" + (i + 1), String.class).invoke(saveModelTemp, dictModel.getCode());
//                    //根据维度生成新的key
//                    StringBuffer strKey = new StringBuffer(oneSaveModel.getKey() + "-" + dictModel.getCode());
//                    mapTemp.put(strKey.toString(), saveModelTemp);
//                }
//            }
//            //如果字典长度是0 抛出异常
//            if (dictModels.size() == 0) {
//                throw new Exception("dict size:0,sql:" + dimensionQuota.getDictSql());
//            }
//            lastMaps = mapTemp;
//        }
        //设置值
        for (Map.Entry<String, SaveModel> one : lastMaps.entrySet()) {
            if (countMap.containsKey(one.getKey())) {
                List<DataModel> dataModels = countMap.get(one.getKey());
                Double result1 = 0.0;
                Double result2 = 0.0;
                for (int j = 0; j < dataModels.size(); j++) {
                    DataModel dataModel = dataModels.get(j);
                    Double num = 0.0;
                    if (dataModel.getNum()!=null){
                        num=dataModel.getNum();
                    }else {
                        num=1.0;
                    }
                    result1 += num;
                    result2++;
                }
                SaveModel saveModel = one.getValue();
                saveModel.setResult1(result1);
                saveModel.setResult2(result2);
                if(dataModels.size()>0&& StringUtils.isNotEmpty(dataModels.get(0).getSlaveKey1())&&!StringUtils.isNotEmpty(saveModel.getSlaveKey1())){
                    saveModel.setSlaveKey1(dataModels.get(0).getSlaveKey1());
                }
                if(dataModels.size()>0&& StringUtils.isNotEmpty(dataModels.get(0).getSlaveKey2())&&!StringUtils.isNotEmpty(saveModel.getSlaveKey2())){
                    saveModel.setSlaveKey2(dataModels.get(0).getSlaveKey2());
                }
                returnList.add(saveModel);
            } else {
                returnList.add(one.getValue());
            }
        }
        return returnList;
    }
}

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/Application.java

@ -1,4 +1,4 @@
package com.yihu.jw;
package com.yihu.wlyy;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/AsyncConfig.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.config;
package com.yihu.wlyy.statistics.config;
import java.util.concurrent.Executor;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/DataSourceConfig.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.config;
package com.yihu.wlyy.statistics.config;
import com.alibaba.druid.filter.stat.StatFilter;
import com.alibaba.druid.pool.DruidDataSource;

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/MVCConfig.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.config;
package com.yihu.wlyy.statistics.config;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/SwaggerConfig.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.config;
package com.yihu.wlyy.statistics.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/WebSecurityConfig.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.config;
package com.yihu.wlyy.statistics.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/jpa/HibernateProperties.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.config.jpa;
package com.yihu.wlyy.statistics.config.jpa;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

+ 3 - 3
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/jpa/WlyyJpa.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.config.jpa;
package com.yihu.wlyy.statistics.config.jpa;
import org.springframework.beans.factory.annotation.Autowired;
@ -24,7 +24,7 @@ import javax.sql.DataSource;
@EnableJpaRepositories(
        entityManagerFactoryRef = "wlyyEntityManagerFactory",
        transactionManagerRef = "wlyyTransactionManager",
        basePackages = {"com.yihu.jw.statistics.dao"})   //设置Repository所在位置
        basePackages = {"com.yihu.wlyy.statistics.dao"})   //设置Repository所在位置
public class WlyyJpa {
    @Autowired
@ -37,7 +37,7 @@ public class WlyyJpa {
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
        emfb.setDataSource(dataSource);
        emfb.setPackagesToScan("com.yihu.jw");
        emfb.setPackagesToScan("com.yihu");
        emfb.setPersistenceUnitName("wlyy");
        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        emfb.setJpaVendorAdapter(vendorAdapter);

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/quartz/JobFactory.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.config.quartz;
package com.yihu.wlyy.statistics.config.quartz;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/quartz/SchedulerConfig.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.config.quartz;
package com.yihu.wlyy.statistics.config.quartz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

+ 2 - 2
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/config/war/ServletInitializer.java

@ -1,6 +1,6 @@
package com.yihu.jw.statistics.config.war;
package com.yihu.wlyy.statistics.config.war;
import com.yihu.jw.Application;
import com.yihu.wlyy.Application;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/controller/BaseController.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.controller;
package com.yihu.wlyy.statistics.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.iot.gateway.IdEntity;

+ 2 - 2
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/controller/ExtractDataController.java

@ -1,6 +1,6 @@
package com.yihu.jw.statistics.controller;
package com.yihu.wlyy.statistics.controller;
import com.yihu.jw.statistics.service.ExtractDataService;
import com.yihu.wlyy.statistics.service.ExtractDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 3 - 3
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/controller/JobController.java

@ -1,7 +1,7 @@
package com.yihu.jw.statistics.controller;
package com.yihu.wlyy.statistics.controller;
import com.yihu.jw.statistics.service.JobService;
import com.yihu.jw.statistics.util.hibernate.HibenateDemo;
import com.yihu.wlyy.statistics.service.JobService;
import com.yihu.wlyy.statistics.util.hibernate.HibenateDemo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

+ 6 - 6
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/controller/QueryController.java

@ -1,10 +1,10 @@
package com.yihu.jw.statistics.controller;
package com.yihu.wlyy.statistics.controller;
import com.yihu.jw.statistics.etl.cache.Cache;
import com.yihu.jw.statistics.etl.save.es.ElasticFactory;
import com.yihu.jw.statistics.util.DateUtil;
import com.yihu.jw.statistics.util.ElasticsearchUtil;
import com.yihu.jw.statistics.vo.SaveModel;
import com.yihu.wlyy.statistics.etl.cache.Cache;
import com.yihu.wlyy.statistics.etl.save.es.ElasticFactory;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.util.ElasticsearchUtil;
import com.yihu.wlyy.statistics.vo.SaveModel;
import io.searchbox.client.JestClient;
import io.searchbox.core.*;
import io.swagger.annotations.Api;

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/dao/JobConfigDao.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.dao;
package com.yihu.wlyy.statistics.dao;
import com.yihu.jw.entity.job.QuartzJobConfig;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

+ 2 - 2
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/dao/QuartzJobConfigDao.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.dao;
package com.yihu.wlyy.statistics.dao;
import com.yihu.jw.entity.job.QuartzJobConfig;
@ -20,7 +20,7 @@ public interface QuartzJobConfigDao extends PagingAndSortingRepository<QuartzJob
    @Query(" FROM QuartzJobConfig a WHERE a.status=?1 and a.del='1'")
    List<QuartzJobConfig> findByAll(String s);
    @Query(" FROM QuartzJobConfig a WHERE  a.del='1' and a.id !=8 order by a.id asc")
    @Query(" FROM QuartzJobConfig a WHERE  a.del='1' and a.id >=28 order by a.id asc")
    List<QuartzJobConfig> findByIds();
    @Query(" FROM QuartzJobConfig a WHERE a.id=?1 and a.del='1'")

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/dao/QuartzJobLogDao.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.dao;
package com.yihu.wlyy.statistics.dao;
import com.yihu.jw.entity.job.QuartzJobLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/dao/QuotaDao.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.dao;
package com.yihu.wlyy.statistics.dao;
import com.yihu.jw.entity.quota.WlyyQuota;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

+ 2 - 2
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/dao/WlyyDimensionQuotaDao.java

@ -1,7 +1,7 @@
package com.yihu.jw.statistics.dao;
package com.yihu.wlyy.statistics.dao;
import com.yihu.jw.statistics.vo.BaseDimensionQuota;
import com.yihu.wlyy.statistics.vo.BaseDimensionQuota;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/dao/WlyyQuotaResultDao.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.dao;
package com.yihu.wlyy.statistics.dao;
import com.yihu.jw.entity.quota.WlyyQuotaResult;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

+ 2 - 2
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/cache/Cache.java

@ -1,6 +1,6 @@
package com.yihu.jw.statistics.etl.cache;
package com.yihu.wlyy.statistics.etl.cache;
import com.yihu.jw.statistics.vo.DataModel;
import com.yihu.wlyy.statistics.vo.DataModel;
import java.util.HashMap;
import java.util.List;

+ 360 - 0
svr/svr-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/compute/ComputeHelper.java

@ -0,0 +1,360 @@
package com.yihu.wlyy.statistics.etl.compute;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.vo.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import java.util.*;
/**
 * Created by chenweida on 2017/6/1.
 */
@Component
@Scope("prototype")
public class ComputeHelper {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public String findOrgType(String wlyyJobCongId){
        String sql = "SELECT IFNULL(dict_value,'') from wlyy_hospital_sys_dict WHERE dict_name = 'quota_org_type' and dict_code = '"+wlyyJobCongId+"'";
        String orgType = jdbcTemplate.queryForObject(sql,String.class);
        return orgType;
    }
    /**
     * @param dataModels      过滤之后的数据
     * @param dimensionQuotas 指标的维度
     * @param wlyyJobCongId
     * @param endTime
     * @return
     */
    public List<SaveModel> compute(List<DataModel> dataModels, List<BaseDimensionQuota> dimensionQuotas, String wlyyJobCongId, String endTime, String timeLevel) {
        try {
            //得到机构类型
            String orgType = findOrgType(wlyyJobCongId);
            //计算数据 返回map key 根据团队和维度拼凑在map中的key   1-2-1  如果维度是长度是0返回团队id 1
            Map<String, List<DataModel>> computeMap = computeDataModel(dimensionQuotas, dataModels,wlyyJobCongId);
            List<SaveModel> savemodels = null;
            if("42".equals(wlyyJobCongId)){
                //新生儿入学只到机构级别
                List<BaseOrgDO> orgDOs = findAllOrg(orgType);
                savemodels = initAndSetResultOrg(orgDOs, dimensionQuotas, computeMap, wlyyJobCongId, endTime, timeLevel);
            }else{
                //得到全部团队
                List<BaseDoctorDO> doctors = findAllDoctor(orgType);
                //初始化map并且设置统计出来的数目
                savemodels = initAndSetResult(doctors, dimensionQuotas, computeMap, wlyyJobCongId, endTime, timeLevel);
            }
            return savemodels;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * //计算数据 返回map
     *
     * @param dataModels      过滤过后的元数据
     * @param dimensionQuotas 该指标的维度
     * @return
     */
    private Map<String, List<DataModel>> computeDataModel(List<BaseDimensionQuota> dimensionQuotas, List<DataModel> dataModels,String wlyyJobCongId) {
        Map<String, List<DataModel>> returnMap = new HashMap<>();
        dataModels.stream().forEach(one -> {
            String key;
            if("42".equals(wlyyJobCongId)){
                key = getOrgKey(one, dimensionQuotas.size());
            }else{
                key = getKey(one, dimensionQuotas.size());
            }
            List<DataModel> sms = new ArrayList<DataModel>();
            if (returnMap.containsKey(key)) {
                sms = returnMap.get(key);
            }
            sms.add(one);
            returnMap.put(key, sms);
        });
        return returnMap;
    }
    /**
     * 获取key  根据团队和维度拼凑在map中的key   1-2-1  如果维度是长度是0返回团队id 1
     *
     * @param one
     * @param size
     * @return
     */
    private String getKey(DataModel one, int size) {
        try {
            if (size > 0) {
                StringBuffer str = new StringBuffer(one.getDoctor());
                for (int i = 1; i <= size; i++) {
                    String invokeKey = (String) DataModel.class.getMethod("getSlaveKey" + i).invoke(one);
                    str.append("-" + invokeKey);
                }
                return str.toString();
            } else {
                return one.getDoctor();
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    private String getOrgKey(DataModel one, int size) {
        try {
            if (size > 0) {
                StringBuffer str = new StringBuffer(one.getHospital());
                for (int i = 1; i <= size; i++) {
                    String invokeKey = (String) DataModel.class.getMethod("getSlaveKey" + i).invoke(one);
                    str.append("-" + invokeKey);
                }
                return str.toString();
            } else {
                return one.getHospital();
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 得到全部机构
     *
     * @return
     */
    private List<BaseOrgDO> findAllOrg(String orgType) {
        String sql = "SELECT " +
                "o.code," +
                "o.name," +
                "o.town_code," +
                "o.town_name" +
                " FROM " +
                "base_org o" +
                " WHERE "+
                " o.del='1' and o.code not in('fxty')";
        if(StringUtils.isNotBlank(orgType)){
            sql += " and o.type = '"+orgType+"'";
        }
        List<BaseOrgDO> orgDOs = jdbcTemplate.query(sql, new BeanPropertyRowMapper(BaseOrgDO.class));
        return orgDOs;
    }
    /**
     * 得到全部医生
     *
     * @return
     */
    private List<BaseDoctorDO> findAllDoctor(String orgType) {
        String sql = "SELECT " +
                "bd.id AS code , " +
                "bd.name ," +
                "bdh.dept_code," +
                "hd.name AS dept_name," +
                "bdh.org_code," +
                "bdh.org_name," +
                "o.town_code," +
                "o.town_name" +
                " FROM " +
                "base_doctor_hospital bdh, " +
                "base_doctor bd," +
                "base_org o," +
                "dict_hospital_dept hd " +
                " WHERE bdh.doctor_code = bd.id  " +
                "AND hd.code= bdh.dept_code " +
                "AND o.code = bdh.org_code " +
                "AND bdh.del=1 and o.code not in('fxty')";
        if(StringUtils.isNotBlank(orgType)){
            sql += " and o.type = '"+orgType+"'";
        }
        List<BaseDoctorDO> doctorDOS = jdbcTemplate.query(sql, new BeanPropertyRowMapper(BaseDoctorDO.class));
        return doctorDOS;
    }
    /**
     * 初始化map
     */
    private List<SaveModel> initAndSetResult(List<BaseDoctorDO> doctors, List<BaseDimensionQuota> dimensionQuotas, Map<String, List<DataModel>> countMap, String wlyyJobCongId, String endTime, String timeLevel) throws Exception {
        List<SaveModel> returnList = new ArrayList<>();
        Map<String, SaveModel> lastMaps = new HashMap<>();
        //初始化医生的数据
        for (int i = 0; i < doctors.size(); i++) {
            BaseDoctorDO one = doctors.get(i);
            //排除测试机构
            SaveModel saveModel = new SaveModel();
            saveModel.setCity("330100");
            saveModel.setCityName("杭州市");
            saveModel.setTown(one.getTownCode());
            saveModel.setTownName(one.getTownName());
            String orgCode = one.getOrgCode();
            saveModel.setHospital(orgCode);
            saveModel.setHospitalName(one.getOrgName());
            saveModel.setDoctor(one.getCode());
            saveModel.setDoctorName(one.getName());
            saveModel.setDept(one.getDeptCode());
            saveModel.setDeptName(one.getDeptName());
            saveModel.setQuotaCode(wlyyJobCongId);
            saveModel.setCreateTime(new Date());
            saveModel.setTimeLevel(timeLevel);
            saveModel.setAreaLevel("6");//医生
            saveModel.setQuotaDate(DateUtil.strToDate(endTime, "yyyy-MM-dd"));
            lastMaps.put(one.getCode(), saveModel);
        }
        //根据维度初始化数据
            for (int i = 0; i < dimensionQuotas.size(); i++) {
                Map<String, SaveModel> mapTemp = new HashMap<>();
                BaseDimensionQuota dimensionQuota = dimensionQuotas.get(i);
                List<Map<String, Object>> listMap = jdbcTemplate.queryForList(dimensionQuota.getDictSql());
                for (Map.Entry<String, SaveModel> oneSaveModel : lastMaps.entrySet()) {
                    for (int j = 0; j < listMap.size(); j++) {
                        SaveModel saveModelTemp = new SaveModel();
                        Map<String, Object> dictModel = listMap.get(j);
                        BeanUtils.copyProperties(oneSaveModel.getValue(), saveModelTemp);
                        SaveModel.class.getMethod("setSlaveKey" + (i + 1) + "Name", String.class).invoke(saveModelTemp, dictModel.get("name"));
                        SaveModel.class.getMethod("setSlaveKey" + (i + 1), String.class).invoke(saveModelTemp, dictModel.get("code"));
                        //根据维度生成新的key
                        StringBuffer strKey = new StringBuffer(oneSaveModel.getKey() + "-" + dictModel.get("code"));
                        mapTemp.put(strKey.toString(), saveModelTemp);
                    }
                }
            //如果字典长度是0 抛出异常
            if (listMap.size() == 0) {
                throw new Exception("dict size:0,sql:" + dimensionQuota.getDictSql());
            }
            lastMaps = mapTemp;
        }
        //设置值
        for (Map.Entry<String, SaveModel> one : lastMaps.entrySet()) {
            if (countMap.containsKey(one.getKey())) {
                List<DataModel> dataModels = countMap.get(one.getKey());
                Double result1 = 0.0;
                Double result2 = 0.0;
                for (int j = 0; j < dataModels.size(); j++) {
                    DataModel dataModel = dataModels.get(j);
                    Double num = 0.0;
                    if (dataModel.getNum()!=null){
                        num=dataModel.getNum();
                    }else {
                        num=1.0;
                    }
                    result1 += num;
                    result2++;
                }
                SaveModel saveModel = one.getValue();
                saveModel.setResult1(result1);
                saveModel.setResult2(result2);
                if(dataModels.size()>0&& StringUtils.isNotEmpty(dataModels.get(0).getSlaveKey1())&&!StringUtils.isNotEmpty(saveModel.getSlaveKey1())){
                    saveModel.setSlaveKey1(dataModels.get(0).getSlaveKey1());
                }
                if(dataModels.size()>0&& StringUtils.isNotEmpty(dataModels.get(0).getSlaveKey2())&&!StringUtils.isNotEmpty(saveModel.getSlaveKey2())){
                    saveModel.setSlaveKey2(dataModels.get(0).getSlaveKey2());
                }
                returnList.add(saveModel);
            } else {
                returnList.add(one.getValue());
            }
        }
        return returnList;
    }
    /**
     * 初始化map
     */
    private List<SaveModel> initAndSetResultOrg(List<BaseOrgDO> orgDOs, List<BaseDimensionQuota> dimensionQuotas, Map<String, List<DataModel>> countMap, String wlyyJobCongId, String endTime, String timeLevel) throws Exception {
        List<SaveModel> returnList = new ArrayList<>();
        Map<String, SaveModel> lastMaps = new HashMap<>();
        //初始化医生的数据
        for (int i = 0; i < orgDOs.size(); i++) {
            BaseOrgDO one = orgDOs.get(i);
            SaveModel saveModel = new SaveModel();
            saveModel.setCity("330100");
            saveModel.setCityName("杭州市");
            saveModel.setTown(one.getTownCode());
            saveModel.setTownName(one.getTownName());
            saveModel.setHospitalName(one.getName());
            saveModel.setHospital(one.getCode());
            saveModel.setQuotaCode(wlyyJobCongId);
            saveModel.setCreateTime(new Date());
            saveModel.setTimeLevel(timeLevel);
            saveModel.setAreaLevel("4");//机构
            saveModel.setQuotaDate(DateUtil.strToDate(endTime, "yyyy-MM-dd"));
            lastMaps.put(one.getCode(), saveModel);
        }
        //根据维度初始化数据
        for (int i = 0; i < dimensionQuotas.size(); i++) {
            Map<String, SaveModel> mapTemp = new HashMap<>();
            BaseDimensionQuota dimensionQuota = dimensionQuotas.get(i);
            List<Map<String, Object>> listMap = jdbcTemplate.queryForList(dimensionQuota.getDictSql());
            for (Map.Entry<String, SaveModel> oneSaveModel : lastMaps.entrySet()) {
                for (int j = 0; j < listMap.size(); j++) {
                    SaveModel saveModelTemp = new SaveModel();
                    Map<String, Object> dictModel = listMap.get(j);
                    BeanUtils.copyProperties(oneSaveModel.getValue(), saveModelTemp);
                    SaveModel.class.getMethod("setSlaveKey" + (i + 1) + "Name", String.class).invoke(saveModelTemp, dictModel.get("name"));
                    SaveModel.class.getMethod("setSlaveKey" + (i + 1), String.class).invoke(saveModelTemp, dictModel.get("code"));
                    //根据维度生成新的key
                    StringBuffer strKey = new StringBuffer(oneSaveModel.getKey() + "-" + dictModel.get("code"));
                    mapTemp.put(strKey.toString(), saveModelTemp);
                }
            }
            //如果字典长度是0 抛出异常
            if (listMap.size() == 0) {
                throw new Exception("dict size:0,sql:" + dimensionQuota.getDictSql());
            }
            lastMaps = mapTemp;
        }
        //设置值
        for (Map.Entry<String, SaveModel> one : lastMaps.entrySet()) {
            if (countMap.containsKey(one.getKey())) {
                List<DataModel> dataModels = countMap.get(one.getKey());
                Double result1 = 0.0;
                Double result2 = 0.0;
                for (int j = 0; j < dataModels.size(); j++) {
                    DataModel dataModel = dataModels.get(j);
                    Double num = 0.0;
                    if (dataModel.getNum()!=null){
                        num=dataModel.getNum();
                    }else {
                        num=1.0;
                    }
                    result1 += num;
                    result2++;
                }
                SaveModel saveModel = one.getValue();
                saveModel.setResult1(result1);
                saveModel.setResult2(result2);
                if(dataModels.size()>0&& StringUtils.isNotEmpty(dataModels.get(0).getSlaveKey1())&&!StringUtils.isNotEmpty(saveModel.getSlaveKey1())){
                    saveModel.setSlaveKey1(dataModels.get(0).getSlaveKey1());
                }
                if(dataModels.size()>0&& StringUtils.isNotEmpty(dataModels.get(0).getSlaveKey2())&&!StringUtils.isNotEmpty(saveModel.getSlaveKey2())){
                    saveModel.setSlaveKey2(dataModels.get(0).getSlaveKey2());
                }
                returnList.add(saveModel);
            } else {
                returnList.add(one.getValue());
            }
        }
        return returnList;
    }
}

+ 3 - 3
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/convert/Convert.java

@ -1,9 +1,9 @@
package com.yihu.jw.statistics.etl.convert;
package com.yihu.wlyy.statistics.etl.convert;
import com.yihu.jw.statistics.vo.BaseDimensionQuota;
import com.yihu.jw.statistics.vo.DataModel;
import com.yihu.wlyy.statistics.vo.BaseDimensionQuota;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.List;

+ 5 - 3
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/convert/ConvertHelper.java

@ -1,8 +1,10 @@
package com.yihu.jw.statistics.etl.convert;
package com.yihu.wlyy.statistics.etl.convert;
import com.yihu.jw.statistics.dao.WlyyDimensionQuotaDao;
import com.yihu.jw.statistics.vo.*;
import com.yihu.wlyy.statistics.dao.WlyyDimensionQuotaDao;
import com.yihu.wlyy.statistics.vo.BaseDimensionQuota;
import com.yihu.wlyy.statistics.vo.DataModel;
import com.yihu.wlyy.statistics.vo.FilterModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;

+ 58 - 0
svr/svr-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/AgeConvert.java

@ -0,0 +1,58 @@
package com.yihu.wlyy.statistics.etl.convert.wlyy;
import com.yihu.wlyy.statistics.etl.convert.Convert;
import com.yihu.wlyy.statistics.util.Contant;
import com.yihu.wlyy.statistics.util.IdCardUtil;
import com.yihu.wlyy.statistics.vo.BaseDimensionQuota;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by yeshijie on 2021/6/11.
 */
public class AgeConvert implements Convert {
    /**
     * @param oneList    数据
     * @param slaveLevel 从1开始
     * @return
     */
    @Override
    public List<DataModel> convert(JdbcTemplate jdbcTemplate, List<DataModel> oneList, String slaveLevel, BaseDimensionQuota temp) {
        Map<String,Object> tempMap = new HashMap<>();
        List<DataModel> result = new ArrayList<>();
        for(DataModel one:oneList) {
            try {
                Object value = one.getIdcard();
                Integer age= IdCardUtil.getAgeForIdcard(String.valueOf(value));
                String key = getAgeCode(age);
                tempMap.put(String.valueOf(value),one);
                DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(one, key);
            } catch (Exception e) {
                e.printStackTrace();
            }
        };
        return oneList;
    }
    public String getAgeCode(Integer age) {
        if (age <= 6) {
            return Contant.convert.level_age_1;
        } else if (age >= 7 && age <= 18) {
            return Contant.convert.level_age_2;
        } else if (age >= 19 && age <= 30) {
            return Contant.convert.level_age_3;
        } else if (age >= 31 && age <= 50) {
            return Contant.convert.level_age_4;
        } else if (age >= 51 && age < 65) {
            return Contant.convert.level_age_5;
        } else {
            return Contant.convert.level_age_6;
        }
    }
}

+ 4 - 4
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/convert/wlyy/ConsultTypeConvert.java

@ -1,9 +1,9 @@
package com.yihu.jw.statistics.etl.convert.wlyy;
package com.yihu.wlyy.statistics.etl.convert.wlyy;
import com.yihu.jw.statistics.etl.convert.Convert;
import com.yihu.jw.statistics.vo.BaseDimensionQuota;
import com.yihu.jw.statistics.vo.DataModel;
import com.yihu.wlyy.statistics.etl.convert.Convert;
import com.yihu.wlyy.statistics.vo.BaseDimensionQuota;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/convert/wlyy/model/HealthLable.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.etl.convert.wlyy.model;
package com.yihu.wlyy.statistics.etl.convert.wlyy.model;
/**
 * Created by chenweida on 2017/7/1.

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/convert/wlyy/model/PrescriptionDisease.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.etl.convert.wlyy.model;
package com.yihu.wlyy.statistics.etl.convert.wlyy.model;
/**
 * Created by zhangdan on 2017/10/26.

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/convert/wlyy/model/ServerType.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.etl.convert.wlyy.model;
package com.yihu.wlyy.statistics.etl.convert.wlyy.model;
/**
 * Created by chenweida on 2017/10/18.

+ 5 - 5
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/extract/ExtractHelper.java

@ -1,10 +1,10 @@
package com.yihu.jw.statistics.etl.extract;
package com.yihu.wlyy.statistics.etl.extract;
import com.yihu.jw.entity.job.QuartzJobConfig;
import com.yihu.jw.statistics.etl.extract.db.DBExtract;
import com.yihu.jw.statistics.etl.extract.db.ESExtract;
import com.yihu.jw.statistics.util.SpringUtil;
import com.yihu.jw.statistics.vo.DataModel;
import com.yihu.wlyy.statistics.etl.extract.db.DBExtract;
import com.yihu.wlyy.statistics.etl.extract.db.ESExtract;
import com.yihu.wlyy.statistics.util.SpringUtil;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

+ 2 - 2
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/extract/db/DBExtract.java

@ -1,6 +1,6 @@
package com.yihu.jw.statistics.etl.extract.db;
package com.yihu.wlyy.statistics.etl.extract.db;
import com.yihu.jw.statistics.util.SpringUtil;
import com.yihu.wlyy.statistics.util.SpringUtil;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

+ 2 - 2
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/extract/db/DBPageExtract.java

@ -1,6 +1,6 @@
package com.yihu.jw.statistics.etl.extract.db;
package com.yihu.wlyy.statistics.etl.extract.db;
import com.yihu.jw.statistics.util.hibernate.HibenateUtils;
import com.yihu.wlyy.statistics.util.hibernate.HibenateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;

+ 3 - 3
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/extract/db/Data2Save.java

@ -1,9 +1,9 @@
package com.yihu.jw.statistics.etl.extract.db;
package com.yihu.wlyy.statistics.etl.extract.db;
import com.yihu.jw.entity.job.QuartzJobConfig;
import com.yihu.jw.statistics.dao.WlyyDimensionQuotaDao;
import com.yihu.jw.statistics.vo.*;
import com.yihu.wlyy.statistics.dao.WlyyDimensionQuotaDao;
import com.yihu.wlyy.statistics.vo.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;

+ 5 - 5
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/extract/db/ESExtract.java

@ -1,11 +1,11 @@
package com.yihu.jw.statistics.etl.extract.db;
package com.yihu.wlyy.statistics.etl.extract.db;
import com.yihu.jw.entity.job.QuartzJobConfig;
import com.yihu.jw.statistics.dao.WlyyDimensionQuotaDao;
import com.yihu.jw.statistics.util.ElasticsearchUtil;
import com.yihu.jw.statistics.vo.BaseDimensionQuota;
import com.yihu.jw.statistics.vo.DataModel;
import com.yihu.wlyy.statistics.dao.WlyyDimensionQuotaDao;
import com.yihu.wlyy.statistics.util.ElasticsearchUtil;
import com.yihu.wlyy.statistics.vo.BaseDimensionQuota;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;

+ 4 - 4
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/filter/FilterHelper.java

@ -1,8 +1,8 @@
package com.yihu.jw.statistics.etl.filter;
package com.yihu.wlyy.statistics.etl.filter;
import com.yihu.jw.statistics.vo.DataModel;
import com.yihu.jw.statistics.vo.ErrModel;
import com.yihu.jw.statistics.vo.FilterModel;
import com.yihu.wlyy.statistics.vo.DataModel;
import com.yihu.wlyy.statistics.vo.ErrModel;
import com.yihu.wlyy.statistics.vo.FilterModel;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

+ 2 - 2
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/filter/filter/NotNullFilter.java

@ -1,6 +1,6 @@
package com.yihu.jw.statistics.etl.filter.filter;
package com.yihu.wlyy.statistics.etl.filter.filter;
import com.yihu.jw.statistics.vo.FilterModel;
import com.yihu.wlyy.statistics.vo.FilterModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;

+ 4 - 4
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/save/SaveHelper.java

@ -1,8 +1,8 @@
package com.yihu.jw.statistics.etl.save;
package com.yihu.wlyy.statistics.etl.save;
import com.yihu.jw.statistics.etl.save.es.ElastricSearchSave;
import com.yihu.jw.statistics.util.SpringUtil;
import com.yihu.jw.statistics.vo.SaveModel;
import com.yihu.wlyy.statistics.etl.save.es.ElastricSearchSave;
import com.yihu.wlyy.statistics.util.SpringUtil;
import com.yihu.wlyy.statistics.vo.SaveModel;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

+ 1 - 1
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/save/es/ElasticFactory.java

@ -1,4 +1,4 @@
package com.yihu.jw.statistics.etl.save.es;
package com.yihu.wlyy.statistics.etl.save.es;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestClientFactory;

+ 2 - 2
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/etl/save/es/ElastricSearchSave.java

@ -1,7 +1,7 @@
package com.yihu.jw.statistics.etl.save.es;
package com.yihu.wlyy.statistics.etl.save.es;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.statistics.vo.SaveModel;
import com.yihu.wlyy.statistics.vo.SaveModel;
import io.searchbox.client.JestClient;
import io.searchbox.core.Bulk;
import io.searchbox.core.BulkResult;

+ 2 - 2
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/job/business/CacheCleanJob.java

@ -1,6 +1,6 @@
package com.yihu.jw.statistics.job.business;
package com.yihu.wlyy.statistics.job.business;
import com.yihu.jw.statistics.etl.cache.Cache;
import com.yihu.wlyy.statistics.etl.cache.Cache;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

+ 22 - 44
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/job/business/CurrentMysqlToEsQuotaJob.java

@ -1,24 +1,24 @@
package com.yihu.jw.statistics.job.business;
package com.yihu.wlyy.statistics.job.business;
import com.yihu.jw.entity.job.QuartzJobConfig;
import com.yihu.jw.entity.job.QuartzJobLog;
import com.yihu.jw.statistics.dao.QuartzJobConfigDao;
import com.yihu.jw.statistics.dao.QuartzJobLogDao;
import com.yihu.jw.statistics.dao.WlyyDimensionQuotaDao;
import com.yihu.jw.statistics.etl.cache.Cache;
import com.yihu.jw.statistics.etl.compute.ComputeHelper;
import com.yihu.jw.statistics.etl.convert.ConvertHelper;
import com.yihu.jw.statistics.etl.extract.ExtractHelper;
import com.yihu.jw.statistics.etl.extract.db.Data2Save;
import com.yihu.jw.statistics.etl.filter.FilterHelper;
import com.yihu.jw.statistics.etl.save.SaveHelper;
import com.yihu.jw.statistics.etl.save.es.ElasticFactory;
import com.yihu.jw.statistics.util.DateUtil;
import com.yihu.jw.statistics.util.SpringUtil;
import com.yihu.jw.statistics.vo.BaseDimensionQuota;
import com.yihu.jw.statistics.vo.DataModel;
import com.yihu.jw.statistics.vo.FilterModel;
import com.yihu.jw.statistics.vo.SaveModel;
import com.yihu.wlyy.statistics.dao.QuartzJobConfigDao;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
import com.yihu.wlyy.statistics.dao.WlyyDimensionQuotaDao;
import com.yihu.wlyy.statistics.etl.cache.Cache;
import com.yihu.wlyy.statistics.etl.compute.ComputeHelper;
import com.yihu.wlyy.statistics.etl.convert.ConvertHelper;
import com.yihu.wlyy.statistics.etl.extract.ExtractHelper;
import com.yihu.wlyy.statistics.etl.extract.db.Data2Save;
import com.yihu.wlyy.statistics.etl.filter.FilterHelper;
import com.yihu.wlyy.statistics.etl.save.SaveHelper;
import com.yihu.wlyy.statistics.etl.save.es.ElasticFactory;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.util.SpringUtil;
import com.yihu.wlyy.statistics.vo.BaseDimensionQuota;
import com.yihu.wlyy.statistics.vo.DataModel;
import com.yihu.wlyy.statistics.vo.FilterModel;
import com.yihu.wlyy.statistics.vo.SaveModel;
import io.searchbox.client.JestClient;
import io.searchbox.core.Search;
import io.searchbox.core.SearchResult;
@ -80,7 +80,7 @@ public class CurrentMysqlToEsQuotaJob implements Job {
    private Data2Save data2Save;
    private String incrementInterval;//增量的时间间隔(天)
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try {
@ -89,7 +89,9 @@ public class CurrentMysqlToEsQuotaJob implements Job {
            //初始化参数
            initParams(context);
            //统计指标
            computequota();
            if(Integer.valueOf(wlyyJobCongId)>27||wlyyJobCongId.equals("8")){
                computequota();
            }
        } catch (Exception e) {
            //如果出錯立即重新執行
            JobExecutionException e2 = new JobExecutionException(e);
@ -134,7 +136,6 @@ public class CurrentMysqlToEsQuotaJob implements Job {
        } else {
            //增量
            if (StringUtils.isEmpty(startTime)) {
//                startTime = new LocalDate(new DateTime().minusDays(2)).toString("yyyy-MM-dd") + " 17:00:00"; //2017-06-01 17:00:00
                getStartTime();
            } else {
                startTime = startTime + " 23:59:59";
@ -183,7 +184,6 @@ public class CurrentMysqlToEsQuotaJob implements Job {
        }
        this.quotaDate = DateUtil.strToDate(endTime, "yyyy-MM-dd");
        one.setStartTime(startTime);
        one.setEndTime(endTime);
        logger.info("========================quotaCode:" + one.getQuotaId() + "," + DateUtil.dateToStr(quotaDate, "yyyy-MM-dd") + ",timeLevel:" + timeLevel + " start========================");
@ -199,7 +199,6 @@ public class CurrentMysqlToEsQuotaJob implements Job {
        tjQuotaLog.setJobType(success ? "1" : "0");
        tjQuotaLog.setJobEndTime(new Date());
        //tjQuotaLog.setJobContent(JSONArray.fromObject(filterModel.getErrorModels()).toString());
        saveLog(tjQuotaLog);
        logger.info("========================quotaCode:" +  one.getQuotaId() + "," + DateUtil.dateToStr(quotaDate, "yyyy-MM-dd") + " end========================");
@ -420,36 +419,15 @@ public class CurrentMysqlToEsQuotaJob implements Job {
        }
    }
    public static void main(String[] args) {
        SimpleDateFormat s=new SimpleDateFormat("");
        System.out.println(s.format(new Date()));
    }
//    public void getStartTime() throws Exception{
//        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
//        if("1".equals(this.incrementInterval)){//日
//            startTime = new LocalDate(new DateTime().minusDays(1)).toString("yyyy-MM-dd") + " 17:00:00";
//        }else if("2".equals(this.incrementInterval)){//周
//            Date monday = DateUtil.getMondayOfThisDayToDate(sf.parse(endTime));
////            startTime =sf.format(monday)+ " 17:00:00";
//            startTime =DateUtil.getNextDay(monday,-1)+ " 17:00:00";
//        }else if("3".equals(this.incrementInterval)){//月
//            Date fristDay = DateUtil.getFristDayOfMonthToDate(sf.parse(endTime));
////            startTime = sf.format(fristDay)+ " 17:00:00";
//            startTime =DateUtil.getNextDay(fristDay,-1)+ " 17:00:00";
//        }
//    }
    public void getStartTime() throws Exception{
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        if("1".equals(this.incrementInterval)){//日
            startTime = new LocalDate(new DateTime().minusDays(1)).toString("yyyy-MM-dd") + " 23:59:59";
        }else if("2".equals(this.incrementInterval)){//周
            Date monday = DateUtil.getMondayOfThisDayToDate(sf.parse(endTime));
    //            startTime =sf.format(monday)+ " 17:00:00";
            startTime =DateUtil.getNextDay(monday,-1)+ " 23:59:59";
        }else if("3".equals(this.incrementInterval)){//月
            Date fristDay = DateUtil.getFristDayOfMonthToDate(sf.parse(endTime));
    //            startTime = sf.format(fristDay)+ " 17:00:00";
            startTime =DateUtil.getNextDay(fristDay,-1)+ " 23:59:59";
        }
    }

+ 20 - 19
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/job/business/EsToEsQuotaJob.java

@ -1,22 +1,22 @@
package com.yihu.jw.statistics.job.business;
package com.yihu.wlyy.statistics.job.business;
import com.yihu.jw.entity.job.QuartzJobConfig;
import com.yihu.jw.entity.job.QuartzJobLog;
import com.yihu.jw.statistics.dao.QuartzJobConfigDao;
import com.yihu.jw.statistics.dao.QuartzJobLogDao;
import com.yihu.jw.statistics.etl.compute.ComputeHelper;
import com.yihu.jw.statistics.etl.convert.ConvertHelper;
import com.yihu.jw.statistics.etl.extract.ExtractHelper;
import com.yihu.jw.statistics.etl.extract.db.Data2Save;
import com.yihu.jw.statistics.etl.filter.FilterHelper;
import com.yihu.jw.statistics.etl.save.SaveHelper;
import com.yihu.jw.statistics.etl.save.es.ElasticFactory;
import com.yihu.jw.statistics.util.DateUtil;
import com.yihu.jw.statistics.util.SpringUtil;
import com.yihu.jw.statistics.vo.BaseDimensionQuota;
import com.yihu.jw.statistics.vo.DataModel;
import com.yihu.jw.statistics.vo.FilterModel;
import com.yihu.jw.statistics.vo.SaveModel;
import com.yihu.wlyy.statistics.dao.QuartzJobConfigDao;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
import com.yihu.wlyy.statistics.etl.compute.ComputeHelper;
import com.yihu.wlyy.statistics.etl.convert.ConvertHelper;
import com.yihu.wlyy.statistics.etl.extract.ExtractHelper;
import com.yihu.wlyy.statistics.etl.extract.db.Data2Save;
import com.yihu.wlyy.statistics.etl.filter.FilterHelper;
import com.yihu.wlyy.statistics.etl.save.SaveHelper;
import com.yihu.wlyy.statistics.etl.save.es.ElasticFactory;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.util.SpringUtil;
import com.yihu.wlyy.statistics.vo.BaseDimensionQuota;
import com.yihu.wlyy.statistics.vo.DataModel;
import com.yihu.wlyy.statistics.vo.FilterModel;
import com.yihu.wlyy.statistics.vo.SaveModel;
import io.searchbox.client.JestClient;
import io.searchbox.core.*;
import org.elasticsearch.index.query.BoolQueryBuilder;
@ -71,6 +71,7 @@ public class EsToEsQuotaJob implements Job {
    @Autowired
    private Data2Save data2Save;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try {
@ -79,7 +80,9 @@ public class EsToEsQuotaJob implements Job {
            //初始化参数
            initParams(context);
            //统计指标
            computequota();
            if(Integer.valueOf(wlyyJobCongId)>27){
                computequota();
            }
        } catch (Exception e) {
            //如果出錯立即重新執行
            JobExecutionException e2 = new JobExecutionException(e);
@ -122,7 +125,6 @@ public class EsToEsQuotaJob implements Job {
            }
        }
        this.quotaDate = DateUtil.strToDate(endTime, "yyyy-MM-dd");
        this.wlyyJobCongId = map.getString("jobConfig");
        this.quartzJobConfig = quartzJobConfigDao.findById(wlyyJobCongId);
@ -152,7 +154,6 @@ public class EsToEsQuotaJob implements Job {
            tjQuotaLog.setJobType(success ? "1" : "0");
            tjQuotaLog.setJobEndTime(new Date());
            //tjQuotaLog.setJobContent(JSONArray.fromObject(filterModel.getErrorModels()).toString());
            saveLog(tjQuotaLog);
            logger.info("========================quotaCode:" + wlyyJobCongId + "," + DateUtil.dateToStr(quotaDate, "yyyy-MM-dd") + " end========================");
        } catch (Exception e) {

+ 0 - 0
svr/svr-statistics-es/src/main/java/com/yihu/jw/statistics/job/business/MysqlToEsQuotaJob.java


部分文件因文件數量過多而無法顯示