Browse Source

修改模型1:案件警情疑似未及时受理案件,修改基本信息格式,新增单位关联表

main
sjh 1 year ago
parent
commit
8f95d1dcf4
  1. 12
      src/main/java/com/biutag/supervision/mapper/GBaseAJJBXXMapper.java
  2. 2
      src/main/java/com/biutag/supervision/mapper/ModelClueDataMapper.java
  3. 7
      src/main/java/com/biutag/supervision/mapper/SupExternalDepartMapper.java
  4. 36
      src/main/java/com/biutag/supervision/pojo/entity/GBaseAJJBXX.java
  5. 2
      src/main/java/com/biutag/supervision/pojo/entity/GBaseCJD.java
  6. 2
      src/main/java/com/biutag/supervision/pojo/entity/GBaseJJD.java
  7. 11
      src/main/java/com/biutag/supervision/pojo/entity/ModelClue.java
  8. 51
      src/main/java/com/biutag/supervision/pojo/entity/SupExternalDepart.java
  9. 7
      src/main/java/com/biutag/supervision/service/BusinessDepartService.java
  10. 32
      src/main/java/com/biutag/supervision/service/ModelClueService.java
  11. 120
      src/main/java/com/biutag/supervision/service/SupExternalDepartService.java

12
src/main/java/com/biutag/supervision/mapper/GBaseAJJBXXMapper.java

@ -0,0 +1,12 @@
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.GBaseAJJBXX;
import org.apache.ibatis.annotations.Mapper;
@DS("slave2")
@Mapper
public interface GBaseAJJBXXMapper extends BaseMapper<GBaseAJJBXX> {
}

2
src/main/java/com/biutag/supervision/mapper/ModelClueDataMapper.java

@ -1,6 +1,5 @@
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;
@ -8,7 +7,6 @@ import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
@DS("slave2")
public interface ModelClueDataMapper extends BaseMapper<ModelClue> {
@Select("${sql}")

7
src/main/java/com/biutag/supervision/mapper/SupExternalDepartMapper.java

@ -0,0 +1,7 @@
package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.SupExternalDepart;
public interface SupExternalDepartMapper extends BaseMapper<SupExternalDepart> {
}

36
src/main/java/com/biutag/supervision/pojo/entity/GBaseAJJBXX.java

@ -0,0 +1,36 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
@TableName("dwd_asj_zfba_ajjbxx")
public class GBaseAJJBXX {
// 立案单位编码
@TableField("LADWBMdm")
private String LADWBMdm;
// 立案单位名称
@TableField("LADWBMmc")
private String LADWBMmc;
// 破案单位编码
@TableField("PADWBMdm")
private String PADWBMdm;
// 破案单位名称
@TableField("PADWBMmc")
private String PADWBMmc;
// 办案单位编码
@TableField("BADWIDdm")
private String BADWIDdm;
// 办案单位名称
@TableField("BADWIDmc")
private String BADWIDmc;
}

2
src/main/java/com/biutag/supervision/pojo/entity/GBaseCJD.java

@ -1,11 +1,13 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@TableName("dwd_asj_zhtx_cjd")
@Setter
@Getter
public class GBaseCJD {

2
src/main/java/com/biutag/supervision/pojo/entity/GBaseJJD.java

@ -1,11 +1,13 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@TableName("dwd_asj_zhtx_jjd")
@Setter
@Getter
public class GBaseJJD {

11
src/main/java/com/biutag/supervision/pojo/entity/ModelClue.java

@ -52,7 +52,16 @@ public class ModelClue {
// 数据详情 JSON
private String data;
@TableField(exist = false)
// 问题ID
@TableField("negative_id")
private String negativeId;
// 状态:0-未处理 1-已处理
@TableField("status")
private Integer status;
// 外部主键
@TableField("unique_key")
private String uniqueKey;
}

51
src/main/java/com/biutag/supervision/pojo/entity/SupExternalDepart.java

@ -0,0 +1,51 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Setter
@Getter
public class SupExternalDepart {
// id
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
// 外部单位id
@TableField("external_id")
private String externalId;
// 外部单位名称
@TableField("external_name")
private String externalName;
// 外部来源
@TableField("source")
private String source;
// 内部单位id
@TableField("internal_id")
private String internalId;
// 内部单位名称
@TableField("internal_name")
private String internalName;
// 内部单位短名称
@TableField("internal_short_name")
private String internalShortName;
// 创建时间
@TableField("create_time")
private LocalDateTime createTime;
// 更新时间
@TableField("update_time")
private LocalDateTime updateTime;
}

7
src/main/java/com/biutag/supervision/service/BusinessDepartService.java

@ -37,6 +37,8 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
private final ModelClueService modelClueService;
private final SupExternalDepartService externalDepartService;
public Page<BusinessPoliceModel> page(BusinessQueryParam businessQueryParam) {
// if (businessQueryParam.getDepartName()!=null && businessQueryParam.getDepartName().equals("开始导入今年所有的数据")) {
// LocalDate start = LocalDate.parse("2024-05-23");
@ -63,6 +65,11 @@ public class BusinessDepartService extends ServiceImpl<BusinessDepartMapper, Bus
System.out.println("执行完毕");
return null;
}
if (businessQueryParam.getDepartName() != null && businessQueryParam.getDepartName().equals("导入单位")) {
externalDepartService.insertPreData();
System.out.println("执行完毕");
return null;
}
QueryWrapper<BusinessPoliceModel> queryWrapper = new QueryWrapper<>();
queryWrapper
.like(StrUtil.isNotBlank(businessQueryParam.getDepartName()), "depart_name", businessQueryParam.getDepartName())

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

@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.constants.enums.*;
@ -20,10 +21,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.*;
@ -52,6 +49,8 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
public final SupDepartMapper supDepartMapper;
public final SupExternalDepartMapper supExternalDepartMapper;
public Page<ModelClueModel> page(ModelClueQueryParam param) {
if (Objects.nonNull(param.getModelIds()) && param.getModelIds().isEmpty()) {
return new Page<ModelClueModel>().setTotal(0).setRecords(new ArrayList<>());
@ -168,10 +167,10 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
for (ModelClue modelClue : modelClues) {
modelClue.setModelId(modelId);
modelClue.setCreateTime(LocalDateTime.now());
SupDepart supDepart = supDepartMapper.selectOne(new LambdaQueryWrapper<SupDepart>().eq(SupDepart::getCode, modelClue.getInvolveDepartId()));
if (supDepart != null && supDepart.getShortName() != null && !supDepart.getShortName().isEmpty()) {
modelClue.setInvolveDepartName(supDepart.getShortName());
modelClue.setInvolveDepartId(supDepart.getId());
SupExternalDepart supExternalDepart = supExternalDepartMapper.selectOne(new LambdaQueryWrapper<SupExternalDepart>().eq(SupExternalDepart::getExternalId, modelClue.getInvolveDepartId()));
if (supExternalDepart != null && supExternalDepart.getInternalShortName() != null && !supExternalDepart.getInternalShortName().isEmpty()) {
modelClue.setInvolveDepartName(supExternalDepart.getInternalShortName());
modelClue.setInvolveDepartId(supExternalDepart.getInternalId());
}
}
modelClueMapper.insert(modelClues);
@ -182,16 +181,27 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
}
public List<ModelClue> getModelClueBySql(String sql, Integer modelId) {
List<String> oldUniqueKeys = this.listObjs(new LambdaQueryWrapper<ModelClue>().select(ModelClue::getUniqueKey).eq(ModelClue::getStatus, 0), String::valueOf);
List<ModelClue> modelClues = modelClueDataMapper.selectDataByDynamicSql(sql);
List<String> uniqueKeys = modelClues.stream().map(ModelClue::getUniqueKey).filter(k -> k != null && !k.isEmpty()).toList();
String newSql = generateNewSql(sql, uniqueKeys);
List<String> changeStatusIds = oldUniqueKeys.stream().filter(item -> !uniqueKeys.contains(item)).toList();
if (!changeStatusIds.isEmpty()) {
modelClueMapper.update(null, new LambdaUpdateWrapper<ModelClue>().in(ModelClue::getUniqueKey, changeStatusIds).set(ModelClue::getStatus, 1));
}
List<String> needsInsertIds = uniqueKeys.stream().filter(item -> !oldUniqueKeys.contains(item)).toList();
if (needsInsertIds.isEmpty()) {
return new ArrayList<>();
}
List<ModelClue> needsInsertModelClues = modelClues.stream().filter(item -> needsInsertIds.contains(item.getUniqueKey())).toList();
String newSql = generateNewSql(sql, needsInsertIds);
List<Map<String, Object>> allData = modelClueDataMapper.selectByUniqueKeys(newSql);
String originalFieldName = getKeyFieldName(sql);
for (ModelClue modelClue : modelClues) {
for (ModelClue modelClue : needsInsertModelClues) {
for (Map<String, Object> data : allData) {
String keyColumn = (String) data.get(originalFieldName);
if (Objects.equals(keyColumn, modelClue.getUniqueKey())) {
modelClue.setData(JSONObject.toJSONString(data));
modelClue.setStatus(0);
List<Integer> modelNos = new ArrayList<>(List.of(1));
if (modelNos.contains(modelId)) {
String thingDesc = modelClue.getThingDesc();
@ -207,7 +217,7 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
}
}
}
return modelClues;
return needsInsertModelClues;
}
private static String getDateString(Object param) {

120
src/main/java/com/biutag/supervision/service/SupExternalDepartService.java

@ -0,0 +1,120 @@
package com.biutag.supervision.service;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.mapper.*;
import com.biutag.supervision.pojo.entity.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Slf4j
@RequiredArgsConstructor
@Service
public class SupExternalDepartService extends ServiceImpl<SupExternalDepartMapper, SupExternalDepart> {
private final SupExternalDepartMapper supExternalDepartMapper;
private final GBaseAJJBXXMapper gBaseAJJBXXMapper;
private final SupDepartMapper supDepartMapper;
private final GBaseJJDMapper gBaseJJDMapper;
private final GBaseCJDMapper gBaseCJDMapper;
public void insertPreData() {
List<SupExternalDepart> supExternalDeparts = new ArrayList<>();
Set<String> dms = new HashSet<>();
selectAJJBXX(1, supExternalDeparts, dms);
selectAJJBXX(2, supExternalDeparts, dms);
selectAJJBXX(3, supExternalDeparts, dms);
selectJJDandCJD(dms, supExternalDeparts);
List<SupDepart> supDeparts = supDepartMapper.selectList(new LambdaQueryWrapper<SupDepart>().in(SupDepart::getCode, dms));
for (SupExternalDepart supExternalDepart : supExternalDeparts) {
SupDepart supDepart = supDeparts.stream().filter(item -> item.getCode().equals(supExternalDepart.getExternalId())).findFirst().orElse(null);
if (supDepart != null) {
supExternalDepart.setInternalId(supDepart.getId());
supExternalDepart.setInternalName(supDepart.getName());
supExternalDepart.setInternalShortName(supDepart.getShortName());
supExternalDepart.setCreateTime(LocalDateTime.now());
}
}
supExternalDepartMapper.insert(supExternalDeparts);
}
private void selectJJDandCJD(Set<String> dms, List<SupExternalDepart> supExternalDeparts) {
List<GBaseJJD> gBaseJJDS = gBaseJJDMapper.selectList(new QueryWrapper<GBaseJJD>().select("DISTINCT gxdwdm, gxdwmc"));
if (!gBaseJJDS.isEmpty()) {
gBaseJJDS.forEach(item -> {
if (item != null && !dms.contains(item.getGxdwdm())) {
SupExternalDepart supExternalDepart = new SupExternalDepart();
supExternalDepart.setExternalId(item.getGxdwdm() == null ? "" : item.getGxdwdm());
supExternalDepart.setExternalName(item.getGxdwmc() == null ? "" : item.getGxdwmc());
dms.add(item.getGxdwdm());
supExternalDepart.setSource("情指行");
supExternalDeparts.add(supExternalDepart);
}
});
}
List<GBaseCJD> gBaseCJDS = gBaseCJDMapper.selectList(new QueryWrapper<GBaseCJD>().select("DISTINCT cjdxssdwdm, cjdxssdwmc"));
if (!gBaseCJDS.isEmpty()) {
gBaseCJDS.forEach(item -> {
if (item != null && !dms.contains(item.getCjdxssdwdm())) {
SupExternalDepart supExternalDepart = new SupExternalDepart();
supExternalDepart.setExternalId(item.getCjdxssdwdm() == null ? "" : item.getCjdxssdwdm());
supExternalDepart.setExternalName(item.getCjdxssdwmc() == null ? "" : item.getCjdxssdwmc());
dms.add(item.getCjdxssdwdm());
supExternalDepart.setSource("情指行");
supExternalDeparts.add(supExternalDepart);
}
});
}
}
@DS("slave2")
private void selectAJJBXX(int type, List<SupExternalDepart> result, Set<String> dms) {
QueryWrapper<GBaseAJJBXX> queryWrapper = new QueryWrapper<>();
if (type == 1) {
queryWrapper.select("DISTINCT LADWBMdm, LADWBMmc");
} else if (type == 2) {
queryWrapper.select("DISTINCT PADWBMdm, PADWBMmc");
} else if (type == 3) {
queryWrapper.select("DISTINCT BADWIDdm, BADWIDmc");
}
List<GBaseAJJBXX> supExternalDeparts = gBaseAJJBXXMapper.selectList(queryWrapper);
if (!supExternalDeparts.isEmpty()) {
supExternalDeparts.forEach(item -> {
if (item != null) {
SupExternalDepart supExternalDepart = new SupExternalDepart();
if (type == 1) {
supExternalDepart.setExternalId(item.getLADWBMdm() == null ? "" : item.getLADWBMdm());
supExternalDepart.setExternalName(item.getLADWBMmc() == null ? "" : item.getLADWBMmc());
} else if (type == 2 && !dms.contains(item.getPADWBMdm())) {
supExternalDepart.setExternalId(item.getPADWBMdm() == null ? "" : item.getPADWBMdm());
supExternalDepart.setExternalName(item.getPADWBMmc() == null ? "" : item.getPADWBMmc());
dms.add(item.getPADWBMdm());
} else if (type == 3 && !dms.contains(item.getBADWIDdm())) {
supExternalDepart.setExternalId(item.getBADWIDdm() == null ? "" : item.getBADWIDdm());
supExternalDepart.setExternalName(item.getBADWIDmc() == null ? "" : item.getBADWIDmc());
dms.add(item.getBADWIDdm());
}
supExternalDepart.setSource("情指行");
result.add(supExternalDepart);
}
});
}
if (dms.isEmpty() && type == 1) {
dms.addAll(result.stream().map(SupExternalDepart::getExternalId).collect(Collectors.toSet()));
}
}
}
Loading…
Cancel
Save