liubing 3 éve
szülő
commit
e7bbf35f83

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

@ -1415,6 +1415,16 @@ public class ElasticsearchUtil {
     *
     */
    public List findDateQuotaLevel2ByKeyGroup(String startDate, String endDate, String area, int level, String index, String timeLevel, String slaveKey1, String slaveKey2, String interval, String lowLevel,String areaLevel,String keyGroup) {
        areaLevel="6";
        if (!index.contains(",")){
            String sqlArea = " select area_level from wlyy_job_config_new where id='"+index+"' ";
            List<String> areaLevels = jdbcTemplate.queryForList(sqlArea,String.class);
            if (areaLevels.size()>0){
                if (StringUtils.isNotBlank(areaLevels.get(0))){
                    areaLevel = areaLevels.get(0);
                }
            }
        }
        //时间格式转换  yyyy-MM-dd转成 2017-07-17T00:00:00+0800
        if (StringUtils.isNotEmpty(startDate)) {
@ -1592,7 +1602,16 @@ public class ElasticsearchUtil {
     * @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 {
        areaLevel="6";
        if (!index.contains(",")){
            String sqlArea = " select area_level from wlyy_job_config_new where id='"+index+"' ";
            List<String> areaLevels = jdbcTemplate.queryForList(sqlArea,String.class);
            if (areaLevels.size()>0){
                if (StringUtils.isNotBlank(areaLevels.get(0))){
                    areaLevel = areaLevels.get(0);
                }
            }
        }
        //时间格式转换  yyyy-MM-dd转成 2017-07-17T00:00:00+0800
        if (StringUtils.isNotEmpty(startDate)) {
            if (startDate.length() > 10) {

+ 69 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/admin/AdminInfoEndpoint.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.common.PermissionService;
import com.yihu.jw.care.service.device.DeviceManageService;
import com.yihu.jw.care.service.sign.ArchiveService;
import com.yihu.jw.care.service.statistics.DetectionPlatformService;
import com.yihu.jw.care.service.statistics.StatisticsService;
import com.yihu.jw.restmodel.web.Envelop;
@ -18,6 +19,9 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2022/3/21.
 * APP管理员部分
@ -35,6 +39,8 @@ public class AdminInfoEndpoint extends EnvelopRestEndpoint {
    private DetectionPlatformService platformService;
    @Autowired
    private DeviceManageService deviceManageService;
    @Autowired
    private ArchiveService archiveService;
    @GetMapping(value = "getOlderOverview")
    @ApiOperation("获取老人概况")
@ -323,7 +329,7 @@ public class AdminInfoEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop statisticsSecurityOlder(
            @RequestParam(required = true) String endDate,
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) Integer level,
            @ApiParam(name="type",value="类型:1本周,2本月",defaultValue = "")@RequestParam(required = false) String type) {
        try {
            JSONObject param = new JSONObject();
@ -339,4 +345,66 @@ public class AdminInfoEndpoint extends EnvelopRestEndpoint {
        }
    }
    @ApiOperation("获取各专题绑定人数")
    @ResponseBody
    @RequestMapping(value = "getTopicPeopleNums", method = RequestMethod.GET)
    public ObjEnvelop getTopicPeopleNums(@RequestParam(required = true) String area,
                                         @RequestParam(required = true) Integer level) {
        try {
            JSONObject param = new JSONObject();
            String doctorId =  permissionService.getUID();
            param.put("doctorId",doctorId);
            if(permissionService.noPermission(0,param)){
                return ObjEnvelop.getError("该操作没有权限");
            }
            return ObjEnvelop.getSuccess("查询成功",platformService.getTopicPeopleNums(area,level+""));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "getSignOlder")
    @ApiOperation(value = "管理员查找签约居民")
    public PageEnvelop<List<Map<String,Object>>> getSignOlder (
            @RequestParam(required = true) String area,
            @RequestParam(required = true) Integer level,
            @ApiParam(name = "name", value = "姓名或身份证", required = false)
            @RequestParam(value = "name",required = false) String name,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) {
        try{
            JSONObject param = new JSONObject();
            String doctorId =  permissionService.getUID();
            param.put("doctorId",doctorId);
            if(permissionService.noPermission(0,param)){
                return PageEnvelop.getError("该操作没有权限");
            }
            return archiveService.adminGetSignOlder(area, level, name, page, size);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getConsultAnalysisRank")
    @ApiOperation(value = "获取咨询排名情况")
    public ObjEnvelop getConsultAnalysisRank(@RequestParam(required = true) String endDate,
                                            @RequestParam(required = true) String area,
                                            @RequestParam(required = true) Integer level,
                                            @ApiParam(name="type",value="咨询类型 23新生儿在线咨询 24老人在线咨询,25老人健康咨询",defaultValue = "")
                                            @RequestParam(required = true) String type) {
        try {
            JSONObject param = new JSONObject();
            String doctorId =  permissionService.getUID();
            param.put("doctorId",doctorId);
            if(permissionService.noPermission(0,param)){
                return ObjEnvelop.getError("该操作没有权限");
            }
            return ObjEnvelop.getSuccess("success",statisticsService.getConsultAnalysisRank(endDate,area,level,type));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
}

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

@ -388,7 +388,7 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @RequestMapping(value = "getTopicPeopleNums", method = RequestMethod.GET)
    public ObjEnvelop getTopicPeopleNums() {
        try {
            return ObjEnvelop.getSuccess("查询成功",platformService.getTopicPeopleNums());
            return ObjEnvelop.getSuccess("查询成功",platformService.getTopicPeopleNums(null,null));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }

+ 3 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/role/RoleService.java

@ -171,10 +171,10 @@ public class RoleService extends BaseJpaService<DoctorRole, DoctorRoleDao> {
     */
    public String getOlderRoleSQL(String area,String level){
        String areaFilter = "";
        String olderFilter = "";
        String olderFilter = " and {patient} not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') ";
        if (StringUtils.isNotBlank(area)){
            if ("330100".equals(area)){
                return "";
                return olderFilter;
            }else {
                if ("4".equals(level)){
@ -188,7 +188,7 @@ public class RoleService extends BaseJpaService<DoctorRole, DoctorRoleDao> {
                            " base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
                            " where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id  and i.del = 1 " +
                            " and sr.`status`=1 and CONVERT(sr.patient USING utf8)  = {patient} " +
                            " and CONVERT(sr.patient USING utf8) not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') "+areaFilter+" ) ";
                            " and {patient} not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') "+areaFilter+" ) ";
                }
            }
        }

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

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.apply.PatientBedApplyDao;
import com.yihu.jw.care.dao.sign.ArchiveDao;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.service.role.RoleService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -53,6 +54,8 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
    private DeviceService deviceService;
    @Autowired
    private BasePatientService basePatientService;
    @Autowired
    private RoleService roleService;
    /**
@ -306,4 +309,45 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
        Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);
    }
    /**
     * 管理员查找签约居民
     * @param area
     * @param level 1省2市3区县4机构5团队6医生
     * @param name
     * @param page
     * @param size
     * @return
     */
    public PageEnvelop<List<Map<String,Object>>> adminGetSignOlder(String area,Integer level,String name,Integer page,Integer size){
        page = page>0?page-1:0;
        String olderFilter = roleService.getOlderRoleSQL(area,level+"");
        String sql = "SELECT DISTINCT p.id,p.name,p.photo,p.sex,p.archive_type as archiveType,p.idcard,p.mobile,p.openid,p.pad_imei padImei " ;
        sql +=",(select COUNT(*) from wlyy_patient_device a where a.`user` = p.id and a.del=0) deviceFlag ";
        String countSql = "SELECT count(DISTINCT p.id) ";
        String filters ="";
        filters = " from base_patient p,wlyy_patient_label l WHERE p.del=1 and p.id = l.patient and l.label_type = 1 "
                +olderFilter.replace("{patient}","p.id") ;
        if(StringUtils.isNotBlank(name)){
            filters += " and (p.name like '%"+name+"%' or p.idcard like '%"+name+"%') ";
        }
        String orderBy = " ORDER BY p.id asc " +
                "LIMIT "+ page * size + "," + size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filters+orderBy);
        for (Map<String,Object> map : list){
            String idcard = map.get("idcard").toString();
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            map.put("deviceType",deviceService.getPatientDeviceCategoryCode(map.get("id").toString()));
            //签约医生标识
            List<Map<String,Object>> doctorList = servicePackageService.getServerDoctorAll(map.get("id").toString(),"0","1");
            List<Map<String,Object>> helperList = servicePackageService.getServerDoctorAll(map.get("id").toString(),"0","2");
            map.put("helper", helperList.size()>0?1:0);
            map.put("doctor", doctorList.size()>0?1:0);
        }
        Long count = jdbcTemplate.queryForObject(countSql+filters,Long.class);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);
    }
}

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

@ -7,6 +7,7 @@ import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.role.RoleService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
@ -64,6 +65,8 @@ public class DetectionPlatformService  {
    private DeviceService deviceService;
    @Autowired
    private ServicePackageService servicePackageService;
    @Autowired
    private RoleService roleService;
    /**
@ -611,20 +614,23 @@ public class DetectionPlatformService  {
     * 睡眠监护  绑定床带 category_code:13
     * 燃气泄漏监护  绑定燃气预警器 category_code:14
     */
    public JSONObject getTopicPeopleNums(){
    public JSONObject getTopicPeopleNums(String area,String level){
        JSONObject result = new JSONObject();
        String filter = " ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) usrCodes 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("usrCodes"));
            if (StringUtils.isNotBlank(orgCodes)) {
                orgCodes = orgCodes.replaceAll(",", "','");
                filter = " and pd.user not in ('" + orgCodes + "') ";
            }
        }
        String olderFilter = roleService.getOlderRoleSQL(area,level);
//        String filter = " ";
//        String sqltmp = "SELECT GROUP_CONCAT(dict_code) usrCodes 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("usrCodes"));
//            if (StringUtils.isNotBlank(orgCodes)) {
//                orgCodes = orgCodes.replaceAll(",", "','");
//                filter = " and pd.user not in ('" + orgCodes + "') ";
//            }
//        }
        String sql = " select count(DISTINCT pd.user) total,pd.category_code from wlyy_patient_device pd where pd.del=0  " +
                " and pd.category_code in (4,7,12,13,14,15) " + filter+
                " and pd.category_code in (4,7,12,13,14,15) " + olderFilter.replace("{patient}","pd.user")+
                " group by pd.category_code ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> tmp:list){

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

@ -903,7 +903,6 @@ public class StatisticsService {
        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;
    }
@ -1098,7 +1097,8 @@ public class StatisticsService {
        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");
        List<SaveModel> sexList = elasticsearchUtil.findDateQuotaLevel2ByKeyGroup(endDate, endDate, area, level,
                "51", SaveModel.timeLevel_DDL, null, archiType, null, null, null, "1");
        JSONArray sexArray = new JSONArray();
        for (int i = 0; i < sexList.size(); i++) {
            SaveModel saveModel = sexList.get(i);
@ -1420,7 +1420,7 @@ public class StatisticsService {
    /**
     * 管理端首页安防预警统计分析
     */
    public JSONObject statisticsSecurityOlder(String endDate, String area, int level, String type) throws Exception {
    public JSONObject statisticsSecurityOlder(String endDate, String area, Integer level, String type) throws Exception {
        JSONObject res = new JSONObject();
        SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevels(endDate, endDate, area, level, "46", SaveModel.timeLevel_DDL, null, null, "-2,0,1" );
@ -1857,8 +1857,7 @@ 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";
        if ("42".equals(index)) {//幼儿
            //新生儿
            //是否入学
            List<SaveModel> statusList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, null, null, areaLevel);
@ -1872,13 +1871,13 @@ public class StatisticsService {
                statusArray.add(json);
            }
            res.put("statusList", statusArray);
        } else {
        } else {//老人
            //老人
            //能力评估 从签约时服务标签取
            res.put("levelList", cloudCareForTheElderly(endDate, area, level));
            //居民健康标签
            List<SaveModel> list = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "47", SaveModel.timeLevel_DDL, null, null, "2");
            List<SaveModel> list = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "47", SaveModel.timeLevel_DDL, null, null, areaLevel);
            JSONArray labelArr = new JSONArray();
            Long total = 0l;
            for (int i = 0; i < list.size(); i++) {
@ -1903,7 +1902,7 @@ public class StatisticsService {
            //年龄分布 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");
            List<SaveModel> ageList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "50", SaveModel.timeLevel_DDL, null, null, areaLevel);
            JSONArray ageArray = new JSONArray();
            for (int i = 0; i < ageList.size(); i++) {
                SaveModel saveModel = ageList.get(i);
@ -2561,4 +2560,61 @@ public class StatisticsService {
        }
        return list;
    }
    /**
     * 咨询排名情况
     * @param endDate
     * @param area
     * @param level 1省2市3区县4机构5团队6医生
     * @param type 咨询类型 23新生儿在线咨询 24老人在线咨询,25老人健康咨询
     * @return
     */
    public JSONArray getConsultAnalysisRank(String endDate,String area,int level,String type) throws Exception {
        JSONArray result = new JSONArray();
        String totalIndex = "";
        String noReplyIndex = "";
        String inTimeIndex = "";
        String lowLevel = "";
        if ("23".equals(type)){
            totalIndex = "28";
            noReplyIndex = "29";
            inTimeIndex = "30";
            lowLevel = "4";
        }else if ("24".equals(type)){
            totalIndex = "31";
            noReplyIndex = "32";
            inTimeIndex = "33";
            lowLevel = "5";
        }else if ("25".equals(type)){
            totalIndex = "57";
            noReplyIndex = "58";
            inTimeIndex = "59";
            lowLevel = "5";
        }else {
            return null;
        }
        //按机构排名
        List<SaveModel> list = elasticsearchUtil.findDateQuotaLevelList(endDate, endDate, area, level, totalIndex, SaveModel.timeLevel_DDL,null,lowLevel, null);
        for (SaveModel tmp:list){
            JSONObject res = new JSONObject();
            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", tmp.getResult2().longValue());
            res.put("dept", tmp.getDept());
            res.put("deptName", tmp.getDeptName());
            res.put("hospital", tmp.getHospital());
            res.put("hospitalName", tmp.getHospitalName());
            res.put("noReply", saveModel2.getResult2().longValue());
            res.put("inTime", saveModel3.getResult2().longValue());
            res.put("finish", saveModel2.getResult2().longValue()+saveModel3.getResult2().longValue());
            res.put("noReplyRate", commonUtil.getRangeDouble(saveModel2.getResult2().intValue(), tmp.getResult2().intValue()));
            res.put("inTimeRate", commonUtil.getRangeDouble(saveModel3.getResult2().intValue(), tmp.getResult2().intValue()));
            res.put("finishRate", commonUtil.getRangeDouble(saveModel2.getResult2().intValue()+saveModel3.getResult2().intValue(), tmp.getResult2().intValue()));
            result.add(res);
        }
        result.sort(Comparator.comparing(obj -> ((JSONObject) obj).getDouble("finishRate")).reversed());
        return result;
    }
}