skyouc
2025-07-10 25579b7079f5fab8fc660358644deb5aea633ed2
zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/services/Impl/WcsApiServiceImpl.java
@@ -348,7 +348,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R slapLightLogic(Map<String, Object> request) {
        String taskNo = request.get("taskNo").toString();
        List<String> taskNos = (List<String>)request.get("taskNo");
        String orderNo = request.get("orderNo").toString();
        String siteNo = Objects.isNull(request.get("siteNo")) ? null : request.get("siteNo").toString();
        List<CacheSite> performs = cacheSiteService.list(new LambdaQueryWrapper<CacheSite>().eq(CacheSite::getOrderNo, orderNo));
@@ -359,59 +359,61 @@
        //* 1. 判断当前容器是否还有物料未拣,未拣完闪灯,拣完通知容器流动,并灭灯
        SlapLightControlParam slapParam = new SlapLightControlParam();
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        //判断当前任务是否还有物料未拣
        if (!checked(orderNo, taskNo)) {
            log.info("未完成闪灯请求地址:{},请求参数:{}", SystemProperties.SLAP_LIGHT, JSONObject.toJSONString(slapParam));
            //调用三方接口,闪灯不做操作
            // 设置请求参数
            throw new CoolException("当前任务未完成,不能执行此操作!!");
        taskNos.forEach(taskNo -> {
            //判断当前任务是否还有物料未拣
            if (!checked(orderNo, taskNo)) {
                log.info("未完成闪灯请求地址:{},请求参数:{}", SystemProperties.SLAP_LIGHT, JSONObject.toJSONString(slapParam));
                //调用三方接口,闪灯不做操作
                // 设置请求参数
                throw new CoolException("当前任务未完成,不能执行此操作!!");
//            params.add("params", JSONObject.toJSONString(slapParam));
        } else {
            //调用三方接口,灭灯通知容器流动, 传灭灯参数
            //todo 判断当前订单是否完成,完成灭灯,未完成保持拣货状态亮灯
            Order one = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, orderNo));
            if (Objects.isNull(one)) {
                throw new CoolException("当前订单明细不存在!!");
            }
            } else {
                //调用三方接口,灭灯通知容器流动, 传灭灯参数
                //todo 判断当前订单是否完成,完成灭灯,未完成保持拣货状态亮灯
                Order one = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, orderNo));
                if (Objects.isNull(one)) {
                    throw new CoolException("当前订单明细不存在!!");
                }
//            //获取播种已完成的订单明细
//            List<OrderDetl> detlList = orderDetls.stream().filter(detl -> {
//                return detl.getPickStatus() == OrderPickStatus.ORDER_PICK_STATUS_DONE.val;
//            }).collect(Collectors.toList());
            //判断数量是否与订单明细的需求量相同,相同则订单完成
            //播种完成,释放绑定站点
            List<CacheSite> cacheSites = cacheSiteService.list(new LambdaQueryWrapper<CacheSite>()
                    .eq(!Objects.isNull(siteNo), CacheSite::getSiteNo, siteNo)
                    .eq(CacheSite::getOrderNo, orderNo));
            for (CacheSite cacheSite : cacheSites) {
                if (!cacheSite.getSiteStatus().equals(CacheSiteStatusType.O.id)) {
                    cacheSite.setSiteStatus(CacheSiteStatusType.O.id);
                    cacheSite.setOrderId(null);
                    cacheSite.setBarcode(null);
                    cacheSite.setOrderNo(null);
                    cacheSite.setPlatformId(null);
                    cacheSite.setPlatformNo(null);
                    cacheSite.setUpdateTime(new Date());
                    if (!cacheSiteService.updateById(cacheSite)) {
                        throw new CoolException("播种站点更新失败");
                //判断数量是否与订单明细的需求量相同,相同则订单完成
                //播种完成,释放绑定站点
                List<CacheSite> cacheSites = cacheSiteService.list(new LambdaQueryWrapper<CacheSite>()
                        .eq(!Objects.isNull(siteNo), CacheSite::getSiteNo, siteNo)
                        .eq(CacheSite::getOrderNo, orderNo));
                for (CacheSite cacheSite : cacheSites) {
                    if (!cacheSite.getSiteStatus().equals(CacheSiteStatusType.O.id)) {
                        cacheSite.setSiteStatus(CacheSiteStatusType.O.id);
                        cacheSite.setOrderId(null);
                        cacheSite.setBarcode(null);
                        cacheSite.setOrderNo(null);
                        cacheSite.setPlatformId(null);
                        cacheSite.setPlatformNo(null);
                        cacheSite.setUpdateTime(new Date());
                        if (!cacheSiteService.updateById(cacheSite)) {
                            throw new CoolException("播种站点更新失败");
                        }
                    }
                }
                params.add("params", JSONObject.toJSONString(slapParam));
                log.info("完成灭灯请求地址:{},请求参数:{}", SystemProperties.SLAP_LIGHT, JSONObject.toJSONString(slapParam));
            }
            params.add("params", JSONObject.toJSONString(slapParam));
            log.info("完成灭灯请求地址:{},请求参数:{}", SystemProperties.SLAP_LIGHT, JSONObject.toJSONString(slapParam));
        }
        Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, request.get("taskNo")));
        if (Objects.isNull(task)) {
            throw new CoolException("任务不存在!!");
        }
        try {
            containerConveryor(task.getBarcode());
        } catch (Exception e) {
            log.error("执行异常:UNK",  e);
            throw new CoolException(e.getMessage());
        }
            Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, request.get("taskNo")));
            if (Objects.isNull(task)) {
                throw new CoolException("任务不存在!!");
            }
            try {
                containerConveryor(task.getBarcode());
            } catch (Exception e) {
                log.error("执行异常:UNK",  e);
                throw new CoolException(e.getMessage());
            }
        });
        return R.ok();
    }