| | |
| | | package com.zy.asrs.wms.apis.wcs.services.Impl;
|
| | |
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.alibaba.fastjson.JSONObject;
|
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
| | | import com.fasterxml.jackson.core.JsonProcessingException;
|
| | | import com.zy.asrs.framework.common.R;
|
| | | import com.zy.asrs.framework.exception.CoolException;
|
| | | import com.zy.asrs.wms.apis.wcs.entity.domain.SystemProperties;
|
| | |
| | | import org.springframework.web.client.RestTemplate;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.*;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | |
| | | for (CacheSite cacheSite:cacheSites) {
|
| | | // 获取任务明细数量
|
| | | List<TaskDetl> taskDetlByTaskId = taskDetlService.getTaskDetlByTaskId(task.getId());
|
| | | double sum = taskDetlByTaskId.stream().mapToDouble(TaskDetl::getAnfme).sum();
|
| | | int sum = (int)taskDetlByTaskId.stream().mapToDouble(TaskDetl::getAnfme).sum();
|
| | | SlapLightControlParam slapLightControlParam = new SlapLightControlParam();
|
| | | slapLightControlParam.setControllerCode(cacheSite.getMemo()).setTagCode(cacheSite.getSiteNo())
|
| | | .setColor("GREEN").setMode("LIGHT").setDisplay(String.valueOf(sum));
|
| | | 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());
|
| | |
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public synchronized R containerConveryor(String code) {
|
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, code));
|
| | | if (tasks.isEmpty()) {
|
| | | return R.error("容器码任务不存在!!");
|
| | | } else if (tasks.size() > 1) {
|
| | | return R.error("容器码任务错误!!");
|
| | | }
|
| | | tasks.forEach(task -> {
|
| | | // try {
|
| | | // ConveyorStarParam conveyorStarParam = new ConveyorStarParam();
|
| | | // conveyorStarParam.setSlotCode(task.getOriginLoc())
|
| | | // .setContainerCode(task.getBarcode());
|
| | | // if (task.getTaskType() == 101) { //任务类型为101全盘出库,直接取下容器,传200
|
| | | // conveyorStarParam.setDirection("200");
|
| | | // } else if (task.getTaskType() == 103) { //如果为任务类型为103,需走回库操作,传100
|
| | | // conveyorStarParam.setDirection("100");
|
| | | // }
|
| | | // //调用三方接口,将任务推送至ESS平台
|
| | | // MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
| | | // // 设置请求参数
|
| | | // params.add("params", JSONObject.toJSONString(conveyorStarParam));
|
| | | // log.info("请求地址:{},请求参数:{}", Constant.CONVEYOR_START, JSONObject.toJSONString(conveyorStarParam));
|
| | | // HttpHeaders headers = new HttpHeaders();
|
| | | // headers.add("Content-Type", "application/json");
|
| | | // HttpEntity httpEntity = new HttpEntity<>(params, headers);
|
| | | // // 请求
|
| | | // ResponseEntity<String> exchange = restTemplate.exchange(Constant.CONVEYOR_START, HttpMethod.POST, httpEntity, String.class);
|
| | | // log.info("下发流动通知 返回结果:{}", exchange);
|
| | | // if (exchange.getBody() == null) {
|
| | | // throw new CoolException("下发流动通知失败!!");
|
| | | // } else {
|
| | | // CommonReponse commonReponse = JSON.toJavaObject(JSON.parseObject(exchange.getBody()), CommonReponse.class);
|
| | | // if (commonReponse.getCode() == 0) {
|
| | | //流动通知下发完成后,修改任务状态为输送线流动中。。
|
| | | //TODO 判断任务是否为103拣料出库,103拣料流动后修改为4(RCS容器流动任务已下发)
|
| | | if (task.getTaskType() == 103) {
|
| | | //TODO 需找海柔确认是否需要重新调用入库接口
|
| | | //更新库存信息,修改任务状态为4 (RCS容器流动任务已下发)
|
| | | workService.pickTask(task.getId());
|
| | | // taskService.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()).set(Task::getTaskSts, TaskStsType.WCS_CONVEYOR_START))
|
| | | } else {
|
| | | taskService.update(new LambdaUpdateWrapper<Task>()
|
| | | .eq(Task::getId, task.getId())
|
| | | .set(Task::getTaskSts, TaskStsType.COMPLETE_OUT.id));
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public synchronized R containerConveryor(String code) throws Exception{
|
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, code));
|
| | | if (Objects.isNull(task)) {
|
| | | throw new CoolException("容器码任务不存在!!");
|
| | | } |
| | | try {
|
| | | ConveyorStarParam conveyorStarParam = new ConveyorStarParam();
|
| | | conveyorStarParam.setSlotCode(task.getOriginSite())
|
| | | .setContainerCode(task.getBarcode());
|
| | | if (task.getTaskType() == 101) { //任务类型为101全盘出库,直接取下容器,传200
|
| | | conveyorStarParam.setDirection("200");
|
| | | } else if (task.getTaskType() == 103 || task.getTaskType() == 107) { //如果为任务类型为103,需走回库操作,传100
|
| | | conveyorStarParam.setDirection("100");
|
| | | }
|
| | | // log.info(task.getTaskNo() + "下发流动通知" + commonReponse.getMsg());
|
| | | // } else {
|
| | | // throw new CoolException("下发流动通知失败!!");
|
| | | // }
|
| | | // }
|
| | | // } catch (Exception ex) {
|
| | | // log.error(ex.getMessage());
|
| | | // } finally {
|
| | | // //如果异常修改禁用状态
|
| | | // taskService.update(new LambdaUpdateWrapper<Task>().set(Task::getStatus, 0)
|
| | | // .set(Task::getUpdateTime, new Date())
|
| | | // .eq(Task::getId, task.getId()));
|
| | | // }
|
| | | });
|
| | | //调用三方接口,将任务推送至ESS平台
|
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
| | | // 设置请求参数
|
| | | HttpHeaders headers = new HttpHeaders();
|
| | | headers.add("Content-Type", "application/json");
|
| | | headers.add("api-version", "v2.0");
|
| | | HttpEntity httpEntity = new HttpEntity<>(conveyorStarParam, headers);
|
| | | log.info("请求地址:{},请求参数:{}", HttpEssUtils.CONVEYOR_START, JSONObject.toJSONString(conveyorStarParam));
|
| | | ResponseEntity<String> exchange = restTemplate.exchange("http://192.168.2.200:9046/conveyor/moveContainer", HttpMethod.POST, httpEntity, String.class);
|
| | | log.info("下发流动通知 返回结果:{}", exchange);
|
| | | if (exchange.getBody() == null) {
|
| | | throw new CoolException("下发流动通知失败!!");
|
| | | } else {
|
| | | CommonReponse commonReponse = JSON.toJavaObject(JSON.parseObject(exchange.getBody()), CommonReponse.class);
|
| | | if (commonReponse.getCode() == 0) {
|
| | | //流动通知下发完成后,修改任务状态为输送线流动中。。
|
| | | if (task.getTaskType() == 103 || task.getTaskType() == 107) {
|
| | | //更新库存信息,修改任务状态为4 (RCS容器流动任务已下发)
|
| | | workService.pickTask(task.getId());
|
| | | } else {
|
| | | taskService.update(new LambdaUpdateWrapper<Task>()
|
| | | .eq(Task::getId, task.getId())
|
| | | .set(Task::getTaskSts, TaskStsType.COMPLETE_OUT.id));
|
| | | }
|
| | | log.info(task.getTaskNo() + "下发流动通知" + commonReponse.getMsg());
|
| | | } else {
|
| | | throw new CoolException("下发流动通知失败!!");
|
| | | }
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("UNK", ex);
|
| | | }
|
| | | return R.ok();
|
| | | }
|
| | |
|
| | |
| | | * 拍灯拣料逻辑,详细说明见接口调用说明
|
| | | *
|
| | | * @param request
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void slapLightLogic(Map<String, Object> request) {
|
| | | public R slapLightLogic(Map<String, Object> request) {
|
| | | String taskNo = request.get("taskNo").toString();
|
| | | String orderNo = request.get("orderNo").toString();
|
| | |
|
| | |
| | | //* 1. 判断当前容器是否还有物料未拣,未拣完闪灯,拣完通知容器流动,并灭灯
|
| | | SlapLightControlParam slapParam = new SlapLightControlParam();
|
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
| | | //默认流动
|
| | | boolean converyor = false;
|
| | | //判断当前任务是否还有物料未拣
|
| | | if (!checked(orderNo, taskNo)) {
|
| | | log.info("未完成闪灯请求地址:{},请求参数:{}", SystemProperties.SLAP_LIGHT, JSONObject.toJSONString(slapParam));
|
| | | //调用三方接口,闪灯不做操作
|
| | | // 设置请求参数
|
| | | params.add("params", JSONObject.toJSONString(slapParam));
|
| | | 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("当前订单明细不存在!!");
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | converyor = true;
|
| | | params.add("params", JSONObject.toJSONString(slapParam));
|
| | | log.info("完成灭灯请求地址:{},请求参数:{}", SystemProperties.SLAP_LIGHT, JSONObject.toJSONString(slapParam));
|
| | | }
|
| | |
|
| | | if (converyor) {
|
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, request.get("taskNo")));
|
| | | if (Objects.isNull(task)) {
|
| | | throw new CoolException("任务不存在!!");
|
| | | }
|
| | | 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());
|
| | | }
|
| | |
|
| | | // HttpHeaders headers = new HttpHeaders();
|
| | | // headers.add("Content-Type", "application/json");
|
| | | // HttpEntity httpEntity = new HttpEntity<>(params, headers);
|
| | | // // 请求
|
| | | // ResponseEntity<CommonReponse> exchange = restTemplate.exchange(SystemProperties.CONVEYOR_START, HttpMethod.POST, httpEntity, CommonReponse.class);
|
| | | // log.info("下发流动通知 返回结果:{}", exchange);
|
| | | // if (exchange.getBody() == null) {
|
| | | // throw new CoolException("下发流动通知失败!!");
|
| | | // } else {
|
| | | // CommonReponse response = exchange.getBody();
|
| | | // if (response.getCode() == 0) {
|
| | | // if (!converyor) {
|
| | | // //* 2. 容器流动判断,如果料箱没有物料 code传200, 有物料传100 执行回库任务,修改任务状态为 调用containerConveryor(taskNo)方法
|
| | | // containerConveryor(request.get("taskNo").toString());
|
| | | // }
|
| | | // }
|
| | | // }
|
| | | return R.ok();
|
| | | }
|
| | |
|
| | | /**
|