Commit 019be050657833c05d7befafd3c1a8d9d1dff47b
1 parent
a6f8ec99
修复bug
Showing
2 changed files
with
236 additions
and
25 deletions
trash-common/src/main/java/com/trash/common/utils/RemoteServerUtils.java
| @@ -277,6 +277,18 @@ public class RemoteServerUtils { | @@ -277,6 +277,18 @@ public class RemoteServerUtils { | ||
| 277 | return turckList; | 277 | return turckList; |
| 278 | 278 | ||
| 279 | } | 279 | } |
| 280 | + public static JSONObject getConstructionLicenseById(String id,String token) { | ||
| 281 | + JSONObject turckList=null; | ||
| 282 | + Object object = get(constructionLicenseById + id,null,token); | ||
| 283 | + | ||
| 284 | + if(object != null){ | ||
| 285 | + turckList = JSON.parseObject(object.toString()); | ||
| 286 | + return turckList; | ||
| 287 | + } | ||
| 288 | + | ||
| 289 | + return turckList; | ||
| 290 | + | ||
| 291 | + } | ||
| 280 | 292 | ||
| 281 | 293 | ||
| 282 | public static JSONObject getConstructionInfo(String id) { | 294 | public static JSONObject getConstructionInfo(String id) { |
trash-workFlow/src/main/java/com/trash/casefile/kafka/Consumer.java
| @@ -28,6 +28,8 @@ import org.springframework.stereotype.Component; | @@ -28,6 +28,8 @@ import org.springframework.stereotype.Component; | ||
| 28 | import org.springframework.transaction.annotation.Transactional; | 28 | import org.springframework.transaction.annotation.Transactional; |
| 29 | 29 | ||
| 30 | import java.io.IOException; | 30 | import java.io.IOException; |
| 31 | +import java.time.LocalTime; | ||
| 32 | +import java.time.format.DateTimeFormatter; | ||
| 31 | import java.util.*; | 33 | import java.util.*; |
| 32 | import java.util.concurrent.TimeUnit; | 34 | import java.util.concurrent.TimeUnit; |
| 33 | 35 | ||
| @@ -63,8 +65,7 @@ public class Consumer { | @@ -63,8 +65,7 @@ public class Consumer { | ||
| 63 | "44030028=离线运输报警(工)", "44030029=离线运输报警(消)", "44030030=未激活车辆作业", "44030031=未核准作业车辆作业", "44030032=未按线路行驶", | 65 | "44030028=离线运输报警(工)", "44030029=离线运输报警(消)", "44030030=未激活车辆作业", "44030031=未核准作业车辆作业", "44030032=未按线路行驶", |
| 64 | "44030033=闯禁行驶", "44030034=失信车辆作业", "44030035=卫星定位异常"}; | 66 | "44030033=闯禁行驶", "44030034=失信车辆作业", "44030035=卫星定位异常"}; |
| 65 | 67 | ||
| 66 | - //卫星定位异常 | ||
| 67 | - | 68 | + |
| 68 | JSONObject jsonObject = JSONObject.parseObject(data); | 69 | JSONObject jsonObject = JSONObject.parseObject(data); |
| 69 | //报警时间 | 70 | //报警时间 |
| 70 | Date alarmTime = new Date(jsonObject.getLong("alarmTime")*1000L); | 71 | Date alarmTime = new Date(jsonObject.getLong("alarmTime")*1000L); |
| @@ -81,6 +82,9 @@ public class Consumer { | @@ -81,6 +82,9 @@ public class Consumer { | ||
| 81 | tomorrowDate = DateFormatUtils.format(DateUtils.addDays(alarmTime, 1), "yyyy-MM-dd"); | 82 | tomorrowDate = DateFormatUtils.format(DateUtils.addDays(alarmTime, 1), "yyyy-MM-dd"); |
| 82 | } | 83 | } |
| 83 | 84 | ||
| 85 | + | ||
| 86 | + | ||
| 87 | + | ||
| 84 | //违规类型code | 88 | //违规类型code |
| 85 | String violationTypeCode = jsonObject.getString("alarmType"); | 89 | String violationTypeCode = jsonObject.getString("alarmType"); |
| 86 | //违规类型 | 90 | //违规类型 |
| @@ -94,7 +98,7 @@ public class Consumer { | @@ -94,7 +98,7 @@ public class Consumer { | ||
| 94 | JSONArray company1 = null; | 98 | JSONArray company1 = null; |
| 95 | JSONObject basevehicleInfo = null; | 99 | JSONObject basevehicleInfo = null; |
| 96 | //这两种类型无需累加 | 100 | //这两种类型无需累加 |
| 97 | - if(violationTypeCode.equals("44030021") || violationTypeCode.equals("44030025")){ | 101 | + if(violationTypeCode.equals("44030021") || violationTypeCode.equals("44030025")||violationTypeCode.equals("44030027")||violationTypeCode.equals("44030030")||violationTypeCode.equals("44030032")||violationTypeCode.equals("44030023")){ |
| 98 | violationWarningInformation1 = null; | 102 | violationWarningInformation1 = null; |
| 99 | }else if(violationTypeCode.equals("44030033")||violationTypeCode.equals("44030034")){//这两种类型根据公司累加 | 103 | }else if(violationTypeCode.equals("44030033")||violationTypeCode.equals("44030034")){//这两种类型根据公司累加 |
| 100 | company1 = redisCache.getCacheObject("companyList"); | 104 | company1 = redisCache.getCacheObject("companyList"); |
| @@ -106,13 +110,11 @@ public class Consumer { | @@ -106,13 +110,11 @@ public class Consumer { | ||
| 106 | if(basevehicleInfo==null){ | 110 | if(basevehicleInfo==null){ |
| 107 | throw new RuntimeException("获取公司详情失败!vehicleId:"+jsonObject.getString("vehicleId")); | 111 | throw new RuntimeException("获取公司详情失败!vehicleId:"+jsonObject.getString("vehicleId")); |
| 108 | } | 112 | } |
| 109 | - String company = jsonObject.getString("enterpriseName"); | ||
| 110 | - violationWarningInformation1 = SpringUtils.getBean(ViolationWarningInformationMapper.class).selectViolationWarningInformation(company,null, violationType, nowDate, tomorrowDate); | ||
| 111 | }else{//其他都是根据工地/消纳站累加 | 113 | }else{//其他都是根据工地/消纳站累加 |
| 112 | String project = jsonObject.getString("siteName"); | 114 | String project = jsonObject.getString("siteName"); |
| 113 | violationWarningInformation1 = SpringUtils.getBean(ViolationWarningInformationMapper.class).selectViolationWarningInformation(null,project, violationType, nowDate, tomorrowDate); | 115 | violationWarningInformation1 = SpringUtils.getBean(ViolationWarningInformationMapper.class).selectViolationWarningInformation(null,project, violationType, nowDate, tomorrowDate); |
| 114 | } | 116 | } |
| 115 | - | 117 | + String siteName = jsonObject.getString("siteName"); |
| 116 | //判断该类型,该工地,该时间段是否已经存在报警信息,如果存在则不再新增,如果不存在则新增 | 118 | //判断该类型,该工地,该时间段是否已经存在报警信息,如果存在则不再新增,如果不存在则新增 |
| 117 | if (violationWarningInformation1 == null) { | 119 | if (violationWarningInformation1 == null) { |
| 118 | ViolationWarningInformation violationWarningInformation = new ViolationWarningInformation(); | 120 | ViolationWarningInformation violationWarningInformation = new ViolationWarningInformation(); |
| @@ -139,44 +141,201 @@ public class Consumer { | @@ -139,44 +141,201 @@ public class Consumer { | ||
| 139 | 141 | ||
| 140 | violationWarningInformation.setSendObject("区管理部门"); | 142 | violationWarningInformation.setSendObject("区管理部门"); |
| 141 | String describe = ""; | 143 | String describe = ""; |
| 144 | + String alarmTimeString = DateFormatUtils.format(alarmTime,"HH:mm"); | ||
| 142 | //根据不同违规类型,走不同流程 | 145 | //根据不同违规类型,走不同流程 |
| 146 | + int count = 0; | ||
| 143 | switch (violationTypeCode) { | 147 | switch (violationTypeCode) { |
| 144 | - case "44030020": | ||
| 145 | - case "44030023": | ||
| 146 | - case "44030022": | ||
| 147 | - case "44030021": | ||
| 148 | - case "44030028": | ||
| 149 | - case "44030030": | ||
| 150 | - case "44030031": | 148 | + case "44030020"://工地预警-未报开工作业 |
| 149 | + //获取报警次数 | ||
| 150 | + count = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020")==null?1:Integer.parseInt(redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020").toString())+1; | ||
| 151 | + //获取累计报警描述 | ||
| 152 | + describe = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020describe")==null?"":redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030020describe").toString(); | ||
| 153 | + | ||
| 154 | + //报警次数等于5推送案卷 | ||
| 155 | + if(count==5){ | ||
| 156 | + violationWarningInformation.setViolationObjectType("0"); | ||
| 157 | + violationWarningInformation.setSendObject("区管理部门"); | ||
| 158 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | ||
| 159 | + if(!StringUtils.isEmpty(describe)){ | ||
| 160 | + describe = describe + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | ||
| 161 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | ||
| 162 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | ||
| 163 | + }else{ | ||
| 164 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | ||
| 165 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | ||
| 166 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + violationWarningInformation.setCreateTime(alarmTime); | ||
| 170 | + violationWarningInformation.setDescribe(describe); | ||
| 171 | + // 业务逻辑 | ||
| 172 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | ||
| 173 | + } | ||
| 174 | + //次数+1 | ||
| 175 | + redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030020",count,1, TimeUnit.DAYS); | ||
| 176 | + //累计描述 | ||
| 177 | + redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030020describe",describe,1, TimeUnit.DAYS); | ||
| 178 | + break; | ||
| 179 | + case "44030023"://工地预警-未按时间作业 | ||
| 180 | + try{ | ||
| 181 | + //获取工地信息 | ||
| 182 | + JSONObject object = RemoteServerUtils.getConstructionLicenseById(jsonObject.getString("siteId"), trashConfig.getToken()); | ||
| 183 | + String transportEndTime = object.getString("transportEndTime"); | ||
| 184 | + String transportStartTime = object.getString("transportStartTime"); | ||
| 185 | + String endTime = manipulateTime(transportEndTime,30); | ||
| 186 | + String startTime = manipulateTime(transportStartTime,-30); | ||
| 187 | + //获取结束运输报警次数 | ||
| 188 | + String countKey = nowDate+jsonObject.getString("siteId")+"44030023"+transportEndTime; | ||
| 189 | + count = redisCache.getCacheObject(countKey)==null?1:Integer.parseInt(redisCache.getCacheObject(countKey).toString())+1; | ||
| 190 | + //获取结束运输累计报警描述 | ||
| 191 | + String describeKey = nowDate+jsonObject.getString("siteId")+"44030023describe"+transportEndTime; | ||
| 192 | + describe = redisCache.getCacheObject(describeKey)==null?"":redisCache.getCacheObject(describeKey).toString(); | ||
| 193 | + //获取结束运输报警次数 | ||
| 194 | + String countEKey = nowDate+jsonObject.getString("siteId")+"44030023"+transportStartTime; | ||
| 195 | + int countE = redisCache.getCacheObject(countEKey)==null?1:Integer.parseInt(redisCache.getCacheObject(countEKey).toString())+1; | ||
| 196 | + //获取结束运输累计报警描述 | ||
| 197 | + String describeEKey = nowDate+jsonObject.getString("siteId")+"44030023describe"+transportStartTime; | ||
| 198 | + String describeE = redisCache.getCacheObject(describeEKey)==null?"":redisCache.getCacheObject(describeEKey).toString(); | ||
| 199 | + | ||
| 200 | + if(!StringUtils.isEmpty(describe)){ | ||
| 201 | + describe = describe + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | ||
| 202 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | ||
| 203 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | ||
| 204 | + }else{ | ||
| 205 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | ||
| 206 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | ||
| 207 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | ||
| 208 | + } | ||
| 209 | + //报警次数等于5推送案卷 | ||
| 210 | + if(count==5){ | ||
| 211 | + violationWarningInformation.setViolationObjectType("0"); | ||
| 212 | + violationWarningInformation.setSendObject("区管理部门"); | ||
| 213 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | ||
| 214 | + | ||
| 215 | + violationWarningInformation.setCreateTime(alarmTime); | ||
| 216 | + violationWarningInformation.setDescribe(describe); | ||
| 217 | + // 业务逻辑 | ||
| 218 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + if(!StringUtils.isEmpty(describeE)){ | ||
| 222 | + describeE = describeE + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | ||
| 223 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | ||
| 224 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | ||
| 225 | + }else{ | ||
| 226 | + describeE = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | ||
| 227 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | ||
| 228 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | ||
| 229 | + } | ||
| 230 | + //报警次数等于5推送案卷 | ||
| 231 | + if(countE==5){ | ||
| 232 | + violationWarningInformation.setViolationObjectType("0"); | ||
| 233 | + violationWarningInformation.setSendObject("区管理部门"); | ||
| 234 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | ||
| 235 | + | ||
| 236 | + violationWarningInformation.setCreateTime(alarmTime); | ||
| 237 | + violationWarningInformation.setDescribe(describeE); | ||
| 238 | + // 业务逻辑 | ||
| 239 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + | ||
| 243 | + //判断结束运输 | ||
| 244 | + if(isTimeWithinRange(alarmTimeString,transportEndTime,endTime)){ | ||
| 245 | + //次数+1 | ||
| 246 | + redisCache.setCacheObject(countKey,count,12, TimeUnit.HOURS); | ||
| 247 | + //累计描述 | ||
| 248 | + redisCache.setCacheObject(describeKey,describe,12, TimeUnit.HOURS); | ||
| 249 | + }else if(isTimeWithinRange(alarmTimeString,startTime,transportStartTime)){ | ||
| 250 | + //次数+1 | ||
| 251 | + redisCache.setCacheObject(countEKey,countE,12, TimeUnit.HOURS); | ||
| 252 | + //累计描述 | ||
| 253 | + redisCache.setCacheObject(describeEKey,describeE,12, TimeUnit.HOURS); | ||
| 254 | + } | ||
| 255 | + }catch (NullPointerException e){ | ||
| 256 | + throw e; | ||
| 257 | + } | ||
| 258 | + break; | ||
| 259 | + | ||
| 260 | + case "44030030"://未激活车辆作业 | ||
| 261 | + case "44030031"://未核准作业车辆作业 | ||
| 262 | + case "44030022"://工地预警-三无车辆进入工地 | ||
| 263 | + case "44030021"://工地预警-视频设备离线超时报警 | ||
| 264 | + case "44030028"://离线运输报警(工) | ||
| 265 | + | ||
| 151 | violationWarningInformation.setViolationObjectType("0"); | 266 | violationWarningInformation.setViolationObjectType("0"); |
| 152 | violationWarningInformation.setSendObject("区管理部门"); | 267 | violationWarningInformation.setSendObject("区管理部门"); |
| 153 | violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | 268 | violationWarningInformation.setProjectName(jsonObject.getString("siteName")); |
| 154 | describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | 269 | describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " |
| 155 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | 270 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + |
| 156 | jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | 271 | jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); |
| 272 | + violationWarningInformation.setCreateTime(alarmTime); | ||
| 273 | + violationWarningInformation.setDescribe(describe); | ||
| 274 | + // 业务逻辑 | ||
| 275 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | ||
| 276 | + break; | ||
| 277 | + | ||
| 278 | + case "44030024"://消纳场预警-未报开工作业 | ||
| 279 | + //获取报警次数 | ||
| 280 | + count = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024")==null?1:Integer.parseInt(redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024").toString())+1; | ||
| 281 | + //获取累计报警描述 | ||
| 282 | + describe = redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024describe")==null?"":redisCache.getCacheObject(nowDate+jsonObject.getString("siteId")+"44030024describe").toString(); | ||
| 283 | + | ||
| 284 | + //报警次数等于5推送案卷 | ||
| 285 | + if(count==5){ | ||
| 286 | + violationWarningInformation.setViolationObjectType("1"); | ||
| 287 | + violationWarningInformation.setSendObject("区管理部门"); | ||
| 288 | + violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | ||
| 289 | + if(!StringUtils.isEmpty(describe)){ | ||
| 290 | + describe = describe + ";\n" + DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | ||
| 291 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | ||
| 292 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | ||
| 293 | + }else{ | ||
| 294 | + describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | ||
| 295 | + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | ||
| 296 | + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | ||
| 297 | + } | ||
| 298 | + violationWarningInformation.setCreateTime(alarmTime); | ||
| 299 | + violationWarningInformation.setDescribe(describe); | ||
| 300 | + // 业务逻辑 | ||
| 301 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + | ||
| 305 | + //次数+1 | ||
| 306 | + redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030024",count,1, TimeUnit.DAYS); | ||
| 307 | + //累计描述 | ||
| 308 | + redisCache.setCacheObject(nowDate+jsonObject.getString("siteId")+"44030024describe",describe,1, TimeUnit.DAYS); | ||
| 157 | break; | 309 | break; |
| 158 | - case "44030027": | ||
| 159 | - case "44030026": | ||
| 160 | - case "44030024": | ||
| 161 | - case "44030029": | ||
| 162 | - case "44030025": | 310 | + case "44030027"://消纳场预警-未到指定的消纳场作业 |
| 311 | + case "44030026"://消纳场预警-三无车辆进入消纳场 | ||
| 312 | + case "44030029"://离线运输报警(消) | ||
| 313 | + case "44030025"://消纳场预警-视频设备离线超时报警 | ||
| 163 | violationWarningInformation.setViolationObjectType("1"); | 314 | violationWarningInformation.setViolationObjectType("1"); |
| 164 | violationWarningInformation.setSendObject("区管理部门"); | 315 | violationWarningInformation.setSendObject("区管理部门"); |
| 165 | violationWarningInformation.setProjectName(jsonObject.getString("siteName")); | 316 | violationWarningInformation.setProjectName(jsonObject.getString("siteName")); |
| 166 | describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | 317 | describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " |
| 167 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | 318 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + |
| 168 | jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | 319 | jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); |
| 320 | + violationWarningInformation.setCreateTime(alarmTime); | ||
| 321 | + violationWarningInformation.setDescribe(describe); | ||
| 322 | + // 业务逻辑 | ||
| 323 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | ||
| 169 | break; | 324 | break; |
| 170 | - case "44030032": | 325 | + case "44030032"://未按线路行驶 |
| 171 | violationWarningInformation.setViolationObjectType("0"); | 326 | violationWarningInformation.setViolationObjectType("0"); |
| 172 | violationWarningInformation.setViolationGrade("重点类"); | 327 | violationWarningInformation.setViolationGrade("重点类"); |
| 173 | violationWarningInformation.setSendObject("区管理部门"); | 328 | violationWarningInformation.setSendObject("区管理部门"); |
| 174 | describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | 329 | describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " |
| 175 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + | 330 | + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" + |
| 176 | jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); | 331 | jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType(); |
| 332 | + violationWarningInformation.setCreateTime(alarmTime); | ||
| 333 | + violationWarningInformation.setDescribe(describe); | ||
| 334 | + // 业务逻辑 | ||
| 335 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | ||
| 177 | break; | 336 | break; |
| 178 | - case "44030033": | ||
| 179 | - case "44030034": | 337 | + case "44030033"://闯禁行驶 |
| 338 | + case "44030034"://失信车辆作业 | ||
| 180 | violationWarningInformation.setViolationObjectType("2"); | 339 | violationWarningInformation.setViolationObjectType("2"); |
| 181 | violationWarningInformation.setSendObject("运输企业"); | 340 | violationWarningInformation.setSendObject("运输企业"); |
| 182 | describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " | 341 | describe = DateFormatUtils.format(alarmTime, "yyyy/MM/dd HH:mm:ss") + " " |
| @@ -188,14 +347,15 @@ public class Consumer { | @@ -188,14 +347,15 @@ public class Consumer { | ||
| 188 | violationWarningInformation.setAbbreviation(jo.getString("abbreviation")); | 347 | violationWarningInformation.setAbbreviation(jo.getString("abbreviation")); |
| 189 | } | 348 | } |
| 190 | } | 349 | } |
| 350 | + violationWarningInformation.setCreateTime(alarmTime); | ||
| 351 | + violationWarningInformation.setDescribe(describe); | ||
| 352 | + // 业务逻辑 | ||
| 353 | + violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | ||
| 191 | break; | 354 | break; |
| 192 | } | 355 | } |
| 193 | 356 | ||
| 194 | 357 | ||
| 195 | - violationWarningInformation.setCreateTime(alarmTime); | ||
| 196 | - violationWarningInformation.setDescribe(describe); | ||
| 197 | - // 业务逻辑 | ||
| 198 | - violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation); | 358 | + |
| 199 | 359 | ||
| 200 | } else { | 360 | } else { |
| 201 | String describe = ""; | 361 | String describe = ""; |
| @@ -226,4 +386,43 @@ public class Consumer { | @@ -226,4 +386,43 @@ public class Consumer { | ||
| 226 | SpringUtils.getBean(KafkaCompensationMapper.class).insertKafkaCompensation(kafkaCompensation); | 386 | SpringUtils.getBean(KafkaCompensationMapper.class).insertKafkaCompensation(kafkaCompensation); |
| 227 | return kafkaCompensation.getId().toString(); | 387 | return kafkaCompensation.getId().toString(); |
| 228 | } | 388 | } |
| 389 | + | ||
| 390 | + /** | ||
| 391 | + * 对HH:mm格式时间进行分钟的加减 | ||
| 392 | + * @param timeStr | ||
| 393 | + * @param minutesToAddOrSubtract | ||
| 394 | + * @return | ||
| 395 | + */ | ||
| 396 | + public String manipulateTime(String timeStr, int minutesToAddOrSubtract) { | ||
| 397 | + // 定义输入时间格式的日期时间格式器 | ||
| 398 | + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); | ||
| 399 | + | ||
| 400 | + // 解析输入的时间字符串为 LocalTime 对象 | ||
| 401 | + LocalTime time = LocalTime.parse(timeStr, formatter); | ||
| 402 | + | ||
| 403 | + // 执行加减分钟的操作 | ||
| 404 | + LocalTime modifiedTime = time.plusMinutes(minutesToAddOrSubtract); | ||
| 405 | + | ||
| 406 | + // 将修改后的时间格式化为 HH:mm 格式 | ||
| 407 | + String formattedModifiedTime = modifiedTime.format(formatter); | ||
| 408 | + | ||
| 409 | + return formattedModifiedTime; | ||
| 410 | + } | ||
| 411 | + | ||
| 412 | + /** | ||
| 413 | + * 判断timeStr是否在startTimeStr-endTimeStr区间 | ||
| 414 | + * @param timeStr | ||
| 415 | + * @param startTimeStr | ||
| 416 | + * @param endTimeStr | ||
| 417 | + * @return | ||
| 418 | + */ | ||
| 419 | + public boolean isTimeWithinRange(String timeStr, String startTimeStr, String endTimeStr) { | ||
| 420 | + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); | ||
| 421 | + LocalTime time = LocalTime.parse(timeStr, formatter); | ||
| 422 | + LocalTime startTime = LocalTime.parse(startTimeStr, formatter); | ||
| 423 | + LocalTime endTime = LocalTime.parse(endTimeStr, formatter); | ||
| 424 | + | ||
| 425 | + return !time.isBefore(startTime) && !time.isAfter(endTime); | ||
| 426 | + | ||
| 427 | + } | ||
| 229 | } | 428 | } |