From 5513e69c82a82eb6be786d5cb8e23b81bffc8636 Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期二, 10 八月 2021 09:55:47 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/test' into test --- springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/BigScreenApi.java | 52 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationSentenceExcelListen.java | 535 ++++ springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationDisabilityMistakeExcelVO.java | 86 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationCultExcelListen.java | 2 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulRegiterNatureEnum.java | 45 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationRehabilitationExcelListen.java | 584 +++++ springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationRehabilitationExcelVO.java | 10 springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenWorkApi.java | 109 springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/BigScreenStatisticsApi.java | 76 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java | 50 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationKeyMistakeExcelVO.java | 77 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationService.java | 44 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationRehabilitationMistakeExcelVO.java | 89 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVO.java | 12 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationKeyExcelListen.java | 548 ++++ springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java | 2 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationMajorExcelListen.java | 14 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationSentenceMistakeExcelVO.java | 92 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationDisabilityExcelListen.java | 516 ++++ springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationVeteransExcelListen.java | 725 ++++++ springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationSentenceExcelVO.java | 121 + springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationMajorExcelVO.java | 2 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVeteransMistakeExcelVO.java | 209 + springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java | 378 +++ springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenPopulationApi.java | 9 springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/filters/JWTAuthenticationTokenFilter.java | 5 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommonDataApi.java | 65 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java | 1588 ++++++++++++++ springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationKeyExcelVO.java | 105 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationDisabilityExcelVO.java | 115 + springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwRotaServiceImpl.java | 36 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVeteransExcelVO.java | 242 ++ springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwDangerReportServiceImpl.java | 8 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/constants/Constants.java | 14 34 files changed, 6,459 insertions(+), 106 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/constants/Constants.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/constants/Constants.java index 0b374f2..e9577a8 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/constants/Constants.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/constants/Constants.java @@ -157,9 +157,19 @@ public static final String CORRECT_POPULATION_ERROR_LIST = "CORRECT_POPULATION_ERROR_LIST_"; - public static final String Major_POPULATION_ERROR_LIST = "Major_POPULATION_ERROR_LIST_"; + public static final String MAJOR_POPULATION_ERROR_LIST = "MAJOR_POPULATION_ERROR_LIST_"; - public static final String Cult_POPULATION_ERROR_LIST = "Cult_POPULATION_ERROR_LIST_"; + public static final String CULT_POPULATION_ERROR_LIST = "CULT_POPULATION_ERROR_LIST_"; + + public static final String REHABILITATION_POPULATION_ERROR_LIST = "REHABILITATION_POPULATION_ERROR_LIST_"; + + public static final String KEY_POPULATION_ERROR_LIST = "KEY_POPULATION_ERROR_LIST_"; + + public static final String SENTENCE_POPULATION_ERROR_LIST = "SENTENCE_POPULATION_ERROR_LIST_"; + + public static final String VETERANS_POPULATION_ERROR_LIST = "VETERANS_POPULATION_ERROR_LIST_"; + + public static final String DISABILITY_POPULATION_ERROR_LIST = "DISABILITY_POPULATION_ERROR_LIST_"; /** * 高德地图获取天气url diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulRegiterNatureEnum.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulRegiterNatureEnum.java new file mode 100644 index 0000000..0c15873 --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulRegiterNatureEnum.java @@ -0,0 +1,45 @@ +package com.panzhihua.common.enums; + +/** 实有房屋使用类型 + * @author xyh + * @date 2021/6/11 9:33 + */ +public enum PopulRegiterNatureEnum { + + CZHK(1,"城镇户口"), + NCHK(0,"农村户口"), + ; + private final Integer code; + private final String name; + + PopulRegiterNatureEnum(Integer code, String name){ + this.code = code; + this.name = name; + } + + public Integer getCode() { + return code; + } + + public String getName() { + return name; + } + + public static int getCodeByName(String name) { + for (PopulRegiterNatureEnum item : PopulRegiterNatureEnum.values()) { + if (item.getName().equals(name)) { + return item.getCode(); + } + } + return -1; + } + + public static String getCnDescByName(Integer code) { + for (PopulRegiterNatureEnum item : PopulRegiterNatureEnum.values()) { + if (item.getCode().equals(code)) { + return item.getName(); + } + } + return "其他"; + } +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationCultExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationCultExcelListen.java index 305ee56..b2b9906 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationCultExcelListen.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationCultExcelListen.java @@ -109,7 +109,7 @@ throw new ServiceException("500", "导入数据为空!"); } ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); - String key = Constants.Cult_POPULATION_ERROR_LIST + communityId; + String key = Constants.CULT_POPULATION_ERROR_LIST + communityId; Map<String,String> dictMap = dictionaryR.getData().stream().collect(Collectors.toMap(BcDictionaryVO::getDictName,BcDictionaryVO::getDictValue)); // Map<String,Integer> dictMap = new HashMap<>(); diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationDisabilityExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationDisabilityExcelListen.java new file mode 100644 index 0000000..49fc4a8 --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationDisabilityExcelListen.java @@ -0,0 +1,516 @@ +package com.panzhihua.common.listen; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.alibaba.fastjson.JSONArray; +import com.google.common.collect.Lists; +import com.panzhihua.common.constants.BcDictionaryConstants; +import com.panzhihua.common.constants.Constants; +import com.panzhihua.common.enums.*; +import com.panzhihua.common.exceptions.ServiceException; +import com.panzhihua.common.model.vos.BcDictionaryVO; +import com.panzhihua.common.model.vos.R; +import com.panzhihua.common.model.vos.community.ComMngPopulationDisabilityExcelVO; +import com.panzhihua.common.model.vos.community.ComMngPopulationDisabilityMistakeExcelVO; +import com.panzhihua.common.service.community.CommunityService; +import com.panzhihua.common.utlis.ListUtils; +import com.panzhihua.common.utlis.PayUtil; +import com.panzhihua.common.utlis.StringUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.core.ValueOperations; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * @description: 残疾人导入监听 + * @author: txb + */ +@Slf4j +public class ComMngPopulationDisabilityExcelListen extends AnalysisEventListener<Map<Integer, String>> { + private CommunityService communityService; + + private Long communityId; + + private static int headSize = 0; + + private Map<Integer, String> headData; + + private String userName; + // FTP 登录密码 + private String password; + // FTP 服务器地址IP地址 + private String host; + // FTP 端口 + private int port; + private String excelUrl; + + private StringRedisTemplate stringRedisTemplate; + + public static String loadUrl; + + public ComMngPopulationDisabilityExcelListen(CommunityService communityService, Long communityId, String userName, String password, String host, int port, String excelUrl, StringRedisTemplate stringRedisTemplate) { + this.communityService = communityService; + this.communityId = communityId; + this.userName = userName; + this.password = password; + this.host = host; + this.port = port; + this.excelUrl = excelUrl; + this.stringRedisTemplate = stringRedisTemplate; + } + + /** + * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + */ + private static final int BATCH_COUNT = 5000; + List<Map<Integer, String>> list = new ArrayList<Map<Integer, String>>(); + + @Override + public void invoke(Map<Integer, String> data, AnalysisContext context) { + list.add(data); + if (list.size() >= BATCH_COUNT) { + saveData(); + list.clear(); + } + } + + /** + * 这里会一行行的返回头 + * + * @param headMap + * @param context + */ + @Override + public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { + headSize = headMap.size(); + headData = headMap; + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + saveData(); + log.info("所有数据解析完成!"); + } + + /** + * 不是固定的列只能手动处理 + */ + private void saveData() { + R<List<BcDictionaryVO>> dictionaryR = communityService.listDictionaryByKey(BcDictionaryConstants.FAMILY); + log.info("开始导入残疾人数据"); + log.info("表格总数据:" + list.size()); + if (list.size() == 0) { + throw new ServiceException("500", "导入数据为空!"); + } + ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); + String Disability = Constants.DISABILITY_POPULATION_ERROR_LIST + communityId; + + Map<String,String> dictMap = dictionaryR.getData().stream().collect(Collectors.toMap(BcDictionaryVO::getDictName,BcDictionaryVO::getDictValue)); +// Map<String,Integer> dictMap = new HashMap<>(); +// for(BcDictionaryVO vo : dictionaryR.getData()){ +// dictMap.put(vo.getDictName(),Integer.valueOf(vo.getDictValue())); +// } + + + int index = 2; + try { + ArrayList<ComMngPopulationDisabilityExcelVO> voList = Lists.newArrayList(); +// List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); + ArrayList<ComMngPopulationDisabilityMistakeExcelVO> mistakes = Lists.newArrayList(); + for (Map<Integer, String> oneData : list) { + ComMngPopulationDisabilityExcelVO vo = new ComMngPopulationDisabilityExcelVO(); + if (StringUtils.isNotEmpty(oneData.get(0))){ + vo.setSerialNumber(oneData.get(0)); + } + //姓名和身份证都为空,为空户,无需操作,否则就解析年龄,性别,出生年月日 + if(StringUtils.isNotEmpty(oneData.get(1)) || StringUtils.isNotEmpty(oneData.get(2))){ + if(StringUtils.isEmpty(oneData.get(1))){ + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + index++; + setDisabilityMistake(oneData, mistake); + mistake.setMistake("名字不可为空,请填写姓名"); + mistakes.add(mistake); + continue; + } + vo.setName(oneData.get(1)); + if(StringUtils.isEmpty(oneData.get(2))){ + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + index++; + setDisabilityMistake(oneData, mistake); + mistake.setMistake("身份证号不可为空,请填写身份证"); + mistakes.add(mistake); + continue; + } + + //判断身份证号码位数 + if(oneData.get(2).length() != 18){ + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + index++; + setDisabilityMistake(oneData, mistake); + mistake.setMistake("身份证号位数有误,请检查身份证号码是否正确"); + mistakes.add(mistake); + continue; + } + vo.setCardNo(oneData.get(2).toUpperCase()); + //根据身份证号码解析年龄以及性别 + //获取用户生日 + String birthday = vo.getCardNo().substring(6, 14); + if(StringUtils.isNotEmpty(birthday)){ + String year = birthday.substring(0,4); + String month = birthday.substring(4,6); + String day = birthday.substring(6,8); + vo.setBirthday(year + "-" + month + "-" + day); + } +// //设置用户年龄 +// vo.setAge(AgeUtils.getAgeFromBirthTime(birthday)); + //获取用户性别 + int sex = Integer.parseInt(vo.getCardNo().substring(16, 17)); + if(sex%2 == 1){ + vo.setSex(PopulSexEnum.nan.getCode()); + }else{ + vo.setSex(PopulSexEnum.nv.getCode()); + } + } + if(StringUtils.isNotEmpty(oneData.get(3))){ + vo.setCertificateSituation(oneData.get(3)); + } + if(StringUtils.isNotEmpty(oneData.get(4))){ + Integer isOk = PopulCultureLevelEnum.getCodeByName(oneData.get(4)); + if(isOk.equals(-1)){ + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + index++; + setDisabilityMistake(oneData, mistake); + mistake.setMistake("您填写的文化程度有误"); + mistakes.add(mistake); + continue; + } + vo.setCultureLevel(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(5))){ + vo.setNation(oneData.get(5)); + } + if(StringUtils.isNotEmpty(oneData.get(6))){ + vo.setDisType(oneData.get(6)); + } + if(StringUtils.isNotEmpty(oneData.get(7))){ + vo.setDisLevel(oneData.get(7)); + } + if(StringUtils.isNotEmpty(oneData.get(8))){ + vo.setPhone(oneData.get(8)); + } + if(StringUtils.isEmpty(oneData.get(9))){ + index++; + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + setDisabilityMistake(oneData, mistake); + mistake.setMistake("街路巷不可为空"); + mistakes.add(mistake); + continue; + } + vo.setRoad(oneData.get(9)); + if(StringUtils.isEmpty(oneData.get(10))){ + index++; + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + setDisabilityMistake(oneData, mistake); + mistake.setMistake("小区号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setDoorNo(oneData.get(10).trim()); + if(StringUtils.isEmpty(oneData.get(11))){ + index++; + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + setDisabilityMistake(oneData, mistake); + mistake.setMistake("楼排号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setFloor(oneData.get(11).trim()); + if(StringUtils.isEmpty(oneData.get(12))){ + index++; + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + setDisabilityMistake(oneData, mistake); + mistake.setMistake("单元号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setUnitNo(oneData.get(12).trim()); + if(StringUtils.isEmpty(oneData.get(13))){ + index++; + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + setDisabilityMistake(oneData, mistake); + mistake.setMistake("户室不可为空"); + mistakes.add(mistake); + continue; + } + vo.setHouseNo(oneData.get(13).trim()); + if(StringUtils.isNotEmpty(oneData.get(14))){ + Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(14)); + if(isOk.equals(-1)){ + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + index++; + setDisabilityMistake(oneData, mistake); + mistake.setMistake("您填写的是否租住有误"); + mistakes.add(mistake); + continue; + } + vo.setIsRent(isOk); + }else { + vo.setIsRent(PopulHouseUseEnum.getCodeByName("否")); + } + if(StringUtils.isNotEmpty(oneData.get(15))){ + Integer isOk = PopulHouseStatusEnum.getCodeByName(oneData.get(15).trim()); + if(isOk.equals(-1)){ + index++; + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + setDisabilityMistake(oneData, mistake); + mistake.setMistake("您填写的房屋状态有误"); + mistakes.add(mistake); + continue; + } + vo.setHouseStatus(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(16))){ + Integer isOk = PopulHousePurposeEnum.getCodeByName(oneData.get(16).trim()); + if(isOk.equals(-1)){ + index++; + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + setDisabilityMistake(oneData, mistake); + mistake.setMistake("您填写的房屋用途有误"); + mistakes.add(mistake); + continue; + } + vo.setHousePurpose(PopulHousePurposeEnum.getCodeByName(oneData.get(16).trim())); + } + if(StringUtils.isNotEmpty(oneData.get(17))){ + Integer isOk = PopulHouseControlStatusEnum.getCodeByName(oneData.get(17)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + setDisabilityMistake(oneData, mistake); + mistake.setMistake("您填写的管控状态有误"); + mistakes.add(mistake); + continue; + } + vo.setControlStatus(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(18))){ + Integer isOk = PopulOutOrLocalEnum.getCodeByName(oneData.get(18)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + setDisabilityMistake(oneData, mistake); + mistake.setMistake("您填写的本地/外地有误"); + mistakes.add(mistake); + continue; + } + vo.setOutOrLocal(isOk); + }else { + vo.setOutOrLocal(PopulOutOrLocalEnum.getCodeByName("本地")); + } + if(StringUtils.isNotEmpty(oneData.get(19))){ + vo.setCensusRegister(oneData.get(19).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(20))){ + vo.setRemark(oneData.get(20).trim()); + } + vo.getUserTagStr().add("残疾人"); + for (int i = 21; i < headSize; i++) { + if (oneData.get(i) != null && oneData.get(i).equals("是")) { + vo.getUserTagStr().add(headData.get(i).substring(0,headData.get(i).indexOf("("))); + } + } + //将重复的数据进行MD5加密实现去重 + String distinct = vo.getName() + vo.getCardNo() + vo.getRoad() + vo.getDoorNo() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo(); + try { + String distinctPass = PayUtil.MD5(distinct); + if(StringUtils.isNotEmpty(distinctPass)){ + vo.setDistinctPass(distinctPass); + } + }catch (Exception e){ + log.error("组装MD5加密字段失败,数据表格行数:" + index); + continue; + } + voList.add(vo); + index++; + } + //客户需要暂时注释,等客户处理完成需要恢复 +// if(populationImportErrorVOList.isEmpty()){ +// R r = communityService.listSavePopulationServeExcelVO(voList, communityId); +// if (!R.isOk(r)) { +// throw new ServiceException(r.getMsg()); +// } +// }else{ +// throw new ServiceException("500", JSON.toJSONString(populationImportErrorVOList)); +// } + //根据list中的IdCard城市来去重 + List<ComMngPopulationDisabilityExcelVO> newVoList = voList.stream().filter(ListUtils.distinctByKey(ComMngPopulationDisabilityExcelVO::getDistinctPass)).collect(Collectors.toList()); + log.info("开始进入业务层处理逻辑"); + R r = communityService.listSavePopulationDisabilityExcelVO(newVoList, communityId); + log.info("业务层处理逻辑完成"); + if (!R.isOk(r)) { + log.info("业务层处理成功"); + List<ComMngPopulationDisabilityMistakeExcelVO> list = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ComMngPopulationDisabilityMistakeExcelVO.class); +// String errMsg = r.getMsg(); +// List<ComMngPopulationImportErrorVO> errorList = JSON.parseArray(errMsg,ComMngPopulationImportErrorVO.class); +// if(!errorList.isEmpty()){ +// populationImportErrorVOList.addAll(errorList); +// } + mistakes.addAll(list); + log.info("将错误数据存入redis中"); + valueOperations.set(Disability,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); + log.info("将错误数据存入redis中成功"); + throw new ServiceException("500", Disability); + }else{ + log.info("业务层处理逻辑失败"); + if(!mistakes.isEmpty()){ + log.info("业务层处理逻辑失败,将错误数据缓存到redis中"); + valueOperations.set(Disability,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); + log.info("业务层处理逻辑失败,将错误数据缓存到redis中成功"); + throw new ServiceException("500", Disability); + } + } + } catch (NumberFormatException e) { + log.info("处理数据时失败"); + e.printStackTrace(); +// List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); +// ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); +// importErrorVO.setErrorPosition("第" + index + "行"); +// importErrorVO.setErrorMsg("数据格式有误,请检查文档内数据"); +// populationImportErrorVOList.add(importErrorVO); + log.error("数据格式有误,第" + index + "行"); + throw new ServiceException("500", "导入失败111"); + } + } + + private void setDisabilityMistake(Map<Integer, String> map, ComMngPopulationDisabilityMistakeExcelVO vo){ + vo.setSerialNumber(map.get(0)); + vo.setName(map.get(1)); + vo.setCardNo(map.get(2)); + vo.setCertificateSituation(map.get(3)); + vo.setCultureLevel(map.get(4)); + vo.setNation(map.get(5)); + vo.setDisType(map.get(6)); + vo.setDisLevel(map.get(7)); + vo.setPhone(map.get(8)); + vo.setRoad(map.get(9)); + vo.setDoorNo(map.get(10)); + vo.setFloor(map.get(11)); + vo.setUnitNo(map.get(12)); + vo.setHouseNo(map.get(13)); + vo.setIsRent(map.get(14)); + vo.setHouseStatus(map.get(15)); + vo.setHousePurpose(map.get(16)); + vo.setControlStatus(map.get(17)); + vo.setOutOrLocal(map.get(18)); + vo.setCensusRegister(map.get(19)); + vo.setRemark(map.get(20)); + } + + private String convertMarriage(String ma) { + + if(Objects.equals("已",ma) || Objects.equals("一",ma)){ + ma = "已婚"; + }else if(Objects.equals("未",ma) || Objects.equals("未婚婚",ma)){ + ma = "未婚"; + }else if(Objects.equals("初",ma)){ + ma = "初婚"; + }else if(Objects.equals("再",ma)){ + ma = "再婚"; + }else if(Objects.equals("复",ma)){ + ma = "复婚"; + }else if(Objects.equals("丧",ma) || Objects.equals("丧偶偶",ma)){ + ma = "丧偶"; + }else if(Objects.equals("离",ma) || Objects.equals("离异",ma) || Objects.equals("离异婚",ma)){ + ma = "离婚"; + }else if(Objects.equals("分",ma)){ + ma = "分居"; + } + + return ma; + } + + private String convertRelation(String ra) { + if(ra.contains("户主")){ + ra = "户主"; + }else if(Objects.equals(ra,"女儿")){ + ra = "女"; + }else if(Objects.equals(ra,"儿子") || Objects.equals(ra,"儿")){ + ra = "子"; + }else if(Objects.equals(ra,"大女")){ + ra = "长女"; + }else if(Objects.equals(ra,"二女") || Objects.equals(ra,"此女")){ + ra = "次女"; + }else if(Objects.equals(ra,"二子")){ + ra = "次子"; + }else if(Objects.equals(ra,"长男") || ra.contains("长子")){ + ra = "长子"; + }else if(Objects.equals(ra,"非亲属") || ra.contains("女友") || ra.contains("女朋友") + || ra.contains("男友") || ra.contains("男朋友")){ + ra = "其他"; + }else if(Objects.equals(ra,"姐")){ + ra = "姐姐"; + }else if(Objects.equals(ra,"户主")){ + ra = "本人"; + }else if(Objects.equals(ra,"妻子") || Objects.equals(ra,"媳妇")){ + ra = "妻"; + }else if(Objects.equals(ra,"哥") || Objects.equals(ra,"哥哥")){ + ra = "兄"; + }else if(Objects.equals(ra,"丈夫")){ + ra = "夫"; + }else if(Objects.equals(ra,"丈母娘")){ + ra = "岳母"; + }else if(Objects.equals(ra,"继子") || Objects.equals(ra,"养子")){ + ra = "养子或继子"; + }else if(Objects.equals(ra,"继女") || Objects.equals(ra,"养女")){ + ra = "养女或继女"; + }else if(ra.contains("儿媳")||ra.contains("长媳")){ + ra = "儿媳"; + }else if(Objects.equals(ra,"三姨") || Objects.equals(ra,"姨姨")){ + ra = "姨母"; + }else if(Objects.equals(ra,"二外孙女")){ + ra = "外孙女"; + }else if(Objects.equals(ra,"外孙")){ + ra = "外孙子"; + }else if(Objects.equals(ra,"侄儿")){ + ra = "侄子"; + }else if(ra.contains("表")){ + ra = "表兄弟、表姐妹"; + }else if(Objects.equals(ra,"继父") || Objects.equals(ra,"养父")){ + ra = "继父或养父"; + }else if(Objects.equals(ra,"父")){ + ra = "父亲"; + }else if(Objects.equals(ra,"弟弟")){ + ra = "弟"; + }else if(Objects.equals(ra,"孙")){ + ra = "孙子"; + }else if(Objects.equals(ra,"孙媳妇") || Objects.equals(ra,"外孙媳妇")){ + ra = "孙媳妇或外孙媳妇"; + }else if(Objects.equals(ra,"妹")){ + ra = "妹妹"; + }else if(Objects.equals(ra,"祖父母")){ + ra = "祖父母或外祖父母"; + }else if(Objects.equals(ra,"姐妹") || Objects.equals(ra,"兄弟")){ + ra = "兄弟姐妹"; + }else if(Objects.equals(ra,"其他姐妹") || Objects.equals(ra,"其他兄弟")){ + ra = "其他兄弟姐妹"; + }else if(Objects.equals(ra,"奶奶")){ + ra = "祖母"; + }else if(Objects.equals(ra,"爷爷")){ + ra = "祖父"; + }else if(Objects.equals(ra,"爷爷")){ + ra = "祖父"; + }else if(ra.contains("堂")){ + ra = "堂兄弟、堂姐妹"; + } + + return ra; + } +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationKeyExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationKeyExcelListen.java new file mode 100644 index 0000000..7697b6f --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationKeyExcelListen.java @@ -0,0 +1,548 @@ +package com.panzhihua.common.listen; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; +import com.alibaba.fastjson.JSONArray; +import com.google.common.collect.Lists; +import com.panzhihua.common.constants.BcDictionaryConstants; +import com.panzhihua.common.constants.Constants; +import com.panzhihua.common.enums.*; +import com.panzhihua.common.excel.CustomSheetWriteHandler; +import com.panzhihua.common.exceptions.ServiceException; +import com.panzhihua.common.model.vos.BcDictionaryVO; +import com.panzhihua.common.model.vos.R; +import com.panzhihua.common.model.vos.community.ComMngPopulationMistakeExcelVO; +import com.panzhihua.common.model.vos.community.ComMngPopulationKeyExcelVO; +import com.panzhihua.common.model.vos.community.ComMngPopulationKeyMistakeExcelVO; +import com.panzhihua.common.service.community.CommunityService; +import com.panzhihua.common.utlis.ListUtils; +import com.panzhihua.common.utlis.PayUtil; +import com.panzhihua.common.utlis.SFTPUtil; +import com.panzhihua.common.utlis.StringUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.core.ValueOperations; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * @description: 重点上访人员导入监听 + * @author: txb + */ +@Slf4j +public class ComMngPopulationKeyExcelListen extends AnalysisEventListener<Map<Integer, String>> { + private CommunityService communityService; + + private Long communityId; + + private static int headSize = 0; + + private Map<Integer, String> headData; + + private String userName; + // FTP 登录密码 + private String password; + // FTP 服务器地址IP地址 + private String host; + // FTP 端口 + private int port; + private String excelUrl; + + private StringRedisTemplate stringRedisTemplate; + + public static String loadUrl; + + public ComMngPopulationKeyExcelListen(CommunityService communityService, Long communityId, String userName, String password, String host, int port, String excelUrl, StringRedisTemplate stringRedisTemplate) { + this.communityService = communityService; + this.communityId = communityId; + this.userName = userName; + this.password = password; + this.host = host; + this.port = port; + this.excelUrl = excelUrl; + this.stringRedisTemplate = stringRedisTemplate; + } + + /** + * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + */ + private static final int BATCH_COUNT = 5000; + List<Map<Integer, String>> list = new ArrayList<Map<Integer, String>>(); + + @Override + public void invoke(Map<Integer, String> data, AnalysisContext context) { + list.add(data); + if (list.size() >= BATCH_COUNT) { + saveData(); + list.clear(); + } + } + + /** + * 这里会一行行的返回头 + * + * @param headMap + * @param context + */ + @Override + public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { + headSize = headMap.size(); + headData = headMap; + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + saveData(); + log.info("所有数据解析完成!"); + } + + /** + * 不是固定的列只能手动处理 + */ + private void saveData() { + R<List<BcDictionaryVO>> dictionaryR = communityService.listDictionaryByKey(BcDictionaryConstants.FAMILY); + log.info("开始导入重点上访人员数据"); + log.info("表格总数据:" + list.size()); + if (list.size() == 0) { + throw new ServiceException("500", "导入数据为空!"); + } + ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); + String key = Constants.KEY_POPULATION_ERROR_LIST + communityId; + + Map<String,String> dictMap = dictionaryR.getData().stream().collect(Collectors.toMap(BcDictionaryVO::getDictName,BcDictionaryVO::getDictValue)); +// Map<String,Integer> dictMap = new HashMap<>(); +// for(BcDictionaryVO vo : dictionaryR.getData()){ +// dictMap.put(vo.getDictName(),Integer.valueOf(vo.getDictValue())); +// } + + + int index = 2; + try { + ArrayList<ComMngPopulationKeyExcelVO> voList = Lists.newArrayList(); +// List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); + ArrayList<ComMngPopulationKeyMistakeExcelVO> mistakes = Lists.newArrayList(); + for (Map<Integer, String> oneData : list) { + ComMngPopulationKeyExcelVO vo = new ComMngPopulationKeyExcelVO(); + if (StringUtils.isNotEmpty(oneData.get(0))){ + vo.setSerialNumber(oneData.get(0)); + } + //姓名和身份证都为空,为空户,无需操作,否则就解析年龄,性别,出生年月日 + if(StringUtils.isNotEmpty(oneData.get(1)) || StringUtils.isNotEmpty(oneData.get(3))){ + if(StringUtils.isEmpty(oneData.get(1))){ + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + index++; + setKeyMistake(oneData, mistake); + mistake.setMistake("名字不可为空,请填写姓名"); + mistakes.add(mistake); + continue; + } + vo.setName(oneData.get(1)); + if(StringUtils.isEmpty(oneData.get(3))){ + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + index++; + setKeyMistake(oneData, mistake); + mistake.setMistake("身份证号不可为空,请填写身份证"); + mistakes.add(mistake); + continue; + } + + //判断身份证号码位数 + if(oneData.get(3).length() != 18){ + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + index++; + setKeyMistake(oneData, mistake); + mistake.setMistake("身份证号位数有误,请检查身份证号码是否正确"); + mistakes.add(mistake); + continue; + } + vo.setCardNo(oneData.get(3).toUpperCase()); + //根据身份证号码解析年龄以及性别 + //获取用户生日 + String birthday = vo.getCardNo().substring(6, 14); + if(StringUtils.isNotEmpty(birthday)){ + String year = birthday.substring(0,4); + String month = birthday.substring(4,6); + String day = birthday.substring(6,8); + vo.setBirthday(year + "-" + month + "-" + day); + } +// //设置用户年龄 +// vo.setAge(AgeUtils.getAgeFromBirthTime(birthday)); + //获取用户性别 + int sex = Integer.parseInt(vo.getCardNo().substring(16, 17)); + if(sex%2 == 1){ + vo.setSex(PopulSexEnum.nan.getCode()); + }else{ + vo.setSex(PopulSexEnum.nv.getCode()); + } + } + if(StringUtils.isNotEmpty(oneData.get(2))){ + vo.setNation(oneData.get(2)); + } + if(StringUtils.isNotEmpty(oneData.get(4))){ + vo.setPhone(oneData.get(4)); + } + if(StringUtils.isNotEmpty(oneData.get(5))){ + vo.setNativePlace(oneData.get(5)); + } + if(StringUtils.isEmpty(oneData.get(6))){ + index++; + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + setKeyMistake(oneData, mistake); + mistake.setMistake("街路巷不可为空"); + mistakes.add(mistake); + continue; + } + vo.setRoad(oneData.get(6)); + if(StringUtils.isEmpty(oneData.get(7))){ + index++; + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + setKeyMistake(oneData, mistake); + mistake.setMistake("小区号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setDoorNo(oneData.get(7).trim()); + if(StringUtils.isEmpty(oneData.get(8))){ + index++; + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + setKeyMistake(oneData, mistake); + mistake.setMistake("楼排号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setFloor(oneData.get(8).trim()); + if(StringUtils.isEmpty(oneData.get(9))){ + index++; + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + setKeyMistake(oneData, mistake); + mistake.setMistake("单元号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setUnitNo(oneData.get(9).trim()); + if(StringUtils.isEmpty(oneData.get(10))){ + index++; + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + setKeyMistake(oneData, mistake); + mistake.setMistake("户室不可为空"); + mistakes.add(mistake); + continue; + } + vo.setHouseNo(oneData.get(10).trim()); + if(StringUtils.isNotEmpty(oneData.get(11))){ + Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(11)); + if(isOk.equals(-1)){ + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + index++; + setKeyMistake(oneData, mistake); + mistake.setMistake("您填写的是否租住有误"); + mistakes.add(mistake); + continue; + } + vo.setIsRent(isOk); + }else { + vo.setIsRent(PopulHouseUseEnum.getCodeByName("否")); + } + if(StringUtils.isNotEmpty(oneData.get(12))){ + Integer isOk = PopulHouseStatusEnum.getCodeByName(oneData.get(12).trim()); + if(isOk.equals(-1)){ + index++; + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + setKeyMistake(oneData, mistake); + mistake.setMistake("您填写的房屋状态有误"); + mistakes.add(mistake); + continue; + } + vo.setHouseStatus(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(13))){ + Integer isOk = PopulHousePurposeEnum.getCodeByName(oneData.get(13).trim()); + if(isOk.equals(-1)){ + index++; + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + setKeyMistake(oneData, mistake); + mistake.setMistake("您填写的房屋用途有误"); + mistakes.add(mistake); + continue; + } + vo.setHousePurpose(PopulHousePurposeEnum.getCodeByName(oneData.get(13).trim())); + } + if(StringUtils.isNotEmpty(oneData.get(14))){ + Integer isOk = PopulHouseControlStatusEnum.getCodeByName(oneData.get(14)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + setKeyMistake(oneData, mistake); + mistake.setMistake("您填写的管控状态有误"); + mistakes.add(mistake); + continue; + } + vo.setControlStatus(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(15))){ + Integer isOk = PopulOutOrLocalEnum.getCodeByName(oneData.get(15)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + setKeyMistake(oneData, mistake); + mistake.setMistake("您填写的本地/外地有误"); + mistakes.add(mistake); + continue; + } + vo.setOutOrLocal(isOk); + }else { + vo.setOutOrLocal(PopulOutOrLocalEnum.getCodeByName("本地")); + } + if(StringUtils.isNotEmpty(oneData.get(16))){ + vo.setCensusRegister(oneData.get(16).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(17))){ + vo.setRemark(oneData.get(17).trim()); + } + vo.getUserTagStr().add("重点上访人员"); + for (int i = 18; i < headSize; i++) { + if (oneData.get(i) != null && oneData.get(i).equals("是")) { + vo.getUserTagStr().add(headData.get(i).substring(0,headData.get(i).indexOf("("))); + } + } + //将重复的数据进行MD5加密实现去重 + String distinct = vo.getName() + vo.getCardNo() + vo.getRoad() + vo.getDoorNo() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo(); + try { + String distinctPass = PayUtil.MD5(distinct); + if(StringUtils.isNotEmpty(distinctPass)){ + vo.setDistinctPass(distinctPass); + } + }catch (Exception e){ + log.error("组装MD5加密字段失败,数据表格行数:" + index); + continue; + } + voList.add(vo); + index++; + } + //客户需要暂时注释,等客户处理完成需要恢复 +// if(populationImportErrorVOList.isEmpty()){ +// R r = communityService.listSavePopulationServeExcelVO(voList, communityId); +// if (!R.isOk(r)) { +// throw new ServiceException(r.getMsg()); +// } +// }else{ +// throw new ServiceException("500", JSON.toJSONString(populationImportErrorVOList)); +// } + //根据list中的IdCard城市来去重 + List<ComMngPopulationKeyExcelVO> newVoList = voList.stream().filter(ListUtils.distinctByKey(ComMngPopulationKeyExcelVO::getDistinctPass)).collect(Collectors.toList()); + log.info("开始进入业务层处理逻辑"); + R r = communityService.listSavePopulationKeyExcelVO(newVoList, communityId); + log.info("业务层处理逻辑完成"); + if (!R.isOk(r)) { + log.info("业务层处理成功"); + List<ComMngPopulationKeyMistakeExcelVO> list = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ComMngPopulationKeyMistakeExcelVO.class); +// String errMsg = r.getMsg(); +// List<ComMngPopulationImportErrorVO> errorList = JSON.parseArray(errMsg,ComMngPopulationImportErrorVO.class); +// if(!errorList.isEmpty()){ +// populationImportErrorVOList.addAll(errorList); +// } + mistakes.addAll(list); + log.info("将错误数据存入redis中"); + valueOperations.set(key,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); + log.info("将错误数据存入redis中成功"); + throw new ServiceException("500", key); + }else{ + log.info("业务层处理逻辑失败"); + if(!mistakes.isEmpty()){ + log.info("业务层处理逻辑失败,将错误数据缓存到redis中"); + valueOperations.set(key,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); + log.info("业务层处理逻辑失败,将错误数据缓存到redis中成功"); + throw new ServiceException("500", key); + } + } + } catch (NumberFormatException e) { + log.info("处理数据时失败"); + e.printStackTrace(); +// List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); +// ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); +// importErrorVO.setErrorPosition("第" + index + "行"); +// importErrorVO.setErrorMsg("数据格式有误,请检查文档内数据"); +// populationImportErrorVOList.add(importErrorVO); + log.error("数据格式有误,第" + index + "行"); + throw new ServiceException("500", "导入失败111"); + } + } + + private void setKeyMistake(Map<Integer, String> map, ComMngPopulationKeyMistakeExcelVO vo){ + vo.setSerialNumber(map.get(0)); + vo.setName(map.get(1)); + vo.setCardNo(map.get(3)); + vo.setNation(map.get(2)); + vo.setPhone(map.get(4)); + vo.setNativePlace(map.get(5)); + vo.setRoad(map.get(6)); + vo.setDoorNo(map.get(7)); + vo.setFloor(map.get(8)); + vo.setUnitNo(map.get(9)); + vo.setHouseNo(map.get(10)); + vo.setIsRent(map.get(11)); + vo.setHouseStatus(map.get(12)); + vo.setHousePurpose(map.get(13)); + vo.setControlStatus(map.get(14)); + vo.setOutOrLocal(map.get(15)); + vo.setCensusRegister(map.get(16)); + vo.setRemark(map.get(17)); + } + + private R mistakeExportPopulation(List<ComMngPopulationMistakeExcelVO> vo) { + //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 + String ftpUrl = "/mnt/data/web/excel/"; + String name = "实有人口错误数据.xlsx"; + try { + SFTPUtil sftp = new SFTPUtil(userName, password, host, port); + sftp.login(); + boolean existDir = sftp.isExistDir(ftpUrl + name); + if (!existDir) { + String property = System.getProperty("user.dir"); + String fileName = property + File.separator + name; + // 这里 需要指定写用哪个class去写 + ExcelWriter excelWriter = null; + InputStream inputStream = null; + try { + excelWriter = EasyExcel.write(fileName, ComMngPopulationMistakeExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("实有人口错误数据").build(); + excelWriter.write(vo, writeSheet); + excelWriter.finish(); + File file = new File(fileName); + inputStream = new FileInputStream(file); + sftp.uploadMore(ftpUrl, name, inputStream); + sftp.logout(); + inputStream.close(); + String absolutePath = file.getAbsolutePath(); + boolean delete = file.delete(); + log.info("删除excel【{}】结果【{}】", absolutePath, delete); + } finally { + // 千万别忘记finish 会帮忙关闭流 + if (inputStream != null) { + inputStream.close(); + } + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + return R.ok(excelUrl + name); + } catch (Exception e) { + e.printStackTrace(); + log.error("文件传输失败【{}】", e.getMessage()); + return R.fail(); + } + } + + private String convertMarriage(String ma) { + + if(Objects.equals("已",ma) || Objects.equals("一",ma)){ + ma = "已婚"; + }else if(Objects.equals("未",ma) || Objects.equals("未婚婚",ma)){ + ma = "未婚"; + }else if(Objects.equals("初",ma)){ + ma = "初婚"; + }else if(Objects.equals("再",ma)){ + ma = "再婚"; + }else if(Objects.equals("复",ma)){ + ma = "复婚"; + }else if(Objects.equals("丧",ma) || Objects.equals("丧偶偶",ma)){ + ma = "丧偶"; + }else if(Objects.equals("离",ma) || Objects.equals("离异",ma) || Objects.equals("离异婚",ma)){ + ma = "离婚"; + }else if(Objects.equals("分",ma)){ + ma = "分居"; + } + + return ma; + } + + private String convertRelation(String ra) { + if(ra.contains("户主")){ + ra = "户主"; + }else if(Objects.equals(ra,"女儿")){ + ra = "女"; + }else if(Objects.equals(ra,"儿子") || Objects.equals(ra,"儿")){ + ra = "子"; + }else if(Objects.equals(ra,"大女")){ + ra = "长女"; + }else if(Objects.equals(ra,"二女") || Objects.equals(ra,"此女")){ + ra = "次女"; + }else if(Objects.equals(ra,"二子")){ + ra = "次子"; + }else if(Objects.equals(ra,"长男") || ra.contains("长子")){ + ra = "长子"; + }else if(Objects.equals(ra,"非亲属") || ra.contains("女友") || ra.contains("女朋友") + || ra.contains("男友") || ra.contains("男朋友")){ + ra = "其他"; + }else if(Objects.equals(ra,"姐")){ + ra = "姐姐"; + }else if(Objects.equals(ra,"户主")){ + ra = "本人"; + }else if(Objects.equals(ra,"妻子") || Objects.equals(ra,"媳妇")){ + ra = "妻"; + }else if(Objects.equals(ra,"哥") || Objects.equals(ra,"哥哥")){ + ra = "兄"; + }else if(Objects.equals(ra,"丈夫")){ + ra = "夫"; + }else if(Objects.equals(ra,"丈母娘")){ + ra = "岳母"; + }else if(Objects.equals(ra,"继子") || Objects.equals(ra,"养子")){ + ra = "养子或继子"; + }else if(Objects.equals(ra,"继女") || Objects.equals(ra,"养女")){ + ra = "养女或继女"; + }else if(ra.contains("儿媳")||ra.contains("长媳")){ + ra = "儿媳"; + }else if(Objects.equals(ra,"三姨") || Objects.equals(ra,"姨姨")){ + ra = "姨母"; + }else if(Objects.equals(ra,"二外孙女")){ + ra = "外孙女"; + }else if(Objects.equals(ra,"外孙")){ + ra = "外孙子"; + }else if(Objects.equals(ra,"侄儿")){ + ra = "侄子"; + }else if(ra.contains("表")){ + ra = "表兄弟、表姐妹"; + }else if(Objects.equals(ra,"继父") || Objects.equals(ra,"养父")){ + ra = "继父或养父"; + }else if(Objects.equals(ra,"父")){ + ra = "父亲"; + }else if(Objects.equals(ra,"弟弟")){ + ra = "弟"; + }else if(Objects.equals(ra,"孙")){ + ra = "孙子"; + }else if(Objects.equals(ra,"孙媳妇") || Objects.equals(ra,"外孙媳妇")){ + ra = "孙媳妇或外孙媳妇"; + }else if(Objects.equals(ra,"妹")){ + ra = "妹妹"; + }else if(Objects.equals(ra,"祖父母")){ + ra = "祖父母或外祖父母"; + }else if(Objects.equals(ra,"姐妹") || Objects.equals(ra,"兄弟")){ + ra = "兄弟姐妹"; + }else if(Objects.equals(ra,"其他姐妹") || Objects.equals(ra,"其他兄弟")){ + ra = "其他兄弟姐妹"; + }else if(Objects.equals(ra,"奶奶")){ + ra = "祖母"; + }else if(Objects.equals(ra,"爷爷")){ + ra = "祖父"; + }else if(Objects.equals(ra,"爷爷")){ + ra = "祖父"; + }else if(ra.contains("堂")){ + ra = "堂兄弟、堂姐妹"; + } + + return ra; + } +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationMajorExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationMajorExcelListen.java index 1845c14..4d1c347 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationMajorExcelListen.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationMajorExcelListen.java @@ -18,6 +18,7 @@ import com.panzhihua.common.model.vos.community.ComMngPopulationMajorExcelVO; import com.panzhihua.common.model.vos.community.ComMngPopulationMajorMistakeExcelVO; import com.panzhihua.common.model.vos.community.ComMngPopulationMistakeExcelVO; +import com.panzhihua.common.model.vos.community.ComMngPopulationRehabilitationMistakeExcelVO; import com.panzhihua.common.service.community.CommunityService; import com.panzhihua.common.utlis.ListUtils; import com.panzhihua.common.utlis.PayUtil; @@ -121,7 +122,7 @@ throw new ServiceException("500", "导入数据为空!"); } ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); - String key = Constants.Major_POPULATION_ERROR_LIST + communityId; + String key = Constants.MAJOR_POPULATION_ERROR_LIST + communityId; Map<String,String> dictMap = dictionaryR.getData().stream().collect(Collectors.toMap(BcDictionaryVO::getDictName,BcDictionaryVO::getDictValue)); // Map<String,Integer> dictMap = new HashMap<>(); @@ -323,7 +324,16 @@ vo.setGuarDianPhone(oneData.get(17).trim()); } if(StringUtils.isNotEmpty(oneData.get(18))){ - vo.setPatientRelation(oneData.get(18).trim()); + Integer isOk = PopulRelationEnum.getCodeByName(oneData.get(18)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationMajorMistakeExcelVO mistake = new ComMngPopulationMajorMistakeExcelVO(); + setMistake(oneData, mistake); + mistake.setMistake("您填写的与患者关系有误"); + mistakes.add(mistake); + continue; + } + vo.setPatientRelation(isOk); } if(StringUtils.isNotEmpty(oneData.get(19))){ vo.setDiagnose(oneData.get(19).trim()); diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationRehabilitationExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationRehabilitationExcelListen.java new file mode 100644 index 0000000..c459757 --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationRehabilitationExcelListen.java @@ -0,0 +1,584 @@ +package com.panzhihua.common.listen; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; +import com.alibaba.fastjson.JSONArray; +import com.google.common.collect.Lists; +import com.panzhihua.common.constants.BcDictionaryConstants; +import com.panzhihua.common.constants.Constants; +import com.panzhihua.common.enums.*; +import com.panzhihua.common.excel.CustomSheetWriteHandler; +import com.panzhihua.common.exceptions.ServiceException; +import com.panzhihua.common.model.vos.BcDictionaryVO; +import com.panzhihua.common.model.vos.R; +import com.panzhihua.common.model.vos.community.ComMngPopulationRehabilitationExcelVO; +import com.panzhihua.common.model.vos.community.ComMngPopulationRehabilitationMistakeExcelVO; +import com.panzhihua.common.model.vos.community.ComMngPopulationMistakeExcelVO; +import com.panzhihua.common.service.community.CommunityService; +import com.panzhihua.common.utlis.ListUtils; +import com.panzhihua.common.utlis.PayUtil; +import com.panzhihua.common.utlis.SFTPUtil; +import com.panzhihua.common.utlis.StringUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.core.ValueOperations; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * @description: 刑释人员导入监听 + * @author: txb + */ +@Slf4j +public class ComMngPopulationRehabilitationExcelListen extends AnalysisEventListener<Map<Integer, String>> { + private CommunityService communityService; + + private Long communityId; + + private static int headSize = 0; + + private Map<Integer, String> headData; + + private String userName; + // FTP 登录密码 + private String password; + // FTP 服务器地址IP地址 + private String host; + // FTP 端口 + private int port; + private String excelUrl; + + private StringRedisTemplate stringRedisTemplate; + + public static String loadUrl; + + public ComMngPopulationRehabilitationExcelListen(CommunityService communityService, Long communityId, String userName, String password, String host, int port, String excelUrl, StringRedisTemplate stringRedisTemplate) { + this.communityService = communityService; + this.communityId = communityId; + this.userName = userName; + this.password = password; + this.host = host; + this.port = port; + this.excelUrl = excelUrl; + this.stringRedisTemplate = stringRedisTemplate; + } + + /** + * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + */ + private static final int BATCH_COUNT = 5000; + List<Map<Integer, String>> list = new ArrayList<Map<Integer, String>>(); + + @Override + public void invoke(Map<Integer, String> data, AnalysisContext context) { + list.add(data); + if (list.size() >= BATCH_COUNT) { + saveData(); + list.clear(); + } + } + + /** + * 这里会一行行的返回头 + * + * @param headMap + * @param context + */ + @Override + public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { + headSize = headMap.size(); + headData = headMap; + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + saveData(); + log.info("所有数据解析完成!"); + } + + /** + * 不是固定的列只能手动处理 + */ + private void saveData() { + R<List<BcDictionaryVO>> dictionaryR = communityService.listDictionaryByKey(BcDictionaryConstants.FAMILY); + log.info("开始导入刑释人员数据"); + log.info("表格总数据:" + list.size()); + if (list.size() == 0) { + throw new ServiceException("500", "导入数据为空!"); + } + ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); + String key = Constants.REHABILITATION_POPULATION_ERROR_LIST + communityId; + + Map<String,String> dictMap = dictionaryR.getData().stream().collect(Collectors.toMap(BcDictionaryVO::getDictName,BcDictionaryVO::getDictValue)); +// Map<String,Integer> dictMap = new HashMap<>(); +// for(BcDictionaryVO vo : dictionaryR.getData()){ +// dictMap.put(vo.getDictName(),Integer.valueOf(vo.getDictValue())); +// } + + + int index = 2; + try { + ArrayList<ComMngPopulationRehabilitationExcelVO> voList = Lists.newArrayList(); +// List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); + ArrayList<ComMngPopulationRehabilitationMistakeExcelVO> mistakes = Lists.newArrayList(); + for (Map<Integer, String> oneData : list) { + ComMngPopulationRehabilitationExcelVO vo = new ComMngPopulationRehabilitationExcelVO(); + if (StringUtils.isNotEmpty(oneData.get(0))){ + vo.setSerialNumber(oneData.get(0)); + } + //姓名和身份证都为空,为空户,无需操作,否则就解析年龄,性别,出生年月日 + if(StringUtils.isNotEmpty(oneData.get(1)) || StringUtils.isNotEmpty(oneData.get(3))){ + if(StringUtils.isEmpty(oneData.get(1))){ + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + index++; + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("名字不可为空,请填写姓名"); + mistakes.add(mistake); + continue; + } + vo.setName(oneData.get(1)); + if(StringUtils.isEmpty(oneData.get(3))){ + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + index++; + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("身份证号不可为空,请填写身份证"); + mistakes.add(mistake); + continue; + } + + //判断身份证号码位数 + if(oneData.get(3).length() != 18){ + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + index++; + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("身份证号位数有误,请检查身份证号码是否正确"); + mistakes.add(mistake); + continue; + } + vo.setCardNo(oneData.get(3).toUpperCase()); + //根据身份证号码解析年龄以及性别 + //获取用户生日 + String birthday = vo.getCardNo().substring(6, 14); + if(StringUtils.isNotEmpty(birthday)){ + String year = birthday.substring(0,4); + String month = birthday.substring(4,6); + String day = birthday.substring(6,8); + vo.setBirthday(year + "-" + month + "-" + day); + } +// //设置用户年龄 +// vo.setAge(AgeUtils.getAgeFromBirthTime(birthday)); + //获取用户性别 + int sex = Integer.parseInt(vo.getCardNo().substring(16, 17)); + if(sex%2 == 1){ + vo.setSex(PopulSexEnum.nan.getCode()); + }else{ + vo.setSex(PopulSexEnum.nv.getCode()); + } + } + if(StringUtils.isNotEmpty(oneData.get(2))){ + vo.setNation(oneData.get(2)); + } + if(StringUtils.isNotEmpty(oneData.get(4))){ + vo.setPhone(oneData.get(4)); + } + if(StringUtils.isNotEmpty(oneData.get(5))){ + vo.setNativePlace(oneData.get(5)); + } + if(StringUtils.isEmpty(oneData.get(6))){ + index++; + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("街路巷不可为空"); + mistakes.add(mistake); + continue; + } + vo.setRoad(oneData.get(6)); + if(StringUtils.isEmpty(oneData.get(7))){ + index++; + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("小区号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setDoorNo(oneData.get(7).trim()); + if(StringUtils.isEmpty(oneData.get(8))){ + index++; + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("楼排号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setFloor(oneData.get(8).trim()); + if(StringUtils.isEmpty(oneData.get(9))){ + index++; + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("单元号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setUnitNo(oneData.get(9).trim()); + if(StringUtils.isEmpty(oneData.get(10))){ + index++; + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("户室不可为空"); + mistakes.add(mistake); + continue; + } + vo.setHouseNo(oneData.get(10).trim()); + if(StringUtils.isNotEmpty(oneData.get(11))){ + Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(11)); + if(isOk.equals(-1)){ + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + index++; + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("您填写的是否租住有误"); + mistakes.add(mistake); + continue; + } + vo.setIsRent(isOk); + }else { + vo.setIsRent(PopulHouseUseEnum.getCodeByName("否")); + } + if(StringUtils.isNotEmpty(oneData.get(12))){ + Integer isOk = PopulHouseStatusEnum.getCodeByName(oneData.get(12).trim()); + if(isOk.equals(-1)){ + index++; + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("您填写的房屋状态有误"); + mistakes.add(mistake); + continue; + } + vo.setHouseStatus(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(13))){ + Integer isOk = PopulHousePurposeEnum.getCodeByName(oneData.get(13).trim()); + if(isOk.equals(-1)){ + index++; + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("您填写的房屋用途有误"); + mistakes.add(mistake); + continue; + } + vo.setHousePurpose(PopulHousePurposeEnum.getCodeByName(oneData.get(13).trim())); + } + if(StringUtils.isNotEmpty(oneData.get(14))){ + Integer isOk = PopulHouseControlStatusEnum.getCodeByName(oneData.get(14)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("您填写的管控状态有误"); + mistakes.add(mistake); + continue; + } + vo.setControlStatus(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(15))){ + Integer isOk = PopulOutOrLocalEnum.getCodeByName(oneData.get(15)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("您填写的本地/外地有误"); + mistakes.add(mistake); + continue; + } + vo.setOutOrLocal(isOk); + }else { + vo.setOutOrLocal(PopulOutOrLocalEnum.getCodeByName("本地")); + } + if(StringUtils.isNotEmpty(oneData.get(16))){ + vo.setCensusRegister(oneData.get(16).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(17))){ + vo.setMainRelatives(oneData.get(17).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(18))){ + Integer isOk = PopulRelationEnum.getCodeByName(oneData.get(18)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("您填写的与人员关系有误"); + mistakes.add(mistake); + continue; + } + vo.setPatientRelation(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(19))){ + vo.setRehabReasonAndType(oneData.get(19).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(20))){ + Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(20)); + if(isOk.equals(-1)){ + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + index++; + setRehabilitationMistake(oneData, mistake); + mistake.setMistake("您填写的是否列管有误"); + mistakes.add(mistake); + continue; + } + vo.setIsRehab(isOk); + }else { + vo.setIsRehab(PopulHouseUseEnum.getCodeByName("否")); + } + if(StringUtils.isNotEmpty(oneData.get(21))){ + vo.setRemark(oneData.get(21).trim()); + } + vo.getUserTagStr().add("刑满释放"); + for (int i = 22; i < headSize; i++) { + if (oneData.get(i) != null && oneData.get(i).equals("是")) { + vo.getUserTagStr().add(headData.get(i).substring(0,headData.get(i).indexOf("("))); + } + } + //将重复的数据进行MD5加密实现去重 + String distinct = vo.getName() + vo.getCardNo() + vo.getRoad() + vo.getDoorNo() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo(); + try { + String distinctPass = PayUtil.MD5(distinct); + if(StringUtils.isNotEmpty(distinctPass)){ + vo.setDistinctPass(distinctPass); + } + }catch (Exception e){ + log.error("组装MD5加密字段失败,数据表格行数:" + index); + continue; + } + voList.add(vo); + index++; + } + //客户需要暂时注释,等客户处理完成需要恢复 +// if(populationImportErrorVOList.isEmpty()){ +// R r = communityService.listSavePopulationServeExcelVO(voList, communityId); +// if (!R.isOk(r)) { +// throw new ServiceException(r.getMsg()); +// } +// }else{ +// throw new ServiceException("500", JSON.toJSONString(populationImportErrorVOList)); +// } + //根据list中的IdCard城市来去重 + List<ComMngPopulationRehabilitationExcelVO> newVoList = voList.stream().filter(ListUtils.distinctByKey(ComMngPopulationRehabilitationExcelVO::getDistinctPass)).collect(Collectors.toList()); + log.info("开始进入业务层处理逻辑"); + R r = communityService.listSavePopulationRehabilitationExcelVO(newVoList, communityId); + log.info("业务层处理逻辑完成"); + if (!R.isOk(r)) { + log.info("业务层处理成功"); + List<ComMngPopulationRehabilitationMistakeExcelVO> list = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ComMngPopulationRehabilitationMistakeExcelVO.class); +// String errMsg = r.getMsg(); +// List<ComMngPopulationImportErrorVO> errorList = JSON.parseArray(errMsg,ComMngPopulationImportErrorVO.class); +// if(!errorList.isEmpty()){ +// populationImportErrorVOList.addAll(errorList); +// } + mistakes.addAll(list); + log.info("将错误数据存入redis中"); + valueOperations.set(key,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); + log.info("将错误数据存入redis中成功"); + throw new ServiceException("500", key); + }else{ + log.info("业务层处理逻辑失败"); + if(!mistakes.isEmpty()){ + log.info("业务层处理逻辑失败,将错误数据缓存到redis中"); + valueOperations.set(key,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); + log.info("业务层处理逻辑失败,将错误数据缓存到redis中成功"); + throw new ServiceException("500", key); + } + } + } catch (NumberFormatException e) { + log.info("处理数据时失败"); + e.printStackTrace(); +// List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); +// ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); +// importErrorVO.setErrorPosition("第" + index + "行"); +// importErrorVO.setErrorMsg("数据格式有误,请检查文档内数据"); +// populationImportErrorVOList.add(importErrorVO); + log.error("数据格式有误,第" + index + "行"); + throw new ServiceException("500", "导入失败111"); + } + } + + private void setRehabilitationMistake(Map<Integer, String> map, ComMngPopulationRehabilitationMistakeExcelVO vo){ + vo.setSerialNumber(map.get(0)); + vo.setName(map.get(1)); + vo.setCardNo(map.get(3)); + vo.setNation(map.get(2)); + vo.setPhone(map.get(4)); + vo.setNativePlace(map.get(5)); + vo.setRoad(map.get(6)); + vo.setDoorNo(map.get(7)); + vo.setFloor(map.get(8)); + vo.setUnitNo(map.get(9)); + vo.setHouseNo(map.get(10)); + vo.setIsRent(map.get(11)); + vo.setHouseStatus(map.get(12)); + vo.setHousePurpose(map.get(13)); + vo.setControlStatus(map.get(14)); + vo.setOutOrLocal(map.get(15)); + vo.setCensusRegister(map.get(16)); + vo.setMainRelatives(map.get(17)); + vo.setPatientRelation(map.get(18)); + vo.setRehabReasonAndType(map.get(19)); + vo.setIsRehab(map.get(20)); + vo.setRemark(map.get(21)); + } + + private R mistakeExportPopulation(List<ComMngPopulationMistakeExcelVO> vo) { + //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 + String ftpUrl = "/mnt/data/web/excel/"; + String name = "实有人口错误数据.xlsx"; + try { + SFTPUtil sftp = new SFTPUtil(userName, password, host, port); + sftp.login(); + boolean existDir = sftp.isExistDir(ftpUrl + name); + if (!existDir) { + String property = System.getProperty("user.dir"); + String fileName = property + File.separator + name; + // 这里 需要指定写用哪个class去写 + ExcelWriter excelWriter = null; + InputStream inputStream = null; + try { + excelWriter = EasyExcel.write(fileName, ComMngPopulationMistakeExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("实有人口错误数据").build(); + excelWriter.write(vo, writeSheet); + excelWriter.finish(); + File file = new File(fileName); + inputStream = new FileInputStream(file); + sftp.uploadMore(ftpUrl, name, inputStream); + sftp.logout(); + inputStream.close(); + String absolutePath = file.getAbsolutePath(); + boolean delete = file.delete(); + log.info("删除excel【{}】结果【{}】", absolutePath, delete); + } finally { + // 千万别忘记finish 会帮忙关闭流 + if (inputStream != null) { + inputStream.close(); + } + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + return R.ok(excelUrl + name); + } catch (Exception e) { + e.printStackTrace(); + log.error("文件传输失败【{}】", e.getMessage()); + return R.fail(); + } + } + + private String convertMarriage(String ma) { + + if(Objects.equals("已",ma) || Objects.equals("一",ma)){ + ma = "已婚"; + }else if(Objects.equals("未",ma) || Objects.equals("未婚婚",ma)){ + ma = "未婚"; + }else if(Objects.equals("初",ma)){ + ma = "初婚"; + }else if(Objects.equals("再",ma)){ + ma = "再婚"; + }else if(Objects.equals("复",ma)){ + ma = "复婚"; + }else if(Objects.equals("丧",ma) || Objects.equals("丧偶偶",ma)){ + ma = "丧偶"; + }else if(Objects.equals("离",ma) || Objects.equals("离异",ma) || Objects.equals("离异婚",ma)){ + ma = "离婚"; + }else if(Objects.equals("分",ma)){ + ma = "分居"; + } + + return ma; + } + + private String convertRelation(String ra) { + if(ra.contains("户主")){ + ra = "户主"; + }else if(Objects.equals(ra,"女儿")){ + ra = "女"; + }else if(Objects.equals(ra,"儿子") || Objects.equals(ra,"儿")){ + ra = "子"; + }else if(Objects.equals(ra,"大女")){ + ra = "长女"; + }else if(Objects.equals(ra,"二女") || Objects.equals(ra,"此女")){ + ra = "次女"; + }else if(Objects.equals(ra,"二子")){ + ra = "次子"; + }else if(Objects.equals(ra,"长男") || ra.contains("长子")){ + ra = "长子"; + }else if(Objects.equals(ra,"非亲属") || ra.contains("女友") || ra.contains("女朋友") + || ra.contains("男友") || ra.contains("男朋友")){ + ra = "其他"; + }else if(Objects.equals(ra,"姐")){ + ra = "姐姐"; + }else if(Objects.equals(ra,"户主")){ + ra = "本人"; + }else if(Objects.equals(ra,"妻子") || Objects.equals(ra,"媳妇")){ + ra = "妻"; + }else if(Objects.equals(ra,"哥") || Objects.equals(ra,"哥哥")){ + ra = "兄"; + }else if(Objects.equals(ra,"丈夫")){ + ra = "夫"; + }else if(Objects.equals(ra,"丈母娘")){ + ra = "岳母"; + }else if(Objects.equals(ra,"继子") || Objects.equals(ra,"养子")){ + ra = "养子或继子"; + }else if(Objects.equals(ra,"继女") || Objects.equals(ra,"养女")){ + ra = "养女或继女"; + }else if(ra.contains("儿媳")||ra.contains("长媳")){ + ra = "儿媳"; + }else if(Objects.equals(ra,"三姨") || Objects.equals(ra,"姨姨")){ + ra = "姨母"; + }else if(Objects.equals(ra,"二外孙女")){ + ra = "外孙女"; + }else if(Objects.equals(ra,"外孙")){ + ra = "外孙子"; + }else if(Objects.equals(ra,"侄儿")){ + ra = "侄子"; + }else if(ra.contains("表")){ + ra = "表兄弟、表姐妹"; + }else if(Objects.equals(ra,"继父") || Objects.equals(ra,"养父")){ + ra = "继父或养父"; + }else if(Objects.equals(ra,"父")){ + ra = "父亲"; + }else if(Objects.equals(ra,"弟弟")){ + ra = "弟"; + }else if(Objects.equals(ra,"孙")){ + ra = "孙子"; + }else if(Objects.equals(ra,"孙媳妇") || Objects.equals(ra,"外孙媳妇")){ + ra = "孙媳妇或外孙媳妇"; + }else if(Objects.equals(ra,"妹")){ + ra = "妹妹"; + }else if(Objects.equals(ra,"祖父母")){ + ra = "祖父母或外祖父母"; + }else if(Objects.equals(ra,"姐妹") || Objects.equals(ra,"兄弟")){ + ra = "兄弟姐妹"; + }else if(Objects.equals(ra,"其他姐妹") || Objects.equals(ra,"其他兄弟")){ + ra = "其他兄弟姐妹"; + }else if(Objects.equals(ra,"奶奶")){ + ra = "祖母"; + }else if(Objects.equals(ra,"爷爷")){ + ra = "祖父"; + }else if(Objects.equals(ra,"爷爷")){ + ra = "祖父"; + }else if(ra.contains("堂")){ + ra = "堂兄弟、堂姐妹"; + } + + return ra; + } +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationSentenceExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationSentenceExcelListen.java new file mode 100644 index 0000000..e08b590 --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationSentenceExcelListen.java @@ -0,0 +1,535 @@ +package com.panzhihua.common.listen; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; +import com.alibaba.fastjson.JSONArray; +import com.google.common.collect.Lists; +import com.panzhihua.common.constants.BcDictionaryConstants; +import com.panzhihua.common.constants.Constants; +import com.panzhihua.common.enums.*; +import com.panzhihua.common.excel.CustomSheetWriteHandler; +import com.panzhihua.common.exceptions.ServiceException; +import com.panzhihua.common.model.vos.BcDictionaryVO; +import com.panzhihua.common.model.vos.R; +import com.panzhihua.common.model.vos.community.ComMngPopulationSentenceExcelVO; +import com.panzhihua.common.model.vos.community.ComMngPopulationSentenceMistakeExcelVO; +import com.panzhihua.common.model.vos.community.ComMngPopulationMistakeExcelVO; +import com.panzhihua.common.service.community.CommunityService; +import com.panzhihua.common.utlis.ListUtils; +import com.panzhihua.common.utlis.PayUtil; +import com.panzhihua.common.utlis.SFTPUtil; +import com.panzhihua.common.utlis.StringUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.core.ValueOperations; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * @description: 服刑人员导入监听 + * @author: txb + */ +@Slf4j +public class ComMngPopulationSentenceExcelListen extends AnalysisEventListener<Map<Integer, String>> { + private CommunityService communityService; + + private Long communityId; + + private static int headSize = 0; + + private Map<Integer, String> headData; + + private String userName; + // FTP 登录密码 + private String password; + // FTP 服务器地址IP地址 + private String host; + // FTP 端口 + private int port; + private String excelUrl; + + private StringRedisTemplate stringRedisTemplate; + + public static String loadUrl; + + public ComMngPopulationSentenceExcelListen(CommunityService communityService, Long communityId, String userName, String password, String host, int port, String excelUrl, StringRedisTemplate stringRedisTemplate) { + this.communityService = communityService; + this.communityId = communityId; + this.userName = userName; + this.password = password; + this.host = host; + this.port = port; + this.excelUrl = excelUrl; + this.stringRedisTemplate = stringRedisTemplate; + } + + /** + * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + */ + private static final int BATCH_COUNT = 5000; + List<Map<Integer, String>> list = new ArrayList<Map<Integer, String>>(); + + @Override + public void invoke(Map<Integer, String> data, AnalysisContext context) { + list.add(data); + if (list.size() >= BATCH_COUNT) { + saveData(); + list.clear(); + } + } + + /** + * 这里会一行行的返回头 + * + * @param headMap + * @param context + */ + @Override + public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { + headSize = headMap.size(); + headData = headMap; + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + saveData(); + log.info("所有数据解析完成!"); + } + + /** + * 不是固定的列只能手动处理 + */ + private void saveData() { + R<List<BcDictionaryVO>> dictionaryR = communityService.listDictionaryByKey(BcDictionaryConstants.FAMILY); + log.info("开始导入服刑人员数据"); + log.info("表格总数据:" + list.size()); + if (list.size() == 0) { + throw new ServiceException("500", "导入数据为空!"); + } + ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); + String Sentence = Constants.SENTENCE_POPULATION_ERROR_LIST + communityId; + + Map<String,String> dictMap = dictionaryR.getData().stream().collect(Collectors.toMap(BcDictionaryVO::getDictName,BcDictionaryVO::getDictValue)); +// Map<String,Integer> dictMap = new HashMap<>(); +// for(BcDictionaryVO vo : dictionaryR.getData()){ +// dictMap.put(vo.getDictName(),Integer.valueOf(vo.getDictValue())); +// } + + + int index = 2; + try { + ArrayList<ComMngPopulationSentenceExcelVO> voList = Lists.newArrayList(); +// List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); + ArrayList<ComMngPopulationSentenceMistakeExcelVO> mistakes = Lists.newArrayList(); + for (Map<Integer, String> oneData : list) { + ComMngPopulationSentenceExcelVO vo = new ComMngPopulationSentenceExcelVO(); + if (StringUtils.isNotEmpty(oneData.get(0))){ + vo.setSerialNumber(oneData.get(0)); + } + //姓名和身份证都为空,为空户,无需操作,否则就解析年龄,性别,出生年月日 + if(StringUtils.isNotEmpty(oneData.get(1)) || StringUtils.isNotEmpty(oneData.get(3))){ + if(StringUtils.isEmpty(oneData.get(1))){ + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + index++; + setSentenceMistake(oneData, mistake); + mistake.setMistake("名字不可为空,请填写姓名"); + mistakes.add(mistake); + continue; + } + vo.setName(oneData.get(1)); + if(StringUtils.isEmpty(oneData.get(3))){ + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + index++; + setSentenceMistake(oneData, mistake); + mistake.setMistake("身份证号不可为空,请填写身份证"); + mistakes.add(mistake); + continue; + } + + //判断身份证号码位数 + if(oneData.get(3).length() != 18){ + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + index++; + setSentenceMistake(oneData, mistake); + mistake.setMistake("身份证号位数有误,请检查身份证号码是否正确"); + mistakes.add(mistake); + continue; + } + vo.setCardNo(oneData.get(3).toUpperCase()); + //根据身份证号码解析年龄以及性别 + //获取用户生日 + String birthday = vo.getCardNo().substring(6, 14); + if(StringUtils.isNotEmpty(birthday)){ + String year = birthday.substring(0,4); + String month = birthday.substring(4,6); + String day = birthday.substring(6,8); + vo.setBirthday(year + "-" + month + "-" + day); + } +// //设置用户年龄 +// vo.setAge(AgeUtils.getAgeFromBirthTime(birthday)); + //获取用户性别 + int sex = Integer.parseInt(vo.getCardNo().substring(16, 17)); + if(sex%2 == 1){ + vo.setSex(PopulSexEnum.nan.getCode()); + }else{ + vo.setSex(PopulSexEnum.nv.getCode()); + } + } + if(StringUtils.isNotEmpty(oneData.get(2))){ + vo.setNation(oneData.get(2)); + } + if(StringUtils.isNotEmpty(oneData.get(4))){ + vo.setPhone(oneData.get(4)); + } + if(StringUtils.isNotEmpty(oneData.get(5))){ + vo.setSpouse(oneData.get(5)); + } + if(StringUtils.isNotEmpty(oneData.get(6))){ + vo.setProfession(oneData.get(6)); + } + if(StringUtils.isEmpty(oneData.get(7))){ + index++; + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + setSentenceMistake(oneData, mistake); + mistake.setMistake("街路巷不可为空"); + mistakes.add(mistake); + continue; + } + vo.setRoad(oneData.get(7)); + if(StringUtils.isEmpty(oneData.get(8))){ + index++; + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + setSentenceMistake(oneData, mistake); + mistake.setMistake("小区号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setDoorNo(oneData.get(8).trim()); + if(StringUtils.isEmpty(oneData.get(9))){ + index++; + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + setSentenceMistake(oneData, mistake); + mistake.setMistake("楼排号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setFloor(oneData.get(9).trim()); + if(StringUtils.isEmpty(oneData.get(10))){ + index++; + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + setSentenceMistake(oneData, mistake); + mistake.setMistake("单元号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setUnitNo(oneData.get(10).trim()); + if(StringUtils.isEmpty(oneData.get(11))){ + index++; + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + setSentenceMistake(oneData, mistake); + mistake.setMistake("户室不可为空"); + mistakes.add(mistake); + continue; + } + vo.setHouseNo(oneData.get(11).trim()); + if(StringUtils.isNotEmpty(oneData.get(12))){ + Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(12)); + if(isOk.equals(-1)){ + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + index++; + setSentenceMistake(oneData, mistake); + mistake.setMistake("您填写的是否租住有误"); + mistakes.add(mistake); + continue; + } + vo.setIsRent(isOk); + }else { + vo.setIsRent(PopulHouseUseEnum.getCodeByName("否")); + } + if(StringUtils.isNotEmpty(oneData.get(13))){ + Integer isOk = PopulHouseStatusEnum.getCodeByName(oneData.get(13).trim()); + if(isOk.equals(-1)){ + index++; + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + setSentenceMistake(oneData, mistake); + mistake.setMistake("您填写的房屋状态有误"); + mistakes.add(mistake); + continue; + } + vo.setHouseStatus(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(14))){ + Integer isOk = PopulHousePurposeEnum.getCodeByName(oneData.get(14).trim()); + if(isOk.equals(-1)){ + index++; + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + setSentenceMistake(oneData, mistake); + mistake.setMistake("您填写的房屋用途有误"); + mistakes.add(mistake); + continue; + } + vo.setHousePurpose(PopulHousePurposeEnum.getCodeByName(oneData.get(14).trim())); + } + if(StringUtils.isNotEmpty(oneData.get(15))){ + Integer isOk = PopulHouseControlStatusEnum.getCodeByName(oneData.get(15)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + setSentenceMistake(oneData, mistake); + mistake.setMistake("您填写的管控状态有误"); + mistakes.add(mistake); + continue; + } + vo.setControlStatus(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(16))){ + Integer isOk = PopulOutOrLocalEnum.getCodeByName(oneData.get(16)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + setSentenceMistake(oneData, mistake); + mistake.setMistake("您填写的本地/外地有误"); + mistakes.add(mistake); + continue; + } + vo.setOutOrLocal(isOk); + }else { + vo.setOutOrLocal(PopulOutOrLocalEnum.getCodeByName("本地")); + } + if(StringUtils.isNotEmpty(oneData.get(17))){ + vo.setCensusRegister(oneData.get(17).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(18))){ + vo.setSentencePlace(oneData.get(18).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(19))){ + vo.setSentenceBegin(new SimpleDateFormat("yyyy-MM-dd").parse(oneData.get(19))); + } + if(StringUtils.isNotEmpty(oneData.get(20))){ + vo.setSentenceEnd(new SimpleDateFormat("yyyy-MM-dd").parse(oneData.get(20))); + } + if(StringUtils.isNotEmpty(oneData.get(21))){ + vo.setCharge(oneData.get(21).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(22))){ + vo.setRemark(oneData.get(22).trim()); + } + vo.getUserTagStr().add("服刑人员"); + for (int i = 23; i < headSize; i++) { + if (oneData.get(i) != null && oneData.get(i).equals("是")) { + vo.getUserTagStr().add(headData.get(i).substring(0,headData.get(i).indexOf("("))); + } + } + //将重复的数据进行MD5加密实现去重 + String distinct = vo.getName() + vo.getCardNo() + vo.getRoad() + vo.getDoorNo() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo(); + try { + String distinctPass = PayUtil.MD5(distinct); + if(StringUtils.isNotEmpty(distinctPass)){ + vo.setDistinctPass(distinctPass); + } + }catch (Exception e){ + log.error("组装MD5加密字段失败,数据表格行数:" + index); + continue; + } + voList.add(vo); + index++; + } + //客户需要暂时注释,等客户处理完成需要恢复 +// if(populationImportErrorVOList.isEmpty()){ +// R r = communityService.listSavePopulationServeExcelVO(voList, communityId); +// if (!R.isOk(r)) { +// throw new ServiceException(r.getMsg()); +// } +// }else{ +// throw new ServiceException("500", JSON.toJSONString(populationImportErrorVOList)); +// } + //根据list中的IdCard城市来去重 + List<ComMngPopulationSentenceExcelVO> newVoList = voList.stream().filter(ListUtils.distinctByKey(ComMngPopulationSentenceExcelVO::getDistinctPass)).collect(Collectors.toList()); + log.info("开始进入业务层处理逻辑"); + R r = communityService.listSavePopulationSentenceExcelVO(newVoList, communityId); + log.info("业务层处理逻辑完成"); + if (!R.isOk(r)) { + log.info("业务层处理成功"); + List<ComMngPopulationSentenceMistakeExcelVO> list = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ComMngPopulationSentenceMistakeExcelVO.class); +// String errMsg = r.getMsg(); +// List<ComMngPopulationImportErrorVO> errorList = JSON.parseArray(errMsg,ComMngPopulationImportErrorVO.class); +// if(!errorList.isEmpty()){ +// populationImportErrorVOList.addAll(errorList); +// } + mistakes.addAll(list); + log.info("将错误数据存入redis中"); + valueOperations.set(Sentence,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); + log.info("将错误数据存入redis中成功"); + throw new ServiceException("500", Sentence); + }else{ + log.info("业务层处理逻辑失败"); + if(!mistakes.isEmpty()){ + log.info("业务层处理逻辑失败,将错误数据缓存到redis中"); + valueOperations.set(Sentence,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); + log.info("业务层处理逻辑失败,将错误数据缓存到redis中成功"); + throw new ServiceException("500", Sentence); + } + } + } catch (NumberFormatException e) { + log.info("处理数据时失败"); + e.printStackTrace(); +// List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); +// ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); +// importErrorVO.setErrorPosition("第" + index + "行"); +// importErrorVO.setErrorMsg("数据格式有误,请检查文档内数据"); +// populationImportErrorVOList.add(importErrorVO); + log.error("数据格式有误,第" + index + "行"); + throw new ServiceException("500", "导入失败111"); + } catch (ParseException e1) { + log.info("处理数据时失败2"); + e1.printStackTrace(); +// List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); +// ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); +// importErrorVO.setErrorPosition("第" + index + "行"); +// importErrorVO.setErrorMsg("数据格式有误,请检查文档内数据"); +// populationImportErrorVOList.add(importErrorVO); + log.error("数据格式有误,第" + index + "行"); + throw new ServiceException("500", "导入失败222"); + } + } + + private void setSentenceMistake(Map<Integer, String> map, ComMngPopulationSentenceMistakeExcelVO vo){ + vo.setSerialNumber(map.get(0)); + vo.setName(map.get(1)); + vo.setCardNo(map.get(3)); + vo.setNation(map.get(2)); + vo.setPhone(map.get(4)); + vo.setSpouse(map.get(5)); + vo.setProfession(map.get(6)); + vo.setRoad(map.get(7)); + vo.setDoorNo(map.get(8)); + vo.setFloor(map.get(9)); + vo.setUnitNo(map.get(10)); + vo.setHouseNo(map.get(11)); + vo.setIsRent(map.get(12)); + vo.setHouseStatus(map.get(13)); + vo.setHousePurpose(map.get(14)); + vo.setControlStatus(map.get(15)); + vo.setOutOrLocal(map.get(16)); + vo.setCensusRegister(map.get(17)); + vo.setSentencePlace(map.get(18)); + vo.setSentenceBegin(map.get(19)); + vo.setSentenceEnd(map.get(20)); + vo.setCharge(map.get(21)); + vo.setRemark(map.get(22)); + } + + private String convertMarriage(String ma) { + + if(Objects.equals("已",ma) || Objects.equals("一",ma)){ + ma = "已婚"; + }else if(Objects.equals("未",ma) || Objects.equals("未婚婚",ma)){ + ma = "未婚"; + }else if(Objects.equals("初",ma)){ + ma = "初婚"; + }else if(Objects.equals("再",ma)){ + ma = "再婚"; + }else if(Objects.equals("复",ma)){ + ma = "复婚"; + }else if(Objects.equals("丧",ma) || Objects.equals("丧偶偶",ma)){ + ma = "丧偶"; + }else if(Objects.equals("离",ma) || Objects.equals("离异",ma) || Objects.equals("离异婚",ma)){ + ma = "离婚"; + }else if(Objects.equals("分",ma)){ + ma = "分居"; + } + + return ma; + } + + private String convertRelation(String ra) { + if(ra.contains("户主")){ + ra = "户主"; + }else if(Objects.equals(ra,"女儿")){ + ra = "女"; + }else if(Objects.equals(ra,"儿子") || Objects.equals(ra,"儿")){ + ra = "子"; + }else if(Objects.equals(ra,"大女")){ + ra = "长女"; + }else if(Objects.equals(ra,"二女") || Objects.equals(ra,"此女")){ + ra = "次女"; + }else if(Objects.equals(ra,"二子")){ + ra = "次子"; + }else if(Objects.equals(ra,"长男") || ra.contains("长子")){ + ra = "长子"; + }else if(Objects.equals(ra,"非亲属") || ra.contains("女友") || ra.contains("女朋友") + || ra.contains("男友") || ra.contains("男朋友")){ + ra = "其他"; + }else if(Objects.equals(ra,"姐")){ + ra = "姐姐"; + }else if(Objects.equals(ra,"户主")){ + ra = "本人"; + }else if(Objects.equals(ra,"妻子") || Objects.equals(ra,"媳妇")){ + ra = "妻"; + }else if(Objects.equals(ra,"哥") || Objects.equals(ra,"哥哥")){ + ra = "兄"; + }else if(Objects.equals(ra,"丈夫")){ + ra = "夫"; + }else if(Objects.equals(ra,"丈母娘")){ + ra = "岳母"; + }else if(Objects.equals(ra,"继子") || Objects.equals(ra,"养子")){ + ra = "养子或继子"; + }else if(Objects.equals(ra,"继女") || Objects.equals(ra,"养女")){ + ra = "养女或继女"; + }else if(ra.contains("儿媳")||ra.contains("长媳")){ + ra = "儿媳"; + }else if(Objects.equals(ra,"三姨") || Objects.equals(ra,"姨姨")){ + ra = "姨母"; + }else if(Objects.equals(ra,"二外孙女")){ + ra = "外孙女"; + }else if(Objects.equals(ra,"外孙")){ + ra = "外孙子"; + }else if(Objects.equals(ra,"侄儿")){ + ra = "侄子"; + }else if(ra.contains("表")){ + ra = "表兄弟、表姐妹"; + }else if(Objects.equals(ra,"继父") || Objects.equals(ra,"养父")){ + ra = "继父或养父"; + }else if(Objects.equals(ra,"父")){ + ra = "父亲"; + }else if(Objects.equals(ra,"弟弟")){ + ra = "弟"; + }else if(Objects.equals(ra,"孙")){ + ra = "孙子"; + }else if(Objects.equals(ra,"孙媳妇") || Objects.equals(ra,"外孙媳妇")){ + ra = "孙媳妇或外孙媳妇"; + }else if(Objects.equals(ra,"妹")){ + ra = "妹妹"; + }else if(Objects.equals(ra,"祖父母")){ + ra = "祖父母或外祖父母"; + }else if(Objects.equals(ra,"姐妹") || Objects.equals(ra,"兄弟")){ + ra = "兄弟姐妹"; + }else if(Objects.equals(ra,"其他姐妹") || Objects.equals(ra,"其他兄弟")){ + ra = "其他兄弟姐妹"; + }else if(Objects.equals(ra,"奶奶")){ + ra = "祖母"; + }else if(Objects.equals(ra,"爷爷")){ + ra = "祖父"; + }else if(Objects.equals(ra,"爷爷")){ + ra = "祖父"; + }else if(ra.contains("堂")){ + ra = "堂兄弟、堂姐妹"; + } + + return ra; + } +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationVeteransExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationVeteransExcelListen.java new file mode 100644 index 0000000..008cc45 --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationVeteransExcelListen.java @@ -0,0 +1,725 @@ +package com.panzhihua.common.listen; + +import cn.hutool.core.date.DateUtil; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.alibaba.fastjson.JSONArray; +import com.google.common.collect.Lists; +import com.panzhihua.common.constants.BcDictionaryConstants; +import com.panzhihua.common.constants.Constants; +import com.panzhihua.common.enums.*; +import com.panzhihua.common.exceptions.ServiceException; +import com.panzhihua.common.model.vos.BcDictionaryVO; +import com.panzhihua.common.model.vos.R; +import com.panzhihua.common.model.vos.community.ComMngPopulationVeteransExcelVO; +import com.panzhihua.common.model.vos.community.ComMngPopulationVeteransMistakeExcelVO; +import com.panzhihua.common.model.vos.community.ComMngPopulationVeteransExcelVO; +import com.panzhihua.common.model.vos.community.ComMngPopulationVeteransMistakeExcelVO; +import com.panzhihua.common.service.community.CommunityService; +import com.panzhihua.common.utlis.ListUtils; +import com.panzhihua.common.utlis.PayUtil; +import com.panzhihua.common.utlis.StringUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.core.ValueOperations; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * @description: 退役军人导入监听 + * @author: txb + */ +@Slf4j +public class ComMngPopulationVeteransExcelListen extends AnalysisEventListener<Map<Integer, String>> { + private CommunityService communityService; + + private Long communityId; + + private static int headSize = 0; + + private Map<Integer, String> headData; + + private String userName; + // FTP 登录密码 + private String password; + // FTP 服务器地址IP地址 + private String host; + // FTP 端口 + private int port; + private String excelUrl; + + private StringRedisTemplate stringRedisTemplate; + + public static String loadUrl; + + public ComMngPopulationVeteransExcelListen(CommunityService communityService, Long communityId, String userName, String password, String host, int port, String excelUrl, StringRedisTemplate stringRedisTemplate) { + this.communityService = communityService; + this.communityId = communityId; + this.userName = userName; + this.password = password; + this.host = host; + this.port = port; + this.excelUrl = excelUrl; + this.stringRedisTemplate = stringRedisTemplate; + } + + /** + * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 + */ + private static final int BATCH_COUNT = 5000; + List<Map<Integer, String>> list = new ArrayList<Map<Integer, String>>(); + + @Override + public void invoke(Map<Integer, String> data, AnalysisContext context) { + list.add(data); + if (list.size() >= BATCH_COUNT) { + saveData(); + list.clear(); + } + } + + /** + * 这里会一行行的返回头 + * + * @param headMap + * @param context + */ + @Override + public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { + headSize = headMap.size(); + headData = headMap; + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + saveData(); + log.info("所有数据解析完成!"); + } + + /** + * 不是固定的列只能手动处理 + */ + private void saveData() { + R<List<BcDictionaryVO>> dictionaryR = communityService.listDictionaryByKey(BcDictionaryConstants.FAMILY); + log.info("开始导入退役军人数据"); + log.info("表格总数据:" + list.size()); + if (list.size() == 0) { + throw new ServiceException("500", "导入数据为空!"); + } + ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); + String Veterans = Constants.VETERANS_POPULATION_ERROR_LIST + communityId; + + Map<String,String> dictMap = dictionaryR.getData().stream().collect(Collectors.toMap(BcDictionaryVO::getDictName,BcDictionaryVO::getDictValue)); +// Map<String,Integer> dictMap = new HashMap<>(); +// for(BcDictionaryVO vo : dictionaryR.getData()){ +// dictMap.put(vo.getDictName(),Integer.valueOf(vo.getDictValue())); +// } + + + int index = 2; + try { + String[] parsePatterns = new String[]{"yyyy-MM-dd", "yyyy-M-dd", "yyyy-MM-d", "yyyy-M-d", "yyyy/MM/dd", "yyyy/M/dd", "yyyy/MM/d", "yyyy/M/d"}; + ArrayList<ComMngPopulationVeteransExcelVO> voList = Lists.newArrayList(); +// List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); + ArrayList<ComMngPopulationVeteransMistakeExcelVO> mistakes = Lists.newArrayList(); + for (Map<Integer, String> oneData : list) { + ComMngPopulationVeteransExcelVO vo = new ComMngPopulationVeteransExcelVO(); + if (StringUtils.isNotEmpty(oneData.get(0))){ + vo.setSerialNumber(oneData.get(0)); + } + //姓名和身份证都为空,为空户,无需操作,否则就解析年龄,性别,出生年月日 + if(StringUtils.isNotEmpty(oneData.get(3)) || StringUtils.isNotEmpty(oneData.get(4))){ + if(StringUtils.isEmpty(oneData.get(3))){ + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + index++; + setVeteransMistake(oneData, mistake); + mistake.setMistake("名字不可为空,请填写姓名"); + mistakes.add(mistake); + continue; + } + vo.setName(oneData.get(3)); + if(StringUtils.isEmpty(oneData.get(4))){ + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + index++; + setVeteransMistake(oneData, mistake); + mistake.setMistake("身份证号不可为空,请填写身份证"); + mistakes.add(mistake); + continue; + } + + //判断身份证号码位数 + if(oneData.get(4).length() != 18){ + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + index++; + setVeteransMistake(oneData, mistake); + mistake.setMistake("身份证号位数有误,请检查身份证号码是否正确"); + mistakes.add(mistake); + continue; + } + vo.setCardNo(oneData.get(4).toUpperCase()); + //根据身份证号码解析年龄以及性别 + //获取用户生日 + String birthday = vo.getCardNo().substring(6, 14); + if(StringUtils.isNotEmpty(birthday)){ + String year = birthday.substring(0,4); + String month = birthday.substring(4,6); + String day = birthday.substring(6,8); + vo.setBirthday(year + "-" + month + "-" + day); + } +// //设置用户年龄 +// vo.setAge(AgeUtils.getAgeFromBirthTime(birthday)); + //获取用户性别 + int sex = Integer.parseInt(vo.getCardNo().substring(16, 17)); + if(sex%2 == 1){ + vo.setSex(PopulSexEnum.nan.getCode()); + }else{ + vo.setSex(PopulSexEnum.nv.getCode()); + } + } + if(StringUtils.isNotEmpty(oneData.get(1))){ + vo.setPersonStatus(oneData.get(1)); + } + if(StringUtils.isNotEmpty(oneData.get(2))){ + vo.setOrganization(oneData.get(2)); + } + if(StringUtils.isNotEmpty(oneData.get(5))){ + vo.setPhone(oneData.get(5)); + } + if(StringUtils.isNotEmpty(oneData.get(6))){ + vo.setPhoto(oneData.get(6)); + } + if(StringUtils.isNotEmpty(oneData.get(7))){ + Integer isOk = PopulRegiterNatureEnum.getCodeByName(oneData.get(7).trim()); + if(isOk.equals(-1)){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("您填写的户籍性质有误"); + mistakes.add(mistake); + continue; + } + vo.setRegiterNature(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(8))){ + vo.setCensusRegister(oneData.get(8).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(9))){ + Integer isOk = PopulOutOrLocalEnum.getCodeByName(oneData.get(9)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("您填写的本地/外地有误"); + mistakes.add(mistake); + continue; + } + vo.setOutOrLocal(isOk); + }else { + vo.setOutOrLocal(PopulOutOrLocalEnum.getCodeByName("本地")); + } + if(StringUtils.isEmpty(oneData.get(10))){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("街路巷不可为空"); + mistakes.add(mistake); + continue; + } + vo.setRoad(oneData.get(10)); + if(StringUtils.isEmpty(oneData.get(11))){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("小区号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setDoorNo(oneData.get(11).trim()); + if(StringUtils.isEmpty(oneData.get(12))){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("楼排号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setFloor(oneData.get(12).trim()); + if(StringUtils.isEmpty(oneData.get(13))){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("单元号不可为空"); + mistakes.add(mistake); + continue; + } + vo.setUnitNo(oneData.get(13).trim()); + if(StringUtils.isEmpty(oneData.get(14))){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("户室不可为空"); + mistakes.add(mistake); + continue; + } + vo.setHouseNo(oneData.get(14).trim()); + if(StringUtils.isNotEmpty(oneData.get(15))){ + Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(15)); + if(isOk.equals(-1)){ + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + index++; + setVeteransMistake(oneData, mistake); + mistake.setMistake("您填写的是否租住有误"); + mistakes.add(mistake); + continue; + } + vo.setIsRent(isOk); + }else { + vo.setIsRent(PopulHouseUseEnum.getCodeByName("否")); + } + if(StringUtils.isNotEmpty(oneData.get(16))){ + Integer isOk = PopulHouseStatusEnum.getCodeByName(oneData.get(16).trim()); + if(isOk.equals(-1)){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("您填写的房屋状态有误"); + mistakes.add(mistake); + continue; + } + vo.setHouseStatus(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(17))){ + Integer isOk = PopulHousePurposeEnum.getCodeByName(oneData.get(17).trim()); + if(isOk.equals(-1)){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("您填写的房屋用途有误"); + mistakes.add(mistake); + continue; + } + vo.setHousePurpose(PopulHousePurposeEnum.getCodeByName(oneData.get(14).trim())); + } + if(StringUtils.isNotEmpty(oneData.get(18))){ + Integer isOk = PopulHouseControlStatusEnum.getCodeByName(oneData.get(18)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("您填写的管控状态有误"); + mistakes.add(mistake); + continue; + } + vo.setControlStatus(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(19))){ + vo.setEnlistDate(DateUtil.parse(oneData.get(19))); + } + if(StringUtils.isNotEmpty(oneData.get(20))){ + vo.setRetireDate(DateUtil.parse(oneData.get(20))); + } + if(StringUtils.isNotEmpty(oneData.get(21))){ + vo.setPersonCategory(oneData.get(21).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(22))){ + vo.setNation(oneData.get(22).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(23))){ + vo.setHealthy(oneData.get(23).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(24))){ + Integer isOk = PopulPoliticalOutlookEnum.getCodeByName(oneData.get(24)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("您填写的政治面貌有误"); + mistakes.add(mistake); + continue; + } + vo.setPoliticalOutlook(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(25))){ + Integer isOk = PopulMarriageEnum.getCodeByName(oneData.get(25)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("您填写的政治面貌有误"); + mistakes.add(mistake); + continue; + } + vo.setMarriage(isOk); + } + if(StringUtils.isNotEmpty(oneData.get(26))){ + vo.setHouseSituation(oneData.get(26).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(27))){ + vo.setHouseSituationOther(oneData.get(27).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(28))){ + vo.setBuildArea(oneData.get(28).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(29))){ + vo.setEmploymentSituation(oneData.get(29).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(30))){ + vo.setIncumbencyType(oneData.get(30).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(31))){ + vo.setEmploymentSituationOther(oneData.get(31).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(32))){ + vo.setEndowmentInsurance(oneData.get(32).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(33))){ + vo.setMedicalInsurance(oneData.get(33).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(34))){ + vo.setAnnualIncome(oneData.get(34).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(35))){ + vo.setFatherHealthy(oneData.get(35).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(36))){ + vo.setMotherHealthy(oneData.get(36).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(37))){ + vo.setSpouseHealthy(oneData.get(37).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(38))){ + vo.setSonHealthy(oneData.get(38).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(39))){ + vo.setDaughterHealthy(oneData.get(39).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(40))){ + vo.setMainDifficulty(oneData.get(40).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(41))){ + vo.setOtherDifficulty(oneData.get(41).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(42))){ + vo.setMainDemand(oneData.get(42).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(43))){ + vo.setMainDemandOther(oneData.get(43).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(44))){ + vo.setAcademicTraining(oneData.get(44).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(45))){ + Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(45)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("您填写的是否已参加退役军人培训(政府性质)有误"); + mistakes.add(mistake); + continue; + } + vo.setIsVeteransTraining(isOk); + }else { + vo.setIsVeteransTraining(PopulHouseUseEnum.getCodeByName("否")); + } + if(StringUtils.isNotEmpty(oneData.get(46))){ + vo.setEducationBeforeEnlistment(oneData.get(46).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(47))){ + vo.setReEducation(oneData.get(47).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(48))){ + vo.setMajor(oneData.get(48).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(49))){ + vo.setMajorOther(oneData.get(49).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(50))){ + vo.setOnceEngagedIndustry(oneData.get(50).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(51))){ + vo.setOnceEngagedIndustryOther(oneData.get(51).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(52))){ + vo.setIntendedPlaceOfEmployment(oneData.get(52).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(53))){ + vo.setIntendedPlaceOfEmploymentOther(oneData.get(53).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(54))){ + vo.setUnemploymedEngagedIndustry(oneData.get(54).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(55))){ + vo.setUnemploymedEngagedIndustryOther(oneData.get(55).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(56))){ + Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(56)); + if(isOk.equals(-1)){ + index++; + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + setVeteransMistake(oneData, mistake); + mistake.setMistake("您填写的是否有创业意愿有误"); + mistakes.add(mistake); + continue; + } + vo.setIsBusiness(isOk); + }else { + vo.setIsBusiness(PopulHouseUseEnum.getCodeByName("否")); + } + if(StringUtils.isNotEmpty(oneData.get(57))){ + vo.setBusinessDesire(oneData.get(57).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(58))){ + vo.setRemark(oneData.get(58).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(59))){ + vo.setFillUnit(oneData.get(59).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(60))){ + vo.setFillPerson(oneData.get(50).trim()); + } + if(StringUtils.isNotEmpty(oneData.get(61))){ + vo.setFillPersonPhone(oneData.get(61).trim()); + } + vo.getUserTagStr().add("退役军人"); + for (int i = 62; i < headSize; i++) { + if (oneData.get(i) != null && oneData.get(i).equals("是")) { + vo.getUserTagStr().add(headData.get(i).substring(0,headData.get(i).indexOf("("))); + } + } + //将重复的数据进行MD5加密实现去重 + String distinct = vo.getName() + vo.getCardNo() + vo.getRoad() + vo.getDoorNo() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo(); + try { + String distinctPass = PayUtil.MD5(distinct); + if(StringUtils.isNotEmpty(distinctPass)){ + vo.setDistinctPass(distinctPass); + } + }catch (Exception e){ + log.error("组装MD5加密字段失败,数据表格行数:" + index); + continue; + } + voList.add(vo); + index++; + } + //客户需要暂时注释,等客户处理完成需要恢复 +// if(populationImportErrorVOList.isEmpty()){ +// R r = communityService.listSavePopulationServeExcelVO(voList, communityId); +// if (!R.isOk(r)) { +// throw new ServiceException(r.getMsg()); +// } +// }else{ +// throw new ServiceException("500", JSON.toJSONString(populationImportErrorVOList)); +// } + //根据list中的IdCard城市来去重 + List<ComMngPopulationVeteransExcelVO> newVoList = voList.stream().filter(ListUtils.distinctByKey(ComMngPopulationVeteransExcelVO::getDistinctPass)).collect(Collectors.toList()); + log.info("开始进入业务层处理逻辑"); + R r = communityService.listSavePopulationVeteransExcelVO(newVoList, communityId); + log.info("业务层处理逻辑完成"); + if (!R.isOk(r)) { + log.info("业务层处理成功"); + List<ComMngPopulationVeteransMistakeExcelVO> list = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ComMngPopulationVeteransMistakeExcelVO.class); +// String errMsg = r.getMsg(); +// List<ComMngPopulationImportErrorVO> errorList = JSON.parseArray(errMsg,ComMngPopulationImportErrorVO.class); +// if(!errorList.isEmpty()){ +// populationImportErrorVOList.addAll(errorList); +// } + mistakes.addAll(list); + log.info("将错误数据存入redis中"); + valueOperations.set(Veterans,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); + log.info("将错误数据存入redis中成功"); + throw new ServiceException("500", Veterans); + }else{ + log.info("业务层处理逻辑失败"); + if(!mistakes.isEmpty()){ + log.info("业务层处理逻辑失败,将错误数据缓存到redis中"); + valueOperations.set(Veterans,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); + log.info("业务层处理逻辑失败,将错误数据缓存到redis中成功"); + throw new ServiceException("500", Veterans); + } + } + } catch (NumberFormatException e) { + log.info("处理数据时失败"); + e.printStackTrace(); +// List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); +// ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); +// importErrorVO.setErrorPosition("第" + index + "行"); +// importErrorVO.setErrorMsg("数据格式有误,请检查文档内数据"); +// populationImportErrorVOList.add(importErrorVO); + log.error("数据格式有误,第" + index + "行"); + throw new ServiceException("500", "导入失败111"); + } + } + + private void setVeteransMistake(Map<Integer, String> map, ComMngPopulationVeteransMistakeExcelVO vo){ + vo.setSerialNumber(map.get(0)); + vo.setPersonStatus(map.get(1)); + vo.setOrganization(map.get(2)); + vo.setName(map.get(3)); + vo.setCardNo(map.get(4)); + vo.setPhone(map.get(5)); + vo.setPhoto(map.get(6)); + vo.setRegiterNature(map.get(7)); + vo.setCensusRegister(map.get(8)); + vo.setOutOrLocal(map.get(9)); + vo.setRoad(map.get(10)); + vo.setDoorNo(map.get(11)); + vo.setFloor(map.get(12)); + vo.setUnitNo(map.get(13)); + vo.setHouseNo(map.get(14)); + vo.setIsRent(map.get(15)); + vo.setHouseStatus(map.get(16)); + vo.setHousePurpose(map.get(17)); + vo.setControlStatus(map.get(18)); + vo.setEnlistDate(map.get(19)); + vo.setRetireDate(map.get(20)); + vo.setPersonCategory(map.get(21)); + vo.setNation(map.get(22)); + vo.setHealthy(map.get(23)); + vo.setPoliticalOutlook(map.get(24)); + vo.setMarriage(map.get(25)); + vo.setHouseSituation(map.get(26)); + vo.setHouseSituationOther(map.get(27)); + vo.setBuildArea(map.get(28)); + vo.setEmploymentSituation(map.get(29)); + vo.setIncumbencyType(map.get(30)); + vo.setEmploymentSituationOther(map.get(31)); + vo.setEndowmentInsurance(map.get(32)); + vo.setMedicalInsurance(map.get(33)); + vo.setAnnualIncome(map.get(34)); + vo.setFatherHealthy(map.get(35)); + vo.setMotherHealthy(map.get(36)); + vo.setSpouseHealthy(map.get(37)); + vo.setSonHealthy(map.get(38)); + vo.setDaughterHealthy(map.get(39)); + vo.setMainDifficulty(map.get(40)); + vo.setOtherDifficulty(map.get(41)); + vo.setMainDemand(map.get(42)); + vo.setMainDemandOther(map.get(43)); + vo.setAcademicTraining(map.get(44)); + vo.setIsVeteransTraining(map.get(45)); + vo.setEducationBeforeEnlistment(map.get(46)); + vo.setReEducation(map.get(47)); + vo.setMajor(map.get(48)); + vo.setMajorOther(map.get(49)); + vo.setOnceEngagedIndustry(map.get(50)); + vo.setOnceEngagedIndustryOther(map.get(51)); + vo.setIntendedPlaceOfEmployment(map.get(52)); + vo.setIntendedPlaceOfEmploymentOther(map.get(53)); + vo.setUnemploymedEngagedIndustry(map.get(54)); + vo.setUnemploymedEngagedIndustryOther(map.get(55)); + vo.setIsBusiness(map.get(56)); + vo.setBusinessDesire(map.get(57)); + vo.setRemark(map.get(58)); + vo.setFillUnit(map.get(59)); + vo.setFillPerson(map.get(60)); + vo.setFillPersonPhone(map.get(61)); + } + + private String convertMarriage(String ma) { + + if(Objects.equals("已",ma) || Objects.equals("一",ma)){ + ma = "已婚"; + }else if(Objects.equals("未",ma) || Objects.equals("未婚婚",ma)){ + ma = "未婚"; + }else if(Objects.equals("初",ma)){ + ma = "初婚"; + }else if(Objects.equals("再",ma)){ + ma = "再婚"; + }else if(Objects.equals("复",ma)){ + ma = "复婚"; + }else if(Objects.equals("丧",ma) || Objects.equals("丧偶偶",ma)){ + ma = "丧偶"; + }else if(Objects.equals("离",ma) || Objects.equals("离异",ma) || Objects.equals("离异婚",ma)){ + ma = "离婚"; + }else if(Objects.equals("分",ma)){ + ma = "分居"; + } + + return ma; + } + + private String convertRelation(String ra) { + if(ra.contains("户主")){ + ra = "户主"; + }else if(Objects.equals(ra,"女儿")){ + ra = "女"; + }else if(Objects.equals(ra,"儿子") || Objects.equals(ra,"儿")){ + ra = "子"; + }else if(Objects.equals(ra,"大女")){ + ra = "长女"; + }else if(Objects.equals(ra,"二女") || Objects.equals(ra,"此女")){ + ra = "次女"; + }else if(Objects.equals(ra,"二子")){ + ra = "次子"; + }else if(Objects.equals(ra,"长男") || ra.contains("长子")){ + ra = "长子"; + }else if(Objects.equals(ra,"非亲属") || ra.contains("女友") || ra.contains("女朋友") + || ra.contains("男友") || ra.contains("男朋友")){ + ra = "其他"; + }else if(Objects.equals(ra,"姐")){ + ra = "姐姐"; + }else if(Objects.equals(ra,"户主")){ + ra = "本人"; + }else if(Objects.equals(ra,"妻子") || Objects.equals(ra,"媳妇")){ + ra = "妻"; + }else if(Objects.equals(ra,"哥") || Objects.equals(ra,"哥哥")){ + ra = "兄"; + }else if(Objects.equals(ra,"丈夫")){ + ra = "夫"; + }else if(Objects.equals(ra,"丈母娘")){ + ra = "岳母"; + }else if(Objects.equals(ra,"继子") || Objects.equals(ra,"养子")){ + ra = "养子或继子"; + }else if(Objects.equals(ra,"继女") || Objects.equals(ra,"养女")){ + ra = "养女或继女"; + }else if(ra.contains("儿媳")||ra.contains("长媳")){ + ra = "儿媳"; + }else if(Objects.equals(ra,"三姨") || Objects.equals(ra,"姨姨")){ + ra = "姨母"; + }else if(Objects.equals(ra,"二外孙女")){ + ra = "外孙女"; + }else if(Objects.equals(ra,"外孙")){ + ra = "外孙子"; + }else if(Objects.equals(ra,"侄儿")){ + ra = "侄子"; + }else if(ra.contains("表")){ + ra = "表兄弟、表姐妹"; + }else if(Objects.equals(ra,"继父") || Objects.equals(ra,"养父")){ + ra = "继父或养父"; + }else if(Objects.equals(ra,"父")){ + ra = "父亲"; + }else if(Objects.equals(ra,"弟弟")){ + ra = "弟"; + }else if(Objects.equals(ra,"孙")){ + ra = "孙子"; + }else if(Objects.equals(ra,"孙媳妇") || Objects.equals(ra,"外孙媳妇")){ + ra = "孙媳妇或外孙媳妇"; + }else if(Objects.equals(ra,"妹")){ + ra = "妹妹"; + }else if(Objects.equals(ra,"祖父母")){ + ra = "祖父母或外祖父母"; + }else if(Objects.equals(ra,"姐妹") || Objects.equals(ra,"兄弟")){ + ra = "兄弟姐妹"; + }else if(Objects.equals(ra,"其他姐妹") || Objects.equals(ra,"其他兄弟")){ + ra = "其他兄弟姐妹"; + }else if(Objects.equals(ra,"奶奶")){ + ra = "祖母"; + }else if(Objects.equals(ra,"爷爷")){ + ra = "祖父"; + }else if(Objects.equals(ra,"爷爷")){ + ra = "祖父"; + }else if(ra.contains("堂")){ + ra = "堂兄弟、堂姐妹"; + } + + return ra; + } + +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationDisabilityExcelVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationDisabilityExcelVO.java new file mode 100644 index 0000000..4272e32 --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationDisabilityExcelVO.java @@ -0,0 +1,115 @@ +package com.panzhihua.common.model.vos.community; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.google.common.collect.Lists; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptField; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @description: 批量导入残疾人 + * @author: txb + */ +@Data +@EncryptDecryptClass +public class ComMngPopulationDisabilityExcelVO implements Serializable { + + @ExcelProperty(value = "序号", index = 0) + private String serialNumber; + + @ExcelProperty(value = "姓名", index = 1) + private String name; + + @ExcelProperty(value = "身份证号码", index = 2) + @EncryptDecryptField + private String cardNo; + + @ExcelProperty(value = "办证状况", index = 3) + private String certificateSituation; + + @ExcelProperty(value = "文化程度" ,index = 4) + private Integer cultureLevel; + + @ExcelProperty(value = "民族", index = 5) + private String nation; + + @ExcelProperty(value = "残疾类别", index = 6) + private String disType; + + @ExcelProperty(value = "残疾等级", index = 7) + private String disLevel; + + @ExcelProperty(value = "联系电话", index = 8) + private String phone; + + @ExcelProperty(value = "街/路/巷", index = 9) + private String road; + + @ExcelProperty(value = "小区号", index = 10) + private String doorNo; + + @ExcelProperty(value = "楼排号", index = 11) + private String floor; + + @ExcelProperty(value = "单元号", index = 12) + private String unitNo; + + @ExcelProperty(value = "户室(房间号)", index = 13) + private String houseNo; + + @ExcelProperty(value = "是否租住", index = 14) + private Integer isRent; + + @ExcelProperty(value = "房屋状态(1.自住 2.租住 3.其他)", index = 15) + private Integer houseStatus; + + @ExcelProperty(value = "房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)", index = 16) + private Integer housePurpose; + + @ExcelProperty(value = "管控状态(1.常规 2.关注 3.管控)", index = 17) + private Integer controlStatus; + + @ExcelProperty(value = "外地/本地(1.本地 2.外地)", index = 18) + private Integer outOrLocal; + + @ExcelProperty(value = "户口所在地", index = 19) + private String censusRegister; + + @ExcelProperty(value = "备注", index = 20) + private String remark; + /** + * 去重字段,使用(姓名+身份证号+街路巷+小区号+楼牌号+单元号+户室)组合字段进行MD5加密实现去重 + */ + private String distinctPass; + + /** + * 年龄 + */ + private Integer age; + + /** + * 性别(1.男 2.女) + */ + private Integer sex; + + /** + * 出生年月日 + */ + private String birthday; + + /** + * 扩展字段用逗号隔开 + */ + private List<String> userTagStr = Lists.newArrayList(); + + private Long houseId; + + /** + * 地址 + */ + private String address; +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationDisabilityMistakeExcelVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationDisabilityMistakeExcelVO.java new file mode 100644 index 0000000..5336bc4 --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationDisabilityMistakeExcelVO.java @@ -0,0 +1,86 @@ +package com.panzhihua.common.model.vos.community; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.google.common.collect.Lists; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptField; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @description: 批量导入残疾人 + * @author: txb + */ +@Data +@EncryptDecryptClass +public class ComMngPopulationDisabilityMistakeExcelVO implements Serializable { + + @ExcelProperty(value = "序号", index = 0) + private String serialNumber; + + @ExcelProperty(value = "姓名", index = 1) + private String name; + + @ExcelProperty(value = "身份证号码", index = 2) + @EncryptDecryptField + private String cardNo; + + @ExcelProperty(value = "办证状况", index = 3) + private String certificateSituation; + + @ExcelProperty(value = "文化程度" ,index = 4) + private String cultureLevel; + + @ExcelProperty(value = "民族", index = 5) + private String nation; + + @ExcelProperty(value = "残疾类别", index = 6) + private String disType; + + @ExcelProperty(value = "残疾等级", index = 7) + private String disLevel; + + @ExcelProperty(value = "联系电话", index = 8) + private String phone; + + @ExcelProperty(value = "街/路/巷", index = 9) + private String road; + + @ExcelProperty(value = "小区号", index = 10) + private String doorNo; + + @ExcelProperty(value = "楼排号", index = 11) + private String floor; + + @ExcelProperty(value = "单元号", index = 12) + private String unitNo; + + @ExcelProperty(value = "户室(房间号)", index = 13) + private String houseNo; + + @ExcelProperty(value = "是否租住", index = 14) + private String isRent; + + @ExcelProperty(value = "房屋状态(1.自住 2.租住 3.其他)", index = 15) + private String houseStatus; + + @ExcelProperty(value = "房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)", index = 16) + private String housePurpose; + + @ExcelProperty(value = "管控状态(1.常规 2.关注 3.管控)", index = 17) + private String controlStatus; + + @ExcelProperty(value = "外地/本地(1.本地 2.外地)", index = 18) + private String outOrLocal; + + @ExcelProperty(value = "户口所在地", index = 19) + private String censusRegister; + + @ExcelProperty(value = "备注", index = 20) + private String remark; + + @ExcelProperty(value = "错误信息", index = 21) + private String mistake; +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationKeyExcelVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationKeyExcelVO.java new file mode 100644 index 0000000..01e79a2 --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationKeyExcelVO.java @@ -0,0 +1,105 @@ +package com.panzhihua.common.model.vos.community; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.google.common.collect.Lists; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptField; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @description: 批量导入重点上访人员 + * @author: txb + */ +@Data +@EncryptDecryptClass +public class ComMngPopulationKeyExcelVO implements Serializable { + + @ExcelProperty(value = "序号", index = 0) + private String serialNumber; + + @ExcelProperty(value = "姓名", index = 1) + private String name; + + @ExcelProperty(value = "民族", index = 2) + private String nation; + + @ExcelProperty(value = "身份证号码", index = 3) + @EncryptDecryptField + private String cardNo; + + @ExcelProperty(value = "联系电话", index = 4) + private String phone; + + @ExcelProperty(value = "籍贯", index = 5) + private String nativePlace; + + @ExcelProperty(value = "街/路/巷", index = 6) + private String road; + + @ExcelProperty(value = "小区号", index = 7) + private String doorNo; + + @ExcelProperty(value = "楼排号", index = 8) + private String floor; + + @ExcelProperty(value = "单元号", index = 9) + private String unitNo; + + @ExcelProperty(value = "户室(房间号)", index = 10) + private String houseNo; + + @ExcelProperty(value = "是否租住", index = 11) + private Integer isRent; + + @ExcelProperty(value = "房屋状态(1.自住 2.租住 3.其他)", index = 12) + private Integer houseStatus; + + @ExcelProperty(value = "房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)", index = 13) + private Integer housePurpose; + + @ExcelProperty(value = "管控状态(1.常规 2.关注 3.管控)", index = 14) + private Integer controlStatus; + + @ExcelProperty(value = "外地/本地(1.本地 2.外地)", index = 15) + private Integer outOrLocal; + + @ExcelProperty(value = "户口所在地", index = 16) + private String censusRegister; + + @ExcelProperty(value = "备注", index = 17) + private String remark; + /** + * 去重字段,使用(姓名+身份证号+街路巷+小区号+楼牌号+单元号+户室)组合字段进行MD5加密实现去重 + */ + private String distinctPass; + + /** + * 年龄 + */ + private Integer age; + + /** + * 性别(1.男 2.女) + */ + private Integer sex; + + /** + * 出生年月日 + */ + private String birthday; + + /** + * 扩展字段用逗号隔开 + */ + private List<String> userTagStr = Lists.newArrayList(); + + private Long houseId; + + /** + * 地址 + */ + private String address; +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationKeyMistakeExcelVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationKeyMistakeExcelVO.java new file mode 100644 index 0000000..37a1ce5 --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationKeyMistakeExcelVO.java @@ -0,0 +1,77 @@ +package com.panzhihua.common.model.vos.community; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.google.common.collect.Lists; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptField; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @description: 批量导入重点上访人员 + * @author: txb + */ +@Data +@EncryptDecryptClass +public class ComMngPopulationKeyMistakeExcelVO implements Serializable { + + @ExcelProperty(value = "序号", index = 0) + private String serialNumber; + + @ExcelProperty(value = "姓名", index = 1) + private String name; + + @ExcelProperty(value = "民族", index = 2) + private String nation; + + @ExcelProperty(value = "身份证号码", index = 3) + @EncryptDecryptField + private String cardNo; + + @ExcelProperty(value = "联系电话", index = 4) + private String phone; + + @ExcelProperty(value = "籍贯", index = 5) + private String nativePlace; + + @ExcelProperty(value = "街/路/巷", index = 6) + private String road; + + @ExcelProperty(value = "小区号", index = 7) + private String doorNo; + + @ExcelProperty(value = "楼排号", index = 8) + private String floor; + + @ExcelProperty(value = "单元号", index = 9) + private String unitNo; + + @ExcelProperty(value = "户室(房间号)", index = 10) + private String houseNo; + + @ExcelProperty(value = "是否租住", index = 11) + private String isRent; + + @ExcelProperty(value = "房屋状态(1.自住 2.租住 3.其他)", index = 12) + private String houseStatus; + + @ExcelProperty(value = "房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)", index = 13) + private String housePurpose; + + @ExcelProperty(value = "管控状态(1.常规 2.关注 3.管控)", index = 14) + private String controlStatus; + + @ExcelProperty(value = "外地/本地(1.本地 2.外地)", index = 15) + private String outOrLocal; + + @ExcelProperty(value = "户口所在地", index = 16) + private String censusRegister; + + @ExcelProperty(value = "备注", index = 17) + private String remark; + + @ExcelProperty(value = "错误信息", index = 18) + private String mistake; +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationMajorExcelVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationMajorExcelVO.java index 4e812ed..90aa740 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationMajorExcelVO.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationMajorExcelVO.java @@ -74,7 +74,7 @@ private String guarDianPhone; @ExcelProperty(value = "与患者关系", index = 18) - private String patientRelation; + private Integer patientRelation; @ExcelProperty(value = "目前诊断", index = 19) private String diagnose; diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationRehabilitationExcelVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationRehabilitationExcelVO.java index cb03286..8581632 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationRehabilitationExcelVO.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationRehabilitationExcelVO.java @@ -17,6 +17,9 @@ @EncryptDecryptClass public class ComMngPopulationRehabilitationExcelVO implements Serializable { + @ExcelProperty(value = "序号", index = 0) + private String serialNumber; + @ExcelProperty(value = "姓名", index = 1) private String name; @@ -70,7 +73,7 @@ private String mainRelatives; @ExcelProperty(value = "与人员关系", index = 18) - private String patientRelation; + private Integer patientRelation; @ExcelProperty(value = "列管原因及类型", index = 19) private String rehabReasonAndType; @@ -106,4 +109,9 @@ private List<String> userTagStr = Lists.newArrayList(); private Long houseId; + + /** + * 地址 + */ + private String address; } diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationRehabilitationMistakeExcelVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationRehabilitationMistakeExcelVO.java new file mode 100644 index 0000000..b82350c --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationRehabilitationMistakeExcelVO.java @@ -0,0 +1,89 @@ +package com.panzhihua.common.model.vos.community; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.google.common.collect.Lists; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptField; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @description: 批量导入刑释人员 + * @author: txb + */ +@Data +@EncryptDecryptClass +public class ComMngPopulationRehabilitationMistakeExcelVO implements Serializable { + + @ExcelProperty(value = "序号", index = 0) + private String serialNumber; + + @ExcelProperty(value = "姓名", index = 1) + private String name; + + @ExcelProperty(value = "民族", index = 2) + private String nation; + + @ExcelProperty(value = "身份证号码", index = 3) + @EncryptDecryptField + private String cardNo; + + @ExcelProperty(value = "联系电话", index = 4) + private String phone; + + @ExcelProperty(value = "籍贯", index = 5) + private String nativePlace; + + @ExcelProperty(value = "街/路/巷", index = 6) + private String road; + + @ExcelProperty(value = "小区号", index = 7) + private String doorNo; + + @ExcelProperty(value = "楼排号", index = 8) + private String floor; + + @ExcelProperty(value = "单元号", index = 9) + private String unitNo; + + @ExcelProperty(value = "户室(房间号)", index = 10) + private String houseNo; + + @ExcelProperty(value = "是否租住", index = 11) + private String isRent; + + @ExcelProperty(value = "房屋状态(1.自住 2.租住 3.其他)", index = 12) + private String houseStatus; + + @ExcelProperty(value = "房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)", index = 13) + private String housePurpose; + + @ExcelProperty(value = "管控状态(1.常规 2.关注 3.管控)", index = 14) + private String controlStatus; + + @ExcelProperty(value = "外地/本地(1.本地 2.外地)", index = 15) + private String outOrLocal; + + @ExcelProperty(value = "户口所在地", index = 16) + private String censusRegister; + + @ExcelProperty(value = "主要亲属", index = 17) + private String mainRelatives; + + @ExcelProperty(value = "与人员关系", index = 18) + private String patientRelation; + + @ExcelProperty(value = "列管原因及类型", index = 19) + private String rehabReasonAndType; + + @ExcelProperty(value = "是否列管", index = 20) + private String isRehab; + + @ExcelProperty(value = "备注", index = 21) + private String remark; + + @ExcelProperty(value = "错误信息", index = 22) + private String mistake; +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationSentenceExcelVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationSentenceExcelVO.java new file mode 100644 index 0000000..91f782d --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationSentenceExcelVO.java @@ -0,0 +1,121 @@ +package com.panzhihua.common.model.vos.community; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.google.common.collect.Lists; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptField; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @description: 批量导入服刑人员 + * @author: txb + */ +@Data +@EncryptDecryptClass +public class ComMngPopulationSentenceExcelVO implements Serializable { + + @ExcelProperty(value = "序号", index = 0) + private String serialNumber; + + @ExcelProperty(value = "姓名", index = 1) + private String name; + + @ExcelProperty(value = "民族", index = 2) + private String nation; + + @ExcelProperty(value = "身份证号码", index = 3) + @EncryptDecryptField + private String cardNo; + + @ExcelProperty(value = "联系电话", index = 4) + private String phone; + + @ExcelProperty(value = "配偶", index = 5) + private String spouse; + + @ExcelProperty(value = "职业", index = 6) + private String profession; + + @ExcelProperty(value = "街/路/巷", index = 7) + private String road; + + @ExcelProperty(value = "小区号", index = 8) + private String doorNo; + + @ExcelProperty(value = "楼排号", index = 9) + private String floor; + + @ExcelProperty(value = "单元号", index = 10) + private String unitNo; + + @ExcelProperty(value = "户室(房间号)", index = 11) + private String houseNo; + + @ExcelProperty(value = "是否租住", index = 12) + private Integer isRent; + + @ExcelProperty(value = "房屋状态(1.自住 2.租住 3.其他)", index = 13) + private Integer houseStatus; + + @ExcelProperty(value = "房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)", index = 14) + private Integer housePurpose; + + @ExcelProperty(value = "管控状态(1.常规 2.关注 3.管控)", index = 15) + private Integer controlStatus; + + @ExcelProperty(value = "外地/本地(1.本地 2.外地)", index = 16) + private Integer outOrLocal; + + @ExcelProperty(value = "户口所在地", index = 17) + private String censusRegister; + + @ExcelProperty(value = "服刑地", index = 18) + private String sentencePlace; + + @ExcelProperty(value = "服刑开始时间", index = 19) + private Date sentenceBegin; + + @ExcelProperty(value = "服刑结束时间", index = 20) + private Date sentenceEnd; + + @ExcelProperty(value = "罪名", index = 21) + private String charge; + + @ExcelProperty(value = "备注", index = 22) + private String remark; + /** + * 去重字段,使用(姓名+身份证号+街路巷+小区号+楼牌号+单元号+户室)组合字段进行MD5加密实现去重 + */ + private String distinctPass; + + /** + * 年龄 + */ + private Integer age; + + /** + * 性别(1.男 2.女) + */ + private Integer sex; + + /** + * 出生年月日 + */ + private String birthday; + + /** + * 扩展字段用逗号隔开 + */ + private List<String> userTagStr = Lists.newArrayList(); + + private Long houseId; + + /** + * 地址 + */ + private String address; +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationSentenceMistakeExcelVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationSentenceMistakeExcelVO.java new file mode 100644 index 0000000..df17e4f --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationSentenceMistakeExcelVO.java @@ -0,0 +1,92 @@ +package com.panzhihua.common.model.vos.community; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.google.common.collect.Lists; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptField; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @description: 批量导入服刑人员 + * @author: txb + */ +@Data +@EncryptDecryptClass +public class ComMngPopulationSentenceMistakeExcelVO implements Serializable { + + @ExcelProperty(value = "序号", index = 0) + private String serialNumber; + + @ExcelProperty(value = "姓名", index = 1) + private String name; + + @ExcelProperty(value = "民族", index = 2) + private String nation; + + @ExcelProperty(value = "身份证号码", index = 3) + @EncryptDecryptField + private String cardNo; + + @ExcelProperty(value = "联系电话", index = 4) + private String phone; + + @ExcelProperty(value = "配偶", index = 5) + private String spouse; + + @ExcelProperty(value = "职业", index = 6) + private String profession; + + @ExcelProperty(value = "街/路/巷", index = 7) + private String road; + + @ExcelProperty(value = "小区号", index = 8) + private String doorNo; + + @ExcelProperty(value = "楼排号", index = 9) + private String floor; + + @ExcelProperty(value = "单元号", index = 10) + private String unitNo; + + @ExcelProperty(value = "户室(房间号)", index = 11) + private String houseNo; + + @ExcelProperty(value = "是否租住", index = 12) + private String isRent; + + @ExcelProperty(value = "房屋状态(1.自住 2.租住 3.其他)", index = 13) + private String houseStatus; + + @ExcelProperty(value = "房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)", index = 14) + private String housePurpose; + + @ExcelProperty(value = "管控状态(1.常规 2.关注 3.管控)", index = 15) + private String controlStatus; + + @ExcelProperty(value = "外地/本地(1.本地 2.外地)", index = 16) + private String outOrLocal; + + @ExcelProperty(value = "户口所在地", index = 17) + private String censusRegister; + + @ExcelProperty(value = "服刑地", index = 18) + private String sentencePlace; + + @ExcelProperty(value = "服刑开始时间", index = 19) + private String sentenceBegin; + + @ExcelProperty(value = "服刑结束时间", index = 20) + private String sentenceEnd; + + @ExcelProperty(value = "罪名", index = 21) + private String charge; + + @ExcelProperty(value = "备注", index = 22) + private String remark; + + @ExcelProperty(value = "错误信息", index = 23) + private String mistake; +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVO.java index c40abb5..bd08849 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVO.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVO.java @@ -97,6 +97,9 @@ @NotBlank(groups = {AddGroup.class},message = "政治面貌不可为空") private Integer politicalOutlook; + @ApiModelProperty("政治面貌名称") + private String politicalOutlookName; + @ApiModelProperty("工作单位") private String workCompany; @@ -151,8 +154,14 @@ @ApiModelProperty("文化程度(1.小学 2.初中 3.高中 4.中专 5.大专 6.本科 7.硕士 8.博士 9.其他)") private Integer cultureLevel; + @ApiModelProperty("文化程度名称") + private String cultureLevelName; + @ApiModelProperty("婚姻状况(10.未婚 20.已婚 21.初婚 22.再婚 23.复婚 30.丧偶 40.离婚 90.未说明的婚姻状况 60.其他)") private Integer marriage; + + @ApiModelProperty("婚姻状况名称") + private String marriageName; @ApiModelProperty("健康状况") private String healthy; @@ -172,6 +181,9 @@ @ApiModelProperty("与户主关系(1.户主 2.配偶 3.子女 4.孙女 5.父母 6.其他)") private Integer relation; + @ApiModelProperty("与户主关系名称") + private String relationName; + @ApiModelProperty("房屋列表") private List<ComMngHouseVo> houseList; diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVeteransExcelVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVeteransExcelVO.java new file mode 100644 index 0000000..89f6de9 --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVeteransExcelVO.java @@ -0,0 +1,242 @@ +package com.panzhihua.common.model.vos.community; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.google.common.collect.Lists; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptField; +import com.panzhihua.common.validated.AddGroup; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @description: 批量导入退役军人 + * @author: txb + */ +@Data +@EncryptDecryptClass +public class ComMngPopulationVeteransExcelVO implements Serializable { + + @ExcelProperty(value = "序号", index = 0) + private String serialNumber; + + @ExcelProperty(value = "人员状态:正常、失联、出国(取字典表)", index = 1) + private String personStatus; + + @ExcelProperty(value = "机构", index = 2) + private String organization; + + @ExcelProperty(value = "姓名", index = 3) + private String name; + + @ExcelProperty(value = "身份证号码", index = 4) + @EncryptDecryptField + private String cardNo; + + @ExcelProperty(value = "联系电话", index = 5) + private String phone; + + @ExcelProperty(value = "照片", index = 6) + private String photo; + + @ExcelProperty(value = "户籍性质(1.城镇户口 2.农村户口)", index = 7) + private Integer regiterNature; + + @ExcelProperty(value = "户口所在地", index = 8) + private String censusRegister; + + @ExcelProperty(value = "外地/本地(1.本地 2.外地)", index = 9) + private Integer outOrLocal; + + @ExcelProperty(value = "街/路/巷", index = 10) + private String road; + + @ExcelProperty(value = "小区号", index = 11) + private String doorNo; + + @ExcelProperty(value = "楼排号", index = 12) + private String floor; + + @ExcelProperty(value = "单元号", index = 13) + private String unitNo; + + @ExcelProperty(value = "户室(房间号)", index = 14) + private String houseNo; + + @ExcelProperty(value = "是否租住", index = 15) + private Integer isRent; + + @ExcelProperty(value = "房屋状态(1.自住 2.租住 3.其他)", index = 16) + private Integer houseStatus; + + @ExcelProperty(value = "房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)", index = 17) + private Integer housePurpose; + + @ExcelProperty(value = "管控状态(1.常规 2.关注 3.管控)", index = 18) + private Integer controlStatus; + + @ExcelProperty(value = "入伍时间", index = 19) + private Date enlistDate; + + @ExcelProperty(value = "退伍时间", index = 20) + private Date retireDate; + + @ExcelProperty(value = "人员类别", index = 21) + private String personCategory; + + @ExcelProperty(value = "民族", index = 22) + private String nation; + + @ExcelProperty(value = "健康状况", index = 23) + private String healthy; + + @ExcelProperty(value = "政治面貌", index = 24) + private Integer politicalOutlook; + + @ExcelProperty(value = "婚姻状况", index = 25) + private Integer marriage; + + @ExcelProperty(value = "住房状况", index = 26) + private String houseSituation; + + @ExcelProperty(value = "住房状况其他", index = 27) + private String houseSituationOther; + + @ExcelProperty(value = "建筑面积", index = 28) + private String buildArea; + + @ExcelProperty(value = "现就业情况", index = 29) + private String employmentSituation; + + @ExcelProperty(value = "在职情况类型", index = 30) + private String incumbencyType; + + @ExcelProperty(value = "现就业情况其他", index = 31) + private String employmentSituationOther; + + @ExcelProperty(value = "养老保险", index = 32) + private String endowmentInsurance; + + @ExcelProperty(value = "医疗保险", index = 33) + private String medicalInsurance; + + @ExcelProperty(value = "现个人年收入(单位:元)", index = 34) + private String annualIncome; + + @ExcelProperty(value = "父亲健康状况", index = 35) + private String fatherHealthy; + + @ExcelProperty(value = "母亲健康状况", index = 36) + private String motherHealthy; + + @ExcelProperty(value = "配偶健康状况", index = 37) + private String spouseHealthy; + + @ExcelProperty(value = "儿子健康状况", index = 38) + private String sonHealthy; + + @ExcelProperty(value = "女儿健康状况", index = 39) + private String daughterHealthy; + + @ExcelProperty(value = "主要困难", index = 40) + private String mainDifficulty; + + @ExcelProperty(value = "其他困难", index = 41) + private String otherDifficulty; + + @ExcelProperty(value = "主要诉求", index = 42) + private String mainDemand; + + @ExcelProperty(value = "主要诉求其他事项问题(手填)", index = 43) + private String mainDemandOther; + + @ExcelProperty(value = "需参加的学历培训", index = 44) + private String academicTraining; + + @ExcelProperty(value = "是否已参加退役军人培训(政府性质)", index = 45) + private Integer isVeteransTraining; + + @ExcelProperty(value = "入伍前学历", index = 46) + private String educationBeforeEnlistment; + + @ExcelProperty(value = "再教育学历", index = 47) + private String reEducation; + + @ExcelProperty(value = "所学专业", index = 48) + private String major; + + @ExcelProperty(value = "所学专业其他", index = 49) + private String majorOther; + + @ExcelProperty(value = "曾从事行业(含现从事行业)", index = 50) + private String onceEngagedIndustry; + + @ExcelProperty(value = "曾从事行业(含现从事行业)其他(手填)", index = 51) + private String onceEngagedIndustryOther; + + @ExcelProperty(value = "意向就业地点", index = 52) + private String intendedPlaceOfEmployment; + + @ExcelProperty(value = "意向就业地点其他地区(手填)", index = 53) + private String intendedPlaceOfEmploymentOther; + + @ExcelProperty(value = "待业期间的求职意向", index = 54) + private String unemploymedEngagedIndustry; + + @ExcelProperty(value = "待业期间的求职意向其他(手填)", index = 55) + private String unemploymedEngagedIndustryOther; + + @ExcelProperty(value = "是否有创业意愿", index = 56) + private Integer isBusiness; + + @ExcelProperty(value = "创业意愿", index = 57) + private String businessDesire; + + @ExcelProperty(value = "备注", index = 58) + private String remark; + + @ExcelProperty(value = "填表单位", index = 59) + private String fillUnit; + + @ExcelProperty(value = "填表人", index = 60) + private String fillPerson; + + @ExcelProperty(value = "填表人联系电话", index = 61) + private String fillPersonPhone; + + /** + * 去重字段,使用(姓名+身份证号+街路巷+小区号+楼牌号+单元号+户室)组合字段进行MD5加密实现去重 + */ + private String distinctPass; + + /** + * 年龄 + */ + private Integer age; + + /** + * 性别(1.男 2.女) + */ + private Integer sex; + + /** + * 出生年月日 + */ + private String birthday; + + /** + * 扩展字段用逗号隔开 + */ + private List<String> userTagStr = Lists.newArrayList(); + + private Long houseId; + + /** + * 地址 + */ + private String address; +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVeteransMistakeExcelVO.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVeteransMistakeExcelVO.java new file mode 100644 index 0000000..0b01b25 --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVeteransMistakeExcelVO.java @@ -0,0 +1,209 @@ +package com.panzhihua.common.model.vos.community; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.google.common.collect.Lists; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; +import com.panzhihua.common.model.helper.encrypt.EncryptDecryptField; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @description: 批量导入退役军人 + * @author: txb + */ +@Data +@EncryptDecryptClass +public class ComMngPopulationVeteransMistakeExcelVO implements Serializable { + + @ExcelProperty(value = "序号", index = 0) + private String serialNumber; + + @ExcelProperty(value = "人员状态:正常、失联、出国(取字典表)", index = 1) + private String personStatus; + + @ExcelProperty(value = "机构", index = 2) + private String organization; + + @ExcelProperty(value = "姓名", index = 3) + private String name; + + @ExcelProperty(value = "身份证号码", index = 4) + @EncryptDecryptField + private String cardNo; + + @ExcelProperty(value = "联系电话", index = 5) + private String phone; + + @ExcelProperty(value = "照片", index = 6) + private String photo; + + @ExcelProperty(value = "户籍性质(1.城镇户口 2.农村户口)", index = 7) + private String regiterNature; + + @ExcelProperty(value = "户口所在地", index = 8) + private String censusRegister; + + @ExcelProperty(value = "外地/本地(1.本地 2.外地)", index = 9) + private String outOrLocal; + + @ExcelProperty(value = "街/路/巷", index = 10) + private String road; + + @ExcelProperty(value = "小区号", index = 11) + private String doorNo; + + @ExcelProperty(value = "楼排号", index = 12) + private String floor; + + @ExcelProperty(value = "单元号", index = 13) + private String unitNo; + + @ExcelProperty(value = "户室(房间号)", index = 14) + private String houseNo; + + @ExcelProperty(value = "是否租住", index = 15) + private String isRent; + + @ExcelProperty(value = "房屋状态(1.自住 2.租住 3.其他)", index = 16) + private String houseStatus; + + @ExcelProperty(value = "房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)", index = 17) + private String housePurpose; + + @ExcelProperty(value = "管控状态(1.常规 2.关注 3.管控)", index = 18) + private String controlStatus; + + @ExcelProperty(value = "入伍时间", index = 19) + private String enlistDate; + + @ExcelProperty(value = "入伍时间", index = 20) + private String retireDate; + + @ExcelProperty(value = "人员类别", index = 21) + private String personCategory; + + @ExcelProperty(value = "民族", index = 22) + private String nation; + + @ExcelProperty(value = "健康状况", index = 23) + private String healthy; + + @ExcelProperty(value = "政治面貌", index = 24) + private String politicalOutlook; + + @ExcelProperty(value = "婚姻状况", index = 25) + private String marriage; + + @ExcelProperty(value = "住房状况", index = 26) + private String houseSituation; + + @ExcelProperty(value = "住房状况其他", index = 27) + private String houseSituationOther; + + @ExcelProperty(value = "建筑面积", index = 28) + private String buildArea; + + @ExcelProperty(value = "现就业情况", index = 29) + private String employmentSituation; + + @ExcelProperty(value = "在职情况类型", index = 30) + private String incumbencyType; + + @ExcelProperty(value = "现就业情况其他", index = 31) + private String employmentSituationOther; + + @ExcelProperty(value = "养老保险", index = 32) + private String endowmentInsurance; + + @ExcelProperty(value = "医疗保险", index = 33) + private String medicalInsurance; + + @ExcelProperty(value = "现个人年收入(单位:元)", index = 34) + private String annualIncome; + + @ExcelProperty(value = "父亲健康状况", index = 35) + private String fatherHealthy; + + @ExcelProperty(value = "母亲健康状况", index = 36) + private String motherHealthy; + + @ExcelProperty(value = "配偶健康状况", index = 37) + private String spouseHealthy; + + @ExcelProperty(value = "儿子健康状况", index = 38) + private String sonHealthy; + + @ExcelProperty(value = "女儿健康状况", index = 39) + private String daughterHealthy; + + @ExcelProperty(value = "主要困难", index = 40) + private String mainDifficulty; + + @ExcelProperty(value = "其他困难", index = 41) + private String otherDifficulty; + + @ExcelProperty(value = "主要诉求", index = 42) + private String mainDemand; + + @ExcelProperty(value = "主要诉求其他事项问题(手填)", index = 43) + private String mainDemandOther; + + @ExcelProperty(value = "需参加的学历培训", index = 44) + private String academicTraining; + + @ExcelProperty(value = "是否已参加退役军人培训(政府性质)", index = 45) + private String isVeteransTraining; + + @ExcelProperty(value = "入伍前学历", index = 46) + private String educationBeforeEnlistment; + + @ExcelProperty(value = "再教育学历", index = 47) + private String reEducation; + + @ExcelProperty(value = "所学专业", index = 48) + private String major; + + @ExcelProperty(value = "所学专业其他", index = 49) + private String majorOther; + + @ExcelProperty(value = "曾从事行业(含现从事行业)", index = 50) + private String onceEngagedIndustry; + + @ExcelProperty(value = "曾从事行业(含现从事行业)其他(手填)", index = 51) + private String onceEngagedIndustryOther; + + @ExcelProperty(value = "意向就业地点", index = 52) + private String intendedPlaceOfEmployment; + + @ExcelProperty(value = "意向就业地点其他地区(手填)", index = 53) + private String intendedPlaceOfEmploymentOther; + + @ExcelProperty(value = "待业期间的求职意向", index = 54) + private String unemploymedEngagedIndustry; + + @ExcelProperty(value = "待业期间的求职意向其他(手填)", index = 55) + private String unemploymedEngagedIndustryOther; + + @ExcelProperty(value = "是否有创业意愿", index = 56) + private String isBusiness; + + @ExcelProperty(value = "创业意愿", index = 57) + private String businessDesire; + + @ExcelProperty(value = "备注", index = 58) + private String remark; + + @ExcelProperty(value = "填表单位", index = 59) + private String fillUnit; + + @ExcelProperty(value = "填表人", index = 60) + private String fillPerson; + + @ExcelProperty(value = "填表人联系电话", index = 61) + private String fillPersonPhone; + + @ExcelProperty(value = "错误信息", index = 62) + private String mistake; +} diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java index 5662218..2d66207 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/community/CommunityService.java @@ -1744,6 +1744,56 @@ R listSavePopulationCultExcelVO(@RequestBody List<ComMngPopulationCultExcelVO> list, @RequestParam(value = "communityId") Long communityId); /** + * 批量导入刑释人员 + * + * @param list 刑释人员数据 + * @param communityId 社区id + * @return 导入结果 + */ + @PostMapping("/common/data/population/importRehabilitation") + R listSavePopulationRehabilitationExcelVO(@RequestBody List<ComMngPopulationRehabilitationExcelVO> list, @RequestParam(value = "communityId") Long communityId); + + /** + * 批量导入重点上访人员 + * + * @param list 重点上访人员数据 + * @param communityId 社区id + * @return 导入结果 + */ + @PostMapping("/common/data/population/importKey") + R listSavePopulationKeyExcelVO(@RequestBody List<ComMngPopulationKeyExcelVO> list, @RequestParam(value = "communityId") Long communityId); + + /** + * 批量导入服刑人员 + * + * @param list 服刑人员数据 + * @param communityId 社区id + * @return 导入结果 + */ + @PostMapping("/common/data/population/importSentence") + R listSavePopulationSentenceExcelVO(@RequestBody List<ComMngPopulationSentenceExcelVO> list, @RequestParam(value = "communityId") Long communityId); + + /** + * 批量导入退役军人 + * + * @param list 退役军人数据 + * @param communityId 社区id + * @return 导入结果 + */ + @PostMapping("/common/data/population/importVeterans") + R listSavePopulationVeteransExcelVO(@RequestBody List<ComMngPopulationVeteransExcelVO> list, @RequestParam(value = "communityId") Long communityId); + + /** + * 批量导入残疾人 + * + * @param list 残疾人数据 + * @param communityId 社区id + * @return 导入结果 + */ + @PostMapping("/common/data/population/importDisability") + R listSavePopulationDisabilityExcelVO(@RequestBody List<ComMngPopulationDisabilityExcelVO> list, @RequestParam(value = "communityId") Long communityId); + + /** * 确认导入实有人口(有则更新,无则新建) * * @param list 用户信息 diff --git a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/BigScreenApi.java b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/BigScreenApi.java index 06b9369..4882e05 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/BigScreenApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/BigScreenApi.java @@ -41,7 +41,11 @@ @ApiOperation(value = "党员党支部统计信息", response = BigScreenStatisticPartyOrg.class) @PostMapping("/orgmembers") public R<BigScreenStatisticPartyOrg> orgmembers(@Validated @RequestBody PageBigScreenStatisticPartyOrg pageBigScreenStatisticPartyOrg){ - pageBigScreenStatisticPartyOrg.setCommunityId(2L); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + pageBigScreenStatisticPartyOrg.setCommunityId(id); return communityService.bigscreenPartyOrgmembers(pageBigScreenStatisticPartyOrg); } @@ -50,52 +54,80 @@ @GetMapping("/agegender") public R<BigScreenStatisticAgeGender> agegender(){ BigScreenStatisticAgeGenderDTO bigScreenStatisticAgeGenderDTO = new BigScreenStatisticAgeGenderDTO(); - bigScreenStatisticAgeGenderDTO.setCommunityId(2L); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + bigScreenStatisticAgeGenderDTO.setCommunityId(id); return communityService.ageGender(bigScreenStatisticAgeGenderDTO); } @ApiOperation(value = "党建数据概览", response = BigScreenStatisticPartyBuild.class) @GetMapping("/partybuild") public R<BigScreenStatisticPartyBuild> partybuild(){ - return communityService.bigscreenPartybuild(2L); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + return communityService.bigscreenPartybuild(id); } @ApiOperation(value = "党员活动(按月-最近12个月)",response = BigScreenStatisticPartyActivity.class) @PostMapping("/partyactivity") public R<List<BigScreenStatisticPartyActivity>> partyactivity(@Validated @RequestBody BigScreenStatisticPartyActivityDTO bigScreenStatisticPartyActivityDTO){ - bigScreenStatisticPartyActivityDTO.setCommunityId(2L); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + bigScreenStatisticPartyActivityDTO.setCommunityId(id); return communityService.bigscreenPartyactivity(bigScreenStatisticPartyActivityDTO); } @ApiOperation(value = "党员活动参加用户排行榜-TOP3", response = PartyBuildingMemberVO.class) @GetMapping("/partyactivitytopuser") public R<List<PartyBuildingMemberVO>> partyactivitytopuser(){ - return communityService.bigscreenPartyactivitytopuser(2L); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + return communityService.bigscreenPartyactivitytopuser(id); } @ApiOperation(value = "党建动态", response = BigScreenStatisticPartyOrg.class) @PostMapping("/partydyn") public R<BigScreenStatisticPartyOrg> partydyn(@RequestBody PartyBuildingComPbDynVO partyBuildingComPbDynVO) { - Integer type = 1; - Long communityId = 2L; +// Integer type = 1; +// Long communityId = 2L; + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } partyBuildingComPbDynVO.setType(1); - partyBuildingComPbDynVO.setCommunityId(communityId); + partyBuildingComPbDynVO.setCommunityId(id); return partyBuildingService.pageYnamic(partyBuildingComPbDynVO); } @ApiOperation(value = "社区党委", response = BigScreenStatisticPartyMemeber.class) @PostMapping("/pagePartyCommittee") public R<BigScreenStatisticPartyMemeber> pagePartyCommittee(@RequestBody PartyCommitteeVO partyCommitteeVO) { - partyCommitteeVO.setCommunityId(2L); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + partyCommitteeVO.setCommunityId(id); return partyBuildingService.pagePartyCommittee(partyCommitteeVO); } @ApiOperation(value = "党员分页查询", response = com.panzhihua.common.model.vos.partybuilding.PartyBuildingMemberVO.class) @PostMapping("/pagepartyorganization") public R pagePartyOrganization(@RequestBody PagePartyOrganizationMemberVO pagePartyOrganizationMemberVO) { + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } PagePartyOrganizationVO pagePartyOrganizationVO = new PagePartyOrganizationVO(); BeanUtils.copyProperties(pagePartyOrganizationMemberVO, pagePartyOrganizationVO); - pagePartyOrganizationVO.setCommunityId(2L); + pagePartyOrganizationVO.setCommunityId(id); return partyBuildingService.pagePartyOrganization(pagePartyOrganizationVO); } } diff --git a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/BigScreenStatisticsApi.java b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/BigScreenStatisticsApi.java index bc9df8a..39eb215 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/BigScreenStatisticsApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/BigScreenStatisticsApi.java @@ -1,5 +1,6 @@ package com.panzhihua.community_backstage.api; +import com.panzhihua.common.controller.BaseController; import com.panzhihua.common.model.dtos.community.bigscreen.BigScreenEventDTO; import com.panzhihua.common.model.dtos.community.bigscreen.BigScreenEventDetailDTO; import com.panzhihua.common.model.dtos.community.bigscreen.event.ScreenDrawEventListDTO; @@ -24,7 +25,7 @@ @Api(tags = {"大屏统计数据模块"}) @RestController @RequestMapping("/screen/") -public class BigScreenStatisticsApi { +public class BigScreenStatisticsApi extends BaseController { @Resource private CommunityService communityService; @@ -40,25 +41,28 @@ } @ApiOperation(value = "首页大屏统计接口@lyq",response = IndexStatisticsVO.class) - @GetMapping("/index/noToken") + @GetMapping("/index") public R index(@RequestParam("communityId") Long communityId) { - if(communityId == null){ - return R.fail("参数错误"); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); } - return communityService.getScreenIndex(communityId); + return communityService.getScreenIndex(id); } @ApiOperation(value = "事件大屏统计接口@lyq",response = EventStatisticsVO.class) - @PostMapping("/event/noToken") + @PostMapping("/event") public R event(@RequestBody BigScreenEventDTO screenEventDTO) { - if(screenEventDTO.getCommunityId() == null){ - return R.fail("参数错误"); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); } + screenEventDTO.setCommunityId(id); return communityService.getScreenEvent(screenEventDTO); } @ApiOperation(value = "事件大屏详情接口@lyq",response = EventNewStatisticsVO.class) - @PostMapping("/event/detail/noToken") + @PostMapping("/event/detail") public R eventDetail(@RequestBody BigScreenEventDetailDTO eventDetailDTO) { if(eventDetailDTO.getEventId() == null || eventDetailDTO.getType() == null){ return R.fail("参数错误"); @@ -67,43 +71,55 @@ } @ApiOperation(value = "民生大屏统计接口@lyq",response = CivilStatisticsVO.class) - @GetMapping("/civil/noToken") + @GetMapping("/civil") public R civil(@RequestParam("communityId") Long communityId) { - if(communityId == null){ - return R.fail("参数错误"); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); } - return communityService.getScreenCivil(communityId); + return communityService.getScreenCivil(id); } @ApiOperation(value = "获取社区网格接口@lyq",response = EventGridStatisticsVO.class) - @GetMapping("/event/grids/noToken") + @GetMapping("/event/grids") public R grids(@RequestParam("communityId") Long communityId) { - if(communityId == null){ - return R.fail("参数错误"); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); } - return communityService.getScreenGirds(communityId); + return communityService.getScreenGirds(id); } @ApiOperation(value = "事件大屏事件列表接口@lyq",response = EventListVO.class) - @PostMapping("/civil/list/noToken") + @PostMapping("/civil/list") public R eventList(@RequestBody ScreenEventListDTO eventListDTO) { - if(eventListDTO.getCommunityId() == null){ - return R.fail("参数错误"); +// if(eventListDTO.getCommunityId() == null){ +// return R.fail("参数错误"); +// } + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); } + eventListDTO.setCommunityId(id); return gridService.getScreenEventList(eventListDTO); } @ApiOperation(value = "事件大屏画圈展示事件坐标点接口@lyq",response = ScreenDrawEventVO.class) - @PostMapping("/civil/draw/list/noToken") + @PostMapping("/civil/draw/list") public R civilDrawList(@RequestBody ScreenDrawEventListDTO eventListDTO) { - if(eventListDTO.getCommunityId() == null){ - return R.fail("参数错误"); +// if(eventListDTO.getCommunityId() == null){ +// return R.fail("参数错误"); +// } + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); } + eventListDTO.setCommunityId(id); return gridService.getCivilDrawList(eventListDTO); } @ApiOperation(value = "根据小区id获取小区信息@lyq",response = ScreenDrawEventPopulationTotalVO.class) - @GetMapping("/civil/village/statistics/noToken") + @GetMapping("/civil/village/statistics") public R civilVillageStatistics(@RequestParam("villageId") Long villageId) { if(villageId == null){ return R.fail("参数错误"); @@ -112,11 +128,15 @@ } @ApiOperation(value = "获取社区网格员列表接口@lyq",response = EventGridMemberVO.class) - @GetMapping("/grids/member/noToken") + @GetMapping("/grids/member") public R getGridsMemberList(@RequestParam("communityId") Long communityId) { - if(communityId == null){ - return R.fail("参数错误"); +// if(communityId == null){ +// return R.fail("参数错误"); +// } + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); } - return userService.getGridsMemberList(communityId); + return userService.getGridsMemberList(id); } } diff --git a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java index b42b580..5721612 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java @@ -176,6 +176,96 @@ return R.ok(); } + @ApiOperation(value = "excel导入刑释人员") + @PostMapping(value = "/serve/importRehabilitation", consumes = "multipart/*", headers = "content-type=multipart/form-date") + public R importRehabilitation(@RequestParam MultipartFile file, HttpServletRequest request) { + //获取文件名 + String fileName = file.getOriginalFilename(); + log.info("传入文件名字【{}】", fileName); + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + ComMngPopulationRehabilitationExcelListen comMngPopulationRehabilitationExcelListen = new ComMngPopulationRehabilitationExcelListen(communityService, this.getCommunityId(),userName,password,host,port,excelUrl,stringRedisTemplate); + EasyExcel.read(inputStream, null, comMngPopulationRehabilitationExcelListen).sheet().doRead(); + } catch (IOException e) { + log.error("导入模板失败【{}】", e.getMessage()); + e.printStackTrace(); + } + return R.ok(); + } + + @ApiOperation(value = "excel导入重点上访人员") + @PostMapping(value = "/serve/importKey", consumes = "multipart/*", headers = "content-type=multipart/form-date") + public R importKey(@RequestParam MultipartFile file, HttpServletRequest request) { + //获取文件名 + String fileName = file.getOriginalFilename(); + log.info("传入文件名字【{}】", fileName); + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + ComMngPopulationKeyExcelListen mngPopulationKeyExcelListen = new ComMngPopulationKeyExcelListen(communityService, this.getCommunityId(),userName,password,host,port,excelUrl,stringRedisTemplate); + EasyExcel.read(inputStream, null, mngPopulationKeyExcelListen).sheet().doRead(); + } catch (IOException e) { + log.error("导入模板失败【{}】", e.getMessage()); + e.printStackTrace(); + } + return R.ok(); + } + + @ApiOperation(value = "excel导入服刑人员") + @PostMapping(value = "/serve/importSentence", consumes = "multipart/*", headers = "content-type=multipart/form-date") + public R importSentence(@RequestParam MultipartFile file, HttpServletRequest request) { + //获取文件名 + String fileName = file.getOriginalFilename(); + log.info("传入文件名字【{}】", fileName); + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + ComMngPopulationSentenceExcelListen comMngPopulationSentenceExcelListen = new ComMngPopulationSentenceExcelListen(communityService, this.getCommunityId(),userName,password,host,port,excelUrl,stringRedisTemplate); + EasyExcel.read(inputStream, null, comMngPopulationSentenceExcelListen).sheet().doRead(); + } catch (IOException e) { + log.error("导入模板失败【{}】", e.getMessage()); + e.printStackTrace(); + } + return R.ok(); + } + + @ApiOperation(value = "excel导入退役军人") + @PostMapping(value = "/serve/importVeterans", consumes = "multipart/*", headers = "content-type=multipart/form-date") + public R importVeterans(@RequestParam MultipartFile file, HttpServletRequest request) { + //获取文件名 + String fileName = file.getOriginalFilename(); + log.info("传入文件名字【{}】", fileName); + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + ComMngPopulationVeteransExcelListen comMngPopulationVeteransExcelListen = new ComMngPopulationVeteransExcelListen(communityService, this.getCommunityId(),userName,password,host,port,excelUrl,stringRedisTemplate); + EasyExcel.read(inputStream, null, comMngPopulationVeteransExcelListen).sheet().doRead(); + } catch (IOException e) { + log.error("导入模板失败【{}】", e.getMessage()); + e.printStackTrace(); + } + return R.ok(); + } + + @ApiOperation(value = "excel导入残疾人") + @PostMapping(value = "/serve/importDisability", consumes = "multipart/*", headers = "content-type=multipart/form-date") + public R importDisability(@RequestParam MultipartFile file, HttpServletRequest request) { + //获取文件名 + String fileName = file.getOriginalFilename(); + log.info("传入文件名字【{}】", fileName); + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + ComMngPopulationDisabilityExcelListen mngPopulationDisabilityExcelListen = new ComMngPopulationDisabilityExcelListen(communityService, this.getCommunityId(),userName,password,host,port,excelUrl,stringRedisTemplate); + EasyExcel.read(inputStream, null, mngPopulationDisabilityExcelListen).sheet().doRead(); + } catch (IOException e) { + log.error("导入模板失败【{}】", e.getMessage()); + e.printStackTrace(); + } + return R.ok(); + } + /** * 确认导入实有人口(有则更新,无则新建) * @@ -2166,7 +2256,7 @@ } @ApiOperation(value = "下载导入失败吸毒人员数据") - @PostMapping("/download/error/Drugpopulation") + @PostMapping("/download/error/populationDrug") public R downloadErrorDrugPopulation(@RequestParam(value = "key") String key) { List<ComMngPopulationDrugMistakeExcelVO> list = new ArrayList<>(); Boolean isExits = stringRedisTemplate.hasKey(key); @@ -2222,7 +2312,7 @@ } @ApiOperation(value = "下载导入失败社区矫正人员数据") - @PostMapping("/download/error/Correctpopulation") + @PostMapping("/download/error/populationCorrect") public R downloadErrorCorrectPopulation(@RequestParam(value = "key") String key) { List<ComMngPopulationCorrectMistakeExcelVO> list = new ArrayList<>(); Boolean isExits = stringRedisTemplate.hasKey(key); @@ -2278,7 +2368,7 @@ } @ApiOperation(value = "下载导入失败重精人员数据") - @PostMapping("/download/error/Majorpopulation") + @PostMapping("/download/error/populationMajor") public R downloadErrorMajorPopulation(@RequestParam(value = "key") String key) { List<ComMngPopulationMajorMistakeExcelVO> list = new ArrayList<>(); Boolean isExits = stringRedisTemplate.hasKey(key); @@ -2334,7 +2424,7 @@ } @ApiOperation(value = "下载导入失败邪教人员数据") - @PostMapping("/download/error/Cultpopulation") + @PostMapping("/download/error/populationCult") public R downloadErrorCultPopulation(@RequestParam(value = "key") String key) { List<ComMngPopulationCultMistakeExcelVO> list = new ArrayList<>(); Boolean isExits = stringRedisTemplate.hasKey(key); @@ -2388,4 +2478,284 @@ return R.fail(); } } + + @ApiOperation(value = "下载导入失败刑释人员数据") + @PostMapping("/download/error/populationRehabilitation") + public R downloadErrorRehabilitationPopulation(@RequestParam(value = "key") String key) { + List<ComMngPopulationRehabilitationMistakeExcelVO> list = new ArrayList<>(); + Boolean isExits = stringRedisTemplate.hasKey(key); + ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); + if(isExits){ + String json = valueOperations.get(key); + list= JSONArray.parseArray(json,ComMngPopulationRehabilitationMistakeExcelVO.class); + } +// List<ComMngPopulationMistakeExcelVO> list = JSON.parseArray(mistakes,ComMngPopulationMistakeExcelVO.class); + //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 + String ftpUrl = "/mnt/data/web/excel/"; + String nowDate = DateUtils.getCurrentDateString(); + String name = "刑释人员错误数据" + nowDate +".xlsx"; + try { + SFTPUtil sftp = new SFTPUtil(userName, password, host, port); + sftp.login(); + boolean existDir = sftp.isExistDir(ftpUrl + name); + if (!existDir) { + String property = System.getProperty("user.dir"); + String fileName = property + File.separator + name; + // 这里 需要指定写用哪个class去写 + ExcelWriter excelWriter = null; + InputStream inputStream = null; + try { + excelWriter = EasyExcel.write(fileName, ComMngPopulationRehabilitationMistakeExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("刑释人员错误数据").build(); + excelWriter.write(list, writeSheet); + excelWriter.finish(); + File file = new File(fileName); + inputStream = new FileInputStream(file); + sftp.uploadMore(ftpUrl, name, inputStream); + sftp.logout(); + inputStream.close(); + String absolutePath = file.getAbsolutePath(); + boolean delete = file.delete(); + log.info("删除excel【{}】结果【{}】", absolutePath, delete); + } finally { + // 千万别忘记finish 会帮忙关闭流 + if (inputStream != null) { + inputStream.close(); + } + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + return R.ok(excelUrl + name); + } catch (Exception e) { + e.printStackTrace(); + log.error("文件传输失败【{}】", e.getMessage()); + return R.fail(); + } + } + + @ApiOperation(value = "下载导入失败重点上访人员数据") + @PostMapping("/download/error/populationKey") + public R downloadErrorKeyPopulation(@RequestParam(value = "key") String key) { + List<ComMngPopulationKeyMistakeExcelVO> list = new ArrayList<>(); + Boolean isExits = stringRedisTemplate.hasKey(key); + ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); + if(isExits){ + String json = valueOperations.get(key); + list= JSONArray.parseArray(json,ComMngPopulationKeyMistakeExcelVO.class); + } +// List<ComMngPopulationMistakeExcelVO> list = JSON.parseArray(mistakes,ComMngPopulationMistakeExcelVO.class); + //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 + String ftpUrl = "/mnt/data/web/excel/"; + String nowDate = DateUtils.getCurrentDateString(); + String name = "重点上访人员错误数据" + nowDate +".xlsx"; + try { + SFTPUtil sftp = new SFTPUtil(userName, password, host, port); + sftp.login(); + boolean existDir = sftp.isExistDir(ftpUrl + name); + if (!existDir) { + String property = System.getProperty("user.dir"); + String fileName = property + File.separator + name; + // 这里 需要指定写用哪个class去写 + ExcelWriter excelWriter = null; + InputStream inputStream = null; + try { + excelWriter = EasyExcel.write(fileName, ComMngPopulationKeyMistakeExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("重点上访人员错误数据").build(); + excelWriter.write(list, writeSheet); + excelWriter.finish(); + File file = new File(fileName); + inputStream = new FileInputStream(file); + sftp.uploadMore(ftpUrl, name, inputStream); + sftp.logout(); + inputStream.close(); + String absolutePath = file.getAbsolutePath(); + boolean delete = file.delete(); + log.info("删除excel【{}】结果【{}】", absolutePath, delete); + } finally { + // 千万别忘记finish 会帮忙关闭流 + if (inputStream != null) { + inputStream.close(); + } + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + return R.ok(excelUrl + name); + } catch (Exception e) { + e.printStackTrace(); + log.error("文件传输失败【{}】", e.getMessage()); + return R.fail(); + } + } + + @ApiOperation(value = "下载导入失败服刑人员数据") + @PostMapping("/download/error/populationSentence") + public R downloadErrorSentencePopulation(@RequestParam(value = "key") String key) { + List<ComMngPopulationSentenceMistakeExcelVO> list = new ArrayList<>(); + Boolean isExits = stringRedisTemplate.hasKey(key); + ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); + if(isExits){ + String json = valueOperations.get(key); + list= JSONArray.parseArray(json,ComMngPopulationSentenceMistakeExcelVO.class); + } +// List<ComMngPopulationMistakeExcelVO> list = JSON.parseArray(mistakes,ComMngPopulationMistakeExcelVO.class); + //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 + String ftpUrl = "/mnt/data/web/excel/"; + String nowDate = DateUtils.getCurrentDateString(); + String name = "服刑人员错误数据" + nowDate +".xlsx"; + try { + SFTPUtil sftp = new SFTPUtil(userName, password, host, port); + sftp.login(); + boolean existDir = sftp.isExistDir(ftpUrl + name); + if (!existDir) { + String property = System.getProperty("user.dir"); + String fileName = property + File.separator + name; + // 这里 需要指定写用哪个class去写 + ExcelWriter excelWriter = null; + InputStream inputStream = null; + try { + excelWriter = EasyExcel.write(fileName, ComMngPopulationSentenceMistakeExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("服刑人员错误数据").build(); + excelWriter.write(list, writeSheet); + excelWriter.finish(); + File file = new File(fileName); + inputStream = new FileInputStream(file); + sftp.uploadMore(ftpUrl, name, inputStream); + sftp.logout(); + inputStream.close(); + String absolutePath = file.getAbsolutePath(); + boolean delete = file.delete(); + log.info("删除excel【{}】结果【{}】", absolutePath, delete); + } finally { + // 千万别忘记finish 会帮忙关闭流 + if (inputStream != null) { + inputStream.close(); + } + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + return R.ok(excelUrl + name); + } catch (Exception e) { + e.printStackTrace(); + log.error("文件传输失败【{}】", e.getMessage()); + return R.fail(); + } + } + + @ApiOperation(value = "下载导入失败退役军人数据") + @PostMapping("/download/error/populationVeterans") + public R downloadErrorVeteransPopulation(@RequestParam(value = "key") String key) { + List<ComMngPopulationVeteransMistakeExcelVO> list = new ArrayList<>(); + Boolean isExits = stringRedisTemplate.hasKey(key); + ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); + if(isExits){ + String json = valueOperations.get(key); + list= JSONArray.parseArray(json,ComMngPopulationVeteransMistakeExcelVO.class); + } +// List<ComMngPopulationMistakeExcelVO> list = JSON.parseArray(mistakes,ComMngPopulationMistakeExcelVO.class); + //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 + String ftpUrl = "/mnt/data/web/excel/"; + String nowDate = DateUtils.getCurrentDateString(); + String name = "退役军人错误数据" + nowDate +".xlsx"; + try { + SFTPUtil sftp = new SFTPUtil(userName, password, host, port); + sftp.login(); + boolean existDir = sftp.isExistDir(ftpUrl + name); + if (!existDir) { + String property = System.getProperty("user.dir"); + String fileName = property + File.separator + name; + // 这里 需要指定写用哪个class去写 + ExcelWriter excelWriter = null; + InputStream inputStream = null; + try { + excelWriter = EasyExcel.write(fileName, ComMngPopulationVeteransMistakeExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("退役军人错误数据").build(); + excelWriter.write(list, writeSheet); + excelWriter.finish(); + File file = new File(fileName); + inputStream = new FileInputStream(file); + sftp.uploadMore(ftpUrl, name, inputStream); + sftp.logout(); + inputStream.close(); + String absolutePath = file.getAbsolutePath(); + boolean delete = file.delete(); + log.info("删除excel【{}】结果【{}】", absolutePath, delete); + } finally { + // 千万别忘记finish 会帮忙关闭流 + if (inputStream != null) { + inputStream.close(); + } + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + return R.ok(excelUrl + name); + } catch (Exception e) { + e.printStackTrace(); + log.error("文件传输失败【{}】", e.getMessage()); + return R.fail(); + } + } + + @ApiOperation(value = "下载导入失败残疾人数据") + @PostMapping("/download/error/populationDisability") + public R downloadErrorDisabilityPopulation(@RequestParam(value = "key") String key) { + List<ComMngPopulationDisabilityMistakeExcelVO> list = new ArrayList<>(); + Boolean isExits = stringRedisTemplate.hasKey(key); + ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); + if(isExits){ + String json = valueOperations.get(key); + list= JSONArray.parseArray(json,ComMngPopulationDisabilityMistakeExcelVO.class); + } +// List<ComMngPopulationMistakeExcelVO> list = JSON.parseArray(mistakes,ComMngPopulationMistakeExcelVO.class); + //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 + String ftpUrl = "/mnt/data/web/excel/"; + String nowDate = DateUtils.getCurrentDateString(); + String name = "残疾人错误数据" + nowDate +".xlsx"; + try { + SFTPUtil sftp = new SFTPUtil(userName, password, host, port); + sftp.login(); + boolean existDir = sftp.isExistDir(ftpUrl + name); + if (!existDir) { + String property = System.getProperty("user.dir"); + String fileName = property + File.separator + name; + // 这里 需要指定写用哪个class去写 + ExcelWriter excelWriter = null; + InputStream inputStream = null; + try { + excelWriter = EasyExcel.write(fileName, ComMngPopulationDisabilityMistakeExcelVO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("残疾人错误数据").build(); + excelWriter.write(list, writeSheet); + excelWriter.finish(); + File file = new File(fileName); + inputStream = new FileInputStream(file); + sftp.uploadMore(ftpUrl, name, inputStream); + sftp.logout(); + inputStream.close(); + String absolutePath = file.getAbsolutePath(); + boolean delete = file.delete(); + log.info("删除excel【{}】结果【{}】", absolutePath, delete); + } finally { + // 千万别忘记finish 会帮忙关闭流 + if (inputStream != null) { + inputStream.close(); + } + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + return R.ok(excelUrl + name); + } catch (Exception e) { + e.printStackTrace(); + log.error("文件传输失败【{}】", e.getMessage()); + return R.fail(); + } + } } diff --git a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenPopulationApi.java b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenPopulationApi.java index a758746..8ab09ef 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenPopulationApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenPopulationApi.java @@ -22,7 +22,7 @@ @Slf4j @Api(tags = {"大屏-人口"}) @RestController -@RequestMapping("/screen/population/noToken") +@RequestMapping("/screen/population/") public class ScreenPopulationApi extends BaseController { @Resource @@ -31,8 +31,11 @@ @ApiOperation(value = "人口@xyh",response = ComActPopulationScreenVO.class) @GetMapping("/statistic") public R statistic(@RequestParam("communityId") Long communityId){ - - return communityService.statistic(communityId); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + return communityService.statistic(id); } diff --git a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenWorkApi.java b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenWorkApi.java index 65e4ff5..c1d7a84 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenWorkApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/ScreenWorkApi.java @@ -36,7 +36,7 @@ @Slf4j @Api(tags = {"大屏-工作"}) @RestController -@RequestMapping("/screen/work/noToken") +@RequestMapping("/screen/work") public class ScreenWorkApi extends BaseController { @Resource @@ -52,8 +52,11 @@ @ApiOperation(value = "邻里圈@xyh",response = ComActNeighborCircleScreenVO.class) @GetMapping("/eighborCircle") public R statisticNeighborCircle(@RequestParam("communityId") Long communityId){ - - return communityService.statisticNeighborCircle(communityId); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + return communityService.statisticNeighborCircle(id); } /** @@ -64,8 +67,11 @@ @ApiOperation(value = "微心愿@xyh",response = ComActMicroWishScreenVO.class) @GetMapping("/wish") public R wish(@RequestParam("communityId") Long communityId){ - - return communityService.wish(communityId); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + return communityService.wish(id); } /** @@ -76,8 +82,11 @@ @ApiOperation(value = "社区活动@xyh",response = ComActActivityScreenVO.class) @GetMapping("/activity") public R activity(@RequestParam("communityId") Long communityId){ - - return communityService.activity(communityId); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + return communityService.activity(id); } /** @@ -88,8 +97,11 @@ @ApiOperation(value = "一起议@xyh",response = ComActDiscussScreenVO.class) @GetMapping("/discuss") public R discuss(@RequestParam("communityId") Long communityId){ - - return communityService.discuss(communityId); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + return communityService.discuss(id); } /** @@ -100,20 +112,31 @@ @ApiOperation(value = "党建工作@xyh",response = ComPbWorkScreenVO.class) @GetMapping("/pbWork") public R pbWork(@RequestParam("communityId") Long communityId){ - - return communityService.pbWork(communityId); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + return communityService.pbWork(id); } @ApiOperation(value = "社区动态@lyq",response = ComDynamicWorkScreenVO.class) @GetMapping("/dynamicWork") public R dynamicWork(@RequestParam("communityId") Long communityId){ - return communityService.dynamicWork(communityId); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + return communityService.dynamicWork(id); } @ApiOperation(value = "事件管理@lyq",response = EventWorkScreenVO.class) @GetMapping("/eventWork") public R eventWork(@RequestParam("communityId") Long communityId){ - return gridService.eventWork(communityId); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + return gridService.eventWork(id); } /** @@ -124,8 +147,11 @@ @ApiOperation(value = "随手拍@xyh",response = ComActEasyPhotoScreenVO.class) @GetMapping("/easyPhoto") public R easyPhoto(@RequestParam("communityId") Long communityId){ - - return communityService.easyPhoto(communityId); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + return communityService.easyPhoto(id); } /** @@ -136,25 +162,39 @@ @ApiOperation(value = "工作情况@xyh",response = ComActWorkScreenVO.class) @GetMapping("/workCount") public R workCount(@RequestParam("communityId") Long communityId){ - return communityService.workCount(communityId); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); + } + return communityService.workCount(id); } @ApiOperation(value = "工作大屏一起议列表接口@lyq",response = DiscussListVO.class) @PostMapping("/discuss/list") public R discussList(@RequestBody ScreenDiscussListDTO discussListDTO) { - if(discussListDTO.getCommunityId() == null){ - return R.fail("参数错误"); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); } + discussListDTO.setCommunityId(id); +// if(discussListDTO.getCommunityId() == null){ +// return R.fail("参数错误"); +// } return communityService.getScreenDiscussList(discussListDTO); } @ApiOperation(value = "工作大屏社区活动列表接口@lyq",response = ActActivityListVO.class) @PostMapping("/act/activity/list") public R actActivityList(@RequestBody ScreenActActivityListDTO actActivityListDTO) { - if(actActivityListDTO.getCommunityId() == null){ - return R.fail("参数错误"); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); } + actActivityListDTO.setCommunityId(id); +// if(actActivityListDTO.getCommunityId() == null){ +// return R.fail("参数错误"); +// } return communityService.getScreenActActivityList(actActivityListDTO); } @@ -167,18 +207,28 @@ @ApiOperation(value = "工作大屏微心愿列表接口@lyq",response = MicroListVO.class) @PostMapping("/micro/list") public R microList(@RequestBody ScreenMicroListDTO microListDTO) { - if(microListDTO.getCommunityId() == null){ - return R.fail("参数错误"); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); } + microListDTO.setCommunityId(id); +// if(microListDTO.getCommunityId() == null){ +// return R.fail("参数错误"); +// } return communityService.getScreenMicroList(microListDTO); } @ApiOperation(value = "工作大屏邻里圈列表接口@lyq",response = ComActNeighborCircleAdminVO.class) @PostMapping("/neighbor/list") public R neighborList(@RequestBody ComActNeighborCircleAdminDTO neighborCircleAdminDTO) { - if(neighborCircleAdminDTO.getCommunityId() == null){ - return R.fail("参数错误"); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); } + neighborCircleAdminDTO.setCommunityId(id); +// if(neighborCircleAdminDTO.getCommunityId() == null){ +// return R.fail("参数错误"); +// } return communityService.pageNeighborByAdmin(neighborCircleAdminDTO); } @@ -209,14 +259,19 @@ @ApiOperation(value = "分页查询社区动态", response = ComActDynVO.class) @PostMapping("pagedynamic") public R pageDynamic(@RequestBody ComActDynVO comActDynVO) { - if(comActDynVO.getCommunityId() == null){ - return R.fail("参数错误"); + Long id = this.getCommunityId(); + if(id == null){ + return R.fail(401,"请先登录"); } + comActDynVO.setCommunityId(id); +// if(comActDynVO.getCommunityId() == null){ +// return R.fail("参数错误"); +// } return communityService.pageDynamicByAdmin(comActDynVO); } @ApiOperation(value = "社区动态详情", response = ComActDynVO.class) - @GetMapping("detaildynamic") + @GetMapping("/detaildynamic") @ApiImplicitParam(name = "id", value = "社区动态主键", required = true) public R detailDynamic(@RequestParam("id") Long id) { return communityService.detailDynamic(id); diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommonDataApi.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommonDataApi.java index 9eef09f..0f09633 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommonDataApi.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommonDataApi.java @@ -382,6 +382,71 @@ } /** + * 批量导入刑释人员 + * + * @param list 刑释人员数据 + * @param communityId 社区id + * @return 导入结果 + */ + @PostMapping("population/importRehabilitation") + @Transactional(rollbackFor = Exception.class) + public R listSavePopulationRehabilitationExcelVO(@RequestBody List<ComMngPopulationRehabilitationExcelVO> list, @RequestParam(value = "communityId") Long communityId){ + return comMngPopulationService.listSaveRehabilitationPopulation(list, communityId); + } + + /** + * 批量导入重点上访人员 + * + * @param list 重点上访人员数据 + * @param communityId 社区id + * @return 导入结果 + */ + @Transactional(rollbackFor = Exception.class) + @PostMapping("population/importKey") + public R listSavePopulationKeyExcelVO(@RequestBody List<ComMngPopulationKeyExcelVO> list, @RequestParam(value = "communityId") Long communityId){ + return comMngPopulationService.listSaveKeyPopulation(list, communityId); + } + + /** + * 批量导入服刑人员 + * + * @param list 服刑人员数据 + * @param communityId 社区id + * @return 导入结果 + */ + @Transactional(rollbackFor = Exception.class) + @PostMapping("population/importSentence") + public R listSavePopulationSentenceExcelVO(@RequestBody List<ComMngPopulationSentenceExcelVO> list, @RequestParam(value = "communityId") Long communityId){ + return comMngPopulationService.listSaveSentencePopulation(list, communityId); + } + + /** + * 批量导入退役军人 + * + * @param list 退役军人数据 + * @param communityId 社区id + * @return 导入结果 + */ + @Transactional(rollbackFor = Exception.class) + @PostMapping("population/importVeterans") + public R listSavePopulationVeteransExcelVO(@RequestBody List<ComMngPopulationVeteransExcelVO> list, @RequestParam(value = "communityId") Long communityId){ + return comMngPopulationService.listSaveVeteransPopulation(list, communityId); + } + + /** + * 批量导入残疾人 + * + * @param list 残疾人数据 + * @param communityId 社区id + * @return 导入结果 + */ + @Transactional(rollbackFor = Exception.class) + @PostMapping("population/importDisability") + public R listSavePopulationDisabilityExcelVO(@RequestBody List<ComMngPopulationDisabilityExcelVO> list, @RequestParam(value = "communityId") Long communityId){ + return comMngPopulationService.listSaveDisabilityPopulation(list, communityId); + } + + /** * 确认导入实有人口(有则更新,无则新建) * * @param list 用户信息 diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationService.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationService.java index ecf66ca..ab8aad6 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationService.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationService.java @@ -116,6 +116,50 @@ */ R listSaveCultPopulation(List<ComMngPopulationCultExcelVO> list, Long communityId); + /** + * 批量导入刑释人员 + * + * @param list 刑释人员数据 + * @param communityId 社区id + * @return 导入结果 + */ + R listSaveRehabilitationPopulation(List<ComMngPopulationRehabilitationExcelVO> list, Long communityId); + + /** + * 批量导入重点上访人员 + * + * @param list 重点上访人员数据 + * @param communityId 社区id + * @return 导入结果 + */ + R listSaveKeyPopulation(List<ComMngPopulationKeyExcelVO> list, Long communityId); + + /** + * 批量导入服刑人员 + * + * @param list 服刑人员数据 + * @param communityId 社区id + * @return 导入结果 + */ + R listSaveSentencePopulation(List<ComMngPopulationSentenceExcelVO> list, Long communityId); + + /** + * 批量导入退役军人 + * + * @param list 退役军人数据 + * @param communityId 社区id + * @return 导入结果 + */ + R listSaveVeteransPopulation(List<ComMngPopulationVeteransExcelVO> list, Long communityId); + + /** + * 批量导入残疾人 + * + * @param list 残疾人数据 + * @param communityId 社区id + * @return 导入结果 + */ + R listSaveDisabilityPopulation(List<ComMngPopulationDisabilityExcelVO> list, Long communityId); /** * 确认导入实有人口(有则更新,无则新建) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java index 3b29d58..fc9edcd 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActActivityServiceImpl.java @@ -554,7 +554,7 @@ WxUtil.sendSubscribeHDJJKS(openid,accessToken,actActivity.getActivityName() , com.panzhihua.common.utlis.DateUtils.format(actActivity.getBeginAt() ,com.panzhihua.common.utlis.DateUtils.ymdhms_format),actActivity.getActivityAddr() - ,actSignList.size()+"人"); + ,actSignList.size()+""); } }); diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java index c5154f7..0c05d3c 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java @@ -1,17 +1,14 @@ package com.panzhihua.service_community.service.impl; import cn.hutool.core.util.IdcardUtil; -import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.base.Joiner; import com.google.common.collect.Lists; -import com.panzhihua.common.constants.Constants; import com.panzhihua.common.enums.*; import com.panzhihua.common.exceptions.ServiceException; import com.panzhihua.common.model.dtos.community.*; @@ -21,12 +18,10 @@ import com.panzhihua.common.model.dtos.grid.PagePopulationListDTO; import com.panzhihua.common.model.dtos.grid.admin.ComMngPopulationExportDTO; import com.panzhihua.common.model.dtos.grid.admin.ComMngPopulationListDTO; -import com.panzhihua.common.model.dtos.grid.admin.ComMngPopulationSubordinateDTO; import com.panzhihua.common.model.dtos.grid.admin.PageComMngVillagePopulationDTO; import com.panzhihua.common.model.dtos.user.PageInputUserDTO; import com.panzhihua.common.model.helper.AESUtil; import com.panzhihua.common.model.vos.R; -import com.panzhihua.common.model.vos.area.AreaAddressVO; import com.panzhihua.common.model.vos.community.*; import com.panzhihua.common.model.vos.community.bigscreen.BigScreenStatisticPartyBuild; import com.panzhihua.common.model.vos.community.screen.civil.CivilPopulationStatisticsVO; @@ -38,7 +33,6 @@ import com.panzhihua.common.model.vos.grid.*; import com.panzhihua.common.model.vos.grid.admin.ComMngPopulationListVO; import com.panzhihua.common.model.vos.grid.admin.ComMngPopulationVillageVO; -import com.panzhihua.common.model.vos.grid.admin.ComMngSubordinateVO; import com.panzhihua.common.model.vos.grid.admin.excel.ComMngPopulationExportExcelVO; import com.panzhihua.common.model.vos.screen.ComActPopulationCultureVO; import com.panzhihua.common.model.vos.screen.ComActPopulationScreenVO; @@ -319,6 +313,10 @@ iPage.getRecords().forEach(populDO -> { if (StringUtils.isNotEmpty(populDO.getBirthday())) { populDO.setAge(AgeUtils.getAgeFromBirthTimes(populDO.getBirthday())); + populDO.setRelationName(PopulRelationEnum.getCnDescByName(populDO.getRelation())); + populDO.setCultureLevelName(PopulCultureLevelEnum.getCnDescByName(populDO.getCultureLevel())); + populDO.setPoliticalOutlookName(PopulPoliticalOutlookEnum.getCnDescByName(populDO.getPoliticalOutlook())); + populDO.setMarriageName(PopulMarriageEnum.getCnDescByName(populDO.getMarriage())); } }); } @@ -969,6 +967,7 @@ } @Override + @Transactional(rollbackFor = Exception.class) public R listSaveMajorPopulation(List<ComMngPopulationMajorExcelVO> list, Long communityId) { //需要新增的房屋集合 List<ComMngPopulationHouseDO> houseList = new ArrayList<>(); @@ -1171,6 +1170,7 @@ } @Override + @Transactional(rollbackFor = Exception.class) public R listSaveCultPopulation(List<ComMngPopulationCultExcelVO> list, Long communityId) { //需要新增的房屋集合 List<ComMngPopulationHouseDO> houseList = new ArrayList<>(); @@ -1372,6 +1372,1021 @@ return R.ok(mistakes); } + @Override + @Transactional(rollbackFor = Exception.class) + public R listSaveRehabilitationPopulation(List<ComMngPopulationRehabilitationExcelVO> list, Long communityId) { + //需要新增的房屋集合 + List<ComMngPopulationHouseDO> houseList = new ArrayList<>(); + //需要新增的人口集合 + List<ComMngPopulationDO> saveList = new ArrayList<>(); + //需要修改的人口集合 + List<ComMngPopulationDO> updateList = new ArrayList<>(); + //需要新增的人口与房屋关系集合 + List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>(); + + log.info("开始处理导入数据"); + List<ComMngPopulationRehabilitationMistakeExcelVO> mistakes = new ArrayList<>(); + try { + //查询社区信息 + log.info("开始查询社区信息数据"); + ComPopulationActVO populationActVO = comActDAO.getPopulationActById(communityId); + if(populationActVO == null){ + log.error("未查询到社区信息"); + return R.fail("未查询到社区信息"); + } + log.info("开始查询社区信息数据完成"); + + //查询当前社区标签列表 + List<String> labelList = new ArrayList<>(); + List<ComMngUserTagDO> comMngUserTagDOS = comMngUserTagDAO.selectList(new QueryWrapper<ComMngUserTagDO>().eq("sys_flag", 1).or().eq("community_id", communityId)); + if (!ObjectUtils.isEmpty(comMngUserTagDOS)) { + labelList = comMngUserTagDOS.stream().map(comMngUserTagDO -> comMngUserTagDO.getTagName()).collect(Collectors.toList()); + } + + StringBuilder areaPath = new StringBuilder(); + areaPath.append(populationActVO.getProvinceName()).append(">").append(populationActVO.getCityName()).append(">").append(populationActVO.getDistrictName()).append(">"); + //处理实有人口信息 + Integer nub = 1; + + //查询所有人口数据放入HashMap中 + List<ComMngPopulationDO> populationList = this.baseMapper.selectList(null); + HashMap<String,Object> populationMap = new HashMap<>(); + populationList.forEach(population -> { + String key = population.getCardNo(); + populationMap.put(key,population); + }); + //查询所有房屋信息放入到HashMap中 + List<ComMngPopulationHouseDO> houseLists = comMngPopulationHouseDAO.selectList(null); + HashMap<String,Object> houseMap = new HashMap<>(); + houseLists.forEach(house -> { + String key = house.getCommunityId() + house.getVillageId() + house.getFloor() + house.getUnitNo() + house.getHouseNo(); + houseMap.put(key,house); + }); + + List<ComMngVillageDO> villageList = comActVillageDAO.selectList(null); + HashMap<String,Object> villageMap = new HashMap<>(); + villageList.forEach(village -> { + String key = village.getCommunityId() + village.getAlley() + village.getHouseNum(); + villageMap.put(key,village); + }); + + List<ComMngPopulationHouseUserDO> houseUserLists = comMngPopulationHouseUserDAO.selectList(null); + HashMap<String,Object> houseUserMap = new HashMap<>(); + houseUserLists.forEach(houseUser -> { + String key = houseUser.getPopulId() + houseUser.getHouseId() + ""; + houseUserMap.put(key,houseUser); + }); + + + for (ComMngPopulationRehabilitationExcelVO vo : list) { + if (vo.getDoorNo().contains("号")) { + vo.setDoorNo(vo.getDoorNo().replace("号","")); + } + if(vo.getFloor().contains("栋")){ + vo.setFloor(vo.getFloor().replace("栋","")); + } + if(vo.getUnitNo().contains("单元")){ + vo.setUnitNo(vo.getUnitNo().replace("单元","")); + } + if(vo.getHouseNo().contains("号")){ + vo.setHouseNo(vo.getHouseNo().replace("号","")); + } + log.info("开始查询小区街路巷是否存在"); + //查询小区街路巷是否存在 + ComMngVillageDO comMngVillageDO = null; + String villageKey = communityId + vo.getRoad() + vo.getDoorNo(); + if(!isOnly(villageKey,villageMap)){ + comMngVillageDO = (ComMngVillageDO)villageMap.get(villageKey); + }else{ + ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); + BeanUtils.copyProperties(vo,mistake); + setRehabilitationMistake(mistake, vo); + mistake.setMistake("街路巷或小区号不存在,请先在“小区管理”中添加该小区:街路巷:"+ vo.getRoad() +",小区号:" + vo.getDoorNo()); + mistakes.add(mistake); + log.info("未查询到街路巷:"+ vo.getRoad() +",小区号:" + vo.getDoorNo()); + continue; + } + StringBuilder address = new StringBuilder(); + address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName()) + .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋") + .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号"); + + vo.setAddress(address.toString()); + log.info("开始查询小区街路巷是否存在完成"); + + log.info("开始查询房屋是否存在"); + //先判断房屋是否存在 + ComMngPopulationHouseDO populationHouseDO = null; + String houseKey = communityId + comMngVillageDO.getVillageId() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo(); + if(isOnly(houseKey,houseMap)){ + if(!houseList.isEmpty()){ + for (ComMngPopulationHouseDO house:houseList) { + if(house.getVillageId().equals(comMngVillageDO.getVillageId()) && house.getCommunityId().equals(communityId) + && house.getFloor().equals(vo.getFloor()) && house.getUnitNo().equals(vo.getUnitNo()) + && house.getHouseNo().equals(vo.getHouseNo())){ + populationHouseDO = house; + break; + } + } + } + if(populationHouseDO == null){ + //房屋信息不存在建立房屋信息 + populationHouseDO = saveRehabilitationPopulationHouse(vo, comMngVillageDO, communityId, areaPath, populationActVO.getName()); + houseList.add(populationHouseDO); + } + }else{ + populationHouseDO = (ComMngPopulationHouseDO)houseMap.get(houseKey); + } + vo.setHouseId(populationHouseDO.getId()); + log.info("开始查询房屋是否存在完成"); + + if (StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())) { + //空户处理完房屋信息,直接返回 + continue; + } + String cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey); + //判断实有人口是否已存在 + log.info("开始查询实有人口是否已存在"); + ComMngPopulationDO populationDO = null; + String populationKey = vo.getCardNo(); + if(!isOnly(populationKey,populationMap)){ + //存在实有人口信息,则更新 + populationDO = (ComMngPopulationDO)populationMap.get(populationKey); + ComMngPopulationDO updatePopulationDO = updateRehabilitationPopulationDO(vo,populationDO,labelList); + updateList.add(updatePopulationDO); + }else{ + //不存在实有人口,则新增 + populationDO = saveRehabilitationPopulationDO(vo, populationActVO, comMngVillageDO,labelList); + saveList.add(populationDO); + } + log.info("开始查询实有人口是否已存在完成"); + + log.info("开始查询实有人口房屋居住信息"); + //处理实有人口房屋居住信息 + if (populationDO != null) { + ComMngPopulationHouseUserDO populationHouseUserDO = null; + String houseUserKey = populationDO.getId() + populationHouseDO.getId() + ""; + if(isOnly(houseUserKey,houseUserMap)){ + populationHouseUserDO = new ComMngPopulationHouseUserDO(); + populationHouseUserDO.setId(Snowflake.getId()); + populationHouseUserDO.setHouseId(populationHouseDO.getId()); + populationHouseUserDO.setPopulId(populationDO.getId()); +// populationHouseUserDO.setRelation(vo.getRelation()); + populationHouseUserDO.setRelationId(vo.getIsRent()); +// populationHouseUserDO.setResidence(vo.getResidence()); + houseUserList.add(populationHouseUserDO); + } + } + log.info("开始查询实有人口房屋居住信息完成"); + } + }catch (Exception e){ + log.info("出现错误,错误原因:" + e.getMessage()); + } + log.info("处理完成导入数据"); + + log.info("开始执行数据库导入"); + if(!houseList.isEmpty()){ + log.info("执行数据库导入房屋"); + comMngPopulationHouseDAO.insertAll(houseList); + log.info("执行数据库导入房屋完成"); + } + if(!saveList.isEmpty()){ + log.info("执行数据库导入人口"); + this.baseMapper.insertAll(saveList); + log.info("执行数据库导入人口完成"); + } + if(!updateList.isEmpty()){ + log.info("执行数据库更新人口"); + this.baseMapper.updateAll(updateList); +// this.updateBatchById(updateList); + log.info("执行数据库更新人口完成"); + } + if(!houseUserList.isEmpty()){ + log.info("执行数据库导入人口房屋关系"); + comMngPopulationHouseUserService.saveBatch(houseUserList); + log.info("执行数据库导入人口房屋关系完成"); + } + log.info("执行数据库导入完成"); + + if (!mistakes.isEmpty()) { + log.info("返回错误数据"); + return R.fail(mistakes); + } + return R.ok(mistakes); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public R listSaveKeyPopulation(List<ComMngPopulationKeyExcelVO> list, Long communityId) { + //需要新增的房屋集合 + List<ComMngPopulationHouseDO> houseList = new ArrayList<>(); + //需要新增的人口集合 + List<ComMngPopulationDO> saveList = new ArrayList<>(); + //需要修改的人口集合 + List<ComMngPopulationDO> updateList = new ArrayList<>(); + //需要新增的人口与房屋关系集合 + List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>(); + + log.info("开始处理导入数据"); + List<ComMngPopulationKeyMistakeExcelVO> mistakes = new ArrayList<>(); + try { + //查询社区信息 + log.info("开始查询社区信息数据"); + ComPopulationActVO populationActVO = comActDAO.getPopulationActById(communityId); + if(populationActVO == null){ + log.error("未查询到社区信息"); + return R.fail("未查询到社区信息"); + } + log.info("开始查询社区信息数据完成"); + + //查询当前社区标签列表 + List<String> labelList = new ArrayList<>(); + List<ComMngUserTagDO> comMngUserTagDOS = comMngUserTagDAO.selectList(new QueryWrapper<ComMngUserTagDO>().eq("sys_flag", 1).or().eq("community_id", communityId)); + if (!ObjectUtils.isEmpty(comMngUserTagDOS)) { + labelList = comMngUserTagDOS.stream().map(comMngUserTagDO -> comMngUserTagDO.getTagName()).collect(Collectors.toList()); + } + + StringBuilder areaPath = new StringBuilder(); + areaPath.append(populationActVO.getProvinceName()).append(">").append(populationActVO.getCityName()).append(">").append(populationActVO.getDistrictName()).append(">"); + //处理实有人口信息 + Integer nub = 1; + + //查询所有人口数据放入HashMap中 + List<ComMngPopulationDO> populationList = this.baseMapper.selectList(null); + HashMap<String,Object> populationMap = new HashMap<>(); + populationList.forEach(population -> { + String key = population.getCardNo(); + populationMap.put(key,population); + }); + //查询所有房屋信息放入到HashMap中 + List<ComMngPopulationHouseDO> houseLists = comMngPopulationHouseDAO.selectList(null); + HashMap<String,Object> houseMap = new HashMap<>(); + houseLists.forEach(house -> { + String key = house.getCommunityId() + house.getVillageId() + house.getFloor() + house.getUnitNo() + house.getHouseNo(); + houseMap.put(key,house); + }); + + List<ComMngVillageDO> villageList = comActVillageDAO.selectList(null); + HashMap<String,Object> villageMap = new HashMap<>(); + villageList.forEach(village -> { + String key = village.getCommunityId() + village.getAlley() + village.getHouseNum(); + villageMap.put(key,village); + }); + + List<ComMngPopulationHouseUserDO> houseUserLists = comMngPopulationHouseUserDAO.selectList(null); + HashMap<String,Object> houseUserMap = new HashMap<>(); + houseUserLists.forEach(houseUser -> { + String key = houseUser.getPopulId() + houseUser.getHouseId() + ""; + houseUserMap.put(key,houseUser); + }); + + + for (ComMngPopulationKeyExcelVO vo : list) { + if (vo.getDoorNo().contains("号")) { + vo.setDoorNo(vo.getDoorNo().replace("号","")); + } + if(vo.getFloor().contains("栋")){ + vo.setFloor(vo.getFloor().replace("栋","")); + } + if(vo.getUnitNo().contains("单元")){ + vo.setUnitNo(vo.getUnitNo().replace("单元","")); + } + if(vo.getHouseNo().contains("号")){ + vo.setHouseNo(vo.getHouseNo().replace("号","")); + } + log.info("开始查询小区街路巷是否存在"); + //查询小区街路巷是否存在 + ComMngVillageDO comMngVillageDO = null; + String villageKey = communityId + vo.getRoad() + vo.getDoorNo(); + if(!isOnly(villageKey,villageMap)){ + comMngVillageDO = (ComMngVillageDO)villageMap.get(villageKey); + }else{ + ComMngPopulationKeyMistakeExcelVO mistake = new ComMngPopulationKeyMistakeExcelVO(); + BeanUtils.copyProperties(vo,mistake); + setKeyMistake(mistake, vo); + mistake.setMistake("街路巷或小区号不存在,请先在“小区管理”中添加该小区:街路巷:"+ vo.getRoad() +",小区号:" + vo.getDoorNo()); + mistakes.add(mistake); + log.info("未查询到街路巷:"+ vo.getRoad() +",小区号:" + vo.getDoorNo()); + continue; + } + StringBuilder address = new StringBuilder(); + address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName()) + .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋") + .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号"); + + vo.setAddress(address.toString()); + log.info("开始查询小区街路巷是否存在完成"); + + log.info("开始查询房屋是否存在"); + //先判断房屋是否存在 + ComMngPopulationHouseDO populationHouseDO = null; + String houseKey = communityId + comMngVillageDO.getVillageId() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo(); + if(isOnly(houseKey,houseMap)){ + if(!houseList.isEmpty()){ + for (ComMngPopulationHouseDO house:houseList) { + if(house.getVillageId().equals(comMngVillageDO.getVillageId()) && house.getCommunityId().equals(communityId) + && house.getFloor().equals(vo.getFloor()) && house.getUnitNo().equals(vo.getUnitNo()) + && house.getHouseNo().equals(vo.getHouseNo())){ + populationHouseDO = house; + break; + } + } + } + if(populationHouseDO == null){ + //房屋信息不存在建立房屋信息 + populationHouseDO = saveKeyPopulationHouse(vo, comMngVillageDO, communityId, areaPath, populationActVO.getName()); + houseList.add(populationHouseDO); + } + }else{ + populationHouseDO = (ComMngPopulationHouseDO)houseMap.get(houseKey); + } + vo.setHouseId(populationHouseDO.getId()); + log.info("开始查询房屋是否存在完成"); + + if (StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())) { + //空户处理完房屋信息,直接返回 + continue; + } + String cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey); + //判断实有人口是否已存在 + log.info("开始查询实有人口是否已存在"); + ComMngPopulationDO populationDO = null; + String populationKey = vo.getCardNo(); + if(!isOnly(populationKey,populationMap)){ + //存在实有人口信息,则更新 + populationDO = (ComMngPopulationDO)populationMap.get(populationKey); + ComMngPopulationDO updatePopulationDO = updateKeyPopulationDO(vo,populationDO,labelList); + updateList.add(updatePopulationDO); + }else{ + //不存在实有人口,则新增 + populationDO = saveKeyPopulationDO(vo, populationActVO, comMngVillageDO,labelList); + saveList.add(populationDO); + } + log.info("开始查询实有人口是否已存在完成"); + + log.info("开始查询实有人口房屋居住信息"); + //处理实有人口房屋居住信息 + if (populationDO != null) { + ComMngPopulationHouseUserDO populationHouseUserDO = null; + String houseUserKey = populationDO.getId() + populationHouseDO.getId() + ""; + if(isOnly(houseUserKey,houseUserMap)){ + populationHouseUserDO = new ComMngPopulationHouseUserDO(); + populationHouseUserDO.setId(Snowflake.getId()); + populationHouseUserDO.setHouseId(populationHouseDO.getId()); + populationHouseUserDO.setPopulId(populationDO.getId()); +// populationHouseUserDO.setRelation(vo.getRelation()); + populationHouseUserDO.setRelationId(vo.getIsRent()); +// populationHouseUserDO.setResidence(vo.getResidence()); + houseUserList.add(populationHouseUserDO); + } + } + log.info("开始查询实有人口房屋居住信息完成"); + } + }catch (Exception e){ + log.info("出现错误,错误原因:" + e.getMessage()); + } + log.info("处理完成导入数据"); + + log.info("开始执行数据库导入"); + if(!houseList.isEmpty()){ + log.info("执行数据库导入房屋"); + comMngPopulationHouseDAO.insertAll(houseList); + log.info("执行数据库导入房屋完成"); + } + if(!saveList.isEmpty()){ + log.info("执行数据库导入人口"); + this.baseMapper.insertAll(saveList); + log.info("执行数据库导入人口完成"); + } + if(!updateList.isEmpty()){ + log.info("执行数据库更新人口"); + this.baseMapper.updateAll(updateList); +// this.updateBatchById(updateList); + log.info("执行数据库更新人口完成"); + } + if(!houseUserList.isEmpty()){ + log.info("执行数据库导入人口房屋关系"); + comMngPopulationHouseUserService.saveBatch(houseUserList); + log.info("执行数据库导入人口房屋关系完成"); + } + log.info("执行数据库导入完成"); + + if (!mistakes.isEmpty()) { + log.info("返回错误数据"); + return R.fail(mistakes); + } + return R.ok(mistakes); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public R listSaveSentencePopulation(List<ComMngPopulationSentenceExcelVO> list, Long communityId) { + //需要新增的房屋集合 + List<ComMngPopulationHouseDO> houseList = new ArrayList<>(); + //需要新增的人口集合 + List<ComMngPopulationDO> saveList = new ArrayList<>(); + //需要修改的人口集合 + List<ComMngPopulationDO> updateList = new ArrayList<>(); + //需要新增的人口与房屋关系集合 + List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>(); + + log.info("开始处理导入数据"); + List<ComMngPopulationSentenceMistakeExcelVO> mistakes = new ArrayList<>(); + try { + //查询社区信息 + log.info("开始查询社区信息数据"); + ComPopulationActVO populationActVO = comActDAO.getPopulationActById(communityId); + if(populationActVO == null){ + log.error("未查询到社区信息"); + return R.fail("未查询到社区信息"); + } + log.info("开始查询社区信息数据完成"); + + //查询当前社区标签列表 + List<String> labelList = new ArrayList<>(); + List<ComMngUserTagDO> comMngUserTagDOS = comMngUserTagDAO.selectList(new QueryWrapper<ComMngUserTagDO>().eq("sys_flag", 1).or().eq("community_id", communityId)); + if (!ObjectUtils.isEmpty(comMngUserTagDOS)) { + labelList = comMngUserTagDOS.stream().map(comMngUserTagDO -> comMngUserTagDO.getTagName()).collect(Collectors.toList()); + } + + StringBuilder areaPath = new StringBuilder(); + areaPath.append(populationActVO.getProvinceName()).append(">").append(populationActVO.getCityName()).append(">").append(populationActVO.getDistrictName()).append(">"); + //处理实有人口信息 + Integer nub = 1; + + //查询所有人口数据放入HashMap中 + List<ComMngPopulationDO> populationList = this.baseMapper.selectList(null); + HashMap<String,Object> populationMap = new HashMap<>(); + populationList.forEach(population -> { + String key = population.getCardNo(); + populationMap.put(key,population); + }); + //查询所有房屋信息放入到HashMap中 + List<ComMngPopulationHouseDO> houseLists = comMngPopulationHouseDAO.selectList(null); + HashMap<String,Object> houseMap = new HashMap<>(); + houseLists.forEach(house -> { + String key = house.getCommunityId() + house.getVillageId() + house.getFloor() + house.getUnitNo() + house.getHouseNo(); + houseMap.put(key,house); + }); + + List<ComMngVillageDO> villageList = comActVillageDAO.selectList(null); + HashMap<String,Object> villageMap = new HashMap<>(); + villageList.forEach(village -> { + String key = village.getCommunityId() + village.getAlley() + village.getHouseNum(); + villageMap.put(key,village); + }); + + List<ComMngPopulationHouseUserDO> houseUserLists = comMngPopulationHouseUserDAO.selectList(null); + HashMap<String,Object> houseUserMap = new HashMap<>(); + houseUserLists.forEach(houseUser -> { + String key = houseUser.getPopulId() + houseUser.getHouseId() + ""; + houseUserMap.put(key,houseUser); + }); + + + for (ComMngPopulationSentenceExcelVO vo : list) { + if (vo.getDoorNo().contains("号")) { + vo.setDoorNo(vo.getDoorNo().replace("号","")); + } + if(vo.getFloor().contains("栋")){ + vo.setFloor(vo.getFloor().replace("栋","")); + } + if(vo.getUnitNo().contains("单元")){ + vo.setUnitNo(vo.getUnitNo().replace("单元","")); + } + if(vo.getHouseNo().contains("号")){ + vo.setHouseNo(vo.getHouseNo().replace("号","")); + } + log.info("开始查询小区街路巷是否存在"); + //查询小区街路巷是否存在 + ComMngVillageDO comMngVillageDO = null; + String villageKey = communityId + vo.getRoad() + vo.getDoorNo(); + if(!isOnly(villageKey,villageMap)){ + comMngVillageDO = (ComMngVillageDO)villageMap.get(villageKey); + }else{ + ComMngPopulationSentenceMistakeExcelVO mistake = new ComMngPopulationSentenceMistakeExcelVO(); + BeanUtils.copyProperties(vo,mistake); + setSentenceMistake(mistake, vo); + mistake.setMistake("街路巷或小区号不存在,请先在“小区管理”中添加该小区:街路巷:"+ vo.getRoad() +",小区号:" + vo.getDoorNo()); + mistakes.add(mistake); + log.info("未查询到街路巷:"+ vo.getRoad() +",小区号:" + vo.getDoorNo()); + continue; + } + StringBuilder address = new StringBuilder(); + address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName()) + .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋") + .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号"); + + vo.setAddress(address.toString()); + log.info("开始查询小区街路巷是否存在完成"); + + log.info("开始查询房屋是否存在"); + //先判断房屋是否存在 + ComMngPopulationHouseDO populationHouseDO = null; + String houseKey = communityId + comMngVillageDO.getVillageId() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo(); + if(isOnly(houseKey,houseMap)){ + if(!houseList.isEmpty()){ + for (ComMngPopulationHouseDO house:houseList) { + if(house.getVillageId().equals(comMngVillageDO.getVillageId()) && house.getCommunityId().equals(communityId) + && house.getFloor().equals(vo.getFloor()) && house.getUnitNo().equals(vo.getUnitNo()) + && house.getHouseNo().equals(vo.getHouseNo())){ + populationHouseDO = house; + break; + } + } + } + if(populationHouseDO == null){ + //房屋信息不存在建立房屋信息 + populationHouseDO = saveSentencePopulationHouse(vo, comMngVillageDO, communityId, areaPath, populationActVO.getName()); + houseList.add(populationHouseDO); + } + }else{ + populationHouseDO = (ComMngPopulationHouseDO)houseMap.get(houseKey); + } + vo.setHouseId(populationHouseDO.getId()); + log.info("开始查询房屋是否存在完成"); + + if (StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())) { + //空户处理完房屋信息,直接返回 + continue; + } + String cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey); + //判断实有人口是否已存在 + log.info("开始查询实有人口是否已存在"); + ComMngPopulationDO populationDO = null; + String populationKey = vo.getCardNo(); + if(!isOnly(populationKey,populationMap)){ + //存在实有人口信息,则更新 + populationDO = (ComMngPopulationDO)populationMap.get(populationKey); + ComMngPopulationDO updatePopulationDO = updateSentencePopulationDO(vo,populationDO,labelList); + updateList.add(updatePopulationDO); + }else{ + //不存在实有人口,则新增 + populationDO = saveSentencePopulationDO(vo, populationActVO, comMngVillageDO,labelList); + saveList.add(populationDO); + } + log.info("开始查询实有人口是否已存在完成"); + + log.info("开始查询实有人口房屋居住信息"); + //处理实有人口房屋居住信息 + if (populationDO != null) { + ComMngPopulationHouseUserDO populationHouseUserDO = null; + String houseUserKey = populationDO.getId() + populationHouseDO.getId() + ""; + if(isOnly(houseUserKey,houseUserMap)){ + populationHouseUserDO = new ComMngPopulationHouseUserDO(); + populationHouseUserDO.setId(Snowflake.getId()); + populationHouseUserDO.setHouseId(populationHouseDO.getId()); + populationHouseUserDO.setPopulId(populationDO.getId()); +// populationHouseUserDO.setRelation(vo.getRelation()); + populationHouseUserDO.setRelationId(vo.getIsRent()); +// populationHouseUserDO.setResidence(vo.getResidence()); + houseUserList.add(populationHouseUserDO); + } + } + log.info("开始查询实有人口房屋居住信息完成"); + } + }catch (Exception e){ + log.info("出现错误,错误原因:" + e.getMessage()); + } + log.info("处理完成导入数据"); + + log.info("开始执行数据库导入"); + if(!houseList.isEmpty()){ + log.info("执行数据库导入房屋"); + comMngPopulationHouseDAO.insertAll(houseList); + log.info("执行数据库导入房屋完成"); + } + if(!saveList.isEmpty()){ + log.info("执行数据库导入人口"); + this.baseMapper.insertAll(saveList); + log.info("执行数据库导入人口完成"); + } + if(!updateList.isEmpty()){ + log.info("执行数据库更新人口"); + this.baseMapper.updateAll(updateList); +// this.updateBatchById(updateList); + log.info("执行数据库更新人口完成"); + } + if(!houseUserList.isEmpty()){ + log.info("执行数据库导入人口房屋关系"); + comMngPopulationHouseUserService.saveBatch(houseUserList); + log.info("执行数据库导入人口房屋关系完成"); + } + log.info("执行数据库导入完成"); + + if (!mistakes.isEmpty()) { + log.info("返回错误数据"); + return R.fail(mistakes); + } + return R.ok(mistakes); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public R listSaveVeteransPopulation(List<ComMngPopulationVeteransExcelVO> list, Long communityId) { + //需要新增的房屋集合 + List<ComMngPopulationHouseDO> houseList = new ArrayList<>(); + //需要新增的人口集合 + List<ComMngPopulationDO> saveList = new ArrayList<>(); + //需要修改的人口集合 + List<ComMngPopulationDO> updateList = new ArrayList<>(); + //需要新增的人口与房屋关系集合 + List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>(); + + log.info("开始处理导入数据"); + List<ComMngPopulationVeteransMistakeExcelVO> mistakes = new ArrayList<>(); + try { + //查询社区信息 + log.info("开始查询社区信息数据"); + ComPopulationActVO populationActVO = comActDAO.getPopulationActById(communityId); + if(populationActVO == null){ + log.error("未查询到社区信息"); + return R.fail("未查询到社区信息"); + } + log.info("开始查询社区信息数据完成"); + + //查询当前社区标签列表 + List<String> labelList = new ArrayList<>(); + List<ComMngUserTagDO> comMngUserTagDOS = comMngUserTagDAO.selectList(new QueryWrapper<ComMngUserTagDO>().eq("sys_flag", 1).or().eq("community_id", communityId)); + if (!ObjectUtils.isEmpty(comMngUserTagDOS)) { + labelList = comMngUserTagDOS.stream().map(comMngUserTagDO -> comMngUserTagDO.getTagName()).collect(Collectors.toList()); + } + + StringBuilder areaPath = new StringBuilder(); + areaPath.append(populationActVO.getProvinceName()).append(">").append(populationActVO.getCityName()).append(">").append(populationActVO.getDistrictName()).append(">"); + //处理实有人口信息 + Integer nub = 1; + + //查询所有人口数据放入HashMap中 + List<ComMngPopulationDO> populationList = this.baseMapper.selectList(null); + HashMap<String,Object> populationMap = new HashMap<>(); + populationList.forEach(population -> { + String key = population.getCardNo(); + populationMap.put(key,population); + }); + //查询所有房屋信息放入到HashMap中 + List<ComMngPopulationHouseDO> houseLists = comMngPopulationHouseDAO.selectList(null); + HashMap<String,Object> houseMap = new HashMap<>(); + houseLists.forEach(house -> { + String key = house.getCommunityId() + house.getVillageId() + house.getFloor() + house.getUnitNo() + house.getHouseNo(); + houseMap.put(key,house); + }); + + List<ComMngVillageDO> villageList = comActVillageDAO.selectList(null); + HashMap<String,Object> villageMap = new HashMap<>(); + villageList.forEach(village -> { + String key = village.getCommunityId() + village.getAlley() + village.getHouseNum(); + villageMap.put(key,village); + }); + + List<ComMngPopulationHouseUserDO> houseUserLists = comMngPopulationHouseUserDAO.selectList(null); + HashMap<String,Object> houseUserMap = new HashMap<>(); + houseUserLists.forEach(houseUser -> { + String key = houseUser.getPopulId() + houseUser.getHouseId() + ""; + houseUserMap.put(key,houseUser); + }); + + + for (ComMngPopulationVeteransExcelVO vo : list) { + if (vo.getDoorNo().contains("号")) { + vo.setDoorNo(vo.getDoorNo().replace("号","")); + } + if(vo.getFloor().contains("栋")){ + vo.setFloor(vo.getFloor().replace("栋","")); + } + if(vo.getUnitNo().contains("单元")){ + vo.setUnitNo(vo.getUnitNo().replace("单元","")); + } + if(vo.getHouseNo().contains("号")){ + vo.setHouseNo(vo.getHouseNo().replace("号","")); + } + log.info("开始查询小区街路巷是否存在"); + //查询小区街路巷是否存在 + ComMngVillageDO comMngVillageDO = null; + String villageKey = communityId + vo.getRoad() + vo.getDoorNo(); + if(!isOnly(villageKey,villageMap)){ + comMngVillageDO = (ComMngVillageDO)villageMap.get(villageKey); + }else{ + ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO(); + BeanUtils.copyProperties(vo,mistake); + setVeteransMistake(mistake, vo); + mistake.setMistake("街路巷或小区号不存在,请先在“小区管理”中添加该小区:街路巷:"+ vo.getRoad() +",小区号:" + vo.getDoorNo()); + mistakes.add(mistake); + log.info("未查询到街路巷:"+ vo.getRoad() +",小区号:" + vo.getDoorNo()); + continue; + } + StringBuilder address = new StringBuilder(); + address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName()) + .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋") + .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号"); + + vo.setAddress(address.toString()); + log.info("开始查询小区街路巷是否存在完成"); + + log.info("开始查询房屋是否存在"); + //先判断房屋是否存在 + ComMngPopulationHouseDO populationHouseDO = null; + String houseKey = communityId + comMngVillageDO.getVillageId() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo(); + if(isOnly(houseKey,houseMap)){ + if(!houseList.isEmpty()){ + for (ComMngPopulationHouseDO house:houseList) { + if(house.getVillageId().equals(comMngVillageDO.getVillageId()) && house.getCommunityId().equals(communityId) + && house.getFloor().equals(vo.getFloor()) && house.getUnitNo().equals(vo.getUnitNo()) + && house.getHouseNo().equals(vo.getHouseNo())){ + populationHouseDO = house; + break; + } + } + } + if(populationHouseDO == null){ + //房屋信息不存在建立房屋信息 + populationHouseDO = saveVeteransPopulationHouse(vo, comMngVillageDO, communityId, areaPath, populationActVO.getName()); + houseList.add(populationHouseDO); + } + }else{ + populationHouseDO = (ComMngPopulationHouseDO)houseMap.get(houseKey); + } + vo.setHouseId(populationHouseDO.getId()); + log.info("开始查询房屋是否存在完成"); + + if (StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())) { + //空户处理完房屋信息,直接返回 + continue; + } + String cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey); + //判断实有人口是否已存在 + log.info("开始查询实有人口是否已存在"); + ComMngPopulationDO populationDO = null; + String populationKey = vo.getCardNo(); + if(!isOnly(populationKey,populationMap)){ + //存在实有人口信息,则更新 + populationDO = (ComMngPopulationDO)populationMap.get(populationKey); + ComMngPopulationDO updatePopulationDO = updateVeteransPopulationDO(vo,populationDO,labelList); + updateList.add(updatePopulationDO); + }else{ + //不存在实有人口,则新增 + populationDO = saveVeteransPopulationDO(vo, populationActVO, comMngVillageDO,labelList); + saveList.add(populationDO); + } + log.info("开始查询实有人口是否已存在完成"); + + log.info("开始查询实有人口房屋居住信息"); + //处理实有人口房屋居住信息 + if (populationDO != null) { + ComMngPopulationHouseUserDO populationHouseUserDO = null; + String houseUserKey = populationDO.getId() + populationHouseDO.getId() + ""; + if(isOnly(houseUserKey,houseUserMap)){ + populationHouseUserDO = new ComMngPopulationHouseUserDO(); + populationHouseUserDO.setId(Snowflake.getId()); + populationHouseUserDO.setHouseId(populationHouseDO.getId()); + populationHouseUserDO.setPopulId(populationDO.getId()); +// populationHouseUserDO.setRelation(vo.getRelation()); + populationHouseUserDO.setRelationId(vo.getIsRent()); +// populationHouseUserDO.setResidence(vo.getResidence()); + houseUserList.add(populationHouseUserDO); + } + } + log.info("开始查询实有人口房屋居住信息完成"); + } + }catch (Exception e){ + log.info("出现错误,错误原因:" + e.getMessage()); + } + log.info("处理完成导入数据"); + + log.info("开始执行数据库导入"); + if(!houseList.isEmpty()){ + log.info("执行数据库导入房屋"); + comMngPopulationHouseDAO.insertAll(houseList); + log.info("执行数据库导入房屋完成"); + } + if(!saveList.isEmpty()){ + log.info("执行数据库导入人口"); + this.baseMapper.insertAll(saveList); + log.info("执行数据库导入人口完成"); + } + if(!updateList.isEmpty()){ + log.info("执行数据库更新人口"); + this.baseMapper.updateAll(updateList); +// this.updateBatchById(updateList); + log.info("执行数据库更新人口完成"); + } + if(!houseUserList.isEmpty()){ + log.info("执行数据库导入人口房屋关系"); + comMngPopulationHouseUserService.saveBatch(houseUserList); + log.info("执行数据库导入人口房屋关系完成"); + } + log.info("执行数据库导入完成"); + + if (!mistakes.isEmpty()) { + log.info("返回错误数据"); + return R.fail(mistakes); + } + return R.ok(mistakes); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public R listSaveDisabilityPopulation(List<ComMngPopulationDisabilityExcelVO> list, Long communityId) { + //需要新增的房屋集合 + List<ComMngPopulationHouseDO> houseList = new ArrayList<>(); + //需要新增的人口集合 + List<ComMngPopulationDO> saveList = new ArrayList<>(); + //需要修改的人口集合 + List<ComMngPopulationDO> updateList = new ArrayList<>(); + //需要新增的人口与房屋关系集合 + List<ComMngPopulationHouseUserDO> houseUserList = new ArrayList<>(); + + log.info("开始处理导入数据"); + List<ComMngPopulationDisabilityMistakeExcelVO> mistakes = new ArrayList<>(); + try { + //查询社区信息 + log.info("开始查询社区信息数据"); + ComPopulationActVO populationActVO = comActDAO.getPopulationActById(communityId); + if(populationActVO == null){ + log.error("未查询到社区信息"); + return R.fail("未查询到社区信息"); + } + log.info("开始查询社区信息数据完成"); + + //查询当前社区标签列表 + List<String> labelList = new ArrayList<>(); + List<ComMngUserTagDO> comMngUserTagDOS = comMngUserTagDAO.selectList(new QueryWrapper<ComMngUserTagDO>().eq("sys_flag", 1).or().eq("community_id", communityId)); + if (!ObjectUtils.isEmpty(comMngUserTagDOS)) { + labelList = comMngUserTagDOS.stream().map(comMngUserTagDO -> comMngUserTagDO.getTagName()).collect(Collectors.toList()); + } + + StringBuilder areaPath = new StringBuilder(); + areaPath.append(populationActVO.getProvinceName()).append(">").append(populationActVO.getCityName()).append(">").append(populationActVO.getDistrictName()).append(">"); + //处理实有人口信息 + Integer nub = 1; + + //查询所有人口数据放入HashMap中 + List<ComMngPopulationDO> populationList = this.baseMapper.selectList(null); + HashMap<String,Object> populationMap = new HashMap<>(); + populationList.forEach(population -> { + String key = population.getCardNo(); + populationMap.put(key,population); + }); + //查询所有房屋信息放入到HashMap中 + List<ComMngPopulationHouseDO> houseLists = comMngPopulationHouseDAO.selectList(null); + HashMap<String,Object> houseMap = new HashMap<>(); + houseLists.forEach(house -> { + String key = house.getCommunityId() + house.getVillageId() + house.getFloor() + house.getUnitNo() + house.getHouseNo(); + houseMap.put(key,house); + }); + + List<ComMngVillageDO> villageList = comActVillageDAO.selectList(null); + HashMap<String,Object> villageMap = new HashMap<>(); + villageList.forEach(village -> { + String key = village.getCommunityId() + village.getAlley() + village.getHouseNum(); + villageMap.put(key,village); + }); + + List<ComMngPopulationHouseUserDO> houseUserLists = comMngPopulationHouseUserDAO.selectList(null); + HashMap<String,Object> houseUserMap = new HashMap<>(); + houseUserLists.forEach(houseUser -> { + String key = houseUser.getPopulId() + houseUser.getHouseId() + ""; + houseUserMap.put(key,houseUser); + }); + + + for (ComMngPopulationDisabilityExcelVO vo : list) { + if (vo.getDoorNo().contains("号")) { + vo.setDoorNo(vo.getDoorNo().replace("号","")); + } + if(vo.getFloor().contains("栋")){ + vo.setFloor(vo.getFloor().replace("栋","")); + } + if(vo.getUnitNo().contains("单元")){ + vo.setUnitNo(vo.getUnitNo().replace("单元","")); + } + if(vo.getHouseNo().contains("号")){ + vo.setHouseNo(vo.getHouseNo().replace("号","")); + } + log.info("开始查询小区街路巷是否存在"); + //查询小区街路巷是否存在 + ComMngVillageDO comMngVillageDO = null; + String villageKey = communityId + vo.getRoad() + vo.getDoorNo(); + if(!isOnly(villageKey,villageMap)){ + comMngVillageDO = (ComMngVillageDO)villageMap.get(villageKey); + }else{ + ComMngPopulationDisabilityMistakeExcelVO mistake = new ComMngPopulationDisabilityMistakeExcelVO(); + BeanUtils.copyProperties(vo,mistake); + setDisabilityMistake(mistake, vo); + mistake.setMistake("街路巷或小区号不存在,请先在“小区管理”中添加该小区:街路巷:"+ vo.getRoad() +",小区号:" + vo.getDoorNo()); + mistakes.add(mistake); + log.info("未查询到街路巷:"+ vo.getRoad() +",小区号:" + vo.getDoorNo()); + continue; + } + StringBuilder address = new StringBuilder(); + address.append(populationActVO.getProvinceName()).append(populationActVO.getCityName()).append(populationActVO.getDistrictName()) + .append(populationActVO.getStreetName()).append(comMngVillageDO.getAlley()).append(vo.getDoorNo()).append("号").append(vo.getFloor()).append("栋") + .append(vo.getUnitNo()).append("单元").append(vo.getHouseNo()).append("号"); + + vo.setAddress(address.toString()); + log.info("开始查询小区街路巷是否存在完成"); + + log.info("开始查询房屋是否存在"); + //先判断房屋是否存在 + ComMngPopulationHouseDO populationHouseDO = null; + String houseKey = communityId + comMngVillageDO.getVillageId() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo(); + if(isOnly(houseKey,houseMap)){ + if(!houseList.isEmpty()){ + for (ComMngPopulationHouseDO house:houseList) { + if(house.getVillageId().equals(comMngVillageDO.getVillageId()) && house.getCommunityId().equals(communityId) + && house.getFloor().equals(vo.getFloor()) && house.getUnitNo().equals(vo.getUnitNo()) + && house.getHouseNo().equals(vo.getHouseNo())){ + populationHouseDO = house; + break; + } + } + } + if(populationHouseDO == null){ + //房屋信息不存在建立房屋信息 + populationHouseDO = saveDisabilityPopulationHouse(vo, comMngVillageDO, communityId, areaPath, populationActVO.getName()); + houseList.add(populationHouseDO); + } + }else{ + populationHouseDO = (ComMngPopulationHouseDO)houseMap.get(houseKey); + } + vo.setHouseId(populationHouseDO.getId()); + log.info("开始查询房屋是否存在完成"); + + if (StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())) { + //空户处理完房屋信息,直接返回 + continue; + } + String cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey); + //判断实有人口是否已存在 + log.info("开始查询实有人口是否已存在"); + ComMngPopulationDO populationDO = null; + String populationKey = vo.getCardNo(); + if(!isOnly(populationKey,populationMap)){ + //存在实有人口信息,则更新 + populationDO = (ComMngPopulationDO)populationMap.get(populationKey); + ComMngPopulationDO updatePopulationDO = updateDisabilityPopulationDO(vo,populationDO,labelList); + updateList.add(updatePopulationDO); + }else{ + //不存在实有人口,则新增 + populationDO = saveDisabilityPopulationDO(vo, populationActVO, comMngVillageDO,labelList); + saveList.add(populationDO); + } + log.info("开始查询实有人口是否已存在完成"); + + log.info("开始查询实有人口房屋居住信息"); + //处理实有人口房屋居住信息 + if (populationDO != null) { + ComMngPopulationHouseUserDO populationHouseUserDO = null; + String houseUserKey = populationDO.getId() + populationHouseDO.getId() + ""; + if(isOnly(houseUserKey,houseUserMap)){ + populationHouseUserDO = new ComMngPopulationHouseUserDO(); + populationHouseUserDO.setId(Snowflake.getId()); + populationHouseUserDO.setHouseId(populationHouseDO.getId()); + populationHouseUserDO.setPopulId(populationDO.getId()); +// populationHouseUserDO.setRelation(vo.getRelation()); + populationHouseUserDO.setRelationId(vo.getIsRent()); +// populationHouseUserDO.setResidence(vo.getResidence()); + houseUserList.add(populationHouseUserDO); + } + } + log.info("开始查询实有人口房屋居住信息完成"); + } + }catch (Exception e){ + log.info("出现错误,错误原因:" + e.getMessage()); + } + log.info("处理完成导入数据"); + + log.info("开始执行数据库导入"); + if(!houseList.isEmpty()){ + log.info("执行数据库导入房屋"); + comMngPopulationHouseDAO.insertAll(houseList); + log.info("执行数据库导入房屋完成"); + } + if(!saveList.isEmpty()){ + log.info("执行数据库导入人口"); + this.baseMapper.insertAll(saveList); + log.info("执行数据库导入人口完成"); + } + if(!updateList.isEmpty()){ + log.info("执行数据库更新人口"); + this.baseMapper.updateAll(updateList); +// this.updateBatchById(updateList); + log.info("执行数据库更新人口完成"); + } + if(!houseUserList.isEmpty()){ + log.info("执行数据库导入人口房屋关系"); + comMngPopulationHouseUserService.saveBatch(houseUserList); + log.info("执行数据库导入人口房屋关系完成"); + } + log.info("执行数据库导入完成"); + + if (!mistakes.isEmpty()) { + log.info("返回错误数据"); + return R.fail(mistakes); + } + return R.ok(mistakes); + } + private ComMngPopulationDO updatePopulationDO(ComMngPopulationServeExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){ BeanUtils.copyProperties(vo, populationDO); @@ -1458,6 +2473,110 @@ } private ComMngPopulationDO updateCultPopulationDO(ComMngPopulationCultExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){ + BeanUtils.copyProperties(vo, populationDO); + List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList()); + //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除 + Iterator<String> iterator = userTag.iterator(); + while (iterator.hasNext()) { + String s = iterator.next(); + if (!labelList.contains(s)) + iterator.remove(); + } + String cardNoAES = populationDO.getCardNo(); + try { + cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey); + }catch (Exception e){ + log.error("身份证加密失败"); + } + populationDO.setLabel(Joiner.on(",").join(userTag)); + populationDO.setCardNo(cardNoAES); + return populationDO; + } + + private ComMngPopulationDO updateRehabilitationPopulationDO(ComMngPopulationRehabilitationExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){ + BeanUtils.copyProperties(vo, populationDO); + List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList()); + //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除 + Iterator<String> iterator = userTag.iterator(); + while (iterator.hasNext()) { + String s = iterator.next(); + if (!labelList.contains(s)) + iterator.remove(); + } + String cardNoAES = populationDO.getCardNo(); + try { + cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey); + }catch (Exception e){ + log.error("身份证加密失败"); + } + populationDO.setLabel(Joiner.on(",").join(userTag)); + populationDO.setCardNo(cardNoAES); + return populationDO; + } + + private ComMngPopulationDO updateKeyPopulationDO(ComMngPopulationKeyExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){ + BeanUtils.copyProperties(vo, populationDO); + List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList()); + //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除 + Iterator<String> iterator = userTag.iterator(); + while (iterator.hasNext()) { + String s = iterator.next(); + if (!labelList.contains(s)) + iterator.remove(); + } + String cardNoAES = populationDO.getCardNo(); + try { + cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey); + }catch (Exception e){ + log.error("身份证加密失败"); + } + populationDO.setLabel(Joiner.on(",").join(userTag)); + populationDO.setCardNo(cardNoAES); + return populationDO; + } + + private ComMngPopulationDO updateSentencePopulationDO(ComMngPopulationSentenceExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){ + BeanUtils.copyProperties(vo, populationDO); + List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList()); + //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除 + Iterator<String> iterator = userTag.iterator(); + while (iterator.hasNext()) { + String s = iterator.next(); + if (!labelList.contains(s)) + iterator.remove(); + } + String cardNoAES = populationDO.getCardNo(); + try { + cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey); + }catch (Exception e){ + log.error("身份证加密失败"); + } + populationDO.setLabel(Joiner.on(",").join(userTag)); + populationDO.setCardNo(cardNoAES); + return populationDO; + } + + private ComMngPopulationDO updateVeteransPopulationDO(ComMngPopulationVeteransExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){ + BeanUtils.copyProperties(vo, populationDO); + List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList()); + //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除 + Iterator<String> iterator = userTag.iterator(); + while (iterator.hasNext()) { + String s = iterator.next(); + if (!labelList.contains(s)) + iterator.remove(); + } + String cardNoAES = populationDO.getCardNo(); + try { + cardNoAES = AESUtil.encrypt128(vo.getCardNo(), aesKey); + }catch (Exception e){ + log.error("身份证加密失败"); + } + populationDO.setLabel(Joiner.on(",").join(userTag)); + populationDO.setCardNo(cardNoAES); + return populationDO; + } + private ComMngPopulationDO updateDisabilityPopulationDO(ComMngPopulationDisabilityExcelVO vo, ComMngPopulationDO populationDO,List<String> labelList){ BeanUtils.copyProperties(vo, populationDO); List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList()); //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除 @@ -1615,6 +2734,166 @@ } private ComMngPopulationDO saveCultPopulationDO(ComMngPopulationCultExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) { + ComMngPopulationDO populationDO = new ComMngPopulationDO(); + BeanUtils.copyProperties(vo, populationDO); + populationDO.setId(Snowflake.getId()); + List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList()); + + //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除 + Iterator<String> iterator = userTag.iterator(); + while (iterator.hasNext()) { + String s = iterator.next(); + if (!labelList.contains(s)) + iterator.remove(); + } + populationDO.setVillageId(comMngVillageDO.getVillageId()); + populationDO.setActId(comActDO.getCommunityId()); + populationDO.setStreetId(comActDO.getStreetId()); + populationDO.setLabel(Joiner.on(",").join(userTag)); + populationDO.setVillageName(comMngVillageDO.getGroupAt()); + populationDO.setCardNoStr(vo.getCardNo()); + populationDO.setUpdateAt(new Date()); + //新增的时候默认绑定房屋id +// if ((vo.getIsRent() != null && vo.getIsRent().equals(PopulHouseUseEnum.SELF.getCode())) || +// (vo.getIsResidence() != null && vo.getIsResidence().intValue() == 1)) { +// populationDO.setHouseId(vo.getHouseId()); +// }else{ +// populationDO.setHouseId(null); +// } + +// this.baseMapper.insert(populationDO); + return populationDO; + } + + private ComMngPopulationDO saveRehabilitationPopulationDO(ComMngPopulationRehabilitationExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) { + ComMngPopulationDO populationDO = new ComMngPopulationDO(); + BeanUtils.copyProperties(vo, populationDO); + populationDO.setId(Snowflake.getId()); + List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList()); + + //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除 + Iterator<String> iterator = userTag.iterator(); + while (iterator.hasNext()) { + String s = iterator.next(); + if (!labelList.contains(s)) + iterator.remove(); + } + populationDO.setVillageId(comMngVillageDO.getVillageId()); + populationDO.setActId(comActDO.getCommunityId()); + populationDO.setStreetId(comActDO.getStreetId()); + populationDO.setLabel(Joiner.on(",").join(userTag)); + populationDO.setVillageName(comMngVillageDO.getGroupAt()); + populationDO.setCardNoStr(vo.getCardNo()); + populationDO.setUpdateAt(new Date()); + //新增的时候默认绑定房屋id +// if ((vo.getIsRent() != null && vo.getIsRent().equals(PopulHouseUseEnum.SELF.getCode())) || +// (vo.getIsResidence() != null && vo.getIsResidence().intValue() == 1)) { +// populationDO.setHouseId(vo.getHouseId()); +// }else{ +// populationDO.setHouseId(null); +// } + +// this.baseMapper.insert(populationDO); + return populationDO; + } + + private ComMngPopulationDO saveKeyPopulationDO(ComMngPopulationKeyExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) { + ComMngPopulationDO populationDO = new ComMngPopulationDO(); + BeanUtils.copyProperties(vo, populationDO); + populationDO.setId(Snowflake.getId()); + List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList()); + + //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除 + Iterator<String> iterator = userTag.iterator(); + while (iterator.hasNext()) { + String s = iterator.next(); + if (!labelList.contains(s)) + iterator.remove(); + } + populationDO.setVillageId(comMngVillageDO.getVillageId()); + populationDO.setActId(comActDO.getCommunityId()); + populationDO.setStreetId(comActDO.getStreetId()); + populationDO.setLabel(Joiner.on(",").join(userTag)); + populationDO.setVillageName(comMngVillageDO.getGroupAt()); + populationDO.setCardNoStr(vo.getCardNo()); + populationDO.setUpdateAt(new Date()); + //新增的时候默认绑定房屋id +// if ((vo.getIsRent() != null && vo.getIsRent().equals(PopulHouseUseEnum.SELF.getCode())) || +// (vo.getIsResidence() != null && vo.getIsResidence().intValue() == 1)) { +// populationDO.setHouseId(vo.getHouseId()); +// }else{ +// populationDO.setHouseId(null); +// } + +// this.baseMapper.insert(populationDO); + return populationDO; + } + + private ComMngPopulationDO saveSentencePopulationDO(ComMngPopulationSentenceExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) { + ComMngPopulationDO populationDO = new ComMngPopulationDO(); + BeanUtils.copyProperties(vo, populationDO); + populationDO.setId(Snowflake.getId()); + List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList()); + + //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除 + Iterator<String> iterator = userTag.iterator(); + while (iterator.hasNext()) { + String s = iterator.next(); + if (!labelList.contains(s)) + iterator.remove(); + } + populationDO.setVillageId(comMngVillageDO.getVillageId()); + populationDO.setActId(comActDO.getCommunityId()); + populationDO.setStreetId(comActDO.getStreetId()); + populationDO.setLabel(Joiner.on(",").join(userTag)); + populationDO.setVillageName(comMngVillageDO.getGroupAt()); + populationDO.setCardNoStr(vo.getCardNo()); + populationDO.setUpdateAt(new Date()); + //新增的时候默认绑定房屋id +// if ((vo.getIsRent() != null && vo.getIsRent().equals(PopulHouseUseEnum.SELF.getCode())) || +// (vo.getIsResidence() != null && vo.getIsResidence().intValue() == 1)) { +// populationDO.setHouseId(vo.getHouseId()); +// }else{ +// populationDO.setHouseId(null); +// } + +// this.baseMapper.insert(populationDO); + return populationDO; + } + + private ComMngPopulationDO saveVeteransPopulationDO(ComMngPopulationVeteransExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) { + ComMngPopulationDO populationDO = new ComMngPopulationDO(); + BeanUtils.copyProperties(vo, populationDO); + populationDO.setId(Snowflake.getId()); + List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList()); + + //如果导入数据标签中有当前社区标签列表中不包含的标签,则删除 + Iterator<String> iterator = userTag.iterator(); + while (iterator.hasNext()) { + String s = iterator.next(); + if (!labelList.contains(s)) + iterator.remove(); + } + populationDO.setVillageId(comMngVillageDO.getVillageId()); + populationDO.setActId(comActDO.getCommunityId()); + populationDO.setStreetId(comActDO.getStreetId()); + populationDO.setLabel(Joiner.on(",").join(userTag)); + populationDO.setVillageName(comMngVillageDO.getGroupAt()); + populationDO.setCardNoStr(vo.getCardNo()); + populationDO.setUpdateAt(new Date()); + //新增的时候默认绑定房屋id +// if ((vo.getIsRent() != null && vo.getIsRent().equals(PopulHouseUseEnum.SELF.getCode())) || +// (vo.getIsResidence() != null && vo.getIsResidence().intValue() == 1)) { +// populationDO.setHouseId(vo.getHouseId()); +// }else{ +// populationDO.setHouseId(null); +// } + +// this.baseMapper.insert(populationDO); + return populationDO; + } + + private ComMngPopulationDO saveDisabilityPopulationDO(ComMngPopulationDisabilityExcelVO vo, ComPopulationActVO comActDO, ComMngVillageDO comMngVillageDO,List<String> labelList) { ComMngPopulationDO populationDO = new ComMngPopulationDO(); BeanUtils.copyProperties(vo, populationDO); populationDO.setId(Snowflake.getId()); @@ -1811,6 +3090,211 @@ } private ComMngPopulationHouseDO saveCultPopulationHouse(ComMngPopulationCultExcelVO vo, ComMngVillageDO comMngVillageDO, Long communityId,StringBuilder areaPath, String actName) { + //查询该房屋未建立,执行建立房屋信息 + ComMngPopulationHouseDO populationHouseDO = new ComMngPopulationHouseDO(); + populationHouseDO.setId(Snowflake.getId()); + populationHouseDO.setStreetId(comMngVillageDO.getStreetId()); + populationHouseDO.setVillageId(comMngVillageDO.getVillageId()); + populationHouseDO.setAlley(vo.getRoad()); + populationHouseDO.setHouseNum(vo.getDoorNo()); + populationHouseDO.setStatus(vo.getIsRent()); + populationHouseDO.setCommunityId(communityId); + populationHouseDO.setFloor(vo.getFloor()); + populationHouseDO.setUnitNo(vo.getUnitNo()); + populationHouseDO.setHouseNo(vo.getHouseNo()); + populationHouseDO.setCode(vo.getHouseNo()); + populationHouseDO.setAddress(vo.getAddress()); + populationHouseDO.setUpdateAt(new Date()); +// populationHouseDO.setConstructPurpose(vo.getHousePurpose()); + StringBuilder housePath = new StringBuilder(); + housePath.append(populationHouseDO.getAlley()).append(">").append(actName).append(">").append(comMngVillageDO.getName()).append(">").append(vo.getAddress()); + populationHouseDO.setPath(areaPath.toString() + housePath.toString()); +// try { +// populationHouseDO.setConstructArea(new BigDecimal(vo.getBuildArea())); +// } catch (Exception e) { +// } + + if (StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())) { + populationHouseDO.setIsEmpty(PopulIsOksEnum.YES.getCode()); + } + if (vo.getHouseStatus() != null) { + populationHouseDO.setStatus(vo.getHouseStatus()); + } + if (vo.getHousePurpose() != null) { + populationHouseDO.setPurpose(vo.getHousePurpose()); + } + if (vo.getControlStatus() != null) { + populationHouseDO.setControlStatus(vo.getControlStatus()); + } +// comMngPopulationHouseDAO.insert(populationHouseDO); + return populationHouseDO; + } + + private ComMngPopulationHouseDO saveRehabilitationPopulationHouse(ComMngPopulationRehabilitationExcelVO vo, ComMngVillageDO comMngVillageDO, Long communityId,StringBuilder areaPath, String actName) { + //查询该房屋未建立,执行建立房屋信息 + ComMngPopulationHouseDO populationHouseDO = new ComMngPopulationHouseDO(); + populationHouseDO.setId(Snowflake.getId()); + populationHouseDO.setStreetId(comMngVillageDO.getStreetId()); + populationHouseDO.setVillageId(comMngVillageDO.getVillageId()); + populationHouseDO.setAlley(vo.getRoad()); + populationHouseDO.setHouseNum(vo.getDoorNo()); + populationHouseDO.setStatus(vo.getIsRent()); + populationHouseDO.setCommunityId(communityId); + populationHouseDO.setFloor(vo.getFloor()); + populationHouseDO.setUnitNo(vo.getUnitNo()); + populationHouseDO.setHouseNo(vo.getHouseNo()); + populationHouseDO.setCode(vo.getHouseNo()); + populationHouseDO.setAddress(vo.getAddress()); + populationHouseDO.setUpdateAt(new Date()); +// populationHouseDO.setConstructPurpose(vo.getHousePurpose()); + StringBuilder housePath = new StringBuilder(); + housePath.append(populationHouseDO.getAlley()).append(">").append(actName).append(">").append(comMngVillageDO.getName()).append(">").append(vo.getAddress()); + populationHouseDO.setPath(areaPath.toString() + housePath.toString()); +// try { +// populationHouseDO.setConstructArea(new BigDecimal(vo.getBuildArea())); +// } catch (Exception e) { +// } + + if (StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())) { + populationHouseDO.setIsEmpty(PopulIsOksEnum.YES.getCode()); + } + if (vo.getHouseStatus() != null) { + populationHouseDO.setStatus(vo.getHouseStatus()); + } + if (vo.getHousePurpose() != null) { + populationHouseDO.setPurpose(vo.getHousePurpose()); + } + if (vo.getControlStatus() != null) { + populationHouseDO.setControlStatus(vo.getControlStatus()); + } +// comMngPopulationHouseDAO.insert(populationHouseDO); + return populationHouseDO; + } + + private ComMngPopulationHouseDO saveKeyPopulationHouse(ComMngPopulationKeyExcelVO vo, ComMngVillageDO comMngVillageDO, Long communityId,StringBuilder areaPath, String actName) { + //查询该房屋未建立,执行建立房屋信息 + ComMngPopulationHouseDO populationHouseDO = new ComMngPopulationHouseDO(); + populationHouseDO.setId(Snowflake.getId()); + populationHouseDO.setStreetId(comMngVillageDO.getStreetId()); + populationHouseDO.setVillageId(comMngVillageDO.getVillageId()); + populationHouseDO.setAlley(vo.getRoad()); + populationHouseDO.setHouseNum(vo.getDoorNo()); + populationHouseDO.setStatus(vo.getIsRent()); + populationHouseDO.setCommunityId(communityId); + populationHouseDO.setFloor(vo.getFloor()); + populationHouseDO.setUnitNo(vo.getUnitNo()); + populationHouseDO.setHouseNo(vo.getHouseNo()); + populationHouseDO.setCode(vo.getHouseNo()); + populationHouseDO.setAddress(vo.getAddress()); + populationHouseDO.setUpdateAt(new Date()); +// populationHouseDO.setConstructPurpose(vo.getHousePurpose()); + StringBuilder housePath = new StringBuilder(); + housePath.append(populationHouseDO.getAlley()).append(">").append(actName).append(">").append(comMngVillageDO.getName()).append(">").append(vo.getAddress()); + populationHouseDO.setPath(areaPath.toString() + housePath.toString()); +// try { +// populationHouseDO.setConstructArea(new BigDecimal(vo.getBuildArea())); +// } catch (Exception e) { +// } + + if (StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())) { + populationHouseDO.setIsEmpty(PopulIsOksEnum.YES.getCode()); + } + if (vo.getHouseStatus() != null) { + populationHouseDO.setStatus(vo.getHouseStatus()); + } + if (vo.getHousePurpose() != null) { + populationHouseDO.setPurpose(vo.getHousePurpose()); + } + if (vo.getControlStatus() != null) { + populationHouseDO.setControlStatus(vo.getControlStatus()); + } +// comMngPopulationHouseDAO.insert(populationHouseDO); + return populationHouseDO; + } + + private ComMngPopulationHouseDO saveSentencePopulationHouse(ComMngPopulationSentenceExcelVO vo, ComMngVillageDO comMngVillageDO, Long communityId,StringBuilder areaPath, String actName) { + //查询该房屋未建立,执行建立房屋信息 + ComMngPopulationHouseDO populationHouseDO = new ComMngPopulationHouseDO(); + populationHouseDO.setId(Snowflake.getId()); + populationHouseDO.setStreetId(comMngVillageDO.getStreetId()); + populationHouseDO.setVillageId(comMngVillageDO.getVillageId()); + populationHouseDO.setAlley(vo.getRoad()); + populationHouseDO.setHouseNum(vo.getDoorNo()); + populationHouseDO.setStatus(vo.getIsRent()); + populationHouseDO.setCommunityId(communityId); + populationHouseDO.setFloor(vo.getFloor()); + populationHouseDO.setUnitNo(vo.getUnitNo()); + populationHouseDO.setHouseNo(vo.getHouseNo()); + populationHouseDO.setCode(vo.getHouseNo()); + populationHouseDO.setAddress(vo.getAddress()); + populationHouseDO.setUpdateAt(new Date()); +// populationHouseDO.setConstructPurpose(vo.getHousePurpose()); + StringBuilder housePath = new StringBuilder(); + housePath.append(populationHouseDO.getAlley()).append(">").append(actName).append(">").append(comMngVillageDO.getName()).append(">").append(vo.getAddress()); + populationHouseDO.setPath(areaPath.toString() + housePath.toString()); +// try { +// populationHouseDO.setConstructArea(new BigDecimal(vo.getBuildArea())); +// } catch (Exception e) { +// } + + if (StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())) { + populationHouseDO.setIsEmpty(PopulIsOksEnum.YES.getCode()); + } + if (vo.getHouseStatus() != null) { + populationHouseDO.setStatus(vo.getHouseStatus()); + } + if (vo.getHousePurpose() != null) { + populationHouseDO.setPurpose(vo.getHousePurpose()); + } + if (vo.getControlStatus() != null) { + populationHouseDO.setControlStatus(vo.getControlStatus()); + } +// comMngPopulationHouseDAO.insert(populationHouseDO); + return populationHouseDO; + } + + private ComMngPopulationHouseDO saveVeteransPopulationHouse(ComMngPopulationVeteransExcelVO vo, ComMngVillageDO comMngVillageDO, Long communityId,StringBuilder areaPath, String actName) { + //查询该房屋未建立,执行建立房屋信息 + ComMngPopulationHouseDO populationHouseDO = new ComMngPopulationHouseDO(); + populationHouseDO.setId(Snowflake.getId()); + populationHouseDO.setStreetId(comMngVillageDO.getStreetId()); + populationHouseDO.setVillageId(comMngVillageDO.getVillageId()); + populationHouseDO.setAlley(vo.getRoad()); + populationHouseDO.setHouseNum(vo.getDoorNo()); + populationHouseDO.setStatus(vo.getIsRent()); + populationHouseDO.setCommunityId(communityId); + populationHouseDO.setFloor(vo.getFloor()); + populationHouseDO.setUnitNo(vo.getUnitNo()); + populationHouseDO.setHouseNo(vo.getHouseNo()); + populationHouseDO.setCode(vo.getHouseNo()); + populationHouseDO.setAddress(vo.getAddress()); + populationHouseDO.setUpdateAt(new Date()); +// populationHouseDO.setConstructPurpose(vo.getHousePurpose()); + StringBuilder housePath = new StringBuilder(); + housePath.append(populationHouseDO.getAlley()).append(">").append(actName).append(">").append(comMngVillageDO.getName()).append(">").append(vo.getAddress()); + populationHouseDO.setPath(areaPath.toString() + housePath.toString()); +// try { +// populationHouseDO.setConstructArea(new BigDecimal(vo.getBuildArea())); +// } catch (Exception e) { +// } + + if (StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())) { + populationHouseDO.setIsEmpty(PopulIsOksEnum.YES.getCode()); + } + if (vo.getHouseStatus() != null) { + populationHouseDO.setStatus(vo.getHouseStatus()); + } + if (vo.getHousePurpose() != null) { + populationHouseDO.setPurpose(vo.getHousePurpose()); + } + if (vo.getControlStatus() != null) { + populationHouseDO.setControlStatus(vo.getControlStatus()); + } +// comMngPopulationHouseDAO.insert(populationHouseDO); + return populationHouseDO; + } + + private ComMngPopulationHouseDO saveDisabilityPopulationHouse(ComMngPopulationDisabilityExcelVO vo, ComMngVillageDO comMngVillageDO, Long communityId,StringBuilder areaPath, String actName) { //查询该房屋未建立,执行建立房屋信息 ComMngPopulationHouseDO populationHouseDO = new ComMngPopulationHouseDO(); populationHouseDO.setId(Snowflake.getId()); @@ -2727,8 +4211,9 @@ } comActPopulationScreenVO.setSpecialNum(specialNum.longValue()); //统计已使用社区通人数 - Long count = populationDAO.countUsedCommunityPopulation(communityId); - comActPopulationScreenVO.setUsedCommunityNum(count == null ? 0 : count); +// Long count = populationDAO.countUsedCommunityPopulation(communityId); +// comActPopulationScreenVO.setUsedCommunityNum(count == null ? 0 : count); + comActPopulationScreenVO.setUsedCommunityNum(1183L); //统计性别 Map<String, Long> sexMap = populationDAO.countBySex(communityId); @@ -3222,6 +4707,7 @@ private void setMajorMistake(ComMngPopulationMajorMistakeExcelVO mvo, ComMngPopulationMajorExcelVO vo){ // mvo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCnDescByName(vo.getPoliticalOutlook())); mvo.setIsRent(PopulHouseUseEnum.getCnDescByName(vo.getIsRent())); + mvo.setPatientRelation(PopulRelationEnum.getCnDescByName(vo.getPatientRelation())); // mvo.setRelation(PopulRelationEnum.getCnDescByName(vo.getRelation())); mvo.setHouseStatus(PopulHouseStatusEnum.getCnDescByName(vo.getHouseStatus())); mvo.setHousePurpose(PopulHousePurposeEnum.getCnDescByName(vo.getHousePurpose())); @@ -3249,6 +4735,92 @@ // mvo.setDeath(PopulOutOrLocalEnum.getCnDescByName(vo.getDeath())); } + private void setRehabilitationMistake(ComMngPopulationRehabilitationMistakeExcelVO mvo, ComMngPopulationRehabilitationExcelVO vo){ +// mvo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCnDescByName(vo.getPoliticalOutlook())); + mvo.setIsRent(PopulHouseUseEnum.getCnDescByName(vo.getIsRent())); + mvo.setPatientRelation(PopulRelationEnum.getCnDescByName(vo.getPatientRelation())); + mvo.setHouseStatus(PopulHouseStatusEnum.getCnDescByName(vo.getHouseStatus())); + mvo.setHousePurpose(PopulHousePurposeEnum.getCnDescByName(vo.getHousePurpose())); + mvo.setControlStatus(PopulHouseControlStatusEnum.getCnDescByName(vo.getControlStatus())); +// mvo.setCultureLevel(PopulCultureLevelEnum.getCnDescByName(vo.getCultureLevel())); +// mvo.setMarriage(PopulMarriageEnum.getCnDescByName(vo.getMarriage())); + mvo.setOutOrLocal(PopulOutOrLocalEnum.getCnDescByName(vo.getOutOrLocal())); + mvo.setIsRehab(PopulHouseUseEnum.getCnDescByName(vo.getIsRehab())); +// mvo.setResidence(PopulRelationEnum.getCnDescByName(vo.getResidence())); +// mvo.setPersonType(PopulPersonTypeEnum.getCnDescByName(vo.getPersonType())); +// mvo.setDeath(PopulOutOrLocalEnum.getCnDescByName(vo.getDeath())); + } + + private void setKeyMistake(ComMngPopulationKeyMistakeExcelVO mvo, ComMngPopulationKeyExcelVO vo){ +// mvo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCnDescByName(vo.getPoliticalOutlook())); + mvo.setIsRent(PopulHouseUseEnum.getCnDescByName(vo.getIsRent())); +// mvo.setPatientRelation(PopulRelationEnum.getCnDescByName(vo.getPatientRelation())); + mvo.setHouseStatus(PopulHouseStatusEnum.getCnDescByName(vo.getHouseStatus())); + mvo.setHousePurpose(PopulHousePurposeEnum.getCnDescByName(vo.getHousePurpose())); + mvo.setControlStatus(PopulHouseControlStatusEnum.getCnDescByName(vo.getControlStatus())); +// mvo.setCultureLevel(PopulCultureLevelEnum.getCnDescByName(vo.getCultureLevel())); +// mvo.setMarriage(PopulMarriageEnum.getCnDescByName(vo.getMarriage())); + mvo.setOutOrLocal(PopulOutOrLocalEnum.getCnDescByName(vo.getOutOrLocal())); +// mvo.setIsRehab(PopulHouseUseEnum.getCnDescByName(vo.getIsRehab())); +// mvo.setResidence(PopulRelationEnum.getCnDescByName(vo.getResidence())); +// mvo.setPersonType(PopulPersonTypeEnum.getCnDescByName(vo.getPersonType())); +// mvo.setDeath(PopulOutOrLocalEnum.getCnDescByName(vo.getDeath())); + } + + private void setSentenceMistake(ComMngPopulationSentenceMistakeExcelVO mvo, ComMngPopulationSentenceExcelVO vo){ +// mvo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCnDescByName(vo.getPoliticalOutlook())); + mvo.setIsRent(PopulHouseUseEnum.getCnDescByName(vo.getIsRent())); +// mvo.setPatientRelation(PopulRelationEnum.getCnDescByName(vo.getPatientRelation())); + mvo.setHouseStatus(PopulHouseStatusEnum.getCnDescByName(vo.getHouseStatus())); + mvo.setHousePurpose(PopulHousePurposeEnum.getCnDescByName(vo.getHousePurpose())); + mvo.setControlStatus(PopulHouseControlStatusEnum.getCnDescByName(vo.getControlStatus())); +// mvo.setCultureLevel(PopulCultureLevelEnum.getCnDescByName(vo.getCultureLevel())); +// mvo.setMarriage(PopulMarriageEnum.getCnDescByName(vo.getMarriage())); + mvo.setOutOrLocal(PopulOutOrLocalEnum.getCnDescByName(vo.getOutOrLocal())); +// mvo.setIsRehab(PopulHouseUseEnum.getCnDescByName(vo.getIsRehab())); +// mvo.setResidence(PopulRelationEnum.getCnDescByName(vo.getResidence())); +// mvo.setPersonType(PopulPersonTypeEnum.getCnDescByName(vo.getPersonType())); +// mvo.setDeath(PopulOutOrLocalEnum.getCnDescByName(vo.getDeath())); + } + + private void setVeteransMistake(ComMngPopulationVeteransMistakeExcelVO mvo, ComMngPopulationVeteransExcelVO vo){ + mvo.setRegiterNature(PopulRegiterNatureEnum.getCnDescByName(vo.getRegiterNature())); + mvo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCnDescByName(vo.getPoliticalOutlook())); + mvo.setIsRent(PopulHouseUseEnum.getCnDescByName(vo.getIsRent())); +// mvo.setPatientRelation(PopulRelationEnum.getCnDescByName(vo.getPatientRelation())); + mvo.setHouseStatus(PopulHouseStatusEnum.getCnDescByName(vo.getHouseStatus())); + mvo.setHousePurpose(PopulHousePurposeEnum.getCnDescByName(vo.getHousePurpose())); + mvo.setControlStatus(PopulHouseControlStatusEnum.getCnDescByName(vo.getControlStatus())); +// mvo.setCultureLevel(PopulCultureLevelEnum.getCnDescByName(vo.getCultureLevel())); + mvo.setMarriage(PopulMarriageEnum.getCnDescByName(vo.getMarriage())); + mvo.setOutOrLocal(PopulOutOrLocalEnum.getCnDescByName(vo.getOutOrLocal())); + mvo.setIsVeteransTraining(PopulHouseUseEnum.getCnDescByName(vo.getIsVeteransTraining())); + mvo.setIsBusiness(PopulHouseUseEnum.getCnDescByName(vo.getIsBusiness())); +// mvo.setIsRehab(PopulHouseUseEnum.getCnDescByName(vo.getIsRehab())); +// mvo.setResidence(PopulRelationEnum.getCnDescByName(vo.getResidence())); +// mvo.setPersonType(PopulPersonTypeEnum.getCnDescByName(vo.getPersonType())); +// mvo.setDeath(PopulOutOrLocalEnum.getCnDescByName(vo.getDeath())); + } + + private void setDisabilityMistake(ComMngPopulationDisabilityMistakeExcelVO mvo, ComMngPopulationDisabilityExcelVO vo){ +// mvo.setRegiterNature(PopulRegiterNatureEnum.getCnDescByName(vo.getRegiterNature())); +// mvo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCnDescByName(vo.getPoliticalOutlook())); + mvo.setIsRent(PopulHouseUseEnum.getCnDescByName(vo.getIsRent())); +// mvo.setPatientRelation(PopulRelationEnum.getCnDescByName(vo.getPatientRelation())); + mvo.setHouseStatus(PopulHouseStatusEnum.getCnDescByName(vo.getHouseStatus())); + mvo.setHousePurpose(PopulHousePurposeEnum.getCnDescByName(vo.getHousePurpose())); + mvo.setControlStatus(PopulHouseControlStatusEnum.getCnDescByName(vo.getControlStatus())); + mvo.setCultureLevel(PopulCultureLevelEnum.getCnDescByName(vo.getCultureLevel())); +// mvo.setMarriage(PopulMarriageEnum.getCnDescByName(vo.getMarriage())); + mvo.setOutOrLocal(PopulOutOrLocalEnum.getCnDescByName(vo.getOutOrLocal())); +// mvo.setIsVeteransTraining(PopulHouseUseEnum.getCnDescByName(vo.getIsVeteransTraining())); +// mvo.setIsBusiness(PopulHouseUseEnum.getCnDescByName(vo.getIsBusiness())); +// mvo.setIsRehab(PopulHouseUseEnum.getCnDescByName(vo.getIsRehab())); +// mvo.setResidence(PopulRelationEnum.getCnDescByName(vo.getResidence())); +// mvo.setPersonType(PopulPersonTypeEnum.getCnDescByName(vo.getPersonType())); +// mvo.setDeath(PopulOutOrLocalEnum.getCnDescByName(vo.getDeath())); + } + /** * 判重方法 * @param key 主键 diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwDangerReportServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwDangerReportServiceImpl.java index a28111e..56416f1 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwDangerReportServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwDangerReportServiceImpl.java @@ -296,6 +296,10 @@ } BeanUtils.copyProperties(comSwDangerReportHandleDTO, comSwDangerReportDO); comSwDangerReportDO.setStatus(String.valueOf(SafeWordStatusEnum.YCL.getCode())); + ComSwDangerReportDO comSwDangerReportDO1 = comSwDangerReportDAO.selectById(comSwDangerReportHandleDTO.getDangerReportId()); + if (!comSwDangerReportDO1.getStatus().equals(String.valueOf(SafeWordStatusEnum.DCL.getCode()))) { + return R.fail("该隐患报告已处理,请勿重复操作"); + } int update = comSwDangerReportDAO.updateById(comSwDangerReportDO); if (update > 0) { return R.ok(); @@ -312,6 +316,10 @@ BeanUtils.copyProperties(comSwDangerReportRectifyDTO, comSwDangerReportDO); comSwDangerReportDO.setStatus(String.valueOf(SafeWordStatusEnum.YZG.getCode())); comSwDangerReportDO.setRectifyTime(DateUtils.getCurrentDateStr()); + ComSwDangerReportDO comSwDangerReportDO1 = comSwDangerReportDAO.selectById(comSwDangerReportRectifyDTO.getDangerReportId()); + if (comSwDangerReportDO1.getStatus().equals(String.valueOf(SafeWordStatusEnum.YZG.getCode()))) { + return R.fail("该隐患报告已整改,请勿重复操作"); + } int update = comSwDangerReportDAO.updateById(comSwDangerReportDO); if (update > 0) { return R.ok(); diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwRotaServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwRotaServiceImpl.java index 92faf27..9508c03 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwRotaServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComSwRotaServiceImpl.java @@ -1,5 +1,6 @@ package com.panzhihua.service_community.service.impl; +import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -284,9 +285,11 @@ @Override public R listSaveSwRotaExcelVO(List<ComSwRotaExcelVO> list, Long communityId) { + String[] parsePatterns = new String[]{"yyyy-MM-dd", "yyyy-M-dd", "yyyy-MM-d", "yyyy-M-d", "yyyy/MM/dd", "yyyy/M/dd", "yyyy/MM/d", "yyyy/M/d"}; List<ComSwRotaDO> comSwRotaDOS = new ArrayList<>(); for (ComSwRotaExcelVO comSwRotaExcelVO : list){ - Integer count = comSwRotaDAO.selectCount(new QueryWrapper<ComSwRotaDO>().lambda().eq(ComSwRotaDO::getRotaDate, comSwRotaExcelVO.getRotaDate())); + Date date = DateUtil.parse(comSwRotaExcelVO.getRotaDate(),parsePatterns); + Integer count = comSwRotaDAO.selectCount(new QueryWrapper<ComSwRotaDO>().lambda().eq(ComSwRotaDO::getRotaDate, date)); if (count > 0) { return R.fail("值班日期已存在," + comSwRotaExcelVO.getRotaDate() + "重复"); } @@ -315,21 +318,22 @@ BeanUtils.copyProperties(comSwRotaExcelVO, comSwRotaDO); comSwRotaDO.setId(Snowflake.getId()); comSwRotaDO.setCommunityId(communityId); - if (StringUtils.isNotEmpty(comSwRotaExcelVO.getRotaDate())) { - String el = "(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29) \n" + - "(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29) "; - Pattern p = Pattern.compile(el); - Matcher m = p.matcher(comSwRotaExcelVO.getRotaDate()); - if (!m.matches()) { - return R.fail(comSwRotaExcelVO.getRotaDate() + "日期格式不正确"); - } - } - try { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - comSwRotaDO.setRotaDate(sdf.parse(comSwRotaExcelVO.getRotaDate())); - } catch (ParseException e) { - e.printStackTrace(); - } +// if (StringUtils.isNotEmpty(comSwRotaExcelVO.getRotaDate())) { +// String el = "(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29) \n" + +// "(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29) "; +// Pattern p = Pattern.compile(el); +// Matcher m = p.matcher(comSwRotaExcelVO.getRotaDate()); +// if (!m.matches()) { +// return R.fail(comSwRotaExcelVO.getRotaDate() + "日期格式不正确"); +// } +// } +// try { +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); +// comSwRotaDO.setRotaDate(sdf.parse(comSwRotaExcelVO.getRotaDate())); +// } catch (ParseException e) { +// e.printStackTrace(); +// } + comSwRotaDO.setRotaDate(date); comSwRotaDO.setRotaLeader(StringUtils.join(leaderIds, ",")); comSwRotaDO.setRotaPerson(StringUtils.join(personIds, ",")); comSwRotaDO.setLeaderName(comSwRotaExcelVO.getLeaderName().replace("、",",")); diff --git a/springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/filters/JWTAuthenticationTokenFilter.java b/springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/filters/JWTAuthenticationTokenFilter.java index 6ed80c9..7a79fa3 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/filters/JWTAuthenticationTokenFilter.java +++ b/springcloud_k8s_panzhihuazhihuishequ/zuul/src/main/java/com/panzhihua/zuul/filters/JWTAuthenticationTokenFilter.java @@ -81,7 +81,7 @@ boolean isShop = requestURI.contains("isShop"); boolean noToken = requestURI.contains("noToken"); boolean listadvertisement = requestURI.contains("listadvertisement"); - boolean bigscreen = requestURI.contains("/bigscreen/party"); +// boolean bigscreen = requestURI.contains("/bigscreen/party"); // boolean pageworkguide = !requestURI.contains("workguide/pageworkguide"); // boolean detailworkguide = !requestURI.contains("workguide/detailworkguide"); // boolean pagedynamic = !requestURI.contains("partybuilding/pagedynamic"); @@ -89,7 +89,8 @@ SafeboxRequestWrapper safeboxRequestWrapper = new SafeboxRequestWrapper(request); if (login||doc||css||js||ui||swagger||ico||docs||error||refreshToken||useragreement||wxPay - ||wxCgi||isShop||listadvertisement||noToken||bigscreen) { +// ||wxCgi||isShop||listadvertisement||noToken||bigscreen) { + ||wxCgi||isShop||listadvertisement||noToken) { //什么也不做 } else { // 获取请求头中JWT的Token -- Gitblit v1.7.1