Преглед изворни кода

Merge branch 'dev' of chinawu123/wlyy2.0 into dev

liubing пре 3 година
родитељ
комит
f64546620e

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

@ -348,6 +348,7 @@ public class ElasticsearchUtil {
                    areaLevel = areaLevels.get(0);
                    areaLevel = areaLevels.get(0);
                }
                }
            }
            }
        }
        }

+ 9 - 1
common/common-entity/sql记录

@ -1613,4 +1613,12 @@ CREATE TABLE `base_patient_step` (
  `create_time` timestamp NULL DEFAULT NULL COMMENT '产生日期',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '产生日期',
  `del` int(1) DEFAULT NULL COMMENT '是否有效 1有效 0无效',
  `del` int(1) DEFAULT NULL COMMENT '是否有效 1有效 0无效',
  PRIMARY KEY (`id`)
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8 COMMENT='患者手表步数';
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8 COMMENT='患者手表步数';
-- 2021-12-27
CREATE TABLE `base_activity_click` (
  `id` varchar(50) NOT NULL,
  `activity_type` tinyint(2) DEFAULT NULL COMMENT '活动类型 1-活动浏览2公益课程播放',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='幼儿活动点击次数统计表';

+ 4 - 0
common/common-rest-model/pom.xml

@ -60,5 +60,9 @@
            <groupId>com.alibaba</groupId>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <artifactId>fastjson</artifactId>
        </dependency>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
    </dependencies>
    </dependencies>
</project>
</project>

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

@ -53,7 +53,7 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    public ListEnvelop executeESSQL1(
    public ListEnvelop executeESSQL1(
            @RequestParam(required = true) String sql) {
            @RequestParam(required = true) String sql) {
        try {
        try {
            return success(elasticsearchUtil.excute(sql, SaveModel.class,null,null));
            return success(elasticsearchUtil.excute(sql, SaveModel.class, null, null));
        } catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException2(e);
            return failedListEnvelopException2(e);
        }
        }
@ -82,6 +82,55 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
        }
        }
    }
    }
    @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.patientAnalysisDP(endDate, area, level, index);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "patientTypeTotalAnalysis")
    @ApiOperation(value = "老人幼儿类型统计分析")
    public ObjEnvelop patientTypeTotalAnalysis(
            @RequestParam(required = true) String startDate,
            @RequestParam(required = true) String endDate,
            @ApiParam(name = "index", value = "42幼儿,37老人", defaultValue = "") @RequestParam(required = true) String index) {
        try {
            JSONObject result = statisticsService.combinedTotal(index,startDate,endDate);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "curveTotal")
    @ApiOperation(value = "曲线图")
    public ObjEnvelop curveTotal(@RequestParam(required = true) String day,
                                 @ApiParam(name = "type", value = "39-老人-生活照料-服务工单数 44-老人-生活照料-代预约 3-幼儿活动报名 41-紧急呼叫  43-老人安放监护 2-公艺课程播放  1-活动浏览次数 28-新生儿-在线咨询总数 32-新生儿-在线咨询总数  35-新生儿-上门辅导-服务工单数")
                                 @RequestParam(required = true) String type,
                                 @RequestParam(required = true) String area,
                                 @RequestParam(required = true) int level,
                                 @RequestParam(required = false) String timeLevel,
                                 @RequestParam(required = false) String interval,
                                 @RequestParam(required = false) String lowLevel
    ) {
        try {
            JSONObject result = statisticsService.curveTotal(day, type, area, level, timeLevel, interval, lowLevel);
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "serviceResources")
    @GetMapping(value = "serviceResources")
    @ApiOperation(value = "服务资源v0.7.0")
    @ApiOperation(value = "服务资源v0.7.0")
    public ObjEnvelop ServiceResources() {
    public ObjEnvelop ServiceResources() {
@ -107,9 +156,9 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getAllDynamics")
    @GetMapping(value = "getAllDynamics")
    @ApiOperation(value = "综合动态v0.7.0")
    @ApiOperation(value = "综合动态v0.7.0")
    public PageEnvelop getAllDynamics(
    public PageEnvelop getAllDynamics(
            @RequestParam(required = true) Integer page,@RequestParam(required = true) Integer size) {
            @RequestParam(required = true) Integer page, @RequestParam(required = true) Integer size) {
        try {
        try {
            return statisticsService.getAllDynamics(page,size);
            return statisticsService.getAllDynamics(page, size);
        } catch (Exception e) {
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
            return failedPageEnvelopException2(e);
        }
        }
@ -118,9 +167,9 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "serviceRankingAnalysis")
    @GetMapping(value = "serviceRankingAnalysis")
    @ApiOperation(value = "服务排名分析")
    @ApiOperation(value = "服务排名分析")
    public ListEnvelop serviceRankingAnalysis(
    public ListEnvelop serviceRankingAnalysis(
            @RequestParam(required = true) String endDate,@RequestParam(required = true) String orgType) {
            @RequestParam(required = true) String endDate, @RequestParam(required = true) String orgType) {
        try {
        try {
            return success(statisticsService.serviceRankingAnalysis(endDate,orgType));
            return success(statisticsService.serviceRankingAnalysis(endDate, orgType));
        } catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException2(e);
            return failedListEnvelopException2(e);
        }
        }
@ -129,9 +178,9 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "fingLoginLog")
    @GetMapping(value = "fingLoginLog")
    @ApiOperation(value = "获取登录记录")
    @ApiOperation(value = "获取登录记录")
    public PageEnvelop fingLoginLog(
    public PageEnvelop fingLoginLog(
            @RequestParam(required = true) Integer page,@RequestParam(required = true) Integer size) {
            @RequestParam(required = true) Integer page, @RequestParam(required = true) Integer size) {
        try {
        try {
            return statisticsService.fingLoginLog(page,size);
            return statisticsService.fingLoginLog(page, size);
        } catch (Exception e) {
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
            return failedPageEnvelopException2(e);
        }
        }
@ -162,60 +211,60 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "findUserByType")
    @GetMapping(value = "findUserByType")
    @ApiOperation(value = "人员实时动态搜索")
    @ApiOperation(value = "人员实时动态搜索")
    public Envelop findUserByType(@ApiParam(name = "type", value = "类型:1幼儿,2老人,3助老员,4医生。不传返回四个类型的数据")
    public Envelop findUserByType(@ApiParam(name = "type", value = "类型:1幼儿,2老人,3助老员,4医生。不传返回四个类型的数据")
                                    @RequestParam(value = "type", required = false)String type,
                                    @ApiParam(name = "name", value = "姓名")
                                    @RequestParam(value = "name", required = false)String name,
                                    @ApiParam(name = "residentialArea", value = "居住小区")
                                    @RequestParam(value = "residentialArea", required = false)String residentialArea,
                                    @ApiParam(name = "page", value = "第几页")
                                        @RequestParam(value = "page", required = false)Integer page,
                                    @ApiParam(name = "size", value = "页面大小")
                                        @RequestParam(value = "size", required = false)Integer size){
        try{
            return success("修改成功",patientService.findUserByType(type, name, residentialArea, page, size));
        }catch (Exception e){
                                  @RequestParam(value = "type", required = false) String type,
                                  @ApiParam(name = "name", value = "姓名")
                                  @RequestParam(value = "name", required = false) String name,
                                  @ApiParam(name = "residentialArea", value = "居住小区")
                                  @RequestParam(value = "residentialArea", required = false) String residentialArea,
                                  @ApiParam(name = "page", value = "第几页")
                                  @RequestParam(value = "page", required = false) Integer page,
                                  @ApiParam(name = "size", value = "页面大小")
                                  @RequestParam(value = "size", required = false) Integer size) {
        try {
            return success("修改成功", patientService.findUserByType(type, name, residentialArea, page, size));
        } catch (Exception e) {
            return failedException2(e);
            return failedException2(e);
        }
        }
    }
    }
    @GetMapping(value = "doctorInfo")
    @GetMapping(value = "doctorInfo")
    @ApiOperation(value = "获取医生详情")
    @ApiOperation(value = "获取医生详情")
    public ObjEnvelop doctorInfo (
    public ObjEnvelop doctorInfo(
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam(value = "doctorId",required = true) String doctorId) throws Exception {
        try{
            return ObjEnvelop.getSuccess("查询成功",doctorService.doctorSimpleInfo(doctorId));
        }catch (Exception e){
            @RequestParam(value = "doctorId", required = true) String doctorId) throws Exception {
        try {
            return ObjEnvelop.getSuccess("查询成功", doctorService.doctorSimpleInfo(doctorId));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
            return failedObjEnvelopException2(e);
        }
        }
    }
    }
    @GetMapping(value = "getDoctorOrderList")
    @GetMapping(value = "getDoctorOrderList")
    @ApiOperation("获取医生生活照料列表")
    @ApiOperation("获取医生生活照料列表")
    public ObjEnvelop getDoctorOrderList(@ApiParam(name="doctor",value = "医生id",required = true)
                                      @RequestParam(value = "doctor")String doctor,
                                      @ApiParam(name="page",value="page")
                                      @RequestParam(name = "page")Integer page,
                                      @ApiParam(name="size",value="size")
                                      @RequestParam(name = "size")Integer size){
    public ObjEnvelop getDoctorOrderList(@ApiParam(name = "doctor", value = "医生id", required = true)
                                         @RequestParam(value = "doctor") String doctor,
                                         @ApiParam(name = "page", value = "page")
                                         @RequestParam(name = "page") Integer page,
                                         @ApiParam(name = "size", value = "size")
                                         @RequestParam(name = "size") Integer size) {
        try {
        try {
            return ObjEnvelop.getSuccess("查询成功",lifeCareOrderService.getDoctorOrderList(doctor,page,size));
        }catch (Exception e){
            return ObjEnvelop.getSuccess("查询成功", lifeCareOrderService.getDoctorOrderList(doctor, page, size));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
            return failedObjEnvelopException2(e);
        }
        }
    }
    }
    @GetMapping(value = "getEmergencyAssistanceList")
    @GetMapping(value = "getEmergencyAssistanceList")
    @ApiOperation(value = "紧急救助列表")
    @ApiOperation(value = "紧急救助列表")
    public PageEnvelop getEmergencyAssistanceList(@ApiParam(name="doctor",value = "医生id",required = true)
                                                     @RequestParam(value = "doctor")String doctor,
                                                 @ApiParam(name="page",value = "page")
                                                 @RequestParam(value = "page") Integer page,
                                                 @ApiParam(name="size",value = "size")
                                                 @RequestParam(value = "size") Integer size){
    public PageEnvelop getEmergencyAssistanceList(@ApiParam(name = "doctor", value = "医生id", required = true)
                                                  @RequestParam(value = "doctor") String doctor,
                                                  @ApiParam(name = "page", value = "page")
                                                  @RequestParam(value = "page") Integer page,
                                                  @ApiParam(name = "size", value = "size")
                                                  @RequestParam(value = "size") Integer size) {
        try {
        try {
            return emergencyAssistanceService.getEmergencyAssistanceList(page,size,doctor);
        }catch (Exception e){
            return emergencyAssistanceService.getEmergencyAssistanceList(page, size, doctor);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
            return failedPageEnvelopException2(e);
        }
        }
    }
    }
@ -225,7 +274,7 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop statisticsOrderServer(
    public ObjEnvelop statisticsOrderServer(
            @RequestParam(required = true) String endDate) {
            @RequestParam(required = true) String endDate) {
        try {
        try {
            JSONObject result = statisticsService.statisticsOrderServer("46,48",endDate,2,"4");
            JSONObject result = statisticsService.statisticsOrderServer("46,48", endDate, 2, "4");
            return success(result);
            return success(result);
        } catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
            return failedObjEnvelopException2(e);
@ -249,7 +298,7 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop statisticsOlderAge(
    public ObjEnvelop statisticsOlderAge(
            @RequestParam(required = true) String endDate) {
            @RequestParam(required = true) String endDate) {
        try {
        try {
            JSONObject result = statisticsService.statisticsOrderServer("50",endDate,2,"2");
            JSONObject result = statisticsService.statisticsOrderServer("50", endDate, 2, "2");
            return success(result);
            return success(result);
        } catch (Exception e) {
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
            return failedObjEnvelopException2(e);
@ -261,18 +310,18 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    public ListEnvelop searchBySql(
    public ListEnvelop searchBySql(
            @RequestParam(required = true) String sql) {
            @RequestParam(required = true) String sql) {
        try {
        try {
            return ListEnvelop.getSuccess("查询成功",statisticsService.searchBySql(sql));
            return ListEnvelop.getSuccess("查询成功", statisticsService.searchBySql(sql));
        } catch (Exception e) {
        } catch (Exception e) {
            return failedListEnvelopException2(e);
            return failedListEnvelopException2(e);
        }
        }
    }
    }
    @RequestMapping(value="esDataModify",method = RequestMethod.GET)
    public ObjEnvelop esDataModify(@RequestParam(required = true) String sql,@RequestParam(required = true) String jsonStr){
    @RequestMapping(value = "esDataModify", method = RequestMethod.GET)
    public ObjEnvelop esDataModify(@RequestParam(required = true) String sql, @RequestParam(required = true) String jsonStr) {
        try {
        try {
            return ObjEnvelop.getSuccess("success",statisticsService.esDataModify(sql,jsonStr));
        }catch (Exception e){
           return failedObjEnvelopException2(e);
            return ObjEnvelop.getSuccess("success", statisticsService.esDataModify(sql, jsonStr));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
        }
    }
    }

+ 13 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/activity/ChildActivityRegistrationService.java

@ -14,8 +14,14 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
import java.util.UUID;
/**
/**
 * Created by yeshijie on 2021/10/16.
 * Created by yeshijie on 2021/10/16.
@ -114,7 +120,13 @@ public class ChildActivityRegistrationService {
     */
     */
    @Transactional
    @Transactional
    public void activityClick(Integer type){
    public void activityClick(Integer type){
        String sql = " UPDATE base_child_activity_click SET num = num+1 where type="+type;
        //取当前时间
        Date nowdate=new Date();
        //转换时间格式
        SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Timestamp timestamp = Timestamp.valueOf(simpleDate.format(nowdate));
        //String sql = " UPDATE base_child_activity_click SET num = num+1 where type="+type;
        String sql = " INSERT INTO base_activity_click VALUES ('"+UUID.randomUUID().toString().replace("-","")+"',"+type+",'"+timestamp+"')";
        jdbcTemplate.execute(sql);
        jdbcTemplate.execute(sql);
    }
    }
}
}

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

@ -43,8 +43,12 @@ import org.springframework.transaction.annotation.Transactional;
import javax.persistence.Transient;
import javax.persistence.Transient;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaBuilder;
import java.awt.print.Pageable;
import java.awt.print.Pageable;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Collectors;
@ -136,19 +140,19 @@ public class StatisticsService {
        String securityMonitoringSql = "SELECT COUNT(1) FROM base_security_monitoring_order where 1=1 "+filter;
        String securityMonitoringSql = "SELECT COUNT(1) FROM base_security_monitoring_order where 1=1 "+filter;
        Integer securityMonitoringNum = jdbcTemplate.queryForObject(securityMonitoringSql,Integer.class);
        Integer securityMonitoringNum = jdbcTemplate.queryForObject(securityMonitoringSql,Integer.class);
        //男 女 性别总数
        /*//男 女 性别总数
        String sexCountSql = "SELECT COUNT(*) ss, CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' END AS sex " +
        String sexCountSql = "SELECT COUNT(*) ss, CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' END AS sex " +
                "FROM wlyy_patient_label lab " +
                "FROM wlyy_patient_label lab " +
                "INNER JOIN base_patient p ON p.id = lab.patient AND lab.label_type = '3' AND lab.patient NOT IN ('null') GROUP BY p.sex";
                "INNER JOIN base_patient p ON p.id = lab.patient AND lab.label_type = '3' AND lab.patient NOT IN ('null') GROUP BY p.sex";
        List<Map<String, Object>> sexCountMap = jdbcTemplate.queryForList(sexCountSql);
        List<Map<String, Object>> sexCountMap = jdbcTemplate.queryForList(sexCountSql);
        res.put("sexCount",sexCountMap);
        res.put("sexCount",sexCountMap);*/
        //老人-紧急预警
        //老人-紧急预警
        res.put("index_"+41,emergencyCallNum);
        res.put("index_"+41,emergencyCallNum);
        //老人 安放监护
        //老人 安放监护
        res.put("index_"+43,securityMonitoringNum);
        res.put("index_"+43,securityMonitoringNum);
        //评估类型
        //评估类型
        res.put("capacityAssessment",capacityAssessment(endDate,defalutArea,defalutLevel));
        res.put("capacityAssessment",cloudCareForTheElderly(endDate,defalutArea,defalutLevel));
        //居民健康标签纬度
        //居民健康标签纬度
        res.put("patientLabelStatistic",statisticsOrderServer("47",endDate,2,"2"));
        res.put("patientLabelStatistic",statisticsOrderServer("47",endDate,2,"2"));
@ -161,20 +165,135 @@ public class StatisticsService {
            res.put("activity_"+tmp.get("type").toString(),num);
            res.put("activity_"+tmp.get("type").toString(),num);
        }
        }
        //返回活动曲线图
        sql = "select count(id),DATE_FORMAT(create_time,'%Y-%m-%d') as total from base_child_activity_registration " +
                "GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d')  " +
                "ORDER BY create_time";
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
        res.put("quxiantu_3",maps);
        //幼儿活动报名总数
        //activity-3 幼儿活动报名-总数
        sql = " select count(id) as total from base_child_activity_registration ";
        sql = " select count(id) as total from base_child_activity_registration ";
        Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
        Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
        res.put("activity_3",count);
        res.put("activity_3",count);
        return res;
        return res;
    }
    }
    /*曲线*/
    public JSONObject curveTotal(String day,String type,String area,int level,String timeLevel,String interval,String lowLevel) throws Exception {
        JSONObject res = new JSONObject();
        StringBuffer sqlbuff = new StringBuffer();
        List<Map<String,Object>> listMaps = null;
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        cal.add(Calendar.DATE, -Integer.parseInt(day));
        java.sql.Date date = new java.sql.Date(cal.getTime().getTime());
        /*---------sql----------*/
        // 3 幼儿活动
        if("3".equals(type)){
            sqlbuff.append("SELECT count(id) amount,DATE_FORMAT(create_time,'%Y-%m-%d') as `range` FROM base_child_activity_registration WHERE DATE_SUB(CURDATE(), INTERVAL "+day+" DAY) <= date(create_time) GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time");
            listMaps = jdbcTemplate.queryForList(String.valueOf(sqlbuff));
            res.put("count",listMaps);
        }
        //41 老人-紧急呼叫
        if("41".equals(type)){
            sqlbuff.append("SELECT COUNT(id) amount,DATE_FORMAT(create_time,'%Y-%m-%d') AS `range` FROM base_emergency_assistance_order WHERE DATE_SUB(CURDATE(), INTERVAL "+day+" DAY) <= DATE(create_time) AND status >= 0 GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time");
            listMaps = jdbcTemplate.queryForList(String.valueOf(sqlbuff));
            res.put("count",listMaps);
        }
        //43 老人 安放监护
        if ("43".equals(type)){
            sqlbuff.append("SELECT COUNT(id) amount,DATE_FORMAT(create_time,'%Y-%m-%d') AS `range` FROM base_security_monitoring_order WHERE DATE_SUB(CURDATE(), INTERVAL "+day+" DAY) <= DATE(create_time) AND status >= 0 GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time");
            listMaps = jdbcTemplate.queryForList(String.valueOf(sqlbuff));
            res.put("count",listMaps);
        }
        // 1   活动浏览次数
        if ("1".equals(type)){
            sqlbuff.append("SELECT COUNT(id) amount,DATE_FORMAT(create_time,'%Y-%m-%d') AS `range` FROM base_activity_click WHERE DATE_SUB(CURDATE(), INTERVAL "+day+" DAY) <= DATE(create_time) AND activity_type = 1 GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time");
            listMaps = jdbcTemplate.queryForList(String.valueOf(sqlbuff));
            res.put("count",listMaps);
        }
        // 2 公艺课程播放
        if ("2".equals(type)){
            sqlbuff.append("SELECT COUNT(id) amount,DATE_FORMAT(create_time,'%Y-%m-%d') AS `range` FROM base_activity_click WHERE DATE_SUB(CURDATE(), INTERVAL "+day+" DAY) <= DATE(create_time) AND activity_type = 2 GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time");
            listMaps = jdbcTemplate.queryForList(String.valueOf(sqlbuff));
            res.put("count",listMaps);
        }
        /*----------es-----------*/
        // 39 老人-生活照料-服务工单数
        // 44 老人-生活照料-代预约
        // 28 新生儿-在线咨询总数
        // 32 新生儿-在线咨询总数
        // 35 新生儿-上门辅导-服务工单数
        if (!"3".equals(type)&&!"41".equals(type)&&!"43".equals(type)&&!"1".equals(type)&&!"2".equals(type)){
            JSONArray esResoult = addLine(String.valueOf(date),LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), area, level, type, timeLevel, interval, lowLevel);
            List<Map> maps = JSONObject.parseArray(esResoult.toJSONString(), Map.class);
            res.put("count",maps);
        }
        return res;
    }
    /*综合总数*/
    public JSONObject combinedTotal(String type,String startDate,String endDate) throws Exception {
        JSONObject res = new JSONObject();
        String index = "";
        //es
        // 39 老人-生活照料-服务工单数
        // 44 老人-生活照料-代预约
        // 28 新生儿-在线咨询总数
        // 35 新生儿-上门辅导-服务工单数
        //sql
        // activity-3 幼儿活动
        // activity-1   活动浏览次数
        // activity-2   公艺课程播放
        //41 老人-紧急呼叫
        //43 老人 安放监护
        //type 42 老人 37 幼儿
        if ("42".equals(type)){
             index = "39,44";
            String[] indexes = index.split(",");
            for(String ind:indexes){
                //总量
                SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, defalutArea, defalutLevel, ind, SaveModel.timeLevel_DDL);
                res.put("index_"+ind,saveModel.getResult2().longValue());
            }
            String emergencyCallSql = "SELECT COUNT(1) FROM base_emergency_assistance_order WHERE status >= 0 ";
            Integer emergencyCallNum = jdbcTemplate.queryForObject(emergencyCallSql,Integer.class);
            String securityMonitoringSql = "SELECT COUNT(1) FROM base_security_monitoring_order where 1=1 ";
            Integer securityMonitoringNum = jdbcTemplate.queryForObject(securityMonitoringSql,Integer.class);
            res.put("index_41",emergencyCallNum);
            res.put("index_43",securityMonitoringNum);
        }else {
            index = "28,35";
            String[] indexes = index.split(",");
            for(String ind:indexes){
                //总量
                SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(startDate, endDate, defalutArea, defalutLevel, ind, SaveModel.timeLevel_DDL);
                res.put("index_"+ind,saveModel.getResult2().longValue());
            }
            // activity-1   活动浏览次数
            // activity-2   公艺课程播放
            String sql = " select type,num from base_child_activity_click where type in(1,2)";
            List<Map<String,Object>> lists = jdbcTemplate.queryForList(sql);
            for (Map<String,Object> tmp:lists){
                Integer num = Integer.parseInt(tmp.get("num").toString());
                res.put("activity_"+tmp.get("type").toString(),num);
            }
            /*幼儿活动报名 总数*/
            String sqlActivity = " select count(id) as total from base_child_activity_registration ";
            Integer count = jdbcTemplate.queryForObject(sqlActivity,Integer.class);
            res.put("activity_3",count);
        }
        return res;
    }
    public JSONObject serviceResources(){
    public JSONObject serviceResources(){
        String orgFilter = "";
        String orgFilter = "";
        String sqlOrg = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' ";
        String sqlOrg = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' ";
@ -723,7 +842,6 @@ public class StatisticsService {
            range.put("amount", saveModel.getResult2());
            range.put("amount", saveModel.getResult2());
            result.add(range);
            result.add(range);
        }
        }
        return result;
        return result;
    }
    }
@ -911,10 +1029,10 @@ public class StatisticsService {
        }
        }
        JSONArray jsonArray = new JSONArray();
        JSONArray jsonArray = new JSONArray();
        String sql = " select dict.dict_code,dict_value,count(DISTINCT A.patient) total from wlyy_hospital_sys_dict dict \n" +
        String sql = " select dict.dict_code,dict_value,count(DISTINCT A.patient) total from wlyy_hospital_sys_dict dict \n" +
                " LEFT JOIN (select distinct lab.patient,lab.label_code from  wlyy_patient_label lab  INNER JOIN base_patient p on p.id = lab.patient AND  lab.label_type='3' " +
                " LEFT JOIN (select distinct lab.patient,lab.label_code from  wlyy_patient_label lab  INNER JOIN base_patient p on p.id = lab.patient AND  lab.label_type='1' " +
                  filter+"   \n" +
                  filter+"   \n" +
                ")A on dict.dict_code = A.label_code " +
                ")A on dict.dict_code = A.label_code " +
                "where  dict.dict_name='older_label'  and  dict.dict_code is not null and dict_code <= 7  \n" +
                "where  dict.dict_name='service_type'  and  dict.dict_code is not null and dict_code <> 5  \n" +
                " GROUP BY dict.dict_code; ";
                " GROUP BY dict.dict_code; ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
@ -1510,4 +1628,153 @@ public class StatisticsService {
    }
    }
    /*大屏 老人云照护 病人分析 */
    public JSONObject patientAnalysisDP(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{
            //老人
            //能力评估 从签约时服务标签取
            res.put("levelList",cloudCareForTheElderly(null,null,null));
            //居民健康标签
            List<SaveModel> list = elasticsearchUtil.findDateAllQuotaLevel1(endDate,endDate,area,level,"47",SaveModel.timeLevel_DDL,null,null,"2");
            JSONArray labelArr = new JSONArray();
            Long total = 0l;
            for(int i=0;i<list.size();i++){
                SaveModel saveModel = list.get(i);
                JSONObject json = new JSONObject();
                if (saveModel.getResult2().longValue()==0&&StringUtils.isBlank(saveModel.getSlaveKey1())){
                    continue;
                }
                if ("0".equals(saveModel.getSlaveKey1())){//去除60岁以下老人
                    continue;
                }
                json.put("num",saveModel.getResult2().longValue());
                json.put("code",saveModel.getSlaveKey1());
                json.put("name",saveModel.getSlaveKey1Name());
                total+=saveModel.getResult2().longValue();
                labelArr.add(json);
            }
            JSONObject arrTmp = new JSONObject();
            arrTmp.put("patientLabelTotal",total);
            arrTmp.put("patientLabelList",labelArr);
            res.put("patientLabelStatistic",arrTmp);
            //年龄分布 50
//            ageList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "50", SaveModel.timeLevel_DDL,null,null,"2");
            List<SaveModel>  ageList = elasticsearchUtil.findDateAllQuotaLevel1(endDate,endDate,area,level,"50",SaveModel.timeLevel_DDL,null,null,"2");
            JSONArray ageArray = new JSONArray();
            for(int i=0;i<ageList.size();i++){
                SaveModel saveModel = ageList.get(i);
                if ("0".equals(saveModel.getSlaveKey1())){//去除60岁以下老人
                    continue;
                }
                JSONObject json = new JSONObject();
                json.put("num",saveModel.getResult2().longValue());
                json.put("code",saveModel.getSlaveKey1());
                json.put("name",saveModel.getSlaveKey1Name());
                ageArray.add(json);
            }
            res.put("ageList",ageArray);
            //居住小区分布
            String filter = "";
            String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
            List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
            if(listtmp.size()>0){
                String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " not in ('"+orgCodes+"')";
            }
            String  sql = "select count(id) total,residential_area residentialArea  from base_patient where del=1 and id "+filter+"  and archive_type=1 " +
                    "GROUP BY residential_area ORDER BY total desc";
            List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
            Iterator<Map<String, Object>> iterator = result.iterator();
            Map<String, Object> tmp = new HashMap<>();
            while (iterator.hasNext()){
                tmp = iterator.next();
                if (null==tmp.get("residentialArea")){
                    iterator.remove();
                    break;
                }
            }
            result.add(tmp);
            res.put("residentialArea",result);
        }
        //性别分析
        String archiType="";
        if("42".equals(index)){
            archiType="2";
        }
        if("37".equals(index)){
            archiType="1";
        }
        List<SaveModel> sexList = elasticsearchUtil.findDateQuotaLevel2ByKeyGroup(endDate, endDate,defalutArea, level, "51",SaveModel.timeLevel_DDL,null,archiType,null,null,"2","1");
        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.getSlaveKey1());
            json.put("name",saveModel.getSlaveKey1Name());
            sexArray.add(json);
        }
        res.put("sexList",sexArray);
        return res;
    }
    /*大屏 老人云照护 评估*/
    public JSONArray cloudCareForTheElderly(String endDate, String area, Integer level) throws Exception{
        //评估类型
        String filter = "";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
        if(listtmp.size()>0){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
            if (StringUtils.isNotBlank(orgCodes)){
                orgCodes = orgCodes.replaceAll(",","','");
                filter = " and lab.patient not in ('"+orgCodes+"')";
            }
        }
        JSONArray jsonArray = new JSONArray();
        String sql = " select dict.dict_code,dict_value,count(DISTINCT A.patient) total from wlyy_hospital_sys_dict dict \n" +
                " LEFT JOIN (select distinct lab.patient,lab.label_code from  wlyy_patient_label lab  INNER JOIN base_patient p on p.id = lab.patient AND  lab.label_type='3' " +
                filter+"   \n" +
                ")A on dict.dict_code = A.label_code " +
                "where  dict.dict_name='older_label'  and  dict.dict_code is not null and dict_code <= 7  \n" +
                " GROUP BY dict.dict_code; ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        String older = " select count(distinct lab.patient) from  wlyy_patient_label lab  INNER JOIN base_patient p on p.id = lab.patient AND  lab.label_type='1' "+filter;
        Integer count = jdbcTemplate.queryForObject(older,Integer.class);
        for(Map<String,Object> map:list){
            JSONObject json = new JSONObject();
            DecimalFormat df = new DecimalFormat("0.00");
            json.put("rate", df.format((Integer.parseInt(map.get("total").toString())*1.00) / count * 100));
            json.put("num", map.get("total"));
            json.put("code",map.get("dict_code").toString());
            json.put("name",map.get("dict_value").toString());
            jsonArray.add(json);
        }
        return jsonArray;
    }
}
}

+ 16 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java

@ -1121,6 +1121,22 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
        }
        }
    }
    }
    @ApiOperation("获取智慧药房取药信息")
    @RequestMapping(value = "getBuyDrugMessage",method = {RequestMethod.GET})
    public ObjEnvelop getBuyDrugMessage(@ApiParam(name = "deviceid", defaultValue = "设备id")
                                        @RequestParam(value = "deviceid", required = true) String deviceid,
                                        @ApiParam(name = "startTime", defaultValue = "开始时间")
                                        @RequestParam(value = "startTime", required = true) String startTime,
                                        @ApiParam(name = "endTime", defaultValue = "开始时间")
                                        @RequestParam(value = "endTime", required = true) String endTime){
        try {
            JSONObject jsonObject = monitorPlatformService.getBuyDrugMessage(deviceid,startTime,endTime);
            return ObjEnvelop.getSuccess("成功",jsonObject,200);
        } catch (Exception e) {
            return ObjEnvelop.getError("失败"+e.getMessage());
        }
    }
    @ApiOperation("智慧药房库存检测信息")
    @ApiOperation("智慧药房库存检测信息")
    @RequestMapping(value = "getYgStockDetection", method = {RequestMethod.GET})
    @RequestMapping(value = "getYgStockDetection", method = {RequestMethod.GET})
    public ObjEnvelop getYgStockDetection(@ApiParam(name = "deviceid", defaultValue = "设备id")
    public ObjEnvelop getYgStockDetection(@ApiParam(name = "deviceid", defaultValue = "设备id")

+ 15 - 5
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

@ -3,7 +3,6 @@ package com.yihu.iot.service.monitorPlatform;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonArray;
import com.yihu.iot.dao.dict.IotSystemDictDao;
import com.yihu.iot.dao.dict.IotSystemDictDao;
import com.yihu.iot.dao.equipment.IotEquipmentDetailDao;
import com.yihu.iot.dao.equipment.IotEquipmentDetailDao;
import com.yihu.iot.service.analyzer.WlyyIotTzDict;
import com.yihu.iot.service.analyzer.WlyyIotTzDict;
@ -1911,10 +1910,10 @@ public class MonitorPlatformService {
            JSONObject quyaoQbject = mediicineorderList.getJSONObject(i);
            JSONObject quyaoQbject = mediicineorderList.getJSONObject(i);
            //取药方式(1、扫码,2、医保卡)
            //取药方式(1、扫码,2、医保卡)
            String shippingType = quyaoQbject.getString("shippingType");
            String shippingType = quyaoQbject.getString("shippingType");
            String payTime = quyaoQbject.getString("payTime");
            String shippingTime = quyaoQbject.getString("shippingTime");
            String name = quyaoQbject.getString("name");
            String name = quyaoQbject.getString("name");
            listMap.put("shippingType", shippingType);
            listMap.put("shippingType", shippingType);
            listMap.put("payTime", payTime);
            listMap.put("shippingTime", shippingTime);
            listMap.put("name", name);
            listMap.put("name", name);
            mediicineorderListMap.add(listMap);
            mediicineorderListMap.add(listMap);
        }
        }
@ -1939,8 +1938,6 @@ public class MonitorPlatformService {
        //取药方式获取
        //取药方式获取
        JSONArray shippingTypeArray = jsonObject.getJSONArray("shippingTypeTotal");
        JSONArray shippingTypeArray = jsonObject.getJSONArray("shippingTypeTotal");
        List<Map> shippingTypeList = JSONObject.parseArray(shippingTypeArray.toJSONString(), Map.class);
        List<Map> shippingTypeList = JSONObject.parseArray(shippingTypeArray.toJSONString(), Map.class);
        //取药列表存放
        //取药列表存放
        resoultMap.put("mediicineorderList", mediicineorderListMap);
        resoultMap.put("mediicineorderList", mediicineorderListMap);
        //设备信息存放
        //设备信息存放
@ -2010,6 +2007,19 @@ public class MonitorPlatformService {
        }
        }
    }
    }
    /*取药信息*/
    public JSONObject getBuyDrugMessage(String deviceid, String startTime,String endTime) throws Exception {
        Map parameterMap = new HashMap<String, String>();
        parameterMap.put("deviceId", deviceid);
        parameterMap.put("startTime", startTime);
        parameterMap.put("endTime", endTime);
        String content = com.alibaba.fastjson.JSONObject.toJSONString(parameterMap);
        String params = AesEncryptUtils.agEncrypt(content);
        JSONObject jsonObject = getUrl("/open/noLogin/getDeviceOrderInfo", params, "detailModelList");
        System.out.println(jsonObject);
        return jsonObject;
    }
    /*智慧药房库存检测
    /*智慧药房库存检测
     * 药房有6层,每层40个货道
     * 药房有6层,每层40个货道
     * 商品状态:未设商品、已有商品
     * 商品状态:未设商品、已有商品