skyouc
2 天以前 1a65da0a6c765b07527082272c8d1afc5119a3fa
rsf-open-api/src/main/java/com/vincent/rsf/openApi/service/impl/WmsRcsServiceImpl.java
@@ -11,9 +11,11 @@
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.WmsConstant;
import com.vincent.rsf.openApi.entity.dto.CommonResponse;
import com.vincent.rsf.openApi.entity.constant.RcsConstant;
import com.vincent.rsf.openApi.entity.dto.SyncLocsDto;
import com.vincent.rsf.openApi.entity.params.ExMsgCallbackParams;
import com.vincent.rsf.openApi.entity.params.RcsPubTaskParams;
import com.vincent.rsf.openApi.entity.params.SyncRcsLocsParam;
import com.vincent.rsf.openApi.mapper.LocMapper;
@@ -102,10 +104,33 @@
     * @version 1.0
     */
    @Override
    public R callBackEvent(Map<String, Object> params) {
        String rcsUrl =  wmsApi.getHost() + ":" + wmsApi.getPort() + RcsConstant.pubTask;
        return R.ok();
    public R callBackEvent(ExMsgCallbackParams params) {
        String callUrl =  wmsApi.getHost() + ":" + wmsApi.getPort() + WmsConstant.callBack;
        /**WMS基础配置链接*/
        log.info("任务执行状态上报,请求地址: {}, 请求参数: {}", callUrl , 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(callUrl, HttpMethod.POST, httpEntity, String.class);
        log.info("任务执行状态上报,响应结果: {}", exchange);
        if (Objects.isNull(exchange.getBody())) {
            throw new CoolException("任务执行状态上报失败!!");
        } 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 R.ok();
                } else {
                    throw new CoolException("任务执行状态上报失败!!");
                }
            } catch (JsonProcessingException e) {
                throw new CoolException(e.getMessage());
            }
        }
    }
    /**