| | |
| | | package com.zy.common.web; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | |
| | | import com.zy.asrs.entity.param.EmptyPlateOutParam; |
| | | import com.zy.asrs.entity.result.FindLocNoAttributeVo; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.web.param.SearchLocParam; |
| | | import com.zy.common.web.param.TransferLocParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | private WrkMastLogService wrkMastLogService; |
| | | @Autowired |
| | | private WrkDetlLogService wrkDetlLogService; |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | |
| | | @PostMapping("/pakin/loc/v1") |
| | | @ResponseBody |
| | |
| | | StartupDto dto = startupPickPutStore(param); |
| | | log.info("WCS拣料盘点入库接口,托盘码:{}", param.getBarcode()); |
| | | return R.ok().add(dto); |
| | | } |
| | | |
| | | @PostMapping("/transfer/loc/v1") |
| | | @ResponseBody |
| | | public synchronized R transferLocV1(@RequestBody TransferLocParam param) { |
| | | log.info("收到WCS申请移库接口请求====>>入参:{}", param); |
| | | if (Cools.isEmpty(param.getLocNo())) { |
| | | return R.error("库位号不存在"); |
| | | } |
| | | |
| | | if (Cools.isEmpty(param.getLane())) { |
| | | return R.error("巷道号不存在"); |
| | | } |
| | | |
| | | try { |
| | | transferLoc(param.getLocNo(), param.getLane()); |
| | | return R.ok(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return R.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/auto/emptyIn/v1") |
| | |
| | | return dto; |
| | | } |
| | | |
| | | @Transactional |
| | | public synchronized void transferLoc(String sourceLocNo, Integer lane) { |
| | | LocMast sourceLocMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", sourceLocNo)); |
| | | if (sourceLocMast == null) { |
| | | throw new CoolException(sourceLocNo + "源库位不存在"); |
| | | } |
| | | |
| | | if (!(sourceLocMast.getLocSts().equals("F") || sourceLocMast.getLocSts().equals("D"))) { |
| | | throw new CoolException(sourceLocNo + "源库位状态不处于在库"); |
| | | } |
| | | |
| | | List<Integer> rows = locMastService.selectRowByCrnNo(sourceLocMast.getCrnNo()); |
| | | LocMast transferLoc = null; |
| | | for (Integer row : rows) { |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("row1", row) |
| | | .eq("loc_type1", sourceLocMast.getLocType1()) |
| | | .eq("loc_sts", "O") |
| | | ); |
| | | for (LocMast locMast : locMasts) { |
| | | if (sourceLocMast.getCrnNo() == 1) { |
| | | if (Utils.getLaneByLocNo(locMast.getLocNo()) != lane) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if (Utils.isDeepLoc(slaveProperties, locMast.getLocNo())) { |
| | | String shallowLocNo = Utils.getShallowLoc(slaveProperties, locMast.getLocNo()); |
| | | LocMast shallowLoc1 = locMastService.selectById(shallowLocNo); |
| | | if (!shallowLoc1.getLocSts().equals("O")) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | transferLoc = locMast; |
| | | break; |
| | | } |
| | | |
| | | if (null != transferLoc) { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (transferLoc == null) { |
| | | throw new CoolException(sourceLocNo + "库位移转失败,未找到空库位"); |
| | | } |
| | | |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(0); |
| | | // 保存工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(11); // 入出库状态: 11.库格移载 |
| | | wrkMast.setIoPri(13D); |
| | | wrkMast.setCrnNo(transferLoc.getCrnNo()); |
| | | wrkMast.setSourceLocNo(sourceLocMast.getLocNo()); // 源库位 |
| | | wrkMast.setLocNo(transferLoc.getLocNo()); // 目标库位 |
| | | wrkMast.setFullPlt(sourceLocMast.getLocSts().equals("D") ? "N" : "Y"); // 满板 |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk(sourceLocMast.getLocSts().equals("D") ? "Y" : "N"); // 空板 |
| | | wrkMast.setBarcode(sourceLocMast.getBarcode()); // 托盘码 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException(sourceLocNo + "库位移转失败,生成库位移转工作档失败"); |
| | | } |
| | | |
| | | // 工作档明细保存 |
| | | if (sourceLocMast.getLocSts().equals("F")) { |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocMast.getLocNo())); |
| | | |
| | | for (LocDetl locDetl : locDetls) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(locDetl); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(new Date()); |
| | | wrkDetl.setAnfme(locDetl.getAnfme()); |
| | | wrkDetl.setAppeTime(new Date()); |
| | | wrkDetl.setModiTime(new Date()); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException(sourceLocNo + "库位移转失败,生成库位移转工作明细档失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 修改源库位状态 |
| | | if (sourceLocMast.getLocSts().equals("D") || sourceLocMast.getLocSts().equals("F")) { |
| | | sourceLocMast.setLocSts("R"); // R.出库预约 |
| | | sourceLocMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(sourceLocMast)) { |
| | | throw new CoolException(sourceLocNo + "库位移转失败,更新源库位状态失败"); |
| | | } |
| | | } |
| | | |
| | | // 修改目标库位状态 |
| | | if (transferLoc.getLocSts().equals("O")) { |
| | | transferLoc.setLocSts("S"); // S.入库预约 |
| | | transferLoc.setModiTime(new Date()); |
| | | if (!locMastService.updateById(transferLoc)) { |
| | | throw new CoolException(sourceLocNo + "库位移转失败,更新目标库位状态失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |