java110
2020-12-02 26d31b2687f5f28704d44e83f948eef00a94da16
service-front/src/main/java/com/java110/front/smo/assetImport/impl/AssetImportSMOImpl.java
@@ -4,20 +4,11 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.core.component.BaseComponentSMO;
import com.java110.core.context.IPageData;
import com.java110.entity.assetImport.ImportFee;
import com.java110.entity.assetImport.ImportFloor;
import com.java110.entity.assetImport.ImportOwner;
import com.java110.entity.assetImport.ImportParkingSpace;
import com.java110.entity.assetImport.ImportRoom;
import com.java110.entity.assetImport.*;
import com.java110.entity.component.ComponentValidateResult;
import com.java110.front.smo.assetImport.IAssetImportSMO;
import com.java110.utils.constant.FeeTypeConstant;
import com.java110.utils.constant.ServiceConstant;
import com.java110.utils.util.Assert;
import com.java110.utils.util.CommonUtil;
import com.java110.utils.util.DateUtil;
import com.java110.utils.util.ImportExcelUtils;
import com.java110.utils.util.StringUtil;
import com.java110.utils.util.*;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.slf4j.Logger;
@@ -183,7 +174,7 @@
        ResponseEntity<String> responseEntity = new ResponseEntity<String>("成功", HttpStatus.OK);
        ImportOwner owner = null;
        for (ImportParkingSpace parkingSpace : parkingSpaces) {
            responseEntity = new ResponseEntity<String>("成功", HttpStatus.OK);
            JSONObject savedParkingAreaInfo = getExistsParkingArea(pd, result, parkingSpace);
            paramIn = new JSONObject();
            // 如果不存在,才插入
@@ -240,26 +231,28 @@
            paramIn.put("psId", savedParkingSpaceInfo.getString("psId"));
            paramIn.put("storeId", result.getStoreId());
            paramIn.put("sellOrHire", parkingSpace.getSellOrHire());
            paramIn.put("startTime", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
            paramIn.put("endTime", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
            if ("H".equals(parkingSpace.getSellOrHire())) {
                paramIn.put("cycles", "0");
            }
            String feeTypeCd = "1001".equals(parkingSpace.getTypeCd())
                    ? FeeTypeConstant.FEE_TYPE_SELL_UP_PARKING_SPACE : FeeTypeConstant.FEE_TYPE_SELL_DOWN_PARKING_SPACE;
            apiUrl = ServiceConstant.SERVICE_API_URL + "/api/feeConfig.listFeeConfigs?page=1&row=1&communityId=" + result.getCommunityId() + "&feeTypeCd=" + feeTypeCd + "&isDefault=T";
            responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
//            String feeTypeCd = "1001".equals(parkingSpace.getTypeCd())
//                    ? FeeTypeConstant.FEE_TYPE_SELL_UP_PARKING_SPACE : FeeTypeConstant.FEE_TYPE_SELL_DOWN_PARKING_SPACE;
//            apiUrl = ServiceConstant.SERVICE_API_URL + "/api/feeConfig.listFeeConfigs?page=1&row=1&communityId=" + result.getCommunityId() + "&feeTypeCd=" + feeTypeCd + "&isDefault=T";
//            responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
//
//            if (responseEntity.getStatusCode() != HttpStatus.OK) {
//                continue;
//            }
            if (responseEntity.getStatusCode() != HttpStatus.OK) {
                continue;
            }
//            JSONObject configInfo = JSONObject.parseObject(responseEntity.getBody()).getJSONArray("feeConfigs").getJSONObject(0);
//            if (!configInfo.containsKey("additionalAmount")) {
//                continue;
//            }
            JSONObject configInfo = JSONObject.parseObject(responseEntity.getBody()).getJSONArray("feeConfigs").getJSONObject(0);
            if (!configInfo.containsKey("additionalAmount")) {
                continue;
            }
            paramIn.put("receivedAmount", configInfo.getString("additionalAmount"));
//            paramIn.put("receivedAmount", configInfo.getString("additionalAmount"));
            apiUrl = ServiceConstant.SERVICE_API_URL + "/api/parkingSpace.sellParkingSpace";
            responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST);
@@ -302,7 +295,7 @@
            paramIn.put("apartment", room.getSection());
            paramIn.put("state", "2002");
            paramIn.put("builtUpArea", room.getBuiltUpArea());
            paramIn.put("unitPrice", "1000.00");
            paramIn.put("feeCoefficient", "1.00");
            responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST);
@@ -505,7 +498,12 @@
            paramIn.put("ownerTypeCd", "1001");
            paramIn.put("idCard", owner.getIdCard());
            responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST);
            if (responseEntity.getStatusCode() == HttpStatus.OK) {
                JSONObject body = JSONObject.parseObject(responseEntity.getBody());
                if (body.containsKey("code") && body.getIntValue("code") != 0) {
                    throw new IllegalArgumentException(body.getString("msg"));
                }
                savedOwnerInfo = getExistsOwner(pd, result, owner);
                owner.setOwnerId(savedOwnerInfo.getString("ownerId"));
            }
@@ -537,6 +535,8 @@
                paramIn.put("floorNum", importFloor.getFloorNum());
                paramIn.put("userId", result.getUserId());
                paramIn.put("name", importFloor.getFloorNum() + "号楼");
                paramIn.put("floorArea", 1.00);
                responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST);
                savedFloorInfo = getExistsFloor(pd, result, importFloor);
            }
@@ -564,6 +564,7 @@
            paramIn.put("unitNum", importFloor.getUnitNum());
            paramIn.put("layerCount", importFloor.getLayerCount());
            paramIn.put("lift", importFloor.getLift());
            paramIn.put("unitArea", 1.00);
            responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST);
            //将unitId 刷入ImportFloor对象
@@ -708,10 +709,10 @@
            if (StringUtil.isNullOrNone(os[0])) {
                continue;
            }
            Assert.hasLength(os[0].toString(), "车位信息选项中" + (osIndex + 1) + "行停车场编号为空");
            Assert.hasLength(os[1].toString(), "车位信息选项中" + (osIndex + 1) + "行车位编码为空");
            Assert.hasLength(os[2].toString(), "车位信息选项中" + (osIndex + 1) + "行停车场类型为空");
            Assert.hasLength(os[3].toString(), "车位信息选项中" + (osIndex + 1) + "行面积为空,没有请填写规定值 如10");
            Assert.hasValue(os[0], "车位信息选项中" + (osIndex + 1) + "行停车场编号为空");
            Assert.hasValue(os[1], "车位信息选项中" + (osIndex + 1) + "行车位编码为空");
            Assert.hasValue(os[2], "车位信息选项中" + (osIndex + 1) + "行停车场类型为空");
            Assert.hasValue(os[3], "车位信息选项中" + (osIndex + 1) + "行面积为空,没有请填写规定值 如10");
            importParkingSpace = new ImportParkingSpace();
            importParkingSpace.setPaNum(os[0].toString());
            importParkingSpace.setPsNum(os[1].toString());
@@ -755,14 +756,14 @@
            if (StringUtil.isNullOrNone(os[0])) {
                continue;
            }
            Assert.hasLength(os[0].toString(), "房屋信息选项中" + (osIndex + 1) + "行楼栋编号为空");
            Assert.hasLength(os[1].toString(), "房屋信息选项中" + (osIndex + 1) + "行单元编号为空");
            Assert.hasLength(os[2].toString(), "房屋信息选项中" + (osIndex + 1) + "行房屋楼层为空");
            Assert.hasLength(os[3].toString(), "房屋信息选项中" + (osIndex + 1) + "行房屋户型为空");
            Assert.hasLength(os[4].toString(), "房屋信息选项中" + (osIndex + 1) + "行建筑面积为空");
            if (!StringUtil.isNullOrNone(os[5])) {
                Assert.hasLength(os[6].toString(), "房屋信息选项中" + (osIndex + 1) + "行房屋费用为空");
                Assert.hasLength(os[7].toString(), "房屋信息选项中" + (osIndex + 1) + "行费用到期时间为空");
            Assert.hasValue(os[1], "房屋信息选项中" + (osIndex + 1) + "行楼栋编号为空");
            Assert.hasValue(os[2], "房屋信息选项中" + (osIndex + 1) + "行单元编号为空");
            Assert.hasValue(os[3], "房屋信息选项中" + (osIndex + 1) + "行房屋楼层为空");
            Assert.hasValue(os[4], "房屋信息选项中" + (osIndex + 1) + "行房屋户型为空");
            Assert.hasValue(os[5], "房屋信息选项中" + (osIndex + 1) + "行建筑面积为空");
            if (!StringUtil.isNullOrNone(os[6])) {
                Assert.hasValue(os[7], "房屋信息选项中" + (osIndex + 1) + "行房屋费用为空");
                Assert.hasValue(os[8], "房屋信息选项中" + (osIndex + 1) + "行费用到期时间为空");
            }
            importRoom = new ImportRoom();
            importRoom.setRoomNum(os[0].toString());
@@ -771,7 +772,7 @@
            importRoom.setSection(os[4].toString());
            importRoom.setBuiltUpArea(Double.parseDouble(os[5].toString()));
            if (!StringUtil.isEmpty(os[7].toString())) {
            if (!StringUtil.isNullOrNone(os[6])) {
                importRoom.setRoomFeeId(os[7].toString());
                importRoom.setFeeEndDate(os[8].toString());
            }
@@ -803,22 +804,22 @@
            if (StringUtil.isNullOrNone(os[0])) {
                continue;
            }
            Assert.hasLength(os[0].toString(), "费用设置选项中" + (osIndex + 1) + "行费用编号为空");
            Assert.hasLength(os[1].toString(), "费用设置选项中" + (osIndex + 1) + "行费用类型为空");
            Assert.hasLength(os[2].toString(), "费用设置选项中" + (osIndex + 1) + "行收费项目为空");
            Assert.hasLength(os[3].toString(), "费用设置选项中" + (osIndex + 1) + "行费用标识为空");
            Assert.hasLength(os[4].toString(), "费用设置选项中" + (osIndex + 1) + "行费用类型为空");
            Assert.hasLength(os[5].toString(), "费用设置选项中" + (osIndex + 1) + "行缴费周期为空");
            Assert.hasValue(os[0], "费用设置选项中" + (osIndex + 1) + "行费用编号为空");
            Assert.hasValue(os[1], "费用设置选项中" + (osIndex + 1) + "行费用类型为空");
            Assert.hasValue(os[2], "费用设置选项中" + (osIndex + 1) + "行收费项目为空");
            Assert.hasValue(os[3], "费用设置选项中" + (osIndex + 1) + "行费用标识为空");
            Assert.hasValue(os[4], "费用设置选项中" + (osIndex + 1) + "行费用类型为空");
            Assert.hasValue(os[5], "费用设置选项中" + (osIndex + 1) + "行缴费周期为空");
            Assert.isInteger(os[5].toString(), "费用设置选项中" + (osIndex + 1) + "行缴费周期不是正整数");
            Assert.hasLength(os[6].toString(), "费用设置选项中" + (osIndex + 1) + "行出账类型为空");
            Assert.hasValue(os[6], "费用设置选项中" + (osIndex + 1) + "行出账类型为空");
            Assert.isDate(os[7].toString(), DateUtil.DATE_FORMATE_STRING_B, "费用设置选项中" + (osIndex + 1) + "行计费起始时间不是有效时间格式 请输入类似2020-06-01");
            Assert.isDate(os[8].toString(), DateUtil.DATE_FORMATE_STRING_B, "费用设置选项中" + (osIndex + 1) + "行计费终止时间不是有效时间格式 请输入类似2037-01-01");
            Assert.hasLength(os[9].toString(), "费用设置选项中" + (osIndex + 1) + "行计算公式为空");
            Assert.hasValue(os[9], "费用设置选项中" + (osIndex + 1) + "行计算公式为空");
            if (!"1001".equals(os[9].toString()) && !"2002".equals(os[9].toString())) {
                throw new IllegalArgumentException("费用设置选项中" + (osIndex + 1) + "行计算公式错误 请填写1001 或者2002");
            }
            Assert.hasLength(os[10].toString(), "费用设置选项中" + (osIndex + 1) + "行计费单价为空");
            Assert.hasLength(os[11].toString(), "费用设置选项中" + (osIndex + 1) + "行固定费用为空");
            Assert.hasValue(os[10], "费用设置选项中" + (osIndex + 1) + "行计费单价为空");
            Assert.hasValue(os[11], "费用设置选项中" + (osIndex + 1) + "行固定费用为空");
            importFee = new ImportFee();
            importFee.setId(os[0].toString());
            importFee.setFeeTypeCd("物业费".equals(os[1]) ? "888800010001" : "888800010002");
@@ -892,27 +893,40 @@
        List<Object[]> oList = ImportExcelUtils.listFromSheet(sheet);
        ImportOwner importOwner = null;
        for (int osIndex = 0; osIndex < oList.size(); osIndex++) {
            Object[] os = oList.get(osIndex);
            if (osIndex == 0) { // 第一行是 头部信息 直接跳过
                continue;
            try {
                Object[] os = oList.get(osIndex);
                if (osIndex == 0) { // 第一行是 头部信息 直接跳过
                    continue;
                }
                if (StringUtil.isNullOrNone(os[0])) {
                    continue;
                }
                Assert.hasValue(os[0], "业主信息选项中" + (osIndex + 1) + "行业主编号为空");
                Assert.hasValue(os[1], "业主信息选项中" + (osIndex + 1) + "行业主名称为空");
                Assert.hasValue(os[2], "业主信息选项中" + (osIndex + 1) + "行业主性别为空");
                String tel = StringUtil.isNullOrNone(os[4]) ? "19999999999" : os[4].toString();
                String idCard = StringUtil.isNullOrNone(os[5]) ? "10000000000000000001" : os[5].toString();
                if (os[4].toString().length() > 11) {
                    throw new IllegalArgumentException(os[1].toString() + " 的手机号超过11位,请核实");
                }
                if (os[5].toString().length() > 18) {
                    throw new IllegalArgumentException(os[1].toString() + " 的身份证超过18位,请核实");
                }
                String age = StringUtil.isNullOrNone(os[3]) ? CommonUtil.getAgeByCertId(idCard) : os[3].toString();
                importOwner = new ImportOwner();
                importOwner.setOwnerNum(os[0].toString());
                importOwner.setOwnerName(os[1].toString());
                importOwner.setSex("男".equals(os[2].toString()) ? "0" : "1");
                importOwner.setAge(Integer.parseInt(age));
                importOwner.setTel(tel);
                importOwner.setIdCard(idCard);
                owners.add(importOwner);
            } catch (Exception e) {
                logger.error("第" + (osIndex + 1) + "行数据出现问题", e);
                throw new IllegalArgumentException("第" + (osIndex + 1) + "行数据出现问题"+e.getLocalizedMessage(),e);
            }
            if (StringUtil.isNullOrNone(os[0])) {
                continue;
            }
            Assert.hasLength(os[0].toString(), "业主信息选项中" + (osIndex + 1) + "行业主编号为空");
            Assert.hasLength(os[1].toString(), "业主信息选项中" + (osIndex + 1) + "行业主名称为空");
            Assert.hasLength(os[2].toString(), "业主信息选项中" + (osIndex + 1) + "行业主性别为空");
            String tel = StringUtil.isNullOrNone(os[4]) ? "19999999999" : os[4].toString();
            String idCard = StringUtil.isNullOrNone(os[5]) ? "10000000000000000001" : os[5].toString();
            String age = StringUtil.isNullOrNone(os[3]) ? CommonUtil.getAgeByCertId(idCard) : os[3].toString();
            importOwner = new ImportOwner();
            importOwner.setOwnerNum(os[0].toString());
            importOwner.setOwnerName(os[1].toString());
            importOwner.setSex("男".equals(os[2].toString()) ? "0" : "1");
            importOwner.setAge(Integer.parseInt(age));
            importOwner.setTel(tel);
            importOwner.setIdCard(idCard);
            owners.add(importOwner);
        }
    }
@@ -937,10 +951,10 @@
                continue;
            }
            Assert.hasLength(os[0].toString(), "楼栋单元选项中" + (osIndex + 1) + "行楼栋号为空");
            Assert.hasLength(os[1].toString(), "楼栋单元选项中" + (osIndex + 1) + "行单元编号为空");
            Assert.hasLength(os[2].toString(), "楼栋单元选项中" + (osIndex + 1) + "行总楼层为空");
            Assert.hasLength(os[3].toString(), "楼栋单元选项中" + (osIndex + 1) + "行是否有电梯为空");
            Assert.hasValue(os[0], "楼栋单元选项中" + (osIndex + 1) + "行楼栋号为空");
            Assert.hasValue(os[1], "楼栋单元选项中" + (osIndex + 1) + "行单元编号为空");
            Assert.hasValue(os[2], "楼栋单元选项中" + (osIndex + 1) + "行总楼层为空");
            Assert.hasValue(os[3], "楼栋单元选项中" + (osIndex + 1) + "行是否有电梯为空");
            importFloor = new ImportFloor();
            importFloor.setFloorNum(os[0].toString());
            importFloor.setUnitNum(os[1].toString());