| | |
| | | } |
| | | |
| | | /** |
| | | * 触发rsf-open-api上报ERP |
| | | * @return com.vincent.rsf.framework.common.R |
| | | */ |
| | | @Override |
| | | public R triggerErpReport() { |
| | | String rcsUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.REPORT_ORDERS_ERP; |
| | | log.info("触发ERP上报:{}", rcsUrl); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.add("Content-Type", "application/json"); |
| | | headers.add("api-version", "v2.0"); |
| | | |
| | | HttpEntity httpEntity = new HttpEntity(headers); |
| | | try { |
| | | ResponseEntity<String> exchange = restTemplate.exchange(rcsUrl, HttpMethod.POST, httpEntity, String.class); |
| | | log.info("触发ERP上报,返回结果: {}", exchange); |
| | | if (Objects.isNull(exchange.getBody())) { |
| | | return R.ok("无返回结果"); |
| | | } |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | objectMapper.coercionConfigDefaults().setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty); |
| | | CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class); |
| | | if (result.getCode() == 200) { |
| | | return R.ok().add(result.getData()); |
| | | } else { |
| | | return R.ok(result.getMsg()).add(result.getData()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("触发ERP上报失败", e); |
| | | return R.ok("触发ERP上报失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 盘点库存数据修改 |
| | | * @param params |
| | | * @return |