zhang
10 小时以前 7da7d2a6f02b8b8dd63130c4c62f171ddf860c47
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/controller/LocController.java
@@ -203,12 +203,21 @@
        Long userId = getLoginUserId();
        for (Map<String, Object> row : rows) {
            Zone zone = resolveZone(readCell(row, "zone"));
            Integer rowNo = parseInteger(row.get("row"), "row", true);
            Integer bayNo = parseInteger(row.get("bay"), "bay", true);
            Integer levNo = parseInteger(row.get("lev"), "lev", true);
            Integer rowNo = parseInteger(row.get("row_no"), "row_no", true);
            Integer bayNo = parseInteger(row.get("bay_no"), "bay_no", true);
            Integer levNo = parseInteger(row.get("lev_no"), "lev_no", true);
            String locNo = buildLocNo(zone, rowNo, bayNo, levNo);
            if (locService.selectByLocNo(locNo) != null) {
                continue;
            Loc loc = locService.selectByLocNo(locNo);
            if (loc == null) {
                loc.setZoneId(zone.getId());
                loc.setUuid(locNo);
                loc.setLocNo(locNo);
                loc.setRowNo(rowNo);
                loc.setBayNo(bayNo);
                loc.setLevNo(levNo);
                loc.setStatus(StatusType.ENABLE.val);
                loc.setCreateBy(userId);
                loc.setCreateTime(now);
            }
            Long locStsId = resolveLocStsId(readCell(row, "loc_sts"));
@@ -217,13 +226,6 @@
            Integer compDirect = parseInteger(row.get("comp_direct"), "comp_direct", false);
            Double offset = parseDouble(row.get("offset"), "offset");
            Loc loc = new Loc();
            loc.setZoneId(zone.getId());
            loc.setUuid(locNo);
            loc.setLocNo(locNo);
            loc.setRow(rowNo);
            loc.setBay(bayNo);
            loc.setLev(levNo);
            loc.setLocSts(locStsId);
            loc.setLocType(locTypeId);
@@ -231,15 +233,19 @@
            loc.setCompDirect(compDirect);
            loc.setOffset(offset);
            loc.setStatus(StatusType.ENABLE.val);
            loc.setCreateBy(userId);
            loc.setCreateTime(now);
            loc.setUpdateBy(userId);
            loc.setUpdateTime(now);
            if (!locService.save(loc)) {
                throw new CoolException(locNo + " save fail !");
            if (loc.getId()==null){
                if (!locService.save(loc)) {
                    throw new CoolException(locNo + " save fail !");
                }
            }else {
                if (!locService.updateById(loc)) {
                    throw new CoolException(locNo + " update fail !");
                }
            }
        }
        return R.ok();
    }
@@ -253,7 +259,8 @@
    private Long resolveLocStsId(String identifier) {
        if (Cools.isEmpty(identifier)) {
            throw new CoolException("loc_sts is required");
            //throw new CoolException("loc_sts is required");
            return null;
        }
        LocStsType locStsType = LocStsType.valueOf(identifier);
        if (locStsType == null) {
@@ -330,17 +337,17 @@
        return Cools.isEmpty(text) ? null : text;
    }
    private String buildLocNo(Zone zone, Integer row, Integer bay, Integer lev) {
        if (zone == null || row == null || bay == null || lev == null) {
            throw new CoolException("zone/row/bay/lev cannot be null");
    private String buildLocNo(Zone zone, Integer rowNo, Integer bayNo, Integer levNo) {
        if (zone == null || rowNo == null || bayNo == null || levNo == null) {
            throw new CoolException("zone/rowNo/bayNo/levNo cannot be null");
        }
        if (Cools.isEmpty(zone.getUuid())) {
            throw new CoolException("zone uuid is empty");
        }
        return Utils.zeroFill(zone.getUuid(), 2)
                + String.format("%03d", row)
                + String.format("%03d", bay)
                + String.format("%02d", lev);
                + String.format("%03d", rowNo)
                + String.format("%03d", bayNo)
                + String.format("%02d", levNo);
    }
}