瀏覽代碼

代码修改

LAPTOP-KB9HII50\70708 3 年之前
父節點
當前提交
648f8b0ebe

+ 16 - 20
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wlyygc/WlyygcDataEndpoint.java

@ -1,10 +1,9 @@
package com.yihu.jw.care.endpoint.wlyygc;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.statistics.WlyygcStatisticsService;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -15,8 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
 * Created by yeshijie on 2022/1/18.
@ -67,7 +65,7 @@ public class WlyygcDataEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "emeAndSecInfo")
    @ApiOperation(value = "安防/紧急呼叫概要")
    public ListEnvelop emeAndSecInfo(@ApiParam(name = "code", value = "社区编码", required = true)
    public PageEnvelop emeAndSecInfo(@ApiParam(name = "code", value = "社区编码", required = true)
                                     @RequestParam(value = "code", required = true) String code,
                                     @ApiParam(name = "page", value = "分页大小", required = true)
                                     @RequestParam(value = "page") Integer page,
@ -78,48 +76,47 @@ public class WlyygcDataEndpoint extends EnvelopRestEndpoint {
                                     @ApiParam(name = "status", value = "状态", required = false)
                                     @RequestParam(value = "status", required = false) Integer status) {
        try {
            JSONArray result = wlyygcStatisticsService.emeAndSecInfo(page,size,code,type,status);
            return success(result);
            return wlyygcStatisticsService.emeAndSecInfo(page,size,code,type,status);
        } catch (Exception e) {
            return failedListEnvelopException2(e);
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "signOldList")
    @ApiOperation(value = "获取签约老人")
    public ListEnvelop signOldList(@ApiParam(name = "code", value = "社区编码")
    public PageEnvelop signOldList(@ApiParam(name = "code", value = "社区编码")
                                   @RequestParam(value = "code", required = true) String code,
                                   @ApiParam(name = "page", value = "分页大小", required = true)
                                   @RequestParam(value = "page") Integer page,
                                   @ApiParam(name = "size", value = "页码", required = true)
                                   @RequestParam(value = "size") Integer size) {
        try {
            List<Map<String, Object>> maps = wlyygcStatisticsService.signOldList(code, page, size);
            return success(maps);
            return wlyygcStatisticsService.signOldList(code, page, size);
        } catch (Exception e) {
            return failedListEnvelopException2(e);
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "securityEmergencyList")
    @ApiOperation(value = "获取安防/监护")
    public ObjEnvelop securityEmergencyList(@ApiParam(name = "code", value = "社区编码")
    public PageEnvelop securityEmergencyList(@ApiParam(name = "code", value = "社区编码")
                                            @RequestParam(value = "code", required = true) String code,
                                            @ApiParam(name = "page", value = "分页大小", required = true)
                                            @RequestParam(value = "page") Integer page,
                                            @ApiParam(name = "type", value = "类型", required = false)
                                            @RequestParam(value = "type") Integer type,
                                            @ApiParam(name = "size", value = "页码", required = true)
                                            @RequestParam(value = "size") Integer size) {
        try {
            JSONObject jsonObject = wlyygcStatisticsService.securityEmergencyList(code,page,size);
            return success(jsonObject);
            return wlyygcStatisticsService.securityEmergencyList(code,type,page,size);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "deviceList")
    @ApiOperation(value = "获取设备列表")
    public ListEnvelop deviceList(@ApiParam(name = "code", value = "社区编码")
    public PageEnvelop deviceList(@ApiParam(name = "code", value = "社区编码")
                                  @RequestParam(value = "code", required = true) String code,
                                  @ApiParam(name = "page", value = "分页大小", required = true)
                                  @RequestParam(value = "page") Integer page,
@ -127,10 +124,9 @@ public class WlyygcDataEndpoint extends EnvelopRestEndpoint {
                                  @RequestParam(value = "size") Integer size) {
        try {
            List<Map<String, Object>> maps = wlyygcStatisticsService.deviceList(code, page, size);
            return success(maps);
            return wlyygcStatisticsService.deviceList(code, page, size);
        } catch (Exception e) {
            return failedListEnvelopException2(e);
            return failedPageEnvelopException2(e);
        }
    }
}

+ 98 - 46
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/WlyygcStatisticsService.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.security.BaseEmergencyWarnLogDao;
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
@ -181,13 +182,13 @@ public class WlyygcStatisticsService {
     * @param code
     * @return
     */
    public JSONArray emeAndSecInfo(Integer page, Integer size,String code,Integer type,Integer status){
    public PageEnvelop emeAndSecInfo(Integer page, Integer size, String code, Integer type, Integer status){
        JSONArray jsonArray = new JSONArray();
        String filter = "";
        if("1".equals(code)){
            filter = " and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
        }else {
            return jsonArray;
            return PageEnvelop.getSuccess("查询成功");
        }
        if(status!=null){
            filter += " and o.status = "+status;
@ -221,6 +222,23 @@ public class WlyygcStatisticsService {
        }
        sql += "ORDER BY a.create_time desc limit "+(page-1)*size+","+size;
        String sqlCount = "SELECT count(*) from ( " +
                "select o.id,'1' type  FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_emergency_assistance_order o    " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                " UNION ALL " +
                "select o.id,'2' type FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_security_monitoring_order o " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                " ) a where 1=1 ";
        if(type!=null){
            sqlCount += " and a.type = '"+type+"'";
        }
        List<Map<String,Object>> res = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map : res){
            JSONObject json = new JSONObject();
@ -241,10 +259,11 @@ public class WlyygcStatisticsService {
            json.put("orderLogInfo",orderLogInfo);
            jsonArray.add(json);
        }
        return jsonArray;
        long total = jdbcTemplate.queryForObject(sqlCount,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",jsonArray,page,size,total);
    }
    public List<Map<String, Object>> signOldList(String code, Integer page, Integer size) {
    public PageEnvelop signOldList(String code, Integer page, Integer size) {
        if (page == null) {
            page = 1;
        }
@ -254,63 +273,80 @@ public class WlyygcStatisticsService {
        String sql = "SELECT DISTINCT p.`name`, p.mobile, p.idcard,(CASE WHEN p.sex = 1 THEN  '男' ELSE '女' END ) AS sex,p.address, TIMESTAMPDIFF(YEAR, p.birthday, CURDATE()) years,p.residential_area AS residentialArea" +
                " FROM base_patient p INNER JOIN base_service_package_sign_record br ON p.id = br.patient, base_service_package_record r" +
                " WHERE p.del = 1 AND br.`status` = 1 AND p.archive_type = 1 AND r.patient = p.id ";
        String sqlCount = "SELECT count(DISTINCT p.id) " +
                " FROM base_patient p INNER JOIN base_service_package_sign_record br ON p.id = br.patient, base_service_package_record r" +
                " WHERE p.del = 1 AND br.`status` = 1 AND p.archive_type = 1 AND r.patient = p.id ";
        if ("1".equals(code)) {
            //1华联社区
            sql += "  and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
            sqlCount += "  and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
        } else {
            return null;
            return PageEnvelop.getSuccess("查询成功");
        }
        sql += "ORDER BY p.`name` desc limit " + (page - 1)*size + "," + size;
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
        return maps;
        long total = jdbcTemplate.queryForObject(sqlCount,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,total);
    }
    public JSONObject securityEmergencyList(String code,Integer page,Integer size) {
        JSONObject jsonObject = new JSONObject();
        if (page == null) {
            page = 1;
    public PageEnvelop securityEmergencyList(String code,Integer type,Integer page,Integer size) {
        String filter = "";
        if("1".equals(code)){
            filter = " and r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam' ";
        }else {
            return PageEnvelop.getSuccess("查询成功");
        }
        if (size == null) {
        if(page==null){
            page =1;
        }
        if(size==null){
            size = 10;
        }
        String sql = "SELECT * from ( " +
                "select p.name,'紧急呼叫' serveDesc,'1' type,o.create_time createTime FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_emergency_assistance_order o    " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                "UNION ALL " +
                "select p.name,o.serve_desc serveDesc,'2' type,o.create_time createTime FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_security_monitoring_order o " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                " ) a where 1=1 ";
        if(type!=null){
            sql += " and a.type = '"+type+"'";
        }
        sql += "ORDER BY a.createTime desc limit "+(page-1)*size+","+size;
        String jjsql = "SELECT DISTINCT " +
                "ord.patient_name," +
                "'紧急呼叫' AS serveDesc " +
                "FROM base_emergency_assistance_order ord ";
        String afsql ="SELECT DISTINCT " +
                "ord.patient_name AS NAME," +
                "ord.serve_desc AS serveDesc " +
                "FROM " +
                "base_security_monitoring_order ord " +
                "INNER JOIN base_service_package_sign_record br ON ord.patient = CONVERT (br.patient USING utf8) COLLATE utf8_unicode_ci," +
                " base_service_package_record r " +
                "WHERE " +
                "r.patient = ord.patient ";
        if ("1".equals(code)) {
                                             //808080eb78f276d40178f3373c8c000b
            jjsql += "WHERE ord.team_code ='8a92aba97a9f6f49017ae4fdbdmqteam'";
            afsql += "AND r.team_code ='8a92aba97a9f6f49017ae4fdbdmqteam'";
        }else {
            return jsonObject;
        String sqlCount = "SELECT count(*) from ( " +
                "select o.id,'1' type  FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_emergency_assistance_order o    " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                " UNION ALL " +
                "select o.id,'2' type FROM  " +
                "base_patient p INNER JOIN base_service_package_sign_record sr on p.id = sr.patient and sr.`status`=1 " +
                ", base_service_package_record r, base_security_monitoring_order o " +
                "WHERE p.del = 1 and p.archive_type =1 and r.patient = p.id " +
                "and p.id = o.patient " + filter +
                " ) a where 1=1 ";
        if(type!=null){
            sqlCount += " and a.type = '"+type+"'";
        }
        jjsql += " ORDER BY ord.patient_name DESC limit " + (page - 1)*size + "," + size;
        afsql += " ORDER BY ord.patient_name DESC limit " + (page - 1)*size + "," + size;
        List<Map<String, Object>> jj = jdbcTemplate.queryForList(jjsql);
        List<Map<String, Object>> af = jdbcTemplate.queryForList(afsql);
        jsonObject.put("Security", af);
        jsonObject.put("Emergency", jj);
        return jsonObject;
        List<Map<String,Object>> res = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map : res){
            map.put("createTime",map.get("createTime").toString().substring(0,19));
        }
        long total = jdbcTemplate.queryForObject(sqlCount,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",res,page,size,total);
    }
    public List<Map<String, Object>> deviceList(String code,Integer page,Integer size){
    public PageEnvelop deviceList(String code,Integer page,Integer size){
        if (page == null) {
            page = 1;
        }
@ -321,13 +357,13 @@ public class WlyygcStatisticsService {
        if ("1".equals(code)){
            filter += "AND r.team_code = '8a92aba97a9f6f49017ae4fdbdmqteam'";
        }else {
            return null;
            return PageEnvelop.getSuccess("查询成功");
        }
        String deviceSql = "SELECT DISTINCT" +
                " pd.device_name as deviceName," +
                "pd.device_type as deviceType," +
                "wd.collect_num as collectNum " +
                "IFNULL(wd.collect_num,0) as collectNum " +
                "FROM " +
                "base_patient p " +
                "INNER JOIN base_service_package_sign_record sr ON p.id = sr.patient " +
@ -344,7 +380,23 @@ public class WlyygcStatisticsService {
                "AND wd.device_code = pd.device_sn "+filter+" ORDER BY pd.device_name DESC limit " + (page - 1)*size + "," + size;
        List<Map<String, Object>> maps = jdbcTemplate.queryForList(deviceSql);
        return maps;
        String sqlCount = "SELECT count(DISTINCT pd.id) " +
                "FROM " +
                "base_patient p " +
                "INNER JOIN base_service_package_sign_record sr ON p.id = sr.patient " +
                "AND sr.`status` = 1," +
                " base_service_package_record r," +
                " wlyy_patient_device pd," +
                " wlyy_devices wd " +
                "WHERE " +
                "p.del = 1 " +
                "AND p.archive_type = 1 " +
                "AND r.patient = p.id " +
                "AND p.id = pd.`user` " +
                "AND pd.del = 0 "+
                "AND wd.device_code = pd.device_sn "+filter;
        long total = jdbcTemplate.queryForObject(sqlCount,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",maps,page,size,total);
    }
}