自动化立体仓库 - WMS系统
zwl
13 小时以前 57610f520d214c9b5797191f7dbc68c121c7f0c1
mat导入问题
移库数据丢失修复
4个文件已修改
124 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java 70 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/utils/MatExcelListener.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/entity/MatExcel.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/LocDetlMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/task/handler/WorkMastHandler.java
@@ -497,31 +497,65 @@
    public void movLoc(WrkMast wrkMast) {
        LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
        if (Objects.isNull(locMast)) {
            throw new CoolException("目标库位不存在!!");
        }
        Date now = new Date();
        Long operatorUser = wrkMast.getModiUser();
        if (Objects.isNull(operatorUser)) {
            operatorUser = wrkMast.getAppeUser();
        }
        // 默认目标库位是空板
        String locSts = "D";
        // 库位移转判断是否为空板移转
        if (wrkMast.getEmptyMk().equals("N")) {
        if ("N".equals(wrkMast.getEmptyMk())) {
            locSts = "F";
            // 转移库存明细数据: 库存号 由工作档源库位变为目标库位
            if (!locDetlService.updateLocNo(wrkMast.getLocNo(), wrkMast.getSourceLocNo())) {
//                            exceptionHandle("库位移转 ===>> 转移库存明细数据失败;[源库位={0}],[目标库位={1}]", wrkMast.getSourceLocNo(), wrkMast.getLocNo());
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                log.info("库位移转 ===>> 转移库存明细数据失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
            List<LocDetl> sourceDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo()));
            for (LocDetl sourceDetl : sourceDetls) {
                LocDetl targetDetl = locDetlService.selectItem(wrkMast.getLocNo(), sourceDetl.getMatnr(), sourceDetl.getBatch(), sourceDetl.getBrand(),
                        sourceDetl.getStandby1(), sourceDetl.getStandby2(), sourceDetl.getStandby3(), sourceDetl.getBoxType1(),
                        sourceDetl.getBoxType2(), sourceDetl.getBoxType3());
                if (null != targetDetl && !Objects.equals(targetDetl.getId(), sourceDetl.getId())) {
                    Double targetQty = targetDetl.getAnfme() == null ? 0D : targetDetl.getAnfme();
                    Double sourceQty = sourceDetl.getAnfme() == null ? 0D : sourceDetl.getAnfme();
                    targetDetl.setAnfme(Math.round((targetQty + sourceQty) * 10000) / 10000.0);
                    targetDetl.setAreaId(locMast.getAreaId());
                    targetDetl.setAreaName(locMast.getAreaName());
                    targetDetl.setModiTime(now);
                    if (!Objects.isNull(operatorUser)) {
                        targetDetl.setModiUser(operatorUser);
                    }
                    if (!locDetlService.updateById(targetDetl)) {
                        throw new CoolException("库位移转 ===>> 合并库存明细失败; [workNo=" + wrkMast.getWrkNo() + "],[sourceLoc=" + wrkMast.getSourceLocNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                    }
                    if (!locDetlService.deleteById(sourceDetl.getId())) {
                        throw new CoolException("库位移转 ===>> 删除源库存明细失败; [workNo=" + wrkMast.getWrkNo() + "],[sourceLoc=" + wrkMast.getSourceLocNo() + "]");
                    }
                } else {
                    sourceDetl.setLocNo(wrkMast.getLocNo());
                    sourceDetl.setAreaId(locMast.getAreaId());
                    sourceDetl.setAreaName(locMast.getAreaName());
                    sourceDetl.setModiTime(now);
                    if (!Objects.isNull(operatorUser)) {
                        sourceDetl.setModiUser(operatorUser);
                    }
                    if (!locDetlService.updateById(sourceDetl)) {
                        throw new CoolException("库位移转 ===>> 转移库存明细失败; [workNo=" + wrkMast.getWrkNo() + "],[sourceLoc=" + wrkMast.getSourceLocNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
                    }
                }
            }
        }
        // 修改源库位状态 ==> O
        LocMast sourceLoc = locMastService.selectById(wrkMast.getSourceLocNo());
        if (null != sourceLoc) {
            sourceLoc.setBarcode("");
            sourceLoc.setLocSts("O");
            sourceLoc.setModiTime(now);
            sourceLoc.setIoTime(now);
            if (!locMastService.updateById(sourceLoc)) {
//                            exceptionHandle("库位移转 ===>> 修改源库位状态失败;[workNo={0}],[sourceLoc={1}]", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                log.info("库位移转 ===>> 修改源库位状态失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
            }
        if (null == sourceLoc) {
            throw new CoolException("源库位不存在!!");
        }
        sourceLoc.setBarcode("");
        sourceLoc.setLocSts("O");
        sourceLoc.setModiTime(now);
        sourceLoc.setIoTime(now);
        if (!locMastService.updateById(sourceLoc)) {
            throw new CoolException("库位移转 ===>> 修改源库位状态失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
        }
        // 修改目标库位状态 ==> .locSts
        locMast.setLocSts(locSts);
@@ -529,9 +563,7 @@
        locMast.setIoTime(now);
        locMast.setModiTime(now);
        if (!locMastService.updateById(locMast)) {
//                        exceptionHandle("库位移转 ===>> 修改目标库位状态失败;[workNo={0}],[locNo={1}]", wrkMast.getWrkNo(), wrkMast.getLocNo());
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
           log.info("库位移转 ===>> 修改目标库位状态失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
            throw new CoolException("库位移转 ===>> 修改目标库位状态失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]");
        }
    }
src/main/java/com/zy/asrs/utils/MatExcelListener.java
@@ -56,6 +56,9 @@
        MatService matService = SpringUtils.getBean(MatService.class);
        Date now = new Date();
        Long tagId;
        if (Cools.isEmpty(excel.getMatnr())) {
            throw new CoolException("商品编码不能为空!!");
        }
        // 分类
        // 一级分类
        if (!Cools.isEmpty(excel.getPriClass()) && !Cools.isEmpty(excel.getSecClass())) {
@@ -125,27 +128,34 @@
        }
        // 商品
        Mat mat = matService.selectByMatnr(excel.getMatnr());
        if (mat == null) {
        boolean isNew = mat == null;
        if (isNew) {
            mat = new Mat();
            mat.setMatnr(excel.getMatnr());
            mat.setMaktx(excel.getMaktx());
            mat.setSafeQty(excel.getSafeQty());
            mat.setVolume(excel.getVolume());
            mat.setStoreMax(excel.getStoreMax());
            mat.setStoreMin(excel.getStoreMin());
            mat.setTagId(tagId);
            mat.setLocType(tagId);
            if (Objects.isNull(mat.getVolume())) {
                throw new CoolException("每公斤长度不能为空!!");
            }
            if (Objects.isNull(mat.getSafeQty())) {
                throw new CoolException("归零阈值不能为空!!");
            }
            if (!matService.insert(mat)) {
                throw new CoolException("保存商品信息失败,商品编码:" + excel.getMatnr());
            }
            total++;
            mat.setCreateBy(userId);
            mat.setCreateTime(now);
        }
        mat.setMatnr(excel.getMatnr());
        mat.setMaktx(excel.getMaktx());
        mat.setUnit(excel.getUnit());
        mat.setSafeQty(excel.getSafeQty());
        mat.setVolume(excel.getVolume());
        mat.setStoreMax(excel.getStoreMax());
        mat.setStoreMin(excel.getStoreMin());
        mat.setTagId(tagId);
        mat.setLocType(tagId);
        mat.setUpdateBy(userId);
        mat.setUpdateTime(now);
        if (Objects.isNull(mat.getVolume())) {
            throw new CoolException("每公斤长度不能为空!!");
        }
        if (Objects.isNull(mat.getSafeQty())) {
            throw new CoolException("归零阈值不能为空!!");
        }
        boolean ok = isNew ? matService.insert(mat) : matService.updateById(mat);
        if (!ok) {
            throw new CoolException((isNew ? "保存" : "更新") + "商品信息失败,商品编码:" + excel.getMatnr());
        }
        total++;
    }
    /**
@@ -154,7 +164,7 @@
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext ctx) {
        log.info("新增{}条物料信息!", total);
        log.info("同步{}条物料信息!", total);
    }
    public int getTotal() {
src/main/java/com/zy/common/entity/MatExcel.java
@@ -31,4 +31,7 @@
    @ExcelProperty(index = 7, value = "库存预警数量下限")
    private Double storeMin;
    @ExcelProperty(index = 8, value = "单位")
    private String unit;
}
src/main/resources/mapper/LocDetlMapper.xml
@@ -299,6 +299,7 @@
        and loc_no = #{locNo}
        and matnr = #{matnr}
        <include refid="batchSeq"></include>
        order by isnull(d.modi_time, d.appe_time) desc, d.id desc
    </select>
    <delete id="deleteItem">