binxie
2023-06-16 da42e2995c00293af89c71fe5ba6e16cbb77e1b3
force-app/main/default/classes/LexArriveGoodsController.cls
@@ -1,14 +1,12 @@
public without sharing class LexArriveGoodsController {
  //初始化
  @AuraEnabled
  public static Results init(String arrType, String eSetId) {
    Results results = new Results();
    results.isNoteStay = LexUtility.getIsNoteStay();
    try {
      ArriveGoodsController arrController = new ArriveGoodsController(
        eSetId,
        arrType
      );
            ArriveGoodsController arrController = new ArriveGoodsController(eSetId, arrType);
      arrController.isLwc = true;
      arrController.init();
      results.arrGoodCon = JSON.serialize(arrController);
@@ -29,20 +27,14 @@
    Results results = new Results();
    try {
      System.debug('arrControllerStr:' + arrControllerStr);
      ArriveGoodsController arrController = (ArriveGoodsController) JSON.deserialize(
        arrControllerStr,
        ArriveGoodsController.class
      );
            ArriveGoodsController arrController = (ArriveGoodsController)JSON.deserialize(arrControllerStr, ArriveGoodsController.class);
      arrController.barcode = barcode;
      arrController.returnError = null;
      arrController.warningList = new List<String>();
      arrController.errorList = new List<String>();
      arrController.SearchPro();
      results.arrGoodCon = JSON.serialize(arrController);
      if (
        arrController.returnError != null &&
        arrController.returnError != ''
      ) {
            if(arrController.returnError != null && arrController.returnError != ''){
        results.result = 'Fail';
        results.errorMsgList = arrController.errorList;
        results.warningMsgList = arrController.warningList;
@@ -52,30 +44,17 @@
        results.saveFLGbln = arrController.saveFLGbln;
        results.returnFLGbln = arrController.ReturnFLGbln;
        results.detailsSummary = changeType1(arrController.detailsSummary);
        results.consumableorderdetailsRecords = changeType1(
          arrController.ConsumableorderdetailsRecords
        );
        results.showGoodsofReturnList = changeType1(
          arrController.ShowGoodsofReturnList
        );
        results.consumableInventory = changeType1(
          arrController.consumableInventory
        );
        results.consumableorderdetailsRecordserror = changeType1(
          arrController.ConsumableorderdetailsRecordserror
        );
                results.consumableorderdetailsRecords = changeType1(arrController.ConsumableorderdetailsRecords);
                results.showGoodsofReturnList = changeType1(arrController.ShowGoodsofReturnList);
                results.consumableInventory = changeType1(arrController.consumableInventory);
                results.consumableorderdetailsRecordserror = changeType1(arrController.ConsumableorderdetailsRecordserror);
        results.errorMsgList = arrController.errorList;
        results.warningMsgList = arrController.warningList;
        results.result = 'Success';
      }
    } catch (Exception e) {
      results.result = 'Fail';
      results.errorMsg =
        e.getLineNumber() +
        '---' +
        e.getMessage() +
        '---' +
        e.getStackTraceString();
            results.errorMsg = e.getLineNumber() + '---' + e.getMessage() + '---' + e.getStackTraceString();
    }
    return results;
  }
@@ -85,19 +64,13 @@
  public static Results arriveGoodsConfim(String arrControllerStr) {
    Results results = new Results();
    try {
      ArriveGoodsController arrController = (ArriveGoodsController) JSON.deserialize(
        arrControllerStr,
        ArriveGoodsController.class
      );
            ArriveGoodsController arrController = (ArriveGoodsController)JSON.deserialize(arrControllerStr, ArriveGoodsController.class);
      arrController.returnError = null;
      arrController.warningList = new List<String>();
      arrController.errorList = new List<String>();
      Pagereference page = arrController.ArriveGoodsConfim();
      results.arrGoodCon = JSON.serialize(arrController);
      if (
        arrController.returnError != null &&
        arrController.returnError != ''
      ) {
            if(arrController.returnError != null && arrController.returnError != ''){
        results.result = 'Fail';
        results.errorMsgList = arrController.errorList;
        results.warningMsgList = arrController.warningList;
@@ -119,30 +92,19 @@
  //登录返品
  @AuraEnabled
  public static Results updateGoodsOfReturn(
    String arrControllerStr,
    String showGoodsofReturnListStr
  ) {
    public static Results updateGoodsOfReturn(String arrControllerStr, String showGoodsofReturnListStr) {
    Results results = new Results();
    try {
      List<ConsumableorderdetailsInfo> showGoodsofReturnList = (List<ConsumableorderdetailsInfo>) JSON.deserialize(
        showGoodsofReturnListStr,
        List<ConsumableorderdetailsInfo>.class
      );
      ArriveGoodsController arrController = (ArriveGoodsController) JSON.deserialize(
        arrControllerStr,
        ArriveGoodsController.class
      );
            List<ConsumableorderdetailsInfo> showGoodsofReturnList = (List<ConsumableorderdetailsInfo>)JSON.deserialize(showGoodsofReturnListStr, List<ConsumableorderdetailsInfo>.class);
            ArriveGoodsController arrController = (ArriveGoodsController)JSON.deserialize(arrControllerStr, ArriveGoodsController.class);
      arrController.ShowGoodsofReturnList = changeType2(showGoodsofReturnList);
      arrController.returnError = null;
      arrController.warningList = new List<String>();
      arrController.errorList = new List<String>();
            StaticParameter.ConsumableOrderTrigger = true; //Add by Li Jun for bypass ConsumableOrderTrigger 20230616
      Pagereference page = arrController.UpdateGoodsOfReturn();
      results.arrGoodCon = JSON.serialize(arrController);
      if (
        arrController.returnError != null &&
        arrController.returnError != ''
      ) {
            if(arrController.returnError != null && arrController.returnError != ''){
        results.result = 'Fail';
        results.errorMsgList = arrController.errorList;
        results.warningMsgList = arrController.warningList;
@@ -165,9 +127,7 @@
    return results;
  }
  public static List<ConsumableorderdetailsInfo> changeType1(
    List<ArriveGoodsController.ConsumableorderdetailsInfo> conList
  ) {
    public static List<ConsumableorderdetailsInfo> changeType1(List<ArriveGoodsController.ConsumableorderdetailsInfo> conList){
    List<ConsumableorderdetailsInfo> conList1 = new List<ConsumableorderdetailsInfo>();
    if (conList != null) {
      for (ArriveGoodsController.ConsumableorderdetailsInfo con : conList) {
@@ -193,9 +153,7 @@
    return conList1;
  }
  public static List<ArriveGoodsController.ConsumableorderdetailsInfo> changeType2(
    List<ConsumableorderdetailsInfo> conList
  ) {
    public static List<ArriveGoodsController.ConsumableorderdetailsInfo> changeType2(List<ConsumableorderdetailsInfo> conList){
    List<ArriveGoodsController.ConsumableorderdetailsInfo> conList1 = new List<ArriveGoodsController.ConsumableorderdetailsInfo>();
    if (conList != null) {
      for (ConsumableorderdetailsInfo con : conList) {
@@ -287,67 +245,9 @@
    public String ReportProductExpirationDate { get; set; }
    public ConsumableorderdetailsInfo() {
    }
    public ConsumableorderdetailsInfo(
      Consumable_order_details2__c e,
      string str
    ) {
      esd = e;
      Prod = e.Consumable_Product__r;
      oldConsumableCount = e.name;
      ErrorReason = str;
      intMark = 1;
      if (e.Report_Product_Expiration__c != null) {
        ReportProductExpirationDate = e.Report_Product_Expiration__c.format();
      }
    }
    public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
      canEdit = false;
      if (e.Box_Piece__c == '盒') {
        e.Rrturn_count__c = 1;
        canEdit = true;
      }
      esd = e;
      Prod = e.Consumable_Product__r;
      oldConsumableCount = e.name;
      if (e.Report_Product_Expiration__c != null) {
        ReportProductExpirationDate = e.Report_Product_Expiration__c.format();
      }
    }
    public ConsumableorderdetailsInfo(Product2__c e, List<String> barinfoL) {
      esd = new Consumable_order_details2__c();
      ProductName = e.Name__c;
      Prod = e;
      barCodeNo = barinfoL[0];
      if (String.isNotBlank(barinfoL[1])) {
        sterilizationlimitDate = Date.valueOf(barinfoL[1]);
      }
      serialNoorLotNo = barinfoL[2];
      tracingCodeNo = barinfoL[3];
      ReturnReason = '';
    }
    public ConsumableorderdetailsInfo(
      Consumable_order_details2__c e,
      List<String> barinfoL
    ) {
      esd = e;
      Prod = e.Consumable_Product__r;
      barCodeNo = barinfoL[0];
      if (String.isNotBlank(barinfoL[1])) {
        sterilizationlimitDate = Date.valueOf(barinfoL[1]);
      }
      serialNoorLotNo = barinfoL[2];
      tracingCodeNo = barinfoL[3];
      if (e.Report_Product_Expiration__c != null) {
        ReportProductExpirationDate = e.Report_Product_Expiration__c.format();
      }
    }
    public ConsumableorderdetailsInfo(Product2__c e) {
      Prod = e;
    }
    // 排序
    public Integer compareTo(Object compareTo) {
      return null;