| | |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.vincent.rsf.server.api.controller.erp.params.InventoryAdjustReportParam; |
| | | import com.vincent.rsf.server.manager.controller.params.ReviseLogParams; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.AsnExceStatus; |
| | |
| | | import com.vincent.rsf.server.manager.mapper.ReviseLogMapper; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | | @Service("reviseLogService") |
| | | public class ReviseLogServiceImpl extends ServiceImpl<ReviseLogMapper, ReviseLog> implements ReviseLogService { |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private OutStockItemService outStockItemService; |
| | | |
| | | @Autowired |
| | | private WarehouseService warehouseService; |
| | | |
| | | @Autowired |
| | | private CloudWmsNotifyLogService cloudWmsNotifyLogService; |
| | | |
| | | @Autowired |
| | | private ObjectMapper objectMapper; |
| | | |
| | | /** |
| | | * 库存调整单明细添加 |
| | |
| | | // 删除原库位的库存明细(如果存在) |
| | | locItemService.remove(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId())); |
| | | |
| | | final Loc sourceLoc = loc; |
| | | Loc finalLoc = loc; |
| | | reviseItems.forEach(logItem -> { |
| | | LocItem locDetl = new LocItem(); |
| | |
| | | if (!locItemService.save(locDetl)) { |
| | | throw new CoolException("库存明细保存失败!!"); |
| | | } |
| | | // 9.2 库存调整主动上报待办 |
| | | try { |
| | | String wareHouseId = null; |
| | | if (finalLoc.getWarehouseId() != null) { |
| | | Warehouse wh = warehouseService.getById(finalLoc.getWarehouseId()); |
| | | if (wh != null) { |
| | | wareHouseId = wh.getCode(); |
| | | } |
| | | } |
| | | if (wareHouseId != null && logItem.getMatnrCode() != null && sourceLoc != null) { |
| | | InventoryAdjustReportParam param = new InventoryAdjustReportParam() |
| | | .setChangeType(3) // 3 移库 |
| | | .setWareHouseId(wareHouseId) |
| | | .setSourceLocId(sourceLoc.getCode()) |
| | | .setTargetLocId(finalLoc.getCode()) |
| | | .setMatNr(logItem.getMatnrCode()) |
| | | .setQty(logItem.getReviseQty() != null ? String.valueOf(logItem.getReviseQty()) : "0"); |
| | | String requestBody = objectMapper.writeValueAsString(param); |
| | | Date now = new Date(); |
| | | CloudWmsNotifyLog notifyLog = new CloudWmsNotifyLog() |
| | | .setReportType(cloudWmsNotifyLogService.getReportTypeInventoryAdjust()) |
| | | .setRequestBody(requestBody) |
| | | .setNotifyStatus(cloudWmsNotifyLogService.getNotifyStatusPending()) |
| | | .setRetryCount(0) |
| | | .setBizRef("reviseId=" + revise.getId() + ",reviseLogItemId=" + logItem.getId()) |
| | | .setCreateTime(now) |
| | | .setUpdateTime(now); |
| | | cloudWmsNotifyLogService.fillFromConfig(notifyLog); |
| | | cloudWmsNotifyLogService.save(notifyLog); |
| | | } |
| | | } catch (Exception e) { |
| | | log.warn("库存调整上报待办落库失败(不影响库存保存),matNr={}:{}", logItem.getMatnrCode(), e.getMessage()); |
| | | } |
| | | |
| | | // 为库存调整产生的库存创建对应的WkOrderItem |
| | | // 遍历所有未完成的出库单,检查是否需要这些物料 |