Browse Source

新增22号模型:执法记录仪使用不规范问题

main
sjh 1 year ago
parent
commit
6e8349702f
  1. 20
      src/main/java/com/biutag/supervision/mapper/ModelClueDataDMMapper.java
  2. 62
      src/main/java/com/biutag/supervision/service/ModelClueService.java
  3. 6
      src/main/resources/application-dev.yml
  4. 6
      src/main/resources/application-prod.yml

20
src/main/java/com/biutag/supervision/mapper/ModelClueDataDMMapper.java

@ -0,0 +1,20 @@
package com.biutag.supervision.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.ModelClue;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
@DS("slave3") // 该注解勿动
public interface ModelClueDataDMMapper extends BaseMapper<ModelClue> {
@Select("${sql}")
List<ModelClue> selectDataByDynamicSql(@org.apache.ibatis.annotations.Param("sql") String sql);
@Select("${newSql}")
List<Map<String, Object>> selectByUniqueKeys(@org.apache.ibatis.annotations.Param("newSql") String newSql);
}

62
src/main/java/com/biutag/supervision/service/ModelClueService.java

@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
@ -52,6 +53,8 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
public final ModelClueDataMapper modelClueDataMapper; public final ModelClueDataMapper modelClueDataMapper;
public final ModelClueDataDMMapper modelClueDataDMMapper;
public final ModelClueRecordMapper modelClueRecordMapper; public final ModelClueRecordMapper modelClueRecordMapper;
public final SupExternalDepartMapper supExternalDepartMapper; public final SupExternalDepartMapper supExternalDepartMapper;
@ -230,6 +233,9 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
} else if (modelId == 20) { // 20号模型:连续7天上传散油购销记录小于10的异常数据 } else if (modelId == 20) { // 20号模型:连续7天上传散油购销记录小于10的异常数据
getModelCluesForModel20(sql, modelClues); getModelCluesForModel20(sql, modelClues);
return modelClues; return modelClues;
} else if (modelId == 22) { // 22号模型:执法记录仪使用不规范问题
getModelCluesForModel22(sql, modelClues);
return modelClues;
} else { } else {
System.out.println("模型" + modelId + "开始查询数据库"); System.out.println("模型" + modelId + "开始查询数据库");
modelClues = modelClueDataMapper.selectDataByDynamicSql(sql); modelClues = modelClueDataMapper.selectDataByDynamicSql(sql);
@ -696,6 +702,62 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
} }
} }
private void getModelCluesForModel22(String sql, List<ModelClue> modelClues) {
System.out.println("模型22开始查询数据库");
List<Map<String, Object>> sqlList = modelClueDataDMMapper.selectByUniqueKeys(sql);
System.out.println("模型22查询数据库完毕");
if (sqlList.isEmpty()) {
return;
}
for (Map<String, Object> map : sqlList) {
ModelClue newModelClue = new ModelClue();
newModelClue.setUniqueKey("");
newModelClue.setNegativeIdEx("");
newModelClue.setInvolvePoliceName((String) map.get("USERNAME"));
newModelClue.setInvolveDepartName((String) map.get("orgname"));
SupExternalDepart supExternalDepart = supExternalDepartMapper.selectOne(new LambdaQueryWrapper<SupExternalDepart>().eq(SupExternalDepart::getInternalName, map.get("orgname")).last("LIMIT 1"));
if (supExternalDepart != null) {
if (supExternalDepart.getInternalId() != null) {
newModelClue.setInvolveDepartId(supExternalDepart.getInternalId());
}
}
newModelClue.setData(JSONObject.toJSONString(map));
newModelClue.setDistributionState("0");
String createTime = "";
Object createTimeObj = map.get("CREATETIME");
try {
if (createTimeObj instanceof Timestamp timestamp) {
Instant instant = timestamp.toInstant();
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
createTime = "于" + formatter.format(localDateTime);
} else if (createTimeObj instanceof String createTimeStr) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS");
Date parseDate = sdf.parse(createTimeStr);
Instant instant = parseDate.toInstant();
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
createTime = "于" + formatter.format(localDateTime);
} else if (createTimeObj instanceof Date date) {
Instant instant = date.toInstant();
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
createTime = "于" + formatter.format(localDateTime);
}
} catch (Exception ex) {
log.error("模型20日期解析失败: {}", ex.getMessage(), ex);
}
newModelClue.setThingDesc(
"灵敏感知系统" + createTime + "发现" + newModelClue.getInvolveDepartName() + "有"
+ map.get("TYPENAME") + "的问题,问题详情:“"
+ map.get("DESCRIBEDETAILS") + "”,请予以重点关注。");
modelClues.add(newModelClue);
}
}
private void mergeModelClues(List<ModelClue> modelClues2, List<ModelClue> modelClues1 , int no) { private void mergeModelClues(List<ModelClue> modelClues2, List<ModelClue> modelClues1 , int no) {
for (ModelClue modelClue2 : modelClues2) { for (ModelClue modelClue2 : modelClues2) {
Iterator<ModelClue> iterator1 = modelClues1.iterator(); Iterator<ModelClue> iterator1 = modelClues1.iterator();

6
src/main/resources/application-dev.yml

@ -20,6 +20,12 @@ spring:
url: jdbc:mysql://172.31.217.20:31868/negative?serverTimezone=GMT%2B8 url: jdbc:mysql://172.31.217.20:31868/negative?serverTimezone=GMT%2B8
username: root username: root
password: ip12341234 password: ip12341234
slave3:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://172.31.217.20:31868/negative?serverTimezone=GMT%2B8
username: root
password: ip12341234
druid: druid:
min-evictable-idle-time-millis: 300000 min-evictable-idle-time-millis: 300000
test-on-borrow: false test-on-borrow: false

6
src/main/resources/application-prod.yml

@ -20,6 +20,12 @@ spring:
url: jdbc:gbase://65.47.16.209:5258/csga_dwd url: jdbc:gbase://65.47.16.209:5258/csga_dwd
username: csga_wdpc username: csga_wdpc
password: csga_wdpc@123 password: csga_wdpc@123
slave3:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: dm.jdbc.driver.DmDriver
url: jdbc:dm://65.47.22.243:5236/JSDZ_4GDB
username: DCZD
password: DCZD@2024
druid: druid:
min-evictable-idle-time-millis: 300000 min-evictable-idle-time-millis: 300000
test-on-borrow: false test-on-borrow: false

Loading…
Cancel
Save