| | |
| | | package com.vincent.rsf.server.manager.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | |
| | | import com.vincent.rsf.server.manager.controller.params.LocToTaskParams; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.*; |
| | | import com.vincent.rsf.server.manager.enums.LocType; |
| | | import com.vincent.rsf.server.manager.mapper.LocItemMapper; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.lang.reflect.Array; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | * type: check 盘点, stock: 库存出库 |
| | | * |
| | | * @param map |
| | | * @param loginUserId |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Synchronized |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R generateTask(LocToTaskParams map) { |
| | | public R generateTask(LocToTaskParams map, Long loginUserId) { |
| | | if (Objects.isNull(map.getSiteNo())) { |
| | | throw new CoolException("站点不能为空!"); |
| | | } |
| | |
| | | } |
| | | |
| | | Task moveTask = new Task(); |
| | | if (!LocUtils.isShallowLoc(slaveProperties, loc.getCode())) { |
| | | if (!LocUtils.isShallowLoc(loc.getCode())) { |
| | | //获取深库位对应浅库位 |
| | | String shallowLoc = LocUtils.getShallowLoc(slaveProperties, loc.getCode()); |
| | | String shallowLoc = LocUtils.getShallowLoc(loc.getCode()); |
| | | Loc one = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc)); |
| | | if (Objects.isNull(one)) { |
| | | throw new CoolException("对应库位不存在!!"); |
| | |
| | | map.setOrgLoc(one.getCode()); |
| | | //优先生成移库任务 |
| | | if (!one.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | | moveTask = genMoveTask(map); |
| | | moveTask = genMoveTask(map, loginUserId); |
| | | } |
| | | } |
| | | |
| | |
| | | .setTaskCode(ruleCode) |
| | | .setParentId(moveTask.getId()) |
| | | .setTargSite(siteNo) |
| | | .setUpdateBy(loginUserId) |
| | | .setCreateBy(loginUserId) |
| | | .setCreateTime(new Date()) |
| | | .setUpdateTime(new Date()) |
| | | .setTaskStatus(TaskStsType.GENERATE_OUT.id) |
| | | .setBarcode(loc.getBarcode()); |
| | | |
| | |
| | | Double useQty = Math.round((outQty + workQty) * 10000) / 10000.0; |
| | | if (orgQty.compareTo(useQty) > 0) { |
| | | //拣料出库 |
| | | task.setTaskType(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type); |
| | | |
| | | DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | .eq(DeviceSite::getSite, siteNo) |
| | |
| | | if (Objects.isNull(deviceSite)) { |
| | | throw new CoolException("站点不支持拣料出库!!"); |
| | | } |
| | | task.setTaskType(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type).setWarehType(deviceSite.getDevice()); |
| | | |
| | | } else { |
| | | //全板出库 |
| | | task.setTaskType(TaskType.TASK_TYPE_OUT.type); |
| | | DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | .eq(DeviceSite::getChannel, loc.getChannel()) |
| | | .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_OUT.type)); |
| | | if (Objects.isNull(deviceSite)) { |
| | | throw new CoolException("站点不支持全板出库!!"); |
| | | } |
| | | task.setTaskType(TaskType.TASK_TYPE_OUT.type).setWarehType(deviceSite.getDevice()); |
| | | |
| | | } |
| | | } else if (map.getType().equals(Constants.TASK_TYPE_OUT_CHECK)) { |
| | | //盘点出库 |
| | | task.setTaskType(TaskType.TASK_TYPE_CHECK_OUT.type); |
| | | DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | .eq(DeviceSite::getChannel, loc.getChannel()) |
| | | .eq(DeviceSite::getSite, siteNo) |
| | |
| | | if (Objects.isNull(deviceSite)) { |
| | | throw new CoolException("当前站点不支持盘点出库!!"); |
| | | } |
| | | |
| | | task.setTaskType(TaskType.TASK_TYPE_CHECK_OUT.type).setWarehType(deviceSite.getDevice()); |
| | | |
| | | } |
| | | |
| | | if (!taskService.save(task)) { |
| | |
| | | taskItem.setTaskId(task.getId()) |
| | | .setAnfme(item.getOutQty()) |
| | | .setBatch(item.getBatch()) |
| | | .setUpdateBy(loginUserId) |
| | | .setCreateBy(loginUserId) |
| | | .setCreateTime(new Date()) |
| | | .setUpdateTime(new Date()) |
| | | .setOrderType(OrderType.ORDER_OUT.type) |
| | | .setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type)); |
| | | taskItems.add(taskItem); |
| | |
| | | } else { |
| | | item.setWorkQty(qty); |
| | | } |
| | | item.setUpdateBy(loginUserId).setUpdateTime(new Date()); |
| | | |
| | | if (!locItemService.updateById(item)) { |
| | | throw new CoolException("库存信息修改失败!!"); |
| | | } |
| | |
| | | * 生成移库任务 |
| | | * |
| | | * @param map |
| | | * @param loginUserId |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Task genMoveTask(LocToTaskParams map) { |
| | | public Task genMoveTask(LocToTaskParams map, Long loginUserId) { |
| | | if (Objects.isNull(map.getOrgLoc()) || StringUtils.isBlank(map.getOrgLoc())) { |
| | | throw new CoolException("源库位不能为空!"); |
| | | } |
| | |
| | | .setTaskCode(ruleCode) |
| | | .setTaskType(TaskType.TASK_TYPE_LOC_MOVE.type) |
| | | .setTargLoc(targetLoc.getCode()) |
| | | .setUpdateBy(loginUserId) |
| | | .setUpdateTime(new Date()) |
| | | .setTaskStatus(TaskStsType.GENERATE_IN.id) |
| | | .setBarcode(orgLoc.getBarcode()); |
| | | |
| | |
| | | taskItem.setTaskId(task.getId()) |
| | | .setAnfme(item.getAnfme()) |
| | | .setBatch(item.getBatch()) |
| | | .setUpdateBy(loginUserId) |
| | | .setUpdateTime(new Date()) |
| | | .setOrderType(OrderType.ORDER_IN.type) |
| | | .setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_OTHER_IN.type)); |
| | | taskItems.add(taskItem); |