| | |
| | | private WorkService workService; |
| | | @Autowired |
| | | private BasCrnpService basCrnpService; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | stationParams.add(stationParam); |
| | | } |
| | | } |
| | | String requestJson = JSON.toJSONString(stationParams); |
| | | String response = ""; |
| | | boolean pushOk = false; |
| | | String pushUrl = buildMesStationRequestUrl(); |
| | | try { |
| | | //获取Cookie值 |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | |
| | | .setHeaders(headers) |
| | | .setUri(mesUrl) |
| | | .setPath(stationAddress) |
| | | .setJson(JSON.toJSONString(stationParams)) |
| | | .setJson(requestJson) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonResponse = JSON.parseObject(response); |
| | | if (jsonResponse.getInteger("code") == 200) { |
| | | |
| | | if (jsonResponse != null && Integer.valueOf(200).equals(jsonResponse.getInteger("code"))) { |
| | | pushOk = true; |
| | | } else { |
| | | return R.error(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | apiLogService.save( |
| | | "推ERP-站点同步", |
| | | pushUrl, |
| | | null, |
| | | "127.0.0.1", |
| | | requestJson, |
| | | response, |
| | | pushOk, |
| | | "站点同步推对方" |
| | | ); |
| | | } catch (Exception logEx) { |
| | | log.error("save station sync api log failed", logEx); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | private String buildMesStationRequestUrl() { |
| | | if (Cools.isEmpty(mesUrl)) { |
| | | return stationAddress; |
| | | } |
| | | if (stationAddress == null) { |
| | | return mesUrl; |
| | | } |
| | | if (mesUrl.endsWith("/") && stationAddress.startsWith("/")) { |
| | | return mesUrl + stationAddress.substring(1); |
| | | } |
| | | if (!mesUrl.endsWith("/") && !stationAddress.startsWith("/")) { |
| | | return mesUrl + "/" + stationAddress; |
| | | } |
| | | return mesUrl + stationAddress; |
| | | } |
| | | |
| | | @Override |
| | | public R mesToComb(MesToCombParam param) { |
| | | if (Cools.isEmpty(param.getPalletId())) { |