buli
2023-07-14 744f42c5496e656a1f9927740a3b37c0b97a6cba
force-app/main/default/classes/LexSaleOrderController.cls
@@ -2,20 +2,11 @@
  public static boolean isRunning = false;
  public static String barcode { get; set; }
  public static Consumable_order__c coc { get; set; }
  public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords {
    get;
    set;
  }
    public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords { get; set; }
  @AuraEnabled
  public static List<Consumable_order_details2__c> consumableorderdetails2Nobox {
    get;
    set;
  }
    public static List<Consumable_order_details2__c> consumableorderdetails2Nobox { get; set; }
  @AuraEnabled
  public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordserror {
    get;
    set;
  }
    public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordserror { get; set; }
  public static Map<String, String> existIdMap { get; set; }
  public static Map<String, String> errorIdMap { get; set; }
  public static Map<String, String> allMap { get; set; }
@@ -41,11 +32,7 @@
    res.entity = data;
    String UserName = UserInfo.getUserId();
    user useracc = [
      SELECT Accountid, Work_Location__c
      FROM user
      WHERE id = :UserName
    ];
        user useracc = [SELECT Accountid, Work_Location__c FROM user WHERE id = :UserName];
    accountid = useracc.Accountid;
    userWorkLocation = useracc.Work_Location__c;
    Account accountInfo = [SELECT Name FROM account WHERE id = :accountid];
@@ -114,9 +101,7 @@
          WHERE Consumable_ZS_order__c = :ESetId
        ];
        for (Integer j = 0; j < arriveDat.size(); j++) {
          consumableorderdetailsRecords.add(
            new ConsumableorderdetailsInfo(arriveDat[j])
          );
                    consumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(arriveDat[j]));
        }
      }
@@ -132,33 +117,16 @@
          Unitprice_To_agency__c,
          isOutPattern__c
        FROM Consumable_orderdetails__c
        WHERE
          Consumable_order__c = :ESetId
          AND Order_Owner_WorkLocal__c = :userWorkLocation
                WHERE Consumable_order__c = :ESetId AND Order_Owner_WorkLocal__c = :userWorkLocation
      ];
      for (Integer i = 0; i < orderdetails.size(); i++) {
        orderpieceorboxMap.put(
          orderdetails[i].Product_Pattern__c,
          orderdetails[i].Box_Piece__c
        );
        if (
          orderdetails[i].Unitprice_To_agency__c != null &&
          orderdetails[i].Unitprice_To_agency__c != 0
        ) {
          orderagencypriceMap.put(
            orderdetails[i].Product_Pattern__c,
            orderdetails[i].Unitprice_To_agency__c
          );
                orderpieceorboxMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Box_Piece__c);
                if (orderdetails[i].Unitprice_To_agency__c != null && orderdetails[i].Unitprice_To_agency__c != 0) {
                    orderagencypriceMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Unitprice_To_agency__c);
        }
        orderpriceMap.put(
          orderdetails[i].Product_Pattern__c,
          orderdetails[i].Delivery_List_RMB__c
        );
        orderdetCountMap.put(
          orderdetails[i].Product_Pattern__c,
          orderdetails[i].Shipment_Count__c
        );
                orderpriceMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Delivery_List_RMB__c);
                orderdetCountMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Shipment_Count__c);
      }
      List<hospitalprice__c> hlist = [
        SELECT id
@@ -172,10 +140,7 @@
      }
    }
    data.put('consumableorderdetailsRecords', consumableorderdetailsRecords);
    data.put(
      'consumableorderdetailsRecordserror',
      consumableorderdetailsRecordserror
    );
        data.put('consumableorderdetailsRecordserror', consumableorderdetailsRecordserror);
    data.put('coc', coc);
    data.put('accountName', accountName);
    data.put('userWorkLocation', userWorkLocation);
@@ -290,17 +255,10 @@
    }
    Map<String, String> proHosMap = new Map<String, String>();
    Map<String, String> proIdMap = new Map<String, String>();
    List<hospitalprice__c> hpList = [
      SELECT id, hospital__c, product__c
      FROM hospitalprice__c
      WHERE account__c = :accountid
    ];
        List<hospitalprice__c> hpList = [SELECT id, hospital__c, product__c FROM hospitalprice__c WHERE account__c = :accountid];
    if (hpList != null && hpList.size() > 0) {
      for (hospitalprice__c hp : hpList) {
        if (
          hp.product__c != null &&
          String.valueof(hp.product__c).length() >= 15
        ) {
                if (hp.product__c != null && String.valueof(hp.product__c).length() >= 15) {
          proIdMap.put(('' + hp.product__c).subString(0, 15) + '是', '');
          if (hp.hospital__c == coc.Order_ForHospital__c) {
            proHosMap.put(('' + hp.product__c).subString(0, 15) + '是', '');
@@ -315,29 +273,18 @@
          newdet2[j].Box_Piece__c != orderdetails[i].Box_Piece__c
        ) {
          String str = '该商品出货单位错误';
          consumableorderdetailsRecordserror.add(
            new ConsumableorderdetailsInfo(newdet2[j], str)
          );
                    consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
          errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
        }
        if (coc.OutPattern__c == true) {
          System.debug(
            'testPattern:' +
              newdet2[j].Product_Pattern__c +
              '---' +
              orderdetails[i].Product_Pattern__c
          );
          if (
            newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c
          ) {
                    System.debug('testPattern:'+newdet2[j].Product_Pattern__c+'---'+orderdetails[i].Product_Pattern__c);
                    if (newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c) {
            //add by rentx 2021-03-22 start
            if (newdet2[j].exchangeOutPattern__c == true) {
              //如果当前经销商下没有维护对应的特价产品 报错
              if (!proIdMap.containsKey(newdet2[j].Product_Pattern__c)) {
                String str = '没有维护该产品的特价医院';
                consumableorderdetailsRecordserror.add(
                  new ConsumableorderdetailsInfo(newdet2[j], str)
                );
                                consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
                errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
              }
            }
@@ -350,9 +297,7 @@
                continue;
              } else {
                String str = '该商品出库医院错误';
                consumableorderdetailsRecordserror.add(
                  new ConsumableorderdetailsInfo(newdet2[j], str)
                );
                                consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
                errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
              }
            }
@@ -393,17 +338,12 @@
    ];
    if (reSet1.size() > 0) {
      for (Integer i = 0; i < reSet1.size(); i++) {
        if (
          errorIdMap.containsKey(reSet1[i].Bar_Code__c) ||
          existIdMap.containsKey(reSet1[i].Bar_Code__c)
        ) {
                if (errorIdMap.containsKey(reSet1[i].Bar_Code__c) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
          // 跳过已经处理的消耗品明细
          continue;
        } else {
          String str = '该产品没有管理编码,无法出库,请与特约经销商管理部人员联系,修正数据';
          consumableorderdetailsRecordserror.add(
            new ConsumableorderdetailsInfo(reSet1[i], str)
          );
                    consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
          errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
        }
      }
@@ -438,17 +378,12 @@
    ];
    if (reSet1.size() > 0) {
      for (Integer i = 0; i < reSet1.size(); i++) {
        if (
          errorIdMap.containsKey(reSet1[i].Bar_Code__c) ||
          existIdMap.containsKey(reSet1[i].Bar_Code__c)
        ) {
                if (errorIdMap.containsKey(reSet1[i].Bar_Code__c) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
          // 跳过已经处理的消耗品明细
          continue;
        } else {
          String str = '该商品已经取消';
          consumableorderdetailsRecordserror.add(
            new ConsumableorderdetailsInfo(reSet1[i], str)
          );
                    consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
          errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
        }
      }
@@ -484,19 +419,12 @@
    ];
    if (reSet1.size() > 0) {
      for (Integer i = 0; i < reSet1.size(); i++) {
        if (
          errorIdMap.containsKey(reSet1[i].Bar_Code__c) ||
          existIdMap.containsKey(reSet1[i].Bar_Code__c)
        ) {
                if (errorIdMap.containsKey(reSet1[i].Bar_Code__c) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
          // 跳过已经处理的消耗品明细
          continue;
        } else if (
          !orderpieceorboxMap.containsKey(reSet1[i].Product_Pattern__c)
        ) {
                } else if (!orderpieceorboxMap.containsKey(reSet1[i].Product_Pattern__c)) {
          String str = '不是本出库单的出库产品';
          consumableorderdetailsRecordserror.add(
            new ConsumableorderdetailsInfo(reSet1[i], str)
          );
                    consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
          errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
        }
      }
@@ -538,10 +466,7 @@
    ];
    if (reSet1.size() > 0) {
      for (Integer i = 0; i < reSet1.size(); i++) {
        if (
          errorIdMap.containsKey(reSet1[i].Bar_Code__c) ||
          existIdMap.containsKey(reSet1[i].Bar_Code__c)
        ) {
                if (errorIdMap.containsKey(reSet1[i].Bar_Code__c) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
          // 跳过已经处理的消耗品明细
          continue;
        } else {
@@ -554,16 +479,11 @@
            }
          }
          if (containsFlg == false) {
            String str =
              '该商品是' +
              reSet1[i].Arrive_Owner_Work_Location__c +
              '的库存';
                        String str = '该商品是' + reSet1[i].Arrive_Owner_Work_Location__c + '的库存';
            if (reSet1[i].Dealer_Info_text__c != accountName) {
              str = '该商品在其他经销商库存';
            }
            consumableorderdetailsRecordserror.add(
              new ConsumableorderdetailsInfo(reSet1[i], str)
            );
                        consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
            errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
          }
        }
@@ -599,17 +519,12 @@
    ];
    if (reSet1.size() > 0) {
      for (Integer i = 0; i < reSet1.size(); i++) {
        if (
          errorIdMap.containsKey(reSet1[i].Bar_Code__c) ||
          existIdMap.containsKey(reSet1[i].Bar_Code__c)
        ) {
                if (errorIdMap.containsKey(reSet1[i].Bar_Code__c) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
          // 跳过已经处理的消耗品明细
          continue;
        } else {
          String str = '该商品已经销售';
          consumableorderdetailsRecordserror.add(
            new ConsumableorderdetailsInfo(reSet1[i], str)
          );
                    consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
          errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
        }
      }
@@ -643,17 +558,12 @@
    ];
    if (reSet1.size() > 0) {
      for (Integer i = 0; i < reSet1.size(); i++) {
        if (
          errorIdMap.containsKey(reSet1[i].Bar_Code__c) ||
          existIdMap.containsKey(reSet1[i].Bar_Code__c)
        ) {
                if (errorIdMap.containsKey(reSet1[i].Bar_Code__c) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
          // 跳过已经处理的消耗品明细
          continue;
        } else {
          String str = '该商品已经出库';
          consumableorderdetailsRecordserror.add(
            new ConsumableorderdetailsInfo(reSet1[i], str)
          );
                    consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
          errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
        }
      }
@@ -686,17 +596,12 @@
    ];
    if (reSet1.size() > 0) {
      for (Integer i = 0; i < reSet1.size(); i++) {
        if (
          errorIdMap.containsKey(reSet1[i].Bar_Code__c) ||
          existIdMap.containsKey(reSet1[i].Bar_Code__c)
        ) {
                if (errorIdMap.containsKey(reSet1[i].Bar_Code__c) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
          // 跳过已经处理的消耗品明细
          continue;
        } else {
          String str = '该商品已经丢失';
          consumableorderdetailsRecordserror.add(
            new ConsumableorderdetailsInfo(reSet1[i], str)
          );
                    consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
          errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
        }
      }
@@ -757,50 +662,33 @@
    for (Integer i = 0; i < orderdetails.size(); i++) {
      Integer a = 0;
      for (Integer j = 0; j < newdet2.size(); j++) {
                if (newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c && a < orderdetails[i].Shipment_Count__c) {
        if (
          newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c &&
          a < orderdetails[i].Shipment_Count__c
        ) {
          if (
            (existIdMap.containsKey(newdet2[j].Bar_Code__c) &&
            newdet2[j].Bar_Code__c == '盒') ||
                        (existIdMap.containsKey(newdet2[j].Bar_Code__c) && newdet2[j].Bar_Code__c == '盒') ||
            errorIdMap.containsKey(newdet2[j].Bar_Code__c)
          ) {
            // 跳过已经处理的消耗品明细
            continue;
          } else if (newdet2[j].Isoverdue__c == 0) {
            String str = '该商品已经超出减菌有效期的有效范围';
            consumableorderdetailsRecordserror.add(
              new ConsumableorderdetailsInfo(newdet2[j], str)
            );
                        consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
            errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
          } else if (newdet2[j].Box_Piece__c != orderdetails[i].Box_Piece__c) {
            String str = '该商品出货单位错误';
            consumableorderdetailsRecordserror.add(
              new ConsumableorderdetailsInfo(newdet2[j], str)
            );
                        consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
            errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
          } else if (!checkBarcodeResult.containsKey(newdet2[j].Bar_Code__c)) {
            Matcher n = Pattern.compile('[0-9]')
              .matcher(newdet2[j].TracingCode__c);
                        Matcher n = Pattern.compile('[0-9]').matcher(newdet2[j].TracingCode__c);
            if (n.find()) {
              if (newdet2[j].TracingCode__c.length() == 5) {
                String tr = newdet2[j].TracingCode__c;
                String Ctr = tr.substring(tr.length() - 3, tr.length());
                String Btr = tr.substring(tr.length() - 4, tr.length() - 3);
                String Atr = tr.substring(tr.length() - 5, tr.length() - 4);
                if (
                  Pattern.compile('[0-9]').matcher(Atr).find() ||
                  Pattern.compile('[0-9]').matcher(Ctr).find()
                ) {
                                if (Pattern.compile('[0-9]').matcher(Atr).find() || Pattern.compile('[0-9]').matcher(Ctr).find()) {
                  String str = '管理编码有误,请检查条形码数据。';
                  consumableorderdetailsRecordserror.add(
                    new ConsumableorderdetailsInfo(newdet2[j], str)
                  );
                  errorIdMap.put(
                    newdet2[j].Bar_Code__c,
                    newdet2[j].Bar_Code__c
                  );
                                    consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
                                    errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
                  continue;
                }
              }
@@ -809,23 +697,13 @@
              // errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
              // continue;
            }
            checkBarcodeResult.put(
              newdet2[j].Bar_Code__c,
              newdet2[j].Bar_Code__c
            );
            consumableorderdetailsRecords.add(
              new ConsumableorderdetailsInfo(newdet2[j])
            );
                        checkBarcodeResult.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
                        consumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(newdet2[j]));
            a++;
            existIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
          }
        } else if (
          newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c
        ) {
          if (
            a >= orderdetails[i].Shipment_Count__c &&
            orderdetails[i].Box_Piece__c == '个'
          ) {
                } else if (newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c) {
                    if (a >= orderdetails[i].Shipment_Count__c && orderdetails[i].Box_Piece__c == '个') {
            // 跳过超过数量的消耗品明细
            continue;
          } else if (errorIdMap.containsKey(newdet2[j].Bar_Code__c)) {
@@ -836,9 +714,7 @@
            // String str = '该商品超出订货数量';
            String str = '该产品超出出库单产品范围';
            //CHAN-C23BWX update by rentx 2021-04-28 end
            consumableorderdetailsRecordserror.add(
              new ConsumableorderdetailsInfo(newdet2[j], str)
            );
                        consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
            errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
          }
        }
@@ -880,17 +756,12 @@
    ];
    if (reSet1.size() > 0) {
      for (Integer i = 0; i < reSet1.size(); i++) {
        if (
          errorIdMap.containsKey(reSet1[i].Bar_Code__c) ||
          existIdMap.containsKey(reSet1[i].Bar_Code__c)
        ) {
                if (errorIdMap.containsKey(reSet1[i].Bar_Code__c) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
          // 跳过已经处理的消耗品明细
          continue;
        } else {
          String str = '该商品未到货确认';
          consumableorderdetailsRecordserror.add(
            new ConsumableorderdetailsInfo(reSet1[i], str)
          );
                    consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
          errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
        }
      }
@@ -924,26 +795,17 @@
        Box_Piece__c,
        hospitalSpecialOffer__c
      FROM Consumable_order_details2__c
      WHERE
        (Dealer_Saled__c = TRUE
        OR Dealer_Shipment__c = TRUE)
        AND Dealer_Returned__c = FALSE
        AND Bar_Code__c IN :exitlist
            WHERE (Dealer_Saled__c = TRUE OR Dealer_Shipment__c = TRUE) AND Dealer_Returned__c = FALSE AND Bar_Code__c IN :exitlist
      ORDER BY Name
    ];
    if (reSet1.size() > 0) {
      for (Integer i = 0; i < reSet1.size(); i++) {
        if (
          errorIdMap.containsKey(reSet1[i].Bar_Code__c) ||
          existIdMap.containsKey(reSet1[i].Bar_Code__c)
        ) {
                if (errorIdMap.containsKey(reSet1[i].Bar_Code__c) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
          // 跳过已经处理的消耗品明细
          continue;
        } else {
          String str = '该商品已经出货';
          consumableorderdetailsRecordserror.add(
            new ConsumableorderdetailsInfo(reSet1[i], str)
          );
                    consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
          errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
        }
      }
@@ -958,18 +820,10 @@
    }
    if (notexitlist.size() > 0) {
      //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode号'+ notexitlist + '不存在。'));
      return new ResponseBodyLWC(
        'Error',
        500,
        'BarCode号' + notexitlist + '不存在。',
        ''
      );
            return new ResponseBodyLWC('Error', 500, 'BarCode号' + notexitlist + '不存在。', '');
    }
    data.put('consumableorderdetailsRecords', consumableorderdetailsRecords);
    data.put(
      'consumableorderdetailsRecordserror',
      consumableorderdetailsRecordserror
    );
        data.put('consumableorderdetailsRecordserror', consumableorderdetailsRecordserror);
    res.status = 'Success';
    res.code = 200;
    System.debug('res = ' + res);
@@ -1042,32 +896,19 @@
      ) {
        // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '请输入产品 '+ ass.Prod.Name +' 的出货数量'));
        // return null;
        return new ResponseBodyLWC(
          'Error',
          500,
          '请输入产品 ' + ass.Prod.Name + ' 的出货数量',
          ''
        );
                return new ResponseBodyLWC('Error', 500, '请输入产品 ' + ass.Prod.Name + ' 的出货数量', '');
      }
      if (ass.outboundCount > deliverycnt) {
        // ass.orderdetails2.Rrturn_count__c.addError('超出出库数量');
        // return null;
        return new ResponseBodyLWC(
          'Error',
          500,
          ass.orderdetails2.Name + '超出出库数量',
          ''
        );
                return new ResponseBodyLWC('Error', 500, ass.orderdetails2.Name + '超出出库数量', '');
      }
    }
    for (Integer i = 0; i < orderdetails.size(); i++) {
      Decimal a = 0;
      for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
        if (
          ass.orderdetails2.Product_Pattern__c ==
          orderdetails[i].Product_Pattern__c
        ) {
                if (ass.orderdetails2.Product_Pattern__c == orderdetails[i].Product_Pattern__c) {
          a = a + ass.outboundCount;
        }
      }
@@ -1076,23 +917,11 @@
      if (a < orderdetails[i].Shipment_Count__c) {
        // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'商品'+orderdetails[i].Consumable_product__r.Name +'数量小于出货数量'));
        // return null;
        return new ResponseBodyLWC(
          'Error',
          500,
          '商品' +
            orderdetails[i].Consumable_product__r.Name +
            '数量小于出货数量',
          ''
        );
                return new ResponseBodyLWC('Error', 500, '商品' + orderdetails[i].Consumable_product__r.Name + '数量小于出货数量', '');
      } else if (a > orderdetails[i].Shipment_Count__c) {
        // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'商品'+orderdetails[i].Consumable_product__r.Name +'超出出货数量'));
        // return null;
        return new ResponseBodyLWC(
          'Error',
          500,
          '商品' + orderdetails[i].Consumable_product__r.Name + '超出出货数量',
          ''
        );
                return new ResponseBodyLWC('Error', 500, '商品' + orderdetails[i].Consumable_product__r.Name + '超出出货数量', '');
      }
    }
    List<Consumable_order_details2__c> Ins = new List<Consumable_order_details2__c>();
@@ -1105,8 +934,7 @@
    try {
      if (orderdetails1List.size() > 0) {
        for (Integer i = 0; i < orderdetails1List.size(); i++) {
          orderdetails1List[i]
            .RecordTypeId = System.Label.RT_ConOrderDetail1_Shipment;
                    orderdetails1List[i].RecordTypeId = System.Label.RT_ConOrderDetail1_Shipment;
          orderdetails1List[i].Used_date__c = Date.today();
        }
        ControllerUtil.updateOrderDetails1Satus(orderdetails1List);
@@ -1126,29 +954,23 @@
      for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
        if (ass.orderdetails2.Box_Piece__c == '个') {
          Decimal cnt = 1;
          for (
            Consumable_order_details2__c codctmp : consumableorderdetails2Nobox
          ) {
                    for (Consumable_order_details2__c codctmp : consumableorderdetails2Nobox) {
            Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
            if (codctmp.Bar_Code__c == ass.orderdetails2.Bar_Code__c) {
              insDetails.Id = codctmp.Id;
              insDetails.Consumable_Sale_order__c = null;
              insDetails.Consumable_Return_order__c = null;
              insDetails.Consumable_ZS_order__c = ESetId;
              insDetails.Delivery_List_RMB__c = orderpriceMap.get(
                ass.orderdetails2.Product_Pattern__c
              );
                            insDetails.Delivery_List_RMB__c = orderpriceMap.get(ass.orderdetails2.Product_Pattern__c);
              insDetails.Return_date__c = null;
              insDetails.Return_reason__c = null;
              insDetails.Consumable_Shipment_order__c = ESetId;
              insDetails.Send_Date__c = Date.today();
              if (coc.SummonsForDirction__c == '互相调货') {
                insDetails.Transfer_Time__c = ass.orderdetails2.Transfer_Time__c ==
                  null
                                insDetails.Transfer_Time__c = ass.orderdetails2.Transfer_Time__c == null
                  ? 1
                  : ass.orderdetails2.Transfer_Time__c + 1;
                insDetails.Frist_Transfer_Agency__c = ass.orderdetails2.Frist_Transfer_Agency__c ==
                  null
                                insDetails.Frist_Transfer_Agency__c = ass.orderdetails2.Frist_Transfer_Agency__c == null
                  ? coc.Dealer_Info__r.Name
                  : ass.orderdetails2.Frist_Transfer_Agency__c;
                insDetails.Agency_Transfer__c = true;
@@ -1165,20 +987,16 @@
          insDetails.Consumable_Sale_order__c = null;
          insDetails.Consumable_Return_order__c = null;
          insDetails.Consumable_ZS_order__c = ESetId;
          insDetails.Delivery_List_RMB__c = orderpriceMap.get(
            ass.orderdetails2.Product_Pattern__c
          );
                    insDetails.Delivery_List_RMB__c = orderpriceMap.get(ass.orderdetails2.Product_Pattern__c);
          insDetails.Return_date__c = null;
          insDetails.Return_reason__c = null;
          insDetails.Consumable_Shipment_order__c = ESetId;
          insDetails.Send_Date__c = Date.today();
          if (coc.SummonsForDirction__c == '互相调货') {
            insDetails.Transfer_Time__c = ass.orderdetails2.Transfer_Time__c ==
              null
                        insDetails.Transfer_Time__c = ass.orderdetails2.Transfer_Time__c == null
              ? 1
              : ass.orderdetails2.Transfer_Time__c + 1;
            insDetails.Frist_Transfer_Agency__c = ass.orderdetails2.Frist_Transfer_Agency__c ==
              null
                        insDetails.Frist_Transfer_Agency__c = ass.orderdetails2.Frist_Transfer_Agency__c == null
              ? coc.Dealer_Info__r.Name
              : ass.orderdetails2.Frist_Transfer_Agency__c;
            insDetails.Agency_Transfer__c = true;
@@ -1240,9 +1058,7 @@
    System.debug('barcode = ' + barcode);
    System.debug('accountName = ' + accountName);
    System.debug('userWorkLocation = ' + userWorkLocation);
    System.debug(
      'consumableorderdetailsRecords = ' + consumableorderdetailsRecords
    );
        System.debug('consumableorderdetailsRecords = ' + consumableorderdetailsRecords);
    System.debug('orderdetails = ' + orderdetails);
    System.debug('orderpriceMap = ' + orderpriceMap);
    System.debug('orderagencypriceMap = ' + orderagencypriceMap);
@@ -1272,59 +1088,32 @@
      ) {
        // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '请输入产品 '+ ass.Prod.Name +' 的出货数量'));
        // return null;
        System.debug(
          'ass.orderdetails2.Box_Piece__c = ' + ass.orderdetails2.Box_Piece__c
        );
                System.debug('ass.orderdetails2.Box_Piece__c = ' + ass.orderdetails2.Box_Piece__c);
        System.debug('ass.outboundCount = ' + ass.outboundCount);
        return new ResponseBodyLWC(
          'Error',
          500,
          '请输入产品 ' + ass.Prod.Name + ' 的出货数量',
          ''
        );
                return new ResponseBodyLWC('Error', 500, '请输入产品 ' + ass.Prod.Name + ' 的出货数量', '');
      }
      if (ass.outboundCount > deliverycnt) {
        // ass.orderdetails2.Rrturn_count__c.addError('超出出库数量');
        // return null;
        return new ResponseBodyLWC(
          'Error',
          500,
          ass.orderdetails2.Name + '超出出库数量',
          ''
        );
                return new ResponseBodyLWC('Error', 500, ass.orderdetails2.Name + '超出出库数量', '');
      }
    }
    for (Integer i = 0; i < orderdetails.size(); i++) {
      Decimal a = 0;
      for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
        if (
          ass.orderdetails2.Product_Pattern__c ==
          orderdetails[i].Product_Pattern__c
        ) {
                if (ass.orderdetails2.Product_Pattern__c == orderdetails[i].Product_Pattern__c) {
          a = a + ass.outboundCount;
        }
      }
      if (a < orderdetails[i].Shipment_Count__c) {
        // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'商品'+orderdetails[i].Consumable_product__r.Name +'数量小于出货数量'));
        // return null;
        return new ResponseBodyLWC(
          'Error',
          500,
          '商品' +
            orderdetails[i].Consumable_product__r.Name +
            '数量小于出货数量',
          ''
        );
                return new ResponseBodyLWC('Error', 500, '商品' + orderdetails[i].Consumable_product__r.Name + '数量小于出货数量', '');
      } else if (a > orderdetails[i].Shipment_Count__c) {
        // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'商品'+orderdetails[i].Consumable_product__r.Name +'超出出货数量'));
        // return null;
        return new ResponseBodyLWC(
          'Error',
          500,
          '商品' + orderdetails[i].Consumable_product__r.Name + '超出出货数量',
          ''
        );
                return new ResponseBodyLWC('Error', 500, '商品' + orderdetails[i].Consumable_product__r.Name + '超出出货数量', '');
      }
    }
@@ -1337,8 +1126,7 @@
    try {
      if (orderdetails1List.size() > 0) {
        for (Integer i = 0; i < orderdetails1List.size(); i++) {
          orderdetails1List[i]
            .RecordTypeId = System.Label.RT_ConOrderDetail1_Sale;
                    orderdetails1List[i].RecordTypeId = System.Label.RT_ConOrderDetail1_Sale;
          orderdetails1List[i].Used_date__c = Date.today();
        }
        ControllerUtil.updateOrderDetails1Satus(orderdetails1List);
@@ -1360,9 +1148,7 @@
      for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
        if (ass.orderdetails2.Box_Piece__c == '个') {
          Decimal cnt = 1;
          for (
            Consumable_order_details2__c codctmp : consumableorderdetails2Nobox
          ) {
                    for (Consumable_order_details2__c codctmp : consumableorderdetails2Nobox) {
            Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
            if (codctmp.Bar_Code__c == ass.orderdetails2.Bar_Code__c) {
              insDetails.Id = codctmp.Id;
@@ -1370,17 +1156,9 @@
              insDetails.Consumable_Return_order__c = null;
              insDetails.Consumable_ZS_order__c = ESetId;
              insDetails.Return_date__c = null;
              insDetails.Delivery_List_RMB__c = orderpriceMap.get(
                ass.orderdetails2.Product_Pattern__c
              );
              if (
                orderagencypriceMap.containsKey(
                  ass.orderdetails2.Product_Pattern__c
                ) == true
              ) {
                insDetails.Unitprice_To_agency__c = orderagencypriceMap.get(
                  ass.orderdetails2.Product_Pattern__c
                );
                            insDetails.Delivery_List_RMB__c = orderpriceMap.get(ass.orderdetails2.Product_Pattern__c);
                            if (orderagencypriceMap.containsKey(ass.orderdetails2.Product_Pattern__c) == true) {
                                insDetails.Unitprice_To_agency__c = orderagencypriceMap.get(ass.orderdetails2.Product_Pattern__c);
              }
              insDetails.Return_reason__c = null;
              insDetails.Used_date__c = Date.today();
@@ -1398,17 +1176,9 @@
          insDetails.Consumable_Return_order__c = null;
          insDetails.Consumable_ZS_order__c = ESetId;
          insDetails.Return_date__c = null;
          insDetails.Delivery_List_RMB__c = orderpriceMap.get(
            ass.orderdetails2.Product_Pattern__c
          );
          if (
            orderagencypriceMap.containsKey(
              ass.orderdetails2.Product_Pattern__c
            ) == true
          ) {
            insDetails.Unitprice_To_agency__c = orderagencypriceMap.get(
              ass.orderdetails2.Product_Pattern__c
            );
                    insDetails.Delivery_List_RMB__c = orderpriceMap.get(ass.orderdetails2.Product_Pattern__c);
                    if (orderagencypriceMap.containsKey(ass.orderdetails2.Product_Pattern__c) == true) {
                        insDetails.Unitprice_To_agency__c = orderagencypriceMap.get(ass.orderdetails2.Product_Pattern__c);
          }
          insDetails.Return_reason__c = null;
          insDetails.Used_date__c = Date.today();
@@ -1430,12 +1200,7 @@
      }
    } catch (Exception e) {
      Database.rollback(sp);
      return new ResponseBodyLWC(
        'Error',
        500,
        e.getMessage() + e.getStackTraceString(),
        ''
      );
            return new ResponseBodyLWC('Error', 500, e.getMessage() + e.getStackTraceString(), '');
    }
    res.status = 'Success';
    res.code = 200;
@@ -1524,10 +1289,7 @@
    @AuraEnabled
    public Decimal outboundCount { get; set; }
    public ConsumableorderdetailsInfo(
      Consumable_order_details2__c e,
      string str
    ) {
        public ConsumableorderdetailsInfo(Consumable_order_details2__c e, string str) {
      orderdetails1 = new Consumable_orderdetails__c();
      orderdetails2 = e;
      Prod = e.Consumable_Product__r;