java110
2021-06-01 b497ff41e47f4ebe69b86f13f6972f34f33f4884
service-front/src/main/java/com/java110/front/smo/assetImport/impl/AssetImportSMOImpl.java
@@ -22,7 +22,9 @@
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@@ -234,8 +236,8 @@
            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));
            paramIn.put("startTime", parkingSpace.getStartTime());
            paramIn.put("endTime", parkingSpace.getEndTime());
            if ("H".equals(parkingSpace.getSellOrHire())) {
                paramIn.put("cycles", "0");
@@ -524,7 +526,7 @@
                paramIn.put("communityId", result.getCommunityId());
                paramIn.put("floorNum", importFloor.getFloorNum());
                paramIn.put("userId", result.getUserId());
                paramIn.put("name", importFloor.getFloorNum() + "号楼");
                paramIn.put("name", importFloor.getFloorNum() + "栋");
                paramIn.put("floorArea", 1.00);
                responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST);
@@ -720,10 +722,42 @@
                importParkingSpace.setCarType(os[7].toString());
                importParkingSpace.setCarColor(os[8].toString());
                importParkingSpace.setSellOrHire(os[9].toString());
                String startTime = excelDoubleToDate(os[10].toString());
                String endTime = excelDoubleToDate(os[11].toString());
                Assert.isDate(startTime, DateUtil.DATE_FORMATE_STRING_B, (osIndex + 1) + "行开始时间格式错误 请填写YYYY-MM-DD 文本格式");
                Assert.isDate(endTime, DateUtil.DATE_FORMATE_STRING_B, (osIndex + 1) + "行结束时间格式错误 请填写YYYY-MM-DD 文本格式");
                importParkingSpace.setStartTime(startTime);
                importParkingSpace.setEndTime(endTime);
            }
            parkingSpaces.add(importParkingSpace);
        }
    }
    //解析Excel日期格式
    public static String excelDoubleToDate(String strDate) {
        if (strDate.length() == 5) {
            try {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                Date tDate = DoubleToDate(Double.parseDouble(strDate));
                return sdf.format(tDate);
            } catch (Exception e) {
                e.printStackTrace();
                return strDate;
            }
        }
        return strDate;
    }
    //解析Excel日期格式
    public static Date DoubleToDate(Double dVal) {
        Date tDate = new Date();
        long localOffset = tDate.getTimezoneOffset() * 60000; //系统时区偏移 1900/1/1 到 1970/1/1 的 25569 天
        tDate.setTime((long) ((dVal - 25569) * 24 * 3600 * 1000 + localOffset));
        return tDate;
    }
    /**
@@ -752,7 +786,7 @@
                Assert.hasValue(os[3], "房屋信息选项中" + (osIndex + 1) + "行房屋楼层为空");
                Assert.hasValue(os[4], "房屋信息选项中" + (osIndex + 1) + "行房屋户型为空");
                Assert.hasValue(os[5], "房屋信息选项中" + (osIndex + 1) + "行建筑面积为空");
                if (!StringUtil.isNullOrNone(os[6])) {
                if (os.length > 6 && !StringUtil.isNullOrNone(os[6])) {
                    Assert.hasValue(os[7], "房屋信息选项中" + (osIndex + 1) + "行房屋费用为空");
                    Assert.hasValue(os[8], "房屋信息选项中" + (osIndex + 1) + "行费用到期时间为空");
                }
@@ -763,17 +797,18 @@
                importRoom.setSection(os[4].toString());
                importRoom.setBuiltUpArea(Double.parseDouble(os[5].toString()));
                if (!StringUtil.isNullOrNone(os[6])) {
                if (os.length > 6 && !StringUtil.isNullOrNone(os[6])) {
                    importRoom.setRoomFeeId(os[7].toString());
                    importRoom.setFeeEndDate(os[8].toString());
                }
                if (StringUtil.isNullOrNone(os[6])) {
                if (os.length < 7 || StringUtil.isNullOrNone(os[6])) {
                    rooms.add(importRoom);
                    continue;
                }
                importRoom.setImportOwner(getImportOwner(owners, os[6].toString()));
                rooms.add(importRoom);
            } catch (Exception e) {
                logger.error("房屋数据校验失败", e);
                throw new IllegalArgumentException("房屋信息sheet中第" + (osIndex + 1) + "行数据错误,请检查" + e.getLocalizedMessage());
            }
        }