huanghongfa
2021-08-19 c40be027ef8068b9a77bb24c94291dee25f563d8
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationVeteransExcelListen.java
@@ -13,8 +13,6 @@
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;
@@ -23,8 +21,6 @@
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;
@@ -111,10 +107,10 @@
            log.info("开始导入退役军人数据");
            log.info("表格总数据:" + list.size());
            if (list.size() == 0) {
                throw new ServiceException("500", "导入数据为空!");
                throw new ServiceException("000", "导入数据为空!");
            }
            ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue();
            String Veterans = Constants.VETERANS_POPULATION_ERROR_LIST + communityId;
            String Veterans = Constants.VETERANS_POPULATION_ERROR_LIST;
            Map<String,String> dictMap = dictionaryR.getData().stream().collect(Collectors.toMap(BcDictionaryVO::getDictName,BcDictionaryVO::getDictValue));
//        Map<String,Integer> dictMap = new HashMap<>();
@@ -135,54 +131,53 @@
                        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(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);
                        }
                    //判断身份证号码位数
                    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());
                        }
                    //获取用户性别
                    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));
                    }
@@ -242,33 +237,39 @@
                        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;
//                    if(StringUtils.isEmpty(oneData.get(12))){
//                        index++;
//                        ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO();
//                        setVeteransMistake(oneData, mistake);
//                        mistake.setMistake("楼排号不可为空");
//                        mistakes.add(mistake);
//                        continue;
//                    }
                    if(StringUtils.isNotEmpty(oneData.get(12))) {
                        vo.setFloor(oneData.get(12).trim());
                    }
                    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;
//                    if(StringUtils.isEmpty(oneData.get(13))){
//                        index++;
//                        ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO();
//                        setVeteransMistake(oneData, mistake);
//                        mistake.setMistake("单元号不可为空");
//                        mistakes.add(mistake);
//                        continue;
//                    }
                    if(StringUtils.isNotEmpty(oneData.get(13))) {
                        vo.setUnitNo(oneData.get(13).trim());
                    }
                    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;
//                    if(StringUtils.isEmpty(oneData.get(14))){
//                        index++;
//                        ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO();
//                        setVeteransMistake(oneData, mistake);
//                        mistake.setMistake("户室不可为空");
//                        mistakes.add(mistake);
//                        continue;
//                    }
                    if(StringUtils.isNotEmpty(oneData.get(14))) {
                        vo.setHouseNo(oneData.get(14).trim());
                    }
                    vo.setHouseNo(oneData.get(14).trim());
                    if(StringUtils.isNotEmpty(oneData.get(15))){
                        Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(15));
                        if(isOk.equals(-1)){
@@ -305,7 +306,7 @@
                            mistakes.add(mistake);
                            continue;
                        }
                        vo.setHousePurpose(PopulHousePurposeEnum.getCodeByName(oneData.get(14).trim()));
                        vo.setHousePurpose(isOk);
                    }
                    if(StringUtils.isNotEmpty(oneData.get(18))){
                        Integer isOk = PopulHouseControlStatusEnum.getCodeByName(oneData.get(18));
@@ -320,10 +321,10 @@
                        vo.setControlStatus(isOk);
                    }
                    if(StringUtils.isNotEmpty(oneData.get(19))){
                        vo.setEnlistDate(DateUtil.parse(oneData.get(19)));
                        vo.setEnlistDate(DateUtil.parse(oneData.get(19), parsePatterns));
                    }
                    if(StringUtils.isNotEmpty(oneData.get(20))){
                        vo.setRetireDate(DateUtil.parse(oneData.get(20)));
                        vo.setRetireDate(DateUtil.parse(oneData.get(20), parsePatterns));
                    }
                    if(StringUtils.isNotEmpty(oneData.get(21))){
                        vo.setPersonCategory(oneData.get(21).trim());
@@ -352,7 +353,7 @@
                            index++;
                            ComMngPopulationVeteransMistakeExcelVO mistake = new ComMngPopulationVeteransMistakeExcelVO();
                            setVeteransMistake(oneData, mistake);
                            mistake.setMistake("您填写的政治面貌有误");
                            mistake.setMistake("您填写的婚姻关系·有误");
                            mistakes.add(mistake);
                            continue;
                        }