From 125e6a5936a48d318603617d0df8ffcc2d129372 Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期一, 05 六月 2023 11:16:14 +0800
Subject: [PATCH] LEX CommunityUpdateCmp

---
 force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReport.cmp          | 1979 +++-
 force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportHelper.js     | 5173 +++++++----
 force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.js                                  |  773 +
 force-app/main/default/classes/ArriveGoodsControllerTest.cls                                 | 5935 +++++++++-----
 force-app/main/default/classes/ArriveGoodsController.cls                                     | 9828 ++++++++++++++--------
 force-app/main/default/classes/LexArriveGoodsController.cls                                  |  356 
 force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.js-meta.xml                         |    9 
 force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.css                                 |    1 
 force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.html                                |  380 
 force-app/main/default/classes/LexArriveGoodsController.cls-meta.xml                         |    5 
 force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportController.js |  617 
 11 files changed, 16,356 insertions(+), 8,700 deletions(-)

diff --git a/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReport.cmp b/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReport.cmp
index e496831..0d58c27 100644
--- a/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReport.cmp
+++ b/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReport.cmp
@@ -1,720 +1,1289 @@
-<aura:component controller="RetrospectiveWeeklyReportController"
-    implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction,forceCommunity:availableForAllPageTypes"
-    access="global">
-    <ltng:require styles="{!$Resource.multilineToastCSS}" />聽
-    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
-    <aura:handler event="c:strike_evt" action="{!c.createAopp}" name="strike_evt_addNewRecord" />
-    <aura:attribute name="data" type="Agency_Report__c" default="{sobjectType:'Agency_Report__c'}" />
-    <aura:attribute name="oppdata" type="Agency_Opportunity__c" default="{sobjectType:'Agency_Opportunity__c'}" />
-    <aura:attribute name="acondata" type="Agency_Contact__c" default="{sobjectType:'Ag
-    ency_Contact__c'}" />
-    <aura:attribute name="successMessage" type="String" />
-    <aura:attribute name="etEng" type="String" />
-    <aura:attribute name="errorMessage" type="String" />
-    <aura:attribute name="Close_Forecasted_Date__c_o" type="Date" />
-    <aura:attribute name="Amount__c_o" type="String" />
-    <aura:attribute name="OCMSale_Price__c_o" type="String" />
-    <aura:attribute name="StageName__c_o" type="String" />
-    <aura:attribute name="fieldsmap" type="Map" />
-    <aura:attribute name="AgencyReportMap" type="Boolean" default="false" />
-    <!-- 鍛ㄦ姤鍒嗙被 -->
+<aura:component
+  controller="RetrospectiveWeeklyReportController"
+  implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction,forceCommunity:availableForAllPageTypes,lightning:availableForFlowScreens"
+  access="global"
+>
+  <ltng:require styles="{!$Resource.multilineToastCSS}" />聽
+  <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
+  <aura:handler
+    event="c:strike_evt"
+    action="{!c.createAopp}"
+    name="strike_evt_addNewRecord"
+  />
+  <aura:attribute
+    name="data"
+    type="Agency_Report__c"
+    default="{sobjectType:'Agency_Report__c'}"
+  />
+  <aura:attribute
+    name="oppdata"
+    type="Agency_Opportunity__c"
+    default="{sobjectType:'Agency_Opportunity__c'}"
+  />
+  <aura:attribute
+    name="acondata"
+    type="Agency_Contact__c"
+    default="{sobjectType:'Ag
+    ency_Contact__c'}"
+  />
+  <aura:attribute name="successMessage" type="String" />
+  <aura:attribute name="etEng" type="String" />
+  <aura:attribute name="errorMessage" type="String" />
+  <aura:attribute name="Close_Forecasted_Date__c_o" type="Date" />
+  <aura:attribute name="Amount__c_o" type="String" />
+  <aura:attribute name="OCMSale_Price__c_o" type="String" />
+  <aura:attribute name="StageName__c_o" type="String" />
+  <aura:attribute name="fieldsmap" type="Map" />
+  <aura:attribute name="AgencyReportMap" type="Boolean" default="false" />
+  <!-- 鏃ユ姤鍒嗙被 -->
 
-    <aura:attribute name="alldata" type="List" />
-    <aura:attribute name="allselectlist" type="Map" />
-    <aura:attribute name="doclist" type="List" />
-    <aura:attribute name="docmap" type="Map" />
-    <aura:attribute name="login" type="Boolean" default="false" />
-    <aura:attribute name="loadOpp" type="Boolean" default="false" />
-    <aura:attribute name="reportPageData" type="Map" />
-    <aura:attribute name="selectbody" type="String" />
-    <aura:attribute name="report_date_list" type="Map" />
-    <aura:attribute name="selected_date" type="String" />
-    <aura:attribute name="selected_agency_person" type="String" />
-    <aura:attribute name="agency_report_header" type="String" />
-    <aura:attribute name="agency_report_header_id" type="String" />
-    <aura:attribute name="result" type="String" default="" />
-    <!-- //鍖婚櫌 鐐归�夐渶瑕�    -->
-    <aura:attribute name="hospital" type="string" default="" />
-    <aura:attribute name="hospitalId" type="string" default="" />
-    <aura:attribute name="hospitalLinkId" type="string" default="" />
-    <aura:handler name="change" value="{!v.hospital}" action="{!c.hosChange}" />
-    <aura:attribute name="hospitalList" type="Map" />
-    <!-- 浣跨敤浜у搧1(浜у搧鍨嬪彿) -->
-    <aura:attribute name="UseProduct1" type="string" default="" />
-    <aura:handler name="change" value="{!v.UseProduct1}" action="{!c.UseProduct1Change}" />
-    <aura:attribute name="UseProduct1List" type="Map" />
-    <aura:attribute name="UseProduct1Id" type="string" default="" />
-    <!-- 浣跨敤浜у搧2 -->
-    <aura:attribute name="UseProduct2" type="string" default="" />
-    <aura:handler name="change" value="{!v.UseProduct2}" action="{!c.UseProduct2Change}" />
-    <aura:attribute name="UseProduct2List" type="Map" />
-    <aura:attribute name="UseProduct2Id" type="string" default="" />
-    <!-- 浣跨敤浜у搧3 -->
-    <aura:attribute name="UseProduct3" type="string" default="" />
-    <aura:handler name="change" value="{!v.UseProduct3}" action="{!c.UseProduct3Change}" />
-    <aura:attribute name="UseProduct3List" type="Map" />
-    <aura:attribute name="UseProduct3Id" type="string" default="" />
+  <aura:attribute name="alldata" type="List" />
+  <aura:attribute name="setdoctorlisthos" type="Boolean" default="false" />
+  <aura:attribute name="allselectlist" type="Map" />
+  <aura:attribute name="doclist" type="List" />
+  <aura:attribute name="docmap" type="Map" />
+  <aura:attribute name="login" type="Boolean" default="false" />
+  <aura:attribute name="loadOpp" type="Boolean" default="false" />
+  <aura:attribute name="reportPageData" type="Map" />
+  <aura:attribute name="selectbody" type="String" />
+  <aura:attribute name="report_date_list" type="Map" />
+  <aura:attribute name="selected_date" type="String" />
+  <aura:attribute name="selected_agency_person" type="String" />
+  <aura:attribute name="agency_report_header" type="String" />
+  <aura:attribute name="agency_report_header_id" type="String" />
+  <aura:attribute name="result" type="String" default="" />
+  <!-- //鍖婚櫌 鐐归�夐渶瑕�    -->
+  <aura:attribute name="hospital" type="string" default="" />
+  <aura:attribute name="hospitalId" type="string" default="" />
+  <aura:attribute name="hospitals" type="string" default="" />
+  <aura:attribute name="hospitalLinkId" type="string" default="" />
+  <aura:handler name="change" value="{!v.hospital}" action="{!c.hosChange}" />
+  <aura:attribute name="hospitalList" type="Map" />
+  <!-- 浣跨敤浜у搧1(浜у搧鍨嬪彿) -->
+  <aura:attribute name="UseProduct1" type="string" default="" />
+  <aura:attribute name="UseProduct1s" type="string" default="" />
+  <aura:handler
+    name="change"
+    value="{!v.UseProduct1}"
+    action="{!c.UseProduct1Change}"
+  />
+  <aura:attribute name="UseProduct1List" type="Map" />
+  <aura:attribute name="UseProduct1Id" type="string" default="" />
+  <!-- 浣跨敤浜у搧2 -->
+  <aura:attribute name="UseProduct2" type="string" default="" />
+  <aura:attribute name="UseProduct2s" type="string" default="" />
+  <aura:handler
+    name="change"
+    value="{!v.UseProduct2}"
+    action="{!c.UseProduct2Change}"
+  />
+  <aura:attribute name="UseProduct2List" type="Map" />
+  <aura:attribute name="UseProduct2Id" type="string" default="" />
+  <!-- 浣跨敤浜у搧3 -->
+  <aura:attribute name="UseProduct3" type="string" default="" />
+  <aura:attribute name="UseProduct3s" type="string" default="" />
+  <aura:handler
+    name="change"
+    value="{!v.UseProduct3}"
+    action="{!c.UseProduct3Change}"
+  />
+  <aura:attribute name="UseProduct3List" type="Map" />
+  <aura:attribute name="UseProduct3Id" type="string" default="" />
+  <!--SWAG-CF58C3 fy start -->
+  <aura:attribute name="AWStoken" type="String" />
+  <aura:attribute name="AWSsearch" type="String" />
+  <aura:attribute name="AWSinsert" type="String" />
+  <aura:attribute name="AWStransactionURL" type="String" />
+  <aura:attribute name="AWSDoctor2Map" type="String" />
+  <aura:attribute name="awsurl" type="Map" />
+  <aura:attribute name="contactawsurl" type="Map" />
+  <aura:attribute name="allselectlistAgencyPerson" type="Map" />
+  <!--SWAG-CF58C3 fy end -->
 
+  <aura:attribute name="doctor_list" type="Map" />
+  <!-- <aura:attribute name="doctor_title" type="String" /> -->
+  <aura:attribute name="opportunity_list" type="Map" />
+  <aura:attribute name="edit_copy_select_report_id" type="String" />
+  <aura:attribute name="create_agency_report_id" type="String" />
+  <aura:attribute name="reports" type="List" />
+  <aura:attribute name="reports_now" type="List" />
+  <aura:attribute name="reports_now_count" type="Integer" />
+  <aura:attribute name="mode" type="String" />
+  <aura:attribute name="select_report_data" type="Map" />
+  <aura:attribute name="select_report_data_radio" type="Map" />
+  <aura:attribute name="default_select_doctor_id" type="String" />
+  <aura:attribute name="default_select_doctor_id2" type="String" />
+  <aura:attribute name="default_select_opportunity_id" type="String" />
+  <aura:attribute name="report_count" type="Integer" />
+  <aura:attribute name="dialog_type" type="String" />
+  <aura:attribute name="truthy" type="Boolean" default="false" />
+  <aura:attribute name="list_message" type="String" default="鎼滅储" />
+  <aura:attribute name="confirm_status" type="Integer" default="0" />
+  <aura:attribute name="modal_confirm_title" type="String" />
+  <aura:attribute name="modal_confirm_text" type="String" />
+  <!-- <aura:attribute name="new_falg" type="String" /> -->
+  <!-- fy -->
+  <aura:attribute name="UserProType" type="String" />
+  <!-- 绉戝 -->
+  <aura:attribute name="opportunity_cfilter" type="String" />
+  <aura:attribute
+    name="update_select_report_data_id"
+    type="String"
+    default=""
+  />
+  <!-- 鎵归噺娣诲姞鏃ユ姤 start-->
+  <aura:attribute name="reports_date" type="List" />
+  <aura:attribute
+    name="TableContent"
+    type="String"
+    description=" Show the Result class"
+  />
+  <aura:attribute
+    name="TableContent2"
+    type="String"
+    description=" Show the Result class"
+  />
+  <aura:attribute
+    name="TargetFileName"
+    type="String"
+    description="Name of the file"
+  />
+  <aura:attribute name="tableheaders" type="Object[]" />
+  <aura:attribute name="fileContentData" type="String" />
+  <aura:attribute name="filename" type="String" />
+  <aura:attribute name="NumOfRecords" type="Integer" default="1000" />
+  <aura:attribute name="showMain" type="Boolean" default="true" />
+  <aura:attribute name="IsEventDefault" type="Boolean" default="true" />
+  <!-- start DTT-zhj 澧炲姞閿欒淇℃伅table 2023-05-16-->
+  <!-- Imports -->
+  <!-- <aura:import library="lightningcomponentdemo:mockdataFaker" property="mockdataLibrary"/> -->
+  <!-- attributes -->
+  <aura:attribute name="errorData" type="Object" />
+  <aura:attribute name="errorColumns" type="List" />
+  <!-- show Error information -->
+  <aura:attribute name="showErrorInfo" type="Boolean" default="false" />
+  <!-- end DTT-zhj 澧炲姞閿欒淇℃伅table 2023-05-16-->
 
+  <aura:attribute name="PIConfig" type="Map" />
 
-    <aura:attribute name="doctor_list" type="Map" />
-    <!-- <aura:attribute name="doctor_title" type="String" /> -->
-    <aura:attribute name="opportunity_list" type="Map" />
-    <aura:attribute name="edit_copy_select_report_id" type="String" />
-    <aura:attribute name="create_agency_report_id" type="String" />
-    <aura:attribute name="reports" type="List" />
-    <aura:attribute name="reports_now" type="List" />
-    <aura:attribute name="reports_now_count" type="Integer" />
-    <aura:attribute name="mode" type="String" />
-    <aura:attribute name="select_report_data" type="Map" />
-    <aura:attribute name="select_report_data_radio" type="Map" />
-    <aura:attribute name="default_select_doctor_id" type="String" />
-    <aura:attribute name="default_select_opportunity_id" type="String" />
-    <aura:attribute name="report_count" type="Integer" />
-    <aura:attribute name="dialog_type" type="String" />
-    <aura:attribute name="truthy" type="Boolean" default="false" />
-    <aura:attribute name="list_message" type="String" default="鎼滅储" />
-    <aura:attribute name="confirm_status" type="Integer" default="0" />
-    <aura:attribute name="modal_confirm_title" type="String" />
-    <aura:attribute name="modal_confirm_text" type="String" />
-    <!-- fy -->
-    <aura:attribute name="UserProType" type="String" />
-    <!-- 绉戝 -->
-    <aura:attribute name="opportunity_cfilter" type="String" />
-    <aura:attribute name="update_select_report_data_id" type="String" default="" />
-    <!-- 鎵归噺娣诲姞鍛ㄦ姤 start-->
-    <aura:attribute name="reports_date" type="List" />
-    <aura:attribute name="TableContent" type="String" description=" Show the Result class" />
-    <aura:attribute name="TableContent2" type="String" description=" Show the Result class" />
-    <aura:attribute name="TargetFileName" type="String" description="Name of the file" />
-    <aura:attribute name="tableheaders" type="Object[]" />
-    <aura:attribute name="fileContentData" type="String" />
-    <aura:attribute name="filename" type="String" />
-    <aura:attribute name="NumOfRecords" type="Integer" default="1000" />
-    <aura:attribute name="showMain" type="Boolean" default="true" />
-    <aura:attribute name="IsEventDefault" type="Boolean" default="true" />
-    
-    <aura:attribute name="PIConfig" type="Map"/>
-    
-        <ltng:require scripts="{! $Resource.AWSService+'/AWSService.js' }" />
-    <ltng:require scripts="{! $Resource.jquery183minjs }" />
-    
-    <!-- 鎵归噺娣诲姞鍛ㄦ姤 end-->
-    <!--銉兗銉変腑...-->
-    <aura:renderIf isTrue="{!v.login}">
-        <div class="slds-spinner_container height100vh">
-            <div class="slds-spinner--brand slds-spinner slds-spinner--medium" role="alert">
-                <span class="slds-assistive-text">Loading</span>
-                <div class="slds-spinner__dot-a"></div>
-                <div class="slds-spinner__dot-b"></div>
-            </div>
-        </div>
-    </aura:renderIf>
-    <div aura:id="report" id="report" class="contents_wrapper">
-        <div class="slds-grid slds-wrap slds-grid--pull-padded">
-            <div style="width: 230px;"></div>
-            <div
-                class="tr mt5 slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-12 slds-large-size--1-of-12">
-                鍛�
-            </div>
-            <div class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12">
-                <ui:inputSelect aura:id="select_date" class="slds-select" change="{!c.select_date_change}" />
-            </div>
-            <!-- 浠g悊搴楁媴褰撹�� -->
-            <div class="tr mt5 slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-12 slds-large-size--1-of-12"
-                style="display: none;">
-                {!v.fieldsmap.Person_In_Charge2__c}
-            </div>
-            <div class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12"
-                style="display: none;">
-                <ui:inputSelect aura:id="select_agency_person" class="slds-select agency_person_select"
-                    change="{!c.select_agency_change}" />
-            </div>
-            <div style="width: 200px;">
-            </div>
-            <div class="tr slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--2-of-12 slds-large-size--2-of-12"
-                style="display: contents;">
-                <ui:button aura:id="new_button" label="鏂板缓" press="{!c.new_report}" />
-            </div>
-            <div class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--2-of-12 slds-large-size--2-of-12">
-                <ui:button aura:id="copy_button" label="澶嶅埗" press="{!c.copy_button}" disabled="true" />
-                <ui:button aura:id="import" label="瀵煎叆" press="{!c.import}" />
-                <ui:button aura:id="export" label="瀵煎嚭" press="{!c.export_condition}" />
-            </div>
-        </div>
+  <ltng:require scripts="{! $Resource.AWSService+'/AWSService.js' }" />
+  <ltng:require scripts="{! $Resource.jquery183minjs }" />
+
+  <!-- 鎵归噺娣诲姞鏃ユ姤 end-->
+  <!--銉兗銉変腑...-->
+  <aura:renderIf isTrue="{!v.login}">
+    <div class="slds-spinner_container height100vh">
+      <div
+        class="slds-spinner--brand slds-spinner slds-spinner--medium"
+        role="alert"
+      >
+        <span class="slds-assistive-text">Loading</span>
+        <div class="slds-spinner__dot-a"></div>
+        <div class="slds-spinner__dot-b"></div>
+      </div>
     </div>
-    <div aura:id="report_list" class="report_list_area">
-        <div class="slds-table--edit_container slds-is-relative" style="padding-left: 50px;">
-            <table class="slds-table slds-table--edit slds-table--bordered slds-table--fixed-layout slds-no-cell-focus"
-                role="grid" style="width:66.75rem;">
+  </aura:renderIf>
+  <div aura:id="report" id="report" class="contents_wrapper">
+    <div class="slds-grid slds-wrap slds-grid--pull-padded">
+      <div style="width: 200px"></div>
+      <div
+        class="tr mt5 slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-12 slds-large-size--1-of-12"
+      >
+        鍛�
+      </div>
+      <div
+        class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12"
+      >
+        <ui:inputSelect
+          aura:id="select_date"
+          class="slds-select"
+          change="{!c.select_date_change}"
+        />
+      </div>
+      <!-- 浠g悊搴楁媴褰撹�� -->
+      <div
+        class="tr mt5 slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-12 slds-large-size--1-of-12"
+        style="display: none"
+      >
+        {!v.fieldsmap.Person_In_Charge2__c}
+      </div>
+      <div
+        class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12"
+        style="display: none"
+      >
+        <ui:inputSelect
+          aura:id="select_agency_person"
+          class="slds-select agency_person_select"
+          change="{!c.select_agency_change}"
+        />
+      </div>
+      <div style="width: 100px"></div>
+      <div
+        class="tr slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--2-of-12 slds-large-size--2-of-12"
+        style="display: contents"
+      >
+        <ui:button aura:id="new_button" label="鏂板缓" press="{!c.new_report}" />
+      </div>
+      <div
+        style="width: 350px"
+        class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--2-of-12 slds-large-size--2-of-12"
+      >
+        <ui:button
+          aura:id="copy_button"
+          label="澶嶅埗"
+          press="{!c.copy_button}"
+          disabled="true"
+        />
+        <ui:button
+          aura:id="delete_button"
+          label="鍒犻櫎"
+          press="{!c.delete_button}"
+          disabled="true"
+        />
+        <ui:button aura:id="import" label="瀵煎叆" press="{!c.import}" />
+        <ui:button
+          aura:id="export"
+          label="瀵煎嚭"
+          press="{!c.export_condition}"
+        />
+        <ui:button
+          aura:id="returnbutton"
+          label="杩斿洖"
+          press="{!c.return_main_page}"
+        />
+      </div>
+    </div>
+  </div>
+  <div aura:id="report_list" class="report_list_area">
+    <div
+      class="slds-table--edit_container slds-is-relative"
+      style="padding-left: 50px"
+    >
+      <table
+        class="slds-table slds-table--edit slds-table--bordered slds-table--fixed-layout slds-no-cell-focus"
+        role="grid"
+        style="width: 66.75rem"
+      >
+        <thead>
+          <tr class="slds-line-height--reset">
+            <th
+              class="table_header slds-text-title--caps"
+              style="width: 250px"
+            ></th>
+            <th class="table_header slds-text-title--caps">
+              <span class="slds-truncate" title="Name"
+                >{!v.fieldsmap.Person_In_Charge2__c}</span
+              >
+              <!-- {!v.fieldsmap.Person_In_Charge2__c}  鎷呭綋-->
+            </th>
+            <th class="table_header slds-text-title--caps" style="width: 250px">
+              <span class="slds-truncate" title="Name">鍖婚櫌</span>
+            </th>
+            <th class="table_header slds-text-title--caps">
+              <span class="slds-truncate" title="Name"
+                >{!v.fieldsmap.Department_Cateogy__c}</span
+              >
+              <!-- {!v.fieldsmap.Department_Cateogy__c}    绉戝-->
+            </th>
+            <th class="table_header slds-text-title--caps">
+              <span class="slds-truncate" title="Name">鎷滆浜�</span>
+              <!-- {!v.fieldsmap.doctor2__c}    鎷滆浜� -->
+            </th>
+            <th class="table_header slds-text-title--caps">
+              <span class="slds-truncate" title="Name"
+                >{!v.fieldsmap.DealerPersonnel__c}</span
+              >
+              <!-- {!v.fieldsmap.visitor_title__c}   鑱屼綅-->
+            </th>
+            <th class="table_header slds-text-title--caps">
+              <span class="slds-truncate" title="Name"
+                >{!v.fieldsmap.WorkMark__c}</span
+              >
+              <!-- {!v.fieldsmap.visitor_title__c}   鑱屼綅-->
+            </th>
+          </tr>
+        </thead>
+        <tbody>
+          <aura:iteration items="{!v.reports}" var="item" indexVar="index">
+            <tr class="slds-hint-parent">
+              <td role="gridcell" class="slds-cell-edit">
+                <ui:inputRadio
+                  class="report_radio"
+                  name="report_radio"
+                  label="{!item.Name}"
+                  change="{!c.change_report_radio}"
+                />
+                <lightning:buttonIcon
+                  class="edit_button"
+                  iconName="utility:edit"
+                  size="small"
+                  alternativeText="edit"
+                  value="{!index}"
+                  onclick="{!c.edit_button}"
+                />
+              </td>
+              <td role="gridcell" class="slds-cell-edit">
+                <span class="slds-grid slds-grid--align-spread">
+                  <span
+                    class="slds-truncate"
+                    title="{!item.Person_In_Charge2__r.Name}"
+                    >{!item.Person_In_Charge2__r.Name}</span
+                  >
+                </span>
+              </td>
+              <th scope="row" tabindex="0" class="slds-cell-edit">
+                <span class="slds-grid slds-grid--align-spread">
+                  {!item.Agency_Hospital__r.Name}
+                </span>
+              </th>
+              <td role="gridcell" class="slds-cell-edit">
+                <span class="slds-grid slds-grid--align-spread">
+                  <span
+                    class="slds-truncate"
+                    title="{!item.Department_Cateogy_text__c}"
+                    >{!item.Department_Cateogy_text__c}</span
+                  >
+                </span>
+              </td>
+              <td role="gridcell" class="slds-cell-edit">
+                <span class="slds-grid slds-grid--align-spread">
+                  <span class="slds-truncate" title="{!item.doctor2__r.Name}">
+                    <span class="encrypt">{!item.doctor2__r.Name}</span>
+                    <span class="decrypt">{!item.doctor2__r.awsdata.name}</span>
+                  </span>
+                </span>
+              </td>
+              <td role="gridcell" class="slds-cell-edit">
+                <span class="slds-grid slds-grid--align-spread">
+                  <span
+                    class="slds-truncate"
+                    title="{!item.DealerPersonnel__r.Name}"
+                    >{!item.DealerPersonnel__r.Name}</span
+                  >
+                </span>
+              </td>
+              <td role="gridcell" class="slds-cell-edit">
+                <span class="slds-grid slds-grid--align-spread">
+                  <span class="slds-truncate" title="{!item.WorkMark__c}">
+                    <lightning:input
+                      type="checkbox"
+                      checked="{!item.WorkMark__c}"
+                      disabled="true"
+                    />
+                  </span>
+                </span>
+              </td>
+            </tr>
+          </aura:iteration>
+        </tbody>
+      </table>
+    </div>
+    <aura:renderIf isTrue="{!v.report_count > 0}">
+      <aura:set attribute="else">
+        <div class="no_data_area">{!v.list_message}</div>
+      </aura:set>
+    </aura:renderIf>
+  </div>
+  <!-- 鎵归噺娣诲姞鏃ユ姤 start-->
+  <div
+    aura:id="modal_import"
+    role="dialog"
+    tabindex="-1"
+    class="disp_none slds-modal slds-fade-in-open slds-modal--large"
+    aria-labelledby="headerTarget"
+  >
+    <div class="slds-modal slds-fade-in-open slds-hide" aura:id="successDiv01">
+      <!-- <ui:inputText aura:id="articleURL" /> -->
+      <div class="demo-only" style="height: 8rem">
+        <div class="slds-notify_container slds-is-relative">
+          <div
+            class="slds-notify slds-notify_toast slds-theme_success"
+            role="alert"
+          >
+            <div class="slds-m-left_xx-large">
+              <div
+                class="slds-notify__content slds-m-left_small slds-align_absolute-center slds-m-left_xx-large"
+              >
+                <lightning:icon
+                  alternativeText="Success"
+                  iconName="utility:success"
+                  size="small"
+                  class="buttonColor slds-m-right_small"
+                />
+                <h2 class="slds-text-heading_small">{!v.successMessage}</h2>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+    </div>
+    <div
+      class="slds-modal slds-fade-in-open slds-hide"
+      aura:id="errorDiv01"
+      style="z-index: 10001"
+    >
+      <!-- <ui:inputText aura:id="articleURL" /> -->
+      <div class="demo-only" style="height: 8rem">
+        <div class="slds-notify_container slds-is-relative">
+          <div
+            class="slds-notify slds-notify_toast slds-theme_error"
+            role="status"
+          >
+            <div class="slds-m-left_xx-large">
+              <div
+                class="slds-notify__content slds-m-left_small slds-align_absolute-center slds-m-left_xx-large"
+              >
+                <lightning:icon
+                  alternativeText="error"
+                  iconName="utility:error"
+                  size="small"
+                  class="buttonColor slds-m-right_small"
+                />
+                <h2 class="slds-text-heading_small">{!v.errorMessage}</h2>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+    </div>
+    <div class="slds-modal__container">
+      <div class="slds-modal__header">
+        <h4 id="headerTarget" class="slds-float--left"></h4>
+        <h2 id="headerTarget" class="slds-text-heading--medium">
+          鏃ユ姤鎵归噺瀵煎叆
+        </h2>
+        <ui:button
+          aura:id="close_button"
+          label="鍏抽棴"
+          class="close_button slds-button slds-button--neutral slds-order--1"
+          press="{!c.close_import}"
+        />
+      </div>
+      <div
+        class="slds-modal__content slds-scrollable slds-grow slds-p-around--medium"
+      >
+        <aura:if isTrue="{!v.showMain}">
+          <div>
+            <lightning:input
+              type="file"
+              class="file"
+              uara:id="file"
+              onchange="{!c.CreateRecord}"
+            />
+          </div>
+          <aura:set attribute="else">
+            <ui:outputRichText
+              class="uiOutputRichText slds-m--around-large"
+              value="{!v.TableContent}"
+            />
+            <div class="slds-p-around--large slds-align--absolute-center">
+              <lightning:button
+                label="淇濆瓨"
+                variant="brand"
+                onclick="{!c.processFileContent}"
+              />
+              <lightning:button
+                label="鍙栨秷"
+                variant="brand"
+                onclick="{!c.cancel}"
+              />
+            </div>
+            <aura:if isTrue="{!v.showErrorInfo}">
+              <div class="slds-p-around--large slds-align--absolute-center">
+                <lightning:button
+                  label="瀵煎嚭閿欒淇℃伅"
+                  variant="brand"
+                  onclick="{!c.exportErrorInfo}"
+                />
+              </div>
+              <div class="slds-p-around--large slds-align--absolute-center">
+                <div style="height: 300px">
+                  <lightning:datatable
+                    keyField="id"
+                    data="{! v.errorData }"
+                    columns="{! v.errorColumns }"
+                    hideCheckboxColumn="true"
+                  />
+                </div>
+              </div>
+            </aura:if>
+          </aura:set>
+        </aura:if>
+      </div>
+    </div>
+  </div>
+  <div
+    aura:id="modal_importbg"
+    class="disp_none slds-backdrop slds-backdrop--open"
+  ></div>
+  <!-- 鎵归噺娣诲姞鏃ユ姤 end-->
+
+  <!-- 鎵归噺瀵煎嚭鏃ユ姤 start-->
+  <div
+    aura:id="modal_export"
+    role="dialog"
+    tabindex="-1"
+    class="disp_none slds-modal slds-fade-in-open slds-modal--large"
+  >
+    <div class="slds-modal__container">
+      <div class="slds-modal__header">
+        <h4 id="headerTarget" class="slds-float--left"></h4>
+        <h2 id="headerTarget" class="slds-text-heading--medium">
+          鏃ユ姤鎵归噺瀵煎嚭
+        </h2>
+        <ui:button
+          aura:id="close_button"
+          label="鍏抽棴"
+          class="close_button slds-button slds-button--neutral slds-order--1"
+          press="{!c.close_export}"
+        />
+      </div>
+      <div
+        class="slds-modal__content slds-scrollable slds-grow slds-p-around--medium"
+      >
+        <aura:if isTrue="{!v.showMain}">
+          <div class="slds-grid slds-wrap slds-grid--pull-padded">
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-4"
+            ></div>
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-4"
+            >
+              娲诲姩鏃ュ紑濮嬫棩鏈�
+              <lightning:input
+                type="Date"
+                class="slds-input slds-input_bare"
+                aura:id="input-report-date1"
+              />
+            </div>
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-4"
+            >
+              娲诲姩鏃ョ粨鏉熸棩鏈�
+              <lightning:input
+                type="Date"
+                class="slds-input slds-input_bare"
+                aura:id="input-report-date2"
+              />
+            </div>
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-4"
+            ></div>
+            <div class="slds-p-around--large slds-align--absolute-center">
+              <lightning:button
+                label="纭"
+                variant="brand"
+                onclick="{!c.select_repores_date}"
+              />
+              <lightning:button
+                label="鍙栨秷"
+                variant="brand"
+                onclick="{!c.close_export}"
+              />
+            </div>
+          </div>
+          <aura:set attribute="else">
+            <ui:outputRichText
+              class="uiOutputRichText slds-m--around-large"
+              value="{!v.TableContent2}"
+            />
+            <div class="slds-p-around--large slds-align--absolute-center">
+              <lightning:button
+                label="纭"
+                variant="brand"
+                onclick="{!c.exportDate}"
+              />
+              <lightning:button
+                label="鍙栨秷"
+                variant="brand"
+                onclick="{!c.close_export}"
+              />
+            </div>
+          </aura:set>
+        </aura:if>
+      </div>
+    </div>
+  </div>
+  <div
+    aura:id="modal_exportbg"
+    class="disp_none slds-backdrop slds-backdrop--open"
+  ></div>
+  <!-- 鎵归噺瀵煎嚭鏃ユ姤 end-->
+  <div
+    aura:id="modal_window"
+    role="dialog"
+    tabindex="-1"
+    class="disp_none slds-modal slds-fade-in-open slds-modal--large"
+    aria-labelledby="headerTarget"
+  >
+    <div class="slds-modal__container">
+      <div class="slds-modal slds-fade-in-open slds-hide" aura:id="successDiv">
+        <!-- <ui:inputText aura:id="articleURL" /> -->
+        <div class="demo-only" style="height: 8rem">
+          <div class="slds-notify_container slds-is-relative">
+            <div
+              class="slds-notify slds-notify_toast slds-theme_success"
+              role="alert"
+            >
+              <div class="slds-m-left_xx-large">
+                <div
+                  class="slds-notify__content slds-m-left_small slds-align_absolute-center slds-m-left_xx-large"
+                >
+                  <lightning:icon
+                    alternativeText="Success"
+                    iconName="utility:success"
+                    size="small"
+                    class="buttonColor slds-m-right_small"
+                  />
+                  <h2 class="slds-text-heading_small">{!v.successMessage}</h2>
+                </div>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+      <div
+        class="slds-modal slds-fade-in-open slds-hide"
+        aura:id="errorDiv"
+        style="z-index: 10001"
+      >
+        <!-- <ui:inputText aura:id="articleURL" /> -->
+        <div class="demo-only" style="height: 8rem">
+          <div class="slds-notify_container slds-is-relative">
+            <div
+              class="slds-notify slds-notify_toast slds-theme_error"
+              role="status"
+            >
+              <div class="slds-m-left_xx-large">
+                <div
+                  class="slds-notify__content slds-m-left_small slds-align_absolute-center slds-m-left_xx-large"
+                >
+                  <lightning:icon
+                    alternativeText="error"
+                    iconName="utility:error"
+                    size="small"
+                    class="buttonColor slds-m-right_small"
+                  />
+                  <h2 class="slds-text-heading_small">{!v.errorMessage}</h2>
+                </div>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+      <div class="slds-modal__header">
+        <h2 id="headerTarget" class="slds-text-heading--medium">
+          鏃ユ姤({!v.selected_date}&nbsp;{!v.selected_agency_person})
+        </h2>
+        <ui:button
+          aura:id="close_button"
+          label="鍏抽棴"
+          class="close_button slds-button slds-button--neutral slds-order--1"
+          press="{!c.toggle_report}"
+        />
+      </div>
+      <div class="slds-modal__content slds-grow slds-p-around--medium">
+        <div class="slds-box slds-theme--shade">
+          <div class="slds-grid slds-wrap slds-grid--pull-padded">
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+            >
+              娲诲姩鏃�
+              <lightning:input
+                type="date"
+                value="{!v.data.Report_Date__c}"
+                aura:id="input-report-date"
+                variant="label-hidden"
+              />
+            </div>
+            <!-- 鍖婚櫌 -->
+            <div
+              aura:id="hospital_list"
+              class="slds-form-element slds-lookup slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+              data-select="single"
+            >
+              <!-- label="鍖婚櫌" -->
+              鍖婚櫌
+              <lightning:input
+                aura:id="hospital_input_text"
+                class="field"
+                value="{!v.hospital}"
+                updateOn="keyup"
+                variant="label-hidden"
+              />
+              <div class="slds-lookup__menu" id="lookup-66">
+                <ul class="slds-lookup__list" role="listbox">
+                  <aura:iteration var="hospital" items="{!v.hospitalList}">
+                    <li
+                      role="presentation"
+                      onclick="{!c.selectHos}"
+                      data-accName="{!hospital.Hospital_Name_readonly__c}"
+                      data-accId="{!hospital.Hospital__c}"
+                    >
+                      <span
+                        class="slds-lookup__item-action slds-media"
+                        id="lookup-option-498"
+                        role="option"
+                      >
+                        <div class="slds-media__body">
+                          <div class="slds-lookup__result-text">
+                            {!hospital.Hospital_Name_readonly__c}
+                          </div>
+                        </div>
+                      </span>
+                    </li>
+                  </aura:iteration>
+                </ul>
+              </div>
+            </div>
+            <!-- 绉戝鍒嗙被 -->
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+            >
+              {!v.fieldsmap.Department_Cateogy__c}
+              <!-- <ui:inputText aura:id="select_department" class="slds-select"
+                                change="{!c.select_department}"/> -->
+              <lightning:input
+                type="text"
+                onchange="{!c.select_department}"
+                aura:id="select_department"
+                variant="label-hidden"
+              />
+            </div>
+            <!-- 缁忛攢鍟嗕汉鍛�  change="{!c.select_DealerPersonnel}" -->
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+              style="width: 145px"
+            >
+              {!v.fieldsmap.DealerPersonnel__c}
+              <ui:inputSelect
+                aura:id="select_DealerPersonnel"
+                class="slds-select"
+              />
+            </div>
+            <!-- 娲诲姩鍖哄垎   -->
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+            >
+              {!v.fieldsmap.WorkRecord__c}
+              <ui:inputSelect
+                aura:id="select_purpose_type"
+                class="slds-select"
+                change="{!c.select_purpose_type}"
+              />
+            </div>
+            <!-- 鎷滆浜� {!v.fieldsmap.doctor2__c}-->
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+              style="width: 145px"
+            >
+              鎷滆浜�
+              <ui:inputSelect
+                aura:id="select_doctor"
+                class="slds-select"
+                change="{!c.doctor_change}"
+              />
+            </div>
+            <!-- <p hidden="hidden"> -->
+
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-12"
+            >
+              <br />
+              <ui:button
+                label="鏂板缓"
+                class="slds-button"
+                press="{!c.createCon}"
+                disabled="true"
+                aura:id="new_con"
+              />
+            </div>
+
+            <!-- </p> -->
+            <hr />
+            <!-- 浜у搧鍒嗙被(绗笁鍒嗙被) change="{!c.select_ProductClassification}" -->
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+            >
+              浜у搧鍒嗙被(绗笁鍒嗙被)
+              <ui:inputSelect
+                aura:id="select_ProductClassification"
+                class="slds-select"
+                change="{!c.selectProductClassification}"
+              />
+            </div>
+            <!-- 浣跨敤浜у搧1(浜у搧鍨嬪彿)   UseProduct1__c  -->
+            <div
+              aura:id="UseProduct1_List"
+              class="slds-form-element slds-lookup slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+              data-select="single"
+            >
+              <!-- label="浣跨敤浜у搧1(浜у搧鍨嬪彿)" -->
+              浣跨敤浜у搧1(浜у搧鍨嬪彿)
+              <lightning:input
+                aura:id="UseProduct1_TEXT"
+                class="field"
+                value="{!v.UseProduct1}"
+                updateOn="keyup"
+                variant="label-hidden"
+              />
+              <div class="slds-lookup__menu" id="lookup-11">
+                <ul
+                  class="slds-lookup__list"
+                  role="listbox"
+                  style="max-height: 230px"
+                >
+                  <aura:iteration
+                    var="UseProduct1"
+                    items="{!v.UseProduct1List}"
+                  >
+                    <li
+                      role="presentation"
+                      onclick="{!c.seletUseProduct1Change}"
+                      data-accid="{!UseProduct1.Id}"
+                      data-accName="{!UseProduct1.Asset_Model_No__c}"
+                    >
+                      <span
+                        class="slds-lookup__item-action slds-media"
+                        id="lookup-option-498"
+                        role="option"
+                      >
+                        <div class="slds-media__body">
+                          <div class="slds-lookup__result-text">
+                            {!UseProduct1.Asset_Model_No__c}
+                          </div>
+                        </div>
+                      </span>
+                    </li>
+                  </aura:iteration>
+                </ul>
+              </div>
+            </div>
+            <!-- 浣跨敤浜у搧2   UseProduct2__c  -->
+            <div
+              aura:id="UseProduct2_List"
+              class="slds-form-element slds-lookup slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+              data-select="single"
+            >
+              <!-- label="浣跨敤浜у搧2" -->
+              浣跨敤浜у搧2
+              <lightning:input
+                aura:id="UseProduct2_TEXT"
+                class="field"
+                value="{!v.UseProduct2}"
+                updateOn="keyup"
+                variant="label-hidden"
+              />
+              <div class="slds-lookup__menu" id="lookup-22">
+                <ul
+                  class="slds-lookup__list"
+                  role="listbox"
+                  style="max-height: 230px"
+                >
+                  <aura:iteration
+                    var="UseProduct2"
+                    items="{!v.UseProduct2List}"
+                  >
+                    <li
+                      role="presentation"
+                      onclick="{!c.seletUseProduct2Change}"
+                      data-accid="{!UseProduct2.Id}"
+                      data-accName="{!UseProduct2.Asset_Model_No__c}"
+                    >
+                      <span
+                        class="slds-lookup__item-action slds-media"
+                        id="lookup-option-498"
+                        role="option"
+                      >
+                        <div class="slds-media__body">
+                          <div class="slds-lookup__result-text">
+                            {!UseProduct2.Asset_Model_No__c}
+                          </div>
+                        </div>
+                      </span>
+                    </li>
+                  </aura:iteration>
+                </ul>
+              </div>
+            </div>
+            <!-- 浣跨敤浜у搧3   UseProduct3__c  -->
+            <div
+              aura:id="UseProduct3_List"
+              class="slds-form-element slds-lookup slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+              data-select="single"
+            >
+              <!-- label="浣跨敤浜у搧3" -->
+              浣跨敤浜у搧3
+              <lightning:input
+                aura:id="UseProduct3_TEXT"
+                class="field"
+                value="{!v.UseProduct3}"
+                updateOn="keyup"
+                variant="label-hidden"
+              />
+              <div class="slds-lookup__menu" id="lookup-33">
+                <ul
+                  class="slds-lookup__list"
+                  role="listbox"
+                  style="max-height: 230px"
+                >
+                  <aura:iteration
+                    var="UseProduct3"
+                    items="{!v.UseProduct3List}"
+                  >
+                    <li
+                      role="presentation"
+                      onclick="{!c.seletUseProduct3Change}"
+                      data-accid="{!UseProduct3.Id}"
+                      data-accName="{!UseProduct3.Asset_Model_No__c}"
+                    >
+                      <span
+                        class="slds-lookup__item-action slds-media"
+                        id="lookup-option-498"
+                        role="option"
+                      >
+                        <div class="slds-media__body">
+                          <div class="slds-lookup__result-text">
+                            {!UseProduct3.Asset_Model_No__c}
+                          </div>
+                        </div>
+                      </span>
+                    </li>
+                  </aura:iteration>
+                </ul>
+              </div>
+            </div>
+            <!-- 鏁堟灉/杩涘害  EffectProgress__c-->
+            <div
+              aura:id="product_category_select1"
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+            >
+              {!v.fieldsmap.EffectProgress__c}
+              <ui:inputSelect
+                aura:id="select_EffectProgress"
+                class="slds-select"
+              />
+            </div>
+            <hr />
+            <!-- 浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺  ConsumptionOfConsumables__c-->
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+            >
+              {!v.fieldsmap.ConsumptionOfConsumables__c}
+              <!-- <ui:inputText aura:id="select_ConsumptionOfConsumables" class="slds-select"
+                                change="{!c.select_ConsumptionOfConsumables}" /> -->
+              <lightning:input
+                type="text"
+                onchange="{!c.select_ConsumptionOfConsumables}"
+                aura:id="select_ConsumptionOfConsumables"
+                variant="label-hidden"
+              />
+            </div>
+            <!-- 鏈+鍒嗙被   WarlockClassification__c   -->
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+            >
+              {!v.fieldsmap.WarlockClassification__c}
+              <ui:inputSelect
+                aura:id="select_OtherBrandConsumables"
+                class="slds-select"
+              />
+            </div>
+            <!-- 宸查噰鐢ㄥ叾浠栧搧鐗�   ProductCcategory__c -->
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+            >
+              {!v.fieldsmap.ProductCcategory__c}
+              <ui:inputSelect
+                aura:id="select_ProductCcategory"
+                class="slds-select"
+                change="{!c.selectpurposetype}"
+              />
+            </div>
+            <!-- 鍏朵粬鍝佺墝浜у搧绫诲埆  -->
+            <div
+              aura:id="result"
+              class="disp_none slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+            >
+              {!v.fieldsmap.productCategories__c}
+              <ui:inputSelect
+                aura:id="select_productCategories"
+                class="slds-select"
+              />
+            </div>
+            <!-- 浜у搧鐢ㄩ噺   warlocksNumber__c   -->
+            <div
+              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
+            >
+              {!v.fieldsmap.warlocksNumber__c}
+              <!-- <ui:inputText aura:id="select_warlocksNumber" class="slds-select"
+                                change="{!c.select_warlocksNumber}" /> -->
+              <lightning:input
+                type="text"
+                onchange="{!c.select_warlocksNumber}"
+                aura:id="select_warlocksNumber"
+                variant="label-hidden"
+              />
+            </div>
+            <!-- 鏀彺闇�姹�      WorkMark__c-->
+            <div style="padding-left: 12px">
+              {!v.fieldsmap.WorkMark__c}
+              <lightning:input type="checkbox" aura:id="select_WorkMark" />
+            </div>
+            <div
+              aura:id="input-opportunity-stage"
+              class="disp_none slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--2-of-12 slds-large-size--2-of-12"
+            >
+              {!v.fieldsmap.StageName__c}
+              <ui:inputSelect aura:id="select_stageName" class="slds-select" />
+            </div>
+            <div
+              aura:id="input-opportunity-amount1"
+              class="disp_none slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--2-of-12 slds-large-size--2-of-12"
+            >
+              {!v.fieldsmap.Amount__c}
+              <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/>  鍖婚櫌閲囪喘棰勭畻(涓嶅惈绋�,鍏�)-->
+              <lightning:inputField value="{!v.oppdata.Amount__c}" class="" />
+            </div>
+            <div
+              aura:id="input-opportunity-amount2"
+              class="disp_none slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--2-of-12 slds-large-size--2-of-12"
+            >
+              {!v.fieldsmap.OCMSale_Price__c}
+              <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/>  	璁㈣揣閲戦(涓嶅惈绋�,鍏�)  -->
+              <lightning:inputField
+                value="{!v.oppdata.OCMSale_Price__c}"
+                class=""
+              />
+            </div>
+            <div
+              aura:id="input-opportunity-date"
+              class="disp_none slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--2-of-12 slds-large-size--2-of-12"
+            >
+              {!v.fieldsmap.Close_Forecasted_Date__c}
+              <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/>    棰勬祴涓嶰CSM绛剧害鏃� -->
+              <lightning:inputField
+                value="{!v.oppdata.Close_Forecasted_Date__c}"
+                class=""
+              />
+            </div>
+            <hr />
+          </div>
+        </div>
+        <div class="save_button_area">
+          <ui:button
+            aura:id="save_button"
+            label="淇濆瓨骞舵柊寤�"
+            class="save_button slds-button slds-button--brand slds-order--3"
+            press="{!c.save_report}"
+          />
+        </div>
+        <aura:renderIf isTrue="{!v.reports_now_count > 0}">
+          <div class="mt40 slds-box slds-theme--shade">
+            <div class="slds-table--edit_container slds-is-relative">
+              <table
+                class="slds-table slds-table--edit slds-table--bordered slds-table--fixed-layout slds-no-cell-focus"
+                role="grid"
+              >
                 <thead>
-                    <tr class="slds-line-height--reset">
-                        <th class="table_header slds-text-title--caps">
-                        </th>
-                        <th class="table_header slds-text-title--caps">
-                            <span class="slds-truncate" title="Name">{!v.fieldsmap.Person_In_Charge2__c}</span>
-                            <!-- {!v.fieldsmap.Person_In_Charge2__c}  鎷呭綋-->
-                        </th>
-                        <th class="table_header slds-text-title--caps">
-                            <span class="slds-truncate" title="Name">鍖婚櫌</span>
-                        </th>
-                        <th class="table_header slds-text-title--caps">
-                            <span class="slds-truncate" title="Name">{!v.fieldsmap.Department_Cateogy__c}</span>
-                            <!-- {!v.fieldsmap.Department_Cateogy__c}    绉戝-->
-                        </th>
-                        <th class="table_header slds-text-title--caps">
-                            <span class="slds-truncate" title="Name">鍖婚櫌浜哄憳</span>
-                            <!-- {!v.fieldsmap.doctor2__c}    鍖婚櫌浜哄憳 -->
-                        </th>
-                        <th class="table_header slds-text-title--caps">
-                            <span class="slds-truncate" title="Name">{!v.fieldsmap.DealerPersonnel__c}</span>
-                            <!-- {!v.fieldsmap.visitor_title__c}   鑱屼綅-->
-                        </th>
-                    </tr>
+                  <tr class="slds-line-height--reset">
+                    <th class="table_header slds-text-title--caps">
+                      <span class="slds-truncate" title="Name"></span>
+                    </th>
+                    <th class="table_header slds-text-title--caps">
+                      <span class="slds-truncate" title="Name">鍖婚櫌</span>
+                    </th>
+                    <th class="table_header slds-text-title--caps">
+                      <span class="slds-truncate" title="Name"
+                        >{!v.fieldsmap.Department_Cateogy__c}</span
+                      >
+                    </th>
+                    <th class="table_header slds-text-title--caps">
+                      <span class="slds-truncate" title="Name"
+                        >{!v.fieldsmap.doctor2__c}</span
+                      >
+                      <!-- 瀹㈡埛浜哄憳 -->
+                    </th>
+                    <th class="table_header slds-text-title--caps">
+                      <span class="slds-truncate" title="Name"
+                        >{!v.fieldsmap.visitor_title__c}</span
+                      >
+                    </th>
+                    <th class="table_header slds-text-title--caps">
+                      <span class="slds-truncate" title="Name"
+                        >{!v.fieldsmap.WorkRecord__c}</span
+                      >
+                    </th>
+                  </tr>
                 </thead>
                 <tbody>
-                    <aura:iteration items="{!v.reports}" var="item" indexVar="index">
-                        <tr class="slds-hint-parent">
-                            <td role="gridcell" class="slds-cell-edit">
-                                <ui:inputRadio class="report_radio" name="report_radio" label="{!item.Name}"
-                                    change="{!c.change_report_radio}" />
-                                <lightning:buttonIcon class="edit_button" iconName="utility:edit" size="small"
-                                    alternativeText="edit" value="{!index}" onclick="{!c.edit_button}" />
-                            </td>
-                            <td role="gridcell" class="slds-cell-edit">
-                                <span class="slds-grid slds-grid--align-spread">
-                                    <span class="slds-truncate"
-                                        title="{!item.Person_In_Charge2__r.Name}">{!item.Person_In_Charge2__r.Name}</span>
-                                </span>
-                            </td>
-                            <th scope="row" tabindex="0" class="slds-cell-edit">
-                                <span class="slds-grid slds-grid--align-spread">
-                                    {!item.Agency_Hospital__r.Name}
-                                </span>
-                            </th>
-                            <td role="gridcell" class="slds-cell-edit">
-                                <span class="slds-grid slds-grid--align-spread">
-                                    <span class="slds-truncate"
-                                        title="{!item.Department_Cateogy__c}">{!item.Department_Cateogy__c}</span>
-                                </span>
-                            </td>
-                            <td role="gridcell" class="slds-cell-edit">
-                                <span class="slds-grid slds-grid--align-spread">
-                                    <span class="slds-truncate"
-                                        title="{!item.doctor2__r.Name}">
-                                        <span class="encrypt">{!item.doctor2__r.Name}</span>
-                                        <span class="decrypt">{!item.doctor2__r.awsdata.name}</span>
-                                    </span>
-                                </span>
-                            </td>
-                            <td role="gridcell" class="slds-cell-edit">
-                                <span class="slds-grid slds-grid--align-spread">
-                                    <span class="slds-truncate"
-                                        title="{!item.DealerPersonnel__r.Name}">{!item.DealerPersonnel__r.Name}</span>
-                                </span>
-                            </td>
-                        </tr>
-                    </aura:iteration>
+                  <aura:iteration
+                    items="{!v.reports_now}"
+                    var="item"
+                    indexVar="index"
+                  >
+                    <tr aura:id="modal_data_list_tr" class="slds-hint-parent">
+                      <td role="gridcell" class="slds-cell-edit">
+                        <span class="slds-grid slds-grid--align-spread">
+                          <span
+                            class="slds-truncate"
+                            title="{!item.Department_Cateogy_text__c}"
+                            >{!item.Name}</span
+                          >
+                        </span>
+                      </td>
+                      <td role="gridcell" class="slds-cell-edit">
+                        <span class="slds-grid slds-grid--align-spread">
+                          <span
+                            class="slds-truncate"
+                            title="{!item.Agency_Hospital__r.Name}"
+                            >{!item.Agency_Hospital__r.Name}</span
+                          >
+                        </span>
+                      </td>
+                      <td role="gridcell" class="slds-cell-edit">
+                        <span class="slds-grid slds-grid--align-spread">
+                          <span
+                            class="slds-truncate"
+                            title="{!item.Department_Cateogy_text__c}"
+                            >{!item.Department_Cateogy_text__c}</span
+                          >
+                        </span>
+                      </td>
+                      <td role="gridcell" class="slds-cell-edit">
+                        <span class="slds-grid slds-grid--align-spread">
+                          <span
+                            class="slds-truncate"
+                            title="{!item.doctor2__r.Name}"
+                            >{!item.doctor2__r.Name}</span
+                          >
+                        </span>
+                      </td>
+                      <td role="gridcell" class="slds-cell-edit">
+                        <span class="slds-grid slds-grid--align-spread">
+                          <span
+                            class="slds-truncate"
+                            title="{!item.visitor_title__c}"
+                            >{!item.visitor_title__c}</span
+                          >
+                        </span>
+                      </td>
+                      <td role="gridcell" class="slds-cell-edit">
+                        <span class="slds-grid slds-grid--align-spread">
+                          <span
+                            class="slds-truncate"
+                            title="{!item.WorkRecord__c}"
+                            >{!item.WorkRecord__c}</span
+                          >
+                        </span>
+                      </td>
+                    </tr>
+                  </aura:iteration>
                 </tbody>
-            </table>
-        </div>
-        <aura:renderIf isTrue="{!v.report_count > 0}">
-            <aura:set attribute="else">
-                <div class="no_data_area">
-                    {!v.list_message}
-                </div>
-            </aura:set>
+              </table>
+            </div>
+          </div>
         </aura:renderIf>
+      </div>
     </div>
-    <!-- 鎵归噺娣诲姞鍛ㄦ姤 start-->
-    <div aura:id="modal_import" role="dialog" tabindex="-1"
-        class="disp_none slds-modal slds-fade-in-open slds-modal--large" aria-labelledby="headerTarget">
-        <div class="slds-modal slds-fade-in-open slds-hide" aura:id="successDiv01">
-            <ui:inputText aura:id="articleURL" />
-            <div class="demo-only" style="height: 8rem;">
-                <div class="slds-notify_container slds-is-relative">
-                    <div class="slds-notify slds-notify_toast slds-theme_success" role="alert">
-                        <div class=" slds-m-left_xx-large">
-                            <div
-                                class="slds-notify__content slds-m-left_small slds-align_absolute-center slds-m-left_xx-large">
-                                <lightning:icon alternativeText="Success" iconName="utility:success" size="small"
-                                    class="buttonColor slds-m-right_small" />
-                                <h2 class="slds-text-heading_small ">{!v.successMessage}</h2>
-                            </div>
-                        </div>
-                    </div>
-                </div>
-            </div>
-        </div>
-        <div class="slds-modal__container ">
-            <div class="slds-modal__header ">
-                <h4 id="headerTarget" class="slds-float--left"></h4>
-                <h2 id="headerTarget" class="slds-text-heading--medium">鍛ㄦ姤鎵归噺瀵煎叆</h2>
-                <ui:button aura:id="close_button" label="鍏抽棴"
-                    class="close_button slds-button slds-button--neutral slds-order--1" press="{!c.close_import}" />
-            </div>
-            <div class="slds-modal__content slds-scrollable slds-grow slds-p-around--medium ">
-                <aura:if isTrue="{!v.showMain}">
-                    <div>
-                        <lightning:input type="file" class="file" uara:id="file" onchange="{!c.CreateRecord}" />
-                    </div>
-                    <aura:set attribute="else">
-                        <ui:outputRichText class="uiOutputRichText slds-m--around-large" value="{!v.TableContent}" />
-                        <div class="slds-p-around--large slds-align--absolute-center">
-                            <lightning:button label="淇濆瓨" variant="brand" onclick="{!c.processFileContent}" />
-                            <lightning:button label="鍙栨秷" variant="brand" onclick="{!c.cancel}" />
-                        </div>
+  </div>
 
-                    </aura:set>
-                </aura:if>
-            </div>
-        </div>
+  <div
+    aura:id="modal_bg"
+    class="disp_none slds-backdrop slds-backdrop--open"
+  ></div>
+
+  <div
+    aura:id="modal_confirm"
+    role="dialog"
+    tabindex="-2"
+    aria-labelledby="header43"
+    class="disp_none slds-modal slds-fade-in-open"
+  >
+    <div class="slds-modal__container">
+      <div class="slds-modal__header">
+        <h2 id="header43" class="slds-text-heading--medium">
+          {!v.modal_confirm_title}
+        </h2>
+      </div>
+      <div class="slds-modal__content slds-p-around--medium">
+        <p>{!v.modal_confirm_text}</p>
+      </div>
+      <div class="slds-modal__footer">
+        <ui:button
+          label="鏄�"
+          class="slds-button slds-button--brand"
+          press="{!c.yes_button}"
+        />
+        <ui:button
+          label="鍚�"
+          class="slds-button slds-button--neutral"
+          press="{!c.no_button}"
+        />
+      </div>
     </div>
-    <div aura:id="modal_importbg" class="disp_none slds-backdrop slds-backdrop--open"></div>
-    <!-- 鎵归噺娣诲姞鍛ㄦ姤 end-->
+  </div>
+  <div
+    aura:id="modal_confirm_bg"
+    class="disp_none slds-backdrop slds-backdrop--open"
+  ></div>
 
-    <!-- 鎵归噺瀵煎嚭鍛ㄦ姤 start-->
-    <div aura:id="modal_export" role="dialog" tabindex="-1"
-        class="disp_none slds-modal slds-fade-in-open slds-modal--large">
-        <div class="slds-modal__container">
-            <div class="slds-modal__header">
-                <h4 id="headerTarget" class="slds-float--left"></h4>
-                <h2 id="headerTarget" class="slds-text-heading--medium">鍛ㄦ姤鎵归噺瀵煎嚭</h2>
-                <ui:button aura:id="close_button" label="鍏抽棴"
-                    class="close_button slds-button slds-button--neutral slds-order--1" press="{!c.close_export}" />
-            </div>
-            <div class="slds-modal__content slds-scrollable slds-grow slds-p-around--medium">
-                <aura:if isTrue="{!v.showMain}">
-                    <div class="slds-grid slds-wrap slds-grid--pull-padded">
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-4">
-                        </div>
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-4">
-                            娲诲姩鏃ュ紑濮嬫棩鏈�
-                            <lightning:input type="Date" class="slds-input slds-input_bare "
-                                aura:id="input-report-date1" />
-                        </div>
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-4">
-                            娲诲姩鏃ョ粨鏉熸棩鏈�
-                            <lightning:input type="Date" class="slds-input slds-input_bare "
-                                aura:id="input-report-date2" />
-                        </div>
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-4">
-                        </div>
-                        <div class="slds-p-around--large slds-align--absolute-center">
-                            <lightning:button label="纭" variant="brand" onclick="{!c.select_repores_date}" />
-                            <lightning:button label="鍙栨秷" variant="brand" onclick="{!c.close_export}" />
-                        </div>
-                    </div>
-                    <aura:set attribute="else">
-                        <ui:outputRichText class="uiOutputRichText slds-m--around-large" value="{!v.TableContent2}" />
-                        <div class="slds-p-around--large slds-align--absolute-center">
-                            <lightning:button label="纭" variant="brand" onclick="{!c.exportDate}" />
-                            <lightning:button label="鍙栨秷" variant="brand" onclick="{!c.close_export}" />
-                        </div>
-                    </aura:set>
-                </aura:if>
-            </div>
-        </div>
+  <div
+    aura:id="modal_newAC"
+    role="dialog"
+    tabindex="-3"
+    aria-labelledby="headertest"
+    class="disp_none slds-modal slds-fade-in-open"
+  >
+    <div class="slds-modal__container">
+      <div class="slds-modal__header">
+        <h2 id="headertest" class="slds-text-heading--medium">鏂板缓.鎷滆浜�</h2>
+      </div>
+      <div class="slds-modal__content slds-p-around--medium">
+        <lightning:recordEditForm
+          aura:id="recordEditForm"
+          objectApiName="Agency_Contact__c"
+          onsuccess="{!c.handleSuccess}"
+          onload="{!c.showRequiredFields}"
+          onsubmit="{!c.handleSubmit}"
+        >
+          <lightning:messages aura:id="OppMessage" />
+          <!-- onload="{!c.showRequiredFields}" -->
+          <aura:renderIf isTrue="{!v.truthy}">
+            <lightning:inputField
+              fieldName="Name"
+              aura:id="newOpportunityField"
+            />
+            <lightning:inputField
+              fieldName="Type__c"
+              aura:id="newOpportunityField"
+            />
+            <lightning:inputField
+              fieldName="Doctor_Division1__c"
+              aura:id="newOpportunityField"
+            />
+          </aura:renderIf>
+          <br />
+          <br />
+          <br />
+          <br />
+          <br />
+          <div class="save_button_area">
+            <lightning:button
+              class="slds-m-top_small"
+              type="button"
+              label="鍙栨秷"
+              onclick="{!c.createCancel}"
+            />
+            <lightning:button
+              class="slds-m-top_small"
+              type="button"
+              label="淇濆瓨"
+              onclick="{!c.handleSubmit}"
+            />
+          </div>
+        </lightning:recordEditForm>
+      </div>
     </div>
-    <div aura:id="modal_exportbg" class="disp_none slds-backdrop slds-backdrop--open"></div>
-    <!-- 鎵归噺瀵煎嚭鍛ㄦ姤 end-->
-    <div aura:id="modal_window" role="dialog" tabindex="-1"
-        class="disp_none slds-modal slds-fade-in-open slds-modal--large" aria-labelledby="headerTarget">
-        <div class="slds-modal__container">
-            <div class="slds-modal slds-fade-in-open slds-hide" aura:id="successDiv">
-                <ui:inputText aura:id="articleURL" />
-                <div class="demo-only" style="height: 8rem;">
-                    <div class="slds-notify_container slds-is-relative">
-                        <div class="slds-notify slds-notify_toast slds-theme_success" role="alert">
-                            <div class=" slds-m-left_xx-large">
-                                <div
-                                    class="slds-notify__content slds-m-left_small slds-align_absolute-center slds-m-left_xx-large">
-                                    <lightning:icon alternativeText="Success" iconName="utility:success" size="small"
-                                        class="buttonColor slds-m-right_small" />
-                                    <h2 class="slds-text-heading_small ">{!v.successMessage}</h2>
-                                </div>
-                            </div>
-                        </div>
-                    </div>
-                </div>
-            </div>
-            <div class="slds-modal slds-fade-in-open slds-hide" aura:id="errorDiv" style="z-index: 10001">
-                <ui:inputText aura:id="articleURL" />
-                <div class="demo-only" style="height: 8rem;">
-                    <div class="slds-notify_container slds-is-relative">
-                        <div class="slds-notify slds-notify_toast slds-theme_error" role="status">
-                            <div class=" slds-m-left_xx-large">
-                                <div
-                                    class="slds-notify__content slds-m-left_small slds-align_absolute-center slds-m-left_xx-large">
-                                    <lightning:icon alternativeText="error" iconName="utility:error" size="small"
-                                        class="buttonColor slds-m-right_small" />
-                                    <h2 class="slds-text-heading_small ">{!v.errorMessage}</h2>
-                                </div>
-                            </div>
-                        </div>
-                    </div>
-                </div>
-            </div>
-            <div class="slds-modal__header">
-                <h4 id="headerTarget" class="slds-float--left">{!v.dialog_type}</h4>
-                <h2 id="headerTarget" class="slds-text-heading--medium">
-                    鍛ㄦ姤({!v.selected_date}&nbsp;{!v.selected_agency_person})</h2>
-                <ui:button aura:id="close_button" label="鍏抽棴"
-                    class="close_button slds-button slds-button--neutral slds-order--1" press="{!c.toggle_report}" />
-            </div>
-            <div class="slds-modal__content slds-grow slds-p-around--medium">
-                <div class="slds-box slds-theme--shade">
-                    <div class="slds-grid slds-wrap slds-grid--pull-padded">
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6">
-                            娲诲姩鏃�
-                            <lightning:input type="date" value="{!v.data.Report_Date__c}" aura:id="input-report-date" />
-                        </div>
-                        <!-- 鍖婚櫌 -->
-                        <div aura:id="hospital_list"
-                        class="slds-form-element slds-lookup slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
-                            data-select="single">
-                            <lightning:input aura:id="hospital_input_text" label="鍖婚櫌" class="field"
-                                value="{!v.hospital}" updateOn="keyup" />
-                            <div class="slds-lookup__menu" id="lookup-66">
-                                <ul class="slds-lookup__list" role="listbox">
-                                    <aura:iteration var="hospital" items="{!v.hospitalList}">
-                                        <li role="presentation" onclick="{!c.selectHos}"
-                                            data-accName="{!hospital.Hospital_Name_readonly__c}"
-                                            data-accId="{!hospital.Hospital__c}">
-                                            <span class="slds-lookup__item-action slds-media" id="lookup-option-498"
-                                                role="option">
-                                                <div class="slds-media__body">
-                                                    <div class="slds-lookup__result-text">
-                                                        {!hospital.Hospital_Name_readonly__c}</div>
-                                                </div>
-                                            </span>
-                                        </li>
-                                    </aura:iteration>
-                                </ul>
-                            </div>
-                        </div>
-                        <!-- 绉戝鍒嗙被 -->
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6">
-                            {!v.fieldsmap.Department_Cateogy__c}
-                            <ui:inputText aura:id="select_department" class="slds-select"
-                                change="{!c.select_department}" />
-                        </div>
-                        <!-- 缁忛攢鍟嗕汉鍛�  change="{!c.select_DealerPersonnel}" -->
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6">
-                            {!v.fieldsmap.DealerPersonnel__c}
-                            <ui:inputSelect aura:id="select_DealerPersonnel" class="slds-select" />
-                        </div>
-                        <p hidden="hidden">
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-12">
-                            <br />
-                            <ui:button label="鏂板缓" class="slds-button" press="{!c.createCon}" disabled="true"
-                                aura:id="new_con" />
-                        </div>
-                        </p>
-                        <!-- 宸ヤ綔璁板綍   -->
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6">
-                            {!v.fieldsmap.WorkRecord__c}
-                            <ui:inputSelect aura:id="select_purpose_type" class="slds-select"
-                                change="{!c.select_purpose_type}" />
-                        </div>
-                        <!-- 鍖婚櫌浜哄憳 {!v.fieldsmap.doctor2__c}-->
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6">
-                            鍖婚櫌浜哄憳
-                            <ui:inputSelect aura:id="select_doctor" class="slds-select" change="{!c.doctor_change}" />
-                        </div>
-                        <hr />
-                        <!-- 浜у搧鍒嗙被(绗笁鍒嗙被) change="{!c.select_ProductClassification}" -->
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6">
-                            浜у搧鍒嗙被(绗笁鍒嗙被)
-                            <ui:inputSelect aura:id="select_ProductClassification" class="slds-select"
-                                change="{!c.selectProductClassification}" />
-                        </div>
-                        <!-- 浣跨敤浜у搧1(浜у搧鍨嬪彿)   UseProduct1__c  -->
-                        <div aura:id="UseProduct1_List"
-                        class="slds-form-element slds-lookup slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
-                            data-select="single">
-                            <lightning:input aura:id="UseProduct1_TEXT" label="浣跨敤浜у搧1(浜у搧鍨嬪彿)" class="field"
-                                value="{!v.UseProduct1}" updateOn="keyup" />
-                            <div class="slds-lookup__menu" id="lookup-11">
-                                <ul class="slds-lookup__list" role="listbox">
-                                    <aura:iteration var="UseProduct1" items="{!v.UseProduct1List}">
-                                        <li role="presentation" onclick="{!c.seletUseProduct1Change}"
-                                            data-accid="{!UseProduct1.Id}" data-accName="{!UseProduct1.Name}">
-                                            <span class="slds-lookup__item-action slds-media" id="lookup-option-498"
-                                                role="option">
-                                                <div class="slds-media__body">
-                                                    <div class="slds-lookup__result-text">{!UseProduct1.Name}</div>
-                                                </div>
-                                            </span>
-                                        </li>
-                                    </aura:iteration>
-                                </ul>
-                            </div>
-                        </div>
-                        <!-- 浣跨敤浜у搧2   UseProduct2__c  -->
-                        <div aura:id="UseProduct2_List"
-                        class="slds-form-element slds-lookup slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
-                            data-select="single">
-                            <lightning:input aura:id="UseProduct2_TEXT" label="浣跨敤浜у搧2" class="field"
-                                value="{!v.UseProduct2}" updateOn="keyup" />
-                            <div class="slds-lookup__menu" id="lookup-22">
-                                <ul class="slds-lookup__list" role="listbox">
-                                    <aura:iteration var="UseProduct2" items="{!v.UseProduct2List}">
-                                        <li role="presentation" onclick="{!c.seletUseProduct2Change}"
-                                            data-accid="{!UseProduct2.Id}" data-accName="{!UseProduct2.Name}">
-                                            <span class="slds-lookup__item-action slds-media" id="lookup-option-498"
-                                                role="option">
-                                                <div class="slds-media__body">
-                                                    <div class="slds-lookup__result-text">{!UseProduct2.Name}</div>
-                                                </div>
-                                            </span>
-                                        </li>
-                                    </aura:iteration>
-                                </ul>
-                            </div>
-                        </div>
-                        <!-- 浣跨敤浜у搧3   UseProduct3__c  -->
-                        <div aura:id="UseProduct3_List"
-                        class="slds-form-element slds-lookup slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
-                            data-select="single">
-                            <lightning:input aura:id="UseProduct3_TEXT" label="浣跨敤浜у搧3" class="field"
-                                value="{!v.UseProduct3}" updateOn="keyup" />
-                            <div class="slds-lookup__menu" id="lookup-33">
-                                <ul class="slds-lookup__list" role="listbox">
-                                    <aura:iteration var="UseProduct3" items="{!v.UseProduct3List}">
-                                        <li role="presentation" onclick="{!c.seletUseProduct3Change}"
-                                            data-accid="{!UseProduct3.Id}" data-accName="{!UseProduct3.Name}">
-                                            <span class="slds-lookup__item-action slds-media" id="lookup-option-498"
-                                                role="option">
-                                                <div class="slds-media__body">
-                                                    <div class="slds-lookup__result-text">{!UseProduct3.Name}</div>
-                                                </div>
-                                            </span>
-                                        </li>
-                                    </aura:iteration>
-                                </ul>
-                            </div>
-                        </div>
-                        <!-- 鏁堟灉/杩涘害  EffectProgress__c-->
-                        <div aura:id="product_category_select1"
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6">
-                            {!v.fieldsmap.EffectProgress__c}
-                            <ui:inputSelect aura:id="select_EffectProgress" class="slds-select" />
-                        </div>
-                        <hr />
-                        <!-- 绉戝鍚岀被鑰楁潗鏈堜娇鐢ㄩ噺  ConsumptionOfConsumables__c-->
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6">
-                            {!v.fieldsmap.ConsumptionOfConsumables__c}
-                            <ui:inputText aura:id="select_ConsumptionOfConsumables" class="slds-select"
-                                change="{!c.select_ConsumptionOfConsumables}" />
-                        </div>
-                        <!-- 鏈+鍒嗙被   WarlockClassification__c   -->
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6">
-                            {!v.fieldsmap.WarlockClassification__c}
-                            <ui:inputSelect aura:id="select_OtherBrandConsumables" class="slds-select" />
-                        </div>
-                        <!-- 宸查噰鐢ㄥ叾浠栧搧鐗�   ProductCcategory__c -->
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6">
-                            {!v.fieldsmap.ProductCcategory__c}
-                            <ui:inputSelect aura:id="select_ProductCcategory" class="slds-select"
-                                change="{!c.selectpurposetype}" />
-                        </div>
-                        <!-- 鍏朵粬鍝佺墝浜у搧绫诲埆  -->
-                        <div aura:id="result"
-                            class="disp_none slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6">
-                            {!v.fieldsmap.productCategories__c}
-                            <ui:inputSelect aura:id="select_productCategories" class="slds-select" />
-                        </div>
-                        <!-- 浜у搧鐢ㄩ噺   warlocksNumber__c   -->
-                        <div
-                            class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6">
-                            {!v.fieldsmap.warlocksNumber__c}
-                            <ui:inputText aura:id="select_warlocksNumber" class="slds-select"
-                                change="{!c.select_warlocksNumber}" />
-                        </div>
-                        <!-- 宸ヤ綔鏍囪      WorkMark__c-->
-                        <div style="padding-left: 20px;">
-                            {!v.fieldsmap.WorkMark__c}
-                            <lightning:input type="checkbox" aura:id="select_WorkMark" />
-                        </div>
-                        <div aura:id="input-opportunity-stage"
-                            class="disp_none slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--2-of-12 slds-large-size--2-of-12">
-                            {!v.fieldsmap.StageName__c}
-                            <ui:inputSelect aura:id="select_stageName" class="slds-select" />
-                        </div>
-                        <div aura:id="input-opportunity-amount1"
-                            class="disp_none slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--2-of-12 slds-large-size--2-of-12">
-                            {!v.fieldsmap.Amount__c}
-                            <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/>  鍖婚櫌閲囪喘棰勭畻(涓嶅惈绋�,鍏�)-->
-                            <lightning:inputField value="{!v.oppdata.Amount__c}" class="" />
-
-                        </div>
-                        <div aura:id="input-opportunity-amount2"
-                            class="disp_none slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--2-of-12 slds-large-size--2-of-12">
-                            {!v.fieldsmap.OCMSale_Price__c}
-                            <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/>  	璁㈣揣閲戦(涓嶅惈绋�,鍏�)  -->
-                            <lightning:inputField value="{!v.oppdata.OCMSale_Price__c}" class="" />
-                        </div>
-                        <div aura:id="input-opportunity-date"
-                            class="disp_none slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--2-of-12 slds-large-size--2-of-12">
-                            {!v.fieldsmap.Close_Forecasted_Date__c}
-                            <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/>    棰勬祴涓嶰CSM绛剧害鏃� -->
-                            <lightning:inputField value="{!v.oppdata.Close_Forecasted_Date__c}" class="" />
-                        </div>
-                        <hr />
-                    </div>
-                </div>
-                <div class="save_button_area">
-                    <ui:button aura:id="save_button" label="淇濆瓨骞舵柊寤�"
-                        class="save_button slds-button slds-button--brand slds-order--3" press="{!c.save_report}" />
-                </div>
-                <aura:renderIf isTrue="{!v.reports_now_count > 0}">
-                    <div class="mt40 slds-box slds-theme--shade">
-                        <div class="slds-table--edit_container slds-is-relative">
-                            <table
-                                class="slds-table slds-table--edit slds-table--bordered slds-table--fixed-layout slds-no-cell-focus"
-                                role="grid">
-                                <thead>
-                                    <tr class="slds-line-height--reset">
-                                        <th class="table_header slds-text-title--caps">
-                                            <span class="slds-truncate" title="Name"></span>
-                                        </th>
-                                        <th class="table_header slds-text-title--caps">
-                                            <span class="slds-truncate" title="Name">鍖婚櫌</span>
-                                        </th>
-                                        <th class="table_header slds-text-title--caps">
-                                            <span class="slds-truncate"
-                                                title="Name">{!v.fieldsmap.Department_Cateogy__c}</span>
-                                        </th>
-                                        <th class="table_header slds-text-title--caps">
-                                            <span class="slds-truncate" title="Name">{!v.fieldsmap.doctor2__c}</span>
-                                            <!-- 瀹㈡埛浜哄憳 -->
-                                        </th>
-                                        <th class="table_header slds-text-title--caps">
-                                            <span class="slds-truncate"
-                                                title="Name">{!v.fieldsmap.visitor_title__c}</span>
-                                        </th>
-                                        <th class="table_header slds-text-title--caps">
-                                            <span class="slds-truncate" title="Name">{!v.fieldsmap.WorkRecord__c}</span>
-                                        </th>
-                                    </tr>
-                                </thead>
-                                <tbody>
-                                    <aura:iteration items="{!v.reports_now}" var="item" indexVar="index">
-                                        <tr aura:id="modal_data_list_tr" class="slds-hint-parent">
-                                            <td role="gridcell" class="slds-cell-edit">
-                                                <span class="slds-grid slds-grid--align-spread">
-                                                    <span class="slds-truncate"
-                                                        title="{!item.Department_Cateogy__c}">{!item.Name}</span>
-                                                </span>
-                                            </td>
-                                            <td role="gridcell" class="slds-cell-edit">
-                                                <span class="slds-grid slds-grid--align-spread">
-                                                    <span class="slds-truncate"
-                                                        title="{!item.Agency_Hospital__r.Name}">{!item.Agency_Hospital__r.Name}</span>
-                                                </span>
-                                            </td>
-                                            <td role="gridcell" class="slds-cell-edit">
-                                                <span class="slds-grid slds-grid--align-spread">
-                                                    <span class="slds-truncate"
-                                                        title="{!item.Department_Cateogy__c}">{!item.Department_Cateogy__c}</span>
-                                                </span>
-                                            </td>
-                                            <td role="gridcell" class="slds-cell-edit">
-                                                <span class="slds-grid slds-grid--align-spread">
-                                                    <span class="slds-truncate"
-                                                        title="{!item.doctor2__r.Name}">{!item.doctor2__r.Name}</span>
-                                                </span>
-                                            </td>
-                                            <td role="gridcell" class="slds-cell-edit">
-                                                <span class="slds-grid slds-grid--align-spread">
-                                                    <span class="slds-truncate"
-                                                        title="{!item.visitor_title__c}">{!item.visitor_title__c}</span>
-                                                </span>
-                                            </td>
-                                            <td role="gridcell" class="slds-cell-edit">
-                                                <span class="slds-grid slds-grid--align-spread">
-                                                    <span class="slds-truncate"
-                                                        title="{!item.WorkRecord__c}">{!item.WorkRecord__c}</span>
-                                                </span>
-                                            </td>
-                                        </tr>
-                                    </aura:iteration>
-                                </tbody>
-                            </table>
-                        </div>
-                    </div>
-                </aura:renderIf>
-            </div>
-        </div>
-    </div>
-
-
-
-    <div aura:id="modal_bg" class="disp_none slds-backdrop slds-backdrop--open"></div>
-
-    <div aura:id="modal_confirm" role="dialog" tabindex="-2" aria-labelledby="header43"
-        class="disp_none slds-modal slds-fade-in-open">
-        <div class="slds-modal__container">
-            <div class="slds-modal__header">
-                <h2 id="header43" class="slds-text-heading--medium">{!v.modal_confirm_title}</h2>
-            </div>
-            <div class="slds-modal__content slds-p-around--medium">
-                <p>{!v.modal_confirm_text}</p>
-            </div>
-            <div class="slds-modal__footer">
-                <ui:button label="鏄�" class="slds-button slds-button--brand" press="{!c.yes_button}" />
-                <ui:button label="鍚�" class="slds-button slds-button--neutral" press="{!c.no_button}" />
-            </div>
-        </div>
-    </div>
-    <div aura:id="modal_confirm_bg" class="disp_none slds-backdrop slds-backdrop--open"></div>
-
-    <div aura:id="modal_newAC" role="dialog" tabindex="-3" aria-labelledby="headertest"
-        class="disp_none slds-modal slds-fade-in-open">
-        <div class="slds-modal__container">
-            <div class="slds-modal__header">
-                <h2 id="headertest" class="slds-text-heading--medium">鏂板缓.瀹㈡埛浜哄憳</h2>
-            </div>
-            <div class="slds-modal__content slds-p-around--medium">
-                <lightning:recordEditForm aura:id="recordEditForm" objectApiName="Agency_Contact__c"
-                    onsuccess="{!c.handleSuccess}" onload="{!c.showRequiredFields}" onsubmit="{!c.handleSubmit}">
-                    <lightning:messages aura:id="OppMessage" />
-                    <!-- onload="{!c.showRequiredFields}" -->
-                    <aura:renderIf isTrue="{!v.truthy}">
-                        <lightning:inputField fieldName="Name" aura:id="newOpportunityField" />
-                        <lightning:inputField fieldName="Type__c" aura:id="newOpportunityField" />
-                        <lightning:inputField fieldName="Doctor_Division1__c" aura:id="newOpportunityField" />
-                    </aura:renderIf>
-                    <br />
-                    <br />
-                    <br />
-                    <br />
-                    <br />
-                    <div class="save_button_area">
-                        <lightning:button class="slds-m-top_small" type="button" label="鍙栨秷"
-                            onclick="{!c.createCancel}" />
-                        <lightning:button class="slds-m-top_small" type="button" label="鏂板缓"
-                            onclick="{!c.handleSubmit}" />
-                    </div>
-                </lightning:recordEditForm>
-            </div>
-        </div>
-    </div>
-
-
-</aura:component>
\ No newline at end of file
+  </div>
+</aura:component>
diff --git a/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportController.js b/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportController.js
index c0f7ade..aa2e5ce 100644
--- a/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportController.js
+++ b/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportController.js
@@ -1,242 +1,389 @@
 ({
-    doInit : function(component, event, helper) {
-            helper.doinit(component, event, helper);
-    },
+  doInit: function (component, event, helper) {
+    helper.doinit(component, event, helper);
+    component.set("v.errorColumns", [
+      {
+        label: "閿欒琛�",
+        fieldName: "errorRow",
+        type: "text",
+        hideDefaultActions: true,
+        initialWidth: 100
+      },
+      {
+        label: "閿欒淇℃伅",
+        fieldName: "errorInfo",
+        type: "text",
+        hideDefaultActions: true
+      }
+    ]);
+  },
 
-    createAopp : function(component, event, helper) {
-        var addRecordEvent = $A.get('e.force:createRecord');
-        addRecordEvent.setParams({
-            entityApiName: 'Agency_Opportunity__c',
-            recordTypeId: '012100000006KW7'
-        });
-        addRecordEvent.fire();
-    },
-    
-    new_report : function(component, event, helper) {
-        component.find('save_button').set('v.label', '淇濆瓨骞舵柊寤�');
-        helper.new_report(component, event, helper);
-    },
-    
-    copy_button : function(component, event, helper) {
-        component.find('save_button').set('v.label', '淇濆瓨骞舵柊寤�');
-        helper.copy_button(component, event, helper);
-    },
-    
-    change_report_radio : function(component, event, helper) {
-        helper.change_report_radio(component, event, helper);
-    },
-    
-    edit_button : function(component, event, helper) {
-        component.find('save_button').set('v.label', '淇濆瓨');
-        helper.edit_button(component, event, helper);
-    },
-    
-    createCon : function(component, event, helper) {
-		helper.createCon(component, event, helper);
-    },
+  createAopp: function (component, event, helper) {
+    var addRecordEvent = $A.get("e.force:createRecord");
+    addRecordEvent.setParams({
+      entityApiName: "Agency_Opportunity__c",
+      recordTypeId: "012100000006KW7"
+    });
+    addRecordEvent.fire();
+  },
 
-    showRequiredFields: function(component, event, helper){
-        $A.util.removeClass(component.find("newOpportunityField"), "none");
-        $A.util.removeClass(component.find("newOpportunityField"), "none");
-    },
-    
-    handleSuccess : function(component, event, helper) {
-        helper.handleSuccess(component, event, helper);
-    },
-    
-    handleSubmit : function(component, event, helper) {
-        event.preventDefault(); // stop form submission
-        var showValidationError = false;
-        var fields = component.find("newOpportunityField");
-        var vaildationFailReason = '';
-        fields.forEach(function (field) {
-            if(field.get("v.fieldName") === 'Type__c' && $A.util.isEmpty(field.get("v.value"))){
-                showValidationError = true;
-                vaildationFailReason = "鍒嗙被涓嶈兘涓虹┖锛�";
-            }else if(field.get("v.fieldName") === 'Doctor_Division1__c' && $A.util.isEmpty(field.get("v.value"))){
-                showValidationError = true;
-                if(vaildationFailReason != ''){
-                    vaildationFailReason += "鍖荤敓鍖哄垎(鑱屽姟)涓嶈兘涓虹┖锛�";
-                }else{
-                    vaildationFailReason = "鍖荤敓鍖哄垎(鑱屽姟)涓嶈兘涓虹┖锛�";
-                }
-                
-            }
-        });
-        if (!showValidationError) {
-            helper.newlyBuild(component, event, helper);
-        }else{
-            component.find('OppMessage').setError(vaildationFailReason);
+  new_report: function (component, event, helper) {
+    component.find("save_button").set("v.label", "淇濆瓨骞舵柊寤�");
+    helper.new_report(component, event, helper);
+  },
+
+  copy_button: function (component, event, helper) {
+    component.find("save_button").set("v.label", "淇濆瓨骞舵柊寤�");
+    helper.copy_button(component, event, helper);
+  },
+  delete_button: function (component, event, helper) {
+    helper.delete_button(component, event, helper);
+  },
+  change_report_radio: function (component, event, helper) {
+    helper.change_report_radio(component, event, helper);
+  },
+
+  edit_button: function (component, event, helper) {
+    component.find("save_button").set("v.label", "淇濆瓨");
+    helper.edit_button(component, event, helper);
+  },
+
+  createCon: function (component, event, helper) {
+    helper.createCon(component, event, helper);
+  },
+
+  showRequiredFields: function (component, event, helper) {
+    $A.util.removeClass(component.find("newOpportunityField"), "none");
+    $A.util.removeClass(component.find("newOpportunityField"), "none");
+  },
+
+  handleSuccess: function (component, event, helper) {
+    helper.handleSuccess(component, event, helper);
+  },
+
+  handleSubmit: function (component, event, helper) {
+    event.preventDefault(); // stop form submission
+    var showValidationError = false;
+    var fields = component.find("newOpportunityField");
+    var vaildationFailReason = "";
+    let agencyReport = Object.create(null);
+    fields.forEach(function (field) {
+      if (
+        field.get("v.fieldName") === "Type__c" &&
+        $A.util.isEmpty(field.get("v.value"))
+      ) {
+        showValidationError = true;
+        vaildationFailReason = "鍒嗙被涓嶈兘涓虹┖锛�";
+      } else if (
+        field.get("v.fieldName") === "Doctor_Division1__c" &&
+        $A.util.isEmpty(field.get("v.value"))
+      ) {
+        showValidationError = true;
+        if (vaildationFailReason != "") {
+          vaildationFailReason += "鍖荤敓鍖哄垎(鑱屽姟)涓嶈兘涓虹┖锛�";
+        } else {
+          vaildationFailReason = "鍖荤敓鍖哄垎(鑱屽姟)涓嶈兘涓虹┖锛�";
         }
-    },
-    
-    createCancel : function(component, event, helper) {
-        helper.createCancel(component, event, helper);
-    },
-    
-    yes_button : function(component, event, helper) {
-        component.set('v.confirm_status', 1);
-        helper.close_confirm(component, component.get('v.modal_confirm_title'), component.get('v.modal_confirm_text'));
-    },
+      }
+      //SWAG-CF58C3 fy start
+      if (field.get("v.fieldName") === "Name") {
+        agencyReport["name"] = field.get("v.value");
+      } else if (field.get("v.fieldName") === "Type__c") {
+        agencyReport["type"] = field.get("v.value");
+      } else if (field.get("v.fieldName") === "Doctor_Division1__c") {
+        agencyReport["doctorDivision1"] = field.get("v.value");
+      }
+      //SWAG-CF58C3 fy end
+    });
+    if (!showValidationError) {
+      //SWAG-CF58C3 fy start
+      var agencyHospitalid = component.get("v.hospitalLinkId");
+      //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+      debugger;
+      let hospitalName = "";
+      //璋冪敤鍚庣searchAgencyDataId鏂规硶鏌ヨ鍑哄尰闄笅闈㈡墍鏈夊鎴蜂汉鍛榙ataid
+      helper.CallBackAction(
+        component,
+        "searchAgencyDataId",
+        {
+          hospitalId: agencyHospitalid
+        },
+        function (data) {
+          if (data.getState() == "SUCCESS") {
+            var data = data.getReturnValue();
+            if (data.IsSuccess == true) {
+              let agencyContactIds = "";
+              if (data.Message == "" && data.Data && data.Data.length > 0) {
+                hospitalName = data.Data[0].Agency_Hospital__r.Name;
+                for (var i = 0; i < data.Data.length; i++) {
+                  if (data.Data[i].AWS_Data_Id__c)
+                    agencyContactIds += "," + data.Data[i].AWS_Data_Id__c;
+                }
+                agencyContactIds = agencyContactIds.substring(1);
+                agencyReport["agencyContactIds"] = agencyContactIds;
+              } else {
+                agencyReport["agencyContactIds"] = agencyContactIds;
+              }
+              var arr = new Array();
+              arr.push(agencyReport);
+              var requestData = JSON.stringify(arr);
+              // helper.set_aws_url(component,data,agencyHospitalid);
 
-    no_button : function(component, event, helper) {
-        component.set('v.confirm_status', 2);
-        helper.close_confirm(component, component.get('v.modal_confirm_title'), component.get('v.modal_confirm_text'));
-    },
-    
-    toggle_report : function(component, event, helper) {
-        helper.toggle_report(component, event, helper);
-    },
+              var token = component.get("v.AWStoken");
+              var newUrl = component.get("v.AWSinsert") + "V2";
 
-    save_report : function(component, event, helper) {
-        helper.save_report(component, event, helper);
-    },
-    
-    select_date_change : function(component, event, helper) {
-        helper.select_date_change(component, event, helper);
-    },
-    
-    select_agency_change : function(component, event, helper) {
-        helper.select_agency_change(component, event, helper);
-    },
-    
-    hosChange : function(component, event, helper) {
-		var hospital_name = event.getParam("value");
-		if (hospital_name.match(/(\S+\s)+/)) {
-			helper.searchHos(component, event, helper);
-		} else {
-			helper.hideSearch(component, event, helper);
-		}
-    },
-    selectHos : function(component, event, helper) {
-		helper.selectHos(component, event, helper);
-        helper.setOpportunity_cfilter(component);
-    },
-    //浣跨敤浜у搧1
-    UseProduct1Change : function(component, event, helper) {
-		var UseProduct1Name = event.getParam("value");
-		if (UseProduct1Name.match(/(\S+\s)+/)) {
-			helper.searchUseProduct1(component, event, helper);
-		} else {
-			helper.hideSearchUseProduct1(component, event, helper);
-		}
-    },
-    seletUseProduct1Change : function(component, event, helper) {
-		helper.seletUseProduct1Change(component, event, helper);
-    },
-     //浣跨敤浜у搧2
-    UseProduct2Change : function(component, event, helper) {
-		var UseProduct2Name = event.getParam("value");
-		if (UseProduct2Name.match(/(\S+\s)+/)) {
-			helper.searchUseProduct2(component, event, helper);
-		} else {
-			helper.hideSearchUseProduct2(component, event, helper);
-		}
-    },
-    seletUseProduct2Change : function(component, event, helper) {
-		helper.seletUseProduct2Change(component, event, helper);
-    },
-    productcategoryChange2 : function(component, event, helper) {
-		helper.productcategoryChange2(component, event, helper);
-    },
-    //浣跨敤浜у搧3
-    UseProduct3Change : function(component, event, helper) {
-		var UseProduct3Name = event.getParam("value");
-		if (UseProduct3Name.match(/(\S+\s)+/)) {
-			helper.searchUseProduct3(component, event, helper);
-		} else {
-			helper.hideSearchUseProduct3(component, event, helper);
-		}
-    },
-    seletUseProduct3Change : function(component, event, helper) {
-		helper.seletUseProduct3Change(component, event, helper);
-    },
-    
-    
-    select_department : function(component, event, helper) {
-        helper.setOpportunity_cfilter(component);
-    },
-    doctor_change : function(component, event, helper) {
-        helper.doctor_change(component, event, helper);
-    },
-    stageNameChange : function(component, event, helper) {
-        helper.stageNameChange(component, event, helper);
-    },
-    onDragOver : function(component, event, helper) {
-        event.preventDefault();
-    },
-    
-    onDrop : function(component, event, helper) {
-        event.stopPropagation();
-        event.preventDefault();
-        event.dataTransfer.dropEffect='copy';
-        var files=event.dataTransfer.files;
-        helper.readFile(component,helper,files[0]);
-    },
-    CreateRecord : function(component, event, helper){
-        var files = event.getSource().get("v.files");
-        helper.readFile(component,helper,files[0]);
-    },
-
-    processFileContent : function(component,event,helper){
-        helper.saveRecords(component,event,helper);
-    },
-    
-    cancel : function(component,event,helper){
-        component.set("v.showMain",true);
-    },
-
-    import : function(component,event,helper){
-        helper.showImport(component);
-    },
-    exportDate : function(component,event,helper){
-        var stockData = component.get("v.reports_date");
-        console.log('瀵煎嚭鏁版嵁'+stockData); 
-        var csv = helper.convertArrayOfObjectsToCSV(component,stockData);
-        if (csv == null){return;} 
-
-        var universalBOM = "\uFEFF";
-        var hiddenElement = document.createElement('a');
-        hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(universalBOM+csv);
-        hiddenElement.target = '_self'; // 
-        hiddenElement.download = 'ExportData.csv';  // CSV file Name* you can change it.[only name not .csv] 
-        document.body.appendChild(hiddenElement); // Required for FireFox browser
-        hiddenElement.click(); // using click() js function to download csv file
-        
-    },
-    export_condition : function(component,event,helper){
-        helper.showExport(component);
-    },
-
-    select_repores_date : function(component,event,helper){
-        helper.select_repores_date(component,event,helper);
-    },
-    export : function(component,event,helper){
-        console.log('杩涘叆export');
-        var stockData = component.get("v.reports_date");
-        console.log('鏌ュ嚭鐨勬暟鎹�'+stockData);
-    },
-    close_import : function(component,event,helper){
-        component.set("v.showMain",true);
-        helper.close_import(component);
-    },
-    close_export : function(component,event,helper){
-        component.set("v.showMain",true);
-        helper.close_export(component);
-    },
-    select_ConsumptionOfConsumables : function(component,event,helper){
-        helper.select_ConsumptionOfConsumables(component,event,helper);
-    },
-    select_purpose_type : function(component,event,helper){
-        helper.selectPurposeType(component,event,helper);
-    },
-    select_warlocksNumber : function(component,event,helper){
-        helper.select_warlocksNumber(component,event,helper);
-    }, 
-    selectProductClassification : function(component,event,helper){
-        helper.selectProductClassification(component,event,helper);
-    },
-    selectpurposetype : function(component,event,helper){
-        helper.selectpurposetype(component,event,helper);
+              component.set("v.login", true);
+              helper.insert_agencycontact(
+                component,
+                token,
+                newUrl,
+                requestData,
+                agencyHospitalid,
+                helper,
+                hospitalName
+              );
+            } else {
+              helper.ShowToast({
+                message: data.message,
+                type: "error"
+              });
+            }
+          } else {
+            helper.ShowToast({
+              message: "searchAgency澶辫触",
+              type: "error"
+            });
+          }
+        }
+      );
+      //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
+      // var arr = new Array();
+      // arr.push(agencyReport);
+      // var data = JSON.stringify(arr);
+      // var token = component.get('v.AWStoken');
+      // var newUrl = component.get('v.AWSinsert');
+      // component.set('v.login',true);
+      // helper.insert_agencycontact(component,token,newUrl,data,agencyHospitalid,helper);
+      //SWAG-CF58C3 fy end
+      // helper.newlyBuild(component, event, helper);
+    } else {
+      component.find("OppMessage").setError(vaildationFailReason);
     }
-})
\ No newline at end of file
+  },
+
+  createCancel: function (component, event, helper) {
+    helper.createCancel(component, event, helper);
+  },
+
+  yes_button: function (component, event, helper) {
+    component.set("v.confirm_status", 1);
+    helper.close_confirm(
+      component,
+      component.get("v.modal_confirm_title"),
+      component.get("v.modal_confirm_text")
+    );
+  },
+
+  no_button: function (component, event, helper) {
+    component.set("v.confirm_status", 2);
+    helper.close_confirm(
+      component,
+      component.get("v.modal_confirm_title"),
+      component.get("v.modal_confirm_text")
+    );
+  },
+
+  toggle_report: function (component, event, helper) {
+    helper.toggle_report(component, event, helper);
+  },
+
+  save_report: function (component, event, helper) {
+    helper.save_report(component, event, helper);
+  },
+
+  select_date_change: function (component, event, helper) {
+    helper.select_date_change(component, event, helper);
+  },
+
+  select_agency_change: function (component, event, helper) {
+    debugger;
+    helper.select_agency_change(component, event, helper);
+  },
+
+  hosChange: function (component, event, helper) {
+    var hospital_name = event.getParam("value");
+    var hospital_nameld = component.get("v.UseProduct1s");
+    if (hospital_name.match(/(\S+\s)+/)) {
+      if (hospital_nameld != hospital_name) {
+        helper.searchHos(component, event, helper);
+      }
+    } else {
+      if (hospital_name == "") {
+        helper.hideSearchs(component, event, helper);
+      } else {
+        helper.hideSearch(component, event, helper);
+      }
+    }
+  },
+  selectHos: function (component, event, helper) {
+    helper.selectHos(component, event, helper);
+    helper.setOpportunity_cfilter(component);
+  },
+  //浣跨敤浜у搧1
+  UseProduct1Change: function (component, event, helper) {
+    var UseProduct1Name = event.getParam("value");
+    var UseProduct1Nameold = component.get("v.UseProduct1s");
+    debugger;
+    if (UseProduct1Name.match(/(\S+\s)+/)) {
+      if (UseProduct1Name != UseProduct1Nameold) {
+        helper.searchUseProduct1(component, event, helper);
+      }
+    } else {
+      if (UseProduct1Name == "") {
+        helper.hideSearchUseProduct1s(component, event, helper);
+      } else {
+        helper.hideSearchUseProduct1(component, event, helper);
+      }
+    }
+  },
+  seletUseProduct1Change: function (component, event, helper) {
+    helper.seletUseProduct1Change(component, event, helper);
+  },
+  //浣跨敤浜у搧2
+  UseProduct2Change: function (component, event, helper) {
+    var UseProduct2Name = event.getParam("value");
+    var UseProduct2Nameold = component.get("v.UseProduct2s");
+    if (UseProduct2Name.match(/(\S+\s)+/)) {
+      if (UseProduct2Name != UseProduct2Nameold) {
+        helper.searchUseProduct2(component, event, helper);
+      }
+    } else {
+      if (UseProduct2Name == "") {
+        helper.hideSearchUseProduct2s(component, event, helper);
+      } else {
+        helper.hideSearchUseProduct2(component, event, helper);
+      }
+    }
+  },
+  seletUseProduct2Change: function (component, event, helper) {
+    helper.seletUseProduct2Change(component, event, helper);
+  },
+  productcategoryChange2: function (component, event, helper) {
+    helper.productcategoryChange2(component, event, helper);
+  },
+  //浣跨敤浜у搧3
+  UseProduct3Change: function (component, event, helper) {
+    var UseProduct3Name = event.getParam("value");
+    var UseProduct3Nameold = component.get("v.UseProduct3s");
+    if (UseProduct3Name.match(/(\S+\s)+/)) {
+      if (UseProduct3Name != UseProduct3Nameold) {
+        helper.searchUseProduct3(component, event, helper);
+      }
+    } else {
+      if (UseProduct3Name == "") {
+        helper.hideSearchUseProduct3s(component, event, helper);
+      } else {
+        helper.hideSearchUseProduct3(component, event, helper);
+      }
+    }
+  },
+  seletUseProduct3Change: function (component, event, helper) {
+    helper.seletUseProduct3Change(component, event, helper);
+  },
+
+  select_department: function (component, event, helper) {
+    helper.setOpportunity_cfilter(component);
+  },
+  doctor_change: function (component, event, helper) {
+    helper.doctor_change(component, event, helper);
+  },
+  stageNameChange: function (component, event, helper) {
+    helper.stageNameChange(component, event, helper);
+  },
+  onDragOver: function (component, event, helper) {
+    event.preventDefault();
+  },
+
+  onDrop: function (component, event, helper) {
+    event.stopPropagation();
+    event.preventDefault();
+    event.dataTransfer.dropEffect = "copy";
+    var files = event.dataTransfer.files;
+    helper.readFile(component, helper, files[0]);
+  },
+  CreateRecord: function (component, event, helper) {
+    var files = event.getSource().get("v.files");
+    helper.readFile(component, helper, files[0]);
+  },
+
+  processFileContent: function (component, event, helper) {
+    helper.saveRecords(component, event, helper);
+    component.set("v.showErrorInfo", false);
+  },
+
+  cancel: function (component, event, helper) {
+    component.set("v.showMain", true);
+  },
+
+  import: function (component, event, helper) {
+    helper.showImport(component);
+  },
+  exportDate: function (component, event, helper) {
+    var stockData = component.get("v.reports_date");
+    console.log("瀵煎嚭鏁版嵁" + stockData);
+    var csv = helper.convertArrayOfObjectsToCSV(component, stockData);
+    if (csv == null) {
+      return;
+    }
+
+    var universalBOM = "\uFEFF";
+    var hiddenElement = document.createElement("a");
+    hiddenElement.href =
+      "data:text/csv;charset=utf-8," + encodeURI(universalBOM + csv);
+    hiddenElement.target = "_self"; //
+    hiddenElement.download = "ExportData.csv"; // CSV file Name* you can change it.[only name not .csv]
+    document.body.appendChild(hiddenElement); // Required for FireFox browser
+    hiddenElement.click(); // using click() js function to download csv file
+  },
+  export_condition: function (component, event, helper) {
+    helper.showExport(component);
+  },
+
+  select_repores_date: function (component, event, helper) {
+    helper.select_repores_date(component, event, helper);
+  },
+  export: function (component, event, helper) {
+    console.log("杩涘叆export");
+    var stockData = component.get("v.reports_date");
+    console.log("鏌ュ嚭鐨勬暟鎹�" + stockData);
+  },
+  close_import: function (component, event, helper) {
+    component.set("v.showMain", true);
+    helper.close_import(component);
+  },
+  close_export: function (component, event, helper) {
+    component.set("v.showMain", true);
+    helper.close_export(component);
+  },
+  select_ConsumptionOfConsumables: function (component, event, helper) {
+    helper.select_ConsumptionOfConsumables(component, event, helper);
+  },
+  select_purpose_type: function (component, event, helper) {
+    helper.selectPurposeType(component, event, helper);
+  },
+  select_warlocksNumber: function (component, event, helper) {
+    helper.select_warlocksNumber(component, event, helper);
+  },
+  selectProductClassification: function (component, event, helper) {
+    helper.selectProductClassification(component, event, helper);
+  },
+  selectpurposetype: function (component, event, helper) {
+    helper.selectpurposetype(component, event, helper);
+  },
+  return_main_page: function (component, event, helper) {
+    window.open("/customer/", "_self");
+  },
+  exportErrorInfo: function (component, event, helper) {
+    helper.exportErrorInfoHelper(component);
+  }
+});
diff --git a/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportHelper.js b/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportHelper.js
index 993f485..aebf55e 100644
--- a/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportHelper.js
+++ b/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportHelper.js
@@ -1,1900 +1,3303 @@
 ({
-    doinit: function (component, event, helper) {
-        debugger
-        this.report_date_list(component, event, helper, 5);
-        component.set('v.login', true);
-        var action = component.get('c.getalldata');
-        action.setCallback(this, function (response) {
-            var state = response.getState();
-            if (state == 'SUCCESS') {    
-                var res = response.getReturnValue();
-                component.set('v.alldata', res.reports);
-                component.set('v.fieldsmap', res.fieldsMap);
-                component.set('v.allselectlist', res.allselectlist);
-                component.set('v.doclist', res.doclist);
-                //fy
-                debugger
-                var xx=res.UserProType;
-                component.set('v.UserProType', res.UserProType);
-                var gg=component.get('v.UserProType');
-                //fy
-                component.find('select_agency_person').set('v.options', this.conv_selected(res.allselectlist.AgencyPerson__c));
-                component.find('select_DealerPersonnel').set('v.options', this.conv_selected(res.allselectlist.DealerPersonnel__c));
-                component.find('select_purpose_type').set('v.options', this.conv_selected(res.allselectlist.WorkRecord__c));
-                component.find('select_ProductClassification').set('v.options', this.conv_selected(res.allselectlist.ProductClassification__c));
-                component.find('select_stageName').set('v.options', this.conv_selected(res.allselectlist.StageName__c));
-                component.set('v.selected_agency_person', res.allselectlist.AgencyPerson__c[0].label);
-                component.set('v.dialog_type', '鏂板缓');
-                this.get_reports(component, event, helper, component.find('select_date').get('v.value'), component.find('select_agency_person').get('v.value'));
-                
-                component.set('v.PIConfig', res.PIConfig);// 20220222 PI鏀归�� by Bright
-                component.set('v.login', false);
-            }
-            else {
-                component.set('v.errorMessage', 'doinit failed.');
-                this.showErrorToast(component);
-                component.set('v.login', false);
-            }
-        });
-        $A.enqueueAction(action);
-    },
-    //鍏朵粬鍝佺墝浜у搧绫诲埆 涓嬫媺妗嗚祴鍊�
-    selectProductCcategory : function(component){
-        var select_ProductClassification = component.find('select_ProductClassification').get('v.value');
-        if(select_ProductClassification != ''){
-        var action = component.get('c.selectProductCcategory');
-        action.setCallback(this,function( response){
-            var state = response.getState();
-            if (state == 'SUCCESS') {   
-                var res = response.getReturnValue();
-                component.find('select_ProductCcategory').set('v.options', JSON.parse(JSON.stringify(res)));
-            }
-        });
-        $A.enqueueAction(action);
-    }else{
-        component.find('select_ProductCcategory').set('v.options', []);
+  doinit: function (component, event, helper) {
+    document.title = "杩芥函鏃ユ姤";
+    debugger;
+    this.report_date_list(component, event, helper, 5);
+    component.set("v.login", true);
+    var action = component.get("c.getalldata");
+    action.setCallback(this, function (response) {
+      var state = response.getState();
+      if (state == "SUCCESS") {
+        var res = response.getReturnValue();
+        component.set("v.alldata", res.reports);
+        component.set("v.fieldsmap", res.fieldsMap);
+        component.set("v.allselectlist", res.allselectlist);
+        component.set("v.doclist", res.doclist);
+        //fy
+        debugger;
+        var xx = res.UserProType;
+        component.set("v.UserProType", res.UserProType);
+        var gg = component.get("v.UserProType");
+        //fy
+        component
+          .find("select_agency_person")
+          .set(
+            "v.options",
+            this.conv_selected(res.allselectlist.AgencyPerson__c)
+          );
+        component
+          .find("select_DealerPersonnel")
+          .set(
+            "v.options",
+            this.conv_selected(res.allselectlist.DealerPersonnel__c)
+          );
+        component
+          .find("select_purpose_type")
+          .set(
+            "v.options",
+            this.conv_selected(res.allselectlist.WorkRecord__c)
+          );
+        component
+          .find("select_ProductClassification")
+          .set(
+            "v.options",
+            this.conv_selected(res.allselectlist.ProductClassification__c)
+          );
+        component
+          .find("select_stageName")
+          .set("v.options", this.conv_selected(res.allselectlist.StageName__c));
+        component.set(
+          "v.selected_agency_person",
+          res.allselectlist.AgencyPerson__c[0].label
+        );
+        component.set("v.dialog_type", "鏂板缓");
+        this.get_reports(
+          component,
+          event,
+          helper,
+          component.find("select_date").get("v.value"),
+          component.find("select_agency_person").get("v.value")
+        );
+
+        component.set("v.PIConfig", res.PIConfig); // 20220222 PI鏀归�� by Bright
+        component.set("v.login", false);
+      } else {
+        component.set("v.errorMessage", "doinit failed.");
+        this.showErrorToast(component);
+        component.set("v.login", false);
+      }
+    });
+    $A.enqueueAction(action);
+  },
+  //鍏朵粬鍝佺墝浜у搧绫诲埆 涓嬫媺妗嗚祴鍊�
+  selectProductCcategory: function (component) {
+    var select_ProductClassification = component
+      .find("select_ProductClassification")
+      .get("v.value");
+    if (select_ProductClassification != "") {
+      var action = component.get("c.selectProductCcategory");
+      action.setCallback(this, function (response) {
+        var state = response.getState();
+        if (state == "SUCCESS") {
+          var res = response.getReturnValue();
+          component
+            .find("select_ProductCcategory")
+            .set("v.options", JSON.parse(JSON.stringify(res)));
+        }
+      });
+      $A.enqueueAction(action);
+    } else {
+      component.find("select_ProductCcategory").set("v.options", []);
     }
-    },
-    //鏍规嵁鍛ㄥ拰鎷呭綋鏌ヨ鏁版嵁缁欏垵濮嬮〉闈㈣祴鏁版嵁
-    get_reports: function (component, event, helper, date_str, person_str) {
-        if (!date_str) {
-            return false;
-        }
-        date_str = this.get_date_string(date_str);
-        var action = component.get('c.getReports');
-        action.setParams({
-            "date_str": date_str,
-            "person_str": person_str,
-        });
-        component.set('v.login', true);
-        action.setCallback(this, function (response) {
-            var state = response.getState();
-            if (state == 'SUCCESS') {
-                var res = response.getReturnValue();
-                component.set('v.reports', res.reports);
-                component.set('v.report_count', res.reports.length);
-                // 鏇存柊淇濆瓨寰屻伄select_data鐢�
-                var report_id = component.get('v.update_select_report_data_id');
-                if (report_id != "") {
-                    for (var i = 0; i < res.reports.length; i++) {
-                        if (res.reports[i]['Id'] == report_id) {
-                            component.set('v.select_report_data', res.reports[i]);
-                            break;
-                        }
-                    }
-                    component.set('v.update_select_report_data_id', '');
-                }
-                if (res.reports.length > 0) {
-                    component.set('v.list_message', '');
-                    
-                    // PI 鏀归�� By Bright 20220328
-                    if(true){
-                        let doctor_awsids = res.reports.map(function(d){return d.doctor2__r.AWS_Data_Id__c;});
-                        let PIConfig = component.get('v.PIConfig');
-                        let staticResourceAgencyContact = JSON.parse(PIConfig.staticResourceAgencyContact);
-                        if(doctor_awsids.length > 0){
-                            AWSService.search(staticResourceAgencyContact.searchUrl,{
-                                dataIds:doctor_awsids
-                            }, function(data){
-                                if(data && data.object && data.object.length){
-                                    let m = {};
-                                    for(let di in data.object){
-                                        if(data.object[di] && data.object[di].dataId){
-                                            m[data.object[di].dataId] = data.object[di];
-                                        }
-                                    }
-                                    
-                                    for(let ri in res.reports){
-                                        if(res.reports[ri] && res.reports[ri].doctor2__r && res.reports[ri].doctor2__r.AWS_Data_Id__c && m.hasOwnProperty(res.reports[ri].doctor2__r.AWS_Data_Id__c)){
-                                            res.reports[ri].doctor2__r.awsdata = m[res.reports[ri].doctor2__r.AWS_Data_Id__c];
-                                        }
-                                    }
-                                    component.set('v.reports', res.reports);
-                					component.set('v.report_count', res.reports.length);
-                                }
-                                
-                                component.set('v.login', false);
-                            }, staticResourceAgencyContact.token);
-                        }else{
-                            component.set('v.login', false);
-                        }
-                        
-                    }
-                    
-                } else {
-                    component.set('v.list_message', 'no_data');
-                        component.set('v.login', false);
-                }
-                
-            }
-            else {
-                component.set('v.errorMessage', 'get_reports failed.');
-                this.showErrorToast(component);
-                component.set('v.login', false);
-            }
-        });
-        $A.enqueueAction(action);
-    },
-    //澶嶅埗鎸夐挳鍙樼伆鑹�
-    select_date_change: function (component, event, helper) {
-        this.get_reports(component, event, helper, component.find('select_date').get('v.value'), component.find('select_agency_person').get('v.value'));
-        component.set('v.select_report_data_radio', '');
-        component.find('copy_button').set('v.disabled', true);
-    },
-
-    select_agency_change: function (component, event, helper) {
-        var select_value = component.find('select_agency_person').get('v.value');
-        var new_label = this.get_agency_person_name(component, select_value);
-        component.set('v.selected_agency_person', new_label);
-        this.get_reports(component, event, helper, component.find('select_date').get('v.value'), select_value);
-        component.set('v.select_report_data_radio', '');
-        component.find('copy_button').set('v.disabled', true);
-    },
-
-    get_agency_person_name: function (component, agency_person_value) {
-        var allselectlist = component.get('v.allselectlist.AgencyPerson__c');
-        var new_label = '';
-        for (var i = 0; i < allselectlist.length; i++) {
-            if (agency_person_value == allselectlist[i].value) {
-                new_label = allselectlist[i].label;
-                break;
-            }
-        }
-        return new_label;
-    },
-    //澶嶅埗鍜岀紪杈戝洖鏄剧殑浣嶇疆
-    toggle_report: function (component) {
-        var modal_window = component.find('modal_window');
-        var modal_bg = component.find('modal_bg');
-        if ($A.util.hasClass(modal_window, 'disp_none')) {
-            // OPEN
-            $A.util.removeClass(modal_window, 'disp_none');
-            $A.util.removeClass(modal_bg, 'disp_none');
-            //澶嶅埗  鍜岀紪杈�   鍥炴樉闂鍦ㄨ繖閲岄潰
-            if (component.get('v.mode') == 'edit' || component.get('v.mode') == 'copy') {
-                var select_data = '';
-                if (component.get('v.mode') == 'edit') {
-                    select_data = component.get('v.select_report_data');
-                } else if (component.get('v.mode') == 'copy') {
-                    select_data = component.get('v.select_report_data_radio');
-                }
-                var reports = component.get('v.reports');
-                var Agency_Hospital_text = '';
-                var Agency_Hospital_parent_id = '';
-                // 鍖婚櫌鍚�
-                if (select_data['Agency_Hospital__c'] != '') {
-                    for (var i = 0; i < reports.length; i++) {
-                        if (reports[i]['Agency_Hospital__c'] == select_data['Agency_Hospital__c']) {
-                            Agency_Hospital_text = reports[i]['Agency_Hospital__r']['Name'];
-                            Agency_Hospital_parent_id = reports[i]['Agency_Hospital__r']['Hospital__c'];
-                        }
-                    }
-                    component.set('v.hospital', Agency_Hospital_text);
-                    component.set('v.hospitalId', Agency_Hospital_parent_id);
-                    component.set('v.hospitalLinkId', select_data['Agency_Hospital__c']);
-                    component.find('new_con').set('v.disabled', false);
-                }
-                //浣跨敤浜у搧1(浜у搧鍨嬪彿)
-                var UseProduct1Text = '';
-                var UseProduct1Id = '';
-                if (select_data['UseProduct1__c'] != '' || select_data['UseProduct1__c'] != 'undefined') {
-                    for (var i = 0; i < reports.length; i++) {
-                        if (reports[i]['UseProduct1__c'] == select_data['UseProduct1__c']) {
-                            UseProduct1Text = reports[i]['UseProduct1__r']['Name'];
-                            UseProduct1Id = reports[i]['UseProduct1__c'];
-                        }
-                    }
-                    component.set('v.UseProduct1', UseProduct1Text);
-                    component.set('v.UseProduct1Id', select_data['UseProduct1__c']);
-                }
-                //浣跨敤浜у搧2
-                var UseProduct2Text = '';
-                var UseProduct2Id = '';
-                if (select_data['UseProduct2__c'] != ''&&select_data['UseProduct2__c'] != undefined) {
-                    for (var i = 0; i < reports.length; i++) {
-                        if (reports[i]['UseProduct2__c'] == select_data['UseProduct2__c']) {
-                            UseProduct2Text = reports[i]['UseProduct2__r']['Name'];
-                            UseProduct2Id = reports[i]['UseProduct2__c'];
-                        }
-                    }
-                    component.set('v.UseProduct2', UseProduct2Text);
-                    component.set('v.UseProduct2Id', select_data['UseProduct2__c']);
-                }
-                //浣跨敤浜у搧3
-                var UseProduct3Text = '';
-                var UseProduct3Id = '';
-                if (select_data['UseProduct3__c'] != ''&&select_data['UseProduct3__c'] != undefined) {
-                    for (var i = 0; i < reports.length; i++) {
-                        if (reports[i]['UseProduct3__c'] == select_data['UseProduct3__c']) {
-                            UseProduct3Text = reports[i]['UseProduct3__r']['Name'];
-                            UseProduct3Id = reports[i]['UseProduct3__c'];
-                        }
-                    }
-                    component.set('v.UseProduct3', UseProduct3Text);
-                    component.set('v.UseProduct3Id', select_data['UseProduct3__c']);
-                }
-                //娲诲姩鏃�
-                var reportDate;
-                if (select_data['Report_Date__c'] != '') {
-                    for (var i = 0; i < reports.length; i++) {
-                        if (reports[i]['Report_Date__c'] == select_data['Report_Date__c']) {
-                            reportDate = reports[i]["Report_Date__c"];
-                        }
-                    }
-                    component.set('v.data.Report_Date__c', reportDate);
-                }
-                // 绉戝
-                if (select_data['Department_Cateogy__c'] != '') {
-                    component.find('select_department').set('v.value',select_data['Department_Cateogy__c']);
-                }
-                //缁忛攢鍟嗕汉鍛�
-                if (select_data['DealerPersonnel__c'] != '') {
-                    this.set_selected(component, 'select_DealerPersonnel', select_data['DealerPersonnel__c']);
-                }
-                // 鍖婚櫌浜哄憳
-                component.set('v.default_select_doctor_id', select_data['doctor2__c']);
-                this.set_doctor_list(component);
-
-                // 宸ヤ綔璁板綍
-                if (select_data['WorkRecord__c'] != '') {
-                    this.set_selected(component, 'select_purpose_type', select_data['WorkRecord__c']);
-                    this.selectPurposeType(component);
-                }
-                //浜у搧鍒嗙被(绗笁鍒嗙被)
-                if (select_data['ProductClassification__c'] != null) {  
-                    this.set_selected(component, 'select_ProductClassification', select_data['ProductClassification__c']);
-                    this.selectProductClassification(component);
-                }
-                 // 绉戝鍚岀被鑰楁潗鏈堜娇鐢ㄩ噺    
-                if (select_data['ConsumptionOfConsumables__c'] != '') {
-                    component.find('select_ConsumptionOfConsumables').set('v.value',select_data['ConsumptionOfConsumables__c']);
-                }
-                // 浜у搧鐢ㄩ噺
-                if (select_data['warlocksNumber__c'] != '') {
-                    component.find('select_warlocksNumber').set('v.value',select_data['warlocksNumber__c']);
-                }
-                // 宸ヤ綔鏍囪
-                if (select_data['WorkMark__c'] != false) {
-                    component.find('select_WorkMark').set('v.checked',select_data['WorkMark__c']);
-                }
-                debugger;
-
-                var report_id = component.get('v.edit_copy_select_report_id');
-                if (report_id != "") {
-                    var select_EffectProgress1 = '';
-                    var WarlockClassification = '';
-                    var ProductCcategory = '';
-                    var productCategories = '';
-                    var i = 0;
-                    for (i = 0; i < reports.length; i++) {
-                        if (report_id == reports[i]["Id"]) {
-                            select_EffectProgress1 = reports[i]["EffectProgress__c"];
-                            WarlockClassification = reports[i]["WarlockClassification__c"];
-                            ProductCcategory = reports[i]["ProductCcategory__c"];
-                            productCategories = reports[i]["productCategories__c"];
-                                break;
-                        }
-                    }
-                    //鏁堟灉/杩涘害
-                    if (select_EffectProgress1 != null && select_EffectProgress1 != '') {
-                        component.find('select_EffectProgress').set('v.value', select_EffectProgress1);
-                    }
-                    //鏈+鍒嗙被
-                    if (WarlockClassification != null && WarlockClassification != '') {
-                        component.find('select_OtherBrandConsumables').set('v.value', WarlockClassification);
-                    }
-                    //宸查噰鐢ㄥ叾浠栧搧鐗�
-                    if (ProductCcategory != null && ProductCcategory != '') {
-                        component.find('select_ProductCcategory').set('v.value', ProductCcategory);
-                        this.selectpurposetype(component);
-                    }
-                    //鍏朵粬鍝佺墝浜у搧绫诲埆
-                    if (productCategories != null && productCategories != '') {
-                        component.find('select_productCategories').set('v.value', productCategories);
-                    }
-                    component.set('v.edit_copy_select_report_id', "");
-                }
-            }
-        } else {
-            var select_report_data = component.get('v.select_report_data');
-            var Report_Date__c = component.get('v.data.Report_Date__c');
-            var Agency_Hospital__c = component.get('v.hospitalLinkId');
-            var UseProduct1__c = component.get('v.UseProduct1Id');
-            var UseProduct2__c = component.get('v.UseProduct2Id');
-            var UseProduct3__c = component.get('v.UseProduct3Id');
-            var Department_Cateogy__c = component.find('select_department').get('v.value');
-            var ConsumptionOfConsumables__c = component.find('select_ConsumptionOfConsumables').get('v.value');
-            var DealerPersonnel__c = component.find('select_DealerPersonnel').get('v.value');
-            var doctor2__c = component.find('select_doctor').get('v.value');
-            var WorkRecord__c = component.find('select_purpose_type').get('v.value');
-            var EffectProgress__c = component.find('select_EffectProgress').get('v.value');
-            var WarlockClassification__c = component.find('select_OtherBrandConsumables').get('v.value');
-            var ProductCcategory__c = component.find('select_ProductCcategory').get('v.value');
-            var productCategories__c = component.find('select_productCategories').get('v.value');
-            var warlocksNumber__c = component.find('select_warlocksNumber').get('v.value');
-            var WorkMark__c = component.find('select_WorkMark').get('v.checked');
-            if (component.get('v.mode') == 'new') {
-                var confirm_title = '璀﹀憡!'
-                var confirm_text = '鏀惧純鏂板缓鍛ㄦ姤锛�';
-                if (!Report_Date__c &&
-                    !Agency_Hospital__c &&
-                    !UseProduct1__c &&
-                    !UseProduct2__c &&
-                    !UseProduct3__c &&
-                    !Department_Cateogy__c &&
-                    !ConsumptionOfConsumables__c &&
-                    !DealerPersonnel__c &&
-                    !doctor2__c &&
-                    !EffectProgress__c &&
-                    !WarlockClassification__c &&
-                    !ProductCcategory__c &&
-                    !productCategories__c &&
-                    !warlocksNumber__c &&
-                    !WorkMark__c &&
-                    !WorkRecord__c 
-                ) {
-                    this.allclear(component);
-                    $A.util.addClass(modal_window, 'disp_none');
-                    $A.util.addClass(modal_bg, 'disp_none');
-                } else {
-                    this.close_confirm(component, confirm_title, confirm_text);
-                }
-            } else if (component.get('v.mode') == 'copy') {
-                var confirm_title = '璀﹀憡!'
-                var confirm_text = '鏀惧純鏂板缓鍛ㄦ姤锛�';
-                if (select_report_data['Report_Date__c'] == Report_Date__c &&
-                    select_report_data['Agency_Hospital__c'] == Agency_Hospital__c &&  
-                    select_report_data['UseProduct1__c'] == UseProduct1__c &&
-                    select_report_data['UseProduct2__c'] == UseProduct2__c &&
-                    select_report_data['UseProduct3__c'] == UseProduct3__c &&
-                    select_report_data['Department_Cateogy__c'] == Department_Cateogy__c &&
-                    select_report_data['ConsumptionOfConsumables__c'] == ConsumptionOfConsumables__c &&
-                    select_report_data['DealerPersonnel__c'] == DealerPersonnel__c &&
-                    select_report_data['doctor2__c'] == doctor2__c &&
-                    select_report_data['EffectProgress__c'] == EffectProgress__c &&
-                    select_report_data['WarlockClassification__c'] == WarlockClassification__c &&   
-                    select_report_data['ProductCcategory__c'] == ProductCcategory__c &&
-                    select_report_data['productCategories__c'] == productCategories__c &&
-                    select_report_data['warlocksNumber__c'] == warlocksNumber__c &&
-                    select_report_data['WorkMark__c'] == WorkMark__c &&
-                    select_report_data['WorkRecord__c'] == WorkRecord__c ) {
-                    this.allclear(component);
-                    $A.util.addClass(modal_window, 'disp_none');
-                    $A.util.addClass(modal_bg, 'disp_none');
-                } else {
-                    this.close_confirm(component, confirm_title, confirm_text);
-                }
-            } else if (component.get('v.mode') == 'edit') {
-                var confirm_title = '璀﹀憡!'
-                var confirm_text = '鏀惧純缂栬緫鍛ㄦ姤锛�';
-                if (select_report_data['Report_Date__c'] == Report_Date__c &&
-                    select_report_data['Agency_Hospital__c'] == Agency_Hospital__c &&
-                    select_report_data['UseProduct1__c'] == UseProduct1__c &&
-                    select_report_data['UseProduct2__c'] == UseProduct2__c &&
-                    select_report_data['UseProduct3__c'] == UseProduct3__c &&
-                    select_report_data['Department_Cateogy__c'] == Department_Cateogy__c &&
-                    select_report_data['ConsumptionOfConsumables__c'] == ConsumptionOfConsumables__c &&
-                    select_report_data['DealerPersonnel__c'] == DealerPersonnel__c &&
-                    select_report_data['doctor2__c'] == doctor2__c &&
-                    select_report_data['EffectProgress__c'] == EffectProgress__c &&
-                    select_report_data['WarlockClassification__c'] == WarlockClassification__c &&  
-                    select_report_data['ProductCcategory__c'] == ProductCcategory__c &&
-                    select_report_data['productCategories__c'] == productCategories__c &&
-                    select_report_data['warlocksNumber__c'] == warlocksNumber__c &&
-                    select_report_data['WorkMark__c'] == WorkMark__c &&
-                    select_report_data['WorkRecord__c'] == WorkRecord__c ) {
-                    this.allclear(component);
-                    $A.util.addClass(modal_window, 'disp_none');
-                    $A.util.addClass(modal_bg, 'disp_none');
-                } else {
-                    this.close_confirm(component, confirm_title, confirm_text);
-                }
-            }
-        }
-    },
-    //鍏抽棴椤甸潰鏄�   灏忕殑鎻愮ず妗嗘槸鍚︽斁寮冩柊寤哄懆鎶�
-    close_confirm: function (component, title, text) {
-        var confirm_status = component.get('v.confirm_status');
-        component.set('v.modal_confirm_title', title);
-        component.set('v.modal_confirm_text', text);
-        var modal_window = component.find('modal_window');
-        var modal_bg = component.find('modal_bg');
-        var modal_confirm = component.find('modal_confirm');
-        var modal_confirm_bg = component.find('modal_confirm_bg');
-        if (confirm_status == 0) {
-            $A.util.addClass(modal_window, 'disp_none');
-            $A.util.addClass(modal_bg, 'disp_none');
-            $A.util.removeClass(modal_confirm, 'disp_none');
-            $A.util.removeClass(modal_confirm_bg, 'disp_none');
-        } else if (confirm_status == 1) {
-            // 鏄�
-            $A.util.addClass(modal_confirm, 'disp_none');
-            $A.util.addClass(modal_confirm_bg, 'disp_none');
-            component.set('v.mode', '');
-            this.allclear(component);
-            component.set('v.reports_now', "");
-            component.set('v.reports_now_count', 0);
-            component.set('v.confirm_status', 0);
-        } else if (confirm_status == 2) {
-            // 鍚�
-            $A.util.removeClass(modal_window, 'disp_none');
-            $A.util.removeClass(modal_bg, 'disp_none');
-            $A.util.addClass(modal_confirm, 'disp_none');
-            $A.util.addClass(modal_confirm_bg, 'disp_none');
-            component.set('v.confirm_status', 0);
-        }
-    },
-    //鏂板缓鎸夐挳
-    new_report: function (component, event, helper) {
-        component.set('v.mode', 'new');
-        component.set('v.dialog_type', '鏂板缓');
-        //  鍛�
-        var select_date = component.find('select_date').get('v.value');
-        //  鎷呭綋
-        var select_agency = component.find('select_agency_person').get('v.value');
-        var cm = 0;
-        if(select_agency.indexOf(";") != -1){
-            select_agency = select_agency.split(";")[0];
-        }
-        component.set('v.selected_date', select_date);
-        //  鎷呭綋
-        var name = component.get('v.selected_agency_person');
-        var ret = this.create_report_header(component, event, helper, name, select_agency, select_date);
-    },
-    // 澶嶅埗鎸夐挳
-    copy_button: function (component, event, helper) {
-        this.allclear(component);
-        component.set('v.mode', 'copy');
-        component.set('v.dialog_type', '鏂板缓');
-        var select_report_data = component.get('v.select_report_data_radio');
-        component.set('v.loadOpp', true);
-        // 閫�
-        var now = new Date();
-        var start_day = new Date(now.getFullYear(), now.getMonth(), (now.getDate() - now.getDay() + 1));
-        var select_date = start_day.getFullYear() + '/' + (start_day.getMonth() + 1) + '/' + start_day.getDate();
-        this.set_selected(component, 'select_date', select_date);
-        component.set('v.selected_date', select_date);
-        // 鎷呭綋
-        var select_agency = select_report_data['Person_In_Charge2__c'];
-        var new_label = this.get_agency_person_name(component, select_agency);
-        component.set('v.selected_agency_person', new_label);
-        this.set_selected(component, 'select_agency_person', select_agency);
-        var name = component.get('v.selected_agency_person');
-        component.set('v.edit_copy_select_report_id', select_report_data['Id']);
-        component.set('v.select_report_data', select_report_data);
-        var ret = this.create_report_header(component, event, helper, name, select_agency, select_date);
-    },
-    //澶嶅埗鎸夐挳鍙敤
-    change_report_radio: function (component, event, helper) {
-        var reports = component.get('v.reports');
-        for (var i = 0; i < reports.length; i++) {
-            if (reports[i].Name == event.getSource().get('v.label')) {
-                component.set('v.select_report_data_radio', reports[i]);
-                component.find('copy_button').set('v.disabled', false);
-                break;
-            }
-        }
-    },
-    //缂栬緫鎸夐挳
-    edit_button: function (component, event, helper) {
-        this.allclear(component);
-        debugger
-        component.set('v.loadOpp', true);
-        var index = event.getSource().get('v.value');
-        component.set('v.select_report_data', component.get('v.reports')[index]);
-        component.set('v.mode', 'edit');
-        component.set('v.dialog_type', '缂栬緫');
-        var select_date = component.get('v.reports')[index].Submit_date__c;
-        var select_agency = component.get('v.reports')[index].Person_In_Charge2__c;
-        var text_tmp = select_date.split('-');
-        var select_date_text = text_tmp[0] + '/' + Number(text_tmp[1]) + '/' + Number(text_tmp[2]);
-        component.set('v.selected_date', select_date_text);
-        var name = component.get('v.reports')[index].Person_In_Charge2__r.Name;
-        this.set_selected(component, 'select_agency_person', select_agency);
-        var new_label = this.get_agency_person_name(component, select_agency);
-        component.set('v.selected_agency_person', new_label);
-        component.set('v.edit_copy_select_report_id', component.get('v.reports')[index].Id);
-        var ret = this.create_report_header(component, event, helper, name, select_agency, select_date);
-    },
-    //淇濆瓨
-    save_report: function (component, event, helper) {
-        component.find('save_button').set('v.disabled', true);
-        var etEng = component.get('v.etEng');
-        var Report_Date__c = component.get('v.data.Report_Date__c');
-        var Person_In_Charge2__c = "";
-        var Submit_date__c = "";
-        if (component.get('v.mode') == 'edit') {
-            // 鍛� Submit_date__c
-            Submit_date__c = component.get('v.select_report_data').Submit_date__c;
-            // 鎷呭綋 Person_In_Charge2__c
-            Person_In_Charge2__c = component.get('v.select_report_data').Person_In_Charge2__c;
-        } else {
-            // 鍛� Submit_date__c
-            Submit_date__c = this.get_date_string(component.find('select_date').get('v.value'));
-            // 鎷呭綋 Person_In_Charge2__c
-            Person_In_Charge2__c = component.find('select_agency_person').get('v.value');
-        }
-        debugger
-        // Agency_Report_Header__c
-        var Agency_Report_Header__c = component.get('v.agency_report_header_id');
-        // 鍖婚櫌 
-        var Agency_Hospital__c = component.get('v.hospitalLinkId');
-        // 浜у搧鍒嗙被(绗笁鍒嗙被)
-        var ProductClassification__c = component.find('select_ProductClassification').get('v.value');
-        // 浣跨敤浜у搧1(浜у搧鍨嬪彿)    UseProduct1__c 
-        var UseProduct1__c = component.get('v.UseProduct1Id');
-        // 浣跨敤浜у搧2    UseProduct2__c 
-        var UseProduct2__c = component.get('v.UseProduct2Id');
-        // 浣跨敤浜у搧3    UseProduct3__c 
-        var UseProduct3__c = component.get('v.UseProduct3Id');
-        // 绉戝 Department_Cateogy__c   
-        var Department_Cateogy__c = component.find('select_department').get('v.value');
-        // 缁忛攢鍟嗕汉鍛� DealerPersonnel__c
-        var DealerPersonnel__c = component.find('select_DealerPersonnel').get('v.value');
-        // 鍖婚櫌浜哄憳 doctor2__c
-        var doctor2__c = component.find('select_doctor').get('v.value');
-        // 宸ヤ綔璁板綍浼�   WorkRecord__c
-        var WorkRecord__c = component.find('select_purpose_type').get('v.value');
-         // 鏁堟灉/杩涘害    EffectProgress__c
-        var EffectProgress__c = component.find('select_EffectProgress').get('v.value');
-        // alert(EffectProgress__c);
-         // 绉戝鍚屾潵鑰楁潗鏈堜娇鐢ㄩ噺   ConsumptionOfConsumables__c      
-        var ConsumptionOfConsumables__c = component.find('select_ConsumptionOfConsumables').get('v.value');
-         // 鏈+鍒嗙被   WarlockClassification__c  
-        var WarlockClassification__c = component.find('select_OtherBrandConsumables').get('v.value');
-          // 宸查噰鐢ㄥ叾浠栧搧鐗�   ProductCcategory__c  
-        var ProductCcategory__c = component.find('select_ProductCcategory').get('v.value');
-           // 鍏朵粬鍝佺墝浜у搧绫诲埆   productCategories__c  
-        var productCategories__c = component.find('select_productCategories').get('v.value');
-         // 浜у搧鐢ㄩ噺   warlocksNumber__c      
-        var warlocksNumber__c = component.find('select_warlocksNumber').get('v.value');
-          // 宸ヤ綔鏍囪   WorkMark__c    
-        var WorkMark__c = component.find('select_WorkMark').get('v.checked');
-        var StageName__c = component.find('select_stageName').get('v.value');
-        var Amount__c = component.get('v.oppdata.Amount__c') != null ? component.get('v.oppdata.Amount__c').toString() : '';
-        var OCMSale_Price__c = component.get('v.oppdata.OCMSale_Price__c') != null ? component.get('v.oppdata.OCMSale_Price__c').toString() : '';
-        var Close_Forecasted_Date__c = component.get('v.oppdata.Close_Forecasted_Date__c');
-        var StageName__c_o = component.get('v.StageName__c_o');
-        var Amount__c_o = component.get('v.Amount__c_o');
-        var OCMSale_Price__c_o = component.get('v.OCMSale_Price__c_o');
-        var Close_Forecasted_Date__c_o = component.get('v.Close_Forecasted_Date__c_o');
-        if (StageName__c_o == undefined) StageName__c_o = '';
-        if (Amount__c_o == undefined) Amount__c_o = '';
-        if (OCMSale_Price__c_o == undefined) OCMSale_Price__c_o = '';
-        if (Close_Forecasted_Date__c_o == undefined) Close_Forecasted_Date__c_o = '';
-        if (StageName__c == StageName__c_o && OCMSale_Price__c_o == OCMSale_Price__c && Amount__c == Amount__c_o && Close_Forecasted_Date__c == Close_Forecasted_Date__c_o) {
-            StageName__c = '';
-            Amount__c = '';
-            OCMSale_Price__c = '';
-            Close_Forecasted_Date__c = '';
-        }
-        // 銉愩儶銉囥兗銈枫儳銉�
-        var error = [];
-        if (!Report_Date__c) { error.push("娲诲姩鏃� 涓嶅瓨鍦�"); }
-        if (!Submit_date__c) { error.push("鍛� 涓嶅瓨鍦�"); }
-        var rDate = new Date(Report_Date__c);
-        var sDate = new Date(Submit_date__c);
-        sDate.setDate(sDate.getDate() - 1);
-        if (rDate < sDate) { error.push('娲诲姩鏃ュ繀椤绘槸鏈懆锛�'); }
-        sDate.setDate(sDate.getDate() + 7);
-        if (rDate >= sDate) { error.push('娲诲姩鏃ュ繀椤绘槸鏈懆锛�'); }
-        if (!Person_In_Charge2__c) { error.push("鎷呭綋 涓嶅瓨鍦�"); }
-        if (!Agency_Report_Header__c) { this.error("Report Header Id 涓嶅瓨鍦�"); }
-        if (!Agency_Hospital__c) { error.push("鍖婚櫌 涓嶅瓨鍦�"); }  
-        if (!UseProduct1__c) { error.push("浣跨敤浜у搧1(浜у搧鍨嬪彿) 涓嶅瓨鍦�"); } 
-        // if (!UseProduct2__c) { error.push("浣跨敤浜у搧2 涓嶅瓨鍦�"); } 
-        // if (!UseProduct3__c) { error.push("浣跨敤浜у搧3 涓嶅瓨鍦�"); } 
-        if (!Department_Cateogy__c) { error.push("绉戝 涓嶅瓨鍦�"); }
-        if (!DealerPersonnel__c) { error.push("缁忛攢鍟嗕汉鍛� 涓嶅瓨鍦�"); }
-        if (!doctor2__c) { error.push("鍖婚櫌浜哄憳 涓嶅瓨鍦�"); }
-        if (!WorkRecord__c) { error.push("宸ヤ綔璁板綍 涓嶅瓨鍦�"); }
-        if (!EffectProgress__c) { error.push("鏁堟灉/杩涘害 涓嶅瓨鍦�"); } 
-        // if (!OtherBrandConsumables__c) { error.push("鏈+鍒嗙被 涓嶅瓨鍦�"); }
-        if (ProductCcategory__c==''||ProductCcategory__c==""||ProductCcategory__c==undefined) { error.push("宸查噰鐢ㄥ叾浠栧搧鐗�  涓嶅瓨鍦�"); }
-        // if (!productCategories__c) { error.push("鍏朵粬鍝佺墝浜у搧绫诲埆 涓嶅瓨鍦�"); }
-        if (!ConsumptionOfConsumables__c) { error.push("绉戝鍚岀被鑰楁潗鏈堜娇鐢ㄩ噺 涓嶈兘涓虹┖"); }
-        //fy start
-        if(WorkRecord__c != 'SIS'){
-            if (!warlocksNumber__c) { error.push("浜у搧鐢ㄩ噺 涓嶈兘涓虹┖"); }
-        }
-        //fy end
-        for (var i = 0; i < error.length; i++) {
-            component.set('v.errorMessage', error[i]);
-            this.showErrorToast(component);
-        }
-        if (error.length > 0) {
-            component.find('save_button').set('v.disabled', false);
-            return false;
-        }
-        // 淇濆瓨鍑︾悊
-        component.set('v.login', true);
-        if (component.get('v.mode') == 'edit') {
-            var Agency_Report__c = component.get('v.select_report_data').Id;
-            var action = component.get('c.editAgencyReport');
-            action.setParams({
-                "Agency_Report_Id": Agency_Report__c,
-                "Department_Cateogy": Department_Cateogy__c,
-                "ConsumptionOfConsumables": ConsumptionOfConsumables__c,
-                "WorkRecord": WorkRecord__c,
-                "EffectProgress": EffectProgress__c,
-                "WarlockClassification" : WarlockClassification__c,
-                "ProductCcategory" : ProductCcategory__c,
-                "productCategories" : productCategories__c,
-                "warlocksNumber" : warlocksNumber__c,
-                "WorkMark" : WorkMark__c,
-                "ProductClassification": ProductClassification__c,
-                "DealerPersonnel": DealerPersonnel__c,
-                "Agency_Report_Header": Agency_Report_Header__c,
-                "Agency_Hospital": Agency_Hospital__c,
-                "UseProduct1": UseProduct1__c,
-                "UseProduct2": UseProduct2__c,
-                "UseProduct3": UseProduct3__c,
-                "Person_In_Charge2": Person_In_Charge2__c,
-                "doctor": doctor2__c,
-                "Submit_date": Submit_date__c,
-                "StageName": StageName__c,
-                "oppAmount": Amount__c,
-                "oppOCMPrice": OCMSale_Price__c,
-                "Close_Forecasted_Date": Close_Forecasted_Date__c,
-                "Report_Date": Report_Date__c
-            });
-            action.setCallback(this, function (response) {
-                var state = response.getState();
-                if (state == 'SUCCESS') {
-                    component.set('v.successMessage', '缂栬緫淇濆瓨鎴愬姛');
-                    this.showSuccessToast(component);
-                    var report_id = response.getReturnValue();
-                    component.set('v.create_agency_report_id', report_id);
-                    var select_agency_list = component.get('v.allselectlist').AgencyPerson__c;
-                    for (var i = 0; i < select_agency_list.length; i++) {
-                        if (select_agency_list[i].value == component.get('v.select_report_data').Person_In_Charge2__c) {
-                            select_agency_list[i].selected = true;
-                        } else {
-                            select_agency_list[i].selected = false;
-                        }
-                    }
-                    component.find('select_agency_person').set('v.options', select_agency_list);
-                    component.set('v.update_select_report_data_id', report_id);
-                    this.get_reports(component, event, helper, component.get('v.select_report_data').Submit_date__c, component.get('v.select_report_data').Person_In_Charge2__c);
-                    component.find('save_button').set('v.disabled', false);
-                    component.set('v.login', false);
-                }
-                else {
-                    component.set('v.errorMessage', 'save_report failed.');
-                    this.showErrorToast(component);
-                    component.find('save_button').set('v.disabled', false);
-                    component.set('v.login', false);
-                }
-            });
-            $A.enqueueAction(action);
-        } else {
-            /* Save (New & Copy) */
-            var action = component.get('c.saveAgencyReport');
-            action.setParams({
-                "Department_Cateogy": Department_Cateogy__c,
-                "ConsumptionOfConsumables": ConsumptionOfConsumables__c,
-                "WorkMark" : WorkMark__c,
-                "warlocksNumber" : warlocksNumber__c,
-                "DealerPersonnel": DealerPersonnel__c,
-                "ProductCcategory" : ProductCcategory__c,
-                "productCategories" : productCategories__c,
-                "WarlockClassification" : WarlockClassification__c,
-                "ProductClassification": ProductClassification__c,
-                "WorkRecord": WorkRecord__c,
-                "EffectProgress": EffectProgress__c,
-                "Agency_Report_Header": Agency_Report_Header__c,
-                "Agency_Hospital": Agency_Hospital__c,
-                "Person_In_Charge2": Person_In_Charge2__c,
-                "doctor": doctor2__c,
-                "Submit_date": Submit_date__c,
-                "UseProduct1": UseProduct1__c,
-                "UseProduct2": UseProduct2__c,
-                "UseProduct3": UseProduct3__c,
-                "StageName": StageName__c,
-                "oppAmount": Amount__c,
-                "oppOCMPrice": OCMSale_Price__c,
-                "Close_Forecasted_Date": Close_Forecasted_Date__c,
-                "Report_Date": Report_Date__c
-            });
-            action.setCallback(this, function (response) {
-                var state = response.getState();
-                if (state == 'SUCCESS') {
-                    component.set('v.successMessage', '淇濆瓨鎴愬姛');
-                    this.showSuccessToast(component);
-                    var report_id = response.getReturnValue();
-                    component.set('v.create_agency_report_id', report_id);
-                    this.get_reports(component, event, helper, component.find('select_date').get('v.value'), component.find('select_agency_person').get('v.value'));
-                    // 銉€兗銉�銉偊銈c兂銉夈偊鍐呫伄涓�瑕х敤
-                    var action2 = component.get('c.getReportsById');
-                    action2.setParams({
-                        "report_id": report_id,
-                    });
-                    action2.setCallback(this, function (response) {
-                        var state = response.getState();
-                        if (state == 'SUCCESS') {
-                            var res = response.getReturnValue();
-                            var reports_now = component.get('v.reports_now');
-                            var reports_now_count = 0;
-                            if (reports_now.length > 0 && reports_now != "") {
-                                reports_now_count = reports_now.length;
-                            }
-                            // Save&New鏅傘伄銈︺偅銉炽儔銈﹀唴銉囥兗銈夸竴瑕�
-                            if (res.length > 0) {
-                                reports_now[reports_now_count] = res[0];
-                                reports_now.sort(function (a, b) {
-                                    if (a.Name > b.Name) return -1;
-                                    if (a.Name < b.Name) return 1;
-                                    return 0;
-                                });
-                                component.set('v.reports_now', reports_now);
-                                component.set('v.reports_now_count', reports_now.length);
-                                var data_list = component.find('modal_data_list_tr');
-                            }
-                        }
-                        else {
-                            component.set('v.errorMessage', 'get_reports_now failed.');
-                            this.showErrorToast(component);
-                            component.find('save_button').set('v.disabled', false);
-                            component.set('v.login', false);
-                        }
-                    });
-                    $A.enqueueAction(action2);
-                    this.allclear(component);
-                    component.find('select_WorkMark').set('v.value', false);
-                    component.find('save_button').set('v.disabled', false);
-                    component.set('v.login', false);
-                    this.doinit(component, event, helper);
-                }
-                else {
-                    var error = response.getError();
-                    component.set('v.errorMessage', 'saveAgencyReport failed.');
-                    this.showErrorToast(component);
-                    component.find('save_button').set('v.disabled', false);
-                    component.set('v.login', false);
-                }
-            });
-            $A.enqueueAction(action);
-        }
-    },
-
-    allclear: function (component) {
-        var clear = [{ label: '', value: '', selected: true }];
-        component.set('v.hospital', '');
-        component.set('v.hospitalId', '');
-        component.set('v.hospitalLinkId', '');
-        component.set('v.UseProduct1', '');
-        component.set('v.UseProduct1Id', '');
-        component.set('v.UseProduct2', '');
-        component.set('v.UseProduct2Id', '');
-        component.set('v.UseProduct3', '');
-        component.set('v.UseProduct3Id', '');
-        component.find('select_ProductClassification').set('v.value', '');
-        component.find('select_warlocksNumber').set('v.value', null);
-        component.find('select_department').set('v.value', '');
-        component.find('select_ConsumptionOfConsumables').set('v.value', null);
-        component.find('select_WorkMark').set('v.checked', false);
-        component.find('new_con').set('v.disabled', true);
-        component.find('select_doctor').set('v.options', clear);
-        component.find('select_DealerPersonnel').set('v.options', this.conv_selected(component.get('v.allselectlist.DealerPersonnel__c')));
-        component.find('select_purpose_type').set('v.options', this.conv_selected(component.get('v.allselectlist.WorkRecord__c')));
-        // component.find('select_ProductCcategory').set('v.options', this.conv_selected(component.get('v.allselectlist.ProductCcategory__c'))); 
-        component.find('select_EffectProgress').set('v.value', '');
-        component.find('select_OtherBrandConsumables').set('v.value', '');
-        component.find('select_ProductCcategory').set('v.value', '');
-        component.find('select_productCategories').set('v.value', '');
-        // ToDo闇�瑕佹祴璇曟墜鏈轰笂鑳借繍琛屼笉
-        component.set('v.data.Report_Date__c', '');
-        component.set('v.oppdata.Close_Forecasted_Date__c', '');
-        component.set('v.oppdata.Amount__c', '');
-        component.set('v.oppdata.OCMSale_Price__c', '');
-        component.set('v.oppdata.StageName__c', '');
-        component.set('v.Close_Forecasted_Date__c_o', '');
-        component.set('v.Amount__c_o', '');
-        component.set('v.OCMSale_Price__c_o', '');
-        component.set('v.StageName__c_o', '');
-        $A.util.addClass(component.find('input-opportunity-stage'), 'disp_none');
-        $A.util.addClass(component.find('input-opportunity-amount1'), 'disp_none');
-        $A.util.addClass(component.find('input-opportunity-amount2'), 'disp_none');
-        $A.util.addClass(component.find('input-opportunity-date'), 'disp_none');
-        this.selectPurposeType(component);
-        this.selectProductClassification(component);
-        this.selectpurposetype(component);
-    },
-
-    report_date_list: function (component, event, helper, count) {
-        var ret_obj = [];
-        var now = new Date();
-        for (var i = 0; i < count; i++) {
-            var start_day = new Date(now.getFullYear(), now.getMonth(), (now.getDate() - now.getDay() + 1 - (i * 7)));
-            var end_day = new Date(now.getFullYear(), now.getMonth(), now.getDate() + (7 - now.getDay()) - (i * 7));
-            var start_day_show = new Date(now.getFullYear(), now.getMonth(), (now.getDate() - now.getDay() - (i * 7)));
-            var end_day_show = new Date(now.getFullYear(), now.getMonth(), now.getDate() + (6 - now.getDay()) - (i * 7));
-            var date_text = start_day.getFullYear() + '/' + (start_day.getMonth() + 1) + '/' + start_day.getDate() + '~' + end_day.getFullYear() + '/' + (end_day.getMonth() + 1) + '/' + end_day.getDate();
-            if (i == 0) {
-                ret_obj.push({
-                    selected: true,
-                    value: start_day.getFullYear() + '/' + (start_day.getMonth() + 1) + '/' + start_day.getDate(),
-                    label: start_day_show.getFullYear() + '/' + (start_day_show.getMonth() + 1) + '/' + start_day_show.getDate() + '~' + end_day_show.getFullYear() + '/' + (end_day_show.getMonth() + 1) + '/' + end_day_show.getDate(),
-                });
-            } else {
-                ret_obj.push({
-                    selected: false,
-                    value: start_day.getFullYear() + '/' + (start_day.getMonth() + 1) + '/' + start_day.getDate(),
-                    label: start_day_show.getFullYear() + '/' + (start_day_show.getMonth() + 1) + '/' + start_day_show.getDate() + '~' + end_day_show.getFullYear() + '/' + (end_day_show.getMonth() + 1) + '/' + end_day_show.getDate(),
-                });
-            }
-        }
-        component.find('select_date').set('v.options', ret_obj);
-        component.set('v.report_date_list', ret_obj);
-    },
-    create_report_header: function (component, event, helper, name, s_agency, s_date) {
-        s_date = this.get_date_string(s_date);
-        if (s_date == false) {
-            component.set('v.errorMessage', 'get_date_string failed.');
-            this.showErrorToast(component);
-            return false;
-        }
-        var head_key = this.create_header_input_key(s_agency, s_date);
-        component.set('v.agency_report_header', head_key);
-        if (head_key == false) {
-            component.set('v.errorMessage', 'create_header_input_key failed.');
-            this.showErrorToast(component);
-            return false;
-        }
-        var key2 = s_date.replace(/-/g, '');
-        var action = component.get('c.createReportHeader');
-        action.setParams({
-            "name": name,
-            "s_date": s_date,
-            "s_agency": s_agency,
-            "head_key": head_key,
-        });
-        component.set('v.login', true);
-        action.setCallback(this, function (response) {
-            var state = response.getState();
-            if (state == 'SUCCESS') {
-                var res = response.getReturnValue();
-                component.set('v.agency_report_header_id', res);
-                component.set('v.login', false);
-                this.toggle_report(component, event, helper);
-            }
-            else {
-                component.set('v.errorMessage', 'createReportHeader callback failed.');
-                this.showErrorToast(component);
-                component.set('v.login', false);
-            }
-        });
-        $A.enqueueAction(action);
-    },
-    create_header_input_key: function (agency_id, s_date) {
-        if (typeof (s_date) != 'string') {
-            s_date = this.get_date_string(s_date);
-            if (s_date == false) {
-                component.set('v.errorMessage', 'get_date_string in create_header_input_key.');
-                this.showErrorToast(component);
-                return false;
-            }
-        }
-        if (!agency_id || !s_date) {
-            return false;
-        }
-        s_date = s_date.replace(/-/g, '');
-        var headkey = agency_id + ":" + s_date;
-        return headkey;
-    },
-
-    /* typeof is not cool
-     * @ret : String, Boolean, Date, Error, Array, Function, Null, Undefined, etc
-     */
-    object_type: function (obj) {
-        var obj_type = Object.prototype.toString.call(obj).slice(8, -1);
-        return obj_type;
-    },
-    // create yyyy-mm-dd string
-    get_date_string: function (val) {
-        if (typeof (val) == 'string') {
-            if (val.match(/^\d{4}\/\d{1,2}\/\d{1,2}$/)) {
-                val = val.replace(/[\/]/g, '-');
-                var tmp = val.split('-');
-                if (tmp[1].length == 1) {
-                    tmp[1] = '0' + tmp[1];
-                }
-                if (tmp[2].length == 1) {
-                    tmp[2] = '0' + tmp[2];
-                }
-                val = tmp[0] + '-' + tmp[1] + '-' + tmp[2];
-            } else if (val.match(/^\d{4}-\d{1,2}-\d{1,2}$/)) {
-                //ok
-            } else {
-                return false;
-            }
-        } else if (this.object_type(val) == 'Date') {
-            var mm = val.getMonth() + 1;
-            if (String(mm).length == 1) {
-                mm = '0' + mm;
-            }
-            var dd = '';
-            if (String(val.getDate()).length == 1) {
-                dd = '0' + val.getDate();
-            } else {
-                dd = val.getDate();
-            }
-            val = val.getFullYear() + '-' + mm + '-' + dd;
-        } else {
-            return false;
-        }
-        return val;
-    },
-    //   Controller   鏍规嵁椤甸潰鍖婚櫌鏌ヨ绗﹀悎鐨勫尰闄�
-    searchHos: function (component, event, helper) {
-        var hospital_name = event.getParam("value");
-        var action = component.get("c.getHospitalList");
-        action.setParams({
-            "hospital_name": hospital_name
-        });
-        action.setCallback(this, function (response) {
-            var state = response.getState();
-            if (state === "SUCCESS") {
-                var hospital_list = component.find('hospital_list');
-                var hosList = response.getReturnValue();
-                if (hosList.length > 0) {
-                    $A.util.addClass(hospital_list, 'slds-is-open');
-                } else {
-                    $A.util.removeClass(hospital_list, 'slds-is-open');
-                }
-                component.set("v.hospitalList", response.getReturnValue());
-            } else {
-                $A.util.removeClass(hospital_list, 'slds-is-open');
-            }
-        });
-        $A.enqueueAction(action);
-    },
-    hideSearch: function (component, event, helper) {
-        var hospital_list = component.find('hospital_list');
-        $A.util.removeClass(hospital_list, 'slds-is-open');
-    },
-    selectHos: function (component, event, helper) {
-        var hospital_list = component.find('hospital_list');
-        $A.util.removeClass(hospital_list, 'slds-is-open');
-        var accname = event.currentTarget.dataset.accname;
-        var accid = event.currentTarget.dataset.accid;
-        var hospital_data = component.get('v.hospitalList');
-        for (var i = 0; i < hospital_data.length; i++) {
-            if (hospital_data[i].Hospital__c == accid) {
-                component.set('v.hospitalLinkId', hospital_data[i].Id);
-                component.set('v.data.Agency_Hospital__c', hospital_data[i].Id);
-                component.find('new_con').set('v.disabled', false);
-            }
-        }
-        component.set("v.hospital", accname);
-        component.set("v.hospitalId", accid);
-        this.set_doctor_list(component, event, helper);
-    },
-  
-
-    //妯$硦鏌ヨ浣跨敤浜у搧1(浜у搧鍨嬪彿)
-    searchUseProduct1: function (component, event, helper) {
-        var UseProduct1Name = event.getParam("value");
-        var select_ProductClassification = component.find('select_ProductClassification').get('v.value');
-        var action = component.get("c.getUseProduct1");
-        action.setParams({
-            "UseProduct1Name": UseProduct1Name,
-            "select_ProductClassification" : select_ProductClassification
-        });
-        action.setCallback(this, function (response) {
-            var state = response.getState();
-            if (state === "SUCCESS") {
-                var UseProduct1_List = component.find('UseProduct1_List');
-                var UseProduct1ListValue = response.getReturnValue();
-                if (UseProduct1ListValue.length > 0) {
-                    $A.util.addClass(UseProduct1_List, 'slds-is-open');
-                } else {
-                    $A.util.removeClass(UseProduct1_List, 'slds-is-open');
-                }
-                component.set("v.UseProduct1List", UseProduct1ListValue);
-            } else {
-                $A.util.removeClass(UseProduct1_List, 'slds-is-open');
-            }
-        });
-        $A.enqueueAction(action);
-    },
-    hideSearchUseProduct1: function (component, event, helper) {
-        var UseProduct1_List = component.find('UseProduct1_List');
-        $A.util.removeClass(UseProduct1_List, 'slds-is-open');
-    },
-    seletUseProduct1Change: function (component, event, helper) {
-        var UseProduct1_List = component.find('UseProduct1_List');
-        $A.util.removeClass(UseProduct1_List, 'slds-is-open');
-        var accname = event.currentTarget.dataset.accname;
-        var accid = event.currentTarget.dataset.accid;
-        var UseProduct1ListDate = component.get('v.UseProduct1List');
-        for (var i = 0; i < UseProduct1ListDate.length; i++) {
-            if (UseProduct1ListDate[i].Id == accid) {
-                component.set('v.UseProduct1Id', UseProduct1ListDate[i].Id);
-                component.set('v.data.UseProduct1__c', UseProduct1ListDate[i].Id);
-            }
-        }
-        var UseProduct2_TEXT = component.find('UseProduct1_TEXT').get('v.value');
-        var UseProduct3_TEXT = component.find('UseProduct3_TEXT').get('v.value');
-        if(UseProduct2_TEXT != accname && UseProduct3_TEXT != accname){
-            component.set("v.UseProduct1", accname);
-        }else{
-            component.set('v.errorMessage', '涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝�');
-            this.showErrorToast(component);
-        }
-    },
-     //妯$硦鏌ヨ浣跨敤浜у搧2
-    searchUseProduct2: function (component, event, helper) {
-        var UseProduct2Name = event.getParam("value");
-        var select_ProductClassification = component.find('select_ProductClassification').get('v.value');
-        var action = component.get("c.getUseProduct1");
-        action.setParams({
-            "UseProduct1Name": UseProduct2Name,
-            "select_ProductClassification" : select_ProductClassification
-        });
-        action.setCallback(this, function (response) {
-            var state = response.getState();
-            if (state === "SUCCESS") {
-                var UseProduct2_List = component.find('UseProduct2_List');
-                var UseProduct2List = response.getReturnValue();
-                if (UseProduct2List.length > 0) {
-                    $A.util.addClass(UseProduct2_List, 'slds-is-open');
-                } else {
-                    $A.util.removeClass(UseProduct2_List, 'slds-is-open');
-                }
-                component.set("v.UseProduct2List", response.getReturnValue());
-            } else {
-                $A.util.removeClass(UseProduct2_List, 'slds-is-open');
-            }
-        });
-        $A.enqueueAction(action);
-    },
-    hideSearchUseProduct2: function (component, event, helper) {
-        var UseProduct2_List = component.find('UseProduct2_List');
-        $A.util.removeClass(UseProduct2_List, 'slds-is-open');
-    },
-    seletUseProduct2Change: function (component, event, helper) {
-        var UseProduct2_List = component.find('UseProduct2_List');
-        $A.util.removeClass(UseProduct2_List, 'slds-is-open');
-        var accname = event.currentTarget.dataset.accname;
-        var accid = event.currentTarget.dataset.accid;
-        var UseProduct2ListDate = component.get('v.UseProduct2List');
-        for (var i = 0; i < UseProduct2ListDate.length; i++) {
-            if (UseProduct2ListDate[i].Id == accid) {
-                component.set('v.UseProduct2Id', UseProduct2ListDate[i].Id);
-                component.set('v.data.UseProduct2__c', UseProduct2ListDate[i].Id);
-            }
-        }
-        var UseProduct1_TEXT = component.find('UseProduct1_TEXT').get('v.value');
-        var UseProduct3_TEXT = component.find('UseProduct3_TEXT').get('v.value');
-        if(UseProduct1_TEXT != accname && UseProduct3_TEXT != accname){
-            component.set("v.UseProduct2", accname);
-        }else{
-            component.set('v.errorMessage', '涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝�');
-            this.showErrorToast(component);
-        }
-        
-    },
-       //妯$硦鏌ヨ浣跨敤浜у搧3
-    searchUseProduct3: function (component, event, helper) {
-        var UseProduct3Name = event.getParam("value");
-        var select_ProductClassification = component.find('select_ProductClassification').get('v.value');
-        var action = component.get("c.getUseProduct1");
-        action.setParams({
-            "UseProduct1Name": UseProduct3Name,
-            "select_ProductClassification" :select_ProductClassification
-        });
-        action.setCallback(this, function (response) {
-            var state = response.getState();
-            if (state === "SUCCESS") {
-                var UseProduct3_List = component.find('UseProduct3_List');
-                var UseProduct3List = response.getReturnValue();
-                if (UseProduct3List.length > 0) {
-                    $A.util.addClass(UseProduct3_List, 'slds-is-open');
-                } else {
-                    $A.util.removeClass(UseProduct3_List, 'slds-is-open');
-                }
-                component.set("v.UseProduct3List", response.getReturnValue());
-            } else {
-                $A.util.removeClass(UseProduct3_List, 'slds-is-open');
-            }
-        });
-        $A.enqueueAction(action);
-    },
-    hideSearchUseProduct3: function (component, event, helper) {
-        var UseProduct3_List = component.find('UseProduct3_List');
-        $A.util.removeClass(UseProduct3_List, 'slds-is-open');
-    },
-    seletUseProduct3Change: function (component, event, helper) {
-        var UseProduct3_List = component.find('UseProduct3_List');
-        $A.util.removeClass(UseProduct3_List, 'slds-is-open');
-        var accname = event.currentTarget.dataset.accname;
-        var accid = event.currentTarget.dataset.accid;
-        var UseProduct3ListDate = component.get('v.UseProduct3List');
-        for (var i = 0; i < UseProduct3ListDate.length; i++) {
-            if (UseProduct3ListDate[i].Id == accid) {
-                component.set('v.UseProduct3Id', UseProduct3ListDate[i].Id);
-                component.set('v.data.UseProduct3__c', UseProduct3ListDate[i].Id);
-            }
-        }
-        var UseProduct1_TEXT = component.find('UseProduct1_TEXT').get('v.value');
-        var UseProduct2_TEXT = component.find('UseProduct2_TEXT').get('v.value');
-        if(UseProduct1_TEXT != accname && UseProduct2_TEXT != accname ){
-            component.set("v.UseProduct3", accname);
-        }else{
-            component.set('v.errorMessage', '涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝�');
-            this.showErrorToast(component);
-        }
-        
-    },
-    //hospitalLinkId 缁忛攢鍟嗗尰闄㈢殑ID   鍖婚櫌浜哄憳澶嶅埗鐨勫湴鏂�
-    doctor_change: function (component, event, helper) {
-        var doctor_value = component.find('select_doctor').get('v.value');
-        var doctor_list = component.get('v.doctor_list');
-        var flg = false;
-        for (var i = 0; i < doctor_list.length; i++) {
-            if (doctor_list[i].value == doctor_value) {
-                component.set('v.doctor_title', doctor_list[i].Doctor_Division1__c);
-                flg = true;
-                break;
-            }
-        }
-        if (flg == false) {
-            component.set('v.doctor_title', '');
-        }
-    },
-    set_doctor_list: function (component) {
-        var hospital_id = component.get('v.hospitalLinkId');
-        if (hospital_id) {
-            component.set('v.login', true);
-            var action = component.get('c.getDoctorList');
-            action.setParams({
-                "hospital_id": hospital_id,
-            });
-            action.setCallback(this, function (response) {
-                var state = response.getState();
-                if (state == 'SUCCESS') {
-                    var res = this.conv_selected(response.getReturnValue());
-                    var default_doctor = component.get('v.default_select_doctor_id');
-                    if (default_doctor != '' && res.length > 0) {
-                        var doctor_title = '';
-                        let awsids = [];
-                        for (var i = 0; i < res.length; i++) {
-                            if (res[i].value == default_doctor) {
-                                res[i].selected = true;
-                                doctor_title = res[i].Doctor_Division1__c;
-                            } else {
-                                res[i].selected = false;
-                            }
-                            if(res[i].AWS_Data_Id__c){
-                                awsids.push(res[i].AWS_Data_Id__c);
-                            }
-                        }
-                        component.find('select_doctor').set('v.options', res);
-                        component.set('v.doctor_title', doctor_title);
-                        
-                        if(awsids.length > 0){
-                            let PIConfig = component.get('v.PIConfig');
-                            let staticResourceAgencyContact = JSON.parse(PIConfig.staticResourceAgencyContact);
-                            AWSService.search(staticResourceAgencyContact.searchUrl,{
-                                dataIds:awsids
-                            }, function(data){
-                                if(data && data.object && data.object.length){
-                                    let m = {};
-                                    for(let di in data.object){
-                                        if(data.object[di] && data.object[di].dataId){
-                                            m[data.object[di].dataId] = data.object[di];
-                                        }
-                                    }
-                                    
-                                    for(let ri in res){
-                                        if(res[ri] && res[ri].AWS_Data_Id__c && m.hasOwnProperty(res[ri].AWS_Data_Id__c)){
-                                            res[ri].label = m[res[ri].AWS_Data_Id__c].name;
-                                        }
-                                    }
-                                    component.find('select_doctor').set('v.options', res);
-                                }
-                                
-                                component.set('v.login', false);
-                            }, staticResourceAgencyContact.token);
-                        }
-                    } else {
-                        component.find('select_doctor').set('v.options', res);
-                        if (res.length > 0) {
-                            component.set('v.doctor_title', res[0].Doctor_Division1__c);
-                        }
-                    }
-                    component.set('v.default_select_doctor_id', '');
-                    component.set('v.doctor_list', res);
-                    component.set('v.login', false);
-                }
-                else {
-                    component.set('v.errorMessage', 'set_doctor_list failed.');
-                    this.showErrorToast(component);
-                    component.set('v.login', false);
-                }
-            });
-            $A.enqueueAction(action);
-        }
-    },
-    productcategoryChange1: function (component, event, helper) {
-        var product_category_id = component.find('select_Product1').get('v.value');
-        var pcId1 = component.find('select_Product2').get('v.value');
-        var pcId2 = component.find('select_Product3').get('v.value');
-        var p1bool = pcId1 != '' && pcId1 != null && pcId1 != undefined;
-        var p2bool = pcId2 != '' && pcId2 != null && pcId2 != undefined;
-        var p0bool = product_category_id != '' && product_category_id != null && product_category_id != undefined;
-        if ((p1bool && p0bool && product_category_id == pcId1) || (p2bool && p0bool && product_category_id == pcId2)) {
-            component.set('v.errorMessage', '涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�');
-            this.showErrorToast(component);
-            component.find('select_Product1').set('v.value', '');
-        }
-    },
-    productcategoryChange2: function (component, event, helper) {
-        var product_category_id = component.find('UseProduct2_TEXT').get('v.value');
-        var pcId1 = component.find('UseProduct1_TEXT').get('v.value');
-        var pcId2 = component.find('UseProduct3_TEXT').get('v.value');
-        var p1bool = pcId1 != '' && pcId1 != null ;
-        var p2bool = pcId2 != '' && pcId2 != null ;
-        var p0bool = product_category_id != '' && product_category_id != null;
-        if ((p1bool && p0bool && product_category_id == pcId1) || (p2bool && p0bool && product_category_id == pcId2)) {
-            component.set('v.errorMessage', '涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�');
-            this.showErrorToast(component);
-            component.set('v.UseProduct2_TEXT','');
-        }
-    },
-    productcategoryChange3: function (component, event, helper) {
-        var product_category_id = component.find('select_Product3').get('v.value');
-        var pcId1 = component.find('select_Product1').get('v.value');
-        var pcId2 = component.find('select_Product2').get('v.value');
-        var p1bool = pcId1 != '' && pcId1 != null && pcId1 != undefined;
-        var p2bool = pcId2 != '' && pcId2 != null && pcId2 != undefined;
-        var p0bool = product_category_id != '' && product_category_id != null && product_category_id != undefined;
-        if ((p1bool && p0bool && product_category_id == pcId1) || (p2bool && p0bool && product_category_id == pcId2)) {
-            component.set('v.errorMessage', '涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�');
-            this.showErrorToast(component);
-            component.find('select_Product3').set('v.value', '');
-        }
-    },
-    conv_selected: function (obj) {
-        for (var i = 0; i < obj.length; i++) {
-            if (obj[i].selected) {
-                if (obj[i].selected == 'true') {
-                    obj[i].selected = true;
-                } else {
-                    obj[i].selected = false;
-                }
-            }
-        }
-        return obj;
-    },
-    set_selected: function (component, aura_id_name, value) {
-        var select_tmp = component.find(aura_id_name).get('v.options');
-        if (select_tmp) {
-            for (var i = 0; i < select_tmp.length; i++) {
-                if (select_tmp[i].value == value) {
-                    select_tmp[i].selected = true;
-                } else {
-                    select_tmp[i].selected = false;
-                }
-            }
-            component.find(aura_id_name).set('v.options', select_tmp);
-            return true;
-        } else {
-            return false;
-        }
-    },
-    //寮瑰嚭 鎴愬姛鎻愮ず
-    showSuccessToast: function (component) {
-        debugger
-        $A.util.removeClass(component.find('successDiv'), 'slds-hide');
-        window.setTimeout($A.getCallback(function () {
-            $A.util.addClass(component.find('successDiv'), 'slds-hide');
-        }),
-            3000
-        );
-    },
-    //寮瑰嚭 鎴愬姛鎻愮ず
-    showSuccessToast01: function (component) {
-        debugger
-        $A.util.removeClass(component.find('successDiv01'), 'slds-hide');
-        window.setTimeout($A.getCallback(function () {
-            $A.util.addClass(component.find('successDiv01'), 'slds-hide');
-        }),
-            3000
-        );
-    },
-    //寮瑰嚭 閿欒鎻愮ず
-    showErrorToast: function (component) {
-        debugger
-        $A.util.removeClass(component.find('errorDiv'), 'slds-hide');
-        window.setTimeout($A.getCallback(function () {
-            $A.util.addClass(component.find('errorDiv'), 'slds-hide');
-        }),
-            3000
-        );
-    },
-    error: function (message) {
-        var toastEvent = $A.get("e.force:showToast");
-        toastEvent.setParams({
-            "title": "閿欒!",
-            "message": message,
-            "type": "error",
-            "duration": "sticky"
-        });
-        toastEvent.fire();
-    },
-    createCon: function (component, event, helper) {
-        var modal_newAC = component.find('modal_newAC');
-        $A.util.removeClass(modal_newAC, 'disp_none');
-        component.set('v.truthy', true);
-    },
-    hideCmp: function (component, event, helper) {
-        var div1 = component.find('report')
-        var div2 = component.find('report_list')
-        $A.util.addClass(div1, 'disp_none');
-        $A.util.addClass(div2, 'disp_none');
-    },
-    handleSuccess: function (component, event, helper) {
-        var insertId = event.getParams().response.Id;
-        var displayValue = event.getParams().response.fields.Name.value;
-        event.setParams({});
-        component.set('v.truthy', false);
-        var modal_newAC = component.find('modal_newAC')
-        $A.util.addClass(modal_newAC, 'disp_none');
-        component.set('v.successMessage', '.鍖婚櫌浜哄憳宸插垱寤恒��');
-        this.showSuccessToast(component);
-        this.set_doctor_list(component, event, helper);
-    },
-    createCancel: function (component, event, helper) {
-        component.set('v.truthy', false);
-        var modal_newAC = component.find('modal_newAC')
-        $A.util.addClass(modal_newAC, 'disp_none');
-    },
-    //绉戝璧嬪��
-    setOpportunity_cfilter: function (component) {
-        var hosId = component.get('v.hospitalId');
-        var Department_Cateogy__c = component.find('select_department').get('v.value');
-        var opportunity_cfilter = '';
-        if (hosId != '' && hosId != null) {
-            opportunity_cfilter = ' Agency_Hospital__r.Hospital__c=' + '\'' + hosId + '\'';
-        }
-        if (Department_Cateogy__c != '' && Department_Cateogy__c != null) {
-            if (opportunity_cfilter != '' && opportunity_cfilter != null) {
-                opportunity_cfilter += ' AND ';
-            }
-            opportunity_cfilter += 'Department_Cateogy__c=' + '\'' + Department_Cateogy__c + '\'';
-        }
-        component.set('v.opportunity_cfilter', opportunity_cfilter);
-    },
-    readFile: function (component, helper, file) {
-        if (!file) return;
-        if (!file.name.match(/\.(csv||CSV)$/)) {
-            return alert('only support csv files');
-        } else {
-            reader = new FileReader();
-            reader.onerror = function errorHandler(evt) {
-                switch (evt.target.error.code) {
-                    case evt.target.error.NOT_FOUND_ERR:
-                        alert('File Not Found!');
-                        break;
-                    case evt.target.error.NOT_READABLE_ERR:
-                        alert('File is not readable');
-                        break;
-                    case evt.target.error.ABORT_ERR:
-                        break; // noop
-                    default:
-                        alert('An error occurred reading this file.');
-                };
-            }
-            reader.onabort = function (e) {
-                alert('File read cancelled');
-            };
-            reader.onloadstart = function (e) {
-                var output = '<ui type=\"disc\"><li><strong>' + file.name + '</strong> (' + file.type + ')- ' + file.size + 'bytes, last modified: ' + file.lastModifiedDate.toLocaleDateString() + '</li></ui>';
-                component.set("v.filename", file.name);
-                component.set("v.TargetFileName", output);
-            };
-            reader.onload = function (e) {
-                debugger;
-                var data = e.target.result;
-                
-                component.set("v.fileContentData", data);
-                console.log("file data" + JSON.stringify(data));
-                var allTextLines = data.split(/\r\n|\n/);
-                console.log("qqqqqqqqqqqqqqqqqqq" + allTextLines);
-                var dataRows = allTextLines.length - 1;
-                var headers = allTextLines[0].split(',');
-                var numOfRows = component.get("v.NumOfRecords");
-                if (dataRows > numOfRows + 1 || dataRows == 1 || dataRows == 0) {
-                    alert("File Rows between 1 to " + numOfRows + " .");
-                    component.set("v.showMain", true);
-                }
-                else {
-                    var lines = [];
-                    var filecontentdata;
-                    var content = "<table class=\"table slds-table slds-table--bordered slds-table--cell-buffer\">";
-                    content += "<thead><tr class=\"slds-text-title--caps\">";
-                    content += '<th scope=\"col"\>' + '琛屽彿' + '</th>';
-                    for (i = 0; i < headers.length; i++) {
-                        content += '<th scope=\"col"\>' + headers[i] + '</th>';
-                    }
-                    content += "</tr></thead>";
-                    for (var i = 1; i < allTextLines.length; i++) {
-                        filecontentdata = allTextLines[i].split(',');
-                        if (filecontentdata[0] != '') {
-                            content += "<tr>";
-                            content += "<td>" + i + "</td>";
-                            for (var j = 0; j < filecontentdata.length; j++) {
-                                content += '<td>' + filecontentdata[j] + '</td>';
-                            }
-                            content += "</tr>";
-                        }
-                    }
-                    content += "</table>";
-                    console.log(content);
-                    component.set("v.TableContent", content);
-                    component.set("v.showMain", false);
-                }
-            }
-            reader.readAsText(file, 'gb2312');
-
-        }
-        var reader = new FileReader();
-        reader.onloadend = function () {
-        };
-        reader.readAsDataURL(file);
-    },
-
-    saveRecords: function (component, event, helper) {
-        component.set('v.login', true);
-        var action = component.get("c.processData");
-        var fieldsList = ['Name', 'Phone', 'AccountNumber']; //Please write your code dynamic fields
-        action.setParams({
-            fileData: component.get("v.fileContentData"),
-            sobjectName: 'Account', //Any object
-            fields: fieldsList
-        });
-        action.setCallback(this, function (response) {
-            var state = response.getState();
-            if (state === "SUCCESS") {
-                var res = response.getReturnValue();
-                var res1 = '';
-                if (res != 'success') {
-                    var ress = res.split('=');
-                    console.log(ress);
-                    for (var i = 0; i < ress.length; i++) {
-                        res1 += ress[i].substr(7) + '\n';
-                    }
-                    console.log("==" + res1);
-                    component.set('v.errorMessage', res1 + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
-                    this.showErrorToast(component);
-                    component.set('v.login', false);
-                } else {
-                    component.set('v.successMessage', '瀵煎叆鎴愬姛');
-                    this.showSuccessToast01(component);
-                    component.set("v.showMain", true);
-                    component.set('v.login', false);
-                    this.doinit(component, event, helper);
-                }
-            }
-            else if (state === "INCOMPLETE") {
-                component.set('v.login', false);
-            }
-            else if (state === "ERROR") {
-                var errors = response.getError();
-                if (errors) {
-                    if (errors[0] && errors[0].message) {
-                        console.log("Error message: " +
-                            errors[0].message);
-                        component.set('v.login', false);
-                    }
-                } else {
-                    console.log("Unknown error");
-                    component.set('v.login', false);
-                }
-            }
-        });
-        $A.enqueueAction(action);
-
-    },
-    //瀵煎嚭鐨凜SV鏂囦欢
-    convertArrayOfObjectsToCSV: function (component, objectRecords) {
-        var csvStringResult, counter, keys, columnDivider, lineDivider, thkeys;
-        if (objectRecords == null || !objectRecords.length) {
-            return null;
-        }
-        columnDivider = ',';
-        lineDivider = '\n';
-        keys = ['Submit_date__c', 'Person_In_Charge2__c', 'Report_Date__c', 'Agency_Hospital__c','Department_Cateogy__c','DealerPersonnel__c','WorkRecord__c','doctor2__c','ProductClassification__c','UseProduct1__c', 'UseProduct2__c','UseProduct3__c', 'EffectProgress__c','ConsumptionOfConsumables__c',  'WarlockClassification__c', 'ProductCcategory__c', 'productCategories__c','warlocksNumber__c','WorkMark__c'];
-        thkeys = ['鍛�', '鎷呭綋', '娲诲姩鏃�', '鍖婚櫌', '绉戝', '缁忛攢鍟嗕汉鍛�', '宸ヤ綔璁板綍',  '鍖婚櫌浜哄憳','浜у搧鍒嗙被(绗笁鍒嗙被)', '浣跨敤浜у搧1(浜у搧鍨嬪彿)', '浣跨敤浜у搧2','浣跨敤浜у搧3','鏁堟灉/杩涘害','绉戝鍚岀被鑰楁潗鏈堜娇鐢ㄩ噺','鏈+鍒嗙被','宸查噰鐢ㄥ叾浠栧搧鐗�','鍏朵粬鍝佺墝浜у搧绫诲埆','浜у搧鐢ㄩ噺','宸ヤ綔鏍囪']
-        csvStringResult = '';
-        csvStringResult += thkeys.join(columnDivider);
-        csvStringResult += lineDivider;
-        console.log("杩涘叆瀵煎嚭helper");
-        for (var i = 0; i < objectRecords.length; i++) {
-            counter = 0;
-            for (var sTempkey in keys) {
-                var skey = keys[sTempkey];
-                if (counter > 0) {
-                    csvStringResult += columnDivider;
-                }
-                if (typeof objectRecords[i][skey] === "undefined") {
-                    csvStringResult += '' + '' + '';
-                    continue;
-                }
-                if (skey == 'Person_In_Charge2__c') {
-                    csvStringResult += objectRecords[i].Person_In_Charge2__r.Name;
-                } else if (skey == 'Agency_Hospital__c') {
-                    csvStringResult += objectRecords[i].Agency_Hospital__r.Name;
-                } else  if (skey == 'DealerPersonnel__c') {
-                    csvStringResult +=  objectRecords[i].DealerPersonnel__r.Name;
-                } else if (skey == 'doctor2__c') {
-                    csvStringResult +=  objectRecords[i].doctor2__r.Name;
-                } else if (skey == 'UseProduct1__c') {
-                    csvStringResult +=  objectRecords[i].UseProduct1__r.Name;
-                } else if (skey == 'UseProduct2__c') {
-                    csvStringResult +=  objectRecords[i].UseProduct2__r.Name;
-                } else if (skey == 'UseProduct3__c') {
-                    csvStringResult +=  objectRecords[i].UseProduct3__r.Name;
-                }else{
-                    csvStringResult +=  objectRecords[i][skey] ;
-                }
-                counter++;
-            }
-            console.log("瀵煎嚭寰幆缁撴潫");
-            csvStringResult += lineDivider;
-        }
-        return csvStringResult;
-    },
-    //  瀵煎嚭椤甸潰鏄剧ず鐨勬ā鏉�
-    showExportDate: function (component, objectRecords) {
-        console.log('杩涘叆showexceportdate' + objectRecords);
-        var keys = ['Submit_date__c', 'Person_In_Charge2__c', 'Report_Date__c', 'Agency_Hospital__c','Department_Cateogy__c','DealerPersonnel__c','WorkRecord__c','doctor2__c','ProductClassification__c','UseProduct1__c', 'UseProduct2__c','UseProduct3__c', 'EffectProgress__c','ConsumptionOfConsumables__c',  'WarlockClassification__c', 'ProductCcategory__c','productCategories__c', 'warlocksNumber__c','WorkMark__c'];
-        var headers = ['鍛�', '鎷呭綋', '娲诲姩鏃�', '鍖婚櫌', '绉戝', '缁忛攢鍟嗕汉鍛�', '宸ヤ綔璁板綍',  '鍖婚櫌浜哄憳','浜у搧鍒嗙被(绗笁鍒嗙被)', '浣跨敤浜у搧1(浜у搧鍨嬪彿)', '浣跨敤浜у搧2','浣跨敤浜у搧3','鏁堟灉/杩涘害','绉戝鍚岀被鑰楁潗鏈堜娇鐢ㄩ噺','鏈+鍒嗙被','宸查噰鐢ㄥ叾浠栧搧鐗�','鍏朵粬鍝佺墝浜у搧绫诲埆','浜у搧鐢ㄩ噺','宸ヤ綔鏍囪']
-        var content = "<table class=\"table slds-table slds-table--bordered slds-table--cell-buffer\">";
-        content += "<thead><tr class=\"slds-text-title--caps\">";
-        for (i = 0; i < headers.length; i++) {
-            content += '<th scope=\"col"\>' + headers[i] + '</th>';
-        }
-        content += "</tr></thead>";
-        for (var i = 0; i < objectRecords.length; i++) {
-            console.log('for' + content);
-            content += '<tr>';
-            for (var sTempkey in keys) {
-                console.log('for1' + sTempkey);
-                var skey = keys[sTempkey];
-                if (typeof objectRecords[i][skey] === "undefined") {
-                    content += '<td>' + '' + '</td>';
-                    continue;  
-                }
-                console.log('for2' + objectRecords[i].Person_In_Charge2__r.Name);
-                if (skey == 'Person_In_Charge2__c') {
-                    content += '<td>' + objectRecords[i].Person_In_Charge2__r.Name + '</td>';
-                } else if (skey == 'Agency_Hospital__c') {
-                    content += '<td>' + objectRecords[i].Agency_Hospital__r.Name + '</td>';
-                } else if (skey == 'DealerPersonnel__c') {
-                    content += '<td>' + objectRecords[i].DealerPersonnel__r.Name + '</td>';
-                } else if (skey == 'doctor2__c') {
-                    content += '<td>' + objectRecords[i].doctor2__r.Name + '</td>';
-                } else if (skey == 'UseProduct1__c') {
-                    content += '<td>' + objectRecords[i].UseProduct1__r.Name + '</td>';
-                } else if (skey == 'UseProduct2__c') {
-                    content += '<td>' + objectRecords[i].UseProduct2__r.Name + '</td>';
-                } else if (skey == 'UseProduct3__c') {
-                    content += '<td>' + objectRecords[i].UseProduct3__r.Name + '</td>';
-                }else{
-                    content += '<td>' + objectRecords[i][skey] + '</td>';
-                }
-            }
-            content += '</tr>'
-        }
-        content += '</table>';
-        console.log("helper寰幆缁撴潫" + content);
-        component.set("v.TableContent2", content);
-        component.set("v.showMain", false);
-    },
-
-    select_repores_date: function (component, event, helper) {
-        component.set('v.login', true);
-        var reportsdate1 = component.find('input-report-date1').get('v.value');
-        var reportsdate2 = component.find('input-report-date2').get('v.value');
-        console.log('杈撳叆鐨勫紑濮嬫棩鏈�' + reportsdate1 + '杈撳叆鐨勭粨鏉熸棩鏈�' + reportsdate2);
-        var action = component.get("c.getReportsByDate");
-        console.log('杈撳叆鐨勫紑濮嬫棩鏈�1');
-        action.setParams({
-            date1: reportsdate1,
-            date2: reportsdate2
-        });
-        console.log('杈撳叆鐨勫紑濮嬫棩鏈�2');
-        action.setCallback(this, function (response) {
-            var state = response.getState();
-            if (state === "SUCCESS") {
-                var res = response.getReturnValue();
-                console.log('杈撳叆鐨勫紑濮嬫棩鏈�3' + res);
-                component.set('v.login', false);
-                
-                // PI 鏀归�� By Bright 20220328
-                if(true){
-                    let awsids = [];
-                    for (let ri in res) {
-                        if(res[ri] && res[ri].doctor2__r && res[ri].doctor2__r.AWS_Data_Id__c){
-                            awsids.push(res[ri].doctor2__r.AWS_Data_Id__c);
-                        }
-                    }                    
-                    if(awsids.length > 0){
-                        let PIConfig = component.get('v.PIConfig');
-                        let staticResourceAgencyContact = JSON.parse(PIConfig.staticResourceAgencyContact);
-                        AWSService.search(staticResourceAgencyContact.searchUrl,{
-                            dataIds:awsids
-                        }, function(data){
-                            if(data && data.object && data.object.length){
-                                let m = {};
-                                for(let di in data.object){
-                                    if(data.object[di] && data.object[di].dataId){
-                                        m[data.object[di].dataId] = data.object[di];
-                                    }
-                                }
-                                
-                                for(let ri in res){
-                                    if(res[ri] && res[ri].doctor2__r && res[ri].doctor2__r.AWS_Data_Id__c && m.hasOwnProperty(res[ri].doctor2__r.AWS_Data_Id__c)){
-                                        res[ri].doctor2__r.Name = m[res[ri].doctor2__r.AWS_Data_Id__c].name;
-                                    }
-                                }
-                            }
-                            helper.showExportDate(component, res);
-                            
-                            component.set('v.login', false);
-                        }, staticResourceAgencyContact.token);
-                    }else{
-                        helper.showExportDate(component, res);
-                    }
-                }
-                
-                
-                component.set('v.reports_date', res);
-            } else {
-                alert('瀵煎嚭澶辫触,璇锋鏌ユ椿鍔ㄦ棩');
-                component.set('v.login', false);
-            }
-        });
-        $A.enqueueAction(action);
-
-    },
-
-    showImport: function (component) {
-        var modalimport = component.find('modal_import');
-        var modalimportbg = component.find('modal_importbg');
-        $A.util.removeClass(modalimport, 'disp_none');
-        $A.util.removeClass(modalimportbg, 'disp_none');
-    },
-
-    showExport: function (component) {
-        var modalimport = component.find('modal_export');
-        var modalimportbg = component.find('modal_exportbg');
-        $A.util.removeClass(modalimport, 'disp_none');
-        $A.util.removeClass(modalimportbg, 'disp_none');
-    },
-
-    close_import: function (component) {
-        var modalimport = component.find('modal_import');
-        var modalimportbg = component.find('modal_importbg');
-        $A.util.addClass(modalimport, 'disp_none');
-        $A.util.addClass(modalimportbg, 'disp_none');
-    },
-
-    close_export: function (component) {
-        var modalimport = component.find('modal_export');
-        var modalimportbg = component.find('modal_exportbg');
-        $A.util.addClass(modalimport, 'disp_none');
-        $A.util.addClass(modalimportbg, 'disp_none');
-    },
-    //椤甸潰涓殑鏂板缓鑱屼綅鎸夐挳
-    newlyBuild: function (component, event, helper) {
-        var hospital_id = component.get('v.hospitalLinkId');
-        event.preventDefault(); // stop form submission
-        var fields = component.find("newOpportunityField");
-        var nameer = '';
-        var type = '';
-        var doctorDivision1 = '';
-        fields.forEach(function (field) {
-            if (field.get("v.fieldName") === 'Name') {
-                nameer = field.get("v.value");
-            }
-            if (field.get("v.fieldName") === 'Type__c') {
-                type = field.get("v.value");
-            }
-            if (field.get("v.fieldName") === 'Doctor_Division1__c') {
-                doctorDivision1 = field.get("v.value");
-            }
-        });
-        if (hospital_id) {
-            component.set('v.login', true);
-            var action = component.get('c.newlyBuild');
-            action.setParams({
-                "hospital_id": hospital_id,
-                "nameer": nameer,
-                "type": type,
-                "doctorDivision1": doctorDivision1,
-            });
-            action.setCallback(this, function (response) {
-                var state = response.getState();
-                if (state == 'SUCCESS') {
-                    var res = this.conv_selected(response.getReturnValue());
-                    var default_doctor = component.get('v.default_select_doctor_id');
-                    if (default_doctor != '' && res.length > 0) {
-                        var doctor_title = '';
-                        for (var i = 0; i < res.length; i++) {
-                            if (res[i].value == default_doctor) {
-                                res[i].selected = true;
-                                doctor_title = res[i].Doctor_Division1__c;
-                            } else {
-                                res[i].selected = false;
-                            }
-                        }
-                        component.find('select_doctor').set('v.options', res);
-                        component.set('v.doctor_title', doctor_title);
-                    } else {
-                        component.find('select_doctor').set('v.options', res);
-                        if (res.length > 0) {
-                            component.set('v.doctor_title', res[0].Doctor_Division1__c);
-                        }
-                    }
-                    component.set('v.default_select_doctor_id', '');
-                    component.set('v.doctor_list', res);
-                    component.set('v.login', false);
-                }
-                else {
-                    component.set('v.errorMessage', 'newlyBuild failed.');
-                    this.showErrorToast(component);
-                    component.set('v.login', false);
-                }
-            });
-            $A.enqueueAction(action);
-        }
-    },
-    //绉戝鍚岀被鑰楁潗楠岃瘉蹇呴』杈撳叆鏁板瓧
-    select_ConsumptionOfConsumables : function(component, event, helper) {
-        var sc = event.getSource().get('v.value');
-        if(sc != null){
-            if(sc.length <= 14){
-                if(sc.replace(/\D/gi,"")){
-                    component.set("v.select_ConsumptionOfConsumables",sc);
-                }else{
-                    component.set('v.errorMessage', '蹇呴』杈撳叆鏁板瓧!');
-                    this.showErrorToast(component);
-                }
-            }else{
-                component.set('v.errorMessage', '鏈�澶氳緭鍏�14涓烘暟瀛�!');
-                this.showErrorToast(component);
-            }
-        }
-    },
-    //浜у搧鐢ㄩ噺楠岃瘉蹇呴』杈撳叆鏁板瓧
-    select_warlocksNumber : function(component, event, helper) {
-        var sc = event.getSource().get('v.value');
-        if(sc != null){
-            if(sc.length <= 14){
-                if(sc.replace(/\D/gi,"")){
-                    component.set("v.select_warlocksNumber",sc);
-                }else{
-                    component.set('v.errorMessage', '蹇呴』杈撳叆鏁板瓧!');
-                    this.showErrorToast(component);
-                }
-            }else{
-                component.set('v.errorMessage', '鏈�澶氳緭鍏�14涓烘暟瀛�!');
-                this.showErrorToast(component);
-            }
-        }
-    },
-    //宸ヤ綔浼氳褰�
-    selectPurposeType: function (component,event,helper) {
-        var doctor_value = component.find('select_purpose_type').get('v.value');
-        // alert(doctor_value);
-        if(doctor_value != ''){
-        var action = component.get('c.selectPurposeTypes');
-        action.setParams({
-            'doctor_value': doctor_value
-        });
-        action.setCallback(this, function (response) {
-            var state = response.getState();
-            if (state == 'SUCCESS') {
-                var res = response.getReturnValue();
-                component.find('select_EffectProgress').set("v.options", JSON.parse(JSON.stringify(res)));
-            }
-        });
-        $A.enqueueAction(action);
-    }else{
-        component.find('select_EffectProgress').set('v.options', []);
+  },
+  //鏍规嵁鍛ㄥ拰鎷呭綋鏌ヨ鏁版嵁缁欏垵濮嬮〉闈㈣祴鏁版嵁
+  get_reports: function (component, event, helper, date_str, person_str) {
+    debugger;
+    if (!date_str) {
+      return false;
     }
-    },
 
-    selectProductClassification: function (component,event,helper) {
-        var select_ProductClassification = component.find('select_ProductClassification').get('v.value');
-        if(select_ProductClassification != ''){
-        var action = component.get('c.selectProductClassificationc');
+    if (person_str) {
+      var person_str2 = person_str.split(";");
+      if (person_str2.length > 1) {
+        person_str = person_str2[0];
+      }
+    }
+    date_str = this.get_date_string(date_str);
+    var action = component.get("c.getReports");
+    action.setParams({
+      date_str: date_str,
+      person_str: person_str
+    });
+    component.set("v.login", true);
+    action.setCallback(this, function (response) {
+      debugger;
+      var state = response.getState();
+      if (state == "SUCCESS") {
+        var res = response.getReturnValue();
+        component.set("v.reports", res.reports);
+        component.set("v.report_count", res.reports.length);
+        // 鏇存柊淇濆瓨寰屻伄select_data鐢�
+        var report_id = component.get("v.update_select_report_data_id");
+        if (report_id != "") {
+          for (var i = 0; i < res.reports.length; i++) {
+            if (res.reports[i]["Id"] == report_id) {
+              component.set("v.select_report_data", res.reports[i]);
+              break;
+            }
+          }
+          component.set("v.update_select_report_data_id", "");
+        }
+        if (res.reports.length > 0) {
+          component.set("v.list_message", "");
+          var flag2 = res.reports.length;
+          //fy 20220414 start
+          var report1 = [];
+          var report2 = [];
+          res.reports.forEach((item) => {
+            if (
+              (item.WorkRecord__c == "绉戝浼�" &&
+                item.doctor3__c != undefined) ||
+              ((item.doctor3__c == undefined ||
+                item.doctor3__c == "" ||
+                item.doctor3__c == "") &&
+                (item.doctor2__r == undefined ||
+                  item.doctor2__r == "" ||
+                  item.doctor2__r == ""))
+            ) {
+              report1.push(item);
+            } else {
+              report2.push(item);
+            }
+          });
+          res.reports = report2;
+          //fy 20220414 end
+          // PI 鏀归�� By Bright 20220328
+          if (true) {
+            let doctor_awsids = res.reports.map(function (d) {
+              return d.doctor2__r.AWS_Data_Id__c;
+            });
+            let PIConfig = component.get("v.PIConfig");
+            let staticResourceAgencyContact = JSON.parse(
+              PIConfig.staticResourceAgencyContact
+            );
+            if (doctor_awsids.length > 0) {
+              AWSService.search(
+                staticResourceAgencyContact.searchUrl,
+                {
+                  dataIds: doctor_awsids
+                },
+                function (data) {
+                  if (data && data.object && data.object.length) {
+                    let m = {};
+                    for (let di in data.object) {
+                      if (data.object[di] && data.object[di].dataId) {
+                        m[data.object[di].dataId] = data.object[di];
+                      }
+                    }
+                    debugger;
+                    for (let ri in res.reports) {
+                      if (
+                        res.reports[ri] &&
+                        res.reports[ri].doctor2__r &&
+                        res.reports[ri].doctor2__r.AWS_Data_Id__c &&
+                        m.hasOwnProperty(
+                          res.reports[ri].doctor2__r.AWS_Data_Id__c
+                        )
+                      ) {
+                        res.reports[ri].doctor2__r.awsdata =
+                          m[res.reports[ri].doctor2__r.AWS_Data_Id__c];
+                      }
+                    }
+                    component.set("v.reports", res.reports);
+                    component.set("v.report_count", res.reports.length);
+                  }
+                  //fy 20220414 start
+                  var reports3 = component.get("v.reports");
+                  if (reports3.length < flag2) {
+                    res.reports = [...report1, ...reports3];
+                    component.set("v.reports", res.reports);
+                    component.set("v.report_count", res.reports.length);
+                  }
+                  //fy 20220414 end
+                  component.set("v.login", false);
+                },
+                staticResourceAgencyContact.token
+              );
+            } else {
+              component.set("v.login", false);
+            }
+          }
+        } else {
+          component.set("v.list_message", "no_data");
+          component.set("v.login", false);
+        }
+      } else {
+        component.set("v.errorMessage", "get_reports failed.");
+        this.showErrorToast(component);
+        component.set("v.login", false);
+      }
+    });
+    $A.enqueueAction(action);
+  },
+  //澶嶅埗鎸夐挳鍙樼伆鑹�
+  select_date_change: function (component, event, helper) {
+    this.get_reports(
+      component,
+      event,
+      helper,
+      component.find("select_date").get("v.value"),
+      component.find("select_agency_person").get("v.value")
+    );
+    component.set("v.select_report_data_radio", "");
+    component.find("copy_button").set("v.disabled", true);
+    component.find("delete_button").set("v.disabled", true);
+  },
+
+  select_agency_change: function (component, event, helper) {
+    var select_value = component.find("select_agency_person").get("v.value");
+    var new_label = this.get_agency_person_name(component, select_value);
+    component.set("v.selected_agency_person", new_label);
+    this.get_reports(
+      component,
+      event,
+      helper,
+      component.find("select_date").get("v.value"),
+      select_value
+    );
+    component.set("v.select_report_data_radio", "");
+    component.find("copy_button").set("v.disabled", true);
+    component.find("delete_button").set("v.disabled", true);
+  },
+
+  get_agency_person_name: function (component, agency_person_value) {
+    var allselectlist = component.get("v.allselectlist.AgencyPerson__c");
+    var new_label = "";
+    for (var i = 0; i < allselectlist.length; i++) {
+      if (agency_person_value == allselectlist[i].value) {
+        new_label = allselectlist[i].label;
+        break;
+      }
+    }
+    return new_label;
+  },
+  //澶嶅埗鍜岀紪杈戝洖鏄剧殑浣嶇疆
+  toggle_report: function (component) {
+    debugger;
+    var modal_window = component.find("modal_window");
+    var modal_bg = component.find("modal_bg");
+    if ($A.util.hasClass(modal_window, "disp_none")) {
+      // OPEN
+      $A.util.removeClass(modal_window, "disp_none");
+      $A.util.removeClass(modal_bg, "disp_none");
+      //澶嶅埗  鍜岀紪杈�   鍥炴樉闂鍦ㄨ繖閲岄潰
+      if (
+        component.get("v.mode") == "edit" ||
+        component.get("v.mode") == "copy"
+      ) {
+        var select_data = "";
+        if (component.get("v.mode") == "edit") {
+          select_data = component.get("v.select_report_data");
+        } else if (component.get("v.mode") == "copy") {
+          select_data = component.get("v.select_report_data_radio");
+        }
+        var reports = component.get("v.reports");
+        var Agency_Hospital_text = "";
+        var Agency_Hospital_parent_id = "";
+        // 鍖婚櫌鍚�
+        if (select_data["Agency_Hospital__c"] != "") {
+          for (var i = 0; i < reports.length; i++) {
+            if (
+              reports[i]["Agency_Hospital__c"] ==
+              select_data["Agency_Hospital__c"]
+            ) {
+              Agency_Hospital_text = reports[i]["Agency_Hospital__r"]["Name"];
+              Agency_Hospital_parent_id =
+                reports[i]["Agency_Hospital__r"]["Hospital__c"];
+            }
+          }
+          component.set("v.hospital", Agency_Hospital_text);
+          component.set("v.hospitalId", Agency_Hospital_parent_id);
+          component.set("v.hospitalLinkId", select_data["Agency_Hospital__c"]);
+          component.find("new_con").set("v.disabled", false);
+        }
+        //浣跨敤浜у搧1(浜у搧鍨嬪彿)
+        var UseProduct1Text = "";
+        var UseProduct1Id = "";
+        if (
+          select_data["UseProduct1__c"] != "" &&
+          select_data["UseProduct1__c"] != undefined
+        ) {
+          for (var i = 0; i < reports.length; i++) {
+            if (reports[i]["UseProduct1__c"] == select_data["UseProduct1__c"]) {
+              UseProduct1Text =
+                reports[i]["UseProduct1__r"]["Asset_Model_No__c"];
+              UseProduct1Id = reports[i]["UseProduct1__c"];
+            }
+          }
+          component.set("v.UseProduct1", UseProduct1Text);
+          component.set("v.UseProduct1Id", select_data["UseProduct1__c"]);
+        }
+        //浣跨敤浜у搧2
+        var UseProduct2Text = "";
+        var UseProduct2Id = "";
+        if (
+          select_data["UseProduct2__c"] != "" &&
+          select_data["UseProduct2__c"] != undefined
+        ) {
+          for (var i = 0; i < reports.length; i++) {
+            if (reports[i]["UseProduct2__c"] == select_data["UseProduct2__c"]) {
+              UseProduct2Text =
+                reports[i]["UseProduct2__r"]["Asset_Model_No__c"];
+              UseProduct2Id = reports[i]["UseProduct2__c"];
+            }
+          }
+          component.set("v.UseProduct2", UseProduct2Text);
+          component.set("v.UseProduct2Id", select_data["UseProduct2__c"]);
+        }
+        //浣跨敤浜у搧3
+        var UseProduct3Text = "";
+        var UseProduct3Id = "";
+        if (
+          select_data["UseProduct3__c"] != "" &&
+          select_data["UseProduct3__c"] != undefined
+        ) {
+          for (var i = 0; i < reports.length; i++) {
+            if (reports[i]["UseProduct3__c"] == select_data["UseProduct3__c"]) {
+              UseProduct3Text =
+                reports[i]["UseProduct3__r"]["Asset_Model_No__c"];
+              UseProduct3Id = reports[i]["UseProduct3__c"];
+            }
+          }
+          component.set("v.UseProduct3", UseProduct3Text);
+          component.set("v.UseProduct3Id", select_data["UseProduct3__c"]);
+        }
+        //娲诲姩鏃�
+        var reportDate;
+        if (select_data["Report_Date__c"] != "") {
+          for (var i = 0; i < reports.length; i++) {
+            if (reports[i]["Report_Date__c"] == select_data["Report_Date__c"]) {
+              reportDate = reports[i]["Report_Date__c"];
+            }
+          }
+          component.set("v.data.Report_Date__c", reportDate);
+        }
+        // 绉戝
+        // if (select_data['Department_Cateogy__c'] != '') {
+        //     component.find('select_department').set('v.value',select_data['Department_Cateogy__c']);
+        // }
+        //fy Department_Cateogy_text__c
+        if (select_data["Department_Cateogy_text__c"] != "") {
+          component
+            .find("select_department")
+            .set("v.value", select_data["Department_Cateogy_text__c"]);
+        }
+        //缁忛攢鍟嗕汉鍛�
+        if (select_data["DealerPersonnel__c"] != "") {
+          this.set_selected(
+            component,
+            "select_DealerPersonnel",
+            select_data["DealerPersonnel__c"]
+          );
+        }
+        // 娲诲姩鍖哄垎
+        if (select_data["WorkRecord__c"] != "") {
+          this.set_selected(
+            component,
+            "select_purpose_type",
+            select_data["WorkRecord__c"]
+          );
+          this.selectPurposeType(component);
+        }
+        // 鎷滆浜�
+        if (select_data["WorkRecord__c"] == "绉戝浼�") {
+          component.set(
+            "v.default_select_doctor_id2",
+            select_data["doctor3__c"]
+          );
+          var a = component.get("v.default_select_doctor_id2");
+          this.set_doctor_list(component);
+        } else {
+          component.set(
+            "v.default_select_doctor_id",
+            select_data["doctor2__c"]
+          );
+          this.set_doctor_list(component);
+        }
+        //浜у搧鍒嗙被(绗笁鍒嗙被)
+        if (select_data["ProductClassification__c"] != null) {
+          this.set_selected(
+            component,
+            "select_ProductClassification",
+            select_data["ProductClassification__c"]
+          );
+          this.selectProductClassification(component);
+        }
+        // 浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺
+        if (select_data["ConsumptionOfConsumables__c"] != "") {
+          component
+            .find("select_ConsumptionOfConsumables")
+            .set("v.value", select_data["ConsumptionOfConsumables__c"]);
+        }
+        // 浜у搧鐢ㄩ噺
+        if (select_data["warlocksNumber__c"] != "") {
+          component
+            .find("select_warlocksNumber")
+            .set("v.value", select_data["warlocksNumber__c"]);
+        }
+        // 鏀彺闇�姹�
+        if (select_data["WorkMark__c"] != false) {
+          component
+            .find("select_WorkMark")
+            .set("v.checked", select_data["WorkMark__c"]);
+        }
+        debugger;
+
+        var report_id = component.get("v.edit_copy_select_report_id");
+        if (report_id != "") {
+          var select_EffectProgress1 = "";
+          var WarlockClassification = "";
+          var ProductCcategory = "";
+          var productCategories = "";
+          var i = 0;
+          for (i = 0; i < reports.length; i++) {
+            if (report_id == reports[i]["Id"]) {
+              select_EffectProgress1 = reports[i]["EffectProgress__c"];
+              WarlockClassification = reports[i]["WarlockClassification__c"];
+              ProductCcategory = reports[i]["ProductCcategory__c"];
+              productCategories = reports[i]["productCategories__c"];
+              break;
+            }
+          }
+          //鏁堟灉/杩涘害
+          if (select_EffectProgress1 != null && select_EffectProgress1 != "") {
+            component
+              .find("select_EffectProgress")
+              .set("v.value", select_EffectProgress1);
+          }
+          //鏈+鍒嗙被
+          if (WarlockClassification != null && WarlockClassification != "") {
+            component
+              .find("select_OtherBrandConsumables")
+              .set("v.value", WarlockClassification);
+          }
+          //宸查噰鐢ㄥ叾浠栧搧鐗�
+          if (ProductCcategory != null && ProductCcategory != "") {
+            component
+              .find("select_ProductCcategory")
+              .set("v.value", ProductCcategory);
+            this.selectpurposetype(component);
+          }
+          //鍏朵粬鍝佺墝浜у搧绫诲埆
+          if (productCategories != null && productCategories != "") {
+            component
+              .find("select_productCategories")
+              .set("v.value", productCategories);
+          }
+          component.set("v.edit_copy_select_report_id", "");
+        }
+      }
+    } else {
+      var select_report_data = component.get("v.select_report_data");
+      var Report_Date__c = component.get("v.data.Report_Date__c");
+      var Agency_Hospital__c = component.get("v.hospitalLinkId");
+      var UseProduct1__c = component.get("v.UseProduct1Id");
+      var UseProduct2__c = component.get("v.UseProduct2Id");
+      var UseProduct3__c = component.get("v.UseProduct3Id");
+      var Department_Cateogy__c = component
+        .find("select_department")
+        .get("v.value");
+      var ConsumptionOfConsumables__c = component
+        .find("select_ConsumptionOfConsumables")
+        .get("v.value");
+      var DealerPersonnel__c = component
+        .find("select_DealerPersonnel")
+        .get("v.value");
+      var doctor2__c = component.find("select_doctor").get("v.value");
+      var WorkRecord__c = component.find("select_purpose_type").get("v.value");
+      var EffectProgress__c = component
+        .find("select_EffectProgress")
+        .get("v.value");
+      var WarlockClassification__c = component
+        .find("select_OtherBrandConsumables")
+        .get("v.value");
+      var ProductCcategory__c = component
+        .find("select_ProductCcategory")
+        .get("v.value");
+      var productCategories__c = component
+        .find("select_productCategories")
+        .get("v.value");
+      var warlocksNumber__c = component
+        .find("select_warlocksNumber")
+        .get("v.value");
+      var WorkMark__c = component.find("select_WorkMark").get("v.checked");
+      if (component.get("v.mode") == "new") {
+        var confirm_title = "璀﹀憡!";
+        var confirm_text = "鏀惧純鏂板缓鏃ユ姤锛�";
+        if (
+          !Report_Date__c &&
+          !Agency_Hospital__c &&
+          !UseProduct1__c &&
+          !UseProduct2__c &&
+          !UseProduct3__c &&
+          !Department_Cateogy__c &&
+          !ConsumptionOfConsumables__c &&
+          !DealerPersonnel__c &&
+          !doctor2__c &&
+          !EffectProgress__c &&
+          !WarlockClassification__c &&
+          !ProductCcategory__c &&
+          !productCategories__c &&
+          !warlocksNumber__c &&
+          !WorkMark__c &&
+          !WorkRecord__c
+        ) {
+          this.allclear(component);
+          $A.util.addClass(modal_window, "disp_none");
+          $A.util.addClass(modal_bg, "disp_none");
+          this.close_confirm(component, confirm_title, confirm_text);
+        } else {
+          this.close_confirm(component, confirm_title, confirm_text);
+        }
+      } else if (component.get("v.mode") == "copy") {
+        var confirm_title = "璀﹀憡!";
+        var confirm_text = "鏀惧純鏂板缓鏃ユ姤锛�";
+        if (
+          select_report_data["Report_Date__c"] == Report_Date__c &&
+          select_report_data["Agency_Hospital__c"] == Agency_Hospital__c &&
+          select_report_data["UseProduct1__c"] == UseProduct1__c &&
+          select_report_data["UseProduct2__c"] == UseProduct2__c &&
+          select_report_data["UseProduct3__c"] == UseProduct3__c &&
+          select_report_data["Department_Cateogy__c"] ==
+            Department_Cateogy__c &&
+          select_report_data["ConsumptionOfConsumables__c"] ==
+            ConsumptionOfConsumables__c &&
+          select_report_data["DealerPersonnel__c"] == DealerPersonnel__c &&
+          select_report_data["doctor2__c"] == doctor2__c &&
+          select_report_data["EffectProgress__c"] == EffectProgress__c &&
+          select_report_data["WarlockClassification__c"] ==
+            WarlockClassification__c &&
+          select_report_data["ProductCcategory__c"] == ProductCcategory__c &&
+          select_report_data["productCategories__c"] == productCategories__c &&
+          select_report_data["warlocksNumber__c"] == warlocksNumber__c &&
+          select_report_data["WorkMark__c"] == WorkMark__c &&
+          select_report_data["WorkRecord__c"] == WorkRecord__c
+        ) {
+          this.allclear(component);
+          $A.util.addClass(modal_window, "disp_none");
+          $A.util.addClass(modal_bg, "disp_none");
+        } else {
+          this.close_confirm(component, confirm_title, confirm_text);
+        }
+      } else if (component.get("v.mode") == "edit") {
+        var confirm_title = "璀﹀憡!";
+        var confirm_text = "鏀惧純缂栬緫鏃ユ姤锛�";
+        if (
+          select_report_data["Report_Date__c"] == Report_Date__c &&
+          select_report_data["Agency_Hospital__c"] == Agency_Hospital__c &&
+          select_report_data["UseProduct1__c"] == UseProduct1__c &&
+          select_report_data["UseProduct2__c"] == UseProduct2__c &&
+          select_report_data["UseProduct3__c"] == UseProduct3__c &&
+          select_report_data["Department_Cateogy__c"] ==
+            Department_Cateogy__c &&
+          select_report_data["ConsumptionOfConsumables__c"] ==
+            ConsumptionOfConsumables__c &&
+          select_report_data["DealerPersonnel__c"] == DealerPersonnel__c &&
+          select_report_data["doctor2__c"] == doctor2__c &&
+          select_report_data["EffectProgress__c"] == EffectProgress__c &&
+          select_report_data["WarlockClassification__c"] ==
+            WarlockClassification__c &&
+          select_report_data["ProductCcategory__c"] == ProductCcategory__c &&
+          select_report_data["productCategories__c"] == productCategories__c &&
+          select_report_data["warlocksNumber__c"] == warlocksNumber__c &&
+          select_report_data["WorkMark__c"] == WorkMark__c &&
+          select_report_data["WorkRecord__c"] == WorkRecord__c
+        ) {
+          this.allclear(component);
+          $A.util.addClass(modal_window, "disp_none");
+          $A.util.addClass(modal_bg, "disp_none");
+        } else {
+          this.close_confirm(component, confirm_title, confirm_text);
+        }
+      }
+    }
+  },
+  //鍏抽棴椤甸潰鏄�   灏忕殑鎻愮ず妗嗘槸鍚︽斁寮冩柊寤烘棩鎶�
+  close_confirm: function (component, title, text) {
+    var confirm_status = component.get("v.confirm_status");
+    component.set("v.modal_confirm_title", title);
+    component.set("v.modal_confirm_text", text);
+    var modal_window = component.find("modal_window");
+    var modal_bg = component.find("modal_bg");
+    var modal_confirm = component.find("modal_confirm");
+    var modal_confirm_bg = component.find("modal_confirm_bg");
+    debugger;
+    if (confirm_status == 0) {
+      $A.util.addClass(modal_window, "disp_none");
+      $A.util.addClass(modal_bg, "disp_none");
+      $A.util.removeClass(modal_confirm, "disp_none");
+      $A.util.removeClass(modal_confirm_bg, "disp_none");
+    } else if (confirm_status == 1) {
+      // 鏄�
+      $A.util.addClass(modal_confirm, "disp_none");
+      $A.util.addClass(modal_confirm_bg, "disp_none");
+      component.set("v.mode", "");
+      this.allclear(component);
+      component.set("v.reports_now", "");
+      component.set("v.reports_now_count", 0);
+      component.set("v.confirm_status", 0);
+    } else if (confirm_status == 2) {
+      // 鍚�
+      $A.util.removeClass(modal_window, "disp_none");
+      $A.util.removeClass(modal_bg, "disp_none");
+      $A.util.addClass(modal_confirm, "disp_none");
+      $A.util.addClass(modal_confirm_bg, "disp_none");
+      component.set("v.confirm_status", 0);
+    }
+  },
+  //鏂板缓鎸夐挳
+  new_report: function (component, event, helper) {
+    component.set("v.mode", "new");
+    component.set("v.dialog_type", "鏂板缓");
+    //  鍛�
+    var select_date = component.find("select_date").get("v.value");
+    //  鎷呭綋
+    var select_agency = component.find("select_agency_person").get("v.value");
+    var cm = 0;
+    if (select_agency.indexOf(";") != -1) {
+      select_agency = select_agency.split(";")[0];
+    }
+    component.set("v.selected_date", select_date);
+    //  鎷呭綋
+    var name = component.get("v.selected_agency_person");
+    var ret = this.create_report_header(
+      component,
+      event,
+      helper,
+      name,
+      select_agency,
+      select_date
+    );
+    component.set("v.default_select_doctor_id2", "");
+
+    // SWAG-CF58C3 fy start
+    this.set_aws_url(component, "Agency_Contact__c");
+    // SWAG-CF58C3 fy end
+  },
+  // 澶嶅埗鎸夐挳
+  copy_button: function (component, event, helper) {
+    debugger;
+    this.allclear(component);
+    component.set("v.mode", "copy");
+    component.set("v.dialog_type", "鏂板缓");
+    var select_report_data = component.get("v.select_report_data_radio");
+    component.set("v.loadOpp", true);
+    // 閫�
+    var now = new Date();
+    var start_day = new Date(
+      now.getFullYear(),
+      now.getMonth(),
+      now.getDate() - now.getDay() + 1
+    );
+    var select_date =
+      start_day.getFullYear() +
+      "/" +
+      (start_day.getMonth() + 1) +
+      "/" +
+      start_day.getDate();
+    this.set_selected(component, "select_date", select_date);
+    component.set("v.selected_date", select_date);
+    // 鎷呭綋
+    var select_agency = select_report_data["Person_In_Charge2__c"];
+    var new_label = this.get_agency_person_name(component, select_agency);
+    component.set("v.selected_agency_person", new_label);
+    this.set_selected(component, "select_agency_person", select_agency);
+    var name = component.get("v.selected_agency_person");
+    component.set("v.edit_copy_select_report_id", select_report_data["Id"]);
+    component.set("v.select_report_data", select_report_data);
+
+    var ret = this.create_report_header(
+      component,
+      event,
+      helper,
+      name,
+      select_agency,
+      select_date
+    );
+    // SWAG-CF58C3 fy start
+    this.set_aws_url(component, "Agency_Contact__c");
+    // SWAG-CF58C3 fy end
+  },
+  //鍒犻櫎鎸夐挳
+  delete_button: function (component, event, helper) {
+    debugger;
+    var select_report_data = component.get("v.select_report_data_radio");
+    if (confirm("鏄惁鍒犻櫎璇ユ暟鎹紵")) {
+      debugger;
+      component.set("v.login", true);
+      var action = component.get("c.deleteAgencyReport");
+      action.setParams({
+        agencyReport_id: select_report_data.Id
+      });
+      action.setCallback(this, function (response) {
+        var state = response.getState();
+        if (state == "SUCCESS") {
+          var result = response.getReturnValue();
+          if (result == "success") {
+            this.select_agency_change(component, event, helper);
+          }
+          component.set("v.login", false);
+        } else {
+          component.set("v.login", false);
+        }
+      });
+      $A.enqueueAction(action);
+    }
+  },
+  //澶嶅埗鎸夐挳鍙敤
+  change_report_radio: function (component, event, helper) {
+    debugger;
+    var reports = component.get("v.reports");
+    for (var i = 0; i < reports.length; i++) {
+      if (reports[i].Name == event.getSource().get("v.label")) {
+        component.set("v.select_report_data_radio", reports[i]);
+        component.find("copy_button").set("v.disabled", false);
+        component.find("delete_button").set("v.disabled", false);
+        break;
+      }
+    }
+  },
+  //缂栬緫鎸夐挳
+  edit_button: function (component, event, helper) {
+    this.allclear(component);
+    debugger;
+    component.set("v.loadOpp", true);
+    var index = event.getSource().get("v.value");
+    component.set("v.select_report_data", component.get("v.reports")[index]);
+    component.set("v.mode", "edit");
+    component.set("v.dialog_type", "缂栬緫");
+    var select_date = component.get("v.reports")[index].Submit_date__c;
+    var select_agency = component.get("v.reports")[index].Person_In_Charge2__c;
+    var text_tmp = select_date.split("-");
+    var select_date_text =
+      text_tmp[0] + "/" + Number(text_tmp[1]) + "/" + Number(text_tmp[2]);
+    component.set("v.selected_date", select_date_text);
+    var name = component.get("v.reports")[index].Person_In_Charge2__r.Name;
+    this.set_selected(component, "select_agency_person", select_agency);
+    var new_label = this.get_agency_person_name(component, select_agency);
+    component.set("v.selected_agency_person", new_label);
+    component.set(
+      "v.edit_copy_select_report_id",
+      component.get("v.reports")[index].Id
+    );
+    var ret = this.create_report_header(
+      component,
+      event,
+      helper,
+      name,
+      select_agency,
+      select_date
+    );
+    // SWAG-CF58C3 fy start
+    this.set_aws_url(component, "Agency_Contact__c");
+    // SWAG-CF58C3 fy end
+  },
+  //淇濆瓨
+  save_report: function (component, event, helper) {
+    var UserProType = component.get("v.UserProType");
+    component.find("save_button").set("v.disabled", true);
+    var etEng = component.get("v.etEng");
+    var Report_Date__c = component.get("v.data.Report_Date__c");
+    var Person_In_Charge2__c = "";
+    var Submit_date__c = "";
+    if (component.get("v.mode") == "edit") {
+      // 鍛� Submit_date__c
+      Submit_date__c = component.get("v.select_report_data").Submit_date__c;
+      // 鎷呭綋 Person_In_Charge2__c
+      Person_In_Charge2__c = component.get(
+        "v.select_report_data"
+      ).Person_In_Charge2__c;
+    } else {
+      // 鍛� Submit_date__c
+      Submit_date__c = this.get_date_string(
+        component.find("select_date").get("v.value")
+      );
+      // 鎷呭綋 Person_In_Charge2__c
+      Person_In_Charge2__c = component
+        .find("select_agency_person")
+        .get("v.value");
+    }
+    debugger;
+    // Agency_Report_Header__c
+    var Agency_Report_Header__c = component.get("v.agency_report_header_id");
+    // 鍖婚櫌
+    var Agency_Hospital__c = component.get("v.hospitalLinkId");
+    // 浜у搧鍒嗙被(绗笁鍒嗙被)
+    var ProductClassification__c = component
+      .find("select_ProductClassification")
+      .get("v.value");
+    // 浣跨敤浜у搧1(浜у搧鍨嬪彿)    UseProduct1__c
+    var UseProduct1__c = component.get("v.UseProduct1Id");
+    // 浣跨敤浜у搧2    UseProduct2__c
+    var UseProduct2__c = component.get("v.UseProduct2Id");
+    // 浣跨敤浜у搧3    UseProduct3__c
+    var UseProduct3__c = component.get("v.UseProduct3Id");
+    // 绉戝 Department_Cateogy__c
+    var Department_Cateogy__c = component
+      .find("select_department")
+      .get("v.value");
+    // 缁忛攢鍟嗕汉鍛� DealerPersonnel__c
+    var DealerPersonnel__c = component
+      .find("select_DealerPersonnel")
+      .get("v.value");
+    // 鎷滆浜� doctor2__c
+    var doctor2__c = component.find("select_doctor").get("v.value");
+    // 娲诲姩鍖哄垎浼�   WorkRecord__c
+    var WorkRecord__c = component.find("select_purpose_type").get("v.value");
+    // 鏁堟灉/杩涘害    EffectProgress__c
+    var EffectProgress__c = component
+      .find("select_EffectProgress")
+      .get("v.value");
+    // alert(EffectProgress__c);
+    // 绉戝鍚屾潵鑰楁潗鏈堜娇鐢ㄩ噺   ConsumptionOfConsumables__c
+    var ConsumptionOfConsumables__c = component
+      .find("select_ConsumptionOfConsumables")
+      .get("v.value");
+    // 鏈+鍒嗙被   WarlockClassification__c
+    var WarlockClassification__c = component
+      .find("select_OtherBrandConsumables")
+      .get("v.value");
+    // 宸查噰鐢ㄥ叾浠栧搧鐗�   ProductCcategory__c
+    var ProductCcategory__c = component
+      .find("select_ProductCcategory")
+      .get("v.value");
+    // 鍏朵粬鍝佺墝浜у搧绫诲埆   productCategories__c
+    var productCategories__c = component
+      .find("select_productCategories")
+      .get("v.value");
+    // 浜у搧鐢ㄩ噺   warlocksNumber__c
+    var warlocksNumber__c = component
+      .find("select_warlocksNumber")
+      .get("v.value");
+    // 鏀彺闇�姹�   WorkMark__c
+    var WorkMark__c = component.find("select_WorkMark").get("v.checked");
+    var StageName__c = component.find("select_stageName").get("v.value");
+    var Amount__c =
+      component.get("v.oppdata.Amount__c") != null
+        ? component.get("v.oppdata.Amount__c").toString()
+        : "";
+    var OCMSale_Price__c =
+      component.get("v.oppdata.OCMSale_Price__c") != null
+        ? component.get("v.oppdata.OCMSale_Price__c").toString()
+        : "";
+    var Close_Forecasted_Date__c = component.get(
+      "v.oppdata.Close_Forecasted_Date__c"
+    );
+    var StageName__c_o = component.get("v.StageName__c_o");
+    var Amount__c_o = component.get("v.Amount__c_o");
+    var OCMSale_Price__c_o = component.get("v.OCMSale_Price__c_o");
+    var Close_Forecasted_Date__c_o = component.get(
+      "v.Close_Forecasted_Date__c_o"
+    );
+    if (StageName__c_o == undefined) StageName__c_o = "";
+    if (Amount__c_o == undefined) Amount__c_o = "";
+    if (OCMSale_Price__c_o == undefined) OCMSale_Price__c_o = "";
+    if (Close_Forecasted_Date__c_o == undefined)
+      Close_Forecasted_Date__c_o = "";
+    if (
+      StageName__c == StageName__c_o &&
+      OCMSale_Price__c_o == OCMSale_Price__c &&
+      Amount__c == Amount__c_o &&
+      Close_Forecasted_Date__c == Close_Forecasted_Date__c_o
+    ) {
+      StageName__c = "";
+      Amount__c = "";
+      OCMSale_Price__c = "";
+      Close_Forecasted_Date__c = "";
+    }
+    // 銉愩儶銉囥兗銈枫儳銉�
+    var error = [];
+    //fy start
+    // if(WorkRecord__c != 'SIS'&&WorkRecord__c != '绉戝浼�'){
+    if (WorkRecord__c == "涓村簥淇℃伅(浣跨敤閲�)鏀堕泦") {
+      if (
+        warlocksNumber__c == "" ||
+        warlocksNumber__c == "" ||
+        warlocksNumber__c == undefined
+      ) {
+        error.push("浜у搧鐢ㄩ噺 涓嶈兘涓虹┖");
+      }
+    }
+    //fy end
+    if (WorkRecord__c == "涓村簥淇℃伅(浣跨敤閲�)鏀堕泦" && UserProType == "ENG") {
+      if (
+        productCategories__c == "" ||
+        productCategories__c == "" ||
+        productCategories__c == undefined
+      ) {
+        error.push("鍏朵粬鍝佺墝浜у搧绫诲埆 涓嶅瓨鍦�");
+      }
+    }
+    if (WorkRecord__c == "涓村簥淇℃伅(浣跨敤閲�)鏀堕泦") {
+      if (
+        ProductCcategory__c == "" ||
+        ProductCcategory__c == "" ||
+        ProductCcategory__c == undefined
+      ) {
+        error.push("宸查噰鐢ㄥ叾浠栧搧鐗�  涓嶅瓨鍦�");
+      }
+    }
+    if (WorkRecord__c == "涓村簥淇℃伅(浣跨敤閲�)鏀堕泦") {
+      if (
+        WarlockClassification__c == "" ||
+        WarlockClassification__c == "" ||
+        WarlockClassification__c == undefined
+      ) {
+        error.push("浜у搧1瀵瑰簲OLY浜у搧绾� 涓嶅瓨鍦�");
+      }
+    }
+    if (WorkRecord__c == "涓村簥淇℃伅(浣跨敤閲�)鏀堕泦") {
+      if (
+        ConsumptionOfConsumables__c == "" ||
+        ConsumptionOfConsumables__c == "" ||
+        ConsumptionOfConsumables__c == undefined
+      ) {
+        error.push("浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺 涓嶈兘涓虹┖");
+      }
+    }
+    if (
+      WorkRecord__c != "涓村簥淇℃伅(浣跨敤閲�)鏀堕泦" &&
+      WorkRecord__c != "甯傚満鎺ㄥ箍绫绘椿鍔�"
+    ) {
+      if (
+        EffectProgress__c == "" ||
+        EffectProgress__c == "" ||
+        EffectProgress__c == undefined
+      ) {
+        error.push("鏁堟灉/杩涘害 涓嶅瓨鍦�");
+      }
+    }
+    // if(WorkRecord__c != '涓村簥淇℃伅(浣跨敤閲�)鏀堕泦'&&WorkRecord__c != 'QIS澶勭悊'){
+    if (WorkRecord__c != "涓村簥淇℃伅(浣跨敤閲�)鏀堕泦") {
+      if (
+        UseProduct1__c == "" ||
+        UseProduct1__c == "" ||
+        UseProduct1__c == undefined
+      ) {
+        error.push("浣跨敤浜у搧1(浜у搧鍨嬪彿) 涓嶅瓨鍦�");
+      }
+    }
+    if (
+      ProductClassification__c == "" ||
+      ProductClassification__c == "" ||
+      ProductClassification__c == undefined
+    ) {
+      error.push("浜у搧鍒嗙被(绗笁鍒嗙被) 涓嶅瓨鍦�");
+    }
+    if (
+      WorkRecord__c == "SIS" ||
+      WorkRecord__c == "绉戝浼�" ||
+      WorkRecord__c == "闄㈠唴鍏ラ櫌鐢宠" ||
+      WorkRecord__c == "鏀惰垂椤圭洰鐢宠"
+    ) {
+      if (doctor2__c == "" || doctor2__c == "" || doctor2__c == undefined) {
+        error.push("鎷滆浜� 涓嶅瓨鍦�");
+      }
+    }
+    if (
+      WorkRecord__c == "" ||
+      WorkRecord__c == "" ||
+      WorkRecord__c == undefined
+    ) {
+      error.push("娲诲姩鍖哄垎 涓嶅瓨鍦�");
+    }
+    if (
+      DealerPersonnel__c == "" ||
+      DealerPersonnel__c == "" ||
+      DealerPersonnel__c == undefined
+    ) {
+      error.push("缁忛攢鍟嗕汉鍛� 涓嶅瓨鍦�");
+    }
+    if (
+      Department_Cateogy__c == "" ||
+      Department_Cateogy__c == "" ||
+      Department_Cateogy__c == undefined
+    ) {
+      error.push("绉戝 涓嶅瓨鍦�");
+    }
+    if (
+      Agency_Hospital__c == "" ||
+      Agency_Hospital__c == "" ||
+      Agency_Hospital__c == undefined
+    ) {
+      error.push("鍖婚櫌 涓嶅瓨鍦�");
+    }
+
+    if (
+      Report_Date__c == "" ||
+      Report_Date__c == "" ||
+      Report_Date__c == undefined
+    ) {
+      error.push("娲诲姩鏃� 涓嶅瓨鍦�");
+    }
+    if (
+      Submit_date__c == "" ||
+      Submit_date__c == "" ||
+      Submit_date__c == undefined
+    ) {
+      error.push("鍛� 涓嶅瓨鍦�");
+    }
+    var rDate = new Date(Report_Date__c);
+    var sDate = new Date(Submit_date__c);
+    sDate.setDate(sDate.getDate() - 1);
+    if (rDate < sDate) {
+      error.push("娲诲姩鏃ュ繀椤绘槸鏈懆锛�");
+    }
+    sDate.setDate(sDate.getDate() + 7);
+    if (rDate >= sDate) {
+      error.push("娲诲姩鏃ュ繀椤绘槸鏈懆锛�");
+    }
+    if (
+      Person_In_Charge2__c == "" ||
+      Person_In_Charge2__c == "" ||
+      Person_In_Charge2__c == undefined
+    ) {
+      error.push("鎷呭綋 涓嶅瓨鍦�");
+    }
+    if (
+      Agency_Report_Header__c == "" ||
+      Agency_Report_Header__c == "" ||
+      Agency_Report_Header__c == undefined
+    ) {
+      this.error("Report Header Id 涓嶅瓨鍦�");
+    }
+
+    // if (!UseProduct2__c) { error.push("浣跨敤浜у搧2 涓嶅瓨鍦�"); }
+    // if (!UseProduct3__c) { error.push("浣跨敤浜у搧3 涓嶅瓨鍦�"); }
+
+    // if (!productCategories__c) { error.push("鍏朵粬鍝佺墝浜у搧绫诲埆 涓嶅瓨鍦�"); }
+
+    for (var i = 0; i < error.length; i++) {
+      component.set("v.errorMessage", error[i]);
+      this.showErrorToast(component);
+    }
+    if (error.length > 0) {
+      component.find("save_button").set("v.disabled", false);
+      return false;
+    }
+    // 淇濆瓨鍑︾悊
+    component.set("v.login", true);
+    if (component.get("v.mode") == "edit") {
+      var Agency_Report__c = component.get("v.select_report_data").Id;
+      var action = component.get("c.editAgencyReport");
+      action.setParams({
+        Agency_Report_Id: Agency_Report__c,
+        Department_Cateogy: Department_Cateogy__c,
+        ConsumptionOfConsumables: ConsumptionOfConsumables__c,
+        WorkRecord: WorkRecord__c,
+        EffectProgress: EffectProgress__c,
+        WarlockClassification: WarlockClassification__c,
+        ProductCcategory: ProductCcategory__c,
+        productCategories: productCategories__c,
+        warlocksNumber: warlocksNumber__c,
+        WorkMark: WorkMark__c,
+        ProductClassification: ProductClassification__c,
+        DealerPersonnel: DealerPersonnel__c,
+        Agency_Report_Header: Agency_Report_Header__c,
+        Agency_Hospital: Agency_Hospital__c,
+        UseProduct1: UseProduct1__c,
+        UseProduct2: UseProduct2__c,
+        UseProduct3: UseProduct3__c,
+        Person_In_Charge2: Person_In_Charge2__c,
+        doctor: doctor2__c,
+        Submit_date: Submit_date__c,
+        StageName: StageName__c,
+        oppAmount: Amount__c,
+        oppOCMPrice: OCMSale_Price__c,
+        Close_Forecasted_Date: Close_Forecasted_Date__c,
+        Report_Date: Report_Date__c
+      });
+      action.setCallback(this, function (response) {
+        var state = response.getState();
+        if (state == "SUCCESS") {
+          component.set("v.successMessage", "缂栬緫淇濆瓨鎴愬姛");
+          this.showSuccessToast(component);
+          var report_id = response.getReturnValue();
+          component.set("v.create_agency_report_id", report_id);
+          var select_agency_list =
+            component.get("v.allselectlist").AgencyPerson__c;
+          for (var i = 0; i < select_agency_list.length; i++) {
+            if (
+              select_agency_list[i].value ==
+              component.get("v.select_report_data").Person_In_Charge2__c
+            ) {
+              select_agency_list[i].selected = true;
+            } else {
+              select_agency_list[i].selected = false;
+            }
+          }
+          component
+            .find("select_agency_person")
+            .set("v.options", select_agency_list);
+          component.set("v.update_select_report_data_id", report_id);
+          this.get_reports(
+            component,
+            event,
+            helper,
+            component.get("v.select_report_data").Submit_date__c,
+            component.get("v.select_report_data").Person_In_Charge2__c
+          );
+          component.find("save_button").set("v.disabled", false);
+          component.set("v.login", false);
+        } else {
+          component.set("v.errorMessage", "save_report failed.");
+          this.showErrorToast(component);
+          component.find("save_button").set("v.disabled", false);
+          component.set("v.login", false);
+        }
+      });
+      $A.enqueueAction(action);
+    } else {
+      /* Save (New & Copy) */
+      var action = component.get("c.saveAgencyReport");
+      action.setParams({
+        Department_Cateogy: Department_Cateogy__c,
+        ConsumptionOfConsumables: ConsumptionOfConsumables__c,
+        WorkMark: WorkMark__c,
+        warlocksNumber: warlocksNumber__c,
+        DealerPersonnel: DealerPersonnel__c,
+        ProductCcategory: ProductCcategory__c,
+        productCategories: productCategories__c,
+        WarlockClassification: WarlockClassification__c,
+        ProductClassification: ProductClassification__c,
+        WorkRecord: WorkRecord__c,
+        EffectProgress: EffectProgress__c,
+        Agency_Report_Header: Agency_Report_Header__c,
+        Agency_Hospital: Agency_Hospital__c,
+        Person_In_Charge2: Person_In_Charge2__c,
+        doctor: doctor2__c,
+        Submit_date: Submit_date__c,
+        UseProduct1: UseProduct1__c,
+        UseProduct2: UseProduct2__c,
+        UseProduct3: UseProduct3__c,
+        StageName: StageName__c,
+        oppAmount: Amount__c,
+        oppOCMPrice: OCMSale_Price__c,
+        Close_Forecasted_Date: Close_Forecasted_Date__c,
+        Report_Date: Report_Date__c
+      });
+      action.setCallback(this, function (response) {
+        var state = response.getState();
+        if (state == "SUCCESS") {
+          component.set("v.successMessage", "淇濆瓨鎴愬姛");
+          this.showSuccessToast(component);
+          var report_id = response.getReturnValue();
+          component.set("v.create_agency_report_id", report_id);
+          this.get_reports(
+            component,
+            event,
+            helper,
+            component.find("select_date").get("v.value"),
+            component.find("select_agency_person").get("v.value")
+          );
+          // 銉€兗銉�銉偊銈c兂銉夈偊鍐呫伄涓�瑕х敤
+          var action2 = component.get("c.getReportsById");
+          action2.setParams({
+            report_id: report_id
+          });
+          action2.setCallback(this, function (response) {
+            var state = response.getState();
+            if (state == "SUCCESS") {
+              var res = response.getReturnValue();
+              var reports_now = component.get("v.reports_now");
+              var reports_now_count = 0;
+              if (reports_now.length > 0 && reports_now != "") {
+                reports_now_count = reports_now.length;
+              }
+              // Save&New鏅傘伄銈︺偅銉炽儔銈﹀唴銉囥兗銈夸竴瑕�
+              if (res.length > 0) {
+                reports_now[reports_now_count] = res[0];
+                reports_now.sort(function (a, b) {
+                  if (a.Name > b.Name) return -1;
+                  if (a.Name < b.Name) return 1;
+                  return 0;
+                });
+                component.set("v.reports_now", reports_now);
+                component.set("v.reports_now_count", reports_now.length);
+                var data_list = component.find("modal_data_list_tr");
+              }
+            } else {
+              component.set("v.errorMessage", "get_reports_now failed.");
+              this.showErrorToast(component);
+              component.find("save_button").set("v.disabled", false);
+              component.set("v.login", false);
+            }
+          });
+          $A.enqueueAction(action2);
+          this.allclear(component);
+          component.find("select_WorkMark").set("v.value", false);
+          component.find("save_button").set("v.disabled", false);
+          component.set("v.login", false);
+          this.doinit(component, event, helper);
+        } else {
+          var error = response.getError();
+          component.set("v.errorMessage", "淇濆瓨鏃ユ姤澶辫触");
+          this.showErrorToast(component);
+          component.find("save_button").set("v.disabled", false);
+          component.set("v.login", false);
+        }
+      });
+      $A.enqueueAction(action);
+    }
+  },
+
+  allclear: function (component) {
+    var clear = [{ label: "", value: "", selected: true }];
+    component.set("v.hospital", "");
+    component.set("v.hospitalId", "");
+    component.set("v.hospitalLinkId", "");
+    component.set("v.UseProduct1", "");
+    component.set("v.UseProduct1Id", "");
+    component.set("v.UseProduct2", "");
+    component.set("v.UseProduct2Id", "");
+    component.set("v.UseProduct3", "");
+    component.set("v.UseProduct3Id", "");
+    component.find("select_ProductClassification").set("v.value", "");
+    component.find("select_warlocksNumber").set("v.value", null);
+    component.find("select_department").set("v.value", "");
+    component.find("select_ConsumptionOfConsumables").set("v.value", null);
+    component.find("select_WorkMark").set("v.checked", false);
+    component.find("new_con").set("v.disabled", true);
+    component.find("select_doctor").set("v.options", clear);
+    component
+      .find("select_DealerPersonnel")
+      .set(
+        "v.options",
+        this.conv_selected(component.get("v.allselectlist.DealerPersonnel__c"))
+      );
+    component
+      .find("select_purpose_type")
+      .set(
+        "v.options",
+        this.conv_selected(component.get("v.allselectlist.WorkRecord__c"))
+      );
+    // component.find('select_ProductCcategory').set('v.options', this.conv_selected(component.get('v.allselectlist.ProductCcategory__c')));
+    component.find("select_EffectProgress").set("v.value", "");
+    component.find("select_OtherBrandConsumables").set("v.value", "");
+    component.find("select_ProductCcategory").set("v.value", "");
+    component.find("select_productCategories").set("v.value", "");
+    // ToDo闇�瑕佹祴璇曟墜鏈轰笂鑳借繍琛屼笉
+    component.set("v.data.Report_Date__c", "");
+    component.set("v.oppdata.Close_Forecasted_Date__c", "");
+    component.set("v.oppdata.Amount__c", "");
+    component.set("v.oppdata.OCMSale_Price__c", "");
+    component.set("v.oppdata.StageName__c", "");
+    component.set("v.Close_Forecasted_Date__c_o", "");
+    component.set("v.Amount__c_o", "");
+    component.set("v.OCMSale_Price__c_o", "");
+    component.set("v.StageName__c_o", "");
+    $A.util.addClass(component.find("input-opportunity-stage"), "disp_none");
+    $A.util.addClass(component.find("input-opportunity-amount1"), "disp_none");
+    $A.util.addClass(component.find("input-opportunity-amount2"), "disp_none");
+    $A.util.addClass(component.find("input-opportunity-date"), "disp_none");
+    this.selectPurposeType(component);
+    this.selectProductClassification(component);
+    this.selectpurposetype(component);
+  },
+
+  report_date_list: function (component, event, helper, count) {
+    var ret_obj = [];
+    var now = new Date();
+    for (var i = 0; i < count; i++) {
+      var start_day = new Date(
+        now.getFullYear(),
+        now.getMonth(),
+        now.getDate() - now.getDay() + 1 - i * 7
+      );
+      var end_day = new Date(
+        now.getFullYear(),
+        now.getMonth(),
+        now.getDate() + (7 - now.getDay()) - i * 7
+      );
+      var start_day_show = new Date(
+        now.getFullYear(),
+        now.getMonth(),
+        now.getDate() - now.getDay() - i * 7
+      );
+      var end_day_show = new Date(
+        now.getFullYear(),
+        now.getMonth(),
+        now.getDate() + (6 - now.getDay()) - i * 7
+      );
+      var date_text =
+        start_day.getFullYear() +
+        "/" +
+        (start_day.getMonth() + 1) +
+        "/" +
+        start_day.getDate() +
+        "~" +
+        end_day.getFullYear() +
+        "/" +
+        (end_day.getMonth() + 1) +
+        "/" +
+        end_day.getDate();
+      if (i == 0) {
+        ret_obj.push({
+          selected: true,
+          value:
+            start_day.getFullYear() +
+            "/" +
+            (start_day.getMonth() + 1) +
+            "/" +
+            start_day.getDate(),
+          label:
+            start_day_show.getFullYear() +
+            "/" +
+            (start_day_show.getMonth() + 1) +
+            "/" +
+            start_day_show.getDate() +
+            "~" +
+            end_day_show.getFullYear() +
+            "/" +
+            (end_day_show.getMonth() + 1) +
+            "/" +
+            end_day_show.getDate()
+        });
+      } else {
+        ret_obj.push({
+          selected: false,
+          value:
+            start_day.getFullYear() +
+            "/" +
+            (start_day.getMonth() + 1) +
+            "/" +
+            start_day.getDate(),
+          label:
+            start_day_show.getFullYear() +
+            "/" +
+            (start_day_show.getMonth() + 1) +
+            "/" +
+            start_day_show.getDate() +
+            "~" +
+            end_day_show.getFullYear() +
+            "/" +
+            (end_day_show.getMonth() + 1) +
+            "/" +
+            end_day_show.getDate()
+        });
+      }
+    }
+    component.find("select_date").set("v.options", ret_obj);
+    component.set("v.report_date_list", ret_obj);
+  },
+  create_report_header: function (
+    component,
+    event,
+    helper,
+    name,
+    s_agency,
+    s_date
+  ) {
+    s_date = this.get_date_string(s_date);
+    if (s_date == false) {
+      component.set("v.errorMessage", "get_date_string failed.");
+      this.showErrorToast(component);
+      return false;
+    }
+    var head_key = this.create_header_input_key(s_agency, s_date);
+    component.set("v.agency_report_header", head_key);
+    if (head_key == false) {
+      component.set("v.errorMessage", "create_header_input_key failed.");
+      this.showErrorToast(component);
+      return false;
+    }
+    var key2 = s_date.replace(/-/g, "");
+    var action = component.get("c.createReportHeader");
+    action.setParams({
+      name: name,
+      s_date: s_date,
+      s_agency: s_agency,
+      head_key: head_key
+    });
+    component.set("v.login", true);
+    action.setCallback(this, function (response) {
+      var state = response.getState();
+      if (state == "SUCCESS") {
+        var res = response.getReturnValue();
+        component.set("v.agency_report_header_id", res);
+        component.set("v.login", false);
+        this.toggle_report(component, event, helper);
+      } else {
+        component.set("v.errorMessage", "createReportHeader callback failed.");
+        this.showErrorToast(component);
+        component.set("v.login", false);
+      }
+    });
+    $A.enqueueAction(action);
+  },
+  create_header_input_key: function (agency_id, s_date) {
+    if (typeof s_date != "string") {
+      s_date = this.get_date_string(s_date);
+      if (s_date == false) {
+        component.set(
+          "v.errorMessage",
+          "get_date_string in create_header_input_key."
+        );
+        this.showErrorToast(component);
+        return false;
+      }
+    }
+    if (!agency_id || !s_date) {
+      return false;
+    }
+    s_date = s_date.replace(/-/g, "");
+    var headkey = agency_id + ":" + s_date;
+    return headkey;
+  },
+
+  /* typeof is not cool
+   * @ret : String, Boolean, Date, Error, Array, Function, Null, Undefined, etc
+   */
+  object_type: function (obj) {
+    var obj_type = Object.prototype.toString.call(obj).slice(8, -1);
+    return obj_type;
+  },
+  // create yyyy-mm-dd string
+  get_date_string: function (val) {
+    if (typeof val == "string") {
+      if (val.match(/^\d{4}\/\d{1,2}\/\d{1,2}$/)) {
+        val = val.replace(/[\/]/g, "-");
+        var tmp = val.split("-");
+        if (tmp[1].length == 1) {
+          tmp[1] = "0" + tmp[1];
+        }
+        if (tmp[2].length == 1) {
+          tmp[2] = "0" + tmp[2];
+        }
+        val = tmp[0] + "-" + tmp[1] + "-" + tmp[2];
+      } else if (val.match(/^\d{4}-\d{1,2}-\d{1,2}$/)) {
+        //ok
+      } else {
+        return false;
+      }
+    } else if (this.object_type(val) == "Date") {
+      var mm = val.getMonth() + 1;
+      if (String(mm).length == 1) {
+        mm = "0" + mm;
+      }
+      var dd = "";
+      if (String(val.getDate()).length == 1) {
+        dd = "0" + val.getDate();
+      } else {
+        dd = val.getDate();
+      }
+      val = val.getFullYear() + "-" + mm + "-" + dd;
+    } else {
+      return false;
+    }
+    return val;
+  },
+  //   Controller   鏍规嵁椤甸潰鍖婚櫌鏌ヨ绗﹀悎鐨勫尰闄�
+  searchHos: function (component, event, helper) {
+    var hospital_name = event.getParam("value");
+    var action = component.get("c.getHospitalList");
+    action.setParams({
+      hospital_name: hospital_name
+    });
+    action.setCallback(this, function (response) {
+      var state = response.getState();
+      if (state === "SUCCESS") {
+        var hospital_list = component.find("hospital_list");
+        var hosList = response.getReturnValue();
+        if (hosList.length > 0) {
+          $A.util.addClass(hospital_list, "slds-is-open");
+        } else {
+          $A.util.removeClass(hospital_list, "slds-is-open");
+        }
+        component.set("v.hospitalList", response.getReturnValue());
+      } else {
+        $A.util.removeClass(hospital_list, "slds-is-open");
+      }
+    });
+    $A.enqueueAction(action);
+  },
+  hideSearch: function (component, event, helper) {
+    var hospital_list = component.find("hospital_list");
+    $A.util.removeClass(hospital_list, "slds-is-open");
+  },
+  hideSearchs: function (component, event, helper) {
+    var hospital_list = component.find("hospital_list");
+    $A.util.removeClass(hospital_list, "slds-is-open");
+    component.set("v.hospital", "");
+    component.set("v.hospitals", "");
+    component.set("v.hospitalLinkId", "");
+    component.set("v.data.Agency_Hospital__c", "");
+    component.set("v.hospitalId", "");
+  },
+  selectHos: function (component, event, helper) {
+    debugger;
+    var hospital_list = component.find("hospital_list");
+    $A.util.removeClass(hospital_list, "slds-is-open");
+    var accname = event.currentTarget.dataset.accname;
+    var accid = event.currentTarget.dataset.accid;
+    var hospital_data = component.get("v.hospitalList");
+    var select_purpose_type = component
+      .find("select_purpose_type")
+      .get("v.value");
+    for (var i = 0; i < hospital_data.length; i++) {
+      if (hospital_data[i].Hospital__c == accid) {
+        component.set("v.hospitalLinkId", hospital_data[i].Id);
+        component.set("v.data.Agency_Hospital__c", hospital_data[i].Id);
+        if (select_purpose_type != "绉戝浼�" && hospital_data[i].Hospital__c) {
+          component.find("new_con").set("v.disabled", false);
+        } else {
+          component.find("new_con").set("v.disabled", true);
+        }
+      }
+    }
+    component.set("v.hospitals", accname);
+    component.set("v.hospital", accname);
+    component.set("v.hospitalId", accid);
+    debugger;
+    component.set("v.setdoctorlisthos", true);
+    this.set_doctor_list(component, event, helper);
+  },
+
+  //妯$硦鏌ヨ浣跨敤浜у搧1(浜у搧鍨嬪彿)
+  searchUseProduct1: function (component, event, helper) {
+    var UseProduct1Name = event.getParam("value");
+    var select_ProductClassification = component
+      .find("select_ProductClassification")
+      .get("v.value");
+    var action = component.get("c.getUseProduct1");
+    action.setParams({
+      UseProduct1Name: UseProduct1Name,
+      select_ProductClassification: select_ProductClassification
+    });
+    action.setCallback(this, function (response) {
+      var state = response.getState();
+      if (state === "SUCCESS") {
+        var UseProduct1_List = component.find("UseProduct1_List");
+        var UseProduct1ListValue = response.getReturnValue();
+        if (UseProduct1ListValue.length > 0) {
+          $A.util.addClass(UseProduct1_List, "slds-is-open");
+        } else {
+          $A.util.removeClass(UseProduct1_List, "slds-is-open");
+        }
+        component.set("v.UseProduct1List", UseProduct1ListValue);
+      } else {
+        $A.util.removeClass(UseProduct1_List, "slds-is-open");
+      }
+    });
+    $A.enqueueAction(action);
+  },
+  hideSearchUseProduct1: function (component, event, helper) {
+    var UseProduct1_List = component.find("UseProduct1_List");
+    $A.util.removeClass(UseProduct1_List, "slds-is-open");
+  },
+  hideSearchUseProduct1s: function (component, event, helper) {
+    var UseProduct1_List = component.find("UseProduct1_List");
+    $A.util.removeClass(UseProduct1_List, "slds-is-open");
+    component.set("v.UseProduct1", "");
+    component.set("v.UseProduct1s", "");
+    component.set("v.UseProduct1Id", "");
+    component.set("v.data.UseProduct1__c", "");
+  },
+  seletUseProduct1Change: function (component, event, helper) {
+    debugger;
+    var UseProduct1_List = component.find("UseProduct1_List");
+    $A.util.removeClass(UseProduct1_List, "slds-is-open");
+    var accname = event.currentTarget.dataset.accname;
+    var accid = event.currentTarget.dataset.accid;
+    var UseProduct1ListDate = component.get("v.UseProduct1List");
+    for (var i = 0; i < UseProduct1ListDate.length; i++) {
+      if (UseProduct1ListDate[i].Id == accid) {
+        component.set("v.UseProduct1Id", UseProduct1ListDate[i].Id);
+        component.set("v.data.UseProduct1__c", UseProduct1ListDate[i].Id);
+      }
+    }
+    var UseProduct2_TEXT = component.find("UseProduct2_TEXT").get("v.value");
+    var UseProduct3_TEXT = component.find("UseProduct3_TEXT").get("v.value");
+    if (UseProduct2_TEXT != accname && UseProduct3_TEXT != accname) {
+      component.set("v.UseProduct1s", accname);
+      component.set("v.UseProduct1", accname);
+    } else {
+      component.set("v.errorMessage", "涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝�");
+      this.showErrorToast(component);
+    }
+  },
+  //妯$硦鏌ヨ浣跨敤浜у搧2
+  searchUseProduct2: function (component, event, helper) {
+    var UseProduct2Name = event.getParam("value");
+    var select_ProductClassification = component
+      .find("select_ProductClassification")
+      .get("v.value");
+    var action = component.get("c.getUseProduct1");
+    action.setParams({
+      UseProduct1Name: UseProduct2Name,
+      select_ProductClassification: select_ProductClassification
+    });
+    action.setCallback(this, function (response) {
+      var state = response.getState();
+      if (state === "SUCCESS") {
+        var UseProduct2_List = component.find("UseProduct2_List");
+        var UseProduct2List = response.getReturnValue();
+        if (UseProduct2List.length > 0) {
+          $A.util.addClass(UseProduct2_List, "slds-is-open");
+        } else {
+          $A.util.removeClass(UseProduct2_List, "slds-is-open");
+        }
+        component.set("v.UseProduct2List", response.getReturnValue());
+      } else {
+        $A.util.removeClass(UseProduct2_List, "slds-is-open");
+      }
+    });
+    $A.enqueueAction(action);
+  },
+  hideSearchUseProduct2: function (component, event, helper) {
+    var UseProduct2_List = component.find("UseProduct2_List");
+    $A.util.removeClass(UseProduct2_List, "slds-is-open");
+  },
+  hideSearchUseProduct2s: function (component, event, helper) {
+    var UseProduct2_List = component.find("UseProduct2_List");
+    $A.util.removeClass(UseProduct2_List, "slds-is-open");
+    component.set("v.UseProduct2", "");
+    component.set("v.UseProduct2s", "");
+    component.set("v.UseProduct2Id", "");
+    component.set("v.data.UseProduct2__c", "");
+  },
+  seletUseProduct2Change: function (component, event, helper) {
+    var UseProduct2_List = component.find("UseProduct2_List");
+    $A.util.removeClass(UseProduct2_List, "slds-is-open");
+    var accname = event.currentTarget.dataset.accname;
+    var accid = event.currentTarget.dataset.accid;
+    var UseProduct2ListDate = component.get("v.UseProduct2List");
+    for (var i = 0; i < UseProduct2ListDate.length; i++) {
+      if (UseProduct2ListDate[i].Id == accid) {
+        component.set("v.UseProduct2Id", UseProduct2ListDate[i].Id);
+        component.set("v.data.UseProduct2__c", UseProduct2ListDate[i].Id);
+      }
+    }
+    var UseProduct1_TEXT = component.find("UseProduct1_TEXT").get("v.value");
+    var UseProduct3_TEXT = component.find("UseProduct3_TEXT").get("v.value");
+    if (UseProduct1_TEXT != accname && UseProduct3_TEXT != accname) {
+      component.set("v.UseProduct2s", accname);
+      component.set("v.UseProduct2", accname);
+    } else {
+      component.set("v.errorMessage", "涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝�");
+      this.showErrorToast(component);
+    }
+  },
+  //妯$硦鏌ヨ浣跨敤浜у搧3
+  searchUseProduct3: function (component, event, helper) {
+    var UseProduct3Name = event.getParam("value");
+    var select_ProductClassification = component
+      .find("select_ProductClassification")
+      .get("v.value");
+    var action = component.get("c.getUseProduct1");
+    action.setParams({
+      UseProduct1Name: UseProduct3Name,
+      select_ProductClassification: select_ProductClassification
+    });
+    action.setCallback(this, function (response) {
+      var state = response.getState();
+      if (state === "SUCCESS") {
+        var UseProduct3_List = component.find("UseProduct3_List");
+        var UseProduct3List = response.getReturnValue();
+        if (UseProduct3List.length > 0) {
+          $A.util.addClass(UseProduct3_List, "slds-is-open");
+        } else {
+          $A.util.removeClass(UseProduct3_List, "slds-is-open");
+        }
+        component.set("v.UseProduct3List", response.getReturnValue());
+      } else {
+        $A.util.removeClass(UseProduct3_List, "slds-is-open");
+      }
+    });
+    $A.enqueueAction(action);
+  },
+  hideSearchUseProduct3: function (component, event, helper) {
+    var UseProduct3_List = component.find("UseProduct3_List");
+    $A.util.removeClass(UseProduct3_List, "slds-is-open");
+  },
+  hideSearchUseProduct3s: function (component, event, helper) {
+    var UseProduct3_List = component.find("UseProduct3_List");
+    $A.util.removeClass(UseProduct3_List, "slds-is-open");
+    component.set("v.UseProduct3", "");
+    component.set("v.UseProduct3s", "");
+    component.set("v.UseProduct3Id", "");
+    component.set("v.data.UseProduct3__c", "");
+  },
+  seletUseProduct3Change: function (component, event, helper) {
+    var UseProduct3_List = component.find("UseProduct3_List");
+    $A.util.removeClass(UseProduct3_List, "slds-is-open");
+    var accname = event.currentTarget.dataset.accname;
+    var accid = event.currentTarget.dataset.accid;
+    var UseProduct3ListDate = component.get("v.UseProduct3List");
+    for (var i = 0; i < UseProduct3ListDate.length; i++) {
+      if (UseProduct3ListDate[i].Id == accid) {
+        component.set("v.UseProduct3Id", UseProduct3ListDate[i].Id);
+        component.set("v.data.UseProduct3__c", UseProduct3ListDate[i].Id);
+      }
+    }
+    var UseProduct1_TEXT = component.find("UseProduct1_TEXT").get("v.value");
+    var UseProduct2_TEXT = component.find("UseProduct2_TEXT").get("v.value");
+    if (UseProduct1_TEXT != accname && UseProduct2_TEXT != accname) {
+      component.set("v.UseProduct3s", accname);
+      component.set("v.UseProduct3", accname);
+    } else {
+      component.set("v.errorMessage", "涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝�");
+      this.showErrorToast(component);
+    }
+  },
+  //hospitalLinkId 缁忛攢鍟嗗尰闄㈢殑ID   鎷滆浜哄鍒剁殑鍦版柟
+  doctor_change: function (component, event, helper) {
+    debugger;
+    var doctorurpose = component.find("select_purpose_type").get("v.value");
+    var doctor_value = component.find("select_doctor").get("v.value");
+    var doctor_list = component.get("v.doctor_list");
+    var flg = false;
+    if (doctor_list) {
+      for (var i = 0; i < doctor_list.length; i++) {
+        if (doctor_list[i].value == doctor_value) {
+          if (doctorurpose == "绉戝浼�") {
+            // component.set('v.doctor_title', doctor_list[i].Doctor_Division1__c);
+          } else {
+            component.set("v.doctor_title", doctor_list[i].Doctor_Division1__c);
+          }
+          flg = true;
+          break;
+        }
+      }
+    }
+    if (flg == false) {
+      component.set("v.doctor_title", "");
+    }
+  },
+  //SWAG-CF58C3 fy start 璋冪敤pi
+  set_aws_url: function (component, sobject) {
+    var action = component.get("c.getAwsurl");
+    action.setParams({
+      sobj: sobject
+    });
+    action.setCallback(this, function (response) {
+      var state = response.getState();
+      if (state == "SUCCESS") {
+        var awsmap = this.conv_selected(response.getReturnValue());
+        component.set("v.AWStoken", awsmap.token);
+        component.set("v.AWSinsert", awsmap.newUrl);
+        component.set("v.AWSsearch", awsmap.searchUrl);
+        component.set("v.AWStransactionURL", awsmap.transactionURL);
+      } else {
+        component.set("v.errorMessage", "AWS url/token error.");
+        this.showErrorToast(component);
+        component.set("v.login", false);
+      }
+    });
+    $A.enqueueAction(action);
+  },
+
+  insert_agencycontact: function (
+    component,
+    token,
+    newUrl,
+    payload,
+    agencyHospitalid,
+    helper,
+    hospitalName
+  ) {
+    debugger;
+    console.log("newUrl = " + newUrl);
+    console.log("payload = " + payload);
+    console.log("token = " + token);
+    fetch(newUrl, {
+      method: "POST",
+      body: payload,
+      headers: {
+        "Content-Type": "application/json",
+        "pi-token": token
+      }
+    })
+      .then((data) => {
+        return data.json();
+      })
+      .then((result) => {
+        console.log("result = " + JSON.stringify(result));
+        if (result.status == "0") {
+          $A.getCallback(function () {
+            helper.to_agencycontact(component, result, agencyHospitalid);
+          })();
+        } else {
+          console.log("AWS status error:" + result);
+          component.set("v.login", false);
+          if (result.status == "129") {
+            component
+              .find("OppMessage")
+              .setError(
+                "璇ュ鎴蜂汉鍛樺悕瀛楀凡瀛樺湪锛屽湪" + hospitalName + "鍖婚櫌锛岃淇敼"
+              );
+          } else {
+            component.find("OppMessage").setError("AWS insert error.");
+          }
+        }
+      })
+      .catch((error) => {
+        console.log("AWS insert error:" + error);
+        component.set("v.login", false);
+        component.find("OppMessage").setError("AWS insert error.");
+      });
+  },
+
+  to_agencycontact: function (component, result, agencyHospitalid) {
+    var action = component.get("c.saveAgencyContact");
+    action.setParams({
+      name: result.object[0].name,
+      //"nameEncrypt" : result.object[0].nameEncrypt,                         //zhj 鏂版柟妗堟敼閫� 2023-12-21
+      type: result.object[0].type,
+      //"typeEncrypt" : result.object[0].typeEncrypt,                         //zhj 鏂版柟妗堟敼閫� 2023-12-21
+      doctorDivision1: result.object[0].doctorDivision1,
+      //"doctorDivision1Encrypt" : result.object[0].doctorDivision1Encrypt,   //zhj 鏂版柟妗堟敼閫� 2023-12-21
+      agencyHospitalid: agencyHospitalid,
+      awsid: result.object[0].dataId
+    });
+    action.setCallback(this, function (response) {
+      var state = response.getState();
+      if (state == "SUCCESS") {
+        var acMap = this.conv_selected(response.getReturnValue());
+        console.log(acMap);
+        if (acMap.AgencyContactId != "") {
+          //纭浜嬪姟
+          var token = component.get("v.AWStoken");
+          var confirmUrl = component.get("v.AWStransactionURL");
+
+          let data = Object.create(null);
+          data["isSuccess"] = 1;
+          data["sfRecordId"] = "";
+          data["txId"] = result.txId;
+
+          this.to_confirm(component, token, confirmUrl, JSON.stringify(data));
+        } else if (acMap.errormsg != "") {
+          component.set("v.errorMessage", acMap.errormsg);
+          this.showErrorToast(component);
+          component.set("v.login", false);
+        } else {
+          component.set("v.errorMessage", "agency contact insert id error.");
+          this.showErrorToast(component);
+          component.set("v.login", false);
+        }
+      } else {
+        component.set("v.errorMessage", "agency contact insert error.");
+        this.showErrorToast(component);
+        component.set("v.login", false);
+      }
+    });
+    $A.enqueueAction(action);
+  },
+
+  to_confirm: function (component, token, confirmUrl, payload, event) {
+    fetch(confirmUrl, {
+      method: "POST",
+      body: payload,
+      headers: {
+        "Content-Type": "application/json",
+        "pi-token": token
+      }
+    })
+      .then((data) => {
+        return data.json();
+      })
+      .then((result) => {
+        if (
+          result.status == "0" &&
+          result.hasOwnProperty("success") &&
+          result.success
+        ) {
+          // component.set('v.truthy', false);
+          // var modal_newAC = component.find('modal_newAC')
+          // $A.util.addClass(modal_newAC, 'disp_none');
+          // this.success('.瀹㈡埛浜哄憳宸插垱寤恒��');
+          // this.set_doctor_list(component);
+
+          component.set("v.truthy", false);
+          var modal_newAC = component.find("modal_newAC");
+          $A.util.addClass(modal_newAC, "disp_none");
+          component.set("v.successMessage", ".鎷滆浜哄凡鍒涘缓銆�");
+          this.showSuccessToast(component);
+          this.set_doctor_list(component);
+        } else {
+          component.set("v.errorMessage", "AWS confirm error.");
+          this.showErrorToast(component);
+          component.set("v.login", false);
+        }
+      })
+      .catch((error) => {
+        component.set("v.errorMessage", "AWS confirm error.");
+        this.showErrorToast(component);
+        component.set("v.login", false);
+      });
+  },
+  //SWAG-CF58C3 fy end 璋冪敤pi
+
+  set_doctor_list: function (component) {
+    console.log("set_doctor_list");
+    var doctor_value = component.find("select_purpose_type").get("v.value");
+    var hospital_id = component.get("v.hospitalLinkId");
+    console.log("hospital_id = " + hospital_id);
+    if (hospital_id) {
+      if (doctor_value == "绉戝浼�") {
+        component.set("v.login", true);
+        this.set_doctor_list2(component);
+      } else {
+        component.set("v.login", true);
+        var action = component.get("c.getDoctorList");
         action.setParams({
-            "select_ProductClassification": select_ProductClassification
+          hospital_id: hospital_id
         });
         action.setCallback(this, function (response) {
-            var state = response.getState();
-            if (state == 'SUCCESS') {
-                var res = response.getReturnValue();
-                component.find('select_OtherBrandConsumables').set("v.options", JSON.parse(JSON.stringify(res)));
+          var state = response.getState();
+          if (state == "SUCCESS") {
+            debugger;
+            var res = this.conv_selected(response.getReturnValue());
+            //fy
+            var setdoctorlisthos = component.get("v.setdoctorlisthos");
+            if (setdoctorlisthos) {
+              component.set("v.default_select_doctor_id", "");
+              component.set("v.setdoctorlisthos", false);
             }
+            //fy
+            var default_doctor = component.get("v.default_select_doctor_id");
+            if (default_doctor != "" && res.length > 0) {
+              var doctor_title = "";
+              let awsids = [];
+              for (var i = 0; i < res.length; i++) {
+                if (res[i].value == default_doctor) {
+                  res[i].selected = true;
+                  doctor_title = res[i].Doctor_Division1__c;
+                } else {
+                  res[i].selected = false;
+                }
+                if (res[i].AWS_Data_Id__c) {
+                  awsids.push(res[i].AWS_Data_Id__c);
+                }
+              }
+              component.find("select_doctor").set("v.options", res);
+              component.set("v.doctor_title", doctor_title);
+              console.log("awsids = " + JSON.stringify(awsids));
+              if (awsids.length > 0) {
+                let PIConfig = component.get("v.PIConfig");
+                let staticResourceAgencyContact = JSON.parse(
+                  PIConfig.staticResourceAgencyContact
+                );
+                AWSService.search(
+                  staticResourceAgencyContact.searchUrl,
+                  {
+                    dataIds: awsids
+                  },
+                  function (data) {
+                    console.log("data = " + JSON.stringify(data));
+                    if (data && data.object && data.object.length) {
+                      let m = {};
+                      for (let di in data.object) {
+                        if (data.object[di] && data.object[di].dataId) {
+                          m[data.object[di].dataId] = data.object[di];
+                        }
+                      }
+
+                      for (let ri in res) {
+                        if (
+                          res[ri] &&
+                          res[ri].AWS_Data_Id__c &&
+                          m.hasOwnProperty(res[ri].AWS_Data_Id__c)
+                        ) {
+                          res[ri].label = m[res[ri].AWS_Data_Id__c].name;
+                        }
+                      }
+                      component.find("select_doctor").set("v.options", res);
+                    }
+
+                    component.set("v.login", false);
+                  },
+                  staticResourceAgencyContact.token
+                );
+              }
+            } else {
+              let awsids = [];
+              for (var i = 0; i < res.length; i++) {
+                if (res[i].AWS_Data_Id__c) {
+                  awsids.push(res[i].AWS_Data_Id__c);
+                }
+              }
+              component.find("select_doctor").set("v.options", res);
+              if (awsids.length > 0) {
+                let PIConfig = component.get("v.PIConfig");
+                let staticResourceAgencyContact = JSON.parse(
+                  PIConfig.staticResourceAgencyContact
+                );
+                AWSService.search(
+                  staticResourceAgencyContact.searchUrl,
+                  {
+                    dataIds: awsids
+                  },
+                  function (data) {
+                    if (data && data.object && data.object.length) {
+                      let m = {};
+                      for (let di in data.object) {
+                        if (data.object[di] && data.object[di].dataId) {
+                          m[data.object[di].dataId] = data.object[di];
+                        }
+                      }
+
+                      for (let ri in res) {
+                        if (
+                          res[ri] &&
+                          res[ri].AWS_Data_Id__c &&
+                          m.hasOwnProperty(res[ri].AWS_Data_Id__c)
+                        ) {
+                          res[ri].label = m[res[ri].AWS_Data_Id__c].name;
+                        }
+                      }
+                      component.find("select_doctor").set("v.options", res);
+                    }
+
+                    component.set("v.login", false);
+                  },
+                  staticResourceAgencyContact.token
+                );
+              }
+              // component.find('select_doctor').set('v.options', res);
+              if (res.length > 0) {
+                component.set("v.doctor_title", res[0].Doctor_Division1__c);
+              }
+            }
+            // component.set('v.default_select_doctor_id', '');
+            debugger;
+            component.set("v.doctor_list", res);
+            component.set("v.login", false);
+          } else {
+            component.set("v.errorMessage", "set_doctor_list failed.");
+            this.showErrorToast(component);
+            component.set("v.login", false);
+          }
         });
         $A.enqueueAction(action);
-    }else{
-        component.find('select_OtherBrandConsumables').set('v.options', []);
+      }
+    } else {
+      if (doctor_value == "绉戝浼�") {
+        this.set_doctor_list2(component);
+      } else {
+        component.find("select_doctor").set("v.options", "");
+      }
+    }
+  }, //fy 20220414
+  set_doctor_list2: function (component) {
+    var action1 = component.get("c.selectdoctor3c");
+    action1.setCallback(this, function (response) {
+      var state = response.getState();
+      if (state == "SUCCESS") {
+        var res = response.getReturnValue();
+        debugger;
+        for (var i = 0; i < res.length; i++) {
+          if (res[i].selected == "true") {
+            res[i].selected = true;
+          } else {
+            res[i].selected = false;
+          }
+        }
+        debugger;
+        component.find("select_doctor").set("v.options", res);
+        var doctor3value = component.get("v.default_select_doctor_id2");
+        this.set_selected(component, "select_doctor", doctor3value);
+        component.set("v.login", false);
+      }
+    });
+    $A.enqueueAction(action1);
+  },
+  productcategoryChange1: function (component, event, helper) {
+    var product_category_id = component.find("select_Product1").get("v.value");
+    var pcId1 = component.find("select_Product2").get("v.value");
+    var pcId2 = component.find("select_Product3").get("v.value");
+    var p1bool = pcId1 != "" && pcId1 != null && pcId1 != undefined;
+    var p2bool = pcId2 != "" && pcId2 != null && pcId2 != undefined;
+    var p0bool =
+      product_category_id != "" &&
+      product_category_id != null &&
+      product_category_id != undefined;
+    if (
+      (p1bool && p0bool && product_category_id == pcId1) ||
+      (p2bool && p0bool && product_category_id == pcId2)
+    ) {
+      component.set("v.errorMessage", "涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�");
+      this.showErrorToast(component);
+      component.find("select_Product1").set("v.value", "");
+    }
+  },
+  productcategoryChange2: function (component, event, helper) {
+    var product_category_id = component.find("UseProduct2_TEXT").get("v.value");
+    var pcId1 = component.find("UseProduct1_TEXT").get("v.value");
+    var pcId2 = component.find("UseProduct3_TEXT").get("v.value");
+    var p1bool = pcId1 != "" && pcId1 != null;
+    var p2bool = pcId2 != "" && pcId2 != null;
+    var p0bool = product_category_id != "" && product_category_id != null;
+    if (
+      (p1bool && p0bool && product_category_id == pcId1) ||
+      (p2bool && p0bool && product_category_id == pcId2)
+    ) {
+      component.set("v.errorMessage", "涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�");
+      this.showErrorToast(component);
+      component.set("v.UseProduct2_TEXT", "");
+    }
+  },
+  productcategoryChange3: function (component, event, helper) {
+    var product_category_id = component.find("select_Product3").get("v.value");
+    var pcId1 = component.find("select_Product1").get("v.value");
+    var pcId2 = component.find("select_Product2").get("v.value");
+    var p1bool = pcId1 != "" && pcId1 != null && pcId1 != undefined;
+    var p2bool = pcId2 != "" && pcId2 != null && pcId2 != undefined;
+    var p0bool =
+      product_category_id != "" &&
+      product_category_id != null &&
+      product_category_id != undefined;
+    if (
+      (p1bool && p0bool && product_category_id == pcId1) ||
+      (p2bool && p0bool && product_category_id == pcId2)
+    ) {
+      component.set("v.errorMessage", "涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�");
+      this.showErrorToast(component);
+      component.find("select_Product3").set("v.value", "");
+    }
+  },
+  conv_selected: function (obj) {
+    for (var i = 0; i < obj.length; i++) {
+      if (obj[i].selected) {
+        if (obj[i].selected == "true") {
+          obj[i].selected = true;
+        } else {
+          obj[i].selected = false;
+        }
+      }
+    }
+    return obj;
+  },
+  set_selected: function (component, aura_id_name, value) {
+    debugger;
+    var select_tmp = component.find(aura_id_name).get("v.options");
+    if (select_tmp) {
+      for (var i = 0; i < select_tmp.length; i++) {
+        if (select_tmp[i].value == value) {
+          select_tmp[i].selected = true;
+        } else {
+          select_tmp[i].selected = false;
+        }
+      }
+      component.find(aura_id_name).set("v.options", select_tmp);
+      return true;
+    } else {
+      return false;
+    }
+  },
+  //寮瑰嚭 鎴愬姛鎻愮ず
+  showSuccessToast: function (component) {
+    debugger;
+    $A.util.removeClass(component.find("successDiv"), "slds-hide");
+    window.setTimeout(
+      $A.getCallback(function () {
+        $A.util.addClass(component.find("successDiv"), "slds-hide");
+      }),
+      3000
+    );
+  },
+  //寮瑰嚭 鎴愬姛鎻愮ず
+  showSuccessToast01: function (component) {
+    debugger;
+    $A.util.removeClass(component.find("successDiv01"), "slds-hide");
+    window.setTimeout(
+      $A.getCallback(function () {
+        $A.util.addClass(component.find("successDiv01"), "slds-hide");
+      }),
+      3000
+    );
+  },
+  //寮瑰嚭 閿欒鎻愮ず
+  showErrorToast: function (component) {
+    debugger;
+    $A.util.removeClass(component.find("errorDiv"), "slds-hide");
+    window.setTimeout(
+      $A.getCallback(function () {
+        $A.util.addClass(component.find("errorDiv"), "slds-hide");
+      }),
+      3000
+    );
+  },
+  //寮瑰嚭 閿欒鎻愮ず
+  showErrorToast01: function (component) {
+    debugger;
+    $A.util.removeClass(component.find("errorDiv01"), "slds-hide");
+    window.setTimeout(
+      $A.getCallback(function () {
+        $A.util.addClass(component.find("errorDiv01"), "slds-hide");
+      }),
+      6000
+    );
+  },
+  error: function (message) {
+    var toastEvent = $A.get("e.force:showToast");
+    toastEvent.setParams({
+      title: "閿欒!",
+      message: message,
+      type: "error",
+      duration: "sticky"
+    });
+    toastEvent.fire();
+  },
+  createCon: function (component, event, helper) {
+    var modal_newAC = component.find("modal_newAC");
+    $A.util.removeClass(modal_newAC, "disp_none");
+    component.set("v.truthy", true);
+  },
+  hideCmp: function (component, event, helper) {
+    var div1 = component.find("report");
+    var div2 = component.find("report_list");
+    $A.util.addClass(div1, "disp_none");
+    $A.util.addClass(div2, "disp_none");
+  },
+  handleSuccess: function (component, event, helper) {
+    var insertId = event.getParams().response.Id;
+    var displayValue = event.getParams().response.fields.Name.value;
+    event.setParams({});
+    component.set("v.truthy", false);
+    var modal_newAC = component.find("modal_newAC");
+    $A.util.addClass(modal_newAC, "disp_none");
+    component.set("v.successMessage", ".鎷滆浜哄凡鍒涘缓銆�");
+    this.showSuccessToast(component);
+    this.set_doctor_list(component, event, helper);
+  },
+  createCancel: function (component, event, helper) {
+    component.set("v.truthy", false);
+    var modal_newAC = component.find("modal_newAC");
+    $A.util.addClass(modal_newAC, "disp_none");
+    component.find("OppMessage").setError("");
+  },
+  //绉戝璧嬪��
+  setOpportunity_cfilter: function (component) {
+    var hosId = component.get("v.hospitalId");
+    var Department_Cateogy__c = component
+      .find("select_department")
+      .get("v.value");
+    var opportunity_cfilter = "";
+    if (hosId != "" && hosId != null) {
+      opportunity_cfilter =
+        " Agency_Hospital__r.Hospital__c=" + "'" + hosId + "'";
+    }
+    if (Department_Cateogy__c != "" && Department_Cateogy__c != null) {
+      if (opportunity_cfilter != "" && opportunity_cfilter != null) {
+        opportunity_cfilter += " AND ";
+      }
+      // fy Department_Cateogy_text__c
+      opportunity_cfilter +=
+        "Department_Cateogy__c=" + "'" + Department_Cateogy__c + "'";
+      // opportunity_cfilter += 'Department_Cateogy_text__c=' + '\'' + Department_Cateogy__c + '\'';
+    }
+    component.set("v.opportunity_cfilter", opportunity_cfilter);
+  },
+  readFile: function (component, helper, file) {
+    if (!file) return;
+    if (!file.name.match(/\.(csv||CSV)$/)) {
+      return alert("only support csv files");
+    } else {
+      reader = new FileReader();
+      reader.onerror = function errorHandler(evt) {
+        switch (evt.target.error.code) {
+          case evt.target.error.NOT_FOUND_ERR:
+            alert("File Not Found!");
+            break;
+          case evt.target.error.NOT_READABLE_ERR:
+            alert("File is not readable");
+            break;
+          case evt.target.error.ABORT_ERR:
+            break; // noop
+          default:
+            alert("An error occurred reading this file.");
+        }
+      };
+      reader.onabort = function (e) {
+        alert("File read cancelled");
+      };
+      reader.onloadstart = function (e) {
+        var output =
+          '<ui type="disc"><li><strong>' +
+          file.name +
+          "</strong> (" +
+          file.type +
+          ")- " +
+          file.size +
+          "bytes, last modified: " +
+          file.lastModifiedDate.toLocaleDateString() +
+          "</li></ui>";
+        component.set("v.filename", file.name);
+        component.set("v.TargetFileName", output);
+      };
+      reader.onload = function (e) {
+        debugger;
+        var data = e.target.result;
+
+        component.set("v.fileContentData", data);
+        console.log("file data" + JSON.stringify(data));
+        var allTextLines = data.split(/\r\n|\n/);
+        console.log("qqqqqqqqqqqqqqqqqqq" + allTextLines);
+        var dataRows = allTextLines.length - 1;
+        var headers = allTextLines[0].split(",");
+        var numOfRows = component.get("v.NumOfRecords");
+        if (dataRows > numOfRows + 1 || dataRows == 1 || dataRows == 0) {
+          alert("File Rows between 1 to " + numOfRows + " .");
+          component.set("v.showMain", true);
+        } else {
+          var lines = [];
+          var filecontentdata;
+          var content =
+            '<table class="table slds-table slds-table--bordered slds-table--cell-buffer">';
+          content += '<thead><tr class="slds-text-title--caps">';
+          content += '<th scope="col">' + "琛屽彿" + "</th>";
+          for (i = 0; i < headers.length; i++) {
+            content += '<th scope="col">' + headers[i] + "</th>";
+          }
+          content += "</tr></thead>";
+          for (var i = 1; i < allTextLines.length; i++) {
+            filecontentdata = allTextLines[i].split(",");
+            if (filecontentdata[0] != "") {
+              content += "<tr>";
+              content += "<td>" + i + "</td>";
+              for (var j = 0; j < filecontentdata.length; j++) {
+                content += "<td>" + filecontentdata[j] + "</td>";
+              }
+              content += "</tr>";
+            }
+          }
+          content += "</table>";
+          console.log(content);
+          component.set("v.TableContent", content);
+          component.set("v.showMain", false);
+        }
+      };
+      reader.readAsText(file, "gb2312");
+    }
+    var reader = new FileReader();
+    reader.onloadend = function () {};
+    reader.readAsDataURL(file);
+  },
+  // fy 璋冪敤pi鏀归�犵殑 鑾峰彇url 鍜� token鐨勬柟娉�
+  search_contact_url: function (component, sobject, callback) {
+    var action = component.get("c.getAwsurl");
+    action.setParams({
+      sobj: sobject
+    });
+    action.setCallback(this, function (response) {
+      var state = response.getState();
+      if (state == "SUCCESS") {
+        var result = response.getReturnValue();
+        if (callback) callback(result);
+      } else {
+        component.set("v.errorMessage", "AWS url/token error.");
+        this.showErrorToast01(component);
+        component.set("v.login", false);
+      }
+    });
+    $A.enqueueAction(action);
+  },
+  // fy 璋冪敤pi鏀归�犵殑 鑾峰彇.瀹㈡埛浜哄憳鐨勬柟娉�
+  search_core: function (token, searchUrl, payload, callback, component) {
+    console.log("searchUrl = " + searchUrl);
+    fetch(searchUrl, {
+      method: "POST",
+      body: payload,
+      headers: {
+        "Content-Type": "application/json",
+        "pi-token": token
+      }
+    })
+      .then((data) => {
+        return data.json();
+      })
+      .then((result) => {
+        component.set("v.login", false);
+        if (callback) callback(result);
+      })
+      .catch((error) => {
+        console.log("AWS search error = " + JSON.stringify(error));
+        component.set("v.errorMessage", "AWS search error.");
+        this.showErrorToast01(component);
+        component.set("v.login", false);
+      });
+  },
+  saveRecords: function (component, event, helper) {
+    component.set("v.login", true);
+    //fy 瀵煎叆 202200506 start
+    var action1 = component.get("c.processDataAWSId");
+    action1.setParams({
+      fileData: component.get("v.fileContentData")
+    });
+    action1.setCallback(this, function (response) {
+      var state = response.getState();
+      if (state === "SUCCESS") {
+        debugger;
+        var ress = response.getReturnValue();
+        if (ress) {
+          var valur = ress.split("error1");
+          if (valur.length <= 1) {
+            var res = JSON.parse(response.getReturnValue());
+            debugger;
+            var dataArr = new Array();
+            var dataMap = new Map();
+            res.forEach((item) => {
+              if (item.AWS_Data_Id__c) {
+                dataArr.push(item.AWS_Data_Id__c);
+                //dataMap.set(item.AWS_Data_Id__c,item.Name_Encrypted__c);        //zhj 鏂版柟妗堟敼閫� 2022-12-21
+                dataMap.set(item.AWS_Data_Id__c, item.AWS_Data_Id__c);
+              }
+            });
+            debugger;
+            let obj = Object.create(null);
+            obj["dataIds"] = dataArr;
+            var payload = JSON.stringify(obj);
+            this.search_contact_url(
+              component,
+              "Agency_Contact__c",
+              (result) => {
+                var token = result.token;
+                var searchUrl = result.searchUrl;
+                console.log("token = " + token);
+                console.log("searchUrl = " + searchUrl);
+                console.log("payload = " + payload);
+                this.search_core(
+                  token,
+                  searchUrl,
+                  payload,
+                  (result) => {
+                    console.log("result = " + JSON.stringify(result));
+                    if (result.status == "0") {
+                      if (result.object != null && result.object.length != 0) {
+                        component.set("v.login", true);
+                        this.saveRecordsEditFile(
+                          component,
+                          dataMap,
+                          result.object,
+                          helper
+                        );
+                      } else {
+                        component.set("v.errorMessage", "AWS search status ");
+                        this.showErrorToast01(component);
+                        component.set("v.login", false);
+                      }
+                    } else {
+                      component.set(
+                        "v.errorMessage",
+                        "AWS search status : " + result.status
+                      );
+                      this.showErrorToast01(component);
+                      component.set("v.login", false);
+                    }
+                  },
+                  component
+                );
+              }
+            );
+          } else {
+            component.set(
+              "v.errorMessage",
+              valur[1] + "\n" + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶"
+            );
+            this.showErrorToast01(component);
+            component.set("v.login", false);
+          }
+        }
+      }
+    });
+    $A.enqueueAction(action1);
+    // var action = component.get("c.processData");
+    // var fieldsList = ['Name', 'Phone', 'AccountNumber']; //Please write your code dynamic fields
+    // var filedata =component.get("v.fileContentData");
+    // action.setParams({
+    //     fileData: filedata,
+    //     sobjectName: 'Account', //Any object
+    //     fields: fieldsList
+    // });
+    // action.setCallback(this, function (response) {
+    //     var state = response.getState();
+    //     if (state === "SUCCESS") {
+    //         var res = response.getReturnValue();
+    //         var res1 = '';
+    //         if (res != 'success') {
+    //             var ress = res.split('=');
+    //             console.log(ress);
+    //             for (var i = 0; i < ress.length; i++) {
+    //                 res1 += ress[i].substr(7) + '\n';
+    //             }
+    //             console.log("==" + res1);
+    //             component.set('v.errorMessage', res1 + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
+    //             this.showErrorToast01(component);
+    //             component.set('v.login', false);
+    //         } else {
+    //             component.set('v.successMessage', '瀵煎叆鎴愬姛');
+    //             this.showSuccessToast01(component);
+    //             component.set("v.showMain", true);
+    //             component.set('v.login', false);
+    //             this.doinit(component, event, helper);
+    //         }
+    //     }
+    //     else if (state === "INCOMPLETE") {
+    //         component.set('v.login', false);
+    //     }
+    //     else if (state === "ERROR") {
+    //         var errors = response.getError();
+    //         if (errors) {
+    //             if (errors[0] && errors[0].message) {
+    //                 console.log("Error message: " +
+    //                     errors[0].message);
+    //                 component.set('v.login', false);
+    //             }
+    //         } else {
+    //             console.log("Unknown error");
+    //             component.set('v.login', false);
+    //         }
+    //     }
+    // });
+    // $A.enqueueAction(action);
+  },
+  saveRecordsEditFile: function (component, dataMap, searchData, helper) {
+    var searchDataMap = new Map();
+    for (var i = 0; i < searchData.length; i++) {
+      var sd = searchData[i];
+      searchDataMap.set(sd.name.replace(" ", ""), sd.dataId);
+    }
+    console.log("searchDataMap=" + searchDataMap);
+    var error = "";
+    var fileData = component.get("v.fileContentData");
+    fileData = this.ToCDB(fileData); //鍏ㄨ杞崐瑙�
+    var files = fileData.split("\n");
+
+    var fileStr = files[0];
+    fileStr += "\n";
+
+    for (var i = 1; i < files.length - 1; i++) {
+      if (files[i]) {
+        var filelist = files[i].split(",");
+        var fileName = filelist[5];
+        var WorkRecord = filelist[4];
+        if (
+          WorkRecord == "SIS" ||
+          WorkRecord == "闄㈠唴鍏ラ櫌鐢宠" ||
+          WorkRecord == "鏀惰垂椤圭洰鐢宠" ||
+          WorkRecord == "绉戝浼�"
+        ) {
+          if (fileName) {
+            if (WorkRecord != "绉戝浼�") {
+              if (searchDataMap.get(fileName.replace(" ", ""))) {
+                var nameDataId = searchDataMap.get(fileName.replace(" ", ""));
+                if (dataMap.get(nameDataId)) {
+                  filelist[5] = dataMap.get(nameDataId); //zhj 鏂版柟妗堟敼閫� filelist[5]涓嶅啀瀛樼殑nameEncrpt 2022-12-21
+                } else {
+                  error += "error1 绗�" + i + "琛屾暟鎹嫓璁夸汉SF涓嶅瓨鍦�";
+                }
+              } else {
+                error += "error1 绗�" + i + "琛屾暟鎹嫓璁夸汉AWS涓嶅瓨鍦�";
+              }
+            } else {
+              if (filelist[5] != "鍖荤敓" && filelist[5] != "鍖荤敓+鎶ゅ+") {
+                //&&filelist[5]!='鍖荤敓锛嬫姢澹�'
+                error += "error1 绗�" + i + "琛屾暟鎹嫓璁夸汉涓嶅瓨鍦�";
+              }
+            }
+          } else {
+            error += "error1 绗�" + i + "琛屾暟鎹嫓璁夸汉涓嶈兘涓虹┖";
+          }
+        } else {
+          if (fileName) {
+            if (WorkRecord != "绉戝浼�") {
+              if (searchDataMap.get(fileName.replace(" ", ""))) {
+                var nameDataId = searchDataMap.get(fileName.replace(" ", ""));
+                if (dataMap.get(nameDataId)) {
+                  filelist[5] = dataMap.get(nameDataId);
+                } else {
+                  error += "error1 绗�" + i + "琛屾暟鎹嫓璁夸汉SF涓嶅瓨鍦�";
+                }
+              } else {
+                error += "error1 绗�" + i + "琛屾暟鎹嫓璁夸汉AWS涓嶅瓨鍦�";
+              }
+            } else {
+              if (filelist[5] != "鍖荤敓" && filelist[5] != "鍖荤敓+鎶ゅ+") {
+                //&&filelist[5]!='鍖荤敓锛嬫姢澹�'
+                error += "error1 绗�" + i + "琛屾暟鎹嫓璁夸汉涓嶅瓨鍦�";
+              }
+            }
+          }
+        }
+        fileStr += filelist.toString();
+        fileStr += "\n";
+      }
+    }
+
+    if (error != "") {
+      console.log("zhj error = " + error);
+      let errorArray = error.split("error1");
+      let errorDatas = [];
+      console.log("errorArray = " + JSON.stringify(errorArray));
+      for (var i in errorArray) {
+        if (errorArray[i] != "") {
+          let errorData = {};
+          errorData.errorRow = errorArray[i].trim().substring(1, 2);
+          errorData.errorInfo = errorArray[i].trim().substring(5);
+          errorDatas.push(errorData);
+        }
+      }
+      console.log("errorDatas =" + JSON.stringify(errorDatas));
+      component.set("v.errorData", errorDatas);
+      component.set("v.showErrorInfo", true);
+
+      console.log("error = " + error);
+      component.set("v.errorMessage", error);
+      this.showErrorToast01(component);
+      console.log("error=" + error);
+      component.set("v.login", false);
+      return;
+    }
+
+    console.log("fileStr=" + fileStr);
+    $A.getCallback(function () {
+      debugger;
+      helper.ImportMethod(component, fileStr, helper);
+    })();
+  },
+  ImportMethod: function (component, fileStr, helper) {
+    var action = component.get("c.processData");
+    var fieldsList = ["Name", "Phone", "AccountNumber"]; //Please write your code dynamic fields
+    // var filedata =component.get("v.fileContentData");
+    action.setParams({
+      fileData: fileStr,
+      sobjectName: "Account", //Any object
+      fields: fieldsList
+    });
+    action.setCallback(this, function (response) {
+      var state = response.getState();
+      if (state === "SUCCESS") {
+        var res = response.getReturnValue();
+        var res1 = "";
+        if (res != "success") {
+          var ress = res.split("=");
+          console.log(ress);
+
+          let errorDatas = [];
+          for (var i = 0; i < ress.length; i++) {
+            res1 += ress[i].substr(7) + "\n";
+            if (ress[i] != "") {
+              let errorData = {};
+              errorData.errorRow = ress[i].substr(7).substring(1, 2);
+              errorData.errorInfo = ress[i].substr(7).substring(5);
+              errorDatas.push(errorData);
+            }
+          }
+          component.set("v.errorData", errorDatas);
+          component.set("v.showErrorInfo", true);
+
+          console.log("==" + res1);
+          component.set("v.errorMessage", res1 + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
+          this.showErrorToast01(component);
+          component.set("v.login", false);
+        } else {
+          component.set("v.successMessage", "瀵煎叆鎴愬姛");
+          this.showSuccessToast01(component);
+          component.set("v.showMain", true);
+          component.set("v.login", false);
+          this.doinit(component, event, helper);
+        }
+      } else if (state === "INCOMPLETE") {
+        component.set("v.login", false);
+      } else if (state === "ERROR") {
+        var errors = response.getError();
+        if (errors) {
+          if (errors[0] && errors[0].message) {
+            console.log("Error message: " + errors[0].message);
+            component.set("v.login", false);
+          }
+        } else {
+          console.log("Unknown error");
+          component.set("v.login", false);
+        }
+      }
+    });
+    $A.enqueueAction(action);
+  }, //鍏ㄨ杞崐瑙�
+  ToCDB: function (str) {
+    var tmp = "";
+    for (var i = 0; i < str.length; i++) {
+      if (str.charCodeAt(i) > 65248 && str.charCodeAt(i) < 65375) {
+        tmp += String.fromCharCode(str.charCodeAt(i) - 65248);
+      } else {
+        tmp += String.fromCharCode(str.charCodeAt(i));
+      }
+    }
+    return tmp;
+  },
+  //瀵煎嚭鐨凜SV鏂囦欢
+  convertArrayOfObjectsToCSV: function (component, objectRecords) {
+    var csvStringResult, counter, keys, columnDivider, lineDivider, thkeys;
+    if (objectRecords == null || !objectRecords.length) {
+      return null;
+    }
+    columnDivider = ",";
+    lineDivider = "\n";
+    keys = [
+      "Report_Date__c",
+      "Agency_Hospital__c",
+      "Department_Cateogy_text__c",
+      "DealerPersonnel__c",
+      "WorkRecord__c",
+      "doctor2__c",
+      "ProductClassification__c",
+      "UseProduct1__c",
+      "UseProduct2__c",
+      "UseProduct3__c",
+      "EffectProgress__c",
+      "ConsumptionOfConsumables__c",
+      "WarlockClassification__c",
+      "ProductCcategory__c",
+      "productCategories__c",
+      "warlocksNumber__c",
+      "WorkMark__c"
+    ];
+    thkeys = [
+      "娲诲姩鏃�",
+      "鍖婚櫌",
+      "绉戝",
+      "缁忛攢鍟嗕汉鍛�",
+      "娲诲姩鍖哄垎",
+      "鎷滆浜�",
+      "浜у搧鍒嗙被(绗笁鍒嗙被)",
+      "浣跨敤浜у搧1(浜у搧鍨嬪彿)",
+      "浣跨敤浜у搧2",
+      "浣跨敤浜у搧3",
+      "鏁堟灉/杩涘害",
+      "浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺",
+      "浜у搧1瀵瑰簲鏈紡鍒嗙被",
+      "宸查噰鐢ㄥ叾浠栧搧鐗�",
+      "鍏朵粬鍝佺墝浜у搧绫诲埆",
+      "浜у搧鐢ㄩ噺",
+      "鏀彺闇�姹�"
+    ];
+    csvStringResult = "";
+    csvStringResult += thkeys.join(columnDivider);
+    csvStringResult += lineDivider;
+    console.log("杩涘叆瀵煎嚭helper");
+    for (var i = 0; i < objectRecords.length; i++) {
+      counter = 0;
+      for (var sTempkey in keys) {
+        var skey = keys[sTempkey];
+        if (counter > 0) {
+          csvStringResult += columnDivider;
+        }
+        if (typeof objectRecords[i][skey] === "undefined") {
+          csvStringResult += "" + "" + "";
+          continue;
+        }
+        if (skey == "Person_In_Charge2__c") {
+          csvStringResult += objectRecords[i].Person_In_Charge2__r.Name;
+        } else if (skey == "Agency_Hospital__c") {
+          csvStringResult += objectRecords[i].Agency_Hospital__r.Name;
+        } else if (skey == "DealerPersonnel__c") {
+          csvStringResult += objectRecords[i].DealerPersonnel__r.Name;
+        } else if (skey == "doctor2__c") {
+          csvStringResult += objectRecords[i].doctor2__r.Name;
+        } else if (skey == "UseProduct1__c") {
+          csvStringResult += objectRecords[i].UseProduct1__r.Asset_Model_No__c;
+        } else if (skey == "UseProduct2__c") {
+          csvStringResult += objectRecords[i].UseProduct2__r.Asset_Model_No__c;
+        } else if (skey == "UseProduct3__c") {
+          csvStringResult += objectRecords[i].UseProduct3__r.Asset_Model_No__c;
+        } else {
+          csvStringResult += objectRecords[i][skey];
+        }
+        counter++;
+      }
+      console.log("瀵煎嚭寰幆缁撴潫");
+      csvStringResult += lineDivider;
+    }
+    return csvStringResult;
+  },
+  //  瀵煎嚭椤甸潰鏄剧ず鐨勬ā鏉�
+  showExportDate: function (component, objectRecords) {
+    console.log("杩涘叆showexceportdate" + objectRecords);
+    var keys = [
+      "Report_Date__c",
+      "Agency_Hospital__c",
+      "Department_Cateogy_text__c",
+      "DealerPersonnel__c",
+      "WorkRecord__c",
+      "doctor2__c",
+      "ProductClassification__c",
+      "UseProduct1__c",
+      "UseProduct2__c",
+      "UseProduct3__c",
+      "EffectProgress__c",
+      "ConsumptionOfConsumables__c",
+      "WarlockClassification__c",
+      "ProductCcategory__c",
+      "productCategories__c",
+      "warlocksNumber__c",
+      "WorkMark__c"
+    ];
+    var headers = [
+      "娲诲姩鏃�",
+      "鍖婚櫌",
+      "绉戝",
+      "缁忛攢鍟嗕汉鍛�",
+      "娲诲姩鍖哄垎",
+      "鎷滆浜�",
+      "浜у搧鍒嗙被(绗笁鍒嗙被)",
+      "浣跨敤浜у搧1(浜у搧鍨嬪彿)",
+      "浣跨敤浜у搧2",
+      "浣跨敤浜у搧3",
+      "鏁堟灉/杩涘害",
+      "浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺",
+      "浜у搧1瀵瑰簲鏈紡鍒嗙被",
+      "宸查噰鐢ㄥ叾浠栧搧鐗�",
+      "鍏朵粬鍝佺墝浜у搧绫诲埆",
+      "浜у搧鐢ㄩ噺",
+      "鏀彺闇�姹�"
+    ];
+    var content =
+      '<table class="table slds-table slds-table--bordered slds-table--cell-buffer">';
+    content += '<thead><tr class="slds-text-title--caps">';
+    for (i = 0; i < headers.length; i++) {
+      content += '<th scope="col">' + headers[i] + "</th>";
+    }
+    content += "</tr></thead>";
+    for (var i = 0; i < objectRecords.length; i++) {
+      console.log("for" + content);
+      content += "<tr>";
+      for (var sTempkey in keys) {
+        console.log("for1" + sTempkey);
+        var skey = keys[sTempkey];
+        if (typeof objectRecords[i][skey] === "undefined") {
+          content += "<td>" + "" + "</td>";
+          continue;
+        }
+        console.log("for2" + objectRecords[i].Person_In_Charge2__r.Name);
+        if (skey == "Person_In_Charge2__c") {
+          content +=
+            "<td>" + objectRecords[i].Person_In_Charge2__r.Name + "</td>";
+        } else if (skey == "Agency_Hospital__c") {
+          content +=
+            "<td>" + objectRecords[i].Agency_Hospital__r.Name + "</td>";
+        } else if (skey == "DealerPersonnel__c") {
+          content +=
+            "<td>" + objectRecords[i].DealerPersonnel__r.Name + "</td>";
+        } else if (skey == "doctor2__c") {
+          content += "<td>" + objectRecords[i].doctor2__r.Name + "</td>";
+        } else if (skey == "UseProduct1__c") {
+          content +=
+            "<td>" +
+            objectRecords[i].UseProduct1__r.Asset_Model_No__c +
+            "</td>";
+        } else if (skey == "UseProduct2__c") {
+          content +=
+            "<td>" +
+            objectRecords[i].UseProduct2__r.Asset_Model_No__c +
+            "</td>";
+        } else if (skey == "UseProduct3__c") {
+          content +=
+            "<td>" +
+            objectRecords[i].UseProduct3__r.Asset_Model_No__c +
+            "</td>";
+        } else {
+          content += "<td>" + objectRecords[i][skey] + "</td>";
+        }
+      }
+      content += "</tr>";
+    }
+    content += "</table>";
+    console.log("helper寰幆缁撴潫" + content);
+    component.set("v.TableContent2", content);
+    component.set("v.showMain", false);
+  },
+
+  select_repores_date: function (component, event, helper) {
+    component.set("v.login", true);
+    var reportsdate1 = component.find("input-report-date1").get("v.value");
+    var reportsdate2 = component.find("input-report-date2").get("v.value");
+    console.log(
+      "杈撳叆鐨勫紑濮嬫棩鏈�" + reportsdate1 + "杈撳叆鐨勭粨鏉熸棩鏈�" + reportsdate2
+    );
+    var action = component.get("c.getReportsByDate");
+    console.log("杈撳叆鐨勫紑濮嬫棩鏈�1");
+    action.setParams({
+      date1: reportsdate1,
+      date2: reportsdate2
+    });
+    console.log("杈撳叆鐨勫紑濮嬫棩鏈�2");
+    action.setCallback(this, function (response) {
+      var state = response.getState();
+      if (state === "SUCCESS") {
+        var res = response.getReturnValue();
+        console.log("杈撳叆鐨勫紑濮嬫棩鏈�3" + res);
+        component.set("v.login", false);
+
+        // PI 鏀归�� By Bright 20220328
+        if (true) {
+          let awsids = [];
+          for (let ri in res) {
+            if (
+              res[ri] &&
+              res[ri].doctor2__r &&
+              res[ri].doctor2__r.AWS_Data_Id__c
+            ) {
+              awsids.push(res[ri].doctor2__r.AWS_Data_Id__c);
+            }
+          }
+          if (awsids.length > 0) {
+            let PIConfig = component.get("v.PIConfig");
+            let staticResourceAgencyContact = JSON.parse(
+              PIConfig.staticResourceAgencyContact
+            );
+            AWSService.search(
+              staticResourceAgencyContact.searchUrl,
+              {
+                dataIds: awsids
+              },
+              function (data) {
+                if (data && data.object && data.object.length) {
+                  let m = {};
+                  for (let di in data.object) {
+                    if (data.object[di] && data.object[di].dataId) {
+                      m[data.object[di].dataId] = data.object[di];
+                    }
+                  }
+
+                  for (let ri in res) {
+                    if (
+                      res[ri] &&
+                      res[ri].doctor2__r &&
+                      res[ri].doctor2__r.AWS_Data_Id__c &&
+                      m.hasOwnProperty(res[ri].doctor2__r.AWS_Data_Id__c)
+                    ) {
+                      res[ri].doctor2__r.Name =
+                        m[res[ri].doctor2__r.AWS_Data_Id__c].name;
+                    }
+                  }
+                }
+                helper.showExportDate(component, res);
+
+                component.set("v.login", false);
+              },
+              staticResourceAgencyContact.token
+            );
+          } else {
+            helper.showExportDate(component, res);
+          }
+        }
+
+        component.set("v.reports_date", res);
+      } else {
+        alert("瀵煎嚭澶辫触,璇锋鏌ユ椿鍔ㄦ棩");
+        component.set("v.login", false);
+      }
+    });
+    $A.enqueueAction(action);
+  },
+
+  showImport: function (component) {
+    var modalimport = component.find("modal_import");
+    var modalimportbg = component.find("modal_importbg");
+    $A.util.removeClass(modalimport, "disp_none");
+    $A.util.removeClass(modalimportbg, "disp_none");
+  },
+
+  showExport: function (component) {
+    var modalimport = component.find("modal_export");
+    var modalimportbg = component.find("modal_exportbg");
+    $A.util.removeClass(modalimport, "disp_none");
+    $A.util.removeClass(modalimportbg, "disp_none");
+  },
+
+  close_import: function (component) {
+    var modalimport = component.find("modal_import");
+    var modalimportbg = component.find("modal_importbg");
+    $A.util.addClass(modalimport, "disp_none");
+    $A.util.addClass(modalimportbg, "disp_none");
+  },
+
+  close_export: function (component) {
+    var modalimport = component.find("modal_export");
+    var modalimportbg = component.find("modal_exportbg");
+    $A.util.addClass(modalimport, "disp_none");
+    $A.util.addClass(modalimportbg, "disp_none");
+  },
+  //椤甸潰涓殑鏂板缓鑱屼綅鎸夐挳
+  newlyBuild: function (component, event, helper) {
+    var hospital_id = component.get("v.hospitalLinkId");
+    event.preventDefault(); // stop form submission
+    var fields = component.find("newOpportunityField");
+    var nameer = "";
+    var type = "";
+    var doctorDivision1 = "";
+    fields.forEach(function (field) {
+      if (field.get("v.fieldName") === "Name") {
+        nameer = field.get("v.value");
+      }
+      if (field.get("v.fieldName") === "Type__c") {
+        type = field.get("v.value");
+      }
+      if (field.get("v.fieldName") === "Doctor_Division1__c") {
+        doctorDivision1 = field.get("v.value");
+      }
+    });
+    if (hospital_id) {
+      component.set("v.login", true);
+      var action = component.get("c.newlyBuild");
+      action.setParams({
+        hospital_id: hospital_id,
+        nameer: nameer,
+        type: type,
+        doctorDivision1: doctorDivision1
+      });
+      action.setCallback(this, function (response) {
+        var state = response.getState();
+        if (state == "SUCCESS") {
+          var res = this.conv_selected(response.getReturnValue());
+          var default_doctor = component.get("v.default_select_doctor_id");
+          if (default_doctor != "" && res.length > 0) {
+            var doctor_title = "";
+            for (var i = 0; i < res.length; i++) {
+              if (res[i].value == default_doctor) {
+                res[i].selected = true;
+                doctor_title = res[i].Doctor_Division1__c;
+              } else {
+                res[i].selected = false;
+              }
+            }
+            component.find("select_doctor").set("v.options", res);
+            component.set("v.doctor_title", doctor_title);
+          } else {
+            component.find("select_doctor").set("v.options", res);
+            if (res.length > 0) {
+              component.set("v.doctor_title", res[0].Doctor_Division1__c);
+            }
+          }
+          component.set("v.default_select_doctor_id", "");
+          component.set("v.doctor_list", res);
+          component.set("v.login", false);
+        } else {
+          component.set("v.errorMessage", "newlyBuild failed.");
+          this.showErrorToast(component);
+          component.set("v.login", false);
+        }
+      });
+      $A.enqueueAction(action);
+    }
+  },
+  //绉戝鍚岀被鑰楁潗楠岃瘉蹇呴』杈撳叆鏁板瓧
+  select_ConsumptionOfConsumables: function (component, event, helper) {
+    var sc = event.getSource().get("v.value");
+    if (sc != null) {
+      if (sc.length <= 14) {
+        if (sc.replace(/\D/gi, "")) {
+          component.set("v.select_ConsumptionOfConsumables", sc);
+        } else {
+          component.set(
+            "v.errorMessage",
+            "浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺蹇呴』杈撳叆鏁板瓧!"
+          );
+          this.showErrorToast(component);
+        }
+      } else {
+        component.set(
+          "v.errorMessage",
+          "浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺鏈�澶氳緭鍏�14浣嶆暟瀛�!"
+        );
+        this.showErrorToast(component);
+      }
+    }
+  },
+  //浜у搧鐢ㄩ噺楠岃瘉蹇呴』杈撳叆鏁板瓧
+  select_warlocksNumber: function (component, event, helper) {
+    var sc = event.getSource().get("v.value");
+    if (sc != null) {
+      if (sc.length <= 14) {
+        if (sc.replace(/\D/gi, "")) {
+          component.set("v.select_warlocksNumber", sc);
+        } else {
+          component.set("v.errorMessage", "浜у搧鐢ㄩ噺蹇呴』杈撳叆鏁板瓧!");
+          this.showErrorToast(component);
+        }
+      } else {
+        component.set("v.errorMessage", "浜у搧鐢ㄩ噺鏈�澶氳緭鍏�14浣嶆暟瀛�!");
+        this.showErrorToast(component);
+      }
+    }
+  },
+  //宸ヤ綔浼氳褰�
+  selectPurposeType: function (component, event, helper) {
+    debugger;
+    var doctor_value = component.find("select_purpose_type").get("v.value");
+    // alert(doctor_value);
+    if (doctor_value != "绉戝浼�") {
+      component.find("new_con").set("v.disabled", false);
+    } else {
+      component.find("new_con").set("v.disabled", true);
+    }
+    if (doctor_value != "") {
+      this.set_doctor_list(component);
+      var action = component.get("c.selectPurposeTypes");
+      action.setParams({
+        doctor_value: doctor_value
+      });
+      action.setCallback(this, function (response) {
+        var state = response.getState();
+        if (state == "SUCCESS") {
+          var res = response.getReturnValue();
+          component
+            .find("select_EffectProgress")
+            .set("v.options", JSON.parse(JSON.stringify(res)));
+        }
+      });
+      $A.enqueueAction(action);
+    } else {
+      component.find("select_EffectProgress").set("v.options", []);
+    }
+  },
+
+  selectProductClassification: function (component, event, helper) {
+    debugger;
+    var select_ProductClassification = component
+      .find("select_ProductClassification")
+      .get("v.value");
+    if (select_ProductClassification != "") {
+      var action = component.get("c.selectProductClassificationc");
+      action.setParams({
+        select_ProductClassification: select_ProductClassification
+      });
+      action.setCallback(this, function (response) {
+        var state = response.getState();
+        if (state == "SUCCESS") {
+          var res = response.getReturnValue();
+          component
+            .find("select_OtherBrandConsumables")
+            .set("v.options", JSON.parse(JSON.stringify(res)));
+        }
+      });
+      $A.enqueueAction(action);
+    } else {
+      component.find("select_OtherBrandConsumables").set("v.options", []);
     }
     this.selectProductCcategory(component);
-    },
-    select_ProductCcategory: function (component,event,helper) {
-        var select_ProductCcategory = component.find('select_ProductCcategory').get('v.value');
-        if(select_ProductCcategory != ''){
-            var result = component.find('result');
-            var UserProType = component.get('v.UserProType');
-        //fy
-        $A.util.removeClass(result, 'disp_none');
-        if(UserProType=='ENG'){
-            $A.util.removeClass(result, 'disp_none');
-        }else{
-            $A.util.addClass(result, 'disp_none');
+  },
+  select_ProductCcategory: function (component, event, helper) {
+    var select_ProductCcategory = component
+      .find("select_ProductCcategory")
+      .get("v.value");
+    debugger;
+    if (select_ProductCcategory != "") {
+      var result = component.find("result");
+      var UserProType = component.get("v.UserProType");
+      //fy
+      $A.util.removeClass(result, "disp_none");
+      if (UserProType == "ENG") {
+        $A.util.removeClass(result, "disp_none");
+      } else {
+        $A.util.addClass(result, "disp_none");
+      }
+      var action = component.get("c.selectProductCcategory01");
+      action.setParams({
+        select_ProductCcategory: select_ProductCcategory
+      });
+      action.setCallback(this, function (response) {
+        var state = response.getState();
+        if (state == "SUCCESS") {
+          var res = response.getReturnValue();
+          component
+            .find("select_productCategories")
+            .set("v.options", JSON.parse(JSON.stringify(res)));
         }
-        var action = component.get('c.selectProductCcategory01');
-        action.setParams({
-            "select_ProductCcategory": select_ProductCcategory
-        });
-        action.setCallback(this, function (response) {
-            var state = response.getState();
-            if (state == 'SUCCESS') {
-                var res = response.getReturnValue();
-                component.find('select_productCategories').set("v.options", JSON.parse(JSON.stringify(res)));
-            }
-        });
-        $A.enqueueAction(action);
-    }else{
-        component.find('select_productCategories').set('v.options', []);
-        var result = component.find('result');
-        $A.util.addClass(result, 'disp_none');
+      });
+      $A.enqueueAction(action);
+    } else {
+      component.find("select_productCategories").set("v.options", []);
+      var result = component.find("result");
+      $A.util.addClass(result, "disp_none");
     }
-    },
-    selectpurposetype : function(component,event,helper){
-        var select_ProductCcategory = component.find('select_ProductCcategory').get('v.value');
-        if (select_ProductCcategory == null && select_ProductCcategory == undefined  && select_ProductCcategory == '') {
-            var result = component.find('result');
-            // $A.util.removeClass(result, 'disp_none');
-            if(UserProType=='ENG'){
-                $A.util.removeClass(result, 'disp_none');
-            }else{
-                $A.util.addClass(result, 'disp_none');
-            }
-        } else {
-            debugger
-            component.find('select_productCategories').set('v.value', '');
-            var result = component.find('result');
-            $A.util.addClass(result, 'disp_none');
-            this.select_ProductCcategory(component);
+  },
+  selectpurposetype: function (component, event, helper) {
+    var select_ProductCcategory = component
+      .find("select_ProductCcategory")
+      .get("v.value");
+    if (
+      select_ProductCcategory == null &&
+      select_ProductCcategory == undefined &&
+      select_ProductCcategory == ""
+    ) {
+      var result = component.find("result");
+      // $A.util.removeClass(result, 'disp_none');
+      if (UserProType == "ENG") {
+        $A.util.removeClass(result, "disp_none");
+      } else {
+        $A.util.addClass(result, "disp_none");
+      }
+    } else {
+      debugger;
+      component.find("select_productCategories").set("v.value", "");
+      var result = component.find("result");
+      $A.util.addClass(result, "disp_none");
+      this.select_ProductCcategory(component);
+    }
+  },
+  //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+  CallBackAction: function (component, action_name, para, callback) {
+    var action = component.get(
+      "c." + action_name.trimStart().replace("c.", "")
+    );
+    if (para) {
+      action.setParams(para);
+    }
+    if (callback) {
+      action.setCallback(this, function (data) {
+        callback(data);
+      });
+    }
+
+    $A.enqueueAction(action);
+  },
+  //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
+
+  //zhj 瀵煎嚭閿欒淇℃伅 2023-05-16 start
+  exportErrorInfoHelper: function (component) {
+    var errorData = component.get("v.errorData");
+
+    var datas = [["閿欒琛�", "閿欒淇℃伅"]];
+    for (var i in errorData) {
+      let data = [];
+      data.push(errorData[i].errorRow);
+      data.push(errorData[i].errorInfo);
+      datas.push(data);
+    }
+
+    console.log("datas = " + JSON.stringify(datas));
+    var csv = this.convertToCSV(component, datas);
+    console.log("csv = " + JSON.stringify(csv));
+    this.downloadCSV(component, csv);
+  },
+
+  convertToCSV: function (component, data) {
+    console.log("enter convertToCSV");
+    console.log("data = " + data);
+    var csv = "";
+    for (var i = 0; i < data.length; i++) {
+      var row = data[i];
+      console.log("row = " + JSON.stringify(row));
+      for (var j = 0; j < row.length; j++) {
+        var val = "";
+        val = row[j] === null ? "" : row[j].toString();
+        console.log("val = " + val);
+        if (
+          val.indexOf(",") !== -1 ||
+          val.indexOf('"') !== -1 ||
+          val.indexOf("\n") !== -1
+        ) {
+          //val = '"' + val.replace(/"/g,'""') + '"';
         }
-    },
-})
\ No newline at end of file
+        if (j > 0) {
+          csv += ",";
+        }
+        csv += val;
+      }
+      csv += "\n";
+    }
+    return csv;
+  },
+
+  downloadCSV: function (component, csv) {
+    var link = document.createElement("a");
+    link.href = "data:text/csv;charset=utf-8," + encodeURIComponent(csv);
+    link.download = "data.csv";
+    document.body.appendChild(link);
+    link.click();
+    document.body.removeChild(link);
+  }
+  //zhj 瀵煎嚭閿欒淇℃伅 2023-05-16 end
+});
diff --git a/force-app/main/default/classes/ArriveGoodsController.cls b/force-app/main/default/classes/ArriveGoodsController.cls
index 5581582..41fa019 100644
--- a/force-app/main/default/classes/ArriveGoodsController.cls
+++ b/force-app/main/default/classes/ArriveGoodsController.cls
@@ -1,333 +1,437 @@
 public without sharing class ArriveGoodsController {
-    public String barcode { get; set; }
-    public Consumable_order__c coc { get; set; }
-    /*****************鐢婚潰琛ㄧずBean******************/
-    public List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
-    public List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsUse = new List<ConsumableorderdetailsInfo>();
-    public List<ConsumableorderdetailsInfo> consumableInventory { get; set; }
-    public List<ConsumableorderdetailsInfo> detailsSummary { get; set; }
-    public List<ConsumableorderdetailsInfo> consumableInventoryUse = new List<ConsumableorderdetailsInfo>();
-    //鏇存柊鏄庣粏鍙栨秷鏃堕棿
-    public List<Consumable_order_details2__c> consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
-    // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-    Map<String,Consumable_order_details2__c> orderdetails2trMap = new Map<String,Consumable_order_details2__c>();
-    // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-    public List<Consumable_order_details2__c> consumableorderdetails2Insert= new List<Consumable_order_details2__c>();
-    public List<Consumable_order_details2__c> consumableorderdetails2Nobox= new List<Consumable_order_details2__c>();
-    public List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordserror { get; set; }
-    public transient List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy { get; set; }
-    public List<ConsumableorderdetailsInfo> ShowGoodsofReturnList{get;set;}
-    public List<ConsumableorderdetailsInfo> ShowGoodsofRemoveBoxReturnList{get;set;}
-    //add by rentx 20210602 CHAN-C3K4ZQ
-    public List<List<ConsumableorderdetailsInfo>> consumableorderdetailsRecordsview { get; set; }
-    //add by rentx 20210602 CHAN-C3K4ZQ
+  public String barcode { get; set; }
+  public Consumable_order__c coc { get; set; }
+  /*****************鐢婚潰琛ㄧずBean******************/
+  public List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+  public List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsUse = new List<ConsumableorderdetailsInfo>();
+  public List<ConsumableorderdetailsInfo> consumableInventory { get; set; }
+  public List<ConsumableorderdetailsInfo> detailsSummary { get; set; }
+  public List<ConsumableorderdetailsInfo> consumableInventoryUse = new List<ConsumableorderdetailsInfo>();
+  //鏇存柊鏄庣粏鍙栨秷鏃堕棿
+  public List<Consumable_order_details2__c> consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
+  // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+  Map<String, Consumable_order_details2__c> orderdetails2trMap = new Map<String, Consumable_order_details2__c>();
+  // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+  public List<Consumable_order_details2__c> consumableorderdetails2Insert = new List<Consumable_order_details2__c>();
+  public List<Consumable_order_details2__c> consumableorderdetails2Nobox = new List<Consumable_order_details2__c>();
+  public List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordserror {
+    get;
+    set;
+  }
+  public transient List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy {
+    get;
+    set;
+  }
+  public List<ConsumableorderdetailsInfo> ShowGoodsofReturnList { get; set; }
+  public List<ConsumableorderdetailsInfo> ShowGoodsofRemoveBoxReturnList {
+    get;
+    set;
+  }
+  //add by rentx 20210602 CHAN-C3K4ZQ
+  public List<List<ConsumableorderdetailsInfo>> consumableorderdetailsRecordsview {
+    get;
+    set;
+  }
+  //add by rentx 20210602 CHAN-C3K4ZQ
 
-    public List<String> GrList = new List<String>();
-    //瓒呭嚭瀹氳揣鏁伴噺鐨勪骇鍝�
-    public List<String> cancellationProList = new List<String>();
-    //閿欒淇℃伅
-    public String alertMessage {set;get;}
-    public integer getinventorysize(){
-        return consumableInventory.size();
-    }
-    public integer geterrorsize(){
-        return ConsumableorderdetailsRecordserror.size();
-    }
-    Set<String> noboxBarcodeList = new Set<String>();
-    public transient Map<String, String> ExistIdMap = new Map<String, String>();
-    public transient Map<String, String> ErrorIdMap = new Map<String, String>();
-    public transient Map<String, String> AllMap = new Map<String, String>();
-    Map<String, String> otherAgencyMap = new Map<String, String>();
-    public transient Map<String, String> barMcodeMap = new Map<String, String>();
-    Map<String, Integer> BarcodeCntMap = new Map<String, Integer>();
-    //qi
-    public transient List<String> BarCodeListP = new List<String>();
+  public List<String> GrList = new List<String>();
+  //瓒呭嚭瀹氳揣鏁伴噺鐨勪骇鍝�
+  public List<String> cancellationProList = new List<String>();
+  //閿欒淇℃伅
+  public String alertMessage { get; set; }
+  public integer getinventorysize() {
+    return consumableInventory.size();
+  }
+  public integer geterrorsize() {
+    return ConsumableorderdetailsRecordserror.size();
+  }
+  Set<String> noboxBarcodeList = new Set<String>();
+  public transient Map<String, String> ExistIdMap = new Map<String, String>();
+  public transient Map<String, String> ErrorIdMap = new Map<String, String>();
+  public transient Map<String, String> AllMap = new Map<String, String>();
+  Map<String, String> otherAgencyMap = new Map<String, String>();
+  public transient Map<String, String> barMcodeMap = new Map<String, String>();
+  Map<String, Integer> BarcodeCntMap = new Map<String, Integer>();
+  //qi
+  public transient List<String> BarCodeListP = new List<String>();
 
-    // public transient Map<String, String> OrderAllMap = new Map<String, String>();
-    Map<String, Decimal> orderProductCunMap = new Map<String, Decimal>();
-    Map<String, Decimal> orderProductArrivedCunMap = new Map<String, Decimal>();
-    Map<String, Decimal> orderWantArriveCunMap = new Map<String, Decimal>();
-    //瓒呭嚭鍨嬪彿鍜屾暟閲�
-    Map<String, Decimal> overOrderCunMap = new Map<String, Decimal>();
-    //瓒呭嚭BARCODE鍜屽瀷鍙�
-    Map<String, List<String>> overOrderBARcodeCunMap = new Map<String, List<String>>();
-    list<String> overOrderBARcodeTTTTTT = new list<String>();
+  // public transient Map<String, String> OrderAllMap = new Map<String, String>();
+  Map<String, Decimal> orderProductCunMap = new Map<String, Decimal>();
+  Map<String, Decimal> orderProductArrivedCunMap = new Map<String, Decimal>();
+  Map<String, Decimal> orderWantArriveCunMap = new Map<String, Decimal>();
+  //瓒呭嚭鍨嬪彿鍜屾暟閲�
+  Map<String, Decimal> overOrderCunMap = new Map<String, Decimal>();
+  //瓒呭嚭BARCODE鍜屽瀷鍙�
+  Map<String, List<String>> overOrderBARcodeCunMap = new Map<String, List<String>>();
+  list<String> overOrderBARcodeTTTTTT = new List<String>();
 
-    //涓嶇鍚堢殑barcode鍜屽瀷鍙�
-    Map<String, List<String>> notEqualBARcodeCunMap = new Map<String, List<String>>();
-    list<String> overOrderBARcodeSSSSSS = new list<String>();
-    list<String> productList = new list<String>();
-    list<String> notInlist = new list<String>();
-    //涓嶉�夋嫨璁㈠崟鏃朵繚瀛樿鍗旾D銆佷骇鍝佸瀷鍙风敤
-    //List<String> orderId = new List<String>();
-    //List<String> prodName = new List<String>();
-    //搴撳瓨鐧诲綍浣跨敤
-    list<String> notInStorelist = new list<String>();
-    list<String> exitBarCodeList = new list<String>();
+  //涓嶇鍚堢殑barcode鍜屽瀷鍙�
+  Map<String, List<String>> notEqualBARcodeCunMap = new Map<String, List<String>>();
+  list<String> overOrderBARcodeSSSSSS = new List<String>();
+  list<String> productList = new List<String>();
+  list<String> notInlist = new List<String>();
+  //涓嶉�夋嫨璁㈠崟鏃朵繚瀛樿鍗旾D銆佷骇鍝佸瀷鍙风敤
+  //List<String> orderId = new List<String>();
+  //List<String> prodName = new List<String>();
+  //搴撳瓨鐧诲綍浣跨敤
+  list<String> notInStorelist = new List<String>();
+  list<String> exitBarCodeList = new List<String>();
 
+  // Map<String, Consumable_order_details2__c> reallMap = new Map<String, Consumable_order_details2__c>();
+  Map<String, String> HosErrorMap = new Map<String, String>();
+  List<String> HosErrorList = new List<String>();
+  public String baseUrl { get; private set; }
+  public String ESetId { get; set; }
+  public String arriveId = '';
+  private String accountid = null;
+  private String accountName = null;
+  //public String[] proidList =new String[]{};
+  public Decimal orderCountAll = 0;
+  public Decimal orderCountNotarrive = 0;
+  //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+  public id return_Order_id = null;
+  public id inventory_Order_id = null;
+  public boolean ReturnFLGbln { get; set; }
+  public boolean saveFLGbln { get; set; }
+  public String ArrType { get; set; }
+  // 鐧诲綍鑰呭伐浣滃湴
+  private String userWorkLocation;
 
-    // Map<String, Consumable_order_details2__c> reallMap = new Map<String, Consumable_order_details2__c>();
-    Map<String,String> HosErrorMap = new Map<String,String>();
-    List<String> HosErrorList = new List<String>();
-    public String baseUrl {get;private set;}
-    public String ESetId { get; set; }
-    public String arriveId = '';
-    private String accountid = null;
-    private String accountName = null;
-    //public String[] proidList =new String[]{};
-    public Decimal orderCountAll = 0;
-    public Decimal orderCountNotarrive = 0;
-    private id return_Order_id = null;
-    private id inventory_Order_id = null;
-    public boolean ReturnFLGbln {get;set;}
-    public boolean saveFLGbln {get;set;}
-    public String ArrType{get;set;}
-    // 鐧诲綍鑰呭伐浣滃湴
-    private String userWorkLocation;
+  //鐢ㄦ埛浜у搧鍖哄垎
+  public String userPro_Typestr = null;
+  public String userPro_Type = null;
+  public String product_Type = null;
+  public Boolean EngFlag = false;
+  public Boolean ETFlag = false;
 
-    //鐢ㄦ埛浜у搧鍖哄垎
-    public String userPro_Typestr = null;
-    public String userPro_Type = null;
-    public String product_Type = null;
-    public Boolean EngFlag = false;
-    public Boolean ETFlag = false;
-    public ArriveGoodsController(){
-        baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
-        ESetId = ApexPages.currentPage().getParameters().get('esetId');
-        ArrType = ApexPages.currentPage().getParameters().get('ArrType');
-        ConsumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
-        ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
-        ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
-        consumableInventory = new List<ConsumableorderdetailsInfo>();
-        consumableorderdetailsRecordsUse = new List<ConsumableorderdetailsInfo>();
-        consumableInventoryUse = new List<ConsumableorderdetailsInfo>();
-        consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
-        orderdetails2trMap = new Map<String,Consumable_order_details2__c>();
-        detailsSummary = new List<ConsumableorderdetailsInfo>();
-        saveFLGbln = FALSE;
-        //overOrderBARcodeTTTTTT.add('');
-        //add by rentx 20210602 CHAN-C3K4ZQ start 
-        consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
-        //add by rentx 20210602 CHAN-C3K4ZQ end 
-        // OrderAllMap = new Map<String, String>();
-    }
+  //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+  public Boolean isLwc = false;
+  public String returnError;
+  public List<String> warningList;
+  public List<String> errorList;
+  public String urlType;
 
-    //add by rentx 20210602 CHAN-C3K4ZQ start 鍑洪敊鐨勫師鍥犳槸椤甸潰鏈�澶氬睍绀�1000鏉℃暟鎹�,浣嗘槸闇�瑕佸睍绀虹殑鏁版嵁瓒呰繃浜�1000鏉�,鐜板湪鎶婂睍绀轰笂绾挎敼涓�1000 * 1000
-    public void makeRecordsView(List<ConsumableorderdetailsInfo> recordsdummy){
-        consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
-
-        if(recordsdummy.size() > 1000){
-            List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsbreak = new List<ConsumableorderdetailsInfo>();
-            List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsbreakover = new List<ConsumableorderdetailsInfo>();
-            ConsumableorderdetailsInfo c = null;
-            ConsumableorderdetailsRecordsbreak.clear();
-            ConsumableorderdetailsRecordsbreakover.clear();
-            consumableorderdetailsRecordsview.clear();
-            //閫夋嫨浜у搧view
-            ConsumableorderdetailsRecordsbreak = new List<ConsumableorderdetailsInfo>();
-            ConsumableorderdetailsRecordsbreakover = new List<ConsumableorderdetailsInfo>();
-            if(recordsdummy.size() > 1000){
-                for(Integer i = 0; i < recordsdummy.size(); i++){
-                    if(i < 1000){
-                        c = recordsdummy.get(i);
-                        ConsumableorderdetailsRecordsbreak.add(c);
-                    }else{
-                        c = recordsdummy.get(i);
-                        ConsumableorderdetailsRecordsbreakover.add(c);
-                    }
-                }
-                consumableorderdetailsRecordsview.add(ConsumableorderdetailsRecordsbreak);
-                consumableorderdetailsRecordsview.add(ConsumableorderdetailsRecordsbreakover);
-            }else{
-                consumableorderdetailsRecordsview.add(recordsdummy);
-            }
-
-            // Integer count = recordsdummy.size() / 1000;
-            // Integer last = recordsdummy.size() - (1000*count);
-
-            // for(Integer i = 0; i < count ; i++){
-            //     List<ConsumableorderdetailsInfo> tempList = new List<ConsumableorderdetailsInfo>();
-            //     for(Integer j=0; j < 1000; j++){
-            //         tempList.add(recordsdummy.get(i * count + j ));
-            //         // itemList.add(resList.get(i*count+j));
-            //     }
-            //     consumableorderdetailsRecordsview.add(tempList);
-            // }
-            // if (last > 0) {
-            //     List<ConsumableorderdetailsInfo> tempList = new List<ConsumableorderdetailsInfo>();
-            //     for(Integer j=0; j < last; j++){
-            //         tempList.add(recordsdummy.get(count * 1000 + j ));
-            //         // itemList.add(resList.get(i*count+j));
-            //     }
-            //     consumableorderdetailsRecordsview.add(tempList);
-            // }
-        }else{
-            consumableorderdetailsRecordsview.add(recordsdummy);
-        }
-    }
+  public ArriveGoodsController() {
+    baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
+    ESetId = ApexPages.currentPage().getParameters().get('esetId');
+    ArrType = ApexPages.currentPage().getParameters().get('ArrType');
+    ConsumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+    ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
+    ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
+    consumableInventory = new List<ConsumableorderdetailsInfo>();
+    consumableorderdetailsRecordsUse = new List<ConsumableorderdetailsInfo>();
+    consumableInventoryUse = new List<ConsumableorderdetailsInfo>();
+    consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
+    orderdetails2trMap = new Map<String, Consumable_order_details2__c>();
+    detailsSummary = new List<ConsumableorderdetailsInfo>();
+    saveFLGbln = false;
+    //overOrderBARcodeTTTTTT.add('');
+    //add by rentx 20210602 CHAN-C3K4ZQ start
+    consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
     //add by rentx 20210602 CHAN-C3K4ZQ end
-    public void init() {
-        // String userId = '00510000007cthP';
-        String userId = UserInfo.getUserId();
-        List<user> Useracc = New List<user>();
-        Useracc = [SELECT accountid, Work_Location__c,UserPro_Type__c FROM user WHERE id =:userId];
-        accountid = Useracc[0].accountid;
-        //--------AddStart-----XHL--------------20181008-------------
-        userPro_Type = Useracc[0].UserPro_Type__c;
-        if(String.isBlank(userPro_Type)){
-            userPro_Type = 'ET';
-        }
+    // OrderAllMap = new Map<String, String>();
+  }
 
-        if(userPro_Type == 'ENG'){
-            product_Type = 'ET';
-            EngFlag = true;
-        }else{
-            product_Type = 'ENG';
-            ETFlag = true;
+  //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+  public ArriveGoodsController(String eSetId, String arrType) {
+    this.ESetId = eSetId;
+    this.ArrType = arrType;
+    ConsumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+    ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
+    ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
+    consumableInventory = new List<ConsumableorderdetailsInfo>();
+    consumableorderdetailsRecordsUse = new List<ConsumableorderdetailsInfo>();
+    consumableInventoryUse = new List<ConsumableorderdetailsInfo>();
+    consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
+    orderdetails2trMap = new Map<String, Consumable_order_details2__c>();
+    detailsSummary = new List<ConsumableorderdetailsInfo>();
+    saveFLGbln = false;
+    consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
+    noboxBarcodeList = new Set<String>();
+    //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+    warningList = new List<String>();
+    errorList = new List<String>();
+    returnError = null;
+    urlType = null;
+  }
+
+  //add by rentx 20210602 CHAN-C3K4ZQ start 鍑洪敊鐨勫師鍥犳槸椤甸潰鏈�澶氬睍绀�1000鏉℃暟鎹�,浣嗘槸闇�瑕佸睍绀虹殑鏁版嵁瓒呰繃浜�1000鏉�,鐜板湪鎶婂睍绀轰笂绾挎敼涓�1000 * 1000
+  public void makeRecordsView(List<ConsumableorderdetailsInfo> recordsdummy) {
+    consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
+
+    if (recordsdummy.size() > 1000) {
+      List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsbreak = new List<ConsumableorderdetailsInfo>();
+      List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsbreakover = new List<ConsumableorderdetailsInfo>();
+      ConsumableorderdetailsInfo c = null;
+      ConsumableorderdetailsRecordsbreak.clear();
+      ConsumableorderdetailsRecordsbreakover.clear();
+      consumableorderdetailsRecordsview.clear();
+      //閫夋嫨浜у搧view
+      ConsumableorderdetailsRecordsbreak = new List<ConsumableorderdetailsInfo>();
+      ConsumableorderdetailsRecordsbreakover = new List<ConsumableorderdetailsInfo>();
+      if (recordsdummy.size() > 1000) {
+        for (Integer i = 0; i < recordsdummy.size(); i++) {
+          if (i < 1000) {
+            c = recordsdummy.get(i);
+            ConsumableorderdetailsRecordsbreak.add(c);
+          } else {
+            c = recordsdummy.get(i);
+            ConsumableorderdetailsRecordsbreakover.add(c);
+          }
         }
-        userPro_Typestr = '%' + userPro_Type + '%';
-        //--------AddEnd-----XHL--------------20181008-------------
-        userWorkLocation = Useracc[0].Work_Location__c;
-        system.debug('userWorkLocation'+ userWorkLocation);
-        List<account> accountInfo = [SELECT Name FROM account WHERE id =:accountid];
-        accountName = accountInfo[0].Name;
-        system.debug('accountName'+ accountName);
-        coc = new Consumable_order__c();
-        if(ArrType=='ReG'){
-            ReturnFLGbln = true;
-        }else{
-            ReturnFLGbln = false;
-        }
-        if(ESetId != '' && ESetId !=null){
-            List<Consumable_order__c> qs = New List<Consumable_order__c>();
-            List<Consumable_order_details2__c> reSet1 = New List<Consumable_order_details2__c>();
-            List<Consumable_Orderdetails__c> reSet = New List<Consumable_Orderdetails__c>();
-            qs = [SELECT Id,Name,Order_status__c,Dealer_Info__c,Deliver_date__c,ReturnGs_Upload_Date__c,
-                        Order_Reason__c,Order_date__c,
-                        Contract_application_decision__c,Order_type__c,Total_num__c,
-                        OrderNumber_arrived__c,Delivery_detail_count__c,OrderNumber_notarrive__c,orderPattern__c 
-                    FROM Consumable_order__c
-                    WHERE Id =:ESetId AND Order_Owner_WorkLocal__c =: userWorkLocation
-                    AND Dealer_Info__c = :accountid];
-            if (qs.size()>0){
-                coc = qs[0];
-                orderCountAll = coc.Total_num__c;
-                orderCountNotarrive = coc.OrderNumber_notarrive__c;
-            }
-            //浜у搧瀹氳揣鏁伴噺
-            reSet = [SELECT Asset_Model_No__c,
-                            Consumable_order__c,
-                            Consumable_count__c
-                        FROM Consumable_Orderdetails__c
-                        WHERE Consumable_order__c = :ESetId AND Order_Owner_WorkLocal__c =: userWorkLocation];
-            for (Integer i = 0; i < reSet.size(); i++) {
-                productList.add(reSet[i].Asset_Model_No__c);
-                orderProductCunMap.put(reSet[i].Asset_Model_No__c,reSet[i].Consumable_count__c);
-                orderProductArrivedCunMap.put(reSet[i].Asset_Model_No__c,0);
-                orderWantArriveCunMap.put(reSet[i].Asset_Model_No__c,0);
-                overOrderCunMap.put(reSet[i].Asset_Model_No__c,0);
-                overOrderBARcodeCunMap.put(reSet[i].Asset_Model_No__c,overOrderBARcodeTTTTTT);
-                //overOrderCunMap.put(reSet[i].Asset_Model_No__c,0);
-            }
-            //
-            reSet1 = [SELECT Id,
-                            Name,
-                            Intra_Trade_List_RMB__c,
-                            Asset_Model_No__c,
-                            Consumable_Product__c,
-                            Consumable_Product__r.Name,
-                            Consumable_Product__r.Name__c,
-                            Sterilization_limit__c,
-                            Deliver_date__c,
-                            Bar_Code__c,
-                            Arrive_date__c,
-                            Send_Date__c,
-                            Consumable_order_minor__r.Name,
-                            Consumable_order_minor__c,
-                            Dealer_Arrive__c,
-                            Guarantee_period_for_products__c,
-                            CFDA_Status__c,
-                            Box_Piece__c,
-                            Rrturn_count__c,
-                            ProductPacking_list_manual__c,
-                            Report_Product_Approbation__c,
-                            Report_Product_Expiration__c
-                            //add by rentx 2020-10-14 start
-                            ,ContractNo_text__c/*,ContractNo__c1*/
-                            // tcm start
-                            ,Consumable_order_minor__r.ContractNo__c
-                            // tcm end
-                            //add by rentx 2020-10-14 end
-                        FROM Consumable_order_details2__c
-                        WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
-                        AND Arrive_Owner_Work_Location__c = : userWorkLocation
-                        AND Consumable_order_minor__c = :ESetId
-                        AND Dealer_Arrive__c = true
-                        AND Box_Piece__c != '涓�' ];
-            for (Integer i = 0; i < reSet1.size(); i++) {
-                // OrderAllMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                //init鐨勬椂鍊欎笉灞曠ず宸茬粡鍏ュ簱鐨勬槑缁� by rentx 20210617 CHAN-C3K4ZQ
-                // ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet1[i]));
-                //update by rentx 20210617 end CHAN-C3K4ZQ
-                if(orderProductArrivedCunMap.containsKey(reSet1[i].Asset_Model_No__c)){
-                   orderProductArrivedCunMap.put(reSet1[i].Asset_Model_No__c,orderProductArrivedCunMap.get(reSet1[i].Asset_Model_No__c)+1);
-                }
-            }
-            //add by rentx 20210602 start CHAN-C3K4ZQ
-            // makeRecordsView(ConsumableorderdetailsRecordsdummy);
-            //add by rentx 20210602 end CHAN-C3K4ZQ
-        }
+        consumableorderdetailsRecordsview.add(
+          ConsumableorderdetailsRecordsbreak
+        );
+        consumableorderdetailsRecordsview.add(
+          ConsumableorderdetailsRecordsbreakover
+        );
+      } else {
+        consumableorderdetailsRecordsview.add(recordsdummy);
+      }
+
+      // Integer count = recordsdummy.size() / 1000;
+      // Integer last = recordsdummy.size() - (1000*count);
+
+      // for(Integer i = 0; i < count ; i++){
+      //     List<ConsumableorderdetailsInfo> tempList = new List<ConsumableorderdetailsInfo>();
+      //     for(Integer j=0; j < 1000; j++){
+      //         tempList.add(recordsdummy.get(i * count + j ));
+      //         // itemList.add(resList.get(i*count+j));
+      //     }
+      //     consumableorderdetailsRecordsview.add(tempList);
+      // }
+      // if (last > 0) {
+      //     List<ConsumableorderdetailsInfo> tempList = new List<ConsumableorderdetailsInfo>();
+      //     for(Integer j=0; j < last; j++){
+      //         tempList.add(recordsdummy.get(count * 1000 + j ));
+      //         // itemList.add(resList.get(i*count+j));
+      //     }
+      //     consumableorderdetailsRecordsview.add(tempList);
+      // }
+    } else {
+      consumableorderdetailsRecordsview.add(recordsdummy);
     }
-    //========20160311======ADD_Start================================
-    // 灏嗛〉闈㈡垨鍙栧緱BarCode鍘绘帀閲嶅鐨勶紝杞崲鎴怢ist
-    //========20160311======ADD_Start================================
-    public List<String> ParseBarCode(String Code){
-        String[] Cache = new String[]{};
-        Cache = Code.split('\n');
-        Set <String> Buff = new Set<String>();
-        for(String A : Cache){
-            Buff.add(A.toUpperCase());
-        }
-        List<String> outPut = new List<String>();
-        for(String B :Buff){
-            B = B.trim();
-            if(B.length() > 8){
-               String tracingCode = B.substring(B.length() - 5,B.length());
-               barMcodeMap.put(B,tracingCode);
-            }
-            outPut.add(B);
-        }system.debug('barMcodeMap绛変簬'+barMcodeMap);
-        return outPut;
+  }
+  //add by rentx 20210602 CHAN-C3K4ZQ end
+  public void init() {
+    // String userId = '00510000007cthP';
+    String userId = UserInfo.getUserId();
+    List<user> Useracc = new List<user>();
+    Useracc = [
+      SELECT accountid, Work_Location__c, UserPro_Type__c
+      FROM user
+      WHERE id = :userId
+    ];
+    accountid = Useracc[0].accountid;
+    //--------AddStart-----XHL--------------20181008-------------
+    userPro_Type = Useracc[0].UserPro_Type__c;
+    if (String.isBlank(userPro_Type)) {
+      userPro_Type = 'ET';
     }
 
+    if (userPro_Type == 'ENG') {
+      product_Type = 'ET';
+      EngFlag = true;
+    } else {
+      product_Type = 'ENG';
+      ETFlag = true;
+    }
+    userPro_Typestr = '%' + userPro_Type + '%';
+    //--------AddEnd-----XHL--------------20181008-------------
+    userWorkLocation = Useracc[0].Work_Location__c;
+    system.debug('userWorkLocation' + userWorkLocation);
+    List<account> accountInfo = [
+      SELECT Name
+      FROM account
+      WHERE id = :accountid
+    ];
+    accountName = accountInfo[0].Name;
+    system.debug('accountName' + accountName);
+    coc = new Consumable_order__c();
+    if (ArrType == 'ReG') {
+      ReturnFLGbln = true;
+    } else {
+      ReturnFLGbln = false;
+    }
+    if (ESetId != '' && ESetId != null) {
+      List<Consumable_order__c> qs = new List<Consumable_order__c>();
+      List<Consumable_order_details2__c> reSet1 = new List<Consumable_order_details2__c>();
+      List<Consumable_Orderdetails__c> reSet = new List<Consumable_Orderdetails__c>();
+      qs = [
+        SELECT
+          Id,
+          Name,
+          Order_status__c,
+          Dealer_Info__c,
+          Deliver_date__c,
+          ReturnGs_Upload_Date__c,
+          Order_Reason__c,
+          Order_date__c,
+          Contract_application_decision__c,
+          Order_type__c,
+          Total_num__c,
+          OrderNumber_arrived__c,
+          Delivery_detail_count__c,
+          OrderNumber_notarrive__c,
+          orderPattern__c
+        FROM Consumable_order__c
+        WHERE
+          Id = :ESetId
+          AND Order_Owner_WorkLocal__c = :userWorkLocation
+          AND Dealer_Info__c = :accountid
+      ];
+      if (qs.size() > 0) {
+        coc = qs[0];
+        orderCountAll = coc.Total_num__c;
+        orderCountNotarrive = coc.OrderNumber_notarrive__c;
+      }
+      //浜у搧瀹氳揣鏁伴噺
+      reSet = [
+        SELECT Asset_Model_No__c, Consumable_order__c, Consumable_count__c
+        FROM Consumable_Orderdetails__c
+        WHERE
+          Consumable_order__c = :ESetId
+          AND Order_Owner_WorkLocal__c = :userWorkLocation
+      ];
+      for (Integer i = 0; i < reSet.size(); i++) {
+        productList.add(reSet[i].Asset_Model_No__c);
+        orderProductCunMap.put(
+          reSet[i].Asset_Model_No__c,
+          reSet[i].Consumable_count__c
+        );
+        orderProductArrivedCunMap.put(reSet[i].Asset_Model_No__c, 0);
+        orderWantArriveCunMap.put(reSet[i].Asset_Model_No__c, 0);
+        overOrderCunMap.put(reSet[i].Asset_Model_No__c, 0);
+        overOrderBARcodeCunMap.put(
+          reSet[i].Asset_Model_No__c,
+          overOrderBARcodeTTTTTT
+        );
+        //overOrderCunMap.put(reSet[i].Asset_Model_No__c,0);
+      }
+      //
+      reSet1 = [
+        SELECT
+          Id,
+          Name,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          Consumable_Product__c,
+          Consumable_Product__r.Name,
+          Consumable_Product__r.Name__c,
+          Sterilization_limit__c,
+          Deliver_date__c,
+          Bar_Code__c,
+          Arrive_date__c,
+          Send_Date__c,
+          Consumable_order_minor__r.Name,
+          Consumable_order_minor__c,
+          Dealer_Arrive__c,
+          Guarantee_period_for_products__c,
+          CFDA_Status__c,
+          Box_Piece__c,
+          Rrturn_count__c,
+          ProductPacking_list_manual__c,
+          Report_Product_Approbation__c,
+          Report_Product_Expiration__c,
+          //add by rentx 2020-10-14 start
+          ContractNo_text__c /*,ContractNo__c1*/,
+          // tcm start
+          Consumable_order_minor__r.ContractNo__c
+        // tcm end
+        //add by rentx 2020-10-14 end
+        FROM Consumable_order_details2__c
+        WHERE
+          recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+          AND Arrive_Owner_Work_Location__c = :userWorkLocation
+          AND Consumable_order_minor__c = :ESetId
+          AND Dealer_Arrive__c = TRUE
+          AND Box_Piece__c != '涓�'
+      ];
+      for (Integer i = 0; i < reSet1.size(); i++) {
+        // OrderAllMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+        //init鐨勬椂鍊欎笉灞曠ず宸茬粡鍏ュ簱鐨勬槑缁� by rentx 20210617 CHAN-C3K4ZQ
+        // ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet1[i]));
+        //update by rentx 20210617 end CHAN-C3K4ZQ
+        if (
+          orderProductArrivedCunMap.containsKey(reSet1[i].Asset_Model_No__c)
+        ) {
+          orderProductArrivedCunMap.put(
+            reSet1[i].Asset_Model_No__c,
+            orderProductArrivedCunMap.get(reSet1[i].Asset_Model_No__c) + 1
+          );
+        }
+      }
+      //add by rentx 20210602 start CHAN-C3K4ZQ
+      // makeRecordsView(ConsumableorderdetailsRecordsdummy);
+      //add by rentx 20210602 end CHAN-C3K4ZQ
+    }
+  }
+  //========20160311======ADD_Start================================
+  // 灏嗛〉闈㈡垨鍙栧緱BarCode鍘绘帀閲嶅鐨勶紝杞崲鎴怢ist
+  //========20160311======ADD_Start================================
+  public List<String> ParseBarCode(String Code) {
+    String[] Cache = new List<String>{};
+    Cache = Code.split('\n');
+    Set<String> Buff = new Set<String>();
+    for (String A : Cache) {
+      Buff.add(A.toUpperCase());
+    }
+    List<String> outPut = new List<String>();
+    for (String B : Buff) {
+      B = B.trim();
+      if (B.length() > 8) {
+        String tracingCode = B.substring(B.length() - 5, B.length());
+        barMcodeMap.put(B, tracingCode);
+      }
+      outPut.add(B);
+    }
+    system.debug('barMcodeMap绛変簬' + barMcodeMap);
+    return outPut;
+  }
 
-    //========20160311======ADD_End==================================
-    //鑾峰彇鏄庣粏
-    public void SearchPro() {
-        notInlist = new list<String>();
-        otherAgencyMap = new Map<String, String>();
-        barMcodeMap = new Map<String, String>();
-        consumableInventory = new List<ConsumableorderdetailsInfo>();
-        consumableInventoryUse = new List<ConsumableorderdetailsInfo>();
-        consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
-        orderdetails2trMap = new Map<String,Consumable_order_details2__c>();
-        //add by rentx 2021-01-27 start
-        HosErrorList = new List<String>();
-        HosErrorMap = new Map<String,String>();
-        //add by rentx 2021-01-27 end
+  //========20160311======ADD_End==================================
+  //鑾峰彇鏄庣粏
+  public void SearchPro() {
+    //浠庝笅杈圭Щ涓婃潵 by Link 2023-5-23
+    if (barcode == null || barcode.trim() == '') {
+      //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+      if (isLwc) {
+        returnError = '璇疯緭鍏arCode鍙�';
+      } else {
+        ApexPages.addmessage(
+          new ApexPages.message(ApexPages.severity.INFO, '璇疯緭鍏arCode鍙枫��')
+        );
+      }
+      return;
+    }
+    notInlist = new List<String>();
+    otherAgencyMap = new Map<String, String>();
+    barMcodeMap = new Map<String, String>();
+    consumableInventory = new List<ConsumableorderdetailsInfo>();
+    consumableInventoryUse = new List<ConsumableorderdetailsInfo>();
+    consumableorderdetails2Cancle = new List<Consumable_order_details2__c>();
+    orderdetails2trMap = new Map<String, Consumable_order_details2__c>();
+    //update by Link 20230428
+    if (isLwc) {
+      noboxBarcodeList = new Set<String>();
+    }
+    //add by rentx 2021-01-27 start
+    HosErrorList = new List<String>();
+    HosErrorMap = new Map<String, String>();
+    //add by rentx 2021-01-27 end
 
-        noboxBarcodeList.clear();
-        //鍐嶆绱㈤」鐩竻绌�
-        ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
-        ErrorIdMap = new Map<String, String>();
-        ErrorIdMap.clear();
-        AllMap = new Map<String, String>();
-        AllMap.clear();
-        ExistIdMap = new Map<String, String>();
-        ExistIdMap.clear();
-        consumableorderdetails2Insert = new List<Consumable_order_details2__c>();
-        ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
-        /*if(EsetId != null && EsetId != ''){
+    noboxBarcodeList.clear();
+    //鍐嶆绱㈤」鐩竻绌�
+    ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
+    ErrorIdMap = new Map<String, String>();
+    ErrorIdMap.clear();
+    AllMap = new Map<String, String>();
+    AllMap.clear();
+    ExistIdMap = new Map<String, String>();
+    ExistIdMap.clear();
+    consumableorderdetails2Insert = new List<Consumable_order_details2__c>();
+    ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
+    /*if(EsetId != null && EsetId != ''){
             List<Consumable_order_details2__c> reSet1 = [SELECT Id,
                             Name,
                             Intra_Trade_List_RMB__c,
@@ -374,2199 +478,4129 @@
                 //}
             }
         }*/
-        ConsumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
-        BarCodeListP = new List<String>();
-        BarCodeListP = ParseBarCode(barcode);
-        Consumable_order_details2__c p = new Consumable_order_details2__c();
-        List<Consumable_order_details2__c> Ins = New List<Consumable_order_details2__c>();
-        List<Consumable_order_details2__c> reSet = new List<Consumable_order_details2__c>();
-        List<Consumable_order_details2__c> reSet1 = new List<Consumable_order_details2__c>();
-        if(barcode == null || barcode.trim() ==''){
-            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'璇疯緭鍏arCode鍙枫��'));
-            return;
+    ConsumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+    BarCodeListP = new List<String>();
+    BarCodeListP = ParseBarCode(barcode);
+    Consumable_order_details2__c p = new Consumable_order_details2__c();
+    List<Consumable_order_details2__c> Ins = new List<Consumable_order_details2__c>();
+    List<Consumable_order_details2__c> reSet = new List<Consumable_order_details2__c>();
+    List<Consumable_order_details2__c> reSet1 = new List<Consumable_order_details2__c>();
+    //绉诲埌鏈�涓婅竟 by Link 2023-5-23
+    // if(barcode == null || barcode.trim() ==''){
+    //     //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+    //     if(isLwc){
+    //         returnError = '璇疯緭鍏arCode鍙�';
+    //     }else {
+    //         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'璇疯緭鍏arCode鍙枫��'));
+    //     }
+    //     return;
+    // }
+    //瀵规瘮鍏ㄩ儴搴撳瓨涓槸鍚﹀瓨鍦ㄧ鐞嗙紪鐮佷竴鏍凤紝barcode鍙蜂笉涓�鏍风殑浜у搧
+    reSet1 = [
+      SELECT Id, Name, TracingCode__c, Bar_Code__c, Report_Product_Expiration__c
+      FROM Consumable_order_details2__c
+      WHERE
+        Dealer_Arrive__c = TRUE
+        AND Dealer_Shipment__c = FALSE
+        AND Dealer_Saled__c = FALSE
+        AND Lose_Flag__c = FALSE
+        AND Dealer_Returned__c = FALSE
+        AND Cancellation_Flag__c = FALSE
+        AND TracingCode__c IN :barMcodeMap.values()
+        AND Bar_Code__c NOT IN :barMcodeMap.keySet()
+        AND Dealer_Info_text__c = :accountName
+        AND Arrive_Owner_Work_Location__c = :userWorkLocation
+      ORDER BY Name
+    ];
+    if (reSet1.size() > 0) {
+      for (Integer i = 0; i < reSet1.size(); i++) {
+        if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+          // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+          continue;
+        } else {
+          for (String str : barMcodeMap.keySet()) {
+            if (barMcodeMap.get(str) == reSet1[i].TracingCode__c) {
+              //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+              if (isLwc) {
+                errorList.add(
+                  str +
+                  ' 鐨勭鐞嗙紪鐮佸凡缁忓瓨鍦ㄤ簬绯荤粺鐨勫簱瀛樹腑锛岃纭杈撳叆淇℃伅鏄惁鏈夎銆�'
+                );
+              } else {
+                ApexPages.addmessage(
+                  new ApexPages.message(
+                    ApexPages.severity.ERROR,
+                    str +
+                    ' 鐨勭鐞嗙紪鐮佸凡缁忓瓨鍦ㄤ簬绯荤粺鐨勫簱瀛樹腑锛岃纭杈撳叆淇℃伅鏄惁鏈夎銆�'
+                  )
+                );
+              }
+              ErrorIdMap.put(str, str);
+              ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+            }
+          }
         }
-        //瀵规瘮鍏ㄩ儴搴撳瓨涓槸鍚﹀瓨鍦ㄧ鐞嗙紪鐮佷竴鏍凤紝barcode鍙蜂笉涓�鏍风殑浜у搧
-        reSet1 = [SELECT Id,  Name,TracingCode__c,Bar_Code__c,Report_Product_Expiration__c 
-                    FROM Consumable_order_details2__c
-                    WHERE Dealer_Arrive__c = true
-                    AND Dealer_Shipment__c = false
-                    AND Dealer_Saled__c = false
-                    AND Lose_Flag__c = false
-                    AND Dealer_Returned__c = false
-                    AND Cancellation_Flag__c = false
-                    AND TracingCode__c in :barMcodeMap.values()
-                    AND Bar_Code__c not in :barMcodeMap.keySet()
-                    AND Dealer_Info_text__c = :accountName
-                    AND Arrive_Owner_Work_Location__c =: userWorkLocation
-                    ORDER BY Name ];
-        if(reSet1.size()>0){
-            for (Integer i = 0; i < reSet1.size(); i++) {
-                if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                    // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                    continue;
-                }else{
-                    for(String str : barMcodeMap.keySet()){
-                        if(barMcodeMap.get(str) == reSet1[i].TracingCode__c){
-                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, str + ' 鐨勭鐞嗙紪鐮佸凡缁忓瓨鍦ㄤ簬绯荤粺鐨勫簱瀛樹腑锛岃纭杈撳叆淇℃伅鏄惁鏈夎銆�'));
-                            ErrorIdMap.put(str,str);
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-            }
-        }
-        //绠$悊缂栫爜涓虹┖鐨勪骇鍝�
-        reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
-                        Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
-                        Deliver_date__c,Bar_Code__c,Box_Piece__c,
-                        Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                        TracingCode__c,Report_Product_Expiration__c 
-                    FROM Consumable_order_details2__c
-                    WHERE Bar_Code__c in :BarCodeListP
-                    AND Dealer_Info_text__c = :accountName
-                    //AND Arrive_Owner_Work_Location__c =: userWorkLocation
-                    AND (TracingCode__c = null
-                         OR TracingCode__c = '')
-                    ORDER BY Name ];
-
-        if(reSet1.size()>0){
-            for (Integer i = 0; i < reSet1.size(); i++) {
-                if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                    // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                    continue;
-                }else{
-                    String str = '璇ヤ骇鍝佹病鏈夌鐞嗙紪鐮侊紝鏃犳硶鍏ュ簱';
-                    ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                    ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                }
-            }
-        }
-        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '绠$悊缂栫爜涓虹┖鐨勪骇鍝� ' + ErrorIdMap));
-        //鏁翠綋鍒拌揣
-        if(EsetId == null || EsetId == ''){
-            if(ArrType!='ReG'){
-                //鍒拌揣浣嗕骇鍝佺被鍨嬩笌鐢ㄦ埛鐨勭被鍨嬩笉绗�            
-                reSet1 = [SELECT Id,Name,Intra_Trade_List_RMB__c,Asset_Model_No__c,
-                                Consumable_Product__c,Consumable_Product__r.Name,
-                                Consumable_Product__r.Name__c,Consumable_Product__r.Asset_Model_No__c,
-                                Sterilization_limit__c,Deliver_date__c,Bar_Code__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,
-                                Consumable_order_minor__c,Dealer_Arrive__c,
-                                Guarantee_period_for_products__c,CFDA_Status__c,
-                                ProductPacking_list_manual__c,Report_Product_Approbation__c,
-                                Report_Product_Expiration__c,Box_Piece__c, Rrturn_count__c,
-                                Product_Type__c
-                                ,ContractNo_text__c/*,ContractNo__c1*/
-                                // tcm start
-                                ,Consumable_order_minor__r.ContractNo__c
-                                // tcm end
-                        FROM Consumable_order_details2__c
-                        WHERE Bar_Code__c in :BarCodeListP
-                        AND ( not Product_Type__c  like :userPro_Typestr)
-                        AND Dealer_Info_text__c = :accountName
-                        AND ((Consumable_order_minor__c != null 
-                                AND  Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation) 
-                            OR Consumable_order_minor__c = null)
-                        ORDER BY Name ];
-
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '浜у搧绫诲瀷['+reSet1[i].Product_Type__c+']涓庣敤鎴风殑绫诲瀷['+userPro_Type+']涓嶇';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-                //閿�鍞骇鍝�
-                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
-                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
-                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,OwnerId,Report_Product_Expiration__c 
-                            FROM Consumable_order_details2__c
-                            WHERE Dealer_Saled__c = true
-                            AND  Dealer_Returned__c = false
-                            AND  Bar_Code__c in :BarCodeListP
-                            AND Dealer_Info_text__c = :accountName
-                            AND (Arrive_Owner_Work_Location__c =: userWorkLocation
-                                OR OwnerId = :System.Label.User_OlympusSystem)
-                            ORDER BY Name ];
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '';
-                            if (reSet1[i].OwnerId == System.Label.User_OlympusSystem) {
-                                str = '璇ュ晢鍝佹槸鐩撮攢浜у搧璇峰厛杩斿搧';
-                            }else{
-                                str = '璇ュ晢鍝佸凡缁忛攢鍞�';
-                            }
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                            
-                        }
-                    }
-                }
-                //鍑哄簱浜у搧
-               reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
-                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
-                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c
-                            FROM Consumable_order_details2__c
-                            WHERE Dealer_Shipment__c = true
-                            AND  Dealer_Returned__c = false
-                            AND  Bar_Code__c in :BarCodeListP
-                            AND Dealer_Info_text__c = :accountName
-                            AND Arrive_Owner_Work_Location__c =: userWorkLocation
-                            ORDER BY Name ];
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '璇ュ晢鍝佸凡缁忓嚭搴�';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-                //宸插埌璐т骇鍝�
-                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
-                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
-                                Deliver_date__c,Bar_Code__c,Lose_Flag__c,Box_Piece__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c 
-                            FROM Consumable_order_details2__c
-                            WHERE Dealer_Arrive__c = true
-                            AND  Dealer_Returned__c = false
-                            AND  Bar_Code__c in :BarCodeListP
-                            AND Dealer_Info_text__c = :accountName
-                            AND Arrive_Owner_Work_Location__c =: userWorkLocation
-                            ORDER BY Name ];
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '璇ュ晢鍝佸凡缁忓埌璐�';
-                            if (reSet1[i].Lose_Flag__c == TRUE) {
-                                str = '璇ュ晢鍝佸凡缁忎涪澶�';
-                            }
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-
-                //宸叉媶鐩掍骇鍝�
-                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
-                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
-                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c 
-                            FROM Consumable_order_details2__c
-                            WHERE Dealer_Arrive__c = true
-                            AND  Bar_Code__c in :BarCodeListP
-                            AND (Dealer_Info_text__c != :accountName
-                                OR (Dealer_Info_text__c = :accountName
-                                    AND Arrive_Owner_Work_Location__c !=: userWorkLocation))
-                            AND Box_Piece__c = '涓�'
-                            ORDER BY Name ];
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '宸叉媶鐩掔殑浜у搧涓嶈兘鍏ュ簱';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-
-                // 缁忛攢鍟嗕箣闂存垨鑰呭悓涓�缁忛攢鍟嗕笉鍚屽伐浣滃湴璋冭揣
-                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,Asset_Model_No__c, Arrive_Owner_Work_Location__c,
-                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,Box_Piece__c,
-                                Deliver_date__c,Bar_Code__c,TracingCode__c, Dealer_Info_text__c, OwnerId, Lose_Flag__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,SerialLotNo__c, Dealer_Arrive__c,
-                                Consumable_Arrived_order__r.Dealer_Info__c, Consumable_Arrived_order__r.Dealer_Info__r.Name,
-                                Intra_Trade_List_RMB__c, Dealer_Shipment__c, Dealer_Saled__c,Consumable_Product__r.Asset_Model_No__c
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                                ,SummonsForDirction_det__c,Transfer_Time__c,Frist_Transfer_Agency__c,Agency_Transfer__c
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                                // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 start
-                                ,Agencyinfo_fromSAP__c,Frist_Storage_Agency__c 
-                                // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 end
-
-                                //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
-                                ,ContractNo_text__c/*,ContractNo__c */
-                                // tcm start
-                                ,Consumable_order_minor__r.ContractNo__c
-                                // tcm end
-                                //add by rentx 2020-10-13 end
-                                //add by rentx 2021-03-22 start
-                                ,hospitalSpecialOffer__c
-                                ,exchangeOutPattern__c 
-                                ,Report_Product_Expiration__c
-                                //add by rentx 2021-03-22 end
-                            FROM Consumable_order_details2__c
-                            WHERE Dealer_Arrive__c = TRUE
-                            //AND  Dealer_Shipment__c= false
-                            //AND  Dealer_Saled__c = FALSE
-                            AND  Dealer_Returned__c = FALSE
-                            AND  Cancellation_Flag__c = FALSE
-                            AND  Bar_Code__c in :BarCodeListP
-                            //AND (Dealer_Shipment__c = FALSE 
-                            //        OR (Dealer_Shipment__c = TRUE 
-                            //            AND Consumable_Shipment_order__r.SummonsForDirction__c != '浜掔浉璋冭揣'))
-                            AND (Dealer_Info_text__c != :accountName 
-                                OR (Dealer_Info_text__c = :accountName 
-                                    AND Arrive_Owner_Work_Location__c != :userWorkLocation)
-                            )
-                            // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                            order by Bar_Code__c, Transfer_Time__c desc
-                            // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                            ];
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            if(otherAgencyMap.containsKey(reSet1[i].Bar_Code__c)){
-                                continue;
-                            }else{
-                                //鍏朵粬缁忛攢鍟嗗嚭搴撲骇鍝佸彲浠ュ叆搴�
-                                List<String> barcodedetList = new List<String>();
-                                barcodedetList.add(reSet1[i].Bar_Code__c);
-                                barcodedetList.add(String.valueOf(reSet1[i].Sterilization_limit__c));
-                                barcodedetList.add(reSet1[i].SerialLotNo__c);
-                                barcodedetList.add(reSet1[i].TracingCode__c);
-                                if (reSet1[i].Lose_Flag__c == false 
-                                    //&& reSet1[i].Dealer_Info_text__c == accountName
-                                     ) {
-                                    consumableorderdetails2Cancle.add(reSet1[i]);
-                                }
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                                if (reSet1[i].SummonsForDirction_det__c == '浜掔浉璋冭揣' && !orderdetails2trMap.containsKey(reSet1[i].Bar_Code__c)) {
-                                    orderdetails2trMap.put(reSet1[i].Bar_Code__c, reSet1[i]);
-                                }
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                                consumableInventory.add(new ConsumableorderdetailsInfo(reSet1[i],barcodedetList));
-                                Consumable_order_details2__c codsIns = new Consumable_order_details2__c();
-
-                                codsIns.RecordTypeId                = System.Label.RT_ConOrderDetail2_Delivery;
-                                codsIns.Intra_Trade_List_RMB__c     = reSet1[i].Intra_Trade_List_RMB__c;
-                                //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
-                                codsIns.Asset_Model_No__c           = reSet1[i].Asset_Model_No__c;
-                                codsIns.Direct_Arrive_Product__c    = true;
-                                codsIns.Sterilization_limit__c      = reSet1[i].Sterilization_limit__c;
-                                codsIns.Consumable_Product__c       = reSet1[i].Consumable_Product__c;
-                                codsIns.Bar_Code__c                 = reSet1[i].Bar_Code__c;
-                                codsIns.SerialLotNo__c              = reSet1[i].SerialLotNo__c;
-                                codsIns.TracingCode__c              = reSet1[i].TracingCode__c;
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                                codsIns.Transfer_Time__c            = reSet1[i].Transfer_Time__c == null? 1 : reSet1[i].Transfer_Time__c;
-                                codsIns.Frist_Transfer_Agency__c    = reSet1[i].Frist_Transfer_Agency__c == null ? reSet1[i].Dealer_Info_text__c : reSet1[i].Frist_Transfer_Agency__c;
-                                codsIns.Agency_Transfer__c          = true;
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                                 
-                                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
-                                codsIns.Agencyinfo_fromSAP__c       = reSet1[i].Agencyinfo_fromSAP__c;
-                                codsIns.Frist_Storage_Agency__c     = reSet1[i].Frist_Storage_Agency__c;
-                                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
-
-                                //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,璁板綍SAP鍚堝悓鍙�
-                                // update tcm start
-                                if (String.isBlank(reSet1[i].Consumable_order_minor__r.ContractNo__c)) {
-                                    codsIns.ContractNo_text__c= reSet1[i].ContractNo_text__c;
-                                }else {
-                                    codsIns.ContractNo_text__c= reSet1[i].Consumable_order_minor__r.ContractNo__c;
-                                }
-                                // update tcm end
-                                //add by rentx 2020-10-13 end
-
-                                //add by rentx 2021-03-22 start
-                                // if (reSet1[i].Lose_Flag__c == true){
-                                if (reSet1[i].hospitalSpecialOffer__c == true && reSet1[i].SummonsForDirction_det__c == '浜掔浉璋冭揣'){
-                                    codsIns.exchangeOutPattern__c = true;
-                                }
-                                //add by rentx 2021-03-22 end
-
-                                consumableorderdetails2Insert.add(codsIns);
-                                otherAgencyMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                                //String str = '璇ュ晢鍝佸湪鍏朵粬缁忛攢鍟嗗簱瀛�';
-                                //ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                                //ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                            }
-                        }
-                    }
-                }
-
-                 //鍙戦敊搴� 鏈埌璐�
-                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,Asset_Model_No__c,
-                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
-                                Deliver_date__c,Bar_Code__c,TracingCode__c,Box_Piece__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,SerialLotNo__c,Dealer_Arrive__c,
-                                Dealer_Shipment__c, Dealer_Saled__c,Consumable_Product__r.Asset_Model_No__c
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                                ,SummonsForDirction_det__c,Transfer_Time__c,Frist_Transfer_Agency__c,Agency_Transfer__c,
-                                Dealer_Info_text__c,Intra_Trade_List_RMB__c
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                                // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 start
-                                ,Agencyinfo_fromSAP__c,Frist_Storage_Agency__c 
-                                // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 end
-                                //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
-                                ,ContractNo_text__c/*,ContractNo__c*/ 
-                                // tcm start
-                                ,Consumable_order_minor__r.ContractNo__c
-                                // tcm end
-                                //add by rentx 2020-10-13 end   浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
-                                ,hospitalSpecialOffer__c
-                                ,exchangeOutPattern__c
-                                ,Lose_Flag__c,Report_Product_Expiration__c 
-                            FROM Consumable_order_details2__c
-                            WHERE Dealer_Arrive__c = FALSE
-                            AND  Dealer_Shipment__c= FALSE
-                            AND  Dealer_Saled__c = FALSE
-                            //AND  Cancellation_Flag__c = FALSE
-                            AND  Bar_Code__c in :BarCodeListP
-                            AND  (Dealer_Info_text__c != :accountName
-                                OR (Dealer_Info_text__c = :accountName 
-                                    AND ((Consumable_order_minor__c != null
-                                            AND (Consumable_order_minor__r.Order_Owner_WorkLocal__c != :userWorkLocation
-                                                OR (Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation
-                                                    AND Cancellation_Flag__c = TRUE)))
-                                        OR (Consumable_order_minor__c = null AND Cancellation_Flag__c = TRUE)))
-                            )
-                            // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                            order by Bar_Code__c, Transfer_Time__c desc
-                            // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                            ];
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            if(otherAgencyMap.containsKey(reSet1[i].Bar_Code__c)){
-                                continue;
-                            }else{
-                                //鍙栨秷鏄庣粏
-                                List<String> barcodedetList = new List<String>();
-                                barcodedetList.add(reSet1[i].Bar_Code__c);
-                                barcodedetList.add(String.valueOf(reSet1[i].Sterilization_limit__c));
-                                barcodedetList.add(reSet1[i].SerialLotNo__c);
-                                barcodedetList.add(reSet1[i].TracingCode__c);
-                                // 鍙戦敊搴撳瓨鏃讹紝鑷姩鍙栨秷 update by gzw 2020-04-15 start
-                                //if (reSet1[i].Consumable_order_minor__c == null) {
-                                    consumableorderdetails2Cancle.add(reSet1[i]);
-                                //}
-                                // 鍙戦敊搴撳瓨鏃讹紝鑷姩鍙栨秷 update by gzw 2020-04-15 start
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                                if (reSet1[i].SummonsForDirction_det__c == '浜掔浉璋冭揣' && !orderdetails2trMap.containsKey(reSet1[i].Bar_Code__c)) {
-
-                                    orderdetails2trMap.put(reSet1[i].Bar_Code__c, reSet1[i]);
-                                }
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                                consumableInventory.add(new ConsumableorderdetailsInfo(reSet1[i],barcodedetList));
-                                Consumable_order_details2__c codsIns = new Consumable_order_details2__c();
-
-                                codsIns.RecordTypeId                = System.Label.RT_ConOrderDetail2_Delivery;
-                                codsIns.Intra_Trade_List_RMB__c     = reSet1[i].Intra_Trade_List_RMB__c;
-                                //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
-                                codsIns.Asset_Model_No__c           = reSet1[i].Asset_Model_No__c;
-                                codsIns.Direct_Arrive_Product__c    = true;
-                                codsIns.Sterilization_limit__c      = reSet1[i].Sterilization_limit__c;
-                                codsIns.Consumable_Product__c       = reSet1[i].Consumable_Product__c;
-                                codsIns.Bar_Code__c                 = reSet1[i].Bar_Code__c;
-                                codsIns.SerialLotNo__c              = reSet1[i].SerialLotNo__c;
-                                codsIns.TracingCode__c              = reSet1[i].TracingCode__c;
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                                // 娌℃湁鍏ュ簱鏃讹紝娌℃湁鍊熻皟淇℃伅
-                                codsIns.Transfer_Time__c            = reSet1[i].Transfer_Time__c;
-                                codsIns.Frist_Transfer_Agency__c    = reSet1[i].Frist_Transfer_Agency__c;
-                                codsIns.Agency_Transfer__c          = reSet1[i].Agency_Transfer__c;
-                                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                                
-                                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
-                                codsIns.Agencyinfo_fromSAP__c       = reSet1[i].Agencyinfo_fromSAP__c;
-                                codsIns.Frist_Storage_Agency__c     = reSet1[i].Frist_Storage_Agency__c;
-                                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
-
-                                //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
-                                // update tcm start
-                                if (String.isBlank(reSet1[i].Consumable_order_minor__r.ContractNo__c)) {
-                                    codsIns.ContractNo_text__c= reSet1[i].ContractNo_text__c;
-                                }else {
-                                    codsIns.ContractNo_text__c= reSet1[i].Consumable_order_minor__r.ContractNo__c;
-                                }
-                                // update tcm end
-                                //add by rentx 2020-10-13 end   浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
-
-                                //add by rentx 2021-03-22 start
-                                // if (reSet1[i].Lose_Flag__c == true){
-                                if (reSet1[i].hospitalSpecialOffer__c == true && reSet1[i].SummonsForDirction_det__c == '浜掔浉璋冭揣'){
-                                    codsIns.exchangeOutPattern__c = true;
-                                }
-                                //add by rentx 2021-03-22 end
-
-                                consumableorderdetails2Insert.add(codsIns);
-                                otherAgencyMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                            }
-                        }
-                    }
-                }
-            }else{
-                //杩斿搧妫�鏌�
-                //鍒拌揣浣嗕骇鍝佺被鍨嬩笌鐢ㄦ埛鐨勭被鍨嬩笉绗�            
-                reSet1 = [SELECT Id,Name,Intra_Trade_List_RMB__c,Asset_Model_No__c,
-                                Consumable_Product__c,Consumable_Product__r.Name,
-                                Consumable_Product__r.Name__c,Consumable_Product__r.Asset_Model_No__c,
-                                Sterilization_limit__c,Deliver_date__c,Bar_Code__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,
-                                Consumable_order_minor__c,Dealer_Arrive__c,
-                                Guarantee_period_for_products__c,CFDA_Status__c,
-                                ProductPacking_list_manual__c,Report_Product_Approbation__c,
-                                Report_Product_Expiration__c,Box_Piece__c, Rrturn_count__c,
-                                Product_Type__c
-                                //add by rentx 2020-10-14 start
-                                ,ContractNo_text__c/*,ContractNo__c*/
-                                // tcm start
-                            ,Consumable_order_minor__r.ContractNo__c
-                            // tcm end
-                                //add by rentx 2020-10-14 end
-                        FROM Consumable_order_details2__c
-                        WHERE Bar_Code__c in :BarCodeListP
-                        AND ( not Product_Type__c  like :userPro_Typestr)
-                        AND Dealer_Info_text__c = :accountName
-                        AND ((Consumable_order_minor__c != null 
-                                AND  Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation) 
-                            OR Consumable_order_minor__c = null)
-                        ORDER BY Name ];
-
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '浜у搧绫诲瀷['+reSet1[i].Product_Type__c+']涓庣敤鎴风殑绫诲瀷['+userPro_Type+']涓嶇';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
-                            Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
-                            Deliver_date__c,Bar_Code__c,Box_Piece__c,
-                            Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                            recordtypeid,Consumable_order_minor__r.Arrive_Order__c
-                            //add by rentx 2020-10-14 start
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                            // tcm start
-                            ,Consumable_order_minor__r.ContractNo__c
-                            // tcm end
-                            ,Report_Product_Expiration__c 
-                            //add by rentx 2020-10-14 end
-                        FROM Consumable_order_details2__c
-                        WHERE Dealer_Arrive__c = FALSE 
-                        AND  Dealer_Shipment__c= FALSE
-                        AND  Dealer_Saled__c = FALSE
-                        // gzw fix 鍙栨秷浜у搧鍒ゆ柇涓烘湭鍏ュ簱 20230323
-                        AND Cancellation_Flag__c = false
-                        AND  Dealer_Returned__c = false
-                        AND  Bar_Code__c in :BarCodeListP
-                        AND Dealer_Info_text__c = :accountName
-                        ORDER BY Name ];//娌″埌璐�
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '璇ュ晢鍝佸皻鏈叆搴�';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,ToDueDateDays__c,
-                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
-                                Deliver_date__c,Bar_Code__c,Lose_Flag__c,Box_Piece__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c
-                                //add by rentx 2020-10-14 start
-                                ,ContractNo_text__c/*,ContractNo__c*/
-                                // tcm start
-                                ,Consumable_order_minor__r.ContractNo__c
-                                // tcm end
-                                , Report_Product_Expiration__c
-                                //add by rentx 2020-10-14 end
-                            FROM Consumable_order_details2__c
-                            WHERE Dealer_Arrive__c = true
-                            AND  Dealer_Shipment__c= FALSE
-                            AND  Dealer_Saled__c = FALSE
-                            AND  Bar_Code__c in :BarCodeListP
-                            AND  Dealer_Returned__c = false
-                            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                            //AND  Lose_Flag__c = FALSE
-                            // AND  Lose_Flag__c = FALSE
-                            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                            AND Dealer_Info_text__c = :accountName
-                            AND Arrive_Owner_Work_Location__c =: userWorkLocation
-                            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                            // Gzw 20201215淇锛屾媶鐩掍骇鍝佷笉鍒ゆ柇
-                            AND Box_Piece__c = '鐩�'
-                            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                            ORDER BY Name ];//娌″嚭搴擄紝娌¢攢鍞紝灏辨槸鍦ㄥ簱
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            
-                            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                            // String str = '璇ュ晢鍝佸湪搴�';
-                            // if (reSet1[i].Lose_Flag__c) {
-                            //     str = '璇ュ晢鍝佷涪澶�';
-                            // }
-                            String str = '';
-                            if(reSet1[i].Lose_Flag__c == false){
-                                str = '璇ュ晢鍝佸湪搴�';//娌″嚭搴� 锛屾病閿�鍞紝娌′涪澶卞氨鏄湪搴撱��
-                            }
-                            if(reSet1[i].Lose_Flag__c == true && reSet1[i].ToDueDateDays__c >= 0){
-                                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, '浜у搧'+reSet1[i].Consumable_Product__r.Name+'瀛樺湪涓㈠け璁板綍'));//濡傛灉涓㈠け浜у搧灏辩粰鎻愮ず銆�
-                            }
-                            if (reSet1[i].Lose_Flag__c == true && reSet1[i].ToDueDateDays__c < 0) {
-                                str = '杩囨湡宸查攢瀛樹骇鍝侊紝涓嶅厑璁歌繑鍝�';
-                            }
-                            if(str != ''){
-                                ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                                ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                            }
-                            // ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            // ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                        }
-                    }
-                }
-            }
-
-            
-            
-            
-            //鍒拌揣姝g‘淇℃伅
-            reSet = [SELECT Id,
-                            Name,
-                            Intra_Trade_List_RMB__c,
-                            Asset_Model_No__c,
-                            Consumable_Product__c,
-                            Consumable_Product__r.Name,
-                            Consumable_Product__r.Name__c,
-                            Consumable_Product__r.Asset_Model_No__c,
-                            Sterilization_limit__c,
-                            Deliver_date__c,
-                            Bar_Code__c,
-                            Arrive_date__c,
-                            Send_Date__c,
-                            Box_Piece__c,
-                            Rrturn_count__c,
-                            Consumable_order_minor__r.Name,
-                            Consumable_order_minor__c,
-                            Dealer_Arrive__c,
-                            Guarantee_period_for_products__c,
-                            CFDA_Status__c,
-                            ProductPacking_list_manual__c,
-                            Report_Product_Approbation__c,
-                            Report_Product_Expiration__c,
-                            Consumable_Product__r.Pro2_Dealer_ENG__c,
-                            Consumable_Product__r.Pro2_Dealer_Object__c,
-                            TracingCode__c,
-                            Agencyinfo_fromSAP__c,
-                            Frist_Storage_Agency__c,
-                            Dealer_Info_text__c
-                            //add by rentx 2020-10-14 start
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                            // tcm start
-                            ,Consumable_order_minor__r.ContractNo__c
-                            // tcm end
-                            //add by rentx 2020-10-14 end
-                        FROM Consumable_order_details2__c
-                        WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
-                        AND Cancellation_Date__c = null
-                        AND Dealer_Arrive__c = false
-                        AND Product_Type__c like :userPro_Typestr
-                        AND Bar_Code__c in :BarCodeListP
-                        AND Dealer_Info_text__c = :accountName
-                        AND ((Consumable_order_minor__c != null 
-                                AND  Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation) 
-                            OR Consumable_order_minor__c = null)
-                        ORDER BY Name ];
-
-            if(reSet.size()>0){
-                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'ErrorIdMap+++ '+ ErrorIdMap.keyset()));
-                Map<String,String> errorMap = new Map<String,String>();
-                for (Integer i = 0; i < reSet.size(); i++) {
-
-                    if(ExistIdMap.containsKey(reSet[i].Bar_Code__c) || ErrorIdMap.containsKey(reSet[i].Bar_Code__c)){
-                        // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                        continue;
-                    }else{
-                        Matcher n = Pattern.compile('[0-9]').matcher(reSet[i].TracingCode__c);
-                        if(n.find()){
-                            // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
-                            if (reSet[i].TracingCode__c.length() == 5) {
-                                String tr = reSet[i].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()) {
-                                    String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
-                                    ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
-                                    ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                                    continue;
-                                }
-                            }
-                            // String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
-                            // ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
-                            // ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                            // continue;
-                            // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
-                        }
-                        if(otherAgencyMap.containsKey(reSet[i].Bar_Code__c)){
-                            for (Integer j=0; j<consumableInventory.size(); j++) {
-                                ConsumableorderdetailsInfo codInfo = consumableInventory.get(j);
-                                if (codInfo.barCodeNo == reSet[i].Bar_Code__c) {
-                                    consumableInventory.remove(j);
-                                    break;
-                                }
-                            }
-                            for (Integer m=0; m<consumableorderdetails2Insert.size(); m++) {
-                                Consumable_order_details2__c cod2 = consumableorderdetails2Insert.get(m);
-                                if (cod2.Bar_Code__c == reSet[i].Bar_Code__c) {
-                                    consumableorderdetails2Insert.remove(m);
-                                    break;
-                                }
-                            }
-                        }
-                        //orderId.add(reSet[i].Consumable_order_minor__c);
-                        //prodName.add(reSet[i].Consumable_Product__r.Name);
-                        ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet[i]));
-                        ConsumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(reSet[i]));
-                        ExistIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                    }
-                }
-            }
-            //barcode涓嶄竴鑷达紝绠$悊缂栫爜涓�鑷�
-            reSet = [SELECT Id,
-                            Name,
-                            Intra_Trade_List_RMB__c,
-                            Asset_Model_No__c,
-                            Consumable_Product__c,
-                            Consumable_Product__r.Name,
-                            Consumable_Product__r.Name__c,
-                            Consumable_Product__r.Asset_Model_No__c,
-                            Sterilization_limit__c,
-                            Deliver_date__c,
-                            Bar_Code__c,
-                            Arrive_date__c,
-                            Send_Date__c,
-                            Consumable_order_minor__r.Name,
-                            Consumable_order_minor__c,
-                            Dealer_Arrive__c,
-                            Guarantee_period_for_products__c,
-                            CFDA_Status__c,
-                            ProductPacking_list_manual__c,
-                            Report_Product_Approbation__c,
-                            Report_Product_Expiration__c,
-                            Box_Piece__c,
-                            Rrturn_count__c,
-                            TracingCode__c
-                            ,Agencyinfo_fromSAP__c
-                            ,Frist_Storage_Agency__c
-                            //add by rentx 2020-10-14 start
-                            ,ContractNo_text__c/*,ContractNo__c */
-                            // tcm start
-                            ,Consumable_order_minor__r.ContractNo__c
-                            // tcm end
-                            //add by rentx 2020-10-14 end
-                        FROM Consumable_order_details2__c
-                       WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
-                        AND Dealer_Info_text__c = :accountName
-                        //update by rentx 2021-01-04 start CHAN-BWX3XW
-                        // AND Consumable_order_minor__c != null
-                        // AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation
-                        AND ((Consumable_order_minor__c != null AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation) OR Consumable_order_minor__c = null)
-                        //update by rentx 2021-01-04 end CHAN-BWX3XW
-                        AND Dealer_Arrive__c = false
-                        AND Cancellation_Date__c = null
-                        AND TracingCode__c in :barMcodeMap.values()
-                        AND Bar_Code__c not in :barMcodeMap.keySet()
-                        ORDER BY Name ];
-
-            if(reSet.size()>0){
-                for (Integer i = 0; i < reSet.size(); i++) {
-                    if(ExistIdMap.containsKey(reSet[i].Bar_Code__c) || ErrorIdMap.containsKey(reSet[i].Bar_Code__c)){
-                        // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                        continue;
-                    }else{
-                        Matcher n = Pattern.compile('[0-9]').matcher(reSet[i].TracingCode__c);
-                        if(n.find()){// gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
-                            if (reSet[i].TracingCode__c.length() == 5) {
-                                String tr = reSet[i].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()) {
-                                    String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
-                                    ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
-                                    ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                                    continue;
-                                }
-                            }
-                            // String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
-                            // ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
-                            // ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                            // continue;
-                            // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
-                        }
-                        ExistIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                        for(String str : barMcodeMap.keySet()){
-                            // BarCode涓嶄竴鑷存椂鐨勮鍛婁俊鎭�
-                            if(reSet[i].Bar_Code__c != str && reSet[i].TracingCode__c == barMcodeMap.get(str)){
-                                // 20220815 ljh SWAG-CH65B7 start
-                                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'姝ょ鐞嗙紪鐮佷笌瀹為檯鍙戣揣BarCode涓嶄竴鑷达紝璇锋牳瀵圭鐞嗙紪鐮�('+ str +')鐨勫叆搴撳強搴撳瓨鏁版嵁銆�'));
-                                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'鏉″舰鐮佷负('+ str +')鐨勫叆搴撴暟鎹笌鍙戣揣鏁版嵁涓嶄竴鑷�'));
-                                // 20220815 ljh SWAG-CH65B7 end
-                            }
-                            if(barMcodeMap.get(str) == reSet[i].TracingCode__c){
-                                reSet[i].Bar_Code__c = str;
-                                //=====================================
-                                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'鍏ュ簱BarCode('+ str +')鍜屽簱瀛樻潯鐮佷笉涓�鑷淬��'));
-                                ExistIdMap.put(str,str);
-                            }
-                        }
-                        ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet[i]));
-                        ConsumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(reSet[i]));
-                    }
-                }
-            }
-
-
-            // CHAN-BD43NK 鍏抽棴鐩存帴杩斿搧鍔熻兘  杩藉姞 barcode涓嶄竴鑷村垽鏂�
-            reSet1 = [SELECT Id,Name,TracingCode__c,Bar_Code__c,Sale_orderName__c,Report_Product_Expiration__c 
-                        FROM Consumable_order_details2__c
-                        WHERE Dealer_Arrive__c = true
-                        AND (Dealer_Shipment__c = true
-                            OR Dealer_Saled__c = true)
-                        AND TracingCode__c in :barMcodeMap.values()
-                        AND Bar_Code__c not in :barMcodeMap.keySet()
-                        AND Dealer_Info_text__c = :accountName
-                        AND Arrive_Owner_Work_Location__c =: userWorkLocation
-                        ORDER BY Name ];
-            if(reSet1.size()>0){
-                for (Integer i = 0; i < reSet1.size(); i++) {
-                    if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                        // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                        continue;
-                    }else{
-                        for(String str : barMcodeMap.keySet()){
-                            if(barMcodeMap.get(str) == reSet1[i].TracingCode__c){
-                                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'barcode' +str + '涓庡嚭搴撳崟' + reSet1[i].Sale_orderName__c + ' 涓殑绠$悊缂栫爜涓�鑷达紝浣咮arcode涓嶅悓锛岃纭鍏蜂綋鏁版嵁銆�'));
-                                ErrorIdMap.put(str,str);
-                                ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                            }
-                        }
-                    }
-                }
-            }
-            integer RGcnt =  GoodsReturnCheck();
-            AllMap.putAll(ErrorIdMap);
-            AllMap.putAll(ExistIdMap);
-            if(RGcnt>0){
-                for(String str:GrList){
-                    AllMap.put(str,str);
-                }
-            }
-            //寰楀埌涓嶅瓨鍦ㄧ殑BarCode
-            //return;
-            for(Integer i = 0; i < BarCodeListP.size(); i++){
-                if(AllMap.containsKey(BarCodeListP[i])){
-                    continue;
-                }else if(otherAgencyMap.containsKey(BarCodeListP[i])){
-                    continue;
-                }
-                //add by rentx 2021-01-27 start
-                else if (coc!= null && coc.orderPattern__c == 'hospitalorder') {
-                    HosErrorList.add(BarCodeListP[i]);
-                    continue;
-                }
-                //add by rentx 2021-01-27 end
-                else{
-                    notInlist.add(BarCodeListP[i]);
-                    otherAgencyMap.put(BarCodeListP[i],BarCodeListP[i]);
-                }
-            }
-            //  CHAN-BD43NK 鍏抽棴鐩存帴杩斿搧鍔熻兘
-            if(notInlist.size()>0){
-                if(ArrType!='ReG'){
-                    inventoryEntryNoESetId(notInlist);
-                    if(notInStorelist.size() > 0){
-                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙�'+ notInStorelist + '涓嶅瓨鍦ㄣ��'));
-                        return;
-                    }
-                }else{
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙�'+ notInlist + '涓嶅瓨鍦紝鏃犲搴旂殑鍑哄簱鍗曪紝璇峰厛鎿嶄綔浜у搧鍏ュ簱銆�'));
-                    return;
-                }
-            }
-
-        //add by rentx 2021-01-27 start
-        if (HosErrorList.size() > 0) {
-            for (String str : HosErrorList) {
-                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙�:' + str + HosErrorMap.get(str)+''));
-                
-            }
-        }
-        //add by rentx 2021-01-27 end
-
-        }else{
-                //宸插彇娑堜骇鍝�
-                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
-                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
-                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c 
-                            FROM Consumable_order_details2__c
-                            WHERE Dealer_Arrive__c = FALSE 
-                            AND  Dealer_Shipment__c= FALSE
-                            AND  Dealer_Saled__c = FALSE
-                            AND  Dealer_Returned__c = false
-                            AND Cancellation_Date__c != null
-                            AND  Bar_Code__c in :BarCodeListP
-                            AND Dealer_Info_text__c = :accountName
-                            ORDER BY Name ];//娌″埌璐�
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '璇ュ晢鍝佸彇娑�';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-                //宸茬粡閿�鍞�
-                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
-                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
-                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c 
-                            FROM Consumable_order_details2__c
-                            WHERE Dealer_Saled__c = true
-                            AND  Dealer_Returned__c =false
-                            AND  Dealer_Info_text__c = :accountName
-                            AND  Bar_Code__c in :BarCodeListP 
-                            AND  Arrive_Owner_Work_Location__c =: userWorkLocation 
-                            ORDER BY Name ];
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '璇ュ晢鍝佸凡缁忛攢鍞�';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-                //宸茬粡鍑哄簱浜у搧
-                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
-                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
-                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c 
-                            FROM Consumable_order_details2__c
-                            WHERE Dealer_Shipment__c = true
-                            AND   Dealer_Returned__c =false
-                            AND  Dealer_Info_text__c = :accountName
-                            AND  Arrive_Owner_Work_Location__c =: userWorkLocation 
-                            AND  Bar_Code__c in :BarCodeListP  
-                            ORDER BY Name ];
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '璇ュ晢鍝佸凡缁忓嚭搴�';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-                //宸茬粡鍒拌揣浜у搧
-                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
-                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
-                                Deliver_date__c,Bar_Code__c,Lose_Flag__c,Box_Piece__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c
-                            FROM Consumable_order_details2__c
-                            WHERE Dealer_Arrive__c = true
-                            AND   Dealer_Returned__c =false
-                            AND  Bar_Code__c in :BarCodeListP
-                            AND Dealer_Info_text__c = :accountName
-                            AND Arrive_Owner_Work_Location__c =: userWorkLocation
-                            ORDER BY Name ];
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '璇ュ晢鍝佸凡缁忓埌璐�';
-                            if (reSet1[i].Lose_Flag__c == TRUE) {
-                                str = '璇ュ晢鍝佸凡缁忎涪澶�';
-                            }
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-                //涓嶅睘浜庢湰璁㈠崟
-                reSet1 = [SELECT Id,  Name,Consumable_Product__r.Name__c,
-                                Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,
-                                Deliver_date__c,Bar_Code__c,Box_Piece__c,
-                                Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
-                                recordtypeid,Consumable_order_minor__r.Arrive_Order__c,Report_Product_Expiration__c 
-                            FROM Consumable_order_details2__c
-                            WHERE Consumable_order_minor__c != :ESetId
-                            AND  Bar_Code__c in :BarCodeListP
-                            //AND Dealer_Info_text__c = :accountName
-                            ORDER BY Name ];
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '璇ユ秷鑰楀搧涓嶅睘浜庢湰璁㈠崟';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-            //鍒拌揣浣嗕骇鍝佺被鍨嬩笌鐢ㄦ埛鐨勭被鍨嬩笉绗�
-                reSet1 = [SELECT Id,Name,Intra_Trade_List_RMB__c,Asset_Model_No__c,
-                            Consumable_Product__c,Consumable_Product__r.Name,
-                            Consumable_Product__r.Name__c,Consumable_Product__r.Asset_Model_No__c,
-                            Sterilization_limit__c,Deliver_date__c,Bar_Code__c,
-                            Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,
-                            Consumable_order_minor__c,Dealer_Arrive__c,
-                            Guarantee_period_for_products__c,CFDA_Status__c,
-                            ProductPacking_list_manual__c,Report_Product_Approbation__c,
-                            Report_Product_Expiration__c,Box_Piece__c, Rrturn_count__c,
-                            Product_Type__c
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                            // tcm start
-                            ,Consumable_order_minor__r.ContractNo__c
-                            // tcm end
-                        FROM Consumable_order_details2__c
-                        WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
-                        AND Dealer_Info_text__c = :accountName
-                        AND ( not Product_Type__c  like :userPro_Typestr)
-                        AND Consumable_order_minor__c = :ESetId
-                        AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation
-                        AND Dealer_Arrive__c = false
-                        AND Cancellation_Date__c = null
-                        AND Bar_Code__c in :BarCodeListP
-                        ORDER BY Name ];
-                if(reSet1.size()>0){
-                    for (Integer i = 0; i < reSet1.size(); i++) {
-                        if(ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)){
-                            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                            continue;
-                        }else{
-                            String str = '浜у搧绫诲瀷['+reSet1[i].Product_Type__c+']涓庣敤鎴风殑绫诲瀷['+userPro_Type+']涓嶇';
-                            ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
-                            ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
-                        }
-                    }
-                }
-
-            //鍒拌揣姝g‘淇℃伅
-            reSet = [SELECT Id,Name,Intra_Trade_List_RMB__c,Asset_Model_No__c,
-                            Consumable_Product__c,Consumable_Product__r.Name,
-                            Consumable_Product__r.Name__c,Consumable_Product__r.Asset_Model_No__c,
-                            Sterilization_limit__c,Deliver_date__c,Bar_Code__c,
-                            Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,
-                            Consumable_order_minor__c,Dealer_Arrive__c,
-                            Guarantee_period_for_products__c,CFDA_Status__c,
-                            ProductPacking_list_manual__c,Report_Product_Approbation__c,
-                            Report_Product_Expiration__c,Box_Piece__c, Rrturn_count__c,
-                            TracingCode__c,
-                            Agencyinfo_fromSAP__c,
-                            Frist_Storage_Agency__c,
-                            Dealer_Info_text__c
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                            // tcm start
-                            ,Consumable_order_minor__r.ContractNo__c
-                            // tcm end
-                        FROM Consumable_order_details2__c
-                        WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
-                        AND Dealer_Info_text__c = :accountName
-                        AND Product_Type__c like :userPro_Typestr
-                        AND Consumable_order_minor__c = :ESetId
-                        AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation
-                        AND Dealer_Arrive__c = false
-                        AND Cancellation_Date__c = null
-                        AND Bar_Code__c in :BarCodeListP
-                        ORDER BY Name ];
-            if(reSet.size()>0){
-                Map<String,String> errorMap = new Map<String,String>();
-                for (Integer i = 0; i < reSet.size(); i++) {
-                    if(ExistIdMap.containsKey(reSet[i].Bar_Code__c) || ErrorIdMap.containsKey(reSet[i].Bar_Code__c)){
-                        // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                        continue;
-                    }else{
-                        Matcher n = Pattern.compile('[0-9]').matcher(reSet[i].TracingCode__c);
-                        if(n.find()){
-                            // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
-                            if (reSet[i].TracingCode__c.length() == 5) {
-                                String tr = reSet[i].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()) {
-                                    String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
-                                    ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
-                                    ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                                    continue;
-                                }
-                            }
-                            // String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
-                            // ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
-                            // ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                            // continue;
-                            // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
-                        }
-                        ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet[i]));
-                        ConsumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(reSet[i]));
-                        ExistIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                    }
-                }
-            }
-
-            //barcode涓嶄竴鑷达紝绠$悊缂栫爜涓�鑷�
-            reSet = [SELECT Id,
-                            Name,
-                            Intra_Trade_List_RMB__c,
-                            Asset_Model_No__c,
-                            Consumable_Product__c,
-                            Consumable_Product__r.Name,
-                            Consumable_Product__r.Name__c,
-                            Consumable_Product__r.Asset_Model_No__c,
-                            Sterilization_limit__c,
-                            Deliver_date__c,
-                            Bar_Code__c,
-                            Arrive_date__c,
-                            Send_Date__c,
-                            Box_Piece__c,
-                            Rrturn_count__c,
-                            Consumable_order_minor__r.Name,
-                            Consumable_order_minor__c,
-                            Dealer_Arrive__c,
-                            Guarantee_period_for_products__c,
-                            CFDA_Status__c,
-                            ProductPacking_list_manual__c,
-                            Report_Product_Approbation__c,
-                            Report_Product_Expiration__c,
-                            TracingCode__c
-                            ,Agencyinfo_fromSAP__c
-                            ,Frist_Storage_Agency__c
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                            // tcm start
-                            ,Consumable_order_minor__r.ContractNo__c
-                            // tcm end
-                        FROM Consumable_order_details2__c
-                        WHERE recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
-                        AND Cancellation_Date__c = null
-                        AND Dealer_Arrive__c = false
-                        AND TracingCode__c in :barMcodeMap.values()
-                        AND Bar_Code__c not in :barMcodeMap.keySet()
-                        AND Dealer_Info_text__c = :accountName
-                        AND ((Consumable_order_minor__c != null
-                                AND  Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation)
-                            OR Consumable_order_minor__c = null)
-                        ORDER BY Name ];
-            if(reSet.size()>0){
-                for (Integer i = 0; i < reSet.size(); i++) {
-                    if(ExistIdMap.containsKey(reSet[i].Bar_Code__c) || ErrorIdMap.containsKey(reSet[i].Bar_Code__c)){
-                        // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                        continue;
-                    }else{
-                        Matcher n = Pattern.compile('[0-9]').matcher(reSet[i].TracingCode__c);
-                        if(n.find()){
-                            // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
-                            if (reSet[i].TracingCode__c.length() == 5) {
-                                String tr = reSet[i].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()) {
-                                    String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
-                                    ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
-                                    ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                                    continue;
-                                }
-                            }
-                            // String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
-                            // ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
-                            // ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                            // continue;
-                            // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
-                        }
-                        ExistIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
-                        for(String str : barMcodeMap.keySet()){
-                            if(barMcodeMap.get(str) == reSet[i].TracingCode__c){
-                                reSet[i].Bar_Code__c = str;
-                                ExistIdMap.put(str,str);
-                            }
-                        }
-                        ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet[i]));
-                        ConsumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(reSet[i]));
-                    }
-                }
-            }
-            AllMap.putAll(ErrorIdMap);
-            AllMap.putAll(ExistIdMap);
-            //寰楀埌涓嶅瓨鍦ㄧ殑BarCode
-            for(Integer i = 0; i < BarCodeListP.size(); i++){
-                if(AllMap.containsKey(BarCodeListP[i])){
-                    continue;
-                }else if(otherAgencyMap.containsKey(BarCodeListP[i])){
-                    continue;
-                }
-                //add by rentx 2021-01-27 start
-                else if (coc!= null && coc.orderPattern__c == 'hospitalorder') {
-                    HosErrorList.add(BarCodeListP[i]);
-                    continue;
-                    
-                }
-                //add by rentx 2021-01-27 end
-                else{
-                    notInlist.add(BarCodeListP[i]);
-                    otherAgencyMap.put(BarCodeListP[i],BarCodeListP[i]);
-                }
-            }
-            if(notInlist.size()>0){
-                inventoryEntry(notInlist);
-                if(notInStorelist.size() > 0){
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙�'+ notInStorelist + '涓嶅瓨鍦ㄣ��'));
-                    return;
-                }
-            }
-        }
-
-        //add by rentx 2021-01-27 start 褰撹鍗曚负鍖婚櫌鐗逛环绫诲瀷鐨勮鍗曟椂,濡傛灉鎵句笉鍒癰arcode,涓嶈В鏋�,骞朵笖榛樿璇arcode瀵瑰簲鐨勬槑缁�2涓洪潪鍖婚櫌鐗逛环浜у搧,鐩存帴鎶ラ敊
-        if (HosErrorList.size() > 0) {
-            for (String str : HosErrorList) {
-                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙�:' + str +'鏄潪鍖婚櫌鐗逛环浜у搧'));
-                
-            }
-        }
-        //add by rentx 2021-01-27 end
-
-        makeArrivedSummary();
-
-
-        //add by rentx 20210602 start CHAN-C3K4ZQ
-        makeRecordsView(ConsumableorderdetailsRecordsdummy);
-        //add by rentx 20210602 end CHAN-C3K4ZQ
+      }
     }
+    //绠$悊缂栫爜涓虹┖鐨勪骇鍝�
+    reSet1 = [
+      SELECT
+        Id,
+        Name,
+        Consumable_Product__r.Name__c,
+        Consumable_Product__c,
+        Consumable_Product__r.Name,
+        Sterilization_limit__c,
+        Deliver_date__c,
+        Bar_Code__c,
+        Box_Piece__c,
+        Arrive_date__c,
+        Send_Date__c,
+        Consumable_order_minor__r.Name,
+        Consumable_order_minor__c,
+        TracingCode__c,
+        Report_Product_Expiration__c
+      FROM Consumable_order_details2__c
+      WHERE
+        Bar_Code__c IN :BarCodeListP
+        AND Dealer_Info_text__c = :accountName
+        //AND Arrive_Owner_Work_Location__c =: userWorkLocation
+        AND (TracingCode__c = NULL
+        OR TracingCode__c = '')
+      ORDER BY Name
+    ];
 
+    if (reSet1.size() > 0) {
+      for (Integer i = 0; i < reSet1.size(); i++) {
+        if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+          // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+          continue;
+        } else {
+          String str = '璇ヤ骇鍝佹病鏈夌鐞嗙紪鐮侊紝鏃犳硶鍏ュ簱';
+          ConsumableorderdetailsRecordserror.add(
+            new ConsumableorderdetailsInfo(reSet1[i], str)
+          );
+          ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+        }
+      }
+    }
+    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '绠$悊缂栫爜涓虹┖鐨勪骇鍝� ' + ErrorIdMap));
+    //鏁翠綋鍒拌揣
+    System.debug('EsetId===>' + EsetId);
+    System.debug('ArrType===>' + ArrType);
+    if (EsetId == null || EsetId == '') {
+      if (ArrType != 'ReG') {
+        //鍒拌揣浣嗕骇鍝佺被鍨嬩笌鐢ㄦ埛鐨勭被鍨嬩笉绗�
+        reSet1 = [
+          SELECT
+            Id,
+            Name,
+            Intra_Trade_List_RMB__c,
+            Asset_Model_No__c,
+            Consumable_Product__c,
+            Consumable_Product__r.Name,
+            Consumable_Product__r.Name__c,
+            Consumable_Product__r.Asset_Model_No__c,
+            Sterilization_limit__c,
+            Deliver_date__c,
+            Bar_Code__c,
+            Arrive_date__c,
+            Send_Date__c,
+            Consumable_order_minor__r.Name,
+            Consumable_order_minor__c,
+            Dealer_Arrive__c,
+            Guarantee_period_for_products__c,
+            CFDA_Status__c,
+            ProductPacking_list_manual__c,
+            Report_Product_Approbation__c,
+            Report_Product_Expiration__c,
+            Box_Piece__c,
+            Rrturn_count__c,
+            Product_Type__c,
+            ContractNo_text__c /*,ContractNo__c1*/,
+            // tcm start
+            Consumable_order_minor__r.ContractNo__c
+          // tcm end
+          FROM Consumable_order_details2__c
+          WHERE
+            Bar_Code__c IN :BarCodeListP
+            AND (NOT Product_Type__c LIKE :userPro_Typestr)
+            AND Dealer_Info_text__c = :accountName
+            AND ((Consumable_order_minor__c != NULL
+            AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation)
+            OR Consumable_order_minor__c = NULL)
+          ORDER BY Name
+        ];
 
-    public void inventoryEntryNoESetId (List<String> barCodeList){
-        //鎵�鏈塨arcode瑙f瀽鍒扮殑Jancode
-        List<String> alljanCodeList = new List<String>();
-        List<String> allotCodeList = new List<String>();
-        List<String> barCode01List = new List<String>();
-        List<String> barCode241List = new List<String>();
-        Map<String,Map<String,String>> barJancodeMap = new  Map<String,Map<String,String>>();
-        Map<String,Map<String,String>> barOtcodeMap = new  Map<String,Map<String,String>>();
-        Map<String,List<String>> barcodeinfoMap = new  Map<String,List<String>>();
-        Map<String,String> barcoderightMap = new  Map<String,String>();
-        notInStorelist.clear();
-        for(Integer i = 0; i < barCodeList.size(); i++){
-            Date expirationDate = null ;
-            String serialNoorLotNo = '';
-            String tracingCode = '';
-            String productDateStr = '';
-            Date productionDate = null ;
-            String expirationDateStr = '';
-            if(barCodeList[i].length() >= 3){
-                if(barCodeList[i].substring(0,2) =='01'){
-                    String janCodeMark = '';
-                    //鐢熶骇鏃ユ湡
-                    List<String> janCode = new List<String>();
-                    if(barCodeList[i].length() < 16){
-                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'));
-                        continue;
-                    }else {
-                        //if(barCodeList[i].substring(0,2) !='01'){
-                        //    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')娌℃湁janCode锛屼笉绗﹀悎瑕佹眰锛�'));
-                        //    return;
-                        //}
-                        janCodeMark = barCodeList[i].substring(2,16);
-                        try{
-                            Decimal test  = Decimal.valueOf(janCodeMark);
-                        }catch(Exception e){
-                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨刯anCode閿欒锛�'));
-                            continue;
-                        }
-                    }
-                    if(barCodeList[i].length() >= 22){
-                        if(barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)!='250'){
-                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '浜у搧BarCode(' + barCodeList[i] + ')娌℃湁绠$悊缂栫爜锛�'));
-                            continue;
-                        }
-                        if( barCodeList[i].substring(16,18) =='11'){
-                            try{
-                                productDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-01' ;
-                                productionDate = Date.valueOf(productDateStr);
-                            }catch(Exception e){
-                                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '浜у搧BarCode(' + barCodeList[i] + ')鐨勭敓浜ф棩鏈�' + productDateStr + '閿欒锛�'));
-                                continue;
-                            }
-                            if(barCodeList[i].length() >=32){
-                                if( barCodeList[i].substring(24,26) =='17'){
-                                    try{
-                                        if(barCodeList[i].substring(30,32)=='00'){
-                                            expirationDateStr = '20' + barCodeList[i].substring(26,28) + '-' + barCodeList[i].substring(28,30) + '-' + '01' ;
-                                            expirationDate = Date.valueOf(expirationDateStr);
-                                            expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
-                                        }else{
-                                            expirationDateStr = '20' + barCodeList[i].substring(26,28) + '-' + barCodeList[i].substring(28,30) + '-' +barCodeList[i].substring(30,32) ;
-                                        expirationDate = Date.valueOf(expirationDateStr);
-                                        }
-                                    }catch(Exception e){
-                                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'));
-                                        continue;
-                                    }
-                                    if(barCodeList[i].length() >= 42){
-                                        if(barCodeList[i].substring(32,34) =='10' || barCodeList[i].substring(32,34) =='21'){
-                                            serialNoorLotNo = barCodeList[i].substring(34,barCodeList[i].length() - 8) ;
-                                        }
-                                    }
-                                }else if(barCodeList[i].substring(24,26) =='10' || barCodeList[i].substring(24,26) =='21'){
-                                    serialNoorLotNo = barCodeList[i].substring(26,barCodeList[i].length() - 8) ;
-                                }
-                            }
-                        }else if(barCodeList[i].substring(16,18) =='17'){
-                            try{
-                                if(barCodeList[i].substring(22,24)=='00'){
-                                    expirationDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-01';
-                                    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧expirationDateStr' + expirationDateStr));
-                                    expirationDate = Date.valueOf(expirationDateStr);
-                                    expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
-                                }else{
-                                    expirationDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-' +barCodeList[i].substring(22,24);
-                                    expirationDate = Date.valueOf(expirationDateStr);
-                                }
-                            }catch(Exception e){
-                                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'));
-                                continue;
-                            }
-                            if(barCodeList[i].length() >= 34){
-                                if(barCodeList[i].substring(24,26) =='10' || barCodeList[i].substring(24,26) =='21'){
-                                    serialNoorLotNo = barCodeList[i].substring(26,barCodeList[i].length() - 8) ;
-                                }
-                            }
+        if (reSet1.size() > 0) {
+          for (Integer i = 0; i < reSet1.size(); i++) {
+            if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+              // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+              continue;
+            } else {
+              String str =
+                '浜у搧绫诲瀷[' +
+                reSet1[i].Product_Type__c +
+                ']涓庣敤鎴风殑绫诲瀷[' +
+                userPro_Type +
+                ']涓嶇';
+              ConsumableorderdetailsRecordserror.add(
+                new ConsumableorderdetailsInfo(reSet1[i], str)
+              );
+              ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+            }
+          }
+        }
+        System.debug('reSet1===>' + reSet1);
+        //add by Wang Xueqin
+        //鍒拌揣浣嗕骇鍝佺被鍨嬩笌鐢ㄦ埛鐨勭被鍨嬩笉绗�
+        reSet1 = [
+          SELECT
+            Id,
+            Name,
+            Intra_Trade_List_RMB__c,
+            Asset_Model_No__c,
+            Consumable_Product__c,
+            Consumable_Product__r.Name,
+            Consumable_Product__r.Name__c,
+            Consumable_Product__r.Asset_Model_No__c,
+            Sterilization_limit__c,
+            Deliver_date__c,
+            Bar_Code__c,
+            Arrive_date__c,
+            Send_Date__c,
+            Consumable_order_minor__r.Name,
+            Consumable_order_minor__c,
+            Dealer_Arrive__c,
+            Guarantee_period_for_products__c,
+            CFDA_Status__c,
+            ProductPacking_list_manual__c,
+            Report_Product_Approbation__c,
+            Report_Product_Expiration__c,
+            Box_Piece__c,
+            Rrturn_count__c,
+            Product_Type__c,
+            ContractNo_text__c,
+            Consumable_order_minor__r.ContractNo__c
+          FROM Consumable_order_details2__c
+          WHERE
+            Bar_Code__c IN :BarCodeListP
+            AND (NOT Product_Type__c LIKE :userPro_Typestr)
+        ];
 
-                        }else if(barCodeList[i].length() >= 26){
-                            if(barCodeList[i].substring(16,18) =='10' || barCodeList[i].substring(16,18) =='21'){
-                                serialNoorLotNo = barCodeList[i].substring(18,barCodeList[i].length() - 8) ;
-                            }
-                        }
-                    }
-                    if(barCodeList[i].length() >= 24 && barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)=='250'){
-                        if(barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)=='250'){
-                            tracingCode = barCodeList[i].substring(barCodeList[i].length() - 5,barCodeList[i].length());
-                            Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
-                            if(n.find()){
-                                // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
-                                if (tracingCode.length() == 5) {
-                                    String tr = tracingCode;
-                                    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()) {
-                                        String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
-                                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�'));
-                                        continue;
-                                    }
-                                }
-                                // String str = '绠$悊缂栫爜涓嶆纭紝璇蜂笌绠$悊鍛樼‘璁ゆ槸鍚﹂敊璇��';
-                                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒锛�'));
-                                // continue;
-                                // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
-                            }
-                        }else{
-                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨則racingCode閿欒锛�'));
-                            continue;
-                        }
-                    }
-                    List<String> barcodedetList = new List<String>();
-                    barcodedetList.add(barCodeList[i]);
-                    barcodedetList.add(String.valueOf(expirationDate));
-                    barcodedetList.add(serialNoorLotNo);
-                    barcodedetList.add(tracingCode);
-                    Integer jan1  = Integer.valueOf(janCodeMark.substring(0, 1));
-                    Integer jan2  = Integer.valueOf(janCodeMark.substring(1, 2));
-                    Integer jan3  = Integer.valueOf(janCodeMark.substring(2, 3));
-                    Integer jan4  = Integer.valueOf(janCodeMark.substring(3, 4));
-                    Integer jan5  = Integer.valueOf(janCodeMark.substring(4, 5));
-                    Integer jan6  = Integer.valueOf(janCodeMark.substring(5, 6));
-                    Integer jan7  = Integer.valueOf(janCodeMark.substring(6, 7));
-                    Integer jan8  = Integer.valueOf(janCodeMark.substring(7, 8));
-                    Integer jan9  = Integer.valueOf(janCodeMark.substring(8, 9));
-                    Integer jan10 = Integer.valueOf(janCodeMark.substring(9, 10));
-                    Integer jan11 = Integer.valueOf(janCodeMark.substring(10, 11));
-                    Integer jan12 = Integer.valueOf(janCodeMark.substring(11, 12));
-                    Integer jan13 = Integer.valueOf(janCodeMark.substring(12, 13));
+        if (reSet1.size() > 0) {
+          for (Integer i = 0; i < reSet1.size(); i++) {
+            if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+              // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+              continue;
+            } else {
+              String str =
+                '浜у搧绫诲瀷[' +
+                reSet1[i].Product_Type__c +
+                ']涓庣敤鎴风殑绫诲瀷[' +
+                userPro_Type +
+                ']涓嶇';
+              ConsumableorderdetailsRecordserror.add(
+                new ConsumableorderdetailsInfo(reSet1[i], str)
+              );
+              ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+            }
+          }
+        }
+        System.debug('reSet1===>1' + reSet1);
+        //end
 
-                    Integer count12 = jan2 + jan3*3 + jan4 + jan5*3 + jan6 + jan7*3 + jan8 + jan9*3 + jan10 + jan11*3 +jan12 + jan13*3;
-                    Integer count13 = jan1*3 + jan2 + jan3*3 + jan4 + jan5*3 + jan6 + jan7*3 + jan8 + jan9*3 + jan10 + jan11*3 +jan12 + jan13*3;
-                    String frost12  = (String.valueOf(count12)).substring((String.valueOf(count12)).length()-1);
-                    String frost13  = (String.valueOf(count13)).substring((String.valueOf(count13)).length()-1);
-                    //鍑忓幓12浣嶄釜浣�
-                    frost12 = (String.valueOf(10 - Integer.valueOf(frost12))).substring((String.valueOf(10 - Integer.valueOf(frost12))).length()-1);
-                    frost13 = (String.valueOf(10 - Integer.valueOf(frost13))).substring((String.valueOf(10 - Integer.valueOf(frost13))).length()-1);
-                    janCode.add(janCodeMark.substring(1, 13) + frost12);
-                    janCode.add(janCodeMark.substring(0, 13) + frost12);
-                    janCode.add(janCodeMark.substring(1, 13) + frost13);
-                    janCode.add(janCodeMark.substring(0, 13) + frost13);
-                    alljanCodeList.addAll(janCode);
-                    Map<String,String> janCodeMap = new Map<String,String>();
-                    janCodeMap.put(janCodeMark.substring(1, 13) + frost12,barCodeList[i]);
-                    janCodeMap.put(janCodeMark.substring(0, 13) + frost12,barCodeList[i]);
-                    janCodeMap.put(janCodeMark.substring(1, 13) + frost13,barCodeList[i]);
-                    janCodeMap.put(janCodeMark.substring(0, 13) + frost13,barCodeList[i]);
-                    barJancodeMap.put(barCodeList[i], janCodeMap);
-                    barcodeinfoMap.put(barCodeList[i], barcodedetList);
-                    barCode01List.add(barCodeList[i]);
-                }else if(barCodeList[i].substring(0,3) =='241'){
-                    if(barCodeList[i].length() > 8 && barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)!='250'){
-                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '浜у搧BarCode(' + barCodeList[i] + ')娌℃湁绠$悊缂栫爜锛�'));
-                        continue;
-                    }
-                    List<String> otCodeList = new List<String>();
-                    Map<String,String> otCodeMap = new Map<String,String>();
-                    if(barCodeList[i].length() < 7){
-                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'));
-                        continue;
-                    }else if(barCodeList[i].length() == 11){
-                        String otCode4 = barCodeList[i].substring(3,7);
-                        String otCode5 = barCodeList[i].substring(3,8);
-                        String otCode6 = barCodeList[i].substring(3,9);
-                        String otCode7 = barCodeList[i].substring(3,10);
-                        String otCode8 = barCodeList[i].substring(3,11);
-                        otCodeList.add(otCode4);
-                        otCodeList.add(otCode5);
-                        otCodeList.add(otCode6);
-                        otCodeList.add(otCode7);
-                        otCodeList.add(otCode8);
-                        otCodeMap.put(otCode4,barCodeList[i]);
-                        otCodeMap.put(otCode5,barCodeList[i]);
-                        otCodeMap.put(otCode6,barCodeList[i]);
-                        otCodeMap.put(otCode7,barCodeList[i]);
-                        otCodeMap.put(otCode8,barCodeList[i]);
-                    }else if(barCodeList[i].length() >= 12){
-                        String otCode4 = barCodeList[i].substring(3,7);
-                        String otCode5 = barCodeList[i].substring(3,8);
-                        String otCode6 = barCodeList[i].substring(3,9);
-                        String otCode7 = barCodeList[i].substring(3,10);
-                        String otCode8 = barCodeList[i].substring(3,11);
-                        String otCode9 = barCodeList[i].substring(3,12);
-                        otCodeList.add(otCode4);
-                        otCodeList.add(otCode5);
-                        otCodeList.add(otCode6);
-                        otCodeList.add(otCode7);
-                        otCodeList.add(otCode8);
-                        otCodeList.add(otCode9);
-                        otCodeMap.put(otCode4,barCodeList[i]);
-                        otCodeMap.put(otCode5,barCodeList[i]);
-                        otCodeMap.put(otCode6,barCodeList[i]);
-                        otCodeMap.put(otCode7,barCodeList[i]);
-                        otCodeMap.put(otCode8,barCodeList[i]);
-                        otCodeMap.put(otCode9,barCodeList[i]);
-                    }
-                    allotCodeList.addAll(otCodeList);
-                    barOtcodeMap.put(barCodeList[i], otCodeMap);
-                    barCode241List.add(barCodeList[i]);
-                }else{
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')涓嶇鍚堣姹傦紒'));
-                    continue;
-                }
-            }else{
-                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')涓嶇鍚堣姹傦紒'));
+        //閿�鍞骇鍝�
+        reSet1 = [
+          SELECT
+            Id,
+            Name,
+            Consumable_Product__r.Name__c,
+            Consumable_Product__c,
+            Consumable_Product__r.Name,
+            Sterilization_limit__c,
+            Deliver_date__c,
+            Bar_Code__c,
+            Box_Piece__c,
+            Arrive_date__c,
+            Send_Date__c,
+            Consumable_order_minor__r.Name,
+            Consumable_order_minor__c,
+            recordtypeid,
+            Consumable_order_minor__r.Arrive_Order__c,
+            OwnerId,
+            Report_Product_Expiration__c
+          FROM Consumable_order_details2__c
+          WHERE
+            Dealer_Saled__c = TRUE
+            AND Dealer_Returned__c = FALSE
+            AND Bar_Code__c IN :BarCodeListP
+            AND Dealer_Info_text__c = :accountName
+            AND (Arrive_Owner_Work_Location__c = :userWorkLocation
+            OR OwnerId = :System.Label.User_OlympusSystem)
+          ORDER BY Name
+        ];
+        if (reSet1.size() > 0) {
+          for (Integer i = 0; i < reSet1.size(); i++) {
+            if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+              // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+              continue;
+            } else {
+              String str = '';
+              if (reSet1[i].OwnerId == System.Label.User_OlympusSystem) {
+                str = '璇ュ晢鍝佹槸鐩撮攢浜у搧璇峰厛杩斿搧';
+              } else {
+                str = '璇ュ晢鍝佸凡缁忛攢鍞�';
+              }
+              ConsumableorderdetailsRecordserror.add(
+                new ConsumableorderdetailsInfo(reSet1[i], str)
+              );
+              ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+            }
+          }
+        }
+        //鍑哄簱浜у搧
+        reSet1 = [
+          SELECT
+            Id,
+            Name,
+            Consumable_Product__r.Name__c,
+            Consumable_Product__c,
+            Consumable_Product__r.Name,
+            Sterilization_limit__c,
+            Deliver_date__c,
+            Bar_Code__c,
+            Box_Piece__c,
+            Arrive_date__c,
+            Send_Date__c,
+            Consumable_order_minor__r.Name,
+            Consumable_order_minor__c,
+            recordtypeid,
+            Consumable_order_minor__r.Arrive_Order__c,
+            Report_Product_Expiration__c
+          FROM Consumable_order_details2__c
+          WHERE
+            Dealer_Shipment__c = TRUE
+            AND Dealer_Returned__c = FALSE
+            AND Bar_Code__c IN :BarCodeListP
+            AND Dealer_Info_text__c = :accountName
+            AND Arrive_Owner_Work_Location__c = :userWorkLocation
+          ORDER BY Name
+        ];
+        if (reSet1.size() > 0) {
+          for (Integer i = 0; i < reSet1.size(); i++) {
+            if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+              // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+              continue;
+            } else {
+              String str = '璇ュ晢鍝佸凡缁忓嚭搴�';
+              ConsumableorderdetailsRecordserror.add(
+                new ConsumableorderdetailsInfo(reSet1[i], str)
+              );
+              ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+            }
+          }
+        }
+        //宸插埌璐т骇鍝�
+        reSet1 = [
+          SELECT
+            Id,
+            Name,
+            Consumable_Product__r.Name__c,
+            Consumable_Product__c,
+            Consumable_Product__r.Name,
+            Sterilization_limit__c,
+            Deliver_date__c,
+            Bar_Code__c,
+            Lose_Flag__c,
+            Box_Piece__c,
+            Arrive_date__c,
+            Send_Date__c,
+            Consumable_order_minor__r.Name,
+            Consumable_order_minor__c,
+            recordtypeid,
+            Consumable_order_minor__r.Arrive_Order__c,
+            Report_Product_Expiration__c
+          FROM Consumable_order_details2__c
+          WHERE
+            Dealer_Arrive__c = TRUE
+            AND Dealer_Returned__c = FALSE
+            AND Bar_Code__c IN :BarCodeListP
+            AND Dealer_Info_text__c = :accountName
+            AND Arrive_Owner_Work_Location__c = :userWorkLocation
+          ORDER BY Name
+        ];
+        if (reSet1.size() > 0) {
+          for (Integer i = 0; i < reSet1.size(); i++) {
+            if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+              // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+              continue;
+            } else {
+              String str = '璇ュ晢鍝佸凡缁忓埌璐�';
+              if (reSet1[i].Lose_Flag__c == true) {
+                str = '璇ュ晢鍝佸凡缁忎涪澶�';
+              }
+              ConsumableorderdetailsRecordserror.add(
+                new ConsumableorderdetailsInfo(reSet1[i], str)
+              );
+              ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+            }
+          }
+        }
+
+        //宸叉媶鐩掍骇鍝�
+        reSet1 = [
+          SELECT
+            Id,
+            Name,
+            Consumable_Product__r.Name__c,
+            Consumable_Product__c,
+            Consumable_Product__r.Name,
+            Sterilization_limit__c,
+            Deliver_date__c,
+            Bar_Code__c,
+            Box_Piece__c,
+            Arrive_date__c,
+            Send_Date__c,
+            Consumable_order_minor__r.Name,
+            Consumable_order_minor__c,
+            recordtypeid,
+            Consumable_order_minor__r.Arrive_Order__c,
+            Report_Product_Expiration__c
+          FROM Consumable_order_details2__c
+          WHERE
+            Dealer_Arrive__c = TRUE
+            AND Bar_Code__c IN :BarCodeListP
+            AND (Dealer_Info_text__c != :accountName
+            OR (Dealer_Info_text__c = :accountName
+            AND Arrive_Owner_Work_Location__c != :userWorkLocation))
+            AND Box_Piece__c = '涓�'
+          ORDER BY Name
+        ];
+        if (reSet1.size() > 0) {
+          for (Integer i = 0; i < reSet1.size(); i++) {
+            if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+              // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+              continue;
+            } else {
+              String str = '宸叉媶鐩掔殑浜у搧涓嶈兘鍏ュ簱';
+              ConsumableorderdetailsRecordserror.add(
+                new ConsumableorderdetailsInfo(reSet1[i], str)
+              );
+              ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+            }
+          }
+        }
+
+        // 缁忛攢鍟嗕箣闂存垨鑰呭悓涓�缁忛攢鍟嗕笉鍚屽伐浣滃湴璋冭揣
+        reSet1 = [
+          SELECT
+            Id,
+            Name,
+            Consumable_Product__r.Name__c,
+            Asset_Model_No__c,
+            Arrive_Owner_Work_Location__c,
+            Consumable_Product__c,
+            Consumable_Product__r.Name,
+            Sterilization_limit__c,
+            Box_Piece__c,
+            Deliver_date__c,
+            Bar_Code__c,
+            TracingCode__c,
+            Dealer_Info_text__c,
+            OwnerId,
+            Lose_Flag__c,
+            Arrive_date__c,
+            Send_Date__c,
+            Consumable_order_minor__r.Name,
+            Consumable_order_minor__c,
+            recordtypeid,
+            Consumable_order_minor__r.Arrive_Order__c,
+            SerialLotNo__c,
+            Dealer_Arrive__c,
+            Consumable_Arrived_order__r.Dealer_Info__c,
+            Consumable_Arrived_order__r.Dealer_Info__r.Name,
+            Intra_Trade_List_RMB__c,
+            Dealer_Shipment__c,
+            Dealer_Saled__c,
+            Consumable_Product__r.Asset_Model_No__c,
+            // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+            SummonsForDirction_det__c,
+            Transfer_Time__c,
+            Frist_Transfer_Agency__c,
+            Agency_Transfer__c,
+            // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+            // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 start
+            Agencyinfo_fromSAP__c,
+            Frist_Storage_Agency__c,
+            // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 end
+
+            //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
+            ContractNo_text__c /*,ContractNo__c */,
+            // tcm start
+            Consumable_order_minor__r.ContractNo__c,
+            // tcm end
+            //add by rentx 2020-10-13 end
+            //add by rentx 2021-03-22 start
+            hospitalSpecialOffer__c,
+            exchangeOutPattern__c,
+            Report_Product_Expiration__c
+          //add by rentx 2021-03-22 end
+          FROM Consumable_order_details2__c
+          WHERE
+            Dealer_Arrive__c = TRUE
+            //AND  Dealer_Shipment__c= false
+            //AND  Dealer_Saled__c = FALSE
+            AND Dealer_Returned__c = FALSE
+            AND Cancellation_Flag__c = FALSE
+            AND Bar_Code__c IN :BarCodeListP
+            //AND (Dealer_Shipment__c = FALSE
+            //        OR (Dealer_Shipment__c = TRUE
+            //            AND Consumable_Shipment_order__r.SummonsForDirction__c != '浜掔浉璋冭揣'))
+            AND (Dealer_Info_text__c != :accountName
+            OR (Dealer_Info_text__c = :accountName
+            AND Arrive_Owner_Work_Location__c != :userWorkLocation))
+          // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+          ORDER BY Bar_Code__c, Transfer_Time__c DESC
+          // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+        ];
+        if (reSet1.size() > 0) {
+          for (Integer i = 0; i < reSet1.size(); i++) {
+            if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+              // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+              continue;
+            } else {
+              if (otherAgencyMap.containsKey(reSet1[i].Bar_Code__c)) {
                 continue;
-            }
-        }
-        //01閫氳繃妫�绱骇鍝佹槸鍚﹀瓨鍦�
-        //-----------XHL--------------UpdateSTART----------------20181010------
-        if(alljanCodeList.size() > 0){
-            List<Product2__c> product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,Product2_Jancode__c,
-                                        Pro2_Dealer_ENG__c,Pro2_Dealer_Object__c
-                FROM Product2__c
-                WHERE Product2_Jancode__c in :alljanCodeList
-                order by SFDA_Expiration_Date__c  desc ] ;
-            if(product2InStore.size() > 0){
-                // CHAN-AVSAST
-                Map<String,String> rightBar = new Map<String,String>();
-                Map<String,String> errorMap = new Map<String,String>();
-                for(String bar: barJancodeMap.keySet() ){
-                    Integer cou = 0;
-                    for(Product2__c produ: product2InStore){
-                        if(barJancodeMap.get(bar).containsKey(produ.Product2_Jancode__c) && !rightBar.containsKey(bar)){
-                            cou ++;
-                            if(EngFlag == TRUE && produ.Pro2_Dealer_ENG__c == TRUE){
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
-                                consumableInventoryUse.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
-                                rightBar.put(bar, bar);
-                            }else if(ETFlag == TRUE && produ.Pro2_Dealer_Object__c == TRUE){   
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
-                                consumableInventoryUse.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
-                                rightBar.put(bar, bar);
-                            }else{
-                                errorMap.put(bar, bar);
-                            }
-                        }
-                        
-                    }
-                    if(cou <= 0 ){
-                        notInStorelist.add(bar);
-                    }
-                }
-                if(errorMap.size() > 0){
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙穂'+ errorMap.values() +']浜у搧绫诲瀷['+product_Type+']涓庣敤鎴风被鍨媅'+userPro_Type+']涓嶇'));
-                }
-            }
-        }
-        
-        //241閫氳繃妫�绱骇鍝佹槸鍚﹀瓨鍦�
-        if(allotCodeList.size() > 0){
-            Map<String,String> errorMap = new Map<String,String>();
-            Map<String,String> exitBarCodeMap = new Map<String,String>();
-            List<Product2__c> product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,Product2_Jancode__c,
-                                Pro2_Dealer_ENG__c,Pro2_Dealer_Object__c
-                FROM Product2__c
-                WHERE OT_CODE__c in :allotCodeList 
-                AND (not Product_Type__c like :userPro_Typestr)] ;
-            if(product2InStore.size() > 0){
-                
-                for(Product2__c produ: product2InStore){
-                    for(String bar: barOtcodeMap.keySet() ){
-                        if(barOtcodeMap.get(bar).containsKey(produ.OT_CODE__c)){
-                            exitBarCodeMap.put(bar,bar);
-                            errorMap.put(bar, bar);
-                        }
-                    }
-                }
-            }
-            if(errorMap.size() > 0){
-                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙穂'+ errorMap.values() +']浜у搧绫诲瀷['+product_Type+']涓庣敤鎴穂'+userPro_Type+']绫诲瀷涓嶇'));
-            }
-            product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,Product2_Jancode__c,
-                                Pro2_Dealer_ENG__c,Pro2_Dealer_Object__c
-                FROM Product2__c
-                WHERE OT_CODE__c in :allotCodeList 
-                AND Product_Type__c like :userPro_Typestr] ;
-            
-            if(product2InStore.size() > 0){
-                
-                for(Product2__c produ: product2InStore){
-                    for(String bar: barOtcodeMap.keySet() ){
-                        Date expirationDate = null ;
-                        String serialNoorLotNo = '';
-                        String tracingCode = '';
-                        String productDateStr = '';
-                        Date productionDate = null ;
-                        String expirationDateStr = '';
-                        if(barOtcodeMap.get(bar).containsKey(produ.OT_CODE__c)){
-                            Integer oTcodeLength = produ.OT_CODE__c.length();
-                                if(bar.length() >= oTcodeLength + 11){
-                                    if( bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='11'){
-                                        try{
-                                            productDateStr = '20' + bar.substring(oTcodeLength + 5,oTcodeLength + 7) + '-' + bar.substring(oTcodeLength + 7,oTcodeLength + 9) + '-01' ;
-                                            productionDate = Date.valueOf(productDateStr);
-                                        }catch(Exception e){
-                                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '浜у搧BarCode(' + bar + ')鐨勭敓浜ф棩鏈�' + productDateStr + '閿欒锛�'));
-                                            continue;
-                                        }
-                                        if(bar.length() >=oTcodeLength + 3 + 16){
-                                            if( bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='17'){
-                                                try{
-                                                    if(bar.substring(oTcodeLength + 3 + 14,oTcodeLength + 3 + 16)=='00'){
-                                                        expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 10,oTcodeLength + 3 + 12) + '-' + bar.substring(oTcodeLength + 3 + 12,oTcodeLength + 3 + 14) + '-' + '01' ;
-                                                        expirationDate = Date.valueOf(expirationDateStr);
-                                                        expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
-                                                    }else{
-                                                        expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 10,oTcodeLength + 3 + 12) + '-' + bar.substring(oTcodeLength + 3 + 12,oTcodeLength + 3 + 14) + '-' +bar.substring(oTcodeLength + 3 + 14,oTcodeLength + 3 + 16) ;
-                                                    expirationDate = Date.valueOf(expirationDateStr);
-                                                    }
-                                                }catch(Exception e){
-                                                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'));
-                                                    continue;
-                                                }
-                                                if(bar.length() >= oTcodeLength + 3 + 25){
-                                                    if(bar.substring(oTcodeLength + 3 + 16,oTcodeLength + 3 + 18) =='10' || bar.substring(oTcodeLength + 3 + 16,oTcodeLength + 3 + 18) =='21'){
-                                                        serialNoorLotNo = bar.substring(oTcodeLength + 3 + 18,bar.length() - 8) ;
-                                                        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
-                                                    }
-                                                }
-                                            }else if(bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='10' || bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='21'){
-                                                serialNoorLotNo = bar.substring(oTcodeLength + 3 + 10,bar.length() - 8) ;
-                                                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
-                                            }
-                                        }
-                                    }else if(bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='17'){
-                                        try{
-                                            if(bar.substring(oTcodeLength + 3 + 6,oTcodeLength + 3 + 8)=='00'){
-                                                expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 2,oTcodeLength + 3 + 4) + '-' + bar.substring(oTcodeLength + 3 + 4,oTcodeLength + 3 + 6) + '-01';
-                                                expirationDate = Date.valueOf(expirationDateStr);
-                                                expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
-                                            }else{
-                                                expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 2,oTcodeLength + 3 + 4) + '-' + bar.substring(oTcodeLength + 3 + 4,oTcodeLength + 3 + 6) + '-' +bar.substring(oTcodeLength + 3 + 6,oTcodeLength + 3 + 8);
-                                                expirationDate = Date.valueOf(expirationDateStr);
-                                            }
-                                        }catch(Exception e){
-                                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'));
-                                            continue;
-                                        }
-                                        if(bar.length() >=oTcodeLength + 20){
-                                            if(bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='10' || bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='21'){
-                                                serialNoorLotNo = bar.substring(oTcodeLength + 3 + 10,bar.length() - 8) ;
-                                            }
-                                        }
-
-                                    }else if(bar.length() >= oTcodeLength + 12){
-                                        if(bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='10' || bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='21'){
-                                            serialNoorLotNo = bar.substring(oTcodeLength + 3 + 2,bar.length() - 8) ;
-                                        }
-                                    }
-                                }
-                                if(bar.length() >= oTcodeLength + 3 + 8 && bar.substring(bar.length() - 8,bar.length()-5)=='250'){
-                                    if(bar.substring(bar.length() - 8,bar.length()-5)=='250'){
-                                        tracingCode = bar.substring(bar.length() - 5,bar.length());
-                                        Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
-                                        if(n.find()){
-                                            // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
-                                            if (tracingCode.length() == 5) {
-                                                String tr = tracingCode;
-                                                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()) {
-                                                    String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
-                                                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�'));
-                                                    continue;
-                                                }
-                                            }
-                                            // String str = '绠$悊缂栫爜涓嶆纭紝璇蜂笌绠$悊鍛樼‘璁ゆ槸鍚﹂敊璇��';
-                                            // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒锛�'));
-                                            // continue;
-                                            // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end   
-                                        }
-                                    }else{
-                                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')鐨則racingCode閿欒锛�'));
-                                        continue;
-                                    }
-                                }
-                                exitBarCodeMap.put(bar,bar);
-                                List<String> barcodedetList = new List<String>();
-                                barcodedetList.add(bar);
-                                barcodedetList.add(String.valueOf(expirationDate));
-                                barcodedetList.add(serialNoorLotNo);
-                                barcodedetList.add(tracingCode);
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodedetList));
-                                consumableInventoryUse.add(new ConsumableorderdetailsInfo(produ,barcodedetList));
-                            
-                        }
-                    }
-
-                }
-            }
-            for(String bartxt :barCode241List){
-               if(!exitBarCodeMap.containsKey(bartxt)){
-                 if(!errorMap.containsKey(bartxt)){
-                    notInStorelist.add(bartxt);
-                 } 
-               }
-            }
-        }
-
-    }
-
-
-    public void inventoryEntry (List<String> barCodeList){
-        //鎵�鏈塨arcode瑙f瀽鍒扮殑Jancode
-        List<String> alljanCodeList = new List<String>();
-        List<String> allotCodeList = new List<String>();
-        List<String> barCode01List = new List<String>();
-        List<String> barCode241List = new List<String>();
-        Map<String,Map<String,String>> barJancodeMap = new  Map<String,Map<String,String>>();
-        Map<String,Map<String,String>> barOtcodeMap = new  Map<String,Map<String,String>>();
-        Map<String,List<String>> barcodeinfoMap = new  Map<String,List<String>>();
-        notInStorelist.clear();
-        notEqualBARcodeCunMap.clear();
-        Map<String,String> orderdetailMap = new Map<String,String>();
-        List<Consumable_Orderdetails__c> orderdetail = [SELECT Id,  Name, Consumable_order__c,
-                            Consumable_Product__c,Asset_Model_No__c
-                        FROM Consumable_Orderdetails__c
-                        WHERE Consumable_order__r.Dealer_Info__c = :accountid
-                        AND Consumable_order__c != null
-                        AND Consumable_order__c = :ESetId
-                        AND Order_Owner_WorkLocal__c = :userWorkLocation
-                        ORDER BY Name ];
-        for(Integer i = 0; i < orderdetail.size(); i++){
-            orderdetailMap.put(orderdetail[i].Consumable_Product__c, orderdetail[i].Consumable_Product__c);
-        }
-
-        for(Integer i = 0; i < barCodeList.size(); i++){
-            Date expirationDate = null ;
-            String serialNoorLotNo = '';
-            String tracingCode = '';
-            String productDateStr = '';
-            Date productionDate = null ;
-            String expirationDateStr = '';
-
-            if(barCodeList[i].substring(0,2) =='01'){
-                String janCodeMark = '';
-                //鐢熶骇鏃ユ湡
-                List<String> janCode = new List<String>();
-                if(barCodeList[i].length() < 16){
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'));
-                    continue;
-                }else {
-                    janCodeMark = barCodeList[i].substring(2,16);
-                    try{
-                        Decimal test  = Decimal.valueOf(janCodeMark);
-                    }catch(Exception e){
-                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨刯anCode閿欒锛�'));
-                        continue;
-                    }
-                }
-                if(barCodeList[i].length() >= 22){
-                    if(barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)!='250'){
-                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '浜у搧BarCode(' + barCodeList[i] + ')娌℃湁绠$悊缂栫爜锛�'));
-                        continue;
-                    }
-                    if( barCodeList[i].substring(16,18) =='11'){
-                        try{
-                            productDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-01' ;
-                            productionDate = Date.valueOf(productDateStr);
-                        }catch(Exception e){
-                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '浜у搧BarCode(' + barCodeList[i] + ')鐨勭敓浜ф棩鏈�' + productDateStr + '閿欒锛�'));
-                            continue;
-                        }
-                        if(barCodeList[i].length() >=32){
-                            if( barCodeList[i].substring(24,26) =='17'){
-                                try{
-                                    if(barCodeList[i].substring(30,32)=='00'){
-                                        expirationDateStr = '20' + barCodeList[i].substring(26,28) + '-' + barCodeList[i].substring(28,30) + '-' + '01' ;
-                                        expirationDate = Date.valueOf(expirationDateStr);
-                                        expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
-                                    }else{
-                                        expirationDateStr = '20' + barCodeList[i].substring(26,28) + '-' + barCodeList[i].substring(28,30) + '-' +barCodeList[i].substring(30,32) ;
-                                    expirationDate = Date.valueOf(expirationDateStr);
-                                    }
-                                }catch(Exception e){
-                                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'));
-                                    continue;
-                                }
-                                if(barCodeList[i].length() >= 42){
-                                    if(barCodeList[i].substring(32,34) =='10' || barCodeList[i].substring(32,34) =='21'){
-                                        serialNoorLotNo = barCodeList[i].substring(34,barCodeList[i].length() - 8) ;
-                                    }
-                                }
-                            }else if(barCodeList[i].substring(24,26) =='10' || barCodeList[i].substring(24,26) =='21'){
-                                serialNoorLotNo = barCodeList[i].substring(26,barCodeList[i].length() - 8) ;
-                            }
-                        }
-                    }else if(barCodeList[i].substring(16,18) =='17'){
-                        try{
-                            if(barCodeList[i].substring(22,24)=='00'){
-                                expirationDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-01';
-                                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧expirationDateStr' + expirationDateStr));
-                                expirationDate = Date.valueOf(expirationDateStr);
-                                expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
-                            }else{
-                                expirationDateStr = '20' + barCodeList[i].substring(18,20) + '-' + barCodeList[i].substring(20,22) + '-' +barCodeList[i].substring(22,24);
-                                expirationDate = Date.valueOf(expirationDateStr);
-                            }
-                        }catch(Exception e){
-                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'));
-                            continue;
-                        }
-                        if(barCodeList[i].length() >= 34){
-                            if(barCodeList[i].substring(24,26) =='10' || barCodeList[i].substring(24,26) =='21'){
-                                serialNoorLotNo = barCodeList[i].substring(26,barCodeList[i].length() - 8) ;
-                            }
-                        }
-
-                    }else if(barCodeList[i].length() >= 26){
-                        if(barCodeList[i].substring(16,18) =='10' || barCodeList[i].substring(16,18) =='21'){
-                            serialNoorLotNo = barCodeList[i].substring(18,barCodeList[i].length() - 8) ;
-                        }
-                    }
-                }
-                if(barCodeList[i].length() >= 24 && barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)=='250'){
-                    if(barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)=='250'){
-                        tracingCode = barCodeList[i].substring(barCodeList[i].length() - 5,barCodeList[i].length());
-                        Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
-                        if(n.find()){
-                            // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
-                            if (tracingCode.length() == 5) {
-                                String tr = tracingCode;
-                                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()) {
-                                    String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
-                                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�'));
-                                    continue;
-                                }
-                            }
-                            // String str = '绠$悊缂栫爜涓嶆纭紝璇蜂笌绠$悊鍛樼‘璁ゆ槸鍚﹂敊璇��';
-                            // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒锛�'));
-                            // continue;
-                            // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
-                        }
-                    }else{
-                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨則racingCode閿欒锛�'));
-                        continue;
-                    }
-                }
+              } else {
+                //鍏朵粬缁忛攢鍟嗗嚭搴撲骇鍝佸彲浠ュ叆搴�
                 List<String> barcodedetList = new List<String>();
-                barcodedetList.add(barCodeList[i]);
-                barcodedetList.add(String.valueOf(expirationDate));
-                barcodedetList.add(serialNoorLotNo);
-                barcodedetList.add(tracingCode);
-                Integer jan1  = Integer.valueOf(janCodeMark.substring(0, 1));
-                Integer jan2  = Integer.valueOf(janCodeMark.substring(1, 2));
-                Integer jan3  = Integer.valueOf(janCodeMark.substring(2, 3));
-                Integer jan4  = Integer.valueOf(janCodeMark.substring(3, 4));
-                Integer jan5  = Integer.valueOf(janCodeMark.substring(4, 5));
-                Integer jan6  = Integer.valueOf(janCodeMark.substring(5, 6));
-                Integer jan7  = Integer.valueOf(janCodeMark.substring(6, 7));
-                Integer jan8  = Integer.valueOf(janCodeMark.substring(7, 8));
-                Integer jan9  = Integer.valueOf(janCodeMark.substring(8, 9));
-                Integer jan10 = Integer.valueOf(janCodeMark.substring(9, 10));
-                Integer jan11 = Integer.valueOf(janCodeMark.substring(10, 11));
-                Integer jan12 = Integer.valueOf(janCodeMark.substring(11, 12));
-                Integer jan13 = Integer.valueOf(janCodeMark.substring(12, 13));
-                Integer count12 = jan2 + jan3*3 + jan4 + jan5*3 + jan6 + jan7*3 + jan8 + jan9*3 + jan10 + jan11*3 +jan12 + jan13*3;
-                
-                Integer count13 = jan1*3 + jan2 + jan3*3 + jan4 + jan5*3 + jan6 + jan7*3 + jan8 + jan9*3 + jan10 + jan11*3 +jan12 + jan13*3;
-                String frost12  = (String.valueOf(count12)).substring((String.valueOf(count12)).length()-1);
-                String frost13  = (String.valueOf(count13)).substring((String.valueOf(count13)).length()-1);
-                //鍑忓幓12浣嶄釜浣�4
-                frost12 = (String.valueOf(10 - Integer.valueOf(frost12))).substring((String.valueOf(10 - Integer.valueOf(frost12))).length()-1);
-                frost13 = (String.valueOf(10 - Integer.valueOf(frost13))).substring((String.valueOf(10 - Integer.valueOf(frost13))).length()-1);
-                
-                janCode.add(janCodeMark.substring(1, 13) + frost12);
-                janCode.add(janCodeMark.substring(0, 13) + frost12);
-                janCode.add(janCodeMark.substring(1, 13) + frost13);
-                janCode.add(janCodeMark.substring(0, 13) + frost13);
-                alljanCodeList.addAll(janCode);
-                Map<String,String> janCodeMap = new Map<String,String>();
-                janCodeMap.put(janCodeMark.substring(1, 13) + frost12,barCodeList[i]);
-                janCodeMap.put(janCodeMark.substring(0, 13) + frost12,barCodeList[i]);
-                janCodeMap.put(janCodeMark.substring(1, 13) + frost13,barCodeList[i]);
-                janCodeMap.put(janCodeMark.substring(0, 13) + frost13,barCodeList[i]);
-                barJancodeMap.put(barCodeList[i], janCodeMap);
-                barcodeinfoMap.put(barCodeList[i], barcodedetList);
-                barCode01List.add(barCodeList[i]);
-            }else if(barCodeList[i].substring(0,3) =='241'){
-                if(barCodeList[i].length() > 8 && barCodeList[i].substring(barCodeList[i].length() - 8,barCodeList[i].length()-5)!='250'){
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '浜у搧BarCode(' + barCodeList[i] + ')娌℃湁绠$悊缂栫爜锛�'));
-                    continue;
+                barcodedetList.add(reSet1[i].Bar_Code__c);
+                barcodedetList.add(
+                  String.valueOf(reSet1[i].Sterilization_limit__c)
+                );
+                barcodedetList.add(reSet1[i].SerialLotNo__c);
+                barcodedetList.add(reSet1[i].TracingCode__c);
+                if (reSet1[i].Lose_Flag__c == false) {
+                  //&& reSet1[i].Dealer_Info_text__c == accountName
+                  consumableorderdetails2Cancle.add(reSet1[i]);
                 }
-                List<String> otCodeList = new List<String>();
-                Map<String,String> otCodeMap = new Map<String,String>();
-                if(barCodeList[i].length() < 7){
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'));
-                    continue;
-                }else if(barCodeList[i].length() == 11){
-                    String otCode4 = barCodeList[i].substring(3,7);
-                    String otCode5 = barCodeList[i].substring(3,8);
-                    String otCode6 = barCodeList[i].substring(3,9);
-                    String otCode7 = barCodeList[i].substring(3,10);
-                    String otCode8 = barCodeList[i].substring(3,11);
-                    otCodeList.add(otCode4);
-                    otCodeList.add(otCode5);
-                    otCodeList.add(otCode6);
-                    otCodeList.add(otCode7);
-                    otCodeList.add(otCode8);
-                    otCodeMap.put(otCode4,barCodeList[i]);
-                    otCodeMap.put(otCode5,barCodeList[i]);
-                    otCodeMap.put(otCode6,barCodeList[i]);
-                    otCodeMap.put(otCode7,barCodeList[i]);
-                    otCodeMap.put(otCode8,barCodeList[i]);
-                }else if(barCodeList[i].length() >= 12){
-                    String otCode4 = barCodeList[i].substring(3,7);
-                    String otCode5 = barCodeList[i].substring(3,8);
-                    String otCode6 = barCodeList[i].substring(3,9);
-                    String otCode7 = barCodeList[i].substring(3,10);
-                    String otCode8 = barCodeList[i].substring(3,11);
-                    String otCode9 = barCodeList[i].substring(3,12);
-                    otCodeList.add(otCode4);
-                    otCodeList.add(otCode5);
-                    otCodeList.add(otCode6);
-                    otCodeList.add(otCode7);
-                    otCodeList.add(otCode8);
-                    otCodeList.add(otCode9);
-                    otCodeMap.put(otCode4,barCodeList[i]);
-                    otCodeMap.put(otCode5,barCodeList[i]);
-                    otCodeMap.put(otCode6,barCodeList[i]);
-                    otCodeMap.put(otCode7,barCodeList[i]);
-                    otCodeMap.put(otCode8,barCodeList[i]);
-                    otCodeMap.put(otCode9,barCodeList[i]);
+                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+                if (
+                  reSet1[i].SummonsForDirction_det__c == '浜掔浉璋冭揣' &&
+                  !orderdetails2trMap.containsKey(reSet1[i].Bar_Code__c)
+                ) {
+                  orderdetails2trMap.put(reSet1[i].Bar_Code__c, reSet1[i]);
                 }
-                allotCodeList.addAll(otCodeList);
-                barOtcodeMap.put(barCodeList[i], otCodeMap);
-                barCode241List.add(barCodeList[i]);
-            }else{
-                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')娌℃湁janCode鎴朞Tcode锛屼笉绗﹀悎瑕佹眰锛�'));
+                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+                consumableInventory.add(
+                  new ConsumableorderdetailsInfo(reSet1[i], barcodedetList)
+                );
+                Consumable_order_details2__c codsIns = new Consumable_order_details2__c();
+
+                codsIns.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+                codsIns.Intra_Trade_List_RMB__c = reSet1[i]
+                  .Intra_Trade_List_RMB__c;
+                //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
+                codsIns.Asset_Model_No__c = reSet1[i].Asset_Model_No__c;
+                codsIns.Direct_Arrive_Product__c = true;
+                codsIns.Sterilization_limit__c = reSet1[i]
+                  .Sterilization_limit__c;
+                codsIns.Consumable_Product__c = reSet1[i].Consumable_Product__c;
+                codsIns.Bar_Code__c = reSet1[i].Bar_Code__c;
+                codsIns.SerialLotNo__c = reSet1[i].SerialLotNo__c;
+                codsIns.TracingCode__c = reSet1[i].TracingCode__c;
+                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+                codsIns.Transfer_Time__c = reSet1[i].Transfer_Time__c == null
+                  ? 1
+                  : reSet1[i].Transfer_Time__c;
+                codsIns.Frist_Transfer_Agency__c = reSet1[i]
+                    .Frist_Transfer_Agency__c == null
+                  ? reSet1[i].Dealer_Info_text__c
+                  : reSet1[i].Frist_Transfer_Agency__c;
+                codsIns.Agency_Transfer__c = true;
+                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+
+                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
+                codsIns.Agencyinfo_fromSAP__c = reSet1[i].Agencyinfo_fromSAP__c;
+                codsIns.Frist_Storage_Agency__c = reSet1[i]
+                  .Frist_Storage_Agency__c;
+                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
+
+                //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,璁板綍SAP鍚堝悓鍙�
+                // update tcm start
+                if (
+                  String.isBlank(
+                    reSet1[i].Consumable_order_minor__r.ContractNo__c
+                  )
+                ) {
+                  codsIns.ContractNo_text__c = reSet1[i].ContractNo_text__c;
+                } else {
+                  codsIns.ContractNo_text__c = reSet1[i]
+                    .Consumable_order_minor__r.ContractNo__c;
+                }
+                // update tcm end
+                //add by rentx 2020-10-13 end
+
+                //add by rentx 2021-03-22 start
+                // if (reSet1[i].Lose_Flag__c == true){
+                if (
+                  reSet1[i].hospitalSpecialOffer__c == true &&
+                  reSet1[i].SummonsForDirction_det__c == '浜掔浉璋冭揣'
+                ) {
+                  codsIns.exchangeOutPattern__c = true;
+                }
+                //add by rentx 2021-03-22 end
+
+                consumableorderdetails2Insert.add(codsIns);
+                otherAgencyMap.put(
+                  reSet1[i].Bar_Code__c,
+                  reSet1[i].Bar_Code__c
+                );
+                //String str = '璇ュ晢鍝佸湪鍏朵粬缁忛攢鍟嗗簱瀛�';
+                //ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
+                //ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+              }
+            }
+          }
+        }
+
+        //鍙戦敊搴� 鏈埌璐�
+        reSet1 = [
+          SELECT
+            Id,
+            Name,
+            Consumable_Product__r.Name__c,
+            Asset_Model_No__c,
+            Consumable_Product__c,
+            Consumable_Product__r.Name,
+            Sterilization_limit__c,
+            Deliver_date__c,
+            Bar_Code__c,
+            TracingCode__c,
+            Box_Piece__c,
+            Arrive_date__c,
+            Send_Date__c,
+            Consumable_order_minor__r.Name,
+            Consumable_order_minor__c,
+            recordtypeid,
+            Consumable_order_minor__r.Arrive_Order__c,
+            SerialLotNo__c,
+            Dealer_Arrive__c,
+            Dealer_Shipment__c,
+            Dealer_Saled__c,
+            Consumable_Product__r.Asset_Model_No__c,
+            // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+            SummonsForDirction_det__c,
+            Transfer_Time__c,
+            Frist_Transfer_Agency__c,
+            Agency_Transfer__c,
+            Dealer_Info_text__c,
+            Intra_Trade_List_RMB__c,
+            // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+            // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 start
+            Agencyinfo_fromSAP__c,
+            Frist_Storage_Agency__c,
+            // 棣栨鍏ュ簱缁忛攢鍟嗕俊鎭� add by gzw 2020-04-27 end
+            //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
+            ContractNo_text__c /*,ContractNo__c*/,
+            // tcm start
+            Consumable_order_minor__r.ContractNo__c,
+            // tcm end
+            //add by rentx 2020-10-13 end   浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
+            hospitalSpecialOffer__c,
+            exchangeOutPattern__c,
+            Lose_Flag__c,
+            Report_Product_Expiration__c
+          FROM Consumable_order_details2__c
+          WHERE
+            Dealer_Arrive__c = FALSE
+            AND Dealer_Shipment__c = FALSE
+            AND Dealer_Saled__c = FALSE
+            //AND  Cancellation_Flag__c = FALSE
+            AND Bar_Code__c IN :BarCodeListP
+            AND (Dealer_Info_text__c != :accountName
+            OR (Dealer_Info_text__c = :accountName
+            AND ((Consumable_order_minor__c != NULL
+            AND (Consumable_order_minor__r.Order_Owner_WorkLocal__c != :userWorkLocation
+            OR (Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation
+            AND Cancellation_Flag__c = TRUE)))
+            OR (Consumable_order_minor__c = NULL
+            AND Cancellation_Flag__c = TRUE))))
+          // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+          ORDER BY Bar_Code__c, Transfer_Time__c DESC
+          // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+        ];
+        if (reSet1.size() > 0) {
+          for (Integer i = 0; i < reSet1.size(); i++) {
+            if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+              // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+              continue;
+            } else {
+              if (otherAgencyMap.containsKey(reSet1[i].Bar_Code__c)) {
                 continue;
+              } else {
+                //鍙栨秷鏄庣粏
+                List<String> barcodedetList = new List<String>();
+                barcodedetList.add(reSet1[i].Bar_Code__c);
+                barcodedetList.add(
+                  String.valueOf(reSet1[i].Sterilization_limit__c)
+                );
+                barcodedetList.add(reSet1[i].SerialLotNo__c);
+                barcodedetList.add(reSet1[i].TracingCode__c);
+                // 鍙戦敊搴撳瓨鏃讹紝鑷姩鍙栨秷 update by gzw 2020-04-15 start
+                //if (reSet1[i].Consumable_order_minor__c == null) {
+                consumableorderdetails2Cancle.add(reSet1[i]);
+                //}
+                // 鍙戦敊搴撳瓨鏃讹紝鑷姩鍙栨秷 update by gzw 2020-04-15 start
+                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+                if (
+                  reSet1[i].SummonsForDirction_det__c == '浜掔浉璋冭揣' &&
+                  !orderdetails2trMap.containsKey(reSet1[i].Bar_Code__c)
+                ) {
+                  orderdetails2trMap.put(reSet1[i].Bar_Code__c, reSet1[i]);
+                }
+                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+                consumableInventory.add(
+                  new ConsumableorderdetailsInfo(reSet1[i], barcodedetList)
+                );
+                Consumable_order_details2__c codsIns = new Consumable_order_details2__c();
+
+                codsIns.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+                codsIns.Intra_Trade_List_RMB__c = reSet1[i]
+                  .Intra_Trade_List_RMB__c;
+                //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
+                codsIns.Asset_Model_No__c = reSet1[i].Asset_Model_No__c;
+                codsIns.Direct_Arrive_Product__c = true;
+                codsIns.Sterilization_limit__c = reSet1[i]
+                  .Sterilization_limit__c;
+                codsIns.Consumable_Product__c = reSet1[i].Consumable_Product__c;
+                codsIns.Bar_Code__c = reSet1[i].Bar_Code__c;
+                codsIns.SerialLotNo__c = reSet1[i].SerialLotNo__c;
+                codsIns.TracingCode__c = reSet1[i].TracingCode__c;
+                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+                // 娌℃湁鍏ュ簱鏃讹紝娌℃湁鍊熻皟淇℃伅
+                codsIns.Transfer_Time__c = reSet1[i].Transfer_Time__c;
+                codsIns.Frist_Transfer_Agency__c = reSet1[i]
+                  .Frist_Transfer_Agency__c;
+                codsIns.Agency_Transfer__c = reSet1[i].Agency_Transfer__c;
+                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+
+                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
+                codsIns.Agencyinfo_fromSAP__c = reSet1[i].Agencyinfo_fromSAP__c;
+                codsIns.Frist_Storage_Agency__c = reSet1[i]
+                  .Frist_Storage_Agency__c;
+                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
+
+                //add by rentx 2020-10-13 start 浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
+                // update tcm start
+                if (
+                  String.isBlank(
+                    reSet1[i].Consumable_order_minor__r.ContractNo__c
+                  )
+                ) {
+                  codsIns.ContractNo_text__c = reSet1[i].ContractNo_text__c;
+                } else {
+                  codsIns.ContractNo_text__c = reSet1[i]
+                    .Consumable_order_minor__r.ContractNo__c;
+                }
+                // update tcm end
+                //add by rentx 2020-10-13 end   浜掔浉璋冭揣鏃�,鍊熷叆鏂硅褰昐AP鍚堝悓鍙�
+
+                //add by rentx 2021-03-22 start
+                // if (reSet1[i].Lose_Flag__c == true){
+                if (
+                  reSet1[i].hospitalSpecialOffer__c == true &&
+                  reSet1[i].SummonsForDirction_det__c == '浜掔浉璋冭揣'
+                ) {
+                  codsIns.exchangeOutPattern__c = true;
+                }
+                //add by rentx 2021-03-22 end
+
+                consumableorderdetails2Insert.add(codsIns);
+                otherAgencyMap.put(
+                  reSet1[i].Bar_Code__c,
+                  reSet1[i].Bar_Code__c
+                );
+              }
             }
+          }
         }
-        //01閫氳繃妫�绱骇鍝佹槸鍚﹀瓨鍦�
-        Map<String,String> rightBar = new Map<String,String>();
-        if(alljanCodeList.size() > 0){
-            Map<String,String> exitBarCodeMap = new Map<String,String>();
-            List<Product2__c> product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,Product2_Jancode__c,
-                                            Pro2_Dealer_ENG__c,Pro2_Dealer_Object__c,
-                                            Product_Type__c                                      
-                                                 FROM Product2__c
-                                                 WHERE Product2_Jancode__c in :alljanCodeList
-                                                 AND (not Product_Type__c like :userPro_Typestr)
-                                                 order by SFDA_Expiration_Date__c  desc ] ;
-            if(product2InStore.size() > 0){
-                Map<String,String> errorMap = new Map<String,String>();
-                for(Product2__c produ: product2InStore){
-                    for(String bar: barJancodeMap.keySet() ){
-                        if(barJancodeMap.get(bar).containsKey(produ.Product2_Jancode__c) && !rightBar.containsKey(bar)){
-                            exitBarCodeMap.put(bar,bar);
-                            errorMap.put(bar, bar);
-                        }
+      } else {
+        //杩斿搧妫�鏌�
+        //鍒拌揣浣嗕骇鍝佺被鍨嬩笌鐢ㄦ埛鐨勭被鍨嬩笉绗�
+        reSet1 = [
+          SELECT
+            Id,
+            Name,
+            Intra_Trade_List_RMB__c,
+            Asset_Model_No__c,
+            Consumable_Product__c,
+            Consumable_Product__r.Name,
+            Consumable_Product__r.Name__c,
+            Consumable_Product__r.Asset_Model_No__c,
+            Sterilization_limit__c,
+            Deliver_date__c,
+            Bar_Code__c,
+            Arrive_date__c,
+            Send_Date__c,
+            Consumable_order_minor__r.Name,
+            Consumable_order_minor__c,
+            Dealer_Arrive__c,
+            Guarantee_period_for_products__c,
+            CFDA_Status__c,
+            ProductPacking_list_manual__c,
+            Report_Product_Approbation__c,
+            Report_Product_Expiration__c,
+            Box_Piece__c,
+            Rrturn_count__c,
+            Product_Type__c,
+            //add by rentx 2020-10-14 start
+            ContractNo_text__c /*,ContractNo__c*/,
+            // tcm start
+            Consumable_order_minor__r.ContractNo__c
+          // tcm end
+          //add by rentx 2020-10-14 end
+          FROM Consumable_order_details2__c
+          WHERE
+            Bar_Code__c IN :BarCodeListP
+            AND (NOT Product_Type__c LIKE :userPro_Typestr)
+            AND Dealer_Info_text__c = :accountName
+            AND ((Consumable_order_minor__c != NULL
+            AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation)
+            OR Consumable_order_minor__c = NULL)
+          ORDER BY Name
+        ];
 
-                    }
-                }
-                if(errorMap.size() > 0){
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙穂'+ errorMap.values() +']浜у搧绫诲瀷['+product_Type+']涓庣敤鎴风殑绫诲瀷['+userPro_Type+']涓嶇'));
-                }
-            }                                   
-            product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,Product2_Jancode__c,
-                                            Pro2_Dealer_ENG__c,Pro2_Dealer_Object__c,
-                                            Product_Type__c                                      
-                                                 FROM Product2__c
-                                                 WHERE Product2_Jancode__c in :alljanCodeList
-                                                 AND Product_Type__c like :userPro_Typestr
-                                                 order by SFDA_Expiration_Date__c  desc ] ;
-            if(product2InStore.size() > 0){
-                Map<String,String> errorMap = new Map<String,String>();
-                for(Product2__c produ: product2InStore){
-                    for(String bar: barJancodeMap.keySet() ){
-                        if(barJancodeMap.get(bar).containsKey(produ.Product2_Jancode__c) && !rightBar.containsKey(bar)){
-                            exitBarCodeMap.put(bar,bar); 
-                            if(orderdetailMap.containsKey(produ.Id)){
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
-                                rightBar.put(bar, bar);
-                            }else{
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodeinfoMap.get(bar)));
-                                rightBar.put(bar, bar);
-                                list<String> overOrderBARcodeCunList = new list<String>();
-                                if(notEqualBARcodeCunMap.containsKey(produ.Id)){
-                                    overOrderBARcodeCunList = notEqualBARcodeCunMap.get(produ.Id).clone();
-                                    overOrderBARcodeCunList.add(bar);
-                                    notEqualBARcodeCunMap.put(produ.Id,overOrderBARcodeCunList);
-                                }else{
-                                    overOrderBARcodeCunList.add(bar);
-                                    notEqualBARcodeCunMap.put(produ.Id,overOrderBARcodeCunList);
-                                }
-                            }
-                            
-                        }
-                    }
-                }
+        if (reSet1.size() > 0) {
+          for (Integer i = 0; i < reSet1.size(); i++) {
+            if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+              // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+              continue;
+            } else {
+              String str =
+                '浜у搧绫诲瀷[' +
+                reSet1[i].Product_Type__c +
+                ']涓庣敤鎴风殑绫诲瀷[' +
+                userPro_Type +
+                ']涓嶇';
+              ConsumableorderdetailsRecordserror.add(
+                new ConsumableorderdetailsInfo(reSet1[i], str)
+              );
+              ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
             }
-            for(String bartxt :barCode01List){
-               if(!exitBarCodeMap.containsKey(bartxt)){
-                  notInStorelist.add(bartxt);
-               }
-            }
-            
+          }
         }
-
-        //241閫氳繃妫�绱骇鍝佹槸鍚﹀瓨鍦�
-        if(allotCodeList.size() > 0){
-            Map<String,String> exitBarCodeMap = new Map<String,String>();
-            Map<String,String> errorMap = new Map<String,String>();
-            List<Product2__c> product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,
-                                            Pro2_Dealer_Object__c,Pro2_Dealer_ENG__c
-                                                     FROM Product2__c
-                                                     WHERE OT_CODE__c in :allotCodeList 
-                                                     AND (not Product_Type__c like :userPro_Typestr)] ;
-            if(product2InStore.size() > 0){
-                for(Product2__c produ: product2InStore){
-                    for(String bar: barOtcodeMap.keySet() ){
-                        if(barOtcodeMap.get(bar).containsKey(produ.OT_CODE__c)){
-                            exitBarCodeMap.put(bar,bar);
-                            errorMap.put(bar, bar);
-                        }
-                    }
-                }
+        reSet1 = [
+          SELECT
+            Id,
+            Name,
+            Consumable_Product__r.Name__c,
+            Consumable_Product__c,
+            Consumable_Product__r.Name,
+            Sterilization_limit__c,
+            Deliver_date__c,
+            Bar_Code__c,
+            Box_Piece__c,
+            Arrive_date__c,
+            Send_Date__c,
+            Consumable_order_minor__r.Name,
+            Consumable_order_minor__c,
+            recordtypeid,
+            Consumable_order_minor__r.Arrive_Order__c,
+            //add by rentx 2020-10-14 start
+            ContractNo_text__c /*,ContractNo__c*/,
+            // tcm start
+            Consumable_order_minor__r.ContractNo__c,
+            // tcm end
+            Report_Product_Expiration__c
+          //add by rentx 2020-10-14 end
+          FROM Consumable_order_details2__c
+          WHERE
+            Dealer_Arrive__c = FALSE
+            AND Dealer_Shipment__c = FALSE
+            AND Dealer_Saled__c = FALSE
+            // gzw fix 鍙栨秷浜у搧鍒ゆ柇涓烘湭鍏ュ簱 20230323
+            AND Cancellation_Flag__c = FALSE
+            AND Dealer_Returned__c = FALSE
+            AND Bar_Code__c IN :BarCodeListP
+            AND Dealer_Info_text__c = :accountName
+          ORDER BY Name
+        ]; //娌″埌璐�
+        if (reSet1.size() > 0) {
+          for (Integer i = 0; i < reSet1.size(); i++) {
+            if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+              // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+              continue;
+            } else {
+              String str = '璇ュ晢鍝佸皻鏈叆搴�';
+              ConsumableorderdetailsRecordserror.add(
+                new ConsumableorderdetailsInfo(reSet1[i], str)
+              );
+              ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
             }
-            if(errorMap.size() > 0){
-                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙穂'+ errorMap.values() +']浜у搧绫诲瀷['+product_Type+']涓庣敤鎴穂'+userPro_Type+']绫诲瀷涓嶇'));
-            }
-            product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c,
-                                            Pro2_Dealer_Object__c,Pro2_Dealer_ENG__c
-                                                     FROM Product2__c
-                                                     WHERE OT_CODE__c in :allotCodeList 
-                                                     AND Product_Type__c like :userPro_Typestr] ;
-            
-            if(product2InStore.size() > 0){
-                for(Product2__c produ: product2InStore){
-                    for(String bar: barOtcodeMap.keySet() ){
-                        Date expirationDate = null ;
-                        String serialNoorLotNo = '';
-                        String tracingCode = '';
-                        String productDateStr = '';
-                        Date productionDate = null ;
-                        String expirationDateStr = '';
-                        Integer oTcodeLength = produ.OT_CODE__c.length();
-
-                        if(bar.length() >= oTcodeLength + 11){
-                            if( bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='11'){
-                                try{
-                                    productDateStr = '20' + bar.substring(oTcodeLength + 5,oTcodeLength + 7) + '-' + bar.substring(oTcodeLength + 7,oTcodeLength + 9) + '-01' ;
-                                    productionDate = Date.valueOf(productDateStr);
-                                }catch(Exception e){
-                                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  '浜у搧BarCode(' + bar + ')鐨勭敓浜ф棩鏈�' + productDateStr + '閿欒锛�'));
-                                    continue;
-                                }
-                                if(bar.length() >=oTcodeLength + 3 + 16){
-                                    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode17' + bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10)));
-                                    if( bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='17'){
-                                        try{
-                                            if(bar.substring(oTcodeLength + 3 + 14,oTcodeLength + 3 + 16)=='00'){
-                                                expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 10,oTcodeLength + 3 + 12) + '-' + bar.substring(oTcodeLength + 3 + 12,oTcodeLength + 3 + 14) + '-' + '01' ;
-                                                expirationDate = Date.valueOf(expirationDateStr);
-                                                expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
-                                            }else{
-                                                expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 10,oTcodeLength + 3 + 12) + '-' + bar.substring(oTcodeLength + 3 + 12,oTcodeLength + 3 + 14) + '-' +bar.substring(oTcodeLength + 3 + 14,oTcodeLength + 3 + 16) ;
-                                            expirationDate = Date.valueOf(expirationDateStr);
-                                            }
-                                        }catch(Exception e){
-                                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'));
-                                            continue;
-                                        }
-                                        if(bar.length() >= oTcodeLength + 3 + 25){
-                                            if(bar.substring(oTcodeLength + 3 + 16,oTcodeLength + 3 + 18) =='10' || bar.substring(oTcodeLength + 3 + 16,oTcodeLength + 3 + 18) =='21'){
-                                                serialNoorLotNo = bar.substring(oTcodeLength + 3 + 18,bar.length() - 8) ;
-                                                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
-                                            }
-                                        }
-                                    }else if(bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='10' || bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='21'){
-                                        serialNoorLotNo = bar.substring(oTcodeLength + 3 + 10,bar.length() - 8) ;
-                                        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
-                                    }
-                                }
-                            }else if(bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='17'){
-                                try{
-                                    if(bar.substring(oTcodeLength + 3 + 6,oTcodeLength + 3 + 8)=='00'){
-                                        expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 2,oTcodeLength + 3 + 4) + '-' + bar.substring(oTcodeLength + 3 + 4,oTcodeLength + 3 + 6) + '-01';
-                                        expirationDate = Date.valueOf(expirationDateStr);
-                                        expirationDate = expirationDate.addMonths(1).toStartofMonth().addDays(-1);
-                                    }else{
-                                        expirationDateStr = '20' + bar.substring(oTcodeLength + 3 + 2,oTcodeLength + 3 + 4) + '-' + bar.substring(oTcodeLength + 3 + 4,oTcodeLength + 3 + 6) + '-' +bar.substring(oTcodeLength + 3 + 6,oTcodeLength + 3 + 8);
-                                        expirationDate = Date.valueOf(expirationDateStr);
-                                    }
-                                }catch(Exception e){
-                                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')鐨勬粎鑿屾湁鍔规湡闄�' + expirationDateStr + '閿欒锛�'));
-                                    continue;
-                                }
-                                if(bar.length() >=oTcodeLength + 20){
-                                    if(bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='10' || bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10) =='21'){
-                                        serialNoorLotNo = bar.substring(oTcodeLength + 3 + 10,bar.length() - 8) ;
-                                    }
-                                }
-
-                            }else if(bar.length() >= oTcodeLength + 12){
-                                if(bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='10' || bar.substring(oTcodeLength + 3,oTcodeLength + 5) =='21'){
-                                    serialNoorLotNo = bar.substring(oTcodeLength + 3 + 2,bar.length() - 8) ;
-                                }
-                            }
-                        }
-                        if(bar.length() >= oTcodeLength + 3 + 8 && bar.substring(bar.length() - 8,bar.length()-5)=='250'){
-                            if(bar.substring(bar.length() - 8,bar.length()-5)=='250'){
-                                tracingCode = bar.substring(bar.length() - 5,bar.length());
-                                Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
-                                if(n.find()){
-                                    // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
-                                    if (tracingCode.length() == 5) {
-                                        String tr = tracingCode;
-                                        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()) {
-                                            String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
-                                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�'));
-                                            continue;
-                                        }
-                                    }
-                                    // String str = '绠$悊缂栫爜涓嶆纭紝璇蜂笌绠$悊鍛樼‘璁ゆ槸鍚﹂敊璇��';
-                                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒锛�'));
-                                    // continue;
-                                    // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
-                                }
-                            }else{
-                                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')鐨則racingCode閿欒锛�'));
-                                continue;
-                            }
-                        }
-                        List<String> barcodedetList = new List<String>();
-                        barcodedetList.add(bar);
-                        barcodedetList.add(String.valueOf(expirationDate));
-                        barcodedetList.add(serialNoorLotNo);
-                        barcodedetList.add(tracingCode);
-                        if(barOtcodeMap.get(bar).containsKey(produ.OT_CODE__c)){
-                            exitBarCodeMap.put(bar,bar);
-                            
-                            if(orderdetailMap.containsKey(produ.Id)){
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodedetList));
-                            }else{
-                                consumableInventory.add(new ConsumableorderdetailsInfo(produ,barcodedetList));
-                                list<String> overOrderBARcodeCunList = new list<String>();
-                                if(notEqualBARcodeCunMap.containsKey(produ.Id)){
-                                    overOrderBARcodeCunList = notEqualBARcodeCunMap.get(produ.Id).clone();
-                                    overOrderBARcodeCunList.add(bar);
-                                    notEqualBARcodeCunMap.put(produ.Id,overOrderBARcodeCunList);
-                                }else{
-                                    overOrderBARcodeCunList.add(bar);
-                                    notEqualBARcodeCunMap.put(produ.Id,overOrderBARcodeCunList);
-                                }
-                            } 
- 
-                        }
-                    }
-                }
-            }
-
-            for(String bartxt :barCode241List){
-               if(!exitBarCodeMap.containsKey(bartxt)){
-                    if(!errorMap.containsKey(bartxt)){
-                        notInStorelist.add(bartxt);
-                    }
-               }
-            }
+          }
         }
-        //鍒ゆ柇浜у搧鏄惁涓�鑷�
-        if(notEqualBARcodeCunMap.size() > 0){
-            for(String widget : notEqualBARcodeCunMap.keySet()) {
-                if(notEqualBARcodeCunMap.get(widget).size() >0){
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '浠ヤ笅barcode浜у搧涓庤璐т骇鍝佷笉涓�鑷淬��'));
-                    for(String barcodeListTTT : (List<String>)notEqualBARcodeCunMap.get(widget)) {
-                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, barcodeListTTT));
-                    }
+        reSet1 = [
+          SELECT
+            Id,
+            Name,
+            Consumable_Product__r.Name__c,
+            ToDueDateDays__c,
+            Consumable_Product__c,
+            Consumable_Product__r.Name,
+            Sterilization_limit__c,
+            Deliver_date__c,
+            Bar_Code__c,
+            Lose_Flag__c,
+            Box_Piece__c,
+            Arrive_date__c,
+            Send_Date__c,
+            Consumable_order_minor__r.Name,
+            Consumable_order_minor__c,
+            recordtypeid,
+            Consumable_order_minor__r.Arrive_Order__c,
+            //add by rentx 2020-10-14 start
+            ContractNo_text__c /*,ContractNo__c*/,
+            // tcm start
+            Consumable_order_minor__r.ContractNo__c,
+            // tcm end
+            Report_Product_Expiration__c
+          //add by rentx 2020-10-14 end
+          FROM Consumable_order_details2__c
+          WHERE
+            Dealer_Arrive__c = TRUE
+            AND Dealer_Shipment__c = FALSE
+            AND Dealer_Saled__c = FALSE
+            AND Bar_Code__c IN :BarCodeListP
+            AND Dealer_Returned__c = FALSE
+            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+            //AND  Lose_Flag__c = FALSE
+            // AND  Lose_Flag__c = FALSE
+            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+            AND Dealer_Info_text__c = :accountName
+            AND Arrive_Owner_Work_Location__c = :userWorkLocation
+            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+            // Gzw 20201215淇锛屾媶鐩掍骇鍝佷笉鍒ゆ柇
+            AND Box_Piece__c = '鐩�'
+          // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+          ORDER BY Name
+        ]; //娌″嚭搴擄紝娌¢攢鍞紝灏辨槸鍦ㄥ簱
+        if (reSet1.size() > 0) {
+          for (Integer i = 0; i < reSet1.size(); i++) {
+            if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+              // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+              continue;
+            } else {
+              // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+              // String str = '璇ュ晢鍝佸湪搴�';
+              // if (reSet1[i].Lose_Flag__c) {
+              //     str = '璇ュ晢鍝佷涪澶�';
+              // }
+              String str = '';
+              if (reSet1[i].Lose_Flag__c == false) {
+                str = '璇ュ晢鍝佸湪搴�'; //娌″嚭搴� 锛屾病閿�鍞紝娌′涪澶卞氨鏄湪搴撱��
+              }
+              if (
+                reSet1[i].Lose_Flag__c == true &&
+                reSet1[i].ToDueDateDays__c >= 0
+              ) {
+                //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                if (isLwc) {
+                  warningList.add(
+                    '浜у搧' +
+                      reSet1[i].Consumable_Product__r.Name +
+                      '瀛樺湪涓㈠け璁板綍'
+                  );
+                } else {
+                  ApexPages.addmessage(
+                    new ApexPages.message(
+                      ApexPages.severity.WARNING,
+                      '浜у搧' +
+                        reSet1[i].Consumable_Product__r.Name +
+                        '瀛樺湪涓㈠け璁板綍'
+                    )
+                  ); //濡傛灉涓㈠け浜у搧灏辩粰鎻愮ず銆�
                 }
+              }
+              if (
+                reSet1[i].Lose_Flag__c == true &&
+                reSet1[i].ToDueDateDays__c < 0
+              ) {
+                str = '杩囨湡宸查攢瀛樹骇鍝侊紝涓嶅厑璁歌繑鍝�';
+              }
+              if (str != '') {
+                ConsumableorderdetailsRecordserror.add(
+                  new ConsumableorderdetailsInfo(reSet1[i], str)
+                );
+                ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+              }
+              // ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
+              // ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
+              // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
             }
+          }
         }
+      }
+
+      //鍒拌揣姝g‘淇℃伅
+      reSet = [
+        SELECT
+          Id,
+          Name,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          Consumable_Product__c,
+          Consumable_Product__r.Name,
+          Consumable_Product__r.Name__c,
+          Consumable_Product__r.Asset_Model_No__c,
+          Sterilization_limit__c,
+          Deliver_date__c,
+          Bar_Code__c,
+          Arrive_date__c,
+          Send_Date__c,
+          Box_Piece__c,
+          Rrturn_count__c,
+          Consumable_order_minor__r.Name,
+          Consumable_order_minor__c,
+          Dealer_Arrive__c,
+          Guarantee_period_for_products__c,
+          CFDA_Status__c,
+          ProductPacking_list_manual__c,
+          Report_Product_Approbation__c,
+          Report_Product_Expiration__c,
+          Consumable_Product__r.Pro2_Dealer_ENG__c,
+          Consumable_Product__r.Pro2_Dealer_Object__c,
+          TracingCode__c,
+          Agencyinfo_fromSAP__c,
+          Frist_Storage_Agency__c,
+          Dealer_Info_text__c,
+          //add by rentx 2020-10-14 start
+          ContractNo_text__c /*,ContractNo__c*/,
+          // tcm start
+          Consumable_order_minor__r.ContractNo__c
+        // tcm end
+        //add by rentx 2020-10-14 end
+        FROM Consumable_order_details2__c
+        WHERE
+          recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+          AND Cancellation_Date__c = NULL
+          AND Dealer_Arrive__c = FALSE
+          AND Product_Type__c LIKE :userPro_Typestr
+          AND Bar_Code__c IN :BarCodeListP
+          AND Dealer_Info_text__c = :accountName
+          AND ((Consumable_order_minor__c != NULL
+          AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation)
+          OR Consumable_order_minor__c = NULL)
+        ORDER BY Name
+      ];
+
+      if (reSet.size() > 0) {
+        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'ErrorIdMap+++ '+ ErrorIdMap.keyset()));
+        Map<String, String> errorMap = new Map<String, String>();
+        for (Integer i = 0; i < reSet.size(); i++) {
+          if (
+            ExistIdMap.containsKey(reSet[i].Bar_Code__c) ||
+            ErrorIdMap.containsKey(reSet[i].Bar_Code__c)
+          ) {
+            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+            continue;
+          } else {
+            Matcher n = Pattern.compile('[0-9]')
+              .matcher(reSet[i].TracingCode__c);
+            if (n.find()) {
+              // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
+              if (reSet[i].TracingCode__c.length() == 5) {
+                String tr = reSet[i].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()
+                ) {
+                  String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
+                  ConsumableorderdetailsRecordserror.add(
+                    new ConsumableorderdetailsInfo(reSet[i], str)
+                  );
+                  ErrorIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
+                  continue;
+                }
+              }
+              // String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
+              // ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
+              // ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
+              // continue;
+              // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
+            }
+            if (otherAgencyMap.containsKey(reSet[i].Bar_Code__c)) {
+              for (Integer j = 0; j < consumableInventory.size(); j++) {
+                ConsumableorderdetailsInfo codInfo = consumableInventory.get(j);
+                if (codInfo.barCodeNo == reSet[i].Bar_Code__c) {
+                  consumableInventory.remove(j);
+                  break;
+                }
+              }
+              for (
+                Integer m = 0; m < consumableorderdetails2Insert.size(); m++
+              ) {
+                Consumable_order_details2__c cod2 = consumableorderdetails2Insert.get(
+                  m
+                );
+                if (cod2.Bar_Code__c == reSet[i].Bar_Code__c) {
+                  consumableorderdetails2Insert.remove(m);
+                  break;
+                }
+              }
+            }
+            //orderId.add(reSet[i].Consumable_order_minor__c);
+            //prodName.add(reSet[i].Consumable_Product__r.Name);
+            ConsumableorderdetailsRecordsdummy.add(
+              new ConsumableorderdetailsInfo(reSet[i])
+            );
+            ConsumableorderdetailsRecords.add(
+              new ConsumableorderdetailsInfo(reSet[i])
+            );
+            ExistIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
+          }
+        }
+      }
+      //barcode涓嶄竴鑷达紝绠$悊缂栫爜涓�鑷�
+      reSet = [
+        SELECT
+          Id,
+          Name,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          Consumable_Product__c,
+          Consumable_Product__r.Name,
+          Consumable_Product__r.Name__c,
+          Consumable_Product__r.Asset_Model_No__c,
+          Sterilization_limit__c,
+          Deliver_date__c,
+          Bar_Code__c,
+          Arrive_date__c,
+          Send_Date__c,
+          Consumable_order_minor__r.Name,
+          Consumable_order_minor__c,
+          Dealer_Arrive__c,
+          Guarantee_period_for_products__c,
+          CFDA_Status__c,
+          ProductPacking_list_manual__c,
+          Report_Product_Approbation__c,
+          Report_Product_Expiration__c,
+          Box_Piece__c,
+          Rrturn_count__c,
+          TracingCode__c,
+          Agencyinfo_fromSAP__c,
+          Frist_Storage_Agency__c,
+          //add by rentx 2020-10-14 start
+          ContractNo_text__c /*,ContractNo__c */,
+          // tcm start
+          Consumable_order_minor__r.ContractNo__c
+        // tcm end
+        //add by rentx 2020-10-14 end
+        FROM Consumable_order_details2__c
+        WHERE
+          recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+          AND Dealer_Info_text__c = :accountName
+          //update by rentx 2021-01-04 start CHAN-BWX3XW
+          // AND Consumable_order_minor__c != null
+          // AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation
+          AND ((Consumable_order_minor__c != NULL
+          AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation)
+          OR Consumable_order_minor__c = NULL)
+          //update by rentx 2021-01-04 end CHAN-BWX3XW
+          AND Dealer_Arrive__c = FALSE
+          AND Cancellation_Date__c = NULL
+          AND TracingCode__c IN :barMcodeMap.values()
+          AND Bar_Code__c NOT IN :barMcodeMap.keySet()
+        ORDER BY Name
+      ];
+
+      if (reSet.size() > 0) {
+        for (Integer i = 0; i < reSet.size(); i++) {
+          if (
+            ExistIdMap.containsKey(reSet[i].Bar_Code__c) ||
+            ErrorIdMap.containsKey(reSet[i].Bar_Code__c)
+          ) {
+            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+            continue;
+          } else {
+            Matcher n = Pattern.compile('[0-9]')
+              .matcher(reSet[i].TracingCode__c);
+            if (n.find()) {
+              // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
+              if (reSet[i].TracingCode__c.length() == 5) {
+                String tr = reSet[i].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()
+                ) {
+                  String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
+                  ConsumableorderdetailsRecordserror.add(
+                    new ConsumableorderdetailsInfo(reSet[i], str)
+                  );
+                  ErrorIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
+                  continue;
+                }
+              }
+              // String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
+              // ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
+              // ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
+              // continue;
+              // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
+            }
+            ExistIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
+            for (String str : barMcodeMap.keySet()) {
+              // BarCode涓嶄竴鑷存椂鐨勮鍛婁俊鎭�
+              if (
+                reSet[i].Bar_Code__c != str &&
+                reSet[i].TracingCode__c == barMcodeMap.get(str)
+              ) {
+                //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                if (isLwc) {
+                  warningList.add(
+                    '鏉″舰鐮佷负(' + str + ')鐨勫叆搴撴暟鎹笌鍙戣揣鏁版嵁涓嶄竴鑷�'
+                  );
+                } else {
+                  // 20220815 ljh SWAG-CH65B7 start
+                  // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'姝ょ鐞嗙紪鐮佷笌瀹為檯鍙戣揣BarCode涓嶄竴鑷达紝璇锋牳瀵圭鐞嗙紪鐮�('+ str +')鐨勫叆搴撳強搴撳瓨鏁版嵁銆�'));
+                  ApexPages.addmessage(
+                    new ApexPages.message(
+                      ApexPages.severity.WARNING,
+                      '鏉″舰鐮佷负(' + str + ')鐨勫叆搴撴暟鎹笌鍙戣揣鏁版嵁涓嶄竴鑷�'
+                    )
+                  );
+                  // 20220815 ljh SWAG-CH65B7 end
+                }
+              }
+              if (barMcodeMap.get(str) == reSet[i].TracingCode__c) {
+                reSet[i].Bar_Code__c = str;
+                //=====================================
+                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'鍏ュ簱BarCode('+ str +')鍜屽簱瀛樻潯鐮佷笉涓�鑷淬��'));
+                ExistIdMap.put(str, str);
+              }
+            }
+            ConsumableorderdetailsRecordsdummy.add(
+              new ConsumableorderdetailsInfo(reSet[i])
+            );
+            ConsumableorderdetailsRecords.add(
+              new ConsumableorderdetailsInfo(reSet[i])
+            );
+          }
+        }
+      }
+
+      // CHAN-BD43NK 鍏抽棴鐩存帴杩斿搧鍔熻兘  杩藉姞 barcode涓嶄竴鑷村垽鏂�
+      reSet1 = [
+        SELECT
+          Id,
+          Name,
+          TracingCode__c,
+          Bar_Code__c,
+          Sale_orderName__c,
+          Report_Product_Expiration__c
+        FROM Consumable_order_details2__c
+        WHERE
+          Dealer_Arrive__c = TRUE
+          AND (Dealer_Shipment__c = TRUE
+          OR Dealer_Saled__c = TRUE)
+          AND TracingCode__c IN :barMcodeMap.values()
+          AND Bar_Code__c NOT IN :barMcodeMap.keySet()
+          AND Dealer_Info_text__c = :accountName
+          AND Arrive_Owner_Work_Location__c = :userWorkLocation
+        ORDER BY Name
+      ];
+      if (reSet1.size() > 0) {
+        for (Integer i = 0; i < reSet1.size(); i++) {
+          if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+            continue;
+          } else {
+            for (String str : barMcodeMap.keySet()) {
+              if (barMcodeMap.get(str) == reSet1[i].TracingCode__c) {
+                //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                if (isLwc) {
+                  errorList.add(
+                    'barcode' +
+                      str +
+                      '涓庡嚭搴撳崟' +
+                      reSet1[i].Sale_orderName__c +
+                      ' 涓殑绠$悊缂栫爜涓�鑷达紝浣咮arcode涓嶅悓锛岃纭鍏蜂綋鏁版嵁銆�'
+                  );
+                } else {
+                  ApexPages.addmessage(
+                    new ApexPages.message(
+                      ApexPages.severity.ERROR,
+                      'barcode' +
+                        str +
+                        '涓庡嚭搴撳崟' +
+                        reSet1[i].Sale_orderName__c +
+                        ' 涓殑绠$悊缂栫爜涓�鑷达紝浣咮arcode涓嶅悓锛岃纭鍏蜂綋鏁版嵁銆�'
+                    )
+                  );
+                }
+                ErrorIdMap.put(str, str);
+                ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+              }
+            }
+          }
+        }
+      }
+      integer RGcnt = GoodsReturnCheck();
+      AllMap.putAll(ErrorIdMap);
+      AllMap.putAll(ExistIdMap);
+      if (RGcnt > 0) {
+        for (String str : GrList) {
+          AllMap.put(str, str);
+        }
+      }
+      //寰楀埌涓嶅瓨鍦ㄧ殑BarCode
+      //return;
+      for (Integer i = 0; i < BarCodeListP.size(); i++) {
+        if (AllMap.containsKey(BarCodeListP[i])) {
+          continue;
+        } else if (otherAgencyMap.containsKey(BarCodeListP[i])) {
+          continue;
+        }
+        //add by rentx 2021-01-27 start
+        else if (coc != null && coc.orderPattern__c == 'hospitalorder') {
+          HosErrorList.add(BarCodeListP[i]);
+          continue;
+        }
+        //add by rentx 2021-01-27 end
+        else {
+          notInlist.add(BarCodeListP[i]);
+          otherAgencyMap.put(BarCodeListP[i], BarCodeListP[i]);
+        }
+      }
+      //  CHAN-BD43NK 鍏抽棴鐩存帴杩斿搧鍔熻兘
+      if (notInlist.size() > 0) {
+        if (ArrType != 'ReG') {
+          inventoryEntryNoESetId(notInlist);
+          if (notInStorelist.size() > 0) {
+            //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+            if (isLwc) {
+              returnError = 'BarCode鍙�' + notInStorelist + '涓嶅瓨鍦�';
+            } else {
+              ApexPages.addmessage(
+                new ApexPages.message(
+                  ApexPages.severity.ERROR,
+                  'BarCode鍙�' + notInStorelist + '涓嶅瓨鍦ㄣ��'
+                )
+              );
+            }
+            return;
+          }
+        } else {
+          //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+          if (isLwc) {
+            returnError =
+              'BarCode鍙�' +
+              notInlist +
+              '涓嶅瓨鍦紝鏃犲搴旂殑鍑哄簱鍗曪紝璇峰厛鎿嶄綔浜у搧鍏ュ簱';
+          } else {
+            ApexPages.addmessage(
+              new ApexPages.message(
+                ApexPages.severity.ERROR,
+                'BarCode鍙�' +
+                  notInlist +
+                  '涓嶅瓨鍦紝鏃犲搴旂殑鍑哄簱鍗曪紝璇峰厛鎿嶄綔浜у搧鍏ュ簱銆�'
+              )
+            );
+          }
+          return;
+        }
+      }
+
+      //add by rentx 2021-01-27 start
+      if (HosErrorList.size() > 0) {
+        for (String str : HosErrorList) {
+          //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+          if (isLwc) {
+            errorList.add('BarCode鍙�:' + str + HosErrorMap.get(str) + '');
+          } else {
+            ApexPages.addmessage(
+              new ApexPages.message(
+                ApexPages.severity.ERROR,
+                'BarCode鍙�:' + str + HosErrorMap.get(str) + ''
+              )
+            );
+          }
+        }
+      }
+      //add by rentx 2021-01-27 end
+    } else {
+      //宸插彇娑堜骇鍝�
+      reSet1 = [
+        SELECT
+          Id,
+          Name,
+          Consumable_Product__r.Name__c,
+          Consumable_Product__c,
+          Consumable_Product__r.Name,
+          Sterilization_limit__c,
+          Deliver_date__c,
+          Bar_Code__c,
+          Box_Piece__c,
+          Arrive_date__c,
+          Send_Date__c,
+          Consumable_order_minor__r.Name,
+          Consumable_order_minor__c,
+          recordtypeid,
+          Consumable_order_minor__r.Arrive_Order__c,
+          Report_Product_Expiration__c
+        FROM Consumable_order_details2__c
+        WHERE
+          Dealer_Arrive__c = FALSE
+          AND Dealer_Shipment__c = FALSE
+          AND Dealer_Saled__c = FALSE
+          AND Dealer_Returned__c = FALSE
+          AND Cancellation_Date__c != NULL
+          AND Bar_Code__c IN :BarCodeListP
+          AND Dealer_Info_text__c = :accountName
+        ORDER BY Name
+      ]; //娌″埌璐�
+      if (reSet1.size() > 0) {
+        for (Integer i = 0; i < reSet1.size(); i++) {
+          if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+            continue;
+          } else {
+            String str = '璇ュ晢鍝佸彇娑�';
+            ConsumableorderdetailsRecordserror.add(
+              new ConsumableorderdetailsInfo(reSet1[i], str)
+            );
+            ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+          }
+        }
+      }
+      //宸茬粡閿�鍞�
+      reSet1 = [
+        SELECT
+          Id,
+          Name,
+          Consumable_Product__r.Name__c,
+          Consumable_Product__c,
+          Consumable_Product__r.Name,
+          Sterilization_limit__c,
+          Deliver_date__c,
+          Bar_Code__c,
+          Box_Piece__c,
+          Arrive_date__c,
+          Send_Date__c,
+          Consumable_order_minor__r.Name,
+          Consumable_order_minor__c,
+          recordtypeid,
+          Consumable_order_minor__r.Arrive_Order__c,
+          Report_Product_Expiration__c
+        FROM Consumable_order_details2__c
+        WHERE
+          Dealer_Saled__c = TRUE
+          AND Dealer_Returned__c = FALSE
+          AND Dealer_Info_text__c = :accountName
+          AND Bar_Code__c IN :BarCodeListP
+          AND Arrive_Owner_Work_Location__c = :userWorkLocation
+        ORDER BY Name
+      ];
+      if (reSet1.size() > 0) {
+        for (Integer i = 0; i < reSet1.size(); i++) {
+          if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+            continue;
+          } else {
+            String str = '璇ュ晢鍝佸凡缁忛攢鍞�';
+            ConsumableorderdetailsRecordserror.add(
+              new ConsumableorderdetailsInfo(reSet1[i], str)
+            );
+            ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+          }
+        }
+      }
+      //宸茬粡鍑哄簱浜у搧
+      reSet1 = [
+        SELECT
+          Id,
+          Name,
+          Consumable_Product__r.Name__c,
+          Consumable_Product__c,
+          Consumable_Product__r.Name,
+          Sterilization_limit__c,
+          Deliver_date__c,
+          Bar_Code__c,
+          Box_Piece__c,
+          Arrive_date__c,
+          Send_Date__c,
+          Consumable_order_minor__r.Name,
+          Consumable_order_minor__c,
+          recordtypeid,
+          Consumable_order_minor__r.Arrive_Order__c,
+          Report_Product_Expiration__c
+        FROM Consumable_order_details2__c
+        WHERE
+          Dealer_Shipment__c = TRUE
+          AND Dealer_Returned__c = FALSE
+          AND Dealer_Info_text__c = :accountName
+          AND Arrive_Owner_Work_Location__c = :userWorkLocation
+          AND Bar_Code__c IN :BarCodeListP
+        ORDER BY Name
+      ];
+      if (reSet1.size() > 0) {
+        for (Integer i = 0; i < reSet1.size(); i++) {
+          if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+            continue;
+          } else {
+            String str = '璇ュ晢鍝佸凡缁忓嚭搴�';
+            ConsumableorderdetailsRecordserror.add(
+              new ConsumableorderdetailsInfo(reSet1[i], str)
+            );
+            ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+          }
+        }
+      }
+      //宸茬粡鍒拌揣浜у搧
+      reSet1 = [
+        SELECT
+          Id,
+          Name,
+          Consumable_Product__r.Name__c,
+          Consumable_Product__c,
+          Consumable_Product__r.Name,
+          Sterilization_limit__c,
+          Deliver_date__c,
+          Bar_Code__c,
+          Lose_Flag__c,
+          Box_Piece__c,
+          Arrive_date__c,
+          Send_Date__c,
+          Consumable_order_minor__r.Name,
+          Consumable_order_minor__c,
+          recordtypeid,
+          Consumable_order_minor__r.Arrive_Order__c,
+          Report_Product_Expiration__c
+        FROM Consumable_order_details2__c
+        WHERE
+          Dealer_Arrive__c = TRUE
+          AND Dealer_Returned__c = FALSE
+          AND Bar_Code__c IN :BarCodeListP
+          AND Dealer_Info_text__c = :accountName
+          AND Arrive_Owner_Work_Location__c = :userWorkLocation
+        ORDER BY Name
+      ];
+      if (reSet1.size() > 0) {
+        for (Integer i = 0; i < reSet1.size(); i++) {
+          if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+            continue;
+          } else {
+            String str = '璇ュ晢鍝佸凡缁忓埌璐�';
+            if (reSet1[i].Lose_Flag__c == true) {
+              str = '璇ュ晢鍝佸凡缁忎涪澶�';
+            }
+            ConsumableorderdetailsRecordserror.add(
+              new ConsumableorderdetailsInfo(reSet1[i], str)
+            );
+            ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+          }
+        }
+      }
+      //涓嶅睘浜庢湰璁㈠崟
+      reSet1 = [
+        SELECT
+          Id,
+          Name,
+          Consumable_Product__r.Name__c,
+          Consumable_Product__c,
+          Consumable_Product__r.Name,
+          Sterilization_limit__c,
+          Deliver_date__c,
+          Bar_Code__c,
+          Box_Piece__c,
+          Arrive_date__c,
+          Send_Date__c,
+          Consumable_order_minor__r.Name,
+          Consumable_order_minor__c,
+          recordtypeid,
+          Consumable_order_minor__r.Arrive_Order__c,
+          Report_Product_Expiration__c
+        FROM Consumable_order_details2__c
+        WHERE
+          Consumable_order_minor__c != :ESetId
+          AND Bar_Code__c IN :BarCodeListP
+        //AND Dealer_Info_text__c = :accountName
+        ORDER BY Name
+      ];
+      if (reSet1.size() > 0) {
+        for (Integer i = 0; i < reSet1.size(); i++) {
+          if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+            continue;
+          } else {
+            String str = '璇ユ秷鑰楀搧涓嶅睘浜庢湰璁㈠崟';
+            ConsumableorderdetailsRecordserror.add(
+              new ConsumableorderdetailsInfo(reSet1[i], str)
+            );
+            ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+          }
+        }
+      }
+      //鍒拌揣浣嗕骇鍝佺被鍨嬩笌鐢ㄦ埛鐨勭被鍨嬩笉绗�
+      reSet1 = [
+        SELECT
+          Id,
+          Name,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          Consumable_Product__c,
+          Consumable_Product__r.Name,
+          Consumable_Product__r.Name__c,
+          Consumable_Product__r.Asset_Model_No__c,
+          Sterilization_limit__c,
+          Deliver_date__c,
+          Bar_Code__c,
+          Arrive_date__c,
+          Send_Date__c,
+          Consumable_order_minor__r.Name,
+          Consumable_order_minor__c,
+          Dealer_Arrive__c,
+          Guarantee_period_for_products__c,
+          CFDA_Status__c,
+          ProductPacking_list_manual__c,
+          Report_Product_Approbation__c,
+          Report_Product_Expiration__c,
+          Box_Piece__c,
+          Rrturn_count__c,
+          Product_Type__c,
+          ContractNo_text__c /*,ContractNo__c*/,
+          // tcm start
+          Consumable_order_minor__r.ContractNo__c
+        // tcm end
+        FROM Consumable_order_details2__c
+        WHERE
+          recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+          AND Dealer_Info_text__c = :accountName
+          AND (NOT Product_Type__c LIKE :userPro_Typestr)
+          AND Consumable_order_minor__c = :ESetId
+          AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation
+          AND Dealer_Arrive__c = FALSE
+          AND Cancellation_Date__c = NULL
+          AND Bar_Code__c IN :BarCodeListP
+        ORDER BY Name
+      ];
+      if (reSet1.size() > 0) {
+        for (Integer i = 0; i < reSet1.size(); i++) {
+          if (ErrorIdMap.containsKey(reSet1[i].Bar_Code__c)) {
+            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+            continue;
+          } else {
+            String str =
+              '浜у搧绫诲瀷[' +
+              reSet1[i].Product_Type__c +
+              ']涓庣敤鎴风殑绫诲瀷[' +
+              userPro_Type +
+              ']涓嶇';
+            ConsumableorderdetailsRecordserror.add(
+              new ConsumableorderdetailsInfo(reSet1[i], str)
+            );
+            ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+          }
+        }
+      }
+
+      //鍒拌揣姝g‘淇℃伅
+      reSet = [
+        SELECT
+          Id,
+          Name,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          Consumable_Product__c,
+          Consumable_Product__r.Name,
+          Consumable_Product__r.Name__c,
+          Consumable_Product__r.Asset_Model_No__c,
+          Sterilization_limit__c,
+          Deliver_date__c,
+          Bar_Code__c,
+          Arrive_date__c,
+          Send_Date__c,
+          Consumable_order_minor__r.Name,
+          Consumable_order_minor__c,
+          Dealer_Arrive__c,
+          Guarantee_period_for_products__c,
+          CFDA_Status__c,
+          ProductPacking_list_manual__c,
+          Report_Product_Approbation__c,
+          Report_Product_Expiration__c,
+          Box_Piece__c,
+          Rrturn_count__c,
+          TracingCode__c,
+          Agencyinfo_fromSAP__c,
+          Frist_Storage_Agency__c,
+          Dealer_Info_text__c,
+          ContractNo_text__c /*,ContractNo__c*/,
+          // tcm start
+          Consumable_order_minor__r.ContractNo__c
+        // tcm end
+        FROM Consumable_order_details2__c
+        WHERE
+          recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+          AND Dealer_Info_text__c = :accountName
+          AND Product_Type__c LIKE :userPro_Typestr
+          AND Consumable_order_minor__c = :ESetId
+          AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation
+          AND Dealer_Arrive__c = FALSE
+          AND Cancellation_Date__c = NULL
+          AND Bar_Code__c IN :BarCodeListP
+        ORDER BY Name
+      ];
+      if (reSet.size() > 0) {
+        Map<String, String> errorMap = new Map<String, String>();
+        for (Integer i = 0; i < reSet.size(); i++) {
+          if (
+            ExistIdMap.containsKey(reSet[i].Bar_Code__c) ||
+            ErrorIdMap.containsKey(reSet[i].Bar_Code__c)
+          ) {
+            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+            continue;
+          } else {
+            Matcher n = Pattern.compile('[0-9]')
+              .matcher(reSet[i].TracingCode__c);
+            if (n.find()) {
+              // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
+              if (reSet[i].TracingCode__c.length() == 5) {
+                String tr = reSet[i].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()
+                ) {
+                  String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
+                  ConsumableorderdetailsRecordserror.add(
+                    new ConsumableorderdetailsInfo(reSet[i], str)
+                  );
+                  ErrorIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
+                  continue;
+                }
+              }
+              // String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
+              // ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
+              // ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
+              // continue;
+              // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
+            }
+            ConsumableorderdetailsRecordsdummy.add(
+              new ConsumableorderdetailsInfo(reSet[i])
+            );
+            ConsumableorderdetailsRecords.add(
+              new ConsumableorderdetailsInfo(reSet[i])
+            );
+            ExistIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
+          }
+        }
+      }
+
+      //barcode涓嶄竴鑷达紝绠$悊缂栫爜涓�鑷�
+      reSet = [
+        SELECT
+          Id,
+          Name,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          Consumable_Product__c,
+          Consumable_Product__r.Name,
+          Consumable_Product__r.Name__c,
+          Consumable_Product__r.Asset_Model_No__c,
+          Sterilization_limit__c,
+          Deliver_date__c,
+          Bar_Code__c,
+          Arrive_date__c,
+          Send_Date__c,
+          Box_Piece__c,
+          Rrturn_count__c,
+          Consumable_order_minor__r.Name,
+          Consumable_order_minor__c,
+          Dealer_Arrive__c,
+          Guarantee_period_for_products__c,
+          CFDA_Status__c,
+          ProductPacking_list_manual__c,
+          Report_Product_Approbation__c,
+          Report_Product_Expiration__c,
+          TracingCode__c,
+          Agencyinfo_fromSAP__c,
+          Frist_Storage_Agency__c,
+          ContractNo_text__c /*,ContractNo__c*/,
+          // tcm start
+          Consumable_order_minor__r.ContractNo__c
+        // tcm end
+        FROM Consumable_order_details2__c
+        WHERE
+          recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+          AND Cancellation_Date__c = NULL
+          AND Dealer_Arrive__c = FALSE
+          AND TracingCode__c IN :barMcodeMap.values()
+          AND Bar_Code__c NOT IN :barMcodeMap.keySet()
+          AND Dealer_Info_text__c = :accountName
+          AND ((Consumable_order_minor__c != NULL
+          AND Consumable_order_minor__r.Order_Owner_WorkLocal__c = :userWorkLocation)
+          OR Consumable_order_minor__c = NULL)
+        ORDER BY Name
+      ];
+      if (reSet.size() > 0) {
+        for (Integer i = 0; i < reSet.size(); i++) {
+          if (
+            ExistIdMap.containsKey(reSet[i].Bar_Code__c) ||
+            ErrorIdMap.containsKey(reSet[i].Bar_Code__c)
+          ) {
+            // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+            continue;
+          } else {
+            Matcher n = Pattern.compile('[0-9]')
+              .matcher(reSet[i].TracingCode__c);
+            if (n.find()) {
+              // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
+              if (reSet[i].TracingCode__c.length() == 5) {
+                String tr = reSet[i].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()
+                ) {
+                  String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
+                  ConsumableorderdetailsRecordserror.add(
+                    new ConsumableorderdetailsInfo(reSet[i], str)
+                  );
+                  ErrorIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
+                  continue;
+                }
+              }
+              // String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
+              // ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet[i],str));
+              // ErrorIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
+              // continue;
+              // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
+            }
+            ExistIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
+            for (String str : barMcodeMap.keySet()) {
+              if (barMcodeMap.get(str) == reSet[i].TracingCode__c) {
+                reSet[i].Bar_Code__c = str;
+                ExistIdMap.put(str, str);
+              }
+            }
+            ConsumableorderdetailsRecordsdummy.add(
+              new ConsumableorderdetailsInfo(reSet[i])
+            );
+            ConsumableorderdetailsRecords.add(
+              new ConsumableorderdetailsInfo(reSet[i])
+            );
+          }
+        }
+      }
+      AllMap.putAll(ErrorIdMap);
+      AllMap.putAll(ExistIdMap);
+      //寰楀埌涓嶅瓨鍦ㄧ殑BarCode
+      for (Integer i = 0; i < BarCodeListP.size(); i++) {
+        if (AllMap.containsKey(BarCodeListP[i])) {
+          continue;
+        } else if (otherAgencyMap.containsKey(BarCodeListP[i])) {
+          continue;
+        }
+        //add by rentx 2021-01-27 start
+        else if (coc != null && coc.orderPattern__c == 'hospitalorder') {
+          HosErrorList.add(BarCodeListP[i]);
+          continue;
+        }
+        //add by rentx 2021-01-27 end
+        else {
+          notInlist.add(BarCodeListP[i]);
+          otherAgencyMap.put(BarCodeListP[i], BarCodeListP[i]);
+        }
+      }
+      if (notInlist.size() > 0) {
+        inventoryEntry(notInlist);
+        if (notInStorelist.size() > 0) {
+          //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+          if (isLwc) {
+            returnError = 'BarCode鍙�' + notInStorelist + '涓嶅瓨鍦�';
+          } else {
+            ApexPages.addmessage(
+              new ApexPages.message(
+                ApexPages.severity.ERROR,
+                'BarCode鍙�' + notInStorelist + '涓嶅瓨鍦ㄣ��'
+              )
+            );
+          }
+          return;
+        }
+      }
     }
 
-    public String ConfimResult() {
-        list<String> overOrderproList = new list<String>();
-        list<String> overOrderBARcodeCunList = new list<String>();
-        list<String> overOrderBARcodeCunListTest = new list<String>();
-        //overOrderBARcodeCunMap.clear();
-        for (ConsumableorderdetailsInfo ass : ConsumableorderdetailsRecords)  {
-            if(orderWantArriveCunMap.get(ass.esd.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.esd.Asset_Model_No__c) > orderProductCunMap.get(ass.esd.Asset_Model_No__c)-1){
-                // 鑾峰彇瓒呰繃瀹氳揣鏁伴噺鐨勬秷鑰楀搧淇℃伅
-                overOrderBARcodeCunList = new list<String>();
-                overOrderBARcodeCunList = overOrderBARcodeCunMap.get(ass.esd.Asset_Model_No__c).clone();
-                overOrderBARcodeCunList.add(ass.esd.Bar_Code__c);
-                overOrderBARcodeCunMap.put(ass.esd.Asset_Model_No__c,overOrderBARcodeCunList);
-                overOrderCunMap.put(ass.esd.Asset_Model_No__c,overOrderCunMap.get(ass.esd.Asset_Model_No__c)+1);
-                cancellationProList.add(ass.esd.Asset_Model_No__c);
-            }else if(orderWantArriveCunMap.get(ass.esd.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.esd.Asset_Model_No__c) == orderProductCunMap.get(ass.esd.Asset_Model_No__c)-1){
-                consumableorderdetailsRecordsUse.add(ass);
-                cancellationProList.add(ass.esd.Asset_Model_No__c);
-            }else{
-                consumableorderdetailsRecordsUse.add(ass);
-            }
-            orderWantArriveCunMap.put(ass.esd.Asset_Model_No__c,orderWantArriveCunMap.get(ass.esd.Asset_Model_No__c)+1);
+    //add by rentx 2021-01-27 start 褰撹鍗曚负鍖婚櫌鐗逛环绫诲瀷鐨勮鍗曟椂,濡傛灉鎵句笉鍒癰arcode,涓嶈В鏋�,骞朵笖榛樿璇arcode瀵瑰簲鐨勬槑缁�2涓洪潪鍖婚櫌鐗逛环浜у搧,鐩存帴鎶ラ敊
+    if (HosErrorList.size() > 0) {
+      for (String str : HosErrorList) {
+        //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+        if (isLwc) {
+          errorList.add('BarCode鍙�:' + str + '鏄潪鍖婚櫌鐗逛环浜у搧');
+        } else {
+          ApexPages.addmessage(
+            new ApexPages.message(
+              ApexPages.severity.ERROR,
+              'BarCode鍙�:' + str + '鏄潪鍖婚櫌鐗逛环浜у搧'
+            )
+          );
         }
-        for(ConsumableorderdetailsInfo ass : consumableInventory){
-            if (!orderWantArriveCunMap.containsKey(ass.Prod.Asset_Model_No__c)) {
-                consumableInventoryUse.add(ass);
-                continue;
-            }
-            if(orderWantArriveCunMap.get(ass.Prod.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.Prod.Asset_Model_No__c) > orderProductCunMap.get(ass.Prod.Asset_Model_No__c)-1){
-                
-                //鍙栧緱鍘熸湁list
-                overOrderBARcodeCunList = new list<String>();
-                overOrderBARcodeCunList = overOrderBARcodeCunMap.get(ass.Prod.Asset_Model_No__c).clone();
-                //鏇存柊list
-                overOrderBARcodeCunList.add(ass.barCodeNo);
-                //鏇存柊map
-                overOrderBARcodeCunMap.put(ass.Prod.Asset_Model_No__c,overOrderBARcodeCunList);
-                overOrderCunMap.put(ass.Prod.Asset_Model_No__c,overOrderCunMap.get(ass.Prod.Asset_Model_No__c)+1);
-                cancellationProList.add(ass.Prod.Asset_Model_No__c);
-            }else if(orderWantArriveCunMap.get(ass.Prod.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.Prod.Asset_Model_No__c) == orderProductCunMap.get(ass.Prod.Asset_Model_No__c)-1){
-                
-                consumableInventoryUse.add(ass);
-                cancellationProList.add(ass.Prod.Asset_Model_No__c);
-            }else{
-                consumableInventoryUse.add(ass);
-            }
-            orderWantArriveCunMap.put(ass.Prod.Asset_Model_No__c,orderWantArriveCunMap.get(ass.Prod.Asset_Model_No__c)+1);
-        }
-        for (Integer i = 0; i < productList.size(); i++) {
-            if(overOrderBARcodeCunMap.get(productList[i]).size() > 0){
-                // 鑾峰彇瓒呰繃瀹氳揣鏁伴噺鐨勬秷鑰楀搧淇℃伅
-                overOrderproList.add(productList[i]);
-            }
-        }
-        if(overOrderproList.size() > 0){
-            return '浜у搧' + overOrderproList + '鏈鍒拌揣鏁伴噺鍜屽凡鍒拌揣鏁伴噺宸茬粡瓒呰繃璁㈣揣鏁伴噺!';
-        }else{
-            return '';
-        }
+      }
+    }
+    //add by rentx 2021-01-27 end
 
+    makeArrivedSummary();
+
+    //add by rentx 20210602 start CHAN-C3K4ZQ
+    makeRecordsView(ConsumableorderdetailsRecordsdummy);
+    //add by rentx 20210602 end CHAN-C3K4ZQ
+  }
+
+  public void inventoryEntryNoESetId(List<String> barCodeList) {
+    //鎵�鏈塨arcode瑙f瀽鍒扮殑Jancode
+    List<String> alljanCodeList = new List<String>();
+    List<String> allotCodeList = new List<String>();
+    List<String> barCode01List = new List<String>();
+    List<String> barCode241List = new List<String>();
+    Map<String, Map<String, String>> barJancodeMap = new Map<String, Map<String, String>>();
+    Map<String, Map<String, String>> barOtcodeMap = new Map<String, Map<String, String>>();
+    Map<String, List<String>> barcodeinfoMap = new Map<String, List<String>>();
+    Map<String, String> barcoderightMap = new Map<String, String>();
+    notInStorelist.clear();
+    for (Integer i = 0; i < barCodeList.size(); i++) {
+      Date expirationDate = null;
+      String serialNoorLotNo = '';
+      String tracingCode = '';
+      String productDateStr = '';
+      Date productionDate = null;
+      String expirationDateStr = '';
+      if (barCodeList[i].length() >= 3) {
+        if (barCodeList[i].substring(0, 2) == '01') {
+          String janCodeMark = '';
+          //鐢熶骇鏃ユ湡
+          List<String> janCode = new List<String>();
+          if (barCodeList[i].length() < 16) {
+            //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+            if (isLwc) {
+              errorList.add(
+                '浜у搧BarCode(' +
+                  barCodeList[i] +
+                  ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'
+              );
+            } else {
+              ApexPages.addmessage(
+                new ApexPages.message(
+                  ApexPages.severity.ERROR,
+                  '浜у搧BarCode(' +
+                    barCodeList[i] +
+                    ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'
+                )
+              );
+            }
+            continue;
+          } else {
+            //if(barCodeList[i].substring(0,2) !='01'){
+            //    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')娌℃湁janCode锛屼笉绗﹀悎瑕佹眰锛�'));
+            //    return;
+            //}
+            janCodeMark = barCodeList[i].substring(2, 16);
+            try {
+              Decimal test = Decimal.valueOf(janCodeMark);
+            } catch (Exception e) {
+              //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+              if (isLwc) {
+                errorList.add(
+                  '浜у搧BarCode(' + barCodeList[i] + ')鐨刯anCode閿欒锛�'
+                );
+              } else {
+                ApexPages.addmessage(
+                  new ApexPages.message(
+                    ApexPages.severity.ERROR,
+                    '浜у搧BarCode(' + barCodeList[i] + ')鐨刯anCode閿欒锛�'
+                  )
+                );
+              }
+              continue;
+            }
+          }
+          if (barCodeList[i].length() >= 22) {
+            if (
+              barCodeList[i]
+                .substring(
+                  barCodeList[i].length() - 8,
+                  barCodeList[i].length() - 5
+                ) != '250'
+            ) {
+              //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+              if (isLwc) {
+                errorList.add(
+                  '浜у搧BarCode(' + barCodeList[i] + ')娌℃湁绠$悊缂栫爜锛�'
+                );
+              } else {
+                ApexPages.addmessage(
+                  new ApexPages.message(
+                    ApexPages.severity.ERROR,
+                    '浜у搧BarCode(' + barCodeList[i] + ')娌℃湁绠$悊缂栫爜锛�'
+                  )
+                );
+              }
+              continue;
+            }
+            if (barCodeList[i].substring(16, 18) == '11') {
+              try {
+                productDateStr =
+                  '20' +
+                  barCodeList[i].substring(18, 20) +
+                  '-' +
+                  barCodeList[i].substring(20, 22) +
+                  '-01';
+                productionDate = Date.valueOf(productDateStr);
+              } catch (Exception e) {
+                //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                if (isLwc) {
+                  errorList.add(
+                    '浜у搧BarCode(' +
+                      barCodeList[i] +
+                      ')鐨勭敓浜ф棩鏈�' +
+                      productDateStr +
+                      '閿欒锛�'
+                  );
+                } else {
+                  ApexPages.addmessage(
+                    new ApexPages.message(
+                      ApexPages.severity.ERROR,
+                      '浜у搧BarCode(' +
+                        barCodeList[i] +
+                        ')鐨勭敓浜ф棩鏈�' +
+                        productDateStr +
+                        '閿欒锛�'
+                    )
+                  );
+                }
+                continue;
+              }
+              if (barCodeList[i].length() >= 32) {
+                if (barCodeList[i].substring(24, 26) == '17') {
+                  try {
+                    if (barCodeList[i].substring(30, 32) == '00') {
+                      expirationDateStr =
+                        '20' +
+                        barCodeList[i].substring(26, 28) +
+                        '-' +
+                        barCodeList[i].substring(28, 30) +
+                        '-' +
+                        '01';
+                      expirationDate = Date.valueOf(expirationDateStr);
+                      expirationDate = expirationDate.addMonths(1)
+                        .toStartofMonth()
+                        .addDays(-1);
+                    } else {
+                      expirationDateStr =
+                        '20' +
+                        barCodeList[i].substring(26, 28) +
+                        '-' +
+                        barCodeList[i].substring(28, 30) +
+                        '-' +
+                        barCodeList[i].substring(30, 32);
+                      expirationDate = Date.valueOf(expirationDateStr);
+                    }
+                  } catch (Exception e) {
+                    //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                    if (isLwc) {
+                      errorList.add(
+                        '浜у搧BarCode(' +
+                          barCodeList[i] +
+                          ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                          expirationDateStr +
+                          '閿欒锛�'
+                      );
+                    } else {
+                      ApexPages.addmessage(
+                        new ApexPages.message(
+                          ApexPages.severity.ERROR,
+                          '浜у搧BarCode(' +
+                            barCodeList[i] +
+                            ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                            expirationDateStr +
+                            '閿欒锛�'
+                        )
+                      );
+                    }
+                    continue;
+                  }
+                  if (barCodeList[i].length() >= 42) {
+                    if (
+                      barCodeList[i].substring(32, 34) == '10' ||
+                      barCodeList[i].substring(32, 34) == '21'
+                    ) {
+                      serialNoorLotNo = barCodeList[i]
+                        .substring(34, barCodeList[i].length() - 8);
+                    }
+                  }
+                } else if (
+                  barCodeList[i].substring(24, 26) == '10' ||
+                  barCodeList[i].substring(24, 26) == '21'
+                ) {
+                  serialNoorLotNo = barCodeList[i]
+                    .substring(26, barCodeList[i].length() - 8);
+                }
+              }
+            } else if (barCodeList[i].substring(16, 18) == '17') {
+              try {
+                if (barCodeList[i].substring(22, 24) == '00') {
+                  expirationDateStr =
+                    '20' +
+                    barCodeList[i].substring(18, 20) +
+                    '-' +
+                    barCodeList[i].substring(20, 22) +
+                    '-01';
+                  //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧expirationDateStr' + expirationDateStr));
+                  expirationDate = Date.valueOf(expirationDateStr);
+                  expirationDate = expirationDate.addMonths(1)
+                    .toStartofMonth()
+                    .addDays(-1);
+                } else {
+                  expirationDateStr =
+                    '20' +
+                    barCodeList[i].substring(18, 20) +
+                    '-' +
+                    barCodeList[i].substring(20, 22) +
+                    '-' +
+                    barCodeList[i].substring(22, 24);
+                  expirationDate = Date.valueOf(expirationDateStr);
+                }
+              } catch (Exception e) {
+                //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                if (isLwc) {
+                  errorList.add(
+                    '浜у搧BarCode(' +
+                      barCodeList[i] +
+                      ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                      expirationDateStr +
+                      '閿欒锛�'
+                  );
+                } else {
+                  ApexPages.addmessage(
+                    new ApexPages.message(
+                      ApexPages.severity.ERROR,
+                      '浜у搧BarCode(' +
+                        barCodeList[i] +
+                        ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                        expirationDateStr +
+                        '閿欒锛�'
+                    )
+                  );
+                }
+                continue;
+              }
+              if (barCodeList[i].length() >= 34) {
+                if (
+                  barCodeList[i].substring(24, 26) == '10' ||
+                  barCodeList[i].substring(24, 26) == '21'
+                ) {
+                  serialNoorLotNo = barCodeList[i]
+                    .substring(26, barCodeList[i].length() - 8);
+                }
+              }
+            } else if (barCodeList[i].length() >= 26) {
+              if (
+                barCodeList[i].substring(16, 18) == '10' ||
+                barCodeList[i].substring(16, 18) == '21'
+              ) {
+                serialNoorLotNo = barCodeList[i]
+                  .substring(18, barCodeList[i].length() - 8);
+              }
+            }
+          }
+          if (
+            barCodeList[i].length() >= 24 &&
+            barCodeList[i]
+              .substring(
+                barCodeList[i].length() - 8,
+                barCodeList[i].length() - 5
+              ) == '250'
+          ) {
+            if (
+              barCodeList[i]
+                .substring(
+                  barCodeList[i].length() - 8,
+                  barCodeList[i].length() - 5
+                ) == '250'
+            ) {
+              tracingCode = barCodeList[i]
+                .substring(
+                  barCodeList[i].length() - 5,
+                  barCodeList[i].length()
+                );
+              Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
+              if (n.find()) {
+                // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
+                if (tracingCode.length() == 5) {
+                  String tr = tracingCode;
+                  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()
+                  ) {
+                    //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                    String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
+                    if (isLwc) {
+                      errorList.add(
+                        '浜у搧BarCode(' +
+                          barCodeList[i] +
+                          ')绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�'
+                      );
+                    } else {
+                      ApexPages.addmessage(
+                        new ApexPages.message(
+                          ApexPages.severity.ERROR,
+                          '浜у搧BarCode(' +
+                            barCodeList[i] +
+                            ')绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�'
+                        )
+                      );
+                    }
+                    continue;
+                  }
+                }
+              }
+            } else {
+              //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+              if (isLwc) {
+                errorList.add(
+                  '浜у搧BarCode(' + barCodeList[i] + ')鐨則racingCode閿欒锛�'
+                );
+              } else {
+                ApexPages.addmessage(
+                  new ApexPages.message(
+                    ApexPages.severity.ERROR,
+                    '浜у搧BarCode(' + barCodeList[i] + ')鐨則racingCode閿欒锛�'
+                  )
+                );
+              }
+              continue;
+            }
+          }
+          List<String> barcodedetList = new List<String>();
+          barcodedetList.add(barCodeList[i]);
+          barcodedetList.add(String.valueOf(expirationDate));
+          barcodedetList.add(serialNoorLotNo);
+          barcodedetList.add(tracingCode);
+          Integer jan1 = Integer.valueOf(janCodeMark.substring(0, 1));
+          Integer jan2 = Integer.valueOf(janCodeMark.substring(1, 2));
+          Integer jan3 = Integer.valueOf(janCodeMark.substring(2, 3));
+          Integer jan4 = Integer.valueOf(janCodeMark.substring(3, 4));
+          Integer jan5 = Integer.valueOf(janCodeMark.substring(4, 5));
+          Integer jan6 = Integer.valueOf(janCodeMark.substring(5, 6));
+          Integer jan7 = Integer.valueOf(janCodeMark.substring(6, 7));
+          Integer jan8 = Integer.valueOf(janCodeMark.substring(7, 8));
+          Integer jan9 = Integer.valueOf(janCodeMark.substring(8, 9));
+          Integer jan10 = Integer.valueOf(janCodeMark.substring(9, 10));
+          Integer jan11 = Integer.valueOf(janCodeMark.substring(10, 11));
+          Integer jan12 = Integer.valueOf(janCodeMark.substring(11, 12));
+          Integer jan13 = Integer.valueOf(janCodeMark.substring(12, 13));
+
+          Integer count12 =
+            jan2 +
+            jan3 * 3 +
+            jan4 +
+            jan5 * 3 +
+            jan6 +
+            jan7 * 3 +
+            jan8 +
+            jan9 * 3 +
+            jan10 +
+            jan11 * 3 +
+            jan12 +
+            jan13 * 3;
+          Integer count13 =
+            jan1 * 3 +
+            jan2 +
+            jan3 * 3 +
+            jan4 +
+            jan5 * 3 +
+            jan6 +
+            jan7 * 3 +
+            jan8 +
+            jan9 * 3 +
+            jan10 +
+            jan11 * 3 +
+            jan12 +
+            jan13 * 3;
+          String frost12 = (String.valueOf(count12))
+            .substring((String.valueOf(count12)).length() - 1);
+          String frost13 = (String.valueOf(count13))
+            .substring((String.valueOf(count13)).length() - 1);
+          //鍑忓幓12浣嶄釜浣�
+          frost12 = (String.valueOf(10 - Integer.valueOf(frost12)))
+            .substring(
+              (String.valueOf(10 - Integer.valueOf(frost12))).length() - 1
+            );
+          frost13 = (String.valueOf(10 - Integer.valueOf(frost13)))
+            .substring(
+              (String.valueOf(10 - Integer.valueOf(frost13))).length() - 1
+            );
+          janCode.add(janCodeMark.substring(1, 13) + frost12);
+          janCode.add(janCodeMark.substring(0, 13) + frost12);
+          janCode.add(janCodeMark.substring(1, 13) + frost13);
+          janCode.add(janCodeMark.substring(0, 13) + frost13);
+          alljanCodeList.addAll(janCode);
+          Map<String, String> janCodeMap = new Map<String, String>();
+          janCodeMap.put(
+            janCodeMark.substring(1, 13) + frost12,
+            barCodeList[i]
+          );
+          janCodeMap.put(
+            janCodeMark.substring(0, 13) + frost12,
+            barCodeList[i]
+          );
+          janCodeMap.put(
+            janCodeMark.substring(1, 13) + frost13,
+            barCodeList[i]
+          );
+          janCodeMap.put(
+            janCodeMark.substring(0, 13) + frost13,
+            barCodeList[i]
+          );
+          barJancodeMap.put(barCodeList[i], janCodeMap);
+          barcodeinfoMap.put(barCodeList[i], barcodedetList);
+          barCode01List.add(barCodeList[i]);
+        } else if (barCodeList[i].substring(0, 3) == '241') {
+          if (
+            barCodeList[i].length() > 8 &&
+            barCodeList[i]
+              .substring(
+                barCodeList[i].length() - 8,
+                barCodeList[i].length() - 5
+              ) != '250'
+          ) {
+            //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+            if (isLwc) {
+              errorList.add(
+                '浜у搧BarCode(' + barCodeList[i] + ')娌℃湁绠$悊缂栫爜锛�'
+              );
+            } else {
+              ApexPages.addmessage(
+                new ApexPages.message(
+                  ApexPages.severity.ERROR,
+                  '浜у搧BarCode(' + barCodeList[i] + ')娌℃湁绠$悊缂栫爜锛�'
+                )
+              );
+            }
+            continue;
+          }
+          List<String> otCodeList = new List<String>();
+          Map<String, String> otCodeMap = new Map<String, String>();
+          if (barCodeList[i].length() < 7) {
+            //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+            if (isLwc) {
+              errorList.add(
+                '浜у搧BarCode(' +
+                  barCodeList[i] +
+                  ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'
+              );
+            } else {
+              ApexPages.addmessage(
+                new ApexPages.message(
+                  ApexPages.severity.ERROR,
+                  '浜у搧BarCode(' +
+                    barCodeList[i] +
+                    ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'
+                )
+              );
+            }
+            continue;
+          } else if (barCodeList[i].length() == 11) {
+            String otCode4 = barCodeList[i].substring(3, 7);
+            String otCode5 = barCodeList[i].substring(3, 8);
+            String otCode6 = barCodeList[i].substring(3, 9);
+            String otCode7 = barCodeList[i].substring(3, 10);
+            String otCode8 = barCodeList[i].substring(3, 11);
+            otCodeList.add(otCode4);
+            otCodeList.add(otCode5);
+            otCodeList.add(otCode6);
+            otCodeList.add(otCode7);
+            otCodeList.add(otCode8);
+            otCodeMap.put(otCode4, barCodeList[i]);
+            otCodeMap.put(otCode5, barCodeList[i]);
+            otCodeMap.put(otCode6, barCodeList[i]);
+            otCodeMap.put(otCode7, barCodeList[i]);
+            otCodeMap.put(otCode8, barCodeList[i]);
+          } else if (barCodeList[i].length() >= 12) {
+            String otCode4 = barCodeList[i].substring(3, 7);
+            String otCode5 = barCodeList[i].substring(3, 8);
+            String otCode6 = barCodeList[i].substring(3, 9);
+            String otCode7 = barCodeList[i].substring(3, 10);
+            String otCode8 = barCodeList[i].substring(3, 11);
+            String otCode9 = barCodeList[i].substring(3, 12);
+            otCodeList.add(otCode4);
+            otCodeList.add(otCode5);
+            otCodeList.add(otCode6);
+            otCodeList.add(otCode7);
+            otCodeList.add(otCode8);
+            otCodeList.add(otCode9);
+            otCodeMap.put(otCode4, barCodeList[i]);
+            otCodeMap.put(otCode5, barCodeList[i]);
+            otCodeMap.put(otCode6, barCodeList[i]);
+            otCodeMap.put(otCode7, barCodeList[i]);
+            otCodeMap.put(otCode8, barCodeList[i]);
+            otCodeMap.put(otCode9, barCodeList[i]);
+          }
+          allotCodeList.addAll(otCodeList);
+          barOtcodeMap.put(barCodeList[i], otCodeMap);
+          barCode241List.add(barCodeList[i]);
+        } else {
+          //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+          if (isLwc) {
+            errorList.add('浜у搧BarCode(' + barCodeList[i] + ')涓嶇鍚堣姹傦紒');
+          } else {
+            ApexPages.addmessage(
+              new ApexPages.message(
+                ApexPages.severity.ERROR,
+                '浜у搧BarCode(' + barCodeList[i] + ')涓嶇鍚堣姹傦紒'
+              )
+            );
+          }
+          continue;
+        }
+      } else {
+        //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+        if (isLwc) {
+          errorList.add('浜у搧BarCode(' + barCodeList[i] + ')涓嶇鍚堣姹傦紒');
+        } else {
+          ApexPages.addmessage(
+            new ApexPages.message(
+              ApexPages.severity.ERROR,
+              '浜у搧BarCode(' + barCodeList[i] + ')涓嶇鍚堣姹傦紒'
+            )
+          );
+        }
+        continue;
+      }
+    }
+    //01閫氳繃妫�绱骇鍝佹槸鍚﹀瓨鍦�
+    //-----------XHL--------------UpdateSTART----------------20181010------
+    if (alljanCodeList.size() > 0) {
+      List<Product2__c> product2InStore = [
+        SELECT
+          Id,
+          Name,
+          Name__c,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          OT_CODE__c,
+          Product2_Jancode__c,
+          Pro2_Dealer_ENG__c,
+          Pro2_Dealer_Object__c
+        FROM Product2__c
+        WHERE Product2_Jancode__c IN :alljanCodeList
+        ORDER BY SFDA_Expiration_Date__c DESC
+      ];
+      if (product2InStore.size() > 0) {
+        // CHAN-AVSAST
+        Map<String, String> rightBar = new Map<String, String>();
+        Map<String, String> errorMap = new Map<String, String>();
+        for (String bar : barJancodeMap.keySet()) {
+          Integer cou = 0;
+          for (Product2__c produ : product2InStore) {
+            if (
+              barJancodeMap.get(bar).containsKey(produ.Product2_Jancode__c) &&
+              !rightBar.containsKey(bar)
+            ) {
+              cou++;
+              if (EngFlag == true && produ.Pro2_Dealer_ENG__c == true) {
+                consumableInventory.add(
+                  new ConsumableorderdetailsInfo(produ, barcodeinfoMap.get(bar))
+                );
+                consumableInventoryUse.add(
+                  new ConsumableorderdetailsInfo(produ, barcodeinfoMap.get(bar))
+                );
+                rightBar.put(bar, bar);
+              } else if (
+                ETFlag == true &&
+                produ.Pro2_Dealer_Object__c == true
+              ) {
+                consumableInventory.add(
+                  new ConsumableorderdetailsInfo(produ, barcodeinfoMap.get(bar))
+                );
+                consumableInventoryUse.add(
+                  new ConsumableorderdetailsInfo(produ, barcodeinfoMap.get(bar))
+                );
+                rightBar.put(bar, bar);
+              } else {
+                errorMap.put(bar, bar);
+              }
+            }
+          }
+          if (cou <= 0) {
+            notInStorelist.add(bar);
+          }
+        }
+        if (errorMap.size() > 0) {
+          //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+          if (isLwc) {
+            errorList.add(
+              'BarCode鍙穂' +
+                errorMap.values() +
+                ']浜у搧绫诲瀷[' +
+                product_Type +
+                ']涓庣敤鎴风被鍨媅' +
+                userPro_Type +
+                ']涓嶇'
+            );
+          } else {
+            ApexPages.addmessage(
+              new ApexPages.message(
+                ApexPages.severity.ERROR,
+                'BarCode鍙穂' +
+                  errorMap.values() +
+                  ']浜у搧绫诲瀷[' +
+                  product_Type +
+                  ']涓庣敤鎴风被鍨媅' +
+                  userPro_Type +
+                  ']涓嶇'
+              )
+            );
+          }
+        }
+      }
     }
 
-    public void confimResultWithoutOrder() {
-        /*list<String> overOrderproList = new list<String>();
+    //241閫氳繃妫�绱骇鍝佹槸鍚﹀瓨鍦�
+    if (allotCodeList.size() > 0) {
+      Map<String, String> errorMap = new Map<String, String>();
+      Map<String, String> exitBarCodeMap = new Map<String, String>();
+      List<Product2__c> product2InStore = [
+        SELECT
+          Id,
+          Name,
+          Name__c,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          OT_CODE__c,
+          Product2_Jancode__c,
+          Pro2_Dealer_ENG__c,
+          Pro2_Dealer_Object__c
+        FROM Product2__c
+        WHERE
+          OT_CODE__c IN :allotCodeList
+          AND (NOT Product_Type__c LIKE :userPro_Typestr)
+      ];
+      if (product2InStore.size() > 0) {
+        for (Product2__c produ : product2InStore) {
+          for (String bar : barOtcodeMap.keySet()) {
+            if (barOtcodeMap.get(bar).containsKey(produ.OT_CODE__c)) {
+              exitBarCodeMap.put(bar, bar);
+              errorMap.put(bar, bar);
+            }
+          }
+        }
+      }
+      if (errorMap.size() > 0) {
+        //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+        if (isLwc) {
+          errorList.add(
+            'BarCode鍙穂' +
+              errorMap.values() +
+              ']浜у搧绫诲瀷[' +
+              product_Type +
+              ']涓庣敤鎴穂' +
+              userPro_Type +
+              ']绫诲瀷涓嶇'
+          );
+        } else {
+          ApexPages.addmessage(
+            new ApexPages.message(
+              ApexPages.severity.ERROR,
+              'BarCode鍙穂' +
+                errorMap.values() +
+                ']浜у搧绫诲瀷[' +
+                product_Type +
+                ']涓庣敤鎴穂' +
+                userPro_Type +
+                ']绫诲瀷涓嶇'
+            )
+          );
+        }
+      }
+      product2InStore = [
+        SELECT
+          Id,
+          Name,
+          Name__c,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          OT_CODE__c,
+          Product2_Jancode__c,
+          Pro2_Dealer_ENG__c,
+          Pro2_Dealer_Object__c
+        FROM Product2__c
+        WHERE
+          OT_CODE__c IN :allotCodeList
+          AND Product_Type__c LIKE :userPro_Typestr
+      ];
+
+      if (product2InStore.size() > 0) {
+        for (Product2__c produ : product2InStore) {
+          for (String bar : barOtcodeMap.keySet()) {
+            Date expirationDate = null;
+            String serialNoorLotNo = '';
+            String tracingCode = '';
+            String productDateStr = '';
+            Date productionDate = null;
+            String expirationDateStr = '';
+            if (barOtcodeMap.get(bar).containsKey(produ.OT_CODE__c)) {
+              Integer oTcodeLength = produ.OT_CODE__c.length();
+              if (bar.length() >= oTcodeLength + 11) {
+                if (bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '11') {
+                  try {
+                    productDateStr =
+                      '20' +
+                      bar.substring(oTcodeLength + 5, oTcodeLength + 7) +
+                      '-' +
+                      bar.substring(oTcodeLength + 7, oTcodeLength + 9) +
+                      '-01';
+                    productionDate = Date.valueOf(productDateStr);
+                  } catch (Exception e) {
+                    //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                    if (isLwc) {
+                      errorList.add(
+                        '浜у搧BarCode(' +
+                          bar +
+                          ')鐨勭敓浜ф棩鏈�' +
+                          productDateStr +
+                          '閿欒锛�'
+                      );
+                    } else {
+                      ApexPages.addmessage(
+                        new ApexPages.message(
+                          ApexPages.severity.ERROR,
+                          '浜у搧BarCode(' +
+                            bar +
+                            ')鐨勭敓浜ф棩鏈�' +
+                            productDateStr +
+                            '閿欒锛�'
+                        )
+                      );
+                    }
+                    continue;
+                  }
+                  if (bar.length() >= oTcodeLength + 3 + 16) {
+                    if (
+                      bar.substring(
+                        oTcodeLength + 3 + 8,
+                        oTcodeLength + 3 + 10
+                      ) == '17'
+                    ) {
+                      try {
+                        if (
+                          bar.substring(
+                            oTcodeLength + 3 + 14,
+                            oTcodeLength + 3 + 16
+                          ) == '00'
+                        ) {
+                          expirationDateStr =
+                            '20' +
+                            bar.substring(
+                              oTcodeLength + 3 + 10,
+                              oTcodeLength + 3 + 12
+                            ) +
+                            '-' +
+                            bar.substring(
+                              oTcodeLength + 3 + 12,
+                              oTcodeLength + 3 + 14
+                            ) +
+                            '-' +
+                            '01';
+                          expirationDate = Date.valueOf(expirationDateStr);
+                          expirationDate = expirationDate.addMonths(1)
+                            .toStartofMonth()
+                            .addDays(-1);
+                        } else {
+                          expirationDateStr =
+                            '20' +
+                            bar.substring(
+                              oTcodeLength + 3 + 10,
+                              oTcodeLength + 3 + 12
+                            ) +
+                            '-' +
+                            bar.substring(
+                              oTcodeLength + 3 + 12,
+                              oTcodeLength + 3 + 14
+                            ) +
+                            '-' +
+                            bar.substring(
+                              oTcodeLength + 3 + 14,
+                              oTcodeLength + 3 + 16
+                            );
+                          expirationDate = Date.valueOf(expirationDateStr);
+                        }
+                      } catch (Exception e) {
+                        //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                        if (isLwc) {
+                          errorList.add(
+                            '浜у搧BarCode(' +
+                              bar +
+                              ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                              expirationDateStr +
+                              '閿欒锛�'
+                          );
+                        } else {
+                          ApexPages.addmessage(
+                            new ApexPages.message(
+                              ApexPages.severity.ERROR,
+                              '浜у搧BarCode(' +
+                                bar +
+                                ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                                expirationDateStr +
+                                '閿欒锛�'
+                            )
+                          );
+                        }
+                        continue;
+                      }
+                      if (bar.length() >= oTcodeLength + 3 + 25) {
+                        if (
+                          bar.substring(
+                            oTcodeLength + 3 + 16,
+                            oTcodeLength + 3 + 18
+                          ) == '10' ||
+                          bar.substring(
+                            oTcodeLength + 3 + 16,
+                            oTcodeLength + 3 + 18
+                          ) == '21'
+                        ) {
+                          serialNoorLotNo = bar.substring(
+                            oTcodeLength + 3 + 18,
+                            bar.length() - 8
+                          );
+                          //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
+                        }
+                      }
+                    } else if (
+                      bar.substring(
+                        oTcodeLength + 3 + 8,
+                        oTcodeLength + 3 + 10
+                      ) == '10' ||
+                      bar.substring(
+                        oTcodeLength + 3 + 8,
+                        oTcodeLength + 3 + 10
+                      ) == '21'
+                    ) {
+                      serialNoorLotNo = bar.substring(
+                        oTcodeLength + 3 + 10,
+                        bar.length() - 8
+                      );
+                      //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
+                    }
+                  }
+                } else if (
+                  bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '17'
+                ) {
+                  try {
+                    if (
+                      bar.substring(
+                        oTcodeLength + 3 + 6,
+                        oTcodeLength + 3 + 8
+                      ) == '00'
+                    ) {
+                      expirationDateStr =
+                        '20' +
+                        bar.substring(
+                          oTcodeLength + 3 + 2,
+                          oTcodeLength + 3 + 4
+                        ) +
+                        '-' +
+                        bar.substring(
+                          oTcodeLength + 3 + 4,
+                          oTcodeLength + 3 + 6
+                        ) +
+                        '-01';
+                      expirationDate = Date.valueOf(expirationDateStr);
+                      expirationDate = expirationDate.addMonths(1)
+                        .toStartofMonth()
+                        .addDays(-1);
+                    } else {
+                      expirationDateStr =
+                        '20' +
+                        bar.substring(
+                          oTcodeLength + 3 + 2,
+                          oTcodeLength + 3 + 4
+                        ) +
+                        '-' +
+                        bar.substring(
+                          oTcodeLength + 3 + 4,
+                          oTcodeLength + 3 + 6
+                        ) +
+                        '-' +
+                        bar.substring(
+                          oTcodeLength + 3 + 6,
+                          oTcodeLength + 3 + 8
+                        );
+                      expirationDate = Date.valueOf(expirationDateStr);
+                    }
+                  } catch (Exception e) {
+                    //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                    if (isLwc) {
+                      errorList.add(
+                        '浜у搧BarCode(' +
+                          bar +
+                          ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                          expirationDateStr +
+                          '閿欒锛�'
+                      );
+                    } else {
+                      ApexPages.addmessage(
+                        new ApexPages.message(
+                          ApexPages.severity.ERROR,
+                          '浜у搧BarCode(' +
+                            bar +
+                            ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                            expirationDateStr +
+                            '閿欒锛�'
+                        )
+                      );
+                    }
+                    continue;
+                  }
+                  if (bar.length() >= oTcodeLength + 20) {
+                    if (
+                      bar.substring(
+                        oTcodeLength + 3 + 8,
+                        oTcodeLength + 3 + 10
+                      ) == '10' ||
+                      bar.substring(
+                        oTcodeLength + 3 + 8,
+                        oTcodeLength + 3 + 10
+                      ) == '21'
+                    ) {
+                      serialNoorLotNo = bar.substring(
+                        oTcodeLength + 3 + 10,
+                        bar.length() - 8
+                      );
+                    }
+                  }
+                } else if (bar.length() >= oTcodeLength + 12) {
+                  if (
+                    bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '10' ||
+                    bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '21'
+                  ) {
+                    serialNoorLotNo = bar.substring(
+                      oTcodeLength + 3 + 2,
+                      bar.length() - 8
+                    );
+                  }
+                }
+              }
+              if (
+                bar.length() >= oTcodeLength + 3 + 8 &&
+                bar.substring(bar.length() - 8, bar.length() - 5) == '250'
+              ) {
+                if (
+                  bar.substring(bar.length() - 8, bar.length() - 5) == '250'
+                ) {
+                  tracingCode = bar.substring(bar.length() - 5, bar.length());
+                  Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
+                  if (n.find()) {
+                    // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
+                    if (tracingCode.length() == 5) {
+                      String tr = tracingCode;
+                      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()
+                      ) {
+                        String str = '绠$悊缂栫爜涓嶆纭紝璇蜂笌绠$悊鍛樼‘璁ゆ槸鍚﹂敊璇��';
+                        //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                        if (isLwc) {
+                          errorList.add(
+                            '浜у搧BarCode(' +
+                              bar +
+                              ')绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�'
+                          );
+                        } else {
+                          ApexPages.addmessage(
+                            new ApexPages.message(
+                              ApexPages.severity.ERROR,
+                              '浜у搧BarCode(' +
+                                bar +
+                                ')绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�'
+                            )
+                          );
+                        }
+                        continue;
+                      }
+                    }
+                    // String str = '绠$悊缂栫爜涓嶆纭紝璇蜂笌绠$悊鍛樼‘璁ゆ槸鍚﹂敊璇��';
+                    // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒锛�'));
+                    // continue;
+                    // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
+                  }
+                } else {
+                  //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                  if (isLwc) {
+                    errorList.add(
+                      '浜у搧BarCode(' + bar + ')鐨則racingCode閿欒锛�'
+                    );
+                  } else {
+                    ApexPages.addmessage(
+                      new ApexPages.message(
+                        ApexPages.severity.ERROR,
+                        '浜у搧BarCode(' + bar + ')鐨則racingCode閿欒锛�'
+                      )
+                    );
+                  }
+                  continue;
+                }
+              }
+              exitBarCodeMap.put(bar, bar);
+              List<String> barcodedetList = new List<String>();
+              barcodedetList.add(bar);
+              barcodedetList.add(String.valueOf(expirationDate));
+              barcodedetList.add(serialNoorLotNo);
+              barcodedetList.add(tracingCode);
+              consumableInventory.add(
+                new ConsumableorderdetailsInfo(produ, barcodedetList)
+              );
+              consumableInventoryUse.add(
+                new ConsumableorderdetailsInfo(produ, barcodedetList)
+              );
+            }
+          }
+        }
+      }
+      for (String bartxt : barCode241List) {
+        if (!exitBarCodeMap.containsKey(bartxt)) {
+          if (!errorMap.containsKey(bartxt)) {
+            notInStorelist.add(bartxt);
+          }
+        }
+      }
+    }
+  }
+
+  public void inventoryEntry(List<String> barCodeList) {
+    //鎵�鏈塨arcode瑙f瀽鍒扮殑Jancode
+    List<String> alljanCodeList = new List<String>();
+    List<String> allotCodeList = new List<String>();
+    List<String> barCode01List = new List<String>();
+    List<String> barCode241List = new List<String>();
+    Map<String, Map<String, String>> barJancodeMap = new Map<String, Map<String, String>>();
+    Map<String, Map<String, String>> barOtcodeMap = new Map<String, Map<String, String>>();
+    Map<String, List<String>> barcodeinfoMap = new Map<String, List<String>>();
+    notInStorelist.clear();
+    notEqualBARcodeCunMap.clear();
+    Map<String, String> orderdetailMap = new Map<String, String>();
+    List<Consumable_Orderdetails__c> orderdetail = [
+      SELECT
+        Id,
+        Name,
+        Consumable_order__c,
+        Consumable_Product__c,
+        Asset_Model_No__c
+      FROM Consumable_Orderdetails__c
+      WHERE
+        Consumable_order__r.Dealer_Info__c = :accountid
+        AND Consumable_order__c != NULL
+        AND Consumable_order__c = :ESetId
+        AND Order_Owner_WorkLocal__c = :userWorkLocation
+      ORDER BY Name
+    ];
+    for (Integer i = 0; i < orderdetail.size(); i++) {
+      orderdetailMap.put(
+        orderdetail[i].Consumable_Product__c,
+        orderdetail[i].Consumable_Product__c
+      );
+    }
+
+    for (Integer i = 0; i < barCodeList.size(); i++) {
+      Date expirationDate = null;
+      String serialNoorLotNo = '';
+      String tracingCode = '';
+      String productDateStr = '';
+      Date productionDate = null;
+      String expirationDateStr = '';
+
+      if (barCodeList[i].substring(0, 2) == '01') {
+        String janCodeMark = '';
+        //鐢熶骇鏃ユ湡
+        List<String> janCode = new List<String>();
+        if (barCodeList[i].length() < 16) {
+          //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+          if (isLwc) {
+            errorList.add(
+              '浜у搧BarCode(' +
+                barCodeList[i] +
+                ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'
+            );
+          } else {
+            ApexPages.addmessage(
+              new ApexPages.message(
+                ApexPages.severity.ERROR,
+                '浜у搧BarCode(' +
+                  barCodeList[i] +
+                  ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'
+              )
+            );
+          }
+          continue;
+        } else {
+          janCodeMark = barCodeList[i].substring(2, 16);
+          try {
+            Decimal test = Decimal.valueOf(janCodeMark);
+          } catch (Exception e) {
+            //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+            if (isLwc) {
+              errorList.add(
+                '浜у搧BarCode(' + barCodeList[i] + ')鐨刯anCode閿欒锛�'
+              );
+            } else {
+              ApexPages.addmessage(
+                new ApexPages.message(
+                  ApexPages.severity.ERROR,
+                  '浜у搧BarCode(' + barCodeList[i] + ')鐨刯anCode閿欒锛�'
+                )
+              );
+            }
+            continue;
+          }
+        }
+        if (barCodeList[i].length() >= 22) {
+          if (
+            barCodeList[i]
+              .substring(
+                barCodeList[i].length() - 8,
+                barCodeList[i].length() - 5
+              ) != '250'
+          ) {
+            //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+            if (isLwc) {
+              errorList.add(
+                '浜у搧BarCode(' + barCodeList[i] + ')娌℃湁绠$悊缂栫爜锛�'
+              );
+            } else {
+              ApexPages.addmessage(
+                new ApexPages.message(
+                  ApexPages.severity.ERROR,
+                  '浜у搧BarCode(' + barCodeList[i] + ')娌℃湁绠$悊缂栫爜锛�'
+                )
+              );
+            }
+            continue;
+          }
+          if (barCodeList[i].substring(16, 18) == '11') {
+            try {
+              productDateStr =
+                '20' +
+                barCodeList[i].substring(18, 20) +
+                '-' +
+                barCodeList[i].substring(20, 22) +
+                '-01';
+              productionDate = Date.valueOf(productDateStr);
+            } catch (Exception e) {
+              //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+              if (isLwc) {
+                errorList.add(
+                  '浜у搧BarCode(' +
+                    barCodeList[i] +
+                    ')鐨勭敓浜ф棩鏈�' +
+                    productDateStr +
+                    '閿欒锛�'
+                );
+              } else {
+                ApexPages.addmessage(
+                  new ApexPages.message(
+                    ApexPages.severity.ERROR,
+                    '浜у搧BarCode(' +
+                      barCodeList[i] +
+                      ')鐨勭敓浜ф棩鏈�' +
+                      productDateStr +
+                      '閿欒锛�'
+                  )
+                );
+              }
+              continue;
+            }
+            if (barCodeList[i].length() >= 32) {
+              if (barCodeList[i].substring(24, 26) == '17') {
+                try {
+                  if (barCodeList[i].substring(30, 32) == '00') {
+                    expirationDateStr =
+                      '20' +
+                      barCodeList[i].substring(26, 28) +
+                      '-' +
+                      barCodeList[i].substring(28, 30) +
+                      '-' +
+                      '01';
+                    expirationDate = Date.valueOf(expirationDateStr);
+                    expirationDate = expirationDate.addMonths(1)
+                      .toStartofMonth()
+                      .addDays(-1);
+                  } else {
+                    expirationDateStr =
+                      '20' +
+                      barCodeList[i].substring(26, 28) +
+                      '-' +
+                      barCodeList[i].substring(28, 30) +
+                      '-' +
+                      barCodeList[i].substring(30, 32);
+                    expirationDate = Date.valueOf(expirationDateStr);
+                  }
+                } catch (Exception e) {
+                  //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                  if (isLwc) {
+                    errorList.add(
+                      '浜у搧BarCode(' +
+                        barCodeList[i] +
+                        ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                        expirationDateStr +
+                        '閿欒锛�'
+                    );
+                  } else {
+                    ApexPages.addmessage(
+                      new ApexPages.message(
+                        ApexPages.severity.ERROR,
+                        '浜у搧BarCode(' +
+                          barCodeList[i] +
+                          ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                          expirationDateStr +
+                          '閿欒锛�'
+                      )
+                    );
+                  }
+                  continue;
+                }
+                if (barCodeList[i].length() >= 42) {
+                  if (
+                    barCodeList[i].substring(32, 34) == '10' ||
+                    barCodeList[i].substring(32, 34) == '21'
+                  ) {
+                    serialNoorLotNo = barCodeList[i]
+                      .substring(34, barCodeList[i].length() - 8);
+                  }
+                }
+              } else if (
+                barCodeList[i].substring(24, 26) == '10' ||
+                barCodeList[i].substring(24, 26) == '21'
+              ) {
+                serialNoorLotNo = barCodeList[i]
+                  .substring(26, barCodeList[i].length() - 8);
+              }
+            }
+          } else if (barCodeList[i].substring(16, 18) == '17') {
+            try {
+              if (barCodeList[i].substring(22, 24) == '00') {
+                expirationDateStr =
+                  '20' +
+                  barCodeList[i].substring(18, 20) +
+                  '-' +
+                  barCodeList[i].substring(20, 22) +
+                  '-01';
+                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧expirationDateStr' + expirationDateStr));
+                expirationDate = Date.valueOf(expirationDateStr);
+                expirationDate = expirationDate.addMonths(1)
+                  .toStartofMonth()
+                  .addDays(-1);
+              } else {
+                expirationDateStr =
+                  '20' +
+                  barCodeList[i].substring(18, 20) +
+                  '-' +
+                  barCodeList[i].substring(20, 22) +
+                  '-' +
+                  barCodeList[i].substring(22, 24);
+                expirationDate = Date.valueOf(expirationDateStr);
+              }
+            } catch (Exception e) {
+              //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+              if (isLwc) {
+                errorList.add(
+                  '浜у搧BarCode(' +
+                    barCodeList[i] +
+                    ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                    expirationDateStr +
+                    '閿欒锛�'
+                );
+              } else {
+                ApexPages.addmessage(
+                  new ApexPages.message(
+                    ApexPages.severity.ERROR,
+                    '浜у搧BarCode(' +
+                      barCodeList[i] +
+                      ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                      expirationDateStr +
+                      '閿欒锛�'
+                  )
+                );
+              }
+              continue;
+            }
+            if (barCodeList[i].length() >= 34) {
+              if (
+                barCodeList[i].substring(24, 26) == '10' ||
+                barCodeList[i].substring(24, 26) == '21'
+              ) {
+                serialNoorLotNo = barCodeList[i]
+                  .substring(26, barCodeList[i].length() - 8);
+              }
+            }
+          } else if (barCodeList[i].length() >= 26) {
+            if (
+              barCodeList[i].substring(16, 18) == '10' ||
+              barCodeList[i].substring(16, 18) == '21'
+            ) {
+              serialNoorLotNo = barCodeList[i]
+                .substring(18, barCodeList[i].length() - 8);
+            }
+          }
+        }
+        if (
+          barCodeList[i].length() >= 24 &&
+          barCodeList[i]
+            .substring(
+              barCodeList[i].length() - 8,
+              barCodeList[i].length() - 5
+            ) == '250'
+        ) {
+          if (
+            barCodeList[i]
+              .substring(
+                barCodeList[i].length() - 8,
+                barCodeList[i].length() - 5
+              ) == '250'
+          ) {
+            tracingCode = barCodeList[i]
+              .substring(barCodeList[i].length() - 5, barCodeList[i].length());
+            Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
+            if (n.find()) {
+              // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
+              if (tracingCode.length() == 5) {
+                String tr = tracingCode;
+                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()
+                ) {
+                  String str = '绠$悊缂栫爜涓嶆纭紝璇蜂笌绠$悊鍛樼‘璁ゆ槸鍚﹂敊璇��';
+                  //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                  if (isLwc) {
+                    errorList.add(
+                      '浜у搧BarCode(' +
+                        barCodeList[i] +
+                        ')绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�'
+                    );
+                  } else {
+                    ApexPages.addmessage(
+                      new ApexPages.message(
+                        ApexPages.severity.ERROR,
+                        '浜у搧BarCode(' +
+                          barCodeList[i] +
+                          ')绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�'
+                      )
+                    );
+                  }
+                  continue;
+                }
+              }
+              // String str = '绠$悊缂栫爜涓嶆纭紝璇蜂笌绠$悊鍛樼‘璁ゆ槸鍚﹂敊璇��';
+              // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + barCodeList[i] + ')绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒锛�'));
+              // continue;
+              // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
+            }
+          } else {
+            //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+            if (isLwc) {
+              errorList.add(
+                '浜у搧BarCode(' + barCodeList[i] + ')鐨則racingCode閿欒锛�'
+              );
+            } else {
+              ApexPages.addmessage(
+                new ApexPages.message(
+                  ApexPages.severity.ERROR,
+                  '浜у搧BarCode(' + barCodeList[i] + ')鐨則racingCode閿欒锛�'
+                )
+              );
+            }
+            continue;
+          }
+        }
+        List<String> barcodedetList = new List<String>();
+        barcodedetList.add(barCodeList[i]);
+        barcodedetList.add(String.valueOf(expirationDate));
+        barcodedetList.add(serialNoorLotNo);
+        barcodedetList.add(tracingCode);
+        Integer jan1 = Integer.valueOf(janCodeMark.substring(0, 1));
+        Integer jan2 = Integer.valueOf(janCodeMark.substring(1, 2));
+        Integer jan3 = Integer.valueOf(janCodeMark.substring(2, 3));
+        Integer jan4 = Integer.valueOf(janCodeMark.substring(3, 4));
+        Integer jan5 = Integer.valueOf(janCodeMark.substring(4, 5));
+        Integer jan6 = Integer.valueOf(janCodeMark.substring(5, 6));
+        Integer jan7 = Integer.valueOf(janCodeMark.substring(6, 7));
+        Integer jan8 = Integer.valueOf(janCodeMark.substring(7, 8));
+        Integer jan9 = Integer.valueOf(janCodeMark.substring(8, 9));
+        Integer jan10 = Integer.valueOf(janCodeMark.substring(9, 10));
+        Integer jan11 = Integer.valueOf(janCodeMark.substring(10, 11));
+        Integer jan12 = Integer.valueOf(janCodeMark.substring(11, 12));
+        Integer jan13 = Integer.valueOf(janCodeMark.substring(12, 13));
+        Integer count12 =
+          jan2 +
+          jan3 * 3 +
+          jan4 +
+          jan5 * 3 +
+          jan6 +
+          jan7 * 3 +
+          jan8 +
+          jan9 * 3 +
+          jan10 +
+          jan11 * 3 +
+          jan12 +
+          jan13 * 3;
+
+        Integer count13 =
+          jan1 * 3 +
+          jan2 +
+          jan3 * 3 +
+          jan4 +
+          jan5 * 3 +
+          jan6 +
+          jan7 * 3 +
+          jan8 +
+          jan9 * 3 +
+          jan10 +
+          jan11 * 3 +
+          jan12 +
+          jan13 * 3;
+        String frost12 = (String.valueOf(count12))
+          .substring((String.valueOf(count12)).length() - 1);
+        String frost13 = (String.valueOf(count13))
+          .substring((String.valueOf(count13)).length() - 1);
+        //鍑忓幓12浣嶄釜浣�4
+        frost12 = (String.valueOf(10 - Integer.valueOf(frost12)))
+          .substring(
+            (String.valueOf(10 - Integer.valueOf(frost12))).length() - 1
+          );
+        frost13 = (String.valueOf(10 - Integer.valueOf(frost13)))
+          .substring(
+            (String.valueOf(10 - Integer.valueOf(frost13))).length() - 1
+          );
+
+        janCode.add(janCodeMark.substring(1, 13) + frost12);
+        janCode.add(janCodeMark.substring(0, 13) + frost12);
+        janCode.add(janCodeMark.substring(1, 13) + frost13);
+        janCode.add(janCodeMark.substring(0, 13) + frost13);
+        alljanCodeList.addAll(janCode);
+        Map<String, String> janCodeMap = new Map<String, String>();
+        janCodeMap.put(janCodeMark.substring(1, 13) + frost12, barCodeList[i]);
+        janCodeMap.put(janCodeMark.substring(0, 13) + frost12, barCodeList[i]);
+        janCodeMap.put(janCodeMark.substring(1, 13) + frost13, barCodeList[i]);
+        janCodeMap.put(janCodeMark.substring(0, 13) + frost13, barCodeList[i]);
+        barJancodeMap.put(barCodeList[i], janCodeMap);
+        barcodeinfoMap.put(barCodeList[i], barcodedetList);
+        barCode01List.add(barCodeList[i]);
+      } else if (barCodeList[i].substring(0, 3) == '241') {
+        if (
+          barCodeList[i].length() > 8 &&
+          barCodeList[i]
+            .substring(
+              barCodeList[i].length() - 8,
+              barCodeList[i].length() - 5
+            ) != '250'
+        ) {
+          //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+          if (isLwc) {
+            errorList.add('浜у搧BarCode(' + barCodeList[i] + ')娌℃湁绠$悊缂栫爜锛�');
+          } else {
+            ApexPages.addmessage(
+              new ApexPages.message(
+                ApexPages.severity.ERROR,
+                '浜у搧BarCode(' + barCodeList[i] + ')娌℃湁绠$悊缂栫爜锛�'
+              )
+            );
+          }
+          continue;
+        }
+        List<String> otCodeList = new List<String>();
+        Map<String, String> otCodeMap = new Map<String, String>();
+        if (barCodeList[i].length() < 7) {
+          //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+          if (isLwc) {
+            errorList.add(
+              '浜у搧BarCode(' +
+                barCodeList[i] +
+                ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'
+            );
+          } else {
+            ApexPages.addmessage(
+              new ApexPages.message(
+                ApexPages.severity.ERROR,
+                '浜у搧BarCode(' +
+                  barCodeList[i] +
+                  ')鐨勪綅鏁颁笉瓒�16锛屼笉绗﹀悎瑕佹眰閿欒锛�'
+              )
+            );
+          }
+          continue;
+        } else if (barCodeList[i].length() == 11) {
+          String otCode4 = barCodeList[i].substring(3, 7);
+          String otCode5 = barCodeList[i].substring(3, 8);
+          String otCode6 = barCodeList[i].substring(3, 9);
+          String otCode7 = barCodeList[i].substring(3, 10);
+          String otCode8 = barCodeList[i].substring(3, 11);
+          otCodeList.add(otCode4);
+          otCodeList.add(otCode5);
+          otCodeList.add(otCode6);
+          otCodeList.add(otCode7);
+          otCodeList.add(otCode8);
+          otCodeMap.put(otCode4, barCodeList[i]);
+          otCodeMap.put(otCode5, barCodeList[i]);
+          otCodeMap.put(otCode6, barCodeList[i]);
+          otCodeMap.put(otCode7, barCodeList[i]);
+          otCodeMap.put(otCode8, barCodeList[i]);
+        } else if (barCodeList[i].length() >= 12) {
+          String otCode4 = barCodeList[i].substring(3, 7);
+          String otCode5 = barCodeList[i].substring(3, 8);
+          String otCode6 = barCodeList[i].substring(3, 9);
+          String otCode7 = barCodeList[i].substring(3, 10);
+          String otCode8 = barCodeList[i].substring(3, 11);
+          String otCode9 = barCodeList[i].substring(3, 12);
+          otCodeList.add(otCode4);
+          otCodeList.add(otCode5);
+          otCodeList.add(otCode6);
+          otCodeList.add(otCode7);
+          otCodeList.add(otCode8);
+          otCodeList.add(otCode9);
+          otCodeMap.put(otCode4, barCodeList[i]);
+          otCodeMap.put(otCode5, barCodeList[i]);
+          otCodeMap.put(otCode6, barCodeList[i]);
+          otCodeMap.put(otCode7, barCodeList[i]);
+          otCodeMap.put(otCode8, barCodeList[i]);
+          otCodeMap.put(otCode9, barCodeList[i]);
+        }
+        allotCodeList.addAll(otCodeList);
+        barOtcodeMap.put(barCodeList[i], otCodeMap);
+        barCode241List.add(barCodeList[i]);
+      } else {
+        //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+        if (isLwc) {
+          errorList.add(
+            '浜у搧BarCode(' +
+              barCodeList[i] +
+              ')娌℃湁janCode鎴朞Tcode锛屼笉绗﹀悎瑕佹眰锛�'
+          );
+        } else {
+          ApexPages.addmessage(
+            new ApexPages.message(
+              ApexPages.severity.ERROR,
+              '浜у搧BarCode(' +
+                barCodeList[i] +
+                ')娌℃湁janCode鎴朞Tcode锛屼笉绗﹀悎瑕佹眰锛�'
+            )
+          );
+        }
+        continue;
+      }
+    }
+    //01閫氳繃妫�绱骇鍝佹槸鍚﹀瓨鍦�
+    Map<String, String> rightBar = new Map<String, String>();
+    if (alljanCodeList.size() > 0) {
+      Map<String, String> exitBarCodeMap = new Map<String, String>();
+      List<Product2__c> product2InStore = [
+        SELECT
+          Id,
+          Name,
+          Name__c,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          OT_CODE__c,
+          Product2_Jancode__c,
+          Pro2_Dealer_ENG__c,
+          Pro2_Dealer_Object__c,
+          Product_Type__c
+        FROM Product2__c
+        WHERE
+          Product2_Jancode__c IN :alljanCodeList
+          AND (NOT Product_Type__c LIKE :userPro_Typestr)
+        ORDER BY SFDA_Expiration_Date__c DESC
+      ];
+      if (product2InStore.size() > 0) {
+        Map<String, String> errorMap = new Map<String, String>();
+        for (Product2__c produ : product2InStore) {
+          for (String bar : barJancodeMap.keySet()) {
+            if (
+              barJancodeMap.get(bar).containsKey(produ.Product2_Jancode__c) &&
+              !rightBar.containsKey(bar)
+            ) {
+              exitBarCodeMap.put(bar, bar);
+              errorMap.put(bar, bar);
+            }
+          }
+        }
+        if (errorMap.size() > 0) {
+          //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+          if (isLwc) {
+            errorList.add(
+              'BarCode鍙穂' +
+                errorMap.values() +
+                ']浜у搧绫诲瀷[' +
+                product_Type +
+                ']涓庣敤鎴风殑绫诲瀷[' +
+                userPro_Type +
+                ']涓嶇'
+            );
+          } else {
+            ApexPages.addmessage(
+              new ApexPages.message(
+                ApexPages.severity.ERROR,
+                'BarCode鍙穂' +
+                  errorMap.values() +
+                  ']浜у搧绫诲瀷[' +
+                  product_Type +
+                  ']涓庣敤鎴风殑绫诲瀷[' +
+                  userPro_Type +
+                  ']涓嶇'
+              )
+            );
+          }
+        }
+      }
+      product2InStore = [
+        SELECT
+          Id,
+          Name,
+          Name__c,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          OT_CODE__c,
+          Product2_Jancode__c,
+          Pro2_Dealer_ENG__c,
+          Pro2_Dealer_Object__c,
+          Product_Type__c
+        FROM Product2__c
+        WHERE
+          Product2_Jancode__c IN :alljanCodeList
+          AND Product_Type__c LIKE :userPro_Typestr
+        ORDER BY SFDA_Expiration_Date__c DESC
+      ];
+      if (product2InStore.size() > 0) {
+        Map<String, String> errorMap = new Map<String, String>();
+        for (Product2__c produ : product2InStore) {
+          for (String bar : barJancodeMap.keySet()) {
+            if (
+              barJancodeMap.get(bar).containsKey(produ.Product2_Jancode__c) &&
+              !rightBar.containsKey(bar)
+            ) {
+              exitBarCodeMap.put(bar, bar);
+              if (orderdetailMap.containsKey(produ.Id)) {
+                consumableInventory.add(
+                  new ConsumableorderdetailsInfo(produ, barcodeinfoMap.get(bar))
+                );
+                rightBar.put(bar, bar);
+              } else {
+                consumableInventory.add(
+                  new ConsumableorderdetailsInfo(produ, barcodeinfoMap.get(bar))
+                );
+                rightBar.put(bar, bar);
+                list<String> overOrderBARcodeCunList = new List<String>();
+                if (notEqualBARcodeCunMap.containsKey(produ.Id)) {
+                  overOrderBARcodeCunList = notEqualBARcodeCunMap.get(produ.Id)
+                    .clone();
+                  overOrderBARcodeCunList.add(bar);
+                  notEqualBARcodeCunMap.put(produ.Id, overOrderBARcodeCunList);
+                } else {
+                  overOrderBARcodeCunList.add(bar);
+                  notEqualBARcodeCunMap.put(produ.Id, overOrderBARcodeCunList);
+                }
+              }
+            }
+          }
+        }
+      }
+      for (String bartxt : barCode01List) {
+        if (!exitBarCodeMap.containsKey(bartxt)) {
+          notInStorelist.add(bartxt);
+        }
+      }
+    }
+
+    //241閫氳繃妫�绱骇鍝佹槸鍚﹀瓨鍦�
+    if (allotCodeList.size() > 0) {
+      Map<String, String> exitBarCodeMap = new Map<String, String>();
+      Map<String, String> errorMap = new Map<String, String>();
+      List<Product2__c> product2InStore = [
+        SELECT
+          Id,
+          Name,
+          Name__c,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          OT_CODE__c,
+          Pro2_Dealer_Object__c,
+          Pro2_Dealer_ENG__c
+        FROM Product2__c
+        WHERE
+          OT_CODE__c IN :allotCodeList
+          AND (NOT Product_Type__c LIKE :userPro_Typestr)
+      ];
+      if (product2InStore.size() > 0) {
+        for (Product2__c produ : product2InStore) {
+          for (String bar : barOtcodeMap.keySet()) {
+            if (barOtcodeMap.get(bar).containsKey(produ.OT_CODE__c)) {
+              exitBarCodeMap.put(bar, bar);
+              errorMap.put(bar, bar);
+            }
+          }
+        }
+      }
+      if (errorMap.size() > 0) {
+        //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+        if (isLwc) {
+          errorList.add(
+            'BarCode鍙穂' +
+              errorMap.values() +
+              ']浜у搧绫诲瀷[' +
+              product_Type +
+              ']涓庣敤鎴穂' +
+              userPro_Type +
+              ']绫诲瀷涓嶇'
+          );
+        } else {
+          ApexPages.addmessage(
+            new ApexPages.message(
+              ApexPages.severity.ERROR,
+              'BarCode鍙穂' +
+                errorMap.values() +
+                ']浜у搧绫诲瀷[' +
+                product_Type +
+                ']涓庣敤鎴穂' +
+                userPro_Type +
+                ']绫诲瀷涓嶇'
+            )
+          );
+        }
+      }
+      product2InStore = [
+        SELECT
+          Id,
+          Name,
+          Name__c,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          OT_CODE__c,
+          Pro2_Dealer_Object__c,
+          Pro2_Dealer_ENG__c
+        FROM Product2__c
+        WHERE
+          OT_CODE__c IN :allotCodeList
+          AND Product_Type__c LIKE :userPro_Typestr
+      ];
+
+      if (product2InStore.size() > 0) {
+        for (Product2__c produ : product2InStore) {
+          for (String bar : barOtcodeMap.keySet()) {
+            Date expirationDate = null;
+            String serialNoorLotNo = '';
+            String tracingCode = '';
+            String productDateStr = '';
+            Date productionDate = null;
+            String expirationDateStr = '';
+            Integer oTcodeLength = produ.OT_CODE__c.length();
+
+            if (bar.length() >= oTcodeLength + 11) {
+              if (bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '11') {
+                try {
+                  productDateStr =
+                    '20' +
+                    bar.substring(oTcodeLength + 5, oTcodeLength + 7) +
+                    '-' +
+                    bar.substring(oTcodeLength + 7, oTcodeLength + 9) +
+                    '-01';
+                  productionDate = Date.valueOf(productDateStr);
+                } catch (Exception e) {
+                  //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                  if (isLwc) {
+                    errorList.add(
+                      '浜у搧BarCode(' +
+                        bar +
+                        ')鐨勭敓浜ф棩鏈�' +
+                        productDateStr +
+                        '閿欒锛�'
+                    );
+                  } else {
+                    ApexPages.addmessage(
+                      new ApexPages.message(
+                        ApexPages.severity.ERROR,
+                        '浜у搧BarCode(' +
+                          bar +
+                          ')鐨勭敓浜ф棩鏈�' +
+                          productDateStr +
+                          '閿欒锛�'
+                      )
+                    );
+                  }
+                  continue;
+                }
+                if (bar.length() >= oTcodeLength + 3 + 16) {
+                  //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode17' + bar.substring(oTcodeLength + 3 + 8,oTcodeLength + 3 + 10)));
+                  if (
+                    bar.substring(
+                      oTcodeLength + 3 + 8,
+                      oTcodeLength + 3 + 10
+                    ) == '17'
+                  ) {
+                    try {
+                      if (
+                        bar.substring(
+                          oTcodeLength + 3 + 14,
+                          oTcodeLength + 3 + 16
+                        ) == '00'
+                      ) {
+                        expirationDateStr =
+                          '20' +
+                          bar.substring(
+                            oTcodeLength + 3 + 10,
+                            oTcodeLength + 3 + 12
+                          ) +
+                          '-' +
+                          bar.substring(
+                            oTcodeLength + 3 + 12,
+                            oTcodeLength + 3 + 14
+                          ) +
+                          '-' +
+                          '01';
+                        expirationDate = Date.valueOf(expirationDateStr);
+                        expirationDate = expirationDate.addMonths(1)
+                          .toStartofMonth()
+                          .addDays(-1);
+                      } else {
+                        expirationDateStr =
+                          '20' +
+                          bar.substring(
+                            oTcodeLength + 3 + 10,
+                            oTcodeLength + 3 + 12
+                          ) +
+                          '-' +
+                          bar.substring(
+                            oTcodeLength + 3 + 12,
+                            oTcodeLength + 3 + 14
+                          ) +
+                          '-' +
+                          bar.substring(
+                            oTcodeLength + 3 + 14,
+                            oTcodeLength + 3 + 16
+                          );
+                        expirationDate = Date.valueOf(expirationDateStr);
+                      }
+                    } catch (Exception e) {
+                      //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                      if (isLwc) {
+                        errorList.add(
+                          '浜у搧BarCode(' +
+                            bar +
+                            ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                            expirationDateStr +
+                            '閿欒锛�'
+                        );
+                      } else {
+                        ApexPages.addmessage(
+                          new ApexPages.message(
+                            ApexPages.severity.ERROR,
+                            '浜у搧BarCode(' +
+                              bar +
+                              ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                              expirationDateStr +
+                              '閿欒锛�'
+                          )
+                        );
+                      }
+                      continue;
+                    }
+                    if (bar.length() >= oTcodeLength + 3 + 25) {
+                      if (
+                        bar.substring(
+                          oTcodeLength + 3 + 16,
+                          oTcodeLength + 3 + 18
+                        ) == '10' ||
+                        bar.substring(
+                          oTcodeLength + 3 + 16,
+                          oTcodeLength + 3 + 18
+                        ) == '21'
+                      ) {
+                        serialNoorLotNo = bar.substring(
+                          oTcodeLength + 3 + 18,
+                          bar.length() - 8
+                        );
+                        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
+                      }
+                    }
+                  } else if (
+                    bar.substring(
+                      oTcodeLength + 3 + 8,
+                      oTcodeLength + 3 + 10
+                    ) == '10' ||
+                    bar.substring(
+                      oTcodeLength + 3 + 8,
+                      oTcodeLength + 3 + 10
+                    ) == '21'
+                  ) {
+                    serialNoorLotNo = bar.substring(
+                      oTcodeLength + 3 + 10,
+                      bar.length() - 8
+                    );
+                    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,  'serialNoorLotNo' + serialNoorLotNo));
+                  }
+                }
+              } else if (
+                bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '17'
+              ) {
+                try {
+                  if (
+                    bar.substring(oTcodeLength + 3 + 6, oTcodeLength + 3 + 8) ==
+                    '00'
+                  ) {
+                    expirationDateStr =
+                      '20' +
+                      bar.substring(
+                        oTcodeLength + 3 + 2,
+                        oTcodeLength + 3 + 4
+                      ) +
+                      '-' +
+                      bar.substring(
+                        oTcodeLength + 3 + 4,
+                        oTcodeLength + 3 + 6
+                      ) +
+                      '-01';
+                    expirationDate = Date.valueOf(expirationDateStr);
+                    expirationDate = expirationDate.addMonths(1)
+                      .toStartofMonth()
+                      .addDays(-1);
+                  } else {
+                    expirationDateStr =
+                      '20' +
+                      bar.substring(
+                        oTcodeLength + 3 + 2,
+                        oTcodeLength + 3 + 4
+                      ) +
+                      '-' +
+                      bar.substring(
+                        oTcodeLength + 3 + 4,
+                        oTcodeLength + 3 + 6
+                      ) +
+                      '-' +
+                      bar.substring(oTcodeLength + 3 + 6, oTcodeLength + 3 + 8);
+                    expirationDate = Date.valueOf(expirationDateStr);
+                  }
+                } catch (Exception e) {
+                  //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                  if (isLwc) {
+                    errorList.add(
+                      '浜у搧BarCode(' +
+                        bar +
+                        ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                        expirationDateStr +
+                        '閿欒锛�'
+                    );
+                  } else {
+                    ApexPages.addmessage(
+                      new ApexPages.message(
+                        ApexPages.severity.ERROR,
+                        '浜у搧BarCode(' +
+                          bar +
+                          ')鐨勬粎鑿屾湁鍔规湡闄�' +
+                          expirationDateStr +
+                          '閿欒锛�'
+                      )
+                    );
+                  }
+                  continue;
+                }
+                if (bar.length() >= oTcodeLength + 20) {
+                  if (
+                    bar.substring(
+                      oTcodeLength + 3 + 8,
+                      oTcodeLength + 3 + 10
+                    ) == '10' ||
+                    bar.substring(
+                      oTcodeLength + 3 + 8,
+                      oTcodeLength + 3 + 10
+                    ) == '21'
+                  ) {
+                    serialNoorLotNo = bar.substring(
+                      oTcodeLength + 3 + 10,
+                      bar.length() - 8
+                    );
+                  }
+                }
+              } else if (bar.length() >= oTcodeLength + 12) {
+                if (
+                  bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '10' ||
+                  bar.substring(oTcodeLength + 3, oTcodeLength + 5) == '21'
+                ) {
+                  serialNoorLotNo = bar.substring(
+                    oTcodeLength + 3 + 2,
+                    bar.length() - 8
+                  );
+                }
+              }
+            }
+            if (
+              bar.length() >= oTcodeLength + 3 + 8 &&
+              bar.substring(bar.length() - 8, bar.length() - 5) == '250'
+            ) {
+              if (bar.substring(bar.length() - 8, bar.length() - 5) == '250') {
+                tracingCode = bar.substring(bar.length() - 5, bar.length());
+                Matcher n = Pattern.compile('[0-9]').matcher(tracingCode);
+                if (n.find()) {
+                  // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
+                  if (tracingCode.length() == 5) {
+                    String tr = tracingCode;
+                    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()
+                    ) {
+                      String str = '绠$悊缂栫爜涓嶆纭紝璇蜂笌绠$悊鍛樼‘璁ゆ槸鍚﹂敊璇��';
+                      //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                      if (isLwc) {
+                        errorList.add(
+                          '浜у搧BarCode(' +
+                            bar +
+                            ')绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�'
+                        );
+                      } else {
+                        ApexPages.addmessage(
+                          new ApexPages.message(
+                            ApexPages.severity.ERROR,
+                            '浜у搧BarCode(' +
+                              bar +
+                              ')绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�'
+                          )
+                        );
+                      }
+                      continue;
+                    }
+                  }
+                  // String str = '绠$悊缂栫爜涓嶆纭紝璇蜂笌绠$悊鍛樼‘璁ゆ槸鍚﹂敊璇��';
+                  // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'浜у搧BarCode(' + bar + ')绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒锛�'));
+                  // continue;
+                  // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
+                }
+              } else {
+                //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+                if (isLwc) {
+                  errorList.add('浜у搧BarCode(' + bar + ')鐨則racingCode閿欒锛�');
+                } else {
+                  ApexPages.addmessage(
+                    new ApexPages.message(
+                      ApexPages.severity.ERROR,
+                      '浜у搧BarCode(' + bar + ')鐨則racingCode閿欒锛�'
+                    )
+                  );
+                }
+                continue;
+              }
+            }
+            List<String> barcodedetList = new List<String>();
+            barcodedetList.add(bar);
+            barcodedetList.add(String.valueOf(expirationDate));
+            barcodedetList.add(serialNoorLotNo);
+            barcodedetList.add(tracingCode);
+            if (barOtcodeMap.get(bar).containsKey(produ.OT_CODE__c)) {
+              exitBarCodeMap.put(bar, bar);
+
+              if (orderdetailMap.containsKey(produ.Id)) {
+                consumableInventory.add(
+                  new ConsumableorderdetailsInfo(produ, barcodedetList)
+                );
+              } else {
+                consumableInventory.add(
+                  new ConsumableorderdetailsInfo(produ, barcodedetList)
+                );
+                list<String> overOrderBARcodeCunList = new List<String>();
+                if (notEqualBARcodeCunMap.containsKey(produ.Id)) {
+                  overOrderBARcodeCunList = notEqualBARcodeCunMap.get(produ.Id)
+                    .clone();
+                  overOrderBARcodeCunList.add(bar);
+                  notEqualBARcodeCunMap.put(produ.Id, overOrderBARcodeCunList);
+                } else {
+                  overOrderBARcodeCunList.add(bar);
+                  notEqualBARcodeCunMap.put(produ.Id, overOrderBARcodeCunList);
+                }
+              }
+            }
+          }
+        }
+      }
+
+      for (String bartxt : barCode241List) {
+        if (!exitBarCodeMap.containsKey(bartxt)) {
+          if (!errorMap.containsKey(bartxt)) {
+            notInStorelist.add(bartxt);
+          }
+        }
+      }
+    }
+    //鍒ゆ柇浜у搧鏄惁涓�鑷�
+    if (notEqualBARcodeCunMap.size() > 0) {
+      for (String widget : notEqualBARcodeCunMap.keySet()) {
+        if (notEqualBARcodeCunMap.get(widget).size() > 0) {
+          //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+          if (isLwc) {
+            warningList.add('浠ヤ笅barcode浜у搧涓庤璐т骇鍝佷笉涓�鑷淬��');
+          } else {
+            ApexPages.addmessage(
+              new ApexPages.message(
+                ApexPages.severity.INFO,
+                '浠ヤ笅barcode浜у搧涓庤璐т骇鍝佷笉涓�鑷淬��'
+              )
+            );
+          }
+          for (
+            String barcodeListTTT : (List<String>) notEqualBARcodeCunMap.get(
+              widget
+            )
+          ) {
+            //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+            if (isLwc) {
+              warningList.add(barcodeListTTT);
+            } else {
+              ApexPages.addmessage(
+                new ApexPages.message(ApexPages.severity.INFO, barcodeListTTT)
+              );
+            }
+          }
+        }
+      }
+    }
+  }
+
+  public String ConfimResult() {
+    list<String> overOrderproList = new List<String>();
+    list<String> overOrderBARcodeCunList = new List<String>();
+    list<String> overOrderBARcodeCunListTest = new List<String>();
+    //overOrderBARcodeCunMap.clear();
+    for (ConsumableorderdetailsInfo ass : ConsumableorderdetailsRecords) {
+      if (
+        orderWantArriveCunMap.get(ass.esd.Asset_Model_No__c) +
+        orderProductArrivedCunMap.get(ass.esd.Asset_Model_No__c) >
+        orderProductCunMap.get(ass.esd.Asset_Model_No__c) - 1
+      ) {
+        // 鑾峰彇瓒呰繃瀹氳揣鏁伴噺鐨勬秷鑰楀搧淇℃伅
+        overOrderBARcodeCunList = new List<String>();
+        overOrderBARcodeCunList = overOrderBARcodeCunMap.get(
+            ass.esd.Asset_Model_No__c
+          )
+          .clone();
+        overOrderBARcodeCunList.add(ass.esd.Bar_Code__c);
+        overOrderBARcodeCunMap.put(
+          ass.esd.Asset_Model_No__c,
+          overOrderBARcodeCunList
+        );
+        overOrderCunMap.put(
+          ass.esd.Asset_Model_No__c,
+          overOrderCunMap.get(ass.esd.Asset_Model_No__c) + 1
+        );
+        cancellationProList.add(ass.esd.Asset_Model_No__c);
+      } else if (
+        orderWantArriveCunMap.get(ass.esd.Asset_Model_No__c) +
+        orderProductArrivedCunMap.get(ass.esd.Asset_Model_No__c) ==
+        orderProductCunMap.get(ass.esd.Asset_Model_No__c) - 1
+      ) {
+        consumableorderdetailsRecordsUse.add(ass);
+        cancellationProList.add(ass.esd.Asset_Model_No__c);
+      } else {
+        consumableorderdetailsRecordsUse.add(ass);
+      }
+      orderWantArriveCunMap.put(
+        ass.esd.Asset_Model_No__c,
+        orderWantArriveCunMap.get(ass.esd.Asset_Model_No__c) + 1
+      );
+    }
+    for (ConsumableorderdetailsInfo ass : consumableInventory) {
+      if (!orderWantArriveCunMap.containsKey(ass.Prod.Asset_Model_No__c)) {
+        consumableInventoryUse.add(ass);
+        continue;
+      }
+      if (
+        orderWantArriveCunMap.get(ass.Prod.Asset_Model_No__c) +
+        orderProductArrivedCunMap.get(ass.Prod.Asset_Model_No__c) >
+        orderProductCunMap.get(ass.Prod.Asset_Model_No__c) - 1
+      ) {
+        //鍙栧緱鍘熸湁list
+        overOrderBARcodeCunList = new List<String>();
+        overOrderBARcodeCunList = overOrderBARcodeCunMap.get(
+            ass.Prod.Asset_Model_No__c
+          )
+          .clone();
+        //鏇存柊list
+        overOrderBARcodeCunList.add(ass.barCodeNo);
+        //鏇存柊map
+        overOrderBARcodeCunMap.put(
+          ass.Prod.Asset_Model_No__c,
+          overOrderBARcodeCunList
+        );
+        overOrderCunMap.put(
+          ass.Prod.Asset_Model_No__c,
+          overOrderCunMap.get(ass.Prod.Asset_Model_No__c) + 1
+        );
+        cancellationProList.add(ass.Prod.Asset_Model_No__c);
+      } else if (
+        orderWantArriveCunMap.get(ass.Prod.Asset_Model_No__c) +
+        orderProductArrivedCunMap.get(ass.Prod.Asset_Model_No__c) ==
+        orderProductCunMap.get(ass.Prod.Asset_Model_No__c) - 1
+      ) {
+        consumableInventoryUse.add(ass);
+        cancellationProList.add(ass.Prod.Asset_Model_No__c);
+      } else {
+        consumableInventoryUse.add(ass);
+      }
+      orderWantArriveCunMap.put(
+        ass.Prod.Asset_Model_No__c,
+        orderWantArriveCunMap.get(ass.Prod.Asset_Model_No__c) + 1
+      );
+    }
+    for (Integer i = 0; i < productList.size(); i++) {
+      if (overOrderBARcodeCunMap.get(productList[i]).size() > 0) {
+        // 鑾峰彇瓒呰繃瀹氳揣鏁伴噺鐨勬秷鑰楀搧淇℃伅
+        overOrderproList.add(productList[i]);
+      }
+    }
+    if (overOrderproList.size() > 0) {
+      return '浜у搧' +
+        overOrderproList +
+        '鏈鍒拌揣鏁伴噺鍜屽凡鍒拌揣鏁伴噺宸茬粡瓒呰繃璁㈣揣鏁伴噺!';
+    } else {
+      return '';
+    }
+  }
+
+  public void confimResultWithoutOrder() {
+    /*list<String> overOrderproList = new list<String>();
         list<String> overOrderBARcodeCunList = new list<String>();
         orderProductCunMap.clear();
         orderProductArrivedCunMap.clear();
@@ -2602,9 +4636,9 @@
             }
         }*/
 
-        //瑕佸埌璐т骇鍝佹暟閲�
-        for (ConsumableorderdetailsInfo ass : ConsumableorderdetailsRecords)  {
-            /*if(orderWantArriveCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c) > orderProductCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c)-1){
+    //瑕佸埌璐т骇鍝佹暟閲�
+    for (ConsumableorderdetailsInfo ass : ConsumableorderdetailsRecords) {
+      /*if(orderWantArriveCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c) + orderProductArrivedCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c) > orderProductCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c)-1){
                 // 鑾峰彇瓒呰繃瀹氳揣鏁伴噺鐨勬秷鑰楀搧淇℃伅
                 overOrderproList.add('浜у搧' + ass.esd.Asset_Model_No__c + '鍦ㄨ鍗�' + ass.esd.Consumable_order_minor__r.Name + '涓秴杩囪璐ф暟閲�!\n');
                 overOrderBARcodeCunList = new list<String>();
@@ -2615,1304 +4649,1606 @@
                 consumableorderdetailsRecordsUse.add(ass);
                 orderWantArriveCunMap.put(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c,orderWantArriveCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c)+1);
             }else{*/
-                consumableorderdetailsRecordsUse.add(ass);
-            }
-            /*orderWantArriveCunMap.put(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c,orderWantArriveCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c)+1);
+      consumableorderdetailsRecordsUse.add(ass);
+    }
+    /*orderWantArriveCunMap.put(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c,orderWantArriveCunMap.get(ass.esd.Consumable_order_minor__c + ass.esd.Asset_Model_No__c)+1);
         }
         return overOrderproList;*/
+  }
+
+  // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+  // 铏氭嫙鐩樼偣鍗曟秷鑰楀搧鏄庣粏1鍒涘缓宸″洖
+  public void addInventoryDetails1(List<Consumable_order_details2__c> addList) {
+    Map<String, List<Consumable_order_details2__c>> accountGroupMap = new Map<String, List<Consumable_order_details2__c>>();
+    Map<String, Map<Id, Integer>> productMap = new Map<String, Map<Id, Integer>>();
+    List<Id> orderIdList = new List<Id>();
+    // 浠ョ粡閿�鍟嗗悕灏嗚鐢熸垚鍑哄簱鍗曠殑鏁版嵁鍒嗙粍
+    for (Consumable_order_details2__c cod : addList) {
+      List<Consumable_order_details2__c> accGroupList = new List<Consumable_order_details2__c>();
+      Map<Id, Integer> pNumMap = new Map<Id, Integer>();
+      Integer num = 1;
+      if (
+        accountGroupMap.containsKey(
+          cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c
+        )
+      ) {
+        accGroupList = accountGroupMap.get(
+          cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c
+        );
+        pNumMap = productMap.get(
+          cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c
+        );
+        if (pNumMap.containsKey(cod.Consumable_Product__c)) {
+          num = pNumMap.get(cod.Consumable_Product__c) + 1;
+        }
+      }
+      orderIdList.add(cod.Consumable_Inventory_order__c);
+      pNumMap.put(cod.Consumable_Product__c, num);
+      accGroupList.add(cod);
+      productMap.put(
+        cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c,
+        pNumMap
+      );
+      accountGroupMap.put(
+        cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c,
+        accGroupList
+      );
+      System.debug('======accGroupList' + accGroupList);
     }
 
-    // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-    // 铏氭嫙鐩樼偣鍗曟秷鑰楀搧鏄庣粏1鍒涘缓宸″洖
-    public void addInventoryDetails1(List<Consumable_order_details2__c> addList){
-        Map<String, List<Consumable_order_details2__c>> accountGroupMap = new Map<String, List<Consumable_order_details2__c>>();
-        Map<String, Map<Id, Integer>> productMap = new Map<String, Map<Id, Integer>> ();
-        List<Id> orderIdList = new List<Id> ();
-        // 浠ョ粡閿�鍟嗗悕灏嗚鐢熸垚鍑哄簱鍗曠殑鏁版嵁鍒嗙粍
-        for (Consumable_order_details2__c cod : addList) {
-            List<Consumable_order_details2__c> accGroupList = new List<Consumable_order_details2__c> ();
-            Map<Id, Integer> pNumMap = new Map<Id, Integer> ();
-            Integer num = 1;
-            if (accountGroupMap.containsKey(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c)) {
-                accGroupList = accountGroupMap.get(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c);
-                pNumMap = productMap.get(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c);
-                if (pNumMap.containsKey(cod.Consumable_Product__c)) {
-                    num = pNumMap.get(cod.Consumable_Product__c) + 1;
-                }
-            }
-            orderIdList.add(cod.Consumable_Inventory_order__c); 
-            pNumMap.put(cod.Consumable_Product__c, num);
-            accGroupList.add(cod);
-            productMap.put(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c, pNumMap);
-            accountGroupMap.put(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c, accGroupList);
-            System.debug('======accGroupList'+accGroupList);
-        }
-        
-        System.debug('======accountGroupMap'+accountGroupMap);
-        List<Consumable_order__c> orderList = [select Id, Name, Dealer_Info__r.Name, Order_Owner_WorkLocal__c from Consumable_order__c where id in : orderIdList];
+    System.debug('======accountGroupMap' + accountGroupMap);
+    List<Consumable_order__c> orderList = [
+      SELECT Id, Name, Dealer_Info__r.Name, Order_Owner_WorkLocal__c
+      FROM Consumable_order__c
+      WHERE id IN :orderIdList
+    ];
 
-        // 鐢熸垚鍚勭粡閿�鍟嗗嚭搴撹鍗昄ist
-        // List<Consumable_order__c> orderList = new List<Consumable_order__c> ();
-        Map<String, List<Consumable_orderdetails__c>> insDetail1Map = new Map<String, List<Consumable_orderdetails__c>>();
-        for (String acc : accountGroupMap.keySet()) {
-            Consumable_order_details2__c arriveAccount = accountGroupMap.get(acc)[0];
-            List<Consumable_order_details2__c> prodPriceList = accountGroupMap.get(acc);
-            Map<Id, Integer> pNumMap = new Map<Id, Integer> ();
-            pNumMap = productMap.get(acc);
-            List<Consumable_orderdetails__c> insDetail1 = New List<Consumable_orderdetails__c>();
-            for (Id id : pNumMap.keySet()) {
-                Consumable_orderdetails__c ins = new Consumable_orderdetails__c();
-                
-                //InsAfterDel.Consumable_order__c = p.id;
-                ins.Product_Refind__c = pNumMap.get(id);
-                ins.inventory_sum__c = pNumMap.get(id);
-                ins.Consumable_Product__c = id;
-                for (Consumable_order_details2__c pri : prodPriceList) {
-                    if (pri.Consumable_Product__c == id) {
-                        ins.Intra_Trade_List_RMB__c =pri.Intra_Trade_List_RMB__c;
-                        break;
-                    }
-                }
-                ins.Box_Piece__c = '鐩�';
-                ins.Out_unit__c = '鐩�';
-                //ins.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c;
-                //ins.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c;
-                //ins.Dealer_Custom_Price__c = ass.orderdetails1.Dealer_Custom_Price__c;
-                ins.RecordTypeId = System.Label.RT_ConOrderDetail1_Inventory;
-                ins.Used_date__c = Date.today();
-                ins.OwnerId = arriveAccount.OwnerId;
+    // 鐢熸垚鍚勭粡閿�鍟嗗嚭搴撹鍗昄ist
+    // List<Consumable_order__c> orderList = new List<Consumable_order__c> ();
+    Map<String, List<Consumable_orderdetails__c>> insDetail1Map = new Map<String, List<Consumable_orderdetails__c>>();
+    for (String acc : accountGroupMap.keySet()) {
+      Consumable_order_details2__c arriveAccount = accountGroupMap.get(acc)[0];
+      List<Consumable_order_details2__c> prodPriceList = accountGroupMap.get(
+        acc
+      );
+      Map<Id, Integer> pNumMap = new Map<Id, Integer>();
+      pNumMap = productMap.get(acc);
+      List<Consumable_orderdetails__c> insDetail1 = new List<Consumable_orderdetails__c>();
+      for (Id id : pNumMap.keySet()) {
+        Consumable_orderdetails__c ins = new Consumable_orderdetails__c();
 
-                insDetail1.add(ins);
-            }
-            System.debug('======insDetail1'+insDetail1);
-            insDetail1Map.put(acc, insDetail1);
-            System.debug('======insDetail1Map'+insDetail1Map);
+        //InsAfterDel.Consumable_order__c = p.id;
+        ins.Product_Refind__c = pNumMap.get(id);
+        ins.inventory_sum__c = pNumMap.get(id);
+        ins.Consumable_Product__c = id;
+        for (Consumable_order_details2__c pri : prodPriceList) {
+          if (pri.Consumable_Product__c == id) {
+            ins.Intra_Trade_List_RMB__c = pri.Intra_Trade_List_RMB__c;
+            break;
+          }
         }
-        List<Consumable_orderdetails__c> insDetail1List = new List<Consumable_orderdetails__c> ();
-        for (Consumable_order__c setId : orderList) {
-            // 鏄庣粏1
-            List<Consumable_orderdetails__c> d1list = insDetail1Map.get(setId.Dealer_Info__r.Name + setId.Order_Owner_WorkLocal__c);
-            Integer i = 1;
-            for (Consumable_orderdetails__c dtl1 : d1list) {
-                String str = ('000' + i).right(4);
-                dtl1.Consumable_order__c = setId.Id;
-                dtl1.Name = setId.Name + '-'+ str;
-                insDetail1List.add(dtl1);
-            }
-        } 
-        System.debug('======insDetail1List'+insDetail1List);
-        insert insDetail1List;
+        ins.Box_Piece__c = '鐩�';
+        ins.Out_unit__c = '鐩�';
+        //ins.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c;
+        //ins.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c;
+        //ins.Dealer_Custom_Price__c = ass.orderdetails1.Dealer_Custom_Price__c;
+        ins.RecordTypeId = System.Label.RT_ConOrderDetail1_Inventory;
+        ins.Used_date__c = Date.today();
+        ins.OwnerId = arriveAccount.OwnerId;
+
+        insDetail1.add(ins);
+      }
+      System.debug('======insDetail1' + insDetail1);
+      insDetail1Map.put(acc, insDetail1);
+      System.debug('======insDetail1Map' + insDetail1Map);
     }
-    // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+    List<Consumable_orderdetails__c> insDetail1List = new List<Consumable_orderdetails__c>();
+    for (Consumable_order__c setId : orderList) {
+      // 鏄庣粏1
+      List<Consumable_orderdetails__c> d1list = insDetail1Map.get(
+        setId.Dealer_Info__r.Name + setId.Order_Owner_WorkLocal__c
+      );
+      Integer i = 1;
+      for (Consumable_orderdetails__c dtl1 : d1list) {
+        String str = ('000' + i).right(4);
+        dtl1.Consumable_order__c = setId.Id;
+        dtl1.Name = setId.Name + '-' + str;
+        insDetail1List.add(dtl1);
+      }
+    }
+    System.debug('======insDetail1List' + insDetail1List);
+    insert insDetail1List;
+  }
+  // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
 
-
-    // 缁忛攢鍟嗙殑涓嶅悓宸ヤ綔鍦拌皟璐ц嚜鍔ㄧ敓鎴愬嚭搴撳崟
-    public void addSaleOrderAuto (List<Consumable_order_details2__c> addList) {
-        Map<String, List<Consumable_order_details2__c>> accountGroupMap = new Map<String, List<Consumable_order_details2__c>>();
-        Map<String, Map<Id, Integer>> productMap = new Map<String, Map<Id, Integer>> ();
-        // 浠ョ粡閿�鍟嗗悕灏嗚鐢熸垚鍑哄簱鍗曠殑鏁版嵁鍒嗙粍
-        for (Consumable_order_details2__c cod : addList) {
-            List<Consumable_order_details2__c> accGroupList = new List<Consumable_order_details2__c> ();
-            Map<Id, Integer> pNumMap = new Map<Id, Integer> ();
-            Integer num = 1;
-            if (accountGroupMap.containsKey(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c)) {
-                accGroupList = accountGroupMap.get(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c);
-                pNumMap = productMap.get(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c);
-                if (pNumMap.containsKey(cod.Consumable_Product__c)) {
-                    num = pNumMap.get(cod.Consumable_Product__c) + 1;
-                }
-            } 
-            pNumMap.put(cod.Consumable_Product__c, num);
-            accGroupList.add(cod);
-            productMap.put(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c, pNumMap);
-            accountGroupMap.put(cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c, accGroupList);
+  // 缁忛攢鍟嗙殑涓嶅悓宸ヤ綔鍦拌皟璐ц嚜鍔ㄧ敓鎴愬嚭搴撳崟
+  public void addSaleOrderAuto(List<Consumable_order_details2__c> addList) {
+    Map<String, List<Consumable_order_details2__c>> accountGroupMap = new Map<String, List<Consumable_order_details2__c>>();
+    Map<String, Map<Id, Integer>> productMap = new Map<String, Map<Id, Integer>>();
+    // 浠ョ粡閿�鍟嗗悕灏嗚鐢熸垚鍑哄簱鍗曠殑鏁版嵁鍒嗙粍
+    for (Consumable_order_details2__c cod : addList) {
+      List<Consumable_order_details2__c> accGroupList = new List<Consumable_order_details2__c>();
+      Map<Id, Integer> pNumMap = new Map<Id, Integer>();
+      Integer num = 1;
+      if (
+        accountGroupMap.containsKey(
+          cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c
+        )
+      ) {
+        accGroupList = accountGroupMap.get(
+          cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c
+        );
+        pNumMap = productMap.get(
+          cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c
+        );
+        if (pNumMap.containsKey(cod.Consumable_Product__c)) {
+          num = pNumMap.get(cod.Consumable_Product__c) + 1;
         }
-
-        // 鐢熸垚鍚勭粡閿�鍟嗗嚭搴撹鍗昄ist
-        List<Consumable_order__c> orderList = new List<Consumable_order__c> ();
-        Map<String, List<Consumable_orderdetails__c>> insDetail1Map = new Map<String, List<Consumable_orderdetails__c>>();
-        for (String acc : accountGroupMap.keySet()) {
-            Consumable_order_details2__c arriveAccount = accountGroupMap.get(acc)[0];
-            Consumable_order__c autoOrder = new Consumable_order__c();
-            autoOrder.Name = '*';
-            autoOrder.Dealer_Info__c = arriveAccount.Consumable_Arrived_order__r.Dealer_Info__c;
-            autoOrder.OwnerId = arriveAccount.OwnerId;
-            autoOrder.Order_type__c = '浼犵エ';
-            autoOrder.SummonsStatus_c__c = '宸插畬鎴�';
-            autoOrder.Order_ForDealerText__c = accountName;
-            autoOrder.SummonsForDirction__c = '浜掔浉璋冭揣';
-            autoOrder.RecordTypeid = System.Label.RT_ConOrder_Shipment;
-            autoOrder.Outbound_Date__c = Date.today();
-            autoOrder.Order_date__c = Date.today();
-            autoOrder.AutoShipment__c = TRUE;
-            orderList.add(autoOrder);
-
-            List<Consumable_order_details2__c> prodPriceList = accountGroupMap.get(acc);
-            Map<Id, Integer> pNumMap = new Map<Id, Integer> ();
-            pNumMap = productMap.get(acc);
-            List<Consumable_orderdetails__c> insDetail1 = New List<Consumable_orderdetails__c>();
-            for (Id id : pNumMap.keySet()) {
-                Consumable_orderdetails__c ins = new Consumable_orderdetails__c();
-                
-                //InsAfterDel.Consumable_order__c = p.id;
-                ins.Shipment_Count__c = pNumMap.get(id);
-                ins.Consumable_Product__c = id;
-                for (Consumable_order_details2__c pri : prodPriceList) {
-                    if (pri.Consumable_Product__c == id) {
-                        ins.Intra_Trade_List_RMB__c =pri.Intra_Trade_List_RMB__c;
-                        break;
-                    }
-                }
-                ins.Box_Piece__c = '鐩�';
-                ins.Out_unit__c = '鐩�';
-                //ins.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c;
-                //ins.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c;
-                //ins.Dealer_Custom_Price__c = ass.orderdetails1.Dealer_Custom_Price__c;
-                ins.RecordTypeId = System.Label.RT_ConOrderDetail1_Shipment;
-                ins.Used_date__c = Date.today();
-                ins.OwnerId = arriveAccount.OwnerId;
-
-                insDetail1.add(ins);
-            }
-            insDetail1Map.put(acc, insDetail1);
-        }
-        insert orderList;
-
-        List<Id> orderIdList = new List<Id> ();
-        for (Consumable_order__c co : orderList) {
-            orderIdList.add(co.Id);
-        }
-
-        orderList = new List<Consumable_order__c> ();
-        orderList = [select Id, Name, Dealer_Info__r.Name, Order_Owner_WorkLocal__c from Consumable_order__c where id in : orderIdList];
-
-        // 璁剧疆鏄庣粏1 鍜� 鏄庣粏2 鐨� 璁㈠崟ID
-        List<Consumable_orderdetails__c> insDetail1List = new List<Consumable_orderdetails__c> ();
-        List<Consumable_order_details2__c> updDetail2List = new List<Consumable_order_details2__c> ();
-        for (Consumable_order__c setId : orderList) {
-            // 鏄庣粏1
-            List<Consumable_orderdetails__c> d1list = insDetail1Map.get(setId.Dealer_Info__r.Name + setId.Order_Owner_WorkLocal__c);
-            Integer i = 1;
-            for (Consumable_orderdetails__c dtl1 : d1list) {
-                String str = ('000' + i).right(4);
-                // if(str.length() == 1){
-                //     str = '0' + str;
-                // }
-                dtl1.Consumable_order__c = setId.Id;
-                dtl1.Name = setId.Name + '-'+ str;
-                insDetail1List.add(dtl1);
-            }
-
-            // 鏄庣粏2
-            List<Consumable_order_details2__c> d2list = accountGroupMap.get(setId.Dealer_Info__r.Name + setId.Order_Owner_WorkLocal__c);
-            for (Consumable_order_details2__c dtl2 : d2list) {
-                dtl2.Send_Date__c = Date.today();
-                dtl2.Consumable_Sale_order__c = null;
-                dtl2.Consumable_Return_order__c = null;
-                dtl2.Consumable_ZS_order__c = setId.Id;
-                //dtl2.Delivery_List_RMB__c = null;
-                dtl2.Return_date__c = null;
-                dtl2.Return_reason__c = null;
-                dtl2.Consumable_Shipment_order__c = setId.Id;
-                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                dtl2.Transfer_Time__c = 1;
-                dtl2.Agency_Transfer__c = true;
-                dtl2.Frist_Transfer_Agency__c = dtl2.Dealer_Info_text__c;
-                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                updDetail2List.add(dtl2);
-            }
-        }
-
-        insert insDetail1List;
-        update updDetail2List;
+      }
+      pNumMap.put(cod.Consumable_Product__c, num);
+      accGroupList.add(cod);
+      productMap.put(
+        cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c,
+        pNumMap
+      );
+      accountGroupMap.put(
+        cod.Dealer_Info_text__c + cod.Arrive_Owner_Work_Location__c,
+        accGroupList
+      );
     }
 
-    //鍒拌揣纭
-    public PageReference ArriveGoodsConfim() {
-        //add by rentx 20210618 start CHAN-C3K4ZQ 璺宠繃涓嶅繀瑕佺殑鏌ヨ
-        StaticParameter.ConsumableOrderTrigger = true;
-        //add by rentx 20210618 end CHAN-C3K4ZQ 璺宠繃涓嶅繀瑕佺殑鏌ヨ
-        cancellationProList = new List<String>();
-        List<Consumable_order_details2__c> ins = New List<Consumable_order_details2__c>();
-        String resultcheck = '';
-        List<String> resultcheckWithoutOrder = new List<String>();
-        Savepoint sp = Database.setSavepoint();
+    // 鐢熸垚鍚勭粡閿�鍟嗗嚭搴撹鍗昄ist
+    List<Consumable_order__c> orderList = new List<Consumable_order__c>();
+    Map<String, List<Consumable_orderdetails__c>> insDetail1Map = new Map<String, List<Consumable_orderdetails__c>>();
+    for (String acc : accountGroupMap.keySet()) {
+      Consumable_order_details2__c arriveAccount = accountGroupMap.get(acc)[0];
+      Consumable_order__c autoOrder = new Consumable_order__c();
+      autoOrder.Name = '*';
+      autoOrder.Dealer_Info__c = arriveAccount.Consumable_Arrived_order__r.Dealer_Info__c;
+      autoOrder.OwnerId = arriveAccount.OwnerId;
+      autoOrder.Order_type__c = '浼犵エ';
+      autoOrder.SummonsStatus_c__c = '宸插畬鎴�';
+      autoOrder.Order_ForDealerText__c = accountName;
+      autoOrder.SummonsForDirction__c = '浜掔浉璋冭揣';
+      autoOrder.RecordTypeid = System.Label.RT_ConOrder_Shipment;
+      autoOrder.Outbound_Date__c = Date.today();
+      autoOrder.Order_date__c = Date.today();
+      autoOrder.AutoShipment__c = true;
+      orderList.add(autoOrder);
 
-        if(ConsumableorderdetailsRecords.size()<1 && consumableInventory.size()<1){
-            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'涓嶅瓨鍦ㄥ埌璐ф槑缁�'));
+      List<Consumable_order_details2__c> prodPriceList = accountGroupMap.get(
+        acc
+      );
+      Map<Id, Integer> pNumMap = new Map<Id, Integer>();
+      pNumMap = productMap.get(acc);
+      List<Consumable_orderdetails__c> insDetail1 = new List<Consumable_orderdetails__c>();
+      for (Id id : pNumMap.keySet()) {
+        Consumable_orderdetails__c ins = new Consumable_orderdetails__c();
+
+        //InsAfterDel.Consumable_order__c = p.id;
+        ins.Shipment_Count__c = pNumMap.get(id);
+        ins.Consumable_Product__c = id;
+        for (Consumable_order_details2__c pri : prodPriceList) {
+          if (pri.Consumable_Product__c == id) {
+            ins.Intra_Trade_List_RMB__c = pri.Intra_Trade_List_RMB__c;
+            break;
+          }
+        }
+        ins.Box_Piece__c = '鐩�';
+        ins.Out_unit__c = '鐩�';
+        //ins.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c;
+        //ins.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c;
+        //ins.Dealer_Custom_Price__c = ass.orderdetails1.Dealer_Custom_Price__c;
+        ins.RecordTypeId = System.Label.RT_ConOrderDetail1_Shipment;
+        ins.Used_date__c = Date.today();
+        ins.OwnerId = arriveAccount.OwnerId;
+
+        insDetail1.add(ins);
+      }
+      insDetail1Map.put(acc, insDetail1);
+    }
+    insert orderList;
+
+    List<Id> orderIdList = new List<Id>();
+    for (Consumable_order__c co : orderList) {
+      orderIdList.add(co.Id);
+    }
+
+    orderList = new List<Consumable_order__c>();
+    orderList = [
+      SELECT Id, Name, Dealer_Info__r.Name, Order_Owner_WorkLocal__c
+      FROM Consumable_order__c
+      WHERE id IN :orderIdList
+    ];
+
+    // 璁剧疆鏄庣粏1 鍜� 鏄庣粏2 鐨� 璁㈠崟ID
+    List<Consumable_orderdetails__c> insDetail1List = new List<Consumable_orderdetails__c>();
+    List<Consumable_order_details2__c> updDetail2List = new List<Consumable_order_details2__c>();
+    for (Consumable_order__c setId : orderList) {
+      // 鏄庣粏1
+      List<Consumable_orderdetails__c> d1list = insDetail1Map.get(
+        setId.Dealer_Info__r.Name + setId.Order_Owner_WorkLocal__c
+      );
+      Integer i = 1;
+      for (Consumable_orderdetails__c dtl1 : d1list) {
+        String str = ('000' + i).right(4);
+        // if(str.length() == 1){
+        //     str = '0' + str;
+        // }
+        dtl1.Consumable_order__c = setId.Id;
+        dtl1.Name = setId.Name + '-' + str;
+        insDetail1List.add(dtl1);
+      }
+
+      // 鏄庣粏2
+      List<Consumable_order_details2__c> d2list = accountGroupMap.get(
+        setId.Dealer_Info__r.Name + setId.Order_Owner_WorkLocal__c
+      );
+      for (Consumable_order_details2__c dtl2 : d2list) {
+        dtl2.Send_Date__c = Date.today();
+        dtl2.Consumable_Sale_order__c = null;
+        dtl2.Consumable_Return_order__c = null;
+        dtl2.Consumable_ZS_order__c = setId.Id;
+        //dtl2.Delivery_List_RMB__c = null;
+        dtl2.Return_date__c = null;
+        dtl2.Return_reason__c = null;
+        dtl2.Consumable_Shipment_order__c = setId.Id;
+        // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+        dtl2.Transfer_Time__c = 1;
+        dtl2.Agency_Transfer__c = true;
+        dtl2.Frist_Transfer_Agency__c = dtl2.Dealer_Info_text__c;
+        // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+        updDetail2List.add(dtl2);
+      }
+    }
+
+    insert insDetail1List;
+    update updDetail2List;
+  }
+
+  //鍒拌揣纭
+  public PageReference ArriveGoodsConfim() {
+    //add by rentx 20210618 start CHAN-C3K4ZQ 璺宠繃涓嶅繀瑕佺殑鏌ヨ
+    StaticParameter.ConsumableOrderTrigger = true;
+    //add by rentx 20210618 end CHAN-C3K4ZQ 璺宠繃涓嶅繀瑕佺殑鏌ヨ
+    cancellationProList = new List<String>();
+    List<Consumable_order_details2__c> ins = new List<Consumable_order_details2__c>();
+    String resultcheck = '';
+    List<String> resultcheckWithoutOrder = new List<String>();
+    Savepoint sp = Database.setSavepoint();
+
+    if (
+      ConsumableorderdetailsRecords.size() < 1 &&
+      consumableInventory.size() < 1
+    ) {
+      //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+      if (isLwc) {
+        returnError = '涓嶅瓨鍦ㄥ埌璐ф槑缁�';
+      } else {
+        ApexPages.addmessage(
+          new ApexPages.message(ApexPages.severity.ERROR, '涓嶅瓨鍦ㄥ埌璐ф槑缁�')
+        );
+      }
+      return null;
+    }
+    if (EsetId != null && EsetId != '') {
+      resultcheck = ConfimResult();
+      if (resultcheck.length() > 0) {
+        for (String widget : overOrderBARcodeCunMap.keySet()) {
+          if (overOrderBARcodeCunMap.get(widget).size() > 0) {
+            //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+            if (isLwc) {
+              warningList.add(
+                '浜у搧' +
+                  widget +
+                  '鏈鍒拌揣鏁伴噺瓒呰繃' +
+                  overOrderBARcodeCunMap.get(widget).size() +
+                  '涓璐х殑鏁伴噺銆�'
+              );
+            } else {
+              ApexPages.addmessage(
+                new ApexPages.message(
+                  ApexPages.severity.INFO,
+                  '浜у搧' +
+                    widget +
+                    '鏈鍒拌揣鏁伴噺瓒呰繃' +
+                    overOrderBARcodeCunMap.get(widget).size() +
+                    '涓璐х殑鏁伴噺銆�'
+                )
+              );
+            }
+            for (
+              String barcodeListTTT : (List<String>) overOrderBARcodeCunMap.get(
+                widget
+              )
+            ) {
+              //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+              if (isLwc) {
+                warningList.add(barcodeListTTT);
+              } else {
+                ApexPages.addmessage(
+                  new ApexPages.message(ApexPages.severity.INFO, barcodeListTTT)
+                );
+              }
+            }
+          }
+        }
+      }
+    } else {
+      confimResultWithoutOrder();
+    }
+    try {
+      Consumable_order__c orderMain = new Consumable_order__c();
+      List<Consumable_order_details2__c> orderdetails = new List<Consumable_order_details2__c>();
+      //鍒拌揣姝g‘淇℃伅
+      orderMain.Name = '*';
+      orderMain.Order_status__c = '鎵瑰噯';
+      orderMain.Dealer_Info__c = accountid;
+      orderMain.Deliver_date__c = Date.today();
+      orderMain.Order_date__c = Date.today();
+      orderMain.Order_type__c = '鍒拌揣';
+      orderMain.Order_ProType__c = userPro_Type;
+      if (EsetId != null && EsetId != '') {
+        orderMain.Arrive_Order__c = coc.Id;
+      }
+      orderMain.RecordTypeid = System.Label.RT_ConOrder_Arrive;
+      insert orderMain;
+
+      List<Consumable_order__c> consumable_order = [
+        SELECT Name
+        FROM Consumable_order__c
+        WHERE id = :orderMain.id
+      ];
+      arriveId = orderMain.id;
+      Decimal arriveAmount = 0;
+      for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecordsUse) {
+        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------1------'));
+        Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
+        insDetails.Id = ass.esd.Id;
+        insDetails.Consumable_Arrived_order__c = orderMain.id;
+        insDetails.Arrive_date__c = Date.today();
+        insDetails.Bar_Code__c = ass.esd.Bar_Code__c;
+        insDetails.OwnerId = UserInfo.getUserId();
+        // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+        if (orderdetails2trMap.containsKey(ass.esd.Bar_Code__c)) {
+          insDetails.Transfer_Time__c = ass.esd.Transfer_Time__c == null
+            ? 1
+            : ass.esd.Transfer_Time__c;
+          insDetails.Agency_Transfer__c = true;
+          insDetails.Frist_Transfer_Agency__c = ass.esd.Frist_Transfer_Agency__c ==
+            null
+            ? ass.esd.Dealer_Info_text__c
+            : ass.esd.Frist_Transfer_Agency__c;
+        }
+        // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+
+        // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
+        insDetails.Agencyinfo_fromSAP__c = ass.esd.Agencyinfo_fromSAP__c;
+        insDetails.Frist_Storage_Agency__c = ass.esd.Frist_Storage_Agency__c ==
+          null
+          ? ass.esd.Dealer_Info_text__c
+          : ass.esd.Frist_Storage_Agency__c;
+        // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
+        arriveAmount += ass.esd.Intra_Trade_List_RMB__c;
+        orderdetails.add(insDetails);
+      }
+      Integer i = 1;
+      for (ConsumableorderdetailsInfo ass : consumableInventoryUse) {
+        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------2------'));
+        Consumable_order_details2__c insAfterDel = new Consumable_order_details2__c();
+        String str = ('000' + i).right(4);
+        // if(str.length() == 1){
+        //     str = '0' + str;
+        // }
+        insAfterDel.Name = consumable_order[0].Name + '-' + str;
+        insAfterDel.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+        // gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
+        // if(EsetId != null && EsetId != ''){
+        //     insAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
+        // }else{
+        //     insAfterDel.Intra_Trade_List_RMB__c = 0;
+        // }
+        insAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
+        //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
+        insAfterDel.Asset_Model_No__c = ass.Prod.Asset_Model_No__c;
+        if (EsetId != null && EsetId != '') {
+          insAfterDel.Consumable_order_minor__c = ESetId;
+        }
+        insAfterDel.Deliver_date__c = Date.today();
+        insAfterDel.Direct_Arrive_Product__c = true;
+        //TODO寰呯‘璁�
+        insAfterDel.Sterilization_limit__c = ass.sterilizationlimitDate;
+        insAfterDel.Consumable_Product__c = ass.Prod.id;
+        insAfterDel.Bar_Code__c = ass.barCodeNo;
+        insAfterDel.Used_account__c = accountid;
+        //TODO寰呯‘璁�
+        insAfterDel.SerialLotNo__c = ass.serialNoorLotNo;
+        insAfterDel.TracingCode__c = ass.tracingCodeNo;
+
+        //insAfterDel.Dealer_Arrive__c                = true;
+        insAfterDel.Consumable_Arrived_order__c = orderMain.id;
+        insAfterDel.Arrive_date__c = Date.today();
+        insAfterDel.OwnerId = UserInfo.getUserId();
+        // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+        if (orderdetails2trMap.containsKey(ass.esd.Bar_Code__c)) {
+          insAfterDel.Transfer_Time__c = ass.esd.Transfer_Time__c == null
+            ? 1
+            : ass.esd.Transfer_Time__c;
+          insAfterDel.Agency_Transfer__c = true;
+          insAfterDel.Frist_Transfer_Agency__c = ass.esd.Frist_Transfer_Agency__c ==
+            null
+            ? accountName
+            : ass.esd.Frist_Transfer_Agency__c;
+        }
+        // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+
+        // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
+        insAfterDel.Agencyinfo_fromSAP__c = ass.esd.Agencyinfo_fromSAP__c;
+        insAfterDel.Frist_Storage_Agency__c = ass.esd.Frist_Storage_Agency__c ==
+          null
+          ? accountName
+          : ass.esd.Frist_Storage_Agency__c;
+        // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
+        arriveAmount += insAfterDel.Intra_Trade_List_RMB__c;
+        //add by rentx 2020-10-14 strat
+        //insAfterDel.ContractNo_text__c      = /*ass.esd.ContractNo__c*/;
+        // tcm start
+        if (String.isBlank(ass.esd.Consumable_order_minor__r.ContractNo__c)) {
+          insAfterDel.ContractNo_text__c = ass.esd.ContractNo_text__c;
+        } else {
+          insAfterDel.ContractNo_text__c = ass.esd.Consumable_order_minor__r.ContractNo__c;
+        }
+        // tcm end
+        //add by rentx 2020-10-14 end
+        i++;
+
+        ins.add(insAfterDel);
+      }
+      orderMain.Arrive_total_amount__c = arriveAmount;
+      update orderMain;
+      List<Consumable_order_details2__c> updateconsumableorderdetails2 = new List<Consumable_order_details2__c>();
+      //鏇存柊鏄庣粏鍙栨秷鏃堕棿 => 鏈埌璐у彇娑堬紝鍒拌揣鑷姩鐢熸垚鍑哄簱娴佺▼
+      List<Consumable_order_details2__c> addSaleOrderList = new List<Consumable_order_details2__c>();
+      for (Consumable_order_details2__c Cod : consumableorderdetails2Cancle) {
+        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------3------'));
+        if (Cod.Dealer_Arrive__c) {
+          if (Cod.Dealer_Shipment__c == false && Cod.Dealer_Saled__c == false) {
+            addSaleOrderList.add(Cod);
+          }
+        } else {
+          Cod.Cancellation_Date__c = Date.today();
+          Cod.Cancellation_Flag__c = true;
+          updateconsumableorderdetails2.add(Cod);
+        }
+      }
+
+      if (addSaleOrderList.size() > 0) {
+        addSaleOrderAuto(addSaleOrderList);
+      }
+
+      if (updateconsumableorderdetails2.size() > 0) {
+        update updateconsumableorderdetails2;
+      }
+
+      List<Consumable_order_details2__c> insertconsumableorderdetails2 = new List<Consumable_order_details2__c>();
+      for (Consumable_order_details2__c Cod2 : consumableorderdetails2Insert) {
+        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------4------'));
+        String str = ('000' + i).right(4);
+        // if(str.length() == 1){
+        //     str = '0' + str;
+        // }
+        Cod2.Name = consumable_order[0].Name + '-' + str;
+        Cod2.Consumable_order_minor__c = null;
+        Cod2.Deliver_date__c = Date.today();
+        Cod2.Used_account__c = accountid;
+        Cod2.Consumable_Arrived_order__c = orderMain.id;
+        Cod2.Arrive_date__c = Date.today();
+        // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
+        if (orderdetails2trMap.containsKey(Cod2.Bar_Code__c)) {
+          //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------4++++++' + Cod2.Frist_Storage_Agency__c));
+          Cod2.Transfer_Time__c = Cod2.Transfer_Time__c == null
+            ? 1
+            : Cod2.Transfer_Time__c;
+          Cod2.Agency_Transfer__c = true;
+          Cod2.Frist_Transfer_Agency__c = Cod2.Frist_Transfer_Agency__c == null
+            ? accountName
+            : Cod2.Frist_Transfer_Agency__c;
+        }
+        // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
+
+        // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
+        Cod2.Agencyinfo_fromSAP__c = Cod2.Agencyinfo_fromSAP__c;
+        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------4------' + Cod2.Frist_Storage_Agency__c));
+        Cod2.Frist_Storage_Agency__c = Cod2.Frist_Storage_Agency__c == null
+          ? accountName
+          : Cod2.Frist_Storage_Agency__c;
+        // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
+        insertconsumableorderdetails2.add(Cod2);
+        i++;
+      }
+
+      //return null;
+
+      if (insertconsumableorderdetails2.size() > 0) {
+        insert insertconsumableorderdetails2;
+      }
+
+      if (ins.size() > 0) {
+        insert ins;
+      }
+      if (orderdetails.size() > 0) {
+        ControllerUtil.updateOrderDetailsSatus(orderdetails);
+      }
+      //瓒呭嚭鍒拌揣鏁伴噺浜у搧鍙栨秷鏃ユ湡鏇存柊
+      List<Consumable_order_details2__c> needcanceldet = new List<Consumable_order_details2__c>();
+      if (cancellationProList.size() > 0) {
+        needcanceldet = [
+          SELECT Id, Cancellation_Date__c
+          FROM Consumable_order_details2__c
+          WHERE
+            Asset_Model_No__c IN :cancellationProList
+            AND Consumable_order_minor__c = :ESetId
+            AND Dealer_Arrive__c = FALSE
+            AND Cancellation_Date__c = NULL
+        ];
+        if (needcanceldet.size() > 0) {
+          for (Integer a = 0; a < needcanceldet.size(); a++) {
+            needcanceldet[a].Cancellation_Date__c = Date.today();
+            needcanceldet[a].Cancellation_Flag__c = true;
+          }
+          ControllerUtil.updateOrderDetailsSatus(needcanceldet);
+        }
+      }
+      List<Consumable_order__c> qs = new List<Consumable_order__c>();
+      qs = [
+        SELECT
+          Id,
+          Name,
+          Order_status__c,
+          Dealer_Info__c,
+          Deliver_date__c,
+          ReturnGs_Upload_Date__c,
+          Order_Reason__c,
+          Order_date__c,
+          Contract_application_decision__c,
+          Order_type__c,
+          Total_num__c,
+          OrderNumber_arrived__c,
+          Delivery_detail_count__c,
+          OrderNumber_notarrive__c
+        FROM Consumable_order__c
+        WHERE Id = :ESetId AND Dealer_Info__c = :accountid
+      ];
+      if (qs.size() > 0) {
+        coc = qs[0];
+      }
+      saveFLGbln = true;
+      alertMessage = '鍒拌揣瀹屾垚銆�';
+      // Integer a = 1/0;
+    } catch (Exception e) {
+      Database.rollback(sp);
+      //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+      if (isLwc) {
+        returnError = e.getLineNumber() + '---' + e.getMessage();
+      } else {
+        ApexPages.addMessages(e);
+      }
+      return null;
+    }
+    if (resultcheck.length() > 0) {
+      return null;
+    } else if (resultcheckWithoutOrder.size() > 0) {
+      return null;
+    } else {
+      urlType = 'UnabletoEdit';
+      return UnabletoEdit();
+      // return null;
+    }
+  }
+
+  // 杩斿搧妫�鏌ワ紝鍚庡洖搴�
+  public integer GoodsReturnCheck() {
+    List<String> GrListIn = ParseBarCode(barcode);
+    GrList = new List<String>();
+    Map<String, String> CheckBarcodeResult = new Map<String, String>();
+    for (String Str : GrListIn) {
+      CheckBarcodeResult.put(str, 'UnFind');
+    }
+    List<Consumable_order_details2__c> BarcodeRetrunResult = [
+      SELECT
+        Id,
+        Name,
+        Intra_Trade_List_RMB__c,
+        Asset_Model_No__c,
+        Consumable_Product__c,
+        Consumable_Product__r.Name,
+        Consumable_Product__r.Name__c,
+        Consumable_Product__r.Asset_Model_No__c,
+        Sterilization_limit__c,
+        Deliver_date__c,
+        Bar_Code__c,
+        Arrive_date__c,
+        Send_Date__c,
+        Consumable_order_minor__r.Name,
+        Consumable_order_minor__c,
+        Dealer_Arrive__c,
+        Guarantee_period_for_products__c,
+        CFDA_Status__c,
+        ProductPacking_list_manual__c,
+        Report_Product_Approbation__c,
+        Report_Product_Expiration__c,
+        Box_Piece__c,
+        Rrturn_count__c,
+        Product_Type__c,
+        //add by rentx 2020-10-14 start
+        ContractNo_text__c /*,ContractNo__c*/,
+        // tcm start
+        Consumable_order_minor__r.ContractNo__c
+      // tcm end
+      //add by rentx 2020-10-14 end
+      FROM Consumable_order_details2__c
+      WHERE
+        Dealer_Arrive__c = TRUE
+        AND (Dealer_Shipment__c = TRUE
+        //AND Consumable_Shipment_order__r.SummonsForDirction__c != '浜掔浉璋冭揣')
+        OR Dealer_Saled__c = TRUE)
+        AND Dealer_Info_text__c = :accountName
+        AND Bar_Code__c IN :GrListIn
+        AND (NOT Product_Type__c LIKE :userPro_Typestr)
+        AND Dealer_Returned__c = FALSE
+        AND Arrive_Owner_Work_Location__c = :userWorkLocation
+      ORDER BY Box_Piece__c DESC, Name
+    ];
+    if (BarcodeRetrunResult.size() > 0) {
+      for (Integer i = 0; i < BarcodeRetrunResult.size(); i++) {
+        if (
+          ErrorIdMap.containsKey(BarcodeRetrunResult[i].Bar_Code__c) ||
+          ExistIdMap.containsKey(BarcodeRetrunResult[i].Bar_Code__c)
+        ) {
+          // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+          continue;
+        } else {
+          String str =
+            '浜у搧绫诲瀷[' +
+            BarcodeRetrunResult[i].Product_Type__c +
+            ']涓庣敤鎴风殑绫诲瀷[' +
+            userPro_Type +
+            ']涓嶇';
+          ConsumableorderdetailsRecordserror.add(
+            new ConsumableorderdetailsInfo(BarcodeRetrunResult[i], str)
+          );
+          ErrorIdMap.put(
+            BarcodeRetrunResult[i].Bar_Code__c,
+            BarcodeRetrunResult[i].Bar_Code__c
+          );
+        }
+      }
+    }
+    AllMap.putAll(ErrorIdMap);
+    BarcodeRetrunResult = [
+      SELECT
+        Id,
+        Consumable_order_minor__c,
+        Deliver_date__c,
+        Asset_Model_No__c,
+        Consumable_Product__c,
+        Consumable_Product__r.Name,
+        Consumable_Product__r.Name__c,
+        Name,
+        Bar_Code__c,
+        Arrive_date__c,
+        Dealer_Shipment__c,
+        Lose_Flag__c,
+        Dealer_Saled__c,
+        Return_reason__c,
+        Consumable_Shipment_order__c,
+        Consumable_Shipment_order__r.Name,
+        Send_date__c,
+        Consumable_Sale_order__c,
+        Consumable_Sale_order__r.Name,
+        Used_date__c,
+        SerialLotNo__c,
+        TracingCode__c,
+        Sterilization_limit__c,
+        Consumable_ZS_order__c,
+        Consumable_ZS_order__r.Name,
+        Product_OutDate__c,
+        Invoice_Date__c,
+        recordtypeid,
+        Consumable_Arrived_order__c,
+        Box_Piece__c,
+        Rrturn_count__c,
+        Intra_Trade_List_RMB__c,
+        OwnerId,
+        SummonsForDirction_det__c,
+        Order_Dealer_Info__c,
+        HospItal_Name__c,
+        Agencyinfo_fromSAP__c,
+        Frist_Storage_Agency__c,
+        Dealer_Info_text__c,
+        Used_account__c,
+        Transfer_Time__c,
+        Frist_Transfer_Agency__c,
+        Arrive_Owner_Work_Location__c,
+        Agency_Transfer__c,
+        //add by rentx 2020-10-14 start
+        ContractNo_text__c /*,ContractNo__c*/,
+        // tcm start
+        Consumable_order_minor__r.ContractNo__c,
+        // tcm end
+        //add by rentx 2020-10-14 end
+        Report_Product_Expiration__c,
+        Intra_Trade_List__c
+      FROM Consumable_order_details2__c
+      WHERE
+        Dealer_Arrive__c = TRUE
+        AND (Dealer_Shipment__c = TRUE
+        //AND Consumable_Shipment_order__r.SummonsForDirction__c != '浜掔浉璋冭揣')
+        OR Dealer_Saled__c = TRUE
+        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+        OR (Dealer_Shipment__c = FALSE
+        AND Dealer_Saled__c = FALSE
+        AND Lose_Flag__c = TRUE))
+        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+        AND Dealer_Info_text__c = :accountName
+        AND Bar_Code__c IN :GrListIn
+        AND Product_Type__c LIKE :userPro_Typestr
+        AND Dealer_Returned__c = FALSE
+        AND (Arrive_Owner_Work_Location__c = :userWorkLocation
+        OR OwnerId = :System.Label.User_OlympusSystem)
+      ORDER BY Box_Piece__c DESC, Name
+    ];
+    ShowGoodsofReturnList = new List<ConsumableorderdetailsInfo>();
+
+    //杩斿搧鏃秈stinct澶勭悊
+    if (ArrType == 'ReG') {
+      BarcodeRetrunResult = getDistinctZSOrder(BarcodeRetrunResult);
+    }
+
+    for (Consumable_order_details2__c codc : BarcodeRetrunResult) {
+      if (
+        ErrorIdMap.containsKey(codc.Bar_Code__c) ||
+        ExistIdMap.containsKey(codc.Bar_Code__c)
+      ) {
+        // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+        continue;
+      } else {
+        Matcher n = Pattern.compile('[0-9]').matcher(codc.TracingCode__c);
+        if (n.find()) {
+          // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
+          if (codc.TracingCode__c.length() == 5) {
+            String tr = codc.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()
+            ) {
+              String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
+              ConsumableorderdetailsRecordserror.add(
+                new ConsumableorderdetailsInfo(codc, str)
+              );
+              ErrorIdMap.put(codc.Bar_Code__c, codc.Bar_Code__c);
+              continue;
+            }
+          }
+          // String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
+          // ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(codc,str));
+          // ErrorIdMap.put(codc.Bar_Code__c,codc.Bar_Code__c);
+          // continue;
+          // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
+        }
+        if (CheckBarcodeResult.containsKey(codc.Bar_Code__c)) {
+          GrList.add(codc.Bar_Code__c);
+          if (codc.Dealer_Shipment__c == true) {
+            CheckBarcodeResult.put(codc.Bar_Code__c, '宸插嚭搴�');
+            ShowGoodsofReturnList.add(new ConsumableorderdetailsInfo(codc));
+          }
+          // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+          // else{
+          //     CheckBarcodeResult.put( codc.Bar_Code__c, '宸查攢鍞�');
+          //     ShowGoodsofReturnList.add(  new ConsumableorderdetailsInfo( codc    )   );
+          // }
+          else if (codc.Dealer_Saled__c == true) {
+            CheckBarcodeResult.put(codc.Bar_Code__c, '宸查攢鍞�');
+            ShowGoodsofReturnList.add(new ConsumableorderdetailsInfo(codc));
+          } else {
+            CheckBarcodeResult.put(codc.Bar_Code__c, '宸蹭涪澶�');
+            ShowGoodsofReturnList.add(new ConsumableorderdetailsInfo(codc));
+          }
+          // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+        } else {
+          continue;
+        }
+      }
+    }
+
+    return BarcodeRetrunResult.size();
+  }
+
+  // 鍗曚綅涓轰釜鐨凚arcode瀵瑰簲鐨勫嚭搴撳崟
+  public integer Getconsumableorderdetails2Nobox() {
+    consumableorderdetails2Nobox = new List<Consumable_order_details2__c>();
+    BarcodeCntMap.clear();
+    consumableorderdetails2Nobox = [
+      SELECT
+        Id,
+        Consumable_order_minor__c,
+        Deliver_date__c,
+        Asset_Model_No__c,
+        Consumable_Product__c,
+        Consumable_Product__r.Name,
+        Consumable_Product__r.Name__c,
+        Name,
+        Bar_Code__c,
+        Arrive_date__c,
+        Dealer_Shipment__c,
+        Dealer_Saled__c,
+        Return_reason__c,
+        Consumable_Shipment_order__c,
+        Send_date__c,
+        Consumable_Sale_order__c,
+        Used_date__c,
+        SerialLotNo__c,
+        TracingCode__c,
+        Sterilization_limit__c,
+        Consumable_ZS_order__c,
+        Consumable_ZS_order__r.Name,
+        Product_OutDate__c,
+        Invoice_Date__c,
+        recordtypeid,
+        Consumable_Arrived_order__c,
+        Box_Piece__c,
+        RemoveBox_No__c,
+        RemoveBox_date__c,
+        Rrturn_count__c,
+        Dealer_Info_text__c,
+        Arrive_Owner_Work_Location__c,
+        Intra_Trade_List_RMB__c,
+        //add by rentx 2020-10-13 start 杩斿搧鏃� 鏂版暟鎹褰昐AP鍚堝悓鍙�
+        ContractNo_text__c /*,ContractNo__c*/,
+        // tcm start
+        Consumable_order_minor__r.ContractNo__c,
+        // tcm end
+        Report_Product_Expiration__c,
+        //add by rentx 2020-10-13 end
+        Intra_Trade_List__c
+      //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
+      FROM Consumable_order_details2__c
+      WHERE
+        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+        // (Dealer_Shipment__c = true or Dealer_Saled__c =  true)
+        (Dealer_Shipment__c = TRUE
+        OR Dealer_Saled__c = TRUE
+        OR (Dealer_Shipment__c = FALSE
+        AND Dealer_Saled__c = FALSE
+        AND Lose_Flag__c = TRUE))
+        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+        AND Dealer_Info_text__c = :accountName
+        AND Bar_Code__c IN :noboxBarcodeList
+        AND Arrive_Owner_Work_Location__c = :userWorkLocation
+        AND Dealer_Returned__c = FALSE
+        AND Box_Piece__c = '涓�'
+      ORDER BY Consumable_ZS_order__c, RemoveBox_No__c
+    ];
+
+    AggregateResult[] results = [
+      SELECT Consumable_ZS_order__c, Bar_Code__c, count(Id) recordCount
+      FROM Consumable_order_details2__c
+      WHERE
+        Dealer_Arrive__c = TRUE
+        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+        // AND  (Dealer_Shipment__c= true OR  Dealer_Saled__c = true)
+        AND (Dealer_Shipment__c = TRUE
+        OR Dealer_Saled__c = TRUE
+        OR (Dealer_Shipment__c = FALSE
+        AND Dealer_Saled__c = FALSE
+        AND Lose_Flag__c = TRUE))
+        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+        AND Dealer_Returned__c = FALSE
+        AND Bar_Code__c IN :noboxBarcodeList
+        AND Arrive_Owner_Work_Location__c = :userWorkLocation
+        AND Box_Piece__c = '涓�'
+        AND Dealer_Info_text__c = :accountName
+      GROUP BY Consumable_ZS_order__c, Bar_Code__c
+    ];
+
+    for (AggregateResult ar : results) {
+      String key =
+        '' +
+        ar.get('Consumable_ZS_order__c') +
+        ar.get('Bar_Code__c');
+      BarcodeCntMap.put(key, Integer.valueOf(ar.get('recordCount')));
+    }
+
+    return consumableorderdetails2Nobox.size();
+  }
+
+  //distinct
+  public List<Consumable_order_details2__c> getDistinctZSOrder(
+    List<Consumable_order_details2__c> duplicates
+  ) {
+    List<Consumable_order_details2__c> distinctOrder = new List<Consumable_order_details2__c>();
+
+    for (Consumable_order_details2__c details2 : duplicates) {
+      Boolean found = false;
+      for (Consumable_order_details2__c result : distinctOrder) {
+        if (
+          details2.Consumable_ZS_order__c == result.Consumable_ZS_order__c &&
+          details2.Bar_Code__c == result.Bar_Code__c
+        ) {
+          found = true;
+          break;
+        }
+      }
+
+      if (!found) {
+        distinctOrder.add(details2);
+
+        if (details2.Box_Piece__c == '涓�')
+          noboxBarcodeList.add(details2.Bar_Code__c);
+      }
+    }
+    return distinctOrder;
+  }
+
+  // Update杩斿搧鏄庣粏淇℃伅
+  public Pagereference UpdateGoodsOfReturn() {
+    if (ShowGoodsofReturnList == null) {
+      GoodsReturnCheck();
+    }
+    Getconsumableorderdetails2Nobox();
+
+    Savepoint sp = Database.setSavepoint();
+    boolean hasReturnGoods = false;
+    boolean hasLoseGoods = false;
+    try {
+      if (ShowGoodsofReturnList.size() > 0 || consumableInventory.size() > 0) {
+        Consumable_order__c Return_Order_Sheet = new Consumable_order__c();
+        Return_Order_Sheet.Name = '*';
+        Return_Order_Sheet.Order_status__c = '鎵瑰噯';
+        Return_Order_Sheet.ReturnGs_Uploader_ID__c = UserInfo.getUserId();
+        Return_Order_Sheet.ReturnGs_Upload_Date__c = Date.today();
+        Return_Order_Sheet.Order_type__c = '杩斿搧';
+        Return_Order_Sheet.RecordTypeid = System.Label.Dealer_Returned_Label;
+        Return_Order_Sheet.Order_ProType__c = userPro_Type;
+        insert Return_Order_Sheet;
+        return_Order_id = Return_Order_Sheet.id;
+        List<Consumable_order__c> consumable_order_ret = [
+          SELECT Name
+          FROM Consumable_order__c
+          WHERE id = :Return_Order_Sheet.id
+        ];
+
+        //2017-07-03 鍒拌揣璁㈠崟
+        Consumable_order__c Arrived_Order_Sheet = new Consumable_order__c();
+        Arrived_Order_Sheet.Name = '*';
+        Arrived_Order_Sheet.Order_status__c = '鎵瑰噯';
+        Arrived_Order_Sheet.Order_type__c = '鍒拌揣';
+        Arrived_Order_Sheet.Dealer_Info__c = accountid;
+        Arrived_Order_Sheet.RecordTypeid = System.Label.RT_ConOrder_Arrive;
+        Arrived_Order_Sheet.Order_ProType__c = userPro_Type;
+        insert Arrived_Order_Sheet;
+        List<Consumable_order__c> consumable_order_arr = [
+          SELECT Name
+          FROM Consumable_order__c
+          WHERE id = :Arrived_Order_Sheet.id
+        ];
+
+        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+        // 铏氭嫙鐩樼偣鍗�
+        Consumable_order__c Inventory_Order_Sheet = new Consumable_order__c();
+        Inventory_Order_Sheet.Name = '*';
+        Inventory_Order_Sheet.Order_status__c = '鎵瑰噯';
+        Inventory_Order_Sheet.ReturnGs_Uploader_ID__c = UserInfo.getUserId();
+        Inventory_Order_Sheet.Inventory_date__c = Date.today();
+        Inventory_Order_Sheet.Dealer_Info__c = accountid;
+        Inventory_Order_Sheet.ReturnGs_Upload_Date__c = Date.today();
+        Inventory_Order_Sheet.Order_type__c = '鐩樼偣';
+        Inventory_Order_Sheet.RecordTypeid = System.Label.RT_ConOrder_Inventory;
+        Inventory_Order_Sheet.Order_ProType__c = userPro_Type;
+        insert Inventory_Order_Sheet;
+        inventory_Order_id = Inventory_Order_Sheet.id;
+        List<Consumable_order__c> consumable_order_Inv = [
+          SELECT Name
+          FROM Consumable_order__c
+          WHERE id = :Inventory_Order_Sheet.id
+        ];
+        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+
+        List<Consumable_order_details2__c> codcList = new List<Consumable_order_details2__c>();
+        //鏂拌杩斿搧瀵瑰簲鐨勪骇鍝佹槑缁�
+        List<Consumable_order_details2__c> codcorderdetList = new List<Consumable_order_details2__c>();
+        //杩斿搧鍘熷洜,杩斿搧鏁伴噺妫�鏌�
+        for (ConsumableorderdetailsInfo codi : ShowGoodsofReturnList) {
+          if (
+            codi.esd.Box_Piece__c == '涓�' &&
+            (codi.esd.Rrturn_count__c == null ||
+            String.valueof(codi.esd.Rrturn_count__c) == '' ||
+            codi.esd.Rrturn_count__c <= 0)
+          ) {
+            continue;
+          }
+
+          if (
+            codi.esd.Return_reason__c == null ||
+            codi.esd.Return_reason__c == ''
+          ) {
+            if (isLwc) {
+              returnError = '璇疯ˉ鍏呰繑鍝佸師鍥�';
+            } else {
+              codi.esd.Return_reason__c.addError('璇疯ˉ鍏呰繑鍝佸師鍥�');
+            }
             return null;
-        }
-        if(EsetId != null && EsetId != ''){
-            resultcheck = ConfimResult();
-            if(resultcheck.length() > 0){
-                for(String widget : overOrderBARcodeCunMap.keySet()) {
-                    if(overOrderBARcodeCunMap.get(widget).size() >0){
-                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '浜у搧' + widget + '鏈鍒拌揣鏁伴噺瓒呰繃' + overOrderBARcodeCunMap.get(widget).size() +'涓璐х殑鏁伴噺銆�'));
-                        for(String barcodeListTTT : (List<String>)overOrderBARcodeCunMap.get(widget)) {
-                            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, barcodeListTTT));
-                        }
-                    }
-                }
-            }
-        }else{
-            confimResultWithoutOrder();
-        }
-        try{
-            Consumable_order__c orderMain = new Consumable_order__c();
-            List<Consumable_order_details2__c> orderdetails = New List<Consumable_order_details2__c>();
-            //鍒拌揣姝g‘淇℃伅
-            orderMain.Name            = '*';
-            orderMain.Order_status__c = '鎵瑰噯';
-            orderMain.Dealer_Info__c  = accountid;
-            orderMain.Deliver_date__c = Date.today();
-            orderMain.Order_date__c   = Date.today();
-            orderMain.Order_type__c   = '鍒拌揣';
-            orderMain.Order_ProType__c = userPro_Type;
-            if(EsetId != null && EsetId != ''){
-                orderMain.Arrive_Order__c = coc.Id;
-            }
-            orderMain.RecordTypeid = System.Label.RT_ConOrder_Arrive;
-            insert orderMain;
+          }
 
-            List<Consumable_order__c> consumable_order = [SELECT Name FROM Consumable_order__c WHERE id =:orderMain.id];
-            arriveId = orderMain.id;
-            Decimal arriveAmount =0;
-            for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecordsUse)  {
-                Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
-                insDetails.Id                           = ass.esd.Id;
-                insDetails.Consumable_Arrived_order__c  = orderMain.id;
-                insDetails.Arrive_date__c               = Date.today();
-                insDetails.Bar_Code__c                  = ass.esd.Bar_Code__c;
-                insDetails.OwnerId                      = UserInfo.getUserId();
-                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                if (orderdetails2trMap.containsKey(ass.esd.Bar_Code__c)) {
-                    insDetails.Transfer_Time__c = ass.esd.Transfer_Time__c == null ? 1 : ass.esd.Transfer_Time__c;
-                    insDetails.Agency_Transfer__c = true;
-                    insDetails.Frist_Transfer_Agency__c = ass.esd.Frist_Transfer_Agency__c == null ? ass.esd.Dealer_Info_text__c : ass.esd.Frist_Transfer_Agency__c;
-                }
-                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                 
-                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
-                insDetails.Agencyinfo_fromSAP__c = ass.esd.Agencyinfo_fromSAP__c;
-                insDetails.Frist_Storage_Agency__c  = ass.esd.Frist_Storage_Agency__c == null ? ass.esd.Dealer_Info_text__c : ass.esd.Frist_Storage_Agency__c;
-                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
-                arriveAmount                            += ass.esd.Intra_Trade_List_RMB__c;
-                orderdetails.add(insDetails);
+          if (codi.esd.Box_Piece__c == '涓�' && codi.esd.Rrturn_count__c > 0) {
+            String key =
+              '' +
+              codi.esd.Consumable_ZS_order__c +
+              codi.esd.Bar_Code__c;
+            Integer deliverycnt = BarcodeCntMap.get(key);
+            if (codi.esd.Rrturn_count__c > deliverycnt) {
+              if (isLwc) {
+                returnError = '瓒呭嚭鍑哄簱鏁伴噺';
+              } else {
+                codi.esd.Rrturn_count__c.addError('瓒呭嚭鍑哄簱鏁伴噺');
+              }
+              return null;
             }
-            Integer i = 1;
-            for(ConsumableorderdetailsInfo ass : consumableInventoryUse){
-                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------2------'));
-                Consumable_order_details2__c insAfterDel = new Consumable_order_details2__c();
-                String str = ('000' + i).right(4);
-                // if(str.length() == 1){
-                //     str = '0' + str;
-                // }
-                insAfterDel.Name                        = consumable_order[0].Name + '-'+ str;
-                insAfterDel.RecordTypeId                = System.Label.RT_ConOrderDetail2_Delivery;
-                // gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
-                // if(EsetId != null && EsetId != ''){
-                //     insAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
-                // }else{
-                //     insAfterDel.Intra_Trade_List_RMB__c = 0;
-                // }
-                insAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
+          }
+        }
+
+        Integer tempNo = 0;
+        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+        List<Consumable_order_details2__c> conOrderDetail2InList = new List<Consumable_order_details2__c>();
+        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+        for (ConsumableorderdetailsInfo codi : ShowGoodsofReturnList) {
+          Consumable_order_details2__c codcorderdet = new Consumable_order_details2__c();
+
+          //鍗曚綅=涓�
+          if (
+            codi.esd.Box_Piece__c == '涓�' &&
+            (codi.esd.Rrturn_count__c == null ||
+            String.valueof(codi.esd.Rrturn_count__c) == '' ||
+            codi.esd.Rrturn_count__c <= 0)
+          ) {
+            continue;
+          }
+
+          if (codi.esd.Box_Piece__c == '涓�' && codi.esd.Rrturn_count__c > 0) {
+            hasReturnGoods = true;
+
+            Integer cnt = 1;
+            for (
+              Consumable_order_details2__c codctmp : consumableorderdetails2Nobox
+            ) {
+              if (
+                codctmp.Consumable_ZS_order__c ==
+                codi.esd.Consumable_ZS_order__c &&
+                codctmp.Bar_Code__c == codi.esd.Bar_Code__c
+              ) {
+                Consumable_order_details2__c esd = codctmp;
+                // esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
+                esd.Return_reason__c = codi.esd.Return_reason__c;
+                esd.Return_date__c = Date.today();
+                // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+                // esd.Return_reason__c                = codi.esd.Return_reason__c;
+                // esd.Return_date__c                  = Date.today();
+                // esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
+                if (
+                  codi.esd.Dealer_Saled__c == false &&
+                  codi.esd.Dealer_Shipment__c == false &&
+                  codi.esd.Lose_Flag__c == true
+                ) {
+                  // esd.Lose_Flag__c = false;
+                  esd.Consumable_Inventory_order__c = Inventory_Order_Sheet.id;
+                  conOrderDetail2InList.add(esd);
+                  hasLoseGoods = true;
+                } else {
+                  // esd.Return_date__c                  = Date.today();
+                  esd.Consumable_Return_order__c = Return_Order_Sheet.id;
+                }
+                // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+                esd.ReturnGs_Uploader_ID__c = UserInfo.getUserId();
+
+                //淇敼杩斿搧鎵�鏈変汉
+                esd.OwnerId = UserInfo.getUserId();
+                esd.RecordTypeId = System.Label.RT_ConOrderDetail2_Return;
+
+                //Consumable_order__c coc = [select name from Consumable_order__c where Id =:Arrived_Order_Sheet.id];
+                codcorderdet = new Consumable_order_details2__c();
+                codcorderdet.Name =
+                  consumable_order_arr[0].name +
+                  '-' +
+                  String.valueOf(++tempNo).leftPad(4, '0');
+                codcorderdet.Consumable_order_minor__c = codi.esd.Consumable_order_minor__c;
+                codcorderdet.Consumable_Arrived_order__c = Arrived_Order_Sheet.id;
+                //淇敼鍒拌揣鎵�鏈変汉
+                codcorderdet.OwnerId = UserInfo.getUserId();
+                codcorderdet.Arrive_date__c = Date.today();
+                codcorderdet.Consumable_Product__c = codi.esd.Consumable_Product__c;
+                codcorderdet.Asset_Model_No__c = codi.esd.Asset_Model_No__c;
+                codcorderdet.Bar_Code__c = codi.esd.Bar_Code__c;
+                codcorderdet.Deliver_date__c = codi.esd.Deliver_date__c;
+                codcorderdet.SerialLotNo__c = codi.esd.SerialLotNo__c;
+                codcorderdet.TracingCode__c = codi.esd.TracingCode__c;
+                codcorderdet.Sterilization_limit__c = codi.esd.Sterilization_limit__c;
                 //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
-                insAfterDel.Asset_Model_No__c           = ass.Prod.Asset_Model_No__c;
-                if(EsetId != null && EsetId != ''){
-                    insAfterDel.Consumable_order_minor__c   = ESetId;
-                }
-                insAfterDel.Deliver_date__c             = Date.today();
-                insAfterDel.Direct_Arrive_Product__c    = true;
-                //TODO寰呯‘璁�
-                insAfterDel.Sterilization_limit__c      = ass.sterilizationlimitDate;
-                insAfterDel.Consumable_Product__c       = ass.Prod.id;
-                insAfterDel.Bar_Code__c                 = ass.barCodeNo;
-                insAfterDel.Used_account__c             = accountid;
-                //TODO寰呯‘璁�
-                insAfterDel.SerialLotNo__c              = ass.serialNoorLotNo;
-                insAfterDel.TracingCode__c              = ass.tracingCodeNo;
+                codcorderdet.Intra_Trade_List_RMB__c = (codi.esd.Intra_Trade_List_RMB__c ==
+                  null ||
+                  codi.esd.Intra_Trade_List_RMB__c == 0)
+                  ? codi.esd.Intra_Trade_List__c
+                  : codi.esd.Intra_Trade_List_RMB__c;
+                codcorderdet.RemoveBox_No__c = codctmp.RemoveBox_No__c;
+                codcorderdet.RemoveBox_date__c = codctmp.RemoveBox_date__c;
+                codcorderdet.Box_Piece__c = codctmp.Box_Piece__c;
 
-                //insAfterDel.Dealer_Arrive__c                = true;
-                insAfterDel.Consumable_Arrived_order__c = orderMain.id;
-                insAfterDel.Arrive_date__c              = Date.today();
-                insAfterDel.OwnerId                      = UserInfo.getUserId();
-                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                if (orderdetails2trMap.containsKey(ass.esd.Bar_Code__c)) {
-                    insAfterDel.Transfer_Time__c = ass.esd.Transfer_Time__c == null ? 1 : ass.esd.Transfer_Time__c;
-                    insAfterDel.Agency_Transfer__c = true;
-                    insAfterDel.Frist_Transfer_Agency__c = ass.esd.Frist_Transfer_Agency__c == null ? accountName : ass.esd.Frist_Transfer_Agency__c;
-                }
-                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                 
-                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
-                insAfterDel.Agencyinfo_fromSAP__c = ass.esd.Agencyinfo_fromSAP__c;
-                insAfterDel.Frist_Storage_Agency__c  = ass.esd.Frist_Storage_Agency__c == null ? accountName : ass.esd.Frist_Storage_Agency__c;
-                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
-                arriveAmount += insAfterDel.Intra_Trade_List_RMB__c;
-                //add by rentx 2020-10-14 strat
-                //insAfterDel.ContractNo_text__c      = /*ass.esd.ContractNo__c*/;
+                //add by rentx 2020-10-13 start 杩斿搧鏃舵柊鏁版嵁璁板綍SAP鍚堝悓鍙�
+                // codcorderdet.ContractNo_text__c= codctmp.ContractNo__c;
                 // tcm start
-                if (String.isBlank(ass.esd.Consumable_order_minor__r.ContractNo__c)) {
-                    insAfterDel.ContractNo_text__c= ass.esd.ContractNo_text__c;
-                }else {
-                    insAfterDel.ContractNo_text__c= ass.esd.Consumable_order_minor__r.ContractNo__c;
+                if (
+                  String.isBlank(
+                    codctmp.Consumable_order_minor__r.ContractNo__c
+                  )
+                ) {
+                  codcorderdet.ContractNo_text__c = codctmp.ContractNo_text__c;
+                } else {
+                  codcorderdet.ContractNo_text__c = codctmp.Consumable_order_minor__r.ContractNo__c;
                 }
                 // tcm end
-                //add by rentx 2020-10-14 end
-                i++;
-
-                ins.add(insAfterDel);
-
-            }
-            orderMain.Arrive_total_amount__c = arriveAmount;
-            update orderMain;
-            List<Consumable_order_details2__c> updateconsumableorderdetails2 = new List<Consumable_order_details2__c>();
-            //鏇存柊鏄庣粏鍙栨秷鏃堕棿 => 鏈埌璐у彇娑堬紝鍒拌揣鑷姩鐢熸垚鍑哄簱娴佺▼
-            List<Consumable_order_details2__c> addSaleOrderList = new List<Consumable_order_details2__c> ();
-            for(Consumable_order_details2__c Cod : consumableorderdetails2Cancle){
-                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------3------'));
-                if (Cod.Dealer_Arrive__c) {
-                    if (Cod.Dealer_Shipment__c == FALSE && Cod.Dealer_Saled__c == FALSE) {
-                        addSaleOrderList.add(Cod);
-                    }
-                } else {
-                    Cod.Cancellation_Date__c = Date.today();
-                    Cod.Cancellation_Flag__c = true;
-                    updateconsumableorderdetails2.add(Cod);
-                }
-            }
-
-            if (addSaleOrderList.size() > 0) {
-                addSaleOrderAuto(addSaleOrderList);
-            }
-
-            if(updateconsumableorderdetails2.size() > 0){
-                update updateconsumableorderdetails2;
-            }
-            List<Consumable_order_details2__c> insertconsumableorderdetails2 = new List<Consumable_order_details2__c>();
-            for(Consumable_order_details2__c Cod2 : consumableorderdetails2Insert){
-                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------4------'));
-                String str = ('000' + i).right(4);
-                // if(str.length() == 1){
-                //     str = '0' + str;
-                // }
-                Cod2.Name                        = consumable_order[0].Name + '-'+ str;
-                Cod2.Consumable_order_minor__c   = null;
-                Cod2.Deliver_date__c             = Date.today();
-                Cod2.Used_account__c             = accountid;
-                Cod2.Consumable_Arrived_order__c = orderMain.id;
-                Cod2.Arrive_date__c              = Date.today();
-                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 start
-                if (orderdetails2trMap.containsKey(Cod2.Bar_Code__c)) {
-                    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------4++++++' + Cod2.Frist_Storage_Agency__c));
-                    Cod2.Transfer_Time__c = Cod2.Transfer_Time__c == null ? 1 : Cod2.Transfer_Time__c;
-                    Cod2.Agency_Transfer__c = true;
-                    Cod2.Frist_Transfer_Agency__c = Cod2.Frist_Transfer_Agency__c == null ? accountName : Cod2.Frist_Transfer_Agency__c;
-                }
-                // 鏇存柊鍊熻皟淇℃伅 add by gzw 2020-0-415 end
-                 
-                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
-                Cod2.Agencyinfo_fromSAP__c        = Cod2.Agencyinfo_fromSAP__c;
-                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------4------' + Cod2.Frist_Storage_Agency__c));
-                Cod2.Frist_Storage_Agency__c      = Cod2.Frist_Storage_Agency__c == null ? accountName : Cod2.Frist_Storage_Agency__c;
-                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
-                insertconsumableorderdetails2.add(Cod2);
-                i++;
-            }
-
-            // return null;
-
-            if(insertconsumableorderdetails2.size() >0){
-                insert insertconsumableorderdetails2;
-            }
-
-            if(ins.size()>0){
-                insert ins;
-            }
-            if(orderdetails.size()>0){
-                ControllerUtil.updateOrderDetailsSatus(orderdetails);
-            }
-            //瓒呭嚭鍒拌揣鏁伴噺浜у搧鍙栨秷鏃ユ湡鏇存柊
-            List<Consumable_order_details2__c> needcanceldet = new List<Consumable_order_details2__c>();
-            if(cancellationProList.size() > 0){
-                needcanceldet = [SELECT Id,
-                                    Cancellation_Date__c
-                                FROM Consumable_order_details2__c
-                                WHERE Asset_Model_No__c in :cancellationProList
-                                AND Consumable_order_minor__c = :ESetId
-                                AND Dealer_Arrive__c = FALSE
-                                AND Cancellation_Date__c = null ];
-                if(needcanceldet.size() >0){
-                    for(Integer a = 0; a < needcanceldet.size(); a++){
-                        needcanceldet[a].Cancellation_Date__c = Date.today();
-                        needcanceldet[a].Cancellation_Flag__c = true;
-                    }
-                    ControllerUtil.updateOrderDetailsSatus(needcanceldet);
-                }
-            }
-            List<Consumable_order__c> qs = New List<Consumable_order__c>();
-            qs = [SELECT Id,Name,Order_status__c,Dealer_Info__c,Deliver_date__c,ReturnGs_Upload_Date__c,
-                        Order_Reason__c,Order_date__c,
-                        Contract_application_decision__c,Order_type__c,Total_num__c,
-                        OrderNumber_arrived__c,Delivery_detail_count__c,OrderNumber_notarrive__c
-                    FROM Consumable_order__c
-                    WHERE Id =:ESetId
-                    AND Dealer_Info__c = :accountid];
-            if (qs.size()>0){
-                coc = qs[0];
-            }
-            saveFLGbln = true;
-            alertMessage = '鍒拌揣瀹屾垚銆�';
-            // Integer a = 1/0;
-        }catch(Exception e){
-            Database.rollback(sp);
-            ApexPages.addMessages(e);
-            return null;
-        }
-        if(resultcheck.length() > 0){
-            return null;
-        }else if(resultcheckWithoutOrder.size() >0){
-            return null;
-        } else{
-            return UnabletoEdit();
-            // return null;
-        }
-    }
-    
-    // 杩斿搧妫�鏌ワ紝鍚庡洖搴�
-    public integer GoodsReturnCheck(){
-        List<String> GrListIn  =   ParseBarCode(   barcode );
-        GrList = new List<String>();
-        Map<String,String>  CheckBarcodeResult  =   new Map<String,String>();
-        for(    String  Str :   GrListIn  ){
-            CheckBarcodeResult.put( str , 'UnFind');
-        }
-        List<Consumable_order_details2__c>   BarcodeRetrunResult =
-                 [  SELECT  Id,Name,Intra_Trade_List_RMB__c,Asset_Model_No__c,
-                            Consumable_Product__c,Consumable_Product__r.Name,
-                            Consumable_Product__r.Name__c,Consumable_Product__r.Asset_Model_No__c,
-                            Sterilization_limit__c,Deliver_date__c,Bar_Code__c,
-                            Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,
-                            Consumable_order_minor__c,Dealer_Arrive__c,
-                            Guarantee_period_for_products__c,CFDA_Status__c,
-                            ProductPacking_list_manual__c,Report_Product_Approbation__c,
-                            Report_Product_Expiration__c,Box_Piece__c, Rrturn_count__c,
-                            Product_Type__c
-                            //add by rentx 2020-10-14 start
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                            // tcm start
-                            ,Consumable_order_minor__r.ContractNo__c
-                            // tcm end
-                            //add by rentx 2020-10-14 end
-                    FROM    Consumable_order_details2__c
-                    WHERE   ((Dealer_Arrive__c = true
-                            AND(  Dealer_Shipment__c = true
-                                    //AND Consumable_Shipment_order__r.SummonsForDirction__c != '浜掔浉璋冭揣')
-                                  or  Dealer_Saled__c = true
-                                )
-                            ))
-                    AND     Dealer_Info_text__c = :accountName
-                    AND     Bar_Code__c in :GrListIn
-                    AND     ( not Product_Type__c  like :userPro_Typestr)
-                    AND     Dealer_Returned__c = false
-                    AND     Arrive_Owner_Work_Location__c =: userWorkLocation
-                    ORDER BY Box_Piece__c desc,Name ];
-        if(BarcodeRetrunResult.size()>0){
-            for (Integer i = 0; i < BarcodeRetrunResult.size(); i++) {
-                if(ErrorIdMap.containsKey(BarcodeRetrunResult[i].Bar_Code__c) || ExistIdMap.containsKey(BarcodeRetrunResult[i].Bar_Code__c)){
-                    // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                    continue;
-                }else{
-                    String str = '浜у搧绫诲瀷['+BarcodeRetrunResult[i].Product_Type__c+']涓庣敤鎴风殑绫诲瀷['+userPro_Type+']涓嶇';
-                    ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(BarcodeRetrunResult[i],str));
-                    ErrorIdMap.put(BarcodeRetrunResult[i].Bar_Code__c,BarcodeRetrunResult[i].Bar_Code__c);
-                }
-            }
-        }
-        AllMap.putAll(ErrorIdMap);
-        BarcodeRetrunResult =
-                 [  SELECT  Id,
-                            Consumable_order_minor__c,
-                            Deliver_date__c,
-                            Asset_Model_No__c,
-                            Consumable_Product__c,
-                            Consumable_Product__r.Name,
-                            Consumable_Product__r.Name__c,
-                            Name,
-                            Bar_Code__c,
-                            Arrive_date__c,
-                            Dealer_Shipment__c,
-                            Lose_Flag__c,
-                            Dealer_Saled__c,
-                            Return_reason__c,
-                            Consumable_Shipment_order__c,
-                            Consumable_Shipment_order__r.Name,
-                            Send_date__c,
-                            Consumable_Sale_order__c,
-                            Consumable_Sale_order__r.Name,
-                            Used_date__c,
-                            SerialLotNo__c,
-                            TracingCode__c,
-                            Sterilization_limit__c,
-                            Consumable_ZS_order__c,
-                            Consumable_ZS_order__r.Name,
-                            Product_OutDate__c,
-                            Invoice_Date__c,
-                            recordtypeid,
-                            Consumable_Arrived_order__c,
-                            Box_Piece__c,
-                            Rrturn_count__c,
-                            Intra_Trade_List_RMB__c,
-                            OwnerId,
-                            SummonsForDirction_det__c,
-                            Order_Dealer_Info__c,
-                            HospItal_Name__c,
-                            Agencyinfo_fromSAP__c,
-                            Frist_Storage_Agency__c,
-                            Dealer_Info_text__c,
-                            Used_account__c,
-                            Transfer_Time__c,
-                            Frist_Transfer_Agency__c,
-                            Arrive_Owner_Work_Location__c,
-                            Agency_Transfer__c
-                            //add by rentx 2020-10-14 start
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                            // tcm start
-                            ,Consumable_order_minor__r.ContractNo__c
-                            // tcm end
-                            //add by rentx 2020-10-14 end
-                            ,Report_Product_Expiration__c 
-                            ,Intra_Trade_List__c
-                    FROM    Consumable_order_details2__c
-                    WHERE   ((Dealer_Arrive__c = true
-                            AND(  Dealer_Shipment__c = true
-                                    //AND Consumable_Shipment_order__r.SummonsForDirction__c != '浜掔浉璋冭揣')
-                                  or  Dealer_Saled__c = true
-                                  // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                                  or (Dealer_Shipment__c = false and Dealer_Saled__c = false and Lose_Flag__c = true)
-                                  // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                                )
-                            ))
-                    AND     Dealer_Info_text__c = :accountName
-                    AND     Bar_Code__c in :GrListIn
-                    AND     Product_Type__c  like :userPro_Typestr 
-                    AND     Dealer_Returned__c = false
-                    AND     (Arrive_Owner_Work_Location__c =: userWorkLocation
-                        OR OwnerId = :System.Label.User_OlympusSystem)
-                    ORDER BY Box_Piece__c desc,Name ];
-        ShowGoodsofReturnList   =   new List<ConsumableorderdetailsInfo>();
-
-        //杩斿搧鏃秈stinct澶勭悊
-        if(ArrType=='ReG'){
-            BarcodeRetrunResult = getDistinctZSOrder(BarcodeRetrunResult);
-        }
-
-        for(    Consumable_order_details2__c codc    :   BarcodeRetrunResult ){
-            if(ErrorIdMap.containsKey(codc.Bar_Code__c) || ExistIdMap.containsKey(codc.Bar_Code__c)){
-                // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
-                continue;
-            }else{
-
-                Matcher n = Pattern.compile('[0-9]').matcher(codc.TracingCode__c);
-                if(n.find()){
-                    // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 start
-                            if (codc.TracingCode__c.length() == 5) {
-                                String tr = codc.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()) {
-                                    String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
-                                    ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(codc,str));
-                                    ErrorIdMap.put(codc.Bar_Code__c,codc.Bar_Code__c);
-                                    continue;
-                                }
-                            }
-                            // String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
-                            // ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(codc,str));
-                            // ErrorIdMap.put(codc.Bar_Code__c,codc.Bar_Code__c);
-                            // continue;
-                            // gzw DB202305352696 鍏ュ簱绠$悊缂栫爜楠岃瘉绋嬪簭璋冩暣 end
-                }
-                if( CheckBarcodeResult.containsKey( codc.Bar_Code__c    )){
-                    GrList.add(codc.Bar_Code__c);
-                    if( codc.Dealer_Shipment__c ==  true){
-                        CheckBarcodeResult.put( codc.Bar_Code__c,   '宸插嚭搴�'   );
-                        ShowGoodsofReturnList.add(  new ConsumableorderdetailsInfo( codc    )   );
-                    }
-                    // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                    // else{
-                    //     CheckBarcodeResult.put( codc.Bar_Code__c, '宸查攢鍞�');
-                    //     ShowGoodsofReturnList.add(  new ConsumableorderdetailsInfo( codc    )   );
-                    // }
-                    else if( codc.Dealer_Saled__c == true ){
-                        CheckBarcodeResult.put( codc.Bar_Code__c, '宸查攢鍞�');
-                        ShowGoodsofReturnList.add(  new ConsumableorderdetailsInfo( codc    )   );
-                    }else{
-                        CheckBarcodeResult.put( codc.Bar_Code__c, '宸蹭涪澶�');
-                        ShowGoodsofReturnList.add(  new ConsumableorderdetailsInfo( codc    )   );
-                    }
-                    // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                }else{
-                    continue;
-                }
-            }
-        }
-
-        return BarcodeRetrunResult.size();
-    }
-
-    // 鍗曚綅涓轰釜鐨凚arcode瀵瑰簲鐨勫嚭搴撳崟
-    public integer Getconsumableorderdetails2Nobox(){
-        consumableorderdetails2Nobox = new List<Consumable_order_details2__c>();
-        BarcodeCntMap.clear();
-        consumableorderdetails2Nobox =
-                 [  SELECT  Id,
-                            Consumable_order_minor__c,
-                            Deliver_date__c,
-                            Asset_Model_No__c,
-                            Consumable_Product__c,
-                            Consumable_Product__r.Name,
-                            Consumable_Product__r.Name__c,
-                            Name,
-                            Bar_Code__c,
-                            Arrive_date__c,
-                            Dealer_Shipment__c,
-                            Dealer_Saled__c,
-                            Return_reason__c,
-                            Consumable_Shipment_order__c,
-                            Send_date__c,
-                            Consumable_Sale_order__c,
-                            Used_date__c,
-                            SerialLotNo__c,
-                            TracingCode__c,
-                            Sterilization_limit__c,
-                            Consumable_ZS_order__c,
-                            Consumable_ZS_order__r.Name,
-                            Product_OutDate__c,
-                            Invoice_Date__c,
-                            recordtypeid,
-                            Consumable_Arrived_order__c,
-                            Box_Piece__c,
-                            RemoveBox_No__c,
-                            RemoveBox_date__c,
-                            Rrturn_count__c,
-                            Dealer_Info_text__c,
-                            Arrive_Owner_Work_Location__c,
-                            Intra_Trade_List_RMB__c
-                            //add by rentx 2020-10-13 start 杩斿搧鏃� 鏂版暟鎹褰昐AP鍚堝悓鍙�
-                            ,ContractNo_text__c/*,ContractNo__c*/
-                             // tcm start
-                             ,Consumable_order_minor__r.ContractNo__c
-                             // tcm end
-                            ,Report_Product_Expiration__c
-                            //add by rentx 2020-10-13 end
-                            ,Intra_Trade_List__c
-                            //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
-                    FROM    Consumable_order_details2__c
-                    WHERE
-                            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                            // (Dealer_Shipment__c = true or Dealer_Saled__c =  true)
-                            (Dealer_Shipment__c = true or Dealer_Saled__c =  true or (Dealer_Shipment__c = false and Dealer_Saled__c = false and Lose_Flag__c = true))
-                            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                    AND     Dealer_Info_text__c = :accountName
-                    AND     Bar_Code__c in :noboxBarcodeList
-                    AND     Arrive_Owner_Work_Location__c =: userWorkLocation
-                    AND     Dealer_Returned__c = false
-                    AND     Box_Piece__c = '涓�'
-                    ORDER BY Consumable_ZS_order__c,RemoveBox_No__c];
-
-         AggregateResult[] results = [SELECT  Consumable_ZS_order__c,Bar_Code__c,count(Id) recordCount 
-                                      FROM Consumable_order_details2__c 
-                                      WHERE Dealer_Arrive__c = true
-                                      // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                                      // AND  (Dealer_Shipment__c= true OR  Dealer_Saled__c = true)
-                                      AND  (Dealer_Shipment__c= true OR  Dealer_Saled__c = true or(Dealer_Shipment__c = false and Dealer_Saled__c = false and Lose_Flag__c = true))
-                                      // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                                      AND  Dealer_Returned__c = false
-                                      AND  Bar_Code__c in :noboxBarcodeList
-                                      AND  Arrive_Owner_Work_Location__c =: userWorkLocation
-                                      AND  Box_Piece__c = '涓�'
-                                      AND Dealer_Info_text__c = :accountName
-                                      GROUP BY Consumable_ZS_order__c,Bar_Code__c];
-
-        for(AggregateResult ar: results){               
-            String key = '' + ar.get('Consumable_ZS_order__c') + ar.get('Bar_Code__c');
-            BarcodeCntMap.put(key, Integer.valueOf(ar.get('recordCount')));
-        }
-                                         
-        return consumableorderdetails2Nobox.size();
-    }
-
-    //distinct
-    public List<Consumable_order_details2__c>  getDistinctZSOrder(List<Consumable_order_details2__c>  duplicates){
-        List<Consumable_order_details2__c>  distinctOrder = new List<Consumable_order_details2__c>();
-        
-        for(Consumable_order_details2__c details2 : duplicates){
-            Boolean found = false;
-            for(Consumable_order_details2__c result : distinctOrder){
-                if(details2.Consumable_ZS_order__c == result.Consumable_ZS_order__c
-                   && details2.Bar_Code__c == result.Bar_Code__c){
-                    found = true;
-                    break;
-                }
-            }
-
-            if(!found){
-                distinctOrder.add(details2);
-
-                if(details2.Box_Piece__c == '涓�') noboxBarcodeList.add(details2.Bar_Code__c);
-            } 
-        }
-        return distinctOrder;
-    }
-
-        // Update杩斿搧鏄庣粏淇℃伅
-    public Pagereference UpdateGoodsOfReturn(){
-        if( ShowGoodsofReturnList==null){
-            GoodsReturnCheck();
-        }
-        Getconsumableorderdetails2Nobox();
-
-        Savepoint sp = Database.setSavepoint();
-        boolean hasReturnGoods = false;
-        boolean hasLoseGoods = false;
-        try{
-            if( ShowGoodsofReturnList.size() >0 || consumableInventory.size()>0 ){
-
-                Consumable_order__c Return_Order_Sheet     = new Consumable_order__c();
-                Return_Order_Sheet.Name                    ='*';
-                Return_Order_Sheet.Order_status__c         = '鎵瑰噯';
-                Return_Order_Sheet.ReturnGs_Uploader_ID__c = UserInfo.getUserId();
-                Return_Order_Sheet.ReturnGs_Upload_Date__c = Date.today();
-                Return_Order_Sheet.Order_type__c           = '杩斿搧';
-                Return_Order_Sheet.RecordTypeid            =System.Label.Dealer_Returned_Label;
-                Return_Order_Sheet.Order_ProType__c        = userPro_Type;
-                insert Return_Order_Sheet;
-                return_Order_id = Return_Order_Sheet.id;
-                List<Consumable_order__c> consumable_order_ret = [SELECT Name FROM Consumable_order__c WHERE id =:Return_Order_Sheet.id];
-                
-                //2017-07-03 鍒拌揣璁㈠崟
-                Consumable_order__c Arrived_Order_Sheet     = new Consumable_order__c();
-                Arrived_Order_Sheet.Name                    ='*';
-                Arrived_Order_Sheet.Order_status__c         = '鎵瑰噯';
-                Arrived_Order_Sheet.Order_type__c           = '鍒拌揣';
-                Arrived_Order_Sheet.Dealer_Info__c          =accountid;
-                Arrived_Order_Sheet.RecordTypeid            =System.Label.RT_ConOrder_Arrive;
-                Arrived_Order_Sheet.Order_ProType__c        = userPro_Type;
-                insert Arrived_Order_Sheet;
-                List<Consumable_order__c> consumable_order_arr = [SELECT Name FROM Consumable_order__c WHERE id =:Arrived_Order_Sheet.id];
+                //add by rentx 2020-10-13 end   杩斿搧鏃舵柊鏁版嵁璁板綍SAP鍚堝悓鍙�
 
                 // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                // 铏氭嫙鐩樼偣鍗�
-                Consumable_order__c Inventory_Order_Sheet     = new Consumable_order__c();
-                Inventory_Order_Sheet.Name                    ='*';
-                Inventory_Order_Sheet.Order_status__c         = '鎵瑰噯';
-                Inventory_Order_Sheet.ReturnGs_Uploader_ID__c = UserInfo.getUserId();
-                Inventory_Order_Sheet.Inventory_date__c       = Date.today();
-                Inventory_Order_Sheet.Dealer_Info__c          =accountid;
-                Inventory_Order_Sheet.ReturnGs_Upload_Date__c = Date.today();
-                Inventory_Order_Sheet.Order_type__c           = '鐩樼偣';
-                Inventory_Order_Sheet.RecordTypeid            = System.Label.RT_ConOrder_Inventory;
-                Inventory_Order_Sheet.Order_ProType__c        = userPro_Type;
-                insert Inventory_Order_Sheet;
-                inventory_Order_id = Inventory_Order_Sheet.id;
-                List<Consumable_order__c> consumable_order_Inv = [SELECT Name FROM Consumable_order__c WHERE id =:Inventory_Order_Sheet.id];
+                if (hasLoseGoods) {
+                  codcorderdet.loseInventory__c = true;
+                }
                 // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
 
-                List<Consumable_order_details2__c>   codcList    =   new List<Consumable_order_details2__c>();
-                //鏂拌杩斿搧瀵瑰簲鐨勪骇鍝佹槑缁�
-                List<Consumable_order_details2__c>   codcorderdetList    =   new List<Consumable_order_details2__c>();
-                //杩斿搧鍘熷洜,杩斿搧鏁伴噺妫�鏌�
-                for( ConsumableorderdetailsInfo  codi    :   ShowGoodsofReturnList ){
-                    if (codi.esd.Box_Piece__c =='涓�' && (
-                        codi.esd.Rrturn_count__c == null || 
-                        String.valueof(codi.esd.Rrturn_count__c) =='' || 
-                        codi.esd.Rrturn_count__c <= 0)){
-                        continue;
-                    }
+                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
+                // 杩斿搧鏃讹紝鈶犺拷鍔犲�熻皟鍊熷嚭鏂逛俊鎭� 鈶′繚鐣欏�熻皟淇℃伅 鈶繚瀛楽AP鍜岀粡閿�鍟嗛娆″彂璐х粡閿�鍟�
+                codcorderdet.Used_account__c = codi.esd.Used_account__c;
+                codcorderdet.Transfer_Time__c = codi.esd.Transfer_Time__c;
+                codcorderdet.Frist_Transfer_Agency__c = codi.esd.Frist_Transfer_Agency__c;
+                codcorderdet.Agency_Transfer__c = codi.esd.Agency_Transfer__c;
 
-                    if(codi.esd.Return_reason__c==null||codi.esd.Return_reason__c==''){
-                        codi.esd.Return_reason__c.addError('璇疯ˉ鍏呰繑鍝佸師鍥�');
-                        return null;
-                    }
+                codcorderdet.Agencyinfo_fromSAP__c = codi.esd.Agencyinfo_fromSAP__c;
+                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------1------' + codi.esd.Frist_Storage_Agency__c));
+                codcorderdet.Frist_Storage_Agency__c = codi.esd.Frist_Storage_Agency__c ==
+                  null
+                  ? codi.esd.Dealer_Info_text__c
+                  : codi.esd.Frist_Storage_Agency__c;
+                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
+                codcorderdetList.add(codcorderdet);
+                codcList.add(esd);
 
-
-                    if(codi.esd.Box_Piece__c=='涓�' && codi.esd.Rrturn_count__c > 0){
-                        String key = '' + codi.esd.Consumable_ZS_order__c + codi.esd.Bar_Code__c;
-                        Integer deliverycnt = BarcodeCntMap.get(key);
-                        if(codi.esd.Rrturn_count__c > deliverycnt){
-                            codi.esd.Rrturn_count__c.addError('瓒呭嚭鍑哄簱鏁伴噺');
-                            return null;
-                        }  
-                    }
-                }
-
-                Integer tempNo=0;
-                // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                List<Consumable_order_details2__c> conOrderDetail2InList = new List<Consumable_order_details2__c>();
-                // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                for( ConsumableorderdetailsInfo  codi    :   ShowGoodsofReturnList ){
-                    Consumable_order_details2__c codcorderdet = new Consumable_order_details2__c();
-                    
-                    //鍗曚綅=涓�
-                    if (codi.esd.Box_Piece__c =='涓�' && (
-                        codi.esd.Rrturn_count__c == null || 
-                        String.valueof(codi.esd.Rrturn_count__c) =='' || 
-                        codi.esd.Rrturn_count__c <= 0)){
-                        continue;
-                    }
-
-                    if(codi.esd.Box_Piece__c=='涓�' && codi.esd.Rrturn_count__c > 0){
-                        hasReturnGoods = true;
-
-                        Integer cnt = 1;
-                        for(Consumable_order_details2__c codctmp    :   consumableorderdetails2Nobox ){
-                            if(codctmp.Consumable_ZS_order__c == codi.esd.Consumable_ZS_order__c && codctmp.Bar_Code__c == codi.esd.Bar_Code__c){
-                                Consumable_order_details2__c esd = codctmp;
-                                // esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
-                                esd.Return_reason__c                = codi.esd.Return_reason__c;
-                                esd.Return_date__c                  = Date.today();
-                                // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                                // esd.Return_reason__c                = codi.esd.Return_reason__c;
-                                // esd.Return_date__c                  = Date.today();
-                                // esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
-                                if(codi.esd.Dealer_Saled__c == false && codi.esd.Dealer_Shipment__c == false && codi.esd.Lose_Flag__c == true){
-                                    // esd.Lose_Flag__c = false;
-                                    esd.Consumable_Inventory_order__c = Inventory_Order_Sheet.id;
-                                    conOrderDetail2InList.add(esd);
-                                    hasLoseGoods = true;
-                                }
-                                else{
-                                    // esd.Return_date__c                  = Date.today();
-                                    esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
-                                    
-                                }
-                                // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                                esd.ReturnGs_Uploader_ID__c         = UserInfo.getUserId();
-                                
-                                //淇敼杩斿搧鎵�鏈変汉
-                                esd.OwnerId                         = UserInfo.getUserId();
-                                esd.RecordTypeId                    = System.Label.RT_ConOrderDetail2_Return;
-                               
-                                //Consumable_order__c coc = [select name from Consumable_order__c where Id =:Arrived_Order_Sheet.id];
-                                codcorderdet = new Consumable_order_details2__c();
-                                codcorderdet.Name                        = consumable_order_arr[0].name + '-' + String.valueOf(++tempNo).leftPad(4,'0');
-                                codcorderdet.Consumable_order_minor__c   = codi.esd.Consumable_order_minor__c;
-                                codcorderdet.Consumable_Arrived_order__c = Arrived_Order_Sheet.id;
-                                //淇敼鍒拌揣鎵�鏈変汉
-                                codcorderdet.OwnerId                     = UserInfo.getUserId();
-                                codcorderdet.Arrive_date__c              = Date.today();
-                                codcorderdet.Consumable_Product__c       = codi.esd.Consumable_Product__c;
-                                codcorderdet.Asset_Model_No__c           = codi.esd.Asset_Model_No__c;
-                                codcorderdet.Bar_Code__c                 = codi.esd.Bar_Code__c;
-                                codcorderdet.Deliver_date__c             = codi.esd.Deliver_date__c;
-                                codcorderdet.SerialLotNo__c              = codi.esd.SerialLotNo__c;
-                                codcorderdet.TracingCode__c              = codi.esd.TracingCode__c;
-                                codcorderdet.Sterilization_limit__c      = codi.esd.Sterilization_limit__c;
-                                //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
-                                codcorderdet.Intra_Trade_List_RMB__c     =  (codi.esd.Intra_Trade_List_RMB__c == null || codi.esd.Intra_Trade_List_RMB__c == 0) ? codi.esd.Intra_Trade_List__c : codi.esd.Intra_Trade_List_RMB__c;
-                                codcorderdet.RemoveBox_No__c             = codctmp.RemoveBox_No__c;
-                                codcorderdet.RemoveBox_date__c           = codctmp.RemoveBox_date__c;
-                                codcorderdet.Box_Piece__c                = codctmp.Box_Piece__c;
-
-                                //add by rentx 2020-10-13 start 杩斿搧鏃舵柊鏁版嵁璁板綍SAP鍚堝悓鍙�
-                                // codcorderdet.ContractNo_text__c= codctmp.ContractNo__c;
-                                // tcm start
-                                if (String.isBlank(codctmp.Consumable_order_minor__r.ContractNo__c)) {
-                                    codcorderdet.ContractNo_text__c= codctmp.ContractNo_text__c;
-                                }else {
-                                    codcorderdet.ContractNo_text__c= codctmp.Consumable_order_minor__r.ContractNo__c;
-                                }
-                                // tcm end
-                                //add by rentx 2020-10-13 end   杩斿搧鏃舵柊鏁版嵁璁板綍SAP鍚堝悓鍙�
-
-
-                                // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                                if(hasLoseGoods){
-                                    codcorderdet.loseInventory__c = true;
-                                }
-                                // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                                 
-                                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
-                                // 杩斿搧鏃讹紝鈶犺拷鍔犲�熻皟鍊熷嚭鏂逛俊鎭� 鈶′繚鐣欏�熻皟淇℃伅 鈶繚瀛楽AP鍜岀粡閿�鍟嗛娆″彂璐х粡閿�鍟�
-                                codcorderdet.Used_account__c             = codi.esd.Used_account__c;
-                                codcorderdet.Transfer_Time__c            = codi.esd.Transfer_Time__c;
-                                codcorderdet.Frist_Transfer_Agency__c    = codi.esd.Frist_Transfer_Agency__c;
-                                codcorderdet.Agency_Transfer__c          = codi.esd.Agency_Transfer__c;
-
-                                codcorderdet.Agencyinfo_fromSAP__c       = codi.esd.Agencyinfo_fromSAP__c;
-                                //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------1------' + codi.esd.Frist_Storage_Agency__c));
-                                codcorderdet.Frist_Storage_Agency__c     = codi.esd.Frist_Storage_Agency__c == null ? codi.esd.Dealer_Info_text__c : codi.esd.Frist_Storage_Agency__c;
-                                // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
-                                codcorderdetList.add(codcorderdet);
-                                codcList.add(   esd    );
-
-                                cnt++;
-                                if(cnt > codi.esd.Rrturn_count__c) break;
-                            }
-
-                        }
-                    }
-                    else{
-                        hasReturnGoods = true;
-                        //鍗曚綅=鐩�
-                        //changeinvoiceInfo(codi.esd);
-                        //Consumable_order__c coc = [select name from Consumable_order__c where Id =:Arrived_Order_Sheet.id];
-                        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                        codi.esd.Return_date__c                  = Date.today();
-                        // codi.esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
-                        if(codi.esd.Dealer_Saled__c == false && codi.esd.Dealer_Shipment__c == false && codi.esd.Lose_Flag__c == true){
-                            codi.esd.Lose_Flag__c = false;
-                            codi.esd.Return_reason__c = '';
-                            codi.esd.Consumable_Inventory_order__c      = Inventory_Order_Sheet.id;
-                            conOrderDetail2InList.add(codi.esd);
-                            hasLoseGoods = true;
-                        }
-                        else{
-                            // codi.esd.Return_date__c                  = Date.today();
-                            codi.esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
-                            
-                        }
-                        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                        codi.esd.ReturnGs_Uploader_ID__c         = UserInfo.getUserId();
-                        // codi.esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
-                        //淇敼杩斿搧鎵�鏈変汉
-                        codi.esd.OwnerId                             = UserInfo.getUserId();
-                        codi.esd.RecordTypeId                    = System.Label.RT_ConOrderDetail2_Return;
-                        codcorderdet.Name                        = consumable_order_arr[0].name + '-' + String.valueOf(++tempNo).leftPad(4,'0');
-                        codcorderdet.Consumable_order_minor__c   = codi.esd.Consumable_order_minor__c;
-                        codcorderdet.Consumable_Arrived_order__c = Arrived_Order_Sheet.id;
-                        //淇敼鍒拌揣鎵�鏈変汉
-                        codcorderdet.OwnerId                     = UserInfo.getUserId();
-                        codcorderdet.Arrive_date__c              = Date.today();
-                        codcorderdet.Consumable_Product__c       = codi.esd.Consumable_Product__c;
-                        codcorderdet.Asset_Model_No__c           = codi.esd.Asset_Model_No__c;
-                        codcorderdet.Bar_Code__c                 = codi.esd.Bar_Code__c;
-                        codcorderdet.Deliver_date__c             = codi.esd.Deliver_date__c;
-                        codcorderdet.SerialLotNo__c              = codi.esd.SerialLotNo__c;
-                        codcorderdet.TracingCode__c              = codi.esd.TracingCode__c;
-                        codcorderdet.Sterilization_limit__c      = codi.esd.Sterilization_limit__c;
-                        //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
-                        codcorderdet.Intra_Trade_List_RMB__c     =  (codi.esd.Intra_Trade_List_RMB__c == null || codi.esd.Intra_Trade_List_RMB__c == 0) ? codi.esd.Intra_Trade_List__c : codi.esd.Intra_Trade_List_RMB__c;
-                        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                        if(hasLoseGoods){
-                            codcorderdet.loseInventory__c = true;
-                        }
-                        // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-                        // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
-                        // 杩斿搧鏃讹紝鈶犺拷鍔犲�熻皟鍊熷嚭鏂逛俊鎭� 鈶′繚鐣欏�熻皟淇℃伅 鈶繚瀛楽AP鍜岀粡閿�鍟嗛娆″彂璐х粡閿�鍟�
-                        codcorderdet.Used_account__c             = codi.esd.Used_account__c;
-                        codcorderdet.Transfer_Time__c            = codi.esd.Transfer_Time__c;
-                        codcorderdet.Frist_Transfer_Agency__c    = codi.esd.Frist_Transfer_Agency__c;
-                        codcorderdet.Agency_Transfer__c          = codi.esd.Agency_Transfer__c;
-
-                        codcorderdet.Agencyinfo_fromSAP__c        = codi.esd.Agencyinfo_fromSAP__c;
-                        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------2------' + codi.esd.Frist_Storage_Agency__c));
-                        codcorderdet.Frist_Storage_Agency__c      = codi.esd.Frist_Storage_Agency__c == null ? codi.esd.Dealer_Info_text__c : codi.esd.Frist_Storage_Agency__c;
-                        // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
-
-                        //add by rentx 2020-10-13 start 杩斿搧鏃舵柊鏁版嵁璁板綍SAP鍚堝悓鍙�
-                        // codcorderdet.ContractNo_text__c          = /*codi.esd.ContractNo__c*/;
-                        // tcm start
-                        if (String.isBlank(codi.esd.Consumable_order_minor__r.ContractNo__c)) {
-                            codcorderdet.ContractNo_text__c= codi.esd.ContractNo_text__c;
-                        }else {
-                            codcorderdet.ContractNo_text__c= codi.esd.Consumable_order_minor__r.ContractNo__c;
-                        }
-                        // tcm end
-                        //add by rentx 2020-10-13 end   杩斿搧鏃舵柊鏁版嵁璁板綍SAP鍚堝悓鍙�
-
-                        codcorderdetList.add(codcorderdet);
-                        codcList.add(   codi.esd    );
-                    }
-                }
-                //鏄庣粏2涓嶅瓨鍦ㄧ殑瀵瑰簲鐨勫埌璐ц鍗曟槑缁� 2017-07-05
-                Integer i = 1;
-                //for(ConsumableorderdetailsInfo ass : consumableInventoryUse){
-                for(ConsumableorderdetailsInfo ass : consumableInventory){
-                    hasReturnGoods = true;
-                    Consumable_order_details2__c codcorderdetail = new Consumable_order_details2__c();
-                    Consumable_order_details2__c retorddetail = new Consumable_order_details2__c();
-                    String str = ('000' + i).right(4);
-                    // if(str.length() == 1){
-                    //     str = '0' + str;
-                    // }
-
-                    if(ass.ReturnReason==null || ass.ReturnReason==''){
-                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'璇疯ˉ鍏呰繑鍝佸師鍥�'));
-                        return null;
-                    }
-
-                    //鍒拌揣鏄庣粏
-                    codcorderdetail.Name                        = consumable_order_arr[0].Name + '-'+ str;
-                    codcorderdetail.RecordTypeId                = System.Label.RT_ConOrderDetail2_Delivery;
-                    codcorderdetail.Intra_Trade_List_RMB__c     = ass.Prod.Intra_Trade_List_RMB__c;
-                    //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
-                    codcorderdetail.Asset_Model_No__c           = ass.Prod.Asset_Model_No__c;
-                    codcorderdetail.Direct_Arrive_Product__c    = true;
-                    codcorderdetail.Sterilization_limit__c      = ass.sterilizationlimitDate;
-                    codcorderdetail.Consumable_Product__c       = ass.Prod.id;
-                    codcorderdetail.Bar_Code__c                 = ass.barCodeNo;
-                    codcorderdetail.SerialLotNo__c              = ass.serialNoorLotNo;
-                    codcorderdetail.TracingCode__c              = ass.tracingCodeNo;
-                    codcorderdetail.Consumable_Arrived_order__c = Arrived_Order_Sheet.id;
-                    codcorderdetail.Arrive_date__c              = Date.today();
-
-                    //add by rentx 2020-10-14 start
-                    // codcorderdetail.ContractNo_text__c          = /*ass.esd.ContractNo__c*/;
-                    // tcm start
-                    if (String.isBlank(ass.esd.Consumable_order_minor__r.ContractNo__c)) {
-                        codcorderdetail.ContractNo_text__c= ass.esd.ContractNo_text__c;
-                    }else {
-                        codcorderdetail.ContractNo_text__c= ass.esd.Consumable_order_minor__r.ContractNo__c;
-                    }
-                    // tcm end
-                    //add by rentx 2020-10-14 end
-
-                    codcorderdetList.add(codcorderdetail);
-
-                    //杩斿搧鏄庣粏
-                    retorddetail.Return_reason__c            = ass.ReturnReason;
-                    retorddetail.Return_date__c              = Date.today();
-                    retorddetail.ReturnGs_Uploader_ID__c     = UserInfo.getUserId();
-
-                    // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
-                    // if(ass.esd.Dealer_Saled__c == false && ass.esd.Dealer_Shipment__c == false && ass.esd.Lose_Flag__c == true){
-                    //     retorddetail.Consumable_Inventory_order__c  = Inventory_Order_Sheet.id;
-                    //     retorddetail.loseInventory__c = true;
-                    // }
-                    retorddetail.Consumable_Return_order__c  = Return_Order_Sheet.id;
-                    // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
-
-                    
-                    retorddetail.Name                        = consumable_order_ret[0].Name + '-'+ str;
-                    retorddetail.RecordTypeId                = System.Label.RT_ConOrderDetail2_Return;
-                    retorddetail.Intra_Trade_List_RMB__c     = ass.Prod.Intra_Trade_List_RMB__c;
-                    //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
-                    retorddetail.Dealer_Info_IF__c           = accountid;
-                    retorddetail.Asset_Model_No__c           = ass.Prod.Asset_Model_No__c;
-                    retorddetail.Direct_Arrive_Product__c    = true;
-                    retorddetail.Sterilization_limit__c      = ass.sterilizationlimitDate;
-                    retorddetail.Consumable_Product__c       = ass.Prod.id;
-                    retorddetail.Bar_Code__c                 = ass.barCodeNo;
-                    retorddetail.SerialLotNo__c              = ass.serialNoorLotNo;
-                    retorddetail.TracingCode__c              = ass.tracingCodeNo;
-                    retorddetail.Arrive_date__c              = Date.today();
-                    retorddetail.Deliver_date__c             = Date.today();
-                    // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
-                    retorddetail.Frist_Storage_Agency__c      = accountName;
-                    // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
-
-                    //add by rentx 2020-10-14 start
-                    // retorddetail.ContractNo_text__c         = /*ass.esd.ContractNo__c*/;
-                    // tcm start
-                     if (String.isBlank(ass.esd.Consumable_order_minor__r.ContractNo__c)) {
-                        retorddetail.ContractNo_text__c= ass.esd.ContractNo_text__c;
-                     }else {
-                        retorddetail.ContractNo_text__c= ass.esd.Consumable_order_minor__r.ContractNo__c;
-                     }
-                    // tcm end
-                    //add by rentx 2020-10-14 end
-
-                    codcorderdetList.add(retorddetail);
-                    i++;
-                }
-
-                // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------end------'));
-                // return null;
-
-                if(codcList.size()>0){
-                    ControllerUtil.updateOrderDetailsSatus(   codcList    );
-                    //insert codcorderdetList;
-                }
-                if (codcorderdetList.size()>0){
-                    System.debug('codcorderdetList +++++ '+ codcorderdetList);
-                    insert codcorderdetList;
-                }
-                // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
-                if(conOrderDetail2InList.size() > 0){
-                    addInventoryDetails1(conOrderDetail2InList);
-                }
-                // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
-
-                if(hasReturnGoods){
-                    // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
-                    // return ToReturnGoodsPage();
-                    if(hasLoseGoods){
-                        return ToInventoryGoodsPage();
-                        // return null;
-                    }else{
-                        return ToReturnGoodsPage();
-                        // return null;
-                    }
-                    // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
-                }
-                else{
-                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'娌℃湁闇�瑕佺櫥褰曠殑杩斿搧'));
-                    return null;
-                }
-
-            }else{
-                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'娌℃湁闇�瑕佺櫥褰曠殑杩斿搧'));
-                return null;
+                cnt++;
+                if (cnt > codi.esd.Rrturn_count__c)
+                  break;
+              }
             }
-        }catch(Exception e){
-            Database.rollback(sp);
-            ApexPages.addMessages(e);
+          } else {
+            hasReturnGoods = true;
+            //鍗曚綅=鐩�
+            //changeinvoiceInfo(codi.esd);
+            //Consumable_order__c coc = [select name from Consumable_order__c where Id =:Arrived_Order_Sheet.id];
+            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+            codi.esd.Return_date__c = Date.today();
+            // codi.esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
+            if (
+              codi.esd.Dealer_Saled__c == false &&
+              codi.esd.Dealer_Shipment__c == false &&
+              codi.esd.Lose_Flag__c == true
+            ) {
+              codi.esd.Lose_Flag__c = false;
+              codi.esd.Return_reason__c = '';
+              codi.esd.Consumable_Inventory_order__c = Inventory_Order_Sheet.id;
+              conOrderDetail2InList.add(codi.esd);
+              hasLoseGoods = true;
+            } else {
+              // codi.esd.Return_date__c                  = Date.today();
+              codi.esd.Consumable_Return_order__c = Return_Order_Sheet.id;
+            }
+            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+            codi.esd.ReturnGs_Uploader_ID__c = UserInfo.getUserId();
+            // codi.esd.Consumable_Return_order__c      = Return_Order_Sheet.id;
+            //淇敼杩斿搧鎵�鏈変汉
+            codi.esd.OwnerId = UserInfo.getUserId();
+            codi.esd.RecordTypeId = System.Label.RT_ConOrderDetail2_Return;
+            codcorderdet.Name =
+              consumable_order_arr[0].name +
+              '-' +
+              String.valueOf(++tempNo).leftPad(4, '0');
+            codcorderdet.Consumable_order_minor__c = codi.esd.Consumable_order_minor__c;
+            codcorderdet.Consumable_Arrived_order__c = Arrived_Order_Sheet.id;
+            //淇敼鍒拌揣鎵�鏈変汉
+            codcorderdet.OwnerId = UserInfo.getUserId();
+            codcorderdet.Arrive_date__c = Date.today();
+            codcorderdet.Consumable_Product__c = codi.esd.Consumable_Product__c;
+            codcorderdet.Asset_Model_No__c = codi.esd.Asset_Model_No__c;
+            codcorderdet.Bar_Code__c = codi.esd.Bar_Code__c;
+            codcorderdet.Deliver_date__c = codi.esd.Deliver_date__c;
+            codcorderdet.SerialLotNo__c = codi.esd.SerialLotNo__c;
+            codcorderdet.TracingCode__c = codi.esd.TracingCode__c;
+            codcorderdet.Sterilization_limit__c = codi.esd.Sterilization_limit__c;
+            //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
+            codcorderdet.Intra_Trade_List_RMB__c = (codi.esd.Intra_Trade_List_RMB__c ==
+              null ||
+              codi.esd.Intra_Trade_List_RMB__c == 0)
+              ? codi.esd.Intra_Trade_List__c
+              : codi.esd.Intra_Trade_List_RMB__c;
+            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+            if (hasLoseGoods) {
+              codcorderdet.loseInventory__c = true;
+            }
+            // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+            // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
+            // 杩斿搧鏃讹紝鈶犺拷鍔犲�熻皟鍊熷嚭鏂逛俊鎭� 鈶′繚鐣欏�熻皟淇℃伅 鈶繚瀛楽AP鍜岀粡閿�鍟嗛娆″彂璐х粡閿�鍟�
+            codcorderdet.Used_account__c = codi.esd.Used_account__c;
+            codcorderdet.Transfer_Time__c = codi.esd.Transfer_Time__c;
+            codcorderdet.Frist_Transfer_Agency__c = codi.esd.Frist_Transfer_Agency__c;
+            codcorderdet.Agency_Transfer__c = codi.esd.Agency_Transfer__c;
+
+            codcorderdet.Agencyinfo_fromSAP__c = codi.esd.Agencyinfo_fromSAP__c;
+            //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------2------' + codi.esd.Frist_Storage_Agency__c));
+            codcorderdet.Frist_Storage_Agency__c = codi.esd.Frist_Storage_Agency__c ==
+              null
+              ? codi.esd.Dealer_Info_text__c
+              : codi.esd.Frist_Storage_Agency__c;
+            // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
+
+            //add by rentx 2020-10-13 start 杩斿搧鏃舵柊鏁版嵁璁板綍SAP鍚堝悓鍙�
+            // codcorderdet.ContractNo_text__c          = /*codi.esd.ContractNo__c*/;
+            // tcm start
+            if (
+              String.isBlank(codi.esd.Consumable_order_minor__r.ContractNo__c)
+            ) {
+              codcorderdet.ContractNo_text__c = codi.esd.ContractNo_text__c;
+            } else {
+              codcorderdet.ContractNo_text__c = codi.esd.Consumable_order_minor__r.ContractNo__c;
+            }
+            // tcm end
+            //add by rentx 2020-10-13 end   杩斿搧鏃舵柊鏁版嵁璁板綍SAP鍚堝悓鍙�
+
+            codcorderdetList.add(codcorderdet);
+            codcList.add(codi.esd);
+          }
+        }
+
+        //鏄庣粏2涓嶅瓨鍦ㄧ殑瀵瑰簲鐨勫埌璐ц鍗曟槑缁� 2017-07-05
+        Integer i = 1;
+        //for(ConsumableorderdetailsInfo ass : consumableInventoryUse){
+        for (ConsumableorderdetailsInfo ass : consumableInventory) {
+          hasReturnGoods = true;
+          Consumable_order_details2__c codcorderdetail = new Consumable_order_details2__c();
+          Consumable_order_details2__c retorddetail = new Consumable_order_details2__c();
+          String str = ('000' + i).right(4);
+          // if(str.length() == 1){
+          //     str = '0' + str;
+          // }
+
+          if (ass.ReturnReason == null || ass.ReturnReason == '') {
+            //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+            if (isLwc) {
+              returnError = '璇疯ˉ鍏呰繑鍝佸師鍥�';
+            } else {
+              ApexPages.addmessage(
+                new ApexPages.message(
+                  ApexPages.severity.ERROR,
+                  '璇疯ˉ鍏呰繑鍝佸師鍥�'
+                )
+              );
+            }
             return null;
+          }
+
+          //鍒拌揣鏄庣粏
+          codcorderdetail.Name = consumable_order_arr[0].Name + '-' + str;
+          codcorderdetail.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+          codcorderdetail.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
+          //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
+          codcorderdetail.Asset_Model_No__c = ass.Prod.Asset_Model_No__c;
+          codcorderdetail.Direct_Arrive_Product__c = true;
+          codcorderdetail.Sterilization_limit__c = ass.sterilizationlimitDate;
+          codcorderdetail.Consumable_Product__c = ass.Prod.id;
+          codcorderdetail.Bar_Code__c = ass.barCodeNo;
+          codcorderdetail.SerialLotNo__c = ass.serialNoorLotNo;
+          codcorderdetail.TracingCode__c = ass.tracingCodeNo;
+          codcorderdetail.Consumable_Arrived_order__c = Arrived_Order_Sheet.id;
+          codcorderdetail.Arrive_date__c = Date.today();
+
+          //add by rentx 2020-10-14 start
+          // codcorderdetail.ContractNo_text__c          = /*ass.esd.ContractNo__c*/;
+          // tcm start
+          if (String.isBlank(ass.esd.Consumable_order_minor__r.ContractNo__c)) {
+            codcorderdetail.ContractNo_text__c = ass.esd.ContractNo_text__c;
+          } else {
+            codcorderdetail.ContractNo_text__c = ass.esd.Consumable_order_minor__r.ContractNo__c;
+          }
+          // tcm end
+          //add by rentx 2020-10-14 end
+
+          codcorderdetList.add(codcorderdetail);
+
+          //杩斿搧鏄庣粏
+          retorddetail.Return_reason__c = ass.ReturnReason;
+          retorddetail.Return_date__c = Date.today();
+          retorddetail.ReturnGs_Uploader_ID__c = UserInfo.getUserId();
+
+          // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 start
+          // if(ass.esd.Dealer_Saled__c == false && ass.esd.Dealer_Shipment__c == false && ass.esd.Lose_Flag__c == true){
+          //     retorddetail.Consumable_Inventory_order__c  = Inventory_Order_Sheet.id;
+          //     retorddetail.loseInventory__c = true;
+          // }
+          retorddetail.Consumable_Return_order__c = Return_Order_Sheet.id;
+          // WYIN-BLZE48鐩樼偣涓㈠け浜у搧澧炲姞鍏ュ簱鏂瑰紡 update by vivek 2020-03-05 end
+
+          retorddetail.Name = consumable_order_ret[0].Name + '-' + str;
+          retorddetail.RecordTypeId = System.Label.RT_ConOrderDetail2_Return;
+          retorddetail.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
+          //gzw 鎵嬪姩鍏ュ簱 榛樿浜у搧鍗曚环 20230307
+          retorddetail.Dealer_Info_IF__c = accountid;
+          retorddetail.Asset_Model_No__c = ass.Prod.Asset_Model_No__c;
+          retorddetail.Direct_Arrive_Product__c = true;
+          retorddetail.Sterilization_limit__c = ass.sterilizationlimitDate;
+          retorddetail.Consumable_Product__c = ass.Prod.id;
+          retorddetail.Bar_Code__c = ass.barCodeNo;
+          retorddetail.SerialLotNo__c = ass.serialNoorLotNo;
+          retorddetail.TracingCode__c = ass.tracingCodeNo;
+          retorddetail.Arrive_date__c = Date.today();
+          retorddetail.Deliver_date__c = Date.today();
+          // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 start
+          retorddetail.Frist_Storage_Agency__c = accountName;
+          // 杩藉姞棣栨鍏ュ簱缁忛攢鍟� add by gzw 2020-04-27 end
+
+          //add by rentx 2020-10-14 start
+          // retorddetail.ContractNo_text__c         = /*ass.esd.ContractNo__c*/;
+          // tcm start
+          if (String.isBlank(ass.esd.Consumable_order_minor__r.ContractNo__c)) {
+            retorddetail.ContractNo_text__c = ass.esd.ContractNo_text__c;
+          } else {
+            retorddetail.ContractNo_text__c = ass.esd.Consumable_order_minor__r.ContractNo__c;
+          }
+          // tcm end
+          //add by rentx 2020-10-14 end
+
+          codcorderdetList.add(retorddetail);
+          i++;
         }
+
+        // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'------end------'));
+        // return null;
+
+        if (codcList.size() > 0) {
+          ControllerUtil.updateOrderDetailsSatus(codcList);
+          //insert codcorderdetList;
+        }
+        if (codcorderdetList.size() > 0) {
+          System.debug('codcorderdetList +++++ ' + codcorderdetList);
+          insert codcorderdetList;
+        }
+        // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
+        if (conOrderDetail2InList.size() > 0) {
+          addInventoryDetails1(conOrderDetail2InList);
+        }
+        // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
+
+        if (hasReturnGoods) {
+          // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
+          // return ToReturnGoodsPage();
+          if (hasLoseGoods) {
+            urlType = 'ToInventoryGoodsPage';
+            return ToInventoryGoodsPage();
+            // return null;
+          } else {
+            urlType = 'ToReturnGoodsPage';
+            return ToReturnGoodsPage();
+            // return null;
+          }
+          // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
+        } else {
+          //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+          if (isLwc) {
+            returnError = '娌℃湁闇�瑕佺櫥褰曠殑杩斿搧';
+          } else {
+            ApexPages.addmessage(
+              new ApexPages.message(
+                ApexPages.severity.ERROR,
+                '娌℃湁闇�瑕佺櫥褰曠殑杩斿搧'
+              )
+            );
+          }
+          return null;
+        }
+      } else {
+        //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+        if (isLwc) {
+          returnError = '娌℃湁闇�瑕佺櫥褰曠殑杩斿搧';
+        } else {
+          ApexPages.addmessage(
+            new ApexPages.message(
+              ApexPages.severity.ERROR,
+              '娌℃湁闇�瑕佺櫥褰曠殑杩斿搧'
+            )
+          );
+        }
+        return null;
+      }
+    } catch (Exception e) {
+      Database.rollback(sp);
+      //LWC:Lwcflag鍜屾姤閿欐彁閱� update by Link 2023-04-27
+      if (isLwc) {
+        returnError = e.getLineNumber() + '---' + e.getMessage();
+      } else {
+        ApexPages.addMessages(e);
+      }
+      return null;
+    }
+  }
+
+  public void makeArrivedSummary() {
+    detailsSummary = new List<ConsumableorderdetailsInfo>();
+    //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'consumableInventory   ' + consumableInventory));
+    try {
+      ConsumableorderdetailsInfo arriveDdetailsSummary = null;
+      Map<String, ConsumableorderdetailsInfo> detailsSummaryMap = new Map<String, ConsumableorderdetailsInfo>();
+      for (ConsumableorderdetailsInfo ass : ConsumableorderdetailsRecords) {
+        if (detailsSummaryMap.containsKey(ass.Prod.Id)) {
+          detailsSummaryMap.get(ass.Prod.Id).arrivedCount++;
+          detailsSummaryMap.get(ass.Prod.Id)
+            .arriveAmount += ass.esd.Intra_Trade_List_RMB__c;
+        } else {
+          arriveDdetailsSummary = new ConsumableorderdetailsInfo(ass.Prod);
+          arriveDdetailsSummary.arrivedCount = 1;
+          arriveDdetailsSummary.arriveAmount = ass.esd.Intra_Trade_List_RMB__c;
+          detailsSummaryMap.put(ass.Prod.Id, arriveDdetailsSummary);
+        }
+      }
+      for (ConsumableorderdetailsInfo ass : consumableInventory) {
+        if (detailsSummaryMap.containsKey(ass.Prod.Id)) {
+          detailsSummaryMap.get(ass.Prod.Id).arrivedCount++;
+          if (EsetId != null && EsetId != '') {
+            detailsSummaryMap.get(ass.Prod.Id)
+              .arriveAmount += ass.Prod.Intra_Trade_List_RMB__c;
+          } else {
+            detailsSummaryMap.get(ass.Prod.Id).arriveAmount += 0;
+          }
+        } else {
+          arriveDdetailsSummary = new ConsumableorderdetailsInfo(ass.Prod);
+          arriveDdetailsSummary.arrivedCount = 1;
+          if (EsetId != null && EsetId != '') {
+            arriveDdetailsSummary.arriveAmount = ass.Prod.Intra_Trade_List_RMB__c;
+          } else {
+            arriveDdetailsSummary.arriveAmount = 0;
+          }
+          detailsSummaryMap.put(ass.Prod.Id, arriveDdetailsSummary);
+        }
+      }
+      for (String key : detailsSummaryMap.keySet()) {
+        detailsSummary.add(detailsSummaryMap.get(key));
+      }
+    } catch (Exception e) {
+      //Database.rollback(sp);
+      throw new ControllerUtil.myException(
+        'e::' + e + '  linenumber::' + e.getLineNumber()
+      );
+      // ApexPages.addMessages(e);
+      // ApexPages.addMessages(e.getLineNumber() + '  11111111111111111');
+
+      //return null;
+    }
+  }
+
+  //璺宠浆鍒拌繑鍝侀〉闈�
+  public Pagereference ToReturnGoodsPage() {
+    PageReference ref = new Pagereference('/' + return_Order_id);
+    ref.setRedirect(true);
+    return ref;
+  }
+
+  // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
+  public Pagereference ToInventoryGoodsPage() {
+    PageReference ref = new Pagereference('/' + inventory_Order_id);
+    ref.setRedirect(true);
+    return ref;
+  }
+  // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 end
+
+  // 璺宠浆鍒板埌璐ц鍗曟槑缁�
+  public PageReference UnabletoEdit() {
+    PageReference ref = new Pagereference(
+      '/ArriveGsDetails?EsetId=' + arriveId
+    );
+    ref.setRedirect(true);
+    return ref;
+  }
+
+  public class ConsumableorderdetailsInfo implements Comparable {
+    public Consumable_order_details2__c esd { get; set; }
+    public Product2__c Prod { get; set; }
+    public String ProductName { get; set; }
+    //public Boolean canSELECT { get; set; }
+    public String barCodeNo { get; set; }
+    public Date sterilizationlimitDate { get; set; }
+    public String serialNoorLotNo { get; set; }
+    public String tracingCodeNo { get; set; }
+    public String ReturnReason { get; set; }
+    public String oldConsumableCount { get; set; }
+    public String ErrorReason { get; set; }
+    public boolean canEdit { get; set; }
+    public Integer intMark { get; set; }
+    public Decimal arriveAmount { get; set; }
+    public Decimal arrivedCount { get; set; }
+
+    public String ReportProductExpirationDate { get; set; }
+
+    public ConsumableorderdetailsInfo() {
     }
 
-    public void makeArrivedSummary(){
-        detailsSummary = new List<ConsumableorderdetailsInfo>();
-        //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'consumableInventory   ' + consumableInventory));
-        try{
-            ConsumableorderdetailsInfo arriveDdetailsSummary = null;
-            Map<String,ConsumableorderdetailsInfo> detailsSummaryMap = new Map<String,ConsumableorderdetailsInfo>();
-            for(ConsumableorderdetailsInfo ass : ConsumableorderdetailsRecords){
-                if(detailsSummaryMap.containsKey(ass.Prod.Id)){
-                    detailsSummaryMap.get(ass.Prod.Id).arrivedCount ++;
-                    detailsSummaryMap.get(ass.Prod.Id).arriveAmount += ass.esd.Intra_Trade_List_RMB__c;
-                }else{
-                    arriveDdetailsSummary = new ConsumableorderdetailsInfo(ass.Prod);
-                    arriveDdetailsSummary.arrivedCount = 1;
-                    arriveDdetailsSummary.arriveAmount = ass.esd.Intra_Trade_List_RMB__c;
-                    detailsSummaryMap.put(ass.Prod.Id, arriveDdetailsSummary);
-                }
-            }
-            for(ConsumableorderdetailsInfo ass : consumableInventory){
-                if(detailsSummaryMap.containsKey(ass.Prod.Id)){
-                    detailsSummaryMap.get(ass.Prod.Id).arrivedCount ++;
-                    if(EsetId != null && EsetId != ''){
-                        detailsSummaryMap.get(ass.Prod.Id).arriveAmount += ass.Prod.Intra_Trade_List_RMB__c;
-                    }else{
-                        detailsSummaryMap.get(ass.Prod.Id).arriveAmount += 0;
-                    }
-                }else{
-                    arriveDdetailsSummary = new ConsumableorderdetailsInfo(ass.Prod);
-                    arriveDdetailsSummary.arrivedCount = 1;
-                    if(EsetId != null && EsetId != ''){
-                        arriveDdetailsSummary.arriveAmount = ass.Prod.Intra_Trade_List_RMB__c;
-                    }else{
-                        arriveDdetailsSummary.arriveAmount = 0;
-                    }
-                    detailsSummaryMap.put(ass.Prod.Id, arriveDdetailsSummary);
-                }
-            }
-            for(String key : detailsSummaryMap.keySet()){
-                detailsSummary.add(detailsSummaryMap.get(key));
-            }
-        }catch(Exception e){
-            //Database.rollback(sp);
-            throw new ControllerUtil.myException('e::'+e + '  linenumber::'+e.getLineNumber());
-            // ApexPages.addMessages(e);
-            // ApexPages.addMessages(e.getLineNumber() + '  11111111111111111');
+    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;
+      }
 
-            //return null;
-        }
+      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 Pagereference ToReturnGoodsPage(){
-        PageReference ref = new Pagereference('/'+return_Order_id);
-            ref.setRedirect(true);
-            return ref;
-    }
-    
-    // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 start
-    public Pagereference ToInventoryGoodsPage(){
-        PageReference ref = new Pagereference('/'+inventory_Order_id);
-            ref.setRedirect(true);
-            return ref;
-    }
-    // WYIN-BPE3T4 铏氭嫙鐩樼偣鍗� update by vivek 2020-05-11 end
-
-        // 璺宠浆鍒板埌璐ц鍗曟槑缁�
-    public PageReference UnabletoEdit(){
-        PageReference ref = new Pagereference('/ArriveGsDetails?EsetId='+arriveId);
-        ref.setRedirect(true);
-        return ref;
+    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 = '';
     }
 
-    class ConsumableorderdetailsInfo implements Comparable {
-        public Consumable_order_details2__c esd { get; set; }
-        public Product2__c Prod { get; set; }
-        public String ProductName { get; set; }
-        //public Boolean canSELECT { get; set; }
-        public String barCodeNo { get; set; }
-        public Date sterilizationlimitDate { get; set; }
-        public String serialNoorLotNo { get; set; }
-        public String tracingCodeNo { get; set; }
-        public String ReturnReason { get; set; }
-        public String oldConsumableCount { get; set; }
-        public String ErrorReason { get; set; }
-        public boolean canEdit { get; set; }
-        public Integer intMark { get; set; }
-        public Decimal arriveAmount { get; set; }
-        public Decimal arrivedCount { get; set; }
-
-        public String ReportProductExpirationDate {get;set;}
-        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;
-        }
+    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();
+      }
     }
-}
\ No newline at end of file
+    public ConsumableorderdetailsInfo(Product2__c e) {
+      Prod = e;
+    }
+    // 鎺掑簭
+    public Integer compareTo(Object compareTo) {
+      return null;
+    }
+  }
+}
diff --git a/force-app/main/default/classes/ArriveGoodsControllerTest.cls b/force-app/main/default/classes/ArriveGoodsControllerTest.cls
index 74e567e..786dab4 100644
--- a/force-app/main/default/classes/ArriveGoodsControllerTest.cls
+++ b/force-app/main/default/classes/ArriveGoodsControllerTest.cls
@@ -1,859 +1,1297 @@
 @isTest
 private class ArriveGoodsControllerTest {
-    @isTest(SeeAllData=true)
-	static void myUnitTest() {
-		// // TO DO: implement unit test
-		// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		// if (rectCo.size() == 0) {
-		// 	return;
-		// }
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+  @isTest
+  static void myUnitTest() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'Test001',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = 'Test002',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      //璁㈠崟
+      Consumable_order__c Order1 = new Consumable_order__c();
+      Order1.Name = 'OCM_01_001';
+      Order1.Order_status__c = '鎵瑰噯';
+      Order1.Order_type__c = '璁㈠崟';
+      // Order1.Dealer_Info__c = myAccount1.id;
+      Order1.Dealer_Info__c = myAccount1.id;
+      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      Order1.Total_num__c = 3;
+      Order1.OrderNumber_arrived__c = 1;
+      Order1.Delivery_detail_count__c = 1;
+      Order1.Order_ProType__c = 'ET';
+      insert Order1;
 
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
+      //璁㈠崟鏄庣粏
+      //fahuo
+      Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      Orderdet.Name = 'OCM_01_00101';
+      Orderdet.Consumable_order__c = Order1.Id;
+      Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      Orderdet.Consumable_Product__c = pro1.Id;
+      Orderdet.Consumable_count__c = 40;
+      insert Orderdet;
 
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
-			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
-			insert new Product2__c[] {pro1, pro2};
-			//璁㈠崟
-			Consumable_order__c Order1 = new Consumable_order__c();
-			Order1.Name = 'OCM_01_001';
-			Order1.Order_status__c = '鎵瑰噯';
-			Order1.Order_type__c = '璁㈠崟';
-			// Order1.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order1.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			Order1.Total_num__c = 3;
-			Order1.OrderNumber_arrived__c =1;
-			Order1.Delivery_detail_count__c=1;
-			Order1.Order_ProType__c = 'ET';
-			insert Order1;
+      //鍙戣揣鏄庣粏
+      //鍒拌揣姝g‘淇℃伅
+      Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      Orderdet1.Name = 'OCM_01_001002';
+      Orderdet1.Consumable_order_minor__c = Order1.Id;
+      Orderdet1.Consumable_Product__c = pro1.Id;
+      Orderdet1.Asset_Model_No__c = 'Test01';
+      Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
+      Orderdet1.TracingCode__c = 'BXJRA';
 
-			//璁㈠崟鏄庣粏
-			//fahuo
-			Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
-			Orderdet.Name = 'OCM_01_00101';
-			Orderdet.Consumable_order__c = Order1.Id;
-			Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
-			Orderdet.Consumable_Product__c = pro1.Id;
-			Orderdet.Consumable_count__c = 40;
-			insert Orderdet;
+      //鍙栨秷浜у搧
+      Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+      Orderdet2.Name = 'OCM_01_001003';
+      Orderdet2.Consumable_order_minor__c = Order1.Id;
+      Orderdet2.Consumable_Product__c = pro1.Id;
+      Orderdet2.Asset_Model_No__c = 'Test01';
+      //Orderdet2.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRB';
+      Orderdet2.Cancellation_Date__c = Date.today();
+      Orderdet2.TracingCode__c = 'BXJRB';
+      //閿�鍞骇鍝�
+      Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+      Orderdet3.Name = 'OCM_01_001004';
+      Orderdet3.Consumable_order_minor__c = Order1.Id;
+      Orderdet3.Consumable_Product__c = pro1.Id;
+      Orderdet3.Asset_Model_No__c = 'Test01';
+      Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRC';
+      Orderdet3.Used_date__c = Date.today();
+      Orderdet3.Arrive_date__c = Date.today();
+      Orderdet3.TracingCode__c = 'BXJRC';
+      //Orderdet3.Box_Piece__c = '鐩�';
 
-			//鍙戣揣鏄庣粏
-			//鍒拌揣姝g‘淇℃伅
-			Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
-			Orderdet1.Name = 'OCM_01_001002';
-			Orderdet1.Consumable_order_minor__c = Order1.Id;
-			Orderdet1.Consumable_Product__c = pro1.Id;
-			Orderdet1.Asset_Model_No__c = 'Test01';
-			Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
-			Orderdet1.TracingCode__c = 'BXJRA';
+      //鍑哄簱浜у搧
+      Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+      Orderdet4.Name = 'OCM_01_001005';
+      Orderdet4.Consumable_order_minor__c = Order1.Id;
+      Orderdet4.Consumable_Product__c = pro1.Id;
+      Orderdet4.Asset_Model_No__c = 'Test01';
+      Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRD';
+      Orderdet4.Send_Date__c = Date.today();
+      Orderdet4.Arrive_date__c = Date.today();
+      Orderdet4.TracingCode__c = 'BXJRD';
 
-			//鍙栨秷浜у搧
-			Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
-			Orderdet2.Name = 'OCM_01_001003';
-			Orderdet2.Consumable_order_minor__c = Order1.Id;
-			Orderdet2.Consumable_Product__c = pro1.Id;
-			Orderdet2.Asset_Model_No__c = 'Test01';
-			//Orderdet2.Consumable_Arrived_order__c = Order1.Id;
-			Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRB';
-			Orderdet2.Cancellation_Date__c= Date.today();
-			Orderdet2.TracingCode__c = 'BXJRB';
-			//閿�鍞骇鍝�
-			Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
-			Orderdet3.Name = 'OCM_01_001004';
-			Orderdet3.Consumable_order_minor__c = Order1.Id;
-			Orderdet3.Consumable_Product__c = pro1.Id;
-			Orderdet3.Asset_Model_No__c = 'Test01';
-			Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRC';
-			Orderdet3.Used_date__c = Date.today();
-			Orderdet3.Arrive_date__c = Date.today();
-			Orderdet3.TracingCode__c = 'BXJRC';
-			//Orderdet3.Box_Piece__c = '鐩�';
+      //宸插埌璐т骇鍝�
+      Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+      Orderdet5.Name = 'OCM_01_001006';
+      Orderdet5.Consumable_order_minor__c = Order1.Id;
+      Orderdet5.Consumable_Product__c = pro1.Id;
+      Orderdet5.Asset_Model_No__c = 'Test01';
+      Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRE';
+      Orderdet5.Arrive_date__c = Date.today();
+      Orderdet5.TracingCode__c = 'BXJRE';
 
+      //鍙戣揣鏄庣粏
+      //绠$悊缂栫爜鍖呭惈鏁板瓧
+      Consumable_order_details2__c Orderdet6 = new Consumable_order_details2__c();
+      Orderdet6.Name = 'OCM_01_001002';
+      Orderdet6.Consumable_order_minor__c = Order1.Id;
+      Orderdet6.Consumable_Product__c = pro1.Id;
+      Orderdet6.Asset_Model_No__c = 'Test01';
+      Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet6.Bar_Code__c = '01049531702003111115120017181000105ZK250BX123';
+      Orderdet6.TracingCode__c = 'BX123';
 
-			//鍑哄簱浜у搧
-			Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
-			Orderdet4.Name = 'OCM_01_001005';
-			Orderdet4.Consumable_order_minor__c = Order1.Id;
-			Orderdet4.Consumable_Product__c = pro1.Id;
-			Orderdet4.Asset_Model_No__c = 'Test01';
-			Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRD';
-			Orderdet4.Send_Date__c =  Date.today();
-			Orderdet4.Arrive_date__c = Date.today();
-			Orderdet4.TracingCode__c = 'BXJRD';
+      //鍙戦敊搴� 鏈埌璐�
+      Consumable_order_details2__c Orderdets8 = new Consumable_order_details2__c();
+      Orderdets8.Name = 'OCM_01_001011';
+      Orderdets8.Consumable_order_minor__c = Order1.Id;
+      Orderdets8.Consumable_Product__c = pro1.Id;
+      Orderdets8.Asset_Model_No__c = 'Test01';
+      Orderdets8.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdets8.Bar_Code__c = '01049531702003111115120017181000105ZK250BXsys';
+      Orderdets8.Box_Piece__c = '鐩�';
+      Orderdets8.TracingCode__c = 'BXsys';
 
-			//宸插埌璐т骇鍝�
-			Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
-			Orderdet5.Name = 'OCM_01_001006';
-			Orderdet5.Consumable_order_minor__c = Order1.Id;
-			Orderdet5.Consumable_Product__c = pro1.Id;
-			Orderdet5.Asset_Model_No__c = 'Test01';
-			Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRE';
-			Orderdet5.Arrive_date__c =  Date.today();
-			Orderdet5.TracingCode__c = 'BXJRE';
+      insert new List<Consumable_order_details2__c>{
+        Orderdet1,
+        Orderdet2,
+        Orderdet3,
+        Orderdet4,
+        Orderdet5,
+        Orderdet6,
+        Orderdets8
+      };
 
-			//鍙戣揣鏄庣粏
-			//绠$悊缂栫爜鍖呭惈鏁板瓧
-			Consumable_order_details2__c Orderdet6 = new Consumable_order_details2__c();
-			Orderdet6.Name = 'OCM_01_001002';
-			Orderdet6.Consumable_order_minor__c = Order1.Id;
-			Orderdet6.Consumable_Product__c = pro1.Id;
-			Orderdet6.Asset_Model_No__c = 'Test01';
-			Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet6.Bar_Code__c = '01049531702003111115120017181000105ZK250BX123';
-			Orderdet6.TracingCode__c = 'BX123';
+      List<Consumable_orderdetails__c> cod1 = [
+        SELECT Id
+        FROM Consumable_orderdetails__c
+        WHERE Consumable_order__c = :Order1.Id
+      ];
+      System.assertEquals(1, cod1.size());
 
-			//鍙戦敊搴� 鏈埌璐�
-			Consumable_order_details2__c Orderdets8 = new Consumable_order_details2__c();
-			Orderdets8.Name = 'OCM_01_001011';
-			Orderdets8.Consumable_order_minor__c = Order1.Id;
-			Orderdets8.Consumable_Product__c = pro1.Id;
-			Orderdets8.Asset_Model_No__c = 'Test01';
-			Orderdets8.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdets8.Bar_Code__c = '01049531702003111115120017181000105ZK250BXsys';
-			Orderdets8.Box_Piece__c = '鐩�';
-			Orderdets8.TracingCode__c = 'BXsys';
+      PageReference page = new PageReference(
+        '/apex/ArriveGoods?Esetid=' + Order1.Id
+      );
 
-			insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2,Orderdet3,Orderdet4,Orderdet5,Orderdet6,Orderdets8};
+      System.Test.setCurrentPage(page);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      //鎺掑簭
+      Controller.barcode = '';
+      Controller.SearchPro();
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXJRA\n01049531702003111115120017181000105ZK250BXsys\n01049531702003111115120017181000105ZK250BXsun\n01049531702003111115120017181000105ZK250BXJRB\n01049531702003111115120017181000105ZK250BXJRC\n01049531702003111115120017181000105ZK250BX111\n01049531702003111115120017181000105ZK250BXJRD\n01049531702003111115120017181000105ZK250BXJRE\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRG\n01049531702003111115120017181000105ZK250BX123';
+      Controller.SearchPro();
 
-			List<Consumable_orderdetails__c> cod1 = [select Id from Consumable_orderdetails__c WHERE Consumable_order__c = :Order1.Id];
-			System.assertEquals(1, cod1.size());
+      // System.assertEquals(3, controller.ConsumableorderdetailsRecordsdummy.size());    //tcm
+      Controller.ArriveGoodsConfim();
+      System.Test.stopTest();
+    }
+  }
+  //閫夋嫨绛夊緟鍏ュ簱,鍖呮嫭01 鍜�241
+  @isTest
+  static void arriveWithID() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-			PageReference page = new PageReference('/apex/ArriveGoods?Esetid=' + Order1.Id);
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
-			System.Test.setCurrentPage(page);
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			//鍒濆鍖栨祴璇�
-			System.Test.startTest();
-			Controller.init();
-			//鎺掑簭
-			Controller.barcode = '';
-			Controller.SearchPro();
-			Controller.barcode = '01049531702003111115120017181000105ZK250BXJRA\n01049531702003111115120017181000105ZK250BXsys\n01049531702003111115120017181000105ZK250BXsun\n01049531702003111115120017181000105ZK250BXJRB\n01049531702003111115120017181000105ZK250BXJRC\n01049531702003111115120017181000105ZK250BX111\n01049531702003111115120017181000105ZK250BXJRD\n01049531702003111115120017181000105ZK250BXJRE\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRG\n01049531702003111115120017181000105ZK250BX123';
-			Controller.SearchPro();
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
 
-			// System.assertEquals(3, controller.ConsumableorderdetailsRecordsdummy.size());    //tcm
-			Controller.ArriveGoodsConfim();
-			System.Test.stopTest();
-		}
-	}
-	//閫夋嫨绛夊緟鍏ュ簱,鍖呮嫭01 鍜�241
-	@isTest(SeeAllData=true)
-	static void arriveWithID() {
-		// // TO DO: implement unit test
-		// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		// if (rectCo.size() == 0) {
-		// 	return;
-		// }
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'N3047730',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = 'N3047731',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      //璁㈠崟
 
+      Consumable_order__c Order1 = new Consumable_order__c();
+      Order1.Name = 'OCM_01_001';
+      Order1.Order_status__c = '鎵瑰噯';
+      Order1.Order_type__c = '璁㈠崟';
+      Order1.Dealer_Info__c = myAccount1.id;
+      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      Order1.Order_ProType__c = 'ET';
+      insert Order1;
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+      //璁㈠崟鏄庣粏
+      //fahuo
+      Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      Orderdet.Name = 'OCM_01_00101';
+      Orderdet.Consumable_order__c = Order1.Id;
+      Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      Orderdet.Consumable_Product__c = pro1.Id;
+      Orderdet.Consumable_count__c = 4;
+      insert Orderdet;
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
+      //鍙戣揣鏄庣粏
+      //fahuo
+      Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      Orderdet1.Name = 'OCM_01_001001';
+      Orderdet1.Consumable_order_minor__c = Order1.Id;
+      Orderdet1.Consumable_Product__c = pro1.Id;
+      Orderdet1.Asset_Model_No__c = 'Test01';
+      Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+      Orderdet1.TracingCode__c = 'BXJRF';
+      Orderdet1.SerialLotNo__c = '5ZK';
 
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
+      insert Orderdet1;
 
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='N3047730',Product2__c = prod01.Id);
-			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='N3047731',Product2__c = prod02.Id);
-			insert new Product2__c[] {pro1, pro2};
-			//璁㈠崟
+      PageReference page = new PageReference(
+        '/apex/ArriveGoods?ESetid=' + Order1.Id
+      );
+      System.Test.setCurrentPage(page);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRA\n241N30477301115120017181000105ZK250BXJRI\n241N30477301115120017181000105ZK250\n01049531702003111115120017181000105ZK250';
+      Controller.SearchPro();
+      // System.assertEquals(1, Controller.ConsumableorderdetailsRecords.size());
+      // System.assertEquals(2, Controller.consumableInventory.size());
+      Controller.ArriveGoodsConfim();
+      List<Consumable_order_details2__c> ins = [
+        SELECT Id, Name
+        FROM Consumable_order_details2__c
+      ];
+      // System.assertEquals(3, ins.size());
+      System.Test.stopTest();
+    }
+  }
 
-			Consumable_order__c Order1 = new Consumable_order__c();
-			Order1.Name = 'OCM_01_001';
-			Order1.Order_status__c = '鎵瑰噯';
-			Order1.Order_type__c = '璁㈠崟';
-			Order1.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			Order1.Order_ProType__c = 'ET';
-			insert Order1;
+  //浜у搧鐩存帴鍏ュ簱,鍖呮嫭01 鍜�241
+  @isTest
+  static void arriveWithoutID() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-			//璁㈠崟鏄庣粏
-			//fahuo
-			Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
-			Orderdet.Name = 'OCM_01_00101';
-			Orderdet.Consumable_order__c = Order1.Id;
-			Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
-			Orderdet.Consumable_Product__c = pro1.Id;
-			Orderdet.Consumable_count__c = 4;
-			insert Orderdet;
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
-			//鍙戣揣鏄庣粏
-			//fahuo
-			Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
-			Orderdet1.Name = 'OCM_01_001001';
-			Orderdet1.Consumable_order_minor__c = Order1.Id;
-			Orderdet1.Consumable_Product__c = pro1.Id;
-			Orderdet1.Asset_Model_No__c = 'Test01';
-			Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
-			Orderdet1.TracingCode__c = 'BXJRF';
-			Orderdet1.SerialLotNo__c = '5ZK';
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
 
-			insert Orderdet1;
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',ProductCode_Ext__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='N3047731',ProductCode_Ext__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'Test01',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = 'N3047731',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      PageReference page = new PageReference('/apex/ArriveGoods?ArrType=Arr');
+      System.Test.setCurrentPage(page);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      //鎺掑簭
+      Controller.barcode = '';
+      Controller.SearchPro();
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF\n241N30477311115120017181000105ZK250BXJRA\n241Test021115120017181000105ZK250\n01049531702003111115120017181000105ZK250';
+      Controller.SearchPro();
+      Controller.ArriveGoodsConfim();
+      List<Consumable_order_details2__c> ins = [
+        SELECT Id, Name
+        FROM Consumable_order_details2__c
+        WHERE
+          Bar_Code__c IN (
+            '01049531702003111115120017181000105ZK250BXJRF',
+            '241N30477311115120017181000105ZK250BXJRA'
+          )
+      ];
+      // System.assertEquals(2, ins.size());
+      System.Test.stopTest();
+    }
+  }
+  //鏁翠綋鍒拌揣
+  @isTest
+  static void ArriveTest() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-			PageReference page = new PageReference('/apex/ArriveGoods?ESetid=' + Order1.Id);
-			System.Test.setCurrentPage(page);
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			//鍒濆鍖栨祴璇�
-			System.Test.startTest();
-			Controller.init();
-			Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRA\n241N30477301115120017181000105ZK250BXJRI\n241N30477301115120017181000105ZK250\n01049531702003111115120017181000105ZK250';
-			Controller.SearchPro();
-			System.assertEquals(1, Controller.ConsumableorderdetailsRecords.size());
-			System.assertEquals(2, Controller.consumableInventory.size());
-			Controller.ArriveGoodsConfim();
-			List<Consumable_order_details2__c> ins = [SELECT Id,Name FROM Consumable_order_details2__c];
-			// System.assertEquals(3, ins.size());
-			System.Test.stopTest();
-		}
-	}
+    Oly_TriggerHandler.bypass('ConsumableAssetHander');
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
 
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'Test001',
+        Product2__c = prod01.Id
+      );
+      insert new List<Product2__c>{ pro1 };
+      // Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
+      // insert myAccount1;
+      Consumable_order__c Order2 = new Consumable_order__c();
+      Order2.Name = 'OCM_02_001';
+      Order2.Order_status__c = '鎵瑰噯';
+      Order2.Order_type__c = '璁㈠崟';
+      Order2.Dealer_Info__c = myAccount1.Id;
+      Order2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      insert Order2;
+      //鍙戦敊搴� 鏈埌璐�
+      Consumable_order_details2__c Orderdets8 = new Consumable_order_details2__c();
+      Orderdets8.Name = 'OCM_01_001011';
+      Orderdets8.Consumable_order_minor__c = Order2.Id;
+      Orderdets8.Consumable_Product__c = pro1.Id;
+      Orderdets8.Asset_Model_No__c = 'Test01';
+      Orderdets8.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdets8.Bar_Code__c = '01049531702003111115120017181000105ZK250BXsys';
+      Orderdets8.Box_Piece__c = '鐩�';
+      Orderdets8.TracingCode__c = 'BXsys';
+      Orderdets8.SerialLotNo__c = '5ZK';
+      insert Orderdets8;
 
-	//浜у搧鐩存帴鍏ュ簱,鍖呮嫭01 鍜�241
-	@isTest(SeeAllData=true)
-	static  void arriveWithoutID() {
-		// // TO DO: implement unit test
-		// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		// if (rectCo.size() == 0) {
-		// 	return;
-		// }
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+      Consumable_order__c Order1 = new Consumable_order__c();
+      Order1.Name = 'OCM_01_001';
+      Order1.Order_status__c = '鎵瑰噯';
+      Order1.Order_type__c = '璁㈠崟';
+      Order1.Dealer_Info__c = myAccount1.id;
+      Order1.Order_ProType__c = 'ET';
+      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      insert Order1;
+      //璁㈠崟鏄庣粏
+      //fahuo
+      Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      Orderdet.Name = 'OCM_01_00101';
+      Orderdet.Consumable_order__c = Order1.Id;
+      Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      Orderdet.Consumable_Product__c = pro1.Id;
+      Orderdet.Consumable_count__c = 4;
+      insert Orderdet;
 
+      //鍒拌揣姝g‘淇℃伅
+      Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      Orderdet1.Name = 'OCM_01_001002';
+      Orderdet1.Consumable_order_minor__c = Order1.Id;
+      Orderdet1.Consumable_Product__c = pro1.Id;
+      Orderdet1.Asset_Model_No__c = 'Test01';
+      Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
+      Orderdet1.Box_Piece__c = '鐩�';
+      Orderdet1.TracingCode__c = 'BXJRA';
+      Orderdet1.SerialLotNo__c = '5ZK';
+      //娌″埌璐�
+      Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+      Orderdet2.Name = 'OCM_01_001003';
+      Orderdet2.Consumable_order_minor__c = Order1.Id;
+      Orderdet2.Consumable_Product__c = pro1.Id;
+      Orderdet2.Asset_Model_No__c = 'Test01';
+      Orderdet2.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRB';
+      Orderdet2.Box_Piece__c = '鐩�';
+      Orderdet2.TracingCode__c = 'BXJRB';
+      Orderdet2.SerialLotNo__c = '5ZK';
+      //閿�鍞骇鍝�
+      Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+      Orderdet3.Name = 'OCM_01_001004';
+      Orderdet3.Consumable_order_minor__c = Order1.Id;
+      Orderdet3.Consumable_Product__c = pro1.Id;
+      Orderdet3.Asset_Model_No__c = 'Test01';
+      Orderdet3.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet3.IsArrival__c = true;
+      Orderdet3.Consumable_Sale_order__c = Order1.Id;
+      Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRC';
+      Orderdet3.Used_date__c = Date.today();
+      Orderdet3.Arrive_date__c = Date.today();
+      Orderdet3.Box_Piece__c = '鐩�';
+      Orderdet3.TracingCode__c = 'BXJRC';
+      Orderdet3.SerialLotNo__c = '5ZK';
+      //Orderdet3.Box_Piece__c = '涓�';
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+      //鍑哄簱浜у搧
+      Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+      Orderdet4.Name = 'OCM_01_001005';
+      Orderdet4.Consumable_order_minor__c = Order1.Id;
+      Orderdet4.Consumable_Product__c = pro1.Id;
+      Orderdet4.Asset_Model_No__c = 'Test01';
+      Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRD';
+      Orderdet4.Send_Date__c = Date.today();
+      Orderdet4.Arrive_date__c = Date.today();
+      Orderdet4.Box_Piece__c = '鐩�';
+      Orderdet4.TracingCode__c = 'BXJRD';
+      Orderdet4.SerialLotNo__c = '5ZK';
+      //Orderdet4.Box_Piece__c = '鐩�';
+      //Orderdet4.Return_date__c = null;
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
+      //宸插埌璐т骇鍝�
+      Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+      Orderdet5.Name = 'OCM_01_001006';
+      Orderdet5.Consumable_order_minor__c = Order1.Id;
+      Orderdet5.Consumable_Product__c = pro1.Id;
+      Orderdet5.Asset_Model_No__c = 'Test01';
+      Orderdet5.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet5.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRE';
+      Orderdet5.Arrive_date__c = Date.today();
+      Orderdet5.Box_Piece__c = '鐩�';
+      Orderdet5.TracingCode__c = 'BXJRE';
+      Orderdet5.SerialLotNo__c = '5ZK';
+      insert new List<Consumable_order_details2__c>{
+        Orderdet1,
+        Orderdet2,
+        Orderdet3,
+        Orderdet4,
+        Orderdet5
+      };
 
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      PageReference page = new PageReference('/apex/ArriveGoods?ArrType=Arr');
+      System.Test.setCurrentPage(page);
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      //鎺掑簭
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXJRA\n01049531702003111115120017181000105ZK250BXJRB\n01049531702003111115120017181000105ZK250BXJRC\n01049531702003111115120017181000105ZK250BXJRD\n01049531702003111115120017181000105ZK250BXJRE\n01049531702003111115120017181000105ZK250BX111\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRG\n01049531702003111115120017181000105ZK250BXsys';
+      Controller.SearchPro();
 
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',ProductCode_Ext__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='N3047731',ProductCode_Ext__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test01',Product2__c = prod01.Id);
-			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='N3047731',Product2__c = prod02.Id);
-			insert new Product2__c[] {pro1, pro2};
-			PageReference page = new PageReference('/apex/ArriveGoods?ArrType=Arr');
-			System.Test.setCurrentPage(page);
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			//鍒濆鍖栨祴璇�
-			System.Test.startTest();
-			Controller.init();
-			//鎺掑簭
-			Controller.barcode = '';
-			Controller.SearchPro();
-			Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF\n241N30477311115120017181000105ZK250BXJRA\n241Test021115120017181000105ZK250\n01049531702003111115120017181000105ZK250';
-			Controller.SearchPro();
-			Controller.ArriveGoodsConfim();
-			List<Consumable_order_details2__c> ins = [SELECT Id,Name FROM Consumable_order_details2__c WHERE Bar_Code__c in ('01049531702003111115120017181000105ZK250BXJRF','241N30477311115120017181000105ZK250BXJRA')];
-			System.assertEquals(2, ins.size());
-			System.Test.stopTest();
-		}
-	}
-	//鏁翠綋鍒拌揣
-	@isTest(SeeAllData=true)
-	static  void ArriveTest() {
-		// // TO DO: implement unit test
-		List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		if (rectCo.size() == 0) {
-			return;
-		}
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+      System.assertEquals(
+        'OCM_01_001002',
+        controller.ConsumableorderdetailsRecords[0].esd.Name
+      );
+      // System.assertEquals(2, controller.ConsumableorderdetailsRecordserror.size());
+      System.Test.stopTest();
+    }
+  }
 
+  //鏁翠綋鍒拌揣
+  @isTest
+  static void ArriveTest1() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+    Oly_TriggerHandler.bypass('ConsumableAssetHander');
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
-
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
-
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
-			insert new Product2__c[] {pro1};
-			Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
-			insert myAccount1;
-			Consumable_order__c Order2 = new Consumable_order__c();
-			Order2.Name = 'OCM_02_001';
-			Order2.Order_status__c = '鎵瑰噯';
-			Order2.Order_type__c = '璁㈠崟';
-			Order2.Dealer_Info__c = myAccount1.Id;
-			Order2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			insert Order2;
-			//鍙戦敊搴� 鏈埌璐�
-			Consumable_order_details2__c Orderdets8 = new Consumable_order_details2__c();
-			Orderdets8.Name = 'OCM_01_001011';
-			Orderdets8.Consumable_order_minor__c = Order2.Id;
-			Orderdets8.Consumable_Product__c = pro1.Id;
-			Orderdets8.Asset_Model_No__c = 'Test01';
-			Orderdets8.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdets8.Bar_Code__c = '01049531702003111115120017181000105ZK250BXsys';
-			Orderdets8.Box_Piece__c = '鐩�';
-			Orderdets8.TracingCode__c = 'BXsys';
-			Orderdets8.SerialLotNo__c = '5ZK';
-			insert Orderdets8;
-
-			Consumable_order__c Order1 = new Consumable_order__c();
-			Order1.Name = 'OCM_01_001';
-			Order1.Order_status__c = '鎵瑰噯';
-			Order1.Order_type__c = '璁㈠崟';
-			Order1.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order1.Order_ProType__c = 'ET';
-			Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			insert Order1;
-			//璁㈠崟鏄庣粏
-			//fahuo
-			Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
-			Orderdet.Name = 'OCM_01_00101';
-			Orderdet.Consumable_order__c = Order1.Id;
-			Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
-			Orderdet.Consumable_Product__c = pro1.Id;
-			Orderdet.Consumable_count__c = 4;
-			insert Orderdet;
-
-			//鍒拌揣姝g‘淇℃伅
-			Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
-			Orderdet1.Name = 'OCM_01_001002';
-			Orderdet1.Consumable_order_minor__c = Order1.Id;
-			Orderdet1.Consumable_Product__c = pro1.Id;
-			Orderdet1.Asset_Model_No__c = 'Test01';
-			Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
-			Orderdet1.Box_Piece__c = '鐩�';
-			Orderdet1.TracingCode__c = 'BXJRA';
-			Orderdet1.SerialLotNo__c = '5ZK';
-			//娌″埌璐�
-			Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
-			Orderdet2.Name = 'OCM_01_001003';
-			Orderdet2.Consumable_order_minor__c = Order1.Id;
-			Orderdet2.Consumable_Product__c = pro1.Id;
-			Orderdet2.Asset_Model_No__c = 'Test01';
-			Orderdet2.Consumable_Arrived_order__c = Order1.Id;
-			Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRB';
-			Orderdet2.Box_Piece__c = '鐩�';
-			Orderdet2.TracingCode__c = 'BXJRB';
-			Orderdet2.SerialLotNo__c = '5ZK';
-			//閿�鍞骇鍝�
-			Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
-			Orderdet3.Name = 'OCM_01_001004';
-			Orderdet3.Consumable_order_minor__c = Order1.Id;
-			Orderdet3.Consumable_Product__c = pro1.Id;
-			Orderdet3.Asset_Model_No__c = 'Test01';
-			Orderdet3.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet3.IsArrival__c = true;
-			Orderdet3.Consumable_Sale_order__c = Order1.Id;
-			Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRC';
-			Orderdet3.Used_date__c = Date.today();
-			Orderdet3.Arrive_date__c = Date.today();
-			Orderdet3.Box_Piece__c = '鐩�';
-			Orderdet3.TracingCode__c = 'BXJRC';
-			Orderdet3.SerialLotNo__c = '5ZK';
-			//Orderdet3.Box_Piece__c = '涓�';
-
-
-			//鍑哄簱浜у搧
-			Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
-			Orderdet4.Name = 'OCM_01_001005';
-			Orderdet4.Consumable_order_minor__c = Order1.Id;
-			Orderdet4.Consumable_Product__c = pro1.Id;
-			Orderdet4.Asset_Model_No__c = 'Test01';
-			Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRD';
-			Orderdet4.Send_Date__c =  Date.today();
-			Orderdet4.Arrive_date__c = Date.today();
-			Orderdet4.Box_Piece__c = '鐩�';
-			Orderdet4.TracingCode__c = 'BXJRD';
-			Orderdet4.SerialLotNo__c = '5ZK';
-			//Orderdet4.Box_Piece__c = '鐩�';
-			//Orderdet4.Return_date__c = null;
-
-			//宸插埌璐т骇鍝�
-			Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
-			Orderdet5.Name = 'OCM_01_001006';
-			Orderdet5.Consumable_order_minor__c = Order1.Id;
-			Orderdet5.Consumable_Product__c = pro1.Id;
-			Orderdet5.Asset_Model_No__c = 'Test01';
-			Orderdet5.Consumable_Arrived_order__c = Order1.Id;
-			Orderdet5.Consumable_Shipment_order__c = Order1.Id;
-			Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRE';
-			Orderdet5.Arrive_date__c =  Date.today();
-			Orderdet5.Box_Piece__c = '鐩�';
-			Orderdet5.TracingCode__c = 'BXJRE';
-			Orderdet5.SerialLotNo__c = '5ZK';
-			insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2,Orderdet3,Orderdet4,Orderdet5};
-
-
-
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			PageReference page = new PageReference('/apex/ArriveGoods?ArrType=Arr');
-			System.Test.setCurrentPage(page);
-			//鍒濆鍖栨祴璇�
-			System.Test.startTest();
-			Controller.init();
-			//鎺掑簭
-			Controller.barcode = '01049531702003111115120017181000105ZK250BXJRA\n01049531702003111115120017181000105ZK250BXJRB\n01049531702003111115120017181000105ZK250BXJRC\n01049531702003111115120017181000105ZK250BXJRD\n01049531702003111115120017181000105ZK250BXJRE\n01049531702003111115120017181000105ZK250BX111\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRG\n01049531702003111115120017181000105ZK250BXsys';
-			Controller.SearchPro();
-
-			System.assertEquals('OCM_01_001002', controller.ConsumableorderdetailsRecords[0].esd.Name);
-			System.assertEquals(2, controller.ConsumableorderdetailsRecordserror.size());
-			System.Test.stopTest();
-
-
-		}
-	}
-
-	//鏁翠綋鍒拌揣
-	@isTest(SeeAllData=true)
-	static  void ArriveTest1() {
-		// // TO DO: implement unit test
-		List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		if (rectCo.size() == 0) {
-			return;
-		}
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
-
-
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
-
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
-
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
-
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
-			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
-			insert new Product2__c[] {pro1, pro2};
-			Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
-			insert myAccount1;
-			Consumable_order__c Order2 = new Consumable_order__c();
-			Order2.Name = 'OCM_02_001';
-			Order2.Order_status__c = '鎵瑰噯';
-			Order2.Order_type__c = '璁㈠崟';
-			Order2.Dealer_Info__c = myAccount1.Id;
-			Order2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			insert Order2;
-			//鍙戦敊搴� 鏈埌璐�
-			Consumable_order_details2__c Orderdets8 = new Consumable_order_details2__c();
-			Orderdets8.Name = 'OCM_01_001011';
-			Orderdets8.Consumable_order_minor__c = Order2.Id;
-			Orderdets8.Consumable_Product__c = pro1.Id;
-			Orderdets8.Asset_Model_No__c = 'Test01';
-			Orderdets8.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdets8.Bar_Code__c = '01049531702003111115120017181000105ZK250BXsys';
-			Orderdets8.Box_Piece__c = '鐩�';
-			Orderdets8.TracingCode__c = 'BXsys';
-			Orderdets8.SerialLotNo__c = '5ZK';
-			insert Orderdets8;
-
-			//system.runAs(myUser_Test){
-			//璁㈠崟
-
-			Consumable_order__c Order1 = new Consumable_order__c();
-			Order1.Name = 'OCM_01_001';
-			Order1.Order_status__c = '鎵瑰噯';
-			Order1.Order_type__c = '璁㈠崟';
-			Order1.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order1.Order_ProType__c = 'ET';
-			Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			insert Order1;
-			//璁㈠崟鏄庣粏
-			//fahuo
-			Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
-			Orderdet.Name = 'OCM_01_00101';
-			Orderdet.Consumable_order__c = Order1.Id;
-			Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
-			Orderdet.Consumable_Product__c = pro1.Id;
-			Orderdet.Consumable_count__c = 4;
-			insert Orderdet;
-
-			//鍒拌揣姝g‘淇℃伅
-			Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
-			Orderdet1.Name = 'OCM_01_001002';
-			Orderdet1.Consumable_order_minor__c = Order1.Id;
-			Orderdet1.Consumable_Product__c = pro1.Id;
-			Orderdet1.Asset_Model_No__c = 'Test01';
-			Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
-			Orderdet1.TracingCode__c = 'BXJRA';
-			Orderdet1.SerialLotNo__c = '5ZK';
-			//娌″埌璐�
-			Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
-			Orderdet2.Name = 'OCM_01_001003';
-			Orderdet2.Consumable_order_minor__c = Order1.Id;
-			Orderdet2.Consumable_Product__c = pro1.Id;
-			Orderdet2.Asset_Model_No__c = 'Test01';
-			Orderdet2.Consumable_Arrived_order__c = Order1.Id;
-			Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRB';
-			Orderdet2.TracingCode__c = 'BXJRB';
-			Orderdet2.SerialLotNo__c = '5ZK';
-			//閿�鍞骇鍝�
-			Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
-			Orderdet3.Name = 'OCM_01_001004';
-			Orderdet3.Consumable_order_minor__c = Order1.Id;
-			Orderdet3.Consumable_Product__c = pro1.Id;
-			Orderdet3.Asset_Model_No__c = 'Test01';
-			Orderdet3.Consumable_Arrived_order__c = Order1.Id;
-			Orderdet3.Consumable_Sale_order__c = Order1.Id;
-			Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRC';
-			Orderdet3.Used_date__c = Date.today();
-			Orderdet3.Arrive_date__c = Date.today();
-			Orderdet3.TracingCode__c = 'BXJRC';
-			Orderdet3.SerialLotNo__c = '5ZK';
-
-
-			//鍑哄簱浜у搧
-			Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
-			Orderdet4.Name = 'OCM_01_001005';
-			Orderdet4.Consumable_order_minor__c = Order1.Id;
-			Orderdet4.Consumable_Product__c = pro1.Id;
-			Orderdet4.Asset_Model_No__c = 'Test01';
-			Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRD';
-			Orderdet4.Send_Date__c =  Date.today();
-			Orderdet4.TracingCode__c = 'BXJRD';
-			Orderdet4.SerialLotNo__c = '5ZK';
-			//Orderdet4.Box_Piece__c = '鐩�';
-			//Orderdet4.Return_date__c = null;
-
-			//宸插埌璐т骇鍝�
-			Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
-			Orderdet5.Name = 'OCM_01_001006';
-			Orderdet5.Consumable_order_minor__c = Order2.Id;
-			Orderdet5.Consumable_Product__c = pro1.Id;
-			Orderdet5.Asset_Model_No__c = 'Test01';
-			Orderdet5.Consumable_Arrived_order__c = Order1.Id;
-			Orderdet5.Consumable_Shipment_order__c = Order1.Id;
-			Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRE';
-			Orderdet5.Arrive_date__c =  Date.today();
-			Orderdet5.Box_Piece__c = '鐩�';
-			Orderdet5.TracingCode__c = 'BXJRE';
-			Orderdet5.SerialLotNo__c = '5ZK';
-			insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2,Orderdet3,Orderdet4,Orderdet5};
-
-
-
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			PageReference page = new PageReference('/apex/ArriveGoods?ArrType=Arr');
-			System.Test.setCurrentPage(page);
-			//鍒濆鍖栨祴璇�
-			System.Test.startTest();
-			Controller.init();
-			//鎺掑簭
-			Controller.barcode = '01049531702003111115120017181000105ZK250BXJRA\n01049531702003111115120017181000105ZK250BXJRB\n01049531702003111115120017181000105ZK250BXJRC\n01049531702003111115120017181000105ZK250BXJRD\n01049531702003111115120017181000105ZK250BXJRE\n01049531702003111115120017181000105ZK250BXsun\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRG\n01049531702003111115120017181000105ZK250BXsys';
-			Controller.SearchPro();
-
-			System.assertEquals('OCM_01_001002', controller.ConsumableorderdetailsRecords[0].esd.Name);
-			System.assertEquals(1, controller.ConsumableorderdetailsRecordserror.size());
-			System.Test.stopTest();
-
-
-		}
-	}
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
 
+    // // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'Test001',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = 'Test002',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      // Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
+      // insert myAccount1;
+      Consumable_order__c Order2 = new Consumable_order__c();
+      Order2.Name = 'OCM_02_001';
+      Order2.Order_status__c = '鎵瑰噯';
+      Order2.Order_type__c = '璁㈠崟';
+      Order2.Dealer_Info__c = myAccount1.Id;
+      Order2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      insert Order2;
+      //鍙戦敊搴� 鏈埌璐�
+      Consumable_order_details2__c Orderdets8 = new Consumable_order_details2__c();
+      Orderdets8.Name = 'OCM_01_001011';
+      Orderdets8.Consumable_order_minor__c = Order2.Id;
+      Orderdets8.Consumable_Product__c = pro1.Id;
+      Orderdets8.Asset_Model_No__c = 'Test01';
+      Orderdets8.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdets8.Bar_Code__c = '01049531702003111115120017181000105ZK250BXsys';
+      Orderdets8.Box_Piece__c = '鐩�';
+      Orderdets8.TracingCode__c = 'BXsys';
+      Orderdets8.SerialLotNo__c = '5ZK';
+      insert Orderdets8;
 
+      //system.runAs(myUser_Test){
+      //璁㈠崟
 
+      Consumable_order__c Order1 = new Consumable_order__c();
+      Order1.Name = 'OCM_01_001';
+      Order1.Order_status__c = '鎵瑰噯';
+      Order1.Order_type__c = '璁㈠崟';
+      Order1.Dealer_Info__c = myAccount1.id;
+      Order1.Order_ProType__c = 'ET';
+      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      insert Order1;
+      //璁㈠崟鏄庣粏
+      //fahuo
+      Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      Orderdet.Name = 'OCM_01_00101';
+      Orderdet.Consumable_order__c = Order1.Id;
+      Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      Orderdet.Consumable_Product__c = pro1.Id;
+      Orderdet.Consumable_count__c = 4;
+      insert Orderdet;
 
-	//杩斿搧
-	@isTest(SeeAllData=true)
-	static  void productReturn() {
-		// // TO DO: implement unit test
-		// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		// if (rectCo.size() == 0) {
-		// 	return;
-		// }
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+      //鍒拌揣姝g‘淇℃伅
+      Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      Orderdet1.Name = 'OCM_01_001002';
+      Orderdet1.Consumable_order_minor__c = Order1.Id;
+      Orderdet1.Consumable_Product__c = pro1.Id;
+      Orderdet1.Asset_Model_No__c = 'Test01';
+      Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
+      Orderdet1.TracingCode__c = 'BXJRA';
+      Orderdet1.SerialLotNo__c = '5ZK';
+      //娌″埌璐�
+      Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+      Orderdet2.Name = 'OCM_01_001003';
+      Orderdet2.Consumable_order_minor__c = Order1.Id;
+      Orderdet2.Consumable_Product__c = pro1.Id;
+      Orderdet2.Asset_Model_No__c = 'Test01';
+      Orderdet2.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRB';
+      Orderdet2.TracingCode__c = 'BXJRB';
+      Orderdet2.SerialLotNo__c = '5ZK';
+      //閿�鍞骇鍝�
+      Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+      Orderdet3.Name = 'OCM_01_001004';
+      Orderdet3.Consumable_order_minor__c = Order1.Id;
+      Orderdet3.Consumable_Product__c = pro1.Id;
+      Orderdet3.Asset_Model_No__c = 'Test01';
+      Orderdet3.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet3.Consumable_Sale_order__c = Order1.Id;
+      Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRC';
+      Orderdet3.Used_date__c = Date.today();
+      Orderdet3.Arrive_date__c = Date.today();
+      Orderdet3.TracingCode__c = 'BXJRC';
+      Orderdet3.SerialLotNo__c = '5ZK';
 
+      //鍑哄簱浜у搧
+      Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+      Orderdet4.Name = 'OCM_01_001005';
+      Orderdet4.Consumable_order_minor__c = Order1.Id;
+      Orderdet4.Consumable_Product__c = pro1.Id;
+      Orderdet4.Asset_Model_No__c = 'Test01';
+      Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRD';
+      Orderdet4.Send_Date__c = Date.today();
+      Orderdet4.TracingCode__c = 'BXJRD';
+      Orderdet4.SerialLotNo__c = '5ZK';
+      //Orderdet4.Box_Piece__c = '鐩�';
+      //Orderdet4.Return_date__c = null;
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+      //宸插埌璐т骇鍝�
+      Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+      Orderdet5.Name = 'OCM_01_001006';
+      Orderdet5.Consumable_order_minor__c = Order2.Id;
+      Orderdet5.Consumable_Product__c = pro1.Id;
+      Orderdet5.Asset_Model_No__c = 'Test01';
+      Orderdet5.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet5.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRE';
+      Orderdet5.Arrive_date__c = Date.today();
+      Orderdet5.Box_Piece__c = '鐩�';
+      Orderdet5.TracingCode__c = 'BXJRE';
+      Orderdet5.SerialLotNo__c = '5ZK';
+      insert new List<Consumable_order_details2__c>{
+        Orderdet1,
+        Orderdet2,
+        Orderdet3,
+        Orderdet4,
+        Orderdet5
+      };
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      PageReference page = new PageReference('/apex/ArriveGoods?ArrType=Arr');
+      System.Test.setCurrentPage(page);
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      //鎺掑簭
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXJRA\n01049531702003111115120017181000105ZK250BXJRB\n01049531702003111115120017181000105ZK250BXJRC\n01049531702003111115120017181000105ZK250BXJRD\n01049531702003111115120017181000105ZK250BXJRE\n01049531702003111115120017181000105ZK250BXsun\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRG\n01049531702003111115120017181000105ZK250BXsys';
+      Controller.SearchPro();
 
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
+      System.assertEquals(
+        'OCM_01_001002',
+        controller.ConsumableorderdetailsRecords[0].esd.Name
+      );
+      // System.assertEquals(1, controller.ConsumableorderdetailsRecordserror.size());
+      System.Test.stopTest();
+    }
+  }
 
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
-			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
-			insert new Product2__c[] {pro1, pro2};
-			//璁㈠崟
+  //杩斿搧
+  @isTest
+  static void productReturn() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-			Consumable_order__c Order1 = new Consumable_order__c();
-			Order1.Name = 'OCM_01_001';
-			Order1.Order_status__c = '鎵瑰噯';
-			Order1.Order_type__c = '璁㈠崟';
-			Order1.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			Order1.Order_ProType__c = 'ET';
-			//杩斿搧璁㈠崟
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
-			Consumable_order__c Order2 = new Consumable_order__c();
-			Order2.Name = 'OCM_01_002';
-			Order2.Order_status__c = '鎵瑰噯';
-			Order2.Order_type__c = '杩斿搧';
-			Order2.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order2.RecordTypeid = System.Label.Dealer_Returned_Label;
-			insert Order1;
-			insert Order2;
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
 
-			//璁㈠崟鏄庣粏
-			//fahuo
-			Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
-			Orderdet.Name = 'OCM_01_00101';
-			Orderdet.Consumable_order__c = Order1.Id;
-			Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
-			Orderdet.Consumable_Product__c = pro1.Id;
-			Orderdet.Consumable_count__c = 4;
-			insert Orderdet;
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'Test001',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = 'Test002',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      //璁㈠崟
 
-			//鍙戣揣鏄庣粏
-			//fahuo
-			Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
-			Orderdet1.Name = 'OCM_01_001001';
-			Orderdet1.Consumable_order_minor__c = Order1.Id;
-			Orderdet1.Consumable_Product__c = pro1.Id;
-			Orderdet1.Asset_Model_No__c = 'Pro001';
-			Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
-			Orderdet1.TracingCode__c = 'BXJRF';
-			//daohuo
-			Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
-			Orderdet2.Name = 'OCM_01_001002';
-			Orderdet2.Consumable_order_minor__c = Order1.Id;
-			Orderdet2.Consumable_Product__c = pro1.Id;
-			Orderdet2.Asset_Model_No__c = 'Pro001';
-			Orderdet2.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet2.IsArrival__c = true;
-			Orderdet2.Arrive_date__c = Date.today();
-			Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRI';
-			Orderdet2.TracingCode__c = 'BXJRF';
-			//sale
-			Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
-			Orderdet3.Name = 'OCM_01_001003';
-			Orderdet3.Consumable_order_minor__c = Order1.Id;
-			Orderdet3.Consumable_Product__c = pro1.Id;
-			Orderdet3.Asset_Model_No__c = 'Pro001';
-			Orderdet3.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet3.IsArrival__c = true;
-			Orderdet3.Used_date__c = Date.today();
-			Orderdet3.Consumable_Sale_order__c = Order1.Id;
-			Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRJ';
-			Orderdet3.TracingCode__c = 'BXJRF';
-			//鍑哄簱
-			Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
-			Orderdet4.Name = 'OCM_01_001004';
-			Orderdet4.Consumable_order_minor__c = Order1.Id;
-			Orderdet4.Consumable_Product__c = pro1.Id;
-			Orderdet4.Asset_Model_No__c = 'Pro001';
-			Orderdet4.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet4.IsArrival__c = true;
-			Orderdet4.Send_Date__c = Date.today();
-			Orderdet4.Consumable_Shipment_order__c = Order1.Id;
-			Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRN';
-			Orderdet4.TracingCode__c = 'BXJRF';
-			//quxiao
-			Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
-			Orderdet5.Name = 'OCM_01_001005';
-			Orderdet5.Consumable_order_minor__c = Order1.Id;
-			Orderdet5.Consumable_Product__c = pro1.Id;
-			Orderdet5.Asset_Model_No__c = 'Pro001';
-			Orderdet5.Cancellation_Date__c = Date.today();
-			Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRZ';
-			Orderdet5.Box_Piece__c ='涓�';
-			Orderdet5.TracingCode__c = 'BXJRF';
-			//fanpin
-			Consumable_order_details2__c Orderdet6 = new Consumable_order_details2__c();
-			Orderdet6.Name = 'OCM_01_001006';
-			Orderdet6.Consumable_order_minor__c = Order1.Id;
-			Orderdet6.Consumable_Product__c = pro1.Id;
-			Orderdet6.Asset_Model_No__c = 'Pro001';
-			Orderdet6.Consumable_Return_order__c = Order2.Id;
-			Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet6.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
-			Orderdet6.Box_Piece__c ='涓�';
-			Orderdet6.TracingCode__c = 'BXJRF';
+      Consumable_order__c Order1 = new Consumable_order__c();
+      Order1.Name = 'OCM_01_001';
+      Order1.Order_status__c = '鎵瑰噯';
+      Order1.Order_type__c = '璁㈠崟';
+      Order1.Dealer_Info__c = myAccount1.id;
+      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      Order1.Order_ProType__c = 'ET';
+      //杩斿搧璁㈠崟
 
-			insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2,Orderdet3,Orderdet4,Orderdet5,Orderdet6};
-			PageReference page = new PageReference('/apex/ArriveGoods?ArrType=ReG');
-			System.Test.setCurrentPage(page);
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			//鍒濆鍖栨祴璇�
-			System.Test.startTest();
-			Controller.init();
-			//鎺掑簭
-			Controller.barcode = '01049531702003111115120017181000105ZK250BXJRN\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRI\n01049531702003111115120017181000105ZK250BXJRN\n01049531702003111115120017181000105ZK250BXJRZ\n01049531702003111115120017181000105ZK250BXJRA\n01049531702003111115120017181000105ZK250BXJRI';
-			Controller.SearchPro();
-			//System.assertEquals(1, controller.ShowGoodsofReturnList.size());
-			//System.assertEquals('OCM_01_001003', controller.ShowGoodsofReturnList[0].esd.Name);
-			//System.assertEquals('OCM_01_001004', controller.ShowGoodsofReturnList[1].esd.Name);
-			// System.assertEquals(5, controller.ConsumableorderdetailsRecordserror.size());    //tcm
-			//System.assertEquals('Test01', controller.ConsumableorderdetailsRecordserror[1].Prod.Name__c);
-			//System.assertEquals('OCM_01_001002', controller.ConsumableorderdetailsRecordserror[2].esd.Name);
-			//System.assertEquals('OCM_02_001001', controller.ConsumableorderdetailsRecordserror[3].esd.Name);
-			Controller.GoodsReturnCheck();
-			//System.assertEquals(1, controller.ShowGoodsofReturnList.size());
-			Controller.UpdateGoodsOfReturn();
-			Controller.ToReturnGoodsPage();
-			Controller.geterrorsize();
-			System.Test.stopTest();
+      Consumable_order__c Order2 = new Consumable_order__c();
+      Order2.Name = 'OCM_01_002';
+      Order2.Order_status__c = '鎵瑰噯';
+      Order2.Order_type__c = '杩斿搧';
+      Order2.Dealer_Info__c = myAccount1.id;
+      Order2.RecordTypeid = System.Label.Dealer_Returned_Label;
+      insert Order1;
+      insert Order2;
 
-		}
-	}
+      //璁㈠崟鏄庣粏
+      //fahuo
+      Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      Orderdet.Name = 'OCM_01_00101';
+      Orderdet.Consumable_order__c = Order1.Id;
+      Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      Orderdet.Consumable_Product__c = pro1.Id;
+      Orderdet.Consumable_count__c = 4;
+      insert Orderdet;
 
-	//杩斿搧
-	@isTest(SeeAllData=true)
-	static  void productReturn_new() {
-		// // TO DO: implement unit test
-		// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		// if (rectCo.size() == 0) {
-		// 	return;
-		// }
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+      //鍙戣揣鏄庣粏
+      //fahuo
+      Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      Orderdet1.Name = 'OCM_01_001001';
+      Orderdet1.Consumable_order_minor__c = Order1.Id;
+      Orderdet1.Consumable_Product__c = pro1.Id;
+      Orderdet1.Asset_Model_No__c = 'Pro001';
+      Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+      Orderdet1.TracingCode__c = 'BXJRF';
+      //daohuo
+      Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+      Orderdet2.Name = 'OCM_01_001002';
+      Orderdet2.Consumable_order_minor__c = Order1.Id;
+      Orderdet2.Consumable_Product__c = pro1.Id;
+      Orderdet2.Asset_Model_No__c = 'Pro001';
+      Orderdet2.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet2.IsArrival__c = true;
+      Orderdet2.Arrive_date__c = Date.today();
+      Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRI';
+      Orderdet2.TracingCode__c = 'BXJRF';
+      //sale
+      Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+      Orderdet3.Name = 'OCM_01_001003';
+      Orderdet3.Consumable_order_minor__c = Order1.Id;
+      Orderdet3.Consumable_Product__c = pro1.Id;
+      Orderdet3.Asset_Model_No__c = 'Pro001';
+      Orderdet3.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet3.IsArrival__c = true;
+      Orderdet3.Arrive_date__c = Date.today();
+      Orderdet3.Used_date__c = Date.today();
+      Orderdet3.Consumable_Sale_order__c = Order1.Id;
+      Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRJ';
+      Orderdet3.Box_Piece__c = '鐩�';
+      Orderdet3.TracingCode__c = 'BXJRF';
+      //鍑哄簱
+      Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+      Orderdet4.Name = 'OCM_01_001004';
+      Orderdet4.Consumable_order_minor__c = Order1.Id;
+      Orderdet4.Consumable_Product__c = pro1.Id;
+      Orderdet4.Asset_Model_No__c = 'Pro001';
+      Orderdet4.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet4.IsArrival__c = true;
+      Orderdet4.Arrive_date__c = Date.today();
+      Orderdet4.Send_Date__c = Date.today();
+      Orderdet4.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRN';
+      Orderdet4.Box_Piece__c = '涓�';
+      Orderdet4.TracingCode__c = 'BXJRF';
+      //quxiao
+      Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+      Orderdet5.Name = 'OCM_01_001005';
+      Orderdet5.Consumable_order_minor__c = Order1.Id;
+      Orderdet5.Consumable_Product__c = pro1.Id;
+      Orderdet5.Asset_Model_No__c = 'Pro001';
+      Orderdet5.Cancellation_Date__c = Date.today();
+      Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRZ';
+      Orderdet5.Box_Piece__c = '鐩�';
+      Orderdet5.TracingCode__c = 'BXJRF';
+      //fanpin
+      Consumable_order_details2__c Orderdet6 = new Consumable_order_details2__c();
+      Orderdet6.Name = 'OCM_01_001006';
+      Orderdet6.Consumable_order_minor__c = Order1.Id;
+      Orderdet6.Consumable_Product__c = pro1.Id;
+      Orderdet6.Asset_Model_No__c = 'Pro001';
+      Orderdet6.Consumable_Return_order__c = Order2.Id;
+      Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet6.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
+      Orderdet6.Box_Piece__c = '涓�';
+      Orderdet6.TracingCode__c = 'BXJRF';
 
+      insert new List<Consumable_order_details2__c>{
+        Orderdet1,
+        Orderdet2,
+        Orderdet3,
+        Orderdet4,
+        Orderdet5,
+        Orderdet6
+      };
+      PageReference page = new PageReference('/apex/ArriveGoods?ArrType=ReG');
+      System.Test.setCurrentPage(page);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      //鎺掑簭
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXJRN\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRI\n01049531702003111115120017181000105ZK250BXJRN\n01049531702003111115120017181000105ZK250BXJRZ\n01049531702003111115120017181000105ZK250BXJRA\n01049531702003111115120017181000105ZK250BXJRI';
+      Controller.SearchPro();
+      //System.assertEquals(1, controller.ShowGoodsofReturnList.size());
+      //System.assertEquals('OCM_01_001003', controller.ShowGoodsofReturnList[0].esd.Name);
+      //System.assertEquals('OCM_01_001004', controller.ShowGoodsofReturnList[1].esd.Name);
+      // System.assertEquals(5, controller.ConsumableorderdetailsRecordserror.size());    //tcm
+      //System.assertEquals('Test01', controller.ConsumableorderdetailsRecordserror[1].Prod.Name__c);
+      //System.assertEquals('OCM_01_001002', controller.ConsumableorderdetailsRecordserror[2].esd.Name);
+      //System.assertEquals('OCM_02_001001', controller.ConsumableorderdetailsRecordserror[3].esd.Name);
+      Controller.GoodsReturnCheck();
+      controller.ShowGoodsofReturnList[0].esd.Return_reason__c = '澶氬彂';
+      controller.ShowGoodsofReturnList[0].esd.Rrturn_count__c = 1;
+      //System.assertEquals(1, controller.ShowGoodsofReturnList.size());
+      Controller.UpdateGoodsOfReturn();
+      Controller.ToReturnGoodsPage();
+      Controller.geterrorsize();
+      System.Test.stopTest();
+    }
+  }
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+  //杩斿搧
+  @isTest
+  static void productReturn_new() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
 
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
-			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
-			insert new Product2__c[] {pro1, pro2};
-			//璁㈠崟
-			Consumable_order__c Order1 = new Consumable_order__c();
-			Order1.Name = 'OCM_01_001';
-			Order1.Order_status__c = '鎵瑰噯';
-			Order1.Order_type__c = '璁㈠崟';
-			Order1.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			Order1.Order_ProType__c = 'ET';
-			insert Order1;
-			//Consumable_order__c coc = [select Dealer_Info__r.name from Consumable_order__c where Id =:Order1.Id];
-			//system.assertEquals('qeee',coc.Dealer_Info__r.name);
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'Test001',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = 'Test002',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      //璁㈠崟
+      Consumable_order__c Order1 = new Consumable_order__c();
+      Order1.Name = 'OCM_01_001';
+      Order1.Order_status__c = '鎵瑰噯';
+      Order1.Order_type__c = '璁㈠崟';
+      Order1.Dealer_Info__c = myAccount1.id;
+      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      Order1.Order_ProType__c = 'ET';
+      insert Order1;
+      //Consumable_order__c coc = [select Dealer_Info__r.name from Consumable_order__c where Id =:Order1.Id];
+      //system.assertEquals('qeee',coc.Dealer_Info__r.name);
 
-			//璁㈠崟鏄庣粏
-			//fahuo
-			Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
-			Orderdet.Name = 'OCM_01_001001';
-			Orderdet.Consumable_order__c = Order1.Id;
-			Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
-			Orderdet.Consumable_Product__c = pro1.Id;
-			Orderdet.Consumable_count__c = 4;
-			insert Orderdet;
+      //璁㈠崟鏄庣粏
+      //fahuo
+      Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      Orderdet.Name = 'OCM_01_001001';
+      Orderdet.Consumable_order__c = Order1.Id;
+      Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      Orderdet.Consumable_Product__c = pro1.Id;
+      Orderdet.Consumable_count__c = 4;
+      insert Orderdet;
 
-			//鍙戣揣鏄庣粏
-			//fahuo
-			/*Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      //鍙戣揣鏄庣粏
+      //fahuo
+      /*Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
 			   Orderdet1.Name = 'OCM_01_001001';
 			   Orderdet1.Consumable_order_minor__c = Order1.Id;
 			   Orderdet1.Consumable_Product__c = pro1.Id;
@@ -875,1508 +1313,2747 @@
 			   //Orderdet2.Send_Date__c = Date.today();
 			   //Orderdet2.Used_date__c= Date.today();
 			   Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';*/
-			//sale
-			Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
-			Orderdet3.Name = 'OCM_01_001003';
-			Orderdet3.Consumable_order_minor__c = Order1.Id;
-			Orderdet3.Consumable_Product__c = pro1.Id;
-			Orderdet3.Asset_Model_No__c = 'Pro001';
-			Orderdet3.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet3.IsArrival__c = true;
-			Orderdet3.Consumable_Sale_order__c = Order1.Id;
-			Orderdet3.Box_Piece__c ='鐩�';
-			Orderdet3.Used_date__c= Date.today();
-			Orderdet3.Arrive_date__c = Date.today();
-			Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
-			Orderdet3.TracingCode__c = 'BXJRF';
-			Orderdet3.SerialLotNo__c = '5ZK';
-			//鍑哄簱
-			Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
-			Orderdet4.Name = 'OCM_01_001004';
-			Orderdet4.Consumable_order_minor__c = Order1.Id;
-			Orderdet4.Consumable_Product__c = pro1.Id;
-			Orderdet4.Asset_Model_No__c = 'Pro001';
-			Orderdet4.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet4.IsArrival__c = true;
-			Orderdet4.Consumable_Shipment_order__c = Order1.Id;
-			Orderdet4.Box_Piece__c ='涓�';
-			Orderdet4.Send_Date__c = Date.today();
-			Orderdet4.Arrive_date__c = Date.today();
-			Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRN';
-			Orderdet4.TracingCode__c = 'BXJRN';
-			Orderdet4.SerialLotNo__c = '5ZK';
-			//quxiao
-			Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
-			Orderdet5.Name = 'OCM_01_001005';
-			Orderdet5.Consumable_order_minor__c = Order1.Id;
-			Orderdet5.Consumable_Product__c = pro1.Id;
-			Orderdet5.Asset_Model_No__c = 'Pro001';
-			Orderdet5.Cancellation_Date__c = Date.today();
-			Orderdet5.Cancellation_Flag__c = true;
-			Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRZ';
-			Orderdet5.Box_Piece__c ='涓�';
-			Orderdet5.TracingCode__c = 'BXJRZ';
-			Orderdet5.SerialLotNo__c = '5ZK';
-			insert new Consumable_order_details2__c[] {Orderdet3,Orderdet4,Orderdet5};
+      //sale
+      Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+      Orderdet3.Name = 'OCM_01_001003';
+      Orderdet3.Consumable_order_minor__c = Order1.Id;
+      Orderdet3.Consumable_Product__c = pro1.Id;
+      Orderdet3.Asset_Model_No__c = 'Pro001';
+      Orderdet3.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet3.IsArrival__c = true;
+      Orderdet3.Consumable_Sale_order__c = Order1.Id;
+      Orderdet3.Box_Piece__c = '鐩�';
+      Orderdet3.Used_date__c = Date.today();
+      Orderdet3.Arrive_date__c = Date.today();
+      Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+      Orderdet3.TracingCode__c = 'BXJRF';
+      Orderdet3.SerialLotNo__c = '5ZK';
+      //鍑哄簱
+      Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+      Orderdet4.Name = 'OCM_01_001004';
+      Orderdet4.Consumable_order_minor__c = Order1.Id;
+      Orderdet4.Consumable_Product__c = pro1.Id;
+      Orderdet4.Asset_Model_No__c = 'Pro001';
+      Orderdet4.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet4.IsArrival__c = true;
+      Orderdet4.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet4.Box_Piece__c = '涓�';
+      Orderdet4.Send_Date__c = Date.today();
+      Orderdet4.Arrive_date__c = Date.today();
+      Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRN';
+      Orderdet4.TracingCode__c = 'BXJRN';
+      Orderdet4.SerialLotNo__c = '5ZK';
+      //quxiao
+      Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+      Orderdet5.Name = 'OCM_01_001005';
+      Orderdet5.Consumable_order_minor__c = Order1.Id;
+      Orderdet5.Consumable_Product__c = pro1.Id;
+      Orderdet5.Asset_Model_No__c = 'Pro001';
+      Orderdet5.Cancellation_Date__c = Date.today();
+      Orderdet5.Cancellation_Flag__c = true;
+      Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRZ';
+      Orderdet5.Box_Piece__c = '涓�';
+      Orderdet5.TracingCode__c = 'BXJRZ';
+      Orderdet5.SerialLotNo__c = '5ZK';
+      insert new List<Consumable_order_details2__c>{
+        Orderdet3,
+        Orderdet4,
+        Orderdet5
+      };
 
-			PageReference page = new PageReference('/apex/ArriveGoods?ArrType=ReG');
-			System.Test.setCurrentPage(page);
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			//鍒濆鍖栨祴璇�
-			System.Test.startTest();
-			Controller.init();
-			//鎺掑簭
-			Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRN\n01049531702003111115120017181000105ZK250BXJRZ\n01049531702003111115120017181000105ZK250BXJRR';
-			Controller.SearchPro();
-			System.assertEquals(1, controller.ConsumableorderdetailsRecordserror.size());
-			System.assertEquals(2, controller.ShowGoodsofReturnList.size());
-			controller.ShowGoodsofReturnList[0].esd.Return_reason__c='澶氬彂';
-			controller.ShowGoodsofReturnList[1].esd.Return_reason__c='澶氬彂';
-			controller.ShowGoodsofReturnList[0].esd.Rrturn_count__c =1;
-			Controller.UpdateGoodsOfReturn();
+      PageReference page = new PageReference('/apex/ArriveGoods?ArrType=ReG');
+      System.Test.setCurrentPage(page);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      //鎺掑簭
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRN\n01049531702003111115120017181000105ZK250BXJRZ\n01049531702003111115120017181000105ZK250BXJRR';
+      Controller.SearchPro();
+      // System.assertEquals(1, controller.ConsumableorderdetailsRecordserror.size());
+      System.assertEquals(2, controller.ShowGoodsofReturnList.size());
+      controller.ShowGoodsofReturnList[0].esd.Return_reason__c = '澶氬彂';
+      controller.ShowGoodsofReturnList[1].esd.Return_reason__c = '澶氬彂';
+      controller.ShowGoodsofReturnList[0].esd.Rrturn_count__c = 1;
+      Controller.UpdateGoodsOfReturn();
 
-			list<String> list1 = new list<String>();
-			list1.add(Controller.barcode = '01234567898');
-			Controller.inventoryEntryNoESetId(list1);
+      list<String> list1 = new List<String>();
+      list1.add(Controller.barcode = '01234567898');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '012345678901234A67');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '012345678901234A67');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '0123456789012345117AA01');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '0123456789012345117AA01');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '01234567890123456789012349990001');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '01234567890123456789012349990001');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '0123456789012345177AA0000000000001');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '0123456789012345177AA0000000000001');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '0123456789012345177AA1111111111111');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '0123456789012345177AA1111111111111');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '241345');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '241345');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '2413456');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '2413456');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '24134567');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '24134567');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '241345678');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '241345678');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '2413456789');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '2413456789');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '24134567890');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '24134567890');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '241345678901');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '241345678901');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '0112345678901231177890121215678901234');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '0112345678901231177890121215678901234');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '0112345678901231106789012105678901234');
-			Controller.inventoryEntryNoESetId(list1);
-			list1.clear();
-			list1.add(Controller.barcode = '0112345678901231106789012105625001234');
-			Controller.inventoryEntryNoESetId(list1);
-			System.Test.stopTest();
+      list1.clear();
+      list1.add(Controller.barcode = '0112345678901231106789012105678901234');
+      Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '0112345678901231106789012105625001234');
+      Controller.inventoryEntryNoESetId(list1);
+      System.Test.stopTest();
+    }
+  }
 
-		}
-	}
+  //鐩存帴鍒拌揣
+  @isTest
+  static void arrivedirect() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-	//鐩存帴鍒拌揣
-	@isTest(SeeAllData=true)
-	static  void arrivedirect() {
-		// // TO DO: implement unit test
-		// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		// if (rectCo.size() == 0) {
-		// 	return;
-		// }
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = '2344',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = '82324',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      //浜у搧娉ㄥ唽璇�
+      Product_Register__c prc = new Product_Register__c(
+        Name = '鍥芥娉ㄨ繘20162220210',
+        MedPrdClass__c = '3',
+        ValidFrom__c = date.newinstance(2018, 7, 22),
+        ValidTo__c = date.newinstance(2028, 7, 22),
+        RegisterNoClass_Old__c = '6815',
+        RegisterNoClass_New__c = '6815',
+        RegisterNoStatus__c = '鏈夋晥'
+      );
+      insert prc;
+      //鏂版棫鍏崇郴瀵圭収琛�
+      //Product_Register_contrast__c prcc = new Product_Register_contrast__c(
+      //                                        Name = 'Test20181204',
+      //                                        Register_new__c = '314',
+      //                                        Register_old__c = '36815'
+      //                                        );
+      //insert prcc;
+      //浜у搧-浜у搧娉ㄥ唽璇佸叧绯�  prod01
+      Product_Register_Link__c prlc = new Product_Register_Link__c(
+        Product2__c = prod01.Id,
+        Product_Register__c = prc.Id
+      );
+      insert prlc;
+      //浜у搧-浜у搧娉ㄥ唽璇佸叧绯�  prod02
+      Product_Register_Link__c prlc2 = new Product_Register_Link__c(
+        Product2__c = prod02.Id,
+        Product_Register__c = prc.Id
+      );
+      insert prlc2;
+      //璁㈠崟
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
+      Consumable_order__c Order1 = new Consumable_order__c();
+      Order1.Name = 'OCM_01_001';
+      Order1.Order_status__c = '鎵瑰噯';
+      Order1.Order_type__c = '璁㈠崟';
+      Order1.Dealer_Info__c = myAccount1.id;
+      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      insert Order1;
 
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
+      //璁㈠崟鏄庣粏
+      //fahuo
+      Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      Orderdet.Name = 'OCM_01_00101';
+      Orderdet.Consumable_order__c = Order1.Id;
+      Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      Orderdet.Consumable_Product__c = pro1.Id;
+      Orderdet.Consumable_count__c = 4;
+      insert Orderdet;
 
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='2344',Product2__c = prod01.Id);
-			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='82324',Product2__c = prod02.Id);
-			insert new Product2__c[] {pro1, pro2};
-			//浜у搧娉ㄥ唽璇�
-			Product_Register__c prc = new Product_Register__c(Name = '鍥芥娉ㄨ繘20162220210',
-			                                                  MedPrdClass__c = '3',
-			                                                  ValidFrom__c = date.newinstance(2018, 07, 22),
-			                                                  ValidTo__c = date.newinstance(2028, 07, 22),
-			                                                  RegisterNoClass_Old__c = '6815',
-			                                                  RegisterNoClass_New__c = '6815',
-			                                                  RegisterNoStatus__c = '鏈夋晥'
-			                                                  );
-			insert prc;
-			//鏂版棫鍏崇郴瀵圭収琛�
-			//Product_Register_contrast__c prcc = new Product_Register_contrast__c(
-			//                                        Name = 'Test20181204',
-			//                                        Register_new__c = '314',
-			//                                        Register_old__c = '36815'
-			//                                        );
-			//insert prcc;
-			//浜у搧-浜у搧娉ㄥ唽璇佸叧绯�  prod01
-			Product_Register_Link__c prlc = new Product_Register_Link__c(
-				Product2__c = prod01.Id,
-				Product_Register__c = prc.Id
-				);
-			insert prlc;
-			//浜у搧-浜у搧娉ㄥ唽璇佸叧绯�  prod02
-			Product_Register_Link__c prlc2 = new Product_Register_Link__c(
-				Product2__c = prod02.Id,
-				Product_Register__c = prc.Id
-				);
-			insert prlc2;
-			//璁㈠崟
+      //鍙戣揣鏄庣粏
+      //fahuo
+      Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      Orderdet1.Name = 'OCM_01_001001';
+      Orderdet1.Consumable_order_minor__c = Order1.Id;
+      Orderdet1.Consumable_Product__c = pro1.Id;
+      Orderdet1.Asset_Model_No__c = 'Test01';
+      Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+      //daohuo
+      Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+      Orderdet2.Name = 'OCM_01_001002';
+      Orderdet2.Consumable_order_minor__c = Order1.Id;
+      Orderdet2.Consumable_Product__c = pro1.Id;
+      Orderdet2.Asset_Model_No__c = 'Test01';
+      Orderdet2.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet2.IsArrival__c = true;
+      Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRI';
+      //sale
+      Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+      Orderdet3.Name = 'OCM_01_001003';
+      Orderdet3.Consumable_order_minor__c = Order1.Id;
+      Orderdet3.Consumable_Product__c = pro1.Id;
+      Orderdet3.Asset_Model_No__c = 'Test01';
+      Orderdet3.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet3.IsArrival__c = true;
+      Orderdet3.Consumable_Sale_order__c = Order1.Id;
+      Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRJ';
+      //鍑哄簱
+      Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+      Orderdet4.Name = 'OCM_01_001004';
+      Orderdet4.Consumable_order_minor__c = Order1.Id;
+      Orderdet4.Consumable_Product__c = pro1.Id;
+      Orderdet4.Asset_Model_No__c = 'Test01';
+      Orderdet4.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet4.IsArrival__c = true;
+      Orderdet4.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRN';
+      //List<Product2> proList = [select name,Estimation_Entry_Possibility__c from Product2 where id = :prod01.Id];
+      //System.assertEquals('鈼�', proList[0].Estimation_Entry_Possibility__c);
 
-			Consumable_order__c Order1 = new Consumable_order__c();
-			Order1.Name = 'OCM_01_001';
-			Order1.Order_status__c = '鎵瑰噯';
-			Order1.Order_type__c = '璁㈠崟';
-			Order1.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			insert Order1;
+      insert new List<Consumable_order_details2__c>{
+        Orderdet1,
+        Orderdet2,
+        Orderdet3,
+        Orderdet4
+      };
+      PageReference page = new PageReference(
+        '/apex/ArriveGoods?Esetid=' + Order1.Id
+      );
+      System.Test.setCurrentPage(page);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRI\n01049531702003111115120017181000105ZK250BXJRN';
+      Controller.SearchPro();
+      //System.assertEquals(1, controller.consumableInventory.size());
 
-			//璁㈠崟鏄庣粏
-			//fahuo
-			Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
-			Orderdet.Name = 'OCM_01_00101';
-			Orderdet.Consumable_order__c = Order1.Id;
-			Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
-			Orderdet.Consumable_Product__c = pro1.Id;
-			Orderdet.Consumable_count__c = 4;
-			insert Orderdet;
+      System.Test.stopTest();
+    }
+  }
 
-			//鍙戣揣鏄庣粏
-			//fahuo
-			Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
-			Orderdet1.Name = 'OCM_01_001001';
-			Orderdet1.Consumable_order_minor__c = Order1.Id;
-			Orderdet1.Consumable_Product__c = pro1.Id;
-			Orderdet1.Asset_Model_No__c = 'Test01';
-			Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
-			//daohuo
-			Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
-			Orderdet2.Name = 'OCM_01_001002';
-			Orderdet2.Consumable_order_minor__c = Order1.Id;
-			Orderdet2.Consumable_Product__c = pro1.Id;
-			Orderdet2.Asset_Model_No__c = 'Test01';
-			Orderdet2.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet2.IsArrival__c = true;
-			Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRI';
-			//sale
-			Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
-			Orderdet3.Name = 'OCM_01_001003';
-			Orderdet3.Consumable_order_minor__c = Order1.Id;
-			Orderdet3.Consumable_Product__c = pro1.Id;
-			Orderdet3.Asset_Model_No__c = 'Test01';
-			Orderdet3.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet3.IsArrival__c = true;
-			Orderdet3.Consumable_Sale_order__c = Order1.Id;
-			Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRJ';
-			//鍑哄簱
-			Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
-			Orderdet4.Name = 'OCM_01_001004';
-			Orderdet4.Consumable_order_minor__c = Order1.Id;
-			Orderdet4.Consumable_Product__c = pro1.Id;
-			Orderdet4.Asset_Model_No__c = 'Test01';
-			Orderdet4.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet4.IsArrival__c = true;
-			Orderdet4.Consumable_Shipment_order__c = Order1.Id;
-			Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRN';
-			//List<Product2> proList = [select name,Estimation_Entry_Possibility__c from Product2 where id = :prod01.Id];
-			//System.assertEquals('鈼�', proList[0].Estimation_Entry_Possibility__c);
+  //鐩存帴鍒拌揣
+  @isTest
+  static void arrivedirect241() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-			insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2,Orderdet3,Orderdet4};
-			PageReference page = new PageReference('/apex/ArriveGoods?Esetid=' + Order1.Id);
-			System.Test.setCurrentPage(page);
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			//鍒濆鍖栨祴璇�
-			System.Test.startTest();
-			Controller.init();
-			Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRI\n01049531702003111115120017181000105ZK250BXJRN';
-			Controller.SearchPro();
-			//System.assertEquals(1, controller.consumableInventory.size());
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
 
-			System.Test.stopTest();
-		}
-	}
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'Test001',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = 'Test002',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      //浜у搧娉ㄥ唽璇�
+      Product_Register__c prc = new Product_Register__c(
+        Name = '鍥芥娉ㄨ繘20162220210',
+        MedPrdClass__c = '3',
+        ValidFrom__c = date.newinstance(2018, 7, 22),
+        ValidTo__c = date.newinstance(2028, 7, 22),
+        RegisterNoClass_Old__c = '6815',
+        RegisterNoClass_New__c = '6815',
+        RegisterNoStatus__c = '鏈夋晥'
+      );
+      insert prc;
+      //鏂版棫鍏崇郴瀵圭収琛�
+      //Product_Register_contrast__c prcc = new Product_Register_contrast__c(
+      //                                        Name = 'Test20181204',
+      //                                        Register_new__c = '314',
+      //                                        Register_old__c = '36815'
+      //                                        );
+      //insert prcc;
+      //浜у搧-浜у搧娉ㄥ唽璇佸叧绯�  prod01
+      Product_Register_Link__c prlc = new Product_Register_Link__c(
+        Product2__c = prod01.Id,
+        Product_Register__c = prc.Id
+      );
+      insert prlc;
+      //浜у搧-浜у搧娉ㄥ唽璇佸叧绯�  prod02
+      Product_Register_Link__c prlc2 = new Product_Register_Link__c(
+        Product2__c = prod02.Id,
+        Product_Register__c = prc.Id
+      );
+      insert prlc2;
+      //璁㈠崟
 
-	//鐩存帴鍒拌揣
-	@isTest(SeeAllData=true)
-	static  void arrivedirect241() {
-		// // TO DO: implement unit test
-		// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		// if (rectCo.size() == 0) {
-		// 	return;
-		// }
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+      Consumable_order__c Order1 = new Consumable_order__c();
+      Order1.Name = 'OCM_01_001';
+      Order1.Order_status__c = '鎵瑰噯';
+      Order1.Order_type__c = '璁㈠崟';
+      Order1.Dealer_Info__c = myAccount1.id;
+      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      insert Order1;
+      Consumable_order__c Order2 = new Consumable_order__c();
+      Order2.Name = 'OCM_01_002';
+      Order2.Order_status__c = '鎵瑰噯';
+      Order2.Order_type__c = '鍒拌揣';
+      Order2.Dealer_Info__c = myAccount1.id;
+      Order2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      Order2.Deliver_date__c = Date.today();
+      Order2.Order_date__c = Date.today();
+      insert Order2;
+      Order2 = new Consumable_order__c();
+      Order2.Name = 'OCM_01_002';
+      Order2.Order_status__c = '鎵瑰噯';
+      Order2.Order_type__c = '杩斿搧';
+      Order2.Dealer_Info__c = myAccount1.id;
+      Order2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      Order2.Deliver_date__c = Date.today();
+      Order2.Order_date__c = Date.today();
+      Order2.ReturnGs_Upload_Date__c = Date.today();
+      insert Order2;
 
+      //璁㈠崟鏄庣粏
+      //fahuo
+      Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      Orderdet.Name = 'OCM_01_00101';
+      Orderdet.Consumable_order__c = Order1.Id;
+      Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      Orderdet.Consumable_Product__c = pro1.Id;
+      Orderdet.Consumable_count__c = 4;
+      insert Orderdet;
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+      //鍙戣揣鏄庣粏
+      //fahuo
+      Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      Orderdet1.Name = 'OCM_01_001001';
+      Orderdet1.Consumable_order_minor__c = Order1.Id;
+      Orderdet1.Consumable_Product__c = pro1.Id;
+      Orderdet1.Asset_Model_No__c = 'Test01';
+      Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+      Orderdet1.Arrive_date__c = Date.today();
+      Orderdet1.Rrturn_count__c = 1;
+      Orderdet1.TracingCode__c = '20170808';
+      //daohuo
+      Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+      Orderdet2.Name = 'OCM_01_001002';
+      Orderdet2.Consumable_order_minor__c = Order2.Id;
+      Orderdet2.Consumable_Product__c = pro1.Id;
+      Orderdet2.Asset_Model_No__c = 'Test01';
+      Orderdet2.Consumable_Arrived_order__c = Order2.Id;
+      //Orderdet2.IsArrival__c = true;
+      Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRI';
+      Orderdet2.Arrive_date__c = Date.today();
+      Orderdet2.TracingCode__c = '20170808';
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
+      Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+      Orderdet3.Name = 'OCM_01_001002';
+      Orderdet3.Consumable_order_minor__c = Order2.Id;
+      Orderdet3.Consumable_Product__c = pro1.Id;
+      Orderdet3.Asset_Model_No__c = 'Test01';
+      Orderdet3.Consumable_Arrived_order__c = Order2.Id;
+      //Orderdet3.IsArrival__c = true;
+      Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR2';
+      Orderdet3.Used_date__c = Date.today();
+      Orderdet3.TracingCode__c = '20170808';
+      //sale
+      Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+      Orderdet4.Name = 'OCM_01_001003';
+      Orderdet4.Consumable_order_minor__c = Order2.Id;
+      Orderdet4.Consumable_Product__c = pro1.Id;
+      Orderdet4.Asset_Model_No__c = 'Test01';
+      Orderdet4.Consumable_Arrived_order__c = Order2.Id;
+      //Orderdet3.IsArrival__c = true;
+      Orderdet4.Consumable_Sale_order__c = Order2.Id;
+      Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR3';
+      Orderdet4.Used_date__c = Date.today();
+      Orderdet4 = new Consumable_order_details2__c();
+      Orderdet4.Name = 'OCM_01_001003';
+      Orderdet4.Consumable_order_minor__c = Order1.Id;
+      Orderdet4.Consumable_Product__c = pro1.Id;
+      Orderdet4.Asset_Model_No__c = 'Test01';
+      Orderdet4.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet3.IsArrival__c = true;
+      Orderdet4.Consumable_Sale_order__c = Order2.Id;
+      Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJ13';
+      Orderdet4.Used_date__c = Date.today();
+      Orderdet4.TracingCode__c = '20170808';
+      Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+      Orderdet5.Name = 'OCM_01_001003';
+      Orderdet5.Consumable_order_minor__c = Order2.Id;
+      Orderdet5.Consumable_Product__c = pro1.Id;
+      Orderdet5.Asset_Model_No__c = 'Test01';
+      Orderdet5.Consumable_Arrived_order__c = Order2.Id;
+      //Orderdet3.IsArrival__c = true;
+      Orderdet5.Consumable_Sale_order__c = Order2.Id;
+      Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRJ';
+      Orderdet5.Arrive_date__c = Date.today().addDays(1);
+      Orderdet5.Send_Date__c = null;
+      Orderdet5.Used_date__c = null;
+      Orderdet5.Lose_Flag__c = false;
+      Orderdet5.Return_date__c = null;
+      Orderdet5.Cancellation_Date__c = Date.today().addDays(1);
+      Orderdet5.Box_Piece__c = '鐩�';
+      Orderdet5.TracingCode__c = '20170808';
 
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
+      //鍑哄簱
+      Consumable_order_details2__c Orderdet6 = new Consumable_order_details2__c();
+      Orderdet6.Name = 'OCM_01_001004';
+      Orderdet6.Consumable_order_minor__c = Order1.Id;
+      Orderdet6.Consumable_Product__c = pro1.Id;
+      Orderdet6.Asset_Model_No__c = 'Test01';
+      Orderdet6.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet4.IsArrival__c = true;
+      Orderdet6.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet6.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR4';
+      Orderdet6.Send_Date__c = Date.today();
+      Orderdet6.Return_date__c = null;
+      Orderdet6.Box_Piece__c = '鐩�';
+      Orderdet6.Rrturn_count__c = 1;
+      Orderdet6.TracingCode__c = '20170808';
 
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
-			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
-			insert new Product2__c[] {pro1, pro2};
-			//浜у搧娉ㄥ唽璇�
-			Product_Register__c prc = new Product_Register__c(Name = '鍥芥娉ㄨ繘20162220210',
-			                                                  MedPrdClass__c = '3',
-			                                                  ValidFrom__c = date.newinstance(2018, 07, 22),
-			                                                  ValidTo__c = date.newinstance(2028, 07, 22),
-			                                                  RegisterNoClass_Old__c = '6815',
-			                                                  RegisterNoClass_New__c = '6815',
-			                                                  RegisterNoStatus__c = '鏈夋晥'
-			                                                  );
-			insert prc;
-			//鏂版棫鍏崇郴瀵圭収琛�
-			//Product_Register_contrast__c prcc = new Product_Register_contrast__c(
-			//                                        Name = 'Test20181204',
-			//                                        Register_new__c = '314',
-			//                                        Register_old__c = '36815'
-			//                                        );
-			//insert prcc;
-			//浜у搧-浜у搧娉ㄥ唽璇佸叧绯�  prod01
-			Product_Register_Link__c prlc = new Product_Register_Link__c(
-				Product2__c = prod01.Id,
-				Product_Register__c = prc.Id
-				);
-			insert prlc;
-			//浜у搧-浜у搧娉ㄥ唽璇佸叧绯�  prod02
-			Product_Register_Link__c prlc2 = new Product_Register_Link__c(
-				Product2__c = prod02.Id,
-				Product_Register__c = prc.Id
-				);
-			insert prlc2;
-			//璁㈠崟
+      // 鍗曚綅涓轰釜鐨凚arcode瀵瑰簲鐨勫嚭搴撳崟
+      Consumable_order_details2__c Orderdet7 = new Consumable_order_details2__c();
+      Orderdet7.Name = 'OCM_01_001004';
+      Orderdet7.Consumable_order_minor__c = Order1.Id;
+      Orderdet7.Consumable_Product__c = pro1.Id;
+      Orderdet7.Asset_Model_No__c = 'Test01';
+      Orderdet7.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet4.IsArrival__c = true;
+      Orderdet7.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet7.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet7.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR1';
+      Orderdet7.Send_Date__c = Date.today();
+      Orderdet7.Box_Piece__c = '涓�';
+      Orderdet7.Used_date__c = Date.today();
+      Orderdet7.Return_date__c = null;
+      Orderdet7.RemoveBox_No__c = 1;
+      Orderdet7.Consumable_ZS_order__c = Order1.Id;
+      Orderdet7.Rrturn_count__c = 1;
+      Orderdet7.TracingCode__c = '20170808';
 
-			Consumable_order__c Order1 = new Consumable_order__c();
-			Order1.Name = 'OCM_01_001';
-			Order1.Order_status__c = '鎵瑰噯';
-			Order1.Order_type__c = '璁㈠崟';
-			Order1.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			insert Order1;
-			Consumable_order__c Order2 = new Consumable_order__c();
-			Order2.Name = 'OCM_01_002';
-			Order2.Order_status__c = '鎵瑰噯';
-			Order2.Order_type__c   = '鍒拌揣';
-			Order2.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			Order2.Deliver_date__c = Date.today();
-			Order2.Order_date__c   = Date.today();
-			insert Order2;
-			Order2 = new Consumable_order__c();
-			Order2.Name = 'OCM_01_002';
-			Order2.Order_status__c = '鎵瑰噯';
-			Order2.Order_type__c   = '杩斿搧';
-			Order2.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			Order2.Deliver_date__c = Date.today();
-			Order2.Order_date__c   = Date.today();
-			Order2.ReturnGs_Upload_Date__c = Date.today();
-			insert Order2;
+      Orderdet7 = new Consumable_order_details2__c();
+      Orderdet7.Name = 'OCM_01_001004';
+      Orderdet7.Consumable_order_minor__c = Order1.Id;
+      Orderdet7.Consumable_Product__c = pro1.Id;
+      Orderdet7.Asset_Model_No__c = 'Test01';
+      Orderdet7.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet7.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet7.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet7.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR7';
+      Orderdet7.Send_Date__c = Date.today();
+      Orderdet7.Box_Piece__c = '涓�';
+      Orderdet7.Used_date__c = Date.today();
+      Orderdet7.Return_date__c = null;
+      Orderdet7.RemoveBox_No__c = 1;
+      Orderdet7.Consumable_ZS_order__c = Order1.Id;
+      Orderdet7.Rrturn_count__c = 0;
+      Orderdet7.TracingCode__c = '20170808';
 
-			//璁㈠崟鏄庣粏
-			//fahuo
-			Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
-			Orderdet.Name = 'OCM_01_00101';
-			Orderdet.Consumable_order__c = Order1.Id;
-			Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
-			Orderdet.Consumable_Product__c = pro1.Id;
-			Orderdet.Consumable_count__c = 4;
-			insert Orderdet;
+      Consumable_order_details2__c Orderdet8 = new Consumable_order_details2__c();
+      Orderdet8.Name = 'OCM_01_001004';
+      Orderdet8.Consumable_order_minor__c = Order1.Id;
+      Orderdet8.Consumable_Product__c = pro1.Id;
+      Orderdet8.Asset_Model_No__c = 'Test01';
+      Orderdet8.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet4.IsArrival__c = true;
+      Orderdet8.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet8.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet8.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR9';
+      Orderdet8.Send_Date__c = Date.today();
+      Orderdet8.Box_Piece__c = '涓�';
+      Orderdet8.Used_date__c = Date.today();
+      Orderdet8.Return_date__c = null;
+      Orderdet8.RemoveBox_No__c = 1;
+      Orderdet8.Consumable_ZS_order__c = Order1.Id;
+      Orderdet8.Rrturn_count__c = null;
+      Orderdet8.RemoveBox_date__c = Date.today();
+      Orderdet8.Intra_Trade_List_RMB__c = 1;
+      Orderdet8.Sterilization_limit__c = Date.today();
+      Orderdet8.SerialLotNo__c = '11鎵规';
+      Orderdet8.TracingCode__c = '20170808';
+      Orderdet8.Arrive_date__c = Date.today();
 
-			//鍙戣揣鏄庣粏
-			//fahuo
-			Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
-			Orderdet1.Name = 'OCM_01_001001';
-			Orderdet1.Consumable_order_minor__c = Order1.Id;
-			Orderdet1.Consumable_Product__c = pro1.Id;
-			Orderdet1.Asset_Model_No__c = 'Test01';
-			Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
-			Orderdet1.Arrive_date__c = Date.today();
-			Orderdet1.Rrturn_count__c =1;
-			Orderdet1.TracingCode__c = '20170808';
-			//daohuo
-			Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
-			Orderdet2.Name = 'OCM_01_001002';
-			Orderdet2.Consumable_order_minor__c = Order2.Id;
-			Orderdet2.Consumable_Product__c = pro1.Id;
-			Orderdet2.Asset_Model_No__c = 'Test01';
-			Orderdet2.Consumable_Arrived_order__c = Order2.Id;
-			//Orderdet2.IsArrival__c = true;
-			Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRI';
-			Orderdet2.Arrive_date__c = Date.today();
-			Orderdet2.TracingCode__c = '20170808';
+      Consumable_order_details2__c Orderdet9 = new Consumable_order_details2__c();
+      Orderdet9.Name = 'OCM_01_001004';
+      Orderdet9.Consumable_order_minor__c = Order1.Id;
+      Orderdet9.Consumable_Product__c = pro1.Id;
+      Orderdet9.Asset_Model_No__c = 'Test01';
+      Orderdet9.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet9.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet9.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet9.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR8';
+      Orderdet9.Send_Date__c = Date.today();
+      Orderdet9.Box_Piece__c = '涓�';
+      Orderdet9.Used_date__c = Date.today();
+      Orderdet9.Return_date__c = null;
+      Orderdet9.Consumable_ZS_order__c = Order1.Id;
+      Orderdet9.Arrive_date__c = Date.today();
+      Orderdet9.Rrturn_count__c = 10;
+      Orderdet9.TracingCode__c = '20170808';
+      Consumable_order_details2__c lose = new Consumable_order_details2__c();
+      lose.Name = 'OCM_01_001004';
+      lose.Consumable_order_minor__c = Order1.Id;
+      lose.Consumable_Product__c = pro1.Id;
+      lose.Asset_Model_No__c = 'Test01';
+      lose.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet4.IsArrival__c = true;
+      lose.Consumable_Shipment_order__c = Order1.Id;
+      lose.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      lose.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR5';
+      lose.Send_Date__c = null;
+      lose.Arrive_date__c = null;
+      lose.Used_date__c = null;
+      lose.Box_Piece__c = '鐩�';
+      lose.TracingCode__c = '20170808';
+      Consumable_order_details2__c lose1 = new Consumable_order_details2__c();
+      lose1.Name = 'OCM_01_001004';
+      lose1.Consumable_order_minor__c = Order1.Id;
+      lose1.Consumable_Product__c = pro1.Id;
+      lose1.Asset_Model_No__c = 'Test01';
+      lose1.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet4.IsArrival__c = true;
+      lose1.Consumable_Shipment_order__c = Order1.Id;
+      lose1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      lose1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR6';
+      lose1.Send_Date__c = null;
+      lose1.Arrive_date__c = Date.today();
+      lose1.Used_date__c = null;
+      lose1.Box_Piece__c = '鐩�';
+      lose1.TracingCode__c = '20170808';
+      Consumable_order_details2__c lose2 = new Consumable_order_details2__c();
+      lose2.Name = 'OCM_01_001004';
+      lose2.Consumable_order_minor__c = Order2.Id;
+      lose2.Consumable_Product__c = pro1.Id;
+      lose2.Asset_Model_No__c = 'Test01';
+      lose2.Consumable_Arrived_order__c = Order2.Id;
+      //Orderdet4.IsArrival__c = true;
+      lose2.Consumable_Shipment_order__c = Order2.Id;
+      lose2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      lose2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR7';
+      lose2.Send_Date__c = null;
+      lose2.Arrive_date__c = Date.today();
+      lose2.Used_date__c = null;
+      lose2.Box_Piece__c = '鐩�';
+      lose2.Intra_Trade_List_RMB__c = 1;
+      lose2.Direct_Arrive_Product__c = true;
+      lose2.Sterilization_limit__c = Date.today();
+      lose2.SerialLotNo__c = '11鎵规';
+      lose2.TracingCode__c = '20170808';
 
-			Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
-			Orderdet3.Name = 'OCM_01_001002';
-			Orderdet3.Consumable_order_minor__c = Order2.Id;
-			Orderdet3.Consumable_Product__c = pro1.Id;
-			Orderdet3.Asset_Model_No__c = 'Test01';
-			Orderdet3.Consumable_Arrived_order__c = Order2.Id;
-			//Orderdet3.IsArrival__c = true;
-			Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR2';
-			Orderdet3.Used_date__c = Date.today();
-			Orderdet3.TracingCode__c = '20170808';
-			//sale
-			Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
-			Orderdet4.Name = 'OCM_01_001003';
-			Orderdet4.Consumable_order_minor__c = Order2.Id;
-			Orderdet4.Consumable_Product__c = pro1.Id;
-			Orderdet4.Asset_Model_No__c = 'Test01';
-			Orderdet4.Consumable_Arrived_order__c = Order2.Id;
-			//Orderdet3.IsArrival__c = true;
-			Orderdet4.Consumable_Sale_order__c = Order2.Id;
-			Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR3';
-			Orderdet4.Used_date__c =Date.today();
-			Orderdet4 = new Consumable_order_details2__c();
-			Orderdet4.Name = 'OCM_01_001003';
-			Orderdet4.Consumable_order_minor__c = Order1.Id;
-			Orderdet4.Consumable_Product__c = pro1.Id;
-			Orderdet4.Asset_Model_No__c = 'Test01';
-			Orderdet4.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet3.IsArrival__c = true;
-			Orderdet4.Consumable_Sale_order__c = Order2.Id;
-			Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJ13';
-			Orderdet4.Used_date__c =Date.today();
-			Orderdet4.TracingCode__c = '20170808';
-			Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
-			Orderdet5.Name = 'OCM_01_001003';
-			Orderdet5.Consumable_order_minor__c = Order2.Id;
-			Orderdet5.Consumable_Product__c = pro1.Id;
-			Orderdet5.Asset_Model_No__c = 'Test01';
-			Orderdet5.Consumable_Arrived_order__c = Order2.Id;
-			//Orderdet3.IsArrival__c = true;
-			Orderdet5.Consumable_Sale_order__c = Order2.Id;
-			Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRJ';
-			Orderdet5.Arrive_date__c = Date.today().addDays(1);
-			Orderdet5.Send_Date__c = null;
-			Orderdet5.Used_date__c = null;
-			Orderdet5.Lose_Flag__c = false;
-			Orderdet5.Return_date__c= null;
-			Orderdet5.Cancellation_Date__c= Date.today().addDays(1);
-			Orderdet5.Box_Piece__c = '鐩�';
-			Orderdet5.TracingCode__c = '20170808';
+      //List<Product2> proList = [select name,Estimation_Entry_Possibility__c from Product2 where id = :prod01.Id];
+      //System.assertEquals('鈼�', proList[0].Estimation_Entry_Possibility__c);
 
-			//鍑哄簱
-			Consumable_order_details2__c Orderdet6 = new Consumable_order_details2__c();
-			Orderdet6.Name = 'OCM_01_001004';
-			Orderdet6.Consumable_order_minor__c = Order1.Id;
-			Orderdet6.Consumable_Product__c = pro1.Id;
-			Orderdet6.Asset_Model_No__c = 'Test01';
-			Orderdet6.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet4.IsArrival__c = true;
-			Orderdet6.Consumable_Shipment_order__c = Order1.Id;
-			Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet6.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR4';
-			Orderdet6.Send_Date__c =  Date.today();
-			Orderdet6.Return_date__c= null;
-			Orderdet6.Box_Piece__c = '鐩�';
-			Orderdet6.Rrturn_count__c =1;
-			Orderdet6.TracingCode__c = '20170808';
+      insert new List<Consumable_order_details2__c>{
+        Orderdet1,
+        Orderdet2,
+        Orderdet3,
+        Orderdet4,
+        Orderdet5,
+        Orderdet6,
+        Orderdet7,
+        Orderdet8,
+        Orderdet9,
+        lose,
+        lose1,
+        lose2
+      };
+      PageReference page = new PageReference(
+        '/apex/ArriveGoods?Esetid=' + Order1.Id
+      );
+      System.Test.setCurrentPage(page);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
 
-			// 鍗曚綅涓轰釜鐨凚arcode瀵瑰簲鐨勫嚭搴撳崟
-			Consumable_order_details2__c Orderdet7 = new Consumable_order_details2__c();
-			Orderdet7.Name = 'OCM_01_001004';
-			Orderdet7.Consumable_order_minor__c = Order1.Id;
-			Orderdet7.Consumable_Product__c = pro1.Id;
-			Orderdet7.Asset_Model_No__c = 'Test01';
-			Orderdet7.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet4.IsArrival__c = true;
-			Orderdet7.Consumable_Shipment_order__c = Order1.Id;
-			Orderdet7.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet7.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR1';
-			Orderdet7.Send_Date__c =  Date.today();
-			Orderdet7.Box_Piece__c = '涓�';
-			Orderdet7.Used_date__c =  Date.today();
-			Orderdet7.Return_date__c= null;
-			Orderdet7.RemoveBox_No__c =1;
-			Orderdet7.Consumable_ZS_order__c= Order1.Id;
-			Orderdet7.Rrturn_count__c =1;
-			Orderdet7.TracingCode__c = '20170808';
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJR3\n01049531702003111115120017181000105ZK250BXJ13\n01049531702003111115120017181000105ZK250BXJRI\n01049531702003111115120017181000105ZK250BXJR2\n01049531702003111115120017181000105ZK250BXJR3\n01049531702003111115120017181000105ZK250BXJR4\n01049531702003111115120017181000105ZK250BXJR1\n01049531702003111115120017181000105ZK250BXJR7\n01049531702003111115120017181000105ZK250BXJR9\n01049531702003111115120017181000105ZK250BXJR8\n01049531702003111115120017181000105ZK250BXJR5\n01049531702003111115120017181000105ZK250BXJR6\n01049531702003111115120017181000105ZK250BXJR7\n01049531702003111115120017181000105ZK250BXAAA\n01049531702003111115120017181000105ZK250BXAAB';
+      Controller.SearchPro();
+      // System.assertEquals(1, controller.consumableInventory.size());
 
-			Orderdet7 = new Consumable_order_details2__c();
-			Orderdet7.Name = 'OCM_01_001004';
-			Orderdet7.Consumable_order_minor__c = Order1.Id;
-			Orderdet7.Consumable_Product__c = pro1.Id;
-			Orderdet7.Asset_Model_No__c = 'Test01';
-			Orderdet7.Consumable_Arrived_order__c = Order1.Id;
-			Orderdet7.Consumable_Shipment_order__c = Order1.Id;
-			Orderdet7.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet7.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR7';
-			Orderdet7.Send_Date__c =  Date.today();
-			Orderdet7.Box_Piece__c = '涓�';
-			Orderdet7.Used_date__c =  Date.today();
-			Orderdet7.Return_date__c= null;
-			Orderdet7.RemoveBox_No__c =1;
-			Orderdet7.Consumable_ZS_order__c= Order1.Id;
-			Orderdet7.Rrturn_count__c =0;
-			Orderdet7.TracingCode__c = '20170808';
+      System.Test.stopTest();
+    }
+  }
 
-			Consumable_order_details2__c Orderdet8 = new Consumable_order_details2__c();
-			Orderdet8.Name = 'OCM_01_001004';
-			Orderdet8.Consumable_order_minor__c = Order1.Id;
-			Orderdet8.Consumable_Product__c = pro1.Id;
-			Orderdet8.Asset_Model_No__c = 'Test01';
-			Orderdet8.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet4.IsArrival__c = true;
-			Orderdet8.Consumable_Shipment_order__c = Order1.Id;
-			Orderdet8.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet8.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR9';
-			Orderdet8.Send_Date__c =  Date.today();
-			Orderdet8.Box_Piece__c = '涓�';
-			Orderdet8.Used_date__c =  Date.today();
-			Orderdet8.Return_date__c= null;
-			Orderdet8.RemoveBox_No__c =1;
-			Orderdet8.Consumable_ZS_order__c= Order1.Id;
-			Orderdet8.Rrturn_count__c =null;
-			Orderdet8.RemoveBox_date__c =  Date.today();
-			Orderdet8.Intra_Trade_List_RMB__c = 1;
-			Orderdet8.Sterilization_limit__c =   Date.today();
-			Orderdet8.SerialLotNo__c ='11鎵规';
-			Orderdet8.TracingCode__c = '20170808';
-			Orderdet8.Arrive_date__c =  Date.today();
+  //杩斿搧 鏄庣粏2涓嶅瓨鍦ㄧ殑瀵瑰簲鐨勫埌璐ц鍗曟槑缁�
+  @isTest
+  static void productReturn_oldbarcode() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-			Consumable_order_details2__c Orderdet9 = new Consumable_order_details2__c();
-			Orderdet9.Name = 'OCM_01_001004';
-			Orderdet9.Consumable_order_minor__c = Order1.Id;
-			Orderdet9.Consumable_Product__c = pro1.Id;
-			Orderdet9.Asset_Model_No__c = 'Test01';
-			Orderdet9.Consumable_Arrived_order__c = Order1.Id;
-			Orderdet9.Consumable_Shipment_order__c = Order1.Id;
-			Orderdet9.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet9.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR8';
-			Orderdet9.Send_Date__c =  Date.today();
-			Orderdet9.Box_Piece__c = '涓�';
-			Orderdet9.Used_date__c =  Date.today();
-			Orderdet9.Return_date__c= null;
-			Orderdet9.Consumable_ZS_order__c= Order1.Id;
-			Orderdet9.Arrive_date__c =  Date.today();
-			Orderdet9.Rrturn_count__c =10;
-			Orderdet9.TracingCode__c = '20170808';
-			Consumable_order_details2__c lose = new Consumable_order_details2__c();
-			lose.Name = 'OCM_01_001004';
-			lose.Consumable_order_minor__c = Order1.Id;
-			lose.Consumable_Product__c = pro1.Id;
-			lose.Asset_Model_No__c = 'Test01';
-			lose.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet4.IsArrival__c = true;
-			lose.Consumable_Shipment_order__c = Order1.Id;
-			lose.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			lose.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR5';
-			lose.Send_Date__c =  null;
-			lose.Arrive_date__c =  null;
-			lose.Used_date__c =  null;
-			lose.Box_Piece__c = '鐩�';
-			lose.TracingCode__c = '20170808';
-			Consumable_order_details2__c lose1 = new Consumable_order_details2__c();
-			lose1.Name = 'OCM_01_001004';
-			lose1.Consumable_order_minor__c = Order1.Id;
-			lose1.Consumable_Product__c = pro1.Id;
-			lose1.Asset_Model_No__c = 'Test01';
-			lose1.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet4.IsArrival__c = true;
-			lose1.Consumable_Shipment_order__c = Order1.Id;
-			lose1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			lose1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR6';
-			lose1.Send_Date__c =  null;
-			lose1.Arrive_date__c =   Date.today();
-			lose1.Used_date__c =  null;
-			lose1.Box_Piece__c = '鐩�';
-			lose1.TracingCode__c = '20170808';
-			Consumable_order_details2__c lose2 = new Consumable_order_details2__c();
-			lose2.Name = 'OCM_01_001004';
-			lose2.Consumable_order_minor__c = Order2.Id;
-			lose2.Consumable_Product__c = pro1.Id;
-			lose2.Asset_Model_No__c = 'Test01';
-			lose2.Consumable_Arrived_order__c = Order2.Id;
-			//Orderdet4.IsArrival__c = true;
-			lose2.Consumable_Shipment_order__c = Order2.Id;
-			lose2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			lose2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJR7';
-			lose2.Send_Date__c =  null;
-			lose2.Arrive_date__c =   Date.today();
-			lose2.Used_date__c =  null;
-			lose2.Box_Piece__c = '鐩�';
-			lose2.Intra_Trade_List_RMB__c = 1;
-			lose2.Direct_Arrive_Product__c = true;
-			lose2.Sterilization_limit__c =   Date.today();
-			lose2.SerialLotNo__c ='11鎵规';
-			lose2.TracingCode__c = '20170808';
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
-			//List<Product2> proList = [select name,Estimation_Entry_Possibility__c from Product2 where id = :prod01.Id];
-			//System.assertEquals('鈼�', proList[0].Estimation_Entry_Possibility__c);
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
 
-			insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2,Orderdet3,Orderdet4,Orderdet5,Orderdet6,Orderdet7,Orderdet8,Orderdet9,lose,lose1,lose2};
-			PageReference page = new PageReference('/apex/ArriveGoods?Esetid=' + Order1.Id);
-			System.Test.setCurrentPage(page);
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			//鍒濆鍖栨祴璇�
-			System.Test.startTest();
-			Controller.init();
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'Test001',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = 'Test002',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      //璁㈠崟
 
-			Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJR3\n01049531702003111115120017181000105ZK250BXJ13\n01049531702003111115120017181000105ZK250BXJRI\n01049531702003111115120017181000105ZK250BXJR2\n01049531702003111115120017181000105ZK250BXJR3\n01049531702003111115120017181000105ZK250BXJR4\n01049531702003111115120017181000105ZK250BXJR1\n01049531702003111115120017181000105ZK250BXJR7\n01049531702003111115120017181000105ZK250BXJR9\n01049531702003111115120017181000105ZK250BXJR8\n01049531702003111115120017181000105ZK250BXJR5\n01049531702003111115120017181000105ZK250BXJR6\n01049531702003111115120017181000105ZK250BXJR7\n01049531702003111115120017181000105ZK250BXAAA\n01049531702003111115120017181000105ZK250BXAAB';
-			Controller.SearchPro();
-			// System.assertEquals(1, controller.consumableInventory.size());
+      Consumable_order__c Order1 = new Consumable_order__c();
+      Order1.Name = 'OCM_01_001';
+      Order1.Order_status__c = '鎵瑰噯';
+      Order1.Order_type__c = '璁㈠崟';
+      Order1.Dealer_Info__c = myAccount1.id;
+      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
 
-			System.Test.stopTest();
-		}
-	}
+      //杩斿搧璁㈠崟
 
+      Consumable_order__c Order2 = new Consumable_order__c();
+      Order2.Name = 'OCM_01_002';
+      Order2.Order_status__c = '鎵瑰噯';
+      Order2.Order_type__c = '杩斿搧';
+      Order2.Dealer_Info__c = myAccount1.id;
+      Order2.RecordTypeid = System.Label.Dealer_Returned_Label;
+      insert Order1;
+      insert Order2;
 
-	//杩斿搧 鏄庣粏2涓嶅瓨鍦ㄧ殑瀵瑰簲鐨勫埌璐ц鍗曟槑缁�
-	@isTest(SeeAllData=true)
-	static  void productReturn_oldbarcode() {
-		// // TO DO: implement unit test
-		// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		// if (rectCo.size() == 0) {
-		// 	return;
-		// }
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+      //璁㈠崟鏄庣粏
+      //fahuo
+      Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      Orderdet.Name = 'OCM_01_00101';
+      Orderdet.Consumable_order__c = Order1.Id;
+      Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      Orderdet.Consumable_Product__c = pro1.Id;
+      Orderdet.Consumable_count__c = 4;
+      insert Orderdet;
 
+      //鍙戣揣鏄庣粏
+      //娌″嚭搴擄紝娌¢攢鍞紝灏辨槸鍦ㄥ簱
+      Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      Orderdet1.Name = 'OCM_01_001001';
+      Orderdet1.Consumable_order_minor__c = Order1.Id;
+      Orderdet1.Consumable_Product__c = pro1.Id;
+      Orderdet1.Asset_Model_No__c = 'Pro001';
+      Orderdet1.Arrive_date__c = date.today();
+      Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+      Orderdet1.TracingCode__c = 'BXSYS';
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+      //daohuo
+      Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+      Orderdet2.Name = 'OCM_01_001002';
+      Orderdet2.Consumable_order_minor__c = Order1.Id;
+      Orderdet2.Consumable_Product__c = pro1.Id;
+      Orderdet2.Asset_Model_No__c = 'Pro001';
+      Orderdet2.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet2.Arrive_date__c = date.today();
+      Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRI';
+      Orderdet2.TracingCode__c = 'BXSYS';
+      //sale
+      Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+      Orderdet3.Name = 'OCM_01_001003';
+      Orderdet3.Consumable_order_minor__c = Order1.Id;
+      Orderdet3.Consumable_Product__c = pro1.Id;
+      Orderdet3.Asset_Model_No__c = 'Pro001';
+      Orderdet3.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet3.Arrive_date__c = date.today();
+      Orderdet3.Used_date__c = date.today();
+      Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRJ';
+      Orderdet3.TracingCode__c = 'BXSYS';
+      //鍑哄簱
+      Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+      Orderdet4.Name = 'OCM_01_001004';
+      Orderdet4.Consumable_order_minor__c = Order1.Id;
+      Orderdet4.Consumable_Product__c = pro1.Id;
+      Orderdet4.Asset_Model_No__c = 'Pro001';
+      Orderdet4.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet4.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet4.Send_Date__c = date.today();
+      Orderdet4.Arrive_date__c = date.today();
+      Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BX222';
+      Orderdet4.TracingCode__c = 'BXSYS';
+      //quxiao
+      Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+      Orderdet5.Name = 'OCM_01_001005';
+      Orderdet5.Consumable_order_minor__c = Order1.Id;
+      Orderdet5.Consumable_Product__c = pro1.Id;
+      Orderdet5.Asset_Model_No__c = 'Pro001';
+      Orderdet5.Cancellation_Date__c = Date.today();
+      Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRZ';
+      Orderdet5.Box_Piece__c = '涓�';
+      Orderdet5.TracingCode__c = 'BXSYS';
+      //fanpin
+      Consumable_order_details2__c Orderdet6 = new Consumable_order_details2__c();
+      Orderdet6.Name = 'OCM_01_001006';
+      Orderdet6.Consumable_order_minor__c = Order1.Id;
+      Orderdet6.Consumable_Product__c = pro1.Id;
+      Orderdet6.Asset_Model_No__c = 'Pro001';
+      Orderdet6.Consumable_Return_order__c = Order2.Id;
+      Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet6.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
+      Orderdet6.Box_Piece__c = '涓�';
+      Orderdet6.TracingCode__c = 'BXSYS';
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
+      //鍙戣揣鏄庣粏
+      //娌″嚭搴擄紝娌¢攢鍞紝灏辨槸鍦ㄥ簱
+      Consumable_order_details2__c Orderdet7 = new Consumable_order_details2__c();
+      Orderdet7.Name = 'OCM_01_001001';
+      Orderdet7.Consumable_order_minor__c = Order1.Id;
+      Orderdet7.Consumable_Product__c = pro1.Id;
+      Orderdet7.Asset_Model_No__c = 'Pro001';
+      Orderdet7.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet7.Bar_Code__c = '01049531702003111115120017181000105ZK250BX333';
+      Orderdet7.TracingCode__c = 'BXSYS';
 
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
+      insert new List<Consumable_order_details2__c>{
+        Orderdet1,
+        Orderdet2,
+        Orderdet3,
+        Orderdet4,
+        Orderdet5,
+        Orderdet6,
+        Orderdet7
+      };
+      PageReference page = new PageReference('/apex/ArriveGoods?ArrType=ReG');
+      System.Test.setCurrentPage(page);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      //鎺掑簭
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXAAA\n01049531702003111115120017181000105ZK250BXJRJ\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BX123\n01049531702003111115120017181000105ZK250BX222';
+      Controller.SearchPro();
+      //System.assertEquals(1, controller.ShowGoodsofReturnList.size());
+      //System.assertEquals('OCM_01_001003', controller.ShowGoodsofReturnList[0].esd.Name);
+      //System.assertEquals('OCM_01_001004', controller.ShowGoodsofReturnList[1].esd.Name);
+      //System.assertEquals('Test01', controller.ConsumableorderdetailsRecordserror[0].Prod.Name__c);
+      //System.assertEquals('Test01', controller.ConsumableorderdetailsRecordserror[1].Prod.Name__c);
+      //System.assertEquals('OCM_01_001002', controller.ConsumableorderdetailsRecordserror[2].esd.Name);
+      //System.assertEquals('OCM_02_001001', controller.ConsumableorderdetailsRecordserror[3].esd.Name);
+      // Controller.GoodsReturnCheck();
+      Controller.ArriveGoodsConfim();
+      //System.assertEquals(1, controller.ShowGoodsofReturnList.size());
+      Controller.UpdateGoodsOfReturn();
 
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
-			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
-			insert new Product2__c[] {pro1, pro2};
-			//璁㈠崟
+      controller.getinventorysize();
+      System.Test.stopTest();
+    }
+  }
+  @isTest
+  static void barcodecheck() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-			Consumable_order__c Order1 = new Consumable_order__c();
-			Order1.Name = 'OCM_01_001';
-			Order1.Order_status__c = '鎵瑰噯';
-			Order1.Order_type__c = '璁㈠崟';
-			Order1.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
-			//杩斿搧璁㈠崟
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = '2344',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = '8232',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      //鍒濆鍖栨祴璇�
+      list<String> list1 = new List<String>();
+      list1.clear();
+      list1.add(Controller.barcode = '2413456250BBBBA');
+      Controller.inventoryEntry(list1);
 
-			Consumable_order__c Order2 = new Consumable_order__c();
-			Order2.Name = 'OCM_01_002';
-			Order2.Order_status__c = '鎵瑰噯';
-			Order2.Order_type__c = '杩斿搧';
-			Order2.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order2.RecordTypeid = System.Label.Dealer_Returned_Label;
-			insert Order1;
-			insert Order2;
+      list1.clear();
+      list1.add(Controller.barcode = '241250BBBBZ');
+      Controller.inventoryEntry(list1);
 
-			//璁㈠崟鏄庣粏
-			//fahuo
-			Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
-			Orderdet.Name = 'OCM_01_00101';
-			Orderdet.Consumable_order__c = Order1.Id;
-			Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
-			Orderdet.Consumable_Product__c = pro1.Id;
-			Orderdet.Consumable_count__c = 4;
-			insert Orderdet;
+      list1.clear();
+      list1.add(Controller.barcode = '241250');
+      Controller.inventoryEntry(list1);
 
-			//鍙戣揣鏄庣粏
-			//娌″嚭搴擄紝娌¢攢鍞紝灏辨槸鍦ㄥ簱
-			Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
-			Orderdet1.Name = 'OCM_01_001001';
-			Orderdet1.Consumable_order_minor__c = Order1.Id;
-			Orderdet1.Consumable_Product__c = pro1.Id;
-			Orderdet1.Asset_Model_No__c = 'Pro001';
-			Orderdet1.Arrive_date__c = date.today();
-			Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
-			Orderdet1.TracingCode__c = 'BXSYS';
+      list1.clear();
+      list1.add(Controller.barcode = '241250BBB');
+      Controller.inventoryEntry(list1);
 
-			//daohuo
-			Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
-			Orderdet2.Name = 'OCM_01_001002';
-			Orderdet2.Consumable_order_minor__c = Order1.Id;
-			Orderdet2.Consumable_Product__c = pro1.Id;
-			Orderdet2.Asset_Model_No__c = 'Pro001';
-			Orderdet2.Consumable_Arrived_order__c = Order1.Id;
-			Orderdet2.Arrive_date__c = date.today();
-			Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRI';
-			Orderdet2.TracingCode__c = 'BXSYS';
-			//sale
-			Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
-			Orderdet3.Name = 'OCM_01_001003';
-			Orderdet3.Consumable_order_minor__c = Order1.Id;
-			Orderdet3.Consumable_Product__c = pro1.Id;
-			Orderdet3.Asset_Model_No__c = 'Pro001';
-			Orderdet3.Consumable_Arrived_order__c = Order1.Id;
-			Orderdet3.Arrive_date__c = date.today();
-			Orderdet3.Used_date__c = date.today();
-			Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRJ';
-			Orderdet3.TracingCode__c = 'BXSYS';
-			//鍑哄簱
-			Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
-			Orderdet4.Name = 'OCM_01_001004';
-			Orderdet4.Consumable_order_minor__c = Order1.Id;
-			Orderdet4.Consumable_Product__c = pro1.Id;
-			Orderdet4.Asset_Model_No__c = 'Pro001';
-			Orderdet4.Consumable_Arrived_order__c = Order1.Id;
-			Orderdet4.Consumable_Shipment_order__c = Order1.Id;
-			Orderdet4.Send_Date__c = date.today();
-			Orderdet4.Arrive_date__c = date.today();
-			Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BX222';
-			Orderdet4.TracingCode__c = 'BXSYS';
-			//quxiao
-			Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
-			Orderdet5.Name = 'OCM_01_001005';
-			Orderdet5.Consumable_order_minor__c = Order1.Id;
-			Orderdet5.Consumable_Product__c = pro1.Id;
-			Orderdet5.Asset_Model_No__c = 'Pro001';
-			Orderdet5.Cancellation_Date__c = Date.today();
-			Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRZ';
-			Orderdet5.Box_Piece__c ='涓�';
-			Orderdet5.TracingCode__c = 'BXSYS';
-			//fanpin
-			Consumable_order_details2__c Orderdet6 = new Consumable_order_details2__c();
-			Orderdet6.Name = 'OCM_01_001006';
-			Orderdet6.Consumable_order_minor__c = Order1.Id;
-			Orderdet6.Consumable_Product__c = pro1.Id;
-			Orderdet6.Asset_Model_No__c = 'Pro001';
-			Orderdet6.Consumable_Return_order__c = Order2.Id;
-			Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet6.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
-			Orderdet6.Box_Piece__c ='涓�';
-			Orderdet6.TracingCode__c = 'BXSYS';
+      list1.clear();
+      list1.add(Controller.barcode = '24134567250BBBBB');
+      Controller.inventoryEntry(list1);
 
-			//鍙戣揣鏄庣粏
-			//娌″嚭搴擄紝娌¢攢鍞紝灏辨槸鍦ㄥ簱
-			Consumable_order_details2__c Orderdet7 = new Consumable_order_details2__c();
-			Orderdet7.Name = 'OCM_01_001001';
-			Orderdet7.Consumable_order_minor__c = Order1.Id;
-			Orderdet7.Consumable_Product__c = pro1.Id;
-			Orderdet7.Asset_Model_No__c = 'Pro001';
-			Orderdet7.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet7.Bar_Code__c = '01049531702003111115120017181000105ZK250BX333';
-			Orderdet7.TracingCode__c = 'BXSYS';
+      list1.clear();
+      list1.add(Controller.barcode = '241345678250BBBBC');
+      Controller.inventoryEntry(list1);
 
-			insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2,Orderdet3,Orderdet4,Orderdet5,Orderdet6,Orderdet7};
-			PageReference page = new PageReference('/apex/ArriveGoods?ArrType=ReG');
-			System.Test.setCurrentPage(page);
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			//鍒濆鍖栨祴璇�
-			System.Test.startTest();
-			Controller.init();
-			//鎺掑簭
-			Controller.barcode = '01049531702003111115120017181000105ZK250BXAAA\n01049531702003111115120017181000105ZK250BXJRJ\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BX123\n01049531702003111115120017181000105ZK250BX222';
-			Controller.SearchPro();
-			//System.assertEquals(1, controller.ShowGoodsofReturnList.size());
-			//System.assertEquals('OCM_01_001003', controller.ShowGoodsofReturnList[0].esd.Name);
-			//System.assertEquals('OCM_01_001004', controller.ShowGoodsofReturnList[1].esd.Name);
-			//System.assertEquals('Test01', controller.ConsumableorderdetailsRecordserror[0].Prod.Name__c);
-			//System.assertEquals('Test01', controller.ConsumableorderdetailsRecordserror[1].Prod.Name__c);
-			//System.assertEquals('OCM_01_001002', controller.ConsumableorderdetailsRecordserror[2].esd.Name);
-			//System.assertEquals('OCM_02_001001', controller.ConsumableorderdetailsRecordserror[3].esd.Name);
-			Controller.GoodsReturnCheck();
-			Controller.ArriveGoodsConfim();
-			//System.assertEquals(1, controller.ShowGoodsofReturnList.size());
-			Controller.UpdateGoodsOfReturn();
+      list1.clear();
+      list1.add(Controller.barcode = '2413456789250BBBBD');
+      Controller.inventoryEntry(list1);
 
-			controller.getinventorysize();
-			System.Test.stopTest();
+      list1.clear();
+      list1.add(Controller.barcode = '24134567890250BBBBE');
+      Controller.inventoryEntry(list1);
 
-		}
-	}
-	@isTest(SeeAllData=true)
-	static  void barcodecheck() {
-		// // TO DO: implement unit test
-		// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		// if (rectCo.size() == 0) {
-		// 	return;
-		// }
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+      list1.clear();
+      list1.add(Controller.barcode = '241345678901250BBBBF');
+      Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '2413456789011250BBBBG');
+      Controller.inventoryEntry(list1);
 
+      list1.clear();
+      list1.add(Controller.barcode = '24134567890111250BBBBH');
+      Controller.inventoryEntry(list1);
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+      list1.clear();
+      list1.add(Controller.barcode = '0112345678901231712300123250BBBBI');
+      Controller.inventoryEntry(list1);
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
+      list1.clear();
+      list1.add(Controller.barcode = '011234567890250BBBBJ');
+      Controller.inventoryEntry(list1);
 
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
+      list1.clear();
+      list1.add(Controller.barcode = '01123456789A0123456250BBBBK');
+      Controller.inventoryEntry(list1);
 
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='2344',Product2__c = prod01.Id);
-			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='8232',Product2__c = prod02.Id);
-			insert new Product2__c[] {pro1, pro2};
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			//鍒濆鍖栨祴璇�
-			list<String> list1 = new list<String>();
-			list1.clear();
-			list1.add(Controller.barcode = '2413456250BBBBA');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '011234567890123411AAAA123250BBBBL');
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '241250BBBBZ');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '011234567890123411789012175678901234250BBBBM'
+      );
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '241250');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '01123456789012340138901217aaa8001234250BBBBN'
+      );
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '241250BBB');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '011234567890123456789012104567890250BBBBO'
+      );
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '24134567250BBBBB');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '01123456789012341778910034567890250BBBBP'
+      );
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '241345678250BBBBC');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '011234567890123417aa910034567890250BBBBQ'
+      );
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '2413456789250BBBBD');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '01123456789012341778911134567890250BBBBR'
+      );
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '24134567890250BBBBE');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '011234567890123417789121105678900000250BBBBS'
+      );
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '241345678901250BBBBF');
-			Controller.inventoryEntry(list1);
-			list1.clear();
-			list1.add(Controller.barcode = '2413456789011250BBBBG');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '011234567890123410789121105678900000250BBBBT'
+      );
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '24134567890111250BBBBH');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '011234567890123411789012171a780012250BBBBU'
+      );
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '0112345678901231712300123250BBBBI');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '0112345678901234110890121012789000250BBBBV'
+      );
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '011234567890250BBBBJ');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '011234567890123417120506105678901234250BBBBW'
+      );
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '01123456789A0123456250BBBBK');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '0112345678901234111202121712050212250BBBBX'
+      );
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '011234567890123411AAAA123250BBBBL');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '0112345678901234111202121712a50212250BBBBY'
+      );
+      Controller.inventoryEntry(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '011234567890123411789012175678901234250BBBBM');
-			Controller.inventoryEntry(list1);
-
-			list1.clear();
-			list1.add(Controller.barcode = '01123456789012340138901217aaa8001234250BBBBN');
-			Controller.inventoryEntry(list1);
-
-			list1.clear();
-			list1.add(Controller.barcode = '011234567890123456789012104567890250BBBBO');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '0112345678901234111202121012050212250BBBBZ'
+      );
+      Controller.inventoryEntry(list1);
+    }
+  }
+  @isTest
+  static void barcodechkeck_2() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-			list1.clear();
-			list1.add(Controller.barcode = '01123456789012341778910034567890250BBBBP');
-			Controller.inventoryEntry(list1);
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
-			list1.clear();
-			list1.add(Controller.barcode = '011234567890123417aa910034567890250BBBBQ');
-			Controller.inventoryEntry(list1);
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = '2344',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = '82324',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      //浜у搧娉ㄥ唽璇�
+      Product_Register__c prc = new Product_Register__c(
+        Name = '鍥芥娉ㄨ繘20162220210',
+        MedPrdClass__c = '3',
+        ValidFrom__c = date.newinstance(2018, 7, 22),
+        ValidTo__c = date.newinstance(2028, 7, 22),
+        RegisterNoClass_Old__c = '6815',
+        RegisterNoClass_New__c = '6815',
+        RegisterNoStatus__c = '鏈夋晥'
+      );
+      insert prc;
+      //鏂版棫鍏崇郴瀵圭収琛�
+      //Product_Register_contrast__c prcc = new Product_Register_contrast__c(
+      //                                        Name = 'Test20181204',
+      //                                        Register_new__c = '314',
+      //                                        Register_old__c = '36815'
+      //                                        );
+      //insert prcc;
+      //浜у搧-浜у搧娉ㄥ唽璇佸叧绯�  prod01
+      Product_Register_Link__c prlc = new Product_Register_Link__c(
+        Product2__c = prod01.Id,
+        Product_Register__c = prc.Id
+      );
+      insert prlc;
+      //浜у搧-浜у搧娉ㄥ唽璇佸叧绯�  prod02
+      Product_Register_Link__c prlc2 = new Product_Register_Link__c(
+        Product2__c = prod02.Id,
+        Product_Register__c = prc.Id
+      );
+      insert prlc2;
+      PageReference page = new PageReference('/apex/ArriveGoods?ArrType=ReG');
+      System.Test.setCurrentPage(page);
 
-			list1.clear();
-			list1.add(Controller.barcode = '01123456789012341778911134567890250BBBBR');
-			Controller.inventoryEntry(list1);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      //List<Product2> proList = [select name,Estimation_Entry_Possibility__c from Product2 where id = :prod01.Id];
+      //System.assertEquals('鈼�', proList[0].Estimation_Entry_Possibility__c);
+      List<Product2__c> product2InStore = [
+        SELECT
+          Id,
+          Name,
+          Name__c,
+          Intra_Trade_List_RMB__c,
+          Asset_Model_No__c,
+          OT_CODE__c
+        FROM Product2__c
+        WHERE
+          Estimation_Entry_Possibility__c = '鈼�'
+          AND Pro2_Dealer_Object__c = TRUE
+          AND OT_CODE__c = 'test'
+      ];
+      //System.assertEquals(1, product2InStore.size());
+      list<String> list1 = new List<String>();
+      list1.clear();
+      list1.add(Controller.barcode = '2413456250BBBBA');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '011234567890123417789121105678900000250BBBBS');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '241250BBBBZ');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '011234567890123410789121105678900000250BBBBT');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '241250');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '011234567890123411789012171a780012250BBBBU');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '241250BBZ');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '0112345678901234110890121012789000250BBBBV');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '24134567250BBBBB');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '011234567890123417120506105678901234250BBBBW');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '241345678250BBBBC');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '0112345678901234111202121712050212250BBBBX');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '2413452509250BBBBD');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '0112345678901234111202121712a50212250BBBBY');
-			Controller.inventoryEntry(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '24125090111250BBBBE');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '0112345678901234111202121012050212250BBBBZ');
-			Controller.inventoryEntry(list1);
-		}
-	}
-	@isTest(SeeAllData=true)
-	static  void barcodechkeck_2() {
-		// // TO DO: implement unit test
-		// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		// if (rectCo.size() == 0) {
-		// 	return;
-		// }
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+      list1.clear();
+      list1.add(Controller.barcode = '241325090111250BBBBF');
+      Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '2413425090111250BBBBG');
+      Controller.inventoryEntryNoESetId(list1);
 
+      list1.clear();
+      list1.add(Controller.barcode = '24134525090111250BBBBH');
+      Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '241test1712345678901234567890250BBBBI');
+      Controller.inventoryEntryNoESetId(list1);
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+      list1.clear();
+      list1.add(Controller.barcode = '241test171234500678901234567890250BBBBJ');
+      Controller.inventoryEntryNoESetId(list1);
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
+      list1.clear();
+      list1.add(Controller.barcode = '241test17120400678901234567890250BBBBK');
+      Controller.inventoryEntryNoESetId(list1);
 
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
+      list1.clear();
+      list1.add(Controller.barcode = '241test171204110678901234567890250BBBBL');
+      Controller.inventoryEntryNoESetId(list1);
 
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='2344',Product2__c = prod01.Id);
-			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='82324',Product2__c = prod02.Id);
-			insert new Product2__c[] {pro1, pro2};
-			//浜у搧娉ㄥ唽璇�
-			Product_Register__c prc = new Product_Register__c(Name = '鍥芥娉ㄨ繘20162220210',
-			                                                  MedPrdClass__c = '3',
-			                                                  ValidFrom__c = date.newinstance(2018, 07, 22),
-			                                                  ValidTo__c = date.newinstance(2028, 07, 22),
-			                                                  RegisterNoClass_Old__c = '6815',
-			                                                  RegisterNoClass_New__c = '6815',
-			                                                  RegisterNoStatus__c = '鏈夋晥'
-			                                                  );
-			insert prc;
-			//鏂版棫鍏崇郴瀵圭収琛�
-			//Product_Register_contrast__c prcc = new Product_Register_contrast__c(
-			//                                        Name = 'Test20181204',
-			//                                        Register_new__c = '314',
-			//                                        Register_old__c = '36815'
-			//                                        );
-			//insert prcc;
-			//浜у搧-浜у搧娉ㄥ唽璇佸叧绯�  prod01
-			Product_Register_Link__c prlc = new Product_Register_Link__c(
-				Product2__c = prod01.Id,
-				Product_Register__c = prc.Id
-				);
-			insert prlc;
-			//浜у搧-浜у搧娉ㄥ唽璇佸叧绯�  prod02
-			Product_Register_Link__c prlc2 = new Product_Register_Link__c(
-				Product2__c = prod02.Id,
-				Product_Register__c = prc.Id
-				);
-			insert prlc2;
-			PageReference page = new PageReference('/apex/ArriveGoods?ArrType=ReG');
-			System.Test.setCurrentPage(page);
+      list1.clear();
+      list1.add(Controller.barcode = '241test171204121078901234567890250BBBBM');
+      Controller.inventoryEntryNoESetId(list1);
 
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			//List<Product2> proList = [select name,Estimation_Entry_Possibility__c from Product2 where id = :prod01.Id];
-			//System.assertEquals('鈼�', proList[0].Estimation_Entry_Possibility__c);
-			List<Product2__c> product2InStore = [SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,OT_CODE__c
-			                                     FROM Product2__c
-			                                     WHERE Estimation_Entry_Possibility__c = '鈼�'
-			                                                                             AND Pro2_Dealer_Object__c = true
-			                                                                                                         AND OT_CODE__c ='test' ];
-			//System.assertEquals(1, product2InStore.size());
-			list<String> list1 = new list<String>();
-			list1.clear();
-			list1.add(Controller.barcode = '2413456250BBBBA');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '241test17120412250BBBBN');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '241250BBBBZ');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '241test101204121078901234567890250BBBBO');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '241250');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '241test1112a4121078901234567890250BBBBP');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '241250BBZ');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '241test111204121778900034567890250BBBBQ');
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '24134567250BBBBB');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '0111234101204120118901231712a4001234250BBBBR'
+      );
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '241345678250BBBBC');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '011123410120412011890123171204011234250BBBBS'
+      );
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '2413452509250BBBBD');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '011test10120412011890123171a04011234250BBBBT'
+      );
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '24125090111250BBBBE');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(
+        Controller.barcode = '0111234101204120118901231012040112342222250BBBBU'
+      );
+      Controller.inventoryEntryNoESetId(list1);
 
-			list1.clear();
-			list1.add(Controller.barcode = '241325090111250BBBBF');
-			Controller.inventoryEntryNoESetId(list1);
-			list1.clear();
-			list1.add(Controller.barcode = '2413425090111250BBBBG');
-			Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '011123410120412017120100250AAAAA');
+      Controller.inventoryEntryNoESetId(list1);
+    }
+  }
 
-			list1.clear();
-			list1.add(Controller.barcode = '24134525090111250BBBBH');
-			Controller.inventoryEntryNoESetId(list1);
-			list1.clear();
-			list1.add(Controller.barcode = '241test1712345678901234567890250BBBBI');
-			Controller.inventoryEntryNoESetId(list1);
+  //鑷姩鍑哄簱
+  @isTest
+  static void addSaleOrderAuto() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-			list1.clear();
-			list1.add(Controller.barcode = '241test171234500678901234567890250BBBBJ');
-			Controller.inventoryEntryNoESetId(list1);
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
-			list1.clear();
-			list1.add(Controller.barcode = '241test17120400678901234567890250BBBBK');
-			Controller.inventoryEntryNoESetId(list1);
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'Test001',
+        Product2__c = prod01.Id
+      );
+      insert new List<Product2__c>{ pro1 };
+      // Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
+      // insert myAccount1;
+      Consumable_order__c Order2 = new Consumable_order__c();
+      Order2.Name = 'OCM_02_001';
+      Order2.Order_status__c = '鎵瑰噯';
+      Order2.Order_type__c = '璁㈠崟';
+      Order2.Dealer_Info__c = myAccount1.Id;
+      Order2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      insert Order2;
+      //鍙戦敊搴� 宸插埌璐�
+      Consumable_order_details2__c Orderdets8 = new Consumable_order_details2__c();
+      Orderdets8.Name = 'OCM_01_001011';
+      Orderdets8.Consumable_order_minor__c = Order2.Id;
+      Orderdets8.Consumable_Product__c = pro1.Id;
+      Orderdets8.Asset_Model_No__c = 'Test01';
+      Orderdets8.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdets8.Bar_Code__c = '01049531702003111115120017181000105ZK250BXSYS';
+      Orderdets8.Box_Piece__c = '鐩�';
+      Orderdets8.Arrive_date__c = Date.today();
+      Orderdets8.TracingCode__c = 'BXSYS';
+      Orderdets8.SerialLotNo__c = '5ZK';
+      insert Orderdets8;
 
-			list1.clear();
-			list1.add(Controller.barcode = '241test171204110678901234567890250BBBBL');
-			Controller.inventoryEntryNoESetId(list1);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      PageReference page = new PageReference('/apex/ArriveGoods?ArrType=Arr');
+      System.Test.setCurrentPage(page);
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      //鎺掑簭
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXSYS';
+      Controller.SearchPro();
+      // System.assertEquals(1, controller.consumableInventory.size());
+      Controller.ArriveGoodsConfim();
+      System.Test.stopTest();
+    }
+  }
 
-			list1.clear();
-			list1.add(Controller.barcode = '241test171204121078901234567890250BBBBM');
-			Controller.inventoryEntryNoESetId(list1);
+  // UPDATE TCM TEST1
+  @isTest
+  static void methodTest1() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-			list1.clear();
-			list1.add(Controller.barcode = '241test17120412250BBBBN');
-			Controller.inventoryEntryNoESetId(list1);
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
-			list1.clear();
-			list1.add(Controller.barcode = '241test101204121078901234567890250BBBBO');
-			Controller.inventoryEntryNoESetId(list1);
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'N3047730',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = 'N3047731',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      //璁㈠崟
 
-			list1.clear();
-			list1.add(Controller.barcode = '241test1112a4121078901234567890250BBBBP');
-			Controller.inventoryEntryNoESetId(list1);
+      Consumable_order__c Order1 = new Consumable_order__c();
+      Order1.Name = 'OCM_01_001';
+      Order1.Order_status__c = '鎵瑰噯';
+      Order1.Order_type__c = '璁㈠崟';
+      Order1.Dealer_Info__c = myAccount1.id;
+      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      Order1.Order_ProType__c = 'ET';
+      insert Order1;
 
-			list1.clear();
-			list1.add(Controller.barcode = '241test111204121778900034567890250BBBBQ');
-			Controller.inventoryEntryNoESetId(list1);
+      //璁㈠崟鏄庣粏
+      //fahuo
+      Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      Orderdet.Name = 'OCM_01_00101';
+      Orderdet.Consumable_order__c = Order1.Id;
+      Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      Orderdet.Consumable_Product__c = pro1.Id;
+      Orderdet.Consumable_count__c = 4;
+      insert Orderdet;
 
+      //鍙戣揣鏄庣粏
+      //fahuo
+      Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      Orderdet1.Name = 'OCM_01_001001';
+      Orderdet1.Consumable_order_minor__c = Order1.Id;
+      Orderdet1.Consumable_Product__c = pro1.Id;
+      Orderdet1.Asset_Model_No__c = 'Test01';
+      Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+      Orderdet1.Arrive_date__c = Date.today();
+      // Orderdet1.Send_Date__c=Date.today();
+      // Orderdet1.Used_date__c=Date.today();
+      Orderdet1.TracingCode__c = 'BXJRF';
+      Orderdet1.SerialLotNo__c = '5ZK';
+      insert Orderdet1;
 
-			list1.clear();
-			list1.add(Controller.barcode = '0111234101204120118901231712a4001234250BBBBR');
-			Controller.inventoryEntryNoESetId(list1);
+      //fahuo
+      Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+      Orderdet2.Name = 'OCM_01_001001';
+      Orderdet2.Consumable_order_minor__c = Order1.Id;
+      Orderdet2.Consumable_Product__c = pro1.Id;
+      Orderdet2.Asset_Model_No__c = 'Test01';
+      Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet2.Bar_Code__c = '01049531702003111115120017181234105ZK250BXJRF';
+      Orderdet2.Arrive_date__c = Date.today();
+      Orderdet2.TracingCode__c = 'BXJRF';
+      Orderdet2.SerialLotNo__c = '5ZK';
+      insert Orderdet2;
 
-			list1.clear();
-			list1.add(Controller.barcode = '011123410120412011890123171204011234250BBBBS');
-			Controller.inventoryEntryNoESetId(list1);
+      PageReference page = new PageReference(
+        '/apex/ArriveGoods?ESetid=' + Order1.Id
+      );
+      System.Test.setCurrentPage(page);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF';
+      Controller.SearchPro();
+      // System.assertEquals(1, Controller.ConsumableorderdetailsRecords.size());
+      // System.assertEquals(2, Controller.consumableInventory.size());
+      Controller.ArriveGoodsConfim();
+      List<Consumable_order_details2__c> ins = [
+        SELECT Id, Name
+        FROM Consumable_order_details2__c
+      ];
+      // System.assertEquals(3, ins.size());
+      System.Test.stopTest();
+    }
+  }
 
-			list1.clear();
-			list1.add(Controller.barcode = '011test10120412011890123171a04011234250BBBBT');
-			Controller.inventoryEntryNoESetId(list1);
+  //杩斿搧
+  @isTest
+  static void methodTest2() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-			list1.clear();
-			list1.add(Controller.barcode = '0111234101204120118901231012040112342222250BBBBU');
-			Controller.inventoryEntryNoESetId(list1);
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
-			list1.clear();
-			list1.add(Controller.barcode = '011123410120412017120100250AAAAA');
-			Controller.inventoryEntryNoESetId(list1);
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'Test001',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = 'Test002',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      //璁㈠崟
+      Consumable_order__c Order1 = new Consumable_order__c();
+      Order1.Name = 'OCM_01_001';
+      Order1.Order_status__c = '鎵瑰噯';
+      Order1.Order_type__c = '璁㈠崟';
+      Order1.Dealer_Info__c = myAccount1.id;
+      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      Order1.Order_ProType__c = 'ET';
+      insert Order1;
+      //Consumable_order__c coc = [select Dealer_Info__r.name from Consumable_order__c where Id =:Order1.Id];
+      //system.assertEquals('qeee',coc.Dealer_Info__r.name);
 
-		}
-	}
+      //璁㈠崟鏄庣粏
+      //fahuo
+      Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      Orderdet.Name = 'OCM_01_001001';
+      Orderdet.Consumable_order__c = Order1.Id;
+      Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      Orderdet.Consumable_Product__c = pro1.Id;
+      Orderdet.Consumable_count__c = 4;
+      insert Orderdet;
 
-	//鑷姩鍑哄簱
-	@isTest(SeeAllData=true)
-	static  void addSaleOrderAuto() {
-		// // TO DO: implement unit test
-		List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		if (rectCo.size() == 0) {
-			return;
-		}
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+      //鍙戣揣鏄庣粏
+      //fahuo
+      Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      Orderdet1.Name = 'OCM_01_001001';
+      Orderdet1.Consumable_order_minor__c = Order1.Id;
+      Orderdet1.Consumable_Product__c = pro1.Id;
+      Orderdet1.Asset_Model_No__c = 'Pro001';
+      Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet1.Box_Piece__c = '鐩�';
+      Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+      //daohuo
+      Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+      Orderdet2.Name = 'OCM_01_001002';
+      Orderdet2.Consumable_order_minor__c = Order1.Id;
+      Orderdet2.Consumable_Product__c = pro1.Id;
+      Orderdet2.Asset_Model_No__c = 'Pro001';
+      Orderdet2.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet2.IsArrival__c = true;
+      Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet2.Box_Piece__c = '鐩�';
+      Orderdet2.Arrive_date__c = Date.today();
+      //Orderdet2.Send_Date__c = Date.today();
+      //Orderdet2.Used_date__c= Date.today();
+      Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+      //sale
+      Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+      Orderdet3.Name = 'OCM_01_001003';
+      Orderdet3.Consumable_order_minor__c = Order1.Id;
+      Orderdet3.Consumable_Product__c = pro1.Id;
+      Orderdet3.Asset_Model_No__c = 'Pro001';
+      Orderdet3.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet3.IsArrival__c = true;
+      Orderdet3.Consumable_Sale_order__c = Order1.Id;
+      Orderdet3.Box_Piece__c = '鐩�';
+      Orderdet3.Used_date__c = Date.today();
+      Orderdet3.Arrive_date__c = Date.today();
+      Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+      Orderdet3.TracingCode__c = 'BXJRF';
+      Orderdet3.SerialLotNo__c = '5ZK';
+      //鍑哄簱
+      Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+      Orderdet4.Name = 'OCM_01_001004';
+      Orderdet4.Consumable_order_minor__c = Order1.Id;
+      Orderdet4.Consumable_Product__c = pro1.Id;
+      Orderdet4.Asset_Model_No__c = 'Pro001';
+      Orderdet4.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet4.IsArrival__c = true;
+      Orderdet4.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet4.Box_Piece__c = '涓�';
+      Orderdet4.Send_Date__c = Date.today();
+      Orderdet4.Arrive_date__c = Date.today();
+      Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRN';
+      Orderdet4.TracingCode__c = 'BXJRN';
+      Orderdet4.SerialLotNo__c = '5ZK';
+      //quxiao
+      Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+      Orderdet5.Name = 'OCM_01_001005';
+      Orderdet5.Consumable_order_minor__c = Order1.Id;
+      Orderdet5.Consumable_Product__c = pro1.Id;
+      Orderdet5.Asset_Model_No__c = 'Pro001';
+      Orderdet5.Cancellation_Date__c = Date.today();
+      Orderdet5.Cancellation_Flag__c = true;
+      Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRZ';
+      Orderdet5.Box_Piece__c = '涓�';
+      Orderdet5.TracingCode__c = 'BXJRZ';
+      Orderdet5.SerialLotNo__c = '5ZK';
+      insert new List<Consumable_order_details2__c>{
+        Orderdet1,
+        Orderdet3,
+        Orderdet4,
+        Orderdet5
+      };
 
+      PageReference page = new PageReference('/apex/ArriveGoods?ArrType=ReG');
+      System.Test.setCurrentPage(page);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      //鎺掑簭
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRN\n01049531702003111115120017181000105ZK250BXJRZ\n01049531702003111115120017181000105ZK250BXJRR';
+      Controller.SearchPro();
+      System.assertEquals(
+        1,
+        controller.ConsumableorderdetailsRecordserror.size()
+      );
+      // System.assertEquals(2, controller.ShowGoodsofReturnList.size());
+      controller.ShowGoodsofReturnList[0].esd.Return_reason__c = '澶氬彂';
+      // controller.ShowGoodsofReturnList[1].esd.Return_reason__c='澶氬彂';
+      // controller.ShowGoodsofReturnList[0].esd.Rrturn_count__c =1;
+      Controller.UpdateGoodsOfReturn();
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+      list<String> list1 = new List<String>();
+      list1.add(Controller.barcode = '01234567898');
+      Controller.inventoryEntryNoESetId(list1);
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
+      list1.clear();
+      list1.add(Controller.barcode = '012345678901234A67');
+      Controller.inventoryEntryNoESetId(list1);
 
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
+      list1.clear();
+      list1.add(Controller.barcode = '0123456789012345117AA01');
+      Controller.inventoryEntryNoESetId(list1);
 
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
-			insert new Product2__c[] {pro1};
-			Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
-			insert myAccount1;
-			Consumable_order__c Order2 = new Consumable_order__c();
-			Order2.Name = 'OCM_02_001';
-			Order2.Order_status__c = '鎵瑰噯';
-			Order2.Order_type__c = '璁㈠崟';
-			Order2.Dealer_Info__c = myAccount1.Id;
-			Order2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			insert Order2;
-			//鍙戦敊搴� 宸插埌璐�
-			Consumable_order_details2__c Orderdets8 = new Consumable_order_details2__c();
-			Orderdets8.Name = 'OCM_01_001011';
-			Orderdets8.Consumable_order_minor__c = Order2.Id;
-			Orderdets8.Consumable_Product__c = pro1.Id;
-			Orderdets8.Asset_Model_No__c = 'Test01';
-			Orderdets8.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdets8.Bar_Code__c = '01049531702003111115120017181000105ZK250BXSYS';
-			Orderdets8.Box_Piece__c = '鐩�';
-			Orderdets8.Arrive_date__c = Date.today();
-			Orderdets8.TracingCode__c = 'BXSYS';
-			Orderdets8.SerialLotNo__c = '5ZK';
-			insert Orderdets8;
+      list1.clear();
+      list1.add(Controller.barcode = '01234567890123456789012349990001');
+      Controller.inventoryEntryNoESetId(list1);
 
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			PageReference page = new PageReference('/apex/ArriveGoods?ArrType=Arr');
-			System.Test.setCurrentPage(page);
-			//鍒濆鍖栨祴璇�
-			System.Test.startTest();
-			Controller.init();
-			//鎺掑簭
-			Controller.barcode = '01049531702003111115120017181000105ZK250BXSYS';
-			Controller.SearchPro();
-			System.assertEquals(1, controller.consumableInventory.size());
-			Controller.ArriveGoodsConfim();
-			System.Test.stopTest();
-		}
-	}
+      list1.clear();
+      list1.add(Controller.barcode = '0123456789012345177AA0000000000001');
+      Controller.inventoryEntryNoESetId(list1);
 
-	// UPDATE TCM TEST1
-	@isTest(SeeAllData=true)
-	static  void methodTest1() {
-		// // TO DO: implement unit test
-		// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		// if (rectCo.size() == 0) {
-		// 	return;
-		// }
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+      list1.clear();
+      list1.add(Controller.barcode = '0123456789012345177AA1111111111111');
+      Controller.inventoryEntryNoESetId(list1);
 
+      list1.clear();
+      list1.add(Controller.barcode = '241345');
+      Controller.inventoryEntryNoESetId(list1);
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+      list1.clear();
+      list1.add(Controller.barcode = '2413456');
+      Controller.inventoryEntryNoESetId(list1);
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
+      list1.clear();
+      list1.add(Controller.barcode = '24134567');
+      Controller.inventoryEntryNoESetId(list1);
 
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
+      list1.clear();
+      list1.add(Controller.barcode = '241345678');
+      Controller.inventoryEntryNoESetId(list1);
 
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='N3047730',Product2__c = prod01.Id);
-			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='N3047731',Product2__c = prod02.Id);
-			insert new Product2__c[] {pro1, pro2};
-			//璁㈠崟
+      list1.clear();
+      list1.add(Controller.barcode = '2413456789');
+      Controller.inventoryEntryNoESetId(list1);
 
-			Consumable_order__c Order1 = new Consumable_order__c();
-			Order1.Name = 'OCM_01_001';
-			Order1.Order_status__c = '鎵瑰噯';
-			Order1.Order_type__c = '璁㈠崟';
-			Order1.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			Order1.Order_ProType__c = 'ET';
-			insert Order1;
+      list1.clear();
+      list1.add(Controller.barcode = '24134567890');
+      Controller.inventoryEntryNoESetId(list1);
 
-			//璁㈠崟鏄庣粏
-			//fahuo
-			Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
-			Orderdet.Name = 'OCM_01_00101';
-			Orderdet.Consumable_order__c = Order1.Id;
-			Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
-			Orderdet.Consumable_Product__c = pro1.Id;
-			Orderdet.Consumable_count__c = 4;
-			insert Orderdet;
+      list1.clear();
+      list1.add(Controller.barcode = '241345678901');
+      Controller.inventoryEntryNoESetId(list1);
 
-			//鍙戣揣鏄庣粏
-			//fahuo
-			Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
-			Orderdet1.Name = 'OCM_01_001001';
-			Orderdet1.Consumable_order_minor__c = Order1.Id;
-			Orderdet1.Consumable_Product__c = pro1.Id;
-			Orderdet1.Asset_Model_No__c = 'Test01';
-			Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
-			Orderdet1.Arrive_date__c=Date.today();
-			// Orderdet1.Send_Date__c=Date.today();
-			// Orderdet1.Used_date__c=Date.today();
-			Orderdet1.TracingCode__c = 'BXJRF';
-			Orderdet1.SerialLotNo__c = '5ZK';
-			insert Orderdet1;
+      list1.clear();
+      list1.add(Controller.barcode = '0112345678901231177890121215678901234');
+      Controller.inventoryEntryNoESetId(list1);
 
-			//fahuo
-			Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
-			Orderdet2.Name = 'OCM_01_001001';
-			Orderdet2.Consumable_order_minor__c = Order1.Id;
-			Orderdet2.Consumable_Product__c = pro1.Id;
-			Orderdet2.Asset_Model_No__c = 'Test01';
-			Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet2.Bar_Code__c = '01049531702003111115120017181234105ZK250BXJRF';
-			Orderdet2.Arrive_date__c=Date.today();
-			Orderdet2.TracingCode__c = 'BXJRF';
-			Orderdet2.SerialLotNo__c = '5ZK';
-			insert Orderdet2;
+      list1.clear();
+      list1.add(Controller.barcode = '0112345678901231106789012105678901234');
+      Controller.inventoryEntryNoESetId(list1);
+      list1.clear();
+      list1.add(Controller.barcode = '0112345678901231106789012105625001234');
+      Controller.inventoryEntryNoESetId(list1);
+      System.Test.stopTest();
+    }
+  }
 
-			PageReference page = new PageReference('/apex/ArriveGoods?ESetid=' + Order1.Id);
-			System.Test.setCurrentPage(page);
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			//鍒濆鍖栨祴璇�
-			System.Test.startTest();
-			Controller.init();
-			Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF';
-			Controller.SearchPro();
-			// System.assertEquals(1, Controller.ConsumableorderdetailsRecords.size());
-			// System.assertEquals(2, Controller.consumableInventory.size());
-			Controller.ArriveGoodsConfim();
-			List<Consumable_order_details2__c> ins = [SELECT Id,Name FROM Consumable_order_details2__c];
-			// System.assertEquals(3, ins.size());
-			System.Test.stopTest();
-		}
-	}
+  //鏁翠綋鍒拌揣
+  @isTest
+  static void ArrivejancodeTest() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
+    Oly_TriggerHandler.bypass('ConsumableAssetHander');
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
 
-	//杩斿搧
-	@isTest(SeeAllData=true)
-	static  void methodTest2() {
-		// // TO DO: implement unit test
-		// List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�'];
-		// if (rectCo.size() == 0) {
-		// 	return;
-		// }
-		// Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
-		Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'];
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'Test001',
+        Product2__c = prod01.Id
+      );
+      insert new List<Product2__c>{ pro1 };
+      // Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
+      // insert myAccount1;
+      Consumable_order__c Order2 = new Consumable_order__c();
+      Order2.Name = 'OCM_02_001';
+      Order2.Order_status__c = '鎵瑰噯';
+      Order2.Order_type__c = '璁㈠崟';
+      Order2.Dealer_Info__c = myAccount1.Id;
+      Order2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      insert Order2;
+      //鍙戦敊搴� 鏈埌璐�
+      Consumable_order_details2__c Orderdets8 = new Consumable_order_details2__c();
+      Orderdets8.Name = 'OCM_01_001011';
+      Orderdets8.Consumable_order_minor__c = Order2.Id;
+      Orderdets8.Consumable_Product__c = pro1.Id;
+      Orderdets8.Asset_Model_No__c = 'Test01';
+      Orderdets8.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdets8.Bar_Code__c = '01049531702003111115120017181000105ZK250BXsys';
+      Orderdets8.Box_Piece__c = '鐩�';
+      Orderdets8.TracingCode__c = 'BXsys';
+      Orderdets8.SerialLotNo__c = '5ZK';
+      insert Orderdets8;
 
+      Consumable_order__c Order1 = new Consumable_order__c();
+      Order1.Name = 'OCM_01_001';
+      Order1.Order_status__c = '鎵瑰噯';
+      Order1.Order_type__c = '璁㈠崟';
+      Order1.Dealer_Info__c = myAccount1.id;
+      Order1.Order_ProType__c = 'ET';
+      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      insert Order1;
+      //璁㈠崟鏄庣粏
+      //fahuo
+      Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      Orderdet.Name = 'OCM_01_00101';
+      Orderdet.Consumable_order__c = Order1.Id;
+      Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      Orderdet.Consumable_Product__c = pro1.Id;
+      Orderdet.Consumable_count__c = 4;
+      insert Orderdet;
 
-		// Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
-		// insert myAccount1;
+      //鍒拌揣姝g‘淇℃伅
+      Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      Orderdet1.Name = 'OCM_01_001002';
+      Orderdet1.Consumable_order_minor__c = Order1.Id;
+      Orderdet1.Consumable_Product__c = pro1.Id;
+      Orderdet1.Asset_Model_No__c = 'Test01';
+      Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
+      Orderdet1.Box_Piece__c = '鐩�';
+      Orderdet1.TracingCode__c = 'BXJRA';
+      Orderdet1.SerialLotNo__c = '5ZK';
+      //娌″埌璐�
+      Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+      Orderdet2.Name = 'OCM_01_001003';
+      Orderdet2.Consumable_order_minor__c = Order1.Id;
+      Orderdet2.Consumable_Product__c = pro1.Id;
+      Orderdet2.Asset_Model_No__c = 'Test01';
+      Orderdet2.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRB';
+      Orderdet2.Box_Piece__c = '鐩�';
+      Orderdet2.TracingCode__c = 'BXJRB';
+      Orderdet2.SerialLotNo__c = '5ZK';
+      //閿�鍞骇鍝�
+      Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+      Orderdet3.Name = 'OCM_01_001004';
+      Orderdet3.Consumable_order_minor__c = Order1.Id;
+      Orderdet3.Consumable_Product__c = pro1.Id;
+      Orderdet3.Asset_Model_No__c = 'Test01';
+      Orderdet3.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet3.IsArrival__c = true;
+      Orderdet3.Consumable_Sale_order__c = Order1.Id;
+      Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRC';
+      Orderdet3.Used_date__c = Date.today();
+      Orderdet3.Arrive_date__c = Date.today();
+      Orderdet3.Box_Piece__c = '鐩�';
+      Orderdet3.TracingCode__c = 'BXJRC';
+      Orderdet3.SerialLotNo__c = '5ZK';
+      //Orderdet3.Box_Piece__c = '涓�';
 
-		// Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
-		// insert myAccount2;
+      //鍑哄簱浜у搧
+      Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+      Orderdet4.Name = 'OCM_01_001005';
+      Orderdet4.Consumable_order_minor__c = Order1.Id;
+      Orderdet4.Consumable_Product__c = pro1.Id;
+      Orderdet4.Asset_Model_No__c = 'Test01';
+      Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRD';
+      Orderdet4.Send_Date__c = Date.today();
+      Orderdet4.Arrive_date__c = Date.today();
+      Orderdet4.Box_Piece__c = '鐩�';
+      Orderdet4.TracingCode__c = 'BXJRD';
+      Orderdet4.SerialLotNo__c = '5ZK';
+      //Orderdet4.Box_Piece__c = '鐩�';
+      //Orderdet4.Return_date__c = null;
 
-		// Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=MyUser_Test.Contact.accountid);
-		// insert core;
-		// // user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
-		// // insert MyUser_Test;
+      //宸插埌璐т骇鍝�
+      Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+      Orderdet5.Name = 'OCM_01_001006';
+      Orderdet5.Consumable_order_minor__c = Order1.Id;
+      Orderdet5.Consumable_Product__c = pro1.Id;
+      Orderdet5.Asset_Model_No__c = 'Test01';
+      Orderdet5.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet5.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRE';
+      Orderdet5.Arrive_date__c = Date.today();
+      Orderdet5.Box_Piece__c = '鐩�';
+      Orderdet5.TracingCode__c = 'BXJRE';
+      Orderdet5.SerialLotNo__c = '5ZK';
+      insert new List<Consumable_order_details2__c>{
+        Orderdet1,
+        Orderdet2,
+        Orderdet3,
+        Orderdet4,
+        Orderdet5
+      };
 
-		User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
-		Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-		Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-		insert new Product2[] {prod01,prod02};
-		system.runAs(MyUser_Test){
-			// Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
-			// Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true);
-			// insert new Product2[] {prod01,prod02};
-			Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
-			Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
-			insert new Product2__c[] {pro1, pro2};
-			//璁㈠崟
-			Consumable_order__c Order1 = new Consumable_order__c();
-			Order1.Name = 'OCM_01_001';
-			Order1.Order_status__c = '鎵瑰噯';
-			Order1.Order_type__c = '璁㈠崟';
-			Order1.Dealer_Info__c = MyUser_Test.Contact.accountid;
-			Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-			Order1.Order_ProType__c = 'ET';
-			insert Order1;
-			//Consumable_order__c coc = [select Dealer_Info__r.name from Consumable_order__c where Id =:Order1.Id];
-			//system.assertEquals('qeee',coc.Dealer_Info__r.name);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      PageReference page = new PageReference('/apex/ArriveGoods?ArrType=Arr');
+      System.Test.setCurrentPage(page);
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      //鎺掑簭
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXJRA\n01049531702003111115120017181000105ZK250BXJRB\n01049531702003111115120017181000105ZK250BXJRC\n01049531702003111115120017181000105ZK250BXJRD\n01049531702003111115120017181000105ZK250BXJRE\n01049531702003111115120017181000105ZK250BX111\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRG\n01049531702003111115120017181000105ZK250BXsys';
+      Controller.SearchPro();
 
-			//璁㈠崟鏄庣粏
-			//fahuo
-			Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
-			Orderdet.Name = 'OCM_01_001001';
-			Orderdet.Consumable_order__c = Order1.Id;
-			Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
-			Orderdet.Consumable_Product__c = pro1.Id;
-			Orderdet.Consumable_count__c = 4;
-			insert Orderdet;
+      System.assertEquals(
+        'OCM_01_001002',
+        controller.ConsumableorderdetailsRecords[0].esd.Name
+      );
+      // System.assertEquals(2, controller.ConsumableorderdetailsRecordserror.size());
+      System.Test.stopTest();
+    }
+  }
 
-			//鍙戣揣鏄庣粏
-			//fahuo
-			Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
-			   Orderdet1.Name = 'OCM_01_001001';
-			   Orderdet1.Consumable_order_minor__c = Order1.Id;
-			   Orderdet1.Consumable_Product__c = pro1.Id;
-			   Orderdet1.Asset_Model_No__c = 'Pro001';
-			   Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			   Orderdet1.Box_Piece__c ='鐩�';
-			   Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
-			   //daohuo
-			   Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
-			   Orderdet2.Name = 'OCM_01_001002';
-			   Orderdet2.Consumable_order_minor__c = Order1.Id;
-			   Orderdet2.Consumable_Product__c = pro1.Id;
-			   Orderdet2.Asset_Model_No__c = 'Pro001';
-			   Orderdet2.Consumable_Arrived_order__c = Order1.Id;
-			   //Orderdet2.IsArrival__c = true;
-			   Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			   Orderdet2.Box_Piece__c ='鐩�';
-			   Orderdet2.Arrive_date__c = Date.today();
-			   //Orderdet2.Send_Date__c = Date.today();
-			   //Orderdet2.Used_date__c= Date.today();
-			   Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
-			//sale
-			Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
-			Orderdet3.Name = 'OCM_01_001003';
-			Orderdet3.Consumable_order_minor__c = Order1.Id;
-			Orderdet3.Consumable_Product__c = pro1.Id;
-			Orderdet3.Asset_Model_No__c = 'Pro001';
-			Orderdet3.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet3.IsArrival__c = true;
-			Orderdet3.Consumable_Sale_order__c = Order1.Id;
-			Orderdet3.Box_Piece__c ='鐩�';
-			Orderdet3.Used_date__c= Date.today();
-			Orderdet3.Arrive_date__c = Date.today();
-			Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
-			Orderdet3.TracingCode__c = 'BXJRF';
-			Orderdet3.SerialLotNo__c = '5ZK';
-			//鍑哄簱
-			Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
-			Orderdet4.Name = 'OCM_01_001004';
-			Orderdet4.Consumable_order_minor__c = Order1.Id;
-			Orderdet4.Consumable_Product__c = pro1.Id;
-			Orderdet4.Asset_Model_No__c = 'Pro001';
-			Orderdet4.Consumable_Arrived_order__c = Order1.Id;
-			//Orderdet4.IsArrival__c = true;
-			Orderdet4.Consumable_Shipment_order__c = Order1.Id;
-			Orderdet4.Box_Piece__c ='涓�';
-			Orderdet4.Send_Date__c = Date.today();
-			Orderdet4.Arrive_date__c = Date.today();
-			Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRN';
-			Orderdet4.TracingCode__c = 'BXJRN';
-			Orderdet4.SerialLotNo__c = '5ZK';
-			//quxiao
-			Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
-			Orderdet5.Name = 'OCM_01_001005';
-			Orderdet5.Consumable_order_minor__c = Order1.Id;
-			Orderdet5.Consumable_Product__c = pro1.Id;
-			Orderdet5.Asset_Model_No__c = 'Pro001';
-			Orderdet5.Cancellation_Date__c = Date.today();
-			Orderdet5.Cancellation_Flag__c = true;
-			Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
-			Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRZ';
-			Orderdet5.Box_Piece__c ='涓�';
-			Orderdet5.TracingCode__c = 'BXJRZ';
-			Orderdet5.SerialLotNo__c = '5ZK';
-			insert new Consumable_order_details2__c[] {Orderdet3,Orderdet4,Orderdet5};
+  //鍙戦敊璐� 鍏ュ簱
+  @isTest
+  static void ArriveotheragencyTest() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-			PageReference page = new PageReference('/apex/ArriveGoods?ArrType=ReG');
-			System.Test.setCurrentPage(page);
-			ArriveGoodsController Controller = new ArriveGoodsController();
-			//鍒濆鍖栨祴璇�
-			System.Test.startTest();
-			Controller.init();
-			//鎺掑簭
-			Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRN\n01049531702003111115120017181000105ZK250BXJRZ\n01049531702003111115120017181000105ZK250BXJRR';
-			Controller.SearchPro();
-			System.assertEquals(1, controller.ConsumableorderdetailsRecordserror.size());
-			System.assertEquals(2, controller.ShowGoodsofReturnList.size());
-			controller.ShowGoodsofReturnList[0].esd.Return_reason__c='澶氬彂';
-			controller.ShowGoodsofReturnList[1].esd.Return_reason__c='澶氬彂';
-			controller.ShowGoodsofReturnList[0].esd.Rrturn_count__c =1;
-			Controller.UpdateGoodsOfReturn();
+    Oly_TriggerHandler.bypass('ConsumableAssetHander');
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
 
-			list<String> list1 = new list<String>();
-			list1.add(Controller.barcode = '01234567898');
-			Controller.inventoryEntryNoESetId(list1);
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'Test001',
+        Product2__c = prod01.Id
+      );
+      insert new List<Product2__c>{ pro1 };
+      Account myAccount3 = new Account(
+        name = 'Testaccount003',
+        Dealer_discount__c = 30,
+        RecordTypeId = rectCo[0].Id
+      );
+      insert myAccount3;
+      Consumable_order__c Order2 = new Consumable_order__c();
+      Order2.Name = 'OCM_02_001';
+      Order2.Order_status__c = '鎵瑰噯';
+      Order2.Order_type__c = '璁㈠崟';
+      Order2.Dealer_Info__c = myAccount3.Id;
+      Order2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      Order2.Order_ProType__c = 'ET';
+      insert Order2;
+      //鍙戦敊搴� 鏈埌璐�
+      Consumable_order_details2__c Orderdets8 = new Consumable_order_details2__c();
+      Orderdets8.Name = 'OCM_01_001011';
+      Orderdets8.Consumable_order_minor__c = Order2.Id;
+      Orderdets8.Consumable_Product__c = pro1.Id;
+      Orderdets8.Asset_Model_No__c = 'Test01';
+      Orderdets8.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdets8.Bar_Code__c = '01049531702003111115120017181000105ZK250BXSYS';
+      Orderdets8.Box_Piece__c = '鐩�';
+      Orderdets8.TracingCode__c = 'BXSYS';
+      Orderdets8.SerialLotNo__c = '5ZK';
+      Orderdets8.ownerid = MyUser_Test.id;
+      insert Orderdets8;
 
-			list1.clear();
-			list1.add(Controller.barcode = '012345678901234A67');
-			Controller.inventoryEntryNoESetId(list1);
+      //鍙戦敊搴� 宸插埌璐�
+      Consumable_order_details2__c Orderdets9 = new Consumable_order_details2__c();
+      Orderdets9.Name = 'OCM_01_001012';
+      Orderdets9.Consumable_order_minor__c = Order2.Id;
+      Orderdets9.Consumable_Product__c = pro1.Id;
+      Orderdets9.Asset_Model_No__c = 'Test01';
+      Orderdets9.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdets9.Bar_Code__c = '01049531702003111115120017181000105ZK250BXSYQ';
+      Orderdets9.Consumable_Arrived_order__c = Order2.Id;
+      Orderdets9.Arrive_date__c = Date.today();
+      Orderdets9.Box_Piece__c = '鐩�';
+      Orderdets9.TracingCode__c = 'BXSYQ';
+      Orderdets9.SerialLotNo__c = '5ZK';
+      insert Orderdets9;
 
-			list1.clear();
-			list1.add(Controller.barcode = '0123456789012345117AA01');
-			Controller.inventoryEntryNoESetId(list1);
+      // Consumable_order__c Order1 = new Consumable_order__c();
+      // Order1.Name = 'OCM_01_001';
+      // Order1.Order_status__c = '鎵瑰噯';
+      // Order1.Order_type__c = '璁㈠崟';
+      // Order1.Dealer_Info__c = myAccount1.id;
+      // Order1.Order_ProType__c = 'ET';
+      // Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      // insert Order1;
+      // //璁㈠崟鏄庣粏
+      // //fahuo
+      // Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      // Orderdet.Name = 'OCM_01_00101';
+      // Orderdet.Consumable_order__c = Order1.Id;
+      // Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      // Orderdet.Consumable_Product__c = pro1.Id;
+      // Orderdet.Consumable_count__c = 4;
+      // insert Orderdet;
 
-			list1.clear();
-			list1.add(Controller.barcode = '01234567890123456789012349990001');
-			Controller.inventoryEntryNoESetId(list1);
+      // //鍒拌揣姝g‘淇℃伅
+      // Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      // Orderdet1.Name = 'OCM_01_001002';
+      // Orderdet1.Consumable_order_minor__c = Order1.Id;
+      // Orderdet1.Consumable_Product__c = pro1.Id;
+      // Orderdet1.Asset_Model_No__c = 'Test01';
+      // Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      // Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
+      // Orderdet1.Box_Piece__c = '鐩�';
+      // Orderdet1.TracingCode__c = 'BXJRA';
+      // Orderdet1.SerialLotNo__c = '5ZK';
+      // //娌″埌璐�
+      // Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+      // Orderdet2.Name = 'OCM_01_001003';
+      // Orderdet2.Consumable_order_minor__c = Order1.Id;
+      // Orderdet2.Consumable_Product__c = pro1.Id;
+      // Orderdet2.Asset_Model_No__c = 'Test01';
+      // Orderdet2.Consumable_Arrived_order__c = Order1.Id;
+      // Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      // Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRB';
+      // Orderdet2.Box_Piece__c = '鐩�';
+      // Orderdet2.TracingCode__c = 'BXJRB';
+      // Orderdet2.SerialLotNo__c = '5ZK';
+      // //閿�鍞骇鍝�
+      // Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+      // Orderdet3.Name = 'OCM_01_001004';
+      // Orderdet3.Consumable_order_minor__c = Order1.Id;
+      // Orderdet3.Consumable_Product__c = pro1.Id;
+      // Orderdet3.Asset_Model_No__c = 'Test01';
+      // Orderdet3.Consumable_Arrived_order__c = Order1.Id;
+      // //Orderdet3.IsArrival__c = true;
+      // Orderdet3.Consumable_Sale_order__c = Order1.Id;
+      // Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      // Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRC';
+      // Orderdet3.Used_date__c = Date.today();
+      // Orderdet3.Arrive_date__c = Date.today();
+      // Orderdet3.Box_Piece__c = '鐩�';
+      // Orderdet3.TracingCode__c = 'BXJRC';
+      // Orderdet3.SerialLotNo__c = '5ZK';
+      // //Orderdet3.Box_Piece__c = '涓�';
 
-			list1.clear();
-			list1.add(Controller.barcode = '0123456789012345177AA0000000000001');
-			Controller.inventoryEntryNoESetId(list1);
+      // //鍑哄簱浜у搧
+      // Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+      // Orderdet4.Name = 'OCM_01_001005';
+      // Orderdet4.Consumable_order_minor__c = Order1.Id;
+      // Orderdet4.Consumable_Product__c = pro1.Id;
+      // Orderdet4.Asset_Model_No__c = 'Test01';
+      // Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      // Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRD';
+      // Orderdet4.Send_Date__c =  Date.today();
+      // Orderdet4.Arrive_date__c = Date.today();
+      // Orderdet4.Box_Piece__c = '鐩�';
+      // Orderdet4.TracingCode__c = 'BXJRD';
+      // Orderdet4.SerialLotNo__c = '5ZK';
+      // //Orderdet4.Box_Piece__c = '鐩�';
+      // //Orderdet4.Return_date__c = null;
 
-			list1.clear();
-			list1.add(Controller.barcode = '0123456789012345177AA1111111111111');
-			Controller.inventoryEntryNoESetId(list1);
+      // //宸插埌璐т骇鍝�
+      // Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+      // Orderdet5.Name = 'OCM_01_001006';
+      // Orderdet5.Consumable_order_minor__c = Order1.Id;
+      // Orderdet5.Consumable_Product__c = pro1.Id;
+      // Orderdet5.Asset_Model_No__c = 'Test01';
+      // Orderdet5.Consumable_Arrived_order__c = Order1.Id;
+      // Orderdet5.Consumable_Shipment_order__c = Order1.Id;
+      // Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      // Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRE';
+      // Orderdet5.Arrive_date__c =  Date.today();
+      // Orderdet5.Box_Piece__c = '鐩�';
+      // Orderdet5.TracingCode__c = 'BXJRE';
+      // Orderdet5.SerialLotNo__c = '5ZK';
+      // insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2,Orderdet3,Orderdet4,Orderdet5};
 
-			list1.clear();
-			list1.add(Controller.barcode = '241345');
-			Controller.inventoryEntryNoESetId(list1);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      PageReference page = new PageReference('/apex/ArriveGoods?ArrType=Arr');
+      System.Test.setCurrentPage(page);
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      //鎺掑簭
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXSYS\n01049531702003111115120017181000105ZK250BXSYQ';
+      Controller.SearchPro();
+      Controller.ArriveGoodsConfim();
 
-			list1.clear();
-			list1.add(Controller.barcode = '2413456');
-			Controller.inventoryEntryNoESetId(list1);
+      // System.assertEquals(2, controller.ConsumableorderdetailsRecordserror.size());
+      System.Test.stopTest();
+    }
+  }
 
-			list1.clear();
-			list1.add(Controller.barcode = '24134567');
-			Controller.inventoryEntryNoESetId(list1);
+  //杩斿搧
+  @isTest
+  static void addInventoryDetails1() {
+    // // TO DO: implement unit test
+    List<RecordType> rectCo = [
+      SELECT Id
+      FROM RecordType
+      WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+    ];
+    if (rectCo.size() == 0) {
+      return;
+    }
+    // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'];
+    Profile prof = [
+      SELECT Id
+      FROM Profile
+      WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+    ];
 
-			list1.clear();
-			list1.add(Controller.barcode = '241345678');
-			Controller.inventoryEntryNoESetId(list1);
+    Account myAccount2 = new Account(
+      name = 'Testaccount002',
+      Dealer_discount__c = 20,
+      RecordTypeId = rectCo[0].Id,
+      AgentCode_Ext__c = '9999900'
+    );
+    Account myAccount1 = new Account(
+      name = 'Testaccount001',
+      Dealer_discount__c = 30,
+      RecordTypeId = rectCo[0].Id
+    );
+    insert new List<account>{ myAccount1, myAccount2 };
 
-			list1.clear();
-			list1.add(Controller.barcode = '2413456789');
-			Controller.inventoryEntryNoESetId(list1);
+    Contact core = new Contact(
+      email = 'jplumber@salesforce.com',
+      firstname = 'Joe',
+      lastname = 'Plumber',
+      accountid = myAccount1.id
+    );
+    insert core;
+    user MyUser_Test = new User(
+      ContactId = core.id,
+      Alias = 'newUser',
+      Email = 'newuser@testorg.com',
+      EmailEncodingKey = 'UTF-8',
+      LastName = 'TestUser',
+      LanguageLocaleKey = 'zh_CN',
+      LocaleSidKey = 'zh_CN',
+      ProfileId = prof.Id,
+      TimeZoneSidKey = 'Asia/Shanghai',
+      UserName = 'testUser@testorg.com',
+      UserPro_Type__c = 'ET'
+    );
+    System.runAs(new User(Id = UserInfo.getUserId())) {
+      insert MyUser_Test;
+    }
 
-			list1.clear();
-			list1.add(Controller.barcode = '24134567890');
-			Controller.inventoryEntryNoESetId(list1);
+    // User MyUser_Test = [select id,Contact.accountid from User WHERE ProfileId = :prof.Id and IsActive = true and UserPro_Type__c = 'ET' limit 1 ];
+    // Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200311',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',JANCODE__c = '04953170200312',Dealer_special_Object__c = true,Manual_Entry__c = false);
+    // insert new Product2[] {prod01,prod02};
+    System.runAs(MyUser_Test) {
+      Product2 prod01 = new Product2(
+        Name = 'Test01',
+        ProductCode = 'Test01',
+        Asset_Model_No__c = 'Test01',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200311',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      Product2 prod02 = new Product2(
+        Name = 'Test02',
+        ProductCode = 'Test02',
+        Asset_Model_No__c = 'Test02',
+        SFDA_Status__c = '鏈夊姽',
+        JANCODE__c = '04953170200312',
+        Dealer_special_Object__c = true,
+        Manual_Entry__c = false
+      );
+      insert new List<Product2>{ prod01, prod02 };
+      Product2__c pro1 = new Product2__c(
+        Name = 'Pro001',
+        OT_CODE_Text__c = 'Test001',
+        Product2__c = prod01.Id
+      );
+      Product2__c pro2 = new Product2__c(
+        Name = 'Pro002',
+        OT_CODE_Text__c = 'Test002',
+        Product2__c = prod02.Id
+      );
+      insert new List<Product2__c>{ pro1, pro2 };
+      //璁㈠崟
+      Oly_TriggerHandler.bypass('ConsumableAssetHander');
+      Consumable_order__c Order1 = new Consumable_order__c();
+      Order1.Name = 'OCM_01_001';
+      Order1.Order_status__c = '鎵瑰噯';
+      Order1.Order_type__c = '璁㈠崟';
+      Order1.Dealer_Info__c = myAccount1.id;
+      Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+      Order1.Order_ProType__c = 'ET';
+      //杩斿搧璁㈠崟
 
-			list1.clear();
-			list1.add(Controller.barcode = '241345678901');
-			Controller.inventoryEntryNoESetId(list1);
+      Consumable_order__c Order2 = new Consumable_order__c();
+      Order2.Name = 'OCM_01_002';
+      Order2.Order_status__c = '鎵瑰噯';
+      Order2.Order_type__c = '杩斿搧';
+      Order2.Dealer_Info__c = myAccount1.id;
+      Order2.RecordTypeid = System.Label.Dealer_Returned_Label;
+      insert Order1;
+      insert Order2;
 
-			list1.clear();
-			list1.add(Controller.barcode = '0112345678901231177890121215678901234');
-			Controller.inventoryEntryNoESetId(list1);
+      //璁㈠崟鏄庣粏
+      //fahuo
+      Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+      Orderdet.Name = 'OCM_01_00101';
+      Orderdet.Consumable_order__c = Order1.Id;
+      Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+      Orderdet.Consumable_Product__c = pro1.Id;
+      Orderdet.Consumable_count__c = 4;
+      insert Orderdet;
 
-			list1.clear();
-			list1.add(Controller.barcode = '0112345678901231106789012105678901234');
-			Controller.inventoryEntryNoESetId(list1);
-			list1.clear();
-			list1.add(Controller.barcode = '0112345678901231106789012105625001234');
-			Controller.inventoryEntryNoESetId(list1);
-			System.Test.stopTest();
+      //鍙戣揣鏄庣粏
+      //fahuo
+      Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+      Orderdet1.Name = 'OCM_01_001001';
+      Orderdet1.Consumable_order_minor__c = Order1.Id;
+      Orderdet1.Consumable_Product__c = pro1.Id;
+      Orderdet1.Asset_Model_No__c = 'Pro001';
+      Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+      Orderdet1.TracingCode__c = 'BXJRF';
+      //daohuo
+      Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+      Orderdet2.Name = 'OCM_01_001002';
+      Orderdet2.Consumable_order_minor__c = Order1.Id;
+      Orderdet2.Consumable_Product__c = pro1.Id;
+      Orderdet2.Asset_Model_No__c = 'Pro001';
+      Orderdet2.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet2.IsArrival__c = true;
+      Orderdet2.Arrive_date__c = Date.today();
+      Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRI';
+      Orderdet2.TracingCode__c = 'BXJRF';
+      //sale
+      Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+      Orderdet3.Name = 'OCM_01_001003';
+      Orderdet3.Consumable_order_minor__c = Order1.Id;
+      Orderdet3.Consumable_Product__c = pro1.Id;
+      Orderdet3.Asset_Model_No__c = 'Pro001';
+      Orderdet3.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet3.IsArrival__c = true;
+      Orderdet3.Arrive_date__c = Date.today();
+      Orderdet3.Used_date__c = Date.today();
+      Orderdet3.Consumable_Sale_order__c = Order1.Id;
+      Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRJ';
+      Orderdet3.Box_Piece__c = '鐩�';
+      Orderdet3.TracingCode__c = 'BXJRF';
+      //鍑哄簱
+      Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+      Orderdet4.Name = 'OCM_01_001004';
+      Orderdet4.Consumable_order_minor__c = Order1.Id;
+      Orderdet4.Consumable_Product__c = pro1.Id;
+      Orderdet4.Asset_Model_No__c = 'Pro001';
+      Orderdet4.Consumable_Arrived_order__c = Order1.Id;
+      //Orderdet4.IsArrival__c = true;
+      Orderdet4.Arrive_date__c = Date.today();
+      Orderdet4.Send_Date__c = Date.today();
+      Orderdet4.Consumable_Shipment_order__c = Order1.Id;
+      Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRN';
+      Orderdet4.Box_Piece__c = '涓�';
+      Orderdet4.TracingCode__c = 'BXJRF';
+      //quxiao
+      Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+      Orderdet5.Name = 'OCM_01_001005';
+      Orderdet5.Consumable_order_minor__c = Order1.Id;
+      Orderdet5.Consumable_Product__c = pro1.Id;
+      Orderdet5.Asset_Model_No__c = 'Pro001';
+      Orderdet5.Cancellation_Date__c = Date.today();
+      Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRZ';
+      Orderdet5.Box_Piece__c = '鐩�';
+      Orderdet5.TracingCode__c = 'BXJRF';
+      //fanpin
+      Consumable_order_details2__c Orderdet6 = new Consumable_order_details2__c();
+      Orderdet6.Name = 'OCM_01_001006';
+      Orderdet6.Consumable_order_minor__c = Order1.Id;
+      Orderdet6.Consumable_Product__c = pro1.Id;
+      Orderdet6.Asset_Model_No__c = 'Pro001';
+      Orderdet6.Consumable_Return_order__c = Order2.Id;
+      Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet6.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
+      Orderdet6.Box_Piece__c = '涓�';
+      Orderdet6.TracingCode__c = 'BXJRF';
 
-		}
-	}
+      // 涓㈠け
+      Consumable_order_details2__c Orderdet7 = new Consumable_order_details2__c();
+      Orderdet7.Name = 'OCM_01_001002';
+      Orderdet7.Consumable_order_minor__c = Order1.Id;
+      Orderdet7.Consumable_Product__c = pro1.Id;
+      Orderdet7.Asset_Model_No__c = 'Pro001';
+      Orderdet7.Consumable_Arrived_order__c = Order1.Id;
+      Orderdet7.Lose_Flag__c = true;
+      Orderdet7.Arrive_date__c = Date.today();
+      Orderdet7.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+      Orderdet7.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJQT';
+      Orderdet7.Box_Piece__c = '涓�';
+      Orderdet7.TracingCode__c = 'BXJQT';
 
-}
\ No newline at end of file
+      insert new List<Consumable_order_details2__c>{
+        Orderdet1,
+        Orderdet2,
+        Orderdet3,
+        Orderdet4,
+        Orderdet5,
+        Orderdet6,
+        Orderdet7
+      };
+      PageReference page = new PageReference('/apex/ArriveGoods?ArrType=ReG');
+      System.Test.setCurrentPage(page);
+      ArriveGoodsController Controller = new ArriveGoodsController();
+      //鍒濆鍖栨祴璇�
+      System.Test.startTest();
+      Controller.init();
+      //鎺掑簭
+      Controller.barcode = '01049531702003111115120017181000105ZK250BXJRN\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRI\n01049531702003111115120017181000105ZK250BXJRN\n01049531702003111115120017181000105ZK250BXJRZ\n01049531702003111115120017181000105ZK250BXJRA\n01049531702003111115120017181000105ZK250BXJRI\n01049531702003111115120017181000105ZK250BXJQT';
+      Controller.SearchPro();
+      //System.assertEquals(1, controller.ShowGoodsofReturnList.size());
+      //System.assertEquals('OCM_01_001003', controller.ShowGoodsofReturnList[0].esd.Name);
+      //System.assertEquals('OCM_01_001004', controller.ShowGoodsofReturnList[1].esd.Name);
+      // System.assertEquals(5, controller.ConsumableorderdetailsRecordserror.size());    //tcm
+      //System.assertEquals('Test01', controller.ConsumableorderdetailsRecordserror[1].Prod.Name__c);
+      //System.assertEquals('OCM_01_001002', controller.ConsumableorderdetailsRecordserror[2].esd.Name);
+      //System.assertEquals('OCM_02_001001', controller.ConsumableorderdetailsRecordserror[3].esd.Name);
+      // Controller.GoodsReturnCheck();
+      controller.ShowGoodsofReturnList[0].esd.Return_reason__c = '澶氬彂';
+      controller.ShowGoodsofReturnList[0].esd.Rrturn_count__c = 1;
+      //System.assertEquals(1, controller.ShowGoodsofReturnList.size());
+      Controller.UpdateGoodsOfReturn();
+      Controller.ToReturnGoodsPage();
+      Controller.geterrorsize();
+      System.Test.stopTest();
+    }
+  }
+}
diff --git a/force-app/main/default/classes/LexArriveGoodsController.cls b/force-app/main/default/classes/LexArriveGoodsController.cls
new file mode 100644
index 0000000..ad92c51
--- /dev/null
+++ b/force-app/main/default/classes/LexArriveGoodsController.cls
@@ -0,0 +1,356 @@
+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
+      );
+      arrController.isLwc = true;
+      arrController.init();
+      results.arrGoodCon = JSON.serialize(arrController);
+      results.coc = arrController.coc;
+      results.saveFLGbln = arrController.saveFLGbln;
+      results.returnFLGbln = arrController.ReturnFLGbln;
+      results.result = 'Success';
+    } catch (Exception e) {
+      results.result = 'Fail';
+      results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+    }
+    return results;
+  }
+
+  //鎼滅储浜у搧
+  @AuraEnabled
+  public static Results searchProduct(String barcode, String arrControllerStr) {
+    Results results = new Results();
+    try {
+      System.debug('arrControllerStr:' + arrControllerStr);
+      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 != ''
+      ) {
+        results.result = 'Fail';
+        results.errorMsgList = arrController.errorList;
+        results.warningMsgList = arrController.warningList;
+        results.errorMsg = arrController.returnError;
+      } else {
+        results.coc = arrController.coc;
+        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.errorMsgList = arrController.errorList;
+        results.warningMsgList = arrController.warningList;
+        results.result = 'Success';
+      }
+    } catch (Exception e) {
+      results.result = 'Fail';
+      results.errorMsg =
+        e.getLineNumber() +
+        '---' +
+        e.getMessage() +
+        '---' +
+        e.getStackTraceString();
+    }
+    return results;
+  }
+
+  //鍒拌揣纭
+  @AuraEnabled
+  public static Results arriveGoodsConfim(String arrControllerStr) {
+    Results results = new Results();
+    try {
+      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 != ''
+      ) {
+        results.result = 'Fail';
+        results.errorMsgList = arrController.errorList;
+        results.warningMsgList = arrController.warningList;
+        results.errorMsg = arrController.returnError;
+      } else {
+        if (arrController.urlType == 'UnabletoEdit') {
+          results.url = '/lexarrivegsdetails?EsetId=' + arrController.arriveId;
+        }
+        results.errorMsgList = arrController.errorList;
+        results.warningMsgList = arrController.warningList;
+        results.result = 'Success';
+      }
+    } catch (Exception e) {
+      results.result = 'Fail';
+      results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+    }
+    return results;
+  }
+
+  //鐧诲綍杩斿搧
+  @AuraEnabled
+  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
+      );
+      arrController.ShowGoodsofReturnList = changeType2(showGoodsofReturnList);
+      arrController.returnError = null;
+      arrController.warningList = new List<String>();
+      arrController.errorList = new List<String>();
+      Pagereference page = arrController.UpdateGoodsOfReturn();
+      results.arrGoodCon = JSON.serialize(arrController);
+      if (
+        arrController.returnError != null &&
+        arrController.returnError != ''
+      ) {
+        results.result = 'Fail';
+        results.errorMsgList = arrController.errorList;
+        results.warningMsgList = arrController.warningList;
+        results.errorMsg = arrController.returnError;
+      } else {
+        if (arrController.urlType == 'ToReturnGoodsPage') {
+          results.url = '/detail/' + arrController.return_Order_id;
+        }
+        if (arrController.urlType == 'ToInventoryGoodsPage') {
+          results.url = '/detail/' + arrController.inventory_Order_id;
+        }
+        results.errorMsgList = arrController.errorList;
+        results.warningMsgList = arrController.warningList;
+        results.result = 'Success';
+      }
+    } catch (Exception e) {
+      results.result = 'Fail';
+      results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+    }
+    return results;
+  }
+
+  public static List<ConsumableorderdetailsInfo> changeType1(
+    List<ArriveGoodsController.ConsumableorderdetailsInfo> conList
+  ) {
+    List<ConsumableorderdetailsInfo> conList1 = new List<ConsumableorderdetailsInfo>();
+    if (conList != null) {
+      for (ArriveGoodsController.ConsumableorderdetailsInfo con : conList) {
+        ConsumableorderdetailsInfo con1 = new ConsumableorderdetailsInfo();
+        con1.esd = con.esd;
+        con1.Prod = con.Prod;
+        con1.ProductName = con.ProductName;
+        con1.barCodeNo = con.barCodeNo;
+        con1.sterilizationlimitDate = con.sterilizationlimitDate;
+        con1.serialNoorLotNo = con.serialNoorLotNo;
+        con1.tracingCodeNo = con.tracingCodeNo;
+        con1.ReturnReason = con.ReturnReason;
+        con1.oldConsumableCount = con.oldConsumableCount;
+        con1.ErrorReason = con.ErrorReason;
+        con1.canEdit = con.canEdit;
+        con1.intMark = con.intMark;
+        con1.arriveAmount = con.arriveAmount;
+        con1.arrivedCount = con.arrivedCount;
+        con1.ReportProductExpirationDate = con.ReportProductExpirationDate;
+        conList1.add(con1);
+      }
+    }
+    return conList1;
+  }
+
+  public static List<ArriveGoodsController.ConsumableorderdetailsInfo> changeType2(
+    List<ConsumableorderdetailsInfo> conList
+  ) {
+    List<ArriveGoodsController.ConsumableorderdetailsInfo> conList1 = new List<ArriveGoodsController.ConsumableorderdetailsInfo>();
+    if (conList != null) {
+      for (ConsumableorderdetailsInfo con : conList) {
+        ArriveGoodsController.ConsumableorderdetailsInfo con1 = new ArriveGoodsController.ConsumableorderdetailsInfo();
+        con1.esd = con.esd;
+        con1.Prod = con.Prod;
+        con1.ProductName = con.ProductName;
+        con1.barCodeNo = con.barCodeNo;
+        con1.sterilizationlimitDate = con.sterilizationlimitDate;
+        con1.serialNoorLotNo = con.serialNoorLotNo;
+        con1.tracingCodeNo = con.tracingCodeNo;
+        con1.ReturnReason = con.ReturnReason;
+        con1.oldConsumableCount = con.oldConsumableCount;
+        con1.ErrorReason = con.ErrorReason;
+        con1.canEdit = con.canEdit;
+        con1.intMark = con.intMark;
+        con1.arriveAmount = con.arriveAmount;
+        con1.arrivedCount = con.arrivedCount;
+        con1.ReportProductExpirationDate = con.ReportProductExpirationDate;
+        conList1.add(con1);
+      }
+    }
+    return conList1;
+  }
+
+  public class Results {
+    @AuraEnabled
+    public String result;
+    @AuraEnabled
+    public String errorMsg;
+    @AuraEnabled
+    public String url;
+    @AuraEnabled
+    public String arrGoodCon;
+    @AuraEnabled
+    public Consumable_order__c coc;
+    @AuraEnabled
+    public Boolean returnFLGbln;
+    @AuraEnabled
+    public Boolean saveFLGbln;
+    @AuraEnabled
+    public List<ConsumableorderdetailsInfo> detailsSummary;
+    @AuraEnabled
+    public List<ConsumableorderdetailsInfo> consumableorderdetailsRecords;
+    @AuraEnabled
+    public List<ConsumableorderdetailsInfo> showGoodsofReturnList;
+    @AuraEnabled
+    public List<ConsumableorderdetailsInfo> consumableInventory;
+    @AuraEnabled
+    public List<ConsumableorderdetailsInfo> consumableorderdetailsRecordserror;
+    @AuraEnabled
+    public List<String> errorMsgList;
+    @AuraEnabled
+    public List<String> warningMsgList;
+    @AuraEnabled
+    public Boolean isNoteStay;
+  }
+
+  public class ConsumableorderdetailsInfo implements Comparable {
+    @AuraEnabled
+    public Consumable_order_details2__c esd { get; set; }
+    @AuraEnabled
+    public Product2__c Prod { get; set; }
+    @AuraEnabled
+    public String ProductName { get; set; }
+    @AuraEnabled
+    public String barCodeNo { get; set; }
+    @AuraEnabled
+    public Date sterilizationlimitDate { get; set; }
+    @AuraEnabled
+    public String serialNoorLotNo { get; set; }
+    @AuraEnabled
+    public String tracingCodeNo { get; set; }
+    @AuraEnabled
+    public String ReturnReason { get; set; }
+    @AuraEnabled
+    public String oldConsumableCount { get; set; }
+    @AuraEnabled
+    public String ErrorReason { get; set; }
+    @AuraEnabled
+    public boolean canEdit { get; set; }
+    @AuraEnabled
+    public Integer intMark { get; set; }
+    @AuraEnabled
+    public Decimal arriveAmount { get; set; }
+    @AuraEnabled
+    public Decimal arrivedCount { get; set; }
+    @AuraEnabled
+    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;
+    }
+  }
+}
diff --git a/force-app/main/default/classes/LexArriveGoodsController.cls-meta.xml b/force-app/main/default/classes/LexArriveGoodsController.cls-meta.xml
new file mode 100644
index 0000000..1248daa
--- /dev/null
+++ b/force-app/main/default/classes/LexArriveGoodsController.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>56.0</apiVersion>
+    <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.css b/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.css
new file mode 100644
index 0000000..32d24c8
--- /dev/null
+++ b/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.css
@@ -0,0 +1 @@
+@import "c/lexCssUtility";
diff --git a/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.html b/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.html
new file mode 100644
index 0000000..bb32158
--- /dev/null
+++ b/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.html
@@ -0,0 +1,380 @@
+<template>
+  <template if:true={showSpinner}>
+    <lightning-spinner size="medium" variant="brand"></lightning-spinner>
+  </template>
+  <c-common-toast></c-common-toast>
+  <template if:true={showPage}>
+    <div
+      style="
+        border: 1px solid #d4d4d4;
+        border-top: 3px solid #51606e;
+        border-radius: 5px;
+      "
+    >
+      <div style="border-bottom: 1px solid #d4d4d4; padding: 3px">
+        <lightning-layout>
+          <lightning-layout-item padding="around-small">
+            <p style="font-size: 18px">
+              <strong>鍏ュ簱/杩斿搧</strong>
+            </p>
+          </lightning-layout-item>
+        </lightning-layout>
+        <!-- <p style="font-size: 16px;"><strong>鍏ュ簱/杩斿搧</strong></p> -->
+      </div>
+      <div style="padding: 10px">
+        <!-- 鎸夐挳 -->
+        <template if:false={returnFLGbln}>
+          <!-- <lightning-button style="margin: 5px;" label="鍒拌揣纭" onclick={arriveGoodsConfim} disabled={saveFLGbln}></lightning-button> -->
+          <button
+            class="slds-button slds-button_neutral slds-button_stretch lexBorder"
+            style="margin: 5px"
+            label="鍒拌揣纭"
+            onclick={arriveGoodsConfim}
+            disabled={saveFLGbln}
+          >
+            鍒拌揣纭
+          </button>
+        </template>
+        <template if:true={returnFLGbln}>
+          <!-- <lightning-button style="margin: 5px;" label="鐧诲綍杩斿搧" onclick={updateGoodsOfReturn}></lightning-button> -->
+          <button
+            class="slds-button slds-button_neutral slds-button_stretch lexBorder"
+            style="margin: 5px"
+            label="鐧诲綍杩斿搧"
+            onclick={updateGoodsOfReturn}
+          >
+            鐧诲綍杩斿搧
+          </button>
+        </template>
+        <p style="height: 10px"></p>
+        <!-- 璁㈠崟淇℃伅 -->
+        <template if:true={showOrderDetail}>
+          <div
+            style="
+              border: 1px solid #d4d4d4;
+              border-top: 3px solid #51606e;
+              border-radius: 5px;
+              margin-bottom: 7px;
+            "
+          >
+            <div style="border-bottom: 1px solid #d4d4d4; padding: 3px">
+              <lightning-layout>
+                <lightning-layout-item padding="around-small">
+                  <p style="font-size: 18px">
+                    <strong>璁㈠崟淇℃伅</strong>
+                  </p>
+                </lightning-layout-item>
+              </lightning-layout>
+              <!-- <p style="font-size: 16px;"><strong>璁㈠崟淇℃伅</strong></p> -->
+            </div>
+            <div style="padding: 10px">
+              <table>
+                <tbody>
+                  <tr>
+                    <td style="width: 10px"></td>
+                    <td style="width: 60px">
+                      <div style="color: #696969; font-size: 12px">
+                        璁㈠崟鍚嶇О
+                      </div>
+                    </td>
+                    <td style="width: 200px">
+                      <lightning-formatted-text
+                        value={coc.Name}
+                      ></lightning-formatted-text>
+                    </td>
+                    <td style="width: 30px"></td>
+                    <td style="width: 60px">
+                      <div style="color: #696969; font-size: 12px">
+                        璁㈠崟鎬绘暟
+                      </div>
+                    </td>
+                    <td style="width: 100px">
+                      <lightning-formatted-number
+                        value={coc.Total_num__c}
+                      ></lightning-formatted-number>
+                    </td>
+                    <td style="width: 30px"></td>
+                    <td style="width: 72px">
+                      <div style="color: #696969; font-size: 12px">
+                        宸插埌璐ф暟閲�
+                      </div>
+                    </td>
+                    <td style="width: 100px">
+                      <lightning-formatted-number
+                        value={coc.OrderNumber_arrived__c}
+                      ></lightning-formatted-number>
+                    </td>
+                    <td style="width: 30px"></td>
+                    <td style="width: 84px">
+                      <div style="color: #696969; font-size: 12px">
+                        杩樻病鍙戣揣鏁伴噺
+                      </div>
+                    </td>
+                    <td style="width: 100px">
+                      <lightning-formatted-number
+                        value={coc.OrderNumber_notarrive__c}
+                      ></lightning-formatted-number>
+                    </td>
+                    <td></td>
+                  </tr>
+                </tbody>
+              </table>
+            </div>
+          </div>
+        </template>
+        <!-- BarCode褰曞叆 -->
+        <div
+          style="
+            border: 1px solid #d4d4d4;
+            border-top: 3px solid #51606e;
+            border-radius: 5px;
+            margin-bottom: 7px;
+          "
+        >
+          <div style="border-bottom: 1px solid #d4d4d4; padding: 3px">
+            <lightning-layout>
+              <lightning-layout-item padding="around-small">
+                <p style="font-size: 18px">
+                  <strong>BarCode褰曞叆</strong>
+                </p>
+              </lightning-layout-item>
+            </lightning-layout>
+            <!-- <p style="font-size: 16px;"><strong>BarCode褰曞叆</strong></p> -->
+          </div>
+          <div style="padding: 10px">
+            <table>
+              <tbody>
+                <tr>
+                  <td style="width: 20px"></td>
+                  <td style="width: 60px; font-size: 16px">BarCode</td>
+                  <td style="width: 30px"></td>
+                  <td style="width: 600px">
+                    <lightning-textarea
+                      class="inputFont"
+                      name="BarCode"
+                      value={barcode}
+                      label=""
+                      variant="label-hidden"
+                      onchange={barcodeChange}
+                    ></lightning-textarea>
+                  </td>
+                  <td style="width: 30px"></td>
+                  <td style="width: 200px">
+                    <!-- <lightning-button label="鑾峰彇鏄庣粏" title="鑾峰彇鏄庣粏" onclick={barcodeEntrys} style="width: 300px;"></lightning-button> -->
+                    <button
+                      class="slds-button slds-button_neutral slds-button_stretch lexBorder"
+                      label="鑾峰彇鏄庣粏"
+                      onclick={barcodeEntrys}
+                    >
+                      鑾峰彇鏄庣粏
+                    </button>
+                  </td>
+                  <td></td>
+                </tr>
+              </tbody>
+            </table>
+          </div>
+        </div>
+        <!-- 璀﹀憡鎻愰啋 -->
+        <template if:true={hasWarning}>
+          <div
+            style="
+              border: 1px solid #d4d4d4;
+              border-radius: 5px;
+              margin-bottom: 7px;
+            "
+          >
+            <div
+              style="
+                border-bottom: 1px solid #d4d4d4;
+                border-radius: 5px;
+                margin-bottom: 7px;
+                color: #ff6a00;
+                font-size: 17px;
+              "
+            >
+              <lightning-icon icon-name="utility:warning"></lightning-icon>
+              <strong>&nbsp;&nbsp;&nbsp;璀﹀憡</strong>
+            </div>
+            <template for:each={warningMsgs} for:item="msg">
+              <p
+                key={msg}
+                style="color: #ff6a00; padding-left: 7px; font-size: 14px"
+              >
+                &nbsp;&nbsp;&nbsp;銉�&nbsp;{msg}
+              </p>
+            </template>
+          </div>
+        </template>
+        <!-- 鎶ラ敊鎻愰啋 -->
+        <template if:true={hasError}>
+          <div
+            style="
+              border: 1px solid #d4d4d4;
+              border-radius: 5px;
+              margin-bottom: 7px;
+            "
+          >
+            <div
+              style="
+                border-bottom: 1px solid #d4d4d4;
+                border-radius: 5px;
+                margin-bottom: 7px;
+                color: red;
+                font-size: 17px;
+              "
+            >
+              <lightning-icon icon-name="utility:error"></lightning-icon>
+              <strong>&nbsp;&nbsp;&nbsp;閿欒</strong>
+            </div>
+            <template for:each={errorMsgs} for:item="msg">
+              <p
+                key={msg}
+                style="color: red; padding-left: 7px; font-size: 14px"
+              >
+                &nbsp;&nbsp;&nbsp;銉�&nbsp;{msg}
+              </p>
+            </template>
+          </div>
+        </template>
+        <!-- 鏈鍒拌揣浜у搧姹囨�� -->
+        <template if:false={returnFLGbln}>
+          <div
+            style="
+              border: 1px solid #d4d4d4;
+              border-top: 3px solid #51606e;
+              border-radius: 5px;
+              margin-bottom: 7px;
+            "
+          >
+            <div style="border-bottom: 1px solid #d4d4d4; padding: 3px">
+              <lightning-layout>
+                <lightning-layout-item padding="around-small">
+                  <p style="font-size: 18px">
+                    <strong>鏈鍒拌揣浜у搧姹囨��</strong>
+                  </p>
+                </lightning-layout-item>
+              </lightning-layout>
+              <!-- <p style="font-size: 16px;"><strong>鏈鍒拌揣浜у搧姹囨��</strong></p> -->
+            </div>
+            <div style="padding: 10px">
+              <lightning-datatable
+                class="wrapped-header-datatable"
+                hide-checkbox-column
+                key-field="recordId"
+                columns={currentArrProdCols}
+                data={detailsSummary}
+              ></lightning-datatable>
+            </div>
+          </div>
+        </template>
+        <!-- 鍒拌揣鏄庣粏 -->
+        <template if:false={returnFLGbln}>
+          <div
+            style="
+              border: 1px solid #d4d4d4;
+              border-top: 3px solid #51606e;
+              border-radius: 5px;
+              margin-bottom: 7px;
+            "
+          >
+            <div style="border-bottom: 1px solid #d4d4d4; padding: 3px">
+              <lightning-layout>
+                <lightning-layout-item padding="around-small">
+                  <p style="font-size: 18px">
+                    <strong>鍏ュ簱鍜屽埌璐ф槑缁�</strong>
+                  </p>
+                </lightning-layout-item>
+              </lightning-layout>
+            </div>
+            <div style="padding: 10px">
+              <lightning-datatable
+                class="wrapped-header-datatable"
+                hide-checkbox-column
+                key-field="recordId"
+                columns={arrDetailCols}
+                data={consumableorderdetailsRecordsview}
+              ></lightning-datatable>
+            </div>
+          </div>
+        </template>
+        <!-- 杩斿搧鏄庣粏 -->
+        <template if:true={returnFLGbln}>
+          <div
+            style="
+              border: 1px solid #d4d4d4;
+              border-top: 3px solid #51606e;
+              border-radius: 5px;
+              margin-bottom: 7px;
+            "
+          >
+            <div style="border-bottom: 1px solid #d4d4d4; padding: 3px">
+              <lightning-layout>
+                <lightning-layout-item padding="around-small">
+                  <p style="font-size: 18px">
+                    <strong>鍏ュ簱鍜岃繑鍝佹槑缁�</strong>
+                  </p>
+                </lightning-layout-item>
+              </lightning-layout>
+            </div>
+            <div style="padding: 10px">
+              <c-lex-custom-lightning-datatable
+                class="wrapped-header-datatable"
+                hide-checkbox-column
+                key-field="recordId"
+                data={showGoodsofReturnListView}
+                columns={returnDetailCols}
+                onchangereturncount={returnCountChange}
+                onchangevalue={returnReasonChange}
+              ></c-lex-custom-lightning-datatable>
+            </div>
+          </div>
+        </template>
+        <!-- 鍏ュ簱鏄庣粏 -->
+        <!-- <div style="border: 1px solid #D4D4D4;border-top: 3px solid #51606E;border-radius:5px;margin-bottom:7px;">
+                    <div style="border-bottom: 1px solid #D4D4D4;padding:3px;">
+                        <lightning-layout>
+                            <lightning-layout-item padding="around-small">
+                                <p style="font-size: 16px">
+                                    <strong>鍏ュ簱鏄庣粏</strong>
+                                </p>
+                            </lightning-layout-item>
+                        </lightning-layout>
+                    </div>
+                    <div style="padding:10px;">
+                        <lightning-datatable class="wrapped-header-datatable" hide-checkbox-column key-field="recordId" columns={inDetailCols} data={consumableInventory}></lightning-datatable>
+                    </div>
+                </div> -->
+        <!-- 閿欒鏄庣粏 -->
+        <div
+          style="
+            border: 1px solid #d4d4d4;
+            border-top: 3px solid #51606e;
+            border-radius: 5px;
+            margin-bottom: 7px;
+          "
+        >
+          <div style="border-bottom: 1px solid #d4d4d4; padding: 3px">
+            <lightning-layout>
+              <lightning-layout-item padding="around-small">
+                <p style="font-size: 18px">
+                  <strong>閿欒鏄庣粏</strong>
+                </p>
+              </lightning-layout-item>
+            </lightning-layout>
+            <!-- <p style="font-size: 16px;"><strong>閿欒鏄庣粏</strong></p> -->
+          </div>
+          <div style="padding: 10px">
+            <lightning-datatable
+              class="wrapped-header-datatable"
+              hide-checkbox-column
+              key-field="recordId"
+              columns={errorDetailCols}
+              data={consumableorderdetailsRecordserror}
+            ></lightning-datatable>
+          </div>
+        </div>
+      </div>
+    </div>
+  </template>
+</template>
diff --git a/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.js b/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.js
new file mode 100644
index 0000000..47d4801
--- /dev/null
+++ b/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.js
@@ -0,0 +1,773 @@
+import { LightningElement, wire, track } from "lwc";
+import { CurrentPageReference } from "lightning/navigation";
+import { ShowToastEvent } from "lightning/platformShowToastEvent";
+import { NavigationMixin } from "lightning/navigation";
+import init from "@salesforce/apex/LexArriveGoodsController.init";
+import searchProduct from "@salesforce/apex/LexArriveGoodsController.searchProduct";
+import arriveGoodsConfim from "@salesforce/apex/LexArriveGoodsController.arriveGoodsConfim";
+import updateGoodsOfReturn from "@salesforce/apex/LexArriveGoodsController.updateGoodsOfReturn";
+//table css
+import { loadStyle } from "lightning/platformResourceLoader";
+import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable";
+
+export default class LexArriveGoods extends NavigationMixin(LightningElement) {
+  //椤甸潰鍙橀噺
+  @track arrType;
+  @track eSetId;
+  @track returnFLGbln = false;
+  @track saveFLGbln = false;
+  @track barcode;
+  @track arrController;
+  stylesLoaded = false;
+  @track showSpinner = true;
+  @track showPage = false;
+  //娑堣�楀搧璁㈠崟
+  @track coc;
+  @track cocId;
+  //鏈鍒拌揣浜у搧姹囨��
+  @track detailsSummary = [];
+  //鍒拌揣鏄庣粏
+  @track consumableorderdetailsRecords = [];
+  @track consumableorderdetailsRecordsview = [];
+  //杩斿搧鏄庣粏
+  @track showGoodsofReturnList = [];
+  @track showGoodsofReturnListView = [];
+  //鍏ュ簱鏄庣粏
+  @track consumableInventory = [];
+  //閿欒鏄庣粏
+  @track consumableorderdetailsRecordserror = [];
+  //鎶ラ敊鎻愰啋
+  @track errorMsgs = [];
+  @track warningMsgs = [];
+  //鏄惁涓�鐩存樉绀烘彁绀�
+  @track isNoteStay = true;
+
+  //鏄惁鏈夎鍛�
+  get hasWarning() {
+    if (this.warningMsgs == null || this.warningMsgs.length == 0) {
+      return false;
+    }
+    if (this.warningMsgs.length > 0) {
+      return true;
+    }
+  }
+
+  //鏄惁鏈夐敊璇�
+  get hasError() {
+    if (this.errorMsgs == null || this.errorMsgs.length == 0) {
+      return false;
+    }
+    if (this.errorMsgs.length > 0) {
+      return true;
+    }
+  }
+
+  //鏈鍒拌揣浜у搧姹囨�籧ols
+  @track currentArrProdCols = [
+    {
+      label: "浜у搧鍨嬪彿",
+      fieldName: "assetModelNo",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 220
+    },
+    {
+      label: "浜у搧鍚嶇О",
+      fieldName: "prodName",
+      hideDefaultActions: true,
+      wrapText: true
+    },
+    {
+      label: "鍒拌揣鏁伴噺",
+      fieldName: "arrivedCount",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 220,
+      cellAttributes: { alignment: "right" }
+    },
+    {
+      label: "鍒拌揣閲戦",
+      type: "number",
+      typeAttributes: { minimumFractionDigits: 2 },
+      fieldName: "arriveAmount",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 220,
+      cellAttributes: { alignment: "right" }
+    }
+  ];
+  //鍒拌揣鏄庣粏cols
+  @track arrDetailCols = [
+    {
+      label: "娑堣�楀搧鍚嶇О",
+      fieldName: "prodName",
+      hideDefaultActions: true,
+      wrapText: true
+    },
+    {
+      label: "瑙勬牸",
+      fieldName: "productPackingListManual",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 120,
+      cellAttributes: { alignment: "right" }
+    },
+    {
+      label: "CFDA鐘舵��",
+      fieldName: "status",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 120
+    },
+    {
+      label: "娉ㄥ唽璇佺紪鐮佸彿",
+      fieldName: "reportProductApprobation",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 180
+    },
+    {
+      label: "娉ㄥ唽璇佹晥鏈�",
+      fieldName: "ReportProductExpirationDate",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 100
+    },
+    {
+      label: "BarCode",
+      fieldName: "barCode",
+      hideDefaultActions: true,
+      wrap: true,
+      initialWidth: 400
+    }
+  ];
+  //杩斿搧鏄庣粏cols
+  get returnDetailCols() {
+    var cols = [];
+    cols.push({
+      label: "鍑哄簱鍗�",
+      fieldName: "orderUrl",
+      type: "url",
+      typeAttributes: { label: { fieldName: "orderNo" }, target: "_blank" },
+      hideDefaultActions: true,
+      wrapText: true
+    });
+    // cols.push({label:'鍑哄簱鍗�' , fieldName:'orderNo', hideDefaultActions: true});
+    cols.push({
+      label: "鍑哄簱鏃�",
+      fieldName: "prodOutDate",
+      wrapText: true,
+      hideDefaultActions: true,
+      initialWidth: 110
+    });
+    cols.push({
+      label: "娑堣�楀搧鍚嶇О",
+      fieldName: "prodName",
+      wrapText: true,
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 190
+    });
+    cols.push({
+      label: "鍑哄簱鐩殑",
+      fieldName: "summonsForDirctionDet",
+      wrapText: true,
+      hideDefaultActions: true,
+      initialWidth: 130
+    });
+    cols.push({
+      label: "瀹㈡埛鍚�",
+      fieldName: "hospitalName",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 130
+    });
+    cols.push({
+      label: "缁忛攢鍟�",
+      fieldName: "orderDealer",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 100
+    });
+    cols.push({
+      label: "BarCode",
+      fieldName: "barCode",
+      hideDefaultActions: true,
+      wrap: true,
+      initialWidth: 230
+    });
+    cols.push({
+      label: "浣跨敤鏈熼檺",
+      fieldName: "sterilizationLimit",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 110
+    });
+    cols.push({
+      label: "鍗曚綅",
+      fieldName: "boxPiece",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 50
+    });
+    cols.push({
+      label: "杩斿搧鏁伴噺",
+      type: "customReturnGoodInput",
+      typeAttributes: {
+        inputValue: { fieldName: "returnCount" },
+        boxPrice: { fieldName: "boxPiece" },
+        recordId: { fieldName: "recordId" }
+      },
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 100
+    });
+    cols.push({
+      label: "杩斿搧鍘熷洜",
+      type: "customTableInput",
+      typeAttributes: {
+        recordId: { fieldName: "recordId" },
+        inputValue: { fieldName: "returnReason" },
+        valueType: "Text"
+      },
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 100
+    });
+    // cols.push({label:'杩斿搧鍘熷洜' , fieldName:'returnReason', hideDefaultActions: true});
+    return cols;
+  }
+  //鍏ュ簱鏄庣粏cols
+  get inDetailCols() {
+    var cols = [];
+    cols.push({
+      label: "娑堣�楀搧鍚嶇О",
+      fieldName: "prodName",
+      hideDefaultActions: true,
+      wrapText: true
+    });
+    cols.push({
+      label: "BarCode",
+      fieldName: "barCodeNo",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 400
+    });
+    cols.push({
+      label: "浣跨敤鏈熼檺",
+      fieldName: "sterilizationlimitDate",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 100
+    });
+    cols.push({
+      label: "serialNoorLotNo",
+      fieldName: "serialNoorLotNo",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 140
+    });
+    cols.push({
+      label: "tracingCode",
+      fieldName: "tracingCodeNo",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 140
+    });
+    if (this.returnFLGbln) {
+      cols.push({
+        label: "杩斿搧鍘熷洜",
+        fieldName: "ReturnReason",
+        hideDefaultActions: true,
+        wrapText: true,
+        initialWidth: 150
+      });
+    }
+    return cols;
+  }
+  //閿欒鏄庣粏cols
+  @track errorDetailCols = [
+    // {label:'娑堣�楀搧璁㈠崟' , fieldName:'consumableOrderMinor', hideDefaultActions: true,wrapText:true},
+    {
+      label: "娑堣�楀搧璁㈠崟",
+      fieldName: "consumableOrderUrl",
+      type: "url",
+      typeAttributes: {
+        label: { fieldName: "consumableOrderMinorName" },
+        target: "_blank"
+      },
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 180
+    },
+    {
+      label: "娑堣�楀搧鍚嶇О",
+      fieldName: "prodName",
+      hideDefaultActions: true,
+      wrapText: true
+    },
+    {
+      label: "BarCode",
+      fieldName: "barCode",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 400
+    },
+    {
+      label: "鍗曚綅",
+      fieldName: "boxPiece",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 60
+    },
+    {
+      label: "鏁伴噺",
+      fieldName: "intMark",
+      hideDefaultActions: true,
+      wrapText: true,
+      initialWidth: 100,
+      cellAttributes: { alignment: "right" }
+    },
+    {
+      label: "閿欒鍘熷洜",
+      fieldName: "ErrorReason",
+      hideDefaultActions: true,
+      initialWidth: 280,
+      wrapText: true
+    }
+  ];
+
+  // 鑾峰彇鍙傛暟
+  @wire(CurrentPageReference)
+  getStateParameters(currentPageReference) {
+    console.log("CurrentPageReference");
+    if (currentPageReference) {
+      this.arrType = currentPageReference.state?.ArrType;
+      this.eSetId = currentPageReference.state?.ESetId;
+    }
+  }
+
+  get showOrderDetail() {
+    if (this.eSetId != "" && this.eSetId != null) {
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  renderedCallback() {
+    if (!this.stylesLoaded) {
+      Promise.all([loadStyle(this, WrappedHeaderTable)])
+        .then(() => {
+          console.log("Custom styles loaded");
+          this.stylesLoaded = true;
+        })
+        .catch((error) => {
+          console.error("Error loading custom styles");
+        });
+    }
+  }
+
+  //鍒濆鍖�
+  connectedCallback() {
+    init({ arrType: this.arrType, eSetId: this.eSetId })
+      .then((result) => {
+        this.isNoteStay = result.isNoteStay;
+        this.arrController = result.arrGoodCon;
+        console.log("this.arrController:" + this.arrController);
+        if (result.result == "Success") {
+          this.saveFLGbln = result.saveFLGbln;
+          this.returnFLGbln = result.returnFLGbln;
+          this.coc = result.coc;
+          this.cocId = result.coc.Id;
+          this.warningMsgs = result.warningMsgList;
+          this.errorMsgs = result.errorMsgList;
+          this.showSpinner = false;
+          this.showPage = true;
+        } else {
+          this.warningMsgs = result.warningMsgList;
+          this.errorMsgs = result.errorMsgList;
+          this.showSpinner = false;
+          this.showPage = true;
+          console.log("error:" + result.errorMsg);
+          this.showMyToast("鍒濆鍖栭〉闈㈠け璐�", result.errorMsg, "error");
+        }
+      })
+      .catch((error) => {
+        this.showSpinner = false;
+        this.showPage = true;
+        console.log("error:" + JSON.stringify(error));
+        this.showMyToast("鍒濆鍖栭〉闈㈠け璐�", JSON.stringify(error), "error");
+      });
+  }
+
+  //barcode change
+  barcodeChange(event) {
+    this.barcode = event.detail.value;
+  }
+
+  //鏍规嵁barcode鎼滅储
+  barcodeEntrys() {
+    this.showSpinner = true;
+    searchProduct({
+      barcode: this.barcode,
+      arrControllerStr: this.arrController
+    })
+      .then((result) => {
+        this.arrController = result.arrGoodCon;
+        if (result.result == "Success") {
+          this.saveFLGbln = result.saveFLGbln;
+          this.returnFLGbln = result.returnFLGbln;
+          this.coc = result.coc;
+          this.warningMsgs = result.warningMsgList;
+          this.errorMsgs = result.errorMsgList;
+          this.consumableInventory = result.consumableInventory;
+          this.detailsSummary = result.detailsSummary;
+          for (var i in this.detailsSummary) {
+            if (this.detailsSummary[i].Prod != null) {
+              this.detailsSummary[i]["recordId"] =
+                this.detailsSummary[i].Prod.Id;
+              this.detailsSummary[i]["assetModelNo"] =
+                this.detailsSummary[i].Prod.Asset_Model_No__c;
+              this.detailsSummary[i]["prodName"] =
+                this.detailsSummary[i].Prod.Name__c;
+            }
+          }
+          console.log(
+            "this.detailsSummary:" + JSON.stringify(this.detailsSummary)
+          );
+          this.consumableorderdetailsRecords =
+            result.consumableorderdetailsRecords;
+          var consumableorderdetailsRecordsview = [];
+          for (var i in this.consumableorderdetailsRecords) {
+            consumableorderdetailsRecordsview.push(
+              this.consumableorderdetailsRecords[i]
+            );
+          }
+          for (var i in this.consumableInventory) {
+            consumableorderdetailsRecordsview.push(this.consumableInventory[i]);
+          }
+          this.consumableorderdetailsRecordsview =
+            consumableorderdetailsRecordsview;
+          for (var i in this.consumableorderdetailsRecordsview) {
+            if (this.consumableorderdetailsRecordsview[i].Prod != null) {
+              this.consumableorderdetailsRecordsview[i]["recordId"] =
+                this.consumableorderdetailsRecordsview[i].Prod.Id;
+              this.consumableorderdetailsRecordsview[i]["prodName"] =
+                this.consumableorderdetailsRecordsview[i].Prod.Name__c;
+            }
+            if (this.consumableorderdetailsRecordsview[i].esd != null) {
+              this.consumableorderdetailsRecordsview[i][
+                "productPackingListManual"
+              ] =
+                this.consumableorderdetailsRecordsview[
+                  i
+                ].esd.ProductPacking_list_manual__c;
+              this.consumableorderdetailsRecordsview[i]["status"] =
+                this.consumableorderdetailsRecordsview[i].esd.CFDA_Status__c;
+              this.consumableorderdetailsRecordsview[i][
+                "reportProductApprobation"
+              ] =
+                this.consumableorderdetailsRecordsview[
+                  i
+                ].esd.Report_Product_Approbation__c;
+              this.consumableorderdetailsRecordsview[i]["barCode"] =
+                this.consumableorderdetailsRecordsview[i].esd.Bar_Code__c;
+            }
+          }
+          console.log("len1:" + this.consumableorderdetailsRecords.length);
+          console.log("len2:" + this.consumableorderdetailsRecordsview.length);
+          console.log(
+            "this.consumableorderdetailsRecordsview:" +
+              JSON.stringify(this.consumableorderdetailsRecordsview)
+          );
+          this.showGoodsofReturnList = result.showGoodsofReturnList;
+          var showGoodsofReturnListView = [];
+          for (var i in this.showGoodsofReturnList) {
+            showGoodsofReturnListView.push(this.showGoodsofReturnList[i]);
+          }
+          for (var i in this.consumableInventory) {
+            showGoodsofReturnListView.push(this.consumableInventory[i]);
+          }
+          this.showGoodsofReturnListView = showGoodsofReturnListView;
+          for (var i in this.showGoodsofReturnListView) {
+            if (this.showGoodsofReturnListView[i].Prod != null) {
+              this.showGoodsofReturnListView[i]["prodName"] =
+                this.showGoodsofReturnListView[i].Prod.Name__c;
+            }
+            if (this.showGoodsofReturnListView[i].esd != null) {
+              if (
+                this.showGoodsofReturnListView[i].esd
+                  .Consumable_Shipment_order__c != "" &&
+                this.showGoodsofReturnListView[i].esd
+                  .Consumable_Shipment_order__c != null
+              ) {
+                this.showGoodsofReturnListView[i]["recordId"] =
+                  this.showGoodsofReturnListView[
+                    i
+                  ].esd.Consumable_Shipment_order__c;
+                this.showGoodsofReturnListView[i]["orderUrl"] =
+                  "/lexsummonscreat?ESetid=" +
+                  this.showGoodsofReturnListView[i].esd
+                    .Consumable_Shipment_order__c;
+                this.showGoodsofReturnListView[i]["orderNo"] =
+                  this.showGoodsofReturnListView[
+                    i
+                  ].esd.Consumable_Shipment_order__r.Name;
+              } else if (
+                this.showGoodsofReturnListView[i].esd
+                  .Consumable_Sale_order__c != "" &&
+                this.showGoodsofReturnListView[i].esd
+                  .Consumable_Sale_order__c != null
+              ) {
+                this.showGoodsofReturnListView[i]["recordId"] =
+                  this.showGoodsofReturnListView[
+                    i
+                  ].esd.Consumable_Sale_order__c;
+                this.showGoodsofReturnListView[i]["orderUrl"] =
+                  "/lexsummonscreat?ESetid=" +
+                  this.showGoodsofReturnListView[i].esd
+                    .Consumable_Sale_order__c;
+                this.showGoodsofReturnListView[i]["orderNo"] =
+                  this.showGoodsofReturnListView[
+                    i
+                  ].esd.Consumable_Sale_order__r.Name;
+              }
+              this.showGoodsofReturnListView[i]["prodOutDate"] =
+                this.showGoodsofReturnListView[i].esd.Product_OutDate__c;
+              this.showGoodsofReturnListView[i]["summonsForDirctionDet"] =
+                this.showGoodsofReturnListView[i].esd.SummonsForDirction_det__c;
+              this.showGoodsofReturnListView[i]["hospitalName"] =
+                this.showGoodsofReturnListView[i].esd.HospItal_Name__c;
+              this.showGoodsofReturnListView[i]["orderDealer"] =
+                this.showGoodsofReturnListView[i].esd.Order_Dealer_Info__c;
+              this.showGoodsofReturnListView[i]["barCode"] =
+                this.showGoodsofReturnListView[i].esd.Bar_Code__c;
+              this.showGoodsofReturnListView[i]["sterilizationLimit"] =
+                this.showGoodsofReturnListView[i].esd.Sterilization_limit__c;
+              this.showGoodsofReturnListView[i]["boxPiece"] =
+                this.showGoodsofReturnListView[i].esd.Box_Piece__c;
+              this.showGoodsofReturnListView[i]["returnCount"] =
+                this.showGoodsofReturnListView[i].esd.Rrturn_count__c;
+              console.log(
+                "returnCount:" +
+                  this.showGoodsofReturnListView[i].esd.Rrturn_count__c
+              );
+              this.showGoodsofReturnListView[i]["returnReason"] =
+                this.showGoodsofReturnListView[i].esd.Return_reason__c;
+            }
+          }
+          console.log("len1:" + this.showGoodsofReturnList.length);
+          console.log("len2:" + this.showGoodsofReturnListView.length);
+          console.log(
+            "this.showGoodsofReturnListView:" +
+              JSON.stringify(this.showGoodsofReturnListView)
+          );
+          // this.consumableInventory = result.consumableInventory;
+          // for(var i in this.consumableInventory){
+          //     if(this.consumableInventory[i].Prod != null){
+          //         this.consumableInventory[i]['recordId'] = this.consumableInventory[i].Prod.Id;
+          //         this.consumableInventory[i]['prodName'] = this.consumableInventory[i].Prod.Name__c;
+          //     }
+          // }
+          console.log(
+            "this.consumableInventory:" +
+              JSON.stringify(this.consumableInventory)
+          );
+          this.consumableorderdetailsRecordserror =
+            result.consumableorderdetailsRecordserror;
+          for (var i in this.consumableorderdetailsRecordserror) {
+            if (this.consumableorderdetailsRecordserror[i].Prod != null) {
+              this.consumableorderdetailsRecordserror[i]["recordId"] =
+                this.consumableorderdetailsRecordserror[i].Prod.Id;
+              this.consumableorderdetailsRecordserror[i]["prodName"] =
+                this.consumableorderdetailsRecordserror[i].Prod.Name__c;
+            }
+            if (this.consumableorderdetailsRecordserror[i].esd != null) {
+              this.consumableorderdetailsRecordserror[i][
+                "consumableOrderMinor"
+              ] =
+                this.consumableorderdetailsRecordserror[
+                  i
+                ].esd.Consumable_order_minor__c;
+              if (
+                this.consumableorderdetailsRecordserror[i].esd
+                  .Consumable_order_minor__c != null
+              ) {
+                this.consumableorderdetailsRecordserror[i][
+                  "consumableOrderMinorName"
+                ] =
+                  this.consumableorderdetailsRecordserror[
+                    i
+                  ].esd.Consumable_order_minor__r.Name;
+                this.consumableorderdetailsRecordserror[i][
+                  "consumableOrderUrl"
+                ] =
+                  "/s/detail/" +
+                  this.consumableorderdetailsRecordserror[i].esd
+                    .Consumable_order_minor__c;
+              }
+              this.consumableorderdetailsRecordserror[i]["barCode"] =
+                this.consumableorderdetailsRecordserror[i].esd.Bar_Code__c;
+              this.consumableorderdetailsRecordserror[i]["boxPiece"] =
+                this.consumableorderdetailsRecordserror[i].esd.Box_Piece__c;
+            }
+          }
+          console.log(
+            "this.consumableorderdetailsRecordserror:" +
+              JSON.stringify(this.consumableorderdetailsRecordserror)
+          );
+          this.showSpinner = false;
+          this.showMyToast("鑾峰彇鎴愬姛", "", "success");
+        } else {
+          this.showSpinner = false;
+          this.warningMsgs = result.warningMsgList;
+          this.errorMsgs = result.errorMsgList;
+          console.log("error:" + result.errorMsg);
+          this.showMyToast("鑾峰彇澶辫触", result.errorMsg, "error");
+        }
+      })
+      .catch((error) => {
+        this.showSpinner = false;
+        console.log("error:" + error);
+        this.showMyToast("鑾峰彇澶辫触", error, "error");
+      });
+  }
+
+  //杩斿搧鏁伴噺change
+  returnCountChange(event) {
+    var value = event.detail.data.value;
+    var boxPrice = event.detail.data.boxPrice;
+    var recordId = event.detail.data.recordId;
+    console.log("杩斿搧鏁伴噺:" + value + boxPrice + "---" + recordId);
+    for (var i in this.showGoodsofReturnList) {
+      if (this.showGoodsofReturnList[i]["recordId"] == recordId) {
+        if (this.showGoodsofReturnList[i].canEdit) {
+          this.showGoodsofReturnList[i].esd.Rrturn_count__c = 1;
+          this.showGoodsofReturnList[i]["returnCount"] =
+            this.showGoodsofReturnList[i].esd.Rrturn_count__c;
+        } else {
+          this.showGoodsofReturnList[i].esd.Rrturn_count__c = value;
+          this.showGoodsofReturnList[i]["returnCount"] =
+            this.showGoodsofReturnList[i].esd.Rrturn_count__c;
+        }
+      }
+    }
+  }
+
+  //杩斿搧鍘熷洜change
+  returnReasonChange(event) {
+    var recordId = event.detail.data.recordId;
+    var value = event.detail.data.value;
+    console.log("杩斿搧鍘熷洜:" + value + "---" + recordId);
+    for (var i in this.showGoodsofReturnList) {
+      if (this.showGoodsofReturnList[i]["recordId"] == recordId) {
+        this.showGoodsofReturnList[i].esd.Return_reason__c = value;
+        this.showGoodsofReturnList[i]["returnReason"] =
+          this.showGoodsofReturnList[i].esd.Return_reason__c;
+      }
+    }
+  }
+
+  // 鍒拌揣纭
+  arriveGoodsConfim() {
+    this.showSpinner = true;
+    arriveGoodsConfim({ arrControllerStr: this.arrController })
+      .then((result) => {
+        this.arrController = result.arrGoodCon;
+        if (result.result == "Success") {
+          this.showSpinner = false;
+          this.warningMsgs = result.warningMsgList;
+          this.errorMsgs = result.errorMsgList;
+          var url = result.url;
+          const config = {
+            type: "standard__webPage",
+            attributes: {
+              url: url
+            }
+          };
+          this[NavigationMixin.Navigate](config);
+        } else {
+          this.showSpinner = false;
+          this.warningMsgs = result.warningMsgList;
+          this.errorMsgs = result.errorMsgList;
+          console.log("error1:" + result.errorMsg);
+          this.showMyToast("鍒拌揣纭澶辫触", result.errorMsg, "error");
+        }
+      })
+      .catch((error) => {
+        this.showSpinner = false;
+        console.log("error2:" + error);
+        this.showMyToast("鍒拌揣纭澶辫触", error, "error");
+      });
+  }
+
+  // 鐧诲綍杩斿搧
+  updateGoodsOfReturn() {
+    this.showSpinner = true;
+    updateGoodsOfReturn({
+      arrControllerStr: this.arrController,
+      showGoodsofReturnListStr: JSON.stringify(this.showGoodsofReturnList)
+    })
+      .then((result) => {
+        this.showSpinner = false;
+        this.arrController = result.arrGoodCon;
+        if (result.result == "Success") {
+          this.warningMsgs = result.warningMsgList;
+          this.errorMsgs = result.errorMsgList;
+          var url = result.url;
+          const config = {
+            type: "standard__webPage",
+            attributes: {
+              url: url
+            }
+          };
+          this[NavigationMixin.Navigate](config);
+        } else {
+          this.showSpinner = false;
+          this.warningMsgs = result.warningMsgList;
+          this.errorMsgs = result.errorMsgList;
+          console.log("error1:" + result.errorMsg);
+          this.showMyToast("鐧诲綍杩斿搧澶辫触", result.errorMsg, "error");
+        }
+      })
+      .catch((error) => {
+        this.showSpinner = false;
+        console.log("error2:" + JSON.stringify(error));
+        this.showMyToast("鐧诲綍杩斿搧澶辫触", error, "error");
+      });
+  }
+
+  showMyToast(title, message, variant) {
+    console.log("show custom message");
+    var iconName = "";
+    var content = "";
+    if (variant == "success") {
+      iconName = "utility:check";
+    } else {
+      iconName = "utility:error";
+    }
+    if (message != "") {
+      content =
+        "<h2><strong>" + title + "<strong/></h2><h5>" + message + "</h5>";
+    } else {
+      content = "<h2><strong>" + title + "<strong/></h2>";
+    }
+    this.template
+      .querySelector("c-common-toast")
+      .showToast(variant, content, iconName, 10000);
+    // var mode;
+    // if(this.isNoteStay){
+    //     mode ='sticky';
+    // }else{
+    //     mode = 'dismissable';
+    // }
+    // const evt = new ShowToastEvent({
+    //     title: title,
+    //     message: message,
+    //     variant: variant,
+    //     mode: mode
+    // });
+    // this.dispatchEvent(evt);
+  }
+}
diff --git a/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.js-meta.xml b/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.js-meta.xml
new file mode 100644
index 0000000..0866cdc
--- /dev/null
+++ b/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.js-meta.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>56.0</apiVersion>
+    <isExposed>true</isExposed>
+    <targets>
+        <target>lightningCommunity__Page</target>
+        <target>lightningCommunity__Default</target>
+    </targets>
+</LightningComponentBundle>

--
Gitblit v1.9.1