| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.CombParam; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.PostMesDataUtils; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.StartupDto; |
| | |
| | | import com.zy.common.web.param.SearchLocParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private TestMastService testMastService; |
| | | @Autowired |
| | | private MatService matService; |
| | | |
| | | @Value("${mes.url}") |
| | | private String mesUrl; |
| | | |
| | | @Value("${mes.inPath}") |
| | | private String inpath; |
| | | |
| | | @PostMapping("/pakin/loc/v1") |
| | | @ResponseBody |
| | | public synchronized R getLocNo(@RequestBody SearchLocParam param) { |
| | | log.info("收到WCS入库接口请求====>>入参:{}", param); |
| | | if (Cools.isEmpty(param.getIoType())) { |
| | | return R.error("入出库类型不能为空"); |
| | | } |
| | | if (Cools.isEmpty(param.getSourceStaNo())) { |
| | | return R.error("源站编号不能为空"); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | List<WaitPakin> waitPakins = null; |
| | | if (param.getIoType() == 1) { |
| | | if (Cools.isEmpty(param.getBarcode())) { |
| | | return R.error("条码不能为空"); |
| | | } |
| | | waitPakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode())); |
| | | if (Cools.isEmpty(waitPakins)) { |
| | | if (Cools.isEmpty(waitPakins) || waitPakins.size() !=1) { |
| | | WrkMast wrkMast = wrkMastService.selectByBarcode(param.getBarcode()); |
| | | if (wrkMast != null && wrkMast.getIoType() == 103) { |
| | | return R.parse(CodeRes.PICK_600); |
| | | if (wrkMast != null || waitPakins.size() !=1) { |
| | | return R.parse("600-重复组托"); |
| | | } |
| | | return R.parse(CodeRes.NO_COMB_700); |
| | | } |
| | | int countWait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet",param.getBarcode()) |
| | | .eq("io_status", "Y")); |
| | | int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet",param.getBarcode())); |
| | | int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet",param.getBarcode())); |
| | | if (countLoc > 0 || countWrk > 0) { |
| | | return R.error("工作档/库存条码数据已存在"); |
| | | if (countLoc > 0 || countWrk > 0 || countWait > 0) { |
| | | if (!Cools.isEmpty(waitPakins.get(0).getDeadWarn()) && waitPakins.get(0).getDeadWarn()!=0){ |
| | | return R.error(CodeRes.EXIST_500); |
| | | } |
| | | } |
| | | } |
| | | if (Cools.isEmpty(param.getLocType1())){ |
| | | return R.error("高低检测信号不能为空"); |
| | | param.setLocType1((short)1); |
| | | } |
| | | |
| | | // 源站点状态检测 |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getSourceStaNo(), true); |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getSourceStaNo(), false); |
| | | sourceStaNo.setLocType1(param.getLocType1()); |
| | | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | |
| | | StartupDto dto = null; |
| | |
| | | default: |
| | | break; |
| | | } |
| | | log.info("/pakin/loc/v1:"+dto + "======托盘码:"+param.getBarcode()); |
| | | log.info("WCS入库接口返参:{},pack码:{}", dto, param.getBarcode()); |
| | | return R.ok().add(dto); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 全板入库 |
| | | * 全板入库 |
| | | */ |
| | | @Transactional |
| | | public StartupDto startupFullPutStore(Integer devpNo, String barcode, LocTypeDto locTypeDto, List<WaitPakin> waitPakins) { |
| | |
| | | if (!res) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 目标库位 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | |
| | | // 生成工作档明细 |
| | | waitPakins.forEach(waitPakin -> { |
| | | for (WaitPakin waitPakin: waitPakins) { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(waitPakin); |
| | | wrkDetl.setWrkNo(wrkMast.getWrkNo()); |
| | | wrkDetl.setIoTime(wrkMast.getIoTime()); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setModiTime(now); |
| | | wrkDetl.setDeadWarn(waitPakin.getDeadWarn()); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作明细失败"); |
| | | } |
| | | }); |
| | | |
| | | TestMast testMast = testMastService.selectOne(new EntityWrapper<TestMast>() |
| | | .eq("barcode", wrkDetl.getMatnr()) |
| | | .eq("user_id",wrkDetl.getZpallet()));//pack码 |
| | | if (Cools.isEmpty(testMast)){ |
| | | //生成测试档 |
| | | testMast=new TestMast(); |
| | | //入待测库位通道设为0 |
| | | if(locMast.getChannel()==null) { |
| | | testMast.setChannel(0);//通道设为0 |
| | | }else{ |
| | | testMast.setChannel(locMast.getChannel()); |
| | | } |
| | | testMast.setUserId(wrkMast.getBarcode());//托盘码 |
| | | testMast.setStatus(1); |
| | | testMast.setBarcode(wrkDetl.getMatnr()); |
| | | testMast.setLocNo(locMast.getLocNo()); |
| | | testMast.setModiTime(now); |
| | | testMast.setAppeTime(now); |
| | | if (!testMastService.insert(testMast)){ |
| | | throw new CoolException(wrkDetl.getMatnr()+"生成测试档失败"); |
| | | } |
| | | }else { |
| | | testMast.setBarcode(wrkDetl.getMatnr()); |
| | | testMast.setChannel(locMast.getChannel()); |
| | | testMast.setLocNo(locMast.getLocNo()); |
| | | testMast.setStatus(1); |
| | | testMast.setUserId(wrkMast.getBarcode());//托盘码 |
| | | testMast.setAppeTime(now); |
| | | if(!testMastService.update(testMast,new EntityWrapper<TestMast>().eq("barcode", wrkDetl.getMatnr()))){ |
| | | throw new CoolException(wrkDetl.getMatnr()+"更新测试档失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | // 更新入库通知档 ioStatus ===>> Y |
| | | Wrapper<WaitPakin> wrapper = new EntityWrapper<WaitPakin>() |
| | | .eq("zpallet", barcode); |
| | | WaitPakin setParam = new WaitPakin(); |
| | | setParam.setLocNo(dto.getLocNo()); |
| | | setParam.setIoStatus("Y"); |
| | | setParam.setModiTime(now); |
| | | if (!waitPakinService.update(setParam, wrapper)) { |
| | |
| | | throw new CoolException("更新源站失败"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("O")){ |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)){ |
| | | throw new CoolException("改变库位状态失败"); |
| | | }else{ |
| | | if (locMast.getRow1()<2){ |
| | | //1.扫码上报 |
| | | CombParam combParam = new CombParam(); |
| | | combParam.setPackNo(waitPakins.get(0).getMatnr()); |
| | | combParam.setBarcode(wrkMast.getBarcode()); |
| | | combParam.setLocNo(wrkMast.getLocNo()); |
| | | combParam.setPackSts(0); |
| | | combParam.setStepSts(1); |
| | | combParam.setRequestTime(DateUtils.convert(now)); |
| | | // new PostMesDataUtils().postMesData("MES系统",mesUrl,inpath,combParam); |
| | | } |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo()+"目标库位已被占用"); |
| | | } |
| | | |
| | | return dto; |
| | | } |
| | | |