From 1cb75b4e73f4753d5df9ddc5709cb4b2b9cbba38 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Wed, 20 Mar 2024 19:10:25 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=A9=E6=B0=94?= =?UTF-8?q?=E6=B0=94=E8=B1=A1=E9=A2=84=E8=AD=A6=E4=BF=A1=E6=81=AF=E5=9B=9E?= =?UTF-8?q?=E4=BC=A0=20=E4=BF=AE=E6=94=B9=E5=9C=A8=E7=BA=BF=E7=8E=87?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E4=BD=BF=E7=94=A8=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BroadcastController.java | 2 +- .../business/controller/StatusController.java | 5 ++++- .../controller/WeatherForecastController.java | 17 ++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/BroadcastController.java b/zc-business/src/main/java/com/zc/business/controller/BroadcastController.java index 379183cd..c76957cb 100644 --- a/zc-business/src/main/java/com/zc/business/controller/BroadcastController.java +++ b/zc-business/src/main/java/com/zc/business/controller/BroadcastController.java @@ -39,7 +39,7 @@ public class BroadcastController extends BaseController { private static final String SECRET = "21232f297a57a5a743894a0e4a801fc3"; - private static final String CALLBACKURL = "http://10.0.81.209/broadcast/logIn"; + private static final String CALLBACKURL = "http://10.0.81.202/broadcast/logIn"; private final static String URL = HTTP + "10.0.81.106/api/REST-API/"; diff --git a/zc-business/src/main/java/com/zc/business/controller/StatusController.java b/zc-business/src/main/java/com/zc/business/controller/StatusController.java index 691175fa..ba211c23 100644 --- a/zc-business/src/main/java/com/zc/business/controller/StatusController.java +++ b/zc-business/src/main/java/com/zc/business/controller/StatusController.java @@ -207,8 +207,11 @@ public class StatusController extends BaseController { maps.put("sucessRate",String.format("%.2f", sucessRate)+"%"); //离线率 maps.put("failRate",failRate); + List list = dcDeviceService.list(); + //已使用数量 + maps.put("sumUseState",String.valueOf(lastEntry.size())); //总数 - maps.put("sum",String.valueOf(lastEntry.size())); + maps.put("sum",String.valueOf(list.size())); subMap.put("全部设备",maps); return AjaxResult.success(subMap); diff --git a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java index 9ff01fbe..c6915458 100644 --- a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java +++ b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java @@ -116,15 +116,14 @@ public class WeatherForecastController extends BaseController { JSONArray meteorologicalEarlyWarning6 = jsonObject.getJSONArray("meteorologicalEarlyWarning6"); JSONArray meteorologicalEarlyWarning7 = jsonObject.getJSONArray("meteorologicalEarlyWarning7"); JSONArray meteorologicalEarlyWarning8 = jsonObject.getJSONArray("meteorologicalEarlyWarning8"); - return AjaxResult.success(meteorologicalEarlyWarning1.size() + - meteorologicalEarlyWarning2.size() + - meteorologicalEarlyWarning3.size() + - meteorologicalEarlyWarning4.size() + - meteorologicalEarlyWarning5.size() + - meteorologicalEarlyWarning6.size() + - meteorologicalEarlyWarning7.size() + - meteorologicalEarlyWarning8.size() - ); + return AjaxResult.success((meteorologicalEarlyWarning1 == null ? 0 : meteorologicalEarlyWarning1.size()) + + (meteorologicalEarlyWarning2 == null ? 0 : meteorologicalEarlyWarning2.size()) + + (meteorologicalEarlyWarning3 == null ? 0 : meteorologicalEarlyWarning3.size()) + + (meteorologicalEarlyWarning4 == null ? 0 : meteorologicalEarlyWarning4.size()) + + (meteorologicalEarlyWarning5 == null ? 0 : meteorologicalEarlyWarning5.size()) + + (meteorologicalEarlyWarning6 == null ? 0 : meteorologicalEarlyWarning6.size()) + + (meteorologicalEarlyWarning7 == null ? 0 : meteorologicalEarlyWarning7.size()) + + (meteorologicalEarlyWarning8 == null ? 0 : meteorologicalEarlyWarning8.size())); } From 7d8bdfbf5eacd0a75e506f4b688826cf1f72d4b1 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Wed, 20 Mar 2024 19:25:50 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8E=82=E5=95=86=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/business/DcDeviceMapper.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml b/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml index c7e78309..7c2e06e7 100644 --- a/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml @@ -32,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -73,9 +74,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select t1.id, t1.iot_device_id, t1.group_id, t1.product_id, t1.stake_mark, t1.direction, t1.device_name, t1.device_code, t1.device_type, t1.installation_Date,t1.production_date,t1.durable_years,t1.installation_site,t1.use_state,t1.device_state,t1.other_config,t1.remark, t1.create_time,t1.update_time,t1.facilities_type,t1.device_ip,t1.stake_mark_range,t1.device_img,t1.child_type, - t1.facilities_type,t2.longitude,t2.latitude + t1.facilities_type,t2.longitude,t2.latitude,t3.manufacturer from dc_device t1 left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction + left join dc_product t3 on t3.id = t1.product_id and t1.id = #{id} and t1.iot_device_id = #{iotDeviceId} From 2fa877d04529b302cefe6c89b446eac655943a69 Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Thu, 21 Mar 2024 09:33:20 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=BD=93=E5=A4=A9=E8=AE=BE=E5=A4=87=E6=8C=87=E5=AE=9A=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/zc/business/controller/DcDeviceController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java index d0b0f0c3..113d1b76 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java @@ -229,6 +229,8 @@ public class DcDeviceController extends BaseController { // 将日期列表以逗号分隔并设置为查询条件的值 props.put("terms[0].value", String.join(",", dateList)); props.put("paging", false); + props.put("sorts[0].order","asc"); + props.put("sorts[0].name","timestamp"); AjaxResult ajaxResult = queryDeviceProperties(deviceId, propertyId, props); if (!ajaxResult.get("code").equals(200)) { return ajaxResult; From dacd76f371177e39e32ce8e678360a200cea7489 Mon Sep 17 00:00:00 2001 From: wangsixiang <2970484253@qq.com> Date: Thu, 21 Mar 2024 09:43:58 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E7=BC=93=E5=AD=98=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DcWarningServiceImpl.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java index 266a685e..a52ca768 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java @@ -89,27 +89,23 @@ public class DcWarningServiceImpl implements IDcWarningService @Override public int insertDcWarning(DcWarning dcWarning) { - dcWarning.setCreateTime(DateUtils.getNowDate()); //设置事件Id UUID无下划线格式32 String uuid = IdUtils.fastSimpleUUID(); dcWarning.setId(uuid); - int priority = new DcWarningServiceImpl().priority(dcWarning); - if (priority==0){ - return 0; - } return dcWarningMapper.insertDcWarning(dcWarning); + } //优先级策略 public int priority(DcWarning dcWarning){ if (StringUtils.isBlank(dcWarning.getStakeMark())||dcWarning.getWarningSource()==null||dcWarning.getWarningType()==null|| - StringUtils.isBlank(dcWarning.getWarningSubclass())||StringUtils.isBlank(dcWarning.getDirection())){ + StringUtils.isBlank(dcWarning.getWarningSubclass())||StringUtils.isBlank(dcWarning.getDirection())){ return 0; } String redisKye=dcWarning.getWarningSource().toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//配置数据的key 事件源+事件类型+策略 - Map redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//获取缓存全部的配置数据 - if (redisWarningStrategy==null){//如果缓存为空,查询数据重新加入缓存 + Map redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//获取缓存全部的配置数据 + if (redisWarningStrategy==null||redisWarningStrategy.size()==0){//如果缓存为空,查询数据重新加入缓存 Map redisMap = new HashMap<>(); List dcWaringStrategies = dcWarningMapper.selectDcWaringStrategyList();//数据库全部配置数据 for (DcWaringStrategy waringStrategy : dcWaringStrategies) { @@ -118,7 +114,7 @@ public class DcWarningServiceImpl implements IDcWarningService JSONObject jsonObject = new JSONObject(); jsonObject.put("strategy", waringStrategy.getStrategy());//策略模式 jsonObject.put("strategyTime", waringStrategy.getStrategyTime());//模式时长,单位为分钟 - jsonObject.put("priority", waringStrategy.getPriority());//策略模式 + jsonObject.put("priority", waringStrategy.getPriority());//优先级 redisMap.put(key, jsonObject); } redisCache.setCacheMap(WARNINGSTRATEGY, redisMap);//数据库配置数据加入缓存中 @@ -127,24 +123,28 @@ public class DcWarningServiceImpl implements IDcWarningService String key=dcWarning.getStakeMark()+dcWarning.getDirection()+dcWarning.getWarningSource(). toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//key,redis存储事件的key(桩号+方向+事件源+类型) String dataId = redisCache.getCacheObject(WARNINGDATA + key);//查看redis是否存在数据(id的值) - JSONObject redisValueOne = redisWarningStrategy.get(redisKye+"1");//查看传入的事件类型是否配置策略1(优先级策略) + HashMap redisValueOne = redisWarningStrategy.get(redisKye+"1");//查看传入的事件类型是否配置策略1(优先级策略) if(redisValueOne!=null){//执行策略1(暂时未定义,定义后开发) } - JSONObject redisValueTwo = redisWarningStrategy.get(redisKye+"2");//查看传入的事件类型是否配置策略2(延迟策略) + HashMap redisValueTwo = redisWarningStrategy.get(redisKye+"2");//查看传入的事件类型是否配置策略2(延迟策略) if (redisValueOne==null&&redisValueTwo!=null){ //执行策略2,执行到这里说明1不存在或者1未满足过滤条件 - String strategyTime = redisValueTwo.getString("strategyTime").toString();//策略时长 + String strategyTime = redisValueTwo.get("strategyTime").toString();//策略时长 if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间 - int insertDcWarning = new DcWarningServiceImpl().insertDcWarning(dcWarning);//加入数据库 + int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库 if (insertDcWarning==0){ return 0; } String id = dcWarning.getId();//取出加入后的id作为value redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟) + return 1;//结束 } //redis存在数据,取出redis的id找对对应事件的配置,合成事件配置,重新定义延迟时间 HashMap map = dcWarningMapper.selectDcWarningById(dataId); - String otherConfig = map.get("otherConfig").toString();//取出原id的配置信息 + String otherConfig=""; + if (map.get("otherConfig")!=null){ + otherConfig = map.get("otherConfig").toString(); //取出原id的配置信息 + } String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息 JSONObject jsonObjectOne = new JSONObject(otherConfig); JSONObject jsonObjectTwo = new JSONObject(otherConfigString); @@ -156,7 +156,7 @@ public class DcWarningServiceImpl implements IDcWarningService } return 1; } - JSONObject redisValueThree = redisWarningStrategy.get(redisKye+"3");//查看传入的事件类型是否配置策略3(时间窗口策略) + HashMap redisValueThree = redisWarningStrategy.get(redisKye+"3");//查看传入的事件类型是否配置策略3(时间窗口策略) if (redisValueOne==null&&redisValueTwo==null&&redisValueThree!=null){ //执行策略3,执行到这里说明1不存在或者2不存在或者1未满足过滤条件 if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间(30分钟) int insertDcWarning = new DcWarningServiceImpl().insertDcWarning(dcWarning);//加入数据库 @@ -179,7 +179,7 @@ public class DcWarningServiceImpl implements IDcWarningService } return 1; } - JSONObject redisValueFour = redisWarningStrategy.get(redisKye+"4");//查看传入的事件类型是否配置策略3(自动结束策略) + HashMap redisValueFour = redisWarningStrategy.get(redisKye+"4");//查看传入的事件类型是否配置策略3(自动结束策略) if (redisValueOne==null&&redisValueTwo==null&&redisValueThree==null&&redisValueFour!=null){ //执行策略4,执行到这里说明1不存在或者2、3不存在或者1未满足过滤条件 if (dataId==null){//如果不存在直接加入数据库,加入缓存 int insertDcWarning = new DcWarningServiceImpl().insertDcWarning(dcWarning);//加入数据库 @@ -203,7 +203,7 @@ public class DcWarningServiceImpl implements IDcWarningService } return 1; } - return 1; + return dcWarningMapper.insertDcWarning(dcWarning);//如果没有配置策略直接加入数据库; } private JSONObject mergeJsonObjects(JSONObject jsonObjectOne, JSONObject jsonObjectTwo){ // 合并videoList From cc1968351b7a9526dcec76b1cc2dd3a11019b43f Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Thu, 21 Mar 2024 11:20:17 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8D=95=E4=B8=AA=E8=AE=BE=E5=A4=87=E5=9C=A8=E7=BA=BF=E7=8E=87?= =?UTF-8?q?=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/controller/StatusController.java | 28 +++++++++---------- .../com/zc/business/mapper/StatusMapper.java | 1 + .../business/service/impl/StatusService.java | 3 ++ .../mapper/business/StatusMapper.xml | 13 +++++++++ 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/StatusController.java b/zc-business/src/main/java/com/zc/business/controller/StatusController.java index ba211c23..00d235f4 100644 --- a/zc-business/src/main/java/com/zc/business/controller/StatusController.java +++ b/zc-business/src/main/java/com/zc/business/controller/StatusController.java @@ -13,10 +13,7 @@ import com.zc.business.service.impl.StatusService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.time.LocalDateTime; @@ -99,9 +96,8 @@ public class StatusController extends BaseController { @ApiOperation("根据设备Id查询折线图数据") - @GetMapping("/deviceStatusList") - public AjaxResult getDeviceStatusList(Long deviceId) { - + @GetMapping("/deviceStatusList/{deviceId}") + public AjaxResult getDeviceStatusList(@PathVariable Long deviceId) { LocalDateTime thirtyDaysAgo = LocalDateTime.now().minusDays(30); LocalDateTime currentTime = LocalDateTime.now(); @@ -110,20 +106,22 @@ public class StatusController extends BaseController { status.setTime(currentTime); status.setDeviceId(deviceId); - List listStatus = statusService.list(status); + List listStatus = statusService.deviceStatusListById(status); - // Group by day and calculate average successRate with two decimal places - Map averageSuccessRateByDay = listStatus.stream() + // Calculate average successRate by day + Map averageSuccessRateByDay = listStatus.stream() .collect(Collectors.groupingBy(s -> s.getTime().getDayOfMonth(), - Collectors.collectingAndThen( - Collectors.averagingDouble(s -> Double.parseDouble(s.getSuccessRate().replace("%", ""))), - avg -> Math.round(Float.parseFloat(String.format("%.2f", avg))) - ))); + Collectors.averagingDouble(s -> Double.parseDouble(s.getSuccessRate().replace("%", ""))))); + if (averageSuccessRateByDay.isEmpty()) { return AjaxResult.success("暂无数据"); } - return AjaxResult.success(averageSuccessRateByDay); + // Round average successRate to two decimal places + Map roundedAverageSuccessRateByDay = averageSuccessRateByDay.entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> Math.round(entry.getValue() * 100.0) / 100.0)); + + return AjaxResult.success(roundedAverageSuccessRateByDay); } //按类型划分设备 diff --git a/zc-business/src/main/java/com/zc/business/mapper/StatusMapper.java b/zc-business/src/main/java/com/zc/business/mapper/StatusMapper.java index 1980b0c8..9626befa 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/StatusMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/StatusMapper.java @@ -17,5 +17,6 @@ public interface StatusMapper { int Add(@Param("status")Status status); List listStatus(@Param("status")Status status); + List deviceStatusListById(@Param("status")Status status); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/StatusService.java b/zc-business/src/main/java/com/zc/business/service/impl/StatusService.java index f1e4ef64..93c42b31 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/StatusService.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/StatusService.java @@ -30,4 +30,7 @@ public class StatusService { return list; } + public List deviceStatusListById(Status status) { + return statusMapper.deviceStatusListById(status); + } } diff --git a/zc-business/src/main/resources/mapper/business/StatusMapper.xml b/zc-business/src/main/resources/mapper/business/StatusMapper.xml index 2f303a32..cc5d9b16 100644 --- a/zc-business/src/main/resources/mapper/business/StatusMapper.xml +++ b/zc-business/src/main/resources/mapper/business/StatusMapper.xml @@ -109,4 +109,17 @@ + + From 2c65803a1dec5373e2c3798e4103bd0f89c50df0 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Thu, 21 Mar 2024 11:46:14 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=A8=E7=BA=BF?= =?UTF-8?q?=E7=8E=87=E8=AE=BE=E5=A4=87=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/zc/business/controller/DeviceStatus.java | 1 - 1 file changed, 1 deletion(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java b/zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java index e307a436..2c2b54c2 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java +++ b/zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java @@ -49,7 +49,6 @@ public class DeviceStatus { StatusService statusService= SpringUtils.getBean(StatusService.class); ExecutorService executor = Executors.newFixedThreadPool(100); LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(DcDevice::getUseState,1); List deviceList = deviceService.list(lambdaQueryWrapper); List> futures = new ArrayList<>(); From 5dde7fce019917cbf1f815bd7ea9a667bc093eaa Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Thu, 21 Mar 2024 11:48:39 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=A8=E7=BA=BF?= =?UTF-8?q?=E7=8E=87=E8=AE=BE=E5=A4=87=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E5=9C=A8=E7=BA=BF=E7=8E=87=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zc/business/controller/StatusController.java | 11 ++++++----- .../java/com/zc/business/mapper/DcDeviceMapper.java | 2 +- .../com/zc/business/service/IDcDeviceService.java | 2 +- .../zc/business/service/impl/DcDeviceServiceImpl.java | 4 ++-- .../main/resources/mapper/business/DcDeviceMapper.xml | 5 +++++ .../main/resources/mapper/business/StatusMapper.xml | 3 --- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/StatusController.java b/zc-business/src/main/java/com/zc/business/controller/StatusController.java index 00d235f4..cb1a077c 100644 --- a/zc-business/src/main/java/com/zc/business/controller/StatusController.java +++ b/zc-business/src/main/java/com/zc/business/controller/StatusController.java @@ -129,7 +129,9 @@ public class StatusController extends BaseController { @GetMapping ("/type") public AjaxResult getTypeList() { - List dcDeviceList = dcDeviceService.numberOfDevicesByType(); + DcDevice dcDevice = new DcDevice(); + dcDevice.setUseState(1); + List dcDeviceList = dcDeviceService.numberOfDevicesByType(dcDevice); HashMap itemTypeMap = new HashMap<>(); itemTypeMap.put("1-1", "高清网络枪型固定摄像机"); itemTypeMap.put("1-2", "高清网络球形摄像机"); @@ -153,7 +155,6 @@ public class StatusController extends BaseController { Status status = new Status(); status.setStartTime(todayStart); status.setTime(currentTime); - status.setUseState(1); List listStatus = statusService.list(status); //根据时间分组 Map> map = listStatus.stream() @@ -184,9 +185,9 @@ public class StatusController extends BaseController { //离线率 maps.put("failRate",failRate); //已使用数量 - maps.put("sumUseState",String.valueOf(groupItems.size())); + maps.put("sum",String.valueOf(groupItems.size())); //总数 - maps.put("sum", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), entrys.getKey())).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0))); + maps.put("sumUseState", String.valueOf(dcDeviceList.stream().filter(item -> Objects.equals(item.getDeviceType(), entrys.getKey())).map(DcDevice::getSumAll).collect(Collectors.toList()).get(0))); if(itemTypeMap.get(entrys.getKey())!=null) { subMap.put(itemTypeMap.get(entrys.getKey()), maps); } @@ -205,8 +206,8 @@ public class StatusController extends BaseController { maps.put("sucessRate",String.format("%.2f", sucessRate)+"%"); //离线率 maps.put("failRate",failRate); - List list = dcDeviceService.list(); //已使用数量 + List list = dcDeviceService.list(); maps.put("sumUseState",String.valueOf(lastEntry.size())); //总数 maps.put("sum",String.valueOf(list.size())); diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java index 1318201f..0fb3a492 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcDeviceMapper.java @@ -15,7 +15,7 @@ import java.util.List; public interface DcDeviceMapper extends BaseMapper { List selectDcDeviceList(DcDevice dcDevice); - List numberOfDevicesByType(); + List numberOfDevicesByType(DcDevice dcDevice); } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java b/zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java index 5e401f43..9ccb83fe 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcDeviceService.java @@ -78,5 +78,5 @@ public interface IDcDeviceService extends IService { List devicePileNumberQueryDevice(Map parameter); - List numberOfDevicesByType(); + List numberOfDevicesByType(DcDevice dcDevice); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java index 0fb6b647..f011b351 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcDeviceServiceImpl.java @@ -448,8 +448,8 @@ public class DcDeviceServiceImpl extends ServiceImpl i } @Override - public List numberOfDevicesByType() { - return dcDeviceMapper.numberOfDevicesByType(); + public List numberOfDevicesByType(DcDevice dcDevice) { + return dcDeviceMapper.numberOfDevicesByType(dcDevice); } public static List castList(Object obj, Class clazz) { diff --git a/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml b/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml index 7c2e06e7..cd5f9e41 100644 --- a/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcDeviceMapper.xml @@ -110,6 +110,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/zc-business/src/main/resources/mapper/business/StatusMapper.xml b/zc-business/src/main/resources/mapper/business/StatusMapper.xml index cc5d9b16..94b29f40 100644 --- a/zc-business/src/main/resources/mapper/business/StatusMapper.xml +++ b/zc-business/src/main/resources/mapper/business/StatusMapper.xml @@ -103,9 +103,6 @@ AND s.device_id = #{status.deviceId} - - AND d.use_state = #{status.useState} -