From b9fd2657a3d528881e4d1f7cae12ca8e2d63951a Mon Sep 17 00:00:00 2001 From: cjl <276999030@qq.com> Date: Wed, 30 Aug 2023 09:33:31 +0800 Subject: [PATCH] fix:补充提交 --- screen-api/src/main/java/com/moral/api/service/impl/AlarmInfoServiceImpl.java | 239 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 226 insertions(+), 13 deletions(-) diff --git a/screen-api/src/main/java/com/moral/api/service/impl/AlarmInfoServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/AlarmInfoServiceImpl.java index 49e5647..7950927 100644 --- a/screen-api/src/main/java/com/moral/api/service/impl/AlarmInfoServiceImpl.java +++ b/screen-api/src/main/java/com/moral/api/service/impl/AlarmInfoServiceImpl.java @@ -15,10 +15,8 @@ import org.springframework.stereotype.Service; import org.springframework.util.ObjectUtils; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.SimpleDateFormat; +import java.util.*; import java.util.stream.Collectors; /** @@ -42,7 +40,8 @@ private AlarmInfoMapper alarmInfoMapper; @Override - public List<Map<String, Object>> getDataByCondition(Map<String, Object> parameters) { + public Map<String, Object> getDataByCondition(Map<String, Object> parameters) { + Map<String, Object> resultMap = new HashMap<>(); int orgId = Integer.parseInt(parameters.get("organization_id").toString()); //���������������������������������id List<Integer> allOrgId = new ArrayList<>(); @@ -76,7 +75,9 @@ } if (deviceIdList.size()>0){ Map<String, Object> map = new HashMap<>(); + QueryWrapper<AlarmInfo> alarmInfoQueryWrapper = new QueryWrapper<>(); map.put("deviceIds",deviceIdList); + alarmInfoQueryWrapper.in("device_id",deviceIdList); int size = Integer.parseInt(parameters.get("size").toString()); int current = Integer.parseInt(parameters.get("current").toString()); int start = (current-1)*size; @@ -86,30 +87,242 @@ String endTime = parameters.get("endTime")+" 23:59:59"; map.put("startTime",startTime); map.put("endTime",endTime); + alarmInfoQueryWrapper.between("alarm_time", startTime, endTime); String index = parameters.get("index").toString(); if (!index.equals("all")){ map.put("index",index); + alarmInfoQueryWrapper.eq("`index`", index); } String alarmType = parameters.get("alarmType").toString(); switch (alarmType){ - case "������":map.put("alarmType","������"); + case "overrun" : map.put("alarmType","������"); + alarmInfoQueryWrapper.eq("alarm_type","������"); break; - case "���������":map.put("alarmType","���������"); + case "sudden" : map.put("alarmType","���������"); + alarmInfoQueryWrapper.eq("alarm_type","���������"); break; - case "���������100":map.put("alarmType","������������������100%"); + case "state100" : map.put("alarmType","������������������100%"); + alarmInfoQueryWrapper.eq("alarm_type","������������������100%"); break; - case "���������150":map.put("alarmType","������������������150%"); + case "state150" : map.put("alarmType","������������������150%"); + alarmInfoQueryWrapper.eq("alarm_type","������������������150%"); break; - case "���������250":map.put("alarmType","������������������250%"); + case "state250" : map.put("alarmType","������������������250%"); + alarmInfoQueryWrapper.eq("alarm_type","������������������250%"); break; - case "������������150":map.put("alarmType","������������������150%"); + case "city150" : map.put("alarmType","������������������150%"); + alarmInfoQueryWrapper.eq("alarm_type","������������������150%"); break; - case "������������250":map.put("alarmType","������������������250%"); + case "city250" : map.put("alarmType","������������������250%"); + alarmInfoQueryWrapper.eq("alarm_type","������������������250%"); break; default:break; } List<Map<String, Object>> resultList = alarmInfoMapper.selectDataByCondition(map); - return resultList; + SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + for (Map<String, Object> alarmInfo:resultList) { + String alarm_time = SDF.format(alarmInfo.get("alarm_time")); + alarmInfo.put("alarm_time",alarm_time); + } + Integer totalNumber = alarmInfoMapper.selectCount(alarmInfoQueryWrapper); + resultMap.put("totalNumber", totalNumber); + resultMap.put("alarmInfos", resultList); + resultMap.put("current",current); + resultMap.put("size",size); + int totalPageNumber = totalNumber/size; + if(totalNumber%size != 0){ + totalPageNumber += 1; + } + resultMap.put("totalPageNumber",totalPageNumber); + return resultMap; + } + return null; + } + + @Override + public Map<String, Object> getDataByConditionWithoutPage(Map<String, Object> parameters) { + Map<String, Object> resultMap = new HashMap<>(); + int orgId = Integer.parseInt(parameters.get("organization_id").toString()); + /* //���������������������������������id + List<Integer> allOrgId = new ArrayList<>(); + allOrgId.add(orgId); + //������������ + //��������������� + List<Organization> allChildrenOrganization = organizationService.getChildrenOrganizationsById(orgId); + if (!ObjectUtils.isEmpty(allChildrenOrganization) || allChildrenOrganization.size() < 1){ + for (Organization organization:allChildrenOrganization) { + allOrgId.add(organization.getId()); + } + } + //������������ + List<Integer> allOrgIdWithoutDuplicates = allOrgId.stream().distinct().collect(Collectors.toList()); + //������������list���������������id + List<Integer> deviceIdList = new ArrayList<>(); + for (Integer orgIdWithoutDuplicates:allOrgIdWithoutDuplicates) { + //������id������������������ + QueryWrapper<Device> wrapper_device = new QueryWrapper<>(); + wrapper_device.eq("is_delete",Constants.NOT_DELETE).eq("organization_id",orgIdWithoutDuplicates); + List<Device> devices = new ArrayList<>(); + devices = deviceMapper.selectList(wrapper_device); + if (devices.size()>0){ + for (Device device:devices) { + int deviceId = device.getId(); + deviceIdList.add(deviceId); + } + }else { + continue; + } + }*/ + List<Integer> deviceIdList = deviceMapper.deviceIdList(orgId); + if (deviceIdList.size()>0){ + Map<String, Object> map = new HashMap<>(); + QueryWrapper<AlarmInfo> alarmInfoQueryWrapper = new QueryWrapper<>(); + map.put("deviceIds",deviceIdList); + alarmInfoQueryWrapper.in("device_id",deviceIdList); + String startTime = parameters.get("startTime")+" 00:00:00"; + String endTime = parameters.get("endTime")+" 23:59:59"; + map.put("startTime",startTime); + map.put("endTime",endTime); + alarmInfoQueryWrapper.between("alarm_time", startTime, endTime); + String index = parameters.get("index").toString(); + if (!index.equals("all")){ + map.put("index",index); + alarmInfoQueryWrapper.eq("`index`", index); + } + String alarmType = parameters.get("alarmType").toString(); + switch (alarmType){ + case "overrun" : map.put("alarmType","������"); + alarmInfoQueryWrapper.eq("alarm_type","������"); + break; + case "sudden" : map.put("alarmType","���������"); + alarmInfoQueryWrapper.eq("alarm_type","���������"); + break; + case "state100" : map.put("alarmType","������������������100%"); + alarmInfoQueryWrapper.eq("alarm_type","������������������100%"); + break; + case "state150" : map.put("alarmType","������������������150%"); + alarmInfoQueryWrapper.eq("alarm_type","������������������150%"); + break; + case "state250" : map.put("alarmType","������������������250%"); + alarmInfoQueryWrapper.eq("alarm_type","������������������250%"); + break; + case "city150" : map.put("alarmType","������������������150%"); + alarmInfoQueryWrapper.eq("alarm_type","������������������150%"); + break; + case "city250" : map.put("alarmType","������������������250%"); + alarmInfoQueryWrapper.eq("alarm_type","������������������250%"); + break; + default:break; + } + List<Map<String, Object>> resultList = alarmInfoMapper.selectDataByConditionWithoutPage(map); + SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + for (Map<String, Object> alarmInfo:resultList) { + String alarm_time = SDF.format(alarmInfo.get("alarm_time")); + alarmInfo.put("alarm_time",alarm_time); + } + Integer totalNumber = alarmInfoMapper.selectCount(alarmInfoQueryWrapper); + resultMap.put("alarmInfos", resultList); + return resultMap; + } + return null; + } + + @Override + public Map<String, Object> alarmReminder(Map<String, Object> parameters) { + Map<String,Object> resultMap = new HashMap<>(); + int orgId = Integer.parseInt(parameters.get("organization_id").toString()); + /*//���������������������������������id + List<Integer> allOrgId = new ArrayList<>(); + allOrgId.add(orgId); + //������������ + //��������������� + List<Organization> allChildrenOrganization = organizationService.getChildrenOrganizationsById(orgId); + if (!ObjectUtils.isEmpty(allChildrenOrganization) || allChildrenOrganization.size() < 1){ + for (Organization organization:allChildrenOrganization) { + allOrgId.add(organization.getId()); + } + } + //������������ + List<Integer> allOrgIdWithoutDuplicates = allOrgId.stream().distinct().collect(Collectors.toList()); + //������������list���������������id + List<Integer> deviceIdList = new ArrayList<>(); + for (Integer orgIdWithoutDuplicates:allOrgIdWithoutDuplicates) { + //������id������������������ + QueryWrapper<Device> wrapper_device = new QueryWrapper<>(); + wrapper_device.eq("is_delete",Constants.NOT_DELETE).eq("organization_id",orgIdWithoutDuplicates); + List<Device> devices = new ArrayList<>(); + devices = deviceMapper.selectList(wrapper_device); + if (devices.size()>0){ + for (Device device:devices) { + int deviceId = device.getId(); + deviceIdList.add(deviceId); + } + }else { + continue; + } + }*/ + // if (deviceIdList.size()>0){ + Map<String, Object> map = new HashMap<>(); + //map.put("deviceIds",deviceIdList); + int size = Integer.parseInt(parameters.get("size").toString()); + map.put("size",size); + map.put("orgId",orgId); + List<Map<String, Object>> resultList = alarmInfoMapper.selectNewestData(map); + SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + for (Map<String, Object> alarmInfo:resultList) { + String alarm_time = SDF.format(alarmInfo.get("alarm_time")); + alarmInfo.put("alarm_time",alarm_time); + } + resultMap.put("alarmInfors",resultList); + Integer totalNumber = alarmInfoMapper.numNews(orgId); + /*QueryWrapper<AlarmInfo> alarmInfoQueryWrapper = new QueryWrapper<>(); + alarmInfoQueryWrapper.in("device_id",deviceIdList); + Integer totalNumber = alarmInfoMapper.selectCount(alarmInfoQueryWrapper);*/ + resultMap.put("totalNumber",totalNumber); + return resultMap; + // } + // return null; + } + + @Override + public Map<String, Object> alarmReminderByMonitorPointIds(Map<String, Object> parameters) { + Map<String, Object> resultMap = new HashMap<>(); + String monitorPointIds = parameters.get("monitorPointIds").toString(); + monitorPointIds.replace("[",""); + monitorPointIds.replace("]",""); + String[] monitorPointIdArray = monitorPointIds.split(","); + List<String> monitorPointIdList = new ArrayList<>(Arrays.asList(monitorPointIdArray)); + //������������list���������������id + List<Integer> deviceIdList = new ArrayList<>(); + //������id������������������ + QueryWrapper<Device> wrapper_device = new QueryWrapper<>(); + wrapper_device.eq("is_delete",Constants.NOT_DELETE); + wrapper_device.in("monitor_point_id",monitorPointIdList); + List<Device> devices = new ArrayList<>(); + devices = deviceMapper.selectList(wrapper_device); + if (devices.size()>0){ + for (Device device:devices) { + int deviceId = device.getId(); + deviceIdList.add(deviceId); + } + } + if (deviceIdList.size()>0){ + Map<String, Object> map = new HashMap<>(); + map.put("deviceIds",deviceIdList); + int size = Integer.parseInt(parameters.get("size").toString()); + map.put("size",size); + List<Map<String, Object>> resultList = alarmInfoMapper.selectNewestData(map); + SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + for (Map<String, Object> alarmInfo:resultList) { + String alarm_time = SDF.format(alarmInfo.get("alarm_time")); + alarmInfo.put("alarm_time",alarm_time); + } + resultMap.put("alarmInfors",resultList); + QueryWrapper<AlarmInfo> alarmInfoQueryWrapper = new QueryWrapper<>(); + alarmInfoQueryWrapper.in("device_id",deviceIdList); + Integer totalNumber = alarmInfoMapper.selectCount(alarmInfoQueryWrapper); + resultMap.put("totalNumber",totalNumber); + return resultMap; } return null; } -- Gitblit v1.8.0