|  |  | 
 |  |  | package com.vincent.rsf.openApi.service.impl; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSONArray; | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.fasterxml.jackson.core.JsonProcessingException; | 
 |  |  | import com.fasterxml.jackson.databind.ObjectMapper; | 
 |  |  | 
 |  |  | import com.vincent.rsf.openApi.entity.dto.OrderDto; | 
 |  |  | import com.vincent.rsf.openApi.entity.params.ErpMatnrParms; | 
 |  |  | import com.vincent.rsf.openApi.entity.params.ErpOpParams; | 
 |  |  | import com.vincent.rsf.openApi.entity.params.ReportParams; | 
 |  |  | import com.vincent.rsf.openApi.service.WmsErpService; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private PlatformProperties.WmsApi wmsApi; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private PlatformProperties.ErpApi erpApi; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private RestTemplate restTemplate; | 
 |  |  | 
 |  |  |                 if (result.getCode() == 200) { | 
 |  |  |                     JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(result.getData())); | 
 |  |  |                     OrderDto dto = new OrderDto(); | 
 |  |  |                     dto.setOrderNo(object.getString("code")).setAnfme(object.getDouble("anfme")).setType(object.getString("type")).setWkType(object.getString("wkType")).setQty(object.getDouble("qty")).setPoCode(object.getString("poCode")).setExceStatus(object.getShort("exceStatus")).setWorkQty(object.getDouble("workQty")); | 
 |  |  |                     dto.setOrderNo(object.getString("code")) | 
 |  |  |                             .setAnfme(object.getDouble("anfme")) | 
 |  |  |                             .setType(object.getString("type")) | 
 |  |  |                             .setWkType(object.getString("wkType")) | 
 |  |  |                             .setQty(object.getDouble("qty")) | 
 |  |  |                             .setPoCode(object.getString("poCode")) | 
 |  |  |                             .setExceStatus(object.getShort("exceStatus")) | 
 |  |  |                             .setWorkQty(object.getDouble("workQty")); | 
 |  |  |                     result.setData(dto); | 
 |  |  |                     return result; | 
 |  |  |                 } else { | 
 |  |  | 
 |  |  |         } | 
 |  |  |         /**WMS基础配置链接*/ | 
 |  |  |         String wmsUrl = wmsApi.getHost() + ":" + wmsApi.getPort() + WmsConstant.MODIFY_ORDER_DETLS; | 
 |  |  |         log.info("修改订单信息及状态: {}, 请求参数: {}", wmsUrl, JSONObject.toJSONString(params)); | 
 |  |  |         HttpHeaders headers = new HttpHeaders(); | 
 |  |  |         headers.add("Content-Type", "application/json"); | 
 |  |  |         headers.add("api-version", "v2.0"); | 
 |  |  |  | 
 |  |  |         List<Map<String, Object>> maps = new ArrayList<>(); | 
 |  |  |         Map<String, Object> mapParams = new HashMap<>(); | 
 |  |  |         mapParams.put("orderNo", Arrays.asList(params.getOrderNo())); | 
 |  |  |         mapParams.put("orderNo", params.getOrderNo()); | 
 |  |  |         mapParams.put("anfme", params.getAnfme()); | 
 |  |  |         mapParams.put("type", params.getType()); | 
 |  |  |         mapParams.put("wkType", params.getWkType()); | 
 |  |  |         mapParams.put("exceStatus", params.getExceStatus()); | 
 |  |  |         mapParams.put("orderItems", params.getOrderItems()); | 
 |  |  |         maps.add(mapParams); | 
 |  |  |  | 
 |  |  |         HttpEntity httpEntity = new HttpEntity(maps, headers); | 
 |  |  |         log.info("修改订单信息及状态: {}, 请求参数: {}", wmsUrl, JSONArray.toJSONString(maps)); | 
 |  |  |         HttpEntity<List<Map<String, Object>>> httpEntity = new HttpEntity<>(maps, headers); | 
 |  |  |         ResponseEntity<String> exchange = restTemplate.exchange(wmsUrl, HttpMethod.POST, httpEntity, String.class); | 
 |  |  |         log.info("订单修改返回结果: {}", exchange); | 
 |  |  |         if (Objects.isNull(exchange.getBody())) { | 
 |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 删除单据 | 
 |  |  |      * | 
 |  |  |      * @param params | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 物料信息修改 | 
 |  |  |      * | 
 |  |  |      * @param params | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public CommonResponse syncMatnrs(ErpMatnrParms params) { | 
 |  |  |         if (Objects.isNull(params.getMatnr()) ) { | 
 |  |  |         if (Objects.isNull(params.getMatnr())) { | 
 |  |  |             throw new CoolException("物料编码不能为空!!"); | 
 |  |  |         } | 
 |  |  |         if (Objects.isNull(params.getMaktx())) { | 
 |  |  | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * @author Ryan | 
 |  |  |      * @date 2025/10/27 | 
 |  |  |      * @description: 上报单据状态 | 
 |  |  |      * @version 1.0 | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public CommonResponse reportOrders(ReportParams params) { | 
 |  |  |         if (Objects.isNull(params)) { | 
 |  |  |             throw new CoolException("参数不能为空!!"); | 
 |  |  |         } | 
 |  |  |         /**WMS基础配置链接*/ | 
 |  |  |         String rcsUrl = erpApi.getHost() + ":" + erpApi.getPort() + WmsConstant.REPORT_ORDER_CALLBACK; | 
 |  |  |         HttpHeaders headers = new HttpHeaders(); | 
 |  |  |         headers.add("Content-Type", "application/json"); | 
 |  |  |         headers.add("api-version", "v2.0"); | 
 |  |  |         HttpEntity httpEntity = new HttpEntity(params, headers); | 
 |  |  |         log.info("已完成订单上传:{}, 请求参数: {}", rcsUrl, httpEntity.getBody()); | 
 |  |  |  | 
 |  |  |         ResponseEntity<String> exchange = restTemplate.exchange(rcsUrl, 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 result; | 
 |  |  |                 } else { | 
 |  |  |                     throw new CoolException("上传失败!!"); | 
 |  |  |                 } | 
 |  |  |             } catch (JsonProcessingException e) { | 
 |  |  |                 throw new CoolException(e.getMessage()); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * @author Ryan | 
 |  |  |      * @date 2025/10/27 | 
 |  |  |      * @description: 盘点差异单修改 | 
 |  |  |      * @version 1.0 | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public CommonResponse reportCheck(Map<String, Object> params) { | 
 |  |  |         if (Objects.isNull(params)) { | 
 |  |  |             throw new CoolException("参数不能为空!!"); | 
 |  |  |         } | 
 |  |  |         /**WMS基础配置链接*/ | 
 |  |  |         String rcsUrl = erpApi.getHost() + ":" + erpApi.getPort() + WmsConstant.REPORT_ORDER_CALLBACK; | 
 |  |  |         log.info("物料修改:{}, 请求参数: {}", rcsUrl, JSONObject.toJSONString(params)); | 
 |  |  |         HttpHeaders headers = new HttpHeaders(); | 
 |  |  |         headers.add("Content-Type", "application/json"); | 
 |  |  |         headers.add("api-version", "v2.0"); | 
 |  |  |  | 
 |  |  |         params.put("", ""); | 
 |  |  |         HttpEntity httpEntity = new HttpEntity(params, headers); | 
 |  |  |         ResponseEntity<String> exchange = restTemplate.exchange(rcsUrl, 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 result; | 
 |  |  |                 } else { | 
 |  |  |                     throw new CoolException("修改失败!!"); | 
 |  |  |                 } | 
 |  |  |             } catch (JsonProcessingException e) { | 
 |  |  |                 throw new CoolException(e.getMessage()); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |