From 75fdd151827559bf7f9f10748fcbda2fdcd96021 Mon Sep 17 00:00:00 2001 From: "liang.chao" <1360241448@qq.com> Date: Tue, 27 Aug 2024 15:53:56 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=81=9C=E7=95=99?= =?UTF-8?q?=E7=82=B9=E5=A2=9E=E5=8A=A0=E7=BB=8F=E7=BA=AC=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/IotMachineServiceImpl.java | 76 +++++++++++-------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java index 1ac01251..d19a8660 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java @@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -30,6 +31,7 @@ import java.util.concurrent.TimeUnit; /** * iot设备管理实现层 + * * @author ma_sh */ @Service @@ -283,6 +285,7 @@ public class IotMachineServiceImpl implements IotMachineService { /** * 获取定位 + * * @param iotDto * @return */ @@ -292,20 +295,20 @@ public class IotMachineServiceImpl implements IotMachineService { if (iotDto == null || StringUtils.isBlank(iotDto.getIotId())) { throw new RuntimeException(ExceptionEnum.PARAM_NULL.getMsg()); } - List list=new ArrayList<>(); - Map map=new HashMap<>(); + List list = new ArrayList<>(); + Map map = new HashMap<>(); //从redis中获取token String redisCode = redisService.getCacheObject(TokenConstants.TOKEN_LOCATION); //如果token为空,先去调登录接口,获取token - if (redisCode == null){ + if (redisCode == null) { redisCode = HttpHelper.getIotToken(); - redisService.setCacheObject(TokenConstants.TOKEN_LOCATION,redisCode,23L, TimeUnit.HOURS); + redisService.setCacheObject(TokenConstants.TOKEN_LOCATION, redisCode, 23L, TimeUnit.HOURS); } map.clear(); list.add(iotDto.getIotId()); - map.put("deviceids",list); + map.put("deviceids", list); String param = JSON.toJSONString(map); - String res = HttpHelper.doPost(HttpStatus.LAST_POSITION_URL+redisCode,param); + String res = HttpHelper.doPost(HttpStatus.LAST_POSITION_URL + redisCode, param); //对返回的结果进行解析 IotLocationVo iotLocationVo = resultDataHandler(res); log.info("resultDataHandler:{}", iotLocationVo); @@ -314,6 +317,7 @@ public class IotMachineServiceImpl implements IotMachineService { /** * 查询行程 + * * @param iotLocationVo * @return */ @@ -323,25 +327,26 @@ public class IotMachineServiceImpl implements IotMachineService { if (iotLocationVo == null || iotLocationVo.getBeginTime() == null || iotLocationVo.getEndTime() == null) { throw new RuntimeException(ExceptionEnum.PARAM_NULL.getMsg()); } - Map map=new HashMap<>(); + Map map = new HashMap<>(); //从redis中获取token String redisCode = redisService.getCacheObject(TokenConstants.TOKEN_LOCATION); //如果token为空,先去调登录接口,获取token - if (redisCode == null){ + if (redisCode == null) { redisCode = HttpHelper.getIotToken(); - redisService.setCacheObject(TokenConstants.TOKEN_LOCATION,redisCode,23L, TimeUnit.HOURS); + redisService.setCacheObject(TokenConstants.TOKEN_LOCATION, redisCode, 23L, TimeUnit.HOURS); } map.clear(); - map.put("deviceid",iotLocationVo.getIotId()); - map.put("begintime",iotLocationVo.getBeginTime()); - map.put("endtime",iotLocationVo.getEndTime()); + map.put("deviceid", iotLocationVo.getIotId()); + map.put("begintime", iotLocationVo.getBeginTime()); + map.put("endtime", iotLocationVo.getEndTime()); String param = JSON.toJSONString(map); - String res = HttpHelper.doPost(HttpStatus.QUERY_TRIPS_URL+redisCode,param); + String res = HttpHelper.doPost(HttpStatus.QUERY_TRIPS_URL + redisCode, param); return AjaxResult.success(res); } /** * 查询停留点 + * * @param iotLocationVo * @return */ @@ -352,20 +357,20 @@ public class IotMachineServiceImpl implements IotMachineService { if (iotLocationVo == null || iotLocationVo.getBeginTime() == null || iotLocationVo.getEndTime() == null) { throw new RuntimeException(ExceptionEnum.PARAM_NULL.getMsg()); } - Map map=new HashMap<>(); + Map map = new HashMap<>(); //从redis中获取token String redisCode = redisService.getCacheObject(TokenConstants.TOKEN_LOCATION); //如果token为空,先去调登录接口,获取token - if (redisCode == null){ + if (redisCode == null) { redisCode = HttpHelper.getIotToken(); - redisService.setCacheObject(TokenConstants.TOKEN_LOCATION,redisCode,23L, TimeUnit.HOURS); + redisService.setCacheObject(TokenConstants.TOKEN_LOCATION, redisCode, 23L, TimeUnit.HOURS); } map.clear(); - map.put("deviceid",iotLocationVo.getIotId()); - map.put("begintime",iotLocationVo.getBeginTime()); - map.put("endtime",iotLocationVo.getEndTime()); + map.put("deviceid", iotLocationVo.getIotId()); + map.put("begintime", iotLocationVo.getBeginTime()); + map.put("endtime", iotLocationVo.getEndTime()); String param = JSON.toJSONString(map); - String res = HttpHelper.doPost(HttpStatus.REPORT_PARK_DETAIL_BY_TIME_URL+redisCode,param); + String res = HttpHelper.doPost(HttpStatus.REPORT_PARK_DETAIL_BY_TIME_URL + redisCode, param); //对返回的结果进行解析 List iotLocationVoList = resultReportParkDetailByTime(res); log.info("resultDataHandler:{}", iotLocationVo); @@ -374,6 +379,7 @@ public class IotMachineServiceImpl implements IotMachineService { /** * 解析停留点返回报文 + * * @param res * @return */ @@ -388,7 +394,7 @@ public class IotMachineServiceImpl implements IotMachineService { if ("OK".equals(cause) && "0".equals(status)) { String records = object.getString("records"); //判断返回结果是否为空 - if (records != null){ + if (records != null) { JSONArray jsonArray = JSON.parseArray(records); for (int i = 0; i < jsonArray.size(); i++) { IotLocationVo iotLocationVo = new IotLocationVo(); @@ -396,6 +402,8 @@ public class IotMachineServiceImpl implements IotMachineService { iotLocationVo.setBeginTime(jsonObject.getString("starttime")); iotLocationVo.setEndTime(jsonObject.getString("endtime")); iotLocationVo.setAddress(jsonObject.getString("address")); + iotLocationVo.setCallat(new BigDecimal(jsonObject.getString("callat"))); + iotLocationVo.setCallon(new BigDecimal(jsonObject.getString("callon"))); iotLocationVoList.add(iotLocationVo); } } @@ -405,6 +413,7 @@ public class IotMachineServiceImpl implements IotMachineService { /** * 绑定设备APP + * * @param iotDto * @return */ @@ -445,6 +454,7 @@ public class IotMachineServiceImpl implements IotMachineService { /** * 报警记录 + * * @param iotLocationVo * @return */ @@ -455,24 +465,24 @@ public class IotMachineServiceImpl implements IotMachineService { throw new RuntimeException(ExceptionEnum.PARAM_NULL.getMsg()); } - Map map=new HashMap<>(); - List list=new ArrayList<>(); + Map map = new HashMap<>(); + List list = new ArrayList<>(); //从redis中获取token String redisCode = redisService.getCacheObject(TokenConstants.TOKEN_LOCATION); //如果token为空,先去调登录接口,获取token - if (redisCode == null){ + if (redisCode == null) { redisCode = HttpHelper.getIotToken(); - redisService.setCacheObject(TokenConstants.TOKEN_LOCATION,redisCode,23L, TimeUnit.HOURS); + redisService.setCacheObject(TokenConstants.TOKEN_LOCATION, redisCode, 23L, TimeUnit.HOURS); } map.clear(); list.add(iotLocationVo.getIotId().toString()); - map.put("devices",list); - map.put("startday",iotLocationVo.getBeginTime()); - map.put("endday",iotLocationVo.getEndTime()); + map.put("devices", list); + map.put("startday", iotLocationVo.getBeginTime()); + map.put("endday", iotLocationVo.getEndTime()); //报警类型 - map.put("needalarm",""); + map.put("needalarm", ""); String param = JSON.toJSONString(map); - String res = HttpHelper.doPost(HttpStatus.REPORT_ALARM_URL+redisCode,param); + String res = HttpHelper.doPost(HttpStatus.REPORT_ALARM_URL + redisCode, param); //对返回的结果进行解析 List iotLocationVoList = resultReportAlarm(res); log.info("resultDataHandler:{}", iotLocationVo); @@ -481,6 +491,7 @@ public class IotMachineServiceImpl implements IotMachineService { /** * 解析报警返回报文 + * * @param res * @return */ @@ -495,7 +506,7 @@ public class IotMachineServiceImpl implements IotMachineService { if ("OK".equals(cause) && "0".equals(status)) { String records = object.getString("alarmrecords"); //判断返回结果是否为空 - if (records != null){ + if (records != null) { JSONArray jsonArray = JSON.parseArray(records); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = JSONObject.from(jsonArray.getJSONObject(i)); @@ -512,6 +523,7 @@ public class IotMachineServiceImpl implements IotMachineService { /** * 解析定位返回报文 + * * @param res * @return */ @@ -526,7 +538,7 @@ public class IotMachineServiceImpl implements IotMachineService { if ("0".equals(status) && "OK".equals(cause)) { String records = object.getString("records"); //判断返回结果是否为空 - if (records != null){ + if (records != null) { JSONArray jsonArray = JSON.parseArray(records); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = JSONObject.from(jsonArray.getJSONObject(i)); From 76a98b70ea286318b9e1bb1de08da0b23e15bcde Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Tue, 27 Aug 2024 16:00:59 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E9=80=80=E6=96=99=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E6=97=B6,=E6=A3=80=E6=9F=A5=E7=BB=93=E7=AE=97=E8=A1=A8?= =?UTF-8?q?=E6=8B=BF=E5=88=B0=E5=BE=85=E9=80=80=E6=96=99=E6=95=B0=E9=87=8F?= =?UTF-8?q?,=E9=98=B2=E6=AD=A2=E5=A4=9A=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/app/BackReceiveMapper.xml | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml index d0bc4741..477bf57b 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml @@ -715,7 +715,7 @@ bad.audit_num as preNum, bad.status as status, bad.back_status as backStatus, - IFNULL(bad.audit_num,0)-IFNULL(aa.back_num,0) as num, + COALESCE(sai.num, 0) as num, bb.finished_back_num, mt.manage_type as manageType, mt.company_id as companyId, @@ -724,28 +724,19 @@ back_apply_details bad LEFT JOIN back_apply_info bai on bai.id=bad.parent_id LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id + LEFT JOIN (select agreement_id, COALESCE(num, 0) as num from slt_agreement_info where 'status'='0') sai on tta.agreement_id=sai.agreement_id LEFT JOIN ma_type mt on mt.type_id=bad.type_id LEFT JOIN ma_type mt2 ON mt2.type_id=mt.parent_id LEFT JOIN ( - SELECT + SELECT type_id as typeId, - SUM(IFNULL(back_num,0)) as back_num - FROM + SUM(IFNULL(back_num,0)) as finished_back_num + FROM back_check_details - WHERE - parent_id=#{id} - GROUP BY type_id - ) aa on aa.typeId=bad.type_id - LEFT JOIN ( - SELECT - type_id as typeId, - SUM(IFNULL(back_num,0)) as finished_back_num - FROM - back_check_details - WHERE - parent_id=#{id} and is_finished = 1 - GROUP BY type_id - ) bb on bb.typeId=bad.type_id + WHERE + parent_id=#{id} and is_finished = 1 + GROUP BY type_id + ) bb on bb.typeId=bad.type_id WHERE bai.id=#{id} From 20dd458628ead8eac7fb4c703fadbff9f49a9234 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Tue, 27 Aug 2024 16:02:25 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/system/SelectMapper.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SelectMapper.xml b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SelectMapper.xml index 3a0f41a0..8c89cb9a 100644 --- a/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SelectMapper.xml +++ b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SelectMapper.xml @@ -126,7 +126,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND mt.level IN ('1','2','3','4') - ORDER BY mt.create_time