|  |  | 
 |  |  | import com.alibaba.fastjson.JSONObject;
 | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 | 
 |  |  | import com.zy.asrs.framework.common.Cools;
 | 
 |  |  | import com.zy.asrs.framework.common.R;
 | 
 |  |  | import com.zy.asrs.framework.exception.CoolException;
 | 
 |  |  | import com.zy.asrs.wms.apis.wcs.entity.domain.SystemProperties;
 | 
 |  |  | 
 |  |  | 
 | 
 |  |  |     @Autowired
 | 
 |  |  |     private PlatformService platformService;
 | 
 |  |  | 
 | 
 |  |  |     @Resource
 | 
 |  |  |     private SystemProperties systemProperties;
 | 
 |  |  |     @Autowired
 | 
 |  |  |     private MobileService mobileService;
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  |     /**
 | 
 |  |  | 
 |  |  |         } else {
 | 
 |  |  |             if (task.getTaskSts() == TaskStsType.WCS_EXECUTE_OUT_ARRIVED.id
 | 
 |  |  |                     || task.getTaskSts() == TaskStsType.WCS_EXECUTE_OUT_TASK_DONE.id) {
 | 
 |  |  |                 // 到达拣选位,控制播种墙亮灯
 | 
 |  |  |                 CacheSite cacheSite = cacheSiteService.getOne(new LambdaQueryWrapper<CacheSite>()
 | 
 |  |  |                         .eq(CacheSite::getChannel, task.getTargetSite())
 | 
 |  |  |                         .isNull(CacheSite::getOrderId).orderByAsc(CacheSite::getId), false);
 | 
 |  |  | //                List<CacheSite> cacheSites = cacheSiteService.list(new LambdaQueryWrapper<CacheSite>()
 | 
 |  |  | //                            .eq(CacheSite::getBarcode, task.getBarcode()));
 | 
 |  |  |                 if (Objects.isNull(cacheSite)) {
 | 
 |  |  |                     log.error("条码:{},未找到播种墙亮灯", task.getBarcode());
 | 
 |  |  |                     throw new CoolException("未找到播种墙");
 | 
 |  |  |                 }
 | 
 |  |  | 
 | 
 |  |  |                 // 获取任务明细数量
 | 
 |  |  |                 List<TaskDetl> taskDetlByTaskId = taskDetlService.getTaskDetlByTaskId(task.getId());
 | 
 |  |  |                 int sum = (int) taskDetlByTaskId.stream().mapToDouble(TaskDetl::getAnfme).sum();
 | 
 |  |  |                 SlapLightControlParam slapLightControlParam = new SlapLightControlParam();
 | 
 |  |  |                 slapLightControlParam
 | 
 |  |  |                         .setControllerCode(cacheSite.getMemo())
 | 
 |  |  |                         .setTagCode(cacheSite.getSiteNo())
 | 
 |  |  |                         .setColor("GREEN")
 | 
 |  |  |                         .setIndex(cacheSite.getIndex())
 | 
 |  |  |                         .setMode("LIGHT")
 | 
 |  |  |                         .setDisplay(sum + "");
 | 
 |  |  |                 // 发起亮灯请求
 | 
 |  |  |                 log.info("任务{}到达拣选位,播种墙亮灯下发", task.getTaskNo(), JSONObject.toJSONString(slapLightControlParam));
 | 
 |  |  |                 CommonReponse response = HttpEssUtils.post("到达拣选位,播种墙亮灯", HttpEssUtils.PLT_SEND_COMMAND, slapLightControlParam);
 | 
 |  |  |                 if (response.getCode().equals(0)) {
 | 
 |  |  |                     log.info("任务{}到达拣选位,播种墙{}亮灯成功", task.getTaskNo(), cacheSite.getSiteNo());
 | 
 |  |  |                 } else {
 | 
 |  |  |                     log.info("任务{}到达拣选位,播种墙{}亮灯失败", task.getTaskNo(), cacheSite.getSiteNo());
 | 
 |  |  |                 }
 | 
 |  |  | 
 | 
 |  |  |                 boolean update = taskService.update(new LambdaUpdateWrapper<Task>()
 | 
 |  |  |                         .set(Task::getTaskSts, TaskStsType.WAVE_SEED.id)
 | 
 |  |  | 
 |  |  |         //* 1. 判断当前容器是否还有物料未拣,未拣完闪灯,拣完通知容器流动,并灭灯
 | 
 |  |  |         SlapLightControlParam slapParam = new SlapLightControlParam();
 | 
 |  |  |         MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
 | 
 |  |  |         Order one = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, orderNo));
 | 
 |  |  |         if (Objects.isNull(one)) {
 | 
 |  |  |             throw new CoolException("当前订单明细不存在!!");
 | 
 |  |  |         }
 | 
 |  |  | 
 | 
 |  |  |         if (Cools.isEmpty(slapParam)) {
 | 
 |  |  |             return null;
 | 
 |  |  |         }
 | 
 |  |  | 
 | 
 |  |  |         //判断当前任务是否还有物料未拣
 | 
 |  |  |         if (!checked(orderNo, taskNo)) {
 | 
 |  |  |             log.info("未完成闪灯请求地址:{},请求参数:{}", SystemProperties.SLAP_LIGHT, JSONObject.toJSONString(slapParam));
 | 
 |  |  |             //调用三方接口,闪灯不做操作
 | 
 |  |  |             // 设置请求参数
 | 
 |  |  |             mobileService.sowLightMange(siteNo, one, "LIGHT");
 | 
 |  |  | //            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("当前订单明细不存在!!");
 | 
 |  |  |             }
 | 
 |  |  | 
 | 
 |  |  | //            //获取播种已完成的订单明细
 | 
 |  |  | //            List<OrderDetl> detlList = orderDetls.stream().filter(detl -> {
 | 
 |  |  | //                return detl.getPickStatus() == OrderPickStatus.ORDER_PICK_STATUS_DONE.val;
 | 
 |  |  | //            }).collect(Collectors.toList());
 | 
 |  |  | 
 | 
 |  |  |             //判断数量是否与订单明细的需求量相同,相同则订单完成
 | 
 |  |  | 
 | 
 |  |  |             List<WaveSeed> seeds = waveSeedService.list(new LambdaQueryWrapper<WaveSeed>().eq(WaveSeed::getOrderNo, orderNo));
 | 
 |  |  |             if (Objects.isNull(seeds)) {
 | 
 |  |  |                 throw new CoolException("数据错误:播种数据不存在!!");
 | 
 |  |  |             }
 | 
 |  |  | 
 | 
 |  |  |             Double tolAnfme = seeds.stream().mapToDouble(WaveSeed::getAnfme).sum();
 | 
 |  |  |             Double toDouble = seeds.stream().mapToDouble(WaveSeed::getWorkQty).sum();
 | 
 |  |  |             if (toDouble.compareTo(tolAnfme) >= 0) {
 | 
 |  |  | 
 |  |  |                         }
 | 
 |  |  |                     }
 | 
 |  |  |                 }
 | 
 |  |  |                 //订单完成,灭灯
 | 
 |  |  |                 mobileService.sowLightMange(siteNo, one, "DARK");
 | 
 |  |  |                 log.info("完成灭灯请求地址:{},请求参数:{}", SystemProperties.SLAP_LIGHT, JSONObject.toJSONString(slapParam));
 | 
 |  |  |             } else {
 | 
 |  |  |                 //订单未完成,继续亮灯
 | 
 |  |  |                 mobileService.sowLightMange(siteNo, one, "LIGHT");
 | 
 |  |  |                 log.info("继续亮灯请求地址:{},请求参数:{}", SystemProperties.SLAP_LIGHT, JSONObject.toJSONString(slapParam));
 | 
 |  |  | 
 | 
 |  |  |             }
 | 
 |  |  |             params.add("params", JSONObject.toJSONString(slapParam));
 | 
 |  |  |             log.info("完成灭灯请求地址:{},请求参数:{}", SystemProperties.SLAP_LIGHT, JSONObject.toJSONString(slapParam));
 |