Commit 48597b26a6cb1ef946ec5c2cbc979dfda8cc88d6

Authored by 273548560@qq.com
1 parent 04f65edd

修复bug

trash-workFlow/src/main/java/com/trash/casefile/kafka/Consumer.java
... ... @@ -58,23 +58,29 @@ public class Consumer {
58 58  
59 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 62 "44030024=消纳场预警-未报开工作业", "44030025=消纳场预警-视频设备离线超时报警", "44030026=消纳场预警-三无车辆进入消纳场", "44030027=消纳场预警-未到指定的消纳场作业",
63 63 "44030028=离线运输报警(工)", "44030029=离线运输报警(消)", "44030030=未激活车辆作业", "44030031=未核准作业车辆作业", "44030032=未按线路行驶",
64 64 "44030033=闯禁行驶", "44030034=失信车辆作业"};
65 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 71 String nowDate = null;
69 72 String tomorrowDate = null;
70 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 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 84 String violationType = jsonObject.getString("alarmName");
79 85 if(RemoteServerUtils.remote==null){
80 86 //登录
... ... @@ -85,9 +91,9 @@ public class Consumer {
85 91 JSONArray company1 = null;
86 92 JSONObject basevehicleInfo = null;
87 93 //这两种类型无需累加
88   - if(violationType.equals("工地预警-视频设备离线超时报警") || violationType.equals("消纳场预警-视频设备离线超时报警")){
  94 + if(violationTypeCode.equals("44030021") || violationTypeCode.equals("44030025")){
89 95 violationWarningInformation1 = null;
90   - }else if(violationType.equals("闯禁行驶")||violationType.equals("失信车辆作业")){//这两种类型根据公司累加
  96 + }else if(violationTypeCode.equals("44030033")||violationTypeCode.equals("44030034")){//这两种类型根据公司累加
91 97 company1 = redisCache.getCacheObject("companyList");
92 98 basevehicleInfo = RemoteServerUtils.getBasevehicleInfo(jsonObject.getString("vehicleId"),trashConfig.getToken());
93 99 if(company1==null){
... ... @@ -103,6 +109,7 @@ public class Consumer {
103 109 String project = jsonObject.getString("siteName");
104 110 violationWarningInformation1 = SpringUtils.getBean(ViolationWarningInformationMapper.class).selectViolationWarningInformation(null,project, violationType, nowDate, tomorrowDate);
105 111 }
  112 +
106 113 //判断该类型,该工地,该时间段是否已经存在报警信息,如果存在则不再新增,如果不存在则新增
107 114 if (violationWarningInformation1 == null) {
108 115 ViolationWarningInformation violationWarningInformation = new ViolationWarningInformation();
... ... @@ -115,7 +122,7 @@ public class Consumer {
115 122 //所属区域
116 123 violationWarningInformation.setOwningRegion(jsonObject.getString("areaName"));
117 124 //案卷编码
118   - String number = DateFormatUtils.format(new Date(), "yyyyMMddHHmmssSSS");
  125 + String number = DateFormatUtils.format(alarmTime, "yyyyMMddHHmmssSSS");
119 126 violationWarningInformation.setNumber(number.substring(2));
120 127 //公司名称
121 128 violationWarningInformation.setCompanyName(jsonObject.getString("enterpriseName"));
... ... @@ -129,46 +136,47 @@ public class Consumer {
129 136  
130 137 violationWarningInformation.setSendObject("区管理部门(治)");
131 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 148 violationWarningInformation.setViolationObjectType("0");
141 149 violationWarningInformation.setSendObject("区管理部门(治)");
142 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 152 + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" +
145 153 jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType();
146 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 160 violationWarningInformation.setViolationObjectType("1");
153 161 violationWarningInformation.setSendObject("区管理部门(消)");
154 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 164 + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" +
157 165 jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType();
158 166 break;
159   - case "未按线路行驶":
  167 + case "44030032":
160 168 violationWarningInformation.setViolationObjectType("0");
161 169 violationWarningInformation.setViolationGrade("重点类");
162 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 172 + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" +
165 173 jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType();
166 174 break;
167   - case "闯禁行驶":
168   - case "失信车辆作业":
  175 + case "44030033":
  176 + case "44030034":
169 177 violationWarningInformation.setViolationObjectType("2");
170 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 180 + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "出现" + violationWarningInformation.getViolationType();
173 181 //设置公司简称
174 182 for(Object o:company1){
... ... @@ -181,18 +189,18 @@ public class Consumer {
181 189 }
182 190  
183 191  
184   -
  192 + violationWarningInformation.setCreateTime(alarmTime);
185 193 violationWarningInformation.setDescribe(describe);
186 194 // 业务逻辑
187 195 violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation);
188 196  
189 197 } else {
190 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 201 + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "出现" + jsonObject.getString("alarmName");
194 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 204 + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "在" +
197 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 90 @Override
91 91 @Transactional
92 92 public int insertViolationWarningInformation(MultipartFile[] files,ViolationWarningInformation violationWarningInformation) throws IOException {
  93 + if(violationWarningInformation.getCreateTime()==null){
  94 + violationWarningInformation.setCreateTime(DateUtils.getNowDate());
  95 + }
93 96 if(StringUtils.isEmpty(violationWarningInformation.getCreateBy())){
94 97 violationWarningInformation.setCreateBy(SecurityUtils.getUsername());
95 98 }
... ... @@ -103,8 +106,6 @@ public class ViolationWarningInformationServiceImpl implements IViolationWarning
103 106 }
104 107 }
105 108 }
106   -
107   - violationWarningInformation.setCreateTime(DateUtils.getNowDate());
108 109 violationWarningInformation.setStatus(0);
109 110 log.info("违规预警信息新增");
110 111 Integer result = violationWarningInformationMapper.insertViolationWarningInformation(violationWarningInformation);
... ...
trash-workFlow/src/main/resources/mapper/casefile/ViolationWarningInformationMapper.xml
... ... @@ -85,7 +85,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
85 85 <if test="abbreviation!=null">abbreviation,</if>
86 86 </trim>
87 87 <trim prefix="values (" suffix=")" suffixOverrides=",">
88   - now(),
  88 + <if test="createTime != null">#{createTime},</if>
89 89 <if test="number != null">#{number},</if>
90 90 <if test="violationObjectType != null">#{violationObjectType},</if>
91 91 <if test="owningRegion != null">#{owningRegion},</if>
... ...