jialh
1 天以前 dd6687b118561100e1677e88a9c2f5842a54c531
service-job/src/main/java/com/java110/job/importData/adapt/ImportRoomOwnerV2QueueDataAdapt.java
@@ -103,13 +103,24 @@
                doImportData(assetImportLogDetailDto);
                updateImportLogDetailState(assetImportLogDetailDto.getDetailId());
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            } catch (Exception e) {
                e.printStackTrace();
                if (e.getMessage().contains("### Error updating database")){
                    updateImportLogDetailState(assetImportLogDetailDto.getDetailId(), "未知错误,请联系管理员");
                }
                else {
                    updateImportLogDetailState(assetImportLogDetailDto.getDetailId(), e);
                String errorMsg = e.getMessage();
                // 先判空,再判断包含关系
                if (errorMsg != null && errorMsg.contains("### Error updating database")) {
                    updateImportLogDetailState(assetImportLogDetailDto.getDetailId(),
                            "未知错误,请联系管理员" + errorMsg);
                } else {
                    // 补充:这里也建议对 e 做兜底处理,避免传递空的异常信息
                    String finalMsg = errorMsg != null ? errorMsg : e.toString();
                    updateImportLogDetailState(assetImportLogDetailDto.getDetailId(), finalMsg);
                    // 如果原方法 updateImportLogDetailState 接收 Exception 类型参数,可保留:
                    // updateImportLogDetailState(assetImportLogDetailDto.getDetailId(), e);
                }
            }
        }
@@ -122,9 +133,25 @@
     * @param assetImportLogDetailDto
     */
    private void doImportData(AssetImportLogDetailDto assetImportLogDetailDto) {
        String test = "";
        int a = 6;
        JSONArray objects = JSONObject.parseArray(assetImportLogDetailDto.getContent());
        if (Vtil.defaultValue(objects.get(11)) == null) {
            objects.set(11, "无名");
            test = test + "\n业主名称为空";
//            throw new IllegalArgumentException("业主名称不能为空");
        }
        if (Vtil.defaultValue(objects.get(16)) == null){
            objects.set(16, "0");
            test = test + "\n房屋面积为空";
        }
//        if (Vtil.defaultValue(objects.get(54)) == null){
//            throw new IllegalArgumentException("性别内容有误!");
//        }
        ImportOwnerRoomDto importOwnerRoomDto = new ImportOwnerRoomDto();//房屋
        importOwnerRoomDto.setRoomId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_roomId));
@@ -139,25 +166,27 @@
        importOwnerRoomDto.setPersonRole(OwnerDto.PERSON_ROLE_OWNER);
        importOwnerRoomDto.setMonthlyUnitPrice(objects.getString(23));
        importOwnerRoomDto.setPropertyFeeMonth(objects.getString(24));
        //--------设置物业类型
        DictDto dictDto = new DictDto();
        dictDto.setTableName("building_room");
        dictDto.setTableColumns("room_sub_type");
        dictDto.setName(Vtil.defaultValue(objects.get(1)));
        List<DictDto> dictDtos = dictV1InnerServiceSMOImpl.queryDictAndSpecs(dictDto);
        if (dictDtos.isEmpty()) {
            DictPo dictPo = new DictPo();
            dictPo.setStatusCd(GenerateCodeFactory.getGeneratorId("2"));
            dictPo.setTableName("building_room");
            dictPo.setTableColumns("room_sub_type");
            dictPo.setName(Vtil.defaultValue(objects.get(1)));
            dictV1InnerServiceSMOImpl.saveDict(dictPo);
            dictDtos = dictV1InnerServiceSMOImpl.queryDictAndSpecs(dictDto);
        if (Vtil.defaultValue(objects.get(1)) != null) {
            //--------设置物业类型
            DictDto dictDto = new DictDto();
            dictDto.setTableName("building_room");
            dictDto.setTableColumns("room_sub_type");
            dictDto.setName(Vtil.defaultValue(objects.get(1)));
            List<DictDto> dictDtos = dictV1InnerServiceSMOImpl.queryDictAndSpecs(dictDto);
            if (dictDtos.isEmpty()) {
                throw new IllegalArgumentException("导入失败:字典中不存在物业类型:" + Vtil.defaultValue(objects.get(1)));
                DictPo dictPo = new DictPo();
                dictPo.setStatusCd(GenerateCodeFactory.getGeneratorId("2"));
                dictPo.setTableName("building_room");
                dictPo.setTableColumns("room_sub_type");
                dictPo.setName(Vtil.defaultValue(objects.get(1)));
                dictV1InnerServiceSMOImpl.saveDict(dictPo);
                dictDtos = dictV1InnerServiceSMOImpl.queryDictAndSpecs(dictDto);
                if (dictDtos.isEmpty()) {
                    throw new IllegalArgumentException("导入失败:字典中不存在物业类型:" + Vtil.defaultValue(objects.get(1)));
                }
            }
            importOwnerRoomDto.setRoomSubType(dictDtos.get(0).getStatusCd());
        }
        importOwnerRoomDto.setRoomSubType(dictDtos.get(0).getStatusCd());
        //----------
        importOwnerRoomDto.setPropertyType(Vtil.defaultValue(objects.get(2)));//住宅类型
@@ -166,9 +195,12 @@
        CommunityDto communityDto = new CommunityDto();
        communityDto.setCommunityCode(Vtil.defaultValue(objects.get(3)));
        communityDto.setName(Vtil.defaultValue(objects.get(4)));
        if (communityDto.getCommunityCode() == null && communityDto.getName() == null) {
            throw new IllegalArgumentException("导入失败:小区编码和小区名称都为空");
        }
        List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
        if (communityDtos.isEmpty()) {
            throw new IllegalArgumentException("导入失败:小区中不存在小区编码为‘" + Vtil.defaultValue(objects.get(1)) + "’的小区");
            throw new IllegalArgumentException("导入失败:小区中不存在小区‘" + Vtil.defaultValue(objects.get(3))+Vtil.defaultValue(objects.get(4)) + "’");
        } else if (communityDtos.size() > 1) {
            String communityNames = communityDtos.stream()
                    .map(CommunityDto::getName) // 提取每个小区的名称
@@ -187,7 +219,7 @@
        importOwnerRoomDto.setRoomNum(Vtil.defaultValue(objects.get(8)));//室
        importOwnerRoomDto.setDoorRoomNum(Vtil.defaultValue(objects.get(9)));//门市号
        importOwnerRoomDto.setPropertyAddress(Vtil.defaultValue(objects.get(10)));//业主地址
        importOwnerRoomDto.setRoomBuyer(Vtil.defaultValue(objects.get(11)));//购房人
        importOwnerRoomDto.setRoomBuyer(Vtil.defaultValue(objects.get(11) , null) == null ? "房屋:" + importOwnerRoomDto.getPropertyAddress() + "购房人姓名为空,待补全": Vtil.defaultValue(objects.get(11)));//购房人
        RoomDto roomDto = new RoomDto();
        roomDto.setCommunityId(importOwnerRoomDto.getCommunityId());
@@ -195,29 +227,39 @@
        roomDto.setFloorNum(importOwnerRoomDto.getFloorNum());
        roomDto.setUnitNum(importOwnerRoomDto.getUnitNum());
        roomDto.setRoomNum(importOwnerRoomDto.getRoomNum());
        if (roomDto.getRoomNum() ==null || roomDto.getRoomNum().equals("")){
            roomDto.setPropertyType("商铺");
        }
        roomDto.setDoorRoomNum(importOwnerRoomDto.getDoorRoomNum());
        roomDto.setPropertyAddress(importOwnerRoomDto.getPropertyAddress());
//        if (roomDto.getRoomNum() ==null || roomDto.getRoomNum().equals("")){
//            roomDto.setPropertyType("商铺");
//        }
        List<Object> objects1 = sqlSessionTemplate.selectList("roomServiceDaoImpl.getRoomInfo", BeanConvertUtil.beanCovertMap(roomDto));
        if (!objects1.isEmpty()) {
            throw new IllegalArgumentException("重复的房屋");
//            throw new IllegalArgumentException("重复的房屋:");
            test = test + "\n重复的房屋:来自导入记录:" + assetImportLogDetailDto.getLogId() + "\t" + assetImportLogDetailDto.getDetailId();
        }
        List<FeeConfigDto> feeDtos = null;
        if (!importOwnerRoomDto.getCommunityId().isEmpty()){
            FeeConfigDto feeConfigDto = new FeeConfigDto();
            feeConfigDto.setCommunityId(importOwnerRoomDto.getCommunityId());
            feeConfigDto.setSecondaryFeeTypeCdName(importOwnerRoomDto.getPropertyType());
            feeDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto);
            if (feeDtos.isEmpty()) {
                throw new IllegalArgumentException("物业类型`"+importOwnerRoomDto.getPropertyType()+"`未查询到收费项");
            if (importOwnerRoomDto.getPropertyType() == null) {
//                throw new IllegalArgumentException("物业类型为空");
                test = test + "\n物业类型为空,无法添加费用";
            }
            else {
                feeConfigDto.setSecondaryFeeTypeCdName(importOwnerRoomDto.getPropertyType());
                feeDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto);
                if (feeDtos.isEmpty()) {
//                    throw new IllegalArgumentException("物业类型`"+importOwnerRoomDto.getPropertyType()+"`未查询到收费项");
                    test = test + "\n物业类型`"+importOwnerRoomDto.getPropertyType()+"`未查询到收费项,无法添加费用";
                }
            }
        }
        //---------家庭成员、租客
        OwnerPo ownerPoTo3 = new OwnerPo();//
        if (!Vtil.defaultValue(objects.get(13)).isEmpty()) {
        if (Vtil.defaultValue(objects.get(13)) != null) {
            String link = Vtil.defaultValue(objects.get(13));
            OwnerDto ownerDto = new OwnerDto();
            ownerDto.setLink(link);
@@ -238,7 +280,7 @@
        }
        OwnerPo ownerPoTo2 = new OwnerPo();//TODO 租客未导入
        if (!Vtil.defaultValue(objects.get(15)).isEmpty()) {
        if (Vtil.defaultValue(objects.get(15)) != null) {
            String link = Vtil.defaultValue(objects.get(15));
            OwnerDto ownerDto = new OwnerDto();
            ownerDto.setLink(link);
@@ -269,7 +311,7 @@
        importOwnerRoomDto.setEoc(Vtil.defaultNum(objects.get(24+a)).toString());//设备运行费
        //-----TODO 待导入  催缴信息
        if (!Vtil.defaultValue(objects.get(31)).isEmpty()) {
        if (Vtil.defaultValue(objects.get(31)) != null) {
            OwnerCollectionDto ownerCollection = new OwnerCollectionDto();
            ownerCollection.setOwnerId(importOwnerRoomDto.getOwnerId());
            ownerCollection.setRoomId(importOwnerRoomDto.getRoomId());
@@ -287,7 +329,7 @@
        //-----
        //-----打折信息 TODO 未添加重复校验
        if (!Vtil.defaultValue(objects.get(42)).isEmpty()) {
        if (Vtil.defaultValue(objects.get(42)) != null) {
            ApplyRoomDiscountPo applyRoomDiscountPo = new ApplyRoomDiscountPo();//打折
            applyRoomDiscountPo.setArdId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_ardId));
            applyRoomDiscountPo.setCommunityId(importOwnerRoomDto.getCommunityId());
@@ -313,22 +355,22 @@
            try {
                applyRoomDiscountServiceDaoImpl.saveApplyRoomDiscountInfo(BeanConvertUtil.beanCovertMap(applyRoomDiscountPo));
            }catch (Exception e){
                throw new IllegalArgumentException("导入失败:打折信息导入存在错误");
                throw new IllegalArgumentException("导入失败:打折信息导入存在错误" + e.getMessage());
            }
        }
        //-----业主信息
        importOwnerRoomDto.setTel(Vtil.defaultValue(objects.get(45+a)));//手机号
        importOwnerRoomDto.setIdCard(Vtil.defaultValue(objects.get(46+a)));//身份证
        importOwnerRoomDto.setAddress(Vtil.defaultValue(objects.get(47+a)));//TODO 导入逻辑未添加该字段  联络地址
        importOwnerRoomDto.setSex(Vtil.defaultValue(objects.get(48+a)).equals("") ?"2" :  Vtil.defaultValue(objects.get(48+a)));
        importOwnerRoomDto.setOwnerName(Vtil.defaultValue(objects.get(11)));
        importOwnerRoomDto.setSex(Vtil.defaultValue(objects.get(48+a)) == null ?"2" :  Vtil.defaultValue(objects.get(48+a)));
        importOwnerRoomDto.setOwnerName(Vtil.defaultValue(Vtil.defaultValue(objects.get(11) , null) == null ? "房屋:" + importOwnerRoomDto.getPropertyAddress() + "购房人姓名为空,待补全": Vtil.defaultValue(objects.get(11))));
        importOwnerRoomDto.setHouseholdPoliceStation(Vtil.defaultValue(objects.get(50+a)));
        importOwnerRoomDto.setPropertyCertificateNo(Vtil.defaultValue(objects.get(51+a)));
        importOwnerRoomDto.setIsEvChargerInstalled(Vtil.defaultValue(objects.get(52+a)));
        if (Vtil.defaultValue(objects.get(61),null) != null) {
        if (Vtil.defaultValue(objects.get(61),null) != null || Vtil.defaultValue(objects.get(141)) == null || Vtil.defaultValue(objects.get(147+a)) == null || Vtil.defaultValue(objects.get(149+a)) == null) {
            OweFeeCallablePo oweFeeCallablePo = new OweFeeCallablePo();
            oweFeeCallablePo.setOfcId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_attrId));
            oweFeeCallablePo.setAmountdOwed("0");
@@ -347,6 +389,14 @@
            oweFeeCallablePo.setStaffId("302025062612580518");
            oweFeeCallablePo.setStaffName("刘志勇");
            oweFeeCallablePo.setState(OweFeeCallableDto.STATE_COMPLETE);
            oweFeeCallablePo.setReceivableAmount(Vtil.defaultValue(objects.get(155+a)));
            oweFeeCallablePo.setReceivedAmount(Vtil.defaultValue(objects.get(156+a)));
//            oweFeeCallablePo.setDifferenceReason(Vtil.defaultValue(objects.get(157+a)));
//            oweFeeCallablePo.setReceiptTime(Vtil.defaultValue(objects.get(158+a)));
            oweFeeCallablePo.setPayee(Vtil.defaultValue(objects.get(159+a)));
            if (Vtil.defaultValue(objects.get(160+a), "") != null) {
                oweFeeCallablePo.setRemark(oweFeeCallablePo.getRemark() + "。备注信息:" + Vtil.defaultValue(objects.get(160+a)));
            }
//            oweFeeCallablePo.setStartTime(Vtil.defaultValueToDate(objects.get(61)));//TODO 时间段需要拆分
//            oweFeeCallablePo.setEndTime(Vtil.defaultValueToDate(objects.get(61)));
            oweFeeCallablePo.setCreateTime(Vtil.defaultValueToDate(objects.get(53+a)));
@@ -357,15 +407,15 @@
            for (int i = 0; i < 5 ; i++) {
                int index = i*4 + 65;
                if(objects.get(index) == null){
                    break;
                }
//                if(objects.get(index) == null || objects.get(index).equals("")) {
//                    break;
//                }
                HouseMailRecord houseMailRecord = new HouseMailRecord();
                houseMailRecord.setId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_houseId));
                houseMailRecord.setOwnerId(importOwnerRoomDto.getOwnerId());
                houseMailRecord.setHouseId(importOwnerRoomDto.getRoomId());
                houseMailRecord.setCallableId(oweFeeCallablePo.getOfcId());
                houseMailRecord.setCreateTime(Vtil.defaultValueToDate(objects.get(index)));
                houseMailRecord.setSendDate(Vtil.defaultValueToDate(objects.get(index)));
                houseMailRecord.setMailNo(Vtil.defaultValue(objects.get(index+1)));
                houseMailRecord.setServiceFee(Vtil.defaultValue(objects.get(index+2)));
                houseMailRecord.setMailResult(Vtil.defaultValue(objects.get(index+3)));
@@ -397,7 +447,7 @@
            //----
            //----法院审理程序
            if (!Vtil.defaultValue(objects.get(141)).isEmpty()) {
//            if (!Vtil.defaultValue(objects.get(141)).isEmpty()) {
                CourtTrialProcedure courtTrialProcedure = new CourtTrialProcedure();
                courtTrialProcedure.setCallableId(oweFeeCallablePo.getOfcId());
                courtTrialProcedure.setOwnerId(importOwnerRoomDto.getOwnerId());
@@ -417,11 +467,11 @@
                courtTrialProcedure.setJudgmentResult(Vtil.defaultValue(objects.get(145+a)));
                courtTrialProcedure.setRemark(Vtil.defaultValue(objects.get(146+a)));
                applyRoomDiscountServiceDaoImpl.saveCourtTrialProcedure(BeanConvertUtil.beanCovertMap(courtTrialProcedure));
            }
//            }
            //-----
            //法院执行程序
            if (!Vtil.defaultValue(objects.get(147+a)).isEmpty()) {
//            if (!Vtil.defaultValue(objects.get(147+a)).isEmpty() || !Vtil.defaultValue(objects.get(149+a)).isEmpty()) {
                CourtExecutionProcedure courtExecutionProcedure = new CourtExecutionProcedure();
                courtExecutionProcedure.setCallableId(oweFeeCallablePo.getOfcId());
                courtExecutionProcedure.setOwnerId(importOwnerRoomDto.getOwnerId());
@@ -436,13 +486,13 @@
                courtExecutionProcedure.setRemark(Vtil.defaultValue(objects.get(160+a)));
                applyRoomDiscountServiceDaoImpl.saveCourtExecutionProcedure(BeanConvertUtil.beanCovertMap(courtExecutionProcedure));
            }
//            }
            //----添加电联
            List<Object> mailCallRecords = new ArrayList<Object>();
            for (int i = 0 ; i < 9 ; i++) {
                int index = i * 3 + 86;
                if(Vtil.defaultValue(objects.get(index)).isEmpty()){
                if(Vtil.defaultValue(objects.get(index)) == null){
//                if (i == 0){
//                    MailCallRecord mailCallRecord = new MailCallRecord();
//                    mailCallRecord.setRemark(objects.get(115).toString());
@@ -471,7 +521,7 @@
        //产调日期
        if (!Vtil.defaultValue(objects.get(126)).isEmpty()) {
//        if (!Vtil.defaultValue(objects.get(126)).isEmpty()) {
            OwnerPropertySurvey ownerPropertySurvey = new OwnerPropertySurvey();
            ownerPropertySurvey.setOwnerId(importOwnerRoomDto.getOwnerId());
            ownerPropertySurvey.setRoomId(importOwnerRoomDto.getRoomId());
@@ -480,11 +530,10 @@
            ownerPropertySurvey.setName(Vtil.defaultValue(objects.get(127)));
            ownerPropertySurvey.setExtraDate(Vtil.defaultValueToDate(objects.get(128)));
            int save = applyRoomDiscountServiceDaoImpl.saveOwnerPropertySurvey(BeanConvertUtil.beanCovertMap(ownerPropertySurvey));
        }
//        }
        //----
        //诉讼
        if (!Vtil.defaultValue(objects.get(130)).isEmpty()) {
            LitigationInfoPo litigationInfoPo = new LitigationInfoPo();
            litigationInfoPo.setLitigationDate(Vtil.defaultValue(objects.get(130)));
            litigationInfoPo.setArrearsPeriod(Vtil.defaultValue(objects.get(131)));
@@ -497,9 +546,8 @@
            litigationInfoPo.setOwnerId(importOwnerRoomDto.getOwnerId());
            sqlSessionTemplate.insert("litigationInfoServiceDaoImpl.saveLitigationInfo",
                    BeanConvertUtil.beanCovertMap(litigationInfoPo));
        }
        importOwnerRoomDto.setRoomState(importOwnerRoomDto.getOwnerName().equals("") ? "2004" : "2001");
        importOwnerRoomDto.setRoomState(importOwnerRoomDto.getOwnerName() == null ? "2004" : "2001");
        importOwnerRoomDto.setRemark(test);
        importOwnerRoomInnerServiceSMOImpl.saveOwnerRoom(importOwnerRoomDto);
        OwnerDto ownerDto = new OwnerDto();
        ownerDto.setOwnerId(importOwnerRoomDto.getOwnerId());