|  |  |  | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<OpenOrderPakoutParam> paramList = new ArrayList<>(); | 
|---|
|  |  |  | OpenOrderPakoutParam param = new OpenOrderPakoutParam(); | 
|---|
|  |  |  | paramList.add(param); | 
|---|
|  |  |  | //        paramList.add(param); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<OrderDetl> orderDetlList = orderDetlService.selectByOrderId(order.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | param.setcCusName(order.getCstmrName()); | 
|---|
|  |  |  | param.setcAccount(order.getNumber()); | 
|---|
|  |  |  | param.setcMemo(order.getMemo()); | 
|---|
|  |  |  | param.setType(order.getDocType$()); | 
|---|
|  |  |  | param.setdDate(Utils.getDateStr(order.getCreateTime())); | 
|---|
|  |  |  | param.setType(Cools.isEmpty(order.getDocType$()) ? "" : order.getDocType$()); | 
|---|
|  |  |  | param.setdDate(Utils.getDateStr(new Date())); | 
|---|
|  |  |  | param.setAllocation(order.getItemName()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<OpenOrderPakoutParam.Body> bodyList = new ArrayList<>(); | 
|---|
|  |  |  | param.setaDDBody(bodyList); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for(OrderDetl orderDetl : orderDetlList){ | 
|---|
|  |  |  | for (OrderDetl orderDetl : orderDetlList) { | 
|---|
|  |  |  | OpenOrderPakoutParam.Body body = new OpenOrderPakoutParam.Body(); | 
|---|
|  |  |  | body.setiQuantity(orderDetl.getQty()); | 
|---|
|  |  |  | body.setcInvCode(orderDetl.getMatnr()); | 
|---|
|  |  |  | 
|---|
|  |  |  | bodyList.add(body); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | doHttpRequest(paramList, "上报ERP出库单据", url, orderReportPath, null, "127.0.0.1"); | 
|---|
|  |  |  | doHttpRequest(param, "上报ERP出库单据", url, orderReportPath, null, "127.0.0.1"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderService.updateSettle(order.getId(),6L,0L); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderService.updateSettle(order.getId(), 6L, 0L); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private int doHttpRequest(Object requestParam, String namespace, String url, String path, String appkey, String ip){ | 
|---|
|  |  |  | private int doHttpRequest(Object requestParam, String namespace, String url, String path, String appkey, String ip) { | 
|---|
|  |  |  | String response = ""; | 
|---|
|  |  |  | boolean success = false; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | log.info(JSONObject.toJSONString(requestParam)); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | response = new HttpHandler.Builder() | 
|---|
|  |  |  | .setUri(url) | 
|---|
|  |  |  | 
|---|
|  |  |  | .setJson(JSONObject.toJSONString(requestParam)) | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  | log.info("上报ERP出库单据请求返回报文:{}", response); | 
|---|
|  |  |  | JSONObject jsonObject = JSON.parseObject(response); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(Cools.isEmpty(jsonObject.get("errCode"))){ | 
|---|
|  |  |  | throw new CoolException(jsonObject.get("Message").toString()); | 
|---|
|  |  |  | if (Cools.isEmpty(jsonObject.get("ErrorCode"))) { | 
|---|
|  |  |  | throw new CoolException(jsonObject.get("ErrorMsg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int code = (int) jsonObject.get("errCode"); | 
|---|
|  |  |  | if(code != 0){ | 
|---|
|  |  |  | throw new CoolException(jsonObject.get("errMsg").toString()); | 
|---|
|  |  |  | int code = Integer.parseInt(jsonObject.get("ErrorCode").toString()); | 
|---|
|  |  |  | if (code == 0) { | 
|---|
|  |  |  | throw new CoolException(jsonObject.get("ErrorMsg").toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | success = true; | 
|---|
|  |  |  | return code; | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error(e.getMessage()); | 
|---|
|  |  |  | throw new CoolException("调用接口响应错误"); | 
|---|
|  |  |  | }finally { | 
|---|
|  |  |  | } finally { | 
|---|
|  |  |  | apiLogService.save( | 
|---|
|  |  |  | namespace, | 
|---|
|  |  |  | url + path, | 
|---|