Bladeren bron

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

liubing 3 jaren geleden
bovenliggende
commit
f47e935dac

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

@ -14,6 +14,9 @@ public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatie
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    Iterable<DevicePatientDevice> findByUser(String user);
    @Query("select a from DevicePatientDevice a where a.del = 0 ")
    List<DevicePatientDevice> findByAll();
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    List<DevicePatientDevice> findByPatient(String user);

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

@ -20,6 +20,9 @@ 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 with IntelliJ IDEA.
 *
@ -55,6 +58,28 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "serviceResources")
    @ApiOperation(value = "服务资源v0.7.0")
    public ObjEnvelop ServiceResources() {
        try {
            JSONObject result = statisticsService.serviceResources();
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "realTimeDataNew")
    @ApiOperation(value = "实时数据v0.7.0")
    public ObjEnvelop realTimeDataNew() {
        try {
            JSONObject result = statisticsService.realTimeDataNew();
            return success(result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "serviceRankingAnalysis")
    @ApiOperation(value = "服务排名分析")
    public ListEnvelop serviceRankingAnalysis(

+ 11 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/BaseServiceNewsService.java

@ -1,7 +1,10 @@
package com.yihu.jw.care.service.message;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.message.BaseServiceNewsDao;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.message.BaseServiceNews;
import com.yihu.jw.restmodel.iot.device.WlyyPatientDeviceVO;
import com.yihu.jw.util.common.IdCardUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
@ -12,6 +15,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * Created with IntelliJ IDEA.
@ -27,6 +31,8 @@ public class BaseServiceNewsService {
    private BaseServiceNewsDao baseServiceNewsDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    /**
     * 查找机构坐标
@ -46,9 +52,14 @@ public class BaseServiceNewsService {
        String sql = "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,CAST(archive_type AS char) type from base_patient p\n" +
                "WHERE p.del = 1 and p.name like '%"+name+"%'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<DevicePatientDevice> feeDetail = patientDeviceDao.findByAll();
        Map<String, List<DevicePatientDevice>> byDept1 = feeDetail.stream()
                .collect(Collectors.groupingBy(DevicePatientDevice::getUser));
        for (Map<String,Object> map:list){
            String idcard = map.get("idcard").toString();
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            List<DevicePatientDevice> patientDevices = byDept1.get(map.get("id"));
            map.put("devices",patientDevices);
        }
        return list;
    }

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

@ -81,6 +81,66 @@ public class StatisticsService {
        return res;
    }
    public JSONObject serviceResources(){
//        String sql = "SELECT type , COUNT(1) count FROM base_org WHERE del = 1 GROUP BY type";
//        List<Map<String , Object>> list = jdbcTemplate.queryForList(sql);
        JSONObject res = new JSONObject();
        String medicalInstitutionSql = "SELECT COUNT(1) FROM base_org WHERE (type = 1 OR type = 2) AND del = 1;";
        String elderlyCarServiceSql = "SELECT COUNT(1) FROM base_org WHERE type = 3 AND del = 1";
        String childcareInstitutionsssSql = "SELECT COUNT(1) FROM base_org WHERE type = 4 AND del = 1";
        String doctorSql = "SELECT COUNT(1) FROM base_doctor WHERE del = 1 AND doctor_level = 1";
        String helperSql = "SELECT COUNT(1) FROM base_doctor WHERE del = 1 AND doctor_level = 2";
        String teacherSql = "SELECT COUNT(1) FROM base_doctor WHERE del = 1 AND doctor_level = 3";
        Integer medicalInstitutionNum = jdbcTemplate.queryForObject(medicalInstitutionSql,Integer.class);
        Integer elderlyCarServiceNum = jdbcTemplate.queryForObject(elderlyCarServiceSql,Integer.class);
        Integer childcareInstitutionsssNum = jdbcTemplate.queryForObject(childcareInstitutionsssSql,Integer.class);
        Integer doctorNum = jdbcTemplate.queryForObject(doctorSql,Integer.class);
        Integer helperNum = jdbcTemplate.queryForObject(helperSql,Integer.class);
        Integer teacherNum = jdbcTemplate.queryForObject(teacherSql,Integer.class);
        res.put("medicalInstitutionNum",medicalInstitutionNum);             //医疗结构
        res.put("elderlyCarServiceNum",elderlyCarServiceNum);               //养老机构
        res.put("childcareInstitutionsssNum",childcareInstitutionsssNum);   //托育机构
        res.put("doctorNum",doctorNum);     //医生
        res.put("helperNum",helperNum);     //助老员
        res.put("teacherNum",teacherNum);   //教师
        return res;
    }
    // v0.7.0实时数据 照护对象、检测设备、紧急救助
    public JSONObject realTimeDataNew() throws Exception {
        JSONObject res = new JSONObject();
        Integer olderTotal = 0;
        Integer childTotal = 0;
        String sql1 = "SELECT COUNT(*) c,archive_type from base_patient WHERE archive_type is  not null and del='1' GROUP BY archive_type";
        List<Map<String,Object>> list1 = jdbcTemplate.queryForList(sql1);
        for(Map<String,Object> map:list1){
            String archive_type = map.get("archive_type").toString();
            Integer num = Integer.valueOf(map.get("c").toString());
            if("1".equals(archive_type)){
                olderTotal = num;
                continue;
            }
            if("2".equals(archive_type)){
                childTotal = num;
            }
        }
        String healthEquipmentSql = "SELECT COUNT(1) FROM wlyy_patient_device WHERE del = 0 AND (category_code = 1 OR category_code = 2)";
        Integer healthEquipmentNum = jdbcTemplate.queryForObject(healthEquipmentSql,Integer.class);
        String securityEquipmentSql = "SELECT COUNT(1) FROM wlyy_patient_device WHERE del = 0 AND category_code > 2";
        Integer securityEquipmentNum = jdbcTemplate.queryForObject(securityEquipmentSql,Integer.class);
        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";
        Integer securityMonitoringNum = jdbcTemplate.queryForObject(securityMonitoringSql,Integer.class);
        res.put("olderTotal",olderTotal);   //老人注册人数
        res.put("childTotal",childTotal);   //儿童注册人数
        res.put("healthEquipmentNum",healthEquipmentNum);   //健康设备
        res.put("securityEquipmentNum",securityEquipmentNum);   //安防设备
        res.put("emergencyCallNum",emergencyCallNum);   //紧急呼叫的次数
        res.put("securityMonitoringNum",securityMonitoringNum);   //安防监护触发工单的次数
        return  res;
    }
    /**
     * 服务排名分析
     * @param endDate