skyouc
2025-06-20 276fbf9d2e719a67df9e3ec691d384854121252a
zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/services/Impl/WcsApiServiceImpl.java
@@ -4,10 +4,6 @@
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.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.cfg.CoercionAction;
import com.fasterxml.jackson.databind.cfg.CoercionInputShape;
import com.zy.asrs.framework.common.R;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wms.apis.wcs.entity.domain.SystemProperties;
@@ -23,8 +19,6 @@
import com.zy.asrs.wms.asrs.service.*;
import io.jsonwebtoken.lang.Collections;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@@ -37,7 +31,6 @@
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@@ -281,14 +274,12 @@
     * @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("容器码任务错误!!");
    @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("容器码任务不存在!!");
        }
        tasks.forEach(task -> {
            try {
                ConveyorStarParam conveyorStarParam = new ConveyorStarParam();
                conveyorStarParam.setSlotCode(task.getOriginSite())
@@ -307,11 +298,6 @@
                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);
//                HttpHeaders headers = new HttpHeaders();
//                headers.add("Content-Type", "application/json");
//                HttpEntity httpEntity = new HttpEntity<>(params, headers);
//                // 请求
//                ResponseEntity<String> exchange = restTemplate.exchange(HttpEssUtils.CONVEYOR_START, HttpMethod.POST, httpEntity, String.class);
                log.info("下发流动通知 返回结果:{}", exchange);
                if (exchange.getBody() == null) {
                    throw new CoolException("下发流动通知失败!!");
@@ -322,7 +308,6 @@
                        if (task.getTaskType() == 103 || task.getTaskType() == 107) {
                            //更新库存信息,修改任务状态为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())
@@ -334,9 +319,8 @@
                    }
                }
            } catch (Exception ex) {
                log.error(ex.getMessage());
            log.error("UNK",  ex);
            }
        });
        return R.ok();
    }
@@ -355,10 +339,11 @@
     * 拍灯拣料逻辑,详细说明见接口调用说明
     *
     * @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();
@@ -370,19 +355,17 @@
        //* 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("当前订单明细不存在!!");
            }
@@ -410,36 +393,22 @@
                    }
                }
            }
            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("任务不存在!!");
            }
        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();
    }
    /**