| | |
| | | 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())) { |
| | |
| | | } |
| | | // 商品 |
| | | Mat mat = matService.selectByMatnr(excel.getMatnr()); |
| | | if (mat == null) { |
| | | mat = excel; |
| | | 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++; |
| | | 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++; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext ctx) { |
| | | log.info("新增{}条物料信息!", total); |
| | | log.info("同步{}条物料信息!", total); |
| | | } |
| | | |
| | | public int getTotal() { |