| | |
| | | package com.zy.common.web; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | 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.command.LedCommand; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.EmptyPlateOutParam; |
| | | import com.zy.asrs.entity.param.MatDto; |
| | | import com.zy.asrs.entity.result.KeyValueVo; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.config.WebSocketServer; |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.service.CommonService; |
| | |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private WorkService workService; |
| | | @Autowired |
| | | private StaDescService staDescService; |
| | | @Autowired |
| | | private WebSocketServer webSocketServer; |
| | | |
| | | |
| | | @PostMapping("/led/getTask") |
| | | @ResponseBody |
| | | public synchronized R getledTask(@RequestBody Map<String, String> param) { |
| | | String taskNo = param.get("taskNo"); |
| | | String sta = param.get("sta"); |
| | | // 命令集合 |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | if ("0".equals(sta)) { |
| | | |
| | | // 工作档集合 |
| | | List<WrkMast> wrkMasts = new ArrayList<>(); |
| | | // 获取工作档数据 |
| | | WrkMast wrkMast = wrkMastService.selectById(taskNo); |
| | | if (null == wrkMast) { return R.error(); } |
| | | wrkMasts.add(wrkMast); |
| | | // 组装命令 |
| | | LedCommand ledCommand = new LedCommand(); |
| | | ledCommand.setWorkNo(wrkMast.getWrkNo()); |
| | | ledCommand.setIoType(wrkMast.getIoType()); |
| | | wrkMasts.add(wrkMast); |
| | | // 出库模式 |
| | | switch (wrkMast.getIoType()) { |
| | | case 1: |
| | | ledCommand.setTitle("全板入库"); |
| | | break; |
| | | case 10: |
| | | ledCommand.setTitle("空板入库"); |
| | | break; |
| | | case 101: |
| | | ledCommand.setTitle("全板出库"); |
| | | break; |
| | | case 103: |
| | | ledCommand.setTitle("拣料出库"); |
| | | break; |
| | | case 104: |
| | | ledCommand.setTitle("并板出库"); |
| | | break; |
| | | case 107: |
| | | ledCommand.setTitle("盘点出库"); |
| | | break; |
| | | case 110: |
| | | ledCommand.setTitle("空板出库"); |
| | | ledCommand.setEmptyMk(true); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); |
| | | ledCommand.setStaNo(wrkMast.getStaNo()); |
| | | ledCommand.setBarcode(wrkMast.getBarcode()); |
| | | if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); |
| | | |
| | | wrkDetls.forEach(wrkDetl -> { |
| | | Double total = 0.0; |
| | | EntityWrapper<LocDetl> wrapper = new EntityWrapper<>(); |
| | | LocDetl locDetl = locDetlService.selectOne(wrapper.eq("zpallet", wrkDetl.getZpallet()).eq("matnr", wrkDetl.getMatnr())); |
| | | if (Cools.isEmpty(locDetl)) { |
| | | total = wrkDetl.getAnfme(); |
| | | } else { |
| | | total = locDetl.getAnfme(); |
| | | } |
| | | if (wrkMast.getIoType() == 101 || wrkMast.getIoType() == 1) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total)); |
| | | } |
| | | if (wrkMast.getIoType() == 103 && (null == wrkDetl.getInspect() || 0 == wrkDetl.getInspect())) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total)); |
| | | } |
| | | if (wrkMast.getIoType() == 107 || wrkMast.getIoType() == 104) { |
| | | ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getBatch(), wrkDetl.getSpecs(), wrkDetl.getManu(), wrkDetl.getMemo(), wrkDetl.getAnfme(),total)); |
| | | } |
| | | }); |
| | | } |
| | | commands.add(ledCommand); |
| | | |
| | | Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet()); |
| | | // 修改主档led标记 |
| | | for (WrkMast wrkMast1 : wrkMasts) { |
| | | wrkMast1.setOveMk("Y"); |
| | | wrkMast1.setModiTime(new Date()); |
| | | if (wrkMastService.updateById(wrkMast1)) { |
| | | throw new CoolException("更新工作档失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | Map<String,Object> map=new HashMap<String, Object>(); |
| | | map.put("to",sta); |
| | | map.put("message",Cools.add("type", "task").add("taskList",commands)); |
| | | webSocketServer.onMessage(JSONObject.toJSONString(map),null,sta); |
| | | return R.ok(); |
| | | |
| | | } |
| | | |
| | | @PostMapping("/led/getError") |
| | | @ResponseBody |
| | | public synchronized R getledError(@RequestBody Map<String, String> param) { |
| | | String sta = param.get("sta"); |
| | | String message = param.get("msg"); |
| | | if (Cools.isEmpty(sta) || Cools.isEmpty(message)) { |
| | | return R.error(); |
| | | } |
| | | Map<String,Object> map=new HashMap<String, Object>(); |
| | | |
| | | map.put("to",sta); |
| | | map.put("message",Cools.add("type", "error").add("errMsg",message)); |
| | | webSocketServer.onMessage(JSONObject.toJSONString(map),null,sta); |
| | | |
| | | |
| | | return R.ok(); |
| | | |
| | | } |
| | | |
| | | |
| | | @Transactional |
| | | public synchronized StartupDto getLocNo3(@RequestBody SearchLocParam param){ |
| | | log.info("收到WCS拣料入库接口请求====>>入参:{}", param); |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", param.getBarcode())); |
| | | if (Cools.isEmpty(wrkMast)){ |
| | | throw new CoolException("未找到任务"); |
| | | } |
| | | StartupDto dto = null; |
| | | StartupDto dto = new StartupDto(); |
| | | // 获取目标站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", wrkMast.getIoType() - 50) |
| | |
| | | wrkMast.setLocNo(wrkMast.getSourceLocNo()); // 目标库位 = 出库时的源库位 |
| | | wrkMast.setSourceLocNo(""); // 源库位清空 |
| | | wrkMast.setModiTime(now); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | throw new CoolException("更新工作档数据状态失败"); |
| | | } |
| | | // 更新明细档io_time (历史档关联使用) |
| | |
| | | List<KeyValueVo> list = locDetls.stream().map(item -> new KeyValueVo(item.getMatnr(), item.getBatch())).distinct().collect(Collectors.toList()); |
| | | try{ |
| | | // dto = commonService.getLocNo(1, 57, param.getSourceStaNo(), list, locTypeDto, 0); |
| | | dto= commonService.getLocNo(1, param.getSourceStaNo(), locDetls.get(0).getMatnr(),locDetls.get(0).getBatch() ,null,locTypeDto); |
| | | dto= commonService.getLocNo(1, param.getSourceStaNo(), locDetls.get(0).getMatnr(),locDetls.get(0).getBatch() ,null,locTypeDto,locDetls.size()>1); |
| | | }catch (Exception e){ |
| | | log.error("堆垛机站盘点再入库查询库位出错:"+e.getMessage()+e); |
| | | return R.error("e.getMessage()"); |
| | |
| | | } |
| | | WrkMast wrkMastPakin = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | | .eq("barcode", param.getBarcode()) |
| | | .eq("io_type", 103) |
| | | .in("io_type", 103,53) |
| | | .eq("wrk_sts",14)); |
| | | if (!Cools.isEmpty(wrkMastPakin)){ |
| | | StartupDto locNo3 = getLocNo3(param); |
| | |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(12, true); |
| | | |
| | | // 检索库位 |
| | | StartupDto dto = commonService.getLocNo( 10, 12, null,null,null, locTypeDto); |
| | | StartupDto dto = commonService.getLocNo( 10, 12, null,null,null, locTypeDto,false); |
| | | Date now = new Date(); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | |
| | | // 检索库位 |
| | | List<String> matnrs = waitPakins.stream().map(WaitPakin::getMatnr).distinct().collect(Collectors.toList()); |
| | | List<String> batchs = waitPakins.stream().map(WaitPakin::getBatch).distinct().collect(Collectors.toList()); |
| | | StartupDto dto = commonService.getLocNo( 1, devpNo, matnrs.get(0),batchs.get(0),null, locTypeDto); |
| | | StartupDto dto = commonService.getLocNo( 1, devpNo, matnrs.get(0),batchs.get(0),null, locTypeDto, matnrs.size() > 1); |
| | | int workNo = dto.getWorkNo(); |
| | | Date now = new Date(); |
| | | // 生成工作档 |
| | |
| | | // 源站点状态检测 |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(devpNo, true); |
| | | // 检索库位 |
| | | StartupDto dto = commonService.getLocNo( 10, devpNo, null,null,null, locTypeDto); |
| | | StartupDto dto = commonService.getLocNo( 10, devpNo, null,null,null, locTypeDto,false); |
| | | int workNo = dto.getWorkNo(); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |