Shi Kejing преди 3 години
родител
ревизия
628b453674

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

@ -158,4 +158,26 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
        }
    }
    /********************v1.1.0**************************/
    @GetMapping(value = "getGiveEarlyWarning")
    @ApiOperation(value = "物联网检测大屏,预警部分")
    public ObjEnvelop getGiveEarlyWarning(){
        try {
            return success("查询成功",200, platformService.getDistributionOfWarningTypes());
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "getServiceSituation")
    @ApiOperation(value = "物联网检测大屏,服务情况")
    public ObjEnvelop getServiceSituation(){
        try {
            return success("查询成功",200, platformService.getServiceSituation());
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
}

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

@ -11,6 +11,7 @@ import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.utils.StringUtil;
import io.swagger.models.auth.In;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -21,6 +22,7 @@ import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -333,4 +335,71 @@ public class DetectionPlatformService  {
        return nightRecordList;  //起夜记录
    }
    public JSONObject getDistributionOfWarningTypes(){
        JSONObject object = new JSONObject();
        /****预警类型分布****/
        String sql = "SELECT hsd.dict_value,aa.count FROM wlyy_hospital_sys_dict hsd LEFT JOIN (SELECT serve_desc,COUNT(1) count FROM base_security_monitoring_order GROUP BY serve_desc)aa ON hsd.dict_value = aa.serve_desc WHERE hsd.dict_name = 'security_server_dict'";
        List<Map<String , Object>> list = jdbcTemplate.queryForList(sql);
        /****工单总量****/
        String sqlAll = "SELECT COUNT(1) count FROM base_security_monitoring_order";
        Integer countAll = jdbcTemplate.queryForObject(sqlAll,Integer.class);
        /****误报警数量****/
        String sql1 = "SELECT COUNT(1) count FROM base_security_monitoring_order WHERE emergency_cancel IS NOT NULL OR emergency_cancel != ''";
        Integer falseAlarmCount = jdbcTemplate.queryForObject(sql1,Integer.class);
        /****响应数量****/
        String responseCountSql = "SELECT COUNT(1) count FROM base_security_monitoring_order WHERE (emergency_cancel IS NOT NULL OR emergency_cancel != '') OR `status` = 0 GROUP BY id";
        List<Map<String,Object>> responseList = jdbcTemplate.queryForList(responseCountSql);
        Integer responseCount = responseList.size();
        object.put("distributionOfWarning",list);
        object.put("countAll",countAll);
        object.put("falseAlarmCount",falseAlarmCount);
        object.put("responseCount",responseCount);
        /****误报警率****/
        object.put("falseAlarmLaw",getRange(falseAlarmCount,countAll));
        /****响应率****/
        object.put("responseLaw",getRange(responseCount,countAll));
        return object;
    }
    public JSONObject getServiceSituation(){
        JSONObject object = new JSONObject();
        /*****设备分类****/
        // SELECT hsd.`value` dict_value,aa.count FROM base_system_dict_entry hsd LEFT JOIN (SELECT serve_desc,COUNT(1) count FROM base_security_monitoring_order GROUP BY serve_desc)aa ON hsd.`value` = aa.serve_desc WHERE hsd.remark = 'security'
        String passportTypeSql = "SELECT sde.`value`,COUNT(d.id) count,GROUP_CONCAT(DISTINCT d.category_code SEPARATOR ',') AS category_code,GROUP_CONCAT(DISTINCT d.model SEPARATOR ',') AS model FROM base_system_dict_entry sde LEFT JOIN dm_device d ON FIND_IN_SET(sde.`code`,d.service_topic) WHERE sde.remark = 'security' GROUP BY sde.`value` ";
        List<Map<String , Object>> passportType = jdbcTemplate.queryForList(passportTypeSql);
        String useSql = "";
        String allSql = "";
        String model = "";
        Integer use = 0;
        Integer putOnFile = 0;
        if (passportType.size() > 0) {
            for (int i=0;i<passportType.size();i++) {
                System.out.println(passportType.get(i).get("value") +"      " + passportType.get(i).get("count") +"      " + passportType.get(i).get("category_code"));
                Long count = (Long) passportType.get(i).get("count");
                model = (String) passportType.get(i).get("model");
                model = model.replace(",","','");
                if ( count.intValue() > 0) {
                    useSql = "SELECT COUNT(1) FROM wlyy_patient_device WHERE category_code IN ("+ passportType.get(i).get("category_code") +") AND del = 0";
                    use = jdbcTemplate.queryForObject(useSql,Integer.class);
                    passportType.get(i).put("use",use);//使用
                    allSql = "SELECT COUNT(1) FROM wlyy_devices WHERE device_model IN ('"+ model +"')";
                    putOnFile = jdbcTemplate.queryForObject(allSql,Integer.class);
                    passportType.get(i).put("putOnFile",putOnFile); //备案
                    passportType.get(i).put("stock",putOnFile - use); //库存
                } else {
                    passportType.get(i).put("putOnFile",0); //备案
                    passportType.get(i).put("stock",0); //库存
                    passportType.get(i).put("use",0); //使用
                }
            }
        }
        object.put("passportType",passportType);
        return object;
    }
}

+ 4 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/WlyyDeviceDao.java

@ -21,4 +21,8 @@ public interface WlyyDeviceDao extends PagingAndSortingRepository<DeviceDetail,
    @Query("update DeviceDetail o set o.contactStatus = 0 , o.contactStatusTime = ?1 where o.deviceCode = ?2")
    void updateContactStatus(Date contactStatusTime, String orderId);
    @Modifying
    @Query("update DeviceDetail o set o.contactStatus = 1 , o.contactStatusTime = ?1 where o.deviceCode = ?2")
    void updateContactStatus1(Date contactStatusTime, String orderId);
}

+ 41 - 6
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -244,9 +244,38 @@ public class PatientDeviceService {
        Date nowDate2 = device2.getTime();
        String startTimeDevice2 = sdf.format(nowDate2);
        try {
            /**血糖仪,血压计。30天内有数据上传,则改为未失联**/
            String sql = "SELECT bb.device_sn  FROM (\n" +
                    "SELECT pd.device_sn FROM base.wlyy_patient_device pd  LEFT JOIN wlyy_patient_health_index phi ON pd.device_sn = phi.device_sn WHERE\n" +
                    "phi.record_date BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"' AND phi.del = 1 AND pd.category_code IN (1,2) GROUP BY phi.device_sn\n" +
                    ") aa RIGHT JOIN (SELECT device_sn FROM wlyy_patient_device WHERE category_code IN (1,2)) bb ON aa.device_sn =  bb.device_sn\n" +
                    "WHERE aa.device_sn IS NOT NULL OR aa.device_sn != ''";
            List<Map<String , Object>> list = jdbcTemplate.queryForList(sql);
            if (list.size() > 0) {
                for (int i=0;i<list.size();i++) {
                    wlyyDeviceDao.updateContactStatus1(new Date(), (String) list.get(i).get("device_sn"));
                }
            }
            /**智能拐杖、智能手表。2天内有数据上传,则改为未失联**/
            sql = "SELECT bb.device_sn  FROM (\n" +
                    "SELECT pd.device_sn FROM base.wlyy_patient_device pd  LEFT JOIN wlyy_patient_health_index phi ON pd.device_sn = phi.device_sn WHERE\n" +
                    "phi.record_date BETWEEN '"+startTimeDevice2+"' AND '"+endTime+"' AND phi.del = 1 AND pd.category_code IN (16) GROUP BY phi.device_sn\n" +
                    ") aa RIGHT JOIN (SELECT device_sn FROM wlyy_patient_device WHERE category_code IN (16)) bb ON aa.device_sn =  bb.device_sn\n" +
                    "WHERE aa.device_sn IS NOT NULL OR aa.device_sn != ''";
            list = jdbcTemplate.queryForList(sql);
            if (list.size() > 0) {
                for (int i=0;i<list.size();i++) {
                    wlyyDeviceDao.updateContactStatus1(new Date(), (String) list.get(i).get("device_sn"));
                }
            }
            /**血糖仪**/
            String sql1 = "SELECT pd.device_sn FROM base.wlyy_patient_device pd WHERE (SELECT COUNT(1) FROM base.wlyy_patient_health_index WHERE \n" +
                    "record_date BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"' ) = 0 AND del = 0 AND category_code = 1";
            String sql1 = "SELECT bb.device_sn  FROM (\n" +
                    "SELECT pd.device_sn FROM base.wlyy_patient_device pd  LEFT JOIN wlyy_patient_health_index phi ON pd.device_sn = phi.device_sn WHERE\n" +
                    "phi.record_date BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"' AND phi.del = 1 AND pd.category_code = 1 GROUP BY phi.device_sn\n" +
                    ") aa RIGHT JOIN (SELECT device_sn FROM wlyy_patient_device WHERE category_code = 1) bb ON aa.device_sn =  bb.device_sn\n" +
                    "WHERE aa.device_sn IS NULL OR aa.device_sn = ''";
            List<Map<String , Object>> list1 = jdbcTemplate.queryForList(sql1);
            if (list1.size() > 0) {
                for (int i=0;i<list1.size();i++) {
@ -254,8 +283,11 @@ public class PatientDeviceService {
                }
            }
            /**血压计**/
            String sql2 = "SELECT pd.device_sn FROM base.wlyy_patient_device pd WHERE (SELECT COUNT(1) FROM base.wlyy_patient_health_index WHERE \n" +
                    "record_date BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"' ) = 0 AND del = 0 AND category_code = 2";
            String sql2 = "SELECT bb.device_sn  FROM (\n" +
                    "SELECT pd.device_sn FROM base.wlyy_patient_device pd  LEFT JOIN wlyy_patient_health_index phi ON pd.device_sn = phi.device_sn WHERE\n" +
                    "phi.record_date BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"' AND phi.del = 1 AND pd.category_code = 2 GROUP BY phi.device_sn\n" +
                    ") aa RIGHT JOIN (SELECT device_sn FROM wlyy_patient_device WHERE category_code = 2) bb ON aa.device_sn =  bb.device_sn\n" +
                    "WHERE aa.device_sn IS NULL OR aa.device_sn = ''";
            List<Map<String , Object>> list2 = jdbcTemplate.queryForList(sql2);
            if (list2.size() > 0) {
                for (int i=0;i<list2.size();i++) {
@ -267,8 +299,11 @@ public class PatientDeviceService {
            //startTimeDevice2   2天
            /**智能拐杖**/
            String sql3 = "SELECT pd.device_sn FROM base.wlyy_patient_device pd WHERE (SELECT COUNT(1) FROM base.base_yxdevice_index WHERE \n" +
                    "create_time BETWEEN '"+startTimeDevice2+"' AND '"+endTime+"' ) = 0 AND del = 0 AND category_code = 16";
            String sql3 = "SELECT bb.device_sn  FROM (\n" +
                    "SELECT pd.device_sn FROM base.wlyy_patient_device pd  LEFT JOIN wlyy_patient_health_index phi ON pd.device_sn = phi.device_sn WHERE\n" +
                    "phi.record_date BETWEEN '"+startTimeDevice2+"' AND '"+endTime+"' AND phi.del = 1 AND pd.category_code = 16 GROUP BY phi.device_sn\n" +
                    ") aa RIGHT JOIN (SELECT device_sn FROM wlyy_patient_device WHERE category_code = 16) bb ON aa.device_sn =  bb.device_sn\n" +
                    "WHERE aa.device_sn IS NULL OR aa.device_sn = ''";
            List<Map<String , Object>> list3 = jdbcTemplate.queryForList(sql3);
            if (list3.size() > 0) {
                for (int i=0;i<list3.size();i++) {