From de9565270a88b0749d17c1961cd41399c8483c96 Mon Sep 17 00:00:00 2001
From: binxie <137736985@qq.com>
Date: 星期一, 26 六月 2023 17:46:45 +0800
Subject: [PATCH] merge
---
force-app/main/default/classes/CPL003Rest.cls | 95 +++++++++++++++++++++++++++++++----------------
1 files changed, 62 insertions(+), 33 deletions(-)
diff --git a/force-app/main/default/classes/CPL003Rest.cls b/force-app/main/default/classes/CPL003Rest.cls
index 6355680..22dc62f 100644
--- a/force-app/main/default/classes/CPL003Rest.cls
+++ b/force-app/main/default/classes/CPL003Rest.cls
@@ -1,28 +1,27 @@
@RestResource(urlMapping='/CPL003/*')
global with sharing class CPL003Rest {
-
global class GeDatas {
- webservice NFMUtil.Monitoring Monitoring;
- webservice CPL003Rest.GeData[] Inventory;
+ webService NFMUtil.Monitoring Monitoring;
+ webService CPL003Rest.GeData[] Inventory;
}
global class GeData {
- webservice String MaterialNumber; //浜у搧缂栫爜(浜у搧浠g爜)
- webservice String ItemQuantity; //OpenPO鍜屽簱瀛樼殑鎬绘暟閲�
+ webService String MaterialNumber; //浜у搧缂栫爜(浜у搧浠g爜)
+ webService String ItemQuantity; //OpenPO鍜屽簱瀛樼殑鎬绘暟閲�
- webservice String Area; //鍖哄煙(寰呭畾)
+ webService String Area; //鍖哄煙(寰呭畾)
//webservice String other1;
//webservice String other2;
//webservice String other3;
}
- @HttpPost
+ @HttpPost
global static void execute() {
- // 鍙栧緱鎺ュ彛浼犺緭鍐呭
+ // 鍙栧緱鎺ュ彛浼犺緭鍐呭
String strData = RestContext.request.requestBody.toString();
GeDatas ges = (GeDatas) JSON.deserializeStrict(strData, GeDatas.class);
- if (ges == null ) {
+ if (ges == null) {
return;
}
@@ -46,7 +45,6 @@
return;
}
-
@future
global static void executefuture(String rowData_Id) {
main(rowData_Id);
@@ -54,8 +52,29 @@
global static void main(String rowData_Id) {
Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt);
- BatchIF_Log__c rowData = [Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, Log12__c, MessageGroupNumber__c,retry_cnt__c from BatchIF_Log__c where RowDataFlg__c = true and Id = :rowData_Id];
- MDMITMWebService.isRunning = true;
+ BatchIF_Log__c rowData = [
+ SELECT
+ Id,
+ Name,
+ Log__c,
+ ErrorLog__c,
+ Log2__c,
+ Log3__c,
+ Log4__c,
+ Log5__c,
+ Log6__c,
+ Log7__c,
+ Log8__c,
+ Log9__c,
+ Log10__c,
+ Log11__c,
+ Log12__c,
+ MessageGroupNumber__c,
+ retry_cnt__c
+ FROM BatchIF_Log__c
+ WHERE RowDataFlg__c = TRUE AND Id = :rowData_Id
+ ];
+ //MDMITMWebService.isRunning = true; //Commented By Li Jun 20230428
String logstr = rowData.MessageGroupNumber__c + ' start\n';
BatchIF_Log__c iflog = new BatchIF_Log__c();
iflog.Type__c = 'CPL003';
@@ -67,36 +86,39 @@
String rowDataStr = NFMUtil.getRowDataStr(rowData);
//rowDataStr = XMLTools.xml2json(rowDataStr);
List<GeData> itemMasterList = (List<GeData>) JSON.deserialize(rowDataStr, List<GeData>.class);
-
+
if (itemMasterList == null || itemMasterList.size() == 0) {
return;
- }
+ }
Savepoint sp = Database.setSavepoint();
- try{
+ try {
List<String> materialNumberList = new List<String>();
for (GeData GeData : itemMasterList) {
- if (String.isBlank(GeData.MaterialNumber)) continue;
- if (String.isBlank(GeData.ItemQuantity)) continue;
+ if (String.isBlank(GeData.MaterialNumber))
+ continue;
+ if (String.isBlank(GeData.ItemQuantity))
+ continue;
materialNumberList.add(GeData.MaterialNumber);
}
- List<Product2> product2List = [select Id, ProductCode, StorageStatusNo__c
- from Product2
- where ProductCode in :materialNumberList ];
-
- Map<String,Product2> product2Map = new Map<String,Product2>();
+ List<Product2> product2List = [
+ SELECT Id, ProductCode, StorageStatusNo__c
+ FROM Product2
+ WHERE ProductCode IN :materialNumberList
+ ];
+
+ Map<String, Product2> product2Map = new Map<String, Product2>();
for (Product2 product2 : product2List) {
product2Map.put(product2.ProductCode, product2);
}
List<Product2> upsertProList = new List<Product2>();
- Map<String,Product2> prdUpdateMap = new Map<String, Product2>();
+ Map<String, Product2> prdUpdateMap = new Map<String, Product2>();
for (GeData GeData : itemMasterList) {
-
if (String.isBlank(GeData.MaterialNumber)) {
iflog.ErrorLog__c += 'MaterialNumber is required.\n';
continue;
@@ -106,29 +128,36 @@
Product2 product = product2Map.get(GeData.MaterialNumber);
product.StorageStatusNo__c = Double.valueOf(GeData.ItemQuantity);
upsertProList.add(product);
-
} else {
iflog.ErrorLog__c += 'This MaterialNumber [ ' + GeData.MaterialNumber + ' ] is not Exist.\n';
continue;
}
}
- if(upsertProList.size() > 0) upsert upsertProList;
+ if (upsertProList.size() > 0)
+ upsert upsertProList;
logstr += '\nend';
- rowData.retry_cnt__c=0;
- } catch(Exception ex) {
+ rowData.retry_cnt__c = 0;
+ } catch (Exception ex) {
// 銈ㄣ儵銉笺亴鐧虹敓銇椼仧鍫村悎
Database.rollback(sp);
logstr += '\n' + ex.getMessage();
iflog.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + iflog.ErrorLog__c;
- if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0;
- if (rowData.retry_cnt__c < batch_retry_max_cnt){
+ if (rowData.retry_cnt__c == null)
+ rowData.retry_cnt__c = 0;
+ if (rowData.retry_cnt__c < batch_retry_max_cnt) {
rowData.retry_cnt__c++;
LogAutoSendSchedule.assignOneMinute();
}
- if (rowData.retry_cnt__c >= batch_retry_max_cnt){
- rowData.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + rowData.ErrorLog__c+'閿欒娆℃暟宸茬粡瓒呰繃鑷姩鏀朵俊璁惧畾鐨勬渶澶ф鏁帮紝璇锋墜鍔ㄦ敹淇�';
+ if (rowData.retry_cnt__c >= batch_retry_max_cnt) {
+ rowData.ErrorLog__c =
+ ex.getMessage() +
+ '\n' +
+ ex.getStackTraceString() +
+ '\n' +
+ rowData.ErrorLog__c +
+ '閿欒娆℃暟宸茬粡瓒呰繃鑷姩鏀朵俊璁惧畾鐨勬渶澶ф鏁帮紝璇锋墜鍔ㄦ敹淇�';
}
}
@@ -142,4 +171,4 @@
}
update iflog;
}
-}
\ No newline at end of file
+}
--
Gitblit v1.9.1