自动化立体仓库 - WMS系统
zyx
2024-04-07 c135b2adb55f470ca20b434ed71ae48d8874d6b0
src/main/java/com/zy/asrs/controller/AgvBasDevpController.java
@@ -18,7 +18,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@@ -115,6 +114,7 @@
        }
        agvBasDevp.setLocSts("O");
        agvBasDevp.setBarcode("");
        agvBasDevp.setLocType2(null);
        agvBasDevpService.update(agvBasDevp,new EntityWrapper<AgvBasDevp>().eq("dev_no",agvBasDevp.getDevNo()));
        return R.ok();
@@ -200,42 +200,72 @@
        return R.ok(result);
    }
    @RequestMapping(value = "/basDevp/visualized/list/auth/v2")
    public R visualizedList(@RequestParam String stationCode){
        Map<String, Object> result = agvBasDevpService.getAgvBasDevpDtoByStationCode(stationCode);
        return R.ok(result);
    }
    /*
    容器离场
    任务完成
     */
    @RequestMapping(value = "/basDevp/visualized/container/moveOut")
    public R visualiZedContainerMoveOut(@RequestBody Map<String,Object> map) {
        List<String> devNos = (List<String>) map.get("devNo");
        List<AgvWrkMast> agvWrkMastList = devNos.stream().map(devNo -> {
        List<String> devNos = new ArrayList<>();
        List<AgvWrkMast> agvWrkMastList = new ArrayList<>();
        try {
            devNos = (List<String>) map.get("devNo");
            agvWrkMastList = devNos.stream().map(devNo -> {
                AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", devNo).eq("wrk_sts",205L));
                if(agvWrkMast.getIoType() != 101 && agvWrkMast.getIoType() != 110){
                    throw new CoolException("工作号为" + agvWrkMast.getWrkNo() + "类型不为101.出库,无法执行容器离场任务,请重新选择站点。");
                }
                return agvWrkMast;
            }).collect(Collectors.toList());
        }catch (Exception e){
            String devNo = map.get("devNo").toString();
            AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", devNo));
            if(agvWrkMast.getIoType() != 101 && agvWrkMast.getIoType() != 110){
                throw new CoolException("工作号为" + agvWrkMast.getWrkNo() + "类型不为101.出库,无法执行容器离场任务,请重新选择站点。");
            }
            return agvWrkMast;
        }).collect(Collectors.toList());
            agvWrkMastList.add(agvWrkMast);
        try {
           int code = agvWrkMastService.containerMoveOut(agvWrkMastList);
           if(code == 0){
               //将工作党状态改为容器离场
               agvWrkMastList.forEach(agvWrkMast -> {
                   agvWrkMast.setWrkSts(206L);
                   agvWrkMastService.updateById(agvWrkMast);
               });
               //修改站点状态
               devNos.forEach(devNo -> {
                   AgvBasDevp agvBasDevp = agvBasDevpService.selectById(devNo);
                   agvBasDevp.setBarcode("");
                   agvBasDevp.setLocSts("O");
                   agvBasDevpService.updateById(agvBasDevp);
               });
           }
        } catch (IOException e) {
            e.printStackTrace();
            return R.error("容器离场失败");
        }
//        List<AgvWrkMast> agvWrkMastList = devNos.stream().map(devNo -> {
//            AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", devNo));
//            if(agvWrkMast.getIoType() != 101 && agvWrkMast.getIoType() != 110){
//                throw new CoolException("工作号为" + agvWrkMast.getWrkNo() + "类型不为101.出库,无法执行容器离场任务,请重新选择站点。");
//            }
//            return agvWrkMast;
//        }).collect(Collectors.toList());
        agvWrkMastList.forEach(agvWrkMast -> {
            agvWrkMast.setWrkSts(206L);
            agvWrkMastService.updateById(agvWrkMast);
        });
//        try {
//           int code = agvWrkMastService.containerMoveOut(agvWrkMastList);
//           if(code == 0){
//               //将工作党状态改为容器离场
//               agvWrkMastList.forEach(agvWrkMast -> {
//                   agvWrkMast.setWrkSts(206L);
//                   agvWrkMastService.updateById(agvWrkMast);
//               });
//               //修改站点状态
////               devNos.forEach(devNo -> {
////                   AgvBasDevp agvBasDevp = agvBasDevpService.selectById(devNo);
////                   agvBasDevp.setBarcode("");
////                   agvBasDevp.setLocSts("O");
////                   agvBasDevpService.updateById(agvBasDevp);
////               });
//           }
//        } catch (IOException e) {
//            e.printStackTrace();
//            return R.error("容器离场失败");
//        }
        return R.ok("容器离场成功");
    }
@@ -245,14 +275,36 @@
     */
    @RequestMapping(value = "/basDevp/visualized/container/pickIn")
    public R visualiZedPickIn(@RequestBody Map<String,Object> map){
        List<String> devNos = (List<String>) map.get("devNo");
        List<AgvWrkMast> agvWrkMastList = devNos.stream().map(devNo -> {
            AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", devNo));
            if(agvWrkMast.getIoType() == 101){
                throw new CoolException("工作号为" + agvWrkMast.getWrkNo() + "类型为101.出库,无法执行拣料入库任务,请重新选择站点。");
        List<String> devNos = new ArrayList<>();
        List<AgvWrkMast> agvWrkMastList = new ArrayList<>();
        try {
            devNos = (List<String>) map.get("devNo");
            agvWrkMastList = devNos.stream().map(devNo -> {
                AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", devNo).eq("wrk_sts",205L));
                if(agvWrkMast.getIoType() == 101){
                    throw new CoolException("工作号为" + agvWrkMast.getWrkNo() + "类型为101.出库,无法执行拣料入库任务,请重新选择站点。");
                }
                return agvWrkMast;
            }).collect(Collectors.toList());
        }catch (Exception e){
            String devNo = map.get("devNo").toString();
            AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", devNo).eq("wrk_sts",205L));
            if (agvWrkMast != null) {
                if(agvWrkMast.getIoType() == 101){
                    throw new CoolException("工作号为" + agvWrkMast.getWrkNo() + "类型为101.出库,无法执行拣料入库任务,请重新选择站点。");
                }
                agvWrkMastList.add(agvWrkMast);
            }
            return agvWrkMast;
        }).collect(Collectors.toList());
        }
//        List<String> devNos = (List<String>) map.get("devNo");
//        List<AgvWrkMast> agvWrkMastList = devNos.stream().map(devNo -> {
//            AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", devNo));
//            if(agvWrkMast.getIoType() == 101){
//                throw new CoolException("工作号为" + agvWrkMast.getWrkNo() + "类型为101.出库,无法执行拣料入库任务,请重新选择站点。");
//            }
//            return agvWrkMast;
//        }).collect(Collectors.toList());
        agvWorkService.pickIn(agvWrkMastList);