Commit 48597b26a6cb1ef946ec5c2cbc979dfda8cc88d6
1 parent
04f65edd
修复bug
Showing
3 changed files
with
45 additions
and
36 deletions
trash-workFlow/src/main/java/com/trash/casefile/kafka/Consumer.java
| @@ -58,23 +58,29 @@ public class Consumer { | @@ -58,23 +58,29 @@ public class Consumer { | ||
| 58 | 58 | ||
| 59 | public void autoViolationWarning(String data,String id) throws InterruptedException, IOException { | 59 | public void autoViolationWarning(String data,String id) throws InterruptedException, IOException { |
| 60 | 60 | ||
| 61 | - String[] code = {"44030020=工地预警-未报开工作业", "44030021=工地预警-视频设备离线超时报警", "44030022=工地预警-三无车辆进入工地", "44030023=工地预警未按时间作业", | 61 | + String[] code = {"44030020=工地预警-未报开工作业", "44030021=工地预警-视频设备离线超时报警", "44030022=工地预警-三无车辆进入工地", "44030023=工地预警-未按时间作业", |
| 62 | "44030024=消纳场预警-未报开工作业", "44030025=消纳场预警-视频设备离线超时报警", "44030026=消纳场预警-三无车辆进入消纳场", "44030027=消纳场预警-未到指定的消纳场作业", | 62 | "44030024=消纳场预警-未报开工作业", "44030025=消纳场预警-视频设备离线超时报警", "44030026=消纳场预警-三无车辆进入消纳场", "44030027=消纳场预警-未到指定的消纳场作业", |
| 63 | "44030028=离线运输报警(工)", "44030029=离线运输报警(消)", "44030030=未激活车辆作业", "44030031=未核准作业车辆作业", "44030032=未按线路行驶", | 63 | "44030028=离线运输报警(工)", "44030029=离线运输报警(消)", "44030030=未激活车辆作业", "44030031=未核准作业车辆作业", "44030032=未按线路行驶", |
| 64 | "44030033=闯禁行驶", "44030034=失信车辆作业"}; | 64 | "44030033=闯禁行驶", "44030034=失信车辆作业"}; |
| 65 | JSONObject jsonObject = JSONObject.parseObject(data); | 65 | JSONObject jsonObject = JSONObject.parseObject(data); |
| 66 | + //报警时间 | ||
| 67 | + Date alarmTime = new Date(jsonObject.getLong("alarmTime")*1000L); | ||
| 66 | 68 | ||
| 67 | - String nowHour = DateFormatUtils.format(new Date(), "HH"); | 69 | + //这一块是一天内同一工地,同一类型的报警,只报有一条数据,不重复报工,只累加 |
| 70 | + String nowHour = DateFormatUtils.format(alarmTime, "HH"); | ||
| 68 | String nowDate = null; | 71 | String nowDate = null; |
| 69 | String tomorrowDate = null; | 72 | String tomorrowDate = null; |
| 70 | if(Integer.valueOf(nowHour)<8){ | 73 | if(Integer.valueOf(nowHour)<8){ |
| 71 | - nowDate = DateFormatUtils.format(DateUtils.addDays(new Date(), -1), "yyyy-MM-dd"); | ||
| 72 | - tomorrowDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd"); | 74 | + nowDate = DateFormatUtils.format(DateUtils.addDays(alarmTime, -1), "yyyy-MM-dd"); |
| 75 | + tomorrowDate = DateFormatUtils.format(alarmTime, "yyyy-MM-dd"); | ||
| 73 | }else{ | 76 | }else{ |
| 74 | - nowDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd"); | ||
| 75 | - tomorrowDate = DateFormatUtils.format(DateUtils.addDays(new Date(), 1), "yyyy-MM-dd"); | 77 | + nowDate = DateFormatUtils.format(alarmTime, "yyyy-MM-dd"); |
| 78 | + tomorrowDate = DateFormatUtils.format(DateUtils.addDays(alarmTime, 1), "yyyy-MM-dd"); | ||
| 76 | } | 79 | } |
| 77 | 80 | ||
| 81 | + //违规类型code | ||
| 82 | + String violationTypeCode = jsonObject.getString("alarmType"); | ||
| 83 | + //违规类型 | ||
| 78 | String violationType = jsonObject.getString("alarmName"); | 84 | String violationType = jsonObject.getString("alarmName"); |
| 79 | if(RemoteServerUtils.remote==null){ | 85 | if(RemoteServerUtils.remote==null){ |
| 80 | //登录 | 86 | //登录 |
| @@ -85,9 +91,9 @@ public class Consumer { | @@ -85,9 +91,9 @@ public class Consumer { | ||
| 85 | JSONArray company1 = null; | 91 | JSONArray company1 = null; |
| 86 | JSONObject basevehicleInfo = null; | 92 | JSONObject basevehicleInfo = null; |
| 87 | //这两种类型无需累加 | 93 | //这两种类型无需累加 |
| 88 | - if(violationType.equals("工地预警-视频设备离线超时报警") || violationType.equals("消纳场预警-视频设备离线超时报警")){ | 94 | + if(violationTypeCode.equals("44030021") || violationTypeCode.equals("44030025")){ |
| 89 | violationWarningInformation1 = null; | 95 | violationWarningInformation1 = null; |
| 90 | - }else if(violationType.equals("闯禁行驶")||violationType.equals("失信车辆作业")){//这两种类型根据公司累加 | 96 | + }else if(violationTypeCode.equals("44030033")||violationTypeCode.equals("44030034")){//这两种类型根据公司累加 |
| 91 | company1 = redisCache.getCacheObject("companyList"); | 97 | company1 = redisCache.getCacheObject("companyList"); |
| 92 | basevehicleInfo = RemoteServerUtils.getBasevehicleInfo(jsonObject.getString("vehicleId"),trashConfig.getToken()); | 98 | basevehicleInfo = RemoteServerUtils.getBasevehicleInfo(jsonObject.getString("vehicleId"),trashConfig.getToken()); |
| 93 | if(company1==null){ | 99 | if(company1==null){ |
| @@ -103,6 +109,7 @@ public class Consumer { | @@ -103,6 +109,7 @@ public class Consumer { | ||
| 103 | String project = jsonObject.getString("siteName"); | 109 | String project = jsonObject.getString("siteName"); |
| 104 | violationWarningInformation1 = SpringUtils.getBean(ViolationWarningInformationMapper.class).selectViolationWarningInformation(null,project, violationType, nowDate, tomorrowDate); | 110 | violationWarningInformation1 = SpringUtils.getBean(ViolationWarningInformationMapper.class).selectViolationWarningInformation(null,project, violationType, nowDate, tomorrowDate); |
| 105 | } | 111 | } |
| 112 | + | ||
| 106 | //判断该类型,该工地,该时间段是否已经存在报警信息,如果存在则不再新增,如果不存在则新增 | 113 | //判断该类型,该工地,该时间段是否已经存在报警信息,如果存在则不再新增,如果不存在则新增 |
| 107 | if (violationWarningInformation1 == null) { | 114 | if (violationWarningInformation1 == null) { |
| 108 | ViolationWarningInformation violationWarningInformation = new ViolationWarningInformation(); | 115 | ViolationWarningInformation violationWarningInformation = new ViolationWarningInformation(); |
| @@ -115,7 +122,7 @@ public class Consumer { | @@ -115,7 +122,7 @@ public class Consumer { | ||
| 115 | //所属区域 | 122 | //所属区域 |
| 116 | violationWarningInformation.setOwningRegion(jsonObject.getString("areaName")); | 123 | violationWarningInformation.setOwningRegion(jsonObject.getString("areaName")); |
| 117 | //案卷编码 | 124 | //案卷编码 |
| 118 | - String number = DateFormatUtils.format(new Date(), "yyyyMMddHHmmssSSS"); | 125 | + String number = DateFormatUtils.format(alarmTime, "yyyyMMddHHmmssSSS"); |
| 119 | violationWarningInformation.setNumber(number.substring(2)); | 126 | violationWarningInformation.setNumber(number.substring(2)); |
| 120 | //公司名称 | 127 | //公司名称 |
| 121 | violationWarningInformation.setCompanyName(jsonObject.getString("enterpriseName")); | 128 | violationWarningInformation.setCompanyName(jsonObject.getString("enterpriseName")); |
| @@ -129,46 +136,47 @@ public class Consumer { | @@ -129,46 +136,47 @@ public class Consumer { | ||
| 129 | 136 | ||
| 130 | violationWarningInformation.setSendObject("区管理部门(治)"); | 137 | violationWarningInformation.setSendObject("区管理部门(治)"); |
| 131 | String describe = ""; | 138 | String describe = ""; |
| 132 | - switch (violationWarningInformation.getViolationType()) { | ||
| 133 | - case "工地预警-未报开工作业": | ||
| 134 | - case "工地预警-未按时间作业": | ||
| 135 | - case "工地预警-三无车辆进入工地": | ||
| 136 | - case "工地预警-视频设备离线超时报警": | ||
| 137 | - case "离线运输报警(工)": | ||
| 138 | - case "未激活车辆作业": | ||
| 139 | - case "未核准作业车辆作业": | 139 | + //根据不同违规类型,走不同流程 |
| 140 | + switch (violationTypeCode) { | ||
| 141 | + case "44030020": | ||
| 142 | + case "44030023": | ||
| 143 | + case "44030022": | ||
| 144 | + case "44030021": | ||
| 145 | + case "44030028": | ||
| 146 | + case "44030030": | ||
| 147 | + case "44030031": | ||
| 140 | violationWarningInformation.setViolationObjectType("0"); | 148 | violationWarningInformation.setViolationObjectType("0"); |
| 141 | violationWarningInformation.setSendObject("区管理部门(治)"); | 149 | violationWarningInformation.setSendObject("区管理部门(治)"); |
| 142 | violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | 150 | violationWarningInformation.setProjectName(jsonObject.getString("siteName")); |
| 143 | - describe = DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " " | 151 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " |
| 144 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | 152 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + |
| 145 | jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | 153 | jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); |
| 146 | break; | 154 | break; |
| 147 | - case "消纳场预警-未到指定的消纳场作业": | ||
| 148 | - case "消纳场预警-三无车辆进入消纳场": | ||
| 149 | - case "消纳场预警-未报开工作业": | ||
| 150 | - case "离线运输报警(消)": | ||
| 151 | - case "消纳场预警-视频设备离线超时报警": | 155 | + case "44030027": |
| 156 | + case "44030026": | ||
| 157 | + case "44030024": | ||
| 158 | + case "44030029": | ||
| 159 | + case "44030025": | ||
| 152 | violationWarningInformation.setViolationObjectType("1"); | 160 | violationWarningInformation.setViolationObjectType("1"); |
| 153 | violationWarningInformation.setSendObject("区管理部门(消)"); | 161 | violationWarningInformation.setSendObject("区管理部门(消)"); |
| 154 | violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | 162 | violationWarningInformation.setProjectName(jsonObject.getString("siteName")); |
| 155 | - describe = DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " " | 163 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " |
| 156 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | 164 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + |
| 157 | jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | 165 | jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); |
| 158 | break; | 166 | break; |
| 159 | - case "未按线路行驶": | 167 | + case "44030032": |
| 160 | violationWarningInformation.setViolationObjectType("0"); | 168 | violationWarningInformation.setViolationObjectType("0"); |
| 161 | violationWarningInformation.setViolationGrade("重点类"); | 169 | violationWarningInformation.setViolationGrade("重点类"); |
| 162 | violationWarningInformation.setSendObject("区管理部门(治)"); | 170 | violationWarningInformation.setSendObject("区管理部门(治)"); |
| 163 | - describe = DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " " | 171 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " |
| 164 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | 172 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + |
| 165 | jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | 173 | jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); |
| 166 | break; | 174 | break; |
| 167 | - case "闯禁行驶": | ||
| 168 | - case "失信车辆作业": | 175 | + case "44030033": |
| 176 | + case "44030034": | ||
| 169 | violationWarningInformation.setViolationObjectType("2"); | 177 | violationWarningInformation.setViolationObjectType("2"); |
| 170 | violationWarningInformation.setSendObject("运输企业"); | 178 | violationWarningInformation.setSendObject("运输企业"); |
| 171 | - describe = DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " " | 179 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " |
| 172 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "出现" + violationWarningInformation.getViolationType(); | 180 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "出现" + violationWarningInformation.getViolationType(); |
| 173 | //设置公司简称 | 181 | //设置公司简称 |
| 174 | for(Object o:company1){ | 182 | for(Object o:company1){ |
| @@ -181,18 +189,18 @@ public class Consumer { | @@ -181,18 +189,18 @@ public class Consumer { | ||
| 181 | } | 189 | } |
| 182 | 190 | ||
| 183 | 191 | ||
| 184 | - | 192 | + violationWarningInformation.setCreateTime(alarmTime); |
| 185 | violationWarningInformation.setDescribe(describe); | 193 | violationWarningInformation.setDescribe(describe); |
| 186 | // 业务逻辑 | 194 | // 业务逻辑 |
| 187 | violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | 195 | violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); |
| 188 | 196 | ||
| 189 | } else { | 197 | } else { |
| 190 | String describe = ""; | 198 | String describe = ""; |
| 191 | - if(violationType.equals("闯禁行驶")||violationType.equals("失信车辆作业")){ | ||
| 192 | - describe = violationWarningInformation1.getDescribe() + ";\n" + DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " " | 199 | + if(violationTypeCode.equals("44030033")||violationTypeCode.equals("44030034")){ |
| 200 | + describe = violationWarningInformation1.getDescribe() + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | ||
| 193 | + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "出现" + jsonObject.getString("alarmName"); | 201 | + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "出现" + jsonObject.getString("alarmName"); |
| 194 | }else{ | 202 | }else{ |
| 195 | - describe = violationWarningInformation1.getDescribe() + ";\n" + DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " " | 203 | + describe = violationWarningInformation1.getDescribe() + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " |
| 196 | + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "在" + | 204 | + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "在" + |
| 197 | jsonObject.get("siteName") + "出现" + jsonObject.getString("alarmName"); | 205 | jsonObject.get("siteName") + "出现" + jsonObject.getString("alarmName"); |
| 198 | } | 206 | } |
trash-workFlow/src/main/java/com/trash/casefile/service/impl/ViolationWarningInformationServiceImpl.java
| @@ -90,6 +90,9 @@ public class ViolationWarningInformationServiceImpl implements IViolationWarning | @@ -90,6 +90,9 @@ public class ViolationWarningInformationServiceImpl implements IViolationWarning | ||
| 90 | @Override | 90 | @Override |
| 91 | @Transactional | 91 | @Transactional |
| 92 | public int insertViolationWarningInformation(MultipartFile[] files,ViolationWarningInformation violationWarningInformation) throws IOException { | 92 | public int insertViolationWarningInformation(MultipartFile[] files,ViolationWarningInformation violationWarningInformation) throws IOException { |
| 93 | + if(violationWarningInformation.getCreateTime()==null){ | ||
| 94 | + violationWarningInformation.setCreateTime(DateUtils.getNowDate()); | ||
| 95 | + } | ||
| 93 | if(StringUtils.isEmpty(violationWarningInformation.getCreateBy())){ | 96 | if(StringUtils.isEmpty(violationWarningInformation.getCreateBy())){ |
| 94 | violationWarningInformation.setCreateBy(SecurityUtils.getUsername()); | 97 | violationWarningInformation.setCreateBy(SecurityUtils.getUsername()); |
| 95 | } | 98 | } |
| @@ -103,8 +106,6 @@ public class ViolationWarningInformationServiceImpl implements IViolationWarning | @@ -103,8 +106,6 @@ public class ViolationWarningInformationServiceImpl implements IViolationWarning | ||
| 103 | } | 106 | } |
| 104 | } | 107 | } |
| 105 | } | 108 | } |
| 106 | - | ||
| 107 | - violationWarningInformation.setCreateTime(DateUtils.getNowDate()); | ||
| 108 | violationWarningInformation.setStatus(0); | 109 | violationWarningInformation.setStatus(0); |
| 109 | log.info("违规预警信息新增"); | 110 | log.info("违规预警信息新增"); |
| 110 | Integer result = violationWarningInformationMapper.insertViolationWarningInformation(violationWarningInformation); | 111 | Integer result = violationWarningInformationMapper.insertViolationWarningInformation(violationWarningInformation); |
trash-workFlow/src/main/resources/mapper/casefile/ViolationWarningInformationMapper.xml
| @@ -85,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -85,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 85 | <if test="abbreviation!=null">abbreviation,</if> | 85 | <if test="abbreviation!=null">abbreviation,</if> |
| 86 | </trim> | 86 | </trim> |
| 87 | <trim prefix="values (" suffix=")" suffixOverrides=","> | 87 | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| 88 | - now(), | 88 | + <if test="createTime != null">#{createTime},</if> |
| 89 | <if test="number != null">#{number},</if> | 89 | <if test="number != null">#{number},</if> |
| 90 | <if test="violationObjectType != null">#{violationObjectType},</if> | 90 | <if test="violationObjectType != null">#{violationObjectType},</if> |
| 91 | <if test="owningRegion != null">#{owningRegion},</if> | 91 | <if test="owningRegion != null">#{owningRegion},</if> |