| | |
| | | // } |
| | | Date now = new Date(); |
| | | //条件拼接 |
| | | JSONObject jsonObjectFBillTypeID = new JSONObject(); |
| | | JSONObject jsonObjectFPickerId = new JSONObject(); |
| | | if (kingDeeUtilType.pakIn==1){ |
| | | jsonObjectFBillTypeID.put("FNUMBER","TLD01_SYS"); |
| | | }else { |
| | | jsonObjectFBillTypeID.put("FNUMBER","TLD01_SYS"); |
| | | jsonObjectFPickerId.put("FStaffNumber","X0103_GLGW074_1"); |
| | | JSONObject jsonObject=new JSONObject(); |
| | | jsonObject.put("FormId",kingDeeUtilType.correspondingFormId); |
| | | |
| | | JSONObject model=new JSONObject(); |
| | | model.put("fid",order.getPostFeeType()); |
| | | |
| | | JSONArray fEntitys = new JSONArray(); |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | JSONObject fEntity = new JSONObject(); |
| | | fEntity.put("FEntryID",orderDetl.getBeBatch()); |
| | | //完成数量-已上报数量 |
| | | if(orderDetl.getQty().equals(0.0)){ |
| | | fEntity.put(kingDeeUtilType.anfme, orderDetl.getQty()); |
| | | }else{ |
| | | fEntity.put(kingDeeUtilType.anfme, orderDetl.getQty()-orderDetl.getPrice()); // 将"FQty"放到最后 |
| | | } |
| | | fEntitys.add(fEntity); |
| | | } |
| | | |
| | | JSONObject jsonObjectFStockOrgId = new JSONObject(); |
| | | jsonObjectFStockOrgId.put("FNUMBER","100"); |
| | | |
| | | JSONObject jsonObjectFOwnerIdHead = new JSONObject(); |
| | | jsonObjectFOwnerIdHead.put("FNUMBER","100"); |
| | | |
| | | JSONObject jsonObjectFDEPTID = new JSONObject(); |
| | | jsonObjectFDEPTID.put("FNUMBER","CX"); |
| | | |
| | | List<JSONObject> jsonObjects = new ArrayList<>(); |
| | | |
| | | for (OrderDetl orderDetl:orderDetls){ |
| | | JSONObject jsonObjectFMATERIALID = new JSONObject(); |
| | | jsonObjectFMATERIALID.put("FNUMBER",orderDetl.getMatnr()); |
| | | |
| | | JSONObject jsonObjectFSTOCKID = new JSONObject(); |
| | | jsonObjectFSTOCKID.put("FNUMBER","CK001"); |
| | | |
| | | JSONObject jsonObjectFLOT = new JSONObject(); |
| | | jsonObjectFLOT.put("FNUMBER",orderDetl.getBatch()); |
| | | |
| | | // 使用LinkedHashMap来保持插入顺序 |
| | | Map<String, Object> orderedMap = new LinkedHashMap<>(); |
| | | |
| | | // 按照期望的顺序添加键值对 |
| | | orderedMap.put("FMATERIALID", jsonObjectFMATERIALID); |
| | | orderedMap.put("FSTOCKID", jsonObjectFSTOCKID); |
| | | orderedMap.put("FLOT", jsonObjectFLOT); |
| | | orderedMap.put("FQty", orderDetl.getQty()); // 将"FQty"放到最后 |
| | | |
| | | JSONObject jsonObjectEnd = new JSONObject(orderedMap); |
| | | |
| | | jsonObjects.add(jsonObjectEnd); |
| | | } |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("FBillTypeID",jsonObjectFBillTypeID); |
| | | if (kingDeeUtilType.pakIn==0){ |
| | | jsonObject.put("FPickerId",jsonObjectFPickerId); |
| | | } |
| | | jsonObject.put("FDate",DateUtils.convert(now, DateUtils.yyyyMMdd_F)); |
| | | jsonObject.put("FStockOrgId",jsonObjectFStockOrgId); |
| | | jsonObject.put("FOwnerTypeIdHead","BD_OwnerOrg"); |
| | | jsonObject.put("FOwnerIdHead",jsonObjectFOwnerIdHead); |
| | | jsonObject.put("FDEPTID",jsonObjectFDEPTID); |
| | | jsonObject.put("FEntity",jsonObjects); |
| | | |
| | | JSONObject jsonObjectModel = new JSONObject(); |
| | | jsonObjectModel.put("Model",jsonObject); |
| | | |
| | | JSONObject jsonObject1 = new JSONObject(); |
| | | jsonObject1.put("data", jsonObjectModel); |
| | | jsonObject1.put("FormId",kingDeeUtilType.correspondingFormId); |
| | | String add = jsonObject1.toJSONString(); |
| | | model.put("FEntity",fEntitys); |
| | | JSONObject data= new JSONObject(); |
| | | data.put("Model",model); |
| | | jsonObject.put("data",data); |
| | | String add = jsonObject.toJSONString(); |
| | | //上报 |
| | | String response = ""; |
| | | boolean success = false; |
| | |
| | | .setHttps(true) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject data = JSON.parseObject(response); |
| | | // JSONObject data = JSON.parseObject(response); |
| | | Object IsSuccess = findValueByKey(JSON.parseObject(response), "IsSuccess"); |
| | | String bool1=IsSuccess.toString(); |
| | | boolean bool = false; |
| | | //保存完成原订单5转6 6.保存完成 |
| | | //保存完成原订单2转3 3.保存完成 |
| | | if(bool1.equals("true")){ |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | JsonNode rootNode = objectMapper.readTree(response); |
| | | bool = rootNode.get("Result").get("ResponseStatus").get("IsSuccess").asBoolean(); |
| | | log.info("保存bool:"+bool); |
| | | //提交完成原订单5转6 6.上报完成 |
| | | //提交完成原订单2转3 3.上报完成 |
| | | if(bool){ |
| | | success = true; |
| | | order.setSettle(6L); |
| | | order.setMemo("3"); |
| | | order.setUpdateTime(new Date()); |
| | | orderService.update(order,new EntityWrapper<Order>().eq("order_no",order.getOrderNo())); |
| | | |
| | | for(OrderDetl orderDetl:orderDetls){ |
| | | orderDetl.setPrice(orderDetl.getQty()); |
| | | orderDetl.setUpdateTime(new Date()); |
| | | if(Cools.isEmpty(orderDetl.getBatch())){ |
| | | orderDetlService.update(orderDetl,new EntityWrapper<OrderDetl>() |
| | | .eq("order_no",order.getOrderNo()) |
| | | .eq("matnr",orderDetl.getMatnr())); |
| | | }else{ |
| | | orderDetlService.update(orderDetl,new EntityWrapper<OrderDetl>() |
| | | .eq("order_no",order.getOrderNo()) |
| | | .eq("matnr",orderDetl.getMatnr()) |
| | | .eq("batch",orderDetl.getBatch())); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "保存", |
| | | "3.保存", |
| | | URL+ outaddressSave, |
| | | null, |
| | | "127.0.0.1", |