| | |
| | | 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.entity.Loc; |
| | | import com.vincent.rsf.server.manager.entity.Task; |
| | | import com.vincent.rsf.server.manager.entity.TaskItem; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.*; |
| | | import com.vincent.rsf.server.manager.mapper.LocItemMapper; |
| | | import com.vincent.rsf.server.manager.entity.LocItem; |
| | | import com.vincent.rsf.server.manager.service.LocItemService; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vincent.rsf.server.manager.service.LocService; |
| | | import com.vincent.rsf.server.manager.service.TaskItemService; |
| | | import com.vincent.rsf.server.manager.service.TaskService; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.system.utils.SerialRuleUtils; |
| | | import lombok.Synchronized; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.lang.reflect.Array; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service("locItemService") |
| | |
| | | private TaskItemService taskItemService; |
| | | @Autowired |
| | | private LocItemService locItemService; |
| | | @Autowired |
| | | private DeviceSiteService deviceSiteService; |
| | | |
| | | |
| | | /** |
| | |
| | | throw new CoolException("托盘任务执行中,不能重复创建!"); |
| | | } |
| | | |
| | | List<Integer> list = Arrays.asList(TaskType.TASK_TYPE_CHECK_OUT.type, TaskType.TASK_TYPE_PICK_AGAIN_OUT.type); |
| | | |
| | | if (type.equals("stock")) { |
| | | 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, loc.getCode()).eq(DeviceSite::getType, TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) ); |
| | | if (Objects.isNull(deviceSite)) { |
| | | throw new CoolException("站点支持拣料出库!!"); |
| | | } |
| | | } else { |
| | | //全板出库 |
| | | task.setTaskType(TaskType.TASK_TYPE_OUT.type); |
| | | DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | .eq(DeviceSite::getSite, loc.getCode()).eq(DeviceSite::getType, TaskType.TASK_TYPE_OUT.type) ); |
| | | if (Objects.isNull(deviceSite)) { |
| | | throw new CoolException("站点支持全板出库!!"); |
| | | } |
| | | } |
| | | } else if (type.equals("check")) { |
| | | //盘点出库 |
| | | task.setTaskType(TaskType.TASK_TYPE_CHECK_OUT.type); |
| | | DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | .eq(DeviceSite::getSite, loc.getCode()).eq(DeviceSite::getType, TaskType.TASK_TYPE_CHECK_OUT.type) ); |
| | | if (Objects.isNull(deviceSite)) { |
| | | throw new CoolException("站点支持盘点出库!!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | if (!taskService.save(task)) { |
| | | throw new CoolException("任务创建失败!!"); |
| | | } |
| | |
| | | LocItem locItem = locItemService.getById(item.getId()); |
| | | if (Objects.isNull(locItem)) { |
| | | throw new CoolException("库存信息不存在!"); |
| | | } |
| | | |
| | | if (item.getOutQty().compareTo(0.0) < 0) { |
| | | throw new CoolException("出库数里不能小于0!!"); |
| | | } |
| | | |
| | | if (locItem.getAnfme().compareTo(qty) < 0) { |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R genMoveTask(Map<String, Object> map) { |
| | | if (Objects.isNull(map.get("targetLoc")) && StringUtils.isNotBlank(map.get("targetLoc").toString())) { |
| | | throw new CoolException("目标库位不能为空!1"); |
| | | if (Objects.isNull(map.get("tarLoc")) || StringUtils.isBlank(map.get("tarLoc").toString())) { |
| | | throw new CoolException("目标库位不能为空!"); |
| | | } |
| | | if (Objects.isNull(map.get("orgLoc")) && StringUtils.isNotBlank(map.get("orgLoc").toString())) { |
| | | if (Objects.isNull(map.get("orgLoc")) || StringUtils.isBlank(map.get("orgLoc").toString())) { |
| | | throw new CoolException("源库位不能为空!"); |
| | | } |
| | | |
| | |
| | | throw new CoolException("源库位不存在!!"); |
| | | } |
| | | |
| | | Loc targetLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, map.get("targetLoc").toString())); |
| | | orgLoc.setUseStatus(LocStsType.LOC_STS_TYPE_R.type); |
| | | |
| | | if (!locService.updateById(orgLoc)) { |
| | | throw new CoolException("目标库位预约失败!!"); |
| | | } |
| | | |
| | | |
| | | Loc targetLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, map.get("tarLoc").toString())); |
| | | if (Objects.isNull(targetLoc)) { |
| | | throw new CoolException("目标库位不存在!!"); |
| | | } |
| | | |
| | | targetLoc.setUseStatus(LocStsType.LOC_STS_TYPE_R.type); |
| | | targetLoc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type); |
| | | |
| | | if (!locService.updateById(targetLoc)) { |
| | | throw new CoolException("目标库位预约失败!!"); |
| | |
| | | .setTaskStatus(TaskStsType.GENERATE_IN.id) |
| | | .setBarcode(orgLoc.getBarcode()); |
| | | |
| | | if (!taskService.save(task)) { |
| | | throw new CoolException("新建移库任务失败!!"); |
| | | } |
| | | |
| | | List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, orgLoc.getId())); |
| | | if (locItems.isEmpty()) { |
| | | throw new CoolException("库位明细不存在!!"); |