|
@@ -106,26 +106,31 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
|
|
|
+
|
|
Date submitDate = saleInterfaceSync.getRequestedDeliveryDate();
|
|
Date submitDate = saleInterfaceSync.getRequestedDeliveryDate();
|
|
String date = DateUtils.date2Str(submitDate,new SimpleDateFormat("yyyy-MM-dd"));
|
|
String date = DateUtils.date2Str(submitDate,new SimpleDateFormat("yyyy-MM-dd"));
|
|
JsonNode jsonNode = HttpUtils.getDateListByUrl(null,date);
|
|
JsonNode jsonNode = HttpUtils.getDateListByUrl(null,date);
|
|
|
|
+
|
|
|
|
+
|
|
String content = jsonNode.get("content").toPrettyString();
|
|
String content = jsonNode.get("content").toPrettyString();
|
|
|
|
|
|
- String numberOfElements = jsonNode.get("numberOfElements").toPrettyString();
|
|
|
|
- String totalElements = jsonNode.get("totalElements").toPrettyString();
|
|
|
|
- String totalPages = jsonNode.get("totalPages").toPrettyString();
|
|
|
|
|
|
+// String numberOfElements = jsonNode.get("numberOfElements").toPrettyString();
|
|
|
|
+// String totalElements = jsonNode.get("totalElements").toPrettyString();
|
|
|
|
+// String totalPages = jsonNode.get("totalPages").toPrettyString();
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
- Map<String, String> aa = new HashMap<>();
|
|
|
|
- aa.put("id", "7781d549-2c06-4c95-8bf8-05b31a4b2f8a");
|
|
|
|
|
|
+// Map<String, String> aa = new HashMap<>();
|
|
|
|
+// aa.put("id", "7781d549-2c06-4c95-8bf8-05b31a4b2f8a");
|
|
// List<Map<String, String>> list =new ArrayList<>();
|
|
// List<Map<String, String>> list =new ArrayList<>();
|
|
// list.add(aa);
|
|
// list.add(aa);
|
|
List<Map<String, String>> list = mapper.readValue(content, new TypeReference<List<Map<String, String>>>() {
|
|
List<Map<String, String>> list = mapper.readValue(content, new TypeReference<List<Map<String, String>>>() {
|
|
});
|
|
});
|
|
- if (list.size() == 0) {
|
|
|
|
- list.add(aa);
|
|
|
|
- }
|
|
|
|
|
|
+// if (list.size() == 0) {
|
|
|
|
+// list.add(aa);
|
|
|
|
+// }
|
|
|
|
+ int a = 0;
|
|
for (Map<String, String> m : list) {
|
|
for (Map<String, String> m : list) {
|
|
-
|
|
|
|
|
|
+ a++;
|
|
|
|
+ System.out.println("===============aaaaaaaa=="+a);
|
|
String id = m.get("id");
|
|
String id = m.get("id");
|
|
SaleInterfaceSync headEntry = this.getById(id);
|
|
SaleInterfaceSync headEntry = this.getById(id);
|
|
if (headEntry != null) {
|
|
if (headEntry != null) {
|
|
@@ -178,13 +183,15 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
|
|
|
|
|
|
String status = jsonNodeAll.get("status") == null ? "" : jsonNodeAll.get("status").asText();
|
|
String status = jsonNodeAll.get("status") == null ? "" : jsonNodeAll.get("status").asText();
|
|
String exported = jsonNodeAll.get("exported") == null ? "" : jsonNodeAll.get("exported").asText();
|
|
String exported = jsonNodeAll.get("exported") == null ? "" : jsonNodeAll.get("exported").asText();
|
|
|
|
+ List<SaleInterfaceItem> saleInterfaceItemList = new ArrayList<>();
|
|
|
|
+ // 3. 访问数组
|
|
|
|
+ JsonNode lineItems = jsonNodeAll.path("lineItems");
|
|
|
|
+ int b=0;
|
|
|
|
+ for (JsonNode line : lineItems) {
|
|
|
|
|
|
- String lineItems = jsonNodeAll.get("lineItems").toPrettyString();
|
|
|
|
- List<Map<String, Object>> lineItemsMap = mapper.readValue(lineItems, new TypeReference<List<Map<String, Object>>>() {
|
|
|
|
- });
|
|
|
|
|
|
|
|
- List<SaleInterfaceItem> saleInterfaceItemList = new ArrayList<>();
|
|
|
|
- for (Map<String, Object> line : lineItemsMap) {
|
|
|
|
|
|
+ b++;
|
|
|
|
+ System.out.println("===============bbbbbbbbb======="+b);
|
|
|
|
|
|
SaleInterfaceItem item = new SaleInterfaceItem();
|
|
SaleInterfaceItem item = new SaleInterfaceItem();
|
|
|
|
|
|
@@ -195,34 +202,86 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
|
|
// String unitPrice = line.get("unitPrice");
|
|
// String unitPrice = line.get("unitPrice");
|
|
String commentLine = line.get("comment") == null ? "" : line.get("comment").toString();
|
|
String commentLine = line.get("comment") == null ? "" : line.get("comment").toString();
|
|
|
|
|
|
- String partIdentification = line.get("partIdentification") == null ? "" : line.get("partIdentification").toString();
|
|
|
|
- String jsonStr = partIdentification.replace("=", "\":\"")
|
|
|
|
- .replace(", ", "\", \"")
|
|
|
|
- .replace("[{", "[{\"")
|
|
|
|
- .replace("}]", "\"}]");
|
|
|
|
- if(StringUtils.isNotBlank(jsonStr)){
|
|
|
|
-
|
|
|
|
- JsonNode rootNode = mapper.readTree(jsonStr);
|
|
|
|
- if(rootNode !=null && rootNode.size() > 0){
|
|
|
|
-
|
|
|
|
- String partCode = rootNode.get(0).path("partCode").asText();
|
|
|
|
|
|
+ // 4. 访问数组中的嵌套数组
|
|
|
|
+ JsonNode partIdentifications = line.path("partIdentification");
|
|
|
|
+ for (JsonNode part : partIdentifications) {
|
|
|
|
+ String partType = part.path("partType").asText();
|
|
|
|
+ String partCode = part.path("partCode").asText();
|
|
|
|
|
|
- item.setSupplierPartNumber(partCode);
|
|
|
|
- }
|
|
|
|
|
|
+ item.setSupplierPartNumber(partCode);
|
|
}
|
|
}
|
|
|
|
|
|
item.setHeadId(id);
|
|
item.setHeadId(id);
|
|
|
|
|
|
- item.setContent(line.toString());
|
|
|
|
|
|
+// item.setContent(line.toString());
|
|
item.setNumber(Integer.valueOf(number));
|
|
item.setNumber(Integer.valueOf(number));
|
|
|
|
+ if(StringUtils.isNotBlank(description)){
|
|
|
|
+
|
|
|
|
+ description = description.substring(1, description.length() - 1);
|
|
|
|
+ }
|
|
item.setDescription(description);
|
|
item.setDescription(description);
|
|
item.setQuantity(quantity);
|
|
item.setQuantity(quantity);
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isNotBlank(unitOfMeasure)){
|
|
|
|
+
|
|
|
|
+ unitOfMeasure = unitOfMeasure.substring(1, unitOfMeasure.length() - 1);
|
|
|
|
+ }
|
|
item.setUnitOfMeasure(unitOfMeasure);
|
|
item.setUnitOfMeasure(unitOfMeasure);
|
|
// item.setUnitPrice();
|
|
// item.setUnitPrice();
|
|
|
|
+
|
|
|
|
+ if(StringUtils.isNotBlank(commentLine)){
|
|
|
|
+
|
|
|
|
+ commentLine = commentLine.substring(1, commentLine.length() - 1);
|
|
|
|
+ }
|
|
item.setComment(commentLine);
|
|
item.setComment(commentLine);
|
|
saleInterfaceItemList.add(item);
|
|
saleInterfaceItemList.add(item);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//
|
|
|
|
+// String lineItems = jsonNodeAll.get("lineItems").toPrettyString();
|
|
|
|
+// List<Map<String, Object>> lineItemsMap = mapper.readValue(lineItems, new TypeReference<List<Map<String, Object>>>() {
|
|
|
|
+// });
|
|
|
|
+//
|
|
|
|
+// List<SaleInterfaceItem> saleInterfaceItemList = new ArrayList<>();
|
|
|
|
+// for (Map<String, Object> line : lineItemsMap) {
|
|
|
|
+//
|
|
|
|
+// SaleInterfaceItem item = new SaleInterfaceItem();
|
|
|
|
+//
|
|
|
|
+// String number = line.get("number") == null ? "" : line.get("number").toString();
|
|
|
|
+// String description = line.get("description") == null ? "" : line.get("description").toString();
|
|
|
|
+// String quantity = line.get("quantity") == null ? "" : line.get("quantity").toString();
|
|
|
|
+// String unitOfMeasure = line.get("unitOfMeasure") == null ? "" : line.get("unitOfMeasure").toString();
|
|
|
|
+//// String unitPrice = line.get("unitPrice");
|
|
|
|
+// String commentLine = line.get("comment") == null ? "" : line.get("comment").toString();
|
|
|
|
+//
|
|
|
|
+// String partIdentification = line.get("partIdentification") == null ? "" : line.get("partIdentification").toString();
|
|
|
|
+// String jsonStr = partIdentification.replaceAll("(\\w+)=", "\"$1\":") // 键名加引号
|
|
|
|
+// .replaceAll("([^\"\\s:,]+)([,}])", "\"$1\"$2") // 值加引号
|
|
|
|
+// .replaceAll(",\\s*\\w+[-\\w]*", ""); // 移除无效字段如ZCS-25M
|
|
|
|
+//
|
|
|
|
+// if(StringUtils.isNotBlank(jsonStr)){
|
|
|
|
+//
|
|
|
|
+// JsonNode rootNode = mapper.readTree(jsonStr);
|
|
|
|
+// if(rootNode !=null && rootNode.size() > 0){
|
|
|
|
+//
|
|
|
|
+// String partCode = rootNode.get(0).path("partCode").asText();
|
|
|
|
+//
|
|
|
|
+// item.setSupplierPartNumber(partCode);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// item.setHeadId(id);
|
|
|
|
+//
|
|
|
|
+// item.setContent(line.toString());
|
|
|
|
+// item.setNumber(Integer.valueOf(number));
|
|
|
|
+// item.setDescription(description);
|
|
|
|
+// item.setQuantity(quantity);
|
|
|
|
+// item.setUnitOfMeasure(unitOfMeasure);
|
|
|
|
+//// item.setUnitPrice();
|
|
|
|
+// item.setComment(commentLine);
|
|
|
|
+// saleInterfaceItemList.add(item);
|
|
|
|
+// }
|
|
|
|
+
|
|
headEntry = new SaleInterfaceSync();
|
|
headEntry = new SaleInterfaceSync();
|
|
|
|
|
|
headEntry.setId(m.get("id"));
|
|
headEntry.setId(m.get("id"));
|
|
@@ -249,7 +308,7 @@ public class SaleInterfaceSyncServiceImpl extends ServiceImpl<SaleInterfaceSyncM
|
|
headEntry.setCreatedDate(Date.from(instant));
|
|
headEntry.setCreatedDate(Date.from(instant));
|
|
}
|
|
}
|
|
|
|
|
|
- headEntry.setContent(jsonNodeAll.toString());
|
|
|
|
|
|
+// headEntry.setContent(jsonNodeAll.toString());
|
|
headEntry.setSubject(subject);
|
|
headEntry.setSubject(subject);
|
|
headEntry.setComment(comment);
|
|
headEntry.setComment(comment);
|
|
headEntry.setTaxStatus(taxStatus);
|
|
headEntry.setTaxStatus(taxStatus);
|