diff --git a/src/main/java/com/biutag/supervisiondata/mapper/wdpc/WdpcPersonMapper.java b/src/main/java/com/biutag/supervisiondata/mapper/wdpc/WdpcPersonMapper.java new file mode 100644 index 0000000..8f341bf --- /dev/null +++ b/src/main/java/com/biutag/supervisiondata/mapper/wdpc/WdpcPersonMapper.java @@ -0,0 +1,16 @@ +package com.biutag.supervisiondata.mapper.wdpc; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.biutag.supervisiondata.pojo.entity.wdpc.WdpcPerson; +import org.apache.ibatis.annotations.Update; + +/** + * @author kami on 2024-12-11 16:35:08 + * @version 0.0.1 + * @since 1.8 + */ +public interface WdpcPersonMapper extends BaseMapper { + + @Update("truncate table wpdc_person") + int truncateTable(); +} diff --git a/src/main/java/com/biutag/supervisiondata/pojo/entity/wdpc/WdpcPerson.java b/src/main/java/com/biutag/supervisiondata/pojo/entity/wdpc/WdpcPerson.java new file mode 100644 index 0000000..f780fa8 --- /dev/null +++ b/src/main/java/com/biutag/supervisiondata/pojo/entity/wdpc/WdpcPerson.java @@ -0,0 +1,21 @@ +package com.biutag.supervisiondata.pojo.entity.wdpc; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** + * @author kami on 2024-12-11 16:34:00 + * @version 0.0.1 + * @since 1.8 + */ +@Data +@TableName("`wdpc_person`") +public class WdpcPerson { + + @TableId("`id`") + Integer id; + @TableField("id_code") + String idCode; +} diff --git a/src/main/java/com/biutag/supervisiondata/repository/WdpcPersonRepository.java b/src/main/java/com/biutag/supervisiondata/repository/WdpcPersonRepository.java new file mode 100644 index 0000000..5e17941 --- /dev/null +++ b/src/main/java/com/biutag/supervisiondata/repository/WdpcPersonRepository.java @@ -0,0 +1,15 @@ +package com.biutag.supervisiondata.repository; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.biutag.supervisiondata.mapper.wdpc.WdpcPersonMapper; +import com.biutag.supervisiondata.pojo.entity.wdpc.WdpcPerson; +import org.springframework.stereotype.Service; + +/** + * @author kami on 2024-12-11 16:35:44 + * @version 0.0.1 + * @since 1.8 + */ +@Service +public class WdpcPersonRepository extends ServiceImpl { +} diff --git a/src/main/java/com/biutag/supervisiondata/service/PersonalService.java b/src/main/java/com/biutag/supervisiondata/service/PersonalService.java index 66ef4cc..b2c3d8e 100644 --- a/src/main/java/com/biutag/supervisiondata/service/PersonalService.java +++ b/src/main/java/com/biutag/supervisiondata/service/PersonalService.java @@ -49,4 +49,9 @@ public interface PersonalService { void pullPsychosis(); void init(); + + /** + * 同步人员到gbase + */ + void syncPerson(); } diff --git a/src/main/java/com/biutag/supervisiondata/service/impl/PersonalServiceImpl.java b/src/main/java/com/biutag/supervisiondata/service/impl/PersonalServiceImpl.java index 7b20966..1f565ad 100644 --- a/src/main/java/com/biutag/supervisiondata/service/impl/PersonalServiceImpl.java +++ b/src/main/java/com/biutag/supervisiondata/service/impl/PersonalServiceImpl.java @@ -9,6 +9,7 @@ import com.biutag.supervisiondata.pojo.entity.ads.GBaseSYRKXX; import com.biutag.supervisiondata.pojo.entity.dwd.GBaseJJD; import com.biutag.supervisiondata.pojo.entity.dwd.GBaseZDRY; import com.biutag.supervisiondata.pojo.entity.mine.*; +import com.biutag.supervisiondata.pojo.entity.wdpc.WdpcPerson; import com.biutag.supervisiondata.pojo.entity.wdpc2.WdpcGrjdJsbry; import com.biutag.supervisiondata.pojo.entity.wdpc.WdpcGrjdXfsj; import com.biutag.supervisiondata.pojo.entity.wdpc.WdpcGrjdXfsjCs; @@ -125,7 +126,7 @@ public class PersonalServiceImpl implements PersonalService { cache.put(item.getBjrzjhm(), new Byte[0]); if (syrkxx != null) { RiskPersonal personal = createPerson(syrkxx, item.getBjsj(), now, end, Default.BIG_TAG_JJD); - if(personal != null) { + if (personal != null) { personals.add(personal); } } @@ -135,16 +136,16 @@ public class PersonalServiceImpl implements PersonalService { if (!idCards.isEmpty()) { String[] arr = idCards.split(","); for (String s : arr) { - if(cache.get(s) != null) { + if (cache.get(s) != null) { continue; } GBaseSYRKXX xx = idCodeMap.get(s); - if(xx == null) { + if (xx == null) { continue; } cache.put(xx.getGmsfhm(), new Byte[0]); RiskPersonal personal = createPerson(xx, item.getBjsj(), now, end, Default.BIG_TAG_JJD); - if(personal == null) { + if (personal == null) { continue; } personals.add(personal); @@ -156,7 +157,7 @@ public class PersonalServiceImpl implements PersonalService { if (syrkxx != null) { cache.put(syrkxx.getGmsfhm(), new Byte[0]); RiskPersonal personal = createPerson(syrkxx, item.getBjsj(), now, end, Default.BIG_TAG_JJD); - if(personal == null) { + if (personal == null) { continue; } personals.add(personal); @@ -240,7 +241,7 @@ public class PersonalServiceImpl implements PersonalService { Contradiction contradiction = map.get(syrkxx.getGmsfhm()); RiskPersonal personal = createPerson(syrkxx, Optional.of(contradiction).map(Contradiction::getMaxTime) .orElse(null), now.toLocalDate(), now, Default.BIG_TAG_SHWFR); - if(personal != null) { + if (personal != null) { personals.add(personal); } @@ -294,8 +295,8 @@ public class PersonalServiceImpl implements PersonalService { Date nowDate = new Date(); for (GBaseSYRKXX xx : xxList) { if (map.get(xx.getGmsfhm()) == null) { - RiskPersonal personal =createPerson(xx, nowDate, today, now, Default.BIG_TAG_PETITION); - if(personal != null) { + RiskPersonal personal = createPerson(xx, nowDate, today, now, Default.BIG_TAG_PETITION); + if (personal != null) { personals.add(personal); } map.put(xx.getGmsfhm(), new Byte[0]); @@ -335,7 +336,7 @@ public class PersonalServiceImpl implements PersonalService { orgCodeMap.put(org.getDm(), org); } - Map supExternalDepartMap = supDeparts.stream().collect(Collectors.toMap(SupExternalDepart::getExternalId, Function.identity(), (val,old) -> val)); + Map supExternalDepartMap = supDeparts.stream().collect(Collectors.toMap(SupExternalDepart::getExternalId, Function.identity(), (val, old) -> val)); List xxList = new ArrayList<>(getByIdCode(idCards2)); // 去重 @@ -348,17 +349,17 @@ public class PersonalServiceImpl implements PersonalService { for (GBaseSYRKXX xx : xxList) { if (map.get(xx.getGmsfhm()) == null) { RiskPersonal personal = createPerson(xx, nowDate, today, now, Default.BIG_TAG_PETITION); - if(personal == null) { + if (personal == null) { continue; } SupExternalDepart depart = hope.get(xx.getSspcsdm()); - if(depart == null) { + if (depart == null) { personal.setMobileNumber(xx.getLxdh()); PointOrg org = orgCodeMap.get(xx.getSspcsdm()); org = OrgUtil.findOrg(org, orgIdMap); depart = Optional.ofNullable(org).map(PointOrg::getDm).map(supExternalDepartMap::get).orElse(null); } - if(depart != null) { + if (depart != null) { hope.put(xx.getSspcsdm(), depart); personal.setControlDepartId(depart.getInternalId()); personal.setControlDepartName(depart.getInternalName()); @@ -374,11 +375,11 @@ public class PersonalServiceImpl implements PersonalService { riskPersonalService.saveDistinct(personals); } - private final WdpcRyLgXXRepository lgXXRepository; + private final WdpcRyLgXXRepository lgXXRepository; @Override public void pullInvestigate() { - List xxList = lgXXRepository.list(new LambdaQueryWrapper().select(WdpcRyLgXX::getXm,WdpcRyLgXX::getSfzh,WdpcRyLgXX::getGxdwmc,WdpcRyLgXX::getGxdwbh,WdpcRyLgXX::getLxdh)); + List xxList = lgXXRepository.list(new LambdaQueryWrapper().select(WdpcRyLgXX::getXm, WdpcRyLgXX::getSfzh, WdpcRyLgXX::getGxdwmc, WdpcRyLgXX::getGxdwbh, WdpcRyLgXX::getLxdh)); LocalDate now = LocalDate.now(); List personals = new ArrayList<>(); for (WdpcRyLgXX wdpcRyLgXX : xxList) { @@ -396,7 +397,7 @@ public class PersonalServiceImpl implements PersonalService { person.setTags(Default.INVESTIGATE_FOUR); personals.add(person); } - if(!personals.isEmpty()) { + if (!personals.isEmpty()) { riskPersonalService.saveDistinct(personals); } } @@ -431,13 +432,13 @@ public class PersonalServiceImpl implements PersonalService { orgCodeMap.put(org.getDm(), org); } - Map supExternalDepartMap = supDeparts.stream().collect(Collectors.toMap(SupExternalDepart::getExternalId, Function.identity(), (val,old) -> val)); + Map supExternalDepartMap = supDeparts.stream().collect(Collectors.toMap(SupExternalDepart::getExternalId, Function.identity(), (val, old) -> val)); Map map = new WeakHashMap<>(); List personals = new ArrayList<>(); Map hope = new WeakHashMap<>(); for (WdpcGrjdJsbry ry : jsbryList) { - if(map.get(ry.getIdCode()) != null) { + if (map.get(ry.getIdCode()) != null) { continue; } map.put(ry.getIdCode(), new Byte[0]); @@ -452,15 +453,15 @@ public class PersonalServiceImpl implements PersonalService { person.setCreateTime(LocalDateTime.now()); person.setControlTime(LocalDateTime.now()); person.setControlDepartType(DepartType.OTHER.getType()); - if(xx != null) { + if (xx != null) { SupExternalDepart depart = hope.get(xx.getSspcsdm()); - if(depart == null) { + if (depart == null) { person.setMobileNumber(xx.getLxdh()); PointOrg org = orgCodeMap.get(xx.getSspcsdm()); org = OrgUtil.findOrg(org, orgIdMap); depart = Optional.ofNullable(org).map(PointOrg::getDm).map(supExternalDepartMap::get).orElse(null); } - if(depart != null) { + if (depart != null) { hope.put(xx.getSspcsdm(), depart); person.setControlDepartId(depart.getInternalId()); person.setControlDepartName(depart.getInternalName()); @@ -470,7 +471,7 @@ public class PersonalServiceImpl implements PersonalService { person.setTags(Default.PSYCHOSIS_TAG); personals.add(person); } - if(!personals.isEmpty()) { + if (!personals.isEmpty()) { riskPersonalService.saveDistinct(personals); } } @@ -487,6 +488,27 @@ public class PersonalServiceImpl implements PersonalService { riskTestRepository.getBaseMapper().truncateTable(); } + private final WdpcPersonRepository wdpcPersonRepository; + + private final RiskPersonalRepository personalRepository; + + @Override + public void syncPerson() { + wdpcPersonRepository.getBaseMapper().truncateTable(); + List personals = personalRepository.list(new LambdaQueryWrapper() + .select(RiskPersonal::getIdCode, RiskPersonal::getIdCode) + .eq(RiskPersonal::getDel, 0)); + + List personList = new ArrayList<>(); + for (RiskPersonal personal : personals) { + WdpcPerson person = new WdpcPerson(); + person.setId(personal.getId()); + person.setIdCode(personal.getIdCode()); + personList.add(person); + } + wdpcPersonRepository.saveBatch(personList, 10000); + } + /** * 通过身份证号查询实有人口 * diff --git a/src/main/java/com/biutag/supervisiondata/service/impl/PetitionServiceImpl.java b/src/main/java/com/biutag/supervisiondata/service/impl/PetitionServiceImpl.java index 9a75828..a179fde 100644 --- a/src/main/java/com/biutag/supervisiondata/service/impl/PetitionServiceImpl.java +++ b/src/main/java/com/biutag/supervisiondata/service/impl/PetitionServiceImpl.java @@ -289,8 +289,7 @@ public class PetitionServiceImpl implements PetitionService { @Override public void petitionModelTask(TaskParamDomain domain) { - RiskTask task = createTask(domain.getPersons().size(), 40); - riskTaskRepository.save(task); + RiskTask task = riskTaskRepository.create(domain.getPersons().size(), 40); LocalDateTime time = LocalDateTime.now().minusMonths(12); List pList1 = new ArrayList<>(); @@ -392,14 +391,7 @@ public class PetitionServiceImpl implements PetitionService { log.info("公安信访数据: {}", toInsert.size()); riskModelTaskClueService.saveClues(toInsert, Default.MAIL_IG); } - - RiskTask updateTask = new RiskTask(); - updateTask.setId(task.getId()); - updateTask.setInsertSize(toInsert.size()); - updateTask.setUpdateSize(0); - updateTask.setState(1); - updateTask.setEndTime(LocalDateTime.now()); - riskTaskRepository.updateById(updateTask); + riskTaskRepository.updateTask(task.getId(), toInsert.size(), 0); } GBaseSYRKXX compare(List infos, String name) { @@ -424,15 +416,6 @@ public class PetitionServiceImpl implements PetitionService { return info; } - RiskTask createTask(Integer size, Integer modelId) { - RiskTask task = new RiskTask(); - task.setModelId(modelId); - task.setStartTime(LocalDateTime.now()); - task.setState(0); - task.setScanSize(size); - return task; - } - RiskModelTaskClue createClue(Integer modelId, Integer score, Integer taskId, ClueData data) { RiskModelTaskClue clue = new RiskModelTaskClue(); clue.setModelId(modelId);