自动化立体仓库 - WMS系统
#
18516761980
2022-04-19 c866b8a4cccdfe330ae2da833c62577d6a902a03
src/main/java/com/zy/common/utils/excel/matcode/MatCodeExcelListener.java
@@ -6,6 +6,7 @@
import com.core.exception.CoolException;
import com.zy.asrs.entity.MatCode;
import com.zy.asrs.service.MatCodeService;
import com.zy.asrs.utils.VersionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,21 +52,26 @@
    @Override
    public void invoke(MatCodeExcel data, AnalysisContext ctx) {
        MatCodeService matCodeService = SpringUtils.getBean(MatCodeService.class);
        if (matCodeService.selectById(data.getMatNo()) == null) {
            MatCode matCode = new MatCode();
            matCode.setMatNo(data.getMatNo());
            matCode.setMatName(data.getMatName());
            matCode.setBarcode(data.getBarcode());
            matCode.setStr1(data.getStr1());
        MatCode matCode = matCodeService.selectById(data.getMatNo());
        if (matCode == null) {
            matCode = new MatCode();
            VersionUtils.setMatCode(matCode, data);
            matCode.setModiTime(new Date());
            matCode.setModiUser(this.userId);
            matCode.setAppeTime(new Date());
            matCode.setAppeUser(this.userId);
            list.add(matCode);
            total ++;
            if (!matCodeService.insertBatch(list)) {
            if (!matCodeService.insert(matCode)) {
                throw new CoolException("导入数据异常");
            }
            total ++;
        } else {
            VersionUtils.setMatCode(matCode, data);
            matCode.setModiTime(new Date());
            matCode.setModiUser(this.userId);
            if (!matCodeService.updateById(matCode)) {
                throw new CoolException("导入数据异常");
            }
            total ++;
        }
        // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
//        if (list.size() >= BATCH_COUNT) {
@@ -81,7 +87,7 @@
     */
    @Override
    public void doAfterAllAnalysed(AnalysisContext ctx) {
        LOGGER.info("新增{}条物料信息!", total);
        LOGGER.info("新增/修改{}条产品信息!", total);
    }
    public int getTotal() {