| | |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | | import com.vincent.rsf.server.system.utils.SystemAuthUtils; |
| | | import lombok.Synchronized; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | | @Service("taskService") |
| | | public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService { |
| | | |
| | |
| | | private CheckDiffService checkDiffService; |
| | | @Autowired |
| | | private CheckDiffItemService checkDiffItemService; |
| | | @Autowired |
| | | private BasContainerService basContainerService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | if (Objects.isNull(deviceSite)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(Integer.valueOf(deviceSite.getSite()))); |
| | | DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(deviceSite.getSite())); |
| | | if (Cools.isEmpty(deviceBind)) { |
| | | throw new CoolException("库位规则未知"); |
| | | } |
| | |
| | | throw new CoolException("请检查组拖状态是否完成!!"); |
| | | } |
| | | waitPakins.forEach(pakin -> { |
| | | BasContainer container = basContainerService.getOne(new LambdaUpdateWrapper<BasContainer>() |
| | | .eq(BasContainer::getCode, pakin.getBarcode())); |
| | | /**获取库位*/ |
| | | String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId()); |
| | | String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), container.getContainerType()); |
| | | if (Cools.isEmpty(targetLoc)) { |
| | | throw new CoolException("该站点对应库区未找到库位"); |
| | | } |
| | |
| | | if (!this.save(task)) { |
| | | throw new CoolException("任务保存失败!!"); |
| | | } |
| | | BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, deviceSite.getSite())); |
| | | if (Objects.isNull(station) || !station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | | throw new CoolException("站点不存在或站点不处于空库状态!!"); |
| | | } |
| | | station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type); |
| | | |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("站点状态更新失败!!"); |
| | | } |
| | | |
| | | |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()) |
| | | .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) { |
| | | throw new CoolException("库位预约失败!!"); |
| | |
| | | */ |
| | | @Synchronized |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void complateInTask(List<Task> tasks) throws Exception { |
| | | Long loginUserId = SystemAuthUtils.getLoginUserId(); |
| | | for (Task task : tasks) { |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) { |
| | | //1.入库 |
| | | complateInstock(task, loginUserId); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) { |
| | | //53.拣料再入库 |
| | | //57.盘点再入库 |
| | | pickComplateInStock(task, loginUserId); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) { |
| | | //移库 |
| | | moveInStock(task, loginUserId); |
| | | try { |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) { |
| | | //1.入库 |
| | | complateInstock(task, loginUserId); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) { |
| | | //53.拣料再入库 |
| | | //57.盘点再入库 |
| | | pickComplateInStock(task, loginUserId); |
| | | } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) { |
| | | //移库 |
| | | moveInStock(task, loginUserId); |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | //更新库位明细 |
| | | saveLocItem(taskItems, task.getId(), loginUserId); |
| | | } catch (Exception e) { |
| | | throw new CoolException("库位明细更新失败!!"); |
| | | throw new CoolException("任务号:" + task.getTaskCode() + "库位明细更新失败!!"); |
| | | } |
| | | |
| | | if (!locItemService.remove(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocCode, task.getOrgLoc()))) { |
| | |
| | | */ |
| | | @Synchronized |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void completeTask(List<Task> tasks) { |
| | | Long loginUserId = SystemAuthUtils.getLoginUserId(); |
| | | for (Task task : tasks) { |
| | |
| | | try { |
| | | complateOutStock(task, loginUserId); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | log.error(e.getMessage(), e); |
| | | // throw new CoolException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (Objects.isNull(loc)) { |
| | | throw new CoolException("库存不存在!!"); |
| | | } |
| | | if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)) { |
| | | throw new CoolException("当前库位状态不处于S.入库预约,不可执行入库操作!"); |
| | | } |
| | | // if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)) { |
| | | // throw new CoolException("当前库位状态不处于S.入库预约,不可执行入库操作!"); |
| | | // } |
| | | |
| | | loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type) |
| | | .setBarcode(task.getBarcode()) |
| | |
| | | if (Objects.isNull(waveItem)) { |
| | | throw new CoolException("波次明细不存在!!"); |
| | | } |
| | | Double workQty = Math.round((waveItem.getWorkQty() - item.getAnfme()) * 10000) / 10000.0; |
| | | Double workQty = Math.round((waveItem.getWorkQty() - item.getAnfme()) * 100) / 100.0; |
| | | waveItem.setWorkQty(workQty).setExceStatus(WaveItemExceStatus.WAVE_ITEM_EXCE_STATUS_UN.val); |
| | | if (!waveItemService.updateById(waveItem)) { |
| | | throw new CoolException("波次明细更新失败!!"); |
| | |
| | | if (Objects.isNull(wkOrder)) { |
| | | throw new CoolException("数据错误:单据已不存在!!"); |
| | | } |
| | | Double workQty = Math.round((wkOrder.getWorkQty() - item.getAnfme()) * 10000) / 10000.0; |
| | | Double workQty = Math.round((wkOrder.getWorkQty() - item.getAnfme()) * 100) / 100.0; |
| | | |
| | | wkOrder.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_INIT.val) |
| | | .setWorkQty(workQty.compareTo(0.00) > 0 ? workQty : 0.00) |
| | |
| | | throw new CoolException("数据错误:单据明细已不存在!!"); |
| | | } |
| | | |
| | | Double workItmQty = Math.round((orderItem.getWorkQty() - item.getAnfme()) * 10000) / 10000.0; |
| | | Double workItmQty = Math.round((orderItem.getWorkQty() - item.getAnfme()) * 100) / 100.0; |
| | | orderItem.setWorkQty(workItmQty); |
| | | |
| | | if (!outStockItemService.updateById(orderItem)) { |
| | |
| | | .setTaskStatus(TaskStsType.GENERATE_IN.id); |
| | | |
| | | TaskInParam param = new TaskInParam(); |
| | | param.setSourceStaNo(Integer.parseInt(task.getTargSite())) |
| | | param.setSourceStaNo(task.getTargSite()) |
| | | .setIoType(type) |
| | | .setLocType1(Integer.parseInt(loc.getType())); |
| | | //获取新库位 |
| | |
| | | if (Objects.isNull(locInfo)) { |
| | | throw new CoolException("获取库位失败!!"); |
| | | } |
| | | task.setTargLoc(locInfo.getLocNo()); |
| | | task.setTargLoc(locInfo.getLocNo()) |
| | | .setOrgSite(task.getTargSite()); |
| | | |
| | | if (!this.updateById(task)) { |
| | | throw new CoolException("任务状态更新失败!!"); |
| | |
| | | if (taskItem.getMatnrId().equals(working.getMatnrId())) { |
| | | Double minQty = taskItem.getAnfme(); |
| | | if (!task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) { |
| | | minQty = Math.round((working.getAnfme() - taskItem.getAnfme()) * 10000) / 10000.0; |
| | | minQty = Math.round((working.getAnfme() - taskItem.getAnfme()) * 100) / 100.0; |
| | | } |
| | | if (minQty.compareTo(0.0) > 0) { |
| | | taskItem.setAnfme(minQty); |
| | |
| | | } |
| | | } else { |
| | | if (!taskItemService.removeById(taskItem)) { |
| | | throw new CoolException("任务明细修改失败!!"); |
| | | log.error("任务明细修改失败!!"); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (Objects.isNull(waveItem)) { |
| | | throw new CoolException("波次明细不存在!!"); |
| | | } |
| | | try { |
| | | saveOutStockItem(maps.get(key), null, waveItem, null, loginUserId); |
| | | } catch (Exception e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | // try { |
| | | // saveOutStockItem(maps.get(key), null, waveItem, null, loginUserId); |
| | | // } catch (Exception e) { |
| | | // throw new CoolException(e.getMessage()); |
| | | // } |
| | | } else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val)) { |
| | | WkOrderItem orderItem = asnOrderItemService.getById(key); |
| | | if (Objects.isNull(orderItem)) { |
| | |
| | | * @description: 出库信息保存至库存明细表 |
| | | * @version 1.0 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveOutStockItem(List<TaskItem> taskItems, WkOrderItem orderItem, WaveItem waveItem, WkOrderItem diffItem, Long loginUserId) throws Exception { |
| | | Stock stock = new Stock(); |
| | |
| | | stock.setSourceId(waveItem.getId()).setType(OrderType.ORDER_OUT.type); |
| | | } else if (!Objects.isNull(orderItem) && StringUtils.isNotBlank(orderItem.getId() + "")) { |
| | | WkOrder wkOrder = asnOrderService.getById(orderItem.getOrderId()); |
| | | Double qty = Math.round((wkOrder.getQty() + sum) * 10000) / 10000.0; |
| | | Double qty = Math.round((wkOrder.getQty() + sum) * 100) / 100.0; |
| | | wkOrder.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_WORKING.val) |
| | | .setQty(qty); |
| | | if (!asnOrderService.updateById(wkOrder)) { |
| | |
| | | if (Objects.isNull(itemServiceOne)) { |
| | | throw new CoolException("数据错误:请查看请货区库存是否存在!!"); |
| | | } |
| | | Double workQty = Math.round((itemServiceOne.getWorkQty() - pakinItem.getAnfme()) * 10000) / 10000.0; |
| | | Double qty = Math.round((itemServiceOne.getQty() + pakinItem.getAnfme()) * 10000) / 10000.0; |
| | | Double workQty = Math.round((itemServiceOne.getWorkQty() - pakinItem.getAnfme()) * 100) / 100.0; |
| | | Double qty = Math.round((itemServiceOne.getQty() + pakinItem.getAnfme()) * 100) / 100.0; |
| | | itemServiceOne.setWorkQty(workQty).setQty(qty); |
| | | |
| | | if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>() |
| | |
| | | .setType(taskItem.getOrderType()); |
| | | locItems.add(item); |
| | | } else { |
| | | locItem.setAnfme(Math.round((locItem.getAnfme() + taskItem.getAnfme()) * 10000) / 10000.0) |
| | | locItem.setAnfme(Math.round((locItem.getAnfme() + taskItem.getAnfme()) * 100) / 100.0) |
| | | .setUpdateTime(new Date()); |
| | | locItems.add(locItem); |
| | | } |