1
1 天以前 e0921e578658cc5181bcb9ff76f61ba47e6f0d76
rsf-open-api/src/main/java/com/vincent/rsf/openApi/service/impl/WmsRcsServiceImpl.java
@@ -11,6 +11,7 @@
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.openApi.config.PlatformProperties;
import com.vincent.rsf.openApi.entity.Loc;
import com.vincent.rsf.openApi.entity.constant.WcsConstant;
import com.vincent.rsf.openApi.entity.constant.WmsConstant;
import com.vincent.rsf.openApi.entity.dto.CommonResponse;
import com.vincent.rsf.openApi.entity.constant.RcsConstant;
@@ -46,6 +47,9 @@
    private PlatformProperties.WmsApi wmsApi;
    @Autowired
    private PlatformProperties.WcsApi wcsApi;
    @Autowired
    private RestTemplate restTemplate;
@@ -60,15 +64,52 @@
    public CommonResponse pubTasks(RcsPubTaskParams params)  {
        /**RCS基础配置链接*/
        String rcsUrl =  rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.pubTask;
        log.info("任务下发,请求地址: {}, 请求参数: {}", rcsUrl , JSONObject.toJSONString(params));
        log.info("RCS任务下发,请求地址: {}, 请求参数: {}", rcsUrl , JSONObject.toJSONString(params));
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json");
        headers.add("api-version", "v2.0");
        HttpEntity httpEntity = new HttpEntity(params, headers);
        ResponseEntity<String> exchange = restTemplate.exchange(rcsUrl, HttpMethod.POST, httpEntity, String.class);
        log.info("任务下发后,响应结果: {}", exchange);
        log.info("RCS任务下发后,响应结果: {}", exchange);
        if (Objects.isNull(exchange.getBody())) {
            throw new CoolException("任务下发失败!!");
            throw new CoolException("RCS任务下发失败!!");
        } else {
            ObjectMapper objectMapper = new ObjectMapper();
            objectMapper.coercionConfigDefaults()
                    .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty);
            try {
                CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class);
                if (result.getCode() == 200) {
                    return result;
                } else {
                    return result;
                }
            } catch (JsonProcessingException e) {
                throw new CoolException(e.getMessage());
            }
        }
    }
    /**
     * @author Munch D. Luffy
     * @date 2026/01/19
     * @description: WCS任务下发
     * @version 1.0
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public CommonResponse pubTasksWcs(RcsPubTaskParams params)  {
        /**WCS基础配置链接*/
        String rcsUrl =  wcsApi.getHost() + ":" + wcsApi.getPort() + WcsConstant.pubTask;
        log.info("WCS任务下发,请求地址: {}, 请求参数: {}", rcsUrl , JSONObject.toJSONString(params));
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json");
        headers.add("api-version", "v2.0");
        HttpEntity httpEntity = new HttpEntity(params, headers);
        ResponseEntity<String> exchange = restTemplate.exchange(rcsUrl, HttpMethod.POST, httpEntity, String.class);
        log.info("WCS任务下发后,响应结果: {}", exchange);
        if (Objects.isNull(exchange.getBody())) {
            throw new CoolException("WCS任务下发失败!!");
        } else {
            ObjectMapper objectMapper = new ObjectMapper();
            objectMapper.coercionConfigDefaults()