| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.api.controller.params.BaseMatParms; |
| | | import com.vincent.rsf.server.manager.entity.Matnr; |
| | | import com.vincent.rsf.server.manager.entity.MatnrGroup; |
| | | import com.vincent.rsf.server.manager.enums.OrderType; |
| | | import com.vincent.rsf.server.manager.entity.PurchaseItem; |
| | | import com.vincent.rsf.server.manager.service.MatnrGroupService; |
| | | import com.vincent.rsf.server.manager.service.PurchaseItemService; |
| | | import com.vincent.rsf.server.manager.service.PurchaseService; |
| | | import com.vincent.rsf.server.manager.service.impl.MatnrServiceImpl; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.api.controller.params.OrderParams; |
| | | import com.vincent.rsf.server.system.entity.Fields; |
| | |
| | | private FieldsService fieldsService; |
| | | @Autowired |
| | | private FieldsItemService fieldsItemService; |
| | | @Autowired |
| | | private MatnrGroupService matnrGroupService; |
| | | @Autowired |
| | | private MatnrServiceImpl matnrService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 物料信息同步 |
| | | * @param matnrs |
| | | */ |
| | | @Override |
| | | public void syncMatnrs(List<BaseMatParms> matnrs) { |
| | | List<Matnr> syncMatnrs = new ArrayList<>(); |
| | | if (!matnrs.isEmpty()) { |
| | | matnrs.forEach(matnr -> { |
| | | Matnr mat = new Matnr(); |
| | | if (Objects.isNull(matnr.getMatnr())) { |
| | | throw new RuntimeException("物料编码不能为空!!"); |
| | | } |
| | | BeanUtils.copyProperties(matnr, mat); |
| | | mat.setCode(matnr.getMatnr()).setName(matnr.getMaktx()); |
| | | if (!Objects.isNull(matnr.getGroupName())) { |
| | | MatnrGroup matnrGroup = matnrGroupService.getOne(new LambdaQueryWrapper<MatnrGroup>().eq(MatnrGroup::getName, matnr.getGroupName()), false); |
| | | if (Objects.isNull(matnrGroup)) { |
| | | mat.setGroupCode(matnrGroup.getCode()).setGroupId(matnrGroup.getId()); |
| | | } |
| | | } |
| | | syncMatnrs.add(mat); |
| | | }); |
| | | |
| | | if (!matnrService.saveOrUpdateBatch(syncMatnrs)) { |
| | | throw new CoolException("物料信息保存成功!!"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |