Commit 30fb7566aaffb9c0fc01163b47a6d30c8199dbfe

Authored by youxiw2000
2 parents be16adfc 9304d22b

Merge branch 'dev' of http://101.95.0.106:8888/youxiw20000/trash into dev

trash-admin/src/main/resources/application.yml
... ... @@ -9,18 +9,19 @@ spring:
9 9 #kafka配置
10 10 kafka:
11 11 bootstrap-servers: 183.66.242.6:9101
  12 + listener:
  13 + ack-mode: manual_immediate
12 14 producer:
13 15 x-serializer: org.apache.kafka.common.serialization.StringSerializer
14 16 value-serializer: org.apache.kafka.common.serialization.StringSerializer
15 17 buffer-memory: 33554432
16 18 acks: all
17 19 consumer:
18   - enable-auto-commit: true
19   - group-id: trash123
  20 + enable-auto-commit: false
  21 + group-id: trash
20 22 key-serializer: org.apache.kafka.common.serialization.StringSerializer
21 23 value-serializer: org.apache.kafka.common.serialization.StringSerializer
22 24 max-poll-records: 1
23   -
24 25 # 资源信息
25 26 messages:
26 27 # 国际化资源文件路径
... ...
trash-quartz/src/main/java/com/trash/quartz/task/DriverTask.java
... ... @@ -9,11 +9,6 @@ import java.util.HashMap;
9 9 import java.util.List;
10 10 import java.util.Map;
11 11  
12   -import javax.servlet.FilterChain;
13   -import javax.servlet.ServletException;
14   -import javax.servlet.http.HttpServletRequest;
15   -import javax.servlet.http.HttpServletResponse;
16   -
17 12 import com.trash.casefile.domain.KafkaCompensation;
18 13 import com.trash.casefile.kafka.Consumer;
19 14 import com.trash.casefile.mapper.KafkaCompensationMapper;
... ... @@ -35,8 +30,6 @@ import com.trash.business.service.IDriverCreditService;
35 30 import com.trash.business.service.ISupervisionThreestepService;
36 31 import com.trash.business.service.ITruckActivateService;
37 32 import com.trash.business.service.ITruckCreditService;
38   -import com.trash.casefile.domain.ViolationWarningInformation;
39   -import com.trash.common.annotation.Log;
40 33 import com.trash.common.config.trashConfig;
41 34 import com.trash.common.utils.LogUtils;
42 35 import com.trash.common.utils.RemoteServerUtils;
... ...
trash-ui/src/views/activiti/task/index.vue
1 1 <template>
2 2 <div class="app-container">
3   - <el-select v-model="queryParams.dept" filterable reserve-keyword @change="getList">
4   - <el-option v-for="item in depts" :label="item.name"
5   - :value="item.code" :key="item.code">
6   - </el-option>
7   - </el-select>
8   - <el-select v-model="queryParams.role" filterable reserve-keyword @change="getList">
9   - <el-option v-for="item in roles" :label="item.name"
10   - :value="item.code" :key="item.code">
11   - </el-option>
12   - </el-select>
  3 +<!-- <el-select v-model="queryParams.dept" filterable reserve-keyword @change="getList">-->
  4 +<!-- <el-option v-for="item in depts" :label="item.name"-->
  5 +<!-- :value="item.code" :key="item.code">-->
  6 +<!-- </el-option>-->
  7 +<!-- </el-select>-->
  8 +<!-- <el-select v-model="queryParams.role" filterable reserve-keyword @change="getList">-->
  9 +<!-- <el-option v-for="item in roles" :label="item.name"-->
  10 +<!-- :value="item.code" :key="item.code">-->
  11 +<!-- </el-option>-->
  12 +<!-- </el-select>-->
13 13  
14 14  
15 15 <taskCard :task="task" v-for="task in taskList" @sendToParent="showTask"/>
... ...
trash-workFlow/src/main/java/com/trash/casefile/kafka/Consumer.java
... ... @@ -15,10 +15,12 @@ import com.trash.common.utils.StringUtils;
15 15 import com.trash.common.utils.spring.SpringUtils;
16 16 import com.trash.framework.web.service.SysLoginService;
17 17 import org.apache.commons.lang3.time.DateFormatUtils;
  18 +import org.apache.kafka.clients.consumer.ConsumerRecord;
18 19 import org.slf4j.Logger;
19 20 import org.slf4j.LoggerFactory;
20 21 import org.springframework.beans.factory.annotation.Autowired;
21 22 import org.springframework.kafka.annotation.KafkaListener;
  23 +import org.springframework.kafka.support.Acknowledgment;
22 24 import org.springframework.kafka.support.KafkaHeaders;
23 25 import org.springframework.messaging.handler.annotation.Header;
24 26 import org.springframework.messaging.handler.annotation.Payload;
... ... @@ -37,10 +39,12 @@ public class Consumer {
37 39 private IViolationWarningInformationService violationWarningInformationService;
38 40  
39 41 @KafkaListener(topics = "record_process_alarm")
40   - public void consume(@Payload String data) throws InterruptedException, IOException {
41   - log.info("kafka消费数据成功,data:" + data);
42   - String id = insertKafkaCompensation(data);
43   - autoViolationWarning(data,id);
  42 + public void consume(ConsumerRecord<?, ?> record, Acknowledgment ack) throws InterruptedException, IOException {
  43 + log.info("kafka消费数据成功,offset:"+ record.offset() +",data:" + record.value());
  44 + String id = insertKafkaCompensation(record.value().toString());
  45 + autoViolationWarning(record.value().toString(),id);
  46 + //手动提交offset
  47 + ack.acknowledge();
44 48 }
45 49  
46 50 @Autowired
... ... @@ -52,7 +56,6 @@ public class Consumer {
52 56 @Autowired
53 57 RedisCache redisCache;
54 58  
55   - @Transactional
56 59 public void autoViolationWarning(String data,String id) throws InterruptedException, IOException {
57 60  
58 61 String[] code = {"44030020=工地预警-未报开工作业", "44030021=工地预警-视频设备离线超时报警", "44030022=工地预警-三无车辆进入工地", "44030023=工地预警未按时间作业",
... ... @@ -72,8 +75,6 @@ public class Consumer {
72 75 tomorrowDate = DateFormatUtils.format(DateUtils.addDays(new Date(), 1), "yyyy-MM-dd");
73 76 }
74 77  
75   -
76   -
77 78 String violationType = jsonObject.getString("alarmName");
78 79 if(RemoteServerUtils.remote==null){
79 80 //登录
... ... @@ -81,19 +82,21 @@ public class Consumer {
81 82 loginService.loginByRemote(trashConfig.getToken());
82 83 }
83 84 ViolationWarningInformation violationWarningInformation1 = null;
84   - JSONArray company1 = redisCache.getCacheObject("companyList");
85   - JSONObject basevehicleInfo = RemoteServerUtils.getBasevehicleInfo(jsonObject.getString("vehicleId"),trashConfig.getToken());
86   - if(company1==null){
87   - throw new RuntimeException("获取公司列表失败!!!");
88   - }
89   -
90   - if(basevehicleInfo==null){
91   - throw new RuntimeException("获取公司详情失败!vehicleId:"+jsonObject.getString("vehicleId"));
92   - }
  85 + JSONArray company1 = null;
  86 + JSONObject basevehicleInfo = null;
93 87 //这两种类型无需累加
94 88 if(violationType.equals("工地预警-视频设备离线超时报警") || violationType.equals("消纳场预警-视频设备离线超时报警")){
95 89 violationWarningInformation1 = null;
96 90 }else if(violationType.equals("闯禁行驶")||violationType.equals("失信车辆作业")){//这两种类型根据公司累加
  91 + company1 = redisCache.getCacheObject("companyList");
  92 + basevehicleInfo = RemoteServerUtils.getBasevehicleInfo(jsonObject.getString("vehicleId"),trashConfig.getToken());
  93 + if(company1==null){
  94 + throw new RuntimeException("获取公司列表失败!!!");
  95 + }
  96 +
  97 + if(basevehicleInfo==null){
  98 + throw new RuntimeException("获取公司详情失败!vehicleId:"+jsonObject.getString("vehicleId"));
  99 + }
97 100 String company = jsonObject.getString("enterpriseName");
98 101 violationWarningInformation1 = SpringUtils.getBean(ViolationWarningInformationMapper.class).selectViolationWarningInformation(company,null, violationType, nowDate, tomorrowDate);
99 102 }else{//其他都是根据工地/消纳站累加
... ... @@ -105,7 +108,7 @@ public class Consumer {
105 108 ViolationWarningInformation violationWarningInformation = new ViolationWarningInformation();
106 109 String siteType = jsonObject.getString("siteType");
107 110 if ("1".equals(siteType)) {//工地
108   - violationWarningInformation.setViolationObjectType("0");
  111 +
109 112 } else if ("2".equals(siteType)) {//消纳场
110 113 violationWarningInformation.setViolationObjectType("1");
111 114 }
... ... @@ -123,53 +126,77 @@ public class Consumer {
123 126 //推送对象
124 127 violationWarningInformation.setViolationGrade("一般类");
125 128 //项目名称(工地名称,消纳场名称)
126   - violationWarningInformation.setProjectName(jsonObject.getString("siteName"));
  129 +
127 130 violationWarningInformation.setSendObject("区管理部门(治)");
  131 + String describe = "";
128 132 switch (violationWarningInformation.getViolationType()) {
129 133 case "工地预警-未报开工作业":
130   - case "消纳场预警-未到指定的消纳场作业":
131   - case "消纳场预警-三无车辆进入消纳场":
132   - case "消纳场预警-未报开工作业":
133 134 case "工地预警-未按时间作业":
134 135 case "工地预警-三无车辆进入工地":
135 136 case "工地预警-视频设备离线超时报警":
136   - case "离线运输报警(消)":
137 137 case "离线运输报警(工)":
138 138 case "未激活车辆作业":
139 139 case "未核准作业车辆作业":
  140 + violationWarningInformation.setViolationObjectType("0");
140 141 violationWarningInformation.setSendObject("区管理部门(治)");
  142 + violationWarningInformation.setProjectName(jsonObject.getString("siteName"));
  143 + describe = DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " "
  144 + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" +
  145 + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType();
141 146 break;
  147 + case "消纳场预警-未到指定的消纳场作业":
  148 + case "消纳场预警-三无车辆进入消纳场":
  149 + case "消纳场预警-未报开工作业":
  150 + case "离线运输报警(消)":
142 151 case "消纳场预警-视频设备离线超时报警":
  152 + violationWarningInformation.setViolationObjectType("1");
143 153 violationWarningInformation.setSendObject("区管理部门(消)");
  154 + violationWarningInformation.setProjectName(jsonObject.getString("siteName"));
  155 + describe = DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " "
  156 + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" +
  157 + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType();
144 158 break;
145 159 case "未按线路行驶":
  160 + violationWarningInformation.setViolationObjectType("0");
146 161 violationWarningInformation.setViolationGrade("重点类");
147 162 violationWarningInformation.setSendObject("区管理部门(治)");
  163 + describe = DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " "
  164 + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" +
  165 + jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType();
148 166 break;
149 167 case "闯禁行驶":
150 168 case "失信车辆作业":
  169 + violationWarningInformation.setViolationObjectType("2");
151 170 violationWarningInformation.setSendObject("运输企业");
  171 + describe = DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " "
  172 + + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "出现" + violationWarningInformation.getViolationType();
  173 + //设置公司简称
  174 + for(Object o:company1){
  175 + JSONObject jo = (JSONObject) o;
  176 + if(basevehicleInfo.getString("companyID").equals(jo.getString("id"))){
  177 + violationWarningInformation.setAbbreviation(jo.getString("abbreviation"));
  178 + }
  179 + }
152 180 break;
153 181 }
154 182  
155   - String describe = DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " "
156   - + violationWarningInformation.getCompanyName() + " " + jsonObject.get("licenseplateNo") + "在" +
157   - jsonObject.get("siteName") + "出现" + violationWarningInformation.getViolationType();
158   - //设置公司简称
159   - for(Object o:company1){
160   - JSONObject jo = (JSONObject) o;
161   - if(basevehicleInfo.getString("companyID").equals(jo.getString("id"))){
162   - violationWarningInformation.setAbbreviation(jo.getString("abbreviation"));
163   - }
164   - }
  183 +
  184 +
165 185 violationWarningInformation.setDescribe(describe);
166 186 // 业务逻辑
167 187 violationWarningInformationService.insertViolationWarningInformation(null, violationWarningInformation);
168 188  
169 189 } else {
170   - String describe = violationWarningInformation1.getDescribe() + ";\n" + DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " "
171   - + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "在" +
172   - jsonObject.get("siteName") + "出现" + jsonObject.getString("alarmName");
  190 + String describe = "";
  191 + if(violationType.equals("闯禁行驶")||violationType.equals("失信车辆作业")){
  192 + describe = violationWarningInformation1.getDescribe() + ";\n" + DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " "
  193 + + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "出现" + jsonObject.getString("alarmName");
  194 + }else{
  195 + describe = violationWarningInformation1.getDescribe() + ";\n" + DateFormatUtils.format(new Date(), "yyyy/MM/dd HH:mm:ss") + " "
  196 + + jsonObject.getString("enterpriseName") + " " + jsonObject.get("licenseplateNo") + "在" +
  197 + jsonObject.get("siteName") + "出现" + jsonObject.getString("alarmName");
  198 + }
  199 +
173 200 violationWarningInformation1.setDescribe(describe);
174 201 SpringUtils.getBean(ViolationWarningInformationMapper.class).updateViolationWarningInformation(violationWarningInformation1);
175 202 }
... ... @@ -180,7 +207,6 @@ public class Consumer {
180 207 SpringUtils.getBean(KafkaCompensationMapper.class).updateKafkaCompensation(kafkaCompensation);
181 208 }
182 209  
183   - @Transactional
184 210 public String insertKafkaCompensation(String data){
185 211 KafkaCompensation kafkaCompensation = new KafkaCompensation();
186 212 kafkaCompensation.setData(data);
... ...
trash-workFlow/src/main/java/com/trash/casefile/service/impl/ViolationWarningInformationServiceImpl.java
... ... @@ -6,19 +6,14 @@ import java.util.stream.Collectors;
6 6  
7 7 import com.alibaba.fastjson.JSONArray;
8 8 import com.alibaba.fastjson.JSONObject;
9   -import com.trash.casefile.domain.ViolationCaseFile;
10 9 import com.trash.casefile.domain.vo.ViolationWarningInformationVo;
11   -import com.trash.casefile.kafka.Consumer;
12 10 import com.trash.common.core.redis.RedisCache;
13 11 import com.trash.common.utils.DateUtils;
14 12 import com.trash.common.utils.SecurityUtils;
15 13 import com.trash.common.utils.StringUtils;
16 14 import com.trash.common.utils.file.FileUploadUtils;
17   -import com.trash.office.domain.LeaveApplication;
18 15 import com.trash.office.domain.UploadFile;
19   -import com.trash.office.domain.vo.LeaveApplicationVo;
20 16 import com.trash.office.mapper.UploadFileMapper;
21   -import com.trash.workflow.domain.Workflow;
22 17 import com.trash.workflow.service.IWorkflowService;
23 18 import org.slf4j.Logger;
24 19 import org.slf4j.LoggerFactory;
... ... @@ -39,7 +34,7 @@ import org.springframework.web.multipart.MultipartFile;
39 34 @Service
40 35 public class ViolationWarningInformationServiceImpl implements IViolationWarningInformationService
41 36 {
42   - private static final Logger log = LoggerFactory.getLogger(Consumer.class);
  37 + private static final Logger log = LoggerFactory.getLogger(ViolationWarningInformationServiceImpl.class);
43 38 @Autowired
44 39 private ViolationWarningInformationMapper violationWarningInformationMapper;
45 40 @Autowired
... ...