| | |
| | | import com.zy.common.model.LocDto; |
| | | import com.zy.common.model.TaskDto; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | * Created by vincent on 2022/3/26 |
| | | */ |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | public class OutController extends BaseController { |
| | | |
| | |
| | | if (issued <= 0.0D) { |
| | | continue; |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.queryStockAll(null, exist,orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(),orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3()); |
| | | List<LocDetl> locDetls = locDetlService.queryStockAll(null, exist, orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(), orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3()); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | LocAroundBind bLocNo = locAroundBindService.selectOne(new EntityWrapper<LocAroundBind>().eq("b_loc_no", locMast.getLocNo())); |
| | | if (!Cools.isEmpty(bLocNo)) { |
| | | continue; |
| | | } |
| | | locDto.setFrozen(locDetl.getFrozen()); |
| | | locDto.setFrozenLoc(locMast.getFrozen()); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), 107); |
| | |
| | | if (issued <= 0.0D) { |
| | | continue; |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.queryStockAll(null, exist,orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(),orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(),orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3()); |
| | | List<LocDetl> locDetls = locDetlService.queryStockAll(null, exist, orderDetl.getMatnr(), orderDetl.getBatch(), |
| | | orderDetl.getBrand(), orderDetl.getStandby1(), orderDetl.getStandby2(), orderDetl.getStandby3(), orderDetl.getBoxType1(), orderDetl.getBoxType2(), orderDetl.getBoxType3()); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | locDto.setFrozen(locDetl.getFrozen()); |
| | | locDto.setFrozenLoc(locMast.getFrozen()); |
| | | List<Integer> staNos; |
| | | if (!Objects.isNull(orderDetl.getStandby1())) { |
| | | BasDevice basDevice = basDeviceService.selectOne(new EntityWrapper<BasDevice>().eq("dev_no", orderDetl.getStandby1())); |
| | | if (Objects.isNull(basDevice)) { |
| | | throw new CoolException("机台信息不存在!!"); |
| | | } |
| | | List<LocAroundBind> binds = locAroundBindService.selectList(new EntityWrapper<LocAroundBind>().eq("dev_no", basDevice.getDevNo())); |
| | | if (Objects.isNull(binds) || binds.isEmpty()) { |
| | | throw new CoolException("台机未绑定工作站台!!"); |
| | | } |
| | | Set<String> locs = binds.stream().map(LocAroundBind::getBLocNo).collect(Collectors.toSet()); |
| | | |
| | | LocMast locMasts = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .in("loc_no", locs) |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | .eq("dev_no", basDevice.getDevNo()) |
| | | .orderAsc(Arrays.asList("loc_no")) |
| | | .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")); |
| | | |
| | | staNos = staDescService.queryOutStaNosByLocNo(locMasts.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103); |
| | | } else { |
| | | staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103); |
| | | } |
| | | |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103); |
| | | locDto.setStaNos(staNos); |
| | | locDto.setBrand(orderDetl.getBrand()); |
| | | locDto.setStandby1(orderDetl.getStandby1()); |
| | |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | List<LocDto> locDtoArrayList = new ArrayList<>(); |
| | | for (LocDto locDto : locDtos){ |
| | | if (locDto.getFrozen()!=1 && locDto.getFrozenLoc()!=1){ |
| | | for (LocDto locDto : locDtos) { |
| | | if (locDto.getFrozen() != 1 && locDto.getFrozenLoc() != 1) { |
| | | locDtoArrayList.add(locDto); |
| | | } |
| | | } |
| | |
| | | List<TaskDto> taskDtos = new ArrayList<>(); |
| | | // 根据 (库位 & 出库站) 分组; 理想状态:一组为一次出库任务 |
| | | for (LocDto locDto : locDtos) { |
| | | if (locDto.isLack()) { continue; } |
| | | if (locDto.isLack()) { |
| | | continue; |
| | | } |
| | | TaskDto taskDto = new TaskDto(locDto.getLocNo(), locDto.getStaNo(), locDto, locDto.getStandby1()); |
| | | if (TaskDto.has(taskDtos, taskDto)) { |
| | | TaskDto dto = TaskDto.find(taskDtos, taskDto); |
| | |
| | | } |
| | | } |
| | | // ----------------------------------------------------------------------------------------------- |
| | | int failCount = 0; |
| | | for (TaskDto taskDto : taskDtos) { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(taskDto.getStaNo()); |
| | | if (!Objects.isNull(taskDto.getDeviceNo())) { |
| | | workService.stockOut(staNo, taskDto, taskDto.getDeviceNo(), getUserId()); |
| | | if (!stockOutSafely(taskDto, getUserId(), "手动订单出库")) { |
| | | failCount++; |
| | | } |
| | | } |
| | | if (failCount > 0) { |
| | | return R.ok("部分出库任务已生成,成功" + (taskDtos.size() - failCount) + "条,失败" + failCount + "条,请查看日志"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | private boolean stockOutSafely(TaskDto taskDto, Long userId, String scene) { |
| | | try { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(taskDto.getStaNo()); |
| | | workService.stockOut(staNo, taskDto, taskDto.getDeviceNo(), userId); |
| | | return true; |
| | | } catch (Exception e) { |
| | | log.error("{}失败[locNo={}, staNo={}, deviceNo={}, orderNos={}],原因: {}", |
| | | scene, |
| | | taskDto.getLocNo(), |
| | | taskDto.getStaNo(), |
| | | taskDto.getDeviceNo(), |
| | | collectOrderNos(taskDto), |
| | | getErrorMessage(e)); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private String collectOrderNos(TaskDto taskDto) { |
| | | Set<String> orderNos = new LinkedHashSet<>(); |
| | | for (LocDto locDto : taskDto.getLocDtos()) { |
| | | if (!Cools.isEmpty(locDto.getOrderNo())) { |
| | | orderNos.add(locDto.getOrderNo()); |
| | | } |
| | | } |
| | | return orderNos.toString(); |
| | | } |
| | | |
| | | private String getErrorMessage(Exception e) { |
| | | return Cools.isEmpty(e.getMessage()) ? e.getClass().getSimpleName() : e.getMessage(); |
| | | } |
| | | } |