自动化立体仓库 - WMS系统
zwl
18 小时以前 57610f520d214c9b5797191f7dbc68c121c7f0c1
src/main/java/com/zy/asrs/utils/MatExcelListener.java
@@ -14,10 +14,7 @@
import com.zy.common.utils.NodeUtils;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by vincent on 2019-11-25
@@ -59,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())) {
@@ -128,15 +128,34 @@
        }
        // 商品
        Mat mat = matService.selectByMatnr(excel.getMatnr());
        if (mat == null) {
            mat = excel;
            mat.setTagId(tagId);
            mat.setLocType(tagId);
            if (!matService.insert(mat)) {
                throw new CoolException("保存商品信息失败,商品编码:" + excel.getMatnr());
            }
            total++;
        boolean isNew = mat == null;
        if (isNew) {
            mat = new Mat();
            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++;
    }
    /**
@@ -145,7 +164,7 @@
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext ctx) {
        log.info("新增{}条物料信息!", total);
        log.info("同步{}条物料信息!", total);
    }
    public int getTotal() {