11 changed files with 268 additions and 14 deletions
@ -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> { |
||||
|
||||
} |
||||
@ -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> { |
||||
} |
||||
@ -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; |
||||
} |
||||
@ -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; |
||||
|
||||
} |
||||
@ -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…
Reference in new issue