自动化立体仓库 - WMS系统
luxiaotao1123
2020-07-24 00b9c782322ad546dd6bd37e6ee27f357557a676
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;
@@ -53,25 +54,22 @@
        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());
            VersionUtils.setMatCode(matCode, data);
            matCode.setModiTime(new Date());
            matCode.setModiUser(this.userId);
            matCode.setAppeTime(new Date());
            matCode.setAppeUser(this.userId);
            list.add(matCode);
            if (!matCodeService.insert(matCode)) {
                throw new CoolException("导入数据异常");
            }
            total ++;
        }
        // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
        if (list.size() >= BATCH_COUNT) {
            if (!matCodeService.insertBatch(list)) {
                throw new CoolException("导入数据异常");
            }
            // 存储完成清理 list
            list.clear();
        }
//        if (list.size() >= BATCH_COUNT) {
//
//            // 存储完成清理 list
//            list.clear();
//        }
    }
    /**