| | |
| | | package com.zy.asrs.wms.apis.wcs.services.Impl;
|
| | |
|
| | | 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.R;
|
| | | import com.zy.asrs.framework.exception.CoolException;
|
| | | import com.zy.asrs.wms.apis.wcs.entity.domain.SystemProperties;
|
| | | import com.zy.asrs.wms.apis.wcs.entity.enums.EssTaskStatus;
|
| | | import com.zy.asrs.wms.apis.wcs.entity.request.*;
|
| | | import com.zy.asrs.wms.apis.wcs.entity.response.CommonReponse;
|
| | | import com.zy.asrs.wms.apis.wcs.services.WcsApiService;
|
| | | import com.zy.asrs.wms.asrs.entity.Task;
|
| | | import com.zy.asrs.wms.asrs.entity.TaskDetl;
|
| | | import com.zy.asrs.wms.asrs.entity.WaveSeed;
|
| | | import com.zy.asrs.wms.asrs.entity.enums.TaskStsType;
|
| | | import com.zy.asrs.wms.asrs.service.TaskService;
|
| | | import com.zy.asrs.wms.asrs.service.WaitPakinService;
|
| | | import com.zy.asrs.wms.asrs.service.WorkService;
|
| | | import com.zy.asrs.wms.asrs.service.*;
|
| | | import io.jsonwebtoken.lang.Collections;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.http.HttpEntity;
|
| | | import org.springframework.http.HttpHeaders;
|
| | | import org.springframework.http.HttpMethod;
|
| | | import org.springframework.http.ResponseEntity;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.util.LinkedMultiValueMap;
|
| | | import org.springframework.util.MultiValueMap;
|
| | | import org.springframework.web.client.RestTemplate;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Objects;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | @Slf4j
|
| | | @Service
|
| | |
| | | private WorkService workService;
|
| | | @Autowired
|
| | | private TaskService taskService;
|
| | | @Autowired
|
| | | private TaskDetlService taskDetlService;
|
| | |
|
| | | @Autowired
|
| | | private WaveSeedService waveSeedService;
|
| | |
|
| | | @Autowired
|
| | | private RestTemplate restTemplate;
|
| | |
|
| | |
|
| | | /**
|
| | |
| | | return R.success("success");
|
| | | }
|
| | |
|
| | | /**
|
| | | * 容器执行状态上报
|
| | | *
|
| | | * @param callbackParam
|
| | | * @param stockType
|
| | | * @param hostId
|
| | | */
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void receiveTaskStatus(TasksStatusCallbackParam callbackParam, String stockType, Long hostId) {
|
| | |
| | | .eq(Task::getBarcode, callbackParam.getContainerCode())
|
| | | .eq(Task::getTaskNo, callbackParam.getTaskCode()));
|
| | |
|
| | | //event事件为task,表明任务上报完成状态
|
| | | if (callbackParam.getEventType().equals(EssTaskStatus.TASK_EVENT_STATUS.event) && result) {
|
| | | //任务状态修改为 99 入库完成
|
| | | workService.completeTask(task.getId());
|
| | | }
|
| | | } else { //出库任务
|
| | |
| | |
|
| | | /**
|
| | | * 容器流动通知
|
| | | *
|
| | | * @param code
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public R containerConveryor(String code) {
|
| | | public synchronized R containerConveryor(String code) {
|
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, code));
|
| | | if (tasks.isEmpty()) {
|
| | | return R.error("容器码任务不存在!!");
|
| | |
| | | //流动通知下发完成后,修改任务状态为输送线流动中。。
|
| | | //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 {
|
| | |
| | | return R.ok();
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public R rfidCallback(RfidSingalRequest request) {
|
| | |
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 拍灯拣料逻辑,详细说明见接口调用说明
|
| | | *
|
| | | * @param request
|
| | | */
|
| | | @Override
|
| | | public void 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)) {
|
| | | //调用三方接口,闪灯不做操作
|
| | |
|
| | | // 设置请求参数
|
| | | params.add("params", JSONObject.toJSONString(slapParam));
|
| | | log.info("请求地址:{},请求参数:{}", SystemProperties.SLAP_LIGHT, JSONObject.toJSONString(slapParam));
|
| | |
|
| | | } else {
|
| | | //调用三方接口,来灯通知容器流动, 传灭灯参数
|
| | |
|
| | | params.add("params", JSONObject.toJSONString(slapParam));
|
| | | log.info("请求地址:{},请求参数:{}", SystemProperties.SLAP_LIGHT, JSONObject.toJSONString(slapParam));
|
| | | }
|
| | |
|
| | | 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());
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 判断当前任务下,订单是否已完成拣货
|
| | | *
|
| | | * @param orderNo
|
| | | * @param taskNo
|
| | | * @return
|
| | | */
|
| | | public synchronized boolean checked(String orderNo, String taskNo) {
|
| | | if (Objects.isNull(orderNo)) {
|
| | | throw new CoolException("订单编码不能为空!!");
|
| | | }
|
| | | if (Objects.isNull(taskNo)) {
|
| | | throw new CoolException("任务编码不能为空!!");
|
| | | }
|
| | |
|
| | | List<TaskDetl> taskDetls = taskDetlService.list(new LambdaQueryWrapper<TaskDetl>().eq(TaskDetl::getTaskNo, taskNo));
|
| | | if (taskDetls.isEmpty()) {
|
| | | throw new CoolException("订单明细不存在!!");
|
| | | }
|
| | |
|
| | | List<Long> detlIds = taskDetls.stream().map(TaskDetl::getId).collect(Collectors.toList());
|
| | |
|
| | | double taskNum = taskDetls.stream().mapToDouble(TaskDetl::getAnfme).sum();
|
| | |
|
| | | List<WaveSeed> seeds = waveSeedService.list(new LambdaQueryWrapper<WaveSeed>().in(WaveSeed::getTaskDetlId, detlIds));
|
| | | if (seeds.isEmpty()) {
|
| | | throw new CoolException("播种信息不存在!!!");
|
| | | }
|
| | | double seedNum = seeds.stream().mapToDouble(WaveSeed::getWorkQty).sum();
|
| | | //判断任务需求总量是否等播种总数量
|
| | | if (taskNum == seedNum) {
|
| | | return true;
|
| | | } else {
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | }
|