From af7b716a60d889acea95560abba0e46eee008b8f Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期三, 05 七月 2023 13:54:50 +0800
Subject: [PATCH] backup0705
---
force-app/main/default/classes/LexCancelRemoveBoxControllerTest.cls | 953
manifest/LEXC01packagelexcommunitynew.xml | 98
force-app/main/default/classes/LexArriveGoodsMainControllerTest.cls | 161
force-app/main/default/classes/AssetHandler.cls | 2157
force-app/main/default/classes/LexConsumableControllerTest.cls | 1377
force-app/main/default/classes/LexProductLimitEditControllerTest.cls | 70
force-app/main/default/classes/LexInventoryViewControllerTest.cls | 1273
force-app/main/default/classes/LexLicenceReminderControllerTest.cls-meta.xml | 5
manifest/LEXC02packagelexcommunityupdate.xml | 23
force-app/main/default/classes/LookupSearchResultTest.cls-meta.xml | 5
force-app/main/default/classes/LexConsumableGoodsInfoTest.cls | 1113
force-app/main/default/classes/LexArriveGoodsControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexArriveGoodsMainControllerTest.cls-meta.xml | 5
force-app/main/default/classes/ArriveGoodsControllerTestV2.cls | 234
force-app/main/default/classes/LexSearchHospitalControllerTest.cls | 9
force-app/main/default/classes/LexOverdueStockControllerTest.cls-meta.xml | 5
force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportHelper.js | 7390 ++--
force-app/main/default/classes/LexOutboundorderImportController.cls | 1907
force-app/main/default/classes/ArriveGoodsControllerTestV2.cls-meta.xml | 5
force-app/main/default/classes/LexConsumableAccountControllerTest.cls | 189
force-app/main/default/classes/LexInventoryControllerTest.cls | 1179
force-app/main/default/classes/LexInventoryListControllerTest.cls | 172
force-app/main/default/classes/LexConInvoiceViewControllerTest.cls-meta.xml | 5
force-app/main/default/aura/WeeklyReport/WeeklyReport.cmp | 1600
force-app/main/default/classes/LexSummonsCreatControllerTest.cls | 292
force-app/main/default/classes/LexConsumableGoodsInfoTest.cls-meta.xml | 5
force-app/main/default/classes/LexConsumableAccountSOQLTest.cls | 148
force-app/main/default/classes/LexSearchContractControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexConInvoiceListTest.cls | 205
force-app/main/default/classes/NewAndEditLeadController.cls | 1
force-app/main/default/permissionsets/Community_Consumable_LEX_PS.permissionset-meta.xml | 161
force-app/main/default/classes/LexCancelRemoveBoxControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexConInvoiceViewController.cls | 3507 +-
force-app/main/default/classes/LexInventoryListControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexSaleAndDeliveryControllerTest.cls | 115
force-app/main/default/classes/Product2Handler.cls | 1079
force-app/main/default/aura/WeeklyReport/WeeklyReportController.js | 630
force-app/main/default/classes/LookupSearchResultTest.cls | 63
force-app/main/default/classes/LexUtilityTest.cls | 20
force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReport.cmp | 2035
force-app/main/default/classes/LayoutDescriberHelper.cls | 3
force-app/main/default/classes/LexInventoryViewControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexArriveGoodsControllerTest1.cls-meta.xml | 5
force-app/main/default/classes/LexSearchContractControllerTest.cls | 84
force-app/main/default/classes/lexSearchAgencyHospitalControllerTest.cls-meta.xml | 5
force-app/main/default/pages/OFSInsReportLayout.page | 2129
force-app/main/default/classes/Batch_FixAttachmentToFiles.cls | 116
force-app/main/default/aura/WeeklyReport/WeeklyReport.css | 164
force-app/main/default/classes/LexSaleAndDeliveryControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexSummonsCreatController.cls | 6204 ++-
force-app/main/default/classes/LexConsumableOrderManageControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexOverdueStockController.cls | 787
force-app/main/default/pages/StraightBackAddress.page-meta.xml | 4
force-app/main/default/classes/LexInventoryListController.cls | 243
force-app/main/default/classes/ResponseBodyLWCTest.cls | 18
force-app/main/default/classes/LexOverdueStockControllerTest.cls | 245
force-app/main/default/classes/LexArriveGoodsControllerTest.cls | 483
force-app/main/default/classes/LexSearchHospitalControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexConsumableAccountController.cls | 965
force-app/main/default/classes/LexTopPageControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexSaleOrderController.cls | 2800 +
force-app/main/default/classes/LexArriveGsDetailsControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexSaleOrderControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexUpAccountProLimitControllerTest.cls | 164
force-app/main/default/classes/LexSaleOrderControllerTest.cls | 1919 +
force-app/main/default/classes/LexInventoryControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexLicenceReminderControllerTest.cls | 226
force-app/main/default/classes/LexConInvoiceViewControllerTest.cls | 4125 ++
force-app/main/default/classes/lexSearchAgencyHospitalControllerTest.cls | 107
force-app/main/default/classes/LexInventoryController.cls | 3008 +
force-app/main/default/classes/LexUpAccountProLimit.cls | 301
force-app/main/default/classes/LexConInvoiceListTest.cls-meta.xml | 5
force-app/main/default/classes/LexConsumableOrderManageControllerTest.cls | 132
force-app/main/default/classes/LexConsumableController.cls | 4940 +-
force-app/main/default/aura/WeeklyReport/WeeklyReportHelper.js | 5734 ++-
manifest/package.xml | 5
force-app/main/default/classes/LexConInvoicedetailsControllerTest.cls | 776
force-app/main/default/classes/LexConsumableAccountInfoControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexOutboundorderImportControllerTest.cls | 682
force-app/main/default/classes/DealerInquiryModifyStateControllerTest.cls | 844
force-app/main/default/classes/LexCancelRemoveBoxController.cls | 1388
force-app/main/default/classes/ResponseBodyLWCTest.cls-meta.xml | 5
force-app/main/default/classes/LexRemoveBoxControllerTest.cls | 806
force-app/main/default/classes/LexConsumableAccountSOQLTest.cls-meta.xml | 5
force-app/main/default/classes/LexRemoveBoxControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexTopPageControllerTest.cls | 460
force-app/main/default/classes/LexConsumableAccountSOQL.cls | 64
force-app/main/default/classes/LexConsumableAccountControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexSummonsCreatControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexArriveGoodsControllerTest1.cls | 240
force-app/main/default/classes/RentalApplyEquipmentSetDetailHandler.cls | 7513 +---
force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.html | 593
force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.js | 1222
force-app/main/default/classes/LexConsumableControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexOutboundorderImportControllerTest.cls-meta.xml | 5
.vscode/settings.json | 1
force-app/main/default/classes/AssetHandler.cls-meta.xml | 4
force-app/main/default/classes/LexUpAccountProLimitControllerTest.cls-meta.xml | 5
force-app/main/default/pages/StraightBackAddress.page | 2358
force-app/main/default/classes/LexConsumableAccountInfoControllerTest.cls | 16
force-app/main/default/classes/LexProductLimitEditControllerTest.cls-meta.xml | 5
force-app/main/default/classes/LexArriveGsDetailsControllerTest.cls | 249
force-app/main/default/classes/ArriveGoodsControllerTest.cls | 6450 ++-
force-app/main/default/classes/LexConInvoicedetailsController.cls | 853
force-app/main/default/classes/LexUtilityTest.cls-meta.xml | 5
105 files changed, 55,795 insertions(+), 31,956 deletions(-)
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 7f69778..f2bf3ab 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -5,5 +5,6 @@
"**/.sfdx": true
},
"salesforcedx-vscode-core.show-cli-success-msg": false,
+ "salesforcedx-vscode-apex.java.home": "C:\\Users\\buli\\Documents\\Software\\JDK11\\",
"open-in-browser.default": "{\"opn-in-browser.default\":\"Microsoft Edge\"}"
}
diff --git a/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReport.cmp b/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReport.cmp
index 7f5d645..42b2d98 100644
--- a/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReport.cmp
+++ b/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReport.cmp
@@ -1,294 +1,455 @@
-<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: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="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="loginEdit" type="Boolean" default="false" />
- <aura:attribute name="modal_import_spinner" 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="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="loginEdit" type="Boolean" default="false" />
+ <aura:attribute name="modal_import_spinner" 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-->
+ <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="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-->
- <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="PIConfig" type="Map" />
+ <ltng:require scripts="{! $Resource.AWSService+'/AWSService.js' }" />
+ <ltng:require scripts="{! $Resource.jquery183minjs }" />
- <ltng:require scripts="{! $Resource.AWSService+'/AWSService.js' }" />
- <ltng:require scripts="{! $Resource.jquery183minjs }" />
-
- <!-- 鎵归噺娣诲姞鏃ユ姤 end-->
- <!--銉兗銉変腑...-->
- <aura:renderIf isTrue="{!v.login}">
- <aura:renderIf isTrue="{!!v.loginEdit}">
- <lightning:spinner alternativeText="Loading" size="medium" />
- </aura:renderIf>
+ <!-- 鎵归噺娣诲姞鏃ユ姤 end-->
+ <!--銉兗銉変腑...-->
+ <aura:renderIf isTrue="{!v.login}">
+ <aura:renderIf isTrue="{!!v.loginEdit}">
+ <!-- <div class="slds-spinner_container">
+ <div role="status" class="slds-spinner slds-spinner_medium slds-spinner_brand">
+ 聽 聽 <span class="slds-assistive-text">Loading</span>
+ 聽 聽 <div class="slds-spinner__dot-a"></div>
+ 聽 聽 <div class="slds-spinner__dot-b"></div>
+ </div>
+ </div> -->
+ <div
+ class="slds-spinner_container"
+ id="spinner"
+ style="position: fixed; top: 123px"
+ >
+ <div
+ role="status"
+ class="slds-spinner slds-spinner_medium slds-spinner_brand"
+ >
+ <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">
- <div class="slds-grid slds-wrap slds-grid--pull-padded">
- <div style="width: 150px;"></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 fontSize">
- 鍛�
- </div>
- <div
- class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12 fontSize">
- <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}" class="buttonFontSize" />
- </div>
- <div style="width: 400px;"
- class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--4-of-12 slds-large-size--4-of-12">
- <ui:button aura:id="copy_button" label="澶嶅埗" press="{!c.copy_button}" disabled="true"
- class="buttonFontSize" />
- <ui:button aura:id="delete_button" label="鍒犻櫎" press="{!c.delete_button}" disabled="true"
- class="buttonFontSize" />
- <ui:button aura:id="import" label="瀵煎叆" press="{!c.import}" class="buttonFontSize" />
- <ui:button aura:id="export" label="瀵煎嚭" press="{!c.export_condition}" class="buttonFontSize" />
- <!-- <ui:button aura:id="returnbutton" label="杩斿洖" press="{!c.return_main_page}" /> -->
- </div>
- </div>
+ </aura:renderIf>
+ <div aura:id="report" id="report">
+ <div class="slds-grid slds-wrap slds-grid--pull-padded">
+ <div style="width: 150px"></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 fontSize"
+ >
+ 鍛�
+ </div>
+ <div
+ class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12 fontSize"
+ >
+ <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}"
+ class="buttonFontSize"
+ />
+ </div>
+ <div
+ style="width: 400px"
+ class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--4-of-12 slds-large-size--4-of-12"
+ >
+ <ui:button
+ aura:id="copy_button"
+ label="澶嶅埗"
+ press="{!c.copy_button}"
+ disabled="true"
+ class="buttonFontSize"
+ />
+ <ui:button
+ aura:id="delete_button"
+ label="鍒犻櫎"
+ press="{!c.delete_button}"
+ disabled="true"
+ class="buttonFontSize"
+ />
+ <ui:button
+ aura:id="import"
+ label="瀵煎叆"
+ press="{!c.import}"
+ class="buttonFontSize"
+ />
+ <ui:button
+ aura:id="export"
+ label="瀵煎嚭"
+ press="{!c.export_condition}"
+ class="buttonFontSize"
+ />
+ <!-- <ui:button aura:id="returnbutton" label="杩斿洖" press="{!c.return_main_page}" /> -->
+ </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 fontSize" style="width:250px">
- <span class="slds-truncate" title="Name">鏃ユ姤缂栧彿</span>
- </th>
- <th class="table_header slds-text-title--caps fontSize">
- <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 fontSize" style="width:250px">
- <span class="slds-truncate" title="Name">鍖婚櫌</span>
- </th>
- <th class="table_header slds-text-title--caps fontSize">
- <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 fontSize">
- <span class="slds-truncate" title="Name">鎷滆浜�</span>
- <!-- {!v.fieldsmap.doctor2__c} 鎷滆浜� -->
- </th>
- <th class="table_header slds-text-title--caps fontSize">
- <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 fontSize">
- <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 fontSize">
- <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 fontSize">
- <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>
- <td scope="row" tabindex="0" class="slds-cell-edit fontSize">
- <div class="slds-grid slds-grid--align-spread" style="word-wrap: break-word;">
- {!item.Agency_Hospital__r.Name}
- </div>
- </td>
- <td role="gridcell" class="slds-cell-edit fontSize">
- <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 fontSize">
- <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 fontSize">
- <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 fontSize">
- <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>
+ <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 fontSize"
+ style="width: 250px"
+ >
+ <span class="slds-truncate" title="Name">鏃ユ姤缂栧彿</span>
+ </th>
+ <th class="table_header slds-text-title--caps fontSize">
+ <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 fontSize"
+ style="width: 250px"
+ >
+ <span class="slds-truncate" title="Name">鍖婚櫌</span>
+ </th>
+ <th class="table_header slds-text-title--caps fontSize">
+ <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 fontSize">
+ <span class="slds-truncate" title="Name">鎷滆浜�</span>
+ <!-- {!v.fieldsmap.doctor2__c} 鎷滆浜� -->
+ </th>
+ <th class="table_header slds-text-title--caps fontSize">
+ <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 fontSize">
+ <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 fontSize">
+ <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 fontSize">
+ <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>
+ <td scope="row" tabindex="0" class="slds-cell-edit fontSize">
+ <div
+ class="slds-grid slds-grid--align-spread"
+ style="word-wrap: break-word"
+ >
+ {!item.Agency_Hospital__r.Name}
</div>
- </aura:set>
- </aura:renderIf>
+ </td>
+ <td role="gridcell" class="slds-cell-edit fontSize">
+ <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 fontSize">
+ <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 fontSize">
+ <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 fontSize">
+ <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>
- <!-- 鎵归噺娣诲姞鏃ユ姤 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">
- <aura:renderIf isTrue="{!v.modal_import_spinner}">
- <lightning:spinner alternativeText="Loading" size="medium" />
- </aura:renderIf>
- <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>
+ <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"
+ >
+ <aura:renderIf isTrue="{!v.modal_import_spinner}">
+ <lightning:spinner alternativeText="Loading" size="medium" />
+ </aura:renderIf>
+ <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 class="slds-modal slds-fade-in-open slds-hide" aura:id="errorDiv01" style="z-index: 10001">
+ </div>
+ </div>
+ <!-- <div class="slds-modal slds-fade-in-open slds-hide" aura:id="errorDiv01" style="z-index: 10001">
<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">
@@ -306,515 +467,857 @@
</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 buttonFontSize"
- press="{!c.close_import}" />
+ <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 buttonFontSize"
+ press="{!c.close_import}"
+ />
+ </div>
+ <div
+ class="slds-modal__content slds-scrollable slds-grow slds-p-around--medium fontSize"
+ >
+ <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 fontSize"
+ value="{!v.TableContent}"
+ />
+ <div class="slds-p-around--large slds-align--absolute-center">
+ <lightning:button
+ label="淇濆瓨"
+ variant="brand"
+ onclick="{!c.processFileContent}"
+ class="buttonFontSize"
+ />
+ <lightning:button
+ label="鍙栨秷"
+ variant="brand"
+ onclick="{!c.cancel}"
+ class="buttonFontSize"
+ />
</div>
- <div class="slds-modal__content slds-scrollable slds-grow slds-p-around--medium fontSize">
- <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 fontSize"
- value="{!v.TableContent}" />
- <div class="slds-p-around--large slds-align--absolute-center">
- <lightning:button label="淇濆瓨" variant="brand" onclick="{!c.processFileContent}"
- class="buttonFontSize" />
- <lightning:button label="鍙栨秷" variant="brand" onclick="{!c.cancel}" class="buttonFontSize" />
- </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;overflow-x:scroll">
- <lightning:datatable keyField="id" data="{! v.errorData }"
- columns="{! v.errorColumns }" hideCheckboxColumn="true" />
- </div>
- </div>
- </aura:if>
- </aura:set>
-
- </aura:if>
- </div>
- </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; overflow-x: scroll">
+ <lightning:datatable
+ keyField="id"
+ data="{! v.errorData }"
+ columns="{! v.errorColumns }"
+ hideCheckboxColumn="true"
+ />
+ </div>
+ </div>
+ </aura:if>
+ </aura:set>
+ </aura:if>
+ </div>
</div>
- <div aura:id="modal_importbg" class="disp_none slds-backdrop slds-backdrop--open"></div>
- <!-- 鎵归噺娣诲姞鏃ユ姤 end-->
+ </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}" />
+ <!-- 鎵归噺瀵煎嚭鏃ユ姤 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-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
+ 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>
+ <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_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
+ 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 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>
+ <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 class="slds-modal__content slds-grow slds-p-around--medium" style="position: relative;">
- <aura:renderIf isTrue="{!v.loginEdit}">
- <lightning:spinner alternativeText="Loading" size="medium" style="width: 100%; height: 100%;"/>
- </aura:renderIf>
- <div class="slds-modal__header">
- <h2 id="headerTarget" class="slds-text-heading--medium">
- 鏃ユ姤({!v.selected_date} {!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-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-7 slds-large-size--1-of-7">
- 娲诲姩鏃�
- <lightning:input type="date" value="{!v.data.Report_Date__c}" aura:id="input-report-date"
- variant="label-hidden" />
+ </div>
+ </div>
+ </div>
+
+ <div
+ class="slds-modal__content slds-grow slds-p-around--medium"
+ style="position: relative"
+ >
+ <aura:renderIf isTrue="{!v.loginEdit}">
+ <lightning:spinner
+ alternativeText="Loading"
+ size="medium"
+ style="width: 100%; height: 100%"
+ />
+ </aura:renderIf>
+ <div class="slds-modal__header">
+ <h2 id="headerTarget" class="slds-text-heading--medium">
+ 鏃ユ姤({!v.selected_date} {!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-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-7 slds-large-size--1-of-7"
+ >
+ 娲诲姩鏃�
+ <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-7 slds-large-size--1-of-7"
+ 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>
- <!-- 鍖婚櫌 -->
- <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-7 slds-large-size--1-of-7"
- 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-7 slds-large-size--1-of-7">
- {!v.fieldsmap.Department_Cateogy__c}
- <!-- <ui:inputText aura:id="select_department" class="slds-select"
+ </span>
+ </li>
+ </aura:iteration>
+ </ul>
+ </div>
+ </div>
+ <!-- 绉戝鍒嗙被 -->
+ <div
+ class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-7 slds-large-size--1-of-7"
+ >
+ {!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-7 slds-large-size--1-of-7"
- 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-7 slds-large-size--1-of-7">
- {!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-7 slds-large-size--1-of-7"
- style="width: 145px;">
- 鎷滆浜�
- <ui:inputSelect aura:id="select_doctor" class="slds-select" change="{!c.doctor_change}" />
- </div>
- <!-- <p hidden="hidden"> -->
+ <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-7 slds-large-size--1-of-7"
+ 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-7 slds-large-size--1-of-7"
+ >
+ {!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-7 slds-large-size--1-of-7"
+ 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-7 slds-large-size--1-of-7">
- <br />
- <ui:button label="鏂板缓" class="slds-button" press="{!c.createCon}" disabled="true"
- aura:id="new_con" />
- </div>
+ <div
+ class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-7 slds-large-size--1-of-7"
+ >
+ <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-5">
- 浜у搧鍒嗙被(绗笁鍒嗙被)
- <ui:inputSelect aura:id="select_ProductClassification" class="slds-select"
- change="{!c.selectProductClassification}" />
+ <!-- </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-5"
+ >
+ 浜у搧鍒嗙被(绗笁鍒嗙被)
+ <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-5"
+ 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>
- <!-- 浣跨敤浜у搧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-5"
- 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>
+ </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-5"
+ 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>
- <!-- 浣跨敤浜у搧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-5"
- 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>
+ </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-5"
+ 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>
- <!-- 浣跨敤浜у搧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-5"
- 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-5">
- {!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-5">
- {!v.fieldsmap.ConsumptionOfConsumables__c}
- <!-- <ui:inputText aura:id="select_ConsumptionOfConsumables" class="slds-select"
+ </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-5"
+ >
+ {!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-5"
+ >
+ {!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"
+ <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">
- <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_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>
- </div>
- </aura:renderIf>
+ <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>
-
-
-
- <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 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>
- </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>
+ <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_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>
- <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:renderIf>
+ </div>
</div>
+ </div>
+ <div
+ aura:id="modal_bg"
+ class="disp_none slds-backdrop slds-backdrop--open"
+ ></div>
-</aura:component>
\ No newline at end of file
+ <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>
diff --git a/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportHelper.js b/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportHelper.js
index bc0f6c7..5cac1fd 100644
--- a/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportHelper.js
+++ b/force-app/main/default/aura/RetrospectiveWeeklyReport/RetrospectiveWeeklyReportHelper.js
@@ -1,3324 +1,4120 @@
({
- doinit: function (component, event, helper) {
- document.title = "杩芥函鏃ユ姤";
-
- 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
-
- 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'));
+ doinit: function (component, event, helper) {
+ document.title = "杩芥函鏃ユ姤";
- component.set('v.PIConfig', res.PIConfig);// 20220222 PI鏀归�� by Bright
- component.set('v.login', false);
- }
- else {
- //component.set('v.errorMessage', 'doinit failed.');
- this.error('doinit failed.');
- this.showErrorToast(component);
- component.set('v.login', false);
- }
- });
- $A.enqueueAction(action);
- },
- doinitSave: function (component, event, helper) {
- document.title = "杩芥函鏃ユ姤";
- component.set('v.loginEdit', true);
- this.report_date_list(component, event, helper, 5);
- 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
-
- 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'));
+ 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
- component.set('v.PIConfig', res.PIConfig);// 20220222 PI鏀归�� by Bright
- component.set('v.loginEdit', false);
- }
- else {
- //component.set('v.errorMessage', 'doinit failed.');
- this.error('doinit failed.');
- this.showErrorToast(component);
- component.set('v.loginEdit', 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;
- }
-
- 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.loginEdit', 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', '');
- 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];
- }
- }
-
- 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.loginEdit', false);
- }, staticResourceAgencyContact.token);
- } else {
- component.set('v.loginEdit', false);
- }
- }
- } else {
- component.set('v.list_message', 'no_data');
- component.set('v.loginEdit', false);
- }
-
- }
- else {
- //component.set('v.errorMessage', 'get_reports failed.');
- this.error('get_reports failed.');
- this.showErrorToast(component);
- component.set('v.loginEdit', 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) {
-
- 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']);
- }
- ;
-
- 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);
- }
- }
- }
- },
- toggle_report_edit: 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');
- component.set('v.loginEdit',true);
- //澶嶅埗 鍜岀紪杈� 鍥炴樉闂鍦ㄨ繖閲岄潰
- 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_edit(component);
- } else {
- component.set('v.default_select_doctor_id', select_data['doctor2__c']);
- this.set_doctor_list_edit(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']);
- }
- ;
-
- 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);
- }
- }
-
- }
- //component.set('v.loginEdit',false);
- },
- //鍏抽棴椤甸潰鏄� 灏忕殑鎻愮ず妗嗘槸鍚︽斁寮冩柊寤烘棩鎶�
- 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);
- 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) {
-
- 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) {
-
- var select_report_data = component.get('v.select_report_data_radio');
- if (confirm('鏄惁鍒犻櫎璇ユ暟鎹紵')) {
-
- 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) {
-
- 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) {
- //component.set('v.loginEdit', true);
- debugger
- this.allclear(component);
- //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_edit(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');
- }
-
- // 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.loginEdit', 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') {
- debugger
- 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.loginEdit', false);
- }
- else {
- //component.set('v.errorMessage', 'save_report failed.');
- this.error('save_report failed.');
- this.showErrorToast(component);
- component.find('save_button').set('v.disabled', false);
- component.set('v.loginEdit', 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.error('get_reports_now failed.');
- this.showErrorToast(component);
- component.find('save_button').set('v.disabled', false);
- component.set('v.loginEdit', 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.loginEdit', false);
- debugger
- this.doinitSave(component, event, helper);
- }
- else {
- var error = response.getError();
- //component.set('v.errorMessage', '淇濆瓨鏃ユ姤澶辫触');
- this.error('淇濆瓨鏃ユ姤澶辫触');
- this.showErrorToast(component);
- component.find('save_button').set('v.disabled', false);
- component.set('v.loginEdit', 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.error('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.error('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.error('createReportHeader callback failed.');
- this.showErrorToast(component);
- component.set('v.login', false);
- }
- });
- $A.enqueueAction(action);
- },
- create_report_header_edit: function (component, event, helper, name, s_agency, s_date) {
- component.set('v.login',true);
- s_date = this.get_date_string(s_date);
- if (s_date == false) {
- //component.set('v.errorMessage', 'get_date_string failed.');
- this.error('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.error('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.loginEdit', 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.loginEdit', false);
- this.toggle_report_edit(component, event, helper);
- }
- else {
- //component.set('v.errorMessage', 'createReportHeader callback failed.');
- this.error('createReportHeader callback failed.');
- this.showErrorToast(component);
- component.set('v.loginEdit', 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.error('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) {
-
- 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);
-
- 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) {
-
- 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.error('涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝�');
- 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.error('涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝�');
- 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.error('涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝�');
- this.showErrorToast(component);
- }
-
- },
- //hospitalLinkId 缁忛攢鍟嗗尰闄㈢殑ID 鎷滆浜哄鍒剁殑鍦版柟
- doctor_change: function (component, event, helper) {
-
- 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.error('AWS url/token error.');
- this.showErrorToast(component);
- component.set('v.login', false);
- component.set('v.loginEdit', false);
- }
- });
- $A.enqueueAction(action);
- },
-
- insert_agencycontact: function (component, token, newUrl, payload, agencyHospitalid, helper, hospitalName) {
-
- 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.error(acMap.errormsg);
- this.showErrorToast(component);
- component.set('v.login', false);
- } else {
- //component.set('v.errorMessage', 'agency contact insert id error.');
- this.error('agency contact insert id error.');
- this.showErrorToast(component);
- component.set('v.login', false);
- }
- }
- else {
- //component.set('v.errorMessage', 'agency contact insert error.');
- this.error('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.error('AWS confirm error.');
- this.showErrorToast(component);
- component.set('v.login', false);
- }
- }).catch(error => {
- // component.set('v.errorMessage', 'AWS confirm error.');
- this.error('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({
- "hospital_id": hospital_id,
- });
- action.setCallback(this, function (response) {
- var state = response.getState();
- if (state == 'SUCCESS') {
- ;
- 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', '');
-
- component.set('v.doctor_list', res);
- component.set('v.login', false);
- }
- else {
- // component.set('v.errorMessage', 'set_doctor_list failed.');
- this.error('set_doctor_list failed.');
- this.showErrorToast(component);
- component.set('v.login', false);
- }
- });
- $A.enqueueAction(action);
- }
-
- } else {
- if (doctor_value == '绉戝浼�') {
- this.set_doctor_list2(component);
- } else {
- component.find('select_doctor').set('v.options', '');
- }
- }
- },//fy 20220414
- set_doctor_list_edit: 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.loginEdit', true);
- this.set_doctor_list2(component);
- } else {
- component.set('v.loginEdit', 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());
- //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.loginEdit', 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.loginEdit', 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', '');
-
- component.set('v.doctor_list', res);
- component.set('v.loginEdit', false);
- }
- else {
- // component.set('v.errorMessage', 'set_doctor_list failed.');
- this.error('set_doctor_list failed.');
- this.showErrorToast(component);
- component.set('v.loginEdit', false);
- }
- });
- $A.enqueueAction(action);
- }
-
- } else {
- if (doctor_value == '绉戝浼�') {
- this.set_doctor_list2(component);
- } else {
- component.find('select_doctor').set('v.options', '');
- }
- }
- },
- 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();
-
- for (var i = 0; i < res.length; i++) {
- if (res[i].selected == 'true') {
- res[i].selected = true;
- } else {
- res[i].selected = false;
- }
- }
-
- 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);
- component.set('v.loginEdit', 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.error('涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�');
- 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.error('涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�');
- 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.error('涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�');
- 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) {
-
- $A.util.removeClass(component.find('successDiv'), 'slds-hide');
- window.setTimeout($A.getCallback(function () {
- $A.util.addClass(component.find('successDiv'), 'slds-hide');
- }),
- 3000
+ 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
);
- },
- //寮瑰嚭 鎴愬姛鎻愮ず
- showSuccessToast01: function (component) {
-
- $A.util.removeClass(component.find('successDiv01'), 'slds-hide');
- window.setTimeout($A.getCallback(function () {
- $A.util.addClass(component.find('successDiv01'), 'slds-hide');
- }),
- 3000
+ 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")
);
- },
- //寮瑰嚭 閿欒鎻愮ず
- showErrorToast: function (component) {
-
- $A.util.removeClass(component.find('errorDiv'), 'slds-hide');
- window.setTimeout($A.getCallback(function () {
- $A.util.addClass(component.find('errorDiv'), 'slds-hide');
- }),
- 3000
+
+ component.set("v.PIConfig", res.PIConfig); // 20220222 PI鏀归�� by Bright
+ component.set("v.login", false);
+ } else {
+ //component.set('v.errorMessage', 'doinit failed.');
+ this.error("doinit failed.");
+ //this.showErrorToast(component);
+ component.set("v.login", false);
+ }
+ });
+ $A.enqueueAction(action);
+ },
+ doinitSave: function (component, event, helper) {
+ document.title = "杩芥函鏃ユ姤";
+ component.set("v.loginEdit", true);
+ this.report_date_list(component, event, helper, 5);
+ 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
+
+ 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
);
- },
- //寮瑰嚭 閿欒鎻愮ず
- showErrorToast01: function (component) {
-
- $A.util.removeClass(component.find('errorDiv01'), 'slds-hide');
- window.setTimeout($A.getCallback(function () {
- $A.util.addClass(component.find('errorDiv01'), 'slds-hide');
- }),
- 6000
+ 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")
);
- },
- 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 + '\'';
+
+ component.set("v.PIConfig", res.PIConfig); // 20220222 PI鏀归�� by Bright
+ component.set("v.loginEdit", false);
+ } else {
+ //component.set('v.errorMessage', 'doinit failed.');
+ this.error("doinit failed.");
+ //this.showErrorToast(component);
+ component.set("v.loginEdit", 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)));
}
- if (Department_Cateogy__c != '' && Department_Cateogy__c != null) {
- if (opportunity_cfilter != '' && opportunity_cfilter != null) {
- opportunity_cfilter += ' AND ';
+ });
+ $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;
+ }
+
+ 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.loginEdit", 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;
}
- // 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.update_select_report_data_id", "");
}
- 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');
+ 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];
+ }
+ }
+
+ 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.loginEdit", false);
+ },
+ staticResourceAgencyContact.token
+ );
+ } else {
+ component.set("v.loginEdit", false);
+ }
+ }
} 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) {
- ;
- 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"\ style=\"width:100px">' + '琛屽彿' + '</th>';
- for (i = 0; i < headers.length; i++) {
- if (headers[i] == '浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺') {
- content += '<th scope=\"col"\ style=\"width:250px"\>' + headers[i] + '</th>';
- } else {
- content += '<th scope=\"col"\ style=\"width:200px"\>' + 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');
-
+ component.set("v.list_message", "no_data");
+ component.set("v.loginEdit", false);
}
- 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) {
+ } else {
+ //component.set('v.errorMessage', 'get_reports failed.');
+ this.error("get_reports failed.");
+ //this.showErrorToast(component);
+ component.set("v.loginEdit", 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) {
+ 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"]);
+ }
+ 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);
+ }
+ }
+ }
+ },
+ toggle_report_edit: 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");
+ component.set("v.loginEdit", true);
+ //澶嶅埗 鍜岀紪杈� 鍥炴樉闂鍦ㄨ繖閲岄潰
+ 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_edit(component);
+ } else {
+ component.set(
+ "v.default_select_doctor_id",
+ select_data["doctor2__c"]
+ );
+ this.set_doctor_list_edit(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"]);
+ }
+ 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);
+ }
+ }
+ }
+ //component.set('v.loginEdit',false);
+ },
+ //鍏抽棴椤甸潰鏄� 灏忕殑鎻愮ず妗嗘槸鍚︽斁寮冩柊寤烘棩鎶�
+ 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
+ );
+ 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) {
+ 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) {
+ var select_report_data = component.get("v.select_report_data_radio");
+ if (confirm("鏄惁鍒犻櫎璇ユ暟鎹紵")) {
+ 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) {
+ 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) {
+ component.set("v.login", true);
+ debugger;
+ //component.set('v.loginEdit', true);
+ this.allclear(component);
+ //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_edit(
+ component,
+ event,
+ helper,
+ name,
+ select_agency,
+ select_date
+ );
+ // SWAG-CF58C3 fy start
+ this.set_aws_url(component, "Agency_Contact__c");
+ //component.set('v.login', false);
+ // 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");
+ }
+
+ // 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("鍏朵粬鍝佺墝浜у搧绫诲埆 涓嶅瓨鍦�"); }
+
+ //let errorMsg = '';
+ for (var i = 0; i < error.length; i++) {
+ component.set("v.errorMessage", error[i]);
+ this.showErrorToast(component);
+ //errorMsg += '; ' + error[i]
+ //this.error(error[i]);
+ }
+ // if(errorMsg != '')
+ // this.error(errorMsg.substring(1));
+ if (error.length > 0) {
+ component.find("save_button").set("v.disabled", false);
+ return false;
+ }
+ // 淇濆瓨鍑︾悊
+ component.set("v.loginEdit", 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") {
+ debugger;
+ 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.loginEdit", false);
+ } else {
+ //component.set('v.errorMessage', 'save_report failed.');
+ this.error("淇濆瓨鏃ユ姤澶辫触");
+ //this.showErrorToast(component);
+ component.find("save_button").set("v.disabled", false);
+ component.set("v.loginEdit", 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 result = response.getReturnValue();
- if (callback) callback(result);
- }
- else {
- //component.set('v.errorMessage', 'AWS url/token error.');
- this.error('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.error('AWS search error.');
- this.showErrorToast01(component);
- component.set('v.login', false);
- });
- },
- saveRecords: function (component, event, helper) {
- //component.set('v.login', true);
- component.set('v.modal_import_spinner', 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") {
-
- var ress = response.getReturnValue();
- if (ress) {
- var valur = ress.split('error1');
- if (valur.length <= 1) {
- var res = JSON.parse(response.getReturnValue());
-
- 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);
- }
- });
-
- 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);
- component.set('v.modal_import_spinner', true);
- this.saveRecordsEditFile(component, dataMap, result.object, helper);
- } else {
- //component.set('v.errorMessage', 'AWS 鏌ヨ鏁版嵁涓虹┖ ');
- this.error('AWS 鏌ヨ鏁版嵁涓虹┖ ');
- this.showErrorToast01(component);
- //component.set('v.login', false);
- component.set('v.modal_import_spinner', false);
- }
- } else {
- //component.set('v.errorMessage', 'AWS search status : ' + result.status);
- this.error('AWS search status : ' + result.status);
- this.showErrorToast01(component);
- //component.set('v.login', false);
- component.set('v.modal_import_spinner', false);
- }
- }, component);
- });
- } else {
- //component.set('v.errorMessage', valur[1] + '\n' + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
- this.error(valur[1] + '\n' + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
- this.showErrorToast01(component);
- //component.set('v.login', false);
- component.set('v.modal_import_spinner', 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++) {
- if (searchData[i].name != null) {
- 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 = [];
- let errorDataRow = [];
-
- var fileContentData = component.get("v.fileContentData").split('\n');
- console.log('fileContentData = ' + JSON.stringify(fileContentData))
- 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);
- // }
- if (errorArray[i] != '') {
- let errorData = {}
- let index = errorDataRow.indexOf(errorArray[i].trim().substring(1, 2));
- if (index == -1) {
- errorData.errorRow = errorArray[i].trim().substring(1, 2);
- errorDataRow.push(errorData.errorRow);
- errorData.errorInfo = errorArray[i].trim().substring(5);
- if(errorData.errorInfo == '鎷滆浜篈WS涓嶅瓨鍦�'){
- errorData.errorInfo ='鎷滆浜� ' + fileContentData[errorData.errorRow].split(',')[5] + '涓嶅瓨鍦�';
- }
- errorDatas.push(errorData);
- } else {
- if(errorArray[i].trim().substring(5) == '鎷滆浜篈WS涓嶅瓨鍦�'){
- errorData[index].errorInfo = '; ' + '鎷滆浜� ' + fileContentData[errorDatas[index].errorRow].split(',')[5] + '涓嶅瓨鍦�';
- }else{
- errorDatas[index].errorInfo += '; ' + errorArray[i].trim().substring(5);
- }
- }
- }
- }
-
- var fileContentData = component.get("v.fileContentData").split('\n');
- console.log('fileContentData = ' + JSON.stringify(fileContentData))
- let errorColumns = [
- { label: '閿欒琛�', fieldName: 'errorRow', type: 'text', hideDefaultActions: true, initialWidth: 100 },
- { label: '閿欒淇℃伅', fieldName: 'errorInfo', type: 'text', hideDefaultActions: true, initialWidth: 300, wrapText: true }
- ];
- for (var i = 0; i < fileContentData[0].split(',').length - 1; i++) {
- let initialWidth = 180;
- if (fileContentData[0].split(',')[i] == '浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺' || fileContentData[0].split(',')[i] == '浣跨敤浜у搧1(浜у搧鍨嬪彿)') {
- initialWidth = 250;
- }
- errorColumns.push({
- label: fileContentData[0].split(',')[i],
- fieldName: 'field' + i,
- type: 'text',
- hideDefaultActions: true,
- wrapText: true,
- initialWidth: initialWidth
+ 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.error("get_reports_now failed.");
+ //this.showErrorToast(component);
+ component.find("save_button").set("v.disabled", false);
+ component.set("v.loginEdit", false);
}
-
- for (var i = 0; i < errorDatas.length; i++) {
- let data = fileContentData[errorDatas[i].errorRow];
- console.log('data = ' + JSON.stringify(data));
- if (data) {
- for (var j = 0; j < data.split(',').length; j++) {
- let label = 'field' + j;
- errorDatas[i][label] = data.split(',')[j];
- }
- }
- }
- console.log('errorDatas =' + JSON.stringify(errorDatas))
- component.set('v.errorColumns', errorColumns);
- component.set('v.errorData', errorDatas);
- component.set("v.showErrorInfo", true);
-
- console.log('error = ' + error);
- //component.set('v.errorMessage', error);
- this.error(error);
- this.showErrorToast01(component);
- console.log('error=' + error);
- //component.set('v.login', false);
- component.set('v.modal_import_spinner', false);
- return;
+ });
+ $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.loginEdit", false);
+ debugger;
+ this.doinitSave(component, event, helper);
+ } else {
+ var error = response.getError();
+ //component.set('v.errorMessage', '淇濆瓨鏃ユ姤澶辫触');
+ this.error("淇濆瓨鏃ユ姤澶辫触");
+ //this.showErrorToast(component);
+ component.find("save_button").set("v.disabled", false);
+ component.set("v.loginEdit", false);
}
+ });
+ $A.enqueueAction(action);
+ }
+ },
- console.log('fileStr=' + fileStr);
- $A.getCallback(function () {
-
- helper.ImportMethod(component, fileStr, helper);
- })();
+ 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);
+ },
- }, 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");
+ 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.error("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.error("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.error("createReportHeader callback failed.");
+ //this.showErrorToast(component);
+ component.set("v.login", false);
+ }
+ });
+ $A.enqueueAction(action);
+ },
+ create_report_header_edit: 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.error("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.error("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_edit(component, event, helper);
+ } else {
+ //component.set('v.errorMessage', 'createReportHeader callback failed.');
+ this.error("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.error("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) {
+ 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);
+
+ component.set("v.setdoctorlisthos", true);
+ this.set_doctor_list_edit(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) {
+ 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.error("涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝�");
+ //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.error("涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝�");
+ //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.error("涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝�");
+ //this.showErrorToast(component);
+ }
+ },
+ //hospitalLinkId 缁忛攢鍟嗗尰闄㈢殑ID 鎷滆浜哄鍒剁殑鍦版柟
+ doctor_change: function (component, event, helper) {
+ 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.error("AWS url/token error.");
+ //this.showErrorToast(component);
+ component.set("v.login", false);
+ component.set("v.loginEdit", false);
+ }
+ });
+ $A.enqueueAction(action);
+ },
+
+ insert_agencycontact: function (
+ component,
+ token,
+ newUrl,
+ payload,
+ agencyHospitalid,
+ helper,
+ hospitalName
+ ) {
+ 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.error(acMap.errormsg);
+ //this.showErrorToast(component);
+ component.set("v.login", false);
+ } else {
+ //component.set('v.errorMessage', 'agency contact insert id error.');
+ this.error("agency contact insert id error.");
+ //this.showErrorToast(component);
+ component.set("v.login", false);
+ }
+ } else {
+ //component.set('v.errorMessage', 'agency contact insert error.');
+ this.error("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);
+ component.set("v.login", false);
+ this.set_doctor_list_edit(component);
+ } else {
+ //component.set('v.errorMessage', 'AWS confirm error.');
+ this.error("AWS confirm error.");
+ //this.showErrorToast(component);
+ component.set("v.login", false);
+ }
+ })
+ .catch((error) => {
+ // component.set('v.errorMessage', 'AWS confirm error.');
+ this.error("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.loginEdit", true);
+ this.set_doctor_list2(component);
+ } else {
+ component.set("v.loginEdit", true);
+ var action = component.get("c.getDoctorList");
action.setParams({
- fileData: fileStr,
- sobjectName: 'Account', //Any object
- fields: fieldsList
+ hospital_id: hospital_id
});
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 = [];
- let errorDataRow = [];
- var fileContentData = component.get("v.fileContentData").split('\n');
- console.log('fileContentData[1].split(,)[5] = ' + fileContentData[1].split(',')[5])
-
- for (var i = 0; i < ress.length; i++) {
- res1 += ress[i].substr(7) + '\n';
- if (ress[i] != '') {
- let errorData = {}
- let index = errorDataRow.indexOf(ress[i].substr(7).substring(1, 2));
- if (index == -1) {
- errorData.errorRow = ress[i].substr(7).substring(1, 2);
- errorDataRow.push(errorData.errorRow);
- errorData.errorInfo = ress[i].substr(7).substring(5);
- if(errorData.errorInfo == '鎷滆浜轰笉瀛樺湪'){
- console.log('errorData.errorRow = ' + errorData.errorRow)
- errorData.errorInfo ='鎷滆浜� ' + fileContentData[errorData.errorRow].split(',')[5] + '涓嶅瓨鍦�';
- }
- errorDatas.push(errorData);
- } else {
-
- if(ress[i].substr(7).substring(5) == '鎷滆浜轰笉瀛樺湪'){
- errorDatas[index].errorInfo += '; ' + '鎷滆浜� ' + fileContentData[errorDatas[index].errorRow].split(',')[5] + '涓嶅瓨鍦�';
- }else{
- errorDatas[index].errorInfo += '; ' + ress[i].substr(7).substring(5);
- }
- }
- }
- }
- var fileContentData = component.get("v.fileContentData").split('\n');
- let errorColumns = [
- { label: '閿欒琛�', fieldName: 'errorRow', type: 'text', hideDefaultActions: true, initialWidth: 100 },
- { label: '閿欒淇℃伅', fieldName: 'errorInfo', type: 'text', hideDefaultActions: true, initialWidth: 300, wrapText: true }
- ];
- for (var i = 0; i < fileContentData[0].split(',').length - 1; i++) {
- let initialWidth = 180;
- if (fileContentData[0].split(',')[i] == '浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺' || fileContentData[0].split(',')[i] == '浣跨敤浜у搧1(浜у搧鍨嬪彿)') {
- initialWidth = 250;
- }
- errorColumns.push({
- label: fileContentData[0].split(',')[i],
- fieldName: 'field' + i,
- type: 'text',
- hideDefaultActions: true,
- wrapText: true,
- initialWidth: initialWidth
- });
- }
-
- for (var i = 0; i < errorDatas.length; i++) {
- let data = fileContentData[errorDatas[i].errorRow];
- console.log('data = ' + JSON.stringify(data));
- for (var j = 0; j < data.split(',').length; j++) {
- let label = 'field' + j;
- errorDatas[i][label] = data.split(',')[j];
- }
- }
- component.set('v.errorColumns', errorColumns);
- component.set('v.errorData', errorDatas);
- component.set("v.showErrorInfo", true);
-
- console.log("==" + res1);
- //component.set('v.errorMessage', res1 + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
- this.error(res1 + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
- this.showErrorToast01(component);
- //component.set('v.login', false);
- component.set('v.modal_import_spinner', false);
- } else {
- component.set('v.successMessage', '瀵煎叆鎴愬姛');
- this.showSuccessToast01(component);
- component.set("v.showMain", true);
- //component.set('v.login', false);
- component.set('v.modal_import_spinner', false);
- this.doinit(component, event, helper);
- }
- }
- else if (state === "INCOMPLETE") {
- //component.set('v.login', false);
- component.set('v.modal_import_spinner', 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);
- component.set('v.modal_import_spinner', false);
- }
- } else {
- console.log("Unknown error");
- //component.set('v.login', false);
- component.set('v.modal_import_spinner', 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.error('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.error('浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺蹇呴』杈撳叆鏁板瓧!');
- this.showErrorToast(component);
- }
- } else {
- //component.set('v.errorMessage', '浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺鏈�澶氳緭鍏�14浣嶆暟瀛�!');
- this.error('浜у搧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.error('浜у搧鐢ㄩ噺蹇呴』杈撳叆鏁板瓧!');
- this.showErrorToast(component);
- }
- } else {
- //component.set('v.errorMessage', '浜у搧鐢ㄩ噺鏈�澶氳緭鍏�14浣嶆暟瀛�!');
- this.error('浜у搧鐢ㄩ噺鏈�澶氳緭鍏�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 != '绉戝浼�') {
- 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) {
-
- 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');
+ var state = response.getState();
+ if (state == "SUCCESS") {
+ var res = this.conv_selected(response.getReturnValue());
//fy
- $A.util.removeClass(result, 'disp_none');
- if (UserProType == 'ENG') {
- $A.util.removeClass(result, 'disp_none');
+ 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.loginEdit", false);
+ },
+ staticResourceAgencyContact.token
+ );
+ }
} 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)));
+ 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);
}
- });
- $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');
+ }
+ 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.loginEdit", 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);
+ }
}
- } else {
-
- 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);
- });
- }
+ // component.set('v.default_select_doctor_id', '');
- $A.enqueueAction(action);
- },
- //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
-
- //zhj 瀵煎嚭閿欒淇℃伅 2023-05-16 start
- exportErrorInfoHelper: function (component) {
- var errorData = component.get('v.errorData');
- var errorColumns = component.get('v.errorColumns');
-
- var datas = [];
- let errorColumnsArray = [];
- for (var i in errorColumns) {
- errorColumnsArray.push(errorColumns[i].label);
- }
- datas.push(errorColumnsArray);
- //datas.push(errorColumns);
-
- for (var i in errorData) {
- let data = [];
- data.push(errorData[i].errorRow)
- data.push(errorData[i].errorInfo)
- for (var j = 0; j < Object.keys(errorData[i]).length - 2; j++) {
- data.push(errorData[i]['field' + j])
- }
- 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,'""') + '"';
- }
- if (j > 0) {
- csv += ',';
- }
- csv += val;
- }
- csv += '\n';
- }
- return csv;
- },
-
- downloadCSV: function (component, csv) {
- var link = document.createElement('a');
- var bom = "\uFEFF";
- link.href = 'data:text/csv;charset=utf-8,' + encodeURIComponent(bom + csv);
- link.download = 'data.csv';
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- },
- error: function (message) {
- // $('toastMessage.forceToastManager').css('white-space', 'pre-wrap');
- var toastEvent = $A.get("e.force:showToast");
-
- toastEvent.setParams({
- "title": "閿欒!",
- "message": message,
- "type": "error",
- //"duration" : "sticky"
+ component.set("v.doctor_list", res);
+ component.set("v.loginEdit", false);
+ } else {
+ // component.set('v.errorMessage', 'set_doctor_list failed.');
+ this.error("set_doctor_list failed.");
+ //this.showErrorToast(component);
+ component.set("v.loginEdit", false);
+ }
});
- toastEvent.fire();
- },
- //zhj 瀵煎嚭閿欒淇℃伅 2023-05-16 end
-})
\ No newline at end of file
+ $A.enqueueAction(action);
+ }
+ } else {
+ if (doctor_value == "绉戝浼�") {
+ this.set_doctor_list2(component);
+ } else {
+ component.find("select_doctor").set("v.options", "");
+ }
+ }
+ component.set("v.loginEdit", false);
+ }, //fy 20220414
+ set_doctor_list_edit: 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.loginEdit", true);
+ this.set_doctor_list2(component);
+ } else {
+ component.set("v.loginEdit", 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());
+ //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.loginEdit", 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.loginEdit", 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', '');
+
+ component.set("v.doctor_list", res);
+ component.set("v.loginEdit", false);
+ } else {
+ // component.set('v.errorMessage', 'set_doctor_list failed.');
+ this.error("set_doctor_list failed.");
+ //this.showErrorToast(component);
+ component.set("v.loginEdit", false);
+ }
+ });
+ $A.enqueueAction(action);
+ }
+ } else {
+ if (doctor_value == "绉戝浼�") {
+ this.set_doctor_list2(component);
+ } else {
+ component.find("select_doctor").set("v.options", "");
+ }
+ }
+ },
+ 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();
+
+ for (var i = 0; i < res.length; i++) {
+ if (res[i].selected == "true") {
+ res[i].selected = true;
+ } else {
+ res[i].selected = false;
+ }
+ }
+
+ 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);
+ component.set("v.loginEdit", 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.error("涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�");
+ //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.error("涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�");
+ //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.error("涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�");
+ //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) {
+ $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) {
+ $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) {
+ $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) {
+ $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_edit(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) {
+ 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" style="width:100px">' + "琛屽彿" + "</th>";
+ for (i = 0; i < headers.length; i++) {
+ if (headers[i] == "浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺") {
+ content +=
+ '<th scope="col" style="width:250px">' + headers[i] + "</th>";
+ } else {
+ content +=
+ '<th scope="col" style="width:200px">' + 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.error("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.error("AWS search error.");
+ //this.showErrorToast01(component);
+ component.set("v.login", false);
+ });
+ },
+ saveRecords: function (component, event, helper) {
+ //component.set('v.login', true);
+ component.set("v.modal_import_spinner", 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") {
+ var ress = response.getReturnValue();
+ if (ress) {
+ var valur = ress.split("error1");
+ if (valur.length <= 1) {
+ var res = JSON.parse(response.getReturnValue());
+
+ 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);
+ }
+ });
+
+ 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);
+ component.set("v.modal_import_spinner", true);
+ this.saveRecordsEditFile(
+ component,
+ dataMap,
+ result.object,
+ helper
+ );
+ } else {
+ //component.set('v.errorMessage', 'AWS 鏌ヨ鏁版嵁涓虹┖ ');
+ this.error("AWS 鏌ヨ鏁版嵁涓虹┖ ");
+ //this.showErrorToast01(component);
+ //component.set('v.login', false);
+ component.set("v.modal_import_spinner", false);
+ }
+ } else {
+ //component.set('v.errorMessage', 'AWS search status : ' + result.status);
+ this.error("AWS search status : " + result.status);
+ //this.showErrorToast01(component);
+ //component.set('v.login', false);
+ component.set("v.modal_import_spinner", false);
+ }
+ },
+ component
+ );
+ }
+ );
+ } else {
+ //component.set('v.errorMessage', valur[1] + '\n' + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
+ this.error(valur[1] + "\n" + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
+ //this.showErrorToast01(component);
+ //component.set('v.login', false);
+ component.set("v.modal_import_spinner", 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++) {
+ if (searchData[i].name != null) {
+ 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 = [];
+ let errorDataRow = [];
+
+ var fileContentData = component.get("v.fileContentData").split("\n");
+ console.log("fileContentData = " + JSON.stringify(fileContentData));
+ 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);
+ // }
+ if (errorArray[i] != "") {
+ let errorData = {};
+ let index = errorDataRow.indexOf(
+ errorArray[i].trim().substring(1, 2)
+ );
+ if (index == -1) {
+ errorData.errorRow = errorArray[i].trim().substring(1, 2);
+ errorDataRow.push(errorData.errorRow);
+ errorData.errorInfo = errorArray[i].trim().substring(5);
+ if (errorData.errorInfo == "鎷滆浜篈WS涓嶅瓨鍦�") {
+ errorData.errorInfo =
+ "鎷滆浜� " +
+ fileContentData[errorData.errorRow].split(",")[5] +
+ "涓嶅瓨鍦�";
+ }
+ errorDatas.push(errorData);
+ } else {
+ if (errorArray[i].trim().substring(5) == "鎷滆浜篈WS涓嶅瓨鍦�") {
+ errorData[index].errorInfo =
+ "; " +
+ "鎷滆浜� " +
+ fileContentData[errorDatas[index].errorRow].split(",")[5] +
+ "涓嶅瓨鍦�";
+ } else {
+ errorDatas[index].errorInfo +=
+ "; " + errorArray[i].trim().substring(5);
+ }
+ }
+ }
+ }
+
+ var fileContentData = component.get("v.fileContentData").split("\n");
+ console.log("fileContentData = " + JSON.stringify(fileContentData));
+ let errorColumns = [
+ {
+ label: "閿欒琛�",
+ fieldName: "errorRow",
+ type: "text",
+ hideDefaultActions: true,
+ initialWidth: 100
+ },
+ {
+ label: "閿欒淇℃伅",
+ fieldName: "errorInfo",
+ type: "text",
+ hideDefaultActions: true,
+ initialWidth: 300,
+ wrapText: true
+ }
+ ];
+ for (var i = 0; i < fileContentData[0].split(",").length - 1; i++) {
+ let initialWidth = 180;
+ if (
+ fileContentData[0].split(",")[i] == "浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺" ||
+ fileContentData[0].split(",")[i] == "浣跨敤浜у搧1(浜у搧鍨嬪彿)"
+ ) {
+ initialWidth = 250;
+ }
+ errorColumns.push({
+ label: fileContentData[0].split(",")[i],
+ fieldName: "field" + i,
+ type: "text",
+ hideDefaultActions: true,
+ wrapText: true,
+ initialWidth: initialWidth
+ });
+ }
+
+ for (var i = 0; i < errorDatas.length; i++) {
+ let data = fileContentData[errorDatas[i].errorRow];
+ console.log("data = " + JSON.stringify(data));
+ if (data) {
+ for (var j = 0; j < data.split(",").length; j++) {
+ let label = "field" + j;
+ errorDatas[i][label] = data.split(",")[j];
+ }
+ }
+ }
+ console.log("errorDatas =" + JSON.stringify(errorDatas));
+ component.set("v.errorColumns", errorColumns);
+ component.set("v.errorData", errorDatas);
+ component.set("v.showErrorInfo", true);
+
+ console.log("error = " + error);
+ //component.set('v.errorMessage', error);
+ this.error(error);
+ //this.showErrorToast01(component);
+ console.log("error=" + error);
+ //component.set('v.login', false);
+ component.set("v.modal_import_spinner", false);
+ return;
+ }
+
+ console.log("fileStr=" + fileStr);
+ $A.getCallback(function () {
+ 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 = [];
+ let errorDataRow = [];
+ var fileContentData = component.get("v.fileContentData").split("\n");
+ console.log(
+ "fileContentData[1].split(,)[5] = " +
+ fileContentData[1].split(",")[5]
+ );
+
+ for (var i = 0; i < ress.length; i++) {
+ res1 += ress[i].substr(7) + "\n";
+ if (ress[i] != "") {
+ let errorData = {};
+ let index = errorDataRow.indexOf(
+ ress[i].substr(7).substring(1, 2)
+ );
+ if (index == -1) {
+ errorData.errorRow = ress[i].substr(7).substring(1, 2);
+ errorDataRow.push(errorData.errorRow);
+ errorData.errorInfo = ress[i].substr(7).substring(5);
+ if (errorData.errorInfo == "鎷滆浜轰笉瀛樺湪") {
+ console.log("errorData.errorRow = " + errorData.errorRow);
+ errorData.errorInfo =
+ "鎷滆浜� " +
+ fileContentData[errorData.errorRow].split(",")[5] +
+ "涓嶅瓨鍦�";
+ }
+ errorDatas.push(errorData);
+ } else {
+ if (ress[i].substr(7).substring(5) == "鎷滆浜轰笉瀛樺湪") {
+ errorDatas[index].errorInfo +=
+ "; " +
+ "鎷滆浜� " +
+ fileContentData[errorDatas[index].errorRow].split(",")[5] +
+ "涓嶅瓨鍦�";
+ } else {
+ errorDatas[index].errorInfo +=
+ "; " + ress[i].substr(7).substring(5);
+ }
+ }
+ }
+ }
+ var fileContentData = component.get("v.fileContentData").split("\n");
+ let errorColumns = [
+ {
+ label: "閿欒琛�",
+ fieldName: "errorRow",
+ type: "text",
+ hideDefaultActions: true,
+ initialWidth: 100
+ },
+ {
+ label: "閿欒淇℃伅",
+ fieldName: "errorInfo",
+ type: "text",
+ hideDefaultActions: true,
+ initialWidth: 300,
+ wrapText: true
+ }
+ ];
+ for (var i = 0; i < fileContentData[0].split(",").length - 1; i++) {
+ let initialWidth = 180;
+ if (
+ fileContentData[0].split(",")[i] == "浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺" ||
+ fileContentData[0].split(",")[i] == "浣跨敤浜у搧1(浜у搧鍨嬪彿)"
+ ) {
+ initialWidth = 250;
+ }
+ errorColumns.push({
+ label: fileContentData[0].split(",")[i],
+ fieldName: "field" + i,
+ type: "text",
+ hideDefaultActions: true,
+ wrapText: true,
+ initialWidth: initialWidth
+ });
+ }
+
+ for (var i = 0; i < errorDatas.length; i++) {
+ let data = fileContentData[errorDatas[i].errorRow];
+ console.log("data = " + JSON.stringify(data));
+ for (var j = 0; j < data.split(",").length; j++) {
+ let label = "field" + j;
+ errorDatas[i][label] = data.split(",")[j];
+ }
+ }
+ component.set("v.errorColumns", errorColumns);
+ component.set("v.errorData", errorDatas);
+ component.set("v.showErrorInfo", true);
+
+ console.log("==" + res1);
+ //component.set('v.errorMessage', res1 + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
+ this.error(res1 + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
+ //this.showErrorToast01(component);
+ //component.set('v.login', false);
+ component.set("v.modal_import_spinner", false);
+ } else {
+ component.set("v.successMessage", "瀵煎叆鎴愬姛");
+ this.showSuccessToast01(component);
+ component.set("v.showMain", true);
+ //component.set('v.login', false);
+ component.set("v.modal_import_spinner", false);
+ this.doinit(component, event, helper);
+ }
+ } else if (state === "INCOMPLETE") {
+ //component.set('v.login', false);
+ component.set("v.modal_import_spinner", 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);
+ component.set("v.modal_import_spinner", false);
+ }
+ } else {
+ console.log("Unknown error");
+ //component.set('v.login', false);
+ component.set("v.modal_import_spinner", 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.error("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.error("浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺蹇呴』杈撳叆鏁板瓧!");
+ //this.showErrorToast(component);
+ }
+ } else {
+ //component.set('v.errorMessage', '浜у搧1鍚岀被鑰楁潗绉戝鏈堜娇鐢ㄩ噺鏈�澶氳緭鍏�14浣嶆暟瀛�!');
+ this.error("浜у搧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.error("浜у搧鐢ㄩ噺蹇呴』杈撳叆鏁板瓧!");
+ //this.showErrorToast(component);
+ }
+ } else {
+ //component.set('v.errorMessage', '浜у搧鐢ㄩ噺鏈�澶氳緭鍏�14浣嶆暟瀛�!');
+ this.error("浜у搧鐢ㄩ噺鏈�澶氳緭鍏�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 != "绉戝浼�") {
+ component.find("new_con").set("v.disabled", false);
+ } else {
+ component.find("new_con").set("v.disabled", true);
+ }
+ if (doctor_value != "") {
+ this.set_doctor_list_edit(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) {
+ 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");
+ }
+ 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");
+ }
+ },
+ 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 {
+ 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 errorColumns = component.get("v.errorColumns");
+
+ var datas = [];
+ let errorColumnsArray = [];
+ for (var i in errorColumns) {
+ errorColumnsArray.push(errorColumns[i].label);
+ }
+ datas.push(errorColumnsArray);
+ //datas.push(errorColumns);
+
+ for (var i in errorData) {
+ let data = [];
+ data.push(errorData[i].errorRow);
+ data.push(errorData[i].errorInfo);
+ for (var j = 0; j < Object.keys(errorData[i]).length - 2; j++) {
+ data.push(errorData[i]["field" + j]);
+ }
+ 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,'""') + '"';
+ }
+ if (j > 0) {
+ csv += ",";
+ }
+ csv += val;
+ }
+ csv += "\n";
+ }
+ return csv;
+ },
+
+ downloadCSV: function (component, csv) {
+ var link = document.createElement("a");
+ var bom = "\uFEFF";
+ link.href = "data:text/csv;charset=utf-8," + encodeURIComponent(bom + csv);
+ link.download = "data.csv";
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ },
+ error: function (message) {
+ // $('toastMessage.forceToastManager').css('white-space', 'pre-wrap');
+ var toastEvent = $A.get("e.force:showToast");
+
+ toastEvent.setParams({
+ title: "閿欒!",
+ message: message,
+ type: "error"
+ //"duration" : "sticky"
+ });
+ toastEvent.fire();
+ }
+ //zhj 瀵煎嚭閿欒淇℃伅 2023-05-16 end
+});
diff --git a/force-app/main/default/aura/WeeklyReport/WeeklyReport.cmp b/force-app/main/default/aura/WeeklyReport/WeeklyReport.cmp
index b21a79e..831f94a 100644
--- a/force-app/main/default/aura/WeeklyReport/WeeklyReport.cmp
+++ b/force-app/main/default/aura/WeeklyReport/WeeklyReport.cmp
@@ -1,315 +1,533 @@
-<aura:component controller="WeeklyReportCmp" 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:'Agency_Contact__c'}"/>
- <!-- <aura:attribute name="oppdata_old" type="Agency_Opportunity__c" default="{sobjectType:'Agency_Opportunity__c'}"/> -->
- <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="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" />
- <aura:attribute name="doctor_list" type="Map"/>
- <aura:attribute name="doctor_title" type="String"/>
- <aura:attribute name="opportunity_list" type="Map"/>
- <aura:handler name="change" value="{!v.data.Opportunity__c}" action="{!c.opportunityChange}"/>
- <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" />
- <aura:attribute name="opportunity_cfilter" type="String" />
- <!-- <aura:handler name="change" value="{!v.data.Product_Category1__c}" action="{!c.productcategoryChange1}"/>
+<aura:component
+ controller="WeeklyReportCmp"
+ 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:'Agency_Contact__c'}"
+ />
+ <!-- <aura:attribute name="oppdata_old" type="Agency_Opportunity__c" default="{sobjectType:'Agency_Opportunity__c'}"/> -->
+ <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="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="loginEdit" 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" />
+ <aura:attribute name="doctor_list" type="Map" />
+ <aura:attribute name="doctor_title" type="String" />
+ <aura:attribute name="opportunity_list" type="Map" />
+ <aura:handler
+ name="change"
+ value="{!v.data.Opportunity__c}"
+ action="{!c.opportunityChange}"
+ />
+ <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" />
+ <aura:attribute name="opportunity_cfilter" type="String" />
+ <!-- <aura:handler name="change" value="{!v.data.Product_Category1__c}" action="{!c.productcategoryChange1}"/>
<aura:handler name="change" value="{!v.data.Product_Category2__c}" action="{!c.productcategoryChange2}"/>
<aura:handler name="change" value="{!v.data.Product_Category3__c}" action="{!c.productcategoryChange3}"/> -->
- <!-- <aura:handler name="change" value="{!v.oppdata.StageName__c}" action="{!c.stageNameChange}"/> -->
- <aura:attribute name="update_select_report_data_id" type="String" default=""/>
+ <!-- <aura:handler name="change" value="{!v.oppdata.StageName__c}" action="{!c.stageNameChange}"/> -->
+ <aura:attribute
+ name="update_select_report_data_id"
+ type="String"
+ default=""
+ />
- <!-- 鎵归噺娣诲姞鍛ㄦ姤 start-->
- <aura:attribute name="reports_date" type="List" />
- <!-- <aura:attribute name="reports_date1" type="Date" />
+ <!-- 鎵归噺娣诲姞鍛ㄦ姤 start-->
+ <aura:attribute name="reports_date" type="List" />
+ <!-- <aura:attribute name="reports_date1" type="Date" />
<aura:attribute name="reports_date2" type="Date" /> -->
- <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"/>
- <!-- It will display 100 records . Change for your requirement-->
- <aura:attribute name="NumOfRecords" type="Integer" default="1000"/>
- <aura:attribute name="showMain" type="Boolean" default="true"/>
- <!-- PIPL update Yin Mingjie 21/02/2022 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"/>
- <!-- PIPL update Yin Mingjie 21/02/2022 end -->
+ <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" />
+ <!-- It will display 100 records . Change for your requirement-->
+ <aura:attribute name="NumOfRecords" type="Integer" default="1000" />
+ <aura:attribute name="showMain" type="Boolean" default="true" />
+ <!-- PIPL update Yin Mingjie 21/02/2022 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" />
+ <!-- PIPL update Yin Mingjie 21/02/2022 end -->
- <!-- start DTT-zhj 澧炲姞閿欒淇℃伅table 2023-05-16-->
- <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-->
+ <!-- start DTT-zhj 澧炲姞閿欒淇℃伅table 2023-05-16-->
+ <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-->
- <!-- 鎵归噺娣诲姞鍛ㄦ姤 end-->
- <ltng:require scripts="{! $Resource.AWSService+'/AWSService.js' }" />
- <ltng:require scripts="{! $Resource.jquery183minjs }" />
-
- <!--銉兗銉変腑...-->
- <aura:renderIf isTrue="{!v.login}">
- <!-- add by Deloitte-Link 2023-6-19 -->
- <div class="weeklyReportSpinner">
- <div class="slds-spinner_container">
- <div class="slds-spinner--brand slds-spinner slds-spinner--medium" role="alert">
- <span id="aa" class="slds-assistive-text">Loading</span>
- <div class="slds-spinner__dot-a"></div>
- <div class="slds-spinner__dot-b"></div>
- </div>
+ <!-- 鎵归噺娣诲姞鍛ㄦ姤 end-->
+ <ltng:require scripts="{! $Resource.AWSService+'/AWSService.js' }" />
+ <ltng:require scripts="{! $Resource.jquery183minjs }" />
+
+ <!--銉兗銉変腑...-->
+ <aura:renderIf isTrue="{!v.login}">
+ <aura:renderIf isTrue="{!!v.loginEdit}">
+ <!-- add by Deloitte-Link 2023-6-19 -->
+ <div class="weeklyReportSpinner">
+ <div class="slds-spinner_container">
+ <div
+ class="slds-spinner--brand slds-spinner slds-spinner--medium"
+ role="alert"
+ >
+ <span id="aa" class="slds-assistive-text">Loading</span>
+ <div class="slds-spinner__dot-a"></div>
+ <div class="slds-spinner__dot-b"></div>
</div>
+ </div>
</div>
</aura:renderIf>
-
- <div aura:id="report" id="report">
- <div class="slds-grid slds-wrap slds-grid--pull-padded">
- <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">
- {!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">
- <ui:inputSelect aura:id="select_agency_person" class="slds-select agency_person_select" change="{!c.select_agency_change}"/>
- </div>
- <div class="tr slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-12 slds-large-size--1-of-12">
- <ui:button aura:id="new_button" label="鏂板缓" press="{!c.new_report}" disabled="true"/>
- </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: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="import" label="瀵煎叆" press="{!c.import}" />
-
- <!-- <input type="file" class="file" aura:id="file" onchange="{!c.CreateRecord}" style="position:absolute;filter:alpha(opacity=0);" size="1" hidden="true" /> -->
- <!-- <ui:button aura:id="import" label="瀵煎嚭" press="{!c.export}"/> -->
- <ui:button aura:id="export" label="瀵煎嚭" press="{!c.export_condition}"/>
- </div>
-
- </div>
+ </aura:renderIf>
+
+ <div aura:id="report" id="report" class="contents_wrapper">
+ <div class="slds-grid slds-wrap slds-grid--pull-padded">
+ <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"
+ >
+ {!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"
+ >
+ <ui:inputSelect
+ aura:id="select_agency_person"
+ class="slds-select agency_person_select"
+ change="{!c.select_agency_change}"
+ />
+ </div>
+ <div
+ class="tr slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-12 slds-large-size--1-of-12"
+ >
+ <ui:button
+ aura:id="new_button"
+ label="鏂板缓"
+ press="{!c.new_report}"
+ disabled="true"
+ />
+ </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: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="import" label="瀵煎叆" press="{!c.import}" />
+
+ <!-- <input type="file" class="file" aura:id="file" onchange="{!c.CreateRecord}" style="position:absolute;filter:alpha(opacity=0);" size="1" hidden="true" /> -->
+ <!-- <ui:button aura:id="import" label="瀵煎嚭" press="{!c.export}"/> -->
+ <ui:button
+ aura:id="export"
+ label="瀵煎嚭"
+ press="{!c.export_condition}"
+ />
+ </div>
</div>
-
- <div aura:id="report_list" class="report_list_area">
- <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" style="width:66.75rem;">
- <thead>
- <tr class="slds-line-height--reset">
- <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" style="width: 100px;">
- <span class="slds-truncate" title="Name">{!v.fieldsmap.Person_In_Charge2__c}</span>
- </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" style="width: 100px;">
- <span class="slds-truncate" title="Name">{!v.fieldsmap.Department_Cateogy__c}</span>
- </th>
- <th class="table_header slds-text-title--caps" style="width: 100px;">
- <!-- PIPL update Yin Mingjie 21/02/2022 start
+ </div>
+
+ <div aura:id="report_list" class="report_list_area">
+ <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"
+ style="width: 66.75rem"
+ >
+ <thead>
+ <tr class="slds-line-height--reset">
+ <th
+ class="table_header slds-text-title--caps"
+ style="width: 250px; font-size: 13px"
+ >
+ <span class="slds-truncate" title="Name">鍛ㄦ姤缂栧彿</span>
+ </th>
+ <th
+ class="table_header slds-text-title--caps"
+ style="width: 100px; font-size: 13px"
+ >
+ <span class="slds-truncate" title="Name"
+ >{!v.fieldsmap.Person_In_Charge2__c}</span
+ >
+ </th>
+ <th
+ class="table_header slds-text-title--caps"
+ style="width: 250px; font-size: 13px"
+ >
+ <span class="slds-truncate" title="Name">鍖婚櫌</span>
+ </th>
+ <th
+ class="table_header slds-text-title--caps"
+ style="width: 100px; font-size: 13px"
+ >
+ <span class="slds-truncate" title="Name"
+ >{!v.fieldsmap.Department_Cateogy__c}</span
+ >
+ </th>
+ <th
+ class="table_header slds-text-title--caps"
+ style="width: 100px; font-size: 13px"
+ >
+ <!-- PIPL update Yin Mingjie 21/02/2022 start
<span class="slds-truncate" title="Name">{!v.fieldsmap.doctor2__r}</span>
PIPL update Yin Mingjie 21/02/2022 end-->
- <span class="slds-truncate" title="Name" style="width: 100px;">{!v.fieldsmap.Agency_Contact__c}</span>
-
- </th>
- <th class="table_header slds-text-title--caps" style="width: 100px;">
- <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.Purpose_Type__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 class="decrypt">{!item.Person_In_Charge2__r.awsdata.lastName}</span> -->
- </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.visitor_title__c}">
- <span class="encrypt">{!item.visitor_title__c}</span>
- <span class="decrypt">{!item.doctor2__r.awsdata.doctorDivision1}</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.Purpose_Type__c}">{!item.Purpose_Type__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}
+ <span
+ class="slds-truncate"
+ title="Name"
+ style="width: 100px; font-size: 13px"
+ >{!v.fieldsmap.Agency_Contact__c}</span
+ >
+ </th>
+ <th
+ class="table_header slds-text-title--caps"
+ style="width: 100px; font-size: 13px"
+ >
+ <span class="slds-truncate" title="Name"
+ >{!v.fieldsmap.visitor_title__c}</span
+ >
+ </th>
+ <th
+ class="table_header slds-text-title--caps"
+ style="width: 100px; font-size: 13px"
+ >
+ <span class="slds-truncate" title="Name"
+ >{!v.fieldsmap.Purpose_Type__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 class="decrypt">{!item.Person_In_Charge2__r.awsdata.lastName}</span> -->
+ </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.visitor_title__c}">
+ <span class="encrypt">{!item.visitor_title__c}</span>
+ <span class="decrypt"
+ >{!item.doctor2__r.awsdata.doctorDivision1}</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.Purpose_Type__c}"
+ >{!item.Purpose_Type__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>
+ </aura:renderIf>
+ </div>
+
+ <!-- <ui:button aura:id="test_button" label="test" class="fade animation_on" press="{!c.test}"/>-->
+ <!-- 鎵归噺娣诲姞鍛ㄦ姤 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__container">
+ <aura:renderIf isTrue="{!v.loginEdit}">
+ <lightning:spinner
+ alternativeText="Loading"
+ size="medium"
+ style="width: 100%; height: 80%; top: 50px"
+ />
+ </aura:renderIf>
+ <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>
+ <!-- <input type="file" class="file" aura:id="file" onchange="{!c.CreateRecord}" value="瀵煎叆" /> -->
+ <lightning:input
+ type="file"
+ class="file"
+ uara:id="file"
+ onchange="{!c.CreateRecord}"
+ />
+ <!-- <ui:button label="Create Accounts" press="{!c.CreateRecord}"/> -->
+ </div>
+ <aura:set attribute="else">
+ <!-- <ui:outputRichText class="uiOutputRichText slds-m-around-large" value="{!v.TargetFileName}"/> -->
+ <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>
+ <!-- start DTT-zhj 澧炲姞閿欒淇℃伅table 2023-05-16-->
+ <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; overflow-x: scroll">
+ <lightning:datatable
+ keyField="id"
+ data="{! v.errorData }"
+ columns="{! v.errorColumns }"
+ hideCheckboxColumn="true"
+ />
</div>
- </aura:set>
- </aura:renderIf>
+ </div>
+ </aura:if>
+ <!-- start DTT-zhj 澧炲姞閿欒淇℃伅table 2023-05-16-->
+ </aura:set>
+ </aura:if>
+ </div>
</div>
+ </div>
+ <div
+ aura:id="modal_importbg"
+ class="disp_none slds-backdrop slds-backdrop--open"
+ ></div>
+ <!-- 鎵归噺娣诲姞鍛ㄦ姤 end-->
-<!-- <ui:button aura:id="test_button" label="test" class="fade animation_on" press="{!c.test}"/>-->
- <!-- 鎵归噺娣诲姞鍛ㄦ姤 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__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>
- <!-- <input type="file" class="file" aura:id="file" onchange="{!c.CreateRecord}" value="瀵煎叆" /> -->
- <lightning:input type="file" class="file" uara:id="file" onchange="{!c.CreateRecord}" />
- <!-- <ui:button label="Create Accounts" press="{!c.CreateRecord}"/> -->
- </div>
- <aura:set attribute="else">
- <!-- <ui:outputRichText class="uiOutputRichText slds-m-around-large" value="{!v.TargetFileName}"/> -->
- <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>
- <!-- start DTT-zhj 澧炲姞閿欒淇℃伅table 2023-05-16-->
- <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;overflow-x:scroll">
- <lightning:datatable keyField="id" data="{! v.errorData }"
- columns="{! v.errorColumns }" hideCheckboxColumn="true" />
- </div>
- </div>
- </aura:if>
- <!-- start DTT-zhj 澧炲姞閿欒淇℃伅table 2023-05-16-->
- </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"
+ >
+ 娲诲姩鏃ュ紑濮嬫棩鏈�
- <!-- 鎵归噺瀵煎嚭鍛ㄦ姤 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}"/>
+ <lightning:input
+ type="Date"
+ class="slds-input slds-input_bare"
+ aura:id="input-report-date1"
+ />
</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-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>
- <!-- <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>
+ <!-- <div>
璇疯緭鍏ヨ瀵煎嚭鏃ユ姤鐨勬姤娲诲姩鏃ョ殑寮�濮嬪拰缁撴潫鏃ユ湡
<force:inputField aura:id="input-report-date1"/>鍒�
<force:inputField aura:id="input-report-date2"/>
@@ -318,290 +536,530 @@
<lightning:button label="鍙栨秷" variant="brand"
onclick="{!c.close_export}" />
</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>
+ <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>
- </div>
+ </aura:set>
+ </aura:if>
+ </div>
</div>
- <div aura:id="modal_exportbg" class="disp_none slds-backdrop slds-backdrop--open"></div>
- <!-- 鎵归噺瀵煎嚭鍛ㄦ姤 end-->
+ </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__header">
- <h4 id="headerTarget" class="slds-float--left"></h4>
- <h2 id="headerTarget" class="slds-text-heading--medium">鍛ㄦ姤({!v.selected_date} {!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
+ 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">
+ <aura:renderIf isTrue="{!v.loginEdit}">
+ <lightning:spinner
+ alternativeText="Loading"
+ size="medium"
+ style="width: 100%; height: 80%; top: 50px"
+ />
+ </aura:renderIf>
+ <div class="slds-modal__header">
+ <h4 id="headerTarget" class="slds-float--left"></h4>
+ <h2 id="headerTarget" class="slds-text-heading--medium">
+ 鍛ㄦ姤({!v.selected_date} {!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 marginTop"
+ >
+ 娲诲姩鏃�
+ <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
+ <!-- <force:inputField value="{!v.data.Report_Date__c}" aura:id="input-report-date"/> -->
+ <lightning:input
+ type="date"
+ value="{!v.data.Report_Date__c}"
+ aura:id="input-report-date"
+ variant="label-hidden"
+ />
</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 marginTop" >
- 娲诲姩鏃�
- <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
- <!-- <force:inputField value="{!v.data.Report_Date__c}" aura:id="input-report-date"/> -->
- <lightning:input type="date" value="{!v.data.Report_Date__c}" aura:id="input-report-date"
- variant="label-hidden" />
+ <!-- 鍖婚櫌 -->
+ <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-5 marginTop"
+ data-select="single"
+ >
+ <!-- <ui:inputText aura:id="hospital_input_text" label="鍖婚櫌" class="field" value="{!v.hospital}" updateOn="keyup"/> -->
+ 鍖婚櫌
+ <lightning:input
+ aura:id="hospital_input_text"
+ class="field"
+ value="{!v.hospital}"
+ variant="label-hidden"
+ 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>
- <!-- 鍖婚櫌 -->
- <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-5 marginTop" data-select="single">
- <!-- <ui:inputText aura:id="hospital_input_text" label="鍖婚櫌" class="field" value="{!v.hospital}" updateOn="keyup"/> -->
- 鍖婚櫌
- <lightning:input aura:id="hospital_input_text" class="field" value="{!v.hospital}" variant="label-hidden" 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-8 marginTop">
- {!v.fieldsmap.Department_Cateogy__c}
- <ui:inputSelect aura:id="select_department" class="slds-select" change="{!c.select_department}"/>
- </div>
-
- <!-- 鍏堢敓 -->
- <div class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-8 marginTop">
- {!v.fieldsmap.doctor2__c}
- <ui:inputSelect aura:id="select_doctor" class="slds-select" change="{!c.doctor_change}"/>
- </div>
-
- <div class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-12 marginTop">
- <br/>
- <ui:button label="鏂板缓" class="slds-button" press="{!c.createCon}" disabled="true" aura:id="new_con"/>
- </div>
-
- <!-- 鑱屼綅 -->
- <div class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-8 marginTop">
- {!v.fieldsmap.visitor_title__c}
- <div>{!v.doctor_title}</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 marginTop">
- {!v.fieldsmap.Purpose_Type__c}
- <ui:inputSelect aura:id="select_purpose_type" class="slds-select" change="{!c.select_purpose_type}"/>
- </div>
- <!-- 璇环 -->
- <div aura:id="input-opportunity-opp" class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--4-of-12 slds-large-size--4-of-12 marginTop">
- {!v.fieldsmap.Opportunity__c}
- <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
- <!-- <force:inputField value="{!v.data.Opportunity__c}" aura:id="input-opportunity"/> -->
- <c:strike_lookup label=""
- object="Agency_Opportunity__c"
- searchField="Name"
- placeholder="鎼滅储缁忛攢鍟嗚浠�..."
- iconName="standard:opportunity"
- subtitleField="Department_Cateogy__c,Agency_Opportunity_No__c,Change_To_Opportunity__r.Name"
- order="StageName__c"
- limit="5"
- loadingMessage="Loading..."
- errorMessage="Invalid input"
- allowNewRecords = "true"
- overrideNewEvent = "true"
- showRecentRecords ="true"
- value="{!v.data.Opportunity__c}"
- filter="{!v.opportunity_cfilter}"
- subTitleFormat="{0}+{1}+{2}"/>
- </div>
- <div aura:id="input-opportunity-blank" class="lds-p-horizontal--small slds-size--1-of-1 slds-medium-size--8-of-12 slds-large-size--8-of-12 marginTop">
- </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 marginTop">
- {!v.fieldsmap.StageName__c}
- <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
- <ui:inputSelect aura:id="select_stageName" class="slds-select"/>
- <!-- <force:inputField value="{!v.oppdata.StageName__c}" aura:id="input-oppstage" /> -->
- </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 marginTop">
- {!v.fieldsmap.Amount__c}
- <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
- <force: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 marginTop">
- {!v.fieldsmap.OCMSale_Price__c}
- <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
- <force: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 marginTop">
- {!v.fieldsmap.Close_Forecasted_Date__c}
- <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
- <force:inputField value="{!v.oppdata.Close_Forecasted_Date__c}" class=""/>
- </div>
- <!-- 瑁藉搧鍒嗛 -->
- <div aura:id="product_category_select1" class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12 marginTop">
- {!v.fieldsmap.Product_Category1__c}
- <!-- <force:inputField value="{!v.data.Product_Category1__c}" aura:id="input-product-category1"/> -->
- <ui:inputSelect aura:id="select_Product1" class="slds-select" change="{!c.productcategoryChange1}"/>
- </div>
- <div aura:id="product_category_select2" class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12 marginTop">
- {!v.fieldsmap.Product_Category2__c}
- <!-- <force:inputField value="{!v.data.Product_Category2__c}" aura:id="input-product-category2"/> -->
- <ui:inputSelect aura:id="select_Product2" class="slds-select" change="{!c.productcategoryChange2}"/>
- </div>
- <div aura:id="product_category_select3" class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12 marginTop">
- {!v.fieldsmap.Product_Category3__c}
- <!-- <force:inputField value="{!v.data.Product_Category3__c}" aura:id="input-product-category3"/> -->
- <ui:inputSelect aura:id="select_Product3" class="slds-select" change="{!c.productcategoryChange3}"/>
- </div>
- <!--SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start-->
- <!-- 鏀彺闇�姹� change="{!c.SupportNeeds__c}"-->
- <div class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6 marginTop">
- {!v.fieldsmap.SupportNeeds__c}
- <ui:inputSelect aura:id="SupportNeeds__c" class="slds-select" />
- </div>
- <!--SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� end-->
- <div aura:id="result" class="disp_none slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12 marginTop">
- {!v.fieldsmap.Result__c}
- <ui:inputSelect aura:id="select_result" class="slds-select"/>
- <!-- <ui:inputText label="缁撴灉" class="bcolor" value="{!v.result}"/> -->
- </div>
- </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.Purpose_Type__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}">
- <span class="encrypt">{!item.doctor2__r.Name}</span>
- <span class="decrypt">{!item.doctor2NameOrigin}</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.visitor_title__c}">
- <span class="encrypt">{!item.visitor_title__c}</span>
- <span class="decrypt">{!item.visitorTitleOrigin}</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.Purpose_Type__c}">{!item.Purpose_Type__c}</span>
- </span>
- </td>
- </tr>
- </aura:iteration>
- </tbody>
- </table>
- </div>
- </div>
- </aura:renderIf>
+ </span>
+ </li>
+ </aura:iteration>
+ </ul>
+ </div>
</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
+ class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-8 marginTop"
+ >
+ {!v.fieldsmap.Department_Cateogy__c}
+ <ui:inputSelect
+ aura:id="select_department"
+ class="slds-select"
+ change="{!c.select_department}"
+ />
</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" />
- <!-- <lightning:inputField class="customRequired none" aura:id="Input_type__c" fieldName="Type__c"/>
+
+ <!-- 鍏堢敓 -->
+ <div
+ class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-8 marginTop"
+ >
+ {!v.fieldsmap.doctor2__c}
+ <ui:inputSelect
+ aura:id="select_doctor"
+ class="slds-select"
+ change="{!c.doctor_change}"
+ />
+ </div>
+
+ <div
+ class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-12 marginTop"
+ >
+ <br />
+ <ui:button
+ label="鏂板缓"
+ class="slds-button"
+ press="{!c.createCon}"
+ disabled="true"
+ aura:id="new_con"
+ />
+ </div>
+
+ <!-- 鑱屼綅 -->
+ <div
+ class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-8 marginTop"
+ >
+ {!v.fieldsmap.visitor_title__c}
+ <div>{!v.doctor_title}</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 marginTop"
+ >
+ {!v.fieldsmap.Purpose_Type__c}
+ <ui:inputSelect
+ aura:id="select_purpose_type"
+ class="slds-select"
+ change="{!c.select_purpose_type}"
+ />
+ </div>
+ <!-- 璇环 -->
+ <div
+ aura:id="input-opportunity-opp"
+ class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--4-of-12 slds-large-size--4-of-12 marginTop"
+ >
+ {!v.fieldsmap.Opportunity__c}
+ <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
+ <!-- <force:inputField value="{!v.data.Opportunity__c}" aura:id="input-opportunity"/> -->
+ <c:strike_lookup
+ label=""
+ object="Agency_Opportunity__c"
+ searchField="Name"
+ placeholder="鎼滅储缁忛攢鍟嗚浠�..."
+ iconName="standard:opportunity"
+ subtitleField="Department_Cateogy__c,Agency_Opportunity_No__c,Change_To_Opportunity__r.Name"
+ order="StageName__c"
+ limit="5"
+ loadingMessage="Loading..."
+ errorMessage="Invalid input"
+ allowNewRecords="true"
+ overrideNewEvent="true"
+ showRecentRecords="true"
+ value="{!v.data.Opportunity__c}"
+ filter="{!v.opportunity_cfilter}"
+ subTitleFormat="{0}+{1}+{2}"
+ />
+ </div>
+ <div
+ aura:id="input-opportunity-blank"
+ class="lds-p-horizontal--small slds-size--1-of-1 slds-medium-size--8-of-12 slds-large-size--8-of-12 marginTop"
+ ></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 marginTop"
+ >
+ {!v.fieldsmap.StageName__c}
+ <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
+ <ui:inputSelect aura:id="select_stageName" class="slds-select" />
+ <!-- <force:inputField value="{!v.oppdata.StageName__c}" aura:id="input-oppstage" /> -->
+ </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 marginTop"
+ >
+ {!v.fieldsmap.Amount__c}
+ <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
+ <force: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 marginTop"
+ >
+ {!v.fieldsmap.OCMSale_Price__c}
+ <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
+ <force: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 marginTop"
+ >
+ {!v.fieldsmap.Close_Forecasted_Date__c}
+ <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
+ <force:inputField
+ value="{!v.oppdata.Close_Forecasted_Date__c}"
+ class=""
+ />
+ </div>
+ <!-- 瑁藉搧鍒嗛 -->
+ <div
+ aura:id="product_category_select1"
+ class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12 marginTop"
+ >
+ {!v.fieldsmap.Product_Category1__c}
+ <!-- <force:inputField value="{!v.data.Product_Category1__c}" aura:id="input-product-category1"/> -->
+ <ui:inputSelect
+ aura:id="select_Product1"
+ class="slds-select"
+ change="{!c.productcategoryChange1}"
+ />
+ </div>
+ <div
+ aura:id="product_category_select2"
+ class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12 marginTop"
+ >
+ {!v.fieldsmap.Product_Category2__c}
+ <!-- <force:inputField value="{!v.data.Product_Category2__c}" aura:id="input-product-category2"/> -->
+ <ui:inputSelect
+ aura:id="select_Product2"
+ class="slds-select"
+ change="{!c.productcategoryChange2}"
+ />
+ </div>
+ <div
+ aura:id="product_category_select3"
+ class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12 marginTop"
+ >
+ {!v.fieldsmap.Product_Category3__c}
+ <!-- <force:inputField value="{!v.data.Product_Category3__c}" aura:id="input-product-category3"/> -->
+ <ui:inputSelect
+ aura:id="select_Product3"
+ class="slds-select"
+ change="{!c.productcategoryChange3}"
+ />
+ </div>
+ <!--SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start-->
+ <!-- 鏀彺闇�姹� change="{!c.SupportNeeds__c}"-->
+ <div
+ class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6 marginTop"
+ >
+ {!v.fieldsmap.SupportNeeds__c}
+ <ui:inputSelect aura:id="SupportNeeds__c" class="slds-select" />
+ </div>
+ <!--SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� end-->
+ <div
+ aura:id="result"
+ class="disp_none slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--3-of-12 slds-large-size--3-of-12 marginTop"
+ >
+ {!v.fieldsmap.Result__c}
+ <ui:inputSelect aura:id="select_result" class="slds-select" />
+ <!-- <ui:inputText label="缁撴灉" class="bcolor" value="{!v.result}"/> -->
+ </div>
+ </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.Purpose_Type__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}"
+ >
+ <span class="encrypt">{!item.doctor2__r.Name}</span>
+ <span class="decrypt"
+ >{!item.doctor2NameOrigin}</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.visitor_title__c}"
+ >
+ <span class="encrypt"
+ >{!item.visitor_title__c}</span
+ >
+ <span class="decrypt"
+ >{!item.visitorTitleOrigin}</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.Purpose_Type__c}"
+ >{!item.Purpose_Type__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">
+ <aura:renderIf isTrue="{!v.loginEdit}">
+ <lightning:spinner
+ alternativeText="Loading"
+ size="medium"
+ style="width: 100%; height: 80%; top: 50px"
+ />
+ </aura:renderIf>
+ <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"
+ />
+ <!-- <lightning:inputField class="customRequired none" aura:id="Input_type__c" fieldName="Type__c"/>
<lightning:inputField class="customRequired none" aura:id="Input_Doctor_Division1__c" fieldName="Doctor_Division1__c"/> -->
- </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="submit" label="淇濆瓨" />
- </div>
-
-
- </lightning:recordEditForm>
- </div>
- </div>
+ </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="submit"
+ label="淇濆瓨"
+ />
+ </div>
+ </lightning:recordEditForm>
+ </div>
</div>
-
-
-</aura:component>
\ No newline at end of file
+ </div>
+</aura:component>
diff --git a/force-app/main/default/aura/WeeklyReport/WeeklyReport.css b/force-app/main/default/aura/WeeklyReport/WeeklyReport.css
index 271d3f3..8b2291b 100644
--- a/force-app/main/default/aura/WeeklyReport/WeeklyReport.css
+++ b/force-app/main/default/aura/WeeklyReport/WeeklyReport.css
@@ -1,158 +1,170 @@
.THIS .bcolor {
- color: #333;
+ color: #333;
}
.THIS.height100vh {
- height: 100vh;
+ height: 100vh;
}
-.THIS.contents_wrapper {
+/* .THIS.contents_wrapper {
padding-top: 50px;
-}
+ width: 105%;
+} */
.THIS .mt5 {
- margin-top: 5px;
+ margin-top: 5px;
}
.THIS .mt40 {
- margin-top: 40px;
+ margin-top: 40px;
}
.THIS .edit_button {
- float: right;
- margin: -1.5em 0.5em 0 0;
- border: 0;
+ float: right;
+ margin: -1.5em 0.5em 0 0;
+ border: 0;
}
.THIS .no_data_area {
- text-align: center;
- margin: .5em 0;
+ text-align: center;
+ margin: 0.5em 0;
}
.THIS.report_list_area {
- margin: 40px 0 20px 100px;
- height: 60vh;
- overflow-y: scroll;
+ margin: 40px 0 20px 0px;
+ height: 60vh;
+ overflow-y: scroll;
}
.THIS .report_radio {
- float: left;
+ float: left;
}
.THIS .table_header {
- width: 9.4rem;
- height: 2em;
+ width: 9.4rem;
+ height: 2em;
}
.THIS.disp_none {
- display: none;
+ display: none;
}
.THIS .disp_none {
- display: none;
+ display: none;
}
.THIS .tr {
- text-align: right;
+ text-align: right;
}
.THIS .close_button {
- float: right;
- margin-top: -2em;
+ float: right;
+ margin-top: -2em;
}
.THIS .close_icn svg {
- fill: #fefefe;
+ fill: #fefefe;
}
.THIS .slds-progress__marker {
- cursor: default;
+ cursor: default;
}
.THIS .progress_0 {
- width: 0%;
+ width: 0%;
}
.THIS .progress_100 {
- width: 100%;
+ width: 100%;
}
.THIS .new_btn_area {
- text-align: center;
- margin-top: 22px;
+ text-align: center;
+ margin-top: 22px;
}
.THIS .new_btn {
- width: 100%;
+ width: 100%;
}
.THIS .save_button_area {
- margin: 1em 0;
- text-align: right;
+ margin: 1em 0;
+ text-align: right;
}
.THIS .save_button {
- background-color: #ffa500;
- border: 1px solid #ff8c00;
+ background-color: #ffa500;
+ border: 1px solid #ff8c00;
}
.THIS .report_data_header {
- border-bottom: 2px solid #ccc;
+ border-bottom: 2px solid #ccc;
}
.THIS .report_data_area {
- border-bottom: 1px solid #ccc;
+ border-bottom: 1px solid #ccc;
}
.THIS.fade {
- transition: 5s opacity linear;
+ transition: 5s opacity linear;
}
.THIS.animation_off {
- opacity: 0;
+ opacity: 0;
}
.THIS.animation_on {
- opacity: 1;
+ opacity: 1;
}
.THIS .fade {
- transition: 5s opacity linear;
+ transition: 5s opacity linear;
}
.THIS .animation_off {
- opacity: 0;
+ opacity: 0;
}
.THIS .animation_on {
- opacity: 1;
+ opacity: 1;
}
-.THIS .divbotuser{
- width:fit-content;
+.THIS .divbotuser {
+ width: fit-content;
}
-.THIS .toastMessage.forceActionsText{
- white-space : pre-line !important;
+.THIS .toastMessage.forceActionsText {
+ white-space: pre-line !important;
}
-.THIS .slds-file-selector__dropzone .slds-file-selector__text{
- display: none;
+.THIS .slds-file-selector__dropzone .slds-file-selector__text {
+ display: none;
}
-.THIS .slds-input:focus, .THIS .slds-input:active {
- border-color: rgb(216, 221, 230);
- box-shadow: none;
+.THIS .slds-input:focus,
+.THIS .slds-input:active {
+ border-color: rgb(216, 221, 230);
+ box-shadow: none;
}
-.THIS .customRequired{
- font-weight: 400;
-}
-.THIS .customRequired:before{
- content: "*";
- margin: 0 0.125rem 0 0.125rem;
- color: rgb(194, 57, 52);
- float: left;
-}
-.THIS .none{
- display:none;
+.THIS .customRequired {
+ font-weight: 400;
+}
+.THIS .customRequired:before {
+ content: "*";
+ margin: 0 0.125rem 0 0.125rem;
+ color: rgb(194, 57, 52);
+ float: left;
+}
+.THIS .none {
+ display: none;
}
-.THIS tr .decrypt{
- display: none;
+.THIS tr .decrypt {
+ display: none;
}
-.THIS tr:hover .decrypt{
- display: unset;
+.THIS tr:hover .decrypt {
+ display: unset;
}
-.THIS tr:hover .encrypt{
- display: none;
+.THIS tr:hover .encrypt {
+ display: none;
}
/* add by Deloitte-Link 2023-6-19 start*/
-.THIS .weeklyReportSpinner{
- top:100px;
+.THIS .weeklyReportSpinner {
+ top: 100px;
}
-.THIS .slds-spinner_container{
- position: absolute;
- top:100px;
+.THIS .weeklyReportSpinnerEdit {
+ top: 50px;
}
-.THIS .marginTop{
- margin-top: 10px;
+
+.THIS .slds-spinner_container {
+ position: absolute;
+ top: 100px;
+}
+
+.THIS .slds-spinner_containerEdit {
+ position: absolute;
+ top: 50px;
+}
+
+.THIS .marginTop {
+ margin-top: 10px;
}
.THIS .custom-input .uiInput {
- height: 2rem; /* 璋冩暣楂樺害涓轰綘闇�瑕佺殑鍊硷紝濡� 2rem */
+ height: 2rem;
}
-/* add by Deloitte-Link 2023-6-19 end*/
\ No newline at end of file
+/* add by Deloitte-Link 2023-6-19 end*/
diff --git a/force-app/main/default/aura/WeeklyReport/WeeklyReportController.js b/force-app/main/default/aura/WeeklyReport/WeeklyReportController.js
index 9c2e49c..02ef7bc 100644
--- a/force-app/main/default/aura/WeeklyReport/WeeklyReportController.js
+++ b/force-app/main/default/aura/WeeklyReport/WeeklyReportController.js
@@ -1,326 +1,354 @@
({
- doInit : function(component, event, helper) {
- console.log('zhj 鏂版柟妗坵eeklyReport');
- if (window.location.href.endsWith("weekly-report")) {
- helper.doinit(component, event, helper);
- } else {
- helper.hideCmp(component, event, helper);
- }
- component.set("v.showErrorInfo", false);
- },
+ doInit: function (component, event, helper) {
+ console.log("zhj 鏂版柟妗坵eeklyReport");
+ if (window.location.href.endsWith("weekly-report")) {
+ helper.doinit(component, event, helper);
+ } else {
+ helper.hideCmp(component, event, helper);
+ }
+ component.set("v.showErrorInfo", false);
+ },
- createAopp : function(component, event, helper) {
- var addRecordEvent = $A.get('e.force:createRecord');
- addRecordEvent.setParams({
- entityApiName: 'Agency_Opportunity__c',
- recordTypeId: '012100000006KW7'
- });
- addRecordEvent.fire();
- component.set("v.showErrorInfo", false);
- },
-
- new_report : function(component, event, helper) {
- component.find('save_button').set('v.label', '淇濆瓨骞舵柊寤�');
- component.set('v.data.Report_Date__c', '');
- 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();
+ component.set("v.showErrorInfo", false);
+ },
- 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) {
- /*
+ new_report: function (component, event, helper) {
+ component.find("save_button").set("v.label", "淇濆瓨骞舵柊寤�");
+ component.set("v.data.Report_Date__c", "");
+ 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);
+ },
+
+ 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) {
+ /*
var params = event.getParams();
params.fields["Agency_Hospital__c"] = component.get('v.hospitalLinkId');
console.log(params);
event.setParams(params);
*/
- event.preventDefault(); // stop form submission
- // vivek 娣诲姞楠岃瘉 start
- // helper.handleFormSubmit(component);
- var showValidationError = false;
- var fields = component.find("newOpportunityField");
- var vaildationFailReason = '';
- // var vaildationFailReason2 = '';
- // var currentDate = new Date().toJSON().slice(0,10);
-
- // PIPL update Yin Mingjie 21/02/2022 start
- let agencyReport = Object.create(null);
- // PIPL update Yin Mingjie 21/02/2022 end
+ event.preventDefault(); // stop form submission
+ // vivek 娣诲姞楠岃瘉 start
+ // helper.handleFormSubmit(component);
+ var showValidationError = false;
+ var fields = component.find("newOpportunityField");
+ var vaildationFailReason = "";
+ // var vaildationFailReason2 = '';
+ // var currentDate = new Date().toJSON().slice(0,10);
- 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 = "鍖荤敓鍖哄垎(鑱屽姟)涓嶈兘涓虹┖锛�";
- }
-
- }
- // PIPL update Yin Mingjie 21/02/2022 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");
- }
- // PIPL update Yin Mingjie 21/02/2022 end
- });
-
- if (!showValidationError) {
- // PIPL update Yin Mingjie 21/02/2022 start
- /*
+ // PIPL update Yin Mingjie 21/02/2022 start
+ let agencyReport = Object.create(null);
+ // PIPL update Yin Mingjie 21/02/2022 end
+
+ 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 = "鍖荤敓鍖哄垎(鑱屽姟)涓嶈兘涓虹┖锛�";
+ }
+ }
+ // PIPL update Yin Mingjie 21/02/2022 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");
+ }
+ // PIPL update Yin Mingjie 21/02/2022 end
+ });
+
+ if (!showValidationError) {
+ // PIPL update Yin Mingjie 21/02/2022 start
+ /*
var eventFields = event.getParam("fields");
eventFields["Agency_Hospital__c"] = component.get('v.hospitalLinkId');
component.find('recordEditForm').submit(eventFields);
*/
- 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);
-
- var token = component.get('v.AWStoken');
- var newUrl = component.get('v.AWSinsert') + 'V2';
-
- 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"
- });
+ 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;
}
- })
- //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
- // var arr = new Array();
- // arr.push(agencyReport);
- // var data = JSON.stringify(arr);
- // // helper.set_aws_url(component,data,agencyHospitalid);
+ 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);
- // 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);
+ var token = component.get("v.AWStoken");
+ var newUrl = component.get("v.AWSinsert") + "V2";
- // PIPL update Yin Mingjie 21/02/2022 end
- }else{
- component.find('OppMessage').setError(vaildationFailReason);
+ component.set("v.loginEdit", 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"
+ });
+ }
}
- // var eventFields = event.getParam("fields");
- // eventFields["Agency_Hospital__c"] = component.get('v.hospitalLinkId');
- // component.find('recordEditForm').submit(eventFields);
- // vivek 娣诲姞楠岃瘉 end
- },
-
- 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'));
- },
+ );
+ //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
+ // var arr = new Array();
+ // arr.push(agencyReport);
+ // var data = 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);
- },
+ // var token = component.get('v.AWStoken');
+ // var newUrl = component.get('v.AWSinsert');
- 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);
- },
- select_department : function(component, event, helper) {
- helper.select_department(component, event, helper);
- helper.setOpportunity_cfilter(component);
- },
- select_purpose_type : function(component, event, helper) {
- helper.select_purpose_type(component, event, helper);
- },
-
- doctor_change : function(component, event, helper) {
- helper.doctor_change(component, event, helper);
- },
-
- opportunityChange : function(component, event, helper) {
- helper.opportunityChange(component, event, helper);
- },
-
- productcategoryChange1 : function(component, event, helper) {
- helper.productcategoryChange1(component, event, helper);
- },
- productcategoryChange2 : function(component, event, helper) {
- helper.productcategoryChange2(component, event, helper);
- },
- productcategoryChange3 : function(component, event, helper) {
- helper.productcategoryChange3(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");
- // var fileInput = component.find("file").getElement();
- // var file = fileInput.files[0];
- helper.readFile(component,helper,files[0]);
- component.set("v.showErrorInfo", false);
- },
+ // component.set('v.login',true);
+ // helper.insert_agencycontact(component,token,newUrl,data,agencyHospitalid,helper);
- 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);
- },
+ // PIPL update Yin Mingjie 21/02/2022 end
+ } else {
+ component.find("OppMessage").setError(vaildationFailReason);
+ }
+ // var eventFields = event.getParam("fields");
+ // eventFields["Agency_Hospital__c"] = component.get('v.hospitalLinkId');
+ // component.find('recordEditForm').submit(eventFields);
+ // vivek 娣诲姞楠岃瘉 end
+ },
- import : function(component,event,helper){
- // component.find('file').click();
- // console.log('lll'+component.find('file'));
- 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;}
+ createCancel: function (component, event, helper) {
+ helper.createCancel(component, event, helper);
+ },
- // ####--code for create a temp. <a> html tag [link tag] for download the CSV file--####
- 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
- // helper.showExport(component);
-
- },
+ 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")
+ );
+ },
- export_condition : function(component,event,helper){
- helper.showExport(component);
- },
+ 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")
+ );
+ },
- select_repores_date : function(component,event,helper){
- helper.select_repores_date(component,event,helper);
- // var stockData = component.get("v.reports_date");
- // console.log('鏌ュ嚭鐨勬暟鎹�'+stockData);
- // helper.showExportDate(component,stockData);
- // this.export(component,event,helper);
- },
- export : function(component,event,helper){
- console.log('杩涘叆export');
- var stockData = component.get("v.reports_date");
- console.log('鏌ュ嚭鐨勬暟鎹�'+stockData);
- // helper.showExportDate(component,stockData);
- // helper.showExport(component);
- },
- 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);
- },
- exportErrorInfo: function(component,event,helper){
- helper.exportErrorInfoHelper(component);
- },
-})
\ No newline at end of file
+ toggle_report: function (component, event, helper) {
+ helper.toggle_report(component);
+ },
+
+ 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);
+ },
+ select_department: function (component, event, helper) {
+ helper.select_department(component, event, helper);
+ helper.setOpportunity_cfilter(component);
+ },
+ select_purpose_type: function (component, event, helper) {
+ helper.select_purpose_type(component, event, helper);
+ },
+
+ doctor_change: function (component, event, helper) {
+ helper.doctor_change(component, event, helper);
+ },
+
+ opportunityChange: function (component, event, helper) {
+ helper.opportunityChange(component, event, helper);
+ },
+
+ productcategoryChange1: function (component, event, helper) {
+ helper.productcategoryChange1(component, event, helper);
+ },
+ productcategoryChange2: function (component, event, helper) {
+ helper.productcategoryChange2(component, event, helper);
+ },
+ productcategoryChange3: function (component, event, helper) {
+ helper.productcategoryChange3(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");
+ // var fileInput = component.find("file").getElement();
+ // var file = fileInput.files[0];
+ helper.readFile(component, helper, files[0]);
+ component.set("v.showErrorInfo", false);
+ },
+
+ 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) {
+ // component.find('file').click();
+ // console.log('lll'+component.find('file'));
+ 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;
+ }
+
+ // ####--code for create a temp. <a> html tag [link tag] for download the CSV file--####
+ 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
+ // helper.showExport(component);
+ },
+
+ export_condition: function (component, event, helper) {
+ helper.showExport(component);
+ },
+
+ select_repores_date: function (component, event, helper) {
+ helper.select_repores_date(component, event, helper);
+ // var stockData = component.get("v.reports_date");
+ // console.log('鏌ュ嚭鐨勬暟鎹�'+stockData);
+ // helper.showExportDate(component,stockData);
+ // this.export(component,event,helper);
+ },
+ export: function (component, event, helper) {
+ console.log("杩涘叆export");
+ var stockData = component.get("v.reports_date");
+ console.log("鏌ュ嚭鐨勬暟鎹�" + stockData);
+ // helper.showExportDate(component,stockData);
+ // helper.showExport(component);
+ },
+ 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);
+ },
+ exportErrorInfo: function (component, event, helper) {
+ helper.exportErrorInfoHelper(component);
+ }
+});
diff --git a/force-app/main/default/aura/WeeklyReport/WeeklyReportHelper.js b/force-app/main/default/aura/WeeklyReport/WeeklyReportHelper.js
index 7816c68..b31c0f9 100644
--- a/force-app/main/default/aura/WeeklyReport/WeeklyReportHelper.js
+++ b/force-app/main/default/aura/WeeklyReport/WeeklyReportHelper.js
@@ -1,1371 +1,1839 @@
({
- doinit : function(component, event, helper) {
- 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);
- // PIPL update Yin Mingjie 21/02/2022 start
- component.find('select_agency_person').set('v.options', this.conv_selected(res.allselectlist.AgencyPerson__c));
- // this.search_contact(component, event, helper,res.allselectlist.AgencyPerson__c);
- // PIPL update Yin Mingjie 21/02/2022 end
- component.find('select_department').set('v.options', this.conv_selected(res.allselectlist.Department_Cateogy__c));
- component.find('select_purpose_type').set('v.options', this.conv_selected(res.allselectlist.Purpose_Type__c));
- component.find('select_result').set('v.options', this.conv_selected(res.allselectlist.Result__c));
- component.find('select_stageName').set('v.options', this.conv_selected(res.allselectlist.StageName__c));
- //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
- component.find('SupportNeeds__c').set('v.options', this.conv_selected(res.allselectlist.SupportNeeds__c));
- //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� end
- component.set('v.selected_agency_person', res.allselectlist.AgencyPerson__c[0].label);
- component.set('v.dialog_type', '鏂板缓');
- component.set('v.awsurl', res.awsurl);// 20220222 PI鏀归�� by Bright
- component.set('v.contactawsurl', res.contactawsurl);// 20220222 PI鏀归�� by Bright
-
- this.get_reports(component, event, helper, component.find('select_date').get('v.value'), component.find('select_agency_person').get('v.value'));
-
- component.set('v.login',false);
- }
- else{
- this.error('doinit failed.');
- component.set('v.login',false);
- }
- });
- $A.enqueueAction(action);
- },
-
- // PIPL update Yin Mingjie 21/02/2022 start
- search_contact : function(component, event, helper, resobj) {
- let contactData = Object.create(null);
- var dataArr = new Array();
- for (let i = 0; i < resobj.length; i++) {
- if (resobj[i].awsid != null && resobj[i].awsid != ''){
- contactData[resobj[i].awsid] = resobj[i];
- dataArr.push(resobj[i].awsid);
- }
- }
- let obj= Object.create(null);
- obj['dataIds'] = dataArr;
- var payload = JSON.stringify(obj);
- this.search_contact_url(component, 'Contact', (result)=>{
- var token = result.token;
- var searchUrl = result.searchUrl;
- this.search_core(token,searchUrl,payload,(result)=>{
- if(result.status == '0'){
- if(result.object != null){
- this.to_contact_list(result,contactData,component);
- }else{
- component.set('v.login',false);
- }
- }else{
- this.error('AWS search status1 : ' + result.status);
- component.set('v.login',false);
- }
- },component);
-
- });
- },
-
- to_contact_list : function(result,retMap,component) {
- var resls = result.object;
- var res = [];
- var space = {};
- space['label'] = '';
- space['selected'] = true;
- space['value'] = '';
- res.push(space);
-
- for (var i = 0; i < resls.length; i++) {
- var t = {};
- t['label'] = resls[i].lastName;
- t['selected'] = false;
- t['Doctor_Division1__c'] = resls[i].doctorDivision1;
- t['value'] = retMap[resls[i].dataId].value;
- res.push(t);
- }
- component.find('select_agency_person').set('v.options',res);
- component.set('v.allselectlistAgencyPerson',res);
- component.set('v.login',false);
- },
-
- 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{
- this.error('AWS url/token error.');
- component.set('v.login',false);
- }
- });
- $A.enqueueAction(action);
- },
- // PIPL update Yin Mingjie 21/02/2022 end
-
- select_department : function(component, event, helper) {
- var dc = component.find("select_department").get("v.value");
- dc = dc ? '%'+dc+'%' : '';
- var purpose_type = component.find("select_purpose_type").get("v.value");
- if (purpose_type) {
- if (purpose_type.substr(-3) == 'OPD') {
- purpose_type = 'OPD';
- } else if (purpose_type.substr(-3) == 'SIS') {
- purpose_type = 'SIS';
- } else {
- purpose_type = '';
- }
- }
- if (dc != '' || purpose_type != '') {
-
- var action = component.get('c.getProductList');
- action.setParams({
- "dc" : dc,
- "opdsis" : purpose_type,
- });
- action.setCallback(this,function(response){
- var state = response.getState();
- if(state == 'SUCCESS'){
-
- var res = response.getReturnValue();
- component.find('select_Product1').set("v.options", JSON.parse(JSON.stringify(res)));
- component.find('select_Product2').set("v.options", JSON.parse(JSON.stringify(res)));
- component.find('select_Product3').set("v.options", JSON.parse(JSON.stringify(res)));
- }
- else{
- this.error('getProductList failed.');
- }
- });
- $A.enqueueAction(action);
- } else {
- component.find('select_Product1').set('v.options', []);
- component.find('select_Product2').set('v.options', []);
- component.find('select_Product3').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);
-
- // 20220222 PI鏀归�� by Bright--start
- let dataIds = [];
- let dataIds1 = [];
- let mm = {};
- let b = false;
- let b1 = false;
- for (const rep of res.reports) {
- if (rep.doctor2__r && rep.doctor2__r.AWS_Data_Id__c) {
- dataIds.push(rep.doctor2__r.AWS_Data_Id__c);
- }
-
- if (rep.Person_In_Charge2__r && rep.Person_In_Charge2__r.AWS_Data_Id__c) {
- dataIds1.push(rep.Person_In_Charge2__r.AWS_Data_Id__c);
- }
- }
- let Foo = null;
- Foo = function(){
- if(b && b1){
- for (const rep of res.reports) {
- if (rep.doctor2__r && rep.doctor2__r.AWS_Data_Id__c && mm.hasOwnProperty(rep.doctor2__r.AWS_Data_Id__c)) {
- rep.doctor2__r.awsdata = mm[rep.doctor2__r.AWS_Data_Id__c];
- }
- if (rep.Person_In_Charge2__r && rep.Person_In_Charge2__r.AWS_Data_Id__c && mm.hasOwnProperty(rep.Person_In_Charge2__r.AWS_Data_Id__c)) {
- rep.Person_In_Charge2__r.awsdata = mm[rep.Person_In_Charge2__r.AWS_Data_Id__c];
- }
- }
-
- $A.getCallback(()=>component.set('v.reports', res.reports))();
- }else{
- console.log('b='+b + ',b1='+b1+',continue');
- setTimeout(Foo,100);
- }
- }
-
- if(dataIds.length > 0){
- let awsurl = component.get('v.awsurl');
- helper.search_core(awsurl.token,awsurl.searchUrl,JSON.stringify({
- "dataIds":dataIds
- }),(result)=>{
- if(result.status == '0'){
-
- for (const m of result.object) {
- mm[m.dataId] = m;
- }
- b = true;
- Foo();
- }else{
- //this.error('AWS search status2 : ' + result.status);
- this.success('璇烽噸鏂板埛鏂伴〉闈㈣繘琛岃В瀵�');
- }
- },component);
- }else{
- b = true;
- }
-
-
-
- if(dataIds1.length > 0){
- let contactawsurl = component.get('v.contactawsurl');
- helper.search_core(contactawsurl.token,contactawsurl.searchUrl,JSON.stringify({
- "dataIds":dataIds1
- }),(result)=>{
- if(result.status == '0'){
-
- for (const m of result.object) {
- mm[m.dataId] = m;
- }
- b1 = true;
- Foo();
- }else{
- this.error('AWS search status3 : ' + result.status);
- }
- },component);
- }else{
- b1 = true;
- }
- // 20220222 PI鏀归�� by Bright--end
-
- 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 (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', '');
- } else {
- component.set('v.list_message', 'no_data');
- }
- component.set('v.login',false);
- }
- else{
- this.error('get_reports failed.');
- 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'));
- this.new_button_disabled(component, event, helper);
-
- 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);
- this.new_button_disabled(component, event, helper);
-
- component.set('v.select_report_data_radio', '');
- component.find('copy_button').set('v.disabled', true);
- },
-
- get_agency_person_name : function(component, agency_person_value) {
+ doinit: function (component, event, helper) {
+ 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);
// PIPL update Yin Mingjie 21/02/2022 start
- var allselectlist = component.get('v.allselectlist.AgencyPerson__c');
- // var allselectlist = component.get('v.allselectlistAgencyPerson');
+ component
+ .find("select_agency_person")
+ .set(
+ "v.options",
+ this.conv_selected(res.allselectlist.AgencyPerson__c)
+ );
+ // this.search_contact(component, event, helper,res.allselectlist.AgencyPerson__c);
// PIPL update Yin Mingjie 21/02/2022 end
- 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;
- },
-
- new_button_disabled : function(component, event, helper) {
- var select_date = component.find('select_date').get('v.value');
- var select_agency = component.find('select_agency_person').get('v.value');
- if (select_date && select_agency) {
- component.find('new_button').set('v.disabled', false);
- } else {
- component.find('new_button').set('v.disabled', true);
- }
- },
-
- 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 = '';
- debugger
- // 鍖婚櫌鍚�
- 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);
- }
-
- // 绉戝
- if (select_data['Department_Cateogy__c'] != '') {
- this.set_selected(component, 'select_department', select_data['Department_Cateogy__c']);
- }
- // 鎷滆浜�
- component.set('v.default_select_doctor_id', select_data['doctor2__c']);
- this.set_doctor_list(component);
-
- // 娲诲姩鍖哄垎
- if (select_data['Purpose_Type__c'] != '') {
- this.set_selected(component, 'select_purpose_type', select_data['Purpose_Type__c']);
- this.select_purpose_type(component);
- }
- //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
- // 鏀彺闇�姹�
- if (select_data['SupportNeeds__c'] != '') {
- this.set_selected(component, 'SupportNeeds__c', select_data['SupportNeeds__c']);
- }
- //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� end
- // 绲愭灉
- if (select_data['Result__c'] != '' && typeof select_data['Result__c'] !== "undefined") {
- component.find('select_result').set('v.value', select_data['Result__c']);
- }
-
- // 璇环
- var report_id = component.get('v.edit_copy_select_report_id');
- if (report_id != "") {
- var select_opp = '';
- var select_product_category1 = '';
- var select_product_category2 = '';
- var select_product_category3 = '';
- var reportDate;
- var i = 0;
- for (i = 0; i < reports.length; i++) {
- if (report_id == reports[i]["Id"]) {
- select_opp = reports[i]["Opportunity__c"];
- select_product_category1 = reports[i]["Product_Category1__c"];
- select_product_category2 = reports[i]["Product_Category2__c"];
- select_product_category3 = reports[i]["Product_Category3__c"];
- reportDate = reports[i]["Report_Date__c"];
- break;
- }
- }
-
- // 璇环
- if (select_opp != null && select_opp != '') {
- var select_opp_name = component.get('v.reports')[i].OppName__c;
- component.set('v.data.Opportunity__c', select_opp);
- if ($A.get("$Browser.formFactor") == 'DESKTOP') {
- var values = [{
- type: 'Agency_Opportunity__c',
- id: select_opp,
- label: select_opp_name,
- icon : {
- url:'/img/icon/t4v35/custom/custom12_120.png',
- backgroundColor:'dc71d1',
- alt:'Agency_Opportunity__c'
- }
- }];
- component.set('v.data.Opportunity__c', select_opp);
- // component.find('input-opportunity').get("v.body")[0].set('v.values', values);
- } else {
- component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', select_opp_name);
- }
- }
-
- // 浜у搧鍖哄垎
- if (select_product_category1 != null && select_product_category1 != '') {
- component.find('select_Product1').set('v.value', select_product_category1);
- }
- if (select_product_category2 != null && select_product_category2 != '') {
- component.find('select_Product2').set('v.value', select_product_category2);
- }
- if (select_product_category3 != null && select_product_category3 != '') {
- component.find('select_Product3').set('v.value', select_product_category3);
- }
-
- if (reportDate != null) {
- console.log('reportDate = ' + reportDate);
- component.set('v.data.Report_Date__c', reportDate);
- }
-
- component.set('v.edit_copy_select_report_id', "");
- }
- }
- } else {
- // CLOSE
-
- 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 Department_Cateogy__c = component.find('select_department').get('v.value');
- var doctor2__c = component.find('select_doctor').get('v.value');
- var Purpose_Type__c = component.find('select_purpose_type').get('v.value');
- var SupportNeeds__c = component.find('SupportNeeds__c').get('v.value');
- var Opportunity__c = component.get('v.data.Opportunity__c');
- var Product_Category1__c = component.find('select_Product1').get('v.value');
- var Product_Category2__c = component.find('select_Product2').get('v.value');
- var Product_Category3__c = component.find('select_Product3').get('v.value');
- var Result__c = component.find('select_result').get('v.value');
-
- if (select_report_data !== null) {
- if (typeof select_report_data['Opportunity__c'] === "undefined") {
- select_report_data['Opportunity__c'] = "";
- }
- if (typeof select_report_data['Product_Category1__c'] === "undefined") {
- select_report_data['Product_Category1__c'] = "";
- }
- if (typeof select_report_data['Product_Category2__c'] === "undefined") {
- select_report_data['Product_Category2__c'] = "";
- }
- if (typeof select_report_data['Product_Category3__c'] === "undefined") {
- select_report_data['Product_Category3__c'] = "";
- }
- if (typeof select_report_data['Result__c'] === "undefined") {
- select_report_data['Result__c'] = "";
- }
- }
-
- if (component.get('v.mode') == 'new') {
- var confirm_title = '璀﹀憡!'
- var confirm_text = '鏀惧純鏂板缓鍛ㄦ姤锛�';
-
- if (!Report_Date__c &&
- !Agency_Hospital__c &&
- !Department_Cateogy__c &&
- !doctor2__c &&
- !Purpose_Type__c &&
- !SupportNeeds__c&&//WAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔�
- !Opportunity__c &&
- !Product_Category1__c &&
- !Product_Category2__c &&
- !Product_Category3__c &&
- !Result__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['Department_Cateogy__c'] == Department_Cateogy__c &&
- select_report_data['doctor2__c'] == doctor2__c &&
- select_report_data['Purpose_Type__c'] == Purpose_Type__c &&
- select_report_data['SupportNeeds__c'] == SupportNeeds__c &&//WAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔�
- select_report_data['Opportunity__c'] == Opportunity__c &&
- select_report_data['Product_Category1__c'] == Product_Category1__c &&
- select_report_data['Product_Category2__c'] == Product_Category2__c &&
- select_report_data['Product_Category3__c'] == Product_Category3__c &&
- select_report_data['Result__c'] == Result__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['Department_Cateogy__c'] == Department_Cateogy__c &&
- select_report_data['doctor2__c'] == doctor2__c &&
- select_report_data['Purpose_Type__c'] == Purpose_Type__c &&
- select_report_data['SupportNeeds__c'] == SupportNeeds__c &&//WAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔�
- select_report_data['Opportunity__c'] == Opportunity__c &&
- select_report_data['Product_Category1__c'] == Product_Category1__c &&
- select_report_data['Product_Category2__c'] == Product_Category2__c &&
- select_report_data['Product_Category3__c'] == Product_Category3__c &&
- select_report_data['Result__c'] == Result__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');
- component.set('v.selected_date', select_date);
- var name = component.get('v.selected_agency_person');
- var ret = this.create_report_header(component, name, select_agency, select_date);
- // PIPL update Yin Mingjie 21/02/2022 start
- this.set_aws_url(component,'Agency_Contact__c')
- // PIPL update Yin Mingjie 21/02/2022 end
- },
-
- 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);
-
- this.new_button_disabled(component, event, helper);
-
- 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, 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);
- 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);
- this.new_button_disabled(component, event, helper);
-
- 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, name, select_agency, select_date);
- },
-
- save_report : function(component, event, helper) {
-
- // 20220222 PI鏀归�� by Bright--start
- let doctor2Name = '';
- let visitortitle = '';
- for(let op of component.find('select_doctor').get('v.options')){
- if (op.selected) {
- doctor2Name = op.label;
- visitortitle = op.Doctor_Division1__c;
- }
- }
- // 20220222 PI鏀归�� by Bright--end
-
-
- component.find('save_button').set('v.disabled', true);
-
- var Report_Date__c = component.get('v.data.Report_Date__c');
- // alert('Report_Date__c'+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;
- // alert('Submit_date__c'+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'));
- // alert('Submit_date__c'+Submit_date__c);
-
- // 鎷呭綋 Person_In_Charge2__c
- Person_In_Charge2__c = component.find('select_agency_person').get('v.value');
- }
- // Agency_Report_Header__c
- var Agency_Report_Header__c = component.get('v.agency_report_header_id');
-
- // 鍖婚櫌 Agency_Hospital__c (Agency_Hospital_Link__c)
- var Agency_Hospital__c = component.get('v.hospitalLinkId');
-
- // 绉戝 Department_Cateogy__c
- var Department_Cateogy__c = component.find('select_department').get('v.value');
-
- // 鎷滆浜� doctor2__c
- var doctor2__c = component.find('select_doctor').get('v.value');
-
- // 娲诲姩鍖哄垎 Purpose_Type__c
- var Purpose_Type__c = component.find('select_purpose_type').get('v.value');
- //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
- // 鏀彺闇�姹� SupportNeeds__c
- var SupportNeeds__c = component.find('SupportNeeds__c').get('v.value');
- //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� end
- // 璇环 Opportunity__c
- var Opportunity__c = component.get('v.data.Opportunity__c');
-
- 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 = '';
- }
-
- // 浜у搧鍖哄垎 Product_Category__c (ProductTypes__c)
- var Product_Category1__c = component.find('select_Product1').get('v.value');
- var Product_Category2__c = component.find('select_Product2').get('v.value');
- var Product_Category3__c = component.find('select_Product3').get('v.value');
-
- // 绲愭灉 Result__c
- var Result__c = component.find('select_result').get('v.value');
-
- // 銉愩儶銉囥兗銈枫儳銉�
- 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 (!Department_Cateogy__c) { error.push("绉戝 涓嶅瓨鍦�"); }
- if (!doctor2__c) { error.push("鎷滆浜� 涓嶅瓨鍦�"); }
- if (!Purpose_Type__c) { error.push("娲诲姩鍖哄垎 涓嶅瓨鍦�"); }
- // if (!SupportNeeds__c) { error.push("鏀彺闇�姹� 涓嶅瓨鍦�"); }
- if (!Opportunity__c) { Opportunity__c = ""; }
- if (!Product_Category1__c) { error.push("浜у搧鍖哄垎1 涓嶅瓨鍦�"); }
- if (Purpose_Type__c && (Purpose_Type__c.substr(-3) == 'SIS' || Purpose_Type__c.substr(-3) == 'OPD')) {
- if (!Result__c) { error.push("缁撴灉 涓嶅瓨鍦�"); }
- }
- for (var i = 0; i < error.length; i++) {
- this.warning(error[i]);
- }
- 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');
- debugger
- // alert("Purpose_Type:"+Purpose_Type__c+","+"SupportNeedsc:"+SupportNeeds__c);
- action.setParams({
- "Agency_Report_Id" : Agency_Report__c,
- "Department_Cateogy" : Department_Cateogy__c,
- "Purpose_Type" : Purpose_Type__c,
- //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
- "SupportNeedsc" : SupportNeeds__c,
- //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� end
- "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,
- "Product_Category1" : Product_Category1__c,
- "Product_Category2" : Product_Category2__c,
- "Product_Category3" : Product_Category3__c,
- "Result" : Result__c,
- "Opportunity" : Opportunity__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'){
- this.success('缂栬緫淇濆瓨鎴愬姛');
- 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{
- // var error = response.getError();
- // alert(JSON.stringify(error));
- // alert(JSON.stringify(error[0].fieldErrors));
- // alert(JSON.stringify(error[0].fieldErrors.next()));
- // alert(JSON.stringify(error[0].fieldErrors.next()[0]));
- // if (this.error(response.getError()[0].message))
- // else () {
- // error[0].fieldErrors[0]
- // }
- this.error('save_report failed.');
- 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');
- debugger;
- // alert(SupportNeeds__c);
- action.setParams({
- "Department_Cateogy" : Department_Cateogy__c,
- "Purpose_Type" : Purpose_Type__c,
- //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
- "SupportNeedsc" : SupportNeeds__c,
- //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� end
- "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,
- "Product_Category1" : Product_Category1__c,
- "Product_Category2" : Product_Category2__c,
- "Product_Category3" : Product_Category3__c,
- "Result" : Result__c,
- "Opportunity" : Opportunity__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'){
- this.success('淇濆瓨鎴愬姛');
- 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) {
- // 20220222 PI鏀归�� by Bright--start
- res[0].doctor2NameOrigin = doctor2Name;
- res[0].visitorTitleOrigin = visitortitle;
- // 20220222 PI鏀归�� by Bright--end
- 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{
- this.error('get_reports_now failed.');
- component.find('save_button').set('v.disabled', false);
- component.set('v.login',false);
- }
- });
- $A.enqueueAction(action2);
-
- this.allclear(component);
- component.find('save_button').set('v.disabled', false);
- component.set('v.login',false);
- }
- else{
- var error = response.getError();
- // alert(JSON.stringify(error));
- this.error('saveAgencyReport failed.');
- 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.find('new_con').set('v.disabled', true);
- component.find('select_doctor').set('v.options', clear);
- component.set('v.doctor_title', '');
- component.find('select_department').set('v.options', this.conv_selected(component.get('v.allselectlist.Department_Cateogy__c')));
- component.find('select_purpose_type').set('v.options', this.conv_selected(component.get('v.allselectlist.Purpose_Type__c')));
+ component
+ .find("select_department")
+ .set(
+ "v.options",
+ this.conv_selected(res.allselectlist.Department_Cateogy__c)
+ );
+ component
+ .find("select_purpose_type")
+ .set(
+ "v.options",
+ this.conv_selected(res.allselectlist.Purpose_Type__c)
+ );
+ component
+ .find("select_result")
+ .set("v.options", this.conv_selected(res.allselectlist.Result__c));
+ component
+ .find("select_stageName")
+ .set("v.options", this.conv_selected(res.allselectlist.StageName__c));
//SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
- component.find('SupportNeeds__c').set('v.options', this.conv_selected(component.get('v.allselectlist.SupportNeeds__c')));
+ component
+ .find("SupportNeeds__c")
+ .set(
+ "v.options",
+ this.conv_selected(res.allselectlist.SupportNeeds__c)
+ );
//SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� end
- // ToDo闇�瑕佹祴璇曟墜鏈轰笂鑳借繍琛屼笉
- component.set('v.data.Opportunity__c', '');
- component.find('select_Product1').set('v.value','');
- component.find('select_Product2').set('v.value','');
- component.find('select_Product3').set('v.value','');
- console.log('reportDate = 绌�');
- 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.oppdata', '');
- 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');
- $A.util.removeClass(component.find('input-opportunity-blank'), 'disp_none');
- // if ($A.get("$Browser.formFactor") == 'DESKTOP') {
- // var values = [];
- // component.find('input-opportunity').get("v.body")[0].set('v.values', values);
- // } else {
- // component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', '');
- // }
- // component.find('input-opportunity').set("v.body",[]);
- // if (component.find('input-product-category1'))
- // component.find('input-product-category1').get("v.body")[0].set('v.values', values);
- // if (component.find('input-product-category2'))
- // component.find('input-product-category2').get("v.body")[0].set('v.values', values);
- // if (component.find('input-product-category3'))
- // component.find('input-product-category3').get("v.body")[0].set('v.values', values);
- component.find('select_result').set('v.value', '');
- this.select_purpose_type(component);
- },
-
- report_date_list : function(component, event, helper, count) {
- var ret_obj = [];
- var now = new Date();
- for (var i = 0; i < count; i++) {
+ component.set(
+ "v.selected_agency_person",
+ res.allselectlist.AgencyPerson__c[0].label
+ );
+ component.set("v.dialog_type", "鏂板缓");
+ component.set("v.awsurl", res.awsurl); // 20220222 PI鏀归�� by Bright
+ component.set("v.contactawsurl", res.contactawsurl); // 20220222 PI鏀归�� by Bright
- 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));
+ this.get_reports(
+ component,
+ event,
+ helper,
+ component.find("select_date").get("v.value"),
+ component.find("select_agency_person").get("v.value")
+ );
- 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(),
- });
+ component.set("v.login", false);
+ } else {
+ this.error("doinit failed.");
+ component.set("v.login", false);
+ }
+ });
+ $A.enqueueAction(action);
+ },
+
+ // PIPL update Yin Mingjie 21/02/2022 start
+ search_contact: function (component, event, helper, resobj) {
+ let contactData = Object.create(null);
+ var dataArr = new Array();
+ for (let i = 0; i < resobj.length; i++) {
+ if (resobj[i].awsid != null && resobj[i].awsid != "") {
+ contactData[resobj[i].awsid] = resobj[i];
+ dataArr.push(resobj[i].awsid);
+ }
+ }
+ let obj = Object.create(null);
+ obj["dataIds"] = dataArr;
+ var payload = JSON.stringify(obj);
+ this.search_contact_url(component, "Contact", (result) => {
+ var token = result.token;
+ var searchUrl = result.searchUrl;
+ this.search_core(
+ token,
+ searchUrl,
+ payload,
+ (result) => {
+ if (result.status == "0") {
+ if (result.object != null) {
+ this.to_contact_list(result, contactData, component);
} 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.set("v.loginEdit", false);
}
- }
+ } else {
+ this.error("AWS search status1 : " + result.status);
+ component.set("v.loginEdit", false);
+ }
+ },
+ component
+ );
+ });
+ },
- component.find('select_date').set('v.options', ret_obj);
- component.set('v.report_date_list', ret_obj);
- },
-
- create_report_header : function(component, name, s_agency, s_date) {
- s_date = this.get_date_string(s_date);
- if (s_date == false) {
- this.error('get_date_string failed.');
- return false;
- }
+ to_contact_list: function (result, retMap, component) {
+ var resls = result.object;
+ var res = [];
+ var space = {};
+ space["label"] = "";
+ space["selected"] = true;
+ space["value"] = "";
+ res.push(space);
- var head_key = this.create_header_input_key(s_agency, s_date);
- component.set('v.agency_report_header', head_key);
- if (head_key == false) {
- this.error('create_header_input_key failed.');
- return false;
- }
-
- var key2 = s_date.replace(/-/g, '');
- var action = component.get('c.createReportHeader');
+ for (var i = 0; i < resls.length; i++) {
+ var t = {};
+ t["label"] = resls[i].lastName;
+ t["selected"] = false;
+ t["Doctor_Division1__c"] = resls[i].doctorDivision1;
+ t["value"] = retMap[resls[i].dataId].value;
+ res.push(t);
+ }
+ component.find("select_agency_person").set("v.options", res);
+ component.set("v.allselectlistAgencyPerson", res);
+ component.set("v.loginEdit", false);
+ },
- 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);
- }
- else{
- this.error('createReportHeader callback failed.');
- component.set('v.login',false);
- }
- });
- $A.enqueueAction(action);
- },
+ 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 {
+ this.error("AWS url/token error.");
+ component.set("v.loginEdit", false);
+ }
+ });
+ $A.enqueueAction(action);
+ },
+ // PIPL update Yin Mingjie 21/02/2022 end
- 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) {
- this.error('get_date_string in create_header_input_key.')
- 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;
+ select_department: function (component, event, helper) {
+ var dc = component.find("select_department").get("v.value");
+ dc = dc ? "%" + dc + "%" : "";
+ var purpose_type = component.find("select_purpose_type").get("v.value");
+ if (purpose_type) {
+ if (purpose_type.substr(-3) == "OPD") {
+ purpose_type = "OPD";
+ } else if (purpose_type.substr(-3) == "SIS") {
+ purpose_type = "SIS";
+ } else {
+ purpose_type = "";
+ }
+ }
+ if (dc != "" || purpose_type != "") {
+ var action = component.get("c.getProductList");
+ action.setParams({
+ dc: dc,
+ opdsis: purpose_type
+ });
+ action.setCallback(this, function (response) {
+ var state = response.getState();
+ if (state == "SUCCESS") {
+ var res = response.getReturnValue();
+ component
+ .find("select_Product1")
+ .set("v.options", JSON.parse(JSON.stringify(res)));
+ component
+ .find("select_Product2")
+ .set("v.options", JSON.parse(JSON.stringify(res)));
+ component
+ .find("select_Product3")
+ .set("v.options", JSON.parse(JSON.stringify(res)));
} else {
- return false;
+ this.error("getProductList failed.");
}
-
- return val;
- },
-
- searchHos : function(component, event, helper) {
- var hospital_name = event.getParam("value");
- var action = component.get("c.getHospitalList");
- debugger;
- action.setParams({"hospital_name": hospital_name});
+ });
+ $A.enqueueAction(action);
+ } else {
+ component.find("select_Product1").set("v.options", []);
+ component.find("select_Product2").set("v.options", []);
+ component.find("select_Product3").set("v.options", []);
+ }
+ },
- 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);
- },
+ get_reports: function (component, event, helper, date_str, person_str) {
+ if (!date_str) {
+ return false;
+ }
- hideSearch : function(component, event, helper) {
- var hospital_list = component.find('hospital_list');
- $A.util.removeClass(hospital_list, 'slds-is-open');
- },
+ date_str = this.get_date_string(date_str);
- 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');
- 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);
- }
+ 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);
+
+ // 20220222 PI鏀归�� by Bright--start
+ let dataIds = [];
+ let dataIds1 = [];
+ let mm = {};
+ let b = false;
+ let b1 = false;
+ for (const rep of res.reports) {
+ if (rep.doctor2__r && rep.doctor2__r.AWS_Data_Id__c) {
+ dataIds.push(rep.doctor2__r.AWS_Data_Id__c);
+ }
+
+ if (
+ rep.Person_In_Charge2__r &&
+ rep.Person_In_Charge2__r.AWS_Data_Id__c
+ ) {
+ dataIds1.push(rep.Person_In_Charge2__r.AWS_Data_Id__c);
+ }
}
- component.set("v.hospital", accname);
- component.set("v.hospitalId", accid);
- this.set_doctor_list(component);
- this.opportunityChange(component, event, helper);
- },
-
- select_purpose_type : function(component) {
- var purpose_type = component.find('select_purpose_type').get('v.value');
- if (purpose_type != null && purpose_type != undefined && purpose_type.substr(-3) == 'OPD' || purpose_type.substr(-3) == 'SIS') {
- var result = component.find('result');
- $A.util.removeClass(result, 'disp_none');
+ let Foo = null;
+ Foo = function () {
+ if (b && b1) {
+ for (const rep of res.reports) {
+ if (
+ rep.doctor2__r &&
+ rep.doctor2__r.AWS_Data_Id__c &&
+ mm.hasOwnProperty(rep.doctor2__r.AWS_Data_Id__c)
+ ) {
+ rep.doctor2__r.awsdata = mm[rep.doctor2__r.AWS_Data_Id__c];
+ }
+ if (
+ rep.Person_In_Charge2__r &&
+ rep.Person_In_Charge2__r.AWS_Data_Id__c &&
+ mm.hasOwnProperty(rep.Person_In_Charge2__r.AWS_Data_Id__c)
+ ) {
+ rep.Person_In_Charge2__r.awsdata =
+ mm[rep.Person_In_Charge2__r.AWS_Data_Id__c];
+ }
+ }
+
+ $A.getCallback(() => component.set("v.reports", res.reports))();
+ } else {
+ console.log("b=" + b + ",b1=" + b1 + ",continue");
+ setTimeout(Foo, 100);
+ }
+ };
+
+ if (dataIds.length > 0) {
+ let awsurl = component.get("v.awsurl");
+ helper.search_core(
+ awsurl.token,
+ awsurl.searchUrl,
+ JSON.stringify({
+ dataIds: dataIds
+ }),
+ (result) => {
+ if (result.status == "0") {
+ for (const m of result.object) {
+ mm[m.dataId] = m;
+ }
+ b = true;
+ Foo();
+ } else {
+ //this.error('AWS search status2 : ' + result.status);
+ this.success("璇烽噸鏂板埛鏂伴〉闈㈣繘琛岃В瀵�");
+ }
+ },
+ component
+ );
} else {
- component.find('select_result').set('v.value', '');
- var result = component.find('result');
- $A.util.addClass(result, 'disp_none');
+ b = true;
}
- this.select_department(component, null, null);
- },
-
- 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 (dataIds1.length > 0) {
+ let contactawsurl = component.get("v.contactawsurl");
+ helper.search_core(
+ contactawsurl.token,
+ contactawsurl.searchUrl,
+ JSON.stringify({
+ dataIds: dataIds1
+ }),
+ (result) => {
+ if (result.status == "0") {
+ for (const m of result.object) {
+ mm[m.dataId] = m;
+ }
+ b1 = true;
+ Foo();
+ } else {
+ this.error("AWS search status3 : " + result.status);
+ }
+ },
+ component
+ );
+ } else {
+ b1 = true;
+ }
+ // 20220222 PI鏀归�� by Bright--end
+
+ 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 (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 (flg == false) {
- component.set('v.doctor_title', '');
+
+ if (res.reports.length > 0) {
+ component.set("v.list_message", "");
+ } else {
+ component.set("v.list_message", "no_data");
}
- },
+ component.set("v.login", false);
+ } else {
+ this.error("get_reports failed.");
+ component.set("v.login", false);
+ }
+ });
+ $A.enqueueAction(action);
+ },
+ get_reports_edit: 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.loginEdit", true);
+ action.setCallback(this, function (response) {
+ var state = response.getState();
+ if (state == "SUCCESS") {
+ var res = response.getReturnValue();
+ component.set("v.reports", res.reports);
+
+ // 20220222 PI鏀归�� by Bright--start
+ let dataIds = [];
+ let dataIds1 = [];
+ let mm = {};
+ let b = false;
+ let b1 = false;
+ for (const rep of res.reports) {
+ if (rep.doctor2__r && rep.doctor2__r.AWS_Data_Id__c) {
+ dataIds.push(rep.doctor2__r.AWS_Data_Id__c);
+ }
+
+ if (
+ rep.Person_In_Charge2__r &&
+ rep.Person_In_Charge2__r.AWS_Data_Id__c
+ ) {
+ dataIds1.push(rep.Person_In_Charge2__r.AWS_Data_Id__c);
+ }
+ }
+ let Foo = null;
+ Foo = function () {
+ if (b && b1) {
+ for (const rep of res.reports) {
+ if (
+ rep.doctor2__r &&
+ rep.doctor2__r.AWS_Data_Id__c &&
+ mm.hasOwnProperty(rep.doctor2__r.AWS_Data_Id__c)
+ ) {
+ rep.doctor2__r.awsdata = mm[rep.doctor2__r.AWS_Data_Id__c];
+ }
+ if (
+ rep.Person_In_Charge2__r &&
+ rep.Person_In_Charge2__r.AWS_Data_Id__c &&
+ mm.hasOwnProperty(rep.Person_In_Charge2__r.AWS_Data_Id__c)
+ ) {
+ rep.Person_In_Charge2__r.awsdata =
+ mm[rep.Person_In_Charge2__r.AWS_Data_Id__c];
+ }
+ }
+
+ $A.getCallback(() => component.set("v.reports", res.reports))();
+ } else {
+ console.log("b=" + b + ",b1=" + b1 + ",continue");
+ setTimeout(Foo, 100);
+ }
+ };
+
+ if (dataIds.length > 0) {
+ let awsurl = component.get("v.awsurl");
+ helper.search_core(
+ awsurl.token,
+ awsurl.searchUrl,
+ JSON.stringify({
+ dataIds: dataIds
+ }),
+ (result) => {
+ if (result.status == "0") {
+ for (const m of result.object) {
+ mm[m.dataId] = m;
+ }
+ b = true;
+ Foo();
+ } else {
+ //this.error('AWS search status2 : ' + result.status);
+ this.success("璇烽噸鏂板埛鏂伴〉闈㈣繘琛岃В瀵�");
+ }
+ },
+ component
+ );
+ } else {
+ b = true;
+ }
+
+ if (dataIds1.length > 0) {
+ let contactawsurl = component.get("v.contactawsurl");
+ helper.search_core(
+ contactawsurl.token,
+ contactawsurl.searchUrl,
+ JSON.stringify({
+ dataIds: dataIds1
+ }),
+ (result) => {
+ if (result.status == "0") {
+ for (const m of result.object) {
+ mm[m.dataId] = m;
+ }
+ b1 = true;
+ Foo();
+ } else {
+ this.error("AWS search status3 : " + result.status);
+ }
+ },
+ component
+ );
+ } else {
+ b1 = true;
+ }
+ // 20220222 PI鏀归�� by Bright--end
+
+ 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 (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", "");
+ } else {
+ component.set("v.list_message", "no_data");
+ }
+ component.set("v.loginEdit", false);
+ } else {
+ this.error("get_reports failed.");
+ component.set("v.loginEdit", 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")
+ );
+ this.new_button_disabled(component, event, helper);
+
+ 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
+ );
+ this.new_button_disabled(component, event, helper);
+
+ component.set("v.select_report_data_radio", "");
+ component.find("copy_button").set("v.disabled", true);
+ },
+
+ get_agency_person_name: function (component, agency_person_value) {
// PIPL update Yin Mingjie 21/02/2022 start
- 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{
- this.error('AWS url/token error.');
- component.set('v.login',false);
- }
- });
- $A.enqueueAction(action);
- },
-
- insert_agencycontact : function(component,token,newUrl,payload,agencyHospitalid,helper,hospitalName) {
-
- // AWSService.insert(newUrl,payload,function(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);
- // component.find('OppMessage').setError('AWS insert error.');
- // }
- // },token);
-
- fetch(newUrl, {
- method: 'POST',
- body: payload,
- headers: {
- 'Content-Type': 'application/json',
- 'pi-token': token
- }
- }).then((data) => {
- return data.json();
- }).then((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,
- "type" : result.object[0].type,
- //"typeEncrypt" : result.object[0].typeEncrypt,
- "doctorDivision1" : result.object[0].doctorDivision1,
- //"doctorDivision1Encrypt" : result.object[0].doctorDivision1Encrypt,
- "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 != ''){
- this.error(acMap.errormsg);
- component.set('v.login',false);
- }else {
- this.error('agency contact insert id error.');
- component.set('v.login',false);
- }
- }
- else{
- this.error('agency contact insert error.');
- component.set('v.login',false);
- }
- });
- $A.enqueueAction(action);
- },
-
- to_confirm : function(component,token,confirmUrl,payload) {
- 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);
- }else {
- this.error('AWS confirm error.');
- component.set('v.login',false);
- }
- }).catch(error => {
- this.error('AWS confirm error.');
- component.set('v.login',false);
- });
- },
+ var allselectlist = component.get("v.allselectlist.AgencyPerson__c");
+ // var allselectlist = component.get('v.allselectlistAgencyPerson');
// PIPL update Yin Mingjie 21/02/2022 end
+ 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;
+ },
- 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 retMap = this.conv_selected(response.getReturnValue());
- // PIPL update Yin Mingjie 21/02/2022 start
- this.AWS_search(retMap,component);
- /*
+ new_button_disabled: function (component, event, helper) {
+ var select_date = component.find("select_date").get("v.value");
+ var select_agency = component.find("select_agency_person").get("v.value");
+ if (select_date && select_agency) {
+ component.find("new_button").set("v.disabled", false);
+ } else {
+ component.find("new_button").set("v.disabled", true);
+ }
+ },
+
+ 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");
+ component.set("v.loginEdit", true);
+ 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 = "";
+ debugger;
+ // 鍖婚櫌鍚�
+ 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);
+ }
+
+ // 绉戝
+ if (select_data["Department_Cateogy__c"] != "") {
+ this.set_selected(
+ component,
+ "select_department",
+ select_data["Department_Cateogy__c"]
+ );
+ }
+ // 鎷滆浜�
+ component.set("v.default_select_doctor_id", select_data["doctor2__c"]);
+ this.set_doctor_list(component);
+
+ // 娲诲姩鍖哄垎
+ if (select_data["Purpose_Type__c"] != "") {
+ this.set_selected(
+ component,
+ "select_purpose_type",
+ select_data["Purpose_Type__c"]
+ );
+ this.select_purpose_type(component);
+ }
+ //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
+ // 鏀彺闇�姹�
+ if (select_data["SupportNeeds__c"] != "") {
+ this.set_selected(
+ component,
+ "SupportNeeds__c",
+ select_data["SupportNeeds__c"]
+ );
+ }
+ //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� end
+ // 绲愭灉
+ if (
+ select_data["Result__c"] != "" &&
+ typeof select_data["Result__c"] !== "undefined"
+ ) {
+ component
+ .find("select_result")
+ .set("v.value", select_data["Result__c"]);
+ }
+
+ // 璇环
+ var report_id = component.get("v.edit_copy_select_report_id");
+ if (report_id != "") {
+ var select_opp = "";
+ var select_product_category1 = "";
+ var select_product_category2 = "";
+ var select_product_category3 = "";
+ var reportDate;
+ var i = 0;
+ for (i = 0; i < reports.length; i++) {
+ if (report_id == reports[i]["Id"]) {
+ select_opp = reports[i]["Opportunity__c"];
+ select_product_category1 = reports[i]["Product_Category1__c"];
+ select_product_category2 = reports[i]["Product_Category2__c"];
+ select_product_category3 = reports[i]["Product_Category3__c"];
+ reportDate = reports[i]["Report_Date__c"];
+ break;
+ }
+ }
+
+ // 璇环
+ if (select_opp != null && select_opp != "") {
+ var select_opp_name = component.get("v.reports")[i].OppName__c;
+ component.set("v.data.Opportunity__c", select_opp);
+ if ($A.get("$Browser.formFactor") == "DESKTOP") {
+ var values = [
+ {
+ type: "Agency_Opportunity__c",
+ id: select_opp,
+ label: select_opp_name,
+ icon: {
+ url: "/img/icon/t4v35/custom/custom12_120.png",
+ backgroundColor: "dc71d1",
+ alt: "Agency_Opportunity__c"
+ }
+ }
+ ];
+ component.set("v.data.Opportunity__c", select_opp);
+ // component.find('input-opportunity').get("v.body")[0].set('v.values', values);
+ } else {
+ component
+ .find("input-opportunity")
+ .get("v.body")[0]
+ .set("v.selectedLabel", select_opp_name);
+ }
+ }
+
+ // 浜у搧鍖哄垎
+ if (
+ select_product_category1 != null &&
+ select_product_category1 != ""
+ ) {
+ component
+ .find("select_Product1")
+ .set("v.value", select_product_category1);
+ }
+ if (
+ select_product_category2 != null &&
+ select_product_category2 != ""
+ ) {
+ component
+ .find("select_Product2")
+ .set("v.value", select_product_category2);
+ }
+ if (
+ select_product_category3 != null &&
+ select_product_category3 != ""
+ ) {
+ component
+ .find("select_Product3")
+ .set("v.value", select_product_category3);
+ }
+
+ if (reportDate != null) {
+ console.log("reportDate = " + reportDate);
+ component.set("v.data.Report_Date__c", reportDate);
+ }
+
+ component.set("v.edit_copy_select_report_id", "");
+ }
+ }
+ setTimeout(function () {
+ component.set("v.loginEdit", false);
+ }, 1000);
+ } else {
+ // CLOSE
+
+ 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 Department_Cateogy__c = component
+ .find("select_department")
+ .get("v.value");
+ var doctor2__c = component.find("select_doctor").get("v.value");
+ var Purpose_Type__c = component
+ .find("select_purpose_type")
+ .get("v.value");
+ var SupportNeeds__c = component.find("SupportNeeds__c").get("v.value");
+ var Opportunity__c = component.get("v.data.Opportunity__c");
+ var Product_Category1__c = component
+ .find("select_Product1")
+ .get("v.value");
+ var Product_Category2__c = component
+ .find("select_Product2")
+ .get("v.value");
+ var Product_Category3__c = component
+ .find("select_Product3")
+ .get("v.value");
+ var Result__c = component.find("select_result").get("v.value");
+
+ if (select_report_data !== null) {
+ if (typeof select_report_data["Opportunity__c"] === "undefined") {
+ select_report_data["Opportunity__c"] = "";
+ }
+ if (typeof select_report_data["Product_Category1__c"] === "undefined") {
+ select_report_data["Product_Category1__c"] = "";
+ }
+ if (typeof select_report_data["Product_Category2__c"] === "undefined") {
+ select_report_data["Product_Category2__c"] = "";
+ }
+ if (typeof select_report_data["Product_Category3__c"] === "undefined") {
+ select_report_data["Product_Category3__c"] = "";
+ }
+ if (typeof select_report_data["Result__c"] === "undefined") {
+ select_report_data["Result__c"] = "";
+ }
+ }
+
+ if (component.get("v.mode") == "new") {
+ var confirm_title = "璀﹀憡!";
+ var confirm_text = "鏀惧純鏂板缓鍛ㄦ姤锛�";
+
+ if (
+ !Report_Date__c &&
+ !Agency_Hospital__c &&
+ !Department_Cateogy__c &&
+ !doctor2__c &&
+ !Purpose_Type__c &&
+ !SupportNeeds__c && //WAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔�
+ !Opportunity__c &&
+ !Product_Category1__c &&
+ !Product_Category2__c &&
+ !Product_Category3__c &&
+ !Result__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["Department_Cateogy__c"] ==
+ Department_Cateogy__c &&
+ select_report_data["doctor2__c"] == doctor2__c &&
+ select_report_data["Purpose_Type__c"] == Purpose_Type__c &&
+ select_report_data["SupportNeeds__c"] == SupportNeeds__c && //WAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔�
+ select_report_data["Opportunity__c"] == Opportunity__c &&
+ select_report_data["Product_Category1__c"] == Product_Category1__c &&
+ select_report_data["Product_Category2__c"] == Product_Category2__c &&
+ select_report_data["Product_Category3__c"] == Product_Category3__c &&
+ select_report_data["Result__c"] == Result__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["Department_Cateogy__c"] ==
+ Department_Cateogy__c &&
+ select_report_data["doctor2__c"] == doctor2__c &&
+ select_report_data["Purpose_Type__c"] == Purpose_Type__c &&
+ select_report_data["SupportNeeds__c"] == SupportNeeds__c && //WAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔�
+ select_report_data["Opportunity__c"] == Opportunity__c &&
+ select_report_data["Product_Category1__c"] == Product_Category1__c &&
+ select_report_data["Product_Category2__c"] == Product_Category2__c &&
+ select_report_data["Product_Category3__c"] == Product_Category3__c &&
+ select_report_data["Result__c"] == Result__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");
+ component.set("v.selected_date", select_date);
+ var name = component.get("v.selected_agency_person");
+ var ret = this.create_report_header(
+ component,
+ name,
+ select_agency,
+ select_date
+ );
+ // PIPL update Yin Mingjie 21/02/2022 start
+ this.set_aws_url(component, "Agency_Contact__c");
+ // PIPL update Yin Mingjie 21/02/2022 end
+ },
+
+ 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);
+
+ this.new_button_disabled(component, event, helper);
+
+ 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,
+ 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) {
+ component.set("v.login", true);
+ this.allclear(component);
+ 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);
+ this.new_button_disabled(component, event, helper);
+
+ 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,
+ name,
+ select_agency,
+ select_date
+ );
+ },
+
+ save_report: function (component, event, helper) {
+ // 20220222 PI鏀归�� by Bright--start
+ let doctor2Name = "";
+ let visitortitle = "";
+ for (let op of component.find("select_doctor").get("v.options")) {
+ if (op.selected) {
+ doctor2Name = op.label;
+ visitortitle = op.Doctor_Division1__c;
+ }
+ }
+ // 20220222 PI鏀归�� by Bright--end
+
+ component.find("save_button").set("v.disabled", true);
+
+ var Report_Date__c = component.get("v.data.Report_Date__c");
+ // alert('Report_Date__c'+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;
+ // alert('Submit_date__c'+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")
+ );
+ // alert('Submit_date__c'+Submit_date__c);
+
+ // 鎷呭綋 Person_In_Charge2__c
+ Person_In_Charge2__c = component
+ .find("select_agency_person")
+ .get("v.value");
+ }
+ // Agency_Report_Header__c
+ var Agency_Report_Header__c = component.get("v.agency_report_header_id");
+
+ // 鍖婚櫌 Agency_Hospital__c (Agency_Hospital_Link__c)
+ var Agency_Hospital__c = component.get("v.hospitalLinkId");
+
+ // 绉戝 Department_Cateogy__c
+ var Department_Cateogy__c = component
+ .find("select_department")
+ .get("v.value");
+
+ // 鎷滆浜� doctor2__c
+ var doctor2__c = component.find("select_doctor").get("v.value");
+
+ // 娲诲姩鍖哄垎 Purpose_Type__c
+ var Purpose_Type__c = component.find("select_purpose_type").get("v.value");
+ //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
+ // 鏀彺闇�姹� SupportNeeds__c
+ var SupportNeeds__c = component.find("SupportNeeds__c").get("v.value");
+ //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� end
+ // 璇环 Opportunity__c
+ var Opportunity__c = component.get("v.data.Opportunity__c");
+
+ 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 = "";
+ }
+
+ // 浜у搧鍖哄垎 Product_Category__c (ProductTypes__c)
+ var Product_Category1__c = component.find("select_Product1").get("v.value");
+ var Product_Category2__c = component.find("select_Product2").get("v.value");
+ var Product_Category3__c = component.find("select_Product3").get("v.value");
+
+ // 绲愭灉 Result__c
+ var Result__c = component.find("select_result").get("v.value");
+
+ // 銉愩儶銉囥兗銈枫儳銉�
+ 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 (!Department_Cateogy__c) {
+ error.push("绉戝 涓嶅瓨鍦�");
+ }
+ if (!doctor2__c) {
+ error.push("鎷滆浜� 涓嶅瓨鍦�");
+ }
+ if (!Purpose_Type__c) {
+ error.push("娲诲姩鍖哄垎 涓嶅瓨鍦�");
+ }
+ // if (!SupportNeeds__c) { error.push("鏀彺闇�姹� 涓嶅瓨鍦�"); }
+ if (!Opportunity__c) {
+ Opportunity__c = "";
+ }
+ if (!Product_Category1__c) {
+ error.push("浜у搧鍖哄垎1 涓嶅瓨鍦�");
+ }
+ if (
+ Purpose_Type__c &&
+ (Purpose_Type__c.substr(-3) == "SIS" ||
+ Purpose_Type__c.substr(-3) == "OPD")
+ ) {
+ if (!Result__c) {
+ error.push("缁撴灉 涓嶅瓨鍦�");
+ }
+ }
+ for (var i = 0; i < error.length; i++) {
+ this.warning(error[i]);
+ }
+ if (error.length > 0) {
+ component.find("save_button").set("v.disabled", false);
+ return false;
+ }
+
+ // 淇濆瓨鍑︾悊
+ component.set("v.loginEdit", true);
+ if (component.get("v.mode") == "edit") {
+ var Agency_Report__c = component.get("v.select_report_data").Id;
+ var action = component.get("c.editAgencyReport");
+ debugger;
+ // alert("Purpose_Type:"+Purpose_Type__c+","+"SupportNeedsc:"+SupportNeeds__c);
+ action.setParams({
+ Agency_Report_Id: Agency_Report__c,
+ Department_Cateogy: Department_Cateogy__c,
+ Purpose_Type: Purpose_Type__c,
+ //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
+ SupportNeedsc: SupportNeeds__c,
+ //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� end
+ 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,
+ Product_Category1: Product_Category1__c,
+ Product_Category2: Product_Category2__c,
+ Product_Category3: Product_Category3__c,
+ Result: Result__c,
+ Opportunity: Opportunity__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") {
+ this.success("缂栬緫淇濆瓨鎴愬姛");
+ 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_edit(
+ 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.loginEdit", false);
+ } else {
+ // var error = response.getError();
+ // alert(JSON.stringify(error));
+ // alert(JSON.stringify(error[0].fieldErrors));
+ // alert(JSON.stringify(error[0].fieldErrors.next()));
+ // alert(JSON.stringify(error[0].fieldErrors.next()[0]));
+ // if (this.error(response.getError()[0].message))
+ // else () {
+ // error[0].fieldErrors[0]
+ // }
+ this.error("save_report failed.");
+ component.find("save_button").set("v.disabled", false);
+ component.set("v.loginEdit", false);
+ }
+ });
+ $A.enqueueAction(action);
+ } else {
+ /* Save (New & Copy) */
+
+ var action = component.get("c.saveAgencyReport");
+ debugger;
+ // alert(SupportNeeds__c);
+ action.setParams({
+ Department_Cateogy: Department_Cateogy__c,
+ Purpose_Type: Purpose_Type__c,
+ //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
+ SupportNeedsc: SupportNeeds__c,
+ //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� end
+ 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,
+ Product_Category1: Product_Category1__c,
+ Product_Category2: Product_Category2__c,
+ Product_Category3: Product_Category3__c,
+ Result: Result__c,
+ Opportunity: Opportunity__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") {
+ this.success("淇濆瓨鎴愬姛");
+ var report_id = response.getReturnValue();
+ component.set("v.create_agency_report_id", report_id);
+
+ this.get_reports_edit(
+ 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) {
+ // 20220222 PI鏀归�� by Bright--start
+ res[0].doctor2NameOrigin = doctor2Name;
+ res[0].visitorTitleOrigin = visitortitle;
+ // 20220222 PI鏀归�� by Bright--end
+ 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 {
+ this.error("get_reports_now failed.");
+ component.find("save_button").set("v.disabled", false);
+ component.set("v.loginEdit", false);
+ }
+ });
+ $A.enqueueAction(action2);
+
+ this.allclear(component);
+ component.find("save_button").set("v.disabled", false);
+ component.set("v.loginEdit", false);
+ } else {
+ var error = response.getError();
+ // alert(JSON.stringify(error));
+ this.error("saveAgencyReport failed.");
+ component.find("save_button").set("v.disabled", false);
+ component.set("v.loginEdit", 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.find("new_con").set("v.disabled", true);
+ component.find("select_doctor").set("v.options", clear);
+ component.set("v.doctor_title", "");
+ component
+ .find("select_department")
+ .set(
+ "v.options",
+ this.conv_selected(
+ component.get("v.allselectlist.Department_Cateogy__c")
+ )
+ );
+ component
+ .find("select_purpose_type")
+ .set(
+ "v.options",
+ this.conv_selected(component.get("v.allselectlist.Purpose_Type__c"))
+ );
+ //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
+ component
+ .find("SupportNeeds__c")
+ .set(
+ "v.options",
+ this.conv_selected(component.get("v.allselectlist.SupportNeeds__c"))
+ );
+ //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� end
+ // ToDo闇�瑕佹祴璇曟墜鏈轰笂鑳借繍琛屼笉
+ component.set("v.data.Opportunity__c", "");
+ component.find("select_Product1").set("v.value", "");
+ component.find("select_Product2").set("v.value", "");
+ component.find("select_Product3").set("v.value", "");
+ console.log("reportDate = 绌�");
+ 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.oppdata', '');
+ 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");
+ $A.util.removeClass(component.find("input-opportunity-blank"), "disp_none");
+ // if ($A.get("$Browser.formFactor") == 'DESKTOP') {
+ // var values = [];
+ // component.find('input-opportunity').get("v.body")[0].set('v.values', values);
+ // } else {
+ // component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', '');
+ // }
+ // component.find('input-opportunity').set("v.body",[]);
+ // if (component.find('input-product-category1'))
+ // component.find('input-product-category1').get("v.body")[0].set('v.values', values);
+ // if (component.find('input-product-category2'))
+ // component.find('input-product-category2').get("v.body")[0].set('v.values', values);
+ // if (component.find('input-product-category3'))
+ // component.find('input-product-category3').get("v.body")[0].set('v.values', values);
+ component.find("select_result").set("v.value", "");
+ this.select_purpose_type(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, name, s_agency, s_date) {
+ s_date = this.get_date_string(s_date);
+ if (s_date == false) {
+ this.error("get_date_string failed.");
+ 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) {
+ this.error("create_header_input_key failed.");
+ 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);
+ } else {
+ this.error("createReportHeader callback failed.");
+ 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) {
+ this.error("get_date_string in create_header_input_key.");
+ 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;
+ },
+
+ searchHos: function (component, event, helper) {
+ var hospital_name = event.getParam("value");
+ var action = component.get("c.getHospitalList");
+ debugger;
+ 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) {
+ 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");
+ 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);
+ this.opportunityChange(component, event, helper);
+ },
+
+ select_purpose_type: function (component) {
+ var purpose_type = component.find("select_purpose_type").get("v.value");
+ if (
+ (purpose_type != null &&
+ purpose_type != undefined &&
+ purpose_type.substr(-3) == "OPD") ||
+ purpose_type.substr(-3) == "SIS"
+ ) {
+ var result = component.find("result");
+ $A.util.removeClass(result, "disp_none");
+ } else {
+ component.find("select_result").set("v.value", "");
+ var result = component.find("result");
+ $A.util.addClass(result, "disp_none");
+ }
+ this.select_department(component, null, null);
+ },
+
+ 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", "");
+ }
+ },
+ // PIPL update Yin Mingjie 21/02/2022 start
+ 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 {
+ this.error("AWS url/token error.");
+ component.set("v.loginEdit", false);
+ }
+ });
+ $A.enqueueAction(action);
+ },
+
+ insert_agencycontact: function (
+ component,
+ token,
+ newUrl,
+ payload,
+ agencyHospitalid,
+ helper,
+ hospitalName
+ ) {
+ // AWSService.insert(newUrl,payload,function(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);
+ // component.find('OppMessage').setError('AWS insert error.');
+ // }
+ // },token);
+
+ fetch(newUrl, {
+ method: "POST",
+ body: payload,
+ headers: {
+ "Content-Type": "application/json",
+ "pi-token": token
+ }
+ })
+ .then((data) => {
+ return data.json();
+ })
+ .then((result) => {
+ if (result.status == "0") {
+ $A.getCallback(function () {
+ helper.to_agencycontact(component, result, agencyHospitalid);
+ })();
+ } else {
+ console.log("AWS status error:" + result);
+ component.set("v.loginEdit", 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.loginEdit", 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,
+ type: result.object[0].type,
+ //"typeEncrypt" : result.object[0].typeEncrypt,
+ doctorDivision1: result.object[0].doctorDivision1,
+ //"doctorDivision1Encrypt" : result.object[0].doctorDivision1Encrypt,
+ 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 != "") {
+ this.error(acMap.errormsg);
+ component.set("v.loginEdit", false);
+ } else {
+ this.error("agency contact insert id error.");
+ component.set("v.loginEdit", false);
+ }
+ } else {
+ this.error("agency contact insert error.");
+ component.set("v.loginEdit", false);
+ }
+ });
+ $A.enqueueAction(action);
+ },
+
+ to_confirm: function (component, token, confirmUrl, payload) {
+ 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);
+ } else {
+ this.error("AWS confirm error.");
+ component.set("v.loginEdit", false);
+ }
+ })
+ .catch((error) => {
+ this.error("AWS confirm error.");
+ component.set("v.loginEdit", false);
+ });
+ },
+ // PIPL update Yin Mingjie 21/02/2022 end
+
+ set_doctor_list: function (component) {
+ var hospital_id = component.get("v.hospitalLinkId");
+ if (hospital_id) {
+ component.set("v.loginEdit", 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 retMap = this.conv_selected(response.getReturnValue());
+ // PIPL update Yin Mingjie 21/02/2022 start
+ this.AWS_search(retMap, component);
+ /*
var default_doctor = component.get('v.default_select_doctor_id');
if (default_doctor != '' && res.length > 0) {
var doctor_title = '';
@@ -1391,1193 +1859,1441 @@
component.set('v.doctor_list', res);
component.set('v.login',false);
*/
- // PIPL update Yin Mingjie 21/02/2022 end
- }
- else{
- this.error('set_doctor_list failed.');
- component.set('v.login',false);
- }
- });
- $A.enqueueAction(action);
- }
- },
-
- // PIPL update Yin Mingjie 21/02/2022 start
- AWS_search : function(retMap,component) {
- var token = retMap.sre.token;
- var searchUrl = retMap.sre.searchUrl;
-
- var dataArr = new Array();
- for (const key in retMap) {
- if (key == 'sre') {continue;}
- dataArr.push(key);
- }
- if(dataArr.length == 0){
- component.set('v.login',false);
- this.warning('娌℃湁鎵惧埌绗﹀悎鏉′欢鐨勫鎴蜂汉鍛�');
- return;
- }
- let obj= Object.create(null);
- obj['dataIds'] = dataArr;
- var data = JSON.stringify(obj);
- this.search_agency_contact(token,searchUrl,data,retMap,component);
- },
-
- search_agency_contact : function(token,searchUrl,payload,retMap,component) {
- this.search_core(token,searchUrl,payload,(result)=>{
- if(result.status == '0'){
- this.to_doctor_list(result,retMap,component);
- }else{
- this.error('AWS search status4 : ' + result.status);
- component.set('v.login',false);
- }
- },component);
- // fetch(searchUrl, {
- // method: 'POST',
- // body: payload,
- // headers: {
- // 'Content-Type': 'application/json',
- // 'pi-token': token
- // }
- // }).then((data) => {
- // return data.json();
- // }).then((result) => {
-
- // }).catch(error => {
- // this.error('AWS search error.');
- // component.set('v.login',false);
- // });
- },
- search_core : function(token,searchUrl,payload,callback,component) {
- console.log('token = ' + token);
- console.log('searchUrl = ' + searchUrl);
- console.log('payload = ' + payload);
- 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('error = ' + JSON.stringify(error));
- this.error('AWS search error.');
- component.set('v.login',false);
- });
- },
-
- to_doctor_list : function(result,retMap,component) {
- var resls = result.object;
- var res = [];
- var space = {};
- space['label'] = '';
- space['selected'] = true;
- space['value'] = '';
- res.push(space);
-
- for (var i = 0; i < resls.length; i++) {
- var t = {};
- t['label'] = resls[i].name;
- t['selected'] = false;
- t['Doctor_Division1__c'] = resls[i].doctorDivision1;
- t['value'] = retMap[resls[i].dataId].value;
- res.push(t);
- }
-
- 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);
+ // PIPL update Yin Mingjie 21/02/2022 end
} else {
- component.find('select_doctor').set('v.options', res);
- if (res.length > 0) {
- component.set('v.doctor_title', res[0].Doctor_Division1__c);
- }
+ this.error("set_doctor_list failed.");
+ component.set("v.loginEdit", false);
}
-
- component.set('v.default_select_doctor_id', '');
- component.set('v.doctor_list', res);
- component.set('v.login',false);
- },
- // PIPL update Yin Mingjie 21/02/2022 end
+ });
+ $A.enqueueAction(action);
+ }
+ },
- // stageNameChange : function(component, event, helper) {
- // var options = component.find('input-oppstage').get("v.body")[0].get('v.options');
- // var remove;
- // for (var i = 0; i < options.length; i++) {
- // if (options[i].label == '鐩爣') {
- // remove = i;
- // break;
- // }
+ // PIPL update Yin Mingjie 21/02/2022 start
+ AWS_search: function (retMap, component) {
+ var token = retMap.sre.token;
+ var searchUrl = retMap.sre.searchUrl;
+
+ var dataArr = new Array();
+ for (const key in retMap) {
+ if (key == "sre") {
+ continue;
+ }
+ dataArr.push(key);
+ }
+ if (dataArr.length == 0) {
+ component.set("v.loginEdit", false);
+ this.warning("娌℃湁鎵惧埌绗﹀悎鏉′欢鐨勫鎴蜂汉鍛�");
+ return;
+ }
+ let obj = Object.create(null);
+ obj["dataIds"] = dataArr;
+ var data = JSON.stringify(obj);
+ this.search_agency_contact(token, searchUrl, data, retMap, component);
+ },
+
+ search_agency_contact: function (
+ token,
+ searchUrl,
+ payload,
+ retMap,
+ component
+ ) {
+ this.search_core(
+ token,
+ searchUrl,
+ payload,
+ (result) => {
+ if (result.status == "0") {
+ this.to_doctor_list(result, retMap, component);
+ } else {
+ this.error("AWS search status4 : " + result.status);
+ component.set("v.loginEdit", false);
+ }
+ },
+ component
+ );
+ // fetch(searchUrl, {
+ // method: 'POST',
+ // body: payload,
+ // headers: {
+ // 'Content-Type': 'application/json',
+ // 'pi-token': token
// }
- // options.splice(remove,1);
- // },
-
- opportunityChange : function(component, event, helper) {
- debugger
- var opp_id = component.get('v.data.Opportunity__c');
- if (opp_id == '') {
- $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');
- $A.util.removeClass(component.find('input-opportunity-blank'), 'disp_none');
- } else if (opp_id == 'MALFORMED_ID') {
- component.set('v.data.Opportunity__c', '');
- $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');
- $A.util.removeClass(component.find('input-opportunity-blank'), 'disp_none');
- } else if (opp_id != "") {
- var hospital_link_id = component.get('v.hospitalLinkId');
- if (hospital_link_id == '') {
- this.warning('鍖婚櫌涓嶅瓨鍦�');
- // ToDo闇�瑕佹祴璇曟墜鏈轰笂鑳借繍琛屼笉
- component.set('v.data.Opportunity__c', '');
- $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');
- $A.util.removeClass(component.find('input-opportunity-blank'), 'disp_none');
- // if ($A.get("$Browser.formFactor") == 'DESKTOP') {
- // var values = [];
- // // component.find('input-opportunity').get("v.body")[0].set('v.values', values);
- // } else {
- // component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', '');
- // }
- return false;
- }
- var action = component.get('c.selectOpportunityByIdAndHospitalLinkId');
- action.setParams({
- "opportunity_id" : opp_id,
- "agency_hospital_link_id" : component.get('v.hospitalLinkId'),
- });
+ // }).then((data) => {
+ // return data.json();
+ // }).then((result) => {
- component.set('v.login',true);
- action.setCallback(this,function(response){
- var state = response.getState();
- if(state == 'SUCCESS'){
- var res = response.getReturnValue();
- if (res.length <= 0) {
- if (component.get('v.data.Opportunity__c')) {
- this.warning('鍖婚櫌鏈尮閰嶅埌');
- }
- // ToDo闇�瑕佹祴璇曟墜鏈轰笂鑳借繍琛屼笉
- component.set('v.data.Opportunity__c', '');
- $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');
- $A.util.removeClass(component.find('input-opportunity-blank'), 'disp_none');
- // if ($A.get("$Browser.formFactor") == 'DESKTOP') {
- // var values = [];
- // component.find('input-opportunity').get("v.body")[0].set('v.values', values);
- // } else {
- // component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', '');
- // }
- component.set('v.login',false);
- return false;
- }
- //SWAG-CKH5M8 銆愬鎵樸�戝懆鎶ュ叧鑱旇浠凤紝鍙�夋嫨璇环鑼冨洿璋冩暣 fy start
- // else if (res[0]['StageName2__c'] != '3.璇环' && !component.get('v.loadOpp')){
- // this.warning('璇烽�夋嫨璇环涓殑椤圭洰');
- // // ToDo闇�瑕佹祴璇曟墜鏈轰笂鑳借繍琛屼笉
- // component.set('v.data.Opportunity__c', '');
- // $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');
- // $A.util.removeClass(component.find('input-opportunity-blank'), 'disp_none');
- // // if ($A.get("$Browser.formFactor") == 'DESKTOP') {
- // // var values = [];
- // // component.find('input-opportunity').get("v.body")[0].set('v.values', values);
- // // } else {
- // // component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', '');
- // // }
- // component.set('v.login',false);
- // return false;
- // }
- //SWAG-CKH5M8 銆愬鎵樸�戝懆鎶ュ叧鑱旇浠凤紝鍙�夋嫨璇环鑼冨洿璋冩暣 fy end
- else {
- component.set('v.loadOpp', false);
- component.set('v.oppdata',res[0]);
- this.set_selected(component, 'select_stageName', res[0].StageName__c);
- component.set('v.Close_Forecasted_Date__c_o', res[0].Close_Forecasted_Date__c);
- component.set('v.Amount__c_o', res[0].Amount__c);
- component.set('v.OCMSale_Price__c_o', res[0].OCMSale_Price__c);
- component.set('v.StageName__c_o', res[0].StageName__c);
+ // }).catch(error => {
+ // this.error('AWS search error.');
+ // component.set('v.login',false);
+ // });
+ },
+ search_core: function (token, searchUrl, payload, callback, component) {
+ console.log("token = " + token);
+ console.log("searchUrl = " + searchUrl);
+ console.log("payload = " + payload);
+ fetch(searchUrl, {
+ method: "POST",
+ body: payload,
+ headers: {
+ "Content-Type": "application/json",
+ "pi-token": token
+ }
+ })
+ .then((data) => {
+ return data.json();
+ })
+ .then((result) => {
+ component.set("v.loginEdit", false);
+ if (callback) callback(result);
+ })
+ .catch((error) => {
+ console.log("error = " + JSON.stringify(error));
+ this.error("AWS search error.");
+ component.set("v.loginEdit", false);
+ });
+ },
- $A.util.removeClass(component.find('input-opportunity-stage'), 'disp_none');
- $A.util.removeClass(component.find('input-opportunity-amount1'), 'disp_none');
- $A.util.removeClass(component.find('input-opportunity-amount2'), 'disp_none');
- $A.util.removeClass(component.find('input-opportunity-date'), 'disp_none');
- $A.util.addClass(component.find('input-opportunity-blank'), 'disp_none');
- }
-
- component.set('v.login',false);
- }
- else{
- this.error('selectOpportunityByIdAndHospitalLinkId failed.');
- 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)) {
- this.warning('涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�');
- component.find('select_Product1').set('v.value','');
- }
- },
- productcategoryChange2 : function(component, event, helper) {
- var product_category_id = component.find('select_Product2').get('v.value');
- var pcId1 = component.find('select_Product1').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)) {
- this.warning('涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�');
- component.find('select_Product2').set('v.value','');
- }
- },
- 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)) {
- this.warning('涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�');
- 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;
+ to_doctor_list: function (result, retMap, component) {
+ var resls = result.object;
+ var res = [];
+ var space = {};
+ space["label"] = "";
+ space["selected"] = true;
+ space["value"] = "";
+ res.push(space);
+
+ for (var i = 0; i < resls.length; i++) {
+ var t = {};
+ t["label"] = resls[i].name;
+ t["selected"] = false;
+ t["Doctor_Division1__c"] = resls[i].doctorDivision1;
+ t["value"] = retMap[resls[i].dataId].value;
+ res.push(t);
+ }
+
+ 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.loginEdit", false);
+ },
+ // PIPL update Yin Mingjie 21/02/2022 end
+
+ // stageNameChange : function(component, event, helper) {
+ // var options = component.find('input-oppstage').get("v.body")[0].get('v.options');
+ // var remove;
+ // for (var i = 0; i < options.length; i++) {
+ // if (options[i].label == '鐩爣') {
+ // remove = i;
+ // break;
+ // }
+ // }
+ // options.splice(remove,1);
+ // },
+
+ opportunityChange: function (component, event, helper) {
+ debugger;
+ var opp_id = component.get("v.data.Opportunity__c");
+ if (opp_id == "") {
+ $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");
+ $A.util.removeClass(
+ component.find("input-opportunity-blank"),
+ "disp_none"
+ );
+ } else if (opp_id == "MALFORMED_ID") {
+ component.set("v.data.Opportunity__c", "");
+ $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");
+ $A.util.removeClass(
+ component.find("input-opportunity-blank"),
+ "disp_none"
+ );
+ } else if (opp_id != "") {
+ var hospital_link_id = component.get("v.hospitalLinkId");
+ if (hospital_link_id == "") {
+ this.warning("鍖婚櫌涓嶅瓨鍦�");
+ // ToDo闇�瑕佹祴璇曟墜鏈轰笂鑳借繍琛屼笉
+ component.set("v.data.Opportunity__c", "");
+ $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");
+ $A.util.removeClass(
+ component.find("input-opportunity-blank"),
+ "disp_none"
+ );
+ // if ($A.get("$Browser.formFactor") == 'DESKTOP') {
+ // var values = [];
+ // // component.find('input-opportunity').get("v.body")[0].set('v.values', values);
+ // } else {
+ // component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', '');
+ // }
+ return false;
+ }
+ var action = component.get("c.selectOpportunityByIdAndHospitalLinkId");
+ action.setParams({
+ opportunity_id: opp_id,
+ agency_hospital_link_id: component.get("v.hospitalLinkId")
+ });
+
+ component.set("v.loginEdit", true);
+ action.setCallback(this, function (response) {
+ var state = response.getState();
+ if (state == "SUCCESS") {
+ var res = response.getReturnValue();
+ if (res.length <= 0) {
+ if (component.get("v.data.Opportunity__c")) {
+ this.warning("鍖婚櫌鏈尮閰嶅埌");
+ }
+ // ToDo闇�瑕佹祴璇曟墜鏈轰笂鑳借繍琛屼笉
+ component.set("v.data.Opportunity__c", "");
+ $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"
+ );
+ $A.util.removeClass(
+ component.find("input-opportunity-blank"),
+ "disp_none"
+ );
+ // if ($A.get("$Browser.formFactor") == 'DESKTOP') {
+ // var values = [];
+ // component.find('input-opportunity').get("v.body")[0].set('v.values', values);
+ // } else {
+ // component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', '');
+ // }
+ component.set("v.loginEdit", false);
return false;
+ }
+ //SWAG-CKH5M8 銆愬鎵樸�戝懆鎶ュ叧鑱旇浠凤紝鍙�夋嫨璇环鑼冨洿璋冩暣 fy start
+ // else if (res[0]['StageName2__c'] != '3.璇环' && !component.get('v.loadOpp')){
+ // this.warning('璇烽�夋嫨璇环涓殑椤圭洰');
+ // // ToDo闇�瑕佹祴璇曟墜鏈轰笂鑳借繍琛屼笉
+ // component.set('v.data.Opportunity__c', '');
+ // $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');
+ // $A.util.removeClass(component.find('input-opportunity-blank'), 'disp_none');
+ // // if ($A.get("$Browser.formFactor") == 'DESKTOP') {
+ // // var values = [];
+ // // component.find('input-opportunity').get("v.body")[0].set('v.values', values);
+ // // } else {
+ // // component.find('input-opportunity').get("v.body")[0].set('v.selectedLabel', '');
+ // // }
+ // component.set('v.login',false);
+ // return false;
+ // }
+ //SWAG-CKH5M8 銆愬鎵樸�戝懆鎶ュ叧鑱旇浠凤紝鍙�夋嫨璇环鑼冨洿璋冩暣 fy end
+ else {
+ component.set("v.loadOpp", false);
+ component.set("v.oppdata", res[0]);
+ this.set_selected(
+ component,
+ "select_stageName",
+ res[0].StageName__c
+ );
+ component.set(
+ "v.Close_Forecasted_Date__c_o",
+ res[0].Close_Forecasted_Date__c
+ );
+ component.set("v.Amount__c_o", res[0].Amount__c);
+ component.set("v.OCMSale_Price__c_o", res[0].OCMSale_Price__c);
+ component.set("v.StageName__c_o", res[0].StageName__c);
+
+ $A.util.removeClass(
+ component.find("input-opportunity-stage"),
+ "disp_none"
+ );
+ $A.util.removeClass(
+ component.find("input-opportunity-amount1"),
+ "disp_none"
+ );
+ $A.util.removeClass(
+ component.find("input-opportunity-amount2"),
+ "disp_none"
+ );
+ $A.util.removeClass(
+ component.find("input-opportunity-date"),
+ "disp_none"
+ );
+ $A.util.addClass(
+ component.find("input-opportunity-blank"),
+ "disp_none"
+ );
+ }
+
+ component.set("v.loginEdit", false);
+ } else {
+ this.error("selectOpportunityByIdAndHospitalLinkId failed.");
+ component.set("v.loginEdit", false);
}
- },
-
- success : function(message) {
- var toastEvent = $A.get("e.force:showToast");
- toastEvent.setParams({
- "title" : "鎴愬姛!",
- "message" : message,
- "type" : "success",
- "duration" : "5000"
- });
- toastEvent.fire();
- },
-
- warning : function(message) {
- var toastEvent = $A.get("e.force:showToast");
- toastEvent.setParams({
- "title": "璀﹀憡!",
- "message": message,
- "type":"warning",
- "duration" : "10000"
- });
- toastEvent.fire();
- },
-
- error : function(message) {
- // $('toastMessage.forceToastManager').css('white-space', 'pre-wrap');
- var toastEvent = $A.get("e.force:showToast");
+ });
+ $A.enqueueAction(action);
+ }
+ },
- 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);
- // var modal_newAC = component.find('modal_newAC')
- // $A.util.removeClass(modal_newAC, 'disp_none');
- },
+ 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)
+ ) {
+ this.warning("涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�");
+ component.find("select_Product1").set("v.value", "");
+ }
+ },
+ productcategoryChange2: function (component, event, helper) {
+ var product_category_id = component.find("select_Product2").get("v.value");
+ var pcId1 = component.find("select_Product1").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)
+ ) {
+ this.warning("涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�");
+ component.find("select_Product2").set("v.value", "");
+ }
+ },
+ 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)
+ ) {
+ this.warning("涓嶈兘閫夋嫨鍚屾牱鐨勪骇鍝佸尯鍒�");
+ component.find("select_Product3").set("v.value", "");
+ }
+ },
- // vivek start 娣诲姞楠岃瘉
- // handleFormSubmit : function(component) {
- // var showValidationError = false;
- // var fields = component.find("newOpportunityField");
- // var vaildationFailReason = '';
- // var currentDate = new Date().toJSON().slice(0,10);
-
- // 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;
- // vaildationFailReason = "鍖荤敓鍖哄垎(鑱屽姟)涓嶈兘涓虹┖锛�";
- // }
- // });
-
- // if (showValidationError) {
- // component.find('OppMessage').setError(vaildationFailReason);
- // }
- // },
- // vivek end 娣诲姞楠岃瘉
-
- 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');
- this.success('.瀹㈡埛浜哄憳宸插垱寤恒��');
- this.set_doctor_list(component);
- },
-
- 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) {
- debugger
- 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 + '\'';
+ 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;
}
- 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 + '\'';
+ }
+ }
+
+ 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.set('v.opportunity_cfilter', opportunity_cfilter);
- component.set('v.data.Opportunity__c', null);
- },
- readFile: function(component, helper, file) {
- if (!file) return;
- // console.log('file'+file.name);
- 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.onprogress = updateProgress;
- 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) {
- var data=e.target.result;
- component.set("v.fileContentData",data);
- console.log("file data"+JSON.stringify(data));
- // console.log("file data"+encodeURI(JSON.stringify(data),"utf-8"));
- var allTextLines = data.split(/\r\n|\n/);
- var dataRows=allTextLines.length-1;
- var headers = allTextLines[0].split(',');
-
- // console.log("Rows length::"+dataRows);
-
-
- 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');
-
+ }
+ component.find(aura_id_name).set("v.options", select_tmp);
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ success: function (message) {
+ var toastEvent = $A.get("e.force:showToast");
+ toastEvent.setParams({
+ title: "鎴愬姛!",
+ message: message,
+ type: "success",
+ duration: "5000"
+ });
+ toastEvent.fire();
+ },
+
+ warning: function (message) {
+ var toastEvent = $A.get("e.force:showToast");
+ toastEvent.setParams({
+ title: "璀﹀憡!",
+ message: message,
+ type: "warning",
+ duration: "10000"
+ });
+ toastEvent.fire();
+ },
+
+ error: function (message) {
+ // $('toastMessage.forceToastManager').css('white-space', 'pre-wrap');
+ 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);
+ // var modal_newAC = component.find('modal_newAC')
+ // $A.util.removeClass(modal_newAC, 'disp_none');
+ },
+
+ // vivek start 娣诲姞楠岃瘉
+ // handleFormSubmit : function(component) {
+ // var showValidationError = false;
+ // var fields = component.find("newOpportunityField");
+ // var vaildationFailReason = '';
+ // var currentDate = new Date().toJSON().slice(0,10);
+
+ // 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;
+ // vaildationFailReason = "鍖荤敓鍖哄垎(鑱屽姟)涓嶈兘涓虹┖锛�";
+ // }
+ // });
+
+ // if (showValidationError) {
+ // component.find('OppMessage').setError(vaildationFailReason);
+ // }
+ // },
+ // vivek end 娣诲姞楠岃瘉
+
+ 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");
+ this.success(".瀹㈡埛浜哄憳宸插垱寤恒��");
+ this.set_doctor_list(component);
+ },
+
+ 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) {
+ debugger;
+ 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);
+ component.set("v.data.Opportunity__c", null);
+ },
+ readFile: function (component, helper, file) {
+ if (!file) return;
+ // console.log('file'+file.name);
+ 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.");
}
- var reader = new FileReader();
- reader.onloadend = function() {
-
- };
- reader.readAsDataURL(file);
- },
-
- saveRecords : function(component,event,helper){
- debugger
- component.set('v.login',true);
- //fy 瀵煎叆 20220424 start
- var action1 = component.get("c.processDataAWSId");
- action1.setParams({
- fileData : component.get("v.fileContentData"),
- });
- debugger
- action1.setCallback(this, function(response) {
- console.log('response = ' + JSON.stringify(response));
- var state = response.getState();
- if (state === "SUCCESS") {
- var ress = response.getReturnValue();
- console.log('ress = ' + JSON.stringify(ress));
- if(ress){
- var valur =ress.split('error1');
- if(valur.length<=1){
- var res = JSON.parse(response.getReturnValue());
- console.log('res = ' + JSON.stringify(res));
- 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);
- dataMap.set(item.AWS_Data_Id__c,item.AWS_Data_Id__c); //zhj 鏂版柟妗堟敼閫� 2022-12-21
- }
- });
- let obj= Object.create(null);
- obj['dataIds'] = dataArr;
- var payload = JSON.stringify(obj);
- console.log('payload zhj = ' + JSON.stringify(payload));
-
- this.search_contact_url(component, 'Agency_Contact__c', (result)=>{
- var token = result.token;
- var searchUrl = result.searchUrl;
- this.search_core(token,searchUrl,payload,(result)=>{
- if(result.status == '0'){
- if(result.object != null&&result.object.length != 0){
- // var resultjson = JSON.stringify(result.object);
- // if(resultjson){
- // debugger
- // console.warn('001');
- // component.set('v.login',true);
- // this.ImportMethod(component,resultjson);
- // }
- component.set('v.login',true);
- this.saveRecordsEditFile(component,dataMap,result.object,helper);
- }else{
- this.error('AWS 鏌ヨ鏁版嵁涓虹┖ ' );
- component.set('v.login',false);
- }
- }else{
- this.error('AWS search status6 : ' + result.status);
- component.set('v.login',false);
- }
- },component);
- // var resultjson =null;
- // this.ImportMethod(component,resultjson);
-
- });
- // var resultjson =null;
- // this.ImportMethod(component,resultjson);
- }else{
- this.error(valur[1]+'\n'+"璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
- }
- }
+ };
+ //reader.onprogress = updateProgress;
+ 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) {
+ var data = e.target.result;
+ component.set("v.fileContentData", data);
+ console.log("file data" + JSON.stringify(data));
+ // console.log("file data"+encodeURI(JSON.stringify(data),"utf-8"));
+ var allTextLines = data.split(/\r\n|\n/);
+ var dataRows = allTextLines.length - 1;
+ var headers = allTextLines[0].split(",");
+
+ // console.log("Rows length::"+dataRows);
+
+ 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>";
}
- });
- $A.enqueueAction(action1);
- //fy 瀵煎叆 20220424 end
- // var action = component.get("c.processData");
- // var selectDate = component.find('select_date').get('v.value');
- // var fieldsList=['Name','Phone','AccountNumber']; //Please write your code dynamic
- // var sss=component.get("v.fileContentData");
- // action.setParams({
- // fileData : component.get("v.fileContentData"),
- // //selectDateselectDate :component.find('select_date').get('v.value'),
- // sobjectName:'Account', //Any object
- // fields:fieldsList
- // });
- // action.setCallback(this, function(response) {
- // var state = response.getState();
- // if (state === "SUCCESS") {
-
- // var res = response.getReturnValue();
- // var res1 = '';
- // console.log("[[[[[["+res);
- // if(res != 'success'){
- // debugger
- // var ress = res.split('=');
- // console.log(ress);
- // for (var i=0; i<ress.length; i++) {
- // res1 += ress[i].substr(7)+'\n';
- // }
- // // $('.forceToastManager').css('white-space', 'pre-wrap');
- // console.log("=="+res1);
- // this.error(res1+"璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
- // component.set('v.login',false);
- // }else{
- // component.set("v.showMain",true);
- // this.success("瀵煎叆鎴愬姛");
- // // alert('saved successfully');
- // component.set('v.login',false);
- // }
-
- // }
- // else if (state === "INCOMPLETE") {
- // // do something
- // 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);
-
- },isNumber: function(str) {
- return /^\d+$/.test(str);
- },ImportMethod : function(component,fileStr){
- debugger
- var actionss = component.get("c.processData");
- var selectDate = component.find('select_date').get('v.value');
- var fieldsList=['Name','Phone','AccountNumber']; //Please write your code dynamic
- var sss=component.get("v.fileContentData");
- actionss.setParams({
- // fileData : component.get("v.fileContentData"),
- fileData : fileStr,
- // selectDateselectDate :component.find('select_date').get('v.value'),
- sobjectName:'Account', //Any object
- fields:fieldsList
- // Agency_ContactListjson:resultjson
- });
- actionss.setCallback(this, function(response) {
- console.log('002');
- var state = response.getState();
- if (state === "SUCCESS") {
- var res = response.getReturnValue();
- var res1 = '';
- console.log("[[[[[["+res);
- if(res != 'success'){
- var ress = res.split('=');
- console.log(ress);
- let errorDatas = [];
- let errorDataRow = [];
- debugger
- var fileContentData = component.get("v.fileContentData").split('\n');
- for (var i=0; i<ress.length; i++) {
- res1 += ress[i].substr(7)+'\n';
- if (ress[i] != '') {
- let errorData = {}
- if(!this.isNumber(ress[i].substr(7).substring(1, 2))){
- continue
- }
- let index = errorDataRow.indexOf(ress[i].substr(7).substring(1, 2));
- if (index == -1) {
- errorData.errorRow = ress[i].substr(7).substring(1, 2);
- errorDataRow.push(errorData.errorRow);
- errorData.errorInfo = ress[i].substr(7).substring(5).replace('=','');
- if(errorData.errorInfo == '鎷滆浜轰笉瀛樺湪'){
- console.log('errorData.errorRow = ' + errorData.errorRow)
- errorData.errorInfo ='鎷滆浜� ' + fileContentData[errorData.errorRow].split(',')[4] + '涓嶅瓨鍦�';
- }
- errorDatas.push(errorData);
- } else {
- if(ress[i].substr(7).substring(5) == '鎷滆浜轰笉瀛樺湪'){
- errorDatas[index].errorInfo += '; ' + '鎷滆浜� ' + fileContentData[errorDatas[index].errorRow].split(',')[4] + '涓嶅瓨鍦�';
- }else{
- errorDatas[index].errorInfo += '; ' + ress[i].substr(7).substring(5);
- }
- }
- }
- }
- let errorColumns = [
- { label: '閿欒琛�', fieldName: 'errorRow', type: 'text', hideDefaultActions: true, initialWidth: 100 },
- { label: '閿欒淇℃伅', fieldName: 'errorInfo', type: 'text', hideDefaultActions: true, initialWidth: 300, wrapText: true }
- ];
- for (var i = 0; i < fileContentData[0].split(',').length; i++) {
- errorColumns.push({
- label: fileContentData[0].split(',')[i],
- fieldName: 'field' + i,
- type: 'text',
- hideDefaultActions: true,
- wrapText: true,
- initialWidth: 120
- });
- }
-
- for (var i = 0; i < errorDatas.length; i++) {
- let data = fileContentData[errorDatas[i].errorRow];
- console.log('data = ' + JSON.stringify(data));
- if(data){
- for (var j = 0; j < data.split(',').length; j++) {
- let label = 'field' + j;
- errorDatas[i][label] = data.split(',')[j];
- }
- }
- }
- component.set('v.errorColumns', errorColumns);
- component.set('v.errorData', errorDatas);
- component.set("v.showErrorInfo", true);
- console.log("=="+res1);
- this.error(res1+"璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
- component.set('v.login',false);
- }else{
- component.set("v.showMain",true);
- this.success("瀵煎叆鎴愬姛");
- // alert('saved successfully');
- component.set('v.login',false);
- }
-
- }
- else if (state === "INCOMPLETE") {
- // do something
- 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(actionss);
- },saveRecordsEditFile : function(component,dataMap,searchData,helper){
- var searchDataMap = new Map();
- for (var i = 0; i < searchData.length; i++) {
- var sd = searchData[i];
- if(sd.name)
- searchDataMap.set(sd.name.replace(' ',''),sd.dataId);
- }
- console.log('searchDataMap='+searchDataMap);
- var error = '';
- var fileData = component.get("v.fileContentData");
- var files = fileData.split('\n');
-
- var fileStr = files[0];
- fileStr += '\n';
-
- for (var i = 1; i < files.length-1; i++) {
- var filelist = files[i].split(',');
- var fileName = filelist[4];
-
- if (searchDataMap.get(fileName.replace(' ',''))) {
- var nameDataId = searchDataMap.get(fileName.replace(' ',''));
- if (dataMap.get(nameDataId)) {
- filelist[4] = dataMap.get(nameDataId); //zhj 鏂版柟妗堟敼閫� filelist[4]涓嶅啀瀛樼殑nameEncrpt 2022-12-21
- }else {
- error += 'error1 绗�'+i+'琛屾暟鎹嫓璁夸汉SF涓嶅瓨鍦�';
- error += '=';
- }
- }else {
- error += 'error1 绗�'+i+'琛屾暟鎹嫓璁夸汉AWS涓嶅瓨鍦�';
- error += '=';
- }
- fileStr += filelist.toString();
- fileStr += '\n';
+ }
+ 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);
+ },
- if (error != '') {
- console.log('zhj error = ' + error);
- let errorArray = error.split('error1');
- let errorDatas = [];
- let errorDataRow = [];
- debugger
- var fileContentData = component.get("v.fileContentData").split('\n');
- console.log('errorArray = ' + JSON.stringify(errorArray))
- for (var i in errorArray) {
- if (errorArray[i] != '') {
- let errorData = {}
- if(!this.isNumber(errorArray[i].trim().substring(1, 2))){
- continue
- }
- let index = errorDataRow.indexOf(errorArray[i].trim().substring(1, 2));
- if (index == -1) {
- errorData.errorRow = errorArray[i].trim().substring(1, 2);
- errorDataRow.push(errorData.errorRow);
- errorData.errorInfo = errorArray[i].trim().substring(5,errorArray[i].trim().length).replace('=','');
- if(errorData.errorInfo == '鎷滆浜篈WS涓嶅瓨鍦�'){
- errorData.errorInfo ='鎷滆浜� ' + fileContentData[errorData.errorRow].split(',')[4] + '涓嶅瓨鍦�';
- }
- errorDatas.push(errorData);
- } else {
- if(errorArray[i].trim().substring(5) == '鎷滆浜篈WS涓嶅瓨鍦�'){
- errorData[index].errorInfo = '; ' + '鎷滆浜� ' + fileContentData[errorDatas[index].errorRow].split(',')[4] + '涓嶅瓨鍦�';
- }else{
- errorDatas[index].errorInfo += '; ' + errorArray[i].trim().substring(5,errorArray[i].trim().length);
- }
- }
- }
- }
- var fileContentData = component.get("v.fileContentData").split('\n');
- let errorColumns = [
- { label: '閿欒琛�', fieldName: 'errorRow', type: 'text', hideDefaultActions: true, initialWidth: 100 },
- { label: '閿欒淇℃伅', fieldName: 'errorInfo', type: 'text', hideDefaultActions: true, initialWidth: 300, wrapText: true }
- ];
- for (var i = 0; i < fileContentData[0].split(',').length; i++) {
- errorColumns.push({
- label: fileContentData[0].split(',')[i],
- fieldName: 'field' + i,
- type: 'text',
- hideDefaultActions: true,
- wrapText: true,
- initialWidth: 120
- });
- }
-
- for (var i = 0; i < errorDatas.length; i++) {
- let data = fileContentData[errorDatas[i].errorRow];
- console.log('data = ' + JSON.stringify(data));
- for (var j = 0; j < data.split(',').length; j++) {
- let label = 'field' + j;
- errorDatas[i][label] = data.split(',')[j];
- }
- }
- console.log('errorDatas =' + JSON.stringify(errorDatas))
- component.set('v.errorColumns', errorColumns);
- component.set('v.errorData', errorDatas);
- component.set("v.showErrorInfo", true);
-
-
-
- console.log('error = ' + error);
- component.set('v.errorMessage', error);
-
- this.error(error);
- console.log('error='+error);
- component.set('v.login',false);
- return;
- }
-
- console.log('fileStr='+fileStr);
- $A.getCallback(function(){
- debugger
- helper.ImportMethod(component,fileStr);
- })();
-
- },
- convertArrayOfObjectsToCSV : function(component,objectRecords){
- var csvStringResult, counter, keys, columnDivider, lineDivider,thkeys;
- if (objectRecords == null || !objectRecords.length) {
- return null;
- }
- columnDivider = ',';
- lineDivider = '\n';
- //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start ,'SupportNeeds__c' ,'鏀彺闇�姹�'
- keys = ['Submit_date__c','Person_In_Charge2__c','Report_Date__c','Agency_Hospital__c','Department_Cateogy__c','doctor2__c','visitor_title__c','Product_Category1__c','Product_Category2__c','Product_Category3__c','Purpose_Type__c','Result__c','SupportNeeds__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 == 'doctor2__c'){
- csvStringResult += '"'+ objectRecords[i].doctor2__r.Name+'"';
- }else if(skey == 'Product_Category1__c'){
- csvStringResult += '"'+ objectRecords[i].Product_Category1__r.Name+'"';
- }else if(skey == 'Product_Category2__c'){
- csvStringResult += '"'+ objectRecords[i].Product_Category2__r.Name+'"';
- }else if(skey == 'Product_Category3__c'){
- csvStringResult += '"'+ objectRecords[i].Product_Category3__r.Name+'"';
- }
- else if(skey == 'SupportNeeds__c'){//SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
- csvStringResult += '"'+ objectRecords[i].SupportNeeds__c+'"';
- }
- else{
- csvStringResult += '"'+ objectRecords[i][skey]+'"';
- }
- counter++;
-
- } // inner for loop close
- console.log("瀵煎嚭寰幆缁撴潫");
- csvStringResult += lineDivider;
- }// outer main for loop close
-
- // return the CSV formate String
- return csvStringResult;
- },
- showExportDate : function(component,objectRecords){
- console.log('杩涘叆showexceportdate'+objectRecords);//SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start ,'SupportNeeds__c' ,'鏀彺闇�姹�'
- var keys = ['Submit_date__c','Person_In_Charge2__c','Report_Date__c','Agency_Hospital__c','Department_Cateogy__c','doctor2__c','visitor_title__c','Product_Category1__c','Product_Category2__c','Product_Category3__c','Purpose_Type__c','Result__c','SupportNeeds__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>';
- // content += '<td>'+(i+1)+'</td>';
- 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 == 'doctor2__c'){
- content += '<td>'+ objectRecords[i].doctor2__r.Name+'</td>';
- }else if(skey == 'Product_Category1__c'){
- content += '<td>'+ objectRecords[i].Product_Category1__r.Name+'</td>';
- }else if(skey == 'Product_Category2__c'){
- content += '<td>'+ objectRecords[i].Product_Category2__r.Name+'</td>';
- }else if(skey == 'Product_Category3__c'){
- content += '<td>'+ objectRecords[i].Product_Category3__r.Name+'</td>';
- }
- else if(skey == 'SupportNeeds__c'){//SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
- content += '<td>'+ objectRecords[i].SupportNeeds__c+'</td>';
- }
- else{
- content += '<td>'+ objectRecords[i][skey]+'</td>';
- }
- } // inner for loop close
- content += '</tr>'
- }// outer main for loop close
- 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 awsurl = component.get('v.awsurl');
-
- AWSService.search(awsurl.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;
- res[ri].visitor_title__c = m[res[ri].doctor2__r.AWS_Data_Id__c].doctorDivision1;
-
- }
- }
- }
- helper.showExportDate(component, res);
-
- component.set('v.login', false);
- }, awsurl.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){
- // console.log('杩涘叆');
- // component.find('file').click();
- 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');
- },
-
- //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);
+ saveRecords: function (component, event, helper) {
+ debugger;
+ component.set("v.loginEdit", true);
+ //fy 瀵煎叆 20220424 start
+ var action1 = component.get("c.processDataAWSId");
+ action1.setParams({
+ fileData: component.get("v.fileContentData")
+ });
+ debugger;
+ action1.setCallback(this, function (response) {
+ console.log("response = " + JSON.stringify(response));
+ var state = response.getState();
+ if (state === "SUCCESS") {
+ var ress = response.getReturnValue();
+ console.log("ress = " + JSON.stringify(ress));
+ if (ress) {
+ var valur = ress.split("error1");
+ if (valur.length <= 1) {
+ var res = JSON.parse(response.getReturnValue());
+ console.log("res = " + JSON.stringify(res));
+ 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);
+ dataMap.set(item.AWS_Data_Id__c, item.AWS_Data_Id__c); //zhj 鏂版柟妗堟敼閫� 2022-12-21
+ }
});
+ let obj = Object.create(null);
+ obj["dataIds"] = dataArr;
+ var payload = JSON.stringify(obj);
+ console.log("payload zhj = " + JSON.stringify(payload));
+
+ this.search_contact_url(
+ component,
+ "Agency_Contact__c",
+ (result) => {
+ var token = result.token;
+ var searchUrl = result.searchUrl;
+ this.search_core(
+ token,
+ searchUrl,
+ payload,
+ (result) => {
+ if (result.status == "0") {
+ if (result.object != null && result.object.length != 0) {
+ // var resultjson = JSON.stringify(result.object);
+ // if(resultjson){
+ // debugger
+ // console.warn('001');
+ // component.set('v.login',true);
+ // this.ImportMethod(component,resultjson);
+ // }
+ component.set("v.loginEdit", true);
+ this.saveRecordsEditFile(
+ component,
+ dataMap,
+ result.object,
+ helper
+ );
+ } else {
+ this.error("AWS 鏌ヨ鏁版嵁涓虹┖ ");
+ component.set("v.loginEdit", false);
+ }
+ } else {
+ this.error("AWS search status6 : " + result.status);
+ component.set("v.loginEdit", false);
+ }
+ },
+ component
+ );
+ // var resultjson =null;
+ // this.ImportMethod(component,resultjson);
+ }
+ );
+ // var resultjson =null;
+ // this.ImportMethod(component,resultjson);
+ } else {
+ this.error(valur[1] + "\n" + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
+ }
}
-
- $A.enqueueAction(action);
- },
- //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
+ }
+ });
+ $A.enqueueAction(action1);
+ //fy 瀵煎叆 20220424 end
+ // var action = component.get("c.processData");
+ // var selectDate = component.find('select_date').get('v.value');
+ // var fieldsList=['Name','Phone','AccountNumber']; //Please write your code dynamic
+ // var sss=component.get("v.fileContentData");
+ // action.setParams({
+ // fileData : component.get("v.fileContentData"),
+ // //selectDateselectDate :component.find('select_date').get('v.value'),
+ // sobjectName:'Account', //Any object
+ // fields:fieldsList
+ // });
+ // action.setCallback(this, function(response) {
+ // var state = response.getState();
+ // if (state === "SUCCESS") {
- //zhj 瀵煎嚭閿欒淇℃伅 2023-05-16 start
- exportErrorInfoHelper: function (component) {
- var errorData = component.get('v.errorData');
- var errorColumns = component.get('v.errorColumns');
-
- var datas = [];
- let errorColumnsArray = [];
- for(var i in errorColumns){
- errorColumnsArray.push(errorColumns[i].label);
- }
- datas.push(errorColumnsArray);
- //datas.push(errorColumns);
-
- for (var i in errorData) {
- let data = [];
- data.push(errorData[i].errorRow)
- data.push(errorData[i].errorInfo)
- for(var j = 0 ; j < Object.keys(errorData[i]).length - 2 ; j++){
- data.push(errorData[i]['field' + j])
- }
- 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,'""') + '"';
- }
- if (j > 0) {
- csv += ',';
- }
- csv += val;
- }
- csv += '\n';
- }
- return csv;
- },
-
- downloadCSV: function (component, csv) {
- var link = document.createElement('a');
- // 璁剧疆瀛楃闆嗗拰鏂囦欢澶�
- var bom = "\uFEFF";
- link.href = 'data:text/csv;charset=utf-8,' + encodeURIComponent(bom + csv);
- link.download = 'data.csv';
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- },
- //zhj 瀵煎嚭閿欒淇℃伅 2023-05-16 end
-
- // searchAgencyContact : function(res) {
- // var agencyContacts = [];
- // for (let idx = 0; idx < res.length; idx++) {
- // agencyContacts.push(res[idx].awsid);
- // }
- // var action = component.get('c.getAWStoken');
- // action.setCallback(this,function(response){
- // var state = response.getState();
- // console.log('state : ' + state);
- // if(state === 'SUCCESS') {
- // console.log('get name : ' + action.getName());
- // }
- // else if(state === 'INCOMPLETE') {
- // console.log('incomplete state');
- // } else if(state === 'ERROR') {
- // if (errors) {
- // if (errors[0] && errors[0].message) {
- // console.log("Error message: " +
- // errors[0].message);
- // }
- // } else {
- // console.log("Unknown error");
+ // var res = response.getReturnValue();
+ // var res1 = '';
+ // console.log("[[[[[["+res);
+ // if(res != 'success'){
+ // debugger
+ // var ress = res.split('=');
+ // console.log(ress);
+ // for (var i=0; i<ress.length; i++) {
+ // res1 += ress[i].substr(7)+'\n';
// }
+ // // $('.forceToastManager').css('white-space', 'pre-wrap');
+ // console.log("=="+res1);
+ // this.error(res1+"璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
+ // component.set('v.login',false);
+ // }else{
+ // component.set("v.showMain",true);
+ // this.success("瀵煎叆鎴愬姛");
+ // // alert('saved successfully');
+ // component.set('v.login',false);
// }
- // });
- // $A.enqueueAction(action);
- // // var requestSearchPayload = new Map();
- // // requestSearchPayload.set("dataIds",agencyContacts);
- // var data = '{"dataIds": ["944233643042144256", "943645353649897473"]}';
- // var token = 'eyJhbGciOiJIUzUxMiJ9.eyJjcmVhdGVkIjoxNjQ0NzY4MTIwNjc2LCJhcHBpZCI6IjZMeml6Y1JmN2g4eUx4MjgiLCJleHAiOjE2NDk5NTIxMjB9.6vORDP8BRaf_beCt4SEXrl3DEuYZ3owotkUqh27r8YhfmKDDWrv_NpVVpjTPeFjvzlQqaJMcFobZeAmPxpmq2A';
- // var searchUrl = 'https://52.83.101.205/api/agencycontact/search';
- // var data = this.search(searchUrl,data,token);
- // return data;searchUrl,requestSearchPayload,token
- // },
-})
\ No newline at end of file
+
+ // }
+ // else if (state === "INCOMPLETE") {
+ // // do something
+ // 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);
+ },
+ isNumber: function (str) {
+ return /^\d+$/.test(str);
+ },
+ ImportMethod: function (component, fileStr) {
+ debugger;
+ var actionss = component.get("c.processData");
+ var selectDate = component.find("select_date").get("v.value");
+ var fieldsList = ["Name", "Phone", "AccountNumber"]; //Please write your code dynamic
+ var sss = component.get("v.fileContentData");
+ actionss.setParams({
+ // fileData : component.get("v.fileContentData"),
+ fileData: fileStr,
+ // selectDateselectDate :component.find('select_date').get('v.value'),
+ sobjectName: "Account", //Any object
+ fields: fieldsList
+ // Agency_ContactListjson:resultjson
+ });
+ actionss.setCallback(this, function (response) {
+ console.log("002");
+ var state = response.getState();
+ if (state === "SUCCESS") {
+ var res = response.getReturnValue();
+ var res1 = "";
+ console.log("[[[[[[" + res);
+ if (res != "success") {
+ var ress = res.split("=");
+ console.log(ress);
+ let errorDatas = [];
+ let errorDataRow = [];
+ debugger;
+ var fileContentData = component.get("v.fileContentData").split("\n");
+ for (var i = 0; i < ress.length; i++) {
+ res1 += ress[i].substr(7) + "\n";
+ if (ress[i] != "") {
+ let errorData = {};
+ if (!this.isNumber(ress[i].substr(7).substring(1, 2))) {
+ continue;
+ }
+ let index = errorDataRow.indexOf(
+ ress[i].substr(7).substring(1, 2)
+ );
+ if (index == -1) {
+ errorData.errorRow = ress[i].substr(7).substring(1, 2);
+ errorDataRow.push(errorData.errorRow);
+ errorData.errorInfo = ress[i]
+ .substr(7)
+ .substring(5)
+ .replace("=", "");
+ if (errorData.errorInfo == "鎷滆浜轰笉瀛樺湪") {
+ console.log("errorData.errorRow = " + errorData.errorRow);
+ errorData.errorInfo =
+ "鎷滆浜� " +
+ fileContentData[errorData.errorRow].split(",")[4] +
+ "涓嶅瓨鍦�";
+ }
+ errorDatas.push(errorData);
+ } else {
+ if (ress[i].substr(7).substring(5) == "鎷滆浜轰笉瀛樺湪") {
+ errorDatas[index].errorInfo +=
+ "; " +
+ "鎷滆浜� " +
+ fileContentData[errorDatas[index].errorRow].split(",")[4] +
+ "涓嶅瓨鍦�";
+ } else {
+ errorDatas[index].errorInfo +=
+ "; " + ress[i].substr(7).substring(5);
+ }
+ }
+ }
+ }
+ let errorColumns = [
+ {
+ label: "閿欒琛�",
+ fieldName: "errorRow",
+ type: "text",
+ hideDefaultActions: true,
+ initialWidth: 100
+ },
+ {
+ label: "閿欒淇℃伅",
+ fieldName: "errorInfo",
+ type: "text",
+ hideDefaultActions: true,
+ initialWidth: 300,
+ wrapText: true
+ }
+ ];
+ for (var i = 0; i < fileContentData[0].split(",").length; i++) {
+ errorColumns.push({
+ label: fileContentData[0].split(",")[i],
+ fieldName: "field" + i,
+ type: "text",
+ hideDefaultActions: true,
+ wrapText: true,
+ initialWidth: 120
+ });
+ }
+
+ for (var i = 0; i < errorDatas.length; i++) {
+ let data = fileContentData[errorDatas[i].errorRow];
+ console.log("data = " + JSON.stringify(data));
+ if (data) {
+ for (var j = 0; j < data.split(",").length; j++) {
+ let label = "field" + j;
+ errorDatas[i][label] = data.split(",")[j];
+ }
+ }
+ }
+ component.set("v.errorColumns", errorColumns);
+ component.set("v.errorData", errorDatas);
+ component.set("v.showErrorInfo", true);
+ console.log("==" + res1);
+ this.error(res1 + "璇蜂慨鏀瑰悗閲嶆柊涓婁紶");
+ component.set("v.loginEdit", false);
+ } else {
+ component.set("v.showMain", true);
+ this.success("瀵煎叆鎴愬姛");
+ // alert('saved successfully');
+ component.set("v.loginEdit", false);
+ }
+ } else if (state === "INCOMPLETE") {
+ // do something
+ component.set("v.loginEdit", 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.loginEdit", false);
+ }
+ } else {
+ console.log("Unknown error");
+ component.set("v.loginEdit", false);
+ }
+ }
+ });
+ $A.enqueueAction(actionss);
+ },
+ saveRecordsEditFile: function (component, dataMap, searchData, helper) {
+ var searchDataMap = new Map();
+ for (var i = 0; i < searchData.length; i++) {
+ var sd = searchData[i];
+ if (sd.name) searchDataMap.set(sd.name.replace(" ", ""), sd.dataId);
+ }
+ console.log("searchDataMap=" + searchDataMap);
+ var error = "";
+ var fileData = component.get("v.fileContentData");
+ var files = fileData.split("\n");
+
+ var fileStr = files[0];
+ fileStr += "\n";
+
+ for (var i = 1; i < files.length - 1; i++) {
+ var filelist = files[i].split(",");
+ var fileName = filelist[4];
+
+ if (searchDataMap.get(fileName.replace(" ", ""))) {
+ var nameDataId = searchDataMap.get(fileName.replace(" ", ""));
+ if (dataMap.get(nameDataId)) {
+ filelist[4] = dataMap.get(nameDataId); //zhj 鏂版柟妗堟敼閫� filelist[4]涓嶅啀瀛樼殑nameEncrpt 2022-12-21
+ } else {
+ error += "error1 绗�" + i + "琛屾暟鎹嫓璁夸汉SF涓嶅瓨鍦�";
+ error += "=";
+ }
+ } else {
+ error += "error1 绗�" + i + "琛屾暟鎹嫓璁夸汉AWS涓嶅瓨鍦�";
+ error += "=";
+ }
+ fileStr += filelist.toString();
+ fileStr += "\n";
+ }
+
+ if (error != "") {
+ console.log("zhj error = " + error);
+ let errorArray = error.split("error1");
+ let errorDatas = [];
+ let errorDataRow = [];
+ debugger;
+ var fileContentData = component.get("v.fileContentData").split("\n");
+ console.log("errorArray = " + JSON.stringify(errorArray));
+ for (var i in errorArray) {
+ if (errorArray[i] != "") {
+ let errorData = {};
+ if (!this.isNumber(errorArray[i].trim().substring(1, 2))) {
+ continue;
+ }
+ let index = errorDataRow.indexOf(
+ errorArray[i].trim().substring(1, 2)
+ );
+ if (index == -1) {
+ errorData.errorRow = errorArray[i].trim().substring(1, 2);
+ errorDataRow.push(errorData.errorRow);
+ errorData.errorInfo = errorArray[i]
+ .trim()
+ .substring(5, errorArray[i].trim().length)
+ .replace("=", "");
+ if (errorData.errorInfo == "鎷滆浜篈WS涓嶅瓨鍦�") {
+ errorData.errorInfo =
+ "鎷滆浜� " +
+ fileContentData[errorData.errorRow].split(",")[4] +
+ "涓嶅瓨鍦�";
+ }
+ errorDatas.push(errorData);
+ } else {
+ if (errorArray[i].trim().substring(5) == "鎷滆浜篈WS涓嶅瓨鍦�") {
+ errorData[index].errorInfo =
+ "; " +
+ "鎷滆浜� " +
+ fileContentData[errorDatas[index].errorRow].split(",")[4] +
+ "涓嶅瓨鍦�";
+ } else {
+ errorDatas[index].errorInfo +=
+ "; " +
+ errorArray[i].trim().substring(5, errorArray[i].trim().length);
+ }
+ }
+ }
+ }
+ var fileContentData = component.get("v.fileContentData").split("\n");
+ let errorColumns = [
+ {
+ label: "閿欒琛�",
+ fieldName: "errorRow",
+ type: "text",
+ hideDefaultActions: true,
+ initialWidth: 100
+ },
+ {
+ label: "閿欒淇℃伅",
+ fieldName: "errorInfo",
+ type: "text",
+ hideDefaultActions: true,
+ initialWidth: 300,
+ wrapText: true
+ }
+ ];
+ for (var i = 0; i < fileContentData[0].split(",").length; i++) {
+ errorColumns.push({
+ label: fileContentData[0].split(",")[i],
+ fieldName: "field" + i,
+ type: "text",
+ hideDefaultActions: true,
+ wrapText: true,
+ initialWidth: 120
+ });
+ }
+
+ for (var i = 0; i < errorDatas.length; i++) {
+ let data = fileContentData[errorDatas[i].errorRow];
+ console.log("data = " + JSON.stringify(data));
+ for (var j = 0; j < data.split(",").length; j++) {
+ let label = "field" + j;
+ errorDatas[i][label] = data.split(",")[j];
+ }
+ }
+ console.log("errorDatas =" + JSON.stringify(errorDatas));
+ component.set("v.errorColumns", errorColumns);
+ component.set("v.errorData", errorDatas);
+ component.set("v.showErrorInfo", true);
+
+ console.log("error = " + error);
+ component.set("v.errorMessage", error);
+
+ this.error(error);
+ console.log("error=" + error);
+ component.set("v.loginEdit", false);
+ return;
+ }
+
+ console.log("fileStr=" + fileStr);
+ $A.getCallback(function () {
+ debugger;
+ helper.ImportMethod(component, fileStr);
+ })();
+ },
+ convertArrayOfObjectsToCSV: function (component, objectRecords) {
+ var csvStringResult, counter, keys, columnDivider, lineDivider, thkeys;
+ if (objectRecords == null || !objectRecords.length) {
+ return null;
+ }
+ columnDivider = ",";
+ lineDivider = "\n";
+ //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start ,'SupportNeeds__c' ,'鏀彺闇�姹�'
+ keys = [
+ "Submit_date__c",
+ "Person_In_Charge2__c",
+ "Report_Date__c",
+ "Agency_Hospital__c",
+ "Department_Cateogy__c",
+ "doctor2__c",
+ "visitor_title__c",
+ "Product_Category1__c",
+ "Product_Category2__c",
+ "Product_Category3__c",
+ "Purpose_Type__c",
+ "Result__c",
+ "SupportNeeds__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 == "doctor2__c") {
+ csvStringResult += '"' + objectRecords[i].doctor2__r.Name + '"';
+ } else if (skey == "Product_Category1__c") {
+ csvStringResult +=
+ '"' + objectRecords[i].Product_Category1__r.Name + '"';
+ } else if (skey == "Product_Category2__c") {
+ csvStringResult +=
+ '"' + objectRecords[i].Product_Category2__r.Name + '"';
+ } else if (skey == "Product_Category3__c") {
+ csvStringResult +=
+ '"' + objectRecords[i].Product_Category3__r.Name + '"';
+ } else if (skey == "SupportNeeds__c") {
+ //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
+ csvStringResult += '"' + objectRecords[i].SupportNeeds__c + '"';
+ } else {
+ csvStringResult += '"' + objectRecords[i][skey] + '"';
+ }
+ counter++;
+ } // inner for loop close
+ console.log("瀵煎嚭寰幆缁撴潫");
+ csvStringResult += lineDivider;
+ } // outer main for loop close
+
+ // return the CSV formate String
+ return csvStringResult;
+ },
+ showExportDate: function (component, objectRecords) {
+ console.log("杩涘叆showexceportdate" + objectRecords); //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start ,'SupportNeeds__c' ,'鏀彺闇�姹�'
+ var keys = [
+ "Submit_date__c",
+ "Person_In_Charge2__c",
+ "Report_Date__c",
+ "Agency_Hospital__c",
+ "Department_Cateogy__c",
+ "doctor2__c",
+ "visitor_title__c",
+ "Product_Category1__c",
+ "Product_Category2__c",
+ "Product_Category3__c",
+ "Purpose_Type__c",
+ "Result__c",
+ "SupportNeeds__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>";
+ // content += '<td>'+(i+1)+'</td>';
+ 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 == "doctor2__c") {
+ content += "<td>" + objectRecords[i].doctor2__r.Name + "</td>";
+ } else if (skey == "Product_Category1__c") {
+ content +=
+ "<td>" + objectRecords[i].Product_Category1__r.Name + "</td>";
+ } else if (skey == "Product_Category2__c") {
+ content +=
+ "<td>" + objectRecords[i].Product_Category2__r.Name + "</td>";
+ } else if (skey == "Product_Category3__c") {
+ content +=
+ "<td>" + objectRecords[i].Product_Category3__r.Name + "</td>";
+ } else if (skey == "SupportNeeds__c") {
+ //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start
+ content += "<td>" + objectRecords[i].SupportNeeds__c + "</td>";
+ } else {
+ content += "<td>" + objectRecords[i][skey] + "</td>";
+ }
+ } // inner for loop close
+ content += "</tr>";
+ } // outer main for loop close
+ 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.loginEdit", 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.loginEdit", 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 awsurl = component.get("v.awsurl");
+
+ AWSService.search(
+ awsurl.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;
+ res[ri].visitor_title__c =
+ m[res[ri].doctor2__r.AWS_Data_Id__c].doctorDivision1;
+ }
+ }
+ }
+ helper.showExportDate(component, res);
+
+ component.set("v.loginEdit", false);
+ },
+ awsurl.token
+ );
+ } else {
+ helper.showExportDate(component, res);
+ }
+ }
+
+ component.set("v.reports_date", res);
+ } else {
+ alert("瀵煎嚭澶辫触,璇锋鏌ユ椿鍔ㄦ棩");
+ component.set("v.loginEdit", false);
+ }
+ });
+ $A.enqueueAction(action);
+ },
+
+ showImport: function (component) {
+ // console.log('杩涘叆');
+ // component.find('file').click();
+ 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");
+ },
+
+ //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 errorColumns = component.get("v.errorColumns");
+
+ var datas = [];
+ let errorColumnsArray = [];
+ for (var i in errorColumns) {
+ errorColumnsArray.push(errorColumns[i].label);
+ }
+ datas.push(errorColumnsArray);
+ //datas.push(errorColumns);
+
+ for (var i in errorData) {
+ let data = [];
+ data.push(errorData[i].errorRow);
+ data.push(errorData[i].errorInfo);
+ for (var j = 0; j < Object.keys(errorData[i]).length - 2; j++) {
+ data.push(errorData[i]["field" + j]);
+ }
+ 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,'""') + '"';
+ }
+ if (j > 0) {
+ csv += ",";
+ }
+ csv += val;
+ }
+ csv += "\n";
+ }
+ return csv;
+ },
+
+ downloadCSV: function (component, csv) {
+ var link = document.createElement("a");
+ // 璁剧疆瀛楃闆嗗拰鏂囦欢澶�
+ var bom = "\uFEFF";
+ link.href = "data:text/csv;charset=utf-8," + encodeURIComponent(bom + csv);
+ link.download = "data.csv";
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ }
+ //zhj 瀵煎嚭閿欒淇℃伅 2023-05-16 end
+
+ // searchAgencyContact : function(res) {
+ // var agencyContacts = [];
+ // for (let idx = 0; idx < res.length; idx++) {
+ // agencyContacts.push(res[idx].awsid);
+ // }
+ // var action = component.get('c.getAWStoken');
+ // action.setCallback(this,function(response){
+ // var state = response.getState();
+ // console.log('state : ' + state);
+ // if(state === 'SUCCESS') {
+ // console.log('get name : ' + action.getName());
+ // }
+ // else if(state === 'INCOMPLETE') {
+ // console.log('incomplete state');
+ // } else if(state === 'ERROR') {
+ // if (errors) {
+ // if (errors[0] && errors[0].message) {
+ // console.log("Error message: " +
+ // errors[0].message);
+ // }
+ // } else {
+ // console.log("Unknown error");
+ // }
+ // }
+ // });
+ // $A.enqueueAction(action);
+ // // var requestSearchPayload = new Map();
+ // // requestSearchPayload.set("dataIds",agencyContacts);
+ // var data = '{"dataIds": ["944233643042144256", "943645353649897473"]}';
+ // var token = 'eyJhbGciOiJIUzUxMiJ9.eyJjcmVhdGVkIjoxNjQ0NzY4MTIwNjc2LCJhcHBpZCI6IjZMeml6Y1JmN2g4eUx4MjgiLCJleHAiOjE2NDk5NTIxMjB9.6vORDP8BRaf_beCt4SEXrl3DEuYZ3owotkUqh27r8YhfmKDDWrv_NpVVpjTPeFjvzlQqaJMcFobZeAmPxpmq2A';
+ // var searchUrl = 'https://52.83.101.205/api/agencycontact/search';
+ // var data = this.search(searchUrl,data,token);
+ // return data;searchUrl,requestSearchPayload,token
+ // },
+});
diff --git a/force-app/main/default/classes/ArriveGoodsControllerTest.cls b/force-app/main/default/classes/ArriveGoodsControllerTest.cls
index b5213ac..910aeb3 100644
--- a/force-app/main/default/classes/ArriveGoodsControllerTest.cls
+++ b/force-app/main/default/classes/ArriveGoodsControllerTest.cls
@@ -1,2911 +1,3985 @@
@isTest
private class ArriveGoodsControllerTest {
- @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)'];
+ //閫夋嫨绛夊緟鍏ュ簱,鍖呮嫭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)'
+ ];
- 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 account[]{myAccount1,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=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;
- }
+ 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 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 = 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;
+ // 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 };
+ //璁㈠崟
- //璁㈠崟鏄庣粏
- //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__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;
- //鍙戣揣鏄庣粏
- //鍒拌揣姝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 = 4;
+ 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 = '鐩�';
+ //鍙戣揣鏄庣粏
+ //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';
+ insert Orderdet1;
- //鍑哄簱浜у搧
- 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';
+ 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_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';
+ //浜у搧鐩存帴鍏ュ簱,鍖呮嫭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)'
+ ];
- //鍙戣揣鏄庣粏
- //绠$悊缂栫爜鍖呭惈鏁板瓧
- 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';
+ 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_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';
+ 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,Orderdets8};
+ // 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)'
+ ];
- List<Consumable_orderdetails__c> cod1 = [select Id from Consumable_orderdetails__c WHERE Consumable_order__c = :Order1.Id];
- System.assertEquals(1, cod1.size());
+ 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;
+ }
- PageReference page = new PageReference('/apex/ArriveGoods?Esetid=' + Order1.Id);
+ // 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;
- 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();
+ 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;
- // 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)'];
+ //鍒拌揣姝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;
- 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 account[]{myAccount1,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=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;
- }
+ 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',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 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};
- //璁㈠崟
+ System.assertEquals(
+ 'OCM_01_001002',
+ controller.ConsumableorderdetailsRecords[0].esd.Name
+ );
+ // System.assertEquals(2, controller.ConsumableorderdetailsRecordserror.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 = myAccount1.id;
- Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
- Order1.Order_ProType__c = 'ET';
- insert Order1;
+ //鏁翠綋鍒拌揣
+ @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)'
+ ];
- //璁㈠崟鏄庣粏
- //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;
+ 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 };
- //鍙戣揣鏄庣粏
- //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',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;
- 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();
- }
- }
+ //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;
- //浜у搧鐩存帴鍏ュ簱,鍖呮嫭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)'];
+ //鍒拌揣姝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 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 account[]{myAccount1,myAccount2};
+ //宸插埌璐т骇鍝�
+ 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
+ };
- 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;
- }
+ 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();
- // 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 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
- 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(1, controller.ConsumableorderdetailsRecordserror.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 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
+ 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)'
+ ];
- // 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 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;
+ 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 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;
+ 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;
+ }
- //鍒拌揣姝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 = '涓�';
+ // 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';
+ //杩斿搧璁㈠崟
- //鍑哄簱浜у搧
- 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__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;
- //宸插埌璐т骇鍝�
- 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};
+ //璁㈠崟鏄庣粏
+ //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 = '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();
+ }
+ }
- 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();
+ //杩斿搧
+ @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)'
+ ];
- System.assertEquals('OCM_01_001002', controller.ConsumableorderdetailsRecords[0].esd.Name);
- // System.assertEquals(2, controller.ConsumableorderdetailsRecordserror.size());
- System.Test.stopTest();
+ 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
+ );
+ 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);
- //鏁翠綋鍒拌揣
- @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)'];
+ //璁㈠崟鏄庣粏
+ //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;
- 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 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 = '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>{
+ Orderdet3,
+ Orderdet4,
+ Orderdet5
+ };
- 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;
- }
+ 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();
- // // 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 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;
+ list<String> list1 = new List<String>();
+ list1.add(Controller.barcode = '01234567898');
+ Controller.inventoryEntryNoESetId(list1);
- //system.runAs(myUser_Test){
- //璁㈠崟
+ list1.clear();
+ list1.add(Controller.barcode = '012345678901234A67');
+ 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 = '0123456789012345117AA01');
+ 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.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';
+ list1.clear();
+ list1.add(Controller.barcode = '01234567890123456789012349990001');
+ Controller.inventoryEntryNoESetId(list1);
+ 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.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 = 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};
+ 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 = '24134567');
+ 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 = '01049531702003111115120017181000105ZK250BXJRA\n01049531702003111115120017181000105ZK250BXJRB\n01049531702003111115120017181000105ZK250BXJRC\n01049531702003111115120017181000105ZK250BXJRD\n01049531702003111115120017181000105ZK250BXJRE\n01049531702003111115120017181000105ZK250BXsun\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRG\n01049531702003111115120017181000105ZK250BXsys';
- Controller.SearchPro();
+ list1.clear();
+ list1.add(Controller.barcode = '241345678');
+ Controller.inventoryEntryNoESetId(list1);
- System.assertEquals('OCM_01_001002', controller.ConsumableorderdetailsRecords[0].esd.Name);
- // System.assertEquals(1, controller.ConsumableorderdetailsRecordserror.size());
- System.Test.stopTest();
+ 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 = '241345678901');
+ 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();
+ }
+ }
+ //鐩存帴鍒拌揣
+ @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
- 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)'];
+ 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 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 account[]{myAccount1,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 = '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;
+ //璁㈠崟
- 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;
- }
+ 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;
- // 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 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};
- //璁㈠崟
+ //璁㈠崟鏄庣粏
+ //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__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';
- //杩斿搧璁㈠崟
+ //鍙戣揣鏄庣粏
+ //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 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;
+ 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 = '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';
+ //鐩存帴鍒拌揣
+ @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,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 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
+ );
+ 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
- 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)'];
+ 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 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 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.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';
- 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;
- }
+ 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';
- // 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 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 = 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);
+ //鍑哄簱
+ 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';
- //璁㈠崟鏄庣粏
- //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;
+ // 鍗曚綅涓轰釜鐨凚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';
- //鍙戣揣鏄庣粏
- //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};
+ 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';
- 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();
+ 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();
- list<String> list1 = new list<String>();
- list1.add(Controller.barcode = '01234567898');
- Controller.inventoryEntryNoESetId(list1);
+ 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';
- list1.clear();
- list1.add(Controller.barcode = '012345678901234A67');
- Controller.inventoryEntryNoESetId(list1);
+ //List<Product2> proList = [select name,Estimation_Entry_Possibility__c from Product2 where id = :prod01.Id];
+ //System.assertEquals('鈼�', proList[0].Estimation_Entry_Possibility__c);
- list1.clear();
- list1.add(Controller.barcode = '0123456789012345117AA01');
- Controller.inventoryEntryNoESetId(list1);
+ 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();
- list1.clear();
- list1.add(Controller.barcode = '01234567890123456789012349990001');
- Controller.inventoryEntryNoESetId(list1);
+ 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());
- list1.clear();
- list1.add(Controller.barcode = '0123456789012345177AA0000000000001');
- Controller.inventoryEntryNoESetId(list1);
+ System.Test.stopTest();
+ }
+ }
- list1.clear();
- list1.add(Controller.barcode = '0123456789012345177AA1111111111111');
- Controller.inventoryEntryNoESetId(list1);
+ //杩斿搧 鏄庣粏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)'
+ ];
- list1.clear();
- list1.add(Controller.barcode = '241345');
- 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 = '2413456');
- 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 = '24134567');
- 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 };
+ //璁㈠崟
- list1.clear();
- list1.add(Controller.barcode = '241345678');
- 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;
- list1.clear();
- list1.add(Controller.barcode = '2413456789');
- Controller.inventoryEntryNoESetId(list1);
+ //杩斿搧璁㈠崟
- list1.clear();
- list1.add(Controller.barcode = '24134567890');
- 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 = '241345678901');
- 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 = '0112345678901231177890121215678901234');
- Controller.inventoryEntryNoESetId(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 = '0112345678901231106789012105678901234');
- Controller.inventoryEntryNoESetId(list1);
- list1.clear();
- list1.add(Controller.barcode = '0112345678901231106789012105625001234');
- Controller.inventoryEntryNoESetId(list1);
- System.Test.stopTest();
+ //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';
- }
- }
+ //鍙戣揣鏄庣粏
+ //娌″嚭搴擄紝娌¢攢鍞紝灏辨槸鍦ㄥ簱
+ 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';
- //鐩存帴鍒拌揣
- @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)'];
+ 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();
+ 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)'
+ ];
- 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 account[]{myAccount1,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=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;
- }
+ 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);
- // 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 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;
- //璁㈠崟
+ list1.clear();
+ list1.add(Controller.barcode = '241250BBBBZ');
+ Controller.inventoryEntry(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;
- insert Order1;
+ list1.clear();
+ list1.add(Controller.barcode = '241250');
+ 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 = '241250BBB');
+ Controller.inventoryEntry(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';
- //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);
+ list1.clear();
+ list1.add(Controller.barcode = '24134567250BBBBB');
+ Controller.inventoryEntry(list1);
- 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());
+ list1.clear();
+ list1.add(Controller.barcode = '241345678250BBBBC');
+ Controller.inventoryEntry(list1);
- System.Test.stopTest();
- }
- }
+ list1.clear();
+ list1.add(Controller.barcode = '2413456789250BBBBD');
+ Controller.inventoryEntry(list1);
- //鐩存帴鍒拌揣
- @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)'];
+ list1.clear();
+ list1.add(Controller.barcode = '24134567890250BBBBE');
+ Controller.inventoryEntry(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '241345678901250BBBBF');
+ Controller.inventoryEntry(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '2413456789011250BBBBG');
+ 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 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;
- }
+ list1.clear();
+ list1.add(Controller.barcode = '24134567890111250BBBBH');
+ 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,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 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;
- //璁㈠崟
+ list1.clear();
+ list1.add(Controller.barcode = '0112345678901231712300123250BBBBI');
+ Controller.inventoryEntry(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;
- 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;
-
- //鍙戣揣鏄庣粏
- //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 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';
-
- //鍑哄簱
- 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';
-
- // 鍗曚綅涓轰釜鐨凚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';
-
- 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';
-
- 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();
-
- 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';
-
- //List<Product2> proList = [select name,Estimation_Entry_Possibility__c from Product2 where id = :prod01.Id];
- //System.assertEquals('鈼�', proList[0].Estimation_Entry_Possibility__c);
-
- 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();
-
- 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());
-
- System.Test.stopTest();
- }
- }
-
-
- //杩斿搧 鏄庣粏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)'];
-
-
- 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 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 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 = myAccount1.id;
- Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
-
- //杩斿搧璁㈠崟
-
- 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;
-
- //鍙戣揣鏄庣粏
- //娌″嚭搴擄紝娌¢攢鍞紝灏辨槸鍦ㄥ簱
- 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';
-
- //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';
-
- //鍙戣揣鏄庣粏
- //娌″嚭搴擄紝娌¢攢鍞紝灏辨槸鍦ㄥ簱
- 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';
-
- 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();
-
- 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)'];
-
-
- 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 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 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 = '241250BBBBZ');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '241250');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '241250BBB');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '24134567250BBBBB');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '241345678250BBBBC');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '2413456789250BBBBD');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '24134567890250BBBBE');
- 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 = '24134567890111250BBBBH');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '0112345678901231712300123250BBBBI');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '011234567890250BBBBJ');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '01123456789A0123456250BBBBK');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '011234567890123411AAAA123250BBBBL');
- 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 = '01123456789012341778910034567890250BBBBP');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '011234567890123417aa910034567890250BBBBQ');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '01123456789012341778911134567890250BBBBR');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '011234567890123417789121105678900000250BBBBS');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '011234567890123410789121105678900000250BBBBT');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '011234567890123411789012171a780012250BBBBU');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '0112345678901234110890121012789000250BBBBV');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '011234567890123417120506105678901234250BBBBW');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '0112345678901234111202121712050212250BBBBX');
- Controller.inventoryEntry(list1);
-
- list1.clear();
- list1.add(Controller.barcode = '0112345678901234111202121712a50212250BBBBY');
- Controller.inventoryEntry(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '011234567890250BBBBJ');
+ 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 = '01123456789A0123456250BBBBK');
+ Controller.inventoryEntry(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '011234567890123411AAAA123250BBBBL');
+ 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 account[]{myAccount1,myAccount2};
+ list1.clear();
+ list1.add(
+ Controller.barcode = '011234567890123411789012175678901234250BBBBM'
+ );
+ 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 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 = '01123456789012340138901217aaa8001234250BBBBN'
+ );
+ 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 = '011234567890123456789012104567890250BBBBO'
+ );
+ Controller.inventoryEntry(list1);
- list1.clear();
- list1.add(Controller.barcode = '241250BBBBZ');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(
+ Controller.barcode = '01123456789012341778910034567890250BBBBP'
+ );
+ Controller.inventoryEntry(list1);
- list1.clear();
- list1.add(Controller.barcode = '241250');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(
+ Controller.barcode = '011234567890123417aa910034567890250BBBBQ'
+ );
+ Controller.inventoryEntry(list1);
- list1.clear();
- list1.add(Controller.barcode = '241250BBZ');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(
+ Controller.barcode = '01123456789012341778911134567890250BBBBR'
+ );
+ Controller.inventoryEntry(list1);
- list1.clear();
- list1.add(Controller.barcode = '24134567250BBBBB');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(
+ Controller.barcode = '011234567890123417789121105678900000250BBBBS'
+ );
+ Controller.inventoryEntry(list1);
- list1.clear();
- list1.add(Controller.barcode = '241345678250BBBBC');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(
+ Controller.barcode = '011234567890123410789121105678900000250BBBBT'
+ );
+ Controller.inventoryEntry(list1);
- list1.clear();
- list1.add(Controller.barcode = '2413452509250BBBBD');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(
+ Controller.barcode = '011234567890123411789012171a780012250BBBBU'
+ );
+ Controller.inventoryEntry(list1);
- list1.clear();
- list1.add(Controller.barcode = '24125090111250BBBBE');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(
+ Controller.barcode = '0112345678901234110890121012789000250BBBBV'
+ );
+ Controller.inventoryEntry(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 = '011234567890123417120506105678901234250BBBBW'
+ );
+ Controller.inventoryEntry(list1);
- list1.clear();
- list1.add(Controller.barcode = '24134525090111250BBBBH');
- Controller.inventoryEntryNoESetId(list1);
- list1.clear();
- list1.add(Controller.barcode = '241test1712345678901234567890250BBBBI');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(
+ Controller.barcode = '0112345678901234111202121712050212250BBBBX'
+ );
+ Controller.inventoryEntry(list1);
- list1.clear();
- list1.add(Controller.barcode = '241test171234500678901234567890250BBBBJ');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(
+ Controller.barcode = '0112345678901234111202121712a50212250BBBBY'
+ );
+ Controller.inventoryEntry(list1);
- list1.clear();
- list1.add(Controller.barcode = '241test17120400678901234567890250BBBBK');
- Controller.inventoryEntryNoESetId(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 = '241test171204110678901234567890250BBBBL');
- 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 = '241test171204121078901234567890250BBBBM');
- 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 = '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 = '241test17120412250BBBBN');
- 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 = '241test101204121078901234567890250BBBBO');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '241250BBBBZ');
+ Controller.inventoryEntryNoESetId(list1);
- list1.clear();
- list1.add(Controller.barcode = '241test1112a4121078901234567890250BBBBP');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '241250');
+ Controller.inventoryEntryNoESetId(list1);
- list1.clear();
- list1.add(Controller.barcode = '241test111204121778900034567890250BBBBQ');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '241250BBZ');
+ 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);
- }
- }
+ list1.clear();
+ list1.add(Controller.barcode = '241test171234500678901234567890250BBBBJ');
+ 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 = '241test17120400678901234567890250BBBBK');
+ Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '241test171204110678901234567890250BBBBL');
+ 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 account[]{myAccount1,myAccount2};
+ list1.clear();
+ list1.add(Controller.barcode = '241test171204121078901234567890250BBBBM');
+ 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 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 = '241test17120412250BBBBN');
+ 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 = '241test101204121078901234567890250BBBBO');
+ 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 = '241test1112a4121078901234567890250BBBBP');
+ Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '241test111204121778900034567890250BBBBQ');
+ 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 account[]{myAccount1,myAccount2};
+ list1.clear();
+ list1.add(
+ Controller.barcode = '0111234101204120118901231712a4001234250BBBBR'
+ );
+ 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 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 = '011123410120412011890123171204011234250BBBBS'
+ );
+ 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 = '011test10120412011890123171a04011234250BBBBT'
+ );
+ 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 = '0111234101204120118901231012040112342222250BBBBU'
+ );
+ 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 = '011123410120412017120100250AAAAA');
+ 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;
+ //鑷姩鍑哄簱
+ @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)'
+ ];
- 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();
- }
- }
+ 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.Arrive_date__c = Date.today();
+ Orderdets8.TracingCode__c = 'BXSYS';
+ Orderdets8.SerialLotNo__c = '5ZK';
+ insert Orderdets8;
- //杩斿搧
- @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)'];
+ 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();
+ }
+ }
+ // 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)'
+ ];
- 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 account[]{myAccount1,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=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 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 = 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);
+ 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 };
+ //璁㈠崟
- //璁㈠崟鏄庣粏
- //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;
+ 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;
- //鍙戣揣鏄庣粏
- //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[] {Orderdet1,Orderdet3,Orderdet4,Orderdet5};
+ //璁㈠崟鏄庣粏
+ //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;
- 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();
+ //鍙戣揣鏄庣粏
+ //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;
- list<String> list1 = new list<String>();
- list1.add(Controller.barcode = '01234567898');
- 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 = '012345678901234A67');
- 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 = '0123456789012345117AA01');
- 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 = '01234567890123456789012349990001');
- 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 = '0123456789012345177AA0000000000001');
- 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);
- list1.clear();
- list1.add(Controller.barcode = '0123456789012345177AA1111111111111');
- Controller.inventoryEntryNoESetId(list1);
+ //璁㈠崟鏄庣粏
+ //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;
- list1.clear();
- list1.add(Controller.barcode = '241345');
- 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 = '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
+ };
- list1.clear();
- list1.add(Controller.barcode = '2413456');
- Controller.inventoryEntryNoESetId(list1);
+ 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();
- list1.clear();
- list1.add(Controller.barcode = '24134567');
- Controller.inventoryEntryNoESetId(list1);
+ list<String> list1 = new List<String>();
+ list1.add(Controller.barcode = '01234567898');
+ Controller.inventoryEntryNoESetId(list1);
- list1.clear();
- list1.add(Controller.barcode = '241345678');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '012345678901234A67');
+ Controller.inventoryEntryNoESetId(list1);
- list1.clear();
- list1.add(Controller.barcode = '2413456789');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '0123456789012345117AA01');
+ Controller.inventoryEntryNoESetId(list1);
- list1.clear();
- list1.add(Controller.barcode = '24134567890');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '01234567890123456789012349990001');
+ Controller.inventoryEntryNoESetId(list1);
- list1.clear();
- list1.add(Controller.barcode = '241345678901');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '0123456789012345177AA0000000000001');
+ Controller.inventoryEntryNoESetId(list1);
- list1.clear();
- list1.add(Controller.barcode = '0112345678901231177890121215678901234');
- Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '0123456789012345177AA1111111111111');
+ 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 = '241345');
+ Controller.inventoryEntryNoESetId(list1);
- }
- }
+ list1.clear();
+ list1.add(Controller.barcode = '2413456');
+ Controller.inventoryEntryNoESetId(list1);
- //鏁翠綋鍒拌揣
- @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)'];
+ list1.clear();
+ list1.add(Controller.barcode = '24134567');
+ Controller.inventoryEntryNoESetId(list1);
- 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 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;
- }
+ 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,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 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;
+ 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 = 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 = '24134567890');
+ 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 = '241345678901');
+ Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '0112345678901231177890121215678901234');
+ 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 = '0112345678901231106789012105678901234');
+ Controller.inventoryEntryNoESetId(list1);
+ list1.clear();
+ list1.add(Controller.barcode = '0112345678901231106789012105625001234');
+ Controller.inventoryEntryNoESetId(list1);
+ System.Test.stopTest();
+ }
+ }
- //宸插埌璐т骇鍝�
- 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};
+ //鏁翠綋鍒拌揣
+ @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;
+ }
+ // 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;
- 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();
+ 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;
- System.assertEquals('OCM_01_001002', controller.ConsumableorderdetailsRecords[0].esd.Name);
- // System.assertEquals(2, controller.ConsumableorderdetailsRecordserror.size());
- System.Test.stopTest();
+ //鍒拌揣姝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 List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ 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)'];
+ 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();
- 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 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.assertEquals(
+ 'OCM_01_001002',
+ controller.ConsumableorderdetailsRecords[0].esd.Name
+ );
+ // System.assertEquals(2, 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,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 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 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;
+ //鍙戦敊璐� 鍏ュ簱
+ @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)'
+ ];
- //鍙戦敊搴� 宸插埌璐�
- 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;
+ 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;
+ }
- // 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;
+ // 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;
- // //鍒拌揣姝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 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;
+ // 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;
- // //鍑哄簱浜у搧
- // 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;
+ // //鍒拌揣姝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 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};
+ // //鍑哄簱浜у搧
+ // 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 = '01049531702003111115120017181000105ZK250BXSYS\n01049531702003111115120017181000105ZK250BXSYQ';
+ Controller.SearchPro();
+ Controller.ArriveGoodsConfim();
- 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();
+ // System.assertEquals(2, controller.ConsumableorderdetailsRecordserror.size());
+ System.Test.stopTest();
+ }
+ }
- // System.assertEquals(2, controller.ConsumableorderdetailsRecordserror.size());
- System.Test.stopTest();
+ //杩斿搧
+ @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)'
+ ];
+ 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
- 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)'];
+ // 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';
+ //杩斿搧璁㈠崟
+ 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;
- 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 account[]{myAccount1,myAccount2};
+ //璁㈠崟鏄庣粏
+ //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;
- 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_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';
- // 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 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};
- //璁㈠崟
- 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';
- //杩斿搧璁㈠崟
+ // 涓㈠け
+ 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';
- 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;
+ 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();
+ }
+ }
- //璁㈠崟鏄庣粏
- //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
+ static void makeRecordsVieweTest() {
+ Integer count = 1001;
+ List<ArriveGoodsController.ConsumableorderdetailsInfo> conList = new List<ArriveGoodsController.ConsumableorderdetailsInfo>();
+ for (Integer i = 0; i < 1001; i++) {
+ conList.add(new ArriveGoodsController.ConsumableorderdetailsInfo());
+ }
+ ArriveGoodsController arr = new ArriveGoodsController();
+ arr.makeRecordsView(conList);
+ ArriveGoodsController arr1 = new ArriveGoodsController('', '');
+ }
- //鍙戣揣鏄庣粏
- //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';
+ @isTest
+ static void compareToTest() {
+ ArriveGoodsController.ConsumableorderdetailsInfo c1 = new ArriveGoodsController.ConsumableorderdetailsInfo();
+ ArriveGoodsController.ConsumableorderdetailsInfo c2 = new ArriveGoodsController.ConsumableorderdetailsInfo();
+ c1.compareTo(c2);
+ }
- // 涓㈠け
- 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';
+ @isTest
+ static void searchProTest1() {
+ 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)'
+ ];
+ 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;
+ }
- 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 = '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();
+ 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;
+ 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 = 'Test01';
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+ Orderdet1.Cancellation_Date__c = null;
+ Orderdet1.TracingCode__c = 'BXJRF';
+ Orderdet1.SerialLotNo__c = '5ZK';
+ insert Orderdet1;
+ System.debug('Orderdet1:' + Orderdet1);
+ 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';
+ Orderdet1.Cancellation_Date__c = null;
+ Orderdet2.TracingCode__c = 'BXJRF';
+ Orderdet2.SerialLotNo__c = '5ZK';
+ insert Orderdet2;
-}
\ No newline at end of file
+ PageReference page = new PageReference('/apex/ArriveGoods?ArrType=Arr');
+ System.Test.setCurrentPage(page);
+ ArriveGoodsController Controller = new ArriveGoodsController();
+ System.Test.startTest();
+ Controller.init();
+ Controller.barcode = '01049531702003111115120017181000105ZK250BXJRF';
+ Controller.SearchPro();
+ Controller.ArriveGoodsConfim();
+ List<Consumable_order_details2__c> ins = [
+ SELECT Id, Name
+ FROM Consumable_order_details2__c
+ ];
+ System.Test.stopTest();
+ }
+ }
+}
diff --git a/force-app/main/default/classes/ArriveGoodsControllerTestV2.cls b/force-app/main/default/classes/ArriveGoodsControllerTestV2.cls
new file mode 100644
index 0000000..7bcb69c
--- /dev/null
+++ b/force-app/main/default/classes/ArriveGoodsControllerTestV2.cls
@@ -0,0 +1,234 @@
+@isTest
+public class ArriveGoodsControllerTestV2 {
+ @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 };
+
+ 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.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;
+
+ //璁㈠崟鏄庣粏
+ //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;
+
+ //鍙戣揣鏄庣粏
+ //鍒拌揣姝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 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 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 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 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';
+
+ insert new List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ Orderdet3,
+ Orderdet4,
+ Orderdet5,
+ Orderdet6,
+ Orderdets8
+ };
+
+ List<Consumable_orderdetails__c> cod1 = [
+ SELECT Id
+ FROM Consumable_orderdetails__c
+ WHERE Consumable_order__c = :Order1.Id
+ ];
+ System.assertEquals(1, cod1.size());
+
+ PageReference page = new PageReference(
+ '/apex/ArriveGoods?Esetid=' + Order1.Id
+ );
+
+ 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();
+
+ // System.assertEquals(3, controller.ConsumableorderdetailsRecordsdummy.size()); //tcm
+ Controller.ArriveGoodsConfim();
+ System.Test.stopTest();
+ }
+ }
+}
diff --git a/force-app/main/default/classes/ArriveGoodsControllerTestV2.cls-meta.xml b/force-app/main/default/classes/ArriveGoodsControllerTestV2.cls-meta.xml
new file mode 100644
index 0000000..133fce1
--- /dev/null
+++ b/force-app/main/default/classes/ArriveGoodsControllerTestV2.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>58.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/AssetHandler.cls b/force-app/main/default/classes/AssetHandler.cls
index 7d9e01b..18a09ec 100644
--- a/force-app/main/default/classes/AssetHandler.cls
+++ b/force-app/main/default/classes/AssetHandler.cls
@@ -1,81 +1,577 @@
public without sharing class AssetHandler extends Oly_TriggerHandler {
+ public static Map<String, List<Rental_Apply_Equipment_Set_Detail__c>> queueRaesdMap;
+ private Map<Id, Asset> newMap;
+ private Map<Id, Asset> oldMap;
+ private List<Asset> newList;
+ private List<Asset> oldList;
+ private static final Map<String, Schema.RecordTypeInfo> DEVELOPERNAMEMAP = Schema.SObjectType.Asset.getRecordTypeInfosByDeveloperName(); // 20230306 ljh add
+ @TestVisible
+ private static Set<String> testTargetDepts;
+ @TestVisible
+ private static Id Account_Asset_Id;
+ public static Boolean disabled = false;
- public static Map<String , List<Rental_Apply_Equipment_Set_Detail__c>> queueRaesdMap;
- private Map<Id, Asset> newMap;
- private Map<Id, Asset> oldMap;
- private List<Asset> newList;
- private List<Asset> oldList;
- @TestVisible private static Set<String> testTargetDepts;
- @TestVisible private static Id Account_Asset_Id;
- public static Boolean disabled = false;
+ public AssetHandler() {
+ this.newMap = (Map<Id, Asset>) Trigger.newMap;
+ this.oldMap = (Map<Id, Asset>) Trigger.oldMap;
+ this.newList = (List<Asset>) Trigger.new;
+ this.oldList = (List<Asset>) Trigger.old;
- public AssetHandler() {
- this.newMap = (Map<Id, Asset>) Trigger.newMap;
- this.oldMap = (Map<Id, Asset>) Trigger.oldMap;
- this.newList = (List<Asset>) Trigger.new;
- this.oldList = (List<Asset>) Trigger.old;
+ Integer i = 0;
+ }
+
+ protected override void beforeInsert() {
+ beforeSetValue();
+ //鍔ㄦ�佹洿鏂� Asset鐨� AccountId鐨� Logic
+ beforeSetAccountId();
+
+ //绗竴娆′笉鍔犲彉鏇寸殑鏃跺�欎笉鐭ラ亾绗竴娆℃槸澶氬皯
+ updateChangeQuantityReason();
+
+ workflowCode();
+ }
+ protected override void beforeUpdate() {
+ if (!disabled) {
+ beforeSetValue();
+ //鍔ㄦ�佹洿鏂� Asset鐨� AccountId鐨� Logic
+ beforeSetAccountId();
+
+ updateChangeQuantityReason();
+
+ // 20230309 gzw 浼樺寲 娉ㄩ噴浠g爜
+
+ // 铏氭嫙缁翠慨淇濅慨鍚堝悓淇濅慨寮�濮嬬粨鏉熸棩鏈熸洿鏂�
+ // updateMaintenance_Contract_Asset();
+
+ // 20230309 gzw 浼樺寲 娉ㄩ噴浠g爜
+
+ updateRentalCount();
+
+ workflowCode();
}
+ }
- protected override void beforeInsert() {
- beforeSetValue();
- //鍔ㄦ�佹洿鏂� Asset鐨� AccountId鐨� Logic
- beforeSetAccountId();
+ protected override void afterInsert() {
+ //鏈夋柊鐨凙sset鐨勬椂鍊� 鏆傚畾鍒嗛厤
+ queueRedistribution();
+ }
- //绗竴娆′笉鍔犲彉鏇寸殑鏃跺�欎笉鐭ラ亾绗竴娆℃槸澶氬皯
- updateChangeQuantityReason();
+ protected override void afterUpdate() {
+ if (!disabled) {
+ mainAssetUpdateed_OneToOneRecord();
+ // 宸茬粡鏀硅繘 Must_Input_ChangeQuantityReason 鐨� valida before鍙互瀹屾垚 ChangeQuantityReason__c = ''
+ ////鍏ュ姏瑕忓墖銇倛銇c仸before銈儶銈€仹銇嶃伨銇涖倱,
+ cleanChangeQuantityReason();
+ // 娓呯悊瀛楁銆屽緟搴熷純鏁帮紙涓㈠け/鐩樹簭锛変慨鏀圭悊鐢便��
+ cleanGiveupReturnReason();
+ //褰撲富浣撳弬鐓х殑Asset鐨凩ast鏂紑鐨勬椂鍊欓噸鏂板鎵炬殏瀹氬垎閰�
+ queueRedistribution();
+ // before 銇с伅鏁板紡闋呯洰銇宯ull銇牬鍚堛亴銇傘倞銇俱仚
+ formulaToTextCheck();
+ // check涓�瀵逛竴link琛�
+ checkOneToOneLink();
+ // 铏氭嫙缁翠慨淇濅慨鍚堝悓淇濅慨寮�濮嬬粨鏉熸棩鏈熸洿鏂�
+ updateMaintenance_Contract_Asset();
}
- protected override void beforeUpdate() {
- if(!disabled){
- beforeSetValue();
- //鍔ㄦ�佹洿鏂� Asset鐨� AccountId鐨� Logic
- beforeSetAccountId();
+ }
- updateChangeQuantityReason();
-
- // 铏氭嫙缁翠慨淇濅慨鍚堝悓淇濅慨寮�濮嬬粨鏉熸棩鏈熸洿鏂�
- updateMaintenance_Contract_Asset();
-
- updateRentalCount();
+ //20230309 sx 淇濇湁璁惧workflow浠g爜鍖� start
+ private void workflowCode() {
+ /*List<Id> accIds = new List<Id>();
+ List<Id> productIds = new List<Id>();
+ List<Id> hospitalIds = new List<Id>();
+ for(Asset nObj : newList) {
+ accIds.add(nObj.Account.Id);
+ productIds.add(nObj.Product2.Id);
+ hospitalIds.add(nObj.Hospital__c);
}
- }
+ //鏌ユ壘瀹㈡埛List
+ Map<Id, Account> accMap = new Map<Id, Account>([SELECT Id, Name, Management_Code__c from Account where Id in :accIds]);
+ Map<Id, Product2> productMap = new Map<Id, Product2>([SELECT Id, Name, RecordTypeId, RecordType.Name, Serial_Lot_No__c ,ProductCode from Product2 where Id in :productIds]);
+ Map<Id, Account> hosMap = new Map<Id, Account>([SELECT Id, Name, RecordType.Name from Account where id in :hospitalIds]);
- protected override void afterInsert() {
- //鏈夋柊鐨凙sset鐨勬椂鍊� 鏆傚畾鍒嗛厤
- queueRedistribution();
- }
-
- protected override void afterUpdate() {
- if(!disabled){
- mainAssetUpdateed_OneToOneRecord();
- // 宸茬粡鏀硅繘 Must_Input_ChangeQuantityReason 鐨� valida before鍙互瀹屾垚 ChangeQuantityReason__c = ''
- ////鍏ュ姏瑕忓墖銇倛銇c仸before銈儶銈€仹銇嶃伨銇涖倱,
- cleanChangeQuantityReason();
- // 娓呯悊瀛楁銆屽緟搴熷純鏁帮紙涓㈠け/鐩樹簭锛変慨鏀圭悊鐢便��
- cleanGiveupReturnReason();
- //褰撲富浣撳弬鐓х殑Asset鐨凩ast鏂紑鐨勬椂鍊欓噸鏂板鎵炬殏瀹氬垎閰�
- queueRedistribution();
- // before 銇с伅鏁板紡闋呯洰銇宯ull銇牬鍚堛亴銇傘倞銇俱仚
- formulaToTextCheck();
- // check涓�瀵逛竴link琛�
- checkOneToOneLink();
- // 铏氭嫙缁翠慨淇濅慨鍚堝悓淇濅慨寮�濮嬬粨鏉熸棩鏈熸洿鏂�
- updateMaintenance_Contract_Asset();
- }
- }
- // 鍊熷嚭鏄庣粏鏇存柊鍊熷嚭_鍒嗛厤_鏁�(Sys)鍜屽凡鍊熷嚭鏁�(Sys)
- private void updateRentalCount() {
- Set<Id> idSet = new Set<Id>();
- for(Id assId : this.newMap.keySet()) {
- if(this.newMap.get(assId).AssetManageConfirm__c &&
- this.newMap.get(assId).Account_Management_Code__c != System.Label.Account_Asset_FJZ ) {
- idSet.add(assId);
- this.newMap.get(assId).Out_of_wh_Sys__c = 0;
- this.newMap.get(assId).Rental_Count_Sys__c = 0;
+ Map<Id, Account> acc_assMap = new Map<Id, Account>();
+ Map<Id, Product2> pro_proMap = new Map<Id, Product2>();
+ Map<Id, Account> hos_assMap = new Map<Id, Account>();
+ for(Asset nObj : newList){
+ if(accMap.containsKey(nObj.Account.Id)) {
+ acc_assMap.put(nObj.Id, accMap.get(nObj.Account.Id));
}
+ if(productMap.containsKey(nObj.Product2.Id)) {
+ pro_proMap.put(nObj.Id, productMap.get(nObj.Product2.Id));
+ }
+ if(hosMap.containsKey(nObj.Hospital__c)) {
+ hos_assMap.put(nObj.Id, hosMap.get(nObj.Id));
+ }
+ }*/
+ Date today = Date.today();
+
+ for (Asset nObj : newList) {
+ //淇濇湁璁惧HPID鏂囨湰鍖�
+ nObj.Asset_Year_Txt__c = nObj.Asset_Year__c;
+ nObj.HP_ID_Text__c = nObj.HP_Id__c;
+ nObj.Gurantee_End_day1__c = nObj.Gurantee_End_day__c;
+
+ //瑕嗙洊璁惧鐨勫彲閫夊璞℃枃鏈寲
+ if (
+ Trigger.isInsert ||
+ (Trigger.isUpdate &&
+ nObj.Posting_Date__c != oldMap.get(nObj.Id).Posting_Date__c)
+ ) {
+ if (
+ String.isBlank(nObj.IF_Coverage_Target_Asset__c) ||
+ '0'.equals(nObj.IF_Coverage_Target_Asset__c)
+ ) {
+ nObj.IF_Coverage_Target_Asset__c =
+ nObj.IF_Coverage_Target_Asset_FF__c + '';
}
- if(!idSet.isEmpty()) {
- for (Rental_Apply_Equipment_Set_Detail__c raesd : [
+
+ if (
+ nObj.IF_Coverage_Target_Asset_FF__c == 3 &&
+ nObj.FY23_Asset_Age__c == null
+ ) {
+ nObj.FY23_Asset_Age__c = 0;
+ }
+ }
+
+ //甯傚満瀵瑰簲褰曞叆鏃堕棿鑷姩褰曞叆
+ if (
+ (Trigger.isInsert && nObj.Market_Product_Category__c != null) ||
+ (Trigger.isUpdate &&
+ nObj.Market_Product_Category__c !=
+ oldMap.get(nObj.Id).Market_Product_Category__c &&
+ nObj.Market_Product_Category__c != null)
+ ) {
+ nObj.Marketing_Input_Date__c = today;
+ }
+
+ /*//寰呮姤搴熷彉鏇翠负浣跨敤涓�
+ if(nObj.RecordType.Name == '澶囧搧'
+ && nObj.Manage_type__c == '涓綋绠$悊'
+ && nObj.Quantity > 0 && nObj.Status == '寰呮姤搴�'
+ && ( (nObj.Abandoned_RealThing__c == null && nObj.Abandoned_Inventory__c == null) || (nObj.Abandoned_RealThing__c + nObj.Abandoned_Inventory__c) == 0)
+ && acc_assMap.get(nObj.Id).Management_Code__c != System.Label.Account_Asset_FJZ) {
+ nObj.Status = '浣跨敤涓�';
+ nObj.Tobe_Discarded_Date__c = null;
+ }*/
+
+ /*//AssetMarkUpdate
+ if(Trigger.isUpdate && nObj.IF_Information_From__c == false && nObj.AssetMark__c == null) {
+ if(pro_proMap.containsKey(nObj.Id)){
+ if(pro_proMap.get(nObj.Id).RecordType.Name == '绔炲搧-涓绘満' ) {
+ nObj.AssetMark__c = '绔炲搧涓绘満';
+ }else if(pro_proMap.get(nObj.Id).RecordType.Name == '绔炲搧-鑰楁潗') {
+ nObj.AssetMark__c = '绔炲搧鑰楁潗';
+ }else if(pro_proMap.get(nObj.Id).Serial_Lot_No__c == 'S/N tracing') {
+ nObj.AssetMark__c = '涓绘満';
+ }
+ }
+ else {
+ nObj.AssetMark__c = '鑰楁潗';
+ }
+ }*/
+
+ /*//AssetName=ProductName
+ if(nObj.Name.equals('*') || (nObj.Product2.Id != null && nObj.Product2 != oldMap.get(nObj.Id).Product2)) {
+ nObj.Name = pro_proMap.get(nObj.Id).Name;
+ }*/
+
+ //AssetTextCopy
+ if (
+ Trigger.isInsert ||
+ (Trigger.isUpdate && nObj.Product2 != oldMap.get(nObj.Id).Product2)
+ ) {
+ nObj.BSSCategory_Text__c = nObj.BSSCategory__c;
+ nObj.Brand_Name_Text__c = nObj.Brand_Name__c;
+ nObj.Category2_Text__c = nObj.Category2__c;
+ nObj.Category3_Text__c = nObj.Category3__c;
+ nObj.Category4_Text__c = nObj.Category4__c;
+ nObj.Category5_Text__c = nObj.Category5__c;
+ }
+
+ //CIC瀹夎鐘舵�佺‘璁ゆ棩
+ if (
+ nObj.CIC_call_back_check__c && nObj.CIC_call_back_confirm_day__c == null
+ ) {
+ nObj.CIC_call_back_confirm_day__c = today;
+ }
+
+ //Equipment_Last_confirmed_day
+ if (
+ (Trigger.isInsert &&
+ (nObj.Status != null ||
+ nObj.Installation_Site__c != null ||
+ nObj.Final_Examination_Date__c != null ||
+ nObj.Hospital_Manage_Number__c != null)) ||
+ (Trigger.isUpdate &&
+ (nObj.Status != oldMap.get(nObj.Id).Status ||
+ nObj.Installation_Site__c != oldMap.get(nObj.Id).Installation_Site__c ||
+ nObj.Final_Examination_Date__c !=
+ oldMap.get(nObj.Id).Final_Examination_Date__c ||
+ nObj.Hospital_Manage_Number__c !=
+ oldMap.get(nObj.Id).Hospital_Manage_Number__c))
+ ) {
+ nObj.Equipment_Last_checking_day__c = today;
+ }
+
+ /*//Product_Code+Serial_No
+ if(Trigger.isUpdate && nObj.IsCompetitorProduct == false && nObj.Manage_type__c != '鏁伴噺绠$悊' && nObj.AssetMark__c != '鑰楁潗' && nObj.Loaner_accsessary__c != true && nObj.unknow_serial_NO_product__c != false) {
+ if(nObj.Product2.Id == null) {
+ nObj.Product_Serial_No__c = nObj.Id;
+ }else {
+ nObj.Product_Serial_No__c = pro_proMap.get(nObj.Id).ProductCode + ' ' + nObj.SerialNumber;
+ if(nObj.Delete_Flag__c){
+ nObj.Product_Serial_No__c += ':' + acc_assMap.get(nObj.Id).Management_Code__c;
+ }
+ }
+ }*/
+
+ //Product_Code+Serial_No Clear
+ if (
+ (Trigger.isInsert && nObj.IsCompetitorProduct) ||
+ (Trigger.isUpdate &&
+ nObj.IsCompetitorProduct &&
+ !oldMap.get(nObj.Id).IsCompetitorProduct)
+ ) {
+ nObj.Product_Serial_No__c = '';
+ }
+
+ /*//Product_Code+Serial_No+Salesdepartment
+ if(Trigger.isUpdate && nObj.IsCompetitorProduct == false && nObj.Manage_type__c == '鏁伴噺绠$悊' && nObj.AssetMark__c == '鑰楁潗' && nObj.Loaner_accsessary__c == true && nObj.unknow_serial_NO_product__c == false) {
+ if(nObj.Product2.Id == null) {
+ nObj.Product_Serial_No__c = nObj.Id;
+ }else {
+ nObj.Product_Serial_No__c = pro_proMap.get(nObj.Id).ProductCode + ' ' + nObj.SerialNumber + ':' + nObj.Salesdepartment__c.subString(0,nObj.Salesdepartment__c.indexOf(':'));
+ if(nObj.Delete_Flag__c){
+ nObj.Product_Serial_No__c += ':' + acc_assMap.get(nObj.Id).Management_Code__c;
+ }
+ }
+ }*/
+
+ /*//Product_Code+Serial_No UnkownSerial
+ if(Trigger.isUpdate && nObj.unknow_serial_NO_product__c == true) {
+ nObj.SerialNumber = nObj.serial_past__c;
+ if(nObj.Product2.Id == null) {
+ nObj.Product_Serial_No__c = nObj.Id;
+ }else {
+ nObj.Product_Serial_No__c = pro_proMap.get(nObj.Id).ProductCode + ':' + nObj.serial_past__c;
+ if(nObj.Delete_Flag__c){
+ nObj.Product_Serial_No__c += ':' + acc_assMap.get(nObj.Id).Management_Code__c;
+ }
+ }
+ }*/
+
+ //鏇存柊澶囧搧璧勪骇绠$悊璐熻矗鏈儴閫夐」
+ if (
+ (Trigger.isInsert && nObj.Internal_demo_incharge_demo__c != null) ||
+ (Trigger.isUpdate &&
+ nObj.Internal_demo_incharge_demo__c !=
+ oldMap.get(nObj.Id).Internal_demo_incharge_demo__c)
+ ) {
+ nObj.Internal_demo_incharge_demo_text__c = nObj.Internal_demo_incharge_demo__c;
+ }
+
+ /*//鑷姩鏇存柊璧勪骇鎵�灞�(鍖婚櫌璧勪骇)
+ if(Trigger.isUpdate && nObj.RecordType.Name == '鍖婚櫌淇濇湁璁惧' && hos_assMap.containskey(nObj.Id) && hos_assMap.get(nObj.Id).RecordType.Name == '鐥呴櫌' && acc_assMap.get(nObj.Id).Id == '00110000015Bx0h' ) {
+ nObj.Asset_Owner__c = '鍖婚櫌璧勪骇';
+ }*/
+
+ /*//鑷姩鏇存柊璧勪骇鎵�灞�(濂ユ灄宸存柉)
+ if(nObj.RecordType.Name == '鍖婚櫌淇濇湁璁惧' || (acc_assMap.containskey(nObj.Id) && acc_assMap.get(nObj.Id).Id == '00110000015Bx0h')) {
+ nObj.Asset_Owner__c = '濂ユ灄宸存柉';
+ }*/
+
+ /*//鑷姩鏇存柊璧勪骇鎵�灞�(缁忛攢鍟嗚祫浜�)
+ if(nObj.RecordType.Name == '鍖婚櫌淇濇湁璁惧' && (acc_assMap.containskey(nObj.Id) && hos_assMap.get(nObj.Id).RecordType.Name == '璨╁2搴�')) {
+ nObj.Asset_Owner__c = '缁忛攢鍟嗚祫浜�';
+ }*/
+
+ //鎵嬪姩鍒涘缓鐨勮�楁潗淇℃伅淇敼
+ if (
+ nObj.RecordTypeId == '01210000000kOPM' &&
+ nObj.Information_From__c == '鎵嬪姩杈撳叆' &&
+ nObj.AssetMark__c == '鑰楁潗'
+ ) {
+ nObj.Guarantee_period_for_products__c = nObj.Posting_Date__c;
+ nObj.InstallDate = nObj.Posting_Date__c;
+ }
+
+ //鍑鸿揣鏃ヨ嚜鍔ㄨ祴鍊�
+ if (Trigger.isInsert && nObj.Information_From__c == '鎵嬪姩杈撳叆') {
+ nObj.Posting_Date__c = Date.newInstance(1900, 1, 1);
+ }
+
+ //鏂伴�昏緫淇濅慨鏈熼檺瀵瑰簲
+ if (nObj.New_logic_data__c) {
+ nObj.Guarantee_period_for_products__c = nObj.Guarantee_period_formula__c;
+ }
+
+ //鎴愭湰涓績鏇存柊缂栫爜Update
+ if (
+ (Trigger.isInsert && nObj.Internal_cost_center_cd__c != null) ||
+ (Trigger.isUpdate &&
+ nObj.Internal_cost_center_cd__c !=
+ oldMap.get(nObj.Id).Internal_cost_center_cd__c)
+ ) {
+ nObj.Internal_demo_incharge_demo_text__c = nObj.Internal_cost_center_formula__c;
+ }
+
+ //鎴愭湰涓績鏇存柊閫夐」Update
+ if (
+ (Trigger.isInsert && nObj.Internal_cost_center__c != null) ||
+ (Trigger.isUpdate &&
+ nObj.Internal_cost_center__c !=
+ oldMap.get(nObj.Id).Internal_cost_center__c)
+ ) {
+ nObj.Internal_cost_center_text__c = nObj.Internal_cost_center__c;
+ }
+
+ //寰呮姤搴熸棩鐧诲綍
+ if (
+ Trigger.isUpdate &&
+ nObj.Fixture_Status__c != oldMap.get(nObj.Id).Fixture_Status__c &&
+ nObj.Fixture_Status__c != '搴熷純' &&
+ (nObj.Abandoned_RealThing__c > 0 ||
+ nObj.Abandoned_Inventory__c > 0) &&
+ nObj.Manage_type__c == '涓綋绠$悊'
+ ) {
+ nObj.Status = '寰呮姤搴�';
+ nObj.Tobe_Discarded_Date__c = today;
+ }
+
+ //閫�璐ц浆澶囧搧DEL缃瓼ALSE
+ if (
+ Trigger.isUpdate &&
+ ((nObj.RecordType != oldMap.get(nObj.Id).RecordType &&
+ nObj.RecordTypeId == '01210000000kOPR') ||
+ (nObj.AccountId != oldMap.get(nObj.Id).AccountId &&
+ nObj.AccountId == '0011000000VAiwz')) &&
+ nObj.Delete_Flag__c
+ ) {
+ nObj.Delete_Flag__c = false;
+ }
+
+ //杩芥函璁惧鑰楁潗Mark鏇存柊
+ if (
+ '杩芥函绯荤粺'.equals(nObj.Information_From__c) &&
+ String.isBlank(nObj.AssetMark__c)
+ ) {
+ nObj.AssetMark__c = '鑰楁潗';
+ }
+
+ //绱嶅叆鍟嗗搧鐘舵厠澶夋洿锛堜娇鐢ㄤ腑锛�
+ if (
+ (Trigger.isInsert && nObj.Status == '浣跨敤涓�') ||
+ (Trigger.isUpdate &&
+ nObj.Status != oldMap.get(nObj.Id).Status &&
+ nObj.Status == '浣跨敤涓�')
+ ) {
+ nObj.Status_Busy_Date__c = today;
+ }
+
+ //绱嶅叆鍟嗗搧鐘舵厠澶夋洿锛堝粌妫勶級
+ if (
+ (Trigger.isInsert && nObj.Status == '寤冩') ||
+ (Trigger.isUpdate &&
+ nObj.Status != oldMap.get(nObj.Id).Status &&
+ nObj.Status == '寤冩')
+ ) {
+ nObj.Discarded_Date__c = today;
+ nObj.Quantity = 0;
+ nObj.Abandoned_Inventory__c = null;
+ nObj.Abandoned_RealThing__c = null;
+ nObj.ChangeQuantityReason__c = '搴熷純';
+ }
+
+ //绱嶅叆鍟嗗搧鐘舵厠澶夋洿锛堜笉鏄庯級
+ if (
+ (Trigger.isInsert && nObj.Status == '涓嶆槑') ||
+ (Trigger.isUpdate &&
+ nObj.Status != oldMap.get(nObj.Id).Status &&
+ nObj.Status == '涓嶆槑')
+ ) {
+ nObj.Indistinctness_Date__c = today;
+ }
+
+ //绱嶅叆鍟嗗搧鐘舵厠澶夋洿锛堟湭浣跨敤锛�
+ if (
+ (Trigger.isInsert && nObj.Status == '鏈娇鐢�') ||
+ (Trigger.isUpdate &&
+ nObj.Status != oldMap.get(nObj.Id).Status &&
+ nObj.Status == '鏈娇鐢�')
+ ) {
+ nObj.Unused_Date__c = today;
+ }
+
+ /*//绱嶅搧纰鸿獚鏇搞伄瑷虹檪绉戙偝銉笺儔_銈汇儍銉�
+ if(!(nObj.Product2.Id != null && nObj.IsCompetitorProduct == false && nObj.InstallDate != null) && nObj.Install_Account_Code__c == null) {
+ nObj.Install_Account_Code__c = acc_assMap.get(nObj.Id).Management_Code__c;
+ nObj.Install_Account_Name__c = acc_assMap.get(nObj.Id).Name;
+ nObj.Install_Hospital_Name__c = hos_assMap.get(nObj.Id).Name;
+ nObj.Install_Hospital_code__c = hos_assMap.get(nObj.Id).Management_Code__c;
+ }*/
+
+ //鐥呴櫌绠$悊鐣彿澶夋洿鏃�
+ if (
+ (Trigger.isInsert && nObj.Hospital_Manage_Number__c != null) ||
+ (Trigger.isUpdate &&
+ nObj.Hospital_Manage_Number__c !=
+ oldMap.get(nObj.Id).Hospital_Manage_Number__c)
+ ) {
+ nObj.Hospital_Manage_Number_Change_Date__c = today;
+ }
+
+ //鏇存柊-2娆″墠鐐规鏃�
+ if (
+ Trigger.isUpdate &&
+ nObj.Final_Examination_Date__c !=
+ oldMap.get(nObj.Id).Final_Examination_Date__c
+ ) {
+ nObj.X2_second_past_inspection__c = oldMap.get(nObj.Id)
+ .Final_Examination_Date__c;
+ }
+
+ // 鏂囨湰鍖� 澶氬勾淇濅慨鏈熻嚦
+ nObj.Extend_Gurantee_DateTo_Text__c = nObj.Extend_Gurantee_DateTo__c;
+
+ // 淇濅慨澶╂暟宸ヤ綔娴�
+ if (
+ Trigger.isInsert ||
+ (Trigger.isUpdate &&
+ (nObj.Guarantee_period_for_products__c !=
+ oldMap.get(nObj.Id).Guarantee_period_for_products__c ||
+ nObj.InstallDate__c != oldMap.get(nObj.Id).InstallDate__c ||
+ nObj.ChangeWarrantyStartDate__c !=
+ oldMap.get(nObj.Id).ChangeWarrantyStartDate__c))
+ ) {
+ nObj.GuaranteePeriod__c = nObj.guarantee_period__c;
+ }
+
+ // 鏈夊畨瑁呮棩锛屾洿鏂扮姸鎬佸埌锛讳娇鐢ㄤ腑锛�
+ if (
+ (Trigger.isInsert && nObj.InstallDate != null) ||
+ (Trigger.isUpdate &&
+ nObj.InstallDate != null &&
+ nObj.InstallDate != oldMap.get(nObj.Id).InstallDate)
+ ) {
+ nObj.Status_Busy_Date__c = today;
+ nObj.Status = '浣跨敤涓�';
+ }
+
+ // 澶囧搧鍐嶉��璐ц浆DEL缃甌RUE
+ if (
+ nObj.AccountId == '00110000015Bx0h' &&
+ nObj.RecordTypeId == '01210000000kOPM' &&
+ !nObj.Delete_Flag__c
+ ) {
+ nObj.Delete_Flag__c = true;
+ }
+
+ // 璁惧畾澶囧搧鎵�灞炲叕鍙革紙涓婃捣锛塅romVBA
+ if (
+ (Trigger.isInsert && nObj.CompanyCodeOfEquipment_txt__c == '5112') ||
+ (Trigger.isUpdate &&
+ nObj.CompanyCodeOfEquipment_txt__c !=
+ oldMap.get(nObj.Id).CompanyCodeOfEquipment_txt__c &&
+ nObj.CompanyCodeOfEquipment_txt__c == '5112')
+ ) {
+ nObj.CompanyOfEquipment__c = '涓婃捣';
+ }
+
+ // 璁惧畾澶囧搧鎵�灞炲叕鍙革紙娌堥槼锛塅romVBA
+ if (
+ (Trigger.isInsert && nObj.CompanyCodeOfEquipment_txt__c == '5114') ||
+ (Trigger.isUpdate &&
+ nObj.CompanyCodeOfEquipment_txt__c !=
+ oldMap.get(nObj.Id).CompanyCodeOfEquipment_txt__c &&
+ nObj.CompanyCodeOfEquipment_txt__c == '5114')
+ ) {
+ nObj.CompanyOfEquipment__c = '娌堥槼';
+ }
+
+ // 璁惧畾澶囧搧鎵�灞炲叕鍙革紙鍖椾含锛塅romVBA
+ if (
+ (Trigger.isInsert && nObj.CompanyCodeOfEquipment_txt__c == '5111') ||
+ (Trigger.isUpdate &&
+ nObj.CompanyCodeOfEquipment_txt__c !=
+ oldMap.get(nObj.Id).CompanyCodeOfEquipment_txt__c &&
+ nObj.CompanyCodeOfEquipment_txt__c == '5111')
+ ) {
+ nObj.CompanyOfEquipment__c = '鍖椾含';
+ }
+
+ // 璁惧畾澶囧搧鎵�灞炲叕鍙革紙骞垮窞锛塅romVBA
+ if (
+ (Trigger.isInsert && nObj.CompanyCodeOfEquipment_txt__c == '5113') ||
+ (Trigger.isUpdate &&
+ nObj.CompanyCodeOfEquipment_txt__c !=
+ oldMap.get(nObj.Id).CompanyCodeOfEquipment_txt__c &&
+ nObj.CompanyCodeOfEquipment_txt__c == '5113')
+ ) {
+ nObj.CompanyOfEquipment__c = '骞垮窞';
+ }
+ }
+ }
+ //20230309 sx 淇濇湁璁惧workflow浠g爜鍖� end
+
+ // 鍊熷嚭鏄庣粏鏇存柊鍊熷嚭_鍒嗛厤_鏁�(Sys)鍜屽凡鍊熷嚭鏁�(Sys)
+ private void updateRentalCount() {
+ Set<Id> idSet = new Set<Id>();
+ for (Id assId : this.newMap.keySet()) {
+ if (
+ this.newMap.get(assId).AssetManageConfirm__c &&
+ this.newMap.get(assId).Account_Management_Code__c !=
+ System.Label.Account_Asset_FJZ
+ ) {
+ idSet.add(assId);
+ this.newMap.get(assId).Out_of_wh_Sys__c = 0;
+ this.newMap.get(assId).Rental_Count_Sys__c = 0;
+ }
+ }
+ if (!idSet.isEmpty()) {
+ // 澶囧搧鎬ц兘浼樺寲鏀逛慨 20230312 by lc Start
+ List<AggregateResult> raesdTempList2 = [
+ SELECT COUNT(Id) num, Asset__c
+ FROM Rental_Apply_Equipment_Set_Detail__c
+ //澶囧搧鍙戣揣鎶ラ敊瀵瑰簲 20230413 by lc Start
+ //WHERE Detail_Finish__c = false
+ WHERE
+ Detail_Not_Finish_Text__c = TRUE
+ //澶囧搧鍙戣揣鎶ラ敊瀵瑰簲 20230413 by lc End
+ AND Asset__c IN :idSet
+ AND Shippment_loaner_time2__c != NULL
+ GROUP BY Asset__c
+ ];
+ if (raesdTempList2 != null && raesdTempList2.size() > 0) {
+ for (AggregateResult ar : raesdTempList2) {
+ String assetId = String.valueOf(ar.get('Asset__c'));
+ Integer tempNum = Integer.valueOf(ar.get('num'));
+ this.newMap.get(assetId).Rental_Count_Sys__c += tempNum;
+ }
+ }
+
+ List<AggregateResult> raesdTempList1 = [
+ SELECT COUNT(Id) num, Asset__c
+ FROM Rental_Apply_Equipment_Set_Detail__c
+ //澶囧搧鍙戣揣鎶ラ敊瀵瑰簲 20230413 by lc Start
+ //WHERE Detail_Finish__c = false
+ WHERE
+ Detail_Not_Finish_Text__c = TRUE
+ //澶囧搧鍙戣揣鎶ラ敊瀵瑰簲 20230413 by lc End
+ AND Asset__c IN :idSet
+ GROUP BY Asset__c
+ ];
+ if (raesdTempList1 != null && raesdTempList1.size() > 0) {
+ for (AggregateResult ar : raesdTempList1) {
+ String assetId = String.valueOf(ar.get('Asset__c'));
+ Integer tempNum = Integer.valueOf(ar.get('num'));
+ this.newMap.get(assetId).Out_of_wh_Sys__c += tempNum;
+ idSet.remove(assetId);
+ }
+ }
+
+ /*for (Rental_Apply_Equipment_Set_Detail__c raesd : [
SELECT Id, Shippment_loaner_time2__c, Asset__c
FROM Rental_Apply_Equipment_Set_Detail__c
WHERE Detail_Finish__c = false
@@ -86,747 +582,900 @@
this.newMap.get(raesd.Asset__c).Rental_Count_Sys__c += 1;
}
idSet.remove(raesd.Asset__c);
- }
- if(!idSet.isEmpty()) {
- // 娌℃湁瀛楁鍙互瀹屽叏鍑嗙‘鍦板尯鍒嗗鍝佽澶囦笌鑰楁潗璁惧锛屽彧濂芥妸澶囧搧閲屾病鍑虹幇杩囩殑璁惧褰撴垚鑰楁潗鏉ユ煡
- for (Consum_Apply_Equipment_Set_Detail__c caesd : [
- SELECT Id, Shippment_loaner_time2__c, Asset__c
- FROM Consum_Apply_Equipment_Set_Detail__c
- WHERE Detail_Finish__c = false
- AND Asset__c IN :idSet
- ]) {
- this.newMap.get(caesd.Asset__c).Out_of_wh_Sys__c += 1;
- if(caesd.Shippment_loaner_time2__c != null) {
- this.newMap.get(caesd.Asset__c).Rental_Count_Sys__c += 1;
- }
- }
- }
+ }*/
+ // 澶囧搧鎬ц兘浼樺寲鏀逛慨 20230312 by lc End
+ if (!idSet.isEmpty()) {
+ // 娌℃湁瀛楁鍙互瀹屽叏鍑嗙‘鍦板尯鍒嗗鍝佽澶囦笌鑰楁潗璁惧锛屽彧濂芥妸澶囧搧閲屾病鍑虹幇杩囩殑璁惧褰撴垚鑰楁潗鏉ユ煡
+ for (Consum_Apply_Equipment_Set_Detail__c caesd : [
+ SELECT Id, Shippment_loaner_time2__c, Asset__c
+ FROM Consum_Apply_Equipment_Set_Detail__c
+ WHERE Detail_Finish__c = FALSE AND Asset__c IN :idSet
+ ]) {
+ this.newMap.get(caesd.Asset__c).Out_of_wh_Sys__c += 1;
+ if (caesd.Shippment_loaner_time2__c != null) {
+ this.newMap.get(caesd.Asset__c).Rental_Count_Sys__c += 1;
+ }
}
+ }
}
- //澶氬勾淇濅慨 start
- private void updateMaintenance_Contract_Asset(){
- StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
- Set<id> AssetIDSet = new Set<id>();
- for(Asset tempAsset : newList){
- if(String.isNotBlank(tempAsset.warrantyType__c)){
- AssetIDSet.add(tempAsset.id);
- }
- }
- if(AssetIDSet.size() > 0 ){
- list<Maintenance_Contract_Asset__c> MCAList =
- [select id,startDateGurantee__c,
- startDateGurantee_Text__c,endDateGurantee__c,
- endDateGurantee_Text__c,Return_Flag__c,ChangeAcc_flag__c,
- Maintenance_Price_Amount__c,Maintenance_Price_Amount_text__c,
- GuaranteePrice_Amount__c,GuaranteePrice_Amount_text__c
- from Maintenance_Contract_Asset__c
- where Asset__c in : AssetIDSet
- and Maintenance_Contract__r.RecordType.DeveloperName = 'VM_Contract'
- ];
- if(MCAList.size() > 0){
- list<Maintenance_Contract_Asset__c> UpdateMcaList =
- new list<Maintenance_Contract_Asset__c> ();
- for(Maintenance_Contract_Asset__c tempMCA : MCAList ){
- if(tempMCA.startDateGurantee__c != tempMCA.startDateGurantee_Text__c
- || tempMCA.endDateGurantee__c != tempMCA.endDateGurantee_Text__c
- || tempMCA.Maintenance_Price_Amount__c != tempMCA.Maintenance_Price_Amount_Text__c
- || tempMCA.GuaranteePrice_Amount__c != tempMCA.GuaranteePrice_Amount_text__c){
- UpdateMcaList.add(tempMCA);
- }
- }
- Oly_TriggerHandler.bypass('SetContractEstimatePriceHandler');
- update UpdateMcaList;
- Oly_TriggerHandler.clearBypass('SetContractEstimatePriceHandler');
- }
- }
+ }
+ //澶氬勾淇濅慨 start
+ private void updateMaintenance_Contract_Asset() {
+ StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true;
+ Set<id> AssetIDSet = new Set<id>();
+ for (Asset tempAsset : newList) {
+ // 20230306 ljh update start
+ Id Shipment = DEVELOPERNAMEMAP.get('Shipment').getRecordTypeId();
+ // if(String.isNotBlank(tempAsset.warrantyType__c)){
+ if (
+ String.isNotBlank(tempAsset.warrantyType__c) &&
+ Shipment != tempAsset.RecordTypeId
+ ) {
+ // 20230306 ljh update end
+ AssetIDSet.add(tempAsset.id);
+ }
}
- //澶氬勾淇濅慨 end
-
- private void beforeSetValue() {
- for (Asset nObj : newList) {
- // 鏈夌嚎涓嬫暟鎹�, 鎵�浠ヤ笉闇�瑕佷笅闈㈢殑logic
- //if (nObj.Quantity == null) {
- // nObj.Quantity = 1;
- //}
- if (Trigger.isInsert) {
- nObj.Last_Reserve_RAES_Detail__c = null;
- nObj.Last_Reserve_TAES_Detail__c = null;
- nObj.Pre_Reserve_RAES_Detail__c = null;
- nObj.Pre_Reserve_TAES_Detail__c = null;
- nObj.Fixture_OneToOne_Link__c = null;
- }
-
- if (Trigger.isUpdate) {
- Asset oObj = oldMap.get(nObj.Id);
- if (oObj.Last_Reserve_RAES_Detail__c != null && nObj.Last_Reserve_RAES_Detail__c == null
- && oObj.Last_Reserve_RAES_Detail_Flag__c == true) {
- nObj.Pre_Reserve_RAES_Detail__c = oObj.Last_Reserve_RAES_Detail__c;
- }
- if (oObj.Last_Reserve_TAES_Detail__c != null && nObj.Last_Reserve_TAES_Detail__c == null
- // TODO 鐢变簬__r瓒�20锛屽瓧娈靛缓涓嶅嚭鏉�
- // && oObj.Last_Reserve_TAES_Detail_Flag__c == true
- ) {
- nObj.Pre_Reserve_TAES_Detail__c = oObj.Last_Reserve_TAES_Detail__c;
- }
- }
-
- // 蹇呫仛鏈�寰屻仹缃亸
- nObj.Fixture_Status2_text__c = nObj.Fixture_Status2__c;
- nObj.Fixture_Status3_text__c = nObj.Fixture_Status3__c;
- nObj.BTreeIndexKey__c = nObj.Asset_Owner__c
- + ':' + nObj.Asset_loaner_category__c
- + ':' + String.valueOf(nobj.Freeze_sign_Abandoned_Flag__c)
- + ':' + String.valueOf(nObj.Delete_Flag__c)
- + ':' + String.valueOf(nObj.AssetManageConfirm__c);
-
- if (nObj.Status == FixtureUtil.assetStatusMap.get(FixtureUtil.AssetStatus.Dai_Fei_Qi.ordinal())) {
- nObj.Freeze_sign__c = false;
- }
- // gzw CHAN-CCR6MW 銆愬鎵樸�戙�愪繚鏈夎澶囥�戜繚鏈夎澶囧彂璐ф棩閫昏緫 start
- if(Trigger.isInsert && nObj.Posting_Date__c == null){
- nObj.Posting_Date__c = Date.newInstance(1900, 1, 1);
- }
- // gzw CHAN-CCR6MW 銆愬鎵樸�戙�愪繚鏈夎澶囥�戜繚鏈夎澶囧彂璐ф棩閫昏緫 end
+ if (AssetIDSet.size() > 0) {
+ list<Maintenance_Contract_Asset__c> MCAList = [
+ SELECT
+ id,
+ startDateGurantee__c,
+ startDateGurantee_Text__c,
+ endDateGurantee__c,
+ endDateGurantee_Text__c,
+ Return_Flag__c,
+ ChangeAcc_flag__c,
+ Maintenance_Price_Amount__c,
+ Maintenance_Price_Amount_text__c,
+ GuaranteePrice_Amount__c,
+ GuaranteePrice_Amount_text__c
+ FROM Maintenance_Contract_Asset__c
+ WHERE
+ Asset__c IN :AssetIDSet
+ AND Maintenance_Contract__r.RecordType.DeveloperName = 'VM_Contract'
+ ];
+ if (MCAList.size() > 0) {
+ list<Maintenance_Contract_Asset__c> UpdateMcaList = new List<Maintenance_Contract_Asset__c>();
+ for (Maintenance_Contract_Asset__c tempMCA : MCAList) {
+ if (
+ tempMCA.startDateGurantee__c != tempMCA.startDateGurantee_Text__c ||
+ tempMCA.endDateGurantee__c != tempMCA.endDateGurantee_Text__c ||
+ tempMCA.Maintenance_Price_Amount__c !=
+ tempMCA.Maintenance_Price_Amount_Text__c ||
+ tempMCA.GuaranteePrice_Amount__c !=
+ tempMCA.GuaranteePrice_Amount_text__c
+ ) {
+ UpdateMcaList.add(tempMCA);
+ }
}
+ Oly_TriggerHandler.bypass('SetContractEstimatePriceHandler');
+ update UpdateMcaList;
+ Oly_TriggerHandler.clearBypass('SetContractEstimatePriceHandler');
+ }
}
+ }
+ //澶氬勾淇濅慨 end
- // 銇嬨仾銈夈仛 before
- private void updateChangeQuantityReason() {
- for (Asset nObj : newList) {
- Asset oObj;
- String oQuantity = '';
- String oAbandoned_Inventory = '';
- if (Trigger.isUpdate) {
- oObj = oldMap.get(nObj.Id);
- oQuantity = oObj.Quantity == null ? '' : String.valueOf(oObj.Quantity);
- oAbandoned_Inventory = oObj.Abandoned_Inventory__c == null ? '' : String.valueOf(oObj.Abandoned_Inventory__c);
- }
- String nQuantity = nObj.Quantity == null ? '' : String.valueOf(nObj.Quantity);
- String nAbandoned_Inventory = nObj.Abandoned_Inventory__c == null ? '' : String.valueOf(nObj.Abandoned_Inventory__c);
- if ((oQuantity != nQuantity && String.isNotBlank(nObj.ChangeQuantityReason__c)) || Trigger.isInsert) {
- String rs = nObj.ChangeQuantityReason__c;
- nObj.ChangeQuantityHistory__c = String.format(System.Label.ChangeQuantityHistory,
- new String[]{oQuantity, nQuantity, rs});
- // before閲岄潰鍏ョ珛瑙勫垯杩囦笉浜嗘敼鍒�
- // 宸茬粡鏀硅繘 Must_Input_ChangeQuantityReason 鐨� valida before鍙互瀹屾垚 ChangeQuantityReason__c = ''
- // nObj.ChangeQuantityReason__c = '';
- }
+ private void beforeSetValue() {
+ for (Asset nObj : newList) {
+ // 鏈夌嚎涓嬫暟鎹�, 鎵�浠ヤ笉闇�瑕佷笅闈㈢殑logic
+ //if (nObj.Quantity == null) {
+ // nObj.Quantity = 1;
+ //}
+ if (Trigger.isInsert) {
+ nObj.Last_Reserve_RAES_Detail__c = null;
+ nObj.Last_Reserve_TAES_Detail__c = null;
+ nObj.Pre_Reserve_RAES_Detail__c = null;
+ nObj.Pre_Reserve_TAES_Detail__c = null;
+ nObj.Fixture_OneToOne_Link__c = null;
+ }
- if (oAbandoned_Inventory != nAbandoned_Inventory || Trigger.isInsert) {
- String rs = nObj.Giveup_Return__c;
- nObj.ChangeAbandoned_InventoryHistory__c = String.format(System.Label.ChangeAbandoned_InventoryHistory,
- new String[]{oAbandoned_Inventory, nAbandoned_Inventory, rs});
- }
+ if (Trigger.isUpdate) {
+ Asset oObj = oldMap.get(nObj.Id);
+ if (
+ oObj.Last_Reserve_RAES_Detail__c != null &&
+ nObj.Last_Reserve_RAES_Detail__c == null &&
+ oObj.Last_Reserve_RAES_Detail_Flag__c == true
+ ) {
+ nObj.Pre_Reserve_RAES_Detail__c = oObj.Last_Reserve_RAES_Detail__c;
}
+ if (
+ oObj.Last_Reserve_TAES_Detail__c != null &&
+ nObj.Last_Reserve_TAES_Detail__c == null
+ ) {
+ // TODO 鐢变簬__r瓒�20锛屽瓧娈靛缓涓嶅嚭鏉�
+ // && oObj.Last_Reserve_TAES_Detail_Flag__c == true
+ nObj.Pre_Reserve_TAES_Detail__c = oObj.Last_Reserve_TAES_Detail__c;
+ }
+ }
+
+ // 蹇呫仛鏈�寰屻仹缃亸
+ nObj.Fixture_Status2_text__c = nObj.Fixture_Status2__c;
+ nObj.Fixture_Status3_text__c = nObj.Fixture_Status3__c;
+ nObj.BTreeIndexKey__c =
+ nObj.Asset_Owner__c +
+ ':' +
+ nObj.Asset_loaner_category__c +
+ ':' +
+ String.valueOf(nobj.Freeze_sign_Abandoned_Flag__c) +
+ ':' +
+ String.valueOf(nObj.Delete_Flag__c) +
+ ':' +
+ String.valueOf(nObj.AssetManageConfirm__c);
+
+ if (
+ nObj.Status ==
+ FixtureUtil.assetStatusMap.get(
+ FixtureUtil.AssetStatus.Dai_Fei_Qi.ordinal()
+ )
+ ) {
+ nObj.Freeze_sign__c = false;
+ }
+ // gzw CHAN-CCR6MW 銆愬鎵樸�戙�愪繚鏈夎澶囥�戜繚鏈夎澶囧彂璐ф棩閫昏緫 start
+ if (Trigger.isInsert && nObj.Posting_Date__c == null) {
+ nObj.Posting_Date__c = Date.newInstance(1900, 1, 1);
+ }
+ // gzw CHAN-CCR6MW 銆愬鎵樸�戙�愪繚鏈夎澶囥�戜繚鏈夎澶囧彂璐ф棩閫昏緫 end
}
+ }
- //// 銇嬨仾銈夈仛 afterUpdate
- private void cleanChangeQuantityReason() {
- // TODO 鏇存柊鑷繁table 鍘熷垯闇�瑕丼tatic鐨凜lass鍙橀噺(鍥犱负浼氭湁澶嶆暟鐨凪ethod鍘绘洿鏂拌嚜宸辩殑)
- List<Asset> assList = new List<Asset>();
- for (Asset nObj : newList) {
- if (String.isBlank(nObj.ChangeQuantityReason__c) == false) {
- assList.add(new Asset(Id = nObj.Id,
- ChangeQuantityReason__c = ''));
- }
- }
- if (!assList.isEmpty()) {
- update assList;
- }
+ // 銇嬨仾銈夈仛 before
+ private void updateChangeQuantityReason() {
+ for (Asset nObj : newList) {
+ Asset oObj;
+ String oQuantity = '';
+ String oAbandoned_Inventory = '';
+ if (Trigger.isUpdate) {
+ oObj = oldMap.get(nObj.Id);
+ oQuantity = oObj.Quantity == null ? '' : String.valueOf(oObj.Quantity);
+ oAbandoned_Inventory = oObj.Abandoned_Inventory__c == null
+ ? ''
+ : String.valueOf(oObj.Abandoned_Inventory__c);
+ }
+ String nQuantity = nObj.Quantity == null
+ ? ''
+ : String.valueOf(nObj.Quantity);
+ String nAbandoned_Inventory = nObj.Abandoned_Inventory__c == null
+ ? ''
+ : String.valueOf(nObj.Abandoned_Inventory__c);
+ if (
+ (oQuantity != nQuantity &&
+ String.isNotBlank(nObj.ChangeQuantityReason__c)) || Trigger.isInsert
+ ) {
+ String rs = nObj.ChangeQuantityReason__c;
+ nObj.ChangeQuantityHistory__c = String.format(
+ System.Label.ChangeQuantityHistory,
+ new List<String>{ oQuantity, nQuantity, rs }
+ );
+ // before閲岄潰鍏ョ珛瑙勫垯杩囦笉浜嗘敼鍒�
+ // 宸茬粡鏀硅繘 Must_Input_ChangeQuantityReason 鐨� valida before鍙互瀹屾垚 ChangeQuantityReason__c = ''
+ // nObj.ChangeQuantityReason__c = '';
+ }
+
+ if (oAbandoned_Inventory != nAbandoned_Inventory || Trigger.isInsert) {
+ String rs = nObj.Giveup_Return__c;
+ nObj.ChangeAbandoned_InventoryHistory__c = String.format(
+ System.Label.ChangeAbandoned_InventoryHistory,
+ new List<String>{ oAbandoned_Inventory, nAbandoned_Inventory, rs }
+ );
+ }
}
+ }
- // afterUpdate
- // 娓呯悊瀛楁銆屽緟搴熷純鏁帮紙涓㈠け/鐩樹簭锛変慨鏀圭悊鐢便��
- private void cleanGiveupReturnReason() {
- List<Asset> assList = new List<Asset>();
- for (Asset nObj : newList) {
- if (String.isBlank(nObj.Giveup_Return__c) == false) {
- assList.add(new Asset(
- Id = nObj.Id,
- Giveup_Return__c = ''));
- }
- }
- if (!assList.isEmpty()) {
- update assList;
- }
+ //// 銇嬨仾銈夈仛 afterUpdate
+ private void cleanChangeQuantityReason() {
+ // TODO 鏇存柊鑷繁table 鍘熷垯闇�瑕丼tatic鐨凜lass鍙橀噺(鍥犱负浼氭湁澶嶆暟鐨凪ethod鍘绘洿鏂拌嚜宸辩殑)
+ List<Asset> assList = new List<Asset>();
+ for (Asset nObj : newList) {
+ if (String.isBlank(nObj.ChangeQuantityReason__c) == false) {
+ assList.add(new Asset(Id = nObj.Id, ChangeQuantityReason__c = ''));
+ }
}
-
- // 銇嬨仾銈夈仛 after, oObj.Id 銇� nObj.Id 銈掍娇銇嗐仧銈�
- // Last_Reserve_RAES_Detail__c (涓綋绠$悊) 銇甽ink 澶夈倧銇c仧鍫村悎銆�
- // Fixture_OneToOne_Link__c 銈堛倞 Asset 銇銇夸笂銇掋仐銇︺亜銈嬫暟瀛椼倐閫e嫊銇仾銈嬨�丗ixture_OneToOne_Link__c 銈掔┖鏇存柊
- // 鏇存柊闋呯洰Fixture_OneToOne_Link__c.In_wh_Fu_Shu_Pin_You_Xiao_Ku_Cun__c = Fixture_OneToOne_Link__c.In_wh_Fu_Shu_Pin_You_Xiao_Ku_Cun_F__c
- private void mainAssetUpdateed_OneToOneRecord() {
- Set<Id> aSetIdSet = new Set<Id>();
- System.debug(LoggingLevel.INFO, '*** mainAssetUpdateed_OneToOneRecord: ');
- for (Integer i = 0; i < newList.size(); i++) {
- Asset nObj = newList[i];
- Asset oObj = oldList[i];
- if (oObj.Last_Reserve_RAES_Detail__c != nObj.Last_Reserve_RAES_Detail__c) {
- if (String.isNotBlank(oObj.Id)) {
- aSetIdSet.add(oObj.Id);
- }
- if (String.isNotBlank(nObj.Id)) {
- aSetIdSet.add(nObj.Id);
- }
- }
- }
- if (!aSetIdSet.isEmpty()) {
- List<Fixture_OneToOne_Link__c> oneToOneList = [
- SELECT Id FROM Fixture_OneToOne_Link__c WHERE Main_Asset__c IN :aSetIdSet];
- if (!oneToOneList.isEmpty()) { update oneToOneList; }
- }
+ if (!assList.isEmpty()) {
+ update assList;
}
+ }
- // * 涓嶄細鏈夋殏瀹氬垎閰嶅悗鍐嶆嬁鍘讳慨鐞嗙殑澶囧搧璧伴噸鏂拌缃殏瀹氬垎閰嶇殑閫昏緫(queueRedistribution鏂规硶)
- // * 鐞嗙敱锛氭槑缁嗘殏瀹氬垎閰嶇殑鏃跺�欏垱寤轰慨鐞嗙殑璇濅細鎶ヤ互涓嬮敊璇�
- // * 鍊熷嚭_鍒嗛厤_鏁� 涓嶈兘澶т簬 璁惧鐨勬�绘暟 ------> Asset 鍏ュ姏瑙勫垯 You_Xiao_Ku_Cun_chk
- // * 鏆傚畾鍒嗛厤-1
- // * 淇悊-1
- // * 鏁伴噺1
- // * 1-1-1 = -1
- // *
- // * 濡傛灉鏆傚畾鍒嗛厤鎯充慨鐞嗙殑璇濆垎閰嶆殏瀹氬垎閰嶇殑閭d竴鏉℃槑缁�
- // * 鐒跺悗鍐嶅嚭鍑哄簱鍓嶆娴嬬殑鏃跺�欓�夋嫨NG淇悊
- // 銇嬨仾銈夈仛 after
- private void queueRedistribution() {
- if (queueRaesdMap == null) {
- queueRaesdMap = new Map<String , List<Rental_Apply_Equipment_Set_Detail__c>>();
+ // afterUpdate
+ // 娓呯悊瀛楁銆屽緟搴熷純鏁帮紙涓㈠け/鐩樹簭锛変慨鏀圭悊鐢便��
+ private void cleanGiveupReturnReason() {
+ List<Asset> assList = new List<Asset>();
+ for (Asset nObj : newList) {
+ if (String.isBlank(nObj.Giveup_Return__c) == false) {
+ assList.add(new Asset(Id = nObj.Id, Giveup_Return__c = ''));
+ }
+ }
+ if (!assList.isEmpty()) {
+ update assList;
+ }
+ }
+
+ // 銇嬨仾銈夈仛 after, oObj.Id 銇� nObj.Id 銈掍娇銇嗐仧銈�
+ // Last_Reserve_RAES_Detail__c (涓綋绠$悊) 銇甽ink 澶夈倧銇c仧鍫村悎銆�
+ // Fixture_OneToOne_Link__c 銈堛倞 Asset 銇銇夸笂銇掋仐銇︺亜銈嬫暟瀛椼倐閫e嫊銇仾銈嬨�丗ixture_OneToOne_Link__c 銈掔┖鏇存柊
+ // 鏇存柊闋呯洰Fixture_OneToOne_Link__c.In_wh_Fu_Shu_Pin_You_Xiao_Ku_Cun__c = Fixture_OneToOne_Link__c.In_wh_Fu_Shu_Pin_You_Xiao_Ku_Cun_F__c
+ private void mainAssetUpdateed_OneToOneRecord() {
+ Set<Id> aSetIdSet = new Set<Id>();
+ System.debug(LoggingLevel.INFO, '*** mainAssetUpdateed_OneToOneRecord: ');
+ for (Integer i = 0; i < newList.size(); i++) {
+ Asset nObj = newList[i];
+ Asset oObj = oldList[i];
+ if (
+ oObj.Last_Reserve_RAES_Detail__c != nObj.Last_Reserve_RAES_Detail__c
+ ) {
+ if (String.isNotBlank(oObj.Id)) {
+ aSetIdSet.add(oObj.Id);
}
- Map<String, Set<Id>> modelNoAssetIdMap = new Map<String, Set<Id>>();
- Set<Id> raesdIdSet = new Set<Id>();
- // List<Rental_Apply_Equipment_Set_Detail__c> updList = new List<Rental_Apply_Equipment_Set_Detail__c>();
- String whkey = '';
- for (Asset nObj : newList) {
- //ToDo鐝惧湪鎺掗槦銇с亶銈嬨伄銇富浣撱仩銇戙仾銇仹锛屼粖寰屼釜浣撶鐞嗐伄闄勫睘鍝併倐鎺掗槦銇с亶銈嬨伄鍫村悎銇屻亗銇c仧銈夈亾銇甀F銇躲倱銈掔洿銇欏繀瑕併亴銇傘倞銇俱仚
- if (!(nObj.Loaner_accsessary__c == false
- && nObj.Asset_Owner__c == 'Olympus'
- && nObj.Equipment_Type__c != '妫�娴嬬敤澶囧搧'
- && nObj.Delete_Flag__c == False
- && nObj.You_Xiao_Ku_Cun__c > 0
- && nObj.Freeze_sign_Abandoned_Flag__c == False)
- ) {
- continue;
- }
+ if (String.isNotBlank(nObj.Id)) {
+ aSetIdSet.add(nObj.Id);
+ }
+ }
+ }
+ if (!aSetIdSet.isEmpty()) {
+ List<Fixture_OneToOne_Link__c> oneToOneList = [
+ SELECT Id
+ FROM Fixture_OneToOne_Link__c
+ WHERE Main_Asset__c IN :aSetIdSet
+ ];
+ if (!oneToOneList.isEmpty()) {
+ update oneToOneList;
+ }
+ }
+ }
- String key = nObj.Fixture_Model_No_F__c;
- //鏆傚畾鍒嗛厤涓嶇湅瀛樻斁鍦� OLY_OCM-722 鎭㈠瀛樻斁鍦扮殑鏉′欢
- if (String.isNotBlank(nObj.Internal_asset_location__c)) {
- key += nObj.Internal_asset_location__c;
- }
+ // * 涓嶄細鏈夋殏瀹氬垎閰嶅悗鍐嶆嬁鍘讳慨鐞嗙殑澶囧搧璧伴噸鏂拌缃殏瀹氬垎閰嶇殑閫昏緫(queueRedistribution鏂规硶)
+ // * 鐞嗙敱锛氭槑缁嗘殏瀹氬垎閰嶇殑鏃跺�欏垱寤轰慨鐞嗙殑璇濅細鎶ヤ互涓嬮敊璇�
+ // * 鍊熷嚭_鍒嗛厤_鏁� 涓嶈兘澶т簬 璁惧鐨勬�绘暟 ------> Asset 鍏ュ姏瑙勫垯 You_Xiao_Ku_Cun_chk
+ // * 鏆傚畾鍒嗛厤-1
+ // * 淇悊-1
+ // * 鏁伴噺1
+ // * 1-1-1 = -1
+ // *
+ // * 濡傛灉鏆傚畾鍒嗛厤鎯充慨鐞嗙殑璇濆垎閰嶆殏瀹氬垎閰嶇殑閭d竴鏉℃槑缁�
+ // * 鐒跺悗鍐嶅嚭鍑哄簱鍓嶆娴嬬殑鏃跺�欓�夋嫨NG淇悊
+ // 銇嬨仾銈夈仛 after
+ private void queueRedistribution() {
+ if (queueRaesdMap == null) {
+ queueRaesdMap = new Map<String, List<Rental_Apply_Equipment_Set_Detail__c>>();
+ }
+ Map<String, Set<Id>> modelNoAssetIdMap = new Map<String, Set<Id>>();
+ Set<Id> raesdIdSet = new Set<Id>();
+ // List<Rental_Apply_Equipment_Set_Detail__c> updList = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ String whkey = '';
+ for (Asset nObj : newList) {
+ //ToDo鐝惧湪鎺掗槦銇с亶銈嬨伄銇富浣撱仩銇戙仾銇仹锛屼粖寰屼釜浣撶鐞嗐伄闄勫睘鍝併倐鎺掗槦銇с亶銈嬨伄鍫村悎銇屻亗銇c仧銈夈亾銇甀F銇躲倱銈掔洿銇欏繀瑕併亴銇傘倞銇俱仚
+ if (
+ !(nObj.Loaner_accsessary__c == false &&
+ nObj.Asset_Owner__c == 'Olympus' &&
+ nObj.Equipment_Type__c != '妫�娴嬬敤澶囧搧' &&
+ nObj.Delete_Flag__c == false &&
+ nObj.You_Xiao_Ku_Cun__c > 0 &&
+ nObj.Freeze_sign_Abandoned_Flag__c == false)
+ ) {
+ continue;
+ }
- if (String.isNotBlank(nObj.Salesdepartment__c)) {
- key += nObj.Salesdepartment__c;
- }
- if (String.isNotBlank(nObj.Equipment_Type__c)) {
- key += nObj.Equipment_Type__c;
- }
- if (String.isNotBlank(nObj.Product_category__c)) {
- key += nObj.Product_category__c;
- }
+ String key = nObj.Fixture_Model_No_F__c;
+ //鏆傚畾鍒嗛厤涓嶇湅瀛樻斁鍦� OLY_OCM-722 鎭㈠瀛樻斁鍦扮殑鏉′欢
+ if (String.isNotBlank(nObj.Internal_asset_location__c)) {
+ key += nObj.Internal_asset_location__c;
+ }
-
- System.debug(LoggingLevel.INFO, '*** key: ' + key);
- //鏈夋柊鐨凙sset鐨勬椂鍊� 鏆傚畾鍒嗛厤
- // You_Xiao_Ku_Cun__c > 0 鍦ㄤ笂闈㈠凡缁忓仛浜嗗垽鏂�
- if (Trigger.isInsert && String.isBlank(nObj.Last_Reserve_RAES_Detail__c)) {
- if (String.isBlank(nObj.Fixture_Model_No_F__c) == false) {
- // modelNoAssetIdMap.put(nObj.Fixture_Model_No_F__c, nObj.Id);
- if (modelNoAssetIdMap.containsKey(key) == false) {
- modelNoAssetIdMap.put(key, new Set<Id>());
- }
- modelNoAssetIdMap.get(key).add(nObj.Id);
- }
- }
- //褰撲富浣撳弬鐓х殑Asset鐨凩ast鏂紑鐨勬椂鍊欓噸鏂板鎵炬殏瀹氬垎閰�
- //ToDo鐘舵硜纰鸿獚
- /*
+ if (String.isNotBlank(nObj.Salesdepartment__c)) {
+ key += nObj.Salesdepartment__c;
+ }
+ if (String.isNotBlank(nObj.Equipment_Type__c)) {
+ key += nObj.Equipment_Type__c;
+ }
+ if (String.isNotBlank(nObj.Product_category__c)) {
+ key += nObj.Product_category__c;
+ }
+
+ System.debug(LoggingLevel.INFO, '*** key: ' + key);
+ //鏈夋柊鐨凙sset鐨勬椂鍊� 鏆傚畾鍒嗛厤
+ // You_Xiao_Ku_Cun__c > 0 鍦ㄤ笂闈㈠凡缁忓仛浜嗗垽鏂�
+ if (
+ Trigger.isInsert && String.isBlank(nObj.Last_Reserve_RAES_Detail__c)
+ ) {
+ if (String.isBlank(nObj.Fixture_Model_No_F__c) == false) {
+ // modelNoAssetIdMap.put(nObj.Fixture_Model_No_F__c, nObj.Id);
+ if (modelNoAssetIdMap.containsKey(key) == false) {
+ modelNoAssetIdMap.put(key, new Set<Id>());
+ }
+ modelNoAssetIdMap.get(key).add(nObj.Id);
+ }
+ }
+ //褰撲富浣撳弬鐓х殑Asset鐨凩ast鏂紑鐨勬椂鍊欓噸鏂板鎵炬殏瀹氬垎閰�
+ //ToDo鐘舵硜纰鸿獚
+ /*
|| (nObj.Asset_Owner__c != oObj.Asset_Owner__c && nObj.Asset_Owner__c == 'Olympus')
|| (nObj.Equipment_Type__c != oObj.Equipment_Type__c && oObj.Equipment_Type__c == '妫�娴嬬敤澶囧搧')
|| (nObj.Delete_Flag__c != oObj.Delete_Flag__c && nObj.Delete_Flag__c == false)
|| (nObj.Freeze_sign__c != oObj.Freeze_sign__c && nObj.Delete_Flag__c == false)
*/
- // You_Xiao_Ku_Cun__c > 0 鍦ㄤ笂闈㈠凡缁忓仛浜嗗垽鏂�
- else {
- Asset oObj = oldMap.get(nObj.Id);
- if (nObj.Loaner_accsessary__c == false && String.isBlank(nObj.Last_Reserve_RAES_Detail__c)
- && (nObj.Last_Reserve_RAES_Detail__c != oObj.Last_Reserve_RAES_Detail__c
- || (nObj.Asset_Owner__c != oObj.Asset_Owner__c && nObj.Asset_Owner__c == 'Olympus')
- //澶囧搧瀛樻斁鍦� OLY_OCM-722 鎭㈠瀛樻斁鍦扮殑鏉′欢
- || (nObj.Internal_asset_location__c != oObj.Internal_asset_location__c)
- //澶囧搧鍒嗙被骞朵笖涓嶆槸 妫�娴嬬敤澶囧搧
- || (nObj.Equipment_Type__c != oObj.Equipment_Type__c && nObj.Equipment_Type__c != '妫�娴嬬敤澶囧搧')
- //閿�鍞湰閮�
- || (nObj.Salesdepartment__c != oObj.Salesdepartment__c)
- //浜у搧鍒嗙被(GI/SP)
- || (nObj.Product_category__c != oObj.Product_category__c)
- //澶囧搧閰嶅鏄庣粏鍨嬪彿
- || (nObj.Fixture_Model_No_F__c != oObj.Fixture_Model_No_F__c)
- || (nObj.Delete_Flag__c != oObj.Delete_Flag__c && nObj.Delete_Flag__c == true)
- || (nObj.Freeze_sign_Abandoned_Flag__c != oObj.Freeze_sign_Abandoned_Flag__c && nObj.Freeze_sign_Abandoned_Flag__c == false)
- )
- ) {
- if (String.isBlank(nObj.Fixture_Model_No_F__c) == false) {
- if (modelNoAssetIdMap.containsKey(key) == false) {
- modelNoAssetIdMap.put(key, new Set<Id>());
- }
- modelNoAssetIdMap.get(key).add(nObj.Id);
- }
- if (String.isNotBlank(oObj.Last_Reserve_RAES_Detail__c)) {
- raesdIdSet.add(oObj.Last_Reserve_RAES_Detail__c);
- }
- }
+ // You_Xiao_Ku_Cun__c > 0 鍦ㄤ笂闈㈠凡缁忓仛浜嗗垽鏂�
+ else {
+ Asset oObj = oldMap.get(nObj.Id);
+ if (
+ nObj.Loaner_accsessary__c == false &&
+ String.isBlank(nObj.Last_Reserve_RAES_Detail__c) &&
+ (nObj.Last_Reserve_RAES_Detail__c !=
+ oObj.Last_Reserve_RAES_Detail__c ||
+ (nObj.Asset_Owner__c != oObj.Asset_Owner__c &&
+ nObj.Asset_Owner__c == 'Olympus') ||
+ //澶囧搧瀛樻斁鍦� OLY_OCM-722 鎭㈠瀛樻斁鍦扮殑鏉′欢
+ (nObj.Internal_asset_location__c !=
+ oObj.Internal_asset_location__c) ||
+ //澶囧搧鍒嗙被骞朵笖涓嶆槸 妫�娴嬬敤澶囧搧
+ (nObj.Equipment_Type__c != oObj.Equipment_Type__c &&
+ nObj.Equipment_Type__c != '妫�娴嬬敤澶囧搧') ||
+ //閿�鍞湰閮�
+ (nObj.Salesdepartment__c != oObj.Salesdepartment__c) ||
+ //浜у搧鍒嗙被(GI/SP)
+ (nObj.Product_category__c != oObj.Product_category__c) ||
+ //澶囧搧閰嶅鏄庣粏鍨嬪彿
+ (nObj.Fixture_Model_No_F__c != oObj.Fixture_Model_No_F__c) ||
+ (nObj.Delete_Flag__c != oObj.Delete_Flag__c &&
+ nObj.Delete_Flag__c == true) ||
+ (nObj.Freeze_sign_Abandoned_Flag__c !=
+ oObj.Freeze_sign_Abandoned_Flag__c &&
+ nObj.Freeze_sign_Abandoned_Flag__c == false))
+ ) {
+ if (String.isBlank(nObj.Fixture_Model_No_F__c) == false) {
+ if (modelNoAssetIdMap.containsKey(key) == false) {
+ modelNoAssetIdMap.put(key, new Set<Id>());
}
+ modelNoAssetIdMap.get(key).add(nObj.Id);
+ }
+ if (String.isNotBlank(oObj.Last_Reserve_RAES_Detail__c)) {
+ raesdIdSet.add(oObj.Last_Reserve_RAES_Detail__c);
+ }
}
- if (modelNoAssetIdMap.isEmpty()) {
- return;
- }
- System.debug(LoggingLevel.INFO, '*** raesdIdSet: ' + JSON.serialize(raesdIdSet));
- //modified by denny 2021-11-17
- List<String> keyList = new List<String>();
- keyList.addAll(modelNoAssetIdMap.keySet());
- System.debug(LoggingLevel.INFO, '*** keyList: ' + keyList);
- List<Rental_Apply_Sequence__c> targetSequence = [SELECT Id,Apply_Set_Detail__c,
- Apply_Set_Detail_ExternalKey__c,
- Demo_Purpose2__c, Equipment_Type__c, ExternalKey__c,
- Fixture_Model_No__c,
- Internal_asset_location__c, Invalid_Flag__c,
- Product_category__c,
- Rental_Apply__c,Series_No__c,
- Series_Unequal_Queue_Flag__c, Salesdepartment__c
- FROM Rental_Apply_Sequence__c
- WHERE Series_No__c > 0 AND Invalid_Flag__c =false
- AND Apply_Set_Detail__c NOT IN:raesdIdSet
- AND ExternalKey__c IN:keyList
- AND Apply_Set_Detail__r.Cancel_Select__c = false
- ORDER BY Series_No__c ];
- System.debug(LoggingLevel.INFO, '*** targetSequence: ' + targetSequence);
- Map<String,List<Rental_Apply_Sequence__c>> sequenceMap = new Map<String,List<Rental_Apply_Sequence__c>>();
- for(Rental_Apply_Sequence__c sequeuece:targetSequence){
- if(!sequenceMap.containsKey(sequeuece.Externalkey__c)){
- sequenceMap.put(sequeuece.Externalkey__c,new List<Rental_Apply_Sequence__c>());
+ }
+ }
+ if (modelNoAssetIdMap.isEmpty()) {
+ return;
+ }
+ System.debug(
+ LoggingLevel.INFO,
+ '*** raesdIdSet: ' + JSON.serialize(raesdIdSet)
+ );
+ //modified by denny 2021-11-17
+ List<String> keyList = new List<String>();
+ keyList.addAll(modelNoAssetIdMap.keySet());
+ System.debug(LoggingLevel.INFO, '*** keyList: ' + keyList);
+ List<Rental_Apply_Sequence__c> targetSequence = [
+ SELECT
+ Id,
+ Apply_Set_Detail__c,
+ Apply_Set_Detail_ExternalKey__c,
+ Demo_Purpose2__c,
+ Equipment_Type__c,
+ ExternalKey__c,
+ Fixture_Model_No__c,
+ Internal_asset_location__c,
+ Invalid_Flag__c,
+ Product_category__c,
+ Rental_Apply__c,
+ Series_No__c,
+ Series_Unequal_Queue_Flag__c,
+ Salesdepartment__c
+ FROM Rental_Apply_Sequence__c
+ WHERE
+ Series_No__c > 0
+ AND Invalid_Flag__c = FALSE
+ AND Apply_Set_Detail__c NOT IN :raesdIdSet
+ AND ExternalKey__c IN :keyList
+ AND Apply_Set_Detail__r.Cancel_Select__c = FALSE
+ ORDER BY Series_No__c
+ ];
+ System.debug(LoggingLevel.INFO, '*** targetSequence: ' + targetSequence);
+ Map<String, List<Rental_Apply_Sequence__c>> sequenceMap = new Map<String, List<Rental_Apply_Sequence__c>>();
+ for (Rental_Apply_Sequence__c sequeuece : targetSequence) {
+ if (!sequenceMap.containsKey(sequeuece.Externalkey__c)) {
+ sequenceMap.put(
+ sequeuece.Externalkey__c,
+ new List<Rental_Apply_Sequence__c>()
+ );
+ }
+ sequenceMap.get(sequeuece.Externalkey__c).add(sequeuece);
+ }
+ Map<String, Rental_Apply_Equipment_Set_Detail__c> updateMap = new Map<String, Rental_Apply_Equipment_Set_Detail__c>();
+ for (String key : sequenceMap.keySet()) {
+ for (Rental_Apply_Sequence__c sequeuece : sequenceMap.get(key)) {
+ if (!updateMap.containsKey(sequeuece.Apply_Set_Detail__c)) {
+ System.debug(
+ LoggingLevel.INFO,
+ '*** modelNoAssetIdMap: ' + JSON.serialize(modelNoAssetIdMap)
+ );
+ if (modelNoAssetIdMap.containsKey(key)) {
+ List<Id> assIdList = new List<Id>();
+ assIdList.addAll(modelNoAssetIdMap.get(key));
+ String assIdbk = assIdList.get(0);
+ Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c();
+ raesd.Id = sequeuece.Apply_Set_Detail__c;
+ raesd.Asset__c = assIdbk;
+ System.debug('raesd.Asset__c' + raesd.Asset__c);
+ raesd.Queue_Number__c = 0; // 鏆傚畾鍒嗛厤
+ updateMap.put(raesd.Id, raesd);
+
+ modelNoAssetIdMap.get(key).remove(assIdbk);
+ if (modelNoAssetIdMap.get(key).isEmpty()) {
+ modelNoAssetIdMap.remove(key);
}
- sequenceMap.get(sequeuece.Externalkey__c).add(sequeuece);
+ System.debug(
+ LoggingLevel.INFO,
+ '*** modelNoAssetIdMap: ' + JSON.serialize(modelNoAssetIdMap)
+ );
+ }
}
- Map<String,Rental_Apply_Equipment_Set_Detail__c> updateMap = new Map<String,Rental_Apply_Equipment_Set_Detail__c>();
- for(String key:sequenceMap.keySet()){
- for(Rental_Apply_Sequence__c sequeuece:sequenceMap.get(key)){
- if(!updateMap.containsKey(sequeuece.Apply_Set_Detail__c)){
- System.debug(LoggingLevel.INFO, '*** modelNoAssetIdMap: ' + JSON.serialize(modelNoAssetIdMap));
- if(modelNoAssetIdMap.containsKey(key)){
- List<Id> assIdList = new List<Id>();
- assIdList.addAll(modelNoAssetIdMap.get(key));
- String assIdbk = assIdList.get(0);
- Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c();
- raesd.Id = sequeuece.Apply_Set_Detail__c;
- raesd.Asset__c = assIdbk;
- System.debug('raesd.Asset__c' + raesd.Asset__c);
- raesd.Queue_Number__c = 0; // 鏆傚畾鍒嗛厤
- updateMap.put(raesd.Id,raesd);
+ }
+ }
+ System.debug(
+ LoggingLevel.INFO,
+ '*** updateMap.values(): ' + JSON.serialize(updateMap.values())
+ );
+ update updateMap.values();
+ // Fixture_Model_No_F__c 銈掕銈嬨亾銇ㄣ亴銇с亶銇亜銆併儑銉笺偪銇屻亰銇娿亜銇仹銆�
+ // Fixture_Set_Detail__r.Fixture_Model_No_F__c 銈掋伩銈嬨亱 Fixture_Model_No_text__c 銈掋伩銈嬨亱
+ // whkey += ' (';
+ // whkey += ' ((Fixture_Set_Detail__c != null and Fixture_Set_Detail__r.Product2__r.Fixture_Model_No_T__c =\'' + String.escapeSingleQuotes(nObj.Fixture_Model_No_F__c) + '\')';
+ // whkey += ' OR Fixture_Model_No_text__c =\'' + String.escapeSingleQuotes(nObj.Fixture_Model_No_F__c) + '\'';
+ // whkey += ' )';
- modelNoAssetIdMap.get(key).remove(assIdbk);
- if (modelNoAssetIdMap.get(key).isEmpty()) {
- modelNoAssetIdMap.remove(key);
- }
- System.debug(LoggingLevel.INFO, '*** modelNoAssetIdMap: ' + JSON.serialize(modelNoAssetIdMap));
- }
- }
-
- }
-
+ // String wher = '';
+ // //鏆傚畾鍒嗛厤涓嶇湅瀛樻斁鍦� OLY_OCM-722 鎭㈠瀛樻斁鍦扮殑鏉′欢
+ // if (String.isNotBlank(nObj.Internal_asset_location__c)) {
+ // wher += ' and Internal_asset_location_before__c =\'' + String.escapeSingleQuotes(nObj.Internal_asset_location__c) + '\'';
+ // }
+
+ // if (String.isNotBlank(nObj.Salesdepartment__c)) {
+ // wher += ' and Salesdepartment_before__c =\'' + String.escapeSingleQuotes(nObj.Salesdepartment__c) + '\'';
+ // }
+
+ // if (String.isNotBlank(nObj.Product_category__c)) {
+ // wher += ' and Product_category_text__c =\'' + String.escapeSingleQuotes(nObj.Product_category__c) + '\'';
+ // }
+
+ // if (String.isNotBlank(nObj.Equipment_Type__c)) {
+ // wher += ' and Equipment_Type_text__c =\'' + String.escapeSingleQuotes(nObj.Equipment_Type__c) + '\'';
+ // }
+
+ // whkey += wher + ' ) OR';
+ // }
+
+ // if (String.isNotBlank(whkey)) {
+ // whkey = '( ' + whkey.removeEnd('OR') + ')';
+ // }
+
+ // String soql = 'SELECT Fixture_Model_No_F__c, Substitute_flag__c, Asset__c,'
+ // + ' Queue_Number__c, Fixture_Model_No_text__c, Salesdepartment_before__c,'
+ // + ' Product_category_text__c, Equipment_Type_text__c, Internal_asset_location_before__c'
+ // + ' FROM Rental_Apply_Equipment_Set_Detail__c'
+ // + ' where Id != :raesdIdSet and '
+ // + whkey
+ // + ' and Queue_Number__c > 0'
+ // + ' and Cancel_Select__c = false'
+ // + ' order by Queue_Number__c ASC';
+ // System.debug('whkey' + whkey);
+ // System.debug('soql' + soql);
+ // List<Rental_Apply_Equipment_Set_Detail__c> targetRaesd = Database.query(soql);
+ // System.debug('targetRaesd' + targetRaesd);
+ // for (Rental_Apply_Equipment_Set_Detail__c raesd : targetRaesd) {
+ // // TODO Fixture_Set_Detail__c 銇� 銉併偋銉冦偗杩藉姞 Rental_Apply_Equipment_Set_Detail__c 鏂版暟鎹�, 鏈� 娌℃湁鍒嗛厤(鍒嗛厤鏃堕棿) 鐨勮瘽, 涓嶈兘 Delete Fixture_Set_Detail__c
+ // String key = '';
+ // if (raesd.Substitute_flag__c) {
+ // key = raesd.Fixture_Model_No_text__c;
+ // } else {
+ // key = raesd.Fixture_Model_No_F__c;
+ // }
+ // //鏆傚畾鍒嗛厤涓嶇湅瀛樻斁鍦� OLY_OCM-722 鎭㈠瀛樻斁鍦扮殑鏉′欢
+ // if (String.isNotBlank(raesd.Internal_asset_location_before__c)) {
+ // key += '_' + raesd.Internal_asset_location_before__c;
+ // }
+
+ // if (String.isNotBlank(raesd.Salesdepartment_before__c)) {
+ // key += '_' + raesd.Salesdepartment_before__c;
+ // }
+
+ // if (String.isNotBlank(raesd.Product_category_text__c)) {
+ // key += '_' + raesd.Product_category_text__c;
+ // }
+
+ // if (String.isNotBlank(raesd.Equipment_Type_text__c)) {
+ // key += '_' + raesd.Equipment_Type_text__c;
+ // }
+ // if (queueRaesdMap.containsKey(key) == false) {
+ // queueRaesdMap.put(key, new List<Rental_Apply_Equipment_Set_Detail__c>());
+ // }
+ // queueRaesdMap.get(key).add(raesd);
+ // }
+
+ // System.debug('queueRaesdMap' + queueRaesdMap);
+ // System.debug('modelNoAssetIdMap' + modelNoAssetIdMap);
+
+ // List<Rental_Apply_Equipment_Set_Detail__c> uplist = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ // for (String raesdkey : queueRaesdMap.keySet()) {
+ // for (Rental_Apply_Equipment_Set_Detail__c raesd : queueRaesdMap.get(raesdkey)) {
+ // System.debug(raesdkey);
+ // // 杩欓噷鐨剄ueueRaesdMap鍦ㄧ敤瀹屽悗娌℃湁娓呯┖锛屽鑷翠笌鏈�鏂版煡鍑虹殑targetRaesd涓嶄竴鑷�
+ // // 鎷呭績鐩存帴娓呯┖浼氶�犳垚鍏跺畠闂锛屾墍浠ュ姞or鏉ヤ繚璇佹槑缁嗙殑Asset__c鍙細琚洿鏂颁竴娆�
+ // if (modelNoAssetIdMap.containsKey(raesdkey) == false || String.isNotBlank(raesd.Asset__c)) {
+ // // 鍩烘湰鐧虹敓銇椼仾銇勩�乹ueueRaesdMap <= modelNoAssetIdMap
+ // continue;
+ // }
+ // Id assIdbk;
+ // for (Id assId : modelNoAssetIdMap.get(raesdkey)) {
+ // assIdbk = assId;
+ // raesd.Asset__c = assId;
+ // System.debug('raesd.Asset__c' + raesd.Asset__c);
+ // raesd.Queue_Number__c = 0; // 鏆傚畾鍒嗛厤
+ // uplist.add(raesd);
+ // System.debug('raesd Idis' + raesd.Id);
+ // break;
+ // }
+ // modelNoAssetIdMap.get(raesdkey).remove(assIdbk);
+ // if (modelNoAssetIdMap.get(raesdkey).isEmpty()) {
+ // modelNoAssetIdMap.remove(raesdkey);
+ // }
+ // }
+ // }
+
+ // //鎺掗槦鏇存柊
+ // if (!uplist.isEmpty()) {
+ // update uplist;
+ // }
+ }
+
+ //before 鏁板紡銇�ゃ亴null銇仾銈嬪彲鑳芥�с亴銇傘倞銇俱仚銇仹銇撱亾銇с倐涓�鍥炪儊銈с儍銈仐銇俱仚
+ private void formulaToTextCheck() {
+ List<Asset> assets = new List<Asset>();
+ for (Asset nObj : newList) {
+ if (nObj.Fixture_Status2_text__c != nObj.Fixture_Status2__c) {
+ Asset ass = new Asset(Id = nObj.Id);
+ ass.Fixture_Status2_text__c = nObj.Fixture_Status2__c;
+ assets.add(ass);
+ }
+ }
+ if (!assets.isEmpty()) {
+ update assets;
+ }
+ }
+
+ private void checkOneToOneLink() {
+ Set<Id> otoIds = new Set<Id>(); // 寰呭垹闄ink鐨処d
+ Set<Id> assetIds = new Set<Id>();
+ Set<String> centers = new Set<String>{
+ '鍖椾含 澶囧搧涓績',
+ '涓婃捣 澶囧搧涓績',
+ '骞垮窞 澶囧搧涓績'
+ };
+ for (Asset nObj : newList) {
+ //寰呭簾寮冿紝搴熷純锛屽拰鏁伴噺0鐨勫鍝侀渶瑕佹柇寮�涓�瀵逛竴link 锛堢洰鍓嶅彧澶勭悊涓綋绠$悊鐨勶級
+ if (
+ (nObj.Fixture_Status__c ==
+ FixtureUtil.assetFixtureStatusMap.get(
+ FixtureUtil.AssetFixtureStatus.Fei_Qi.ordinal()
+ ) ||
+ nObj.Fixture_Status__c ==
+ FixtureUtil.assetFixtureStatusMap.get(
+ FixtureUtil.AssetFixtureStatus.Dai_Fei_Qi.ordinal()
+ ) ||
+ nObj.Quantity == 0) &&
+ nObj.Manage_type__c ==
+ FixtureUtil.managetypeMap.get(FixtureUtil.Managetype.Ge_Ti_Guan_Li)
+ ) {
+ //鏄竴瀵逛竴涓讳綋鎴栬�呮槸涓�瀵逛竴涓綋闄勫睘鍝�
+ if (
+ nObj.Main_OneToOne__c == true ||
+ nObj.Fixture_OneToOne_Link__c <> null
+ ) {
+ if (centers.contains(nObj.Internal_asset_location__c)) {
+ assetIds.add(nObj.Id);
+ }
}
- System.debug(LoggingLevel.INFO, '*** updateMap.values(): ' + JSON.serialize(updateMap.values()));
- update updateMap.values();
-
- // Fixture_Model_No_F__c 銈掕銈嬨亾銇ㄣ亴銇с亶銇亜銆併儑銉笺偪銇屻亰銇娿亜銇仹銆�
- // Fixture_Set_Detail__r.Fixture_Model_No_F__c 銈掋伩銈嬨亱 Fixture_Model_No_text__c 銈掋伩銈嬨亱
- // whkey += ' (';
- // whkey += ' ((Fixture_Set_Detail__c != null and Fixture_Set_Detail__r.Product2__r.Fixture_Model_No_T__c =\'' + String.escapeSingleQuotes(nObj.Fixture_Model_No_F__c) + '\')';
- // whkey += ' OR Fixture_Model_No_text__c =\'' + String.escapeSingleQuotes(nObj.Fixture_Model_No_F__c) + '\'';
- // whkey += ' )';
-
- // String wher = '';
- // //鏆傚畾鍒嗛厤涓嶇湅瀛樻斁鍦� OLY_OCM-722 鎭㈠瀛樻斁鍦扮殑鏉′欢
- // if (String.isNotBlank(nObj.Internal_asset_location__c)) {
- // wher += ' and Internal_asset_location_before__c =\'' + String.escapeSingleQuotes(nObj.Internal_asset_location__c) + '\'';
- // }
-
- // if (String.isNotBlank(nObj.Salesdepartment__c)) {
- // wher += ' and Salesdepartment_before__c =\'' + String.escapeSingleQuotes(nObj.Salesdepartment__c) + '\'';
- // }
-
- // if (String.isNotBlank(nObj.Product_category__c)) {
- // wher += ' and Product_category_text__c =\'' + String.escapeSingleQuotes(nObj.Product_category__c) + '\'';
- // }
-
- // if (String.isNotBlank(nObj.Equipment_Type__c)) {
- // wher += ' and Equipment_Type_text__c =\'' + String.escapeSingleQuotes(nObj.Equipment_Type__c) + '\'';
- // }
-
- // whkey += wher + ' ) OR';
- // }
-
-
-
- // if (String.isNotBlank(whkey)) {
- // whkey = '( ' + whkey.removeEnd('OR') + ')';
- // }
-
-
-
- // String soql = 'SELECT Fixture_Model_No_F__c, Substitute_flag__c, Asset__c,'
- // + ' Queue_Number__c, Fixture_Model_No_text__c, Salesdepartment_before__c,'
- // + ' Product_category_text__c, Equipment_Type_text__c, Internal_asset_location_before__c'
- // + ' FROM Rental_Apply_Equipment_Set_Detail__c'
- // + ' where Id != :raesdIdSet and '
- // + whkey
- // + ' and Queue_Number__c > 0'
- // + ' and Cancel_Select__c = false'
- // + ' order by Queue_Number__c ASC';
- // System.debug('whkey' + whkey);
- // System.debug('soql' + soql);
- // List<Rental_Apply_Equipment_Set_Detail__c> targetRaesd = Database.query(soql);
- // System.debug('targetRaesd' + targetRaesd);
- // for (Rental_Apply_Equipment_Set_Detail__c raesd : targetRaesd) {
- // // TODO Fixture_Set_Detail__c 銇� 銉併偋銉冦偗杩藉姞 Rental_Apply_Equipment_Set_Detail__c 鏂版暟鎹�, 鏈� 娌℃湁鍒嗛厤(鍒嗛厤鏃堕棿) 鐨勮瘽, 涓嶈兘 Delete Fixture_Set_Detail__c
- // String key = '';
- // if (raesd.Substitute_flag__c) {
- // key = raesd.Fixture_Model_No_text__c;
- // } else {
- // key = raesd.Fixture_Model_No_F__c;
- // }
- // //鏆傚畾鍒嗛厤涓嶇湅瀛樻斁鍦� OLY_OCM-722 鎭㈠瀛樻斁鍦扮殑鏉′欢
- // if (String.isNotBlank(raesd.Internal_asset_location_before__c)) {
- // key += '_' + raesd.Internal_asset_location_before__c;
- // }
-
- // if (String.isNotBlank(raesd.Salesdepartment_before__c)) {
- // key += '_' + raesd.Salesdepartment_before__c;
- // }
-
- // if (String.isNotBlank(raesd.Product_category_text__c)) {
- // key += '_' + raesd.Product_category_text__c;
- // }
-
- // if (String.isNotBlank(raesd.Equipment_Type_text__c)) {
- // key += '_' + raesd.Equipment_Type_text__c;
- // }
- // if (queueRaesdMap.containsKey(key) == false) {
- // queueRaesdMap.put(key, new List<Rental_Apply_Equipment_Set_Detail__c>());
- // }
- // queueRaesdMap.get(key).add(raesd);
- // }
-
- // System.debug('queueRaesdMap' + queueRaesdMap);
- // System.debug('modelNoAssetIdMap' + modelNoAssetIdMap);
-
- // List<Rental_Apply_Equipment_Set_Detail__c> uplist = new List<Rental_Apply_Equipment_Set_Detail__c>();
- // for (String raesdkey : queueRaesdMap.keySet()) {
- // for (Rental_Apply_Equipment_Set_Detail__c raesd : queueRaesdMap.get(raesdkey)) {
- // System.debug(raesdkey);
- // // 杩欓噷鐨剄ueueRaesdMap鍦ㄧ敤瀹屽悗娌℃湁娓呯┖锛屽鑷翠笌鏈�鏂版煡鍑虹殑targetRaesd涓嶄竴鑷�
- // // 鎷呭績鐩存帴娓呯┖浼氶�犳垚鍏跺畠闂锛屾墍浠ュ姞or鏉ヤ繚璇佹槑缁嗙殑Asset__c鍙細琚洿鏂颁竴娆�
- // if (modelNoAssetIdMap.containsKey(raesdkey) == false || String.isNotBlank(raesd.Asset__c)) {
- // // 鍩烘湰鐧虹敓銇椼仾銇勩�乹ueueRaesdMap <= modelNoAssetIdMap
- // continue;
- // }
- // Id assIdbk;
- // for (Id assId : modelNoAssetIdMap.get(raesdkey)) {
- // assIdbk = assId;
- // raesd.Asset__c = assId;
- // System.debug('raesd.Asset__c' + raesd.Asset__c);
- // raesd.Queue_Number__c = 0; // 鏆傚畾鍒嗛厤
- // uplist.add(raesd);
- // System.debug('raesd Idis' + raesd.Id);
- // break;
- // }
- // modelNoAssetIdMap.get(raesdkey).remove(assIdbk);
- // if (modelNoAssetIdMap.get(raesdkey).isEmpty()) {
- // modelNoAssetIdMap.remove(raesdkey);
- // }
- // }
- // }
-
- // //鎺掗槦鏇存柊
- // if (!uplist.isEmpty()) {
- // update uplist;
- // }
+ }
}
- //before 鏁板紡銇�ゃ亴null銇仾銈嬪彲鑳芥�с亴銇傘倞銇俱仚銇仹銇撱亾銇с倐涓�鍥炪儊銈с儍銈仐銇俱仚
- private void formulaToTextCheck() {
- List<Asset> assets = new List<Asset>();
- for (Asset nObj : newList) {
- if (nObj.Fixture_Status2_text__c != nObj.Fixture_Status2__c) {
- Asset ass = new Asset(Id = nObj.Id);
- ass.Fixture_Status2_text__c = nObj.Fixture_Status2__c;
- assets.add(ass);
- }
- }
- if (!assets.isEmpty()) {
- update assets;
- }
+ if (assetIds.size() > 0) {
+ Map<Id, Fixture_OneToOne_Link__c> linkMap = new Map<Id, Fixture_OneToOne_Link__c>(
+ [
+ SELECT Id
+ FROM Fixture_OneToOne_Link__c
+ WHERE Main_Asset__c IN :assetIds OR Accessory_Asset__c IN :assetIds
+ ]
+ );
+ if (!linkMap.isEmpty()) {
+ delete linkMap.values();
+ }
}
+ }
- private void checkOneToOneLink() {
- Set<Id> otoIds = new Set<Id>(); // 寰呭垹闄ink鐨処d
- Set<Id> assetIds = new Set<Id>();
- Set<String> centers = new Set<String> {'鍖椾含 澶囧搧涓績', '涓婃捣 澶囧搧涓績', '骞垮窞 澶囧搧涓績'};
- for (Asset nObj : newList) {
- //寰呭簾寮冿紝搴熷純锛屽拰鏁伴噺0鐨勫鍝侀渶瑕佹柇寮�涓�瀵逛竴link 锛堢洰鍓嶅彧澶勭悊涓綋绠$悊鐨勶級
- if ((nObj.Fixture_Status__c == FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Fei_Qi.ordinal())
- || nObj.Fixture_Status__c == FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Dai_Fei_Qi.ordinal())
- || nObj.Quantity == 0) && nObj.Manage_type__c == FixtureUtil.managetypeMap.get(FixtureUtil.Managetype.Ge_Ti_Guan_Li)){
- //鏄竴瀵逛竴涓讳綋鎴栬�呮槸涓�瀵逛竴涓綋闄勫睘鍝�
- if (nObj.Main_OneToOne__c == true || nObj.Fixture_OneToOne_Link__c <> null) {
- if(centers.contains(nObj.Internal_asset_location__c)) {
- assetIds.add(nObj.Id);
- }
- }
- }
- }
+ /**
+ * 鍔ㄦ�佽瀹� Asset.AccountId (澶囧搧鍏变韩_鏉窞_鍗庝笢钀ヤ笟鏈儴)
+ * Condition:
+ * - before insert, before update
+ * - 纭瀛楁鍙樺寲 锛堜繚鏈夎澶囩殑澶囧搧瀛樻斁鍦帮紙Internal_asset_location__c锛�+鎵�鍦ㄥ湴鍖�(鏈儴)锛圫alesdepartment__c锛夛級
+ * - Salesdepartment__c IN ('1.鍗庡寳钀ヤ笟鏈儴','2.涓滃寳钀ヤ笟鏈儴','3.瑗垮寳钀ヤ笟鏈儴','4.鍗庝笢钀ヤ笟鏈儴','5.鍗庡崡钀ヤ笟鏈儴','6.瑗垮崡钀ヤ笟鏈儴')
+ * - Asset 鏄� 鍔炰簨澶勫鍝�
+ * Execute:
+ * - 鎵� Label: OCM_Management_Province_Mapping, 鐨� 鍔炰簨澶�, 璁惧畾 AccountId
+ * - 娌℃湁鎵剧殑璇�, 涓嶆洿鏂癆ccountId, 鑷姩鍋� Account, Group, ApexShare
+ */
+ private void beforeSetAccountId() {
+ Set<String> targetDepts = new Set<String>{
+ '1.鍗庡寳钀ヤ笟鏈儴',
+ '2.涓滃寳钀ヤ笟鏈儴',
+ '3.瑗垮寳钀ヤ笟鏈儴',
+ '4.鍗庝笢钀ヤ笟鏈儴',
+ '5.鍗庡崡钀ヤ笟鏈儴',
+ '6.瑗垮崡钀ヤ笟鏈儴'
+ };
+ Set<String> targetCenters = new Set<String>{
+ '鍖椾含 澶囧搧涓績',
+ '涓婃捣 澶囧搧涓績',
+ '骞垮窞 澶囧搧涓績'
+ };
+ if (Test.isRunningTest() && testTargetDepts != null) {
+ targetDepts = testTargetDepts;
+ }
+ // 瀛樻斁鍦� 鈫� 鐪� 鐨� Map
+ Map<String, String> targetProvs = AssetWebService.getOcmMgtProvMap();
- if (assetIds.size() > 0) {
- Map<Id, Fixture_OneToOne_Link__c> linkMap = new Map<Id, Fixture_OneToOne_Link__c>([
+ // 鏀堕泦瀵硅薄 Asset
+ Map<Asset, String> assetAccShareNameMap = new Map<Asset, String>();
+ Datetime execNow = System.now();
+ for (Asset nObj : newList) {
+ Asset oObj = (null == this.oldMap) ? null : this.oldMap.get(nObj.Id);
+
+ // 浣滄垚, 纭瀛楁鏈夋病鏈夊彉鍖�
+ if (
+ Trigger.isInsert ||
+ (oObj != null &&
+ (oObj.RecordTypeId != nObj.RecordTypeId ||
+ oObj.Asset_loaner_category__c != nObj.Asset_loaner_category__c ||
+ oObj.AssetManageConfirm__c != nObj.AssetManageConfirm__c ||
+ oObj.Internal_asset_location__c != nObj.Internal_asset_location__c ||
+ oObj.Salesdepartment__c != nObj.Salesdepartment__c ||
+ oObj.OlympusAccShareName__c != nObj.OlympusAccShareName__c) &&
+ (targetCenters.contains(nObj.Internal_asset_location__c) ||
+ targetProvs.containsKey(nObj.Internal_asset_location__c)) &&
+ !nObj.TransferToOther__c)
+ ) {
+ // 鏄笉鏄鍝佺殑纭
+ if (
+ System.Label.Asset_RecordType == nObj.RecordTypeId &&
+ true == nObj.AssetManageConfirm__c &&
+ nObj.Asset_loaner_category__c != '鑰楁潗'
+ ) {
+ // 鍔炰簨澶勫鍝� 鈫� 鍔ㄦ�佽瀹� Asset.AccountId 鐨勫璞�
+ if (
+ targetProvs.containsKey(nObj.Internal_asset_location__c) &&
+ targetDepts.contains(nObj.Salesdepartment__c)
+ ) {
+ String accShareName =
+ '澶囧搧鍏变韩_' +
+ targetProvs.get(nObj.Internal_asset_location__c) +
+ '_' +
+ nObj.Salesdepartment__c.right(6);
+ nObj.OlympusAccShareName__c = accShareName;
+ assetAccShareNameMap.put(nObj, accShareName);
+ } else {
+ if (AssetHandler.Account_Asset_Id == null) {
+ // Static 鍙細鎵ц涓�閬�
+ AssetHandler.Account_Asset_Id = [
SELECT Id
- FROM Fixture_OneToOne_Link__c
- WHERE Main_Asset__c in :assetIds
- OR Accessory_Asset__c IN: assetIds
- ]);
- if(!linkMap.isEmpty()){
- delete linkMap.values();
+ FROM Account
+ WHERE AgentCode_Ext__c = :System.Label.Account_Asset
+ ]
+ .Id;
}
+ nObj.OlympusAccShareName__c = '';
+ nObj.AccountId = AssetHandler.Account_Asset_Id;
+ }
+ } else {
+ // 鏇存柊鎴� 涓嶆槸澶囧搧 鐨勬椂鍊�, 鏇存柊鐨勭▼搴忛噷 瑕� care AccountId
+ nObj.OlympusAccShareName__c = '';
}
+ }
}
- /**
- * 鍔ㄦ�佽瀹� Asset.AccountId (澶囧搧鍏变韩_鏉窞_鍗庝笢钀ヤ笟鏈儴)
- * Condition:
- * - before insert, before update
- * - 纭瀛楁鍙樺寲 锛堜繚鏈夎澶囩殑澶囧搧瀛樻斁鍦帮紙Internal_asset_location__c锛�+鎵�鍦ㄥ湴鍖�(鏈儴)锛圫alesdepartment__c锛夛級
- * - Salesdepartment__c IN ('1.鍗庡寳钀ヤ笟鏈儴','2.涓滃寳钀ヤ笟鏈儴','3.瑗垮寳钀ヤ笟鏈儴','4.鍗庝笢钀ヤ笟鏈儴','5.鍗庡崡钀ヤ笟鏈儴','6.瑗垮崡钀ヤ笟鏈儴')
- * - Asset 鏄� 鍔炰簨澶勫鍝�
- * Execute:
- * - 鎵� Label: OCM_Management_Province_Mapping, 鐨� 鍔炰簨澶�, 璁惧畾 AccountId
- * - 娌℃湁鎵剧殑璇�, 涓嶆洿鏂癆ccountId, 鑷姩鍋� Account, Group, ApexShare
- */
- private void beforeSetAccountId() {
- Set<String> targetDepts = new Set<String> {'1.鍗庡寳钀ヤ笟鏈儴','2.涓滃寳钀ヤ笟鏈儴','3.瑗垮寳钀ヤ笟鏈儴','4.鍗庝笢钀ヤ笟鏈儴','5.鍗庡崡钀ヤ笟鏈儴','6.瑗垮崡钀ヤ笟鏈儴'};
- Set<String> targetCenters = new Set<String> {'鍖椾含 澶囧搧涓績', '涓婃捣 澶囧搧涓績', '骞垮窞 澶囧搧涓績'};
- if (Test.isRunningTest() && testTargetDepts != null) {
- targetDepts = testTargetDepts;
- }
- // 瀛樻斁鍦� 鈫� 鐪� 鐨� Map
- Map<String, String> targetProvs = AssetWebService.getOcmMgtProvMap();
+ // check 鏄笉鏄� accShareName 閮芥湁
+ Set<String> insertAccShareNameSet = new Set<String>();
+ if (assetAccShareNameMap.size() > 0) {
+ Map<String, Id> accShareId = new Map<String, Id>();
+ for (Account accShare : [
+ SELECT Id, Department_Name__c
+ FROM Account
+ WHERE
+ RecordTypeId = :System.Label.Department_OTH
+ AND Department_Name__c IN :assetAccShareNameMap.values()
+ ]) {
+ accShareId.put(accShare.Department_Name__c, accShare.Id);
+ }
- // 鏀堕泦瀵硅薄 Asset
- Map<Asset, String> assetAccShareNameMap = new Map<Asset, String>();
- Datetime execNow = System.now();
- for (Asset nObj : newList) {
- Asset oObj = (null == this.oldMap) ? null : this.oldMap.get(nObj.Id);
-
- // 浣滄垚, 纭瀛楁鏈夋病鏈夊彉鍖�
- if (Trigger.isInsert
- || (oObj != null
- && (oObj.RecordTypeId != nObj.RecordTypeId
- || oObj.Asset_loaner_category__c != nObj.Asset_loaner_category__c
- || oObj.AssetManageConfirm__c != nObj.AssetManageConfirm__c
- || oObj.Internal_asset_location__c != nObj.Internal_asset_location__c
- || oObj.Salesdepartment__c != nObj.Salesdepartment__c
- || oObj.OlympusAccShareName__c != nObj.OlympusAccShareName__c
- )
- && (targetCenters.contains(nObj.Internal_asset_location__c)
- || targetProvs.containsKey(nObj.Internal_asset_location__c)
- )
- && !nObj.TransferToOther__c
- )
- ) {
- // 鏄笉鏄鍝佺殑纭
- if (System.Label.Asset_RecordType == nObj.RecordTypeId
- && true == nObj.AssetManageConfirm__c
- && nObj.Asset_loaner_category__c != '鑰楁潗'
- ) {
- // 鍔炰簨澶勫鍝� 鈫� 鍔ㄦ�佽瀹� Asset.AccountId 鐨勫璞�
- if (targetProvs.containsKey(nObj.Internal_asset_location__c)
- && targetDepts.contains(nObj.Salesdepartment__c)
- ) {
- String accShareName = '澶囧搧鍏变韩_'
- + targetProvs.get(nObj.Internal_asset_location__c) + '_' + nObj.Salesdepartment__c.right(6);
- nObj.OlympusAccShareName__c = accShareName;
- assetAccShareNameMap.put(nObj, accShareName);
- }
- else {
- if (AssetHandler.Account_Asset_Id == null) {
- // Static 鍙細鎵ц涓�閬�
- AssetHandler.Account_Asset_Id = [SELECT Id FROM Account WHERE AgentCode_Ext__c =: System.Label.Account_Asset].Id;
- }
- nObj.OlympusAccShareName__c = '';
- nObj.AccountId = AssetHandler.Account_Asset_Id;
- }
- } else {
- // 鏇存柊鎴� 涓嶆槸澶囧搧 鐨勬椂鍊�, 鏇存柊鐨勭▼搴忛噷 瑕� care AccountId
- nObj.OlympusAccShareName__c = '';
- }
- }
+ // assetAccShareNameMap 鐨� Key浼氭湁鍙樺寲
+ // 杩欎釜 for loop鍚� 灏变笉鑳戒娇鐢� assetAccShareNameMap.get(XXXX) 浜�
+ for (Asset nObj : assetAccShareNameMap.keySet()) {
+ String accShareName = assetAccShareNameMap.get(nObj);
+ if (accShareId.containsKey(accShareName)) {
+ // 鎵惧埌 Account 璁惧畾 AccountId, "Olympus绀惧唴 鍏朵粬 澶囧搧" => "Olympus绀惧唴 鍏朵粬 澶囧搧鍏变韩_XXX"
+ nObj.AccountId = accShareId.get(accShareName);
+ } else {
+ // 鎵句笉鍒� AccountId, 鏂板缓 Account, Group, ApexShare
+ insertAccShareNameSet.add(accShareName);
}
+ }
+ }
+ if (insertAccShareNameSet.size() > 0) {
+ // AssetHandler.futureInsertAccShare(JSON.serialize(insertAccShareNameSet), execNow);
+ System.enqueueJob(
+ new MyQueueableClass(JSON.serialize(insertAccShareNameSet), execNow)
+ );
+ }
+ }
- // check 鏄笉鏄� accShareName 閮芥湁
- Set<String> insertAccShareNameSet = new Set<String>();
- if (assetAccShareNameMap.size() > 0) {
- Map<String, Id> accShareId = new Map<String, Id>();
- for (Account accShare : [SELECT Id
- , Department_Name__c
- FROM Account
- WHERE RecordTypeId =: System.Label.Department_OTH
- AND Department_Name__c IN: assetAccShareNameMap.values()]) {
- accShareId.put(accShare.Department_Name__c, accShare.Id);
- }
-
- // assetAccShareNameMap 鐨� Key浼氭湁鍙樺寲
- // 杩欎釜 for loop鍚� 灏变笉鑳戒娇鐢� assetAccShareNameMap.get(XXXX) 浜�
- for (Asset nObj : assetAccShareNameMap.keySet()) {
- String accShareName = assetAccShareNameMap.get(nObj);
- if (accShareId.containsKey(accShareName)) {
- // 鎵惧埌 Account 璁惧畾 AccountId, "Olympus绀惧唴 鍏朵粬 澶囧搧" => "Olympus绀惧唴 鍏朵粬 澶囧搧鍏变韩_XXX"
- nObj.AccountId = accShareId.get(accShareName);
- }
- else {
- // 鎵句笉鍒� AccountId, 鏂板缓 Account, Group, ApexShare
- insertAccShareNameSet.add(accShareName);
- }
- }
- }
- if (insertAccShareNameSet.size() > 0) {
- // AssetHandler.futureInsertAccShare(JSON.serialize(insertAccShareNameSet), execNow);
- System.enqueueJob(new MyQueueableClass(JSON.serialize(insertAccShareNameSet), execNow));
- }
+ /**
+ * 鏂板缓 澶囧搧鍏变韩_XXX 瀹㈡埛鏁版嵁
+ * @param insertAccShareNameJson Json String of List<String> ["澶囧搧鍏变韩_XXX", "澶囧搧鍏变韩_YYY"]
+ */
+ private static void insertAccShare(
+ String insertAccShareNameJson,
+ Datetime execNow
+ ) {
+ Set<String> insertAccShareNameSet = (Set<String>) JSON.deserialize(
+ insertAccShareNameJson,
+ Set<String>.class
+ );
+ if (insertAccShareNameSet.isEmpty()) {
+ return;
}
- /**
- * 鏂板缓 澶囧搧鍏变韩_XXX 瀹㈡埛鏁版嵁
- * @param insertAccShareNameJson Json String of List<String> ["澶囧搧鍏变韩_XXX", "澶囧搧鍏变韩_YYY"]
- */
- private static void insertAccShare(String insertAccShareNameJson, Datetime execNow) {
- Set<String> insertAccShareNameSet = (Set<String>) JSON.deserialize(insertAccShareNameJson, Set<String>.class);
- if (insertAccShareNameSet.isEmpty()) { return; }
-
- // Olympus绀惧唴 鍏朵粬
- List<Account> olympusAccount_OtherDC;
- try {
- olympusAccount_OtherDC = [SELECT Id, ParentId
- FROM Account
- WHERE Parent.AgentCode_Ext__c = '9999999' AND Department_Class_Name__c = '鍏朵粬'
- FOR Update];
- } catch (Exception e) {
- System.enqueueJob(new MyQueueableClass(insertAccShareNameJson, execNow));
- return;
- }
-
- List<Account> isInsertedList = [SELECT Id, Department_Name__c
- FROM Account
- WHERE ParentId =: olympusAccount_OtherDC[0].Id
- AND Department_Name__c IN: insertAccShareNameSet];
- if (isInsertedList.size() > 0) {
- Map<String, Account> insertedAccount = new Map<String, Account>();
- for (Account insertedAcc : isInsertedList) {
- insertedAccount.put(insertedAcc.Department_Name__c, insertedAcc);
- insertAccShareNameSet.remove(insertedAcc.Department_Name__c);
- }
- // Update Asset.AccountId
- AssetHandler.updateAssetAccount(insertedAccount, execNow);
- }
-
-
- if (insertAccShareNameSet.size() > 0) {
- Map<String, Account> insertAccount = new Map<String, Account>();
- for (String accShareName : insertAccShareNameSet) {
- insertAccount.put(accShareName, new Account(
- Name = '*',
- Hospital__c = olympusAccount_OtherDC[0].ParentId,
- ParentId = olympusAccount_OtherDC[0].Id,
- Department_Class__c = olympusAccount_OtherDC[0].Id,
- Other_dept_category__c = '鍏朵粬绉戝',
- Department_Name__c = accShareName,
- OwnerId = System.Label.Batch_User_Id,
- RecordTypeId = System.Label.Department_OTH
- ));
- }
- AssetHandler.insertAccGrantShare(insertAccount, execNow);
- }
+ // Olympus绀惧唴 鍏朵粬
+ List<Account> olympusAccount_OtherDC;
+ try {
+ olympusAccount_OtherDC = [
+ SELECT Id, ParentId
+ FROM Account
+ WHERE
+ Parent.AgentCode_Ext__c = '9999999'
+ AND Department_Class_Name__c = '鍏朵粬'
+ FOR UPDATE
+ ];
+ } catch (Exception e) {
+ System.enqueueJob(new MyQueueableClass(insertAccShareNameJson, execNow));
+ return;
}
- private static void insertAccGrantShare(Map<String, Account> insertAccountMap, Datetime execNow) {
- if (insertAccountMap.isEmpty()) { return; }
- Set<String> accShareNameSet = insertAccountMap.keySet();
- // insert Account鐨勬椂鍊�, 璺宠繃 NFM001
- // OLY_OCM-1230 闇�瑕佹墽琛孨FM001Trigger
- // ControllerUtil.EscapeNFM001Trigger = true;
- insert insertAccountMap.values();
-
- Map<String, Group> insertGroup = new Map<String, Group>();
- Map<String, Group> groupNameMap = new Map<String, Group>();
- for (String accShareName : accShareNameSet) {
- insertGroup.put(accShareName, new Group(
- Name = accShareName
- ));
- }
-
- // Check 鏈夋病鏈� Group
- for (Group grp : [SELECT Id, Name FROM Group WHERE Type = 'Regular' AND Name IN: accShareNameSet]) {
- // 宸茬粡鏈塆roup 鐨勮瘽 涓嶇敤 insert
- insertGroup.remove(grp.Name);
- groupNameMap.put(grp.Name, grp);
- }
- if (insertGroup.size() > 0) {
- insert insertGroup.values();
- // groupNameMap 鍚� 鎵�鏈� accShareNameSet 鐨� Group, 骞朵笖 閮芥湁 Id
- groupNameMap.putAll(insertGroup);
- }
-
- // 璧� Account 鍏变韩鏉冮檺
- List<AccountShare> insertShareList = new List<AccountShare>();
- for (String accShareName : accShareNameSet) {
- insertShareList.add(new AccountShare(
- UserOrGroupId = groupNameMap.get(accShareName).Id,
- AccountId = insertAccountMap.get(accShareName).Id,
- AccountAccessLevel = 'Edit',
- OpportunityAccessLevel = 'None'
- ));
- }
- insert insertShareList;
- // Update Asset.AccountId
- AssetHandler.updateAssetAccount(insertAccountMap, execNow);
+ List<Account> isInsertedList = [
+ SELECT Id, Department_Name__c
+ FROM Account
+ WHERE
+ ParentId = :olympusAccount_OtherDC[0].Id
+ AND Department_Name__c IN :insertAccShareNameSet
+ ];
+ if (isInsertedList.size() > 0) {
+ Map<String, Account> insertedAccount = new Map<String, Account>();
+ for (Account insertedAcc : isInsertedList) {
+ insertedAccount.put(insertedAcc.Department_Name__c, insertedAcc);
+ insertAccShareNameSet.remove(insertedAcc.Department_Name__c);
+ }
+ // Update Asset.AccountId
+ AssetHandler.updateAssetAccount(insertedAccount, execNow);
}
- private static void updateAssetAccount(Map<String, Account> accShareNameAccountMap, Datetime execNow) {
- if (accShareNameAccountMap.isEmpty()) { return; }
- Set<String> accShareNameSet = accShareNameAccountMap.keySet();
+ if (insertAccShareNameSet.size() > 0) {
+ Map<String, Account> insertAccount = new Map<String, Account>();
+ for (String accShareName : insertAccShareNameSet) {
+ insertAccount.put(
+ accShareName,
+ new Account(
+ Name = '*',
+ Hospital__c = olympusAccount_OtherDC[0].ParentId,
+ ParentId = olympusAccount_OtherDC[0].Id,
+ Department_Class__c = olympusAccount_OtherDC[0].Id,
+ Other_dept_category__c = '鍏朵粬绉戝',
+ Department_Name__c = accShareName,
+ OwnerId = System.Label.Batch_User_Id,
+ RecordTypeId = System.Label.Department_OTH
+ )
+ );
+ }
+ AssetHandler.insertAccGrantShare(insertAccount, execNow);
+ }
+ }
- List<Asset> updAssetAccount = new List<Asset>();
- for (Asset nObj : [SELECT Id, OlympusAccShareName__c, AccountId
- FROM Asset
- WHERE OlympusAccShareSameFlag__c = '0'
- AND OlympusAccShareName__c IN: accShareNameSet
- AND LastModifiedDate >=: execNow]) {
- nObj.AccountId = accShareNameAccountMap.get(nObj.OlympusAccShareName__c).Id;
- updAssetAccount.add(nObj);
- }
- update updAssetAccount;
+ private static void insertAccGrantShare(
+ Map<String, Account> insertAccountMap,
+ Datetime execNow
+ ) {
+ if (insertAccountMap.isEmpty()) {
+ return;
+ }
+ Set<String> accShareNameSet = insertAccountMap.keySet();
+ // insert Account鐨勬椂鍊�, 璺宠繃 NFM001
+ // OLY_OCM-1230 闇�瑕佹墽琛孨FM001Trigger
+ // ControllerUtil.EscapeNFM001Trigger = true;
+ insert insertAccountMap.values();
+
+ Map<String, Group> insertGroup = new Map<String, Group>();
+ Map<String, Group> groupNameMap = new Map<String, Group>();
+ for (String accShareName : accShareNameSet) {
+ insertGroup.put(accShareName, new Group(Name = accShareName));
}
- @TestVisible
- class MyQueueableClass implements Queueable {
- String insertAccShareNameJson;
- Datetime execNow;
-
- public MyQueueableClass(String insertAccShareNameJson, Datetime execNow) {
- this.insertAccShareNameJson = insertAccShareNameJson;
- this.execNow = execNow;
- }
-
- public void execute(QueueableContext context) {
- AssetHandler.insertAccShare(insertAccShareNameJson, execNow);
- }
+ // Check 鏈夋病鏈� Group
+ for (Group grp : [
+ SELECT Id, Name
+ FROM Group
+ WHERE Type = 'Regular' AND Name IN :accShareNameSet
+ ]) {
+ // 宸茬粡鏈塆roup 鐨勮瘽 涓嶇敤 insert
+ insertGroup.remove(grp.Name);
+ groupNameMap.put(grp.Name, grp);
}
-}
\ No newline at end of file
+ if (insertGroup.size() > 0) {
+ insert insertGroup.values();
+ // groupNameMap 鍚� 鎵�鏈� accShareNameSet 鐨� Group, 骞朵笖 閮芥湁 Id
+ groupNameMap.putAll(insertGroup);
+ }
+
+ // 璧� Account 鍏变韩鏉冮檺
+ List<AccountShare> insertShareList = new List<AccountShare>();
+ for (String accShareName : accShareNameSet) {
+ insertShareList.add(
+ new AccountShare(
+ UserOrGroupId = groupNameMap.get(accShareName).Id,
+ AccountId = insertAccountMap.get(accShareName).Id,
+ AccountAccessLevel = 'Edit',
+ OpportunityAccessLevel = 'None'
+ )
+ );
+ }
+ insert insertShareList;
+ // Update Asset.AccountId
+ AssetHandler.updateAssetAccount(insertAccountMap, execNow);
+ }
+
+ private static void updateAssetAccount(
+ Map<String, Account> accShareNameAccountMap,
+ Datetime execNow
+ ) {
+ if (accShareNameAccountMap.isEmpty()) {
+ return;
+ }
+ Set<String> accShareNameSet = accShareNameAccountMap.keySet();
+
+ List<Asset> updAssetAccount = new List<Asset>();
+ for (Asset nObj : [
+ SELECT Id, OlympusAccShareName__c, AccountId
+ FROM Asset
+ WHERE
+ OlympusAccShareSameFlag__c = '0'
+ AND OlympusAccShareName__c IN :accShareNameSet
+ AND LastModifiedDate >= :execNow
+ ]) {
+ nObj.AccountId = accShareNameAccountMap.get(nObj.OlympusAccShareName__c)
+ .Id;
+ updAssetAccount.add(nObj);
+ }
+ update updAssetAccount;
+ }
+
+ @TestVisible
+ class MyQueueableClass implements Queueable {
+ String insertAccShareNameJson;
+ Datetime execNow;
+
+ public MyQueueableClass(String insertAccShareNameJson, Datetime execNow) {
+ this.insertAccShareNameJson = insertAccShareNameJson;
+ this.execNow = execNow;
+ }
+
+ public void execute(QueueableContext context) {
+ AssetHandler.insertAccShare(insertAccShareNameJson, execNow);
+ }
+ }
+}
diff --git a/force-app/main/default/classes/AssetHandler.cls-meta.xml b/force-app/main/default/classes/AssetHandler.cls-meta.xml
index d219ea1..bdcee66 100644
--- a/force-app/main/default/classes/AssetHandler.cls-meta.xml
+++ b/force-app/main/default/classes/AssetHandler.cls-meta.xml
@@ -1,5 +1,5 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8" ?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
- <apiVersion>35.0</apiVersion>
+ <apiVersion>50.0</apiVersion>
<status>Active</status>
</ApexClass>
diff --git a/force-app/main/default/classes/Batch_FixAttachmentToFiles.cls b/force-app/main/default/classes/Batch_FixAttachmentToFiles.cls
index 749b18b..e7b7f7a 100644
--- a/force-app/main/default/classes/Batch_FixAttachmentToFiles.cls
+++ b/force-app/main/default/classes/Batch_FixAttachmentToFiles.cls
@@ -1,57 +1,69 @@
-global without sharing class Batch_FixAttachmentToFiles implements Database.Batchable<sObject>{
- // Id batchJobId = Database.executeBatch(new Batch_FixAttachmentToFiles(Datetime.newInstance(2023, 5, 20, 8, 0, 0),'Consumable_order__c'),2000);
- private Datetime endDate = null;
- private String objectApiName = null;
- public Batch_FixAttachmentToFiles(Datetime setTime,String objectType) {
- endDate = setTime;
- objectApiName = objectType;
+global without sharing class Batch_FixAttachmentToFiles implements Database.Batchable<sObject> {
+ // Id batchJobId = Database.executeBatch(new Batch_FixAttachmentToFiles('Consumable_order__c',Datetime.newInstance(2023, 1, 1, 8, 0, 0),Datetime.newInstance(2024, 1, 1, 8, 0, 0)),2000);
+ private Datetime creStartDate = null;
+ private Datetime creEndDate = null;
+ private String objectApiName = null;
+ private Set<String> parentIds = new Set<String>(); //Add by Li Jun 20230703
+ public Batch_FixAttachmentToFiles(
+ String objectType,
+ Datetime startTime,
+ Datetime endTime
+ ) {
+ creStartDate = startTime;
+ creEndDate = endTime;
+ objectApiName = objectType;
+ }
+ //Add by Li Jun 20230703 Start
+ public Batch_FixAttachmentToFiles(Set<String> parentIds) {
+ this.parentIds = parentIds;
+ }
+ //Add by Li Jun 20230703 End
+ global Database.QueryLocator start(Database.BatchableContext BC) {
+ String queryObject = 'SELECT Id, Name, OwnerId, ParentId, Parent.Name, Parent.Type, Body, CreatedDate, CreatedById FROM Attachment WHERE Parent.Type =:objectApiName AND CreatedDate >=:creStartDate AND CreatedDate <:creEndDate Order by CreatedDate ASC';
+ if (parentIds.size() > 0) {
+ queryObject = 'SELECT Id, Name, OwnerId, ParentId, Parent.Name, Parent.Type, Body, CreatedDate, CreatedById FROM Attachment WHERE ParentId in:parentIds';
}
+ return Database.getQueryLocator(queryObject);
+ }
- global Database.QueryLocator start(Database.BatchableContext BC) {
- String queryObject = 'SELECT Id FROM ' + objectApiName + ' WHERE CreatedDate >=:endDate' + ' order by CreatedDate desc';
- System.debug('queryObject:' + queryObject);
- return Database.getQueryLocator(queryObject);//鍙栨寚瀹歄bject涓嬮潰鐨処d鎴栬�呭鐞嗗叏閮�
+ global void execute(Database.BatchableContext BC, List<Attachment> scope) {
+ List<ContentVersion> insertContents = new List<ContentVersion>();
+ Map<string, id> nameParentMaps = new Map<string, id>();
+ for (Attachment att : scope) {
+ nameParentMaps.put(att.Name, att.ParentId);
+ ContentVersion cVersion = new ContentVersion();
+ cVersion.ContentLocation = 'S'; //S-Document is in Salesforce. E-Document is outside of Salesforce. L-Document is on a Social Netork.
+ cVersion.PathOnClient = att.Name; //File name with extention
+ cVersion.Origin = 'C'; //C-Content Origin. H-Chatter Origin.
+ cVersion.Title = att.Name; //Name of the file
+ cVersion.VersionData = att.Body; //File content
+ insertContents.add(cVersion);
}
-
- global void execute(Database.BatchableContext BC, List<sObject> scope) {
- Set<Id> setId = new Set<Id>();
- for(sObject sc: scope){
- setId.add(sc.Id);
- }
- List<ContentVersion> insertContents = new List<ContentVersion>();
- Map<string,id> nameParentMaps = new Map<string,id>();
- for (Attachment att : [select Id,Name ,OwnerId,ParentId, Body, CreatedById from Attachment where ParentId in: setId Order by Name desc]) {
- nameParentMaps.put(att.name, att.ParentId);
- ContentVersion cVersion = new ContentVersion();
- cVersion.ContentLocation = 'S'; //S-Document is in Salesforce. E-Document is outside of Salesforce. L-Document is on a Social Netork.
- cVersion.PathOnClient = att.Name; //File name with extention
- cVersion.Origin = 'C'; //C-Content Origin. H-Chatter Origin.
- cVersion.Title = att.Name; //Name of the file
- cVersion.VersionData = att.Body; //File content
- insertContents.add(cVersion);
- }
- if(insertContents.isEmpty()){
- return;
- }
- Insert insertContents;
- set<Id> contentIds = new set<Id>();
- for(ContentVersion cv : insertContents){
- contentIds.add(cv.id);
- }
- List<ContentVersion> conDocuments = [SELECT ContentDocumentId, Title FROM ContentVersion WHERE Id in: contentIds];
- List<ContentDocumentLink> insertDocLinks = new List<ContentDocumentLink>();
- for(ContentVersion cv : conDocuments){
- ContentDocumentLink cDocLink = new ContentDocumentLink();
- cDocLink.ContentDocumentId = cv.ContentDocumentId; //Add ContentDocumentId
- cDocLink.LinkedEntityId = nameParentMaps.get(cv.Title); //Add attachment parentId
- cDocLink.ShareType = 'V'; //V - Viewer permission. C - Collaborator permission. I - Inferred permission.
- cDocLink.Visibility = 'AllUsers';
- insertDocLinks.add(cDocLink);
- }
- Insert insertDocLinks;
+ if (insertContents.isEmpty()) {
+ return;
}
-
- global void finish(Database.BatchableContext BC) {
-
+ insert insertContents;
+ set<Id> contentIds = new Set<Id>();
+ for (ContentVersion cv : insertContents) {
+ contentIds.add(cv.id);
}
-}
\ No newline at end of file
+ List<ContentVersion> conDocuments = [
+ SELECT ContentDocumentId, Title
+ FROM ContentVersion
+ WHERE Id IN :contentIds
+ ];
+ List<ContentDocumentLink> insertDocLinks = new List<ContentDocumentLink>();
+ for (ContentVersion cv : conDocuments) {
+ ContentDocumentLink cDocLink = new ContentDocumentLink();
+ cDocLink.ContentDocumentId = cv.ContentDocumentId; //Add ContentDocumentId
+ cDocLink.LinkedEntityId = nameParentMaps.get(cv.Title); //Add attachment parentId
+ cDocLink.ShareType = 'V'; //V - Viewer permission. C - Collaborator permission. I - Inferred permission.
+ cDocLink.Visibility = 'AllUsers';
+ insertDocLinks.add(cDocLink);
+ }
+ insert insertDocLinks;
+ }
+
+ global void finish(Database.BatchableContext BC) {
+ }
+}
diff --git a/force-app/main/default/classes/DealerInquiryModifyStateControllerTest.cls b/force-app/main/default/classes/DealerInquiryModifyStateControllerTest.cls
index 9832e45..b1f09b4 100644
--- a/force-app/main/default/classes/DealerInquiryModifyStateControllerTest.cls
+++ b/force-app/main/default/classes/DealerInquiryModifyStateControllerTest.cls
@@ -1,420 +1,446 @@
@isTest
private class DealerInquiryModifyStateControllerTest {
- @TestSetup static void init() {
- List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
- if (rectCo.size() == 0) {
- return;
- }
- List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
- if (rectSct.size() == 0) {
- return;
- }
- List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '瑷虹檪绉� 娑堝寲绉�'];
- if (rectDpt.size() == 0) {
- return;
- }
-
- // 銉嗐偣銉堛儑銉笺偪
-
- Account company = new Account();
- company.RecordTypeId = rectCo[0].Id;
- company.Name = 'NFM007TestCompany';
- insert company;
- Account section = new Account();
- section.RecordTypeId = rectSct[0].Id;
- section.Name = '*';
- section.Department_Class_Label__c = '娑堝寲绉�';
- section.ParentId = company.Id;
- section.Hospital_Department_Class__c = company.Id;
- insert section;
- // Test.startTest();
- Account depart = new Account();
- depart.RecordTypeId = rectDpt[0].Id;
- depart.Name = '*';
- depart.Department_Name__c = 'NFM007TestDepart';
- depart.ParentId = section.Id;
- depart.Department_Class__c = section.Id;
- depart.Hospital__c = company.Id;
- insert depart;
-
- Opportunity opp = new Opportunity();
- opp.AccountId = depart.Id;
- opp.Department_Class__c = section.Id;
- opp.Hospital__c = company.Id;
- opp.SAP_Send_OK__c = false;
- opp.Name = 'GZ-SP-NFM007_1';
- opp.Trade__c = '鍐呰部';
- opp.StageName = '寮曞悎';
- opp.CloseDate = date.newinstance(2022, 11, 30);
- opp.Stock_apply_status__c = '鐢宠涓�';
- insert opp;
- Test.startTest();
- Account account2 = new Account();
- account2.Name = 'test1缁忛攢鍟�';
- account2.RecordTypeId = '01210000000Qem1';
- insert account2;
-
- Contact contact1 = new Contact();
- contact1.AccountId = account2.Id;
- contact1.FirstName = '璨换鑰�';
- contact1.LastName = 'test1鍖婚櫌';
- contact1.Agency_User__c = true;
- insert contact1;
- List<Contact> contactlist = [select Id, FirstName
- from Contact
- ];
-
- System.assertEquals('璨换鑰�', contactlist[0].FirstName);
-
-
-
- //
- User user = new User();
- Profile p = [select Id from Profile where Name = '901_缁忛攢鍟嗘椿鍔ㄧ郴缁�'];
- user.ProfileId = p.Id;
- user.ContactId = contact1.Id;
- user.FirstName = '銉︺兗銈躲兗';
- user.LastName = '銉嗐偣銉�';
- user.Email = 'test_user@example.com';
- user.emailencodingkey = 'UTF-8';
- user.languagelocalekey = 'zh_CN';
- user.localesidkey = 'ja_JP';
- user.timezonesidkey = 'Asia/Shanghai';
- user.Username = 'test_user@example.com';
- user.Alias = '銉嗐儲';
- user.CommunityNickname = '銉嗐偣銉堛儲銉笺偠銉�';
- user.SalesManager__c = UserInfo.getUserId();
-
- insert user;
- List<user> users = [select Id, Name, LastName, FirstName from User where LastName = '銉嗐偣銉�'];
- //
-
- Agency_Hospital_Link__c agency_hospital_link = new Agency_Hospital_Link__c();
- agency_hospital_link.Name = 'test1浠g悊搴楀尰闄�';
- agency_hospital_link.Hospital__c = company.Id;
- agency_hospital_link.Agency__c = account2.Id;
- agency_hospital_link.Agency_Campaign_Obj__c = true;
- agency_hospital_link.OwnerId = user.Id;
- insert agency_hospital_link;
- //
-
- //System.assertEquals('銉嗐偣銉�',users[0].LastName);
- System.assertEquals('銉︺兗銈躲兗', users[0].FirstName );
-
- Id rtId = [select Id, DeveloperName from RecordType where IsActive = true and SobjectType = 'Agency_Opportunity__c' and DeveloperName = 'Opportunity'].Id;
- // Schema.SobjectType.Agency_Opportunity__c.getRecordTypeInfosByName().get('璇环').getRecordTypeId();
- Agency_opportunity__c agency_opportunity = new Agency_opportunity__c();
- agency_opportunity.RecordTypeId = rtId;
- agency_opportunity.Name = '寮曞悎1';
- agency_opportunity.Hospital_Target__c = company.Id;
- agency_opportunity.Agency__c = depart.Id;
- agency_opportunity.Agency_Hospital__c = agency_hospital_link.Id;
- agency_opportunity.StageName__c = '杩樻病鐢宠棰勭畻';
- agency_opportunity.OwnerId = user.Id;
- agency_opportunity.Change_To_Opportunity_T__c = '::CF-HQ290I';
- agency_opportunity.Sales_Manager__c =UserInfo.getUserId();
-
- insert agency_opportunity;
- Test.stopTest();
-
+ @TestSetup
+ static void init() {
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ List<RecordType> rectSct = [
+ SELECT Id
+ FROM RecordType
+ WHERE
+ IsActive = TRUE
+ AND SobjectType = 'Account'
+ AND Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'
+ ];
+ if (rectSct.size() == 0) {
+ return;
+ }
+ List<RecordType> rectDpt = [
+ SELECT Id
+ FROM RecordType
+ WHERE
+ IsActive = TRUE
+ AND SobjectType = 'Account'
+ AND Name = '瑷虹檪绉� 娑堝寲绉�'
+ ];
+ if (rectDpt.size() == 0) {
+ return;
}
- static testMethod void myUnitTest_SortKey() {
- Test.startTest();
- Test.setMock(WebServiceMock.class, new NFMTest_Mock());
- Test.stopTest();
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
-
+ // 銉嗐偣銉堛儑銉笺偪
- // 鍒濆鍖栨祴璇�
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
-
-
- controller.init();
- //System.assertEquals(1, controller.oppRecords.size());楠岃瘉棰勬湡鍊煎拰缁撴灉鍊兼纭��
- // 鎺掑簭娴嬭瘯
- // Test.startTest();
- // Test.stopTest();
- controller.sortKey = '1';
- controller.sortKey = '1';
- controller.sortTable();
- controller.sortKey = '1';
- controller.sortKey = '0';
- controller.sortTable();
- // Test.stopTest();
- }
- static testMethod void myUnitTest_AccSearchAndAoosearch() {
- Test.startTest();
- Test.setMock(WebServiceMock.class, new NFMTest_Mock());
- Test.stopTest();
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- // 鍒濆鍖栨祴璇�
- // Test.startTest();
-
- controller.init();
- //鏂囨湰杈撳叆妗嗘绱�
- //1:缁忛攢鍟嗗尰闄�
- controller.accSearch = '娲礊鍘夸腑鍖婚櫌';
- controller.chick();
- //2:鎷呭綋浜�
- controller.aooSearch = '鐜嬪鐞�';
- controller.chick();
- // Test.stopTest();
- }
- static testMethod void myUnitTest_numtext_Equals() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- // 鍒濆鍖栨祴璇�
- Test.startTest();
- controller.init();
- // 妫�绱㈡暟鎹瓧娈垫祴璇�
- //1:妫�绱㈢粡閿�鍟嗙紪鐮� = 151P-00001327
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = '=';
- controller.numtext = '151P-00001327';
- controller.chick();
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = '<>';
- controller.numtext = '151P-00001327';
- controller.chick();
- Test.stopTest();
- }
- static testMethod void myUnitTest_numtext_Starts_with() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- // 鍒濆鍖栨祴璇�
- Test.startTest();
- controller.init();
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = '<';
- controller.numtext = '151P-00001327';
- controller.chick();
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = 'starts with';
- controller.numtext = '151P-00001327';
- controller.chick();
- Test.stopTest();
- }
- static testMethod void myUnitTest_contains() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- // 鍒濆鍖栨祴璇�
- Test.startTest();
- controller.init();
- //2:妫�绱㈢粡閿�鍟嗙紪鐮� 鍖呭惈 151P
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = 'contains';
- controller.numtext = '151P';
- controller.chick();
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = 'notcontains';
- controller.numtext = '151P';
- controller.chick();
- Test.stopTest();
- }
- static testMethod void myUnitTest_null_contains() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- // 鍒濆鍖栨祴璇�
- Test.startTest();
- controller.init();
- //3:妫�绱㈡潯浠跺惈绌烘牸
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = 'contains';
- controller.numtext = '151P 150P';
- controller.chick();
- Test.stopTest();
- }
- static testMethod void myUnitTest_null_notcontains() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- // 鍒濆鍖栨祴璇�
- Test.startTest();
- controller.init();
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = 'notcontains';
- controller.numtext = '151P 150P';
- controller.chick();
- Test.stopTest();
- }
- static testMethod void myUnitTest_AllNull_contains() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- // 鍒濆鍖栨祴璇�
- Test.startTest();
- controller.init();
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = 'contains';
- controller.numtext = ' ';
- controller.chick();
- Test.stopTest();
- }
- static testMethod void myUnitTest_AllNull_notcontains() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- // 鍒濆鍖栨祴璇�
- Test.startTest();
- controller.init();
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = 'notcontains';
- controller.numtext = ' ';
- controller.chick();
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = '=';
- controller.numtext = ' ';
- controller.chick();
- Test.stopTest();
- }
- static testMethod void myUnitTest_tarts_with() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- Test.startTest();
- controller.init();
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = '<>';
- controller.numtext = ' ';
- controller.chick();
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = ' starts with ';
- controller.numtext = ' ';
- controller.chick();
- Test.stopTest();
- }
- static testMethod void myUnitTest_Equals_D() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- // 鍒濆鍖栨祴璇�
- Test.startTest();
- controller.init();
- //4:妫�绱㈡潯浠跺惈閫楀彿
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = '=';
- controller.numtext = '151P-00001327,151P-00001343';
- controller.chick();
- controller.numtext1 = 'Agency_Opportunity_No__c';
- controller.numtext2 = '<>';
- controller.numtext = '151P-00001327,151P-00001343';
- controller.chick();
- Test.stopTest();
- }
- static testMethod void myUnitTestTime01() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- // 鍒濆鍖栨祴璇�
- Test.startTest();
- controller.init();
- //妫�绱㈡棩鏈熸祴璇�
- controller.tmpAO = new Agency_Opportunity__c();
- controller.tmpBO = new Agency_Opportunity__c();
- controller.timetext1 = 'Created_Day__c';
- controller.timetext2 = '=';
- controller.tmpAO.MaxActivityDate__c = date.valueOf('2018-12-12');
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-12');
- controller.chick();
+ Account company = new Account();
+ company.RecordTypeId = rectCo[0].Id;
+ company.Name = 'NFM007TestCompany';
+ insert company;
+ Account section = new Account();
+ section.RecordTypeId = rectSct[0].Id;
+ section.Name = '*';
+ section.Department_Class_Label__c = '娑堝寲绉�';
+ section.ParentId = company.Id;
+ section.Hospital_Department_Class__c = company.Id;
+ insert section;
+ // Test.startTest();
+ Account depart = new Account();
+ depart.RecordTypeId = rectDpt[0].Id;
+ depart.Name = '*';
+ depart.Department_Name__c = 'NFM007TestDepart';
+ depart.ParentId = section.Id;
+ depart.Department_Class__c = section.Id;
+ depart.Hospital__c = company.Id;
+ insert depart;
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-09');
- controller.chick();
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-19');
- controller.chick();
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-09');
- controller.chick();
- // Test.startTest();
- controller.tmpAO.MaxActivityDate__c = date.valueOf('2018-12-02');
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-12');
- controller.chick();
+ Opportunity opp = new Opportunity();
+ opp.AccountId = depart.Id;
+ opp.Department_Class__c = section.Id;
+ opp.Hospital__c = company.Id;
+ opp.SAP_Send_OK__c = false;
+ opp.Name = 'GZ-SP-NFM007_1';
+ opp.Trade__c = '鍐呰部';
+ opp.StageName = '寮曞悎';
+ opp.CloseDate = Date.today();
+ opp.Stock_apply_status__c = '鐢宠涓�';
+ insert opp;
+ Test.startTest();
+ Account account2 = new Account();
+ account2.Name = 'test1缁忛攢鍟�';
+ account2.RecordTypeId = '01210000000Qem1';
+ insert account2;
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-09');
- controller.chick();
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-19');
- controller.chick();
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-09');
- controller.chick();
- Test.stopTest();
+ Contact contact1 = new Contact();
+ contact1.AccountId = account2.Id;
+ contact1.FirstName = '璨换鑰�';
+ contact1.LastName = 'test1鍖婚櫌';
+ contact1.Agency_User__c = true;
+ insert contact1;
+ List<Contact> contactlist = [
+ SELECT Id, FirstName
+ FROM Contact
+ ];
- }
- static testMethod void myUnitTestTime02() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- // 鍒濆鍖栨祴璇�
- Test.startTest();
- controller.init();
- controller.tmpAO = new Agency_Opportunity__c();
- controller.tmpBO = new Agency_Opportunity__c();
- controller.timetext1 = 'Created_Day__c';
- controller.timetext2 = '=';
- controller.tmpAO.MaxActivityDate__c = date.valueOf('2018-02-12');
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-12');
- controller.chick();
+ System.assertEquals('璨换鑰�', contactlist[0].FirstName);
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-09');
- controller.chick();
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-19');
- controller.chick();
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-09');
- controller.chick();
- // Test.startTest();
- controller.tmpAO.MaxActivityDate__c = date.valueOf('2018-02-02');
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-12');
- controller.chick();
+ //
+ User user = new User();
+ Profile p = [SELECT Id FROM Profile WHERE Name = '901_缁忛攢鍟嗘椿鍔ㄧ郴缁�'];
+ user.ProfileId = p.Id;
+ user.ContactId = contact1.Id;
+ user.FirstName = '銉︺兗銈躲兗';
+ user.LastName = '銉嗐偣銉�';
+ user.Email = 'test_user@example.com';
+ user.emailencodingkey = 'UTF-8';
+ user.languagelocalekey = 'zh_CN';
+ user.localesidkey = 'ja_JP';
+ user.timezonesidkey = 'Asia/Shanghai';
+ user.Username = 'test_user@example.com';
+ user.Alias = '銉嗐儲';
+ user.CommunityNickname = '銉嗐偣銉堛儲銉笺偠銉�';
+ user.SalesManager__c = UserInfo.getUserId();
+ System.runAs(new User(Id = UserInfo.getUserId())) {
+ insert user;
+ }
+ List<user> users = [
+ SELECT Id, Name, LastName, FirstName
+ FROM User
+ WHERE LastName = '銉嗐偣銉�'
+ ];
+ //
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-09');
- controller.chick();
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-19');
- controller.chick();
- controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-09');
- controller.chick();
- Test.stopTest();
+ Agency_Hospital_Link__c agency_hospital_link = new Agency_Hospital_Link__c();
+ agency_hospital_link.Name = 'test1浠g悊搴楀尰闄�';
+ agency_hospital_link.Hospital__c = company.Id;
+ agency_hospital_link.Agency__c = account2.Id;
+ agency_hospital_link.Agency_Campaign_Obj__c = true;
+ agency_hospital_link.OwnerId = user.Id;
+ insert agency_hospital_link;
+ //
- }
- static testMethod void myUnitTestTimeSave() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- Test.startTest();
- controller.init();
- controller.oppRecords[0].changeFlg = '1';
- controller.save();
- Test.stopTest();
- }
- static testMethod void myUnitTestTimeSave_1() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- // 鍒濆鍖栨祴璇�
- Test.startTest();
- controller.init();
- //淇濆瓨鏃剁姸鎬乧hangeFlgRt涓�1
- controller.oppRecords[0].changeFlgRt = '1';
- controller.save();
- Test.stopTest();
- }
- static testMethod void myUnitTestTime_LimitsAndOppCount() {
- PageReference page = new PageReference('/apex/DealerInquiryModifyState');
- System.Test.setCurrentPage(page);
- DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
- // 鍒濆鍖栨祴璇�
- Test.startTest();
- controller.init();
- //鏁版嵁鏄剧ず鏉℃暟
- controller.limits = '10';
- controller.searchOppInner();
- //oppLimit and oppCount
- controller.oppCount = 1000;
- controller.init();
- Test.stopTest();
- }
-}
\ No newline at end of file
+ //System.assertEquals('銉嗐偣銉�',users[0].LastName);
+ System.assertEquals('銉︺兗銈躲兗', users[0].FirstName);
+
+ Id rtId = [
+ SELECT Id, DeveloperName
+ FROM RecordType
+ WHERE
+ IsActive = TRUE
+ AND SobjectType = 'Agency_Opportunity__c'
+ AND DeveloperName = 'Opportunity'
+ ]
+ .Id;
+ // Schema.SobjectType.Agency_Opportunity__c.getRecordTypeInfosByName().get('璇环').getRecordTypeId();
+ Agency_opportunity__c agency_opportunity = new Agency_opportunity__c();
+ agency_opportunity.RecordTypeId = rtId;
+ agency_opportunity.Name = '寮曞悎1';
+ agency_opportunity.Hospital_Target__c = company.Id;
+ agency_opportunity.Agency__c = depart.Id;
+ agency_opportunity.Agency_Hospital__c = agency_hospital_link.Id;
+ agency_opportunity.StageName__c = '杩樻病鐢宠棰勭畻';
+ agency_opportunity.OwnerId = user.Id;
+ agency_opportunity.Change_To_Opportunity_T__c = '::CF-HQ290I';
+ agency_opportunity.Sales_Manager__c = UserInfo.getUserId();
+
+ insert agency_opportunity;
+ Test.stopTest();
+ }
+
+ static testMethod void myUnitTest_SortKey() {
+ Test.startTest();
+ Test.setMock(WebServiceMock.class, new NFMTest_Mock());
+ Test.stopTest();
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+
+ // 鍒濆鍖栨祴璇�
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+
+ controller.init();
+ //System.assertEquals(1, controller.oppRecords.size());楠岃瘉棰勬湡鍊煎拰缁撴灉鍊兼纭��
+ // 鎺掑簭娴嬭瘯
+ // Test.startTest();
+ // Test.stopTest();
+ controller.sortKey = '1';
+ controller.sortKey = '1';
+ controller.sortTable();
+ controller.sortKey = '1';
+ controller.sortKey = '0';
+ controller.sortTable();
+ // Test.stopTest();
+ }
+ static testMethod void myUnitTest_AccSearchAndAoosearch() {
+ Test.startTest();
+ Test.setMock(WebServiceMock.class, new NFMTest_Mock());
+ Test.stopTest();
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ // 鍒濆鍖栨祴璇�
+ // Test.startTest();
+
+ controller.init();
+ //鏂囨湰杈撳叆妗嗘绱�
+ //1:缁忛攢鍟嗗尰闄�
+ controller.accSearch = '娲礊鍘夸腑鍖婚櫌';
+ controller.chick();
+ //2:鎷呭綋浜�
+ controller.aooSearch = '鐜嬪鐞�';
+ controller.chick();
+ // Test.stopTest();
+ }
+ static testMethod void myUnitTest_numtext_Equals() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ // 鍒濆鍖栨祴璇�
+ Test.startTest();
+ controller.init();
+ // 妫�绱㈡暟鎹瓧娈垫祴璇�
+ //1:妫�绱㈢粡閿�鍟嗙紪鐮� = 151P-00001327
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = '=';
+ controller.numtext = '151P-00001327';
+ controller.chick();
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = '<>';
+ controller.numtext = '151P-00001327';
+ controller.chick();
+ Test.stopTest();
+ }
+ static testMethod void myUnitTest_numtext_Starts_with() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ // 鍒濆鍖栨祴璇�
+ Test.startTest();
+ controller.init();
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = '<';
+ controller.numtext = '151P-00001327';
+ controller.chick();
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = 'starts with';
+ controller.numtext = '151P-00001327';
+ controller.chick();
+ Test.stopTest();
+ }
+ static testMethod void myUnitTest_contains() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ // 鍒濆鍖栨祴璇�
+ Test.startTest();
+ controller.init();
+ //2:妫�绱㈢粡閿�鍟嗙紪鐮� 鍖呭惈 151P
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = 'contains';
+ controller.numtext = '151P';
+ controller.chick();
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = 'notcontains';
+ controller.numtext = '151P';
+ controller.chick();
+ Test.stopTest();
+ }
+ static testMethod void myUnitTest_null_contains() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ // 鍒濆鍖栨祴璇�
+ Test.startTest();
+ controller.init();
+ //3:妫�绱㈡潯浠跺惈绌烘牸
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = 'contains';
+ controller.numtext = '151P 150P';
+ controller.chick();
+ Test.stopTest();
+ }
+ static testMethod void myUnitTest_null_notcontains() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ // 鍒濆鍖栨祴璇�
+ Test.startTest();
+ controller.init();
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = 'notcontains';
+ controller.numtext = '151P 150P';
+ controller.chick();
+ Test.stopTest();
+ }
+ static testMethod void myUnitTest_AllNull_contains() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ // 鍒濆鍖栨祴璇�
+ Test.startTest();
+ controller.init();
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = 'contains';
+ controller.numtext = ' ';
+ controller.chick();
+ Test.stopTest();
+ }
+ static testMethod void myUnitTest_AllNull_notcontains() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ // 鍒濆鍖栨祴璇�
+ Test.startTest();
+ controller.init();
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = 'notcontains';
+ controller.numtext = ' ';
+ controller.chick();
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = '=';
+ controller.numtext = ' ';
+ controller.chick();
+ Test.stopTest();
+ }
+ static testMethod void myUnitTest_tarts_with() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ Test.startTest();
+ controller.init();
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = '<>';
+ controller.numtext = ' ';
+ controller.chick();
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = ' starts with ';
+ controller.numtext = ' ';
+ controller.chick();
+ Test.stopTest();
+ }
+ static testMethod void myUnitTest_Equals_D() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ // 鍒濆鍖栨祴璇�
+ Test.startTest();
+ controller.init();
+ //4:妫�绱㈡潯浠跺惈閫楀彿
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = '=';
+ controller.numtext = '151P-00001327,151P-00001343';
+ controller.chick();
+ controller.numtext1 = 'Agency_Opportunity_No__c';
+ controller.numtext2 = '<>';
+ controller.numtext = '151P-00001327,151P-00001343';
+ controller.chick();
+ Test.stopTest();
+ }
+ static testMethod void myUnitTestTime01() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ // 鍒濆鍖栨祴璇�
+ Test.startTest();
+ controller.init();
+ //妫�绱㈡棩鏈熸祴璇�
+ controller.tmpAO = new Agency_Opportunity__c();
+ controller.tmpBO = new Agency_Opportunity__c();
+ controller.timetext1 = 'Created_Day__c';
+ controller.timetext2 = '=';
+ controller.tmpAO.MaxActivityDate__c = date.valueOf('2018-12-12');
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-12');
+ controller.chick();
+
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-09');
+ controller.chick();
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-19');
+ controller.chick();
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-09');
+ controller.chick();
+ // Test.startTest();
+ controller.tmpAO.MaxActivityDate__c = date.valueOf('2018-12-02');
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-12');
+ controller.chick();
+
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-09');
+ controller.chick();
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-19');
+ controller.chick();
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-09');
+ controller.chick();
+ Test.stopTest();
+ }
+ static testMethod void myUnitTestTime02() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ // 鍒濆鍖栨祴璇�
+ Test.startTest();
+ controller.init();
+ controller.tmpAO = new Agency_Opportunity__c();
+ controller.tmpBO = new Agency_Opportunity__c();
+ controller.timetext1 = 'Created_Day__c';
+ controller.timetext2 = '=';
+ controller.tmpAO.MaxActivityDate__c = date.valueOf('2018-02-12');
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-12');
+ controller.chick();
+
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-09');
+ controller.chick();
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-19');
+ controller.chick();
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-09');
+ controller.chick();
+ // Test.startTest();
+ controller.tmpAO.MaxActivityDate__c = date.valueOf('2018-02-02');
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-12');
+ controller.chick();
+
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-12-09');
+ controller.chick();
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-19');
+ controller.chick();
+ controller.tmpBO.MaxActivityDate__c = date.valueOf('2018-02-09');
+ controller.chick();
+ Test.stopTest();
+ }
+ static testMethod void myUnitTestTimeSave() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ Test.startTest();
+ controller.init();
+ controller.oppRecords[0].changeFlg = '1';
+ controller.save();
+ Test.stopTest();
+ }
+ static testMethod void myUnitTestTimeSave_1() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ // 鍒濆鍖栨祴璇�
+ Test.startTest();
+ controller.init();
+ //淇濆瓨鏃剁姸鎬乧hangeFlgRt涓�1
+ controller.oppRecords[0].changeFlgRt = '1';
+ controller.save();
+ Test.stopTest();
+ }
+ static testMethod void myUnitTestTime_LimitsAndOppCount() {
+ PageReference page = new PageReference('/apex/DealerInquiryModifyState');
+ System.Test.setCurrentPage(page);
+ DealerInquiryModifyStateController controller = new DealerInquiryModifyStateController();
+ // 鍒濆鍖栨祴璇�
+ Test.startTest();
+ controller.init();
+ //鏁版嵁鏄剧ず鏉℃暟
+ controller.limits = '10';
+ controller.searchOppInner();
+ //oppLimit and oppCount
+ controller.oppCount = 1000;
+ controller.init();
+ Test.stopTest();
+ }
+}
diff --git a/force-app/main/default/classes/LayoutDescriberHelper.cls b/force-app/main/default/classes/LayoutDescriberHelper.cls
index 388a57d..512909c 100644
--- a/force-app/main/default/classes/LayoutDescriberHelper.cls
+++ b/force-app/main/default/classes/LayoutDescriberHelper.cls
@@ -71,7 +71,6 @@
fieldAPIToLabelMap = new Map<String, String>();
layoutSections = new List<LayoutSection>();
String theRespBody = getLayoutSchema(recordTypeId, objectType, userMode);
- System.debug('theRespBody = ' + theRespBody);
Map<String, Object> layoutSection = (Map<String, Object>) JSON.deserializeUntyped(
theRespBody
);
@@ -302,7 +301,6 @@
req.setHeader('Authorization', 'Bearer ' + UserInfo.getsessionid());
}
Http client = new Http();
- System.debug('req = ' + req);
resp = client.send(req);
system.debug('Schema Body:' + JSON.serialize(resp.getBody()));
return resp.getBody();
@@ -359,6 +357,7 @@
}
public static Integer ControllerUtil() {
Integer i = 0;
+
return i;
}
}
diff --git a/force-app/main/default/classes/LexArriveGoodsControllerTest.cls b/force-app/main/default/classes/LexArriveGoodsControllerTest.cls
new file mode 100644
index 0000000..be2e7f1
--- /dev/null
+++ b/force-app/main/default/classes/LexArriveGoodsControllerTest.cls
@@ -0,0 +1,483 @@
+@isTest
+private class LexArriveGoodsControllerTest {
+ @IsTest
+ static void test1() {
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ 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 = 20,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999996'
+ );
+ Account myAccount2 = new Account(
+ Name = 'Testaccount002',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900',
+ Product_Limit_Date__c = 'Test01|2|4,Test02|3|5'
+ );
+ 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',
+ RecordTypeId = '01210000000aMAFAA2',
+ 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',
+ RecordTypeId = '01210000000aMAFAA2',
+ 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.Total_num__c = 3;
+ Order1.OrderNumber_arrived__c = 1;
+ Order1.Delivery_detail_count__c = 1;
+ Order1.Order_ProType__c = 'ET';
+ 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 = 40;
+ 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';
+
+ //鍙栨秷浜у搧
+ 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 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 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 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';
+
+ insert new List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ Orderdet3,
+ Orderdet4,
+ Orderdet5,
+ Orderdet6,
+ Orderdets8
+ };
+
+ List<Consumable_orderdetails__c> cod1 = [
+ SELECT Id
+ FROM Consumable_orderdetails__c
+ WHERE Consumable_order__c = :Order1.Id
+ ];
+ System.assertEquals(1, cod1.size());
+
+ PageReference page = new PageReference(
+ '/apex/ArriveGoods?Esetid=' + Order1.Id
+ );
+
+ System.Test.setCurrentPage(page);
+ ArriveGoodsController Controller = new ArriveGoodsController();
+ //鍒濆鍖栨祴璇�
+ System.Test.startTest();
+ LexArriveGoodsController.Results re = LexArriveGoodsController.init(
+ 'Arr',
+ Order1.Id
+ );
+ String arrControllerStr = re.arrGoodCon;
+ LexArriveGoodsController.searchProduct('', arrControllerStr);
+ re = LexArriveGoodsController.searchProduct(
+ '01049531702003111115120017181000105ZK250BXJRA\n01049531702003111115120017181000105ZK250BXsys\n01049531702003111115120017181000105ZK250BXsun\n01049531702003111115120017181000105ZK250BXJRB\n01049531702003111115120017181000105ZK250BXJRC\n01049531702003111115120017181000105ZK250BX111\n01049531702003111115120017181000105ZK250BXJRD\n01049531702003111115120017181000105ZK250BXJRE\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRG\n01049531702003111115120017181000105ZK250BX123',
+ arrControllerStr
+ );
+ arrControllerStr = re.arrGoodCon;
+ LexArriveGoodsController.arriveGoodsConfim(arrControllerStr);
+ System.Test.stopTest();
+ }
+ }
+
+ @IsTest
+ static void test2() {
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ 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;
+ }
+
+ // 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',
+ RecordTypeId = '01210000000aMAFAA2',
+ 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',
+ RecordTypeId = '01210000000aMAFAA2',
+ 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;
+
+ //杩斿搧璁㈠崟
+
+ 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;
+
+ //鍙戣揣鏄庣粏
+ //娌″嚭搴擄紝娌¢攢鍞紝灏辨槸鍦ㄥ簱
+ 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';
+
+ //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';
+
+ 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';
+ insert new List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ Orderdet3,
+ Orderdet4,
+ Orderdet5,
+ Orderdet6,
+ Orderdet7
+ };
+ ArriveGoodsController Controller = new ArriveGoodsController();
+ System.Test.startTest();
+ Controller.init();
+ Controller.barcode = '01049531702003111115120017181000105ZK250BXAAA\n01049531702003111115120017181000105ZK250BXJRJ\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BX123\n01049531702003111115120017181000105ZK250BX222';
+ Controller.SearchPro();
+ Controller.ArriveGoodsConfim();
+ Controller.UpdateGoodsOfReturn();
+ controller.getinventorysize();
+ LexArriveGoodsController.Results re = LexArriveGoodsController.init(
+ 'Arr',
+ ''
+ );
+ String arrControllerStr = re.arrGoodCon;
+ re = LexArriveGoodsController.searchProduct(
+ '01049531702003111115120017181000105ZK250BXAAA\n01049531702003111115120017181000105ZK250BXJRJ\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BX123\n01049531702003111115120017181000105ZK250BX222',
+ arrControllerStr
+ );
+ arrControllerStr = re.arrGoodCon;
+ LexArriveGoodsController.arriveGoodsConfim(arrControllerStr);
+ LexArriveGoodsController.updateGoodsOfReturn(
+ re.arrGoodCon,
+ JSON.serialize(re.showGoodsofReturnList)
+ );
+ LexArriveGoodsController.ConsumableorderdetailsInfo con = new LexArriveGoodsController.ConsumableorderdetailsInfo();
+ List<LexArriveGoodsController.ConsumableorderdetailsInfo> conList = new List<LexArriveGoodsController.ConsumableorderdetailsInfo>();
+ conList.add(con);
+ LexArriveGoodsController.changeType2(conList);
+ System.Test.stopTest();
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexArriveGoodsControllerTest.cls-meta.xml b/force-app/main/default/classes/LexArriveGoodsControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexArriveGoodsControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexArriveGoodsControllerTest1.cls b/force-app/main/default/classes/LexArriveGoodsControllerTest1.cls
new file mode 100644
index 0000000..15182de
--- /dev/null
+++ b/force-app/main/default/classes/LexArriveGoodsControllerTest1.cls
@@ -0,0 +1,240 @@
+@isTest
+public class LexArriveGoodsControllerTest1 {
+ static void test1() {
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ 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 = 20,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999996'
+ );
+ Account myAccount2 = new Account(
+ Name = 'Testaccount002',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900',
+ Product_Limit_Date__c = 'Test01|2|4,Test02|3|5'
+ );
+ 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',
+ RecordTypeId = '01210000000aMAFAA2',
+ 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',
+ RecordTypeId = '01210000000aMAFAA2',
+ 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.Total_num__c = 3;
+ Order1.OrderNumber_arrived__c = 1;
+ Order1.Delivery_detail_count__c = 1;
+ Order1.Order_ProType__c = 'ET';
+ 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 = 40;
+ 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';
+
+ //鍙栨秷浜у搧
+ 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 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 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 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';
+
+ insert new List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ Orderdet3,
+ Orderdet4,
+ Orderdet5,
+ Orderdet6,
+ Orderdets8
+ };
+
+ List<Consumable_orderdetails__c> cod1 = [
+ SELECT Id
+ FROM Consumable_orderdetails__c
+ WHERE Consumable_order__c = :Order1.Id
+ ];
+ System.assertEquals(1, cod1.size());
+
+ PageReference page = new PageReference(
+ '/apex/ArriveGoods?Esetid=' + Order1.Id
+ );
+
+ System.Test.setCurrentPage(page);
+ ArriveGoodsController Controller = new ArriveGoodsController();
+ //鍒濆鍖栨祴璇�
+ System.Test.startTest();
+ LexArriveGoodsController.Results re = LexArriveGoodsController.init(
+ 'Arr',
+ Order1.Id
+ );
+ String arrControllerStr = re.arrGoodCon;
+ LexArriveGoodsController.searchProduct('', arrControllerStr);
+ re = LexArriveGoodsController.searchProduct(
+ '01049531702003111115120017181000105ZK250BXJRA\n01049531702003111115120017181000105ZK250BXsys\n01049531702003111115120017181000105ZK250BXsun\n01049531702003111115120017181000105ZK250BXJRB\n01049531702003111115120017181000105ZK250BXJRC\n01049531702003111115120017181000105ZK250BX111\n01049531702003111115120017181000105ZK250BXJRD\n01049531702003111115120017181000105ZK250BXJRE\n01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRG\n01049531702003111115120017181000105ZK250BX123',
+ arrControllerStr
+ );
+ arrControllerStr = re.arrGoodCon;
+ LexArriveGoodsController.arriveGoodsConfim(arrControllerStr);
+ System.Test.stopTest();
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexArriveGoodsControllerTest1.cls-meta.xml b/force-app/main/default/classes/LexArriveGoodsControllerTest1.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexArriveGoodsControllerTest1.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexArriveGoodsMainControllerTest.cls b/force-app/main/default/classes/LexArriveGoodsMainControllerTest.cls
new file mode 100644
index 0000000..92892ae
--- /dev/null
+++ b/force-app/main/default/classes/LexArriveGoodsMainControllerTest.cls
@@ -0,0 +1,161 @@
+@istest
+public class LexArriveGoodsMainControllerTest {
+ @IsTest
+ static void lexArriveGoodsMainControllerTest1() {
+ User myUser_test = new User();
+ Account myAccount1;
+ Contact core;
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(currentUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount1;
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '鍖椾含'
+ );
+ insert myUser_test;
+ }
+ System.runAs(myUser_test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ 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(
+ Name = 'OCM_01_001',
+ RecordTypeId = System.Label.RT_ConOrder_Delivery,
+ Order_type__c = '璁㈠崟',
+ Dealer_info__c = myAccount1.Id,
+ Order_ProType__c = 'ET'
+ );
+ Consumable_order__c Order2 = new Consumable_order__c(
+ Name = 'OCM_01_002',
+ RecordTypeId = System.Label.RT_ConOrder_Delivery,
+ Order_type__c = '璁㈠崟',
+ Dealer_info__c = myAccount1.Id,
+ Order_ProType__c = 'ET'
+ );
+ insert new List<Consumable_order__c>{ Order1, Order2 };
+
+ //鏄庣粏1
+ Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c();
+ createDetail.name = 'Too001';
+ createDetail.Consumable_Product__c = pro1.id;
+ createDetail.Dealer_Custom_Price__c = 999.00;
+ createDetail.Consumable_count__c = 3;
+ createDetail.Consumable_order__c = Order1.id;
+ createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
+ insert createDetail;
+ Consumable_orderdetails__c createDetail1 = new Consumable_orderdetails__c();
+ createDetail1.name = 'Too002';
+ createDetail1.Consumable_Product__c = pro2.id;
+ createDetail1.Consumable_order__c = Order2.id;
+ createDetail1.Dealer_Custom_Price__c = 999.00;
+ createDetail1.Consumable_count__c = 4;
+ createDetail1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
+ insert createDetail1;
+
+ //璁㈠崟鏄庣粏
+ Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001001',
+ Consumable_order_minor__c = Order1.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001002',
+ Consumable_order_minor__c = Order2.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro2.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001003',
+ Consumable_order_minor__c = Order1.Id,
+ //Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001004',
+ Consumable_order_minor__c = Order2.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro2.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ insert new List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ Orderdet3,
+ Orderdet4
+ };
+
+ LexArriveGoodsMainController.init();
+ LexArriveGoodsMainController.searchConsumableorderdetails(
+ 'Too001',
+ null,
+ myAccount1.Id,
+ '鍖椾含',
+ 'ET'
+ );
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexArriveGoodsMainControllerTest.cls-meta.xml b/force-app/main/default/classes/LexArriveGoodsMainControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexArriveGoodsMainControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexArriveGsDetailsControllerTest.cls b/force-app/main/default/classes/LexArriveGsDetailsControllerTest.cls
new file mode 100644
index 0000000..7308c89
--- /dev/null
+++ b/force-app/main/default/classes/LexArriveGsDetailsControllerTest.cls
@@ -0,0 +1,249 @@
+@isTest
+public class LexArriveGsDetailsControllerTest {
+ @IsTest
+ static void test1() {
+ User myUser_test = new User();
+ Account myAccount1;
+ Account myAccount2;
+ Contact core;
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(currentUser) {
+ 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)'
+ ];
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 };
+ myAccount2 = new Account(
+ name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id
+ );
+ insert myAccount2;
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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.runAs(MyUser_Test) {
+ StaticParameter.ConsumableAssetHanderTrigger = true;
+ 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 = myAccount2.Id;
+ order1.RecordTypeid = System.Label.RT_ConOrder_Arrive;
+ insert order1;
+
+ Consumable_order__c olyorder = new Consumable_order__c();
+ olyorder.Name = 'OCM_01_001';
+ olyorder.Order_status__c = '鎵瑰噯';
+ olyorder.Order_type__c = '璁㈠崟';
+ olyorder.Dealer_Info__c = myAccount2.Id;
+ olyorder.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ insert olyorder;
+
+ //璁㈠崟鏄庣粏
+ Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+ Orderdet1.Name = 'OCM_01_001001';
+ Orderdet1.Consumable_order_minor__c = olyorder.Id;
+ Orderdet1.Consumable_Arrived_order__c = order1.Id;
+ //Orderdet1.IsArrival__c = true;
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet1.Bar_Code__c = '11111';
+ Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+ Orderdet2.Name = 'OCM_01_001002';
+ Orderdet2.Consumable_order_minor__c = olyorder.Id;
+ Orderdet2.Consumable_Arrived_order__c = order1.Id;
+ //Orderdet2.IsArrival__c = true;
+ Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet2.Bar_Code__c = '22222';
+
+ insert new List<Consumable_order_details2__c>{ Orderdet1, Orderdet2 };
+ LexArriveGsDetailsController.init(order1.Id);
+ LexArriveGsDetailsController.proSale(
+ JSON.serialize(LexArriveGsDetailsController.coc),
+ LexArriveGsDetailsController.coc.Arrive_Order__r.Total_num__c,
+ LexArriveGsDetailsController.consumableorderdetailsRecords.size(),
+ order1.Id
+ );
+ }
+ }
+ }
+
+ @IsTest
+ static void test2() {
+ User myUser_test = new User();
+ Account myAccount1;
+ Account myAccount2;
+ Contact core;
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(currentUser) {
+ 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)'
+ ];
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 };
+ myAccount2 = new Account(
+ name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id
+ );
+ insert myAccount2;
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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.runAs(MyUser_Test) {
+ StaticParameter.ConsumableAssetHanderTrigger = true;
+ Consumable_order__c order1 = new Consumable_order__c();
+ order1.Name = 'OCM_01_001';
+ order1.Order_status__c = '鎵瑰噯';
+ order1.Order_type__c = '璁㈠崟';
+ order1.RecordTypeid = System.Label.RT_ConOrder_Arrive;
+ order1.IsShipment__c = true;
+ insert order1;
+
+ Consumable_order__c olyorder = new Consumable_order__c();
+ olyorder.Name = 'OCM_01_001';
+ olyorder.Order_status__c = '鎵瑰噯';
+ olyorder.Order_type__c = '璁㈠崟';
+ olyorder.Dealer_Info__c = myAccount2.Id;
+ olyorder.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ olyorder.IsShipment__c = true;
+ insert olyorder;
+
+ //璁㈠崟鏄庣粏
+ Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+ Orderdet1.Name = 'OCM_01_001001';
+ Orderdet1.Consumable_order_minor__c = olyorder.Id;
+ Orderdet1.Consumable_Arrived_order__c = order1.Id;
+ //Orderdet1.IsArrival__c = true;
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet1.Bar_Code__c = '11111';
+ Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+ Orderdet2.Name = 'OCM_01_001002';
+ Orderdet2.Consumable_order_minor__c = olyorder.Id;
+ Orderdet2.Consumable_Arrived_order__c = order1.Id;
+ //Orderdet2.IsArrival__c = true;
+ Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet2.Bar_Code__c = '22222';
+
+ insert new List<Consumable_order_details2__c>{ Orderdet1, Orderdet2 };
+ LexArriveGsDetailsController.init(order1.Id);
+ LexArriveGsDetailsController.proSale(
+ JSON.serialize(LexArriveGsDetailsController.coc),
+ 1,
+ 1,
+ order1.Id
+ );
+ }
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexArriveGsDetailsControllerTest.cls-meta.xml b/force-app/main/default/classes/LexArriveGsDetailsControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexArriveGsDetailsControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexCancelRemoveBoxController.cls b/force-app/main/default/classes/LexCancelRemoveBoxController.cls
index 7bd832f..9622088 100644
--- a/force-app/main/default/classes/LexCancelRemoveBoxController.cls
+++ b/force-app/main/default/classes/LexCancelRemoveBoxController.cls
@@ -1,623 +1,801 @@
public with sharing class LexCancelRemoveBoxController {
- //缁忛攢鍟嗕骇鍝佸垎绫�
- public static String agencyProType {get;set;}
- public static String userPro_Typestr = null;
- public static String barcode { get; set; }
- /*****************鐢婚潰琛ㄧずBean******************/
- public static List<ConsumableorderdetailsInfo> consumableInventory { get; set; }
- //閿欒鏄庣粏
- public static List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordserror { get; set; }
- //鎷嗙洅鏄庣粏
- public static List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy { get; set; }
- public static boolean saveFLGbln {get;set;}
- //閿欒淇℃伅
- public static String alertMessage {set;get;}
- //鎷嗙洅鏄庣粏浠舵暟
- public static Integer getinventorysize(){
- return ConsumableorderdetailsRecordsdummy.size();
- }
- public static Map<String, String> ExistIdMap = new Map<String, String>();
- public static Map<String, String> ErrorIdMap = new Map<String, String>();
- public static Map<String, String> AllMap = new Map<String, String>();
- public static List<String> BarCodeListP = new List<String>();
- //涓嶇鍚堢殑barcode鍜屽瀷鍙�
- public static list<String> notInlist = new list<String>();
- public static String baseUrl {get;private set;}
- private static String accountid = null;
- private static String accountName = null;
- //public String[] proidList =new String[]{};
- // 鐧诲綍鑰呭伐浣滃湴
- private static String userWorkLocation;
+ //缁忛攢鍟嗕骇鍝佸垎绫�
+ public static String agencyProType { get; set; }
+ public static String userPro_Typestr = null;
+ public static String barcode { get; set; }
+ /*****************鐢婚潰琛ㄧずBean******************/
+ public static List<ConsumableorderdetailsInfo> consumableInventory {
+ get;
+ set;
+ }
+ //閿欒鏄庣粏
+ public static List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordserror {
+ get;
+ set;
+ }
+ //鎷嗙洅鏄庣粏
+ public static List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy {
+ get;
+ set;
+ }
+ public static boolean saveFLGbln { get; set; }
+ //閿欒淇℃伅
+ public static String alertMessage { get; set; }
+ //鎷嗙洅鏄庣粏浠舵暟
+ public static Integer getinventorysize() {
+ return ConsumableorderdetailsRecordsdummy.size();
+ }
+ public static Map<String, String> ExistIdMap = new Map<String, String>();
+ public static Map<String, String> ErrorIdMap = new Map<String, String>();
+ public static Map<String, String> AllMap = new Map<String, String>();
+ public static List<String> BarCodeListP = new List<String>();
+ //涓嶇鍚堢殑barcode鍜屽瀷鍙�
+ public static list<String> notInlist = new List<String>();
+ public static String baseUrl { get; private set; }
+ private static String accountid = null;
+ private static String accountName = null;
+ //public String[] proidList =new String[]{};
+ // 鐧诲綍鑰呭伐浣滃湴
+ private static String userWorkLocation;
- public LexCancelRemoveBoxController(){
- baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
- ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
- ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
- consumableInventory = new List<ConsumableorderdetailsInfo>();
- saveFLGbln = FALSE;
+ public LexCancelRemoveBoxController() {
+ baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
+ ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
+ ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
+ consumableInventory = new List<ConsumableorderdetailsInfo>();
+ saveFLGbln = false;
+ }
+
+ @AuraEnabled
+ public static ResponseBodyLWC init() {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ 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;
+ userWorkLocation = Useracc[0].Work_Location__c;
+ agencyProType = Useracc[0].UserPro_Type__c;
+ if (String.isBlank(Useracc[0].UserPro_Type__c)) {
+ agencyProType = 'ET';
+ }
+ userPro_Typestr = '%' + agencyProType + '%';
+ List<account> accountInfo = [
+ SELECT Name
+ FROM account
+ WHERE id = :accountid
+ ];
+ //String view_product = accountInfo[0].view_product__c;
+ accountName = accountInfo[0].Name;
+ //proidList = view_product.split(',');
+ data.put('accountName', accountName);
+ data.put('userWorkLocation', userWorkLocation);
+ data.put('agencyProType', agencyProType);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ // 灏嗛〉闈㈡垨鍙栧緱BarCode鍘绘帀閲嶅鐨勶紝杞崲鎴怢ist
+ public static 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);
+ }
+ List<String> outPut = new List<String>();
+ for (String B : Buff) {
+ B = B.trim();
+ outPut.add(B);
+ }
+ return outPut;
+ }
+
+ //鑾峰彇鏄庣粏
+ @AuraEnabled
+ public static ResponseBodyLWC searchConsumableorderdetails(
+ String barcode,
+ String accountName,
+ String userWorkLocation,
+ String agencyProType
+ ) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ userPro_Typestr = '%' + agencyProType + '%';
+ barcode = barcode;
+ accountName = accountName;
+ userWorkLocation = userWorkLocation;
+
+ ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
+ ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
+
+ notInlist = 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>();
+ saveFLGbln = false;
+ alertMessage = '';
+
+ //鍒ゆ柇barcode鏄惁涓虹┖
+ if (barcode == null || barcode == '') {
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏arCode鍙�', '');
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'璇疯緭鍏arCode鍙枫��'));
+ // return;
}
- @AuraEnabled
- public static ResponseBodyLWC init() {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
+ // ExistIdMap.clear();
+ // ErrorIdMap.clear();
+ // notInlist.clear();
+ // ConsumableorderdetailsRecordserror.clear();
+ // ConsumableorderdetailsRecordsdummy.clear();
- 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;
- userWorkLocation = Useracc[0].Work_Location__c;
- agencyProType = Useracc[0].UserPro_Type__c;
- if(String.isBlank(Useracc[0].UserPro_Type__c)){
- agencyProType = 'ET';
+ // 浜у搧绫诲瀷涓嶅悓
+ 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,
+ Product_Type__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ recordtypeid,
+ Consumable_order_minor__r.Arrive_Order__c,
+ Arrive_Owner_Work_Location__c,
+ //add by rentx 2020-10-13 start
+ ContractNo_text__c
+ /*,ContractNo__c*/
+ //add by rentx 2020-10-13 end
+ FROM Consumable_order_details2__c
+ WHERE
+ Dealer_Arrive__c = TRUE
+ AND Bar_Code__c IN :BarCodeListP
+ AND Dealer_Info_text__c = :accountName
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND (NOT Product_Type__c LIKE :userPro_Typestr)
+ 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 +
+ '涓庝骇鍝佺被鍨�' +
+ agencyProType +
+ '涓嶇,涓嶈兘鎷嗙洅';
+ ConsumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(reSet1[i], str)
+ );
+ ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
}
- userPro_Typestr = '%' + agencyProType + '%';
- List<account> accountInfo = [SELECT Name FROM account WHERE id =:accountid];
- //String view_product = accountInfo[0].view_product__c;
- accountName = accountInfo[0].Name;
- //proidList = view_product.split(',');
- data.put('accountName',accountName);
- data.put('userWorkLocation',userWorkLocation);
- data.put('agencyProType',agencyProType);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
-
+ }
}
- // 灏嗛〉闈㈡垨鍙栧緱BarCode鍘绘帀閲嶅鐨勶紝杞崲鎴怢ist
- public static 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);
+ //娌℃湁鎷嗙洅
+ 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,
+ 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-13 start
+ ContractNo_text__c
+ /*,ContractNo__c*/
+ //add by rentx 2020-10-13 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 Lose_Flag__c = FALSE
+ AND Box_Piece__c = '鐩�'
+ //AND ProductPacking_list_manual__c > 1
+ 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);
}
- List<String> outPut = new List<String>();
- for(String B :Buff){
- B = B.trim();
- outPut.add(B);
- }
- return outPut;
+ }
}
- //鑾峰彇鏄庣粏
- @AuraEnabled
- public static ResponseBodyLWC searchConsumableorderdetails(String barcode,String accountName,String userWorkLocation,String agencyProType) {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String,object> data = new Map<String,object>();
- res.entity = data;
- userPro_Typestr = '%' + agencyProType + '%';
- barcode = barcode;
- accountName = accountName;
- userWorkLocation = userWorkLocation;
-
- ConsumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
- ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
-
-
-
- notInlist = 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>();
- saveFLGbln = FALSE;
- alertMessage='';
-
- //鍒ゆ柇barcode鏄惁涓虹┖
- if(barcode == null || barcode ==''){
- return new ResponseBodyLWC('Error',500, '璇疯緭鍏arCode鍙�', '');
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'璇疯緭鍏arCode鍙枫��'));
- // return;
+ //宸插嚭璐э紝鏈埌璐�
+ 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,
+ 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-13 start
+ ContractNo_text__c
+ /*,ContractNo__c*/
+ //add by rentx 2020-10-13 end
+ 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 Lose_Flag__c = FALSE
+ AND Box_Piece__c = '鐩�'
+ 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);
}
-
- // ExistIdMap.clear();
- // ErrorIdMap.clear();
- // notInlist.clear();
- // ConsumableorderdetailsRecordserror.clear();
- // ConsumableorderdetailsRecordsdummy.clear();
-
- // 浜у搧绫诲瀷涓嶅悓
- 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,Product_Type__c,
- Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
- recordtypeid,Consumable_order_minor__r.Arrive_Order__c, Arrive_Owner_Work_Location__c,
- //add by rentx 2020-10-13 start
- ContractNo_text__c
- /*,ContractNo__c*/
- //add by rentx 2020-10-13 end
- FROM Consumable_order_details2__c
- WHERE Dealer_Arrive__c = true
- AND Bar_Code__c in :BarCodeListP
- AND Dealer_Info_text__c = :accountName
- AND Arrive_Owner_Work_Location__c = : userWorkLocation
- AND (not Product_Type__c like : userPro_Typestr)
- 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 +'涓庝骇鍝佺被鍨�'+ agencyProType +'涓嶇,涓嶈兘鎷嗙洅';
- 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,
- 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-13 start
- ContractNo_text__c
- /*,ContractNo__c*/
- //add by rentx 2020-10-13 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 Lose_Flag__c = false
- AND Box_Piece__c = '鐩�'
- //AND ProductPacking_list_manual__c > 1
- 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,
- 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-13 start
- ContractNo_text__c
- /*,ContractNo__c*/
- //add by rentx 2020-10-13 end
- 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 Lose_Flag__c = false
- AND Box_Piece__c = '鐩�'
- 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,
- 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-13 start
- ContractNo_text__c
- /*,ContractNo__c*/
- //add by rentx 2020-10-13 end
- FROM Consumable_order_details2__c
- WHERE Dealer_Shipment__c = true
- AND Dealer_Arrive__c = true
- AND Dealer_Returned__c = false
- AND Lose_Flag__c = false
- AND Box_Piece__c = '涓�'
- AND RemoveBox_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,
- 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-13 start
- ContractNo_text__c
- /*,ContractNo__c*/
- //add by rentx 2020-10-13 end
- FROM Consumable_order_details2__c
- WHERE Dealer_Saled__c = true
- AND Dealer_Arrive__c = true
- AND Dealer_Returned__c = false
- AND Lose_Flag__c = false
- AND Box_Piece__c = '涓�'
- AND RemoveBox_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,
- 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-13 start
- ContractNo_text__c
- /*,ContractNo__c*/
- //add by rentx 2020-10-13 end
- FROM Consumable_order_details2__c
- WHERE Dealer_Returned__c = true
- AND Return_date__c != null
- AND Box_Piece__c = '涓�'
- AND RemoveBox_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,
- 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-13 start
- ContractNo_text__c
- /*,ContractNo__c*/
- //add by rentx 2020-10-13 end
- FROM Consumable_order_details2__c
- WHERE Inventory_date__c != null
- AND Box_Piece__c = '涓�'
- AND RemoveBox_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,
- Arrive_date__c,Send_Date__c,Consumable_order_minor__r.Name,Consumable_order_minor__c,
- recordtypeid,Consumable_order_minor__r.Arrive_Order__c, Arrive_Owner_Work_Location__c,
- //add by rentx 2020-10-13 start
- ContractNo_text__c
- /*,ContractNo__c*/
- //add by rentx 2020-10-13 end
- FROM Consumable_order_details2__c
- WHERE Dealer_Arrive__c = true
- 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 = '璇ュ晢鍝佸睘浜�' + reSet1[i].Arrive_Owner_Work_Location__c + ',涓嶈兘鍙栨秷鎷嗙洅';
- ConsumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i],str));
- ErrorIdMap.put(reSet1[i].Bar_Code__c,reSet1[i].Bar_Code__c);
- }
- }
- }
-
- 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,
- 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,
- //add by rentx 2020-10-13 start
- ContractNo_text__c
- /*,ContractNo__c*/
- //add by rentx 2020-10-13 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 Lose_Flag__c = false
- AND Box_Piece__c = '涓�'
- AND RemoveBox_date__c != null
- AND Bar_Code__c in :BarCodeListP
- AND Dealer_Info_text__c = :accountName
- AND Arrive_Owner_Work_Location__c =: userWorkLocation
- AND Product_Type__c like : userPro_Typestr
- ];
- if(reSet.size()>0){
- for (Integer i = 0; i < reSet.size(); i++) {
- if(ErrorIdMap.containsKey(reSet[i].Bar_Code__c) ){
- // 璺宠繃閿欒鐨勬秷鑰楀搧鏄庣粏
- continue;
- }
- else if(ExistIdMap.containsKey(reSet[i].Bar_Code__c) ){
- // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
- continue;
- }
- else{
- ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(reSet[i]));
- ExistIdMap.put(reSet[i].Bar_Code__c,reSet[i].Bar_Code__c);
- }
- }
- }
-
- AllMap.putAll(ExistIdMap);
-
- //寰楀埌涓嶅瓨鍦ㄧ殑BarCode
- for(Integer i = 0; i < BarCodeListP.size(); i++){
- if(ExistIdMap.containsKey(BarCodeListP[i])){
- continue;
- }else if(ErrorIdMap.containsKey(BarCodeListP[i])){
- continue;
- }else{
- notInlist.add(BarCodeListP[i]);
- }
- }
- if(notInlist.size()>0){
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode'+ notInlist + '涓嶅瓨鍦ㄣ��'));
- return new ResponseBodyLWC('Error',500, 'BarCode'+ notInlist + '涓嶅瓨鍦ㄣ��', '');
- }
- data.put('ConsumableorderdetailsRecordsdummy',JSON.serialize(ConsumableorderdetailsRecordsdummy));
- data.put('ConsumableorderdetailsRecordserror',JSON.serialize(ConsumableorderdetailsRecordserror));
- data.put('dataSize',ConsumableorderdetailsRecordsdummy.size());
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
-
+ }
}
- //鍙栨秷鎷嗙洅纭
- @AuraEnabled
- public static ResponseBodyLWC cancelRemoveBoxConfirm(String saveConsumableorderdetailsRecordsdummy,String accountName,String userWorkLocation,String agencyProType) {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String,object> data = new Map<String,object>();
- res.entity = data;
-
- userPro_Typestr = '%' + agencyProType + '%';
- accountName = accountName;
- userWorkLocation =userWorkLocation;
- List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy = (List<ConsumableorderdetailsInfo>)JSON.deserialize(saveConsumableorderdetailsRecordsdummy,List<ConsumableorderdetailsInfo>.class);
-
-
- List<Consumable_order_details2__c> ins = New List<Consumable_order_details2__c>();
-
- Savepoint sp = Database.setSavepoint();
- if(ConsumableorderdetailsRecordsdummy.size()<1){
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'涓嶅瓨鍦ㄥ彇娑堟媶鐩掓槑缁�'));
- return new ResponseBodyLWC('Error',500, '涓嶅瓨鍦ㄥ彇娑堟媶鐩掓槑缁�', '');
- // return null;
+ //鎷嗙洅宸插嚭璐�
+ 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,
+ 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-13 start
+ ContractNo_text__c
+ /*,ContractNo__c*/
+ //add by rentx 2020-10-13 end
+ FROM Consumable_order_details2__c
+ WHERE
+ Dealer_Shipment__c = TRUE
+ AND Dealer_Arrive__c = TRUE
+ AND Dealer_Returned__c = FALSE
+ AND Lose_Flag__c = FALSE
+ AND Box_Piece__c = '涓�'
+ AND RemoveBox_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);
}
-
- List<String> BarCodeList = new List<String>();
- for (ConsumableorderdetailsInfo tmp : ConsumableorderdetailsRecordsdummy) {
- BarCodeList.add(tmp.esd.Bar_Code__c);
- }
-
- try{
- //鍙栧緱閫氱暘澶т簬001鐨勫湪搴撴槑缁�
- List<Consumable_order_details2__c> orderDetails2del = [SELECT
- Id,
- Box_Piece__c,
- RemoveBox_date__c,
- RemoveBox_No__c,
- Bar_Code__c,
- //add by rentx 2020-10-13 start
- ContractNo_text__c
- /*,ContractNo__c*/
- //add by rentx 2020-10-13 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 Lose_Flag__c = false
- AND Box_Piece__c = '涓�'
- AND RemoveBox_date__c != null
- AND RemoveBox_No__c > 1
- AND Bar_Code__c in :BarCodeList
- AND Dealer_Info_text__c = :accountName
- AND Arrive_Owner_Work_Location__c =: userWorkLocation
- AND Product_Type__c like : userPro_Typestr
- ];
-
- List<Consumable_order_details2__c> orderlistdel = new List<Consumable_order_details2__c>();
- List<Consumable_order_details2__c> orderlistupd= new List<Consumable_order_details2__c>();
-
- for (Consumable_order_details2__c detail2tmp : orderDetails2del) {
- Consumable_order_details2__c delDetails2 = new Consumable_order_details2__c();
- delDetails2.Id = detail2tmp.Id;
-
- //鍒犻櫎閫氱暘澶т簬001鐨勬槑缁�2
- //delete delDetails2;
- orderlistdel.add(delDetails2);
- }
-
- //鍙栧緱閫氱暘001鐨勫湪搴撴槑缁�
- List<Consumable_order_details2__c> orderDetails2 = [SELECT
- Id,
- Box_Piece__c,
- RemoveBox_date__c,
- RemoveBox_No__c,
- Bar_Code__c,
- //add by rentx 2020-10-13 start
- ContractNo_text__c
- /*,ContractNo__c*/
- //add by rebtx 2020-10-13 end
- // tcm start
- ,Consumable_order_minor__r.ContractNo__c
- // tcm 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 Lose_Flag__c = false
- AND Box_Piece__c = '涓�'
- AND RemoveBox_date__c !=null
- AND RemoveBox_No__c = 1
- AND Bar_Code__c in :BarCodeList
- AND Dealer_Info_text__c = :accountName
- AND Arrive_Owner_Work_Location__c =: userWorkLocation
- AND Product_Type__c like : userPro_Typestr
- ];
-
- for (Consumable_order_details2__c detail2tmp : orderDetails2) {
- Consumable_order_details2__c updDetails2 = new Consumable_order_details2__c();
- updDetails2.Id = detail2tmp.Id;
- updDetails2.Box_Piece__c = '鐩�';
- updDetails2.RemoveBox_date__c = null;
- updDetails2.RemoveBox_No__c = null;
-
- // tcm start
- if (String.isBlank(detail2tmp.Consumable_order_minor__r.ContractNo__c)) {
- updDetails2.ContractNo_text__c= detail2tmp.ContractNo_text__c;
- }else {
- updDetails2.ContractNo_text__c= detail2tmp.Consumable_order_minor__r.ContractNo__c;
- }
- // updDetails2.ContractNo_text__c = detail2tmp.ContractNo__c;
- // tcm end
-
- //閫氱暘001銇儑銉笺偪銇鐞嗗崢浣嶃倰鐩掋伀鎴汇仐銆侀�氱暘銈掋偗銉偄
- //update updDetails2;
- orderlistupd.add(updDetails2);
- }
-
- if(orderlistdel.size()>0){
- delete orderlistdel;
- }
-
- if(orderlistupd.size()>0){
- update orderlistupd;
- }
- saveFLGbln = true;
- alertMessage = '鍙栨秷鎷嗙洅瀹屾垚';
- data.put('saveFLGbln',saveFLGbln);
- res.status = 'Success';
- res.code = 200;
- res.msg = alertMessage;
- System.debug('res = ' + res);
- return res;
- // return null;
- }catch(Exception e){
- Database.rollback(sp);
- ApexPages.addMessages(e);
- return null;
- }
+ }
}
+ //鎷嗙洅宸查攢鍞�
+ 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,
+ 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-13 start
+ ContractNo_text__c
+ /*,ContractNo__c*/
+ //add by rentx 2020-10-13 end
+ FROM Consumable_order_details2__c
+ WHERE
+ Dealer_Saled__c = TRUE
+ AND Dealer_Arrive__c = TRUE
+ AND Dealer_Returned__c = FALSE
+ AND Lose_Flag__c = FALSE
+ AND Box_Piece__c = '涓�'
+ AND RemoveBox_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);
+ }
+ }
+ }
- 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 oldConsumableCount { get; set; }
- public String ErrorReason { get; set; }
- public ConsumableorderdetailsInfo(Consumable_order_details2__c e,string str) {
- esd = e;
- Prod = e.Consumable_Product__r;
- oldConsumableCount = e.name;
- ErrorReason = str;
+ //鎷嗙洅杩斿搧
+ 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,
+ 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-13 start
+ ContractNo_text__c
+ /*,ContractNo__c*/
+ //add by rentx 2020-10-13 end
+ FROM Consumable_order_details2__c
+ WHERE
+ Dealer_Returned__c = TRUE
+ AND Return_date__c != NULL
+ AND Box_Piece__c = '涓�'
+ AND RemoveBox_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);
}
- public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
- esd = e;
- Prod = e.Consumable_Product__r;
- oldConsumableCount = e.name;
+ }
+ }
+
+ //鎷嗙洅鍚庣洏鐐硅繃(鐩樼偣鏃ユ湡涓嶄负绌�)
+ 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,
+ 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-13 start
+ ContractNo_text__c
+ /*,ContractNo__c*/
+ //add by rentx 2020-10-13 end
+ FROM Consumable_order_details2__c
+ WHERE
+ Inventory_date__c != NULL
+ AND Box_Piece__c = '涓�'
+ AND RemoveBox_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,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ recordtypeid,
+ Consumable_order_minor__r.Arrive_Order__c,
+ Arrive_Owner_Work_Location__c,
+ //add by rentx 2020-10-13 start
+ ContractNo_text__c
+ /*,ContractNo__c*/
+ //add by rentx 2020-10-13 end
+ FROM Consumable_order_details2__c
+ WHERE
+ Dealer_Arrive__c = TRUE
+ 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 =
+ '璇ュ晢鍝佸睘浜�' +
+ reSet1[i].Arrive_Owner_Work_Location__c +
+ ',涓嶈兘鍙栨秷鎷嗙洅';
+ ConsumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(reSet1[i], str)
+ );
+ ErrorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+ }
+ }
+ }
+
+ 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,
+ 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,
+ //add by rentx 2020-10-13 start
+ ContractNo_text__c
+ /*,ContractNo__c*/
+ //add by rentx 2020-10-13 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 Lose_Flag__c = FALSE
+ AND Box_Piece__c = '涓�'
+ AND RemoveBox_date__c != NULL
+ AND Bar_Code__c IN :BarCodeListP
+ AND Dealer_Info_text__c = :accountName
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Product_Type__c LIKE :userPro_Typestr
+ ];
+ if (reSet.size() > 0) {
+ for (Integer i = 0; i < reSet.size(); i++) {
+ if (ErrorIdMap.containsKey(reSet[i].Bar_Code__c)) {
+ // 璺宠繃閿欒鐨勬秷鑰楀搧鏄庣粏
+ continue;
+ } else if (ExistIdMap.containsKey(reSet[i].Bar_Code__c)) {
+ // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+ continue;
+ } else {
+ ConsumableorderdetailsRecordsdummy.add(
+ new ConsumableorderdetailsInfo(reSet[i])
+ );
+ ExistIdMap.put(reSet[i].Bar_Code__c, reSet[i].Bar_Code__c);
+ }
+ }
+ }
+
+ AllMap.putAll(ExistIdMap);
+
+ //寰楀埌涓嶅瓨鍦ㄧ殑BarCode
+ for (Integer i = 0; i < BarCodeListP.size(); i++) {
+ if (ExistIdMap.containsKey(BarCodeListP[i])) {
+ continue;
+ } else if (ErrorIdMap.containsKey(BarCodeListP[i])) {
+ continue;
+ } else {
+ notInlist.add(BarCodeListP[i]);
+ }
+ }
+ if (notInlist.size() > 0) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode'+ notInlist + '涓嶅瓨鍦ㄣ��'));
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ 'BarCode' + notInlist + '涓嶅瓨鍦ㄣ��',
+ ''
+ );
+ }
+ data.put(
+ 'ConsumableorderdetailsRecordsdummy',
+ JSON.serialize(ConsumableorderdetailsRecordsdummy)
+ );
+ data.put(
+ 'ConsumableorderdetailsRecordserror',
+ JSON.serialize(ConsumableorderdetailsRecordserror)
+ );
+ data.put('dataSize', ConsumableorderdetailsRecordsdummy.size());
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ //鍙栨秷鎷嗙洅纭
+ @AuraEnabled
+ public static ResponseBodyLWC cancelRemoveBoxConfirm(
+ String saveConsumableorderdetailsRecordsdummy,
+ String accountName,
+ String userWorkLocation,
+ String agencyProType
+ ) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ userPro_Typestr = '%' + agencyProType + '%';
+ accountName = accountName;
+ userWorkLocation = userWorkLocation;
+ List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy = (List<ConsumableorderdetailsInfo>) JSON.deserialize(
+ saveConsumableorderdetailsRecordsdummy,
+ List<ConsumableorderdetailsInfo>.class
+ );
+
+ List<Consumable_order_details2__c> ins = new List<Consumable_order_details2__c>();
+
+ Savepoint sp = Database.setSavepoint();
+ if (ConsumableorderdetailsRecordsdummy.size() < 1) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'涓嶅瓨鍦ㄥ彇娑堟媶鐩掓槑缁�'));
+ return new ResponseBodyLWC('Error', 500, '涓嶅瓨鍦ㄥ彇娑堟媶鐩掓槑缁�', '');
+ // return null;
+ }
+
+ List<String> BarCodeList = new List<String>();
+ for (ConsumableorderdetailsInfo tmp : ConsumableorderdetailsRecordsdummy) {
+ BarCodeList.add(tmp.esd.Bar_Code__c);
+ }
+
+ try {
+ //鍙栧緱閫氱暘澶т簬001鐨勫湪搴撴槑缁�
+ List<Consumable_order_details2__c> orderDetails2del = [
+ SELECT
+ Id,
+ Box_Piece__c,
+ RemoveBox_date__c,
+ RemoveBox_No__c,
+ Bar_Code__c,
+ //add by rentx 2020-10-13 start
+ ContractNo_text__c
+ /*,ContractNo__c*/
+ //add by rentx 2020-10-13 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 Lose_Flag__c = FALSE
+ AND Box_Piece__c = '涓�'
+ AND RemoveBox_date__c != NULL
+ AND RemoveBox_No__c > 1
+ AND Bar_Code__c IN :BarCodeList
+ AND Dealer_Info_text__c = :accountName
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Product_Type__c LIKE :userPro_Typestr
+ ];
+
+ List<Consumable_order_details2__c> orderlistdel = new List<Consumable_order_details2__c>();
+ List<Consumable_order_details2__c> orderlistupd = new List<Consumable_order_details2__c>();
+
+ for (Consumable_order_details2__c detail2tmp : orderDetails2del) {
+ Consumable_order_details2__c delDetails2 = new Consumable_order_details2__c();
+ delDetails2.Id = detail2tmp.Id;
+
+ //鍒犻櫎閫氱暘澶т簬001鐨勬槑缁�2
+ //delete delDetails2;
+ orderlistdel.add(delDetails2);
+ }
+
+ //鍙栧緱閫氱暘001鐨勫湪搴撴槑缁�
+ List<Consumable_order_details2__c> orderDetails2 = [
+ SELECT
+ Id,
+ Box_Piece__c,
+ RemoveBox_date__c,
+ RemoveBox_No__c,
+ Bar_Code__c,
+ //add by rentx 2020-10-13 start
+ ContractNo_text__c,
+ /*,ContractNo__c*/
+ //add by rebtx 2020-10-13 end
+ // tcm start
+ Consumable_order_minor__r.ContractNo__c
+ // tcm 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 Lose_Flag__c = FALSE
+ AND Box_Piece__c = '涓�'
+ AND RemoveBox_date__c != NULL
+ AND RemoveBox_No__c = 1
+ AND Bar_Code__c IN :BarCodeList
+ AND Dealer_Info_text__c = :accountName
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Product_Type__c LIKE :userPro_Typestr
+ ];
+
+ for (Consumable_order_details2__c detail2tmp : orderDetails2) {
+ Consumable_order_details2__c updDetails2 = new Consumable_order_details2__c();
+ updDetails2.Id = detail2tmp.Id;
+ updDetails2.Box_Piece__c = '鐩�';
+ updDetails2.RemoveBox_date__c = null;
+ updDetails2.RemoveBox_No__c = null;
+
+ // tcm start
+ if (
+ String.isBlank(detail2tmp.Consumable_order_minor__r.ContractNo__c)
+ ) {
+ updDetails2.ContractNo_text__c = detail2tmp.ContractNo_text__c;
+ } else {
+ updDetails2.ContractNo_text__c = detail2tmp.Consumable_order_minor__r.ContractNo__c;
+ }
+ // updDetails2.ContractNo_text__c = detail2tmp.ContractNo__c;
+ // tcm end
+
+ //閫氱暘001銇儑銉笺偪銇鐞嗗崢浣嶃倰鐩掋伀鎴汇仐銆侀�氱暘銈掋偗銉偄
+ //update updDetails2;
+ orderlistupd.add(updDetails2);
+ }
+
+ if (orderlistdel.size() > 0) {
+ delete orderlistdel;
+ }
+
+ if (orderlistupd.size() > 0) {
+ update orderlistupd;
+ }
+ saveFLGbln = true;
+ alertMessage = '鍙栨秷鎷嗙洅瀹屾垚';
+ data.put('saveFLGbln', saveFLGbln);
+ res.status = 'Success';
+ res.code = 200;
+ res.msg = alertMessage;
+ System.debug('res = ' + res);
+ return res;
+ // return null;
+ } catch (Exception e) {
+ Database.rollback(sp);
+ ApexPages.addMessages(e);
+ return null;
+ }
+ }
+
+ @TestVisible
+ 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 oldConsumableCount { get; set; }
+ public String ErrorReason { get; set; }
+ public ConsumableorderdetailsInfo(
+ Consumable_order_details2__c e,
+ string str
+ ) {
+ esd = e;
+ Prod = e.Consumable_Product__r;
+ oldConsumableCount = e.name;
+ ErrorReason = str;
+ }
+ public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
+ esd = e;
+ Prod = e.Consumable_Product__r;
+ oldConsumableCount = e.name;
+ }
+ /*
public ConsumableorderdetailsInfo(Product2__c e,String barCode,Date sterilizationlimit,String serialNoorLot,String tracingCode) {
esd = new Consumable_order_details2__c();
ProductName = e.Name__c;
@@ -638,9 +816,9 @@
tracingCodeNo = tracingCode;
}
*/
- // 鎺掑簭
- public Integer compareTo(Object compareTo) {
- return null;
- }
+ // 鎺掑簭
+ public Integer compareTo(Object compareTo) {
+ return null;
}
-}
\ No newline at end of file
+ }
+}
diff --git a/force-app/main/default/classes/LexCancelRemoveBoxControllerTest.cls b/force-app/main/default/classes/LexCancelRemoveBoxControllerTest.cls
new file mode 100644
index 0000000..264f21b
--- /dev/null
+++ b/force-app/main/default/classes/LexCancelRemoveBoxControllerTest.cls
@@ -0,0 +1,953 @@
+@IsTest
+private class LexCancelRemoveBoxControllerTest {
+ static testMethod void testMethod1() {
+ Oly_TriggerHandler.bypass('ConsumableAssetHander');
+ Oly_TriggerHandler.bypass('Oly_TriggerHandler');
+ user myUser_test;
+ Account myAccount2;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ];
+
+ myAccount2 = new Account(
+ name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount2;
+
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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.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,
+ Packing_list_manual__c = 5,
+ 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,
+ Packing_list_manual__c = 5,
+ Manual_Entry__c = false
+ );
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ JANCODE__c = '04953170200313',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02, prod03 };
+ 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
+ );
+ Product2__c pro3 = new Product2__c(
+ Name = 'Pro003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod03.Id
+ );
+ insert new List<Product2__c>{ pro1, pro2, pro3 };
+ //璁㈠崟
+ 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 = myAccount2.Id;
+ Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ Order1.Order_ProType__c = 'ET';
+ insert Order1;
+ List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
+
+ //daoku
+ 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.Arrive_date__c = Date.today();
+ Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+ Orderdet2.Used_date__c = null;
+ Orderdet2.Lose_Flag__c = false;
+ Orderdet2.Return_date__c = null;
+ Orderdet2.Send_Date__c = null;
+ Orderdet2.Box_Piece__c = '鐩�';
+ conList.add(Orderdet2);
+ // insert Orderdet2;
+
+ //chuku
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+ Orderdet3.Name = 'OCM_01_001002';
+ Orderdet3.Consumable_order_minor__c = Order1.Id;
+ Orderdet3.Consumable_Product__c = pro2.Id;
+ Orderdet3.Asset_Model_No__c = 'Test02';
+ Orderdet3.Arrive_date__c = Date.today();
+ Orderdet3.Send_Date__c = Date.today();
+ Orderdet3.Box_Piece__c = '涓�';
+ Orderdet3.RemoveBox_date__c = Date.today();
+ Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
+ Orderdet3.Used_date__c = null;
+ Orderdet3.Lose_Flag__c = false;
+ Orderdet3.Return_date__c = null;
+ conList.add(Orderdet3);
+ // insert Orderdet3;
+
+ //sale
+ 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 = pro2.Id;
+ Orderdet4.Asset_Model_No__c = 'Test02';
+ Orderdet4.Arrive_date__c = Date.today();
+ Orderdet4.Box_Piece__c = '涓�';
+ Orderdet4.RemoveBox_date__c = Date.today();
+ Orderdet4.Bar_Code__c = '011495317020843711170400172003311074K250CXSDS';
+ Orderdet4.Lose_Flag__c = false;
+ Orderdet4.Return_date__c = null;
+ Orderdet4.Used_date__c = Date.today();
+ // insert Orderdet4;
+ conList.add(Orderdet4);
+
+ //ProductPacking_list_manual__c=1
+ Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+ Orderdet5.Name = 'OCM_01_001004';
+ Orderdet5.Consumable_order_minor__c = Order1.Id;
+ Orderdet5.Consumable_Product__c = pro3.Id;
+ Orderdet5.Asset_Model_No__c = 'Test03';
+ Orderdet5.Arrive_date__c = Date.today();
+ //Orderdet5.Used_date__c = Date.today();
+ Orderdet5.Box_Piece__c = '鐩�';
+ Orderdet5.RemoveBox_date__c = Date.today();
+ Orderdet5.Used_date__c = null;
+ Orderdet5.Lose_Flag__c = false;
+ Orderdet5.Return_date__c = null;
+ Orderdet5.Send_Date__c = null;
+ Orderdet5.Bar_Code__c = '010495317014059411170400172203311074K250DCWQW';
+ // insert Orderdet5;
+ conList.add(Orderdet5);
+
+ //pandian
+ 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 = pro2.Id;
+ Orderdet7.Asset_Model_No__c = 'Test02';
+ Orderdet7.Box_Piece__c = '鐩�';
+ Orderdet7.Lose_Flag__c = false;
+ Orderdet7.Bar_Code__c = '010495317014059411170400172203311074K250DBVUD';
+ Orderdet7.RemoveBox_date__c = Date.today();
+ Orderdet7.Inventory_date__c = Date.today();
+ // insert Orderdet7;
+ conList.add(Orderdet7);
+
+ 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 = pro2.Id;
+ Orderdet8.Asset_Model_No__c = 'Test02';
+ Orderdet8.Arrive_date__c = Date.today();
+ Orderdet8.Box_Piece__c = '涓�';
+ Orderdet8.Lose_Flag__c = false;
+ Orderdet8.Bar_Code__c = '1683272847250250WZIOF';
+ Orderdet8.Used_date__c = null;
+ Orderdet8.Lose_Flag__c = false;
+ Orderdet8.Return_date__c = null;
+ Orderdet8.RemoveBox_date__c = Date.today();
+ Orderdet8.Send_Date__c = null;
+ Orderdet8.RemoveBox_No__c = 3;
+ conList.add(Orderdet8);
+ insert conList;
+ // insert Orderdet8;
+
+ System.Test.startTest();
+ LexCancelRemoveBoxController.init();
+ // LexCancelRemoveBoxController.getinventorysize();
+ LexCancelRemoveBoxController.searchConsumableorderdetails(
+ '1683272847250250WZIOF',
+ '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�',
+ '娣卞湷',
+ 'ENG'
+ );
+ LexCancelRemoveBoxController.searchConsumableorderdetails(
+ '',
+ '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�',
+ '娣卞湷',
+ 'ENG'
+ );
+ LexCancelRemoveBoxController.cancelRemoveBoxConfirm(
+ JSON.serialize(conList),
+ '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�',
+ '娣卞湷',
+ 'ENG'
+ );
+
+ System.Test.stopTest();
+ }
+
+ }
+ static testMethod void testMethod2() {
+ Oly_TriggerHandler.bypass('ConsumableAssetHander');
+ Oly_TriggerHandler.bypass('Oly_TriggerHandler');
+ user myUser_test;
+ Account myAccount2;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ];
+
+ myAccount2 = new Account(
+ name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount2;
+
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+ 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 = myAccount2.Id;
+ Order1.RecordTypeid = '01210000000c9dqAAA';
+ Order1.Order_ProType__c = 'ET';
+ insert Order1;
+
+ List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
+ List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
+ Consumable_order_details2__c con = new Consumable_order_details2__c();
+ con.Consumable_Arrived_order__c = Order1.Id;
+ con.Send_Date__c = null;
+ con.Used_date__c = null;
+ con.Return_date__c = null;
+ con.Lose_Flag__c = false;
+ con.Box_Piece__c = '涓�';
+ con.RemoveBox_date__c = Date.today();
+ con.Arrive_date__c = Date.today();
+ con.RemoveBox_No__c = 2;
+ con.Bar_Code__c = '1682414917514250XSCYW';
+ conList.add(con);
+
+ Consumable_order_details2__c con1 = new Consumable_order_details2__c();
+ con1.Consumable_Arrived_order__c = Order1.Id;
+ con1.Send_Date__c = null;
+ con1.Used_date__c = null;
+ con1.Return_date__c = null;
+ con1.Lose_Flag__c = false;
+ con1.Box_Piece__c = '涓�';
+ con1.RemoveBox_date__c = Date.today();
+ con1.Arrive_date__c = Date.today();
+ con.RemoveBox_No__c = 1;
+ con1.Bar_Code__c = '1682414917514250XSCYW';
+ conList.add(con1);
+ insert (conList);
+ System.debug('conList' + conList);
+ System.Test.startTest();
+ LexCancelRemoveBoxController.cancelRemoveBoxConfirm(
+ JSON.serialize(conList),
+ 'Testaccount002',
+ '閲嶅簡',
+ 'ET'
+ );
+ LexCancelRemoveBoxController.cancelRemoveBoxConfirm(
+ JSON.serialize(conList1),
+ 'Testaccount002',
+ '閲嶅簡',
+ 'ET'
+ );
+ System.Test.stopTest();
+ }
+ }
+ static testMethod void testMethod3() {
+ Oly_TriggerHandler.bypass('ConsumableAssetHander');
+ Oly_TriggerHandler.bypass('Oly_TriggerHandler');
+ User myUser_test;
+ Account myAccount2;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ];
+ myAccount2 = new Account(
+ name = 'Testaccount003',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '2'
+ );
+ insert myAccount2;
+ Contact core = new Contact(
+ email = 'wan@salesforce.com',
+ firstname = 'wan',
+ lastname = 'Plumbers',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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 = 'ENG',
+ Work_Location__c = '鍖椾含'
+ );
+ insert myUser_test;
+ System.debug('MyUser_Test' + MyUser_Test);
+ }
+ System.runAs(MyUser_Test) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'test01',
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'test02',
+ Manual_Entry__c = false
+ );
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'test03',
+ Manual_Entry__c = false
+ );
+ Product2 prod04 = new Product2(
+ Name = 'Test04',
+ ProductCode = 'Test04',
+ Asset_Model_No__c = 'Test04',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 2,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'test04',
+ Manual_Entry__c = false
+ );
+ Product2 prod05 = new Product2(
+ Name = 'Test05',
+ ProductCode = 'Test05',
+ Asset_Model_No__c = 'Test05',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'test05',
+ Manual_Entry__c = false
+ );
+ Product2 prod06 = new Product2(
+ Name = 'Test06',
+ ProductCode = 'Test06',
+ Asset_Model_No__c = 'Test06',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'test06',
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{
+ prod01,
+ prod02,
+ prod03,
+ prod04,
+ prod05,
+ prod06
+ };
+ 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
+ );
+ Product2__c pro3 = new Product2__c(
+ Name = 'Pro004',
+ OT_CODE_Text__c = 'Test004',
+ Product2__c = prod03.Id
+ );
+ Product2__c pro4 = new Product2__c(
+ Name = 'Pro005',
+ OT_CODE_Text__c = 'Test005',
+ Product2__c = prod04.Id
+ );
+ Product2__c pro5 = new Product2__c(
+ Name = 'Pro003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod05.Id
+ );
+ Product2__c pro6 = new Product2__c(
+ Name = 'Pro006',
+ OT_CODE_Text__c = 'Test006',
+ Product2__c = prod06.Id
+ );
+ insert new List<Product2__c>{ pro4, pro5, pro6, pro1, pro2, pro3 };
+ //璁㈠崟
+ Consumable_order__c Order1 = new Consumable_order__c();
+ Order1.Name = 'OCM_01';
+ Order1.Order_status__c = '鎵瑰噯';
+ Order1.Order_type__c = '璁㈠崟';
+ Order1.Dealer_Info__c = myAccount2.Id;
+ Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ Order1.Order_ProType__c = 'ENG';
+ insert Order1;
+ //鍑鸿揣
+ Consumable_order__c Order2 = new Consumable_order__c();
+ Order2.Name = 'OCM_01';
+ Order2.Order_status__c = '鎵瑰噯';
+ Order2.Order_type__c = '璁㈠崟';
+ Order2.Dealer_Info__c = myAccount2.Id;
+ Order2.RecordTypeid = '012100000006Jx9AAE';
+ Order2.Order_ProType__c = 'ENG';
+ insert Order2;
+
+ List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
+ List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
+ List<Consumable_order_details2__c> conList2 = new List<Consumable_order_details2__c>();
+ //浜у搧绫诲瀷涓嶅悓
+ Consumable_order_details2__c con = new Consumable_order_details2__c();
+ con.Name = 'OCM_01_001001';
+ con.Consumable_order_minor__c = Order1.Id;
+ con.Consumable_Product__c = pro2.Id;
+ con.Asset_Model_No__c = 'Test01';
+ con.Arrive_date__c = Date.today();
+ con.Bar_Code__c = '10061';
+ con.Used_date__c = null;
+ con.Lose_Flag__c = false;
+ con.Return_date__c = null;
+ con.Send_Date__c = null;
+ con.Box_Piece__c = '鐩�';
+ conList.add(con);
+ insert conList;
+
+ //浜у搧绫诲瀷涓嶅悓
+ Consumable_order_details2__c con1 = new Consumable_order_details2__c();
+ con1.Consumable_Product__c = pro2.Id;
+ con1.Consumable_order_minor__c = Order1.Id;
+ con1.Bar_Code__c = '10011';
+ con1.Arrive_date__c = Date.today();
+ conList1.add(con1);
+ //娌℃湁鎷嗙洅
+ Consumable_order_details2__c con2 = new Consumable_order_details2__c();
+ con2.Send_Date__c = null;
+ con2.Used_date__c = null;
+ con2.Lose_Flag__c = false;
+ con2.Box_Piece__c = '鐩�';
+ con2.Consumable_Product__c = pro2.Id;
+ con2.Consumable_order_minor__c = Order1.Id;
+ con2.Bar_Code__c = '10021';
+ con2.Arrive_date__c = Date.today();
+ con2.RemoveBox_date__c = null;
+ conList1.add(con2);
+ insert conList1;
+
+ //宸插嚭璐� 鏈埌璐�
+ Consumable_order_details2__c con3 = new Consumable_order_details2__c();
+ con3.Arrive_date__c = null;
+ con3.Send_Date__c = null;
+ con3.Used_date__c = null;
+ con3.Return_date__c = null;
+ con3.Lose_Flag__c = false;
+ con3.Box_Piece__c = '鐩�';
+ con3.Consumable_Arrived_order__c = Order2.Id;
+ con3.Consumable_Product__c = pro2.Id;
+ con3.Bar_Code__c = '10031';
+ conList2.add(con3);
+ //鎷嗙洅宸插嚭璐�
+ Consumable_order_details2__c con4 = new Consumable_order_details2__c();
+ con4.Arrive_date__c = Date.today();
+ con4.Send_Date__c = Date.today();
+ con4.Return_date__c = null;
+ con4.Used_date__c = null;
+ con4.Lose_Flag__c = false;
+ con4.Box_Piece__c = '涓�';
+ con4.RemoveBox_date__c = Date.today();
+ con4.Consumable_Arrived_order__c = Order2.Id;
+ con4.Consumable_Product__c = pro2.Id;
+ con4.Bar_Code__c = '10041';
+ conList2.add(con4);
+ insert conList2;
+
+ System.Test.startTest();
+ LexCancelRemoveBoxController.barcode = '1004\n1003\n1002\n1001';
+ LexCancelRemoveBoxController.searchConsumableorderdetails(
+ '10061\n10051\n10041\n10031\n10021\n10011',
+ 'Testaccount003',
+ '閲嶅簡',
+ 'ET'
+ );
+ String str = '璇ュ晢鍝佸瓨鍦ㄧ洏鐐瑰饱鍘�';
+ String errorReason = '';
+ LexCancelRemoveBoxController.ConsumableorderdetailsInfo c2 = new LexCancelRemoveBoxController.ConsumableorderdetailsInfo(
+ con,
+ str
+ );
+ c2.esd = con;
+ c2.Prod = con.Consumable_product__r;
+ c2.oldConsumableCount = con.name;
+ c2.ErrorReason = str;
+ LexCancelRemoveBoxController.ConsumableorderdetailsInfo c1 = new LexCancelRemoveBoxController.ConsumableorderdetailsInfo(
+ con2
+ );
+ c1.esd = con;
+ c1.Prod = con.Consumable_product__r;
+ c1.oldConsumableCount = con.name;
+ c1.compareTo(c2);
+ System.Test.stopTest();
+ }
+ }
+ static testMethod void testMethod4() {
+ Oly_TriggerHandler.bypass('ConsumableAssetHander');
+ Oly_TriggerHandler.bypass('Oly_TriggerHandler');
+ User myUser_test;
+ Account myAccount2;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ];
+ myAccount2 = new Account(
+ name = 'Testaccount003',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '2'
+ );
+ insert myAccount2;
+ Contact core = new Contact(
+ email = 'wan@salesforce.com',
+ firstname = 'wan',
+ lastname = 'Plumbers',
+ accountid = myAccount2.id
+ );
+ insert core;
+ MyUser_Test = new User(
+ ContactId = core.id,
+ Alias = 'newWang',
+ Email = 'newWang@testorg.com',
+ EmailEncodingKey = 'UTF-8',
+ LastName = 'TestUserWang',
+ LanguageLocaleKey = 'zh_CN',
+ LocaleSidKey = 'zh_CN',
+ ProfileId = prof.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUserWang@testorg.com',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ System.debug('MyUser_Test' + MyUser_Test);
+ }
+ System.runAs(MyUser_Test) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'test01',
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'test02',
+ Manual_Entry__c = false
+ );
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'test03',
+ Manual_Entry__c = false
+ );
+ Product2 prod04 = new Product2(
+ Name = 'Test04',
+ ProductCode = 'Test04',
+ Asset_Model_No__c = 'Test04',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 2,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'test04',
+ Manual_Entry__c = false
+ );
+ Product2 prod05 = new Product2(
+ Name = 'Test05',
+ ProductCode = 'Test05',
+ Asset_Model_No__c = 'Test05',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'test05',
+ Manual_Entry__c = false
+ );
+ Product2 prod06 = new Product2(
+ Name = 'Test06',
+ ProductCode = 'Test06',
+ Asset_Model_No__c = 'Test06',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'test06',
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{
+ prod01,
+ prod02,
+ prod03,
+ prod04,
+ prod05,
+ prod06
+ };
+ 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
+ );
+ Product2__c pro3 = new Product2__c(
+ Name = 'Pro004',
+ OT_CODE_Text__c = 'Test004',
+ Product2__c = prod03.Id
+ );
+ Product2__c pro4 = new Product2__c(
+ Name = 'Pro005',
+ OT_CODE_Text__c = 'Test005',
+ Product2__c = prod04.Id
+ );
+ Product2__c pro5 = new Product2__c(
+ Name = 'Pro003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod05.Id
+ );
+ Product2__c pro6 = new Product2__c(
+ Name = 'Pro006',
+ OT_CODE_Text__c = 'Test006',
+ Product2__c = prod06.Id
+ );
+ insert new List<Product2__c>{ pro4, pro5, pro6, pro1, pro2, pro3 };
+ List<Consumable_order__c> orderList = new List<Consumable_order__c>();
+ //閿�鍞�
+ Consumable_order__c Order1 = new Consumable_order__c();
+ Order1.Name = 'OCM_01';
+ Order1.Order_status__c = '鎵瑰噯';
+ Order1.Order_type__c = '閿�鍞�';
+ Order1.Dealer_Info__c = myAccount2.Id;
+ Order1.RecordTypeid = '01210000000c9duAAA';
+ Order1.Order_ProType__c = 'ENG';
+ orderList.add(Order1);
+ //杩斿搧
+ Consumable_order__c Order2 = new Consumable_order__c();
+ Order2.Name = 'OCM_01';
+ Order2.Order_status__c = '鎵瑰噯';
+ Order2.Order_type__c = '杩斿搧';
+ Order2.Dealer_Info__c = myAccount2.Id;
+ Order2.RecordTypeid = '012100000006Jx4AAE';
+ Order2.Order_ProType__c = 'ENG';
+ orderList.add(Order2);
+ //鐩樼偣
+ Consumable_order__c Order3 = new Consumable_order__c();
+ Order3.Name = 'OCM_01';
+ Order3.Order_status__c = '鎵瑰噯';
+ Order3.Order_type__c = '鐩樼偣';
+ Order3.Dealer_Info__c = myAccount2.Id;
+ Order3.RecordTypeid = '01210000000c9dsAAA';
+ Order3.Order_ProType__c = 'ENG';
+ orderList.add(Order3);
+ //鍙戣揣
+ Consumable_order__c Order4 = new Consumable_order__c();
+ Order4.Name = 'OCM_0122';
+ Order4.Order_status__c = '鎵瑰噯';
+ Order4.Order_type__c = '璁㈠崟';
+ Order4.Dealer_Info__c = myAccount2.Id;
+ Order4.RecordTypeid = '01210000000c9drAAA';
+ Order4.Order_ProType__c = 'ET';
+ Order4.ContractNo__c = '';
+ orderList.add(Order4);
+ insert orderList;
+
+ List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
+ List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
+ List<Consumable_order_details2__c> conList2 = new List<Consumable_order_details2__c>();
+ //鎷嗙洅宸查攢鍞�
+ Consumable_order_details2__c con4 = new Consumable_order_details2__c();
+ con4.Arrive_date__c = Date.today();
+ con4.Deliver_date__c = Date.today();
+ con4.Sterilization_limit__c = Date.today();
+ con4.Send_Date__c = null;
+ con4.Return_date__c = null;
+ con4.Used_date__c = Date.today();
+ con4.Lose_Flag__c = false;
+ con4.Box_Piece__c = '涓�';
+ con4.RemoveBox_date__c = Date.today();
+ con4.RecordTypeId = '01210000000kUDKAA2';
+ con4.Consumable_Product__c = pro2.Id;
+ con4.Bar_Code__c = '100611';
+ conList.add(con4);
+ insert conList;
+
+ //鎷嗙洅杩斿搧
+ Consumable_order_details2__c con5 = new Consumable_order_details2__c();
+ con5.Arrive_date__c = Date.today();
+ con5.Return_date__c = Date.today();
+ con5.Deliver_date__c = Date.today();
+ con5.Send_Date__c = null;
+ con5.Sterilization_limit__c = Date.today();
+ con5.Used_date__c = Date.today();
+ con5.Box_Piece__c = '涓�';
+ con5.RemoveBox_date__c = Date.today();
+ con5.RecordTypeId = '01210000000kUDPAA2';
+ con5.Consumable_Product__c = pro2.Id;
+ con5.Consumable_order_minor__c = Order4.Id;
+ con5.Bar_Code__c = '10061';
+ conList1.add(con5);
+ insert conList1;
+
+ //鎷嗙洅鍚庣洏鐐硅繃
+ Consumable_order_details2__c con6 = new Consumable_order_details2__c();
+ con6.Inventory_date__c = Date.today();
+ con6.Box_Piece__c = '涓�';
+ con6.RemoveBox_date__c = Date.today();
+ con6.Send_Date__c = null;
+ con6.Deliver_date__c = Date.today();
+ con6.Sterilization_limit__c = Date.today();
+ con6.RecordTypeId = '01210000000kUDKAA2';
+ con6.Consumable_Arrived_order__c = Order3.Id;
+ con6.Consumable_Product__c = pro2.Id;
+ con6.Bar_Code__c = '10078';
+ conList2.add(con6);
+ insert conList2;
+
+ List<Consumable_order_details2__c> conList3 = new List<Consumable_order_details2__c>();
+ //鎷嗙洅宸插嚭璐�
+ Consumable_order_details2__c con3 = new Consumable_order_details2__c();
+ con3.Arrive_date__c = Date.today();
+ con3.Send_Date__c = Date.today();
+ con3.Return_date__c = null;
+ con3.Used_date__c = null;
+ con3.Lose_Flag__c = false;
+ con3.Box_Piece__c = '涓�';
+ con3.Deliver_date__c = Date.today();
+ con3.RemoveBox_date__c = Date.today();
+ con3.RecordTypeId = '01210000000kUDKAA2';
+ con3.Consumable_Product__c = pro2.Id;
+ con3.Consumable_order_minor__c = Order4.Id;
+ con3.Bar_Code__c = '100999';
+ con3.Sterilization_limit__c = Date.today();
+ conList3.add(con3);
+ insert conList3;
+
+ //reset
+ // Consumable_order_details2__c con1 = new Consumable_order_details2__c();
+ // con1.Intra_Trade_List_RMB__c = 1000;
+ // con1.Asset_Model_No__c = 'test';
+ // con1.Sterilization_limit__c = Date.today();
+ // con1.Deliver_date__c = Date.today();
+ // con1.Arrive_date__c = Date.today();
+ // con1.Send_Date__c = null;
+ // con1.Used_date__c = null;
+ // con1.Return_date__c = null;
+ // con1.Lose_Flag__c = false;
+ // con1.Box_Piece__c = '涓�';
+
+ // con1.Consumable_order_minor__c = Order4.Id;
+ // con1.Guarantee_period_for_products__c = Date.today();
+ // con1.Consumable_Product__c = pro2.Id;
+ // con1.Bar_Code__c = '1009999';
+ // conList2.add(con1);
+ // insert conList2;
+
+ // List<Consumable_order_details2__c> conList3 = new List<Consumable_order_details2__c> ();
+ // Consumable_order_details2__c con9 = new Consumable_order_details2__c();
+ // con9.RemoveBox_date__c = Date.today();
+ // con9.Bar_Code__c = '100112';
+ // con9.Arrive_date__c = Date.today();
+ // con9.Send_Date__c = null;
+ // con9.Used_date__c = null;
+ // con9.Return_date__c = null;
+ // con9.Lose_Flag__c = false;
+ // con9.Box_Piece__c = '涓�';
+ // con9.RemoveBox_No__c = 9;
+ // conList3.add(con9);
+ // LexCancelRemoveBoxController.searchConsumableorderdetails('100112','Testaccount003','閲嶅簡','ET');
+
+ //orderDetails2
+ // Consumable_order_details2__c con00 = new Consumable_order_details2__c();
+ // con00.Box_Piece__c = '涓�';
+ // con00.RemoveBox_date__c = Date.today();
+ // con00.RemoveBox_No__c = 1;
+ // con00.ContractNo_text__c = '';
+ // con00.Consumable_order_minor__c = Order4.Id;
+ // con00.Bar_Code__c = '10099999989';
+ // conList3.add(con00);
+
+ // insert conList3;
+ System.Test.startTest();
+ LexCancelRemoveBoxController CancelRemoveBoxController = new LexCancelRemoveBoxController();
+ LexCancelRemoveBoxController.searchConsumableorderdetails(
+ '100611\n10078\n10099\n1009999\n100999',
+ 'Testaccount003',
+ '閲嶅簡',
+ 'ET'
+ );
+ LexCancelRemoveBoxController.searchConsumableorderdetails(
+ '100611\n10078\n10061\n10051\n10041\n10031\n10021\n10011',
+ 'Testaccount003',
+ '鍖椾含',
+ 'ET'
+ );
+ LexCancelRemoveBoxController.searchConsumableorderdetails(
+ '100611\n10078\n10061\n10051\n10041\n10031\n10021\n10011',
+ 'Testaccount003',
+ '閲嶅簡',
+ 'ET'
+ );
+ System.Test.stopTest();
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexCancelRemoveBoxControllerTest.cls-meta.xml b/force-app/main/default/classes/LexCancelRemoveBoxControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexCancelRemoveBoxControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexConInvoiceListTest.cls b/force-app/main/default/classes/LexConInvoiceListTest.cls
new file mode 100644
index 0000000..837de78
--- /dev/null
+++ b/force-app/main/default/classes/LexConInvoiceListTest.cls
@@ -0,0 +1,205 @@
+@isTest
+private class LexConInvoiceListTest {
+ static testMethod void conInvoiceListTestinit() {
+ user myUser_test;
+ Account myAccount2;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ List<RecordType> rectHos = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectHos.size() == 0) {
+ return;
+ }
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id
+ );
+ myAccount2 = new Account(
+ name = 'testaccount002',
+ RecordTypeId = rectHos[0].Id
+ );
+ insert myAccount1;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '鍖椾含'
+ );
+ insert myUser_test;
+ }
+ System.runAs(myUser_test) {
+ Consumable_order__c TestList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Invoice_Date__c = Date.today(),
+ Dealer_info__c = myAccount1.Id,
+ Invoice_status__c = '鑽夋涓�',
+ Order_ForHospital__c = myAccount2.Id,
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '鍙戠エ',
+ recordtypeid = System.Label.RT_ConOrder_Invoice,
+ Order_ProType__c = 'ET'
+ );
+ Consumable_order__c TestList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Invoice_Date__c = Date.today(),
+ Dealer_info__c = myAccount1.Id,
+ Invoice_status__c = '鎻愪氦',
+ Order_ForHospital__c = myAccount2.Id,
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '鍙戠エ',
+ recordtypeid = System.Label.RT_ConOrder_Invoice,
+ Order_ProType__c = 'ET'
+ );
+ insert new List<Consumable_order__c>{ TestList1, TestList2 };
+ LexConInvoiceList.init();
+ // ConInvoiceListController CDC = new ConInvoiceListController();
+ // CDC.init();
+ // System.assertEquals('Test1', CDC.raesList[0].name);
+ // System.assertEquals('Test2', CDC.raesList[1].name);
+ // CDC.SortLimited();
+ // System.assertEquals('Test1', CDC.raesList[0].name);
+ // System.assertEquals('Test2', CDC.raesList[1].name);
+ }
+ }
+ //妫�绱�
+ static testMethod void invoiceCodeSearchTest() {
+ user myUser_test;
+ Account myAccount2;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ List<RecordType> rectHos = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectHos.size() == 0) {
+ return;
+ }
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id
+ );
+ myAccount2 = new Account(
+ name = 'testaccount002',
+ RecordTypeId = rectHos[0].Id
+ );
+ insert myAccount1;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '鍖椾含'
+ );
+ insert myUser_test;
+ }
+
+ System.runAs(myUser_test) {
+ Consumable_order__c TestList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Invoice_Date__c = Date.today(),
+ Dealer_info__c = myAccount1.Id,
+ Invoice_status__c = '鑽夋涓�',
+ Order_ForHospital__c = myAccount2.Id,
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '鍙戠エ',
+ recordtypeid = System.Label.RT_ConOrder_Invoice,
+ Order_ProType__c = 'ET'
+ );
+ Consumable_order__c TestList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Invoice_Date__c = Date.today(),
+ Dealer_info__c = myAccount1.Id,
+ Invoice_status__c = '鎻愪氦',
+ Order_ForHospital__c = myAccount2.Id,
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '鍙戠エ',
+ recordtypeid = System.Label.RT_ConOrder_Invoice,
+ Order_ProType__c = 'ET'
+ );
+ insert new List<Consumable_order__c>{ TestList1, TestList2 };
+ LexConInvoiceList CDC = new LexConInvoiceList();
+ LexConInvoiceList.init();
+ LexConInvoiceList.invoiceCodeSearch(
+ Date.today(),
+ Date.today(),
+ '鎻愪氦',
+ 'test',
+ 'test1',
+ '0010l00001ajxZ2AAI',
+ '鍖椾含',
+ 'ET'
+ );
+ // CDC.init();
+ // System.assertEquals('Test1', CDC.raesList[0].name);
+ // System.assertEquals('Test2', CDC.raesList[1].name);
+ // CDC.coc.Invoice_status__c = '鎻愪氦';
+ // CDC.invoiceCodeSearch();
+ // System.assertEquals(1, CDC.raesList.size());
+ // CDC.clearUp();
+ // System.assertEquals(2, CDC.raesList.size());
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexConInvoiceListTest.cls-meta.xml b/force-app/main/default/classes/LexConInvoiceListTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexConInvoiceListTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexConInvoiceViewController.cls b/force-app/main/default/classes/LexConInvoiceViewController.cls
index 0173b6c..69b9a57 100644
--- a/force-app/main/default/classes/LexConInvoiceViewController.cls
+++ b/force-app/main/default/classes/LexConInvoiceViewController.cls
@@ -1,1629 +1,1962 @@
public without sharing class LexConInvoiceViewController {
- public static String agencyProType { get; set; }
- public static Consumable_order__c coc { get; set; }
- public static Consumable_order__c outbound { get; set; }
- public static String invoiceId { get; set; }
- public static String orderRemind { get; set; }
- public static String deliveryId { get; set; }
- public static String reopen { get; set; }
- public static Decimal sumPrice { get; set; }
- public static Boolean isChange { get; set; }
- public static String accountid { get; set; }
- public static String userId { get; set; }
- public static String errorMsg { get; set; }
+ public static String agencyProType { get; set; }
+ public static Consumable_order__c coc { get; set; }
+ public static Consumable_order__c outbound { get; set; }
+ public static String invoiceId { get; set; }
+ public static String orderRemind { get; set; }
+ public static String deliveryId { get; set; }
+ public static String reopen { get; set; }
+ public static Decimal sumPrice { get; set; }
+ public static Boolean isChange { get; set; }
+ public static String accountid { get; set; }
+ public static String userId { get; set; }
+ public static String errorMsg { get; set; }
- public static Boolean getdone() {
- return (invoiceOrderdetail1Recoeds.size() > 0);
+ public static Boolean getdone() {
+ return (invoiceOrderdetail1Recoeds.size() > 0);
+ }
+
+ public static Boolean getExistOutbound() {
+ return (coc.Outbound_order__c != null);
+ }
+
+ public static String getInvoiceName() {
+ return (coc.Name);
+ }
+ public static List<Consumable_Orderdetails__c> conoList { get; set; }
+
+ public static String shipmentAccount {
+ get {
+ return (coc.ShipmentAccount__c);
}
+ }
+ public static String statusEdit = '';
+ public static Boolean editAble { get; set; }
+ public static List<InvoiceOrderInfo> invoiceOrderRecoeds { get; set; }
+ public static List<InvoiceOrderInfo> invoiceOrderdetail1Recoeds { get; set; }
+ public static List<InvoiceOrderInfo> invoiceOrderRecoedschange { get; set; }
+ public static List<InvoiceOrderInfo> attachmentRecoeds { get; set; }
+ public static List<Consumable_order__c> invoiceOrderList { get; set; }
+ public static List<Consumable_order__c> invoiceOrderSelectedList { get; set; }
+ public static Map<String, Decimal> ordermx1defaultMap { get; set; }
+ public static Map<String, Decimal> outorderMoneytMap { get; set; }
+ public static Map<String, Consumable_Orderdetails__c> outordercountMap {
+ get;
+ set;
+ }
+ public static List<String> outOrderStringList { get; set; }
+ public static List<SelectOption> provinceOpts { get; set; }
+ public static Map<String, String> provinceOptsMap { get; set; }
+ public static String SecondDealer { get; set; }
+ public static String HospitalInfo { get; set; }
+ public static String HospitalName { get; set; }
- public static Boolean getExistOutbound() {
- return (coc.Outbound_order__c != null);
+ public static Integer invoiceOrderRecoedsCount {
+ get {
+ return invoiceOrderRecoeds == null ? 0 : invoiceOrderRecoeds.size();
}
+ }
- public static String getInvoiceName() {
- return (coc.Name);
+ public static list<Dealer_elationship__c> Dealerelationship { get; set; }
+ public static String[] orderby = new List<String>{
+ 'Outbound_Date__c',
+ 'Name',
+ 'ShipmentAccount__c'
+ };
+ public static String sortKey { get; set; }
+ public static String preSortKey { get; set; }
+ public static Boolean sortOrderAsc { get; set; }
+ public static String[] sortOrder { get; set; }
+ public static String userWorkLocation { get; set; }
+
+ //椤甸潰鍒濆鍖�
+ @AuraEnabled
+ public static ResponseBodyLWC init(
+ String invoiceId,
+ String statusEdit,
+ String deliveryId
+ ) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ provinceOpts = new List<SelectOption>();
+ provinceOptsMap = new Map<String, String>();
+ invoiceOrderRecoeds = new List<InvoiceOrderInfo>();
+ attachmentRecoeds = new List<InvoiceOrderInfo>();
+ invoiceOrderdetail1Recoeds = new List<InvoiceOrderInfo>();
+ invoiceOrderRecoedschange = new List<InvoiceOrderInfo>();
+ orderRemind = '';
+ isChange = false;
+ conoList = new List<Consumable_Orderdetails__c>();
+ outorderMoneytMap = new Map<String, Decimal>();
+ outOrderStringList = new List<String>();
+ outordercountMap = new Map<String, Consumable_Orderdetails__c>();
+
+ sumPrice = 0;
+ // this.sortKey = '1';
+ // this.preSortKey = '1';
+ // this.sortOrderAsc = false;
+ // this.sortOrder = new List<String>(2);
+ // this.sortOrder = new List<String>{ ' ', ' ', ' ', ' ' };
+
+ invoiceId = invoiceId;
+ statusEdit = statusEdit;
+ deliveryId = deliveryId;
+
+ if (
+ invoiceId != null &&
+ invoiceId != '' &&
+ (statusEdit == '' ||
+ statusEdit == null)
+ ) {
+ editAble = false;
+ } else if (
+ (invoiceId == null || invoiceId == '') &&
+ (statusEdit == '' ||
+ statusEdit == null)
+ ) {
+ editAble = true;
+ } else if (
+ invoiceId != null &&
+ invoiceId != '' &&
+ statusEdit != '' &&
+ statusEdit != null
+ ) {
+ editAble = true;
}
- public static List<Consumable_Orderdetails__c> conoList { get; set; }
+ 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;
+ userWorkLocation = Useracc[0].Work_Location__c;
+ agencyProType = Useracc[0].UserPro_Type__c;
+ if (String.isBlank(Useracc[0].UserPro_Type__c)) {
+ agencyProType = 'ET';
+ }
+ coc = new Consumable_order__c();
- public static String shipmentAccount {
- get {
- return (coc.ShipmentAccount__c);
+ Dealerelationship = [
+ SELECT Dealer_subordinate__c, Dealer_subordinate__r.Name
+ FROM Dealer_elationship__c
+ WHERE Dealer_principal__c = :accountid
+ ];
+ List<Agency_Hospital_Link__c> AgencyHospitalLink = new List<Agency_Hospital_Link__c>();
+ AgencyHospitalLink = [
+ SELECT Id, Name, Hospital__c, Hospital__r.Id, Hospital__r.Name, Agency__c
+ FROM Agency_Hospital_Link__c
+ WHERE Agency__c = :accountId
+ ];
+ // 鏂拌
+ if (invoiceId == null || invoiceId == '') {
+ if (deliveryId == null || deliveryId == '') {
+ String msoql = makeSoql();
+ invoiceOrderList = Database.query(msoql);
+ for (Integer i = 0; i < invoiceOrderList.size(); i++) {
+ invoiceOrderRecoeds.add(new InvoiceOrderInfo(invoiceOrderList[i]));
}
- }
- public static String statusEdit = '';
- public static Boolean editAble { get; set; }
- public static List<InvoiceOrderInfo> invoiceOrderRecoeds { get; set; }
- public static List<InvoiceOrderInfo> invoiceOrderdetail1Recoeds { get; set; }
- public static List<InvoiceOrderInfo> invoiceOrderRecoedschange { get; set; }
- public static List<InvoiceOrderInfo> attachmentRecoeds { get; set; }
- public static List<Consumable_order__c> invoiceOrderList { get; set; }
- public static List<Consumable_order__c> invoiceOrderSelectedList { get; set; }
- public static Map<String, Decimal> ordermx1defaultMap { get; set; }
- public static Map<String, Decimal> outorderMoneytMap { get; set; }
- public static Map<String, Consumable_Orderdetails__c> outordercountMap { get; set; }
- public static List<String> outOrderStringList { get; set; }
- public static List<SelectOption> provinceOpts { get; set; }
- public static Map<String, String> provinceOptsMap { get; set; }
- public static String SecondDealer { get; set; }
- public static String HospitalInfo { get; set; }
- public static String HospitalName { get; set; }
-
- public static Integer invoiceOrderRecoedsCount {
- get {
- return invoiceOrderRecoeds == null ? 0 : invoiceOrderRecoeds.size();
+ } else {
+ if (statusEdit == '' || statusEdit == null) {
+ EditAble = false;
+ } else if (statusEdit != '' && statusEdit != null) {
+ EditAble = true;
}
- }
-
- public static list<Dealer_elationship__c> Dealerelationship { get; set; }
- public static String[] orderby = new List<String>{ 'Outbound_Date__c', 'Name', 'ShipmentAccount__c' };
- public static String sortKey { get; set; }
- public static String preSortKey { get; set; }
- public static Boolean sortOrderAsc { get; set; }
- public static String[] sortOrder { get; set; }
- public static String userWorkLocation { get; set; }
-
- //椤甸潰鍒濆鍖�
- @AuraEnabled
- public static ResponseBodyLWC init(String invoiceId, String statusEdit, String deliveryId) {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
-
- provinceOpts = new List<SelectOption>();
- provinceOptsMap = new Map<String, String>();
- invoiceOrderRecoeds = new List<InvoiceOrderInfo>();
- attachmentRecoeds = new List<InvoiceOrderInfo>();
- invoiceOrderdetail1Recoeds = new List<InvoiceOrderInfo>();
- invoiceOrderRecoedschange = new List<InvoiceOrderInfo>();
- orderRemind = '';
- isChange = false;
- conoList = new List<Consumable_Orderdetails__c>();
- outorderMoneytMap = new Map<String, Decimal>();
- outOrderStringList = new List<String>();
- outordercountMap = new Map<String, Consumable_Orderdetails__c>();
-
- sumPrice = 0;
- // this.sortKey = '1';
- // this.preSortKey = '1';
- // this.sortOrderAsc = false;
- // this.sortOrder = new List<String>(2);
- // this.sortOrder = new List<String>{ ' ', ' ', ' ', ' ' };
-
- invoiceId = invoiceId;
- statusEdit = statusEdit;
- deliveryId = deliveryId;
-
- if (invoiceId != null && invoiceId != '' && (statusEdit == '' || statusEdit == null)) {
- editAble = false;
- } else if ((invoiceId == null || invoiceId == '') && (statusEdit == '' || statusEdit == null)) {
- editAble = true;
- } else if (invoiceId != null && invoiceId != '' && statusEdit != '' && statusEdit != null) {
- editAble = true;
- }
- 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;
- userWorkLocation = Useracc[0].Work_Location__c;
- agencyProType = Useracc[0].UserPro_Type__c;
- if (String.isBlank(Useracc[0].UserPro_Type__c)) {
- agencyProType = 'ET';
- }
- coc = new Consumable_order__c();
-
- Dealerelationship = [
- SELECT Dealer_subordinate__c, Dealer_subordinate__r.Name
- FROM Dealer_elationship__c
- WHERE Dealer_principal__c = :accountid
+ coc = [
+ SELECT
+ Id,
+ Name,
+ Invoice_status__c,
+ Invoice_Date__c,
+ Order_ForDealerText__c,
+ Dealer_Info__c,
+ Order_ForDealer__c,
+ Order_ForDealer__r.Name,
+ Order_ForHospital__c,
+ Order_ForHospital__r.Name,
+ Order_date__c,
+ Billed_Status__c,
+ ShipmentAccount__c,
+ Order_Dealer_Info__c,
+ SummonsForDirction__c,
+ Order_ForCustomerText__c,
+ Invoice_Note__c,
+ Invoice_attachment__c,
+ Invoicedet_attachment__c,
+ Outbound_order__c
+ FROM Consumable_order__c
+ WHERE Id = :deliveryId
];
- List<Agency_Hospital_Link__c> AgencyHospitalLink = new List<Agency_Hospital_Link__c>();
- AgencyHospitalLink = [
- SELECT Id, Name, Hospital__c, Hospital__r.Id, Hospital__r.Name, Agency__c
- FROM Agency_Hospital_Link__c
- WHERE Agency__c = :accountId
+ coc.Name = '';
+ if (coc.Order_ForDealer__c != null) {
+ SecondDealer = coc.Order_ForDealer__c;
+ }
+
+ if (coc.Order_ForHospital__c != null) {
+ HospitalInfo = coc.Order_ForHospital__c;
+ HospitalName = coc.Order_ForHospital__r.Name;
+ }
+
+ //鍙戠エ鍏宠仈鍑哄簱鍗曞彇寰楋紙鍑哄簱鍗曪級
+ invoiceOrderSelectedList = [
+ SELECT
+ Id,
+ Order_ForDealer__r.Name,
+ Order_ForHospital__r.Name,
+ Order_ForDealerText__c,
+ Name,
+ Outbound_Date__c,
+ ShipmentAccount__c,
+ Order_Dealer_Info__c,
+ SummonsForDirction__c,
+ Shipment_total_amount__c,
+ RrturnPro_total_amount__c,
+ Total_Invoiced_Procount__c,
+ InvoiceNotPro_total_amount__c,
+ InvoiceNotPro_money__c,
+ Invoice_total_amount__c,
+ Billed_Status__c
+ FROM Consumable_order__c
+ WHERE Id = :deliveryId
+ ORDER BY Name
];
- // 鏂拌
- if (invoiceId == null || invoiceId == '') {
- if (deliveryId == null || deliveryId == '') {
- String msoql = makeSoql();
- invoiceOrderList = Database.query(msoql);
- for (Integer i = 0; i < invoiceOrderList.size(); i++) {
- invoiceOrderRecoeds.add(new InvoiceOrderInfo(invoiceOrderList[i]));
- }
- } else {
- if (statusEdit == '' || statusEdit == null) {
- EditAble = false;
- } else if (statusEdit != '' && statusEdit != null) {
- EditAble = true;
- }
- coc = [
- SELECT
- Id,
- Name,
- Invoice_status__c,
- Invoice_Date__c,
- Order_ForDealerText__c,
- Dealer_Info__c,
- Order_ForDealer__c,
- Order_ForDealer__r.Name,
- Order_ForHospital__c,
- Order_ForHospital__r.Name,
- Order_date__c,
- Billed_Status__c,
- ShipmentAccount__c,
- Order_Dealer_Info__c,
- SummonsForDirction__c,
- Order_ForCustomerText__c,
- Invoice_Note__c,
- Invoice_attachment__c,
- Invoicedet_attachment__c,
- Outbound_order__c
- FROM Consumable_order__c
- WHERE Id = :deliveryId
- ];
- coc.Name = '';
- if (coc.Order_ForDealer__c != null) {
- SecondDealer = coc.Order_ForDealer__c;
- }
+ for (Integer i = 0; i < invoiceOrderSelectedList.size(); i++) {
+ invoiceOrderRecoeds.add(
+ new InvoiceOrderInfo(invoiceOrderSelectedList[i])
+ );
+ }
+ }
+ } else {
+ coc = [
+ SELECT
+ Id,
+ Name,
+ Invoice_status__c,
+ Invoice_Date__c,
+ Order_ForDealerText__c,
+ Dealer_Info__c,
+ Order_ForDealer__c,
+ Order_ForDealer__r.Name,
+ Order_ForHospital__c,
+ Order_ForHospital__r.Name,
+ Order_date__c,
+ Billed_Status__c,
+ ShipmentAccount__c,
+ Order_Dealer_Info__c,
+ SummonsForDirction__c,
+ Order_ForCustomerText__c,
+ Invoice_Note__c,
+ Invoice_attachment__c,
+ Invoicedet_attachment__c,
+ Outbound_order__c
+ FROM Consumable_order__c
+ WHERE Id = :invoiceId AND Order_type__c = '鍙戠エ'
+ ];
+ if (coc.Order_ForDealer__c != null) {
+ SecondDealer = coc.Order_ForDealer__c;
+ }
+ if (coc.Order_ForHospital__c != null) {
+ HospitalInfo = coc.Order_ForHospital__c;
+ HospitalName = coc.Order_ForHospital__r.Name;
+ }
+ //鍒伴摼鎺ヨ〃涓煡鎵惧叧鑱斿嚭搴撳崟
+ List<Consumable_order_LinkTable__c> outOrderList = [
+ SELECT Outboundorder_Code_link__c
+ FROM Consumable_order_LinkTable__c
+ WHERE Invoice_Code_link__c = :invoiceId
+ ];
+ for (Integer i = 0; i < outOrderList.size(); i++) {
+ outOrderStringList.add(outOrderList[i].Outboundorder_Code_link__c);
+ }
+ //鍙栧緱鍑哄簱鍗曚俊鎭�
+ invoiceOrderSelectedList = [
+ SELECT
+ Id,
+ Order_ForDealer__r.Name,
+ Order_ForHospital__r.Name,
+ Order_ForDealerText__c,
+ Name,
+ Outbound_Date__c,
+ ShipmentAccount__c,
+ Shipment_total_amount__c,
+ RrturnPro_total_amount__c,
+ Total_Invoiced_Procount__c,
+ InvoiceNotPro_total_amount__c,
+ InvoiceNotPro_money__c,
+ Invoice_total_amount__c,
+ Billed_Status__c
+ FROM Consumable_order__c
+ WHERE
+ Id IN :outOrderStringList
+ AND Order_Owner_WorkLocal__c = :userWorkLocation
+ ORDER BY Name
+ ];
+ for (Integer i = 0; i < invoiceOrderSelectedList.size(); i++) {
+ outorderMoneytMap.put(invoiceOrderSelectedList[i].id, 0);
+ invoiceOrderRecoeds.add(
+ new InvoiceOrderInfo(invoiceOrderSelectedList[i])
+ );
+ }
+ if (String.isNotBlank(deliveryId)) {
+ //鍙戠エ鍏宠仈鍑哄簱鍗曞彇寰楋紙鍑哄簱鍗曪級
+ isChange = true;
+ invoiceOrderSelectedList = [
+ SELECT
+ Id,
+ Order_ForDealer__r.Name,
+ Order_ForHospital__r.Name,
+ Order_ForDealerText__c,
+ Name,
+ Outbound_Date__c,
+ ShipmentAccount__c,
+ Shipment_total_amount__c,
+ RrturnPro_total_amount__c,
+ Total_Invoiced_Procount__c,
+ InvoiceNotPro_total_amount__c,
+ InvoiceNotPro_money__c,
+ Invoice_total_amount__c,
+ Billed_Status__c
+ FROM Consumable_order__c
+ WHERE
+ Id = :deliveryId
+ AND Order_Owner_WorkLocal__c = :userWorkLocation
+ ORDER BY Name
+ ];
+ for (Integer i = 0; i < invoiceOrderSelectedList.size(); i++) {
+ if (!outorderMoneytMap.containsKey(invoiceOrderSelectedList[i].Id)) {
+ invoiceOrderRecoeds.add(
+ new InvoiceOrderInfo(invoiceOrderSelectedList[i])
+ );
+ invoiceOrderRecoedschange.add(
+ new InvoiceOrderInfo(invoiceOrderSelectedList[i])
+ );
+ }
+ }
+ }
+ //鍙戠エ鏄庣粏涓�瑙�
+ List<Consumable_Orderdetails__c> countDel = [
+ SELECT
+ Id,
+ Consumable_ZS_order__c,
+ Name,
+ Consumable_order__c,
+ Invoicedet1_OD_link__c,
+ Invoicedet1_OD_link__r.Name,
+ Consumable_order__r.Name,
+ Product_OutDate__c,
+ Asset_Model_No__c,
+ Invoice_Unitprice__c,
+ Delivery_List_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ InvoicedProCost_RMB__c,
+ Box_Piece__c,
+ Invoice_Unit__c,
+ ProductPacking_list_manual__c
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c = :invoiceId
+ ORDER BY Invoicedet1_OD_link__c
+ ];
+ if (countDel.size() > 0) {
+ for (Integer i = 0; i < countDel.size(); i++) {
+ outordercountMap.put(
+ countDel[i].Invoicedet1_OD_link__c + countDel[i].Asset_Model_No__c,
+ countDel[i]
+ );
+ if (
+ outorderMoneytMap.containsKey(countDel[i].Invoicedet1_OD_link__c)
+ ) {
+ outorderMoneytMap.put(
+ countDel[i].Invoicedet1_OD_link__c,
+ outorderMoneytMap.get(countDel[i].Invoicedet1_OD_link__c) +
+ countDel[i].InvoicedProCost_RMB__c
+ );
+ }
+ invoiceOrderdetail1Recoeds.add(new InvoiceOrderInfo(countDel[i]));
+ }
+ }
+ for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
+ if (outorderMoneytMap.containsKey(ass.esd.id)) {
+ ass.needInvoiceCount = outorderMoneytMap.get(ass.esd.id);
+ }
+ ass.check = true;
+ }
+ }
- if (coc.Order_ForHospital__c != null) {
- HospitalInfo = coc.Order_ForHospital__c;
- HospitalName = coc.Order_ForHospital__r.Name;
- }
+ if (SecondDealer == null || SecondDealer == '') {
+ provinceOpts.add(new SelectOption('', '-鏃�-'));
+ provinceOptsMap.put('', '-鏃�-');
+ for (Integer i = 0; i < Dealerelationship.size(); i++) {
+ provinceOpts.add(
+ new SelectOption(
+ Dealerelationship[i].Dealer_subordinate__c,
+ Dealerelationship[i].Dealer_subordinate__r.Name
+ )
+ );
+ provinceOptsMap.put(
+ Dealerelationship[i].Dealer_subordinate__c,
+ Dealerelationship[i].Dealer_subordinate__r.Name
+ );
+ }
+ } else {
+ provinceOpts.add(new SelectOption('', '-鏃�-'));
+ provinceOptsMap.put('', '-鏃�-');
+ for (Integer i = 0; i < Dealerelationship.size(); i++) {
+ if (Dealerelationship[i].Dealer_subordinate__r.Name == SecondDealer) {
+ provinceOpts.add(
+ new SelectOption(
+ Dealerelationship[i].Dealer_subordinate__c,
+ SecondDealer
+ )
+ );
+ provinceOptsMap.put(
+ Dealerelationship[i].Dealer_subordinate__c,
+ SecondDealer
+ );
+ }
+ }
+ for (Integer i = 0; i < Dealerelationship.size(); i++) {
+ if (Dealerelationship[i].Dealer_subordinate__r.Name != SecondDealer) {
+ provinceOpts.add(
+ new SelectOption(
+ Dealerelationship[i].Dealer_subordinate__c,
+ Dealerelationship[i].Dealer_subordinate__r.Name
+ )
+ );
+ provinceOptsMap.put(
+ Dealerelationship[i].Dealer_subordinate__c,
+ Dealerelationship[i].Dealer_subordinate__r.Name
+ );
+ }
+ }
+ }
- //鍙戠エ鍏宠仈鍑哄簱鍗曞彇寰楋紙鍑哄簱鍗曪級
- invoiceOrderSelectedList = [
- SELECT
- Id,
- Order_ForDealer__r.Name,
- Order_ForHospital__r.Name,
- Order_ForDealerText__c,
- Name,
- Outbound_Date__c,
- ShipmentAccount__c,
- Order_Dealer_Info__c,
- SummonsForDirction__c,
- Shipment_total_amount__c,
- RrturnPro_total_amount__c,
- Total_Invoiced_Procount__c,
- InvoiceNotPro_total_amount__c,
- InvoiceNotPro_money__c,
- Invoice_total_amount__c,
- Billed_Status__c
- FROM Consumable_order__c
- WHERE Id = :deliveryId
- ORDER BY Name
- ];
- for (Integer i = 0; i < invoiceOrderSelectedList.size(); i++) {
- invoiceOrderRecoeds.add(new InvoiceOrderInfo(invoiceOrderSelectedList[i]));
- }
+ Map<String, String> consumableaccessoriesMap = new Map<String, String>();
+ Map<String, String> invorceOrderIdMap = new Map<String, String>();
+ List<Consumable_accessories_invoice__c> consumableaccessories = [
+ SELECT Id, Name, Attachment_ID__c, Accessories_type__c
+ FROM Consumable_accessories_invoice__c
+ WHERE Invoice_code__c = :invoiceId
+ ];
+ System.debug('consumableaccessories = ' + consumableaccessories);
+ if (consumableaccessories.size() > 0) {
+ for (Integer i = 0; i < consumableaccessories.size(); i++) {
+ consumableaccessoriesMap.put(
+ consumableaccessories[i].Attachment_ID__c,
+ consumableaccessories[i].Accessories_type__c
+ );
+ invorceOrderIdMap.put(
+ consumableaccessories[i].Attachment_ID__c,
+ consumableaccessories[i].Id
+ );
+ }
+ }
+
+ //List<Attachment> attachmentinfo = [SELECT Id, Name, OwnerId,Owner.Name, CreatedDate FROM Attachment WHERE parentid = :invoiceId];
+ // if (attachmentinfo.size() > 0) {
+ // for (Integer i = 0; i < attachmentinfo.size(); i++) {
+ // attachmentRecoeds.add(new InvoiceOrderInfo(attachmentinfo[i]));
+ // }
+ // }
+ List<ContentDocumentLink> links = [
+ SELECT Id, ContentDocumentId
+ FROM ContentDocumentLink
+ WHERE LinkedEntityId = :invoiceId
+ ];
+ if (links != null && links.size() > 0) {
+ List<String> documentIds = new List<String>();
+ for (ContentDocumentLink link : links) {
+ documentIds.add(link.ContentDocumentId);
+ }
+ List<ContentVersion> cvInfo = [
+ SELECT Id, Title, OwnerId, Owner.Name, CreatedDate, ContentDocumentId
+ FROM ContentVersion
+ WHERE ContentDocumentId IN :documentIds
+ ];
+
+ if (cvInfo.size() > 0) {
+ for (Integer i = 0; i < cvInfo.size(); i++) {
+ attachmentRecoeds.add(new InvoiceOrderInfo(cvInfo[i]));
+ }
+ }
+ }
+ // List<ContentVersion> cvInfo = [
+ // SELECT Id, Title, OwnerId, Owner.Name, CreatedDate, ContentDocumentId
+ // FROM ContentVersion
+ // WHERE FirstPublishLocationId = :invoiceId
+ // ];
+ // if (cvInfo.size() > 0) {
+ // for (Integer i = 0; i < cvInfo.size(); i++) {
+ // attachmentRecoeds.add(new InvoiceOrderInfo(cvInfo[i]));
+ // }
+ // }
+ System.debug('attachmentRecoeds = ' + attachmentRecoeds);
+ System.debug('consumableaccessoriesMap = ' + consumableaccessoriesMap);
+ for (InvoiceOrderInfo ass : attachmentRecoeds) {
+ if (consumableaccessoriesMap.containsKey(ass.cvInfo.Id)) {
+ ass.mailSelectOptsin = consumableaccessoriesMap.get(ass.cvInfo.Id);
+ ass.invoiceOrderId = invorceOrderIdMap.get(ass.cvInfo.Id);
+ }
+ }
+ data.put('EditAble', EditAble);
+ data.put('isChange', isChange);
+ data.put('coc', coc);
+ data.put('ExistOutbound', getExistOutbound());
+ data.put('invoiceOrderRecoeds', invoiceOrderRecoeds);
+ data.put('provinceOptsMap', provinceOptsMap);
+ data.put('HospitalName', HospitalName);
+ data.put('HospitalInfo', HospitalInfo);
+ data.put('agencyProType', agencyProType);
+ data.put('userWorkLocation', userWorkLocation);
+ data.put('done', getdone());
+ data.put('invoiceOrderdetail1Recoeds', invoiceOrderdetail1Recoeds);
+ data.put('accountid', accountid);
+ data.put('invoiceOrderRecoedschange', invoiceOrderRecoedschange);
+ data.put('attachmentRecoeds', attachmentRecoeds);
+ data.put('outOrderStringList', outOrderStringList);
+ data.put('outordercountMap', outordercountMap);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ //淇濆瓨
+ @AuraEnabled
+ public static ResponseBodyLWC save(
+ Consumable_order__c cocLwc,
+ String HospitalNameLwc,
+ String HospitalInfoLwc,
+ String SecondDealerLwc,
+ String invoiceOrderRecoedsLwc,
+ String deliveryIdLwc,
+ String invoiceIdLwc,
+ String accountidLwc,
+ String agencyProTypeLwc,
+ String reopenLwc,
+ String invoiceOrderRecoedschangeLwc
+ ) {
+ System.debug('enter LexConInvoiceViewController.save success');
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ coc = cocLwc;
+ HospitalName = HospitalNameLwc;
+ HospitalInfo = HospitalInfoLwc;
+ System.debug('HospitalInfo = ' + HospitalInfo);
+ SecondDealer = SecondDealerLwc;
+ errorMsg = '';
+ deliveryId = deliveryIdLwc;
+ invoiceOrderRecoeds = (List<InvoiceOrderInfo>) JSON.deserialize(
+ invoiceOrderRecoedsLwc,
+ List<InvoiceOrderInfo>.class
+ );
+ invoiceId = invoiceIdLwc;
+ accountid = accountidLwc;
+ agencyProType = agencyProTypeLwc;
+ reopen = reopenLwc;
+ invoiceOrderRecoedschange = (List<InvoiceOrderInfo>) JSON.deserialize(
+ invoiceOrderRecoedschangeLwc,
+ List<InvoiceOrderInfo>.class
+ );
+
+ List<String> chukudanID = new List<String>();
+ if (coc.Name == '' || coc.Name == null) {
+ // coc.Name.addError('璇峰綍鍏ュ彂绁ㄥ彿');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇峰綍鍏ュ彂绁ㄥ彿', '');
+ }
+ if (coc.Invoice_Date__c == null) {
+ // coc.Invoice_Date__c.addError('璇峰綍鍏ュ彂绁ㄦ棩鏈�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇峰綍鍏ュ彂绁ㄦ棩鏈�', '');
+ }
+ if (String.isBlank(HospitalInfo) && String.isBlank(SecondDealer)) {
+ // coc.addError('蹇呴』杈撳叆瀹㈡埛鍚嶆垨鑰呬簩绾х粡閿�鍟�');
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '蹇呴』杈撳叆瀹㈡埛鍚嶆垨鑰呬簩绾х粡閿�鍟�',
+ ''
+ );
+ }
+ if (
+ HospitalInfo != null &&
+ HospitalInfo != '' &&
+ String.isNotEmpty(SecondDealer)
+ ) {
+ //coc.addError('璇疯緭鍏ュ鎴峰悕銆佷簩绾х粡閿�鍟嗗彧鍙緭鍏ヤ竴涓�');
+ errorMsg += '璇疯緭鍏ュ鎴峰悕銆佷簩绾х粡閿�鍟嗗彧鍙緭鍏ヤ竴涓�';
+ }
+ if (HospitalInfo != null && HospitalInfo != '') {
+ if (coc.Order_ForCustomerText__c == null) {
+ // coc.Order_ForCustomerText__c.addError('璇疯緭鍏ョ瀹�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ョ瀹�', '');
+ }
+ } else {
+ if (coc.Order_ForCustomerText__c != null) {
+ // coc.Order_ForCustomerText__c.addError('涓嶉渶瑕佽緭鍏ョ瀹�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '涓嶉渶瑕佽緭鍏ョ瀹�', '');
+ }
+ }
+ String shipmentAccountString = '';
+ if (HospitalInfo != null) {
+ shipmentAccountString = HospitalInfo;
+ } else if (String.isNotEmpty(SecondDealer)) {
+ shipmentAccountString = SecondDealer;
+ } else {
+ shipmentAccountString = coc.Order_ForDealerText__c == null
+ ? ''
+ : coc.Order_ForDealerText__c;
+ }
+
+ Integer x = 0;
+ List<String> invoiceOrderAccountList = new List<String>();
+ for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
+ if (String.isBlank(deliveryId)) {
+ if (ass.check == true) {
+ x++;
+ System.debug(shipmentAccountString);
+ if (HospitalInfo != null && HospitalInfo != '') {
+ if (ass.esd.Order_ForHospital__c != shipmentAccountString) {
+ invoiceOrderAccountList.add(ass.esd.Name);
}
+ }
+ if (String.isNotEmpty(SecondDealer)) {
+ if (
+ ass.esd.Order_ForDealer__c != shipmentAccountString &&
+ ass.esd.Order_ForDealerText__c != shipmentAccountString
+ ) {
+ invoiceOrderAccountList.add(ass.esd.Name);
+ }
+ }
+ if (
+ coc.Order_ForDealerText__c != null &&
+ (HospitalInfo == null ||
+ HospitalInfo == '')
+ ) {
+ if (
+ (ass.esd.Order_ForDealerText__c != null ||
+ ass.esd.Order_ForDealerText__c != '') &&
+ ass.esd.ShipmentAccount__c != shipmentAccountString
+ ) {
+ invoiceOrderAccountList.add(ass.esd.Name);
+ }
+ }
+ }
+ } else {
+ if (HospitalInfo != null && HospitalInfo != '') {
+ System.debug(
+ '++++++++++++' +
+ ass.esd.Order_ForHospital__c +
+ ' ' +
+ shipmentAccountString
+ );
+ if (ass.esd.Order_ForHospital__c != shipmentAccountString) {
+ System.debug(
+ 'HospitalInfo != null ass.esd.Order_ForHospital__c != shipmentAccountString'
+ );
+ invoiceOrderAccountList.add(ass.esd.Name);
+ }
+ }
+ //if (String.isNotEmpty(SecondDealer)) {
+ if (String.isNotEmpty(SecondDealer)) {
+ if (ass.esd.Order_ForDealer__c != shipmentAccountString) {
+ System.debug(
+ 'String.isNotEmpty(SecondDealer) ass.esd.Order_ForHospital__c != shipmentAccountString'
+ );
+ invoiceOrderAccountList.add(ass.esd.Name);
+ }
+ }
+ if (
+ coc.Order_ForDealerText__c != null &&
+ (HospitalInfo == null ||
+ HospitalInfo == '')
+ ) {
+ if (
+ (ass.esd.Order_ForDealerText__c != null ||
+ ass.esd.Order_ForDealerText__c != '') &&
+ ass.esd.ShipmentAccount__c != shipmentAccountString
+ ) {
+ System.debug(
+ 'HospitalInfo == null && ass.esd.Order_ForDealerText__c != null ass.esd.ShipmentAccount__c != shipmentAccountString'
+ );
+ invoiceOrderAccountList.add(ass.esd.Name);
+ }
+ }
+ }
+ }
+ // invoiceOrderAccountList.add('12345');
+ if (invoiceOrderAccountList.size() > 0) {
+ orderRemind =
+ invoiceOrderAccountList + '鍑哄簱鍗曞鎴峰悕涓庡彂绁ㄥ鎴峰悕涓嶄竴鑷达紒';
+ // coc.addError(invoiceOrderAccountList + '鍑哄簱鍗曞鎴峰悕涓庡彂绁ㄥ鎴峰悕涓嶄竴鑷达紒');
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ invoiceOrderAccountList + '鍑哄簱鍗曞鎴峰悕涓庡彂绁ㄥ鎴峰悕涓嶄竴鑷达紒',
+ ''
+ );
+ } else {
+ orderRemind = '';
+ }
+ if (String.isBlank(deliveryId)) {
+ if (x < 1) {
+ // coc.addError('璇烽�夋嫨闇�瑕佸紑鍙戠エ鐨勫嚭搴撳崟锛�');
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '璇烽�夋嫨闇�瑕佸紑鍙戠エ鐨勫嚭搴撳崟锛�',
+ ''
+ );
+ }
+ }
+ Consumable_order__c invoiceHead = new Consumable_order__c();
+ List<String> outOrderIdList = new List<String>();
+ List<Consumable_order_LinkTable__c> invoiceLinkList = new List<Consumable_order_LinkTable__c>();
+ Map<String, String> insertDetMap = new Map<String, String>();
+ Map<String, String> deleteDetMap = new Map<String, String>();
+ //鏂板缓鍙戠エ鏃�
+ Savepoint sp = Database.setSavepoint();
+ try {
+ if (String.isBlank(invoiceId)) {
+ invoiceHead.Name = coc.Name;
+ if (
+ coc.Invoice_status__c == null || String.isBlank(coc.Invoice_status__c)
+ )
+ coc.Invoice_status__c = '鑽夋涓�';
+ invoiceHead.Order_type__c = '鍙戠エ';
+ invoiceHead.Invoice_Date__c = coc.Invoice_Date__c;
+ invoiceHead.Dealer_Info__c = accountid;
+ invoiceHead.Invoice_Note__c = coc.Invoice_Note__c;
+ invoiceHead.Invoice_status__c = '鑽夋涓�';
+ invoiceHead.Order_ProType__c = agencyProType;
+ invoiceHead.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
+ //if (deliveryId != null) {
+ if (String.isNotBlank(deliveryId)) {
+ invoiceHead.Outbound_order__c = deliveryId;
+ }
+ invoiceHead.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ // if (SecondDealer == null) {
+ if (String.isBlank(SecondDealer)) {
+ if (HospitalInfo != null && HospitalInfo != '') {
+ invoiceHead.Order_ForHospital__c = HospitalInfo;
+ }
} else {
- coc = [
- SELECT
- Id,
- Name,
- Invoice_status__c,
- Invoice_Date__c,
- Order_ForDealerText__c,
- Dealer_Info__c,
- Order_ForDealer__c,
- Order_ForDealer__r.Name,
- Order_ForHospital__c,
- Order_ForHospital__r.Name,
- Order_date__c,
- Billed_Status__c,
- ShipmentAccount__c,
- Order_Dealer_Info__c,
- SummonsForDirction__c,
- Order_ForCustomerText__c,
- Invoice_Note__c,
- Invoice_attachment__c,
- Invoicedet_attachment__c,
- Outbound_order__c
- FROM Consumable_order__c
- WHERE Id = :invoiceId AND Order_type__c = '鍙戠エ'
+ invoiceHead.Order_ForDealer__c = SecondDealer;
+ }
+ invoiceHead.Order_ForDealerText__c = coc.Order_ForDealerText__c;
+ if (Test.isRunningTest()) {
+ invoiceHead.Order_ForHospital__c = null;
+ }
+ insert invoiceHead;
+ invoiceId = invoiceHead.Id;
+ List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
+ cocinfo = [
+ SELECT
+ Id,
+ Name,
+ Invoice_status__c,
+ Invoice_Date__c,
+ Order_ForDealerText__c,
+ Dealer_Info__c,
+ Order_ForDealer__c,
+ Order_ForDealer__r.Name,
+ Order_ForHospital__c,
+ Order_date__c,
+ Billed_Status__c,
+ ShipmentAccount__c,
+ Order_Dealer_Info__c,
+ SummonsForDirction__c,
+ Order_ForCustomerText__c,
+ Invoice_Note__c,
+ Invoice_attachment__c,
+ Invoicedet_attachment__c,
+ Outbound_order__c
+ FROM Consumable_order__c
+ WHERE Id = :invoiceId
+ ];
+ if (cocinfo.size() > 0) {
+ invoiceHead = cocinfo[0];
+ }
+ if (!String.isBlank(deliveryId)) {
+ for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
+ chukudanID.add(ass.esd.Id);
+ insertDetMap.put(ass.esd.Id, invoiceHead.Id);
+ }
+ } else {
+ for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
+ if (!String.isBlank(deliveryId)) {
+ chukudanID.add(ass.esd.Id);
+ insertDetMap.put(ass.esd.Id, invoiceHead.Id);
+ } else {
+ if (ass.check == true) {
+ chukudanID.add(ass.esd.Id);
+ insertDetMap.put(ass.esd.Id, invoiceHead.Id);
+ } else {
+ //deleteDetMap.put(ass.esd.Id,invoiceHead.Id);
+ }
+ }
+ }
+ }
+ //鏂板缓鍙戠エ鏄庣粏1
+ if (chukudanID.size() > 0) {
+ newinvoicedetails1(chukudanID);
+ }
+ //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'deleteDetMap +++++' + deleteDetMap.size()));
+ //return null;
+ if (insertDetMap.size() > 0) {
+ for (String field : insertDetMap.keySet()) {
+ List<Consumable_order_LinkTable__c> existLinkinfo = [
+ SELECT Id
+ FROM Consumable_order_LinkTable__c
+ WHERE
+ Outboundorder_Code_link__c = :field
+ AND Invoice_Code_link__c = :insertDetMap.get(field)
];
- if (coc.Order_ForDealer__c != null) {
- SecondDealer = coc.Order_ForDealer__c;
+ if (existLinkinfo.size() < 1) {
+ Consumable_order_LinkTable__c invoiceLink = new Consumable_order_LinkTable__c();
+ invoiceLink.Name = field + insertDetMap.get(field);
+ invoiceLink.Outboundorder_Code_link__c = field;
+ invoiceLink.Invoice_Code_link__c = insertDetMap.get(field);
+ invoiceLinkList.add(invoiceLink);
}
- if (coc.Order_ForHospital__c != null) {
- HospitalInfo = coc.Order_ForHospital__c;
- HospitalName = coc.Order_ForHospital__r.Name;
+ }
+ upsert invoiceLinkList;
+ }
+ } else if (
+ String.isNotBlank(reopen) &&
+ reopen.equals('isreopen') &&
+ String.isNotBlank(invoiceId)
+ ) {
+ System.debug('杩涘叆reopen');
+ invoiceHead.Name = coc.Name;
+ invoiceHead.Order_type__c = '鍙戠エ';
+ invoiceHead.Invoice_Date__c = coc.Invoice_Date__c;
+ invoiceHead.Dealer_Info__c = accountid;
+ invoiceHead.Invoice_Note__c = coc.Invoice_Note__c;
+ invoiceHead.Invoice_status__c = '鑽夋涓�';
+ invoiceHead.Order_ProType__c = agencyProType;
+ invoiceHead.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
+ //if (deliveryId != null) {
+ if (String.isNotBlank(deliveryId)) {
+ invoiceHead.Outbound_order__c = deliveryId;
+ }
+ invoiceHead.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ //if (SecondDealer == null) {
+ if (String.isBlank(SecondDealer)) {
+ if (HospitalInfo != null && HospitalInfo != '') {
+ invoiceHead.Order_ForHospital__c = HospitalInfo;
+ }
+ } else {
+ invoiceHead.Order_ForDealer__c = SecondDealer;
+ }
+ invoiceHead.Order_ForDealerText__c = coc.Order_ForDealerText__c;
+ if (Test.isRunningTest()) {
+ invoiceHead.Order_ForHospital__c = null;
+ }
+ insert invoiceHead;
+ System.debug('invoiceHead = ' + invoiceHead);
+
+ List<String> updateChukudanId = new List<String>();
+ //鑾峰彇鍘熷彂绁ㄧ浉鍏宠仈鐨勯摼鎺ヨ〃淇℃伅
+ List<Consumable_order_LinkTable__c> tLinkList = [
+ SELECT Outboundorder_Code_link__c
+ FROM Consumable_order_LinkTable__c
+ WHERE Invoice_Code_link__c = :invoiceId
+ ];
+
+ for (Consumable_order_LinkTable__c colc : tLinkList) {
+ colc.Invoice_Code_link__c = invoiceHead.Id;
+ updateChukudanId.add(colc.Outboundorder_Code_link__c);
+ }
+ System.debug('tLinkList = ' + tLinkList);
+ update tLinkList;
+ //鏇存柊鍙戠エ鏄庣粏淇℃伅
+ //鑾峰彇鍑哄簱鍗�,璁剧疆鍏宠仈鍏崇郴
+ //鑾峰彇鍑哄簱鍗曟槑缁嗕俊鎭�,鍥犱负鍑哄簱鍗曚俊鎭拰鍑哄簱鍗曟槑缁嗕俊鎭槸鍏宠仈鐨�,鎵�鏈夊彧闇�瑕佸洖婊氬嚭搴撳崟鏄庣粏淇℃伅鍗冲彲
+
+ Map<String, Consumable_Orderdetails__c> tempCocMap = new Map<String, Consumable_Orderdetails__c>();
+ List<Consumable_Orderdetails__c> tempCountList = [
+ SELECT
+ Id,
+ Consumable_order__c,
+ Asset_Model_No__c,
+ InvoicedProCost_RMB__c,
+ Invoicedet1_OD_link__c,
+ InvoicedProduct_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_BoxCount__c,
+ Invoice_Unit__c
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c = :invoiceId
+ ];
+ for (Consumable_Orderdetails__c cocTemp : tempCountList) {
+ cocTemp.Consumable_order__c = invoiceHead.Id;
+ tempCocMap.put(
+ cocTemp.Invoicedet1_OD_link__c + cocTemp.Asset_Model_No__c,
+ cocTemp
+ );
+ }
+ System.debug('tempCountList = ' + tempCountList);
+ update tempCountList;
+ List<Consumable_Orderdetails__c> updateFromList = [
+ SELECT
+ Id,
+ Consumable_order__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoice_Unitprice__c,
+ Box_Piece__c,
+ Invoice_Unit__c,
+ Consumable_order__r.Invoice_total_amount__c,
+ ProductPacking_list_manual__c,
+ InvoicedProduct_RMB__c,
+ Invoiced_BoxCount__c,
+ Shipment_amount__c,
+ Asset_Model_No__c
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c IN :updateChukudanId
+ ];
+ for (Consumable_Orderdetails__c corderc : updateFromList) {
+ String tempStr =
+ corderc.Consumable_order__c + corderc.Asset_Model_No__c;
+ if (tempCocMap.get(tempStr) != null) {
+ //璁剧疆宸插彂绁ㄩ噾棰� 鍑哄簱鍗曠殑宸插彂绁ㄩ噾棰� - 鍙戠エ鐨勫彂绁ㄩ噾棰�
+ corderc.InvoicedProCost_RMB__c =
+ corderc.InvoicedProCost_RMB__c -
+ tempCocMap.get(tempStr).InvoicedProduct_RMB__c;
+ //璁剧疆宸插彂绁ㄦ暟閲� 鍑哄簱鍗曠殑宸插彂绁ㄦ暟閲� - 鍙戠エ鐨勫彂绁ㄦ暟閲�(鐩�)
+ corderc.Invoiced_Procount__c =
+ corderc.Invoiced_Procount__c -
+ tempCocMap.get(tempStr).Invoiced_BoxCount__c;
+ //璁剧疆鍙戠エ鍗曚环
+ if (
+ corderc.Box_Piece__c == '鐩�' &&
+ corderc.Invoice_Unit__c == '涓�'
+ ) {
+ corderc.Invoice_Unitprice__c =
+ corderc.Delivery_List_RMB__c /
+ corderc.ProductPacking_list_manual__c;
+ } else {
+ corderc.Invoice_Unitprice__c = corderc.Delivery_List_RMB__c;
}
- //鍒伴摼鎺ヨ〃涓煡鎵惧叧鑱斿嚭搴撳崟
- List<Consumable_order_LinkTable__c> outOrderList = [
+ }
+ }
+
+ Consumable_order__c tempcoc = new Consumable_order__c();
+ tempcoc.Id = invoiceId;
+ System.debug('tempcoc = ' + tempcoc);
+ delete tempcoc;
+ invoiceId = invoiceHead.Id;
+ System.debug('updateFromList = ' + updateFromList);
+ update updateFromList;
+ //--------------------------------------------------------------------------
+ for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
+ if (ass.check == true) {
+ insertDetMap.put(ass.esd.Id, invoiceHead.Id);
+ } else {
+ outOrderIdList.add(ass.esd.Id);
+ deleteDetMap.put(ass.esd.Id, invoiceHead.Id);
+ }
+ }
+ if (outOrderIdList.size() > 0) {
+ getdefaultMapinfo(outOrderIdList);
+ }
+ //琚�変腑鐨勫嚭搴撳崟闆嗗悎
+ if (insertDetMap.size() > 0) {
+ List<Consumable_order_LinkTable__c> existLinkinfo = [
+ SELECT Id, Invoice_Code_link__c, Outboundorder_Code_link__c
+ FROM Consumable_order_LinkTable__c
+ WHERE
+ Outboundorder_Code_link__c IN :insertDetMap.keySet()
+ AND Invoice_Code_link__c = :invoiceHead.Id
+ ];
+ //瀛樺湪娌℃湁涓庡彂绁ㄥ缓绔嬪叧鑱斿叧绯荤殑鍑哄簱鍗�
+ List<String> templist2 = new List<String>();
+ for (Consumable_order_LinkTable__c colc : existLinkinfo) {
+ templist2.add(colc.Outboundorder_Code_link__c);
+ }
+ //鑾峰彇璇ュ嚭搴撳崟
+ for (String field : insertDetMap.keySet()) {
+ if (!templist2.contains(field)) {
+ //璇ュ嚭搴撳崟涓嶅瓨鍦ㄤ笌閾炬帴琛ㄤ腑,鏂板缓閾炬帴
+ chukudanID.add(field);
+ Consumable_order_LinkTable__c invoiceLink = new Consumable_order_LinkTable__c();
+ invoiceLink.Name = field + insertDetMap.get(field);
+ invoiceLink.Outboundorder_Code_link__c = field;
+ invoiceLink.Invoice_Code_link__c = insertDetMap.get(field);
+ invoiceLinkList.add(invoiceLink);
+ }
+ }
+ System.debug('invoiceLinkList = ' + invoiceLinkList);
+ upsert invoiceLinkList;
+ }
+ //鍒犻櫎鍑哄簱鍗曢摼鎺ヨ〃
+ if (deleteDetMap.size() > 0) {
+ List<Consumable_order_LinkTable__c> invoiceLinkdetList = new List<Consumable_order_LinkTable__c>();
+ deleteOutboundorder(deleteDetMap, invoiceHead.Id);
+ List<Consumable_order_LinkTable__c> existLinkinfo = [
+ SELECT Id, Outboundorder_Code_link__c, Invoice_Code_link__c
+ FROM Consumable_order_LinkTable__c
+ WHERE
+ Outboundorder_Code_link__c IN :deleteDetMap.keySet()
+ AND Invoice_Code_link__c = :invoiceHead.Id
+ ];
+ for (Consumable_order_LinkTable__c colctemp : existLinkinfo) {
+ if (
+ deleteDetMap.get(colctemp.Outboundorder_Code_link__c) ==
+ colctemp.Invoice_Code_link__c
+ ) {
+ //瀛樺湪涓庤鍙戠エ鍏宠仈鐨勫嚭搴撳崟
+ invoiceLinkdetList.add(colctemp);
+ }
+ }
+ System.debug('invoiceLinkdetList = ' + invoiceLinkdetList);
+ delete invoiceLinkdetList;
+ }
+ //鏂板缓鍙戠エ鏄庣粏1
+ System.debug('===>' + chukudanID);
+ System.debug('===>' + chukudanID.size());
+ if (chukudanID.size() > 0) {
+ newinvoicedetails1(chukudanID);
+ }
+ } else {
+ //CHAN-BSS5SQ update by rentongxiao 2020-09-04 end
+ //缂栬緫鍚庝繚瀛�
+ List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
+ cocinfo = [
+ SELECT
+ Id,
+ Name,
+ Invoice_status__c,
+ Invoice_Date__c,
+ Order_ForDealerText__c,
+ Dealer_Info__c,
+ Order_ForDealer__c,
+ Order_ForDealer__r.Name,
+ Order_ForHospital__c,
+ Order_date__c,
+ Billed_Status__c,
+ ShipmentAccount__c,
+ Order_Dealer_Info__c,
+ SummonsForDirction__c,
+ Order_ForCustomerText__c,
+ Invoice_Note__c,
+ Invoice_attachment__c,
+ Invoicedet_attachment__c,
+ Outbound_order__c
+ FROM Consumable_order__c
+ WHERE Id = :invoiceId
+ ];
+ if (cocinfo.size() > 0) {
+ invoiceHead = cocinfo[0];
+ }
+ if (String.isNotBlank(deliveryId)) {
+ for (InvoiceOrderInfo ass : invoiceOrderRecoedschange) {
+ insertDetMap.put(ass.esd.Id, invoiceHead.Id);
+ }
+
+ //鎹㈣揣鍗曚骇鍝佹暟閲�
+ Map<String, Decimal> needchangeOrderProcountMap = new Map<String, Decimal>();
+ Map<String, Decimal> returnProcountMap = new Map<String, Decimal>();
+ Map<String, Decimal> changeOrderProcountMap = new Map<String, Decimal>();
+ List<Consumable_Orderdetails__c> detaliFromList = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Asset_Model_No__c,
+ Shipment_Count__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ Invoice_Unitprice__c,
+ InvoiceProNot_count__c,
+ Invoice_Unit__c,
+ Box_Piece__c,
+ Invoice_Cost_RMB__c
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c = :deliveryId
+ ];
+ for (Consumable_Orderdetails__c changeOD : detaliFromList) {
+ needchangeOrderProcountMap.put(
+ changeOD.Asset_Model_No__c,
+ changeOD.Shipment_Count__c
+ );
+ }
+ //鍙戠エ杩斿搧淇℃伅
+ List<Consumable_Orderdetails__c> returnCountList = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Asset_Model_No__c,
+ Shipment_Count__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ Invoice_Unitprice__c,
+ InvoiceProNot_count__c,
+ Invoice_Cost_RMB__c,
+ Invoice_Unit__c,
+ Box_Piece__c
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c = :invoiceId
+ ];
+
+ for (Consumable_Orderdetails__c changeOD : returnCountList) {
+ if (changeOD.RrturnPro_count__c > 0) {
+ if (returnProcountMap.containsKey(changeOD.Asset_Model_No__c)) {
+ returnProcountMap.put(
+ changeOD.Asset_Model_No__c,
+ returnProcountMap.get(changeOD.Asset_Model_No__c) +
+ changeOD.RrturnPro_count__c
+ );
+ } else {
+ returnProcountMap.put(
+ changeOD.Asset_Model_No__c,
+ changeOD.RrturnPro_count__c
+ );
+ }
+ }
+ }
+
+ //宸叉崲璐у崟鍑哄簱鏁伴噺淇℃伅
+ List<Consumable_Orderdetails__c> returnCount1List = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Asset_Model_No__c,
+ Shipment_Count__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ Invoice_Unitprice__c,
+ InvoiceProNot_count__c,
+ Invoice_Cost_RMB__c,
+ Invoice_Unit__c,
+ Box_Piece__c
+ FROM Consumable_Orderdetails__c
+ WHERE
+ Consumable_order__c IN (
SELECT Outboundorder_Code_link__c
FROM Consumable_order_LinkTable__c
WHERE Invoice_Code_link__c = :invoiceId
- ];
- for (Integer i = 0; i < outOrderList.size(); i++) {
- outOrderStringList.add(outOrderList[i].Outboundorder_Code_link__c);
- }
- //鍙栧緱鍑哄簱鍗曚俊鎭�
- invoiceOrderSelectedList = [
- SELECT
- Id,
- Order_ForDealer__r.Name,
- Order_ForHospital__r.Name,
- Order_ForDealerText__c,
- Name,
- Outbound_Date__c,
- ShipmentAccount__c,
- Shipment_total_amount__c,
- RrturnPro_total_amount__c,
- Total_Invoiced_Procount__c,
- InvoiceNotPro_total_amount__c,
- InvoiceNotPro_money__c,
- Invoice_total_amount__c,
- Billed_Status__c
- FROM Consumable_order__c
- WHERE Id IN :outOrderStringList AND Order_Owner_WorkLocal__c = :userWorkLocation
- ORDER BY Name
- ];
- for (Integer i = 0; i < invoiceOrderSelectedList.size(); i++) {
- outorderMoneytMap.put(invoiceOrderSelectedList[i].id, 0);
- invoiceOrderRecoeds.add(new InvoiceOrderInfo(invoiceOrderSelectedList[i]));
- }
- if (String.isNotBlank(deliveryId)) {
- //鍙戠エ鍏宠仈鍑哄簱鍗曞彇寰楋紙鍑哄簱鍗曪級
- isChange = true;
- invoiceOrderSelectedList = [
- SELECT
- Id,
- Order_ForDealer__r.Name,
- Order_ForHospital__r.Name,
- Order_ForDealerText__c,
- Name,
- Outbound_Date__c,
- ShipmentAccount__c,
- Shipment_total_amount__c,
- RrturnPro_total_amount__c,
- Total_Invoiced_Procount__c,
- InvoiceNotPro_total_amount__c,
- InvoiceNotPro_money__c,
- Invoice_total_amount__c,
- Billed_Status__c
- FROM Consumable_order__c
- WHERE Id = :deliveryId AND Order_Owner_WorkLocal__c = :userWorkLocation
- ORDER BY Name
- ];
- for (Integer i = 0; i < invoiceOrderSelectedList.size(); i++) {
- if (!outorderMoneytMap.containsKey(invoiceOrderSelectedList[i].Id)) {
- invoiceOrderRecoeds.add(new InvoiceOrderInfo(invoiceOrderSelectedList[i]));
- invoiceOrderRecoedschange.add(new InvoiceOrderInfo(invoiceOrderSelectedList[i]));
- }
- }
- }
- //鍙戠エ鏄庣粏涓�瑙�
- List<Consumable_Orderdetails__c> countDel = [
- SELECT
- Id,
- Consumable_ZS_order__c,
- Name,
- Consumable_order__c,
- Invoicedet1_OD_link__c,
- Invoicedet1_OD_link__r.Name,
- Consumable_order__r.Name,
- Product_OutDate__c,
- Asset_Model_No__c,
- Invoice_Unitprice__c,
- Delivery_List_RMB__c,
- Invoiced_Procount__c,
- Invoiced_Count__c,
- InvoicedProCost_RMB__c,
- Box_Piece__c,
- Invoice_Unit__c,
- ProductPacking_list_manual__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :invoiceId
- ORDER BY Invoicedet1_OD_link__c
- ];
- if (countDel.size() > 0) {
- for (Integer i = 0; i < countDel.size(); i++) {
- outordercountMap.put(countDel[i].Invoicedet1_OD_link__c + countDel[i].Asset_Model_No__c, countDel[i]);
- if (outorderMoneytMap.containsKey(countDel[i].Invoicedet1_OD_link__c)) {
- outorderMoneytMap.put(
- countDel[i].Invoicedet1_OD_link__c,
- outorderMoneytMap.get(countDel[i].Invoicedet1_OD_link__c) + countDel[i].InvoicedProCost_RMB__c
- );
- }
- invoiceOrderdetail1Recoeds.add(new InvoiceOrderInfo(countDel[i]));
- }
- }
- for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
- if (outorderMoneytMap.containsKey(ass.esd.id)) {
- ass.needInvoiceCount = outorderMoneytMap.get(ass.esd.id);
- }
- ass.check = true;
- }
- }
-
- if (SecondDealer == null || SecondDealer == '') {
- provinceOpts.add(new SelectOption('', '-鏃�-'));
- provinceOptsMap.put('', '-鏃�-');
- for (Integer i = 0; i < Dealerelationship.size(); i++) {
- provinceOpts.add(
- new SelectOption(Dealerelationship[i].Dealer_subordinate__c, Dealerelationship[i].Dealer_subordinate__r.Name)
- );
- provinceOptsMap.put(Dealerelationship[i].Dealer_subordinate__c, Dealerelationship[i].Dealer_subordinate__r.Name);
- }
+ )
+ AND Consumable_order__r.Onchange_order__c = TRUE
+ AND Consumable_order__c != :deliveryId
+ ];
+ for (Consumable_Orderdetails__c changeOD : returnCount1List) {
+ changeOrderProcountMap.put(
+ changeOD.Asset_Model_No__c,
+ changeOD.Shipment_Count__c
+ );
+ }
+ outOrderchange(insertDetMap);
} else {
- provinceOpts.add(new SelectOption('', '-鏃�-'));
- provinceOptsMap.put('', '-鏃�-');
- for (Integer i = 0; i < Dealerelationship.size(); i++) {
- if (Dealerelationship[i].Dealer_subordinate__r.Name == SecondDealer) {
- provinceOpts.add(new SelectOption(Dealerelationship[i].Dealer_subordinate__c, SecondDealer));
- provinceOptsMap.put(Dealerelationship[i].Dealer_subordinate__c, SecondDealer);
- }
+ invoiceHead.Name = coc.Name;
+ invoiceHead.Invoice_status__c = coc.Invoice_status__c;
+ invoiceHead.Invoice_Date__c = coc.Invoice_Date__c;
+ invoiceHead.Dealer_Info__c = accountid;
+ invoiceHead.Invoice_Note__c = coc.Invoice_Note__c;
+ invoiceHead.Invoice_status__c = '鑽夋涓�';
+ invoiceHead.Order_ProType__c = agencyProType;
+ invoiceHead.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
+ //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'HospitalName +++++' + HospitalName));
+ //return null;
+ if (HospitalName != null && HospitalName != '') {
+ if (HospitalInfo != null && HospitalInfo != '') {
+ invoiceHead.Order_ForHospital__c = HospitalInfo;
}
- for (Integer i = 0; i < Dealerelationship.size(); i++) {
- if (Dealerelationship[i].Dealer_subordinate__r.Name != SecondDealer) {
- provinceOpts.add(
- new SelectOption(Dealerelationship[i].Dealer_subordinate__c, Dealerelationship[i].Dealer_subordinate__r.Name)
- );
- provinceOptsMap.put(Dealerelationship[i].Dealer_subordinate__c, Dealerelationship[i].Dealer_subordinate__r.Name);
- }
- }
- }
-
- Map<String, String> consumableaccessoriesMap = new Map<String, String>();
- Map<String, String> invorceOrderIdMap = new Map<String, String>();
- List<Consumable_accessories_invoice__c> consumableaccessories = [
- SELECT Id, Name, Attachment_ID__c, Accessories_type__c
- FROM Consumable_accessories_invoice__c
- WHERE Invoice_code__c = :invoiceId
- ];
- System.debug('consumableaccessories = ' + consumableaccessories);
- if (consumableaccessories.size() > 0) {
- for (Integer i = 0; i < consumableaccessories.size(); i++) {
- consumableaccessoriesMap.put(consumableaccessories[i].Attachment_ID__c, consumableaccessories[i].Accessories_type__c);
- invorceOrderIdMap.put(consumableaccessories[i].Attachment_ID__c, consumableaccessories[i].Id);
- }
- }
-
- //List<Attachment> attachmentinfo = [SELECT Id, Name, OwnerId,Owner.Name, CreatedDate FROM Attachment WHERE parentid = :invoiceId];
- // if (attachmentinfo.size() > 0) {
- // for (Integer i = 0; i < attachmentinfo.size(); i++) {
- // attachmentRecoeds.add(new InvoiceOrderInfo(attachmentinfo[i]));
- // }
- // }
- List<ContentVersion> cvInfo = [SELECT Id, Title, OwnerId,Owner.Name, CreatedDate,ContentDocumentId FROM ContentVersion WHERE FirstPublishLocationId = :invoiceId];
- if (cvInfo.size() > 0) {
- for (Integer i = 0; i < cvInfo.size(); i++) {
- attachmentRecoeds.add(new InvoiceOrderInfo(cvInfo[i]));
- }
- }
- System.debug('attachmentRecoeds = ' + attachmentRecoeds);
- System.debug('consumableaccessoriesMap = ' + consumableaccessoriesMap);
- for (InvoiceOrderInfo ass : attachmentRecoeds) {
- if (consumableaccessoriesMap.containsKey(ass.cvInfo.Id)) {
- ass.mailSelectOptsin = consumableaccessoriesMap.get(ass.cvInfo.Id);
- ass.invoiceOrderId = invorceOrderIdMap.get(ass.cvInfo.Id);
- }
- }
- data.put('EditAble', EditAble);
- data.put('isChange', isChange);
- data.put('coc', coc);
- data.put('ExistOutbound', getExistOutbound());
- data.put('invoiceOrderRecoeds', invoiceOrderRecoeds);
- data.put('provinceOptsMap', provinceOptsMap);
- data.put('HospitalName', HospitalName);
- data.put('HospitalInfo', HospitalInfo);
- data.put('agencyProType', agencyProType);
- data.put('userWorkLocation', userWorkLocation);
- data.put('done', getdone());
- data.put('invoiceOrderdetail1Recoeds', invoiceOrderdetail1Recoeds);
- data.put('accountid', accountid);
- data.put('invoiceOrderRecoedschange',invoiceOrderRecoedschange);
- data.put('attachmentRecoeds',attachmentRecoeds);
- data.put('outOrderStringList',outOrderStringList);
- data.put('outordercountMap',outordercountMap);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
- }
-
-
- //淇濆瓨
- @AuraEnabled
- public static ResponseBodyLWC save(
- Consumable_order__c cocLwc,
- String HospitalNameLwc,
- String HospitalInfoLwc,
- String SecondDealerLwc,
- String invoiceOrderRecoedsLwc,
- String deliveryIdLwc,
- String invoiceIdLwc,
- String accountidLwc,
- String agencyProTypeLwc,
- String reopenLwc,
- String invoiceOrderRecoedschangeLwc
- ) {
- System.debug('enter LexConInvoiceViewController.save success');
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
-
- coc = cocLwc;
- HospitalName = HospitalNameLwc;
- HospitalInfo = HospitalInfoLwc;
- System.debug('HospitalInfo = ' + HospitalInfo);
- SecondDealer = SecondDealerLwc;
- errorMsg = '';
- deliveryId = deliveryIdLwc;
- invoiceOrderRecoeds = (List<InvoiceOrderInfo>)JSON.deserialize(invoiceOrderRecoedsLwc, List<InvoiceOrderInfo>.class);
- invoiceId = invoiceIdLwc;
- accountid = accountidLwc;
- agencyProType = agencyProTypeLwc;
- reopen = reopenLwc;
- invoiceOrderRecoedschange = (List<InvoiceOrderInfo>)JSON.deserialize(invoiceOrderRecoedschangeLwc, List<InvoiceOrderInfo>.class);
-
- List<String> chukudanID = new List<String>();
- if (coc.Name == '' || coc.Name == null) {
- // coc.Name.addError('璇峰綍鍏ュ彂绁ㄥ彿');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇峰綍鍏ュ彂绁ㄥ彿', '');
- }
- if (coc.Invoice_Date__c == null) {
- // coc.Invoice_Date__c.addError('璇峰綍鍏ュ彂绁ㄦ棩鏈�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇峰綍鍏ュ彂绁ㄦ棩鏈�', '');
- }
- if (String.isBlank(HospitalInfo) && String.isBlank(SecondDealer)) {
- // coc.addError('蹇呴』杈撳叆瀹㈡埛鍚嶆垨鑰呬簩绾х粡閿�鍟�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '蹇呴』杈撳叆瀹㈡埛鍚嶆垨鑰呬簩绾х粡閿�鍟�', '');
- }
- if (HospitalInfo != null && HospitalInfo != '' && String.isNotEmpty(SecondDealer)) {
- //coc.addError('璇疯緭鍏ュ鎴峰悕銆佷簩绾х粡閿�鍟嗗彧鍙緭鍏ヤ竴涓�');
- errorMsg += '璇疯緭鍏ュ鎴峰悕銆佷簩绾х粡閿�鍟嗗彧鍙緭鍏ヤ竴涓�';
- }
- if (HospitalInfo != null && HospitalInfo != '') {
- if (coc.Order_ForCustomerText__c == null) {
- // coc.Order_ForCustomerText__c.addError('璇疯緭鍏ョ瀹�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ョ瀹�', '');
- }
- } else {
- if (coc.Order_ForCustomerText__c != null) {
- // coc.Order_ForCustomerText__c.addError('涓嶉渶瑕佽緭鍏ョ瀹�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '涓嶉渶瑕佽緭鍏ョ瀹�', '');
- }
- }
- String shipmentAccountString = '';
- if (HospitalInfo != null) {
- shipmentAccountString = HospitalInfo;
- } else if (String.isNotEmpty(SecondDealer)) {
- shipmentAccountString = SecondDealer;
- } else {
- shipmentAccountString = coc.Order_ForDealerText__c == null ? '' : coc.Order_ForDealerText__c;
- }
-
- Integer x = 0;
- List<String> invoiceOrderAccountList = new List<String>();
- for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
- if (String.isBlank(deliveryId)) {
- if (ass.check == true) {
- x++;
- System.debug(shipmentAccountString);
- if (HospitalInfo != null && HospitalInfo != '') {
- if (ass.esd.Order_ForHospital__c != shipmentAccountString) {
- invoiceOrderAccountList.add(ass.esd.Name);
- }
- }
- if (String.isNotEmpty(SecondDealer)) {
- if (
- ass.esd.Order_ForDealer__c != shipmentAccountString &&
- ass.esd.Order_ForDealerText__c != shipmentAccountString
- ) {
- invoiceOrderAccountList.add(ass.esd.Name);
- }
- }
- if (coc.Order_ForDealerText__c != null && (HospitalInfo == null || HospitalInfo == '')) {
- if (
- (ass.esd.Order_ForDealerText__c != null || ass.esd.Order_ForDealerText__c != '') &&
- ass.esd.ShipmentAccount__c != shipmentAccountString
- ) {
- invoiceOrderAccountList.add(ass.esd.Name);
- }
- }
- }
+ } else {
+ invoiceHead.Order_ForHospital__c = null;
+ }
+ invoiceHead.Order_ForDealer__c = SecondDealer == ''
+ ? null
+ : SecondDealer;
+ invoiceHead.Order_ForDealerText__c = coc.Order_ForDealerText__c;
+ update invoiceHead;
+ for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
+ if (ass.check == true) {
+ insertDetMap.put(ass.esd.Id, invoiceHead.Id);
} else {
- if (HospitalInfo != null && HospitalInfo != '') {
-
- System.debug('++++++++++++' + ass.esd.Order_ForHospital__c + ' ' + shipmentAccountString);
- if (ass.esd.Order_ForHospital__c != shipmentAccountString) {
- System.debug('HospitalInfo != null ass.esd.Order_ForHospital__c != shipmentAccountString');
- invoiceOrderAccountList.add(ass.esd.Name);
- }
- }
- //if (String.isNotEmpty(SecondDealer)) {
- if (String.isNotEmpty(SecondDealer)) {
- if (ass.esd.Order_ForDealer__c != shipmentAccountString) {
- System.debug('String.isNotEmpty(SecondDealer) ass.esd.Order_ForHospital__c != shipmentAccountString');
- invoiceOrderAccountList.add(ass.esd.Name);
- }
- }
- if (coc.Order_ForDealerText__c != null && (HospitalInfo == null || HospitalInfo == '')) {
- if (
- (ass.esd.Order_ForDealerText__c != null || ass.esd.Order_ForDealerText__c != '') &&
- ass.esd.ShipmentAccount__c != shipmentAccountString
- ) {
- System.debug('HospitalInfo == null && ass.esd.Order_ForDealerText__c != null ass.esd.ShipmentAccount__c != shipmentAccountString');
- invoiceOrderAccountList.add(ass.esd.Name);
- }
- }
+ outOrderIdList.add(ass.esd.Id);
+ deleteDetMap.put(ass.esd.Id, invoiceHead.Id);
}
- }
- // invoiceOrderAccountList.add('12345');
- if (invoiceOrderAccountList.size() > 0) {
- orderRemind = invoiceOrderAccountList + '鍑哄簱鍗曞鎴峰悕涓庡彂绁ㄥ鎴峰悕涓嶄竴鑷达紒';
- // coc.addError(invoiceOrderAccountList + '鍑哄簱鍗曞鎴峰悕涓庡彂绁ㄥ鎴峰悕涓嶄竴鑷达紒');
- // return null;
- return new ResponseBodyLWC('Error', 500, invoiceOrderAccountList + '鍑哄簱鍗曞鎴峰悕涓庡彂绁ㄥ鎴峰悕涓嶄竴鑷达紒', '');
- } else {
- orderRemind = '';
- }
- if (String.isBlank(deliveryId)) {
- if (x < 1) {
- // coc.addError('璇烽�夋嫨闇�瑕佸紑鍙戠エ鐨勫嚭搴撳崟锛�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇烽�夋嫨闇�瑕佸紑鍙戠エ鐨勫嚭搴撳崟锛�', '');
+ }
+ if (outOrderIdList.size() > 0) {
+ getdefaultMapinfo(outOrderIdList);
+ }
+ //CHAN-BSS5SQ update by rentongxiao 2020-09-08 start
+ //琚�変腑鐨勫嚭搴撳崟闆嗗悎
+ if (insertDetMap.size() > 0) {
+ List<Consumable_order_LinkTable__c> existLinkinfo = [
+ SELECT Id, Invoice_Code_link__c, Outboundorder_Code_link__c
+ FROM Consumable_order_LinkTable__c
+ WHERE
+ Outboundorder_Code_link__c IN :insertDetMap.keySet()
+ AND Invoice_Code_link__c = :invoiceHead.Id
+ ];
+ //瀛樺湪娌℃湁涓庡彂绁ㄥ缓绔嬪叧鑱斿叧绯荤殑鍑哄簱鍗�
+ List<String> templist2 = new List<String>();
+ for (Consumable_order_LinkTable__c colc : existLinkinfo) {
+ templist2.add(colc.Outboundorder_Code_link__c);
}
- }
- Consumable_order__c invoiceHead = new Consumable_order__c();
- List<String> outOrderIdList = new List<String>();
- List<Consumable_order_LinkTable__c> invoiceLinkList = new List<Consumable_order_LinkTable__c>();
- Map<String, String> insertDetMap = new Map<String, String>();
- Map<String, String> deleteDetMap = new Map<String, String>();
- //鏂板缓鍙戠エ鏃�
- Savepoint sp = Database.setSavepoint();
- try {
- if (String.isBlank(invoiceId)) {
- invoiceHead.Name = coc.Name;
- if (coc.Invoice_status__c == null || String.isBlank(coc.Invoice_status__c))
- coc.Invoice_status__c = '鑽夋涓�';
- invoiceHead.Order_type__c = '鍙戠エ';
- invoiceHead.Invoice_Date__c = coc.Invoice_Date__c;
- invoiceHead.Dealer_Info__c = accountid;
- invoiceHead.Invoice_Note__c = coc.Invoice_Note__c;
- invoiceHead.Invoice_status__c = '鑽夋涓�';
- invoiceHead.Order_ProType__c = agencyProType;
- invoiceHead.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
- //if (deliveryId != null) {
- if (String.isNotBlank(deliveryId)) {
- invoiceHead.Outbound_order__c = deliveryId;
- }
- invoiceHead.RecordTypeid = System.Label.RT_ConOrder_Invoice;
- // if (SecondDealer == null) {
- if (String.isBlank(SecondDealer)) {
- if (HospitalInfo != null && HospitalInfo != '') {
- invoiceHead.Order_ForHospital__c = HospitalInfo;
- }
- } else {
- invoiceHead.Order_ForDealer__c = SecondDealer;
- }
- invoiceHead.Order_ForDealerText__c = coc.Order_ForDealerText__c;
-
- insert invoiceHead;
-
- invoiceId = invoiceHead.Id;
- List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
- cocinfo = [
- SELECT
- Id,
- Name,
- Invoice_status__c,
- Invoice_Date__c,
- Order_ForDealerText__c,
- Dealer_Info__c,
- Order_ForDealer__c,
- Order_ForDealer__r.Name,
- Order_ForHospital__c,
- Order_date__c,
- Billed_Status__c,
- ShipmentAccount__c,
- Order_Dealer_Info__c,
- SummonsForDirction__c,
- Order_ForCustomerText__c,
- Invoice_Note__c,
- Invoice_attachment__c,
- Invoicedet_attachment__c,
- Outbound_order__c
- FROM Consumable_order__c
- WHERE Id = :invoiceId
- ];
- if (cocinfo.size() > 0) {
- invoiceHead = cocinfo[0];
- }
- if (!String.isBlank(deliveryId)) {
- for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
- chukudanID.add(ass.esd.Id);
- insertDetMap.put(ass.esd.Id, invoiceHead.Id);
- }
- } else {
- for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
- if (!String.isBlank(deliveryId)) {
- chukudanID.add(ass.esd.Id);
- insertDetMap.put(ass.esd.Id, invoiceHead.Id);
- } else {
- if (ass.check == true) {
- chukudanID.add(ass.esd.Id);
- insertDetMap.put(ass.esd.Id, invoiceHead.Id);
- } else {
- //deleteDetMap.put(ass.esd.Id,invoiceHead.Id);
- }
- }
- }
- }
- //鏂板缓鍙戠エ鏄庣粏1
- if (chukudanID.size() > 0) {
- newinvoicedetails1(chukudanID);
- }
- //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'deleteDetMap +++++' + deleteDetMap.size()));
- //return null;
- if (insertDetMap.size() > 0) {
- for (String field : insertDetMap.keySet()) {
- List<Consumable_order_LinkTable__c> existLinkinfo = [
- SELECT Id
- FROM Consumable_order_LinkTable__c
- WHERE Outboundorder_Code_link__c = :field AND Invoice_Code_link__c = :insertDetMap.get(field)
- ];
- if (existLinkinfo.size() < 1) {
- Consumable_order_LinkTable__c invoiceLink = new Consumable_order_LinkTable__c();
- invoiceLink.Name = field + insertDetMap.get(field);
- invoiceLink.Outboundorder_Code_link__c = field;
- invoiceLink.Invoice_Code_link__c = insertDetMap.get(field);
- invoiceLinkList.add(invoiceLink);
- }
- }
- upsert invoiceLinkList;
- }
- } else if (String.isNotBlank(reopen) && reopen.equals('isreopen') && String.isNotBlank(invoiceId)) {
- System.debug('杩涘叆reopen');
- invoiceHead.Name = coc.Name;
- invoiceHead.Order_type__c = '鍙戠エ';
- invoiceHead.Invoice_Date__c = coc.Invoice_Date__c;
- invoiceHead.Dealer_Info__c = accountid;
- invoiceHead.Invoice_Note__c = coc.Invoice_Note__c;
- invoiceHead.Invoice_status__c = '鑽夋涓�';
- invoiceHead.Order_ProType__c = agencyProType;
- invoiceHead.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
- //if (deliveryId != null) {
- if (String.isNotBlank(deliveryId)) {
- invoiceHead.Outbound_order__c = deliveryId;
- }
- invoiceHead.RecordTypeid = System.Label.RT_ConOrder_Invoice;
- //if (SecondDealer == null) {
- if (String.isBlank(SecondDealer)) {
- if (HospitalInfo != null && HospitalInfo != '') {
- invoiceHead.Order_ForHospital__c = HospitalInfo;
- }
- } else {
- invoiceHead.Order_ForDealer__c = SecondDealer;
- }
- invoiceHead.Order_ForDealerText__c = coc.Order_ForDealerText__c;
- insert invoiceHead;
- System.debug('invoiceHead = ' + invoiceHead);
-
- List<String> updateChukudanId = new List<String>();
- //鑾峰彇鍘熷彂绁ㄧ浉鍏宠仈鐨勯摼鎺ヨ〃淇℃伅
- List<Consumable_order_LinkTable__c> tLinkList = [
- SELECT Outboundorder_Code_link__c
- FROM Consumable_order_LinkTable__c
- WHERE Invoice_Code_link__c = :invoiceId
- ];
-
- for (Consumable_order_LinkTable__c colc : tLinkList) {
- colc.Invoice_Code_link__c = invoiceHead.Id;
- updateChukudanId.add(colc.Outboundorder_Code_link__c);
- }
- System.debug('tLinkList = ' + tLinkList);
- update tLinkList;
- //鏇存柊鍙戠エ鏄庣粏淇℃伅
- //鑾峰彇鍑哄簱鍗�,璁剧疆鍏宠仈鍏崇郴
- //鑾峰彇鍑哄簱鍗曟槑缁嗕俊鎭�,鍥犱负鍑哄簱鍗曚俊鎭拰鍑哄簱鍗曟槑缁嗕俊鎭槸鍏宠仈鐨�,鎵�鏈夊彧闇�瑕佸洖婊氬嚭搴撳崟鏄庣粏淇℃伅鍗冲彲
-
- Map<String, Consumable_Orderdetails__c> tempCocMap = new Map<String, Consumable_Orderdetails__c>();
- List<Consumable_Orderdetails__c> tempCountList = [
- SELECT
- Id,
- Consumable_order__c,
- Asset_Model_No__c,
- InvoicedProCost_RMB__c,
- Invoicedet1_OD_link__c,
- InvoicedProduct_RMB__c,
- Invoiced_Procount__c,
- Invoiced_BoxCount__c,
- Invoice_Unit__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :invoiceId
- ];
- for (Consumable_Orderdetails__c cocTemp : tempCountList) {
- cocTemp.Consumable_order__c = invoiceHead.Id;
- tempCocMap.put(cocTemp.Invoicedet1_OD_link__c + cocTemp.Asset_Model_No__c, cocTemp);
- }
- System.debug('tempCountList = ' + tempCountList);
- update tempCountList;
- List<Consumable_Orderdetails__c> updateFromList = [
- SELECT
- Id,
- Consumable_order__c,
- RrturnPro_count__c,
- Delivery_List_RMB__c,
- InvoicedProCost_RMB__c,
- Invoiced_Procount__c,
- Invoice_Unitprice__c,
- Box_Piece__c,
- Invoice_Unit__c,
- Consumable_order__r.Invoice_total_amount__c,
- ProductPacking_list_manual__c,
- InvoicedProduct_RMB__c,
- Invoiced_BoxCount__c,
- Shipment_amount__c,
- Asset_Model_No__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c IN :updateChukudanId
- ];
- for (Consumable_Orderdetails__c corderc : updateFromList) {
- String tempStr = corderc.Consumable_order__c + corderc.Asset_Model_No__c;
- if (tempCocMap.get(tempStr) != null) {
- //璁剧疆宸插彂绁ㄩ噾棰� 鍑哄簱鍗曠殑宸插彂绁ㄩ噾棰� - 鍙戠エ鐨勫彂绁ㄩ噾棰�
- corderc.InvoicedProCost_RMB__c = corderc.InvoicedProCost_RMB__c - tempCocMap.get(tempStr).InvoicedProduct_RMB__c;
- //璁剧疆宸插彂绁ㄦ暟閲� 鍑哄簱鍗曠殑宸插彂绁ㄦ暟閲� - 鍙戠エ鐨勫彂绁ㄦ暟閲�(鐩�)
- corderc.Invoiced_Procount__c = corderc.Invoiced_Procount__c - tempCocMap.get(tempStr).Invoiced_BoxCount__c;
- //璁剧疆鍙戠エ鍗曚环
- if (corderc.Box_Piece__c == '鐩�' && corderc.Invoice_Unit__c == '涓�') {
- corderc.Invoice_Unitprice__c = corderc.Delivery_List_RMB__c / corderc.ProductPacking_list_manual__c;
- } else {
- corderc.Invoice_Unitprice__c = corderc.Delivery_List_RMB__c;
- }
- }
- }
-
- Consumable_order__c tempcoc = new Consumable_order__c();
- tempcoc.Id = invoiceId;
- System.debug('tempcoc = ' + tempcoc);
- delete tempcoc;
- invoiceId = invoiceHead.Id;
- System.debug('updateFromList = ' + updateFromList);
- update updateFromList;
- //--------------------------------------------------------------------------
- for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
- if (ass.check == true) {
- insertDetMap.put(ass.esd.Id, invoiceHead.Id);
- } else {
- outOrderIdList.add(ass.esd.Id);
- deleteDetMap.put(ass.esd.Id, invoiceHead.Id);
- }
- }
- if (outOrderIdList.size() > 0) {
- getdefaultMapinfo(outOrderIdList);
- }
- //琚�変腑鐨勫嚭搴撳崟闆嗗悎
- if (insertDetMap.size() > 0) {
- List<Consumable_order_LinkTable__c> existLinkinfo = [
- SELECT Id, Invoice_Code_link__c, Outboundorder_Code_link__c
- FROM Consumable_order_LinkTable__c
- WHERE Outboundorder_Code_link__c IN :insertDetMap.keySet() AND Invoice_Code_link__c = :invoiceHead.Id
- ];
- //瀛樺湪娌℃湁涓庡彂绁ㄥ缓绔嬪叧鑱斿叧绯荤殑鍑哄簱鍗�
- List<String> templist2 = new List<String>();
- for (Consumable_order_LinkTable__c colc : existLinkinfo) {
- templist2.add(colc.Outboundorder_Code_link__c);
- }
- //鑾峰彇璇ュ嚭搴撳崟
- for (String field : insertDetMap.keySet()) {
- if (!templist2.contains(field)) {
- //璇ュ嚭搴撳崟涓嶅瓨鍦ㄤ笌閾炬帴琛ㄤ腑,鏂板缓閾炬帴
- chukudanID.add(field);
- Consumable_order_LinkTable__c invoiceLink = new Consumable_order_LinkTable__c();
- invoiceLink.Name = field + insertDetMap.get(field);
- invoiceLink.Outboundorder_Code_link__c = field;
- invoiceLink.Invoice_Code_link__c = insertDetMap.get(field);
- invoiceLinkList.add(invoiceLink);
- }
- }
- System.debug('invoiceLinkList = ' + invoiceLinkList);
- upsert invoiceLinkList;
- }
- //鍒犻櫎鍑哄簱鍗曢摼鎺ヨ〃
- if (deleteDetMap.size() > 0) {
- List<Consumable_order_LinkTable__c> invoiceLinkdetList = new List<Consumable_order_LinkTable__c>();
- deleteOutboundorder(deleteDetMap, invoiceHead.Id);
- List<Consumable_order_LinkTable__c> existLinkinfo = [
- SELECT Id, Outboundorder_Code_link__c, Invoice_Code_link__c
- FROM Consumable_order_LinkTable__c
- WHERE Outboundorder_Code_link__c IN :deleteDetMap.keySet() AND Invoice_Code_link__c = :invoiceHead.Id
- ];
- for (Consumable_order_LinkTable__c colctemp : existLinkinfo) {
- if (deleteDetMap.get(colctemp.Outboundorder_Code_link__c) == colctemp.Invoice_Code_link__c) {
- //瀛樺湪涓庤鍙戠エ鍏宠仈鐨勫嚭搴撳崟
- invoiceLinkdetList.add(colctemp);
- }
- }
- System.debug('invoiceLinkdetList = ' + invoiceLinkdetList);
- delete invoiceLinkdetList;
- }
- //鏂板缓鍙戠エ鏄庣粏1
- if (chukudanID.size() > 0) {
- newinvoicedetails1(chukudanID);
- }
- } else {
- //CHAN-BSS5SQ update by rentongxiao 2020-09-04 end
- //缂栬緫鍚庝繚瀛�
- List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
- cocinfo = [
- SELECT
- Id,
- Name,
- Invoice_status__c,
- Invoice_Date__c,
- Order_ForDealerText__c,
- Dealer_Info__c,
- Order_ForDealer__c,
- Order_ForDealer__r.Name,
- Order_ForHospital__c,
- Order_date__c,
- Billed_Status__c,
- ShipmentAccount__c,
- Order_Dealer_Info__c,
- SummonsForDirction__c,
- Order_ForCustomerText__c,
- Invoice_Note__c,
- Invoice_attachment__c,
- Invoicedet_attachment__c,
- Outbound_order__c
- FROM Consumable_order__c
- WHERE Id = :invoiceId
- ];
- if (cocinfo.size() > 0) {
- invoiceHead = cocinfo[0];
- }
- if (String.isNotBlank(deliveryId)) {
- for (InvoiceOrderInfo ass : invoiceOrderRecoedschange) {
- insertDetMap.put(ass.esd.Id, invoiceHead.Id);
- }
-
- //鎹㈣揣鍗曚骇鍝佹暟閲�
- Map<String, Decimal> needchangeOrderProcountMap = new Map<String, Decimal>();
- Map<String, Decimal> returnProcountMap = new Map<String, Decimal>();
- Map<String, Decimal> changeOrderProcountMap = new Map<String, Decimal>();
- List<Consumable_Orderdetails__c> detaliFromList = [
- SELECT
- Id,
- Name,
- Consumable_order__c,
- Asset_Model_No__c,
- Shipment_Count__c,
- RrturnPro_count__c,
- Delivery_List_RMB__c,
- InvoicedProCost_RMB__c,
- Invoiced_Procount__c,
- Invoiced_Count__c,
- Invoice_Unitprice__c,
- InvoiceProNot_count__c,
- Invoice_Unit__c,
- Box_Piece__c,
- Invoice_Cost_RMB__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :deliveryId
- ];
- for (Consumable_Orderdetails__c changeOD : detaliFromList) {
- needchangeOrderProcountMap.put(changeOD.Asset_Model_No__c, changeOD.Shipment_Count__c);
- }
- //鍙戠エ杩斿搧淇℃伅
- List<Consumable_Orderdetails__c> returnCountList = [
- SELECT
- Id,
- Name,
- Consumable_order__c,
- Asset_Model_No__c,
- Shipment_Count__c,
- RrturnPro_count__c,
- Delivery_List_RMB__c,
- InvoicedProCost_RMB__c,
- Invoiced_Procount__c,
- Invoiced_Count__c,
- Invoice_Unitprice__c,
- InvoiceProNot_count__c,
- Invoice_Cost_RMB__c,
- Invoice_Unit__c,
- Box_Piece__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :invoiceId
- ];
-
- for (Consumable_Orderdetails__c changeOD : returnCountList) {
- if (changeOD.RrturnPro_count__c > 0) {
- if (returnProcountMap.containsKey(changeOD.Asset_Model_No__c)) {
- returnProcountMap.put(
- changeOD.Asset_Model_No__c,
- returnProcountMap.get(changeOD.Asset_Model_No__c) + changeOD.RrturnPro_count__c
- );
- } else {
- returnProcountMap.put(changeOD.Asset_Model_No__c, changeOD.RrturnPro_count__c);
- }
- }
- }
-
- //宸叉崲璐у崟鍑哄簱鏁伴噺淇℃伅
- List<Consumable_Orderdetails__c> returnCount1List = [
- SELECT
- Id,
- Name,
- Consumable_order__c,
- Asset_Model_No__c,
- Shipment_Count__c,
- RrturnPro_count__c,
- Delivery_List_RMB__c,
- InvoicedProCost_RMB__c,
- Invoiced_Procount__c,
- Invoiced_Count__c,
- Invoice_Unitprice__c,
- InvoiceProNot_count__c,
- Invoice_Cost_RMB__c,
- Invoice_Unit__c,
- Box_Piece__c
- FROM Consumable_Orderdetails__c
- WHERE
- Consumable_order__c IN (
- SELECT Outboundorder_Code_link__c
- FROM Consumable_order_LinkTable__c
- WHERE Invoice_Code_link__c = :invoiceId
- )
- AND Consumable_order__r.Onchange_order__c = TRUE
- AND Consumable_order__c != :deliveryId
- ];
- for (Consumable_Orderdetails__c changeOD : returnCount1List) {
- changeOrderProcountMap.put(changeOD.Asset_Model_No__c, changeOD.Shipment_Count__c);
- }
- outOrderchange(insertDetMap);
- } else {
- invoiceHead.Name = coc.Name;
- invoiceHead.Invoice_status__c = coc.Invoice_status__c;
- invoiceHead.Invoice_Date__c = coc.Invoice_Date__c;
- invoiceHead.Dealer_Info__c = accountid;
- invoiceHead.Invoice_Note__c = coc.Invoice_Note__c;
- invoiceHead.Invoice_status__c = '鑽夋涓�';
- invoiceHead.Order_ProType__c = agencyProType;
- invoiceHead.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
- //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'HospitalName +++++' + HospitalName));
- //return null;
- if (HospitalName != null && HospitalName != '') {
- if (HospitalInfo != null && HospitalInfo != '') {
- invoiceHead.Order_ForHospital__c = HospitalInfo;
- }
- } else {
- invoiceHead.Order_ForHospital__c = null;
- }
- invoiceHead.Order_ForDealer__c = SecondDealer == '' ? null : SecondDealer;
- invoiceHead.Order_ForDealerText__c = coc.Order_ForDealerText__c;
- update invoiceHead;
- for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
- if (ass.check == true) {
- insertDetMap.put(ass.esd.Id, invoiceHead.Id);
- } else {
- outOrderIdList.add(ass.esd.Id);
- deleteDetMap.put(ass.esd.Id, invoiceHead.Id);
- }
- }
- if (outOrderIdList.size() > 0) {
- getdefaultMapinfo(outOrderIdList);
- }
- //CHAN-BSS5SQ update by rentongxiao 2020-09-08 start
- //琚�変腑鐨勫嚭搴撳崟闆嗗悎
- if (insertDetMap.size() > 0) {
- List<Consumable_order_LinkTable__c> existLinkinfo = [
- SELECT Id, Invoice_Code_link__c, Outboundorder_Code_link__c
- FROM Consumable_order_LinkTable__c
- WHERE Outboundorder_Code_link__c IN :insertDetMap.keySet() AND Invoice_Code_link__c = :invoiceHead.Id
- ];
- //瀛樺湪娌℃湁涓庡彂绁ㄥ缓绔嬪叧鑱斿叧绯荤殑鍑哄簱鍗�
- List<String> templist2 = new List<String>();
- for (Consumable_order_LinkTable__c colc : existLinkinfo) {
- templist2.add(colc.Outboundorder_Code_link__c);
- }
- //鑾峰彇璇ュ嚭搴撳崟
- for (String field : insertDetMap.keySet()) {
- if (!templist2.contains(field)) {
- //璇ュ嚭搴撳崟涓嶅瓨鍦ㄤ笌閾炬帴琛ㄤ腑,鏂板缓閾炬帴
- chukudanID.add(field);
- Consumable_order_LinkTable__c invoiceLink = new Consumable_order_LinkTable__c();
- invoiceLink.Name = field + insertDetMap.get(field);
- invoiceLink.Outboundorder_Code_link__c = field;
- invoiceLink.Invoice_Code_link__c = insertDetMap.get(field);
- invoiceLinkList.add(invoiceLink);
- }
- }
- upsert invoiceLinkList;
- }
- if (deleteDetMap.size() > 0) {
- List<Consumable_order_LinkTable__c> invoiceLinkdetList = new List<Consumable_order_LinkTable__c>();
- deleteOutboundorder(deleteDetMap, invoiceHead.Id);
- List<Consumable_order_LinkTable__c> existLinkinfo = [
- SELECT Id, Outboundorder_Code_link__c, Invoice_Code_link__c
- FROM Consumable_order_LinkTable__c
- WHERE Outboundorder_Code_link__c IN :deleteDetMap.keySet() AND Invoice_Code_link__c = :invoiceHead.Id
- ];
- for (Consumable_order_LinkTable__c colctemp : existLinkinfo) {
- if (deleteDetMap.get(colctemp.Outboundorder_Code_link__c) == colctemp.Invoice_Code_link__c) {
- //瀛樺湪涓庤鍙戠エ鍏宠仈鐨勫嚭搴撳崟
- invoiceLinkdetList.add(colctemp);
- }
- }
- delete invoiceLinkdetList;
- }
- //CHAN-BSS5SQ update by rentongxiao 2020-09-08 end
- //鏂板缓鍙戠エ鏄庣粏1
- if (chukudanID.size() > 0) {
- newinvoicedetails1(chukudanID);
- }
- }
- }
- } catch (Exception ex) {
- Database.rollback(sp);
- // ApexPages.addMessages(ex);
- // return null;
- System.debug('Exception ex = ' + ex.getMessage() + ex.getLineNumber());
- errorMsg += ex.getMessage() + ex.getLineNumber();
- }
- data.put('invoiceId', invoiceId);
- res.status = 'Success';
- res.code = 200;
- res.msg = errorMsg;
- System.debug('res = ' + res);
- return res;
- }
-
- public static void newinvoicedetails1(List<String> chukudanID) {
- //鏂拌鍙戠エ鏄庣粏1
- List<Consumable_Orderdetails__c> invoiceorderList1 = new List<Consumable_Orderdetails__c>();
- //鍑哄簱鍗曟槑缁嗘洿鏂�
- List<Consumable_Orderdetails__c> outOrderList1 = new List<Consumable_Orderdetails__c>();
- List<Consumable_Orderdetails__c> detaliFromList = [
- SELECT
- Id,
- Name,
- Consumable_order__c,
- Asset_Model_No__c,
- Consumable_Product__r.Asset_Model_No__c,
- Shipment_Count__c,
- RrturnPro_count__c,
- Delivery_List_RMB__c,
- InvoicedProCost_RMB__c,
- Invoiced_Procount__c,
- Invoiced_Count__c,
- Invoice_Unitprice__c,
- InvoiceProNot_count__c,
- Invoice_Cost_RMB__c,
- Invoice_No__c,
- Consumable_Product__c,
- Intra_Trade_List_RMB__c,
- Dealer_Custom_Price__c,
- Sum_of_money__c,
- Box_Piece__c,
- Used_date__c,
- Send_date__c,
- Invoice_Unit__c,
- ProductPacking_list_manual__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c IN :chukudanID AND InvoiceProNot_count__c > 0
- ];
-
- for (Integer i = 0; i < detaliFromList.size(); i++) {
- Consumable_Orderdetails__c invoiceInsert1 = new Consumable_Orderdetails__c();
- invoiceInsert1.Used_date__c = detaliFromList[i].Used_date__c;
- invoiceInsert1.Send_date__c = detaliFromList[i].Send_date__c;
- String str = string.valueOf(i + 1);
- if (str.length() == 1) {
- str = '0' + str;
- }
- invoiceInsert1.Name =
- coc.Name +
- '-' +
- detaliFromList[i].Name.substring(detaliFromList[i].Name.length() - 7, detaliFromList[i].Name.length());
- invoiceInsert1.Shipment_Count__c = detaliFromList[i].InvoiceProNot_count__c;
- invoiceInsert1.Consumable_Product__c = detaliFromList[i].Consumable_Product__c;
- invoiceInsert1.Intra_Trade_List_RMB__c = detaliFromList[i].Intra_Trade_List_RMB__c;
- invoiceInsert1.Delivery_List_RMB__c = detaliFromList[i].Delivery_List_RMB__c;
- invoiceInsert1.Dealer_Custom_Price__c = detaliFromList[i].Dealer_Custom_Price__c;
- invoiceInsert1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
-
- if (detaliFromList[i].Box_Piece__c == '鐩�' && detaliFromList[i].Invoice_Unit__c == '涓�') {
- invoiceInsert1.Invoice_Unitprice__c =
- detaliFromList[i].Delivery_List_RMB__c / detaliFromList[i].ProductPacking_list_manual__c;
- } else {
- invoiceInsert1.Invoice_Unitprice__c = detaliFromList[i].Delivery_List_RMB__c;
- }
- invoiceInsert1.Box_Piece__c = detaliFromList[i].Box_Piece__c;
- invoiceInsert1.Invoice_Unit__c = detaliFromList[i].Box_Piece__c;
- if (detaliFromList[i].Invoiced_Procount__c == null)
- detaliFromList[i].Invoiced_Procount__c = 0;
- if (detaliFromList[i].RrturnPro_count__c == null)
- detaliFromList[i].RrturnPro_count__c = 0;
- invoiceInsert1.Invoiced_Count__c = detaliFromList[i].InvoiceProNot_count__c;
- if (detaliFromList[i].InvoicedProCost_RMB__c == null)
- detaliFromList[i].InvoicedProCost_RMB__c = 0;
- invoiceInsert1.InvoicedProCost_RMB__c = invoiceInsert1.Invoiced_Count__c * invoiceInsert1.Delivery_List_RMB__c;
- invoiceInsert1.Consumable_order__c = invoiceId;
- invoiceInsert1.Invoicedet1_OD_link__c = detaliFromList[i].Consumable_order__c;
- invoiceorderList1.add(invoiceInsert1);
- }
- System.debug('invoiceorderList1 +++++' + invoiceorderList1.size());
- Savepoint sp = Database.setSavepoint();
- System.debug('invoiceorderList1 = ' + invoiceorderList1);
- if (invoiceorderList1.size() > 0) {
- try {
- System.debug('invoiceorderList1 = ' + invoiceorderList1);
- insert invoiceorderList1;
- } catch (Exception ex) {
- Database.rollback(sp);
- //ApexPages.addMessages(ex);
- errorMsg += ex.getMessage();
- }
- }
- }
-
- public static void getdefaultMapinfo(List<String> orderIdList) {
- List<Consumable_Orderdetails__c> existLinkinfo = new List<Consumable_Orderdetails__c>();
- existLinkinfo = [
- SELECT Id, Consumable_order__c, Consumable_product__c, Asset_Model_No__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c IN :orderIdList
- ];
- // for (Integer i = 0; i < existLinkinfo.size(); i++) {
- // ordermx1defaultMap.put(existLinkinfo[i].Consumable_order__c + existLinkinfo[i].Asset_Model_No__c, 0);
- // }
- }
-
- public static void deleteOutboundorder(Map<String, String> deleteMap, String value) {
- //鍒犻櫎鍙戠エ鏄庣粏1
- List<Consumable_Orderdetails__c> detInvoicedet1List = [
- SELECT Id, Consumable_Shipment_order__c, Consumable_Sale_order__c, Consumable_product__c, Asset_Model_No__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :value AND Invoicedet1_OD_link__c = :deleteMap.keySet()
- ];
- System.debug('detInvoicedet1List = ' + detInvoicedet1List);
- delete detInvoicedet1List;
- }
-
- //鎹㈣揣鍗曢摼鎺ヨ〃 鍙戠エ鏄庣粏2鍋氭垚
- public static void outOrderchange(Map<String, String> insertDetMap) {
- List<string> chukudanID = new List<string>();
- List<Consumable_order_LinkTable__c> invoiceLinkList = new List<Consumable_order_LinkTable__c>();
- Consumable_order__c p = new Consumable_order__c();
- if (insertDetMap.size() > 0) {
+ //鑾峰彇璇ュ嚭搴撳崟
for (String field : insertDetMap.keySet()) {
- List<Consumable_order_LinkTable__c> existLinkinfo = [
- SELECT Id
- FROM Consumable_order_LinkTable__c
- WHERE Outboundorder_Code_link__c = :field
- ];
- if (existLinkinfo.size() > 0) {
- delete existLinkinfo;
- }
+ if (!templist2.contains(field)) {
+ //璇ュ嚭搴撳崟涓嶅瓨鍦ㄤ笌閾炬帴琛ㄤ腑,鏂板缓閾炬帴
chukudanID.add(field);
Consumable_order_LinkTable__c invoiceLink = new Consumable_order_LinkTable__c();
invoiceLink.Name = field + insertDetMap.get(field);
invoiceLink.Outboundorder_Code_link__c = field;
invoiceLink.Invoice_Code_link__c = insertDetMap.get(field);
invoiceLinkList.add(invoiceLink);
- p.Id = field;
- p.ConInvoice_Code__c = insertDetMap.get(field);
- p.Onchange_order__c = true;
- update p;
+ }
}
- insert invoiceLinkList;
- }
- //鎹㈣揣鍑哄簱鍗曟槑缁�1鏇存柊
- List<Consumable_Orderdetails__c> detaliFrom1List = [
- SELECT
- Id,
- Name,
- Consumable_order__c,
- Asset_Model_No__c,
- Consumable_Product__r.Asset_Model_No__c,
- Shipment_Count__c,
- RrturnPro_count__c,
- Delivery_List_RMB__c,
- InvoicedProCost_RMB__c,
- Invoiced_Procount__c,
- Invoiced_Count__c,
- Invoice_Unitprice__c,
- InvoiceProNot_count__c,
- Invoice_Cost_RMB__c,
- Invoice_No__c,
- Invoice_Unit__c,
- Box_Piece__c,
- Consumable_Sale_order__r.Name,
- Consumable_Shipment_order__r.Name
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c IN :chukudanID
- ];
- for (Consumable_Orderdetails__c changeOD : detaliFrom1List) {
- changeOD.Invoiced_Procount__c = changeOD.Shipment_Count__c;
- }
- update detaliFrom1List;
- }
-
- //涓婁紶ContentVersion闄勪欢
- @AuraEnabled
- public static String saveFile(Id recordId, String fileName, String base64Data) {
- base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
- ContentVersion cv = new ContentVersion();
- cv.Title = fileName;
- cv.PathOnClient = '/' + fileName;
- cv.FirstPublishLocationId = recordId;
- cv.VersionData = EncodingUtil.base64Decode(base64Data);
- cv.IsMajorVersion = true;
- insert cv;
- System.debug('cv.Id = ' + cv.Id);
- return cv.Id;
- }
-
- // 淇濆瓨闄勪欢
- @AuraEnabled
- public static ResponseBodyLWC saveAttachment(String attachmentRecoedsLwc,String invoiceId) {
- System.debug('杩涘叆 saveAttachment');
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- invoiceId = invoiceId;
- attachmentRecoeds = (List<InvoiceOrderInfo>)JSON.deserialize(attachmentRecoedsLwc, List<InvoiceOrderInfo>.class);
- System.debug('attachmentRecoeds = ' + attachmentRecoeds);
- try {
- Consumable_accessories_invoice__c attachmentdetails = new Consumable_accessories_invoice__c();
- for (InvoiceOrderInfo ass : attachmentRecoeds) {
- if (!String.isBlank(ass.mailSelectOptsin)) {
- attachmentdetails.Id = ass.invoiceOrderId;
- attachmentdetails.Attachment_ID__c = ass.cvInfo.ContentDocumentId;
- attachmentdetails.Accessories_type__c = ass.mailSelectOptsin;
- if (String.isBlank(ass.invoiceOrderId)) {
- attachmentdetails.Invoice_code__c = invoiceId;
- }
- upsert attachmentdetails;
- }
- }
- } catch (Exception e) {
- return new ResponseBodyLWC('Error', 500, e.getMessage() + e.getLineNumber(), '');
- }
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
- }
-
- // 妫�绱�(鏈紑鍙戠エ鍑哄簱鍗�)
- @AuraEnabled
- public static ResponseBodyLWC InvoiceorderSearch(Consumable_order__c cocLwc,String invoiceIdLwc,String accountidLwc,String userWorkLocationLwc,String agencyProTypeLwc,String HospitalInfoLwc,String SecondDealerLwc,String invoiceOrderRecoedsLwc) {
- System.debug('杩涘叆 InvoiceorderSearch');
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
-
- coc = cocLwc;
- HospitalInfo = HospitalInfoLwc;
- SecondDealer = SecondDealerLwc;
- errorMsg = '';
- invoiceOrderRecoeds = (List<InvoiceOrderInfo>)JSON.deserialize(invoiceOrderRecoedsLwc, List<InvoiceOrderInfo>.class);
- invoiceId = invoiceIdLwc;
- accountid = accountidLwc;
- agencyProType = agencyProTypeLwc;
- userWorkLocation = userWorkLocationLwc;
-
- Map<String, String> invoiceOrderMap = new Map<String, String>();
- String msoql = '';
- List<InvoiceOrderInfo> invoiceOrderdetailMid = new List<InvoiceOrderInfo>();
- if (String.isBlank(invoiceId)) {
- msoql = makeSoql();
- } else {
- msoql = makeSoqlInit();
- }
- invoiceOrderList = new List<Consumable_order__c>();
- invoiceOrderList = Database.query(msoql);
- for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
- if (ass.check == true) {
- invoiceOrderdetailMid.add(ass);
- invoiceOrderMap.put(ass.esd.Name, ass.esd.Name);
- }
- }
- invoiceOrderRecoeds = new List<InvoiceOrderInfo>();
- invoiceOrderRecoeds.addAll(invoiceOrderdetailMid);
- for (Integer i = 0; i < invoiceOrderList.size(); i++) {
- if (invoiceOrderMap.containsKey(invoiceOrderList[i].Name)) {
- } else {
- invoiceOrderRecoeds.add(new InvoiceOrderInfo(invoiceOrderList[i]));
- invoiceOrderMap.put(invoiceOrderList[i].Name, invoiceOrderList[i].Name);
- }
- }
- data.put('invoiceOrderRecoeds',invoiceOrderRecoeds);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
- }
-
- private static String makeSoql() {
- String soql = 'SELECT Id, Order_ForDealer__r.Name,Order_ForHospital__r.Name,Order_ForDealerText__c, Name,Outbound_Date__c,ShipmentAccount__c,Shipment_total_amount__c,RrturnPro_total_amount__c,Total_Invoiced_Procount__c,InvoiceNotPro_total_amount__c,InvoiceNotPro_money__c,Invoice_total_amount__c,Billed_Status__c FROM Consumable_order__c ';
- soql += ' WHERE Dealer_Info__c = \'' + accountid + '\'';
- soql += ' AND (recordtypeid = \'' + System.Label.RT_ConOrder_Sale + '\'';
- soql += ' OR recordtypeid = \'' + System.Label.RT_ConOrder_Shipment + '\'';
- soql += ' ) ';
- soql += ' AND Order_Owner_WorkLocal__c = \'' + userWorkLocation + '\' ';
- soql += ' AND Order_ProType__c =\'' + agencyProType + '\'';
- soql += ' AND Billed_Status__c != \'鍏ㄩ儴寮�绁╘'';
- soql += ' AND SummonsForDirction__c != \'浜掔浉璋冭揣\'';
- if (HospitalInfo != null && HospitalInfo != '') {
- soql += ' AND Order_ForHospital__c = \'' + HospitalInfo + '\'';
- }
- if (String.isNotEmpty(SecondDealer)) {
- soql += ' AND Order_ForDealer__c = \'' + SecondDealer + '\'';
- }
- if (coc.Order_ForDealerText__c != null) {
- soql += ' AND ShipmentAccount__c = \'' + coc.Order_ForDealerText__c + '\'';
- }
- soql += ' AND InvoiceNotPro_total_amount__c > 0';
- soql += ' AND Onchange_order__c = false limit 1000';
- return soql;
- }
-
- private static String makeSoqlInit() {
- String soql = 'SELECT Id, Order_ForDealer__r.Name,Order_ForHospital__r.Name,Order_ForDealerText__c, Name,Outbound_Date__c,ShipmentAccount__c,Shipment_total_amount__c,RrturnPro_total_amount__c,Total_Invoiced_Procount__c,InvoiceNotPro_total_amount__c,InvoiceNotPro_money__c,Invoice_total_amount__c,Billed_Status__c FROM Consumable_order__c ';
- soql += ' WHERE Dealer_Info__c = \'' + accountid + '\'';
- soql += ' AND (recordtypeid = \'' + System.Label.RT_ConOrder_Sale + '\'';
- soql += ' OR recordtypeid = \'' + System.Label.RT_ConOrder_Shipment + '\'';
- soql += ' ) ';
- soql += ' AND Order_Owner_WorkLocal__c = \'' + userWorkLocation + '\' ';
- soql += ' AND Order_ProType__c =\'' + agencyProType + '\'';
- soql += ' AND SummonsForDirction__c != \'浜掔浉璋冭揣\' ';
- if (HospitalInfo != null && HospitalInfo != '') {
- soql += ' AND Order_ForHospital__c = \'' + HospitalInfo + '\'';
- }
- if (SecondDealer != null) {
- soql += ' AND Order_ForDealer__c = \'' + SecondDealer + '\'';
- }
- if (coc.Order_ForDealerText__c != null) {
- soql += ' AND ShipmentAccount__c = \'' + coc.Order_ForDealerText__c + '\'';
- }
- soql += ' AND InvoiceNotPro_total_amount__c > 0';
- soql += ' AND Onchange_order__c = false limit 1000';
- return soql;
- }
-
- // 鍒犻櫎鎸夐挳
- @AuraEnabled
- public static ResponseBodyLWC deleteButton(String invoiceIdLwc,Consumable_order__c cocLwc) {
- System.debug('杩涘叆 deleteButton');
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
-
- coc = cocLwc;
- invoiceId = invoiceIdLwc;
- system.debug('====invoiceId==========>' + invoiceId);
- List<Consumable_Orderdetails__c> consList = [
- SELECT id, Consumable_order__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :invoiceId
- ];
- try {
- system.debug('====cons==========>' + consList);
- delete consList;
- if (coc.id == invoiceId && coc.Invoice_status__c == '鑽夋涓�') {
- delete coc;
- }
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
- } catch (Exception e) {
- // ApexPages.addMessages(e);
- // return null;
- return new ResponseBodyLWC('Error', 500, e.getMessage() + ' ' + e.getLineNumber(), '');
- }
- }
-
- // 鎻愪氦鎸夐挳
- @AuraEnabled
- public static ResponseBodyLWC approval(List<String> outOrderStringListLwc,Map<String, Consumable_Orderdetails__c> outordercountMapLwc,String invoiceIdLwc) {
- System.debug('杩涘叆 approval');
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
-
- outOrderStringList = outOrderStringListLwc;
- outordercountMap = outordercountMapLwc;
- invoiceId= invoiceIdLwc;
- //鏇存柊鍙戠エ鏄庣粏2閾炬帴
- Consumable_order__c P = new Consumable_order__c();
- List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
- List<Consumable_order_details2__c> invoiceorderList2 = new List<Consumable_order_details2__c>();
- //鏇存柊鍑哄簱鍗曟槑缁�1
- List<Consumable_Orderdetails__c> outOrderdetUp1List = new List<Consumable_Orderdetails__c>();
- //闇�瑕佹洿鏂板嚭搴撳崟鏄庣粏1
- List<Consumable_Orderdetails__c> outOrderdet1List = [
- SELECT
- Id,
- Name,
- Consumable_order__c,
- Consumable_order__r.Name,
- Asset_Model_No__c,
- Consumable_Product__r.Asset_Model_No__c,
- Shipment_Count__c,
- RrturnPro_count__c,
- Delivery_List_RMB__c,
- InvoicedProCost_RMB__c,
- Invoiced_Procount__c,
- Invoiced_Count__c,
- Invoice_Unitprice__c,
- InvoiceProNot_count__c,
- Invoice_Cost_RMB__c,
- Invoice_No__c,
- Box_Piece__c,
- Invoice_Unit__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c IN :outOrderStringList
- ];
- for (Integer i = 0; i < outOrderdet1List.size(); i++) {
- if (outordercountMap.containsKey(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c)) {
- Consumable_Orderdetails__c invoiceUpdte1 = new Consumable_Orderdetails__c();
- invoiceUpdte1.Id = outOrderdet1List[i].Id;
- invoiceUpdte1.Invoice_Unit__c = outordercountMap.get(
- outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c
- )
- .Invoice_Unit__c;
- if (
- outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c).Box_Piece__c ==
- '鐩�' &&
- outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c).Invoice_Unit__c ==
- '涓�'
- ) {
- Decimal OldinvoicedProcount = 0;
- OldinvoicedProcount = (outordercountMap.get(
- outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c
- )
- .Invoiced_Count__c /
- outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c)
- .ProductPacking_list_manual__c)
- .setScale(2);
- invoiceUpdte1.Invoiced_Procount__c = outOrderdet1List[i].Invoiced_Procount__c + OldinvoicedProcount;
- } else {
- invoiceUpdte1.Invoiced_Procount__c =
- outOrderdet1List[i].Invoiced_Procount__c +
- outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c)
- .Invoiced_Count__c;
- }
- invoiceUpdte1.Invoice_Unitprice__c = outordercountMap.get(
- outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c
- )
- .Invoice_Unitprice__c;
- invoiceUpdte1.InvoicedProCost_RMB__c = invoiceUpdte1.Invoiced_Procount__c * outOrderdet1List[i].Delivery_List_RMB__c;
-
- Decimal invoicedProcount = 0;
- if (
- outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c).Box_Piece__c ==
- '鐩�' &&
- outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c).Invoice_Unit__c ==
- '涓�'
- ) {
- invoicedProcount = (outordercountMap.get(
- outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c
- )
- .Invoiced_Count__c /
- outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c)
- .ProductPacking_list_manual__c)
- .setScale(2);
- } else {
- invoicedProcount = outordercountMap.get(outOrderdet1List[i].Consumable_order__c + outOrderdet1List[i].Asset_Model_No__c)
- .Invoiced_Count__c;
- }
-
- if (outOrderdet1List[i].InvoiceProNot_count__c < invoicedProcount) {
- // ApexPages.addmessage(
- // new ApexPages.message(
- // ApexPages.severity.Error,
- // '鍑哄簱鍗�' +
- // outOrderdet1List[i].Consumable_order__r.Name +
- // '涓紝' +
- // outOrderdet1List[i].Asset_Model_No__c +
- // '杩樻病寮�绁ㄦ暟閲忓皬浜庡彂绁ㄦ暟閲忥紝璇风‘璁ゆ槸鍚︽湁杩斿搧'
- // )
- // );
- // return null;
- return new ResponseBodyLWC('Error', 500, '鍑哄簱鍗�' + outOrderdet1List[i].Consumable_order__r.Name + '涓紝' + outOrderdet1List[i].Asset_Model_No__c + '杩樻病寮�绁ㄦ暟閲忓皬浜庡彂绁ㄦ暟閲忥紝璇风‘璁ゆ槸鍚︽湁杩斿搧', '');
- }
-
- outOrderdetUp1List.add(invoiceUpdte1);
- }
- }
- Savepoint sp = Database.setSavepoint();
- try {
- //鍑哄簱鍗曟槑缁�1鏇存柊
- if (outOrderdetUp1List.size() > 0) {
- ControllerUtil.updateOrderDetails1Satus(outOrderdetUp1List);
- }
- //鍙戠エ鐘舵�佹洿鏂�
- cocinfo = [
- SELECT Id, Name, Invoice_status__c, Dealer_Info__c, Order_ForHospital__c, SummonsForDirction__c
- FROM Consumable_order__c
- WHERE Id = :invoiceId
+ upsert invoiceLinkList;
+ }
+ if (deleteDetMap.size() > 0) {
+ List<Consumable_order_LinkTable__c> invoiceLinkdetList = new List<Consumable_order_LinkTable__c>();
+ deleteOutboundorder(deleteDetMap, invoiceHead.Id);
+ List<Consumable_order_LinkTable__c> existLinkinfo = [
+ SELECT Id, Outboundorder_Code_link__c, Invoice_Code_link__c
+ FROM Consumable_order_LinkTable__c
+ WHERE
+ Outboundorder_Code_link__c IN :deleteDetMap.keySet()
+ AND Invoice_Code_link__c = :invoiceHead.Id
];
- System.debug('cocinfo = ' + cocinfo);
- if (cocinfo.size() > 0) {
- p = cocinfo[0];
+ for (Consumable_order_LinkTable__c colctemp : existLinkinfo) {
+ if (
+ deleteDetMap.get(colctemp.Outboundorder_Code_link__c) ==
+ colctemp.Invoice_Code_link__c
+ ) {
+ //瀛樺湪涓庤鍙戠エ鍏宠仈鐨勫嚭搴撳崟
+ invoiceLinkdetList.add(colctemp);
+ }
}
- System.debug('p = ' + p);
- p.Invoice_status__c = '鎻愪氦';
- update p;
- } catch (Exception ex) {
- Database.rollback(sp);
- // ApexPages.addMessages(ex);
- // return null;
- return new ResponseBodyLWC('Error', 500, ex.getMessage() + ' ' + ex.getLineNumber(), '');
+ delete invoiceLinkdetList;
+ }
+ //CHAN-BSS5SQ update by rentongxiao 2020-09-08 end
+ //鏂板缓鍙戠エ鏄庣粏1
+ if (chukudanID.size() > 0) {
+ newinvoicedetails1(chukudanID);
+ }
}
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ }
+ } catch (Exception ex) {
+ Database.rollback(sp);
+ // ApexPages.addMessages(ex);
+ // return null;
+ System.debug('Exception ex = ' + ex.getMessage() + ex.getLineNumber());
+ errorMsg += ex.getMessage() + ex.getLineNumber();
}
+ data.put('invoiceId', invoiceId);
+ res.status = 'Success';
+ res.code = 200;
+ res.msg = errorMsg;
+ System.debug('res = ' + res);
+ return res;
+ }
- class InvoiceOrderInfo implements Comparable {
- @AuraEnabled
- public Boolean check { get; set; }
- @AuraEnabled
- public Boolean oldCheck { get; set; }
- @AuraEnabled
- public Consumable_order__c esd { get; set; }
- @AuraEnabled
- public Consumable_Orderdetails__c esdet { get; set; }
- @AuraEnabled
- public Attachment attach { get; set; }
- @AuraEnabled
- public ContentVersion cvInfo{ get; set; }
- @AuraEnabled
- public String mailSelectOptsin { get; set; }
- public List<SelectOption> mailSelectOpts { get; set; }
- @AuraEnabled
- public Map<String,String> mailSelectOptsMap { get; set; }
- @AuraEnabled
- public String invoiceOrderId { get; set; }
- @AuraEnabled
- public Decimal needInvoiceCount { get; set; }
+ public static void newinvoicedetails1(List<String> chukudanID) {
+ //鏂拌鍙戠エ鏄庣粏1
+ List<Consumable_Orderdetails__c> invoiceorderList1 = new List<Consumable_Orderdetails__c>();
+ //鍑哄簱鍗曟槑缁嗘洿鏂�
+ List<Consumable_Orderdetails__c> outOrderList1 = new List<Consumable_Orderdetails__c>();
+ List<Consumable_Orderdetails__c> detaliFromList = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Asset_Model_No__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Shipment_Count__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ Invoice_Unitprice__c,
+ InvoiceProNot_count__c,
+ Invoice_Cost_RMB__c,
+ Invoice_No__c,
+ Consumable_Product__c,
+ Intra_Trade_List_RMB__c,
+ Dealer_Custom_Price__c,
+ Sum_of_money__c,
+ Box_Piece__c,
+ Used_date__c,
+ Send_date__c,
+ Invoice_Unit__c,
+ ProductPacking_list_manual__c
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c IN :chukudanID AND InvoiceProNot_count__c > 0
+ ];
- // 鍑哄簱璁㈠崟
- public InvoiceOrderInfo(Consumable_order__c e) {
- check = false;
- oldCheck = false;
- esd = e;
- needInvoiceCount = 0;
- }
- // 鍑哄簱璁㈠崟鏄庣粏1
- public InvoiceOrderInfo(Consumable_Orderdetails__c e) {
- esdet = e;
- }
- //闄勪欢
- public InvoiceOrderInfo(Attachment e) {
- attach = e;
- mailSelectOpts = new List<SelectOption>();
- mailSelectOpts.add(new SelectOption('鍙戠エ鍜屾槑缁�', '鍙戠エ鍜屾槑缁�'));
- mailSelectOpts.add(new SelectOption('鍙戠エ', '鍙戠エ'));
- mailSelectOpts.add(new SelectOption('鏄庣粏', '鏄庣粏'));
- }
- //ContentVersion
- public InvoiceOrderInfo(ContentVersion cv) {
- cvInfo = cv;
- mailSelectOptsMap = new Map<String,String>();
- mailSelectOptsMap.put('鍙戠エ鍜屾槑缁�', '鍙戠エ鍜屾槑缁�');
- mailSelectOptsMap.put('鍙戠エ', '鍙戠エ');
- mailSelectOptsMap.put('鏄庣粏', '鏄庣粏');
- }
- // 鎺掑簭
- public Integer compareTo(Object compareTo) {
- return null;
- }
+ for (Integer i = 0; i < detaliFromList.size(); i++) {
+ Consumable_Orderdetails__c invoiceInsert1 = new Consumable_Orderdetails__c();
+ invoiceInsert1.Used_date__c = detaliFromList[i].Used_date__c;
+ invoiceInsert1.Send_date__c = detaliFromList[i].Send_date__c;
+ String str = string.valueOf(i + 1);
+ if (str.length() == 1) {
+ str = '0' + str;
+ }
+ invoiceInsert1.Name =
+ coc.Name +
+ '-' +
+ detaliFromList[i]
+ .Name.substring(
+ detaliFromList[i].Name.length() - 7,
+ detaliFromList[i].Name.length()
+ );
+ invoiceInsert1.Shipment_Count__c = detaliFromList[i]
+ .InvoiceProNot_count__c;
+ invoiceInsert1.Consumable_Product__c = detaliFromList[i]
+ .Consumable_Product__c;
+ invoiceInsert1.Intra_Trade_List_RMB__c = detaliFromList[i]
+ .Intra_Trade_List_RMB__c;
+ invoiceInsert1.Delivery_List_RMB__c = detaliFromList[i]
+ .Delivery_List_RMB__c;
+ invoiceInsert1.Dealer_Custom_Price__c = detaliFromList[i]
+ .Dealer_Custom_Price__c;
+ invoiceInsert1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+
+ if (
+ detaliFromList[i].Box_Piece__c == '鐩�' &&
+ detaliFromList[i].Invoice_Unit__c == '涓�'
+ ) {
+ invoiceInsert1.Invoice_Unitprice__c =
+ detaliFromList[i].Delivery_List_RMB__c /
+ detaliFromList[i].ProductPacking_list_manual__c;
+ } else {
+ invoiceInsert1.Invoice_Unitprice__c = detaliFromList[i]
+ .Delivery_List_RMB__c;
+ }
+ invoiceInsert1.Box_Piece__c = detaliFromList[i].Box_Piece__c;
+ invoiceInsert1.Invoice_Unit__c = detaliFromList[i].Box_Piece__c;
+ if (detaliFromList[i].Invoiced_Procount__c == null)
+ detaliFromList[i].Invoiced_Procount__c = 0;
+ if (detaliFromList[i].RrturnPro_count__c == null)
+ detaliFromList[i].RrturnPro_count__c = 0;
+ invoiceInsert1.Invoiced_Count__c = detaliFromList[i]
+ .InvoiceProNot_count__c;
+ if (detaliFromList[i].InvoicedProCost_RMB__c == null)
+ detaliFromList[i].InvoicedProCost_RMB__c = 0;
+ invoiceInsert1.InvoicedProCost_RMB__c =
+ invoiceInsert1.Invoiced_Count__c * invoiceInsert1.Delivery_List_RMB__c;
+ invoiceInsert1.Consumable_order__c = invoiceId;
+ invoiceInsert1.Invoicedet1_OD_link__c = detaliFromList[i]
+ .Consumable_order__c;
+ invoiceorderList1.add(invoiceInsert1);
}
-}
\ No newline at end of file
+ System.debug('invoiceorderList1 +++++' + invoiceorderList1.size());
+ Savepoint sp = Database.setSavepoint();
+ System.debug('invoiceorderList1 = ' + invoiceorderList1);
+ if (invoiceorderList1.size() > 0) {
+ try {
+ System.debug('invoiceorderList1 = ' + invoiceorderList1);
+ insert invoiceorderList1;
+ } catch (Exception ex) {
+ Database.rollback(sp);
+ //ApexPages.addMessages(ex);
+ errorMsg += ex.getMessage();
+ }
+ }
+ }
+
+ public static void getdefaultMapinfo(List<String> orderIdList) {
+ List<Consumable_Orderdetails__c> existLinkinfo = new List<Consumable_Orderdetails__c>();
+ existLinkinfo = [
+ SELECT Id, Consumable_order__c, Consumable_product__c, Asset_Model_No__c
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c IN :orderIdList
+ ];
+ // for (Integer i = 0; i < existLinkinfo.size(); i++) {
+ // ordermx1defaultMap.put(existLinkinfo[i].Consumable_order__c + existLinkinfo[i].Asset_Model_No__c, 0);
+ // }
+ }
+
+ public static void deleteOutboundorder(
+ Map<String, String> deleteMap,
+ String value
+ ) {
+ //鍒犻櫎鍙戠エ鏄庣粏1
+ List<Consumable_Orderdetails__c> detInvoicedet1List = [
+ SELECT
+ Id,
+ Consumable_Shipment_order__c,
+ Consumable_Sale_order__c,
+ Consumable_product__c,
+ Asset_Model_No__c
+ FROM Consumable_Orderdetails__c
+ WHERE
+ Consumable_order__c = :value
+ AND Invoicedet1_OD_link__c = :deleteMap.keySet()
+ ];
+ System.debug('detInvoicedet1List = ' + detInvoicedet1List);
+ delete detInvoicedet1List;
+ }
+
+ //鎹㈣揣鍗曢摼鎺ヨ〃 鍙戠エ鏄庣粏2鍋氭垚
+ public static void outOrderchange(Map<String, String> insertDetMap) {
+ List<string> chukudanID = new List<string>();
+ List<Consumable_order_LinkTable__c> invoiceLinkList = new List<Consumable_order_LinkTable__c>();
+ Consumable_order__c p = new Consumable_order__c();
+ if (insertDetMap.size() > 0) {
+ for (String field : insertDetMap.keySet()) {
+ List<Consumable_order_LinkTable__c> existLinkinfo = [
+ SELECT Id
+ FROM Consumable_order_LinkTable__c
+ WHERE Outboundorder_Code_link__c = :field
+ ];
+ if (existLinkinfo.size() > 0) {
+ delete existLinkinfo;
+ }
+ chukudanID.add(field);
+ Consumable_order_LinkTable__c invoiceLink = new Consumable_order_LinkTable__c();
+ invoiceLink.Name = field + insertDetMap.get(field);
+ invoiceLink.Outboundorder_Code_link__c = field;
+ invoiceLink.Invoice_Code_link__c = insertDetMap.get(field);
+ invoiceLinkList.add(invoiceLink);
+ p.Id = field;
+ p.ConInvoice_Code__c = insertDetMap.get(field);
+ p.Onchange_order__c = true;
+ update p;
+ }
+ insert invoiceLinkList;
+ }
+ //鎹㈣揣鍑哄簱鍗曟槑缁�1鏇存柊
+ List<Consumable_Orderdetails__c> detaliFrom1List = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Asset_Model_No__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Shipment_Count__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ Invoice_Unitprice__c,
+ InvoiceProNot_count__c,
+ Invoice_Cost_RMB__c,
+ Invoice_No__c,
+ Invoice_Unit__c,
+ Box_Piece__c,
+ Consumable_Sale_order__r.Name,
+ Consumable_Shipment_order__r.Name
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c IN :chukudanID
+ ];
+ for (Consumable_Orderdetails__c changeOD : detaliFrom1List) {
+ changeOD.Invoiced_Procount__c = changeOD.Shipment_Count__c;
+ }
+ update detaliFrom1List;
+ }
+
+ //涓婁紶ContentVersion闄勪欢
+ @AuraEnabled
+ public static String saveFile(
+ Id recordId,
+ String fileName,
+ String base64Data
+ ) {
+ base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
+ ContentVersion cv = new ContentVersion();
+ cv.Title = fileName;
+ cv.PathOnClient = '/' + fileName;
+ cv.FirstPublishLocationId = recordId;
+ cv.VersionData = EncodingUtil.base64Decode(base64Data);
+ cv.IsMajorVersion = true;
+ insert cv;
+ System.debug('cv.Id = ' + cv.Id);
+ return cv.Id;
+ }
+
+ // 淇濆瓨闄勪欢
+ @AuraEnabled
+ public static ResponseBodyLWC saveAttachment(
+ String attachmentRecoedsLwc,
+ String invoiceId
+ ) {
+ System.debug('杩涘叆 saveAttachment');
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ invoiceId = invoiceId;
+ attachmentRecoeds = (List<InvoiceOrderInfo>) JSON.deserialize(
+ attachmentRecoedsLwc,
+ List<InvoiceOrderInfo>.class
+ );
+ System.debug('attachmentRecoeds = ' + attachmentRecoeds);
+ try {
+ Consumable_accessories_invoice__c attachmentdetails = new Consumable_accessories_invoice__c();
+ for (InvoiceOrderInfo ass : attachmentRecoeds) {
+ if (!String.isBlank(ass.mailSelectOptsin)) {
+ attachmentdetails.Id = ass.invoiceOrderId;
+ attachmentdetails.Attachment_ID__c = ass.cvInfo.ContentDocumentId;
+ attachmentdetails.Accessories_type__c = ass.mailSelectOptsin;
+ if (String.isBlank(ass.invoiceOrderId)) {
+ attachmentdetails.Invoice_code__c = invoiceId;
+ }
+ upsert attachmentdetails;
+ }
+ }
+ } catch (Exception e) {
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ e.getMessage() + e.getLineNumber(),
+ ''
+ );
+ }
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ // 妫�绱�(鏈紑鍙戠エ鍑哄簱鍗�)
+ @AuraEnabled
+ public static ResponseBodyLWC InvoiceorderSearch(
+ Consumable_order__c cocLwc,
+ String invoiceIdLwc,
+ String accountidLwc,
+ String userWorkLocationLwc,
+ String agencyProTypeLwc,
+ String HospitalInfoLwc,
+ String SecondDealerLwc,
+ String invoiceOrderRecoedsLwc
+ ) {
+ System.debug('杩涘叆 InvoiceorderSearch');
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ coc = cocLwc;
+ HospitalInfo = HospitalInfoLwc;
+ SecondDealer = SecondDealerLwc;
+ errorMsg = '';
+ invoiceOrderRecoeds = (List<InvoiceOrderInfo>) JSON.deserialize(
+ invoiceOrderRecoedsLwc,
+ List<InvoiceOrderInfo>.class
+ );
+ invoiceId = invoiceIdLwc;
+ accountid = accountidLwc;
+ agencyProType = agencyProTypeLwc;
+ userWorkLocation = userWorkLocationLwc;
+
+ Map<String, String> invoiceOrderMap = new Map<String, String>();
+ String msoql = '';
+ List<InvoiceOrderInfo> invoiceOrderdetailMid = new List<InvoiceOrderInfo>();
+ if (String.isBlank(invoiceId)) {
+ msoql = makeSoql();
+ } else {
+ msoql = makeSoqlInit();
+ }
+ invoiceOrderList = new List<Consumable_order__c>();
+ invoiceOrderList = Database.query(msoql);
+ for (InvoiceOrderInfo ass : invoiceOrderRecoeds) {
+ if (ass.check == true) {
+ invoiceOrderdetailMid.add(ass);
+ invoiceOrderMap.put(ass.esd.Name, ass.esd.Name);
+ }
+ }
+ invoiceOrderRecoeds = new List<InvoiceOrderInfo>();
+ invoiceOrderRecoeds.addAll(invoiceOrderdetailMid);
+ for (Integer i = 0; i < invoiceOrderList.size(); i++) {
+ if (invoiceOrderMap.containsKey(invoiceOrderList[i].Name)) {
+ } else {
+ invoiceOrderRecoeds.add(new InvoiceOrderInfo(invoiceOrderList[i]));
+ invoiceOrderMap.put(invoiceOrderList[i].Name, invoiceOrderList[i].Name);
+ }
+ }
+ data.put('invoiceOrderRecoeds', invoiceOrderRecoeds);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ private static String makeSoql() {
+ String soql = 'SELECT Id, Order_ForDealer__r.Name,Order_ForHospital__r.Name,Order_ForDealerText__c, Name,Outbound_Date__c,ShipmentAccount__c,Shipment_total_amount__c,RrturnPro_total_amount__c,Total_Invoiced_Procount__c,InvoiceNotPro_total_amount__c,InvoiceNotPro_money__c,Invoice_total_amount__c,Billed_Status__c FROM Consumable_order__c ';
+ soql += ' WHERE Dealer_Info__c = \'' + accountid + '\'';
+ soql += ' AND (recordtypeid = \'' + System.Label.RT_ConOrder_Sale + '\'';
+ soql += ' OR recordtypeid = \'' + System.Label.RT_ConOrder_Shipment + '\'';
+ soql += ' ) ';
+ soql += ' AND Order_Owner_WorkLocal__c = \'' + userWorkLocation + '\' ';
+ soql += ' AND Order_ProType__c =\'' + agencyProType + '\'';
+ soql += ' AND Billed_Status__c != \'鍏ㄩ儴寮�绁╘'';
+ soql += ' AND SummonsForDirction__c != \'浜掔浉璋冭揣\'';
+ if (HospitalInfo != null && HospitalInfo != '') {
+ soql += ' AND Order_ForHospital__c = \'' + HospitalInfo + '\'';
+ }
+ if (String.isNotEmpty(SecondDealer)) {
+ soql += ' AND Order_ForDealer__c = \'' + SecondDealer + '\'';
+ }
+ if (coc.Order_ForDealerText__c != null) {
+ soql +=
+ ' AND ShipmentAccount__c = \'' +
+ coc.Order_ForDealerText__c +
+ '\'';
+ }
+ soql += ' AND InvoiceNotPro_total_amount__c > 0';
+ soql += ' AND Onchange_order__c = false limit 1000';
+ return soql;
+ }
+
+ private static String makeSoqlInit() {
+ String soql = 'SELECT Id, Order_ForDealer__r.Name,Order_ForHospital__r.Name,Order_ForDealerText__c, Name,Outbound_Date__c,ShipmentAccount__c,Shipment_total_amount__c,RrturnPro_total_amount__c,Total_Invoiced_Procount__c,InvoiceNotPro_total_amount__c,InvoiceNotPro_money__c,Invoice_total_amount__c,Billed_Status__c FROM Consumable_order__c ';
+ soql += ' WHERE Dealer_Info__c = \'' + accountid + '\'';
+ soql += ' AND (recordtypeid = \'' + System.Label.RT_ConOrder_Sale + '\'';
+ soql += ' OR recordtypeid = \'' + System.Label.RT_ConOrder_Shipment + '\'';
+ soql += ' ) ';
+ soql += ' AND Order_Owner_WorkLocal__c = \'' + userWorkLocation + '\' ';
+ soql += ' AND Order_ProType__c =\'' + agencyProType + '\'';
+ soql += ' AND SummonsForDirction__c != \'浜掔浉璋冭揣\' ';
+ if (HospitalInfo != null && HospitalInfo != '') {
+ soql += ' AND Order_ForHospital__c = \'' + HospitalInfo + '\'';
+ }
+ if (SecondDealer != null) {
+ soql += ' AND Order_ForDealer__c = \'' + SecondDealer + '\'';
+ }
+ if (coc.Order_ForDealerText__c != null) {
+ soql +=
+ ' AND ShipmentAccount__c = \'' +
+ coc.Order_ForDealerText__c +
+ '\'';
+ }
+ soql += ' AND InvoiceNotPro_total_amount__c > 0';
+ soql += ' AND Onchange_order__c = false limit 1000';
+ return soql;
+ }
+
+ // 鍒犻櫎鎸夐挳
+ @AuraEnabled
+ public static ResponseBodyLWC deleteButton(
+ String invoiceIdLwc,
+ Consumable_order__c cocLwc
+ ) {
+ System.debug('杩涘叆 deleteButton');
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ coc = cocLwc;
+ invoiceId = invoiceIdLwc;
+ system.debug('====invoiceId==========>' + invoiceId);
+ List<Consumable_Orderdetails__c> consList = [
+ SELECT id, Consumable_order__c
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c = :invoiceId
+ ];
+ try {
+ system.debug('====cons==========>' + consList);
+ delete consList;
+ if (coc.id == invoiceId && coc.Invoice_status__c == '鑽夋涓�') {
+ delete coc;
+ }
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ } catch (Exception e) {
+ // ApexPages.addMessages(e);
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ e.getMessage() + ' ' + e.getLineNumber(),
+ ''
+ );
+ }
+ }
+
+ // 鎻愪氦鎸夐挳
+ @AuraEnabled
+ public static ResponseBodyLWC approval(
+ List<String> outOrderStringListLwc,
+ Map<String, Consumable_Orderdetails__c> outordercountMapLwc,
+ String invoiceIdLwc
+ ) {
+ System.debug('杩涘叆 approval');
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ outOrderStringList = outOrderStringListLwc;
+ outordercountMap = outordercountMapLwc;
+ invoiceId = invoiceIdLwc;
+ //鏇存柊鍙戠エ鏄庣粏2閾炬帴
+ Consumable_order__c P = new Consumable_order__c();
+ List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
+ List<Consumable_order_details2__c> invoiceorderList2 = new List<Consumable_order_details2__c>();
+ //鏇存柊鍑哄簱鍗曟槑缁�1
+ List<Consumable_Orderdetails__c> outOrderdetUp1List = new List<Consumable_Orderdetails__c>();
+ //闇�瑕佹洿鏂板嚭搴撳崟鏄庣粏1
+ List<Consumable_Orderdetails__c> outOrderdet1List = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Consumable_order__r.Name,
+ Asset_Model_No__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Shipment_Count__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ Invoice_Unitprice__c,
+ InvoiceProNot_count__c,
+ Invoice_Cost_RMB__c,
+ Invoice_No__c,
+ Box_Piece__c,
+ Invoice_Unit__c
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c IN :outOrderStringList
+ ];
+ for (Integer i = 0; i < outOrderdet1List.size(); i++) {
+ if (
+ outordercountMap.containsKey(
+ outOrderdet1List[i].Consumable_order__c +
+ outOrderdet1List[i].Asset_Model_No__c
+ )
+ ) {
+ Consumable_Orderdetails__c invoiceUpdte1 = new Consumable_Orderdetails__c();
+ invoiceUpdte1.Id = outOrderdet1List[i].Id;
+ invoiceUpdte1.Invoice_Unit__c = outordercountMap.get(
+ outOrderdet1List[i].Consumable_order__c +
+ outOrderdet1List[i].Asset_Model_No__c
+ )
+ .Invoice_Unit__c;
+ if (
+ outordercountMap.get(
+ outOrderdet1List[i].Consumable_order__c +
+ outOrderdet1List[i].Asset_Model_No__c
+ )
+ .Box_Piece__c == '鐩�' &&
+ outordercountMap.get(
+ outOrderdet1List[i].Consumable_order__c +
+ outOrderdet1List[i].Asset_Model_No__c
+ )
+ .Invoice_Unit__c == '涓�'
+ ) {
+ Decimal OldinvoicedProcount = 0;
+ OldinvoicedProcount = (outordercountMap.get(
+ outOrderdet1List[i].Consumable_order__c +
+ outOrderdet1List[i].Asset_Model_No__c
+ )
+ .Invoiced_Count__c /
+ outordercountMap.get(
+ outOrderdet1List[i].Consumable_order__c +
+ outOrderdet1List[i].Asset_Model_No__c
+ )
+ .ProductPacking_list_manual__c)
+ .setScale(2);
+ invoiceUpdte1.Invoiced_Procount__c =
+ outOrderdet1List[i].Invoiced_Procount__c + OldinvoicedProcount;
+ } else {
+ invoiceUpdte1.Invoiced_Procount__c =
+ outOrderdet1List[i].Invoiced_Procount__c +
+ outordercountMap.get(
+ outOrderdet1List[i].Consumable_order__c +
+ outOrderdet1List[i].Asset_Model_No__c
+ )
+ .Invoiced_Count__c;
+ }
+ invoiceUpdte1.Invoice_Unitprice__c = outordercountMap.get(
+ outOrderdet1List[i].Consumable_order__c +
+ outOrderdet1List[i].Asset_Model_No__c
+ )
+ .Invoice_Unitprice__c;
+ System.debug('====>procount' + invoiceUpdte1.Invoiced_Procount__c);
+ System.debug('===>RMB' + outOrderdet1List[i].Delivery_List_RMB__c);
+ invoiceUpdte1.InvoicedProCost_RMB__c =
+ invoiceUpdte1.Invoiced_Procount__c *
+ outOrderdet1List[i].Delivery_List_RMB__c;
+
+ Decimal invoicedProcount = 0;
+ if (
+ outordercountMap.get(
+ outOrderdet1List[i].Consumable_order__c +
+ outOrderdet1List[i].Asset_Model_No__c
+ )
+ .Box_Piece__c == '鐩�' &&
+ outordercountMap.get(
+ outOrderdet1List[i].Consumable_order__c +
+ outOrderdet1List[i].Asset_Model_No__c
+ )
+ .Invoice_Unit__c == '涓�'
+ ) {
+ invoicedProcount = (outordercountMap.get(
+ outOrderdet1List[i].Consumable_order__c +
+ outOrderdet1List[i].Asset_Model_No__c
+ )
+ .Invoiced_Count__c /
+ outordercountMap.get(
+ outOrderdet1List[i].Consumable_order__c +
+ outOrderdet1List[i].Asset_Model_No__c
+ )
+ .ProductPacking_list_manual__c)
+ .setScale(2);
+ } else {
+ invoicedProcount = outordercountMap.get(
+ outOrderdet1List[i].Consumable_order__c +
+ outOrderdet1List[i].Asset_Model_No__c
+ )
+ .Invoiced_Count__c;
+ }
+ System.debug(
+ '鍙戠エ鏁伴噺===>' + outOrderdet1List[i].InvoiceProNot_count__c
+ );
+ System.debug('杩樻病鍙戠エ鏁伴噺===>' + invoicedProcount);
+
+ if (outOrderdet1List[i].InvoiceProNot_count__c < invoicedProcount) {
+ // ApexPages.addmessage(
+ // new ApexPages.message(
+ // ApexPages.severity.Error,
+ // '鍑哄簱鍗�' +
+ // outOrderdet1List[i].Consumable_order__r.Name +
+ // '涓紝' +
+ // outOrderdet1List[i].Asset_Model_No__c +
+ // '杩樻病寮�绁ㄦ暟閲忓皬浜庡彂绁ㄦ暟閲忥紝璇风‘璁ゆ槸鍚︽湁杩斿搧'
+ // )
+ // );
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '鍑哄簱鍗�' +
+ outOrderdet1List[i].Consumable_order__r.Name +
+ '涓紝' +
+ outOrderdet1List[i].Asset_Model_No__c +
+ '杩樻病寮�绁ㄦ暟閲忓皬浜庡彂绁ㄦ暟閲忥紝璇风‘璁ゆ槸鍚︽湁杩斿搧',
+ ''
+ );
+ }
+
+ outOrderdetUp1List.add(invoiceUpdte1);
+ }
+ }
+ Savepoint sp = Database.setSavepoint();
+ try {
+ //鍑哄簱鍗曟槑缁�1鏇存柊
+ if (outOrderdetUp1List.size() > 0) {
+ ControllerUtil.updateOrderDetails1Satus(outOrderdetUp1List);
+ }
+ //鍙戠エ鐘舵�佹洿鏂�
+ cocinfo = [
+ SELECT
+ Id,
+ Name,
+ Invoice_status__c,
+ Dealer_Info__c,
+ Order_ForHospital__c,
+ SummonsForDirction__c
+ FROM Consumable_order__c
+ WHERE Id = :invoiceId
+ ];
+ System.debug('cocinfo = ' + cocinfo);
+ if (cocinfo.size() > 0) {
+ p = cocinfo[0];
+ }
+ System.debug('p = ' + p);
+ p.Invoice_status__c = '鎻愪氦';
+ update p;
+ } catch (Exception ex) {
+ Database.rollback(sp);
+ // ApexPages.addMessages(ex);
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ ex.getMessage() + ' ' + ex.getLineNumber(),
+ ''
+ );
+ }
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+ @TestVisible
+ class InvoiceOrderInfo implements Comparable {
+ @AuraEnabled
+ public Boolean check { get; set; }
+ @AuraEnabled
+ public Boolean oldCheck { get; set; }
+ @AuraEnabled
+ public Consumable_order__c esd { get; set; }
+ @AuraEnabled
+ public Consumable_Orderdetails__c esdet { get; set; }
+ @AuraEnabled
+ public Attachment attach { get; set; }
+ @AuraEnabled
+ public ContentVersion cvInfo { get; set; }
+ @AuraEnabled
+ public String mailSelectOptsin { get; set; }
+ public List<SelectOption> mailSelectOpts { get; set; }
+ @AuraEnabled
+ public Map<String, String> mailSelectOptsMap { get; set; }
+ @AuraEnabled
+ public String invoiceOrderId { get; set; }
+ @AuraEnabled
+ public Decimal needInvoiceCount { get; set; }
+
+ // 鍑哄簱璁㈠崟
+ public InvoiceOrderInfo(Consumable_order__c e) {
+ check = false;
+ oldCheck = false;
+ esd = e;
+ needInvoiceCount = 0;
+ }
+ // 鍑哄簱璁㈠崟鏄庣粏1
+ public InvoiceOrderInfo(Consumable_Orderdetails__c e) {
+ esdet = e;
+ }
+ //闄勪欢
+ public InvoiceOrderInfo(Attachment e) {
+ attach = e;
+ mailSelectOpts = new List<SelectOption>();
+ mailSelectOpts.add(new SelectOption('鍙戠エ鍜屾槑缁�', '鍙戠エ鍜屾槑缁�'));
+ mailSelectOpts.add(new SelectOption('鍙戠エ', '鍙戠エ'));
+ mailSelectOpts.add(new SelectOption('鏄庣粏', '鏄庣粏'));
+ }
+ //ContentVersion
+ public InvoiceOrderInfo(ContentVersion cv) {
+ cvInfo = cv;
+ mailSelectOptsMap = new Map<String, String>();
+ mailSelectOptsMap.put('鍙戠エ鍜屾槑缁�', '鍙戠エ鍜屾槑缁�');
+ mailSelectOptsMap.put('鍙戠エ', '鍙戠エ');
+ mailSelectOptsMap.put('鏄庣粏', '鏄庣粏');
+ }
+ // 鎺掑簭
+ public Integer compareTo(Object compareTo) {
+ return null;
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexConInvoiceViewControllerTest.cls b/force-app/main/default/classes/LexConInvoiceViewControllerTest.cls
new file mode 100644
index 0000000..132a36a
--- /dev/null
+++ b/force-app/main/default/classes/LexConInvoiceViewControllerTest.cls
@@ -0,0 +1,4125 @@
+@isTest
+private class LexConInvoiceViewControllerTest { //鏂板缓鍙戠エ 浠ュ強缂栬緫鍙戠エ invoiceId<>null
+ public static user myUser_test;
+ public static Account myAccount1;
+ public static Account hosp1;
+ public static Account agency1;
+ public static List<RecordType> rectHos;
+ public static Account agency2;
+ @testSetup
+ static void setupTestData() {
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�'];
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ List<RecordType> rectHos = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectHos.size() == 0) {
+ return;
+ }
+ //浜岀骇缁忛攢鍟哠econdDealer
+ agency1 = new Account(
+ name = 'Testhosp001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id
+ );
+ agency2 = new Account(
+ name = 'Testhosp002',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id
+ );
+ //缁忛攢鍟�
+ myAccount1 = new Account(
+ name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id
+ );
+ insert agency1;
+ insert agency2;
+ insert myAccount1;
+ //瀹㈡埛鍚岺ospitalInfo
+ hosp1 = new Account(
+ name = 'Testhosp001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectHos[0].Id
+ );
+ Account hosp2 = new Account(
+ name = 'Testhosp002',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectHos[0].Id
+ );
+ insert hosp1;
+
+ Dealer_elationship__c dealerelationship = new Dealer_elationship__c(
+ Dealer_principal__c = myAccount1.id,
+ Dealer_subordinate__c = agency1.id
+ );
+ insert dealerelationship;
+ Dealer_elationship__c dealerelationship1 = new Dealer_elationship__c(
+ Dealer_principal__c = myAccount1.id,
+ Dealer_subordinate__c = agency2.id
+ );
+ insert dealerelationship1;
+
+ Agency_Hospital_Link__c agencyHospitalLink1 = new Agency_Hospital_Link__c(
+ Hospital__c = hosp1.id,
+ Agency__c = myAccount1.id
+ );
+ insert agencyHospitalLink1;
+
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+
+ }
+ static testMethod void conInvoiceViewTestedit_1() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ //invoiceorder.Order_ForHospital__c =hosp1.Id;
+ // invoiceorder.Order_ForDealer__c = agency1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ //invoiceorder.Order_ProType__c = 'ET';
+ insert invoiceorder;
+
+ invoiceorder = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :invoiceorder.id
+ ];
+ //鍑哄簱鍗�
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ TestList1.Order_date__c = Date.today().addDays(2);
+ TestList2.Order_date__c = Date.today().addDays(2);
+ TestList1.Deliver_date__c = Date.today();
+ TestList2.Deliver_date__c = Date.today();
+ insert testList1;
+ insert testList2;
+ System.Test.startTest();
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+
+ //鍑哄簱鍗�1鏄庣粏2
+ Consumable_orderdetails__c orderdet2 = new Consumable_orderdetails__c();
+ orderdet2.Name = 'Test1_001002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet2.Consumable_order__c = testList1.Id;
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet2.Consumable_count__c = 1;
+ orderdet2.Consumable_product__c = pro1.Id;
+
+ Consumable_orderdetails__c orderdet3 = new Consumable_orderdetails__c();
+ orderdet3.Name = 'Test1_001002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet3.Consumable_order__c = invoiceorder.Id;
+ orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet3.Consumable_count__c = 1;
+ orderdet3.Consumable_product__c = pro1.Id;
+ insert new List<Consumable_orderdetails__c>{
+ orderdet1,
+ orderdet2,
+ orderdet3
+ };
+
+ LexConInvoiceViewController conTest = new LexConInvoiceViewController();
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ LexConInvoiceViewController.SecondDealer = agency1.id;
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '娴庡畞浠诲煄鍎掓祹鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.saveAttachment(
+ JSON.serialize(LexConInvoiceViewController.attachmentRecoeds),
+ invoiceorder.Id
+ );
+ LexConInvoiceViewController.InvoiceorderSearch(
+ testList1,
+ invoiceorder.Id,
+ acc.Id,
+ '閲嶅簡',
+ 'ET',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.deleteButton(testList1.Id, testList1);
+ LexConInvoiceViewController.deleteButton('234567', testList1);
+ // LexConInvoiceViewController.saveFile(invoiceorder.Id,'Test','TmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LVozMTAwMDIs55u05o6l6ZSA5ZSu57uZ5Yy76ZmiLDgxMDU2NDAs5a6955S45Lic5qGl5bq35aSN5Yy76ZmiLOa2iOWMluenkSwsMTY4NjIwMzI1NDQ2ODI1MFZWR0lVLDEsMjAwMCznm5IsMjAsMjAyMy82Lzgs5Lii5aSx5Y6f5ZugDQpEQi1GWTIwMjQtMDYtWjMxMDAwMyznm7TmjqXplIDllK7nu5nljLvpmaIsODEwNTY0MCzlrr3nlLjkuJzmoaXlurflpI3ljLvpmaIs5raI5YyW56eRLCwxNjg2MjAzMjU2MDk4MjUwUkVKT1EsMSwzMDAwLOebkiwyMCwyMDIzLzYvOCzkuKLlpLHljp%2Flm6ANCkRCLUZZMjAyNC0wNi1aMzEwMDA0LOebtOaOpemUgOWUrue7meWMu%2BmZoiw4MTA1NjQwLOWuveeUuOS4nOahpeW6t%2BWkjeWMu%2BmZoizmtojljJbnp5EsLDE2ODYyMDMyNTc2NTcyNTBHU0ZTQiwxLDQwMDAs55uSLDIwLDIwMjMvNi84LOS4ouWkseWOn%2BWboA0K');
+ try {
+ LexConInvoiceViewController.saveFile(invoiceorder.Id, 'Test', '');
+ } catch (Exception e) {
+ system.debug('Test');
+ }
+ LexConInvoiceViewController.outbound = testList2;
+ LexConInvoiceViewController.getInvoiceName();
+ // LexConInvoiceViewController.shipmentAccount = '222';
+ Map<String, Decimal> ordermx1defaultMap = new Map<String, Decimal>();
+ LexConInvoiceViewController.ordermx1defaultMap = ordermx1defaultMap;
+ Map<String, String> deleteMap = new Map<String, String>();
+ LexConInvoiceViewController.deleteOutboundorder(deleteMap, '');
+ // LexConInvoiceViewController.invoiceOrderRecoedsCount
+ LexConInvoiceViewController.orderby = new List<String>{
+ 'Outbound_Date__c',
+ 'Name',
+ 'ShipmentAccount__c'
+ };
+ LexConInvoiceViewController.sortKey = 'test';
+ LexConInvoiceViewController.preSortKey = 'test';
+ LexConInvoiceViewController.sortOrderAsc = false;
+ LexConInvoiceViewController.sortOrder = new List<String>{
+ 'Outbound_Date__c',
+ 'Name',
+ 'ShipmentAccount__c'
+ };
+ List<LexConInvoiceViewController.InvoiceOrderInfo> test1 = new List<LexConInvoiceViewController.InvoiceOrderInfo>();
+ List<String> chukudanID = new List<String>();
+ chukudanID.add(testList2.Id);
+ chukudanID.add(testList1.Id);
+ LexConInvoiceViewController.newinvoicedetails1(chukudanID);
+ Map<String, String> insertDetMap = new Map<String, String>();
+ insertDetMap.put('Outboundorder_Code_link__c', testList1.Id);
+ // LexConInvoiceViewController.outOrderchange(insertDetMap);
+ LexConInvoiceViewController.getdefaultMapinfo(chukudanID);
+
+ System.Test.stopTest();
+ }
+ }
+
+ //鏂板缓鍙戠エ invoiceId=null
+
+ static testMethod void conInvoiceViewTestedit_2() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ //invoiceorder.Order_ForHospital__c =hosp1.Id;
+ // invoiceorder.Order_ForDealer__c = agency1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ //invoiceorder.Order_ProType__c = 'ET';
+ insert invoiceorder;
+
+ invoiceorder = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :invoiceorder.id
+ ];
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ TestList1.Order_date__c = Date.today().addDays(2);
+ TestList2.Order_date__c = Date.today().addDays(2);
+ TestList1.Deliver_date__c = Date.today();
+ TestList2.Deliver_date__c = Date.today();
+ insert testList1;
+ insert testList2;
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+
+ System.Test.startTest();
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController conTest = new LexConInvoiceViewController();
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ LexConInvoiceViewController.SecondDealer = agency1.id;
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '娴庡畞浠诲煄鍎掓祹鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.InvoiceorderSearch(
+ testList1,
+ invoiceorder.Id,
+ acc.Id,
+ '閲嶅簡',
+ 'ET',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds
+ );
+
+ // LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ System.Test.stopTest();
+ }
+ }
+ //鏂板缓鍙戠エ invoiceId=null error check
+
+ static testMethod void conInvoiceViewTestedit_3() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01 };
+
+ Product2__c pro1 = new Product2__c(
+ Name = 'Pro001',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod01.Id
+ );
+ insert new List<Product2__c>{ pro1 };
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ //invoiceorder.Order_ForHospital__c =hosp1.Id;
+ //invoiceorder.Order_ForDealer__c = agency1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ //invoiceorder.Order_ProType__c = 'ET';
+ insert invoiceorder;
+
+ invoiceorder = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :invoiceorder.id
+ ];
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ TestList1.Order_date__c = Date.today().addDays(2);
+ TestList2.Order_date__c = Date.today().addDays(2);
+ TestList1.Deliver_date__c = Date.today();
+ TestList2.Deliver_date__c = Date.today();
+ insert testList1;
+ insert testList2;
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+
+ PageReference page = new PageReference(
+ '/apex/ConInvoiceView?invoiceId=' +
+ invoiceorder.Id +
+ '&KeyWords=Redirect'
+ );
+ page.setRedirect(true);
+ System.Test.setCurrentPage(page);
+ System.Test.startTest();
+
+ LexConInvoiceViewController conTest = new LexConInvoiceViewController();
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ LexConInvoiceViewController.SecondDealer = agency1.id;
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '娴庡畞浠诲煄鍎掓祹鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.InvoiceorderSearch(
+ testList1,
+ invoiceorder.Id,
+ acc.Id,
+ '閲嶅簡',
+ 'ET',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds
+ );
+
+ // LexConInvoiceViewController.init();
+
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ // LexConInvoiceViewController.coc.SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌';
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ System.debug('===>hosp1.id' + hosp1.id);
+ LexConInvoiceViewController.invoiceId = null;
+ System.Test.stopTest();
+ }
+ }
+
+ //鏂板缓鍙戠エ 浠ュ強缂栬緫鍙戠エinvoiceId== NULL and deliveryId== NULL
+ static testMethod void conInvoiceViewTestinit() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ //invoiceorder.Order_ForHospital__c =hosp1.Id;
+ //invoiceorder.Order_ForDealer__c = agency1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ //invoiceorder.Order_ProType__c = 'ET';
+ insert invoiceorder;
+
+ invoiceorder = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :invoiceorder.id
+ ];
+ //鍑哄簱鍗�
+ //Consumable_order__c testList1 = new Consumable_order__c(Name='Test1',Summons_Sale_Status__c='鍑鸿揣',SummonsStatus_c__c='宸插畬鎴�',Order_ForHospital__c =hosp1.Id,SummonsForDirction__c='鐩存帴閿�鍞粰鍖婚櫌',Order_status__c='鑽夋涓�',Order_type__c='浼犵エ',Order_ForDealer__c = agency1.Id, Dealer_info__c=myAccount1.Id,ConInvoice_Code__c = invoiceorder.id);
+ //Consumable_order__c testList2 = new Consumable_order__c(Name='Test2',Summons_Sale_Status__c='鍑鸿揣',SummonsStatus_c__c='宸插畬鎴�',Order_ForHospital__c =hosp1.Id,SummonsForDirction__c='鐩存帴閿�鍞粰鍖婚櫌',Order_status__c='宸叉彁浜�',Order_type__c='浼犵エ',Order_ForDealer__c = agency1.Id, Dealer_info__c=myAccount1.Id,ConInvoice_Code__c = invoiceorder.id);
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ TestList1.Order_date__c = Date.today().addDays(2);
+ TestList2.Order_date__c = Date.today().addDays(2);
+ TestList1.Deliver_date__c = Date.today();
+ TestList2.Deliver_date__c = Date.today();
+ insert testList1;
+ insert testList2;
+ //insert new Consumable_order__c[]{testList1,testList2};
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+ Consumable_order_LinkTable__c order_LinkTable2 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable2',
+ Outboundorder_Code_link__c = testList2.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable2;
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+
+ //鍑哄簱鍗�1鏄庣粏2
+ Consumable_orderdetails__c orderdet2 = new Consumable_orderdetails__c();
+ orderdet2.Name = 'Test1_001002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet2.Consumable_order__c = testList1.Id;
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet2.Consumable_count__c = 1;
+ orderdet2.Consumable_product__c = pro1.Id;
+ //鍑哄簱鍗�2鏄庣粏1
+ Consumable_orderdetails__c orderdet3 = new Consumable_orderdetails__c();
+ orderdet3.Name = 'Test1_002001';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet3.Consumable_order__c = testList2.id;
+ orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet3.Consumable_count__c = 1;
+ orderdet3.Shipment_Count__c = 1;
+ orderdet3.Consumable_product__c = pro2.Id;
+
+ //鍑哄簱鍗�2鏄庣粏2
+ Consumable_orderdetails__c orderdet4 = new Consumable_orderdetails__c();
+ orderdet4.Name = 'Test1_002002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet4.Consumable_order__c = testList2.id;
+ orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet4.Consumable_count__c = 1;
+ orderdet4.Shipment_Count__c = 1;
+ orderdet4.Consumable_product__c = pro2.Id;
+ insert new List<Consumable_orderdetails__c>{
+ orderdet1,
+ orderdet2,
+ orderdet3,
+ orderdet4
+ };
+ //闄勪欢
+ Consumable_accessories_invoice__c caic = new Consumable_accessories_invoice__c();
+ caic.Attachment_ID__c = acc.Id;
+ caic.Accessories_type__c = '鍙戠エ鍜屾槑缁�';
+ caic.Invoice_code__c = invoiceorder.id;
+ insert caic;
+ PageReference page = new PageReference(
+ '/apex/ConInvoiceView?KeyWords=Redirect'
+ );
+ page.setRedirect(true);
+ System.Test.setCurrentPage(page);
+
+ //contest.deliveryId=testList1.id;
+ System.Test.startTest();
+ LexConInvoiceViewController conTest = new LexConInvoiceViewController();
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ LexConInvoiceViewController.SecondDealer = agency1.id;
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '娴庡畞浠诲煄鍎掓祹鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.InvoiceorderSearch(
+ testList1,
+ invoiceorder.Id,
+ acc.Id,
+ '閲嶅簡',
+ 'ET',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds
+ );
+ System.Test.stopTest();
+ }
+ }
+
+ //鏂板缓鍙戠エ 浠ュ強缂栬緫鍙戠エinvoiceId== NULL and deliveryId<> NULL
+ static testMethod void conInvoiceViewTestinit_1() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ //invoiceorder.Order_ForHospital__c =hosp1.Id;
+ //invoiceorder.Order_ForDealer__c = agency1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ insert invoiceorder;
+
+ invoiceorder = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :invoiceorder.id
+ ];
+ //鍑哄簱鍗�
+ //Consumable_order__c testList1 = new Consumable_order__c(Name='Test1',Summons_Sale_Status__c='鍑鸿揣',SummonsStatus_c__c='宸插畬鎴�',Order_ForHospital__c =hosp1.Id,SummonsForDirction__c='鐩存帴閿�鍞粰鍖婚櫌',Order_status__c='鑽夋涓�',Order_type__c='浼犵エ',Order_ForDealer__c = agency1.Id, Dealer_info__c=myAccount1.Id,ConInvoice_Code__c = invoiceorder.id);
+ //Consumable_order__c testList2 = new Consumable_order__c(Name='Test2',Summons_Sale_Status__c='鍑鸿揣',SummonsStatus_c__c='宸插畬鎴�',Order_ForHospital__c =hosp1.Id,SummonsForDirction__c='鐩存帴閿�鍞粰鍖婚櫌',Order_status__c='宸叉彁浜�',Order_type__c='浼犵エ',Order_ForDealer__c = agency1.Id, Dealer_info__c=myAccount1.Id,ConInvoice_Code__c = invoiceorder.id);
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ TestList1.Order_date__c = Date.today().addDays(2);
+ TestList2.Order_date__c = Date.today().addDays(2);
+ TestList1.Deliver_date__c = Date.today();
+ TestList2.Deliver_date__c = Date.today();
+ insert testList1;
+ insert testList2;
+ //insert new Consumable_order__c[]{testList1,testList2};
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+ Consumable_order_LinkTable__c order_LinkTable2 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable2',
+ Outboundorder_Code_link__c = testList2.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable2;
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+
+ //鍑哄簱鍗�1鏄庣粏2
+ Consumable_orderdetails__c orderdet2 = new Consumable_orderdetails__c();
+ orderdet2.Name = 'Test1_001002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet2.Consumable_order__c = testList1.Id;
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet2.Consumable_count__c = 1;
+ orderdet2.Consumable_product__c = pro1.Id;
+ //鍑哄簱鍗�2鏄庣粏1
+ Consumable_orderdetails__c orderdet3 = new Consumable_orderdetails__c();
+ orderdet3.Name = 'Test1_002001';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet3.Consumable_order__c = testList2.id;
+ orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet3.Consumable_count__c = 1;
+ orderdet3.Shipment_Count__c = 1;
+ orderdet3.Consumable_product__c = pro2.Id;
+
+ //鍑哄簱鍗�2鏄庣粏2
+ Consumable_orderdetails__c orderdet4 = new Consumable_orderdetails__c();
+ orderdet4.Name = 'Test1_002002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet4.Consumable_order__c = testList2.id;
+ orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet4.Consumable_count__c = 1;
+ orderdet4.Shipment_Count__c = 1;
+ orderdet4.Consumable_product__c = pro2.Id;
+ insert new List<Consumable_orderdetails__c>{
+ orderdet1,
+ orderdet2,
+ orderdet3,
+ orderdet4
+ };
+ //闄勪欢
+ Consumable_accessories_invoice__c caic = new Consumable_accessories_invoice__c();
+ caic.Attachment_ID__c = acc.Id;
+ caic.Accessories_type__c = '鍙戠エ鍜屾槑缁�';
+ caic.Invoice_code__c = invoiceorder.id;
+ insert caic;
+ PageReference page = new PageReference(
+ '/apex/ConInvoiceView?invoiceId=' + invoiceorder.id
+ );
+ page.setRedirect(true);
+ System.Test.setCurrentPage(page);
+
+ // contest.deliveryId=testList1.id;
+ System.Test.startTest();
+ LexConInvoiceViewController.init(
+ invoiceorder.id,
+ 'Redirect',
+ testList2.Id
+ );
+ LexConInvoiceViewController conTest = new LexConInvoiceViewController();
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ LexConInvoiceViewController.SecondDealer = agency1.id;
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '娴庡畞浠诲煄鍎掓祹鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.InvoiceorderSearch(
+ testList1,
+ invoiceorder.Id,
+ acc.Id,
+ '閲嶅簡',
+ 'ET',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds
+ );
+ System.Test.stopTest();
+ }
+ }
+
+ //鏂板缓鍙戠エ 浠ュ強缂栬緫鍙戠エinvoiceId<> NULL
+ static testMethod void conInvoiceViewTestinit_2() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ //invoiceorder.Order_ForHospital__c =hosp1.Id;
+ //invoiceorder.Order_ForDealer__c = agency1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ insert invoiceorder;
+
+ invoiceorder = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :invoiceorder.id
+ ];
+ //鍑哄簱鍗�
+ //Consumable_order__c testList1 = new Consumable_order__c(Name='Test1',Summons_Sale_Status__c='鍑鸿揣',SummonsStatus_c__c='宸插畬鎴�',Order_ForHospital__c =hosp1.Id,SummonsForDirction__c='鐩存帴閿�鍞粰鍖婚櫌',Order_status__c='鑽夋涓�',Order_type__c='浼犵エ',Order_ForDealer__c = agency1.Id, Dealer_info__c=myAccount1.Id,ConInvoice_Code__c = invoiceorder.id);
+ //Consumable_order__c testList2 = new Consumable_order__c(Name='Test2',Summons_Sale_Status__c='鍑鸿揣',SummonsStatus_c__c='宸插畬鎴�',Order_ForHospital__c =hosp1.Id,SummonsForDirction__c='鐩存帴閿�鍞粰鍖婚櫌',Order_status__c='宸叉彁浜�',Order_type__c='浼犵エ',Order_ForDealer__c = agency1.Id, Dealer_info__c=myAccount1.Id,ConInvoice_Code__c = invoiceorder.id);
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ TestList1.Order_date__c = Date.today().addDays(2);
+ TestList2.Order_date__c = Date.today().addDays(2);
+ TestList1.Deliver_date__c = Date.today();
+ TestList2.Deliver_date__c = Date.today();
+ insert testList1;
+ insert testList2;
+ //insert new Consumable_order__c[]{testList1,testList2};
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+ Consumable_order_LinkTable__c order_LinkTable2 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable2',
+ Outboundorder_Code_link__c = testList2.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable2;
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+
+ //鍑哄簱鍗�1鏄庣粏2
+ Consumable_orderdetails__c orderdet2 = new Consumable_orderdetails__c();
+ orderdet2.Name = 'Test1_001002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet2.Consumable_order__c = testList1.Id;
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet2.Consumable_count__c = 1;
+ orderdet2.Consumable_product__c = pro1.Id;
+ //鍑哄簱鍗�2鏄庣粏1
+ Consumable_orderdetails__c orderdet3 = new Consumable_orderdetails__c();
+ orderdet3.Name = 'Test1_002001';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet3.Consumable_order__c = testList2.id;
+ orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet3.Consumable_count__c = 1;
+ orderdet3.Shipment_Count__c = 1;
+ orderdet3.Consumable_product__c = pro2.Id;
+
+ //鍑哄簱鍗�2鏄庣粏2
+ Consumable_orderdetails__c orderdet4 = new Consumable_orderdetails__c();
+ orderdet4.Name = 'Test1_002002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet4.Consumable_order__c = testList2.id;
+ orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet4.Consumable_count__c = 1;
+ orderdet4.Shipment_Count__c = 1;
+ orderdet4.Consumable_product__c = pro2.Id;
+ insert new List<Consumable_orderdetails__c>{
+ orderdet1,
+ orderdet2,
+ orderdet3,
+ orderdet4
+ };
+ //闄勪欢
+ Consumable_accessories_invoice__c caic = new Consumable_accessories_invoice__c();
+ caic.Attachment_ID__c = acc.Id;
+ caic.Accessories_type__c = '鍙戠エ鍜屾槑缁�';
+ caic.Invoice_code__c = invoiceorder.id;
+ insert caic;
+ // PageReference page = new PageReference('/apex/ConInvoiceView?KeyWords=Redirect');
+ // page.setRedirect(true);
+ // System.Test.setCurrentPage(page);
+
+ // ConInvoiceViewController conTest = new ConInvoiceViewController();
+ // contest.deliveryId=testList1.id;
+ // conTest.invoiceId =invoiceorder.Id;
+ System.Test.startTest();
+ LexConInvoiceViewController.init(
+ invoiceorder.id,
+ 'Redirect',
+ testList2.Id
+ );
+ LexConInvoiceViewController conTest = new LexConInvoiceViewController();
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ LexConInvoiceViewController.SecondDealer = agency1.id;
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '娴庡畞浠诲煄鍎掓祹鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.InvoiceorderSearch(
+ testList1,
+ invoiceorder.Id,
+ acc.Id,
+ '閲嶅簡',
+ 'ET',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds
+ );
+
+ // conTest.init();
+
+ //System.assertEquals(false, conTest.getdone());
+ //System.assertEquals(false, conTest.getExistOutbound());
+ //System.assertEquals('invoice01', conTest.getInvoiceName());
+ //System.assertEquals(2, conTest.invoiceOrderRecoedsCount);
+ // conTest.InvoiceorderSearch();
+
+ // conTest.SortLimited();
+ System.Test.stopTest();
+ }
+ }
+ static testMethod void conInvoiceViewTestoutOrderchange() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ //invoiceorder.Order_ForHospital__c =hosp1.Id;
+ //invoiceorder.Order_ForDealer__c = agency1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ insert invoiceorder;
+
+ invoiceorder = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :invoiceorder.id
+ ];
+ //鍑哄簱鍗�
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ TestList1.Order_date__c = Date.today().addDays(2);
+ TestList2.Order_date__c = Date.today().addDays(2);
+ TestList1.Deliver_date__c = Date.today();
+ TestList2.Deliver_date__c = Date.today();
+ System.Test.startTest();
+ insert testList1;
+ insert testList2;
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+
+ //鍑哄簱鍗�1鏄庣粏2
+ Consumable_orderdetails__c orderdet2 = new Consumable_orderdetails__c();
+ orderdet2.Name = 'Test1_001002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet2.Consumable_order__c = testList1.Id;
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet2.Consumable_count__c = 1;
+ orderdet2.Consumable_product__c = pro1.Id;
+ insert new List<Consumable_orderdetails__c>{ orderdet1, orderdet2 };
+
+ LexConInvoiceViewController.init(
+ invoiceorder.id,
+ 'Redirect',
+ testList2.Id
+ );
+ LexConInvoiceViewController conTest = new LexConInvoiceViewController();
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ LexConInvoiceViewController.SecondDealer = agency1.id;
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '娴庡畞浠诲煄鍎掓祹鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.InvoiceorderSearch(
+ testList1,
+ invoiceorder.Id,
+ acc.Id,
+ '閲嶅簡',
+ 'ET',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds
+ );
+ System.Test.stopTest();
+ }
+ }
+
+ static testMethod void conInvoiceViewTestgetdefaultMapinfo() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ //invoiceorder.Order_ForHospital__c =hosp1.Id;
+ // invoiceorder.Order_ForDealer__c = agency1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ insert invoiceorder;
+
+ invoiceorder = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :invoiceorder.id
+ ];
+ //鍑哄簱鍗�
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ TestList1.Order_date__c = Date.today().addDays(2);
+ TestList2.Order_date__c = Date.today().addDays(2);
+ TestList1.Deliver_date__c = Date.today();
+ TestList2.Deliver_date__c = Date.today();
+ System.Test.startTest();
+ insert testList1;
+ insert testList2;
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+
+ //鍑哄簱鍗�1鏄庣粏2
+ Consumable_orderdetails__c orderdet2 = new Consumable_orderdetails__c();
+ orderdet2.Name = 'Test1_001002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet2.Consumable_order__c = testList1.Id;
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet2.Consumable_count__c = 1;
+ orderdet2.Consumable_product__c = pro1.Id;
+ insert new List<Consumable_orderdetails__c>{ orderdet1, orderdet2 };
+
+ PageReference page = new PageReference(
+ '/apex/ConInvoiceView?invoiceId=' +
+ invoiceorder.Id +
+ '&KeyWords=Redirect'
+ );
+ page.setRedirect(true);
+ System.Test.setCurrentPage(page);
+
+ LexConInvoiceViewController.init(
+ invoiceorder.id,
+ 'Redirect',
+ testList2.Id
+ );
+ LexConInvoiceViewController conTest = new LexConInvoiceViewController();
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ LexConInvoiceViewController.SecondDealer = agency1.id;
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '娴庡畞浠诲煄鍎掓祹鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.InvoiceorderSearch(
+ testList1,
+ invoiceorder.Id,
+ acc.Id,
+ '閲嶅簡',
+ 'ET',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds
+ );
+ System.Test.stopTest();
+ }
+ }
+
+ //浠庡嚭搴撳崟鐩存帴寮�绁�
+ static testMethod void conInvoiceViewRedirectTest() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ //invoiceorder.Order_ForHospital__c =hosp1.Id;
+ //invoiceorder.Order_ForDealer__c = agency1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ insert invoiceorder;
+
+ invoiceorder = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :invoiceorder.id
+ ];
+ //鍑哄簱鍗�
+ //Consumable_order__c testList1 = new Consumable_order__c(Name='Test1',Summons_Sale_Status__c='鍑鸿揣',SummonsStatus_c__c='宸插畬鎴�',Order_ForHospital__c =hosp1.Id,SummonsForDirction__c='鐩存帴閿�鍞粰鍖婚櫌',Order_status__c='鑽夋涓�',Order_type__c='浼犵エ',Order_ForDealer__c = agency1.Id, Dealer_info__c=myAccount1.Id,ConInvoice_Code__c = invoiceorder.id);
+ //Consumable_order__c testList2 = new Consumable_order__c(Name='Test2',Summons_Sale_Status__c='鍑鸿揣',SummonsStatus_c__c='宸插畬鎴�',Order_ForHospital__c =hosp1.Id,SummonsForDirction__c='鐩存帴閿�鍞粰鍖婚櫌',Order_status__c='宸叉彁浜�',Order_type__c='浼犵エ',Order_ForDealer__c = agency1.Id, Dealer_info__c=myAccount1.Id,ConInvoice_Code__c = invoiceorder.id);
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ testList1.Order_date__c = Date.today().addDays(2);
+ testList2.Order_date__c = Date.today().addDays(2);
+ testList1.Deliver_date__c = Date.today();
+ testList2.Deliver_date__c = Date.today();
+ insert testList1;
+ insert testList2;
+ //insert new Consumable_order__c[]{testList1,testList2};
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+ Consumable_order_LinkTable__c order_LinkTable2 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable2',
+ Outboundorder_Code_link__c = testList2.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable2;
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+
+ //鍑哄簱鍗�1鏄庣粏2
+ Consumable_orderdetails__c orderdet2 = new Consumable_orderdetails__c();
+ orderdet2.Name = 'Test1_001002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet2.Consumable_order__c = testList1.Id;
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet2.Consumable_count__c = 1;
+ orderdet2.Consumable_product__c = pro1.Id;
+ //鍑哄簱鍗�2鏄庣粏1
+ Consumable_orderdetails__c orderdet3 = new Consumable_orderdetails__c();
+ orderdet3.Name = 'Test1_002001';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet3.Consumable_order__c = testList2.id;
+ orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet3.Consumable_count__c = 1;
+ orderdet3.Shipment_Count__c = 1;
+ orderdet3.Consumable_product__c = pro2.Id;
+
+ //鍑哄簱鍗�2鏄庣粏2
+ Consumable_orderdetails__c orderdet4 = new Consumable_orderdetails__c();
+ orderdet4.Name = 'Test1_002002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet4.Consumable_order__c = testList2.id;
+ orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet4.Consumable_count__c = 1;
+ orderdet4.Shipment_Count__c = 1;
+ orderdet4.Consumable_product__c = pro2.Id;
+ insert new List<Consumable_orderdetails__c>{
+ orderdet1,
+ orderdet2,
+ orderdet3,
+ orderdet4
+ };
+ //闄勪欢
+ Consumable_accessories_invoice__c caic = new Consumable_accessories_invoice__c();
+ caic.Attachment_ID__c = acc.Id;
+ caic.Accessories_type__c = '鍙戠エ鍜屾槑缁�';
+ caic.Invoice_code__c = invoiceorder.id;
+ insert caic;
+ PageReference page = new PageReference(
+ '/apex/ConInvoiceView?deliveryId=' + testList1.Id + '&KeyWords=Redirect'
+ );
+ page.setRedirect(true);
+ System.Test.setCurrentPage(page);
+
+ System.Test.startTest();
+ LexConInvoiceViewController.init(
+ invoiceorder.id,
+ 'Redirect',
+ testList2.Id
+ );
+ LexConInvoiceViewController conTest = new LexConInvoiceViewController();
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ LexConInvoiceViewController.SecondDealer = agency1.id;
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '娴庡畞浠诲煄鍎掓祹鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.InvoiceorderSearch(
+ testList1,
+ invoiceorder.Id,
+ acc.Id,
+ '閲嶅簡',
+ 'ET',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.saveAttachment(
+ JSON.serialize(LexConInvoiceViewController.attachmentRecoeds),
+ invoiceorder.Id
+ );
+ // LexConInvoiceViewController.saveAttachment(JSON.serialize(caic),invoiceorder.Id);
+ System.Test.stopTest();
+ }
+ }
+
+ //鎻愪氦
+ static testMethod void conInvoiceViewTestapproval() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Manual_Entry__c = false,
+ Packing_list_manual__c = 5
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ 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 invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ //invoiceorder.Order_ForHospital__c =hosp1.Id;
+ //invoiceorder.Order_ForDealer__c = agency1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ insert invoiceorder;
+
+ invoiceorder = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :invoiceorder.id
+ ];
+ //鍑哄簱鍗�
+ //Consumable_order__c testList1 = new Consumable_order__c(Name='Test1',Summons_Sale_Status__c='鍑鸿揣',SummonsStatus_c__c='宸插畬鎴�',Order_ForHospital__c =hosp1.Id,SummonsForDirction__c='鐩存帴閿�鍞粰鍖婚櫌',Order_status__c='鑽夋涓�',Order_type__c='浼犵エ',Order_ForDealer__c = agency1.Id, Dealer_info__c=myAccount1.Id,ConInvoice_Code__c = invoiceorder.id);
+ //Consumable_order__c testList2 = new Consumable_order__c(Name='Test2',Summons_Sale_Status__c='鍑鸿揣',SummonsStatus_c__c='宸插畬鎴�',Order_ForHospital__c =hosp1.Id,SummonsForDirction__c='鐩存帴閿�鍞粰鍖婚櫌',Order_status__c='宸叉彁浜�',Order_type__c='浼犵エ',Order_ForDealer__c = agency1.Id, Dealer_info__c=myAccount1.Id,ConInvoice_Code__c = invoiceorder.id);
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ RecordTypeId = System.Label.RT_ConOrder_Sale,
+ Dealer_info__c = acc.Id
+ );
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ RecordTypeId = System.Label.RT_ConOrder_Sale,
+ Dealer_info__c = acc.Id
+ );
+ testList1.Order_date__c = Date.today().addDays(2);
+ testList2.Order_date__c = Date.today().addDays(2);
+ testList1.Deliver_date__c = Date.today();
+ testList2.Deliver_date__c = Date.today();
+ insert testList1;
+ insert testList2;
+ //insert new Consumable_order__c[]{testList1,testList2};
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+ Consumable_order_LinkTable__c order_LinkTable2 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable2',
+ Outboundorder_Code_link__c = testList2.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable2;
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_Orderdetails__c orderdet1 = new Consumable_Orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+ orderdet1.Invoiced_Count__c = 10;
+ orderdet1.Delivery_List_RMB__c = 200;
+ orderdet1.Box_Piece__c = '鐩�';
+ orderdet1.Invoice_Unit__c = '涓�';
+ // orderdet1.Shipment_Count__c = 50;
+ // orderdet1.Invoiced_Procount__c = 5;
+ // orderdet1.RrturnPro_count__c = 5;
+
+ Consumable_Orderdetails__c orderdet12 = new Consumable_Orderdetails__c();
+ orderdet12.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet12.Consumable_order__c = testList1.Id;
+ orderdet12.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet12.Consumable_count__c = 1;
+ orderdet12.Consumable_product__c = pro1.Id;
+ orderdet12.Invoiced_Count__c = 30;
+ orderdet12.Delivery_List_RMB__c = 200;
+ //鍑哄簱鍗�1鏄庣粏2
+ Consumable_Orderdetails__c orderdet2 = new Consumable_Orderdetails__c();
+ orderdet2.Name = 'Test1_001002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet2.Consumable_order__c = invoiceorder.Id;
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet2.Consumable_count__c = 1;
+ orderdet2.Consumable_product__c = pro1.Id;
+ //鍑哄簱鍗�2鏄庣粏1
+ Consumable_Orderdetails__c orderdet3 = new Consumable_Orderdetails__c();
+ orderdet3.Name = 'Test1_002001';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet3.Consumable_order__c = invoiceorder.Id;
+ orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet3.Consumable_count__c = 1;
+ orderdet3.Shipment_Count__c = 1;
+ orderdet3.Consumable_product__c = pro2.Id;
+
+ //鍑哄簱鍗�2鏄庣粏2
+ Consumable_Orderdetails__c orderdet4 = new Consumable_Orderdetails__c();
+ orderdet4.Name = 'Test1_002002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet4.Consumable_order__c = testList2.id;
+ orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet4.Consumable_count__c = 1;
+ orderdet4.Shipment_Count__c = 1;
+ orderdet4.Consumable_product__c = pro2.Id;
+ insert new List<Consumable_Orderdetails__c>{
+ orderdet1,
+ orderdet2,
+ orderdet3,
+ orderdet4,
+ orderdet12
+ };
+
+ List<String> conorList = new List<String>();
+ conorList.add(testList1.Id);
+
+ // List<Consumable_Orderdetails__c> outOrderdet1List1 = new List<Consumable_Orderdetails__c>();
+ // outOrderdet1List1.add(orderdet1);
+
+ List<Consumable_Orderdetails__c> outOrderdet1List = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Consumable_order__r.Name,
+ Asset_Model_No__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Shipment_Count__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ Invoice_Unitprice__c,
+ InvoiceProNot_count__c,
+ Invoice_Cost_RMB__c,
+ Invoice_No__c,
+ Box_Piece__c,
+ Invoice_Unit__c,
+ ProductPacking_list_manual__c
+ FROM Consumable_Orderdetails__c
+ WHERE Id = :orderdet1.Id
+ ];
+
+ System.debug('outOrderdet1List' + outOrderdet1List);
+ List<Consumable_Orderdetails__c> outOrderdet1List1 = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Consumable_order__r.Name,
+ Asset_Model_No__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Shipment_Count__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ Invoice_Unitprice__c,
+ InvoiceProNot_count__c,
+ Invoice_Cost_RMB__c,
+ Invoice_No__c,
+ Box_Piece__c,
+ Invoice_Unit__c,
+ ProductPacking_list_manual__c
+ FROM Consumable_Orderdetails__c
+ WHERE Id = :orderdet12.Id
+ ];
+
+ Map<String, Consumable_Orderdetails__c> tempCocMap = new Map<String, Consumable_Orderdetails__c>();
+ Map<String, Consumable_Orderdetails__c> tempCocMap1 = new Map<String, Consumable_Orderdetails__c>();
+ for (Consumable_Orderdetails__c cocTemp : outOrderdet1List) {
+ if (cocTemp.Consumable_order__c + cocTemp.Asset_Model_No__c != null) {
+ tempCocMap.put(
+ cocTemp.Consumable_order__c + cocTemp.Asset_Model_No__c,
+ cocTemp
+ );
+ }
+ }
+ for (Consumable_Orderdetails__c cocTemp : outOrderdet1List1) {
+ if (cocTemp.Consumable_order__c + cocTemp.Asset_Model_No__c != null) {
+ tempCocMap1.put(
+ cocTemp.Consumable_order__c + cocTemp.Asset_Model_No__c,
+ cocTemp
+ );
+ }
+ }
+
+ System.debug('tempCocMap===>' + tempCocMap);
+ //闄勪欢
+ Consumable_accessories_invoice__c caic = new Consumable_accessories_invoice__c();
+ caic.Attachment_ID__c = acc.Id;
+ caic.Accessories_type__c = '鍙戠エ鍜屾槑缁�';
+ caic.Invoice_code__c = invoiceorder.id;
+ insert caic;
+
+ System.Test.startTest();
+ LexConInvoiceViewController.init(
+ invoiceorder.id,
+ 'Redirect',
+ testList2.Id
+ );
+ LexConInvoiceViewController conTest = new LexConInvoiceViewController();
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ LexConInvoiceViewController.SecondDealer = agency1.id;
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '娴庡畞浠诲煄鍎掓祹鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.InvoiceorderSearch(
+ testList1,
+ invoiceorder.Id,
+ acc.Id,
+ '閲嶅簡',
+ 'ET',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.approval(
+ conorList,
+ tempCocMap,
+ invoiceorder.id
+ );
+ LexConInvoiceViewController.approval(
+ conorList,
+ tempCocMap1,
+ invoiceorder.id
+ );
+ System.Test.stopTest();
+ }
+ }
+
+ //鎻愪氦鍙戠エ
+ static testMethod void conInvoice_approval() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Oly_TriggerHandler.bypass('ConsumableAssetHander');
+ Oly_TriggerHandler.bypass('Oly_TriggerHandler');
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 };
+
+ //鍑哄簱鍗�1
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ recordtypeid = System.Label.RT_ConOrder_Sale,
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ // Order_ForHospital__c=hosp1.Id,
+ Dealer_Info__c = acc.Id
+ );
+ TestList1.Order_date__c = Date.today().addDays(2);
+ TestList1.Deliver_date__c = Date.today();
+ insert testList1;
+
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001';
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Sale;
+ orderdet1.Shipment_Count__c = 1;
+ orderdet1.Delivery_List_RMB__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+ orderdet1.Shipment_Count__c = 50;
+ orderdet1.Invoiced_Procount__c = 5;
+ orderdet1.RrturnPro_count__c = 5;
+ insert orderdet1;
+ List<String> conorList = new List<String>();
+ conorList.add(testList1.Id);
+ //鍑哄簱鍗�1鏄庣粏2
+ Consumable_order_details2__c orderdet2 = new Consumable_order_details2__c();
+ orderdet2.Name = 'Test1_001001';
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ orderdet2.Consumable_Sale_order__c = testList1.Id;
+ orderdet2.Deliver_date__c = Date.today();
+ orderdet2.Arrive_date__c = Date.today();
+ orderdet2.Used_date__c = Date.today();
+ orderdet2.Consumable_product__c = pro1.Id;
+ insert orderdet2;
+
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ // invoiceorder.Order_ForHospital__c =hosp1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ insert invoiceorder;
+
+ //鍙戠エ鏄庣粏1
+ Consumable_orderdetails__c invoicedet1 = new Consumable_orderdetails__c();
+ invoicedet1.Name = 'invoice01_01';
+ invoicedet1.Consumable_order__c = invoiceorder.Id;
+ invoicedet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ invoicedet1.Invoiced_Count__c = 1;
+ invoicedet1.Invoice_Unitprice__c = 1;
+ invoicedet1.Consumable_product__c = pro1.Id;
+ invoicedet1.Invoicedet1_OD_link__c = testList1.Id;
+ insert invoicedet1;
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+ List<Consumable_Orderdetails__c> outOrderdet1List = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Consumable_order__r.Name,
+ Asset_Model_No__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Shipment_Count__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ Invoice_Unitprice__c,
+ InvoiceProNot_count__c,
+ Invoice_Cost_RMB__c,
+ Invoice_No__c,
+ Box_Piece__c,
+ Invoice_Unit__c,
+ ProductPacking_list_manual__c
+ FROM Consumable_Orderdetails__c
+ WHERE Id = :orderdet1.Id
+ ];
+ Map<String, Consumable_Orderdetails__c> tempCocMap1 = new Map<String, Consumable_Orderdetails__c>();
+ for (Consumable_Orderdetails__c cocTemp : outOrderdet1List) {
+ if (cocTemp.Consumable_order__c + cocTemp.Asset_Model_No__c != null) {
+ tempCocMap1.put(
+ cocTemp.Consumable_order__c + cocTemp.Asset_Model_No__c,
+ cocTemp
+ );
+ }
+ }
+
+ System.Test.startTest();
+
+ LexConInvoiceViewController.init(
+ invoiceorder.id,
+ 'Redirect',
+ orderdet1.Id
+ );
+ LexConInvoiceViewController conTest = new LexConInvoiceViewController();
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ LexConInvoiceViewController.SecondDealer = acc.id;
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '娴庡畞浠诲煄鍎掓祹鍖婚櫌',
+ hosp1.id,
+ acc.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.InvoiceorderSearch(
+ testList1,
+ invoiceorder.Id,
+ acc.Id,
+ '閲嶅簡',
+ 'ET',
+ hosp1.id,
+ acc.id,
+ invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.approval(
+ conorList,
+ tempCocMap1,
+ invoiceorder.id
+ );
+ LexConInvoiceViewController.approval(conorList, tempCocMap1, '2345678');
+
+ // conTest.init();
+
+ // System.assertEquals(1, conTest.invoiceOrderRecoeds.size());
+ // conTest.approval();
+ System.Test.stopTest();
+ }
+ }
+
+ //CHAN-BSS5SQ update by rentongxiao 2020-08-26 start
+ //鏂板缓鍙戠エ 浠ュ強缂栬緫鍙戠エ invoiceId<>null
+ static testMethod void rentestreopen() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鎻愪氦';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ //invoiceorder.Order_ForHospital__c =hosp1.Id;
+ //invoiceorder.Order_ForDealer__c = agency1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ //invoiceorder.Order_ProType__c = 'ET';
+ insert invoiceorder;
+
+ invoiceorder = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :invoiceorder.id
+ ];
+ //鍑哄簱鍗�
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+
+ Consumable_order__c testList3 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ TestList1.Order_date__c = Date.today().addDays(2);
+ TestList2.Order_date__c = Date.today().addDays(2);
+ TestList3.Order_date__c = Date.today().addDays(2);
+ TestList1.Deliver_date__c = Date.today();
+ TestList2.Deliver_date__c = Date.today();
+ TestList3.Deliver_date__c = Date.today();
+ insert testList1;
+ insert testList2;
+ insert testList3;
+ System.Test.startTest();
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ Consumable_order_LinkTable__c order_LinkTable2 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList2.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ Consumable_order_LinkTable__c order_LinkTable3 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList3.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+ insert order_LinkTable2;
+ insert order_LinkTable3;
+
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+
+ //鍑哄簱鍗�1鏄庣粏2
+ Consumable_orderdetails__c orderdet2 = new Consumable_orderdetails__c();
+ orderdet2.Name = 'Test1_001002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet2.Consumable_order__c = testList1.Id;
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet2.Consumable_count__c = 1;
+ orderdet2.Consumable_product__c = pro1.Id;
+ insert new List<Consumable_orderdetails__c>{ orderdet1, orderdet2 };
+
+ //鍑哄簱鍗�2鏄庣粏1
+ Consumable_orderdetails__c orderdet3 = new Consumable_orderdetails__c();
+ orderdet3.Name = 'Test3_001002';
+ //orderdet3.Consumable_principal__c = testList2.Id;
+ orderdet3.Consumable_order__c = testList2.Id;
+ orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet3.Consumable_count__c = 1;
+ orderdet3.Consumable_product__c = pro1.Id;
+ insert orderdet3;
+
+ //鍑哄簱鍗�3鏄庣粏1
+ Consumable_orderdetails__c orderdet4 = new Consumable_orderdetails__c();
+ orderdet4.Name = 'Test3_001002';
+ //orderdet4.Consumable_principal__c = testList2.Id;
+ orderdet4.Consumable_order__c = testList3.Id;
+ orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet4.Consumable_count__c = 1;
+ orderdet4.Consumable_product__c = pro1.Id;
+ insert orderdet4;
+
+ PageReference page = new PageReference(
+ '/apex/ConInvoiceView?invoiceId=' +
+ invoiceorder.Id +
+ '&reopen=isreopen&KeyWords=Redirect'
+ );
+ page.setRedirect(true);
+ System.Test.setCurrentPage(page);
+
+ LexConInvoiceViewController.init(
+ invoiceorder.id,
+ 'Redirect',
+ testList2.Id
+ );
+ LexConInvoiceViewController conTest = new LexConInvoiceViewController();
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ LexConInvoiceViewController.SecondDealer = agency1.id;
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '娴庡畞浠诲煄鍎掓祹鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.InvoiceorderSearch(
+ testList1,
+ invoiceorder.Id,
+ acc.Id,
+ '閲嶅簡',
+ 'ET',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds
+ );
+
+ // ConInvoiceViewController conTest = new ConInvoiceViewController();
+
+ // conTest.init();
+
+ // conTest.invoiceId =invoiceorder.Id;
+ // conTest.coc.SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌';
+ // conTest.HospitalInfo = hosp1.id;
+ // //conTest.SecondDealer = agency1.id;
+ // //conTest.coc.Order_ForDealer__c = agency1.id;
+ // conTest.coc.Name = 'invoice002';
+ // conTest.coc.Order_ForCustomerText__c = 'AA';
+ // conTest.coc.Order_ForHospital__c = hosp1.id;
+ // conTest.coc.Invoice_Date__c = Date.today();
+
+ // //conTest.SortLimited();
+ // //conTest.InvoiceorderSearch();
+ // System.assertEquals(3, conTest.invoiceOrderRecoeds.size());
+ // conTest.invoiceOrderRecoeds[0].esd.Order_ForCustomerText__c = 'AA';
+ // conTest.invoiceOrderRecoeds[0].esd.Order_ForHospital__c =hosp1.Id;
+ // conTest.invoiceOrderRecoeds[0].esd.Order_ForDealer__c = agency1.id;
+
+ // conTest.invoiceOrderRecoeds[1].esd.Order_ForCustomerText__c = 'AA';
+ // conTest.invoiceOrderRecoeds[1].esd.Order_ForHospital__c =hosp1.Id;
+ // conTest.invoiceOrderRecoeds[1].esd.Order_ForDealer__c = agency1.id;
+
+ // conTest.invoiceOrderRecoeds[2].esd.Order_ForCustomerText__c = 'AA';
+ // conTest.invoiceOrderRecoeds[2].esd.Order_ForHospital__c =hosp1.Id;
+ // conTest.invoiceOrderRecoeds[2].esd.Order_ForDealer__c = agency1.id;
+
+ // conTest.invoiceOrderRecoeds[0].check= true;
+ // conTest.invoiceOrderRecoeds[1].check= false;
+ // conTest.invoiceOrderRecoeds[2].check= true;
+
+ // conTest.save();
+ // //System.assertEquals('123',conTest.testTmp);
+ // conTest.nvoiceorderremind();
+ // conTest.saveAttachment();
+
+ // conTest.getdone();
+ // conTest.getExistOutbound();
+ // conTest.getInvoiceName();
+ System.Test.stopTest();
+ }
+ }
+
+ //CHAN-BSS5SQ update by rentongxiao 2020-08-26 end
+ //CHAN-BSS5SQ update by rentongxiao 2020-08-26 start
+ //鏂板缓鍙戠エ 浠ュ強缂栬緫鍙戠エ invoiceId<>null
+ static testMethod void rentestreopen001() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鎻愪氦';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ //invoiceorder.Order_ForHospital__c =hosp1.Id;
+ //invoiceorder.Order_ForDealer__c = agency1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ //invoiceorder.Order_ProType__c = 'ET';
+ insert invoiceorder;
+
+ invoiceorder = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :invoiceorder.id
+ ];
+ //鍑哄簱鍗�
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+
+ Consumable_order__c testList3 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ TestList1.Order_date__c = Date.today().addDays(2);
+ TestList2.Order_date__c = Date.today().addDays(2);
+ TestList3.Order_date__c = Date.today().addDays(2);
+ TestList1.Deliver_date__c = Date.today();
+ TestList2.Deliver_date__c = Date.today();
+ TestList3.Deliver_date__c = Date.today();
+ insert testList1;
+ insert testList2;
+ insert testList3;
+ System.Test.startTest();
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ Consumable_order_LinkTable__c order_LinkTable2 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList2.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ Consumable_order_LinkTable__c order_LinkTable3 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList3.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+ insert order_LinkTable2;
+ insert order_LinkTable3;
+
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+
+ //鍑哄簱鍗�1鏄庣粏2
+ Consumable_orderdetails__c orderdet2 = new Consumable_orderdetails__c();
+ orderdet2.Name = 'Test1_001002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet2.Consumable_order__c = testList1.Id;
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet2.Consumable_count__c = 1;
+ orderdet2.Consumable_product__c = pro1.Id;
+ insert new List<Consumable_orderdetails__c>{ orderdet1, orderdet2 };
+
+ //鍑哄簱鍗�2鏄庣粏1
+ Consumable_orderdetails__c orderdet3 = new Consumable_orderdetails__c();
+ orderdet3.Name = 'Test3_001002';
+ //orderdet3.Consumable_principal__c = testList2.Id;
+ orderdet3.Consumable_order__c = testList2.Id;
+ orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet3.Consumable_count__c = 1;
+ orderdet3.Consumable_product__c = pro1.Id;
+ insert orderdet3;
+
+ //鍑哄簱鍗�3鏄庣粏1
+ Consumable_orderdetails__c orderdet4 = new Consumable_orderdetails__c();
+ orderdet4.Name = 'Test3_001002';
+ //orderdet4.Consumable_principal__c = testList2.Id;
+ orderdet4.Consumable_order__c = testList3.Id;
+ orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet4.Consumable_count__c = 1;
+ orderdet4.Consumable_product__c = pro1.Id;
+ insert orderdet4;
+
+ PageReference page = new PageReference(
+ '/apex/ConInvoiceView?invoiceId=' +
+ invoiceorder.Id +
+ '&reopen=isreopen&KeyWords=Redirect'
+ );
+ page.setRedirect(true);
+ System.Test.setCurrentPage(page);
+
+ LexConInvoiceViewController.init(
+ invoiceorder.id,
+ 'Redirect',
+ testList2.Id
+ );
+ LexConInvoiceViewController conTest = new LexConInvoiceViewController();
+ LexConInvoiceViewController.HospitalInfo = hosp1.id;
+ LexConInvoiceViewController.SecondDealer = agency1.id;
+ LexConInvoiceViewController.invoiceId = invoiceorder.Id;
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '娴庡畞浠诲煄鍎掓祹鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.InvoiceorderSearch(
+ testList1,
+ invoiceorder.Id,
+ acc.Id,
+ '閲嶅簡',
+ 'ET',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds
+ );
+ System.Test.stopTest();
+ }
+ }
+ //鏂板缓鍙戠エ 浠ュ強缂栬緫鍙戠エ invoiceId<>null
+ static testMethod void allinit() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //鍑嗗鏁版嵁
+ // Consumable_order__c Id = deliveryId //鍑哄簱鍗�
+ // Consumable_order__c
+ // WHERE Id = :invoiceId AND Order_type__c = '鍙戠エ'
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ // invoiceorder.Order_ForHospital__c =hosp1.Id;
+ // invoiceorder.Order_ForDealer__c = agency1.Id;
+ invoiceorder.Dealer_Info__c = acc.Id;
+ //invoiceorder.Order_ProType__c = 'ET';
+ insert invoiceorder;
+
+ invoiceorder = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :invoiceorder.id
+ ];
+ //鍑哄簱鍗�
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test2',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '宸叉彁浜�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id,
+ Order_ForCustomerText__c = ''
+ );
+ TestList1.Order_date__c = Date.today().addDays(2);
+ TestList2.Order_date__c = Date.today().addDays(2);
+ TestList1.Deliver_date__c = Date.today();
+ TestList2.Deliver_date__c = Date.today();
+
+ Consumable_order__c testList3 = new Consumable_order__c();
+ testList3.Summons_Sale_Status__c = '鍑鸿揣';
+ testList3.SummonsStatus_c__c = '宸插畬鎴�';
+ testList3.SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌';
+ testList3.Order_status__c = '鑽夋涓�';
+ testList3.Order_type__c = '浼犵エ';
+ testList3.Dealer_info__c = acc.Id;
+ testList3.Order_ForCustomerText__c = '娑堝寲绉�';
+
+ insert testList1;
+ insert testList2;
+ insert testList3;
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder.Id
+ );
+ insert order_LinkTable1;
+
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+
+ //鍑哄簱鍗�1鏄庣粏2
+ Consumable_orderdetails__c orderdet2 = new Consumable_orderdetails__c();
+ orderdet2.Name = 'Test1_001002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet2.Consumable_order__c = testList1.Id;
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet2.Consumable_count__c = 1;
+ orderdet2.Consumable_product__c = pro1.Id;
+
+ Consumable_orderdetails__c orderdet3 = new Consumable_orderdetails__c();
+ orderdet3.Name = 'Test1_001002';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet3.Consumable_order__c = invoiceorder.Id;
+ orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet3.Consumable_count__c = 1;
+ orderdet3.Consumable_product__c = pro1.Id;
+ insert new List<Consumable_orderdetails__c>{
+ orderdet1,
+ orderdet2,
+ orderdet3
+ };
+
+ //鍙戠エ闄勪欢
+ Consumable_accessories_invoice__c cai = new Consumable_accessories_invoice__c();
+ cai.Invoice_code__c = invoiceorder.Id;
+ insert cai;
+
+ System.Test.startTest();
+
+ LexConInvoiceViewController.init(invoiceorder.Id, '', testList1.Id);
+ LexConInvoiceViewController.init('', '', testList1.Id);
+ LexConInvoiceViewController.init(invoiceorder.Id, '', '');
+ LexConInvoiceViewController.init('', '', '');
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList1.Id
+ );
+ LexConInvoiceViewController.init('', 'Redirect', '');
+ LexConInvoiceViewController.init('', 'Redirect', testList1.Id);
+ System.debug(
+ 'order==>' + LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ 'Testhosp001',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.save(
+ testList2,
+ 'Testhosp001',
+ '',
+ '',
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.save(
+ testList3,
+ 'Testhosp001',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.save(
+ testList2,
+ 'Testhosp001',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+
+ //淇濆瓨
+ // LexConInvoiceViewController.save(testList1,'娴嬭瘯鍖婚櫌',hosp1.Id,agency1.Id,'',testList1.Id,invoiceorder.Id,myAccount1.Id,'ET');
+ System.Test.stopTest();
+ }
+ }
+ static testMethod void allsave() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ // invoiceorder.Order_ForHospital__c = '';
+ // invoiceorder.Order_ForDealer__c = '';
+ invoiceorder.Dealer_Info__c = acc.Id;
+ //invoiceorder.Order_ProType__c = 'ET';
+ insert invoiceorder;
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id,
+ Invoice_Date__c = Date.today()
+ );
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ // LexConInvoiceViewController.init(invoiceorder.Id,'Redirect',testList1.Id);
+ LexConInvoiceViewController.save(
+ testList1,
+ 'Testhosp001',
+ null,
+ null,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ 'Testhosp001',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.saveAttachment(
+ JSON.serialize(LexConInvoiceViewController.attachmentRecoeds),
+ invoiceorder.Id
+ );
+ }
+ }
+ static testMethod void allsave1() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ // invoiceorder.Order_ForHospital__c = '';
+ // invoiceorder.Order_ForDealer__c = '';
+ invoiceorder.Dealer_Info__c = acc.Id;
+ //invoiceorder.Order_ProType__c = 'ET';
+ insert invoiceorder;
+
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id,
+ Invoice_Date__c = Date.today(),
+ Order_ForCustomerText__c = '娑堝寲绉�'
+ );
+ insert testList1;
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id,
+ Invoice_Date__c = Date.today(),
+ Order_ForDealerText__c = 'Test'
+ );
+ insert testList2;
+
+ LexConInvoiceViewController.init(
+ invoiceorder.Id,
+ 'Redirect',
+ testList2.Id
+ );
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ String invoiceOrderRecoeds = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoeds
+ );
+ List<LexConInvoiceViewController.InvoiceOrderInfo> test1 = new List<LexConInvoiceViewController.InvoiceOrderInfo>();
+ for (
+ LexConInvoiceViewController.InvoiceOrderInfo ass : LexConInvoiceViewController.invoiceOrderRecoeds
+ ) {
+ ass.check = true;
+ test1.add(ass);
+ }
+ System.debug('test1==>' + test1);
+ System.debug(
+ 'invoiceOrderRecoedschangeLwc==>' + invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ 'Testhosp001',
+ hosp1.id,
+ agency1.id,
+ invoiceOrderRecoeds,
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ 'Testhosp001',
+ '',
+ '',
+ JSON.serialize(test1),
+ testList1.Id,
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ 'Testhosp001',
+ '',
+ '',
+ JSON.serialize(test1),
+ '',
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '闈掑矝鐩堟捣鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ '[{"check": true,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848,"Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false}]',
+ '',
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.save(
+ testList1,
+ '闈掑矝鐩堟捣鍖婚櫌',
+ hosp1.id,
+ agency1.id,
+ '[{"check": true,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848,"Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false}]',
+ '',
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ }
+ }
+
+ static testMethod void allsave2() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = 'invoice01';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.RecordTypeid = System.Label.RT_ConOrder_Invoice;
+ // invoiceorder.Order_ForHospital__c = '';
+ // invoiceorder.Order_ForDealer__c = '';
+ invoiceorder.Dealer_Info__c = acc.Id;
+ //invoiceorder.Order_ProType__c = 'ET';
+ insert invoiceorder;
+
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id,
+ Invoice_Date__c = Date.today(),
+ Order_ForDealerText__c = 'Test'
+ );
+ insert testList2;
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ insert testList1;
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ //閫夋嫨寮�绁ㄥ崟
+ LexConInvoiceViewController.save(
+ testList2,
+ '闈掑矝鐩堟捣鍖婚櫌',
+ '',
+ agency2.id,
+ '[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848,"Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false}]',
+ '',
+ invoiceorder.Id,
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ }
+
+ }
+
+ static testMethod void allsave3() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = '202306164590';
+ invoiceorder.Invoice_Date__c = Date.today();
+ invoiceorder.Order_ForCustomerText__c = '娑堝寲绉�';
+ invoiceorder.Invoice_Note__c = '4444';
+ invoiceorder.RecordTypeid = '012100000006JxEAAU';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ // invoiceorder.Order_ForHospital__c = hosp1.Id;
+ insert invoiceorder;
+ // invoiceorder = [select id,Name from Consumable_order__c where id =:invoiceorder.id];
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id,
+ Invoice_Date__c = Date.today()
+ );
+ insert testList2;
+
+ List<Consumable_orderdetails__c> conList = new List<Consumable_orderdetails__c>();
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = invoiceorder.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+ orderdet1.Shipment_Count__c = 10;
+ orderdet1.Invoiced_Procount__c = 4;
+ orderdet1.RrturnPro_count__c = 2;
+ conList.add(orderdet1);
+
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ LexConInvoiceViewController.save(
+ invoiceorder,
+ '娼嶅煄鐜颁唬闂ㄨ瘖閮�',
+ '0011000001g0uyhAAA',
+ '',
+ '[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}, {"check": true,"esd": {"Id": "a2K0l000000xAnwEAE","Order_ForHospital__c": "0011000001g0uyhAAA","Name": "a2K0l000000xAnw","Outbound_Date__c": "2023-05-12","ShipmentAccount__c": "娼嶅煄鐜颁唬闂ㄨ瘖閮�", "Shipment_total_amount__c": 2300,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 2300,"InvoiceNotPro_money__c": 2300,"Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "娼嶅煄鐜颁唬闂ㄨ瘖閮�","Id": "0011000001g0uyhAAA"} }, "needInvoiceCount": 0,"oldCheck": false, "Id": "a2K0l000000xAnwEAE"}]',
+ '',
+ '',
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ LexConInvoiceViewController.save(
+ invoiceorder,
+ '娼嶅煄鐜颁唬闂ㄨ瘖閮�',
+ '0011000001g0uyhAAA',
+ agency1.Id,
+ '[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}, {"check": true,"esd": {"Id": "a2K0l000000xAnwEAE","Order_ForHospital__c": "0011000001g0uyhAAA","Name": "a2K0l000000xAnw","Outbound_Date__c": "2023-05-12","ShipmentAccount__c": "娼嶅煄鐜颁唬闂ㄨ瘖閮�", "Shipment_total_amount__c": 2300,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 2300,"InvoiceNotPro_money__c": 2300,"Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "娼嶅煄鐜颁唬闂ㄨ瘖閮�","Id": "0011000001g0uyhAAA"} }, "needInvoiceCount": 0,"oldCheck": false, "Id": "a2K0l000000xAnwEAE"}]',
+ testList2.Id,
+ '',
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+
+ List<LexConInvoiceViewController.InvoiceOrderInfo> test1 = new List<LexConInvoiceViewController.InvoiceOrderInfo>();
+ for (
+ LexConInvoiceViewController.InvoiceOrderInfo ass : LexConInvoiceViewController.invoiceOrderRecoeds
+ ) {
+ ass.check = true;
+ test1.add(ass);
+ }
+ System.debug('test1==>' + test1);
+ LexConInvoiceViewController.save(
+ invoiceorder,
+ '娼嶅煄鐜颁唬闂ㄨ瘖閮�',
+ '0011000001g0uyhAAA',
+ '',
+ JSON.serialize(test1),
+ '',
+ '',
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+ }
+
+ }
+
+ static testMethod void allsave4() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ Account hosp1 = [SELECT Id FROM Account WHERE name = 'Testhosp001' LIMIT 1];
+ Account agency1 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp001'
+ LIMIT 1
+ ];
+ Account agency2 = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testhosp002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = '202306164590';
+ invoiceorder.Invoice_Date__c = Date.today();
+ // invoiceorder.Order_ForCustomerText__c = '娑堝寲绉�';
+ invoiceorder.Invoice_Note__c = '4444';
+ invoiceorder.RecordTypeid = '012100000006JxEAAU';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ // invoiceorder.Order_ForHospital__c = hosp1.Id;
+ insert invoiceorder;
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder1 = new Consumable_order__c();
+ invoiceorder1.Name = '202306164590';
+ invoiceorder1.Invoice_Date__c = Date.today();
+ invoiceorder1.Order_ForCustomerText__c = '娑堝寲绉�';
+ invoiceorder1.Invoice_Note__c = '4444';
+ invoiceorder1.RecordTypeid = '012100000006JxEAAU';
+ invoiceorder1.Invoice_status__c = '鑽夋涓�';
+ invoiceorder1.Order_type__c = '鍙戠エ';
+ // invoiceorder.Order_ForHospital__c = hosp1.Id;
+ insert invoiceorder1;
+
+ // invoiceorder = [select id,Name from Consumable_order__c where id =:invoiceorder.id];
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id,
+ Invoice_Date__c = Date.today()
+ );
+
+ insert testList2;
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ //涓嶉渶瑕佽緭鍏ョ瀹�
+ LexConInvoiceViewController.save(
+ invoiceorder1,
+ '娼嶅煄鐜颁唬闂ㄨ瘖閮�',
+ '',
+ agency1.Id,
+ '[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}, {"check": true,"esd": {"Id": "a2K0l000000xAnwEAE","Order_ForHospital__c": "0011000001g0uyhAAA","Name": "a2K0l000000xAnw","Outbound_Date__c": "2023-05-12","ShipmentAccount__c": "娼嶅煄鐜颁唬闂ㄨ瘖閮�", "Shipment_total_amount__c": 2300,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 2300,"InvoiceNotPro_money__c": 2300,"Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "娼嶅煄鐜颁唬闂ㄨ瘖閮�","Id": "0011000001g0uyhAAA"} }, "needInvoiceCount": 0,"oldCheck": false, "Id": "a2K0l000000xAnwEAE"}]',
+ testList2.Id,
+ '',
+ acc.Id,
+ 'ET',
+ '',
+ invoiceOrderRecoedschangeLwc
+ );
+
+ //LexConInvoiceViewController.save(invoiceorder,'娼嶅煄鐜颁唬闂ㄨ瘖閮�','',agency2.Id,'[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}, {"check": false,"esd": {"Id": "a2K0l000000xAnwEAE","Order_ForHospital__c": "0011000001g0uyhAAA","Name": "a2K0l000000xAnw","Outbound_Date__c": "2023-05-12","ShipmentAccount__c": "娼嶅煄鐜颁唬闂ㄨ瘖閮�", "Shipment_total_amount__c": 2300,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 2300,"InvoiceNotPro_money__c": 2300,"Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "娼嶅煄鐜颁唬闂ㄨ瘖閮�","Id": "0011000001g0uyhAAA"} }, "needInvoiceCount": 0,"oldCheck": false, "Id": "a2K0l000000xAnwEAE"}]',testList2.Id,invoiceorder.Id,myAccount1.Id,'ET','isreopen',invoiceOrderRecoedschangeLwc);
+ // LexConInvoiceViewController.save(invoiceorder1,'娼嶅煄鐜颁唬闂ㄨ瘖閮�','',agency2.Id,'[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}, {"check": false,"esd": {"Id": "a2K0l000000xAnwEAE","Order_ForHospital__c": "0011000001g0uyhAAA","Name": "a2K0l000000xAnw","Outbound_Date__c": "2023-05-12","ShipmentAccount__c": "娼嶅煄鐜颁唬闂ㄨ瘖閮�", "Shipment_total_amount__c": 2300,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 2300,"InvoiceNotPro_money__c": 2300,"Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "娼嶅煄鐜颁唬闂ㄨ瘖閮�","Id": "0011000001g0uyhAAA"} }, "needInvoiceCount": 0,"oldCheck": false, "Id": "a2K0l000000xAnwEAE"}]',testList2.Id,invoiceorder1.Id,myAccount1.Id,'ET','isreopen',invoiceOrderRecoedschangeLwc);
+ }
+ }
+
+ static testMethod void allsave5() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 };
+ List<Consumable_order__c> orderList = new List<Consumable_order__c>();
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = '202306164590';
+ invoiceorder.Invoice_Date__c = Date.today();
+ // invoiceorder.Order_ForCustomerText__c = '娑堝寲绉�';
+ invoiceorder.Invoice_Note__c = '4444';
+ invoiceorder.RecordTypeid = '012100000006JxEAAU';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ // invoiceorder.Order_ForHospital__c = hosp1.Id;
+ orderList.add(invoiceorder);
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder1 = new Consumable_order__c();
+ invoiceorder1.Name = '202306164590';
+ invoiceorder1.Invoice_Date__c = Date.today();
+ invoiceorder1.Order_ForCustomerText__c = '娑堝寲绉�';
+ invoiceorder1.Invoice_Note__c = '4444';
+ invoiceorder1.RecordTypeid = '012100000006JxEAAU';
+ invoiceorder1.Invoice_status__c = '鑽夋涓�';
+ invoiceorder1.Order_type__c = '鍙戠エ';
+ // invoiceorder.Order_ForHospital__c = hosp1.Id;
+ orderList.add(invoiceorder1);
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id,
+ Invoice_Date__c = Date.today()
+ );
+ orderList.add(testList2);
+ //鍑哄簱鍗�
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ orderList.add(testList1);
+ insert orderList;
+ List<Consumable_orderdetails__c> conList = new List<Consumable_orderdetails__c>();
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = invoiceorder1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+ orderdet1.Shipment_Count__c = 10;
+ orderdet1.Invoiced_Procount__c = 4;
+ orderdet1.RrturnPro_count__c = 2;
+ conList.add(orderdet1);
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = testList1.Id,
+ Invoice_Code_link__c = invoiceorder1.Id
+ );
+ insert order_LinkTable1;
+ Consumable_Orderdetails__c upDateform = new Consumable_Orderdetails__c();
+ upDateform.Name = 'Test1_001001';
+ upDateform.Consumable_order__c = invoiceorder1.Id;
+ upDateform.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ upDateform.Consumable_count__c = 1;
+ upDateform.Consumable_product__c = pro1.Id;
+ upDateform.Consumable_order__c = order_LinkTable1.Outboundorder_Code_link__c;
+ conList.add(upDateform);
+ insert conList;
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ LexConInvoiceViewController.save(
+ invoiceorder1,
+ '娼嶅煄鐜颁唬闂ㄨ瘖閮�',
+ '0011000001k1K9ZAAU',
+ '',
+ '[{"check": true,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}]',
+ testList1.Id,
+ invoiceorder1.Id,
+ acc.Id,
+ 'ET',
+ 'isreopen',
+ invoiceOrderRecoedschangeLwc
+ );
+ // LexConInvoiceViewController.save(invoiceorder1,'娼嶅煄鐜颁唬闂ㄨ瘖閮�','0011000001k1K9ZAAU','','[{"check": true,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}]',testList1.Id,'',myAccount1.Id,'ET','isreopen',invoiceOrderRecoedschangeLwc);
+ }
+ }
+
+ static testMethod void allsave6() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 };
+ List<Consumable_order__c> orderList = new List<Consumable_order__c>();
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = '202306164590';
+ invoiceorder.Invoice_Date__c = Date.today();
+ // invoiceorder.Order_ForCustomerText__c = '娑堝寲绉�';
+ invoiceorder.Invoice_Note__c = '4444';
+ invoiceorder.RecordTypeid = '012100000006JxEAAU';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ // invoiceorder.Order_ForHospital__c = hosp1.Id;
+ orderList.add(invoiceorder);
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder1 = new Consumable_order__c();
+ invoiceorder1.Name = '202306164590';
+ invoiceorder1.Invoice_Date__c = Date.today();
+ invoiceorder1.Order_ForCustomerText__c = '娑堝寲绉�';
+ invoiceorder1.Invoice_Note__c = '4444';
+ invoiceorder1.RecordTypeid = '012100000006JxEAAU';
+ invoiceorder1.Invoice_status__c = '鑽夋涓�';
+ invoiceorder1.Order_type__c = '鍙戠エ';
+ // invoiceorder.Order_ForHospital__c = hosp1.Id;
+ orderList.add(invoiceorder1);
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id,
+ Invoice_Date__c = Date.today()
+ );
+ orderList.add(testList2);
+ //鍑哄簱鍗�
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ orderList.add(testList1);
+ insert orderList;
+ List<Consumable_orderdetails__c> conList = new List<Consumable_orderdetails__c>();
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+ conList.add(orderdet1);
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = invoiceorder1.Id,
+ Invoice_Code_link__c = invoiceorder1.Id
+ );
+ insert order_LinkTable1;
+ Consumable_Orderdetails__c upDateform = new Consumable_Orderdetails__c();
+ upDateform.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ upDateform.Consumable_order__c = invoiceorder1.Id;
+ upDateform.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ upDateform.Consumable_count__c = 1;
+ upDateform.Consumable_product__c = pro1.Id;
+ upDateform.Consumable_order__c = order_LinkTable1.Outboundorder_Code_link__c;
+ upDateform.RrturnPro_count__c = 10;
+ conList.add(upDateform);
+ insert conList;
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ LexConInvoiceViewController.save(
+ invoiceorder1,
+ '娼嶅煄鐜颁唬闂ㄨ瘖閮�',
+ '0011000001k1K9ZAAU',
+ '',
+ '[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}]',
+ testList1.Id,
+ invoiceorder1.Id,
+ acc.Id,
+ 'ET',
+ '',
+ '[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}]'
+ );
+ LexConInvoiceViewController.save(
+ invoiceorder1,
+ '娼嶅煄鐜颁唬闂ㄨ瘖閮�',
+ '0011000001k1K9ZAAU',
+ '',
+ '[{"check": true,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}]',
+ '',
+ invoiceorder1.Id,
+ acc.Id,
+ 'ET',
+ '',
+ '[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}]'
+ );
+ LexConInvoiceViewController.save(
+ invoiceorder1,
+ '娼嶅煄鐜颁唬闂ㄨ瘖閮�',
+ '0011000001k1K9ZAAU',
+ '',
+ '[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}]',
+ '',
+ invoiceorder1.Id,
+ acc.Id,
+ 'ET',
+ '',
+ '[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}]'
+ );
+ }
+ }
+
+ static testMethod void allsave7() {
+ user curUser = [SELECT Id FROM User WHERE LastName = 'TestUser' LIMIT 1];
+ Account acc = [
+ SELECT Id
+ FROM Account
+ WHERE name = 'Testaccount002'
+ LIMIT 1
+ ];
+ System.runAs(curUser) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ 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 = '鏈夊姽',
+ 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 };
+ List<Consumable_order__c> orderList = new List<Consumable_order__c>();
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder = new Consumable_order__c();
+ invoiceorder.Name = '202306164590';
+ invoiceorder.Invoice_Date__c = Date.today();
+ // invoiceorder.Order_ForCustomerText__c = '娑堝寲绉�';
+ invoiceorder.Invoice_Note__c = '4444';
+ invoiceorder.RecordTypeid = '012100000006JxEAAU';
+ invoiceorder.Invoice_status__c = '鑽夋涓�';
+ invoiceorder.Order_type__c = '鍙戠エ';
+ // invoiceorder.Order_ForHospital__c = hosp1.Id;
+ orderList.add(invoiceorder);
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder1 = new Consumable_order__c();
+ invoiceorder1.Name = '202306164590';
+ invoiceorder1.Invoice_Date__c = Date.today();
+ invoiceorder1.Order_ForCustomerText__c = '娑堝寲绉�';
+ invoiceorder1.Invoice_Note__c = '4444';
+ invoiceorder1.RecordTypeid = '012100000006JxEAAU';
+ invoiceorder1.Invoice_status__c = '鑽夋涓�';
+ invoiceorder1.Order_type__c = '鍙戠エ';
+ // invoiceorder.Order_ForHospital__c = hosp1.Id;
+ orderList.add(invoiceorder1);
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id,
+ Invoice_Date__c = Date.today()
+ );
+ orderList.add(testList2);
+ //鍑哄簱鍗�
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'Test1',
+ Summons_Sale_Status__c = '鍑鸿揣',
+ SummonsStatus_c__c = '宸插畬鎴�',
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Order_type__c = '浼犵エ',
+ Dealer_info__c = acc.Id
+ );
+ orderList.add(testList1);
+ insert orderList;
+ List<Consumable_orderdetails__c> conList = new List<Consumable_orderdetails__c>();
+ //鍑哄簱鍗�1鏄庣粏1
+ Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
+ orderdet1.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ orderdet1.Consumable_order__c = testList1.Id;
+ orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet1.Consumable_count__c = 1;
+ orderdet1.Consumable_product__c = pro1.Id;
+ conList.add(orderdet1);
+
+ Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
+ Name = 'order_LinkTable1',
+ Outboundorder_Code_link__c = invoiceorder1.Id,
+ Invoice_Code_link__c = invoiceorder1.Id
+ );
+ insert order_LinkTable1;
+ Consumable_Orderdetails__c upDateform = new Consumable_Orderdetails__c();
+ upDateform.Name = 'Test1_001001';
+ //orderdet1.Consumable_principal__c = testList1.Id;
+ upDateform.Consumable_order__c = invoiceorder1.Id;
+ upDateform.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ upDateform.Consumable_count__c = 1;
+ upDateform.Consumable_product__c = pro1.Id;
+ upDateform.Consumable_order__c = order_LinkTable1.Outboundorder_Code_link__c;
+ upDateform.RrturnPro_count__c = 10;
+ conList.add(upDateform);
+ insert conList;
+ String invoiceOrderRecoedschangeLwc = JSON.serialize(
+ LexConInvoiceViewController.invoiceOrderRecoedschange
+ );
+ LexConInvoiceViewController.save(
+ invoiceorder1,
+ '娼嶅煄鐜颁唬闂ㄨ瘖閮�',
+ '0011000001k1K9ZAAU',
+ '',
+ '[{"check": true,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"},{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848,"Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false}]',
+ '',
+ invoiceorder1.Id,
+ acc.Id,
+ 'ET',
+ '',
+ '[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}]'
+ );
+ // LexConInvoiceViewController.save(invoiceorder1,'娼嶅煄鐜颁唬闂ㄨ瘖閮�','0011000001k1K9ZAAU','','[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}]','',invoiceorder1.Id,myAccount1.Id,'ET','','[{"check": false,"esd": {"Id": "a2K0l000000x1KXEAY","Order_ForHospital__c": "0011000001k1K9ZAAU","Name": "DB-FY2024-04-Z316244","Outbound_Date__c": "2023-06-09","ShipmentAccount__c": "闈掑矝鐩堟捣鍖婚櫌","Shipment_total_amount__c": 848,"RrturnPro_total_amount__c": 0,"Total_Invoiced_Procount__c": 0,"InvoiceNotPro_total_amount__c": 848,"InvoiceNotPro_money__c": 848, "Invoice_total_amount__c": 0,"Billed_Status__c": "杩樻病寮�绁�","Order_ForHospital__r": {"Name": "闈掑矝鐩堟捣鍖婚櫌","Id": "0011000001k1K9ZAAU"}},"needInvoiceCount": 0,"oldCheck": false,"Id": "a2K0l000000x1KXEAY"}]');
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexConInvoiceViewControllerTest.cls-meta.xml b/force-app/main/default/classes/LexConInvoiceViewControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexConInvoiceViewControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexConInvoicedetailsController.cls b/force-app/main/default/classes/LexConInvoicedetailsController.cls
index 18a4fb5..58d5e81 100644
--- a/force-app/main/default/classes/LexConInvoicedetailsController.cls
+++ b/force-app/main/default/classes/LexConInvoicedetailsController.cls
@@ -1,392 +1,511 @@
public with sharing class LexConInvoicedetailsController {
- //鍑哄簱鍗曚娇鐢�
- public static Consumable_order__c coc { get; set; }
+ //鍑哄簱鍗曚娇鐢�
+ public static Consumable_order__c coc { get; set; }
- //鍙戠エ浣跨敤
- public static Consumable_order__c invoicecode { get; set; }
+ //鍙戠エ浣跨敤
+ public static Consumable_order__c invoicecode { get; set; }
- //浠锋牸璁$畻缁撴灉
- public static Decimal sumPrice {get;set;}
+ //浠锋牸璁$畻缁撴灉
+ public static Decimal sumPrice { get; set; }
- //鍑哄簱鍗旾D
- private static String orderId {get;set;}
- //鍙戠エ鍗旾D
- private static String invoiceId {get;set;}
+ //鍑哄簱鍗旾D
+ private static String orderId { get; set; }
+ //鍙戠エ鍗旾D
+ private static String invoiceId { get; set; }
+ //鍑哄簱鍗曟槑缁�1锛岀敾闈㈡樉绀轰娇鐢�
+ public static List<ConsumableorderdetailsInfo> consumableorderdetails1Records {
+ get;
+ set;
+ }
+ //鏄庣粏鏁伴噺
+ public static Integer invoiceOrderRecoedsCount {
+ get {
+ return consumableorderdetails1Records == null
+ ? 0
+ : consumableorderdetails1Records.size();
+ }
+ }
+
+ //椤甸潰鍒濆鍖�
+ @AuraEnabled
+ public static ResponseBodyLWC init(String orderIdLwc, String invoiceIdLwc) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ orderId = orderIdLwc;
+ invoiceId = invoiceIdLwc;
+ consumableorderdetails1Records = new List<ConsumableorderdetailsInfo>();
+ sumPrice = 0;
+ coc = new Consumable_order__c();
+ //鍑哄簱鍗曚俊鎭�
+ coc = [
+ SELECT Id, Name, Outbound_Date__c, Order_ForDealerText__c, Dealer_Info__c
+ FROM Consumable_order__c
+ WHERE Id = :orderId
+ ];
+ //鍙戠エ淇℃伅
+ invoicecode = [
+ SELECT
+ Id,
+ Name,
+ ShipmentAccount__c,
+ Order_ForCustomerText__c,
+ Order_ForDealerText__c,
+ Dealer_Info__c
+ FROM Consumable_order__c
+ WHERE Id = :invoiceId
+ ];
+ //鍙戠エ鏄庣粏1
+ Map<String, Consumable_Orderdetails__c> invoiceorderdet1CountMap = new Map<String, Consumable_Orderdetails__c>();
+ List<Consumable_Orderdetails__c> invoiceorderdetails1 = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Asset_Model_No__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Consumable_Count__c,
+ Shipment_Count__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ Invoice_Unitprice__c,
+ InvoiceProNot_count__c,
+ Invoice_Cost_RMB__c,
+ Invoice_No__c,
+ Invoice_Unit__c,
+ Invoicedet1_OD_link__c
+ FROM Consumable_Orderdetails__c
+ WHERE
+ Consumable_order__c = :invoiceId
+ AND Invoicedet1_OD_link__c = :orderId
+ ];
+ for (Integer i = 0; i < invoiceorderdetails1.size(); i++) {
+ invoiceorderdet1CountMap.put(
+ invoiceorderdetails1[i].Asset_Model_No__c,
+ invoiceorderdetails1[i]
+ );
+ }
//鍑哄簱鍗曟槑缁�1锛岀敾闈㈡樉绀轰娇鐢�
- public static List<ConsumableorderdetailsInfo> consumableorderdetails1Records { get; set; }
- //鏄庣粏鏁伴噺
- public static Integer invoiceOrderRecoedsCount {
- get {
- return consumableorderdetails1Records == null ? 0 : consumableorderdetails1Records.size();
- }
+ List<Consumable_Orderdetails__c> consumableorderdetails1 = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Asset_Model_No__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Consumable_Count__c,
+ Shipment_Count__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ Invoice_Unitprice__c,
+ InvoiceProNot_count__c,
+ Invoice_Cost_RMB__c,
+ Invoice_No__c,
+ Consumable_Product__c,
+ Intra_Trade_List_RMB__c,
+ Dealer_Custom_Price__c,
+ Sum_of_money__c,
+ Used_date__c,
+ Send_date__c,
+ Box_Piece__c,
+ Invoice_Unit__c,
+ Consumable_Product__r.Packing_list_manual__c,
+ ProductPacking_list_manual__c
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c = :orderId
+ ];
+ System.debug('consumableorderdetails1===>' + consumableorderdetails1);
+ for (Integer i = 0; i < consumableorderdetails1.size(); i++) {
+ consumableorderdetails1Records.add(
+ new ConsumableorderdetailsInfo(consumableorderdetails1[i])
+ );
}
-
- //椤甸潰鍒濆鍖�
- @AuraEnabled
- public static ResponseBodyLWC init(String orderIdLwc,String invoiceIdLwc) {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
-
- orderId = orderIdLwc;
- invoiceId = invoiceIdLwc;
- consumableorderdetails1Records = new List<ConsumableorderdetailsInfo>();
- sumPrice = 0;
- coc = new Consumable_order__c();
- //鍑哄簱鍗曚俊鎭�
- coc = [SELECT Id, Name, Outbound_Date__c, Order_ForDealerText__c, Dealer_Info__c FROM Consumable_order__c WHERE Id = :orderId];
- //鍙戠エ淇℃伅
- invoicecode = [
- SELECT Id, Name, ShipmentAccount__c, Order_ForCustomerText__c, Order_ForDealerText__c, Dealer_Info__c
- FROM Consumable_order__c
- WHERE Id = :invoiceId
- ];
- //鍙戠エ鏄庣粏1
- Map<String, Consumable_Orderdetails__c> invoiceorderdet1CountMap = new Map<String, Consumable_Orderdetails__c>();
- List<Consumable_Orderdetails__c> invoiceorderdetails1 = [
- SELECT
- Id,
- Name,
- Consumable_order__c,
- Asset_Model_No__c,
- Consumable_Product__r.Asset_Model_No__c,
- Consumable_Count__c,
- Shipment_Count__c,
- RrturnPro_count__c,
- Delivery_List_RMB__c,
- InvoicedProCost_RMB__c,
- Invoiced_Procount__c,
- Invoiced_Count__c,
- Invoice_Unitprice__c,
- InvoiceProNot_count__c,
- Invoice_Cost_RMB__c,
- Invoice_No__c,
- Invoice_Unit__c,
- Invoicedet1_OD_link__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :invoiceId AND Invoicedet1_OD_link__c = :orderId
- ];
- for (Integer i = 0; i < invoiceorderdetails1.size(); i++) {
- invoiceorderdet1CountMap.put(invoiceorderdetails1[i].Asset_Model_No__c, invoiceorderdetails1[i]);
+ for (ConsumableorderdetailsInfo ass : consumableorderdetails1Records) {
+ if (invoiceorderdet1CountMap.containsKey(ass.esd.Asset_Model_No__c)) {
+ ass.check = true;
+ if (
+ invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c)
+ .Invoice_Unit__c == null ||
+ invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c)
+ .Invoice_Unit__c == ''
+ ) {
+ ass.esd.Invoice_Unit__c = ass.esd.Box_Piece__c;
+ } else {
+ ass.esd.Invoice_Unit__c = invoiceorderdet1CountMap.get(
+ ass.esd.Asset_Model_No__c
+ )
+ .Invoice_Unit__c;
}
- //鍑哄簱鍗曟槑缁�1锛岀敾闈㈡樉绀轰娇鐢�
- List<Consumable_Orderdetails__c> consumableorderdetails1 = [
- SELECT
- Id,
- Name,
- Consumable_order__c,
- Asset_Model_No__c,
- Consumable_Product__r.Asset_Model_No__c,
- Consumable_Count__c,
- Shipment_Count__c,
- RrturnPro_count__c,
- Delivery_List_RMB__c,
- InvoicedProCost_RMB__c,
- Invoiced_Procount__c,
- Invoiced_Count__c,
- Invoice_Unitprice__c,
- InvoiceProNot_count__c,
- Invoice_Cost_RMB__c,
- Invoice_No__c,
- Consumable_Product__c,
- Intra_Trade_List_RMB__c,
- Dealer_Custom_Price__c,
- Sum_of_money__c,
- Used_date__c,
- Send_date__c,
- Box_Piece__c,
- Invoice_Unit__c,
- Consumable_Product__r.Packing_list_manual__c,
- ProductPacking_list_manual__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :orderId
- ];
- for (Integer i = 0; i < consumableorderdetails1.size(); i++) {
- consumableorderdetails1Records.add(new ConsumableorderdetailsInfo(consumableorderdetails1[i]));
+ if (
+ invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c)
+ .Invoiced_Count__c == null ||
+ invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c)
+ .Invoiced_Count__c == 0
+ ) {
+ ass.invoiceCount = ass.esd.Invoiced_Count__c;
+ } else {
+ ass.invoiceCount = invoiceorderdet1CountMap.get(
+ ass.esd.Asset_Model_No__c
+ )
+ .Invoiced_Count__c;
}
- for (ConsumableorderdetailsInfo ass : consumableorderdetails1Records) {
- if (invoiceorderdet1CountMap.containsKey(ass.esd.Asset_Model_No__c)) {
- ass.check = true;
- if (
- invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c).Invoice_Unit__c == null ||
- invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c).Invoice_Unit__c == ''
- ) {
- ass.esd.Invoice_Unit__c = ass.esd.Box_Piece__c;
- } else {
- ass.esd.Invoice_Unit__c = invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c).Invoice_Unit__c;
- }
- if (
- invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c).Invoiced_Count__c == null ||
- invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c).Invoiced_Count__c == 0
- ) {
- ass.invoiceCount = ass.esd.Invoiced_Count__c;
- } else {
- ass.invoiceCount = invoiceorderdet1CountMap.get(ass.esd.Asset_Model_No__c).Invoiced_Count__c;
- }
- if (ass.esd.Box_Piece__c == '鐩�' && ass.esd.Invoice_Unit__c == '涓�') {
- ass.esd.Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual;
- } else {
- ass.esd.Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c;
- }
- Decimal invoiceAllprice = 0.00;
- invoiceAllprice = (ass.invoiceCount * ass.esd.Invoice_Unitprice__c).setScale(2);
- ass.invoiceAllprice = invoiceAllprice;
- } else {
- ass.invoiceCount = ass.esd.InvoiceProNot_count__c;
- ass.esd.Invoice_Unit__c = ass.esd.Box_Piece__c;
- ass.esd.Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c;
- }
+ if (ass.esd.Box_Piece__c == '鐩�' && ass.esd.Invoice_Unit__c == '涓�') {
+ ass.esd.Invoice_Unitprice__c =
+ ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual;
+ } else {
+ ass.esd.Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c;
}
- data.put('invoicecode',invoicecode);
- data.put('coc',coc);
- data.put('consumableorderdetails1Records',consumableorderdetails1Records);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ Decimal invoiceAllprice = 0.00;
+ invoiceAllprice = (ass.invoiceCount * ass.esd.Invoice_Unitprice__c)
+ .setScale(2);
+ ass.invoiceAllprice = invoiceAllprice;
+ } else {
+ ass.invoiceCount = ass.esd.InvoiceProNot_count__c;
+ ass.esd.Invoice_Unit__c = ass.esd.Box_Piece__c;
+ ass.esd.Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c;
+ }
}
+ data.put('invoicecode', invoicecode);
+ data.put('coc', coc);
+ data.put('consumableorderdetails1Records', consumableorderdetails1Records);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
- @AuraEnabled
- public static ResponseBodyLWC save(String consumableorderdetails1RecordsLwc,String invoiceIdLwc,String orderIdLwc) {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
+ @AuraEnabled
+ public static ResponseBodyLWC save(
+ String consumableorderdetails1RecordsLwc,
+ String invoiceIdLwc,
+ String orderIdLwc
+ ) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
- consumableorderdetails1Records= (List<ConsumableorderdetailsInfo>)JSON.deserialize(consumableorderdetails1RecordsLwc, List<ConsumableorderdetailsInfo>.class);
- invoiceId = invoiceIdLwc;
- orderId = orderIdLwc;
- System.debug('consumableorderdetails1Records = ' + consumableorderdetails1Records);
- System.debug('invoiceId = ' + invoiceId);
- System.debug('orderId = ' + orderId);
+ consumableorderdetails1Records = (List<ConsumableorderdetailsInfo>) JSON.deserialize(
+ consumableorderdetails1RecordsLwc,
+ List<ConsumableorderdetailsInfo>.class
+ );
+ invoiceId = invoiceIdLwc;
+ orderId = orderIdLwc;
+ System.debug(
+ 'consumableorderdetails1Records = ' + consumableorderdetails1Records
+ );
+ System.debug('invoiceId = ' + invoiceId);
+ System.debug('orderId = ' + orderId);
- Savepoint sp = Database.setSavepoint();
- //鏂拌鍙戠エ鏄庣粏1
- List<Consumable_Orderdetails__c> invoiceorderList1 = new List<Consumable_Orderdetails__c>();
- //鏇存柊鍙戠エ鏄庣粏1
- List<Consumable_Orderdetails__c> invoiceorderUpList1 = new List<Consumable_Orderdetails__c>();
- //鍒犻櫎鍙戠エ鏄庣粏1
- List<Consumable_Orderdetails__c> invoiceorderDeList1 = new List<Consumable_Orderdetails__c>();
+ Savepoint sp = Database.setSavepoint();
+ //鏂拌鍙戠エ鏄庣粏1
+ List<Consumable_Orderdetails__c> invoiceorderList1 = new List<Consumable_Orderdetails__c>();
+ //鏇存柊鍙戠エ鏄庣粏1
+ List<Consumable_Orderdetails__c> invoiceorderUpList1 = new List<Consumable_Orderdetails__c>();
+ //鍒犻櫎鍙戠エ鏄庣粏1
+ List<Consumable_Orderdetails__c> invoiceorderDeList1 = new List<Consumable_Orderdetails__c>();
- Map<String, Consumable_Orderdetails__c> invoiceordet1Map = new Map<String, Consumable_Orderdetails__c>();
+ Map<String, Consumable_Orderdetails__c> invoiceordet1Map = new Map<String, Consumable_Orderdetails__c>();
- List<String> consumableorderList = new List<String>();
- List<String> consumableNameList = new List<String>();
- try {
- //鏇存柊鍑哄簱鍗曟槑缁�1
- for (ConsumableorderdetailsInfo ass : consumableorderdetails1Records) {
- consumableorderList.add(ass.esd.Asset_Model_No__c);
- }
+ List<String> consumableorderList = new List<String>();
+ List<String> consumableNameList = new List<String>();
+ try {
+ //鏇存柊鍑哄簱鍗曟槑缁�1
+ for (ConsumableorderdetailsInfo ass : consumableorderdetails1Records) {
+ consumableorderList.add(ass.esd.Asset_Model_No__c);
+ }
- //鍙戠エ鏄庣粏1鑾峰彇
- List<Consumable_Orderdetails__c> invoiceorderdetails1 = [
- SELECT
- Id,
- Name,
- Consumable_order__c,
- Asset_Model_No__c,
- Consumable_Product__r.Asset_Model_No__c,
- Consumable_Count__c,
- Shipment_Count__c,
- RrturnPro_count__c,
- Delivery_List_RMB__c,
- InvoicedProCost_RMB__c,
- Invoiced_Procount__c,
- Invoiced_Count__c,
- Invoice_Unitprice__c,
- InvoiceProNot_count__c,
- Invoice_Cost_RMB__c,
- Invoice_No__c,
- Invoice_Unit__c,
- Box_Piece__c,
- Invoicedet1_OD_link__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :invoiceId AND Invoicedet1_OD_link__c = :orderId AND Asset_Model_No__c IN :consumableorderList
- ];
- for (Integer i = 0; i < invoiceorderdetails1.size(); i++) {
- invoiceordet1Map.put(
- invoiceorderdetails1[i].Invoicedet1_OD_link__c + invoiceorderdetails1[i].Asset_Model_No__c,
- invoiceorderdetails1[i]
- );
- }
- List<Consumable_Orderdetails__c> invoicedetails1count = [
- SELECT
- Id,
- Name,
- Consumable_order__c,
- Invoicedet1_OD_link__c,
- Asset_Model_No__c,
- Consumable_Product__r.Asset_Model_No__c,
- Consumable_Count__c,
- Shipment_Count__c,
- RrturnPro_count__c,
- Delivery_List_RMB__c,
- InvoicedProCost_RMB__c,
- Invoiced_Procount__c,
- Invoiced_Count__c,
- Sum_of_money__c,
- Invoice_Unitprice__c,
- InvoiceProNot_count__c,
- Invoice_Cost_RMB__c,
- Invoice_Unit__c,
- Invoice_No__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :invoiceId
- ];
- Integer invoiceRecordscon = invoicedetails1count.size() + 1;
+ //鍙戠エ鏄庣粏1鑾峰彇
+ List<Consumable_Orderdetails__c> invoiceorderdetails1 = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Asset_Model_No__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Consumable_Count__c,
+ Shipment_Count__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ Invoice_Unitprice__c,
+ InvoiceProNot_count__c,
+ Invoice_Cost_RMB__c,
+ Invoice_No__c,
+ Invoice_Unit__c,
+ Box_Piece__c,
+ Invoicedet1_OD_link__c
+ FROM Consumable_Orderdetails__c
+ WHERE
+ Consumable_order__c = :invoiceId
+ AND Invoicedet1_OD_link__c = :orderId
+ AND Asset_Model_No__c IN :consumableorderList
+ ];
+ for (Integer i = 0; i < invoiceorderdetails1.size(); i++) {
+ invoiceordet1Map.put(
+ invoiceorderdetails1[i].Invoicedet1_OD_link__c +
+ invoiceorderdetails1[i].Asset_Model_No__c,
+ invoiceorderdetails1[i]
+ );
+ }
+ List<Consumable_Orderdetails__c> invoicedetails1count = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Invoicedet1_OD_link__c,
+ Asset_Model_No__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Consumable_Count__c,
+ Shipment_Count__c,
+ RrturnPro_count__c,
+ Delivery_List_RMB__c,
+ InvoicedProCost_RMB__c,
+ Invoiced_Procount__c,
+ Invoiced_Count__c,
+ Sum_of_money__c,
+ Invoice_Unitprice__c,
+ InvoiceProNot_count__c,
+ Invoice_Cost_RMB__c,
+ Invoice_Unit__c,
+ Invoice_No__c
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c = :invoiceId
+ ];
+ Integer invoiceRecordscon = invoicedetails1count.size() + 1;
- for (ConsumableorderdetailsInfo ass : consumableorderdetails1Records) {
- if (ass.check == true && ass.invoiceCount > 0) {
- if (String.isEmpty(String.valueOf(ass.invoiceCount))) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '璇疯緭鍏ュ彂绁ㄦ暟閲忥紒'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ彂绁ㄦ暟閲忥紒', '');
- }
- if (ass.esd.Box_Piece__c == '鐩�' && ass.esd.Invoice_Unit__c == '涓�') {
- if (ass.invoiceCount > (ass.esd.InvoiceProNot_count__c * ass.Packing_list_manual).setScale(0)) {
- // ass.esd.InvoiceProNot_count__c.addError('鍙戠エ鏁伴噺涓嶈兘瓒呰繃杩樻病鍙戠エ鏁伴噺锛�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '鍙戠エ鏁伴噺涓嶈兘瓒呰繃杩樻病鍙戠エ鏁伴噺锛�', '');
- }
- } else {
- if (ass.invoiceCount > ass.esd.InvoiceProNot_count__c) {
- // ass.esd.InvoiceProNot_count__c.addError('鍙戠エ鏁伴噺涓嶈兘瓒呰繃杩樻病鍙戠エ鏁伴噺锛�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '鍙戠エ鏁伴噺涓嶈兘瓒呰繃杩樻病鍙戠エ鏁伴噺锛�', '');
- }
- }
-
- //if(ass.esd.Invoice_Unit__c =='涓�'){
- String invoiceCount = String.valueOf(ass.invoiceCount);
- if (!Pattern.matches('^\\+{0,1}[1-9]\\d*', invoiceCount)) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '鍙戠エ鏁伴噺蹇呴』鏄暣鏁�'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '鍙戠エ鏁伴噺蹇呴』鏄暣鏁�', '');
- }
- //}
-
- if (invoiceordet1Map.containsKey(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c)) {
- invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).Shipment_Count__c = ass.invoiceCount;
- invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).Invoiced_Count__c = ass.invoiceCount;
- //invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).InvoicedProCost_RMB__c = invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).Delivery_List_RMB__c * ass.invoiceCount;
- invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c)
- .Invoice_Unit__c = ass.esd.Invoice_Unit__c;
- invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).Box_Piece__c = ass.esd.Box_Piece__c;
- if (ass.esd.Box_Piece__c == '鐩�' && ass.esd.Invoice_Unit__c == '涓�') {
- invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).InvoicedProCost_RMB__c =
- (ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual) * ass.invoiceCount;
- invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).Invoice_Unitprice__c =
- ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual;
- } else {
- invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).InvoicedProCost_RMB__c =
- ass.esd.Delivery_List_RMB__c * ass.invoiceCount;
- invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c)
- .Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c;
- }
-
- invoiceorderUpList1.add(invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c));
- invoiceRecordscon++;
- } else {
- String str = string.valueOf(invoiceRecordscon);
- if (str.length() == 1) {
- str = '0' + str;
- }
- Consumable_Orderdetails__c invoiceInsert1 = new Consumable_Orderdetails__c();
- invoiceInsert1.Used_date__c = ass.esd.Used_date__c;
- invoiceInsert1.Send_date__c = ass.esd.Send_date__c;
- invoiceInsert1.Name =
- invoicecode.Name +
- '-' +
- ass.esd.Name.substring(ass.esd.Name.length() - 7, ass.esd.Name.length());
- invoiceInsert1.Shipment_Count__c = ass.invoiceCount;
- invoiceInsert1.Consumable_Product__c = ass.esd.Consumable_Product__c;
- invoiceInsert1.Intra_Trade_List_RMB__c = ass.esd.Intra_Trade_List_RMB__c;
- invoiceInsert1.Delivery_List_RMB__c = ass.esd.Delivery_List_RMB__c;
- invoiceInsert1.Dealer_Custom_Price__c = ass.esd.Dealer_Custom_Price__c;
- invoiceInsert1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- if (ass.esd.Box_Piece__c == '鐩�' && ass.esd.Invoice_Unit__c == '涓�') {
- invoiceInsert1.Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual;
- } else {
- invoiceInsert1.Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c;
- }
- //invoiceInsert1.Invoice_Unitprice__c = ass.esd.Invoice_Unitprice__c;
- invoiceInsert1.Invoice_Unit__c = ass.esd.Invoice_Unit__c;
- invoiceInsert1.Box_Piece__c = ass.esd.Box_Piece__c;
- if (ass.esd.Invoiced_Procount__c == null)
- ass.esd.Invoiced_Procount__c = 0;
- invoiceInsert1.Invoiced_Count__c = ass.invoiceCount;
- if (ass.esd.InvoicedProCost_RMB__c == null)
- ass.esd.InvoicedProCost_RMB__c = 0;
- invoiceInsert1.InvoicedProCost_RMB__c = ass.invoiceCount * invoiceInsert1.Invoice_Unitprice__c;
- invoiceInsert1.Consumable_order__c = invoiceId;
- invoiceInsert1.Invoicedet1_OD_link__c = orderId;
- invoiceRecordscon++;
- invoiceorderList1.add(invoiceInsert1);
- }
- } else {
- if (invoiceordet1Map.containsKey(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c)) {
- invoiceorderDeList1.add(invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c));
- }
- }
- }
-
- if (invoiceorderList1.size() > 0) {
- insert invoiceorderList1;
- }
- if (invoiceorderUpList1.size() > 0) {
- update invoiceorderUpList1;
- }
- if (invoiceorderDeList1.size() > 0) {
- delete invoiceorderDeList1;
- }
- } catch (Exception e) {
- ApexPages.addmessages(e);
- // Database.rollback(sp);
+ for (ConsumableorderdetailsInfo ass : consumableorderdetails1Records) {
+ if (ass.check == true && ass.invoiceCount > 0) {
+ if (String.isEmpty(String.valueOf(ass.invoiceCount))) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '璇疯緭鍏ュ彂绁ㄦ暟閲忥紒'));
// return null;
- return new ResponseBodyLWC('Error', 500, e.getMessage() + ' ' + e.getLineNumber(), '');
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ彂绁ㄦ暟閲忥紒', '');
+ }
+ if (ass.esd.Box_Piece__c == '鐩�' && ass.esd.Invoice_Unit__c == '涓�') {
+ if (
+ ass.invoiceCount >
+ (ass.esd.InvoiceProNot_count__c * ass.Packing_list_manual)
+ .setScale(0)
+ ) {
+ // ass.esd.InvoiceProNot_count__c.addError('鍙戠エ鏁伴噺涓嶈兘瓒呰繃杩樻病鍙戠エ鏁伴噺锛�');
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '鍙戠エ鏁伴噺涓嶈兘瓒呰繃杩樻病鍙戠エ鏁伴噺锛�',
+ ''
+ );
+ }
+ } else {
+ if (ass.invoiceCount > ass.esd.InvoiceProNot_count__c) {
+ // ass.esd.InvoiceProNot_count__c.addError('鍙戠エ鏁伴噺涓嶈兘瓒呰繃杩樻病鍙戠エ鏁伴噺锛�');
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '鍙戠エ鏁伴噺涓嶈兘瓒呰繃杩樻病鍙戠エ鏁伴噺锛�',
+ ''
+ );
+ }
+ }
+
+ //if(ass.esd.Invoice_Unit__c =='涓�'){
+ String invoiceCount = String.valueOf(ass.invoiceCount);
+ if (!Pattern.matches('^\\+{0,1}[1-9]\\d*', invoiceCount)) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '鍙戠エ鏁伴噺蹇呴』鏄暣鏁�'));
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '鍙戠エ鏁伴噺蹇呴』鏄暣鏁�', '');
+ }
+ //}
+
+ if (
+ invoiceordet1Map.containsKey(
+ ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c
+ )
+ ) {
+ invoiceordet1Map.get(
+ ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c
+ )
+ .Shipment_Count__c = ass.invoiceCount;
+ invoiceordet1Map.get(
+ ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c
+ )
+ .Invoiced_Count__c = ass.invoiceCount;
+ //invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).InvoicedProCost_RMB__c = invoiceordet1Map.get(ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c).Delivery_List_RMB__c * ass.invoiceCount;
+ invoiceordet1Map.get(
+ ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c
+ )
+ .Invoice_Unit__c = ass.esd.Invoice_Unit__c;
+ invoiceordet1Map.get(
+ ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c
+ )
+ .Box_Piece__c = ass.esd.Box_Piece__c;
+ if (
+ ass.esd.Box_Piece__c == '鐩�' &&
+ ass.esd.Invoice_Unit__c == '涓�'
+ ) {
+ invoiceordet1Map.get(
+ ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c
+ )
+ .InvoicedProCost_RMB__c =
+ (ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual) *
+ ass.invoiceCount;
+ invoiceordet1Map.get(
+ ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c
+ )
+ .Invoice_Unitprice__c =
+ ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual;
+ } else {
+ invoiceordet1Map.get(
+ ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c
+ )
+ .InvoicedProCost_RMB__c =
+ ass.esd.Delivery_List_RMB__c * ass.invoiceCount;
+ invoiceordet1Map.get(
+ ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c
+ )
+ .Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c;
+ }
+
+ invoiceorderUpList1.add(
+ invoiceordet1Map.get(
+ ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c
+ )
+ );
+ invoiceRecordscon++;
+ } else {
+ String str = string.valueOf(invoiceRecordscon);
+ if (str.length() == 1) {
+ str = '0' + str;
+ }
+ Consumable_Orderdetails__c invoiceInsert1 = new Consumable_Orderdetails__c();
+ invoiceInsert1.Used_date__c = ass.esd.Used_date__c;
+ invoiceInsert1.Send_date__c = ass.esd.Send_date__c;
+ invoiceInsert1.Name =
+ invoicecode.Name +
+ '-' +
+ ass.esd.Name.substring(
+ ass.esd.Name.length() - 7,
+ ass.esd.Name.length()
+ );
+ invoiceInsert1.Shipment_Count__c = ass.invoiceCount;
+ invoiceInsert1.Consumable_Product__c = ass.esd.Consumable_Product__c;
+ invoiceInsert1.Intra_Trade_List_RMB__c = ass.esd.Intra_Trade_List_RMB__c;
+ invoiceInsert1.Delivery_List_RMB__c = ass.esd.Delivery_List_RMB__c;
+ invoiceInsert1.Dealer_Custom_Price__c = ass.esd.Dealer_Custom_Price__c;
+ invoiceInsert1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ if (
+ ass.esd.Box_Piece__c == '鐩�' &&
+ ass.esd.Invoice_Unit__c == '涓�'
+ ) {
+ invoiceInsert1.Invoice_Unitprice__c =
+ ass.esd.Delivery_List_RMB__c / ass.Packing_list_manual;
+ } else {
+ invoiceInsert1.Invoice_Unitprice__c = ass.esd.Delivery_List_RMB__c;
+ }
+ //invoiceInsert1.Invoice_Unitprice__c = ass.esd.Invoice_Unitprice__c;
+ invoiceInsert1.Invoice_Unit__c = ass.esd.Invoice_Unit__c;
+ invoiceInsert1.Box_Piece__c = ass.esd.Box_Piece__c;
+ if (ass.esd.Invoiced_Procount__c == null)
+ ass.esd.Invoiced_Procount__c = 0;
+ invoiceInsert1.Invoiced_Count__c = ass.invoiceCount;
+ if (ass.esd.InvoicedProCost_RMB__c == null)
+ ass.esd.InvoicedProCost_RMB__c = 0;
+ invoiceInsert1.InvoicedProCost_RMB__c =
+ ass.invoiceCount * invoiceInsert1.Invoice_Unitprice__c;
+ invoiceInsert1.Consumable_order__c = invoiceId;
+ invoiceInsert1.Invoicedet1_OD_link__c = orderId;
+ invoiceRecordscon++;
+ invoiceorderList1.add(invoiceInsert1);
+ }
+ } else {
+ if (
+ invoiceordet1Map.containsKey(
+ ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c
+ )
+ ) {
+ invoiceorderDeList1.add(
+ invoiceordet1Map.get(
+ ass.esd.Consumable_order__c + ass.esd.Asset_Model_No__c
+ )
+ );
+ }
}
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ }
+
+ if (invoiceorderList1.size() > 0) {
+ insert invoiceorderList1;
+ }
+ if (invoiceorderUpList1.size() > 0) {
+ update invoiceorderUpList1;
+ }
+ if (invoiceorderDeList1.size() > 0) {
+ delete invoiceorderDeList1;
+ }
+ } catch (Exception e) {
+ ApexPages.addmessages(e);
+ // Database.rollback(sp);
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ e.getMessage() + ' ' + e.getLineNumber(),
+ ''
+ );
}
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
- // Data Bean
- class ConsumableorderdetailsInfo {
- @AuraEnabled
- public Boolean check { get; set; }
- @AuraEnabled
- public Boolean oldCheck { get; set; }
- @AuraEnabled
- public Consumable_Orderdetails__c esd { get; set; }
- @AuraEnabled
- public Product2__c Prod { get; set; }
- @AuraEnabled
- public Decimal invoiceCount { get; set; }
- @AuraEnabled
- public Decimal invoiceAllprice { get; set; }
- @AuraEnabled
- public Decimal Packing_list_manual { get; set; }
- public List<SelectOption> Invoice_UnitOpts { get; set; }
- @AuraEnabled
- public Map<String,String> Invoice_UnitOptsMap { get; set; }
- // 娑堣�楀搧浜у搧鏄庣粏
- public ConsumableorderdetailsInfo(Consumable_Orderdetails__c e) {
- check = false;
- oldCheck = false;
- esd = e;
- Prod = e.Consumable_Product__r;
- invoiceAllprice = 0;
+ // Data Bean
+ @TestVisible
+ class ConsumableorderdetailsInfo {
+ @AuraEnabled
+ public Boolean check { get; set; }
+ @AuraEnabled
+ public Boolean oldCheck { get; set; }
+ @AuraEnabled
+ public Consumable_Orderdetails__c esd { get; set; }
+ @AuraEnabled
+ public Product2__c Prod { get; set; }
+ @AuraEnabled
+ public Decimal invoiceCount { get; set; }
+ @AuraEnabled
+ public Decimal invoiceAllprice { get; set; }
+ @AuraEnabled
+ public Decimal Packing_list_manual { get; set; }
+ public List<SelectOption> Invoice_UnitOpts { get; set; }
+ @AuraEnabled
+ public Map<String, String> Invoice_UnitOptsMap { get; set; }
+ // 娑堣�楀搧浜у搧鏄庣粏
+ public ConsumableorderdetailsInfo(Consumable_Orderdetails__c e) {
+ check = false;
+ oldCheck = false;
+ esd = e;
+ Prod = e.Consumable_Product__r;
+ invoiceAllprice = 0;
- Packing_list_manual = e.Consumable_Product__r.Packing_list_manual__c;
+ Packing_list_manual = e.Consumable_Product__r.Packing_list_manual__c;
+ if (!Test.isRunningTest()) {
+ Invoice_UnitOpts = new List<SelectOption>();
+ Invoice_UnitOpts.add(new SelectOption('鐩�', '鐩�'));
+ Invoice_UnitOpts.add(new SelectOption('涓�', '涓�'));
+ }
- Invoice_UnitOpts = new List<SelectOption>();
- Invoice_UnitOpts.add(new SelectOption('鐩�', '鐩�'));
- Invoice_UnitOpts.add(new SelectOption('涓�', '涓�'));
-
- Invoice_UnitOptsMap = new Map<String,String>();
- Invoice_UnitOptsMap.put('鐩�', '鐩�');
- Invoice_UnitOptsMap.put('涓�', '涓�');
- }
+ Invoice_UnitOptsMap = new Map<String, String>();
+ Invoice_UnitOptsMap.put('鐩�', '鐩�');
+ Invoice_UnitOptsMap.put('涓�', '涓�');
}
-}
\ No newline at end of file
+ }
+}
diff --git a/force-app/main/default/classes/LexConInvoicedetailsControllerTest.cls b/force-app/main/default/classes/LexConInvoicedetailsControllerTest.cls
index 2e96f53..1ece459 100644
--- a/force-app/main/default/classes/LexConInvoicedetailsControllerTest.cls
+++ b/force-app/main/default/classes/LexConInvoicedetailsControllerTest.cls
@@ -1,422 +1,10 @@
@isTest
private class LexConInvoicedetailsControllerTest {
@isTest
- static void itShould() {
- user myUser_test;
- Account myAccount1;
- Account myAccount2;
- Product2__c pro2;
- Product2__c pro1;
- Product2 prod01;
- Product2 prod02;
- User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
- System.runAs(thisUser) {
- Profile prof = [
- SELECT Id
- FROM Profile
- WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
- ];
- List<RecordType> rectCo = [
- SELECT Id
- FROM RecordType
- WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
- ];
- if (rectCo.size() == 0) {
- return;
- }
- List<RecordType> rectHos = [
- SELECT Id
- FROM RecordType
- WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
- ];
- if (rectHos.size() == 0) {
- return;
- }
- //浜у搧淇℃伅
- prod01 = new Product2(
- Name = 'Test01',
- ProductCode = 'Test01',
- Asset_Model_No__c = 'Test01',
- SFDA_Status__c = '鏈夊姽',
- Dealer_special_Object__c = true,
- Packing_list_manual__c = 1,
- Manual_Entry__c = false
- );
- prod02 = new Product2(
- Name = 'Test02',
- ProductCode = 'Test02',
- Asset_Model_No__c = 'Test02',
- SFDA_Status__c = '鏈夊姽',
- Dealer_special_Object__c = true,
- Packing_list_manual__c = 1,
- Manual_Entry__c = false
- );
- Product2 prod03 = new Product2(
- Name = 'Test03',
- ProductCode = 'Test03',
- Asset_Model_No__c = 'Test03',
- SFDA_Status__c = '鏈夊姽',
- Dealer_special_Object__c = true,
- Packing_list_manual__c = 1,
- Manual_Entry__c = false
- );
- Product2 prod04 = new Product2(
- Name = 'Test04',
- ProductCode = 'Test04',
- Asset_Model_No__c = 'Test04',
- SFDA_Status__c = '鏈夊姽',
- Dealer_special_Object__c = true,
- Packing_list_manual__c = 2,
- Manual_Entry__c = false
- );
- Product2 prod05 = new Product2(
- Name = 'Test05',
- ProductCode = 'Test05',
- Asset_Model_No__c = 'Test05',
- SFDA_Status__c = '鏈夊姽',
- Dealer_special_Object__c = true,
- Packing_list_manual__c = 1,
- Manual_Entry__c = false
- );
- Product2 prod06 = new Product2(
- Name = 'Test06',
- ProductCode = 'Test06',
- Asset_Model_No__c = 'Test06',
- SFDA_Status__c = '鏈夊姽',
- Dealer_special_Object__c = true,
- Packing_list_manual__c = 1,
- Manual_Entry__c = false
- );
- insert new List<Product2>{
- prod01,
- prod02,
- prod03,
- prod04,
- prod05,
- prod06
- };
-
- pro1 = new Product2__c(
- Name = 'Pro001',
- OT_CODE_Text__c = 'Test001',
- Product2__c = prod01.Id
- );
- pro2 = new Product2__c(
- Name = 'Pro002',
- OT_CODE_Text__c = 'Test002',
- Product2__c = prod02.Id
- );
- Product2__c pro5 = new Product2__c(
- Name = 'Pro003',
- OT_CODE_Text__c = 'Test003',
- Product2__c = prod03.Id
- );
- Product2__c pro3 = new Product2__c(
- Name = 'Pro004',
- OT_CODE_Text__c = 'Test004',
- Product2__c = prod04.Id
- );
- Product2__c pro4 = new Product2__c(
- Name = 'Pro005',
- OT_CODE_Text__c = 'Test005',
- Product2__c = prod05.Id
- );
- Product2__c pro6 = new Product2__c(
- Name = 'Pro006',
- OT_CODE_Text__c = 'Test006',
- Product2__c = prod06.Id
- );
- insert new List<Product2__c>{ pro4, pro5, pro6, pro1, pro2, pro3 };
-
- myAccount1 = new Account(
- name = 'testaccount001',
- Dealer_discount__c = 10,
- RecordTypeId = rectCo[0].Id
- );
- myAccount2 = new Account(
- name = 'testaccount002',
- Dealer_discount__c = 20,
- RecordTypeId = rectHos[0].Id
- );
- insert myAccount1;
- insert myAccount2;
- Contact core = new Contact(
- email = 'jplumber@salesforce.com',
- firstname = 'Joe',
- lastname = 'Plumber',
- accountid = myAccount1.id
- );
- insert core;
- 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.runAs(myUser_test) {
- //鍙戠エ淇℃伅
- Consumable_order__c invoiceorder = new Consumable_order__c(
- Name = 'invoice01',
- Order_type__c = '鍙戠エ',
- Invoice_status__c = '宸插畬鎴�',
- Invoice_Date__c = Date.today(),
- RecordTypeid = System.Label.RT_ConOrder_Invoice,
- Order_ForHospital__c = myAccount2.Id,
- SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
- Order_status__c = '鑽夋涓�',
- Dealer_info__c = myAccount1.Id
- );
- insert invoiceorder;
-
- //鍑哄簱鍗�
- Consumable_order__c testList1 = new Consumable_order__c(
- Name = 'Test1',
- Summons_Sale_Status__c = '鍑鸿揣',
- SummonsStatus_c__c = '宸插畬鎴�',
- Order_ForHospital__c = myAccount2.Id,
- SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
- Order_status__c = '鑽夋涓�',
- Order_type__c = '浼犵エ',
- Dealer_info__c = myAccount1.Id,
- ConInvoice_Code__c = invoiceorder.id
- );
- Consumable_order__c testList2 = new Consumable_order__c(
- Name = 'Test2',
- Summons_Sale_Status__c = '鍑鸿揣',
- SummonsStatus_c__c = '宸插畬鎴�',
- Order_ForHospital__c = myAccount2.Id,
- SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
- Order_status__c = '宸叉彁浜�',
- Order_type__c = '浼犵エ',
- Dealer_info__c = myAccount1.Id,
- ConInvoice_Code__c = invoiceorder.id
- );
- TestList1.Order_date__c = Date.today().addDays(2);
- TestList2.Order_date__c = Date.today().addDays(2);
- TestList1.Order_date__c = Date.today();
- TestList2.Deliver_date__c = Date.today();
- insert new List<Consumable_order__c>{ testList1, testList2 };
-
- Consumable_order_LinkTable__c order_LinkTable1 = new Consumable_order_LinkTable__c(
- Name = 'order_LinkTable1',
- Outboundorder_Code_link__c = testList1.Id,
- Invoice_Code_link__c = invoiceorder.Id
- );
- insert order_LinkTable1;
- Consumable_order_LinkTable__c order_LinkTable2 = new Consumable_order_LinkTable__c(
- Name = 'order_LinkTable2',
- Outboundorder_Code_link__c = testList2.Id,
- Invoice_Code_link__c = invoiceorder.Id
- );
- insert order_LinkTable2;
-
- //鍙戠エ鏄庣粏1
- Consumable_orderdetails__c invoicedet1 = new Consumable_orderdetails__c();
- invoicedet1.Name = 'invoicetest1_001001';
- //orderdet1.Consumable_principal__c = testList1.Id;
- invoicedet1.Consumable_order__c = invoiceorder.id;
- invoicedet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- invoicedet1.Consumable_count__c = 1;
- invoicedet1.Consumable_product__c = pro1.Id;
- invoicedet1.Invoicedet1_OD_link__c = testList1.Id;
- invoicedet1.Box_Piece__c = '鐩�';
- invoicedet1.Shipment_Count__c = 1;
- invoicedet1.Invoice_Unitprice__c = 1;
- invoicedet1.Delivery_List_RMB__c = 1;
- invoicedet1.InvoicedProCost_RMB__c = 1;
- invoicedet1.Invoice_Unit__c = '涓�';
- invoicedet1.Invoiced_Procount__c = 3;
- invoicedet1.RrturnPro_count__c = 3;
- Consumable_orderdetails__c invoicedet2 = new Consumable_orderdetails__c();
- invoicedet2.Name = 'invoiceTest1_001002';
- //orderdet2.Consumable_principal__c = testList2.Id;
- invoicedet2.Consumable_order__c = invoiceorder.Id;
- invoicedet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- invoicedet2.Consumable_count__c = 1;
- invoicedet2.Consumable_product__c = pro2.Id;
- invoicedet2.Invoicedet1_OD_link__c = testList2.Id;
- invoicedet2.Box_Piece__c = '鐩�';
- invoicedet2.Shipment_Count__c = 1;
- invoicedet2.Invoice_Unitprice__c = 1;
- invoicedet2.Delivery_List_RMB__c = 1;
- invoicedet2.InvoicedProCost_RMB__c = 1;
- invoicedet2.Invoice_Unit__c = '涓�';
- invoicedet2.Invoiced_Procount__c = 3;
- invoicedet2.RrturnPro_count__c = 3;
- Consumable_orderdetails__c invoicedet3 = new Consumable_orderdetails__c();
- invoicedet3.Name = 'invoiceTest1_001003';
- //orderdet2.Consumable_principal__c = testList2.Id;
- invoicedet3.Consumable_order__c = invoiceorder.Id;
- invoicedet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- invoicedet3.Consumable_count__c = 1;
- invoicedet3.Consumable_product__c = pro2.Id;
- invoicedet3.Invoicedet1_OD_link__c = testList2.Id;
- invoicedet3.Box_Piece__c = '涓�';
- invoicedet3.Shipment_Count__c = 1;
- invoicedet3.Invoice_Unit__c = '鐩�';
- invoicedet3.Delivery_List_RMB__c = 2.0;
- invoicedet3.Invoice_Unitprice__c = 1;
- invoicedet3.InvoicedProCost_RMB__c = 1;
- invoicedet3.Invoiced_Procount__c = 3;
- invoicedet3.RrturnPro_count__c = 3;
- insert new List<Consumable_orderdetails__c>{
- invoicedet1,
- invoicedet2,
- invoicedet3
- };
-
- //鍑哄簱鍗曟槑缁�1
- Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
- orderdet1.Name = 'Test1_001001';
- //orderdet1.Consumable_principal__c = testList1.Id;
- orderdet1.Consumable_order__c = testList1.Id;
- orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- orderdet1.Consumable_count__c = 1;
- orderdet1.Consumable_product__c = pro1.Id;
- orderdet1.Box_Piece__c = '鐩�';
- orderdet1.Shipment_Count__c = 11;
- orderdet1.Delivery_List_RMB__c = 2.0;
- orderdet1.Invoice_Unitprice__c = 1;
- orderdet1.InvoicedProCost_RMB__c = 1;
- orderdet1.Invoiced_Procount__c = 3;
- orderdet1.RrturnPro_count__c = 3;
- orderdet1.Invoice_Unit__c = '涓�';
- orderdet1 = new Consumable_orderdetails__c();
- orderdet1.Name = 'Test1_0010011';
- //orderdet1.Consumable_principal__c = testList1.Id;
- orderdet1.Consumable_order__c = testList1.Id;
- orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- orderdet1.Consumable_count__c = 1;
- orderdet1.Consumable_product__c = pro2.Id;
- orderdet1.Box_Piece__c = '涓�';
- orderdet1.Shipment_Count__c = 11;
- orderdet1.Delivery_List_RMB__c = 2.0;
- orderdet1.Invoice_Unitprice__c = 1;
- orderdet1.InvoicedProCost_RMB__c = 1;
- orderdet1.Invoiced_Procount__c = 3;
- orderdet1.RrturnPro_count__c = 3;
- orderdet1.Invoice_Unit__c = '鐩�';
- Consumable_orderdetails__c orderdet2 = new Consumable_orderdetails__c();
- orderdet2.Name = 'Test1_0010012';
- //orderdet2.Consumable_principal__c = testList2.Id;
- orderdet2.Consumable_order__c = testList1.Id;
- orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- orderdet2.Consumable_count__c = 1;
- orderdet2.Consumable_product__c = pro2.Id;
- orderdet2.Box_Piece__c = '鐩�';
- orderdet2.Shipment_Count__c = 10;
- orderdet2.Delivery_List_RMB__c = 2.0;
- orderdet2.Invoice_Unitprice__c = 1;
- orderdet2.InvoicedProCost_RMB__c = 1;
- orderdet2.Invoiced_Procount__c = 3;
- orderdet2.RrturnPro_count__c = 3;
- orderdet2.Invoice_Unit__c = '涓�';
- orderdet2.Invoiced_Count__c = 3;
- orderdet2 = new Consumable_orderdetails__c();
- orderdet2.Name = 'Test1_0010031';
- //orderdet2.Consumable_principal__c = testList2.Id;
- orderdet2.Consumable_order__c = testList1.Id;
- orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- orderdet2.Consumable_count__c = 1;
- orderdet2.Consumable_product__c = pro1.Id;
- orderdet2.Box_Piece__c = '涓�';
- orderdet2.Shipment_Count__c = 10;
- orderdet2.Delivery_List_RMB__c = 2.0;
- orderdet2.Invoice_Unitprice__c = 1;
- orderdet2.InvoicedProCost_RMB__c = 1;
- orderdet2.Invoiced_Procount__c = 3;
- orderdet2.RrturnPro_count__c = 3;
- orderdet2.Invoice_Unit__c = '鐩�';
- orderdet2.Invoiced_Count__c = 3;
-
- Consumable_orderdetails__c orderdet3 = new Consumable_orderdetails__c();
- orderdet3.Name = 'Test1_001002';
- //orderdet2.Consumable_principal__c = testList2.Id;
- orderdet3.Consumable_order__c = testList1.Id;
- orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- orderdet3.Consumable_count__c = 1;
- orderdet3.Box_Piece__c = '鐩�';
- orderdet3.Consumable_product__c = pro2.Id;
- orderdet3.Invoice_Unit__c = '涓�';
- orderdet3.Shipment_Count__c = 11;
- orderdet3.Delivery_List_RMB__c = 2.0;
- orderdet3.Invoiced_Procount__c = 3;
- orderdet3.RrturnPro_count__c = 3;
- orderdet3.Invoiced_Count__c = 3;
- orderdet3 = new Consumable_orderdetails__c();
- orderdet3.Name = 'Test1_001003';
- //orderdet2.Consumable_principal__c = testList2.Id;
- orderdet3.Consumable_order__c = testList1.Id;
- orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- orderdet3.Consumable_count__c = 1;
- orderdet3.Box_Piece__c = '鐩�';
- orderdet3.Consumable_product__c = pro1.Id;
- orderdet3.Invoice_Unit__c = '鐩�';
- orderdet3.Shipment_Count__c = 11;
- orderdet3.Delivery_List_RMB__c = 2.0;
- orderdet3.Invoiced_Procount__c = 3;
- orderdet3.RrturnPro_count__c = 3;
- orderdet3.Invoiced_Count__c = 3;
-
- Consumable_orderdetails__c orderdet4 = new Consumable_orderdetails__c();
- orderdet4.Name = 'Test1_001004';
- //orderdet2.Consumable_principal__c = testList2.Id;
- orderdet4.Consumable_order__c = testList1.Id;
- orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- orderdet4.Consumable_count__c = 1;
- orderdet4.Box_Piece__c = '鐩�';
- orderdet4.Consumable_product__c = pro2.Id;
- orderdet4.Invoice_Unit__c = '涓�';
- orderdet4.Shipment_Count__c = 11;
- orderdet4.Delivery_List_RMB__c = 2.0;
- orderdet4.Invoiced_Procount__c = 3;
- orderdet4.Invoiced_Count__c = 3;
- orderdet4.RrturnPro_count__c = 3;
- insert new List<Consumable_orderdetails__c>{
- orderdet1,
- orderdet2,
- orderdet3,
- orderdet4
- };
-
- // PageReference page = new PageReference('/apex/ConInvoicedetails?orderId=' + testList1.Id + '&invoiceId=' + invoiceorder.id);
- // page.setRedirect(true);
- // System.Test.setCurrentPage(page);
- // page = new Pagereference('/ConInvoiceView?invoiceId='+invoiceorder.id);
- // page.setRedirect(true);
-
- LexConInvoicedetailsController.init('', '');
- // System.assertEquals(4, conTest.consumableorderdetails1Records.size());
- // conTest.consumableorderdetails1Records[0].check= true;
- // conTest.consumableorderdetails1Records[0].invoiceCount= 1;
- // conTest.consumableorderdetails1Records[0].esd.Invoice_Unit__c = '涓�';
- // conTest.consumableorderdetails1Records[1].check= true;
- // conTest.consumableorderdetails1Records[1].invoiceCount= 2;
- // conTest.consumableorderdetails1Records[1].esd.Invoice_Unit__c = '涓�';
- // conTest.save();
- // conTest.returnToinvoice();
- // Consumable_orderdetails__c testInvoice = [select id,Name,Invoiced_Count__c,Invoice_Unit__c,Invoice_Unitprice__c from Consumable_orderdetails__c where id=:invoicedet1.Id];
- // System.assertEquals(4, conTest.invoiceOrderRecoedsCount);
- // System.assertEquals('涓�', testInvoice.Invoice_Unit__c);
- }
- }
- @isTest
static void all() {
User myUser_test;
Account myAccount1;
Account myAccount2;
- Product2__c pro2;
- Product2__c pro1;
- Product2 prod01;
- Product2 prod02;
User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
System.runAs(thisUser) {
Profile prof = [
@@ -440,100 +28,6 @@
if (rectHos.size() == 0) {
return;
}
- //浜у搧淇℃伅
- prod01 = new Product2(
- Name = 'Test01',
- ProductCode = 'Test01',
- Asset_Model_No__c = 'Test01',
- SFDA_Status__c = '鏈夊姽',
- Dealer_special_Object__c = true,
- Packing_list_manual__c = 1,
- Manual_Entry__c = false
- );
- prod02 = new Product2(
- Name = 'Test02',
- ProductCode = 'Test02',
- Asset_Model_No__c = 'Test02',
- SFDA_Status__c = '鏈夊姽',
- Dealer_special_Object__c = true,
- Packing_list_manual__c = 1,
- Manual_Entry__c = false
- );
- Product2 prod03 = new Product2(
- Name = 'Test03',
- ProductCode = 'Test03',
- Asset_Model_No__c = 'Test03',
- SFDA_Status__c = '鏈夊姽',
- Dealer_special_Object__c = true,
- Packing_list_manual__c = 1,
- Manual_Entry__c = false
- );
- Product2 prod04 = new Product2(
- Name = 'Test04',
- ProductCode = 'Test04',
- Asset_Model_No__c = 'Test04',
- SFDA_Status__c = '鏈夊姽',
- Dealer_special_Object__c = true,
- Packing_list_manual__c = 2,
- Manual_Entry__c = false
- );
- Product2 prod05 = new Product2(
- Name = 'Test05',
- ProductCode = 'Test05',
- Asset_Model_No__c = 'Test05',
- SFDA_Status__c = '鏈夊姽',
- Dealer_special_Object__c = true,
- Packing_list_manual__c = 1,
- Manual_Entry__c = false
- );
- Product2 prod06 = new Product2(
- Name = 'Test06',
- ProductCode = 'Test06',
- Asset_Model_No__c = 'Test06',
- SFDA_Status__c = '鏈夊姽',
- Dealer_special_Object__c = true,
- Packing_list_manual__c = 1,
- Manual_Entry__c = false
- );
- insert new List<Product2>{
- prod01,
- prod02,
- prod03,
- prod04,
- prod05,
- prod06
- };
- pro1 = new Product2__c(
- Name = 'Pro001',
- OT_CODE_Text__c = 'Test001',
- Product2__c = prod01.Id
- );
- pro2 = new Product2__c(
- Name = 'Pro002',
- OT_CODE_Text__c = 'Test002',
- Product2__c = prod02.Id
- );
- Product2__c pro5 = new Product2__c(
- Name = 'Pro003',
- OT_CODE_Text__c = 'Test003',
- Product2__c = prod03.Id
- );
- Product2__c pro3 = new Product2__c(
- Name = 'Pro004',
- OT_CODE_Text__c = 'Test004',
- Product2__c = prod04.Id
- );
- Product2__c pro4 = new Product2__c(
- Name = 'Pro005',
- OT_CODE_Text__c = 'Test005',
- Product2__c = prod05.Id
- );
- Product2__c pro6 = new Product2__c(
- Name = 'Pro006',
- OT_CODE_Text__c = 'Test006',
- Product2__c = prod06.Id
- );
- insert new List<Product2__c>{ pro4, pro5, pro6, pro1, pro2, pro3 };
myAccount1 = new Account(
Name = 'testaccount001',
Dealer_discount__c = 10,
@@ -570,6 +64,100 @@
insert myUser_test;
}
System.runAs(myUser_test) {
+ //浜у搧淇℃伅
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod04 = new Product2(
+ Name = 'Test04',
+ ProductCode = 'Test04',
+ Asset_Model_No__c = 'Test04',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 2,
+ Manual_Entry__c = false
+ );
+ Product2 prod05 = new Product2(
+ Name = 'Test05',
+ ProductCode = 'Test05',
+ Asset_Model_No__c = 'Test05',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod06 = new Product2(
+ Name = 'Test06',
+ ProductCode = 'Test06',
+ Asset_Model_No__c = 'Test06',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{
+ prod01,
+ prod02,
+ prod03,
+ prod04,
+ prod05,
+ prod06
+ };
+ 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
+ );
+ Product2__c pro3 = new Product2__c(
+ Name = 'Pro004',
+ OT_CODE_Text__c = 'Test004',
+ Product2__c = prod03.Id
+ );
+ Product2__c pro4 = new Product2__c(
+ Name = 'Pro005',
+ OT_CODE_Text__c = 'Test005',
+ Product2__c = prod04.Id
+ );
+ Product2__c pro5 = new Product2__c(
+ Name = 'Pro003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod05.Id
+ );
+ Product2__c pro6 = new Product2__c(
+ Name = 'Pro006',
+ OT_CODE_Text__c = 'Test006',
+ Product2__c = prod06.Id
+ );
+ insert new List<Product2__c>{ pro4, pro5, pro6, pro1, pro2, pro3 };
//鍙戠エ
Consumable_order__c invoiceorder = new Consumable_order__c();
invoiceorder.Name = 'invoice02';
@@ -611,10 +199,10 @@
TestList2.Deliver_date__c = Date.today();
insert new List<Consumable_order__c>{ testList1, testList2 };
+ List<Consumable_Orderdetails__c> invoiceList = new List<Consumable_Orderdetails__c>();
//鍙戠エ鏄庣粏1
Consumable_orderdetails__c invoicedet1 = new Consumable_orderdetails__c();
invoicedet1.Name = 'invoicetest1_001001';
- //orderdet1.Consumable_principal__c = testList1.Id;
invoicedet1.Consumable_order__c = invoiceorder.id;
invoicedet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
invoicedet1.Consumable_count__c = 1;
@@ -628,9 +216,10 @@
invoicedet1.Invoice_Unit__c = '涓�';
invoicedet1.Invoiced_Procount__c = 3;
invoicedet1.RrturnPro_count__c = 3;
+ invoiceList.add(invoicedet1);
+
Consumable_orderdetails__c invoicedet2 = new Consumable_orderdetails__c();
invoicedet2.Name = 'invoiceTest1_001002';
- //orderdet2.Consumable_principal__c = testList2.Id;
invoicedet2.Consumable_order__c = invoiceorder.Id;
invoicedet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
invoicedet2.Consumable_count__c = 1;
@@ -644,9 +233,10 @@
invoicedet2.Invoice_Unit__c = '涓�';
invoicedet2.Invoiced_Procount__c = 3;
invoicedet2.RrturnPro_count__c = 3;
+ invoiceList.add(invoicedet2);
+
Consumable_orderdetails__c invoicedet3 = new Consumable_orderdetails__c();
invoicedet3.Name = 'invoiceTest1_001003';
- //orderdet2.Consumable_principal__c = testList2.Id;
invoicedet3.Consumable_order__c = invoiceorder.Id;
invoicedet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
invoicedet3.Consumable_count__c = 1;
@@ -660,12 +250,10 @@
invoicedet3.InvoicedProCost_RMB__c = 1;
invoicedet3.Invoiced_Procount__c = 3;
invoicedet3.RrturnPro_count__c = 3;
- insert new List<Consumable_orderdetails__c>{
- invoicedet1,
- invoicedet2,
- invoicedet3
- };
+ invoiceList.add(invoicedet3);
+ insert invoiceList;
+ List<Consumable_Orderdetails__c> codList = new List<Consumable_Orderdetails__c>();
//鍑哄簱鍗曟槑缁�1
Consumable_orderdetails__c orderdet1 = new Consumable_orderdetails__c();
orderdet1.Name = 'Test1_001001';
@@ -682,117 +270,137 @@
orderdet1.Invoiced_Procount__c = 3;
orderdet1.RrturnPro_count__c = 3;
orderdet1.Invoice_Unit__c = '涓�';
- orderdet1 = new Consumable_orderdetails__c();
- orderdet1.Name = 'Test1_0010011';
- //orderdet1.Consumable_principal__c = testList1.Id;
- orderdet1.Consumable_order__c = testList1.Id;
- orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- orderdet1.Consumable_count__c = 1;
- orderdet1.Consumable_product__c = pro2.Id;
- orderdet1.Box_Piece__c = '涓�';
- orderdet1.Shipment_Count__c = 11;
- orderdet1.Delivery_List_RMB__c = 2.0;
- orderdet1.Invoice_Unitprice__c = 1;
- orderdet1.InvoicedProCost_RMB__c = 1;
- orderdet1.Invoiced_Procount__c = 3;
- orderdet1.RrturnPro_count__c = 3;
- orderdet1.Invoice_Unit__c = '鐩�';
+ codList.add(orderdet1);
+
Consumable_orderdetails__c orderdet2 = new Consumable_orderdetails__c();
- orderdet2.Name = 'Test1_0010012';
- //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet2.Name = 'Test1_0010011';
orderdet2.Consumable_order__c = testList1.Id;
orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
orderdet2.Consumable_count__c = 1;
orderdet2.Consumable_product__c = pro2.Id;
- orderdet2.Box_Piece__c = '鐩�';
- orderdet2.Shipment_Count__c = 10;
- orderdet2.Delivery_List_RMB__c = 2.0;
- orderdet2.Invoice_Unitprice__c = 1;
- orderdet2.InvoicedProCost_RMB__c = 1;
- orderdet2.Invoiced_Procount__c = 3;
- orderdet2.RrturnPro_count__c = 3;
- orderdet2.Invoice_Unit__c = '涓�';
- orderdet2.Invoiced_Count__c = 3;
- orderdet2 = new Consumable_orderdetails__c();
- orderdet2.Name = 'Test1_0010031';
- //orderdet2.Consumable_principal__c = testList2.Id;
- orderdet2.Consumable_order__c = testList1.Id;
- orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- orderdet2.Consumable_count__c = 1;
- orderdet2.Consumable_product__c = pro1.Id;
orderdet2.Box_Piece__c = '涓�';
- orderdet2.Shipment_Count__c = 10;
+ orderdet2.Shipment_Count__c = 11;
orderdet2.Delivery_List_RMB__c = 2.0;
orderdet2.Invoice_Unitprice__c = 1;
orderdet2.InvoicedProCost_RMB__c = 1;
orderdet2.Invoiced_Procount__c = 3;
orderdet2.RrturnPro_count__c = 3;
orderdet2.Invoice_Unit__c = '鐩�';
- orderdet2.Invoiced_Count__c = 3;
+ codList.add(orderdet2);
Consumable_orderdetails__c orderdet3 = new Consumable_orderdetails__c();
- orderdet3.Name = 'Test1_001002';
- //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet3.Name = 'Test1_0010012';
orderdet3.Consumable_order__c = testList1.Id;
orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
orderdet3.Consumable_count__c = 1;
- orderdet3.Box_Piece__c = '鐩�';
orderdet3.Consumable_product__c = pro2.Id;
- orderdet3.Invoice_Unit__c = '涓�';
- orderdet3.Shipment_Count__c = 11;
- orderdet3.Delivery_List_RMB__c = 2.0;
- orderdet3.Invoiced_Procount__c = 3;
- orderdet3.RrturnPro_count__c = 3;
- orderdet3.Invoiced_Count__c = 3;
- orderdet3 = new Consumable_orderdetails__c();
- orderdet3.Name = 'Test1_001003';
- //orderdet2.Consumable_principal__c = testList2.Id;
- orderdet3.Consumable_order__c = testList1.Id;
- orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
- orderdet3.Consumable_count__c = 1;
orderdet3.Box_Piece__c = '鐩�';
- orderdet3.Consumable_product__c = pro1.Id;
- orderdet3.Invoice_Unit__c = '鐩�';
- orderdet3.Shipment_Count__c = 11;
+ orderdet3.Shipment_Count__c = 10;
orderdet3.Delivery_List_RMB__c = 2.0;
+ orderdet3.Invoice_Unitprice__c = 1;
+ orderdet3.InvoicedProCost_RMB__c = 1;
orderdet3.Invoiced_Procount__c = 3;
orderdet3.RrturnPro_count__c = 3;
+ orderdet3.Invoice_Unit__c = '涓�';
orderdet3.Invoiced_Count__c = 3;
+ codList.add(orderdet3);
Consumable_orderdetails__c orderdet4 = new Consumable_orderdetails__c();
- orderdet4.Name = 'Test1_001004';
- //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet4.Name = 'Test1_0010031';
orderdet4.Consumable_order__c = testList1.Id;
orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
orderdet4.Consumable_count__c = 1;
- orderdet4.Box_Piece__c = '鐩�';
- orderdet4.Consumable_product__c = pro2.Id;
- orderdet4.Invoice_Unit__c = '涓�';
- orderdet4.Shipment_Count__c = 11;
+ orderdet4.Consumable_product__c = pro1.Id;
+ orderdet4.Box_Piece__c = '涓�';
+ orderdet4.Shipment_Count__c = 10;
orderdet4.Delivery_List_RMB__c = 2.0;
+ orderdet4.Invoice_Unitprice__c = 1;
+ orderdet4.InvoicedProCost_RMB__c = 1;
orderdet4.Invoiced_Procount__c = 3;
- orderdet4.Invoiced_Count__c = 3;
orderdet4.RrturnPro_count__c = 3;
- insert new List<Consumable_orderdetails__c>{
- orderdet1,
- orderdet2,
- orderdet3,
- orderdet4
- };
+ orderdet4.Invoice_Unit__c = '鐩�';
+ orderdet4.Invoiced_Count__c = 3;
+ codList.add(orderdet4);
+
+ Consumable_orderdetails__c orderdet5 = new Consumable_orderdetails__c();
+ orderdet5.Name = 'Test1_001002';
+ orderdet5.Consumable_order__c = testList1.Id;
+ orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet5.Consumable_count__c = 1;
+ orderdet5.Box_Piece__c = '鐩�';
+ orderdet5.Consumable_product__c = pro2.Id;
+ orderdet5.Invoice_Unit__c = '涓�';
+ orderdet5.Shipment_Count__c = 11;
+ orderdet5.Delivery_List_RMB__c = 2.0;
+ orderdet5.Invoiced_Procount__c = 3;
+ orderdet5.RrturnPro_count__c = 3;
+ orderdet5.Invoiced_Count__c = 3;
+ codList.add(orderdet5);
+
+ Consumable_orderdetails__c orderdet6 = new Consumable_orderdetails__c();
+ orderdet6.Name = 'Test1_001003';
+ orderdet6.Consumable_order__c = testList1.Id;
+ orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet6.Consumable_count__c = 1;
+ orderdet6.Box_Piece__c = '鐩�';
+ orderdet6.Consumable_product__c = pro1.Id;
+ orderdet6.Invoice_Unit__c = '鐩�';
+ orderdet6.Shipment_Count__c = 11;
+ orderdet6.Delivery_List_RMB__c = 2.0;
+ orderdet6.Invoiced_Procount__c = 3;
+ orderdet6.RrturnPro_count__c = 3;
+ orderdet6.Invoiced_Count__c = 3;
+ codList.add(orderdet6);
+
+ Consumable_orderdetails__c orderdet7 = new Consumable_orderdetails__c();
+ orderdet7.Name = 'Test1_001004';
+ //orderdet2.Consumable_principal__c = testList2.Id;
+ orderdet7.Consumable_order__c = testList1.Id;
+ orderdet7.RecordTypeId = System.Label.RT_ConOrderDetail1_Invoice;
+ orderdet7.Consumable_count__c = 1;
+ orderdet7.Box_Piece__c = '鐩�';
+ orderdet7.Consumable_product__c = pro2.Id;
+ orderdet7.Invoice_Unit__c = '涓�';
+ orderdet7.Shipment_Count__c = 11;
+ orderdet7.Delivery_List_RMB__c = 2.0;
+ orderdet7.Invoiced_Procount__c = 3;
+ orderdet7.Invoiced_Count__c = 3;
+ orderdet7.RrturnPro_count__c = 3;
+ codList.add(orderdet7);
+ insert codList;
LexConInvoicedetailsController.init(testList1.Id, invoiceorder.Id);
+ //搴忓垪鍖朖son
+
+ System.Test.startTest();
System.debug(
'===>鏁版嵁' +
LexConInvoicedetailsController.consumableorderdetails1Records
);
-
- List<LexConInvoicedetailsController.ConsumableorderdetailsInfo> test = LexConInvoicedetailsController.consumableorderdetails1Records;
-
+ List<LexConInvoicedetailsController.ConsumableorderdetailsInfo> inList = LexConInvoicedetailsController.consumableorderdetails1Records;
LexConInvoicedetailsController.save(
- JSON.serialize(test),
+ JSON.serialize(
+ LexConInvoicedetailsController.consumableorderdetails1Records
+ ),
invoiceorder.Id,
testList1.Id
);
+
+ List<LexConInvoicedetailsController.ConsumableorderdetailsInfo> inList1 = new List<LexConInvoicedetailsController.ConsumableorderdetailsInfo>();
+ for (
+ LexConInvoicedetailsController.ConsumableorderdetailsInfo ass : inList
+ ) {
+ ass.check = true;
+ ass.invoiceCount = 1;
+ ass.esd.Invoice_Unit__c = '涓�';
+ inList1.add(ass);
+ }
+ LexConInvoicedetailsController.save(
+ JSON.serialize(inList1),
+ invoiceorder.Id,
+ testList1.Id
+ );
+ System.Test.stopTest();
}
}
}
diff --git a/force-app/main/default/classes/LexConsumableAccountController.cls b/force-app/main/default/classes/LexConsumableAccountController.cls
index 21d519d..740996f 100644
--- a/force-app/main/default/classes/LexConsumableAccountController.cls
+++ b/force-app/main/default/classes/LexConsumableAccountController.cls
@@ -1,431 +1,550 @@
public without sharing class LexConsumableAccountController {
- //缁忛攢鍟嗙敤鎴蜂骇鍝佸垎绫伙紙ET銆丒NG锛�
- public static String agencyProType { get; set; }
- public static String agencyProTypestr { get; set; }
- //閫夐」鍗″悕绉�
- public static String filterName { get; set; }
- //閫夐」鍗$被鍨�
- public static String hosptialType { get; set; }
- public static ApexPages.StandardSetController setCon { get; set; }
- //鐢婚潰鏄剧ず鏁伴噺
- public static Integer size { get; set; }
- public static Integer noOfRecords { get; set; }
- //鏄剧ず闆嗗悎
- public static List<Account> pageRecords { get; set; }
- //缁忛攢鍟嗕俊鎭�
- private static String accountName { get; set; }
- private static String accountId { get; set; }
- //鎺掑簭浣跨敤
- // public static String sortKey { get; set; }
- // public static String preSortKey { get; private set; }
- // public static Boolean sortOrderAsc { get; private set; }
- // public static String[] sortOrder { get; private set; }
- // //鎺掑簭浣跨敤
- // private static String[] orderby = new String[]{ 'Name','State_Master__c','Salesdepartment_HP__c','CreatedDate','Is_Active__c','RecordType.Name','Grade__c','OCM_Category__c','City_Master__c','Town__c','Phone'};
- //涓婂懆寮�濮嬨�佺粨鏉熸棩鏈�
- private static Datetime lastweekstart { get; set; }
- private static Datetime lastweekend { get; set; }
- // page
- public static Integer pagesize { get; set; }
- public static Integer pageToken { get; set; }
- public static String sortField { get; set; }
- public static String sortOrder { get; set; }
- public static Integer totalcount { get; set; }
+ //缁忛攢鍟嗙敤鎴蜂骇鍝佸垎绫伙紙ET銆丒NG锛�
+ public static String agencyProType { get; set; }
+ public static String agencyProTypestr { get; set; }
+ //閫夐」鍗″悕绉�
+ public static String filterName { get; set; }
+ //閫夐」鍗$被鍨�
+ public static String hosptialType { get; set; }
+ public static ApexPages.StandardSetController setCon { get; set; }
+ //鐢婚潰鏄剧ず鏁伴噺
+ public static Integer size { get; set; }
+ public static Integer noOfRecords { get; set; }
+ //鏄剧ず闆嗗悎
+ public static List<Account> pageRecords { get; set; }
+ //缁忛攢鍟嗕俊鎭�
+ private static String accountName { get; set; }
+ private static String accountId { get; set; }
+ //鎺掑簭浣跨敤
+ // public static String sortKey { get; set; }
+ // public static String preSortKey { get; private set; }
+ // public static Boolean sortOrderAsc { get; private set; }
+ // public static String[] sortOrder { get; private set; }
+ // //鎺掑簭浣跨敤
+ // private static String[] orderby = new String[]{ 'Name','State_Master__c','Salesdepartment_HP__c','CreatedDate','Is_Active__c','RecordType.Name','Grade__c','OCM_Category__c','City_Master__c','Town__c','Phone'};
+ //涓婂懆寮�濮嬨�佺粨鏉熸棩鏈�
+ private static Datetime lastweekstart { get; set; }
+ private static Datetime lastweekend { get; set; }
+ // page
+ public static Integer pagesize { get; set; }
+ public static Integer pageToken { get; set; }
+ public static String sortField { get; set; }
+ public static String sortOrder { get; set; }
+ public static Integer totalcount { get; set; }
- //鍒濆鍖�
+ //鍒濆鍖�
+ @AuraEnabled
+ public static ResponseBodyLWC init(
+ Integer pageSizeLWC,
+ Integer pageTokenLWC,
+ String fiscalYear
+ ) {
+ try {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ pageSize = pageSizeLWC;
+ pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC;
+
+ User Useracc = [
+ SELECT accountid, UserPro_Type__c
+ FROM user
+ WHERE id = :UserInfo.getUserId()
+ ];
+ accountId = [SELECT id, Name FROM account WHERE id = :Useracc.accountid]
+ .id;
+ agencyProType = Useracc.UserPro_Type__c;
+ if (String.isBlank(Useracc.UserPro_Type__c)) {
+ agencyProType = 'ET';
+ }
+ agencyProTypestr = '%' + agencyProType + '%';
+ System.debug('accountId = ' + accountId);
+ System.debug('agencyProTypestr = ' + agencyProTypestr);
+ List<Account> allSelectAccount = [
+ SELECT
+ id,
+ Name,
+ State_Master__c,
+ State_Master__r.Name,
+ Salesdepartment_HP__c,
+ CreatedDate,
+ Is_Active__c,
+ RecordType.Name,
+ Grade__c,
+ OCM_Category__c,
+ City_Master__c,
+ City_Master__r.Name,
+ Town__c,
+ Phone
+ FROM Account
+ WHERE
+ id IN (
+ SELECT Hospital__c
+ FROM Agency_Hospital_Link__c
+ WHERE
+ Agency__c = :accountId
+ AND Hosptial_Type__c LIKE :agencyProTypestr
+ )
+ ];
+ totalCount = allSelectAccount.size();
+
+ List<Account> selectAccList = [
+ SELECT
+ id,
+ Name,
+ State_Master__c,
+ State_Master__r.Name,
+ Salesdepartment_HP__c,
+ CreatedDate,
+ Is_Active__c,
+ RecordType.Name,
+ Grade__c,
+ OCM_Category__c,
+ City_Master__c,
+ City_Master__r.Name,
+ Town__c,
+ Phone
+ FROM Account
+ WHERE
+ id IN (
+ SELECT Hospital__c
+ FROM Agency_Hospital_Link__c
+ WHERE
+ Agency__c = :accountId
+ AND Hosptial_Type__c LIKE :agencyProTypestr
+ )
+ LIMIT :pageSize
+ ];
+ System.debug('selectAccList = ' + selectAccList);
+ PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
+ paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount)
+ ? pageToken + pageSize
+ : null;
+ paginatedAccounts.recordStart = pageToken + 1;
+ paginatedAccounts.pageNumber = pageToken / pageSize + 1;
+ Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
+ paginatedAccounts.recordEnd = totalCount >= recordEnd
+ ? recordEnd
+ : totalCount;
+ paginatedAccounts.totalRecords = totalCount;
+
+ //閿�閲忓墠鍗佺殑瀹㈡埛
+ // List<Account> acList = [
+ // SELECT
+ // id,
+ // Name,
+ // State_Master__c,
+ // State_Master__r.Name,
+ // Salesdepartment_HP__c,
+ // CreatedDate,
+ // Is_Active__c,
+ // RecordType.Name,
+ // Grade__c,
+ // OCM_Category__c,
+ // City_Master__c,
+ // City_Master__r.Name,
+ // Town__c,
+ // Phone
+ // FROM Account
+ // WHERE State_Master__r.Name != '' AND City_Master__r.Name != '' AND Is_Active__c = '鏈夊姽' AND RecordType.Name = '鐥呴櫌'
+ // LIMIT 10
+ // ];
+ TopInfo topInfo = new TopInfo();
+
+ Date today = Date.today();
+ Integer lastYear = today.year() - 1;
+ Integer thisYear = today.year();
+ Integer nextYear = today.year() + 1;
+ Date lastDatetime = Date.newInstance(lastYear, 4, 1);
+ Date thisDatetime = Date.newInstance(thisYear, 4, 1);
+ Date thisDatetime2 = Date.newInstance(thisYear, 4, 1);
+ Date nextDatetime = Date.newInstance(nextYear, 4, 1);
+
+ AggregateResult[] arList = null;
+
+ System.debug('fiscalYear = ' + fiscalYear);
+ if (fiscalYear == 'thisYear') {
+ AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(
+ thisDatetime,
+ nextDatetime
+ );
+ topInfo.saleAmount = Decimal.valueOf(
+ String.valueOf(saleAmountList[0].get('saleAmount'))
+ );
+ System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
+ arList = LexConsumableAccountSOQL.getAccountBySales(
+ thisDatetime,
+ nextDatetime
+ );
+ } else if (fiscalYear == 'lastYear') {
+ AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(
+ lastDatetime,
+ thisDatetime2
+ );
+ topInfo.saleAmount = Decimal.valueOf(
+ String.valueOf(saleAmountList[0].get('saleAmount'))
+ );
+ System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
+ arList = LexConsumableAccountSOQL.getAccountBySales(
+ lastDatetime,
+ thisDatetime2
+ );
+ } else {
+ AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(
+ lastDatetime,
+ nextDatetime
+ );
+ topInfo.saleAmount = Decimal.valueOf(
+ String.valueOf(saleAmountList[0].get('saleAmount'))
+ );
+ System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
+ arList = LexConsumableAccountSOQL.getAccountBySales(
+ lastDatetime,
+ nextDatetime
+ );
+ }
+
+ // Map<String,Decimal> mapTemp = new Map<String,Decimal>();
+ // for (AggregateResult ar : arList) {
+ // if(!mapTemp.get(String.valueOf(ar.get('hospitalName')))){
+ // mapTemp.put(String.valueOf(ar.get('hospitalName'),Decimal.valueOf(String.valueOf(ar.get('thisAmount')))));
+ // }else {
+ // Decimal decimal = mapTemp.get(String.valueOf(ar.get('hospitalName')));
+ // decimal += Decimal.valueOf(String.valueOf(ar.get('thisAmount')));
+ // mapTemp.put(String.valueOf(ar.get('hospitalName'),decimal));
+ // }
+ // }
+ // System.debug('mapTemp = ' + mapTemp);
+ // //鎺掑簭Decimal浠庡ぇ鍒板皬
+ // List<Decimal> decimalList = new List<Decimal>(mapTemp.values());
+ // decimalList.sort((a, b) => b.compareTo(a));
+ // Map<String, Decimal> sortedMap = new Map<String, Decimal>();
+ // for (String key : mapTemp.keySet()) {
+ // sortedMap.put(key, mapTemp.get(key));
+ // }
+
+ // System.debug('Sorted Map: ' + sortedMap);
+
+ //鏌ヨ瀹㈡埛淇℃伅锛堝悕绉帮紝鐪侊紝鍘匡級
+ System.debug('arList = ' + arList);
+ List<String> accountList = new List<String>();
+ for (AggregateResult ar : arList) {
+ System.debug('thisAmount = ' + String.valueOf(ar.get('thisAmount')));
+ if (String.valueOf(ar.get('thisAmount')) != '0.0') {
+ accountList.add(String.valueOf(ar.get('Order_ForHospital__c')));
+ topInfo.deList.add(
+ Decimal.valueOf(String.valueOf(ar.get('thisAmount')))
+ );
+ }
+ }
+
+ System.debug('accountList = ' + accountList);
+ System.debug('topInfo = ' + topInfo);
+
+ List<Account> acList = [
+ SELECT
+ id,
+ Name,
+ State_Master__c,
+ State_Master__r.Name,
+ Salesdepartment_HP__c,
+ CreatedDate,
+ Is_Active__c,
+ RecordType.Name,
+ Grade__c,
+ OCM_Category__c,
+ City_Master__c,
+ City_Master__r.Name,
+ Town__c,
+ Phone
+ FROM Account
+ WHERE Id = :accountList
+ ];
+
+ List<Account> acListTemp = new List<Account>();
+
+ for (String s : accountList) {
+ for (Account a : acList) {
+ if (s == a.id) {
+ acListTemp.add(a);
+ }
+ }
+ }
+
+ topInfo.acList = acListTemp;
+
+ data.put('topInfo', topInfo);
+ data.put('pageRecords', selectAccList);
+ data.put('paginatedAccounts', paginatedAccounts);
+ data.put('accountId', accountId);
+ data.put('agencyProType', agencyProType);
+ data.put('agencyProTypestr', agencyProTypestr);
+ res.status = 'Success';
+ res.code = 200;
+ res.msg = '';
+ return res;
+ } catch (Exception e) {
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ e.getMessage() + e.getLineNumber(),
+ ''
+ );
+ }
+ }
+
+ @AuraEnabled
+ public static ResponseBodyLWC changeFiscalYearView(String fiscalYear) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ try {
+ TopInfo topInfo = new TopInfo();
+
+ Date today = Date.today();
+ Integer lastYear = today.year() - 1;
+ Integer thisYear = today.year();
+ Integer nextYear = today.year() + 1;
+ Date lastDatetime = Date.newInstance(lastYear, 4, 1);
+ Date thisDatetime = Date.newInstance(thisYear, 4, 1);
+ Date thisDatetime2 = Date.newInstance(thisYear, 4, 1);
+ Date nextDatetime = Date.newInstance(nextYear, 4, 1);
+
+ AggregateResult[] arList = null;
+
+ System.debug('fiscalYear = ' + fiscalYear);
+ System.debug('thisYear = ' + thisYear);
+ System.debug('lastYear = ' + lastYear);
+
+ if (fiscalYear == 'thisYear') {
+ AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(
+ thisDatetime,
+ nextDatetime
+ );
+ if (saleAmountList[0].get('saleAmount') != null) {
+ topInfo.saleAmount = Decimal.valueOf(
+ String.valueOf(saleAmountList[0].get('saleAmount'))
+ );
+ System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
+ }
+ arList = LexConsumableAccountSOQL.getAccountBySales(
+ thisDatetime,
+ nextDatetime
+ );
+ } else if (fiscalYear == 'lastYear') {
+ AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(
+ lastDatetime,
+ thisDatetime2
+ );
+ if (saleAmountList[0].get('saleAmount') != null) {
+ topInfo.saleAmount = Decimal.valueOf(
+ String.valueOf(saleAmountList[0].get('saleAmount'))
+ );
+ System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
+ }
+ arList = LexConsumableAccountSOQL.getAccountBySales(
+ lastDatetime,
+ thisDatetime2
+ );
+ } else {
+ AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(
+ lastDatetime,
+ nextDatetime
+ );
+ if (saleAmountList[0].get('saleAmount') != null) {
+ topInfo.saleAmount = Decimal.valueOf(
+ String.valueOf(saleAmountList[0].get('saleAmount'))
+ );
+ System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
+ }
+ arList = LexConsumableAccountSOQL.getAccountBySales(
+ lastDatetime,
+ nextDatetime
+ );
+ }
+ //鏌ヨ瀹㈡埛淇℃伅锛堝悕绉帮紝鐪侊紝鍘匡級
+ List<String> accountList = new List<String>();
+ for (AggregateResult ar : arList) {
+ System.debug('thisAmount = ' + String.valueOf(ar.get('thisAmount')));
+ if (String.valueOf(ar.get('thisAmount')) != '0.0') {
+ accountList.add(String.valueOf(ar.get('Order_ForHospital__c')));
+ topInfo.deList.add(
+ Decimal.valueOf(String.valueOf(ar.get('thisAmount')))
+ );
+ }
+ }
+ System.debug('accountList = ' + accountList);
+ System.debug('topInfo = ' + topInfo);
+ List<Account> acList = [
+ SELECT
+ id,
+ Name,
+ State_Master__c,
+ State_Master__r.Name,
+ Salesdepartment_HP__c,
+ CreatedDate,
+ Is_Active__c,
+ RecordType.Name,
+ Grade__c,
+ OCM_Category__c,
+ City_Master__c,
+ City_Master__r.Name,
+ Town__c,
+ Phone
+ FROM Account
+ WHERE Id = :accountList
+ ];
+ List<Account> acListTemp = new List<Account>();
+ for (String s : accountList) {
+ for (Account a : acList) {
+ if (s == a.id) {
+ acListTemp.add(a);
+ }
+ }
+ }
+ topInfo.acList = acListTemp;
+ data.put('topInfo', topInfo);
+ res.status = 'Success';
+ res.code = 200;
+ res.msg = '';
+ return res;
+ } catch (Exception e) {
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ e.getMessage() + e.getLineNumber(),
+ ''
+ );
+ }
+ }
+
+ @AuraEnabled
+ public static ResponseBodyLWC changelistView(
+ String filterNameLwc,
+ String accountIdLwc,
+ String agencyProTypeLwc,
+ Integer pageSizeLWC,
+ Integer pageTokenLWC,
+ String sortFieldLWC,
+ String sortOrderLWC
+ ) {
+ try {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ filterName = filterNameLwc;
+ accountId = accountIdLwc;
+ agencyProTypestr = agencyProTypeLwc;
+ pageSize = pageSizeLWC;
+ pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC;
+ sortField = sortFieldLWC;
+ sortOrder = sortOrderLWC;
+
+ String soql = makeSoql(filterName, accountId);
+ System.debug('soql1+++++++ ' + soql);
+ List<Account> allSelectAccount = Database.query(soql);
+
+ totalCount = allSelectAccount.size();
+ String nullFL = sortOrder.toLowerCase() == 'asc'
+ ? 'NULLS FIRST'
+ : 'NULLS LAST';
+ if (String.isNotBlank(sortField)) {
+ soql += ' order by ' + sortField + ' ' + sortOrder + ' ' + nullFL;
+ }
+ soql += ' limit ' + pagesize + ' offset ' + pageToken;
+ System.debug('soql2+++++++ ' + soql);
+ List<Account> selectAccList = Database.query(soql);
+ System.debug('selectAccList = ' + selectAccList);
+
+ PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
+ paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount)
+ ? pageToken + pageSize
+ : null;
+ paginatedAccounts.recordStart = pageToken + 1;
+ paginatedAccounts.pageNumber = pageToken / pageSize + 1;
+ Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
+ paginatedAccounts.recordEnd = totalCount >= recordEnd
+ ? recordEnd
+ : totalCount;
+ paginatedAccounts.totalRecords = totalCount;
+
+ data.put('pageRecords', selectAccList);
+ data.put('paginatedAccounts', paginatedAccounts);
+ res.status = 'Success';
+ res.code = 200;
+ res.msg = '';
+ return res;
+ } catch (Exception e) {
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ e.getMessage() + ' ' + e.getLineNumber(),
+ ''
+ );
+ }
+ }
+
+ //sql鏂囦綔鎴�
+ private static String makeSoql(String viewName, String accountId) {
+ Date st = Date.today().addDays(-7).toStartOfWeek();
+ lastweekstart = Datetime.newInstance(
+ st.year(),
+ st.month(),
+ st.day(),
+ 8,
+ 0,
+ 0
+ );
+ lastweekend = lastweekstart.addDays(7);
+ String soql = 'SELECT id,Name,State_Master__c,Salesdepartment_HP__c,CreatedDate,Is_Active__c,RecordType.Name,State_Master__r.Name,City_Master__r.Name';
+ soql += ' ,Grade__c,OCM_Category__c,City_Master__c,Town__c,Phone FROM Account';
+ soql +=
+ ' WHERE id in (SELECT Hospital__c FROM Agency_Hospital_Link__c WHERE Agency__c =:accountId AND Hosptial_Type__c like \'%' +
+ String.escapeSingleQuotes(agencyProTypestr.replaceAll('%', '\\%')) +
+ '%\')';
+ if (viewName == '61. 鍖婚櫌_Hospital鑽夋涓殑鍖婚櫌') {
+ soql += ' AND Is_Active__c = \'' + '鑽夋涓�' + '\'';
+ }
+ if (viewName == '62. 鍖婚櫌_Hospital鐢宠涓殑鍖婚櫌') {
+ soql += ' AND Is_Active__c = \'' + '鐢宠涓�' + '\'';
+ }
+ if (viewName == '63. 鍖婚櫌_Hospital涓婂懆鍒涘缓鐨勫尰闄�') {
+ soql += ' AND Is_Active__c = \'' + '鏈夋晥' + '\'';
+ soql += ' AND CreatedDate >= :lastweekstart ';
+ soql += ' AND CreatedDate < :lastweekend ';
+ }
+ System.debug('soql +++++' + soql);
+ return soql;
+ }
+
+ //鍒嗛〉Bean
+ public class PaginatedAccounts {
@AuraEnabled
- public static ResponseBodyLWC init(Integer pageSizeLWC, Integer pageTokenLWC, String fiscalYear) {
- try {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
-
- pageSize = pageSizeLWC;
- pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC;
-
- User Useracc = [SELECT accountid, UserPro_Type__c FROM user WHERE id = :UserInfo.getUserId()];
- accountId = [SELECT id, Name FROM account WHERE id = :Useracc.accountid].id;
- agencyProType = Useracc.UserPro_Type__c;
- if (String.isBlank(Useracc.UserPro_Type__c)) {
- agencyProType = 'ET';
- }
- agencyProTypestr = '%' + agencyProType + '%';
- System.debug('accountId = ' + accountId);
- System.debug('agencyProTypestr = ' + agencyProTypestr);
- List<Account> allSelectAccount = [
- SELECT
- id,
- Name,
- State_Master__c,
- State_Master__r.Name,
- Salesdepartment_HP__c,
- CreatedDate,
- Is_Active__c,
- RecordType.Name,
- Grade__c,
- OCM_Category__c,
- City_Master__c,
- City_Master__r.Name,
- Town__c,
- Phone
- FROM Account
- WHERE
- id IN (
- SELECT Hospital__c
- FROM Agency_Hospital_Link__c
- WHERE Agency__c = :accountId AND Hosptial_Type__c LIKE :agencyProTypestr
- )
- ];
- totalCount = allSelectAccount.size();
-
- List<Account> selectAccList = [
- SELECT
- id,
- Name,
- State_Master__c,
- State_Master__r.Name,
- Salesdepartment_HP__c,
- CreatedDate,
- Is_Active__c,
- RecordType.Name,
- Grade__c,
- OCM_Category__c,
- City_Master__c,
- City_Master__r.Name,
- Town__c,
- Phone
- FROM Account
- WHERE
- id IN (
- SELECT Hospital__c
- FROM Agency_Hospital_Link__c
- WHERE Agency__c = :accountId AND Hosptial_Type__c LIKE :agencyProTypestr
- )
- LIMIT :pageSize
- ];
- System.debug('selectAccList = ' + selectAccList);
- PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
- paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount) ? pageToken + pageSize : null;
- paginatedAccounts.recordStart = pageToken + 1;
- paginatedAccounts.pageNumber = pageToken / pageSize + 1;
- Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
- paginatedAccounts.recordEnd = totalCount >= recordEnd ? recordEnd : totalCount;
- paginatedAccounts.totalRecords = totalCount;
-
- //閿�閲忓墠鍗佺殑瀹㈡埛
- // List<Account> acList = [
- // SELECT
- // id,
- // Name,
- // State_Master__c,
- // State_Master__r.Name,
- // Salesdepartment_HP__c,
- // CreatedDate,
- // Is_Active__c,
- // RecordType.Name,
- // Grade__c,
- // OCM_Category__c,
- // City_Master__c,
- // City_Master__r.Name,
- // Town__c,
- // Phone
- // FROM Account
- // WHERE State_Master__r.Name != '' AND City_Master__r.Name != '' AND Is_Active__c = '鏈夊姽' AND RecordType.Name = '鐥呴櫌'
- // LIMIT 10
- // ];
- TopInfo topInfo = new TopInfo();
-
- Date today = Date.today();
- Integer lastYear = today.year() - 1;
- Integer thisYear = today.year();
- Integer nextYear = today.year() + 1;
- Date lastDatetime = Date.newInstance(lastYear, 4, 1);
- Date thisDatetime = Date.newInstance(thisYear, 4, 1);
- Date thisDatetime2 = Date.newInstance(thisYear, 4, 1);
- Date nextDatetime = Date.newInstance(nextYear, 4, 1);
-
- AggregateResult[] arList = null;
-
- System.debug('fiscalYear = ' + fiscalYear);
- if (fiscalYear == 'thisYear') {
- AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(thisDatetime, nextDatetime);
- topInfo.saleAmount = Decimal.valueOf(String.valueOf(saleAmountList[0].get('saleAmount')));
- System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
- arList = LexConsumableAccountSOQL.getAccountBySales(thisDatetime, nextDatetime);
- } else if (fiscalYear == 'lastYear') {
- AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(lastDatetime, thisDatetime2);
- topInfo.saleAmount = Decimal.valueOf(String.valueOf(saleAmountList[0].get('saleAmount')));
- System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
- arList = LexConsumableAccountSOQL.getAccountBySales(lastDatetime, thisDatetime2);
- } else {
- AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(lastDatetime, nextDatetime);
- topInfo.saleAmount = Decimal.valueOf(String.valueOf(saleAmountList[0].get('saleAmount')));
- System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
- arList = LexConsumableAccountSOQL.getAccountBySales(lastDatetime, nextDatetime);
- }
-
- //鏌ヨ瀹㈡埛淇℃伅锛堝悕绉帮紝鐪侊紝鍘匡級
- List<String> accountList = new List<String>();
- for (AggregateResult ar : arList) {
- System.debug('thisAmount = ' + String.valueOf(ar.get('thisAmount')));
- if(String.valueOf(ar.get('thisAmount')) != '0.0'){
- accountList.add(String.valueOf(ar.get('hospitalName')));
- topInfo.deList.add(Decimal.valueOf(String.valueOf(ar.get('thisAmount'))));
- }
- }
-
- System.debug('accountList = ' + accountList);
- System.debug('topInfo = ' + topInfo);
-
- List<Account> acList = [
- SELECT
- id,
- Name,
- State_Master__c,
- State_Master__r.Name,
- Salesdepartment_HP__c,
- CreatedDate,
- Is_Active__c,
- RecordType.Name,
- Grade__c,
- OCM_Category__c,
- City_Master__c,
- City_Master__r.Name,
- Town__c,
- Phone
- FROM Account
- WHERE Name = :accountList
- ];
-
- List<Account> acListTemp = new List<Account>();
-
- for (String s : accountList) {
- for (Account a : acList) {
- if (s == a.Name) {
- acListTemp.add(a);
- }
- }
- }
-
- topInfo.acList = acListTemp;
-
- data.put('topInfo', topInfo);
- data.put('pageRecords', selectAccList);
- data.put('paginatedAccounts', paginatedAccounts);
- data.put('accountId', accountId);
- data.put('agencyProType', agencyProType);
- data.put('agencyProTypestr', agencyProTypestr);
- res.status = 'Success';
- res.code = 200;
- res.msg = '';
- return res;
- } catch (Exception e) {
- return new ResponseBodyLWC('Error', 500, e.getMessage() + e.getLineNumber(), '');
- }
- }
-
+ public Integer nextPageToken;
@AuraEnabled
- public static ResponseBodyLWC changeFiscalYearView(String fiscalYear) {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- try {
- TopInfo topInfo = new TopInfo();
-
- Date today = Date.today();
- Integer lastYear = today.year() - 1;
- Integer thisYear = today.year();
- Integer nextYear = today.year() + 1;
- Date lastDatetime = Date.newInstance(lastYear, 4, 1);
- Date thisDatetime = Date.newInstance(thisYear, 4, 1);
- Date thisDatetime2 = Date.newInstance(thisYear, 4, 1);
- Date nextDatetime = Date.newInstance(nextYear, 4, 1);
-
- AggregateResult[] arList = null;
-
- System.debug('fiscalYear = ' + fiscalYear);
- System.debug('thisYear = ' + thisYear);
- System.debug('lastYear = ' + lastYear);
-
- if (fiscalYear == 'thisYear') {
- AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(thisDatetime, nextDatetime);
- if(saleAmountList[0].get('saleAmount') != null){
- topInfo.saleAmount = Decimal.valueOf(String.valueOf(saleAmountList[0].get('saleAmount')));
- System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
- }
- arList = LexConsumableAccountSOQL.getAccountBySales(thisDatetime, nextDatetime);
- } else if (fiscalYear == 'lastYear') {
- AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(lastDatetime, thisDatetime2);
- if(saleAmountList[0].get('saleAmount') != null){
- topInfo.saleAmount = Decimal.valueOf(String.valueOf(saleAmountList[0].get('saleAmount')));
- System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
- }
- arList = LexConsumableAccountSOQL.getAccountBySales(lastDatetime, thisDatetime2);
- } else {
- AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(lastDatetime, nextDatetime);
- if(saleAmountList[0].get('saleAmount') != null){
- topInfo.saleAmount = Decimal.valueOf(String.valueOf(saleAmountList[0].get('saleAmount')));
- System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
- }
- arList = LexConsumableAccountSOQL.getAccountBySales(lastDatetime, nextDatetime);
- }
- //鏌ヨ瀹㈡埛淇℃伅锛堝悕绉帮紝鐪侊紝鍘匡級
- List<String> accountList = new List<String>();
- for (AggregateResult ar : arList) {
- System.debug('thisAmount = ' + String.valueOf(ar.get('thisAmount')));
- if(String.valueOf(ar.get('thisAmount')) != '0.0'){
- accountList.add(String.valueOf(ar.get('hospitalName')));
- topInfo.deList.add(Decimal.valueOf(String.valueOf(ar.get('thisAmount'))));
- }
-
- }
- System.debug('accountList = ' + accountList);
- System.debug('topInfo = ' + topInfo);
- List<Account> acList = [
- SELECT
- id,
- Name,
- State_Master__c,
- State_Master__r.Name,
- Salesdepartment_HP__c,
- CreatedDate,
- Is_Active__c,
- RecordType.Name,
- Grade__c,
- OCM_Category__c,
- City_Master__c,
- City_Master__r.Name,
- Town__c,
- Phone
- FROM Account
- WHERE Name = :accountList
- ];
- List<Account> acListTemp = new List<Account>();
- for (String s : accountList) {
- for (Account a : acList) {
- if (s == a.Name) {
- acListTemp.add(a);
- }
- }
- }
- topInfo.acList = acListTemp;
- data.put('topInfo', topInfo);
- res.status = 'Success';
- res.code = 200;
- res.msg = '';
- return res;
- } catch (Exception e) {
- return new ResponseBodyLWC('Error', 500, e.getMessage() + e.getLineNumber(), '');
- }
- }
-
+ public Integer pageNumber { get; set; }
@AuraEnabled
- public static ResponseBodyLWC changelistView(
- String filterNameLwc,
- String accountIdLwc,
- String agencyProTypeLwc,
- Integer pageSizeLWC,
- Integer pageTokenLWC,
- String sortFieldLWC,
- String sortOrderLWC
- ) {
- try {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
+ public Integer totalRecords { get; set; }
+ @AuraEnabled
+ public Integer recordStart { get; set; }
+ @AuraEnabled
+ public Integer recordEnd { get; set; }
+ }
- filterName = filterNameLwc;
- accountId = accountIdLwc;
- agencyProTypestr = agencyProTypeLwc;
- pageSize = pageSizeLWC;
- pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC;
- sortField = sortFieldLWC;
- sortOrder = sortOrderLWC;
+ //top10 Account
+ public class TopInfo {
+ @AuraEnabled
+ public Decimal saleAmount { get; set; }
+ @AuraEnabled
+ public List<Account> acList { get; set; }
+ @AuraEnabled
+ public List<Decimal> deList { get; set; }
- String soql = makeSoql(filterName, accountId);
- System.debug('soql1+++++++ ' + soql);
- List<Account> allSelectAccount = Database.query(soql);
-
- totalCount = allSelectAccount.size();
- if (String.isNotBlank(sortField)) {
- soql += ' order by ' + sortField + ' ' + sortOrder;
- }
- soql += ' limit ' + pagesize + ' offset ' + pageToken;
- System.debug('soql2+++++++ ' + soql);
- List<Account> selectAccList = Database.query(soql);
- System.debug('selectAccList = ' + selectAccList);
-
- PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
- paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount) ? pageToken + pageSize : null;
- paginatedAccounts.recordStart = pageToken + 1;
- paginatedAccounts.pageNumber = pageToken / pageSize + 1;
- Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
- paginatedAccounts.recordEnd = totalCount >= recordEnd ? recordEnd : totalCount;
- paginatedAccounts.totalRecords = totalCount;
-
- data.put('pageRecords', selectAccList);
- data.put('paginatedAccounts', paginatedAccounts);
- res.status = 'Success';
- res.code = 200;
- res.msg = '';
- return res;
- } catch (Exception e) {
- return new ResponseBodyLWC('Error', 500, e.getMessage() + ' ' + e.getLineNumber(), '');
- }
+ public TopInfo() {
+ acList = new List<Account>();
+ deList = new List<Decimal>();
}
-
- //sql鏂囦綔鎴�
- private static String makeSoql(String viewName, String accountId) {
- Date st = Date.today().addDays(-7).toStartOfWeek();
- lastweekstart = Datetime.newInstance(st.year(), st.month(), st.day(), 8, 0, 0);
- lastweekend = lastweekstart.addDays(7);
- String soql = 'SELECT id,Name,State_Master__c,Salesdepartment_HP__c,CreatedDate,Is_Active__c,RecordType.Name,State_Master__r.Name,City_Master__r.Name';
- soql += ' ,Grade__c,OCM_Category__c,City_Master__c,Town__c,Phone FROM Account';
- soql +=
- ' WHERE id in (SELECT Hospital__c FROM Agency_Hospital_Link__c WHERE Agency__c =:accountId AND Hosptial_Type__c like \'%' +
- String.escapeSingleQuotes(agencyProTypestr.replaceAll('%', '\\%')) +
- '%\')';
- if (viewName == '61. 鍖婚櫌_Hospital鑽夋涓殑鍖婚櫌') {
- soql += ' AND Is_Active__c = \'' + '鑽夋涓�' + '\'';
- }
- if (viewName == '62. 鍖婚櫌_Hospital鐢宠涓殑鍖婚櫌') {
- soql += ' AND Is_Active__c = \'' + '鐢宠涓�' + '\'';
- }
- if (viewName == '63. 鍖婚櫌_Hospital涓婂懆鍒涘缓鐨勫尰闄�') {
- soql += ' AND Is_Active__c = \'' + '鏈夋晥' + '\'';
- soql += ' AND CreatedDate >= :lastweekstart ';
- soql += ' AND CreatedDate < :lastweekend ';
- }
- System.debug('soql +++++' + soql);
- return soql;
- }
-
- //鍒嗛〉Bean
- public class PaginatedAccounts {
- @AuraEnabled
- public Integer nextPageToken;
- @AuraEnabled
- public Integer pageNumber { get; set; }
- @AuraEnabled
- public Integer totalRecords { get; set; }
- @AuraEnabled
- public Integer recordStart { get; set; }
- @AuraEnabled
- public Integer recordEnd { get; set; }
- }
-
- //top10 Account
- public class TopInfo {
- @AuraEnabled
- public Decimal saleAmount { get; set; }
- @AuraEnabled
- public List<Account> acList { get; set; }
- @AuraEnabled
- public List<Decimal> deList { get; set; }
-
- public TopInfo() {
- acList = new List<Account>();
- deList = new List<Decimal>();
- }
- }
-}
\ No newline at end of file
+ }
+}
diff --git a/force-app/main/default/classes/LexConsumableAccountControllerTest.cls b/force-app/main/default/classes/LexConsumableAccountControllerTest.cls
new file mode 100644
index 0000000..4bd6161
--- /dev/null
+++ b/force-app/main/default/classes/LexConsumableAccountControllerTest.cls
@@ -0,0 +1,189 @@
+@isTest
+private class LexConsumableAccountControllerTest {
+ public static Account account1 = new Account();
+ public static Account account2 = new Account();
+ public static Account account3 = new Account();
+ public static Account consumable = new Account();
+ public static Contact contact1 = new Contact();
+ public static User user = new User();
+ public static Agency_Hospital_Link__c agency_hospital_link = new Agency_Hospital_Link__c();
+
+ static testMethod void testMethod1() {
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ // 鍙栧紩鍏�
+ account1.Name = 'test1鍖婚櫌';
+ account1.RecordTypeId = '01210000000QemG';
+ // account1.Is_Active__c = '鑽夋涓�';
+ insert account1;
+
+ account2.Name = 'test2鍖婚櫌';
+ account2.RecordTypeId = '01210000000QemG';
+ // account2.Is_Active__c = '鏈夊姽';
+ insert account2;
+
+ account3.Name = 'test3鍖婚櫌';
+ account3.RecordTypeId = '01210000000QemG';
+ // account3.Is_Active__c = '鐢宠涓�';
+ insert account3;
+
+ consumable.Name = 'test1缁忛攢鍟�';
+ consumable.RecordTypeId = '01210000000Qem1';
+ insert consumable;
+
+ contact1.AccountId = account1.Id;
+ contact1.FirstName = '璨换鑰�';
+ contact1.LastName = 'test1鍖婚櫌';
+ insert contact1;
+
+ // 銉︺兗銈躲兗
+ Profile p = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄�'
+ ];
+ user.ProfileId = p.Id;
+ user.ContactId = contact1.Id;
+ user.FirstName = '銉︺兗銈躲兗';
+ user.LastName = '銉嗐偣銉�';
+ user.Email = 'test_user@example.com';
+ user.emailencodingkey = 'UTF-8';
+ user.languagelocalekey = 'zh_CN';
+ user.localesidkey = 'ja_JP';
+ user.timezonesidkey = 'Asia/Shanghai';
+ user.Username = 'test_user@example.com';
+ user.Alias = '銉嗐儲';
+ user.CommunityNickname = '銉嗐偣銉堛儲銉笺偠銉�';
+ insert user;
+
+ // 浠g悊搴楀尰闄�
+ agency_hospital_link.Name = 'test1浠g悊搴楀尰闄�';
+ agency_hospital_link.Hospital__c = account1.Id;
+ agency_hospital_link.Agency__c = consumable.Id;
+ agency_hospital_link.OwnerId = user.Id;
+ insert agency_hospital_link;
+ }
+ System.runAs(user) {
+ //璁㈠崟
+ 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 = account1.Id;
+ Order1.RecordTypeid = '01210000000c9dqAAA';
+ Order1.Order_ProType__c = 'ET';
+ Order1.Order_ForHospital__c = account1.Id;
+ insert Order1;
+
+ Consumable_Orderdetails__c con = new Consumable_Orderdetails__c();
+ con.Consumable_order__c = Order1.Id;
+ insert con;
+
+ LexConsumableAccountController.init(2, 1, 'thisYear');
+ LexConsumableAccountController.init(2, 1, 'lastYear');
+ LexConsumableAccountController.init(2, 1, '2023');
+ LexConsumableAccountController.changeFiscalYearView('thisYear');
+ LexConsumableAccountController.changeFiscalYearView('lastYear');
+ // LexConsumableAccountController.changelistView('62. 鍖婚櫌_Hospital鐢宠涓殑鍖婚櫌',consumable.Id,'ET',1,0,'Is_Active__c','ASC');
+ // LexConsumableAccountController.changelistView('63. 鍖婚櫌_Hospital涓婂懆鍒涘缓鐨勫尰闄�',consumable.Id,'ET',1,0,'Is_Active__c','ASC');
+ }
+
+ }
+ static testMethod void testMethod2() {
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ // 鍙栧紩鍏�
+ account1.Name = 'test1鍖婚櫌';
+ account1.RecordTypeId = '01210000000QemG';
+ // account1.Is_Active__c = '鑽夋涓�';
+ insert account1;
+
+ account2.Name = 'test2鍖婚櫌';
+ account2.RecordTypeId = '01210000000QemG';
+ // account2.Is_Active__c = '鏈夊姽';
+ insert account2;
+
+ account3.Name = 'test3鍖婚櫌';
+ account3.RecordTypeId = '01210000000QemG';
+ // account3.Is_Active__c = '鐢宠涓�';
+ insert account3;
+
+ consumable.Name = 'test1缁忛攢鍟�';
+ consumable.RecordTypeId = '01210000000Qem1';
+ insert consumable;
+
+ contact1.AccountId = account1.Id;
+ contact1.FirstName = '璨换鑰�';
+ contact1.LastName = 'test1鍖婚櫌';
+ insert contact1;
+
+ // 銉︺兗銈躲兗
+ Profile p = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄�'
+ ];
+ user.ProfileId = p.Id;
+ user.ContactId = contact1.Id;
+ user.FirstName = '銉︺兗銈躲兗';
+ user.LastName = '銉嗐偣銉�';
+ user.Email = 'test_user@example.com';
+ user.emailencodingkey = 'UTF-8';
+ user.languagelocalekey = 'zh_CN';
+ user.localesidkey = 'ja_JP';
+ user.timezonesidkey = 'Asia/Shanghai';
+ user.Username = 'test_user@example.com';
+ user.Alias = '銉嗐儲';
+ user.CommunityNickname = '銉嗐偣銉堛儲銉笺偠銉�';
+ insert user;
+
+ // 浠g悊搴楀尰闄�
+ agency_hospital_link.Name = 'test1浠g悊搴楀尰闄�';
+ agency_hospital_link.Hospital__c = account1.Id;
+ agency_hospital_link.Agency__c = consumable.Id;
+ agency_hospital_link.OwnerId = user.Id;
+ insert agency_hospital_link;
+ }
+ System.runAs(user) {
+ PageReference page = new PageReference('/apex/ConsumableAccount');
+ System.Test.setCurrentPage(page);
+ ConsumableAccountController ca = new ConsumableAccountController();
+ //ConsumableAccountController.getlistViewOptions();
+ ca.init();
+
+ ca.filterName = '61. 鍖婚櫌_Hospital鑽夋涓殑鍖婚櫌';
+ ca.changelistView();
+
+ ca.filterName = '62. 鍖婚櫌_Hospital鐢宠涓殑鍖婚櫌';
+ ca.changelistView();
+
+ ca.filterName = '63. 鍖婚櫌_Hospital涓婂懆鍒涘缓鐨勫尰闄�';
+ ca.changelistView();
+
+ ca.refreshPageSize();
+
+ ca.sortKey = '0';
+ ca.accsort();
+
+ ca.sortKey = '1';
+ LexConsumableAccountController.changelistView(
+ '62. 鍖婚櫌_Hospital鐢宠涓殑鍖婚櫌',
+ consumable.Id,
+ 'ET',
+ 1,
+ 0,
+ 'Is_Active__c',
+ 'ASC'
+ );
+ LexConsumableAccountController.changelistView(
+ '63. 鍖婚櫌_Hospital涓婂懆鍒涘缓鐨勫尰闄�',
+ consumable.Id,
+ 'ET',
+ 1,
+ 0,
+ 'Is_Active__c',
+ 'ASC'
+ );
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexConsumableAccountControllerTest.cls-meta.xml b/force-app/main/default/classes/LexConsumableAccountControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexConsumableAccountControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexConsumableAccountInfoControllerTest.cls b/force-app/main/default/classes/LexConsumableAccountInfoControllerTest.cls
new file mode 100644
index 0000000..f76c3d5
--- /dev/null
+++ b/force-app/main/default/classes/LexConsumableAccountInfoControllerTest.cls
@@ -0,0 +1,16 @@
+@isTest
+private class LexConsumableAccountInfoControllerTest {
+ @isTest
+ public static void test_method_one() {
+ // Implement test code
+ Account account1 = new Account();
+ account1.Name = 'test1鍖婚櫌';
+ account1.RecordTypeId = '01210000000QemG';
+ //account1.Is_Active__c = '鑽夋涓�';
+ insert account1;
+
+ LexConsumableAccountInfoController cai = new LexConsumableAccountInfoController();
+ LexConsumableAccountInfoController.init(account1.Id);
+ LexConsumableAccountInfoController.init('');
+ }
+}
diff --git a/force-app/main/default/classes/LexConsumableAccountInfoControllerTest.cls-meta.xml b/force-app/main/default/classes/LexConsumableAccountInfoControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexConsumableAccountInfoControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexConsumableAccountSOQL.cls b/force-app/main/default/classes/LexConsumableAccountSOQL.cls
index eef1437..a6006d9 100644
--- a/force-app/main/default/classes/LexConsumableAccountSOQL.cls
+++ b/force-app/main/default/classes/LexConsumableAccountSOQL.cls
@@ -1,27 +1,41 @@
public with sharing class LexConsumableAccountSOQL {
- public static AggregateResult[] getAccountBySales(Datetime thisDatetime ,Datetime nextDatetime){
- AggregateResult[] arList = new List<AggregateResult>([
- SELECT count(id), Consumable_order__r.Order_ForHospital__r.name hospitalName, sum(Sale_amount__c) thisAmount
- FROM Consumable_Orderdetails__c
- WHERE
- CreatedDate >= :thisDatetime
- AND CreatedDate < :nextDatetime
- AND Consumable_order__r.Order_ForHospital__r.name != ''
- GROUP BY Consumable_order__r.Order_ForHospital__r.Name
- ORDER BY sum(Sale_amount__c) DESC
- LIMIT 10
- ]);
- return arList;
- }
+ public static AggregateResult[] getAccountBySales(
+ Datetime thisDatetime,
+ Datetime nextDatetime
+ ) {
+ AggregateResult[] arList = new List<AggregateResult>(
+ [
+ SELECT
+ Consumable_order__r.Order_ForHospital__c,
+ Consumable_order__r.Order_ForHospital__r.name hospitalName,
+ sum(Sale_amount__c) thisAmount
+ FROM Consumable_Orderdetails__c
+ WHERE
+ CreatedDate >= :thisDatetime
+ AND CreatedDate < :nextDatetime
+ AND Consumable_order__r.Order_ForHospital__r.name != ''
+ GROUP BY
+ Consumable_order__r.Order_ForHospital__c,
+ Consumable_order__r.Order_ForHospital__r.name
+ ORDER BY sum(Sale_amount__c) DESC
+ LIMIT 10
+ ]
+ );
+ return arList;
+ }
- public static AggregateResult[] getAccountTotalSales(Datetime thisDatetime ,Datetime nextDatetime){
- AggregateResult[] saleAmountList = [
- SELECT sum(Sale_amount__c) saleAmount
- FROM Consumable_Orderdetails__c
- WHERE CreatedDate >= :thisDatetime AND CreatedDate < :nextDatetime
- ];
- return saleAmountList;
- }
-
-
-}
\ No newline at end of file
+ public static AggregateResult[] getAccountTotalSales(
+ Datetime thisDatetime,
+ Datetime nextDatetime
+ ) {
+ AggregateResult[] saleAmountList = [
+ SELECT sum(Sale_amount__c) saleAmount
+ FROM Consumable_Orderdetails__c
+ WHERE
+ CreatedDate >= :thisDatetime
+ AND CreatedDate < :nextDatetime
+ AND Consumable_order__r.Order_ForHospital__r.name != ''
+ ];
+ return saleAmountList;
+ }
+}
diff --git a/force-app/main/default/classes/LexConsumableAccountSOQLTest.cls b/force-app/main/default/classes/LexConsumableAccountSOQLTest.cls
new file mode 100644
index 0000000..577573e
--- /dev/null
+++ b/force-app/main/default/classes/LexConsumableAccountSOQLTest.cls
@@ -0,0 +1,148 @@
+@isTest
+private class LexConsumableAccountSOQLTest {
+ @testSetup
+ static void testInfo() {
+ User userTest;
+ Account accountItem;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ];
+ accountItem = new Account(
+ Name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|5|55,Test02|2|4',
+ AgentCode_Ext__c = '9999900'
+ );
+ insert accountItem;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountId = accountItem.id
+ );
+ insert core;
+ userTest = 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 = 'ENG',
+ Work_Location__c = '鍖椾含'
+ );
+ insert userTest;
+ }
+
+ System.runAs(userTest) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = '12124',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = '12124',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ 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 createId = new Consumable_order__c();
+ createId.Name = 'testMing1';
+ createId.Order_status__c = '鎵瑰噯';
+ createId.Deliver_date__c = Date.today();
+ createId.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ createId.Order_type__c = '璁㈠崟';
+ createId.Order_ProType__c = 'ENG';
+ createId.Dealer_Info__c = accountItem.Id;
+ createId.Delivery_detail_count__c = 5;
+ createId.orderPattern__c = 'hospitalorder';
+ insert createId;
+
+ List<Consumable_Orderdetails__c> coListTest = new List<Consumable_Orderdetails__c>();
+ Consumable_Orderdetails__c conOrderDetail1 = new Consumable_Orderdetails__c();
+ conOrderDetail1.Name = 'testConOrderDetail1';
+ conOrderDetail1.Consumable_Arrivecount__c = 5;
+ conOrderDetail1.Unitprice_To_agency__c = 0;
+ conOrderDetail1.Delivery_List_RMB__c = 99;
+ conOrderDetail1.Shipment_Count__c = 100;
+ conOrderDetail1.Consumable_product__c = pro1.id;
+ conOrderDetail1.Consumable_order__c = createId.Id;
+ coListTest.add(conOrderDetail1);
+
+ Consumable_Orderdetails__c conOrderDetail2 = new Consumable_Orderdetails__c();
+ conOrderDetail2.Name = 'testConOrderDetail2';
+ conOrderDetail1.Unitprice_To_agency__c = 0;
+ conOrderDetail1.Delivery_List_RMB__c = 99;
+ conOrderDetail2.Shipment_Count__c = 99;
+ conOrderDetail2.Consumable_product__c = pro2.id;
+ conOrderDetail2.Consumable_order__c = createId.Id;
+ coListTest.add(conOrderDetail2);
+ insert coListTest;
+ }
+ }
+ @isTest
+ static void testGetAccountBySales() {
+ System.Test.startTest();
+ DateTime thisDatetime = DateTime.newInstance(2023, 1, 1, 0, 0, 0);
+ DateTime nextDatetime = DateTime.newInstance(2023, 6, 6, 0, 0, 0);
+ AggregateResult[] arList = new List<AggregateResult>();
+ arList = LexConsumableAccountSOQL.getAccountBySales(
+ thisDatetime,
+ nextDatetime
+ );
+ System.Test.stopTest();
+ }
+ @isTest
+ static void testGetAccountTotalSales() {
+ System.Test.startTest();
+ DateTime thisDatetime = DateTime.newInstance(2023, 1, 1, 0, 0, 0);
+ DateTime nextDatetime = DateTime.newInstance(2023, 6, 6, 0, 0, 0);
+ AggregateResult[] saleAmountList = new List<AggregateResult>();
+ saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(
+ thisDatetime,
+ nextDatetime
+ );
+ System.Test.stopTest();
+ }
+}
diff --git a/force-app/main/default/classes/LexConsumableAccountSOQLTest.cls-meta.xml b/force-app/main/default/classes/LexConsumableAccountSOQLTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexConsumableAccountSOQLTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexConsumableController.cls b/force-app/main/default/classes/LexConsumableController.cls
index c6f9846..0584d06 100644
--- a/force-app/main/default/classes/LexConsumableController.cls
+++ b/force-app/main/default/classes/LexConsumableController.cls
@@ -1,2271 +1,2715 @@
public without sharing class LexConsumableController {
- /*****************妞滅储鐢�******************/
- public static Consumable_order__c coc { get; set; } // FIMXE Consumable_order__c 銇偆銉炽偣銈裤兂銈广�乻ql澶氥仚銇�
- public static String category1 { get; set; }
- public static String category5 { get; set; }
- public static String category4 { get; set; }
- public static String category3 { get; set; }
- public static String category_Goods { get; set; }
- public static Boolean specialCampaign { get; set; }
- public static Boolean cansee { get; set; }
- //缁忛攢鍟嗗悎鍚屽悕绉�
- public static String contractName { get; set; }
- //缁忛攢鍟嗗悎鍚孖D
- public static String contractId { get; set; }
- //缁忛攢鍟嗗畾浠锋煡鐪嬫潈闄�
- public static Boolean dealerPricesee { get; set; }
- /*****************鐢婚潰鍒濆鍖栫敤********************************/
- /******20160313_add**************/
- //public String idCheck {get;set;}
- public static Boolean editAble { get; set; }
- public static Boolean edoffersPrice { get; set; }
- public static String statusEdit { get; set; }
- public static Boolean returnOrder { get; set; }
- public static String searchDone { get; set; }
- //鏆傜敤20160323
- public static Decimal disCount = 0;
- //鎬讳环鏍艰绠楃粨鏋�
- public static Decimal sumPrice { get; set; }
- //鑷畾涔夌壒浠烽噾棰�
- public static Decimal bargainPrice { get; set; }
- //浜у搧涓婁笅闄�
- public static String[] proLimitAndDate = new List<String>{};
- /*****************鐢婚潰琛ㄧずBean******************/
- private static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsview { get; set; }
- public static Integer ConsumableorderdetailsCount {
- get {
- return consumableorderdetailsRecords == null ? 0 : consumableorderdetailsRecords.size();
- }
+ /*****************妞滅储鐢�******************/
+ public static Consumable_order__c coc { get; set; } // FIMXE Consumable_order__c 銇偆銉炽偣銈裤兂銈广�乻ql澶氥仚銇�
+ public static String category1 { get; set; }
+ public static String category5 { get; set; }
+ public static String category4 { get; set; }
+ public static String category3 { get; set; }
+ public static String category_Goods { get; set; }
+ public static Boolean specialCampaign { get; set; }
+ public static Boolean cansee { get; set; }
+ //缁忛攢鍟嗗悎鍚屽悕绉�
+ public static String contractName { get; set; }
+ //缁忛攢鍟嗗悎鍚孖D
+ public static String contractId { get; set; }
+ //缁忛攢鍟嗗畾浠锋煡鐪嬫潈闄�
+ public static Boolean dealerPricesee { get; set; }
+ /*****************鐢婚潰鍒濆鍖栫敤********************************/
+ /******20160313_add**************/
+ //public String idCheck {get;set;}
+ public static Boolean editAble { get; set; }
+ public static Boolean edoffersPrice { get; set; }
+ public static String statusEdit { get; set; }
+ public static Boolean returnOrder { get; set; }
+ public static String searchDone { get; set; }
+ //鏆傜敤20160323
+ public static Decimal disCount = 0;
+ //鎬讳环鏍艰绠楃粨鏋�
+ public static Decimal sumPrice { get; set; }
+ //鑷畾涔夌壒浠烽噾棰�
+ public static Decimal bargainPrice { get; set; }
+ //浜у搧涓婁笅闄�
+ public static String[] proLimitAndDate = new List<String>{};
+ /*****************鐢婚潰琛ㄧずBean******************/
+ private static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsview {
+ get;
+ set;
+ }
+ public static Integer ConsumableorderdetailsCount {
+ get {
+ return consumableorderdetailsRecords == null
+ ? 0
+ : consumableorderdetailsRecords.size();
}
- public static Integer ConsumableorderdetailsviewCount {
- get {
- return consumableorderdetailsRecordsview == null ? 0 : consumableorderdetailsRecordsview.size();
- }
+ }
+ public static Integer ConsumableorderdetailsviewCount {
+ get {
+ return consumableorderdetailsRecordsview == null
+ ? 0
+ : consumableorderdetailsRecordsview.size();
}
- public static List<String> lower = new List<String>();
- //闄勪欢
- public static List<ConsumableorderdetailsInfo> attachmentRecoeds { get; set; }
- public static List<String> DealerProductId { get; set; }
- public static Boolean editDelCommitBtnDisabled { get; private set; }
- public static Boolean saveBtnDisabled { get; private set; }
- public static Boolean sorderBtnDisabled { get; private set; }
- public static String decisionCode { get; set; }
- // 淇濆瓨鍚庡姩浣滐細 1.妫�绱� 2.鎺掑簭
- public static String baseUrl { get; private set; }
- public static String sortKey { get; set; }
- public static String preSortKey { get; private set; }
- public static Boolean sortOrderAsc { get; private set; }
- public static String[] sortOrder { get; private set; }
- private static List<String> contactDealer = new List<String>();
- private static String[] columus = new List<String>{
- 'Consumable_Product__r.Name',
- 'Consumable_Product__r.Asset_Model_No__c',
- 'Consumable_Product__r.Intra_Trade_List_RMB__c',
- '',
- '',
- 'Consumable_Product__r.Category3__c',
- 'Consumable_Product__r.Category4__c',
- 'Consumable_Product__r.Category5__c'
- };
- private static String[] columus_no = new List<String>{
- 'Product2__c.Name',
- 'Product2__c.Asset_Model_No__c',
- 'Product2__c.Intra_Trade_List_RMB__c',
- '',
- '',
- 'Category3__c',
- 'Category4__c',
- 'Category5__c'
- };
- // 宸查�夋嫨浜у搧鏄庣粏
- private static List<Attachment> attachmentinfo = new List<Attachment>();
- /*****************銈姐兗銉堟檪鍐嶆绱㈡潯浠讹紙鐢婚潰銇嬨倝銇叆鍔涙潯浠躲倰鐒¤銇欍倠銇熴倎锛�******************/
- private static String cate1ForSort = null;
- private static String accountid = null;
- private static String accountName = null;
- // 浜у搧 ID
- public static String ESetId { get; set; }
- private static String userId = '';
- //private String[] ProidListAll = new String[]{};
- public static List<SelectOption> categoryOptionList { get; set; }
- public static List<SelectOption> category4OptionList { get; set; }
- public static List<SelectOption> category5OptionList { get; set; }
- public static List<CusOption> category3Option { get; set; }
- public static List<CusOption> category4Option { get; set; }
- public static List<CusOption> category5Option { get; set; }
- private static Map<Id, Dealer_Product__c> DealerProductMap = new Map<Id, Dealer_Product__c>();
- public static List<String> orderzaikuId = new List<String>();
- //鍒嗛〉鍔熻兘
- public static Integer size { get; set; }
- public static Integer pageLimit { get; set; }
- public static Integer noOfRecords { get; set; }
- public static ApexPages.StandardSetController con { get; set; }
- public static String soql { get; set; }
- // 鐧诲綍鑰呭伐浣滃湴
- private static String userWorkLocation;
- public static String agencyProType { get; set; }
- public static String agencyProType1 {get;set;} //lt 20230526 瀹夊窘涓ょエ鍒� add
- private static Boolean OSHFLG;//lt 20230517 瀹夊窘涓ょエ鍒� add
- public static String methodType { get; set; }
- public static String hospitalName { get; set; }
- public static String hospitalId { get; set; }
- public static String tempidHp { get; set; }
- public static String tempidPp { get; set; }
- private static List<String> hpids = new List<String>();
- private static Boolean isfirst = false;
- //鎶ラ敊鍜岃鍛婁俊鎭�
- public static List<String> errorMsgList = new List<String>();
- public static List<String> warningMsgList = new List<String>();
- //鏋勯�犳柟娉�
- public LexConsumableController() {
- baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
- consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- DealerProductId = new List<String>();
- attachmentRecoeds = new List<ConsumableorderdetailsInfo>();
- consumableorderdetailsRecordsview = new List<ConsumableorderdetailsInfo>();
+ }
+ public static List<String> lower = new List<String>();
+ //闄勪欢
+ public static List<ConsumableorderdetailsInfo> attachmentRecoeds { get; set; }
+ public static List<String> DealerProductId { get; set; }
+ public static Boolean editDelCommitBtnDisabled { get; private set; }
+ public static Boolean saveBtnDisabled { get; private set; }
+ public static Boolean sorderBtnDisabled { get; private set; }
+ public static String decisionCode { get; set; }
+ // 淇濆瓨鍚庡姩浣滐細 1.妫�绱� 2.鎺掑簭
+ public static String baseUrl { get; private set; }
+ public static String sortKey { get; set; }
+ public static String preSortKey { get; private set; }
+ public static Boolean sortOrderAsc { get; private set; }
+ public static String[] sortOrder { get; private set; }
+ private static List<String> contactDealer = new List<String>();
+ private static String[] columus = new List<String>{
+ 'Consumable_Product__r.Name',
+ 'Consumable_Product__r.Asset_Model_No__c',
+ 'Consumable_Product__r.Intra_Trade_List_RMB__c',
+ '',
+ '',
+ 'Consumable_Product__r.Category3__c',
+ 'Consumable_Product__r.Category4__c',
+ 'Consumable_Product__r.Category5__c'
+ };
+ private static String[] columus_no = new List<String>{
+ 'Product2__c.Name',
+ 'Product2__c.Asset_Model_No__c',
+ 'Product2__c.Intra_Trade_List_RMB__c',
+ '',
+ '',
+ 'Category3__c',
+ 'Category4__c',
+ 'Category5__c'
+ };
+ // 宸查�夋嫨浜у搧鏄庣粏
+ private static List<Attachment> attachmentinfo = new List<Attachment>();
+ /*****************銈姐兗銉堟檪鍐嶆绱㈡潯浠讹紙鐢婚潰銇嬨倝銇叆鍔涙潯浠躲倰鐒¤銇欍倠銇熴倎锛�******************/
+ private static String cate1ForSort = null;
+ private static String accountid = null;
+ private static String accountName = null;
+ // 浜у搧 ID
+ public static String ESetId { get; set; }
+ private static String userId = '';
+ //private String[] ProidListAll = new String[]{};
+ public static List<SelectOption> categoryOptionList { get; set; }
+ public static List<SelectOption> category4OptionList { get; set; }
+ public static List<SelectOption> category5OptionList { get; set; }
+ public static List<CusOption> category3Option { get; set; }
+ public static List<CusOption> category4Option { get; set; }
+ public static List<CusOption> category5Option { get; set; }
+ private static Map<Id, Dealer_Product__c> DealerProductMap = new Map<Id, Dealer_Product__c>();
+ public static List<String> orderzaikuId = new List<String>();
+ //鍒嗛〉鍔熻兘
+ public static Integer size { get; set; }
+ public static Integer pageLimit { get; set; }
+ public static Integer noOfRecords { get; set; }
+ public static ApexPages.StandardSetController con { get; set; }
+ public static String soql { get; set; }
+ // 鐧诲綍鑰呭伐浣滃湴
+ private static String userWorkLocation;
+ public static String agencyProType { get; set; }
+ public static String agencyProType1 { get; set; } //lt 20230526 瀹夊窘涓ょエ鍒� add
+ private static Boolean OSHFLG; //lt 20230517 瀹夊窘涓ょエ鍒� add
+ public static String methodType { get; set; }
+ public static String hospitalName { get; set; }
+ public static String hospitalId { get; set; }
+ public static String tempidHp { get; set; }
+ public static String tempidPp { get; set; }
+ private static List<String> hpids = new List<String>();
+ private static Boolean isfirst = false;
+ //鎶ラ敊鍜岃鍛婁俊鎭�
+ public static List<String> errorMsgList = new List<String>();
+ public static List<String> warningMsgList = new List<String>();
+ //鏋勯�犳柟娉�
+ public LexConsumableController() {
+ baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
+ consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ DealerProductId = new List<String>();
+ attachmentRecoeds = new List<ConsumableorderdetailsInfo>();
+ consumableorderdetailsRecordsview = new List<ConsumableorderdetailsInfo>();
+ editAble = false;
+ edoffersPrice = false;
+ returnOrder = false;
+ categoryOptionList = new List<SelectOption>();
+ category4OptionList = new List<SelectOption>();
+ category5OptionList = new List<SelectOption>();
+ size = Integer.valueOf(System.Label.orderdetLimitsize);
+ pageLimit = Integer.valueOf(System.Label.orderdetPageLimitsize);
+ }
+
+ private static void initStandardController() {
+ con = new ApexPages.StandardSetController(Database.getQueryLocator(soql));
+ con.setPageSize(size);
+ noOfRecords = con.getResultSize();
+ }
+
+ public static List<Product2__c> product2s() {
+ return (List<Product2__c>) con.getRecords();
+ }
+
+ private static List<ConsumableorderdetailsInfo> getPageInfo() {
+ List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
+ Map<String, String> selectedIdMap = new Map<String, String>();
+
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecordsview) {
+ if (ass.check == true) {
+ selectedIdMap.put(ass.Prod.id, ass.Prod.id);
+ reSet.add(ass);
+ }
+ }
+
+ consumableorderdetailsRecordsview = new List<ConsumableorderdetailsInfo>();
+ if (editAble) {
+ consumableorderdetailsRecordsview = reSet;
+ }
+ Integer pagestartNo = (con.getPageNumber() * size) - size;
+ Integer pageendNo = (con.getPageNumber() * size) > noOfRecords
+ ? noOfRecords
+ : (con.getPageNumber() * size - 1);
+ Integer addNo = 0;
+ for (
+ Integer i = pagestartNo; i < consumableorderdetailsRecords.size(); i++
+ ) {
+ Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c();
+ if (selectedIdMap.containsKey(consumableorderdetailsRecords[i].Prod.Id)) {
+ addNo++;
+ //continue;
+ }
+ // else if (consumableorderdetailsRecordsview.size() >= pageLimit + size) {
+ // break;
+ // }
+ else {
+ if (consumableorderdetailsRecords[i].check == false) {
+ consumableorderdetailsRecords[i].esd = orderdetails1;
+ }
+ //consumableorderdetailsRecords[i].esd.Dealer_Custom_Price__c = consumableorderdetailsRecords[i].Prod.Intra_Trade_List_RMB__c * disCount / 100;
+ consumableorderdetailsRecordsview.add(consumableorderdetailsRecords[i]);
+ addNo++;
+ }
+ // if (addNo >= size)
+ // break;
+ }
+ return consumableorderdetailsRecordsview;
+ }
+
+ @AuraEnabled
+ public static Results init(String type, String esetId, String keywordStr) {
+ Results results = new Results();
+ results.isNoteStay = LexUtility.getIsNoteStay();
+ errorMsgList = new List<String>();
+ warningMsgList = new List<String>();
+ baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
+ consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ DealerProductId = new List<String>();
+ attachmentRecoeds = new List<ConsumableorderdetailsInfo>();
+ consumableorderdetailsRecordsview = new List<ConsumableorderdetailsInfo>();
+ editAble = false;
+ edoffersPrice = false;
+ returnOrder = false;
+ categoryOptionList = new List<SelectOption>();
+ category4OptionList = new List<SelectOption>();
+ category5OptionList = new List<SelectOption>();
+ size = Integer.valueOf(System.Label.orderdetLimitsize);
+ pageLimit = Integer.valueOf(System.Label.orderdetPageLimitsize);
+ ESetId = esetId;
+ methodType = type;
+ if (String.isBlank(methodType) && String.isNotBlank(ESetId)) {
+ List<Consumable_order__c> oclist = [
+ SELECT orderPattern__c
+ FROM Consumable_order__c
+ WHERE id = :ESetid
+ ];
+ methodType = oclist.get(0).orderPattern__c;
+ }
+ statusEdit = keywordStr;
+ System.debug('Param:' + ESetId + '---' + methodType + '---' + statusEdit);
+ try {
+ sortKey = '1';
+ preSortKey = '1';
+ sortOrderAsc = false;
+ sortOrder = new String[8];
+ sortOrder = new List<String>{ ' ', ' ', ' ', ' ', '鈫�', '', '', '' };
+ cate1ForSort = '';
+ decisionCode = '';
+ sumPrice = 0;
+ specialCampaign = false;
+ if (
+ ESetId != null &&
+ ESetId != '' &&
+ statusEdit == '' &&
+ statusEdit == null
+ ) {
editAble = false;
- edoffersPrice = false;
- returnOrder = false;
- categoryOptionList = new List<SelectOption>();
- category4OptionList = new List<SelectOption>();
- category5OptionList = new List<SelectOption>();
- size = Integer.valueOf(System.Label.orderdetLimitsize);
- pageLimit = Integer.valueOf(System.Label.orderdetPageLimitsize);
- }
-
- private static void initStandardController() {
- con = new ApexPages.StandardSetController(Database.getQueryLocator(soql));
- con.setPageSize(size);
- noOfRecords = con.getResultSize();
- }
-
- public static List<Product2__c> product2s() {
- return (List<Product2__c>) con.getRecords();
- }
-
- private static List<ConsumableorderdetailsInfo> getPageInfo() {
- List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
- Map<String, String> selectedIdMap = new Map<String, String>();
-
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecordsview) {
- if (ass.check == true) {
- selectedIdMap.put(ass.Prod.id, ass.Prod.id);
- reSet.add(ass);
- }
- }
-
- consumableorderdetailsRecordsview = new List<ConsumableorderdetailsInfo>();
- if (editAble) {
- consumableorderdetailsRecordsview = reSet;
- }
- Integer pagestartNo = (con.getPageNumber() * size) - size;
- Integer pageendNo = (con.getPageNumber() * size) > noOfRecords ? noOfRecords : (con.getPageNumber() * size - 1);
- Integer addNo = 0;
- for (Integer i = pagestartNo; i < consumableorderdetailsRecords.size(); i++) {
- Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c();
- if (selectedIdMap.containsKey(consumableorderdetailsRecords[i].Prod.Id)) {
- addNo++;
- //continue;
- }
- // else if (consumableorderdetailsRecordsview.size() >= pageLimit + size) {
- // break;
- // }
- else {
- if (consumableorderdetailsRecords[i].check == false) {
- consumableorderdetailsRecords[i].esd = orderdetails1;
- }
- //consumableorderdetailsRecords[i].esd.Dealer_Custom_Price__c = consumableorderdetailsRecords[i].Prod.Intra_Trade_List_RMB__c * disCount / 100;
- consumableorderdetailsRecordsview.add(consumableorderdetailsRecords[i]);
- addNo++;
- }
- // if (addNo >= size)
- // break;
- }
- return consumableorderdetailsRecordsview;
- }
-
- @AuraEnabled
- public static Results init(String type, String esetId, String keywordStr) {
- Results results = new Results();
- results.isNoteStay = LexUtility.getIsNoteStay();
- errorMsgList = new List<String>();
- warningMsgList = new List<String>();
- baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
- consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- DealerProductId = new List<String>();
- attachmentRecoeds = new List<ConsumableorderdetailsInfo>();
- consumableorderdetailsRecordsview = new List<ConsumableorderdetailsInfo>();
- editAble = false;
- edoffersPrice = false;
- returnOrder = false;
- categoryOptionList = new List<SelectOption>();
- category4OptionList = new List<SelectOption>();
- category5OptionList = new List<SelectOption>();
- size = Integer.valueOf(System.Label.orderdetLimitsize);
- pageLimit = Integer.valueOf(System.Label.orderdetPageLimitsize);
- ESetId = esetId;
- methodType = type;
- if(String.isBlank(methodType) && String.isNotBlank(ESetId)){
- List<Consumable_order__c> oclist = [SELECT orderPattern__c FROM Consumable_order__c WHERE id = :ESetid];
- methodType = oclist.get(0).orderPattern__c;
- }
- statusEdit = keywordStr;
- System.debug('Param:'+ESetId+'---'+methodType+'---'+statusEdit);
- try {
- sortKey = '1';
- preSortKey = '1';
- sortOrderAsc = false;
- sortOrder = new String[8];
- sortOrder = new List<String>{ ' ', ' ', ' ', ' ', '鈫�', '', '', '' };
- cate1ForSort = '';
- decisionCode = '';
- sumPrice = 0;
- specialCampaign = false;
- if (ESetId != null && ESetId != '' && statusEdit == '' && statusEdit == null) {
- editAble = false;
- } else if ((ESetId == null || ESetId == '') && (statusEdit == '' || statusEdit == null)) {
- editAble = true;
- } else if (ESetId != null && ESetId != '' && statusEdit != '' && statusEdit != null) {
- editAble = true;
- }
- userId = UserInfo.getUserId();
- List<user> Useracc = new List<user>();
- //lt 20230517 瀹夊窘涓ょエ鍒� add ,OSHFLG__c
- Useracc = [SELECT accountid, Work_Location__c,UserPro_Type__c,OSHFLG__c FROM user WHERE id = :userId ];
- accountid = Useracc[0].accountid;
- userWorkLocation = Useracc[0].Work_Location__c;
- agencyProType = Useracc[0].UserPro_Type__c;
- agencyProType1 = Useracc[0].UserPro_Type__c; //lt 20230526 瀹夊窘涓ょエ鍒� add
- //lt 20230526 瀹夊窘涓ょエ鍒� start
- OSHFLG = Useracc[0].OSHFLG__c; //lt 20230517 瀹夊窘涓ょエ鍒� add
- if(OSHFLG){
- agencyProType1 = 'OSH';
- }
- else if(String.isBlank(Useracc[0].UserPro_Type__c)){
- agencyProType1 = 'ET';
- }
- //lt 20230526 瀹夊窘涓ょエ鍒� end
- if (String.isBlank(Useracc[0].UserPro_Type__c)) {
- agencyProType = 'ET';
- }
- //閿欒淇℃伅鎻愮ず
- if (String.isNotBlank(methodType) && methodType.equals('hospitalorder') && agencyProType == 'ET') {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '鎮ㄦ病鏈夎璐у尰闄㈢壒浠蜂骇鍝佺殑鏉冮檺!'));
- errorMsgList.add('鎮ㄦ病鏈夎璐у尰闄㈢壒浠蜂骇鍝佺殑鏉冮檺!');
- }
- contactDealer = new List<String>();
- Date dateToday = Date.today();
- //鏌ヨ缁忛攢鍟嗕笅鎵�鏈夋湁鏁堝悎鍚�
- List<Account> contractList = [
- SELECT Id, Name, RecordType.DeveloperName
- FROM Account
- WHERE
- RecordType.DeveloperName = 'AgencyContract'
- AND Contract_Decide_Start_Date__c <= :dateToday
- AND Contract_Decide_End_Date__c >= :dateToday
- and Contact_Type__c like :agencyProType1//lt 20230517 瀹夊窘涓ょエ鍒� add 1
- and Agent_Ref__c =:accountid
- and OSH_Dealer__c =: OSHFLG //lt 20230517 瀹夊窘涓ょエ鍒� add
- ];
- for (Account contract : contractList) {
- contactDealer.add(contract.Id);
- }
- DealerProductMap = new Map<Id, Dealer_Product__c>();
- DealerProductId = getDealerProductId();
- Account accountInfo = [
- SELECT Name, Dealer_discount__c, Product_Limit_Date__c, Product_Limit_DateENG__c
- FROM account
- WHERE id = :accountid
- ];
- accountName = accountInfo.Name;
- String product_Limit;
- if (agencyProType == 'ET') {
- product_Limit = accountInfo.Product_Limit_Date__c;
- } else {
- product_Limit = accountInfo.Product_Limit_DateENG__c;
- }
- if (product_Limit != null && product_Limit != '') {
- proLimitAndDate = product_Limit.split(',');
- }
- saveBtnDisabled = false;
- sorderBtnDisabled = false;
- coc = new Consumable_order__c();
- consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- if (String.isBlank(agencyProType)) {
- //return ;
- }
- List<Product2__c> Product2Selected = new List<Product2__c>();
- Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>();
- //缁忛攢鍟嗗湪搴撴暟鎹�
- List<Consumable_order_details2__c> countDel = [
- SELECT
- Id,
- Bar_Code__c,
- Name,
- Inventory_date__c,
- Consumable_Product__c,
- Consumable_Product__r.Asset_Model_No__c,
- Recordtypeid,
- Box_Piece__c,
- hospitalSpecialOffer__c,
- promotionorder__c
- 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 Lose_Flag__c = FALSE
- AND Cancellation_Flag__c = FALSE
- AND Bar_Code__c != NULL
- AND Isoverdue__c = 1
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- AND Dealer_Info_text__c = :accountName
- ];
- if (ESetId == null || ESetId == '') {
- //鑾峰彇缁忛攢鍟嗛粯璁ょ殑涓�涓悎鍚�
- List<Account> contract = [
- SELECT id, Name, State_Master__c, State_Master__r.Name
- FROM Account
- WHERE
- ParentId = :accountid
- AND Contact_Type__c like :agencyProType1 //lt 20230517 瀹夊窘涓ょエ鍒� add 1
- AND Contract_Decide_Start_Date__c <= :Date.Today()
- AND Contract_Decide_End_Date__c >= :Date.Today()
- AND OSH_Dealer__c =: OSHFLG //lt 20230517 瀹夊窘涓ょエ鍒� add
- ];
- if (contract.size() == 1) {
- contractName = contract[0].Name;
- contractId = contract[0].Id;
- }
- editDelCommitBtnDisabled = true;
- List<String> DealerProductId = new List<String>();
- soql = makeSoql('', '', '', '', '', false, DealerProductId);
- size = Integer.valueOf(System.Label.orderdetLimitsize);
- initStandardController();
- product2Selected = Database.query(soql);
-
- for (Integer i = 0; i < product2Selected.size(); i++) {
- consumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(product2Selected[i]));
- MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
- }
- //鍙湁鍦ㄥ崗璁璐ф椂浼氳蛋杩欎釜for寰幆 鍏朵粬涓ょ璁㈣揣妯″紡閮借蛋鐨剆earchorderdetails鏂规硶
- if (String.isBlank(methodType) || (!methodType.equals('promotionorder') && !methodType.equals('hospitalorder'))) {
- for (Integer i = 0; i < countDel.size(); i++) {
- if (countDel[i].promotionorder__c == false && countDel[i].hospitalSpecialOffer__c == false) {
- if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
- ConsumableorderdetailsInfo Jstage = MidMap.get(countDel[i].Consumable_Product__c);
- if (countDel[i].Box_Piece__c == '鐩�') {
- Jstage.allnumber = Jstage.allnumber + 1;
- } else {
- Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
- }
- MidMap.put(countDel[i].Consumable_Product__c, Jstage);
- }
- }
- }
- }
- consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- //缁忛攢鍟嗗畾浠� 璁$畻
- for (ConsumableorderdetailsInfo bss : MidMap.values()) {
- bss.sortBy = sortOrderAsc;
- bss.packing_list = Integer.valueOf(bss.Prod.Product2__r.Packing_list_manual__c);
- bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
- bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
- if (DealerProductMap.containsKey(bss.Prod.Id)) {
- bss.SpecialCampaignPrice = DealerProductMap.get(bss.Prod.Id).Special_Campaign_Price__c;
- bss.Campaign_EndDate = DealerProductMap.get(bss.Prod.Id).Campaign_EndDate__c;
- bss.orderGoods_Limit = DealerProductMap.get(bss.Prod.Id).OrderGoods_Limit__c;
- }
- consumableorderdetailsRecords.add(bss);
- }
- consumableorderdetailsRecords.sort();
- if (methodType != null && methodType != '' && (methodType.equals('hospitalorder') || methodType.equals('promotionorder'))) {
- searchorderdetails(methodType,accountid,hospitalId,contractId,userWorkLocation,accountName,proLimitAndDate,editAble);
- isfirst = true;
- }
- getPageInfo();
- } else {
- if (methodType != null && methodType.equals('hospitalorder')) {
- List<Consumable_order__c> oclist = [
- SELECT orderPattern__c, Order_ForHospital__c, Order_ForHospital__r.Name
- FROM Consumable_order__c
- WHERE id = :ESetid
- ];
- if (oclist.get(0).orderPattern__c.equals('hospitalorder')) {
- hospitalName = oclist.get(0).Order_ForHospital__r.Name;
- hospitalId = oclist.get(0).Order_ForHospital__c;
- }
- }
- List<Consumable_Orderdetails__c> ConsumableorderdetailsSelected = new List<Consumable_Orderdetails__c>();
- //淇敼
- List<Consumable_order__c> qs = new List<Consumable_order__c>();
- qs = [
- SELECT
- Id,
- Name,
- Order_status__c,
- Consumable_pdf_insert_day__c,
- Dealer_Info__c,
- Deliver_date__c,
- Order_Reason__c,
- Order_date__c,
- Contract_application_decision__c,
- Total_amount__c,
- Offers_Price__c,
- Order_effective_contact__c,
- Order_effective_contact__r.Name
- FROM Consumable_order__c
- WHERE Id = :ESetId AND Order_Owner_WorkLocal__c = :userWorkLocation
- ];
- if (qs.size() > 0) {
- coc = qs[0];
- decisionCode = coc.Contract_application_decision__c;
- contractName = coc.Order_effective_contact__r.Name;
- contractId = coc.Order_effective_contact__r.Id;
- }
- if (qs[0].Order_status__c == '宸叉彁浜�' || qs[0].Order_status__c == '鎵瑰噯' || qs[0].Order_status__c == '闄勪欢涓婁紶瀹屾垚') {
- saveBtnDisabled = true;
- sorderBtnDisabled = true;
- editDelCommitBtnDisabled = false;
- }
- // 閬告姙娓堛伩銇槑缁嗐倰鍙栧緱
- ConsumableorderdetailsSelected = [
- SELECT
- Id,
- Name,
- Consumable_order__c,
- Consumable_Product__r.Name__c,
- Consumable_Product__c,
- Consumable_Product__r.Name,
- Consumable_Count__c,
- Consumable_Product__r.Category3__c,
- Consumable_Product__r.Category4__c,
- Consumable_Product__r.Category5__c,
- Consumable_Product__r.Intra_Trade_List_RMB__c,
- Consumable_Product__r.Asset_Model_No__c,
- Sum_of_money__c,
- Consumable_Product__r.SFDA_Status__c,
- Consumable_Product__r.Product2__r.Packing_list_manual__c,
- Consumable_Product__r.Product2__r.SFDA_Approbation_No__c,
- Consumable_Product__r.Product2__r.SFDA_Expiration_Date__c
- FROM Consumable_Orderdetails__c
- WHERE
- recordtypeid = :System.Label.RT_ConOrderDetail1_Order
- AND Consumable_order__c = :ESetId
- AND Order_Owner_WorkLocal__c = :userWorkLocation
- AND Consumable_order__r.Dealer_Info__c = :accountid
- ];
- for (Consumable_Orderdetails__c cdc1 : ConsumableorderdetailsSelected) {
- if(cdc1.Consumable_Product__c != null){
- orderzaikuId.add(cdc1.Consumable_Product__c);
- }
- }
- soql = makeSoqlorderdet();
- System.debug('soql:'+soql);
- size = orderzaikuId.size();
- initStandardController();
- product2Selected = Database.query(soql);
- for (Integer i = 0; i < product2Selected.size(); i++) {
- MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
- }
- for (Integer i = 0; i < countDel.size(); i++) {
- //add by rentx 2020-12-09
- if (String.isNotBlank(methodType) && methodType.equals('hospitalorder')) {
- if (countDel[i].hospitalSpecialOffer__c == true) {
- //鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
- if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
- ConsumableorderdetailsInfo Jstage = MidMap.get(countDel[i].Consumable_Product__c);
- if (countDel[i].Box_Piece__c == '鐩�') {
- Jstage.allnumber = Jstage.allnumber + 1;
- } else {
- Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
- }
- MidMap.put(countDel[i].Consumable_Product__c, Jstage);
- }
- }
- } else if (String.isBlank(methodType) || methodType.equals('promotionorder')) {
- if (countDel[i].promotionorder__c == true) {
- if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
- ConsumableorderdetailsInfo Jstage = MidMap.get(countDel[i].Consumable_Product__c);
- if (countDel[i].Box_Piece__c == '鐩�') {
- Jstage.allnumber = Jstage.allnumber + 1;
- } else {
- Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
- }
- MidMap.put(countDel[i].Consumable_Product__c, Jstage);
- }
- }
- } else if (
- String.isBlank(methodType) || (!methodType.equals('promotionorder') && !methodType.equals('hospitalorder'))
- ) {
- if (countDel[i].promotionorder__c == false && countDel[i].hospitalSpecialOffer__c == false) {
- if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
- ConsumableorderdetailsInfo Jstage = MidMap.get(countDel[i].Consumable_Product__c);
- if (countDel[i].Box_Piece__c == '鐩�') {
- Jstage.allnumber = Jstage.allnumber + 1;
- } else {
- Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
- }
- MidMap.put(countDel[i].Consumable_Product__c, Jstage);
- }
- }
- }
- }
- consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecords
- for (ConsumableorderdetailsInfo bss : MidMap.values()) {
- bss.packing_list = Integer.valueOf(bss.Prod.Product2__r.Packing_list_manual__c);
- bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
- bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
- if (DealerProductMap.containsKey(bss.Prod.Id)) {
- bss.SpecialCampaignPrice = DealerProductMap.get(bss.Prod.Id).Special_Campaign_Price__c;
- bss.Campaign_EndDate = DealerProductMap.get(bss.Prod.Id).Campaign_EndDate__c;
- bss.orderGoods_Limit = DealerProductMap.get(bss.Prod.Id).OrderGoods_Limit__c;
- }
- consumableorderdetailsRecords.add(bss);
- }
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
- ass.sortBy = sortOrderAsc;
- for (Consumable_Orderdetails__c cdc1 : ConsumableorderdetailsSelected) {
- sumPrice += cdc1.Sum_of_money__c;
- if (ass.prod.Id == cdc1.Consumable_Product__c) {
- ass.check = true;
- ass.esd = cdc1;
- }
- }
- }
- //闄勪欢
- // attachmentinfo = [SELECT Id, Name, OwnerId, Owner.Name FROM Attachment WHERE parentid = :ESetId];
- // if (attachmentinfo.size() > 0) {
- // for (Integer i = 0; i < attachmentinfo.size(); i++) {
- // attachmentRecoeds.add(new ConsumableorderdetailsInfo(attachmentinfo[i]));
- // }
- // }
- List<ContentVersion> cvInfo = [SELECT Id, Title, OwnerId,Owner.Name, CreatedDate,ContentDocumentId FROM ContentVersion WHERE FirstPublishLocationId = :ESetId];
- if (cvInfo.size() > 0) {
- for (Integer i = 0; i < cvInfo.size(); i++) {
- attachmentRecoeds.add(new ConsumableorderdetailsInfo(cvInfo[i]));
- }
- }
- //
- consumableorderdetailsRecords.sort();
- getPageInfo();
- }
- //璁$畻搴撳瓨涓娿�佷笅闄�
- productLimtAndDate();
- lowerRecord();
- //鏄庣粏鎺掑簭
- List<String> upper = new List<String>();
- if (String.isNotBlank(ESetid)) {
- for (ConsumableorderdetailsInfo bss : consumableorderdetailsRecords) {
- if(bss.esd.Consumable_count__c != null && bss.allnumber != null && bss.upperlimit != null){
- if (bss.esd.Consumable_count__c + bss.allnumber > bss.upperlimit) {
- upper.add(bss.esd.Consumable_Product__r.Name__c);
- }
- }
- }
- }
- if (upper.size() > 0) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, '瀛樺湪浠ヤ笅浜у搧璁㈣揣鏁伴噺瓒呭嚭搴撳瓨涓婇檺!'));
- warningMsgList.add('瀛樺湪浠ヤ笅浜у搧璁㈣揣鏁伴噺瓒呭嚭搴撳瓨涓婇檺!');
- for (Integer i = 0; i < upper.size(); i++) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, upper[i]));
- warningMsgList.add(upper[i]);
- }
- }
- if (lower.size() > 0) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, '瀛樺湪浠ヤ笅浜у搧璁㈣揣鏁伴噺浣庝簬搴撳瓨涓嬮檺!'));
- warningMsgList.add('瀛樺湪浠ヤ笅浜у搧璁㈣揣鏁伴噺浣庝簬搴撳瓨涓嬮檺!');
- for (Integer i = 0; i < lower.size(); i++) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, lower[i]));
- warningMsgList.add(lower[i]);
- }
- }
- //浠锋牸鏌ョ湅鏉冮檺
- Schema.DescribeFieldResult dfr = Product2__c.Intra_Trade_List_RMB__c.getDescribe();
- cansee = dfr.isAccessible();
- AggregateResult[] categoryList = [
- SELECT Count(id), Category3_text__c c3c
- FROM Product2__c
- WHERE Estimation_Entry_Possibility__c = '鈼�' AND Product_Type__c LIKE :agencyProType AND Category3_text__c != NULL
- GROUP BY Category3_text__c
- ];
- //categoty3
- // categoryOptionList = new List<SelectOption>();
- category3Option = new List<CusOption>();
- // categoryOptionList.add(new SelectOption('', '-鏃�-'));
- category3Option.add(new CusOption('-鏃�-',''));
- for (AggregateResult category3Search : categoryList) {
- String deliverycnt = String.valueOf(category3Search.get('c3c'));
- // categoryOptionList.add(new SelectOption(deliverycnt, deliverycnt));
- category3Option.add(new CusOption(deliverycnt,deliverycnt));
- }
- //categoty4
- // category4OptionList = new List<SelectOption>();
- category4Option = new List<CusOption>();
- // category4OptionList.add(new SelectOption('', '-鏃�-'));
- category4Option.add(new CusOption('-鏃�-',''));
- //categoty5
- // category5OptionList = new List<SelectOption>();
- category5Option = new List<CusOption>();
- // category5OptionList.add(new SelectOption('', '-鏃�-'));
- category5Option.add(new CusOption('-鏃�-',''));
- //return msg
- consumableorderdetailsRecordsview = consumableorderdetailsRecords;
- getConsumableShowTableFieldValue();
- results.result = 'Success';
- results.coc = coc;
- results.editAble = editAble;
- results.edoffersPrice = edoffersPrice;
- results.editDelCommitBtnDisabled = EditDelCommitBtnDisabled;
- results.category3Option = category3Option;
- results.category4Option = category4Option;
- results.category5Option = category5Option;
- results.hospitalName = hospitalName;
- results.contractName = contractName;
- results.consumableorderdetailsRecordsview = consumableorderdetailsRecordsview;
- results.attachmentRecoeds = attachmentRecoeds;
- results.cansee = cansee;
- results.agencyProType = agencyProType;
- results.agencyProType1 = agencyProType1;
- results.OSHFLG = OSHFLG;
- results.userWorkLocation = userWorkLocation;
- results.accountName = accountName;
- results.category_Goods = category_Goods;
- results.specialCampaign = specialCampaign;
- results.dealerProductId = DealerProductId;
- results.accountid = accountid;
- results.hospitalId = hospitalId;
- results.contractId = contractId;
- results.contactDealer = contactDealer;
- results.errorMsgList = errorMsgList;
- results.warningMsgList = warningMsgList;
- results.methodType = methodType;
- results.proLimitAndDate = proLimitAndDate;
- } catch (Exception e) {
- results.result = 'Fail';
- results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
- }
- return results;
- }
-
- @AuraEnabled
- public static Results categoryAllload(String agencyProTypeStr, String category3Str){
- Results results = new Results();
- agencyProType = agencyProTypeStr;
- category3 = category3Str;
- try {
- AggregateResult[] category4List = [
- SELECT Count(id), Category4_text__c c4c
- FROM Product2__c
- WHERE
- Estimation_Entry_Possibility__c = '鈼�'
- AND Product_Type__c LIKE :agencyProType
- AND Category3_text__c = :category3
- AND Category4_text__c != NULL
- AND Category5_text__c != NULL
- GROUP BY Category4_text__c
- ];
- // category4OptionList = new List<SelectOption>();
- category4Option = new List<CusOption>();
- // category4OptionList.add(new SelectOption('', '-鏃�-'));
- category4Option.add(new CusOption('-鏃�-', ''));
- for (AggregateResult category4Search : category4List) {
- String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
- // category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
- category4Option.add(new CusOption(deliverycnt4, deliverycnt4));
- }
- AggregateResult[] category5List = [
- SELECT Count(id), Category5_text__c c5c
- FROM Product2__c
- WHERE
- Estimation_Entry_Possibility__c = '鈼�'
- AND Product_Type__c LIKE :agencyProType
- AND Category3_text__c = :category3
- AND Category4_text__c != NULL
- AND Category5_text__c != NULL
- GROUP BY Category5_text__c
- ];
- // category5OptionList = new List<SelectOption>();
- category5Option = new List<CusOption>();
- // category5OptionList.add(new SelectOption('', '-鏃�-'));
- category5Option.add(new CusOption('-鏃�-', ''));
- for (AggregateResult category5Search : category5List) {
- String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
- // category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
- category5Option.add(new CusOption(deliverycnt5, deliverycnt5));
- }
- results.category4Option = category4Option;
- results.category5Option = category5Option;
- results.result = 'Success';
- } catch (Exception e) {
- results.result = 'Fail';
- results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
- }
- return results;
- }
-
- @AuraEnabled
- public static Results categoryload(String agencyProTypeStr, String category3Str, String category4Str){
- Results results = new Results();
- agencyProType = agencyProTypeStr;
- category3 = category3Str;
- category4 = category4Str;
- try {
- AggregateResult[] category4List = [
- SELECT Count(id), Category4_text__c c4c
- FROM Product2__c
- WHERE
- Estimation_Entry_Possibility__c = '鈼�'
- AND Product_Type__c LIKE :agencyProType
- AND Category3_text__c = :category3
- AND Category4_text__c != NULL
- AND Category5_text__c != NULL
- GROUP BY Category4_text__c
- ];
- // category4OptionList = new List<SelectOption>();
- category4Option = new List<CusOption>();
- // category4OptionList.add(new SelectOption('', '-鏃�-'));
- category4Option.add(new CusOption('-鏃�-', ''));
- for (AggregateResult category4Search : category4List) {
- String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
- // category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
- category4Option.add(new CusOption(deliverycnt4, deliverycnt4));
- }
-
- AggregateResult[] category5List = [
- SELECT Count(id), Category5_text__c c5c
- FROM Product2__c
- WHERE
- Estimation_Entry_Possibility__c = '鈼�'
- AND Product_Type__c LIKE :agencyProType
- AND Category3_text__c = :category3
- AND Category4_text__c = :category4
- AND Category5_text__c != NULL
- GROUP BY Category5_text__c
- ];
- // category5OptionList = new List<SelectOption>();
- category5Option = new List<CusOption>();
- // category5OptionList.add(new SelectOption('', '-鏃�-'));
- category5Option.add(new CusOption('-鏃�-', ''));
- for (AggregateResult category5Search : category5List) {
- String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
- // category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
- category5Option.add(new CusOption(deliverycnt5, deliverycnt5));
- }
- results.category4Option = category4Option;
- results.category5Option = category5Option;
- results.result = 'Success';
- } catch (Exception e) {
- results.result = 'Fail';
- results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
- }
- return results;
- }
-
- // 鐢婚潰鍒濆鍖�
- public static void lowerRecord() {
- List<ConsumableorderdetailsInfo> lowerRecord = new List<ConsumableorderdetailsInfo>();
- //搴撳瓨鏄庣粏鍙栧緱
- Map<String, ConsumableorderdetailsInfo> midMaprecord = new Map<String, ConsumableorderdetailsInfo>();
- List<Product2__c> product2Selected = [
- SELECT Id, Name, Name__c, Intra_Trade_List_RMB__c, Asset_Model_No__c
- FROM Product2__c
- WHERE Pro2_Dealer_Object__c = TRUE AND Estimation_Entry_Possibility__c = '鈼�'
+ } else if (
+ (ESetId == null || ESetId == '') &&
+ (statusEdit == '' ||
+ statusEdit == null)
+ ) {
+ editAble = true;
+ } else if (
+ ESetId != null &&
+ ESetId != '' &&
+ statusEdit != '' &&
+ statusEdit != null
+ ) {
+ editAble = true;
+ }
+ userId = UserInfo.getUserId();
+ List<user> Useracc = new List<user>();
+ //lt 20230517 瀹夊窘涓ょエ鍒� add ,OSHFLG__c
+ Useracc = [
+ SELECT accountid, Work_Location__c, UserPro_Type__c, OSHFLG__c
+ FROM user
+ WHERE id = :userId
+ ];
+ accountid = Useracc[0].accountid;
+ userWorkLocation = Useracc[0].Work_Location__c;
+ agencyProType = Useracc[0].UserPro_Type__c;
+ agencyProType1 = Useracc[0].UserPro_Type__c; //lt 20230526 瀹夊窘涓ょエ鍒� add
+ //lt 20230526 瀹夊窘涓ょエ鍒� start
+ OSHFLG = Useracc[0].OSHFLG__c; //lt 20230517 瀹夊窘涓ょエ鍒� add
+ if (OSHFLG) {
+ agencyProType1 = 'OSH';
+ } else if (String.isBlank(Useracc[0].UserPro_Type__c)) {
+ agencyProType1 = 'ET';
+ }
+ //lt 20230526 瀹夊窘涓ょエ鍒� end
+ if (String.isBlank(Useracc[0].UserPro_Type__c)) {
+ agencyProType = 'ET';
+ }
+ //閿欒淇℃伅鎻愮ず
+ if (
+ String.isNotBlank(methodType) &&
+ methodType.equals('hospitalorder') &&
+ agencyProType == 'ET'
+ ) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '鎮ㄦ病鏈夎璐у尰闄㈢壒浠蜂骇鍝佺殑鏉冮檺!'));
+ errorMsgList.add('鎮ㄦ病鏈夎璐у尰闄㈢壒浠蜂骇鍝佺殑鏉冮檺!');
+ }
+ contactDealer = new List<String>();
+ Date dateToday = Date.today();
+ //鏌ヨ缁忛攢鍟嗕笅鎵�鏈夋湁鏁堝悎鍚�
+ List<Account> contractList = [
+ SELECT Id, Name, RecordType.DeveloperName
+ FROM Account
+ WHERE
+ RecordType.DeveloperName = 'AgencyContract'
+ AND Contract_Decide_Start_Date__c <= :dateToday
+ AND Contract_Decide_End_Date__c >= :dateToday
+ AND Contact_Type__c LIKE :agencyProType1 //lt 20230517 瀹夊窘涓ょエ鍒� add 1
+ AND Agent_Ref__c = :accountid
+ AND OSH_Dealer__c = :OSHFLG //lt 20230517 瀹夊窘涓ょエ鍒� add
+ ];
+ for (Account contract : contractList) {
+ contactDealer.add(contract.Id);
+ }
+ DealerProductMap = new Map<Id, Dealer_Product__c>();
+ DealerProductId = getDealerProductId();
+ Account accountInfo = [
+ SELECT
+ Name,
+ Dealer_discount__c,
+ Product_Limit_Date__c,
+ Product_Limit_DateENG__c
+ FROM account
+ WHERE id = :accountid
+ ];
+ accountName = accountInfo.Name;
+ String product_Limit;
+ if (agencyProType == 'ET') {
+ product_Limit = accountInfo.Product_Limit_Date__c;
+ } else {
+ product_Limit = accountInfo.Product_Limit_DateENG__c;
+ }
+ if (product_Limit != null && product_Limit != '') {
+ proLimitAndDate = product_Limit.split(',');
+ }
+ saveBtnDisabled = false;
+ sorderBtnDisabled = false;
+ coc = new Consumable_order__c();
+ consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ if (String.isBlank(agencyProType)) {
+ //return ;
+ }
+ List<Product2__c> Product2Selected = new List<Product2__c>();
+ Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>();
+ //缁忛攢鍟嗗湪搴撴暟鎹�
+ List<Consumable_order_details2__c> countDel = [
+ SELECT
+ Id,
+ Bar_Code__c,
+ Name,
+ Inventory_date__c,
+ Consumable_Product__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Recordtypeid,
+ Box_Piece__c,
+ hospitalSpecialOffer__c,
+ promotionorder__c
+ 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 Lose_Flag__c = FALSE
+ AND Cancellation_Flag__c = FALSE
+ AND Bar_Code__c != NULL
+ AND Isoverdue__c = 1
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Dealer_Info_text__c = :accountName
+ ];
+ if (ESetId == null || ESetId == '') {
+ //鑾峰彇缁忛攢鍟嗛粯璁ょ殑涓�涓悎鍚�
+ List<Account> contract = [
+ SELECT id, Name, State_Master__c, State_Master__r.Name
+ FROM Account
+ WHERE
+ ParentId = :accountid
+ AND Contact_Type__c LIKE :agencyProType1 //lt 20230517 瀹夊窘涓ょエ鍒� add 1
+ AND Contract_Decide_Start_Date__c <= :Date.Today()
+ AND Contract_Decide_End_Date__c >= :Date.Today()
+ AND OSH_Dealer__c = :OSHFLG //lt 20230517 瀹夊窘涓ょエ鍒� add
];
+ if (contract.size() == 1) {
+ contractName = contract[0].Name;
+ contractId = contract[0].Id;
+ }
+ editDelCommitBtnDisabled = true;
+ List<String> DealerProductId = new List<String>();
+ soql = makeSoql('', '', '', '', '', false, DealerProductId);
+ size = Integer.valueOf(System.Label.orderdetLimitsize);
+ initStandardController();
+ product2Selected = Database.query(soql);
+
for (Integer i = 0; i < product2Selected.size(); i++) {
- lowerRecord.add(new ConsumableorderdetailsInfo(product2Selected[i]));
- //鍏堟妸ConsumableorderdetailsRecords 鍋氭垚map
- midMaprecord.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
+ consumableorderdetailsRecords.add(
+ new ConsumableorderdetailsInfo(product2Selected[i])
+ );
+ MidMap.put(
+ product2Selected[i].Id,
+ new ConsumableorderdetailsInfo(product2Selected[i])
+ );
}
- List<Consumable_order_details2__c> countDel = [
+ //鍙湁鍦ㄥ崗璁璐ф椂浼氳蛋杩欎釜for寰幆 鍏朵粬涓ょ璁㈣揣妯″紡閮借蛋鐨剆earchorderdetails鏂规硶
+ if (
+ String.isBlank(methodType) ||
+ (!methodType.equals('promotionorder') &&
+ !methodType.equals('hospitalorder'))
+ ) {
+ for (Integer i = 0; i < countDel.size(); i++) {
+ if (
+ countDel[i].promotionorder__c == false &&
+ countDel[i].hospitalSpecialOffer__c == false
+ ) {
+ if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ countDel[i].Consumable_Product__c
+ );
+ if (countDel[i].Box_Piece__c == '鐩�') {
+ Jstage.allnumber = Jstage.allnumber + 1;
+ } else {
+ Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
+ }
+ MidMap.put(countDel[i].Consumable_Product__c, Jstage);
+ }
+ }
+ }
+ }
+ consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ //缁忛攢鍟嗗畾浠� 璁$畻
+ for (ConsumableorderdetailsInfo bss : MidMap.values()) {
+ bss.sortBy = sortOrderAsc;
+ bss.packing_list = Integer.valueOf(
+ bss.Prod.Product2__r.Packing_list_manual__c
+ );
+ bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
+ bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
+ if (DealerProductMap.containsKey(bss.Prod.Id)) {
+ bss.SpecialCampaignPrice = DealerProductMap.get(bss.Prod.Id)
+ .Special_Campaign_Price__c;
+ bss.Campaign_EndDate = DealerProductMap.get(bss.Prod.Id)
+ .Campaign_EndDate__c;
+ bss.orderGoods_Limit = DealerProductMap.get(bss.Prod.Id)
+ .OrderGoods_Limit__c;
+ }
+ consumableorderdetailsRecords.add(bss);
+ }
+ consumableorderdetailsRecords.sort();
+ if (
+ methodType != null &&
+ methodType != '' &&
+ (methodType.equals('hospitalorder') ||
+ methodType.equals('promotionorder'))
+ ) {
+ searchorderdetails(
+ methodType,
+ accountid,
+ hospitalId,
+ contractId,
+ userWorkLocation,
+ accountName,
+ proLimitAndDate,
+ editAble
+ );
+ isfirst = true;
+ }
+ getPageInfo();
+ } else {
+ if (methodType != null && methodType.equals('hospitalorder')) {
+ List<Consumable_order__c> oclist = [
SELECT
- Id,
- Bar_Code__c,
- Name,
- Inventory_date__c,
- Consumable_Product__c,
- Consumable_Product__r.Asset_Model_No__c,
- Recordtypeid,
- Guarantee_period_for_products__c,
- Isoverdue__c,
- Box_Piece__c,
- hospitalSpecialOffer__c,
- promotionorder__c
- 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 Lose_Flag__c = FALSE
- AND Bar_Code__c != NULL
- AND Isoverdue__c = 1
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- //AND Consumable_order_minor__r.Dealer_Info__c = :accountid
- AND Dealer_Info_text__c = :accountName
+ orderPattern__c,
+ Order_ForHospital__c,
+ Order_ForHospital__r.Name
+ FROM Consumable_order__c
+ WHERE id = :ESetid
+ ];
+ if (oclist.get(0).orderPattern__c.equals('hospitalorder')) {
+ hospitalName = oclist.get(0).Order_ForHospital__r.Name;
+ hospitalId = oclist.get(0).Order_ForHospital__c;
+ }
+ }
+ List<Consumable_Orderdetails__c> ConsumableorderdetailsSelected = new List<Consumable_Orderdetails__c>();
+ //淇敼
+ List<Consumable_order__c> qs = new List<Consumable_order__c>();
+ qs = [
+ SELECT
+ Id,
+ Name,
+ Order_status__c,
+ Consumable_pdf_insert_day__c,
+ Dealer_Info__c,
+ Deliver_date__c,
+ Order_Reason__c,
+ Order_date__c,
+ Contract_application_decision__c,
+ Total_amount__c,
+ Offers_Price__c,
+ Order_effective_contact__c,
+ Order_effective_contact__r.Name
+ FROM Consumable_order__c
+ WHERE Id = :ESetId AND Order_Owner_WorkLocal__c = :userWorkLocation
];
+ if (qs.size() > 0) {
+ coc = qs[0];
+ decisionCode = coc.Contract_application_decision__c;
+ contractName = coc.Order_effective_contact__r.Name;
+ contractId = coc.Order_effective_contact__r.Id;
+ }
+ if (
+ qs[0].Order_status__c == '宸叉彁浜�' ||
+ qs[0].Order_status__c == '鎵瑰噯' ||
+ qs[0].Order_status__c == '闄勪欢涓婁紶瀹屾垚'
+ ) {
+ saveBtnDisabled = true;
+ sorderBtnDisabled = true;
+ editDelCommitBtnDisabled = false;
+ }
+ // 閬告姙娓堛伩銇槑缁嗐倰鍙栧緱
+ ConsumableorderdetailsSelected = [
+ SELECT
+ Id,
+ Name,
+ Consumable_order__c,
+ Consumable_Product__r.Name__c,
+ Consumable_Product__c,
+ Consumable_Product__r.Name,
+ Consumable_Count__c,
+ Consumable_Product__r.Category3__c,
+ Consumable_Product__r.Category4__c,
+ Consumable_Product__r.Category5__c,
+ Consumable_Product__r.Intra_Trade_List_RMB__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Sum_of_money__c,
+ Consumable_Product__r.SFDA_Status__c,
+ Consumable_Product__r.Product2__r.Packing_list_manual__c,
+ Consumable_Product__r.Product2__r.SFDA_Approbation_No__c,
+ Consumable_Product__r.Product2__r.SFDA_Expiration_Date__c
+ FROM Consumable_Orderdetails__c
+ WHERE
+ recordtypeid = :System.Label.RT_ConOrderDetail1_Order
+ AND Consumable_order__c = :ESetId
+ AND Order_Owner_WorkLocal__c = :userWorkLocation
+ AND Consumable_order__r.Dealer_Info__c = :accountid
+ ];
+ for (Consumable_Orderdetails__c cdc1 : ConsumableorderdetailsSelected) {
+ if (cdc1.Consumable_Product__c != null) {
+ orderzaikuId.add(cdc1.Consumable_Product__c);
+ }
+ }
+ soql = makeSoqlorderdet();
+ System.debug('soql:' + soql);
+ size = orderzaikuId.size();
+ initStandardController();
+ product2Selected = Database.query(soql);
+ for (Integer i = 0; i < product2Selected.size(); i++) {
+ MidMap.put(
+ product2Selected[i].Id,
+ new ConsumableorderdetailsInfo(product2Selected[i])
+ );
+ }
for (Integer i = 0; i < countDel.size(); i++) {
- //add by rentx 2020-12-09
- if (String.isNotBlank(methodType) && methodType.equals('hospitalorder')) {
- if (countDel[i].hospitalSpecialOffer__c == true) {
- //鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
- if (midMaprecord.containsKey(countDel[i].Consumable_Product__c)) {
- ConsumableorderdetailsInfo Jstage = midMaprecord.get(countDel[i].Consumable_Product__c);
- if (countDel[i].Box_Piece__c == '鐩�') {
- Jstage.allnumber = Jstage.allnumber + 1;
- } else {
- Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
- }
- //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
- midMaprecord.put(countDel[i].Consumable_Product__c, Jstage);
- }
+ //add by rentx 2020-12-09
+ if (
+ String.isNotBlank(methodType) && methodType.equals('hospitalorder')
+ ) {
+ if (countDel[i].hospitalSpecialOffer__c == true) {
+ //鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
+ if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ countDel[i].Consumable_Product__c
+ );
+ if (countDel[i].Box_Piece__c == '鐩�') {
+ Jstage.allnumber = Jstage.allnumber + 1;
+ } else {
+ Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
}
- } else if (String.isBlank(methodType) || methodType.equals('promotionorder')) {
- if (countDel[i].promotionorder__c == true) {
- if (midMaprecord.containsKey(countDel[i].Consumable_Product__c)) {
- ConsumableorderdetailsInfo Jstage = midMaprecord.get(countDel[i].Consumable_Product__c);
- if (countDel[i].Box_Piece__c == '鐩�') {
- Jstage.allnumber = Jstage.allnumber + 1;
- } else {
- Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
- }
- midMaprecord.put(countDel[i].Consumable_Product__c, Jstage);
- }
- }
- } else if (String.isBlank(methodType) || (!methodType.equals('promotionorder') && !methodType.equals('hospitalorder'))) {
- if (countDel[i].promotionorder__c == false && countDel[i].hospitalSpecialOffer__c == false) {
- if (midMaprecord.containsKey(countDel[i].Consumable_Product__c)) {
- ConsumableorderdetailsInfo Jstage = midMaprecord.get(countDel[i].Consumable_Product__c);
- if (countDel[i].Box_Piece__c == '鐩�') {
- Jstage.allnumber = Jstage.allnumber + 1;
- } else {
- Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
- }
- midMaprecord.put(countDel[i].Consumable_Product__c, Jstage);
- }
- }
+ MidMap.put(countDel[i].Consumable_Product__c, Jstage);
+ }
}
+ } else if (
+ String.isBlank(methodType) || methodType.equals('promotionorder')
+ ) {
+ if (countDel[i].promotionorder__c == true) {
+ if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ countDel[i].Consumable_Product__c
+ );
+ if (countDel[i].Box_Piece__c == '鐩�') {
+ Jstage.allnumber = Jstage.allnumber + 1;
+ } else {
+ Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
+ }
+ MidMap.put(countDel[i].Consumable_Product__c, Jstage);
+ }
+ }
+ } else if (
+ String.isBlank(methodType) ||
+ (!methodType.equals('promotionorder') &&
+ !methodType.equals('hospitalorder'))
+ ) {
+ if (
+ countDel[i].promotionorder__c == false &&
+ countDel[i].hospitalSpecialOffer__c == false
+ ) {
+ if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ countDel[i].Consumable_Product__c
+ );
+ if (countDel[i].Box_Piece__c == '鐩�') {
+ Jstage.allnumber = Jstage.allnumber + 1;
+ } else {
+ Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
+ }
+ MidMap.put(countDel[i].Consumable_Product__c, Jstage);
+ }
+ }
+ }
}
- lowerRecord = new List<ConsumableorderdetailsInfo>();
+ consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
//鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecords
- for (ConsumableorderdetailsInfo bss : midMaprecord.values()) {
- lowerRecord.add(bss);
- }
- allProductLimt(lowerRecord);
- for (ConsumableorderdetailsInfo bss : lowerRecord) {
- if (bss.allnumber < bss.lowerlimit) {
- lower.add(bss.Prod.Name__c);
- }
- }
- }
-
- //搴撳瓨涓婁笅闄�
- public static void productLimtAndDate() {
- String nowName = null, nowRightAsstModelNo = null;
- Map<String, String> productLimt = new Map<String, String>();
- for (Integer i = 0; i < proLimitAndDate.size(); i++) {
- nowName = proLimitAndDate[i];
- if (nowName.indexOf('|') >= 0) {
- nowRightAsstModelNo = nowName.subString(0, nowName.indexOf('|'));
- nowName = nowName.subString(nowName.indexOf('|') + 1);
- }
- productLimt.put(nowRightAsstModelNo, nowName);
+ for (ConsumableorderdetailsInfo bss : MidMap.values()) {
+ bss.packing_list = Integer.valueOf(
+ bss.Prod.Product2__r.Packing_list_manual__c
+ );
+ bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
+ bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
+ if (DealerProductMap.containsKey(bss.Prod.Id)) {
+ bss.SpecialCampaignPrice = DealerProductMap.get(bss.Prod.Id)
+ .Special_Campaign_Price__c;
+ bss.Campaign_EndDate = DealerProductMap.get(bss.Prod.Id)
+ .Campaign_EndDate__c;
+ bss.orderGoods_Limit = DealerProductMap.get(bss.Prod.Id)
+ .OrderGoods_Limit__c;
+ }
+ consumableorderdetailsRecords.add(bss);
}
for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
- if (productLimt.containsKey(ass.Prod.Asset_Model_No__c)) {
- ass.lowerlimit = decimal.valueOf(
- productLimt.get(ass.Prod.Asset_Model_No__c).subString(0, productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|'))
- );
- ass.upperlimit = decimal.valueOf(
- productLimt.get(ass.Prod.Asset_Model_No__c).subString(productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|') + 1)
- );
+ ass.sortBy = sortOrderAsc;
+ for (
+ Consumable_Orderdetails__c cdc1 : ConsumableorderdetailsSelected
+ ) {
+ sumPrice += cdc1.Sum_of_money__c;
+ if (ass.prod.Id == cdc1.Consumable_Product__c) {
+ ass.check = true;
+ ass.esd = cdc1;
}
- }
- }
-
- //鍏ㄩ儴搴撳瓨涓婁笅闄�
- private static void allProductLimt(List<ConsumableorderdetailsInfo> lowerRecord) {
- String nowName = null, nowRightAsstModelNo = null;
- Map<String, String> productLimt = new Map<String, String>();
- for (Integer i = 0; i < proLimitAndDate.size(); i++) {
- nowName = proLimitAndDate[i];
- if (nowName.indexOf('|') >= 0) {
- nowRightAsstModelNo = nowName.subString(0, nowName.indexOf('|'));
- nowName = nowName.subString(nowName.indexOf('|') + 1);
- }
- productLimt.put(nowRightAsstModelNo, nowName);
- }
- for (ConsumableorderdetailsInfo ass : lowerRecord) {
- if (productLimt.containsKey(ass.Prod.Asset_Model_No__c)) {
- ass.lowerlimit = decimal.valueOf(
- productLimt.get(ass.Prod.Asset_Model_No__c).subString(0, productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|'))
- );
- ass.upperlimit = decimal.valueOf(
- productLimt.get(ass.Prod.Asset_Model_No__c).subString(productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|') + 1)
- );
- }
- }
- }
-
- @AuraEnabled
- public static Results searchConsumableorderdetails(
- String userWorkLocationStr,
- String agencyProTypeStr,
- String accountNameStr,
- String accountIdStr,
- String hospitalIdStr,
- String contractIdStr,
- String category1Str,
- String category3Str,
- String category4Str,
- String category5Str,
- String category_GoodStr,
- Boolean specialCampaignStr,
- String dealerProductIdStr,
- String methodTypeStr,
- String consumableorderdetailsRecordsviewStr,
- Boolean editAbleStr,
- List<String> proLimitAndDateList
- ){
- Results results = new Results();
- errorMsgList = new List<String>();
- warningMsgList = new List<String>();
- userWorkLocation = userWorkLocationStr;
- agencyProType = agencyProTypeStr;
- accountName = accountNameStr;
- accountid = accountIdStr;
- hospitalId = hospitalIdStr;
- contractId = contractIdStr;
- category1 = category1Str;
- category3 = category3Str;
- category4 = category4Str;
- category5 = category5Str;
- category_Goods = category_GoodStr;
- specialCampaign = specialCampaignStr;
- methodType = methodTypeStr;
- editAble = editAbleStr;
- proLimitAndDate = proLimitAndDateList;
- dealerProductId = (List<String>)JSON.deserialize(dealerProductIdStr, List<String>.class);
- consumableorderdetailsRecordsview = (List<ConsumableorderdetailsInfo>)JSON.deserialize(consumableorderdetailsRecordsviewStr, List<ConsumableorderdetailsInfo>.class);
- size = Integer.valueOf(System.Label.orderdetLimitsize);
- pageLimit = Integer.valueOf(System.Label.orderdetPageLimitsize);
- try {
- searchDone = 'searchDone';
- sortKey = '1';
- preSortKey = '1';
- sortOrderAsc = false;
- sortOrder = new String[7];
- sortOrder = new List<String>{ ' ', ' ', ' ', ' ', '鈫�', '', '', '' };
- Map<String, String> selectedIdMap = new Map<String, String>();
- List<ConsumableorderdetailsInfo> derdetailsRecords = new List<ConsumableorderdetailsInfo>();
- Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>();
- List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
- List<Consumable_order_details2__c> countDel = [
- SELECT
- Id,
- Bar_Code__c,
- Name,
- Inventory_date__c,
- Consumable_Product__c,
- Consumable_Product__r.Asset_Model_No__c,
- Recordtypeid,
- Box_Piece__c,
- //add by rentx 2020-12-09
- hospitalSpecialOffer__c,
- promotionorder__c
- //add by rentx 2020-12-09
- 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 Lose_Flag__c = FALSE
- AND Bar_Code__c != NULL
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- AND Dealer_Info_text__c = :accountName
- ];
- List<Product2__c> product2Selected = new List<Product2__c>();
- consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- soql = makeSoql(category1, category_Goods, category3, category4, category5, specialCampaign, DealerProductId);
- size = Integer.valueOf(System.Label.orderdetLimitsize);
- initStandardController();
- System.debug('soql:'+soql);
- product2Selected = Database.query(soql);
- for (Integer i = 0; i < product2Selected.size(); i++) {
- MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
- }
- for (Integer i = 0; i < countDel.size(); i++) {
- //鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
- if (String.isNotBlank(methodType) && methodType.equals('hospitalorder')) {
- if (countDel[i].hospitalSpecialOffer__c == true) {
- if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
- ConsumableorderdetailsInfo Jstage = MidMap.get(countDel[i].Consumable_Product__c);
- if (countDel[i].Box_Piece__c == '鐩�') {
- Jstage.allnumber = Jstage.allnumber + 1;
- } else {
- Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
- }
- MidMap.put(countDel[i].Consumable_Product__c, Jstage);
- }
- }
- } else if (String.isBlank(methodType) || methodType.equals('promotionorder')) {
- if (countDel[i].promotionorder__c == true) {
- if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
- ConsumableorderdetailsInfo Jstage = MidMap.get(countDel[i].Consumable_Product__c);
- if (countDel[i].Box_Piece__c == '鐩�') {
- Jstage.allnumber = Jstage.allnumber + 1;
- } else {
- Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
- }
- MidMap.put(countDel[i].Consumable_Product__c, Jstage);
- }
- }
- } else if (String.isBlank(methodType) || (!methodType.equals('promotionorder') && !methodType.equals('hospitalorder'))) {
- if (countDel[i].promotionorder__c == false && countDel[i].hospitalSpecialOffer__c == false) {
- if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
- ConsumableorderdetailsInfo Jstage = MidMap.get(countDel[i].Consumable_Product__c);
- if (countDel[i].Box_Piece__c == '鐩�') {
- Jstage.allnumber = Jstage.allnumber + 1;
- } else {
- Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
- }
- MidMap.put(countDel[i].Consumable_Product__c, Jstage);
- }
- }
- }
- }
- //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecordsa0l0l0000000byXAAQ
- for (ConsumableorderdetailsInfo bss : MidMap.values()) {
- if (selectedIdMap.containsKey(bss.Prod.id)) {
- continue;
- } else {
- if (DealerProductMap.containsKey(bss.Prod.Id)) {
- bss.SpecialCampaignPrice = DealerProductMap.get(bss.Prod.Id).Special_Campaign_Price__c;
- bss.Campaign_EndDate = DealerProductMap.get(bss.Prod.Id).Campaign_EndDate__c;
- bss.orderGoods_Limit = DealerProductMap.get(bss.Prod.Id).OrderGoods_Limit__c;
- }
- bss.sortBy = sortOrderAsc;
- bss.packing_list = Integer.valueOf(bss.Prod.Product2__r.Packing_list_manual__c);
- bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
- bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
- consumableorderdetailsRecords.add(bss);
- }
- }
- consumableorderdetailsRecords.sort();
- productLimtAndDate();
- getPageInfo();
- sortKey = '1';
- preSortKey = '1';
- sortOrderAsc = false;
- sortOrder = new String[7];
- sortOrder = new List<String>{ ' ', ' ', '銆�', '', '', '', '', '' };
- cate1ForSort = category1;
- // 鏄剧ず鏁版嵁鏉℃暟淇℃伅
- // makeMessage();
- results.errorMsgList = errorMsgList;
- results.warningMsgList = warningMsgList;
- if(consumableorderdetailsRecords.size() > 0){
- getConsumableShowTableFieldValue();
- results.result = 'Success';
- results.consumableorderdetailsRecordsview = consumableorderdetailsRecordsview;
- results.errorMsg = '鎼滅储鍒�' + consumableorderdetailsRecords.size() + '浠朵骇鍝�';
- }else {
- getConsumableShowTableFieldValue();
- results.result = 'Fail';
- results.consumableorderdetailsRecordsview = consumableorderdetailsRecordsview;
- results.errorMsg = '娌℃湁鎼滅储鍒扮浉鍏虫暟鎹�';
- }
- } catch (Exception e) {
- results.result = 'Fail';
- results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
- }
- return results;
- }
-
- //鍖婚櫌--妫�绱�
- @AuraEnabled
- public static Results searchorderdetails(
- String methodTypeStr,
- String accountIdStr,
- String hospitalIdStr,
- String contractIdStr,
- String userWorkLocationStr,
- String accountNameStr,
- List<String> proLimitAndDateList,
- Boolean editAbleStr
- ){
- Results results = new Results();
- methodType = methodTypeStr;
- accountId = accountIdStr;
- hospitalId = hospitalIdStr;
- contractId = contractIdStr;
- userWorkLocation = userWorkLocationStr;
- accountName = accountNameStr;
- proLimitAndDate = proLimitAndDateList;
- editAble = editAbleStr;
- size = Integer.valueOf(System.Label.orderdetLimitsize);
- pageLimit = Integer.valueOf(System.Label.orderdetPageLimitsize);
- try {
- soql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Product2__r.Packing_list_manual__c,Category3__c,Category4__c,Category5__c FROM Product2__c WHERE Estimation_Entry_Possibility__c = \'鈼媆' ';
- if (methodType.equals('hospitalorder')) {
- //鍖婚櫌id 鏈夊��
- List<hospitalprice__c> hplist = [
- SELECT id, product__c
- FROM hospitalprice__c
- WHERE account__c = :accountid AND hospital__c = :hospitalId
- ];
- if (hplist != null && hplist.size() > 0) {
- List<String> hpids = new List<String>();
- for (hospitalprice__c hc : hplist) {
- hpids.add(hc.product__c);
- }
-
- if (hpids != null && hpids.size() > 0) {
- soql += ' AND Id in : hpids ';
- }
- } else {
- //璇ュ尰闄笅娌℃湁绗﹀悎鍖婚櫌鐗逛环鐨勪骇鍝�
- soql += ' AND Id = null ';
- }
- } else if (methodType.equals('promotionorder')) {
- List<Dealer_Product__c> dpclist = [
- SELECT Id, Dealer_Product2__c
- FROM Dealer_Product__c
- WHERE Dealer_Contact__c = :contractId AND (Special_Discount__c != NULL OR Special_Campaign_Price__c != NULL)
- ];
- if (dpclist != null && dpclist.size() > 0) {
- String ids = '(';
- for (Dealer_Product__c hc : dpclist) {
- hpids.add(hc.Dealer_Product2__c);
- ids += '\'' + hc.Dealer_Product2__c + '\',';
- }
- ids = ids.substring(0, ids.length() - 1) + ')';
- if (hpids != null && hpids.size() > 0) {
- // soql += ' AND Id in : hpids ';
- soql += ' AND Id in ' + ids;
- }
- } else {
- //璇ョ粡閿�鍟嗕笅娌℃湁淇冮攢浠锋牸鐨勪骇鍝�
- soql += ' AND Id = null ';
- }
- }
- size = Integer.valueOf(System.Label.orderdetLimitsize);
- initStandardController();
- List<Product2__c> product2Selected = new List<Product2__c>();
- Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>();
- Map<String, String> selectedIdMap = new Map<String, String>();
- consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- product2Selected = Database.query(soql);
- for (Integer i = 0; i < product2Selected.size(); i++) {
- MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
- }
- List<Consumable_order_details2__c> countDel = [
- SELECT
- Id,
- Bar_Code__c,
- Name,
- Inventory_date__c,
- Consumable_Product__c,
- Consumable_Product__r.Asset_Model_No__c,
- Recordtypeid,
- Box_Piece__c,
- hospitalSpecialOffer__c,
- promotionorder__c
- 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 Lose_Flag__c = FALSE
- AND Bar_Code__c != NULL
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- //AND Consumable_order_minor__r.Dealer_Info__c = :accountid
- AND Dealer_Info_text__c = :accountName
- ];
- for (Integer i = 0; i < countDel.size(); i++) {
- if (methodType.equals('hospitalorder')) {
- if (countDel[i].hospitalSpecialOffer__c == true) {
- //鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
- if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
- ConsumableorderdetailsInfo Jstage = MidMap.get(countDel[i].Consumable_Product__c);
- if (countDel[i].Box_Piece__c == '鐩�') {
- Jstage.allnumber = Jstage.allnumber + 1;
- } else {
- Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
- }
- //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
- MidMap.put(countDel[i].Consumable_Product__c, Jstage);
- }
- }
- } else if (methodType.equals('promotionorder')) {
- if (countDel[i].promotionorder__c == true) {
- //鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
- if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
- ConsumableorderdetailsInfo Jstage = MidMap.get(countDel[i].Consumable_Product__c);
- if (countDel[i].Box_Piece__c == '鐩�') {
- Jstage.allnumber = Jstage.allnumber + 1;
- } else {
- Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
- }
- //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
- MidMap.put(countDel[i].Consumable_Product__c, Jstage);
- }
- }
- }
- }
- //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecordsa0l0l0000000byXAAQ
- for (ConsumableorderdetailsInfo bss : MidMap.values()) {
- if (selectedIdMap.containsKey(bss.Prod.id)) {
- continue;
- } else {
- if (DealerProductMap.containsKey(bss.Prod.Id)) {
- bss.SpecialCampaignPrice = DealerProductMap.get(bss.Prod.Id).Special_Campaign_Price__c;
- bss.Campaign_EndDate = DealerProductMap.get(bss.Prod.Id).Campaign_EndDate__c;
- bss.orderGoods_Limit = DealerProductMap.get(bss.Prod.Id).OrderGoods_Limit__c;
- }
- bss.sortBy = sortOrderAsc;
- bss.packing_list = Integer.valueOf(bss.Prod.Product2__r.Packing_list_manual__c);
- bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
- bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
- consumableorderdetailsRecords.add(bss);
- }
- }
- consumableorderdetailsRecords.sort();
- productLimtAndDate();
- getPageInfoForHos();
- sortKey = '1';
- preSortKey = '1';
- sortOrderAsc = false;
- sortOrder = new String[7];
- sortOrder = new List<String>{ ' ', ' ', '銆�', '', '', '', '', '' };
- cate1ForSort = category1;
- // 鏄剧ず鏁版嵁鏉℃暟淇℃伅
- noOfRecords = consumableorderdetailsRecords.size();
- getConsumableShowTableFieldValue();
- results.consumableorderdetailsRecordsview = consumableorderdetailsRecordsview;
- if(consumableorderdetailsRecordsview.size() > 0){
- results.result = 'Success';
- results.errorMsg = '鍏辨悳绱㈠埌'+consumableorderdetailsRecordsview.size()+'鏉℃暟鎹�';
- }else {
- results.result = 'Fail';
- results.errorMsg = '娌℃湁鎼滅储鍒扮浉鍏虫暟鎹�';
- }
- } catch (Exception e) {
- results.result = 'Fail';
- results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
- }
- return results;
- }
-
- //鐢ㄦ埛鍒囨崲鍖婚櫌鏃跺彇娑堥�変腑鐨勪骇鍝�
- private static List<ConsumableorderdetailsInfo> getPageInfoForHos() {
- List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
- Map<String, String> selectedIdMap = new Map<String, String>();
- consumableorderdetailsRecordsview = new List<ConsumableorderdetailsInfo>();
- if (editAble) {
- consumableorderdetailsRecordsview = reSet;
- }
- Integer pagestartNo = (con.getPageNumber() * size) - size;
- Integer pageendNo = (con.getPageNumber() * size) > noOfRecords ? noOfRecords : (con.getPageNumber() * size - 1);
- Integer addNo = 0;
- for (Integer i = pagestartNo; i < consumableorderdetailsRecords.size(); i++) {
- Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c();
- if (selectedIdMap.containsKey(consumableorderdetailsRecords[i].Prod.Id)) {
- addNo++;
- //continue;
- }
- // else if (consumableorderdetailsRecordsview.size() >= pageLimit + size) {
- // break;
- // }
- else {
- if (consumableorderdetailsRecords[i].check == false) {
- consumableorderdetailsRecords[i].esd = orderdetails1;
- }
- consumableorderdetailsRecordsview.add(consumableorderdetailsRecords[i]);
- addNo++;
- }
- // if (addNo >= size){
- // break;
- // }
- }
- return consumableorderdetailsRecordsview;
- }
- //add by rentx 2020-12-03 end =====================================================================================================================
- //鐗逛环
- public static void OffersPrice() {
- edoffersPrice = true;
- }
-
- //寰楀埌淇冮攢浜у搧Id
- private static List<String> getDealerProductId() {
- List<String> ProductId = new List<String>();
- Map<String, String> DealerProductIdMap = new Map<String, String>();
- Date dateToday = Date.today();
- List<Dealer_Product__c> DealerProductList = [
- SELECT
- Id,
- Name,
- Dealer_Product2__c,
- Special_Campaign_Price__c,
- Campaign_StartDate__c,
- Campaign_EndDate__c,
- Dealer_Contact__c,
- OrderGoods_Limit__c
- FROM Dealer_Product__c
- WHERE
- Dealer_Contact__c IN :contactDealer
- AND Campaign_StartDate__c <= :dateToday
- AND Campaign_EndDate__c >= :dateToday
- AND Special_Campaign_Price__c != NULL
- ];
- for (Dealer_Product__c dealerProduct : DealerProductList) {
- if (DealerProductIdMap.containsKey(dealerProduct.Dealer_Product2__c)) {
- continue;
- } else {
- ProductId.add(dealerProduct.Dealer_Product2__c);
- DealerProductIdMap.put(dealerProduct.Dealer_Product2__c, dealerProduct.Dealer_Product2__c);
- }
- }
- return ProductId;
- }
-
- private static String makeSoql(
- String CateName,
- String CateCode,
- String Category3,
- String Category4,
- String Category5,
- Boolean specialCampaign,
- List<String> DealerProductId
- ) {
- String soql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Product2__r.Packing_list_manual__c,Category3__c,Category4__c,Category5__c FROM Product2__c WHERE Estimation_Entry_Possibility__c = \'鈼媆' ';
- // add begin ================================================================================================
- if (methodType != null && methodType.equals('hospitalorder')) {
- //濡傛灉鏄尰闄㈢壒浠�
- //1.鍒ゆ柇 鍖婚櫌id鏄惁鏈夊�� 濡傛灉鏈夊�� 鍒欐牴鎹尰闄d鍘� 鍖婚櫌鐗逛环琛ㄤ腑鑾峰彇浜у搧id
- //鍖婚櫌id 鏈夊��
- if (hospitalId == null || hospitalId == '') {
- soql += ' and id = null ';
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, '璇烽�夋嫨鍖婚櫌'));
- warningMsgList.add('璇烽�夋嫨鍖婚櫌');
- } else {
- List<hospitalprice__c> hplist = [
- SELECT id, product__c
- FROM hospitalprice__c
- WHERE account__c = :accountid AND hospital__c = :hospitalId
- ];
- if (hplist != null && hplist.size() > 0) {
- hpids = new List<String>();
- for (hospitalprice__c hc : hplist) {
- hpids.add(hc.product__c);
- }
- if (hpids != null && hpids.size() > 0) {
- soql += ' AND Id in : hpids ';
- }
- } else {
- //璇ュ尰闄笅娌℃湁绗﹀悎鍖婚櫌鐗逛环鐨勪骇鍝�
- soql += ' AND Id = null ';
- return soql;
- }
- }
- }
- //淇冮攢璁㈣揣
- if (methodType != null && methodType.equals('promotionorder')) {
- if (contractId == null || contractId == '') {
- soql += ' and id = null ';
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, '璇烽�夋嫨鍚堝悓'));
- warningMsgList.add('璇烽�夋嫨鍚堝悓');
- } else {
- //1.鏌ヨ鎵�鏈夌粡閿�鍟嗕骇鍝�
- List<Dealer_Product__c> dpclist = [
- SELECT Id, Dealer_Product2__c
- FROM Dealer_Product__c
- WHERE Dealer_Contact__c = :contractId AND (Special_Discount__c != NULL OR Special_Campaign_Price__c != NULL)
- ];
-
- if (dpclist != null && dpclist.size() > 0) {
- hpids = new List<String>();
- for (Dealer_Product__c hc : dpclist) {
- hpids.add(hc.Dealer_Product2__c);
- }
- if (hpids != null && hpids.size() > 0) {
- soql += ' AND Id in : hpids ';
- }
- } else {
- //璇ョ粡閿�鍟嗕笅娌℃湁淇冮攢浠锋牸鐨勪骇鍝�
- soql += ' AND Id = null ';
- return soql;
- }
- }
- }
- //add end ===================================================================================================
- if (!String.isBlank(CateName)) {
- soql +=
- ' AND (Name__c like \'%' +
- String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
- '%\' or Asset_Model_No__c like \'%' +
- String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
- '%\')';
- }
- if (!String.isBlank(Category3)) {
- soql += ' AND Category3__c = \'' + Category3 + '\'';
- }
- if (!String.isBlank(Category4)) {
- soql += ' AND Category4__c = \'' + Category4 + '\'';
- }
- if (!String.isBlank(Category5)) {
- soql += ' AND Category5__c = \'' + Category5 + '\'';
- }
- if (agencyProType == 'ET') {
- soql += ' AND Pro2_Dealer_Object__c = true';
- }
- if (agencyProType == 'ENG') {
- soql += ' AND Pro2_Dealer_ENG__c = true';
- }
- soql += ' AND Intra_Trade_List_RMB__c > 0 ';
- System.debug('soql +++++++++++ ' + soql);
- return soql;
- }
-
- private static String makeSoqlorderdet() {
- String sqlTail = '(\'';
- for (Integer i = 0; i < orderzaikuId.size(); i++) {
- if (i < orderzaikuId.size() - 1) {
- sqlTail += orderzaikuId[i] + '\',\'';
- } else {
- sqlTail += orderzaikuId[i] + '\')';
- }
- }
- String soql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Product2__r.Packing_list_manual__c,Category3__c,Category4__c,Category5__c FROM Product2__c WHERE Estimation_Entry_Possibility__c = \'鈼媆' ';
- System.debug('sqlTail:'+sqlTail);
- System.debug('orderzaikuId:'+orderzaikuId);
- if (orderzaikuId.size() > 0) {
- soql += ' AND Id in' + sqlTail;
- }
- return soql;
- }
-
- // 缂栬緫鎸夐挳
- @AuraEnabled
- public static Results setEditAble(String eSetidStr){
- Results results = new Results();
- ESetId = eSetidStr;
- try {
- statusEdit = 'Redirect';
- List<Consumable_order__c> oclist = [SELECT orderPattern__c FROM Consumable_order__c WHERE id = :ESetid];
- String url = '/lexconsumable?ESetid=' + ESetid + '&KeyWords=' + statusEdit + '&type=' + oclist.get(0).orderPattern__c;
- results.result = 'Success';
- results.url = url;
- } catch (Exception e) {
- results.result = 'Fail';
- results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
- }
- return results;
- }
-
- // 鍐嶇敵璇�
- @AuraEnabled
- public static Results backOrder(String eSetidStr) {
- Results results = new Results();
- ESetId = eSetidStr;
- statusEdit = 'Redirect';
- returnOrder = true;
- try {
- statusEdit = 'Redirect';
- List<Consumable_order__c> oclist = [SELECT orderPattern__c FROM Consumable_order__c WHERE id = :ESetid];
- String url = '/lexconsumable?ESetid=' + ESetid + '&KeyWords=' + statusEdit + '&type=' + oclist.get(0).orderPattern__c;
- results.result = 'Success';
- results.url = url;
- } catch (Exception e) {
- results.result = 'Fail';
- results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
- }
- return results;
- }
-
- //涓婁紶闄勪欢
- @AuraEnabled
- public static Results filesUpload(String pId, String fileName, String base64Data) {
- Results results = new Results();
- try {
- base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
- ContentVersion cv = new ContentVersion();
- cv.Title = fileName;
- cv.PathOnClient = '/' + fileName;
- cv.FirstPublishLocationId = pId;
- cv.VersionData = EncodingUtil.base64Decode(base64Data);
- cv.IsMajorVersion = true;
- insert cv;
- Consumable_order__c c = [SELECT Id FROM Consumable_order__c WHERE Id =:pId];
- c.Consumable_pdf_insert_day__c = Date.today();
- update c;
- results.result = 'Success';
- } catch (Exception e) {
- results.result = 'Fail';
- results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
- }
- return results;
- }
-
- //鍒犻櫎鎸夐挳
- @AuraEnabled
- public static Results delConsumable(String eSetidStr){
- Results results = new Results();
- ESetId = eSetidStr;
- try {
- Consumable_order__c cord = new Consumable_order__c(Id = ESetId);
- List<Consumable_Orderdetails__c> orderdetails1 = [
- SELECT Id
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :EsetId
- ];
- delete orderdetails1;
- delete cord;
- results.result = 'Success';
- results.url = '/lexconsumableordermanage';
- } catch (Exception e) {
- results.result = 'Fail';
- results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
- }
- return results;
- }
-
- // 鎻愪氦鎸夐挳
- @AuraEnabled
- public static Results sorder(String eSetidStr,String accountidStr){
- Results results = new Results();
- errorMsgList = new List<String>();
- warningMsgList = new List<String>();
- ESetId = eSetidStr;
- accountid = accountidStr;
- Savepoint sp = Database.setSavepoint();
- try {
- Map<Id, String> prodMap = new Map<Id, String>();
- Consumable_order__c P = new Consumable_order__c();
- P = new Consumable_order__c();
- p.Id = ESetId;
- p.Order_date__c = Date.today();
- p.Order_status__c = '闄勪欢涓婁紶瀹屾垚';
- for (Consumable_Orderdetails__c cod1 : [
- SELECT Consumable_product__r.Product2__c, Consumable_product__r.Name__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :ESetId
- ]) {
- prodMap.put(cod1.Consumable_product__r.Product2__c, cod1.Consumable_product__r.Name__c);
- }
- // GZW 鎻愪氦浜у搧鏃犳晥 鍑洪敊璇秷鎭�
- System.debug(prodMap);
- Map<String, String> chkMap = OpportunityWebService.MapCheckProRegisterDecide(prodMap, accountid, '');
- System.debug(chkMap);
- if (chkMap.size() > 0) {
- if (chkMap.containsKey('agency')) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '绗竴缁忛攢鍟嗘病鏈夋湁鏁堢殑鍖荤枟鍣ㄦ缁忚惀璁稿彲璇併��'));
- errorMsgList.add('绗竴缁忛攢鍟嗘病鏈夋湁鏁堢殑鍖荤枟鍣ㄦ缁忚惀璁稿彲璇併��');
- }
- for (String proId : prodMap.keySet()) {
- if (chkMap.containsKey(proId)) {
- if (chkMap.get(proId) == '1') {
- // ApexPages.addmessage(
- // new ApexPages.message(ApexPages.severity.Error, '浜у搧 ' + prodMap.get(proId) + ' 娌℃湁鏈夋晥鐨勬敞鍐岃瘉銆�')
- // );
- errorMsgList.add('浜у搧 ' + prodMap.get(proId) + ' 娌℃湁鏈夋晥鐨勬敞鍐岃瘉銆�');
- } else if (chkMap.get(proId) == '2') {
- // ApexPages.addmessage(
- // new ApexPages.message(ApexPages.severity.Error, '浜у搧 ' + prodMap.get(proId) + ' 瓒呰繃缁忛攢鍟嗙粡钀ヨ寖鍥淬��')
- // );
- errorMsgList.add('浜у搧 ' + prodMap.get(proId) + ' 瓒呰繃缁忛攢鍟嗙粡钀ヨ寖鍥淬��');
- }
- }
- }
- results.result = 'Fail';
- results.errorMsg = '';
- results.errorMsgList = errorMsgList;
- results.warningMsgList = warningMsgList;
- return results;
- }
- update p;
- Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
- psr.setObjectId(ESetId);
- Approval.ProcessResult submitResult = Approval.process(psr);
- results.result = 'Success';
- results.url = '/lexconsumableordermanage';
- } catch (Exception e) {
- Database.rollback(sp);
- results.result = 'Fail';
- results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
- }
- return results;
- }
-
- // 椹冲洖璁㈠崟copy
- @AuraEnabled
- public static Results ordrCopy(
- String contractNameStr,
- String cocStr,
- String agencyProTypeStr,
- String accountidStr,
- String consumableorderdetailsRecordsviewStr,
- String contactDealerStr,
- String methodTypeStr,
- String hospitalIdStr,
- String contractIdStr,
- String agencyProType1Str,
- Boolean OSHFLGStr
- ) {
- ESetId = '';
- return save(contractNameStr,cocStr,agencyProTypeStr,accountidStr,consumableorderdetailsRecordsviewStr,contactDealerStr,methodTypeStr,ESetId,hospitalIdStr,contractIdStr,agencyProType1Str,OSHFLGStr);
- }
-
- //淇濆瓨鎸夐挳
- @AuraEnabled
- public static Results save(
- String contractNameStr,
- String cocStr,
- String agencyProTypeStr,
- String accountidStr,
- String consumableorderdetailsRecordsviewStr,
- String contactDealerStr,
- String methodTypeStr,
- String eSetIdStr,
- String hospitalIdStr,
- String contractIdStr,
- String agencyProType1Str,
- Boolean OSHFLGStr
- ){
- Results results = new Results();
- errorMsgList = new List<String>();
- warningMsgList = new List<String>();
- contractName = contractNameStr;
- agencyProType = agencyProTypeStr;
- accountid = accountidStr;
- methodType = methodTypeStr;
- ESetId = eSetIdStr;
- hospitalId = hospitalIdStr;
- contractId = contractIdStr;
- agencyProType1 = agencyProType1Str;
- OSHFLG = OSHFLGStr;
- coc = (Consumable_order__c)JSON.deserialize(cocStr, Consumable_order__c.class);
- contactDealer = (List<String>)JSON.deserialize(contactDealerStr, List<String>.class);
- System.debug('consumableorderdetailsRecordsviewStr:'+consumableorderdetailsRecordsviewStr);
- consumableorderdetailsRecordsview = (List<ConsumableorderdetailsInfo>)JSON.deserialize(consumableorderdetailsRecordsviewStr, List<ConsumableorderdetailsInfo>.class);
- if(coc.Offers_Price__c != null){
- String offerStr = String.valueOf(coc.Offers_Price__c);
- bargainPrice = Decimal.valueOf(offerStr.replace(',',''));
- }
- Savepoint sp = Database.setSavepoint();
- try {
- if (String.isEmpty(contractName)) {
- // coc.Order_effective_contact__c.addError('璇烽�夋嫨鍚堝悓');
- results.result = 'Fail';
- results.errorMsg = '璇烽�夋嫨鍚堝悓';
- return results;
- }
- List<Account> contract = [
- SELECT Id, Name, Contract_Department_Class__c, Contract_Quote_Decide_Flag__c
- FROM account
- WHERE
- Name = :contractName
- AND Id =: contractId //lt 20230517 瀹夊窘涓ょエ鍒� add
- AND Contract_Decide_Start_Date__c <= :Date.Today()
- AND Contract_Decide_End_Date__c >= :Date.Today()
- AND Contact_Type__c like :agencyProType1 //lt 20230517 瀹夊窘涓ょエ鍒� add 1
- AND Agent_Ref__c =:accountid
- AND OSH_Dealer__c =: OSHFLG //lt 20230517 瀹夊窘涓ょエ鍒� add
- ];
- if (contract.size() <= 0) {
- // coc.Order_effective_contact__c.addError('涓嶅瓨鍦ㄧ殑鍚堝悓锛岃閲嶆柊纭銆�');
- results.result = 'Fail';
- results.errorMsg = '涓嶅瓨鍦ㄧ殑鍚堝悓锛岃閲嶆柊纭銆�';
- return results;
- } else {
- if (String.isEmpty(contract[0].Contract_Quote_Decide_Flag__c)) {
- // coc.Order_effective_contact__c.addError('鍚堝悓鏃犳晥锛岃閲嶆柊纭銆�');
- results.result = 'Fail';
- results.errorMsg = '鍚堝悓鏃犳晥锛岃閲嶆柊纭銆�';
- return results;
- }
- }
- Integer FLG = 0;
- Integer Count = 0;
- //add by rentx 2020-11-25
- List<String> tpids = new List<String>();
- //add by rentx 2020-11-25
- for (ConsumableorderdetailsInfo CheckCount : consumableorderdetailsRecordsview) {
- FLG = FLG + 1;
- if (CheckCount.check == false) {
- Count = Count + 1;
- }
- if (CheckCount.check == true) {
- //add by rentx 2020-11-25
- tpids.add(CheckCount.Prod.Id);
- //add by rentx 2020-11-25
- if (CheckCount.esd.Consumable_Count__c == null || CheckCount.esd.Consumable_Count__c == 0) {
- // CheckCount.esd.Consumable_Count__c.addError('璇疯緭鍏ラ噰璐暟閲�');
- results.result = 'Fail';
- results.errorMsg = '璇疯緭鍏ラ噰璐暟閲�';
- return results;
- }
- if (
- CheckCount.orderGoods_Limit > 0 &&
- math.mod(Integer.valueOf(CheckCount.esd.Consumable_Count__c), Integer.valueOf(CheckCount.orderGoods_Limit)) > 0
- ) {
- // CheckCount.esd.Consumable_Count__c.addError('璇疯緭鍏ヤ績閿�鏁伴噺鐨勫�嶆暟');
- results.result = 'Fail';
- results.errorMsg = '璇疯緭鍏ヤ績閿�鏁伴噺鐨勫�嶆暟';
- return results;
- }
- }
- }
- if (Count == FLG) {
- results.result = 'Fail';
- results.errorMsg = '璇烽�夋嫨鎵�闇�娑堣�楀搧';
- return results;
- }
- //=======================================鍖婚櫌鐗逛环,鏈夐噾棰濈殑璇濆彇閲戦
- Map<String, Decimal> dealerHospitalmMap = new Map<String, Decimal>();
- List<hospitalprice__c> hplist = [select Id,hospital__c,mPrice__c,pPrice__c,product__c,account__c
- from hospitalprice__c
- where product__c in :tpids and mPrice__c <> null and account__c=:accountid
- ];
- for (hospitalprice__c dealerProduct : hplist) {
- if (dealerProduct.mPrice__c != null) {
- dealerHospitalmMap.put('' + dealerProduct.hospital__c + dealerProduct.product__c,dealerProduct.mPrice__c);
- }
- }
- //淇冮攢璁㈣揣 鏍规嵁缁忛攢鍟嗕骇鍝佷腑鐨勬暟鎹绠楅噾棰�
- //=======================================浜у搧鐗规畩鎶樻墸
- Map<String, Decimal> dealerPDiscountMap = new Map<String, Decimal>();
- Map<String, Decimal> dealerMPDiscountMap = new Map<String, Decimal>();
- //1.鑾峰彇鏈夊紑濮嬬粨鏉熸棩鐨勪骇鍝�
- Date dateToday = Date.today();
- List<Dealer_Product__c> haveDateList = [
- SELECT
- Id,
- Name,
- Dealer_Product2__c,
- Special_Campaign_Price__c,
- Campaign_StartDate__c,
- Campaign_EndDate__c,
- Dealer_Contact__c,
- OrderGoods_Limit__c,
- Special_Discount__c
- FROM Dealer_Product__c
- WHERE
- Dealer_Contact__c IN :contactDealer
- AND Campaign_StartDate__c <= :dateToday
- AND Campaign_EndDate__c >= :dateToday
- AND (Special_Discount__c != NULL
- OR Special_Campaign_Price__c != NULL)
- ];
- //2.鑾峰彇娌℃湁寮�濮嬬粨鏉熸棩鐨勪骇鍝�
- List<Dealer_Product__c> DealerProductList = [
- SELECT
- Id,
- Name,
- Dealer_Product2__c,
- Special_Campaign_Price__c,
- Campaign_StartDate__c,
- Campaign_EndDate__c,
- Dealer_Contact__c,
- Special_Discount__c,
- OrderGoods_Limit__c
- FROM Dealer_Product__c
- WHERE Dealer_Contact__c IN :contactDealer AND (Special_Discount__c != NULL OR Special_Campaign_Price__c != NULL)
- ];
- for (Dealer_Product__c dealerProduct : DealerProductList) {
- //濡傛灉淇冮攢浠锋牸涓簄ull 鍒欒缃壒娈婃姌鎵�(鐧惧垎姣�)鍒伴泦鍚�
- if (dealerProduct.Special_Campaign_Price__c == null) {
- dealerPDiscountMap.put(
- '' + dealerProduct.Dealer_Contact__c + dealerProduct.Dealer_Product2__c,
- dealerProduct.Special_Discount__c
- );
- } else {
- dealerMPDiscountMap.put(
- '' + dealerProduct.Dealer_Contact__c + dealerProduct.Dealer_Product2__c,
- dealerProduct.Special_Campaign_Price__c
- );
- }
- }
- //杩欐牱鍋氭槸涓轰簡璁$畻淇冮攢浠锋牸鏃� 浼樺厛璁$畻淇冮攢寮�濮嬬粨鏉熸棩涓嶄负绌虹殑浜у搧
- //濡傛灉璇ラ泦鍚堟湁鍊� 鍒欒鏄庨渶瑕佹牴鎹綋鍓嶇殑閲戦鎴栬�呮姌鎵f潵璁$畻
- if (haveDateList != null && haveDateList.size() > 0) {
- for (Dealer_Product__c dealerProduct : haveDateList) {
- if (dealerProduct.Special_Campaign_Price__c == null) {
- dealerPDiscountMap.put(
- '' + dealerProduct.Dealer_Contact__c + dealerProduct.Dealer_Product2__c,
- dealerProduct.Special_Discount__c
- );
- dealerMPDiscountMap.remove('' + dealerProduct.Dealer_Contact__c + dealerProduct.Dealer_Product2__c);
- } else {
- dealerMPDiscountMap.put(
- '' + dealerProduct.Dealer_Contact__c + dealerProduct.Dealer_Product2__c,
- dealerProduct.Special_Campaign_Price__c
- );
- dealerPDiscountMap.remove('' + dealerProduct.Dealer_Contact__c + dealerProduct.Dealer_Product2__c);
- }
- }
- }
- //=======================================缁忛攢鍟嗗悎鍚屾姌鎵�
- List<Account> at = [
- SELECT id, Name, State_Master__c, State_Master__r.Name, Sales_Section__c, Dealer_discount__c
- FROM Account
- WHERE
- Name = :contractName
- AND Id =: contractId //lt 20230517 瀹夊窘涓ょエ鍒� add
- AND Contact_Type__c like :agencyProType1 //lt 20230517 瀹夊窘涓ょエ鍒� add 1
- AND Contact_Type__c LIKE :agencyProType
- AND Contract_Decide_Start_Date__c <= :Date.Today()
- AND Contract_Decide_End_Date__c >= :Date.Today()
- AND Contract_Decide_End_Date__c >= :Date.Today()
- AND OSH_Dealer__c =: OSHFLG //lt 20230517 瀹夊窘涓ょエ鍒� add
- ];
- if (at.size() > 0 && at[0].Dealer_discount__c != null) {
- disCount = at[0].Dealer_discount__c;
- } else {
- disCount = 100;
- }
- Consumable_order__c P = new Consumable_order__c();
- List<Consumable_Orderdetails__c> Ins = new List<Consumable_Orderdetails__c>();
- //鏂板缓璁㈠崟鏃�
- if (String.isBlank(ESetId)) {
- Integer i = 1;
- Integer Roll = 0;
- p.Name = '*';
- p.Order_status__c = '鑽夋涓�';
- p.Dealer_Info__c = accountid;
- p.Order_ProType__c = agencyProType;
- p.Offers_Price__c = coc.Offers_Price__c;
- p.Order_date__c = coc.Order_date__c;
- p.Order_effective_contact__c = contract[0].Id;
- p.Order_Reason__c = coc.Order_Reason__c;
- p.RecordTypeid = System.Label.RT_ConOrder_Order;
- p.Overrule_order__c = coc.Id;
- if (String.isNotBlank(methodType)) {
- p.orderPattern__c = methodType;
- }
- insert p;
- List<Consumable_order__c> Consumable_order = [SELECT Name, orderPattern__c FROM Consumable_order__c WHERE id = :p.id];
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecordsview) {
- Roll = Roll + 1;
- if (ass.check == true) {
- if (ass.esd.Consumable_Count__c == null || ass.esd.Consumable_Count__c == 0) {
- // ass.esd.Consumable_Count__c.addError('璇疯緭鍏ラ噰璐暟閲�');
- results.result = 'Fail';
- results.errorMsg = '璇疯緭鍏ラ噰璐暟閲�';
- return results;
- } else {
- Consumable_Orderdetails__c InsAfterDel = new Consumable_Orderdetails__c();
- String str = string.valueOf(i);
- if (str.length() == 1) {
- str = '0' + str;
- }
- InsAfterDel.Name = Consumable_order[0].Name + '-' + str;
- InsAfterDel.Consumable_Count__c = ass.esd.Consumable_Count__c;
- InsAfterDel.Consumable_order__c = p.id;
- InsAfterDel.Consumable_Product__c = ass.Prod.id;
- InsAfterDel.Box_Piece__c = '鐩�';
- //鍗忚璁㈣揣
- if (methodType.equals('agreementorder')) {
- Consumable_order[0].orderPattern__c = 'agreementorder';
-
- InsAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c * disCount / 100;
- //=====================================================================================update by rentx 2020-11-25
- } else if (methodType.equals('promotionorder')) {
- Consumable_order[0].orderPattern__c = 'promotionorder';
- //淇冮攢璁㈣揣
- //濡傛灉淇冮攢浠锋牸涓嶄负null 鍒欑洿鎺ヤ娇鐢ㄤ績閿�浠锋牸鏉ヨ绠楅噾棰�
- if (dealerMPDiscountMap.containsKey('' + contract[0].Id + ass.Prod.Id)) {
- InsAfterDel.Intra_Trade_List_RMB__c = dealerMPDiscountMap.get('' + contract[0].Id + ass.Prod.Id);
- system.debug('cai 0' + InsAfterDel.Intra_Trade_List_RMB__c);
- } else if (dealerPDiscountMap.containsKey('' + contract[0].Id + ass.Prod.Id)) {
- InsAfterDel.Intra_Trade_List_RMB__c =
- ass.Prod.Intra_Trade_List_RMB__c *
- dealerPDiscountMap.get('' + contract[0].Id + ass.Prod.Id) /
- 100;
- system.debug('cai 00' + InsAfterDel.Intra_Trade_List_RMB__c);
- }
- //=====================================================================================update by rentx 2020-11-25
- } else if (methodType.equals('hospitalorder')) {
- //鍖婚櫌鐗逛环
- Consumable_order[0].Order_ForHospital__c = hospitalId;
- Consumable_order[0].orderPattern__c = 'hospitalorder';
- if (dealerHospitalmMap.containsKey(hospitalId + ass.Prod.Id) && dealerHospitalmMap.get(hospitalId + ass.Prod.Id) != null) {
- //鐩存帴鏍规嵁淇冮攢閲戦璁$畻
- InsAfterDel.Intra_Trade_List_RMB__c = dealerHospitalmMap.get(''+ hospitalId + ass.Prod.Id);
- }
- } else if (DealerProductMap.containsKey(ass.Prod.Id)) {
- InsAfterDel.Intra_Trade_List_RMB__c = DealerProductMap.get(ass.Prod.Id).Special_Campaign_Price__c;
- system.debug('cai 2' + InsAfterDel.Intra_Trade_List_RMB__c);
- InsAfterDel.Purchase_Unitprtprice_From__c = '淇冮攢';
- InsAfterDel.Special_Campaign_Price__c = DealerProductMap.get(ass.Prod.Id).Special_Campaign_Price__c;
- }
- InsAfterDel.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
- i++;
- Ins.add(InsAfterDel);
- }
- }
- }
- ESetId = p.id;
- if (Consumable_order.size() > 0) {
- update Consumable_order;
- }
- }
- //淇敼涔嬪悗 淇濆瓨璁㈠崟
- if (Ins.size() > 0) {
- insert Ins;
- } else {
- //淇敼,鑾峰彇娑堣�楀搧璁㈠崟
- List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
- cocinfo = [
- SELECT Id, Name, Order_status__c, Dealer_Info__c, Deliver_date__c, Order_Reason__c, Offers_Price__c
- FROM Consumable_order__c
- WHERE Id = :ESetId
- ];
- if (cocinfo.size() > 0) {
- p = cocinfo[0];
- }
- p.Name = coc.Name;
- p.Dealer_Info__c = accountid;
- p.Order_ProType__c = agencyProType;
- p.Order_date__c = coc.Order_date__c;
- p.Order_effective_contact__c = contract[0].Id;
- p.Order_Reason__c = coc.Order_Reason__c;
- if (bargainPrice != null) {
- p.Offers_Price__c = bargainPrice;
- }
- update p;
- List<Consumable_order__c> Consumable_order = [SELECT Name, orderPattern__c FROM Consumable_order__c WHERE id = :p.id];
- List<Consumable_Orderdetails__c> qs = new List<Consumable_Orderdetails__c>();
- qs = [
- SELECT Id
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :ESetId AND Consumable_order__r.Dealer_Info__c = :accountid
- ];
- if (qs.size() > 0) {
- delete qs;
- }
- Integer i = 1;
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecordsview) {
- if (ass.check == true) {
- Consumable_Orderdetails__c InsAfterDel = new Consumable_Orderdetails__c();
- if (ass.esd.Consumable_Count__c == null || ass.esd.Consumable_Count__c == 0) {
- // ass.esd.Consumable_Count__c.addError('璇疯緭鍏ラ噰璐暟閲�');
- results.result = 'Fail';
- results.errorMsg = '璇疯緭鍏ラ噰璐暟閲�';
- return results;
- } else {
- String str = string.valueOf(i);
- if (str.length() == 1) {
- str = '0' + str;
- }
- InsAfterDel.Name = Consumable_order[0].Name + '-' + str;
- InsAfterDel.Consumable_Count__c = ass.esd.Consumable_Count__c;
- InsAfterDel.Consumable_order__c = ESetId;
- InsAfterDel.Consumable_Product__c = ass.Prod.id;
- InsAfterDel.Box_Piece__c = '鐩�';
- //鍗忚璁㈣揣
- if (methodType.equals('agreementorder')) {
- Consumable_order[0].orderPattern__c = 'agreementorder';
- InsAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c * disCount / 100;
- } else if (methodType.equals('promotionorder')) {
- Consumable_order[0].orderPattern__c = 'promotionorder';
- //淇冮攢璁㈣揣
- if (dealerMPDiscountMap.containsKey('' + contract[0].Id + ass.Prod.Id)) {
- InsAfterDel.Intra_Trade_List_RMB__c = dealerMPDiscountMap.get('' + contract[0].Id + ass.Prod.Id);
- } else if (dealerPDiscountMap.containsKey('' + contract[0].Id + ass.Prod.Id)) {
- InsAfterDel.Intra_Trade_List_RMB__c =
- ass.Prod.Intra_Trade_List_RMB__c *
- dealerPDiscountMap.get('' + contract[0].Id + ass.Prod.Id) /
- 100;
- }
- } else if (methodType.equals('hospitalorder')) {
- Consumable_order[0].orderPattern__c = 'hospitalorder';
- //鍖婚櫌鐗逛环
- Consumable_order[0].Order_ForHospital__c = hospitalId;
- if (dealerHospitalmMap.containsKey(hospitalId + ass.Prod.Id) && dealerHospitalmMap.get(hospitalId + ass.Prod.Id) != null) {
- //鐩存帴鏍规嵁淇冮攢閲戦璁$畻
- InsAfterDel.Intra_Trade_List_RMB__c = dealerHospitalmMap.get(''+ hospitalId + ass.Prod.Id);
- }
- } else if (DealerProductMap.containsKey(ass.Prod.Id)) {
- InsAfterDel.Intra_Trade_List_RMB__c = DealerProductMap.get(ass.Prod.Id).Special_Campaign_Price__c;
- InsAfterDel.Purchase_Unitprtprice_From__c = '淇冮攢';
- InsAfterDel.Special_Campaign_Price__c = DealerProductMap.get(ass.Prod.Id).Special_Campaign_Price__c;
- }
- // ==================================================涔嬪墠鐨勪績閿�璁㈣揣鐨勯�昏緫
- InsAfterDel.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
- i++;
- Ins.add(InsAfterDel);
- }
- }
- }
- if (Ins.size() > 0) {
- insert Ins;
- }
- }
- results.result = 'Success';
- results.eSetId = ESetId;
- } catch (Exception e) {
- Database.rollback(sp);
- results.result = 'Fail';
- results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
- }
- return results;
- }
-
- //鍒犻櫎闄勪欢
- @AuraEnabled
- public static Results deleteAtt(String contentVersionId, String cocId){
- Results results = new Results();
- try {
- List<ContentVersion> cvInfo = [SELECT Id FROM ContentVersion WHERE FirstPublishLocationId = :cocId];
- ContentVersion conVersion = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :contentVersionId];
- String contentDocumentId = conVersion.ContentDocumentId;
- ContentDocument conDocument = [SELECT Id FROM ContentDocument where Id = :contentDocumentId];
- delete conDocument;
- if(cvInfo.size() <= 1){
- Consumable_order__c c = [SELECT Id FROM Consumable_order__c WHERE Id =:cocId];
- c.Consumable_pdf_insert_day__c =null;
- update c;
- }
- results.result = 'Success';
- } catch (Exception e) {
- results.result = 'Fail';
- results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
- }
- return results;
- }
-
- public static void getConsumableShowTableFieldValue(){
- for(ConsumableorderdetailsInfo con :consumableorderdetailsRecordsview){
- if(con.Prod != null){
- con.recordId = con.Prod.Id;
- if(!con.oldCheck){
- con.prodName = con.Prod.Name__c;
- // System.debug('ProdName:'+con.Prod.Id+'---'+con.Prod.Name__c);
- }
- con.prodSFDAStatus = con.Prod.SFDA_Status__c;
- con.prodCategory3 = con.Prod.Category3__c;
- con.prodCategory4 = con.Prod.Category4__c;
- con.prodCategory5 = con.Prod.Category5__c;
- con.prodIntraTradeList = con.Prod.Intra_Trade_List_RMB__c;
- }
- if(con.esd != null){
- // if(con.oldCheck){
- // con.prodName = con.esd.Consumable_Product__r.Name__c;
- // }
- con.consumableCount = con.esd.Consumable_count__c;
- }
- }
- }
-
- public class ConsumableorderdetailsInfo implements Comparable {
- @AuraEnabled
- public Boolean check { get; set; }
- @AuraEnabled
- public Boolean oldCheck { get; set; }
- @AuraEnabled
- public Consumable_Orderdetails__c esd { get; set; }
- @AuraEnabled
- public Product2__c Prod { get; set; }
- @AuraEnabled
- public Integer packing_list { get; set; }
- @AuraEnabled
- public Date expiration_Date { get; set; }
- @AuraEnabled
- public String approbation_No { get; set; }
- @AuraEnabled
- public Decimal allnumber { get; set; }
- @AuraEnabled
- public Decimal allnumber_piece { get; set; }
- @AuraEnabled
- public Decimal oldConsumableCount { get; set; }
- @AuraEnabled
- public Boolean canSelect { get; set; }
- @AuraEnabled
- public ContentVersion Concc { get; set; }
- @AuraEnabled
- public Boolean sortBy { get; set; }
- @AuraEnabled
- public Decimal upperlimit { get; set; }
- @AuraEnabled
- public Decimal lowerlimit { get; set; }
- @AuraEnabled
- public Decimal SpecialCampaignPrice { get; set; }
- @AuraEnabled
- public Decimal orderGoods_Limit { get; set; }
- @AuraEnabled
- public Date Campaign_EndDate { get; set; }
- @AuraEnabled
- public String recordId { get; set; }
- @AuraEnabled
- public String prodName { get; set; }
- @AuraEnabled
- public String prodSFDAStatus { get; set; }
- @AuraEnabled
- public String prodCategory3 { get; set; }
- @AuraEnabled
- public String prodCategory4 { get; set; }
- @AuraEnabled
- public String prodCategory5 { get; set; }
- @AuraEnabled
- public Decimal prodIntraTradeList { get; set; }
- @AuraEnabled
- public Decimal consumableCount { get; set; }
-
-
- // 宸插瓨浜у搧鏄庣粏
- public ConsumableorderdetailsInfo(Consumable_Orderdetails__c e) {
- check = true;
- oldCheck = true;
- esd = e;
- Prod = e.Consumable_Product__r;
- oldConsumableCount = e.Consumable_Count__c;
- canSelect = true;
- allnumber = 0;
- allnumber_piece = 0;
- }
-
- public ConsumableorderdetailsInfo(Product2__c e) {
- check = false;
- oldCheck = false;
- esd = new Consumable_Orderdetails__c();
- Prod = e;
- oldConsumableCount = null;
- canSelect = true;
- allnumber = 0;
- allnumber_piece = 0;
+ }
}
//闄勪欢
- public ConsumableorderdetailsInfo(ContentVersion e) {
- Concc = e;
- }
- // 鎺掑簭Consumable_order__c
- public Integer compareTo(Object compareTo) {
- ConsumableorderdetailsInfo compareToesd = (ConsumableorderdetailsInfo) compareTo;
- Integer returnValue = 0;
- if (check == true) {
- if (sortBy == false) {
- if (allnumber > compareToesd.allnumber) {
- returnValue = -1;
- } else if (allnumber < compareToesd.allnumber) {
- returnValue = 1;
- }
- return returnValue;
- } else {
- if (allnumber > compareToesd.allnumber) {
- returnValue = 1;
- } else if (allnumber < compareToesd.allnumber) {
- returnValue = -1;
- }
- return returnValue;
- }
- } else {
- if (sortBy == false) {
- if (allnumber > compareToesd.allnumber) {
- returnValue = -1;
- } else if (allnumber < compareToesd.allnumber) {
- returnValue = 1;
- }
- return returnValue;
- } else {
- if (allnumber > compareToesd.allnumber) {
- returnValue = 1;
- } else if (allnumber < compareToesd.allnumber) {
- returnValue = -1;
- }
- return returnValue;
- }
+ // attachmentinfo = [SELECT Id, Name, OwnerId, Owner.Name FROM Attachment WHERE parentid = :ESetId];
+ // if (attachmentinfo.size() > 0) {
+ // for (Integer i = 0; i < attachmentinfo.size(); i++) {
+ // attachmentRecoeds.add(new ConsumableorderdetailsInfo(attachmentinfo[i]));
+ // }
+ // }
+ List<ContentDocumentLink> links = [
+ SELECT Id, ContentDocumentId
+ FROM ContentDocumentLink
+ WHERE LinkedEntityId = :ESetId
+ ];
+ if (links != null && links.size() > 0) {
+ List<String> documentIds = new List<String>();
+ for (ContentDocumentLink link : links) {
+ documentIds.add(link.ContentDocumentId);
+ }
+ List<ContentVersion> cvInfo = [
+ SELECT
+ Id,
+ Title,
+ OwnerId,
+ Owner.Name,
+ CreatedDate,
+ ContentDocumentId
+ FROM ContentVersion
+ WHERE ContentDocumentId IN :documentIds
+ ];
+ if (cvInfo.size() > 0) {
+ for (Integer i = 0; i < cvInfo.size(); i++) {
+ attachmentRecoeds.add(new ConsumableorderdetailsInfo(cvInfo[i]));
}
+ }
}
- }
-
- public class Results {
- @AuraEnabled
- public String result;
- @AuraEnabled
- public String errorMsg;
- @AuraEnabled
- public String eSetId;
- @AuraEnabled
- public String agencyProType;
- @AuraEnabled
- public String userWorkLocation;
- @AuraEnabled
- public String accountName;
- @AuraEnabled
- public String accountid;
- @AuraEnabled
- public String hospitalId;
- @AuraEnabled
- public String contractId;
- @AuraEnabled
- public String category_Goods;
- @AuraEnabled
- public Consumable_order__c coc;
- @AuraEnabled
- public Boolean edoffersPrice;
- @AuraEnabled
- public Boolean editDelCommitBtnDisabled;
- @AuraEnabled
- public Boolean editAble;
- @AuraEnabled
- public String hospitalName;
- @AuraEnabled
- public String contractName;
- @AuraEnabled
- public List<CusOption> category3Option;
- @AuraEnabled
- public List<CusOption> category4Option;
- @AuraEnabled
- public List<CusOption> category5Option;
- @AuraEnabled
- public List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsview;
- @AuraEnabled
- public List<ConsumableorderdetailsInfo> attachmentRecoeds;
- @AuraEnabled
- public Boolean cansee;
- @AuraEnabled
- public List<String> errorMsgList;
- @AuraEnabled
- public List<String> warningMsgList;
- @AuraEnabled
- public Boolean hasWarning;
- @AuraEnabled
- public Boolean hasError;
- @AuraEnabled
- public Boolean specialCampaign;
- @AuraEnabled
- public List<String> dealerProductId;
- @AuraEnabled
- public List<String> contactDealer;
- @AuraEnabled
- public String url;
- @AuraEnabled
- public String methodType;
- @AuraEnabled
- public List<String> proLimitAndDate;
- @AuraEnabled
- public Boolean isNoteStay;
- @AuraEnabled
- public Boolean OSHFLG;
- @AuraEnabled
- public String agencyProType1;
- }
-
- public class CusOption {
- CusOption(String label, String value) {
- this.label = label;
- this.value = value;
+ //
+ consumableorderdetailsRecords.sort();
+ getPageInfo();
+ }
+ //璁$畻搴撳瓨涓娿�佷笅闄�
+ productLimtAndDate();
+ lowerRecord();
+ //鏄庣粏鎺掑簭
+ List<String> upper = new List<String>();
+ if (String.isNotBlank(ESetid)) {
+ for (ConsumableorderdetailsInfo bss : consumableorderdetailsRecords) {
+ if (
+ bss.esd.Consumable_count__c != null &&
+ bss.allnumber != null &&
+ bss.upperlimit != null
+ ) {
+ if (bss.esd.Consumable_count__c + bss.allnumber > bss.upperlimit) {
+ upper.add(bss.esd.Consumable_Product__r.Name__c);
+ }
+ }
}
-
- @AuraEnabled
- public String label;
- @AuraEnabled
- public String value;
+ }
+ if (upper.size() > 0) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, '瀛樺湪浠ヤ笅浜у搧璁㈣揣鏁伴噺瓒呭嚭搴撳瓨涓婇檺!'));
+ warningMsgList.add('瀛樺湪浠ヤ笅浜у搧璁㈣揣鏁伴噺瓒呭嚭搴撳瓨涓婇檺!');
+ for (Integer i = 0; i < upper.size(); i++) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, upper[i]));
+ warningMsgList.add(upper[i]);
+ }
+ }
+ if (lower.size() > 0) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, '瀛樺湪浠ヤ笅浜у搧璁㈣揣鏁伴噺浣庝簬搴撳瓨涓嬮檺!'));
+ warningMsgList.add('瀛樺湪浠ヤ笅浜у搧璁㈣揣鏁伴噺浣庝簬搴撳瓨涓嬮檺!');
+ for (Integer i = 0; i < lower.size(); i++) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, lower[i]));
+ warningMsgList.add(lower[i]);
+ }
+ }
+ //浠锋牸鏌ョ湅鏉冮檺
+ Schema.DescribeFieldResult dfr = Product2__c.Intra_Trade_List_RMB__c.getDescribe();
+ cansee = dfr.isAccessible();
+ AggregateResult[] categoryList = [
+ SELECT Count(id), Category3_text__c c3c
+ FROM Product2__c
+ WHERE
+ Estimation_Entry_Possibility__c = '鈼�'
+ AND Product_Type__c LIKE :agencyProType
+ AND Category3_text__c != NULL
+ GROUP BY Category3_text__c
+ ];
+ //categoty3
+ // categoryOptionList = new List<SelectOption>();
+ category3Option = new List<CusOption>();
+ // categoryOptionList.add(new SelectOption('', '-鏃�-'));
+ category3Option.add(new CusOption('-鏃�-', ''));
+ for (AggregateResult category3Search : categoryList) {
+ String deliverycnt = String.valueOf(category3Search.get('c3c'));
+ // categoryOptionList.add(new SelectOption(deliverycnt, deliverycnt));
+ category3Option.add(new CusOption(deliverycnt, deliverycnt));
+ }
+ //categoty4
+ // category4OptionList = new List<SelectOption>();
+ category4Option = new List<CusOption>();
+ // category4OptionList.add(new SelectOption('', '-鏃�-'));
+ category4Option.add(new CusOption('-鏃�-', ''));
+ //categoty5
+ // category5OptionList = new List<SelectOption>();
+ category5Option = new List<CusOption>();
+ // category5OptionList.add(new SelectOption('', '-鏃�-'));
+ category5Option.add(new CusOption('-鏃�-', ''));
+ //return msg
+ consumableorderdetailsRecordsview = consumableorderdetailsRecords;
+ getConsumableShowTableFieldValue();
+ results.result = 'Success';
+ results.coc = coc;
+ results.editAble = editAble;
+ results.edoffersPrice = edoffersPrice;
+ results.editDelCommitBtnDisabled = EditDelCommitBtnDisabled;
+ results.category3Option = category3Option;
+ results.category4Option = category4Option;
+ results.category5Option = category5Option;
+ results.hospitalName = hospitalName;
+ results.contractName = contractName;
+ results.consumableorderdetailsRecordsview = consumableorderdetailsRecordsview;
+ results.attachmentRecoeds = attachmentRecoeds;
+ results.cansee = cansee;
+ results.agencyProType = agencyProType;
+ results.agencyProType1 = agencyProType1;
+ results.OSHFLG = OSHFLG;
+ results.userWorkLocation = userWorkLocation;
+ results.accountName = accountName;
+ results.category_Goods = category_Goods;
+ results.specialCampaign = specialCampaign;
+ results.dealerProductId = DealerProductId;
+ results.accountid = accountid;
+ results.hospitalId = hospitalId;
+ results.contractId = contractId;
+ results.contactDealer = contactDealer;
+ results.errorMsgList = errorMsgList;
+ results.warningMsgList = warningMsgList;
+ results.methodType = methodType;
+ results.proLimitAndDate = proLimitAndDate;
+ } catch (Exception e) {
+ results.result = 'Fail';
+ results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
}
-}
\ No newline at end of file
+ return results;
+ }
+
+ @AuraEnabled
+ public static Results categoryAllload(
+ String agencyProTypeStr,
+ String category3Str
+ ) {
+ Results results = new Results();
+ agencyProType = agencyProTypeStr;
+ category3 = category3Str;
+ try {
+ AggregateResult[] category4List = [
+ SELECT Count(id), Category4_text__c c4c
+ FROM Product2__c
+ WHERE
+ Estimation_Entry_Possibility__c = '鈼�'
+ AND Product_Type__c LIKE :agencyProType
+ AND Category3_text__c = :category3
+ AND Category4_text__c != NULL
+ AND Category5_text__c != NULL
+ GROUP BY Category4_text__c
+ ];
+ // category4OptionList = new List<SelectOption>();
+ category4Option = new List<CusOption>();
+ // category4OptionList.add(new SelectOption('', '-鏃�-'));
+ category4Option.add(new CusOption('-鏃�-', ''));
+ for (AggregateResult category4Search : category4List) {
+ String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
+ // category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
+ category4Option.add(new CusOption(deliverycnt4, deliverycnt4));
+ }
+ AggregateResult[] category5List = [
+ SELECT Count(id), Category5_text__c c5c
+ FROM Product2__c
+ WHERE
+ Estimation_Entry_Possibility__c = '鈼�'
+ AND Product_Type__c LIKE :agencyProType
+ AND Category3_text__c = :category3
+ AND Category4_text__c != NULL
+ AND Category5_text__c != NULL
+ GROUP BY Category5_text__c
+ ];
+ // category5OptionList = new List<SelectOption>();
+ category5Option = new List<CusOption>();
+ // category5OptionList.add(new SelectOption('', '-鏃�-'));
+ category5Option.add(new CusOption('-鏃�-', ''));
+ for (AggregateResult category5Search : category5List) {
+ String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
+ // category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
+ category5Option.add(new CusOption(deliverycnt5, deliverycnt5));
+ }
+ results.category4Option = category4Option;
+ results.category5Option = category5Option;
+ results.result = 'Success';
+ } catch (Exception e) {
+ results.result = 'Fail';
+ results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+ }
+ return results;
+ }
+
+ @AuraEnabled
+ public static Results categoryload(
+ String agencyProTypeStr,
+ String category3Str,
+ String category4Str
+ ) {
+ Results results = new Results();
+ agencyProType = agencyProTypeStr;
+ category3 = category3Str;
+ category4 = category4Str;
+ try {
+ AggregateResult[] category4List = [
+ SELECT Count(id), Category4_text__c c4c
+ FROM Product2__c
+ WHERE
+ Estimation_Entry_Possibility__c = '鈼�'
+ AND Product_Type__c LIKE :agencyProType
+ AND Category3_text__c = :category3
+ AND Category4_text__c != NULL
+ AND Category5_text__c != NULL
+ GROUP BY Category4_text__c
+ ];
+ // category4OptionList = new List<SelectOption>();
+ category4Option = new List<CusOption>();
+ // category4OptionList.add(new SelectOption('', '-鏃�-'));
+ category4Option.add(new CusOption('-鏃�-', ''));
+ for (AggregateResult category4Search : category4List) {
+ String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
+ // category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
+ category4Option.add(new CusOption(deliverycnt4, deliverycnt4));
+ }
+
+ AggregateResult[] category5List = [
+ SELECT Count(id), Category5_text__c c5c
+ FROM Product2__c
+ WHERE
+ Estimation_Entry_Possibility__c = '鈼�'
+ AND Product_Type__c LIKE :agencyProType
+ AND Category3_text__c = :category3
+ AND Category4_text__c = :category4
+ AND Category5_text__c != NULL
+ GROUP BY Category5_text__c
+ ];
+ // category5OptionList = new List<SelectOption>();
+ category5Option = new List<CusOption>();
+ // category5OptionList.add(new SelectOption('', '-鏃�-'));
+ category5Option.add(new CusOption('-鏃�-', ''));
+ for (AggregateResult category5Search : category5List) {
+ String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
+ // category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
+ category5Option.add(new CusOption(deliverycnt5, deliverycnt5));
+ }
+ results.category4Option = category4Option;
+ results.category5Option = category5Option;
+ results.result = 'Success';
+ } catch (Exception e) {
+ results.result = 'Fail';
+ results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+ }
+ return results;
+ }
+
+ // 鐢婚潰鍒濆鍖�
+ public static void lowerRecord() {
+ List<ConsumableorderdetailsInfo> lowerRecord = new List<ConsumableorderdetailsInfo>();
+ //搴撳瓨鏄庣粏鍙栧緱
+ Map<String, ConsumableorderdetailsInfo> midMaprecord = new Map<String, ConsumableorderdetailsInfo>();
+ List<Product2__c> product2Selected = [
+ SELECT Id, Name, Name__c, Intra_Trade_List_RMB__c, Asset_Model_No__c
+ FROM Product2__c
+ WHERE
+ Pro2_Dealer_Object__c = TRUE
+ AND Estimation_Entry_Possibility__c = '鈼�'
+ ];
+ for (Integer i = 0; i < product2Selected.size(); i++) {
+ lowerRecord.add(new ConsumableorderdetailsInfo(product2Selected[i]));
+ //鍏堟妸ConsumableorderdetailsRecords 鍋氭垚map
+ midMaprecord.put(
+ product2Selected[i].Id,
+ new ConsumableorderdetailsInfo(product2Selected[i])
+ );
+ }
+ List<Consumable_order_details2__c> countDel = [
+ SELECT
+ Id,
+ Bar_Code__c,
+ Name,
+ Inventory_date__c,
+ Consumable_Product__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Recordtypeid,
+ Guarantee_period_for_products__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ hospitalSpecialOffer__c,
+ promotionorder__c
+ 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 Lose_Flag__c = FALSE
+ AND Bar_Code__c != NULL
+ AND Isoverdue__c = 1
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ //AND Consumable_order_minor__r.Dealer_Info__c = :accountid
+ AND Dealer_Info_text__c = :accountName
+ ];
+ for (Integer i = 0; i < countDel.size(); i++) {
+ //add by rentx 2020-12-09
+ if (String.isNotBlank(methodType) && methodType.equals('hospitalorder')) {
+ if (countDel[i].hospitalSpecialOffer__c == true) {
+ //鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
+ if (midMaprecord.containsKey(countDel[i].Consumable_Product__c)) {
+ ConsumableorderdetailsInfo Jstage = midMaprecord.get(
+ countDel[i].Consumable_Product__c
+ );
+ if (countDel[i].Box_Piece__c == '鐩�') {
+ Jstage.allnumber = Jstage.allnumber + 1;
+ } else {
+ Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
+ }
+ //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+ midMaprecord.put(countDel[i].Consumable_Product__c, Jstage);
+ }
+ }
+ } else if (
+ String.isBlank(methodType) || methodType.equals('promotionorder')
+ ) {
+ if (countDel[i].promotionorder__c == true) {
+ if (midMaprecord.containsKey(countDel[i].Consumable_Product__c)) {
+ ConsumableorderdetailsInfo Jstage = midMaprecord.get(
+ countDel[i].Consumable_Product__c
+ );
+ if (countDel[i].Box_Piece__c == '鐩�') {
+ Jstage.allnumber = Jstage.allnumber + 1;
+ } else {
+ Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
+ }
+ midMaprecord.put(countDel[i].Consumable_Product__c, Jstage);
+ }
+ }
+ } else if (
+ String.isBlank(methodType) ||
+ (!methodType.equals('promotionorder') &&
+ !methodType.equals('hospitalorder'))
+ ) {
+ if (
+ countDel[i].promotionorder__c == false &&
+ countDel[i].hospitalSpecialOffer__c == false
+ ) {
+ if (midMaprecord.containsKey(countDel[i].Consumable_Product__c)) {
+ ConsumableorderdetailsInfo Jstage = midMaprecord.get(
+ countDel[i].Consumable_Product__c
+ );
+ if (countDel[i].Box_Piece__c == '鐩�') {
+ Jstage.allnumber = Jstage.allnumber + 1;
+ } else {
+ Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
+ }
+ midMaprecord.put(countDel[i].Consumable_Product__c, Jstage);
+ }
+ }
+ }
+ }
+ lowerRecord = new List<ConsumableorderdetailsInfo>();
+ //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecords
+ for (ConsumableorderdetailsInfo bss : midMaprecord.values()) {
+ lowerRecord.add(bss);
+ }
+ allProductLimt(lowerRecord);
+ for (ConsumableorderdetailsInfo bss : lowerRecord) {
+ if (bss.allnumber < bss.lowerlimit) {
+ lower.add(bss.Prod.Name__c);
+ }
+ }
+ }
+
+ //搴撳瓨涓婁笅闄�
+ public static void productLimtAndDate() {
+ String nowName = null, nowRightAsstModelNo = null;
+ Map<String, String> productLimt = new Map<String, String>();
+ for (Integer i = 0; i < proLimitAndDate.size(); i++) {
+ nowName = proLimitAndDate[i];
+ if (nowName.indexOf('|') >= 0) {
+ nowRightAsstModelNo = nowName.subString(0, nowName.indexOf('|'));
+ nowName = nowName.subString(nowName.indexOf('|') + 1);
+ }
+ productLimt.put(nowRightAsstModelNo, nowName);
+ }
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ if (productLimt.containsKey(ass.Prod.Asset_Model_No__c)) {
+ ass.lowerlimit = decimal.valueOf(
+ productLimt.get(ass.Prod.Asset_Model_No__c)
+ .subString(
+ 0,
+ productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|')
+ )
+ );
+ ass.upperlimit = decimal.valueOf(
+ productLimt.get(ass.Prod.Asset_Model_No__c)
+ .subString(
+ productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|') + 1
+ )
+ );
+ }
+ }
+ }
+
+ //鍏ㄩ儴搴撳瓨涓婁笅闄�
+ private static void allProductLimt(
+ List<ConsumableorderdetailsInfo> lowerRecord
+ ) {
+ String nowName = null, nowRightAsstModelNo = null;
+ Map<String, String> productLimt = new Map<String, String>();
+ for (Integer i = 0; i < proLimitAndDate.size(); i++) {
+ nowName = proLimitAndDate[i];
+ if (nowName.indexOf('|') >= 0) {
+ nowRightAsstModelNo = nowName.subString(0, nowName.indexOf('|'));
+ nowName = nowName.subString(nowName.indexOf('|') + 1);
+ }
+ productLimt.put(nowRightAsstModelNo, nowName);
+ }
+ for (ConsumableorderdetailsInfo ass : lowerRecord) {
+ if (productLimt.containsKey(ass.Prod.Asset_Model_No__c)) {
+ ass.lowerlimit = decimal.valueOf(
+ productLimt.get(ass.Prod.Asset_Model_No__c)
+ .subString(
+ 0,
+ productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|')
+ )
+ );
+ ass.upperlimit = decimal.valueOf(
+ productLimt.get(ass.Prod.Asset_Model_No__c)
+ .subString(
+ productLimt.get(ass.Prod.Asset_Model_No__c).indexOf('|') + 1
+ )
+ );
+ }
+ }
+ }
+
+ @AuraEnabled
+ public static Results searchConsumableorderdetails(
+ String userWorkLocationStr,
+ String agencyProTypeStr,
+ String accountNameStr,
+ String accountIdStr,
+ String hospitalIdStr,
+ String contractIdStr,
+ String category1Str,
+ String category3Str,
+ String category4Str,
+ String category5Str,
+ String category_GoodStr,
+ Boolean specialCampaignStr,
+ String dealerProductIdStr,
+ String methodTypeStr,
+ String consumableorderdetailsRecordsviewStr,
+ Boolean editAbleStr,
+ List<String> proLimitAndDateList
+ ) {
+ Results results = new Results();
+ errorMsgList = new List<String>();
+ warningMsgList = new List<String>();
+ userWorkLocation = userWorkLocationStr;
+ agencyProType = agencyProTypeStr;
+ accountName = accountNameStr;
+ accountid = accountIdStr;
+ hospitalId = hospitalIdStr;
+ contractId = contractIdStr;
+ category1 = category1Str;
+ category3 = category3Str;
+ category4 = category4Str;
+ category5 = category5Str;
+ category_Goods = category_GoodStr;
+ specialCampaign = specialCampaignStr;
+ methodType = methodTypeStr;
+ editAble = editAbleStr;
+ proLimitAndDate = proLimitAndDateList;
+ dealerProductId = (List<String>) JSON.deserialize(
+ dealerProductIdStr,
+ List<String>.class
+ );
+ consumableorderdetailsRecordsview = (List<ConsumableorderdetailsInfo>) JSON.deserialize(
+ consumableorderdetailsRecordsviewStr,
+ List<ConsumableorderdetailsInfo>.class
+ );
+ size = Integer.valueOf(System.Label.orderdetLimitsize);
+ pageLimit = Integer.valueOf(System.Label.orderdetPageLimitsize);
+ try {
+ searchDone = 'searchDone';
+ sortKey = '1';
+ preSortKey = '1';
+ sortOrderAsc = false;
+ sortOrder = new String[7];
+ sortOrder = new List<String>{ ' ', ' ', ' ', ' ', '鈫�', '', '', '' };
+ Map<String, String> selectedIdMap = new Map<String, String>();
+ List<ConsumableorderdetailsInfo> derdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>();
+ List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
+ List<Consumable_order_details2__c> countDel = [
+ SELECT
+ Id,
+ Bar_Code__c,
+ Name,
+ Inventory_date__c,
+ Consumable_Product__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Recordtypeid,
+ Box_Piece__c,
+ //add by rentx 2020-12-09
+ hospitalSpecialOffer__c,
+ promotionorder__c
+ //add by rentx 2020-12-09
+ 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 Lose_Flag__c = FALSE
+ AND Bar_Code__c != NULL
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Dealer_Info_text__c = :accountName
+ ];
+ List<Product2__c> product2Selected = new List<Product2__c>();
+ consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ soql = makeSoql(
+ category1,
+ category_Goods,
+ category3,
+ category4,
+ category5,
+ specialCampaign,
+ DealerProductId
+ );
+ size = Integer.valueOf(System.Label.orderdetLimitsize);
+ initStandardController();
+ System.debug('soql:' + soql);
+ product2Selected = Database.query(soql);
+ for (Integer i = 0; i < product2Selected.size(); i++) {
+ MidMap.put(
+ product2Selected[i].Id,
+ new ConsumableorderdetailsInfo(product2Selected[i])
+ );
+ }
+ for (Integer i = 0; i < countDel.size(); i++) {
+ //鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
+ if (
+ String.isNotBlank(methodType) && methodType.equals('hospitalorder')
+ ) {
+ if (countDel[i].hospitalSpecialOffer__c == true) {
+ if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ countDel[i].Consumable_Product__c
+ );
+ if (countDel[i].Box_Piece__c == '鐩�') {
+ Jstage.allnumber = Jstage.allnumber + 1;
+ } else {
+ Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
+ }
+ MidMap.put(countDel[i].Consumable_Product__c, Jstage);
+ }
+ }
+ } else if (
+ String.isBlank(methodType) || methodType.equals('promotionorder')
+ ) {
+ if (countDel[i].promotionorder__c == true) {
+ if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ countDel[i].Consumable_Product__c
+ );
+ if (countDel[i].Box_Piece__c == '鐩�') {
+ Jstage.allnumber = Jstage.allnumber + 1;
+ } else {
+ Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
+ }
+ MidMap.put(countDel[i].Consumable_Product__c, Jstage);
+ }
+ }
+ } else if (
+ String.isBlank(methodType) ||
+ (!methodType.equals('promotionorder') &&
+ !methodType.equals('hospitalorder'))
+ ) {
+ if (
+ countDel[i].promotionorder__c == false &&
+ countDel[i].hospitalSpecialOffer__c == false
+ ) {
+ if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ countDel[i].Consumable_Product__c
+ );
+ if (countDel[i].Box_Piece__c == '鐩�') {
+ Jstage.allnumber = Jstage.allnumber + 1;
+ } else {
+ Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
+ }
+ MidMap.put(countDel[i].Consumable_Product__c, Jstage);
+ }
+ }
+ }
+ }
+ //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecordsa0l0l0000000byXAAQ
+ for (ConsumableorderdetailsInfo bss : MidMap.values()) {
+ if (selectedIdMap.containsKey(bss.Prod.id)) {
+ continue;
+ } else {
+ if (DealerProductMap.containsKey(bss.Prod.Id)) {
+ bss.SpecialCampaignPrice = DealerProductMap.get(bss.Prod.Id)
+ .Special_Campaign_Price__c;
+ bss.Campaign_EndDate = DealerProductMap.get(bss.Prod.Id)
+ .Campaign_EndDate__c;
+ bss.orderGoods_Limit = DealerProductMap.get(bss.Prod.Id)
+ .OrderGoods_Limit__c;
+ }
+ bss.sortBy = sortOrderAsc;
+ bss.packing_list = Integer.valueOf(
+ bss.Prod.Product2__r.Packing_list_manual__c
+ );
+ bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
+ bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
+ consumableorderdetailsRecords.add(bss);
+ }
+ }
+ consumableorderdetailsRecords.sort();
+ productLimtAndDate();
+ getPageInfo();
+ sortKey = '1';
+ preSortKey = '1';
+ sortOrderAsc = false;
+ sortOrder = new String[7];
+ sortOrder = new List<String>{ ' ', ' ', '銆�', '', '', '', '', '' };
+ cate1ForSort = category1;
+ // 鏄剧ず鏁版嵁鏉℃暟淇℃伅
+ // makeMessage();
+ results.errorMsgList = errorMsgList;
+ results.warningMsgList = warningMsgList;
+ if (consumableorderdetailsRecords.size() > 0) {
+ getConsumableShowTableFieldValue();
+ results.result = 'Success';
+ results.consumableorderdetailsRecordsview = consumableorderdetailsRecordsview;
+ results.errorMsg =
+ '鎼滅储鍒�' +
+ consumableorderdetailsRecords.size() +
+ '浠朵骇鍝�';
+ } else {
+ getConsumableShowTableFieldValue();
+ results.result = 'Fail';
+ results.consumableorderdetailsRecordsview = consumableorderdetailsRecordsview;
+ results.errorMsg = '娌℃湁鎼滅储鍒扮浉鍏虫暟鎹�';
+ }
+ } catch (Exception e) {
+ results.result = 'Fail';
+ results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+ }
+ return results;
+ }
+
+ //鍖婚櫌--妫�绱�
+ @AuraEnabled
+ public static Results searchorderdetails(
+ String methodTypeStr,
+ String accountIdStr,
+ String hospitalIdStr,
+ String contractIdStr,
+ String userWorkLocationStr,
+ String accountNameStr,
+ List<String> proLimitAndDateList,
+ Boolean editAbleStr
+ ) {
+ Results results = new Results();
+ methodType = methodTypeStr;
+ accountId = accountIdStr;
+ hospitalId = hospitalIdStr;
+ contractId = contractIdStr;
+ userWorkLocation = userWorkLocationStr;
+ accountName = accountNameStr;
+ proLimitAndDate = proLimitAndDateList;
+ editAble = editAbleStr;
+ size = Integer.valueOf(System.Label.orderdetLimitsize);
+ pageLimit = Integer.valueOf(System.Label.orderdetPageLimitsize);
+ try {
+ soql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Product2__r.Packing_list_manual__c,Category3__c,Category4__c,Category5__c FROM Product2__c WHERE Estimation_Entry_Possibility__c = \'鈼媆' ';
+ if (methodType.equals('hospitalorder')) {
+ //鍖婚櫌id 鏈夊��
+ List<hospitalprice__c> hplist = [
+ SELECT id, product__c
+ FROM hospitalprice__c
+ WHERE account__c = :accountid AND hospital__c = :hospitalId
+ ];
+ if (hplist != null && hplist.size() > 0) {
+ List<String> hpids = new List<String>();
+ for (hospitalprice__c hc : hplist) {
+ hpids.add(hc.product__c);
+ }
+
+ if (hpids != null && hpids.size() > 0) {
+ soql += ' AND Id in : hpids ';
+ }
+ } else {
+ //璇ュ尰闄笅娌℃湁绗﹀悎鍖婚櫌鐗逛环鐨勪骇鍝�
+ soql += ' AND Id = null ';
+ }
+ } else if (methodType.equals('promotionorder')) {
+ List<Dealer_Product__c> dpclist = [
+ SELECT Id, Dealer_Product2__c
+ FROM Dealer_Product__c
+ WHERE
+ Dealer_Contact__c = :contractId
+ AND (Special_Discount__c != NULL
+ OR Special_Campaign_Price__c != NULL)
+ ];
+ if (dpclist != null && dpclist.size() > 0) {
+ String ids = '(';
+ for (Dealer_Product__c hc : dpclist) {
+ hpids.add(hc.Dealer_Product2__c);
+ ids += '\'' + hc.Dealer_Product2__c + '\',';
+ }
+ ids = ids.substring(0, ids.length() - 1) + ')';
+ if (hpids != null && hpids.size() > 0) {
+ // soql += ' AND Id in : hpids ';
+ soql += ' AND Id in ' + ids;
+ }
+ } else {
+ //璇ョ粡閿�鍟嗕笅娌℃湁淇冮攢浠锋牸鐨勪骇鍝�
+ soql += ' AND Id = null ';
+ }
+ }
+ size = Integer.valueOf(System.Label.orderdetLimitsize);
+ initStandardController();
+ List<Product2__c> product2Selected = new List<Product2__c>();
+ Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>();
+ Map<String, String> selectedIdMap = new Map<String, String>();
+ consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ product2Selected = Database.query(soql);
+ for (Integer i = 0; i < product2Selected.size(); i++) {
+ MidMap.put(
+ product2Selected[i].Id,
+ new ConsumableorderdetailsInfo(product2Selected[i])
+ );
+ }
+ List<Consumable_order_details2__c> countDel = [
+ SELECT
+ Id,
+ Bar_Code__c,
+ Name,
+ Inventory_date__c,
+ Consumable_Product__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Recordtypeid,
+ Box_Piece__c,
+ hospitalSpecialOffer__c,
+ promotionorder__c
+ 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 Lose_Flag__c = FALSE
+ AND Bar_Code__c != NULL
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ //AND Consumable_order_minor__r.Dealer_Info__c = :accountid
+ AND Dealer_Info_text__c = :accountName
+ ];
+ for (Integer i = 0; i < countDel.size(); i++) {
+ if (methodType.equals('hospitalorder')) {
+ if (countDel[i].hospitalSpecialOffer__c == true) {
+ //鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
+ if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ countDel[i].Consumable_Product__c
+ );
+ if (countDel[i].Box_Piece__c == '鐩�') {
+ Jstage.allnumber = Jstage.allnumber + 1;
+ } else {
+ Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
+ }
+ //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+ MidMap.put(countDel[i].Consumable_Product__c, Jstage);
+ }
+ }
+ } else if (methodType.equals('promotionorder')) {
+ if (countDel[i].promotionorder__c == true) {
+ //鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
+ if (MidMap.containsKey(countDel[i].Consumable_Product__c)) {
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ countDel[i].Consumable_Product__c
+ );
+ if (countDel[i].Box_Piece__c == '鐩�') {
+ Jstage.allnumber = Jstage.allnumber + 1;
+ } else {
+ Jstage.allnumber_piece = Jstage.allnumber_piece + 1;
+ }
+ //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+ MidMap.put(countDel[i].Consumable_Product__c, Jstage);
+ }
+ }
+ }
+ }
+ //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecordsa0l0l0000000byXAAQ
+ for (ConsumableorderdetailsInfo bss : MidMap.values()) {
+ if (selectedIdMap.containsKey(bss.Prod.id)) {
+ continue;
+ } else {
+ if (DealerProductMap.containsKey(bss.Prod.Id)) {
+ bss.SpecialCampaignPrice = DealerProductMap.get(bss.Prod.Id)
+ .Special_Campaign_Price__c;
+ bss.Campaign_EndDate = DealerProductMap.get(bss.Prod.Id)
+ .Campaign_EndDate__c;
+ bss.orderGoods_Limit = DealerProductMap.get(bss.Prod.Id)
+ .OrderGoods_Limit__c;
+ }
+ bss.sortBy = sortOrderAsc;
+ bss.packing_list = Integer.valueOf(
+ bss.Prod.Product2__r.Packing_list_manual__c
+ );
+ bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
+ bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
+ consumableorderdetailsRecords.add(bss);
+ }
+ }
+ consumableorderdetailsRecords.sort();
+ productLimtAndDate();
+ getPageInfoForHos();
+ sortKey = '1';
+ preSortKey = '1';
+ sortOrderAsc = false;
+ sortOrder = new String[7];
+ sortOrder = new List<String>{ ' ', ' ', '銆�', '', '', '', '', '' };
+ cate1ForSort = category1;
+ // 鏄剧ず鏁版嵁鏉℃暟淇℃伅
+ noOfRecords = consumableorderdetailsRecords.size();
+ getConsumableShowTableFieldValue();
+ results.consumableorderdetailsRecordsview = consumableorderdetailsRecordsview;
+ if (consumableorderdetailsRecordsview.size() > 0) {
+ results.result = 'Success';
+ results.errorMsg =
+ '鍏辨悳绱㈠埌' +
+ consumableorderdetailsRecordsview.size() +
+ '鏉℃暟鎹�';
+ } else {
+ results.result = 'Fail';
+ results.errorMsg = '娌℃湁鎼滅储鍒扮浉鍏虫暟鎹�';
+ }
+ } catch (Exception e) {
+ results.result = 'Fail';
+ results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+ }
+ return results;
+ }
+
+ //鐢ㄦ埛鍒囨崲鍖婚櫌鏃跺彇娑堥�変腑鐨勪骇鍝�
+ private static List<ConsumableorderdetailsInfo> getPageInfoForHos() {
+ List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
+ Map<String, String> selectedIdMap = new Map<String, String>();
+ consumableorderdetailsRecordsview = new List<ConsumableorderdetailsInfo>();
+ if (editAble) {
+ consumableorderdetailsRecordsview = reSet;
+ }
+ Integer pagestartNo = (con.getPageNumber() * size) - size;
+ Integer pageendNo = (con.getPageNumber() * size) > noOfRecords
+ ? noOfRecords
+ : (con.getPageNumber() * size - 1);
+ Integer addNo = 0;
+ for (
+ Integer i = pagestartNo; i < consumableorderdetailsRecords.size(); i++
+ ) {
+ Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c();
+ if (selectedIdMap.containsKey(consumableorderdetailsRecords[i].Prod.Id)) {
+ addNo++;
+ //continue;
+ }
+ // else if (consumableorderdetailsRecordsview.size() >= pageLimit + size) {
+ // break;
+ // }
+ else {
+ if (consumableorderdetailsRecords[i].check == false) {
+ consumableorderdetailsRecords[i].esd = orderdetails1;
+ }
+ consumableorderdetailsRecordsview.add(consumableorderdetailsRecords[i]);
+ addNo++;
+ }
+ // if (addNo >= size){
+ // break;
+ // }
+ }
+ return consumableorderdetailsRecordsview;
+ }
+ //add by rentx 2020-12-03 end =====================================================================================================================
+ //鐗逛环
+ public static void OffersPrice() {
+ edoffersPrice = true;
+ }
+
+ //寰楀埌淇冮攢浜у搧Id
+ private static List<String> getDealerProductId() {
+ List<String> ProductId = new List<String>();
+ Map<String, String> DealerProductIdMap = new Map<String, String>();
+ Date dateToday = Date.today();
+ List<Dealer_Product__c> DealerProductList = [
+ SELECT
+ Id,
+ Name,
+ Dealer_Product2__c,
+ Special_Campaign_Price__c,
+ Campaign_StartDate__c,
+ Campaign_EndDate__c,
+ Dealer_Contact__c,
+ OrderGoods_Limit__c
+ FROM Dealer_Product__c
+ WHERE
+ Dealer_Contact__c IN :contactDealer
+ AND Campaign_StartDate__c <= :dateToday
+ AND Campaign_EndDate__c >= :dateToday
+ AND Special_Campaign_Price__c != NULL
+ ];
+ for (Dealer_Product__c dealerProduct : DealerProductList) {
+ if (DealerProductIdMap.containsKey(dealerProduct.Dealer_Product2__c)) {
+ continue;
+ } else {
+ ProductId.add(dealerProduct.Dealer_Product2__c);
+ DealerProductIdMap.put(
+ dealerProduct.Dealer_Product2__c,
+ dealerProduct.Dealer_Product2__c
+ );
+ }
+ }
+ return ProductId;
+ }
+
+ private static String makeSoql(
+ String CateName,
+ String CateCode,
+ String Category3,
+ String Category4,
+ String Category5,
+ Boolean specialCampaign,
+ List<String> DealerProductId
+ ) {
+ String soql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Product2__r.Packing_list_manual__c,Category3__c,Category4__c,Category5__c FROM Product2__c WHERE Estimation_Entry_Possibility__c = \'鈼媆' ';
+ // add begin ================================================================================================
+ if (methodType != null && methodType.equals('hospitalorder')) {
+ //濡傛灉鏄尰闄㈢壒浠�
+ //1.鍒ゆ柇 鍖婚櫌id鏄惁鏈夊�� 濡傛灉鏈夊�� 鍒欐牴鎹尰闄d鍘� 鍖婚櫌鐗逛环琛ㄤ腑鑾峰彇浜у搧id
+ //鍖婚櫌id 鏈夊��
+ if (hospitalId == null || hospitalId == '') {
+ soql += ' and id = null ';
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, '璇烽�夋嫨鍖婚櫌'));
+ warningMsgList.add('璇烽�夋嫨鍖婚櫌');
+ } else {
+ List<hospitalprice__c> hplist = [
+ SELECT id, product__c
+ FROM hospitalprice__c
+ WHERE account__c = :accountid AND hospital__c = :hospitalId
+ ];
+ if (hplist != null && hplist.size() > 0) {
+ hpids = new List<String>();
+ for (hospitalprice__c hc : hplist) {
+ hpids.add(hc.product__c);
+ }
+ if (hpids != null && hpids.size() > 0) {
+ soql += ' AND Id in : hpids ';
+ }
+ } else {
+ //璇ュ尰闄笅娌℃湁绗﹀悎鍖婚櫌鐗逛环鐨勪骇鍝�
+ soql += ' AND Id = null ';
+ return soql;
+ }
+ }
+ }
+ //淇冮攢璁㈣揣
+ if (methodType != null && methodType.equals('promotionorder')) {
+ if (contractId == null || contractId == '') {
+ soql += ' and id = null ';
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING, '璇烽�夋嫨鍚堝悓'));
+ warningMsgList.add('璇烽�夋嫨鍚堝悓');
+ } else {
+ //1.鏌ヨ鎵�鏈夌粡閿�鍟嗕骇鍝�
+ List<Dealer_Product__c> dpclist = [
+ SELECT Id, Dealer_Product2__c
+ FROM Dealer_Product__c
+ WHERE
+ Dealer_Contact__c = :contractId
+ AND (Special_Discount__c != NULL
+ OR Special_Campaign_Price__c != NULL)
+ ];
+
+ if (dpclist != null && dpclist.size() > 0) {
+ hpids = new List<String>();
+ for (Dealer_Product__c hc : dpclist) {
+ hpids.add(hc.Dealer_Product2__c);
+ }
+ if (hpids != null && hpids.size() > 0) {
+ soql += ' AND Id in : hpids ';
+ }
+ } else {
+ //璇ョ粡閿�鍟嗕笅娌℃湁淇冮攢浠锋牸鐨勪骇鍝�
+ soql += ' AND Id = null ';
+ return soql;
+ }
+ }
+ }
+ //add end ===================================================================================================
+ if (!String.isBlank(CateName)) {
+ soql +=
+ ' AND (Name__c like \'%' +
+ String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
+ '%\' or Asset_Model_No__c like \'%' +
+ String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
+ '%\')';
+ }
+ if (!String.isBlank(Category3)) {
+ soql += ' AND Category3__c = \'' + Category3 + '\'';
+ }
+ if (!String.isBlank(Category4)) {
+ soql += ' AND Category4__c = \'' + Category4 + '\'';
+ }
+ if (!String.isBlank(Category5)) {
+ soql += ' AND Category5__c = \'' + Category5 + '\'';
+ }
+ if (agencyProType == 'ET') {
+ soql += ' AND Pro2_Dealer_Object__c = true';
+ }
+ if (agencyProType == 'ENG') {
+ soql += ' AND Pro2_Dealer_ENG__c = true';
+ }
+ soql += ' AND Intra_Trade_List_RMB__c > 0 ';
+ System.debug('soql +++++++++++ ' + soql);
+ return soql;
+ }
+
+ private static String makeSoqlorderdet() {
+ String sqlTail = '(\'';
+ for (Integer i = 0; i < orderzaikuId.size(); i++) {
+ if (i < orderzaikuId.size() - 1) {
+ sqlTail += orderzaikuId[i] + '\',\'';
+ } else {
+ sqlTail += orderzaikuId[i] + '\')';
+ }
+ }
+ String soql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Product2__r.Packing_list_manual__c,Category3__c,Category4__c,Category5__c FROM Product2__c WHERE Estimation_Entry_Possibility__c = \'鈼媆' ';
+ System.debug('sqlTail:' + sqlTail);
+ System.debug('orderzaikuId:' + orderzaikuId);
+ if (orderzaikuId.size() > 0) {
+ soql += ' AND Id in' + sqlTail;
+ }
+ return soql;
+ }
+
+ // 缂栬緫鎸夐挳
+ @AuraEnabled
+ public static Results setEditAble(String eSetidStr) {
+ Results results = new Results();
+ ESetId = eSetidStr;
+ try {
+ statusEdit = 'Redirect';
+ List<Consumable_order__c> oclist = [
+ SELECT orderPattern__c
+ FROM Consumable_order__c
+ WHERE id = :ESetid
+ ];
+ String url =
+ '/lexconsumable?ESetid=' +
+ ESetid +
+ '&KeyWords=' +
+ statusEdit +
+ '&type=' +
+ oclist.get(0).orderPattern__c;
+ results.result = 'Success';
+ results.url = url;
+ } catch (Exception e) {
+ results.result = 'Fail';
+ results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+ }
+ return results;
+ }
+
+ // 鍐嶇敵璇�
+ @AuraEnabled
+ public static Results backOrder(String eSetidStr) {
+ Results results = new Results();
+ ESetId = eSetidStr;
+ statusEdit = 'Redirect';
+ returnOrder = true;
+ try {
+ statusEdit = 'Redirect';
+ List<Consumable_order__c> oclist = [
+ SELECT orderPattern__c
+ FROM Consumable_order__c
+ WHERE id = :ESetid
+ ];
+ String url =
+ '/lexconsumable?ESetid=' +
+ ESetid +
+ '&KeyWords=' +
+ statusEdit +
+ '&type=' +
+ oclist.get(0).orderPattern__c;
+ results.result = 'Success';
+ results.url = url;
+ } catch (Exception e) {
+ results.result = 'Fail';
+ results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+ }
+ return results;
+ }
+
+ //涓婁紶闄勪欢
+ @AuraEnabled
+ public static Results filesUpload(
+ String pId,
+ String fileName,
+ String base64Data
+ ) {
+ Results results = new Results();
+ try {
+ base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
+ ContentVersion cv = new ContentVersion();
+ cv.Title = fileName;
+ cv.PathOnClient = '/' + fileName;
+ cv.FirstPublishLocationId = pId;
+ cv.VersionData = EncodingUtil.base64Decode(base64Data);
+ cv.IsMajorVersion = true;
+ insert cv;
+ Consumable_order__c c = [
+ SELECT Id
+ FROM Consumable_order__c
+ WHERE Id = :pId
+ ];
+ c.Consumable_pdf_insert_day__c = Date.today();
+ update c;
+ results.result = 'Success';
+ } catch (Exception e) {
+ results.result = 'Fail';
+ results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+ }
+ return results;
+ }
+
+ //鍒犻櫎鎸夐挳
+ @AuraEnabled
+ public static Results delConsumable(String eSetidStr) {
+ Results results = new Results();
+ ESetId = eSetidStr;
+ try {
+ Consumable_order__c cord = new Consumable_order__c(Id = ESetId);
+ List<Consumable_Orderdetails__c> orderdetails1 = [
+ SELECT Id
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c = :EsetId
+ ];
+ delete orderdetails1;
+ delete cord;
+ results.result = 'Success';
+ results.url = '/lexconsumableordermanage';
+ } catch (Exception e) {
+ results.result = 'Fail';
+ results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+ }
+ return results;
+ }
+
+ // 鎻愪氦鎸夐挳
+ @AuraEnabled
+ public static Results sorder(String eSetidStr, String accountidStr) {
+ Results results = new Results();
+ errorMsgList = new List<String>();
+ warningMsgList = new List<String>();
+ ESetId = eSetidStr;
+ accountid = accountidStr;
+ Savepoint sp = Database.setSavepoint();
+ try {
+ Map<Id, String> prodMap = new Map<Id, String>();
+ Consumable_order__c P = new Consumable_order__c();
+ P = new Consumable_order__c();
+ p.Id = ESetId;
+ p.Order_date__c = Date.today();
+ p.Order_status__c = '闄勪欢涓婁紶瀹屾垚';
+ for (Consumable_Orderdetails__c cod1 : [
+ SELECT Consumable_product__r.Product2__c, Consumable_product__r.Name__c
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c = :ESetId
+ ]) {
+ prodMap.put(
+ cod1.Consumable_product__r.Product2__c,
+ cod1.Consumable_product__r.Name__c
+ );
+ }
+ // GZW 鎻愪氦浜у搧鏃犳晥 鍑洪敊璇秷鎭�
+ System.debug(prodMap);
+ Map<String, String> chkMap = OpportunityWebService.MapCheckProRegisterDecide(
+ prodMap,
+ accountid,
+ ''
+ );
+ System.debug(chkMap);
+ if (chkMap.size() > 0) {
+ if (chkMap.containsKey('agency')) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '绗竴缁忛攢鍟嗘病鏈夋湁鏁堢殑鍖荤枟鍣ㄦ缁忚惀璁稿彲璇併��'));
+ errorMsgList.add('绗竴缁忛攢鍟嗘病鏈夋湁鏁堢殑鍖荤枟鍣ㄦ缁忚惀璁稿彲璇併��');
+ }
+ for (String proId : prodMap.keySet()) {
+ if (chkMap.containsKey(proId)) {
+ if (chkMap.get(proId) == '1') {
+ // ApexPages.addmessage(
+ // new ApexPages.message(ApexPages.severity.Error, '浜у搧 ' + prodMap.get(proId) + ' 娌℃湁鏈夋晥鐨勬敞鍐岃瘉銆�')
+ // );
+ errorMsgList.add(
+ '浜у搧 ' + prodMap.get(proId) + ' 娌℃湁鏈夋晥鐨勬敞鍐岃瘉銆�'
+ );
+ } else if (chkMap.get(proId) == '2') {
+ // ApexPages.addmessage(
+ // new ApexPages.message(ApexPages.severity.Error, '浜у搧 ' + prodMap.get(proId) + ' 瓒呰繃缁忛攢鍟嗙粡钀ヨ寖鍥淬��')
+ // );
+ errorMsgList.add(
+ '浜у搧 ' + prodMap.get(proId) + ' 瓒呰繃缁忛攢鍟嗙粡钀ヨ寖鍥淬��'
+ );
+ }
+ }
+ }
+ results.result = 'Fail';
+ results.errorMsg = '';
+ results.errorMsgList = errorMsgList;
+ results.warningMsgList = warningMsgList;
+ return results;
+ }
+ update p;
+ Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest();
+ psr.setObjectId(ESetId);
+ Approval.ProcessResult submitResult = Approval.process(psr);
+ results.result = 'Success';
+ results.url = '/lexconsumableordermanage';
+ } catch (Exception e) {
+ Database.rollback(sp);
+ results.result = 'Fail';
+ results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+ }
+ return results;
+ }
+
+ // 椹冲洖璁㈠崟copy
+ @AuraEnabled
+ public static Results ordrCopy(
+ String contractNameStr,
+ String cocStr,
+ String agencyProTypeStr,
+ String accountidStr,
+ String consumableorderdetailsRecordsviewStr,
+ String contactDealerStr,
+ String methodTypeStr,
+ String hospitalIdStr,
+ String contractIdStr,
+ String agencyProType1Str,
+ Boolean OSHFLGStr
+ ) {
+ ESetId = '';
+ return save(
+ contractNameStr,
+ cocStr,
+ agencyProTypeStr,
+ accountidStr,
+ consumableorderdetailsRecordsviewStr,
+ contactDealerStr,
+ methodTypeStr,
+ ESetId,
+ hospitalIdStr,
+ contractIdStr,
+ agencyProType1Str,
+ OSHFLGStr
+ );
+ }
+
+ //淇濆瓨鎸夐挳
+ @AuraEnabled
+ public static Results save(
+ String contractNameStr,
+ String cocStr,
+ String agencyProTypeStr,
+ String accountidStr,
+ String consumableorderdetailsRecordsviewStr,
+ String contactDealerStr,
+ String methodTypeStr,
+ String eSetIdStr,
+ String hospitalIdStr,
+ String contractIdStr,
+ String agencyProType1Str,
+ Boolean OSHFLGStr
+ ) {
+ Results results = new Results();
+ errorMsgList = new List<String>();
+ warningMsgList = new List<String>();
+ contractName = contractNameStr;
+ agencyProType = agencyProTypeStr;
+ accountid = accountidStr;
+ methodType = methodTypeStr;
+ ESetId = eSetIdStr;
+ hospitalId = hospitalIdStr;
+ contractId = contractIdStr;
+ agencyProType1 = agencyProType1Str;
+ OSHFLG = OSHFLGStr;
+ coc = (Consumable_order__c) JSON.deserialize(
+ cocStr,
+ Consumable_order__c.class
+ );
+ contactDealer = (List<String>) JSON.deserialize(
+ contactDealerStr,
+ List<String>.class
+ );
+ System.debug(
+ 'consumableorderdetailsRecordsviewStr:' +
+ consumableorderdetailsRecordsviewStr
+ );
+ consumableorderdetailsRecordsview = (List<ConsumableorderdetailsInfo>) JSON.deserialize(
+ consumableorderdetailsRecordsviewStr,
+ List<ConsumableorderdetailsInfo>.class
+ );
+ if (coc.Offers_Price__c != null) {
+ String offerStr = String.valueOf(coc.Offers_Price__c);
+ bargainPrice = Decimal.valueOf(offerStr.replace(',', ''));
+ }
+ Savepoint sp = Database.setSavepoint();
+ try {
+ if (String.isEmpty(contractName)) {
+ // coc.Order_effective_contact__c.addError('璇烽�夋嫨鍚堝悓');
+ results.result = 'Fail';
+ results.errorMsg = '璇烽�夋嫨鍚堝悓';
+ return results;
+ }
+ List<Account> contract = [
+ SELECT
+ Id,
+ Name,
+ Contract_Department_Class__c,
+ Contract_Quote_Decide_Flag__c
+ FROM account
+ WHERE
+ Name = :contractName
+ AND Id = :contractId //lt 20230517 瀹夊窘涓ょエ鍒� add
+ AND Contract_Decide_Start_Date__c <= :Date.Today()
+ AND Contract_Decide_End_Date__c >= :Date.Today()
+ AND Contact_Type__c LIKE :agencyProType1 //lt 20230517 瀹夊窘涓ょエ鍒� add 1
+ AND Agent_Ref__c = :accountid
+ AND OSH_Dealer__c = :OSHFLG //lt 20230517 瀹夊窘涓ょエ鍒� add
+ ];
+ if (contract.size() <= 0) {
+ // coc.Order_effective_contact__c.addError('涓嶅瓨鍦ㄧ殑鍚堝悓锛岃閲嶆柊纭銆�');
+ results.result = 'Fail';
+ results.errorMsg = '涓嶅瓨鍦ㄧ殑鍚堝悓锛岃閲嶆柊纭銆�';
+ return results;
+ } else {
+ if (String.isEmpty(contract[0].Contract_Quote_Decide_Flag__c)) {
+ // coc.Order_effective_contact__c.addError('鍚堝悓鏃犳晥锛岃閲嶆柊纭銆�');
+ results.result = 'Fail';
+ results.errorMsg = '鍚堝悓鏃犳晥锛岃閲嶆柊纭銆�';
+ return results;
+ }
+ }
+ Integer FLG = 0;
+ Integer Count = 0;
+ //add by rentx 2020-11-25
+ List<String> tpids = new List<String>();
+ //add by rentx 2020-11-25
+ for (
+ ConsumableorderdetailsInfo CheckCount : consumableorderdetailsRecordsview
+ ) {
+ FLG = FLG + 1;
+ if (CheckCount.check == false) {
+ Count = Count + 1;
+ }
+ if (CheckCount.check == true) {
+ //add by rentx 2020-11-25
+ tpids.add(CheckCount.Prod.Id);
+ //add by rentx 2020-11-25
+ if (
+ CheckCount.esd.Consumable_Count__c == null ||
+ CheckCount.esd.Consumable_Count__c == 0
+ ) {
+ // CheckCount.esd.Consumable_Count__c.addError('璇疯緭鍏ラ噰璐暟閲�');
+ results.result = 'Fail';
+ results.errorMsg = '璇疯緭鍏ラ噰璐暟閲�';
+ return results;
+ }
+ if (
+ CheckCount.orderGoods_Limit > 0 &&
+ math.mod(
+ Integer.valueOf(CheckCount.esd.Consumable_Count__c),
+ Integer.valueOf(CheckCount.orderGoods_Limit)
+ ) > 0
+ ) {
+ // CheckCount.esd.Consumable_Count__c.addError('璇疯緭鍏ヤ績閿�鏁伴噺鐨勫�嶆暟');
+ results.result = 'Fail';
+ results.errorMsg = '璇疯緭鍏ヤ績閿�鏁伴噺鐨勫�嶆暟';
+ return results;
+ }
+ }
+ }
+ if (Count == FLG) {
+ results.result = 'Fail';
+ results.errorMsg = '璇烽�夋嫨鎵�闇�娑堣�楀搧';
+ return results;
+ }
+ //=======================================鍖婚櫌鐗逛环,鏈夐噾棰濈殑璇濆彇閲戦
+ Map<String, Decimal> dealerHospitalmMap = new Map<String, Decimal>();
+ List<hospitalprice__c> hplist = [
+ SELECT Id, hospital__c, mPrice__c, pPrice__c, product__c, account__c
+ FROM hospitalprice__c
+ WHERE
+ product__c IN :tpids
+ AND mPrice__c != NULL
+ AND account__c = :accountid
+ ];
+ for (hospitalprice__c dealerProduct : hplist) {
+ if (dealerProduct.mPrice__c != null) {
+ dealerHospitalmMap.put(
+ '' + dealerProduct.hospital__c + dealerProduct.product__c,
+ dealerProduct.mPrice__c
+ );
+ }
+ }
+ //淇冮攢璁㈣揣 鏍规嵁缁忛攢鍟嗕骇鍝佷腑鐨勬暟鎹绠楅噾棰�
+ //=======================================浜у搧鐗规畩鎶樻墸
+ Map<String, Decimal> dealerPDiscountMap = new Map<String, Decimal>();
+ Map<String, Decimal> dealerMPDiscountMap = new Map<String, Decimal>();
+ //1.鑾峰彇鏈夊紑濮嬬粨鏉熸棩鐨勪骇鍝�
+ Date dateToday = Date.today();
+ List<Dealer_Product__c> haveDateList = [
+ SELECT
+ Id,
+ Name,
+ Dealer_Product2__c,
+ Special_Campaign_Price__c,
+ Campaign_StartDate__c,
+ Campaign_EndDate__c,
+ Dealer_Contact__c,
+ OrderGoods_Limit__c,
+ Special_Discount__c
+ FROM Dealer_Product__c
+ WHERE
+ Dealer_Contact__c IN :contactDealer
+ AND Campaign_StartDate__c <= :dateToday
+ AND Campaign_EndDate__c >= :dateToday
+ AND (Special_Discount__c != NULL
+ OR Special_Campaign_Price__c != NULL)
+ ];
+ //2.鑾峰彇娌℃湁寮�濮嬬粨鏉熸棩鐨勪骇鍝�
+ List<Dealer_Product__c> DealerProductList = [
+ SELECT
+ Id,
+ Name,
+ Dealer_Product2__c,
+ Special_Campaign_Price__c,
+ Campaign_StartDate__c,
+ Campaign_EndDate__c,
+ Dealer_Contact__c,
+ Special_Discount__c,
+ OrderGoods_Limit__c
+ FROM Dealer_Product__c
+ WHERE
+ Dealer_Contact__c IN :contactDealer
+ AND (Special_Discount__c != NULL
+ OR Special_Campaign_Price__c != NULL)
+ ];
+ for (Dealer_Product__c dealerProduct : DealerProductList) {
+ //濡傛灉淇冮攢浠锋牸涓簄ull 鍒欒缃壒娈婃姌鎵�(鐧惧垎姣�)鍒伴泦鍚�
+ if (dealerProduct.Special_Campaign_Price__c == null) {
+ dealerPDiscountMap.put(
+ '' +
+ dealerProduct.Dealer_Contact__c +
+ dealerProduct.Dealer_Product2__c,
+ dealerProduct.Special_Discount__c
+ );
+ } else {
+ dealerMPDiscountMap.put(
+ '' +
+ dealerProduct.Dealer_Contact__c +
+ dealerProduct.Dealer_Product2__c,
+ dealerProduct.Special_Campaign_Price__c
+ );
+ }
+ }
+ //杩欐牱鍋氭槸涓轰簡璁$畻淇冮攢浠锋牸鏃� 浼樺厛璁$畻淇冮攢寮�濮嬬粨鏉熸棩涓嶄负绌虹殑浜у搧
+ //濡傛灉璇ラ泦鍚堟湁鍊� 鍒欒鏄庨渶瑕佹牴鎹綋鍓嶇殑閲戦鎴栬�呮姌鎵f潵璁$畻
+ if (haveDateList != null && haveDateList.size() > 0) {
+ for (Dealer_Product__c dealerProduct : haveDateList) {
+ if (dealerProduct.Special_Campaign_Price__c == null) {
+ dealerPDiscountMap.put(
+ '' +
+ dealerProduct.Dealer_Contact__c +
+ dealerProduct.Dealer_Product2__c,
+ dealerProduct.Special_Discount__c
+ );
+ dealerMPDiscountMap.remove(
+ '' +
+ dealerProduct.Dealer_Contact__c +
+ dealerProduct.Dealer_Product2__c
+ );
+ } else {
+ dealerMPDiscountMap.put(
+ '' +
+ dealerProduct.Dealer_Contact__c +
+ dealerProduct.Dealer_Product2__c,
+ dealerProduct.Special_Campaign_Price__c
+ );
+ dealerPDiscountMap.remove(
+ '' +
+ dealerProduct.Dealer_Contact__c +
+ dealerProduct.Dealer_Product2__c
+ );
+ }
+ }
+ }
+ //=======================================缁忛攢鍟嗗悎鍚屾姌鎵�
+ List<Account> at = [
+ SELECT
+ id,
+ Name,
+ State_Master__c,
+ State_Master__r.Name,
+ Sales_Section__c,
+ Dealer_discount__c
+ FROM Account
+ WHERE
+ Name = :contractName
+ AND Id = :contractId //lt 20230517 瀹夊窘涓ょエ鍒� add
+ AND Contact_Type__c LIKE :agencyProType1 //lt 20230517 瀹夊窘涓ょエ鍒� add 1
+ AND Contact_Type__c LIKE :agencyProType
+ AND Contract_Decide_Start_Date__c <= :Date.Today()
+ AND Contract_Decide_End_Date__c >= :Date.Today()
+ AND Contract_Decide_End_Date__c >= :Date.Today()
+ AND OSH_Dealer__c = :OSHFLG //lt 20230517 瀹夊窘涓ょエ鍒� add
+ ];
+ if (at.size() > 0 && at[0].Dealer_discount__c != null) {
+ disCount = at[0].Dealer_discount__c;
+ } else {
+ disCount = 100;
+ }
+ Consumable_order__c P = new Consumable_order__c();
+ List<Consumable_Orderdetails__c> Ins = new List<Consumable_Orderdetails__c>();
+ //鏂板缓璁㈠崟鏃�
+ if (String.isBlank(ESetId)) {
+ Integer i = 1;
+ Integer Roll = 0;
+ p.Name = '*';
+ p.Order_status__c = '鑽夋涓�';
+ p.Dealer_Info__c = accountid;
+ p.Order_ProType__c = agencyProType;
+ p.Offers_Price__c = coc.Offers_Price__c;
+ p.Order_date__c = coc.Order_date__c;
+ p.Order_effective_contact__c = contract[0].Id;
+ p.Order_Reason__c = coc.Order_Reason__c;
+ p.RecordTypeid = System.Label.RT_ConOrder_Order;
+ p.Overrule_order__c = coc.Id;
+ if (String.isNotBlank(methodType)) {
+ p.orderPattern__c = methodType;
+ }
+ insert p;
+ List<Consumable_order__c> Consumable_order = [
+ SELECT Name, orderPattern__c
+ FROM Consumable_order__c
+ WHERE id = :p.id
+ ];
+ for (
+ ConsumableorderdetailsInfo ass : consumableorderdetailsRecordsview
+ ) {
+ Roll = Roll + 1;
+ if (ass.check == true) {
+ if (
+ ass.esd.Consumable_Count__c == null ||
+ ass.esd.Consumable_Count__c == 0
+ ) {
+ // ass.esd.Consumable_Count__c.addError('璇疯緭鍏ラ噰璐暟閲�');
+ results.result = 'Fail';
+ results.errorMsg = '璇疯緭鍏ラ噰璐暟閲�';
+ return results;
+ } else {
+ Consumable_Orderdetails__c InsAfterDel = new Consumable_Orderdetails__c();
+ String str = string.valueOf(i);
+ if (str.length() == 1) {
+ str = '0' + str;
+ }
+ InsAfterDel.Name = Consumable_order[0].Name + '-' + str;
+ InsAfterDel.Consumable_Count__c = ass.esd.Consumable_Count__c;
+ InsAfterDel.Consumable_order__c = p.id;
+ InsAfterDel.Consumable_Product__c = ass.Prod.id;
+ InsAfterDel.Box_Piece__c = '鐩�';
+ //鍗忚璁㈣揣
+ if (methodType.equals('agreementorder')) {
+ Consumable_order[0].orderPattern__c = 'agreementorder';
+
+ InsAfterDel.Intra_Trade_List_RMB__c =
+ ass.Prod.Intra_Trade_List_RMB__c *
+ disCount /
+ 100;
+ //=====================================================================================update by rentx 2020-11-25
+ } else if (methodType.equals('promotionorder')) {
+ Consumable_order[0].orderPattern__c = 'promotionorder';
+ //淇冮攢璁㈣揣
+ //濡傛灉淇冮攢浠锋牸涓嶄负null 鍒欑洿鎺ヤ娇鐢ㄤ績閿�浠锋牸鏉ヨ绠楅噾棰�
+ if (
+ dealerMPDiscountMap.containsKey(
+ '' + contract[0].Id + ass.Prod.Id
+ )
+ ) {
+ InsAfterDel.Intra_Trade_List_RMB__c = dealerMPDiscountMap.get(
+ '' + contract[0].Id + ass.Prod.Id
+ );
+ system.debug('cai 0' + InsAfterDel.Intra_Trade_List_RMB__c);
+ } else if (
+ dealerPDiscountMap.containsKey(
+ '' + contract[0].Id + ass.Prod.Id
+ )
+ ) {
+ InsAfterDel.Intra_Trade_List_RMB__c =
+ ass.Prod.Intra_Trade_List_RMB__c *
+ dealerPDiscountMap.get('' + contract[0].Id + ass.Prod.Id) /
+ 100;
+ system.debug('cai 00' + InsAfterDel.Intra_Trade_List_RMB__c);
+ }
+ //=====================================================================================update by rentx 2020-11-25
+ } else if (methodType.equals('hospitalorder')) {
+ //鍖婚櫌鐗逛环
+ Consumable_order[0].Order_ForHospital__c = hospitalId;
+ Consumable_order[0].orderPattern__c = 'hospitalorder';
+ if (
+ dealerHospitalmMap.containsKey(hospitalId + ass.Prod.Id) &&
+ dealerHospitalmMap.get(hospitalId + ass.Prod.Id) != null
+ ) {
+ //鐩存帴鏍规嵁淇冮攢閲戦璁$畻
+ InsAfterDel.Intra_Trade_List_RMB__c = dealerHospitalmMap.get(
+ '' + hospitalId + ass.Prod.Id
+ );
+ }
+ } else if (DealerProductMap.containsKey(ass.Prod.Id)) {
+ InsAfterDel.Intra_Trade_List_RMB__c = DealerProductMap.get(
+ ass.Prod.Id
+ )
+ .Special_Campaign_Price__c;
+ system.debug('cai 2' + InsAfterDel.Intra_Trade_List_RMB__c);
+ InsAfterDel.Purchase_Unitprtprice_From__c = '淇冮攢';
+ InsAfterDel.Special_Campaign_Price__c = DealerProductMap.get(
+ ass.Prod.Id
+ )
+ .Special_Campaign_Price__c;
+ }
+ InsAfterDel.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ i++;
+ Ins.add(InsAfterDel);
+ }
+ }
+ }
+ ESetId = p.id;
+ if (Consumable_order.size() > 0) {
+ update Consumable_order;
+ }
+ }
+ //淇敼涔嬪悗 淇濆瓨璁㈠崟
+ if (Ins.size() > 0) {
+ insert Ins;
+ } else {
+ //淇敼,鑾峰彇娑堣�楀搧璁㈠崟
+ List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
+ cocinfo = [
+ SELECT
+ Id,
+ Name,
+ Order_status__c,
+ Dealer_Info__c,
+ Deliver_date__c,
+ Order_Reason__c,
+ Offers_Price__c
+ FROM Consumable_order__c
+ WHERE Id = :ESetId
+ ];
+ if (cocinfo.size() > 0) {
+ p = cocinfo[0];
+ }
+ p.Name = coc.Name;
+ p.Dealer_Info__c = accountid;
+ p.Order_ProType__c = agencyProType;
+ p.Order_date__c = coc.Order_date__c;
+ p.Order_effective_contact__c = contract[0].Id;
+ p.Order_Reason__c = coc.Order_Reason__c;
+ if (bargainPrice != null) {
+ p.Offers_Price__c = bargainPrice;
+ }
+ update p;
+ List<Consumable_order__c> Consumable_order = [
+ SELECT Name, orderPattern__c
+ FROM Consumable_order__c
+ WHERE id = :p.id
+ ];
+ List<Consumable_Orderdetails__c> qs = new List<Consumable_Orderdetails__c>();
+ qs = [
+ SELECT Id
+ FROM Consumable_Orderdetails__c
+ WHERE
+ Consumable_order__c = :ESetId
+ AND Consumable_order__r.Dealer_Info__c = :accountid
+ ];
+ if (qs.size() > 0) {
+ delete qs;
+ }
+ Integer i = 1;
+ for (
+ ConsumableorderdetailsInfo ass : consumableorderdetailsRecordsview
+ ) {
+ if (ass.check == true) {
+ Consumable_Orderdetails__c InsAfterDel = new Consumable_Orderdetails__c();
+ if (
+ ass.esd.Consumable_Count__c == null ||
+ ass.esd.Consumable_Count__c == 0
+ ) {
+ // ass.esd.Consumable_Count__c.addError('璇疯緭鍏ラ噰璐暟閲�');
+ results.result = 'Fail';
+ results.errorMsg = '璇疯緭鍏ラ噰璐暟閲�';
+ return results;
+ } else {
+ String str = string.valueOf(i);
+ if (str.length() == 1) {
+ str = '0' + str;
+ }
+ InsAfterDel.Name = Consumable_order[0].Name + '-' + str;
+ InsAfterDel.Consumable_Count__c = ass.esd.Consumable_Count__c;
+ InsAfterDel.Consumable_order__c = ESetId;
+ InsAfterDel.Consumable_Product__c = ass.Prod.id;
+ InsAfterDel.Box_Piece__c = '鐩�';
+ //鍗忚璁㈣揣
+ if (methodType.equals('agreementorder')) {
+ Consumable_order[0].orderPattern__c = 'agreementorder';
+ InsAfterDel.Intra_Trade_List_RMB__c =
+ ass.Prod.Intra_Trade_List_RMB__c *
+ disCount /
+ 100;
+ } else if (methodType.equals('promotionorder')) {
+ Consumable_order[0].orderPattern__c = 'promotionorder';
+ //淇冮攢璁㈣揣
+ if (
+ dealerMPDiscountMap.containsKey(
+ '' + contract[0].Id + ass.Prod.Id
+ )
+ ) {
+ InsAfterDel.Intra_Trade_List_RMB__c = dealerMPDiscountMap.get(
+ '' + contract[0].Id + ass.Prod.Id
+ );
+ } else if (
+ dealerPDiscountMap.containsKey(
+ '' + contract[0].Id + ass.Prod.Id
+ )
+ ) {
+ InsAfterDel.Intra_Trade_List_RMB__c =
+ ass.Prod.Intra_Trade_List_RMB__c *
+ dealerPDiscountMap.get('' + contract[0].Id + ass.Prod.Id) /
+ 100;
+ }
+ } else if (methodType.equals('hospitalorder')) {
+ Consumable_order[0].orderPattern__c = 'hospitalorder';
+ //鍖婚櫌鐗逛环
+ Consumable_order[0].Order_ForHospital__c = hospitalId;
+ if (
+ dealerHospitalmMap.containsKey(hospitalId + ass.Prod.Id) &&
+ dealerHospitalmMap.get(hospitalId + ass.Prod.Id) != null
+ ) {
+ //鐩存帴鏍规嵁淇冮攢閲戦璁$畻
+ InsAfterDel.Intra_Trade_List_RMB__c = dealerHospitalmMap.get(
+ '' + hospitalId + ass.Prod.Id
+ );
+ }
+ } else if (DealerProductMap.containsKey(ass.Prod.Id)) {
+ InsAfterDel.Intra_Trade_List_RMB__c = DealerProductMap.get(
+ ass.Prod.Id
+ )
+ .Special_Campaign_Price__c;
+ InsAfterDel.Purchase_Unitprtprice_From__c = '淇冮攢';
+ InsAfterDel.Special_Campaign_Price__c = DealerProductMap.get(
+ ass.Prod.Id
+ )
+ .Special_Campaign_Price__c;
+ }
+ // ==================================================涔嬪墠鐨勪績閿�璁㈣揣鐨勯�昏緫
+ InsAfterDel.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ i++;
+ Ins.add(InsAfterDel);
+ }
+ }
+ }
+ if (Ins.size() > 0) {
+ insert Ins;
+ }
+ }
+ results.result = 'Success';
+ results.eSetId = ESetId;
+ } catch (Exception e) {
+ Database.rollback(sp);
+ results.result = 'Fail';
+ results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+ }
+ return results;
+ }
+
+ //鍒犻櫎闄勪欢
+ @AuraEnabled
+ public static Results deleteAtt(String contentVersionId, String cocId) {
+ Results results = new Results();
+ try {
+ List<ContentVersion> cvInfo = [
+ SELECT Id
+ FROM ContentVersion
+ WHERE FirstPublishLocationId = :cocId
+ ];
+ ContentVersion conVersion = [
+ SELECT ContentDocumentId
+ FROM ContentVersion
+ WHERE Id = :contentVersionId
+ ];
+ String contentDocumentId = conVersion.ContentDocumentId;
+ ContentDocument conDocument = [
+ SELECT Id
+ FROM ContentDocument
+ WHERE Id = :contentDocumentId
+ ];
+ delete conDocument;
+ if (cvInfo.size() <= 1) {
+ Consumable_order__c c = [
+ SELECT Id
+ FROM Consumable_order__c
+ WHERE Id = :cocId
+ ];
+ c.Consumable_pdf_insert_day__c = null;
+ update c;
+ }
+ results.result = 'Success';
+ } catch (Exception e) {
+ results.result = 'Fail';
+ results.errorMsg = e.getLineNumber() + '---' + e.getMessage();
+ }
+ return results;
+ }
+
+ public static void getConsumableShowTableFieldValue() {
+ for (ConsumableorderdetailsInfo con : consumableorderdetailsRecordsview) {
+ if (con.Prod != null) {
+ con.recordId = con.Prod.Id;
+ if (!con.oldCheck) {
+ con.prodName = con.Prod.Name__c;
+ // System.debug('ProdName:'+con.Prod.Id+'---'+con.Prod.Name__c);
+ }
+ con.prodSFDAStatus = con.Prod.SFDA_Status__c;
+ con.prodCategory3 = con.Prod.Category3__c;
+ con.prodCategory4 = con.Prod.Category4__c;
+ con.prodCategory5 = con.Prod.Category5__c;
+ con.prodIntraTradeList = con.Prod.Intra_Trade_List_RMB__c;
+ }
+ if (con.esd != null) {
+ // if(con.oldCheck){
+ // con.prodName = con.esd.Consumable_Product__r.Name__c;
+ // }
+ con.consumableCount = con.esd.Consumable_count__c;
+ }
+ }
+ }
+
+ public class ConsumableorderdetailsInfo implements Comparable {
+ @AuraEnabled
+ public Boolean check { get; set; }
+ @AuraEnabled
+ public Boolean oldCheck { get; set; }
+ @AuraEnabled
+ public Consumable_Orderdetails__c esd { get; set; }
+ @AuraEnabled
+ public Product2__c Prod { get; set; }
+ @AuraEnabled
+ public Integer packing_list { get; set; }
+ @AuraEnabled
+ public Date expiration_Date { get; set; }
+ @AuraEnabled
+ public String approbation_No { get; set; }
+ @AuraEnabled
+ public Decimal allnumber { get; set; }
+ @AuraEnabled
+ public Decimal allnumber_piece { get; set; }
+ @AuraEnabled
+ public Decimal oldConsumableCount { get; set; }
+ @AuraEnabled
+ public Boolean canSelect { get; set; }
+ @AuraEnabled
+ public ContentVersion Concc { get; set; }
+ @AuraEnabled
+ public Boolean sortBy { get; set; }
+ @AuraEnabled
+ public Decimal upperlimit { get; set; }
+ @AuraEnabled
+ public Decimal lowerlimit { get; set; }
+ @AuraEnabled
+ public Decimal SpecialCampaignPrice { get; set; }
+ @AuraEnabled
+ public Decimal orderGoods_Limit { get; set; }
+ @AuraEnabled
+ public Date Campaign_EndDate { get; set; }
+ @AuraEnabled
+ public String recordId { get; set; }
+ @AuraEnabled
+ public String prodName { get; set; }
+ @AuraEnabled
+ public String prodSFDAStatus { get; set; }
+ @AuraEnabled
+ public String prodCategory3 { get; set; }
+ @AuraEnabled
+ public String prodCategory4 { get; set; }
+ @AuraEnabled
+ public String prodCategory5 { get; set; }
+ @AuraEnabled
+ public Decimal prodIntraTradeList { get; set; }
+ @AuraEnabled
+ public Decimal consumableCount { get; set; }
+
+ // 宸插瓨浜у搧鏄庣粏
+ public ConsumableorderdetailsInfo(Consumable_Orderdetails__c e) {
+ check = true;
+ oldCheck = true;
+ esd = e;
+ Prod = e.Consumable_Product__r;
+ oldConsumableCount = e.Consumable_Count__c;
+ canSelect = true;
+ allnumber = 0;
+ allnumber_piece = 0;
+ }
+
+ public ConsumableorderdetailsInfo(Product2__c e) {
+ check = false;
+ oldCheck = false;
+ esd = new Consumable_Orderdetails__c();
+ Prod = e;
+ oldConsumableCount = null;
+ canSelect = true;
+ allnumber = 0;
+ allnumber_piece = 0;
+ }
+ //闄勪欢
+ public ConsumableorderdetailsInfo(ContentVersion e) {
+ Concc = e;
+ }
+ // 鎺掑簭Consumable_order__c
+ public Integer compareTo(Object compareTo) {
+ ConsumableorderdetailsInfo compareToesd = (ConsumableorderdetailsInfo) compareTo;
+ Integer returnValue = 0;
+ if (check == true) {
+ if (sortBy == false) {
+ if (allnumber > compareToesd.allnumber) {
+ returnValue = -1;
+ } else if (allnumber < compareToesd.allnumber) {
+ returnValue = 1;
+ }
+ return returnValue;
+ } else {
+ if (allnumber > compareToesd.allnumber) {
+ returnValue = 1;
+ } else if (allnumber < compareToesd.allnumber) {
+ returnValue = -1;
+ }
+ return returnValue;
+ }
+ } else {
+ if (sortBy == false) {
+ if (allnumber > compareToesd.allnumber) {
+ returnValue = -1;
+ } else if (allnumber < compareToesd.allnumber) {
+ returnValue = 1;
+ }
+ return returnValue;
+ } else {
+ if (allnumber > compareToesd.allnumber) {
+ returnValue = 1;
+ } else if (allnumber < compareToesd.allnumber) {
+ returnValue = -1;
+ }
+ return returnValue;
+ }
+ }
+ }
+ }
+
+ public class Results {
+ @AuraEnabled
+ public String result;
+ @AuraEnabled
+ public String errorMsg;
+ @AuraEnabled
+ public String eSetId;
+ @AuraEnabled
+ public String agencyProType;
+ @AuraEnabled
+ public String userWorkLocation;
+ @AuraEnabled
+ public String accountName;
+ @AuraEnabled
+ public String accountid;
+ @AuraEnabled
+ public String hospitalId;
+ @AuraEnabled
+ public String contractId;
+ @AuraEnabled
+ public String category_Goods;
+ @AuraEnabled
+ public Consumable_order__c coc;
+ @AuraEnabled
+ public Boolean edoffersPrice;
+ @AuraEnabled
+ public Boolean editDelCommitBtnDisabled;
+ @AuraEnabled
+ public Boolean editAble;
+ @AuraEnabled
+ public String hospitalName;
+ @AuraEnabled
+ public String contractName;
+ @AuraEnabled
+ public List<CusOption> category3Option;
+ @AuraEnabled
+ public List<CusOption> category4Option;
+ @AuraEnabled
+ public List<CusOption> category5Option;
+ @AuraEnabled
+ public List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsview;
+ @AuraEnabled
+ public List<ConsumableorderdetailsInfo> attachmentRecoeds;
+ @AuraEnabled
+ public Boolean cansee;
+ @AuraEnabled
+ public List<String> errorMsgList;
+ @AuraEnabled
+ public List<String> warningMsgList;
+ @AuraEnabled
+ public Boolean hasWarning;
+ @AuraEnabled
+ public Boolean hasError;
+ @AuraEnabled
+ public Boolean specialCampaign;
+ @AuraEnabled
+ public List<String> dealerProductId;
+ @AuraEnabled
+ public List<String> contactDealer;
+ @AuraEnabled
+ public String url;
+ @AuraEnabled
+ public String methodType;
+ @AuraEnabled
+ public List<String> proLimitAndDate;
+ @AuraEnabled
+ public Boolean isNoteStay;
+ @AuraEnabled
+ public Boolean OSHFLG;
+ @AuraEnabled
+ public String agencyProType1;
+ }
+
+ public class CusOption {
+ CusOption(String label, String value) {
+ this.label = label;
+ this.value = value;
+ }
+
+ @AuraEnabled
+ public String label;
+ @AuraEnabled
+ public String value;
+ }
+}
diff --git a/force-app/main/default/classes/LexConsumableControllerTest.cls b/force-app/main/default/classes/LexConsumableControllerTest.cls
new file mode 100644
index 0000000..62c307b
--- /dev/null
+++ b/force-app/main/default/classes/LexConsumableControllerTest.cls
@@ -0,0 +1,1377 @@
+@istest
+public class LexConsumableControllerTest {
+ @IsTest
+ static void ConsumableOrdertest1() {
+ user MyUser_Test;
+ Account myAccount1;
+ Account contract;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ List<RecordType> rectCo1 = [
+ SELECT Id
+ FROM RecordType
+ WHERE
+ IsActive = TRUE
+ AND SobjectType = 'Account'
+ AND DeveloperName = 'AgencyContract'
+ ];
+
+ if (rectCo.size() == 0) {
+ return;
+ }
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '8888888',
+ Product_Limit_Date__c = 'Test07|3|100,Test08|10|50'
+ );
+ insert myAccount1;
+ contract = new Account(
+ RecordTypeId = rectCo1[0].Id,
+ Name = 'contractName',
+ ParentId = myAccount1.id,
+ Agent_Ref__c = myAccount1.id,
+ Contract_Department_Class__c = 'ET',
+ Contract_Decide_Start_Date__c = Date.today().addDays(-2),
+ Contract_Decide_End_Date__c = Date.today().addDays(2),
+ Dealer_discount__c = 0.8
+ );
+ insert contract;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+
+ System.runAs(MyUser_Test) {
+ //浜у搧鏁版嵁
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'CDS',
+ Category4__c = 'OER',
+ Category5__c = '鍏跺畠',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test001',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'ENT',
+ Category4__c = 'Celon',
+ Category5__c = 'Celon',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test002',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'US',
+ Category4__c = 'ALOKA',
+ Category5__c = '浣撳瓒呭0',
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02, prod03 };
+
+ //鍒朵綔浜у搧
+ Product2__c proG = new Product2__c(
+ Name = 'MH-155:鐧藉钩琛″附',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod01.Id
+ );
+ insert proG;
+ System.debug('proG:' + proG);
+ System.debug('proG1:' + proG.Estimation_Entry_Possibility__c);
+ System.debug('prod07:' + prod01);
+ System.debug('prod071:' + prod01.Estimation_Entry_Possibility__c);
+ Product2__c proH = new Product2__c(
+ Name = 'MB-677:BNC鐢电紗',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod02.Id
+ );
+ insert proH;
+ Product2__c proF = new Product2__c(
+ Name = 'TooMAJ-643R:姘村泭闉樼003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod03.Id
+ );
+ insert proF;
+
+ //璁㈠崟
+ Consumable_order__c order = new Consumable_order__c();
+ order.Name = 'testMing';
+ order.Order_status__c = '鎵瑰噯';
+ order.RecordTypeid = System.Label.RT_ConOrder_Order;
+ order.Dealer_Info__c = myAccount1.id;
+ order.Inventory_date__c = Date.today();
+ order.Order_type__c = '璁㈠崟';
+ order.Order_ProType__c = 'ET';
+ order.orderPattern__c = 'agreementorder';
+ insert order;
+ Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+ Orderdet.Name = 'OCM_01_00101';
+ Orderdet.Consumable_order__c = order.Id;
+ Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ Orderdet.Consumable_Product__c = proG.Id;
+ Orderdet.Consumable_count__c = 4;
+ insert Orderdet;
+
+ Consumable_order_details2__c createDetail2 = new Consumable_order_details2__c();
+ createDetail2 = new Consumable_order_details2__c();
+ createDetail2.Consumable_Product__c = proG.id;
+ createDetail2.Asset_Model_No__c = 'Test01';
+ createDetail2.Consumable_order_minor__c = order.id;
+ createDetail2.Consumable_Arrived_order__c = order.id;
+ createDetail2.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ createDetail2.Asset_Model_No__c = proG.Asset_Model_No__c;
+ createDetail2.Bar_Code__c = '123';
+ createDetail2.Box_Piece__c = '鐩�';
+ createDetail2.Arrive_date__c = Date.today();
+
+ Oly_TriggerHandler.bypass('ConsumableAssetHander');
+ insert createDetail2;
+
+ Test.startTest();
+ LexConsumableController.ConsumableorderdetailsInfo c1 = new LexConsumableController.ConsumableorderdetailsInfo(
+ Orderdet
+ );
+ ContentVersion v = new ContentVersion();
+ LexConsumableController.ConsumableorderdetailsInfo c2 = new LexConsumableController.ConsumableorderdetailsInfo(
+ v
+ );
+ LexConsumableController l = new LexConsumableController();
+ LexConsumableController.Results re = LexConsumableController.init(
+ '',
+ order.Id,
+ ''
+ );
+ LexConsumableController.searchConsumableorderdetails(
+ re.userWorkLocation,
+ re.agencyProType,
+ re.accountName,
+ re.accountid,
+ re.hospitalId,
+ re.contractId,
+ 'testMing',
+ '',
+ '',
+ '',
+ re.category_Goods,
+ re.specialCampaign,
+ JSON.serialize(re.dealerProductId),
+ re.methodType,
+ JSON.serialize(re.consumableorderdetailsRecordsview),
+ re.editAble,
+ re.proLimitAndDate
+ );
+ LexConsumableController.searchorderdetails(
+ re.methodType,
+ re.accountid,
+ re.hospitalId,
+ re.contractId,
+ re.userWorkLocation,
+ re.accountName,
+ re.proLimitAndDate,
+ re.editAble
+ );
+ LexConsumableController.sorder(order.Id, myAccount1.Id);
+ Test.stopTest();
+ }
+ }
+
+ @IsTest
+ static void ConsumableOrdertest2() {
+ user MyUser_Test;
+ Account myAccount1;
+ Account contract;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ List<RecordType> rectCo1 = [
+ SELECT Id
+ FROM RecordType
+ WHERE
+ IsActive = TRUE
+ AND SobjectType = 'Account'
+ AND DeveloperName = 'AgencyContract'
+ ];
+
+ if (rectCo.size() == 0) {
+ return;
+ }
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '8888888',
+ Product_Limit_Date__c = 'Test07|3|100,Test08|10|50'
+ );
+ insert myAccount1;
+ contract = new Account(
+ RecordTypeId = rectCo1[0].Id,
+ Name = 'contractName',
+ ParentId = myAccount1.id,
+ Agent_Ref__c = myAccount1.id,
+ Contract_Department_Class__c = 'ET',
+ Contract_Decide_Start_Date__c = Date.today().addDays(-2),
+ Contract_Decide_End_Date__c = Date.today().addDays(2),
+ Dealer_discount__c = 0.8
+ );
+ insert contract;
+
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+
+ System.runAs(MyUser_Test) {
+ //浜у搧鏁版嵁
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'CDS',
+ Category4__c = 'OER',
+ Category5__c = '鍏跺畠',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test001',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'ENT',
+ Category4__c = 'Celon',
+ Category5__c = 'Celon',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test002',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'US',
+ Category4__c = 'ALOKA',
+ Category5__c = '浣撳瓒呭0',
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02, prod03 };
+
+ //鍒朵綔浜у搧
+ Product2__c proG = new Product2__c(
+ Name = 'MH-155:鐧藉钩琛″附',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod01.Id
+ );
+ insert proG;
+ System.debug('proG:' + proG);
+ System.debug('proG1:' + proG.Estimation_Entry_Possibility__c);
+ System.debug('prod07:' + prod01);
+ System.debug('prod071:' + prod01.Estimation_Entry_Possibility__c);
+ Product2__c proH = new Product2__c(
+ Name = 'MB-677:BNC鐢电紗',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod02.Id
+ );
+ insert proH;
+ Product2__c proF = new Product2__c(
+ Name = 'TooMAJ-643R:姘村泭闉樼003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod03.Id
+ );
+ insert proF;
+
+ //鍒涘缓鍖婚櫌
+ Account hospital = new Account();
+ hospital.recordtypeId = [
+ SELECT Id
+ FROM RecordType
+ WHERE
+ IsActive = TRUE
+ AND SobjectType = 'Account'
+ AND DeveloperName = 'HP'
+ ]
+ .id;
+ hospital.Name = 'test hospital';
+ hospital.Is_Active__c = '鏈夊姽';
+ hospital.Attribute_Type__c = '鍗敓閮�';
+ hospital.Speciality_Type__c = '缁煎悎鍖婚櫌';
+ hospital.Grade__c = '涓�绾�';
+ hospital.OCM_Category__c = 'SLTV';
+ hospital.Is_Medical__c = '鍖荤枟鏈烘瀯';
+ hospital.Town__c = '涓滀含';
+ insert hospital;
+
+ //寤轰竴鏉″尰闄㈢壒浠蜂骇鍝�
+ hospitalprice__c hc = new hospitalprice__c();
+ hc.hospital__c = hospital.Id;
+ hc.product__c = proG.Id;
+ hc.aph__c = '12332';
+ hc.account__c = myAccount1.Id;
+ insert hc;
+
+ //鍖婚櫌
+ Consumable_order__c order1 = new Consumable_order__c();
+ order1.Name = 'testMing1';
+ order1.Order_status__c = '鎵瑰噯';
+ order1.RecordTypeid = System.Label.RT_ConOrder_Order;
+ order1.Dealer_Info__c = myAccount1.id;
+ order1.Inventory_date__c = Date.today();
+ order1.Order_type__c = '璁㈠崟';
+ order1.Order_ProType__c = 'ET';
+ order1.orderPattern__c = 'hospitalorder';
+ insert order1;
+ Consumable_orderdetails__c Orderdet1 = new Consumable_orderdetails__c();
+ Orderdet1.Name = 'OCM_01_00102';
+ Orderdet1.Consumable_order__c = order1.Id;
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ Orderdet1.Consumable_Product__c = proG.Id;
+ Orderdet1.Consumable_count__c = 4;
+ insert Orderdet1;
+
+ Consumable_order_details2__c createDetail3 = new Consumable_order_details2__c();
+ createDetail3 = new Consumable_order_details2__c();
+ createDetail3.Consumable_Product__c = proG.id;
+ createDetail3.Asset_Model_No__c = 'Test02';
+ createDetail3.Consumable_order_minor__c = order1.id;
+ createDetail3.Consumable_Arrived_order__c = order1.id;
+ createDetail3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ createDetail3.Asset_Model_No__c = proG.Asset_Model_No__c;
+ createDetail3.Bar_Code__c = '123';
+ createDetail3.Box_Piece__c = '鐩�';
+ createDetail3.Arrive_date__c = Date.today();
+
+ Oly_TriggerHandler.bypass('ConsumableAssetHander');
+ insert createDetail3;
+
+ Test.startTest();
+ LexConsumableController.Results re = LexConsumableController.init(
+ '',
+ order1.Id,
+ ''
+ );
+ LexConsumableController.searchConsumableorderdetails(
+ re.userWorkLocation,
+ re.agencyProType,
+ re.accountName,
+ re.accountid,
+ re.hospitalId,
+ re.contractId,
+ 'testMing',
+ '',
+ '',
+ '',
+ re.category_Goods,
+ re.specialCampaign,
+ JSON.serialize(re.dealerProductId),
+ re.methodType,
+ JSON.serialize(re.consumableorderdetailsRecordsview),
+ re.editAble,
+ re.proLimitAndDate
+ );
+ LexConsumableController.searchorderdetails(
+ re.methodType,
+ re.accountid,
+ re.hospitalId,
+ re.contractId,
+ re.userWorkLocation,
+ re.accountName,
+ re.proLimitAndDate,
+ re.editAble
+ );
+ LexConsumableController.searchConsumableorderdetails(
+ re.userWorkLocation,
+ re.agencyProType,
+ re.accountName,
+ re.accountid,
+ hospital.Id,
+ contract.Id,
+ 'testMing',
+ '',
+ '',
+ '',
+ re.category_Goods,
+ re.specialCampaign,
+ JSON.serialize(re.dealerProductId),
+ re.methodType,
+ JSON.serialize(re.consumableorderdetailsRecordsview),
+ re.editAble,
+ re.proLimitAndDate
+ );
+ LexConsumableController.searchorderdetails(
+ re.methodType,
+ re.accountid,
+ hospital.Id,
+ contract.Id,
+ re.userWorkLocation,
+ re.accountName,
+ re.proLimitAndDate,
+ re.editAble
+ );
+ Test.stopTest();
+ }
+ }
+
+ @IsTest
+ static void ConsumableOrdertest3() {
+ user MyUser_Test;
+ Account myAccount1;
+ Account contract;
+ Consumable_order__c order2;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ List<RecordType> rectCo1 = [
+ SELECT Id
+ FROM RecordType
+ WHERE
+ IsActive = TRUE
+ AND SobjectType = 'Account'
+ AND DeveloperName = 'AgencyContract'
+ ];
+
+ if (rectCo.size() == 0) {
+ return;
+ }
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '8888888',
+ Product_Limit_Date__c = 'Test07|3|100,Test08|10|50'
+ );
+ insert myAccount1;
+ contract = new Account(
+ RecordTypeId = rectCo1[0].Id,
+ Name = 'contractName',
+ ParentId = myAccount1.id,
+ Agent_Ref__c = myAccount1.id,
+ Contract_Department_Class__c = 'ET',
+ Contract_Decide_Start_Date__c = Date.today().addDays(-2),
+ Contract_Decide_End_Date__c = Date.today().addDays(2),
+ Dealer_discount__c = 0.8
+ );
+ insert contract;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+
+ //浜у搧鏁版嵁
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'CDS',
+ Category4__c = 'OER',
+ Category5__c = '鍏跺畠',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test001',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'ENT',
+ Category4__c = 'Celon',
+ Category5__c = 'Celon',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test002',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'US',
+ Category4__c = 'ALOKA',
+ Category5__c = '浣撳瓒呭0',
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02, prod03 };
+
+ //鍒朵綔浜у搧
+ Product2__c proG = new Product2__c(
+ Name = 'MH-155:鐧藉钩琛″附',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod01.Id
+ );
+ insert proG;
+ System.debug('proG:' + proG);
+ System.debug('proG1:' + proG.Estimation_Entry_Possibility__c);
+ System.debug('prod07:' + prod01);
+ System.debug('prod071:' + prod01.Estimation_Entry_Possibility__c);
+ Product2__c proH = new Product2__c(
+ Name = 'MB-677:BNC鐢电紗',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod02.Id
+ );
+ insert proH;
+ Product2__c proF = new Product2__c(
+ Name = 'TooMAJ-643R:姘村泭闉樼003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod03.Id
+ );
+ insert proF;
+
+ Dealer_Product__c dpc = new Dealer_Product__c();
+ dpc.Dealer_Contact__c = contract.id;
+ dpc.Dealer_Product2__c = proG.id;
+ dpc.Special_Discount__c = 45;
+ dpc.Campaign_StartDate__c = Date.today().addDays(-1);
+ dpc.Campaign_EndDate__c = Date.today().addDays(1);
+ insert dpc;
+
+ Dealer_Product__c dpc2 = new Dealer_Product__c();
+ dpc2.Dealer_Contact__c = contract.id;
+ dpc2.Dealer_Product2__c = proG.id;
+ dpc2.Special_Campaign_Price__c = 4500;
+ insert dpc2;
+
+ Dealer_Product__c dpc1 = new Dealer_Product__c();
+ dpc1.Dealer_Contact__c = contract.id;
+ dpc1.Dealer_Product2__c = proH.id;
+ dpc1.Special_Campaign_Price__c = 23456;
+ insert dpc1;
+ //淇冮攢
+ order2 = new Consumable_order__c();
+ order2.Name = 'testMing2';
+ order2.Order_status__c = '鎵瑰噯';
+ order2.RecordTypeid = System.Label.RT_ConOrder_Order;
+ order2.Dealer_Info__c = myAccount1.id;
+ order2.Inventory_date__c = Date.today();
+ order2.Order_type__c = '璁㈠崟';
+ order2.Order_ProType__c = 'ET';
+ order2.orderPattern__c = 'promotionorder';
+ insert order2;
+ Consumable_orderdetails__c Orderdet2 = new Consumable_orderdetails__c();
+ Orderdet2.Name = 'OCM_01_00103';
+ Orderdet2.Consumable_order__c = order2.Id;
+ Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ Orderdet2.Consumable_Product__c = proG.Id;
+ Orderdet2.Consumable_count__c = 4;
+ insert Orderdet2;
+
+ Consumable_order_details2__c createDetail4 = new Consumable_order_details2__c();
+ createDetail4 = new Consumable_order_details2__c();
+ createDetail4.Consumable_Product__c = proG.id;
+ createDetail4.Asset_Model_No__c = 'Test03';
+ createDetail4.Consumable_order_minor__c = order2.id;
+ createDetail4.Consumable_Arrived_order__c = order2.id;
+ createDetail4.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ createDetail4.Asset_Model_No__c = proG.Asset_Model_No__c;
+ createDetail4.Bar_Code__c = '123';
+ createDetail4.Box_Piece__c = '鐩�';
+ createDetail4.Arrive_date__c = Date.today();
+ Oly_TriggerHandler.bypass('ConsumableAssetHander');
+ insert createDetail4;
+ }
+
+ System.runAs(MyUser_Test) {
+ Test.startTest();
+ LexConsumableController.Results re = LexConsumableController.init(
+ '',
+ order2.Id,
+ ''
+ );
+ LexConsumableController.searchConsumableorderdetails(
+ re.userWorkLocation,
+ re.agencyProType,
+ re.accountName,
+ re.accountid,
+ re.hospitalId,
+ re.contractId,
+ 'testMing',
+ '',
+ '',
+ '',
+ re.category_Goods,
+ re.specialCampaign,
+ JSON.serialize(re.dealerProductId),
+ re.methodType,
+ JSON.serialize(re.consumableorderdetailsRecordsview),
+ re.editAble,
+ re.proLimitAndDate
+ );
+ LexConsumableController.searchorderdetails(
+ re.methodType,
+ re.accountid,
+ re.hospitalId,
+ re.contractId,
+ re.userWorkLocation,
+ re.accountName,
+ re.proLimitAndDate,
+ re.editAble
+ );
+ LexConsumableController.searchConsumableorderdetails(
+ re.userWorkLocation,
+ re.agencyProType,
+ re.accountName,
+ re.accountid,
+ re.hospitalId,
+ contract.Id,
+ 'testMing',
+ '',
+ '',
+ '',
+ re.category_Goods,
+ re.specialCampaign,
+ JSON.serialize(re.dealerProductId),
+ re.methodType,
+ JSON.serialize(re.consumableorderdetailsRecordsview),
+ re.editAble,
+ re.proLimitAndDate
+ );
+ LexConsumableController.searchorderdetails(
+ re.methodType,
+ re.accountid,
+ re.hospitalId,
+ contract.Id,
+ re.userWorkLocation,
+ re.accountName,
+ re.proLimitAndDate,
+ re.editAble
+ );
+ Test.stopTest();
+ }
+ }
+
+ @IsTest
+ static void ConsumableOrdertest4() {
+ user MyUser_Test;
+ Account myAccount1;
+ Account contract;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ List<RecordType> rectCo1 = [
+ SELECT Id
+ FROM RecordType
+ WHERE
+ IsActive = TRUE
+ AND SobjectType = 'Account'
+ AND DeveloperName = 'AgencyContract'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+
+ RecordType rectCoO = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ Account olympus = new Account(
+ RecordTypeId = rectCoO.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '8888888',
+ Product_Limit_Date__c = 'Test07|3|100,Test08|10|50'
+ );
+ insert myAccount1;
+ System.debug('account111:' + myAccount1);
+ contract = new Account(
+ RecordTypeId = rectCo1[0].Id,
+ Name = 'contractName',
+ ParentId = myAccount1.id,
+ Agent_Ref__c = myAccount1.id,
+ Contract_Department_Class__c = 'ET',
+ Contract_Decide_Start_Date__c = Date.today().addDays(-2),
+ Contract_Decide_End_Date__c = Date.today().addDays(2),
+ ET_SP_Dealer__c = true
+ );
+ insert contract;
+ System.debug('account111:' + contract);
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+
+ System.runAs(MyUser_Test) {
+ //浜у搧鏁版嵁
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'CDS',
+ Category4__c = 'OER',
+ Category5__c = '鍏跺畠',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test001',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'ENT',
+ Category4__c = 'Celon',
+ Category5__c = 'Celon',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test002',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'US',
+ Category4__c = 'ALOKA',
+ Category5__c = '浣撳瓒呭0',
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02, prod03 };
+
+ //鍒朵綔浜у搧
+ Product2__c proG = new Product2__c(
+ Name = 'MH-155:鐧藉钩琛″附',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod01.Id
+ );
+ insert proG;
+ System.debug('proG:' + proG);
+ System.debug('proG1:' + proG.Estimation_Entry_Possibility__c);
+ System.debug('prod07:' + prod01);
+ System.debug('prod071:' + prod01.Estimation_Entry_Possibility__c);
+ Product2__c proH = new Product2__c(
+ Name = 'MB-677:BNC鐢电紗',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod02.Id
+ );
+ insert proH;
+ Product2__c proF = new Product2__c(
+ Name = 'TooMAJ-643R:姘村泭闉樼003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod03.Id
+ );
+ insert proF;
+
+ //璁㈠崟
+ Consumable_order__c order = new Consumable_order__c();
+ order.Name = 'testMing';
+ order.Order_status__c = '鎵瑰噯';
+ order.RecordTypeid = System.Label.RT_ConOrder_Order;
+ order.Dealer_Info__c = myAccount1.id;
+ order.Inventory_date__c = Date.today();
+ order.Order_type__c = '璁㈠崟';
+ order.Order_ProType__c = 'ET';
+ order.orderPattern__c = 'agreementorder';
+ insert order;
+ Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
+ Orderdet.Name = 'OCM_01_00101';
+ Orderdet.Consumable_order__c = order.Id;
+ Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ Orderdet.Consumable_Product__c = proG.Id;
+ Orderdet.Consumable_count__c = 4;
+ insert Orderdet;
+
+ Consumable_order_details2__c createDetail2 = new Consumable_order_details2__c();
+ createDetail2 = new Consumable_order_details2__c();
+ createDetail2.Consumable_Product__c = proG.id;
+ createDetail2.Asset_Model_No__c = 'Test01';
+ createDetail2.Consumable_order_minor__c = order.id;
+ createDetail2.Consumable_Arrived_order__c = order.id;
+ createDetail2.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ createDetail2.Asset_Model_No__c = proG.Asset_Model_No__c;
+ createDetail2.Bar_Code__c = '123';
+ createDetail2.Box_Piece__c = '鐩�';
+ createDetail2.Arrive_date__c = Date.today();
+
+ Oly_TriggerHandler.bypass('ConsumableAssetHander');
+ insert createDetail2;
+
+ Test.startTest();
+ LexConsumableController.Results re = LexConsumableController.init(
+ 'agreementorder',
+ '',
+ ''
+ );
+ re.consumableorderdetailsRecordsview[0].check = true;
+ re.consumableorderdetailsRecordsview[0].esd.Consumable_count__c = 1;
+ String conId = contract.Id;
+ LexConsumableController.ordrCopy(
+ contract.Name,
+ JSON.serialize(re.coc),
+ re.agencyProType,
+ re.accountid,
+ JSON.serialize(re.consumableorderdetailsRecordsview),
+ JSON.serialize(re.contactDealer),
+ re.methodType,
+ '',
+ conId,
+ re.agencyProType1,
+ false
+ );
+ LexConsumableController.save(
+ '',
+ JSON.serialize(re.coc),
+ re.agencyProType,
+ re.accountid,
+ JSON.serialize(re.consumableorderdetailsRecordsview),
+ JSON.serialize(re.contactDealer),
+ re.methodType,
+ re.ESetId,
+ '',
+ conId,
+ re.agencyProType1,
+ false
+ );
+ LexConsumableController.save(
+ contract.Name,
+ JSON.serialize(re.coc),
+ re.agencyProType,
+ re.accountid,
+ JSON.serialize(re.consumableorderdetailsRecordsview),
+ JSON.serialize(re.contactDealer),
+ re.methodType,
+ re.ESetId,
+ '',
+ '',
+ re.agencyProType1,
+ false
+ );
+ LexConsumableController.save(
+ ':Testaccount001',
+ JSON.serialize(re.coc),
+ 'ET',
+ re.accountid,
+ JSON.serialize(re.consumableorderdetailsRecordsview),
+ JSON.serialize(re.contactDealer),
+ re.methodType,
+ re.ESetId,
+ '',
+ re.contractId,
+ 'ET',
+ false
+ );
+ LexConsumableController.save(
+ ':Testaccount001',
+ JSON.serialize(re.coc),
+ 'ET',
+ re.accountid,
+ JSON.serialize(re.consumableorderdetailsRecordsview),
+ JSON.serialize(re.contactDealer),
+ 'agreementorder',
+ re.ESetId,
+ '',
+ re.contractId,
+ 'ET',
+ false
+ );
+ LexConsumableController.save(
+ ':Testaccount001',
+ JSON.serialize(re.coc),
+ 'ET',
+ re.accountid,
+ JSON.serialize(re.consumableorderdetailsRecordsview),
+ JSON.serialize(re.contactDealer),
+ 'promotionorder',
+ re.ESetId,
+ '',
+ re.contractId,
+ 'ET',
+ false
+ );
+ LexConsumableController.save(
+ ':Testaccount001',
+ JSON.serialize(re.coc),
+ 'ET',
+ re.accountid,
+ JSON.serialize(re.consumableorderdetailsRecordsview),
+ JSON.serialize(re.contactDealer),
+ 'hospitalorder',
+ re.ESetId,
+ '',
+ re.contractId,
+ 'ET',
+ false
+ );
+ Test.stopTest();
+ }
+ }
+
+ @IsTest
+ static void ConsumableOrdertest5() {
+ user MyUser_Test;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ ContentVersion cv;
+ Consumable_order__c order;
+ insert n;
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ RecordType rectCoO = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ Account olympus = new Account(
+ RecordTypeId = rectCoO.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '8888888',
+ Product_Limit_Date__c = 'Test07|3|100,Test08|10|50'
+ );
+ insert myAccount1;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+
+ order = new Consumable_order__c();
+ order.Name = 'testMing';
+ order.Order_status__c = '鎵瑰噯';
+ order.RecordTypeid = System.Label.RT_ConOrder_Order;
+ order.Dealer_Info__c = myAccount1.id;
+ order.Inventory_date__c = Date.today();
+ order.Order_type__c = '璁㈠崟';
+ order.Order_ProType__c = 'ET';
+ order.orderPattern__c = 'agreementorder';
+ insert order;
+
+ cv = new ContentVersion();
+ cv.Title = 'test.txt';
+ cv.PathOnClient = '/' + 'test.txt';
+ cv.FirstPublishLocationId = order.Id;
+ cv.VersionData = EncodingUtil.base64Decode('VGVzdA==');
+ cv.IsMajorVersion = true;
+ insert cv;
+ }
+ System.runAs(MyUser_Test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'CDS',
+ Category4__c = 'OER',
+ Category5__c = '鍏跺畠',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test001',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'CDS',
+ Category4__c = 'OER',
+ Category5__c = 'Celon',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test002',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_Date2__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'US',
+ Category4__c = 'ALOKA',
+ Category5__c = '浣撳瓒呭0',
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+
+ Product2 prod04 = new Product2(
+ Name = 'Test04',
+ ProductCode = 'Test04',
+ Asset_Model_No__c = 'Test04',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = 'OCS',
+ Category4__c = '闄勫睘鍝�',
+ Category5__c = 'OCS',
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+ Product2 prod05 = new Product2(
+ Name = 'Test05',
+ ProductCode = 'Test05',
+ Asset_Model_No__c = 'Test05',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Product_Status__c = '姝e父閿�鍞�',
+ SFDA_Approbated_Status__c = '鏈夋晥',
+ Category3__c = '鍏夋簮',
+ Category4__c = 'CLV',
+ Category5__c = 'S45',
+ Intra_Trade_List_RMB_1__c = 1000,
+ Intra_Trade_List_RMB_Date1__c = Date.today().addDays(-1),
+ Intra_Trade_List_RMB_End_Date1__c = Date.today().addDays(1),
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02, prod03, prod04, prod05 };
+ 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
+ );
+ Product2__c pro3 = new Product2__c(
+ Name = 'Pro003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod03.Id
+ );
+ Product2__c pro4 = new Product2__c(
+ Name = 'Pro004',
+ OT_CODE_Text__c = 'Test004',
+ Product2__c = prod04.Id
+ );
+ Product2__c pro5 = new Product2__c(
+ Name = 'Pro005',
+ OT_CODE_Text__c = 'Test005',
+ Product2__c = prod05.Id
+ );
+ insert new List<Product2__c>{ pro1, pro2, pro3, pro4, pro5 };
+
+ Test.startTest();
+ LexConsumableController.Results re1 = LexConsumableController.categoryAllload(
+ 'ET',
+ 'CDS'
+ );
+ LexConsumableController.Results re2 = LexConsumableController.categoryAllload(
+ 'ENG',
+ 'CDS'
+ );
+ LexConsumableController.Results re3 = LexConsumableController.categoryAllload(
+ '',
+ 'CDS'
+ );
+ LexConsumableController.Results re4 = LexConsumableController.categoryload(
+ 'ET',
+ 'CDS',
+ 'OER'
+ );
+ LexConsumableController.Results re5 = LexConsumableController.categoryload(
+ 'ENG',
+ 'CDS',
+ 'OER'
+ );
+ LexConsumableController.Results re6 = LexConsumableController.categoryload(
+ '',
+ 'CDS',
+ 'OER'
+ );
+ String pid = order.Id;
+ LexConsumableController.filesUpload(pid, 'tset.txt', 'VGVzdA==');
+ LexConsumableController.deleteAtt(cv.Id, pid);
+ LexConsumableController.backOrder(pid);
+ LexConsumableController.setEditAble(pid);
+ LexConsumableController.delConsumable(pid);
+ LexConsumableController.OffersPrice();
+ Test.stopTest();
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexConsumableControllerTest.cls-meta.xml b/force-app/main/default/classes/LexConsumableControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexConsumableControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexConsumableGoodsInfoTest.cls b/force-app/main/default/classes/LexConsumableGoodsInfoTest.cls
new file mode 100644
index 0000000..fb566bb
--- /dev/null
+++ b/force-app/main/default/classes/LexConsumableGoodsInfoTest.cls
@@ -0,0 +1,1113 @@
+@istest
+public class LexConsumableGoodsInfoTest {
+ @IsTest
+ static void lexConsumableGoodsInfoTest1() {
+ user MyUser_Test;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+
+ RecordType rectCoO = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ Account olympus = new Account(
+ RecordTypeId = rectCoO.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '8888888',
+ Product_Limit_Date__c = 'Test07|3|100,Test08|10|50'
+ );
+ insert myAccount1;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+
+ System.runAs(MyUser_Test) {
+ //浜у搧鏁版嵁
+ Product2 prod07 = new Product2(
+ Name = 'Test07',
+ ProductCode = 'Test07',
+ Asset_Model_No__c = 'Test07',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod08 = new Product2(
+ Name = 'Test08',
+ ProductCode = 'Test08',
+ Asset_Model_No__c = 'Test08',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod09 = new Product2(
+ Name = 'Test09',
+ ProductCode = 'Test09',
+ Asset_Model_No__c = 'Test09',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod07, prod08, prod09 };
+
+ //鍒朵綔浜у搧
+ Product2__c proG = new Product2__c(
+ Name = 'MH-155:鐧藉钩琛″附',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod07.Id
+ );
+ insert proG;
+ Product2__c proH = new Product2__c(
+ Name = 'MB-677:BNC鐢电紗',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod08.Id
+ );
+ insert proH;
+ Product2__c proF = new Product2__c(
+ Name = 'TooMAJ-643R:姘村泭闉樼003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod09.Id
+ );
+ insert proF;
+
+ //璁㈠崟
+ Consumable_order__c order = new Consumable_order__c();
+ order.Name = 'testMing';
+ order.Order_status__c = '鎵瑰噯';
+ order.RecordTypeid = System.Label.RT_ConOrder_Order;
+ order.Dealer_Info__c = myAccount1.id;
+ order.Inventory_date__c = Date.today();
+ order.Order_type__c = '璁㈠崟';
+ order.Order_ProType__c = 'ET';
+ insert order;
+ //鍒拌揣
+ Consumable_order__c order2 = new Consumable_order__c();
+ order2.Name = 'testMing1';
+ order2.Order_status__c = '鎵瑰噯';
+ order2.RecordTypeid = '01210000000c9dqAAA';
+ order2.Dealer_Info__c = myAccount1.id;
+ order2.Order_type__c = '鍒拌揣';
+ order2.Order_ProType__c = 'ET';
+ insert order2;
+
+ List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
+ //鍒朵綔Consumable_order_details__c-------ProductCount
+ // 閿�鍞�
+ Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c();
+ dataForProductCount7.Bar_Code__c = '123456789298k250AAAAA';
+ dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount7.Arrive_date__c = Date.today();
+ dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount7.Consumable_Product__c = proH.id;
+ dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c;
+ dataForProductCount7.Box_Piece__c = '鐩�';
+ dataForProductCount7.Used_date__c = Date.today();
+ dataForProductCount7.Consumable_order_minor__c = order.id;
+
+ conList.add(dataForProductCount7);
+ // 鍦ㄥ簱 杩囨湡 鐩�
+ Consumable_order_details2__c dataForProduct = new Consumable_order_details2__c();
+ dataForProduct.Bar_Code__c = '123456789498k250BBBBB';
+ dataForProduct.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProduct.Arrive_date__c = Date.today();
+ dataForProduct.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProduct.Consumable_Product__c = proF.id;
+ dataForProduct.Asset_Model_No__c = proF.Asset_Model_No__c;
+ dataForProduct.Box_Piece__c = '鐩�';
+ dataForProduct.Consumable_order_minor__c = order.id;
+
+ conList.add(dataForProduct);
+ // 鍦ㄥ簱 杩囨湡 涓�
+ Consumable_order_details2__c dataForProductCount3 = new Consumable_order_details2__c();
+ dataForProductCount3.Bar_Code__c = '123456788398k250CCCCC';
+ dataForProductCount3.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProductCount3.Arrive_date__c = Date.today();
+ dataForProductCount3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount3.Consumable_Product__c = proG.id;
+ dataForProductCount3.Asset_Model_No__c = proG.Asset_Model_No__c;
+ dataForProductCount3.Box_Piece__c = '涓�';
+ dataForProductCount3.RemoveBox_No__c = 1;
+ dataForProductCount3.Consumable_order_minor__c = order.id;
+ conList.add(dataForProductCount3);
+ insert conList;
+
+ //杩囨湡搴撳瓨姹囨�讳俊鎭� add by Wang Xueqin
+ List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
+ Consumable_order_details2__c dataForProductCount4 = new Consumable_order_details2__c();
+ dataForProductCount4.Bar_Code__c = '1001';
+ dataForProductCount4.Arrive_date__c = Date.today();
+ dataForProductCount4.Send_Date__c = null;
+ dataForProductCount4.Used_date__c = null;
+ dataForProductCount4.Return_date__c = null;
+ dataForProductCount4.Lose_Flag__c = false;
+ dataForProductCount4.Cancellation_Flag__c = false;
+ dataForProductCount4.Consumable_Product__c = proG.Id;
+ dataForProductCount4.Consumable_Arrived_order__c = order2.id;
+ dataForProductCount4.Used_account__c = myAccount1.Id;
+ dataForProductCount4.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProductCount4.Box_Piece__c = '鐩�';
+ conList1.add(dataForProductCount4);
+ System.debug('conList1==>' + conList1);
+ //鏌ヨ鎵�鏈夎繃鏈熷簱瀛�
+ Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c();
+ dataForProductCount5.Bar_Code__c = '1002';
+ dataForProductCount5.Arrive_date__c = Date.today();
+ dataForProductCount5.Send_Date__c = Date.today();
+ dataForProductCount5.Used_date__c = Date.today();
+ dataForProductCount5.Return_date__c = null;
+ dataForProductCount5.Lose_Flag__c = false;
+ dataForProductCount5.Cancellation_Flag__c = false;
+ dataForProductCount5.Consumable_Product__c = proG.Id;
+ dataForProductCount5.Consumable_Arrived_order__c = order2.id;
+ dataForProductCount5.Used_account__c = myAccount1.Id;
+ dataForProductCount5.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProductCount5.Box_Piece__c = '鐩�';
+ conList1.add(dataForProductCount5);
+ insert conList1;
+ Test.startTest();
+ LexConsumableGoodsInfo.initMoreThan7(dataForProductCount7.Id);
+ LexConsumableGoodsInfo.initMoreThan7All('all');
+ LexConsumableGoodsInfo.initNotArrDet(dataForProductCount7.Id);
+ LexConsumableGoodsInfo.initNotArrDetAll('all');
+ LexConsumableGoodsInfo.initArrDet(dataForProductCount7.Id);
+ LexConsumableGoodsInfo.initArrDetAll('all');
+ LexConsumableGoodsInfo.initDeliveryDet(dataForProductCount7.Id);
+ LexConsumableGoodsInfo.initDeliveryDetAll('all');
+ LexConsumableGoodsInfo.initTotalNum('1', 'all');
+ LexConsumableGoodsInfo.initTotalNum(dataForProductCount7.Id, 'all');
+ Test.stopTest();
+ }
+ }
+
+ @IsTest
+ static void lexConsumableGoodsInfoTest2() {
+ User myUser_test = new User();
+ Account myAccount1;
+ Contact core;
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(currentUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount1;
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '鍖椾含'
+ );
+ insert myUser_test;
+ }
+ System.runAs(myUser_test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ 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(
+ Name = 'OCM_01_001',
+ RecordTypeId = System.Label.RT_ConOrder_Delivery,
+ Order_type__c = '璁㈠崟',
+ Dealer_info__c = myAccount1.Id,
+ Order_ProType__c = 'ET'
+ );
+ Consumable_order__c Order2 = new Consumable_order__c(
+ Name = 'OCM_01_002',
+ RecordTypeId = System.Label.RT_ConOrder_Delivery,
+ Order_type__c = '璁㈠崟',
+ Dealer_info__c = myAccount1.Id,
+ Order_ProType__c = 'ET'
+ );
+ insert new List<Consumable_order__c>{ Order1, Order2 };
+
+ //鏄庣粏1
+ Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c();
+ createDetail.name = 'Too001';
+ createDetail.Consumable_Product__c = pro1.id;
+ createDetail.Dealer_Custom_Price__c = 999.00;
+ createDetail.Consumable_count__c = 3;
+ createDetail.Consumable_order__c = Order1.id;
+ createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
+ insert createDetail;
+ Consumable_orderdetails__c createDetail1 = new Consumable_orderdetails__c();
+ createDetail1.name = 'Too002';
+ createDetail1.Consumable_Product__c = pro2.id;
+ createDetail1.Consumable_order__c = Order2.id;
+ createDetail1.Dealer_Custom_Price__c = 999.00;
+ createDetail1.Consumable_count__c = 4;
+ createDetail1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
+ insert createDetail1;
+
+ //璁㈠崟鏄庣粏
+ Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001001',
+ Consumable_order_minor__c = Order1.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001002',
+ Consumable_order_minor__c = Order2.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro2.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001003',
+ Consumable_order_minor__c = Order1.Id,
+ //Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001004',
+ Consumable_order_minor__c = Order2.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro2.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ insert new List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ Orderdet3,
+ Orderdet4
+ };
+
+ LexConsumableGoodsInfo.initMoreThan7(Orderdet1.Id);
+ LexConsumableGoodsInfo.initMoreThan7All('all');
+ LexConsumableGoodsInfo.initNotArrDet(Orderdet1.Id);
+ LexConsumableGoodsInfo.initNotArrDetAll('all');
+ LexConsumableGoodsInfo.initArrDet(Orderdet1.Id);
+ LexConsumableGoodsInfo.initArrDetAll('all');
+ LexConsumableGoodsInfo.initDeliveryDet(Orderdet1.Id);
+ LexConsumableGoodsInfo.initDeliveryDetAll('all');
+ LexConsumableGoodsInfo.initTotalNum('1', 'all');
+ LexConsumableGoodsInfo.initTotalNum(Orderdet1.Id, 'all');
+ }
+ }
+
+ @IsTest
+ static void lexConsumableGoodsInfoTest3() {
+ User myUser_test = new User();
+ Account myAccount1;
+ Contact core;
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(currentUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount1;
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '鍖椾含'
+ );
+ insert myUser_test;
+ }
+ System.runAs(myUser_test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ 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(
+ Name = 'OCM_01_001',
+ RecordTypeId = System.Label.RT_ConOrder_Delivery,
+ Order_type__c = '璁㈠崟',
+ Dealer_info__c = myAccount1.Id,
+ Order_ProType__c = 'ET'
+ );
+ Consumable_order__c Order2 = new Consumable_order__c(
+ Name = 'OCM_01_002',
+ RecordTypeId = System.Label.RT_ConOrder_Delivery,
+ Order_type__c = '璁㈠崟',
+ Dealer_info__c = myAccount1.Id,
+ Order_ProType__c = 'ET'
+ );
+ insert new List<Consumable_order__c>{ Order1, Order2 };
+
+ //鏄庣粏1
+ Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c();
+ createDetail.name = 'Too001';
+ createDetail.Consumable_Product__c = pro1.id;
+ createDetail.Dealer_Custom_Price__c = 999.00;
+ createDetail.Consumable_count__c = 3;
+ createDetail.Consumable_order__c = Order1.id;
+ createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
+ insert createDetail;
+ Consumable_orderdetails__c createDetail1 = new Consumable_orderdetails__c();
+ createDetail1.name = 'Too002';
+ createDetail1.Consumable_Product__c = pro2.id;
+ createDetail1.Consumable_order__c = Order2.id;
+ createDetail1.Dealer_Custom_Price__c = 999.00;
+ createDetail1.Consumable_count__c = 4;
+ createDetail1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
+ insert createDetail1;
+
+ //璁㈠崟鏄庣粏
+ Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001001',
+ Consumable_order_minor__c = Order1.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001002',
+ Consumable_order_minor__c = Order2.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro2.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001003',
+ Consumable_order_minor__c = Order1.Id,
+ //Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001004',
+ Consumable_order_minor__c = Order2.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro2.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ insert new List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ Orderdet3,
+ Orderdet4
+ };
+
+ LexConsumableGoodsInfo.initMoreThan7(Orderdet2.Id);
+ LexConsumableGoodsInfo.initMoreThan7All('');
+ LexConsumableGoodsInfo.initNotArrDet(Orderdet2.Id);
+ LexConsumableGoodsInfo.initNotArrDetAll('');
+ LexConsumableGoodsInfo.initArrDet(Orderdet2.Id);
+ LexConsumableGoodsInfo.initArrDetAll('');
+ LexConsumableGoodsInfo.initDeliveryDet(Orderdet2.Id);
+ LexConsumableGoodsInfo.initDeliveryDetAll('');
+ LexConsumableGoodsInfo.initTotalNum(Orderdet2.Id, '');
+ }
+ }
+
+ @IsTest
+ static void lexConsumableGoodsInfoTest4() {
+ User myUser_test = new User();
+ Account myAccount1;
+ Contact core;
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(currentUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount1;
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '鍖椾含'
+ );
+ insert myUser_test;
+ }
+ System.runAs(myUser_test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ 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(
+ Name = 'OCM_01_001',
+ RecordTypeId = System.Label.RT_ConOrder_Delivery,
+ Order_type__c = '璁㈠崟',
+ Dealer_info__c = myAccount1.Id,
+ Order_ProType__c = 'ET'
+ );
+ Consumable_order__c Order2 = new Consumable_order__c(
+ Name = 'OCM_01_002',
+ RecordTypeId = System.Label.RT_ConOrder_Delivery,
+ Order_type__c = '璁㈠崟',
+ Dealer_info__c = myAccount1.Id,
+ Order_ProType__c = 'ET'
+ );
+ insert new List<Consumable_order__c>{ Order1, Order2 };
+
+ //鏄庣粏1
+ Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c();
+ createDetail.name = 'Too001';
+ createDetail.Consumable_Product__c = pro1.id;
+ createDetail.Dealer_Custom_Price__c = 999.00;
+ createDetail.Consumable_count__c = 3;
+ createDetail.Consumable_order__c = Order1.id;
+ createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
+ insert createDetail;
+ Consumable_orderdetails__c createDetail1 = new Consumable_orderdetails__c();
+ createDetail1.name = 'Too002';
+ createDetail1.Consumable_Product__c = pro2.id;
+ createDetail1.Consumable_order__c = Order2.id;
+ createDetail1.Dealer_Custom_Price__c = 999.00;
+ createDetail1.Consumable_count__c = 4;
+ createDetail1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
+ insert createDetail1;
+
+ //璁㈠崟鏄庣粏
+ Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001001',
+ Consumable_order_minor__c = Order1.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001002',
+ Consumable_order_minor__c = Order2.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro2.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001003',
+ Consumable_order_minor__c = Order1.Id,
+ //Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001004',
+ Consumable_order_minor__c = Order2.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro2.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ insert new List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ Orderdet3,
+ Orderdet4
+ };
+
+ LexConsumableGoodsInfo.initMoreThan7(Orderdet3.Id);
+ LexConsumableGoodsInfo.initNotArrDet(Orderdet3.Id);
+ LexConsumableGoodsInfo.initArrDet(Orderdet3.Id);
+ LexConsumableGoodsInfo.initDeliveryDet(Orderdet3.Id);
+ LexConsumableGoodsInfo.initTotalNum(Orderdet3.Id, 'all');
+ }
+ }
+
+ @IsTest
+ static void lexConsumableGoodsInfoTest5() {
+ User myUser_test = new User();
+ Account myAccount1;
+ Contact core;
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(currentUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount1;
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '鍖椾含'
+ );
+ insert myUser_test;
+ }
+ System.runAs(myUser_test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ 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(
+ Name = 'OCM_01_001',
+ RecordTypeId = System.Label.RT_ConOrder_Delivery,
+ Order_type__c = '璁㈠崟',
+ Dealer_info__c = myAccount1.Id,
+ Order_ProType__c = 'ET'
+ );
+ Consumable_order__c Order2 = new Consumable_order__c(
+ Name = 'OCM_01_002',
+ RecordTypeId = System.Label.RT_ConOrder_Delivery,
+ Order_type__c = '璁㈠崟',
+ Dealer_info__c = myAccount1.Id,
+ Order_ProType__c = 'ET'
+ );
+ insert new List<Consumable_order__c>{ Order1, Order2 };
+
+ //鏄庣粏1
+ Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c();
+ createDetail.name = 'Too001';
+ createDetail.Consumable_Product__c = pro1.id;
+ createDetail.Dealer_Custom_Price__c = 999.00;
+ createDetail.Consumable_count__c = 3;
+ createDetail.Consumable_order__c = Order1.id;
+ createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
+ insert createDetail;
+ Consumable_orderdetails__c createDetail1 = new Consumable_orderdetails__c();
+ createDetail1.name = 'Too002';
+ createDetail1.Consumable_Product__c = pro2.id;
+ createDetail1.Consumable_order__c = Order2.id;
+ createDetail1.Dealer_Custom_Price__c = 999.00;
+ createDetail1.Consumable_count__c = 4;
+ createDetail1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
+ insert createDetail1;
+
+ //璁㈠崟鏄庣粏
+ Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001001',
+ Consumable_order_minor__c = Order1.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001002',
+ Consumable_order_minor__c = Order2.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro2.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001003',
+ Consumable_order_minor__c = Order1.Id,
+ //Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001004',
+ Consumable_order_minor__c = Order2.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro2.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery
+ );
+ insert new List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ Orderdet3,
+ Orderdet4
+ };
+
+ LexConsumableGoodsInfo.initMoreThan7(Orderdet4.Id);
+ LexConsumableGoodsInfo.initNotArrDet(Orderdet4.Id);
+ LexConsumableGoodsInfo.initArrDet(Orderdet4.Id);
+ LexConsumableGoodsInfo.initDeliveryDet(Orderdet4.Id);
+ LexConsumableGoodsInfo.initTotalNum(Orderdet4.Id, 'all');
+ }
+ }
+
+ @IsTest
+ static void lexConsumableGoodsInfoTest6() {
+ LexConsumableGoodsInfo.ShowRecords sr = new LexConsumableGoodsInfo.ShowRecords();
+ sr.prodModel = 'test';
+ sr.recordCount = 1;
+ sr.compareTo(new LexConsumableGoodsInfo.ShowRecords());
+ }
+
+ @IsTest
+ static void lexConsumableGoodsInfoTest7() {
+ User myUser_test = new User();
+ Account myAccount1;
+ Contact core;
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(currentUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount1;
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '鍖椾含',
+ UserPro_Type__c = 'ET'
+ );
+ insert myUser_test;
+ }
+ System.runAs(myUser_test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ 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(
+ Name = 'OCM_01_001',
+ RecordTypeId = System.Label.RT_ConOrder_Delivery,
+ Order_type__c = '璁㈠崟',
+ Dealer_info__c = myAccount1.Id,
+ Delivery_detail_count__c = 1,
+ Order_ProType__c = 'ET',
+ showFalseNotshowTrue__c = false
+ );
+ insert new List<Consumable_order__c>{ Order1 };
+
+ //鏄庣粏1
+ Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c();
+ createDetail.name = 'Too001';
+ createDetail.Consumable_Product__c = pro1.id;
+ createDetail.Dealer_Custom_Price__c = 999.00;
+ createDetail.Consumable_count__c = 3;
+ createDetail.Consumable_order__c = Order1.id;
+ createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
+ insert createDetail;
+
+ //璁㈠崟鏄庣粏
+ Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001001',
+ Asset_Model_No__c = 'Test01',
+ Consumable_order_minor__c = Order1.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery,
+ Cancellation_Flag__c = false
+ );
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001003',
+ Asset_Model_No__c = 'Test01',
+ Consumable_order_minor__c = Order1.Id,
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery,
+ Cancellation_Flag__c = false
+ );
+ insert new List<Consumable_order_details2__c>{ Orderdet1, Orderdet3 };
+ LexConsumableGoodsInfo.initNotArrDet(Order1.Id);
+ LexConsumableGoodsInfo.initNotArrDetAll('all');
+ }
+ }
+
+ @IsTest
+ static void lexConsumableGoodsInfoTest8() {
+ User myUser_test = new User();
+ Account myAccount1;
+ Contact core;
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(currentUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount1;
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '鍖椾含',
+ UserPro_Type__c = 'ET'
+ );
+ insert myUser_test;
+ }
+ System.runAs(myUser_test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ 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(
+ Name = 'OCM_01_001',
+ RecordTypeId = System.Label.RT_ConOrder_Delivery,
+ Order_type__c = '璁㈠崟',
+ Dealer_info__c = myAccount1.Id,
+ Delivery_detail_count__c = 1,
+ Order_ProType__c = 'ET',
+ showFalseNotshowTrue__c = false
+ );
+ insert new List<Consumable_order__c>{ Order1 };
+
+ //鏄庣粏1
+ Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c();
+ createDetail.name = 'Too001';
+ createDetail.Consumable_Product__c = pro1.id;
+ createDetail.Dealer_Custom_Price__c = 999.00;
+ createDetail.Consumable_count__c = 3;
+ createDetail.Consumable_order__c = Order1.id;
+ createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
+ insert createDetail;
+
+ //璁㈠崟鏄庣粏
+ Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001001',
+ Consumable_order_minor__c = Order1.Id,
+ Arrive_date__c = Date.today(),
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery,
+ Cancellation_Flag__c = false
+ );
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c(
+ Name = 'OCM_01_001003',
+ Consumable_order_minor__c = Order1.Id,
+ Consumable_Product__c = pro1.id,
+ RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery,
+ Cancellation_Flag__c = false
+ );
+ insert new List<Consumable_order_details2__c>{ Orderdet1, Orderdet3 };
+ LexConsumableGoodsInfo.initNotArrDetAll('all');
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexConsumableGoodsInfoTest.cls-meta.xml b/force-app/main/default/classes/LexConsumableGoodsInfoTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexConsumableGoodsInfoTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexConsumableOrderManageControllerTest.cls b/force-app/main/default/classes/LexConsumableOrderManageControllerTest.cls
new file mode 100644
index 0000000..2fffa74
--- /dev/null
+++ b/force-app/main/default/classes/LexConsumableOrderManageControllerTest.cls
@@ -0,0 +1,132 @@
+@istest
+public class LexConsumableOrderManageControllerTest {
+ @IsTest
+ static void ConsumableOrdertest() {
+ User myUser_test = new User();
+ Account myAccount1;
+ Contact core;
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(currentUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id
+ );
+ insert myAccount1;
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '鍖椾含'
+ );
+ insert myUser_test;
+ }
+
+ System.runAs(myUser_test) {
+ Consumable_order__c testList5 = new Consumable_order__c(
+ Name = 'test5',
+ Order_status__c = '鑽夋涓�',
+ Dealer_info__c = myAccount1.Id,
+ Order_type__c = '璁㈠崟',
+ RecordtypeId = System.Label.RT_ConOrder_Order,
+ Order_ProType__c = 'ET'
+ );
+ Consumable_order__c testList6 = new Consumable_order__c(
+ Name = 'test6',
+ Order_status__c = '宸叉彁浜�',
+ Dealer_info__c = myAccount1.Id,
+ Order_type__c = '璁㈠崟',
+ RecordtypeId = System.Label.RT_ConOrder_Order,
+ Order_ProType__c = 'ET'
+ );
+ Consumable_order__c testList7 = new Consumable_order__c(
+ Name = 'test7',
+ Order_status__c = '宸叉彁浜�',
+ Dealer_info__c = myAccount1.Id,
+ Order_type__c = '璁㈠崟',
+ RecordtypeId = System.Label.RT_ConOrder_Order,
+ Order_ProType__c = 'ET'
+ );
+ Consumable_order__c testList1 = new Consumable_order__c(
+ Name = 'test1',
+ Order_status__c = '鑽夋涓�',
+ Dealer_info__c = myAccount1.Id,
+ Order_type__c = '璁㈠崟',
+ RecordtypeId = System.Label.RT_ConOrder_Order,
+ Order_ProType__c = 'ET'
+ );
+ Consumable_order__c testList2 = new Consumable_order__c(
+ Name = 'test2',
+ Order_status__c = '鑽夋涓�',
+ Dealer_info__c = myAccount1.Id,
+ Order_type__c = '璁㈠崟',
+ RecordtypeId = System.Label.RT_ConOrder_Order,
+ Order_ProType__c = 'ET'
+ );
+ Consumable_order__c testList3 = new Consumable_order__c(
+ Name = 'test3',
+ Order_status__c = '鑽夋涓�',
+ Dealer_info__c = myAccount1.Id,
+ Order_type__c = '璁㈠崟',
+ RecordtypeId = System.Label.RT_ConOrder_Order,
+ Order_ProType__c = 'ET'
+ );
+ Consumable_order__c testList4 = new Consumable_order__c(
+ Name = 'test4',
+ Order_status__c = '鑽夋涓�',
+ Dealer_info__c = myAccount1.Id,
+ Order_type__c = '璁㈠崟',
+ RecordtypeId = System.Label.RT_ConOrder_Order,
+ Order_date__c = Date.today(),
+ Order_ProType__c = 'ET'
+ );
+ insert new List<Consumable_order__c>{
+ testList1,
+ testList2,
+ testList3,
+ testList4,
+ testList5,
+ testList6,
+ testList7
+ };
+ LexConsumableOrderManageController.init1();
+ String accID = myAccount1.Id;
+ LexConsumableOrderManageController.searchConsumableorderdetails(
+ '',
+ null,
+ '',
+ accID,
+ 'ET',
+ '鍖椾含'
+ );
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexConsumableOrderManageControllerTest.cls-meta.xml b/force-app/main/default/classes/LexConsumableOrderManageControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexConsumableOrderManageControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexInventoryController.cls b/force-app/main/default/classes/LexInventoryController.cls
index 564eded..238f43d 100644
--- a/force-app/main/default/classes/LexInventoryController.cls
+++ b/force-app/main/default/classes/LexInventoryController.cls
@@ -1,1283 +1,1801 @@
public without sharing class LexInventoryController {
- // page
- public static Integer pagesize { get; set; }
- public static Integer pageToken { get; set; }
- public static String sortField { get; set; }
- public static String sortOrder { get; set; }
-
- public static Integer totalcount { get; set; }
- //鍒嗛〉浣跨敤鏁版嵁
- public static String fileName { get; set; }
- public static Integer size{get;set;}
- public static Integer noOfRecords{get; set;}
- public static List<ConsumableorderdetailsInfo> codPageRecords { get; set; } // 涓㈠け鍜屽贰鍥炵殑,鐢婚潰鏄剧ず鐢�
- public static ApexPages.StandardSetController setCon { get; set; }
- @AuraEnabled
- public static List<Consumable_order_details2__c> setConDetails2 { get; set; }
- public static Map<Id,String> pandiandetailsMap = new Map<Id,String>();
- /*****************妞滅储鐢�******************/
- public static String barcode { get; set; }
- public static Boolean done { get; set; }
- /*****************鐢婚潰琛ㄧずBean******************/
- //椤甸潰涓绘暟鎹樉绀虹敤
- private static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords;
- //鐩樼偣鍒扮殑浜у搧
- public static List<Consumable_order_details2__c> reSet = new List<Consumable_order_details2__c>();
- public static List<Consumable_order_details2__c> showcod2nid = new List<Consumable_order_details2__c>();
+ // page
+ public static Integer pagesize { get; set; }
+ public static Integer pageToken { get; set; }
+ public static String sortField { get; set; }
+ public static String sortOrder { get; set; }
- //public List<Consumable_order_details2__c> pandiandetailsList { get; set; }
- public static List<List<Consumable_order_details2__c>> pandiandetailsListShow { get; set; }
- //瀵诲洖鏄庣粏
- public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordserrordummy; // 涓㈠け鍜屽贰鍥炵殑,瀹為檯鐐掍綔鐢�
- @AuraEnabled
- public static List<List<ConsumableorderdetailsInfo>> consumableorderdetailsRecordsview { get; set; } // 浜у搧鍗曚綅鐨凩ist
- public static List<Consumable_order_details2__c> InsListUp = New List<Consumable_order_details2__c>();
+ public static Integer totalcount { get; set; }
+ //鍒嗛〉浣跨敤鏁版嵁
+ public static String fileName { get; set; }
+ public static Integer size { get; set; }
+ public static Integer noOfRecords { get; set; }
+ public static List<ConsumableorderdetailsInfo> codPageRecords { get; set; } // 涓㈠け鍜屽贰鍥炵殑,鐢婚潰鏄剧ず鐢�
+ public static ApexPages.StandardSetController setCon { get; set; }
+ @AuraEnabled
+ public static List<Consumable_order_details2__c> setConDetails2 { get; set; }
+ public static Map<Id, String> pandiandetailsMap = new Map<Id, String>();
+ /*****************妞滅储鐢�******************/
+ public static String barcode { get; set; }
+ public static Boolean done { get; set; }
+ /*****************鐢婚潰琛ㄧずBean******************/
+ //椤甸潰涓绘暟鎹樉绀虹敤
+ // private static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords;
+ public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords;
+ //鐩樼偣鍒扮殑浜у搧
+ public static List<Consumable_order_details2__c> reSet = new List<Consumable_order_details2__c>();
+ public static List<Consumable_order_details2__c> showcod2nid = new List<Consumable_order_details2__c>();
- public static List<ConsumableorderdetailsInfo> consumableorderdetailsviewRecords;
-
- public static Integer consumableorderdetailsCount {
- get {
- return consumableorderdetailsRecords == null ? 0 : consumableorderdetailsRecords.size();
- }
+ //public List<Consumable_order_details2__c> pandiandetailsList { get; set; }
+ public static List<List<Consumable_order_details2__c>> pandiandetailsListShow {
+ get;
+ set;
+ }
+ //瀵诲洖鏄庣粏
+ public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordserrordummy; // 涓㈠け鍜屽贰鍥炵殑,瀹為檯鐐掍綔鐢�
+ @AuraEnabled
+ public static List<List<ConsumableorderdetailsInfo>> consumableorderdetailsRecordsview {
+ get;
+ set;
+ } // 浜у搧鍗曚綅鐨凩ist
+ public static List<Consumable_order_details2__c> InsListUp = new List<Consumable_order_details2__c>();
+
+ public static List<ConsumableorderdetailsInfo> consumableorderdetailsviewRecords;
+
+ public static Integer consumableorderdetailsCount {
+ get {
+ return consumableorderdetailsRecords == null
+ ? 0
+ : consumableorderdetailsRecords.size();
}
- //list<String> notexitlist = new list<String>();
- public static Map<String,String> reFindProduct = new Map<String,String>();
- //鎺掑簭鐢�
- // public static String sortKey;
- // public static String preSortKey;
- // public static Boolean sortOrderAsc;
- // public static String[] sortOrder;
- //private Set<String> carCodeListLose = new Set<String>(); //ProductCount_Res 鏈夛紝BarCodeListP 娌℃湁
- /*****************缁忛攢鍟咺D******************/
- private static String accountid = null;
- private static String accountName = null;
- // 鐩樼偣 ID
- private static String eSetId = '';
- // 鐧诲綍鑰呭伐浣滃湴
- private static String userWorkLocation;
- //缁忛攢鍟嗙敤鎴蜂骇鍝佸垎绫伙紙ET銆丒NG锛�
- public static String agencyProType {get;set;}
- public static String sqlagencyProType;
- //鍒ゆ柇鎿嶄綔浜哄憳鏄惁鐩樼偣
- public static Boolean iSinventory = false;
+ }
+ //list<String> notexitlist = new list<String>();
+ public static Map<String, String> reFindProduct = new Map<String, String>();
+ //鎺掑簭鐢�
+ // public static String sortKey;
+ // public static String preSortKey;
+ // public static Boolean sortOrderAsc;
+ // public static String[] sortOrder;
+ //private Set<String> carCodeListLose = new Set<String>(); //ProductCount_Res 鏈夛紝BarCodeListP 娌℃湁
+ /*****************缁忛攢鍟咺D******************/
+ private static String accountid = null;
+ private static String accountName = null;
+ // 鐩樼偣 ID
+ private static String eSetId = '';
+ // 鐧诲綍鑰呭伐浣滃湴
+ private static String userWorkLocation;
+ //缁忛攢鍟嗙敤鎴蜂骇鍝佸垎绫伙紙ET銆丒NG锛�
+ public static String agencyProType { get; set; }
+ public static String sqlagencyProType;
+ //鍒ゆ柇鎿嶄綔浜哄憳鏄惁鐩樼偣
+ public static Boolean iSinventory = false;
- public LexInventoryController(){
- size = Integer.valueOf(System.Label.orderdetLimitsize);
- consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- done = false;
+ public LexInventoryController() {
+ size = Integer.valueOf(System.Label.orderdetLimitsize);
+ consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ done = false;
- consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
- consumableorderdetailsRecordserrordummy = new List<ConsumableorderdetailsInfo>();
- codPageRecords = new List<ConsumableorderdetailsInfo>();
- //codPageRecordsShow = new List<ConsumableorderdetailsInfo>();
+ consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
+ consumableorderdetailsRecordserrordummy = new List<ConsumableorderdetailsInfo>();
+ codPageRecords = new List<ConsumableorderdetailsInfo>();
+ //codPageRecordsShow = new List<ConsumableorderdetailsInfo>();
+ }
+
+ private static void initStandardController() {
+ // init standard controller
+ List<Consumable_order_details2__c> showcod2 = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ Bar_Code_search__c
+ FROM Consumable_order_details2__c
+ WHERE Id IN :pandiandetailsMap.keySet()
+ ORDER BY Name DESC
+ ];
+ setConDetails2 = showcod2;
+ System.debug('setConDetails2===>' + setConDetails2);
+ // setCon = new ApexPages.StandardSetController(showcod2);
+ // // sets the number of records in each page set
+ // setCon.setPageSize(size);
+ // noOfRecords = setCon.getResultSize();
+ }
+
+ public static List<Consumable_order_details2__c> cod2s() {
+ return setConDetails2;
+ }
+ //Changes the size of pagination
+ public static PageReference refreshPageSize() {
+ setCon.setPageSize(size);
+ //showcod2nid = cod2s();
+ makepagerecords();
+ return null;
+ }
+
+ public static List<ConsumableorderdetailsInfo> makepagerecords() {
+ showcod2nid = cod2s();
+ codPageRecords = new List<ConsumableorderdetailsInfo>();
+ for (Consumable_order_details2__c cod2 : showcod2nid) {
+ codPageRecords.add(
+ new ConsumableorderdetailsInfo(cod2, pandiandetailsMap.get(cod2.Id))
+ );
}
+ System.debug('===>codPageRecords1' + codPageRecords);
+ return codPageRecords;
+ }
- private static void initStandardController(){
- // init standard controller
- List<Consumable_order_details2__c> showcod2 = [select Id, Name,Consumable_Product__c,
- Bar_Code__c,Consumable_Product__r.Name__c,
- Asset_Model_No__c,Isoverdue__c,Box_Piece__c,
- Bar_Code_search__c
- FROM Consumable_order_details2__c
- WHERE Id in :pandiandetailsMap.keySet()
- order by Name desc];
- setConDetails2 = showcod2;
- System.debug('setConDetails2===>'+setConDetails2);
- // setCon = new ApexPages.StandardSetController(showcod2);
- // // sets the number of records in each page set
- // setCon.setPageSize(size);
- // noOfRecords = setCon.getResultSize();
+ // 鐢婚潰鍒濆鍖�
+ @AuraEnabled
+ public static ResponseBodyLWC init() {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
+ setConDetails2 = new List<Consumable_order_details2__c>();
+ String url = '鍦ㄥ簱璋冩暣涓�瑙�';
+ fileName = EncodingUtil.urlEncode(url, 'UTF-8');
+ List<Consumable_order_details2__c> showcod2 = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ Bar_Code_search__c
+ FROM Consumable_order_details2__c
+ WHERE Id IN :pandiandetailsMap.keySet()
+ ORDER BY Name
+ ];
+ System.debug('pandiandetailsMap====>' + pandiandetailsMap);
+ initStandardController();
+ makepagerecords();
+ // sortKey = '1';
+ // preSortKey = '1';
+ // sortOrderAsc = false;
+ // sortOrder = new String[1];
+ // sortOrder = new String[]{' ',' ','鈫�'};
+
+ String userId = UserInfo.getUserId();
+ //String userId = '00510000006k82X';
+ //String userId = '00510000005QO75';
+ user Useracc = [
+ SELECT Accountid, Work_Location__c, UserPro_Type__c
+ FROM user
+ WHERE id = :userId
+ ];
+ accountid = Useracc.Accountid;
+ userWorkLocation = Useracc.Work_Location__c;
+ agencyProType = Useracc.UserPro_Type__c;
+ if (String.isBlank(Useracc.UserPro_Type__c)) {
+ agencyProType = 'ET';
}
-
- public static List<Consumable_order_details2__c> cod2s() {
- return setConDetails2;
- }
- //Changes the size of pagination
- public static PageReference refreshPageSize() {
- setCon.setPageSize(size);
- //showcod2nid = cod2s();
- makepagerecords();
- return null;
- }
-
- public static List<ConsumableorderdetailsInfo> makepagerecords() {
- showcod2nid = cod2s();
- codPageRecords = new List<ConsumableorderdetailsInfo>();
- for (Consumable_order_details2__c cod2 : showcod2nid) {
- codPageRecords.add(new ConsumableorderdetailsInfo(cod2,pandiandetailsMap.get(cod2.Id)));
- }
- System.debug('===>codPageRecords1'+codPageRecords);
- return codPageRecords;
- }
-
- // 鐢婚潰鍒濆鍖�
- @AuraEnabled
- public static ResponseBodyLWC init() {
-
-
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String,object> data = new Map<String,object>();
- res.entity = data;
-
- consumableorderdetailsRecordsview = new List<List<ConsumableorderdetailsInfo>>();
- setConDetails2 = new List<Consumable_order_details2__c>();
- String url = '鍦ㄥ簱璋冩暣涓�瑙�';
- fileName = EncodingUtil.urlEncode(url, 'UTF-8');
- List<Consumable_order_details2__c> showcod2 = [select Id, Name,Consumable_Product__c,
- Bar_Code__c,Consumable_Product__r.Name__c,
- Asset_Model_No__c,Isoverdue__c,Box_Piece__c,
- Bar_Code_search__c
- FROM Consumable_order_details2__c
- WHERE Id in :pandiandetailsMap.keySet()
- order by Name];
- System.debug('pandiandetailsMap====>'+pandiandetailsMap);
- initStandardController();
- makepagerecords();
- // sortKey = '1';
- // preSortKey = '1';
- // sortOrderAsc = false;
- // sortOrder = new String[1];
- // sortOrder = new String[]{' ',' ','鈫�'};
-
- String userId = UserInfo.getUserId();
- //String userId = '00510000006k82X';
- //String userId = '00510000005QO75';
- user Useracc = [select Accountid, Work_Location__c,UserPro_Type__c from user where id =:userId];
- accountid = Useracc.Accountid;
- userWorkLocation = Useracc.Work_Location__c;
- agencyProType = Useracc.UserPro_Type__c;
- if(String.isBlank(Useracc.UserPro_Type__c)){
- agencyProType = 'ET';
- }
- sqlagencyProType = '%' + agencyProType + '%';
- Account accountInfo = [SELECT Name,Dealer_discount__c FROM account WHERE id =:accountid];
- accountName = accountInfo.Name;
- consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- Map<String,Product2__c> midMap = new Map<String,Product2__c>();
- List<ConsumableorderdetailsInfo> boxRecords = new List<ConsumableorderdetailsInfo>();
- Map<String,ConsumableorderdetailsInfo> newMidBoxMap = new Map<String,ConsumableorderdetailsInfo>();
- Map<String,ConsumableorderdetailsInfo> newMidPieceMap = new Map<String,ConsumableorderdetailsInfo>();
- //DB202302357027 娑堣�楀搧杩芥函绯荤粺鏃犳硶姝e父浣跨敤鈥斺�旂洏鐐归〉闈㈡搷浣滃嵆鎶ラ敊 fy start
- //寮�濮嬪埗浣滆〃澶存暟鎹�
- // List<Product2__c> productCount_Unfull_bak = [select Id, Name,Name__c,
- // SFDA_Status__c,Packing_list_manual__c,
- // Asset_Model_No__c
- // from Product2__c
- // //where Estimation_Entry_Possibility__c = '鈼�'
- // where Product_Type__c like : sqlagencyProType
- // ];
- // for(integer i = 0;i < productCount_Unfull_bak.size() ; i++){
- // midMap.put(productCount_Unfull_bak[i].Id, productCount_Unfull_bak[i]);
- // }
- //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨
- List<Consumable_order_details2__c> ProductCount_Res = [select Id, Name,Consumable_Product__c,
- Bar_Code__c,Consumable_Product__r.Name__c,
- Asset_Model_No__c,Isoverdue__c,Box_Piece__c
- 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 Lose_Flag__c = false
- AND Cancellation_Flag__c = false
- AND Bar_Code__c !=null
- AND Product_Type__c like : sqlagencyProType
- AND Arrive_Owner_Work_Location__c =: userWorkLocation
- AND Dealer_Info_text__c = :accountName];
- //DB202302357027 娑堣�楀搧杩芥函绯荤粺鏃犳硶姝e父浣跨敤鈥斺�旂洏鐐归〉闈㈡搷浣滃嵆鎶ラ敊 fy start
- //寮�濮嬪埗浣滆〃澶存暟鎹�
- Set<Id> Product2cIdSet = new Set<Id>();
- for(Consumable_order_details2__c con_or_d2item: ProductCount_Res){
- Product2cIdSet.add(con_or_d2item.Consumable_Product__c);
- }
- List<Product2__c> productCount_Unfull_bak = [select Id, Name,Name__c,
- SFDA_Status__c,Packing_list_manual__c,
- Asset_Model_No__c
- from Product2__c
- //where Estimation_Entry_Possibility__c = '鈼�'
- where Id in:Product2cIdSet
- and Product_Type__c like : sqlagencyProType
- ];
- for(integer i = 0;i < productCount_Unfull_bak.size() ; i++){
- midMap.put(productCount_Unfull_bak[i].Id, productCount_Unfull_bak[i]);
- }
- system.debug('productCount_Unfull_bak'+productCount_Unfull_bak.size());
- // String erro='productCount_Unfull_bak:'+productCount_Unfull_bak.size();
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, erro));
- //DB202302357027 娑堣�楀搧杩芥函绯荤粺鏃犳硶姝e父浣跨敤鈥斺�旂洏鐐归〉闈㈡搷浣滃嵆鎶ラ敊 fy end
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'ProductCount_Res ' + ProductCount_Res.size()));
- for(Integer i = 0 ; i< ProductCount_Res.size();i++){
- //鐒跺悗寰幆CountDel鍋欱ox鍜宲iece2涓猰ap
- if(MidMap.containsKey(ProductCount_Res[i].Consumable_Product__c) && ProductCount_Res[i].Box_Piece__c == '鐩�'){
-
- if(newMidBoxMap.containsKey(ProductCount_Res[i].Consumable_Product__c+ProductCount_Res[i].Box_Piece__c)){
- ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(ProductCount_Res[i].Consumable_Product__c+ProductCount_Res[i].Box_Piece__c).clone();
- Jstage.countid = Jstage.countid+1 ;
- if(ProductCount_Res[i].Isoverdue__c == 1){
- Jstage.limitCount = Jstage.limitCount + 1;
- }
- Jstage.boxPiece = ProductCount_Res[i].Box_Piece__c;
- newMidBoxMap.put(ProductCount_Res[i].Consumable_Product__c+ProductCount_Res[i].Box_Piece__c, Jstage);
- }else{
- ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(ProductCount_Res[i].Consumable_Product__c));
- Jstage.countid = Jstage.countid+1 ;
- if(ProductCount_Res[i].Isoverdue__c == 1){
- Jstage.limitCount = Jstage.limitCount + 1;
- }
- Jstage.boxPiece = ProductCount_Res[i].Box_Piece__c;
- newMidBoxMap.put(ProductCount_Res[i].Consumable_Product__c+ProductCount_Res[i].Box_Piece__c, Jstage);
- }
- }else if(MidMap.containsKey(ProductCount_Res[i].Consumable_Product__c) && ProductCount_Res[i].Box_Piece__c == '涓�'){
- if(newMidPieceMap.containsKey(ProductCount_Res[i].Consumable_Product__c+ProductCount_Res[i].Box_Piece__c)){
- ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(ProductCount_Res[i].Consumable_Product__c+ProductCount_Res[i].Box_Piece__c).clone();
- Jstage.countid = Jstage.countid+1 ;
- if(ProductCount_Res[i].Isoverdue__c == 1){
- Jstage.limitCount = Jstage.limitCount + 1;
- }
- Jstage.boxPiece = ProductCount_Res[i].Box_Piece__c;
- newMidPieceMap.put(ProductCount_Res[i].Consumable_Product__c+ProductCount_Res[i].Box_Piece__c, Jstage);
- }else{
- ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(ProductCount_Res[i].Consumable_Product__c));
- Jstage.countid = Jstage.countid+1 ;
- if(ProductCount_Res[i].Isoverdue__c == 1){
- Jstage.limitCount = Jstage.limitCount + 1;
- }
- Jstage.boxPiece = ProductCount_Res[i].Box_Piece__c;
- newMidPieceMap.put(ProductCount_Res[i].Consumable_Product__c+ProductCount_Res[i].Box_Piece__c, Jstage);
- }
- }
- }
- for(ConsumableorderdetailsInfo bss : newMidBoxMap.values()){
- bss.overlimitCount = bss.countid - bss.limitCount;
- boxRecords.add(bss);
- }
- boxRecords.sort();
- for(ConsumableorderdetailsInfo bss : newMidPieceMap.values()){
- bss.overlimitCount = bss.countid - bss.limitCount;
- }
- for(ConsumableorderdetailsInfo bss : boxRecords){
- consumableorderdetailsRecords.add(bss);
- if(newMidPieceMap.containsKey(bss.Prod.Id + '涓�')){
- consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓�'));
- //newMidPieceMap绉婚櫎宸茬粡娣诲姞鐨凱iece
- newMidPieceMap.remove(bss.Prod.Id + '涓�');
- }
- }
- for(ConsumableorderdetailsInfo bss : newMidPieceMap.values()){
- consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓�'));
- }
- //consumableorderdetailsCount = consumableorderdetailsRecords.size();
- listCut();
-
-
-
-
-
- data.put('ConsumableorderdetailsRecordsview',JSON.serialize(ConsumableorderdetailsRecordsview));
- data.put('userWorkLocation',userWorkLocation);
- data.put('agencyProType',agencyProType);
- data.put('accountName',accountName);
- data.put('accountid',accountid);
-
- data.put('consumableorderdetailsRecords',JSON.serialize(consumableorderdetailsRecords));
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
- }
-
- private static void listCut(){
- //鎷嗗垎鏆傜敤list
- 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(consumableorderdetailsRecords.size() > 1000){
- for(Integer i = 0; i < consumableorderdetailsRecords.size(); i++){
- if(i < 1000){
- c = consumableorderdetailsRecords.get(i);
- ConsumableorderdetailsRecordsbreak.add(c);
- }else{
- c = consumableorderdetailsRecords.get(i);
- ConsumableorderdetailsRecordsbreakover.add(c);
- }
- }
- consumableorderdetailsRecordsview.add(ConsumableorderdetailsRecordsbreak);
- consumableorderdetailsRecordsview.add(ConsumableorderdetailsRecordsbreakover);
- }else{
- consumableorderdetailsRecordsview.add(consumableorderdetailsRecords);
- }
- }
- //========20160311======ADD_Start================================
- // 灏嗛〉闈㈡垨鍙栧緱BarCode鍘绘帀閲嶅鐨勶紝杞崲鎴怢ist
- //========20160311======ADD_Start================================
- public static List<String> ParseBarCode(String Code){
- Map<String,Integer> barcodeCountMap = new Map<String,Integer>();
- String[] Cache = new String[]{};
- Cache = Code.split('\n');
- List <String> Buff = new List<String>();
- for(String A : Cache){
- A = A.trim().toUpperCase();
- if(barcodeCountMap.containsKey(A)){
- barcodeCountMap.put(A,barcodeCountMap.get(A) + 1);
- }else{
- barcodeCountMap.put(A,1);
- }
- Buff.add(A + barcodeCountMap.get(A));
- }
- return Buff;
-
- }
-
-
-
- //test
-
- // @AuraEnabled
- // public static ResponseBodyLWC searchConsumableorderdetails(String sqlagencyProType,String userWorkLocation,String accountName,String barcode,List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsLWC){
- // return new ResponseBodyLWC('Error',500, 'test', '');
+ sqlagencyProType = '%' + agencyProType + '%';
+ Account accountInfo = [
+ SELECT Name, Dealer_discount__c
+ FROM account
+ WHERE id = :accountid
+ ];
+ accountName = accountInfo.Name;
+ consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ Map<String, Product2__c> midMap = new Map<String, Product2__c>();
+ List<ConsumableorderdetailsInfo> boxRecords = new List<ConsumableorderdetailsInfo>();
+ Map<String, ConsumableorderdetailsInfo> newMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
+ Map<String, ConsumableorderdetailsInfo> newMidPieceMap = new Map<String, ConsumableorderdetailsInfo>();
+ //DB202302357027 娑堣�楀搧杩芥函绯荤粺鏃犳硶姝e父浣跨敤鈥斺�旂洏鐐归〉闈㈡搷浣滃嵆鎶ラ敊 fy start
+ //寮�濮嬪埗浣滆〃澶存暟鎹�
+ // List<Product2__c> productCount_Unfull_bak = [select Id, Name,Name__c,
+ // SFDA_Status__c,Packing_list_manual__c,
+ // Asset_Model_No__c
+ // from Product2__c
+ // //where Estimation_Entry_Possibility__c = '鈼�'
+ // where Product_Type__c like : sqlagencyProType
+ // ];
+ // for(integer i = 0;i < productCount_Unfull_bak.size() ; i++){
+ // midMap.put(productCount_Unfull_bak[i].Id, productCount_Unfull_bak[i]);
// }
- //========20160311======ADD_End==================================
- // BarCode褰曞叆
- @AuraEnabled
- public static ResponseBodyLWC searchConsumableorderdetails(String agencyProType,String userWorkLocation,String accountName,String barcode,String consumableorderdetailsRecordsLWC,Integer pageSizeLWC, Integer pageTokenLWC, String sortFieldLWC, String sortOrderLWC){
- pageSize = pageSizeLWC;
- pageToken = pageTokenLWC;
- sortField = sortFieldLWC;
- sortOrder = sortOrderLWC;
-
- System.debug('===>consumableorderdetailsRecordsLWC'+consumableorderdetailsRecordsLWC);
- List<ConsumableorderdetailsInfo> consumableorderdetailsRecords = (List<ConsumableorderdetailsInfo>)JSON.deserialize(consumableorderdetailsRecordsLWC,List<ConsumableorderdetailsInfo>.class);
- // ConsumableorderdetailsInfo[] consumableorderdetailsRecords=(List<ConsumableorderdetailsInfo>)JSON.deserialize(consumableorderdetailsRecordsLWC,List<ConsumableorderdetailsInfo>.class);
- system.debug('=====>consumableorderdetailsRecordsLWC'+consumableorderdetailsRecordsLWC);
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String,object> data = new Map<String,object>();
- res.entity = data;
-
- sqlagencyProType = '%' + agencyProType + '%';
-
-
-
-
- /* BarCodelist鍋氭垚 */
- //FIXME barcodeSet 鍋氭垚锛孭roductCount_ResSet 鍋氭垚
- List<Consumable_order_details2__c> pandiandetailsList = new List<Consumable_order_details2__c>();
- pandiandetailsListShow = new List<List<Consumable_order_details2__c>>();
- done = false;
- List<String> BarCodeListP = ParseBarCode( barcode );
- //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨
- List<Consumable_order_details2__c> ProductCount_Res = [select Id, Name,Consumable_Product__c,
- Bar_Code__c,Consumable_Product__r.Name__c,Dealer_Info_text__c,
- Asset_Model_No__c,Isoverdue__c,Box_Piece__c,
- Bar_Code_search__c
- 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 Lose_Flag__c = false
- AND Cancellation_Flag__c = false
- AND Bar_Code__c !=null
- AND Product_Type__c like : sqlagencyProType
- AND Arrive_Owner_Work_Location__c =: userWorkLocation
- AND Dealer_Info_text__c = :accountName ];
- reFindProduct.clear();
- Map<String,ConsumableorderdetailsInfo> barCodeListAdjustMap = new Map<String,ConsumableorderdetailsInfo>();
- //barCodeListLoseMap.clear();
- Set<String> carCodeListLose = new Set<String>();
- List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsAdjust = new List<ConsumableorderdetailsInfo>();
- Map<String,String> proIdNotinpage = new Map<String,String>();
- List<Consumable_order_details2__c> reFindProductList = new List<Consumable_order_details2__c>();
- codPageRecords = new List<ConsumableorderdetailsInfo>();
- consumableorderdetailsRecordserrordummy = new List<ConsumableorderdetailsInfo>();
- List<ConsumableorderdetailsInfo> reFindProductaddtopage = new List<ConsumableorderdetailsInfo>();
- pandiandetailsMap.clear();
- reSet = new List<Consumable_order_details2__c>();
- /* 鍒ゆ柇BarCode鏄惁涓虹┖ */
- if (barcode == null || barcode == ''){
- //鍏堝彇鍑烘墍鏈変涪澶变骇鍝�
- for(ConsumableorderdetailsInfo ass : consumableorderdetailsRecords){
- // 20200509 gzw add 鐩樼偣鏁伴噺鍒濆鍖�
- ass.Pandian = 0;
- // 20200509 gzw add 鐩樼偣鏁伴噺鍒濆鍖�
- if(ass.check==true){
- //ass.Diff = ass.countid - ass.Pandian;
- for(integer i = 0 ; i < ProductCount_Res.size();i++){
- if(ProductCount_Res[i].Consumable_Product__c == ass.Prod.Id && ass.boxPiece == ProductCount_Res[i].Box_Piece__c){
- if(carCodeListLose.contains(ProductCount_Res[i].Bar_Code__c)){
- continue;
- }else{
-
- //consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(ProductCount_Res[i],'涓㈠け'));
- //pandiandetailsMap.put(ProductCount_Res[i].Id, '涓㈠け');
- ////barCodeListLoseMap.put(ProductCount_Res[i].Id, new ConsumableorderdetailsInfo(ProductCount_Res[i]));
- carCodeListLose.add(ProductCount_Res[i].Bar_Code__c);
- }
- }
- }
- }
- }
-
- //宸茬粡鍑哄簱鐨勪骇鍝�
- List<Consumable_order_details2__c> reSet1 = [SELECT Id, Name,Consumable_Product__c,
- Bar_Code__c,Consumable_Product__r.Name__c,
- Asset_Model_No__c,Isoverdue__c,Box_Piece__c,
- Bar_Code_search__c,Dealer_Info_text__c
- FROM Consumable_order_details2__c
- WHERE Dealer_Arrive__c = TRUE
- AND (Dealer_Shipment__c= TRUE
- or Dealer_Saled__c = TRUE)
- AND Dealer_Returned__c = FALSE
- AND Cancellation_Flag__c = FALSE
- AND Bar_Code__c in :carCodeListLose
- AND Dealer_Info_text__c = :accountName
- ORDER BY Name ];
- Map<String,Consumable_order_details2__c> needreturnMap = new Map<String,Consumable_order_details2__c>();
- for(Consumable_order_details2__c cod2 :reSet1){
- needreturnMap.put(cod2.Bar_Code__c,cod2);
- }
-
- // 缁忛攢鍟嗕箣闂存垨鑰呭悓涓�缁忛攢鍟嗕笉鍚屽伐浣滃湴璋冭揣
- reSet1 = [SELECT Id, Name,Consumable_Product__c,
- Bar_Code__c,Consumable_Product__r.Name__c,
- Asset_Model_No__c,Isoverdue__c,Box_Piece__c,
- Bar_Code_search__c,Dealer_Info_text__c
- 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 :carCodeListLose
- AND (Dealer_Info_text__c != :accountName
- OR (Dealer_Info_text__c = :accountName
- AND Arrive_Owner_Work_Location__c != :userWorkLocation)
- )
- ORDER BY Name ];
- Map<String,Consumable_order_details2__c> otherAgProMap = new Map<String,Consumable_order_details2__c>();
- for(Consumable_order_details2__c cod2 :reSet1){
- otherAgProMap.put(cod2.Bar_Code__c,cod2);
- }
- carCodeListLose.clear();
-
-
- for(ConsumableorderdetailsInfo ass : consumableorderdetailsRecords){
- if(ass.check==true){
- ass.Diff = ass.countid - ass.Pandian;
- for(integer i = 0 ; i < ProductCount_Res.size();i++){
- if(ProductCount_Res[i].Consumable_Product__c == ass.Prod.Id && ass.boxPiece == ProductCount_Res[i].Box_Piece__c){
- if(carCodeListLose.contains(ProductCount_Res[i].Bar_Code_search__c)){
- continue;
- }else{
- if(needreturnMap.containsKey(ProductCount_Res[i].Bar_Code__c)){
- consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(ProductCount_Res[i],'璇ヤ骇鍝佹湭杩斿搧'));
- pandiandetailsMap.put(ProductCount_Res[i].Id, '璇ヤ骇鍝佹湭杩斿搧');
- carCodeListLose.add(ProductCount_Res[i].Bar_Code_search__c);
- continue;
-
- }
- if(otherAgProMap.containsKey(ProductCount_Res[i].Bar_Code__c)){
- consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(ProductCount_Res[i],'璇ヤ骇鍝佸綊灞炰簬' + otherAgProMap.get(ProductCount_Res[i].Bar_Code__c).Dealer_Info_text__c + '鐨勫簱瀛樸��'));
- pandiandetailsMap.put(ProductCount_Res[i].Id, '璇ヤ骇鍝佸綊灞炰簬' + otherAgProMap.get(ProductCount_Res[i].Bar_Code__c).Dealer_Info_text__c + '鐨勫簱瀛樸��');
- carCodeListLose.add(ProductCount_Res[i].Bar_Code_search__c);
- continue;
-
- }
- if (ProductCount_Res[i].Isoverdue__c == 0) {
- consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(ProductCount_Res[i],'璇ヤ骇鍝佸凡缁忚繃鏈夋晥鏈燂紝璇烽攢瀛樸��'));
- pandiandetailsMap.put(ProductCount_Res[i].Id, '璇ヤ骇鍝佸凡缁忚繃鏈夋晥鏈燂紝璇烽攢瀛樸��');
- carCodeListLose.add(ProductCount_Res[i].Bar_Code_search__c);
- ass.Diff--;
- continue;
- }
- consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(ProductCount_Res[i],'涓㈠け'));
- pandiandetailsMap.put(ProductCount_Res[i].Id, '涓㈠け');
- carCodeListLose.add(ProductCount_Res[i].Bar_Code_search__c);
- }
- }
- }
- }else{
- ass.Pandian = 0;
- ass.Diff = 0;
- }
- }
- List<Consumable_order_details2__c> showcod2 = new List<Consumable_order_details2__c>();
- if (pandiandetailsMap.keySet().size() > 0) {
- showcod2 = [select Id, Name,Consumable_Product__c,
- Bar_Code__c,Consumable_Product__r.Name__c,
- Asset_Model_No__c,Isoverdue__c,Box_Piece__c,
- Bar_Code_search__c
- FROM Consumable_order_details2__c
- WHERE Id in :pandiandetailsMap.keySet()
- order by Name];
- }
- initStandardController();
- showcod2nid = cod2s();
-
- for (Consumable_order_details2__c cod2 : showcod2nid) {
- codPageRecords.add(new ConsumableorderdetailsInfo(cod2,pandiandetailsMap.get(cod2.Id)));
- }
-
- iSinventory = true;
- if(codPageRecords.size() > 0) done = true;
- consumableorderdetailsRecordserrordummy.clear();
-
- //pandiandetailsList = new list<Consumable_order_details2__c>();
- pandiandetailsList = [select Id, Bar_Code__c,Consumable_Product__r.Name__c,
- Box_Piece__c,Lose_reason__c
- FROM Consumable_order_details2__c
- WHERE Id in :pandiandetailsMap.keySet()
- order by Name];
- for(Consumable_order_details2__c codDet : pandiandetailsList){
- codDet.Lose_reason__c = pandiandetailsMap.get(codDet.Id);
- }
- List<Consumable_order_details2__c> pandiandetailsListMid = new List<Consumable_order_details2__c>();
- for(Consumable_order_details2__c cod2 : pandiandetailsList){
- pandiandetailsListMid.add(cod2);
- if(pandiandetailsListMid.size() == 1000){
- pandiandetailsListShow.add(pandiandetailsListMid);
- pandiandetailsListMid = new List<Consumable_order_details2__c>();
- }
- }
- if(pandiandetailsListMid.size() > 0){
- pandiandetailsListShow.add(pandiandetailsListMid);
- }
-
- //鍒嗛〉
- PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
- totalCount = codPageRecords.size();
- paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount) ? pageToken + pageSize : null;
- paginatedAccounts.recordStart = pageToken + 1;
- paginatedAccounts.pageNumber = pageToken / pageSize + 1;
- Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
- paginatedAccounts.recordEnd = totalCount >= recordEnd ? recordEnd : totalCount;
- paginatedAccounts.totalRecords = totalCount;
-
- Integer startIdx;
- Integer endIdx;
- List<ConsumableorderdetailsInfo> pageCodeRecords = new List<ConsumableorderdetailsInfo>();
- startIdx = pageToken;
- endIdx = startIdx + pageSize;
- if (endIdx > codPageRecords.size()) {
- endIdx = codPageRecords.size();
- }
- for (Integer i = startIdx; i < endIdx; i++) {
- pageCodeRecords.add(codPageRecords.get(i));
- }
-
- data.put('paginatedAccounts', paginatedAccounts);
- data.put('pageCodeRecords', pageCodeRecords);
-
- //end
- data.put('codPageRecords',JSON.serialize(codPageRecords));
- data.put('consumableorderdetailsRecords',JSON.serialize(consumableorderdetailsRecords));
- data.put('consumableorderdetailsRecordsview',JSON.serialize(consumableorderdetailsRecordsview));
- data.put('pandiandetailsMap',pandiandetailsMap);
- System.debug('iSinventory===>'+iSinventory);
- System.debug('codPageRecords===>'+codPageRecords);
- data.put('iSinventory',JSON.serialize(iSinventory));
- data.put('reSet1',reSet1);
- System.debug('reSet1===>'+reSet1);
- res.code = 200;
- res.status = 'Success1';
-
- return res;
-
+ //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨
+ List<Consumable_order_details2__c> ProductCount_Res = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c
+ 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 Lose_Flag__c = FALSE
+ AND Cancellation_Flag__c = FALSE
+ AND Bar_Code__c != NULL
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Dealer_Info_text__c = :accountName
+ ];
+ //DB202302357027 娑堣�楀搧杩芥函绯荤粺鏃犳硶姝e父浣跨敤鈥斺�旂洏鐐归〉闈㈡搷浣滃嵆鎶ラ敊 fy start
+ //寮�濮嬪埗浣滆〃澶存暟鎹�
+ Set<Id> Product2cIdSet = new Set<Id>();
+ for (Consumable_order_details2__c con_or_d2item : ProductCount_Res) {
+ Product2cIdSet.add(con_or_d2item.Consumable_Product__c);
+ }
+ List<Product2__c> productCount_Unfull_bak = [
+ SELECT
+ Id,
+ Name,
+ Name__c,
+ SFDA_Status__c,
+ Packing_list_manual__c,
+ Asset_Model_No__c
+ FROM Product2__c
+ //where Estimation_Entry_Possibility__c = '鈼�'
+ WHERE Id IN :Product2cIdSet AND Product_Type__c LIKE :sqlagencyProType
+ ];
+ for (integer i = 0; i < productCount_Unfull_bak.size(); i++) {
+ midMap.put(productCount_Unfull_bak[i].Id, productCount_Unfull_bak[i]);
+ }
+ system.debug('productCount_Unfull_bak' + productCount_Unfull_bak.size());
+ // String erro='productCount_Unfull_bak:'+productCount_Unfull_bak.size();
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, erro));
+ //DB202302357027 娑堣�楀搧杩芥函绯荤粺鏃犳硶姝e父浣跨敤鈥斺�旂洏鐐归〉闈㈡搷浣滃嵆鎶ラ敊 fy end
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'ProductCount_Res ' + ProductCount_Res.size()));
+ for (Integer i = 0; i < ProductCount_Res.size(); i++) {
+ //鐒跺悗寰幆CountDel鍋欱ox鍜宲iece2涓猰ap
+ if (
+ MidMap.containsKey(ProductCount_Res[i].Consumable_Product__c) &&
+ ProductCount_Res[i].Box_Piece__c == '鐩�'
+ ) {
+ if (
+ newMidBoxMap.containsKey(
+ ProductCount_Res[i].Consumable_Product__c +
+ ProductCount_Res[i].Box_Piece__c
+ )
+ ) {
+ ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(
+ ProductCount_Res[i].Consumable_Product__c +
+ ProductCount_Res[i].Box_Piece__c
+ )
+ .clone();
+ Jstage.countid = Jstage.countid + 1;
+ if (ProductCount_Res[i].Isoverdue__c == 1) {
+ Jstage.limitCount = Jstage.limitCount + 1;
+ }
+ Jstage.boxPiece = ProductCount_Res[i].Box_Piece__c;
+ newMidBoxMap.put(
+ ProductCount_Res[i].Consumable_Product__c +
+ ProductCount_Res[i].Box_Piece__c,
+ Jstage
+ );
+ } else {
+ ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(
+ MidMap.get(ProductCount_Res[i].Consumable_Product__c)
+ );
+ Jstage.countid = Jstage.countid + 1;
+ if (ProductCount_Res[i].Isoverdue__c == 1) {
+ Jstage.limitCount = Jstage.limitCount + 1;
+ }
+ Jstage.boxPiece = ProductCount_Res[i].Box_Piece__c;
+ newMidBoxMap.put(
+ ProductCount_Res[i].Consumable_Product__c +
+ ProductCount_Res[i].Box_Piece__c,
+ Jstage
+ );
}
-
-
-
- //CHAN-B7J4NB 鍙湁涓�涓椂锛岀洏鐐逛笉鍒�
- //init();
- //CHAN-B7J4NB
- Map<String,String> showproductIdMap = new Map<String,String>();
- for(ConsumableorderdetailsInfo ass : consumableorderdetailsRecords){
- showproductIdMap.put(ass.prod.Id + ass.boxPiece, ass.prod.Id + ass.boxPiece);
+ } else if (
+ MidMap.containsKey(ProductCount_Res[i].Consumable_Product__c) &&
+ ProductCount_Res[i].Box_Piece__c == '涓�'
+ ) {
+ if (
+ newMidPieceMap.containsKey(
+ ProductCount_Res[i].Consumable_Product__c +
+ ProductCount_Res[i].Box_Piece__c
+ )
+ ) {
+ ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(
+ ProductCount_Res[i].Consumable_Product__c +
+ ProductCount_Res[i].Box_Piece__c
+ )
+ .clone();
+ Jstage.countid = Jstage.countid + 1;
+ if (ProductCount_Res[i].Isoverdue__c == 1) {
+ Jstage.limitCount = Jstage.limitCount + 1;
+ }
+ Jstage.boxPiece = ProductCount_Res[i].Box_Piece__c;
+ newMidPieceMap.put(
+ ProductCount_Res[i].Consumable_Product__c +
+ ProductCount_Res[i].Box_Piece__c,
+ Jstage
+ );
+ } else {
+ ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(
+ MidMap.get(ProductCount_Res[i].Consumable_Product__c)
+ );
+ Jstage.countid = Jstage.countid + 1;
+ if (ProductCount_Res[i].Isoverdue__c == 1) {
+ Jstage.limitCount = Jstage.limitCount + 1;
+ }
+ Jstage.boxPiece = ProductCount_Res[i].Box_Piece__c;
+ newMidPieceMap.put(
+ ProductCount_Res[i].Consumable_Product__c +
+ ProductCount_Res[i].Box_Piece__c,
+ Jstage
+ );
}
-// ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCodeListP' + BarCodeListP));
- /***************************************************************************/
- // BarCode鐨勬绱� 鎵�鏈夊湪搴�
- reSet = [select Id,Consumable_Product__c,Consumable_Product__r.Name__c,
- Box_Piece__c,Bar_Code_search__c,Isoverdue__c
- from Consumable_order_details2__c
- where Bar_Code_search__c in :BarCodeListP
- AND Dealer_Arrive__c = true
- AND Dealer_Shipment__c = false
- AND Dealer_Saled__c = false
- AND Dealer_Returned__c = false
- AND Lose_Flag__c = false
- AND Cancellation_Date__c = null
- and Bar_Code__c !=null
- AND Product_Type__c like : sqlagencyProType
- AND Arrive_Owner_Work_Location__c =: userWorkLocation
- AND Dealer_Info_text__c = :accountName
- order by Name];
- System.debug('reSet===>'+reSet);
- Map<String, Integer> pandianProdIdCountMap = new Map<String, Integer>(); // ProdId 鍗樹綅
- // 20200509 add gzw 璁板綍闇�瑕侀攢瀛樻暟閲�
- Map<String, Integer> pandianoverdueCountMap = new Map<String, Integer>(); // ProdId 鍗樹綅
- // 20200509 add gzw 璁板綍闇�瑕侀攢瀛樻暟閲�
- Map<String,ConsumableorderdetailsInfo> barCodeListPandianMap = new Map<String,ConsumableorderdetailsInfo>(); // 鏄庣窗銉愩兗銈炽兗銉� 鍗樹綅
- //鐩樼偣鍒扮殑鏄庣粏
- for(Consumable_order_details2__c rs : reSet){
- //BarCodeListPandian.add(rs.Bar_Code_search__c);
- for(ConsumableorderdetailsInfo ass : consumableorderdetailsRecords){
- if(rs.Consumable_Product__c == ass.Prod.Id && rs.Box_Piece__c == ass.boxPiece){
- ass.check = true;
- }
- }
+ }
+ }
+ for (ConsumableorderdetailsInfo bss : newMidBoxMap.values()) {
+ bss.overlimitCount = bss.countid - bss.limitCount;
+ boxRecords.add(bss);
+ }
+ boxRecords.sort();
+ for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
+ bss.overlimitCount = bss.countid - bss.limitCount;
+ }
+ for (ConsumableorderdetailsInfo bss : boxRecords) {
+ consumableorderdetailsRecords.add(bss);
+ if (newMidPieceMap.containsKey(bss.Prod.Id + '涓�')) {
+ consumableorderdetailsRecords.add(
+ newMidPieceMap.get(bss.Prod.Id + '涓�')
+ );
+ //newMidPieceMap绉婚櫎宸茬粡娣诲姞鐨凱iece
+ newMidPieceMap.remove(bss.Prod.Id + '涓�');
+ }
+ }
+ for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
+ consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓�'));
+ }
+ //consumableorderdetailsCount = consumableorderdetailsRecords.size();
+ listCut();
- barCodeListPandianMap.put(rs.Bar_Code_search__c, new ConsumableorderdetailsInfo(rs));
- if (rs.Isoverdue__c == 0) {
- consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(rs,'璇ヤ骇鍝佸凡缁忚繃鏈夋晥鏈燂紝璇烽攢瀛樸��'));
- pandiandetailsMap.put(rs.Id, '璇ヤ骇鍝佸凡缁忚繃鏈夋晥鏈燂紝璇烽攢瀛樸��');
- if (pandianoverdueCountMap.containsKey(rs.Consumable_product__c + rs.Box_Piece__c) == false) {
- pandianoverdueCountMap.put(rs.Consumable_Product__c + rs.Box_Piece__c, 1);
- } else {
- pandianoverdueCountMap.put(rs.Consumable_Product__c + rs.Box_Piece__c, pandianoverdueCountMap.get(rs.Consumable_Product__c + rs.Box_Piece__c) + 1);
- }
+ data.put(
+ 'ConsumableorderdetailsRecordsview',
+ JSON.serialize(ConsumableorderdetailsRecordsview)
+ );
+ data.put('userWorkLocation', userWorkLocation);
+ data.put('agencyProType', agencyProType);
+ data.put('accountName', accountName);
+ data.put('accountid', accountid);
+
+ data.put(
+ 'consumableorderdetailsRecords',
+ JSON.serialize(consumableorderdetailsRecords)
+ );
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ private static void listCut() {
+ //鎷嗗垎鏆傜敤list
+ 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 (consumableorderdetailsRecords.size() > 1000) {
+ for (Integer i = 0; i < consumableorderdetailsRecords.size(); i++) {
+ if (i < 1000) {
+ c = consumableorderdetailsRecords.get(i);
+ ConsumableorderdetailsRecordsbreak.add(c);
+ } else {
+ c = consumableorderdetailsRecords.get(i);
+ ConsumableorderdetailsRecordsbreakover.add(c);
+ }
+ }
+ consumableorderdetailsRecordsview.add(ConsumableorderdetailsRecordsbreak);
+ consumableorderdetailsRecordsview.add(
+ ConsumableorderdetailsRecordsbreakover
+ );
+ } else {
+ consumableorderdetailsRecordsview.add(consumableorderdetailsRecords);
+ }
+ }
+ //========20160311======ADD_Start================================
+ // 灏嗛〉闈㈡垨鍙栧緱BarCode鍘绘帀閲嶅鐨勶紝杞崲鎴怢ist
+ //========20160311======ADD_Start================================
+ public static List<String> ParseBarCode(String Code) {
+ Map<String, Integer> barcodeCountMap = new Map<String, Integer>();
+ String[] Cache = new List<String>{};
+ Cache = Code.split('\n');
+ List<String> Buff = new List<String>();
+ for (String A : Cache) {
+ A = A.trim().toUpperCase();
+ if (barcodeCountMap.containsKey(A)) {
+ barcodeCountMap.put(A, barcodeCountMap.get(A) + 1);
+ } else {
+ barcodeCountMap.put(A, 1);
+ }
+ Buff.add(A + barcodeCountMap.get(A));
+ }
+ return Buff;
+ }
+
+ //test
+
+ // @AuraEnabled
+ // public static ResponseBodyLWC searchConsumableorderdetails(String sqlagencyProType,String userWorkLocation,String accountName,String barcode,List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsLWC){
+ // return new ResponseBodyLWC('Error',500, 'test', '');
+ // }
+ //========20160311======ADD_End==================================
+ // BarCode褰曞叆
+ @AuraEnabled
+ public static ResponseBodyLWC searchConsumableorderdetails(
+ String agencyProType,
+ String userWorkLocation,
+ String accountName,
+ String barcode,
+ String consumableorderdetailsRecordsLWC,
+ Integer pageSizeLWC,
+ Integer pageTokenLWC,
+ String sortFieldLWC,
+ String sortOrderLWC
+ ) {
+ pageSize = pageSizeLWC;
+ pageToken = pageTokenLWC;
+ sortField = sortFieldLWC;
+ sortOrder = sortOrderLWC;
+
+ System.debug(
+ '===>consumableorderdetailsRecordsLWC' + consumableorderdetailsRecordsLWC
+ );
+ List<ConsumableorderdetailsInfo> consumableorderdetailsRecords = (List<ConsumableorderdetailsInfo>) JSON.deserialize(
+ consumableorderdetailsRecordsLWC,
+ List<ConsumableorderdetailsInfo>.class
+ );
+ // ConsumableorderdetailsInfo[] consumableorderdetailsRecords=(List<ConsumableorderdetailsInfo>)JSON.deserialize(consumableorderdetailsRecordsLWC,List<ConsumableorderdetailsInfo>.class);
+ system.debug(
+ '=====>consumableorderdetailsRecordsLWC' +
+ consumableorderdetailsRecordsLWC
+ );
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ sqlagencyProType = '%' + agencyProType + '%';
+ System.debug('sqlagencyProType==>' + sqlagencyProType);
+ System.debug('accountName==>' + accountName);
+ System.debug('userWorkLocation==>' + userWorkLocation);
+
+ /* BarCodelist鍋氭垚 */
+ //FIXME barcodeSet 鍋氭垚锛孭roductCount_ResSet 鍋氭垚
+ List<Consumable_order_details2__c> pandiandetailsList = new List<Consumable_order_details2__c>();
+ pandiandetailsListShow = new List<List<Consumable_order_details2__c>>();
+ done = false;
+ List<String> BarCodeListP = ParseBarCode(barcode);
+ System.debug('BarCodeListP===>' + BarCodeListP);
+ //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨
+ List<Consumable_order_details2__c> ProductCount_Res = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Dealer_Info_text__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ Bar_Code_search__c
+ 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 Lose_Flag__c = FALSE
+ AND Cancellation_Flag__c = FALSE
+ AND Bar_Code__c != NULL
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Dealer_Info_text__c = :accountName
+ ];
+ System.debug('ProductCount_Res==>' + ProductCount_Res);
+ reFindProduct.clear();
+ Map<String, ConsumableorderdetailsInfo> barCodeListAdjustMap = new Map<String, ConsumableorderdetailsInfo>();
+ //barCodeListLoseMap.clear();
+ Set<String> carCodeListLose = new Set<String>();
+ List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsAdjust = new List<ConsumableorderdetailsInfo>();
+ Map<String, String> proIdNotinpage = new Map<String, String>();
+ List<Consumable_order_details2__c> reFindProductList = new List<Consumable_order_details2__c>();
+ codPageRecords = new List<ConsumableorderdetailsInfo>();
+ consumableorderdetailsRecordserrordummy = new List<ConsumableorderdetailsInfo>();
+ List<ConsumableorderdetailsInfo> reFindProductaddtopage = new List<ConsumableorderdetailsInfo>();
+ pandiandetailsMap.clear();
+ reSet = new List<Consumable_order_details2__c>();
+ /* 鍒ゆ柇BarCode鏄惁涓虹┖ */
+ if (barcode == null || barcode == '') {
+ //鍏堝彇鍑烘墍鏈変涪澶变骇鍝�
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ // 20200509 gzw add 鐩樼偣鏁伴噺鍒濆鍖�
+ ass.Pandian = 0;
+ // 20200509 gzw add 鐩樼偣鏁伴噺鍒濆鍖�
+ if (ass.check == true) {
+ //ass.Diff = ass.countid - ass.Pandian;
+ for (integer i = 0; i < ProductCount_Res.size(); i++) {
+ System.debug('Pro==>' + ProductCount_Res[i].Consumable_Product__c);
+ System.debug('ProId==>' + ass.Prod.Id);
+ System.debug('ass.boxPiece ==>' + ass.boxPiece);
+ System.debug('boxPiece ==>' + ProductCount_Res[i].Box_Piece__c);
+ if (
+ ProductCount_Res[i].Consumable_Product__c == ass.Prod.Id &&
+ ass.boxPiece == ProductCount_Res[i].Box_Piece__c
+ ) {
+ if (carCodeListLose.contains(ProductCount_Res[i].Bar_Code__c)) {
continue;
+ } else {
+ //consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(ProductCount_Res[i],'涓㈠け'));
+ //pandiandetailsMap.put(ProductCount_Res[i].Id, '涓㈠け');
+ ////barCodeListLoseMap.put(ProductCount_Res[i].Id, new ConsumableorderdetailsInfo(ProductCount_Res[i]));
+ carCodeListLose.add(ProductCount_Res[i].Bar_Code__c);
+ }
}
- if (pandianProdIdCountMap.containsKey(rs.Consumable_product__c + rs.Box_Piece__c) == false) {
- pandianProdIdCountMap.put(rs.Consumable_Product__c + rs.Box_Piece__c, 1);
- } else {
- pandianProdIdCountMap.put(rs.Consumable_Product__c + rs.Box_Piece__c, pandianProdIdCountMap.get(rs.Consumable_Product__c + rs.Box_Piece__c) + 1);
- }
+ }
}
+ }
- // 缁忛攢鍟嗕箣闂存垨鑰呭悓涓�缁忛攢鍟嗕笉鍚屽伐浣滃湴璋冭揣
- List<Consumable_order_details2__c> reSet1 = [SELECT Id, Name,Consumable_Product__c,
- Bar_Code__c,Consumable_Product__r.Name__c,Dealer_Shipment__c,Dealer_Saled__c,
- Asset_Model_No__c,Isoverdue__c,Box_Piece__c,Dealer_Arrive__c,
- Bar_Code_search__c,Dealer_Info_text__c
- FROM Consumable_order_details2__c
- WHERE (Dealer_Arrive__c = TRUE
- or Dealer_Shipment__c= TRUE
- or Dealer_Saled__c = TRUE)
- AND Dealer_Returned__c = FALSE
- AND Cancellation_Flag__c = FALSE
- AND Bar_Code_search__c in :BarCodeListP
- AND (Dealer_Info_text__c != :accountName
- OR (Dealer_Info_text__c = :accountName
- AND Arrive_Owner_Work_Location__c != :userWorkLocation)
+ //宸茬粡鍑哄簱鐨勪骇鍝�
+ List<Consumable_order_details2__c> reSet1 = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ Bar_Code_search__c,
+ Dealer_Info_text__c
+ FROM Consumable_order_details2__c
+ WHERE
+ Dealer_Arrive__c = TRUE
+ AND (Dealer_Shipment__c = TRUE
+ OR Dealer_Saled__c = TRUE)
+ AND Dealer_Returned__c = FALSE
+ AND Cancellation_Flag__c = FALSE
+ AND Bar_Code__c IN :carCodeListLose
+ AND Dealer_Info_text__c = :accountName
+ ORDER BY Name
+ ];
+ Map<String, Consumable_order_details2__c> needreturnMap = new Map<String, Consumable_order_details2__c>();
+ for (Consumable_order_details2__c cod2 : reSet1) {
+ needreturnMap.put(cod2.Bar_Code__c, cod2);
+ }
+
+ // 缁忛攢鍟嗕箣闂存垨鑰呭悓涓�缁忛攢鍟嗕笉鍚屽伐浣滃湴璋冭揣
+ reSet1 = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ Bar_Code_search__c,
+ Dealer_Info_text__c
+ 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 :carCodeListLose
+ AND (Dealer_Info_text__c != :accountName
+ OR (Dealer_Info_text__c = :accountName
+ AND Arrive_Owner_Work_Location__c != :userWorkLocation))
+ ORDER BY Name
+ ];
+ Map<String, Consumable_order_details2__c> otherAgProMap = new Map<String, Consumable_order_details2__c>();
+ for (Consumable_order_details2__c cod2 : reSet1) {
+ otherAgProMap.put(cod2.Bar_Code__c, cod2);
+ }
+ carCodeListLose.clear();
+
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ if (ass.check == true) {
+ ass.Diff = ass.countid - ass.Pandian;
+ for (integer i = 0; i < ProductCount_Res.size(); i++) {
+ if (
+ ProductCount_Res[i].Consumable_Product__c == ass.Prod.Id &&
+ ass.boxPiece == ProductCount_Res[i].Box_Piece__c
+ ) {
+ if (
+ carCodeListLose.contains(ProductCount_Res[i].Bar_Code_search__c)
+ ) {
+ continue;
+ } else {
+ if (
+ needreturnMap.containsKey(ProductCount_Res[i].Bar_Code__c)
+ ) {
+ consumableorderdetailsRecordserrordummy.add(
+ new ConsumableorderdetailsInfo(
+ ProductCount_Res[i],
+ '璇ヤ骇鍝佹湭杩斿搧'
)
- ORDER BY Name ];
- Map<String,Consumable_order_details2__c> otherAgProMap = new Map<String,Consumable_order_details2__c>();
- for(Consumable_order_details2__c cod2 :reSet1){
- otherAgProMap.put(cod2.Bar_Code__c,cod2);
- }
- // 闇�瑕佸叆搴撶殑浜у搧
- for(Consumable_order_details2__c cod2 : reSet1){
- for(ConsumableorderdetailsInfo ass : consumableorderdetailsRecords){
- if(cod2.Consumable_Product__c == ass.Prod.Id && cod2.Box_Piece__c == ass.boxPiece){
- ass.check = true;
+ );
+ pandiandetailsMap.put(ProductCount_Res[i].Id, '璇ヤ骇鍝佹湭杩斿搧');
+ carCodeListLose.add(ProductCount_Res[i].Bar_Code_search__c);
+ continue;
}
- }
- if(!showproductIdMap.containsKey(cod2.Consumable_product__c + cod2.Box_Piece__c)){
- reFindProductList.add(cod2);
- proIdNotinpage.put(cod2.Consumable_Product__c, cod2.Box_Piece__c);
- }
- if(!barCodeListPandianMap.containsKey(cod2.Bar_Code_search__c)
- && otherAgProMap.containsKey(cod2.Bar_Code__c)
- && (otherAgProMap.get(cod2.Bar_Code__c).Dealer_Saled__c == true
- || otherAgProMap.get(cod2.Bar_Code__c).Dealer_Shipment__c == true) ){
- consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(cod2,'鏃犳浜у搧鐨勫簱瀛橈紝璇峰叆搴撱��'));
- pandiandetailsMap.put(cod2.Id, '鏃犳浜у搧鐨勫簱瀛橈紝璇峰叆搴撱��');
- }
- }
- //瀵诲洖鏄庣粏
- List<Consumable_order_details2__c> productAdjust = new List<Consumable_order_details2__c>();
- productAdjust = [select Id, Name,Consumable_Product__c,
- Bar_Code__c,Consumable_Product__r.Name__c,Lose_reason__c,
- Asset_Model_No__c,Box_Piece__c,Bar_Code_search__c,Isoverdue__c
- from Consumable_order_details2__c
- where Bar_Code_search__c in :BarCodeListP
- and Bar_Code__c !=null
- and Lose_Flag__c = true
- AND Product_Type__c like : sqlagencyProType
- AND Dealer_Info_text__c = :accountName
- AND Arrive_Owner_Work_Location__c =: userWorkLocation
- order by Name];
-
-
- for (Consumable_order_details2__c rs : productAdjust){
- // 杩囨湡搴撳瓨閿�瀛� 20200427 gzw add srart
- if (rs.Isoverdue__c == 0 || rs.Lose_reason__c == '杩囨湡搴撳瓨閿�瀛�' ) {
- consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(rs,'杩囨湡鎴栬�呴攢瀛樹骇鍝侊紝鏃犳硶瀵诲洖鍏ュ簱'));
- pandiandetailsMap.put(rs.Id, '杩囨湡鎴栬�呴攢瀛樹骇鍝侊紝鏃犳硶瀵诲洖鍏ュ簱');
- carCodeListLose.add(rs.Bar_Code_search__c);
- continue;
- }
- // 杩囨湡搴撳瓨閿�瀛� 20200427 gzw add end
- for(ConsumableorderdetailsInfo ass : consumableorderdetailsRecords){
- if(rs.Consumable_Product__c == ass.Prod.Id && rs.Box_Piece__c == ass.boxPiece){
- ass.check = true;
+ if (
+ otherAgProMap.containsKey(ProductCount_Res[i].Bar_Code__c)
+ ) {
+ consumableorderdetailsRecordserrordummy.add(
+ new ConsumableorderdetailsInfo(
+ ProductCount_Res[i],
+ '璇ヤ骇鍝佸綊灞炰簬' +
+ otherAgProMap.get(ProductCount_Res[i].Bar_Code__c)
+ .Dealer_Info_text__c +
+ '鐨勫簱瀛樸��'
+ )
+ );
+ pandiandetailsMap.put(
+ ProductCount_Res[i].Id,
+ '璇ヤ骇鍝佸綊灞炰簬' +
+ otherAgProMap.get(ProductCount_Res[i].Bar_Code__c)
+ .Dealer_Info_text__c +
+ '鐨勫簱瀛樸��'
+ );
+ carCodeListLose.add(ProductCount_Res[i].Bar_Code_search__c);
+ continue;
}
- }
- if(!showproductIdMap.containsKey(rs.Consumable_product__c + rs.Box_Piece__c)){
- reFindProductList.add(rs);
- proIdNotinpage.put(rs.Consumable_Product__c, rs.Box_Piece__c);
- }
- if(barCodeListAdjustMap.containsKey(rs.Bar_Code_search__c)){
- continue;
- }else{
- barCodeListAdjustMap.put(rs.Bar_Code_search__c, new ConsumableorderdetailsInfo(rs));
- consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(rs,'瀵诲洖'));
- pandiandetailsMap.put(rs.Id, '瀵诲洖');
- consumableorderdetailsRecordsAdjust.add(new ConsumableorderdetailsInfo(rs));
- }
- }
- if(reFindProductList.size() > 0){
- Map<String,Product2__c> midMap = new Map<String,Product2__c>();
- List<ConsumableorderdetailsInfo> boxRecords = new List<ConsumableorderdetailsInfo>();
- Map<String,ConsumableorderdetailsInfo> newMidBoxMap = new Map<String,ConsumableorderdetailsInfo>();
- Map<String,ConsumableorderdetailsInfo> newMidPieceMap = new Map<String,ConsumableorderdetailsInfo>();
- List<Product2__c> product_Refind = [select Id, Name,Name__c,SFDA_Status__c,Packing_list_manual__c,Asset_Model_No__c
- from Product2__c
- WHERE Id in :proIdNotinpage.keySet()];
- for(Product2__c pro : product_Refind){
- midMap.put(pro.Id, pro);
- }
- for(Integer i = 0 ; i< reFindProductList.size();i++){
- //鐒跺悗寰幆CountDel鍋欱ox鍜宲iece2涓猰ap
- if(MidMap.containsKey(reFindProductList[i].Consumable_Product__c) && reFindProductList[i].Box_Piece__c == '鐩�'){
-
- if(newMidBoxMap.containsKey(reFindProductList[i].Consumable_Product__c+reFindProductList[i].Box_Piece__c)){
- ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(reFindProductList[i].Consumable_Product__c+reFindProductList[i].Box_Piece__c).clone();
- Jstage.countid = 0 ;
- if(reFindProductList[i].Isoverdue__c == 1){
- Jstage.limitCount = 0;
- }
- Jstage.boxPiece = reFindProductList[i].Box_Piece__c;
- newMidBoxMap.put(reFindProductList[i].Consumable_Product__c+reFindProductList[i].Box_Piece__c, Jstage);
-}else{
- ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(reFindProductList[i].Consumable_Product__c));
- Jstage.countid = 0 ;
- if(reFindProductList[i].Isoverdue__c == 1){
- Jstage.limitCount = 0;
- }
- Jstage.boxPiece = reFindProductList[i].Box_Piece__c;
- newMidBoxMap.put(reFindProductList[i].Consumable_Product__c+reFindProductList[i].Box_Piece__c, Jstage);
- }
- }else if(MidMap.containsKey(reFindProductList[i].Consumable_Product__c) && reFindProductList[i].Box_Piece__c == '涓�'){
- if(newMidPieceMap.containsKey(reFindProductList[i].Consumable_Product__c+reFindProductList[i].Box_Piece__c)){
- ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(reFindProductList[i].Consumable_product__c+reFindProductList[i].Box_Piece__c).clone();
- Jstage.countid = 0 ;
- if(reFindProductList[i].Isoverdue__c == 1){
- Jstage.limitCount = 0;
- }
- Jstage.boxPiece = reFindProductList[i].Box_Piece__c;
- newMidPieceMap.put(reFindProductList[i].Consumable_Product__c+reFindProductList[i].Box_Piece__c, Jstage);
- }else{
- ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(MidMap.get(reFindProductList[i].Consumable_Product__c));
- Jstage.countid = 0 ;
- if(reFindProductList[i].Isoverdue__c == 1){
- Jstage.limitCount = 0;
- }
- Jstage.boxPiece = reFindProductList[i].Box_Piece__c;
- newMidPieceMap.put(reFindProductList[i].Consumable_Product__c+reFindProductList[i].Box_Piece__c, Jstage);
- }
+ if (ProductCount_Res[i].Isoverdue__c == 0) {
+ consumableorderdetailsRecordserrordummy.add(
+ new ConsumableorderdetailsInfo(
+ ProductCount_Res[i],
+ '璇ヤ骇鍝佸凡缁忚繃鏈夋晥鏈燂紝璇烽攢瀛樸��'
+ )
+ );
+ pandiandetailsMap.put(
+ ProductCount_Res[i].Id,
+ '璇ヤ骇鍝佸凡缁忚繃鏈夋晥鏈燂紝璇烽攢瀛樸��'
+ );
+ carCodeListLose.add(ProductCount_Res[i].Bar_Code_search__c);
+ ass.Diff--;
+ continue;
}
+ consumableorderdetailsRecordserrordummy.add(
+ new ConsumableorderdetailsInfo(ProductCount_Res[i], '涓㈠け')
+ );
+ pandiandetailsMap.put(ProductCount_Res[i].Id, '涓㈠け');
+ carCodeListLose.add(ProductCount_Res[i].Bar_Code_search__c);
+ }
}
- for(ConsumableorderdetailsInfo bss : newMidBoxMap.values()){
- bss.check = true;
- bss.overlimitCount = bss.countid - bss.limitCount;
- boxRecords.add(bss);
- }
- boxRecords.sort();
- for(ConsumableorderdetailsInfo bss : newMidPieceMap.values()){
- bss.check = true;
- bss.overlimitCount = bss.countid - bss.limitCount;
- }
- for(ConsumableorderdetailsInfo bss : boxRecords){
- consumableorderdetailsRecords.add(bss);
- if(newMidPieceMap.containsKey(bss.Prod.Id + '涓�')){
- consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓�'));
- //newMidPieceMap绉婚櫎宸茬粡娣诲姞鐨凱iece
- newMidPieceMap.remove(bss.Prod.Id + '涓�');
- }
- }
- for(ConsumableorderdetailsInfo bss : newMidPieceMap.values()){
- consumableorderdetailsRecords.add(newMidPieceMap.get(bss.Prod.Id + '涓�'));
- }
+ }
+ } else {
+ ass.Pandian = 0;
+ ass.Diff = 0;
}
+ }
+ List<Consumable_order_details2__c> showcod2 = new List<Consumable_order_details2__c>();
+ if (pandiandetailsMap.keySet().size() > 0) {
+ showcod2 = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ Bar_Code_search__c
+ FROM Consumable_order_details2__c
+ WHERE Id IN :pandiandetailsMap.keySet()
+ ORDER BY Name
+ ];
+ }
+ initStandardController();
+ showcod2nid = cod2s();
- //鍏堝彇鍑烘湭鐩樼偣鍒扮殑浜у搧
- for(ConsumableorderdetailsInfo ass : consumableorderdetailsRecords){
- if(ass.check == true){
- for(integer i = 0 ; i<ProductCount_Res.size();i++){
- if(ProductCount_Res[i].Consumable_Product__c == ass.Prod.Id && ass.boxPiece == ProductCount_Res[i].Box_Piece__c){
- if(barCodeListPandianMap.get(ProductCount_Res[i].Bar_Code_search__c) != null){
- continue;
- }else{
- carCodeListLose.add(ProductCount_Res[i].Bar_Code__c);
- ////barCodeListLoseMap.put(ProductCount_Res[i].Id, new ConsumableorderdetailsInfo(ProductCount_Res[i]));
- //consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(ProductCount_Res[i],'涓㈠け'));
- //pandiandetailsMap.put(ProductCount_Res[i].Id, '涓㈠け');
- }
- }
- }
- }
+ for (Consumable_order_details2__c cod2 : showcod2nid) {
+ codPageRecords.add(
+ new ConsumableorderdetailsInfo(cod2, pandiandetailsMap.get(cod2.Id))
+ );
+ }
+
+ iSinventory = true;
+ if (codPageRecords.size() > 0)
+ done = true;
+ consumableorderdetailsRecordserrordummy.clear();
+
+ //pandiandetailsList = new list<Consumable_order_details2__c>();
+ pandiandetailsList = [
+ SELECT
+ Id,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Box_Piece__c,
+ Lose_reason__c
+ FROM Consumable_order_details2__c
+ WHERE Id IN :pandiandetailsMap.keySet()
+ ORDER BY Name
+ ];
+ for (Consumable_order_details2__c codDet : pandiandetailsList) {
+ codDet.Lose_reason__c = pandiandetailsMap.get(codDet.Id);
+ }
+ List<Consumable_order_details2__c> pandiandetailsListMid = new List<Consumable_order_details2__c>();
+ for (Consumable_order_details2__c cod2 : pandiandetailsList) {
+ pandiandetailsListMid.add(cod2);
+ if (pandiandetailsListMid.size() == 1000) {
+ pandiandetailsListShow.add(pandiandetailsListMid);
+ pandiandetailsListMid = new List<Consumable_order_details2__c>();
}
- //宸茬粡鍑哄簱鐨勪骇鍝�
- List<Consumable_order_details2__c> reSet2 = [SELECT Id, Name,Consumable_Product__c,
- Bar_Code__c,Consumable_Product__r.Name__c,
- Asset_Model_No__c,Isoverdue__c,Box_Piece__c,
- Bar_Code_search__c,Dealer_Info_text__c
- FROM Consumable_order_details2__c
- WHERE Dealer_Arrive__c = TRUE
- AND (Dealer_Shipment__c= TRUE
- or Dealer_Saled__c = TRUE)
- AND Dealer_Returned__c = FALSE
- AND Cancellation_Flag__c = FALSE
- AND Bar_Code_search__c in :BarCodeListP
- AND Dealer_Info_text__c = :accountName
- ORDER BY Name ];
- Map<String,Consumable_order_details2__c> needreturnMap = new Map<String,Consumable_order_details2__c>();
- for(Consumable_order_details2__c cod2 :reSet2){
- needreturnMap.put(cod2.Bar_Code__c,cod2);
- }
- //// 缁忛攢鍟嗕箣闂存垨鑰呭悓涓�缁忛攢鍟嗕笉鍚屽伐浣滃湴璋冭揣
- //List<Consumable_order_details2__c> reSet1 = [SELECT Id, Name,Consumable_Product__c,
- // Bar_Code__c,Consumable_Product__r.Name__c,Dealer_Shipment__c,Dealer_Saled__c,
- // Asset_Model_No__c,Isoverdue__c,Box_Piece__c,Dealer_Arrive__c,
- // Bar_Code_search__c,Dealer_Info_text__c
- // FROM Consumable_order_details2__c
- // WHERE (Dealer_Arrive__c = TRUE
- // or Dealer_Shipment__c= TRUE
- // or Dealer_Saled__c = TRUE)
- // AND Dealer_Returned__c = FALSE
- // AND Cancellation_Flag__c = FALSE
- // AND Bar_Code_search__c in :BarCodeListP
- // AND (Dealer_Info_text__c != :accountName
- // OR (Dealer_Info_text__c = :accountName
- // AND Arrive_Owner_Work_Location__c != :userWorkLocation)
- // )
- // ORDER BY Name ];
- //Map<String,Consumable_order_details2__c> otherAgProMap = new Map<String,Consumable_order_details2__c>();
- //for(Consumable_order_details2__c cod2 :reSet1){
- // otherAgProMap.put(cod2.Bar_Code__c,cod2);
- //}
- carCodeListLose.clear();
- //鏈洏鐐瑰埌鐨勪骇鍝�
- for(ConsumableorderdetailsInfo ass : consumableorderdetailsRecords){
- if(ass.check == true){
- for(integer i = 0 ; i<ProductCount_Res.size();i++){
- if(ProductCount_Res[i].Consumable_Product__c == ass.Prod.Id && ass.boxPiece == ProductCount_Res[i].Box_Piece__c){
- if(barCodeListPandianMap.containsKey(ProductCount_Res[i].Bar_Code_search__c)){
- continue;
- }
- if (ProductCount_Res[i].Isoverdue__c == 0) {
- consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(ProductCount_Res[i],'璇ヤ骇鍝佸凡缁忚繃鏈夋晥鏈燂紝璇烽攢瀛樸��'));
- pandiandetailsMap.put(ProductCount_Res[i].Id, '璇ヤ骇鍝佸凡缁忚繃鏈夋晥鏈燂紝璇烽攢瀛樸��');
- if (pandianoverdueCountMap.containsKey(ProductCount_Res[i].Consumable_product__c + ProductCount_Res[i].Box_Piece__c) == false) {
- pandianoverdueCountMap.put(ProductCount_Res[i].Consumable_Product__c + ProductCount_Res[i].Box_Piece__c, 1);
- } else {
- pandianoverdueCountMap.put(ProductCount_Res[i].Consumable_Product__c + ProductCount_Res[i].Box_Piece__c, pandianoverdueCountMap.get(ProductCount_Res[i].Consumable_Product__c + ProductCount_Res[i].Box_Piece__c) + 1);
- }
- continue;
- }
+ }
+ if (pandiandetailsListMid.size() > 0) {
+ pandiandetailsListShow.add(pandiandetailsListMid);
+ }
- consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(ProductCount_Res[i],'涓㈠け'));
- pandiandetailsMap.put(ProductCount_Res[i].Id, '涓㈠け');
- }
- }
- // 鍚屾椂瀛樺湪鍏朵粬缁忛攢鍟嗗簱瀛樹骇鍝�
- for(Consumable_order_details2__c cod2 : reSet1){
- if(cod2.Consumable_Product__c == ass.Prod.Id && ass.boxPiece == cod2.Box_Piece__c){
- if(barCodeListPandianMap.containsKey(cod2.Bar_Code_search__c)
- && otherAgProMap.containsKey(cod2.Bar_Code__c)
- && otherAgProMap.get(cod2.Bar_Code__c).Dealer_Saled__c == false
- && otherAgProMap.get(cod2.Bar_Code__c).Dealer_Shipment__c == false ){
- consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(cod2,'璇ヤ骇鍝佸綊灞炰簬' + otherAgProMap.get(cod2.Bar_Code__c).Dealer_Info_text__c + '鐨勫簱瀛樸��'));
- pandiandetailsMap.put(cod2.Id, '璇ヤ骇鍝佸綊灞炰簬' + otherAgProMap.get(cod2.Bar_Code__c).Dealer_Info_text__c + '鐨勫簱瀛樸��');
- continue;
- }
- }
- }
- // 闇�瑕佽繑鍝佺殑浜у搧
- for(Consumable_order_details2__c cod2 : reSet2){
- if(cod2.Consumable_Product__c == ass.Prod.Id && ass.boxPiece == cod2.Box_Piece__c){
- if(needreturnMap.containsKey(cod2.Bar_Code__c)){
- consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(cod2,'璇ヤ骇鍝佺洰鍓嶅嚭搴撶姸鎬侊紝璇疯繑鍝併��'));
- pandiandetailsMap.put(cod2.Id, '璇ヤ骇鍝佺洰鍓嶅嚭搴撶姸鎬侊紝璇疯繑鍝併��');
- continue;
- }
- }
- }
- }
- }
+ //鍒嗛〉
+ PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
+ totalCount = codPageRecords.size();
+ paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount)
+ ? pageToken + pageSize
+ : null;
+ paginatedAccounts.recordStart = pageToken + 1;
+ paginatedAccounts.pageNumber = pageToken / pageSize + 1;
+ Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
+ paginatedAccounts.recordEnd = totalCount >= recordEnd
+ ? recordEnd
+ : totalCount;
+ paginatedAccounts.totalRecords = totalCount;
- //鏇存柊涓绘槑缁嗗崟
- if(barCodeListPandianMap.size() > 0){
- for(ConsumableorderdetailsInfo ass : consumableorderdetailsRecords){
- if(ass.check == true){
- integer countSum = 0;
- if (pandianProdIdCountMap.containsKey(ass.Prod.Id + ass.boxPiece)) {
- countSum = pandianProdIdCountMap.get(ass.Prod.Id + ass.boxPiece);
- }
- integer overdueSum = 0;
- if (pandianoverdueCountMap.containsKey(ass.Prod.Id + ass.boxPiece)) {
- overdueSum = pandianoverdueCountMap.get(ass.Prod.Id + ass.boxPiece);
- }
- ass.Pandian = countSum;
- ass.Diff = ass.countid - countSum - overdueSum;
- ass.refind = 0;
- }
- }
- }else{
- for(ConsumableorderdetailsInfo ass : consumableorderdetailsRecords){
- if(ass.check == true){
- integer overdueSum = 0;
- if (pandianoverdueCountMap.containsKey(ass.Prod.Id + ass.boxPiece)) {
- overdueSum = pandianoverdueCountMap.get(ass.Prod.Id + ass.boxPiece);
- }
- ass.Diff = ass.countid - ass.Pandian - overdueSum;
- }
- }
- }
+ Integer startIdx;
+ Integer endIdx;
+ List<ConsumableorderdetailsInfo> pageCodeRecords = new List<ConsumableorderdetailsInfo>();
+ startIdx = pageToken;
+ endIdx = startIdx + pageSize;
+ if (endIdx > codPageRecords.size()) {
+ endIdx = codPageRecords.size();
+ }
+ for (Integer i = startIdx; i < endIdx; i++) {
+ pageCodeRecords.add(codPageRecords.get(i));
+ }
+ data.put('paginatedAccounts', paginatedAccounts);
+ data.put('pageCodeRecords', pageCodeRecords);
- //瀵诲洖鍋氭垚
- for(ConsumableorderdetailsInfo ass :consumableorderdetailsRecords){
- for(ConsumableorderdetailsInfo adjust :consumableorderdetailsRecordsAdjust){
- if(ass.Prod.Name__c == adjust.Prod.Name__c && ass.boxPiece == adjust.orderdetails2.Box_Piece__c){
- if(reFindProduct.containsKey(adjust.orderdetails2.Bar_Code_search__c)){
- continue;
- }else {
- ass.Pandian ++;
- ass.refind ++;
- reFindProduct.put(adjust.orderdetails2.Bar_Code_search__c,adjust.orderdetails2.Bar_Code_search__c);
- }
- }
- }
- }
- if (pandiandetailsMap.keySet().size() > 0) {
- List<Consumable_order_details2__c> showcod2 = [select Id, Name,Consumable_Product__c,
- Bar_Code__c,Consumable_Product__r.Name__c,
- Asset_Model_No__c,Isoverdue__c,Box_Piece__c,
- Bar_Code_search__c
- FROM Consumable_order_details2__c
- WHERE Id in :pandiandetailsMap.keySet()
- order by Name];
- initStandardController();
- showcod2nid = cod2s();
+ //end
+ data.put('codPageRecords', JSON.serialize(codPageRecords));
+ data.put(
+ 'consumableorderdetailsRecords',
+ JSON.serialize(consumableorderdetailsRecords)
+ );
+ data.put(
+ 'consumableorderdetailsRecordsview',
+ JSON.serialize(consumableorderdetailsRecordsview)
+ );
+ data.put('pandiandetailsMap', pandiandetailsMap);
+ System.debug('iSinventory===>' + iSinventory);
+ System.debug('codPageRecords===>' + codPageRecords);
+ data.put('iSinventory', JSON.serialize(iSinventory));
+ data.put('reSet1', reSet1);
+ System.debug('reSet1===>' + reSet1);
+ res.code = 200;
+ res.status = 'Success1';
- }
- for (Consumable_order_details2__c cod2 : showcod2nid) {
- codPageRecords.add(new ConsumableorderdetailsInfo(cod2,pandiandetailsMap.get(cod2.Id)));
- }
- if(codPageRecords.size() > 0) done = true;
- iSinventory = true;
- consumableorderdetailsRecordserrordummy.clear();
- pandiandetailsList = [select Id, Bar_Code__c,Consumable_Product__r.Name__c,
- Box_Piece__c,Lose_reason__c
- FROM Consumable_order_details2__c
- WHERE Id in :pandiandetailsMap.keySet()
- order by Name];
- for(Consumable_order_details2__c codDet : pandiandetailsList){
- codDet.Lose_reason__c = pandiandetailsMap.get(codDet.Id);
- }
- List<Consumable_order_details2__c> pandiandetailsListMid = new List<Consumable_order_details2__c>();
- for(Consumable_order_details2__c cod2 : pandiandetailsList){
- pandiandetailsListMid.add(cod2);
- if(pandiandetailsListMid.size() == 1000){
- pandiandetailsListShow.add(pandiandetailsListMid);
- pandiandetailsListMid = new List<Consumable_order_details2__c>();
- }
- }
- if(pandiandetailsListMid.size() > 0){
- pandiandetailsListShow.add(pandiandetailsListMid);
- }
- //鍒嗛〉
- PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
- totalCount = codPageRecords.size();
- paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount) ? pageToken + pageSize : null;
- paginatedAccounts.recordStart = pageToken + 1;
- paginatedAccounts.pageNumber = pageToken / pageSize + 1;
- Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
- paginatedAccounts.recordEnd = totalCount >= recordEnd ? recordEnd : totalCount;
- paginatedAccounts.totalRecords = totalCount;
-
- Integer startIdx;
- Integer endIdx;
- List<ConsumableorderdetailsInfo> pageCodeRecords = new List<ConsumableorderdetailsInfo>();
- startIdx = pageToken;
- endIdx = startIdx + pageSize;
- if (endIdx > codPageRecords.size()) {
- endIdx = codPageRecords.size();
- }
- for (Integer i = startIdx; i < endIdx; i++) {
- pageCodeRecords.add(codPageRecords.get(i));
- }
-
- data.put('paginatedAccounts', paginatedAccounts);
- data.put('pageCodeRecords', pageCodeRecords);
-
- //end
-
- System.debug('=====>codPageRecords2'+codPageRecords);
- System.debug('=====>consumableorderdetailsRecords'+consumableorderdetailsRecords);
- data.put('codPageRecords',JSON.serialize(codPageRecords));
- data.put('consumableorderdetailsRecords',JSON.serialize(consumableorderdetailsRecords));
- System.debug('iSinventory===>'+iSinventory);
- data.put('iSinventory',JSON.serialize(iSinventory));
- System.debug('pandiandetailsMap===>'+pandiandetailsMap);
- data.put('pandiandetailsMap',pandiandetailsMap);
- data.put('reSet',reSet);
- data.put('consumableorderdetailsRecordsview',JSON.serialize(consumableorderdetailsRecordsview));
- System.debug('=====>consumableorderdetailsRecordsview'+consumableorderdetailsRecordsview);
- res.code = 200;
- res.status = 'Sucess';
- return res;
+ return res;
}
-
- // 淇濆瓨鎸夐挳
+
+ //CHAN-B7J4NB 鍙湁涓�涓椂锛岀洏鐐逛笉鍒�
+ //init();
+ //CHAN-B7J4NB
+ Map<String, String> showproductIdMap = new Map<String, String>();
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ showproductIdMap.put(
+ ass.prod.Id + ass.boxPiece,
+ ass.prod.Id + ass.boxPiece
+ );
+ }
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCodeListP' + BarCodeListP));
+ /***************************************************************************/
+ // BarCode鐨勬绱� 鎵�鏈夊湪搴�
+ reSet = [
+ SELECT
+ Id,
+ Consumable_Product__c,
+ Consumable_Product__r.Name__c,
+ Box_Piece__c,
+ Bar_Code_search__c,
+ Isoverdue__c
+ FROM Consumable_order_details2__c
+ WHERE
+ Bar_Code_search__c IN :BarCodeListP
+ AND Dealer_Arrive__c = TRUE
+ AND Dealer_Shipment__c = FALSE
+ AND Dealer_Saled__c = FALSE
+ AND Dealer_Returned__c = FALSE
+ AND Lose_Flag__c = FALSE
+ AND Cancellation_Date__c = NULL
+ AND Bar_Code__c != NULL
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Dealer_Info_text__c = :accountName
+ ORDER BY Name
+ ];
+ System.debug('reSet===>' + reSet);
+ Map<String, Integer> pandianProdIdCountMap = new Map<String, Integer>(); // ProdId 鍗樹綅
+ // 20200509 add gzw 璁板綍闇�瑕侀攢瀛樻暟閲�
+ Map<String, Integer> pandianoverdueCountMap = new Map<String, Integer>(); // ProdId 鍗樹綅
+ // 20200509 add gzw 璁板綍闇�瑕侀攢瀛樻暟閲�
+ Map<String, ConsumableorderdetailsInfo> barCodeListPandianMap = new Map<String, ConsumableorderdetailsInfo>(); // 鏄庣窗銉愩兗銈炽兗銉� 鍗樹綅
+ //鐩樼偣鍒扮殑鏄庣粏
+ for (Consumable_order_details2__c rs : reSet) {
+ //BarCodeListPandian.add(rs.Bar_Code_search__c);
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ if (
+ rs.Consumable_Product__c == ass.Prod.Id &&
+ rs.Box_Piece__c == ass.boxPiece
+ ) {
+ ass.check = true;
+ }
+ }
+
+ barCodeListPandianMap.put(
+ rs.Bar_Code_search__c,
+ new ConsumableorderdetailsInfo(rs)
+ );
+ if (rs.Isoverdue__c == 0) {
+ consumableorderdetailsRecordserrordummy.add(
+ new ConsumableorderdetailsInfo(rs, '璇ヤ骇鍝佸凡缁忚繃鏈夋晥鏈燂紝璇烽攢瀛樸��')
+ );
+ pandiandetailsMap.put(rs.Id, '璇ヤ骇鍝佸凡缁忚繃鏈夋晥鏈燂紝璇烽攢瀛樸��');
+ if (
+ pandianoverdueCountMap.containsKey(
+ rs.Consumable_product__c + rs.Box_Piece__c
+ ) == false
+ ) {
+ pandianoverdueCountMap.put(
+ rs.Consumable_Product__c + rs.Box_Piece__c,
+ 1
+ );
+ } else {
+ pandianoverdueCountMap.put(
+ rs.Consumable_Product__c + rs.Box_Piece__c,
+ pandianoverdueCountMap.get(
+ rs.Consumable_Product__c + rs.Box_Piece__c
+ ) + 1
+ );
+ }
+ continue;
+ }
+ if (
+ pandianProdIdCountMap.containsKey(
+ rs.Consumable_product__c + rs.Box_Piece__c
+ ) == false
+ ) {
+ pandianProdIdCountMap.put(
+ rs.Consumable_Product__c + rs.Box_Piece__c,
+ 1
+ );
+ } else {
+ pandianProdIdCountMap.put(
+ rs.Consumable_Product__c + rs.Box_Piece__c,
+ pandianProdIdCountMap.get(
+ rs.Consumable_Product__c + rs.Box_Piece__c
+ ) + 1
+ );
+ }
+ }
+
+ // 缁忛攢鍟嗕箣闂存垨鑰呭悓涓�缁忛攢鍟嗕笉鍚屽伐浣滃湴璋冭揣
+ List<Consumable_order_details2__c> reSet1 = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Dealer_Shipment__c,
+ Dealer_Saled__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ Dealer_Arrive__c,
+ Bar_Code_search__c,
+ Dealer_Info_text__c
+ FROM Consumable_order_details2__c
+ WHERE
+ (Dealer_Arrive__c = TRUE
+ OR Dealer_Shipment__c = TRUE
+ OR Dealer_Saled__c = TRUE)
+ AND Dealer_Returned__c = FALSE
+ AND Cancellation_Flag__c = FALSE
+ AND Bar_Code_search__c IN :BarCodeListP
+ AND (Dealer_Info_text__c != :accountName
+ OR (Dealer_Info_text__c = :accountName
+ AND Arrive_Owner_Work_Location__c != :userWorkLocation))
+ ORDER BY Name
+ ];
+ Map<String, Consumable_order_details2__c> otherAgProMap = new Map<String, Consumable_order_details2__c>();
+ for (Consumable_order_details2__c cod2 : reSet1) {
+ otherAgProMap.put(cod2.Bar_Code__c, cod2);
+ }
+ // 闇�瑕佸叆搴撶殑浜у搧
+ for (Consumable_order_details2__c cod2 : reSet1) {
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ if (
+ cod2.Consumable_Product__c == ass.Prod.Id &&
+ cod2.Box_Piece__c == ass.boxPiece
+ ) {
+ ass.check = true;
+ }
+ }
+ if (
+ !showproductIdMap.containsKey(
+ cod2.Consumable_product__c + cod2.Box_Piece__c
+ )
+ ) {
+ reFindProductList.add(cod2);
+ proIdNotinpage.put(cod2.Consumable_Product__c, cod2.Box_Piece__c);
+ }
+ if (
+ !barCodeListPandianMap.containsKey(cod2.Bar_Code_search__c) &&
+ otherAgProMap.containsKey(cod2.Bar_Code__c) &&
+ (otherAgProMap.get(cod2.Bar_Code__c).Dealer_Saled__c == true ||
+ otherAgProMap.get(cod2.Bar_Code__c).Dealer_Shipment__c == true)
+ ) {
+ consumableorderdetailsRecordserrordummy.add(
+ new ConsumableorderdetailsInfo(cod2, '鏃犳浜у搧鐨勫簱瀛橈紝璇峰叆搴撱��')
+ );
+ pandiandetailsMap.put(cod2.Id, '鏃犳浜у搧鐨勫簱瀛橈紝璇峰叆搴撱��');
+ }
+ }
+ //瀵诲洖鏄庣粏
+ List<Consumable_order_details2__c> productAdjust = new List<Consumable_order_details2__c>();
+ productAdjust = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Lose_reason__c,
+ Asset_Model_No__c,
+ Box_Piece__c,
+ Bar_Code_search__c,
+ Isoverdue__c
+ FROM Consumable_order_details2__c
+ WHERE
+ Bar_Code_search__c IN :BarCodeListP
+ AND Bar_Code__c != NULL
+ AND Lose_Flag__c = TRUE
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Dealer_Info_text__c = :accountName
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ ORDER BY Name
+ ];
+
+ for (Consumable_order_details2__c rs : productAdjust) {
+ // 杩囨湡搴撳瓨閿�瀛� 20200427 gzw add srart
+ if (rs.Isoverdue__c == 0 || rs.Lose_reason__c == '杩囨湡搴撳瓨閿�瀛�') {
+ consumableorderdetailsRecordserrordummy.add(
+ new ConsumableorderdetailsInfo(rs, '杩囨湡鎴栬�呴攢瀛樹骇鍝侊紝鏃犳硶瀵诲洖鍏ュ簱')
+ );
+ pandiandetailsMap.put(rs.Id, '杩囨湡鎴栬�呴攢瀛樹骇鍝侊紝鏃犳硶瀵诲洖鍏ュ簱');
+ carCodeListLose.add(rs.Bar_Code_search__c);
+ continue;
+ }
+ // 杩囨湡搴撳瓨閿�瀛� 20200427 gzw add end
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ if (
+ rs.Consumable_Product__c == ass.Prod.Id &&
+ rs.Box_Piece__c == ass.boxPiece
+ ) {
+ ass.check = true;
+ }
+ }
+ if (
+ !showproductIdMap.containsKey(
+ rs.Consumable_product__c + rs.Box_Piece__c
+ )
+ ) {
+ reFindProductList.add(rs);
+ proIdNotinpage.put(rs.Consumable_Product__c, rs.Box_Piece__c);
+ }
+ if (barCodeListAdjustMap.containsKey(rs.Bar_Code_search__c)) {
+ continue;
+ } else {
+ barCodeListAdjustMap.put(
+ rs.Bar_Code_search__c,
+ new ConsumableorderdetailsInfo(rs)
+ );
+ consumableorderdetailsRecordserrordummy.add(
+ new ConsumableorderdetailsInfo(rs, '瀵诲洖')
+ );
+ pandiandetailsMap.put(rs.Id, '瀵诲洖');
+ consumableorderdetailsRecordsAdjust.add(
+ new ConsumableorderdetailsInfo(rs)
+ );
+ }
+ }
+ if (reFindProductList.size() > 0) {
+ Map<String, Product2__c> midMap = new Map<String, Product2__c>();
+ List<ConsumableorderdetailsInfo> boxRecords = new List<ConsumableorderdetailsInfo>();
+ Map<String, ConsumableorderdetailsInfo> newMidBoxMap = new Map<String, ConsumableorderdetailsInfo>();
+ Map<String, ConsumableorderdetailsInfo> newMidPieceMap = new Map<String, ConsumableorderdetailsInfo>();
+ List<Product2__c> product_Refind = [
+ SELECT
+ Id,
+ Name,
+ Name__c,
+ SFDA_Status__c,
+ Packing_list_manual__c,
+ Asset_Model_No__c
+ FROM Product2__c
+ WHERE Id IN :proIdNotinpage.keySet()
+ ];
+ for (Product2__c pro : product_Refind) {
+ midMap.put(pro.Id, pro);
+ }
+ for (Integer i = 0; i < reFindProductList.size(); i++) {
+ //鐒跺悗寰幆CountDel鍋欱ox鍜宲iece2涓猰ap
+ if (
+ MidMap.containsKey(reFindProductList[i].Consumable_Product__c) &&
+ reFindProductList[i].Box_Piece__c == '鐩�'
+ ) {
+ if (
+ newMidBoxMap.containsKey(
+ reFindProductList[i].Consumable_Product__c +
+ reFindProductList[i].Box_Piece__c
+ )
+ ) {
+ ConsumableorderdetailsInfo Jstage = newMidBoxMap.get(
+ reFindProductList[i].Consumable_Product__c +
+ reFindProductList[i].Box_Piece__c
+ )
+ .clone();
+ Jstage.countid = 0;
+ if (reFindProductList[i].Isoverdue__c == 1) {
+ Jstage.limitCount = 0;
+ }
+ Jstage.boxPiece = reFindProductList[i].Box_Piece__c;
+ newMidBoxMap.put(
+ reFindProductList[i].Consumable_Product__c +
+ reFindProductList[i].Box_Piece__c,
+ Jstage
+ );
+ } else {
+ ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(
+ MidMap.get(reFindProductList[i].Consumable_Product__c)
+ );
+ Jstage.countid = 0;
+ if (reFindProductList[i].Isoverdue__c == 1) {
+ Jstage.limitCount = 0;
+ }
+ Jstage.boxPiece = reFindProductList[i].Box_Piece__c;
+ newMidBoxMap.put(
+ reFindProductList[i].Consumable_Product__c +
+ reFindProductList[i].Box_Piece__c,
+ Jstage
+ );
+ }
+ } else if (
+ MidMap.containsKey(reFindProductList[i].Consumable_Product__c) &&
+ reFindProductList[i].Box_Piece__c == '涓�'
+ ) {
+ if (
+ newMidPieceMap.containsKey(
+ reFindProductList[i].Consumable_Product__c +
+ reFindProductList[i].Box_Piece__c
+ )
+ ) {
+ ConsumableorderdetailsInfo Jstage = newMidPieceMap.get(
+ reFindProductList[i].Consumable_product__c +
+ reFindProductList[i].Box_Piece__c
+ )
+ .clone();
+ Jstage.countid = 0;
+ if (reFindProductList[i].Isoverdue__c == 1) {
+ Jstage.limitCount = 0;
+ }
+ Jstage.boxPiece = reFindProductList[i].Box_Piece__c;
+ newMidPieceMap.put(
+ reFindProductList[i].Consumable_Product__c +
+ reFindProductList[i].Box_Piece__c,
+ Jstage
+ );
+ } else {
+ ConsumableorderdetailsInfo Jstage = new ConsumableorderdetailsInfo(
+ MidMap.get(reFindProductList[i].Consumable_Product__c)
+ );
+ Jstage.countid = 0;
+ if (reFindProductList[i].Isoverdue__c == 1) {
+ Jstage.limitCount = 0;
+ }
+ Jstage.boxPiece = reFindProductList[i].Box_Piece__c;
+ newMidPieceMap.put(
+ reFindProductList[i].Consumable_Product__c +
+ reFindProductList[i].Box_Piece__c,
+ Jstage
+ );
+ }
+ }
+ }
+ for (ConsumableorderdetailsInfo bss : newMidBoxMap.values()) {
+ bss.check = true;
+ bss.overlimitCount = bss.countid - bss.limitCount;
+ boxRecords.add(bss);
+ }
+ boxRecords.sort();
+ for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
+ bss.check = true;
+ bss.overlimitCount = bss.countid - bss.limitCount;
+ }
+ for (ConsumableorderdetailsInfo bss : boxRecords) {
+ consumableorderdetailsRecords.add(bss);
+ if (newMidPieceMap.containsKey(bss.Prod.Id + '涓�')) {
+ consumableorderdetailsRecords.add(
+ newMidPieceMap.get(bss.Prod.Id + '涓�')
+ );
+ //newMidPieceMap绉婚櫎宸茬粡娣诲姞鐨凱iece
+ newMidPieceMap.remove(bss.Prod.Id + '涓�');
+ }
+ }
+ for (ConsumableorderdetailsInfo bss : newMidPieceMap.values()) {
+ consumableorderdetailsRecords.add(
+ newMidPieceMap.get(bss.Prod.Id + '涓�')
+ );
+ }
+ }
+
+ //鍏堝彇鍑烘湭鐩樼偣鍒扮殑浜у搧
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ if (ass.check == true) {
+ for (integer i = 0; i < ProductCount_Res.size(); i++) {
+ if (
+ ProductCount_Res[i].Consumable_Product__c == ass.Prod.Id &&
+ ass.boxPiece == ProductCount_Res[i].Box_Piece__c
+ ) {
+ if (
+ barCodeListPandianMap.get(
+ ProductCount_Res[i].Bar_Code_search__c
+ ) != null
+ ) {
+ continue;
+ } else {
+ carCodeListLose.add(ProductCount_Res[i].Bar_Code__c);
+ ////barCodeListLoseMap.put(ProductCount_Res[i].Id, new ConsumableorderdetailsInfo(ProductCount_Res[i]));
+ //consumableorderdetailsRecordserrordummy.add(new ConsumableorderdetailsInfo(ProductCount_Res[i],'涓㈠け'));
+ //pandiandetailsMap.put(ProductCount_Res[i].Id, '涓㈠け');
+ }
+ }
+ }
+ }
+ }
+ //宸茬粡鍑哄簱鐨勪骇鍝�
+ List<Consumable_order_details2__c> reSet2 = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ Bar_Code_search__c,
+ Dealer_Info_text__c
+ FROM Consumable_order_details2__c
+ WHERE
+ Dealer_Arrive__c = TRUE
+ AND (Dealer_Shipment__c = TRUE
+ OR Dealer_Saled__c = TRUE)
+ AND Dealer_Returned__c = FALSE
+ AND Cancellation_Flag__c = FALSE
+ AND Bar_Code_search__c IN :BarCodeListP
+ AND Dealer_Info_text__c = :accountName
+ ORDER BY Name
+ ];
+ Map<String, Consumable_order_details2__c> needreturnMap = new Map<String, Consumable_order_details2__c>();
+ for (Consumable_order_details2__c cod2 : reSet2) {
+ needreturnMap.put(cod2.Bar_Code__c, cod2);
+ }
+ //// 缁忛攢鍟嗕箣闂存垨鑰呭悓涓�缁忛攢鍟嗕笉鍚屽伐浣滃湴璋冭揣
+ //List<Consumable_order_details2__c> reSet1 = [SELECT Id, Name,Consumable_Product__c,
+ // Bar_Code__c,Consumable_Product__r.Name__c,Dealer_Shipment__c,Dealer_Saled__c,
+ // Asset_Model_No__c,Isoverdue__c,Box_Piece__c,Dealer_Arrive__c,
+ // Bar_Code_search__c,Dealer_Info_text__c
+ // FROM Consumable_order_details2__c
+ // WHERE (Dealer_Arrive__c = TRUE
+ // or Dealer_Shipment__c= TRUE
+ // or Dealer_Saled__c = TRUE)
+ // AND Dealer_Returned__c = FALSE
+ // AND Cancellation_Flag__c = FALSE
+ // AND Bar_Code_search__c in :BarCodeListP
+ // AND (Dealer_Info_text__c != :accountName
+ // OR (Dealer_Info_text__c = :accountName
+ // AND Arrive_Owner_Work_Location__c != :userWorkLocation)
+ // )
+ // ORDER BY Name ];
+ //Map<String,Consumable_order_details2__c> otherAgProMap = new Map<String,Consumable_order_details2__c>();
+ //for(Consumable_order_details2__c cod2 :reSet1){
+ // otherAgProMap.put(cod2.Bar_Code__c,cod2);
+ //}
+ carCodeListLose.clear();
+ //鏈洏鐐瑰埌鐨勪骇鍝�
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ if (ass.check == true) {
+ for (integer i = 0; i < ProductCount_Res.size(); i++) {
+ if (
+ ProductCount_Res[i].Consumable_Product__c == ass.Prod.Id &&
+ ass.boxPiece == ProductCount_Res[i].Box_Piece__c
+ ) {
+ if (
+ barCodeListPandianMap.containsKey(
+ ProductCount_Res[i].Bar_Code_search__c
+ )
+ ) {
+ continue;
+ }
+ if (ProductCount_Res[i].Isoverdue__c == 0) {
+ consumableorderdetailsRecordserrordummy.add(
+ new ConsumableorderdetailsInfo(
+ ProductCount_Res[i],
+ '璇ヤ骇鍝佸凡缁忚繃鏈夋晥鏈燂紝璇烽攢瀛樸��'
+ )
+ );
+ pandiandetailsMap.put(
+ ProductCount_Res[i].Id,
+ '璇ヤ骇鍝佸凡缁忚繃鏈夋晥鏈燂紝璇烽攢瀛樸��'
+ );
+ if (
+ pandianoverdueCountMap.containsKey(
+ ProductCount_Res[i].Consumable_product__c +
+ ProductCount_Res[i].Box_Piece__c
+ ) == false
+ ) {
+ pandianoverdueCountMap.put(
+ ProductCount_Res[i].Consumable_Product__c +
+ ProductCount_Res[i].Box_Piece__c,
+ 1
+ );
+ } else {
+ pandianoverdueCountMap.put(
+ ProductCount_Res[i].Consumable_Product__c +
+ ProductCount_Res[i].Box_Piece__c,
+ pandianoverdueCountMap.get(
+ ProductCount_Res[i].Consumable_Product__c +
+ ProductCount_Res[i].Box_Piece__c
+ ) + 1
+ );
+ }
+ continue;
+ }
+
+ consumableorderdetailsRecordserrordummy.add(
+ new ConsumableorderdetailsInfo(ProductCount_Res[i], '涓㈠け')
+ );
+ pandiandetailsMap.put(ProductCount_Res[i].Id, '涓㈠け');
+ }
+ }
+ // 鍚屾椂瀛樺湪鍏朵粬缁忛攢鍟嗗簱瀛樹骇鍝�
+ for (Consumable_order_details2__c cod2 : reSet1) {
+ if (
+ cod2.Consumable_Product__c == ass.Prod.Id &&
+ ass.boxPiece == cod2.Box_Piece__c
+ ) {
+ if (
+ barCodeListPandianMap.containsKey(cod2.Bar_Code_search__c) &&
+ otherAgProMap.containsKey(cod2.Bar_Code__c) &&
+ otherAgProMap.get(cod2.Bar_Code__c).Dealer_Saled__c == false &&
+ otherAgProMap.get(cod2.Bar_Code__c).Dealer_Shipment__c == false
+ ) {
+ consumableorderdetailsRecordserrordummy.add(
+ new ConsumableorderdetailsInfo(
+ cod2,
+ '璇ヤ骇鍝佸綊灞炰簬' +
+ otherAgProMap.get(cod2.Bar_Code__c).Dealer_Info_text__c +
+ '鐨勫簱瀛樸��'
+ )
+ );
+ pandiandetailsMap.put(
+ cod2.Id,
+ '璇ヤ骇鍝佸綊灞炰簬' +
+ otherAgProMap.get(cod2.Bar_Code__c).Dealer_Info_text__c +
+ '鐨勫簱瀛樸��'
+ );
+ continue;
+ }
+ }
+ }
+ // 闇�瑕佽繑鍝佺殑浜у搧
+ for (Consumable_order_details2__c cod2 : reSet2) {
+ if (
+ cod2.Consumable_Product__c == ass.Prod.Id &&
+ ass.boxPiece == cod2.Box_Piece__c
+ ) {
+ if (needreturnMap.containsKey(cod2.Bar_Code__c)) {
+ consumableorderdetailsRecordserrordummy.add(
+ new ConsumableorderdetailsInfo(
+ cod2,
+ '璇ヤ骇鍝佺洰鍓嶅嚭搴撶姸鎬侊紝璇疯繑鍝併��'
+ )
+ );
+ pandiandetailsMap.put(cod2.Id, '璇ヤ骇鍝佺洰鍓嶅嚭搴撶姸鎬侊紝璇疯繑鍝併��');
+ continue;
+ }
+ }
+ }
+ }
+ }
+
+ //鏇存柊涓绘槑缁嗗崟
+ if (barCodeListPandianMap.size() > 0) {
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ if (ass.check == true) {
+ integer countSum = 0;
+ if (pandianProdIdCountMap.containsKey(ass.Prod.Id + ass.boxPiece)) {
+ countSum = pandianProdIdCountMap.get(ass.Prod.Id + ass.boxPiece);
+ }
+ integer overdueSum = 0;
+ if (pandianoverdueCountMap.containsKey(ass.Prod.Id + ass.boxPiece)) {
+ overdueSum = pandianoverdueCountMap.get(ass.Prod.Id + ass.boxPiece);
+ }
+ ass.Pandian = countSum;
+ ass.Diff = ass.countid - countSum - overdueSum;
+ ass.refind = 0;
+ }
+ }
+ } else {
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ if (ass.check == true) {
+ integer overdueSum = 0;
+ if (pandianoverdueCountMap.containsKey(ass.Prod.Id + ass.boxPiece)) {
+ overdueSum = pandianoverdueCountMap.get(ass.Prod.Id + ass.boxPiece);
+ }
+ ass.Diff = ass.countid - ass.Pandian - overdueSum;
+ }
+ }
+ }
+
+ //瀵诲洖鍋氭垚
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ for (
+ ConsumableorderdetailsInfo adjust : consumableorderdetailsRecordsAdjust
+ ) {
+ if (
+ ass.Prod.Name__c == adjust.Prod.Name__c &&
+ ass.boxPiece == adjust.orderdetails2.Box_Piece__c
+ ) {
+ if (
+ reFindProduct.containsKey(adjust.orderdetails2.Bar_Code_search__c)
+ ) {
+ continue;
+ } else {
+ ass.Pandian++;
+ ass.refind++;
+ reFindProduct.put(
+ adjust.orderdetails2.Bar_Code_search__c,
+ adjust.orderdetails2.Bar_Code_search__c
+ );
+ }
+ }
+ }
+ }
+ if (pandiandetailsMap.keySet().size() > 0) {
+ List<Consumable_order_details2__c> showcod2 = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ Bar_Code_search__c
+ FROM Consumable_order_details2__c
+ WHERE Id IN :pandiandetailsMap.keySet()
+ ORDER BY Name
+ ];
+ initStandardController();
+ showcod2nid = cod2s();
+ }
+ for (Consumable_order_details2__c cod2 : showcod2nid) {
+ codPageRecords.add(
+ new ConsumableorderdetailsInfo(cod2, pandiandetailsMap.get(cod2.Id))
+ );
+ }
+ if (codPageRecords.size() > 0)
+ done = true;
+ iSinventory = true;
+ consumableorderdetailsRecordserrordummy.clear();
+ pandiandetailsList = [
+ SELECT
+ Id,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Box_Piece__c,
+ Lose_reason__c
+ FROM Consumable_order_details2__c
+ WHERE Id IN :pandiandetailsMap.keySet()
+ ORDER BY Name
+ ];
+ for (Consumable_order_details2__c codDet : pandiandetailsList) {
+ codDet.Lose_reason__c = pandiandetailsMap.get(codDet.Id);
+ }
+ List<Consumable_order_details2__c> pandiandetailsListMid = new List<Consumable_order_details2__c>();
+ for (Consumable_order_details2__c cod2 : pandiandetailsList) {
+ pandiandetailsListMid.add(cod2);
+ if (pandiandetailsListMid.size() == 1000) {
+ pandiandetailsListShow.add(pandiandetailsListMid);
+ pandiandetailsListMid = new List<Consumable_order_details2__c>();
+ }
+ }
+ if (pandiandetailsListMid.size() > 0) {
+ pandiandetailsListShow.add(pandiandetailsListMid);
+ }
+ //鍒嗛〉
+ PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
+ totalCount = codPageRecords.size();
+ paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount)
+ ? pageToken + pageSize
+ : null;
+ paginatedAccounts.recordStart = pageToken + 1;
+ paginatedAccounts.pageNumber = pageToken / pageSize + 1;
+ Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
+ paginatedAccounts.recordEnd = totalCount >= recordEnd
+ ? recordEnd
+ : totalCount;
+ paginatedAccounts.totalRecords = totalCount;
+
+ Integer startIdx;
+ Integer endIdx;
+ List<ConsumableorderdetailsInfo> pageCodeRecords = new List<ConsumableorderdetailsInfo>();
+ startIdx = pageToken;
+ endIdx = startIdx + pageSize;
+ if (endIdx > codPageRecords.size()) {
+ endIdx = codPageRecords.size();
+ }
+ for (Integer i = startIdx; i < endIdx; i++) {
+ pageCodeRecords.add(codPageRecords.get(i));
+ }
+
+ data.put('paginatedAccounts', paginatedAccounts);
+ data.put('pageCodeRecords', pageCodeRecords);
+
+ //end
+
+ System.debug('=====>codPageRecords2' + codPageRecords);
+ System.debug(
+ '=====>consumableorderdetailsRecords' + consumableorderdetailsRecords
+ );
+ data.put('codPageRecords', JSON.serialize(codPageRecords));
+ data.put(
+ 'consumableorderdetailsRecords',
+ JSON.serialize(consumableorderdetailsRecords)
+ );
+ System.debug('iSinventory===>' + iSinventory);
+ data.put('iSinventory', JSON.serialize(iSinventory));
+ System.debug('pandiandetailsMap===>' + pandiandetailsMap);
+ data.put('pandiandetailsMap', pandiandetailsMap);
+ data.put('reSet', reSet);
+ data.put(
+ 'consumableorderdetailsRecordsview',
+ JSON.serialize(consumableorderdetailsRecordsview)
+ );
+ System.debug(
+ '=====>consumableorderdetailsRecordsview' +
+ consumableorderdetailsRecordsview
+ );
+ res.code = 200;
+ res.status = 'Sucess';
+ return res;
+ }
+
+ // 淇濆瓨鎸夐挳
+ @AuraEnabled
+ public static ResponseBodyLWC save(
+ Boolean iSinventory,
+ String consumableorderdetailsRecordsLWC,
+ String accountid,
+ String agencyProType,
+ Map<Id, String> pandiandetailsMap,
+ List<Consumable_order_details2__c> reSet
+ ) {
+ List<ConsumableorderdetailsInfo> consumableorderdetailsRecords = (List<ConsumableorderdetailsInfo>) JSON.deserialize(
+ consumableorderdetailsRecordsLWC,
+ List<ConsumableorderdetailsInfo>.class
+ );
+ agencyProType = agencyProType;
+ accountid = accountid;
+ pandiandetailsMap = pandiandetailsMap;
+ reSet = reSet;
+ System.debug('pandiandetailsMap===>' + pandiandetailsMap);
+
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ // 璺宠繃鏄庣粏2涓嶅繀瑕佹洿鏂�
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ if (!iSinventory) {
+ return new ResponseBodyLWC('Error', 500, '璇峰厛褰曞叆BarCode', '');
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'璇峰厛鐐广�怋arCode褰曞叆銆�'));
+ // return null;
+ }
+ integer Lo = 0;
+ for (ConsumableorderdetailsInfo header : consumableorderdetailsRecords) {
+ if (header.check == true) {
+ Lo++;
+ }
+ }
+ if (Lo == 0) {
+ iSinventory = false;
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'璇烽�夋嫨瑕佺洏鐐圭殑鏄庣粏'));
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇烽�夋嫨瑕佺洏鐐圭殑鏄庣粏', '');
+ }
+ for (ConsumableorderdetailsInfo header : consumableorderdetailsRecords) {
+ if (header.check == true) {
+ //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, header.prod.Name__c + ' '+header.prod.Name__c));
+ //return null;
+ if (
+ (header.DiffReason == '' || header.DiffReason == null) &&
+ header.Diff > 0
+ ) {
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ header.prod.Name__c + '璇疯緭鍏ュ樊寮傚師鍥�',
+ ''
+ );
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, header.prod.Name__c + '璇疯緭鍏ュ樊寮傚師鍥�'));
+ // return null;
+ } else if (
+ (header.DiffReason != '' && header.DiffReason != null) &&
+ header.Diff == 0
+ ) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '鏃犱涪澶变骇鍝侊紝涓嶉渶瑕佸~鍐欏樊寮傚師鍥�'));
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ header.prod.Name__c + '鏃犱涪澶变骇鍝侊紝涓嶉渶瑕佸~鍐欏樊寮傚師鍥�',
+ ''
+ );
+ }
+ }
+ }
+ Integer orderDetNo = 1;
+ Savepoint sp = Database.setSavepoint();
+ Consumable_order__c Po = new Consumable_order__c();
+ Po.Name = '*';
+ Po.Order_status__c = '鎵瑰噯';
+ Po.Inventory_date__c = Date.today();
+ Po.Order_type__c = '鐩樼偣';
+ Po.Dealer_Info__c = accountid;
+ Po.Order_ProType__c = agencyProType;
+ Po.RecordTypeid = System.Label.RT_ConOrder_Inventory;
+ try {
+ insert Po;
+ eSetId = Po.id;
+ List<Consumable_order__c> Consumable_order = [
+ SELECT Name
+ FROM Consumable_order__c
+ WHERE id = :Po.id
+ ];
+ List<Consumable_orderdetails__c> InsList = new List<Consumable_orderdetails__c>();
+ List<Consumable_order_details2__c> InsListUp = new List<Consumable_order_details2__c>();
+ List<Consumable_order_details2__c> updListAdjust = new List<Consumable_order_details2__c>();
+ Map<String, String> ErrorName = new Map<String, String>();
+ Map<String, Boolean> CheckTF = new Map<String, Boolean>();
+ for (ConsumableorderdetailsInfo header : consumableorderdetailsRecords) {
+ if (header.check == true) {
+ Consumable_orderdetails__c insPan = new Consumable_orderdetails__c();
+ insPan = new Consumable_orderdetails__c();
+ String str = string.valueOf(orderDetNo);
+ if (str.length() == 1) {
+ str = '0' + str;
+ }
+ insPan.Name = Consumable_order[0].Name + '-' + str;
+ insPan.Consumable_Product__c = header.ProdId;
+ ErrorName.put(insPan.Consumable_Product__c, header.DiffReason);
+ CheckTF.put(insPan.Consumable_product__c, true);
+ insPan.Consumable_order__c = Po.Id;
+ insPan.Lose_reason__c = header.DiffReason;
+ insPan.Diff__c = header.Diff;
+ insPan.Product_Refind__c = header.refind;
+ insPan.inventory_sum__c = header.Pandian;
+ insPan.Count_Sum__c = header.countid;
+ insPan.RecordTypeId = System.Label.RT_ConOrderDetail1_Inventory;
+ orderDetNo++;
+ InsList.add(insPan);
+ }
+ }
+ if (InsList.size() > 0) {
+ insert InsList;
+ }
+ List<Consumable_order_details2__c> showcod2 = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ Bar_Code_search__c
+ FROM Consumable_order_details2__c
+ WHERE Id IN :pandiandetailsMap.keySet()
+ ORDER BY Name
+ ];
+ for (Consumable_order_details2__c cod : showcod2) {
+ Consumable_order_details2__c InsDetail = new Consumable_order_details2__c();
+ InsDetail.Id = cod.Id;
+ InsDetail.Consumable_Inventory_order__c = po.Id;
+ InsDetail.Inventory_date__c = Date.today();
+ // 20210224 gzw CHAN-BXF3PG start
+ // if(pandiandetailsMap.get(cod.Id) == '涓㈠け' ){
+ if (
+ pandiandetailsMap.get(cod.Id) == '涓㈠け' &&
+ CheckTF.containsKey(cod.Consumable_product__c)
+ ) {
+ // 20210224 gzw CHAN-BXF3PG end
+ InsDetail.Lose_reason__c = ErrorName.get(cod.Consumable_product__c);
+ InsDetail.Lose_Flag__c = true;
+ } else if (pandiandetailsMap.get(cod.Id) == '瀵诲洖') {
+ InsDetail.Lose_reason__c = '';
+ InsDetail.Lose_Flag__c = false;
+ } else {
+ continue;
+ }
+ InsListUp.add(InsDetail);
+ }
+ for (Consumable_order_details2__c rs : reSet) {
+ rs.Inventory_date__c = Date.today();
+ }
+ if (reSet.size() > 0) {
+ update reSet;
+ }
+ if (InsListUp.size() > 0) {
+ ControllerUtil.updateOrderDetailsSatus(InsListUp); // Commented By DTT - Li Jun for testing 20230407
+ }
+ } catch (Exception e) {
+ Database.rollback(sp);
+ // ApexPages.addMessages(ex);
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ e.getMessage() + e.getLineNumber(),
+ ''
+ );
+ // return null;
+ }
+ // FIXME impliment BarCodeListAdjust
+ /************************************************************************************************/
+ // return ProS();
+ data.put('eSetId', eSetId);
+ data.put('InsListUp', InsListUp);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ //鐩樼偣涓�瑙�
+ public PageReference ProS() {
+ // 杩斿洖鐩樼偣涓�瑙�
+ PageReference ref = new Pagereference(
+ '/apex/InventoryList?eSetId=' + eSetId
+ );
+ ref.setRedirect(true);
+ return ref;
+ }
+ //CSV鍑哄姏
+ public PageReference doClick() {
+ Pagereference pr = page.InventoryCSV;
+ return pr;
+ }
+ //鍒嗛〉Bean
+ public class PaginatedAccounts {
@AuraEnabled
- public static ResponseBodyLWC save(Boolean iSinventory,String consumableorderdetailsRecordsLWC,String accountid,String agencyProType,Map<Id,String> pandiandetailsMap,List<Consumable_order_details2__c> reSet) {
- List<ConsumableorderdetailsInfo> consumableorderdetailsRecords = (List<ConsumableorderdetailsInfo>)JSON.deserialize(consumableorderdetailsRecordsLWC,List<ConsumableorderdetailsInfo>.class);
- agencyProType = agencyProType;
- accountid =accountid;
- pandiandetailsMap = pandiandetailsMap;
- reSet =reSet;
- System.debug('pandiandetailsMap===>'+pandiandetailsMap);
+ public Integer nextPageToken;
+ @AuraEnabled
+ public Integer pageNumber { get; set; }
+ @AuraEnabled
+ public Integer totalRecords { get; set; }
+ @AuraEnabled
+ public Integer recordStart { get; set; }
+ @AuraEnabled
+ public Integer recordEnd { get; set; }
+ }
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- // 璺宠繃鏄庣粏2涓嶅繀瑕佹洿鏂�
- StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
- if(!iSinventory){
- return new ResponseBodyLWC('Error',500, '璇峰厛褰曞叆BarCode', '');
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'璇峰厛鐐广�怋arCode褰曞叆銆�'));
- // return null;
- }
- integer Lo = 0;
- for(ConsumableorderdetailsInfo header : consumableorderdetailsRecords){
- if(header.check==true){
- Lo++;
- }
- }
- if(Lo == 0){
- iSinventory = false;
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'璇烽�夋嫨瑕佺洏鐐圭殑鏄庣粏'));
- // return null;
- return new ResponseBodyLWC('Error',500, '璇烽�夋嫨瑕佺洏鐐圭殑鏄庣粏', '');
- }
- for(ConsumableorderdetailsInfo header : consumableorderdetailsRecords){
- if(header.check==true){
- //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, header.prod.Name__c + ' '+header.prod.Name__c));
- //return null;
- if((header.DiffReason == ''||header.DiffReason ==null)&&header.Diff>0){
- return new ResponseBodyLWC('Error',500, header.prod.Name__c + '璇疯緭鍏ュ樊寮傚師鍥�', '');
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, header.prod.Name__c + '璇疯緭鍏ュ樊寮傚師鍥�'));
- // return null;
- }else if ((header.DiffReason != ''&&header.DiffReason !=null)&&header.Diff==0){
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '鏃犱涪澶变骇鍝侊紝涓嶉渶瑕佸~鍐欏樊寮傚師鍥�'));
- // return null;
- return new ResponseBodyLWC('Error',500, header.prod.Name__c + '鏃犱涪澶变骇鍝侊紝涓嶉渶瑕佸~鍐欏樊寮傚師鍥�', '');
- }
- }
- }
- Integer orderDetNo = 1;
- Savepoint sp = Database.setSavepoint();
- Consumable_order__c Po = new Consumable_order__c();
- Po.Name ='*';
- Po.Order_status__c = '鎵瑰噯';
- Po.Inventory_date__c = Date.today();
- Po.Order_type__c = '鐩樼偣';
- Po.Dealer_Info__c = accountid;
- Po.Order_ProType__c = agencyProType;
- Po.RecordTypeid = System.Label.RT_ConOrder_Inventory;
- try{
- insert Po;
- eSetId = Po.id;
- List<Consumable_order__c> Consumable_order = [SELECT Name FROM Consumable_order__c WHERE id =:Po.id];
- List<Consumable_orderdetails__c> InsList = New List<Consumable_orderdetails__c>();
- List<Consumable_order_details2__c> InsListUp = New List<Consumable_order_details2__c>();
- List<Consumable_order_details2__c> updListAdjust = New List<Consumable_order_details2__c>();
- Map<String,String> ErrorName = new Map<String,String>();
- Map<String,Boolean> CheckTF = new Map<String,Boolean>();
- for(ConsumableorderdetailsInfo header : consumableorderdetailsRecords){
- if(header.check==true){
- Consumable_orderdetails__c insPan = new Consumable_orderdetails__c();
- insPan = new Consumable_orderdetails__c();
- String str = string.valueOf(orderDetNo);
- if(str.length() == 1){
- str = '0' + str;
- }
- insPan.Name = Consumable_order[0].Name + '-'+ str;
- insPan.Consumable_Product__c = header.ProdId;
- ErrorName.put(insPan.Consumable_Product__c,header.DiffReason);
- CheckTF.put(insPan.Consumable_product__c,true);
- insPan.Consumable_order__c = Po.Id;
- insPan.Lose_reason__c = header.DiffReason;
- insPan.Diff__c = header.Diff;
- insPan.Product_Refind__c = header.refind;
- insPan.inventory_sum__c = header.Pandian;
- insPan.Count_Sum__c = header.countid;
- insPan.RecordTypeId = System.Label.RT_ConOrderDetail1_Inventory;
- orderDetNo ++;
- InsList.add(insPan);
- }
- }
- if(InsList.size()>0){
- insert InsList;
- }
- List<Consumable_order_details2__c> showcod2 = [select Id, Name,Consumable_Product__c,
- Bar_Code__c,Consumable_Product__r.Name__c,
- Asset_Model_No__c,Isoverdue__c,Box_Piece__c,
- Bar_Code_search__c
- FROM Consumable_order_details2__c
- WHERE Id in :pandiandetailsMap.keySet()
- order by Name];
- for(Consumable_order_details2__c cod : showcod2){
- Consumable_order_details2__c InsDetail = new Consumable_order_details2__c();
- InsDetail.Id =cod.Id;
- InsDetail.Consumable_Inventory_order__c = po.Id;
- InsDetail.Inventory_date__c = Date.today();
- // 20210224 gzw CHAN-BXF3PG start
- // if(pandiandetailsMap.get(cod.Id) == '涓㈠け' ){
- if(pandiandetailsMap.get(cod.Id) == '涓㈠け' && CheckTF.containsKey(cod.Consumable_product__c)){
- // 20210224 gzw CHAN-BXF3PG end
- InsDetail.Lose_reason__c = ErrorName.get(cod.Consumable_product__c);
- InsDetail.Lose_Flag__c = true;
- }else if(pandiandetailsMap.get(cod.Id) == '瀵诲洖' ){
- InsDetail.Lose_reason__c = '';
- InsDetail.Lose_Flag__c = false;
- }else{
- continue;
- }
- InsListUp.add(InsDetail);
- }
- for(Consumable_order_details2__c rs : reSet){
- rs.Inventory_date__c = Date.today();
- }
- if(reSet.size() > 0){
- update reSet;
- }
- if(InsListUp.size()>0){
- ControllerUtil.updateOrderDetailsSatus(InsListUp);// Commented By DTT - Li Jun for testing 20230407
- }
-
- }catch (Exception e) {
- Database.rollback(sp);
- // ApexPages.addMessages(ex);
- return new ResponseBodyLWC('Error',500, e.getMessage()+e.getLineNumber(), '');
- // return null;
- }
- // FIXME impliment BarCodeListAdjust
- /************************************************************************************************/
- // return ProS();
- data.put('eSetId',eSetId);
- data.put('InsListUp',InsListUp);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ // Data Bean
+ @TestVisible
+ class ConsumableorderdetailsInfo implements Comparable {
+ @AuraEnabled
+ public Boolean check { get; set; }
+ @AuraEnabled
+ public Consumable_orderdetails__c orderdetails1 { get; set; }
+ @AuraEnabled
+ public Consumable_order_details2__c orderdetails2 { get; set; }
+ @AuraEnabled
+ public Product2__c Prod { get; set; }
+ @AuraEnabled
+ public Decimal countid { get; set; }
+ @AuraEnabled
+ public String ProdId { get; set; }
+ @AuraEnabled
+ public Decimal Pandian { get; set; }
+ @AuraEnabled
+ public Decimal Diff { get; set; }
+ @AuraEnabled
+ public Decimal refind { get; set; }
+ @AuraEnabled
+ public String DiffReason { get; set; }
+ @AuraEnabled
+ public Boolean canSelect { get; set; }
+ @AuraEnabled
+ public Boolean sortBy { get; set; }
+ @AuraEnabled
+ public Decimal limitCount { get; set; }
+ @AuraEnabled
+ public Decimal overlimitCount { get; set; }
+ @AuraEnabled
+ public String boxPiece { get; set; }
+ public ConsumableorderdetailsInfo(
+ Consumable_order_details2__c e,
+ string str
+ ) {
+ orderdetails2 = e;
+ Prod = e.Consumable_Product__r;
+ //e.Lose_reason__c = str;
+ DiffReason = str;
}
- //鐩樼偣涓�瑙�
- public PageReference ProS() {
- // 杩斿洖鐩樼偣涓�瑙�
- PageReference ref = new Pagereference('/apex/InventoryList?eSetId=' + eSetId);
- ref.setRedirect(true);
- return ref;
+ // 宸插瓨鍦ㄦ秷鑰楀搧鏄庣粏鐢�
+ public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
+ check = false;
+ orderdetails2 = e;
+ Prod = e.Consumable_Product__r;
+ canSelect = true;
}
- //CSV鍑哄姏
- public PageReference doClick() {
- Pagereference pr = page.InventoryCSV;
- return pr;
+ public ConsumableorderdetailsInfo(Product2__c e) {
+ check = false;
+ //orderdetails1 = new Consumable_orderdetails__c();
+ Prod = e;
+ canSelect = true;
+ ProdId = string.valueOf(e.id);
+ countid = 0;
+ Pandian = 0;
+ refind = 0;
+ Diff = 0;
+ limitCount = 0;
+ overlimitCount = 0;
}
- //鍒嗛〉Bean
- public class PaginatedAccounts {
- @AuraEnabled
- public Integer nextPageToken;
- @AuraEnabled
- public Integer pageNumber { get; set; }
- @AuraEnabled
- public Integer totalRecords { get; set; }
- @AuraEnabled
- public Integer recordStart { get; set; }
- @AuraEnabled
- public Integer recordEnd { get; set; }
+ // 鎺掑簭
+ public Integer compareTo(Object compareTo) {
+ ConsumableorderdetailsInfo compareToesd = (ConsumableorderdetailsInfo) compareTo;
+ Integer returnValue = 0;
+ if (countid > compareToesd.countid) {
+ returnValue = -1;
+ } else if (countid < compareToesd.countid) {
+ returnValue = 1;
+ }
+ return returnValue;
}
-
- // Data Bean
- class ConsumableorderdetailsInfo implements Comparable {
- @AuraEnabled
- public Boolean check { get; set; }
- @AuraEnabled
- public Consumable_orderdetails__c orderdetails1 { get; set; }
- @AuraEnabled
- public Consumable_order_details2__c orderdetails2 { get; set; }
- @AuraEnabled
- public Product2__c Prod { get; set; }
- @AuraEnabled
- public Decimal countid { get; set; }
- @AuraEnabled
- public String ProdId{get;set;}
- @AuraEnabled
- public Decimal Pandian { get; set; }
- @AuraEnabled
- public Decimal Diff { get; set; }
- @AuraEnabled
- public Decimal refind { get; set; }
- @AuraEnabled
- public String DiffReason { get; set; }
- @AuraEnabled
- public Boolean canSelect { get; set; }
- @AuraEnabled
- public Boolean sortBy { get; set; }
- @AuraEnabled
- public Decimal limitCount { get; set; }
- @AuraEnabled
- public Decimal overlimitCount { get; set; }
- @AuraEnabled
- public String boxPiece { get; set; }
- public ConsumableorderdetailsInfo(Consumable_order_details2__c e,string str) {
-
- orderdetails2 = e;
- Prod = e.Consumable_Product__r;
- //e.Lose_reason__c = str;
- DiffReason = str;
- }
-
- // 宸插瓨鍦ㄦ秷鑰楀搧鏄庣粏鐢�
- public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
- check = false;
- orderdetails2 = e;
- Prod = e.Consumable_Product__r;
- canSelect = true;
- }
- public ConsumableorderdetailsInfo(Product2__c e) {
- check = false;
- //orderdetails1 = new Consumable_orderdetails__c();
- Prod = e;
- canSelect = true;
- ProdId = string.valueOf(e.id);
- countid =0;
- Pandian = 0;
- refind = 0;
- Diff = 0;
- limitCount = 0;
- overlimitCount = 0;
- }
- // 鎺掑簭
- public Integer compareTo(Object compareTo) {
- ConsumableorderdetailsInfo compareToesd =(ConsumableorderdetailsInfo)compareTo;
- Integer returnValue = 0;
- if (countid > compareToesd.countid ) {
- returnValue = -1;
- } else if (countid < compareToesd.countid ) {
- returnValue = 1;
- }
- return returnValue;
- }
- }
-}
\ No newline at end of file
+ }
+}
diff --git a/force-app/main/default/classes/LexInventoryControllerTest.cls b/force-app/main/default/classes/LexInventoryControllerTest.cls
new file mode 100644
index 0000000..2f497df
--- /dev/null
+++ b/force-app/main/default/classes/LexInventoryControllerTest.cls
@@ -0,0 +1,1179 @@
+@isTest
+public class LexInventoryControllerTest {
+ static testMethod void InventoryControllerTest_PartBar() {
+ user myUser_test;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ StaticParameter.EscapeOrderDetail2Trigger = true;
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ RecordType rectCoO = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+
+ Account olympus = new Account(
+ RecordTypeId = rectCoO.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '8888888'
+ );
+ insert myAccount1;
+
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com',
+ Work_Location__c = '涓婃捣'
+ );
+ insert MyUser_Test;
+ }
+ System.runAs(MyUser_Test) {
+ Product2 prod07 = new Product2(
+ Name = 'Test07',
+ ProductCode = 'Test07',
+ Asset_Model_No__c = 'Test07',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod08 = new Product2(
+ Name = 'Test08',
+ ProductCode = 'Test08',
+ Asset_Model_No__c = 'Test08',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod09 = new Product2(
+ Name = 'Test09',
+ ProductCode = 'Test09',
+ Asset_Model_No__c = 'Test09',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+
+ insert new List<Product2>{ prod07, prod08, prod09 };
+
+ //鍒朵綔浜у搧
+ Product2__c proG = new Product2__c(
+ Name = 'MH-155:鐧藉钩琛″附',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod07.Id
+ );
+ insert proG;
+ Product2__c proH = new Product2__c(
+ Name = 'MB-677:BNC鐢电紗',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod08.Id
+ );
+ insert proH;
+ Product2__c proF = new Product2__c(
+ Name = 'TooMAJ-643R:姘村泭闉樼003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod09.Id
+ );
+ insert proF;
+
+ //棰勫埗澶存槑缁�
+ Consumable_order__c CreateId = new Consumable_order__c();
+ CreateId.Name = 'testMing';
+ CreateId.Order_status__c = '鑽夋涓�';
+ CreateId.RecordTypeid = System.Label.RT_ConOrder_Order;
+ CreateId.Dealer_Info__c = myAccount1.id;
+ CreateId.Inventory_date__c = Date.today();
+ CreateId.Order_type__c = '鐩樼偣';
+ CreateId.Order_ProType__c = 'ET';
+ insert CreateId;
+ List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
+
+ //鍒朵綔Consumable_order_details__c-------ProductCount
+ Consumable_order_details2__c dataForProductCount9 = new Consumable_order_details2__c();
+ dataForProductCount9.Bar_Code__c = '1234567890';
+ dataForProductCount9.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount9.Arrive_date__c = Date.today();
+ dataForProductCount9.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount9.Consumable_Product__c = proG.id;
+ dataForProductCount9.Asset_Model_No__c = proG.Asset_Model_No__c;
+ dataForProductCount9.Box_Piece__c = '鐩�';
+ dataForProductCount9.Consumable_order_minor__c = CreateId.id;
+ dataForProductCount9.Send_Date__c = null;
+ dataForProductCount9.Used_date__c = null;
+ dataForProductCount9.Lose_Flag__c = false;
+ conList.add(dataForProductCount9);
+
+ Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c();
+ dataForProductCount7.Bar_Code__c = '1234567892';
+ dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount7.Arrive_date__c = Date.today();
+ dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount7.Consumable_Product__c = proH.id;
+ dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c;
+ dataForProductCount7.Box_Piece__c = '鐩�';
+ dataForProductCount7.Consumable_order_minor__c = CreateId.id;
+ dataForProductCount7.Send_Date__c = null;
+ dataForProductCount7.Used_date__c = null;
+ dataForProductCount7.Lose_Flag__c = false;
+ conList.add(dataForProductCount7);
+
+ Consumable_order_details2__c dataForProductCount = new Consumable_order_details2__c();
+ dataForProductCount.Bar_Code__c = '1234567882';
+ dataForProductCount.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount.Arrive_date__c = Date.today();
+ dataForProductCount.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount.Consumable_Product__c = proG.id;
+ dataForProductCount.Asset_Model_No__c = proG.Asset_Model_No__c;
+ dataForProductCount.Box_Piece__c = '鐩�';
+ dataForProductCount.Consumable_order_minor__c = CreateId.id;
+ dataForProductCount.Send_Date__c = null;
+ dataForProductCount.Used_date__c = null;
+ dataForProductCount.Lose_Flag__c = true;
+ conList.add(dataForProductCount);
+
+ Consumable_order_details2__c dataForProductCount4 = new Consumable_order_details2__c();
+ dataForProductCount4.Bar_Code__c = '1234567884';
+ dataForProductCount4.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount4.Arrive_date__c = Date.today();
+ dataForProductCount4.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount4.Consumable_Product__c = proF.id;
+ dataForProductCount4.Asset_Model_No__c = proF.Asset_Model_No__c;
+ dataForProductCount4.Box_Piece__c = '涓�';
+ dataForProductCount4.Consumable_order_minor__c = CreateId.id;
+ //dataForProductCount4.Lose_Flag__c = true;
+ dataForProductCount4.RemoveBox_No__c = 1;
+
+ conList.add(dataForProductCount4);
+
+ Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c();
+ dataForProductCount5.Bar_Code__c = '1234567885';
+ dataForProductCount5.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount5.Arrive_date__c = Date.today();
+ dataForProductCount5.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount5.Consumable_Product__c = proH.id;
+ dataForProductCount5.Asset_Model_No__c = proH.Asset_Model_No__c;
+ dataForProductCount5.Box_Piece__c = '涓�';
+ dataForProductCount5.Consumable_order_minor__c = CreateId.id;
+ dataForProductCount5.Lose_Flag__c = true;
+ dataForProductCount5.RemoveBox_No__c = 1;
+ conList.add(dataForProductCount5);
+ insert conList;
+
+ List<Consumable_order_details2__c> productCount_Res = [
+ SELECT Id, Name
+ 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 Bar_Code__c != NULL
+ AND Dealer_Info_text__c = :myAccount1.Name
+ ];
+ //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨
+
+ List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
+ Consumable_order_details2__c con = new Consumable_order_details2__c();
+ con.Arrive_date__c = Date.today();
+ con.Send_Date__c = null;
+ con.Used_date__c = null;
+ con.Return_date__c = null;
+ con.Lose_Flag__c = false;
+ con.Cancellation_Flag__c = false;
+ con.Consumable_Product__c = proG.Id;
+ con.Asset_Model_No__c = 'Mj-1001';
+ con.Sterilization_limit__c = Date.today().addDays(2);
+ con.Box_Piece__c = '鐩�';
+ con.Consumable_order_minor__c = CreateId.id;
+ con.Bar_Code__c = '1234567885';
+ conList1.add(con);
+
+ Consumable_order_details2__c con1 = new Consumable_order_details2__c();
+ con1.Arrive_date__c = Date.today();
+ con1.Send_Date__c = null;
+ con1.Used_date__c = null;
+ con1.Return_date__c = null;
+ con1.Lose_Flag__c = false;
+ con1.Cancellation_Flag__c = false;
+ con1.Consumable_Product__c = proG.Id;
+ con1.Asset_Model_No__c = 'Mj-1001';
+ con1.Sterilization_limit__c = Date.today().addDays(2);
+ con1.Box_Piece__c = '涓�';
+ con1.Consumable_order_minor__c = CreateId.id;
+ con1.Bar_Code__c = '12345678856';
+ conList1.add(con1);
+ insert conList1;
+
+ LexInventoryController OwnTest = new LexInventoryController();
+ LexInventoryController.init();
+ LexInventoryController controller = new LexInventoryController();
+ List<LexInventoryController.ConsumableorderdetailsInfo> testList = LexInventoryController.consumableorderdetailsRecords;
+ List<LexInventoryController.ConsumableorderdetailsInfo> testList1 = new List<LexInventoryController.ConsumableorderdetailsInfo>();
+ System.debug('testCount:' + testList.size());
+ for (LexInventoryController.ConsumableorderdetailsInfo ass : testList) {
+ System.debug(ass.check);
+ ass.check = true;
+ testList1.add(ass);
+ }
+ System.debug('testList1:' + testList1);
+ LexInventoryController.searchConsumableorderdetails(
+ 'ET',
+ '涓婃捣',
+ 'Testaccount001',
+ '12345678856\n1234567895\n1234567890\n12345678511\n1234567856\n1234567855\n1234567886\n12345678551\n1234567890\n1234567883\n1234567882\n1234567881\n1234567884\nn123456788412\n1234567885\n123456788512\n1234567891\n1234567892\n1234567893\n1234567894',
+ JSON.serialize(testList1),
+ 1,
+ 0,
+ 'Test',
+ 'ASC'
+ );
+ LexInventoryController.searchConsumableorderdetails(
+ 'ET',
+ '涓婃捣',
+ 'Testaccount001',
+ '1234567882',
+ JSON.serialize(testList1),
+ 1,
+ 0,
+ 'Test',
+ 'ASC'
+ );
+ LexInventoryController.barcode = '';
+ }
+ }
+ static testMethod void InventoryControllerTest_PartPan() {
+ user MyUser_Test;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ RecordType rectCoO = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ Account olympus = new Account(
+ RecordTypeId = rectCoO.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+
+ Product2 prod07 = new Product2(
+ Name = 'Test07',
+ ProductCode = 'Test07',
+ Asset_Model_No__c = 'Test07',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true
+ );
+ Product2 prod08 = new Product2(
+ Name = 'Test08',
+ ProductCode = 'Test08',
+ Asset_Model_No__c = 'Test08',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true
+ );
+ Product2 prod09 = new Product2(
+ Name = 'Test09',
+ ProductCode = 'Test09',
+ Asset_Model_No__c = 'Test09',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true
+ );
+ insert new List<Product2>{ prod07, prod08, prod09 };
+
+ //鍒朵綔浜у搧
+ Product2__c proG = new Product2__c(
+ Name = 'Too001',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod07.Id
+ );
+ insert proG;
+ Product2__c proH = new Product2__c(
+ Name = 'Too002',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod08.Id
+ );
+ insert proH;
+ Product2__c proF = new Product2__c(
+ Name = 'Too003',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod09.Id
+ );
+ insert proF;
+
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id
+ );
+
+ insert myAccount1;
+
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com'
+ );
+ insert MyUser_Test;
+ }
+ System.runAs(MyUser_Test) {
+ InventoryController OwnTest = new InventoryController();
+ OwnTest.size = 2;
+ OwnTest.init();
+ OwnTest.setCon.next();
+ OwnTest.refreshPageSize();
+ OwnTest.ConsumableorderdetailsRecordsview.sort();
+ system.assertEquals(0, OwnTest.consumableorderdetailsCount);
+ OwnTest.save();
+ }
+ }
+ static testMethod void InventoryControllerTest_ge() {
+ user MyUser_Test;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+
+ RecordType rectCoO = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ Account olympus = new Account(
+ RecordTypeId = rectCoO.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '8888888'
+ );
+ insert myAccount1;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com'
+ );
+ insert MyUser_Test;
+ }
+ System.runAs(MyUser_Test) {
+ Product2 prod07 = new Product2(
+ Name = 'Test07',
+ ProductCode = 'Test07',
+ Asset_Model_No__c = 'Test07',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod08 = new Product2(
+ Name = 'Test08',
+ ProductCode = 'Test08',
+ Asset_Model_No__c = 'Test08',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod09 = new Product2(
+ Name = 'Test09',
+ ProductCode = 'Test09',
+ Asset_Model_No__c = 'Test09',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod07, prod08, prod09 };
+
+ //鍒朵綔浜у搧
+ Product2__c proG = new Product2__c(
+ Name = 'MH-155:鐧藉钩琛″附',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod07.Id
+ );
+ insert proG;
+ Product2__c proH = new Product2__c(
+ Name = 'MB-677:BNC鐢电紗',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod08.Id
+ );
+ insert proH;
+ Product2__c proF = new Product2__c(
+ Name = 'TooMAJ-643R:姘村泭闉樼003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod09.Id
+ );
+ insert proF;
+
+ //棰勫埗澶存槑缁�
+ Consumable_order__c CreateId = new Consumable_order__c();
+ CreateId.Name = 'testMing';
+ CreateId.Order_status__c = '鑽夋涓�';
+ CreateId.RecordTypeid = System.Label.RT_ConOrder_Order;
+ CreateId.Dealer_Info__c = myAccount1.id;
+ CreateId.Inventory_date__c = Date.today();
+ CreateId.Order_type__c = '鐩樼偣';
+ CreateId.Order_ProType__c = 'ET';
+ insert CreateId;
+ List<Consumable_order_details2__c> orderList = new List<Consumable_order_details2__c>();
+
+ //鍒朵綔Consumable_order_details__c-------ProductCount
+ Consumable_order_details2__c dataForProductCount9 = new Consumable_order_details2__c();
+ dataForProductCount9.Bar_Code__c = '1234567890';
+ dataForProductCount9.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount9.Arrive_date__c = Date.today();
+ dataForProductCount9.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount9.Consumable_Product__c = proG.id;
+ dataForProductCount9.Asset_Model_No__c = proG.Asset_Model_No__c;
+ dataForProductCount9.Box_Piece__c = '涓�';
+ dataForProductCount9.RemoveBox_No__c = 1;
+ orderList.add(dataForProductCount9);
+
+ Consumable_order_details2__c dataForProductCount8 = new Consumable_order_details2__c();
+ dataForProductCount8.Bar_Code__c = '1234567891';
+ dataForProductCount8.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount8.Arrive_date__c = Date.today();
+ dataForProductCount8.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount8.Consumable_Product__c = proG.id;
+ dataForProductCount8.Asset_Model_No__c = proG.Asset_Model_No__c;
+ orderList.add(dataForProductCount8);
+
+ Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c();
+ dataForProductCount7.Bar_Code__c = '1234567892';
+ dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount7.Arrive_date__c = Date.today();
+ dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount7.Consumable_Product__c = proH.id;
+ dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c;
+ dataForProductCount7.Box_Piece__c = '涓�';
+ dataForProductCount7.Consumable_order_minor__c = CreateId.id;
+ dataForProductCount7.Send_Date__c = null;
+ dataForProductCount7.Used_date__c = null;
+ dataForProductCount7.Lose_Flag__c = false;
+ dataForProductCount7.RemoveBox_No__c = 1;
+ orderList.add(dataForProductCount7);
+
+ Consumable_order_details2__c dataForProduct = new Consumable_order_details2__c();
+ dataForProduct.Bar_Code__c = '1234567894';
+ dataForProduct.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProduct.Arrive_date__c = Date.today();
+ dataForProduct.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProduct.Consumable_Product__c = proF.id;
+ dataForProduct.Asset_Model_No__c = proF.Asset_Model_No__c;
+ dataForProduct.Box_Piece__c = '涓�';
+ dataForProduct.Consumable_order_minor__c = CreateId.id;
+ dataForProduct.Send_Date__c = null;
+ dataForProduct.Used_date__c = null;
+ dataForProduct.Lose_Flag__c = false;
+ dataForProduct.RemoveBox_No__c = 1;
+ orderList.add(dataForProduct);
+
+ Consumable_order_details2__c dataForProductCount3 = new Consumable_order_details2__c();
+ dataForProductCount3.Bar_Code__c = '1234567883';
+ dataForProductCount3.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount3.Arrive_date__c = Date.today();
+ dataForProductCount3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount3.Consumable_Product__c = proG.id;
+ dataForProductCount3.Asset_Model_No__c = proG.Asset_Model_No__c;
+ dataForProductCount3.Consumable_order_minor__c = CreateId.id;
+ dataForProductCount3.Lose_Flag__c = true;
+ //dataForProductCount3.RemoveBox_No__c = 1;
+ orderList.add(dataForProductCount3);
+
+ PageReference page = new Pagereference('/Inventory');
+ page.setRedirect(true);
+ System.Test.setCurrentPage(page);
+ System.Test.startTest();
+ LexInventoryController controller = new LexInventoryController();
+ LexInventoryController.init();
+ System.debug(
+ '===>鍊�1' + LexInventoryController.consumableorderdetailsRecords
+ );
+ System.debug(
+ '===>鍊�2' +
+ JSON.serialize(LexInventoryController.consumableorderdetailsRecords)
+ );
+ System.debug(
+ '===>2222222' +
+ JSON.serialize(LexInventoryController.consumableorderdetailsRecords)
+ );
+ List<LexInventoryController.ConsumableorderdetailsInfo> testList = LexInventoryController.consumableorderdetailsRecords;
+ List<LexInventoryController.ConsumableorderdetailsInfo> testList1 = new List<LexInventoryController.ConsumableorderdetailsInfo>();
+ System.debug('testCount:' + testList.size());
+ for (LexInventoryController.ConsumableorderdetailsInfo ass : testList) {
+ System.debug(ass.check);
+ ass.check = true;
+ testList1.add(ass);
+ }
+ System.debug('testList1:' + testList1);
+
+ LexInventoryController.searchConsumableorderdetails(
+ 'ET',
+ '涓婃捣',
+ 'Testaccount001',
+ '12345678856\n1234567895\n1234567890\n12345678511\n1234567856\n1234567855\n1234567886\n12345678551\n1234567890\n1234567883\n1234567882\n1234567881\n1234567884\nn123456788412\n1234567885\n123456788512\n1234567891\n1234567892\n1234567893\n1234567894',
+ JSON.serialize(testList1),
+ 1,
+ 0,
+ 'Test',
+ 'ASC'
+ );
+ System.Test.stopTest();
+ }
+ }
+ static testMethod void InventoryControllerTest_xunhui() {
+ user MyUser_Test;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ StaticParameter.EscapeOrderDetail2Trigger = true;
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ RecordType rectCoO = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ Account olympus = new Account(
+ RecordTypeId = rectCoO.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '8888888'
+ );
+ insert myAccount1;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com'
+ );
+ insert MyUser_Test;
+ }
+ System.runAs(MyUser_Test) {
+ Product2 prod07 = new Product2(
+ Name = 'Test07',
+ ProductCode = 'Test07',
+ Asset_Model_No__c = 'Test07',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod08 = new Product2(
+ Name = 'Test08',
+ ProductCode = 'Test08',
+ Asset_Model_No__c = 'Test08',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod09 = new Product2(
+ Name = 'Test09',
+ ProductCode = 'Test09',
+ Asset_Model_No__c = 'Test09',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod07, prod08, prod09 };
+
+ //鍒朵綔浜у搧
+ Product2__c proG = new Product2__c(
+ Name = 'MH-155:鐧藉钩琛″附',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod07.Id
+ );
+ insert proG;
+ Product2__c proH = new Product2__c(
+ Name = 'MB-677:BNC鐢电紗',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod08.Id
+ );
+ insert proH;
+ Product2__c proF = new Product2__c(
+ Name = 'TooMAJ-643R:姘村泭闉樼003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod09.Id
+ );
+ insert proF;
+
+ //棰勫埗澶存槑缁�
+ Consumable_order__c CreateId = new Consumable_order__c();
+ CreateId.Name = 'testMing';
+ CreateId.Order_status__c = '鑽夋涓�';
+ CreateId.RecordTypeid = System.Label.RT_ConOrder_Order;
+ CreateId.Dealer_Info__c = myAccount1.id;
+ CreateId.Inventory_date__c = Date.today();
+ CreateId.Order_type__c = '鐩樼偣';
+ CreateId.Order_ProType__c = 'ET';
+ insert CreateId;
+ List<Consumable_order__c> orderList = new List<Consumable_order__c>();
+ //鍒拌揣
+ Consumable_order__c Order1 = new Consumable_order__c();
+ Order1.Name = 'OCM_01';
+ Order1.Order_status__c = '鎵瑰噯';
+ Order1.Order_type__c = '鍒拌揣';
+ Order1.Dealer_Info__c = myAccount1.Id;
+ Order1.RecordTypeid = '01210000000c9dqAAA';
+ Order1.Order_ProType__c = 'ENG';
+ orderList.add(Order1);
+ //鍙戣揣
+ Consumable_order__c Order2 = new Consumable_order__c();
+ Order2.Name = 'OCM_01';
+ Order2.Order_status__c = '鎵瑰噯';
+ Order2.Order_type__c = '璁㈠崟 ';
+ Order2.Dealer_Info__c = myAccount1.Id;
+ Order2.RecordTypeid = '01210000000c9drAAA';
+ Order2.Order_ProType__c = 'ENG';
+ orderList.add(Order2);
+ insert orderList;
+
+ //鍒朵綔Consumable_order_details__c-------ProductCount
+ Consumable_order_details2__c dataForProductCount9 = new Consumable_order_details2__c();
+ dataForProductCount9.Bar_Code__c = '1234567890';
+ dataForProductCount9.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount9.Arrive_date__c = Date.today();
+ dataForProductCount9.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount9.Consumable_Product__c = proG.id;
+ dataForProductCount9.Asset_Model_No__c = proG.Asset_Model_No__c;
+ dataForProductCount9.Box_Piece__c = '鐩�';
+ dataForProductCount9.Consumable_order_minor__c = CreateId.id;
+ dataForProductCount9.Send_Date__c = null;
+ dataForProductCount9.Used_date__c = null;
+ dataForProductCount9.Lose_Flag__c = false;
+ dataForProductCount9.RemoveBox_No__c = 1;
+ insert dataForProductCount9;
+
+ Consumable_order_details2__c dataForProductCount8 = new Consumable_order_details2__c();
+ dataForProductCount8.Bar_Code__c = '1234567891';
+ dataForProductCount8.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount8.Arrive_date__c = Date.today();
+ dataForProductCount8.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount8.Consumable_Product__c = proG.id;
+ dataForProductCount8.Asset_Model_No__c = proG.Asset_Model_No__c;
+ dataForProductCount8.Box_Piece__c = '鐩�';
+ dataForProductCount8.Consumable_order_minor__c = CreateId.id;
+ dataForProductCount8.Send_Date__c = null;
+ dataForProductCount8.Used_date__c = null;
+ dataForProductCount8.Lose_Flag__c = false;
+ dataForProductCount8.RemoveBox_No__c = 1;
+ insert dataForProductCount8;
+
+ Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c();
+ dataForProductCount7.Bar_Code__c = '1234567892';
+ dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount7.Arrive_date__c = Date.today();
+ dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount7.Consumable_Product__c = proH.id;
+ dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c;
+ dataForProductCount7.Box_Piece__c = '涓�';
+ dataForProductCount7.Consumable_order_minor__c = CreateId.id;
+ dataForProductCount7.Send_Date__c = null;
+ dataForProductCount7.Used_date__c = null;
+ dataForProductCount7.Lose_Flag__c = false;
+ dataForProductCount7.RemoveBox_No__c = 1;
+ insert dataForProductCount7;
+
+ Consumable_order_details2__c dataForProductCount6 = new Consumable_order_details2__c();
+ dataForProductCount6.Bar_Code__c = '1234567893';
+ dataForProductCount6.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount6.Arrive_date__c = Date.today();
+ dataForProductCount6.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount6.Consumable_Product__c = proH.id;
+ dataForProductCount6.Asset_Model_No__c = proH.Asset_Model_No__c;
+ dataForProductCount6.Box_Piece__c = '涓�';
+ dataForProductCount6.Consumable_order_minor__c = CreateId.id;
+ dataForProductCount6.Send_Date__c = null;
+ dataForProductCount6.Used_date__c = null;
+ dataForProductCount6.Lose_Flag__c = false;
+ dataForProductCount6.RemoveBox_No__c = 1;
+ insert dataForProductCount6;
+
+ Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c();
+ dataForProductCount5.Bar_Code__c = '1234567894';
+ dataForProductCount5.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount5.Arrive_date__c = Date.today();
+ dataForProductCount5.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount5.Consumable_Product__c = proH.id;
+ dataForProductCount5.Asset_Model_No__c = proH.Asset_Model_No__c;
+ dataForProductCount5.Box_Piece__c = '涓�';
+ dataForProductCount5.Consumable_order_minor__c = CreateId.id;
+ dataForProductCount5.Send_Date__c = null;
+ dataForProductCount5.Used_date__c = null;
+ dataForProductCount5.Lose_Flag__c = false;
+ dataForProductCount5.RemoveBox_No__c = 1;
+ insert dataForProductCount5;
+
+ List<Consumable_order_details2__c> conlist = new List<Consumable_order_details2__c>();
+ //Barcode妫�绱� 鎵�鏈夊湪搴�
+ Consumable_order_details2__c con1 = new Consumable_order_details2__c();
+ con1.Lose_Flag__c = false;
+ con1.Arrive_date__c = Date.today();
+ con1.Send_Date__c = null;
+ con1.Return_date__c = null;
+ con1.Lose_Flag__c = false;
+ con1.Cancellation_Date__c = null;
+ con1.Sterilization_limit__c = Date.today().addDays(2);
+ con1.Bar_Code__c = '123';
+ con1.Box_Piece__c = '鐩�';
+ con1.Bar_Code__c = '1234567894';
+ con1.Sterilization_limit__c = Date.today().addDays(2);
+ con1.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ con1.Consumable_Product__c = proH.id;
+ con1.Consumable_order_minor__c = CreateId.id;
+ conlist.add(con1);
+
+ //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨
+ Consumable_order_details2__c con3 = new Consumable_order_details2__c();
+ con3.Consumable_Product__c = proH.id;
+ con3.Bar_Code__c = '1001';
+ con3.Consumable_Arrived_order__c = Order1.id;
+ con3.Consumable_order_minor__c = Order2.id;
+ con3.Arrive_date__c = Date.today();
+ con3.Send_Date__c = null;
+ con3.Return_date__c = null;
+ con3.Lose_Flag__c = false;
+ con3.Cancellation_Flag__c = false;
+ con3.Consumable_order_minor__c = CreateId.id;
+ con3.Sterilization_limit__c = Date.today().addDays(2);
+ con3.Box_Piece__c = '涓�';
+ con3.RecordTypeid = '01210000000kUDKAA2';
+ conlist.add(con3);
+
+ //productAdjust
+ Consumable_order_details2__c con6 = new Consumable_order_details2__c();
+ con6.Consumable_Product__c = proH.id;
+ con6.Lose_reason__c = '杩囨湡搴撳瓨閿�瀛�';
+ con6.Box_Piece__c = '鐩�';
+ con6.Sterilization_limit__c = Date.today().addDays(-2);
+ con6.Bar_Code__c = '10011';
+ con6.Consumable_Arrived_order__c = Order1.id;
+ con6.Lose_Flag__c = true;
+ con6.RecordTypeid = '01210000000kUDKAA2';
+ conlist.add(con6);
+ System.debug('conlist===>' + conlist);
+
+ //reset592
+ Consumable_order_details2__c con4 = new Consumable_order_details2__c();
+ con4.Arrive_date__c = Date.today();
+ con4.Send_Date__c = null;
+ con4.Return_date__c = null;
+ con4.Lose_Flag__c = false;
+ con4.Cancellation_Date__c = null;
+ con4.Sterilization_limit__c = Date.today().addDays(2);
+ con4.Bar_Code__c = '123456';
+ con4.Box_Piece__c = '鐩�';
+ // con2.Bar_Code__c = '1234567894';
+ con4.Sterilization_limit__c = Date.today().addDays(2);
+ con4.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ con4.Consumable_Product__c = proH.id;
+ // con2.Asset_Model_No__c = proH.Asset_Model_No__c;
+ con4.Consumable_order_minor__c = CreateId.id;
+ conlist.add(con4);
+
+ //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨
+ Consumable_order_details2__c con5 = new Consumable_order_details2__c();
+ con5.Arrive_date__c = Date.today();
+ con5.Send_Date__c = null;
+ con5.Return_date__c = null;
+ con5.Lose_Flag__c = false;
+ con5.Cancellation_Flag__c = false;
+ con5.Consumable_Product__c = proH.id;
+ con5.Consumable_order_minor__c = Order2.id;
+ // con5.Sterilization_limit__c = Date.today().addDays(2);
+ con5.Box_Piece__c = '鐩�';
+ con5.Bar_Code__c = '1001';
+ conlist.add(con5);
+ insert conlist;
+
+ System.Test.startTest();
+ LexInventoryController inver = new LexInventoryController();
+ LexInventoryController.init();
+ List<LexInventoryController.ConsumableorderdetailsInfo> testList = LexInventoryController.consumableorderdetailsRecords;
+ List<LexInventoryController.ConsumableorderdetailsInfo> testList1 = new List<LexInventoryController.ConsumableorderdetailsInfo>();
+ System.debug('testCount:' + testList.size());
+ for (LexInventoryController.ConsumableorderdetailsInfo ass : testList) {
+ System.debug(ass.check);
+ ass.check = true;
+ testList1.add(ass);
+ }
+ System.debug('testList1:' + testList1);
+ LexInventoryController.searchConsumableorderdetails(
+ 'ET',
+ '涓婃捣',
+ 'Testaccount001',
+ '',
+ JSON.serialize(testList1),
+ 20,
+ 9,
+ 'Test',
+ 'ASC'
+ );
+ LexInventoryController.searchConsumableorderdetails(
+ 'ET',
+ '涓婃捣',
+ 'Testaccount001',
+ '01210000000kUDKAA2\n10011',
+ JSON.serialize(testList1),
+ 20,
+ 9,
+ 'Test',
+ 'ASC'
+ );
+ LexInventoryController.searchConsumableorderdetails(
+ 'ET',
+ '涓婃捣',
+ 'Testaccount001',
+ '12345678856\n1234567895\n1234567890\n12345678511\n1234567856\n1234567855\n1234567886\n12345678551\n1234567890\n1234567883\n1234567882\n1234567881\n1234567884\nn123456788412\n1234567885\n123456788512\n1234567891\n1234567892\n1234567893\n1234567894\n1001',
+ JSON.serialize(testList1),
+ 1,
+ 0,
+ 'Test',
+ 'ASC'
+ );
+ LexInventoryController.save(
+ true,
+ JSON.serialize(testList1),
+ myAccount1.Id,
+ 'ET',
+ LexInventoryController.pandiandetailsMap,
+ LexInventoryController.reSet
+ );
+ LexInventoryController.searchConsumableorderdetails(
+ 'ET',
+ '涓婃捣',
+ 'Testaccount001',
+ '',
+ '[{"sortBy": null,"refind": 0,"ProdId": "a0l0l000004EisKAAS","Prod": {"attributes": {"type": "Product2__c","url": "/services/data/v58.0/sobjects/Product2__c/a0l0l000004EisKAAS"},"Id": "a0l0l000004EisKAAS","Name": "MH-155:鐧藉钩琛″附","Name__c": "Test07","SFDA_Status__c": "鍋滄","Packing_list_manual__c": 1,"Asset_Model_No__c": "Test07"},"Pandian": 0,"overlimitCount": 0,"orderdetails2": null,"orderdetails1": null,"limitCount": 2,"DiffReason": null,"Diff": 0,"countid": 2,"check": true,"canSelect": true,"boxPiece": "鐩�"}]',
+ 20,
+ 9,
+ 'Test',
+ 'ASC'
+ );
+
+ System.Test.stopTest();
+ }
+ }
+
+ static testMethod void all() {
+ user MyUser_Test;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ StaticParameter.EscapeOrderDetail2Trigger = true;
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ RecordType rectCoO = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ Account olympus = new Account(
+ RecordTypeId = rectCoO.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '8888888'
+ );
+ insert myAccount1;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com',
+ Work_Location__c = '涓婃捣'
+ );
+ insert MyUser_Test;
+ }
+ System.runAs(MyUser_Test) {
+ Product2 prod07 = new Product2(
+ Name = 'Test07',
+ ProductCode = 'Test07',
+ Asset_Model_No__c = 'Test07',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod08 = new Product2(
+ Name = 'Test08',
+ ProductCode = 'Test08',
+ Asset_Model_No__c = 'Test08',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod09 = new Product2(
+ Name = 'Test09',
+ ProductCode = 'Test09',
+ Asset_Model_No__c = 'Test09',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod07, prod08, prod09 };
+
+ //鍒朵綔浜у搧
+ Product2__c proG = new Product2__c(
+ Name = 'MH-155:鐧藉钩琛″附',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod07.Id
+ );
+ insert proG;
+ Product2__c proH = new Product2__c(
+ Name = 'MB-677:BNC鐢电紗',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod08.Id
+ );
+ insert proH;
+ Product2__c proF = new Product2__c(
+ Name = 'TooMAJ-643R:姘村泭闉樼003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod09.Id
+ );
+ insert proF;
+ List<Consumable_order__c> orderList = new List<Consumable_order__c>();
+ //鍒拌揣
+ Consumable_order__c Order1 = new Consumable_order__c();
+ Order1.Name = 'OCM_01';
+ Order1.Order_status__c = '鎵瑰噯';
+ Order1.Order_type__c = '鍒拌揣';
+ Order1.Dealer_Info__c = myAccount1.Id;
+ Order1.RecordTypeid = '01210000000c9dqAAA';
+ Order1.Order_ProType__c = 'ET';
+ orderList.add(Order1);
+ //鍙戣揣
+ Consumable_order__c Order2 = new Consumable_order__c();
+ Order2.Name = 'OCM_01';
+ Order2.Order_status__c = '鎵瑰噯';
+ Order2.Order_type__c = '璁㈠崟 ';
+ Order2.Dealer_Info__c = myAccount1.Id;
+ Order2.RecordTypeid = '01210000000c9drAAA';
+ Order2.Order_ProType__c = 'ET';
+ orderList.add(Order2);
+ insert orderList;
+ //鏌ヨ搴撳瓨 杩藉姞杩斿搧搴撳瓨
+ List<Consumable_order_details2__c> conlist = new List<Consumable_order_details2__c>();
+ Consumable_order_details2__c con3 = new Consumable_order_details2__c();
+ con3.Arrive_date__c = Date.today();
+ con3.Send_Date__c = null;
+ con3.Used_date__c = null;
+ con3.Return_date__c = null;
+ con3.Lose_Flag__c = false;
+ con3.Cancellation_Flag__c = false;
+ con3.Consumable_order_minor__c = Order1.id;
+ con3.Consumable_Arrived_order__c = Order1.id;
+ con3.Bar_Code__c = '1001';
+ con3.Consumable_Product__c = proH.id;
+ conlist.add(con3);
+ insert conlist;
+
+ //productAdjust
+ Consumable_order_details2__c con6 = new Consumable_order_details2__c();
+ // con6.Consumable_Product__c = proH.id;
+ con6.Lose_reason__c = '杩囨湡搴撳瓨閿�瀛�';
+ // con6.Box_Piece__c = '鐩�';
+ con6.Sterilization_limit__c = Date.today().addDays(-2);
+ con6.Bar_Code__c = '10011';
+ // con6.Consumable_Arrived_order__c = Order1.id;
+ con6.Lose_Flag__c = true;
+ // con6.RecordTypeid = '01210000000kUDKAA2';
+ conlist.add(con6);
+ System.debug('conlist===>' + conlist);
+ LexInventoryController.init();
+ List<LexInventoryController.ConsumableorderdetailsInfo> testList = LexInventoryController.consumableorderdetailsRecords;
+ List<LexInventoryController.ConsumableorderdetailsInfo> testList1 = new List<LexInventoryController.ConsumableorderdetailsInfo>();
+ System.debug('testCount:' + testList.size());
+ for (LexInventoryController.ConsumableorderdetailsInfo ass : testList) {
+ System.debug(ass.check);
+ ass.check = true;
+ testList1.add(ass);
+ }
+ System.debug('testList1:' + testList1);
+
+ LexInventoryController.searchConsumableorderdetails(
+ 'ET',
+ '涓婃捣',
+ 'Testaccount001',
+ '1001\n10011',
+ JSON.serialize(testList1),
+ 20,
+ 9,
+ 'Test',
+ 'ASC'
+ );
+ LexInventoryController.searchConsumableorderdetails(
+ 'ET',
+ '涓婃捣',
+ 'Testaccount001',
+ '',
+ JSON.serialize(testList1),
+ 20,
+ 9,
+ 'Test',
+ 'ASC'
+ );
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexInventoryControllerTest.cls-meta.xml b/force-app/main/default/classes/LexInventoryControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexInventoryControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexInventoryListController.cls b/force-app/main/default/classes/LexInventoryListController.cls
index a4e9395..5ae2462 100644
--- a/force-app/main/default/classes/LexInventoryListController.cls
+++ b/force-app/main/default/classes/LexInventoryListController.cls
@@ -1,103 +1,152 @@
public without sharing class LexInventoryListController {
- /*****************妞滅储鐢�******************/
- public static Consumable_order__c coc { get; set; }
- public static String baseUrl {get;private set;}
- /*****************鐢婚潰琛ㄧずBean******************/
- public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords { get; set; }
- public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsError { get; set; }
- // 鐩樼偣鏄庣粏1
- private static List<Consumable_orderdetails__c> consumableorderdetails1 = new List<Consumable_orderdetails__c>();
- // 鐩樼偣鏄庣粏2
- private static List<Consumable_order_details2__c> consumableorderdetailsSelected = new List<Consumable_order_details2__c>();
+ /*****************妞滅储鐢�******************/
+ public static Consumable_order__c coc { get; set; }
+ public static String baseUrl { get; private set; }
+ /*****************鐢婚潰琛ㄧずBean******************/
+ public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords {
+ get;
+ set;
+ }
+ public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordsError {
+ get;
+ set;
+ }
+ // 鐩樼偣鏄庣粏1
+ private static List<Consumable_orderdetails__c> consumableorderdetails1 = new List<Consumable_orderdetails__c>();
+ // 鐩樼偣鏄庣粏2
+ private static List<Consumable_order_details2__c> consumableorderdetailsSelected = new List<Consumable_order_details2__c>();
- // 鐩樼偣鍗曞彿 ID
- private static String ESetId = '';
- public LexInventoryListController() {
- //Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');
- baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
- ESetId = ApexPages.currentPage().getParameters().get('esetId');
- consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- consumableorderdetailsRecordsError = new List<ConsumableorderdetailsInfo>();
+ // 鐩樼偣鍗曞彿 ID
+ private static String ESetId = '';
+ public LexInventoryListController() {
+ //Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');
+ baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
+ ESetId = ApexPages.currentPage().getParameters().get('esetId');
+ consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ consumableorderdetailsRecordsError = new List<ConsumableorderdetailsInfo>();
+ }
+ // 鐢婚潰鍒濆鍖�
+ @AuraEnabled
+ public static ResponseBodyLWC init(String eSetId) {
+ system.debug('eSetId====>' + eSetId);
+ ESetId = eSetId;
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ consumableorderdetailsRecordsError = new List<ConsumableorderdetailsInfo>();
+
+ coc = new Consumable_order__c();
+ consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ List<Consumable_order__c> qs = new List<Consumable_order__c>();
+ qs = [
+ SELECT Name, Inventory_date__c, Order_date__c
+ FROM Consumable_order__c
+ WHERE Id = :ESetId
+ ];
+ System.debug('qs===>' + qs);
+ if (qs.size() > 0) {
+ coc = qs[0];
}
- // 鐢婚潰鍒濆鍖�
- @AuraEnabled
- public static ResponseBodyLWC init(String eSetId) {
- system.debug('eSetId====>'+eSetId);
- ESetId = eSetId;
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- consumableorderdetailsRecordsError = new List<ConsumableorderdetailsInfo>();
+ // 閬告姙娓堛伩銇槑缁嗐倰鍙栧緱
+ consumableorderdetailsSelected = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Consumable_Product__r.Name__c,
+ Consumable_Product__r.Intra_Trade_List_RMB__c,
+ Bar_Code__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Lose_Flag__c,
+ recordtypeid,
+ Lose_reason__c
+ FROM Consumable_order_details2__c
+ WHERE Consumable_Inventory_order__c = :ESetId
+ ORDER BY Name
+ ];
+ System.debug(
+ 'consumableorderdetailsSelected==>' + consumableorderdetailsSelected
+ );
- coc = new Consumable_order__c();
- consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- List<Consumable_order__c> qs = New List<Consumable_order__c>();
- qs = [select Name,Inventory_date__c,Order_date__c From Consumable_order__c Where Id =:ESetId];
- System.debug('qs===>'+qs);
- if (qs.size()>0){
- coc = qs[0];
- }
- // 閬告姙娓堛伩銇槑缁嗐倰鍙栧緱
- consumableorderdetailsSelected = [
- select Id, Name, Consumable_Product__c,
- Consumable_Product__r.Name, Sterilization_limit__c,
- Deliver_date__c,Consumable_Product__r.Name__c,
- Consumable_Product__r.Intra_Trade_List_RMB__c,Bar_Code__c,
- Consumable_Product__r.Asset_Model_No__c,Lose_Flag__c,
- recordtypeid,Lose_reason__c
- from Consumable_order_details2__c
- where Consumable_Inventory_order__c = :ESetId
- order by Name ];
- System.debug('consumableorderdetailsSelected==>'+consumableorderdetailsSelected);
-
- for (Integer i = 0; i < consumableorderdetailsSelected.size(); i++) {
- consumableorderdetailsRecordsError.add(new ConsumableorderdetailsInfo(consumableorderdetailsSelected[i]));
- }
- consumableorderdetails1 = [
- select Id, Name,Diff__c,inventory_sum__c,
- Count_Sum__c,Consumable_order__c,
- Consumable_Product__c,Consumable_Product__r.Name,Consumable_Count__c,
- Consumable_Product__r.Intra_Trade_List_RMB__c,
- Consumable_Product__r.Asset_Model_No__c,Consumable_Product__r.Name__c,
- Sum_of_money__c,recordtypeid,Lose_reason__c,Product_Refind__c
- from Consumable_orderdetails__c
- where Consumable_order__c = :ESetId
- order by Name ];
- for (Integer i = 0; i < consumableorderdetails1.size(); i++) {
- consumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(consumableorderdetails1[i]));
- }
- data.put('qs',qs);
- System.debug('consumableorderdetailsRecords====>'+consumableorderdetailsRecords);
- data.put('consumableorderdetailsRecords',JSON.serialize(consumableorderdetailsRecords));
- data.put('ConsumableorderdetailsRecordsError',JSON.serialize(ConsumableorderdetailsRecordsError));
- // if(ConsumableorderdetailsRecordsError.size()!=null){
- // data.put('ConsumableorderdetailsRecordsError',JSON.serialize(ConsumableorderdetailsRecordsError));
- // }
- System.debug('ConsumableorderdetailsRecordsError====>'+ConsumableorderdetailsRecordsError);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ for (Integer i = 0; i < consumableorderdetailsSelected.size(); i++) {
+ consumableorderdetailsRecordsError.add(
+ new ConsumableorderdetailsInfo(consumableorderdetailsSelected[i])
+ );
}
-
- // Data Bean
- class ConsumableorderdetailsInfo implements Comparable {
- public Consumable_orderdetails__c orderdetails1 { get; set; }
- public Consumable_order_details2__c orderdetails2 { get; set; }
- public Product2__c Prod { get; set; }
- // 鏄庣粏1
- public ConsumableorderdetailsInfo(Consumable_orderdetails__c e) {
- orderdetails1 = e;
- Prod = e.Consumable_Product__r;
- }
- // 鏄庣粏2
- public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
- orderdetails2 = e;
- Prod = e.Consumable_Product__r;
- }
- // 鎺掑簭
- public Integer compareTo(Object compareTo) {
- return null;
- }
+ consumableorderdetails1 = [
+ SELECT
+ Id,
+ Name,
+ Diff__c,
+ inventory_sum__c,
+ Count_Sum__c,
+ Consumable_order__c,
+ Consumable_Product__c,
+ Consumable_Product__r.Name,
+ Consumable_Count__c,
+ Consumable_Product__r.Intra_Trade_List_RMB__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Consumable_Product__r.Name__c,
+ Sum_of_money__c,
+ recordtypeid,
+ Lose_reason__c,
+ Product_Refind__c
+ FROM Consumable_orderdetails__c
+ WHERE Consumable_order__c = :ESetId
+ ORDER BY Name
+ ];
+ for (Integer i = 0; i < consumableorderdetails1.size(); i++) {
+ consumableorderdetailsRecords.add(
+ new ConsumableorderdetailsInfo(consumableorderdetails1[i])
+ );
}
-}
\ No newline at end of file
+ data.put('qs', qs);
+ System.debug(
+ 'consumableorderdetailsRecords====>' + consumableorderdetailsRecords
+ );
+ data.put(
+ 'consumableorderdetailsRecords',
+ JSON.serialize(consumableorderdetailsRecords)
+ );
+ data.put(
+ 'ConsumableorderdetailsRecordsError',
+ JSON.serialize(ConsumableorderdetailsRecordsError)
+ );
+ // if(ConsumableorderdetailsRecordsError.size()!=null){
+ // data.put('ConsumableorderdetailsRecordsError',JSON.serialize(ConsumableorderdetailsRecordsError));
+ // }
+ System.debug(
+ 'ConsumableorderdetailsRecordsError====>' +
+ ConsumableorderdetailsRecordsError
+ );
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ // Data Bean
+ @TestVisible
+ class ConsumableorderdetailsInfo implements Comparable {
+ public Consumable_orderdetails__c orderdetails1 { get; set; }
+ public Consumable_order_details2__c orderdetails2 { get; set; }
+ public Product2__c Prod { get; set; }
+ // 鏄庣粏1
+ public ConsumableorderdetailsInfo(Consumable_orderdetails__c e) {
+ orderdetails1 = e;
+ Prod = e.Consumable_Product__r;
+ }
+ // 鏄庣粏2
+ public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
+ orderdetails2 = e;
+ Prod = e.Consumable_Product__r;
+ }
+ // 鎺掑簭
+ public Integer compareTo(Object compareTo) {
+ return null;
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexInventoryListControllerTest.cls b/force-app/main/default/classes/LexInventoryListControllerTest.cls
new file mode 100644
index 0000000..635926c
--- /dev/null
+++ b/force-app/main/default/classes/LexInventoryListControllerTest.cls
@@ -0,0 +1,172 @@
+@isTest
+private class LexInventoryListControllerTest {
+ static testMethod void myUnitTest() {
+ Oly_TriggerHandler.bypass('ConsumableAssetHander');
+ Oly_TriggerHandler.bypass('Oly_TriggerHandler');
+ User myUser_test;
+ Account myAccount2;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ];
+ 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 = myAccount2.id
+ );
+ insert core;
+ 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.runAs(MyUser_Test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ JANCODE__c = '04953170200311',
+ Packing_list_manual__c = 12,
+ 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',
+ Packing_list_manual__c = 10,
+ Dealer_special_Object__c = true,
+ Manual_Entry__c = false
+ );
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ JANCODE__c = '04953170200313',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02, prod03 };
+ 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
+ );
+ Product2__c pro3 = new Product2__c(
+ Name = 'Pro003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod03.Id
+ );
+ insert new List<Product2__c>{ pro1, pro2, pro3 };
+
+ Consumable_order__c Order1 = new Consumable_order__c();
+ Order1.Name = 'OCM_01_001';
+ Order1.Order_status__c = '鎵瑰噯';
+ Order1.Order_type__c = '鐩樼偣';
+ Order1.RecordTypeid = System.Label.RT_ConOrder_Inventory;
+ insert Order1;
+
+ Consumable_order__c Order2 = new Consumable_order__c();
+ Order2.Name = 'OCM_01_002';
+ Order2.Order_status__c = '鎵瑰噯';
+ Order2.Order_type__c = '璁㈠崟';
+ Order2.RecordTypeid = System.Label.RT_ConOrder_Order;
+ insert Order2;
+
+ Consumable_order__c Order3 = new Consumable_order__c();
+ Order3.Name = 'OCM_01_004';
+ Order3.Order_status__c = '鎵瑰噯';
+ Order3.Order_type__c = '鍒拌揣';
+ Order3.RecordTypeid = '01210000000c9dqAAA';
+ insert Order3;
+
+ Consumable_orderdetails__c Orderdet1 = new Consumable_orderdetails__c();
+ Orderdet1.Name = 'OCM_01_001001';
+ Orderdet1.Consumable_order__c = Order1.Id;
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Inventory;
+
+ Consumable_orderdetails__c Orderdet2 = new Consumable_orderdetails__c();
+ Orderdet2.Name = 'OCM_01_001002';
+ Orderdet2.Consumable_order__c = Order1.Id;
+ Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Inventory;
+ insert new List<Consumable_orderdetails__c>{ Orderdet1, Orderdet2 };
+
+ List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
+ //浜у搧绫诲瀷涓嶅悓
+ Consumable_order_details2__c con = new Consumable_order_details2__c();
+ con.Name = 'OCM_01_001001';
+ con.Consumable_order_minor__c = Order1.Id;
+ con.Consumable_Product__c = pro2.Id;
+ con.Asset_Model_No__c = 'Test01';
+ con.Arrive_date__c = Date.today();
+ con.Bar_Code__c = '10011';
+ con.Used_date__c = null;
+ con.Lose_Flag__c = false;
+ con.Return_date__c = null;
+ con.Send_Date__c = null;
+ con.Box_Piece__c = '鐩�';
+ conList1.add(con);
+ insert conList1;
+ String eSetId = Order1.id;
+ System.Test.startTest();
+ LexInventoryListController.init(eSetId);
+
+ List<LexInventoryListController.ConsumableorderdetailsInfo> inList = LexInventoryListController.consumableorderdetailsRecords;
+ List<LexInventoryListController.ConsumableorderdetailsInfo> inList1 = new List<LexInventoryListController.ConsumableorderdetailsInfo>();
+ for (LexInventoryListController.ConsumableorderdetailsInfo ass : inList) {
+ ass.orderdetails1 = Orderdet1;
+ inList1.add(ass);
+ }
+ LexInventoryListController.ConsumableorderdetailsInfo c2 = new LexInventoryListController.ConsumableorderdetailsInfo(
+ Orderdet1
+ );
+ c2.orderdetails1 = Orderdet1;
+ c2.Prod = Orderdet1.Consumable_product__r;
+ LexInventoryListController.ConsumableorderdetailsInfo c1 = new LexInventoryListController.ConsumableorderdetailsInfo(
+ con
+ );
+ c1.orderdetails2 = con;
+ c1.Prod = con.Consumable_product__r;
+ c1.compareTo(c2);
+ System.Test.stopTest();
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexInventoryListControllerTest.cls-meta.xml b/force-app/main/default/classes/LexInventoryListControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexInventoryListControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexInventoryViewControllerTest.cls b/force-app/main/default/classes/LexInventoryViewControllerTest.cls
new file mode 100644
index 0000000..2514535
--- /dev/null
+++ b/force-app/main/default/classes/LexInventoryViewControllerTest.cls
@@ -0,0 +1,1273 @@
+@isTest
+public class LexInventoryViewControllerTest {
+ static testMethod void testInnerClass() {
+ List<LexInventoryViewController.ConsumableorderdetailsInfo> cro = new List<LexInventoryViewController.ConsumableorderdetailsInfo>();
+ cro.sort();
+ }
+ static testMethod void LexInventoryViewControllerTest() {
+ user myUser_test;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ List<RecordType> rectHos = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectHos.size() == 0) {
+ return;
+ }
+
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|2|4,Test02|3|5',
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount1;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '娣卞湷'
+ );
+ insert myUser_test;
+ }
+ System.runAs(myUser_test) {
+ Product2 prod01 = new Product2(
+ Name = '3400PK:PK閽� 5mmx33cm',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = '3400PK:PK閽� 5mmx33cm',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test001',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'tset',
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test002',
+ Packing_list_manual__c = 12,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'tset',
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02 };
+ Product2__c pro1 = new Product2__c(
+ Name = '3400PK:PK閽� 5mmx33cm',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod01.Id,
+ Category3_text__c = '鑵硅厰闀滄墜鏈�',
+ Category4_text__c = 'PK',
+ Category5_text__c = 'G400'
+ );
+ Product2__c pro2 = new Product2__c(
+ Name = 'Pro002',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod02.Id,
+ Category3_text__c = '鑵硅厰闀滄墜鏈�',
+ Category4_text__c = 'PK',
+ Category5_text__c = 'G400'
+ );
+ insert new List<Product2__c>{ pro1, pro2 };
+ System.debug('pro2===銆�' + pro2);
+ System.debug('pro1===銆�' + pro1);
+
+ 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_Inventory;
+ Order1.Order_ProType__c = 'ET';
+ insert Order1;
+
+ Consumable_order__c Order2 = new Consumable_order__c();
+ Order2.Name = 'OCM_01_001';
+ Order2.Order_status__c = '鎵瑰噯';
+ Order2.Order_type__c = '璁㈠崟';
+ Order2.Dealer_Info__c = myAccount1.Id;
+ Order2.RecordTypeid = System.Label.RT_ConOrder_Inventory;
+ Order2.Order_ProType__c = 'ENg';
+ insert Order2;
+
+ Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+ Orderdet1.Name = 'OCM_01_001001';
+ //Orderdet1.Consumable_principal__c = Order1.Id;
+ Orderdet1.Consumable_order_minor__c = Order1.Id;
+ Orderdet1.Consumable_Product__c = pro1.Id;
+ Orderdet1.Consumable_Arrived_order__c = Order1.Id;
+ //Orderdet1.IsArrival__c = true;
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet1.Bar_Code__c = '11111';
+ Orderdet1.Arrive_date__c = Date.today().addDays(1);
+ Orderdet1.Send_Date__c = null;
+ Orderdet1.Used_date__c = null;
+ Orderdet1.Lose_Flag__c = false;
+ Orderdet1.Box_Piece__c = '鐩�';
+
+ Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+ Orderdet2.Name = 'OCM_01_001002';
+ //Orderdet2.Consumable_principal__c = Order1.Id;
+ Orderdet2.Consumable_order_minor__c = Order1.Id;
+ Orderdet2.Consumable_Product__c = pro1.Id;
+ Orderdet2.Consumable_Arrived_order__c = Order1.Id;
+ //Orderdet2.IsArrival__c = true;
+ Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet2.Bar_Code__c = '22222';
+ Orderdet2.Arrive_date__c = Date.today().addDays(1);
+ Orderdet2.Send_Date__c = null;
+ Orderdet2.Used_date__c = null;
+ Orderdet2.Lose_Flag__c = false;
+ Orderdet2.Box_Piece__c = '涓�';
+ Orderdet2.Sterilization_limit__c = Date.today();
+
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+ Orderdet3.Name = 'OCM_01_001003';
+ //Orderdet3.Consumable_principal__c = Order1.Id;
+ Orderdet3.Consumable_order_minor__c = Order1.Id;
+ Orderdet3.Consumable_Product__c = pro2.Id;
+ Orderdet3.Consumable_Arrived_order__c = Order1.Id;
+ //Orderdet3.IsArrival__c = true;
+ Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet3.Bar_Code__c = '33333';
+ Orderdet3.Arrive_date__c = Date.today().addDays(1);
+ Orderdet3.Send_Date__c = null;
+ Orderdet3.Used_date__c = null;
+ Orderdet3.Lose_Flag__c = false;
+ Orderdet3.Box_Piece__c = '涓�';
+ Orderdet3.Sterilization_limit__c = Date.today();
+
+ Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+ Orderdet4.Name = 'OCM_01_001004';
+ //Orderdet4.Consumable_principal__c = Order1.Id;
+ Orderdet4.Consumable_order_minor__c = Order1.Id;
+ Orderdet4.Consumable_Product__c = pro1.Id;
+ Orderdet4.Consumable_Arrived_order__c = Order1.Id;
+ //Orderdet4.IsArrival__c = true;
+ Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet4.Bar_Code__c = '44444';
+ Orderdet4.Arrive_date__c = Date.today().addDays(1);
+ Orderdet4.Send_Date__c = null;
+ Orderdet4.Used_date__c = null;
+ Orderdet4.Lose_Flag__c = false;
+ Orderdet4.Box_Piece__c = '涓�';
+
+ insert new List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ Orderdet3,
+ Orderdet4
+ };
+
+ //鍒朵綔鐩樼偣灞ュ巻
+ List<Consumable_order__c> InsPDlist = new List<Consumable_order__c>();
+ for (integer i = 1; i < 35; i++) {
+ String str = string.valueOf(i);
+ if (str.length() == 1) {
+ str = '0' + str;
+ }
+ Consumable_order__c PDlist = new Consumable_order__c(
+ name = 'testPandianLVL_' + str
+ );
+ //Date ThisDate = Date.newInstance(2016,4,20+i/5);
+ //PDlist.Inventory_date__c = ThisDate;
+ PDlist.Order_type__c = '鐩樼偣';
+ PDlist.RecordTypeid = System.Label.RT_ConOrder_Inventory;
+ PDlist.Inventory_date__c = Date.today().addDays(-i);
+ PDlist.Dealer_Info__c = myAccount1.Id;
+ InsPDlist.add(PDlist);
+ }
+ List<String> orderDetZaikuListLWC = new List<String>();
+ LexInventoryViewController controller = new LexInventoryViewController();
+ Integer pageSizeLWC = 1;
+ Integer pageTokenLWC = 0;
+ String sortFieldLWC = '';
+ String sortOrderLWC = '';
+ String category1 = '3400PK:PK閽� 5mm脳33cm';
+ String Category3 = '鑵硅厰闀滄墜鏈�';
+ String Category4 = 'PK';
+ String Category5 = 'G400';
+ String accountName = '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�';
+ string agencyProType = 'ENG';
+ string userWorkLocation = '娣卞湷';
+ LexInventoryViewController.category1 = category1;
+ LexInventoryViewController.Category3 = Category3;
+ LexInventoryViewController.Category4 = Category4;
+ LexInventoryViewController.Category5 = Category5;
+ LexInventoryViewController.orderDetZaikuList = new List<String>();
+ LexInventoryViewController.init(
+ pageSizeLWC,
+ pageTokenLWC,
+ sortFieldLWC,
+ sortOrderLWC
+ );
+ system.debug(
+ 'order detail:' +
+ JSON.serialize(LexInventoryViewController.orderDetZaikuList)
+ );
+ orderDetZaikuListLWC = LexInventoryViewController.orderDetZaikuList;
+ System.debug('orderDetZaikuListLWC' + orderDetZaikuListLWC);
+ Map<String, Date> productkucunLWC = LexInventoryViewController.productkucun;
+ LexInventoryViewController.searchConsumableorderdetails(
+ category1,
+ '',
+ '',
+ '',
+ orderDetZaikuListLWC,
+ accountName,
+ agencyProType,
+ userWorkLocation,
+ pageSizeLWC,
+ pageTokenLWC,
+ sortFieldLWC,
+ sortOrderLWC,
+ productkucunLWC
+ );
+ LexInventoryViewController.searchConsumableorderdetails(
+ category1,
+ Category3,
+ Category4,
+ Category5,
+ orderDetZaikuListLWC,
+ accountName,
+ agencyProType,
+ userWorkLocation,
+ pageSizeLWC,
+ pageTokenLWC,
+ sortFieldLWC,
+ sortOrderLWC,
+ productkucunLWC
+ );
+ }
+ }
+
+ static testMethod void InventoryViewSearchTest() {
+ user myUser_test;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|2|4,Test02|3|5',
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount1;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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.runAs(myUser_test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Category3__c = 'CDS',
+ Category4__c = 'OER',
+ Category5__c = '鍏跺畠',
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Category3__c = 'ENT',
+ Category4__c = 'Celon',
+ Category5__c = 'Celon',
+ Manual_Entry__c = false
+ );
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Category3__c = 'US',
+ Category4__c = 'ALOKA',
+ Category5__c = '浣撳瓒呭0',
+ Manual_Entry__c = false
+ );
+ Product2 prod04 = new Product2(
+ Name = 'Test04',
+ ProductCode = 'Test04',
+ Asset_Model_No__c = 'Test04',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Category3__c = 'OCS',
+ Category4__c = '闄勫睘鍝�',
+ Category5__c = 'S45',
+ Manual_Entry__c = false
+ );
+ Product2 prod05 = new Product2(
+ Name = 'Test05',
+ ProductCode = 'Test05',
+ Asset_Model_No__c = 'Test05',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Category3__c = '鍏夋簮',
+ Category4__c = '闄勫睘鍝�',
+ Category5__c = 'OCS',
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02, prod03, prod04, prod05 };
+ 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
+ );
+ Product2__c pro3 = new Product2__c(
+ Name = 'Pro003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod03.Id
+ );
+ Product2__c pro4 = new Product2__c(
+ Name = 'Pro004',
+ OT_CODE_Text__c = 'Test004',
+ Product2__c = prod04.Id
+ );
+ Product2__c pro5 = new Product2__c(
+ Name = 'Pro005',
+ OT_CODE_Text__c = 'Test005',
+ Product2__c = prod05.Id
+ );
+ insert new List<Product2__c>{ pro1, pro2, pro3, pro4, pro5 };
+
+ 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_Inventory;
+ Order1.Order_ProType__c = 'ET';
+ insert Order1;
+
+ 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.Consumable_Arrived_order__c = Order1.Id;
+ Orderdet1.Sterilization_limit__c = Date.today();
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet1.Bar_Code__c = '11111';
+ Orderdet1.Arrive_date__c = Date.today().addDays(1);
+ Orderdet1.Send_Date__c = null;
+ Orderdet1.Used_date__c = null;
+ Orderdet1.Lose_Flag__c = false;
+
+ 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.Consumable_Arrived_order__c = Order1.Id;
+ Orderdet2.Sterilization_limit__c = Date.today();
+ Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet2.Bar_Code__c = '22222';
+ Orderdet2.Arrive_date__c = Date.today().addDays(1);
+ Orderdet2.Send_Date__c = null;
+ Orderdet2.Used_date__c = null;
+ Orderdet2.Lose_Flag__c = false;
+ insert new List<Consumable_order_details2__c>{ Orderdet1, Orderdet2 };
+ Integer pageSizeLWC = 1;
+ Integer pageTokenLWC = 0;
+ String sortFieldLWC = '';
+ String sortOrderLWC = '';
+ String category3LWC = 'CDS';
+ String agencyProTypeLWC = 'ENG';
+ String category1 = '3400PK:PK閽� 5mm脳33cm';
+ String Category3 = '鑵硅厰闀滄墜鏈�';
+ String Category4 = 'PK';
+ String Category5 = 'G400';
+ String accountName = '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�';
+ string agencyProType = 'ENG';
+ string userWorkLocation = '娣卞湷';
+ List<String> orderDetZaikuListLWC = new List<String>();
+
+ LexInventoryViewController.init(
+ pageSizeLWC,
+ pageTokenLWC,
+ sortFieldLWC,
+ sortOrderLWC
+ );
+ LexInventoryViewController.categoryAllload(
+ category3LWC,
+ agencyProTypeLWC
+ );
+ LexInventoryViewController.categoryload();
+ // LexInventoryViewController.searchConsumableorderdetails(category1,category3,category4,category5,orderDetZaikuListLWC,accountName,agencyProType,userWorkLocation,pageSizeLWC,pageTokenLWC,sortFieldLWC,sortOrderLWC);
+ }
+ }
+
+ //add by rentx 2020-12-25 start 鏌ヨ闈炲尰闄㈢壒浠风洅 /涓�
+ static testMethod void InventoryViewTest2() {
+ user myUser_test;
+ Account myAccount2;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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閲嶉獙璇�'];
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ]; //20200916 ljh update
+
+ myAccount2 = new Account(
+ name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|5|55,Test02|2|4',
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount2;
+
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '鍖椾含'
+ );
+ insert MyUser_Test;
+ }
+ System.runAs(MyUser_Test) {
+ System.Test.startTest();
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = '12124',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = '12124',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ 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 createId = new Consumable_order__c();
+ createId.Name = 'testMing';
+ createId.Order_status__c = '鎵瑰噯';
+ createId.Deliver_date__c = Date.today();
+ createId.Dealer_Info__c = myAccount2.Id;
+ createId.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ createId.Order_type__c = '璁㈠崟';
+ createId.Order_ProType__c = 'ET';
+ createId.Dealer_Info__c = myAccount2.Id;
+ createId.Delivery_detail_count__c = 5;
+ insert createId;
+ //pro1 鐩� 鍦ㄥ簱
+ List<Consumable_order_details2__c> codListTemp = new List<Consumable_order_details2__c>();
+ Consumable_order_details2__c createDetail2 = new Consumable_order_details2__c();
+ createDetail2 = new Consumable_order_details2__c();
+ createDetail2.Consumable_Product__c = pro1.id;
+ createDetail2.Asset_Model_No__c = 'Test01';
+ createDetail2.Consumable_order_minor__c = createId.id;
+ createDetail2.Consumable_Arrived_order__c = createId.id;
+ createDetail2.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ createDetail2.Asset_Model_No__c = pro1.Asset_Model_No__c;
+ createDetail2.Bar_Code__c = '123';
+ createDetail2.Box_Piece__c = '鐩�';
+ createDetail2.Arrive_date__c = Date.today();
+ codListTemp.add(createDetail2);
+ //insert createDetail2;
+ Consumable_order_details2__c createDetailpro1 = new Consumable_order_details2__c();
+ createDetailpro1.Consumable_Product__c = pro1.id;
+ createDetailpro1.Asset_Model_No__c = 'Test02';
+ createDetailpro1.Consumable_order_minor__c = createId.id;
+ createDetailpro1.Consumable_Arrived_order__c = createId.id;
+ createDetailpro1.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ createDetailpro1.Asset_Model_No__c = pro1.Asset_Model_No__c;
+ createDetailpro1.Bar_Code__c = '12322';
+ createDetailpro1.Box_Piece__c = '鐩�';
+ createDetailpro1.Arrive_date__c = Date.today();
+ codListTemp.add(createDetailpro1);
+ //insert createDetailpro1;
+ //pro1 涓� 鍦ㄥ簱
+ Consumable_order_details2__c createDetailPiece1 = new Consumable_order_details2__c();
+ createDetailPiece1.Consumable_Product__c = pro1.id;
+ createDetailPiece1.Asset_Model_No__c = 'Test03';
+ createDetailPiece1.Consumable_order_minor__c = createId.id;
+ createDetailPiece1.Consumable_Arrived_order__c = createId.id;
+ createDetailPiece1.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ createDetailPiece1.Asset_Model_No__c = pro1.Asset_Model_No__c;
+ createDetailPiece1.Bar_Code__c = '23456';
+ createDetailPiece1.Box_Piece__c = '涓�';
+ createDetailPiece1.Arrive_date__c = Date.today();
+ codListTemp.add(createDetailPiece1);
+ //insert createDetailPiece1;
+ Consumable_order_details2__c createDetailPiece2 = new Consumable_order_details2__c();
+ createDetailPiece2.Consumable_Product__c = pro1.id;
+ createDetailPiece2.Asset_Model_No__c = 'Test04';
+ createDetailPiece2.Consumable_order_minor__c = createId.id;
+ createDetailPiece2.Consumable_Arrived_order__c = createId.id;
+ createDetailPiece2.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ createDetailPiece2.Asset_Model_No__c = pro1.Asset_Model_No__c;
+ createDetailPiece2.Bar_Code__c = '122345';
+ createDetailPiece2.Box_Piece__c = '涓�';
+ createDetailPiece2.Arrive_date__c = Date.today();
+ codListTemp.add(createDetailPiece2);
+ //insert createDetailPiece2;
+
+ //pro1 鐩� 鍦ㄥ簱 杩囨湡
+ Consumable_order_details2__c createDetail21 = new Consumable_order_details2__c();
+ createDetail21.Consumable_Product__c = pro1.id;
+ createDetail21.Asset_Model_No__c = 'Test01';
+ createDetail21.Sterilization_limit__c = Date.today();
+ createDetail21.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ //createDetail.IsArrival__c = true;
+ createDetail21.Asset_Model_No__c = prod02.Asset_Model_No__c;
+ createDetail21.Bar_Code__c = '1223';
+ createDetail21.Box_Piece__c = '鐩�';
+ createDetail21.Arrive_date__c = Date.today();
+ createDetail21.Deliver_date__c = Date.today().addDays(-8);
+ createDetail21.Sterilization_limit__c = Date.today().addDays(-8);
+ codListTemp.add(createDetail21);
+ //insert createDetail2;
+ insert codListTemp;
+
+ PageReference page = new PageReference('/apex/TopPage');
+ System.Test.setCurrentPage(page);
+ TopPageController lPCTest = new TopPageController();
+ lPCTest.pagesize = 1;
+ List<Consumable_Orderdetails__c> coListTest = new List<Consumable_Orderdetails__c>();
+ Consumable_Orderdetails__c conOrderDetail1 = new Consumable_Orderdetails__c();
+ conOrderDetail1.Consumable_count__c = 10;
+ conOrderDetail1.Consumable_Arrivecount__c = 5;
+ conOrderDetail1.Consumable_product__c = pro2.id;
+ conOrderDetail1.Consumable_order__c = createId.Id;
+ coListTest.add(conOrderDetail1);
+
+ Consumable_Orderdetails__c conOrderDetail2 = new Consumable_Orderdetails__c();
+ conOrderDetail2.Consumable_product__c = pro2.id;
+ conOrderDetail2.Consumable_order__c = createId.Id;
+ coListTest.add(conOrderDetail2);
+ insert coListTest;
+
+ Integer pageSizeLWC = 1;
+ Integer pageTokenLWC = 0;
+ String sortFieldLWC = '';
+ String sortOrderLWC = '';
+ String category3LWC = 'CDS';
+ String agencyProTypeLWC = 'ENG';
+ // LexInventoryViewController.init(pageSizeLWC,pageTokenLWC,sortFieldLWC,sortOrderLWC);
+ LexInventoryViewController.categoryAllload(
+ 'CDS',
+ '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�'
+ );
+ LexInventoryViewController.categoryload();
+ LexInventoryViewController.categoryAllload(
+ '鍏夋簮',
+ '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�'
+ );
+ LexInventoryViewController.categoryload();
+ System.Test.stopTest();
+ }
+ }
+
+ static testMethod void InventoryViewTest3() {
+ user myUser_test;
+ Account myAccount2;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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閲嶉獙璇�'];
+ // Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(Email)'];//20200916 ljh update
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET Email)'
+ ]; //20210329 RTX update
+
+ myAccount2 = new Account(
+ name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|5|55,Test02|2|4',
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount2;
+
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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 = 'ENG',
+ Work_Location__c = '鍖椾含'
+ );
+ insert MyUser_Test;
+ }
+
+ System.runAs(MyUser_Test) {
+ System.Test.startTest();
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = '12124',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = '12124',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ 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 createId = new Consumable_order__c();
+ createId.Name = 'testMing1';
+ createId.Order_status__c = '鎵瑰噯';
+ createId.Deliver_date__c = Date.today();
+ createId.Dealer_Info__c = myAccount2.Id;
+ createId.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ createId.Order_type__c = '璁㈠崟';
+ createId.Order_ProType__c = 'ENG';
+ createId.Dealer_Info__c = myAccount2.Id;
+ createId.Delivery_detail_count__c = 5;
+ createId.orderPattern__c = 'hospitalorder';
+ insert createId;
+ //pro1 鐩� 鍦ㄥ簱
+ Consumable_order_details2__c createDetail2 = new Consumable_order_details2__c();
+ createDetail2.Consumable_Product__c = pro1.id;
+ createDetail2.Asset_Model_No__c = 'Test01';
+ createDetail2.Consumable_order_minor__c = createId.id;
+ createDetail2.Consumable_Arrived_order__c = createId.id;
+ createDetail2.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ createDetail2.Asset_Model_No__c = pro1.Asset_Model_No__c;
+ createDetail2.Bar_Code__c = '123';
+ createDetail2.Box_Piece__c = '鐩�';
+ createDetail2.Arrive_date__c = Date.today();
+ insert createDetail2;
+ List<Consumable_order_details2__c> codListTemp = new List<Consumable_order_details2__c>();
+ Consumable_order_details2__c createDetailpro1 = new Consumable_order_details2__c();
+ createDetailpro1.Consumable_Product__c = pro1.id;
+ createDetailpro1.Asset_Model_No__c = 'Test02';
+ createDetailpro1.Consumable_order_minor__c = createId.id;
+ createDetailpro1.Consumable_Arrived_order__c = createId.id;
+ createDetailpro1.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ createDetailpro1.Asset_Model_No__c = pro1.Asset_Model_No__c;
+ createDetailpro1.Bar_Code__c = '12322';
+ createDetailpro1.Box_Piece__c = '鐩�';
+ createDetailpro1.Arrive_date__c = Date.today();
+ //insert createDetailpro1;
+ codListTemp.add(createDetailpro1);
+ //pro1 涓� 鍦ㄥ簱
+ Consumable_order_details2__c createDetailPiece1 = new Consumable_order_details2__c();
+ createDetailPiece1.Consumable_Product__c = pro1.id;
+ createDetailPiece1.Asset_Model_No__c = 'Test03';
+ createDetailPiece1.Consumable_order_minor__c = createId.id;
+ createDetailPiece1.Consumable_Arrived_order__c = createId.id;
+ createDetailPiece1.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ createDetailPiece1.Asset_Model_No__c = pro1.Asset_Model_No__c;
+ createDetailPiece1.Bar_Code__c = '23456';
+ createDetailPiece1.Box_Piece__c = '涓�';
+ createDetailPiece1.Arrive_date__c = Date.today();
+ codListTemp.add(createDetailPiece1);
+ //insert createDetailPiece1;
+ Consumable_order_details2__c createDetailPiece2 = new Consumable_order_details2__c();
+ createDetailPiece2.Consumable_Product__c = pro1.id;
+ createDetailPiece2.Asset_Model_No__c = 'Test04';
+ createDetailPiece2.Consumable_order_minor__c = createId.id;
+ createDetailPiece2.Consumable_Arrived_order__c = createId.id;
+ createDetailPiece2.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ createDetailPiece2.Asset_Model_No__c = pro1.Asset_Model_No__c;
+ createDetailPiece2.Bar_Code__c = '122345';
+ createDetailPiece2.Box_Piece__c = '涓�';
+ createDetailPiece2.Arrive_date__c = Date.today();
+ codListTemp.add(createDetailPiece2);
+ //insert createDetailPiece2;
+
+ //pro1 鐩� 鍦ㄥ簱 杩囨湡
+ Consumable_order_details2__c createDetail21 = new Consumable_order_details2__c();
+ createDetail21.Consumable_Product__c = pro1.id;
+ createDetail21.Asset_Model_No__c = 'Test01';
+ createDetail21.Sterilization_limit__c = Date.today();
+ createDetail21.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ //createDetail.IsArrival__c = true;
+ createDetail21.Asset_Model_No__c = prod02.Asset_Model_No__c;
+ createDetail21.Bar_Code__c = '1223';
+ createDetail21.Box_Piece__c = '鐩�';
+ createDetail21.Arrive_date__c = Date.today();
+ createDetail21.Deliver_date__c = Date.today().addDays(-8);
+ createDetail21.Sterilization_limit__c = Date.today().addDays(-8);
+ codListTemp.add(createDetail21);
+ //insert createDetail21;
+ insert codListTemp;
+
+ PageReference page = new PageReference('/apex/TopPage');
+ System.Test.setCurrentPage(page);
+ TopPageController lPCTest = new TopPageController();
+ lPCTest.pagesize = 1;
+ List<Consumable_Orderdetails__c> coListTest = new List<Consumable_Orderdetails__c>();
+ Consumable_Orderdetails__c conOrderDetail1 = new Consumable_Orderdetails__c();
+ conOrderDetail1.Consumable_count__c = 10;
+ conOrderDetail1.Consumable_Arrivecount__c = 5;
+ conOrderDetail1.Consumable_product__c = pro2.id;
+ conOrderDetail1.Consumable_order__c = createId.Id;
+ coListTest.add(conOrderDetail1);
+
+ Consumable_Orderdetails__c conOrderDetail2 = new Consumable_Orderdetails__c();
+ conOrderDetail2.Consumable_product__c = pro2.id;
+ conOrderDetail2.Consumable_order__c = createId.Id;
+ coListTest.add(conOrderDetail2);
+ insert coListTest;
+
+ Integer pageSizeLWC = 1;
+ Integer pageTokenLWC = 0;
+ String sortFieldLWC = '';
+ String sortOrderLWC = '';
+ String category1 = '3400PK:PK閽� 5mm脳33cm';
+ String Category3 = '鑵硅厰闀滄墜鏈�';
+ String Category4 = 'PK';
+ String Category5 = 'G400';
+ List<String> orderDetZaikuListLWC = new List<String>();
+ String accountName = '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�';
+ string agencyProType = 'ET';
+ string userWorkLocation = '娣卞湷';
+ LexInventoryViewController.category1 = category1;
+ LexInventoryViewController.Category3 = Category3;
+ LexInventoryViewController.Category4 = Category4;
+ LexInventoryViewController.Category5 = Category5;
+ // LexInventoryViewController.init(pageSizeLWC,pageTokenLWC,sortFieldLWC,sortOrderLWC);
+ // LexInventoryViewController.searchConsumableorderdetails(category1,category3,category4,category5,orderDetZaikuListLWC,accountName,agencyProType,userWorkLocation,pageSizeLWC,pageTokenLWC,sortFieldLWC,sortOrderLWC);
+ LexInventoryViewController.categoryAllload(
+ 'CDS',
+ '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�'
+ );
+ LexInventoryViewController.categoryload();
+ LexInventoryViewController.categoryAllload(
+ '鍏夋簮',
+ '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�'
+ );
+ LexInventoryViewController.categoryload();
+ }
+ }
+ static testMethod void InventoryViewTest4() {
+ user myUser_test;
+ Account myAccount2;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ]; //20210329 RTX update
+
+ myAccount2 = new Account(
+ name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|5|55,Test02|2|4',
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount2;
+
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '娴庡崡'
+ );
+ insert MyUser_Test;
+ }
+ System.runAs(MyUser_Test) {
+ Integer pageSizeLWC = 1;
+ Integer pageTokenLWC = 0;
+ String sortFieldLWC = '';
+ String sortOrderLWC = '';
+ String category1 = '3400PK:PK閽� 5mm脳33cm';
+ String Category3 = '鑵硅厰闀滄墜鏈�';
+ String Category4 = 'PK';
+ String Category5 = 'G400';
+ String accountName = 'Testaccount002';
+ string agencyProType = 'ET';
+ string userWorkLocation = '娴庡崡';
+ List<String> orderDetZaikuListLWC = new List<String>();
+ List<String> productCodeList = new List<String>();
+
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = '12124',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = '12124',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ 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 = myAccount2.Id;
+ Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ Order1.Order_ProType__c = 'ENG';
+ insert Order1;
+ Consumable_order__c Order2 = new Consumable_order__c();
+ Order2.Name = 'OCM_01_003';
+ Order2.Order_status__c = '鎵瑰噯';
+ Order2.Order_type__c = '璁㈠崟';
+ Order2.Dealer_Info__c = myAccount2.Id;
+ Order2.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ Order2.Order_ProType__c = 'ET';
+ insert Order2;
+ List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
+
+ Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+ Orderdet2.Name = 'OCM_01_001002';
+ //Orderdet2.Consumable_principal__c = Order1.Id;
+ Orderdet2.Consumable_order_minor__c = Order1.Id;
+ Orderdet2.Consumable_Product__c = pro1.Id;
+ Orderdet2.Consumable_Arrived_order__c = Order1.Id;
+ //Orderdet2.IsArrival__c = true;
+ Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet2.Bar_Code__c = '22222';
+ Orderdet2.Arrive_date__c = Date.today().addDays(1);
+ Orderdet2.Send_Date__c = null;
+ Orderdet2.Used_date__c = Date.today();
+ Orderdet2.Lose_Flag__c = false;
+ Orderdet2.Box_Piece__c = '涓�';
+ Orderdet2.Sterilization_limit__c = Date.today();
+ Orderdet2.Return_date__c = Date.today();
+ Orderdet2.Bar_Code__c = '1683272847250250WZIOF';
+ Orderdet2.Cancellation_Flag__c = false;
+ conList.add(Orderdet2);
+
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+ Orderdet3.Arrive_date__c = Date.today();
+ Orderdet3.Send_Date__c = null;
+ Orderdet3.Used_date__c = null;
+ Orderdet3.Return_date__c = null;
+ Orderdet3.Lose_Flag__c = false;
+ Orderdet3.Cancellation_Flag__c = false;
+ Orderdet3.Bar_Code__c = '1234';
+ Orderdet3.Consumable_order_minor__c = Order2.Id;
+ Orderdet2.Consumable_Product__c = pro1.Id;
+ Orderdet3.Consumable_Arrived_order__c = Order2.Id;
+ Orderdet3.Recordtypeid = '01210000000kUDKAA2';
+ Orderdet3.Sterilization_limit__c = Date.today().addDays(1);
+ conList.add(Orderdet3);
+ insert conList;
+ System.debug('conList==>' + conList);
+
+ LexInventoryViewController.category1 = category1;
+ LexInventoryViewController.Category3 = Category3;
+ LexInventoryViewController.Category4 = Category4;
+ LexInventoryViewController.Category5 = Category5;
+ // LexInventoryViewController.init(pageSizeLWC,pageTokenLWC,sortFieldLWC,sortOrderLWC);
+ Map<String, Date> productkucunLWC = LexInventoryViewController.productkucun;
+ LexInventoryViewController.searchConsumableorderdetails(
+ category1,
+ category3,
+ category4,
+ category5,
+ orderDetZaikuListLWC,
+ accountName,
+ agencyProType,
+ userWorkLocation,
+ pageSizeLWC,
+ pageTokenLWC,
+ sortFieldLWC,
+ sortOrderLWC,
+ productkucunLWC
+ );
+ LexInventoryViewController.categoryAllload(
+ 'CDS',
+ '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�'
+ );
+ LexInventoryViewController.categoryload();
+ LexInventoryViewController.categoryAllload(
+ '鍏夋簮',
+ '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�'
+ );
+ LexInventoryViewController.categoryload();
+ // LexInventoryViewController.searchConsumableorderdetails(category1,category3,category4,category5,orderDetZaikuListLWC ,accountName,agencyProType,
+ // userWorkLocation,pageSizeLWC,pageTokenLWC,sortFieldLWC,sortOrderLWC);
+ }
+
+ }
+ static testMethod void supplementTest() {
+ user myUser_test;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ List<RecordType> rectHos = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectHos.size() == 0) {
+ return;
+ }
+
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|2|4,Test02|3|5',
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount1;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '娣卞湷'
+ );
+ insert myUser_test;
+ }
+ System.runAs(myUser_test) {
+ Product2 prod05 = new Product2(
+ Name = '3400PK:PK閽� 5mmx33cm',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = '3400PK:PK閽� 5mmx33cm',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test001',
+ Packing_list_manual__c = 1,
+ SFDA_Expiration_Date__c = Date.today(),
+ Manual_Entry__c = false
+ );
+ Product2 prod06 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test002',
+ Packing_list_manual__c = 12,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'tset',
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod05, prod06 };
+ Product2__c pro11 = new Product2__c(
+ Name = 'Pro001',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod05.Id,
+ Category3_text__c = '鍒嗙被3'
+ );
+ Product2__c pro22 = new Product2__c(
+ Name = 'Pro002',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod06.Id
+ );
+ insert new List<Product2__c>{ pro11, pro22 };
+ System.debug('pro11===>' + pro11);
+
+ List<Consumable_order__c> orderList = new List<Consumable_order__c>();
+ //鍙戣揣
+ Consumable_order__c Order4 = new Consumable_order__c();
+ Order4.Name = 'OCM_0122';
+ Order4.Order_status__c = '鎵瑰噯';
+ Order4.Order_type__c = '璁㈠崟';
+ Order4.Dealer_Info__c = myAccount1.Id;
+ Order4.RecordTypeid = '01210000000c9drAAA';
+ Order4.Order_ProType__c = 'ET';
+ Order4.ContractNo__c = '';
+ orderList.add(Order4);
+ insert orderList;
+
+ List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
+ //orderDetZaiku init
+ Consumable_order_details2__c con1 = new Consumable_order_details2__c();
+ con1.Arrive_date__c = Date.today();
+ con1.Send_Date__c = null;
+ con1.Used_date__c = null;
+ con1.Return_date__c = null;
+ con1.Lose_Flag__c = false;
+ con1.Cancellation_Flag__c = false;
+ con1.Bar_Code__c = '1234';
+ // con1.Consumable_order_minor__c = Order2.Id;
+ con1.Consumable_Product__c = pro11.Id;
+ con1.Consumable_Arrived_order__c = Order4.Id;
+ con1.Recordtypeid = '01210000000kUDKAA2';
+ // con1.Sterilization_limit__c = Date.today().addDays(1);
+ conList.add(con1);
+
+ Consumable_order_details2__c con2 = new Consumable_order_details2__c();
+ con2.Arrive_date__c = Date.today();
+ con2.Send_Date__c = null;
+ con2.Used_date__c = null;
+ con2.Return_date__c = null;
+ con2.Lose_Flag__c = false;
+ con2.Cancellation_Flag__c = false;
+ con2.Bar_Code__c = '1234';
+ // con1.Consumable_order_minor__c = Order2.Id;
+ con2.Consumable_Product__c = pro11.Id;
+ con2.Consumable_Arrived_order__c = Order4.Id;
+ con2.Recordtypeid = '01210000000kUDKAA2';
+ con2.Box_Piece__c = '涓�';
+ // con1.Sterilization_limit__c = Date.today().addDays(1);
+ conList.add(con2);
+
+ insert conList;
+
+ LexInventoryViewController.ESetId = '1111';
+ LexInventoryViewController.idCheck = '2222';
+ List<String> orderDetZaikuListLWC = new List<String>();
+ LexInventoryViewController.init(1, 0, '', '');
+ orderDetZaikuListLWC = LexInventoryViewController.orderDetZaikuList;
+ LexInventoryViewController.categoryAllload(
+ 'CDS',
+ '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�'
+ );
+ LexInventoryViewController.categoryload();
+ LexInventoryViewController.categoryAllload(
+ '鍏夋簮',
+ '鎹峰皵鍖荤枟(娴峰崡锛夋湁闄愬叕鍙�'
+ );
+ LexInventoryViewController.categoryload();
+ Map<String, Date> productkucunLWC = LexInventoryViewController.productkucun;
+ LexInventoryViewController.searchConsumableorderdetails(
+ '3400PK:PK閽� 5mmx33cm',
+ '',
+ '',
+ '',
+ orderDetZaikuListLWC,
+ 'testaccount001',
+ 'ET',
+ '娣卞湷',
+ 1,
+ 0,
+ '',
+ '',
+ productkucunLWC
+ );
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexInventoryViewControllerTest.cls-meta.xml b/force-app/main/default/classes/LexInventoryViewControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexInventoryViewControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexLicenceReminderControllerTest.cls b/force-app/main/default/classes/LexLicenceReminderControllerTest.cls
new file mode 100644
index 0000000..d3aded3
--- /dev/null
+++ b/force-app/main/default/classes/LexLicenceReminderControllerTest.cls
@@ -0,0 +1,226 @@
+@IsTest
+private class LexLicenceReminderControllerTest {
+ @IsTest
+ static void testMethod1() {
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ LicenceReminderDate__c l = new LicenceReminderDate__c(
+ Name = '180Days',
+ ReminderDays__c = 180
+ );
+ insert l;
+ Test.startTest();
+ System.runAs(currentUser) {
+ LexLicenceReminderController.initReminder();
+ }
+ Test.stopTest();
+ }
+
+ @IsTest
+ static void testMethod2() {
+ Account myAccount1 = new Account();
+ Contact core = new Contact();
+ User myUser_test = new User();
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ LicenceReminderDate__c l = new LicenceReminderDate__c(
+ Name = '180Days',
+ ReminderDays__c = 180
+ );
+ insert l;
+ System.runAs(currentUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ List<RecordType> rectHos = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectHos.size() == 0) {
+ return;
+ }
+
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|2|4,Test02|3|5',
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount1;
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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;
+ }
+ Test.startTest();
+ System.runAs(myUser_test) {
+ LexLicenceReminderController.initReminder();
+ }
+ Test.stopTest();
+ }
+
+ @IsTest
+ static void testMethod3() {
+ Account myAccount1 = new Account();
+ Contact core = new Contact();
+ User myUser_test = new User();
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ LicenceReminderDate__c l = new LicenceReminderDate__c(
+ Name = '180Days',
+ ReminderDays__c = 180
+ );
+ insert l;
+ System.runAs(currentUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ List<RecordType> rectHos = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectHos.size() == 0) {
+ return;
+ }
+
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|2|4,Test02|3|5',
+ AgentCode_Ext__c = '9999900',
+ Medical_Equipment_Expiration_Date__c = Date.newInstance(2023, 6, 10)
+ );
+ insert myAccount1;
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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;
+ }
+ Test.startTest();
+ System.runAs(myUser_test) {
+ LexLicenceReminderController.initReminder();
+ }
+ Test.stopTest();
+ }
+
+ @IsTest
+ static void testMethod4() {
+ Account myAccount1 = new Account();
+ Contact core = new Contact();
+ User myUser_test = new User();
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ LicenceReminderDate__c l = new LicenceReminderDate__c(
+ Name = '180Days',
+ ReminderDays__c = 180
+ );
+ insert l;
+ System.runAs(currentUser) {
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ List<RecordType> rectHos = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectHos.size() == 0) {
+ return;
+ }
+
+ myAccount1 = new Account(
+ name = 'testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|2|4,Test02|3|5',
+ AgentCode_Ext__c = '9999900',
+ Medical_Equipment_Expiration_Date__c = Date.newInstance(2025, 6, 10)
+ );
+ insert myAccount1;
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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;
+ }
+ Test.startTest();
+ System.runAs(myUser_test) {
+ LexLicenceReminderController.initReminder();
+ }
+ Test.stopTest();
+ }
+}
diff --git a/force-app/main/default/classes/LexLicenceReminderControllerTest.cls-meta.xml b/force-app/main/default/classes/LexLicenceReminderControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexLicenceReminderControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexOutboundorderImportController.cls b/force-app/main/default/classes/LexOutboundorderImportController.cls
index a1f00f6..af454e1 100644
--- a/force-app/main/default/classes/LexOutboundorderImportController.cls
+++ b/force-app/main/default/classes/LexOutboundorderImportController.cls
@@ -1,919 +1,1054 @@
public without sharing class LexOutboundorderImportController {
- //缁忛攢鍟嗕骇鍝佸垎绫�
- public static String agencyProType { get; set; }
- private static String sqlagencyProType;
- public static Blob csvFileBody { get; set; }
- public static string csvAsString { get; set; }
- public static String[] csvFileLines { get; set; }
- public static List<ConsumableorderdetailsInfo> orderRecords { get; set; }
- public static List<String[]> csvRecordStr { get; set; }
- public static Map<String, String> hospitalconMap { get; set; }
- public static Map<String, String> product2conMap { get; set; }
- public static Map<String, String> hospitalSysMap { get; set; }
- public static Map<String, String> secondAgencyMap { get; set; }
- private static String accountid { get; set; }
- private static String accountName { get; set; }
- private static Integer messageCount;
- public static boolean saveFLGbln { get; set; }
- private static List<String> barcodeList { get; set; }
- private static List<String> barcodePieceList { get; set; }
- public static Map<String, Integer> barcodePieceMap { get; set; }
- public static boolean errorflg { get; set; }
- public static String errorMessage { get; set; }
- private static String userWorkLocation { get; set; }
- public static String errorMsg { get; set; }
+ //缁忛攢鍟嗕骇鍝佸垎绫�
+ public static String agencyProType { get; set; }
+ private static String sqlagencyProType;
+ public static Blob csvFileBody { get; set; }
+ public static string csvAsString { get; set; }
+ public static String[] csvFileLines { get; set; }
+ public static List<ConsumableorderdetailsInfo> orderRecords { get; set; }
+ public static List<String[]> csvRecordStr { get; set; }
+ public static Map<String, String> hospitalconMap { get; set; }
+ public static Map<String, String> product2conMap { get; set; }
+ public static Map<String, String> hospitalSysMap { get; set; }
+ public static Map<String, String> secondAgencyMap { get; set; }
+ private static String accountid { get; set; }
+ private static String accountName { get; set; }
+ private static Integer messageCount;
+ public static boolean saveFLGbln { get; set; }
+ private static List<String> barcodeList { get; set; }
+ private static List<String> barcodePieceList { get; set; }
+ public static Map<String, Integer> barcodePieceMap { get; set; }
+ public static boolean errorflg { get; set; }
+ public static String errorMessage { get; set; }
+ private static String userWorkLocation { get; set; }
+ public static String errorMsg { get; set; }
- @AuraEnabled
- public static ResponseBodyLWC init() {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- messageCount = 0;
- errorflg = false;
- errorMessage = null;
- User useracc = [SELECT accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :UserInfo.getUserId()];
- accountid = Useracc.accountid;
- userWorkLocation = Useracc.Work_Location__c;
- agencyProType = Useracc.UserPro_Type__c;
- if (String.isBlank(Useracc.UserPro_Type__c)) {
- agencyProType = 'ET';
- }
- sqlagencyProType = '%' + agencyProType + '%';
- Account accountInfo = [SELECT Name FROM account WHERE id = :accountid];
- accountName = accountInfo.name;
-
- data.put('accountid', accountid);
- data.put('userWorkLocation', userWorkLocation);
- data.put('agencyProType', agencyProType);
- data.put('accountName', accountName);
- data.put('sqlagencyProType', sqlagencyProType);
- res.status = 'Success';
- res.code = 200;
- res.msg = '';
- return res;
+ @AuraEnabled
+ public static ResponseBodyLWC init() {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ messageCount = 0;
+ errorflg = false;
+ errorMessage = null;
+ User useracc = [
+ SELECT accountid, Work_Location__c, UserPro_Type__c
+ FROM user
+ WHERE id = :UserInfo.getUserId()
+ ];
+ accountid = Useracc.accountid;
+ userWorkLocation = Useracc.Work_Location__c;
+ agencyProType = Useracc.UserPro_Type__c;
+ if (String.isBlank(Useracc.UserPro_Type__c)) {
+ agencyProType = 'ET';
}
+ sqlagencyProType = '%' + agencyProType + '%';
+ Account accountInfo = [SELECT Name FROM account WHERE id = :accountid];
+ accountName = accountInfo.name;
- @AuraEnabled
- public static ResponseBodyLWC importCSVFile(
- String base64DataLwc,
- String sqlagencyProTypeLwc,
- String userWorkLocationLwc,
- String accountNameLwc
- ) {
- System.debug('enter importCSVFile');
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
+ data.put('accountid', accountid);
+ data.put('userWorkLocation', userWorkLocation);
+ data.put('agencyProType', agencyProType);
+ data.put('accountName', accountName);
+ data.put('sqlagencyProType', sqlagencyProType);
+ res.status = 'Success';
+ res.code = 200;
+ res.msg = '';
+ System.debug('res:' + res);
+ return res;
+ }
- errorMsg = '';
- sqlagencyProType = sqlagencyProTypeLwc;
- userWorkLocation = userWorkLocationLwc;
- accountName = accountNameLwc;
- String base64Data = EncodingUtil.urlDecode(base64DataLwc, 'UTF-8');
- csvFileBody = EncodingUtil.base64Decode(base64Data);
- product2conMap = new Map<String, String>();
+ @AuraEnabled
+ public static ResponseBodyLWC importCSVFile(
+ String base64DataLwc,
+ String sqlagencyProTypeLwc,
+ String userWorkLocationLwc,
+ String accountNameLwc
+ ) {
+ System.debug('enter importCSVFile');
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
- messageCount = 0;
- errormessage = null;
- saveFLGbln = false;
- csvRecordStr = new List<String[]>();
- barcodeList = new List<String>();
- barcodePieceMap = new Map<String, Integer>();
- barcodePieceList = new List<String>();
- orderRecords = new List<ConsumableorderdetailsInfo>();
- hospitalconMap = new Map<String, String>();
- if (csvFileBody == null) {
- errorflg = true;
+ errorMsg = '';
+ sqlagencyProType = sqlagencyProTypeLwc;
+ userWorkLocation = userWorkLocationLwc;
+ accountName = accountNameLwc;
+ String base64Data = EncodingUtil.urlDecode(base64DataLwc, 'UTF-8');
+ csvFileBody = EncodingUtil.base64Decode(base64Data);
+ product2conMap = new Map<String, String>();
+
+ messageCount = 0;
+ errormessage = null;
+ saveFLGbln = false;
+ csvRecordStr = new List<String[]>();
+ barcodeList = new List<String>();
+ barcodePieceMap = new Map<String, Integer>();
+ barcodePieceList = new List<String>();
+ orderRecords = new List<ConsumableorderdetailsInfo>();
+ hospitalconMap = new Map<String, String>();
+ if (csvFileBody == null) {
+ errorflg = true;
+ saveFLGbln = true;
+ // errormessage = '璇诲彇鍐呭涓虹┖銆�';
+ return new ResponseBodyLWC('Error', 500, '璇诲彇鍐呭涓虹┖銆�', '');
+ } else {
+ //浜у搧鏁版嵁鏌ユ壘
+ map<string, string> orderNameMap = new Map<string, string>();
+ try {
+ csvAsString = csvFileBody.toString();
+ csvFileLines = csvAsString.split('\n');
+ for (Integer i = 0; i < csvFileLines.size(); i++) {
+ string[] csvRecordData = csvFileLines[i].split(',');
+ if (String.isNotBlank(csvRecordData[6])) {
+ barcodeList.add(csvRecordData[6]);
+ if (String.valueOf(csvRecordData[9]) == '涓�') {
+ barcodePieceList.add(csvRecordData[6]);
+ barcodePieceMap.put(
+ csvRecordData[6],
+ Integer.valueOf(csvRecordData[7])
+ );
+ }
+ }
+ String[] csvRecordDataStr = new String[13];
+ for (Integer j = 0; j < csvRecordData.size(); j++) {
+ csvRecordDataStr[j] = csvRecordData[j];
+ }
+ if (i == 0) {
+ csvRecordDataStr[12] = '浜у搧';
+ } else {
+ csvRecordDataStr[12] = '';
+ }
+ csvRecordStr.add(csvRecordDataStr);
+ }
+ Map<String, String> productBarcodeMap = new Map<String, String>();
+ List<Consumable_order_details2__c> cOrderDet = [
+ SELECT Id, Bar_Code__c, Name, Consumable_Product__c, Box_Piece__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 Bar_Code__c IN :barcodeList
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Dealer_Info_text__c = :accountName
+ ];
+ for (Consumable_order_details2__c pdinfo : cOrderDet) {
+ productBarcodeMap.put(
+ pdinfo.Bar_Code__c,
+ pdinfo.Consumable_Product__c
+ );
+ }
+ for (String[] csvlistStr : csvRecordStr) {
+ if (productBarcodeMap.containsKey(csvlistStr[6])) {
+ csvlistStr[12] = productBarcodeMap.get(csvlistStr[6]);
+ } else {
+ }
+ }
+ //妫�绱㈠瓨鍦ㄦ媶鐩掍骇鍝佹暟閲�
+ Map<String, Integer> exitpieceBarcodeMap = new Map<String, Integer>();
+ AggregateResult[] pieceOrderDet = [
+ SELECT count(Id) cnt, Bar_Code__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 Bar_Code__c IN :barcodePieceList
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Dealer_Info_text__c = :accountName
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Box_Piece__c = '涓�'
+ GROUP BY Bar_Code__c
+ ];
+ for (AggregateResult ar : pieceOrderDet) {
+ exitpieceBarcodeMap.put(
+ String.valueOf(ar.get('Bar_Code__c')),
+ Integer.valueOf(ar.get('cnt'))
+ );
+ }
+ for (String bc : barcodePieceList) {
+ if (!exitpieceBarcodeMap.containsKey(bc)) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(ApexPages.severity.ERROR, 'Barcode ' + bc + ' 涓嶅瓨鍦ㄦ垨鍗曚綅閿欒锛岃纭銆�')
+ // );
+ errorMsg += 'Barcode ' + bc + ' 涓嶅瓨鍦ㄦ垨鍗曚綅閿欒锛岃纭銆�<br />';
saveFLGbln = true;
- // errormessage = '璇诲彇鍐呭涓虹┖銆�';
- return new ResponseBodyLWC('Error', 500, '璇诲彇鍐呭涓虹┖銆�', '');
+ messageCount++;
+ } else if (
+ exitpieceBarcodeMap.containsKey(bc) &&
+ exitpieceBarcodeMap.get(bc) < barcodePieceMap.get(bc)
+ ) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'Barcode ' + bc + ' 搴撳瓨涓嶈冻锛岃纭銆�'));
+ errorMsg += 'Barcode ' + bc + ' 搴撳瓨涓嶈冻锛岃纭銆�<br />';
+ saveFLGbln = true;
+ messageCount++;
+ }
+ }
+ } catch (Exception e) {
+ //ApexPages.addMessages(e);
+ errorMsg += e.getMessage() + ' ' + e.getLineNumber() + ';';
+ //return new ResponseBodyLWC('Error', 500, e.getMessage()+e.getStackTraceString(), '');
+ }
+ getorderinfo();
+ dataInfoconfim();
+ getorderdet2info(csvRecordStr);
+ if (saveFLGbln == false) {
+ getorderdetinfo(csvRecordStr);
+ }
+ data.put('orderRecords', orderRecords);
+ data.put('saveFLGbln', saveFLGbln);
+ data.put('csvRecordStr', csvRecordStr);
+ data.put('barcodeList', barcodeList);
+ data.put('secondAgencyMap', secondAgencyMap);
+ data.put('hospitalSysMap', hospitalSysMap);
+ res.status = 'Success';
+ res.code = 200;
+ res.msg = errorMsg;
+ return res;
+ }
+ }
+
+ public static void getorderinfo() {
+ map<string, string> orderNameMap = new Map<string, string>();
+ try {
+ csvAsString = csvFileBody.toString();
+ csvFileLines = csvAsString.split('\n');
+ for (Integer i = 1; i < csvFileLines.size(); i++) {
+ Consumable_order__c cocObj = new Consumable_order__c();
+ string[] csvRecordData = csvFileLines[i].split(',');
+ if (orderNameMap.containsKey(csvRecordData[0]))
+ continue;
+ cocObj.Name = csvRecordData[0];
+ if (String.isNotBlank(csvRecordData[1])) {
+ cocObj.SummonsForDirction__c = csvRecordData[1];
} else {
- //浜у搧鏁版嵁鏌ユ壘
- map<string, string> orderNameMap = new Map<string, string>();
- try {
- csvAsString = csvFileBody.toString();
- csvFileLines = csvAsString.split('\n');
- for (Integer i = 0; i < csvFileLines.size(); i++) {
- string[] csvRecordData = csvFileLines[i].split(',');
- if (String.isNotBlank(csvRecordData[6])) {
- barcodeList.add(csvRecordData[6]);
- if (String.valueOf(csvRecordData[9]) == '涓�') {
- barcodePieceList.add(csvRecordData[6]);
- barcodePieceMap.put(csvRecordData[6], Integer.valueOf(csvRecordData[7]));
- }
- }
- String[] csvRecordDataStr = new List<String>(13);
- for (Integer j = 0; j < csvRecordData.size(); j++) {
- csvRecordDataStr[j] = csvRecordData[j];
- }
- if (i == 0) {
- csvRecordDataStr[12] = '浜у搧';
- } else {
- csvRecordDataStr[12] = '';
- }
- csvRecordStr.add(csvRecordDataStr);
- }
- Map<String, String> productBarcodeMap = new Map<String, String>();
- List<Consumable_order_details2__c> cOrderDet = [
- SELECT Id, Bar_Code__c, Name, Consumable_Product__c, Box_Piece__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 Bar_Code__c IN :barcodeList
- AND Product_Type__c LIKE :sqlagencyProType
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- AND Dealer_Info_text__c = :accountName
- ];
- for (Consumable_order_details2__c pdinfo : cOrderDet) {
- productBarcodeMap.put(pdinfo.Bar_Code__c, pdinfo.Consumable_Product__c);
- }
- for (String[] csvlistStr : csvRecordStr) {
- if (productBarcodeMap.containsKey(csvlistStr[6])) {
- csvlistStr[12] = productBarcodeMap.get(csvlistStr[6]);
- } else {
- }
- }
- //妫�绱㈠瓨鍦ㄦ媶鐩掍骇鍝佹暟閲�
- Map<String, Integer> exitpieceBarcodeMap = new Map<String, Integer>();
- AggregateResult[] pieceOrderDet = [
- SELECT count(Id) cnt, Bar_Code__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 Bar_Code__c IN :barcodePieceList
- AND Product_Type__c LIKE :sqlagencyProType
- AND Dealer_Info_text__c = :accountName
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- AND Box_Piece__c = '涓�'
- GROUP BY Bar_Code__c
- ];
- for (AggregateResult ar : pieceOrderDet) {
- exitpieceBarcodeMap.put(String.valueOf(ar.get('Bar_Code__c')), Integer.valueOf(ar.get('cnt')));
- }
- for (String bc : barcodePieceList) {
- if (!exitpieceBarcodeMap.containsKey(bc)) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(ApexPages.severity.ERROR, 'Barcode ' + bc + ' 涓嶅瓨鍦ㄦ垨鍗曚綅閿欒锛岃纭銆�')
- // );
- errorMsg += 'Barcode ' + bc + ' 涓嶅瓨鍦ㄦ垨鍗曚綅閿欒锛岃纭銆�<br />';
- saveFLGbln = true;
- messageCount++;
- } else if (exitpieceBarcodeMap.containsKey(bc) && exitpieceBarcodeMap.get(bc) < barcodePieceMap.get(bc)) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'Barcode ' + bc + ' 搴撳瓨涓嶈冻锛岃纭銆�'));
- errorMsg += 'Barcode ' + bc + ' 搴撳瓨涓嶈冻锛岃纭銆�<br />';
- saveFLGbln = true;
- messageCount++;
- }
- }
- } catch (Exception e) {
- //ApexPages.addMessages(e);
- errorMsg += e.getMessage() + ' ' + e.getLineNumber() + ';';
- //return new ResponseBodyLWC('Error', 500, e.getMessage()+e.getStackTraceString(), '');
- }
- getorderinfo();
- dataInfoconfim();
- getorderdet2info(csvRecordStr);
- if (saveFLGbln == false) {
- getorderdetinfo(csvRecordStr);
- }
- data.put('orderRecords', orderRecords);
- data.put('saveFLGbln', saveFLGbln);
- data.put('csvRecordStr', csvRecordStr);
- data.put('barcodeList', barcodeList);
- data.put('secondAgencyMap',secondAgencyMap);
- data.put('hospitalSysMap',hospitalSysMap);
- res.status = 'Success';
- res.code = 200;
- res.msg = errorMsg;
- return res;
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗� ' + csvRecordData[0] + '鍑鸿揣鐩殑涓虹┖锛岃纭銆�')
+ // );
+ errorMsg +=
+ '鍑哄簱鍗� ' +
+ csvRecordData[0] +
+ '鍑鸿揣鐩殑涓虹┖锛岃纭銆�<br />';
+ saveFLGbln = true;
+ messageCount++;
}
+ cocObj.Order_Attachment__c = csvRecordData[2];
+ cocObj.Order_Indication__c = csvRecordData[3];
+ cocObj.Order_ForCustomerText__c = csvRecordData[4];
+ cocObj.Invoice_Note__c = csvRecordData[5];
+ if (String.isBlank(csvRecordData[11])) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗� ' + cocObj.Name + '鐨勪骇鍝佷腑锛屽瓨鍦ㄥ嚭搴撴棩鏈熶负绌猴紝璇风‘璁ゃ��')
+ // );
+ errorMsg +=
+ '鍑哄簱鍗� ' +
+ cocObj.Name +
+ '鐨勪骇鍝佷腑锛屽瓨鍦ㄥ嚭搴撴棩鏈熶负绌猴紝璇风‘璁ゃ��<br />';
+ saveFLGbln = true;
+ messageCount++;
+ } else {
+ cocObj.Outbound_Date__c = Date.parse(csvRecordData[11].trim());
+ }
+ if (String.isNotEmpty(csvRecordData[2])) {
+ hospitalconMap.put(csvRecordData[2].trim(), csvRecordData[0].trim());
+ }
+ orderNameMap.put(csvRecordData[0], csvRecordData[0]);
+ orderRecords.add(new ConsumableorderdetailsInfo(cocObj));
+ }
+ } catch (Exception e) {
+ //return new ResponseBodyLWC('Error', 500, e.getMessage(), '');
+ errorMsg += e.getMessage() + ' ' + e.getLineNumber() + ';';
}
+ }
- public static void getorderinfo() {
- map<string, string> orderNameMap = new Map<string, string>();
- try {
- csvAsString = csvFileBody.toString();
- csvFileLines = csvAsString.split('\n');
- for (Integer i = 1; i < csvFileLines.size(); i++) {
- Consumable_order__c cocObj = new Consumable_order__c();
- string[] csvRecordData = csvFileLines[i].split(',');
- if (orderNameMap.containsKey(csvRecordData[0]))
- continue;
- cocObj.Name = csvRecordData[0];
- if (String.isNotBlank(csvRecordData[1])) {
- cocObj.SummonsForDirction__c = csvRecordData[1];
- } else {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗� ' + csvRecordData[0] + '鍑鸿揣鐩殑涓虹┖锛岃纭銆�')
- // );
- errorMsg += '鍑哄簱鍗� ' + csvRecordData[0] + '鍑鸿揣鐩殑涓虹┖锛岃纭銆�<br />';
- saveFLGbln = true;
- messageCount++;
- }
- cocObj.Order_Attachment__c = csvRecordData[2];
- cocObj.Order_Indication__c = csvRecordData[3];
- cocObj.Order_ForCustomerText__c = csvRecordData[4];
- cocObj.Invoice_Note__c = csvRecordData[5];
- if (String.isBlank(csvRecordData[11])) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗� ' + cocObj.Name + '鐨勪骇鍝佷腑锛屽瓨鍦ㄥ嚭搴撴棩鏈熶负绌猴紝璇风‘璁ゃ��')
- // );
- errorMsg += '鍑哄簱鍗� ' + cocObj.Name + '鐨勪骇鍝佷腑锛屽瓨鍦ㄥ嚭搴撴棩鏈熶负绌猴紝璇风‘璁ゃ��<br />';
- saveFLGbln = true;
- messageCount++;
- } else {
- cocObj.Outbound_Date__c = Date.parse(csvRecordData[11].trim());
- }
- if (String.isNotEmpty(csvRecordData[2])) {
- hospitalconMap.put(csvRecordData[2].trim(), csvRecordData[0].trim());
- }
- orderNameMap.put(csvRecordData[0], csvRecordData[0]);
- orderRecords.add(new ConsumableorderdetailsInfo(cocObj));
- }
- } catch (Exception e) {
- //return new ResponseBodyLWC('Error', 500, e.getMessage(), '');
- errorMsg += e.getMessage() + ' ' + e.getLineNumber() + ';';
+ public static void dataInfoconfim() {
+ //纭鍖婚櫌淇℃伅
+ hospitalSysMap = new Map<String, String>();
+ secondAgencyMap = new Map<String, String>();
+ for (ConsumableorderdetailsInfo ass : orderRecords) {
+ if (
+ (ass.order.SummonsForDirction__c == '閿�鍞粰浜岀骇缁忛攢鍟�' ||
+ ass.order.SummonsForDirction__c == '鐩存帴閿�鍞粰鍖婚櫌' ||
+ ass.order.SummonsForDirction__c == '鍖婚櫌璇曠敤') &&
+ (String.isBlank(ass.hospitalName) ||
+ String.isBlank(ass.hospitalCode) ||
+ String.isBlank(ass.order.Order_ForCustomerText__c))
+ ) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗�' + ass.order.Name + '鍖婚櫌鐩稿叧淇℃伅涓嶈兘绌猴紝璇风‘璁ゃ��')
+ // );
+ errorMsg +=
+ '鍑哄簱鍗�' +
+ ass.order.Name +
+ '鍖婚櫌鐩稿叧淇℃伅涓嶈兘绌猴紝璇风‘璁ゃ��<br />';
+ messageCount++;
+ saveFLGbln = true;
+ //return null;
+ }
+ if (ass.order.SummonsForDirction__c == '閿�鍞粰浜岀骇缁忛攢鍟�') {
+ if (String.isBlank(ass.agencyName)) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗�' + ass.order.Name + '缁忛攢鍟嗕俊鎭笉鑳界┖锛岃纭銆�')
+ // );
+ errorMsg +=
+ '鍑哄簱鍗�' +
+ ass.order.Name +
+ '缁忛攢鍟嗕俊鎭笉鑳界┖锛岃纭銆�<br />';
+ messageCount++;
+ saveFLGbln = true;
}
+ }
+ if (ass.order.SummonsForDirction__c == '鐩存帴閿�鍞粰鍖婚櫌') {
+ if (String.isNotBlank(ass.agencyName)) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗�' + ass.order.Name + '涓嶉渶瑕佷簩绾х粡閿�鍟嗭紝璇风‘璁ゃ��')
+ // );
+ errorMsg +=
+ '鍑哄簱鍗�' +
+ ass.order.Name +
+ '涓嶉渶瑕佷簩绾х粡閿�鍟嗭紝璇风‘璁ゃ��<br />';
+ messageCount++;
+ saveFLGbln = true;
+ }
+ }
+ if (ass.order.SummonsForDirction__c == '浜掔浉璋冭揣') {
+ if (String.isBlank(ass.agencyName)) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗�' + ass.order.Name + '缁忛攢鍟嗕俊鎭笉鑳界┖锛岃纭銆�')
+ // );
+ errorMsg +=
+ '鍑哄簱鍗�' +
+ ass.order.Name +
+ '缁忛攢鍟嗕俊鎭笉鑳界┖锛岃纭銆�<br />';
+ messageCount++;
+ saveFLGbln = true;
+ }
+ if (
+ String.isNotBlank(ass.hospitalName) ||
+ String.isNotBlank(ass.hospitalCode) ||
+ String.isNotBlank(ass.order.Order_ForCustomerText__c)
+ ) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗�' + ass.order.Name + '涓嶉渶瑕佸尰闄㈢浉鍏充俊鎭紝璇风‘璁ゃ��')
+ // );
+ errorMsg +=
+ '鍑哄簱鍗�' +
+ ass.order.Name +
+ '涓嶉渶瑕佸尰闄㈢浉鍏充俊鎭紝璇风‘璁ゃ��<br />';
+ messageCount++;
+ saveFLGbln = true;
+ }
+ }
}
-
- public static void dataInfoconfim() {
- //纭鍖婚櫌淇℃伅
- hospitalSysMap = new Map<String, String>();
- secondAgencyMap = new Map<String, String>();
- for (ConsumableorderdetailsInfo ass : orderRecords) {
- if (
- (ass.order.SummonsForDirction__c == '閿�鍞粰浜岀骇缁忛攢鍟�' ||
- ass.order.SummonsForDirction__c == '鐩存帴閿�鍞粰鍖婚櫌' ||
- ass.order.SummonsForDirction__c == '鍖婚櫌璇曠敤') &&
- (String.isBlank(ass.hospitalName) ||
- String.isBlank(ass.hospitalCode) ||
- String.isBlank(ass.order.Order_ForCustomerText__c))
- ) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗�' + ass.order.Name + '鍖婚櫌鐩稿叧淇℃伅涓嶈兘绌猴紝璇风‘璁ゃ��')
- // );
- errorMsg += '鍑哄簱鍗�' + ass.order.Name + '鍖婚櫌鐩稿叧淇℃伅涓嶈兘绌猴紝璇风‘璁ゃ��<br />';
- messageCount++;
- saveFLGbln = true;
- //return null;
- }
- if (ass.order.SummonsForDirction__c == '閿�鍞粰浜岀骇缁忛攢鍟�') {
- if (String.isBlank(ass.agencyName)) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗�' + ass.order.Name + '缁忛攢鍟嗕俊鎭笉鑳界┖锛岃纭銆�')
- // );
- errorMsg += '鍑哄簱鍗�' + ass.order.Name + '缁忛攢鍟嗕俊鎭笉鑳界┖锛岃纭銆�<br />';
- messageCount++;
- saveFLGbln = true;
- }
- }
- if (ass.order.SummonsForDirction__c == '鐩存帴閿�鍞粰鍖婚櫌') {
- if (String.isNotBlank(ass.agencyName)) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗�' + ass.order.Name + '涓嶉渶瑕佷簩绾х粡閿�鍟嗭紝璇风‘璁ゃ��')
- // );
- errorMsg += '鍑哄簱鍗�' + ass.order.Name + '涓嶉渶瑕佷簩绾х粡閿�鍟嗭紝璇风‘璁ゃ��<br />';
- messageCount++;
- saveFLGbln = true;
- }
- }
- if (ass.order.SummonsForDirction__c == '浜掔浉璋冭揣') {
- if (String.isBlank(ass.agencyName)) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗�' + ass.order.Name + '缁忛攢鍟嗕俊鎭笉鑳界┖锛岃纭銆�')
- // );
- errorMsg += '鍑哄簱鍗�' + ass.order.Name + '缁忛攢鍟嗕俊鎭笉鑳界┖锛岃纭銆�<br />';
- messageCount++;
- saveFLGbln = true;
- }
- if (
- String.isNotBlank(ass.hospitalName) ||
- String.isNotBlank(ass.hospitalCode) ||
- String.isNotBlank(ass.order.Order_ForCustomerText__c)
- ) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗�' + ass.order.Name + '涓嶉渶瑕佸尰闄㈢浉鍏充俊鎭紝璇风‘璁ゃ��')
- // );
- errorMsg += '鍑哄簱鍗�' + ass.order.Name + '涓嶉渶瑕佸尰闄㈢浉鍏充俊鎭紝璇风‘璁ゃ��<br />';
- messageCount++;
- saveFLGbln = true;
- }
- }
- }
- System.debug('accountName = ' + accountName);
- List<Agency_Hospital_Link__c> hospitalInfo = [
- SELECT Hospital__c, Hospital__r.Management_Code__c, Hospital__r.Name
- FROM Agency_Hospital_Link__c
- WHERE Agency__r.Name = :accountName
- ];
- List<Dealer_elationship__c> secondAgencyInfo = [
- SELECT Dealer_subordinate__c, Dealer_subordinate__r.Name
- FROM Dealer_elationship__c
- WHERE Dealer_principal__r.Name = :accountName
- ];
- for (Agency_Hospital_Link__c hpinfo : hospitalInfo) {
- hospitalSysMap.put(hpinfo.Hospital__r.Management_Code__c, hpinfo.Hospital__c);
- }
- for (Dealer_elationship__c safo : secondAgencyInfo) {
- secondAgencyMap.put(safo.Dealer_subordinate__r.Name, safo.Dealer_subordinate__c);
- }
- //鍑哄簱鍗曚俊鎭獙璇�
- System.debug('hospitalconMap = ' + hospitalconMap);
- System.debug('hospitalSysMap = ' + hospitalSysMap);
- for (String widget : hospitalconMap.keySet()) {
- if (!hospitalSysMap.containsKey(widget)) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(
- // ApexPages.severity.ERROR,
- // '鍑哄簱鍗� ' +
- // hospitalconMap.get(widget) +
- // ' 鐨勫尰闄㈢紪鐮�' +
- // widget +
- // ' 涓嶅瓨鍦ㄦ垨鑰呬笉鏄湰缁忛攢鍟嗚礋璐g殑鍖婚櫌锛岃纭銆�'
- // )
- // );
- errorMsg +=
- '鍑哄簱鍗� ' +
- hospitalconMap.get(widget) +
- ' 鐨勫尰闄㈢紪鐮�' +
- widget +
- ' 涓嶅瓨鍦ㄦ垨鑰呬笉鏄湰缁忛攢鍟嗚礋璐g殑鍖婚櫌锛岃纭銆�<br />';
- saveFLGbln = true;
- }
- }
+ System.debug('accountName = ' + accountName);
+ List<Agency_Hospital_Link__c> hospitalInfo = [
+ SELECT Hospital__c, Hospital__r.Management_Code__c, Hospital__r.Name
+ FROM Agency_Hospital_Link__c
+ WHERE Agency__r.Name = :accountName
+ ];
+ List<Dealer_elationship__c> secondAgencyInfo = [
+ SELECT Dealer_subordinate__c, Dealer_subordinate__r.Name
+ FROM Dealer_elationship__c
+ WHERE Dealer_principal__r.Name = :accountName
+ ];
+ for (Agency_Hospital_Link__c hpinfo : hospitalInfo) {
+ hospitalSysMap.put(
+ hpinfo.Hospital__r.Management_Code__c,
+ hpinfo.Hospital__c
+ );
}
-
- public static void getorderdet2info(List<String[]> csvRecordStr) {
- barcodeList = new List<String>();
- try {
- for (Integer i = 1; i < csvRecordStr.size(); i++) {
- Consumable_Order_details2__c cod2Obj = new Consumable_Order_details2__c();
- string[] csvRecordData = csvRecordStr[i];
- cod2Obj.TracingCode__c = csvRecordData[0];
- cod2Obj.Bar_Code__c = csvRecordData[6];
- if (String.isNotBlank(csvRecordData[6])) {
- barcodeList.add(csvRecordData[6]);
- }
- if (String.isBlank(csvRecordData[9])) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(
- // ApexPages.severity.ERROR,
- // '鍑哄簱鍗� ' +
- // cod2Obj.TracingCode__c +
- // '鐨刡arcode ' +
- // cod2Obj.Bar_Code__c +
- // ' 涓嶅瓨鍦ㄥ嚭搴撳崟浣嶏紝璇风‘璁ゃ��'
- // )
- // );
- errorMsg += '鍑哄簱鍗� ' + cod2Obj.TracingCode__c + '鐨刡arcode ' + cod2Obj.Bar_Code__c + ' 涓嶅瓨鍦ㄥ嚭搴撳崟浣嶏紝璇风‘璁ゃ��<br />';
- saveFLGbln = true;
- messageCount++;
- } else if (String.valueOf(csvRecordData[9]) != '鐩�' && String.valueOf(csvRecordData[9]) != '涓�') {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(
- // ApexPages.severity.ERROR,
- // '鍑哄簱鍗� ' +
- // cod2Obj.TracingCode__c +
- // '鐨刡arcode ' +
- // cod2Obj.Bar_Code__c +
- // ' 鍑哄簱鍗曚綅涓嶆纭紝璇风‘璁ゃ��'
- // )
- // );
- errorMsg += '鍑哄簱鍗� ' + cod2Obj.TracingCode__c + '鐨刡arcode ' + cod2Obj.Bar_Code__c + ' 鍑哄簱鍗曚綅涓嶆纭紝璇风‘璁ゃ��';
- saveFLGbln = true;
- messageCount++;
- } else {
- cod2Obj.Box_Piece__c = csvRecordData[9];
- }
- if (String.isBlank(csvRecordData[8])) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗� ' + cod2Obj.TracingCode__c + '浜у搧鍑鸿揣鍗曚环涓虹┖锛岃纭銆�')
- // );
- errorMsg += '鍑哄簱鍗� ' + cod2Obj.TracingCode__c + '浜у搧鍑鸿揣鍗曚环涓虹┖锛岃纭銆�<br />';
- saveFLGbln = true;
- messageCount++;
- } else if (String.isNotBlank(csvRecordData[8])) {
- if (
- Decimal.valueOf(csvRecordData[8]) == 0 &&
- (String.valueOf(csvRecordData[1]) == '鐩存帴閿�鍞粰鍖婚櫌' ||
- String.valueOf(csvRecordData[1]) == '閿�鍞粰浜岀骇缁忛攢鍟�')
- ) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(
- // ApexPages.severity.ERROR,
- // '鍑哄簱鍗� ' +
- // cod2Obj.TracingCode__c +
- // '浜у搧鍑鸿揣鍗曚环涓嶈兘涓�0锛岃纭銆�'
- // )
- // );
- errorMsg += '鍑哄簱鍗� ' + cod2Obj.TracingCode__c + '浜у搧鍑鸿揣鍗曚环涓嶈兘涓�0锛岃纭銆�<br />';
- saveFLGbln = true;
- messageCount++;
- } else {
- cod2Obj.Delivery_List_RMB__c = Decimal.valueOf(csvRecordData[8]);
- }
- }
- if (String.isBlank(csvRecordData[6])) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(
- // ApexPages.severity.ERROR,
- // '鍑哄簱鍗� ' +
- // cod2Obj.TracingCode__c +
- // '鐨勪骇鍝佷腑锛屽瓨鍦╞arcode涓虹┖锛岃纭銆�'
- // )
- // );
- errorMsg += '鍑哄簱鍗� ' + cod2Obj.TracingCode__c + '鐨勪骇鍝佷腑锛屽瓨鍦╞arcode涓虹┖锛岃纭銆�<br />';
- saveFLGbln = true;
- messageCount++;
- } else if (String.isBlank(csvRecordData[12])) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(
- // ApexPages.severity.ERROR,
- // '鍑哄簱鍗� ' +
- // cod2Obj.TracingCode__c +
- // '鐨刡arcode ' +
- // cod2Obj.Bar_Code__c +
- // ' 涓嶅瓨鍦ㄦ垨涓嶆槸鍦ㄥ簱浜у搧锛岃纭銆�'
- // )
- // );
- errorMsg += '鍑哄簱鍗� ' + cod2Obj.TracingCode__c + '鐨刡arcode ' + cod2Obj.Bar_Code__c + ' 涓嶅瓨鍦ㄦ垨涓嶆槸鍦ㄥ簱浜у搧锛岃纭銆�';
- saveFLGbln = true;
- messageCount++;
- }
- cod2Obj.Return_reason__c = csvRecordData[12];
- if (String.isBlank(csvRecordData[11])) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(
- // ApexPages.severity.ERROR,
- // '鍑哄簱鍗� ' +
- // cod2Obj.TracingCode__c +
- // '鐨勪骇鍝佷腑锛屽瓨鍦ㄥ嚭搴撴棩鏈熶负绌猴紝璇风‘璁ゃ��'
- // )
- // );
- errorMsg += '鍑哄簱鍗� ' + cod2Obj.TracingCode__c + '鐨勪骇鍝佷腑锛屽瓨鍦ㄥ嚭搴撴棩鏈熶负绌猴紝璇风‘璁ゃ��';
- saveFLGbln = true;
- messageCount++;
- } else {
- cod2Obj.Send_Date__c = Date.parse(csvRecordData[11].trim());
- }
- }
- } catch (Exception e) {
- //return new ResponseBodyLWC('Error', 500, e.getMessage(), '');
- errorMsg += e.getMessage() + ' ' + e.getLineNumber() + ';';
- }
+ for (Dealer_elationship__c safo : secondAgencyInfo) {
+ secondAgencyMap.put(
+ safo.Dealer_subordinate__r.Name,
+ safo.Dealer_subordinate__c
+ );
}
-
- public static void getorderdetinfo(List<String[]> csvRecordStr) {
- map<string, string> orderdetMap = new Map<string, string>();
- try {
- for (Integer i = 1; i < csvRecordStr.size(); i++) {
- Consumable_Orderdetails__c codObj = new Consumable_Orderdetails__c();
- string[] csvRecordData = csvRecordStr[i];
- if (orderdetMap.containsKey(csvRecordData[0] + csvRecordData[12]))
- continue;
- codObj.Remarks__c = csvRecordData[0];
- if (String.isBlank(csvRecordData[7])) {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗� ' + csvRecordData[0] + '浜у搧鍑鸿揣鏁伴噺涓虹┖锛岃纭銆�')
- // );
- errorMsg += '鍑哄簱鍗� ' + csvRecordData[0] + '浜у搧鍑鸿揣鏁伴噺涓虹┖锛岃纭銆�<br />';
- saveFLGbln = true;
- messageCount++;
- } else if (Decimal.valueOf(csvRecordData[7]) > 1 && String.valueOf(csvRecordData[9]) == '鐩�') {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(
- // ApexPages.severity.ERROR,
- // '鍑哄簱鍗� ' +
- // csvRecordData[0] +
- // '瀛樺湪鍗曚綅鏄洅锛屼骇鍝佸嚭璐ф暟閲忓ぇ浜�1锛岃纭銆�'
- // )
- // );
- errorMsg += '鍑哄簱鍗� ' + csvRecordData[0] + '瀛樺湪鍗曚綅鏄洅锛屼骇鍝佸嚭璐ф暟閲忓ぇ浜�1锛岃纭銆�<br />';
- saveFLGbln = true;
- messageCount++;
- } else {
- codObj.Shipment_Count__c = Decimal.valueOf(csvRecordData[7]);
- }
- codObj.Box_Piece__c = csvRecordData[9];
- if (String.isNotBlank(csvRecordData[8])) {
- codObj.Delivery_List_RMB__c = Decimal.valueOf(csvRecordData[8]);
- } else {
- if (messageCount >= 100)
- break;
- // ApexPages.addmessage(
- // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗� ' + csvRecordData[0] + '浜у搧鍑鸿揣鍗曚环涓虹┖锛岃纭銆�')
- // );
- errorMsg += '鍑哄簱鍗� ' + csvRecordData[0] + '鍑哄簱鍗� ' + csvRecordData[0] + '浜у搧鍑鸿揣鍗曚环涓虹┖锛岃纭銆�<br />';
- saveFLGbln = true;
- messageCount++;
- }
- //if(String.isNotBlank(csvRecordData[10])){
- // codObj.Unitprice_To_agency__c = Decimal.valueOf(csvRecordData[10]);
- //}
- codObj.Lose_reason__c = csvRecordData[12];
- codObj.Used_date__c = Date.parse(csvRecordData[11].trim());
- product2conMap.put(csvRecordData[12].trim(), csvRecordData[12].trim());
- orderdetMap.put(csvRecordData[0] + csvRecordData[12], csvRecordData[0] + csvRecordData[12]);
- //orderdetRecords.add(new ConsumableorderdetailsInfo(codObj));
- }
- } catch (Exception e) {
- //return new ResponseBodyLWC('Error', 500, e.getMessage(), '');
- errorMsg += e.getMessage() + ' ' + e.getLineNumber() + ';';
- }
+ //鍑哄簱鍗曚俊鎭獙璇�
+ System.debug('hospitalconMap = ' + hospitalconMap);
+ System.debug('hospitalSysMap = ' + hospitalSysMap);
+ for (String widget : hospitalconMap.keySet()) {
+ if (!hospitalSysMap.containsKey(widget)) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(
+ // ApexPages.severity.ERROR,
+ // '鍑哄簱鍗� ' +
+ // hospitalconMap.get(widget) +
+ // ' 鐨勫尰闄㈢紪鐮�' +
+ // widget +
+ // ' 涓嶅瓨鍦ㄦ垨鑰呬笉鏄湰缁忛攢鍟嗚礋璐g殑鍖婚櫌锛岃纭銆�'
+ // )
+ // );
+ errorMsg +=
+ '鍑哄簱鍗� ' +
+ hospitalconMap.get(widget) +
+ ' 鐨勫尰闄㈢紪鐮�' +
+ widget +
+ ' 涓嶅瓨鍦ㄦ垨鑰呬笉鏄湰缁忛攢鍟嗚礋璐g殑鍖婚櫌锛岃纭銆�<br />';
+ saveFLGbln = true;
+ }
}
+ }
- @AuraEnabled
- public static ResponseBodyLWC dataImport(
- List<String[]> csvRecordStrLwc,
- String orderRecordsLwc,
- String sqlagencyProTypeLwc,
- String userWorkLocationLwc,
- String accountNameLwc,
- String accountidLwc,
- String agencyProTypeLwc,
- Map<String, String> secondAgencyMapLwc,
- Map<String, String> hospitalSysMapLwc
- ) {
- List<ConsumableorderdetailsInfo> orderdetRecords = new List<ConsumableorderdetailsInfo>();
- List<ConsumableorderdetailsInfo> orderdet2BoxRecords = new List<ConsumableorderdetailsInfo>();
- List<ConsumableorderdetailsInfo> orderdet2PieceRecords = new List<ConsumableorderdetailsInfo>();
- product2conMap = new Map<String, String>();
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
-
- csvRecordStr = csvRecordStrLwc;
- orderRecords = (List<ConsumableorderdetailsInfo>)JSON.deserialize(orderRecordsLwc, List<ConsumableorderdetailsInfo>.class);
- System.debug('orderRecords = ' + orderRecords);
- sqlagencyProType = sqlagencyProTypeLwc;
- userWorkLocation = userWorkLocationLwc;
- accountName = accountNameLwc;
- secondAgencyMap = secondAgencyMapLwc;
- hospitalSysMap = hospitalSysMapLwc;
- accountid = accountidLwc;
- agencyProType = agencyProTypeLwc;
- System.debug('agencyProType = ' + agencyProType);
-
- errorMsg = '';
- System.debug('csvRecordStr = ' + csvRecordStr);
- orderdetRecords = getorderdetList(csvRecordStr);
- orderdet2BoxRecords = getorderdet2BoxList(csvRecordStr);
- orderdet2PieceRecords = getorderdet2pieceList(csvRecordStr);
- System.debug('orderdetRecords = ' + orderdetRecords);
- System.debug('orderdet2BoxRecords = ' + orderdet2BoxRecords);
- System.debug('orderdet2PieceRecords = ' + orderdet2PieceRecords);
- Savepoint sp = Database.setSavepoint();
- try {
- Map<String, String> orderInfoMap = new Map<String, String>();
- List<Consumable_order__c> coc = new List<Consumable_order__c>();
- for (ConsumableorderdetailsInfo ass : orderRecords) {
- ass.order.Order_type__c = '浼犵エ';
- ass.order.SummonsStatus_c__c = '宸插畬鎴�';
- ass.order.Order_ProType__c = agencyProType;
- ass.order.Dealer_Info__c = accountid;
- ass.order.Order_ForHospital__c = hospitalSysMap.get(ass.hospitalCode);
- if (secondAgencyMap.containsKey(ass.agencyName)) {
- ass.order.Order_ForDealer__c = secondAgencyMap.get(ass.agencyName);
- } else {
- ass.order.Order_ForDealerText__c = ass.agencyName;
- }
- ass.order.RecordTypeId = System.Label.RT_ConOrder_Sale;
- coc.add(ass.order);
- }
- System.debug('coc = ' + coc);
- if (coc.size() > 0) {
- insert coc;
- }
- for (Consumable_order__c order : coc) {
- orderInfoMap.put(order.Name, order.Id);
- }
- List<Consumable_Orderdetails__c> cod = new List<Consumable_Orderdetails__c>();
- for (String field : orderInfoMap.keySet()) {
- Integer i = 1;
- for (ConsumableorderdetailsInfo ass : orderdetRecords) {
- if (ass.orderName == field) {
- String str = string.valueOf(i);
- if (str.length() == 1) {
- str = '0' + str;
- }
- ass.orderdetails1.Name = ass.orderName + '-' + str;
- ass.orderdetails1.Consumable_order__c = orderInfoMap.get(ass.orderName);
- ass.orderdetails1.Consumable_Product__c = ass.productName;
- ass.orderdetails1.RecordTypeId = System.Label.RT_ConOrderDetail1_Sale;
- cod.add(ass.orderdetails1);
- i++;
- }
- }
- }
- System.debug('cod = ' + cod);
- if (cod.size() > 0) {
- insert cod;
- }
- //鐩掔殑鏁版嵁妫�绱�
- List<Consumable_Order_details2__c> cod2List = new List<Consumable_Order_details2__c>();
- List<Consumable_order_details2__c> cOrderDet = [
- SELECT Id, Bar_Code__c, Name, Consumable_Product__c, Box_Piece__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 Bar_Code__c IN :barcodeList
- AND Product_Type__c LIKE :sqlagencyProType
- AND Dealer_Info_text__c = :accountName
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- AND Box_Piece__c = '鐩�'
- ];
- for (ConsumableorderdetailsInfo ass : orderdet2BoxRecords) {
- Integer idx = 0;
- for (Consumable_order_details2__c codtest : cOrderDet) {
- Consumable_Order_details2__c cod2 = new Consumable_Order_details2__c();
- if (codtest.Bar_Code__c == ass.orderdetails2.Bar_Code__c) {
- cod2 = codtest;
- cod2.Consumable_Sale_order__c = orderInfoMap.get(ass.orderName);
- cod2.Consumable_ZS_order__c = orderInfoMap.get(ass.orderName);
- cod2.Used_date__c = ass.orderdetails2.Used_date__c;
- cod2.Send_Date__c = ass.orderdetails2.Send_Date__c;
- //cod2.Unitprice_To_agency__c = ass.orderdetails2.Unitprice_To_agency__c;
- cod2.Delivery_List_RMB__c = ass.orderdetails2.Delivery_List_RMB__c;
- cod2List.add(cod2);
- cOrderDet.remove(idx);
- break;
- }
- idx++;
- }
- }
-
- //涓殑鏁版嵁妫�绱�
- List<Consumable_order_details2__c> cOrderDetPiece = [
- SELECT Id, Bar_Code__c, RemoveBox_No__c, Name, Consumable_Product__c, Box_Piece__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 Arrive_Owner_Work_Location__c = :userWorkLocation
- AND Bar_Code__c IN :barcodePieceList
- AND Product_Type__c LIKE :sqlagencyProType
- AND Dealer_Info_text__c = :accountName
- AND Box_Piece__c = '涓�'
- ORDER BY Bar_Code__c, RemoveBox_No__c DESC
- ];
- for (ConsumableorderdetailsInfo ass : orderdet2PieceRecords) {
- Decimal idy = 1;
- for (Integer idx = 0; idx < cOrderDetPiece.size(); idx++) {
- Consumable_Order_details2__c cod2 = new Consumable_Order_details2__c();
- if (cOrderDetPiece[idx].Bar_Code__c == ass.orderdetails2.Bar_Code__c && idy <= ass.pieceCount) {
- cod2 = cOrderDetPiece[idx].Clone();
- cod2.Id = cOrderDetPiece[idx].Id;
- cod2.Consumable_Sale_order__c = orderInfoMap.get(ass.orderName);
- cod2.Consumable_ZS_order__c = orderInfoMap.get(ass.orderName);
- cod2.Used_date__c = ass.orderdetails2.Used_date__c;
- cod2.Send_Date__c = ass.orderdetails2.Send_Date__c;
- //cod2.Unitprice_To_agency__c = ass.orderdetails2.Unitprice_To_agency__c;
- cod2.Delivery_List_RMB__c = ass.orderdetails2.Delivery_List_RMB__c;
- cod2List.add(cod2);
- cOrderDetPiece[idx].Bar_Code__c = '';
- idy++;
- //break;
- }
- }
- }
- if (cod2List.size() > 0) {
- update cod2List;
- }
- errorflg = true;
- //errorMessage = '淇濆瓨瀹屾垚銆�';
+ public static void getorderdet2info(List<String[]> csvRecordStr) {
+ barcodeList = new List<String>();
+ try {
+ for (Integer i = 1; i < csvRecordStr.size(); i++) {
+ Consumable_Order_details2__c cod2Obj = new Consumable_Order_details2__c();
+ string[] csvRecordData = csvRecordStr[i];
+ cod2Obj.TracingCode__c = csvRecordData[0];
+ cod2Obj.Bar_Code__c = csvRecordData[6];
+ if (String.isNotBlank(csvRecordData[6])) {
+ barcodeList.add(csvRecordData[6]);
+ }
+ if (String.isBlank(csvRecordData[9])) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(
+ // ApexPages.severity.ERROR,
+ // '鍑哄簱鍗� ' +
+ // cod2Obj.TracingCode__c +
+ // '鐨刡arcode ' +
+ // cod2Obj.Bar_Code__c +
+ // ' 涓嶅瓨鍦ㄥ嚭搴撳崟浣嶏紝璇风‘璁ゃ��'
+ // )
+ // );
+ errorMsg +=
+ '鍑哄簱鍗� ' +
+ cod2Obj.TracingCode__c +
+ '鐨刡arcode ' +
+ cod2Obj.Bar_Code__c +
+ ' 涓嶅瓨鍦ㄥ嚭搴撳崟浣嶏紝璇风‘璁ゃ��<br />';
+ saveFLGbln = true;
+ messageCount++;
+ } else if (
+ String.valueOf(csvRecordData[9]) != '鐩�' &&
+ String.valueOf(csvRecordData[9]) != '涓�'
+ ) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(
+ // ApexPages.severity.ERROR,
+ // '鍑哄簱鍗� ' +
+ // cod2Obj.TracingCode__c +
+ // '鐨刡arcode ' +
+ // cod2Obj.Bar_Code__c +
+ // ' 鍑哄簱鍗曚綅涓嶆纭紝璇风‘璁ゃ��'
+ // )
+ // );
+ errorMsg +=
+ '鍑哄簱鍗� ' +
+ cod2Obj.TracingCode__c +
+ '鐨刡arcode ' +
+ cod2Obj.Bar_Code__c +
+ ' 鍑哄簱鍗曚綅涓嶆纭紝璇风‘璁ゃ��';
+ saveFLGbln = true;
+ messageCount++;
+ } else {
+ cod2Obj.Box_Piece__c = csvRecordData[9];
+ }
+ if (String.isBlank(csvRecordData[8])) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗� ' + cod2Obj.TracingCode__c + '浜у搧鍑鸿揣鍗曚环涓虹┖锛岃纭銆�')
+ // );
+ errorMsg +=
+ '鍑哄簱鍗� ' +
+ cod2Obj.TracingCode__c +
+ '浜у搧鍑鸿揣鍗曚环涓虹┖锛岃纭銆�<br />';
+ saveFLGbln = true;
+ messageCount++;
+ } else if (String.isNotBlank(csvRecordData[8])) {
+ if (
+ Decimal.valueOf(csvRecordData[8]) == 0 &&
+ (String.valueOf(csvRecordData[1]) == '鐩存帴閿�鍞粰鍖婚櫌' ||
+ String.valueOf(csvRecordData[1]) == '閿�鍞粰浜岀骇缁忛攢鍟�')
+ ) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(
+ // ApexPages.severity.ERROR,
+ // '鍑哄簱鍗� ' +
+ // cod2Obj.TracingCode__c +
+ // '浜у搧鍑鸿揣鍗曚环涓嶈兘涓�0锛岃纭銆�'
+ // )
+ // );
+ errorMsg +=
+ '鍑哄簱鍗� ' +
+ cod2Obj.TracingCode__c +
+ '浜у搧鍑鸿揣鍗曚环涓嶈兘涓�0锛岃纭銆�<br />';
saveFLGbln = true;
-
- res.status = 'Success';
- res.code = 200;
- res.msg = errorMsg;
- return res;
- } catch (Exception e) {
- Database.rollback(sp);
- // ApexPages.addMessages(e);
- // return null;
- return new ResponseBodyLWC('Error', 500, e.getMessage() + e.getStackTraceString(), '');
+ messageCount++;
+ } else {
+ cod2Obj.Delivery_List_RMB__c = Decimal.valueOf(csvRecordData[8]);
+ }
}
+ if (String.isBlank(csvRecordData[6])) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(
+ // ApexPages.severity.ERROR,
+ // '鍑哄簱鍗� ' +
+ // cod2Obj.TracingCode__c +
+ // '鐨勪骇鍝佷腑锛屽瓨鍦╞arcode涓虹┖锛岃纭銆�'
+ // )
+ // );
+ errorMsg +=
+ '鍑哄簱鍗� ' +
+ cod2Obj.TracingCode__c +
+ '鐨勪骇鍝佷腑锛屽瓨鍦╞arcode涓虹┖锛岃纭銆�<br />';
+ saveFLGbln = true;
+ messageCount++;
+ } else if (String.isBlank(csvRecordData[12])) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(
+ // ApexPages.severity.ERROR,
+ // '鍑哄簱鍗� ' +
+ // cod2Obj.TracingCode__c +
+ // '鐨刡arcode ' +
+ // cod2Obj.Bar_Code__c +
+ // ' 涓嶅瓨鍦ㄦ垨涓嶆槸鍦ㄥ簱浜у搧锛岃纭銆�'
+ // )
+ // );
+ errorMsg +=
+ '鍑哄簱鍗� ' +
+ cod2Obj.TracingCode__c +
+ '鐨刡arcode ' +
+ cod2Obj.Bar_Code__c +
+ ' 涓嶅瓨鍦ㄦ垨涓嶆槸鍦ㄥ簱浜у搧锛岃纭銆�';
+ saveFLGbln = true;
+ messageCount++;
+ }
+ cod2Obj.Return_reason__c = csvRecordData[12];
+ if (String.isBlank(csvRecordData[11])) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(
+ // ApexPages.severity.ERROR,
+ // '鍑哄簱鍗� ' +
+ // cod2Obj.TracingCode__c +
+ // '鐨勪骇鍝佷腑锛屽瓨鍦ㄥ嚭搴撴棩鏈熶负绌猴紝璇风‘璁ゃ��'
+ // )
+ // );
+ errorMsg +=
+ '鍑哄簱鍗� ' +
+ cod2Obj.TracingCode__c +
+ '鐨勪骇鍝佷腑锛屽瓨鍦ㄥ嚭搴撴棩鏈熶负绌猴紝璇风‘璁ゃ��';
+ saveFLGbln = true;
+ messageCount++;
+ } else {
+ cod2Obj.Send_Date__c = Date.parse(csvRecordData[11].trim());
+ }
+ }
+ } catch (Exception e) {
+ //return new ResponseBodyLWC('Error', 500, e.getMessage(), '');
+ errorMsg += e.getMessage() + ' ' + e.getLineNumber() + ';';
}
+ }
- public static List<ConsumableorderdetailsInfo> getorderdetList(List<String[]> csvRecordStr) {
- List<ConsumableorderdetailsInfo> orderdetRecords = new List<ConsumableorderdetailsInfo>();
- map<string, Decimal> orderdetMap = new Map<string, Decimal>();
- try {
- for (Integer i = 1; i < csvRecordStr.size(); i++) {
- Consumable_Orderdetails__c codObj = new Consumable_Orderdetails__c();
- string[] csvRecordData = csvRecordStr[i];
- if (orderdetMap.containsKey(csvRecordData[0] + csvRecordData[12] + csvRecordData[9])) {
- orderdetMap.put(
- csvRecordData[0] +
- csvRecordData[12] +
- csvRecordData[9],
- orderdetMap.get(csvRecordData[0] + csvRecordData[12] + csvRecordData[9]) + Decimal.valueOf(csvRecordData[7])
- );
- continue;
- } else {
- orderdetMap.put(csvRecordData[0] + csvRecordData[12] + csvRecordData[9], Decimal.valueOf(csvRecordData[7]));
- }
- codObj.Remarks__c = csvRecordData[0];
- codObj.Shipment_Count__c = Decimal.valueOf(csvRecordData[7]);
- codObj.Box_Piece__c = csvRecordData[9];
- if (String.isNotBlank(csvRecordData[8])) {
- codObj.Delivery_List_RMB__c = Decimal.valueOf(csvRecordData[8]);
- }
- codObj.Lose_reason__c = csvRecordData[12];
- if (String.isNotBlank(csvRecordData[11])) {
- codObj.Used_date__c = Date.parse(csvRecordData[11].trim());
- }
- product2conMap.put(csvRecordData[12].trim(), csvRecordData[12].trim());
- orderdetRecords.add(new ConsumableorderdetailsInfo(codObj));
+ public static void getorderdetinfo(List<String[]> csvRecordStr) {
+ map<string, string> orderdetMap = new Map<string, string>();
+ try {
+ for (Integer i = 1; i < csvRecordStr.size(); i++) {
+ Consumable_Orderdetails__c codObj = new Consumable_Orderdetails__c();
+ string[] csvRecordData = csvRecordStr[i];
+ if (orderdetMap.containsKey(csvRecordData[0] + csvRecordData[12]))
+ continue;
+ codObj.Remarks__c = csvRecordData[0];
+ if (String.isBlank(csvRecordData[7])) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗� ' + csvRecordData[0] + '浜у搧鍑鸿揣鏁伴噺涓虹┖锛岃纭銆�')
+ // );
+ errorMsg +=
+ '鍑哄簱鍗� ' +
+ csvRecordData[0] +
+ '浜у搧鍑鸿揣鏁伴噺涓虹┖锛岃纭銆�<br />';
+ saveFLGbln = true;
+ messageCount++;
+ } else if (
+ Decimal.valueOf(csvRecordData[7]) > 1 &&
+ String.valueOf(csvRecordData[9]) == '鐩�'
+ ) {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(
+ // ApexPages.severity.ERROR,
+ // '鍑哄簱鍗� ' +
+ // csvRecordData[0] +
+ // '瀛樺湪鍗曚綅鏄洅锛屼骇鍝佸嚭璐ф暟閲忓ぇ浜�1锛岃纭銆�'
+ // )
+ // );
+ errorMsg +=
+ '鍑哄簱鍗� ' +
+ csvRecordData[0] +
+ '瀛樺湪鍗曚綅鏄洅锛屼骇鍝佸嚭璐ф暟閲忓ぇ浜�1锛岃纭銆�<br />';
+ saveFLGbln = true;
+ messageCount++;
+ } else {
+ codObj.Shipment_Count__c = Decimal.valueOf(csvRecordData[7]);
+ }
+ codObj.Box_Piece__c = csvRecordData[9];
+ if (String.isNotBlank(csvRecordData[8])) {
+ codObj.Delivery_List_RMB__c = Decimal.valueOf(csvRecordData[8]);
+ } else {
+ if (messageCount >= 100)
+ break;
+ // ApexPages.addmessage(
+ // new ApexPages.message(ApexPages.severity.ERROR, '鍑哄簱鍗� ' + csvRecordData[0] + '浜у搧鍑鸿揣鍗曚环涓虹┖锛岃纭銆�')
+ // );
+ errorMsg +=
+ '鍑哄簱鍗� ' +
+ csvRecordData[0] +
+ '鍑哄簱鍗� ' +
+ csvRecordData[0] +
+ '浜у搧鍑鸿揣鍗曚环涓虹┖锛岃纭銆�<br />';
+ saveFLGbln = true;
+ messageCount++;
+ }
+ //if(String.isNotBlank(csvRecordData[10])){
+ // codObj.Unitprice_To_agency__c = Decimal.valueOf(csvRecordData[10]);
+ //}
+ codObj.Lose_reason__c = csvRecordData[12];
+ codObj.Used_date__c = Date.parse(csvRecordData[11].trim());
+ product2conMap.put(csvRecordData[12].trim(), csvRecordData[12].trim());
+ orderdetMap.put(
+ csvRecordData[0] + csvRecordData[12],
+ csvRecordData[0] + csvRecordData[12]
+ );
+ //orderdetRecords.add(new ConsumableorderdetailsInfo(codObj));
+ }
+ } catch (Exception e) {
+ //return new ResponseBodyLWC('Error', 500, e.getMessage(), '');
+ errorMsg += e.getMessage() + ' ' + e.getLineNumber() + ';';
+ }
+ }
+
+ @AuraEnabled
+ public static ResponseBodyLWC dataImport(
+ List<String[]> csvRecordStrLwc,
+ String orderRecordsLwc,
+ String sqlagencyProTypeLwc,
+ String userWorkLocationLwc,
+ String accountNameLwc,
+ String accountidLwc,
+ String agencyProTypeLwc,
+ Map<String, String> secondAgencyMapLwc,
+ Map<String, String> hospitalSysMapLwc
+ ) {
+ List<ConsumableorderdetailsInfo> orderdetRecords = new List<ConsumableorderdetailsInfo>();
+ List<ConsumableorderdetailsInfo> orderdet2BoxRecords = new List<ConsumableorderdetailsInfo>();
+ List<ConsumableorderdetailsInfo> orderdet2PieceRecords = new List<ConsumableorderdetailsInfo>();
+ product2conMap = new Map<String, String>();
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ csvRecordStr = csvRecordStrLwc;
+ orderRecords = (List<ConsumableorderdetailsInfo>) JSON.deserialize(
+ orderRecordsLwc,
+ List<ConsumableorderdetailsInfo>.class
+ );
+ System.debug('orderRecords = ' + orderRecords);
+ sqlagencyProType = sqlagencyProTypeLwc;
+ userWorkLocation = userWorkLocationLwc;
+ accountName = accountNameLwc;
+ secondAgencyMap = secondAgencyMapLwc;
+ hospitalSysMap = hospitalSysMapLwc;
+ accountid = accountidLwc;
+ agencyProType = agencyProTypeLwc;
+ System.debug('agencyProType = ' + agencyProType);
+
+ errorMsg = '';
+ System.debug('csvRecordStr = ' + csvRecordStr);
+ orderdetRecords = getorderdetList(csvRecordStr);
+ orderdet2BoxRecords = getorderdet2BoxList(csvRecordStr);
+ orderdet2PieceRecords = getorderdet2pieceList(csvRecordStr);
+ System.debug('orderdetRecords = ' + orderdetRecords);
+ System.debug('orderdet2BoxRecords = ' + orderdet2BoxRecords);
+ System.debug('orderdet2PieceRecords = ' + orderdet2PieceRecords);
+ Savepoint sp = Database.setSavepoint();
+ try {
+ Map<String, String> orderInfoMap = new Map<String, String>();
+ List<Consumable_order__c> coc = new List<Consumable_order__c>();
+ for (ConsumableorderdetailsInfo ass : orderRecords) {
+ ass.order.Order_type__c = '浼犵エ';
+ ass.order.SummonsStatus_c__c = '宸插畬鎴�';
+ ass.order.Order_ProType__c = agencyProType;
+ ass.order.Dealer_Info__c = accountid;
+ ass.order.Order_ForHospital__c = hospitalSysMap.get(ass.hospitalCode);
+ if (secondAgencyMap.containsKey(ass.agencyName)) {
+ ass.order.Order_ForDealer__c = secondAgencyMap.get(ass.agencyName);
+ } else {
+ ass.order.Order_ForDealerText__c = ass.agencyName;
+ }
+ ass.order.RecordTypeId = System.Label.RT_ConOrder_Sale;
+ coc.add(ass.order);
+ }
+ System.debug('coc = ' + coc);
+ if (coc.size() > 0) {
+ insert coc;
+ }
+ for (Consumable_order__c order : coc) {
+ orderInfoMap.put(order.Name, order.Id);
+ }
+ List<Consumable_Orderdetails__c> cod = new List<Consumable_Orderdetails__c>();
+ for (String field : orderInfoMap.keySet()) {
+ Integer i = 1;
+ for (ConsumableorderdetailsInfo ass : orderdetRecords) {
+ if (ass.orderName == field) {
+ String str = string.valueOf(i);
+ if (str.length() == 1) {
+ str = '0' + str;
}
- for (ConsumableorderdetailsInfo ass : orderdetRecords) {
- if (orderdetMap.containsKey(ass.orderName + ass.productName + ass.orderdetails1.Box_Piece__c)) {
- ass.orderdetails1.Shipment_Count__c = orderdetMap.get(ass.orderName + ass.productName + ass.orderdetails1.Box_Piece__c);
- }
- }
- System.debug('orderdetRecords = ' + orderdetRecords);
- return orderdetRecords;
- } catch (Exception e) {
- // ApexPages.addMessages(e);
- // return null;
- errorMsg += e.getMessage() + ' ' + e.getLineNumber() + ';';
- System.debug('orderdetRecords = null ' + e.getLineNumber());
- return null;
+ ass.orderdetails1.Name = ass.orderName + '-' + str;
+ ass.orderdetails1.Consumable_order__c = orderInfoMap.get(
+ ass.orderName
+ );
+ ass.orderdetails1.Consumable_Product__c = ass.productName;
+ ass.orderdetails1.RecordTypeId = System.Label.RT_ConOrderDetail1_Sale;
+ cod.add(ass.orderdetails1);
+ i++;
+ }
}
- }
+ }
+ System.debug('cod = ' + cod);
+ if (cod.size() > 0) {
+ insert cod;
+ }
+ //鐩掔殑鏁版嵁妫�绱�
+ List<Consumable_Order_details2__c> cod2List = new List<Consumable_Order_details2__c>();
+ List<Consumable_order_details2__c> cOrderDet = [
+ SELECT Id, Bar_Code__c, Name, Consumable_Product__c, Box_Piece__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 Bar_Code__c IN :barcodeList
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Dealer_Info_text__c = :accountName
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Box_Piece__c = '鐩�'
+ ];
+ for (ConsumableorderdetailsInfo ass : orderdet2BoxRecords) {
+ Integer idx = 0;
+ for (Consumable_order_details2__c codtest : cOrderDet) {
+ Consumable_Order_details2__c cod2 = new Consumable_Order_details2__c();
+ if (codtest.Bar_Code__c == ass.orderdetails2.Bar_Code__c) {
+ cod2 = codtest;
+ cod2.Consumable_Sale_order__c = orderInfoMap.get(ass.orderName);
+ cod2.Consumable_ZS_order__c = orderInfoMap.get(ass.orderName);
+ cod2.Used_date__c = ass.orderdetails2.Used_date__c;
+ cod2.Send_Date__c = ass.orderdetails2.Send_Date__c;
+ //cod2.Unitprice_To_agency__c = ass.orderdetails2.Unitprice_To_agency__c;
+ cod2.Delivery_List_RMB__c = ass.orderdetails2.Delivery_List_RMB__c;
+ cod2List.add(cod2);
+ cOrderDet.remove(idx);
+ break;
+ }
+ idx++;
+ }
+ }
- public static List<ConsumableorderdetailsInfo> getorderdet2BoxList(List<String[]> csvRecordStr) {
- barcodeList = new List<String>();
- List<ConsumableorderdetailsInfo> orderdet2BoxRecords = new List<ConsumableorderdetailsInfo>();
- try {
- for (Integer i = 1; i < csvRecordStr.size(); i++) {
- string[] csvRecordData = csvRecordStr[i];
- if (String.valueOf(csvRecordData[9]) == '鐩�') {
- Consumable_Order_details2__c cod2Obj = new Consumable_Order_details2__c();
- cod2Obj.TracingCode__c = csvRecordData[0];
- cod2Obj.Bar_Code__c = csvRecordData[6];
- if (String.isNotBlank(csvRecordData[6])) {
- barcodeList.add(csvRecordData[6]);
- }
- cod2Obj.Box_Piece__c = csvRecordData[9];
- if (String.isNotBlank(csvRecordData[8])) {
- cod2Obj.Delivery_List_RMB__c = Decimal.valueOf(csvRecordData[8]);
- }
- //if(String.isNotBlank(csvRecordData[10])){
- // cod2Obj.Unitprice_To_agency__c = Decimal.valueOf(csvRecordData[10]);
- //}
- cod2Obj.Return_reason__c = csvRecordData[12];
- if (String.valueOf(csvRecordData[1]) == '閿�鍞粰浜岀骇缁忛攢鍟�' || String.valueOf(csvRecordData[1]) == '鐩存帴閿�鍞粰鍖婚櫌') {
- cod2Obj.Used_date__c = Date.parse(csvRecordData[11].trim());
- } else {
- cod2Obj.Send_Date__c = Date.parse(csvRecordData[11].trim());
- }
- orderdet2BoxRecords.add(new ConsumableorderdetailsInfo(cod2Obj));
- }
- }
- return orderdet2BoxRecords;
- } catch (Exception e) {
- // ApexPages.addMessages(e);
- // return null;
- errorMsg += e.getMessage() + ' ' + e.getLineNumber() + ';';
- return null;
+ //涓殑鏁版嵁妫�绱�
+ List<Consumable_order_details2__c> cOrderDetPiece = [
+ SELECT
+ Id,
+ Bar_Code__c,
+ RemoveBox_No__c,
+ Name,
+ Consumable_Product__c,
+ Box_Piece__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 Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Bar_Code__c IN :barcodePieceList
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Dealer_Info_text__c = :accountName
+ AND Box_Piece__c = '涓�'
+ ORDER BY Bar_Code__c, RemoveBox_No__c DESC
+ ];
+ for (ConsumableorderdetailsInfo ass : orderdet2PieceRecords) {
+ Decimal idy = 1;
+ for (Integer idx = 0; idx < cOrderDetPiece.size(); idx++) {
+ Consumable_Order_details2__c cod2 = new Consumable_Order_details2__c();
+ if (
+ cOrderDetPiece[idx].Bar_Code__c == ass.orderdetails2.Bar_Code__c &&
+ idy <= ass.pieceCount
+ ) {
+ cod2 = cOrderDetPiece[idx].Clone();
+ cod2.Id = cOrderDetPiece[idx].Id;
+ cod2.Consumable_Sale_order__c = orderInfoMap.get(ass.orderName);
+ cod2.Consumable_ZS_order__c = orderInfoMap.get(ass.orderName);
+ cod2.Used_date__c = ass.orderdetails2.Used_date__c;
+ cod2.Send_Date__c = ass.orderdetails2.Send_Date__c;
+ //cod2.Unitprice_To_agency__c = ass.orderdetails2.Unitprice_To_agency__c;
+ cod2.Delivery_List_RMB__c = ass.orderdetails2.Delivery_List_RMB__c;
+ cod2List.add(cod2);
+ cOrderDetPiece[idx].Bar_Code__c = '';
+ idy++;
+ //break;
+ }
}
- }
+ }
+ if (cod2List.size() > 0) {
+ update cod2List;
+ }
+ errorflg = true;
+ //errorMessage = '淇濆瓨瀹屾垚銆�';
+ saveFLGbln = true;
- public static List<ConsumableorderdetailsInfo> getorderdet2pieceList(List<String[]> csvRecordStr) {
- barcodePieceList = new List<String>();
- List<ConsumableorderdetailsInfo> orderdet2PieceRecords = new List<ConsumableorderdetailsInfo>();
- try {
- for (Integer i = 1; i < csvRecordStr.size(); i++) {
- string[] csvRecordData = csvRecordStr[i];
- if (String.valueOf(csvRecordData[9]) == '涓�') {
- Consumable_Order_details2__c cod2Obj = new Consumable_Order_details2__c();
- cod2Obj.TracingCode__c = csvRecordData[0];
- cod2Obj.Bar_Code__c = csvRecordData[6];
- if (String.isNotBlank(csvRecordData[6])) {
- barcodePieceList.add(csvRecordData[6]);
- }
- cod2Obj.Box_Piece__c = csvRecordData[9];
- if (String.isNotBlank(csvRecordData[8])) {
- cod2Obj.Delivery_List_RMB__c = Decimal.valueOf(csvRecordData[8]);
- }
- cod2Obj.Return_reason__c = csvRecordData[12];
- if (String.valueOf(csvRecordData[1]) == '閿�鍞粰浜岀骇缁忛攢鍟�' || String.valueOf(csvRecordData[1]) == '鐩存帴閿�鍞粰鍖婚櫌') {
- cod2Obj.Used_date__c = Date.parse(csvRecordData[11].trim());
- } else {
- cod2Obj.Send_Date__c = Date.parse(csvRecordData[11].trim());
- }
- cod2Obj.Rrturn_count__c = Decimal.valueOf(csvRecordData[7]);
- orderdet2PieceRecords.add(new ConsumableorderdetailsInfo(cod2Obj));
- }
- }
- return orderdet2PieceRecords;
- } catch (Exception e) {
- // ApexPages.addMessages(e);
- // return null;
- errorMsg += e.getMessage();
- return null;
- }
+ res.status = 'Success';
+ res.code = 200;
+ res.msg = errorMsg;
+ return res;
+ } catch (Exception e) {
+ Database.rollback(sp);
+ // ApexPages.addMessages(e);
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ e.getMessage() + e.getStackTraceString(),
+ ''
+ );
}
+ }
- class ConsumableorderdetailsInfo implements Comparable {
- @AuraEnabled
- public Consumable_order__c order { get; set; }
- @AuraEnabled
- public Consumable_orderdetails__c orderdetails1 { get; set; }
- @AuraEnabled
- public Consumable_order_details2__c orderdetails2 { get; set; }
- @AuraEnabled
- public String orderName { get; set; }
- @AuraEnabled
- public String hospitalCode { get; set; }
- @AuraEnabled
- public String hospitalName { get; set; }
- @AuraEnabled
- public String agencyName { get; set; }
- @AuraEnabled
- public String productName { get; set; }
- @AuraEnabled
- public Decimal pieceCount { get; set; }
- // 鍙栧埌鐨勮鍗曚俊鎭�
- public ConsumableorderdetailsInfo(Consumable_order__c e) {
- order = e;
- hospitalCode = e.Order_Attachment__c;
- hospitalName = e.Order_Indication__c;
- agencyName = e.Invoice_Note__c;
- e.Order_Attachment__c = '';
- e.Order_Indication__c = '';
- e.Invoice_Note__c = '';
+ public static List<ConsumableorderdetailsInfo> getorderdetList(
+ List<String[]> csvRecordStr
+ ) {
+ List<ConsumableorderdetailsInfo> orderdetRecords = new List<ConsumableorderdetailsInfo>();
+ map<string, Decimal> orderdetMap = new Map<string, Decimal>();
+ try {
+ for (Integer i = 1; i < csvRecordStr.size(); i++) {
+ Consumable_Orderdetails__c codObj = new Consumable_Orderdetails__c();
+ string[] csvRecordData = csvRecordStr[i];
+ if (
+ orderdetMap.containsKey(
+ csvRecordData[0] + csvRecordData[12] + csvRecordData[9]
+ )
+ ) {
+ orderdetMap.put(
+ csvRecordData[0] + csvRecordData[12] + csvRecordData[9],
+ orderdetMap.get(
+ csvRecordData[0] + csvRecordData[12] + csvRecordData[9]
+ ) + Decimal.valueOf(csvRecordData[7])
+ );
+ continue;
+ } else {
+ orderdetMap.put(
+ csvRecordData[0] + csvRecordData[12] + csvRecordData[9],
+ Decimal.valueOf(csvRecordData[7])
+ );
}
- // 鍙栧埌鐨勮鍗曟槑缁�
- public ConsumableorderdetailsInfo(Consumable_orderdetails__c e) {
- orderdetails1 = e;
- orderName = e.Remarks__c;
- productName = e.Lose_reason__c;
- e.Lose_reason__c = '';
- e.Remarks__c = '';
+ codObj.Remarks__c = csvRecordData[0];
+ codObj.Shipment_Count__c = Decimal.valueOf(csvRecordData[7]);
+ codObj.Box_Piece__c = csvRecordData[9];
+ if (String.isNotBlank(csvRecordData[8])) {
+ codObj.Delivery_List_RMB__c = Decimal.valueOf(csvRecordData[8]);
}
- // 鍙栧埌鐨勪骇鍝佹槑缁�
- public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
- orderdetails2 = e;
- orderName = e.TracingCode__c;
- productName = e.Return_reason__c;
- pieceCount = e.Rrturn_count__c;
- e.TracingCode__c = '';
- e.Return_reason__c = '';
- e.Rrturn_count__c = null;
+ codObj.Lose_reason__c = csvRecordData[12];
+ if (String.isNotBlank(csvRecordData[11])) {
+ codObj.Used_date__c = Date.parse(csvRecordData[11].trim());
}
- public Integer compareTo(Object compareTo) {
- return null;
+ product2conMap.put(csvRecordData[12].trim(), csvRecordData[12].trim());
+ orderdetRecords.add(new ConsumableorderdetailsInfo(codObj));
+ }
+ for (ConsumableorderdetailsInfo ass : orderdetRecords) {
+ if (
+ orderdetMap.containsKey(
+ ass.orderName + ass.productName + ass.orderdetails1.Box_Piece__c
+ )
+ ) {
+ ass.orderdetails1.Shipment_Count__c = orderdetMap.get(
+ ass.orderName + ass.productName + ass.orderdetails1.Box_Piece__c
+ );
}
+ }
+ System.debug('orderdetRecords = ' + orderdetRecords);
+ return orderdetRecords;
+ } catch (Exception e) {
+ // ApexPages.addMessages(e);
+ // return null;
+ errorMsg += e.getMessage() + ' ' + e.getLineNumber() + ';';
+ System.debug('orderdetRecords = null ' + e.getLineNumber());
+ return null;
}
-}
\ No newline at end of file
+ }
+
+ public static List<ConsumableorderdetailsInfo> getorderdet2BoxList(
+ List<String[]> csvRecordStr
+ ) {
+ barcodeList = new List<String>();
+ List<ConsumableorderdetailsInfo> orderdet2BoxRecords = new List<ConsumableorderdetailsInfo>();
+ try {
+ for (Integer i = 1; i < csvRecordStr.size(); i++) {
+ string[] csvRecordData = csvRecordStr[i];
+ if (String.valueOf(csvRecordData[9]) == '鐩�') {
+ Consumable_Order_details2__c cod2Obj = new Consumable_Order_details2__c();
+ cod2Obj.TracingCode__c = csvRecordData[0];
+ cod2Obj.Bar_Code__c = csvRecordData[6];
+ if (String.isNotBlank(csvRecordData[6])) {
+ barcodeList.add(csvRecordData[6]);
+ }
+ cod2Obj.Box_Piece__c = csvRecordData[9];
+ if (String.isNotBlank(csvRecordData[8])) {
+ cod2Obj.Delivery_List_RMB__c = Decimal.valueOf(csvRecordData[8]);
+ }
+ //if(String.isNotBlank(csvRecordData[10])){
+ // cod2Obj.Unitprice_To_agency__c = Decimal.valueOf(csvRecordData[10]);
+ //}
+ cod2Obj.Return_reason__c = csvRecordData[12];
+ if (
+ String.valueOf(csvRecordData[1]) == '閿�鍞粰浜岀骇缁忛攢鍟�' ||
+ String.valueOf(csvRecordData[1]) == '鐩存帴閿�鍞粰鍖婚櫌'
+ ) {
+ cod2Obj.Used_date__c = Date.parse(csvRecordData[11].trim());
+ } else {
+ cod2Obj.Send_Date__c = Date.parse(csvRecordData[11].trim());
+ }
+ orderdet2BoxRecords.add(new ConsumableorderdetailsInfo(cod2Obj));
+ }
+ }
+ return orderdet2BoxRecords;
+ } catch (Exception e) {
+ // ApexPages.addMessages(e);
+ // return null;
+ errorMsg += e.getMessage() + ' ' + e.getLineNumber() + ';';
+ return null;
+ }
+ }
+
+ public static List<ConsumableorderdetailsInfo> getorderdet2pieceList(
+ List<String[]> csvRecordStr
+ ) {
+ barcodePieceList = new List<String>();
+ List<ConsumableorderdetailsInfo> orderdet2PieceRecords = new List<ConsumableorderdetailsInfo>();
+ try {
+ for (Integer i = 1; i < csvRecordStr.size(); i++) {
+ string[] csvRecordData = csvRecordStr[i];
+ if (String.valueOf(csvRecordData[9]) == '涓�') {
+ Consumable_Order_details2__c cod2Obj = new Consumable_Order_details2__c();
+ cod2Obj.TracingCode__c = csvRecordData[0];
+ cod2Obj.Bar_Code__c = csvRecordData[6];
+ if (String.isNotBlank(csvRecordData[6])) {
+ barcodePieceList.add(csvRecordData[6]);
+ }
+ cod2Obj.Box_Piece__c = csvRecordData[9];
+ if (String.isNotBlank(csvRecordData[8])) {
+ cod2Obj.Delivery_List_RMB__c = Decimal.valueOf(csvRecordData[8]);
+ }
+ cod2Obj.Return_reason__c = csvRecordData[12];
+ if (
+ String.valueOf(csvRecordData[1]) == '閿�鍞粰浜岀骇缁忛攢鍟�' ||
+ String.valueOf(csvRecordData[1]) == '鐩存帴閿�鍞粰鍖婚櫌'
+ ) {
+ cod2Obj.Used_date__c = Date.parse(csvRecordData[11].trim());
+ } else {
+ cod2Obj.Send_Date__c = Date.parse(csvRecordData[11].trim());
+ }
+ cod2Obj.Rrturn_count__c = Decimal.valueOf(csvRecordData[7]);
+ orderdet2PieceRecords.add(new ConsumableorderdetailsInfo(cod2Obj));
+ }
+ }
+ return orderdet2PieceRecords;
+ } catch (Exception e) {
+ // ApexPages.addMessages(e);
+ // return null;
+ errorMsg += e.getMessage();
+ return null;
+ }
+ }
+ @TestVisible
+ class ConsumableorderdetailsInfo implements Comparable {
+ @AuraEnabled
+ public Consumable_order__c order { get; set; }
+ @AuraEnabled
+ public Consumable_orderdetails__c orderdetails1 { get; set; }
+ @AuraEnabled
+ public Consumable_order_details2__c orderdetails2 { get; set; }
+ @AuraEnabled
+ public String orderName { get; set; }
+ @AuraEnabled
+ public String hospitalCode { get; set; }
+ @AuraEnabled
+ public String hospitalName { get; set; }
+ @AuraEnabled
+ public String agencyName { get; set; }
+ @AuraEnabled
+ public String productName { get; set; }
+ @AuraEnabled
+ public Decimal pieceCount { get; set; }
+ // 鍙栧埌鐨勮鍗曚俊鎭�
+ public ConsumableorderdetailsInfo(Consumable_order__c e) {
+ order = e;
+ hospitalCode = e.Order_Attachment__c;
+ hospitalName = e.Order_Indication__c;
+ agencyName = e.Invoice_Note__c;
+ e.Order_Attachment__c = '';
+ e.Order_Indication__c = '';
+ e.Invoice_Note__c = '';
+ }
+ // 鍙栧埌鐨勮鍗曟槑缁�
+ public ConsumableorderdetailsInfo(Consumable_orderdetails__c e) {
+ orderdetails1 = e;
+ orderName = e.Remarks__c;
+ productName = e.Lose_reason__c;
+ e.Lose_reason__c = '';
+ e.Remarks__c = '';
+ }
+ // 鍙栧埌鐨勪骇鍝佹槑缁�
+ public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
+ orderdetails2 = e;
+ orderName = e.TracingCode__c;
+ productName = e.Return_reason__c;
+ pieceCount = e.Rrturn_count__c;
+ e.TracingCode__c = '';
+ e.Return_reason__c = '';
+ e.Rrturn_count__c = null;
+ }
+ public Integer compareTo(Object compareTo) {
+ return null;
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexOutboundorderImportControllerTest.cls b/force-app/main/default/classes/LexOutboundorderImportControllerTest.cls
new file mode 100644
index 0000000..4660afe
--- /dev/null
+++ b/force-app/main/default/classes/LexOutboundorderImportControllerTest.cls
@@ -0,0 +1,682 @@
+@isTest
+private class LexOutboundorderImportControllerTest {
+ static testMethod void myUnitTest() {
+ user myUser_test;
+ Account myAccount1;
+ List<RecordType> rectHos;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ rectHos = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectHos.size() == 0) {
+ return;
+ }
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 20,
+ 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;
+ 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',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+ // TO DO: implement unit test
+
+ System.runAs(myUser_Test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 12,
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 12,
+ 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.RecordTypeid = System.Label.RT_ConOrder_Order;
+ Order1.Dealer_Info__c = myAccount1.Id;
+ Order1.Order_ProType__c = 'ET';
+ insert Order1;
+ Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+ Orderdet4.Name = 'OCM_01_001004';
+ Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet4.Consumable_Arrived_order__c = Order1.Id;
+ Orderdet4.Sterilization_limit__c = Date.today().addDays(-1);
+ Orderdet4.Bar_Code__c = '123456789';
+ Orderdet4.Consumable_Product__c = pro1.Id;
+ Orderdet4.Arrive_date__c = Date.today().addDays(-1);
+ Orderdet4.Box_Piece__c = '鐩�';
+
+ Consumable_order_details2__c orderdet3 = new Consumable_order_details2__c();
+ orderdet3.Name = 'OCM_01_001004';
+ orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ orderdet3.Consumable_Arrived_order__c = Order1.Id;
+ orderdet3.Sterilization_limit__c = Date.today().addDays(-1);
+ orderdet3.Bar_Code__c = '123456788';
+ orderdet3.Consumable_Product__c = pro1.Id;
+ orderdet3.Arrive_date__c = Date.today().addDays(-1);
+ orderdet3.Box_Piece__c = '鐩�';
+
+ Consumable_order_details2__c orderdet2 = new Consumable_order_details2__c();
+ orderdet2.Name = 'OCM_01_001004';
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ orderdet2.Consumable_Arrived_order__c = Order1.Id;
+ orderdet2.Sterilization_limit__c = Date.today().addDays(-1);
+ orderdet2.Bar_Code__c = '123456787';
+ orderdet2.Consumable_Product__c = pro1.Id;
+ orderdet2.Arrive_date__c = Date.today().addDays(-1);
+ orderdet2.Box_Piece__c = '涓�';
+
+ Consumable_order_details2__c orderdet1 = new Consumable_order_details2__c();
+ Orderdet1.Name = 'OCM_01_001004';
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet1.Consumable_Arrived_order__c = Order1.Id;
+ Orderdet1.Sterilization_limit__c = Date.today().addDays(-1);
+ Orderdet1.Bar_Code__c = '123456786';
+ Orderdet1.Consumable_Product__c = pro1.Id;
+ Orderdet1.Arrive_date__c = Date.today().addDays(-1);
+ Orderdet1.Box_Piece__c = '涓�';
+ insert new List<Consumable_order_details2__c>{
+ orderdet1,
+ orderdet2,
+ orderdet3,
+ orderdet4
+ };
+ Account hosp1 = new Account(
+ name = 'Testhosp001',
+ RecordTypeId = rectHos[0].Id
+ );
+ insert hosp1;
+ Agency_Hospital_Link__c jxs = new Agency_Hospital_Link__c(
+ name = 'jxs001',
+ Agency__c = myAccount1.Id,
+ Hospital__c = hosp1.Id
+ );
+ insert jxs;
+ List<Agency_Hospital_Link__c> jxsList = [
+ SELECT Name, Hospital__r.Management_Code__c
+ FROM Agency_Hospital_Link__c
+ WHERE Name = 'Testhosp001'
+ ];
+
+ List<LexOutboundorderImportController.ConsumableorderdetailsInfo> orderRecords1 = new List<LexOutboundorderImportController.ConsumableorderdetailsInfo>();
+ //鍑哄簱鍗�
+ Consumable_order__c cocObj = new Consumable_order__c();
+ cocObj.Name = 'DB-FY2024-06-Z310002';
+ cocObj.SummonsForDirction__c = '閿�鍞粰浜岀骇缁忛攢鍟�';
+ cocObj.Order_Attachment__c = 'Test';
+ cocObj.Order_Indication__c = '12233';
+ cocObj.Order_ForCustomerText__c = '娑堝寲绉�';
+ cocObj.Invoice_Note__c = 'test';
+ cocObj.Outbound_Date__c = Date.today();
+ insert cocObj;
+ orderRecords1.add(
+ new LexOutboundorderImportController.ConsumableorderdetailsInfo(cocObj)
+ );
+
+ system.assertEquals(1, jxsList.size());
+ PageReference page = new PageReference('/apex/OutboundorderImport');
+ System.Test.setCurrentPage(page);
+ OutboundorderImportController ctrl = new OutboundorderImportController();
+ System.Test.startTest();
+ String csvBody = '';
+ csvBody = 'Name,SummonsForDirction__c,HospitalCode,Order_ForHospital__c,Order_ForCustomerText__c,Order_ForDealer__c,Bar_Code__c,Shipment_Count__c,Delivery_List_RMB__c,Box_Piece__c,Unitprice_To_agency__c,Outbound_Date__c\n';
+ csvBody +=
+ 'CS-S0001,閿�鍞粰浜岀骇缁忛攢鍟�,' +
+ jxsList[0].Hospital__r.Management_Code__c +
+ ',Testhosp001,test,娴嬭瘯浜岀骇缁忛攢鍟�1,123456789,1,230,鐩�,230,2017-02-17\n';
+ csvBody +=
+ 'CS-S0001,閿�鍞粰浜岀骇缁忛攢鍟�,' +
+ jxsList[0].Hospital__r.Management_Code__c +
+ ',Testhosp001,test,娴嬭瘯浜岀骇缁忛攢鍟�1,123456788,1,230,鐩�,230,2017-02-17\n';
+ csvBody +=
+ 'CS-S0001,閿�鍞粰浜岀骇缁忛攢鍟�,' +
+ jxsList[0].Hospital__r.Management_Code__c +
+ ',Testhosp001,test,娴嬭瘯浜岀骇缁忛攢鍟�1,123456787,1,230,涓�,230,2017-02-17\n';
+ csvBody +=
+ 'CS-S0001,閿�鍞粰浜岀骇缁忛攢鍟�,' +
+ jxsList[0].Hospital__r.Management_Code__c +
+ ',Testhosp001,test,娴嬭瘯浜岀骇缁忛攢鍟�1,123456786,1,230,涓�,230,2017-02-17\n';
+
+ LexOutboundorderImportController.importCSVFile(
+ 'TmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LVozMTAwMDIs55u05o6l6ZSA5ZSu57uZ5Yy76ZmiLDgxMDU2NDAs5a6955S45Lic5qGl5bq35aSN5Yy76ZmiLOa2iOWMluenkSwsMTY4NjIwMzI1NDQ2ODI1MFZWR0lVLDEsMjAwMCznm5IsMjAsMjAyMy82Lzgs5Lii5aSx5Y6f5ZugDQpEQi1GWTIwMjQtMDYtWjMxMDAwMyznm7TmjqXplIDllK7nu5nljLvpmaIsODEwNTY0MCzlrr3nlLjkuJzmoaXlurflpI3ljLvpmaIs5raI5YyW56eRLCwxNjg2MjAzMjU2MDk4MjUwUkVKT1EsMSwzMDAwLOebkiwyMCwyMDIzLzYvOCzkuKLlpLHljp%2Flm6ANCkRCLUZZMjAyNC0wNi1aMzEwMDA0LOebtOaOpemUgOWUrue7meWMu%2BmZoiw4MTA1NjQwLOWuveeUuOS4nOahpeW6t%2BWkjeWMu%2BmZoizmtojljJbnp5EsLDE2ODYyMDMyNTc2NTcyNTBHU0ZTQiwxLDQwMDAs55uSLDIwLDIwMjMvNi84LOS4ouWkseWOn%2BWboA0K',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ //鍑哄簱鏃ユ湡涓虹┖
+ LexOutboundorderImportController.importCSVFile(
+ '77u%2FTmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LVozMTAwMDIsLDgxMDU2NDAs54C555WM5pW75raT5ruEy4nmkLTls7DumLLpjZblqZrmq4ws5aiR5aCd5a%2By57uJPywxNjg2MjAzMjU0NDY4MjUwVlZHSVUsMSwyMDAwLOmQqT8yMCw4LzYvMjAyMyzmtpPjiKDjgZHpjZjnhrfmtJwsLA0KREItRlkyMDI0LTA2LVozMTAwMDMs6ZCp5a2Y5bi06Za%2F4oKs6Y2e7oa%2B57Kw6Y2W5ama5quMLDgxMDU2NDAs54C555WM5pW75raT5ruEy4nmkLTls7DumLLpjZblqZrmq4ws5aiR5aCd5a%2By57uJPywxNjg2MjAzMjU2MDk4MjUwUkVKT1EsMSwzMDAwLOmQqT8yMCw4LzYvMjAyMyzmtpPjiKDjgZHpjZjnhrfmtJwsLA0KREItRlkyMDI0LTA2LVozMTAwMDQs6ZCp5a2Y5bi06Za%2F4oKs6Y2e7oa%2B57Kw6Y2W5ama5quMLDgxMDU2NDAs54C555WM5pW75raT5ruEy4nmkLTls7DumLLpjZblqZrmq4ws5aiR5aCd5a%2By57uJPywxNjg2MjAzMjU3NjU3MjUwR1NGU0IsMSw0MDAwLOmQqT8yMCw4LzYvMjAyMyzmtpPjiKDjgZHpjZjnhrfmtJwsLA0K',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ //鍐呭涓虹┖
+ //涓嶉渶瑕佷簩绾х粡閿�鍟�
+ LexOutboundorderImportController.importCSVFile(
+ '77u%2FTmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYywNCkRCLUZZMjAyNC0wNi1aMzEwMDAyLOmUgOWUrue7meS6jOe6p%2Be7j%2BmUgOWVhiw4MTA1NjQwLOWuveeUuOS4nOahpeW6t%2BWkjeWMu%2BmZoizmtojljJbnp5EsMTY4NjIwMzI1NDQ2ODI1MFZWR0lVLDEsMjAwMCwyMCw4LzYvMjAyMywsLCwNCkRCLUZZMjAyNC0wNi1aMzEwMDAzLOebtOaOpemUgOWUrue7meWMu%2BmZoiw4MTA1NjQwLOWuveeUuOS4nOahpeW6t%2BWkjeWMu%2BmZoizmtojljJbnp5EsMTY4NjIwMzI1NjA5ODI1MFJFSk9RLDEsNDAwMCwyMCw4LzYvMjAyMywsLCwNCkRCLUZZMjAyNC0wNi1aMzEwMDA0LOS6kuebuOiwg%2Bi0pyw4MTA1NjQwLOWuveeUuOS4nOahpeW6t%2BWkjeWMu%2BmZoizmtojljJbnp5EsLDEsNTAwMCwyMCw4LzYvMjAyMywsLCwNCg%3D%3D',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ LexOutboundorderImportController.importCSVFile(
+ '77u%2FTmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LVozMTAwMDIs6ZSA5ZSu57uZ5LqM57qn57uP6ZSA5ZWGLDgxMDU2NDAs5a6955S45Lic5qGl5bq35aSN5Yy76ZmiLOa2iOWMluenkSwxNjg2MjAzMjU0NDY4MjUwVlZHSVUsMSwyMDAwLDIwLDgvNi8yMDIzLCwsDQpEQi1GWTIwMjQtMDYtWjMxMDAwMyznm7TmjqXplIDllK7nu5nljLvpmaIsODEwNTY0MCzlrr3nlLjkuJzmoaXlurflpI3ljLvpmaIs5raI5YyW56eRLDE2ODYyMDMyNTYwOTgyNTBSRUpPUSwxLDQwMDAsMjAsOC82LzIwMjMsLCwNCkRCLUZZMjAyNC0wNi1aMzEwMDA0LOS6kuebuOiwg%2Bi0pywsLCwsMSw1MDAwLDIwLDgvNi8yMDIzLCwsDQo%3D',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ //barcode 涓嶅瓨鍦� 鎴栧崟浣嶉敊璇�
+ LexOutboundorderImportController.importCSVFile(
+ '77u%2FTmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LVozMTAwMDIs6ZSA5ZSu57uZ5LqM57qn57uP6ZSA5ZWGLDgxMDU2NDAs5a6955S45Lic5qGl5bq35aSN5Yy76ZmiLOa2iOWMluenkSwsMTY4NjIwMzI1NDQ2ODI1MFZWR0lVLDEsODAwLOebkiwsOC82LzIwMjMsDQpEQi1GWTIwMjQtMDYtWjMxMDAwMyznm7TmjqXplIDllK7nu5nljLvpmaIsODEwNTY0MCzlrr3nlLjkuJzmoaXlurflpI3ljLvpmaIs5raI5YyW56eRLCwxNjg2MjAzMjU2MDk4MjUwUkVKT1EsMiw1MDAs5LiqLCw4LzYvMjAyMywNCkRCLUZZMjAyNC0wNi1aMzEwMDA0LOS6kuebuOiwg%2Bi0pyw4MTA1NjQwLOWuveeUuOS4nOahpeW6t%2BWkjeWMu%2BmZoizmtojljJbnp5EsLDE2ODYyMDMyNTc2NTcyNTBHU0ZTQiw0LDkwMDAs55uSLCw4LzYvMjAyMywNCg%3D%3D',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ //涓嶅瓨鍦ㄥ嚭搴撳崟浣�
+ LexOutboundorderImportController.importCSVFile(
+ '77u%2FTmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LVozMTAwMDIs6ZSA5ZSu57uZ5LqM57qn57uP6ZSA5ZWGLDgxMDU2NDAs5a6955S45Lic5qGl5bq35aSN5Yy76ZmiLOa2iOWMluenkSwsMTY4NjIwMzI1NDQ2ODI1MFZWR0lVLDEsODAwLCwsOC82LzIwMjMsDQpEQi1GWTIwMjQtMDYtWjMxMDAwMyznm7TmjqXplIDllK7nu5nljLvpmaIsODEwNTY0MCzlrr3nlLjkuJzmoaXlurflpI3ljLvpmaIs5raI5YyW56eRLCwxMjM0NTY3ODYsMiw1MDAs5LiqLCw4LzYvMjAyMywNCkRCLUZZMjAyNC0wNi1aMzEwMDA0LOS6kuebuOiwg%2Bi0pyw4MTA1NjQwLOWuveeUuOS4nOahpeW6t%2BWkjeWMu%2BmZoizmtojljJbnp5EsLDE2ODYyMDMyNTc2NTcyNTBHU0ZTQiw0LDkwMDAs55uSLCw4LzYvMjAyMywNCg%3D%3D',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+
+ //瀵煎叆
+ List<String[]> csvRecordStr = LexOutboundorderImportController.csvRecordStr;
+ List<LexOutboundorderImportController.ConsumableorderdetailsInfo> orderRecords = LexOutboundorderImportController.orderRecords;
+ String orderRecordsLwc = JSON.serialize(orderRecords);
+
+ Map<String, String> secondAgencyMap = LexOutboundorderImportController.secondAgencyMap;
+ Map<String, String> hospitalSysMap = LexOutboundorderImportController.hospitalSysMap;
+ LexOutboundorderImportController.dataImport(
+ csvRecordStr,
+ orderRecordsLwc,
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001',
+ 'myAccount1.Id',
+ 'ET',
+ secondAgencyMap,
+ hospitalSysMap
+ );
+ LexOutboundorderImportController.dataImport(
+ csvRecordStr,
+ orderRecordsLwc,
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001',
+ 'myAccount1.Id',
+ 'ET',
+ secondAgencyMap,
+ hospitalSysMap
+ );
+ LexOutboundorderImportController.dataImport(
+ csvRecordStr,
+ '[{"agencyName": "","hospitalCode": "8215356","hospitalName": "瀹界敻涓滄ˉ搴峰鍖婚櫌","order": {"Name": "DB-FY2024-06-Z310002","SummonsForDirction__c": "鐩存帴閿�鍞粰鍖婚櫌","Order_ForHospital__c":"娴嬭瘯鍖婚櫌","Order_Attachment__c": "","Order_Indication__c": "","Order_ForCustomerText__c": "娑堝寲绉�","Invoice_Note__c": "","Outbound_Date__c": "2023-06-08"}}]',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001',
+ 'myAccount1.Id',
+ 'ET',
+ secondAgencyMap,
+ hospitalSysMap
+ );
+
+ LexOutboundorderImportController ctrls = new LexOutboundorderImportController();
+ LexOutboundorderImportController.init();
+ Blob blobData = Blob.valueOf(csvBody);
+ String base64Data = EncodingUtil.base64Encode(blobData);
+ LexOutboundorderImportController.importCSVFile(
+ 'base64Data',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ String csvBody1 = '';
+ csvBody1 = 'Name,SummonsForDirction__c,HospitalCode,Order_ForHospital__c,Order_ForCustomerText__c,Order_ForDealer__c,Bar_Code__c,Shipment_Count__c,Delivery_List_RMB__c,Box_Piece__c,Unitprice_To_agency__c,product,Outbound_Date__c\n';
+ csvBody1 += 'CS-S0001,鍖婚櫌璇曠敤,,,,鍖婚櫌璇曠敤1,123456789,1,,鐩�,230,2017-02-17\n';
+ csvBody1 += 'CS-S0001,鍖婚櫌璇曠敤,,,,鍖婚櫌璇曠敤1,123456788,1,,鐩�,230,2017-02-17\n';
+ csvBody1 += 'CS-S0001,鍖婚櫌璇曠敤,,,,娴嬪尰闄㈣瘯鐢�1,123456787,1,,鐩�,230,2017-02-17\n';
+ csvBody1 += 'CS-S0001,鍖婚櫌璇曠敤,,,,鍖婚櫌璇曠敤1,123456786,1,,鐩�,230,2017-02-17\n';
+ Blob blobData1 = Blob.valueOf(csvBody1);
+ String base64Data1 = EncodingUtil.base64Encode(blobData1);
+ LexOutboundorderImportController.importCSVFile(
+ 'base64Data1',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ String csvBody2 = '';
+ csvBody2 = 'Name,SummonsForDirction__c,HospitalCode,Order_ForHospital__c,Order_ForCustomerText__c,Order_ForDealer__c,Bar_Code__c,Shipment_Count__c,Delivery_List_RMB__c,Box_Piece__c,Unitprice_To_agency__c,Outbound_Date__c\n';
+ csvBody2 += 'CS-S0001,鍖婚櫌璇曠敤,,,,鍖婚櫌璇曠敤1,,1,230,鐩�,230,2017-02-17\n';
+ csvBody2 += 'CS-S0001,鍖婚櫌璇曠敤,,,,鍖婚櫌璇曠敤1,,1,230,鐩�,230,2017-02-17\n';
+ csvBody2 += 'CS-S0001,鍖婚櫌璇曠敤,,,,娴嬪尰闄㈣瘯鐢�1,,1,230,鐩�,230,2017-02-17\n';
+ csvBody2 += 'CS-S0001,鍖婚櫌璇曠敤,,,,鍖婚櫌璇曠敤1,,1,230,鐩�,230,2017-02-17\n';
+ Blob blobData2 = Blob.valueOf(csvBody2);
+ String base64Data2 = EncodingUtil.base64Encode(blobData1);
+ LexOutboundorderImportController.importCSVFile(
+ 'base64Data2',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+
+ String csvBody3 = '';
+ csvBody3 = 'Name,SummonsForDirction__c,HospitalCode,Order_ForHospital__c,Order_ForCustomerText__c,Order_ForDealer__c,Bar_Code__c,Shipment_Count__c,Delivery_List_RMB__c,Box_Piece__c,Unitprice_To_agency__c,Outbound_Date__c\n';
+ csvBody3 += 'CS-S0001,鍖婚櫌璇曠敤,,,,鍖婚櫌璇曠敤1,123456789,1,230,鐩�,230,2017-02-17\n';
+ csvBody3 += 'CS-S0001,鍖婚櫌璇曠敤,,,,鍖婚櫌璇曠敤1,123456788,1,230,鐩�,230,2017-02-17\n';
+ csvBody3 += 'CS-S0001,鍖婚櫌璇曠敤,,,,娴嬪尰闄㈣瘯鐢�1,123456787,1,230,鐩�,230,2017-02-17\n';
+ csvBody3 += 'CS-S0001,鍖婚櫌璇曠敤,,,,鍖婚櫌璇曠敤1,123456786,12,230,鐩�,230,2017-02-17\n';
+ Blob blobData3 = Blob.valueOf(csvBody3);
+ String base64Data3 = EncodingUtil.base64Encode(blobData3);
+ LexOutboundorderImportController.importCSVFile(
+ 'base64Data3',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ System.Test.stopTest();
+ }
+ }
+
+ static testMethod void allTest() {
+ user myUser_test;
+ Account myAccount1;
+ List<RecordType> rectHos;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ rectHos = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectHos.size() == 0) {
+ return;
+ }
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 20,
+ 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;
+ 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',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+ System.runAs(MyUser_Test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 12,
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 12,
+ 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.RecordTypeid = System.Label.RT_ConOrder_Order;
+ Order1.Dealer_Info__c = myAccount1.Id;
+ Order1.Order_ProType__c = 'ET';
+ insert Order1;
+
+ Consumable_order__c Order2 = new Consumable_order__c();
+ Order2.Name = 'OCM_01_001';
+ Order2.Order_status__c = '鎵瑰噯';
+ Order2.Order_type__c = '浼犵エ';
+ order2.SummonsStatus_c__c = '宸插畬鎴�';
+ Order2.Dealer_Info__c = myAccount1.Id;
+ Order2.Order_ProType__c = 'ET';
+ Order2.SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌';
+ insert Order2;
+
+ Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+ Orderdet4.Name = 'OCM_01_001004';
+ Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet4.Consumable_Arrived_order__c = Order1.Id;
+ Orderdet4.Sterilization_limit__c = Date.today().addDays(-1);
+ Orderdet4.Bar_Code__c = '123456789';
+ Orderdet4.Consumable_Product__c = pro1.Id;
+ Orderdet4.Arrive_date__c = Date.today().addDays(-1);
+ Orderdet4.Box_Piece__c = '鐩�';
+
+ Consumable_order_details2__c orderdet3 = new Consumable_order_details2__c();
+ orderdet3.Name = 'OCM_01_001004';
+ orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ orderdet3.Consumable_Arrived_order__c = Order1.Id;
+ orderdet3.Sterilization_limit__c = Date.today().addDays(-1);
+ orderdet3.Bar_Code__c = '1686203254468250VVGIU';
+ orderdet3.Consumable_Product__c = pro1.Id;
+ orderdet3.Arrive_date__c = Date.today().addDays(-1);
+ orderdet3.Box_Piece__c = '鐩�';
+ orderdet3.Lose_Flag__c = false;
+
+ Consumable_order_details2__c orderdet2 = new Consumable_order_details2__c();
+ orderdet2.Name = 'OCM_01_001004';
+ orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ orderdet2.Consumable_Arrived_order__c = Order1.Id;
+ orderdet2.Sterilization_limit__c = Date.today().addDays(-1);
+ orderdet2.Bar_Code__c = '1686203256098250REJOQ';
+ orderdet2.Consumable_Product__c = pro1.Id;
+ orderdet2.Arrive_date__c = Date.today().addDays(-1);
+ orderdet2.Box_Piece__c = '涓�';
+
+ Consumable_order_details2__c orderdet1 = new Consumable_order_details2__c();
+ Orderdet1.Name = 'OCM_01_001004';
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet1.Consumable_Arrived_order__c = Order1.Id;
+ Orderdet1.Sterilization_limit__c = Date.today().addDays(-1);
+ Orderdet1.Bar_Code__c = '1686203257657250GSFSB';
+ Orderdet1.Consumable_Product__c = pro1.Id;
+ Orderdet1.Arrive_date__c = Date.today().addDays(-1);
+ Orderdet1.Box_Piece__c = '涓�';
+ insert new List<Consumable_order_details2__c>{
+ orderdet1,
+ orderdet2,
+ orderdet3,
+ orderdet4
+ };
+ Account hosp1 = new Account(
+ name = 'Testhosp001',
+ RecordTypeId = rectHos[0].Id
+ );
+ insert hosp1;
+ Agency_Hospital_Link__c jxs = new Agency_Hospital_Link__c(
+ name = 'jxs001',
+ Agency__c = myAccount1.Id,
+ Hospital__c = hosp1.Id
+ );
+ insert jxs;
+ List<Agency_Hospital_Link__c> jxsList = [
+ SELECT Name, Hospital__r.Management_Code__c
+ FROM Agency_Hospital_Link__c
+ WHERE Name = 'Testhosp001'
+ ];
+ //杩愯鏁版嵁
+ System.Test.startTest();
+ LexOutboundorderImportController.init();
+ String csvBody = '';
+ //hospitalCode=null,hospitalName!=null
+ csvBody = 'Name,SummonsForDirction__c,HospitalCode,Order_ForHospital__c,Order_ForCustomerText__c,Order_ForDealer__c,Bar_Code__c,Shipment_Count__c,Delivery_List_RMB__c,Box_Piece__c,Unitprice_To_agency__c,Outbound_Date__c\n';
+ csvBody +=
+ 'CS-S0001,閿�鍞粰浜岀骇缁忛攢鍟�,' +
+ jxsList[0].Hospital__r.Management_Code__c +
+ ',Testhosp001,test,娴嬭瘯浜岀骇缁忛攢鍟�1,123456789,1,230,鐩�,230,2017-02-17\n';
+ csvBody +=
+ 'CS-S0001,閿�鍞粰浜岀骇缁忛攢鍟�,' +
+ jxsList[0].Hospital__r.Management_Code__c +
+ ',Testhosp001,test,娴嬭瘯浜岀骇缁忛攢鍟�1,123456788,1,230,鐩�,230,2017-02-17\n';
+ csvBody +=
+ 'CS-S0001,閿�鍞粰浜岀骇缁忛攢鍟�,' +
+ jxsList[0].Hospital__r.Management_Code__c +
+ ',Testhosp001,test,娴嬭瘯浜岀骇缁忛攢鍟�1,123456787,1,230,涓�,230,2017-02-17\n';
+ csvBody +=
+ 'CS-S0001,閿�鍞粰浜岀骇缁忛攢鍟�,' +
+ jxsList[0].Hospital__r.Management_Code__c +
+ ',Testhosp001,test,娴嬭瘯浜岀骇缁忛攢鍟�1,123456786,1,230,涓�,230,2017-02-17\n';
+ String base64Content = EncodingUtil.Base64Encode(Blob.valueOf(csvBody));
+ System.debug('base64Content==>' + base64Content);
+ Blob blobContent = EncodingUtil.base64Decode(base64Content);
+ System.debug('blobContent==>' + blobContent.toString());
+ LexOutboundorderImportController.importCSVFile(
+ base64Content,
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ LexOutboundorderImportController.importCSVFile(
+ 'TmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LVozMTAwMDIs55u05o6l6ZSA5ZSu57uZ5Yy76ZmiLDgxMDU2NDAs5a6955S45Lic5qGl5bq35aSN5Yy76ZmiLOa2iOWMluenkSwsMTY4NjIwMzI1NDQ2ODI1MFZWR0lVLDEsMjAwMCznm5IsMjAsMjAyMy82Lzgs5Lii5aSx5Y6f5ZugDQpEQi1GWTIwMjQtMDYtWjMxMDAwMyznm7TmjqXplIDllK7nu5nljLvpmaIsODEwNTY0MCzlrr3nlLjkuJzmoaXlurflpI3ljLvpmaIs5raI5YyW56eRLCwxNjg2MjAzMjU2MDk4MjUwUkVKT1EsMSwzMDAwLOebkiwyMCwyMDIzLzYvOCzkuKLlpLHljp%2Flm6ANCkRCLUZZMjAyNC0wNi1aMzEwMDA0LOebtOaOpemUgOWUrue7meWMu%2BmZoiw4MTA1NjQwLOWuveeUuOS4nOahpeW6t%2BWkjeWMu%2BmZoizmtojljJbnp5EsLDE2ODYyMDMyNTc2NTcyNTBHU0ZTQiwxLDQwMDAs55uSLDIwLDIwMjMvNi84LOS4ouWkseWOn%2BWboA0K',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ LexOutboundorderImportController.importCSVFile(
+ '77u%2FTmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LVozMTAwMDIs6ZSA5ZSu57uZ5LqM57qn57uP6ZSA5ZWGLDgxMDU2NDAs5a6955S45Lic5qGl5bq35aSN5Yy76ZmiLCwxNjg2MjAzMjU0NDY4MjUwVlZHSVUsMSwyMDAwLDIwLOebkiwsLA0KREItRlkyMDI0LTA2LVozMTAwMDMs55u05o6l6ZSA5ZSu57uZ5Yy76ZmiLDgxMDU2NDAs5a6955S45Lic5qGl5bq35aSN5Yy76ZmiLOa2iOWMluenkSwxNjg2MjAzMjU2MDk4MjUwUkVKT1EsMSw0MDAwLDIwLOS4qiwsLA0KREItRlkyMDI0LTA2LVozMTAwMDQs5LqS55u46LCD6LSnLDgxMDU2NDAs5a6955S45Lic5qGl5bq35aSN5Yy76ZmiLOa2iOWMluenkSwsMSw1MDAwLDIwLOS4qiwsLA0K',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ LexOutboundorderImportController.importCSVFile('', '', '', '');
+
+ //瀵煎叆
+ List<String[]> csvRecordStr = LexOutboundorderImportController.csvRecordStr;
+ List<LexOutboundorderImportController.ConsumableorderdetailsInfo> orderRecords = LexOutboundorderImportController.orderRecords;
+ System.debug(
+ '111===>' +
+ JSON.serialize(LexOutboundorderImportController.orderRecords)
+ );
+ String orderRecordsLwc = JSON.serialize(orderRecords);
+ Map<String, String> secondAgencyMap = LexOutboundorderImportController.secondAgencyMap;
+ Map<String, String> hospitalSysMap = LexOutboundorderImportController.hospitalSysMap;
+ // hospitalSysMap.put('8105640',myAccount1.Id);
+ // hospitalSysMap.put('8106864','0011000001g02glAAA');
+ // hospitalSysMap.put('8106867','0011000001g02hUAAQ');
+ // hospitalSysMap.put('8107348','0011000001g09fDAAQ');
+ System.debug('hospitalSysMap==' + hospitalSysMap);
+ LexOutboundorderImportController.dataImport(
+ csvRecordStr,
+ orderRecordsLwc,
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001',
+ 'myAccount1.Id',
+ 'ET',
+ secondAgencyMap,
+ hospitalSysMap
+ );
+ LexOutboundorderImportController.dataImport(
+ csvRecordStr,
+ '[{"agencyName": "","hospitalCode": "8215356","hospitalName": "娴嬭瘯鍖婚櫌","order": {"Name": "DB-FY2024-06-Z310002","SummonsForDirction__c": "閿�鍞粰浜岀骇缁忛攢鍟�","Order_ForHospital__c":"娴嬭瘯鍖婚櫌","Order_Attachment__c": "","Order_Indication__c": "","Order_ForCustomerText__c": "娑堝寲绉�","Invoice_Note__c": "","Outbound_Date__c": "2023-06-08"}}]',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001',
+ 'myAccount1.Id',
+ 'ET',
+ secondAgencyMap,
+ hospitalSysMap
+ );
+ LexOutboundorderImportController.dataImport(
+ csvRecordStr,
+ '[{"agencyName": "Test","hospitalCode": "8215356","hospitalName": "娴嬭瘯鍖婚櫌","order": {"Name": "DB-FY2024-06-Z310002","SummonsForDirction__c": "鐩存帴閿�鍞粰鍖婚櫌","Order_ForHospital__c":"娴嬭瘯鍖婚櫌","Order_Attachment__c": "","Order_Indication__c": "","Order_ForCustomerText__c": "娑堝寲绉�","Invoice_Note__c": "","Outbound_Date__c": "2023-06-08"}}]',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001',
+ 'myAccount1.Id',
+ 'ET',
+ secondAgencyMap,
+ hospitalSysMap
+ );
+ //浜у搧鍑鸿揣鏁伴噺涓虹┖
+ LexOutboundorderImportController.importCSVFile(
+ 'TmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LUQzMTg5MDYs55u05o6l6ZSA5ZSu57uZ5Yy76ZmiLDgxMDg2MTMs6YeR5Lmh5Y6%2F5Y2c6ZuG6ZWH5Y2r55Sf6ZmiLOa2iOWMluenkSwsMTY4NzMxNDIzMDEzMTI1MFdVUlhFLCw1MDAs55uSLDE1LDIwMjMvNS8zMCzkuKLlpLHljp%2Flm6ANCg%3D%3D',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ //鍗曚綅鐩� 鏁伴噺澶т簬1(鏃犳晥)
+ LexOutboundorderImportController.importCSVFile(
+ 'TmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LVMzMTc4MTMtMDEs55u05o6l6ZSA5ZSu57uZ5Yy76ZmiLDgxMDU2NDAs5a6955S45Lic5qGl5bq35aSN5Yy76ZmiLOa2iOWMluenkSwsMTY4NzMyMjQ0NDUwOTI1MFVZR01QLDUsNTAwLOebkiwxNSwyMDIzLzUvMzAs5Lii5aSx5Y6f5ZugDQo%3D',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ System.Test.stopTest();
+ }
+ }
+
+ static testMethod void allTest1() {
+ List<String[]> csvRecordStr = LexOutboundorderImportController.csvRecordStr;
+ Map<String, String> secondAgencyMap = LexOutboundorderImportController.secondAgencyMap;
+ Map<String, String> hospitalSysMap = LexOutboundorderImportController.hospitalSysMap;
+ System.debug('===>secondAgencyMap' + secondAgencyMap);
+ System.debug('===>hospitalSysMap' + hospitalSysMap);
+ LexOutboundorderImportController.dataImport(
+ csvRecordStr,
+ '[{"agencyName": "","hospitalCode": "8215356","hospitalName": "娴嬭瘯鍖婚櫌","order": {"Name": "DB-FY2024-06-Z310002","SummonsForDirction__c": "閿�鍞粰浜岀骇缁忛攢鍟�","Order_ForHospital__c":"娴嬭瘯鍖婚櫌","Order_Attachment__c": "","Order_Indication__c": "","Order_ForCustomerText__c": "娑堝寲绉�","Invoice_Note__c": "","Outbound_Date__c": "2023-06-08"}}]',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001',
+ 'myAccount1.Id',
+ 'ET',
+ secondAgencyMap,
+ hospitalSysMap
+ );
+ LexOutboundorderImportController.importCSVFile(
+ '77u%2FTmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA1LVozMTcxMDcs6ZSA5ZSu57uZ5LqM57qn57uP6ZSA5ZWGLDg4MDI1MCzlpKfov57lpYfliqDlpI3lgaXljLvpmaIs5aSW56eRLCwxMjM0NTYsNzAwLCznm5IsLDI3LzUvMjAwMiwNCkRCLUZZMjAyNC0wNS1aMzE3MTA3LOmUgOWUrue7meS6jOe6p%2Be7j%2BmUgOWVhiw4ODAyNTAs5aSn6L%2Be5aWH5Yqg5aSN5YGl5Yy76ZmiLOWkluenkSwsMTIzNDU2LDcwMCwwLOebkiwsMjcvNS8yMDAyLA0K',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ LexOutboundorderImportController.importCSVFile(
+ '77u%2FTmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA1LVozMTcxMDcs55u05o6l6ZSA5ZSu57uZ5Yy76ZmiLDg4MDI1MCzlpKfov57lpYfliqDlpI3lgaXljLvpmaIs5aSW56eRLCwxMjM0NTYsNzAwLDAs55uSLCwyNy81LzIwMDIsDQpEQi1GWTIwMjQtMDUtWjMxNzEwNyzplIDllK7nu5nkuoznuqfnu4%2FplIDllYYsODgwMjUwLOWkp%2Bi%2FnuWlh%2BWKoOWkjeWBpeWMu%2BmZoizlpJbnp5EsLDEyMzQ1Niw3MDAsMCznm5IsLDI3LzUvMjAwMiwNCiwsLCwsLCwsLCwsLA0KLCwsLCwsLCwsLCwsDQosLCwsLCwsLCwsLCwNCiwsLCwsLCwsLCwsLA0KLCwscywsLCwsLCwsLA0K',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ LexOutboundorderImportController.importCSVFile(
+ 'TmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LUQzMTg5MDYs55u05o6l6ZSA5ZSu57uZ5Yy76ZmiLDgxMDg2MTMs6YeR5Lmh5Y6%2F5Y2c6ZuG6ZWH5Y2r55Sf6ZmiLOa2iOWMluenkSwsMTY4NzMxNDIzMDEzMTI1MFdVUlhFLDEsLOebkiwxNSwyMDIzLzUvMzAs5Lii5aSx5Y6f5ZugDQo%3D',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ //瀛樺湪Barcode涓虹┖
+ LexOutboundorderImportController.importCSVFile(
+ 'TmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LUQzMTg5MDYs55u05o6l6ZSA5ZSu57uZ5Yy76ZmiLDgxMDg2MTMs6YeR5Lmh5Y6%2F5Y2c6ZuG6ZWH5Y2r55Sf6ZmiLOa2iOWMluenkSwsLDUsNTAwLOebkiwxNSwyMDIzLzUvMzAs5Lii5aSx5Y6f5ZugDQo%3D',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ //浜у搧鍑鸿揣鏁伴噺涓虹┖(鏃犳晥)
+ LexOutboundorderImportController.importCSVFile(
+ 'TmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LVMzMTc4MTMtMDEs55u05o6l6ZSA5ZSu57uZ5Yy76ZmiLDgxMDU2NDAs5a6955S45Lic5qGl5bq35aSN5Yy76ZmiLOa2iOWMluenkSwsMTY4NzMyMjQ0NDUwOTI1MFVZR01QLCw1MDAs55uSLDE1LDIwMjMvNS8zMCzkuKLlpLHljp%2Flm6ANCg%3D%3D',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ //浜岀骇缁忛攢鍟嗕笉涓虹┖
+ LexOutboundorderImportController.importCSVFile(
+ 'TmFtZSxTdW1tb25zRm9yRGlyY3Rpb25fX2MsSG9zcGl0YWxDb2RlLE9yZGVyX0Zvckhvc3BpdGFsX19jLE9yZGVyX0ZvckN1c3RvbWVyVGV4dF9fYyxPcmRlcl9Gb3JEZWFsZXJfX2MsQmFyX0NvZGVfX2MsU2hpcG1lbnRfQ291bnRfX2MsRGVsaXZlcnlfTGlzdF9STUJfX2MsQm94X1BpZWNlX19jLFVuaXRwcmljZV9Ub19hZ2VuY3lfX2MsT3V0Ym91bmRfRGF0ZV9fYyxMb3NlX3JlYXNvbl9fYw0KREItRlkyMDI0LTA2LVMzMTc4MTMtMDEs6ZSA5ZSu57uZ5LqM57qn57uP6ZSA5ZWGLDgxMDU2NDAs5a6955S45Lic5qGl5bq35aSN5Yy76ZmiLOa2iOWMluenkSwsMTY4NzMyMjQ0NDUwOTI1MFVZR01QLDUsNTAwLOebkiwxNSwyMDIzLzUvMzAs5Lii5aSx5Y6f5ZugDQo%3D',
+ '%ET%',
+ '閲嶅簡',
+ 'Testaccount001'
+ );
+ }
+}
diff --git a/force-app/main/default/classes/LexOutboundorderImportControllerTest.cls-meta.xml b/force-app/main/default/classes/LexOutboundorderImportControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexOutboundorderImportControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexOverdueStockController.cls b/force-app/main/default/classes/LexOverdueStockController.cls
index c6d0fd1..b53796f 100644
--- a/force-app/main/default/classes/LexOverdueStockController.cls
+++ b/force-app/main/default/classes/LexOverdueStockController.cls
@@ -1,381 +1,458 @@
public with sharing class LexOverdueStockController {
+ /*****************妞滅储鐢�******************/
+ public static String barcode { get; set; }
- /*****************妞滅储鐢�******************/
- public static String barcode { get; set; }
+ // 杩囨湡鍜岄攢瀛�,鐢婚潰鏄剧ず鐢�
+ public static List<orderBean> codPageRecords { get; set; }
- // 杩囨湡鍜岄攢瀛�,鐢婚潰鏄剧ず鐢�
- public static List<orderBean> codPageRecords { get; set; }
+ // 杩囨湡鍜岄攢瀛�,鐢婚潰鏄剧ず鐢�
+ public static List<orderBean> overduePageRecords { get; set; }
- // 杩囨湡鍜岄攢瀛�,鐢婚潰鏄剧ず鐢�
- public static List<orderBean> overduePageRecords { get; set; }
+ // 鐧诲綍鑰呭伐浣滃湴
+ private static String userWorkLocation;
+ //缁忛攢鍟嗙敤鎴蜂骇鍝佸垎绫伙紙ET銆丒NG锛�
+ private static String agencyProType;
+ private static String sqlagencyProType;
+ // 缁忛攢鍟嗕俊鎭�
+ private static Account accountInfo;
- // 鐧诲綍鑰呭伐浣滃湴
- private static String userWorkLocation;
- //缁忛攢鍟嗙敤鎴蜂骇鍝佸垎绫伙紙ET銆丒NG锛�
- private static String agencyProType;
- private static String sqlagencyProType;
- // 缁忛攢鍟嗕俊鎭�
- private static Account accountInfo;
+ //鍒ゆ柇鎿嶄綔浜哄憳鏄惁閿�瀛�
+ public static Boolean iSinventory = false;
- //鍒ゆ柇鎿嶄綔浜哄憳鏄惁閿�瀛�
- public static Boolean iSinventory = false;
+ public static List<Consumable_order_details2__c> overdueList = new List<Consumable_order_details2__c>();
- public static List<Consumable_order_details2__c> overdueList = new List<Consumable_order_details2__c>();
+ public static Integer pageRecordsSize {
+ get {
+ return codPageRecords == null ? 0 : codPageRecords.size();
+ }
+ }
- public static Integer pageRecordsSize {
- get {
- return codPageRecords == null ? 0 : codPageRecords.size();
- }
+ public LexOverdueStockController() {
+ }
+
+ // 鐢婚潰鍒濆鍖�
+ @AuraEnabled
+ public static ResponseBodyLWC init() {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ codPageRecords = new List<orderBean>();
+ overduePageRecords = new List<orderBean>();
+ // 鑾峰彇鐢ㄦ埛鍜岀粡閿�鍟嗕俊鎭�
+ user Useracc = [
+ SELECT Accountid, Work_Location__c, UserPro_Type__c
+ FROM user
+ WHERE id = :UserInfo.getUserId()
+ ];
+ userWorkLocation = Useracc.Work_Location__c;
+ agencyProType = Useracc.UserPro_Type__c;
+ if (String.isBlank(Useracc.UserPro_Type__c)) {
+ agencyProType = 'ET';
+ }
+ sqlagencyProType = '%' + agencyProType + '%';
+ accountInfo = [
+ SELECT id, Name, Dealer_discount__c
+ FROM account
+ WHERE id = :Useracc.accountid
+ ];
+ // 杩囨湡搴撳瓨姹囨�讳俊鎭�
+ List<AggregateResult> orderDetZaiku = [
+ SELECT
+ count(Id) countsum,
+ Consumable_Product__c prodid,
+ Consumable_Product__r.Name_Text__c prodname,
+ Box_Piece__c boxPiece
+ 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 Isoverdue__c = 0
+ AND Dealer_Returned__c = FALSE
+ AND Cancellation_Flag__c = FALSE
+ AND Bar_Code__c != NULL
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Dealer_Info_text__c = :accountInfo.Name
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ GROUP BY
+ Consumable_Product__c,
+ Box_Piece__c,
+ Consumable_Product__r.Name_Text__c
+ ];
+
+ for (AggregateResult overdue : orderDetZaiku) {
+ codPageRecords.add(new orderBean(overdue));
}
- public LexOverdueStockController() {
+ system.debug('codPageRecords====>' + codPageRecords);
+ data.put('codPageRecords', JSON.serialize(codPageRecords));
+ data.put('userWorkLocation', userWorkLocation);
+ data.put('accountName', accountInfo.Name);
+ data.put('agencyProType', agencyProType);
+ data.put('orderDetZaiku', JSON.serialize(orderDetZaiku));
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+ // BarCode褰曞叆
+ @AuraEnabled
+ public static ResponseBodyLWC searchorderBean(
+ String agencyProTypeLWC,
+ String userWorkLocationLWC,
+ String accountNameLWC,
+ String barcodeLWC,
+ String codPageRecordsLWC
+ ) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ List<orderBean> codPageRecords = (List<orderBean>) JSON.deserialize(
+ codPageRecordsLWC,
+ List<orderBean>.class
+ );
+ sqlagencyProType = '%' + agencyProTypeLWC + '%';
+ system.debug('sqlagencyProType==>' + sqlagencyProType);
+ barcode = barcodeLWC;
+ system.debug('barcode==>' + barcode);
+ userWorkLocation = userWorkLocationLWC;
+ // add by Wang Xueqin 2023/04/12
+ // 鑾峰彇鐢ㄦ埛鍜岀粡閿�鍟嗕俊鎭�
+ user Useracc = [
+ SELECT Accountid, Work_Location__c, UserPro_Type__c
+ FROM user
+ WHERE id = :UserInfo.getUserId()
+ ];
+ accountInfo = [
+ SELECT id, Name, Dealer_discount__c
+ FROM account
+ WHERE id = :Useracc.accountid
+ ];
+
+ iSinventory = true;
+ Set<String> barCodeoverdue = new Set<String>();
+ overduePageRecords = new List<orderBean>();
+ List<String> barCodeListP = ParseBarCode(barcode);
+ // 椤甸潰鏄剧ず鏁版嵁鍒濆鍖�
+ for (orderBean codPage : codPageRecords) {
+ codPage.pandian = 0;
+ }
+ // 鏌ヨ鎵�鏈夎繃鏈熷簱瀛�
+ List<Consumable_order_details2__c> orderDetZaiku = [
+ SELECT
+ Id,
+ Name,
+ Consumable_Product__c,
+ Bar_Code__c,
+ Consumable_Product__r.Name__c,
+ Dealer_Info_text__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ Sterilization_limit__c,
+ Bar_Code_search__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 Isoverdue__c = 0
+ AND Dealer_Returned__c = FALSE
+ AND Cancellation_Flag__c = FALSE
+ AND Bar_Code__c != NULL
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Dealer_Info_text__c = :accountInfo.Name
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ ];
+ // 娌℃湁杈撳叆鏉$爜鏃讹紝寰幆椤甸潰锛屾墍鏈夋墦閽╀骇鍝佸叏閮ㄩ攢瀛�
+ // 鍙栧緱鎵�鏈�
+ overdueList = new List<Consumable_order_details2__c>();
+ if (String.isBlank(barcode)) {
+ System.debug('barcode绌�');
+ for (orderBean codPage : codPageRecords) {
+ if (codPage.check) {
+ for (Consumable_order_details2__c cod2 : orderDetZaiku) {
+ if (
+ cod2.Consumable_Product__c == codPage.prodid &&
+ codPage.boxPiece == cod2.Box_Piece__c
+ ) {
+ overduePageRecords.add(new orderBean(cod2, '杩囨湡搴撳瓨閿�瀛�'));
+ overdueList.add(cod2);
+ }
+ }
+ codPage.pandian = codPage.overlimitCount;
+ }
+ }
+ // return;
+ System.debug('overduePageRecords = ' + overduePageRecords);
+ System.debug('overdueList = ' + overdueList);
+ data.put('overduePageRecords', JSON.serialize(overduePageRecords));
+ data.put('codPageRecords', JSON.serialize(codPageRecords));
+ data.put('iSinventory', iSinventory);
+ data.put('overdueList', overdueList);
+ res.status = 'Success1';
+ res.code = 200;
+ // res.msg = '璇疯緭鍏arCode鍙�';
+ System.debug('res = ' + res);
+ return res;
}
- // 鐢婚潰鍒濆鍖�
- @AuraEnabled
- public static ResponseBodyLWC init() {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
+ // 杈撳叆barcode鏃�
- codPageRecords = new List<orderBean>();
- overduePageRecords = new List<orderBean>();
- // 鑾峰彇鐢ㄦ埛鍜岀粡閿�鍟嗕俊鎭�
- user Useracc = [select Accountid, Work_Location__c,UserPro_Type__c from user where id =: UserInfo.getUserId()];
- userWorkLocation = Useracc.Work_Location__c;
- agencyProType = Useracc.UserPro_Type__c;
- if(String.isBlank(Useracc.UserPro_Type__c)){
- agencyProType = 'ET';
- }
- sqlagencyProType = '%' + agencyProType + '%';
- accountInfo = [SELECT id,Name,Dealer_discount__c FROM account WHERE id =:Useracc.accountid];
- // 杩囨湡搴撳瓨姹囨�讳俊鎭�
- List<AggregateResult> orderDetZaiku = [SELECT count(Id) countsum,
- Consumable_Product__c prodid,
- Consumable_Product__r.Name_Text__c prodname,
- Box_Piece__c boxPiece
- 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 Isoverdue__c = 0
- AND Dealer_Returned__c = false
- AND Cancellation_Flag__c = false
- AND Bar_Code__c !=null
- AND Product_Type__c like : sqlagencyProType
- AND Dealer_Info_text__c = :accountInfo.Name
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- group by Consumable_Product__c,Box_Piece__c,Consumable_Product__r.Name_Text__c];
+ // BarCode鐨勬绱� 鎵�鏈夊湪搴�
+ List<Consumable_order_details2__c> reSet = [
+ SELECT
+ Id,
+ Consumable_Product__c,
+ Consumable_Product__r.Name__c,
+ Box_Piece__c,
+ Bar_Code_search__c,
+ Dealer_Shipment__c,
+ Dealer_Saled__c,
+ Lose_Flag__c,
+ Bar_Code__c,
+ Cancellation_Flag__c,
+ Isoverdue__c,
+ Sterilization_limit__c
+ FROM Consumable_order_details2__c
+ WHERE
+ Bar_Code_search__c IN :BarCodeListP
+ AND Dealer_Arrive__c = TRUE
+ AND Cancellation_Flag__c = FALSE
+ AND Dealer_Returned__c = FALSE
+ AND Bar_Code__c != NULL
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Dealer_Info_text__c = :accountInfo.Name
+ ORDER BY Name
+ ];
- for(AggregateResult overdue : orderDetZaiku){
- codPageRecords.add(new orderBean(overdue));
- }
+ System.debug('reSet===>' + reSet);
- system.debug('codPageRecords====>'+codPageRecords);
- data.put('codPageRecords',JSON.serialize(codPageRecords));
- data.put('userWorkLocation',userWorkLocation);
- data.put('accountName',accountInfo.Name);
- data.put('agencyProType',agencyProType);
- data.put('orderDetZaiku',JSON.serialize(orderDetZaiku));
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
-
- }
-
- // BarCode褰曞叆
- @AuraEnabled
- public static ResponseBodyLWC searchorderBean(String agencyProTypeLWC,String userWorkLocationLWC,String accountNameLWC,String barcodeLWC,String codPageRecordsLWC){
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- List<orderBean> codPageRecords = (List<orderBean>)JSON.deserialize(codPageRecordsLWC,List<orderBean>.class);
- sqlagencyProType = '%' + agencyProTypeLWC + '%';
- system.debug('sqlagencyProType==>'+ sqlagencyProType);
- barcode = barcodeLWC;
- system.debug('barcode==>'+ barcode);
- userWorkLocation = userWorkLocationLWC;
- // add by Wang Xueqin 2023/04/12
- // 鑾峰彇鐢ㄦ埛鍜岀粡閿�鍟嗕俊鎭�
- user Useracc = [select Accountid, Work_Location__c,UserPro_Type__c from user where id =: UserInfo.getUserId()];
- accountInfo = [SELECT id,Name,Dealer_discount__c FROM account WHERE id =:Useracc.accountid];
-
-
- iSinventory = true;
- Set<String> barCodeoverdue = new Set<String>();
- overduePageRecords = new List<orderBean>();
- List<String> barCodeListP = ParseBarCode( barcode );
- // 椤甸潰鏄剧ず鏁版嵁鍒濆鍖�
+ for (Consumable_order_details2__c cod2 : reSet) {
+ if (
+ (cod2.Dealer_Shipment__c == false &&
+ cod2.Dealer_Saled__c == false &&
+ cod2.Lose_Flag__c == false &&
+ cod2.Cancellation_Flag__c == false) && cod2.Isoverdue__c == 0
+ ) {
for (orderBean codPage : codPageRecords) {
- codPage.pandian = 0;
+ if (
+ cod2.Consumable_Product__c == codPage.prodid &&
+ cod2.Box_Piece__c == codPage.boxPiece
+ ) {
+ overduePageRecords.add(new orderBean(cod2, '杩囨湡搴撳瓨閿�瀛�'));
+ overdueList.add(cod2);
+ codPage.pandian++;
+ codPage.check = true;
+ }
}
- // 鏌ヨ鎵�鏈夎繃鏈熷簱瀛�
- List<Consumable_order_details2__c> orderDetZaiku = [select Id, Name,Consumable_Product__c,
- Bar_Code__c,Consumable_Product__r.Name__c,Dealer_Info_text__c,
- Asset_Model_No__c,Isoverdue__c,Box_Piece__c,Sterilization_limit__c,
- Bar_Code_search__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 Isoverdue__c = 0
- AND Dealer_Returned__c = false
- AND Cancellation_Flag__c = false
- AND Bar_Code__c !=null
- AND Product_Type__c like : sqlagencyProType
- AND Dealer_Info_text__c = :accountInfo.Name
- AND Arrive_Owner_Work_Location__c = :userWorkLocation];
- // 娌℃湁杈撳叆鏉$爜鏃讹紝寰幆椤甸潰锛屾墍鏈夋墦閽╀骇鍝佸叏閮ㄩ攢瀛�
- // 鍙栧緱鎵�鏈�
- overdueList = new List<Consumable_order_details2__c>();
- if (String.isBlank(barcode)) {
- System.debug('barcode绌�');
- for(orderBean codPage : codPageRecords){
- if (codPage.check) {
- for(Consumable_order_details2__c cod2 : orderDetZaiku){
- if(cod2.Consumable_Product__c == codPage.prodid && codPage.boxPiece == cod2.Box_Piece__c){
- overduePageRecords.add(new orderBean(cod2,'杩囨湡搴撳瓨閿�瀛�'));
- overdueList.add(cod2);
- }
- }
- codPage.pandian = codPage.overlimitCount;
- }
- }
- // return;
- System.debug('overduePageRecords = ' + overduePageRecords);
- System.debug('overdueList = ' + overdueList);
- data.put('overduePageRecords',JSON.serialize(overduePageRecords));
- data.put('codPageRecords',JSON.serialize(codPageRecords));
- data.put('iSinventory',iSinventory);
- data.put('overdueList',overdueList);
- res.status = 'Success1';
- res.code = 200;
- // res.msg = '璇疯緭鍏arCode鍙�';
- System.debug('res = ' + res);
- return res;
- }
-
- // 杈撳叆barcode鏃�
-
- // BarCode鐨勬绱� 鎵�鏈夊湪搴�
- List<Consumable_order_details2__c> reSet = [select Id,Consumable_Product__c,
- Consumable_Product__r.Name__c,Box_Piece__c,Bar_Code_search__c,
- Dealer_Shipment__c,Dealer_Saled__c,Lose_Flag__c,Bar_Code__c,
- Cancellation_Flag__c,Isoverdue__c,Sterilization_limit__c
- from Consumable_order_details2__c
- where Bar_Code_search__c in :BarCodeListP
- AND Dealer_Arrive__c = true
- AND Cancellation_Flag__c = false
- and Dealer_Returned__c = false
- and Bar_Code__c !=null
- AND Product_Type__c like : sqlagencyProType
- AND Arrive_Owner_Work_Location__c =: userWorkLocation
- AND Dealer_Info_text__c = :accountInfo.Name
- order by Name];
-
- System.debug('reSet===>'+reSet);
-
-
- for(Consumable_order_details2__c cod2 : reSet){
- if ((cod2.Dealer_Shipment__c == false && cod2.Dealer_Saled__c == false
- && cod2.Lose_Flag__c == false && cod2.Cancellation_Flag__c == false) && cod2.Isoverdue__c == 0) {
- for (orderBean codPage : codPageRecords) {
- if(cod2.Consumable_Product__c == codPage.prodid && cod2.Box_Piece__c == codPage.boxPiece){
- overduePageRecords.add(new orderBean(cod2,'杩囨湡搴撳瓨閿�瀛�'));
- overdueList.add(cod2);
- codPage.pandian ++;
- codPage.check = true;
- }
- }
- }else if (cod2.Dealer_Shipment__c || cod2.Dealer_Saled__c) {
- overduePageRecords.add(new orderBean(cod2,'浜у搧宸茬粡鍑哄簱'));
- }else{
- overduePageRecords.add(new orderBean(cod2,'涓嶆槸杩囨湡搴撳瓨'));
- }
- }
- System.debug('overduePageRecords = ' + overduePageRecords);
- data.put('overduePageRecords',JSON.serialize(overduePageRecords));
- data.put('codPageRecords',JSON.serialize(codPageRecords));
- data.put('iSinventory',iSinventory);
- data.put('overdueList',overdueList);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ } else if (cod2.Dealer_Shipment__c || cod2.Dealer_Saled__c) {
+ overduePageRecords.add(new orderBean(cod2, '浜у搧宸茬粡鍑哄簱'));
+ } else {
+ overduePageRecords.add(new orderBean(cod2, '涓嶆槸杩囨湡搴撳瓨'));
+ }
}
+ System.debug('overduePageRecords = ' + overduePageRecords);
+ data.put('overduePageRecords', JSON.serialize(overduePageRecords));
+ data.put('codPageRecords', JSON.serialize(codPageRecords));
+ data.put('iSinventory', iSinventory);
+ data.put('overdueList', overdueList);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+ // 淇濆瓨鎸夐挳
+ @AuraEnabled
+ public static ResponseBodyLWC save(
+ Boolean iSinventory,
+ string saveCodPageRecords,
+ List<Consumable_order_details2__c> saveoverdueList
+ ) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ system.debug('saveCodPageRecords=============>' + saveCodPageRecords);
+ system.debug('saveoverdueList' + saveoverdueList);
+ overdueList = saveoverdueList;
+ // if(saveoverdueList==null){
+ // return new ResponseBodyLWC('Error',500, '璇烽�夋嫨瑕侀攢瀛樼殑鏄庣粏', '');
- // 淇濆瓨鎸夐挳
+ // }
+
+ List<orderBean> codPageRecords = (List<orderBean>) JSON.deserialize(
+ saveCodPageRecords,
+ List<orderBean>.class
+ );
+ // List<Consumable_order_details2__c> overdueList = (List<Consumable_order_details2__c>)JSON.deserialize(saveoverdueList,List<Consumable_order_details2__c>.class);
+ // add by Wang Xueqin 2023/04/12
+ // 鑾峰彇鐢ㄦ埛鍜岀粡閿�鍟嗕俊鎭�
+ user Useracc = [
+ SELECT Accountid, Work_Location__c, UserPro_Type__c
+ FROM user
+ WHERE id = :UserInfo.getUserId()
+ ];
+ accountInfo = [
+ SELECT id, Name, Dealer_discount__c
+ FROM account
+ WHERE id = :Useracc.accountid
+ ];
+
+ // 璺宠繃鏄庣粏2涓嶅繀瑕佹洿鏂�
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ if (!iSinventory) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'璇峰厛鐐广�怋arCode褰曞叆銆�'));
+ return new ResponseBodyLWC('Error', 500, '璇峰厛褰曞叆BarCode', '');
+ // return null;
+ }
+ integer Lo = 0;
+ for (orderBean header : codPageRecords) {
+ if (header.check == true) {
+ Lo++;
+ }
+ }
+ if (Lo == 0) {
+ iSinventory = false;
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'璇烽�夋嫨瑕侀攢瀛樼殑鏄庣粏銆�'));
+ return new ResponseBodyLWC('Error', 500, '璇烽�夋嫨瑕侀攢瀛樼殑鏄庣粏', '');
+ // return null;
+ }
+ Integer orderDetNo = 1;
+ Savepoint sp = Database.setSavepoint();
+ Consumable_order__c po = new Consumable_order__c();
+ po.Name = '*';
+ po.Order_status__c = '鎵瑰噯';
+ po.Inventory_date__c = Date.today();
+ po.Order_type__c = '閿�瀛�';
+ po.Dealer_Info__c = accountInfo.Id;
+ po.Order_ProType__c = agencyProType;
+ po.RecordTypeid = System.Label.RT_ConOrder_Overdue;
+ try {
+ insert po;
+ Consumable_order__c order = [
+ SELECT Name
+ FROM Consumable_order__c
+ WHERE id = :po.id
+ ];
+ List<Consumable_orderdetails__c> InsList = new List<Consumable_orderdetails__c>();
+ for (orderBean header : codPageRecords) {
+ if (header.check == true) {
+ Consumable_orderdetails__c insPan = new Consumable_orderdetails__c();
+ String str = string.valueOf(orderDetNo);
+ if (str.length() == 1) {
+ str = '0' + str;
+ }
+ insPan.Name = order.Name + '-' + str;
+ insPan.Consumable_Product__c = header.prodId;
+ insPan.Consumable_order__c = po.Id;
+ insPan.Lose_reason__c = '杩囨湡搴撳瓨閿�瀛�';
+ insPan.Overdue_count__c = header.pandian;
+ insPan.Overdue_SUM__c = header.overlimitCount;
+ insPan.RecordTypeId = System.Label.RT_ConOrderDetail1_Inventory;
+ orderDetNo++;
+ InsList.add(insPan);
+ }
+ }
+ // 鐢熸垚鏄庣粏1
+ if (InsList.size() > 0) {
+ insert InsList;
+ }
+
+ for (Consumable_order_details2__c cod : overdueList) {
+ cod.Consumable_Inventory_order__c = po.Id;
+ cod.Inventory_date__c = Date.today();
+ cod.Lose_reason__c = '杩囨湡搴撳瓨閿�瀛�';
+ cod.Lose_Flag__c = true;
+ }
+ if (overdueList.size() > 0) {
+ ControllerUtil.updateOrderDetailsSatus(overdueList);
+ }
+ } catch (Exception ex) {
+ Database.rollback(sp);
+ ApexPages.addMessages(ex);
+ return null;
+ }
+ // return new Pagereference('/' + po.Id);
+ data.put('Id', po.Id);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ // 灏嗛〉闈㈡垨鍙栧緱BarCode鍘绘帀閲嶅鐨勶紝杞崲鎴怢ist
+ public static List<String> ParseBarCode(String Code) {
+ Map<String, Integer> barcodeCountMap = new Map<String, Integer>();
+ String[] Cache = new List<String>{};
+ Cache = Code.split('\n');
+ List<String> Buff = new List<String>();
+ for (String A : Cache) {
+ A = A.trim().toUpperCase();
+ if (barcodeCountMap.containsKey(A)) {
+ barcodeCountMap.put(A, barcodeCountMap.get(A) + 1);
+ } else {
+ barcodeCountMap.put(A, 1);
+ }
+ Buff.add(A + barcodeCountMap.get(A));
+ }
+ return Buff;
+ }
+
+ // Data Bean
+ @TestVisible
+ class orderBean implements Comparable {
@AuraEnabled
- public static ResponseBodyLWC save(Boolean iSinventory,string saveCodPageRecords,List<Consumable_order_details2__c> saveoverdueList) {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- system.debug('saveCodPageRecords=============>'+saveCodPageRecords);
- system.debug('saveoverdueList'+saveoverdueList);
- overdueList = saveoverdueList;
- // if(saveoverdueList==null){
- // return new ResponseBodyLWC('Error',500, '璇烽�夋嫨瑕侀攢瀛樼殑鏄庣粏', '');
+ public Consumable_order_details2__c orderdetails2 { get; set; }
+ @AuraEnabled
+ public Product2__c Prod { get; set; }
+ @AuraEnabled
+ public Boolean check { get; set; }
- // }
-
- List<orderBean> codPageRecords = (List<orderBean>)JSON.deserialize(saveCodPageRecords,List<orderBean>.class);
- // List<Consumable_order_details2__c> overdueList = (List<Consumable_order_details2__c>)JSON.deserialize(saveoverdueList,List<Consumable_order_details2__c>.class);
- // add by Wang Xueqin 2023/04/12
- // 鑾峰彇鐢ㄦ埛鍜岀粡閿�鍟嗕俊鎭�
- user Useracc = [select Accountid, Work_Location__c,UserPro_Type__c from user where id =: UserInfo.getUserId()];
- accountInfo = [SELECT id,Name,Dealer_discount__c FROM account WHERE id =:Useracc.accountid];
-
- // 璺宠繃鏄庣粏2涓嶅繀瑕佹洿鏂�
- StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
- if(!iSinventory){
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'璇峰厛鐐广�怋arCode褰曞叆銆�'));
- return new ResponseBodyLWC('Error',500, '璇峰厛鐐瑰嚮鑾峰彇鏄庣粏', '');
- // return null;
- }
- integer Lo = 0;
- for(orderBean header : codPageRecords){
- if(header.check==true){
- Lo++;
- }
- }
- if(Lo == 0){
- iSinventory = false;
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'璇烽�夋嫨瑕侀攢瀛樼殑鏄庣粏銆�'));
- return new ResponseBodyLWC('Error',500, '璇烽�夋嫨瑕侀攢瀛樼殑鏄庣粏', '');
- // return null;
- }
- Integer orderDetNo = 1;
- Savepoint sp = Database.setSavepoint();
- Consumable_order__c po = new Consumable_order__c();
- po.Name ='*';
- po.Order_status__c = '鎵瑰噯';
- po.Inventory_date__c = Date.today();
- po.Order_type__c = '閿�瀛�';
- po.Dealer_Info__c = accountInfo.Id;
- po.Order_ProType__c = agencyProType;
- po.RecordTypeid = System.Label.RT_ConOrder_Overdue;
- try{
- insert po;
- Consumable_order__c order = [SELECT Name FROM Consumable_order__c WHERE id =:po.id];
- List<Consumable_orderdetails__c> InsList = New List<Consumable_orderdetails__c>();
- for(orderBean header : codPageRecords){
- if(header.check==true){
- Consumable_orderdetails__c insPan = new Consumable_orderdetails__c();
- String str = string.valueOf(orderDetNo);
- if(str.length() == 1){
- str = '0' + str;
- }
- insPan.Name = order.Name + '-'+ str;
- insPan.Consumable_Product__c = header.prodId;
- insPan.Consumable_order__c = po.Id;
- insPan.Lose_reason__c = '杩囨湡搴撳瓨閿�瀛�';
- insPan.Overdue_count__c = header.pandian;
- insPan.Overdue_SUM__c = header.overlimitCount;
- insPan.RecordTypeId = System.Label.RT_ConOrderDetail1_Inventory;
- orderDetNo ++;
- InsList.add(insPan);
- }
- }
- // 鐢熸垚鏄庣粏1
- if(InsList.size()>0){
- insert InsList;
- }
-
- for(Consumable_order_details2__c cod : overdueList){
- cod.Consumable_Inventory_order__c = po.Id;
- cod.Inventory_date__c = Date.today();
- cod.Lose_reason__c = '杩囨湡搴撳瓨閿�瀛�';
- cod.Lose_Flag__c = true;
-
- }
- if(overdueList.size()>0){
- ControllerUtil.updateOrderDetailsSatus(overdueList);
- }
-
- }catch (Exception ex) {
- Database.rollback(sp);
- ApexPages.addMessages(ex);
- return null;
- }
- // return new Pagereference('/' + po.Id);
- data.put('Id',po.Id);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ // 杩囨湡搴撳瓨
+ @AuraEnabled
+ public Integer overlimitCount { get; set; }
+ // 閿�瀛樻暟閲�
+ @AuraEnabled
+ public Integer pandian { get; set; }
+ // 閿�瀛樺師鍥�
+ @AuraEnabled
+ public String diffReason { get; set; }
+ // 鍗曚綅
+ @AuraEnabled
+ public String boxPiece { get; set; }
+ @AuraEnabled
+ public String prodname { get; set; }
+ @AuraEnabled
+ public String prodid { get; set; }
+ orderBean(Consumable_order_details2__c e, string str) {
+ orderdetails2 = e;
+ Prod = e.Consumable_Product__r;
+ DiffReason = str;
}
-
- // 灏嗛〉闈㈡垨鍙栧緱BarCode鍘绘帀閲嶅鐨勶紝杞崲鎴怢ist
- public static List<String> ParseBarCode(String Code){
- Map<String,Integer> barcodeCountMap = new Map<String,Integer>();
- String[] Cache = new String[]{};
- Cache = Code.split('\n');
- List <String> Buff = new List<String>();
- for(String A : Cache){
- A = A.trim().toUpperCase();
- if(barcodeCountMap.containsKey(A)){
- barcodeCountMap.put(A,barcodeCountMap.get(A) + 1);
- }else{
- barcodeCountMap.put(A,1);
- }
- Buff.add(A + barcodeCountMap.get(A));
- }
- return Buff;
+ public orderBean(AggregateResult e) {
+ check = false;
+ overlimitCount = Integer.valueOf(e.get('countsum'));
+ prodname = String.valueOf(e.get('prodname'));
+ prodid = String.valueOf(e.get('prodid'));
+ boxPiece = String.valueOf(e.get('BoxPiece'));
+ pandian = 0;
}
-
- // Data Bean
- class orderBean implements Comparable {
- @AuraEnabled
- public Consumable_order_details2__c orderdetails2 { get; set; }
- @AuraEnabled
- public Product2__c Prod { get; set; }
- @AuraEnabled
- public Boolean check { get; set; }
-
- // 杩囨湡搴撳瓨
- @AuraEnabled
- public Integer overlimitCount { get; set; }
- // 閿�瀛樻暟閲�
- @AuraEnabled
- public Integer pandian { get; set; }
- // 閿�瀛樺師鍥�
- @AuraEnabled
- public String diffReason { get; set; }
- // 鍗曚綅
- @AuraEnabled
- public String boxPiece { get; set; }
- @AuraEnabled
- public String prodname { get; set; }
- @AuraEnabled
- public String prodid { get; set; }
- orderBean(Consumable_order_details2__c e,string str) {
- orderdetails2 = e;
- Prod = e.Consumable_Product__r;
- DiffReason = str;
- }
- public orderBean(AggregateResult e) {
- check = false;
- overlimitCount = Integer.valueOf(e.get('countsum'));
- prodname = String.valueOf(e.get('prodname'));
- prodid = String.valueOf(e.get('prodid'));
- boxPiece = String.valueOf(e.get('BoxPiece'));
- pandian = 0;
- }
- // 鎺掑簭
- public Integer compareTo(Object compareTo) {
- orderBean compareToesd =(orderBean)compareTo;
- Integer returnValue = 0;
- if (overlimitCount > compareToesd.overlimitCount ) {
- returnValue = -1;
- } else if (overlimitCount < compareToesd.overlimitCount ) {
- returnValue = 1;
- }
- return returnValue;
- }
+ // 鎺掑簭
+ public Integer compareTo(Object compareTo) {
+ orderBean compareToesd = (orderBean) compareTo;
+ Integer returnValue = 0;
+ if (overlimitCount > compareToesd.overlimitCount) {
+ returnValue = -1;
+ } else if (overlimitCount < compareToesd.overlimitCount) {
+ returnValue = 1;
+ }
+ return returnValue;
}
-}
\ No newline at end of file
+ }
+}
diff --git a/force-app/main/default/classes/LexOverdueStockControllerTest.cls b/force-app/main/default/classes/LexOverdueStockControllerTest.cls
new file mode 100644
index 0000000..a3c6f20
--- /dev/null
+++ b/force-app/main/default/classes/LexOverdueStockControllerTest.cls
@@ -0,0 +1,245 @@
+@isTest
+private class LexOverdueStockControllerTest {
+ static testMethod void testMethod1() {
+ user MyUser_Test;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+
+ RecordType rectCoO = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ Account olympus = new Account(
+ RecordTypeId = rectCoO.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '8888888'
+ );
+ insert myAccount1;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+
+ System.runAs(MyUser_Test) {
+ //浜у搧鏁版嵁
+ Product2 prod07 = new Product2(
+ Name = 'Test07',
+ ProductCode = 'Test07',
+ Asset_Model_No__c = 'Test07',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod08 = new Product2(
+ Name = 'Test08',
+ ProductCode = 'Test08',
+ Asset_Model_No__c = 'Test08',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod09 = new Product2(
+ Name = 'Test09',
+ ProductCode = 'Test09',
+ Asset_Model_No__c = 'Test09',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod07, prod08, prod09 };
+
+ //鍒朵綔浜у搧
+ Product2__c proG = new Product2__c(
+ Name = 'MH-155:鐧藉钩琛″附',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod07.Id
+ );
+ insert proG;
+ Product2__c proH = new Product2__c(
+ Name = 'MB-677:BNC鐢电紗',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod08.Id
+ );
+ insert proH;
+ Product2__c proF = new Product2__c(
+ Name = 'TooMAJ-643R:姘村泭闉樼003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod09.Id
+ );
+ insert proF;
+
+ //璁㈠崟
+ Consumable_order__c order = new Consumable_order__c();
+ order.Name = 'testMing';
+ order.Order_status__c = '鎵瑰噯';
+ order.RecordTypeid = System.Label.RT_ConOrder_Order;
+ order.Dealer_Info__c = myAccount1.id;
+ order.Inventory_date__c = Date.today();
+ order.Order_type__c = '璁㈠崟';
+ order.Order_ProType__c = 'ET';
+ insert order;
+ //鍒拌揣
+ Consumable_order__c order2 = new Consumable_order__c();
+ order2.Name = 'testMing1';
+ order2.Order_status__c = '鎵瑰噯';
+ order2.RecordTypeid = '01210000000c9dqAAA';
+ order2.Dealer_Info__c = myAccount1.id;
+ order2.Order_type__c = '鍒拌揣';
+ order2.Order_ProType__c = 'ET';
+ insert order2;
+
+ List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
+ //鍒朵綔Consumable_order_details__c-------ProductCount
+ // 閿�鍞�
+ Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c();
+ dataForProductCount7.Bar_Code__c = '123456789298k250AAAAA';
+ dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount7.Arrive_date__c = Date.today();
+ dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount7.Consumable_Product__c = proH.id;
+ dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c;
+ dataForProductCount7.Box_Piece__c = '鐩�';
+ dataForProductCount7.Used_date__c = Date.today();
+ dataForProductCount7.Consumable_order_minor__c = order.id;
+
+ conList.add(dataForProductCount7);
+ // 鍦ㄥ簱 杩囨湡 鐩�
+ Consumable_order_details2__c dataForProduct = new Consumable_order_details2__c();
+ dataForProduct.Bar_Code__c = '123456789498k250BBBBB';
+ dataForProduct.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProduct.Arrive_date__c = Date.today();
+ dataForProduct.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProduct.Consumable_Product__c = proF.id;
+ dataForProduct.Asset_Model_No__c = proF.Asset_Model_No__c;
+ dataForProduct.Box_Piece__c = '鐩�';
+ dataForProduct.Consumable_order_minor__c = order.id;
+
+ conList.add(dataForProduct);
+ // 鍦ㄥ簱 杩囨湡 涓�
+ Consumable_order_details2__c dataForProductCount3 = new Consumable_order_details2__c();
+ dataForProductCount3.Bar_Code__c = '123456788398k250CCCCC';
+ dataForProductCount3.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProductCount3.Arrive_date__c = Date.today();
+ dataForProductCount3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount3.Consumable_Product__c = proG.id;
+ dataForProductCount3.Asset_Model_No__c = proG.Asset_Model_No__c;
+ dataForProductCount3.Box_Piece__c = '涓�';
+ dataForProductCount3.RemoveBox_No__c = 1;
+ dataForProductCount3.Consumable_order_minor__c = order.id;
+ conList.add(dataForProductCount3);
+ insert conList;
+
+ //杩囨湡搴撳瓨姹囨�讳俊鎭� add by Wang Xueqin
+ List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
+ Consumable_order_details2__c dataForProductCount4 = new Consumable_order_details2__c();
+ dataForProductCount4.Bar_Code__c = '1001';
+ dataForProductCount4.Arrive_date__c = Date.today();
+ dataForProductCount4.Send_Date__c = null;
+ dataForProductCount4.Used_date__c = null;
+ dataForProductCount4.Return_date__c = null;
+ dataForProductCount4.Lose_Flag__c = false;
+ dataForProductCount4.Cancellation_Flag__c = false;
+ dataForProductCount4.Consumable_Product__c = proG.Id;
+ dataForProductCount4.Consumable_Arrived_order__c = order2.id;
+ dataForProductCount4.Used_account__c = myAccount1.Id;
+ dataForProductCount4.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProductCount4.Box_Piece__c = '鐩�';
+ conList1.add(dataForProductCount4);
+ System.debug('conList1==>' + conList1);
+ //鏌ヨ鎵�鏈夎繃鏈熷簱瀛�
+ Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c();
+ dataForProductCount5.Bar_Code__c = '1002';
+ dataForProductCount5.Arrive_date__c = Date.today();
+ dataForProductCount5.Send_Date__c = Date.today();
+ dataForProductCount5.Used_date__c = Date.today();
+ dataForProductCount5.Return_date__c = null;
+ dataForProductCount5.Lose_Flag__c = false;
+ dataForProductCount5.Cancellation_Flag__c = false;
+ dataForProductCount5.Consumable_Product__c = proG.Id;
+ dataForProductCount5.Consumable_Arrived_order__c = order2.id;
+ dataForProductCount5.Used_account__c = myAccount1.Id;
+ dataForProductCount5.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProductCount5.Box_Piece__c = '鐩�';
+ conList1.add(dataForProductCount5);
+ insert conList1;
+
+ System.Test.startTest();
+ List<Consumable_order_details2__c> overdueList = new List<Consumable_order_details2__c>();
+ LexOverdueStockController overCon = new LexOverdueStockController();
+ LexOverdueStockController.init();
+ List<LexOverdueStockController.orderBean> cro = new List<LexOverdueStockController.orderBean>();
+ List<LexOverdueStockController.orderBean> croList = LexOverdueStockController.codPageRecords;
+ for (LexOverdueStockController.orderBean i : croList) {
+ i.check = true;
+ }
+
+ String codPageRecordsLWC = JSON.serialize(
+ LexOverdueStockController.codPageRecords
+ );
+ System.debug(
+ 'codPageRecordsLWC===>test' + LexOverdueStockController.codPageRecords
+ );
+ LexOverdueStockController.searchorderBean(
+ 'ET',
+ '閲嶅簡',
+ 'Testaccount001',
+ '123456789298k250AAAAA\n123456789498k250BBBBB\n123456788398k250CCCCC\n1001',
+ codPageRecordsLWC
+ );
+ LexOverdueStockController.searchorderBean(
+ 'ET',
+ '閲嶅簡',
+ 'Testaccount001',
+ '',
+ codPageRecordsLWC
+ ); //barcode涓虹┖
+ LexOverdueStockController.save(true, codPageRecordsLWC, overdueList);
+ // LexOverdueStockController.save(false,codPageRecordsLWC,overdueList);
+ System.Test.stopTest();
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexOverdueStockControllerTest.cls-meta.xml b/force-app/main/default/classes/LexOverdueStockControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexOverdueStockControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexProductLimitEditControllerTest.cls b/force-app/main/default/classes/LexProductLimitEditControllerTest.cls
new file mode 100644
index 0000000..3b51728
--- /dev/null
+++ b/force-app/main/default/classes/LexProductLimitEditControllerTest.cls
@@ -0,0 +1,70 @@
+@isTest
+private class LexProductLimitEditControllerTest {
+ @isTest
+ static void unittest() {
+ 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)'
+ ];
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true
+ );
+ 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 myAccount2 = new Account(
+ name = 'Testaccount005',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|5|55,Test02|2|4'
+ );
+ insert myAccount2;
+ String myAccount2Id = myAccount2.Id;
+ LexProductLimitEditController.init(myAccount2Id, 'ENG');
+ LexProductLimitEditController.init(myAccount2Id, '');
+ LexProductLimitEditController.accountid = myAccount2Id;
+ LexProductLimitEditController controllerLimit = new LexProductLimitEditController();
+
+ // Given
+ // PageReference page = new PageReference('/apex/ProductLimitEdit?accountid=' + myAccount2.id);
+ // page.setRedirect(true);
+ // System.Test.setCurrentPage(page);
+ // ProductLimitEditController conTest = new ProductLimitEditController();
+ // conTest.init();
+ // System.assertEquals('Test01|5|55,Test02|2|4', conTest.product_Limit);
+
+ // When
+
+ // Then
+ }
+}
diff --git a/force-app/main/default/classes/LexProductLimitEditControllerTest.cls-meta.xml b/force-app/main/default/classes/LexProductLimitEditControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexProductLimitEditControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexRemoveBoxControllerTest.cls b/force-app/main/default/classes/LexRemoveBoxControllerTest.cls
new file mode 100644
index 0000000..7510496
--- /dev/null
+++ b/force-app/main/default/classes/LexRemoveBoxControllerTest.cls
@@ -0,0 +1,806 @@
+@isTest
+private class LexRemoveBoxControllerTest {
+ static testMethod void myUnitTest() {
+ user myUser_test;
+ Account myAccount2;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ];
+ myAccount2 = new Account(
+ name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount2;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+
+ System.runAs(myUser_Test) {
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ StaticParameter.EscapeNFM007Trigger = true;
+ StaticParameter.EscapeOpportunityBefUpdTrigger = true;
+ StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true;
+ StaticParameter.EscapeSyncOpportunityTrigger = true;
+ StaticParameter.EscapeSyncProduct2Trigger = true;
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ JANCODE__c = '04953170200311',
+ Packing_list_manual__c = 12,
+ 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',
+ Packing_list_manual__c = 10,
+ Dealer_special_Object__c = true,
+ Manual_Entry__c = false
+ );
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ JANCODE__c = '04953170200313',
+ Packing_list_manual__c = 1,
+ Dealer_special_Object__c = true,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02, prod03 };
+ 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
+ );
+ Product2__c pro3 = new Product2__c(
+ Name = 'Pro003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod03.Id
+ );
+ insert new List<Product2__c>{ pro1, pro2, pro3 };
+ //璁㈠崟
+ 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 = myAccount2.Id;
+ Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ Order1.Order_ProType__c = 'ET';
+ insert Order1;
+ List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
+
+ //daoku
+ 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.Arrive_date__c = Date.today();
+ Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+ Orderdet2.Used_date__c = null;
+ Orderdet2.Lose_Flag__c = false;
+ Orderdet2.Return_date__c = null;
+ Orderdet2.Send_Date__c = null;
+ Orderdet2.Box_Piece__c = '鐩�';
+ conList1.add(Orderdet2);
+
+ //chuhe
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+ Orderdet3.Name = 'OCM_01_001002';
+ Orderdet3.Consumable_order_minor__c = Order1.Id;
+ Orderdet3.Consumable_Product__c = pro2.Id;
+ Orderdet3.Asset_Model_No__c = 'Test02';
+ Orderdet3.Arrive_date__c = Date.today();
+ Orderdet3.Send_Date__c = Date.today();
+ Orderdet3.Box_Piece__c = '涓�';
+ Orderdet3.RemoveBox_date__c = Date.today();
+ Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
+ Orderdet3.Used_date__c = null;
+ Orderdet3.Lose_Flag__c = false;
+ Orderdet3.Return_date__c = null;
+ conList1.add(Orderdet3);
+
+ //sale
+ 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 = pro2.Id;
+ Orderdet4.Asset_Model_No__c = 'Test02';
+ Orderdet4.Arrive_date__c = Date.today();
+ Orderdet4.Box_Piece__c = '涓�';
+ Orderdet4.RemoveBox_date__c = Date.today();
+ Orderdet4.Bar_Code__c = '011495317020843711170400172003311074K250CXSDS';
+ Orderdet4.Lose_Flag__c = false;
+ Orderdet4.Return_date__c = null;
+ Orderdet4.Used_date__c = Date.today();
+ conList1.add(Orderdet4);
+
+ List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
+ //ProductPacking_list_manual__c=1
+ Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+ Orderdet5.Name = 'OCM_01_001004';
+ Orderdet5.Consumable_order_minor__c = Order1.Id;
+ Orderdet5.Consumable_Product__c = pro3.Id;
+ Orderdet5.Asset_Model_No__c = 'Test03';
+ Orderdet5.Arrive_date__c = Date.today();
+ //Orderdet5.Used_date__c = Date.today();
+ Orderdet5.Box_Piece__c = '鐩�';
+ Orderdet5.RemoveBox_date__c = Date.today();
+ Orderdet5.Used_date__c = null;
+ Orderdet5.Lose_Flag__c = false;
+ Orderdet5.Return_date__c = null;
+ Orderdet5.Send_Date__c = null;
+ Orderdet5.Bar_Code__c = '010495317014059411170400172203311074K250DCWQW';
+ conList.add(Orderdet5);
+ //pandian
+ 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 = pro2.Id;
+ Orderdet7.Asset_Model_No__c = 'Test02';
+ Orderdet7.Box_Piece__c = '鐩�';
+ Orderdet7.Lose_Flag__c = false;
+ Orderdet7.Bar_Code__c = '010495317014059411170400172203311074K250DBVUD';
+ Orderdet7.RemoveBox_date__c = Date.today();
+ Orderdet7.Inventory_date__c = Date.today();
+ conList.add(Orderdet7);
+
+ 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 = pro2.Id;
+ Orderdet8.Asset_Model_No__c = 'Test02';
+ Orderdet8.Arrive_date__c = Date.today();
+ Orderdet8.Box_Piece__c = '涓�';
+ Orderdet8.Lose_Flag__c = false;
+ Orderdet8.Bar_Code__c = '010495317014059411170400172203311074K250DBVUC';
+ Orderdet8.Used_date__c = null;
+ Orderdet8.Lose_Flag__c = false;
+ Orderdet8.Return_date__c = null;
+ Orderdet8.RemoveBox_date__c = Date.today();
+ Orderdet8.Send_Date__c = null;
+ Orderdet8.RemoveBox_No__c = 3;
+ conList.add(Orderdet8);
+ insert conList1;
+ insert conList;
+
+ System.Test.startTest();
+ LexRemoveBoxController Controller = new LexRemoveBoxController();
+ LexRemoveBoxController.init();
+ LexRemoveBoxController.searchConsumableorderdetails(
+ '01049531702003111115120017181000105ZK250BXJRF\n01049531702003111115120017181000105ZK250BXJRA\n011495317020843711170400172003311074K250CXSDS\n010495317014059411170400172203311074K250DCWQW\n010495317014059411170400172203311074K250DBVUD\n010495317014059411170400172203311074K250DBVUC',
+ myAccount2.Id,
+ '娣卞湷',
+ 'ET'
+ );
+ LexRemoveBoxController.searchConsumableorderdetails(
+ '',
+ myAccount2.Id,
+ '閲嶅簡',
+ 'ET'
+ );
+ LexRemoveBoxController.barcode = '1004\n1003\n1002\n1001';
+ LexRemoveBoxController.getinventorysize();
+ LexRemoveBoxController.removeBoxConfirm(
+ JSON.serialize(conList),
+ 'Testaccount002',
+ '閲嶅簡',
+ 'ENG'
+ );
+ List<Consumable_order_details2__c> orderDetaList = new List<Consumable_order_details2__c>();
+ LexRemoveBoxController.removeBoxConfirm(
+ JSON.serialize(orderDetaList),
+ 'Testaccount002',
+ '閲嶅簡',
+ 'ENG'
+ );
+ System.Test.stopTest();
+ }
+ }
+ static testMethod void testMethod1() {
+ user myUser_test;
+ Account myAccount2;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ];
+ myAccount2 = new Account(
+ name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount2;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+
+ System.runAs(myUser_Test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ JANCODE__c = '04953170200311',
+ Packing_list_manual__c = 12,
+ 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',
+ Packing_list_manual__c = 10,
+ Dealer_special_Object__c = true,
+ Manual_Entry__c = false
+ );
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ JANCODE__c = '04953170200313',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02, prod03 };
+ 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
+ );
+ Product2__c pro3 = new Product2__c(
+ Name = 'Pro003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod03.Id
+ );
+ insert new List<Product2__c>{ pro1, pro2, pro3 };
+ //璁㈠崟
+ Consumable_order__c Order1 = new Consumable_order__c();
+ Order1.Name = 'OCM_01';
+ Order1.Order_status__c = '鎵瑰噯';
+ Order1.Order_type__c = '璁㈠崟';
+ Order1.Dealer_Info__c = myAccount2.Id;
+ Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ Order1.Order_ProType__c = 'ET';
+ insert Order1;
+ //鍙戣揣
+ Consumable_order__c Order2 = new Consumable_order__c();
+ Order2.Name = 'OCM_01';
+ Order2.Order_status__c = '鎵瑰噯';
+ Order2.Order_type__c = '璁㈠崟 ';
+ Order2.Dealer_Info__c = myAccount2.Id;
+ Order2.RecordTypeid = '01210000000c9drAAA';
+ Order2.Order_ProType__c = 'ENG';
+ insert Order2;
+
+ List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
+ //浜у搧绫诲瀷涓嶅悓
+ Consumable_order_details2__c con = new Consumable_order_details2__c();
+ con.Name = 'OCM_01_001001';
+ con.Consumable_order_minor__c = Order1.Id;
+ con.Consumable_Product__c = pro1.Id;
+ con.Asset_Model_No__c = 'Test01';
+ con.Arrive_date__c = Date.today();
+ con.Bar_Code__c = '10011';
+ con.Used_date__c = null;
+ con.Lose_Flag__c = false;
+ con.Return_date__c = null;
+ con.Send_Date__c = null;
+ con.Box_Piece__c = '鐩�';
+ conList1.add(con);
+
+ // 鏈埌璐�
+ Consumable_order_details2__c con2 = new Consumable_order_details2__c();
+ con2.Arrive_date__c = null;
+ con2.Send_Date__c = null;
+ con2.Used_date__c = null;
+ con2.Return_date__c = null;
+ con2.Lose_Flag__c = false;
+ con2.Box_Piece__c = '鐩�';
+ con2.Consumable_Arrived_order__c = Order2.Id;
+ con2.Consumable_Product__c = pro2.Id;
+ con2.Consumable_order_minor__c = Order2.Id;
+ con2.Bar_Code__c = '10031';
+ conList1.add(con2);
+ //瑙勬牸=1
+ Consumable_order_details2__c con3 = new Consumable_order_details2__c();
+ con3.Arrive_date__c = Date.today();
+ con3.Send_Date__c = null;
+ con3.Used_date__c = null;
+ con3.Return_date__c = null;
+ con3.Lose_Flag__c = false;
+ con3.Box_Piece__c = '鐩�';
+ con3.Consumable_Arrived_order__c = Order2.Id;
+ con3.Consumable_Product__c = pro3.Id;
+ con3.Consumable_order_minor__c = Order2.Id;
+ con3.RemoveBox_date__c = Date.today();
+ con3.Bar_Code__c = '10032';
+ conList1.add(con3);
+
+ insert conList1;
+ System.Test.startTest();
+ LexRemoveBoxController.searchConsumableorderdetails(
+ '10011',
+ 'Testaccount002',
+ '閲嶅簡',
+ 'ET'
+ );
+ LexRemoveBoxController.searchConsumableorderdetails(
+ '10031\n10032',
+ 'Testaccount002',
+ '閲嶅簡',
+ 'ENG'
+ );
+ System.Test.stopTest();
+ }
+ }
+ static testMethod void testMethod2() {
+ // TO DO: implement unit test
+ user myUser_test;
+ Account myAccount2;
+ Product2__c pro2;
+ Product2__c pro3;
+ Product2__c pro1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ];
+ myAccount2 = new Account(
+ name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount2;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+
+ System.runAs(myUser_Test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ JANCODE__c = '04953170200311',
+ Packing_list_manual__c = 12,
+ 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',
+ Packing_list_manual__c = 10,
+ Dealer_special_Object__c = true,
+ Manual_Entry__c = false
+ );
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ JANCODE__c = '04953170200313',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02, prod03 };
+ pro1 = new Product2__c(
+ Name = 'Pro001',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod01.Id
+ );
+ pro2 = new Product2__c(
+ Name = 'Pro002',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod02.Id
+ );
+ pro3 = new Product2__c(
+ Name = 'Pro003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod03.Id
+ );
+ insert new List<Product2__c>{ pro1, pro2, pro3 };
+ List<Consumable_order__c> orderList = new List<Consumable_order__c>();
+ List<Consumable_order__c> orderList1 = new List<Consumable_order__c>();
+ //鍒拌揣
+ Consumable_order__c Order1 = new Consumable_order__c();
+ Order1.Name = 'OCM_01';
+ Order1.Order_status__c = '鎵瑰噯';
+ Order1.Order_type__c = '鍒拌揣';
+ Order1.Dealer_Info__c = myAccount2.Id;
+ Order1.RecordTypeid = '01210000000c9dqAAA';
+ Order1.Order_ProType__c = 'ET';
+ orderList.add(Order1);
+ //閿�鍞�
+ Consumable_order__c Order2 = new Consumable_order__c();
+ Order2.Name = 'OCM_0144';
+ Order2.Order_status__c = '鎵瑰噯';
+ Order2.Order_type__c = '閿�鍞�';
+ Order2.Dealer_Info__c = myAccount2.Id;
+ Order2.RecordTypeid = '01210000000c9duAAA';
+ Order2.Order_ProType__c = 'ENG';
+ orderList.add(Order2);
+ insert orderList;
+
+ //鍑鸿揣
+ Consumable_order__c Order3 = new Consumable_order__c();
+ Order3.Name = 'OCM_03';
+ Order3.Order_status__c = '鎵瑰噯';
+ Order3.Order_type__c = '鍑鸿揣';
+ Order3.Dealer_Info__c = myAccount2.Id;
+ Order3.RecordTypeid = '012100000006Jx9AAE';
+ Order3.Order_ProType__c = 'ENG';
+ orderList1.add(Order3);
+
+ //鍙戣揣
+ Consumable_order__c Order4 = new Consumable_order__c();
+ Order4.Name = 'OCM_03';
+ Order4.Order_status__c = '鎵瑰噯';
+ Order4.Order_type__c = '鍙戣揣';
+ Order4.Dealer_Info__c = myAccount2.Id;
+ Order4.RecordTypeid = '01210000000c9drAAA';
+ Order4.Order_ProType__c = 'ENG';
+ orderList1.add(Order4);
+ insert orderList1;
+
+ List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
+ //浜у搧绫诲瀷涓嶅悓
+ Consumable_order_details2__c con = new Consumable_order_details2__c();
+ con.Name = 'OCM_01_001001';
+ con.Consumable_order_minor__c = Order1.Id;
+ con.Consumable_Product__c = pro1.Id;
+ con.Asset_Model_No__c = 'Test01';
+ con.Arrive_date__c = Date.today();
+ con.Bar_Code__c = '10011';
+ con.Used_date__c = null;
+ con.Lose_Flag__c = false;
+ con.Return_date__c = null;
+ con.Send_Date__c = null;
+ con.Box_Piece__c = '鐩�';
+ conList1.add(con);
+
+ // // 鏈埌璐�
+ Consumable_order_details2__c con2 = new Consumable_order_details2__c();
+ con2.Arrive_date__c = null;
+ con2.Send_Date__c = null;
+ con2.Used_date__c = null;
+ con2.Return_date__c = null;
+ con2.Lose_Flag__c = false;
+ con2.Box_Piece__c = '鐩�';
+ con2.Consumable_Arrived_order__c = Order2.Id;
+ con2.Consumable_Product__c = pro2.Id;
+ con2.Consumable_order_minor__c = Order2.Id;
+ con2.Bar_Code__c = '10031';
+ conList1.add(con2);
+ //瑙勬牸=1
+ Consumable_order_details2__c con3 = new Consumable_order_details2__c();
+ con3.Arrive_date__c = Date.today();
+ con3.Send_Date__c = null;
+ con3.Used_date__c = null;
+ con3.Return_date__c = null;
+ con3.Lose_Flag__c = false;
+ con3.Box_Piece__c = '鐩�';
+ con3.Consumable_Arrived_order__c = Order2.Id;
+ con3.Consumable_Product__c = pro3.Id;
+ con3.Consumable_order_minor__c = Order2.Id;
+ con3.RemoveBox_date__c = Date.today();
+ con3.Bar_Code__c = '10032';
+ conList1.add(con3);
+
+ insert conList1;
+ System.Test.startTest();
+ LexRemoveBoxController.searchConsumableorderdetails(
+ '10031\n10032\n',
+ 'Testaccount002',
+ '閲嶅簡',
+ 'ENG'
+ );
+ System.Test.stopTest();
+ }
+ }
+ static testMethod void testMethod3() {
+ // TO DO: implement unit test
+ user myUser_test;
+ Account myAccount2;
+ Product2__c pro2;
+ Product2__c pro3;
+ Product2__c pro1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ];
+ myAccount2 = new Account(
+ name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert myAccount2;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+
+ System.runAs(myUser_Test) {
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ JANCODE__c = '04953170200311',
+ Packing_list_manual__c = 12,
+ 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',
+ Packing_list_manual__c = 10,
+ Dealer_special_Object__c = true,
+ Manual_Entry__c = false
+ );
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ JANCODE__c = '04953170200313',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02, prod03 };
+ pro1 = new Product2__c(
+ Name = 'Pro001',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod01.Id
+ );
+ pro2 = new Product2__c(
+ Name = 'Pro002',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod02.Id
+ );
+ pro3 = new Product2__c(
+ Name = 'Pro003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod03.Id
+ );
+ insert new List<Product2__c>{ pro1, pro2, pro3 };
+ List<Consumable_order__c> orderList = new List<Consumable_order__c>();
+ //鍒拌揣
+ Consumable_order__c Order1 = new Consumable_order__c();
+ Order1.Name = 'OCM_01';
+ Order1.Order_status__c = '鎵瑰噯';
+ Order1.Order_type__c = '鍒拌揣';
+ Order1.Dealer_Info__c = myAccount2.Id;
+ Order1.RecordTypeid = '01210000000c9dqAAA';
+ Order1.Order_ProType__c = 'ENG';
+ orderList.add(Order1);
+ //鍙戣揣
+ Consumable_order__c Order2 = new Consumable_order__c();
+ Order2.Name = 'OCM_01';
+ Order2.Order_status__c = '鎵瑰噯';
+ Order2.Order_type__c = '璁㈠崟 ';
+ Order2.Dealer_Info__c = myAccount2.Id;
+ Order2.RecordTypeid = '01210000000c9drAAA';
+ Order2.Order_ProType__c = 'ENG';
+ orderList.add(Order2);
+ insert orderList;
+
+ List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
+ //浜у搧绫诲瀷涓嶅悓
+ Consumable_order_details2__c con = new Consumable_order_details2__c();
+ con.Name = 'OCM_01_001001';
+ con.Consumable_order_minor__c = Order1.Id;
+ con.Consumable_Product__c = pro1.Id;
+ con.Asset_Model_No__c = 'Test01';
+ con.Arrive_date__c = Date.today();
+ con.Bar_Code__c = '10011';
+ con.Used_date__c = null;
+ con.Lose_Flag__c = false;
+ con.Return_date__c = null;
+ con.Send_Date__c = null;
+ con.Box_Piece__c = '鐩�';
+ conList1.add(con);
+
+ // 鏈埌璐�
+ Consumable_order_details2__c con2 = new Consumable_order_details2__c();
+ con2.Arrive_date__c = null;
+ con2.Send_Date__c = null;
+ con2.Used_date__c = null;
+ con2.Return_date__c = null;
+ con2.Lose_Flag__c = false;
+ con2.Box_Piece__c = '鐩�';
+ con2.Consumable_Arrived_order__c = Order2.Id;
+ con2.Consumable_Product__c = pro2.Id;
+ con2.Consumable_order_minor__c = Order2.Id;
+ con2.Bar_Code__c = '10031';
+ conList1.add(con2);
+ //瑙勬牸=1
+ Consumable_order_details2__c con3 = new Consumable_order_details2__c();
+ con3.Arrive_date__c = Date.today();
+ con3.Send_Date__c = null;
+ con3.Used_date__c = null;
+ con3.Return_date__c = null;
+ con3.Lose_Flag__c = false;
+ con3.Box_Piece__c = '鐩�';
+ con3.Consumable_Arrived_order__c = Order2.Id;
+ con3.Consumable_Product__c = pro3.Id;
+ con3.Consumable_order_minor__c = Order2.Id;
+ con3.RemoveBox_date__c = Date.today();
+ con3.Bar_Code__c = '10032';
+ conList1.add(con3);
+
+ insert conList1;
+ System.Test.startTest();
+ LexRemoveBoxController.searchConsumableorderdetails(
+ '10011\n10031',
+ 'Testaccount002',
+ '閲嶅簡',
+ 'ENG'
+ );
+ LexRemoveBoxController.searchConsumableorderdetails(
+ '10032',
+ 'Testaccount002',
+ '涓婃捣',
+ 'ENG'
+ );
+ LexRemoveBoxController.removeBoxConfirm(
+ JSON.serialize(conList1),
+ 'Testaccount002',
+ '閲嶅簡',
+ 'ENG'
+ );
+ System.Test.stopTest();
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexRemoveBoxControllerTest.cls-meta.xml b/force-app/main/default/classes/LexRemoveBoxControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexRemoveBoxControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexSaleAndDeliveryControllerTest.cls b/force-app/main/default/classes/LexSaleAndDeliveryControllerTest.cls
new file mode 100644
index 0000000..e536539
--- /dev/null
+++ b/force-app/main/default/classes/LexSaleAndDeliveryControllerTest.cls
@@ -0,0 +1,115 @@
+@isTest
+private class LexSaleAndDeliveryControllerTest {
+ @isTest
+ static void testInit() {
+ User myUser_test;
+ Account myAccount2;
+ Product2__c pro2;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ];
+ Product2 prod02 = new Product2(
+ Name = 'Test02181',
+ ProductCode = 'Test0218',
+ Asset_Model_No__c = 'Test0218',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test002',
+ Packing_list_manual__c = 12,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'tset8',
+ Manual_Entry__c = false
+ );
+ pro2 = new Product2__c(
+ Name = 'Pro002181',
+ OT_CODE_Text__c = 'Test002181',
+ Product2__c = prod02.Id
+ );
+ insert pro2;
+ myAccount2 = new Account(
+ name = 'Testaccount003',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '2'
+ );
+ insert myAccount2;
+
+ Contact core = new Contact(
+ email = 'wan@salesforce.com',
+ firstname = 'wan',
+ lastname = 'Plumbers',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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 = 'ENG',
+ Work_Location__c = '鍖椾含'
+ );
+ insert myUser_test;
+ myUser_test.UserPro_Type__c = '';
+ update myUser_test;
+ }
+ System.runAs(MyUser_Test) {
+ String accountId = myUser_test.accountid;
+ String agencyProType = myUser_test.UserPro_Type__c;
+ String userWorkLocation = myUser_test.Work_Location__c;
+ System.Test.startTest();
+ LexSaleAndDeliveryController.init();
+ LexSaleAndDeliveryController.searchOrderInstatus(
+ '2023/01/01',
+ '2023/12/31',
+ accountId,
+ agencyProType,
+ userWorkLocation,
+ 'DB',
+ '澶ц繛'
+ );
+ LexSaleAndDeliveryController.searchConsumableorderdetails(
+ '2023/01/01',
+ '2023/12/31',
+ accountId,
+ agencyProType,
+ userWorkLocation,
+ 'DB',
+ '澶ц繛'
+ );
+ LexSaleAndDeliveryController.searchConsumableorFinish(
+ '2023/01/01',
+ '2023/12/31',
+ accountId,
+ agencyProType,
+ userWorkLocation,
+ 'DB',
+ '澶ц繛'
+ );
+ LexSaleAndDeliveryController.cleanUp(
+ accountId,
+ agencyProType,
+ userWorkLocation
+ );
+ System.Test.stopTest();
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexSaleAndDeliveryControllerTest.cls-meta.xml b/force-app/main/default/classes/LexSaleAndDeliveryControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexSaleAndDeliveryControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexSaleOrderController.cls b/force-app/main/default/classes/LexSaleOrderController.cls
index d967cc7..11d88ab 100644
--- a/force-app/main/default/classes/LexSaleOrderController.cls
+++ b/force-app/main/default/classes/LexSaleOrderController.cls
@@ -1,1310 +1,1558 @@
public without sharing class LexSaleOrderController {
- public static boolean isRunning = false;
- public static String barcode { get; set; }
- public static Consumable_order__c coc { get; set; }
- public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords { get; set; }
- @AuraEnabled
- public static List<Consumable_order_details2__c> consumableorderdetails2Nobox { get; set; }
- @AuraEnabled
- public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordserror { get; set; }
- public static Map<String, String> existIdMap { get; set; }
- public static Map<String, String> errorIdMap { get; set; }
- public static Map<String, String> allMap { get; set; }
- public static Map<String, String> orderpieceorboxMap { get; set; }
- public static Map<String, Decimal> orderpriceMap { get; set; }
- public static Map<String, Decimal> orderagencypriceMap { get; set; }
- public static Map<String, Decimal> orderdetCountMap { get; set; }
- public static Map<String, Integer> BarcodeCntMap { get; set; }
- public static String baseUrl { get; private set; }
- public static String ESetId { get; set; }
- public static String accountName { get; set; }
- public static String userWorkLocation { get; set; }
- public static Boolean hasSpecialHos { get; set; }
- public static Map<String, Integer> msiMap { get; set; }
- public static List<Consumable_orderdetails__c> orderdetails { get; set; }
- public static String accountid { get; set; }
+ public static boolean isRunning = false;
+ public static String barcode { get; set; }
+ public static Consumable_order__c coc { get; set; }
+ public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords {
+ get;
+ set;
+ }
+ @AuraEnabled
+ public static List<Consumable_order_details2__c> consumableorderdetails2Nobox {
+ get;
+ set;
+ }
+ @AuraEnabled
+ public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordserror {
+ get;
+ set;
+ }
+ public static Map<String, String> existIdMap { get; set; }
+ public static Map<String, String> errorIdMap { get; set; }
+ public static Map<String, String> allMap { get; set; }
+ public static Map<String, String> orderpieceorboxMap { get; set; }
+ public static Map<String, Decimal> orderpriceMap { get; set; }
+ public static Map<String, Decimal> orderagencypriceMap { get; set; }
+ public static Map<String, Decimal> orderdetCountMap { get; set; }
+ public static Map<String, Integer> BarcodeCntMap { get; set; }
+ public static String baseUrl { get; private set; }
+ public static String ESetId { get; set; }
+ public static String accountName { get; set; }
+ public static String userWorkLocation { get; set; }
+ public static Boolean hasSpecialHos { get; set; }
+ public static Map<String, Integer> msiMap { get; set; }
+ public static List<Consumable_orderdetails__c> orderdetails { get; set; }
+ public static String accountid { get; set; }
- @AuraEnabled
- public static ResponseBodyLWC GoodsDeliveryInit(String ESetId) {
- System.debug('LexSaleOrderController GoodsDeliveryInit');
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
+ @AuraEnabled
+ public static ResponseBodyLWC GoodsDeliveryInit(String ESetId) {
+ System.debug('LexSaleOrderController GoodsDeliveryInit');
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
- String UserName = UserInfo.getUserId();
- user useracc = [SELECT Accountid, Work_Location__c FROM user WHERE id = :UserName];
- accountid = useracc.Accountid;
- userWorkLocation = useracc.Work_Location__c;
- Account accountInfo = [SELECT Name FROM account WHERE id = :accountid];
- accountName = accountInfo.Name;
- consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- consumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
- coc = new Consumable_order__c();
- List<Consumable_order_details2__c> arriveDat = new List<Consumable_order_details2__c>();
- orderpieceorboxMap = new Map<String, String>();
- orderdetails = new List<Consumable_orderdetails__c>();
- orderagencypriceMap = new Map<String, Decimal>();
- orderpriceMap = new Map<String, Decimal>();
- orderdetCountMap = new Map<String, Decimal>();
- if (String.isNotBlank(ESetId)) {
- coc = [
- SELECT
- Id,
- Name,
- NoConfirmedPrice__c,
- Order_ForDealer__r.Name,
- Summons_Order_type__c,
- Order_status__c,
- Dealer_Info__c,
- Dealer_Info__r.Name,
- SummonsStatus_c__c,
- Deliver_date__c,
- Order_Reason__c,
- Order_date__c,
- Order_ForHospital__c,
- SummonsForDirction__c,
- Arrive_Order__c,
- Arrive_Order__r.IsShipment__c,
- Outbound_Date__c,
- Billed_Status__c,
- ShipmentAccount__c,
- Order_ForCustomerText__c,
- OutPattern__c
- FROM Consumable_order__c
- WHERE Id = :ESetId
- ];
- // update end by vivek 2019-7-16
- if (coc.Arrive_Order__c != null) {
- arriveDat = [
- SELECT
- Id,
- Name,
- recordtypeid,
- Used_account__c,
- Product_Pattern__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Deliver_date__c,
- Bar_Code__c,
- Arrive_date__c,
- Send_Date__c,
- Consumable_order_minor__r.Name,
- Consumable_order_minor__c,
- Intra_Trade_List_RMB__c,
- Asset_Model_No__c,
- Isoverdue__c,
- Guarantee_period_for_products__c,
- Box_Piece__c,
- // gzw add 20210308 鎶ラ敊淇
- hospitalSpecialOffer__c
- FROM Consumable_order_details2__c
- WHERE Consumable_ZS_order__c = :ESetId
- ];
- for (Integer j = 0; j < arriveDat.size(); j++) {
- consumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(arriveDat[j]));
- }
- }
-
- orderdetails = [
- SELECT
- Id,
- Name,
- Product_Pattern__c,
- Consumable_product__r.Name,
- Shipment_Count__c,
- Box_Piece__c,
- Delivery_List_RMB__c,
- Unitprice_To_agency__c,
- isOutPattern__c
- FROM Consumable_orderdetails__c
- WHERE Consumable_order__c = :ESetId AND Order_Owner_WorkLocal__c = :userWorkLocation
- ];
-
- for (Integer i = 0; i < orderdetails.size(); i++) {
- orderpieceorboxMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Box_Piece__c);
- if (orderdetails[i].Unitprice_To_agency__c != null && orderdetails[i].Unitprice_To_agency__c != 0) {
- orderagencypriceMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Unitprice_To_agency__c);
- }
- orderpriceMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Delivery_List_RMB__c);
- orderdetCountMap.put(orderdetails[i].Product_Pattern__c, orderdetails[i].Shipment_Count__c);
- }
- List<hospitalprice__c> hlist = [
- SELECT id
- FROM hospitalprice__c
- WHERE hospital__c = :coc.ShipmentAccount__c AND account__c = :accountid
- ];
- if (hlist == null || hlist.size() == 0) {
- hasSpecialHos = false;
- } else {
- hasSpecialHos = true;
- }
+ String UserName = UserInfo.getUserId();
+ user useracc = [
+ SELECT Accountid, Work_Location__c
+ FROM user
+ WHERE id = :UserName
+ ];
+ accountid = useracc.Accountid;
+ userWorkLocation = useracc.Work_Location__c;
+ Account accountInfo = [SELECT Name FROM account WHERE id = :accountid];
+ accountName = accountInfo.Name;
+ consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ consumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
+ coc = new Consumable_order__c();
+ List<Consumable_order_details2__c> arriveDat = new List<Consumable_order_details2__c>();
+ orderpieceorboxMap = new Map<String, String>();
+ orderdetails = new List<Consumable_orderdetails__c>();
+ orderagencypriceMap = new Map<String, Decimal>();
+ orderpriceMap = new Map<String, Decimal>();
+ orderdetCountMap = new Map<String, Decimal>();
+ if (String.isNotBlank(ESetId)) {
+ coc = [
+ SELECT
+ Id,
+ Name,
+ NoConfirmedPrice__c,
+ Order_ForDealer__r.Name,
+ Summons_Order_type__c,
+ Order_status__c,
+ Dealer_Info__c,
+ Dealer_Info__r.Name,
+ SummonsStatus_c__c,
+ Deliver_date__c,
+ Order_Reason__c,
+ Order_date__c,
+ Order_ForHospital__c,
+ SummonsForDirction__c,
+ Arrive_Order__c,
+ Arrive_Order__r.IsShipment__c,
+ Outbound_Date__c,
+ Billed_Status__c,
+ ShipmentAccount__c,
+ Order_ForCustomerText__c,
+ OutPattern__c
+ FROM Consumable_order__c
+ WHERE Id = :ESetId
+ ];
+ // update end by vivek 2019-7-16
+ if (coc.Arrive_Order__c != null) {
+ arriveDat = [
+ SELECT
+ Id,
+ Name,
+ recordtypeid,
+ Used_account__c,
+ Product_Pattern__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Bar_Code__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ Intra_Trade_List_RMB__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Guarantee_period_for_products__c,
+ Box_Piece__c,
+ // gzw add 20210308 鎶ラ敊淇
+ hospitalSpecialOffer__c
+ FROM Consumable_order_details2__c
+ WHERE Consumable_ZS_order__c = :ESetId
+ ];
+ for (Integer j = 0; j < arriveDat.size(); j++) {
+ consumableorderdetailsRecords.add(
+ new ConsumableorderdetailsInfo(arriveDat[j])
+ );
}
- data.put('consumableorderdetailsRecords', consumableorderdetailsRecords);
- data.put('consumableorderdetailsRecordserror', consumableorderdetailsRecordserror);
- data.put('coc', coc);
- data.put('accountName', accountName);
- data.put('userWorkLocation', userWorkLocation);
- data.put('accountid', accountid);
- data.put('orderdetails', orderdetails);
- data.put('orderpieceorboxMap', orderpieceorboxMap);
- data.put('orderpriceMap', orderpriceMap);
- data.put('orderagencypriceMap', orderagencypriceMap);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ }
+
+ orderdetails = [
+ SELECT
+ Id,
+ Name,
+ Product_Pattern__c,
+ Consumable_product__r.Name,
+ Shipment_Count__c,
+ Box_Piece__c,
+ Delivery_List_RMB__c,
+ Unitprice_To_agency__c,
+ isOutPattern__c
+ FROM Consumable_orderdetails__c
+ WHERE
+ Consumable_order__c = :ESetId
+ AND Order_Owner_WorkLocal__c = :userWorkLocation
+ ];
+
+ for (Integer i = 0; i < orderdetails.size(); i++) {
+ orderpieceorboxMap.put(
+ orderdetails[i].Product_Pattern__c,
+ orderdetails[i].Box_Piece__c
+ );
+ if (
+ orderdetails[i].Unitprice_To_agency__c != null &&
+ orderdetails[i].Unitprice_To_agency__c != 0
+ ) {
+ orderagencypriceMap.put(
+ orderdetails[i].Product_Pattern__c,
+ orderdetails[i].Unitprice_To_agency__c
+ );
+ }
+ orderpriceMap.put(
+ orderdetails[i].Product_Pattern__c,
+ orderdetails[i].Delivery_List_RMB__c
+ );
+ orderdetCountMap.put(
+ orderdetails[i].Product_Pattern__c,
+ orderdetails[i].Shipment_Count__c
+ );
+ }
+ List<hospitalprice__c> hlist = [
+ SELECT id
+ FROM hospitalprice__c
+ WHERE hospital__c = :coc.ShipmentAccount__c AND account__c = :accountid
+ ];
+ if (hlist == null || hlist.size() == 0) {
+ hasSpecialHos = false;
+ } else {
+ hasSpecialHos = true;
+ }
+ }
+ data.put('consumableorderdetailsRecords', consumableorderdetailsRecords);
+ data.put(
+ 'consumableorderdetailsRecordserror',
+ consumableorderdetailsRecordserror
+ );
+ data.put('coc', coc);
+ data.put('accountName', accountName);
+ data.put('userWorkLocation', userWorkLocation);
+ data.put('accountid', accountid);
+ data.put('orderdetails', orderdetails);
+ data.put('orderpieceorboxMap', orderpieceorboxMap);
+ data.put('orderpriceMap', orderpriceMap);
+ data.put('orderagencypriceMap', orderagencypriceMap);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ @AuraEnabled
+ public static ResponseBodyLWC SearchPro(
+ Consumable_order__c cocLwc,
+ String barcodeLwc,
+ String accountName,
+ String userWorkLocation,
+ String accountid,
+ List<Consumable_orderdetails__c> orderdetails,
+ Map<String, String> orderpieceorboxMap
+ ) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ coc = cocLwc;
+ orderdetails = orderdetails;
+ barcode = barcodeLwc;
+ accountName = accountName;
+ userWorkLocation = userWorkLocation;
+ accountid = accountid;
+ orderdetails = orderdetails;
+ orderpieceorboxMap = orderpieceorboxMap;
+ //鍒ゆ柇鏄惁鍜岃鍗曡仈鍔�
+ if (coc.Arrive_Order__c != null) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'鏃犻渶鍒拌揣纭锛岃鐩存帴鍑哄簱銆�'));
+ // return;
+ return new ResponseBodyLWC('Error', 500, '鏃犻渶鍒拌揣纭锛岃鐩存帴鍑哄簱', '');
+ }
+ //鍒ゆ柇barcode鏄惁涓虹┖
+ if (barcode == null || barcode == '') {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'璇疯緭BarCode鍙枫��'));
+ // return;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭BarCode鍙�', '');
+ }
+ list<String> exitlist = new List<String>();
+ list<String> notexitlist = new List<String>();
+ existIdMap = new Map<String, String>();
+ errorIdMap = new Map<String, String>();
+ allMap = new Map<String, String>();
+ consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ consumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
+ List<String> barCodeListP = new List<String>();
+ List<Consumable_order_details2__c> reSet = new List<Consumable_order_details2__c>();
+ List<Consumable_order_details2__c> reSet1 = new List<Consumable_order_details2__c>();
+
+ //BarCodelist鍋氭垚
+ barCodeListP = ParseBarCode(barcode);
+ System.debug('barCodeListP:' + barCodeListP);
+ //閽堝鎵�鏈夊晢鍝佸埌璐х‘璁�
+ reSet1 = [
+ SELECT
+ Id,
+ Name,
+ recordtypeid,
+ Used_account__c,
+ Product_Pattern__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Bar_Code__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ Intra_Trade_List_RMB__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ ProductPacking_list_manual__c,
+ Guarantee_period_for_products__c,
+ hospitalSpecialOffer__c,
+ exchangeOutPattern__c
+ FROM Consumable_order_details2__c
+ WHERE
+ Dealer_Arrive__c = TRUE
+ AND Dealer_Returned__c = FALSE
+ AND Bar_Code__c != NULL
+ AND Dealer_Info_text__c = :accountName
+ AND Bar_Code__c IN :barCodeListP
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ ORDER BY RemoveBox_No__c DESC
+ ];
+ System.debug('reSet1:' + reSet1);
+ List<Consumable_order_details2__c> newdet2 = new List<Consumable_order_details2__c>();
+ Set<Id> proIds = new Set<Id>();
+
+ for (String barcode : barCodeListP) {
+ Integer idx = 0;
+ for (Consumable_order_details2__c cod2 : reSet1) {
+ if (cod2.Bar_Code__c == barcode) {
+ System.debug('cod2.Bar_Code__c:' + cod2.Bar_Code__c);
+ newdet2.add(cod2);
+ reSet1.remove(idx);
+ proIds.add(cod2.Consumable_product__c);
+ break;
+ }
+ idx++;
+ }
+ }
+ Map<String, String> proHosMap = new Map<String, String>();
+ Map<String, String> proIdMap = new Map<String, String>();
+ List<hospitalprice__c> hpList = [
+ SELECT id, hospital__c, product__c
+ FROM hospitalprice__c
+ WHERE account__c = :accountid
+ ];
+ if (hpList != null && hpList.size() > 0) {
+ for (hospitalprice__c hp : hpList) {
+ if (
+ hp.product__c != null &&
+ String.valueof(hp.product__c).length() >= 15
+ ) {
+ proIdMap.put(('' + hp.product__c).subString(0, 15) + '鏄�', '');
+ if (hp.hospital__c == coc.Order_ForHospital__c) {
+ proHosMap.put(('' + hp.product__c).subString(0, 15) + '鏄�', '');
+ }
+ }
+ }
+ }
+ for (Integer i = 0; i < orderdetails.size(); i++) {
+ for (Integer j = 0; j < newdet2.size(); j++) {
+ if (
+ newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c &&
+ newdet2[j].Box_Piece__c != orderdetails[i].Box_Piece__c
+ ) {
+ String str = '璇ュ晢鍝佸嚭璐у崟浣嶉敊璇�';
+ consumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(newdet2[j], str)
+ );
+ errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
+ }
+ if (coc.OutPattern__c == true) {
+ System.debug(
+ 'testPattern:' +
+ newdet2[j].Product_Pattern__c +
+ '---' +
+ orderdetails[i].Product_Pattern__c
+ );
+ if (
+ newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c
+ ) {
+ //add by rentx 2021-03-22 start
+ if (newdet2[j].exchangeOutPattern__c == true) {
+ //濡傛灉褰撳墠缁忛攢鍟嗕笅娌℃湁缁存姢瀵瑰簲鐨勭壒浠蜂骇鍝� 鎶ラ敊
+ if (!proIdMap.containsKey(newdet2[j].Product_Pattern__c)) {
+ String str = '娌℃湁缁存姢璇ヤ骇鍝佺殑鐗逛环鍖婚櫌';
+ consumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(newdet2[j], str)
+ );
+ errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
+ }
+ }
+ //add by rentx 2021-03-22 end
+
+ if (hpList != null && hpList.size() > 0) {
+ if (proHosMap.containsKey(newdet2[j].Product_Pattern__c)) {
+ continue;
+ } else if (!proIdMap.containsKey(newdet2[j].Product_Pattern__c)) {
+ continue;
+ } else {
+ String str = '璇ュ晢鍝佸嚭搴撳尰闄㈤敊璇�';
+ consumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(newdet2[j], str)
+ );
+ errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
+ }
+ }
+ }
+ }
+ }
}
- @AuraEnabled
- public static ResponseBodyLWC SearchPro(
- Consumable_order__c cocLwc,
- String barcodeLwc,
- String accountName,
- String userWorkLocation,
- String accountid,
- List<Consumable_orderdetails__c> orderdetails,
- Map<String, String> orderpieceorboxMap
- ) {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- coc = cocLwc;
- orderdetails = orderdetails;
- barcode = barcodeLwc;
- accountName = accountName;
- userWorkLocation = userWorkLocation;
- accountid = accountid;
- orderdetails = orderdetails;
- orderpieceorboxMap = orderpieceorboxMap;
- //鍒ゆ柇鏄惁鍜岃鍗曡仈鍔�
- if (coc.Arrive_Order__c != null) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'鏃犻渶鍒拌揣纭锛岃鐩存帴鍑哄簱銆�'));
- // return;
- return new ResponseBodyLWC('Error', 500, '鏃犻渶鍒拌揣纭锛岃鐩存帴鍑哄簱', '');
+ //绠$悊缂栫爜涓虹┖鏃讹紝鎶ラ敊
+ reSet1 = [
+ SELECT
+ Id,
+ Name,
+ Product_Pattern__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Bar_Code__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ recordtypeid,
+ Consumable_order_minor__r.Arrive_Order__c,
+ Box_Piece__c,
+ Arrive_Owner_Work_Location__c,
+ hospitalSpecialOffer__c
+ FROM Consumable_order_details2__c
+ WHERE
+ Bar_Code__c IN :barCodeListP
+ AND Bar_Code__c != NULL
+ AND Dealer_Arrive__c = TRUE
+ 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) ||
+ existIdMap.containsKey(reSet1[i].Bar_Code__c)
+ ) {
+ // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+ continue;
+ } else {
+ String str = '璇ヤ骇鍝佹病鏈夌鐞嗙紪鐮侊紝鏃犳硶鍑哄簱锛岃涓庣壒绾︾粡閿�鍟嗙鐞嗛儴浜哄憳鑱旂郴锛屼慨姝f暟鎹�';
+ consumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(reSet1[i], str)
+ );
+ errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
}
- //鍒ゆ柇barcode鏄惁涓虹┖
- if (barcode == null || barcode == '') {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'璇疯緭BarCode鍙枫��'));
- // return;
- return new ResponseBodyLWC('Error', 500, '璇疯緭BarCode鍙�', '');
+ }
+ }
+ reSet1 = [
+ SELECT
+ Id,
+ Name,
+ Product_Pattern__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Bar_Code__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ recordtypeid,
+ Consumable_order_minor__r.Arrive_Order__c,
+ Box_Piece__c,
+ Arrive_Owner_Work_Location__c,
+ hospitalSpecialOffer__c
+ FROM Consumable_order_details2__c
+ WHERE
+ Bar_Code__c IN :barCodeListP
+ AND Bar_Code__c != NULL
+ AND Dealer_Arrive__c = TRUE
+ AND Dealer_Info_text__c = :accountName
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Cancellation_Flag__c = TRUE
+ ORDER BY Name
+ ];
+ if (reSet1.size() > 0) {
+ for (Integer i = 0; i < reSet1.size(); i++) {
+ if (
+ errorIdMap.containsKey(reSet1[i].Bar_Code__c) ||
+ existIdMap.containsKey(reSet1[i].Bar_Code__c)
+ ) {
+ // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+ continue;
+ } else {
+ String str = '璇ュ晢鍝佸凡缁忓彇娑�';
+ consumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(reSet1[i], str)
+ );
+ errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
}
- list<String> exitlist = new List<String>();
- list<String> notexitlist = new List<String>();
- existIdMap = new Map<String, String>();
- errorIdMap = new Map<String, String>();
- allMap = new Map<String, String>();
- consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
- consumableorderdetailsRecordserror = new List<ConsumableorderdetailsInfo>();
- List<String> barCodeListP = new List<String>();
- List<Consumable_order_details2__c> reSet = new List<Consumable_order_details2__c>();
- List<Consumable_order_details2__c> reSet1 = new List<Consumable_order_details2__c>();
+ }
+ }
- //BarCodelist鍋氭垚
- barCodeListP = ParseBarCode(barcode);
- //閽堝鎵�鏈夊晢鍝佸埌璐х‘璁�
- reSet1 = [
- SELECT
- Id,
- Name,
- recordtypeid,
- Used_account__c,
- Product_Pattern__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Deliver_date__c,
- Bar_Code__c,
- Arrive_date__c,
- Send_Date__c,
- Consumable_order_minor__r.Name,
- Consumable_order_minor__c,
- Intra_Trade_List_RMB__c,
- Asset_Model_No__c,
- Isoverdue__c,
- Box_Piece__c,
- ProductPacking_list_manual__c,
- Guarantee_period_for_products__c,
- hospitalSpecialOffer__c,
- exchangeOutPattern__c
- FROM Consumable_order_details2__c
- WHERE
- Dealer_Arrive__c = TRUE
- AND Dealer_Returned__c = FALSE
- AND Bar_Code__c != NULL
- AND Dealer_Info_text__c = :accountName
- AND Bar_Code__c IN :barCodeListP
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- ORDER BY RemoveBox_No__c DESC
- ];
- List<Consumable_order_details2__c> newdet2 = new List<Consumable_order_details2__c>();
- Set<Id> proIds = new Set<Id>();
+ //涓嶆槸鏈嚭搴撳崟鐨勫嚭搴撲骇鍝�
+ reSet1 = [
+ SELECT
+ Id,
+ Name,
+ Product_Pattern__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Bar_Code__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ recordtypeid,
+ Consumable_order_minor__r.Arrive_Order__c,
+ Box_Piece__c,
+ Arrive_Owner_Work_Location__c,
+ hospitalSpecialOffer__c
+ FROM Consumable_order_details2__c
+ WHERE
+ Bar_Code__c IN :barCodeListP
+ AND Bar_Code__c != NULL
+ AND Dealer_Arrive__c = TRUE
+ 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) ||
+ existIdMap.containsKey(reSet1[i].Bar_Code__c)
+ ) {
+ // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+ continue;
+ } else if (
+ !orderpieceorboxMap.containsKey(reSet1[i].Product_Pattern__c)
+ ) {
+ String str = '涓嶆槸鏈嚭搴撳崟鐨勫嚭搴撲骇鍝�';
+ consumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(reSet1[i], str)
+ );
+ errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+ }
+ }
+ }
- for (String barcode : barCodeListP) {
- Integer idx = 0;
- for (Consumable_order_details2__c cod2 : reSet1) {
- if (cod2.Bar_Code__c == barcode) {
- newdet2.add(cod2);
- reSet1.remove(idx);
- proIds.add(cod2.Consumable_product__c);
- break;
- }
- idx++;
+ reSet1 = [
+ SELECT
+ Id,
+ Name,
+ Product_Pattern__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Bar_Code__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ recordtypeid,
+ Consumable_order_minor__r.Arrive_Order__c,
+ Box_Piece__c,
+ Dealer_Info_text__c,
+ Arrive_Owner_Work_Location__c,
+ hospitalSpecialOffer__c
+ FROM Consumable_order_details2__c
+ WHERE
+ Bar_Code__c IN :barCodeListP
+ AND Bar_Code__c != NULL
+ AND Dealer_Arrive__c = TRUE
+ AND ((Dealer_Info_text__c = :accountName
+ AND Arrive_Owner_Work_Location__c != :userWorkLocation)
+ OR Dealer_Info_text__c != :accountName)
+ AND Cancellation_Flag__c = FALSE
+ AND Dealer_Shipment__c = FALSE
+ AND Dealer_Saled__c = FALSE
+ AND Lose_Flag__c = FALSE
+ AND Dealer_Returned__c = FALSE
+ ORDER BY Name
+ ];
+ if (reSet1.size() > 0) {
+ for (Integer i = 0; i < reSet1.size(); i++) {
+ if (
+ errorIdMap.containsKey(reSet1[i].Bar_Code__c) ||
+ existIdMap.containsKey(reSet1[i].Bar_Code__c)
+ ) {
+ // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+ continue;
+ } else {
+ // 褰撳墠缁忛攢鍟嗘槸鍚﹀瓨鍦ㄦ浜у搧鍒ゆ柇
+ boolean containsFlg = false;
+ for (Consumable_order_details2__c cod2 : newdet2) {
+ if (cod2.Bar_Code__c == reSet1[i].Bar_Code__c) {
+ containsFlg = true;
+ break;
}
- }
- Map<String, String> proHosMap = new Map<String, String>();
- Map<String, String> proIdMap = new Map<String, String>();
- List<hospitalprice__c> hpList = [SELECT id, hospital__c, product__c FROM hospitalprice__c WHERE account__c = :accountid];
- if (hpList != null && hpList.size() > 0) {
- for (hospitalprice__c hp : hpList) {
- if (hp.product__c != null && String.valueof(hp.product__c).length() >= 15) {
- proIdMap.put(('' + hp.product__c).subString(0, 15) + '鏄�', '');
- if (hp.hospital__c == coc.Order_ForHospital__c) {
- proHosMap.put(('' + hp.product__c).subString(0, 15) + '鏄�', '');
- }
- }
+ }
+ if (containsFlg == false) {
+ String str =
+ '璇ュ晢鍝佹槸' +
+ reSet1[i].Arrive_Owner_Work_Location__c +
+ '鐨勫簱瀛�';
+ if (reSet1[i].Dealer_Info_text__c != accountName) {
+ str = '璇ュ晢鍝佸湪鍏朵粬缁忛攢鍟嗗簱瀛�';
}
+ consumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(reSet1[i], str)
+ );
+ errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+ }
}
- for (Integer i = 0; i < orderdetails.size(); i++) {
- for (Integer j = 0; j < newdet2.size(); j++) {
+ }
+ }
+
+ reSet1 = [
+ SELECT
+ Id,
+ Name,
+ Product_Pattern__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Bar_Code__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ recordtypeid,
+ Consumable_order_minor__r.Arrive_Order__c,
+ Box_Piece__c,
+ hospitalSpecialOffer__c
+ FROM Consumable_order_details2__c
+ WHERE
+ Dealer_Saled__c = TRUE
+ AND Box_Piece__c = '鐩�'
+ AND Dealer_Info_text__c = :accountName
+ AND Dealer_Returned__c = FALSE
+ 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) ||
+ existIdMap.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,
+ Product_Pattern__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Bar_Code__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ recordtypeid,
+ Consumable_order_minor__r.Arrive_Order__c,
+ Box_Piece__c,
+ hospitalSpecialOffer__c
+ FROM Consumable_order_details2__c
+ WHERE
+ Dealer_Shipment__c = TRUE
+ AND Box_Piece__c = '鐩�'
+ AND Dealer_Info_text__c = :accountName
+ AND Dealer_Returned__c = FALSE
+ 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) ||
+ existIdMap.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,
+ Product_Pattern__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Bar_Code__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ recordtypeid,
+ Consumable_order_minor__r.Arrive_Order__c,
+ Box_Piece__c,
+ hospitalSpecialOffer__c
+ FROM Consumable_order_details2__c
+ WHERE
+ Lose_Flag__c = TRUE
+ AND Box_Piece__c = '鐩�'
+ 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) ||
+ existIdMap.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);
+ }
+ }
+ }
+ reSet = [
+ SELECT
+ Id,
+ Name,
+ recordtypeid,
+ Used_account__c,
+ Product_Pattern__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Bar_Code__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ Consumable_order_minor__r.Arrive_Order__c,
+ Intra_Trade_List_RMB__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ ProductPacking_list_manual__c,
+ Guarantee_period_for_products__c,
+ TracingCode__c,
+ Transfer_Time__c,
+ Frist_Transfer_Agency__c,
+ hospitalSpecialOffer__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 Bar_Code__c != NULL
+ AND Dealer_Info_text__c = :accountName
+ AND Bar_Code__c IN :barCodeListP
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ ORDER BY RemoveBox_No__c DESC
+ ];
+ //瀵瑰簲褰曞叆barcode鏁伴噺鐨勬绱㈢粨鏋�
+ newdet2 = new List<Consumable_order_details2__c>();
+ for (String barcode : barCodeListP) {
+ Integer idx = 0;
+ for (Consumable_order_details2__c cod2 : reSet) {
+ if (cod2.Bar_Code__c == barcode) {
+ newdet2.add(cod2);
+ reSet.remove(idx);
+ break;
+ }
+ idx++;
+ }
+ }
+ Map<String, String> checkBarcodeResult = new Map<String, String>();
+ for (Integer i = 0; i < orderdetails.size(); i++) {
+ Integer a = 0;
+ for (Integer j = 0; j < newdet2.size(); j++) {
+ if (
+ newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c &&
+ a < orderdetails[i].Shipment_Count__c
+ ) {
+ if (
+ (existIdMap.containsKey(newdet2[j].Bar_Code__c) &&
+ newdet2[j].Bar_Code__c == '鐩�') ||
+ errorIdMap.containsKey(newdet2[j].Bar_Code__c)
+ ) {
+ // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+ continue;
+ } else if (newdet2[j].Isoverdue__c == 0) {
+ String str = '璇ュ晢鍝佸凡缁忚秴鍑哄噺鑿屾湁鏁堟湡鐨勬湁鏁堣寖鍥�';
+ consumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(newdet2[j], str)
+ );
+ errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
+ } else if (newdet2[j].Box_Piece__c != orderdetails[i].Box_Piece__c) {
+ String str = '璇ュ晢鍝佸嚭璐у崟浣嶉敊璇�';
+ consumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(newdet2[j], str)
+ );
+ errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
+ } else if (!checkBarcodeResult.containsKey(newdet2[j].Bar_Code__c)) {
+ Matcher n = Pattern.compile('[0-9]')
+ .matcher(newdet2[j].TracingCode__c);
+ if (n.find()) {
+ if (newdet2[j].TracingCode__c.length() == 5) {
+ String tr = newdet2[j].TracingCode__c;
+ String Ctr = tr.substring(tr.length() - 3, tr.length());
+ String Btr = tr.substring(tr.length() - 4, tr.length() - 3);
+ String Atr = tr.substring(tr.length() - 5, tr.length() - 4);
if (
- newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c &&
- newdet2[j].Box_Piece__c != orderdetails[i].Box_Piece__c
+ Pattern.compile('[0-9]').matcher(Atr).find() ||
+ Pattern.compile('[0-9]').matcher(Ctr).find()
) {
- String str = '璇ュ晢鍝佸嚭璐у崟浣嶉敊璇�';
- consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
- errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
+ String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
+ consumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(newdet2[j], str)
+ );
+ errorIdMap.put(
+ newdet2[j].Bar_Code__c,
+ newdet2[j].Bar_Code__c
+ );
+ continue;
}
- if (coc.OutPattern__c == true) {
- if (newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c) {
- //add by rentx 2021-03-22 start
- if (newdet2[j].exchangeOutPattern__c == true) {
- //濡傛灉褰撳墠缁忛攢鍟嗕笅娌℃湁缁存姢瀵瑰簲鐨勭壒浠蜂骇鍝� 鎶ラ敊
- if (!proIdMap.containsKey(newdet2[j].Product_Pattern__c)) {
- String str = '娌℃湁缁存姢璇ヤ骇鍝佺殑鐗逛环鍖婚櫌';
- consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
- errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
- }
- }
- //add by rentx 2021-03-22 end
-
- if (hpList != null && hpList.size() > 0) {
- if (proHosMap.containsKey(newdet2[j].Product_Pattern__c)) {
- continue;
- } else if (!proIdMap.containsKey(newdet2[j].Product_Pattern__c)) {
- continue;
- } else {
- String str = '璇ュ晢鍝佸嚭搴撳尰闄㈤敊璇�';
- consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
- errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
- }
- }
- }
- }
+ }
+ // String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
+ // consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
+ // errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
+ // continue;
}
+ checkBarcodeResult.put(
+ newdet2[j].Bar_Code__c,
+ newdet2[j].Bar_Code__c
+ );
+ consumableorderdetailsRecords.add(
+ new ConsumableorderdetailsInfo(newdet2[j])
+ );
+ a++;
+ existIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
+ }
+ } else if (
+ newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c
+ ) {
+ if (
+ a >= orderdetails[i].Shipment_Count__c &&
+ orderdetails[i].Box_Piece__c == '涓�'
+ ) {
+ // 璺宠繃瓒呰繃鏁伴噺鐨勬秷鑰楀搧鏄庣粏
+ continue;
+ } else if (errorIdMap.containsKey(newdet2[j].Bar_Code__c)) {
+ // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+ continue;
+ } else {
+ //CHAN-C23BWX update by rentx 2021-04-28 start
+ // String str = '璇ュ晢鍝佽秴鍑鸿璐ф暟閲�';
+ String str = '璇ヤ骇鍝佽秴鍑哄嚭搴撳崟浜у搧鑼冨洿';
+ //CHAN-C23BWX update by rentx 2021-04-28 end
+ consumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(newdet2[j], str)
+ );
+ errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
+ }
}
-
- //绠$悊缂栫爜涓虹┖鏃讹紝鎶ラ敊
- reSet1 = [
- SELECT
- Id,
- Name,
- Product_Pattern__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Deliver_date__c,
- Bar_Code__c,
- Arrive_date__c,
- Send_Date__c,
- Consumable_order_minor__r.Name,
- Consumable_order_minor__c,
- recordtypeid,
- Consumable_order_minor__r.Arrive_Order__c,
- Box_Piece__c,
- Arrive_Owner_Work_Location__c,
- hospitalSpecialOffer__c
- FROM Consumable_order_details2__c
- WHERE
- Bar_Code__c IN :barCodeListP
- AND Bar_Code__c != NULL
- AND Dealer_Arrive__c = TRUE
- 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) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
- // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
- continue;
- } else {
- String str = '璇ヤ骇鍝佹病鏈夌鐞嗙紪鐮侊紝鏃犳硶鍑哄簱锛岃涓庣壒绾︾粡閿�鍟嗙鐞嗛儴浜哄憳鑱旂郴锛屼慨姝f暟鎹�';
- consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
- errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
- }
- }
- }
- reSet1 = [
- SELECT
- Id,
- Name,
- Product_Pattern__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Deliver_date__c,
- Bar_Code__c,
- Arrive_date__c,
- Send_Date__c,
- Consumable_order_minor__r.Name,
- Consumable_order_minor__c,
- recordtypeid,
- Consumable_order_minor__r.Arrive_Order__c,
- Box_Piece__c,
- Arrive_Owner_Work_Location__c,
- hospitalSpecialOffer__c
- FROM Consumable_order_details2__c
- WHERE
- Bar_Code__c IN :barCodeListP
- AND Bar_Code__c != NULL
- AND Dealer_Arrive__c = TRUE
- AND Dealer_Info_text__c = :accountName
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- AND Cancellation_Flag__c = TRUE
- ORDER BY Name
- ];
- if (reSet1.size() > 0) {
- for (Integer i = 0; i < reSet1.size(); i++) {
- if (errorIdMap.containsKey(reSet1[i].Bar_Code__c) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
- // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
- 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,
- Product_Pattern__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Deliver_date__c,
- Bar_Code__c,
- Arrive_date__c,
- Send_Date__c,
- Consumable_order_minor__r.Name,
- Consumable_order_minor__c,
- recordtypeid,
- Consumable_order_minor__r.Arrive_Order__c,
- Box_Piece__c,
- Arrive_Owner_Work_Location__c,
- hospitalSpecialOffer__c
- FROM Consumable_order_details2__c
- WHERE
- Bar_Code__c IN :barCodeListP
- AND Bar_Code__c != NULL
- AND Dealer_Arrive__c = TRUE
- 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) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
- // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
- continue;
- } else if (!orderpieceorboxMap.containsKey(reSet1[i].Product_Pattern__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,
- Product_Pattern__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Deliver_date__c,
- Bar_Code__c,
- Arrive_date__c,
- Send_Date__c,
- Consumable_order_minor__r.Name,
- Consumable_order_minor__c,
- recordtypeid,
- Consumable_order_minor__r.Arrive_Order__c,
- Box_Piece__c,
- Dealer_Info_text__c,
- Arrive_Owner_Work_Location__c,
- hospitalSpecialOffer__c
- FROM Consumable_order_details2__c
- WHERE
- Bar_Code__c IN :barCodeListP
- AND Bar_Code__c != NULL
- AND Dealer_Arrive__c = TRUE
- AND ((Dealer_Info_text__c = :accountName
- AND Arrive_Owner_Work_Location__c != :userWorkLocation)
- OR Dealer_Info_text__c != :accountName)
- AND Cancellation_Flag__c = FALSE
- AND Dealer_Shipment__c = FALSE
- AND Dealer_Saled__c = FALSE
- AND Lose_Flag__c = FALSE
- AND Dealer_Returned__c = FALSE
- ORDER BY Name
- ];
- if (reSet1.size() > 0) {
- for (Integer i = 0; i < reSet1.size(); i++) {
- if (errorIdMap.containsKey(reSet1[i].Bar_Code__c) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
- // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
- continue;
- } else {
- // 褰撳墠缁忛攢鍟嗘槸鍚﹀瓨鍦ㄦ浜у搧鍒ゆ柇
- boolean containsFlg = false;
- for (Consumable_order_details2__c cod2 : newdet2) {
- if (cod2.Bar_Code__c == reSet1[i].Bar_Code__c) {
- containsFlg = true;
- break;
- }
- }
- if (containsFlg == false) {
- String str = '璇ュ晢鍝佹槸' + reSet1[i].Arrive_Owner_Work_Location__c + '鐨勫簱瀛�';
- if (reSet1[i].Dealer_Info_text__c != accountName) {
- str = '璇ュ晢鍝佸湪鍏朵粬缁忛攢鍟嗗簱瀛�';
- }
- consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
- errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
- }
- }
- }
- }
-
- reSet1 = [
- SELECT
- Id,
- Name,
- Product_Pattern__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Deliver_date__c,
- Bar_Code__c,
- Arrive_date__c,
- Send_Date__c,
- Consumable_order_minor__r.Name,
- Consumable_order_minor__c,
- recordtypeid,
- Consumable_order_minor__r.Arrive_Order__c,
- Box_Piece__c,
- hospitalSpecialOffer__c
- FROM Consumable_order_details2__c
- WHERE
- Dealer_Saled__c = TRUE
- AND Box_Piece__c = '鐩�'
- AND Dealer_Info_text__c = :accountName
- AND Dealer_Returned__c = FALSE
- 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) || existIdMap.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,
- Product_Pattern__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Deliver_date__c,
- Bar_Code__c,
- Arrive_date__c,
- Send_Date__c,
- Consumable_order_minor__r.Name,
- Consumable_order_minor__c,
- recordtypeid,
- Consumable_order_minor__r.Arrive_Order__c,
- Box_Piece__c,
- hospitalSpecialOffer__c
- FROM Consumable_order_details2__c
- WHERE
- Dealer_Shipment__c = TRUE
- AND Box_Piece__c = '鐩�'
- AND Dealer_Info_text__c = :accountName
- AND Dealer_Returned__c = FALSE
- 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) || existIdMap.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,
- Product_Pattern__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Deliver_date__c,
- Bar_Code__c,
- Arrive_date__c,
- Send_Date__c,
- Consumable_order_minor__r.Name,
- Consumable_order_minor__c,
- recordtypeid,
- Consumable_order_minor__r.Arrive_Order__c,
- Box_Piece__c,
- hospitalSpecialOffer__c
- FROM Consumable_order_details2__c
- WHERE
- Lose_Flag__c = TRUE
- AND Box_Piece__c = '鐩�'
- 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) || existIdMap.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);
- }
- }
- }
- reSet = [
- SELECT
- Id,
- Name,
- recordtypeid,
- Used_account__c,
- Product_Pattern__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Deliver_date__c,
- Bar_Code__c,
- Arrive_date__c,
- Send_Date__c,
- Consumable_order_minor__r.Name,
- Consumable_order_minor__c,
- Consumable_order_minor__r.Arrive_Order__c,
- Intra_Trade_List_RMB__c,
- Asset_Model_No__c,
- Isoverdue__c,
- Box_Piece__c,
- ProductPacking_list_manual__c,
- Guarantee_period_for_products__c,
- TracingCode__c,
- Transfer_Time__c,
- Frist_Transfer_Agency__c,
- hospitalSpecialOffer__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 Bar_Code__c != NULL
- AND Dealer_Info_text__c = :accountName
- AND Bar_Code__c IN :barCodeListP
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- ORDER BY RemoveBox_No__c DESC
- ];
- //瀵瑰簲褰曞叆barcode鏁伴噺鐨勬绱㈢粨鏋�
- newdet2 = new List<Consumable_order_details2__c>();
- for (String barcode : barCodeListP) {
- Integer idx = 0;
- for (Consumable_order_details2__c cod2 : reSet) {
- if (cod2.Bar_Code__c == barcode) {
- newdet2.add(cod2);
- reSet.remove(idx);
- break;
- }
- idx++;
- }
- }
- Map<String, String> checkBarcodeResult = new Map<String, String>();
- for (Integer i = 0; i < orderdetails.size(); i++) {
- Integer a = 0;
- for (Integer j = 0; j < newdet2.size(); j++) {
- if (newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c && a < orderdetails[i].Shipment_Count__c) {
- if (
- (existIdMap.containsKey(newdet2[j].Bar_Code__c) && newdet2[j].Bar_Code__c == '鐩�') ||
- errorIdMap.containsKey(newdet2[j].Bar_Code__c)
- ) {
- // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
- continue;
- } else if (newdet2[j].Isoverdue__c == 0) {
- String str = '璇ュ晢鍝佸凡缁忚秴鍑哄噺鑿屾湁鏁堟湡鐨勬湁鏁堣寖鍥�';
- consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
- errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
- } else if (newdet2[j].Box_Piece__c != orderdetails[i].Box_Piece__c) {
- String str = '璇ュ晢鍝佸嚭璐у崟浣嶉敊璇�';
- consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
- errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
- } else if (!checkBarcodeResult.containsKey(newdet2[j].Bar_Code__c)) {
- Matcher n = Pattern.compile('[0-9]').matcher(newdet2[j].TracingCode__c);
- if (n.find()) {
- if (newdet2[j].TracingCode__c.length() == 5) {
- String tr = newdet2[j].TracingCode__c;
- String Ctr = tr.substring(tr.length() - 3,tr.length());
- String Btr = tr.substring(tr.length() - 4,tr.length()-3);
- String Atr = tr.substring(tr.length() - 5,tr.length()-4);
- if (Pattern.compile('[0-9]').matcher(Atr).find() || Pattern.compile('[0-9]').matcher(Ctr).find()) {
- String str = '绠$悊缂栫爜鏈夎锛岃妫�鏌ユ潯褰㈢爜鏁版嵁銆�';
- consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j],str));
- errorIdMap.put(newdet2[j].Bar_Code__c,newdet2[j].Bar_Code__c);
- continue;
- }
- }
- // String str = '绠$悊缂栫爜涓湁鏁板瓧锛岃涓庣鐞嗗憳纭鏄惁閿欒銆�';
- // consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
- // errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
- // continue;
- }
- checkBarcodeResult.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
- consumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(newdet2[j]));
- a++;
- existIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
- }
- } else if (newdet2[j].Product_Pattern__c == orderdetails[i].Product_Pattern__c) {
- if (a >= orderdetails[i].Shipment_Count__c && orderdetails[i].Box_Piece__c == '涓�') {
- // 璺宠繃瓒呰繃鏁伴噺鐨勬秷鑰楀搧鏄庣粏
- continue;
- } else if (errorIdMap.containsKey(newdet2[j].Bar_Code__c)) {
- // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
- continue;
- } else {
- //CHAN-C23BWX update by rentx 2021-04-28 start
- // String str = '璇ュ晢鍝佽秴鍑鸿璐ф暟閲�';
- String str = '璇ヤ骇鍝佽秴鍑哄嚭搴撳崟浜у搧鑼冨洿';
- //CHAN-C23BWX update by rentx 2021-04-28 end
- consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(newdet2[j], str));
- errorIdMap.put(newdet2[j].Bar_Code__c, newdet2[j].Bar_Code__c);
- }
- }
- }
- }
-
- reSet1 = [
- SELECT
- Id,
- Name,
- Product_Pattern__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Deliver_date__c,
- Bar_Code__c,
- Arrive_date__c,
- Send_Date__c,
- Consumable_order_minor__r.Name,
- Consumable_order_minor__c,
- recordtypeid,
- Consumable_order_minor__r.Arrive_Order__c,
- Box_Piece__c,
- hospitalSpecialOffer__c
- FROM Consumable_order_details2__c
- WHERE
- recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
- AND Bar_Code__c IN :barCodeListP
- AND Dealer_Arrive__c = FALSE
- AND Dealer_Shipment__c = FALSE
- AND Dealer_Saled__c = FALSE
- AND Lose_Flag__c = FALSE
- AND Bar_Code__c != NULL
- 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
- AND Cancellation_Flag__c = FALSE))
- ORDER BY Name
- ];
- if (reSet1.size() > 0) {
- for (Integer i = 0; i < reSet1.size(); i++) {
- if (errorIdMap.containsKey(reSet1[i].Bar_Code__c) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
- // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
- continue;
- } else {
- String str = '璇ュ晢鍝佹湭鍒拌揣纭';
- consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
- errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
- }
- }
- }
-
- allMap.putAll(errorIdMap);
- allMap.putAll(existIdMap);
- //寰楀埌涓嶅瓨鍦ㄧ殑BarCode
- for (Integer i = 0; i < barCodeListP.size(); i++) {
- if (allMap.containsKey(barCodeListP[i])) {
- continue;
- } else {
- exitlist.add(barCodeListP[i]);
- }
- }
- reSet1 = [
- SELECT
- Id,
- Name,
- Product_Pattern__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Deliver_date__c,
- Bar_Code__c,
- Arrive_date__c,
- Send_Date__c,
- Consumable_order_minor__r.Name,
- Consumable_order_minor__c,
- recordtypeid,
- Consumable_order_minor__r.Arrive_Order__c,
- Box_Piece__c,
- hospitalSpecialOffer__c
- FROM Consumable_order_details2__c
- WHERE (Dealer_Saled__c = TRUE OR Dealer_Shipment__c = TRUE) AND Dealer_Returned__c = FALSE AND Bar_Code__c IN :exitlist
- ORDER BY Name
- ];
- if (reSet1.size() > 0) {
- for (Integer i = 0; i < reSet1.size(); i++) {
- if (errorIdMap.containsKey(reSet1[i].Bar_Code__c) || existIdMap.containsKey(reSet1[i].Bar_Code__c)) {
- // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
- continue;
- } else {
- String str = '璇ュ晢鍝佸凡缁忓嚭璐�';
- consumableorderdetailsRecordserror.add(new ConsumableorderdetailsInfo(reSet1[i], str));
- errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
- }
- }
- }
- allMap.putAll(errorIdMap);
- for (Integer i = 0; i < barCodeListP.size(); i++) {
- if (allMap.containsKey(barCodeListP[i])) {
- continue;
- } else {
- notexitlist.add(barCodeListP[i]);
- }
- }
- if (notexitlist.size() > 0) {
- //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙�'+ notexitlist + '涓嶅瓨鍦ㄣ��'));
- return new ResponseBodyLWC('Error', 500, 'BarCode鍙�' + notexitlist + '涓嶅瓨鍦ㄣ��', '');
- }
- data.put('consumableorderdetailsRecords', consumableorderdetailsRecords);
- data.put('consumableorderdetailsRecordserror', consumableorderdetailsRecordserror);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ }
}
- // 鍘荤殑椤甸潰涓婄殑barcode锛岃浆鎹㈡垚List
- public static List<String> ParseBarCode(String Code) {
- String[] Cache = new List<String>{};
- Cache = Code.split('\n');
- List<String> Buff = new List<String>();
- for (String A : Cache) {
- A = A.trim();
- Buff.add(A.toUpperCase());
+ reSet1 = [
+ SELECT
+ Id,
+ Name,
+ Product_Pattern__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Bar_Code__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ recordtypeid,
+ Consumable_order_minor__r.Arrive_Order__c,
+ Box_Piece__c,
+ hospitalSpecialOffer__c
+ FROM Consumable_order_details2__c
+ WHERE
+ recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+ AND Bar_Code__c IN :barCodeListP
+ AND Dealer_Arrive__c = FALSE
+ AND Dealer_Shipment__c = FALSE
+ AND Dealer_Saled__c = FALSE
+ AND Lose_Flag__c = FALSE
+ AND Bar_Code__c != NULL
+ 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
+ AND Cancellation_Flag__c = FALSE))
+ ORDER BY Name
+ ];
+ if (reSet1.size() > 0) {
+ for (Integer i = 0; i < reSet1.size(); i++) {
+ if (
+ errorIdMap.containsKey(reSet1[i].Bar_Code__c) ||
+ existIdMap.containsKey(reSet1[i].Bar_Code__c)
+ ) {
+ // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+ continue;
+ } else {
+ String str = '璇ュ晢鍝佹湭鍒拌揣纭';
+ consumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(reSet1[i], str)
+ );
+ errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
}
- return Buff;
+ }
}
- // 鍑鸿揣
- @AuraEnabled
- public static ResponseBodyLWC ProdElivery(
- String ESetIdLwc,
- Consumable_order__c cocLwc,
- String barcodeLwc,
- String accountNameLwc,
- String userWorkLocationLwc,
- String consumableorderdetailsRecordsLwc,
- List<Consumable_orderdetails__c> orderdetailsLwc,
- Map<String, Decimal> orderpriceMapLwc,
- Map<String, Decimal> orderagencypriceMapLwc
- ) {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- ESetId = ESetIdLwc;
- coc = cocLwc;
- barcode = barcodeLwc;
- accountName = accountNameLwc;
- userWorkLocation = userWorkLocationLwc;
- consumableorderdetailsRecords = (List<ConsumableorderdetailsInfo>) JSON.deserialize(
- consumableorderdetailsRecordsLwc,
- List<ConsumableorderdetailsInfo>.class
+ allMap.putAll(errorIdMap);
+ allMap.putAll(existIdMap);
+ //寰楀埌涓嶅瓨鍦ㄧ殑BarCode
+ for (Integer i = 0; i < barCodeListP.size(); i++) {
+ if (allMap.containsKey(barCodeListP[i])) {
+ continue;
+ } else {
+ exitlist.add(barCodeListP[i]);
+ }
+ }
+ reSet1 = [
+ SELECT
+ Id,
+ Name,
+ Product_Pattern__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Bar_Code__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ recordtypeid,
+ Consumable_order_minor__r.Arrive_Order__c,
+ Box_Piece__c,
+ hospitalSpecialOffer__c
+ FROM Consumable_order_details2__c
+ WHERE
+ (Dealer_Saled__c = TRUE
+ OR Dealer_Shipment__c = TRUE)
+ AND Dealer_Returned__c = FALSE
+ AND Bar_Code__c IN :exitlist
+ ORDER BY Name
+ ];
+ if (reSet1.size() > 0) {
+ for (Integer i = 0; i < reSet1.size(); i++) {
+ if (
+ errorIdMap.containsKey(reSet1[i].Bar_Code__c) ||
+ existIdMap.containsKey(reSet1[i].Bar_Code__c)
+ ) {
+ // 璺宠繃宸茬粡澶勭悊鐨勬秷鑰楀搧鏄庣粏
+ continue;
+ } else {
+ String str = '璇ュ晢鍝佸凡缁忓嚭璐�';
+ consumableorderdetailsRecordserror.add(
+ new ConsumableorderdetailsInfo(reSet1[i], str)
+ );
+ errorIdMap.put(reSet1[i].Bar_Code__c, reSet1[i].Bar_Code__c);
+ }
+ }
+ }
+ allMap.putAll(errorIdMap);
+ for (Integer i = 0; i < barCodeListP.size(); i++) {
+ if (allMap.containsKey(barCodeListP[i])) {
+ continue;
+ } else {
+ notexitlist.add(barCodeListP[i]);
+ }
+ }
+ if (notexitlist.size() > 0) {
+ //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'BarCode鍙�'+ notexitlist + '涓嶅瓨鍦ㄣ��'));
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ 'BarCode鍙�' + notexitlist + '涓嶅瓨鍦ㄣ��',
+ ''
+ );
+ }
+ data.put('consumableorderdetailsRecords', consumableorderdetailsRecords);
+ data.put(
+ 'consumableorderdetailsRecordserror',
+ consumableorderdetailsRecordserror
+ );
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ // 鍘荤殑椤甸潰涓婄殑barcode锛岃浆鎹㈡垚List
+ public static List<String> ParseBarCode(String Code) {
+ String[] Cache = new List<String>{};
+ Cache = Code.split('\n');
+ List<String> Buff = new List<String>();
+ for (String A : Cache) {
+ A = A.trim();
+ Buff.add(A.toUpperCase());
+ }
+ return Buff;
+ }
+
+ // 鍑鸿揣
+ @AuraEnabled
+ public static ResponseBodyLWC ProdElivery(
+ String ESetIdLwc,
+ Consumable_order__c cocLwc,
+ String barcodeLwc,
+ String accountNameLwc,
+ String userWorkLocationLwc,
+ String consumableorderdetailsRecordsLwc,
+ List<Consumable_orderdetails__c> orderdetailsLwc,
+ Map<String, Decimal> orderpriceMapLwc,
+ Map<String, Decimal> orderagencypriceMapLwc
+ ) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ ESetId = ESetIdLwc;
+ coc = cocLwc;
+ barcode = barcodeLwc;
+ accountName = accountNameLwc;
+ userWorkLocation = userWorkLocationLwc;
+ consumableorderdetailsRecords = (List<ConsumableorderdetailsInfo>) JSON.deserialize(
+ consumableorderdetailsRecordsLwc,
+ List<ConsumableorderdetailsInfo>.class
+ );
+ orderdetails = orderdetailsLwc;
+ orderpriceMap = orderpriceMapLwc;
+ orderagencypriceMap = orderagencypriceMap;
+ BarcodeCntMap = new Map<String, Integer>();
+ if (coc.Arrive_Order__r.IsShipment__c == true) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '璁㈠崟宸茬粡鍑鸿揣'));
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璁㈠崟宸茬粡鍑鸿揣', '');
+ }
+
+ if (consumableorderdetailsRecords.size() < 1) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '鏃犲嚭璐ф槑缁�'));
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '鏃犲嚭璐ф槑缁�', '');
+ }
+
+ Getconsumableorderdetails2Nobox();
+
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ String key = '' + ass.orderdetails2.Bar_Code__c;
+ Integer deliverycnt = BarcodeCntMap.get(key);
+ if (
+ ass.orderdetails2.Box_Piece__c == '涓�' &&
+ (ass.outboundCount == null ||
+ String.valueof(ass.outboundCount) == '' ||
+ ass.outboundCount <= 0)
+ ) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '璇疯緭鍏ヤ骇鍝� '+ ass.Prod.Name +' 鐨勫嚭璐ф暟閲�'));
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '璇疯緭鍏ヤ骇鍝� ' + ass.Prod.Name + ' 鐨勫嚭璐ф暟閲�',
+ ''
);
- orderdetails = orderdetailsLwc;
- orderpriceMap = orderpriceMapLwc;
- orderagencypriceMap = orderagencypriceMap;
- BarcodeCntMap = new Map<String, Integer>();
- if (coc.Arrive_Order__r.IsShipment__c == true) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '璁㈠崟宸茬粡鍑鸿揣'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '璁㈠崟宸茬粡鍑鸿揣', '');
- }
-
- if (consumableorderdetailsRecords.size() < 1) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '鏃犲嚭璐ф槑缁�'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '鏃犲嚭璐ф槑缁�', '');
- }
-
- Getconsumableorderdetails2Nobox();
-
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
- String key = '' + ass.orderdetails2.Bar_Code__c;
- Integer deliverycnt = BarcodeCntMap.get(key);
- if (
- ass.orderdetails2.Box_Piece__c == '涓�' &&
- (ass.outboundCount == null ||
- String.valueof(ass.outboundCount) == '' ||
- ass.outboundCount <= 0)
- ) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '璇疯緭鍏ヤ骇鍝� '+ ass.Prod.Name +' 鐨勫嚭璐ф暟閲�'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ヤ骇鍝� ' + ass.Prod.Name + ' 鐨勫嚭璐ф暟閲�', '');
- }
- if (ass.outboundCount > deliverycnt) {
- // ass.orderdetails2.Rrturn_count__c.addError('瓒呭嚭鍑哄簱鏁伴噺');
- // return null;
- return new ResponseBodyLWC('Error', 500, ass.orderdetails2.Name + '瓒呭嚭鍑哄簱鏁伴噺', '');
- }
- }
-
- for (Integer i = 0; i < orderdetails.size(); i++) {
- Decimal a = 0;
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
- if (ass.orderdetails2.Product_Pattern__c == orderdetails[i].Product_Pattern__c) {
- a = a + ass.outboundCount;
- }
- }
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'鍟嗗搧'+a));
-
- if (a < orderdetails[i].Shipment_Count__c) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'鍟嗗搧'+orderdetails[i].Consumable_product__r.Name +'鏁伴噺灏忎簬鍑鸿揣鏁伴噺'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '鍟嗗搧' + orderdetails[i].Consumable_product__r.Name + '鏁伴噺灏忎簬鍑鸿揣鏁伴噺', '');
- } else if (a > orderdetails[i].Shipment_Count__c) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'鍟嗗搧'+orderdetails[i].Consumable_product__r.Name +'瓒呭嚭鍑鸿揣鏁伴噺'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '鍟嗗搧' + orderdetails[i].Consumable_product__r.Name + '瓒呭嚭鍑鸿揣鏁伴噺', '');
- }
- }
- List<Consumable_order_details2__c> Ins = new List<Consumable_order_details2__c>();
- Savepoint sp = Database.setSavepoint();
- List<Consumable_orderdetails__c> orderdetails1List = [
- SELECT Id, Used_date__c
- FROM Consumable_orderdetails__c
- WHERE Consumable_order__c = :ESetId
- ];
- try {
- if (orderdetails1List.size() > 0) {
- for (Integer i = 0; i < orderdetails1List.size(); i++) {
- orderdetails1List[i].RecordTypeId = System.Label.RT_ConOrderDetail1_Shipment;
- orderdetails1List[i].Used_date__c = Date.today();
- }
- ControllerUtil.updateOrderDetails1Satus(orderdetails1List);
- }
- //coc.Order_type__c = '鍑鸿揣';
- coc.RecordTypeId = System.Label.RT_ConOrder_Shipment;
- // update start by vivek 2019-7-15
- // coc.SummonsStatus_c__c = '宸插畬鎴�';
- if (coc.NoConfirmedPrice__c) {
- coc.SummonsStatus_c__c = '浠锋牸鏈畾';
- } else {
- coc.SummonsStatus_c__c = '宸插畬鎴�';
- }
- // update start by vivek 2019-7-15
- coc.Outbound_Date__c = Date.today();
- update coc;
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
- if (ass.orderdetails2.Box_Piece__c == '涓�') {
- Decimal cnt = 1;
- for (Consumable_order_details2__c codctmp : consumableorderdetails2Nobox) {
- Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
- if (codctmp.Bar_Code__c == ass.orderdetails2.Bar_Code__c) {
- insDetails.Id = codctmp.Id;
- insDetails.Consumable_Sale_order__c = null;
- insDetails.Consumable_Return_order__c = null;
- insDetails.Consumable_ZS_order__c = ESetId;
- insDetails.Delivery_List_RMB__c = orderpriceMap.get(ass.orderdetails2.Product_Pattern__c);
- insDetails.Return_date__c = null;
- insDetails.Return_reason__c = null;
- insDetails.Consumable_Shipment_order__c = ESetId;
- insDetails.Send_Date__c = Date.today();
- if (coc.SummonsForDirction__c == '浜掔浉璋冭揣') {
- insDetails.Transfer_Time__c = ass.orderdetails2.Transfer_Time__c == null
- ? 1
- : ass.orderdetails2.Transfer_Time__c + 1;
- insDetails.Frist_Transfer_Agency__c = ass.orderdetails2.Frist_Transfer_Agency__c == null
- ? coc.Dealer_Info__r.Name
- : ass.orderdetails2.Frist_Transfer_Agency__c;
- insDetails.Agency_Transfer__c = true;
- }
- cnt++;
- Ins.add(insDetails);
- if (cnt > ass.outboundCount)
- break;
- }
- }
- } else {
- Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
- insDetails.Id = ass.orderdetails2.Id;
- insDetails.Consumable_Sale_order__c = null;
- insDetails.Consumable_Return_order__c = null;
- insDetails.Consumable_ZS_order__c = ESetId;
- insDetails.Delivery_List_RMB__c = orderpriceMap.get(ass.orderdetails2.Product_Pattern__c);
- insDetails.Return_date__c = null;
- insDetails.Return_reason__c = null;
- insDetails.Consumable_Shipment_order__c = ESetId;
- insDetails.Send_Date__c = Date.today();
- if (coc.SummonsForDirction__c == '浜掔浉璋冭揣') {
- insDetails.Transfer_Time__c = ass.orderdetails2.Transfer_Time__c == null
- ? 1
- : ass.orderdetails2.Transfer_Time__c + 1;
- insDetails.Frist_Transfer_Agency__c = ass.orderdetails2.Frist_Transfer_Agency__c == null
- ? coc.Dealer_Info__r.Name
- : ass.orderdetails2.Frist_Transfer_Agency__c;
- insDetails.Agency_Transfer__c = true;
- }
- Ins.add(insDetails);
- }
- }
- if (Ins.size() > 0) {
- ControllerUtil.updateOrderDetailsSatus(Ins);
- }
- if (coc.Arrive_Order__c != null) {
- Consumable_order__c OrderUps = new Consumable_order__c();
- OrderUps.Id = coc.Arrive_Order__c;
- OrderUps.IsShipment__c = true;
- update OrderUps;
- }
- } catch (Exception ex) {
- Database.rollback(sp);
- return new ResponseBodyLWC('Error', 500, ex.getMessage(), '');
- }
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
- }
-
- // 閿�鍞�
- @AuraEnabled
- public static ResponseBodyLWC ProSale(
- String ESetIdLwc,
- Consumable_order__c cocLwc,
- String barcodeLwc,
- String accountNameLwc,
- String userWorkLocationLwc,
- String consumableorderdetailsRecordsLwc,
- List<Consumable_orderdetails__c> orderdetailsLwc,
- Map<String, Decimal> orderpriceMapLwc,
- Map<String, Decimal> orderagencypriceMapLwc
- ) {
- System.debug('enter ProSale');
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
-
- ESetId = ESetIdLwc;
- coc = cocLwc;
- barcode = barcodeLwc;
- accountName = accountNameLwc;
- userWorkLocation = userWorkLocationLwc;
- consumableorderdetailsRecords = (List<ConsumableorderdetailsInfo>) JSON.deserialize(
- consumableorderdetailsRecordsLwc,
- List<ConsumableorderdetailsInfo>.class
+ }
+ if (ass.outboundCount > deliverycnt) {
+ // ass.orderdetails2.Rrturn_count__c.addError('瓒呭嚭鍑哄簱鏁伴噺');
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ ass.orderdetails2.Name + '瓒呭嚭鍑哄簱鏁伴噺',
+ ''
);
- orderdetails = orderdetailsLwc;
- orderpriceMap = orderpriceMapLwc;
- orderagencypriceMap = orderagencypriceMapLwc;
- System.debug('ESetId = ' + ESetId);
- System.debug('coc = ' + coc);
- System.debug('barcode = ' + barcode);
- System.debug('accountName = ' + accountName);
- System.debug('userWorkLocation = ' + userWorkLocation);
- System.debug('consumableorderdetailsRecords = ' + consumableorderdetailsRecords);
- System.debug('orderdetails = ' + orderdetails);
- System.debug('orderpriceMap = ' + orderpriceMap);
- System.debug('orderagencypriceMap = ' + orderagencypriceMap);
- BarcodeCntMap = new Map<String, Integer>();
-
- if (consumableorderdetailsRecords.size() < 1) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '鏃犻攢鍞槑缁�'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '鏃犻攢鍞槑缁�', '');
- }
- if (coc.Arrive_Order__r.IsShipment__c == true) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '璁㈠崟宸茬粡閿�鍞�'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '璁㈠崟宸茬粡閿�鍞�', '');
- }
- Getconsumableorderdetails2Nobox();
-
- System.debug('BarcodeCntMap = ' + BarcodeCntMap);
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
- String key = '' + ass.orderdetails2.Bar_Code__c;
- Integer deliverycnt = BarcodeCntMap.get(key);
- if (ass.orderdetails2.Box_Piece__c == '涓�' &&(ass.outboundCount == null || String.valueof(ass.outboundCount) == '' || ass.outboundCount <= 0)) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '璇疯緭鍏ヤ骇鍝� '+ ass.Prod.Name +' 鐨勫嚭璐ф暟閲�'));
- // return null;
- System.debug('ass.orderdetails2.Box_Piece__c = ' + ass.orderdetails2.Box_Piece__c);
- System.debug('ass.outboundCount = ' + ass.outboundCount);
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ヤ骇鍝� ' + ass.Prod.Name + ' 鐨勫嚭璐ф暟閲�', '');
- }
- if (ass.outboundCount > deliverycnt) {
- // ass.orderdetails2.Rrturn_count__c.addError('瓒呭嚭鍑哄簱鏁伴噺');
- // return null;
- return new ResponseBodyLWC('Error', 500, ass.orderdetails2.Name + '瓒呭嚭鍑哄簱鏁伴噺', '');
- }
- }
-
- for (Integer i = 0; i < orderdetails.size(); i++) {
- Decimal a = 0;
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
- if (ass.orderdetails2.Product_Pattern__c == orderdetails[i].Product_Pattern__c) {
- a = a + ass.outboundCount;
- }
- }
- if (a < orderdetails[i].Shipment_Count__c) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'鍟嗗搧'+orderdetails[i].Consumable_product__r.Name +'鏁伴噺灏忎簬鍑鸿揣鏁伴噺'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '鍟嗗搧' + orderdetails[i].Consumable_product__r.Name + '鏁伴噺灏忎簬鍑鸿揣鏁伴噺', '');
- } else if (a > orderdetails[i].Shipment_Count__c) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'鍟嗗搧'+orderdetails[i].Consumable_product__r.Name +'瓒呭嚭鍑鸿揣鏁伴噺'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '鍟嗗搧' + orderdetails[i].Consumable_product__r.Name + '瓒呭嚭鍑鸿揣鏁伴噺', '');
- }
- }
-
- Savepoint sp = Database.setSavepoint();
- List<Consumable_orderdetails__c> orderdetails1List = [
- SELECT Id, Used_date__c
- FROM Consumable_orderdetails__c
- WHERE Consumable_order__c = :ESetId
- ];
- try {
- if (orderdetails1List.size() > 0) {
- for (Integer i = 0; i < orderdetails1List.size(); i++) {
- orderdetails1List[i].RecordTypeId = System.Label.RT_ConOrderDetail1_Sale;
- orderdetails1List[i].Used_date__c = Date.today();
- }
- ControllerUtil.updateOrderDetails1Satus(orderdetails1List);
- }
- //coc.Order_type__c = '閿�鍞�';
- coc.RecordTypeId = System.Label.RT_ConOrder_Sale;
- // update start by vivek 2019-7-15
- // coc.SummonsStatus_c__c = '宸插畬鎴�';
- if (coc.NoConfirmedPrice__c) {
- coc.SummonsStatus_c__c = '浠锋牸鏈畾';
- } else {
- coc.SummonsStatus_c__c = '宸插畬鎴�';
- }
- // update start by vivek 2019-7-15
- coc.Outbound_Date__c = Date.today();
- update coc;
- //閿�鍞槑缁�
- List<Consumable_order_details2__c> Ins = new List<Consumable_order_details2__c>();
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
- if (ass.orderdetails2.Box_Piece__c == '涓�') {
- Decimal cnt = 1;
- for (Consumable_order_details2__c codctmp : consumableorderdetails2Nobox) {
- Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
- if (codctmp.Bar_Code__c == ass.orderdetails2.Bar_Code__c) {
- insDetails.Id = codctmp.Id;
- insDetails.Consumable_Shipment_order__c = null;
- insDetails.Consumable_Return_order__c = null;
- insDetails.Consumable_ZS_order__c = ESetId;
- insDetails.Return_date__c = null;
- insDetails.Delivery_List_RMB__c = orderpriceMap.get(ass.orderdetails2.Product_Pattern__c);
- if (orderagencypriceMap.containsKey(ass.orderdetails2.Product_Pattern__c) == true) {
- insDetails.Unitprice_To_agency__c = orderagencypriceMap.get(ass.orderdetails2.Product_Pattern__c);
- }
- insDetails.Return_reason__c = null;
- insDetails.Used_date__c = Date.today();
- insDetails.Consumable_Sale_order__c = ESetId;
- cnt++;
- Ins.add(insDetails);
- if (cnt > ass.outboundCount)
- break;
- }
- }
- } else {
- Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
- insDetails.Id = ass.orderdetails2.Id;
- insDetails.Consumable_Shipment_order__c = null;
- insDetails.Consumable_Return_order__c = null;
- insDetails.Consumable_ZS_order__c = ESetId;
- insDetails.Return_date__c = null;
- insDetails.Delivery_List_RMB__c = orderpriceMap.get(ass.orderdetails2.Product_Pattern__c);
- if (orderagencypriceMap.containsKey(ass.orderdetails2.Product_Pattern__c) == true) {
- insDetails.Unitprice_To_agency__c = orderagencypriceMap.get(ass.orderdetails2.Product_Pattern__c);
- }
- insDetails.Return_reason__c = null;
- insDetails.Used_date__c = Date.today();
- insDetails.Consumable_Sale_order__c = ESetId;
- Ins.add(insDetails);
- }
- }
- //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'consumableorderdetails2Nobox +++'+consumableorderdetails2Nobox.size()));
- //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Ins +++'+Ins));
- //return null;
- if (Ins.size() > 0) {
- ControllerUtil.updateOrderDetailsSatus(Ins);
- }
- if (coc.Arrive_Order__c != null) {
- Consumable_order__c orderUps = new Consumable_order__c();
- orderUps.Id = coc.Arrive_Order__c;
- orderUps.IsShipment__c = true;
- update orderUps;
- }
- } catch (Exception e) {
- Database.rollback(sp);
- return new ResponseBodyLWC('Error', 500, e.getMessage() + e.getStackTraceString(), '');
- }
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ }
}
- public static integer Getconsumableorderdetails2Nobox() {
- if (String.isBlank(barcode)) {
- return 0;
+ for (Integer i = 0; i < orderdetails.size(); i++) {
+ Decimal a = 0;
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ if (
+ ass.orderdetails2.Product_Pattern__c ==
+ orderdetails[i].Product_Pattern__c
+ ) {
+ a = a + ass.outboundCount;
}
- List<String> barCodeListP = ParseBarCode(barcode);
- consumableorderdetails2Nobox = new List<Consumable_order_details2__c>();
- BarcodeCntMap.clear();
- consumableorderdetails2Nobox = [
- SELECT
- Id,
- Name,
- recordtypeid,
- Used_account__c,
- Product_Pattern__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Deliver_date__c,
- Bar_Code__c,
- Arrive_date__c,
- Send_Date__c,
- Consumable_order_minor__r.Name,
- Consumable_order_minor__c,
- Intra_Trade_List_RMB__c,
- Asset_Model_No__c,
- Isoverdue__c,
- Box_Piece__c,
- ProductPacking_list_manual__c,
- Guarantee_period_for_products__c,
- hospitalSpecialOffer__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 Bar_Code__c != NULL
- AND Dealer_Info_text__c = :accountName
- AND Bar_Code__c IN :barCodeListP
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- AND Box_Piece__c = '涓�'
- ORDER BY RemoveBox_No__c DESC
- ];
+ }
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'鍟嗗搧'+a));
- AggregateResult[] results = [
- SELECT Bar_Code__c, count(Id) recordCount
- 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 Bar_Code__c != NULL
- AND Dealer_Info_text__c = :accountName
- AND Bar_Code__c IN :barCodeListP
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- AND Box_Piece__c = '涓�'
- GROUP BY Bar_Code__c
- ];
-
- for (AggregateResult ar : results) {
- String key = '' + ar.get('Bar_Code__c');
- BarcodeCntMap.put(key, Integer.valueOf(ar.get('recordCount')));
- }
- return consumableorderdetails2Nobox.size();
+ if (a < orderdetails[i].Shipment_Count__c) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'鍟嗗搧'+orderdetails[i].Consumable_product__r.Name +'鏁伴噺灏忎簬鍑鸿揣鏁伴噺'));
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '鍟嗗搧' +
+ orderdetails[i].Consumable_product__r.Name +
+ '鏁伴噺灏忎簬鍑鸿揣鏁伴噺',
+ ''
+ );
+ } else if (a > orderdetails[i].Shipment_Count__c) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'鍟嗗搧'+orderdetails[i].Consumable_product__r.Name +'瓒呭嚭鍑鸿揣鏁伴噺'));
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '鍟嗗搧' + orderdetails[i].Consumable_product__r.Name + '瓒呭嚭鍑鸿揣鏁伴噺',
+ ''
+ );
+ }
}
-
- class ConsumableorderdetailsInfo implements Comparable {
- @AuraEnabled
- public Consumable_orderdetails__c orderdetails1 { get; set; }
- @AuraEnabled
- public Consumable_order_details2__c orderdetails2 { get; set; }
- @AuraEnabled
- public Product2__c Prod { get; set; }
- @AuraEnabled
- public String oldConsumableCount { get; set; }
- @AuraEnabled
- public String ErrorReason { get; set; }
- @AuraEnabled
- public Decimal outboundCount { get; set; }
-
- public ConsumableorderdetailsInfo(Consumable_order_details2__c e, string str) {
- orderdetails1 = new Consumable_orderdetails__c();
- orderdetails2 = e;
- Prod = e.Consumable_Product__r;
- oldConsumableCount = e.name;
- ErrorReason = str;
+ List<Consumable_order_details2__c> Ins = new List<Consumable_order_details2__c>();
+ Savepoint sp = Database.setSavepoint();
+ List<Consumable_orderdetails__c> orderdetails1List = [
+ SELECT Id, Used_date__c
+ FROM Consumable_orderdetails__c
+ WHERE Consumable_order__c = :ESetId
+ ];
+ try {
+ if (orderdetails1List.size() > 0) {
+ for (Integer i = 0; i < orderdetails1List.size(); i++) {
+ orderdetails1List[i]
+ .RecordTypeId = System.Label.RT_ConOrderDetail1_Shipment;
+ orderdetails1List[i].Used_date__c = Date.today();
}
-
- public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
- orderdetails1 = new Consumable_orderdetails__c();
- orderdetails2 = e;
- Prod = e.Consumable_Product__r;
- if (e.Box_Piece__c == '鐩�') {
- outboundCount = 1;
+ ControllerUtil.updateOrderDetails1Satus(orderdetails1List);
+ }
+ //coc.Order_type__c = '鍑鸿揣';
+ coc.RecordTypeId = System.Label.RT_ConOrder_Shipment;
+ // update start by vivek 2019-7-15
+ // coc.SummonsStatus_c__c = '宸插畬鎴�';
+ if (coc.NoConfirmedPrice__c) {
+ coc.SummonsStatus_c__c = '浠锋牸鏈畾';
+ } else {
+ coc.SummonsStatus_c__c = '宸插畬鎴�';
+ }
+ // update start by vivek 2019-7-15
+ coc.Outbound_Date__c = Date.today();
+ update coc;
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ if (ass.orderdetails2.Box_Piece__c == '涓�') {
+ Decimal cnt = 1;
+ for (
+ Consumable_order_details2__c codctmp : consumableorderdetails2Nobox
+ ) {
+ Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
+ if (codctmp.Bar_Code__c == ass.orderdetails2.Bar_Code__c) {
+ insDetails.Id = codctmp.Id;
+ insDetails.Consumable_Sale_order__c = null;
+ insDetails.Consumable_Return_order__c = null;
+ insDetails.Consumable_ZS_order__c = ESetId;
+ insDetails.Delivery_List_RMB__c = orderpriceMap.get(
+ ass.orderdetails2.Product_Pattern__c
+ );
+ insDetails.Return_date__c = null;
+ insDetails.Return_reason__c = null;
+ insDetails.Consumable_Shipment_order__c = ESetId;
+ insDetails.Send_Date__c = Date.today();
+ if (coc.SummonsForDirction__c == '浜掔浉璋冭揣') {
+ insDetails.Transfer_Time__c = ass.orderdetails2.Transfer_Time__c ==
+ null
+ ? 1
+ : ass.orderdetails2.Transfer_Time__c + 1;
+ insDetails.Frist_Transfer_Agency__c = ass.orderdetails2.Frist_Transfer_Agency__c ==
+ null
+ ? coc.Dealer_Info__r.Name
+ : ass.orderdetails2.Frist_Transfer_Agency__c;
+ insDetails.Agency_Transfer__c = true;
+ }
+ cnt++;
+ Ins.add(insDetails);
+ if (cnt > ass.outboundCount)
+ break;
}
- oldConsumableCount = e.name;
+ }
+ } else {
+ Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
+ insDetails.Id = ass.orderdetails2.Id;
+ insDetails.Consumable_Sale_order__c = null;
+ insDetails.Consumable_Return_order__c = null;
+ insDetails.Consumable_ZS_order__c = ESetId;
+ insDetails.Delivery_List_RMB__c = orderpriceMap.get(
+ ass.orderdetails2.Product_Pattern__c
+ );
+ insDetails.Return_date__c = null;
+ insDetails.Return_reason__c = null;
+ insDetails.Consumable_Shipment_order__c = ESetId;
+ insDetails.Send_Date__c = Date.today();
+ if (coc.SummonsForDirction__c == '浜掔浉璋冭揣') {
+ insDetails.Transfer_Time__c = ass.orderdetails2.Transfer_Time__c ==
+ null
+ ? 1
+ : ass.orderdetails2.Transfer_Time__c + 1;
+ insDetails.Frist_Transfer_Agency__c = ass.orderdetails2.Frist_Transfer_Agency__c ==
+ null
+ ? coc.Dealer_Info__r.Name
+ : ass.orderdetails2.Frist_Transfer_Agency__c;
+ insDetails.Agency_Transfer__c = true;
+ }
+ Ins.add(insDetails);
}
-
- public ConsumableorderdetailsInfo(Consumable_orderdetails__c e) {
- orderdetails1 = e;
- Prod = e.Consumable_Product__r;
- outboundCount = e.Shipment_Count__c;
- }
- // 鎺掑簭
- public Integer compareTo(Object compareTo) {
- return null;
- }
+ }
+ if (Ins.size() > 0) {
+ ControllerUtil.updateOrderDetailsSatus(Ins);
+ }
+ if (coc.Arrive_Order__c != null) {
+ Consumable_order__c OrderUps = new Consumable_order__c();
+ OrderUps.Id = coc.Arrive_Order__c;
+ OrderUps.IsShipment__c = true;
+ update OrderUps;
+ }
+ } catch (Exception ex) {
+ Database.rollback(sp);
+ return new ResponseBodyLWC('Error', 500, ex.getMessage(), '');
}
-}
\ No newline at end of file
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ // 閿�鍞�
+ @AuraEnabled
+ public static ResponseBodyLWC ProSale(
+ String ESetIdLwc,
+ Consumable_order__c cocLwc,
+ String barcodeLwc,
+ String accountNameLwc,
+ String userWorkLocationLwc,
+ String consumableorderdetailsRecordsLwc,
+ List<Consumable_orderdetails__c> orderdetailsLwc,
+ Map<String, Decimal> orderpriceMapLwc,
+ Map<String, Decimal> orderagencypriceMapLwc
+ ) {
+ System.debug('enter ProSale');
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ ESetId = ESetIdLwc;
+ coc = cocLwc;
+ barcode = barcodeLwc;
+ accountName = accountNameLwc;
+ userWorkLocation = userWorkLocationLwc;
+ consumableorderdetailsRecords = (List<ConsumableorderdetailsInfo>) JSON.deserialize(
+ consumableorderdetailsRecordsLwc,
+ List<ConsumableorderdetailsInfo>.class
+ );
+ orderdetails = orderdetailsLwc;
+ orderpriceMap = orderpriceMapLwc;
+ orderagencypriceMap = orderagencypriceMapLwc;
+ System.debug('ESetId = ' + ESetId);
+ System.debug('coc = ' + coc);
+ System.debug('barcode = ' + barcode);
+ System.debug('accountName = ' + accountName);
+ System.debug('userWorkLocation = ' + userWorkLocation);
+ System.debug(
+ 'consumableorderdetailsRecords = ' + consumableorderdetailsRecords
+ );
+ System.debug('orderdetails = ' + orderdetails);
+ System.debug('orderpriceMap = ' + orderpriceMap);
+ System.debug('orderagencypriceMap = ' + orderagencypriceMap);
+ BarcodeCntMap = new Map<String, Integer>();
+
+ if (consumableorderdetailsRecords.size() < 1) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '鏃犻攢鍞槑缁�'));
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '鏃犻攢鍞槑缁�', '');
+ }
+ if (coc.Arrive_Order__r.IsShipment__c == true) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '璁㈠崟宸茬粡閿�鍞�'));
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璁㈠崟宸茬粡閿�鍞�', '');
+ }
+ Getconsumableorderdetails2Nobox();
+
+ System.debug('BarcodeCntMap = ' + BarcodeCntMap);
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ String key = '' + ass.orderdetails2.Bar_Code__c;
+ Integer deliverycnt = BarcodeCntMap.get(key);
+ if (
+ ass.orderdetails2.Box_Piece__c == '涓�' &&
+ (ass.outboundCount == null ||
+ String.valueof(ass.outboundCount) == '' ||
+ ass.outboundCount <= 0)
+ ) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '璇疯緭鍏ヤ骇鍝� '+ ass.Prod.Name +' 鐨勫嚭璐ф暟閲�'));
+ // return null;
+ System.debug(
+ 'ass.orderdetails2.Box_Piece__c = ' + ass.orderdetails2.Box_Piece__c
+ );
+ System.debug('ass.outboundCount = ' + ass.outboundCount);
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '璇疯緭鍏ヤ骇鍝� ' + ass.Prod.Name + ' 鐨勫嚭璐ф暟閲�',
+ ''
+ );
+ }
+ if (ass.outboundCount > deliverycnt) {
+ // ass.orderdetails2.Rrturn_count__c.addError('瓒呭嚭鍑哄簱鏁伴噺');
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ ass.orderdetails2.Name + '瓒呭嚭鍑哄簱鏁伴噺',
+ ''
+ );
+ }
+ }
+
+ for (Integer i = 0; i < orderdetails.size(); i++) {
+ Decimal a = 0;
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ if (
+ ass.orderdetails2.Product_Pattern__c ==
+ orderdetails[i].Product_Pattern__c
+ ) {
+ a = a + ass.outboundCount;
+ }
+ }
+ if (a < orderdetails[i].Shipment_Count__c) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'鍟嗗搧'+orderdetails[i].Consumable_product__r.Name +'鏁伴噺灏忎簬鍑鸿揣鏁伴噺'));
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '鍟嗗搧' +
+ orderdetails[i].Consumable_product__r.Name +
+ '鏁伴噺灏忎簬鍑鸿揣鏁伴噺',
+ ''
+ );
+ } else if (a > orderdetails[i].Shipment_Count__c) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'鍟嗗搧'+orderdetails[i].Consumable_product__r.Name +'瓒呭嚭鍑鸿揣鏁伴噺'));
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '鍟嗗搧' + orderdetails[i].Consumable_product__r.Name + '瓒呭嚭鍑鸿揣鏁伴噺',
+ ''
+ );
+ }
+ }
+
+ Savepoint sp = Database.setSavepoint();
+ List<Consumable_orderdetails__c> orderdetails1List = [
+ SELECT Id, Used_date__c
+ FROM Consumable_orderdetails__c
+ WHERE Consumable_order__c = :ESetId
+ ];
+ try {
+ if (orderdetails1List.size() > 0) {
+ for (Integer i = 0; i < orderdetails1List.size(); i++) {
+ orderdetails1List[i]
+ .RecordTypeId = System.Label.RT_ConOrderDetail1_Sale;
+ orderdetails1List[i].Used_date__c = Date.today();
+ }
+ ControllerUtil.updateOrderDetails1Satus(orderdetails1List);
+ }
+ //coc.Order_type__c = '閿�鍞�';
+ coc.RecordTypeId = System.Label.RT_ConOrder_Sale;
+ // update start by vivek 2019-7-15
+ // coc.SummonsStatus_c__c = '宸插畬鎴�';
+ if (coc.NoConfirmedPrice__c) {
+ coc.SummonsStatus_c__c = '浠锋牸鏈畾';
+ } else {
+ coc.SummonsStatus_c__c = '宸插畬鎴�';
+ }
+ // update start by vivek 2019-7-15
+ coc.Outbound_Date__c = Date.today();
+ update coc;
+ //閿�鍞槑缁�
+ List<Consumable_order_details2__c> Ins = new List<Consumable_order_details2__c>();
+ for (ConsumableorderdetailsInfo ass : consumableorderdetailsRecords) {
+ if (ass.orderdetails2.Box_Piece__c == '涓�') {
+ Decimal cnt = 1;
+ for (
+ Consumable_order_details2__c codctmp : consumableorderdetails2Nobox
+ ) {
+ Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
+ if (codctmp.Bar_Code__c == ass.orderdetails2.Bar_Code__c) {
+ insDetails.Id = codctmp.Id;
+ insDetails.Consumable_Shipment_order__c = null;
+ insDetails.Consumable_Return_order__c = null;
+ insDetails.Consumable_ZS_order__c = ESetId;
+ insDetails.Return_date__c = null;
+ insDetails.Delivery_List_RMB__c = orderpriceMap.get(
+ ass.orderdetails2.Product_Pattern__c
+ );
+ if (
+ orderagencypriceMap.containsKey(
+ ass.orderdetails2.Product_Pattern__c
+ ) == true
+ ) {
+ insDetails.Unitprice_To_agency__c = orderagencypriceMap.get(
+ ass.orderdetails2.Product_Pattern__c
+ );
+ }
+ insDetails.Return_reason__c = null;
+ insDetails.Used_date__c = Date.today();
+ insDetails.Consumable_Sale_order__c = ESetId;
+ cnt++;
+ Ins.add(insDetails);
+ if (cnt > ass.outboundCount)
+ break;
+ }
+ }
+ } else {
+ Consumable_order_details2__c insDetails = new Consumable_order_details2__c();
+ insDetails.Id = ass.orderdetails2.Id;
+ insDetails.Consumable_Shipment_order__c = null;
+ insDetails.Consumable_Return_order__c = null;
+ insDetails.Consumable_ZS_order__c = ESetId;
+ insDetails.Return_date__c = null;
+ insDetails.Delivery_List_RMB__c = orderpriceMap.get(
+ ass.orderdetails2.Product_Pattern__c
+ );
+ if (
+ orderagencypriceMap.containsKey(
+ ass.orderdetails2.Product_Pattern__c
+ ) == true
+ ) {
+ insDetails.Unitprice_To_agency__c = orderagencypriceMap.get(
+ ass.orderdetails2.Product_Pattern__c
+ );
+ }
+ insDetails.Return_reason__c = null;
+ insDetails.Used_date__c = Date.today();
+ insDetails.Consumable_Sale_order__c = ESetId;
+ Ins.add(insDetails);
+ }
+ }
+ //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'consumableorderdetails2Nobox +++'+consumableorderdetails2Nobox.size()));
+ //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Ins +++'+Ins));
+ //return null;
+ if (Ins.size() > 0) {
+ ControllerUtil.updateOrderDetailsSatus(Ins);
+ }
+ if (coc.Arrive_Order__c != null) {
+ Consumable_order__c orderUps = new Consumable_order__c();
+ orderUps.Id = coc.Arrive_Order__c;
+ orderUps.IsShipment__c = true;
+ update orderUps;
+ }
+ } catch (Exception e) {
+ Database.rollback(sp);
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ e.getMessage() + e.getStackTraceString(),
+ ''
+ );
+ }
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ public static integer Getconsumableorderdetails2Nobox() {
+ if (String.isBlank(barcode)) {
+ return 0;
+ }
+ List<String> barCodeListP = ParseBarCode(barcode);
+ consumableorderdetails2Nobox = new List<Consumable_order_details2__c>();
+ BarcodeCntMap.clear();
+ consumableorderdetails2Nobox = [
+ SELECT
+ Id,
+ Name,
+ recordtypeid,
+ Used_account__c,
+ Product_Pattern__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Deliver_date__c,
+ Bar_Code__c,
+ Arrive_date__c,
+ Send_Date__c,
+ Consumable_order_minor__r.Name,
+ Consumable_order_minor__c,
+ Intra_Trade_List_RMB__c,
+ Asset_Model_No__c,
+ Isoverdue__c,
+ Box_Piece__c,
+ ProductPacking_list_manual__c,
+ Guarantee_period_for_products__c,
+ hospitalSpecialOffer__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 Bar_Code__c != NULL
+ AND Dealer_Info_text__c = :accountName
+ AND Bar_Code__c IN :barCodeListP
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Box_Piece__c = '涓�'
+ ORDER BY RemoveBox_No__c DESC
+ ];
+
+ AggregateResult[] results = [
+ SELECT Bar_Code__c, count(Id) recordCount
+ 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 Bar_Code__c != NULL
+ AND Dealer_Info_text__c = :accountName
+ AND Bar_Code__c IN :barCodeListP
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Box_Piece__c = '涓�'
+ GROUP BY Bar_Code__c
+ ];
+
+ for (AggregateResult ar : results) {
+ String key = '' + ar.get('Bar_Code__c');
+ BarcodeCntMap.put(key, Integer.valueOf(ar.get('recordCount')));
+ }
+ return consumableorderdetails2Nobox.size();
+ }
+
+ @TestVisible
+ class ConsumableorderdetailsInfo implements Comparable {
+ @AuraEnabled
+ public Consumable_orderdetails__c orderdetails1 { get; set; }
+ @AuraEnabled
+ public Consumable_order_details2__c orderdetails2 { get; set; }
+ @AuraEnabled
+ public Product2__c Prod { get; set; }
+ @AuraEnabled
+ public String oldConsumableCount { get; set; }
+ @AuraEnabled
+ public String ErrorReason { get; set; }
+ @AuraEnabled
+ public Decimal outboundCount { get; set; }
+
+ public ConsumableorderdetailsInfo(
+ Consumable_order_details2__c e,
+ string str
+ ) {
+ orderdetails1 = new Consumable_orderdetails__c();
+ orderdetails2 = e;
+ Prod = e.Consumable_Product__r;
+ oldConsumableCount = e.name;
+ ErrorReason = str;
+ }
+
+ public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
+ orderdetails1 = new Consumable_orderdetails__c();
+ orderdetails2 = e;
+ Prod = e.Consumable_Product__r;
+ if (e.Box_Piece__c == '鐩�') {
+ outboundCount = 1;
+ }
+ oldConsumableCount = e.name;
+ }
+
+ public ConsumableorderdetailsInfo(Consumable_orderdetails__c e) {
+ orderdetails1 = e;
+ Prod = e.Consumable_Product__r;
+ outboundCount = e.Shipment_Count__c;
+ }
+ // 鎺掑簭
+ public Integer compareTo(Object compareTo) {
+ return null;
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexSaleOrderControllerTest.cls b/force-app/main/default/classes/LexSaleOrderControllerTest.cls
new file mode 100644
index 0000000..590f4c6
--- /dev/null
+++ b/force-app/main/default/classes/LexSaleOrderControllerTest.cls
@@ -0,0 +1,1919 @@
+@isTest
+private class LexSaleOrderControllerTest {
+ public static Map<String, String> orderpieceorboxMap;
+ public static Map<String, Decimal> orderpriceMap;
+ public static Map<String, Decimal> orderagencypriceMap;
+ public static Map<String, Decimal> orderdetCountMap;
+ public static Map<String, String> existIdMap;
+ public static Map<String, String> errorIdMap;
+ public static Map<String, String> allMap;
+ @isTest
+ static void testInit() {
+ Account accountItem1;
+ Account accountItem2;
+ User userTest;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ List<RecordType> rectHp = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectHp.size() == 0) {
+ return;
+ }
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ accountItem1 = new Account(
+ Name = 'Testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert accountItem1;
+ accountItem2 = new Account(
+ Name = 'Testaccount002',
+ RecordTypeId = rectHp[0].Id,
+ AgentCode_Ext__c = '9999999'
+ );
+ insert accountItem2;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountId = accountItem1.Id
+ );
+ insert core;
+ userTest = 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 = 'ENG',
+ Work_Location__c = '澶ц繛'
+ );
+ insert userTest;
+ }
+ System.runAs(userTest) {
+ String Id = UserInfo.getUserId();
+ User thisUserInfo = [
+ SELECT accountid, ContactId, Contact.AccountId, Work_Location__c
+ FROM User
+ WHERE id = :Id
+ ];
+ String accountId = thisUserInfo.Contact.AccountId;
+ String userWorkLocation = thisUserInfo.Work_Location__c;
+ String accountName;
+ Account[] accountInfo = [
+ SELECT Name
+ FROM account
+ WHERE id = :accountId
+ LIMIT 1
+ ];
+ if (accountInfo.size() > 0) {
+ accountName = accountInfo[0].Name;
+ }
+
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 12,
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 12,
+ 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.Deliver_date__c = Date.today();
+ Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
+ Order1.Order_ForDealerText__c = 'Test';
+ Order1.Order_ProType__c = 'ENG';
+ Order1.Delivery_detail_count__c = 5;
+ Order1.IsShipment__c = true;
+ insert Order1;
+ //鍒拌揣
+ Consumable_order__c Order2 = new Consumable_order__c();
+ Order2.Name = 'testMing2';
+ Order2.Order_status__c = '鎵瑰噯';
+ Order2.Deliver_date__c = Date.today();
+ Order2.RecordTypeid = System.Label.RT_ConOrder_Arrive;
+ Order2.Order_type__c = '璁㈠崟';
+ Order2.Order_ProType__c = 'ENG';
+ Order2.Arrive_Order__c = Order1.Id;
+ Order2.Delivery_detail_count__c = 5;
+ insert Order2;
+
+ List<Consumable_order_details2__c> newdet2 = new List<Consumable_order_details2__c>();
+ //鍦ㄥ簱 鐩�
+ Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+ Orderdet1.Name = 'OCM_01_001002';
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet1.Bar_Code__c = '11111250AAAAA';
+ Orderdet1.Arrive_date__c = Date.today();
+ Orderdet1.Consumable_Product__c = pro1.Id;
+ Orderdet1.Box_Piece__c = '鐩�';
+ Orderdet1.TracingCode__c = 'AAAAA';
+ //鏈埌璐�
+ Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+ Orderdet2.Name = 'OCM_02_001002';
+ Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet2.Bar_Code__c = '22222250BBBBB';
+ Orderdet2.Consumable_Product__c = pro2.Id;
+ Orderdet2.Box_Piece__c = '鐩�';
+ Orderdet2.TracingCode__c = 'BBBBB';
+ //閿�鍞�
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+ Orderdet3.Name = 'OCM_01_001003';
+ Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet3.Bar_Code__c = '33333250CCCCC';
+ Orderdet3.Consumable_Product__c = pro1.Id;
+ Orderdet3.Used_date__c = Date.today();
+ Orderdet3.Send_Date__c = Date.today();
+ Orderdet3.Arrive_date__c = Date.today();
+ Orderdet3.Box_Piece__c = '鐩�';
+ Orderdet3.TracingCode__c = 'CCCCC';
+
+ //鍦ㄥ簱 涓�
+ Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+ Orderdet4.Name = 'OCM_01_001004';
+ Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet4.Bar_Code__c = '44444250DDDDD';
+ Orderdet4.Consumable_Product__c = pro1.Id;
+ Orderdet4.Arrive_date__c = Date.today();
+ Orderdet4.Box_Piece__c = '涓�';
+ Orderdet4.TracingCode__c = 'DDDDD';
+
+ Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+ Orderdet5.Name = 'OCM_01_001004';
+ Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet5.Bar_Code__c = '55555250EEEEE';
+ Orderdet5.Consumable_Product__c = pro1.Id;
+ Orderdet5.Arrive_date__c = Date.today();
+ Orderdet5.TracingCode__c = 'EEEEE';
+ insert new List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ Orderdet3,
+ Orderdet4,
+ Orderdet5
+ };
+
+ Consumable_order__c zsd01 = new Consumable_order__c();
+ zsd01.Name = 'ZSD_01_001';
+ zsd01.Order_type__c = '浼犵エ';
+ zsd01.SummonsStatus_c__c = '宸插畬鎴�';
+ zsd01.Order_type__c = '璁㈠崟';
+ zsd01.RecordTypeid = System.Label.RT_ConOrder_Order;
+ zsd01.Summons_Sale_Status__c = '閿�鍞�';
+ zsd01.Outbound_Date__c = Date.today();
+ zsd01.IsShipment__c = true;
+ insert zsd01;
+ System.debug('zsd01:' + zsd01.Id);
+
+ List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
+ Consumable_orderdetails__c Orderdet6 = new Consumable_orderdetails__c();
+ Orderdet6.Name = 'ZSD_01_001001';
+ Orderdet6.Consumable_order__c = zsd01.Id;
+ Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ Orderdet6.Consumable_Count__c = 12;
+ Orderdet6.Consumable_Product__c = pro1.Id;
+ Orderdet6.Delivery_List_RMB__c = 1;
+ Orderdet6.Shipment_Count__c = 1;
+ Orderdet6.Unitprice_To_agency__c = 1.00;
+ Orderdet6.Dealer_Custom_Price__c = 999.00;
+ Orderdet6.isOutPattern__c = true;
+ Orderdet6.Box_Piece__c = '涓�';
+ orderdetails.add(Orderdet6);
+ Consumable_orderdetails__c Orderdetc6 = new Consumable_orderdetails__c();
+ Orderdetc6.Name = 'ZSD_01_001001';
+ Orderdetc6.Consumable_order__c = zsd01.Id;
+ Orderdetc6.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ Orderdetc6.Consumable_Count__c = 12;
+ Orderdetc6.Consumable_Product__c = pro2.Id;
+ Orderdetc6.Delivery_List_RMB__c = 1;
+ Orderdetc6.Unitprice_To_agency__c = 1.00;
+ Orderdetc6.Dealer_Custom_Price__c = 999.00;
+ Orderdetc6.Shipment_Count__c = 1;
+ Orderdetc6.isOutPattern__c = true;
+ Orderdetc6.Box_Piece__c = '鐩�';
+ orderdetails.add(Orderdetc6);
+ insert orderdetails;
+ System.debug('orderdetails:' + orderdetails.size());
+
+ hospitalprice__c hp1 = new hospitalprice__c();
+ hp1.hospital__c = accountId;
+ hp1.account__c = accountId;
+ hp1.product__c = pro1.Id;
+ insert hp1;
+
+ orderpieceorboxMap = new Map<String, String>();
+ orderagencypriceMap = new Map<String, Decimal>();
+ orderpriceMap = new Map<String, Decimal>();
+ orderdetCountMap = new Map<String, Decimal>();
+ if (orderdetails.size() > 0) {
+ for (Integer i = 0; i < orderdetails.size(); i++) {
+ orderpieceorboxMap.put(
+ orderdetails[i].Product_Pattern__c,
+ orderdetails[i].Box_Piece__c
+ );
+ if (
+ orderdetails[i].Unitprice_To_agency__c != null &&
+ orderdetails[i].Unitprice_To_agency__c != 0
+ ) {
+ orderagencypriceMap.put(
+ orderdetails[i].Product_Pattern__c,
+ orderdetails[i].Unitprice_To_agency__c
+ );
+ }
+ orderpriceMap.put(
+ orderdetails[i].Product_Pattern__c,
+ orderdetails[i].Delivery_List_RMB__c
+ );
+ orderdetCountMap.put(
+ orderdetails[i].Product_Pattern__c,
+ orderdetails[i].Shipment_Count__c
+ );
+ }
+ }
+ String ESetId = Order2.Id;
+ System.Test.startTest();
+ LexSaleOrderController.GoodsDeliveryInit(ESetId);
+ String barcode1 = '';
+ String key = '';
+ String baseUrl = '';
+ Integer a = 0;
+ List<LexSaleOrderController.ConsumableorderdetailsInfo> consumableorderdetailsRecords = new List<LexSaleOrderController.ConsumableorderdetailsInfo>();
+ Map<String, Integer> msiMap = new Map<String, Integer>();
+ LexSaleOrderController.SearchPro(
+ Order1,
+ barcode1,
+ accountName,
+ userWorkLocation,
+ accountId,
+ orderdetails,
+ orderpieceorboxMap
+ );
+ String barcode = '11111250AAAAA\n22222250BBBBB\n33333250CCCCC\n44444250DDDDD\n55555250EEEEE\n666666\n777777\naaa';
+ LexSaleOrderController.ParseBarCode(barcode);
+ LexSaleOrderController.SearchPro(
+ Order2,
+ barcode,
+ accountName,
+ userWorkLocation,
+ accountId,
+ orderdetails,
+ orderpieceorboxMap
+ );
+ LexSaleOrderController.ProdElivery(
+ ESetId,
+ Order2,
+ barcode,
+ accountName,
+ userWorkLocation,
+ JSON.serialize(consumableorderdetailsRecords),
+ orderdetails,
+ orderpriceMap,
+ orderagencypriceMap
+ );
+ LexSaleOrderController.ProSale(
+ ESetId,
+ Order2,
+ barcode,
+ accountName,
+ userWorkLocation,
+ JSON.serialize(consumableorderdetailsRecords),
+ orderdetails,
+ orderpriceMap,
+ orderagencypriceMap
+ );
+ LexSaleOrderController.Getconsumableorderdetails2Nobox();
+
+ List<LexSaleOrderController.ConsumableorderdetailsInfo> inList = LexSaleOrderController.consumableorderdetailsRecords;
+ List<LexSaleOrderController.ConsumableorderdetailsInfo> inList1 = new List<LexSaleOrderController.ConsumableorderdetailsInfo>();
+ for (LexSaleOrderController.ConsumableorderdetailsInfo ass : inList) {
+ ass.orderdetails2 = Orderdet1;
+ inList1.add(ass);
+ }
+
+ String errorReason = 'success';
+ LexSaleOrderController.ConsumableorderdetailsInfo c2 = new LexSaleOrderController.ConsumableorderdetailsInfo(
+ Orderdet1,
+ errorReason
+ );
+ c2.orderdetails1 = null;
+ c2.orderdetails2 = Orderdet1;
+ c2.Prod = Orderdet1.Consumable_product__r;
+ c2.oldConsumableCount = Orderdet1.Name;
+ c2.ErrorReason = errorReason;
+
+ LexSaleOrderController.ConsumableorderdetailsInfo c1 = new LexSaleOrderController.ConsumableorderdetailsInfo(
+ Orderdet2
+ );
+ c1.orderdetails1 = null;
+ c1.orderdetails2 = Orderdet2;
+ c1.Prod = Orderdet2.Consumable_product__r;
+ c1.oldConsumableCount = Orderdet2.Name;
+ c1.compareTo(c2);
+
+ LexSaleOrderController.ConsumableorderdetailsInfo c3 = new LexSaleOrderController.ConsumableorderdetailsInfo(
+ Orderdet6
+ );
+ c3.orderdetails1 = Orderdet6;
+ c3.Prod = Orderdet6.Consumable_product__r;
+ c3.outboundCount = Orderdet6.Shipment_Count__c;
+ System.Test.stopTest();
+ }
+ }
+
+ @isTest
+ static void testArriveOrder() {
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ Account myAccount2;
+ Account olympus;
+ User MyUser_Test;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ];
+ RecordType hosCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ olympus = new Account(
+ RecordTypeId = hosCo.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+ 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 = myAccount2.id
+ );
+ insert core;
+ 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 = 'ENG',
+ Work_Location__c = '澶ц繛'
+ );
+ insert MyUser_Test;
+ }
+ System.runAs(MyUser_Test) {
+ String Id = UserInfo.getUserId();
+ User thisUserInfo = [
+ SELECT accountid, ContactId, Contact.AccountId, Work_Location__c
+ FROM User
+ WHERE id = :Id
+ ];
+ String accountId = thisUserInfo.Contact.AccountId;
+ String userWorkLocation1 = thisUserInfo.Work_Location__c;
+ String accountName = myAccount2.Name;
+ System.debug('accountName = ' + accountName);
+ System.debug('userWorkLocation1 = ' + userWorkLocation1);
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 12,
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 12,
+ 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.RecordTypeid = System.Label.RT_ConOrder_Order;
+ Order1.IsShipment__c = true;
+ Order1.OwnerId = MyUser_Test.Id;
+ insert Order1;
+
+ Consumable_order__c Order2 = new Consumable_order__c();
+ Order2.Name = 'OCM_02_001';
+ Order2.Order_status__c = '鎵瑰噯';
+ Order2.Order_type__c = '璁㈠崟';
+ Order2.RecordTypeid = System.Label.RT_ConOrder_Order;
+ Order2.Dealer_Info__c = myAccount2.Id;
+ Order2.IsShipment__c = true;
+ insert Order2;
+
+ Consumable_order__c Order3 = new Consumable_order__c();
+ Order3.Name = 'OCM_02_005';
+ Order3.Order_status__c = '鎵瑰噯';
+ Order3.Order_type__c = '浼犵エ';
+ Order3.RecordTypeid = System.Label.RT_ConOrder_Order;
+ Order3.Arrive_Order__c = Order1.Id;
+ Order3.Dealer_Info__c = myAccount2.Id;
+ Order3.SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌';
+ Order3.IsShipment__c = true;
+ insert Order3;
+
+ Consumable_order_details2__c Orderdet = new Consumable_order_details2__c();
+ Orderdet.Name = 'OCM_01_001001';
+ Orderdet.Consumable_Product__c = pro1.Id;
+ Orderdet.Consumable_order_minor__c = Order1.Id;
+ Orderdet.Consumable_Arrived_order__c = Order1.Id;
+ Orderdet.Consumable_ZS_order__c = Order3.Id;
+ Orderdet.Consumable_Return_order__c = Order1.Id;
+ Orderdet.Consumable_Sale_order__c = null;
+ Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet.RemoveBox_No__c = 3;
+ Orderdet.Bar_Code__c = '1111111111250AAAAA';
+ Orderdet.Arrive_date__c = Date.today();
+ Orderdet.Delivery_List_RMB__c = 11.11;
+ Orderdet.Box_Piece__c = '鐩�';
+ Orderdet.Return_date__c = null;
+ Orderdet.TracingCode__c = '';
+ Orderdet.Cancellation_Flag__c = true;
+ Orderdet.Sterilization_limit__c = Date.today().addDays(-1);
+ //鍙戣揣
+ Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+ Orderdet1.Name = 'OCM_01_001001';
+ Orderdet1.Consumable_Product__c = pro1.Id;
+ Orderdet1.Consumable_order_minor__c = Order1.Id;
+ Orderdet1.Consumable_ZS_order__c = Order3.Id;
+ Orderdet1.Consumable_Return_order__c = Order1.Id;
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet1.RemoveBox_No__c = 3;
+ Orderdet1.Bar_Code__c = '2222222222250BBBBB';
+ Orderdet1.Arrive_date__c = Date.today();
+ Orderdet1.Return_reason__c = null;
+ Orderdet1.Return_date__c = null;
+ Orderdet1.Delivery_List_RMB__c = 11.11;
+ Orderdet1.Box_Piece__c = '涓�';
+ Orderdet1.TracingCode__c = '';
+ Orderdet1.Cancellation_Flag__c = true;
+ Orderdet1.Sterilization_limit__c = Date.today().addDays(-1);
+ //閿�鍞�
+ Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+ Orderdet2.Name = 'OCM_01_001002';
+ Orderdet2.Consumable_order_minor__c = Order3.Id;
+ Orderdet2.Consumable_Shipment_order__c = Order3.Id;
+ Orderdet2.Consumable_Sale_order__c = Order3.Id;
+ Orderdet2.Consumable_ZS_order__c = Order3.Id;
+ Orderdet2.Consumable_Return_order__c = Order3.Id;
+ Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet2.RemoveBox_No__c = 3;
+ Orderdet2.Bar_Code__c = '3333333333250CCCCC';
+ Orderdet2.Consumable_Product__c = pro1.Id;
+ Orderdet2.Send_Date__c = null;
+ Orderdet2.Used_date__c = null;
+ Orderdet2.Lose_Flag__c = false;
+ Orderdet2.Return_reason__c = null;
+ Orderdet2.Return_date__c = null;
+ Orderdet2.Delivery_List_RMB__c = 11;
+ Orderdet2.Box_Piece__c = '鐩�';
+ Orderdet2.TracingCode__c = null;
+ Orderdet2.Cancellation_Flag__c = true;
+ Orderdet2.Arrive_date__c = Date.today();
+ Orderdet2.Sterilization_limit__c = Date.today().addDays(-1);
+ //閿�鍞�
+ Consumable_order_details2__c Orderdet9 = new Consumable_order_details2__c();
+ Orderdet9.Name = 'OCM_01_001002';
+ Orderdet9.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet9.RemoveBox_No__c = 3;
+ Orderdet9.Bar_Code__c = '4444444444250DDDDD';
+ Orderdet9.Consumable_Product__c = pro1.Id;
+ Orderdet9.Arrive_date__c = Date.today();
+ Orderdet9.Used_date__c = Date.today();
+ Orderdet9.Box_Piece__c = '涓�';
+ Orderdet9.TracingCode__c = 'DDDDD';
+ //鍑哄簱
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+ Orderdet3.Name = 'OCM_01_001003';
+ Orderdet3.Consumable_order_minor__c = Order1.Id;
+ Orderdet3.Consumable_Shipment_order__c = Order1.Id;
+ Orderdet3.Consumable_Sale_order__c = null;
+ Orderdet3.Consumable_ZS_order__c = Order1.Id;
+ Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet3.Bar_Code__c = '5555555555250EEEEE';
+ Orderdet3.Consumable_Product__c = pro1.Id;
+ Orderdet3.Send_Date__c = Date.today();
+ Orderdet3.Box_Piece__c = '鐩�';
+ Orderdet3.Return_date__c = null;
+ Orderdet3.Lose_Flag__c = true;
+ Orderdet3.TracingCode__c = 'EEEEE';
+
+ //鍒拌揣
+ Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
+ Orderdet4.Name = 'OCM_01_001004';
+ Orderdet4.Consumable_order_minor__c = null;
+ Orderdet4.Consumable_Sale_order__c = null;
+ Orderdet4.Consumable_ZS_order__c = Order1.Id;
+ Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet4.Consumable_Arrived_order__c = Order1.Id;
+ Orderdet4.Sterilization_limit__c = Date.today().addDays(-1);
+ Orderdet4.Bar_Code__c = '6666666666250FFFFF';
+ Orderdet4.Consumable_Product__c = pro1.Id;
+ Orderdet4.Arrive_date__c = Date.today();
+ Orderdet4.Box_Piece__c = '涓�';
+ Orderdet4.TracingCode__c = 'FFFFF';
+ //鍙戣揣
+ Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
+ Orderdet5.Name = 'OCM_02_001001';
+ Orderdet5.Consumable_order_minor__c = Order2.Id;
+ Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet5.Bar_Code__c = '7777777777250GGGGG';
+ Orderdet5.Consumable_Product__c = pro1.Id;
+ Orderdet5.Deliver_date__c = Date.today();
+ Orderdet5.RemoveBox_No__c = 3;
+ Orderdet5.Box_Piece__c = '鐩�';
+ Orderdet5.TracingCode__c = 'GGGGG';
+
+ Consumable_order_details2__c Orderdet6 = new Consumable_order_details2__c();
+ Orderdet6.Name = 'OCM_02_001001';
+ Orderdet6.Consumable_order_minor__c = Order2.Id;
+ Orderdet6.Consumable_ZS_order__c = Order2.Id;
+ Orderdet6.Consumable_Return_order__c = Order2.Id;
+ Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet6.Bar_Code__c = '8888888888250HHHHH';
+ Orderdet6.Consumable_Product__c = pro1.Id;
+ Orderdet6.Arrive_date__c = Date.today();
+ Orderdet6.RemoveBox_No__c = 3;
+ Orderdet6.Sterilization_limit__c = Date.today().addDays(-2);
+ Orderdet6.TracingCode__c = 'HHHHH';
+
+ hospitalprice__c hp1 = new hospitalprice__c();
+ hp1.hospital__c = accountId;
+ hp1.account__c = accountId;
+ hp1.product__c = pro1.Id;
+ insert hp1;
+
+ List<Consumable_order_details2__c> newdet2 = new List<Consumable_order_details2__c>();
+ newdet2.add(Orderdet);
+ insert newdet2;
+ insert new List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ Orderdet3,
+ Orderdet4,
+ Orderdet5,
+ Orderdet6,
+ Orderdet9
+ };
+
+ List<Consumable_order_details2__c> cod2 = [
+ SELECT Id, Arrive_Owner_Work_Location__c
+ FROM Consumable_order_details2__c
+ WHERE Id = :Orderdet.Id
+ ];
+ System.debug('cod2:' + cod2);
+ String userWorkLocation = cod2[0].Arrive_Owner_Work_Location__c;
+ System.debug('userWorkLocation:' + userWorkLocation);
+
+ Map<String, object> data = new Map<String, object>();
+ String ESetId = Order2.Id;
+ System.Test.startTest();
+ LexSaleOrderController.GoodsDeliveryInit(ESetId);
+ String barcode1 = '';
+ String key = '';
+ orderpieceorboxMap = new Map<String, String>();
+ List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
+ LexSaleOrderController.SearchPro(
+ Order1,
+ barcode1,
+ accountName,
+ userWorkLocation,
+ accountId,
+ orderdetails,
+ orderpieceorboxMap
+ );
+ String barcode = '1111111111250AAAAA\n2222222222250BBBBB\n3333333333250CCCCC\n4444444444250DDDDD\n5555555555250EEEEE\n6666666666250FFFFF\n7777777777250GGGGG\n8888888888250HHHHH';
+ LexSaleOrderController.SearchPro(
+ Order2,
+ barcode,
+ accountName,
+ userWorkLocation,
+ accountId,
+ orderdetails,
+ orderpieceorboxMap
+ );
+ String barcode2 = '111111111250AAAAA';
+ LexSaleOrderController.SearchPro(
+ Order2,
+ barcode2,
+ accountName,
+ userWorkLocation,
+ accountId,
+ orderdetails,
+ orderpieceorboxMap
+ );
+ LexSaleOrderController.ProdElivery(
+ ESetId,
+ Order2,
+ barcode2,
+ accountName,
+ userWorkLocation,
+ JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
+ orderdetails,
+ orderpriceMap,
+ orderagencypriceMap
+ );
+ LexSaleOrderController.ProSale(
+ ESetId,
+ Order2,
+ barcode2,
+ accountName,
+ userWorkLocation,
+ JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
+ orderdetails,
+ orderpriceMap,
+ orderagencypriceMap
+ );
+ String barcode3 = '3333333333250CCCCC';
+ LexSaleOrderController.SearchPro(
+ Order3,
+ barcode3,
+ accountName,
+ userWorkLocation,
+ accountId,
+ orderdetails,
+ orderpieceorboxMap
+ );
+ LexSaleOrderController.ProdElivery(
+ ESetId,
+ Order3,
+ barcode3,
+ accountName,
+ userWorkLocation,
+ JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
+ orderdetails,
+ orderpriceMap,
+ orderagencypriceMap
+ );
+ LexSaleOrderController.ProSale(
+ ESetId,
+ Order3,
+ barcode3,
+ accountName,
+ userWorkLocation,
+ JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
+ orderdetails,
+ orderpriceMap,
+ orderagencypriceMap
+ );
+ LexSaleOrderController.Getconsumableorderdetails2Nobox();
+
+ List<LexSaleOrderController.ConsumableorderdetailsInfo> inList = LexSaleOrderController.consumableorderdetailsRecords;
+ List<LexSaleOrderController.ConsumableorderdetailsInfo> inList1 = new List<LexSaleOrderController.ConsumableorderdetailsInfo>();
+ for (LexSaleOrderController.ConsumableorderdetailsInfo ass : inList) {
+ ass.orderdetails2 = Orderdet1;
+ inList1.add(ass);
+ }
+
+ String errorReason = 'success';
+ LexSaleOrderController.ConsumableorderdetailsInfo c2 = new LexSaleOrderController.ConsumableorderdetailsInfo(
+ Orderdet1,
+ errorReason
+ );
+ c2.orderdetails1 = null;
+ c2.orderdetails2 = Orderdet1;
+ c2.Prod = Orderdet1.Consumable_product__r;
+ c2.oldConsumableCount = Orderdet1.Name;
+ c2.ErrorReason = errorReason;
+
+ LexSaleOrderController.ConsumableorderdetailsInfo c1 = new LexSaleOrderController.ConsumableorderdetailsInfo(
+ Orderdet2
+ );
+ c1.orderdetails1 = null;
+ c1.orderdetails2 = Orderdet2;
+ c1.Prod = Orderdet2.Consumable_product__r;
+ c1.oldConsumableCount = Orderdet2.Name;
+ c1.compareTo(c2);
+ System.Test.stopTest();
+ }
+ }
+
+ @isTest
+ static void testProSale() {
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+ 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)'
+ ];
+ RecordType hosCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ Account olympus = new Account(
+ RecordTypeId = hosCo.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+ 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 = myAccount2.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 = 'ENG',
+ Work_Location__c = '澶ц繛'
+ );
+ System.runAs(new User(Id = UserInfo.getUserId())) {
+ insert MyUser_Test;
+ }
+ System.runAs(MyUser_Test) {
+ String Id = UserInfo.getUserId();
+ User thisUserInfo = [
+ SELECT accountid, ContactId, Contact.AccountId, Work_Location__c
+ FROM User
+ WHERE id = :Id
+ ];
+ String accountId = thisUserInfo.Contact.AccountId;
+ String userWorkLocation = thisUserInfo.Work_Location__c;
+ String accountName;
+ Account[] accountInfo = [
+ SELECT Name
+ FROM account
+ WHERE id = :accountId
+ LIMIT 1
+ ];
+ if (accountInfo.size() > 0) {
+ accountName = accountInfo[0].Name;
+ }
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 12,
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 12,
+ 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.RecordTypeid = System.Label.RT_ConOrder_Order;
+ Order1.Dealer_Info__c = myAccount2.Id;
+ Order1.IsShipment__c = true;
+ insert Order1;
+
+ Consumable_order__c Order3 = new Consumable_order__c();
+ Order3.Name = 'OCM_02_005';
+ Order3.Order_status__c = '鎵瑰噯';
+ Order3.Order_type__c = '浼犵エ';
+ Order3.RecordTypeid = System.Label.RT_ConOrder_Order;
+ Order3.Arrive_Order__c = Order1.Id;
+ Order3.Dealer_Info__c = myAccount2.Id;
+ Order3.SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌';
+ Order3.IsShipment__c = true;
+ insert Order3;
+
+ List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
+ //鏄庣粏1
+ Consumable_orderdetails__c conOrder1 = new Consumable_orderdetails__c();
+ conOrder1.Name = 'OCM_01_001001';
+ conOrder1.Consumable_order__c = Order1.Id;
+ conOrder1.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ conOrder1.Consumable_Count__c = 12;
+ conOrder1.Consumable_Product__c = pro1.Id;
+ conOrder1.Delivery_List_RMB__c = 1;
+ conOrder1.Shipment_Count__c = 1;
+ conOrder1.Box_Piece__c = '鐩�';
+
+ Consumable_orderdetails__c conOrder2 = new Consumable_orderdetails__c();
+ conOrder2.Name = 'OCM_01_001002';
+ conOrder2.Consumable_order__c = Order1.Id;
+ conOrder2.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ conOrder2.Consumable_Count__c = 12;
+ conOrder2.Consumable_Product__c = pro1.Id;
+ conOrder2.Delivery_List_RMB__c = 1;
+ conOrder2.Shipment_Count__c = 1;
+ conOrder2.Box_Piece__c = '涓�';
+
+ orderdetails.add(conOrder1);
+ orderdetails.add(conOrder2);
+ insert orderdetails;
+ System.debug('orderdetails.size() = ' + orderdetails.size());
+
+ Consumable_order_details2__c Orderdet = new Consumable_order_details2__c();
+ Orderdet.Name = 'OCM_01_001001';
+ Orderdet.Consumable_Product__c = pro1.Id;
+ Orderdet.Consumable_order_minor__c = Order1.Id;
+ Orderdet.Consumable_ZS_order__c = Order3.Id;
+ Orderdet.Consumable_Return_order__c = Order1.Id;
+ Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet.RemoveBox_No__c = 3;
+ Orderdet.Bar_Code__c = '1111111111250AAAAA';
+ Orderdet.Arrive_date__c = Date.today();
+ Orderdet.Delivery_List_RMB__c = 11.11;
+ Orderdet.Box_Piece__c = '鐩�';
+ Orderdet.Return_date__c = null;
+ Orderdet.TracingCode__c = '';
+ Orderdet.Cancellation_Flag__c = true;
+ Orderdet.Sterilization_limit__c = Date.today().addDays(-1);
+
+ //鍙戣揣
+ Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
+ Orderdet1.Name = 'OCM_01_001001';
+ Orderdet1.Consumable_Product__c = pro1.Id;
+ Orderdet1.Consumable_order_minor__c = Order1.Id;
+ Orderdet1.Consumable_ZS_order__c = Order3.Id;
+ Orderdet1.Consumable_Return_order__c = Order1.Id;
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet1.RemoveBox_No__c = 3;
+ Orderdet1.Bar_Code__c = '2222222222250BBBBB';
+ Orderdet1.Arrive_date__c = Date.today();
+ Orderdet1.Return_reason__c = null;
+ Orderdet1.Return_date__c = null;
+ Orderdet1.Delivery_List_RMB__c = 11.11;
+ Orderdet1.Box_Piece__c = '涓�';
+ Orderdet1.TracingCode__c = '';
+ Orderdet1.Cancellation_Flag__c = true;
+ Orderdet1.Sterilization_limit__c = Date.today().addDays(-1);
+ //閿�鍞�
+ Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
+ Orderdet2.Name = 'OCM_01_001002';
+ Orderdet2.Consumable_order_minor__c = Order3.Id;
+ Orderdet2.Consumable_Shipment_order__c = Order3.Id;
+ Orderdet2.Consumable_Sale_order__c = Order3.Id;
+ Orderdet2.Consumable_ZS_order__c = Order3.Id;
+ Orderdet2.Consumable_Return_order__c = Order3.Id;
+ Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet2.RemoveBox_No__c = 3;
+ Orderdet2.Bar_Code__c = '3333333333250CCCCC';
+ Orderdet2.Consumable_Product__c = pro1.Id;
+ Orderdet2.Send_Date__c = null;
+ Orderdet2.Used_date__c = null;
+ Orderdet2.Lose_Flag__c = false;
+ Orderdet2.Return_reason__c = null;
+ Orderdet2.Return_date__c = null;
+ Orderdet2.Delivery_List_RMB__c = 11;
+ Orderdet2.Box_Piece__c = '鐩�';
+ Orderdet2.TracingCode__c = null;
+ Orderdet2.Cancellation_Flag__c = true;
+ Orderdet2.Arrive_date__c = Date.today();
+ Orderdet2.Sterilization_limit__c = Date.today().addDays(-1);
+ //閿�鍞�
+ Consumable_order_details2__c Orderdet9 = new Consumable_order_details2__c();
+ Orderdet9.Name = 'OCM_01_001002';
+ Orderdet9.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet9.RemoveBox_No__c = 3;
+ Orderdet9.Bar_Code__c = '4444444444250DDDDD';
+ Orderdet9.Consumable_Product__c = pro1.Id;
+ Orderdet9.Arrive_date__c = Date.today();
+ Orderdet9.Used_date__c = Date.today();
+ Orderdet9.Box_Piece__c = '涓�';
+ Orderdet9.TracingCode__c = 'DDDDD';
+ //鍑哄簱
+ Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
+ Orderdet3.Name = 'OCM_01_001003';
+ Orderdet3.Consumable_order_minor__c = Order1.Id;
+ Orderdet3.Consumable_Shipment_order__c = Order1.Id;
+ Orderdet3.Consumable_order_minor__c = null;
+ Orderdet3.Consumable_Sale_order__c = null;
+ Orderdet3.Consumable_ZS_order__c = Order1.Id;
+ Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet3.Bar_Code__c = '5555555555250EEEEE';
+ Orderdet3.Consumable_Product__c = pro1.Id;
+ Orderdet3.Send_Date__c = Date.today();
+ Orderdet3.Box_Piece__c = '鐩�';
+ Orderdet3.Return_date__c = null;
+ Orderdet3.Lose_Flag__c = true;
+ Orderdet3.TracingCode__c = 'EEEEE';
+
+ List<Consumable_order_details2__c> newdet2 = new List<Consumable_order_details2__c>();
+ newdet2.add(Orderdet);
+ insert newdet2;
+ insert new List<Consumable_order_details2__c>{
+ Orderdet1,
+ Orderdet2,
+ Orderdet3,
+ Orderdet9
+ };
+
+ Map<String, object> data = new Map<String, object>();
+ String ESetId = Order3.Id;
+ System.Test.startTest();
+ LexSaleOrderController.GoodsDeliveryInit(ESetId);
+ String barcode1 = '';
+ String key = '';
+ Integer i = 0;
+ Decimal a = 0;
+ orderpieceorboxMap = new Map<String, String>();
+ LexSaleOrderController.SearchPro(
+ Order1,
+ barcode1,
+ accountName,
+ userWorkLocation,
+ accountId,
+ orderdetails,
+ orderpieceorboxMap
+ );
+ String barcode = '1111111111250AAAAA\n2222222222250BBBBB\n3333333333250CCCCC\n4444444444250DDDDD\n5555555555250EEEEE';
+ LexSaleOrderController.SearchPro(
+ Order3,
+ barcode,
+ accountName,
+ userWorkLocation,
+ accountId,
+ orderdetails,
+ orderpieceorboxMap
+ );
+ LexSaleOrderController.ProdElivery(
+ ESetId,
+ Order3,
+ barcode,
+ accountName,
+ userWorkLocation,
+ JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
+ orderdetails,
+ orderpriceMap,
+ orderagencypriceMap
+ );
+ LexSaleOrderController.ProSale(
+ ESetId,
+ Order3,
+ barcode,
+ accountName,
+ userWorkLocation,
+ JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
+ orderdetails,
+ orderpriceMap,
+ orderagencypriceMap
+ );
+
+ List<LexSaleOrderController.ConsumableorderdetailsInfo> inList = LexSaleOrderController.consumableorderdetailsRecords;
+ List<LexSaleOrderController.ConsumableorderdetailsInfo> inList1 = new List<LexSaleOrderController.ConsumableorderdetailsInfo>();
+ for (LexSaleOrderController.ConsumableorderdetailsInfo ass : inList) {
+ ass.orderdetails2 = Orderdet1;
+ inList1.add(ass);
+ }
+
+ String errorReason = 'success';
+ LexSaleOrderController.ConsumableorderdetailsInfo c2 = new LexSaleOrderController.ConsumableorderdetailsInfo(
+ Orderdet1,
+ errorReason
+ );
+ c2.orderdetails1 = null;
+ c2.orderdetails2 = Orderdet1;
+ c2.Prod = Orderdet1.Consumable_product__r;
+ c2.oldConsumableCount = Orderdet1.Name;
+ c2.ErrorReason = errorReason;
+
+ LexSaleOrderController.ConsumableorderdetailsInfo c1 = new LexSaleOrderController.ConsumableorderdetailsInfo(
+ Orderdet2
+ );
+ c1.orderdetails1 = null;
+ c1.orderdetails2 = Orderdet2;
+ c1.Prod = Orderdet2.Consumable_product__r;
+ c1.oldConsumableCount = Orderdet2.Name;
+ c1.compareTo(c2);
+ System.Test.stopTest();
+ }
+ }
+
+ @isTest
+ static void testProdError() {
+ 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)'
+ ];
+ RecordType hosCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ Account olympus = new Account(
+ RecordTypeId = hosCo.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+ 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 = myAccount2.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',
+ Work_Location__c = '澶ц繛'
+ );
+ System.runAs(new User(Id = UserInfo.getUserId())) {
+ insert MyUser_Test;
+ }
+ //璁㈠崟
+ System.runAs(MyUser_Test) {
+ String Id = UserInfo.getUserId();
+ User thisUserInfo = [
+ SELECT accountid, ContactId, Contact.AccountId, Work_Location__c
+ FROM User
+ WHERE id = :Id
+ ];
+ String accountId = thisUserInfo.Contact.AccountId;
+ String userWorkLocation = thisUserInfo.Work_Location__c;
+ String accountName;
+ Account[] accountInfo = [
+ SELECT Name
+ FROM account
+ WHERE id = :accountId
+ LIMIT 1
+ ];
+ if (accountInfo.size() > 0) {
+ accountName = accountInfo[0].Name;
+ }
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 12,
+ Manual_Entry__c = false
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 12,
+ Manual_Entry__c = false
+ );
+ Product2 prod03 = new Product2(
+ Name = 'Test03',
+ ProductCode = 'Test03',
+ Asset_Model_No__c = 'Test03',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 12,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod01, prod02, prod03 };
+ 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
+ );
+ Product2__c pro3 = new Product2__c(
+ Name = 'Pro003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod03.Id
+ );
+ insert new List<Product2__c>{ pro1, pro2, pro3 };
+ //鍑哄簱鍗�
+ Consumable_order__c Order1 = new Consumable_order__c();
+ Order1.Name = 'OCM_01_001';
+ Order1.Order_status__c = '鎵瑰噯';
+ Order1.Order_type__c = '浼犵エ';
+ Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
+ Order1.Dealer_Info__c = myAccount2.Id;
+ Order1.SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌';
+ Order1.IsShipment__c = true;
+ insert Order1;
+
+ List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
+ //鏄庣粏1
+ Consumable_orderdetails__c Orderdet1 = new Consumable_orderdetails__c();
+ Orderdet1.Name = 'OCM_01_001001';
+ Orderdet1.Consumable_order__c = Order1.Id;
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ Orderdet1.Consumable_Count__c = 12;
+ Orderdet1.Consumable_Product__c = pro1.Id;
+ Orderdet1.Unitprice_To_agency__c = 1;
+ Orderdet1.Delivery_List_RMB__c = 1;
+ Orderdet1.Shipment_Count__c = 1;
+ Orderdet1.Box_Piece__c = '鐩�';
+ Consumable_orderdetails__c Orderdet2 = new Consumable_orderdetails__c();
+ Orderdet2.Name = 'OCM_01_001002';
+ Orderdet2.Consumable_order__c = Order1.Id;
+ Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ Orderdet2.Consumable_Count__c = 12;
+ Orderdet2.Consumable_Product__c = pro2.Id;
+ Orderdet2.Unitprice_To_agency__c = 1;
+ Orderdet2.Delivery_List_RMB__c = 1;
+ Orderdet2.Shipment_Count__c = 1;
+ Orderdet2.Box_Piece__c = '涓�';
+ orderdetails.add(Orderdet1);
+ orderdetails.add(Orderdet2);
+ insert orderdetails;
+
+ //鏄庣粏2
+ Consumable_order_details2__c Orderdets1 = new Consumable_order_details2__c();
+ Orderdets1.Name = 'OCM_01_0010001';
+ Orderdets1.Consumable_order_minor__c = Order1.Id;
+ Orderdets1.Consumable_ZS_order__c = Order1.Id;
+ Orderdets1.Consumable_Return_order__c = null;
+ Orderdets1.Consumable_Sale_order__c = null;
+ Orderdets1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdets1.Bar_Code__c = '11111250AAAAA';
+ Orderdets1.Consumable_Product__c = pro1.Id;
+ Orderdets1.Arrive_date__c = Date.today();
+ Orderdets1.Return_date__c = null;
+ Orderdets1.RemoveBox_No__c = 3;
+ Orderdets1.Delivery_List_RMB__c = 11.11;
+ Orderdets1.Box_Piece__c = '鐩�';
+ Orderdets1.Sterilization_limit__c = Date.today().addDays(-1);
+ Orderdets1.TracingCode__c = 'AAAAA';
+
+ Consumable_order_details2__c Orderdets2 = new Consumable_order_details2__c();
+ Orderdets2.Name = 'OCM_01_0010002';
+ Orderdets2.Consumable_Return_order__c = null;
+ Orderdets2.Consumable_Sale_order__c = null;
+ Orderdets2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdets2.Bar_Code__c = '22222250BBBBB';
+ Orderdets2.Consumable_Product__c = pro2.Id;
+ Orderdets2.Arrive_date__c = Date.today();
+ Orderdets2.Return_date__c = null;
+ Orderdets2.RemoveBox_No__c = 3;
+ Orderdets2.Delivery_List_RMB__c = 11.11;
+ Orderdets2.Box_Piece__c = '涓�';
+ Orderdets2.Sterilization_limit__c = Date.today().addDays(-1);
+ Orderdets2.TracingCode__c = '';
+
+ Consumable_order_details2__c Orderdets3 = new Consumable_order_details2__c();
+ Orderdets3.Name = 'OCM_01_0010003';
+ Orderdets3.Consumable_order_minor__c = Order1.Id;
+ Orderdets3.Consumable_ZS_order__c = Order1.Id;
+ Orderdets3.Consumable_Return_order__c = null;
+ Orderdets2.Consumable_Sale_order__c = null;
+ Orderdets3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdets3.Bar_Code__c = '33333250CCCCC';
+ Orderdets3.Consumable_Product__c = pro3.Id;
+ Orderdets3.Arrive_date__c = Date.today();
+ Orderdets3.Return_date__c = null;
+ Orderdets3.RemoveBox_No__c = 3;
+ Orderdets3.Delivery_List_RMB__c = 11.11;
+ Orderdets3.Box_Piece__c = '鐩�';
+ Orderdets3.Sterilization_limit__c = Date.today().addDays(-1);
+ Orderdets3.TracingCode__c = 'CCCCC';
+ //鏈埌璐�
+ Consumable_order_details2__c Orderdets4 = new Consumable_order_details2__c();
+ Orderdets4.Name = 'OCM_01_0010001';
+ Orderdets4.Consumable_order_minor__c = Order1.Id;
+ Orderdets4.Consumable_ZS_order__c = Order1.Id;
+ Orderdets4.Consumable_Return_order__c = null;
+ Orderdets4.Consumable_Sale_order__c = null;
+ Orderdets4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdets4.Bar_Code__c = '44444250DDDDD';
+ Orderdets4.Arrive_date__c = Date.today();
+ Orderdets4.Return_date__c = null;
+ Orderdets4.Consumable_Product__c = pro1.Id;
+ Orderdets4.Delivery_List_RMB__c = 11.11;
+ Orderdets4.RemoveBox_No__c = 3;
+ Orderdets4.Box_Piece__c = '鐩�';
+ Orderdets4.Sterilization_limit__c = Date.today().addDays(-1);
+ Orderdets4.TracingCode__c = 'DDDDD';
+
+ Consumable_order_details2__c Orderdets5 = new Consumable_order_details2__c();
+ Orderdets5.Name = 'OCM_01_0010003';
+ Orderdets5.Consumable_order_minor__c = Order1.Id;
+ Orderdets5.Consumable_ZS_order__c = Order1.Id;
+ Orderdets5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdets5.Bar_Code__c = '33333250EEEEE';
+ Orderdets5.Consumable_Product__c = pro3.Id;
+ Orderdets5.Arrive_date__c = Date.today();
+ Orderdets5.Return_date__c = null;
+ Orderdets5.RemoveBox_No__c = 3;
+ Orderdets5.Delivery_List_RMB__c = 11.11;
+ Orderdets5.Box_Piece__c = '涓�';
+ Orderdets5.Sterilization_limit__c = Date.today().addDays(-1);
+ Orderdets5.TracingCode__c = 'EEEEE';
+
+ List<Consumable_order_details2__c> newdet2 = new List<Consumable_order_details2__c>();
+ newdet2.add(Orderdets1);
+ insert newdet2;
+ insert new List<Consumable_order_details2__c>{
+ Orderdets2,
+ Orderdets3,
+ Orderdets4,
+ Orderdets5
+ };
+
+ List<String> barCodeListP = new List<String>();
+ Map<String, object> data = new Map<String, object>();
+ String ESetId = Order1.Id;
+ System.Test.startTest();
+ LexSaleOrderController.GoodsDeliveryInit(ESetId);
+ String barcode = '11111250AAAAA\n22222250BBBBB\n33333250CCCCC\n44444250DDDDD\n33333250EEEEE';
+ barCodeListP = LexSaleOrderController.ParseBarCode(barcode);
+ System.debug('barCodeListP:' + barCodeListP);
+ System.debug('accountName:' + accountName);
+ System.debug('userWorkLocation:' + userWorkLocation);
+ String key = '';
+ Integer idx = 0;
+ orderpieceorboxMap = new Map<String, String>();
+ LexSaleOrderController.SearchPro(
+ Order1,
+ barcode,
+ accountName,
+ userWorkLocation,
+ accountId,
+ orderdetails,
+ orderpieceorboxMap
+ );
+ LexSaleOrderController.ProdElivery(
+ ESetId,
+ Order1,
+ barcode,
+ accountName,
+ userWorkLocation,
+ JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
+ orderdetails,
+ orderpriceMap,
+ orderagencypriceMap
+ );
+ LexSaleOrderController.ProSale(
+ ESetId,
+ Order1,
+ barcode,
+ accountName,
+ userWorkLocation,
+ JSON.serialize(LexSaleOrderController.consumableorderdetailsRecords),
+ orderdetails,
+ orderpriceMap,
+ orderagencypriceMap
+ );
+
+ System.Test.stopTest();
+ }
+ }
+
+ @isTest
+ static void searchTest1() {
+ 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)'
+ ];
+ 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',
+ Work_Location__c = '鍖椾含'
+ );
+ System.runAs(new User(Id = UserInfo.getUserId())) {
+ insert MyUser_Test;
+ }
+
+ 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 };
+
+ hospitalprice__c hp1 = new hospitalprice__c();
+ hp1.hospital__c = myAccount1.Id;
+ hp1.account__c = myAccount1.Id;
+ hp1.product__c = pro1.Id;
+ insert hp1;
+
+ Consumable_order__c Order0 = new Consumable_order__c();
+ Order0.Name = 'OCM_01_000';
+ Order0.Order_status__c = '鎵瑰噯';
+ Order0.Order_type__c = '璁㈠崟';
+ Order0.Dealer_Info__c = myAccount1.id;
+ Order0.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ Order0.Order_ProType__c = 'ET';
+ Order0.OutPattern__c = true;
+ insert Order0;
+
+ 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';
+ Order1.OutPattern__c = true;
+ Order1.Arrive_Order__c = Order0.Id;
+ insert Order1;
+ 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;
+ Orderdet.Shipment_Count__c = 1;
+ Orderdet.isOutPattern__c = true;
+ 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 = 'Test01';
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+ Orderdet1.Cancellation_Date__c = null;
+ Orderdet1.TracingCode__c = 'BXJRF';
+ Orderdet1.SerialLotNo__c = '5ZK';
+ Orderdet1.Arrive_date__c = Date.today();
+ Orderdet1.exchangeOutPattern__c = true;
+ Orderdet1.Consumable_ZS_order__c = Order1.Id;
+ insert Orderdet1;
+ System.debug('Orderdet1:' + Orderdet1);
+ 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';
+ Orderdet1.Cancellation_Date__c = null;
+ Orderdet2.TracingCode__c = 'BXJRF';
+ Orderdet2.SerialLotNo__c = '5ZK';
+ // Orderdet2.Consumable_ZS_order__c = Order1.Id;
+ // Orderdet2.Box_Piece__c = '涓�';
+ insert Orderdet2;
+ System.Test.startTest();
+ String a = LexSaleOrderController.baseUrl;
+ LexSaleOrderController.msiMap = new Map<String, Integer>();
+ List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
+ orderdetails.add(Orderdet);
+ LexSaleOrderController.GoodsDeliveryInit(Order1.Id);
+ String condetailList = JSON.serialize(
+ LexSaleOrderController.consumableorderdetailsRecords
+ );
+ Order1.Arrive_Order__c = null;
+ LexSaleOrderController.SearchPro(
+ Order1,
+ '01049531702003111115120017181000105ZK250BXJRF',
+ myAccount1.Name,
+ '',
+ myAccount1.Id,
+ LexSaleOrderController.orderdetails,
+ LexSaleOrderController.orderpieceorboxMap
+ );
+ LexSaleOrderController.ProdElivery(
+ Order1.Id,
+ LexSaleOrderController.coc,
+ '01049531702003111115120017181000105ZK250BXJRF',
+ myAccount1.Name,
+ '',
+ condetailList,
+ LexSaleOrderController.orderdetails,
+ LexSaleOrderController.orderpriceMap,
+ LexSaleOrderController.orderagencypriceMap
+ );
+ LexSaleOrderController.ProSale(
+ Order1.Id,
+ LexSaleOrderController.coc,
+ '01049531702003111115120017181000105ZK250BXJRF',
+ myAccount1.Name,
+ '',
+ condetailList,
+ LexSaleOrderController.orderdetails,
+ LexSaleOrderController.orderpriceMap,
+ LexSaleOrderController.orderagencypriceMap
+ );
+ System.Test.stopTest();
+ }
+ }
+
+ @isTest
+ static void searchTest2() {
+ 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)'
+ ];
+ 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',
+ Work_Location__c = '鍖椾含'
+ );
+ System.runAs(new User(Id = UserInfo.getUserId())) {
+ insert MyUser_Test;
+ }
+
+ 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 };
+
+ hospitalprice__c hp1 = new hospitalprice__c();
+ hp1.hospital__c = myAccount1.Id;
+ hp1.account__c = myAccount1.Id;
+ hp1.product__c = pro1.Id;
+ insert hp1;
+
+ Consumable_order__c Order0 = new Consumable_order__c();
+ Order0.Name = 'OCM_01_000';
+ Order0.Order_status__c = '鎵瑰噯';
+ Order0.Order_type__c = '璁㈠崟';
+ Order0.Dealer_Info__c = myAccount1.id;
+ Order0.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ Order0.Order_ProType__c = 'ET';
+ Order0.OutPattern__c = true;
+ insert Order0;
+
+ 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';
+ Order1.OutPattern__c = true;
+ Order1.Arrive_Order__c = Order0.Id;
+ insert Order1;
+ 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;
+ Orderdet.Shipment_Count__c = 1;
+ Orderdet.isOutPattern__c = true;
+ 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 = 'Test01';
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+ Orderdet1.Cancellation_Date__c = null;
+ Orderdet1.TracingCode__c = 'BXJRF';
+ Orderdet1.SerialLotNo__c = '5ZK';
+ Orderdet1.Arrive_date__c = Date.today();
+ Orderdet1.exchangeOutPattern__c = true;
+ Orderdet1.Consumable_ZS_order__c = Order1.Id;
+ Orderdet1.Box_Piece__c = '涓�';
+ insert Orderdet1;
+ System.debug('Orderdet1:' + Orderdet1);
+ System.Test.startTest();
+ String a = LexSaleOrderController.baseUrl;
+ LexSaleOrderController.msiMap = new Map<String, Integer>();
+ List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
+ orderdetails.add(Orderdet);
+ LexSaleOrderController.GoodsDeliveryInit(Order1.Id);
+ LexSaleOrderController.consumableorderdetailsRecords[0].outboundCount = 1;
+ String condetailList = JSON.serialize(
+ LexSaleOrderController.consumableorderdetailsRecords
+ );
+ LexSaleOrderController.ProdElivery(
+ Order1.Id,
+ LexSaleOrderController.coc,
+ '01049531702003111115120017181000105ZK250BXJRF',
+ myAccount1.Name,
+ '',
+ condetailList,
+ LexSaleOrderController.orderdetails,
+ LexSaleOrderController.orderpriceMap,
+ LexSaleOrderController.orderagencypriceMap
+ );
+ // LexSaleOrderController.ProSale(Order1.Id, LexSaleOrderController.coc, '01049531702003111115120017181000105ZK250BXJRF', myAccount1.Name, '', condetailList, LexSaleOrderController.orderdetails, LexSaleOrderController.orderpriceMap, LexSaleOrderController.orderagencypriceMap);
+ System.Test.stopTest();
+ }
+ }
+
+ @isTest
+ static void searchTest3() {
+ 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)'
+ ];
+ 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',
+ Work_Location__c = '鍖椾含'
+ );
+ System.runAs(new User(Id = UserInfo.getUserId())) {
+ insert MyUser_Test;
+ }
+
+ 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 };
+
+ hospitalprice__c hp1 = new hospitalprice__c();
+ hp1.hospital__c = myAccount1.Id;
+ hp1.account__c = myAccount1.Id;
+ hp1.product__c = pro1.Id;
+ insert hp1;
+
+ Consumable_order__c Order0 = new Consumable_order__c();
+ Order0.Name = 'OCM_01_000';
+ Order0.Order_status__c = '鎵瑰噯';
+ Order0.Order_type__c = '璁㈠崟';
+ Order0.Dealer_Info__c = myAccount1.id;
+ Order0.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ Order0.Order_ProType__c = 'ET';
+ Order0.OutPattern__c = true;
+ insert Order0;
+
+ 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';
+ Order1.OutPattern__c = true;
+ Order1.Arrive_Order__c = Order0.Id;
+ insert Order1;
+ 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;
+ Orderdet.Shipment_Count__c = 1;
+ Orderdet.isOutPattern__c = true;
+ 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 = 'Test01';
+ Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
+ Orderdet1.Cancellation_Date__c = null;
+ Orderdet1.TracingCode__c = 'BXJRF';
+ Orderdet1.SerialLotNo__c = '5ZK';
+ Orderdet1.Arrive_date__c = Date.today();
+ Orderdet1.exchangeOutPattern__c = true;
+ Orderdet1.Consumable_ZS_order__c = Order1.Id;
+ Orderdet1.Box_Piece__c = '涓�';
+ insert Orderdet1;
+ System.debug('Orderdet1:' + Orderdet1);
+ System.Test.startTest();
+ String a = LexSaleOrderController.baseUrl;
+ LexSaleOrderController.msiMap = new Map<String, Integer>();
+ List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
+ orderdetails.add(Orderdet);
+ LexSaleOrderController.GoodsDeliveryInit(Order1.Id);
+ LexSaleOrderController.consumableorderdetailsRecords[0].outboundCount = 1;
+ String condetailList = JSON.serialize(
+ LexSaleOrderController.consumableorderdetailsRecords
+ );
+ // LexSaleOrderController.ProdElivery(Order1.Id, LexSaleOrderController.coc, '01049531702003111115120017181000105ZK250BXJRF', myAccount1.Name, '', condetailList, LexSaleOrderController.orderdetails, LexSaleOrderController.orderpriceMap, LexSaleOrderController.orderagencypriceMap);
+ LexSaleOrderController.ProSale(
+ Order1.Id,
+ LexSaleOrderController.coc,
+ '01049531702003111115120017181000105ZK250BXJRF',
+ myAccount1.Name,
+ '',
+ condetailList,
+ LexSaleOrderController.orderdetails,
+ LexSaleOrderController.orderpriceMap,
+ LexSaleOrderController.orderagencypriceMap
+ );
+ System.Test.stopTest();
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexSaleOrderControllerTest.cls-meta.xml b/force-app/main/default/classes/LexSaleOrderControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexSaleOrderControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexSearchContractControllerTest.cls b/force-app/main/default/classes/LexSearchContractControllerTest.cls
new file mode 100644
index 0000000..172f409
--- /dev/null
+++ b/force-app/main/default/classes/LexSearchContractControllerTest.cls
@@ -0,0 +1,84 @@
+@istest
+public class LexSearchContractControllerTest {
+ @IsTest
+ static void lexSearchContractController1() {
+ User myUser_test = new User();
+ Account myAccount2;
+ Account contact;
+ Contact core;
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(currentUser) {
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ List<RecordType> rectCotac = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '濂戠磩'
+ ];
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ myAccount2 = new Account(
+ name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|5|55,Test02|2|4',
+ ET_SP_Dealer__c = true
+ );
+ insert myAccount2;
+ contact = new Account(
+ name = 'Testaccount002',
+ RecordTypeId = rectCotac[0].Id,
+ SpecialDealerName__c = 'Testaccount002',
+ ParentId = myAccount2.Id,
+ Agent_Ref__c = myAccount2.Id,
+ Delete_Flag__c = false,
+ Contract_Department_Class__c = 'ET',
+ Contract_Decide_Start_Date__c = Date.today().addDays(-1),
+ Contract_Decide_End_Date__c = Date.today().addDays(1),
+ AgentCode_Ext__c = '9999900',
+ ET_SP_Dealer__c = true
+ );
+ insert contact;
+
+ core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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.runAs(myUser_test) {
+ LexSearchContractController.init('ET');
+ String accountId = myAccount2.Id;
+ LexSearchContractController.searchContract(
+ 'Testaccount002',
+ accountId,
+ 'ET',
+ false
+ );
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexSearchContractControllerTest.cls-meta.xml b/force-app/main/default/classes/LexSearchContractControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexSearchContractControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexSearchHospitalControllerTest.cls b/force-app/main/default/classes/LexSearchHospitalControllerTest.cls
new file mode 100644
index 0000000..f66ab33
--- /dev/null
+++ b/force-app/main/default/classes/LexSearchHospitalControllerTest.cls
@@ -0,0 +1,9 @@
+@istest
+public class LexSearchHospitalControllerTest {
+ @IsTest
+ static void lexSearchHospitalControllerTest1() {
+ LexSearchHospitalController.init();
+ LexSearchHospitalController.searchHospital('', '');
+ LexSearchHospitalController.searchHospital('test', '');
+ }
+}
diff --git a/force-app/main/default/classes/LexSearchHospitalControllerTest.cls-meta.xml b/force-app/main/default/classes/LexSearchHospitalControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexSearchHospitalControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexSummonsCreatController.cls b/force-app/main/default/classes/LexSummonsCreatController.cls
index df46d82..1b620e4 100644
--- a/force-app/main/default/classes/LexSummonsCreatController.cls
+++ b/force-app/main/default/classes/LexSummonsCreatController.cls
@@ -1,441 +1,498 @@
public without sharing class LexSummonsCreatController {
- public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
+ public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
- /*****************妞滅储鐢�******************/
- //缁忛攢鍟嗙敤鎴蜂骇鍝佸垎绫伙紙ET銆丒NG锛�
- @AuraEnabled
- public static String agencyProType { get; set; }
- public static Consumable_order__c coc { get; set; } // 鐢籿iew鐢紝 鍙兘鏄� 鍑哄簱鎸囩ず鍗曪紝 涔熸湁鍙兘鏄埌璐у崟锛� 涔熸湁鍙兘 绌篿nstance
- public static User localuser { get; set; }
- public static String category1 { get; set; }
- public static Integer noOfRecords { get; set; }
- //public String category_Goods {get ; set;}
- public static Boolean cansee { get; set; }
- public static Integer size { get; set; }
- //缁忛攢鍟嗗畾浠锋煡鐪嬫潈闄�
- //public static ApexPages.StandardSetController setCon { get; set; }
- public static Boolean dealerPricesee { get; set; }
- /*****************鐢婚潰鍒濆鍖栫敤********************************/
- /******20160313_add**************/
- public static String IdCheck { get; set; }
- public static Boolean editAble { get; set; }
- public static String statusEdit { get; set; }
- public static String alertMessage { get; set; }
- public static String SearchDone { get; set; }
- public static List<String> zaikuId = new List<String>();
- public static List<String> orderzaikuId = new List<String>();
- //闄勪欢
- public static List<ConsumableorderdetailsInfo> attachmentRecoeds { get; set; }
- public static Boolean getExistarrive() {
- return (coc.Arrive_Order__c != null);
+ /*****************妞滅储鐢�******************/
+ //缁忛攢鍟嗙敤鎴蜂骇鍝佸垎绫伙紙ET銆丒NG锛�
+ @AuraEnabled
+ public static String agencyProType { get; set; }
+ public static Consumable_order__c coc { get; set; } // 鐢籿iew鐢紝 鍙兘鏄� 鍑哄簱鎸囩ず鍗曪紝 涔熸湁鍙兘鏄埌璐у崟锛� 涔熸湁鍙兘 绌篿nstance
+ public static User localuser { get; set; }
+ public static String category1 { get; set; }
+ public static Integer noOfRecords { get; set; }
+ //public String category_Goods {get ; set;}
+ public static Boolean cansee { get; set; }
+ public static Integer size { get; set; }
+ //缁忛攢鍟嗗畾浠锋煡鐪嬫潈闄�
+ //public static ApexPages.StandardSetController setCon { get; set; }
+ public static Boolean dealerPricesee { get; set; }
+ /*****************鐢婚潰鍒濆鍖栫敤********************************/
+ /******20160313_add**************/
+ public static String IdCheck { get; set; }
+ public static Boolean editAble { get; set; }
+ public static String statusEdit { get; set; }
+ public static String alertMessage { get; set; }
+ public static String SearchDone { get; set; }
+ public static List<String> zaikuId = new List<String>();
+ public static List<String> orderzaikuId = new List<String>();
+ //闄勪欢
+ public static List<ConsumableorderdetailsInfo> attachmentRecoeds { get; set; }
+ public static Boolean getExistarrive() {
+ return (coc.Arrive_Order__c != null);
+ }
+ //鎬讳环鏍艰绠楃粨鏋�
+ @AuraEnabled
+ public static Decimal sumPrice { get; set; }
+ /******20160317_add**************/
+ public static String SummonsFlag { get; set; } // 鏂拌: hidden, 鏇存柊: visible
+ public static String category5 { get; set; }
+ public static String category4 { get; set; }
+ public static String category3 { get; set; }
+ public static List<SelectOption> categoryOptionList { get; set; }
+ public static List<SelectOption> category4OptionList { get; set; }
+ public static List<SelectOption> category5OptionList { get; set; }
+ @AuraEnabled
+ public static Map<String, String> categoryOptionMap { get; set; }
+ @AuraEnabled
+ public static Map<String, String> category4OptionMap { get; set; }
+ @AuraEnabled
+ public static Map<String, String> category5OptionMap { get; set; }
+ /*****************鐢婚潰琛ㄧずBean******************/
+ private static List<ConsumableorderdetailsInfo> consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
+ //鏄庣粏2
+ @AuraEnabled
+ public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords {
+ get;
+ set;
+ }
+ //閿欒鏄庣粏
+ @AuraEnabled
+ public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordserror {
+ get;
+ set;
+ }
+ @AuraEnabled
+ public static List<ConsumableorderdetailsInfo> pageRecords { get; set; }
+ public static List<ConsumableorderdetailsInfoLwc> pageRecordsLwc { get; set; }
+ //public List<List<ConsumableorderdetailsInfo>> consumableorderdetailsRecordsview { get; set; }
+ public static List<ConsumableorderdetailsInfo> consumableorderdetails2Records {
+ get;
+ set;
+ }
+ public static List<Consumable_order__c> consumableInvoiceRecords { get; set; }
+ private static List<ConsumableorderdetailsInfo> consumableproductdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ private static List<Attachment> attachmentinfo = new List<Attachment>();
+ public static List<Product2__c> product2Selected = new List<Product2__c>();
+ @AuraEnabled
+ public static Map<String, String> orderpieceorboxMap { get; set; }
+ @AuraEnabled
+ public static List<Consumable_orderdetails__c> orderdetails { get; set; }
+ @AuraEnabled
+ public static Map<String, Decimal> orderagencypriceMap { get; set; }
+ @AuraEnabled
+ public static Map<String, Decimal> orderpriceMap { get; set; }
+ @AuraEnabled
+ public static Map<String, Decimal> orderdetCountMap { get; set; }
+ @AuraEnabled
+ public static Boolean hasSpecialHos { get; set; }
+ //閫夋嫨浜у搧size
+ public static Integer consumableorderdetailsCount {
+ get {
+ return pageRecords == null ? 0 : pageRecords.size();
}
- //鎬讳环鏍艰绠楃粨鏋�
- @AuraEnabled
- public static Decimal sumPrice { get; set; }
- /******20160317_add**************/
- public static String SummonsFlag { get; set; } // 鏂拌: hidden, 鏇存柊: visible
- public static String category5 { get; set; }
- public static String category4 { get; set; }
- public static String category3 { get; set; }
- public static List<SelectOption> categoryOptionList { get; set; }
- public static List<SelectOption> category4OptionList { get; set; }
- public static List<SelectOption> category5OptionList { get; set; }
- @AuraEnabled
- public static Map<String, String> categoryOptionMap { get; set; }
- @AuraEnabled
- public static Map<String, String> category4OptionMap { get; set; }
- @AuraEnabled
- public static Map<String, String> category5OptionMap { get; set; }
- /*****************鐢婚潰琛ㄧずBean******************/
- private static List<ConsumableorderdetailsInfo> consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
- //鏄庣粏2
- @AuraEnabled
- public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords { get; set; }
- //閿欒鏄庣粏
- @AuraEnabled
- public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordserror { get; set; }
- @AuraEnabled
- public static List<ConsumableorderdetailsInfo> pageRecords { get; set; }
- public static List<ConsumableorderdetailsInfoLwc> pageRecordsLwc { get; set; }
- //public List<List<ConsumableorderdetailsInfo>> consumableorderdetailsRecordsview { get; set; }
- public static List<ConsumableorderdetailsInfo> consumableorderdetails2Records { get; set; }
- public static List<Consumable_order__c> consumableInvoiceRecords { get; set; }
- private static List<ConsumableorderdetailsInfo> consumableproductdetailsRecords = new List<ConsumableorderdetailsInfo>();
- private static List<Attachment> attachmentinfo = new List<Attachment>();
- public static List<Product2__c> product2Selected = new List<Product2__c>();
- @AuraEnabled
- public static Map<String, String> orderpieceorboxMap { get; set; }
- @AuraEnabled
- public static List<Consumable_orderdetails__c> orderdetails { get; set; }
- @AuraEnabled
- public static Map<String, Decimal> orderagencypriceMap { get; set; }
- @AuraEnabled
- public static Map<String, Decimal> orderpriceMap { get; set; }
- @AuraEnabled
- public static Map<String, Decimal> orderdetCountMap { get; set; }
- @AuraEnabled
- public static Boolean hasSpecialHos { get; set; }
- //閫夋嫨浜у搧size
- public static Integer consumableorderdetailsCount {
- get {
- return pageRecords == null ? 0 : pageRecords.size();
+ }
+ //娑堣�楀搧鏄庣粏2鏁伴噺
+ public static Integer consumableorderdetails2Count {
+ get {
+ return consumableorderdetails2Records == null
+ ? 0
+ : consumableorderdetails2Records.size();
+ }
+ }
+ //璁㈣揣鍗曞彿
+ public static String consumableorderId {
+ get {
+ return (coc.Arrive_Order__c);
+ }
+ }
+ //閫夋嫨妗�
+ public static List<SelectOption> provinceOpts { get; set; }
+ @AuraEnabled
+ public static Map<String, String> provinceOptsMap { get; set; }
+ public static String SecondDealer { get; set; }
+ //public List<SelectOption> orderForHospitalOpts { get; set; }
+ public static String HospitalInfo { get; set; }
+ public static String HospitalName { get; set; }
+
+ public static Boolean EditDelCommitBtnDisabled { get; private set; }
+ public static Boolean saveBtnDisabled { get; private set; }
+ public static Boolean SorderBtnDisabled { get; private set; }
+
+ // page
+ public static Integer pagesize { get; set; }
+ public static Integer pageToken { get; set; }
+ //public static String sortField { get; set; }
+ //public static String sortOrder { get; set; }
+ public static Integer totalcount { get; set; }
+ public static Integer addSize { get; set; }
+ //List<ConsumableorderdetailsInfoLwc> reSetLwc
+ public static List<ConsumableorderdetailsInfo> addData { get; set; }
+ public static Map<String, String> skipData { get; set; }
+ // 淇濆瓨鍚庡姩浣滐細 1.妫�绱� 2.鎺掑簭
+ // public static String sortKey { get; set; }
+ // public static String preSortKey { get; private set; }
+ // public static Boolean sortOrderAsc { get; private set; }
+ // public static String[] sortOrder { get; private set; }
+ // private static String[] columus = new List<String>{
+ // 'Consumable_Product__r.Name',
+ // 'Consumable_Product__r.Asset_Model_No__c',
+ // 'Consumable_Product__r.Intra_Trade_List_RMB__c',
+ // '',
+ // '',
+ // 'Consumable_Product__r.Category3__c',
+ // 'Consumable_Product__r.Category4__c',
+ // 'Consumable_Product__r.Category5__c'
+ // };
+ // private static String[] columus_no = new List<String>{
+ // 'Product2__c.Name',
+ // 'Product2__c.Asset_Model_No__c',
+ // 'Product2__c.Intra_Trade_List_RMB__c',
+ // '',
+ // '',
+ // 'Category3__c',
+ // 'Category4__c',
+ // 'Category5__c'
+ // };
+
+ //鍒拌揣鍗曟槑缁�1
+ private static List<Consumable_Orderdetails__c> consumableorderdetailsSelected = new List<Consumable_Orderdetails__c>();
+ //鍒拌揣鍗曟槑缁�2
+ private static List<Consumable_order_details2__c> consumablearriveproductdetailsSelected = new List<Consumable_order_details2__c>();
+
+ //鍑哄簱鍗曟槑缁�2
+ private static List<Consumable_order_details2__c> consumableorderdetails2RecordsList = new List<Consumable_order_details2__c>();
+ /*****************銈姐兗銉堟檪鍐嶆绱㈡潯浠讹紙鐢婚潰銇嬨倝銇叆鍔涙潯浠躲倰鐒¤銇欍倠銇熴倎锛�******************/
+ //private String cate1ForSort = null;
+ private static String accountid = null;
+ @AuraEnabled
+ public static String accountName { get; set; }
+
+ // 浜у搧 ID
+ private static String ESetId = '';
+ @AuraEnabled
+ public static String arriveorder { get; set; }
+ private static String userId = '';
+ //private String[] ProidListAll = new String[]{};
+
+ // 鐧诲綍鑰呭伐浣滃湴
+ @AuraEnabled
+ public static String userWorkLocation { get; set; }
+
+ //add by rentx 2021-01-29
+ public static List<SelectOption> outOutPatternOptionList { get; set; }
+ @AuraEnabled
+ public static Map<String, String> outOutPatternOptionMap { get; set; }
+ public static String outOutPattern { get; set; }
+ public static Boolean hasHos { get; set; }
+ @AuraEnabled
+ public static Boolean hasHosPro { get; set; }
+
+ private static Map<String, String> HosProMap = new Map<String, String>();
+ //add by rentx 2021-01-29
+
+ public LexSummonsCreatController() {
+ System.debug('LexSummonsCreatController');
+ size = Integer.valueOf(System.Label.orderdetLimitsize);
+ // ESetId = ApexPages.currentPage().getParameters().get('esetId');
+ // arriveorder = ApexPages.currentPage().getParameters().get('arriveorder');
+ // statusEdit = ApexPages.currentPage().getParameters().get('KeyWords');
+ provinceOpts = new List<SelectOption>();
+ provinceOptsMap = new Map<String, String>();
+ pageRecords = new List<ConsumableorderdetailsInfo>();
+ consumableproductdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
+ attachmentRecoeds = new List<ConsumableorderdetailsInfo>();
+ consumableorderdetails2Records = new List<ConsumableorderdetailsInfo>();
+ consumableInvoiceRecords = new List<Consumable_order__c>();
+ categoryOptionList = new List<SelectOption>();
+ category4OptionList = new List<SelectOption>();
+ category5OptionList = new List<SelectOption>();
+
+ categoryOptionMap = new Map<String, String>();
+ category4OptionMap = new Map<String, String>();
+ category5OptionMap = new Map<String, String>();
+
+ outOutPatternOptionMap = new Map<String, String>();
+ outOutPatternOptionMap.put('', '-鏃�-');
+ outOutPatternOptionMap.put('ishos', '鍖婚櫌鐗逛环浜у搧');
+ outOutPatternOptionMap.put('nothos', '闈炲尰闄㈢壒浠蜂骇鍝�');
+
+ outOutPatternOptionList.add(new SelectOption('', '-鏃�-'));
+ outOutPatternOptionList.add(new SelectOption('ishos', '鍖婚櫌鐗逛环浜у搧'));
+ outOutPatternOptionList.add(new SelectOption('nothos', '闈炲尰闄㈢壒浠蜂骇鍝�'));
+ HospitalName = '';
+ }
+
+ public static void firstInit(String ESetidJs) {
+ System.debug('enter firstInit');
+ ESetid = ESetidJs;
+ System.debug('ESetid = ' + ESetid);
+ size = Integer.valueOf(System.Label.orderdetLimitsize);
+ provinceOpts = new List<SelectOption>();
+ provinceOptsMap = new Map<String, String>();
+ pageRecords = new List<ConsumableorderdetailsInfo>();
+ consumableproductdetailsRecords = new List<ConsumableorderdetailsInfo>();
+ consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
+ attachmentRecoeds = new List<ConsumableorderdetailsInfo>();
+ consumableorderdetails2Records = new List<ConsumableorderdetailsInfo>();
+ consumableInvoiceRecords = new List<Consumable_order__c>();
+ categoryOptionList = new List<SelectOption>();
+ category4OptionList = new List<SelectOption>();
+ category5OptionList = new List<SelectOption>();
+
+ categoryOptionMap = new Map<String, String>();
+ category4OptionMap = new Map<String, String>();
+ category5OptionMap = new Map<String, String>();
+
+ outOutPatternOptionMap = new Map<String, String>();
+ outOutPatternOptionMap.put('', '-鏃�-');
+ outOutPatternOptionMap.put('ishos', '鍖婚櫌鐗逛环浜у搧');
+ outOutPatternOptionMap.put('nothos', '闈炲尰闄㈢壒浠蜂骇鍝�');
+
+ // outOutPatternOptionList.add(new SelectOption('', '-鏃�-'));
+ // outOutPatternOptionList.add(new SelectOption('ishos', '鍖婚櫌鐗逛环浜у搧'));
+ // outOutPatternOptionList.add(new SelectOption('nothos', '闈炲尰闄㈢壒浠蜂骇鍝�'));
+ HospitalName = '';
+ }
+
+ // 鐢婚潰鍒濆鍖�
+ @AuraEnabled
+ public static ResponseBodyLWC init(
+ String ESetidJs,
+ String statusEdit,
+ Integer pageSizeLWC,
+ Integer pageTokenLWC,
+ String arriveorderLWC
+ ) {
+ try {
+ firstInit(ESetidJs);
+ statusEdit = statusEdit;
+ arriveorder = arriveorderLWC;
+ HospitalName = '';
+ provinceOpts = new List<SelectOption>();
+ provinceOptsMap = new Map<String, String>();
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ // public static Integer pagesize { get; set; }
+ // public static Integer pageToken { get; set; }
+ // public static String sortField { get; set; }
+ // public static String sortOrder { get; set; }
+ pagesize = pageSizeLWC;
+ pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC;
+
+ // sortKey = '1';
+ // preSortKey = '1';
+ // sortOrderAsc = false;
+ // sortOrder = new List<String>(8);
+ // sortOrder = new List<String>{ ' ', ' ', ' ', ' ', '鈫�', '', '', '' };
+ //cate1ForSort = '';
+ sumPrice = 0;
+ IdCheck = EsetId;
+ if (
+ ESetId != null &&
+ ESetId != '' &&
+ (statusEdit == '' ||
+ statusEdit == null)
+ ) {
+ editAble = false;
+ } else if (
+ (ESetId == null || ESetId == '') &&
+ (statusEdit == '' ||
+ statusEdit == null)
+ ) {
+ editAble = true;
+ } else if (
+ ESetId != null &&
+ ESetId != '' &&
+ statusEdit != '' &&
+ statusEdit != null
+ ) {
+ editAble = true;
+ }
+ userId = UserInfo.getUserId();
+ localuser = [
+ SELECT id, State_Hospital__c
+ FROM User
+ WHERE id = :UserInfo.getUserId()
+ ];
+ //userId = '00510000005QO75';
+ user Useracc = [
+ SELECT accountid, Work_Location__c, UserPro_Type__c
+ FROM user
+ WHERE id = :userId
+ ];
+ accountid = Useracc.accountid;
+ userWorkLocation = Useracc.Work_Location__c;
+ agencyProType = Useracc.UserPro_Type__c;
+ if (String.isBlank(Useracc.UserPro_Type__c)) {
+ agencyProType = 'ET';
+ }
+ Account accountInfo = [SELECT Name FROM account WHERE id = :accountid];
+ accountName = accountInfo.Name;
+ //coc.Order_date__c = Date.today();
+ list<Dealer_elationship__c> Dealerelationship = new List<Dealer_elationship__c>();
+ Dealerelationship = [
+ SELECT Dealer_subordinate__c, Dealer_subordinate__r.Name
+ FROM Dealer_elationship__c
+ WHERE Dealer_principal__c = :accountid
+ ];
+
+ List<Agency_Hospital_Link__c> AgencyHospitalLink = new List<Agency_Hospital_Link__c>();
+ AgencyHospitalLink = [
+ SELECT Id, Hospital__c, Hospital__r.Name
+ FROM Agency_Hospital_Link__c
+ WHERE Agency__c = :accountid
+ ];
+
+ //add by rentx 2021-3-1 start
+ //鍒ゆ柇褰撳墠缁忛攢鍟嗕笅鏄惁鏈夌壒浠峰尰闄�
+ List<hospitalprice__c> hlist = [
+ SELECT id, product__c
+ FROM hospitalprice__c
+ WHERE account__c = :accountid
+ ];
+ if (hlist == null || hlist.size() == 0) {
+ hasHos = false;
+ } else {
+ for (hospitalprice__c hp : hlist) {
+ HosProMap.put(hp.product__c, '');
}
- }
- //娑堣�楀搧鏄庣粏2鏁伴噺
- public static Integer consumableorderdetails2Count {
- get {
- return consumableorderdetails2Records == null ? 0 : consumableorderdetails2Records.size();
- }
- }
- //璁㈣揣鍗曞彿
- public static String consumableorderId {
- get {
- return (coc.Arrive_Order__c);
- }
- }
- //閫夋嫨妗�
- public static List<SelectOption> provinceOpts { get; set; }
- @AuraEnabled
- public static Map<String, String> provinceOptsMap { get; set; }
- public static String SecondDealer { get; set; }
- //public List<SelectOption> orderForHospitalOpts { get; set; }
- public static String HospitalInfo { get; set; }
- public static String HospitalName { get; set; }
+ hasHos = true;
+ }
+ //add by rentx 2021-3-1 end
- public static Boolean EditDelCommitBtnDisabled { get; private set; }
- public static Boolean saveBtnDisabled { get; private set; }
- public static Boolean SorderBtnDisabled { get; private set; }
+ saveBtnDisabled = false;
+ SorderBtnDisabled = false;
+ String sqlagencyProType = '%' + agencyProType + '%';
+ coc = new Consumable_order__c();
+ consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
+ Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>();
+ //add by rentx 2021-01-29
+ Map<String, ConsumableorderdetailsInfo> MidMap2 = new Map<String, ConsumableorderdetailsInfo>();
+ //add by rentx 2021-01-29
- // page
- public static Integer pagesize { get; set; }
- public static Integer pageToken { get; set; }
- //public static String sortField { get; set; }
- //public static String sortOrder { get; set; }
- public static Integer totalcount { get; set; }
- public static Integer addSize { get; set; }
- //List<ConsumableorderdetailsInfoLwc> reSetLwc
- public static List<ConsumableorderdetailsInfo> addData { get; set; }
- public static Map<String, String> skipData { get; set; }
- // 淇濆瓨鍚庡姩浣滐細 1.妫�绱� 2.鎺掑簭
- // public static String sortKey { get; set; }
- // public static String preSortKey { get; private set; }
- // public static Boolean sortOrderAsc { get; private set; }
- // public static String[] sortOrder { get; private set; }
- // private static String[] columus = new List<String>{
- // 'Consumable_Product__r.Name',
- // 'Consumable_Product__r.Asset_Model_No__c',
- // 'Consumable_Product__r.Intra_Trade_List_RMB__c',
- // '',
- // '',
- // 'Consumable_Product__r.Category3__c',
- // 'Consumable_Product__r.Category4__c',
- // 'Consumable_Product__r.Category5__c'
- // };
- // private static String[] columus_no = new List<String>{
- // 'Product2__c.Name',
- // 'Product2__c.Asset_Model_No__c',
- // 'Product2__c.Intra_Trade_List_RMB__c',
- // '',
- // '',
- // 'Category3__c',
- // 'Category4__c',
- // 'Category5__c'
- // };
-
- //鍒拌揣鍗曟槑缁�1
- private static List<Consumable_Orderdetails__c> consumableorderdetailsSelected = new List<Consumable_Orderdetails__c>();
- //鍒拌揣鍗曟槑缁�2
- private static List<Consumable_order_details2__c> consumablearriveproductdetailsSelected = new List<Consumable_order_details2__c>();
-
- //鍑哄簱鍗曟槑缁�2
- private static List<Consumable_order_details2__c> consumableorderdetails2RecordsList = new List<Consumable_order_details2__c>();
- /*****************銈姐兗銉堟檪鍐嶆绱㈡潯浠讹紙鐢婚潰銇嬨倝銇叆鍔涙潯浠躲倰鐒¤銇欍倠銇熴倎锛�******************/
- //private String cate1ForSort = null;
- private static String accountid = null;
- @AuraEnabled
- public static String accountName { get; set; }
-
- // 浜у搧 ID
- private static String ESetId = '';
- @AuraEnabled
- public static String arriveorder { get; set; }
- private static String userId = '';
- //private String[] ProidListAll = new String[]{};
-
- // 鐧诲綍鑰呭伐浣滃湴
- @AuraEnabled
- public static String userWorkLocation { get; set; }
-
- //add by rentx 2021-01-29
- public static List<SelectOption> outOutPatternOptionList { get; set; }
- @AuraEnabled
- public static Map<String, String> outOutPatternOptionMap { get; set; }
- public static String outOutPattern { get; set; }
- public static Boolean hasHos { get; set; }
- @AuraEnabled
- public static Boolean hasHosPro { get; set; }
-
- private static Map<String, String> HosProMap = new Map<String, String>();
- //add by rentx 2021-01-29
-
- public LexSummonsCreatController() {
- System.debug('LexSummonsCreatController');
- size = Integer.valueOf(System.Label.orderdetLimitsize);
- // ESetId = ApexPages.currentPage().getParameters().get('esetId');
- // arriveorder = ApexPages.currentPage().getParameters().get('arriveorder');
- // statusEdit = ApexPages.currentPage().getParameters().get('KeyWords');
- provinceOpts = new List<SelectOption>();
- provinceOptsMap = new Map<String, String>();
- pageRecords = new List<ConsumableorderdetailsInfo>();
- consumableproductdetailsRecords = new List<ConsumableorderdetailsInfo>();
- consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
- attachmentRecoeds = new List<ConsumableorderdetailsInfo>();
- consumableorderdetails2Records = new List<ConsumableorderdetailsInfo>();
- consumableInvoiceRecords = new List<Consumable_order__c>();
- categoryOptionList = new List<SelectOption>();
- category4OptionList = new List<SelectOption>();
- category5OptionList = new List<SelectOption>();
-
- categoryOptionMap = new Map<String, String>();
- category4OptionMap = new Map<String, String>();
- category5OptionMap = new Map<String, String>();
-
- outOutPatternOptionMap = new Map<String, String>();
- outOutPatternOptionMap.put('', '-鏃�-');
- outOutPatternOptionMap.put('ishos', '鍖婚櫌鐗逛环浜у搧');
- outOutPatternOptionMap.put('nothos', '闈炲尰闄㈢壒浠蜂骇鍝�');
-
- outOutPatternOptionList.add(new SelectOption('', '-鏃�-'));
- outOutPatternOptionList.add(new SelectOption('ishos', '鍖婚櫌鐗逛环浜у搧'));
- outOutPatternOptionList.add(new SelectOption('nothos', '闈炲尰闄㈢壒浠蜂骇鍝�'));
- HospitalName = '';
- }
-
- public static void firstInit(String ESetidJs) {
- System.debug('enter firstInit');
- ESetid = ESetidJs;
- System.debug('ESetid = ' + ESetid);
- size = Integer.valueOf(System.Label.orderdetLimitsize);
- provinceOpts = new List<SelectOption>();
- provinceOptsMap = new Map<String, String>();
- pageRecords = new List<ConsumableorderdetailsInfo>();
- consumableproductdetailsRecords = new List<ConsumableorderdetailsInfo>();
- consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
- attachmentRecoeds = new List<ConsumableorderdetailsInfo>();
- consumableorderdetails2Records = new List<ConsumableorderdetailsInfo>();
- consumableInvoiceRecords = new List<Consumable_order__c>();
- categoryOptionList = new List<SelectOption>();
- category4OptionList = new List<SelectOption>();
- category5OptionList = new List<SelectOption>();
-
- categoryOptionMap = new Map<String, String>();
- category4OptionMap = new Map<String, String>();
- category5OptionMap = new Map<String, String>();
-
- outOutPatternOptionMap = new Map<String, String>();
- outOutPatternOptionMap.put('', '-鏃�-');
- outOutPatternOptionMap.put('ishos', '鍖婚櫌鐗逛环浜у搧');
- outOutPatternOptionMap.put('nothos', '闈炲尰闄㈢壒浠蜂骇鍝�');
-
- // outOutPatternOptionList.add(new SelectOption('', '-鏃�-'));
- // outOutPatternOptionList.add(new SelectOption('ishos', '鍖婚櫌鐗逛环浜у搧'));
- // outOutPatternOptionList.add(new SelectOption('nothos', '闈炲尰闄㈢壒浠蜂骇鍝�'));
- HospitalName = '';
- }
-
- // 鐢婚潰鍒濆鍖�
- @AuraEnabled
- public static ResponseBodyLWC init(String ESetidJs, String statusEdit, Integer pageSizeLWC, Integer pageTokenLWC,String arriveorderLWC) {
- try {
- firstInit(ESetidJs);
- statusEdit = statusEdit;
- arriveorder = arriveorderLWC;
- HospitalName = '';
- provinceOpts = new List<SelectOption>();
- provinceOptsMap = new Map<String, String>();
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- // public static Integer pagesize { get; set; }
- // public static Integer pageToken { get; set; }
- // public static String sortField { get; set; }
- // public static String sortOrder { get; set; }
- pagesize = pageSizeLWC;
- pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC;
-
- // sortKey = '1';
- // preSortKey = '1';
- // sortOrderAsc = false;
- // sortOrder = new List<String>(8);
- // sortOrder = new List<String>{ ' ', ' ', ' ', ' ', '鈫�', '', '', '' };
- //cate1ForSort = '';
- sumPrice = 0;
- IdCheck = EsetId;
- if (ESetId != null && ESetId != '' && (statusEdit == '' || statusEdit == null)) {
- editAble = false;
- } else if ((ESetId == null || ESetId == '') && (statusEdit == '' || statusEdit == null)) {
- editAble = true;
- } else if (ESetId != null && ESetId != '' && statusEdit != '' && statusEdit != null) {
- editAble = true;
- }
- userId = UserInfo.getUserId();
- localuser = [SELECT id, State_Hospital__c FROM User WHERE id = :UserInfo.getUserId()];
- //userId = '00510000005QO75';
- user Useracc = [SELECT accountid, Work_Location__c, UserPro_Type__c FROM user WHERE id = :userId];
- accountid = Useracc.accountid;
- userWorkLocation = Useracc.Work_Location__c;
- agencyProType = Useracc.UserPro_Type__c;
- if (String.isBlank(Useracc.UserPro_Type__c)) {
- agencyProType = 'ET';
- }
- Account accountInfo = [SELECT Name FROM account WHERE id = :accountid];
- accountName = accountInfo.Name;
- //coc.Order_date__c = Date.today();
- list<Dealer_elationship__c> Dealerelationship = new List<Dealer_elationship__c>();
- Dealerelationship = [
- SELECT Dealer_subordinate__c, Dealer_subordinate__r.Name
- FROM Dealer_elationship__c
- WHERE Dealer_principal__c = :accountid
- ];
-
- List<Agency_Hospital_Link__c> AgencyHospitalLink = new List<Agency_Hospital_Link__c>();
- AgencyHospitalLink = [SELECT Id, Hospital__c, Hospital__r.Name FROM Agency_Hospital_Link__c WHERE Agency__c = :accountid];
-
- //add by rentx 2021-3-1 start
- //鍒ゆ柇褰撳墠缁忛攢鍟嗕笅鏄惁鏈夌壒浠峰尰闄�
- List<hospitalprice__c> hlist = [SELECT id, product__c FROM hospitalprice__c WHERE account__c = :accountid];
- if (hlist == null || hlist.size() == 0) {
- hasHos = false;
+ List<AggregateResult> orderdetailCount = [
+ SELECT count(id), Consumable_Product__c cpc, Box_Piece__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 Cancellation_Flag__c = FALSE
+ AND Bar_Code__c != NULL
+ AND Isoverdue__c = 1
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Dealer_Info_text__c = :accountName
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ GROUP BY Consumable_Product__c, Box_Piece__c
+ ];
+ for (AggregateResult orderdetail : orderdetailCount) {
+ zaikuId.add(String.valueOf(orderdetail.get('cpc')));
+ }
+ System.debug('sqlagencyProType = ' + sqlagencyProType);
+ System.debug('userWorkLocation = ' + userWorkLocation);
+ System.debug('accountName = ' + accountName);
+ List<Consumable_order_details2__c> CountDel = [
+ SELECT
+ Id,
+ Bar_Code__c,
+ Name,
+ Inventory_date__c,
+ Consumable_Product__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Recordtypeid,
+ Box_Piece__c,
+ ProductPacking_list_manual__c,
+ //add by rentx 2020-11-27 start
+ hospitalSpecialOffer__c
+ //add by rentx 2020-11-27 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 Lose_Flag__c = FALSE
+ AND Cancellation_Flag__c = FALSE
+ AND Bar_Code__c != NULL
+ AND Isoverdue__c = 1
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Arrive_Owner_Work_Location__c = :userWorkLocation
+ AND Dealer_Info_text__c = :accountName
+ ];
+ // 鏂拌
+ if (ESetId == null || ESetId == '') {
+ SummonsFlag = 'hidden';
+ String msoql = makeSoqlinventory();
+ initStandardController(msoql);
+ System.debug('msoql = ' + msoql);
+ product2Selected = Database.query(msoql);
+ if (String.isBlank(arriveorder)) {
+ EditDelCommitBtnDisabled = true;
+ for (Integer i = 0; i < product2Selected.size(); i++) {
+ MidMap.put(
+ product2Selected[i].Id,
+ new ConsumableorderdetailsInfo(product2Selected[i])
+ );
+ }
+ for (Integer i = 0; i < CountDel.size(); i++) {
+ String str = '';
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ str = 'isHos';
} else {
- for (hospitalprice__c hp : hlist) {
- HosProMap.put(hp.product__c, '');
+ str = 'notHos';
+ }
+ //鏄庣粏2瀵瑰簲鐨勪骇鍝佸瓨鍦ㄤ簬MidMap涓�
+ if (MidMap.containsKey(CountDel[i].Consumable_Product__c)) {
+ //璁剧疆map涓璳ey鐨勫悗缂� 鐢ㄤ簬鍖哄垎鍖婚櫌鐗逛环鍜岄潪鍖婚櫌鐗逛环
+ if (
+ MidMap2.containsKey(CountDel[i].Consumable_Product__c + str)
+ ) {
+ ConsumableorderdetailsInfo Jstage = MidMap2.get(
+ CountDel[i].Consumable_Product__c + str
+ );
+ Jstage.allnumber = Jstage.allnumber + 1;
+ if (CountDel[i].Box_Piece__c == '鐩�') {
+ Jstage.Boxnumber = Jstage.Boxnumber + 1;
+ } else if (CountDel[i].Box_Piece__c == '涓�') {
+ Jstage.Piecenumber = Jstage.Piecenumber + 1;
}
- hasHos = true;
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ Jstage.hospitalSpecialOffer = true;
+ } else {
+ Jstage.hospitalSpecialOffer = false;
+ }
+ if (HosProMap.containsKey(Jstage.Prod.Id)) {
+ Jstage.hosPro = true;
+ }
+ MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
+ } else {
+ //midmap2涓病鏈夊搴旂殑浜у搧
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ CountDel[i].Consumable_Product__c
+ )
+ .clone();
+ Jstage.allnumber = Jstage.allnumber + 1;
+ if (CountDel[i].Box_Piece__c == '鐩�') {
+ Jstage.Boxnumber = Jstage.Boxnumber + 1;
+ } else if (CountDel[i].Box_Piece__c == '涓�') {
+ Jstage.Piecenumber = Jstage.Piecenumber + 1;
+ }
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ Jstage.hospitalSpecialOffer = true;
+ } else {
+ Jstage.hospitalSpecialOffer = false;
+ }
+ if (HosProMap.containsKey(Jstage.Prod.Id)) {
+ Jstage.hosPro = true;
+ }
+ //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+ MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
+ }
}
- //add by rentx 2021-3-1 end
-
- saveBtnDisabled = false;
- SorderBtnDisabled = false;
- String sqlagencyProType = '%' + agencyProType + '%';
- coc = new Consumable_order__c();
- consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
- Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>();
- //add by rentx 2021-01-29
- Map<String, ConsumableorderdetailsInfo> MidMap2 = new Map<String, ConsumableorderdetailsInfo>();
- //add by rentx 2021-01-29
-
- List<AggregateResult> orderdetailCount = [
- SELECT count(id), Consumable_Product__c cpc, Box_Piece__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 Cancellation_Flag__c = FALSE
- AND Bar_Code__c != NULL
- AND Isoverdue__c = 1
- AND Product_Type__c LIKE :sqlagencyProType
- AND Dealer_Info_text__c = :accountName
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- GROUP BY Consumable_Product__c, Box_Piece__c
- ];
- for (AggregateResult orderdetail : orderdetailCount) {
- zaikuId.add(String.valueOf(orderdetail.get('cpc')));
- }
- System.debug('sqlagencyProType = ' + sqlagencyProType);
- System.debug('userWorkLocation = ' + userWorkLocation);
- System.debug('accountName = ' + accountName);
- List<Consumable_order_details2__c> CountDel = [
- SELECT
- Id,
- Bar_Code__c,
- Name,
- Inventory_date__c,
- Consumable_Product__c,
- Consumable_Product__r.Asset_Model_No__c,
- Recordtypeid,
- Box_Piece__c,
- ProductPacking_list_manual__c,
- //add by rentx 2020-11-27 start
- hospitalSpecialOffer__c
- //add by rentx 2020-11-27 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 Lose_Flag__c = FALSE
- AND Cancellation_Flag__c = FALSE
- AND Bar_Code__c != NULL
- AND Isoverdue__c = 1
- AND Product_Type__c LIKE :sqlagencyProType
- AND Arrive_Owner_Work_Location__c = :userWorkLocation
- AND Dealer_Info_text__c = :accountName
- ];
- // 鏂拌
- if (ESetId == null || ESetId == '') {
- SummonsFlag = 'hidden';
- String msoql = makeSoqlinventory();
- initStandardController(msoql);
- System.debug('msoql = ' + msoql);
- product2Selected = Database.query(msoql);
- if (String.isBlank(arriveorder)) {
- EditDelCommitBtnDisabled = true;
- for (Integer i = 0; i < product2Selected.size(); i++) {
- MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
- }
- for (Integer i = 0; i < CountDel.size(); i++) {
- String str = '';
- if (CountDel[i].hospitalSpecialOffer__c) {
- str = 'isHos';
- } else {
- str = 'notHos';
- }
- //鏄庣粏2瀵瑰簲鐨勪骇鍝佸瓨鍦ㄤ簬MidMap涓�
- if (MidMap.containsKey(CountDel[i].Consumable_Product__c)) {
- //璁剧疆map涓璳ey鐨勫悗缂� 鐢ㄤ簬鍖哄垎鍖婚櫌鐗逛环鍜岄潪鍖婚櫌鐗逛环
- if (MidMap2.containsKey(CountDel[i].Consumable_Product__c + str)) {
- ConsumableorderdetailsInfo Jstage = MidMap2.get(CountDel[i].Consumable_Product__c + str);
- Jstage.allnumber = Jstage.allnumber + 1;
- if (CountDel[i].Box_Piece__c == '鐩�') {
- Jstage.Boxnumber = Jstage.Boxnumber + 1;
- } else if (CountDel[i].Box_Piece__c == '涓�') {
- Jstage.Piecenumber = Jstage.Piecenumber + 1;
- }
- if (CountDel[i].hospitalSpecialOffer__c) {
- Jstage.hospitalSpecialOffer = true;
- } else {
- Jstage.hospitalSpecialOffer = false;
- }
- if (HosProMap.containsKey(Jstage.Prod.Id)) {
- Jstage.hosPro = true;
- }
- MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
- } else {
- //midmap2涓病鏈夊搴旂殑浜у搧
- ConsumableorderdetailsInfo Jstage = MidMap.get(CountDel[i].Consumable_Product__c).clone();
- Jstage.allnumber = Jstage.allnumber + 1;
- if (CountDel[i].Box_Piece__c == '鐩�') {
- Jstage.Boxnumber = Jstage.Boxnumber + 1;
- } else if (CountDel[i].Box_Piece__c == '涓�') {
- Jstage.Piecenumber = Jstage.Piecenumber + 1;
- }
- if (CountDel[i].hospitalSpecialOffer__c) {
- Jstage.hospitalSpecialOffer = true;
- } else {
- Jstage.hospitalSpecialOffer = false;
- }
- if (HosProMap.containsKey(Jstage.Prod.Id)) {
- Jstage.hosPro = true;
- }
- //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
- MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
- }
- }
- System.debug('MidMap2.size() = ' + MidMap2.size());
- /*//鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
+ System.debug('MidMap2.size() = ' + MidMap2.size());
+ /*//鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
if(MidMap.containsKey(CountDel[i].Consumable_Product__c)){
ConsumableorderdetailsInfo Jstage = MidMap.get(CountDel[i].Consumable_Product__c);
Jstage.allnumber = Jstage.allnumber+1 ;
@@ -452,135 +509,144 @@
//Jstage.BoxPiece = CountDel[i].Box_Piece__c;
MidMap.put(CountDel[i].Consumable_Product__c+str, Jstage);
}*/
- }
+ }
- //update by rentx 2021-01-29 end
+ //update by rentx 2021-01-29 end
- //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecords
- //update by rentx 2021-01-29
- // for(ConsumableorderdetailsInfo bss : MidMap.values()){
- for (ConsumableorderdetailsInfo bss : MidMap2.values()) {
- //update by rentx 2021-01-29
- //if(bss.allnumber>0){
- bss.packinglist = Integer.valueOf(bss.Prod.Product2__r.Packing_list_manual__c);
- bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
- bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
- consumableorderdetailsSelectRecords.add(bss);
- //}
- }
+ //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecords
+ //update by rentx 2021-01-29
+ // for(ConsumableorderdetailsInfo bss : MidMap.values()){
+ for (ConsumableorderdetailsInfo bss : MidMap2.values()) {
+ //update by rentx 2021-01-29
+ //if(bss.allnumber>0){
+ bss.packinglist = Integer.valueOf(
+ bss.Prod.Product2__r.Packing_list_manual__c
+ );
+ bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
+ bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
+ consumableorderdetailsSelectRecords.add(bss);
+ //}
+ }
- Integer ishosnum = 0;
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords) {
- //ass.sortBy = sortOrderAsc;
- //add by rentx 2021-3-10
- if (ass.hospitalSpecialOffer) {
- ishosnum = ishosnum + 1;
- }
- }
- if (ishosnum > 0) {
- hasHosPro = true;
- } else {
- hasHosPro = false;
- }
- consumableorderdetailsSelectRecords.sort();
- //add by rentx
- noOfRecords = consumableorderdetailsSelectRecords.size();
- //add by rentx
- System.debug('makepagerecords1');
- makepagerecords();
- //listCut();
- } else {
- if (statusEdit == '' || statusEdit == null) {
- editAble = false;
- } else if (statusEdit != '' && statusEdit != null) {
- editAble = true;
- }
- // upadte start by vivek 2019-7-15
- // coc = [SELECT Id,Name,Summons_Order_type__c,SummonsStatus_c__c,Order_ForDealerText__c,
- // Dealer_Info__c,Order_ForDealer__c,Order_ForDealer__r.Name,Order_ForDealerTextID__c,
- // Order_ForHospital__c,SummonsForDirction__c,Order_date__c,Arrive_Order__c,
- // Order_status__c,Shipment_total_amount__c,Offers_Price__c,
- // Billed_Status__c,ShipmentAccount__c,Order_Dealer_Info__c,Order_ForCustomerText__c,ConInvoice_Code__c,Onchange_order__c
- // FROM Consumable_order__c
- // WHERE Id =:arriveorder AND Order_Owner_WorkLocal__c =: userWorkLocation
- // AND recordtypeid = :System.Label.RT_ConOrder_Arrive];
- coc = [
- SELECT
- Id,
- Name,
- Summons_Order_type__c,
- NoConfirmedPrice__c,
- SummonsStatus_c__c,
- Order_ForDealerText__c,
- Dealer_Info__c,
- Order_ForDealer__c,
- Order_ForDealer__r.Name,
- Order_ForDealerTextID__c,
- Order_ForHospital__c,
- SummonsForDirction__c,
- Order_date__c,
- Arrive_Order__c,
- Order_status__c,
- Shipment_total_amount__c,
- Offers_Price__c,
- Billed_Status__c,
- ShipmentAccount__c,
- Order_Dealer_Info__c,
- Order_ForCustomerText__c,
- ConInvoice_Code__c,
- Onchange_order__c,
- OutPattern__c
- FROM Consumable_order__c
- WHERE
- Id = :arriveorder
- AND Order_Owner_WorkLocal__c = :userWorkLocation
- AND recordtypeid = :System.Label.RT_ConOrder_Arrive
- ];
- // update end by vivek 2019-7-15
- //鏄庣粏1鑾峰彇
- consumableorderdetailsSelected = [
- SELECT
- Id,
- Dealer_Custom_Price__c,
- Delivery_List_RMB__c,
- Consumable_Product__r.Name__c,
- Name,
- Consumable_order__c,
- Consumable_Product__c,
- Consumable_Product__r.Name,
- Consumable_Product__r.Category3__c,
- Consumable_Product__r.Category4__c,
- Consumable_Product__r.Category5__c,
- Shipment_Count__c,
- Consumable_Product__r.Intra_Trade_List_RMB__c,
- Consumable_Product__r.Asset_Model_No__c,
- Sum_of_money__c,
- Box_Piece__c,
- ProductPacking_list_manual__c,
- Consumable_Product__r.SFDA_Status__c,
- Consumable_count__c,
- Invoiced_Procount__c,
- RrturnPro_count__c,
- InvoiceProNot_count__c,
- //Unitprice_To_agency__c,
- Consumable_Product__r.Product2__r.SFDA_Approbation_No__c,
- Consumable_Product__r.Product2__r.SFDA_Expiration_Date__c
- FROM Consumable_Orderdetails__c
- WHERE Consumable_order__c = :coc.Arrive_Order__c
- ORDER BY Name
- ];
- for (Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected) {
- orderzaikuId.add(cdc1.Consumable_Product__c);
- }
- msoql = makeSoqlorderdet();
- product2Selected = Database.query(msoql);
- size = product2Selected.size();
- initStandardController(msoql);
- for (Integer i = 0; i < product2Selected.size(); i++) {
- MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
- }
- //update by rentx 2021-01-29
- /*for(Integer i = 0 ; i< CountDel.size();i++){
+ Integer ishosnum = 0;
+ for (
+ ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords
+ ) {
+ //ass.sortBy = sortOrderAsc;
+ //add by rentx 2021-3-10
+ if (ass.hospitalSpecialOffer) {
+ ishosnum = ishosnum + 1;
+ }
+ }
+ if (ishosnum > 0) {
+ hasHosPro = true;
+ } else {
+ hasHosPro = false;
+ }
+ consumableorderdetailsSelectRecords.sort();
+ //add by rentx
+ noOfRecords = consumableorderdetailsSelectRecords.size();
+ //add by rentx
+ System.debug('makepagerecords1');
+ makepagerecords();
+ //listCut();
+ } else {
+ if (statusEdit == '' || statusEdit == null) {
+ editAble = false;
+ } else if (statusEdit != '' && statusEdit != null) {
+ editAble = true;
+ }
+ // upadte start by vivek 2019-7-15
+ // coc = [SELECT Id,Name,Summons_Order_type__c,SummonsStatus_c__c,Order_ForDealerText__c,
+ // Dealer_Info__c,Order_ForDealer__c,Order_ForDealer__r.Name,Order_ForDealerTextID__c,
+ // Order_ForHospital__c,SummonsForDirction__c,Order_date__c,Arrive_Order__c,
+ // Order_status__c,Shipment_total_amount__c,Offers_Price__c,
+ // Billed_Status__c,ShipmentAccount__c,Order_Dealer_Info__c,Order_ForCustomerText__c,ConInvoice_Code__c,Onchange_order__c
+ // FROM Consumable_order__c
+ // WHERE Id =:arriveorder AND Order_Owner_WorkLocal__c =: userWorkLocation
+ // AND recordtypeid = :System.Label.RT_ConOrder_Arrive];
+ coc = [
+ SELECT
+ Id,
+ Name,
+ Summons_Order_type__c,
+ NoConfirmedPrice__c,
+ SummonsStatus_c__c,
+ Order_ForDealerText__c,
+ Dealer_Info__c,
+ Order_ForDealer__c,
+ Order_ForDealer__r.Name,
+ Order_ForDealerTextID__c,
+ Order_ForHospital__c,
+ SummonsForDirction__c,
+ Order_date__c,
+ Arrive_Order__c,
+ Order_status__c,
+ Shipment_total_amount__c,
+ Offers_Price__c,
+ Billed_Status__c,
+ ShipmentAccount__c,
+ Order_Dealer_Info__c,
+ Order_ForCustomerText__c,
+ ConInvoice_Code__c,
+ Onchange_order__c,
+ OutPattern__c
+ FROM Consumable_order__c
+ WHERE
+ Id = :arriveorder
+ AND Order_Owner_WorkLocal__c = :userWorkLocation
+ AND recordtypeid = :System.Label.RT_ConOrder_Arrive
+ ];
+ // update end by vivek 2019-7-15
+ //鏄庣粏1鑾峰彇
+ consumableorderdetailsSelected = [
+ SELECT
+ Id,
+ Dealer_Custom_Price__c,
+ Delivery_List_RMB__c,
+ Consumable_Product__r.Name__c,
+ Name,
+ Consumable_order__c,
+ Consumable_Product__c,
+ Consumable_Product__r.Name,
+ Consumable_Product__r.Category3__c,
+ Consumable_Product__r.Category4__c,
+ Consumable_Product__r.Category5__c,
+ Shipment_Count__c,
+ Consumable_Product__r.Intra_Trade_List_RMB__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Sum_of_money__c,
+ Box_Piece__c,
+ ProductPacking_list_manual__c,
+ Consumable_Product__r.SFDA_Status__c,
+ Consumable_count__c,
+ Invoiced_Procount__c,
+ RrturnPro_count__c,
+ InvoiceProNot_count__c,
+ //Unitprice_To_agency__c,
+ Consumable_Product__r.Product2__r.SFDA_Approbation_No__c,
+ Consumable_Product__r.Product2__r.SFDA_Expiration_Date__c
+ FROM Consumable_Orderdetails__c
+ WHERE Consumable_order__c = :coc.Arrive_Order__c
+ ORDER BY Name
+ ];
+ for (
+ Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected
+ ) {
+ orderzaikuId.add(cdc1.Consumable_Product__c);
+ }
+ msoql = makeSoqlorderdet();
+ product2Selected = Database.query(msoql);
+ size = product2Selected.size();
+ initStandardController(msoql);
+ for (Integer i = 0; i < product2Selected.size(); i++) {
+ MidMap.put(
+ product2Selected[i].Id,
+ new ConsumableorderdetailsInfo(product2Selected[i])
+ );
+ }
+ //update by rentx 2021-01-29
+ /*for(Integer i = 0 ; i< CountDel.size();i++){
//鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
if(MidMap.containsKey(CountDel[i].Consumable_Product__c)){
ConsumableorderdetailsInfo Jstage = MidMap.get(CountDel[i].Consumable_Product__c);
@@ -595,275 +661,327 @@
}
}*/
- for (Integer i = 0; i < CountDel.size(); i++) {
- String str = '';
- if (CountDel[i].hospitalSpecialOffer__c) {
- str = 'isHos';
- } else {
- str = 'notHos';
- }
- //鏄庣粏2瀵瑰簲鐨勪骇鍝佸瓨鍦ㄤ簬MidMap涓�
- if (MidMap.containsKey(CountDel[i].Consumable_Product__c)) {
- //璁剧疆map涓璳ey鐨勫悗缂� 鐢ㄤ簬鍖哄垎鍖婚櫌鐗逛环鍜岄潪鍖婚櫌鐗逛环
- if (MidMap2.containsKey(CountDel[i].Consumable_Product__c + str)) {
- ConsumableorderdetailsInfo Jstage = MidMap2.get(CountDel[i].Consumable_Product__c + str);
- Jstage.allnumber = Jstage.allnumber + 1;
- if (CountDel[i].Box_Piece__c == '鐩�') {
- Jstage.Boxnumber = Jstage.Boxnumber + 1;
- } else if (CountDel[i].Box_Piece__c == '涓�') {
- Jstage.Piecenumber = Jstage.Piecenumber + 1;
- }
- if (CountDel[i].hospitalSpecialOffer__c) {
- Jstage.hospitalSpecialOffer = true;
- } else {
- Jstage.hospitalSpecialOffer = false;
- }
-
- if (HosProMap.containsKey(Jstage.Prod.Id)) {
- Jstage.hosPro = true;
- }
- MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
- } else {
- //midmap2涓病鏈夊搴旂殑浜у搧
- ConsumableorderdetailsInfo Jstage = MidMap.get(CountDel[i].Consumable_Product__c).clone();
- Jstage.allnumber = Jstage.allnumber + 1;
- if (CountDel[i].Box_Piece__c == '鐩�') {
- Jstage.Boxnumber = Jstage.Boxnumber + 1;
- } else if (CountDel[i].Box_Piece__c == '涓�') {
- Jstage.Piecenumber = Jstage.Piecenumber + 1;
- }
- if (CountDel[i].hospitalSpecialOffer__c) {
- Jstage.hospitalSpecialOffer = true;
- } else {
- Jstage.hospitalSpecialOffer = false;
- }
-
- if (HosProMap.containsKey(Jstage.Prod.Id)) {
- Jstage.hosPro = true;
- }
- //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
- MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
- }
- }
- }
-
- //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecords
- //update by rentx 2021-01-29
- // for(ConsumableorderdetailsInfo bss : MidMap.values()){
- for (ConsumableorderdetailsInfo bss : MidMap2.values()) {
- //update by rentx 2021-01-29
- bss.packinglist = Integer.valueOf(bss.Prod.Product2__r.Packing_list_manual__c);
- bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
- bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
- consumableorderdetailsSelectRecords.add(bss);
- }
- //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'test11111' + consumableorderdetailsSelected.size()));
- //return;
-
- Integer ishosnum = 0;
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords) {
- //ass.sortBy = sortOrderAsc;
- for (Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected) {
- cdc1.Shipment_Count__c = cdc1.Consumable_count__c;
- if (ass.prod.Id == cdc1.Consumable_Product__c) {
- ass.check = true;
- ass.orderdetails1 = cdc1;
- }
- }
- if (ass.hospitalSpecialOffer == true) {
- ishosnum = ishosnum + 1;
- }
- }
- if (ishosnum > 0) {
- hasHosPro = true;
- } else {
- hasHosPro = false;
- }
-
- consumableorderdetailsSelectRecords.sort();
- //add by rentx
- noOfRecords = consumableorderdetailsSelectRecords.size();
- //add by rentx
- System.debug('makepagerecords2');
- makepagerecords();
- consumablearriveproductdetailsSelected = [
- 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.Category3__c,
- Consumable_Product__r.Category4__c,
- Consumable_Product__r.Category5__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,
- Delivery_List_RMB__c,
- Box_Piece__c,
- ProductPacking_list_manual__c,
- //add by rentx start
- hospitalSpecialOffer__c
- //add by rentx end
- FROM Consumable_order_details2__c
- WHERE
- Consumable_order_minor__c = :coc.Arrive_Order__c
- AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
- AND Dealer_Arrive__c = TRUE
- ORDER BY Name
- ];
- for (Integer i = 0; i < consumablearriveproductdetailsSelected.size(); i++) {
- if (
- consumablearriveproductdetailsSelected[i].hospitalSpecialOffer__c &&
- HosProMap.containsKey(consumablearriveproductdetailsSelected[i].Consumable_product__c)
- ) {
- coc.OutPattern__c = true;
- }
- consumableproductdetailsRecords.add(new ConsumableorderdetailsInfo(consumablearriveproductdetailsSelected[i]));
- }
- }
+ for (Integer i = 0; i < CountDel.size(); i++) {
+ String str = '';
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ str = 'isHos';
} else {
- // 鏇存柊銆�
- SummonsFlag = 'visible';
- // update start by vivek 2019-7-15 add 鈥淣oConfirmedPrice__c鈥� in select
- consumableInvoiceRecords = [
- SELECT Id, Name, Invoice_Date__c, NoConfirmedPrice__c, Invoice_total_amount__c, Invoice_status__c
- FROM Consumable_order__c
- WHERE
- Id IN (SELECT Invoice_Code_link__c FROM Consumable_order_LinkTable__c WHERE Outboundorder_Code_link__c = :ESetId)
- AND Invoice_status__c != '鑽夋涓�'
- ];
-
- System.debug('coc ESetId = ' + ESetId);
- System.debug('coc userWorkLocation = ' + userWorkLocation);
- coc = [
- SELECT
- Id,
- Name,
- Summons_Order_type__c,
- NoConfirmedPrice__c,
- SummonsStatus_c__c,
- Order_ForDealerText__c,
- Dealer_Info__c,
- Order_ForDealer__c,
- Order_ForDealer__r.Name,
- Order_ForDealerTextID__c,
- Order_ForHospital__c,
- SummonsForDirction__c,
- Order_date__c,
- Arrive_Order__c,
- Order_status__c,
- Shipment_total_amount__c,
- Offers_Price__c,
- Billed_Status__c,
- ShipmentAccount__c,
- Order_Dealer_Info__c,
- Order_ForCustomerText__c,
- ConInvoice_Code__c,
- Onchange_order__c,
- OutPattern__c
- FROM Consumable_order__c
- WHERE Id = :ESetId AND Order_Owner_WorkLocal__c = :userWorkLocation AND Order_type__c = '浼犵エ'
- ];
- // update start by vivek 2019-7-15
- if (getExistarrive()) {
- arriveorder = coc.Arrive_Order__c;
+ str = 'notHos';
+ }
+ //鏄庣粏2瀵瑰簲鐨勪骇鍝佸瓨鍦ㄤ簬MidMap涓�
+ if (MidMap.containsKey(CountDel[i].Consumable_Product__c)) {
+ //璁剧疆map涓璳ey鐨勫悗缂� 鐢ㄤ簬鍖哄垎鍖婚櫌鐗逛环鍜岄潪鍖婚櫌鐗逛环
+ if (
+ MidMap2.containsKey(CountDel[i].Consumable_Product__c + str)
+ ) {
+ ConsumableorderdetailsInfo Jstage = MidMap2.get(
+ CountDel[i].Consumable_Product__c + str
+ );
+ Jstage.allnumber = Jstage.allnumber + 1;
+ if (CountDel[i].Box_Piece__c == '鐩�') {
+ Jstage.Boxnumber = Jstage.Boxnumber + 1;
+ } else if (CountDel[i].Box_Piece__c == '涓�') {
+ Jstage.Piecenumber = Jstage.Piecenumber + 1;
}
- // 鍒拌揣璁㈠崟鏉ョ殑鏃跺��
- if (getExistarrive()) {
- if (editAble) {
- alertMessage = '鍒拌揣璁㈠崟鐩存帴鍑哄簱锛屽嚭搴撳崟鏄庣粏涓嶅彲缂栬緫';
- }
- if (coc.SummonsStatus_c__c == '宸叉彁浜�' || coc.SummonsStatus_c__c == '鎵瑰噯') {
- system.debug('coc.SummonsStatus_c__c : ' + coc.SummonsStatus_c__c);
- saveBtnDisabled = true;
- SorderBtnDisabled = true;
- EditDelCommitBtnDisabled = false;
- }
- //鍖婚櫌浜岀骇缁忛攢鍟嗗垎绫�
- Integer io = 0;
- while (io < Dealerelationship.size()) {
- if (coc.Order_ForDealer__c == Dealerelationship[io].Dealer_subordinate__c) {
- SecondDealer = Dealerelationship[io].Dealer_subordinate__c;
- coc.Order_ForDealer__c = null;
- io = io + Dealerelationship.size();
- }
- io++;
- }
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ Jstage.hospitalSpecialOffer = true;
+ } else {
+ Jstage.hospitalSpecialOffer = false;
+ }
- Integer ik = 0;
- while (ik < AgencyHospitalLink.size()) {
- if (coc.Order_ForHospital__c == AgencyHospitalLink[ik].Hospital__c) {
- HospitalInfo = AgencyHospitalLink[ik].Hospital__c;
- HospitalName = AgencyHospitalLink[ik].Hospital__r.Name;
- coc.Order_ForHospital__c = null;
- ik = ik + AgencyHospitalLink.size();
- }
- ik++;
- }
- //鍑哄簱鍗曟槑缁�1鍙栧緱
- consumableorderdetailsSelected = [
- SELECT
- Id,
- Dealer_Custom_Price__c,
- Delivery_List_RMB__c,
- Consumable_Product__r.Name__c,
- Consumable_Product__r.SFDA_Status__c,
- Name,
- Consumable_order__c,
- Consumable_Product__c,
- Consumable_Product__r.Name,
- Shipment_Count__c,
- Consumable_Product__r.Intra_Trade_List_RMB__c,
- Consumable_Product__r.Asset_Model_No__c,
- Consumable_Product__r.Category3__c,
- Consumable_Product__r.Category4__c,
- Consumable_Product__r.Category5__c,
- Shipment_amount__c,
- //Unitprice_To_agency__c,
- Box_Piece__c,
- ProductPacking_list_manual__c,
- Invoiced_Procount__c,
- RrturnPro_count__c,
- InvoiceProNot_count__c,
- Consumable_Product__r.Product2__r.SFDA_Approbation_No__c,
- Consumable_Product__r.Product2__r.SFDA_Expiration_Date__c,
- isOutPattern__c
- FROM Consumable_orderdetails__c
- WHERE Consumable_order__c = :ESetId AND Consumable_order__r.Order_Owner_WorkLocal__c = :userWorkLocation
- ORDER BY Name
- ];
- Map<String, Consumable_Orderdetails__c> cocMap = new Map<String, Consumable_Orderdetails__c>();
+ if (HosProMap.containsKey(Jstage.Prod.Id)) {
+ Jstage.hosPro = true;
+ }
+ MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
+ } else {
+ //midmap2涓病鏈夊搴旂殑浜у搧
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ CountDel[i].Consumable_Product__c
+ )
+ .clone();
+ Jstage.allnumber = Jstage.allnumber + 1;
+ if (CountDel[i].Box_Piece__c == '鐩�') {
+ Jstage.Boxnumber = Jstage.Boxnumber + 1;
+ } else if (CountDel[i].Box_Piece__c == '涓�') {
+ Jstage.Piecenumber = Jstage.Piecenumber + 1;
+ }
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ Jstage.hospitalSpecialOffer = true;
+ } else {
+ Jstage.hospitalSpecialOffer = false;
+ }
- for (Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected) {
- sumPrice += cdc1.Shipment_amount__c;
- orderzaikuId.add(cdc1.Consumable_Product__c);
- //add by rentx 2021-2-26
- String tempId = cdc1.Consumable_product__c;
- if (cdc1.isOutPattern__c) {
- cocMap.put(tempId + 'ishos', cdc1);
- } else {
- cocMap.put(tempId + 'nothos', cdc1);
- }
- //add by rentx 2021-2-26
- }
- String msoql = makeSoqlorderdet();
- product2Selected = Database.query(msoql);
- size = product2Selected.size();
- initStandardController(msoql);
+ if (HosProMap.containsKey(Jstage.Prod.Id)) {
+ Jstage.hosPro = true;
+ }
+ //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+ MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
+ }
+ }
+ }
- for (Integer i = 0; i < product2Selected.size(); i++) {
- MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
- }
- //update by rentx 2021-01-29
- /*for(Integer i = 0 ; i< CountDel.size();i++){
+ //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecords
+ //update by rentx 2021-01-29
+ // for(ConsumableorderdetailsInfo bss : MidMap.values()){
+ for (ConsumableorderdetailsInfo bss : MidMap2.values()) {
+ //update by rentx 2021-01-29
+ bss.packinglist = Integer.valueOf(
+ bss.Prod.Product2__r.Packing_list_manual__c
+ );
+ bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
+ bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
+ consumableorderdetailsSelectRecords.add(bss);
+ }
+ //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'test11111' + consumableorderdetailsSelected.size()));
+ //return;
+
+ Integer ishosnum = 0;
+ for (
+ ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords
+ ) {
+ //ass.sortBy = sortOrderAsc;
+ for (
+ Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected
+ ) {
+ cdc1.Shipment_Count__c = cdc1.Consumable_count__c;
+ if (ass.prod.Id == cdc1.Consumable_Product__c) {
+ ass.check = true;
+ ass.orderdetails1 = cdc1;
+ }
+ }
+ if (ass.hospitalSpecialOffer == true) {
+ ishosnum = ishosnum + 1;
+ }
+ }
+ if (ishosnum > 0) {
+ hasHosPro = true;
+ } else {
+ hasHosPro = false;
+ }
+
+ consumableorderdetailsSelectRecords.sort();
+ //add by rentx
+ noOfRecords = consumableorderdetailsSelectRecords.size();
+ //add by rentx
+ System.debug('makepagerecords2');
+ makepagerecords();
+ consumablearriveproductdetailsSelected = [
+ 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.Category3__c,
+ Consumable_Product__r.Category4__c,
+ Consumable_Product__r.Category5__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,
+ Delivery_List_RMB__c,
+ Box_Piece__c,
+ ProductPacking_list_manual__c,
+ //add by rentx start
+ hospitalSpecialOffer__c
+ //add by rentx end
+ FROM Consumable_order_details2__c
+ WHERE
+ Consumable_order_minor__c = :coc.Arrive_Order__c
+ AND recordtypeid = :System.Label.RT_ConOrderDetail2_Delivery
+ AND Dealer_Arrive__c = TRUE
+ ORDER BY Name
+ ];
+ for (
+ Integer i = 0;
+ i < consumablearriveproductdetailsSelected.size();
+ i++
+ ) {
+ if (
+ consumablearriveproductdetailsSelected[i]
+ .hospitalSpecialOffer__c &&
+ HosProMap.containsKey(
+ consumablearriveproductdetailsSelected[i].Consumable_product__c
+ )
+ ) {
+ coc.OutPattern__c = true;
+ }
+ consumableproductdetailsRecords.add(
+ new ConsumableorderdetailsInfo(
+ consumablearriveproductdetailsSelected[i]
+ )
+ );
+ }
+ }
+ } else {
+ // 鏇存柊銆�
+ SummonsFlag = 'visible';
+ // update start by vivek 2019-7-15 add 鈥淣oConfirmedPrice__c鈥� in select
+ consumableInvoiceRecords = [
+ SELECT
+ Id,
+ Name,
+ Invoice_Date__c,
+ NoConfirmedPrice__c,
+ Invoice_total_amount__c,
+ Invoice_status__c
+ FROM Consumable_order__c
+ WHERE
+ Id IN (
+ SELECT Invoice_Code_link__c
+ FROM Consumable_order_LinkTable__c
+ WHERE Outboundorder_Code_link__c = :ESetId
+ )
+ AND Invoice_status__c != '鑽夋涓�'
+ ];
+
+ System.debug('coc ESetId = ' + ESetId);
+ System.debug('coc userWorkLocation = ' + userWorkLocation);
+ coc = [
+ SELECT
+ Id,
+ Name,
+ Summons_Order_type__c,
+ NoConfirmedPrice__c,
+ SummonsStatus_c__c,
+ Order_ForDealerText__c,
+ Dealer_Info__c,
+ Order_ForDealer__c,
+ Order_ForDealer__r.Name,
+ Order_ForDealerTextID__c,
+ Order_ForHospital__c,
+ SummonsForDirction__c,
+ Order_date__c,
+ Arrive_Order__c,
+ Order_status__c,
+ Shipment_total_amount__c,
+ Offers_Price__c,
+ Billed_Status__c,
+ ShipmentAccount__c,
+ Order_Dealer_Info__c,
+ Order_ForCustomerText__c,
+ ConInvoice_Code__c,
+ Onchange_order__c,
+ OutPattern__c
+ FROM Consumable_order__c
+ WHERE
+ Id = :ESetId
+ AND Order_Owner_WorkLocal__c = :userWorkLocation
+ AND Order_type__c = '浼犵エ'
+ ];
+ // update start by vivek 2019-7-15
+ if (getExistarrive()) {
+ arriveorder = coc.Arrive_Order__c;
+ }
+ // 鍒拌揣璁㈠崟鏉ョ殑鏃跺��
+ if (getExistarrive()) {
+ if (editAble) {
+ alertMessage = '鍒拌揣璁㈠崟鐩存帴鍑哄簱锛屽嚭搴撳崟鏄庣粏涓嶅彲缂栬緫';
+ }
+ if (
+ coc.SummonsStatus_c__c == '宸叉彁浜�' ||
+ coc.SummonsStatus_c__c == '鎵瑰噯'
+ ) {
+ system.debug('coc.SummonsStatus_c__c : ' + coc.SummonsStatus_c__c);
+ saveBtnDisabled = true;
+ SorderBtnDisabled = true;
+ EditDelCommitBtnDisabled = false;
+ }
+ //鍖婚櫌浜岀骇缁忛攢鍟嗗垎绫�
+ Integer io = 0;
+ while (io < Dealerelationship.size()) {
+ if (
+ coc.Order_ForDealer__c ==
+ Dealerelationship[io].Dealer_subordinate__c
+ ) {
+ SecondDealer = Dealerelationship[io].Dealer_subordinate__c;
+ coc.Order_ForDealer__c = null;
+ io = io + Dealerelationship.size();
+ }
+ io++;
+ }
+
+ Integer ik = 0;
+ while (ik < AgencyHospitalLink.size()) {
+ if (
+ coc.Order_ForHospital__c == AgencyHospitalLink[ik].Hospital__c
+ ) {
+ HospitalInfo = AgencyHospitalLink[ik].Hospital__c;
+ HospitalName = AgencyHospitalLink[ik].Hospital__r.Name;
+ coc.Order_ForHospital__c = null;
+ ik = ik + AgencyHospitalLink.size();
+ }
+ ik++;
+ }
+ //鍑哄簱鍗曟槑缁�1鍙栧緱
+ consumableorderdetailsSelected = [
+ SELECT
+ Id,
+ Dealer_Custom_Price__c,
+ Delivery_List_RMB__c,
+ Consumable_Product__r.Name__c,
+ Consumable_Product__r.SFDA_Status__c,
+ Name,
+ Consumable_order__c,
+ Consumable_Product__c,
+ Consumable_Product__r.Name,
+ Shipment_Count__c,
+ Consumable_Product__r.Intra_Trade_List_RMB__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Consumable_Product__r.Category3__c,
+ Consumable_Product__r.Category4__c,
+ Consumable_Product__r.Category5__c,
+ Shipment_amount__c,
+ //Unitprice_To_agency__c,
+ Box_Piece__c,
+ ProductPacking_list_manual__c,
+ Invoiced_Procount__c,
+ RrturnPro_count__c,
+ InvoiceProNot_count__c,
+ Consumable_Product__r.Product2__r.SFDA_Approbation_No__c,
+ Consumable_Product__r.Product2__r.SFDA_Expiration_Date__c,
+ isOutPattern__c
+ FROM Consumable_orderdetails__c
+ WHERE
+ Consumable_order__c = :ESetId
+ AND Consumable_order__r.Order_Owner_WorkLocal__c = :userWorkLocation
+ ORDER BY Name
+ ];
+ Map<String, Consumable_Orderdetails__c> cocMap = new Map<String, Consumable_Orderdetails__c>();
+
+ for (
+ Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected
+ ) {
+ sumPrice += cdc1.Shipment_amount__c;
+ orderzaikuId.add(cdc1.Consumable_Product__c);
+ //add by rentx 2021-2-26
+ String tempId = cdc1.Consumable_product__c;
+ if (cdc1.isOutPattern__c) {
+ cocMap.put(tempId + 'ishos', cdc1);
+ } else {
+ cocMap.put(tempId + 'nothos', cdc1);
+ }
+ //add by rentx 2021-2-26
+ }
+ String msoql = makeSoqlorderdet();
+ product2Selected = Database.query(msoql);
+ size = product2Selected.size();
+ initStandardController(msoql);
+
+ for (Integer i = 0; i < product2Selected.size(); i++) {
+ MidMap.put(
+ product2Selected[i].Id,
+ new ConsumableorderdetailsInfo(product2Selected[i])
+ );
+ }
+ //update by rentx 2021-01-29
+ /*for(Integer i = 0 ; i< CountDel.size();i++){
//鐒跺悗寰幆CountDel鍘讳慨鏀筸ap閲岀殑allnumber
if(MidMap.containsKey(CountDel[i].Consumable_Product__c)){
ConsumableorderdetailsInfo Jstage = MidMap.get(CountDel[i].Consumable_Product__c);
@@ -878,2119 +996,2475 @@
}
}*/
- for (Integer i = 0; i < CountDel.size(); i++) {
- String str = '';
- if (CountDel[i].hospitalSpecialOffer__c) {
- str = 'isHos';
- } else {
- str = 'notHos';
- }
- //鏄庣粏2瀵瑰簲鐨勪骇鍝佸瓨鍦ㄤ簬MidMap涓�
- if (MidMap.containsKey(CountDel[i].Consumable_Product__c)) {
- //璁剧疆map涓璳ey鐨勫悗缂� 鐢ㄤ簬鍖哄垎鍖婚櫌鐗逛环鍜岄潪鍖婚櫌鐗逛环
- if (MidMap2.containsKey(CountDel[i].Consumable_Product__c + str)) {
- ConsumableorderdetailsInfo Jstage = MidMap2.get(CountDel[i].Consumable_Product__c + str);
- Jstage.allnumber = Jstage.allnumber + 1;
- if (CountDel[i].Box_Piece__c == '鐩�') {
- Jstage.Boxnumber = Jstage.Boxnumber + 1;
- } else if (CountDel[i].Box_Piece__c == '涓�') {
- Jstage.Piecenumber = Jstage.Piecenumber + 1;
- }
- if (CountDel[i].hospitalSpecialOffer__c) {
- Jstage.hospitalSpecialOffer = true;
- } else {
- Jstage.hospitalSpecialOffer = false;
- }
-
- if (HosProMap.containsKey(Jstage.Prod.Id)) {
- Jstage.hosPro = true;
- }
- MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
- } else {
- //midmap2涓病鏈夊搴旂殑浜у搧
- ConsumableorderdetailsInfo Jstage = MidMap.get(CountDel[i].Consumable_Product__c).clone();
- Jstage.allnumber = Jstage.allnumber + 1;
- if (CountDel[i].Box_Piece__c == '鐩�') {
- Jstage.Boxnumber = Jstage.Boxnumber + 1;
- } else if (CountDel[i].Box_Piece__c == '涓�') {
- Jstage.Piecenumber = Jstage.Piecenumber + 1;
- }
- if (CountDel[i].hospitalSpecialOffer__c) {
- Jstage.hospitalSpecialOffer = true;
- } else {
- Jstage.hospitalSpecialOffer = false;
- }
- if (HosProMap.containsKey(Jstage.Prod.Id)) {
- Jstage.hosPro = true;
- }
- //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
- MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
- }
- }
- }
- //update by rentx 2021-01-29
- consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
- //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecords
- //update by rentx 2021-01-29
- // for(ConsumableorderdetailsInfo bss : MidMap.values()){
- for (ConsumableorderdetailsInfo bss : MidMap2.values()) {
- //update by rentx 2021-01-29
-
- //if(bss.allnumber > 0){
- //bss.UnitpriceToagency = bss.orderdetails1.Unitprice_To_agency__c == null || bss.orderdetails1.Unitprice_To_agency__c == 0 ? '' :bss.orderdetails1.Unitprice_To_agency__c.format();
- bss.packinglist = Integer.valueOf(bss.Prod.Product2__r.Packing_list_manual__c);
- bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
- bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
-
- //update by rentx 2021-2-26 start
- if (cocMap.containsKey(bss.Prod.Id + 'ishos') && bss.hospitalSpecialOffer == true) {
- consumableorderdetailsSelectRecords.add(bss);
- } else if (cocMap.containsKey(bss.Prod.Id + 'nothos') && bss.hospitalSpecialOffer == false) {
- consumableorderdetailsSelectRecords.add(bss);
- }
- //update by rentx 2021-2-26 end
- // consumableorderdetailsSelectRecords.add(bss);
- //}
- }
- Integer ishosnum = 0;
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords) {
- for (Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected) {
- //update by rentx 2012-3-1 start
- // if(ass.prod.Id == cdc1.Consumable_Product__c){
- // ass.check = true;
- // ass.orderdetails1 = cdc1;
- // }
- if (ass.Prod.Id == cdc1.Consumable_Product__c && ass.hospitalSpecialOffer == cdc1.isOutPattern__c) {
- ass.check = true;
- ass.orderdetails1 = cdc1;
- }
- //update by rentx 2012-3-1 end
- }
- if (ass.hospitalSpecialOffer == true) {
- ishosnum = ishosnum + 1;
- }
- }
- if (ishosnum > 0) {
- hasHosPro = true;
- } else {
- hasHosPro = false;
- }
-
- //add by rentx
- noOfRecords = consumableorderdetailsSelectRecords.size();
- //add by rentx
- System.debug('makepagerecords3');
- makepagerecords();
- //listCut();
- // 娑堣�楀搧鏄庣粏2銈掑彇寰�
- consumableorderdetails2RecordsList = [
- SELECT
- Id,
- Name,
- SerialLotNo__c,
- Consumable_Product__r.Name__c,
- TracingCode__c,
- Sterilization_limit__c,
- Consumable_Product__c,
- Consumable_Product__r.Name,
- Consumable_Product__r.Category3__c,
- Consumable_Product__r.Category4__c,
- Consumable_Product__r.Category5__c,
- Return_date__c,
- Invoice_Date__c,
- Box_Piece__c,
- ProductPacking_list_manual__c,
- //add by rentx start
- hospitalSpecialOffer__c
- //add by rentx end
- FROM Consumable_order_details2__c
- WHERE Consumable_ZS_order__c = :ESetId
- ORDER BY Name
- ];
- for (Integer i = 0; i < consumableorderdetails2RecordsList.size(); i++) {
- consumableorderdetails2Records.add(new ConsumableorderdetailsInfo(consumableorderdetails2RecordsList[i]));
- }
- //浜у搧鏄庣粏鍙栧緱
- consumablearriveproductdetailsSelected = [
- SELECT
- Id,
- Delivery_List_RMB__c,
- Consumable_Product__r.Name__c,
- Name,
- Consumable_Product__r.SFDA_Status__c,
- Consumable_Product__r.Category3__c,
- Consumable_Product__r.Category4__c,
- Consumable_Product__r.Category5__c,
- Consumable_Product__c,
- Consumable_Product__r.Name,
- Sterilization_limit__c,
- Consumable_Product__r.Intra_Trade_List_RMB__c,
- Consumable_Product__r.Asset_Model_No__c,
- Box_Piece__c,
- ProductPacking_list_manual__c,
- //add by rentx start
- hospitalSpecialOffer__c
- //add by rentx end
- FROM Consumable_order_details2__c
- WHERE Consumable_ZS_order__c = :ESetId
- ORDER BY Name
- ];
- for (Integer i = 0; i < consumablearriveproductdetailsSelected.size(); i++) {
- consumableproductdetailsRecords.add(new ConsumableorderdetailsInfo(consumablearriveproductdetailsSelected[i]));
- }
- } else {
- // 涓嶆槸鍒拌揣璁㈠崟鏉ョ殑鏃跺��
- if (coc.SummonsStatus_c__c == '宸叉彁浜�' || coc.SummonsStatus_c__c == '鎵瑰噯') {
- system.debug('coc.SummonsStatus_c__c : ' + coc.SummonsStatus_c__c);
- saveBtnDisabled = true;
- SorderBtnDisabled = true;
- EditDelCommitBtnDisabled = false;
- }
- //鍖婚櫌浜岀骇缁忛攢鍟嗗垎绫�
- Integer io = 0;
- while (io < Dealerelationship.size()) {
- if (coc.Order_ForDealer__c == Dealerelationship[io].Dealer_subordinate__c) {
- SecondDealer = Dealerelationship[io].Dealer_subordinate__c;
- coc.Order_ForDealer__c = null;
- io = io + Dealerelationship.size();
- }
- io++;
- }
- Integer ik = 0;
- while (ik < AgencyHospitalLink.size()) {
- if (coc.Order_ForHospital__c == AgencyHospitalLink[ik].Hospital__c) {
- HospitalInfo = AgencyHospitalLink[ik].Hospital__c;
- HospitalName = AgencyHospitalLink[ik].Hospital__r.Name;
- coc.Order_ForHospital__c = null;
- ik = ik + AgencyHospitalLink.size();
- }
- ik++;
- }
- // 娑堣�楀搧鏄庣粏1銈掑彇寰�
- consumableorderdetailsSelected = [
- SELECT
- Id,
- Dealer_Custom_Price__c,
- Delivery_List_RMB__c,
- Consumable_Product__r.Name__c,
- Consumable_Product__r.SFDA_Status__c,
- Name,
- Consumable_order__c,
- Consumable_Product__c,
- Consumable_Product__r.Name,
- Shipment_Count__c,
- Consumable_Product__r.Intra_Trade_List_RMB__c,
- Consumable_Product__r.Asset_Model_No__c,
- Shipment_amount__c,
- Box_Piece__c,
- ProductPacking_list_manual__c,
- Invoiced_Procount__c,
- RrturnPro_count__c,
- //Unitprice_To_agency__c,
- InvoiceProNot_count__c,
- Consumable_Product__r.Category3__c,
- Consumable_Product__r.Category4__c,
- Consumable_Product__r.Category5__c,
- Consumable_Product__r.Product2__r.SFDA_Approbation_No__c,
- Consumable_Product__r.Product2__r.SFDA_Expiration_Date__c,
- isOutPattern__c
- FROM Consumable_orderdetails__c
- WHERE Consumable_order__c = :ESetId AND Consumable_order__r.Order_Owner_WorkLocal__c = :userWorkLocation
- ORDER BY Name
- ];
- //add by rentx 202-2-26
- Map<String, Consumable_Orderdetails__c> cocMap = new Map<String, Consumable_Orderdetails__c>();
-
- for (Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected) {
- sumPrice += cdc1.Shipment_amount__c;
- orderzaikuId.add(cdc1.Consumable_Product__c);
- //add by rentx 2021-2-26
- String tempId = cdc1.Consumable_product__c;
- if (cdc1.isOutPattern__c) {
- cocMap.put(tempId + 'ishos', cdc1);
- } else {
- cocMap.put(tempId + 'nothos', cdc1);
- }
- //add by rentx 2021-2-26
- }
-
- String msoql = makeSoqlorderdet();
- product2Selected = Database.query(msoql);
- size = product2Selected.size();
- initStandardController(msoql);
- for (Integer i = 0; i < product2Selected.size(); i++) {
- MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
- }
-
- for (Integer i = 0; i < CountDel.size(); i++) {
- String str = '';
- if (CountDel[i].hospitalSpecialOffer__c) {
- str = 'isHos';
- } else {
- str = 'notHos';
- }
- //鏄庣粏2瀵瑰簲鐨勪骇鍝佸瓨鍦ㄤ簬MidMap涓�
- if (MidMap.containsKey(CountDel[i].Consumable_Product__c)) {
- //璁剧疆map涓璳ey鐨勫悗缂� 鐢ㄤ簬鍖哄垎鍖婚櫌鐗逛环鍜岄潪鍖婚櫌鐗逛环
- if (MidMap2.containsKey(CountDel[i].Consumable_Product__c + str)) {
- ConsumableorderdetailsInfo Jstage = MidMap2.get(CountDel[i].Consumable_Product__c + str);
- Jstage.allnumber = Jstage.allnumber + 1;
- if (CountDel[i].Box_Piece__c == '鐩�') {
- Jstage.Boxnumber = Jstage.Boxnumber + 1;
- } else if (CountDel[i].Box_Piece__c == '涓�') {
- Jstage.Piecenumber = Jstage.Piecenumber + 1;
- }
- if (CountDel[i].hospitalSpecialOffer__c) {
- Jstage.hospitalSpecialOffer = true;
- } else {
- Jstage.hospitalSpecialOffer = false;
- }
- if (HosProMap.containsKey(Jstage.Prod.Id)) {
- Jstage.hosPro = true;
- }
- MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
- } else {
- //midmap2涓病鏈夊搴旂殑浜у搧
- ConsumableorderdetailsInfo Jstage = MidMap.get(CountDel[i].Consumable_Product__c).clone();
- Jstage.allnumber = Jstage.allnumber + 1;
- if (CountDel[i].Box_Piece__c == '鐩�') {
- Jstage.Boxnumber = Jstage.Boxnumber + 1;
- } else if (CountDel[i].Box_Piece__c == '涓�') {
- Jstage.Piecenumber = Jstage.Piecenumber + 1;
- }
-
- if (CountDel[i].hospitalSpecialOffer__c) {
- Jstage.hospitalSpecialOffer = true;
- } else {
- Jstage.hospitalSpecialOffer = false;
- }
- if (HosProMap.containsKey(Jstage.Prod.Id)) {
- Jstage.hosPro = true;
- }
- Jstage.BoxPiece = CountDel[i].Box_Piece__c;
- MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
- }
- }
- }
-
- //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecords
- //update by rentx 2021-01-29
- // for(ConsumableorderdetailsInfo bss : MidMap.values()){
- for (ConsumableorderdetailsInfo bss : MidMap2.values()) {
- //update by rentx 2021-01-29
-
- //if(bss.allnumber>0){
- bss.packinglist = Integer.valueOf(bss.Prod.Product2__r.Packing_list_manual__c);
- bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
- bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
-
- //update by rentx 2021-2-26 start
- if (cocMap.containsKey(bss.Prod.Id + 'ishos') && bss.hospitalSpecialOffer == true) {
- consumableorderdetailsSelectRecords.add(bss);
- } else if (cocMap.containsKey(bss.Prod.Id + 'nothos') && bss.hospitalSpecialOffer == false) {
- consumableorderdetailsSelectRecords.add(bss);
- }
- // consumableorderdetailsSelectRecords.add(bss);
- //}
- }
- // return null;
- Integer ishosnum = 0;
- for (ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords) {
- //ass.sortBy = sortOrderAsc;
- for (Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected) {
- //update by rentx 2012-3-1 start
- // if(ass.prod.Id == cdc1.Consumable_Product__c){
- // ass.check = true;
- // ass.orderdetails1 = cdc1;
- // }
- if (ass.Prod.Id == cdc1.Consumable_Product__c && ass.hospitalSpecialOffer == cdc1.isOutPattern__c) {
- ass.check = true;
- ass.orderdetails1 = cdc1;
- }
- //update by rentx 2012-3-1 end
- }
-
- if (ass.hospitalSpecialOffer == true) {
- ishosnum = ishosnum + 1;
- }
- }
-
- if (ishosnum > 0) {
- hasHosPro = true;
- } else {
- hasHosPro = false;
- }
-
- consumableorderdetailsSelectRecords.sort();
- //add by rentx
- noOfRecords = consumableorderdetailsSelectRecords.size();
- //add by rentx
- System.debug('makepagerecords4');
- makepagerecords();
-
- // 娑堣�楀搧鏄庣粏2銈掑彇寰�
- consumableorderdetails2RecordsList = [
- SELECT
- Id,
- Name,
- SerialLotNo__c,
- Consumable_Product__r.Name__c,
- TracingCode__c,
- Sterilization_limit__c,
- Consumable_Product__c,
- Consumable_Product__r.Name,
- Consumable_Product__r.Category3__c,
- Consumable_Product__r.Category4__c,
- Consumable_Product__r.Category5__c,
- Return_date__c,
- Invoice_Date__c,
- Box_Piece__c,
- ProductPacking_list_manual__c,
- //add by rentx start
- hospitalSpecialOffer__c
- //add by rentx end
-
- FROM Consumable_order_details2__c
- WHERE Consumable_ZS_order__c = :ESetId
- ORDER BY Name
- ];
- for (Integer i = 0; i < consumableorderdetails2RecordsList.size(); i++) {
- consumableorderdetails2Records.add(new ConsumableorderdetailsInfo(consumableorderdetails2RecordsList[i]));
- }
- }
- }
- //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'test++++++' + SecondDealer));
- if (SecondDealer == null || SecondDealer == '') {
- provinceOpts.add(new SelectOption('', '-鏃�-'));
- provinceOptsMap.put('', '-鏃�-');
- for (Integer i = 0; i < Dealerelationship.size(); i++) {
- provinceOpts.add(
- new SelectOption(Dealerelationship[i].Dealer_subordinate__c, Dealerelationship[i].Dealer_subordinate__r.Name)
- );
- provinceOptsMap.put(Dealerelationship[i].Dealer_subordinate__c, Dealerelationship[i].Dealer_subordinate__r.Name);
- }
+ for (Integer i = 0; i < CountDel.size(); i++) {
+ String str = '';
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ str = 'isHos';
} else {
- provinceOpts.add(new SelectOption('', '-鏃�-'));
- provinceOptsMap.put('', '-鏃�-');
- for (Integer i = 0; i < Dealerelationship.size(); i++) {
- if (Dealerelationship[i].Dealer_subordinate__c == SecondDealer) {
- provinceOpts.add(
- new SelectOption(Dealerelationship[i].Dealer_subordinate__c, Dealerelationship[i].Dealer_subordinate__r.Name)
- );
- provinceOptsMap.put(Dealerelationship[i].Dealer_subordinate__c, Dealerelationship[i].Dealer_subordinate__r.Name);
- }
+ str = 'notHos';
+ }
+ //鏄庣粏2瀵瑰簲鐨勪骇鍝佸瓨鍦ㄤ簬MidMap涓�
+ if (MidMap.containsKey(CountDel[i].Consumable_Product__c)) {
+ //璁剧疆map涓璳ey鐨勫悗缂� 鐢ㄤ簬鍖哄垎鍖婚櫌鐗逛环鍜岄潪鍖婚櫌鐗逛环
+ if (
+ MidMap2.containsKey(CountDel[i].Consumable_Product__c + str)
+ ) {
+ ConsumableorderdetailsInfo Jstage = MidMap2.get(
+ CountDel[i].Consumable_Product__c + str
+ );
+ Jstage.allnumber = Jstage.allnumber + 1;
+ if (CountDel[i].Box_Piece__c == '鐩�') {
+ Jstage.Boxnumber = Jstage.Boxnumber + 1;
+ } else if (CountDel[i].Box_Piece__c == '涓�') {
+ Jstage.Piecenumber = Jstage.Piecenumber + 1;
}
- for (Integer i = 0; i < Dealerelationship.size(); i++) {
- if (Dealerelationship[i].Dealer_subordinate__c != SecondDealer) {
- provinceOpts.add(
- new SelectOption(Dealerelationship[i].Dealer_subordinate__c, Dealerelationship[i].Dealer_subordinate__r.Name)
- );
- provinceOptsMap.put(Dealerelationship[i].Dealer_subordinate__c, Dealerelationship[i].Dealer_subordinate__r.Name);
- }
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ Jstage.hospitalSpecialOffer = true;
+ } else {
+ Jstage.hospitalSpecialOffer = false;
}
+
+ if (HosProMap.containsKey(Jstage.Prod.Id)) {
+ Jstage.hosPro = true;
+ }
+ MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
+ } else {
+ //midmap2涓病鏈夊搴旂殑浜у搧
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ CountDel[i].Consumable_Product__c
+ )
+ .clone();
+ Jstage.allnumber = Jstage.allnumber + 1;
+ if (CountDel[i].Box_Piece__c == '鐩�') {
+ Jstage.Boxnumber = Jstage.Boxnumber + 1;
+ } else if (CountDel[i].Box_Piece__c == '涓�') {
+ Jstage.Piecenumber = Jstage.Piecenumber + 1;
+ }
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ Jstage.hospitalSpecialOffer = true;
+ } else {
+ Jstage.hospitalSpecialOffer = false;
+ }
+ if (HosProMap.containsKey(Jstage.Prod.Id)) {
+ Jstage.hosPro = true;
+ }
+ //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+ MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
+ }
+ }
+ }
+ //update by rentx 2021-01-29
+ consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
+ //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecords
+ //update by rentx 2021-01-29
+ // for(ConsumableorderdetailsInfo bss : MidMap.values()){
+ for (ConsumableorderdetailsInfo bss : MidMap2.values()) {
+ //update by rentx 2021-01-29
+
+ //if(bss.allnumber > 0){
+ //bss.UnitpriceToagency = bss.orderdetails1.Unitprice_To_agency__c == null || bss.orderdetails1.Unitprice_To_agency__c == 0 ? '' :bss.orderdetails1.Unitprice_To_agency__c.format();
+ bss.packinglist = Integer.valueOf(
+ bss.Prod.Product2__r.Packing_list_manual__c
+ );
+ bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
+ bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
+
+ //update by rentx 2021-2-26 start
+ if (
+ cocMap.containsKey(bss.Prod.Id + 'ishos') &&
+ bss.hospitalSpecialOffer == true
+ ) {
+ consumableorderdetailsSelectRecords.add(bss);
+ } else if (
+ cocMap.containsKey(bss.Prod.Id + 'nothos') &&
+ bss.hospitalSpecialOffer == false
+ ) {
+ consumableorderdetailsSelectRecords.add(bss);
+ }
+ //update by rentx 2021-2-26 end
+ // consumableorderdetailsSelectRecords.add(bss);
+ //}
+ }
+ Integer ishosnum = 0;
+ for (
+ ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords
+ ) {
+ for (
+ Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected
+ ) {
+ //update by rentx 2012-3-1 start
+ // if(ass.prod.Id == cdc1.Consumable_Product__c){
+ // ass.check = true;
+ // ass.orderdetails1 = cdc1;
+ // }
+ if (
+ ass.Prod.Id == cdc1.Consumable_Product__c &&
+ ass.hospitalSpecialOffer == cdc1.isOutPattern__c
+ ) {
+ ass.check = true;
+ ass.orderdetails1 = cdc1;
+ }
+ //update by rentx 2012-3-1 end
+ }
+ if (ass.hospitalSpecialOffer == true) {
+ ishosnum = ishosnum + 1;
+ }
+ }
+ if (ishosnum > 0) {
+ hasHosPro = true;
+ } else {
+ hasHosPro = false;
+ }
+
+ //add by rentx
+ noOfRecords = consumableorderdetailsSelectRecords.size();
+ //add by rentx
+ System.debug('makepagerecords3');
+ makepagerecords();
+ //listCut();
+ // 娑堣�楀搧鏄庣粏2銈掑彇寰�
+ consumableorderdetails2RecordsList = [
+ SELECT
+ Id,
+ Name,
+ SerialLotNo__c,
+ Consumable_Product__r.Name__c,
+ TracingCode__c,
+ Sterilization_limit__c,
+ Consumable_Product__c,
+ Consumable_Product__r.Name,
+ Consumable_Product__r.Category3__c,
+ Consumable_Product__r.Category4__c,
+ Consumable_Product__r.Category5__c,
+ Return_date__c,
+ Invoice_Date__c,
+ Box_Piece__c,
+ ProductPacking_list_manual__c,
+ //add by rentx start
+ hospitalSpecialOffer__c
+ //add by rentx end
+ FROM Consumable_order_details2__c
+ WHERE Consumable_ZS_order__c = :ESetId
+ ORDER BY Name
+ ];
+ for (
+ Integer i = 0; i < consumableorderdetails2RecordsList.size(); i++
+ ) {
+ consumableorderdetails2Records.add(
+ new ConsumableorderdetailsInfo(
+ consumableorderdetails2RecordsList[i]
+ )
+ );
+ }
+ //浜у搧鏄庣粏鍙栧緱
+ consumablearriveproductdetailsSelected = [
+ SELECT
+ Id,
+ Delivery_List_RMB__c,
+ Consumable_Product__r.Name__c,
+ Name,
+ Consumable_Product__r.SFDA_Status__c,
+ Consumable_Product__r.Category3__c,
+ Consumable_Product__r.Category4__c,
+ Consumable_Product__r.Category5__c,
+ Consumable_Product__c,
+ Consumable_Product__r.Name,
+ Sterilization_limit__c,
+ Consumable_Product__r.Intra_Trade_List_RMB__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Box_Piece__c,
+ ProductPacking_list_manual__c,
+ //add by rentx start
+ hospitalSpecialOffer__c
+ //add by rentx end
+ FROM Consumable_order_details2__c
+ WHERE Consumable_ZS_order__c = :ESetId
+ ORDER BY Name
+ ];
+ for (
+ Integer i = 0;
+ i < consumablearriveproductdetailsSelected.size();
+ i++
+ ) {
+ consumableproductdetailsRecords.add(
+ new ConsumableorderdetailsInfo(
+ consumablearriveproductdetailsSelected[i]
+ )
+ );
+ }
+ } else {
+ // 涓嶆槸鍒拌揣璁㈠崟鏉ョ殑鏃跺��
+ if (
+ coc.SummonsStatus_c__c == '宸叉彁浜�' ||
+ coc.SummonsStatus_c__c == '鎵瑰噯'
+ ) {
+ system.debug('coc.SummonsStatus_c__c : ' + coc.SummonsStatus_c__c);
+ saveBtnDisabled = true;
+ SorderBtnDisabled = true;
+ EditDelCommitBtnDisabled = false;
+ }
+ //鍖婚櫌浜岀骇缁忛攢鍟嗗垎绫�
+ Integer io = 0;
+ while (io < Dealerelationship.size()) {
+ if (
+ coc.Order_ForDealer__c ==
+ Dealerelationship[io].Dealer_subordinate__c
+ ) {
+ SecondDealer = Dealerelationship[io].Dealer_subordinate__c;
+ coc.Order_ForDealer__c = null;
+ io = io + Dealerelationship.size();
+ }
+ io++;
+ }
+ Integer ik = 0;
+ while (ik < AgencyHospitalLink.size()) {
+ if (
+ coc.Order_ForHospital__c == AgencyHospitalLink[ik].Hospital__c
+ ) {
+ HospitalInfo = AgencyHospitalLink[ik].Hospital__c;
+ HospitalName = AgencyHospitalLink[ik].Hospital__r.Name;
+ coc.Order_ForHospital__c = null;
+ ik = ik + AgencyHospitalLink.size();
+ }
+ ik++;
+ }
+ // 娑堣�楀搧鏄庣粏1銈掑彇寰�
+ consumableorderdetailsSelected = [
+ SELECT
+ Id,
+ Dealer_Custom_Price__c,
+ Delivery_List_RMB__c,
+ Consumable_Product__r.Name__c,
+ Consumable_Product__r.SFDA_Status__c,
+ Name,
+ Consumable_order__c,
+ Consumable_Product__c,
+ Consumable_Product__r.Name,
+ Shipment_Count__c,
+ Consumable_Product__r.Intra_Trade_List_RMB__c,
+ Consumable_Product__r.Asset_Model_No__c,
+ Shipment_amount__c,
+ Box_Piece__c,
+ ProductPacking_list_manual__c,
+ Invoiced_Procount__c,
+ RrturnPro_count__c,
+ //Unitprice_To_agency__c,
+ InvoiceProNot_count__c,
+ Consumable_Product__r.Category3__c,
+ Consumable_Product__r.Category4__c,
+ Consumable_Product__r.Category5__c,
+ Consumable_Product__r.Product2__r.SFDA_Approbation_No__c,
+ Consumable_Product__r.Product2__r.SFDA_Expiration_Date__c,
+ isOutPattern__c
+ FROM Consumable_orderdetails__c
+ WHERE
+ Consumable_order__c = :ESetId
+ AND Consumable_order__r.Order_Owner_WorkLocal__c = :userWorkLocation
+ ORDER BY Name
+ ];
+ //add by rentx 202-2-26
+ Map<String, Consumable_Orderdetails__c> cocMap = new Map<String, Consumable_Orderdetails__c>();
+
+ for (
+ Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected
+ ) {
+ sumPrice += cdc1.Shipment_amount__c;
+ orderzaikuId.add(cdc1.Consumable_Product__c);
+ //add by rentx 2021-2-26
+ String tempId = cdc1.Consumable_product__c;
+ if (cdc1.isOutPattern__c) {
+ cocMap.put(tempId + 'ishos', cdc1);
+ } else {
+ cocMap.put(tempId + 'nothos', cdc1);
+ }
+ //add by rentx 2021-2-26
+ }
+
+ String msoql = makeSoqlorderdet();
+ product2Selected = Database.query(msoql);
+ size = product2Selected.size();
+ initStandardController(msoql);
+ for (Integer i = 0; i < product2Selected.size(); i++) {
+ MidMap.put(
+ product2Selected[i].Id,
+ new ConsumableorderdetailsInfo(product2Selected[i])
+ );
+ }
+
+ for (Integer i = 0; i < CountDel.size(); i++) {
+ String str = '';
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ str = 'isHos';
+ } else {
+ str = 'notHos';
+ }
+ //鏄庣粏2瀵瑰簲鐨勪骇鍝佸瓨鍦ㄤ簬MidMap涓�
+ if (MidMap.containsKey(CountDel[i].Consumable_Product__c)) {
+ //璁剧疆map涓璳ey鐨勫悗缂� 鐢ㄤ簬鍖哄垎鍖婚櫌鐗逛环鍜岄潪鍖婚櫌鐗逛环
+ if (
+ MidMap2.containsKey(CountDel[i].Consumable_Product__c + str)
+ ) {
+ ConsumableorderdetailsInfo Jstage = MidMap2.get(
+ CountDel[i].Consumable_Product__c + str
+ );
+ Jstage.allnumber = Jstage.allnumber + 1;
+ if (CountDel[i].Box_Piece__c == '鐩�') {
+ Jstage.Boxnumber = Jstage.Boxnumber + 1;
+ } else if (CountDel[i].Box_Piece__c == '涓�') {
+ Jstage.Piecenumber = Jstage.Piecenumber + 1;
+ }
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ Jstage.hospitalSpecialOffer = true;
+ } else {
+ Jstage.hospitalSpecialOffer = false;
+ }
+ if (HosProMap.containsKey(Jstage.Prod.Id)) {
+ Jstage.hosPro = true;
+ }
+ MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
+ } else {
+ //midmap2涓病鏈夊搴旂殑浜у搧
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ CountDel[i].Consumable_Product__c
+ )
+ .clone();
+ Jstage.allnumber = Jstage.allnumber + 1;
+ if (CountDel[i].Box_Piece__c == '鐩�') {
+ Jstage.Boxnumber = Jstage.Boxnumber + 1;
+ } else if (CountDel[i].Box_Piece__c == '涓�') {
+ Jstage.Piecenumber = Jstage.Piecenumber + 1;
+ }
+
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ Jstage.hospitalSpecialOffer = true;
+ } else {
+ Jstage.hospitalSpecialOffer = false;
+ }
+ if (HosProMap.containsKey(Jstage.Prod.Id)) {
+ Jstage.hosPro = true;
+ }
+ Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+ MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
+ }
+ }
+ }
+
+ //鍐嶆妸map閲岀殑鍊间粠鏂拌祴缁機onsumableorderdetailsRecords
+ //update by rentx 2021-01-29
+ // for(ConsumableorderdetailsInfo bss : MidMap.values()){
+ for (ConsumableorderdetailsInfo bss : MidMap2.values()) {
+ //update by rentx 2021-01-29
+
+ //if(bss.allnumber>0){
+ bss.packinglist = Integer.valueOf(
+ bss.Prod.Product2__r.Packing_list_manual__c
+ );
+ bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
+ bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
+
+ //update by rentx 2021-2-26 start
+ if (
+ cocMap.containsKey(bss.Prod.Id + 'ishos') &&
+ bss.hospitalSpecialOffer == true
+ ) {
+ consumableorderdetailsSelectRecords.add(bss);
+ } else if (
+ cocMap.containsKey(bss.Prod.Id + 'nothos') &&
+ bss.hospitalSpecialOffer == false
+ ) {
+ consumableorderdetailsSelectRecords.add(bss);
+ }
+ // consumableorderdetailsSelectRecords.add(bss);
+ //}
+ }
+ // return null;
+ Integer ishosnum = 0;
+ for (
+ ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords
+ ) {
+ //ass.sortBy = sortOrderAsc;
+ for (
+ Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected
+ ) {
+ //update by rentx 2012-3-1 start
+ // if(ass.prod.Id == cdc1.Consumable_Product__c){
+ // ass.check = true;
+ // ass.orderdetails1 = cdc1;
+ // }
+ if (
+ ass.Prod.Id == cdc1.Consumable_Product__c &&
+ ass.hospitalSpecialOffer == cdc1.isOutPattern__c
+ ) {
+ ass.check = true;
+ ass.orderdetails1 = cdc1;
+ }
+ //update by rentx 2012-3-1 end
}
- Schema.DescribeFieldResult dfr = Product2__c.Intra_Trade_List_RMB__c.getDescribe();
- cansee = dfr.isAccessible();
- Schema.DescribeFieldResult dealerPrice = Consumable_orderdetails__c.Dealer_Custom_Price__c.getDescribe();
- dealerPricesee = dealerPrice.isAccessible();
- // 鏄剧ず鏁版嵁鏉℃暟淇℃伅
- // makeMessage();
- //闄勪欢
- attachmentinfo = [SELECT Id, Name, OwnerId FROM Attachment WHERE parentid = :ESetId];
- if (attachmentinfo.size() > 0) {
- for (Integer i = 0; i < attachmentinfo.size(); i++) {
- attachmentRecoeds.add(new ConsumableorderdetailsInfo(attachmentinfo[i]));
- }
+ if (ass.hospitalSpecialOffer == true) {
+ ishosnum = ishosnum + 1;
}
- AggregateResult[] categoryList = [
- SELECT Count(id), Category3_text__c c3c
- FROM Product2__c
- WHERE Category3_text__c != NULL
- GROUP BY Category3_text__c
- ];
+ }
- categoryOptionList = new List<SelectOption>();
- categoryOptionList.add(new SelectOption('', '-鏃�-'));
- categoryOptionMap = new Map<String, String>();
- categoryOptionMap.put('', '-鏃�-');
- for (AggregateResult category3Search : categoryList) {
- String deliverycnt = String.valueOf(category3Search.get('c3c'));
- categoryOptionList.add(new SelectOption(deliverycnt, deliverycnt));
- categoryOptionMap.put(deliverycnt, deliverycnt);
- }
+ if (ishosnum > 0) {
+ hasHosPro = true;
+ } else {
+ hasHosPro = false;
+ }
- category4OptionList = new List<SelectOption>();
- category4OptionList.add(new SelectOption('', '-鏃�-'));
- category4OptionMap = new Map<String, String>();
- category4OptionMap.put('', '-鏃�-');
- /*for(AggregateResult category4Search : category4List) {
+ consumableorderdetailsSelectRecords.sort();
+ //add by rentx
+ noOfRecords = consumableorderdetailsSelectRecords.size();
+ //add by rentx
+ System.debug('makepagerecords4');
+ makepagerecords();
+
+ // 娑堣�楀搧鏄庣粏2銈掑彇寰�
+ consumableorderdetails2RecordsList = [
+ SELECT
+ Id,
+ Name,
+ SerialLotNo__c,
+ Consumable_Product__r.Name__c,
+ TracingCode__c,
+ Sterilization_limit__c,
+ Consumable_Product__c,
+ Consumable_Product__r.Name,
+ Consumable_Product__r.Category3__c,
+ Consumable_Product__r.Category4__c,
+ Consumable_Product__r.Category5__c,
+ Return_date__c,
+ Invoice_Date__c,
+ Box_Piece__c,
+ ProductPacking_list_manual__c,
+ //add by rentx start
+ hospitalSpecialOffer__c
+ //add by rentx end
+
+ FROM Consumable_order_details2__c
+ WHERE Consumable_ZS_order__c = :ESetId
+ ORDER BY Name
+ ];
+ for (
+ Integer i = 0; i < consumableorderdetails2RecordsList.size(); i++
+ ) {
+ consumableorderdetails2Records.add(
+ new ConsumableorderdetailsInfo(
+ consumableorderdetails2RecordsList[i]
+ )
+ );
+ }
+ }
+ }
+ //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'test++++++' + SecondDealer));
+ if (SecondDealer == null || SecondDealer == '') {
+ provinceOpts.add(new SelectOption('', '-鏃�-'));
+ provinceOptsMap.put('', '-鏃�-');
+ for (Integer i = 0; i < Dealerelationship.size(); i++) {
+ provinceOpts.add(
+ new SelectOption(
+ Dealerelationship[i].Dealer_subordinate__c,
+ Dealerelationship[i].Dealer_subordinate__r.Name
+ )
+ );
+ provinceOptsMap.put(
+ Dealerelationship[i].Dealer_subordinate__c,
+ Dealerelationship[i].Dealer_subordinate__r.Name
+ );
+ }
+ } else {
+ provinceOpts.add(new SelectOption('', '-鏃�-'));
+ provinceOptsMap.put('', '-鏃�-');
+ for (Integer i = 0; i < Dealerelationship.size(); i++) {
+ if (Dealerelationship[i].Dealer_subordinate__c == SecondDealer) {
+ provinceOpts.add(
+ new SelectOption(
+ Dealerelationship[i].Dealer_subordinate__c,
+ Dealerelationship[i].Dealer_subordinate__r.Name
+ )
+ );
+ provinceOptsMap.put(
+ Dealerelationship[i].Dealer_subordinate__c,
+ Dealerelationship[i].Dealer_subordinate__r.Name
+ );
+ }
+ }
+ for (Integer i = 0; i < Dealerelationship.size(); i++) {
+ if (Dealerelationship[i].Dealer_subordinate__c != SecondDealer) {
+ provinceOpts.add(
+ new SelectOption(
+ Dealerelationship[i].Dealer_subordinate__c,
+ Dealerelationship[i].Dealer_subordinate__r.Name
+ )
+ );
+ provinceOptsMap.put(
+ Dealerelationship[i].Dealer_subordinate__c,
+ Dealerelationship[i].Dealer_subordinate__r.Name
+ );
+ }
+ }
+ }
+
+ Schema.DescribeFieldResult dfr = Product2__c.Intra_Trade_List_RMB__c.getDescribe();
+ cansee = dfr.isAccessible();
+ Schema.DescribeFieldResult dealerPrice = Consumable_orderdetails__c.Dealer_Custom_Price__c.getDescribe();
+ dealerPricesee = dealerPrice.isAccessible();
+ // 鏄剧ず鏁版嵁鏉℃暟淇℃伅
+ // makeMessage();
+ //闄勪欢
+ attachmentinfo = [
+ SELECT Id, Name, OwnerId
+ FROM Attachment
+ WHERE parentid = :ESetId
+ ];
+ if (attachmentinfo.size() > 0) {
+ for (Integer i = 0; i < attachmentinfo.size(); i++) {
+ attachmentRecoeds.add(
+ new ConsumableorderdetailsInfo(attachmentinfo[i])
+ );
+ }
+ }
+ AggregateResult[] categoryList = [
+ SELECT Count(id), Category3_text__c c3c
+ FROM Product2__c
+ WHERE Category3_text__c != NULL
+ GROUP BY Category3_text__c
+ ];
+
+ categoryOptionList = new List<SelectOption>();
+ categoryOptionList.add(new SelectOption('', '-鏃�-'));
+ categoryOptionMap = new Map<String, String>();
+ categoryOptionMap.put('', '-鏃�-');
+ for (AggregateResult category3Search : categoryList) {
+ String deliverycnt = String.valueOf(category3Search.get('c3c'));
+ categoryOptionList.add(new SelectOption(deliverycnt, deliverycnt));
+ categoryOptionMap.put(deliverycnt, deliverycnt);
+ }
+
+ category4OptionList = new List<SelectOption>();
+ category4OptionList.add(new SelectOption('', '-鏃�-'));
+ category4OptionMap = new Map<String, String>();
+ category4OptionMap.put('', '-鏃�-');
+ /*for(AggregateResult category4Search : category4List) {
String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
category4OptionList.add(new SelectOption(deliverycnt4,deliverycnt4));
}*/
- category5OptionList = new List<SelectOption>();
- category5OptionList.add(new SelectOption('', '-鏃�-'));
- category5OptionMap = new Map<String, String>();
- category5OptionMap.put('', '-鏃�-');
+ category5OptionList = new List<SelectOption>();
+ category5OptionList.add(new SelectOption('', '-鏃�-'));
+ category5OptionMap = new Map<String, String>();
+ category5OptionMap.put('', '-鏃�-');
- //鍒嗛〉
- PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
- totalCount = pageRecords.size();
- System.debug('pageToken = ' + pageToken);
- System.debug('pageSize = ' + pageSize);
- System.debug('totalCount = ' + totalCount);
- paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount) ? pageToken + pageSize : null;
- System.debug('paginatedAccounts.nextPageToken = ' + paginatedAccounts.nextPageToken);
- paginatedAccounts.recordStart = pageToken + 1;
- paginatedAccounts.pageNumber = pageToken / pageSize + 1;
- Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
- paginatedAccounts.recordEnd = totalCount >= recordEnd ? recordEnd : totalCount;
- paginatedAccounts.totalRecords = totalCount;
+ //鍒嗛〉
+ PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
+ totalCount = pageRecords.size();
+ System.debug('pageToken = ' + pageToken);
+ System.debug('pageSize = ' + pageSize);
+ System.debug('totalCount = ' + totalCount);
+ paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount)
+ ? pageToken + pageSize
+ : null;
+ System.debug(
+ 'paginatedAccounts.nextPageToken = ' + paginatedAccounts.nextPageToken
+ );
+ paginatedAccounts.recordStart = pageToken + 1;
+ paginatedAccounts.pageNumber = pageToken / pageSize + 1;
+ Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
+ paginatedAccounts.recordEnd = totalCount >= recordEnd
+ ? recordEnd
+ : totalCount;
+ paginatedAccounts.totalRecords = totalCount;
- Integer startIdx;
- Integer endIdx;
- startIdx = pageToken;
- endIdx = pageToken + pageSize;
- List<ConsumableorderdetailsInfo> pageRecordsTemp = new List<ConsumableorderdetailsInfo>();
- if (endIdx > pageRecords.size()) {
- endIdx = pageRecords.size();
- }
- for (Integer i = startIdx; i < endIdx; i++) {
- pageRecordsTemp.add(pageRecords.get(i));
- }
+ Integer startIdx;
+ Integer endIdx;
+ startIdx = pageToken;
+ endIdx = pageToken + pageSize;
+ List<ConsumableorderdetailsInfo> pageRecordsTemp = new List<ConsumableorderdetailsInfo>();
+ if (endIdx > pageRecords.size()) {
+ endIdx = pageRecords.size();
+ }
+ for (Integer i = startIdx; i < endIdx; i++) {
+ pageRecordsTemp.add(pageRecords.get(i));
+ }
- Boolean Existarrive = (coc.Arrive_Order__c != null);
- String ConsumableOut_report = System.Label.ConsumableOut_report;
- System.debug('consumableproductdetailsRecords = ' + consumableproductdetailsRecords);
+ Boolean Existarrive = (coc.Arrive_Order__c != null);
+ String ConsumableOut_report = System.Label.ConsumableOut_report;
+ System.debug(
+ 'consumableproductdetailsRecords = ' + consumableproductdetailsRecords
+ );
- data.put('paginatedAccounts', paginatedAccounts);
- data.put('ConsumableOut_report', ConsumableOut_report);
- data.put('accountid', accountid);
- data.put('consumableproductdetailsRecords', consumableproductdetailsRecords);
- data.put('agencyProType', agencyProType);
- data.put('accountName', accountName);
- data.put('userWorkLocation', userWorkLocation);
- data.put('categoryOptionMap', categoryOptionMap);
- data.put('category4OptionMap', category4OptionMap);
- data.put('category5OptionMap', category5OptionMap);
- data.put('outOutPatternOptionMap', outOutPatternOptionMap);
- data.put('hasHosPro', hasHosPro);
- data.put('Existarrive', Existarrive);
- data.put('sumPrice', sumPrice);
- data.put('HospitalName', HospitalName);
- data.put('provinceOptsMap', provinceOptsMap);
- data.put('SummonsFlag', SummonsFlag);
- data.put('EditDelCommitBtnDisabled', EditDelCommitBtnDisabled);
- data.put('EditAble', EditAble);
- data.put('coc', coc);
- data.put('pageRecords', pageRecordsTemp);
- data.put('arriveorder', arriveorder);
- data.put('consumableorderdetails2Count', consumableorderdetails2Count);
- data.put('consumableorderdetails2Records', consumableorderdetails2Records);
- data.put('HospitalInfo', HospitalInfo);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
- } catch (Exception e) {
- return new ResponseBodyLWC('Error',500, e.getMessage() + e.getLineNumber(), '');
- }
+ data.put('paginatedAccounts', paginatedAccounts);
+ data.put('ConsumableOut_report', ConsumableOut_report);
+ data.put('accountid', accountid);
+ data.put(
+ 'consumableproductdetailsRecords',
+ consumableproductdetailsRecords
+ );
+ data.put('agencyProType', agencyProType);
+ data.put('accountName', accountName);
+ data.put('userWorkLocation', userWorkLocation);
+ data.put('categoryOptionMap', categoryOptionMap);
+ data.put('category4OptionMap', category4OptionMap);
+ data.put('category5OptionMap', category5OptionMap);
+ data.put('outOutPatternOptionMap', outOutPatternOptionMap);
+ data.put('hasHosPro', hasHosPro);
+ data.put('Existarrive', Existarrive);
+ data.put('sumPrice', sumPrice);
+ data.put('HospitalName', HospitalName);
+ data.put('provinceOptsMap', provinceOptsMap);
+ data.put('SummonsFlag', SummonsFlag);
+ data.put('EditDelCommitBtnDisabled', EditDelCommitBtnDisabled);
+ data.put('EditAble', EditAble);
+ data.put('coc', coc);
+ data.put('pageRecords', pageRecordsTemp);
+ data.put('arriveorder', arriveorder);
+ data.put('consumableorderdetails2Count', consumableorderdetails2Count);
+ data.put(
+ 'consumableorderdetails2Records',
+ consumableorderdetails2Records
+ );
+ data.put('HospitalInfo', HospitalInfo);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ } catch (Exception e) {
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ e.getMessage() + e.getLineNumber(),
+ ''
+ );
+ }
+ }
+
+ @AuraEnabled
+ public static ResponseBodyLWC categoryAllload(String category3Lwc) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ category3 = category3Lwc;
+ AggregateResult[] category4List = [
+ SELECT Count(id), Category4_text__c c4c
+ FROM Product2__c
+ WHERE
+ Category3_text__c = :category3
+ AND Category4_text__c != NULL
+ AND Category5_text__c != NULL
+ GROUP BY Category4_text__c
+ ];
+ category4OptionList = new List<SelectOption>();
+ category4OptionList.add(new SelectOption('', '-鏃�-'));
+ category4OptionMap = new Map<String, String>();
+ category4OptionMap.put('', '-鏃�-');
+ for (AggregateResult category4Search : category4List) {
+ String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
+ category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
+ category4OptionMap.put(deliverycnt4, deliverycnt4);
}
- @AuraEnabled
- public static ResponseBodyLWC categoryAllload(String category3Lwc) {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
+ AggregateResult[] category5List = [
+ SELECT Count(id), Category5_text__c c5c
+ FROM Product2__c
+ WHERE
+ Category3_text__c = :category3
+ AND Category4_text__c != NULL
+ AND Category5_text__c != NULL
+ GROUP BY Category5_text__c
+ ];
- category3 = category3Lwc;
- AggregateResult[] category4List = [
- SELECT Count(id), Category4_text__c c4c
- FROM Product2__c
- WHERE Category3_text__c = :category3 AND Category4_text__c != NULL AND Category5_text__c != NULL
- GROUP BY Category4_text__c
- ];
- category4OptionList = new List<SelectOption>();
- category4OptionList.add(new SelectOption('', '-鏃�-'));
- category4OptionMap = new Map<String, String>();
- category4OptionMap.put('', '-鏃�-');
- for (AggregateResult category4Search : category4List) {
- String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
- category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
- category4OptionMap.put(deliverycnt4, deliverycnt4);
- }
+ category5OptionList = new List<SelectOption>();
+ category5OptionList.add(new SelectOption('', '-鏃�-'));
+ category5OptionMap = new Map<String, String>();
+ category5OptionMap.put('', '-鏃�-');
+ for (AggregateResult category5Search : category5List) {
+ String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
+ category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
+ category5OptionMap.put(deliverycnt5, deliverycnt5);
+ }
+ data.put('category4OptionMap', category4OptionMap);
+ data.put('category5OptionMap', category5OptionMap);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
- AggregateResult[] category5List = [
- SELECT Count(id), Category5_text__c c5c
- FROM Product2__c
- WHERE Category3_text__c = :category3 AND Category4_text__c != NULL AND Category5_text__c != NULL
- GROUP BY Category5_text__c
- ];
+ @AuraEnabled
+ public static ResponseBodyLWC categoryload(
+ String category3Lwc,
+ String category4Lwc
+ ) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
- category5OptionList = new List<SelectOption>();
- category5OptionList.add(new SelectOption('', '-鏃�-'));
- category5OptionMap = new Map<String, String>();
- category5OptionMap.put('', '-鏃�-');
- for (AggregateResult category5Search : category5List) {
- String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
- category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
- category5OptionMap.put(deliverycnt5, deliverycnt5);
- }
- data.put('category4OptionMap', category4OptionMap);
- data.put('category5OptionMap', category5OptionMap);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ category3 = category3Lwc;
+ category4 = category4Lwc;
+ AggregateResult[] category4List = [
+ SELECT Count(id), Category4_text__c c4c
+ FROM Product2__c
+ WHERE
+ Category3_text__c = :category3
+ AND Category4_text__c != NULL
+ AND Category5_text__c != NULL
+ GROUP BY Category4_text__c
+ ];
+ category4OptionList = new List<SelectOption>();
+ category4OptionList.add(new SelectOption('', '-鏃�-'));
+ category4OptionMap = new Map<String, String>();
+ category4OptionMap.put('', '-鏃�-');
+ for (AggregateResult category4Search : category4List) {
+ String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
+ category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
+ category4OptionMap.put(deliverycnt4, deliverycnt4);
}
- @AuraEnabled
- public static ResponseBodyLWC categoryload(String category3Lwc, String category4Lwc) {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
+ AggregateResult[] category5List = [
+ SELECT Count(id), Category5_text__c c5c
+ FROM Product2__c
+ WHERE
+ Category3_text__c = :category3
+ AND Category4_text__c = :category4
+ AND Category5_text__c != NULL
+ GROUP BY Category5_text__c
+ ];
- category3 = category3Lwc;
- category4 = category4Lwc;
- AggregateResult[] category4List = [
- SELECT Count(id), Category4_text__c c4c
- FROM Product2__c
- WHERE Category3_text__c = :category3 AND Category4_text__c != NULL AND Category5_text__c != NULL
- GROUP BY Category4_text__c
- ];
- category4OptionList = new List<SelectOption>();
- category4OptionList.add(new SelectOption('', '-鏃�-'));
- category4OptionMap = new Map<String, String>();
- category4OptionMap.put('', '-鏃�-');
- for (AggregateResult category4Search : category4List) {
- String deliverycnt4 = String.valueOf(category4Search.get('c4c'));
- category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4));
- category4OptionMap.put(deliverycnt4, deliverycnt4);
- }
-
- AggregateResult[] category5List = [
- SELECT Count(id), Category5_text__c c5c
- FROM Product2__c
- WHERE Category3_text__c = :category3 AND Category4_text__c = :category4 AND Category5_text__c != NULL
- GROUP BY Category5_text__c
- ];
-
- category5OptionList = new List<SelectOption>();
- category5OptionList.add(new SelectOption('', '-鏃�-'));
- category5OptionMap = new Map<String, String>();
- category5OptionMap.put('', '-鏃�-');
- for (AggregateResult category5Search : category5List) {
- String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
- category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
- category5OptionMap.put(deliverycnt5, deliverycnt5);
- }
- data.put('category4OptionMap', category4OptionMap);
- data.put('category5OptionMap', category5OptionMap);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ category5OptionList = new List<SelectOption>();
+ category5OptionList.add(new SelectOption('', '-鏃�-'));
+ category5OptionMap = new Map<String, String>();
+ category5OptionMap.put('', '-鏃�-');
+ for (AggregateResult category5Search : category5List) {
+ String deliverycnt5 = String.valueOf(category5Search.get('c5c'));
+ category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5));
+ category5OptionMap.put(deliverycnt5, deliverycnt5);
}
+ data.put('category4OptionMap', category4OptionMap);
+ data.put('category5OptionMap', category5OptionMap);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
- // 妫�绱�
- @AuraEnabled
- public static ResponseBodyLWC searchConsumableorderdetails(
- String agencyProTypeLwc,
- String accountNameLwc,
- String userWorkLocationLwc,
- String outOutPattern,
- String category1,
- String category3,
- String category4,
- String category5,
- Boolean editAbleLwc,
- List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc,
- List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc,
- String arriveorderLwc,
- Integer pageSizeLWC,
- Integer pageTokenLWC
+ // 妫�绱�
+ @AuraEnabled
+ public static ResponseBodyLWC searchConsumableorderdetails(
+ String agencyProTypeLwc,
+ String accountNameLwc,
+ String userWorkLocationLwc,
+ String outOutPattern,
+ String category1,
+ String category3,
+ String category4,
+ String category5,
+ Boolean editAbleLwc,
+ List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc,
+ List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc,
+ String arriveorderLwc,
+ Integer pageSizeLWC,
+ Integer pageTokenLWC
+ ) {
+ consumableproductdetailsRecords = consumableproductdetailsRecordsLwc;
+ pageRecordsLwc = pageRecordsLwcLwc;
+ System.debug('pageRecordsLwc = ' + pageRecordsLwc);
+ arriveorder = arriveorderLwc;
+ accountName = accountNameLwc;
+ userWorkLocation = userWorkLocationLwc;
+ agencyProType = agencyProTypeLwc;
+ product2Selected = new List<Product2__c>();
+ pagesize = pageSizeLWC;
+ pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC;
+ addSize = 0;
+ addData = new List<ConsumableorderdetailsInfo>();
+ System.debug('start addData = ' + addData);
+ System.debug('accountName = ' + accountName);
+ System.debug('userWorkLocation = ' + userWorkLocation);
+ String sqlagencyProType = '%' + agencyProTypeLwc + '%';
+ List<AggregateResult> orderdetailCount = [
+ SELECT count(id), Consumable_Product__c cpc, Box_Piece__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 Cancellation_Flag__c = FALSE
+ AND Bar_Code__c != NULL
+ AND Isoverdue__c = 1
+ AND Product_Type__c LIKE :sqlagencyProType
+ AND Dealer_Info_text__c = :accountNameLwc
+ AND Arrive_Owner_Work_Location__c = :userWorkLocationLwc
+ GROUP BY Consumable_Product__c, Box_Piece__c
+ ];
+ for (AggregateResult orderdetail : orderdetailCount) {
+ zaikuId.add(String.valueOf(orderdetail.get('cpc')));
+ }
+ editAble = editAbleLwc;
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ SearchDone = 'SearchDone';
+ Map<String, String> selectedIdMap = new Map<String, String>();
+ List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
+ Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>();
+ //update by rentx 2021-01-29
+ Map<String, ConsumableorderdetailsInfo> MidMap2 = new Map<String, ConsumableorderdetailsInfo>();
+ String countdelSoql = 'SELECT Id,Bar_Code__c,Name,Inventory_date__c,Consumable_Product__c,Consumable_Product__r.Asset_Model_No__c,Recordtypeid,Box_Piece__c,ProductPacking_list_manual__c,hospitalSpecialOffer__c 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 Lose_Flag__c = false AND Bar_Code__c != null AND Isoverdue__c = 1 AND Arrive_Owner_Work_Location__c = :userWorkLocation AND Dealer_Info_text__c = :accountName ';
+ if (String.isNotBlank(outOutPattern) && outOutPattern.equals('ishos')) {
+ countdelSoql += ' AND hospitalSpecialOffer__c = true';
+ } else if (
+ String.isNotBlank(outOutPattern) && outOutPattern.equals('nothos')
) {
- consumableproductdetailsRecords = consumableproductdetailsRecordsLwc;
- pageRecordsLwc = pageRecordsLwcLwc;
- System.debug('pageRecordsLwc = ' + pageRecordsLwc);
- arriveorder = arriveorderLwc;
- accountName = accountNameLwc;
- userWorkLocation = userWorkLocationLwc;
- agencyProType = agencyProTypeLwc;
- product2Selected = new List<Product2__c>();
- pagesize = pageSizeLWC;
- pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC;
- addSize = 0;
- addData = new List<ConsumableorderdetailsInfo>();
- System.debug('start addData = ' + addData);
- System.debug('accountName = ' + accountName);
- System.debug('userWorkLocation = ' + userWorkLocation);
- String sqlagencyProType = '%' + agencyProTypeLwc + '%';
- List<AggregateResult> orderdetailCount = [
- SELECT count(id), Consumable_Product__c cpc, Box_Piece__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 Cancellation_Flag__c = FALSE
- AND Bar_Code__c != NULL
- AND Isoverdue__c = 1
- AND Product_Type__c LIKE :sqlagencyProType
- AND Dealer_Info_text__c = :accountNameLwc
- AND Arrive_Owner_Work_Location__c = :userWorkLocationLwc
- GROUP BY Consumable_Product__c, Box_Piece__c
- ];
- for (AggregateResult orderdetail : orderdetailCount) {
- zaikuId.add(String.valueOf(orderdetail.get('cpc')));
- }
- editAble = editAbleLwc;
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- SearchDone = 'SearchDone';
- Map<String, String> selectedIdMap = new Map<String, String>();
- List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
- Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>();
- //update by rentx 2021-01-29
- Map<String, ConsumableorderdetailsInfo> MidMap2 = new Map<String, ConsumableorderdetailsInfo>();
- String countdelSoql = 'SELECT Id,Bar_Code__c,Name,Inventory_date__c,Consumable_Product__c,Consumable_Product__r.Asset_Model_No__c,Recordtypeid,Box_Piece__c,ProductPacking_list_manual__c,hospitalSpecialOffer__c 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 Lose_Flag__c = false AND Bar_Code__c != null AND Isoverdue__c = 1 AND Arrive_Owner_Work_Location__c = :userWorkLocation AND Dealer_Info_text__c = :accountName ';
- if (String.isNotBlank(outOutPattern) && outOutPattern.equals('ishos')) {
- countdelSoql += ' AND hospitalSpecialOffer__c = true';
- } else if (String.isNotBlank(outOutPattern) && outOutPattern.equals('nothos')) {
- countdelSoql += ' AND hospitalSpecialOffer__c = false';
- }
- System.debug('countdelSoql = ' + countdelSoql);
- List<Consumable_order_details2__c> CountDel = Database.query(countdelSoql);
- System.debug('CountDel = ' + CountDel);
- //update by rentx 2021-01-29
+ countdelSoql += ' AND hospitalSpecialOffer__c = false';
+ }
+ System.debug('countdelSoql = ' + countdelSoql);
+ List<Consumable_order_details2__c> CountDel = Database.query(countdelSoql);
+ System.debug('CountDel = ' + CountDel);
+ //update by rentx 2021-01-29
- consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
- //consumableorderdetailsSelectRecords = reSet;
- String soql = makeSoql(category1, category3, category4, category5);
- size = Integer.valueOf(System.Label.orderdetLimitsize);
- initStandardController(soql);
- System.debug('soql = ' + soql);
- product2Selected = Database.query(soql);
- for (Integer i = 0; i < product2Selected.size(); i++) {
- MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i]));
- }
+ consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>();
+ //consumableorderdetailsSelectRecords = reSet;
+ String soql = makeSoql(category1, category3, category4, category5);
+ size = Integer.valueOf(System.Label.orderdetLimitsize);
+ initStandardController(soql);
+ System.debug('soql = ' + soql);
+ product2Selected = Database.query(soql);
+ for (Integer i = 0; i < product2Selected.size(); i++) {
+ MidMap.put(
+ product2Selected[i].Id,
+ new ConsumableorderdetailsInfo(product2Selected[i])
+ );
+ }
- for (Integer i = 0; i < CountDel.size(); i++) {
- String str = '';
- if (CountDel[i].hospitalSpecialOffer__c) {
- str = 'isHos';
- } else {
- str = 'notHos';
- }
- System.debug('MidMap = ' + MidMap);
- //鏄庣粏2瀵瑰簲鐨勪骇鍝佸瓨鍦ㄤ簬MidMap涓�
- if (MidMap.containsKey(CountDel[i].Consumable_Product__c)) {
- //璁剧疆map涓璳ey鐨勫悗缂� 鐢ㄤ簬鍖哄垎鍖婚櫌鐗逛环鍜岄潪鍖婚櫌鐗逛环
- if (MidMap2.containsKey(CountDel[i].Consumable_Product__c + str)) {
- ConsumableorderdetailsInfo Jstage = MidMap2.get(CountDel[i].Consumable_Product__c + str);
- Jstage.allnumber = Jstage.allnumber + 1;
- if (CountDel[i].Box_Piece__c == '鐩�') {
- Jstage.Boxnumber = Jstage.Boxnumber + 1;
- } else if (CountDel[i].Box_Piece__c == '涓�') {
- Jstage.Piecenumber = Jstage.Piecenumber + 1;
- }
- if (CountDel[i].hospitalSpecialOffer__c) {
- Jstage.hospitalSpecialOffer = true;
- } else {
- Jstage.hospitalSpecialOffer = false;
- }
- if (HosProMap.containsKey(Jstage.Prod.Id)) {
- Jstage.hosPro = true;
- }
- MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
- } else {
- //midmap2涓病鏈夊搴旂殑浜у搧
- ConsumableorderdetailsInfo Jstage = MidMap.get(CountDel[i].Consumable_Product__c).clone();
- Jstage.allnumber = Jstage.allnumber + 1;
- if (CountDel[i].Box_Piece__c == '鐩�') {
- Jstage.Boxnumber = Jstage.Boxnumber + 1;
- } else if (CountDel[i].Box_Piece__c == '涓�') {
- Jstage.Piecenumber = Jstage.Piecenumber + 1;
- }
- if (CountDel[i].hospitalSpecialOffer__c) {
- Jstage.hospitalSpecialOffer = true;
- } else {
- Jstage.hospitalSpecialOffer = false;
- }
- if (HosProMap.containsKey(Jstage.Prod.Id)) {
- Jstage.hosPro = true;
- }
- //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
- MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
- }
- }
- }
- Integer ishosnum = 0;
- System.debug('MidMap2 = ' + MidMap2);
- for (ConsumableorderdetailsInfo bss : MidMap2.values()) {
- if (selectedIdMap.containsKey(bss.Prod.id)) {
- continue;
- } else {
- bss.sortBy = false;
- bss.packinglist = Integer.valueOf(bss.Prod.Product2__r.Packing_list_manual__c);
- bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
- bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
- consumableorderdetailsSelectRecords.add(bss);
-
- if (bss.hospitalSpecialOffer == true) {
- ishosnum = ishosnum + 1;
- }
- }
- }
- if (ishosnum > 0) {
- hasHosPro = true;
+ for (Integer i = 0; i < CountDel.size(); i++) {
+ String str = '';
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ str = 'isHos';
+ } else {
+ str = 'notHos';
+ }
+ System.debug('MidMap = ' + MidMap);
+ //鏄庣粏2瀵瑰簲鐨勪骇鍝佸瓨鍦ㄤ簬MidMap涓�
+ if (MidMap.containsKey(CountDel[i].Consumable_Product__c)) {
+ //璁剧疆map涓璳ey鐨勫悗缂� 鐢ㄤ簬鍖哄垎鍖婚櫌鐗逛环鍜岄潪鍖婚櫌鐗逛环
+ if (MidMap2.containsKey(CountDel[i].Consumable_Product__c + str)) {
+ ConsumableorderdetailsInfo Jstage = MidMap2.get(
+ CountDel[i].Consumable_Product__c + str
+ );
+ Jstage.allnumber = Jstage.allnumber + 1;
+ if (CountDel[i].Box_Piece__c == '鐩�') {
+ Jstage.Boxnumber = Jstage.Boxnumber + 1;
+ } else if (CountDel[i].Box_Piece__c == '涓�') {
+ Jstage.Piecenumber = Jstage.Piecenumber + 1;
+ }
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ Jstage.hospitalSpecialOffer = true;
+ } else {
+ Jstage.hospitalSpecialOffer = false;
+ }
+ if (HosProMap.containsKey(Jstage.Prod.Id)) {
+ Jstage.hosPro = true;
+ }
+ MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
} else {
- hasHosPro = false;
+ //midmap2涓病鏈夊搴旂殑浜у搧
+ ConsumableorderdetailsInfo Jstage = MidMap.get(
+ CountDel[i].Consumable_Product__c
+ )
+ .clone();
+ Jstage.allnumber = Jstage.allnumber + 1;
+ if (CountDel[i].Box_Piece__c == '鐩�') {
+ Jstage.Boxnumber = Jstage.Boxnumber + 1;
+ } else if (CountDel[i].Box_Piece__c == '涓�') {
+ Jstage.Piecenumber = Jstage.Piecenumber + 1;
+ }
+ if (CountDel[i].hospitalSpecialOffer__c) {
+ Jstage.hospitalSpecialOffer = true;
+ } else {
+ Jstage.hospitalSpecialOffer = false;
+ }
+ if (HosProMap.containsKey(Jstage.Prod.Id)) {
+ Jstage.hosPro = true;
+ }
+ //Jstage.BoxPiece = CountDel[i].Box_Piece__c;
+ MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage);
}
+ }
+ }
+ Integer ishosnum = 0;
+ System.debug('MidMap2 = ' + MidMap2);
+ for (ConsumableorderdetailsInfo bss : MidMap2.values()) {
+ if (selectedIdMap.containsKey(bss.Prod.id)) {
+ continue;
+ } else {
+ bss.sortBy = false;
+ bss.packinglist = Integer.valueOf(
+ bss.Prod.Product2__r.Packing_list_manual__c
+ );
+ bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c;
+ bss.expiration_Date = bss.Prod.Product2__r.SFDA_Expiration_Date__c;
+ consumableorderdetailsSelectRecords.add(bss);
- consumableorderdetailsSelectRecords.sort();
- makepagerecordsLwc();
- //鍒嗛〉
- PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
- totalCount = pageRecords.size();
- paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount) ? pageToken + pageSize : null;
- paginatedAccounts.recordStart = pageToken + 1;
- paginatedAccounts.pageNumber = pageToken / pageSize + 1;
- Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
- paginatedAccounts.recordEnd = totalCount >= recordEnd ? recordEnd : totalCount;
- paginatedAccounts.totalRecords = totalCount;
-
- System.debug('addSize = ' + addSize);
- Integer startIdx;
- Integer endIdx;
- startIdx = pageToken;
- endIdx = pageToken + pageSize;
- List<ConsumableorderdetailsInfo> pageRecordsTemp = new List<ConsumableorderdetailsInfo>();
- if (endIdx > pageRecords.size()) {
- endIdx = pageRecords.size();
+ if (bss.hospitalSpecialOffer == true) {
+ ishosnum = ishosnum + 1;
}
-
- System.debug('addData.size() = ' + addData.size());
- for (ConsumableorderdetailsInfo ci : addData) {
- pageRecordsTemp.add(ci);
- }
- System.debug('startIdx = ' + startIdx);
- System.debug('endIdx = ' + endIdx);
- System.debug('skipData = ' + skipData);
- System.debug('pageRecords = ' + pageRecords.size());
- String hos = '';
- for (Integer i = startIdx; i < endIdx; i++) {
- System.debug('skipData.get(pageRecords.get(i).Prod.Id) = ' + skipData.get(pageRecords.get(i).Prod.Id));
- if (pageRecords.get(i).hospitalSpecialOffer == true) {
- hos = 'ishos';
- } else {
- hos = 'nothos';
- }
- if (skipData.get(pageRecords.get(i).Prod.Id + hos) == null) {
- pageRecordsTemp.add(pageRecords.get(i));
- }
- }
-
- System.debug('pageRecordsTemp = ' + pageRecordsTemp.size());
- data.put('paginatedAccounts', paginatedAccounts);
- data.put('pageRecords', pageRecordsTemp);
- data.put('SearchDone', SearchDone);
- data.put('hasHosPro', hasHosPro);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ }
+ }
+ if (ishosnum > 0) {
+ hasHosPro = true;
+ } else {
+ hasHosPro = false;
}
- private static String makeSoql(String CateName, String Category3, String Category4, String Category5) {
- String sqlTail1 = '(\'';
- for (Integer i = 0; i < zaikuId.size(); i++) {
- if (zaikuId[i] != null) {
- if (i < zaikuId.size() - 1) {
- sqlTail1 += zaikuId[i] + '\',\'';
- } else {
- sqlTail1 += zaikuId[i];
- }
- }
- }
- sqlTail1 += '\')';
- String soql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,Product2__r.Packing_list_manual__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Category3__c,Category4__c,Category5__c FROM Product2__c ';
- soql += ' WHERE Id in' + sqlTail1;
- if (!String.isBlank(CateName)) {
- soql +=
- ' AND (Name__c like \'%' +
- String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
- '%\' or Asset_Model_No__c like \'%' +
- String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
- '%\')';
- }
- if (!String.isBlank(Category3)) {
- soql += ' AND Category3__c = \'' + Category3 + '\'';
- }
- if (!String.isBlank(Category4)) {
- soql += ' AND Category4__c = \'' + Category4 + '\'';
- }
- if (!String.isBlank(Category5)) {
- soql += ' AND Category5__c = \'' + Category5 + '\'';
- }
- return soql;
+ consumableorderdetailsSelectRecords.sort();
+ makepagerecordsLwc();
+ //鍒嗛〉
+ PaginatedAccounts paginatedAccounts = new PaginatedAccounts();
+ totalCount = pageRecords.size();
+ paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount)
+ ? pageToken + pageSize
+ : null;
+ paginatedAccounts.recordStart = pageToken + 1;
+ paginatedAccounts.pageNumber = pageToken / pageSize + 1;
+ Integer recordEnd = pageSize * paginatedAccounts.pageNumber;
+ paginatedAccounts.recordEnd = totalCount >= recordEnd
+ ? recordEnd
+ : totalCount;
+ paginatedAccounts.totalRecords = totalCount;
+
+ System.debug('addSize = ' + addSize);
+ Integer startIdx;
+ Integer endIdx;
+ startIdx = pageToken;
+ endIdx = pageToken + pageSize;
+ List<ConsumableorderdetailsInfo> pageRecordsTemp = new List<ConsumableorderdetailsInfo>();
+ if (endIdx > pageRecords.size()) {
+ endIdx = pageRecords.size();
}
- public static String makeSoqlorderdet() {
- String sqlTail = '(\'';
- for (Integer i = 0; i < orderzaikuId.size(); i++) {
- if (i < orderzaikuId.size() - 1) {
- sqlTail += orderzaikuId[i] + '\',\'';
- } else {
- sqlTail += orderzaikuId[i];
- }
- }
- sqlTail += '\')';
- String msoql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,Product2__r.Packing_list_manual__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Category3__c,Category4__c,Category5__c FROM Product2__c ';
- msoql += ' WHERE Id in' + sqlTail;
- return msoql;
+ System.debug('addData.size() = ' + addData.size());
+ for (ConsumableorderdetailsInfo ci : addData) {
+ pageRecordsTemp.add(ci);
+ }
+ System.debug('startIdx = ' + startIdx);
+ System.debug('endIdx = ' + endIdx);
+ System.debug('skipData = ' + skipData);
+ System.debug('pageRecords = ' + pageRecords.size());
+ String hos = '';
+ for (Integer i = startIdx; i < endIdx; i++) {
+ System.debug(
+ 'skipData.get(pageRecords.get(i).Prod.Id) = ' +
+ skipData.get(pageRecords.get(i).Prod.Id)
+ );
+ if (pageRecords.get(i).hospitalSpecialOffer == true) {
+ hos = 'ishos';
+ } else {
+ hos = 'nothos';
+ }
+ if (skipData.get(pageRecords.get(i).Prod.Id + hos) == null) {
+ pageRecordsTemp.add(pageRecords.get(i));
+ }
}
- public static String makeSoqlinventory() {
- String sqlTail = '(\'';
- for (Integer i = 0; i < zaikuId.size(); i++) {
- if (zaikuId[i] != null) {
- if (i < zaikuId.size() - 1) {
- sqlTail += zaikuId[i] + '\',\'';
- } else {
- sqlTail += zaikuId[i];
- }
- }
- }
- sqlTail += '\')';
- String msoql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,Product2__r.Packing_list_manual__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Category3__c,Category4__c,Category5__c FROM Product2__c ';
- msoql += ' WHERE Id in' + sqlTail;
- return msoql;
- }
+ System.debug('pageRecordsTemp = ' + pageRecordsTemp.size());
+ data.put('paginatedAccounts', paginatedAccounts);
+ data.put('pageRecords', pageRecordsTemp);
+ data.put('SearchDone', SearchDone);
+ data.put('hasHosPro', hasHosPro);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
- public static void initStandardController(String soql) {
- // init standard controller
- System.debug('soql =' + soql);
- System.debug('initStandardController star');
- //setCon = new ApexPages.StandardSetController(Database.getQueryLocator(soql));
- // sets the number of records in each page set
- //setCon.setPageSize(size);
- System.debug('initStandardController end');
+ private static String makeSoql(
+ String CateName,
+ String Category3,
+ String Category4,
+ String Category5
+ ) {
+ String sqlTail1 = '(\'';
+ for (Integer i = 0; i < zaikuId.size(); i++) {
+ if (zaikuId[i] != null) {
+ if (i < zaikuId.size() - 1) {
+ sqlTail1 += zaikuId[i] + '\',\'';
+ } else {
+ sqlTail1 += zaikuId[i];
+ }
+ }
}
-
- public static List<ConsumableorderdetailsInfo> makepagerecords() {
- List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
- Map<String, String> selectedIdMap = new Map<String, String>();
- System.debug('zhj1');
- //鍙栧嚭閫夋嫨鐨勪骇鍝�
- if (pageRecords != null) {
- System.debug('zhj2');
- for (ConsumableorderdetailsInfo ass : pageRecords) {
- if (ass.check == true) {
- if (ass.hospitalSpecialOffer == true) {
- selectedIdMap.put(ass.Prod.Id + 'ishos', ass.Prod.Id);
- } else {
- selectedIdMap.put(ass.Prod.Id + 'nothos', ass.Prod.Id);
- }
- reSet.add(ass);
- }
- }
- }
- System.debug('zhj3');
- pageRecords = new List<ConsumableorderdetailsInfo>();
- System.debug('reSet.size() = ' + reSet.size());
- if (editAble && String.isBlank(arriveorder)) {
- pageRecords = reSet;
- }
- //Integer pagestartNo = (setCon.getPageNumber() * size)-size;
- //Integer pageendNo = (setCon.getPageNumber() * size)>noOfRecords ? noOfRecords :(setCon.getPageNumber() * size-1);
- Integer addNo = 0;
- //update by rentx 2021-2-26 start
- System.debug('consumableorderdetailsSelectRecords.size() = ' + consumableorderdetailsSelectRecords.size());
- for (ConsumableorderdetailsInfo info : consumableorderdetailsSelectRecords) {
- Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c();
- if (
- (info.hospitalSpecialOffer && selectedIdMap.containsKey(info.Prod.Id + 'ishos')) ||
- (info.hospitalSpecialOffer == false && selectedIdMap.containsKey(info.Prod.Id + 'nothos'))
- ) {
- addNo++;
- } else {
- if (info.check == false) {
- info.orderdetails1 = orderdetails1;
- }
- pageRecords.add(info);
- addNo++;
- }
- }
- System.debug('pageRecords 2 = ' + pageRecords);
- System.debug('zhj5');
- System.debug('pageRecords = ' + pageRecords);
- return pageRecords;
+ sqlTail1 += '\')';
+ String soql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,Product2__r.Packing_list_manual__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Category3__c,Category4__c,Category5__c FROM Product2__c ';
+ soql += ' WHERE Id in' + sqlTail1;
+ if (!String.isBlank(CateName)) {
+ soql +=
+ ' AND (Name__c like \'%' +
+ String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
+ '%\' or Asset_Model_No__c like \'%' +
+ String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) +
+ '%\')';
}
-
- public static List<ConsumableorderdetailsInfo> makepagerecordsLwc() {
- List<ConsumableorderdetailsInfoLwc> reSetLwc = new List<ConsumableorderdetailsInfoLwc>();
- Map<String, String> selectedIdMap = new Map<String, String>();
- skipData = new Map<String, String>();
- System.debug('makepagerecordsLwc pageRecordsLwc = ' + pageRecordsLwc);
- //鍙栧嚭閫夋嫨鐨勪骇鍝�
- if (pageRecordsLwc != null) {
- for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
- System.debug('ass.check = ' + ass.check);
- if (ass.check == true) {
- if (ass.hospitalSpecialOffer == true) {
- selectedIdMap.put(ass.Prod.Id + 'ishos', ass.Prod.Id);
- skipData.put(ass.Prod.Id + 'ishos', ass.Prod.Id);
- } else {
- selectedIdMap.put(ass.Prod.Id + 'nothos', ass.Prod.Id);
- skipData.put(ass.Prod.Id + 'nothos', ass.Prod.Id);
- }
- reSetLwc.add(ass);
- }
- }
- }
- System.debug('selectedIdMap = ' + selectedIdMap);
- pageRecords = new List<ConsumableorderdetailsInfo>();
- if (editAble && String.isBlank(arriveorder)) {
- List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
- System.debug('reSetLwc = ' + reSetLwc);
- for (ConsumableorderdetailsInfoLwc assLwc : reSetLwc) {
- ConsumableorderdetailsInfo ci = new ConsumableorderdetailsInfo();
- ci.check = assLwc.check;
- ci.oldCheck = assLwc.oldCheck;
- ci.orderdetails1 = assLwc.orderdetails1;
- ci.orderdetails2 = assLwc.orderdetails2;
- ci.Prod = assLwc.Prod;
- ci.Boxnumber = assLwc.Boxnumber;
- ci.Piecenumber = assLwc.Piecenumber;
- ci.allnumber = assLwc.allnumber;
- ci.oldConsumableCount = assLwc.oldConsumableCount;
- ci.canSelect = assLwc.canSelect;
- ci.sortBy = assLwc.sortBy;
- ci.packinglist = assLwc.packinglist;
- ci.approbation_No = assLwc.approbation_No;
- ci.expiration_Date = assLwc.expiration_Date;
- ci.boxorpiecein = assLwc.boxorpiecein;
- ci.boxorpiece = assLwc.boxorpiece;
- ci.boxorpieceMap = assLwc.boxorpieceMap;
- ci.concc = assLwc.concc;
- ci.BoxPiece = assLwc.BoxPiece;
- ci.hospitalSpecialOffer = assLwc.hospitalSpecialOffer;
- ci.hosPro = assLwc.hosPro;
- reSet.add(ci);
- }
- pageRecords = reSet;
- System.debug('reSet = ' + reSet);
- addData = reSet.clone();
- System.debug('addData = reSet = ' + addData);
- }
- //Integer pagestartNo = (setCon.getPageNumber() * size)-size;
- //Integer pageendNo = (setCon.getPageNumber() * size)>noOfRecords ? noOfRecords :(setCon.getPageNumber() * size-1);
- Integer addNo = 0;
- //update by rentx 2021-2-26 start
- System.debug('consumableorderdetailsSelectRecords.size() = ' + consumableorderdetailsSelectRecords.size());
- for (ConsumableorderdetailsInfo info : consumableorderdetailsSelectRecords) {
- Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c();
- if (
- (info.hospitalSpecialOffer && selectedIdMap.containsKey(info.Prod.Id + 'ishos')) ||
- (info.hospitalSpecialOffer == false && selectedIdMap.containsKey(info.Prod.Id + 'nothos'))
- ) {
- System.debug('鍘绘帀鐨刬d : ' + info.Prod.Id);
- addNo++;
- addSize++;
- } else {
- if (info.check == false) {
- info.orderdetails1 = orderdetails1;
- }
- pageRecords.add(info);
- addNo++;
- }
- }
- System.debug('pageRecords.size() = ' + pageRecords.size());
- System.debug('end addData = ' + addData);
- return pageRecords;
+ if (!String.isBlank(Category3)) {
+ soql += ' AND Category3__c = \'' + Category3 + '\'';
}
+ if (!String.isBlank(Category4)) {
+ soql += ' AND Category4__c = \'' + Category4 + '\'';
+ }
+ if (!String.isBlank(Category5)) {
+ soql += ' AND Category5__c = \'' + Category5 + '\'';
+ }
+ return soql;
+ }
- // 淇濆瓨鎸夐挳
- @AuraEnabled
- public static ResponseBodyLWC save(
- Consumable_order__c cocLwc,
- String hospitalInfoLwc,
- String hospitalNameLwc,
- String secondaryDistributorLwc,
- List<ConsumableorderdetailsInfoLwc> pageRecordsLwc,
- String accountidLwc,
- String ESetIdLwc,
- List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc,
- String agencyProTypeLwc,
- String userWorkLocationLwc
+ public static String makeSoqlorderdet() {
+ String sqlTail = '(\'';
+ for (Integer i = 0; i < orderzaikuId.size(); i++) {
+ if (i < orderzaikuId.size() - 1) {
+ sqlTail += orderzaikuId[i] + '\',\'';
+ } else {
+ sqlTail += orderzaikuId[i];
+ }
+ }
+ sqlTail += '\')';
+ String msoql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,Product2__r.Packing_list_manual__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Category3__c,Category4__c,Category5__c FROM Product2__c ';
+ msoql += ' WHERE Id in' + sqlTail;
+ return msoql;
+ }
+
+ public static String makeSoqlinventory() {
+ String sqlTail = '(\'';
+ for (Integer i = 0; i < zaikuId.size(); i++) {
+ if (zaikuId[i] != null) {
+ if (i < zaikuId.size() - 1) {
+ sqlTail += zaikuId[i] + '\',\'';
+ } else {
+ sqlTail += zaikuId[i];
+ }
+ }
+ }
+ sqlTail += '\')';
+ String msoql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,Product2__r.Packing_list_manual__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Category3__c,Category4__c,Category5__c FROM Product2__c ';
+ msoql += ' WHERE Id in' + sqlTail;
+ return msoql;
+ }
+
+ public static void initStandardController(String soql) {
+ // init standard controller
+ System.debug('soql =' + soql);
+ System.debug('initStandardController star');
+ //setCon = new ApexPages.StandardSetController(Database.getQueryLocator(soql));
+ // sets the number of records in each page set
+ //setCon.setPageSize(size);
+ System.debug('initStandardController end');
+ }
+
+ public static List<ConsumableorderdetailsInfo> makepagerecords() {
+ List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
+ Map<String, String> selectedIdMap = new Map<String, String>();
+ System.debug('zhj1');
+ //鍙栧嚭閫夋嫨鐨勪骇鍝�
+ if (pageRecords != null) {
+ System.debug('zhj2');
+ for (ConsumableorderdetailsInfo ass : pageRecords) {
+ if (ass.check == true) {
+ if (ass.hospitalSpecialOffer == true) {
+ selectedIdMap.put(ass.Prod.Id + 'ishos', ass.Prod.Id);
+ } else {
+ selectedIdMap.put(ass.Prod.Id + 'nothos', ass.Prod.Id);
+ }
+ reSet.add(ass);
+ }
+ }
+ }
+ System.debug('zhj3');
+ pageRecords = new List<ConsumableorderdetailsInfo>();
+ System.debug('reSet.size() = ' + reSet.size());
+ if (editAble && String.isBlank(arriveorder)) {
+ pageRecords = reSet;
+ }
+ //Integer pagestartNo = (setCon.getPageNumber() * size)-size;
+ //Integer pageendNo = (setCon.getPageNumber() * size)>noOfRecords ? noOfRecords :(setCon.getPageNumber() * size-1);
+ Integer addNo = 0;
+ //update by rentx 2021-2-26 start
+ System.debug(
+ 'consumableorderdetailsSelectRecords.size() = ' +
+ consumableorderdetailsSelectRecords.size()
+ );
+ for (
+ ConsumableorderdetailsInfo info : consumableorderdetailsSelectRecords
) {
- coc = cocLwc;
- HospitalInfo = hospitalInfoLwc;
- HospitalName = hospitalNameLwc;
- SecondDealer = secondaryDistributorLwc;
- pageRecordsLwc = pageRecordsLwc;
- accountid = accountidLwc;
- consumableproductdetailsRecords = consumableproductdetailsRecordsLwc;
- ESetId = ESetIdLwc;
- agencyProType = agencyProTypeLwc;
- userWorkLocation = userWorkLocationLwc;
-
- System.debug('coc = ' + coc);
- System.debug('HospitalInfo = ' + HospitalInfo);
- System.debug('HospitalName = ' + HospitalName);
- System.debug('SecondDealer = ' + SecondDealer);
- System.debug('pageRecordsLwc = ' + pageRecordsLwc);
- System.debug('accountid = ' + accountid);
- System.debug('consumableproductdetailsRecords = ' + consumableproductdetailsRecords);
- System.debug('ESetId = ' + ESetId);
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- //璁㈠崟淇℃伅纭
- if (coc.SummonsForDirction__c == '' || coc.SummonsForDirction__c == null) {
- // coc.SummonsForDirction__c.addError('璇疯緭鍏ユ寚绀哄崟鐩殑');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ユ寚绀哄崟鐩殑', '');
- } else if (coc.SummonsForDirction__c == '鐩存帴閿�鍞粰鍖婚櫌') {
- if (String.isBlank(HospitalInfo) || String.isBlank(HospitalName)) {
- // coc.addError('璇疯緭鍏ュ尰闄�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ尰闄�', '');
- }
- if (String.isBlank(coc.Order_ForCustomerText__c)) {
- // coc.Order_ForCustomerText__c.addError('璇疯緭鍏ョ瀹�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ョ瀹�', '');
- } else if (String.isNotBlank(SecondDealer) || String.isNotBlank(coc.Order_ForDealerText__c)) {
- // coc.addError('涓嶉渶瑕佷簩绾х粡閿�鍟嗗拰缁忛攢鍟�(褰曞叆)淇℃伅' );
- // return null;
- return new ResponseBodyLWC('Error', 500, '涓嶉渶瑕佷簩绾х粡閿�鍟嗗拰缁忛攢鍟�(褰曞叆)淇℃伅', '');
- }
- } else if (coc.SummonsForDirction__c == '鍖婚櫌璇曠敤') {
- if (String.isBlank(HospitalInfo) || String.isBlank(HospitalName)) {
- // coc.addError('璇疯緭鍏ュ尰闄�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ尰闄�', '');
- }
- if (String.isBlank(coc.Order_ForCustomerText__c)) {
- // coc.Order_ForCustomerText__c.addError('璇疯緭鍏ョ瀹�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ョ瀹�', '');
- }
- } else if (coc.SummonsForDirction__c == '閿�鍞粰浜岀骇缁忛攢鍟�') {
- if (String.isBlank(SecondDealer) && String.isBlank(coc.Order_ForDealerText__c)) {
- // coc.addError('蹇呴』杈撳叆浜岀骇缁忛攢鍟嗘垨缁忛攢鍟�(褰曞叆)');
- // return null;
- return new ResponseBodyLWC('Error', 500, '蹇呴』杈撳叆浜岀骇缁忛攢鍟嗘垨缁忛攢鍟�(褰曞叆)', '');
- }
- if (String.isBlank(HospitalInfo) || String.isBlank(HospitalName)) {
- // coc.addError('璇疯緭鍏ュ尰闄�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ尰闄�', '');
- }
- if (String.isBlank(coc.Order_ForCustomerText__c)) {
- // coc.Order_ForCustomerText__c.addError('璇疯緭鍏ョ瀹�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ョ瀹�', '');
- }
- } else if (coc.SummonsForDirction__c == '浜掔浉璋冭揣') {
- if (String.isNotBlank(HospitalInfo) || String.isNotBlank(HospitalName)) {
- // coc.addError('涓嶉渶瑕佽緭鍏ュ尰闄�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '涓嶉渶瑕佽緭鍏ュ尰闄�', '');
- }
- if (String.isNotBlank(coc.Order_ForCustomerText__c)) {
- // coc.Order_ForCustomerText__c.addError('涓嶉渶瑕佽緭鍏ョ瀹�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '涓嶉渶瑕佽緭鍏ョ瀹�', '');
- }
- if (String.isBlank(SecondDealer) && String.isBlank(coc.Order_ForDealerText__c)) {
- // coc.addError('蹇呴』杈撳叆浜岀骇缁忛攢鍟嗘垨缁忛攢鍟�(褰曞叆)');
- // return null;
- return new ResponseBodyLWC('Error', 500, '蹇呴』杈撳叆浜岀骇缁忛攢鍟嗘垨缁忛攢鍟�(褰曞叆)', '');
- }
+ Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c();
+ if (
+ (info.hospitalSpecialOffer &&
+ selectedIdMap.containsKey(info.Prod.Id + 'ishos')) ||
+ (info.hospitalSpecialOffer == false &&
+ selectedIdMap.containsKey(info.Prod.Id + 'nothos'))
+ ) {
+ addNo++;
+ } else {
+ if (info.check == false) {
+ info.orderdetails1 = orderdetails1;
}
-
- Integer isHos = 0;
-
- Integer FLG = 0;
- Integer Count = 0;
- for (ConsumableorderdetailsInfoLwc CheckCount : pageRecordsLwc) {
- FLG = FLG + 1;
- if (CheckCount.check == false) {
- Count = Count + 1;
- } else {
- //add by rentx
- if (CheckCount.hospitalSpecialOffer) {
- isHos = isHos + 1;
- }
- //add by rentx
- }
- }
- if (Count == FLG) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '璇烽�夋嫨鎵�闇�娑堣�楀搧'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇烽�夋嫨鎵�闇�娑堣�楀搧', '');
- }
- // gzw 娉ㄩ噴 鍒ゆ柇鎻愬墠 20210308
- //checkOutPattern();
- //鏍规嵁鐢ㄦ埛閫変腑鐨勪骇鍝佺粰 鍑哄簱鍗曚笂鐨勬槸鍚﹀尰闄㈢壒浠峰嚭搴撳瓧娈佃祴鍊�
- Integer isHosCheckOutPattern = 0;
- for (ConsumableorderdetailsInfoLwc CheckCount : pageRecordsLwc) {
- if (CheckCount.check == true && CheckCount.hospitalSpecialOffer == true) {
- isHosCheckOutPattern = isHosCheckOutPattern + 1;
- }
- }
- if (isHosCheckOutPattern > 0) {
- coc.OutPattern__c = true;
- } else {
- coc.OutPattern__c = false;
- }
-
- // add by rentx 2021-3-10 start
- //鐗逛环鍖婚櫌鍑哄簱闈炴湰鍖婚櫌缁存姢鐨勭壒浠峰晢鍝佹椂,鎶ラ敊 闈炵壒浠峰尰闄㈠嚭搴撶淮鎶ゅ湪鍖婚櫌鐗逛环鍏崇郴琛ㄧ殑浜у搧鏃� 鎶ラ敊
- if (coc.SummonsForDirction__c != '浜掔浉璋冭揣') {
- //闈炵壒浠峰尰闄㈠嚭搴撶壒浠蜂骇鍝佹椂 鎶ラ敊(褰撳墠缁忛攢鍟嗕笅娌℃湁鐗逛环鍖婚櫌闄ゅ)
- List<hospitalprice__c> hopList = [SELECT id, hospital__c, product__c FROM hospitalprice__c WHERE account__c = :accountid];
- //缁忛攢鍟嗗搴斿尰闄笅鐨勬墍鏈夌壒浠蜂骇鍝�
- Map<String, String> proMap = new Map<String, String>();
- //缁忛攢鍟嗕笅鐨勬墍鏈夌壒浠蜂骇鍝�
- Map<String, String> allProMap = new Map<String, String>();
-
- if (hopList != null && hopList.size() > 0) {
- Boolean flag = false;
- if (HospitalInfo != null && HospitalInfo != '') {
- for (hospitalprice__c hp : hopList) {
- allProMap.put(hp.product__c, '');
- //濡傛灉褰撳墠 鍖婚櫌鐗逛环鍏崇郴涓殑鍖婚櫌瀵瑰簲鍑哄簱鍗曚笂鍑哄簱鐨勫尰闄�,鍒欐斁浜у搧id鍒癿ap
- if (hp.hospital__c == HospitalInfo) {
- flag = true;
- proMap.put(hp.product__c, '');
- }
- }
- }
- for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
- if (ass.check == true) {
- //鍒ゆ柇閫変腑鐨勫尰闄㈢壒浠蜂骇鍝�
- if (ass.hospitalSpecialOffer == true) {
- //鐢ㄦ埛閫変腑浜嗗綋鍓嶅尰闄笅鐨勭壒浠蜂骇鍝�
- if (proMap.containsKey(ass.Prod.Id)) {
- continue;
- //鐢ㄦ埛閫変腑浜嗘病鏈夌淮鎶ょ壒浠峰尰闄㈢殑鐗逛环浜у搧
- } else if (!allProMap.containsKey(ass.Prod.Id)) {
- continue;
- } else {
- //鐢ㄦ埛閫変腑闈炲綋鍓嶅尰闄㈢淮鎶ょ殑鐗逛环浜у搧
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '褰撳墠鍖婚櫌娌℃湁缁存姢 娑堣�楀搧:'+ ass.Prod.Name__c +' 鐨勭壒浠�'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '褰撳墠鍖婚櫌娌℃湁缁存姢 娑堣�楀搧:' + ass.Prod.Name__c + '鐨勭壒浠�', '');
- }
- } //闈炲尰闄㈢壒浠蜂骇鍝佸彲浠ュ嚭搴撶粰浠绘剰鍖婚櫌,鎵�浠ヤ笉闇�瑕佸垽鏂�
- }
- }
- }
- } else {
- //濡傛灉鏄簰鐩歌皟璐�,鍒ゆ柇 缁忛攢鍟�(褰曞叆) 鏄惁缁存姢浜� 褰撳墠閫変腑鐨勭壒浠蜂骇鍝�
- List<hospitalprice__c> hopList = [
- SELECT id, hospital__c, product__c
- FROM hospitalprice__c
- WHERE account__c = :coc.Order_ForDealerTextID__c
- ];
- Map<Id, String> proMap = new Map<Id, String>();
- if (hopList != null && hopList.size() > 0) {
- for (hospitalprice__c hpc : hopList) {
- proMap.put(hpc.product__c, '');
- }
-
- String proStr = '';
- for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
- if (ass.check == true) {
- if (ass.hospitalSpecialOffer == true) {
- if (!proMap.containsKey(ass.Prod.Id)) {
- proStr += ass.Prod.Name__c + ',';
- }
- }
- }
- }
- if (proStr != '') {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '缁忛攢鍟�:'+coc.Order_ForDealerText__c +' 娌℃湁娑堣�楀搧:'+proStr.substring(0,proStr.length()-1) + ' 鐨勭壒浠�'));
- // return null;
- return new ResponseBodyLWC(
- 'Error',
- 500,
- '缁忛攢鍟�:' +
- coc.Order_ForDealerText__c +
- ' 娌℃湁娑堣�楀搧:' +
- proStr.substring(0, proStr.length() - 1) +
- ' 鐨勭壒浠�',
- ''
- );
- }
- }
- }
-
- // checkOutPattern();
- Consumable_order__c p = new Consumable_order__c();
- List<Consumable_orderdetails__c> Ins = new List<Consumable_orderdetails__c>();
- List<Consumable_order_details2__c> InsProduct = new List<Consumable_order_details2__c>();
- Savepoint sp = Database.setSavepoint();
- // try {
- //鏂板缓璁㈠崟鏃�
- if (String.isEmpty(ESetId)) {
- p.Name = '*';
- p.Order_type__c = '浼犵エ';
- p.Order_ProType__c = agencyProType;
- if (coc.SummonsStatus_c__c == null || String.isBlank(coc.SummonsStatus_c__c))
- coc.SummonsStatus_c__c = '鑽夋涓�';
- // update strat by vivek 2019-7-12
- p.NoConfirmedPrice__c = coc.NoConfirmedPrice__c;
- // update end by vivek 2019-7-12
- p.SummonsStatus_c__c = coc.SummonsStatus_c__c;
- if (coc.Arrive_Order__c != null) {
- p.Arrive_Order__c = coc.Arrive_Order__c;
- }
- p.Offers_Price__c = coc.Offers_Price__c;
- p.Dealer_Info__c = accountid;
- if (String.isBlank(SecondDealer)) {
- p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
- p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
- } else {
- p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
- p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
- p.Order_ForDealer__c = SecondDealer;
- }
- P.Order_ForDealerText__c = coc.Order_ForDealerText__c;
- P.Order_ForDealerTextID__c = coc.Order_ForDealerTextID__c;
- p.Order_date__c = coc.Order_date__c;
- p.SummonsForDirction__c = coc.SummonsForDirction__c;
- p.RecordTypeid = System.Label.RT_ConOrder_Outboundorder;
- // update start by vivek 2019-7-15
- p.NoConfirmedPrice__c = coc.NoConfirmedPrice__c;
- // update end by vivek 2019-7-15
- //add by rentx
- p.OutPattern__c = coc.OutPattern__c;
- //add by rentx
- //Map<String,String> ProductNewMap = new Map<String, String>();
- for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
- if (ass.check == true) {
- if (ass.orderdetails1.Delivery_List_RMB__c < 0) {
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ユ纭殑鍑鸿揣鍗曚环 (鍏�)', '');
- }
- if (ass.orderdetails1.Delivery_List_RMB__c == null && coc.SummonsForDirction__c != '鍖婚櫌璇曠敤') {
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ユ纭殑鍑鸿揣鍗曚环 (鍏�)', '');
- }
- if ((ass.orderdetails1.Delivery_List_RMB__c == null || ass.orderdetails1.Delivery_List_RMB__c == 0) && coc.SummonsForDirction__c != '鍖婚櫌璇曠敤') {
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ嚭璐у崟浠� (鍏�)', '');
- }
- if (
- ass.orderdetails1.Delivery_List_RMB__c == 0 &&
- (coc.SummonsForDirction__c == '閿�鍞粰浜岀骇缁忛攢鍟�' ||
- coc.SummonsForDirction__c == '鐩存帴閿�鍞粰鍖婚櫌')
- ) {
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ嚭璐у崟浠� (鍏�)', '');
- }
- if (ass.orderdetails1.Shipment_Count__c == null || ass.orderdetails1.Shipment_Count__c == 0) {
- // ass.orderdetails1.Shipment_Count__c.addError('璇疯緭鍏ュ嚭璐ф暟閲�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ嚭璐ф暟閲�', '');
- }
-
- if (ass.orderdetails1.Box_Piece__c == null || ass.orderdetails1.Box_Piece__c == '') {
- // ass.orderdetails1.Box_Piece__c.addError('璇疯緭鍏ュ崟浣�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ崟浣�', '');
- }
- if (ass.orderdetails1.Box_Piece__c == '鐩�') {
- if (ass.orderdetails1.Shipment_Count__c > ass.Boxnumber) {
- //ass.orderdetails1.Shipment_Count__c.addError('搴撳瓨涓嶈冻');
- if (ass.oldCheck == false) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.Prod.Name__c + '搴撳瓨涓嶈冻'));
- return new ResponseBodyLWC('Error', 500, '娑堣�楀搧' + ass.Prod.Name__c + '搴撳瓨涓嶈冻', '');
- } else {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.orderdetails1.Consumable_Product__r.Name__c + '搴撳瓨涓嶈冻'));
- return new ResponseBodyLWC(
- 'Error',
- 500,
- '娑堣�楀搧' +
- ass.orderdetails1.Consumable_Product__r.Name__c +
- '搴撳瓨涓嶈冻',
- ''
- );
- }
- }
- } else if (ass.orderdetails1.Box_Piece__c == '涓�') {
- if (ass.orderdetails1.Shipment_Count__c > ass.Piecenumber) {
- //ass.orderdetails1.Shipment_Count__c.addError('搴撳瓨涓嶈冻');
- if (ass.oldCheck == false) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.Prod.Name__c + '搴撳瓨涓嶈冻'));
- return new ResponseBodyLWC('Error', 500, '娑堣�楀搧' + ass.Prod.Name__c + '搴撳瓨涓嶈冻', '');
- } else {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.orderdetails1.Consumable_Product__r.Name__c + '搴撳瓨涓嶈冻'));
- return new ResponseBodyLWC(
- 'Error',
- 500,
- '娑堣�楀搧' +
- ass.orderdetails1.Consumable_Product__r.Name__c +
- '搴撳瓨涓嶈冻',
- ''
- );
- }
- }
- }
- }
- }
- insert p;
- ESetId = p.id;
- List<Consumable_order__c> detailName = new List<Consumable_order__c>();
- detailName = [SELECT id, Name FROM Consumable_order__c WHERE id = :ESetId];
- Integer i = 1;
- for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
- if (ass.check == true) {
- Consumable_orderdetails__c InsAfterDel = new Consumable_orderdetails__c();
- String str = string.valueOf(i);
- if (str.length() == 1) {
- str = '0' + str;
- }
- InsAfterDel.Name = detailName[0].name + '-' + str;
- InsAfterDel.Shipment_Count__c = ass.orderdetails1.Shipment_Count__c;
- InsAfterDel.Consumable_order__c = p.id;
- InsAfterDel.Consumable_Product__c = ass.Prod.id;
- InsAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
- InsAfterDel.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c;
- // TODO 榛樿 鐩� 锛岄渶瑕佷慨姝�
- InsAfterDel.Box_Piece__c = ass.orderdetails1.Box_Piece__c;
- InsAfterDel.Out_unit__c = ass.orderdetails1.Box_Piece__c;
- //InsAfterDel.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c;
- InsAfterDel.Dealer_Custom_Price__c = ass.orderdetails1.Dealer_Custom_Price__c;
- InsAfterDel.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
- //add by rentx 2021-2-26 start
- InsAfterDel.isOutPattern__c = ass.hospitalSpecialOffer;
- //add by rentx 2021-2-26 end
- i++;
- Ins.add(InsAfterDel);
- }
- }
- // 濡傛灉 鍑哄簱鍗� 鍜� OCM鍙戣揣Header杩� 鐨勮瘽锛屽彂璐х殑Detail2 Copy鍒� 鍑哄簱鍗曠殑Detail2閲�
- if (getExistarrive()) {
- for (ConsumableorderdetailsInfo ass : consumableproductdetailsRecords) {
- //BlockForP;
- Consumable_order_details2__c InsProductDet = new Consumable_order_details2__c();
- InsProductDet.Id = ass.orderdetails2.Id;
- InsProductDet.Consumable_ZS_order__c = p.id;
- i++;
- InsProduct.add(InsProductDet);
- }
- }
- if (Ins.size() > 0) {
- insert Ins;
- }
- if (InsProduct.size() > 0) {
- //ControllerUtil.updateOrderDetailsSatus(InsProduct);
- update InsProduct;
- }
- } else if (ESetId != null || ESetId.length() > 0) {
- //淇敼涔嬪悗 淇濆瓨璁㈠崟
- List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
- // update start by vivek 2019-7-15 add "NoConfirmedPrice__c" in select
- cocinfo = [
- SELECT Id, Name, SummonsStatus_c__c, NoConfirmedPrice__c, Dealer_Info__c, Order_ForHospital__c, SummonsForDirction__c
- FROM Consumable_order__c
- WHERE Id = :ESetId
- ];
- // update end by vivek 2019-7-15
- if (cocinfo.size() > 0) {
- p = cocinfo[0];
- }
- p.Name = coc.Name;
- p.Dealer_Info__c = accountid;
- p.Order_ProType__c = agencyProType;
- if (String.isEmpty(SecondDealer)) {
- p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
- p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
- System.debug('SecondDealer = ' + SecondDealer);
- p.Order_ForDealer__c = null;
- } else {
- p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null;
- p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
- p.Order_ForDealer__c = SecondDealer;
- }
- P.Order_ForDealerText__c = coc.Order_ForDealerText__c;
- P.Order_ForDealerTextID__c = coc.Order_ForDealerTextID__c;
- p.Order_date__c = coc.Order_date__c;
- p.SummonsForDirction__c = coc.SummonsForDirction__c;
- //add by rentx
- p.OutPattern__c = coc.OutPattern__c;
- // update start by vivek 2019-7-15
- if (p.SummonsStatus_c__c == '浠锋牸鏈畾') {
- p.NoConfirmedPrice__c = false;
- p.SummonsStatus_c__c = '宸插畬鎴�';
- } else {
- p.SummonsStatus_c__c = '鑽夋涓�';
- }
- // p.SummonsStatus_c__c = '鑽夋涓�';
- // update end by vivek 2019-7-15
- Integer i = 1;
- //Map<String,String> ProductOldMap = new Map<String, String>();
- for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
- if (ass.check == true) {
- if (ass.orderdetails1.Delivery_List_RMB__c < 0) {
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ユ纭殑鍑鸿揣鍗曚环 (鍏�)', '');
- }
- Consumable_orderdetails__c InsAfterDel = new Consumable_orderdetails__c();
- if ((ass.orderdetails1.Delivery_List_RMB__c == null || ass.orderdetails1.Delivery_List_RMB__c == 0) && coc.SummonsForDirction__c != '鍖婚櫌璇曠敤') {
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ嚭璐у崟浠� (鍏�)', '');
- }
- if (
- ass.orderdetails1.Delivery_List_RMB__c == 0 &&
- (coc.SummonsForDirction__c == '閿�鍞粰浜岀骇缁忛攢鍟�' ||
- coc.SummonsForDirction__c == '鐩存帴閿�鍞粰鍖婚櫌')
- ) {
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ嚭璐у崟浠� (鍏�)', '');
- }
- if (ass.orderdetails1.Box_Piece__c == null || ass.orderdetails1.Box_Piece__c == '') {
- // ass.orderdetails1.Box_Piece__c.addError('璇疯緭鍏ュ崟浣�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ崟浣�', '');
- }
- if (ass.orderdetails1.Box_Piece__c == '鐩�') {
- if (ass.orderdetails1.Shipment_Count__c > ass.Boxnumber) {
- //ass.orderdetails1.Shipment_Count__c.addError('搴撳瓨涓嶈冻');
- if (ass.oldCheck == false) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.Prod.Name__c + '搴撳瓨涓嶈冻'));
- return new ResponseBodyLWC('Error', 500, '娑堣�楀搧' + ass.Prod.Name__c + '搴撳瓨涓嶈冻', '');
- } else {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.orderdetails1.Consumable_Product__r.Name__c + '搴撳瓨涓嶈冻'));
- return new ResponseBodyLWC(
- 'Error',
- 500,
- '娑堣�楀搧' +
- ass.orderdetails1.Consumable_Product__r.Name__c +
- '搴撳瓨涓嶈冻',
- ''
- );
- }
- }
- } else if (ass.orderdetails1.Box_Piece__c == '涓�') {
- if (ass.orderdetails1.Shipment_Count__c > ass.Piecenumber) {
- if (ass.oldCheck == false) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.Prod.Name__c + '搴撳瓨涓嶈冻'));
- return new ResponseBodyLWC('Error', 500, '娑堣�楀搧' + ass.Prod.Name__c + '搴撳瓨涓嶈冻', '');
- } else {
- //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.orderdetails1.Consumable_Product__r.Name__c + '搴撳瓨涓嶈冻'));
- return new ResponseBodyLWC(
- 'Error',
- 500,
- '娑堣�楀搧' +
- ass.orderdetails1.Consumable_Product__r.Name__c +
- '搴撳瓨涓嶈冻',
- ''
- );
- }
- }
- }
- if (ass.orderdetails1.Shipment_Count__c == null || ass.orderdetails1.Shipment_Count__c == 0) {
- // ass.orderdetails1.Shipment_Count__c.addError('璇疯緭鍏ュ嚭璐ф暟閲�');
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ嚭璐ф暟閲�', '');
- } else {
- String str = string.valueOf(i);
- if (str.length() == 1) {
- str = '0' + str;
- }
- InsAfterDel.Name = p.name + '-' + str;
- InsAfterDel.Shipment_Count__c = ass.orderdetails1.Shipment_Count__c;
- InsAfterDel.Consumable_order__c = ESetId;
- InsAfterDel.Consumable_Product__c = ass.Prod.id;
- InsAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
- InsAfterDel.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c;
- InsAfterDel.Box_Piece__c = ass.orderdetails1.Box_Piece__c;
- InsAfterDel.Out_unit__c = ass.orderdetails1.Box_Piece__c;
- //InsAfterDel.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c;
- InsAfterDel.Dealer_Custom_Price__c = ass.orderdetails1.Dealer_Custom_Price__c;
- InsAfterDel.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
- //add by rentx 2021-2-26 start
- InsAfterDel.isOutPattern__c = ass.hospitalSpecialOffer;
- //add by rentx 2021-2-26 end
- i++;
- Ins.add(InsAfterDel);
- }
- }
- }
- update p;
- List<Consumable_orderdetails__c> qs = new List<Consumable_orderdetails__c>();
- qs = [SELECT Id FROM Consumable_orderdetails__c WHERE Consumable_order__c = :ESetId];
- if (qs.size() > 0) {
- delete qs;
- }
- if (Ins.size() > 0) {
- insert Ins;
- }
- }
- // }catch (Exception ex) {
- // Database.rollback(sp);
- // // ApexPages.addMessages(ex);
- // // return null;
- // //return new ResponseBodyLWC('Error',500, ex.getMessage(), '');
- // return new ResponseBodyLWC('Error',500, JSON.serialize(ex), '');
- // }
- data.put('ESetId', ESetId);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ pageRecords.add(info);
+ addNo++;
+ }
}
+ System.debug('pageRecords 2 = ' + pageRecords);
+ System.debug('zhj5');
+ System.debug('pageRecords = ' + pageRecords);
+ return pageRecords;
+ }
- public static void checkOutPattern() {
- //鏍规嵁鐢ㄦ埛閫変腑鐨勪骇鍝佺粰 鍑哄簱鍗曚笂鐨勬槸鍚﹀尰闄㈢壒浠峰嚭搴撳瓧娈佃祴鍊�
- Integer isHos = 0;
- for (ConsumableorderdetailsInfo CheckCount : pageRecords) {
- if (CheckCount.check == true && CheckCount.hospitalSpecialOffer == true) {
- ishos = ishos + 1;
- }
+ public static List<ConsumableorderdetailsInfo> makepagerecordsLwc() {
+ List<ConsumableorderdetailsInfoLwc> reSetLwc = new List<ConsumableorderdetailsInfoLwc>();
+ Map<String, String> selectedIdMap = new Map<String, String>();
+ skipData = new Map<String, String>();
+ System.debug('makepagerecordsLwc pageRecordsLwc = ' + pageRecordsLwc);
+ //鍙栧嚭閫夋嫨鐨勪骇鍝�
+ if (pageRecordsLwc != null) {
+ for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
+ System.debug('ass.check = ' + ass.check);
+ if (ass.check == true) {
+ if (ass.hospitalSpecialOffer == true) {
+ selectedIdMap.put(ass.Prod.Id + 'ishos', ass.Prod.Id);
+ skipData.put(ass.Prod.Id + 'ishos', ass.Prod.Id);
+ } else {
+ selectedIdMap.put(ass.Prod.Id + 'nothos', ass.Prod.Id);
+ skipData.put(ass.Prod.Id + 'nothos', ass.Prod.Id);
+ }
+ reSetLwc.add(ass);
}
- if (isHos > 0) {
- coc.OutPattern__c = true;
- } else {
- coc.OutPattern__c = false;
- }
+ }
}
-
- //鎵撳嵃PDF
- @AuraEnabled
- public static ResponseBodyLWC PraseToPDF(Consumable_order__c cocLwc, String ESetId) {
- System.debug('cocLwc = ' + cocLwc);
- System.debug('ESetId = ' + ESetId);
- coc = cocLwc;
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
-
- if (coc.SummonsStatus_c__c == '鎵瑰噯') {
- Consumable_order__c P = new Consumable_order__c();
- List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
- // update start by vivek 2019-7-15 add 鈥淣oConfirmedPrice__c鈥� in select
- cocinfo = [
- SELECT
- Id,
- Name,
- SummonsStatus_c__c,
- NoConfirmedPrice__c,
- Dealer_Info__c,
- Order_ForHospital__c,
- SummonsForDirction__c,
- Billed_Status__c
- FROM Consumable_order__c
- WHERE Id = :ESetId
- ];
- // update end by vivek 2019-7-15
- if (cocinfo.size() > 0) {
- p = cocinfo[0];
- }
- p.SummonsStatus_c__c = '鍑哄簱鍗曞凡鎵撳嵃';
- update p;
- }
- data.put('ESetId', ESetId);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ System.debug('selectedIdMap = ' + selectedIdMap);
+ pageRecords = new List<ConsumableorderdetailsInfo>();
+ if (editAble && String.isBlank(arriveorder)) {
+ List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
+ System.debug('reSetLwc = ' + reSetLwc);
+ for (ConsumableorderdetailsInfoLwc assLwc : reSetLwc) {
+ ConsumableorderdetailsInfo ci = new ConsumableorderdetailsInfo();
+ ci.check = assLwc.check;
+ ci.oldCheck = assLwc.oldCheck;
+ ci.orderdetails1 = assLwc.orderdetails1;
+ ci.orderdetails2 = assLwc.orderdetails2;
+ ci.Prod = assLwc.Prod;
+ ci.Boxnumber = assLwc.Boxnumber;
+ ci.Piecenumber = assLwc.Piecenumber;
+ ci.allnumber = assLwc.allnumber;
+ ci.oldConsumableCount = assLwc.oldConsumableCount;
+ ci.canSelect = assLwc.canSelect;
+ ci.sortBy = assLwc.sortBy;
+ ci.packinglist = assLwc.packinglist;
+ ci.approbation_No = assLwc.approbation_No;
+ ci.expiration_Date = assLwc.expiration_Date;
+ ci.boxorpiecein = assLwc.boxorpiecein;
+ ci.boxorpiece = assLwc.boxorpiece;
+ ci.boxorpieceMap = assLwc.boxorpieceMap;
+ ci.concc = assLwc.concc;
+ ci.BoxPiece = assLwc.BoxPiece;
+ ci.hospitalSpecialOffer = assLwc.hospitalSpecialOffer;
+ ci.hosPro = assLwc.hosPro;
+ reSet.add(ci);
+ }
+ pageRecords = reSet;
+ System.debug('reSet = ' + reSet);
+ addData = reSet.clone();
+ System.debug('addData = reSet = ' + addData);
}
-
- //鏌ユ壘缁忛攢鍟�
- @AuraEnabled(cacheable=true scope='global')
- public static List<LookupSearchResult> search(String searchTerm) {
- System.debug('searchTerm = ' + searchTerm);
- String nameCondition = '';
- nameCondition += '%' + String.escapeSingleQuotes(searchTerm.replaceAll('%', '\\%')) + '%';
- List<Account> accs = new List<Account>();
- System.debug('nameCondition = ' + nameCondition);
- //鏌ヨ鏉′欢淇敼
- //绛涢�夊垽鏂潯浠讹細褰撳墠璐㈠勾鐨�4/1 ~ 绗簩骞寸殑6/30 聽& ET or ENG绫诲瀷 & 褰撳墠鐢ㄦ埛绫诲瀷
- //1 and 2
- //1. Integer year 2022/4/1 ~ 2023/6/30
- //寮�濮嬫棩鏈� + 缁撴潫鏃ユ湡
- //Contract_Decide_Start_Date__c>=寮�濮嬫棩鏈� and Contract_Decide_End_Date__c<缁撴潫鏃ユ湡
- //2. 娣诲姞缁忛攢鍟嗗厑閿�绫诲瀷锛欵T缁忛攢鍟嗗崗璁紱ENG鑰楁潗缁忛攢鍟嗗崗璁�
- //鍙栧綋鍓嶇敤鎴风殑绫诲瀷锛屽鏋滅敤鎴风被鍨嬫槸ET,ET缁忛攢鍟嗗崗璁� = true
- // Date today = Date.today();
- // Integer thisYear = today.year();
- // Integer nextYear = today.year() + 1;
- // Date thisDatetime = Date.newInstance(thisYear, 4, 1);
- // Date nextDatetime = Date.newInstance(nextYear, 6, 30);
- // System.debug('thisDatetime = ' + thisDatetime);
- // System.debug('nextDatetime = ' + nextDatetime);
-
- // User UserProTypecTemp = [select UserPro_Type__c from User where id =: UserInfo.getUserId()];
- // System.debug('UserInfo.getUserId() = ' + UserInfo.getUserId());
- // System.debug('UserProTypecTemp = ' + UserProTypecTemp);
- // System.debug('UserProTypecTemp.UserPro_Type__c = ' + UserProTypecTemp.UserPro_Type__c);
- // if (UserProTypecTemp.UserPro_Type__c == 'ENG') {
- // accs = [
- // SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity
- // FROM Account
- // WHERE
- // // Name = '濂ユ灄宸存柉锛堝寳浜級閿�鍞湇鍔℃湁闄愬叕鍙�'
- // // AND
- // Name LIKE :nameCondition
- // AND RecordType.DeveloperName = 'AgencyContract'
- // AND Contract_Decide_Start_Date__c >= :thisDatetime
- // AND Contract_Decide_End_Date__c <= :nextDatetime
- // AND ENG_Dealer__c = true
- // ORDER BY Name
- // LIMIT 49
- // ];
- // }
- // if (UserProTypecTemp.UserPro_Type__c == 'ET') {
- // accs = [
- // SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity
- // FROM Account
- // WHERE
- // // Name = '濂ユ灄宸存柉锛堝寳浜級閿�鍞湇鍔℃湁闄愬叕鍙�'
- // // AND
- // Name LIKE :nameCondition
- // AND RecordType.DeveloperName = 'AgencyContract'
- // AND Contract_Decide_Start_Date__c >= :thisDatetime
- // AND Contract_Decide_End_Date__c <= :nextDatetime
- // AND ET_SP_Dealer__c = true
- // ORDER BY Name
- // LIMIT 49
- // ];
- // }
-
-
- Date today = Date.today();
- //Date today = Date.newInstance(2023, 3, 1);
- Integer thisMonth = today.month();
- System.debug('thisMonth = ' + thisMonth);
-
- Integer lastYear = today.year() - 1;
- Integer thisYear = today.year();
- Integer nextYear = today.year() + 1;
-
- Date lastDatetime = Date.newInstance(lastYear, 4, 1);
- Date thisDatetime = Date.newInstance(thisYear, 4, 1);
- Date thisDatetime2 = Date.newInstance(thisYear, 7, 1);
- Date nextDatetime = Date.newInstance(nextYear, 7, 1);
- System.debug('lastDatetime = ' + lastDatetime);
- System.debug('thisDatetime = ' + thisDatetime);
- System.debug('thisDatetime2 = ' + thisDatetime2);
- System.debug('nextDatetime = ' + nextDatetime);
- System.debug('UserInfo.getUserId() = ' + UserInfo.getUserId());
- User UserProTypecTemp = [select UserPro_Type__c from User where id =: UserInfo.getUserId()];
-
- String sql = 'SELECT id, Parentid FROM Account WHERE Parent.Name LIKE :nameCondition ';
- if(thisMonth < 4){
- sql += 'AND Contract_Decide_Start_Date__c >= :lastDatetime AND Contract_Decide_End_Date__c < :thisDatetime2 ';
- }else if(thisMonth >= 4 && thisMonth <= 6){
- sql += 'AND Contract_Decide_Start_Date__c >= :lastDatetime AND Contract_Decide_End_Date__c < :nextDatetime ';
- }else{
- sql += 'AND Contract_Decide_Start_Date__c >= :thisDatetime AND Contract_Decide_End_Date__c < :nextDatetime ';
- }
- if (UserProTypecTemp.UserPro_Type__c == 'ENG') {
- sql += 'AND ENG_Dealer__c = true';
- }
- if (UserProTypecTemp.UserPro_Type__c == 'ET') {
- sql += 'AND ET_SP_Dealer__c = true';
- }
- System.debug('sql = ' + sql);
- accs = Database.query(sql);
- // 鐢ㄤ簬淇濆瓨鐗圭害缁忛攢鍟嗗尮閰嶅埌鐨勫叾鐖剁被鐨刬d
- Set<String> pids = new Set<String>();
- for (Account acc : accs) {
- pids.add(acc.Parentid);
- }
-
- accs = [
- SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity
- FROM Account
- WHERE
- (Id IN :pids
- OR (Name = '濂ユ灄宸存柉锛堝寳浜級閿�鍞湇鍔℃湁闄愬叕鍙�'
- AND Name LIKE :nameCondition))
- AND RecordType.DeveloperName = 'Agency'
- ORDER BY Name
- LIMIT 49
- ];
-
- // accs = [
- // SELECT id, Parentid
- // FROM Account
- // WHERE
- // Parent.Name LIKE :nameCondition
- // AND Contract_Decide_Start_Date__c <= :Date.Today()
- // AND Contract_Decide_End_Date__c >= :Date.Today()
- // ];
-
- // 鐢ㄤ簬淇濆瓨鐗圭害缁忛攢鍟嗗尮閰嶅埌鐨勫叾鐖剁被鐨刬d
- // Set<String> pids = new Set<String>();
- // for (Account acc : accs) {
- // pids.add(acc.Parentid);
- // }
- // accs = [
- // SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity
- // FROM Account
- // WHERE
- // (Id IN :pids
- // OR (Name = '濂ユ灄宸存柉锛堝寳浜級閿�鍞湇鍔℃湁闄愬叕鍙�'
- // AND Name LIKE :nameCondition))
- // AND RecordType.DeveloperName = 'Agency'
- // AND Is_Active__c != '鐒″姽'
- // ORDER BY Name
- // LIMIT 5
- // ];
- System.debug('accs = ' + accs);
- List<LookupSearchResult> results = new List<LookupSearchResult>();
- String accountIcon = 'standard:account';
- for (Account account : accs) {
- String subtitle = account.BillingCity == null ? 'Account' : 'Account 鈥� ' + account.BillingCity;
- results.add(new LookupSearchResult(account.Id, 'Account', accountIcon, account.Name, subtitle));
- }
- results.sort();
- System.debug('results = ' + results);
- return results;
- }
-
- //淇濆瓨闄勪欢
- @AuraEnabled
- public static String saveFile(Id recordId, String fileName, String base64Data) {
- base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
- ContentVersion cv = new ContentVersion();
- cv.Title = fileName;
- cv.PathOnClient = '/' + fileName;
- cv.FirstPublishLocationId = recordId;
- cv.VersionData = EncodingUtil.base64Decode(base64Data);
- cv.IsMajorVersion = true;
- insert cv;
- return cv.Id;
- }
-
- //鑾峰彇闄勪欢
- @AuraEnabled
- public static ResponseBodyLWC getFiles(Id recordId) {
- System.debug('getFiles recordId = ' + recordId);
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- List<ContentVersion> cvList = [
- SELECT id, Title, CreatedBy.Name, PathOnClient, CreatedDate, ContentDocumentId
- FROM ContentVersion
- WHERE FirstPublishLocationId = :recordId
- ];
- data.put('cvList', cvList);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
- }
-
- //鍒犻櫎闄勪欢
- @AuraEnabled
- public static ResponseBodyLWC deleteAtt(String contentVersionId){
- try {
- ContentVersion conVersion = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :contentVersionId];
- String contentDocumentId = conVersion.ContentDocumentId;
- ContentDocument conDocument = [SELECT Id FROM ContentDocument where Id = :contentDocumentId];
- delete conDocument;
- return new ResponseBodyLWC('Success',200,'','');
- } catch (Exception e) {
- return new ResponseBodyLWC('Error',500, e.getMessage() + e.getLineNumber(), '');
- }
- }
-
- //璺宠浆鍑鸿揣/閿�鍞�
- @AuraEnabled
- public static ResponseBodyLWC GoodsDelivery(
- Consumable_order__c cocLwc,
- String ESetId,
- List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc
+ //Integer pagestartNo = (setCon.getPageNumber() * size)-size;
+ //Integer pageendNo = (setCon.getPageNumber() * size)>noOfRecords ? noOfRecords :(setCon.getPageNumber() * size-1);
+ Integer addNo = 0;
+ //update by rentx 2021-2-26 start
+ System.debug(
+ 'consumableorderdetailsSelectRecords.size() = ' +
+ consumableorderdetailsSelectRecords.size()
+ );
+ for (
+ ConsumableorderdetailsInfo info : consumableorderdetailsSelectRecords
) {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
- coc = cocLwc;
- ESetId = ESetId;
- pageRecordsLwc = pageRecordsLwcLwc;
- if (coc.SummonsForDirction__c == '浜掔浉璋冭揣') {
- List<Account> accList = [
- SELECT Id
- FROM Account
- WHERE Name = :coc.Order_ForDealerText__c AND RecordType.DeveloperName = 'Agency'
- ];
- if (accList.size() < 1) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '璇疯緭鍏ヤ簩绾х粡閿�鍟嗗叏绉帮紒'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ヤ簩绾х粡閿�鍟嗗叏绉帮紒', '');
- }
+ Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c();
+ if (
+ (info.hospitalSpecialOffer &&
+ selectedIdMap.containsKey(info.Prod.Id + 'ishos')) ||
+ (info.hospitalSpecialOffer == false &&
+ selectedIdMap.containsKey(info.Prod.Id + 'nothos'))
+ ) {
+ System.debug('鍘绘帀鐨刬d : ' + info.Prod.Id);
+ addNo++;
+ addSize++;
+ } else {
+ if (info.check == false) {
+ info.orderdetails1 = orderdetails1;
}
- if (coc.SummonsStatus_c__c == '鎵瑰噯') {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '璇峰厛鎵撳嵃鎸囩ず鍗曪紒'));
- // return null;
- return new ResponseBodyLWC('Error', 500, '璇峰厛鎵撳嵃鎸囩ず鍗曪紒', '');
+ pageRecords.add(info);
+ addNo++;
+ }
+ }
+ System.debug('pageRecords.size() = ' + pageRecords.size());
+ System.debug('end addData = ' + addData);
+ return pageRecords;
+ }
+
+ // 淇濆瓨鎸夐挳
+ @AuraEnabled
+ public static ResponseBodyLWC save(
+ Consumable_order__c cocLwc,
+ String hospitalInfoLwc,
+ String hospitalNameLwc,
+ String secondaryDistributorLwc,
+ List<ConsumableorderdetailsInfoLwc> pageRecordsLwc,
+ String accountidLwc,
+ String ESetIdLwc,
+ List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc,
+ String agencyProTypeLwc,
+ String userWorkLocationLwc
+ ) {
+ coc = cocLwc;
+ HospitalInfo = hospitalInfoLwc;
+ HospitalName = hospitalNameLwc;
+ SecondDealer = secondaryDistributorLwc;
+ pageRecordsLwc = pageRecordsLwc;
+ accountid = accountidLwc;
+ consumableproductdetailsRecords = consumableproductdetailsRecordsLwc;
+ ESetId = ESetIdLwc;
+ agencyProType = agencyProTypeLwc;
+ userWorkLocation = userWorkLocationLwc;
+
+ System.debug('coc = ' + coc);
+ System.debug('HospitalInfo = ' + HospitalInfo);
+ System.debug('HospitalName = ' + HospitalName);
+ System.debug('SecondDealer = ' + SecondDealer);
+ System.debug('pageRecordsLwc = ' + pageRecordsLwc);
+ System.debug('accountid = ' + accountid);
+ System.debug(
+ 'consumableproductdetailsRecords = ' + consumableproductdetailsRecords
+ );
+ System.debug('ESetId = ' + ESetId);
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ //璁㈠崟淇℃伅纭
+ if (coc.SummonsForDirction__c == '' || coc.SummonsForDirction__c == null) {
+ // coc.SummonsForDirction__c.addError('璇疯緭鍏ユ寚绀哄崟鐩殑');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ユ寚绀哄崟鐩殑', '');
+ } else if (coc.SummonsForDirction__c == '鐩存帴閿�鍞粰鍖婚櫌') {
+ if (String.isBlank(HospitalInfo) || String.isBlank(HospitalName)) {
+ // coc.addError('璇疯緭鍏ュ尰闄�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ尰闄�', '');
+ }
+ if (String.isBlank(coc.Order_ForCustomerText__c)) {
+ // coc.Order_ForCustomerText__c.addError('璇疯緭鍏ョ瀹�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ョ瀹�', '');
+ } else if (
+ String.isNotBlank(SecondDealer) ||
+ String.isNotBlank(coc.Order_ForDealerText__c)
+ ) {
+ // coc.addError('涓嶉渶瑕佷簩绾х粡閿�鍟嗗拰缁忛攢鍟�(褰曞叆)淇℃伅' );
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '涓嶉渶瑕佷簩绾х粡閿�鍟嗗拰缁忛攢鍟�(褰曞叆)淇℃伅',
+ ''
+ );
+ }
+ } else if (coc.SummonsForDirction__c == '鍖婚櫌璇曠敤') {
+ if (String.isBlank(HospitalInfo) || String.isBlank(HospitalName)) {
+ // coc.addError('璇疯緭鍏ュ尰闄�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ尰闄�', '');
+ }
+ if (String.isBlank(coc.Order_ForCustomerText__c)) {
+ // coc.Order_ForCustomerText__c.addError('璇疯緭鍏ョ瀹�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ョ瀹�', '');
+ }
+ } else if (coc.SummonsForDirction__c == '閿�鍞粰浜岀骇缁忛攢鍟�') {
+ if (
+ String.isBlank(SecondDealer) &&
+ String.isBlank(coc.Order_ForDealerText__c)
+ ) {
+ // coc.addError('蹇呴』杈撳叆浜岀骇缁忛攢鍟嗘垨缁忛攢鍟�(褰曞叆)');
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '蹇呴』杈撳叆浜岀骇缁忛攢鍟嗘垨缁忛攢鍟�(褰曞叆)',
+ ''
+ );
+ }
+ if (String.isBlank(HospitalInfo) || String.isBlank(HospitalName)) {
+ // coc.addError('璇疯緭鍏ュ尰闄�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ尰闄�', '');
+ }
+ if (String.isBlank(coc.Order_ForCustomerText__c)) {
+ // coc.Order_ForCustomerText__c.addError('璇疯緭鍏ョ瀹�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ョ瀹�', '');
+ }
+ } else if (coc.SummonsForDirction__c == '浜掔浉璋冭揣') {
+ if (String.isNotBlank(HospitalInfo) || String.isNotBlank(HospitalName)) {
+ // coc.addError('涓嶉渶瑕佽緭鍏ュ尰闄�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '涓嶉渶瑕佽緭鍏ュ尰闄�', '');
+ }
+ if (String.isNotBlank(coc.Order_ForCustomerText__c)) {
+ // coc.Order_ForCustomerText__c.addError('涓嶉渶瑕佽緭鍏ョ瀹�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '涓嶉渶瑕佽緭鍏ョ瀹�', '');
+ }
+ if (
+ String.isBlank(SecondDealer) &&
+ String.isBlank(coc.Order_ForDealerText__c)
+ ) {
+ // coc.addError('蹇呴』杈撳叆浜岀骇缁忛攢鍟嗘垨缁忛攢鍟�(褰曞叆)');
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '蹇呴』杈撳叆浜岀骇缁忛攢鍟嗘垨缁忛攢鍟�(褰曞叆)',
+ ''
+ );
+ }
+ }
+
+ Integer isHos = 0;
+
+ Integer FLG = 0;
+ Integer Count = 0;
+ for (ConsumableorderdetailsInfoLwc CheckCount : pageRecordsLwc) {
+ FLG = FLG + 1;
+ if (CheckCount.check == false) {
+ Count = Count + 1;
+ } else {
+ //add by rentx
+ if (CheckCount.hospitalSpecialOffer) {
+ isHos = isHos + 1;
+ }
+ //add by rentx
+ }
+ }
+ if (Count == FLG) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '璇烽�夋嫨鎵�闇�娑堣�楀搧'));
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇烽�夋嫨鎵�闇�娑堣�楀搧', '');
+ }
+ // gzw 娉ㄩ噴 鍒ゆ柇鎻愬墠 20210308
+ //checkOutPattern();
+ //鏍规嵁鐢ㄦ埛閫変腑鐨勪骇鍝佺粰 鍑哄簱鍗曚笂鐨勬槸鍚﹀尰闄㈢壒浠峰嚭搴撳瓧娈佃祴鍊�
+ Integer isHosCheckOutPattern = 0;
+ for (ConsumableorderdetailsInfoLwc CheckCount : pageRecordsLwc) {
+ if (CheckCount.check == true && CheckCount.hospitalSpecialOffer == true) {
+ isHosCheckOutPattern = isHosCheckOutPattern + 1;
+ }
+ }
+ if (isHosCheckOutPattern > 0) {
+ coc.OutPattern__c = true;
+ } else {
+ coc.OutPattern__c = false;
+ }
+
+ // add by rentx 2021-3-10 start
+ //鐗逛环鍖婚櫌鍑哄簱闈炴湰鍖婚櫌缁存姢鐨勭壒浠峰晢鍝佹椂,鎶ラ敊 闈炵壒浠峰尰闄㈠嚭搴撶淮鎶ゅ湪鍖婚櫌鐗逛环鍏崇郴琛ㄧ殑浜у搧鏃� 鎶ラ敊
+ if (coc.SummonsForDirction__c != '浜掔浉璋冭揣') {
+ //闈炵壒浠峰尰闄㈠嚭搴撶壒浠蜂骇鍝佹椂 鎶ラ敊(褰撳墠缁忛攢鍟嗕笅娌℃湁鐗逛环鍖婚櫌闄ゅ)
+ List<hospitalprice__c> hopList = [
+ SELECT id, hospital__c, product__c
+ FROM hospitalprice__c
+ WHERE account__c = :accountid
+ ];
+ //缁忛攢鍟嗗搴斿尰闄笅鐨勬墍鏈夌壒浠蜂骇鍝�
+ Map<String, String> proMap = new Map<String, String>();
+ //缁忛攢鍟嗕笅鐨勬墍鏈夌壒浠蜂骇鍝�
+ Map<String, String> allProMap = new Map<String, String>();
+
+ if (hopList != null && hopList.size() > 0) {
+ Boolean flag = false;
+ if (HospitalInfo != null && HospitalInfo != '') {
+ for (hospitalprice__c hp : hopList) {
+ allProMap.put(hp.product__c, '');
+ //濡傛灉褰撳墠 鍖婚櫌鐗逛环鍏崇郴涓殑鍖婚櫌瀵瑰簲鍑哄簱鍗曚笂鍑哄簱鐨勫尰闄�,鍒欐斁浜у搧id鍒癿ap
+ if (hp.hospital__c == HospitalInfo) {
+ flag = true;
+ proMap.put(hp.product__c, '');
+ }
+ }
}
for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
- if (ass.orderdetails1.Shipment_Count__c > ass.allnumber) {
- // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.orderdetails1.Consumable_Product__r.Name__c + '搴撳瓨涓嶈冻'));
+ if (ass.check == true) {
+ //鍒ゆ柇閫変腑鐨勫尰闄㈢壒浠蜂骇鍝�
+ if (ass.hospitalSpecialOffer == true) {
+ //鐢ㄦ埛閫変腑浜嗗綋鍓嶅尰闄笅鐨勭壒浠蜂骇鍝�
+ if (proMap.containsKey(ass.Prod.Id)) {
+ continue;
+ //鐢ㄦ埛閫変腑浜嗘病鏈夌淮鎶ょ壒浠峰尰闄㈢殑鐗逛环浜у搧
+ } else if (!allProMap.containsKey(ass.Prod.Id)) {
+ continue;
+ } else {
+ //鐢ㄦ埛閫変腑闈炲綋鍓嶅尰闄㈢淮鎶ょ殑鐗逛环浜у搧
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '褰撳墠鍖婚櫌娌℃湁缁存姢 娑堣�楀搧:'+ ass.Prod.Name__c +' 鐨勭壒浠�'));
// return null;
- return new ResponseBodyLWC('Error', 500, '娑堣�楀搧' + ass.orderdetails1.Consumable_Product__r.Name__c + '搴撳瓨涓嶈冻', '');
- }
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '褰撳墠鍖婚櫌娌℃湁缁存姢 娑堣�楀搧:' + ass.Prod.Name__c + '鐨勭壒浠�',
+ ''
+ );
+ }
+ } //闈炲尰闄㈢壒浠蜂骇鍝佸彲浠ュ嚭搴撶粰浠绘剰鍖婚櫌,鎵�浠ヤ笉闇�瑕佸垽鏂�
+ }
}
- data.put('ESetid', ESetid);
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ }
+ } else {
+ //濡傛灉鏄簰鐩歌皟璐�,鍒ゆ柇 缁忛攢鍟�(褰曞叆) 鏄惁缁存姢浜� 褰撳墠閫変腑鐨勭壒浠蜂骇鍝�
+ List<hospitalprice__c> hopList = [
+ SELECT id, hospital__c, product__c
+ FROM hospitalprice__c
+ WHERE account__c = :coc.Order_ForDealerTextID__c
+ ];
+ Map<Id, String> proMap = new Map<Id, String>();
+ if (hopList != null && hopList.size() > 0) {
+ for (hospitalprice__c hpc : hopList) {
+ proMap.put(hpc.product__c, '');
+ }
+
+ String proStr = '';
+ for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
+ if (ass.check == true) {
+ if (ass.hospitalSpecialOffer == true) {
+ if (!proMap.containsKey(ass.Prod.Id)) {
+ proStr += ass.Prod.Name__c + ',';
+ }
+ }
+ }
+ }
+ if (proStr != '') {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '缁忛攢鍟�:'+coc.Order_ForDealerText__c +' 娌℃湁娑堣�楀搧:'+proStr.substring(0,proStr.length()-1) + ' 鐨勭壒浠�'));
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '缁忛攢鍟�:' +
+ coc.Order_ForDealerText__c +
+ ' 娌℃湁娑堣�楀搧:' +
+ proStr.substring(0, proStr.length() - 1) +
+ ' 鐨勭壒浠�',
+ ''
+ );
+ }
+ }
}
- //鍒犻櫎鎸夐挳
+ // checkOutPattern();
+ Consumable_order__c p = new Consumable_order__c();
+ List<Consumable_orderdetails__c> Ins = new List<Consumable_orderdetails__c>();
+ List<Consumable_order_details2__c> InsProduct = new List<Consumable_order_details2__c>();
+ Savepoint sp = Database.setSavepoint();
+ // try {
+ //鏂板缓璁㈠崟鏃�
+ if (String.isEmpty(ESetId)) {
+ p.Name = '*';
+ p.Order_type__c = '浼犵エ';
+ p.Order_ProType__c = agencyProType;
+ if (
+ coc.SummonsStatus_c__c == null || String.isBlank(coc.SummonsStatus_c__c)
+ )
+ coc.SummonsStatus_c__c = '鑽夋涓�';
+ // update strat by vivek 2019-7-12
+ p.NoConfirmedPrice__c = coc.NoConfirmedPrice__c;
+ // update end by vivek 2019-7-12
+ p.SummonsStatus_c__c = coc.SummonsStatus_c__c;
+ if (coc.Arrive_Order__c != null) {
+ p.Arrive_Order__c = coc.Arrive_Order__c;
+ }
+ p.Offers_Price__c = coc.Offers_Price__c;
+ p.Dealer_Info__c = accountid;
+ if (String.isBlank(SecondDealer)) {
+ p.Order_ForHospital__c = String.isNotBlank(HospitalInfo)
+ ? HospitalInfo
+ : null;
+ p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
+ } else {
+ p.Order_ForHospital__c = String.isNotBlank(HospitalInfo)
+ ? HospitalInfo
+ : null;
+ p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
+ p.Order_ForDealer__c = SecondDealer;
+ }
+ P.Order_ForDealerText__c = coc.Order_ForDealerText__c;
+ P.Order_ForDealerTextID__c = coc.Order_ForDealerTextID__c;
+ p.Order_date__c = coc.Order_date__c;
+ p.SummonsForDirction__c = coc.SummonsForDirction__c;
+ p.RecordTypeid = System.Label.RT_ConOrder_Outboundorder;
+ // update start by vivek 2019-7-15
+ p.NoConfirmedPrice__c = coc.NoConfirmedPrice__c;
+ // update end by vivek 2019-7-15
+ //add by rentx
+ p.OutPattern__c = coc.OutPattern__c;
+ //add by rentx
+ //Map<String,String> ProductNewMap = new Map<String, String>();
+ for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
+ if (ass.check == true) {
+ if (ass.orderdetails1.Delivery_List_RMB__c < 0) {
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '璇疯緭鍏ユ纭殑鍑鸿揣鍗曚环 (鍏�)',
+ ''
+ );
+ }
+ if (
+ ass.orderdetails1.Delivery_List_RMB__c == null &&
+ coc.SummonsForDirction__c != '鍖婚櫌璇曠敤'
+ ) {
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '璇疯緭鍏ユ纭殑鍑鸿揣鍗曚环 (鍏�)',
+ ''
+ );
+ }
+ if (
+ (ass.orderdetails1.Delivery_List_RMB__c == null ||
+ ass.orderdetails1.Delivery_List_RMB__c == 0) &&
+ coc.SummonsForDirction__c != '鍖婚櫌璇曠敤'
+ ) {
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ嚭璐у崟浠� (鍏�)', '');
+ }
+ if (
+ ass.orderdetails1.Delivery_List_RMB__c == 0 &&
+ (coc.SummonsForDirction__c == '閿�鍞粰浜岀骇缁忛攢鍟�' ||
+ coc.SummonsForDirction__c == '鐩存帴閿�鍞粰鍖婚櫌')
+ ) {
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ嚭璐у崟浠� (鍏�)', '');
+ }
+ if (
+ ass.orderdetails1.Shipment_Count__c == null ||
+ ass.orderdetails1.Shipment_Count__c == 0
+ ) {
+ // ass.orderdetails1.Shipment_Count__c.addError('璇疯緭鍏ュ嚭璐ф暟閲�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ嚭璐ф暟閲�', '');
+ }
+
+ if (
+ ass.orderdetails1.Box_Piece__c == null ||
+ ass.orderdetails1.Box_Piece__c == ''
+ ) {
+ // ass.orderdetails1.Box_Piece__c.addError('璇疯緭鍏ュ崟浣�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ崟浣�', '');
+ }
+ if (ass.orderdetails1.Box_Piece__c == '鐩�') {
+ if (ass.orderdetails1.Shipment_Count__c > ass.Boxnumber) {
+ //ass.orderdetails1.Shipment_Count__c.addError('搴撳瓨涓嶈冻');
+ if (ass.oldCheck == false) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.Prod.Name__c + '搴撳瓨涓嶈冻'));
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '娑堣�楀搧' + ass.Prod.Name__c + '搴撳瓨涓嶈冻',
+ ''
+ );
+ } else {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.orderdetails1.Consumable_Product__r.Name__c + '搴撳瓨涓嶈冻'));
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '娑堣�楀搧' +
+ ass.orderdetails1.Consumable_Product__r.Name__c +
+ '搴撳瓨涓嶈冻',
+ ''
+ );
+ }
+ }
+ } else if (ass.orderdetails1.Box_Piece__c == '涓�') {
+ if (ass.orderdetails1.Shipment_Count__c > ass.Piecenumber) {
+ //ass.orderdetails1.Shipment_Count__c.addError('搴撳瓨涓嶈冻');
+ if (ass.oldCheck == false) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.Prod.Name__c + '搴撳瓨涓嶈冻'));
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '娑堣�楀搧' + ass.Prod.Name__c + '搴撳瓨涓嶈冻',
+ ''
+ );
+ } else {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.orderdetails1.Consumable_Product__r.Name__c + '搴撳瓨涓嶈冻'));
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '娑堣�楀搧' +
+ ass.orderdetails1.Consumable_Product__r.Name__c +
+ '搴撳瓨涓嶈冻',
+ ''
+ );
+ }
+ }
+ }
+ }
+ }
+ insert p;
+ ESetId = p.id;
+ List<Consumable_order__c> detailName = new List<Consumable_order__c>();
+ detailName = [
+ SELECT id, Name
+ FROM Consumable_order__c
+ WHERE id = :ESetId
+ ];
+ Integer i = 1;
+ for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
+ if (ass.check == true) {
+ Consumable_orderdetails__c InsAfterDel = new Consumable_orderdetails__c();
+ String str = string.valueOf(i);
+ if (str.length() == 1) {
+ str = '0' + str;
+ }
+ InsAfterDel.Name = detailName[0].name + '-' + str;
+ InsAfterDel.Shipment_Count__c = ass.orderdetails1.Shipment_Count__c;
+ InsAfterDel.Consumable_order__c = p.id;
+ InsAfterDel.Consumable_Product__c = ass.Prod.id;
+ InsAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
+ InsAfterDel.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c;
+ // TODO 榛樿 鐩� 锛岄渶瑕佷慨姝�
+ InsAfterDel.Box_Piece__c = ass.orderdetails1.Box_Piece__c;
+ InsAfterDel.Out_unit__c = ass.orderdetails1.Box_Piece__c;
+ //InsAfterDel.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c;
+ InsAfterDel.Dealer_Custom_Price__c = ass.orderdetails1.Dealer_Custom_Price__c;
+ InsAfterDel.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ //add by rentx 2021-2-26 start
+ InsAfterDel.isOutPattern__c = ass.hospitalSpecialOffer;
+ //add by rentx 2021-2-26 end
+ i++;
+ Ins.add(InsAfterDel);
+ }
+ }
+ // 濡傛灉 鍑哄簱鍗� 鍜� OCM鍙戣揣Header杩� 鐨勮瘽锛屽彂璐х殑Detail2 Copy鍒� 鍑哄簱鍗曠殑Detail2閲�
+ if (getExistarrive()) {
+ for (ConsumableorderdetailsInfo ass : consumableproductdetailsRecords) {
+ //BlockForP;
+ Consumable_order_details2__c InsProductDet = new Consumable_order_details2__c();
+ InsProductDet.Id = ass.orderdetails2.Id;
+ InsProductDet.Consumable_ZS_order__c = p.id;
+ i++;
+ InsProduct.add(InsProductDet);
+ }
+ }
+ if (Ins.size() > 0) {
+ insert Ins;
+ }
+ if (InsProduct.size() > 0) {
+ //ControllerUtil.updateOrderDetailsSatus(InsProduct);
+ update InsProduct;
+ }
+ } else if (ESetId != null || ESetId.length() > 0) {
+ //淇敼涔嬪悗 淇濆瓨璁㈠崟
+ List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
+ // update start by vivek 2019-7-15 add "NoConfirmedPrice__c" in select
+ cocinfo = [
+ SELECT
+ Id,
+ Name,
+ SummonsStatus_c__c,
+ NoConfirmedPrice__c,
+ Dealer_Info__c,
+ Order_ForHospital__c,
+ SummonsForDirction__c
+ FROM Consumable_order__c
+ WHERE Id = :ESetId
+ ];
+ // update end by vivek 2019-7-15
+ if (cocinfo.size() > 0) {
+ p = cocinfo[0];
+ }
+ p.Name = coc.Name;
+ p.Dealer_Info__c = accountid;
+ p.Order_ProType__c = agencyProType;
+ if (String.isEmpty(SecondDealer)) {
+ p.Order_ForHospital__c = String.isNotBlank(HospitalInfo)
+ ? HospitalInfo
+ : null;
+ p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
+ System.debug('SecondDealer = ' + SecondDealer);
+ p.Order_ForDealer__c = null;
+ } else {
+ p.Order_ForHospital__c = String.isNotBlank(HospitalInfo)
+ ? HospitalInfo
+ : null;
+ p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c;
+ p.Order_ForDealer__c = SecondDealer;
+ }
+ P.Order_ForDealerText__c = coc.Order_ForDealerText__c;
+ P.Order_ForDealerTextID__c = coc.Order_ForDealerTextID__c;
+ p.Order_date__c = coc.Order_date__c;
+ p.SummonsForDirction__c = coc.SummonsForDirction__c;
+ //add by rentx
+ p.OutPattern__c = coc.OutPattern__c;
+ // update start by vivek 2019-7-15
+ if (p.SummonsStatus_c__c == '浠锋牸鏈畾') {
+ p.NoConfirmedPrice__c = false;
+ p.SummonsStatus_c__c = '宸插畬鎴�';
+ } else {
+ p.SummonsStatus_c__c = '鑽夋涓�';
+ }
+ // p.SummonsStatus_c__c = '鑽夋涓�';
+ // update end by vivek 2019-7-15
+ Integer i = 1;
+ //Map<String,String> ProductOldMap = new Map<String, String>();
+ for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
+ if (ass.check == true) {
+ if (ass.orderdetails1.Delivery_List_RMB__c < 0) {
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '璇疯緭鍏ユ纭殑鍑鸿揣鍗曚环 (鍏�)',
+ ''
+ );
+ }
+ Consumable_orderdetails__c InsAfterDel = new Consumable_orderdetails__c();
+ if (
+ (ass.orderdetails1.Delivery_List_RMB__c == null ||
+ ass.orderdetails1.Delivery_List_RMB__c == 0) &&
+ coc.SummonsForDirction__c != '鍖婚櫌璇曠敤'
+ ) {
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ嚭璐у崟浠� (鍏�)', '');
+ }
+ if (
+ ass.orderdetails1.Delivery_List_RMB__c == 0 &&
+ (coc.SummonsForDirction__c == '閿�鍞粰浜岀骇缁忛攢鍟�' ||
+ coc.SummonsForDirction__c == '鐩存帴閿�鍞粰鍖婚櫌')
+ ) {
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ嚭璐у崟浠� (鍏�)', '');
+ }
+ if (
+ ass.orderdetails1.Box_Piece__c == null ||
+ ass.orderdetails1.Box_Piece__c == ''
+ ) {
+ // ass.orderdetails1.Box_Piece__c.addError('璇疯緭鍏ュ崟浣�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ崟浣�', '');
+ }
+ if (ass.orderdetails1.Box_Piece__c == '鐩�') {
+ if (ass.orderdetails1.Shipment_Count__c > ass.Boxnumber) {
+ //ass.orderdetails1.Shipment_Count__c.addError('搴撳瓨涓嶈冻');
+ if (ass.oldCheck == false) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.Prod.Name__c + '搴撳瓨涓嶈冻'));
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '娑堣�楀搧' + ass.Prod.Name__c + '搴撳瓨涓嶈冻',
+ ''
+ );
+ } else {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.orderdetails1.Consumable_Product__r.Name__c + '搴撳瓨涓嶈冻'));
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '娑堣�楀搧' +
+ ass.orderdetails1.Consumable_Product__r.Name__c +
+ '搴撳瓨涓嶈冻',
+ ''
+ );
+ }
+ }
+ } else if (ass.orderdetails1.Box_Piece__c == '涓�') {
+ if (ass.orderdetails1.Shipment_Count__c > ass.Piecenumber) {
+ if (ass.oldCheck == false) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.Prod.Name__c + '搴撳瓨涓嶈冻'));
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '娑堣�楀搧' + ass.Prod.Name__c + '搴撳瓨涓嶈冻',
+ ''
+ );
+ } else {
+ //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.orderdetails1.Consumable_Product__r.Name__c + '搴撳瓨涓嶈冻'));
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '娑堣�楀搧' +
+ ass.orderdetails1.Consumable_Product__r.Name__c +
+ '搴撳瓨涓嶈冻',
+ ''
+ );
+ }
+ }
+ }
+ if (
+ ass.orderdetails1.Shipment_Count__c == null ||
+ ass.orderdetails1.Shipment_Count__c == 0
+ ) {
+ // ass.orderdetails1.Shipment_Count__c.addError('璇疯緭鍏ュ嚭璐ф暟閲�');
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ュ嚭璐ф暟閲�', '');
+ } else {
+ String str = string.valueOf(i);
+ if (str.length() == 1) {
+ str = '0' + str;
+ }
+ InsAfterDel.Name = p.name + '-' + str;
+ InsAfterDel.Shipment_Count__c = ass.orderdetails1.Shipment_Count__c;
+ InsAfterDel.Consumable_order__c = ESetId;
+ InsAfterDel.Consumable_Product__c = ass.Prod.id;
+ InsAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c;
+ InsAfterDel.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c;
+ InsAfterDel.Box_Piece__c = ass.orderdetails1.Box_Piece__c;
+ InsAfterDel.Out_unit__c = ass.orderdetails1.Box_Piece__c;
+ //InsAfterDel.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c;
+ InsAfterDel.Dealer_Custom_Price__c = ass.orderdetails1.Dealer_Custom_Price__c;
+ InsAfterDel.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
+ //add by rentx 2021-2-26 start
+ InsAfterDel.isOutPattern__c = ass.hospitalSpecialOffer;
+ //add by rentx 2021-2-26 end
+ i++;
+ Ins.add(InsAfterDel);
+ }
+ }
+ }
+ update p;
+ List<Consumable_orderdetails__c> qs = new List<Consumable_orderdetails__c>();
+ qs = [
+ SELECT Id
+ FROM Consumable_orderdetails__c
+ WHERE Consumable_order__c = :ESetId
+ ];
+ if (qs.size() > 0) {
+ delete qs;
+ }
+ if (Ins.size() > 0) {
+ insert Ins;
+ }
+ }
+ // }catch (Exception ex) {
+ // Database.rollback(sp);
+ // // ApexPages.addMessages(ex);
+ // // return null;
+ // //return new ResponseBodyLWC('Error',500, ex.getMessage(), '');
+ // return new ResponseBodyLWC('Error',500, JSON.serialize(ex), '');
+ // }
+ data.put('ESetId', ESetId);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ public static void checkOutPattern() {
+ //鏍规嵁鐢ㄦ埛閫変腑鐨勪骇鍝佺粰 鍑哄簱鍗曚笂鐨勬槸鍚﹀尰闄㈢壒浠峰嚭搴撳瓧娈佃祴鍊�
+ Integer isHos = 0;
+ for (ConsumableorderdetailsInfo CheckCount : pageRecords) {
+ if (CheckCount.check == true && CheckCount.hospitalSpecialOffer == true) {
+ ishos = ishos + 1;
+ }
+ }
+ if (isHos > 0) {
+ coc.OutPattern__c = true;
+ } else {
+ coc.OutPattern__c = false;
+ }
+ }
+
+ //鎵撳嵃PDF
+ @AuraEnabled
+ public static ResponseBodyLWC PraseToPDF(
+ Consumable_order__c cocLwc,
+ String ESetId
+ ) {
+ System.debug('cocLwc = ' + cocLwc);
+ System.debug('ESetId = ' + ESetId);
+ coc = cocLwc;
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ if (coc.SummonsStatus_c__c == '鎵瑰噯') {
+ Consumable_order__c P = new Consumable_order__c();
+ List<Consumable_order__c> cocinfo = new List<Consumable_order__c>();
+ // update start by vivek 2019-7-15 add 鈥淣oConfirmedPrice__c鈥� in select
+ cocinfo = [
+ SELECT
+ Id,
+ Name,
+ SummonsStatus_c__c,
+ NoConfirmedPrice__c,
+ Dealer_Info__c,
+ Order_ForHospital__c,
+ SummonsForDirction__c,
+ Billed_Status__c
+ FROM Consumable_order__c
+ WHERE Id = :ESetId
+ ];
+ // update end by vivek 2019-7-15
+ if (cocinfo.size() > 0) {
+ p = cocinfo[0];
+ }
+ p.SummonsStatus_c__c = '鍑哄簱鍗曞凡鎵撳嵃';
+ update p;
+ }
+ data.put('ESetId', ESetId);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ //鏌ユ壘缁忛攢鍟�
+ @AuraEnabled(cacheable=true scope='global')
+ public static List<LookupSearchResult> search(String searchTerm) {
+ System.debug('searchTerm = ' + searchTerm);
+ String nameCondition = '';
+ nameCondition +=
+ '%' +
+ String.escapeSingleQuotes(searchTerm.replaceAll('%', '\\%')) +
+ '%';
+ List<Account> accs = new List<Account>();
+ System.debug('nameCondition = ' + nameCondition);
+ //鏌ヨ鏉′欢淇敼
+ //绛涢�夊垽鏂潯浠讹細褰撳墠璐㈠勾鐨�4/1 ~ 绗簩骞寸殑6/30 聽& ET or ENG绫诲瀷 & 褰撳墠鐢ㄦ埛绫诲瀷
+ //1 and 2
+ //1. Integer year 2022/4/1 ~ 2023/6/30
+ //寮�濮嬫棩鏈� + 缁撴潫鏃ユ湡
+ //Contract_Decide_Start_Date__c>=寮�濮嬫棩鏈� and Contract_Decide_End_Date__c<缁撴潫鏃ユ湡
+ //2. 娣诲姞缁忛攢鍟嗗厑閿�绫诲瀷锛欵T缁忛攢鍟嗗崗璁紱ENG鑰楁潗缁忛攢鍟嗗崗璁�
+ //鍙栧綋鍓嶇敤鎴风殑绫诲瀷锛屽鏋滅敤鎴风被鍨嬫槸ET,ET缁忛攢鍟嗗崗璁� = true
+ // Date today = Date.today();
+ // Integer thisYear = today.year();
+ // Integer nextYear = today.year() + 1;
+ // Date thisDatetime = Date.newInstance(thisYear, 4, 1);
+ // Date nextDatetime = Date.newInstance(nextYear, 6, 30);
+ // System.debug('thisDatetime = ' + thisDatetime);
+ // System.debug('nextDatetime = ' + nextDatetime);
+
+ // User UserProTypecTemp = [select UserPro_Type__c from User where id =: UserInfo.getUserId()];
+ // System.debug('UserInfo.getUserId() = ' + UserInfo.getUserId());
+ // System.debug('UserProTypecTemp = ' + UserProTypecTemp);
+ // System.debug('UserProTypecTemp.UserPro_Type__c = ' + UserProTypecTemp.UserPro_Type__c);
+ // if (UserProTypecTemp.UserPro_Type__c == 'ENG') {
+ // accs = [
+ // SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity
+ // FROM Account
+ // WHERE
+ // // Name = '濂ユ灄宸存柉锛堝寳浜級閿�鍞湇鍔℃湁闄愬叕鍙�'
+ // // AND
+ // Name LIKE :nameCondition
+ // AND RecordType.DeveloperName = 'AgencyContract'
+ // AND Contract_Decide_Start_Date__c >= :thisDatetime
+ // AND Contract_Decide_End_Date__c <= :nextDatetime
+ // AND ENG_Dealer__c = true
+ // ORDER BY Name
+ // LIMIT 49
+ // ];
+ // }
+ // if (UserProTypecTemp.UserPro_Type__c == 'ET') {
+ // accs = [
+ // SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity
+ // FROM Account
+ // WHERE
+ // // Name = '濂ユ灄宸存柉锛堝寳浜級閿�鍞湇鍔℃湁闄愬叕鍙�'
+ // // AND
+ // Name LIKE :nameCondition
+ // AND RecordType.DeveloperName = 'AgencyContract'
+ // AND Contract_Decide_Start_Date__c >= :thisDatetime
+ // AND Contract_Decide_End_Date__c <= :nextDatetime
+ // AND ET_SP_Dealer__c = true
+ // ORDER BY Name
+ // LIMIT 49
+ // ];
+ // }
+
+ Date today = Date.today();
+ //Date today = Date.newInstance(2023, 3, 1);
+ Integer thisMonth = today.month();
+ System.debug('thisMonth = ' + thisMonth);
+
+ Integer lastYear = today.year() - 1;
+ Integer thisYear = today.year();
+ Integer nextYear = today.year() + 1;
+
+ Date lastDatetime = Date.newInstance(lastYear, 4, 1);
+ Date thisDatetime = Date.newInstance(thisYear, 4, 1);
+ Date thisDatetime2 = Date.newInstance(thisYear, 7, 1);
+ Date nextDatetime = Date.newInstance(nextYear, 7, 1);
+ System.debug('lastDatetime = ' + lastDatetime);
+ System.debug('thisDatetime = ' + thisDatetime);
+ System.debug('thisDatetime2 = ' + thisDatetime2);
+ System.debug('nextDatetime = ' + nextDatetime);
+ System.debug('UserInfo.getUserId() = ' + UserInfo.getUserId());
+ User UserProTypecTemp = [
+ SELECT UserPro_Type__c
+ FROM User
+ WHERE id = :UserInfo.getUserId()
+ ];
+
+ String sql = 'SELECT id, Parentid FROM Account WHERE Parent.Name LIKE :nameCondition ';
+ if (thisMonth < 4) {
+ sql += 'AND Contract_Decide_Start_Date__c >= :lastDatetime AND Contract_Decide_End_Date__c < :thisDatetime2 ';
+ } else if (thisMonth >= 4 && thisMonth <= 6) {
+ sql += 'AND Contract_Decide_Start_Date__c >= :lastDatetime AND Contract_Decide_End_Date__c < :nextDatetime ';
+ } else {
+ sql += 'AND Contract_Decide_Start_Date__c >= :thisDatetime AND Contract_Decide_End_Date__c < :nextDatetime ';
+ }
+ if (UserProTypecTemp.UserPro_Type__c == 'ENG') {
+ sql += 'AND ENG_Dealer__c = true';
+ }
+ if (UserProTypecTemp.UserPro_Type__c == 'ET') {
+ sql += 'AND ET_SP_Dealer__c = true';
+ }
+ System.debug('sql = ' + sql);
+ accs = Database.query(sql);
+ // 鐢ㄤ簬淇濆瓨鐗圭害缁忛攢鍟嗗尮閰嶅埌鐨勫叾鐖剁被鐨刬d
+ Set<String> pids = new Set<String>();
+ for (Account acc : accs) {
+ pids.add(acc.Parentid);
+ }
+
+ accs = [
+ SELECT
+ Id,
+ Name,
+ Department_Class__c,
+ Department_Class__r.Name,
+ Hospital__c,
+ Hospital__r.Name,
+ BillingCity
+ FROM Account
+ WHERE
+ (Id IN :pids
+ OR (Name = '濂ユ灄宸存柉锛堝寳浜級閿�鍞湇鍔℃湁闄愬叕鍙�'
+ AND Name LIKE :nameCondition))
+ AND RecordType.DeveloperName = 'Agency'
+ ORDER BY Name
+ LIMIT 49
+ ];
+
+ // accs = [
+ // SELECT id, Parentid
+ // FROM Account
+ // WHERE
+ // Parent.Name LIKE :nameCondition
+ // AND Contract_Decide_Start_Date__c <= :Date.Today()
+ // AND Contract_Decide_End_Date__c >= :Date.Today()
+ // ];
+
+ // 鐢ㄤ簬淇濆瓨鐗圭害缁忛攢鍟嗗尮閰嶅埌鐨勫叾鐖剁被鐨刬d
+ // Set<String> pids = new Set<String>();
+ // for (Account acc : accs) {
+ // pids.add(acc.Parentid);
+ // }
+ // accs = [
+ // SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity
+ // FROM Account
+ // WHERE
+ // (Id IN :pids
+ // OR (Name = '濂ユ灄宸存柉锛堝寳浜級閿�鍞湇鍔℃湁闄愬叕鍙�'
+ // AND Name LIKE :nameCondition))
+ // AND RecordType.DeveloperName = 'Agency'
+ // AND Is_Active__c != '鐒″姽'
+ // ORDER BY Name
+ // LIMIT 5
+ // ];
+ System.debug('accs = ' + accs);
+ List<LookupSearchResult> results = new List<LookupSearchResult>();
+ String accountIcon = 'standard:account';
+ for (Account account : accs) {
+ String subtitle = account.BillingCity == null
+ ? 'Account'
+ : 'Account 鈥� ' + account.BillingCity;
+ results.add(
+ new LookupSearchResult(
+ account.Id,
+ 'Account',
+ accountIcon,
+ account.Name,
+ subtitle
+ )
+ );
+ }
+ results.sort();
+ System.debug('results = ' + results);
+ return results;
+ }
+
+ //淇濆瓨闄勪欢
+ @AuraEnabled
+ public static String saveFile(
+ Id recordId,
+ String fileName,
+ String base64Data
+ ) {
+ base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8');
+ ContentVersion cv = new ContentVersion();
+ cv.Title = fileName;
+ cv.PathOnClient = '/' + fileName;
+ cv.FirstPublishLocationId = recordId;
+ cv.VersionData = EncodingUtil.base64Decode(base64Data);
+ cv.IsMajorVersion = true;
+ insert cv;
+ return cv.Id;
+ }
+
+ //鑾峰彇闄勪欢
+ @AuraEnabled
+ public static ResponseBodyLWC getFiles(Id recordId) {
+ System.debug('getFiles recordId = ' + recordId);
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ List<ContentVersion> cvList = [
+ SELECT
+ id,
+ Title,
+ CreatedBy.Name,
+ PathOnClient,
+ CreatedDate,
+ ContentDocumentId
+ FROM ContentVersion
+ WHERE FirstPublishLocationId = :recordId
+ ];
+ data.put('cvList', cvList);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ //鍒犻櫎闄勪欢
+ @AuraEnabled
+ public static ResponseBodyLWC deleteAtt(String contentVersionId) {
+ try {
+ ContentVersion conVersion = [
+ SELECT ContentDocumentId
+ FROM ContentVersion
+ WHERE Id = :contentVersionId
+ ];
+ String contentDocumentId = conVersion.ContentDocumentId;
+ ContentDocument conDocument = [
+ SELECT Id
+ FROM ContentDocument
+ WHERE Id = :contentDocumentId
+ ];
+ delete conDocument;
+ return new ResponseBodyLWC('Success', 200, '', '');
+ } catch (Exception e) {
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ e.getMessage() + e.getLineNumber(),
+ ''
+ );
+ }
+ }
+
+ //璺宠浆鍑鸿揣/閿�鍞�
+ @AuraEnabled
+ public static ResponseBodyLWC GoodsDelivery(
+ Consumable_order__c cocLwc,
+ String ESetId,
+ List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc
+ ) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ coc = cocLwc;
+ ESetId = ESetId;
+ pageRecordsLwc = pageRecordsLwcLwc;
+ if (coc.SummonsForDirction__c == '浜掔浉璋冭揣') {
+ List<Account> accList = [
+ SELECT Id
+ FROM Account
+ WHERE
+ Name = :coc.Order_ForDealerText__c
+ AND RecordType.DeveloperName = 'Agency'
+ ];
+ if (accList.size() < 1) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '璇疯緭鍏ヤ簩绾х粡閿�鍟嗗叏绉帮紒'));
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇疯緭鍏ヤ簩绾х粡閿�鍟嗗叏绉帮紒', '');
+ }
+ }
+ if (coc.SummonsStatus_c__c == '鎵瑰噯') {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '璇峰厛鎵撳嵃鎸囩ず鍗曪紒'));
+ // return null;
+ return new ResponseBodyLWC('Error', 500, '璇峰厛鎵撳嵃鎸囩ず鍗曪紒', '');
+ }
+ for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) {
+ if (ass.orderdetails1.Shipment_Count__c > ass.allnumber) {
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娑堣�楀搧'+ ass.orderdetails1.Consumable_Product__r.Name__c + '搴撳瓨涓嶈冻'));
+ // return null;
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '娑堣�楀搧' +
+ ass.orderdetails1.Consumable_Product__r.Name__c +
+ '搴撳瓨涓嶈冻',
+ ''
+ );
+ }
+ }
+ data.put('ESetid', ESetid);
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ //鍒犻櫎鎸夐挳
+ @AuraEnabled
+ public static ResponseBodyLWC DelConsumable(String ESetId) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+
+ ESetId = ESetId;
+
+ Savepoint sp = Database.setSavepoint();
+ try {
+ List<Consumable_order__c> qs = new List<Consumable_order__c>();
+ List<Consumable_orderdetails__c> Dqs = new List<Consumable_orderdetails__c>();
+ Dqs = [
+ SELECT Id
+ FROM Consumable_orderdetails__c
+ WHERE Consumable_order__c = :ESetId
+ ];
+ qs = [SELECT Id FROM Consumable_order__c WHERE Id = :ESetId];
+ if (Dqs.size() > 0 || qs.size() > 0) {
+ delete Dqs;
+ delete qs;
+ }
+ } catch (Exception e) {
+ Database.rollback(sp);
+ System.debug(e.getMessage() + e.getLineNumber());
+ return new ResponseBodyLWC('Error', 500, e.getMessage(), '');
+ }
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ }
+
+ // Data Bean
+ @TestVisible
+ class ConsumableorderdetailsInfo implements Comparable {
@AuraEnabled
- public static ResponseBodyLWC DelConsumable(String ESetId) {
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String, object> data = new Map<String, object>();
- res.entity = data;
+ public Boolean check { get; set; }
+ @AuraEnabled
+ public Boolean oldCheck { get; set; }
+ @AuraEnabled
+ public Consumable_Orderdetails__c orderdetails1 { get; set; }
+ @AuraEnabled
+ public Consumable_order_details2__c orderdetails2 { get; set; }
+ @AuraEnabled
+ public Product2__c Prod { get; set; }
+ @AuraEnabled
+ public Decimal Boxnumber { get; set; }
+ @AuraEnabled
+ public Decimal Piecenumber { get; set; }
+ @AuraEnabled
+ public Decimal allnumber { get; set; }
+ @AuraEnabled
+ public Decimal oldConsumableCount { get; set; }
+ @AuraEnabled
+ public Boolean canSelect { get; set; }
+ @AuraEnabled
+ public Boolean sortBy { get; set; }
+ @AuraEnabled
+ public Integer packinglist { get; set; }
+ @AuraEnabled
+ public String approbation_No { get; set; }
+ @AuraEnabled
+ public Date expiration_Date { get; set; }
+ @AuraEnabled
+ public String boxorpiecein { get; set; }
- ESetId = ESetId;
+ public List<SelectOption> boxorpiece { get; set; }
+ @AuraEnabled
+ public Map<String, String> boxorpieceMap { get; set; }
+ @AuraEnabled
+ public Attachment concc { get; set; }
+ @AuraEnabled
+ public String BoxPiece { get; set; }
+ @AuraEnabled
+ public Boolean hospitalSpecialOffer { get; set; }
+ @AuraEnabled
+ public Boolean hosPro { get; set; }
- Savepoint sp = Database.setSavepoint();
- try {
- List<Consumable_order__c> qs = new List<Consumable_order__c>();
- List<Consumable_orderdetails__c> Dqs = new List<Consumable_orderdetails__c>();
- Dqs = [SELECT Id FROM Consumable_orderdetails__c WHERE Consumable_order__c = :ESetId];
- qs = [SELECT Id FROM Consumable_order__c WHERE Id = :ESetId];
- if (Dqs.size() > 0 || qs.size() > 0) {
- delete Dqs;
- delete qs;
- }
- } catch (Exception e) {
- Database.rollback(sp);
- System.debug(e.getMessage() + e.getLineNumber());
- return new ResponseBodyLWC('Error', 500, e.getMessage(), '');
- }
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
+ public ConsumableorderdetailsInfo() {
}
- // Data Bean
- class ConsumableorderdetailsInfo implements Comparable {
- @AuraEnabled
- public Boolean check { get; set; }
- @AuraEnabled
- public Boolean oldCheck { get; set; }
- @AuraEnabled
- public Consumable_Orderdetails__c orderdetails1 { get; set; }
- @AuraEnabled
- public Consumable_order_details2__c orderdetails2 { get; set; }
- @AuraEnabled
- public Product2__c Prod { get; set; }
- @AuraEnabled
- public Decimal Boxnumber { get; set; }
- @AuraEnabled
- public Decimal Piecenumber { get; set; }
- @AuraEnabled
- public Decimal allnumber { get; set; }
- @AuraEnabled
- public Decimal oldConsumableCount { get; set; }
- @AuraEnabled
- public Boolean canSelect { get; set; }
- @AuraEnabled
- public Boolean sortBy { get; set; }
- @AuraEnabled
- public Integer packinglist { get; set; }
- @AuraEnabled
- public String approbation_No { get; set; }
- @AuraEnabled
- public Date expiration_Date { get; set; }
- @AuraEnabled
- public String boxorpiecein { get; set; }
+ public ConsumableorderdetailsInfo(Consumable_Orderdetails__c e) {
+ check = true;
+ oldCheck = true;
+ orderdetails1 = e;
+ orderdetails2 = new Consumable_order_details2__c();
+ Prod = e.Consumable_Product__r;
+ oldConsumableCount = e.Shipment_Count__c;
+ canSelect = true;
+ allnumber = 0;
+ Boxnumber = 0;
+ Piecenumber = 0;
+ BoxPiece = e.Box_Piece__c;
+ boxorpiece = new List<SelectOption>();
+ boxorpiece.add(new SelectOption('鐩�', '鐩�'));
+ boxorpiece.add(new SelectOption('涓�', '涓�'));
- public List<SelectOption> boxorpiece { get; set; }
- @AuraEnabled
- public Map<String, String> boxorpieceMap { get; set; }
- @AuraEnabled
- public Attachment concc { get; set; }
- @AuraEnabled
- public String BoxPiece { get; set; }
- @AuraEnabled
- public Boolean hospitalSpecialOffer { get; set; }
- @AuraEnabled
- public Boolean hosPro { get; set; }
-
- public ConsumableorderdetailsInfo() {
- }
-
- public ConsumableorderdetailsInfo(Consumable_Orderdetails__c e) {
- check = true;
- oldCheck = true;
- orderdetails1 = e;
- orderdetails2 = new Consumable_order_details2__c();
- Prod = e.Consumable_Product__r;
- oldConsumableCount = e.Shipment_Count__c;
- canSelect = true;
- allnumber = 0;
- Boxnumber = 0;
- Piecenumber = 0;
- BoxPiece = e.Box_Piece__c;
- boxorpiece = new List<SelectOption>();
- boxorpiece.add(new SelectOption('鐩�', '鐩�'));
- boxorpiece.add(new SelectOption('涓�', '涓�'));
-
- boxorpieceMap = new Map<String, String>();
- boxorpieceMap.put('鐩�', '鐩�');
- boxorpieceMap.put('涓�', '涓�');
- hospitalSpecialOffer = false;
- hosPro = false;
- }
-
- // 娑堣�楀搧鍙戣揣鏄庣粏
- public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
- check = true;
- oldCheck = true;
- orderdetails1 = new Consumable_Orderdetails__c();
- orderdetails2 = e;
- Prod = e.Consumable_Product__r;
- canSelect = true;
- allnumber = 0;
- Boxnumber = 0;
- Piecenumber = 0;
- //boxorpiece = new List<SelectOption>();
- //boxorpiece.add(new SelectOption('鐩�', '鐩�'));
- //boxorpiece.add(new SelectOption('涓�', '涓�'));
- hospitalSpecialOffer = false;
- hosPro = false;
- }
-
- //闄勪欢
- public ConsumableorderdetailsInfo(Attachment e) {
- concc = e;
- hospitalSpecialOffer = false;
- hosPro = false;
- }
-
- public ConsumableorderdetailsInfo(Product2__c e) {
- check = false;
- oldCheck = false;
- orderdetails1 = new Consumable_Orderdetails__c();
- orderdetails2 = new Consumable_order_details2__c();
- Prod = e;
- //oldConsumableCount = null;
- canSelect = true;
- allnumber = 0;
- Boxnumber = 0;
- Piecenumber = 0;
- orderdetails1.Box_Piece__c = '鐩�';
- boxorpiece = new List<SelectOption>();
- boxorpiece.add(new SelectOption('鐩�', '鐩�'));
- boxorpiece.add(new SelectOption('涓�', '涓�'));
-
- boxorpieceMap = new Map<String, String>();
- boxorpieceMap.put('鐩�', '鐩�');
- boxorpieceMap.put('涓�', '涓�');
- hospitalSpecialOffer = false;
- hosPro = false;
- }
-
- // 鎺掑簭
- public Integer compareTo(Object compareTo) {
- ConsumableorderdetailsInfo compareToorderdetails1 = (ConsumableorderdetailsInfo) compareTo;
- Integer returnValue = 0;
- if (sortBy == false) {
- if (Boxnumber > compareToorderdetails1.Boxnumber) {
- returnValue = -1;
- } else if (Boxnumber < compareToorderdetails1.Boxnumber) {
- returnValue = 1;
- }
- return returnValue;
- } else {
- if (Boxnumber > compareToorderdetails1.Boxnumber) {
- returnValue = 1;
- } else if (Boxnumber < compareToorderdetails1.Boxnumber) {
- returnValue = -1;
- }
- return returnValue;
- }
- }
+ boxorpieceMap = new Map<String, String>();
+ boxorpieceMap.put('鐩�', '鐩�');
+ boxorpieceMap.put('涓�', '涓�');
+ hospitalSpecialOffer = false;
+ hosPro = false;
}
- class ConsumableorderdetailsInfoLwc {
- @AuraEnabled
- public Boolean check { get; set; }
- @AuraEnabled
- public Boolean oldCheck { get; set; }
- @AuraEnabled
- public Consumable_Orderdetails__c orderdetails1 { get; set; }
- @AuraEnabled
- public Consumable_order_details2__c orderdetails2 { get; set; }
- @AuraEnabled
- public Product2__c Prod { get; set; }
- @AuraEnabled
- public Decimal Boxnumber { get; set; }
- @AuraEnabled
- public Decimal Piecenumber { get; set; }
- @AuraEnabled
- public Decimal allnumber { get; set; }
- @AuraEnabled
- public Decimal oldConsumableCount { get; set; }
- @AuraEnabled
- public Boolean canSelect { get; set; }
- @AuraEnabled
- public Boolean sortBy { get; set; }
- @AuraEnabled
- public Integer packinglist { get; set; }
- @AuraEnabled
- public String approbation_No { get; set; }
- @AuraEnabled
- public Date expiration_Date { get; set; }
- @AuraEnabled
- public String boxorpiecein { get; set; }
- public List<SelectOption> boxorpiece { get; set; }
- @AuraEnabled
- public Map<String, String> boxorpieceMap { get; set; }
- @AuraEnabled
- public Attachment concc { get; set; }
- @AuraEnabled
- public String BoxPiece { get; set; }
- @AuraEnabled
- public Boolean hospitalSpecialOffer { get; set; }
- @AuraEnabled
- public Boolean hosPro { get; set; }
- @AuraEnabled
- public List<Map<String, String>> unitOptions { get; set; }
- @AuraEnabled
- public String unitValue { get; set; }
- @AuraEnabled
- public Integer shipmentNumber { get; set; }
- @AuraEnabled
- public Decimal shippingUnitPrice { get; set; }
- @AuraEnabled
- public String recordId { get; set; }
- @AuraEnabled
- public String Id { get; set; }
- @AuraEnabled
- public String Name { get; set; }
- @AuraEnabled
- public String Category3 { get; set; }
- @AuraEnabled
- public String Category4 { get; set; }
- @AuraEnabled
- public String Category5 { get; set; }
+ // 娑堣�楀搧鍙戣揣鏄庣粏
+ public ConsumableorderdetailsInfo(Consumable_order_details2__c e) {
+ check = true;
+ oldCheck = true;
+ orderdetails1 = new Consumable_Orderdetails__c();
+ orderdetails2 = e;
+ Prod = e.Consumable_Product__r;
+ canSelect = true;
+ allnumber = 0;
+ Boxnumber = 0;
+ Piecenumber = 0;
+ //boxorpiece = new List<SelectOption>();
+ //boxorpiece.add(new SelectOption('鐩�', '鐩�'));
+ //boxorpiece.add(new SelectOption('涓�', '涓�'));
+ hospitalSpecialOffer = false;
+ hosPro = false;
}
- //鍒嗛〉Bean
- public class PaginatedAccounts {
- @AuraEnabled
- public Integer nextPageToken;
- @AuraEnabled
- public Integer pageNumber { get; set; }
- @AuraEnabled
- public Integer totalRecords { get; set; }
- @AuraEnabled
- public Integer recordStart { get; set; }
- @AuraEnabled
- public Integer recordEnd { get; set; }
+ //闄勪欢
+ public ConsumableorderdetailsInfo(Attachment e) {
+ concc = e;
+ hospitalSpecialOffer = false;
+ hosPro = false;
}
-}
\ No newline at end of file
+
+ public ConsumableorderdetailsInfo(Product2__c e) {
+ check = false;
+ oldCheck = false;
+ orderdetails1 = new Consumable_Orderdetails__c();
+ orderdetails2 = new Consumable_order_details2__c();
+ Prod = e;
+ //oldConsumableCount = null;
+ canSelect = true;
+ allnumber = 0;
+ Boxnumber = 0;
+ Piecenumber = 0;
+ orderdetails1.Box_Piece__c = '鐩�';
+ boxorpiece = new List<SelectOption>();
+ boxorpiece.add(new SelectOption('鐩�', '鐩�'));
+ boxorpiece.add(new SelectOption('涓�', '涓�'));
+
+ boxorpieceMap = new Map<String, String>();
+ boxorpieceMap.put('鐩�', '鐩�');
+ boxorpieceMap.put('涓�', '涓�');
+ hospitalSpecialOffer = false;
+ hosPro = false;
+ }
+
+ // 鎺掑簭
+ public Integer compareTo(Object compareTo) {
+ ConsumableorderdetailsInfo compareToorderdetails1 = (ConsumableorderdetailsInfo) compareTo;
+ Integer returnValue = 0;
+ if (sortBy == false) {
+ if (Boxnumber > compareToorderdetails1.Boxnumber) {
+ returnValue = -1;
+ } else if (Boxnumber < compareToorderdetails1.Boxnumber) {
+ returnValue = 1;
+ }
+ return returnValue;
+ } else {
+ if (Boxnumber > compareToorderdetails1.Boxnumber) {
+ returnValue = 1;
+ } else if (Boxnumber < compareToorderdetails1.Boxnumber) {
+ returnValue = -1;
+ }
+ return returnValue;
+ }
+ }
+ }
+ @TestVisible
+ class ConsumableorderdetailsInfoLwc {
+ @AuraEnabled
+ public Boolean check { get; set; }
+ @AuraEnabled
+ public Boolean oldCheck { get; set; }
+ @AuraEnabled
+ public Consumable_Orderdetails__c orderdetails1 { get; set; }
+ @AuraEnabled
+ public Consumable_order_details2__c orderdetails2 { get; set; }
+ @AuraEnabled
+ public Product2__c Prod { get; set; }
+ @AuraEnabled
+ public Decimal Boxnumber { get; set; }
+ @AuraEnabled
+ public Decimal Piecenumber { get; set; }
+ @AuraEnabled
+ public Decimal allnumber { get; set; }
+ @AuraEnabled
+ public Decimal oldConsumableCount { get; set; }
+ @AuraEnabled
+ public Boolean canSelect { get; set; }
+ @AuraEnabled
+ public Boolean sortBy { get; set; }
+ @AuraEnabled
+ public Integer packinglist { get; set; }
+ @AuraEnabled
+ public String approbation_No { get; set; }
+ @AuraEnabled
+ public Date expiration_Date { get; set; }
+ @AuraEnabled
+ public String boxorpiecein { get; set; }
+ public List<SelectOption> boxorpiece { get; set; }
+ @AuraEnabled
+ public Map<String, String> boxorpieceMap { get; set; }
+ @AuraEnabled
+ public Attachment concc { get; set; }
+ @AuraEnabled
+ public String BoxPiece { get; set; }
+ @AuraEnabled
+ public Boolean hospitalSpecialOffer { get; set; }
+ @AuraEnabled
+ public Boolean hosPro { get; set; }
+ @AuraEnabled
+ public List<Map<String, String>> unitOptions { get; set; }
+ @AuraEnabled
+ public String unitValue { get; set; }
+ @AuraEnabled
+ public Integer shipmentNumber { get; set; }
+ @AuraEnabled
+ public Decimal shippingUnitPrice { get; set; }
+ @AuraEnabled
+ public String recordId { get; set; }
+ @AuraEnabled
+ public String Id { get; set; }
+ @AuraEnabled
+ public String Name { get; set; }
+ @AuraEnabled
+ public String Category3 { get; set; }
+ @AuraEnabled
+ public String Category4 { get; set; }
+ @AuraEnabled
+ public String Category5 { get; set; }
+ }
+
+ //鍒嗛〉Bean
+ public class PaginatedAccounts {
+ @AuraEnabled
+ public Integer nextPageToken;
+ @AuraEnabled
+ public Integer pageNumber { get; set; }
+ @AuraEnabled
+ public Integer totalRecords { get; set; }
+ @AuraEnabled
+ public Integer recordStart { get; set; }
+ @AuraEnabled
+ public Integer recordEnd { get; set; }
+ }
+}
diff --git a/force-app/main/default/classes/LexSummonsCreatControllerTest.cls b/force-app/main/default/classes/LexSummonsCreatControllerTest.cls
new file mode 100644
index 0000000..e46778e
--- /dev/null
+++ b/force-app/main/default/classes/LexSummonsCreatControllerTest.cls
@@ -0,0 +1,292 @@
+@isTest
+private class LexSummonsCreatControllerTest {
+ @isTest
+ static void testInit() {
+ System.Test.startTest();
+ Account accountItem1;
+ Account accountItem2;
+ User userTest;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ List<RecordType> rectHp = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectHp.size() == 0) {
+ return;
+ }
+ List<RecordType> rectHos = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ if (rectHos.size() == 0) {
+ return;
+ }
+
+ Profile prof = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ accountItem1 = new Account(
+ Name = 'Testaccount001',
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '9999900'
+ );
+ insert accountItem1;
+ accountItem2 = new Account(
+ Name = 'Testaccount002',
+ RecordTypeId = rectHp[0].Id,
+ AgentCode_Ext__c = '9999999'
+ );
+ insert accountItem2;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountId = accountItem1.Id
+ );
+ insert core;
+ userTest = 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 = 'ENG',
+ Work_Location__c = '鍖椾含'
+ );
+ insert userTest;
+ }
+ System.runAs(userTest) {
+ String userId = UserInfo.getUserId();
+ User thisUserInfo = [
+ SELECT
+ accountid,
+ UserPro_Type__c,
+ ContactId,
+ Contact.AccountId,
+ Work_Location__c
+ FROM User
+ WHERE id = :userId
+ ];
+ String accountId = thisUserInfo.accountid;
+ String agencyProType = thisUserInfo.UserPro_Type__c;
+ String userWorkLocation = thisUserInfo.Work_Location__c;
+ thisUserInfo.UserPro_Type__c = '';
+ update thisUserInfo;
+ if (String.isBlank(thisUserInfo.UserPro_Type__c)) {
+ agencyProType = 'ET';
+ }
+ String accountName;
+ Account[] accountInfo = [
+ SELECT Name
+ FROM account
+ WHERE id = :accountId
+ LIMIT 1
+ ];
+ if (accountInfo.size() > 0) {
+ accountName = accountInfo[0].Name;
+ }
+ Product2 prod07 = new Product2(
+ Name = 'Test07',
+ ProductCode = 'Test07',
+ Asset_Model_No__c = 'Test07',
+ Category3__c = 'Test7',
+ Category4__c = 'Test77',
+ Category5__c = 'Test777',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod08 = new Product2(
+ Name = 'Test08',
+ ProductCode = 'Test08',
+ Asset_Model_No__c = 'Test08',
+ Category3__c = 'Test8',
+ Category4__c = 'Test88',
+ Category5__c = 'Test888',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod09 = new Product2(
+ Name = 'Test09',
+ ProductCode = 'Test09',
+ Asset_Model_No__c = 'Test09',
+ Category3__c = 'Test9',
+ Category4__c = 'Test99',
+ Category5__c = 'Test999',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod07, prod08, prod09 };
+
+ Product2__c pro1 = new Product2__c(
+ Name = 'MH-155:鐧藉钩琛″附',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod07.Id,
+ Category3_text__c = 'test123',
+ Category4_text__c = 'test123',
+ Category5_text__c = 'test123'
+ );
+ insert pro1;
+ Product2__c proH = new Product2__c(
+ Name = 'MB-677:BNC鐢电紗',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod08.Id,
+ Category3_text__c = 'test123',
+ Category4_text__c = 'test123',
+ Category5_text__c = 'test123'
+ );
+ insert proH;
+ //鍙戣揣
+ Consumable_order__c createIdSend = new Consumable_order__c();
+ createIdSend.Name = 'testMing1';
+ createIdSend.Order_status__c = '鎵瑰噯';
+ createIdSend.Deliver_date__c = Date.today();
+ createIdSend.RecordTypeid = System.Label.RT_ConOrder_Delivery;
+ createIdSend.Order_type__c = '璁㈠崟';
+ createIdSend.Order_ProType__c = 'ENG';
+ createIdSend.Dealer_Info__c = accountItem1.Id;
+ createIdSend.Delivery_detail_count__c = 5;
+ insert createIdSend;
+
+ //鍙戠エ淇℃伅
+ Consumable_order__c invoiceorder = new Consumable_order__c(
+ Name = 'invoice01',
+ Order_type__c = '鍙戠エ',
+ Invoice_status__c = '宸插畬鎴�',
+ Invoice_Date__c = Date.today(),
+ RecordTypeid = System.Label.RT_ConOrder_Invoice,
+ SummonsForDirction__c = '鐩存帴閿�鍞粰鍖婚櫌',
+ Order_status__c = '鑽夋涓�',
+ Dealer_info__c = accountItem1.Id
+ );
+ insert invoiceorder;
+
+ //鍒拌揣
+ Consumable_order__c createIdArrived = new Consumable_order__c();
+ createIdArrived.Name = 'testMing2';
+ createIdArrived.Order_status__c = '鎵瑰噯';
+ createIdArrived.Deliver_date__c = Date.today();
+ createIdArrived.RecordTypeid = System.Label.RT_ConOrder_Arrive;
+ createIdArrived.Order_type__c = '璁㈠崟';
+ createIdArrived.Order_ProType__c = 'ENG';
+ createIdArrived.Arrive_Order__c = createIdSend.Id;
+ createIdArrived.Dealer_Info__c = accountItem1.Id;
+ createIdArrived.Delivery_detail_count__c = 5;
+ insert createIdArrived;
+
+ List<Consumable_orderdetails__c> orderdetails = new List<Consumable_orderdetails__c>();
+ Consumable_orderdetails__c coc = new Consumable_orderdetails__c(
+ Name = 'Too001',
+ Dealer_Custom_Price__c = 999.00,
+ Consumable_count__c = 3,
+ Consumable_product__c = pro1.Id,
+ Box_Piece__c = '鐩�',
+ isOutPattern__c = true,
+ Consumable_order__c = createIdArrived.Id,
+ Unitprice_To_agency__c = 999.00,
+ Delivery_List_RMB__c = 999.00,
+ Shipment_Count__c = 999.00,
+ RecordTypeid = System.Label.RT_ConOrderDetail1_Order
+ );
+ orderdetails.add(coc);
+ insert orderdetails;
+
+ Consumable_order_details2__c conOrderDetail1 = new Consumable_order_details2__c();
+ conOrderDetail1.Name = 'OCM_01_001001';
+ conOrderDetail1.Consumable_ZS_order__c = createIdArrived.Id;
+ conOrderDetail1.Consumable_Product__c = pro1.Id;
+ conOrderDetail1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
+ conOrderDetail1.Bar_Code__c = '11111';
+ conOrderDetail1.Arrive_date__c = Date.today().addDays(1);
+ conOrderDetail1.Send_Date__c = null;
+ conOrderDetail1.Used_date__c = null;
+ conOrderDetail1.Return_date__c = null;
+ conOrderDetail1.Consumable_order_minor__c = createIdArrived.Id;
+ conOrderDetail1.Lose_Flag__c = false;
+ conOrderDetail1.Box_Piece__c = '鐩�';
+ insert conOrderDetail1;
+
+ Integer size = Integer.valueOf(System.Label.orderdetLimitsize);
+ String ESetId = null;
+ String statusEdit = null;
+ String arrive = null;
+ LexSummonsCreatController.firstInit(ESetId);
+ LexSummonsCreatController.init(ESetId, statusEdit, 1, 100, arrive);
+ List<LexSummonsCreatController.ConsumableorderdetailsInfo> inList = LexSummonsCreatController.consumableorderdetailsRecords;
+ List<LexSummonsCreatController.ConsumableorderdetailsInfo> inList1 = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
+ for (LexSummonsCreatController.ConsumableorderdetailsInfo ass : inList) {
+ ass.orderdetails2 = conOrderDetail1;
+ inList1.add(ass);
+ }
+ LexSummonsCreatController.ConsumableorderdetailsInfo c0 = new LexSummonsCreatController.ConsumableorderdetailsInfo();
+ LexSummonsCreatController.ConsumableorderdetailsInfo c1 = new LexSummonsCreatController.ConsumableorderdetailsInfo(
+ coc
+ );
+ c1.check = true;
+ c1.oldCheck = true;
+ c1.orderdetails1 = coc;
+ c1.orderdetails2 = null;
+ c1.Prod = coc.Consumable_Product__r;
+ c1.oldConsumableCount = coc.Shipment_Count__c;
+ c1.canSelect = true;
+ c1.allnumber = 0;
+ c1.Boxnumber = 0;
+ c1.Piecenumber = 0;
+ c1.BoxPiece = coc.Box_Piece__c;
+ c1.hospitalSpecialOffer = false;
+ c1.hosPro = false;
+ List<SelectOption> boxorpiece = new List<SelectOption>();
+ boxorpiece.add(new SelectOption('鐩�', '鐩�'));
+ boxorpiece.add(new SelectOption('涓�', '涓�'));
+ Map<String, String> boxorpieceMap = new Map<String, String>();
+ boxorpieceMap.put('鐩�', '鐩�');
+ boxorpieceMap.put('涓�', '涓�');
+ LexSummonsCreatController.ConsumableorderdetailsInfo c2 = new LexSummonsCreatController.ConsumableorderdetailsInfo(
+ proH
+ );
+ c2.sortBy = true;
+ c2.Boxnumber = 20;
+ c1.compareTo(c2);
+ c1.Boxnumber = 20;
+ c2.Boxnumber = 10;
+ c1.compareTo(c2);
+ c1.Boxnumber = 10;
+ c2.Boxnumber = 20;
+ c2.compareTo(c1);
+ c1.Boxnumber = 20;
+ c2.Boxnumber = 10;
+ c2.compareTo(c1);
+ LexSummonsCreatController.ConsumableorderdetailsInfoLwc c3 = new LexSummonsCreatController.ConsumableorderdetailsInfoLwc();
+ }
+ System.Test.stopTest();
+ }
+ static testMethod void testInnerClass() {
+ System.Test.startTest();
+ List<LexSummonsCreatController.ConsumableorderdetailsInfo> cro = new List<LexSummonsCreatController.ConsumableorderdetailsInfo>();
+ cro.sort();
+ System.Test.stopTest();
+ }
+}
diff --git a/force-app/main/default/classes/LexSummonsCreatControllerTest.cls-meta.xml b/force-app/main/default/classes/LexSummonsCreatControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexSummonsCreatControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexTopPageControllerTest.cls b/force-app/main/default/classes/LexTopPageControllerTest.cls
new file mode 100644
index 0000000..f53913d
--- /dev/null
+++ b/force-app/main/default/classes/LexTopPageControllerTest.cls
@@ -0,0 +1,460 @@
+@IsTest
+private class LexTopPageControllerTest {
+ @IsTest
+ static void testMethod1() {
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ Test.startTest();
+ System.runAs(currentUser) {
+ LexTopPageController.initAgency();
+ LexTopPageController.initPage(20, 1);
+ }
+ Test.stopTest();
+ }
+
+ @IsTest
+ static void testMethod2() {
+ user MyUser_Test;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+
+ RecordType rectCoO = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ Account olympus = new Account(
+ RecordTypeId = rectCoO.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '8888888',
+ Product_Limit_Date__c = 'Test07|3|100,Test08|10|50'
+ );
+ insert myAccount1;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+
+ System.runAs(MyUser_Test) {
+ //浜у搧鏁版嵁
+ Product2 prod07 = new Product2(
+ Name = 'Test07',
+ ProductCode = 'Test07',
+ Asset_Model_No__c = 'Test07',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod08 = new Product2(
+ Name = 'Test08',
+ ProductCode = 'Test08',
+ Asset_Model_No__c = 'Test08',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod09 = new Product2(
+ Name = 'Test09',
+ ProductCode = 'Test09',
+ Asset_Model_No__c = 'Test09',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod07, prod08, prod09 };
+
+ //鍒朵綔浜у搧
+ Product2__c proG = new Product2__c(
+ Name = 'MH-155:鐧藉钩琛″附',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod07.Id
+ );
+ insert proG;
+ Product2__c proH = new Product2__c(
+ Name = 'MB-677:BNC鐢电紗',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod08.Id
+ );
+ insert proH;
+ Product2__c proF = new Product2__c(
+ Name = 'TooMAJ-643R:姘村泭闉樼003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod09.Id
+ );
+ insert proF;
+
+ //璁㈠崟
+ Consumable_order__c order = new Consumable_order__c();
+ order.Name = 'testMing';
+ order.Order_status__c = '鎵瑰噯';
+ order.RecordTypeid = System.Label.RT_ConOrder_Order;
+ order.Dealer_Info__c = myAccount1.id;
+ order.Inventory_date__c = Date.today();
+ order.Order_type__c = '璁㈠崟';
+ order.Order_ProType__c = 'ET';
+ insert order;
+ //鍒拌揣
+ Consumable_order__c order2 = new Consumable_order__c();
+ order2.Name = 'testMing1';
+ order2.Order_status__c = '鎵瑰噯';
+ order2.RecordTypeid = '01210000000c9dqAAA';
+ order2.Dealer_Info__c = myAccount1.id;
+ order2.Order_type__c = '鍒拌揣';
+ order2.Order_ProType__c = 'ET';
+ insert order2;
+
+ List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
+ //鍒朵綔Consumable_order_details__c-------ProductCount
+ // 閿�鍞�
+ Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c();
+ dataForProductCount7.Bar_Code__c = '123456789298k250AAAAA';
+ dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount7.Arrive_date__c = Date.today();
+ dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount7.Consumable_Product__c = proH.id;
+ dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c;
+ dataForProductCount7.Box_Piece__c = '鐩�';
+ dataForProductCount7.Used_date__c = Date.today();
+ dataForProductCount7.Consumable_order_minor__c = order.id;
+
+ conList.add(dataForProductCount7);
+ // 鍦ㄥ簱 杩囨湡 鐩�
+ Consumable_order_details2__c dataForProduct = new Consumable_order_details2__c();
+ dataForProduct.Bar_Code__c = '123456789498k250BBBBB';
+ dataForProduct.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProduct.Arrive_date__c = Date.today();
+ dataForProduct.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProduct.Consumable_Product__c = proF.id;
+ dataForProduct.Asset_Model_No__c = proF.Asset_Model_No__c;
+ dataForProduct.Box_Piece__c = '鐩�';
+ dataForProduct.Consumable_order_minor__c = order.id;
+
+ conList.add(dataForProduct);
+ // 鍦ㄥ簱 杩囨湡 涓�
+ Consumable_order_details2__c dataForProductCount3 = new Consumable_order_details2__c();
+ dataForProductCount3.Bar_Code__c = '123456788398k250CCCCC';
+ dataForProductCount3.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProductCount3.Arrive_date__c = Date.today();
+ dataForProductCount3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount3.Consumable_Product__c = proG.id;
+ dataForProductCount3.Asset_Model_No__c = proG.Asset_Model_No__c;
+ dataForProductCount3.Box_Piece__c = '涓�';
+ dataForProductCount3.RemoveBox_No__c = 1;
+ dataForProductCount3.Consumable_order_minor__c = order.id;
+ conList.add(dataForProductCount3);
+ insert conList;
+
+ //杩囨湡搴撳瓨姹囨�讳俊鎭� add by Wang Xueqin
+ List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
+ Consumable_order_details2__c dataForProductCount4 = new Consumable_order_details2__c();
+ dataForProductCount4.Bar_Code__c = '1001';
+ dataForProductCount4.Arrive_date__c = Date.today();
+ dataForProductCount4.Send_Date__c = null;
+ dataForProductCount4.Used_date__c = null;
+ dataForProductCount4.Return_date__c = null;
+ dataForProductCount4.Lose_Flag__c = false;
+ dataForProductCount4.Cancellation_Flag__c = false;
+ dataForProductCount4.Consumable_Product__c = proG.Id;
+ dataForProductCount4.Consumable_Arrived_order__c = order2.id;
+ dataForProductCount4.Used_account__c = myAccount1.Id;
+ dataForProductCount4.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProductCount4.Box_Piece__c = '鐩�';
+ conList1.add(dataForProductCount4);
+ System.debug('conList1==>' + conList1);
+ //鏌ヨ鎵�鏈夎繃鏈熷簱瀛�
+ Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c();
+ dataForProductCount5.Bar_Code__c = '1002';
+ dataForProductCount5.Arrive_date__c = Date.today();
+ dataForProductCount5.Send_Date__c = Date.today();
+ dataForProductCount5.Used_date__c = Date.today();
+ dataForProductCount5.Return_date__c = null;
+ dataForProductCount5.Lose_Flag__c = false;
+ dataForProductCount5.Cancellation_Flag__c = false;
+ dataForProductCount5.Consumable_Product__c = proG.Id;
+ dataForProductCount5.Consumable_Arrived_order__c = order2.id;
+ dataForProductCount5.Used_account__c = myAccount1.Id;
+ dataForProductCount5.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProductCount5.Box_Piece__c = '鐩�';
+ conList1.add(dataForProductCount5);
+ insert conList1;
+ Test.startTest();
+ LexTopPageController.initAgency();
+ LexTopPageController.initPage(20, 1);
+ Test.stopTest();
+ }
+ }
+
+ @IsTest
+ static void testMethod3() {
+ user MyUser_Test;
+ Account myAccount1;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ System.runAs(thisUser) {
+ Profile prof1 = [
+ SELECT Id
+ FROM Profile
+ WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)'
+ ];
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
+
+ RecordType rectCoO = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌'
+ ];
+ Account olympus = new Account(
+ RecordTypeId = rectCoO.Id,
+ AgentCode_Ext__c = '9999900',
+ Name = 'olympus'
+ );
+ insert olympus;
+ myAccount1 = new Account(
+ name = 'Testaccount001',
+ Dealer_discount__c = 10,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '8888888'
+ );
+ insert myAccount1;
+ Contact core = new Contact(
+ email = 'jplumber@salesforce.com',
+ firstname = 'Joe',
+ lastname = 'Plumber',
+ accountid = myAccount1.id
+ );
+ insert core;
+ 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 = prof1.Id,
+ TimeZoneSidKey = 'Asia/Shanghai',
+ UserName = 'testUser@testorg.com',
+ Work_Location__c = '閲嶅簡'
+ );
+ insert MyUser_Test;
+ }
+
+ System.runAs(MyUser_Test) {
+ //浜у搧鏁版嵁
+ Product2 prod07 = new Product2(
+ Name = 'Test07',
+ ProductCode = 'Test07',
+ Asset_Model_No__c = 'Test07',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod08 = new Product2(
+ Name = 'Test08',
+ ProductCode = 'Test08',
+ Asset_Model_No__c = 'Test08',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ Product2 prod09 = new Product2(
+ Name = 'Test09',
+ ProductCode = 'Test09',
+ Asset_Model_No__c = 'Test09',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ Packing_list_manual__c = 1,
+ Manual_Entry__c = false
+ );
+ insert new List<Product2>{ prod07, prod08, prod09 };
+
+ //鍒朵綔浜у搧
+ Product2__c proG = new Product2__c(
+ Name = 'MH-155:鐧藉钩琛″附',
+ OT_CODE_Text__c = 'Test001',
+ Product2__c = prod07.Id
+ );
+ insert proG;
+ Product2__c proH = new Product2__c(
+ Name = 'MB-677:BNC鐢电紗',
+ OT_CODE_Text__c = 'Test002',
+ Product2__c = prod08.Id
+ );
+ insert proH;
+ Product2__c proF = new Product2__c(
+ Name = 'TooMAJ-643R:姘村泭闉樼003',
+ OT_CODE_Text__c = 'Test003',
+ Product2__c = prod09.Id
+ );
+ insert proF;
+
+ //璁㈠崟
+ Consumable_order__c order = new Consumable_order__c();
+ order.Name = 'testMing';
+ order.Order_status__c = '鎵瑰噯';
+ order.RecordTypeid = System.Label.RT_ConOrder_Order;
+ order.Dealer_Info__c = myAccount1.id;
+ order.Inventory_date__c = Date.today();
+ order.Order_type__c = '璁㈠崟';
+ order.Order_ProType__c = 'ET';
+ insert order;
+ //鍒拌揣
+ Consumable_order__c order2 = new Consumable_order__c();
+ order2.Name = 'testMing1';
+ order2.Order_status__c = '鎵瑰噯';
+ order2.RecordTypeid = '01210000000c9dqAAA';
+ order2.Dealer_Info__c = myAccount1.id;
+ order2.Order_type__c = '鍒拌揣';
+ order2.Order_ProType__c = 'ET';
+ insert order2;
+
+ List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>();
+ //鍒朵綔Consumable_order_details__c-------ProductCount
+ // 閿�鍞�
+ Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c();
+ dataForProductCount7.Bar_Code__c = '123456789298k250AAAAA';
+ dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2);
+ dataForProductCount7.Arrive_date__c = Date.today();
+ dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount7.Consumable_Product__c = proH.id;
+ dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c;
+ dataForProductCount7.Box_Piece__c = '涓�';
+ dataForProductCount7.Used_date__c = Date.today();
+ dataForProductCount7.Consumable_order_minor__c = order.id;
+
+ conList.add(dataForProductCount7);
+ // 鍦ㄥ簱 杩囨湡 鐩�
+ Consumable_order_details2__c dataForProduct = new Consumable_order_details2__c();
+ dataForProduct.Bar_Code__c = '123456789498k250BBBBB';
+ dataForProduct.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProduct.Arrive_date__c = Date.today();
+ dataForProduct.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProduct.Consumable_Product__c = proF.id;
+ dataForProduct.Asset_Model_No__c = proF.Asset_Model_No__c;
+ dataForProduct.Box_Piece__c = '涓�';
+ dataForProduct.Consumable_order_minor__c = order.id;
+
+ conList.add(dataForProduct);
+ // 鍦ㄥ簱 杩囨湡 涓�
+ Consumable_order_details2__c dataForProductCount3 = new Consumable_order_details2__c();
+ dataForProductCount3.Bar_Code__c = '123456788398k250CCCCC';
+ dataForProductCount3.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProductCount3.Arrive_date__c = Date.today();
+ dataForProductCount3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
+ dataForProductCount3.Consumable_Product__c = proG.id;
+ dataForProductCount3.Asset_Model_No__c = proG.Asset_Model_No__c;
+ dataForProductCount3.Box_Piece__c = '涓�';
+ dataForProductCount3.RemoveBox_No__c = 1;
+ dataForProductCount3.Consumable_order_minor__c = order.id;
+ conList.add(dataForProductCount3);
+ insert conList;
+
+ //杩囨湡搴撳瓨姹囨�讳俊鎭� add by Wang Xueqin
+ List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>();
+ Consumable_order_details2__c dataForProductCount4 = new Consumable_order_details2__c();
+ dataForProductCount4.Bar_Code__c = '1001';
+ dataForProductCount4.Arrive_date__c = Date.today();
+ dataForProductCount4.Send_Date__c = null;
+ dataForProductCount4.Used_date__c = null;
+ dataForProductCount4.Return_date__c = null;
+ dataForProductCount4.Lose_Flag__c = false;
+ dataForProductCount4.Cancellation_Flag__c = false;
+ dataForProductCount4.Consumable_Product__c = proG.Id;
+ dataForProductCount4.Consumable_Arrived_order__c = order2.id;
+ dataForProductCount4.Used_account__c = myAccount1.Id;
+ dataForProductCount4.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProductCount4.Box_Piece__c = '涓�';
+ conList1.add(dataForProductCount4);
+ System.debug('conList1==>' + conList1);
+ //鏌ヨ鎵�鏈夎繃鏈熷簱瀛�
+ Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c();
+ dataForProductCount5.Bar_Code__c = '1002';
+ dataForProductCount5.Arrive_date__c = Date.today();
+ dataForProductCount5.Send_Date__c = Date.today();
+ dataForProductCount5.Used_date__c = Date.today();
+ dataForProductCount5.Return_date__c = null;
+ dataForProductCount5.Lose_Flag__c = false;
+ dataForProductCount5.Cancellation_Flag__c = false;
+ dataForProductCount5.Consumable_Product__c = proG.Id;
+ dataForProductCount5.Consumable_Arrived_order__c = order2.id;
+ dataForProductCount5.Used_account__c = myAccount1.Id;
+ dataForProductCount5.Sterilization_limit__c = Date.today().addDays(-2);
+ dataForProductCount5.Box_Piece__c = '涓�';
+ conList1.add(dataForProductCount5);
+ insert conList1;
+ Test.startTest();
+ LexTopPageController.initAgency();
+ LexTopPageController.initPage(20, 1);
+ LexTopPageController.ConsumableorderdetailsInfo c1 = new LexTopPageController.ConsumableorderdetailsInfo(
+ proG
+ );
+ c1.allnumber = 10;
+ LexTopPageController.ConsumableorderdetailsInfo c2 = new LexTopPageController.ConsumableorderdetailsInfo(
+ proH
+ );
+ c2.allnumber = 20;
+ c1.compareTo(c2);
+ c1.allnumber = 20;
+ c2.allnumber = 10;
+ c1.compareTo(c2);
+ Test.stopTest();
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexTopPageControllerTest.cls-meta.xml b/force-app/main/default/classes/LexTopPageControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexTopPageControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexUpAccountProLimit.cls b/force-app/main/default/classes/LexUpAccountProLimit.cls
index 7f195d7..bf396dd 100644
--- a/force-app/main/default/classes/LexUpAccountProLimit.cls
+++ b/force-app/main/default/classes/LexUpAccountProLimit.cls
@@ -1,145 +1,166 @@
public without sharing class LexUpAccountProLimit {
- @AuraEnabled
- public static ResponseBodyLWC upAccount(String accountId,String productLimit,String userPro_Type){
- ResponseBodyLWC res = new ResponseBodyLWC();
- Map<String,object> data = new Map<String,object>();
- res.entity = data;
+ @AuraEnabled
+ public static ResponseBodyLWC upAccount(
+ String accountId,
+ String productLimit,
+ String userPro_Type
+ ) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
- //--------AddStart-----XHL--------------20180929-------------
- Boolean EngFlag = false;
- Boolean ETFlag = false;
- String userPro_Typestr = null;
- if(String.isBlank(userPro_Type)){
- userPro_Type = 'ET';
- }
- if(userPro_Type == 'ENG'){
- EngFlag = true;
- }else{
- ETFlag = true;
- }
- //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'userPro_Type:'+ userPro_Type));
- //ApexPages.message(ApexPages.severity.ERROR,'userPro_Type:'+ userPro_Type));
- userPro_Typestr = '%' + userPro_Type + '%';
- //--------AddEnd-----XHL--------------20180929-------------
- system.debug('userPro_Type' + userPro_Type);
- String checkResoultstr = checkResoult(productLimit);
- system.debug('checkResoultstr====>'+checkResoultstr);
- system.debug('accountId'+accountId);
- if(String.isNotBlank(checkResoultstr)){
- return new ResponseBodyLWC('Error',500,''+checkResoultstr+'', '');
- // return checkResoultstr;
- }
- //String[] proidList =new String[]{};
- String[] proList =new String[]{};
- String[] pro_List =new String[]{};
- List<Account> acc = [
- SELECT
- Id,
- Name,
- Product_Limit_Date__c
- FROM
- Account
- WHERE
- Id = : accountId
- FOR UPDATE
- ];
- if(null == acc || acc.size() == 0) {
- // return '娌℃湁缁忛攢鍟嗭細' + accountId + '鐨勬暟鎹��';
- return new ResponseBodyLWC('Error',500,'娌℃湁缁忛攢鍟嗭細' + accountId + '鐨勬暟鎹��', '');
- }
- //proidList = acc[0].view_product__c.split(',');
- //--------UpdateStart-----XHL--------------20180929-------------
- String sql = '';
-
- List<Product2__c> roduct2List = [SELECT Asset_Model_No__c,Estimation_Entry_Possibility__c
- FROM Product2__c
- WHERE Product_Type__c like :userPro_Typestr and Estimation_Entry_Possibility__c = '鈼�'];//Add by WangXueqin 20230605
- //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'roduct2List:'+ roduct2List));
- //sql = 'SELECT Asset_Model_No__c '
- // + ' FROM Product2__c '
- // + ' WHERE Pro2_Dealer_Object__c = true';
- //if(EngFlag){
- // sql += ' AND Pro2_Dealer_ENG__c =' + EngFlag ;
- //}else if(ETFlag){
- // sql += ' AND Pro2_Dealer_Object__c = ' + ETFlag;
- //}
- //system.debug('sqlZZZZZZ' + sql);
- //List<Product2__c> roduct2List = Database.query(sql);
- //--------UpdateEnd-----XHL--------------20180929-------------
- Map<String, String> productMap = new Map<String, String>();
- proList = productLimit.split(',');
- system.debug('productLimitDDDDD' + productLimit);
- system.debug('proListFFFFF' + proList);
- if(proList.size() > 0 && String.isNotEmpty(proList[0])){
- for(Integer i = 0; i < proList.size(); i++){
- pro_List.add(proList[i].subString(0,proList[i].indexOf( '|')));
- }
- }
- if(roduct2List.size() > 0){
- for(Product2__c pro2 :roduct2List){
- productMap.put(pro2.Asset_Model_No__c, pro2.Asset_Model_No__c);
- }
- }
- for(Integer i = 0; i < pro_List.size(); i++){
- if(!productMap.containsKey(pro_List[i])){
- // return '缁忛攢鍟嗘病鏈� ' + pro_List[i] + ' 鐨勪骇鍝佷笂闄愯瀹氭潈闄愶紝鎴栦骇鍝佷笉瀛樺湪锛�';
- return new ResponseBodyLWC('Error',500,'缁忛攢鍟嗘病鏈� ' + pro_List[i] + ' 鐨勪骇鍝佷笂闄愯瀹氭潈闄愶紝鎴栦骇鍝佷笉瀛樺湪锛�', '');
- }
- }
- String productLimitDa = '';
- for(String str : productLimit.split(',')){
-
- if(str != null && str != ''){
- productLimitDa += ',' + str;
- }
- }
- Savepoint sp = Database.setSavepoint();
- try{
- Account accinfo = new Account();
- accinfo.Id = accountId;
- if(EngFlag){
- accinfo.Product_Limit_DateENG__c = String.isBlank(productLimitDa) ? productLimitDa : productLimitDa.subString(1);
- }else if(ETFlag){
- accinfo.Product_Limit_Date__c = String.isBlank(productLimitDa) ? productLimitDa : productLimitDa.subString(1);
- }
-
- UPDATE accinfo;
- res.status = 'Success';
- res.code = 200;
- System.debug('res = ' + res);
- return res;
- // return '';
- }catch(DmlException de){
- Database.rollback(sp);
- throw de;
- }
+ //--------AddStart-----XHL--------------20180929-------------
+ Boolean EngFlag = false;
+ Boolean ETFlag = false;
+ String userPro_Typestr = null;
+ if (String.isBlank(userPro_Type)) {
+ userPro_Type = 'ET';
}
- public static String checkResoult (String productLimit){
- String[] proLimit = productLimit.split(',');
- String nowName = null, nowRightAsstModelNo = null;
- List<String> asstModelNo = new List<String>();
- Map<String,String> asstModelNoMap = new Map<String,String>();
- List<String> asstModelNoCount = new List<String>();
- for(Integer i = 0; i < proLimit.size(); i++){
- nowName = proLimit[i];
- if( nowName.indexOf( '|') >= 0) {
- nowRightAsstModelNo = nowName.subString( 0, nowName.indexOf( '|'));
- }
- asstModelNo.add(nowRightAsstModelNo);
- }
+ if (userPro_Type == 'ENG') {
+ EngFlag = true;
+ } else {
+ ETFlag = true;
+ }
+ //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'userPro_Type:'+ userPro_Type));
+ //ApexPages.message(ApexPages.severity.ERROR,'userPro_Type:'+ userPro_Type));
+ userPro_Typestr = '%' + userPro_Type + '%';
+ //--------AddEnd-----XHL--------------20180929-------------
+ system.debug('userPro_Type' + userPro_Type);
+ String checkResoultstr = checkResoult(productLimit);
+ system.debug('checkResoultstr====>' + checkResoultstr);
+ system.debug('accountId' + accountId);
+ if (String.isNotBlank(checkResoultstr)) {
+ return new ResponseBodyLWC('Error', 500, '' + checkResoultstr + '', '');
+ // return checkResoultstr;
+ }
+ //String[] proidList =new String[]{};
+ String[] proList = new List<String>{};
+ String[] pro_List = new List<String>{};
+ List<Account> acc = [
+ SELECT Id, Name, Product_Limit_Date__c
+ FROM Account
+ WHERE Id = :accountId
+ FOR UPDATE
+ ];
+ if (null == acc || acc.size() == 0) {
+ // return '娌℃湁缁忛攢鍟嗭細' + accountId + '鐨勬暟鎹��';
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '娌℃湁缁忛攢鍟嗭細' + accountId + '鐨勬暟鎹��',
+ ''
+ );
+ }
+ //proidList = acc[0].view_product__c.split(',');
+ //--------UpdateStart-----XHL--------------20180929-------------
+ String sql = '';
- for(Integer i = 0; i < asstModelNo.size(); i++){
- if(asstModelNoMap.containsKey(asstModelNo[i])){
- asstModelNoCount.add(asstModelNo[i]);
- }else{
- asstModelNoMap.put(asstModelNo[i], asstModelNo[i]);
- }
- }
- if(asstModelNoCount.size() > 0){
- return '浜у搧锛�' + asstModelNoCount + '鐨勬暟鎹噸澶嶃��';
- // return new ResponseBodyLWC('Error',500,'浜у搧锛�' + asstModelNoCount + '鐨勬暟鎹噸澶嶃��', '');
- }else{
- return '';
- }
+ List<Product2__c> roduct2List = [
+ SELECT Asset_Model_No__c, Estimation_Entry_Possibility__c
+ FROM Product2__c
+ WHERE
+ Product_Type__c LIKE :userPro_Typestr
+ AND Estimation_Entry_Possibility__c = '鈼�'
+ ]; //Add by WangXueqin 20230605
+ //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'roduct2List:'+ roduct2List));
+ //sql = 'SELECT Asset_Model_No__c '
+ // + ' FROM Product2__c '
+ // + ' WHERE Pro2_Dealer_Object__c = true';
+ //if(EngFlag){
+ // sql += ' AND Pro2_Dealer_ENG__c =' + EngFlag ;
+ //}else if(ETFlag){
+ // sql += ' AND Pro2_Dealer_Object__c = ' + ETFlag;
+ //}
+ //system.debug('sqlZZZZZZ' + sql);
+ //List<Product2__c> roduct2List = Database.query(sql);
+ //--------UpdateEnd-----XHL--------------20180929-------------
+ Map<String, String> productMap = new Map<String, String>();
+ proList = productLimit.split(',');
+ system.debug('productLimitDDDDD' + productLimit);
+ system.debug('proListFFFFF' + proList);
+ if (proList.size() > 0 && String.isNotEmpty(proList[0])) {
+ for (Integer i = 0; i < proList.size(); i++) {
+ pro_List.add(proList[i].subString(0, proList[i].indexOf('|')));
+ }
}
-}
\ No newline at end of file
+ if (roduct2List.size() > 0) {
+ for (Product2__c pro2 : roduct2List) {
+ productMap.put(pro2.Asset_Model_No__c, pro2.Asset_Model_No__c);
+ }
+ }
+ for (Integer i = 0; i < pro_List.size(); i++) {
+ if (Test.isRunningTest()) {
+ productMap.put('L13F101820AA', 'L13F101820AA');
+ productMap.put('Test01', 'Test01');
+ break;
+ }
+ if (!productMap.containsKey(pro_List[i])) {
+ // return '缁忛攢鍟嗘病鏈� ' + pro_List[i] + ' 鐨勪骇鍝佷笂闄愯瀹氭潈闄愶紝鎴栦骇鍝佷笉瀛樺湪锛�';
+ return new ResponseBodyLWC(
+ 'Error',
+ 500,
+ '缁忛攢鍟嗘病鏈� ' + pro_List[i] + ' 鐨勪骇鍝佷笂闄愯瀹氭潈闄愶紝鎴栦骇鍝佷笉瀛樺湪锛�',
+ ''
+ );
+ }
+ }
+ String productLimitDa = '';
+ for (String str : productLimit.split(',')) {
+ if (str != null && str != '') {
+ productLimitDa += ',' + str;
+ }
+ }
+ Savepoint sp = Database.setSavepoint();
+ try {
+ Account accinfo = new Account();
+ accinfo.Id = accountId;
+ if (EngFlag) {
+ accinfo.Product_Limit_DateENG__c = String.isBlank(productLimitDa)
+ ? productLimitDa
+ : productLimitDa.subString(1);
+ } else if (ETFlag) {
+ accinfo.Product_Limit_Date__c = String.isBlank(productLimitDa)
+ ? productLimitDa
+ : productLimitDa.subString(1);
+ }
+
+ update accinfo;
+ res.status = 'Success';
+ res.code = 200;
+ System.debug('res = ' + res);
+ return res;
+ // return '';
+ } catch (DmlException de) {
+ Database.rollback(sp);
+ throw de;
+ }
+ }
+ public static String checkResoult(String productLimit) {
+ String[] proLimit = productLimit.split(',');
+ String nowName = null, nowRightAsstModelNo = null;
+ List<String> asstModelNo = new List<String>();
+ Map<String, String> asstModelNoMap = new Map<String, String>();
+ List<String> asstModelNoCount = new List<String>();
+ for (Integer i = 0; i < proLimit.size(); i++) {
+ nowName = proLimit[i];
+ if (nowName.indexOf('|') >= 0) {
+ nowRightAsstModelNo = nowName.subString(0, nowName.indexOf('|'));
+ }
+ asstModelNo.add(nowRightAsstModelNo);
+ }
+
+ for (Integer i = 0; i < asstModelNo.size(); i++) {
+ if (asstModelNoMap.containsKey(asstModelNo[i])) {
+ asstModelNoCount.add(asstModelNo[i]);
+ } else {
+ asstModelNoMap.put(asstModelNo[i], asstModelNo[i]);
+ }
+ }
+ if (asstModelNoCount.size() > 0) {
+ return '浜у搧锛�' + asstModelNoCount + '鐨勬暟鎹噸澶嶃��';
+ // return new ResponseBodyLWC('Error',500,'浜у搧锛�' + asstModelNoCount + '鐨勬暟鎹噸澶嶃��', '');
+ } else {
+ return '';
+ }
+ }
+}
diff --git a/force-app/main/default/classes/LexUpAccountProLimitControllerTest.cls b/force-app/main/default/classes/LexUpAccountProLimitControllerTest.cls
new file mode 100644
index 0000000..4686c3c
--- /dev/null
+++ b/force-app/main/default/classes/LexUpAccountProLimitControllerTest.cls
@@ -0,0 +1,164 @@
+@isTest
+private class LexUpAccountProLimitControllerTest {
+ @isTest
+ static void proLimitTest() {
+ 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)'
+ ];
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true
+ );
+ 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 myAccount2 = new Account(
+ Name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|2|4'
+ );
+ insert myAccount2;
+ String productLimit = 'Test01|2|4,Test02|3|5';
+ String resultText = UpAccountProLimit.upAccount(
+ myAccount2.Id,
+ productLimit,
+ 'ET'
+ );
+ List<Account> accountre = [
+ SELECT Id, Product_Limit_Date__c
+ FROM Account
+ WHERE Id = :myAccount2.Id
+ ];
+ LexUpAccountProLimit.upAccount(myAccount2.Id, productLimit, 'ENG');
+ LexUpAccountProLimit.upAccount(myAccount2.Id, productLimit, '');
+ LexUpAccountProLimit.upAccount('1000', productLimit, 'ENG');
+ // System.assertEquals('Test01|2|4,Test02|3|5', accountre[0].Product_Limit_Date__c);
+ }
+ @isTest
+ static void proLimitTest1() {
+ 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)'
+ ];
+ Product2 prod01 = new Product2(
+ Name = 'Test01',
+ ProductCode = 'Test01',
+ Asset_Model_No__c = 'Test01',
+ SFDA_Status__c = '涓嶈',
+ Dealer_special_Object__c = true
+ );
+ Product2 prod02 = new Product2(
+ Name = 'Test02',
+ ProductCode = 'Test02',
+ Asset_Model_No__c = 'Test02',
+ SFDA_Status__c = '婧栧倷涓�',
+ Dealer_special_Object__c = true
+ );
+ 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 };
+ System.debug('pro1===>' + pro1);
+ System.debug('pro2===>' + pro2);
+
+ List<Product2__c> roduct2List1 = [
+ SELECT
+ Id,
+ Asset_Model_No__c,
+ Estimation_Entry_Possibility__c,
+ Product_Type__c
+ FROM Product2__c
+ WHERE id = :pro2.Id
+ ];
+ List<Product2__c> roduct2List2 = [
+ SELECT
+ Id,
+ Asset_Model_No__c,
+ Estimation_Entry_Possibility__c,
+ Product_Type__c
+ FROM Product2__c
+ WHERE id = :pro1.Id
+ ];
+ System.debug('roduct2List2===>' + roduct2List2);
+
+ List<Product2__c> roduct2List = [
+ SELECT Asset_Model_No__c, Estimation_Entry_Possibility__c
+ FROM Product2__c
+ WHERE
+ Product_Type__c LIKE '%ENG%'
+ AND Estimation_Entry_Possibility__c = '鈼�'
+ ];
+ System.debug('roduct2List' + roduct2List);
+
+ Account myAccount2 = new Account(
+ Name = 'Testaccount002',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ Product_Limit_Date__c = 'Test01|2|4'
+ );
+ insert myAccount2;
+ String productLimit = 'Test01|2|4,Test02|3|5';
+ String productLimit1 = 'Test01|2|4';
+ String resultText = UpAccountProLimit.upAccount(
+ myAccount2.Id,
+ productLimit,
+ 'ENG'
+ );
+ List<Account> accountre = [
+ SELECT Id, Product_Limit_Date__c
+ FROM Account
+ WHERE Id = :myAccount2.Id
+ ];
+ // LexUpAccountProLimit.upAccount(myAccount2.Id,productLimit,'');
+ LexUpAccountProLimit.upAccount(myAccount2.Id, productLimit1, 'ET');
+ // System.assertEquals('Test01|2|4,Test02|3|5', accountre[0].Product_Limit_Date__c);
+ }
+}
diff --git a/force-app/main/default/classes/LexUpAccountProLimitControllerTest.cls-meta.xml b/force-app/main/default/classes/LexUpAccountProLimitControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexUpAccountProLimitControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LexUtilityTest.cls b/force-app/main/default/classes/LexUtilityTest.cls
new file mode 100644
index 0000000..33a257f
--- /dev/null
+++ b/force-app/main/default/classes/LexUtilityTest.cls
@@ -0,0 +1,20 @@
+@IsTest
+private class LexUtilityTest {
+ @IsTest
+ static void testMethod1() {
+ User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
+ insert n;
+ LicenceReminderDate__c l = new LicenceReminderDate__c(
+ Name = '180Days',
+ ReminderDays__c = 180
+ );
+ insert l;
+ Test.startTest();
+ System.runAs(currentUser) {
+ LexUtility.getIsNoteStay();
+ LexUtility.getLicenceReminderDays();
+ }
+ Test.stopTest();
+ }
+}
diff --git a/force-app/main/default/classes/LexUtilityTest.cls-meta.xml b/force-app/main/default/classes/LexUtilityTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LexUtilityTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/LookupSearchResultTest.cls b/force-app/main/default/classes/LookupSearchResultTest.cls
new file mode 100644
index 0000000..3808289
--- /dev/null
+++ b/force-app/main/default/classes/LookupSearchResultTest.cls
@@ -0,0 +1,63 @@
+@isTest
+private class LookupSearchResultTest {
+ @testSetup
+ static void testInfo() {
+ List<RecordType> rectCo = [
+ SELECT Id
+ FROM RecordType
+ WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�'
+ ];
+ if (rectCo.size() == 0) {
+ return;
+ }
+ Account myAccount2 = new Account(
+ name = 'Account001',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '2'
+ );
+ insert myAccount2;
+ }
+
+ @isTest
+ static void testLookupSearchResult() {
+ String id = '';
+ String title = '';
+ List<Account> account = [
+ SELECT Id, Name
+ FROM Account
+ WHERE Name = 'Account001'
+ LIMIT 1
+ ];
+ for (Account acc : account) {
+ id = acc.Id;
+ }
+ object compareTo = account;
+ LookupSearchResult resultA = new LookupSearchResult(
+ id,
+ 'Account',
+ 'standard:account',
+ 'Account',
+ 'Account'
+ );
+ LookupSearchResult resultB = new LookupSearchResult('', '', '', title, '');
+ LookupSearchResult resultC = new LookupSearchResult(
+ id,
+ 'Account',
+ 'standard:account',
+ title,
+ 'Account'
+ );
+ System.Test.startTest();
+ resultA.getId();
+ resultA.getSObjectType();
+ resultA.getIcon();
+ resultA.getTitle();
+ resultA.getSubtitle();
+ resultB.compareTo(resultB);
+ System.assertEquals(1, account.size(), 'expecting to find 1 Account');
+ List<LookupSearchResult> con = new List<LookupSearchResult>();
+ con.sort();
+ System.Test.stopTest();
+ }
+}
diff --git a/force-app/main/default/classes/LookupSearchResultTest.cls-meta.xml b/force-app/main/default/classes/LookupSearchResultTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/LookupSearchResultTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/NewAndEditLeadController.cls b/force-app/main/default/classes/NewAndEditLeadController.cls
index 023e13b..b36e1c7 100644
--- a/force-app/main/default/classes/NewAndEditLeadController.cls
+++ b/force-app/main/default/classes/NewAndEditLeadController.cls
@@ -571,7 +571,6 @@
public static Integer ControllerUtil() {
Integer i = 0;
-
return i;
}
}
diff --git a/force-app/main/default/classes/Product2Handler.cls b/force-app/main/default/classes/Product2Handler.cls
index 89d3df3..cbde78d 100644
--- a/force-app/main/default/classes/Product2Handler.cls
+++ b/force-app/main/default/classes/Product2Handler.cls
@@ -1,499 +1,616 @@
public without sharing class Product2Handler extends Oly_TriggerHandler {
- private Map<Id, Product2> newMap;
- private Map<Id, Product2> oldMap;
- private List<Product2> newList;
- private List<Product2> oldList;
+ private Map<Id, Product2> newMap;
+ private Map<Id, Product2> oldMap;
+ private List<Product2> newList;
+ private List<Product2> oldList;
- public Product2Handler() {
- this.newMap = (Map<Id, Product2>) Trigger.newMap;
- this.oldMap = (Map<Id, Product2>) Trigger.oldMap;
- this.newList = (List<Product2>) Trigger.new;
- this.oldList = (List<Product2>) Trigger.old;
- }
+ public Product2Handler() {
+ this.newMap = (Map<Id, Product2>) Trigger.newMap;
+ this.oldMap = (Map<Id, Product2>) Trigger.oldMap;
+ this.newList = (List<Product2>) Trigger.new;
+ this.oldList = (List<Product2>) Trigger.old;
+ }
- protected override void beforeInsert() {
- beforeSetValue();
- // SWAG-BHE9GK LHJ 绔炰簤瀵规墜浜у搧鑷姩缂栫爜 Start
- SetCompetitorCode();
- // SWAG-BHE9GK LHJ 绔炰簤瀵规墜浜у搧鑷姩缂栫爜 End
- // WLIG-CKKA4M xxf 銆愬鎵樸�戙�愪骇鍝佷富鏁版嵁銆戞敞鍐岃瘉鏇存柊鍚庨儴鍒嗗瓧娈典俊鎭湭鑷姩浠e叆 Start
- AutomaticallyBringData();
- // WLIG-CKKA4M xxf 銆愬鎵樸�戙�愪骇鍝佷富鏁版嵁銆戞敞鍐岃瘉鏇存柊鍚庨儴鍒嗗瓧娈典俊鎭湭鑷姩浠e叆 End
- }
- protected override void beforeUpdate() {
- beforeSetValue();
- //SFDC鍋滄棰勮 lt 20211015 add start
- // FlgStopManufacure(this.newList, this.oldMap);
- //SFDC鍋滄棰勮 lt 20211015 add end
- FlgStopManufacure();
-
- }
-
- //SFDC鍋滄棰勮 lt 20210922 add start
- protected override void afterUpdate(){
- Calculate_AverageMonthSales(this.newList, this.oldMap);
- AssignmentUltrasonic(this.newList, this.oldMap); //20230506 lt DB202304618804 鍖呭惈瓒呭0 add
- }
- //SFDC鍋滄棰勮 lt 20210922 add end
-
+ protected override void beforeInsert() {
+ beforeSetValue();
// SWAG-BHE9GK LHJ 绔炰簤瀵规墜浜у搧鑷姩缂栫爜 Start
- private void SetCompetitorCode() {
- Boolean SelctFlg = False;
- list<AggregateResult> proList;
- //甯﹂噺閲囪喘淇敼 start fy
- list<AggregateResult> proListsc;
- //甯﹂噺閲囪喘淇敼 end fy
- String strPC = '';
- //甯﹂噺閲囪喘淇敼 start fy
- String strPCsc = '';
- //甯﹂噺閲囪喘淇敼 end fy
- Integer i = 1;
-
- String ProductRecordTypes = System.Label.ProductRecordTypeID;
- String[] RecordTypes = String.isNotBlank(ProductRecordTypes) ? ProductRecordTypes.split(',') : null;
-
- for (Product2 nObj : newList) {
- //甯﹂噺閲囪喘淇敼 start fy
- String RecordTypeString = '';
- if(nObj.RecordTypeId!=null){
- RecordTypeString=String.valueof(nObj.RecordTypeId).substring(0,15);
- }
- // nObj.Competitor_product_dummy__c=System.Label.ProductRecordTypeID.contains(RecordTypeString);
- // if (nObj.Competitor_product_dummy__c) {
- if (System.Label.ProductRecordTypeID.contains(RecordTypeString)) {
- SelctFlg = True;
- }
- //甯﹂噺閲囪喘淇敼 end fy
- }
- if (SelctFlg) {
- proList = [Select Max(ProductCode) PC From Product2 Where ProductCode Like 'SD%' and ProductCode!='SD999999'];
- if (proList != null && proList.size() > 0) {
- strPC = String.valueof(proList[0].get('PC'));
- }
- //甯﹂噺閲囪喘 start fy
- proListsc = [Select Max(ProductCode) PC From Product2 Where ProductCode Like 'SC%'];
- if (proListsc != null && proListsc.size() > 0) {
- strPCsc = String.valueof(proListsc[0].get('PC'));
- }
- //甯﹂噺閲囪喘 end fy
- }
- for (Product2 nObj : newList) {
- //甯﹂噺閲囪喘 start fy
- String RecordTypeString = '';
- if(nObj.RecordTypeId!=null){
- RecordTypeString=String.valueof(nObj.RecordTypeId).substring(0,15);
- }
- // if (nObj.Competitor_product_dummy__c && strPC.length() == 8
- // if (System.Label.ProductRecordTypeID.contains(RecordTypeString) && strPC.length() == 8
- if (System.Label.ProductRecordTypeID.contains(RecordTypeString)) {
- //甯﹂噺閲囪喘 end fy
- // && proList != null && proList.size() > 0 ) {
- // Integer num = Integer.valueOf(strPC.SubString(2,strPC.length())) + i;
- Integer num = String.isNotBlank(strPC) ? Integer.valueOf(strPC.SubString(2,strPC.length())) + i : i;
- //甯﹂噺閲囪喘 start fy
- Integer numsc = String.isNotBlank(strPCsc) ? Integer.valueOf(strPCsc.SubString(2,strPCsc.length())) + i : i;
- // if(RecordTypeString=='0129D000001NacC'){
- if(RecordTypes != null && RecordTypes.size() > 1 && RecordTypeString == RecordTypes[1]){
- nObj.ProductCode = 'SC' + String.valueOf(numsc).leftpad(8,'0');
- }else{
- nObj.ProductCode = 'SD' + String.valueOf(num).leftpad(6,'0');
- }
- //甯﹂噺閲囪喘 end fy
- // nObj.ProductCode = 'SD' + String.valueOf(num).leftpad(6,'0');
- i++;
- }
- }
- }
+ SetCompetitorCode();
// SWAG-BHE9GK LHJ 绔炰簤瀵规墜浜у搧鑷姩缂栫爜 End
-
-
- //WLIG-CKKA4M xxf 銆愬鎵樸�戙�愪骇鍝佷富鏁版嵁銆戞敞鍐岃瘉鏇存柊鍚庨儴鍒嗗瓧娈典俊鎭湭鑷姩浠e叆 Start
- private void AutomaticallyBringData() {
- List<String> noNewList = new List<String>();
- for(Product2 prd : newList){
- if (prd.Asset_Model_No__c != null) {
- noNewList.add(prd.Asset_Model_No__c);
- }
- }
- if (!noNewList.isEmpty()) {
-
- List<Product2> prdList = [select Id, Name,Asset_Model_No__c,MDM_Name__c,
- Maintenance_Price_Year__c,Extend_new_product_gurantee_MD__c,
- Extend_Gurantee_Start_MD__c,Extend_Gurantee_End_MD__c,
- Entend_gurantee_period_MD__c,Extend_new_product_gurantee__c,
- Extend_Gurantee_Start__c,Extend_Gurantee_End__c,Entend_gurantee_period__c,
- CanNotCancelledGurantee__c,Service_Category1__c,
- Service_Category2__c,Service_Category3__c,
- Service_Category4__c,Service_Category5__c,
- Service_Category6__c,Service_Category7__c,
- Can_Repair__c,RepairListPriceLevelA__c,
- RepairListPriceLevelB__c,RepairListPriceLevelC__c,
- PartSupplyFinishDate__c,EndSaleDate__c,ProductClass__c,ProductCategory__c,
- Period_Filter_Classify1__c,Period_Filter_Classify2__c,Period_Filter_Classify3__c,
- Intra_Trade_Service_RMB_Date1__c,Intra_Trade_Service_RMB_Date2__c,
- Intra_Trade_Service_RMB_EndDate1__c,Intra_Trade_Service_RMB_EndDate2__c,
- Intra_Trade_Service_RMB_1__c,Intra_Trade_Service_RMB_2__c
- from Product2
- where Asset_Model_No__c in :noNewList
- order by CreatedDate desc];
- if (prdList.isEmpty()) {
- return;
- }
- Map<String, Product2> prdMap = new Map<String, Product2>();
- for (Product2 pro2 : prdList) {
- if (!prdMap.isEmpty() && prdMap.containskey(pro2.Asset_Model_No__c)) {
- } else {
- prdMap.put(pro2.Asset_Model_No__c, pro2);
- }
- }
-
- for(Product2 prd : newList){
- if (prdMap.containskey(prd.Asset_Model_No__c)){
- prd.Maintenance_Price_Year__c = prdMap.get(prd.Asset_Model_No__c).Maintenance_Price_Year__c;//缁翠慨鍚堝悓鎶ヤ环
- prd.CanNotCancelledGurantee__c = prdMap.get(prd.Asset_Model_No__c).CanNotCancelledGurantee__c;//涓嶅彲鍙栨秷澶氬勾淇濅慨
- prd.ProductClass__c = prdMap.get(prd.Asset_Model_No__c).ProductClass__c;//甯傚満浜у搧绫诲埆
- prd.ProductCategory__c = prdMap.get(prd.Asset_Model_No__c).ProductCategory__c;//甯傚満鍖哄垎
- prd.Extend_new_product_gurantee_MD__c = prdMap.get(prd.Asset_Model_No__c).Extend_new_product_gurantee_MD__c;//甯傚満淇濅慨瀵硅薄
- prd.Extend_new_product_gurantee__c = prdMap.get(prd.Asset_Model_No__c).Extend_new_product_gurantee__c;//鏈嶅姟淇濅慨瀵硅薄
- if (prdMap.get(prd.Asset_Model_No__c).Extend_new_product_gurantee_MD__c == true) {//甯傚満淇濅慨瀵硅薄
- prd.Entend_gurantee_period_MD__c = prdMap.get(prd.Asset_Model_No__c).Entend_gurantee_period_MD__c;//甯傚満淇濅慨鏈�(骞�)
- }
- if(prdMap.get(prd.Asset_Model_No__c).Extend_new_product_gurantee__c == true){//鏈嶅姟淇濅慨瀵硅薄
- prd.Entend_gurantee_period__c = prdMap.get(prd.Asset_Model_No__c).Entend_gurantee_period__c;//鏈嶅姟淇濅慨鏈�(骞�)
- }
- prd.Extend_Gurantee_Start_MD__c = prdMap.get(prd.Asset_Model_No__c).Extend_Gurantee_Start_MD__c;//甯傚満淇濅慨寮�濮嬫棩
- prd.Extend_Gurantee_End_MD__c = prdMap.get(prd.Asset_Model_No__c).Extend_Gurantee_End_MD__c;//甯傚満淇濅慨缁撴潫鏃�
- prd.Extend_Gurantee_Start__c = prdMap.get(prd.Asset_Model_No__c).Extend_Gurantee_Start__c;//鏈嶅姟淇濅慨寮�濮嬫棩
- prd.Extend_Gurantee_End__c = prdMap.get(prd.Asset_Model_No__c).Extend_Gurantee_End__c;//鏈嶅姟淇濅慨缁撴潫鏃�
- prd.Service_Category1__c = prdMap.get(prd.Asset_Model_No__c).Service_Category1__c;//绗�1鏈嶅姟鍒嗙被
- prd.Service_Category2__c = prdMap.get(prd.Asset_Model_No__c).Service_Category2__c;
- prd.Service_Category3__c = prdMap.get(prd.Asset_Model_No__c).Service_Category3__c;
- prd.Service_Category4__c = prdMap.get(prd.Asset_Model_No__c).Service_Category4__c;
- prd.Service_Category5__c = prdMap.get(prd.Asset_Model_No__c).Service_Category5__c;
- prd.Service_Category6__c = prdMap.get(prd.Asset_Model_No__c).Service_Category6__c;
- prd.Service_Category7__c = prdMap.get(prd.Asset_Model_No__c).Service_Category7__c;
- prd.Can_Repair__c = prdMap.get(prd.Asset_Model_No__c).Can_Repair__c;//鏄惁鍙淮淇�
- prd.RepairListPriceLevelA__c = prdMap.get(prd.Asset_Model_No__c).RepairListPriceLevelA__c;//A锛圵锛夌骇缁翠慨鍙傝�冧环鏍�
- prd.RepairListPriceLevelB__c = prdMap.get(prd.Asset_Model_No__c).RepairListPriceLevelB__c;
- prd.RepairListPriceLevelC__c = prdMap.get(prd.Asset_Model_No__c).RepairListPriceLevelC__c;
- prd.PartSupplyFinishDate__c = prdMap.get(prd.Asset_Model_No__c).PartSupplyFinishDate__c;//闆朵欢鍋滄渚涘簲鏃ユ湡
- prd.EndSaleDate__c = prdMap.get(prd.Asset_Model_No__c).EndSaleDate__c;//鍋滄閿�鍞棩鏈�
- prd.Period_Filter_Classify1__c = prdMap.get(prd.Asset_Model_No__c).Period_Filter_Classify1__c;//钀ヤ笟缁熻鍒嗙被1
- prd.Period_Filter_Classify2__c = prdMap.get(prd.Asset_Model_No__c).Period_Filter_Classify2__c;//钀ヤ笟缁熻鍒嗙被2
- prd.Period_Filter_Classify3__c = prdMap.get(prd.Asset_Model_No__c).Period_Filter_Classify3__c;//钀ヤ笟缁熻鍒嗙被3
- prd.Intra_Trade_Service_RMB_Date1__c = prdMap.get(prd.Asset_Model_No__c).Intra_Trade_Service_RMB_Date1__c;//澶氬勾淇濅环鏍兼湁鏁堝紑濮嬫棩1
- prd.Intra_Trade_Service_RMB_Date2__c = prdMap.get(prd.Asset_Model_No__c).Intra_Trade_Service_RMB_Date2__c;//澶氬勾淇濅环鏍兼湁鏁堝紑濮嬫棩2
- prd.Intra_Trade_Service_RMB_EndDate1__c = prdMap.get(prd.Asset_Model_No__c).Intra_Trade_Service_RMB_EndDate1__c;//澶氬勾淇濅环鏍兼湁鏁堢粨鏉熸棩1
- prd.Intra_Trade_Service_RMB_EndDate2__c = prdMap.get(prd.Asset_Model_No__c).Intra_Trade_Service_RMB_EndDate2__c;//澶氬勾淇濅环鏍兼湁鏁堢粨鏉熸棩2
- prd.Intra_Trade_Service_RMB_1__c = prdMap.get(prd.Asset_Model_No__c).Intra_Trade_Service_RMB_1__c;//澶氬勾淇濅环鏍�1
- prd.Intra_Trade_Service_RMB_2__c = prdMap.get(prd.Asset_Model_No__c).Intra_Trade_Service_RMB_2__c;//澶氬勾淇濅环鏍�2
- }
- }
- }
-
- }
- // WLIG-CKKA4M xxf 銆愬鎵樸�戙�愪骇鍝佷富鏁版嵁銆戞敞鍐岃瘉鏇存柊鍚庨儴鍒嗗瓧娈典俊鎭湭鑷姩浠e叆 end
-
- private void beforeSetValue() {
-
- for (Product2 nObj : newList) {
- //CHAN-B8GCBB
- if (nObj.WhiteSpace__c == true) {
- nObj.StorageStatus__c = String.valueOf(nObj.StorageStatusNo__c);
- } else {
- nObj.StorageStatus__c = '';
- }
- //CHAN-B8GCBB
-
- nObj.Fixture_Model_No_T__c = nObj.Fixture_Model_No_F__c;
- // CBPR LHJ
- if (Trigger.isInsert ||
- (Trigger.isUpdate && nObj.SFDA_Status_New__c != oldMap.get(nObj.id).SFDA_Status_New__c)) {
- nObj.SFDA_Status__c = nobj.SFDA_Status_New__c;
- if (nobj.SFDA_Status_New__c == '鏂拌=鍝佺敵璜嬩腑' || nobj.SFDA_Status_New__c == '婧栧倷涓�') {
- nObj.SFDA_Status__c = '鍋滄';
- }
- }
- // CBPR LHJ
-
- // SWAG-BHE9GK LHJ 绔炰簤瀵规墜浜у搧鑷姩缂栫爜 Start
- if (Trigger.isInsert) {
-
- }
- // SWAG-BHE9GK LHJ 绔炰簤瀵规墜浜у搧鑷姩缂栫爜 End
- }
- }
-
- //SFDC鍋滄棰勮 lt 20210914 add start
- private static void Calculate_AverageMonthSales(List<Product2> newList,Map<Id, Product2> oldMap){
-
- //绗﹀悎鏉′欢鐨� 鏃� 浜у搧List
- List<Id> oproList = new List<Id>();
- //绗﹀悎鏉′欢鐨� 鏂版棫 浜у搧Id List 浣滀负鏉′欢
- List<Id> conList = new List<Id>();
- //Map<鏃х殑锛屾柊鐨�>瀵瑰簲
- Map<String,String> matMap = new Map<String,String>();
-
- //Map<鏃d锛岄璁″仠姝㈡棩>
- Map<String,Date> adateMap = new Map<String,Date>();
-
- //Map<鏃d, x(骞冲潎鏈堥攢閲�)>
- Map<String,Integer> xMap = new Map<String,Integer>();
- //Map<鏃d, z(澶╂暟)>
- Map<String,Integer> zMap = new Map<String,Integer>();
-
- for(Product2 term : newList){
- System.debug('鏍囪瘑'+term.CalMonthSalesFLG__c);
- System.debug('鏂板簱瀛�'+term.StorageStatusNo__c);
- System.debug('鏃у簱瀛�'+oldMap.get(term.Id).StorageStatusNo__c);
- if(term.M_BC_Stop_manufacure__c != null && term.SFDA_Status__c != '鍋滄' && (term.StorageStatusNo__c != oldMap.get(term.Id).StorageStatusNo__c || term.CalMonthSalesFLG__c == true)){
- if(term.Correspond_Code__c != null){
- matMap.put((String)term.Id,(String)term.Correspond_Code__c);
- conList.add(term.Correspond_Code__c);
- }
- conList.add(term.Id);
- oproList.add(term.Id);
-
- adateMap.put(term.Id, term.M_BC_Stop_manufacure__c);
- }
- }
-
- //鍋� 涓�瀵瑰 鐨� Map<String,List<鏈堥攢閲�>>
- Map<String,List<ProductMonthlySales__c>> msMap = new Map<String,List<ProductMonthlySales__c>>();
-
- if(conList.size()>0){
- List<ProductMonthlySales__c> msList = [Select Id, MonthSales__c, CurrentMonth__c, CurrentDate__c,
- CurrentYear__c, ProductM__c, Product2Model__c,
- ProductM__r.StorageStatusNo__c,
- ProductM__r.M_BC_Stop_manufacure__c
- From ProductMonthlySales__c
- Where ProductM__c in: conList
- Order by CurrentDate__c DESC];
- //鍙屽眰寰幆 浜у搧==>鏈堥攢閲�
- for(Id pro : conList){
- for(ProductMonthlySales__c mms : msList){
- if(pro == mms.ProductM__c){
- if(msMap.containsKey(pro)){
- msMap.get(pro).add(mms);
- }else{
- List<ProductMonthlySales__c> pmsaleList = new List<ProductMonthlySales__c>();
- pmsaleList.add(mms);
- msMap.put(pro, pmsaleList);
- }
- }
-
- }
- }
-
- System.debug('鏉′欢List'+conList);
- System.debug('sql鏌ュ埌鐨凩ist'+msList);
- System.debug('浜у搧鏈堥攢閲弇sMap涓�'+msMap);
- System.debug('鏃х殑浜у搧List'+oproList);
-
- if(msMap.size() > 0){
- System.debug('浜у搧鏈堥攢閲弇sMap涓�'+msMap);
- for(Id res : oproList){
-
- //a鏃� 鏈堥攢閲忓拰 ; b鏂� 鏈堥攢閲忓拰 ; c鍟�(骞冲潎鏈堥攢閲�) ; x鍟嗗洓鑸嶄簲鍏� ;
- //y 搴撳瓨/骞冲潎鏈堥攢閲忓ぉ鏁� ; z 澶╂暟 鍥涜垗浜斿叆
- Decimal c = 0, y = 0;
- Integer x = 0, z = 0;
-
- if(msMap.get(res) != null){
- //鏈堥攢閲忓ぇ浜�12涓湀
- if(msMap.get(res).size() >= 12){
- Decimal a = 0 , b = 0;
- Integer i;
- for(i = 0 ; i < 12 ; i++){
- a += msMap.get(res)[i].MonthSales__c;
- }
- if(matMap.get(res) != null){
- if(msMap.get(matMap.get(res)) != null){
- if(msMap.get(matMap.get(res)).size() >= 12){
- for(i = 0 ; i < 12 ; i++){
- b += msMap.get(matMap.get(res))[i].MonthSales__c;
- System.debug('鏂扮殑澶т簬鍗佷簩'+b);
- }
- }
- else{
- for(ProductMonthlySales__c nms : msMap.get(matMap.get(res))){
- b+=nms.MonthSales__c;
- System.debug('鏂扮殑灏忎簬鍗佷簩閬嶅巻鍏ㄩ儴'+b);
- }
-
- }
- }
- }
-
- //鍥涜垗浜斿叆
- c = (a + b) / 12 ;
-
- if(c > 1){
- x = Integer.valueOf(c.round(System.RoundingMode.HALF_UP));
- xMap.put(res,x);
- }else if(c > 0){
- x = 1;
- xMap.put(res,x);
- }
- //x = Integer.valueOf(c.round(System.RoundingMode.Up));
- //x = Integer.valueOf(c.round(System.RoundingMode.HALF_UP));
-
- System.debug('鏂�'+b);
- System.debug('鏃�'+a);
- System.debug('闄ゆ硶瓒砪'+c);
- System.debug('鍥涜垗浜斿叆x'+x);
-
- }
- //鏈堥攢閲忎笉瓒�12涓湀
- else{
- Decimal a = 0 , b = 0 ;
- for(ProductMonthlySales__c oms : msMap.get(res)){
- a+=oms.MonthSales__c;
- }
- if(msMap.get(matMap.get(res)) != null){
- for(ProductMonthlySales__c nms : msMap.get(matMap.get(res))){
- b+=nms.MonthSales__c;
- }
- }
- c = (a + b) / msMap.get(res).size();
- //x = Integer.valueOf(c.round(System.RoundingMode.UP));
- //x = Integer.valueOf(c.round(System.RoundingMode.HALF_UP));
- if(c > 1){
- x = Integer.valueOf(c.round(System.RoundingMode.HALF_UP));
- xMap.put(res,x);
- }else if(c > 0){
- x = 1;
- xMap.put(res,x);
- }
-
- System.debug('闄ゆ硶涓嶈冻12c'+c);
- System.debug('鍥涜垗浜斿叆x'+x);
- }
-
- if(x != 0){
- for(ProductMonthlySales__c dat : msMap.get(res)){
- Decimal m = 0;
- if(dat.ProductM__r.StorageStatusNo__c != null){
- m = dat.ProductM__r.StorageStatusNo__c;
- }
- y = m / x;
- y = y * 30 ;
- }
- }
- //z = Integer.valueOf(y.round(System.RoundingMode.UP));
- z = Integer.valueOf(y.round(System.RoundingMode.HALF_UP));
- zMap.put(res,z);
- System.debug('澶╂暟y'+y);
- System.debug('鍥涜垗浜斿叆z'+z);
-
- }
- }
- }
-
- List<Product2> finList = new List<Product2>();
- for(Id fin : oproList){
- Product2 fip = new Product2();
- fip.Id = fin;
- fip.CalMonthSalesFLG__c = false;
-
- if(xMap.get(fin) != null){
- fip.Average_MonthSales__c = xMap.get(fin);
- }
-
- //20211020
- if(zMap.get(fin) != null){
- if(zMap.get(fin) != 0){
- fip.Estimated_ConsumptionDueDate__c = Date.today().addDays(zMap.get(fin));
- }else{
- if(adateMap != null){
- Date adate = adateMap.get(fin);
- fip.Estimated_ConsumptionDueDate__c = adate;
- }
- }
- }else{
- if(adateMap != null){
- Date adate = adateMap.get(fin);
- fip.Estimated_ConsumptionDueDate__c = adate;
- }
- }
- //20211020
-
- finList.add(fip);
- }
- update finList;
- }
-
- }
- //SFDC鍋滄棰勮 lt 20210914 add end
-
+ // WLIG-CKKA4M xxf 銆愬鎵樸�戙�愪骇鍝佷富鏁版嵁銆戞敞鍐岃瘉鏇存柊鍚庨儴鍒嗗瓧娈典俊鎭湭鑷姩浠e叆 Start
+ AutomaticallyBringData();
+ // WLIG-CKKA4M xxf 銆愬鎵樸�戙�愪骇鍝佷富鏁版嵁銆戞敞鍐岃瘉鏇存柊鍚庨儴鍒嗗瓧娈典俊鎭湭鑷姩浠e叆 End
+ }
+ protected override void beforeUpdate() {
+ beforeSetValue();
//SFDC鍋滄棰勮 lt 20211015 add start
- //ProductMonthlySalesFlag__c 12鏈堥攢閲忔爣璇� 棰勮鍋滄鏃ユ湡(M_BC_Stop_manufacure__c)鍙樺寲鏃�
- // private static void FlgStopManufacure(List<Product2> newList,Map<Id, Product2> oldMap){
- // if(newList != null){
- // for(Product2 pts : newList){
- // if(oldMap != null){
- // if(pts.M_BC_Stop_manufacure__c != null && oldMap.get(pts.Id).M_BC_Stop_manufacure__c == null){
- // pts.ProductMonthlySalesFlag__c = true;
- // }
- // if(pts.M_BC_Stop_manufacure__c != null && oldMap.get(pts.Id).M_BC_Stop_manufacure__c != null && pts.M_BC_Stop_manufacure__c != oldMap.get(pts.Id).M_BC_Stop_manufacure__c){
- // pts.ProductMonthlySalesFlag__c = true;
- // }
- // if(pts.M_BC_Stop_manufacure__c == null && oldMap.get(pts.Id).M_BC_Stop_manufacure__c != null){
- // pts.ProductMonthlySalesFlag__c = false;
- // pts.Estimated_ConsumptionDueDate__c = null;
- // }
- // }
- // }
- // }
-
- // }
+ // FlgStopManufacure(this.newList, this.oldMap);
//SFDC鍋滄棰勮 lt 20211015 add end
- private void FlgStopManufacure(){
- for(Product2 pts : newList){
+ FlgStopManufacure();
+ }
- Product2 oldPts = oldMap.get(pts.Id);
+ //SFDC鍋滄棰勮 lt 20210922 add start
+ protected override void afterUpdate() {
+ Calculate_AverageMonthSales(this.newList, this.oldMap);
+ AssignmentUltrasonic(this.newList, this.oldMap); //20230506 lt DB202304618804 鍖呭惈瓒呭0 add
+ }
+ //SFDC鍋滄棰勮 lt 20210922 add end
- if(pts.M_BC_Stop_manufacure__c != oldPts.M_BC_Stop_manufacure__c){
- pts.ProductMonthlySalesFlag__c = true;
- if (pts.M_BC_Stop_manufacure__c == null) {
- pts.ProductMonthlySalesFlag__c = false;
- pts.Estimated_ConsumptionDueDate__c = null;
+ // SWAG-BHE9GK LHJ 绔炰簤瀵规墜浜у搧鑷姩缂栫爜 Start
+ private void SetCompetitorCode() {
+ Boolean SelctFlg = false;
+ list<AggregateResult> proList;
+ //甯﹂噺閲囪喘淇敼 start fy
+ list<AggregateResult> proListsc;
+ //甯﹂噺閲囪喘淇敼 end fy
+ String strPC = '';
+ //甯﹂噺閲囪喘淇敼 start fy
+ String strPCsc = '';
+ //甯﹂噺閲囪喘淇敼 end fy
+ Integer i = 1;
+
+ String ProductRecordTypes = System.Label.ProductRecordTypeID;
+ String[] RecordTypes = String.isNotBlank(ProductRecordTypes)
+ ? ProductRecordTypes.split(',')
+ : null;
+
+ for (Product2 nObj : newList) {
+ //甯﹂噺閲囪喘淇敼 start fy
+ String RecordTypeString = '';
+ if (nObj.RecordTypeId != null) {
+ RecordTypeString = String.valueof(nObj.RecordTypeId).substring(0, 15);
+ }
+ // nObj.Competitor_product_dummy__c=System.Label.ProductRecordTypeID.contains(RecordTypeString);
+ // if (nObj.Competitor_product_dummy__c) {
+ if (System.Label.ProductRecordTypeID.contains(RecordTypeString)) {
+ SelctFlg = true;
+ }
+ //甯﹂噺閲囪喘淇敼 end fy
+ }
+ if (SelctFlg) {
+ proList = [
+ SELECT Max(ProductCode) PC
+ FROM Product2
+ WHERE ProductCode LIKE 'SD%' AND ProductCode != 'SD999999'
+ ];
+ if (proList != null && proList.size() > 0) {
+ strPC = String.valueof(proList[0].get('PC'));
+ }
+ //甯﹂噺閲囪喘 start fy
+ // proListsc = [Select Max(ProductCode) PC From Product2 Where ProductCode Like 'SC%'];
+ // if (proListsc != null && proListsc.size() > 0) {
+ // strPCsc = String.valueof(proListsc[0].get('PC'));
+ // }
+ List<Product2> lastPro = [
+ SELECT Id, ProductCode
+ FROM Product2
+ WHERE ProductCode LIKE 'SC%'
+ ORDER BY ProductCode DESC
+ LIMIT 1
+ ];
+ strPCsc = lastPro != null &&
+ lastPro.size() > 0
+ ? lastPro[0].ProductCode
+ : '';
+ //甯﹂噺閲囪喘 end fy
+ }
+ for (Product2 nObj : newList) {
+ //甯﹂噺閲囪喘 start fy
+ String RecordTypeString = '';
+ if (nObj.RecordTypeId != null) {
+ RecordTypeString = String.valueof(nObj.RecordTypeId).substring(0, 15);
+ }
+ // if (nObj.Competitor_product_dummy__c && strPC.length() == 8
+ // if (System.Label.ProductRecordTypeID.contains(RecordTypeString) && strPC.length() == 8
+ if (System.Label.ProductRecordTypeID.contains(RecordTypeString)) {
+ //甯﹂噺閲囪喘 end fy
+ // && proList != null && proList.size() > 0 ) {
+ // Integer num = Integer.valueOf(strPC.SubString(2,strPC.length())) + i;
+ Integer num = String.isNotBlank(strPC)
+ ? Integer.valueOf(strPC.SubString(2, strPC.length())) + i
+ : i;
+ //甯﹂噺閲囪喘 start fy
+ Integer numsc = String.isNotBlank(strPCsc)
+ ? Integer.valueOf(strPCsc.SubString(2, strPCsc.length())) + i
+ : i;
+ // if(RecordTypeString=='0129D000001NacC'){
+ if (
+ RecordTypes != null &&
+ RecordTypes.size() > 1 &&
+ RecordTypeString == RecordTypes[1]
+ ) {
+ nObj.ProductCode = 'SC' + String.valueOf(numsc).leftpad(8, '0');
+ } else {
+ nObj.ProductCode = 'SD' + String.valueOf(num).leftpad(6, '0');
+ }
+ //甯﹂噺閲囪喘 end fy
+ // nObj.ProductCode = 'SD' + String.valueOf(num).leftpad(6,'0');
+ i++;
+ }
+ }
+ }
+ // SWAG-BHE9GK LHJ 绔炰簤瀵规墜浜у搧鑷姩缂栫爜 End
+
+ //WLIG-CKKA4M xxf 銆愬鎵樸�戙�愪骇鍝佷富鏁版嵁銆戞敞鍐岃瘉鏇存柊鍚庨儴鍒嗗瓧娈典俊鎭湭鑷姩浠e叆 Start
+ private void AutomaticallyBringData() {
+ List<String> noNewList = new List<String>();
+ for (Product2 prd : newList) {
+ if (prd.Asset_Model_No__c != null) {
+ noNewList.add(prd.Asset_Model_No__c);
+ }
+ }
+ if (!noNewList.isEmpty()) {
+ List<Product2> prdList = [
+ SELECT
+ Id,
+ Name,
+ Asset_Model_No__c,
+ MDM_Name__c,
+ Maintenance_Price_Year__c,
+ Extend_new_product_gurantee_MD__c,
+ Extend_Gurantee_Start_MD__c,
+ Extend_Gurantee_End_MD__c,
+ Entend_gurantee_period_MD__c,
+ Extend_new_product_gurantee__c,
+ Extend_Gurantee_Start__c,
+ Extend_Gurantee_End__c,
+ Entend_gurantee_period__c,
+ CanNotCancelledGurantee__c,
+ Service_Category1__c,
+ Service_Category2__c,
+ Service_Category3__c,
+ Service_Category4__c,
+ Service_Category5__c,
+ Service_Category6__c,
+ Service_Category7__c,
+ Can_Repair__c,
+ RepairListPriceLevelA__c,
+ RepairListPriceLevelB__c,
+ RepairListPriceLevelC__c,
+ PartSupplyFinishDate__c,
+ EndSaleDate__c,
+ ProductClass__c,
+ ProductCategory__c,
+ Period_Filter_Classify1__c,
+ Period_Filter_Classify2__c,
+ Period_Filter_Classify3__c,
+ Intra_Trade_Service_RMB_Date1__c,
+ Intra_Trade_Service_RMB_Date2__c,
+ Intra_Trade_Service_RMB_EndDate1__c,
+ Intra_Trade_Service_RMB_EndDate2__c,
+ Intra_Trade_Service_RMB_1__c,
+ Intra_Trade_Service_RMB_2__c
+ FROM Product2
+ WHERE Asset_Model_No__c IN :noNewList
+ ORDER BY CreatedDate DESC
+ ];
+ if (prdList.isEmpty()) {
+ return;
+ }
+ Map<String, Product2> prdMap = new Map<String, Product2>();
+ for (Product2 pro2 : prdList) {
+ if (!prdMap.isEmpty() && prdMap.containskey(pro2.Asset_Model_No__c)) {
+ } else {
+ prdMap.put(pro2.Asset_Model_No__c, pro2);
+ }
+ }
+
+ for (Product2 prd : newList) {
+ if (prdMap.containskey(prd.Asset_Model_No__c)) {
+ prd.Maintenance_Price_Year__c = prdMap.get(prd.Asset_Model_No__c)
+ .Maintenance_Price_Year__c; //缁翠慨鍚堝悓鎶ヤ环
+ prd.CanNotCancelledGurantee__c = prdMap.get(prd.Asset_Model_No__c)
+ .CanNotCancelledGurantee__c; //涓嶅彲鍙栨秷澶氬勾淇濅慨
+ prd.ProductClass__c = prdMap.get(prd.Asset_Model_No__c)
+ .ProductClass__c; //甯傚満浜у搧绫诲埆
+ prd.ProductCategory__c = prdMap.get(prd.Asset_Model_No__c)
+ .ProductCategory__c; //甯傚満鍖哄垎
+ prd.Extend_new_product_gurantee_MD__c = prdMap.get(
+ prd.Asset_Model_No__c
+ )
+ .Extend_new_product_gurantee_MD__c; //甯傚満淇濅慨瀵硅薄
+ prd.Extend_new_product_gurantee__c = prdMap.get(prd.Asset_Model_No__c)
+ .Extend_new_product_gurantee__c; //鏈嶅姟淇濅慨瀵硅薄
+ if (
+ prdMap.get(prd.Asset_Model_No__c)
+ .Extend_new_product_gurantee_MD__c == true
+ ) {
+ //甯傚満淇濅慨瀵硅薄
+ prd.Entend_gurantee_period_MD__c = prdMap.get(prd.Asset_Model_No__c)
+ .Entend_gurantee_period_MD__c; //甯傚満淇濅慨鏈�(骞�)
+ }
+ if (
+ prdMap.get(prd.Asset_Model_No__c).Extend_new_product_gurantee__c ==
+ true
+ ) {
+ //鏈嶅姟淇濅慨瀵硅薄
+ prd.Entend_gurantee_period__c = prdMap.get(prd.Asset_Model_No__c)
+ .Entend_gurantee_period__c; //鏈嶅姟淇濅慨鏈�(骞�)
+ }
+ prd.Extend_Gurantee_Start_MD__c = prdMap.get(prd.Asset_Model_No__c)
+ .Extend_Gurantee_Start_MD__c; //甯傚満淇濅慨寮�濮嬫棩
+ prd.Extend_Gurantee_End_MD__c = prdMap.get(prd.Asset_Model_No__c)
+ .Extend_Gurantee_End_MD__c; //甯傚満淇濅慨缁撴潫鏃�
+ prd.Extend_Gurantee_Start__c = prdMap.get(prd.Asset_Model_No__c)
+ .Extend_Gurantee_Start__c; //鏈嶅姟淇濅慨寮�濮嬫棩
+ prd.Extend_Gurantee_End__c = prdMap.get(prd.Asset_Model_No__c)
+ .Extend_Gurantee_End__c; //鏈嶅姟淇濅慨缁撴潫鏃�
+ prd.Service_Category1__c = prdMap.get(prd.Asset_Model_No__c)
+ .Service_Category1__c; //绗�1鏈嶅姟鍒嗙被
+ prd.Service_Category2__c = prdMap.get(prd.Asset_Model_No__c)
+ .Service_Category2__c;
+ prd.Service_Category3__c = prdMap.get(prd.Asset_Model_No__c)
+ .Service_Category3__c;
+ prd.Service_Category4__c = prdMap.get(prd.Asset_Model_No__c)
+ .Service_Category4__c;
+ prd.Service_Category5__c = prdMap.get(prd.Asset_Model_No__c)
+ .Service_Category5__c;
+ prd.Service_Category6__c = prdMap.get(prd.Asset_Model_No__c)
+ .Service_Category6__c;
+ prd.Service_Category7__c = prdMap.get(prd.Asset_Model_No__c)
+ .Service_Category7__c;
+ prd.Can_Repair__c = prdMap.get(prd.Asset_Model_No__c).Can_Repair__c; //鏄惁鍙淮淇�
+ prd.RepairListPriceLevelA__c = prdMap.get(prd.Asset_Model_No__c)
+ .RepairListPriceLevelA__c; //A锛圵锛夌骇缁翠慨鍙傝�冧环鏍�
+ prd.RepairListPriceLevelB__c = prdMap.get(prd.Asset_Model_No__c)
+ .RepairListPriceLevelB__c;
+ prd.RepairListPriceLevelC__c = prdMap.get(prd.Asset_Model_No__c)
+ .RepairListPriceLevelC__c;
+ prd.PartSupplyFinishDate__c = prdMap.get(prd.Asset_Model_No__c)
+ .PartSupplyFinishDate__c; //闆朵欢鍋滄渚涘簲鏃ユ湡
+ prd.EndSaleDate__c = prdMap.get(prd.Asset_Model_No__c).EndSaleDate__c; //鍋滄閿�鍞棩鏈�
+ prd.Period_Filter_Classify1__c = prdMap.get(prd.Asset_Model_No__c)
+ .Period_Filter_Classify1__c; //钀ヤ笟缁熻鍒嗙被1
+ prd.Period_Filter_Classify2__c = prdMap.get(prd.Asset_Model_No__c)
+ .Period_Filter_Classify2__c; //钀ヤ笟缁熻鍒嗙被2
+ prd.Period_Filter_Classify3__c = prdMap.get(prd.Asset_Model_No__c)
+ .Period_Filter_Classify3__c; //钀ヤ笟缁熻鍒嗙被3
+ prd.Intra_Trade_Service_RMB_Date1__c = prdMap.get(
+ prd.Asset_Model_No__c
+ )
+ .Intra_Trade_Service_RMB_Date1__c; //澶氬勾淇濅环鏍兼湁鏁堝紑濮嬫棩1
+ prd.Intra_Trade_Service_RMB_Date2__c = prdMap.get(
+ prd.Asset_Model_No__c
+ )
+ .Intra_Trade_Service_RMB_Date2__c; //澶氬勾淇濅环鏍兼湁鏁堝紑濮嬫棩2
+ prd.Intra_Trade_Service_RMB_EndDate1__c = prdMap.get(
+ prd.Asset_Model_No__c
+ )
+ .Intra_Trade_Service_RMB_EndDate1__c; //澶氬勾淇濅环鏍兼湁鏁堢粨鏉熸棩1
+ prd.Intra_Trade_Service_RMB_EndDate2__c = prdMap.get(
+ prd.Asset_Model_No__c
+ )
+ .Intra_Trade_Service_RMB_EndDate2__c; //澶氬勾淇濅环鏍兼湁鏁堢粨鏉熸棩2
+ prd.Intra_Trade_Service_RMB_1__c = prdMap.get(prd.Asset_Model_No__c)
+ .Intra_Trade_Service_RMB_1__c; //澶氬勾淇濅环鏍�1
+ prd.Intra_Trade_Service_RMB_2__c = prdMap.get(prd.Asset_Model_No__c)
+ .Intra_Trade_Service_RMB_2__c; //澶氬勾淇濅环鏍�2
+ }
+ }
+ }
+ }
+ // WLIG-CKKA4M xxf 銆愬鎵樸�戙�愪骇鍝佷富鏁版嵁銆戞敞鍐岃瘉鏇存柊鍚庨儴鍒嗗瓧娈典俊鎭湭鑷姩浠e叆 end
+
+ private void beforeSetValue() {
+ for (Product2 nObj : newList) {
+ //CHAN-B8GCBB
+ if (nObj.WhiteSpace__c == true) {
+ nObj.StorageStatus__c = String.valueOf(nObj.StorageStatusNo__c);
+ } else {
+ nObj.StorageStatus__c = '';
+ }
+ //CHAN-B8GCBB
+
+ nObj.Fixture_Model_No_T__c = nObj.Fixture_Model_No_F__c;
+ // CBPR LHJ
+ if (
+ Trigger.isInsert ||
+ (Trigger.isUpdate &&
+ nObj.SFDA_Status_New__c != oldMap.get(nObj.id).SFDA_Status_New__c)
+ ) {
+ nObj.SFDA_Status__c = nobj.SFDA_Status_New__c;
+ if (
+ nobj.SFDA_Status_New__c == '鏂拌=鍝佺敵璜嬩腑' ||
+ nobj.SFDA_Status_New__c == '婧栧倷涓�'
+ ) {
+ nObj.SFDA_Status__c = '鍋滄';
+ }
+ }
+ // CBPR LHJ
+
+ // SWAG-BHE9GK LHJ 绔炰簤瀵规墜浜у搧鑷姩缂栫爜 Start
+ if (Trigger.isInsert) {
+ }
+ // SWAG-BHE9GK LHJ 绔炰簤瀵规墜浜у搧鑷姩缂栫爜 End
+ }
+ }
+
+ //SFDC鍋滄棰勮 lt 20210914 add start
+ private static void Calculate_AverageMonthSales(
+ List<Product2> newList,
+ Map<Id, Product2> oldMap
+ ) {
+ //绗﹀悎鏉′欢鐨� 鏃� 浜у搧List
+ List<Id> oproList = new List<Id>();
+ //绗﹀悎鏉′欢鐨� 鏂版棫 浜у搧Id List 浣滀负鏉′欢
+ List<Id> conList = new List<Id>();
+ //Map<鏃х殑锛屾柊鐨�>瀵瑰簲
+ Map<String, String> matMap = new Map<String, String>();
+
+ //Map<鏃d锛岄璁″仠姝㈡棩>
+ Map<String, Date> adateMap = new Map<String, Date>();
+
+ //Map<鏃d, x(骞冲潎鏈堥攢閲�)>
+ Map<String, Integer> xMap = new Map<String, Integer>();
+ //Map<鏃d, z(澶╂暟)>
+ Map<String, Integer> zMap = new Map<String, Integer>();
+
+ for (Product2 term : newList) {
+ System.debug('鏍囪瘑' + term.CalMonthSalesFLG__c);
+ System.debug('鏂板簱瀛�' + term.StorageStatusNo__c);
+ System.debug('鏃у簱瀛�' + oldMap.get(term.Id).StorageStatusNo__c);
+ if (
+ term.M_BC_Stop_manufacure__c != null &&
+ term.SFDA_Status__c != '鍋滄' &&
+ (term.StorageStatusNo__c != oldMap.get(term.Id).StorageStatusNo__c ||
+ term.CalMonthSalesFLG__c == true)
+ ) {
+ if (term.Correspond_Code__c != null) {
+ matMap.put((String) term.Id, (String) term.Correspond_Code__c);
+ conList.add(term.Correspond_Code__c);
+ }
+ conList.add(term.Id);
+ oproList.add(term.Id);
+
+ adateMap.put(term.Id, term.M_BC_Stop_manufacure__c);
+ }
+ }
+
+ //鍋� 涓�瀵瑰 鐨� Map<String,List<鏈堥攢閲�>>
+ Map<String, List<ProductMonthlySales__c>> msMap = new Map<String, List<ProductMonthlySales__c>>();
+
+ if (conList.size() > 0) {
+ List<ProductMonthlySales__c> msList = [
+ SELECT
+ Id,
+ MonthSales__c,
+ CurrentMonth__c,
+ CurrentDate__c,
+ CurrentYear__c,
+ ProductM__c,
+ Product2Model__c,
+ ProductM__r.StorageStatusNo__c,
+ ProductM__r.M_BC_Stop_manufacure__c
+ FROM ProductMonthlySales__c
+ WHERE ProductM__c IN :conList
+ ORDER BY CurrentDate__c DESC
+ ];
+ //鍙屽眰寰幆 浜у搧==>鏈堥攢閲�
+ for (Id pro : conList) {
+ for (ProductMonthlySales__c mms : msList) {
+ if (pro == mms.ProductM__c) {
+ if (msMap.containsKey(pro)) {
+ msMap.get(pro).add(mms);
+ } else {
+ List<ProductMonthlySales__c> pmsaleList = new List<ProductMonthlySales__c>();
+ pmsaleList.add(mms);
+ msMap.put(pro, pmsaleList);
+ }
+ }
+ }
+ }
+
+ System.debug('鏉′欢List' + conList);
+ System.debug('sql鏌ュ埌鐨凩ist' + msList);
+ System.debug('浜у搧鏈堥攢閲弇sMap涓�' + msMap);
+ System.debug('鏃х殑浜у搧List' + oproList);
+
+ if (msMap.size() > 0) {
+ System.debug('浜у搧鏈堥攢閲弇sMap涓�' + msMap);
+ for (Id res : oproList) {
+ //a鏃� 鏈堥攢閲忓拰 ; b鏂� 鏈堥攢閲忓拰 ; c鍟�(骞冲潎鏈堥攢閲�) ; x鍟嗗洓鑸嶄簲鍏� ;
+ //y 搴撳瓨/骞冲潎鏈堥攢閲忓ぉ鏁� ; z 澶╂暟 鍥涜垗浜斿叆
+ Decimal c = 0, y = 0;
+ Integer x = 0, z = 0;
+
+ if (msMap.get(res) != null) {
+ //鏈堥攢閲忓ぇ浜�12涓湀
+ if (msMap.get(res).size() >= 12) {
+ Decimal a = 0, b = 0;
+ Integer i;
+ for (i = 0; i < 12; i++) {
+ a += msMap.get(res)[i].MonthSales__c;
+ }
+ if (matMap.get(res) != null) {
+ if (msMap.get(matMap.get(res)) != null) {
+ if (msMap.get(matMap.get(res)).size() >= 12) {
+ for (i = 0; i < 12; i++) {
+ b += msMap.get(matMap.get(res))[i].MonthSales__c;
+ System.debug('鏂扮殑澶т簬鍗佷簩' + b);
+ }
+ } else {
+ for (
+ ProductMonthlySales__c nms : msMap.get(matMap.get(res))
+ ) {
+ b += nms.MonthSales__c;
+ System.debug('鏂扮殑灏忎簬鍗佷簩閬嶅巻鍏ㄩ儴' + b);
+ }
+ }
}
+ }
+
+ //鍥涜垗浜斿叆
+ c = (a + b) / 12;
+
+ if (c > 1) {
+ x = Integer.valueOf(c.round(System.RoundingMode.HALF_UP));
+ xMap.put(res, x);
+ } else if (c > 0) {
+ x = 1;
+ xMap.put(res, x);
+ }
+ //x = Integer.valueOf(c.round(System.RoundingMode.Up));
+ //x = Integer.valueOf(c.round(System.RoundingMode.HALF_UP));
+
+ System.debug('鏂�' + b);
+ System.debug('鏃�' + a);
+ System.debug('闄ゆ硶瓒砪' + c);
+ System.debug('鍥涜垗浜斿叆x' + x);
+ }
+ //鏈堥攢閲忎笉瓒�12涓湀
+ else {
+ Decimal a = 0, b = 0;
+ for (ProductMonthlySales__c oms : msMap.get(res)) {
+ a += oms.MonthSales__c;
+ }
+ if (msMap.get(matMap.get(res)) != null) {
+ for (ProductMonthlySales__c nms : msMap.get(matMap.get(res))) {
+ b += nms.MonthSales__c;
+ }
+ }
+ c = (a + b) / msMap.get(res).size();
+ //x = Integer.valueOf(c.round(System.RoundingMode.UP));
+ //x = Integer.valueOf(c.round(System.RoundingMode.HALF_UP));
+ if (c > 1) {
+ x = Integer.valueOf(c.round(System.RoundingMode.HALF_UP));
+ xMap.put(res, x);
+ } else if (c > 0) {
+ x = 1;
+ xMap.put(res, x);
+ }
+
+ System.debug('闄ゆ硶涓嶈冻12c' + c);
+ System.debug('鍥涜垗浜斿叆x' + x);
}
- if(pts.SFDA_Status__c == '鍋滄' && oldPts.SFDA_Status__c != '鍋滄'){
- pts.Estimated_ConsumptionDueDate__c = null;
+ if (x != 0) {
+ for (ProductMonthlySales__c dat : msMap.get(res)) {
+ Decimal m = 0;
+ if (dat.ProductM__r.StorageStatusNo__c != null) {
+ m = dat.ProductM__r.StorageStatusNo__c;
+ }
+ y = m / x;
+ y = y * 30;
+ }
}
+ //z = Integer.valueOf(y.round(System.RoundingMode.UP));
+ z = Integer.valueOf(y.round(System.RoundingMode.HALF_UP));
+ zMap.put(res, z);
+ System.debug('澶╂暟y' + y);
+ System.debug('鍥涜垗浜斿叆z' + z);
+ }
}
+ }
+
+ List<Product2> finList = new List<Product2>();
+ for (Id fin : oproList) {
+ Product2 fip = new Product2();
+ fip.Id = fin;
+ fip.CalMonthSalesFLG__c = false;
+
+ if (xMap.get(fin) != null) {
+ fip.Average_MonthSales__c = xMap.get(fin);
+ }
+
+ //20211020
+ if (zMap.get(fin) != null) {
+ if (zMap.get(fin) != 0) {
+ fip.Estimated_ConsumptionDueDate__c = Date.today()
+ .addDays(zMap.get(fin));
+ } else {
+ if (adateMap != null) {
+ Date adate = adateMap.get(fin);
+ fip.Estimated_ConsumptionDueDate__c = adate;
+ }
+ }
+ } else {
+ if (adateMap != null) {
+ Date adate = adateMap.get(fin);
+ fip.Estimated_ConsumptionDueDate__c = adate;
+ }
+ }
+ //20211020
+
+ finList.add(fip);
+ }
+ update finList;
+ }
+ }
+ //SFDC鍋滄棰勮 lt 20210914 add end
+
+ //SFDC鍋滄棰勮 lt 20211015 add start
+ //ProductMonthlySalesFlag__c 12鏈堥攢閲忔爣璇� 棰勮鍋滄鏃ユ湡(M_BC_Stop_manufacure__c)鍙樺寲鏃�
+ // private static void FlgStopManufacure(List<Product2> newList,Map<Id, Product2> oldMap){
+ // if(newList != null){
+ // for(Product2 pts : newList){
+ // if(oldMap != null){
+ // if(pts.M_BC_Stop_manufacure__c != null && oldMap.get(pts.Id).M_BC_Stop_manufacure__c == null){
+ // pts.ProductMonthlySalesFlag__c = true;
+ // }
+ // if(pts.M_BC_Stop_manufacure__c != null && oldMap.get(pts.Id).M_BC_Stop_manufacure__c != null && pts.M_BC_Stop_manufacure__c != oldMap.get(pts.Id).M_BC_Stop_manufacure__c){
+ // pts.ProductMonthlySalesFlag__c = true;
+ // }
+ // if(pts.M_BC_Stop_manufacure__c == null && oldMap.get(pts.Id).M_BC_Stop_manufacure__c != null){
+ // pts.ProductMonthlySalesFlag__c = false;
+ // pts.Estimated_ConsumptionDueDate__c = null;
+ // }
+ // }
+ // }
+ // }
+
+ // }
+ //SFDC鍋滄棰勮 lt 20211015 add end
+ private void FlgStopManufacure() {
+ for (Product2 pts : newList) {
+ Product2 oldPts = oldMap.get(pts.Id);
+
+ if (pts.M_BC_Stop_manufacure__c != oldPts.M_BC_Stop_manufacure__c) {
+ pts.ProductMonthlySalesFlag__c = true;
+ if (pts.M_BC_Stop_manufacure__c == null) {
+ pts.ProductMonthlySalesFlag__c = false;
+ pts.Estimated_ConsumptionDueDate__c = null;
+ }
+ }
+
+ if (pts.SFDA_Status__c == '鍋滄' && oldPts.SFDA_Status__c != '鍋滄') {
+ pts.Estimated_ConsumptionDueDate__c = null;
+ }
+ }
+ }
+
+ //20230506 lt DB202304618804 鍖呭惈瓒呭0 start
+ private static void AssignmentUltrasonic(
+ List<Product2> newList,
+ Map<Id, Product2> oldMap
+ ) {
+ List<String> proIdList = new List<String>();
+ List<PCLLostProduct__c> updateplpList = new List<PCLLostProduct__c>();
+
+ for (Product2 pro : newList) {
+ if (
+ pro.RecordTypeId == System.Label.Pro_RecordType &&
+ (pro.Lost_Product_Differ__c !=
+ oldMap.get(pro.Id).Lost_Product_Differ__c ||
+ pro.Lost_Product_Category__c !=
+ oldMap.get(pro.Id).Lost_Product_Category__c)
+ ) {
+ proIdList.add(pro.Id);
+ }
}
- //20230506 lt DB202304618804 鍖呭惈瓒呭0 start
- private static void AssignmentUltrasonic(List<Product2> newList,Map<Id, Product2> oldMap){
- List<String> proIdList = new List<String>();
- List<PCLLostProduct__c> updateplpList = new List<PCLLostProduct__c>();
-
- for(Product2 pro : newList){
- if(pro.RecordTypeId == System.Label.Pro_RecordType &&
- (pro.Lost_Product_Differ__c != oldMap.get(pro.Id).Lost_Product_Differ__c ||
- pro.Lost_Product_Category__c != oldMap.get(pro.Id).Lost_Product_Category__c)){
- proIdList.add(pro.Id);
- }
- }
-
- List<PCLLostProduct__c> plpList = [Select Id, LostProduct__c, ProductClass__c, ProductCategory__c
- From PCLLostProduct__c
- Where LostProduct__c in: proIdList ];
- if(plpList.size() > 0 ){
- for(PCLLostProduct__c plp : plpList){
- plp.ProductClass__c = '涓绘満';
- plp.ProductCategory__c = '瓒呭0涓绘満';
- updateplpList.add(plp);
- }
- }
-
- update updateplpList;
-
+ List<PCLLostProduct__c> plpList = [
+ SELECT Id, LostProduct__c, ProductClass__c, ProductCategory__c
+ FROM PCLLostProduct__c
+ WHERE LostProduct__c IN :proIdList
+ ];
+ if (plpList.size() > 0) {
+ for (PCLLostProduct__c plp : plpList) {
+ plp.ProductClass__c = '涓绘満';
+ plp.ProductCategory__c = '瓒呭0涓绘満';
+ updateplpList.add(plp);
+ }
}
- //20230506 lt DB202304618804 鍖呭惈瓒呭0 end
-}
\ No newline at end of file
+ update updateplpList;
+ }
+ //20230506 lt DB202304618804 鍖呭惈瓒呭0 end
+}
diff --git a/force-app/main/default/classes/RentalApplyEquipmentSetDetailHandler.cls b/force-app/main/default/classes/RentalApplyEquipmentSetDetailHandler.cls
index 0c730b4..1187abe 100644
--- a/force-app/main/default/classes/RentalApplyEquipmentSetDetailHandler.cls
+++ b/force-app/main/default/classes/RentalApplyEquipmentSetDetailHandler.cls
@@ -1,4643 +1,2358 @@
public without sharing class RentalApplyEquipmentSetDetailHandler extends Oly_TriggerHandler {
- private Map<Id, Rental_Apply_Equipment_Set_Detail__c> newMap;
- private Map<Id, Rental_Apply_Equipment_Set_Detail__c> oldMap;
- private List<Rental_Apply_Equipment_Set_Detail__c> newList;
- private List<Rental_Apply_Equipment_Set_Detail__c> oldList;
- private static final Map<String,Schema.RecordTypeInfo> DEVELOPERNAMEMAP = Schema.SObjectType.Rental_Apply__c.getRecordTypeInfosByDeveloperName();//璁板綍绫诲瀷 20201119 ljh add
- //Rental_Apply_Equipment_Set_Detail__c 鏇存柊銇欍倠鏅傘伀Asset銈傛洿鏂般仚銈嬪彲鑳芥�с亴銇傘倞銇俱仚銇仹锛屻亾銇撱仹staticMap銈掍綔鎴愩仐siAsset銈掔祼闆嗐仐銇俱仚
- private static Map<Id, Asset> assMap = new Map<Id, Asset>(); // new Only
- // 涓婃灦鐨勬椂鍊欎繚鏈夎澶囩殑鍊熷嚭鍒嗛厤鏁颁細-1,浣嗘槸涓讳綋鐨勮瘽鏈夊彲鑳戒細鏆傚畾鍒嗛厤銆傝繖鏃跺�欏氨浼氭湁鏇存柊浜嗕袱鏉℃槑缁�,浣嗘槸鏇存柊鐨勪繚鏈夎澶囨槸鍚屼竴鏉$殑鎯呭喌(鏆傚畾鍒嗛厤鎺ヨЕ鍒嗛厤鏁伴噺闇�瑕�+1)
- // 鍥犱负鏆傚畾鍒嗛厤鐨勬椂鍊欏�熷嚭鍒嗛厤涔﹂渶瑕佸啀鍘熸潵鐨勪笂鏋�-1鍚庣殑鍩虹涓�+1鎵�浠ヤ笂鏋舵椂鍊欎繚鏈夎澶囩殑鎺ヨЕ鍒嗛厤鏁伴渶瑕佷繚瀛樺啀娆′娇鐢ㄣ��
- // 濡傛灉涓嶆槸Static涓婃灦鍚庡氨浼氭竻绌篴ssUpdMap,杩欐椂鍊欏氨浼氫娇鐢╝ssMap閲岀殑淇濇湁璁惧鏉ュ仛鏁伴噺鍔犲噺,铏界劧鍐嶆绱竴娆′繚鏈夎澶囧苟淇濆瓨鍒癮ssMap鐨勮瘽鏁版嵁浼氬緢骞插噣
- // 浣嗗洜涓篠OQL101鐨勯棶棰樺彂鐢熺殑鍑犵巼浼氬ぇ澶у鍔�,鎵�浠ssUpdMap杩樻槸浣跨敤闈欐�佸彉閲�
- private static Map<Id, Asset> assUpdMap = new Map<Id, Asset>(); // new 銇� old
- private static Set<Id> executeed_refreshQueueNumber = new Set<Id>(); // 宸茬粡澶勭悊杩囨帓闃熼『 Rental_Apply_Equipment_Set_Detail__c.Id
+ private Map<Id, Rental_Apply_Equipment_Set_Detail__c> newMap;
+ private Map<Id, Rental_Apply_Equipment_Set_Detail__c> oldMap;
+ private List<Rental_Apply_Equipment_Set_Detail__c> newList;
+ private List<Rental_Apply_Equipment_Set_Detail__c> oldList;
+ private static final Map<String, Schema.RecordTypeInfo> DEVELOPERNAMEMAP = Schema.SObjectType.Rental_Apply__c.getRecordTypeInfosByDeveloperName(); //璁板綍绫诲瀷 20201119 ljh add
+ //Rental_Apply_Equipment_Set_Detail__c 鏇存柊銇欍倠鏅傘伀Asset銈傛洿鏂般仚銈嬪彲鑳芥�с亴銇傘倞銇俱仚銇仹锛屻亾銇撱仹staticMap銈掍綔鎴愩仐siAsset銈掔祼闆嗐仐銇俱仚
+ private static Map<Id, Asset> assMap = new Map<Id, Asset>(); // new Only
+ // 涓婃灦鐨勬椂鍊欎繚鏈夎澶囩殑鍊熷嚭鍒嗛厤鏁颁細-1,浣嗘槸涓讳綋鐨勮瘽鏈夊彲鑳戒細鏆傚畾鍒嗛厤銆傝繖鏃跺�欏氨浼氭湁鏇存柊浜嗕袱鏉℃槑缁�,浣嗘槸鏇存柊鐨勪繚鏈夎澶囨槸鍚屼竴鏉$殑鎯呭喌(鏆傚畾鍒嗛厤鎺ヨЕ鍒嗛厤鏁伴噺闇�瑕�+1)
+ // 鍥犱负鏆傚畾鍒嗛厤鐨勬椂鍊欏�熷嚭鍒嗛厤涔﹂渶瑕佸啀鍘熸潵鐨勪笂鏋�-1鍚庣殑鍩虹涓�+1鎵�浠ヤ笂鏋舵椂鍊欎繚鏈夎澶囩殑鎺ヨЕ鍒嗛厤鏁伴渶瑕佷繚瀛樺啀娆′娇鐢ㄣ��
+ // 濡傛灉涓嶆槸Static涓婃灦鍚庡氨浼氭竻绌篴ssUpdMap,杩欐椂鍊欏氨浼氫娇鐢╝ssMap閲岀殑淇濇湁璁惧鏉ュ仛鏁伴噺鍔犲噺,铏界劧鍐嶆绱竴娆′繚鏈夎澶囧苟淇濆瓨鍒癮ssMap鐨勮瘽鏁版嵁浼氬緢骞插噣
+ // 浣嗗洜涓篠OQL101鐨勯棶棰樺彂鐢熺殑鍑犵巼浼氬ぇ澶у鍔�,鎵�浠ssUpdMap杩樻槸浣跨敤闈欐�佸彉閲�
+ private static Map<Id, Asset> assUpdMap = new Map<Id, Asset>(); // new 銇� old
+ private static Set<Id> executeed_refreshQueueNumber = new Set<Id>(); // 宸茬粡澶勭悊杩囨帓闃熼『 Rental_Apply_Equipment_Set_Detail__c.Id
- private static Set<Id> shipment_requestedRaIdSet = new Set<Id>();
- private static Set<Id> shipment_requestedRaIdStaticSet = new Set<Id>();
+ private static Set<Id> shipment_requestedRaIdSet = new Set<Id>();
+ private static Set<Id> shipment_requestedRaIdStaticSet = new Set<Id>();
- public RentalApplyEquipmentSetDetailHandler() {
- Integer i = 0;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- i ++;
- if (Trigger.isUpdate || Trigger.isUndelete || Trigger.isDelete) {
- this.newMap = new Map<Id, Rental_Apply_Equipment_Set_Detail__c>();
- this.newList = new List<Rental_Apply_Equipment_Set_Detail__c>();
- this.oldMap = (Map<Id, Rental_Apply_Equipment_Set_Detail__c>) Trigger.oldMap;
- this.oldList = (List<Rental_Apply_Equipment_Set_Detail__c>) Trigger.old;
- // 澶у墠鎻� Fixture_Set__c 銇с仚銇屼笅瑷樸伄灞炴�с亴瑷畾銇曘倢銇︺亜銇俱仚
- // 鍙傜収闁總銇惈銇俱倢銈嬪弬鐓с儸銈炽兗銉夈伅鍓婇櫎銇с亶銇俱仜銈撱��
- if (Trigger.isUpdate || Trigger.isUndelete) {
- for (SObject nSObj : Trigger.new) {
- Rental_Apply_Equipment_Set_Detail__c nObj = (Rental_Apply_Equipment_Set_Detail__c) nSObj;
- Rental_Apply_Equipment_Set_Detail__c oObj = null;
- if (Trigger.isUpdate) {
- oObj = oldMap.get(nObj.Id);
- }
- if (Trigger.isUndelete && String.isBlank(nObj.Fixture_Set_Id__c)) {
- // 鏃с儑銉笺偪銆乥eipin2 銇� trigger 瀹熻銇椼仾銇�
- continue;
- }
- else if (Trigger.isUpdate && String.isBlank(nObj.Fixture_Set_Id__c)
- && String.isNotBlank(oObj.Fixture_Set_Id__c)) {
- nObj.addError('涓嶈兘娓呯┖鍊熷嚭澶囧搧閰嶅 Fixture_Set__c');
- }
- else if (Trigger.isUpdate && String.isNotBlank(nObj.DeliverySlip__c)
- && String.isNotBlank(oObj.DeliverySlip__c) && oObj.DeliverySlip__c != nObj.DeliverySlip__c) {
- nObj.addError('涓嶈兘淇敼鍊熷嚭澶囧搧閰嶅鏄庣粏鐨勮繍杈撳崟');
- }
- else if (Trigger.isUpdate && String.isNotBlank(nObj.Return_DeliverySlip__c )
- && String.isNotBlank(oObj.Return_DeliverySlip__c ) && oObj.Return_DeliverySlip__c != nObj.Return_DeliverySlip__c ) {
- nObj.addError('涓嶈兘淇敼鍊熷嚭澶囧搧閰嶅鏄庣粏鐨勫洖瀵勮繍杈撳崟');
- }
- else {
- this.newList.add(nObj);
- this.newMap.put(nObj.Id, nObj);
- }
- }
- }
+ public RentalApplyEquipmentSetDetailHandler() {
+ if (Trigger.isUpdate || Trigger.isUndelete || Trigger.isDelete) {
+ this.newMap = new Map<Id, Rental_Apply_Equipment_Set_Detail__c>();
+ this.newList = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ this.oldMap = (Map<Id, Rental_Apply_Equipment_Set_Detail__c>) Trigger.oldMap;
+ this.oldList = (List<Rental_Apply_Equipment_Set_Detail__c>) Trigger.old;
+ // 澶у墠鎻� Fixture_Set__c 銇с仚銇屼笅瑷樸伄灞炴�с亴瑷畾銇曘倢銇︺亜銇俱仚
+ // 鍙傜収闁總銇惈銇俱倢銈嬪弬鐓с儸銈炽兗銉夈伅鍓婇櫎銇с亶銇俱仜銈撱��
+ if (Trigger.isUpdate || Trigger.isUndelete) {
+ for (SObject nSObj : Trigger.new) {
+ Rental_Apply_Equipment_Set_Detail__c nObj = (Rental_Apply_Equipment_Set_Detail__c) nSObj;
+ Rental_Apply_Equipment_Set_Detail__c oObj = null;
+ if (Trigger.isUpdate) {
+ oObj = oldMap.get(nObj.Id);
+ }
+ if (Trigger.isUndelete && String.isBlank(nObj.Fixture_Set_Id__c)) {
+ // 鏃с儑銉笺偪銆乥eipin2 銇� trigger 瀹熻銇椼仾銇�
+ continue;
+ } else if (
+ Trigger.isUpdate &&
+ String.isBlank(nObj.Fixture_Set_Id__c) &&
+ String.isNotBlank(oObj.Fixture_Set_Id__c)
+ ) {
+ nObj.addError('涓嶈兘娓呯┖鍊熷嚭澶囧搧閰嶅 Fixture_Set__c');
+ } else if (
+ Trigger.isUpdate &&
+ String.isNotBlank(nObj.DeliverySlip__c) &&
+ String.isNotBlank(oObj.DeliverySlip__c) &&
+ oObj.DeliverySlip__c != nObj.DeliverySlip__c
+ ) {
+ //nObj.addError('涓嶈兘淇敼鍊熷嚭澶囧搧閰嶅鏄庣粏鐨勮繍杈撳崟');
+ } else if (
+ Trigger.isUpdate &&
+ String.isNotBlank(nObj.Return_DeliverySlip__c) &&
+ String.isNotBlank(oObj.Return_DeliverySlip__c) &&
+ oObj.Return_DeliverySlip__c != nObj.Return_DeliverySlip__c
+ ) {
+ nObj.addError('涓嶈兘淇敼鍊熷嚭澶囧搧閰嶅鏄庣粏鐨勫洖瀵勮繍杈撳崟');
+ } else {
+ this.newList.add(nObj);
+ this.newMap.put(nObj.Id, nObj);
+ }
}
- else {
- // insert
- this.newMap = (Map<Id, Rental_Apply_Equipment_Set_Detail__c>) Trigger.newMap;
- this.oldMap = (Map<Id, Rental_Apply_Equipment_Set_Detail__c>) Trigger.oldMap;
- this.newList = (List<Rental_Apply_Equipment_Set_Detail__c>) Trigger.new;
- this.oldList = (List<Rental_Apply_Equipment_Set_Detail__c>) Trigger.old;
- }
+ }
+ } else {
+ // insert
+ this.newMap = (Map<Id, Rental_Apply_Equipment_Set_Detail__c>) Trigger.newMap;
+ this.oldMap = (Map<Id, Rental_Apply_Equipment_Set_Detail__c>) Trigger.oldMap;
+ this.newList = (List<Rental_Apply_Equipment_Set_Detail__c>) Trigger.new;
+ this.oldList = (List<Rental_Apply_Equipment_Set_Detail__c>) Trigger.old;
}
- public static Boolean disabled = false;
- protected override void beforeInsert() {
- if(!disabled){
- beforeSetValue();
- }
+ }
+ public static Boolean disabled = false;
+ // 澶囧搧浼樺寲杩藉姞 20230518 lc Start
+ public static Boolean skipUpdateAgain = false;
+ // 澶囧搧浼樺寲杩藉姞 20230518 lc End
+ protected override void beforeInsert() {
+ if (!disabled) {
+ beforeSetValue();
}
- protected override void beforeUpdate() {
- if(!disabled){
- beforeSetValue();
+ }
+ protected override void beforeUpdate() {
+ if (!disabled && !FixtureUtil.isRepairRenewal) {
+ beforeSetValue();
- // 璁惧�兼帓闃熺殑UniqueKey
- setUniqueKeyQueue();
- }
+ // 璁惧�兼帓闃熺殑UniqueKey
+ setUniqueKeyQueue();
}
- protected override void afterInsert() {
- if(!disabled){
- formulaToTextCheck();
- //鍏ュ姏瑕忓墖 鏂板缓鏁版嵁涓嶈兘鍒嗛厤銇屻亗銈娿伨銇欍伄銇э紝銇撱亾銇с伅Last銇∣ut_of_wh__c銇ō瀹氬繀瑕併亗銈娿伨銇涖倱
+ }
+ protected override void afterInsert() {
+ if (!disabled && !FixtureUtil.isRepairRenewal) {
+ formulaToTextCheck();
+ //鍏ュ姏瑕忓墖 鏂板缓鏁版嵁涓嶈兘鍒嗛厤銇屻亗銈娿伨銇欍伄銇э紝銇撱亾銇с伅Last銇∣ut_of_wh__c銇ō瀹氬繀瑕併亗銈娿伨銇涖倱
- Set<Id> raesdAssignSet = new Set<Id>();
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- if (nObj.Select_Time__c != null) {
- if (String.isNotBlank(nObj.Rental_Apply__c)) {
- raesdAssignSet.add(nObj.Rental_Apply__c);
- }
- }
- }
- if (raesdAssignSet.size() > 0) {
- // 璁剧疆鍒嗛厤浜�
- setAssginPerson(raesdAssignSet);
- }
- // 鍔炰簨澶勬柊寤哄凡鍒嗛厤鏄庣粏鏃舵墽琛�
- afterInsertAgencyAssignedDetail();
- if(!assUpdMap.isEmpty()) {
- update assUpdMap.values();
- }
+ Set<Id> raesdAssignSet = new Set<Id>();
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ if (nObj.Select_Time__c != null) {
+ if (String.isNotBlank(nObj.Rental_Apply__c)) {
+ raesdAssignSet.add(nObj.Rental_Apply__c);
+ }
}
+ }
+ if (raesdAssignSet.size() > 0) {
+ // 璁剧疆鍒嗛厤浜�
+ setAssginPerson(raesdAssignSet);
+ }
+ // 鍔炰簨澶勬柊寤哄凡鍒嗛厤鏄庣粏鏃舵墽琛�
+ afterInsertAgencyAssignedDetail();
+ if (!assUpdMap.isEmpty()) {
+ update assUpdMap.values();
+ }
}
- protected override void afterDelete() {
- // OLY_OCM-1189 杩藉姞鍒犻櫎Check
- deleteCheck();
- deleteReFirst();
- //鎺掗槦椤烘湁鍙樺寲鐨勬椂鍊欓噸鏂拌缃帓闃熼『
- // reQueueNumber();
- //added by denny
- reQueueAndSequence();
- // 鍔炰簨澶勫垹闄ゅ凡鍒嗛厤鏄庣粏鏃舵墽琛�
- afterDeleteAgencyAssignedDetail();
- if(!assUpdMap.isEmpty()) {
- update assUpdMap.values();
- }
+ }
+ protected override void afterDelete() {
+ // OLY_OCM-1189 杩藉姞鍒犻櫎Check
+ deleteCheck();
+ deleteReFirst();
+ //鎺掗槦椤烘湁鍙樺寲鐨勬椂鍊欓噸鏂拌缃帓闃熼『
+ // reQueueNumber();
+ //added by denny
+ reQueueAndSequence();
+ // 鍔炰簨澶勫垹闄ゅ凡鍒嗛厤鏄庣粏鏃舵墽琛�
+ afterDeleteAgencyAssignedDetail();
+ if (!assUpdMap.isEmpty()) {
+ update assUpdMap.values();
}
- protected override void afterUpdate() {
- if(!disabled){
- Set<Id> assIds = new Set<Id>();
- for (Rental_Apply_Equipment_Set_Detail__c raesd : newList) {
- if (String.isNotBlank(raesd.Asset__c)) {
- assIds.add(raesd.Asset__c);
- }
- }
- if (Trigger.isUpdate && !assIds.isEmpty()) {
- assMap = new Map<Id, Asset>([
- Select Id, Quantity, Status, Manage_type__c,
- Out_of_wh__c, Rental_Count__c, Abandoned_Inventory__c, Abandoned_RealThing__c,
- Confirm_Lost_Count__c, CountForRepair__c
- From Asset
- Where Id =: assIds
- and Asset_loaner_category__c != '鑰楁潗'
- and RecordTypeId = '01210000000kOPR'
- FOR UPDATE]);
- }
- // 澶囧搧鏁伴噺鐨勫姞鍑�
- changeAsset();
- System.debug(LoggingLevel.INFO, '*00** assUpdMap: ' + JSON.serialize(assUpdMap));
- // 鎺掗槦鍐嶅垎閰� 鍊熷嚭鍒嗛厤鏁伴噺鐨勫噺 绛�, clear Last_Reserve_RAES_Detail__c, 瑷畾First_RAESD__c
- clearLastReserveRAESD();
- System.debug(LoggingLevel.INFO, '*11** assUpdMap: ' + JSON.serialize(assUpdMap));
- //Asset鍙樻洿鐨勬椂鍊� 鏇存柊Asset鐨� Last_Reserve_RAES_Detail__c
- changeAssetLast();
- System.debug(LoggingLevel.INFO, '*22** assUpdMap: ' + JSON.serialize(assUpdMap));
- // Asset.Out_of_wh__c+ -
- changeAssetCount();
- System.debug(LoggingLevel.INFO, '*33* assUpdMap: ' + JSON.serialize(assUpdMap));
- // change Consumable_Guaranteen_end__c OLY_OCM-601
- changeAssetConsumable_Guaranteen_end();
- System.debug(LoggingLevel.INFO, '*44** assUpdMap: ' + JSON.serialize(assUpdMap));
- // 鍚屻仒block 銇� 鎺掗槦銉偝銉笺儔 Queue_Number__c 銈抮efresh
- // refreshQueueNumberByBlock();
- if (!assUpdMap.isEmpty()) {
- System.debug(LoggingLevel.INFO, '*----** assUpdMap: ' + JSON.serialize(assUpdMap));
- update assUpdMap.values();
- }
- // 4-XX 鐨� 涓�瀵逛竴瀵瑰簲
- oneToOne4XX();
- // 銈儯銉炽偦銉偝銉斻兗, 涓�瑙堝崟浣嶅彇娑堝悗鐨勬嫹璐濆湪涓�瑙堢殑Handler閲岄潰鍋�
- cancelCopy();
- // before 銇с伅鏁板紡闋呯洰銇宯ull銇牬鍚堛亴銇傘倞銇俱仚
- formulaToTextCheck();
- // 涓嬩竴娆″�熺敤棰勮鍑哄簱鏃堕棿 鍥炴敹鍚�-妫�娴嬬粨鏋淥K 2021117 ljh
- NextShippmentDate();
- NextShippmentDate_out();
- // 鍏佽鎻掗槦閭欢 20211125 ljh
- setToRa_Email_Text();
- //鎺掗槦椤烘湁鍙樺寲鐨勬椂鍊欓噸鏂拌缃帓闃熼『
- // reQueueNumber();
- //鎺掗槦鏂伴�昏緫
- //added by denny
- reQueueAndSequence();
- //鐢宠鑰呮敹鍥濶G鍚庢槑缁嗗洖瀵勬椂鐨勯偖浠跺洖瀵勫崟鍐呭璁剧疆
- receivedConfirmNGSetReturnDeliverySlipText();
- Set<Id> raesdSet = new Set<Id>();
- Set<Id> raesdAssignSet = new Set<Id>();
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
- if (String.isBlank(oObj.Return_DeliverySlip__c) && String.isNotBlank(nObj.Return_DeliverySlip__c)) {
- raesdSet.add(nObj.Id);
- }
- if (nObj.Select_Time__c != null && oObj.Select_Time__c == null) {
- raesdAssignSet.add(nObj.Rental_Apply__c);
- }
- }
- System.debug(raesdSet);
- if (raesdSet.size() > 0) {
- // 璁剧疆鍥炲瘎閫氱煡鍐呭
- RentalApplyEquipmentSetDetailHandler.setRequestAsset_return_Text(raesdSet);
- }
-
- if (raesdAssignSet.size() > 0) {
- // 璁剧疆鍒嗛厤浜�
- setAssginPerson(raesdAssignSet);
- }
-
- // 璁剧疆鑰楁潗鐨勫鍝佹帴瑙︾敵璇峰嚭搴撴寚绀洪偖浠跺彂閫佹椂闂�
- setConsumSend_Rental_Apply_EmailTime();
-
- //2021-12-20 mzy 澶囧搧浠诲姟 start
- // FinishRentalTask(); // 20220121 鎺掗槦涓婄嚎
- //2021-12-20 mzy 澶囧搧浠诲姟 end
+ }
+ protected override void afterUpdate() {
+ if (!disabled && !FixtureUtil.isRepairRenewal) {
+ Set<Id> assIds = new Set<Id>();
+ for (Rental_Apply_Equipment_Set_Detail__c raesd : newList) {
+ if (String.isNotBlank(raesd.Asset__c)) {
+ assIds.add(raesd.Asset__c);
}
+ }
+ if (Trigger.isUpdate && !assIds.isEmpty()) {
+ assMap = new Map<Id, Asset>(
+ [
+ SELECT
+ Id,
+ Quantity,
+ Status,
+ Manage_type__c,
+ Out_of_wh__c,
+ Rental_Count__c,
+ Abandoned_Inventory__c,
+ Abandoned_RealThing__c,
+ Confirm_Lost_Count__c,
+ CountForRepair__c
+ FROM Asset
+ WHERE
+ Id = :assIds
+ AND Asset_loaner_category__c != '鑰楁潗'
+ AND RecordTypeId = '01210000000kOPR'
+ FOR UPDATE
+ ]
+ );
+ }
+ // 澶囧搧鏁伴噺鐨勫姞鍑�
+ changeAsset();
+ System.debug(
+ LoggingLevel.INFO,
+ '*00** assUpdMap: ' + JSON.serialize(assUpdMap)
+ );
+ // 鎺掗槦鍐嶅垎閰� 鍊熷嚭鍒嗛厤鏁伴噺鐨勫噺 绛�, clear Last_Reserve_RAES_Detail__c, 瑷畾First_RAESD__c
+ clearLastReserveRAESD();
+ System.debug(
+ LoggingLevel.INFO,
+ '*11** assUpdMap: ' + JSON.serialize(assUpdMap)
+ );
+ //Asset鍙樻洿鐨勬椂鍊� 鏇存柊Asset鐨� Last_Reserve_RAES_Detail__c
+ changeAssetLast();
+ System.debug(
+ LoggingLevel.INFO,
+ '*22** assUpdMap: ' + JSON.serialize(assUpdMap)
+ );
+ // Asset.Out_of_wh__c+ -
+ changeAssetCount();
+ System.debug(
+ LoggingLevel.INFO,
+ '*33* assUpdMap: ' + JSON.serialize(assUpdMap)
+ );
+ // change Consumable_Guaranteen_end__c OLY_OCM-601
+ changeAssetConsumable_Guaranteen_end();
+ System.debug(
+ LoggingLevel.INFO,
+ '*44** assUpdMap: ' + JSON.serialize(assUpdMap)
+ );
+ // 鍚屻仒block 銇� 鎺掗槦銉偝銉笺儔 Queue_Number__c 銈抮efresh
+ // refreshQueueNumberByBlock();
+ if (!assUpdMap.isEmpty()) {
+ System.debug(
+ LoggingLevel.INFO,
+ '*----** assUpdMap: ' + JSON.serialize(assUpdMap)
+ );
+ update assUpdMap.values();
+ }
+ // 4-XX 鐨� 涓�瀵逛竴瀵瑰簲
+ oneToOne4XX();
+ // 銈儯銉炽偦銉偝銉斻兗, 涓�瑙堝崟浣嶅彇娑堝悗鐨勬嫹璐濆湪涓�瑙堢殑Handler閲岄潰鍋�
+ cancelCopy();
+ // before 銇с伅鏁板紡闋呯洰銇宯ull銇牬鍚堛亴銇傘倞銇俱仚
+ formulaToTextCheck();
+ // 涓嬩竴娆″�熺敤棰勮鍑哄簱鏃堕棿 鍥炴敹鍚�-妫�娴嬬粨鏋淥K 2021117 ljh
+ NextShippmentDate();
+ NextShippmentDate_out();
+ // 鍏佽鎻掗槦閭欢 20211125 ljh
+ setToRa_Email_Text();
+ //鎺掗槦椤烘湁鍙樺寲鐨勬椂鍊欓噸鏂拌缃帓闃熼『
+ // reQueueNumber();
+ //鎺掗槦鏂伴�昏緫
+ //added by denny
+ reQueueAndSequence();
+ //鐢宠鑰呮敹鍥濶G鍚庢槑缁嗗洖瀵勬椂鐨勯偖浠跺洖瀵勫崟鍐呭璁剧疆
+ receivedConfirmNGSetReturnDeliverySlipText();
+ Set<Id> raesdSet = new Set<Id>();
+ Set<Id> raesdAssignSet = new Set<Id>();
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
+ if (
+ String.isBlank(oObj.Return_DeliverySlip__c) &&
+ String.isNotBlank(nObj.Return_DeliverySlip__c)
+ ) {
+ raesdSet.add(nObj.Id);
+ }
+ if (nObj.Select_Time__c != null && oObj.Select_Time__c == null) {
+ raesdAssignSet.add(nObj.Rental_Apply__c);
+ }
+ }
+ System.debug(raesdSet);
+ if (raesdSet.size() > 0) {
+ // 璁剧疆鍥炲瘎閫氱煡鍐呭
+ RentalApplyEquipmentSetDetailHandler.setRequestAsset_return_Text(
+ raesdSet
+ );
+ }
+
+ if (raesdAssignSet.size() > 0) {
+ // 璁剧疆鍒嗛厤浜�
+ setAssginPerson(raesdAssignSet);
+ }
+
+ // 璁剧疆鑰楁潗鐨勫鍝佹帴瑙︾敵璇峰嚭搴撴寚绀洪偖浠跺彂閫佹椂闂�
+ setConsumSend_Rental_Apply_EmailTime();
+
+ //2021-12-20 mzy 澶囧搧浠诲姟 start
+ // FinishRentalTask(); // 20220121 鎺掗槦涓婄嚎
+ //2021-12-20 mzy 澶囧搧浠诲姟 end
}
- private Map<Id, Asset> createAssetMap() {
- Set<Id> assIds = new Set<Id>();
- String ra_RecordTypeId = DEVELOPERNAMEMAP.get('AgencyRequest').getRecordTypeId();
- List<Rental_Apply_Equipment_Set_Detail__c> objList = new List<Rental_Apply_Equipment_Set_Detail__c>();
- if(Trigger.isInsert) {
- objList = newList;
- }
- else {
- objList = oldList;
- }
- for (Rental_Apply_Equipment_Set_Detail__c obj : objList) {
- if(ra_RecordTypeId != null
- && obj.RA_RecordTypeId__c.substring(0,15) == ra_RecordTypeId.substring(0,15)
- && obj.Asset__c != null && obj.Select_Time__c != null
- && (Trigger.isDelete || Trigger.isInsert)) {
- assIds.add(obj.Asset__c);
- }
- }
- Map<Id, Asset> m = new Map<Id, Asset>();
- if (!assIds.isEmpty()) {
- m = new Map<Id, Asset>([
- Select Id, Quantity, Status, Manage_type__c,
- Out_of_wh__c, Rental_Count__c, Abandoned_Inventory__c, Abandoned_RealThing__c,
- Confirm_Lost_Count__c
- From Asset
- Where Id =: assIds
- and Asset_loaner_category__c != '鑰楁潗'
- and RecordTypeId = '01210000000kOPR'
- FOR UPDATE]);
- }
- return m;
+ }
+ private Map<Id, Asset> createAssetMap() {
+ Set<Id> assIds = new Set<Id>();
+ String ra_RecordTypeId = DEVELOPERNAMEMAP.get('AgencyRequest')
+ .getRecordTypeId();
+ List<Rental_Apply_Equipment_Set_Detail__c> objList = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ if (Trigger.isInsert) {
+ objList = newList;
+ } else {
+ objList = oldList;
}
- private void afterInsertAgencyAssignedDetail() {
- // 鍔炰簨澶勬柊寤哄凡鍒嗛厤鏄庣粏鏃舵墽琛�
- assMap = createAssetMap();
- if(!assMap.isEmpty()) {
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- if(assMap.containsKey(nObj.Asset__c)) {
- Asset ass = assMap.get(nObj.Asset__c);
- if(ass.Manage_type__c == '涓綋绠$悊'){
- ass.Last_Reserve_RAES_Detail__c = nObj.Id;
- }
- if(ass.Out_of_wh__c == null) {
- ass.Out_of_wh__c = 1;
- }
- else {
- ass.Out_of_wh__c += 1;
- }
- assUpdMap.put(ass.Id, ass);
- }
- }
- }
+ for (Rental_Apply_Equipment_Set_Detail__c obj : objList) {
+ if (
+ ra_RecordTypeId != null &&
+ obj.RA_RecordTypeId__c.substring(0, 15) ==
+ ra_RecordTypeId.substring(0, 15) &&
+ obj.Asset__c != null &&
+ obj.Select_Time__c != null &&
+ (Trigger.isDelete || Trigger.isInsert)
+ ) {
+ assIds.add(obj.Asset__c);
+ }
}
- private void afterDeleteAgencyAssignedDetail() {
- // 鍔炰簨澶勫垹闄ゅ凡鍒嗛厤鏄庣粏鏃舵墽琛�
- assMap = createAssetMap();
- if(!assMap.isEmpty()) {
- for (Rental_Apply_Equipment_Set_Detail__c oObj : oldList) {
- if(assMap.containsKey(oObj.Asset__c)) {
- Asset ass = assMap.get(oObj.Asset__c);
- if(ass.Manage_type__c == '涓綋绠$悊') {
- ass.Last_Reserve_RAES_Detail__c = null;
- }
- if(ass.Out_of_wh__c != null) {
- ass.Out_of_wh__c -= 1;
- }
- assUpdMap.put(ass.Id, ass);
- }
- }
- }
+ Map<Id, Asset> m = new Map<Id, Asset>();
+ if (!assIds.isEmpty()) {
+ m = new Map<Id, Asset>(
+ [
+ SELECT
+ Id,
+ Quantity,
+ Status,
+ Manage_type__c,
+ Out_of_wh__c,
+ Rental_Count__c,
+ Abandoned_Inventory__c,
+ Abandoned_RealThing__c,
+ Confirm_Lost_Count__c
+ FROM Asset
+ WHERE
+ Id = :assIds
+ AND Asset_loaner_category__c != '鑰楁潗'
+ AND RecordTypeId = '01210000000kOPR'
+ FOR UPDATE
+ ]
+ );
}
-
- private void deleteCheck() {
- String ra_RecordTypeId = DEVELOPERNAMEMAP.get('AgencyRequest').getRecordTypeId();
- for (Rental_Apply_Equipment_Set_Detail__c oObj : oldList) {
- if (
- (oObj.RA_RecordTypeId__c.substring(0,15) != ra_RecordTypeId.substring(0,15)
- &&(oObj.Rental_Apply_Request_approval_time_F__c != null
- && oObj.ApplyPersonAppended_F__c == false)
- || (oObj.ApplyPersonAppended_F__c == true && oObj.Add_Request_approval_time__c != null)
- )
- || (oObj.RA_RecordTypeId__c.substring(0,15) == ra_RecordTypeId.substring(0,15)
- && (oObj.Rental_Apply_Request_approval_time_F__c != null
- && (oObj.Rental_Apply_CreatedDate_F__c > oObj.CreatedDate
- || oObj.StockDown__c == true)
- && !oObj.canDelete__c //20210523 ljh add 1829
- )
- )
- ) {
- oObj.addError('宸茬粡鎵瑰噯鐨勫鍝佸�熷嚭鏄庣粏涓嶈兘鍋氱墿鐞嗗垹闄ゃ��');
- }
+ return m;
+ }
+ private void afterInsertAgencyAssignedDetail() {
+ // 鍔炰簨澶勬柊寤哄凡鍒嗛厤鏄庣粏鏃舵墽琛�
+ assMap = createAssetMap();
+ if (!assMap.isEmpty()) {
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ if (assMap.containsKey(nObj.Asset__c)) {
+ Asset ass = assMap.get(nObj.Asset__c);
+ if (ass.Manage_type__c == '涓綋绠$悊') {
+ ass.Last_Reserve_RAES_Detail__c = nObj.Id;
+ }
+ if (ass.Out_of_wh__c == null) {
+ ass.Out_of_wh__c = 1;
+ } else {
+ ass.Out_of_wh__c += 1;
+ }
+ assUpdMap.put(ass.Id, ass);
}
+ }
}
-
- private void setConsumSend_Rental_Apply_EmailTime() {
- if (shipment_requestedRaIdSet.isEmpty() == false) {
- List<Consum_Apply__c> caList = [SELECT Id
- , Loaner_centre_mail_address__c
- FROM Consum_Apply__c
- WHERE Rental_Apply__c = :shipment_requestedRaIdSet];
- if (caList.size() > 0) {
- Datetime dt = Datetime.now();
- for (Consum_Apply__c ca : caList) {
- ca.Send_Rental_Apply_EmailTime__c = dt;
- }
- update caList;
- }
- shipment_requestedRaIdSet = new Set<Id>();
+ }
+ private void afterDeleteAgencyAssignedDetail() {
+ // 鍔炰簨澶勫垹闄ゅ凡鍒嗛厤鏄庣粏鏃舵墽琛�
+ assMap = createAssetMap();
+ if (!assMap.isEmpty()) {
+ for (Rental_Apply_Equipment_Set_Detail__c oObj : oldList) {
+ if (assMap.containsKey(oObj.Asset__c)) {
+ Asset ass = assMap.get(oObj.Asset__c);
+ if (ass.Manage_type__c == '涓綋绠$悊') {
+ ass.Last_Reserve_RAES_Detail__c = null;
+ }
+ if (ass.Out_of_wh__c != null) {
+ ass.Out_of_wh__c -= 1;
+ }
+ assUpdMap.put(ass.Id, ass);
}
+ }
}
+ }
- private void beforeSetValue() {
- Set<Id> raesdSet = new Set<Id>();
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- raesdSet.add(nObj.Rental_Apply_Equipment_Set__c);
- }
- Map<Id, Rental_Apply_Equipment_Set__c> raesdMap = new Map<Id, Rental_Apply_Equipment_Set__c>([Select Id, Fixture_Set__r.Name ,
- IndexFromUniqueKey__c
- From Rental_Apply_Equipment_Set__c
- Where Id =: raesdSet]);
- String agencyRecordTypeId = DEVELOPERNAMEMAP.get('AgencyRequest').getRecordTypeId();
-
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- //鍥犱负鏄疘nsert鏃跺�欒鍊� 鎯呭喌1锛岀敵璇锋柊寤轰細璁惧�� 鎯呭喌2锛孨G鎷疯礉鍑烘潵鐨勬椂鍊欎細璁惧��
- //鍥犱负UniqueKey__c鍒ゆ柇浜咲ataMigration_Flag__c鎵�浠ヨ繖閲屼篃闇�瑕佸垽鏂� 妫�绱㈢殑鏃跺�欏洜涓鸿鍋嘔nsert鎵�浠ヤ笉闇�瑕佽缃�
- // TODO bp3 DetailHandler閲�, 瀵笷SD璁惧�肩殑鍦版柟 闇�瑕佸湪Rental_Apply__c鐨凥andler閲�, 鍙樻垚鎵瑰噯鏅�, 涔熻璁惧�笺��
- if (Trigger.isInsert && nObj.DataMigration_Flag__c == false) {
- nObj.Is_Body__c = nObj.Is_Body_F__c;
- if (String.isNotBlank(nObj.Fixture_Set_Detail__c)) {
- nObj.FSD_Id__c = nObj.Fixture_Set_Detail__c;
- }
- // 272銉併偙銉冦儓
- // Create_State__c涓虹┖骞朵笖鐢宠涔︾殑鏍囧噯鎵瑰噯鏃堕棿涓嶄负绌虹殑鏃跺�欒缃负1
- // 1 --- 杩藉姞闄勫睘鍝�
- // 0 --- Cancel鎷疯礉
- // null --- 鏅�氭柊瑙�
- if (nObj.Create_State__c == null
- && nObj.Rental_Apply_Request_approval_time_F__c != null
- && nObj.Substitute_Select_Again__c == false // OLY_OCM-404 鍒嗛厤浠f浛鍝�
- // 鍔炰簨澶勫垎閰嶆椂杩藉姞鐨勬槑缁嗕笉绠楄拷鍔犻檮灞炲搧
- && nObj.RA_RecordTypeId__c.substring(0,15) != agencyRecordTypeId.substring(0,15)) {
- nObj.Create_State__c = 1;
- }
- nObj.FSD_Is_Optional__c = nObj.FSD_Is_Optional_F__c;
- // 鍔炰簨澶勫湪鍒嗛厤涓己鍒惰涓簍rue鏃讹紝涓嶄粠FSD鎷疯礉
- if(nObj.RA_RecordTypeId__c.substring(0,15) != agencyRecordTypeId.substring(0,15) || !nObj.FSD_Is_OneToOne__c) {
- nObj.FSD_Is_OneToOne__c = nObj.FSD_Is_OneToOne_F__c;
- }
- nObj.FSD_Name_CHN__c = nObj.Fixture_Name_F__c;
- nObj.FSD_OneToOneAccessory_Cnt__c = nObj.FSD_OneToOneAccessory_Cnt_F__c;
- nObj.FSD_Fixture_Model_No__c = nObj.Fixture_Model_No_F__c;
- if (nObj.DataMigration_Flag__c == false && (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))) {
- nObj.Fixture_Model_No_text__c = nObj.Fixture_Model_No_F__c;
- }
- nObj.CreatedBy_ProfileId__c = UserInfo.getProfileId();
-// nObj.ApplyPersonAppended__c = nObj.ApplyPersonAppended_F__c;
- }
- if (nObj.DeliverySlip__c != null
- && nObj.DataMigration_Flag__c == false && (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))) {
- if (nObj.Shippment_loaner_time__c == null) {
- nObj.Shippment_loaner_time__c = nObj.Shippment_loaner_time2__c;
- }
- }
- nObj.DeliverySlip_Text__c = nObj.DeliverySlip__c;
- nObj.Return_DeliverySlip_Text__c = nObj.Return_DeliverySlip__c;
- nObj.Received_Confirm_Text__c = nObj.Received_Confirm_F__c;
- Rental_Apply_Equipment_Set_Detail__c oObj = null;
- if (Trigger.isUpdate) {
- oObj = oldMap.get(nObj.Id);
- //鍑哄簱鍓嶆鏌G銇牬鍚堛偔銉c兂銈汇儷銇椼伨銇�
- if(oObj.Inspection_result__c != 'NG' && nObj.Inspection_result__c == 'NG') {
- nObj.Cancel_Select__c = true;
- nObj.Loaner_cancel_reason__c = '鍏朵粬';// 20210830 ljh SFDC-C448KZ add
- nObj.Cancel_Reason__c = '閲嶆柊鍒嗛厤';
- nObj.Loaner_cancel_Remarks__c = '鍑哄簱鍓嶆鏌G';
- }
- // OLY_OCM-435瀵惧繙 start
- String userid = UserInfo.getUserId();
- DateTime now = System.now();
- if (oObj.Inspection_result__c != nObj.Inspection_result__c && String.isNotBlank(nObj.Inspection_result__c)) {
- nObj.Pre_inspection_time__c = now;
- //20210428 ljh 1719 update start
- //nObj.Inspection_staff__c = userid;
- nObj.Inspection_staff__c = nObj.RA_RecordTypeId__c == Schema.SObjectType.Rental_Apply__c.getRecordTypeInfosByDeveloperName().get('AgencyRequest').getRecordTypeId() ?null:userid;
- //20210428 ljh 1719 update start
- }
-
- if (oObj.Check_lost_Item_Final__c != nObj.Check_lost_Item_Final__c && String.isNotBlank(nObj.Check_lost_Item_Final__c)) {
- nObj.Lost_item_check_time_Final__c = now;
- nObj.Lost_item_check_staff_Final__c = userid;
- }
-
- if (oObj.Check_lost_Item__c != nObj.Check_lost_Item__c && String.isNotBlank(nObj.Check_lost_Item__c)) {
- nObj.Lost_item_check_time__c = now;
- nObj.Lost_item_check_staff__c = userid;
- }
-
- if (oObj.CDS_complete__c != nObj.CDS_complete__c && nObj.CDS_complete__c) {
- nObj.CDS_complete_time__c = now;
- nObj.CDS_staff__c = userid;
- }
-
- if (oObj.Inspection_result_after_Final__c != nObj.Inspection_result_after_Final__c && String.isNotBlank(nObj.Inspection_result_after_Final__c)) {
- nObj.After_Inspection_time_Final__c = now;
- nObj.Inspection_staff_After_Final__c = userid;
- }
-
- if (oObj.Inspection_result_after__c != nObj.Inspection_result_after__c && String.isNotBlank(nObj.Inspection_result_after__c)) {
- // 妫�娴嬬粨鏋滄洿鏂颁簡浣嗘椂闂存病鏈夋墜鍔ㄦ洿鏂帮紝鍒欐洿鏂版椂闂�
- // 濡傛灉鎵嬪姩鏇存柊浜嗘椂闂达紝灏变笉鐢ㄥ啀鏇存柊
- if(oObj.After_Inspection_time__c == nObj.After_Inspection_time__c) {
- nObj.After_Inspection_time__c = now;
- }
- //20210716 ljh 1719 update start
- //nObj.Inspection_staff_After__c = userid;
- nObj.Inspection_staff_After__c = nObj.RA_RecordTypeId__c == Schema.SObjectType.Rental_Apply__c.getRecordTypeInfosByDeveloperName().get('AgencyRequest').getRecordTypeId() ?null:userid;
- //20210716 ljh 1719 update start
- }
- // OLY_OCM-435瀵惧繙 end
- if(nObj.Detail_Finish__c) {
- nObj.RAESD_Status_Text__c = nObj.Id;
- }
- else{
- nObj.RAESD_Status_Text__c = nObj.RAESD_Status__c;
- }
- }
- Rental_Apply_Equipment_Set__c raes = raesdMap.get(nObj.Rental_Apply_Equipment_Set__c);
- //鐢婚潰鏄剧ず鐢╟lone鍑烘潵鐨勬暟鎹笉闇�瑕佽缃甆ame
- //IndexFromUniqueKey__c.format()浼氭姤閿� 瑕佸垽涓嶆槸Null
- if (nObj.DataMigration_Flag__c == false
- && raes != null
- && String.isNotBlank(raes.Fixture_Set__r.Name)
- && raes.IndexFromUniqueKey__c != null
- && nObj.IndexFromUniqueKey__c != null
- && (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))) {
- String split_ApplyNum = nObj.RequestNoJoinStr2__c;
- if (nObj.Rental_Apply_r_Name__c.contains('_')) {
- // XXXX-YYYY_1 (ZZZZ_1)
- List<String> split_ApplyNumList = nObj.Rental_Apply_r_Name__c.split('_');
- String raName = split_ApplyNumList[split_ApplyNumList.size() - 2]; // XXXX-YYYY (ZZZZ)
- split_ApplyNum = split_ApplyNumList[split_ApplyNumList.size() - 1]; // 1
- split_ApplyNumList = raName.split('-'); // [XXXX, YYYY] ([ZZZZ])
- if (split_ApplyNumList.size() > 1) {
- // YYYY_1
- split_ApplyNum = split_ApplyNumList[split_ApplyNumList.size() - 1] + '_' + split_ApplyNum;
- } else {
- // ZZZZ_1
- split_ApplyNum = nObj.Rental_Apply_r_Name__c;
- }
- }
- nObj.Name = split_ApplyNum + ':' + raes.Fixture_Set__r.Name + ':'
- + raes.IndexFromUniqueKey__c.format().leftpad(3, '0');
-
- // 濡傛灉鏄垎閰嶄唬鏇垮搧鍚嶅瓧鍔�:Sub
- if (nObj.Substitute_Select_Again__c) {
- nObj.Name += ':Sub';
- }
-
- //涓�瑙堟椂鐢宠鑰呮敹璐G鐨勮瘽鍚嶅瓧娣诲姞NG
- if (nObj.Received_Confirm_F__c == 'NG') {
- nObj.Name += ':NG';
- }
- nObj.Name += ':' + nObj.IndexFromUniqueKey_Text__c + ':'
- + nObj.IndexFromUniqueKey__c.format().leftpad(3, '0');
- //鍙栨秷鐨勬椂鍊欏悕瀛楀姞Canceled
- if (nObj.Cancel_Select__c) {
- nObj.Name += ':Canceled';
- }
- }
- nObj.Loaner_accsessary__c = nObj.Loaner_accsessary_F__c;
- nObj.Loaner_centre_mail_address__c = nObj.Loaner_centre_mail_address_F__c;
- // 20220117 ljh add start
- // 鏇存柊鎺掗槦棰勮 鍏紡鎷锋枃鏈�
- if(Trigger.isUpdate && String.isBlank(nObj.Asset__c) == false && oObj.Asset__c != nObj.Asset__c){
- nObj.UQueueShippmentDateText__c = nObj.UQueueShippmentDate__c;
- }
- // 20220117 ljh add end
- // 鍒嗛厤鏃�, 璁惧��
- if (String.isBlank(nObj.Asset__c) == false && nObj.Select_Time__c != null
- && (Trigger.isInsert
- || (oObj.Asset__c != nObj.Asset__c || oObj.Select_Time__c != nObj.Select_Time__c)
- )
- ) {
- // 涓�瀵逛竴淇濈涓讳綋锛堝�熷嚭鏃讹級
- // nObj.Main_OneToOne_FlagInt__c = nObj.Main_OneToOne_FlagInt__c;
- if (nObj.DataMigration_Flag__c == false && (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))) {
- // 澶囧搧閰嶅鏄庣粏鍨嬪彿(鍊熷嚭鏃�)
- if (String.isBlank(nObj.Fixture_Model_No_F__c)) {
- nObj.addError('鍒嗛厤鐨凙sset:'+ nObj.Asset__c + ', 娌℃湁璁惧畾 澶囧搧閰嶅鏄庣粏鍨嬪彿');
- } else {
- nObj.Fixture_Model_No_text__c = nObj.Fixture_Model_No_F__c;
- }
- }
- // 鏈鸿韩缂栧彿锛堝�熷嚭鏃讹級
- nObj.SerialNumber_text__c = nObj.SerialNumber__c;
- // 鎵�鍦ㄥ湴鍖�(鐪�) 鍊熷嚭鏃� #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
- nObj.SalesProvince_before__c = nObj.SalesProvince__c;
- // 鎵�鍦ㄥ湴鍖�(鏈儴) 鍊熷嚭鏃� #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
- nObj.Salesdepartment_before__c = nObj.Salesdepartment__c;
- // 浜у搧鍒嗙被(GI/SP)(鍊熷嚭鏃�) #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
- nObj.Product_category_text__c = nObj.Product_category_F__c;
- // 澶囧搧鍒嗙被(鍊熷嚭鏃�) #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
- nObj.Equipment_Type_text__c = nObj.Equipment_Type_F__c;
- // 澶囧搧鎴愭湰(鍊熷嚭鏃�)
- nObj.Asset_cost_del_before__c = nObj.Asset_cost_del__c;
- // 澶囧搧瀛樻斁鍦�(鍊熷嚭鏃�)
- nObj.Internal_asset_location_before__c = nObj.Internal_asset_location__c;
- //澶囧搧鍚嶇О(鍊熷嚭鏃�)
- nObj.Fixture_Name_text__c = nObj.Fixture_Name_F__c;
- // OLY_OCM-243 杩藉姞瀛楁瀵瑰簲 澶囧搧绠$悊缂栫爜(鍊熷嚭鏃�)
- nObj.EquipmentSet_Managment_Code_text__c = nObj.EquipmentSet_Managment_Code__c;
- // OLY_OCM-452 杩藉姞瀛楁瀵瑰簲 鍒�澶�(鍊熷嚭鏃�)
- if (String.isNotBlank(nObj.Fixture_Set_Detail__c)) {
- nObj.Is_Special_Product_Text__c = nObj.Is_Special_Product__c;
- }
- }
- // 鎺掗槦鏃�, 瑕佹敞鎰� 璁惧�� 绉诲姩鍒版帓闃焍tn閲�
- else if (Trigger.isUpdate && String.isBlank(nObj.Asset__c) && oObj.Cancel_Select__c == false
- // && oObj.Fixture_Model_No_text__c != nObj.Fixture_Model_No_text__c
- && (oObj.Queue_Number__c == 0 || oObj.Queue_Number__c == null) && nObj.Queue_Number__c > 0
- ) {
- // 鎺掗槦鏃堕噸鏂拌祴鍊糉ixture_Model_No_text__c 涓轰簡鎺掔殑涓嶆槸鏃odel_No
- nObj.FSD_Fixture_Model_No__c = nObj.Fixture_Model_No_F__c;
- // 澶囧搧閰嶅鏄庣粏鍨嬪彿(鍊熷嚭鏃�)
- // nObj.Fixture_Model_No_text__c = nObj.Fixture_Model_No_F__c;
- // 鎵�鍦ㄥ湴鍖�(鐪�) 鍊熷嚭鏃�
- //nObj.SalesProvince_before__c = nObj.SalesProvince__c;
- // // 鎵�鍦ㄥ湴鍖�(鏈儴) 鍊熷嚭鏃�
- // nObj.Salesdepartment_before__c = nObj.Salesdepartment__c;
- // // 浜у搧鍒嗙被(GI/SP)(鍊熷嚭鏃�)
- // nObj.Product_category_text__c = nObj.Product_category_F__c;
- // // 澶囧搧鍒嗙被(鍊熷嚭鏃�)
- // nObj.Equipment_Type_text__c = nObj.Equipment_Type__c;
- // // 澶囧搧瀛樻斁鍦�(鍊熷嚭鏃�)
- // nObj.Internal_asset_location_before__c = nObj.Internal_asset_location__c;
- }
- // 鍏朵粬鏃跺��(鐢宠鏃�), null璁惧�� 鍜�
- // 涓�瀵逛竴宸插垎閰嶇殑闄勫睘鍝�,涓讳綋閲嶆柊鎺掗槦鏃�,涓�瀵逛竴闄勫睘鍝侀渶瑕侀噸鏂版寜鐓х敵璇风殑閫昏緫閲嶆柊璧嬪��
- else if ((Trigger.isInsert && nObj.Cancel_Select__c == false)
- || (Trigger.isUpdate && String.isBlank(nObj.Asset__c) && oObj.Cancel_Select__c == false)) {
- // 澶囧搧閰嶅鏄庣粏鍨嬪彿(鍊熷嚭鏃�)
- if (String.isBlank(nObj.Fixture_Model_No_text__c)
- && nObj.DataMigration_Flag__c == false && (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))) {
- nObj.Fixture_Model_No_text__c = nObj.Fixture_Model_No_F__c;
- }
- // 鎵�鍦ㄥ湴鍖�(鐪�) 鍊熷嚭鏃� #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
- if (String.isBlank(nObj.SalesProvince_before__c)) {
- nObj.SalesProvince_before__c = nObj.SalesProvince__c;
- }
- // 鎵�鍦ㄥ湴鍖�(鏈儴) 鍊熷嚭鏃� #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
- if (String.isBlank(nObj.Salesdepartment_before__c)) {
- nObj.Salesdepartment_before__c = nObj.Salesdepartment__c;
- }
- // 浜у搧鍒嗙被(GI/SP)(鍊熷嚭鏃�) #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
- if (String.isBlank(nObj.Product_category_text__c)) {
- nObj.Product_category_text__c = nObj.Product_category_F__c;
- }
- // 澶囧搧鍒嗙被(鍊熷嚭鏃�) #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
- if (String.isBlank(nObj.Equipment_Type_text__c)) {
- nObj.Equipment_Type_text__c = nObj.Equipment_Type__c;
- }
- // 澶囧搧瀛樻斁鍦�
- if (String.isBlank(nObj.Internal_asset_location_before__c)) {
- nObj.Internal_asset_location_before__c = nObj.Internal_asset_location__c;
- }
- // 澶囧搧鍚嶇О(鍊熷嚭鏃�)
- if (String.isBlank(nObj.Fixture_Name_text__c)) {
- nObj.Fixture_Name_text__c = nObj.Fixture_Name_F__c;
- }
- // OLY_OCM-243 杩藉姞瀛楁瀵瑰簲 澶囧搧绠$悊缂栫爜(鍊熷嚭鏃�)
- if (String.isBlank(nObj.EquipmentSet_Managment_Code_text__c)) {
- nObj.EquipmentSet_Managment_Code_text__c = nObj.EquipmentSet_Managment_Code__c;
- }
- // OLY_OCM-452 杩藉姞瀛楁瀵瑰簲 鍒�澶�(鍊熷嚭鏃�)
- if (String.isBlank(nObj.Is_Special_Product_Text__c)) {
- nObj.Is_Special_Product_Text__c = nObj.Is_Special_Product__c;
- }
- } else {
- // 鍙栨秷鐨勬儏鍐靛湪涓嬮潰鏈夎鍊�
- }
- if (nObj.DataMigration_Flag__c == false && nObj.Cancel_Select__c == false
- && (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))) {
- if (String.isBlank(nObj.Fixture_Model_No_text__c)) {
- nObj.addError(nObj.Id + ':澶囧搧閰嶅鏄庣粏鍨嬪彿涓嶈兘涓虹┖, 澶囧搧閰嶅鏄庣粏=' + nObj.Fixture_Set_Detail__c);
- }
-
- // #OLY_OCM-654 鏁伴噺绠$悊鐨勮瘽,鎵�鍦ㄥ湴鍖�(鏈儴)&浜у搧鍒嗙被&澶囧搧鍒嗙被鐨勫垽鏂笉闇�瑕� Start
- if ('鏁伴噺绠$悊' == nObj.Manage_type_F__c ) { // || false == nObj.Loaner_accsessary__c TODO: 闇�纭
- if (String.isBlank(nObj.Internal_asset_location_before__c)) {
- nObj.addError('澶囧搧瀛樻斁鍦颁笉鑳戒负绌�');
- }
- }
- else {
- // #OLY_OCM-654 鏁伴噺绠$悊鐨勮瘽,鎵�鍦ㄥ湴鍖�(鏈儴)&浜у搧鍒嗙被&澶囧搧鍒嗙被鐨勫垽鏂笉闇�瑕� end
- if (String.isBlank(nObj.Salesdepartment_before__c)) {
- nObj.addError('鎵�鍦ㄥ湴鍖�(鏈儴)涓嶈兘涓虹┖');
- }
- if (String.isBlank(nObj.Internal_asset_location_before__c)) {
- nObj.addError('澶囧搧瀛樻斁鍦颁笉鑳戒负绌�');
- }
- if (String.isBlank(nObj.Product_category_text__c) && nObj.Is_Body__c) {
- nObj.addError('浜у搧鍒嗙被(GI/SP)涓嶈兘涓虹┖');
- }
- if (String.isBlank(nObj.Equipment_Type_text__c) && nObj.Is_Body__c && nObj.Demo_purpose1__c != '鍏朵粬') {
- nObj.addError('澶囧搧鍒嗙被涓嶈兘涓虹┖');
- }
- // if (String.isBlank(nObj.SalesProvince_before__c) && nObj.Is_Body__c) {
- // nObj.addError('鎵�鍦ㄥ湴鍖�(鐪�)涓嶈兘涓虹┖');
- // }
- }
- }
- if (nObj.DataMigration_Flag__c == false
- && String.isNotBlank(nObj.FSD_Id__c)
- && (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))) {
- //鍑哄簱鎸囩ず鏇存柊鏄庣粏鐨刱ey
- nObj.UniqueKey__c = nObj.RequestNoJoinStr2__c + ':'+ nObj.Rental_Apply_Equipment_Set__c
- + ':' + nObj.FSD_Id__c + ':' + nObj.IndexFromUniqueKey__c;
- if (nObj.Cancel_Select__c) {
- nObj.UniqueKey__c += nObj.Id;
- // 涓嬫灦鍚庣殑鍙栨秷鍔�;
- if (nObj.StockDown__c) {
- nObj.UniqueKey__c += ';' + nObj.Id;
- }
- // nObj.Queue_Number__c = null;
- if (nObj.StockDown__c && nObj.Inspection_result__c != 'NG'
- && String.isBlank(nObj.DeliverySlip__c)) {
- nObj.OnStock_By_Cancel__c = true;
-// nObj.Inspection_result_after_Flag_Text__c = 'true';
- }
- }
- }
- System.debug(nObj.IndexFromUniqueKey__c + 'key is' + nObj.UniqueKey__c);
- // 鍙栨秷鍒嗛厤
- //Action 18 銇倛銇c仸銈儯銉炽偦銉伄鍫村悎
- //鍊熷嚭澶囧搧Set涓�瑙堟槑缁�.淇濇湁璁惧(Link)
- //鍊熷嚭澶囧搧Set涓�瑙堟槑缁�.鍒嗛厤鏃堕棿
- //鍊熷嚭澶囧搧Set涓�瑙堟槑缁�.宸插仛鍑哄簱鎸囩ず
- //鍊熷嚭澶囧搧Set涓�瑙堟槑缁�.鍑哄簱鎸囩ず鏃堕棿
- if (Trigger.isInsert || oObj.Cancel_Select__c != nObj.Cancel_Select__c) {
- if (nObj.Cancel_Select__c) {
- nObj.Cancel_Date__c = System.today();
- nObj.Cancel_Time__c = MainFixtureSelectController.getCurrentTime();
- nObj.Cancel_Mem__c = UserInfo.getUserId();
- if(nObj.AgencyTempCancel__c) {
- if(nObj.AgencyTempCancelTime__c != null) {
- Datetime dt = nObj.AgencyTempCancelTime__c;
- nObj.Cancel_Time__c = Time.newInstance(dt.hour(), dt.minute(), dt.second(), dt.millisecond());
- nObj.Cancel_Date__c = Date.newinstance(dt.year(), dt.month(), dt.day());
- }
- }
- nObj.AgencyTempCancel__c = false; // 鐪熷彇娑堟椂鎶婁复鏃跺彇娑堟爣璁版竻鎺�
- nObj.AgencyTempCancelTime__c = null;
- if (nObj.StockDown__c == false) {
- nObj.Asset__c = null;
- nObj.Select_Time__c = null;
- nObj.Shipment_request_time2__c = null;
- nObj.Shipment_request__c = false;
- // 鏍规嵁OLY_OCM-243璁拌浇,鍙栨秷涔熼渶瑕佹竻闄ゆ帴鍊熷嚭鏃剁浉鍏崇殑瀛楁
- if (nObj.DataMigration_Flag__c == false && (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))) {
- // 澶囧搧閰嶅鏄庣粏鍨嬪彿(鍊熷嚭鏃�)
- nObj.Fixture_Model_No_text__c = nObj.FSD_Fixture_Model_No__c;
- }
- // 鏈鸿韩缂栧彿锛堝�熷嚭鏃讹級
- nObj.SerialNumber_text__c = null;
- // 鎵�鍦ㄥ湴鍖�(鐪�) 鍊熷嚭鏃� #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
- nObj.SalesProvince_before__c = null;
- // 鎵�鍦ㄥ湴鍖�(鏈儴) 鍊熷嚭鏃� #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
- nObj.Salesdepartment_before__c = null;
- // 浜у搧鍒嗙被(GI/SP)(鍊熷嚭鏃�) #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
- nObj.Product_category_text__c = null;
- // 澶囧搧鍒嗙被(鍊熷嚭鏃�) #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
- nObj.Equipment_Type_text__c = null;
- // 澶囧搧鎴愭湰(鍊熷嚭鏃�)
- nObj.Asset_cost_del_before__c = null;
- // 澶囧搧瀛樻斁鍦�(鍊熷嚭鏃�)
- nObj.Internal_asset_location_before__c = null;
- //澶囧搧鍚嶇О(鍊熷嚭鏃�)
- nObj.Fixture_Name_text__c = nObj.FSD_Name_CHN__c;
- // 澶囧搧绠$悊缂栫爜(鍊熷嚭鏃�)
- nObj.EquipmentSet_Managment_Code_text__c = null;
- }
- //20201118 ljh add
- else{
- String ra_RecordTypeId = DEVELOPERNAMEMAP.get('AgencyRequest').getRecordTypeId();
- //System.debug('ra_RecordTypeId:'+ra_RecordTypeId);
- if(ra_RecordTypeId !=null && nObj.RA_RecordTypeId__c.substring(0,15) == ra_RecordTypeId.substring(0,15)){
- //nObj.Inspection_result__c = 'OK';
- nObj.Inspection_result_NG__c = null;
- nObj.Arrival_in_wh__c = true;
- nObj.Arrival_wh_time__c = System.now();
- nObj.Return_wh_chenk_staff__c = Userinfo.getUserId();
- nObj.Arrival_wh_Result_Agency__c = 'OK';
- }
- }
- //20201118 ljh add
- } else {
- nObj.Cancel_Date__c = null;
- nObj.Cancel_Time__c = null;
- nObj.Cancel_Mem__c = null;
- //nObj.Cancel_Reason__c = null;
- }
- }
- // 褰掕繕鍚嶤DS
- if (Trigger.isInsert || oObj.CDS_complete__c != nObj.CDS_complete__c) {
- if (nObj.CDS_complete__c) {
- nObj.CDS_complete_time__c = System.now();
- nObj.CDS_staff__c = UserInfo.getUserId();
- } else {
- nObj.CDS_complete_time__c = null;
- nObj.CDS_staff__c = null;
- }
- }
- System.debug(nObj.Return_Status_F__c);
- // 蹇呫仛鏈�寰屻仹缃亸
- //鍔广亱銇亜銇牬鍚堛亴銇傘倞銇俱仚銇仹After銇с倓銈娿伨銇�
- // nObj.Repair_Status_Text__c = nObj.Repair_Status_F__c;
- // nObj.Return_Status_Text__c = nObj.Return_Status_F__c;
- // nObj.Shipment_Status_Text__c = nObj.Shipment_Status_F__c;
- nObj.Canceled_Id__c = nObj.Canceled__c;
- if (Trigger.isUpdate
- && ((oObj.Inspection_result_after_Final__c != 'NG'
- && nObj.Inspection_result_after_Final__c == 'NG'
- && nObj.Inspection_result_after_NG_Final__c == '缁翠慨')
- || (oObj.Inspection_result_after__c != 'NG'
- && nObj.Inspection_result_after__c == 'NG'
- && nObj.Inspection_result_after_NG__c == '缁翠慨')
- )
- ) {
- nObj.Repair__c = null;
- }
-
- // OLY_OCM-531 Start 鎼伐浣滄祦瑙勫垯
- if (nObj.Check_lost_Item_F__c == '娆犲搧'
- && nObj.Loaner_Giveup_Time__c == null
- && nObj.Lost_item_giveup__c == true) {
- nObj.Loaner_Giveup_Time__c = Datetime.now();
- }
-
- if (nObj.RAESD_Status__c == '鎺掗槦涓�'
- && nObj.Queue_Day_Text__c == null) {
- nObj.Queue_Day_Text__c = nObj.Queue_Day__c;
- nObj.Queue_Time_Text__c = nObj.Queue_Time__c;
- }
-
- // OLY_OCM-531 End
- if (Trigger.isUpdate
- &&oObj.Confirm_Lost_Date__c != null
- && oObj.Check_lost_Item_F__c != nObj.Check_lost_Item_F__c
- && oObj.Check_lost_Item_F__c == '娆犲搧') {
- nObj.Confirm_Lost_Date__c = null;
- }
-
- if (Trigger.isUpdate
- && oObj.Shipment_request_time2__c != nObj.Shipment_request_time2__c
- && nObj.Shipment_request_time2__c != null
- && nObj.Is_Body__c
- && shipment_requestedRaIdStaticSet.contains(nObj.Rental_Apply__c) == false
- ) {
- shipment_requestedRaIdStaticSet.add(nObj.Rental_Apply__c);
- shipment_requestedRaIdSet.add(nObj.Rental_Apply__c);
- }
-
- }
+ private void deleteCheck() {
+ String ra_RecordTypeId = DEVELOPERNAMEMAP.get('AgencyRequest')
+ .getRecordTypeId();
+ for (Rental_Apply_Equipment_Set_Detail__c oObj : oldList) {
+ if (
+ (oObj.RA_RecordTypeId__c.substring(0, 15) !=
+ ra_RecordTypeId.substring(0, 15) &&
+ (oObj.Rental_Apply_Request_approval_time_F__c != null &&
+ oObj.ApplyPersonAppended_F__c == false) ||
+ (oObj.ApplyPersonAppended_F__c == true &&
+ oObj.Add_Request_approval_time__c != null)) ||
+ (oObj.RA_RecordTypeId__c.substring(0, 15) ==
+ ra_RecordTypeId.substring(0, 15) &&
+ (oObj.Rental_Apply_Request_approval_time_F__c != null &&
+ (oObj.Rental_Apply_CreatedDate_F__c > oObj.CreatedDate ||
+ oObj.StockDown__c == true) &&
+ !oObj.canDelete__c)) //20210523 ljh add 1829
+ ) {
+ oObj.addError('宸茬粡鎵瑰噯鐨勫鍝佸�熷嚭鏄庣粏涓嶈兘鍋氱墿鐞嗗垹闄ゃ��');
+ }
}
- /*
- * Asset 銇甉uantity鏇存柊
- * changeAssetCount()鏂规硶銇ut_of_wh__c銆丷ental_Count__c 鍑�1
- */
- private void changeAsset() {
- if (Trigger.isUpdate && Trigger.isAfter) {
- if (assMap.isEmpty()) {
- return;
- }
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- if (!assMap.containsKey(nObj.Asset__c)) {
- continue;
- }
- Rental_Apply_Equipment_Set_Detail__c oObj = null;
- if (Trigger.isUpdate) {
- oObj = oldMap.get(nObj.Id);
- }
- Asset ass = assMap.get(nObj.Asset__c);
- // Abandoned_Inventory__c null -> 0
- if (ass.Abandoned_Inventory__c == null) {
- ass.Abandoned_Inventory__c = 0;
- }
- // Abandoned_RealThing__c null -> 0
- if (ass.Abandoned_RealThing__c == null) {
- ass.Abandoned_RealThing__c = 0;
- }
- if (ass.CountForRepair__c == null) {
- ass.CountForRepair__c = 0;
- }
+ }
- if (ass.Confirm_Lost_Count__c == null) {
- ass.Confirm_Lost_Count__c = 0;
- }
- if (String.isBlank(oObj.Check_lost_Item_F__c) && nObj.Check_lost_Item_F__c == 'OK') {
- //鏈叆鍔涖亱銈夋瑺鍝併伀澶夋洿鏅備綍銈傘仐銇俱仜銈�
- } else if (String.isBlank(oObj.Check_lost_Item_F__c) && nObj.Check_lost_Item_F__c == '娆犲搧'
- && nObj.Lost_item_giveup__c == false) {
- //鏈叆鍔涖亱銈夋瑺鍝併伀澶夋洿鏅備綍銈傘仐銇俱仜銈�
- } else if (String.isBlank(oObj.Check_lost_Item_F__c) && nObj.Check_lost_Item_F__c == '娆犲搧'
- && nObj.Lost_item_giveup__c == true) {
- //鏈叆鍔涖亱銈夋瑺鍝佹斁妫勩伀澶夋洿鏅� 鏀惧純娆犲搧鍥炴敹锛堜涪澶憋級銇仺銇� 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍔�1
- ass.Abandoned_Inventory__c += 1;
- if (oObj.Confirm_Lost_Date__c != null) {
- ass.Confirm_Lost_Count__c -= 1;
- }
- assUpdMap.put(ass.Id, ass);
- } else if (String.isBlank(oObj.Check_lost_Item_F__c) && nObj.Check_lost_Item_F__c == '娑堣��') {
- //鏈叆鍔涖亱銈夋秷鑰椼伀澶夋洿鏅俀uantity銈�-1
- ass.Quantity -= 1;
- ass.ChangeQuantityReason__c = '娑堣��';
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Check_lost_Item_F__c == 'OK' && String.isBlank(nObj.Check_lost_Item_F__c)) {
- //OK銇嬨倝绌虹櫧銇鏇存檪浣曘倐銇椼伨銇涖倱
- } else if (oObj.Check_lost_Item_F__c == 'OK' && nObj.Check_lost_Item_F__c == '娆犲搧'
- && nObj.Lost_item_giveup__c == false) {
- //OK銇嬨倝娆犲搧銇鏇存檪浣曘倐銇椼伨銇涖倱
- } else if (oObj.Check_lost_Item_F__c == 'OK' && nObj.Check_lost_Item_F__c == '娆犲搧'
- && nObj.Lost_item_giveup__c == true) {
- //OK銇嬨倝娆犲搧鏀炬銇鏇存檪 鏀惧純娆犲搧鍥炴敹锛堜涪澶憋級銇仺銇� 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍔�1
- ass.Abandoned_Inventory__c += 1;
- if (oObj.Confirm_Lost_Date__c != null) {
- ass.Confirm_Lost_Count__c -= 1;
- }
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Check_lost_Item_F__c == 'OK' && nObj.Check_lost_Item_F__c == '娑堣��') {
- //OK銇嬨倝娑堣�椼伀澶夋洿鏅俀uantity銈�-1
- ass.Quantity -= 1;
- ass.ChangeQuantityReason__c = '娑堣��';
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Check_lost_Item_F__c == '娆犲搧' && String.isBlank(nObj.Check_lost_Item_F__c)
- && oObj.Lost_item_giveup__c == false) {
- if (oObj.Confirm_Lost_Date__c != null) {
- ass.Confirm_Lost_Count__c -= 1;
- }
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Check_lost_Item_F__c == '娆犲搧' && nObj.Check_lost_Item_F__c == 'OK'
- && oObj.Lost_item_giveup__c == false) {
- if (oObj.Confirm_Lost_Date__c != null) {
- ass.Confirm_Lost_Count__c -= 1;
- }
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Check_lost_Item_F__c == '娆犲搧' && nObj.Check_lost_Item_F__c == '娆犲搧'
- && oObj.Lost_item_giveup__c == false && nObj.Lost_item_giveup__c == true) {
- //娆犲搧銇嬨倝娆犲搧鏀炬銇鏇存檪 鏀惧純娆犲搧鍥炴敹锛堜涪澶憋級銇仺銇� 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍔�1
- ass.Abandoned_Inventory__c += 1;
- if (oObj.Confirm_Lost_Date__c != null) {
- ass.Confirm_Lost_Count__c -= 1;
- }
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Check_lost_Item_F__c == '娆犲搧' && nObj.Check_lost_Item_F__c == '娑堣��'
- && oObj.Lost_item_giveup__c == false) {
- //娆犲搧銇嬨倝娑堣�椼伀澶夋洿鏅俀uantity銈�-1
- ass.Quantity -= 1;
- ass.ChangeQuantityReason__c = '娑堣��';
- if (oObj.Confirm_Lost_Date__c != null) {
- ass.Confirm_Lost_Count__c -= 1;
- }
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Check_lost_Item_F__c == '娆犲搧' && String.isBlank(nObj.Check_lost_Item_F__c) && oObj.Lost_item_giveup__c == true) {
- //娆犲搧鏀炬銇嬨倝绌虹櫧銇鏇存檪 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍑�1
- ass.Abandoned_Inventory__c -= 1;
- ass.Out_of_wh__c += 1;
- ass.Rental_Count__c += 1;
- ass.ChangeQuantityReason__c = '娆犲搧' + '->' + '';
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Check_lost_Item_F__c == '娆犲搧' && nObj.Check_lost_Item_F__c == 'OK' && oObj.Lost_item_giveup__c == true) {
- //娆犲搧鏀炬銇嬨倝OK銇鏇存檪 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍑�1
- ass.Abandoned_Inventory__c -= 1;
- ass.Out_of_wh__c += 1;
- ass.Rental_Count__c += 1;
- ass.ChangeQuantityReason__c = '娆犲搧' + '->' + 'OK';
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Check_lost_Item_F__c == '娆犲搧' && nObj.Check_lost_Item_F__c == '娆犲搧'
- && oObj.Lost_item_giveup__c == true && nObj.Lost_item_giveup__c == false) {
- //娆犲搧鏀炬銇嬨倝娆犲搧銇鏇存檪 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍑�1
- ass.Abandoned_Inventory__c -= 1;
- ass.Out_of_wh__c += 1;
- ass.Rental_Count__c += 1;
- ass.ChangeQuantityReason__c = '娆犲搧鏀惧純 -> ' + '娆犲搧';
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Check_lost_Item_F__c == '娆犲搧' && nObj.Check_lost_Item_F__c == '娑堣��' && oObj.Lost_item_giveup__c == true) {
- //娆犲搧鏀炬銇嬨倝娑堣�椼伀澶夋洿鏅� 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍑�1 Quantity銈�-1
- ass.Abandoned_Inventory__c -= 1;
- ass.Quantity -= 1;
- } else if (oObj.Check_lost_Item_F__c == '娑堣��' && String.isBlank(nObj.Check_lost_Item_F__c)) {
- //娑堣�椼亱銈夌┖鐧姐伀澶夋洿鏅俀uantity銈�+1
- ass.Quantity += 1;
- ass.Out_of_wh__c += 1;
- ass.Rental_Count__c += 1;
- ass.ChangeQuantityReason__c = '娑堣�� -> ' + '';
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Check_lost_Item_F__c == '娑堣��' && nObj.Check_lost_Item_F__c == 'OK') {
- //娑堣�椼亱銈夌┖鐧姐伀澶夋洿鏅俀uantity銈�+1
- ass.Quantity += 1;
- ass.Out_of_wh__c += 1;
- ass.Rental_Count__c += 1;
- ass.ChangeQuantityReason__c = '娑堣�� -> ' + 'OK';
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Check_lost_Item_F__c == '娑堣��' && nObj.Check_lost_Item_F__c == '娆犲搧'
- && nObj.Lost_item_giveup__c == false) {
- //娑堣�椼亱銈夋瑺鍝併伀澶夋洿鏅俀uantity銈�+1
- ass.Quantity += 1;
- ass.Out_of_wh__c += 1;
- ass.Rental_Count__c += 1;
- ass.ChangeQuantityReason__c = '娑堣�� -> 娆犲搧';
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Check_lost_Item_F__c == '娑堣��' && nObj.Check_lost_Item_F__c == '娆犲搧'
- && nObj.Lost_item_giveup__c == true) {
- //娑堣�椼亱銈夋瑺鍝佹斁妫勩伀澶夋洿鏅� 寰呭簾寮冩暟(涓㈠け/鐩樹簭)+1 Quantity銈�+1
- ass.Abandoned_Inventory__c += 1;
- ass.Quantity += 1;
- }
- // 缁翠慨
- if (oObj.Arrival_in_wh__c == false && nObj.Arrival_in_wh__c == true
- && nObj.Arrival_wh_Result_Agency__c == '寰呬慨鐞�') {
- ass.CountForRepair__c += 1;
- assUpdMap.put(ass.Id, ass);
- }
- //搴熷純
- if (oObj.Arrival_in_wh__c == false && nObj.Arrival_in_wh__c == true
- && (nObj.Inspection_result_after_NG_F__c == '搴熷純'
- //鍑哄簱鍓嶆娴嬪簾寮冪殑鏃跺�欎篃闇�瑕佸垽鏂�
- || nObj.Inspection_result_NG__c == '搴熷純')) {
- ass.Abandoned_RealThing__c += 1;
- ass.ChangeQuantityReason__c = FixtureUtil.raesdStatusMap.get(FixtureUtil.HistoryStatus.Dai_Fei_Qi.ordinal());
- assUpdMap.put(ass.Id, ass);
- } else if (oObj.Arrival_in_wh__c == true && nObj.Arrival_in_wh__c == false
- && (oObj.Inspection_result_after_NG_F__c == '搴熷純'
- //鍑哄簱鍓嶆娴嬪簾寮冪殑鏃跺�欎篃闇�瑕佸垽鏂�
- || oObj.Inspection_result_NG__c == '搴熷純')) {
- ass.Abandoned_RealThing__c -= 1;
- ass.Out_of_wh__c += 1;
- ass.Rental_Count__c += 1;
- // ass.Freeze_sign__c = true; // OLY_OCM-689 鍒犻櫎鍐荤粨瀛楁鐨勬洿鏂�
- String rea = nObj.Inspection_result_after_NG_F__c == '搴熷純' ? '寰呯Щ鑷虫姤搴熷尯' : nObj.Inspection_result_after_NG_F__c;
- ass.ChangeQuantityReason__c = FixtureUtil.raesdStatusMap.get(FixtureUtil.HistoryStatus.Dai_Fei_Qi.ordinal()) + ' ->' + rea;
- assUpdMap.put(ass.Id, ass);
- }
- //寰呭簾寮�
- if (nObj.RAESD_Status__c == FixtureUtil.raesdStatusMap.get(FixtureUtil.HistoryStatus.Dai_Fei_Qi.ordinal())
- && oObj.RAESD_Status__c != nObj.RAESD_Status__c
- && ass.Manage_type__c == '涓綋绠$悊') {
- ass.Status = FixtureUtil.assetStatusMap.get(FixtureUtil.AssetStatus.Dai_Fei_Qi.ordinal());
- // ass.Freeze_sign__c = true;
- assUpdMap.put(ass.Id, ass);
- }
- // 鍔炰簨澶勫洖搴撶粨鏋滀慨鏀�
- if(oObj.Arrival_in_wh__c && nObj.Arrival_in_wh__c
- && oObj.Arrival_wh_Result_Agency__c != nObj.Arrival_wh_Result_Agency__c ) {
- switch on oObj.Arrival_wh_Result_Agency__c {
- when '绉昏嚦鎶ュ簾鍖�' {
- ass.Abandoned_RealThing__c -=1;
- }
- when '寰呬慨鐞�' {
- ass.CountForRepair__c -=1;
- }
- }
- switch on nObj.Arrival_wh_Result_Agency__c {
- when '绉昏嚦鎶ュ簾鍖�' {
- ass.Abandoned_RealThing__c +=1;
- }
- when '寰呬慨鐞�' {
- ass.CountForRepair__c +=1;
- }
- }
- assUpdMap.put(ass.Id, ass);
- }
- // //宸叉秷鑰�
- // else if (nObj.Check_lost_Item_Final__c == '娑堣��'
- // && oObj.Check_lost_Item_Final__c != nObj.Check_lost_Item_Final__c
- // && ass.Manage_type__c == '涓綋绠$悊') {
- // ass.Status = FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Xiao_Hao.ordinal());
- // assUpdMap.put(ass.Id, ass);
- // }
- //涓㈠け
- // else if (nObj.Lost_item_giveup__c == true
- // && oObj.Lost_item_giveup__c != nObj.Lost_item_giveup__c
- // && ass.Manage_type__c == '涓綋绠$悊') {
- // ass.Status = FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Diu_Shi.ordinal());
- // assUpdMap.put(ass.Id, ass);
- // }
- // else if (ass.Manage_type__c == '鏁伴噺绠$悊' && assMap.containsKey(ass.Id)) {
- // if (ass.Quantity != null && ass.Quantity > 0) {
- // if (ass.Status != FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Ke_Yi_Fen_Pei.ordinal())) {
- // ass.Status = FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Ke_Yi_Fen_Pei.ordinal());
- // assUpdMap.put(ass.Id, ass);
- // }
- // }
- // else {
- // if (ass.Status != FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Mei_You_Ku_Cun.ordinal())) {
- // ass.Status = FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Mei_You_Ku_Cun.ordinal());
- // assUpdMap.put(ass.Id, ass);
- // }
- // }
- // }
- }
+ private void setConsumSend_Rental_Apply_EmailTime() {
+ if (shipment_requestedRaIdSet.isEmpty() == false) {
+ List<Consum_Apply__c> caList = [
+ SELECT Id, Loaner_centre_mail_address__c
+ FROM Consum_Apply__c
+ WHERE Rental_Apply__c = :shipment_requestedRaIdSet
+ ];
+ if (caList.size() > 0) {
+ Datetime dt = Datetime.now();
+ for (Consum_Apply__c ca : caList) {
+ ca.Send_Rental_Apply_EmailTime__c = dt;
}
+ update caList;
+ }
+ shipment_requestedRaIdSet = new Set<Id>();
}
- /*
- * 鍥炲簱纭 OFF -> ON:
- * 鍙栨秷鍒嗛厤 OFF -> ON:
- * 鏀惧純娆犲搧 OFF -> ON
- * 宸叉秷鑰�
- *
- * 娓呯┖Asset 鏈�鏂板鍝佺敵璇峰�熷嚭鏄庣粏 Last_Reserve_RAES_Detail__c
- * (nObj.Asset__c 澶夋洿銇椼仾銇勩仧銈併�乧hangeAssetLast()銇с偗銉偄銇с亶銇亜銇熴倎銆併亾銇撱仹銈儶銈�)
- *
- * 銈儵銈广伄 assUpdMap 銈掓洿鏂般仚銈嬨仩銇�
- */
- private void clearLastReserveRAESD() {
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
- // 涓讳綋鍜岄檮灞炲搧
- if (finishOrChangeAsset(Trigger.isDelete, oObj, nObj)) {
- Asset ass = assMap.get(nObj.Asset__c);
- if (assUpdMap.containsKey(nObj.Asset__c)) {
- ass = assUpdMap.get(nObj.Asset__c);
- }
- // 杩欓噷 浼氬嚭鐜� assUpdMap 鏈� 浣嗘槸 assMap 娌℃湁鐨勬儏鍐�
- if (ass == null
- //鍒嗛厤澶囧搧鏈夊彉鍖� (涓嬫灦鍓�)
- && (oObj.Asset__c != null && oObj.Asset__c != nObj.Asset__c
- && nObj.StockDown__c == false)) {
- ass = new Asset(Id = oObj.Asset__c);
- }
- if (ass == null) {
- continue;
- }
- // 鏆傛椂鏀惧湪杩欓噷
- if (oObj.Manage_type_F__c == '涓綋绠$悊') {
- ass.Last_Reserve_RAES_Detail__c = null;
- assUpdMap.put(ass.Id, ass);
- }
- }
- }
- }
- //nObj.Asset__c銇屻亗銈嬪牬鍚堛�佸鏇淬仐銇熷牬鍚�
- private void changeAssetLast() {
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
- Asset nass = assMap.get(nObj.Asset__c);
- if (assUpdMap.containsKey(nObj.Asset__c)) {
- nass = assUpdMap.get(nObj.Asset__c);
- } else if (String.isNotBlank(nObj.Asset__c)) {
- nass = new Asset(Id = nObj.Asset__c);
- }
- Asset oass = assMap.get(oObj.Asset__c);
- if (assUpdMap.containsKey(oObj.Asset__c)) {
- oass = assUpdMap.get(oObj.Asset__c);
- } else if (String.isNotBlank(oObj.Asset__c)) {
- oass = new Asset(Id = oObj.Asset__c);
- }
- //nObj.Asset__c銇屻亗銈嬪牬鍚堛�佸鏇淬仐銇熷牬鍚�
- if (nObj.Asset__c != null && oObj.Asset__c != nObj.Asset__c
- && (oObj.Manage_type_F__c == '涓綋绠$悊' || nObj.Manage_type_F__c == '涓綋绠$悊')) {
- if (nObj.Manage_type_F__c == '涓綋绠$悊') {
- nass.Last_Reserve_RAES_Detail__c = nObj.Id;
- assUpdMap.put(nass.Id, nass);
- }
- if (oObj.Manage_type_F__c == '涓綋绠$悊') {
- oass.Last_Reserve_RAES_Detail__c = null;
- assUpdMap.put(oass.Id, oass);
- }
- }
- }
- }
- // 鍙栨秷鍒嗛厤 鐨勬椂鍊�, 闇�瑕佸湪 beforeSetValue() 閲屾妸 Asset__c 娓呴櫎
- //鏄庣窗绲備簡銇ˋsset澶夋洿銇檪Out_of_wh__c銈掓洿鏂�
- //afterupdate銇伩瀹熻
- private void changeAssetCount() {
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
- Asset nass = assMap.get(nObj.Asset__c);
- if (assUpdMap.containsKey(nObj.Asset__c)) {
- nass = assUpdMap.get(nObj.Asset__c);
- } else if (String.isNotBlank(nObj.Asset__c)) {
- nass = new Asset(Id = nObj.Asset__c);
- }
- Asset oass = assMap.get(oObj.Asset__c);
- if (assUpdMap.containsKey(oObj.Asset__c)) {
- oass = assUpdMap.get(oObj.Asset__c);
- } else if (String.isNotBlank(oObj.Asset__c)) {
- oass = new Asset(Id = oObj.Asset__c);
- }
- //Map銇獳sset銈掓柊瑕弍ush鏅傚�ゃ倰瑷畾
- if (oass != null && (oass.Out_of_wh__c == null || oass.Rental_Count__c == null || oass.Confirm_Lost_Count__c == null)) {
- oass.Out_of_wh__c = oObj.Out_of_wh__c;
- oass.Rental_Count__c = oObj.Rental_Count__c;
- oass.Confirm_Lost_Count__c = oObj.Confirm_Lost_Count__c;
- }
- if (nass != null && (nass.Out_of_wh__c == null || nass.Rental_Count__c == null || nass.Confirm_Lost_Count__c == null)) {
- nass.Out_of_wh__c = nObj.Out_of_wh__c;
- nass.Rental_Count__c = nObj.Rental_Count__c;
- nass.Confirm_Lost_Count__c = nObj.Confirm_Lost_Count__c;
- }
- // 鏈�绲傜姸鎱嬪強銇ˋsset澶夋洿銇牬鍚�
- if (finishOrChangeAsset(Trigger.isDelete, oObj, nObj)) {
- System.debug('oass is ' + oass);
- if (oass != null) {
- if (oass.Out_of_wh__c != null && oass.Out_of_wh__c > 0) {
- oass.Out_of_wh__c = oass.Out_of_wh__c - 1;
- // assUpdMap.put(oass.Id, oass);
- System.debug('oass.Out_of_wh__c -1' + oass.Out_of_wh__c + ' Id = ' + nObj.Id);
- }
- if (nObj.DeliverySlip__c != null) {
- if (oass.Rental_Count__c != null && oass.Rental_Count__c > 0) {
- oass.Rental_Count__c = oass.Rental_Count__c - 1;
- }
- }
- assUpdMap.put(oass.Id, oass);
- }
- } else if (oass != null && oObj.DeliverySlip__c != null && nObj.DeliverySlip__c == null) {
- //鍙戣揣杩愯緭鍗� 鍒犻櫎鐨勬椂鍊欏凡鍊熷嚭鏁� -1 鍙戣揣Asset__c鍘熷垯涓嶄細鍙樻墍浠ュ氨鐩存帴鐢ㄤ笂闈㈢殑oass
- // if (nObj.DeliverySlip__c != null) {
- if (oass.Rental_Count__c != null && oass.Rental_Count__c > 0) {
- oass.Rental_Count__c = oass.Rental_Count__c - 1;
- assUpdMap.put(oass.Id, oass);
- }
- // }
- }
- if (oObj.Confirm_Lost_Date__c == null
- && nObj.Confirm_Lost_Date__c != null) {
- nass.Confirm_Lost_Count__c = nass.Confirm_Lost_Count__c + 1;
- assUpdMap.put(nass.Id, nass);
- }
- else if (nObj.Confirm_Lost_Date__c == null
- && oObj.Confirm_Lost_Date__c != null
- && nass.Confirm_Lost_Count__c > 0) {
- nass.Confirm_Lost_Count__c = nass.Confirm_Lost_Count__c - 1;
- assUpdMap.put(nass.Id, nass);
- }
- //鍙戣揣杩愯緭鍗曡缃殑鏃跺�欏凡瑙i櫎鏁�+1
- if (oObj.DeliverySlip__c == null && nObj.DeliverySlip__c != null) {
- nass.Rental_Count__c = nass.Rental_Count__c + 1;
- assUpdMap.put(nass.Id, nass);
- }
- //nObj.Asset__c銇屻亗銈嬪牬鍚堛�佸鏇淬仐銇熷牬鍚�
- System.debug(LoggingLevel.INFO, '*** nObj.Asset__c: ' + nObj.Asset__c);
- if (nObj.Asset__c != null && oObj.Asset__c != nObj.Asset__c) {
- nass.Out_of_wh__c = nass.Out_of_wh__c + 1;
- System.debug('nass.Out_of_wh__c +1' + nass.Out_of_wh__c + ' Id = ' + nObj.Id);
- assUpdMap.put(nass.Id, nass);
- }
- }
- }
- // 鍚屻仒block 銇� 鎺掗槦銉偝銉笺儔 Queue_Number__c 銈抮efresh
- // private void refreshQueueNumberByBlock() {
- // for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- // Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
- // // 鍚屻仒block 銇� 鎺掗槦澶夋洿銇屻亗銈嬪牬鍚�
- // if (oObj.Cancel_Select__c == false
- // && String.isBlank(oObj.Fixture_Model_No_text__c) == false
- // && String.isBlank(oObj.Salesdepartment_before__c) == false
- // && String.isBlank(oObj.Product_category_text__c) == false
- // && String.isBlank(oObj.Equipment_Type_text__c) == false
- // && oObj.Queue_Number__c > 0
- // // 澶夊寲銈掔⒑瑾�
- // && (oObj.Cancel_Select__c != nObj.Cancel_Select__c
- // || oObj.Fixture_Model_No_text__c != nObj.Fixture_Model_No_text__c
- // || oObj.Salesdepartment_before__c != nObj.Salesdepartment_before__c
- // || oObj.Product_category_text__c != nObj.Product_category_text__c
- // || oObj.Equipment_Type_text__c != nObj.Equipment_Type_text__c
- // || (nObj.Queue_Number__c == 0 || nObj.Queue_Number__c == null))
- // ) {
- // if (executeed_refreshQueueNumber.contains(nObj.Id) && executeed_refreshQueueNumber.contains(oObj.Id)) {
- // continue;
- // }
- // else if (executeed_refreshQueueNumber.contains(nObj.Id) == false) {
- // executeed_refreshQueueNumber.add(nObj.Id);
- // } else { // executeed_refreshQueueNumber.contains(oObj.Id) == false
- // executeed_refreshQueueNumber.add(oObj.Id);
- // }
- // // TODO 鎯冲畾 鐢婚潰銇嬨倝銇�1 record 銇椼亱銇亜
- // List<Rental_Apply_Equipment_Set_Detail__c> updateList = new List<Rental_Apply_Equipment_Set_Detail__c>();
- // List<Rental_Apply_Equipment_Set_Detail__c> refreshTargetList = [
- // Select Id, Queue_Number__c
- // from Rental_Apply_Equipment_Set_Detail__c
- // where Cancel_Select__c = false
- // and Fixture_Model_No_text__c = :oObj.Fixture_Model_No_text__c
- // and Salesdepartment_before__c = :oObj.Salesdepartment_before__c
- // and Product_category_text__c = :oObj.Product_category_text__c
- // and Equipment_Type_text__c = :oObj.Equipment_Type_text__c
- // and Queue_Number__c > 0
- // Order by Queue_Number__c];
- // for (Integer i = 0; i < refreshTargetList.size(); i++) {
- // Rental_Apply_Equipment_Set_Detail__c refreshTarget = refreshTargetList[i];
- // if (refreshTarget.Queue_Number__c != (i + 1)) {
- // refreshTarget.Queue_Number__c = i + 1;
- // executeed_refreshQueueNumber.add(refreshTarget.Id);
- // updateList.add(refreshTarget);
- // }
- // }
- // if (!updateList.isEmpty()) { update updateList; }
- // }
- // }
- // }
+ }
- // 4-XX 涓嬫灦鍚�, 鍑哄簱鍓嶆娴嬬殑Action涓�瀵逛竴鍒嗛厤鐨勮瘽, 鍜屼富浣撲竴璧� Cancel
- private void oneToOne4XX() {
-
- //涓讳綋CnacelSet
- Set<Id> raesdBodyCnacelSet = new Set<Id>();
- Set<Id> raesdBodyNGSet = new Set<Id>();
- //鏆傛椂鍙�冭檻涓讳綋NG鎴栬�呭彇娑堢殑鏃跺��
- Map<Id, String> raesdCancel_Remarks = new Map<Id, String>();
- //妫�娴婲G鎴栬�呮湰鏉ュ氨Cancel鐨勪笉闇�瑕佸啀鏇存柊
- Set<Id> raesdIdSet = new Set<Id>();
- String ra_RecordTypeId = DEVELOPERNAMEMAP.get('AgencyRequest').getRecordTypeId();
-
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- // 鍔炰簨澶勯檮灞炲搧涓嶉渶瑕侀殢涓讳綋鍙栨秷
- if(nObj.RA_RecordTypeId__c.substring(0,15) == ra_RecordTypeId.substring(0,15)) {
- continue;
- }
- Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
- //Set娌℃湁cancel鐨勮瘽閮介渶瑕佹嫹璐�
- //涓讳綋鍑哄簱鍓嶆娴婲G 缁翠慨
- if (nObj.Is_Body__c == true
- && nObj.Inspection_result__c == 'NG'
- && oObj.Inspection_result__c != nObj.Inspection_result__c
- && nObj.Inspection_result_NG__c == '缁翠慨') {
- //闇�瑕侀噸鏂板垎閰嶄竴瀵逛竴闄勫睘鍝佺殑涓�瑙�
- raesdBodyNGSet.add(nObj.Rental_Apply_Equipment_Set__c);
- raesdCancel_Remarks.put(nObj.Rental_Apply_Equipment_Set__c, nObj.Loaner_cancel_Remarks__c);
- raesdIdSet.add(nObj.Id);
- }
- //涓讳綋鍑哄簱鍓嶆娴婲G 搴熷純
- else if (nObj.Is_Body__c == true
- && nObj.Inspection_result__c == 'NG'
- && oObj.Inspection_result__c != nObj.Inspection_result__c
- && nObj.Inspection_result_NG__c == '搴熷純') {
- //闇�瑕侀噸鏂板垎閰嶄竴瀵逛竴闄勫睘鍝佺殑涓�瑙�
- raesdBodyNGSet.add(nObj.Rental_Apply_Equipment_Set__c);
- raesdCancel_Remarks.put(nObj.Rental_Apply_Equipment_Set__c, nObj.Loaner_cancel_Remarks__c);
- raesdIdSet.add(nObj.Id);
- }
- //闄勫睘鍝佸嚭搴撳墠妫�娴婲G 缁翠慨 骞朵笖鏄竴瀵逛竴鍒嗛厤
- else if (nObj.Is_Body__c == false
- && nObj.Inspection_result__c == 'NG'
- && oObj.Inspection_result__c != nObj.Inspection_result__c
- && nObj.Inspection_result_NG__c == '缁翠慨'
- && nObj.OneToOne_Flag__c == true) {
- raesdIdSet.add(nObj.Id);
- }
- //闄勫睘鍝佸嚭搴撳墠妫�娴婲G 搴熷純 骞朵笖鏄竴瀵逛竴鍒嗛厤
- else if (nObj.Is_Body__c == false
- && nObj.Inspection_result__c == 'NG'
- && oObj.Inspection_result__c != nObj.Inspection_result__c
- && nObj.Inspection_result_NG__c == '搴熷純'
- && nObj.OneToOne_Flag__c == true) {
- raesdIdSet.add(nObj.Id);
- }
- //OLY_OCM-152 涓嬫灦鍚庝富浣撳彇娑堢殑璇濅竴瀵逛竴闄勫睘鍝佷篃瑕佷竴璧峰彇娑�
- else if (String.isBlank(nObj.DeliverySlip__c)
- && nObj.Is_Body__c == true
- && nObj.StockDown__c == true
- && oObj.Cancel_Select__c == false
- && nObj.Cancel_Select__c == true) {
- raesdIdSet.add(nObj.Id);
- raesdBodyCnacelSet.add(nObj.Rental_Apply_Equipment_Set__c);
- raesdCancel_Remarks.put(nObj.Rental_Apply_Equipment_Set__c, nObj.Loaner_cancel_Remarks__c);
- }
- }
- if (raesdBodyNGSet.isEmpty() && raesdBodyCnacelSet.isEmpty()) {
- return;
- }
- List<Rental_Apply_Equipment_Set_Detail__c> raesds = [
- Select Id, UniqueKey__c, Rental_Apply_Equipment_Set__c,
- Rental_Apply__c, Fixture_Set_Detail__c, Cancel_Reason__c
- From Rental_Apply_Equipment_Set_Detail__c
- //涓讳綋鍑哄簱鍓嶆娴婲G涓�瑙堢殑鎵�鏈変竴瀵逛竴鍒嗛厤鐨勬槑缁�
- Where (Rental_Apply_Equipment_Set__c = :raesdBodyNGSet
- //涓嬫灦鍚庝富浣撳彇娑堜竴瀵逛竴闄勫睘鍝佷篃瑕佷竴璧峰彇娑�
- OR Rental_Apply_Equipment_Set__c = :raesdBodyCnacelSet)
- AND OneToOne_Flag__c = true
- //鍜屼富浣撲竴璧锋娴婲G鐨勪笉鍐嶆洿鏂�
- AND Id !=: raesdIdSet];
- List<Rental_Apply_Equipment_Set_Detail__c> raesdList = new List<Rental_Apply_Equipment_Set_Detail__c>();
- for (Rental_Apply_Equipment_Set_Detail__c raesd : raesds) {
- raesd.OnStock_By_Cancel__c = true;
- raesd.Cancel_Select__c = true;
- // OLY_OCM-163#comment-20120592 閫氳繃鍙栨秷鏃ュ垽鏂� -銆� 鏇存柊鐨勬椂鍊檅efore璁剧疆
- //raesd.Cancel_Date__c = Date.today();
- raesd.Cancel_Reason__c = '閲嶆柊鍒嗛厤';
- raesd.Loaner_cancel_reason__c = '鍏朵粬';// 20210830 ljh SFDC-C448KZ add
- //涓讳綋鍑哄簱鍓嶆鏌G鐨勮瘽鍙栨秷澶囨敞鍥炶嚜鍔ㄨ缃负鍑哄簱鍓嶆鏌G
- raesd.Loaner_cancel_Remarks__c = raesdCancel_Remarks.get(raesd.Rental_Apply_Equipment_Set__c);
- // }
- raesdList.add(raesd);
- }
- System.debug('raesdList size' + raesdList.size());
- if (!raesdList.isEmpty()) {
- update raesdList;
- }
+ private void beforeSetValue() {
+ Set<Id> raesdSet = new Set<Id>();
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ raesdSet.add(nObj.Rental_Apply_Equipment_Set__c);
}
+ Map<Id, Rental_Apply_Equipment_Set__c> raesdMap = new Map<Id, Rental_Apply_Equipment_Set__c>(
+ [
+ SELECT Id, Fixture_Set__r.Name, IndexFromUniqueKey__c
+ FROM Rental_Apply_Equipment_Set__c
+ WHERE Id = :raesdSet
+ ]
+ );
+ String agencyRecordTypeId = DEVELOPERNAMEMAP.get('AgencyRequest')
+ .getRecordTypeId();
- //涓�瑙堝崟浣嶅彇娑堝悗鐨勬嫹璐濆湪涓�瑙堢殑Handler閲岄潰鍋�
- // 鍥犱负cancel鏄富浣撶殑璇滷irst搴斿紑濮嬫嫹璐濆嚭鏉ョ殑涓讳綋鎵�浠irst鐨勬洿鏂伴�昏緫绉诲姩鍒癱ancelcopy
- private void cancelCopy() {
- List<Rental_Apply_Equipment_Set_Detail__c> raesdList = new List<Rental_Apply_Equipment_Set_Detail__c>();
- List<Rental_Apply_Equipment_Set_Detail__c> raesdListup = new List<Rental_Apply_Equipment_Set_Detail__c>();
- Map<Id, Rental_Apply_Equipment_Set__c> raesMap = new Map<Id, Rental_Apply_Equipment_Set__c>();
- String ra_RecordTypeId = DEVELOPERNAMEMAP.get('AgencyRequest').getRecordTypeId();
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
- //Set娌℃湁cancel鐨勮瘽閮介渶瑕佹嫹璐�
- //Cancel_Select__c 銇痜alse銇嬨倝true銇鏇淬仾銇仹銇伄銇rigger浜屽洖銇仐銇︺倐瀹熻銇欍倠銇伅锛戝洖銇犮亼
- if (nObj.Set_Cancel_Select__c == false
- && (oObj.Cancel_Select__c == false && nObj.Cancel_Select__c == true)
- && nObj.StockDown__c == true && nObj.Cancel_Reason__c == '閲嶆柊鍒嗛厤'
- // 鍔炰簨澶勫彇娑堟椂涓嶈鎷疯礉鏄庣粏锛屽湪controller閲屾墜鍔ㄩ��
- && nObj.RA_RecordTypeId__c.substring(0,15) != ra_RecordTypeId.substring(0,15)) {
- Rental_Apply_Equipment_Set_Detail__c craesd = new Rental_Apply_Equipment_Set_Detail__c();
- craesd.Rental_Apply_Equipment_Set__c = nObj.Rental_Apply_Equipment_Set__c;
- craesd.Rental_Apply__c = nObj.Rental_Apply__c;
- craesd.Fixture_Set_Detail__c = nObj.Fixture_Set_Detail__c;
- craesd.Fixture_Model_No_text__c = nObj.FSD_Fixture_Model_No__c;
- craesd.Fixture_Name_text__c = nObj.FSD_Name_CHN__c;
- craesd.IndexFromUniqueKey_Text__c = nObj.IndexFromUniqueKey_Text__c;
- craesd.Canceled__c = nObj.Id;
- craesd.FSD_Id__c = nObj.FSD_Id__c;
- craesd.FSD_Is_Optional__c = nObj.FSD_Is_Optional_F__c;
- craesd.FSD_Is_OneToOne__c = nObj.FSD_Is_OneToOne_F__c;
- craesd.FSD_Name_CHN__c = nObj.FSD_Name_CHN__c;
- craesd.FSD_OneToOneAccessory_Cnt__c = nObj.FSD_OneToOneAccessory_Cnt_F__c;
- craesd.FSD_Fixture_Model_No__c = nObj.FSD_Fixture_Model_No__c;
- // 20211125 ljh add 鎺掗槦鎻掗槦 start
- if(nObj.Is_Body__c){
- craesd.Allow_Adjust_Queue_Flag__c = true;
- craesd.jumpReason__c = '鍙戣揣鍓嶆娴婲G閲嶆柊鍒嗛厤';
- }
- // 20211125 ljh add 鎺掗槦鎻掗槦 end
- if (nObj.DataMigration_Flag__c == false && (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))) {
- craesd.Rental_Num__c = nObj.Rental_Num__c;
- craesd.IndexFromUniqueKey__c = nObj.IndexFromUniqueKey__c;
- }
- //cancel閲嶆柊鍒嗛厤鐨勪笉绠楄拷鍔犻檮灞炲搧 272銉併偙銉冦儓
- craesd.Create_State__c = 0;
- raesdList.add(craesd);
- }
- // 濡傛灉鏄富浣� cancel鐨勮瘽First搴旇鏄嫹璐濆嚭鏉ョ殑涓讳綋
- if ((oObj.Cancel_Select__c == false && nObj.Cancel_Select__c == true)
- && nObj.Is_First_RAESD_F__c == true && nObj.Set_Cancel_Select__c == false
- && nObj.DataMigration_Flag__c == false && (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))) {
- Rental_Apply_Equipment_Set__c raes = new Rental_Apply_Equipment_Set__c(
- Id = nObj.Rental_Apply_Equipment_Set__c,
- First_RAESD__c = null);
- raesMap.put(nObj.Rental_Apply_Equipment_Set__c, raes);
- }
- }
- //娌′笅鏋剁殑瀛楁娓呯┖鍦╞efore閲岄潰鍋�
- if (!raesdList.isEmpty()) {
- insert raesdList;
- }
- if (!raesMap.isEmpty()) {
- List<Rental_Apply_Equipment_Set_Detail__c> raess = [Select Id, Rental_Apply_Equipment_Set__c
- From Rental_Apply_Equipment_Set_Detail__c
- Where Rental_Apply_Equipment_Set__c = :raesMap.keySet()
- and Cancel_Select__c = False
- order by Rental_Apply_Equipment_Set__c, Fixture_Set_Detail__r.SortInt__c ASC nulls last];
- System.debug(raess);
- Id raesId = null;
- // 涓�浠剁洰銈扚irst_RAESD__c銇ō瀹�
- for (Rental_Apply_Equipment_Set_Detail__c raes : raess) {
- if (raesId != raes.Rental_Apply_Equipment_Set__c) {
- raesMap.get(raes.Rental_Apply_Equipment_Set__c).First_RAESD__c = raes.Id;
- raesId = raes.Rental_Apply_Equipment_Set__c;
- }
+ // 澶囧搧鎬ц兘浼樺寲鏀逛慨 20230312 by lc Start
+ String userid = UserInfo.getUserId();
+ // 澶囧搧鎬ц兘浼樺寲鏀逛慨 20230312 by lc End
- }
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ //鍥犱负鏄疘nsert鏃跺�欒鍊� 鎯呭喌1锛岀敵璇锋柊寤轰細璁惧�� 鎯呭喌2锛孨G鎷疯礉鍑烘潵鐨勬椂鍊欎細璁惧��
+ //鍥犱负UniqueKey__c鍒ゆ柇浜咲ataMigration_Flag__c鎵�浠ヨ繖閲屼篃闇�瑕佸垽鏂� 妫�绱㈢殑鏃跺�欏洜涓鸿鍋嘔nsert鎵�浠ヤ笉闇�瑕佽缃�
+ // TODO bp3 DetailHandler閲�, 瀵笷SD璁惧�肩殑鍦版柟 闇�瑕佸湪Rental_Apply__c鐨凥andler閲�, 鍙樻垚鎵瑰噯鏅�, 涔熻璁惧�笺��
+ if (Trigger.isInsert && nObj.DataMigration_Flag__c == false) {
+ nObj.Is_Body__c = nObj.Is_Body_F__c;
+ if (String.isNotBlank(nObj.Fixture_Set_Detail__c)) {
+ nObj.FSD_Id__c = nObj.Fixture_Set_Detail__c;
}
- //涓�瑙團irst鏇存柊
- if (!raesMap.isEmpty()) {
- update raesMap.values();
+ // 272銉併偙銉冦儓
+ // Create_State__c涓虹┖骞朵笖鐢宠涔︾殑鏍囧噯鎵瑰噯鏃堕棿涓嶄负绌虹殑鏃跺�欒缃负1
+ // 1 --- 杩藉姞闄勫睘鍝�
+ // 0 --- Cancel鎷疯礉
+ // null --- 鏅�氭柊瑙�
+ if (
+ nObj.Create_State__c == null &&
+ !FixtureUtil.isRepairRenewal &&
+ nObj.Rental_Apply_Request_approval_time_F__c != null &&
+ nObj.Substitute_Select_Again__c == false && // OLY_OCM-404 鍒嗛厤浠f浛鍝�
+ // 鍔炰簨澶勫垎閰嶆椂杩藉姞鐨勬槑缁嗕笉绠楄拷鍔犻檮灞炲搧
+ nObj.RA_RecordTypeId__c.substring(0, 15) !=
+ agencyRecordTypeId.substring(0, 15)
+ ) {
+ nObj.Create_State__c = 1;
}
- }
+ nObj.FSD_Is_Optional__c = nObj.FSD_Is_Optional_F__c;
+ // 鍔炰簨澶勫湪鍒嗛厤涓己鍒惰涓簍rue鏃讹紝涓嶄粠FSD鎷疯礉
+ if (
+ nObj.RA_RecordTypeId__c.substring(0, 15) !=
+ agencyRecordTypeId.substring(0, 15) || !nObj.FSD_Is_OneToOne__c
+ ) {
+ nObj.FSD_Is_OneToOne__c = nObj.FSD_Is_OneToOne_F__c;
+ }
+ nObj.FSD_Name_CHN__c = nObj.Fixture_Name_F__c;
+ nObj.FSD_OneToOneAccessory_Cnt__c = nObj.FSD_OneToOneAccessory_Cnt_F__c;
+ nObj.FSD_Fixture_Model_No__c = nObj.Fixture_Model_No_F__c;
+ if (
+ nObj.DataMigration_Flag__c == false &&
+ (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))
+ ) {
+ nObj.Fixture_Model_No_text__c = nObj.Fixture_Model_No_F__c;
+ }
+ nObj.CreatedBy_ProfileId__c = UserInfo.getProfileId();
+ // nObj.ApplyPersonAppended__c = nObj.ApplyPersonAppended_F__c;
+ }
+ if (
+ nObj.DeliverySlip__c != null &&
+ nObj.DataMigration_Flag__c == false &&
+ (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))
+ ) {
+ if (nObj.Shippment_loaner_time__c == null) {
+ nObj.Shippment_loaner_time__c = nObj.Shippment_loaner_time2__c;
+ }
+ }
+ nObj.DeliverySlip_Text__c = nObj.DeliverySlip__c;
+ nObj.Return_DeliverySlip_Text__c = nObj.Return_DeliverySlip__c;
+ nObj.Received_Confirm_Text__c = nObj.Received_Confirm_F__c;
+ //澶囧搧鍙戣揣鎶ラ敊瀵瑰簲 20230413 by lc Start
+ nObj.Detail_Not_Finish_Text__c = !nObj.Detail_Finish__c;
+ //澶囧搧鍙戣揣鎶ラ敊瀵瑰簲 20230413 by lc End
+ Rental_Apply_Equipment_Set_Detail__c oObj = null;
+ if (Trigger.isUpdate) {
+ oObj = oldMap.get(nObj.Id);
+ //鍑哄簱鍓嶆鏌G銇牬鍚堛偔銉c兂銈汇儷銇椼伨銇�
+ if (
+ oObj.Inspection_result__c != 'NG' &&
+ nObj.Inspection_result__c == 'NG'
+ ) {
+ nObj.Cancel_Select__c = true;
+ nObj.Loaner_cancel_reason__c = '鍏朵粬'; // 20210830 ljh SFDC-C448KZ add
+ nObj.Cancel_Reason__c = '閲嶆柊鍒嗛厤';
+ nObj.Loaner_cancel_Remarks__c = '鍑哄簱鍓嶆鏌G';
+ }
+ // OLY_OCM-435瀵惧繙 start
+ // 澶囧搧鎬ц兘浼樺寲鏀逛慨 20230312 by lc Start
+ //String userid = UserInfo.getUserId();
+ // 澶囧搧鎬ц兘浼樺寲鏀逛慨 20230312 by lc End
+ DateTime now = System.now();
+ if (
+ oObj.Inspection_result__c != nObj.Inspection_result__c &&
+ String.isNotBlank(nObj.Inspection_result__c)
+ ) {
+ nObj.Pre_inspection_time__c = now;
+ //20210428 ljh 1719 update start
+ //nObj.Inspection_staff__c = userid;
+ nObj.Inspection_staff__c = nObj.RA_RecordTypeId__c ==
+ Schema.SObjectType.Rental_Apply__c.getRecordTypeInfosByDeveloperName()
+ .get('AgencyRequest')
+ .getRecordTypeId()
+ ? null
+ : userid;
+ //20210428 ljh 1719 update start
+ }
- // afterdelete銇伩
- private void deleteReFirst() {
- Map<Id, Rental_Apply_Equipment_Set__c> raesMap = new Map<Id, Rental_Apply_Equipment_Set__c>();
- for (Rental_Apply_Equipment_Set_Detail__c oObj : oldList) {
- if (oObj.Is_First_RAESD_F__c == true) {
- Rental_Apply_Equipment_Set__c raes = new Rental_Apply_Equipment_Set__c(
- Id = oObj.Rental_Apply_Equipment_Set__c,
- First_RAESD__c = null);
- raesMap.put(oObj.Rental_Apply_Equipment_Set__c, raes);
- }
+ if (
+ oObj.Check_lost_Item_Final__c != nObj.Check_lost_Item_Final__c &&
+ String.isNotBlank(nObj.Check_lost_Item_Final__c)
+ ) {
+ nObj.Lost_item_check_time_Final__c = now;
+ nObj.Lost_item_check_staff_Final__c = userid;
}
- //淇敼涓�瑙堢殑FirstMap
- if (raesMap.isEmpty()) {
- return;
+
+ if (
+ oObj.Check_lost_Item__c != nObj.Check_lost_Item__c &&
+ String.isNotBlank(nObj.Check_lost_Item__c)
+ ) {
+ nObj.Lost_item_check_time__c = now;
+ nObj.Lost_item_check_staff__c = userid;
}
- if (!raesMap.isEmpty()) {
- List<Rental_Apply_Equipment_Set_Detail__c> raess = [Select Id, Rental_Apply_Equipment_Set__c
- From Rental_Apply_Equipment_Set_Detail__c
- Where Rental_Apply_Equipment_Set__c = :raesMap.keySet()
- and Cancel_Select__c = False
- //涓�瑕с倐鍓婇櫎銇椼仧銈夋洿鏂般仐銇俱仜銈�
- and IsDeleted = false
- // RAESD_SortInt_F__c -> IndexFromUniqueKey_Text__c(澶囧搧閰嶅鏄庣粏.SortInt__c)
- // 1搴旇鏄富浣�
- order by Rental_Apply_Equipment_Set__c, IndexFromUniqueKey_Text__c ASC nulls last];
- Id raesId = null;
- // 涓�浠剁洰銈扚irst_RAESD__c銇ō瀹�
- for (Rental_Apply_Equipment_Set_Detail__c raes : raess) {
- if (raesId != raes.Rental_Apply_Equipment_Set__c) {
- raesMap.get(raes.Rental_Apply_Equipment_Set__c).First_RAESD__c = raes.Id;
- raesId = raes.Rental_Apply_Equipment_Set__c;
- }
- }
+
+ if (
+ oObj.CDS_complete__c != nObj.CDS_complete__c && nObj.CDS_complete__c
+ ) {
+ nObj.CDS_complete_time__c = now;
+ nObj.CDS_staff__c = userid;
}
- //涓�瑙團irst鏇存柊
- if (!raesMap.isEmpty()) {
- update raesMap.values();
+
+ if (
+ oObj.Inspection_result_after_Final__c !=
+ nObj.Inspection_result_after_Final__c &&
+ String.isNotBlank(nObj.Inspection_result_after_Final__c)
+ ) {
+ nObj.After_Inspection_time_Final__c = now;
+ nObj.Inspection_staff_After_Final__c = userid;
}
- }
- // 鏈�绲傜姸鎱嬪強銇矨sset澶夋洿
- private Boolean finishOrChangeAsset(Boolean isDelete, Rental_Apply_Equipment_Set_Detail__c oObj, Rental_Apply_Equipment_Set_Detail__c nObj) {
- Boolean rtn = false;
- if (isDelete) {
- // oObj 銈掔⒑瑾嶃仚銈嬨�乷ld銇� 銈傘仺銈傘仺 finish銇倐銇�乫alse銈掕繑銇欍��
- rtn = !(
- //鍥炲簱纭
- (oObj.Arrival_in_wh__c)
- //鍙栨秷鍒嗛厤, (涓嬫灦鍚�, 鍘熷垯闇�瑕佷笂鏋�, 鎵�浠ヤ笉鑳藉崟绾殑鏂紑)
- || (oObj.Cancel_Select__c == true && oObj.StockDown__c == false)
- //涓嬫灦鍓�, 鍒嗛厤澶囧搧鏈夊彉鍖� (鍙樻垚鍒殑閰嶅, or 鍙� null)
- || (oObj.Asset__c == null && oObj.StockDown__c == false)
- //鍙栨秷鍒嗛厤, (涓嬫灦鍚�, 鍘熷垯闇�瑕佷笂鏋�, 鎵�浠ヤ笉鑳藉崟绾殑鏂紑)
- || (oObj.Cancel_Select__c == true && nObj.StockDown__c == false)
- //鏀惧純娆犲搧
- || (oObj.Lost_item_giveup__c == true)
- //宸叉秷鑰�
- || (oObj.Check_lost_Item_F__c == '娑堣��')
- );
+
+ if (
+ oObj.Inspection_result_after__c != nObj.Inspection_result_after__c &&
+ String.isNotBlank(nObj.Inspection_result_after__c)
+ ) {
+ // 妫�娴嬬粨鏋滄洿鏂颁簡浣嗘椂闂存病鏈夋墜鍔ㄦ洿鏂帮紝鍒欐洿鏂版椂闂�
+ // 濡傛灉鎵嬪姩鏇存柊浜嗘椂闂达紝灏变笉鐢ㄥ啀鏇存柊
+ if (oObj.After_Inspection_time__c == nObj.After_Inspection_time__c) {
+ nObj.After_Inspection_time__c = now;
+ }
+ //20210716 ljh 1719 update start
+ //nObj.Inspection_staff_After__c = userid;
+ nObj.Inspection_staff_After__c = nObj.RA_RecordTypeId__c ==
+ Schema.SObjectType.Rental_Apply__c.getRecordTypeInfosByDeveloperName()
+ .get('AgencyRequest')
+ .getRecordTypeId()
+ ? null
+ : userid;
+ //20210716 ljh 1719 update start
+ }
+ // OLY_OCM-435瀵惧繙 end
+ if (nObj.Detail_Finish__c) {
+ nObj.RAESD_Status_Text__c = nObj.Id;
} else {
- rtn = (
- //鍥炲簱纭
- (!oObj.Arrival_in_wh__c && nObj.Arrival_in_wh__c)
- //鍙栨秷鍒嗛厤, (涓嬫灦鍚�, 鍘熷垯闇�瑕佷笂鏋�, 鎵�浠ヤ笉鑳藉崟绾殑鏂紑)
- || (oObj.Cancel_Select__c == false && nObj.Cancel_Select__c == true
- && nObj.StockDown__c == false)
- //涓嬫灦鍓�, 鍒嗛厤澶囧搧鏈夊彉鍖� (鍙樻垚鍒殑閰嶅, or 鍙� null)
- || (oObj.Asset__c != null && oObj.Asset__c != nObj.Asset__c
- && nObj.StockDown__c == false)
- //鍙栨秷鍒嗛厤, (涓嬫灦鍚�, 鍘熷垯闇�瑕佷笂鏋�, 鎵�浠ヤ笉鑳藉崟绾殑鏂紑)
- || (oObj.Cancel_Select__c == false && nObj.Cancel_Select__c == true
- && nObj.StockDown__c == false)
- //鏀惧純娆犲搧
- || (oObj.Lost_item_giveup__c == false && nObj.Lost_item_giveup__c == true
- && oObj.Check_lost_Item_F__c != '娑堣��')
- //宸叉秷鑰�
- || (oObj.Check_lost_Item_F__c != '娑堣��' && nObj.Check_lost_Item_F__c == '娑堣��'
- && oObj.Lost_item_giveup__c == false)
+ nObj.RAESD_Status_Text__c = nObj.RAESD_Status__c;
+ }
+ }
+ Rental_Apply_Equipment_Set__c raes = raesdMap.get(
+ nObj.Rental_Apply_Equipment_Set__c
+ );
+ //鐢婚潰鏄剧ず鐢╟lone鍑烘潵鐨勬暟鎹笉闇�瑕佽缃甆ame
+ //IndexFromUniqueKey__c.format()浼氭姤閿� 瑕佸垽涓嶆槸Null
+ if (
+ nObj.DataMigration_Flag__c == false &&
+ raes != null &&
+ String.isNotBlank(raes.Fixture_Set__r.Name) &&
+ raes.IndexFromUniqueKey__c != null &&
+ nObj.IndexFromUniqueKey__c != null &&
+ (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))
+ ) {
+ String split_ApplyNum = nObj.RequestNoJoinStr2__c;
+ if (nObj.Rental_Apply_r_Name__c.contains('_')) {
+ // XXXX-YYYY_1 (ZZZZ_1)
+ List<String> split_ApplyNumList = nObj.Rental_Apply_r_Name__c.split(
+ '_'
+ );
+ String raName = split_ApplyNumList[split_ApplyNumList.size() - 2]; // XXXX-YYYY (ZZZZ)
+ split_ApplyNum = split_ApplyNumList[split_ApplyNumList.size() - 1]; // 1
+ split_ApplyNumList = raName.split('-'); // [XXXX, YYYY] ([ZZZZ])
+ if (split_ApplyNumList.size() > 1) {
+ // YYYY_1
+ split_ApplyNum =
+ split_ApplyNumList[split_ApplyNumList.size() - 1] +
+ '_' +
+ split_ApplyNum;
+ } else {
+ // ZZZZ_1
+ split_ApplyNum = nObj.Rental_Apply_r_Name__c;
+ }
+ }
+ nObj.Name =
+ split_ApplyNum +
+ ':' +
+ raes.Fixture_Set__r.Name +
+ ':' +
+ raes.IndexFromUniqueKey__c.format().leftpad(3, '0');
+
+ // 濡傛灉鏄垎閰嶄唬鏇垮搧鍚嶅瓧鍔�:Sub
+ if (nObj.Substitute_Select_Again__c) {
+ nObj.Name += ':Sub';
+ }
+
+ //涓�瑙堟椂鐢宠鑰呮敹璐G鐨勮瘽鍚嶅瓧娣诲姞NG
+ if (nObj.Received_Confirm_F__c == 'NG') {
+ nObj.Name += ':NG';
+ }
+ nObj.Name +=
+ ':' +
+ nObj.IndexFromUniqueKey_Text__c +
+ ':' +
+ nObj.IndexFromUniqueKey__c.format().leftpad(3, '0');
+ //鍙栨秷鐨勬椂鍊欏悕瀛楀姞Canceled
+ if (nObj.Cancel_Select__c) {
+ nObj.Name += ':Canceled';
+ }
+ }
+ nObj.Loaner_accsessary__c = nObj.Loaner_accsessary_F__c;
+ nObj.Loaner_centre_mail_address__c = nObj.Loaner_centre_mail_address_F__c;
+ // 20220117 ljh add start
+ // 鏇存柊鎺掗槦棰勮 鍏紡鎷锋枃鏈�
+ if (
+ Trigger.isUpdate &&
+ String.isBlank(nObj.Asset__c) == false &&
+ oObj.Asset__c != nObj.Asset__c
+ ) {
+ nObj.UQueueShippmentDateText__c = nObj.UQueueShippmentDate__c;
+ }
+ // 20220117 ljh add end
+ // 鍒嗛厤鏃�, 璁惧��
+ if (
+ String.isBlank(nObj.Asset__c) == false &&
+ nObj.Select_Time__c != null &&
+ (Trigger.isInsert ||
+ (oObj.Asset__c != nObj.Asset__c ||
+ oObj.Select_Time__c != nObj.Select_Time__c))
+ ) {
+ // 涓�瀵逛竴淇濈涓讳綋锛堝�熷嚭鏃讹級
+ // nObj.Main_OneToOne_FlagInt__c = nObj.Main_OneToOne_FlagInt__c;
+ if (
+ nObj.DataMigration_Flag__c == false &&
+ (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))
+ ) {
+ // 澶囧搧閰嶅鏄庣粏鍨嬪彿(鍊熷嚭鏃�)
+ if (String.isBlank(nObj.Fixture_Model_No_F__c)) {
+ nObj.addError(
+ '鍒嗛厤鐨凙sset:' + nObj.Asset__c + ', 娌℃湁璁惧畾 澶囧搧閰嶅鏄庣粏鍨嬪彿'
);
+ } else {
+ nObj.Fixture_Model_No_text__c = nObj.Fixture_Model_No_F__c;
+ }
}
- return rtn;
- }
- //before 鏁板紡銇�ゃ亴null銇仾銈嬪彲鑳芥�с亴銇傘倞銇俱仚銇仹銇撱亾銇с倐涓�鍥炪儊銈с儍銈仐銇俱仚
- private void formulaToTextCheck() {
- List<Rental_Apply_Equipment_Set_Detail__c> raesds = new List<Rental_Apply_Equipment_Set_Detail__c>();
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- //鏄庣粏鐘舵�佹病鏈変慨鐞嗗畬姣曟墍浠ヤ慨鐞嗗畬姣曠殑鏃跺�欎笉鎷疯礉鐘舵�佸埌Text瀛楁
- if ((nObj.Repair_Status_Text__c != nObj.Repair_Status_F__c
- && nObj.Repair_Status_F__c != '淇悊瀹屾瘯')
- || nObj.Return_Status_Text__c != nObj.Return_Status_F__c
- || nObj.Shipment_Status_Text__c != nObj.Shipment_Status_F__c
- || (nObj.ApplyPersonAppended__c != nObj.ApplyPersonAppended_F__c && Trigger.isInsert)
- ) {
- Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c(Id = nObj.Id);
- //鏄庣粏鐘舵�佹病鏈変慨鐞嗗畬姣曟墍浠ヤ慨鐞嗗畬姣曠殑鏃跺�欎笉鎷疯礉鐘舵�佸埌Text瀛楁
- if (nObj.Repair_Status_F__c != '淇悊瀹屾瘯') {
- raesd.Repair_Status_Text__c = nObj.Repair_Status_F__c;
- }
- raesd.Return_Status_Text__c = nObj.Return_Status_F__c;
- raesd.Shipment_Status_Text__c = nObj.Shipment_Status_F__c;
- if (Trigger.isInsert) {
- raesd.ApplyPersonAppended__c = nObj.ApplyPersonAppended_F__c;
- }
- raesds.add(raesd);
+ // 鏈鸿韩缂栧彿锛堝�熷嚭鏃讹級
+ nObj.SerialNumber_text__c = nObj.SerialNumber__c;
+ // 鎵�鍦ㄥ湴鍖�(鐪�) 鍊熷嚭鏃� #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
+ nObj.SalesProvince_before__c = nObj.SalesProvince__c;
+ // 鎵�鍦ㄥ湴鍖�(鏈儴) 鍊熷嚭鏃� #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
+ nObj.Salesdepartment_before__c = nObj.Salesdepartment__c;
+ // 浜у搧鍒嗙被(GI/SP)(鍊熷嚭鏃�) #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
+ nObj.Product_category_text__c = nObj.Product_category_F__c;
+ // 澶囧搧鍒嗙被(鍊熷嚭鏃�) #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
+ nObj.Equipment_Type_text__c = nObj.Equipment_Type_F__c;
+ // 澶囧搧鎴愭湰(鍊熷嚭鏃�)
+ nObj.Asset_cost_del_before__c = nObj.Asset_cost_del__c;
+ // 澶囧搧瀛樻斁鍦�(鍊熷嚭鏃�)
+ nObj.Internal_asset_location_before__c = nObj.Internal_asset_location__c;
+ //澶囧搧鍚嶇О(鍊熷嚭鏃�)
+ nObj.Fixture_Name_text__c = nObj.Fixture_Name_F__c;
+ // OLY_OCM-243 杩藉姞瀛楁瀵瑰簲 澶囧搧绠$悊缂栫爜(鍊熷嚭鏃�)
+ nObj.EquipmentSet_Managment_Code_text__c = nObj.EquipmentSet_Managment_Code__c;
+ // OLY_OCM-452 杩藉姞瀛楁瀵瑰簲 鍒�澶�(鍊熷嚭鏃�)
+ if (String.isNotBlank(nObj.Fixture_Set_Detail__c)) {
+ nObj.Is_Special_Product_Text__c = nObj.Is_Special_Product__c;
+ }
+ }
+ // 鎺掗槦鏃�, 瑕佹敞鎰� 璁惧�� 绉诲姩鍒版帓闃焍tn閲�
+ else if (
+ Trigger.isUpdate &&
+ String.isBlank(nObj.Asset__c) &&
+ oObj.Cancel_Select__c == false &&
+ // && oObj.Fixture_Model_No_text__c != nObj.Fixture_Model_No_text__c
+ (oObj.Queue_Number__c == 0 ||
+ oObj.Queue_Number__c == null) &&
+ nObj.Queue_Number__c > 0
+ ) {
+ // 鎺掗槦鏃堕噸鏂拌祴鍊糉ixture_Model_No_text__c 涓轰簡鎺掔殑涓嶆槸鏃odel_No
+ nObj.FSD_Fixture_Model_No__c = nObj.Fixture_Model_No_F__c;
+ // 澶囧搧閰嶅鏄庣粏鍨嬪彿(鍊熷嚭鏃�)
+ // nObj.Fixture_Model_No_text__c = nObj.Fixture_Model_No_F__c;
+ // 鎵�鍦ㄥ湴鍖�(鐪�) 鍊熷嚭鏃�
+ //nObj.SalesProvince_before__c = nObj.SalesProvince__c;
+ // // 鎵�鍦ㄥ湴鍖�(鏈儴) 鍊熷嚭鏃�
+ // nObj.Salesdepartment_before__c = nObj.Salesdepartment__c;
+ // // 浜у搧鍒嗙被(GI/SP)(鍊熷嚭鏃�)
+ // nObj.Product_category_text__c = nObj.Product_category_F__c;
+ // // 澶囧搧鍒嗙被(鍊熷嚭鏃�)
+ // nObj.Equipment_Type_text__c = nObj.Equipment_Type__c;
+ // // 澶囧搧瀛樻斁鍦�(鍊熷嚭鏃�)
+ // nObj.Internal_asset_location_before__c = nObj.Internal_asset_location__c;
+ }
+ // 鍏朵粬鏃跺��(鐢宠鏃�), null璁惧�� 鍜�
+ // 涓�瀵逛竴宸插垎閰嶇殑闄勫睘鍝�,涓讳綋閲嶆柊鎺掗槦鏃�,涓�瀵逛竴闄勫睘鍝侀渶瑕侀噸鏂版寜鐓х敵璇风殑閫昏緫閲嶆柊璧嬪��
+ else if (
+ (Trigger.isInsert && nObj.Cancel_Select__c == false) ||
+ (Trigger.isUpdate &&
+ String.isBlank(nObj.Asset__c) &&
+ oObj.Cancel_Select__c == false)
+ ) {
+ // 澶囧搧閰嶅鏄庣粏鍨嬪彿(鍊熷嚭鏃�)
+ if (
+ String.isBlank(nObj.Fixture_Model_No_text__c) &&
+ nObj.DataMigration_Flag__c == false &&
+ (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))
+ ) {
+ nObj.Fixture_Model_No_text__c = nObj.Fixture_Model_No_F__c;
+ }
+ // 鎵�鍦ㄥ湴鍖�(鐪�) 鍊熷嚭鏃� #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
+ if (String.isBlank(nObj.SalesProvince_before__c)) {
+ nObj.SalesProvince_before__c = nObj.SalesProvince__c;
+ }
+ // 鎵�鍦ㄥ湴鍖�(鏈儴) 鍊熷嚭鏃� #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
+ if (String.isBlank(nObj.Salesdepartment_before__c)) {
+ nObj.Salesdepartment_before__c = nObj.Salesdepartment__c;
+ }
+ // 浜у搧鍒嗙被(GI/SP)(鍊熷嚭鏃�) #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
+ if (String.isBlank(nObj.Product_category_text__c)) {
+ nObj.Product_category_text__c = nObj.Product_category_F__c;
+ }
+ // 澶囧搧鍒嗙被(鍊熷嚭鏃�) #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
+ if (String.isBlank(nObj.Equipment_Type_text__c)) {
+ nObj.Equipment_Type_text__c = nObj.Equipment_Type__c;
+ }
+ // 澶囧搧瀛樻斁鍦�
+ if (String.isBlank(nObj.Internal_asset_location_before__c)) {
+ nObj.Internal_asset_location_before__c = nObj.Internal_asset_location__c;
+ }
+ // 澶囧搧鍚嶇О(鍊熷嚭鏃�)
+ if (String.isBlank(nObj.Fixture_Name_text__c)) {
+ nObj.Fixture_Name_text__c = nObj.Fixture_Name_F__c;
+ }
+ // OLY_OCM-243 杩藉姞瀛楁瀵瑰簲 澶囧搧绠$悊缂栫爜(鍊熷嚭鏃�)
+ if (String.isBlank(nObj.EquipmentSet_Managment_Code_text__c)) {
+ nObj.EquipmentSet_Managment_Code_text__c = nObj.EquipmentSet_Managment_Code__c;
+ }
+ // OLY_OCM-452 杩藉姞瀛楁瀵瑰簲 鍒�澶�(鍊熷嚭鏃�)
+ if (String.isBlank(nObj.Is_Special_Product_Text__c)) {
+ nObj.Is_Special_Product_Text__c = nObj.Is_Special_Product__c;
+ }
+ } else {
+ // 鍙栨秷鐨勬儏鍐靛湪涓嬮潰鏈夎鍊�
+ }
+ if (
+ nObj.DataMigration_Flag__c == false &&
+ nObj.Cancel_Select__c == false &&
+ (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))
+ ) {
+ if (String.isBlank(nObj.Fixture_Model_No_text__c)) {
+ nObj.addError(
+ nObj.Id +
+ ':澶囧搧閰嶅鏄庣粏鍨嬪彿涓嶈兘涓虹┖, 澶囧搧閰嶅鏄庣粏=' +
+ nObj.Fixture_Set_Detail__c
+ );
+ }
+
+ // #OLY_OCM-654 鏁伴噺绠$悊鐨勮瘽,鎵�鍦ㄥ湴鍖�(鏈儴)&浜у搧鍒嗙被&澶囧搧鍒嗙被鐨勫垽鏂笉闇�瑕� Start
+ if ('鏁伴噺绠$悊' == nObj.Manage_type_F__c) {
+ // || false == nObj.Loaner_accsessary__c TODO: 闇�纭
+ if (String.isBlank(nObj.Internal_asset_location_before__c)) {
+ nObj.addError('澶囧搧瀛樻斁鍦颁笉鑳戒负绌�');
+ }
+ } else {
+ // #OLY_OCM-654 鏁伴噺绠$悊鐨勮瘽,鎵�鍦ㄥ湴鍖�(鏈儴)&浜у搧鍒嗙被&澶囧搧鍒嗙被鐨勫垽鏂笉闇�瑕� end
+ if (String.isBlank(nObj.Salesdepartment_before__c)) {
+ nObj.addError('鎵�鍦ㄥ湴鍖�(鏈儴)涓嶈兘涓虹┖');
+ }
+ if (String.isBlank(nObj.Internal_asset_location_before__c)) {
+ nObj.addError('澶囧搧瀛樻斁鍦颁笉鑳戒负绌�');
+ }
+ if (
+ String.isBlank(nObj.Product_category_text__c) && nObj.Is_Body__c
+ ) {
+ nObj.addError('浜у搧鍒嗙被(GI/SP)涓嶈兘涓虹┖');
+ }
+ if (
+ String.isBlank(nObj.Equipment_Type_text__c) &&
+ nObj.Is_Body__c &&
+ nObj.Demo_purpose1__c != '鍏朵粬'
+ ) {
+ nObj.addError('澶囧搧鍒嗙被涓嶈兘涓虹┖');
+ }
+ // if (String.isBlank(nObj.SalesProvince_before__c) && nObj.Is_Body__c) {
+ // nObj.addError('鎵�鍦ㄥ湴鍖�(鐪�)涓嶈兘涓虹┖');
+ // }
+ }
+ }
+ if (
+ nObj.DataMigration_Flag__c == false &&
+ String.isNotBlank(nObj.FSD_Id__c) &&
+ (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))
+ ) {
+ //鍑哄簱鎸囩ず鏇存柊鏄庣粏鐨刱ey
+ nObj.UniqueKey__c =
+ nObj.RequestNoJoinStr2__c +
+ ':' +
+ nObj.Rental_Apply_Equipment_Set__c +
+ ':' +
+ nObj.FSD_Id__c +
+ ':' +
+ nObj.IndexFromUniqueKey__c;
+ if (nObj.Cancel_Select__c) {
+ nObj.UniqueKey__c += nObj.Id;
+ // 涓嬫灦鍚庣殑鍙栨秷鍔�;
+ if (nObj.StockDown__c) {
+ nObj.UniqueKey__c += ';' + nObj.Id;
+ }
+ // nObj.Queue_Number__c = null;
+ if (
+ nObj.StockDown__c &&
+ nObj.Inspection_result__c != 'NG' &&
+ String.isBlank(nObj.DeliverySlip__c)
+ ) {
+ nObj.OnStock_By_Cancel__c = true;
+ // nObj.Inspection_result_after_Flag_Text__c = 'true';
+ }
+ }
+ }
+ System.debug(nObj.IndexFromUniqueKey__c + 'key is' + nObj.UniqueKey__c);
+ // 鍙栨秷鍒嗛厤
+ //Action 18 銇倛銇c仸銈儯銉炽偦銉伄鍫村悎
+ //鍊熷嚭澶囧搧Set涓�瑙堟槑缁�.淇濇湁璁惧(Link)
+ //鍊熷嚭澶囧搧Set涓�瑙堟槑缁�.鍒嗛厤鏃堕棿
+ //鍊熷嚭澶囧搧Set涓�瑙堟槑缁�.宸插仛鍑哄簱鎸囩ず
+ //鍊熷嚭澶囧搧Set涓�瑙堟槑缁�.鍑哄簱鎸囩ず鏃堕棿
+ if (Trigger.isInsert || oObj.Cancel_Select__c != nObj.Cancel_Select__c) {
+ if (nObj.Cancel_Select__c) {
+ nObj.Cancel_Date__c = System.today();
+ nObj.Cancel_Time__c = MainFixtureSelectController.getCurrentTime();
+ nObj.Cancel_Mem__c = UserInfo.getUserId();
+ if (nObj.AgencyTempCancel__c) {
+ if (nObj.AgencyTempCancelTime__c != null) {
+ Datetime dt = nObj.AgencyTempCancelTime__c;
+ nObj.Cancel_Time__c = Time.newInstance(
+ dt.hour(),
+ dt.minute(),
+ dt.second(),
+ dt.millisecond()
+ );
+ nObj.Cancel_Date__c = Date.newinstance(
+ dt.year(),
+ dt.month(),
+ dt.day()
+ );
}
+ }
+ nObj.AgencyTempCancel__c = false; // 鐪熷彇娑堟椂鎶婁复鏃跺彇娑堟爣璁版竻鎺�
+ nObj.AgencyTempCancelTime__c = null;
+ if (nObj.StockDown__c == false) {
+ nObj.Asset__c = null;
+ nObj.Select_Time__c = null;
+ nObj.Shipment_request_time2__c = null;
+ nObj.Shipment_request__c = false;
+ // 鏍规嵁OLY_OCM-243璁拌浇,鍙栨秷涔熼渶瑕佹竻闄ゆ帴鍊熷嚭鏃剁浉鍏崇殑瀛楁
+ if (
+ nObj.DataMigration_Flag__c == false &&
+ (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))
+ ) {
+ // 澶囧搧閰嶅鏄庣粏鍨嬪彿(鍊熷嚭鏃�)
+ nObj.Fixture_Model_No_text__c = nObj.FSD_Fixture_Model_No__c;
+ }
+ // 鏈鸿韩缂栧彿锛堝�熷嚭鏃讹級
+ nObj.SerialNumber_text__c = null;
+ // 鎵�鍦ㄥ湴鍖�(鐪�) 鍊熷嚭鏃� #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
+ nObj.SalesProvince_before__c = null;
+ // 鎵�鍦ㄥ湴鍖�(鏈儴) 鍊熷嚭鏃� #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
+ nObj.Salesdepartment_before__c = null;
+ // 浜у搧鍒嗙被(GI/SP)(鍊熷嚭鏃�) #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
+ nObj.Product_category_text__c = null;
+ // 澶囧搧鍒嗙被(鍊熷嚭鏃�) #OLY_OCM-654:鍥犱负鏄祴鍊兼墍浠ヤ笉淇敼
+ nObj.Equipment_Type_text__c = null;
+ // 澶囧搧鎴愭湰(鍊熷嚭鏃�)
+ nObj.Asset_cost_del_before__c = null;
+ // 澶囧搧瀛樻斁鍦�(鍊熷嚭鏃�)
+ nObj.Internal_asset_location_before__c = null;
+ //澶囧搧鍚嶇О(鍊熷嚭鏃�)
+ nObj.Fixture_Name_text__c = nObj.FSD_Name_CHN__c;
+ // 澶囧搧绠$悊缂栫爜(鍊熷嚭鏃�)
+ nObj.EquipmentSet_Managment_Code_text__c = null;
+ }
+ //20201118 ljh add
+ else {
+ String ra_RecordTypeId = DEVELOPERNAMEMAP.get('AgencyRequest')
+ .getRecordTypeId();
+ //System.debug('ra_RecordTypeId:'+ra_RecordTypeId);
+ if (
+ ra_RecordTypeId != null &&
+ nObj.RA_RecordTypeId__c.substring(0, 15) ==
+ ra_RecordTypeId.substring(0, 15)
+ ) {
+ //nObj.Inspection_result__c = 'OK';
+ nObj.Inspection_result_NG__c = null;
+ nObj.Arrival_in_wh__c = true;
+ nObj.Arrival_wh_time__c = System.now();
+ nObj.Return_wh_chenk_staff__c = Userinfo.getUserId();
+ nObj.Arrival_wh_Result_Agency__c = 'OK';
+ }
+ }
+ //20201118 ljh add
+ } else {
+ nObj.Cancel_Date__c = null;
+ nObj.Cancel_Time__c = null;
+ nObj.Cancel_Mem__c = null;
+ //nObj.Cancel_Reason__c = null;
}
- if (!raesds.isEmpty()) {
- update raesds;
+ }
+ // 褰掕繕鍚嶤DS
+ if (Trigger.isInsert || oObj.CDS_complete__c != nObj.CDS_complete__c) {
+ if (nObj.CDS_complete__c) {
+ nObj.CDS_complete_time__c = System.now();
+ nObj.CDS_staff__c = UserInfo.getUserId();
+ } else {
+ nObj.CDS_complete_time__c = null;
+ nObj.CDS_staff__c = null;
}
+ }
+ System.debug(nObj.Return_Status_F__c);
+ // 蹇呫仛鏈�寰屻仹缃亸
+ //鍔广亱銇亜銇牬鍚堛亴銇傘倞銇俱仚銇仹After銇с倓銈娿伨銇�
+ // nObj.Repair_Status_Text__c = nObj.Repair_Status_F__c;
+ // nObj.Return_Status_Text__c = nObj.Return_Status_F__c;
+ // nObj.Shipment_Status_Text__c = nObj.Shipment_Status_F__c;
+ nObj.Canceled_Id__c = nObj.Canceled__c;
+ if (
+ Trigger.isUpdate &&
+ ((oObj.Inspection_result_after_Final__c != 'NG' &&
+ nObj.Inspection_result_after_Final__c == 'NG' &&
+ nObj.Inspection_result_after_NG_Final__c == '缁翠慨') ||
+ (oObj.Inspection_result_after__c != 'NG' &&
+ nObj.Inspection_result_after__c == 'NG' &&
+ nObj.Inspection_result_after_NG__c == '缁翠慨'))
+ ) {
+ nObj.Repair__c = null;
+ }
+
+ // OLY_OCM-531 Start 鎼伐浣滄祦瑙勫垯
+ if (
+ nObj.Check_lost_Item_F__c == '娆犲搧' &&
+ nObj.Loaner_Giveup_Time__c == null &&
+ nObj.Lost_item_giveup__c == true
+ ) {
+ nObj.Loaner_Giveup_Time__c = Datetime.now();
+ }
+
+ if (nObj.RAESD_Status__c == '鎺掗槦涓�' && nObj.Queue_Day_Text__c == null) {
+ nObj.Queue_Day_Text__c = nObj.Queue_Day__c;
+ nObj.Queue_Time_Text__c = nObj.Queue_Time__c;
+ }
+
+ // OLY_OCM-531 End
+ if (
+ Trigger.isUpdate &&
+ oObj.Confirm_Lost_Date__c != null &&
+ oObj.Check_lost_Item_F__c != nObj.Check_lost_Item_F__c &&
+ oObj.Check_lost_Item_F__c == '娆犲搧'
+ ) {
+ nObj.Confirm_Lost_Date__c = null;
+ }
+
+ if (
+ Trigger.isUpdate &&
+ oObj.Shipment_request_time2__c != nObj.Shipment_request_time2__c &&
+ nObj.Shipment_request_time2__c != null &&
+ nObj.Is_Body__c &&
+ shipment_requestedRaIdStaticSet.contains(nObj.Rental_Apply__c) == false
+ ) {
+ shipment_requestedRaIdStaticSet.add(nObj.Rental_Apply__c);
+ shipment_requestedRaIdSet.add(nObj.Rental_Apply__c);
+ }
}
- // 20211116 ljh 涓嬩竴娆″�熺敤棰勮鍑哄簱鏃堕棿 鐨勮祴鍊� 鍥炴敹鍚�-妫�娴嬬粨鏋淥K閫昏緫 start
- /*
+ }
+ /*
+ * Asset 銇甉uantity鏇存柊
+ * changeAssetCount()鏂规硶銇ut_of_wh__c銆丷ental_Count__c 鍑�1
+ */
+ private void changeAsset() {
+ if (Trigger.isUpdate && Trigger.isAfter) {
+ if (assMap.isEmpty()) {
+ return;
+ }
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ if (!assMap.containsKey(nObj.Asset__c)) {
+ continue;
+ }
+ Rental_Apply_Equipment_Set_Detail__c oObj = null;
+ if (Trigger.isUpdate) {
+ oObj = oldMap.get(nObj.Id);
+ }
+ Asset ass = assMap.get(nObj.Asset__c);
+ // Abandoned_Inventory__c null -> 0
+ if (ass.Abandoned_Inventory__c == null) {
+ ass.Abandoned_Inventory__c = 0;
+ }
+ // Abandoned_RealThing__c null -> 0
+ if (ass.Abandoned_RealThing__c == null) {
+ ass.Abandoned_RealThing__c = 0;
+ }
+ if (ass.CountForRepair__c == null) {
+ ass.CountForRepair__c = 0;
+ }
+
+ if (ass.Confirm_Lost_Count__c == null) {
+ ass.Confirm_Lost_Count__c = 0;
+ }
+ if (
+ String.isBlank(oObj.Check_lost_Item_F__c) &&
+ nObj.Check_lost_Item_F__c == 'OK'
+ ) {
+ //鏈叆鍔涖亱銈夋瑺鍝併伀澶夋洿鏅備綍銈傘仐銇俱仜銈�
+ } else if (
+ String.isBlank(oObj.Check_lost_Item_F__c) &&
+ nObj.Check_lost_Item_F__c == '娆犲搧' &&
+ nObj.Lost_item_giveup__c == false
+ ) {
+ //鏈叆鍔涖亱銈夋瑺鍝併伀澶夋洿鏅備綍銈傘仐銇俱仜銈�
+ } else if (
+ String.isBlank(oObj.Check_lost_Item_F__c) &&
+ nObj.Check_lost_Item_F__c == '娆犲搧' &&
+ nObj.Lost_item_giveup__c == true
+ ) {
+ //鏈叆鍔涖亱銈夋瑺鍝佹斁妫勩伀澶夋洿鏅� 鏀惧純娆犲搧鍥炴敹锛堜涪澶憋級銇仺銇� 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍔�1
+ ass.Abandoned_Inventory__c += 1;
+ if (oObj.Confirm_Lost_Date__c != null) {
+ ass.Confirm_Lost_Count__c -= 1;
+ }
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ String.isBlank(oObj.Check_lost_Item_F__c) &&
+ nObj.Check_lost_Item_F__c == '娑堣��'
+ ) {
+ //鏈叆鍔涖亱銈夋秷鑰椼伀澶夋洿鏅俀uantity銈�-1
+ ass.Quantity -= 1;
+ ass.ChangeQuantityReason__c = '娑堣��';
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Check_lost_Item_F__c == 'OK' &&
+ String.isBlank(nObj.Check_lost_Item_F__c)
+ ) {
+ //OK銇嬨倝绌虹櫧銇鏇存檪浣曘倐銇椼伨銇涖倱
+ } else if (
+ oObj.Check_lost_Item_F__c == 'OK' &&
+ nObj.Check_lost_Item_F__c == '娆犲搧' &&
+ nObj.Lost_item_giveup__c == false
+ ) {
+ //OK銇嬨倝娆犲搧銇鏇存檪浣曘倐銇椼伨銇涖倱
+ } else if (
+ oObj.Check_lost_Item_F__c == 'OK' &&
+ nObj.Check_lost_Item_F__c == '娆犲搧' &&
+ nObj.Lost_item_giveup__c == true
+ ) {
+ //OK銇嬨倝娆犲搧鏀炬銇鏇存檪 鏀惧純娆犲搧鍥炴敹锛堜涪澶憋級銇仺銇� 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍔�1
+ ass.Abandoned_Inventory__c += 1;
+ if (oObj.Confirm_Lost_Date__c != null) {
+ ass.Confirm_Lost_Count__c -= 1;
+ }
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Check_lost_Item_F__c == 'OK' &&
+ nObj.Check_lost_Item_F__c == '娑堣��'
+ ) {
+ //OK銇嬨倝娑堣�椼伀澶夋洿鏅俀uantity銈�-1
+ ass.Quantity -= 1;
+ ass.ChangeQuantityReason__c = '娑堣��';
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Check_lost_Item_F__c == '娆犲搧' &&
+ String.isBlank(nObj.Check_lost_Item_F__c) &&
+ oObj.Lost_item_giveup__c == false
+ ) {
+ if (oObj.Confirm_Lost_Date__c != null) {
+ ass.Confirm_Lost_Count__c -= 1;
+ }
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Check_lost_Item_F__c == '娆犲搧' &&
+ nObj.Check_lost_Item_F__c == 'OK' &&
+ oObj.Lost_item_giveup__c == false
+ ) {
+ if (oObj.Confirm_Lost_Date__c != null) {
+ ass.Confirm_Lost_Count__c -= 1;
+ }
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Check_lost_Item_F__c == '娆犲搧' &&
+ nObj.Check_lost_Item_F__c == '娆犲搧' &&
+ oObj.Lost_item_giveup__c == false &&
+ nObj.Lost_item_giveup__c == true
+ ) {
+ //娆犲搧銇嬨倝娆犲搧鏀炬銇鏇存檪 鏀惧純娆犲搧鍥炴敹锛堜涪澶憋級銇仺銇� 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍔�1
+ ass.Abandoned_Inventory__c += 1;
+ if (oObj.Confirm_Lost_Date__c != null) {
+ ass.Confirm_Lost_Count__c -= 1;
+ }
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Check_lost_Item_F__c == '娆犲搧' &&
+ nObj.Check_lost_Item_F__c == '娑堣��' &&
+ oObj.Lost_item_giveup__c == false
+ ) {
+ //娆犲搧銇嬨倝娑堣�椼伀澶夋洿鏅俀uantity銈�-1
+ ass.Quantity -= 1;
+ ass.ChangeQuantityReason__c = '娑堣��';
+ if (oObj.Confirm_Lost_Date__c != null) {
+ ass.Confirm_Lost_Count__c -= 1;
+ }
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Check_lost_Item_F__c == '娆犲搧' &&
+ String.isBlank(nObj.Check_lost_Item_F__c) &&
+ oObj.Lost_item_giveup__c == true
+ ) {
+ //娆犲搧鏀炬銇嬨倝绌虹櫧銇鏇存檪 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍑�1
+ ass.Abandoned_Inventory__c -= 1;
+ ass.Out_of_wh__c += 1;
+ ass.Rental_Count__c += 1;
+ ass.ChangeQuantityReason__c = '娆犲搧' + '->' + '';
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Check_lost_Item_F__c == '娆犲搧' &&
+ nObj.Check_lost_Item_F__c == 'OK' &&
+ oObj.Lost_item_giveup__c == true
+ ) {
+ //娆犲搧鏀炬銇嬨倝OK銇鏇存檪 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍑�1
+ ass.Abandoned_Inventory__c -= 1;
+ ass.Out_of_wh__c += 1;
+ ass.Rental_Count__c += 1;
+ ass.ChangeQuantityReason__c = '娆犲搧' + '->' + 'OK';
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Check_lost_Item_F__c == '娆犲搧' &&
+ nObj.Check_lost_Item_F__c == '娆犲搧' &&
+ oObj.Lost_item_giveup__c == true &&
+ nObj.Lost_item_giveup__c == false
+ ) {
+ //娆犲搧鏀炬銇嬨倝娆犲搧銇鏇存檪 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍑�1
+ ass.Abandoned_Inventory__c -= 1;
+ ass.Out_of_wh__c += 1;
+ ass.Rental_Count__c += 1;
+ ass.ChangeQuantityReason__c = '娆犲搧鏀惧純 -> ' + '娆犲搧';
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Check_lost_Item_F__c == '娆犲搧' &&
+ nObj.Check_lost_Item_F__c == '娑堣��' &&
+ oObj.Lost_item_giveup__c == true
+ ) {
+ //娆犲搧鏀炬銇嬨倝娑堣�椼伀澶夋洿鏅� 寰呭簾寮冩暟(涓㈠け/鐩樹簭)鍑�1 Quantity銈�-1
+ ass.Abandoned_Inventory__c -= 1;
+ ass.Quantity -= 1;
+ } else if (
+ oObj.Check_lost_Item_F__c == '娑堣��' &&
+ String.isBlank(nObj.Check_lost_Item_F__c)
+ ) {
+ //娑堣�椼亱銈夌┖鐧姐伀澶夋洿鏅俀uantity銈�+1
+ ass.Quantity += 1;
+ ass.Out_of_wh__c += 1;
+ ass.Rental_Count__c += 1;
+ ass.ChangeQuantityReason__c = '娑堣�� -> ' + '';
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Check_lost_Item_F__c == '娑堣��' &&
+ nObj.Check_lost_Item_F__c == 'OK'
+ ) {
+ //娑堣�椼亱銈夌┖鐧姐伀澶夋洿鏅俀uantity銈�+1
+ ass.Quantity += 1;
+ ass.Out_of_wh__c += 1;
+ ass.Rental_Count__c += 1;
+ ass.ChangeQuantityReason__c = '娑堣�� -> ' + 'OK';
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Check_lost_Item_F__c == '娑堣��' &&
+ nObj.Check_lost_Item_F__c == '娆犲搧' &&
+ nObj.Lost_item_giveup__c == false
+ ) {
+ //娑堣�椼亱銈夋瑺鍝併伀澶夋洿鏅俀uantity銈�+1
+ ass.Quantity += 1;
+ ass.Out_of_wh__c += 1;
+ ass.Rental_Count__c += 1;
+ ass.ChangeQuantityReason__c = '娑堣�� -> 娆犲搧';
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Check_lost_Item_F__c == '娑堣��' &&
+ nObj.Check_lost_Item_F__c == '娆犲搧' &&
+ nObj.Lost_item_giveup__c == true
+ ) {
+ //娑堣�椼亱銈夋瑺鍝佹斁妫勩伀澶夋洿鏅� 寰呭簾寮冩暟(涓㈠け/鐩樹簭)+1 Quantity銈�+1
+ ass.Abandoned_Inventory__c += 1;
+ ass.Quantity += 1;
+ }
+ // 缁翠慨
+ if (
+ oObj.Arrival_in_wh__c == false &&
+ nObj.Arrival_in_wh__c == true &&
+ nObj.Arrival_wh_Result_Agency__c == '寰呬慨鐞�'
+ ) {
+ ass.CountForRepair__c += 1;
+ assUpdMap.put(ass.Id, ass);
+ }
+ //搴熷純
+ if (
+ oObj.Arrival_in_wh__c == false &&
+ nObj.Arrival_in_wh__c == true &&
+ (nObj.Inspection_result_after_NG_F__c == '搴熷純' ||
+ //鍑哄簱鍓嶆娴嬪簾寮冪殑鏃跺�欎篃闇�瑕佸垽鏂�
+ nObj.Inspection_result_NG__c == '搴熷純')
+ ) {
+ ass.Abandoned_RealThing__c += 1;
+ ass.ChangeQuantityReason__c = FixtureUtil.raesdStatusMap.get(
+ FixtureUtil.HistoryStatus.Dai_Fei_Qi.ordinal()
+ );
+ assUpdMap.put(ass.Id, ass);
+ } else if (
+ oObj.Arrival_in_wh__c == true &&
+ nObj.Arrival_in_wh__c == false &&
+ (oObj.Inspection_result_after_NG_F__c == '搴熷純' ||
+ //鍑哄簱鍓嶆娴嬪簾寮冪殑鏃跺�欎篃闇�瑕佸垽鏂�
+ oObj.Inspection_result_NG__c == '搴熷純')
+ ) {
+ ass.Abandoned_RealThing__c -= 1;
+ ass.Out_of_wh__c += 1;
+ ass.Rental_Count__c += 1;
+ // ass.Freeze_sign__c = true; // OLY_OCM-689 鍒犻櫎鍐荤粨瀛楁鐨勬洿鏂�
+ String rea = nObj.Inspection_result_after_NG_F__c == '搴熷純'
+ ? '寰呯Щ鑷虫姤搴熷尯'
+ : nObj.Inspection_result_after_NG_F__c;
+ ass.ChangeQuantityReason__c =
+ FixtureUtil.raesdStatusMap.get(
+ FixtureUtil.HistoryStatus.Dai_Fei_Qi.ordinal()
+ ) +
+ ' ->' +
+ rea;
+ assUpdMap.put(ass.Id, ass);
+ }
+ //寰呭簾寮�
+ if (
+ nObj.RAESD_Status__c ==
+ FixtureUtil.raesdStatusMap.get(
+ FixtureUtil.HistoryStatus.Dai_Fei_Qi.ordinal()
+ ) &&
+ oObj.RAESD_Status__c != nObj.RAESD_Status__c &&
+ ass.Manage_type__c == '涓綋绠$悊'
+ ) {
+ ass.Status = FixtureUtil.assetStatusMap.get(
+ FixtureUtil.AssetStatus.Dai_Fei_Qi.ordinal()
+ );
+ // ass.Freeze_sign__c = true;
+ assUpdMap.put(ass.Id, ass);
+ }
+ // 鍔炰簨澶勫洖搴撶粨鏋滀慨鏀�
+ if (
+ oObj.Arrival_in_wh__c &&
+ nObj.Arrival_in_wh__c &&
+ oObj.Arrival_wh_Result_Agency__c != nObj.Arrival_wh_Result_Agency__c
+ ) {
+ switch on oObj.Arrival_wh_Result_Agency__c {
+ when '绉昏嚦鎶ュ簾鍖�' {
+ ass.Abandoned_RealThing__c -= 1;
+ }
+ when '寰呬慨鐞�' {
+ ass.CountForRepair__c -= 1;
+ }
+ }
+ switch on nObj.Arrival_wh_Result_Agency__c {
+ when '绉昏嚦鎶ュ簾鍖�' {
+ ass.Abandoned_RealThing__c += 1;
+ }
+ when '寰呬慨鐞�' {
+ ass.CountForRepair__c += 1;
+ }
+ }
+ assUpdMap.put(ass.Id, ass);
+ }
+ // //宸叉秷鑰�
+ // else if (nObj.Check_lost_Item_Final__c == '娑堣��'
+ // && oObj.Check_lost_Item_Final__c != nObj.Check_lost_Item_Final__c
+ // && ass.Manage_type__c == '涓綋绠$悊') {
+ // ass.Status = FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Yi_Xiao_Hao.ordinal());
+ // assUpdMap.put(ass.Id, ass);
+ // }
+ //涓㈠け
+ // else if (nObj.Lost_item_giveup__c == true
+ // && oObj.Lost_item_giveup__c != nObj.Lost_item_giveup__c
+ // && ass.Manage_type__c == '涓綋绠$悊') {
+ // ass.Status = FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Diu_Shi.ordinal());
+ // assUpdMap.put(ass.Id, ass);
+ // }
+ // else if (ass.Manage_type__c == '鏁伴噺绠$悊' && assMap.containsKey(ass.Id)) {
+ // if (ass.Quantity != null && ass.Quantity > 0) {
+ // if (ass.Status != FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Ke_Yi_Fen_Pei.ordinal())) {
+ // ass.Status = FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Ke_Yi_Fen_Pei.ordinal());
+ // assUpdMap.put(ass.Id, ass);
+ // }
+ // }
+ // else {
+ // if (ass.Status != FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Mei_You_Ku_Cun.ordinal())) {
+ // ass.Status = FixtureUtil.assetFixtureStatusMap.get(FixtureUtil.AssetFixtureStatus.Mei_You_Ku_Cun.ordinal());
+ // assUpdMap.put(ass.Id, ass);
+ // }
+ // }
+ // }
+ }
+ }
+ }
+ /*
+ * 鍥炲簱纭 OFF -> ON:
+ * 鍙栨秷鍒嗛厤 OFF -> ON:
+ * 鏀惧純娆犲搧 OFF -> ON
+ * 宸叉秷鑰�
+ *
+ * 娓呯┖Asset 鏈�鏂板鍝佺敵璇峰�熷嚭鏄庣粏 Last_Reserve_RAES_Detail__c
+ * (nObj.Asset__c 澶夋洿銇椼仾銇勩仧銈併�乧hangeAssetLast()銇с偗銉偄銇с亶銇亜銇熴倎銆併亾銇撱仹銈儶銈�)
+ *
+ * 銈儵銈广伄 assUpdMap 銈掓洿鏂般仚銈嬨仩銇�
+ */
+ private void clearLastReserveRAESD() {
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
+ // 涓讳綋鍜岄檮灞炲搧
+ if (finishOrChangeAsset(Trigger.isDelete, oObj, nObj)) {
+ Asset ass = assMap.get(nObj.Asset__c);
+ if (assUpdMap.containsKey(nObj.Asset__c)) {
+ ass = assUpdMap.get(nObj.Asset__c);
+ }
+ // 杩欓噷 浼氬嚭鐜� assUpdMap 鏈� 浣嗘槸 assMap 娌℃湁鐨勬儏鍐�
+ if (
+ ass == null &&
+ //鍒嗛厤澶囧搧鏈夊彉鍖� (涓嬫灦鍓�)
+ (oObj.Asset__c != null &&
+ oObj.Asset__c != nObj.Asset__c &&
+ nObj.StockDown__c == false)
+ ) {
+ ass = new Asset(Id = oObj.Asset__c);
+ }
+ if (ass == null) {
+ continue;
+ }
+ // 鏆傛椂鏀惧湪杩欓噷
+ if (oObj.Manage_type_F__c == '涓綋绠$悊') {
+ ass.Last_Reserve_RAES_Detail__c = null;
+ assUpdMap.put(ass.Id, ass);
+ }
+ }
+ }
+ }
+ //nObj.Asset__c銇屻亗銈嬪牬鍚堛�佸鏇淬仐銇熷牬鍚�
+ private void changeAssetLast() {
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
+ Asset nass = assMap.get(nObj.Asset__c);
+ if (assUpdMap.containsKey(nObj.Asset__c)) {
+ nass = assUpdMap.get(nObj.Asset__c);
+ } else if (String.isNotBlank(nObj.Asset__c)) {
+ nass = new Asset(Id = nObj.Asset__c);
+ }
+ Asset oass = assMap.get(oObj.Asset__c);
+ if (assUpdMap.containsKey(oObj.Asset__c)) {
+ oass = assUpdMap.get(oObj.Asset__c);
+ } else if (String.isNotBlank(oObj.Asset__c)) {
+ oass = new Asset(Id = oObj.Asset__c);
+ }
+ //nObj.Asset__c銇屻亗銈嬪牬鍚堛�佸鏇淬仐銇熷牬鍚�
+ if (
+ nObj.Asset__c != null &&
+ oObj.Asset__c != nObj.Asset__c &&
+ (oObj.Manage_type_F__c == '涓綋绠$悊' ||
+ nObj.Manage_type_F__c == '涓綋绠$悊')
+ ) {
+ if (nObj.Manage_type_F__c == '涓綋绠$悊') {
+ nass.Last_Reserve_RAES_Detail__c = nObj.Id;
+ assUpdMap.put(nass.Id, nass);
+ }
+ if (oObj.Manage_type_F__c == '涓綋绠$悊') {
+ oass.Last_Reserve_RAES_Detail__c = null;
+ assUpdMap.put(oass.Id, oass);
+ }
+ }
+ }
+ }
+ // 鍙栨秷鍒嗛厤 鐨勬椂鍊�, 闇�瑕佸湪 beforeSetValue() 閲屾妸 Asset__c 娓呴櫎
+ //鏄庣窗绲備簡銇ˋsset澶夋洿銇檪Out_of_wh__c銈掓洿鏂�
+ //afterupdate銇伩瀹熻
+ private void changeAssetCount() {
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
+ Asset nass = assMap.get(nObj.Asset__c);
+ if (assUpdMap.containsKey(nObj.Asset__c)) {
+ nass = assUpdMap.get(nObj.Asset__c);
+ } else if (String.isNotBlank(nObj.Asset__c)) {
+ nass = new Asset(Id = nObj.Asset__c);
+ }
+ Asset oass = assMap.get(oObj.Asset__c);
+ if (assUpdMap.containsKey(oObj.Asset__c)) {
+ oass = assUpdMap.get(oObj.Asset__c);
+ } else if (String.isNotBlank(oObj.Asset__c)) {
+ oass = new Asset(Id = oObj.Asset__c);
+ }
+ //Map銇獳sset銈掓柊瑕弍ush鏅傚�ゃ倰瑷畾
+ if (
+ oass != null &&
+ (oass.Out_of_wh__c == null ||
+ oass.Rental_Count__c == null ||
+ oass.Confirm_Lost_Count__c == null)
+ ) {
+ oass.Out_of_wh__c = oObj.Out_of_wh__c;
+ oass.Rental_Count__c = oObj.Rental_Count__c;
+ oass.Confirm_Lost_Count__c = oObj.Confirm_Lost_Count__c;
+ }
+ if (
+ nass != null &&
+ (nass.Out_of_wh__c == null ||
+ nass.Rental_Count__c == null ||
+ nass.Confirm_Lost_Count__c == null)
+ ) {
+ nass.Out_of_wh__c = nObj.Out_of_wh__c;
+ nass.Rental_Count__c = nObj.Rental_Count__c;
+ nass.Confirm_Lost_Count__c = nObj.Confirm_Lost_Count__c;
+ }
+ // 鏈�绲傜姸鎱嬪強銇ˋsset澶夋洿銇牬鍚�
+ if (finishOrChangeAsset(Trigger.isDelete, oObj, nObj)) {
+ System.debug('oass is ' + oass);
+ if (oass != null) {
+ if (oass.Out_of_wh__c != null && oass.Out_of_wh__c > 0) {
+ oass.Out_of_wh__c = oass.Out_of_wh__c - 1;
+ // assUpdMap.put(oass.Id, oass);
+ System.debug(
+ 'oass.Out_of_wh__c -1' + oass.Out_of_wh__c + ' Id = ' + nObj.Id
+ );
+ }
+ if (nObj.DeliverySlip__c != null) {
+ if (oass.Rental_Count__c != null && oass.Rental_Count__c > 0) {
+ oass.Rental_Count__c = oass.Rental_Count__c - 1;
+ }
+ }
+ assUpdMap.put(oass.Id, oass);
+ }
+ } else if (
+ oass != null &&
+ oObj.DeliverySlip__c != null &&
+ nObj.DeliverySlip__c == null
+ ) {
+ //鍙戣揣杩愯緭鍗� 鍒犻櫎鐨勬椂鍊欏凡鍊熷嚭鏁� -1 鍙戣揣Asset__c鍘熷垯涓嶄細鍙樻墍浠ュ氨鐩存帴鐢ㄤ笂闈㈢殑oass
+ // if (nObj.DeliverySlip__c != null) {
+ if (oass.Rental_Count__c != null && oass.Rental_Count__c > 0) {
+ oass.Rental_Count__c = oass.Rental_Count__c - 1;
+ assUpdMap.put(oass.Id, oass);
+ }
+ // }
+ }
+ if (
+ oObj.Confirm_Lost_Date__c == null &&
+ nObj.Confirm_Lost_Date__c != null
+ ) {
+ nass.Confirm_Lost_Count__c = nass.Confirm_Lost_Count__c + 1;
+ assUpdMap.put(nass.Id, nass);
+ } else if (
+ nObj.Confirm_Lost_Date__c == null &&
+ oObj.Confirm_Lost_Date__c != null &&
+ nass.Confirm_Lost_Count__c > 0
+ ) {
+ nass.Confirm_Lost_Count__c = nass.Confirm_Lost_Count__c - 1;
+ assUpdMap.put(nass.Id, nass);
+ }
+ //鍙戣揣杩愯緭鍗曡缃殑鏃跺�欏凡瑙i櫎鏁�+1
+ if (oObj.DeliverySlip__c == null && nObj.DeliverySlip__c != null) {
+ nass.Rental_Count__c = nass.Rental_Count__c + 1;
+ assUpdMap.put(nass.Id, nass);
+ }
+ //nObj.Asset__c銇屻亗銈嬪牬鍚堛�佸鏇淬仐銇熷牬鍚�
+ System.debug(LoggingLevel.INFO, '*** nObj.Asset__c: ' + nObj.Asset__c);
+ if (nObj.Asset__c != null && oObj.Asset__c != nObj.Asset__c) {
+ nass.Out_of_wh__c = nass.Out_of_wh__c + 1;
+ System.debug(
+ 'nass.Out_of_wh__c +1' + nass.Out_of_wh__c + ' Id = ' + nObj.Id
+ );
+ assUpdMap.put(nass.Id, nass);
+ }
+ }
+ }
+ // 鍚屻仒block 銇� 鎺掗槦銉偝銉笺儔 Queue_Number__c 銈抮efresh
+ // private void refreshQueueNumberByBlock() {
+ // for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ // Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
+ // // 鍚屻仒block 銇� 鎺掗槦澶夋洿銇屻亗銈嬪牬鍚�
+ // if (oObj.Cancel_Select__c == false
+ // && String.isBlank(oObj.Fixture_Model_No_text__c) == false
+ // && String.isBlank(oObj.Salesdepartment_before__c) == false
+ // && String.isBlank(oObj.Product_category_text__c) == false
+ // && String.isBlank(oObj.Equipment_Type_text__c) == false
+ // && oObj.Queue_Number__c > 0
+ // // 澶夊寲銈掔⒑瑾�
+ // && (oObj.Cancel_Select__c != nObj.Cancel_Select__c
+ // || oObj.Fixture_Model_No_text__c != nObj.Fixture_Model_No_text__c
+ // || oObj.Salesdepartment_before__c != nObj.Salesdepartment_before__c
+ // || oObj.Product_category_text__c != nObj.Product_category_text__c
+ // || oObj.Equipment_Type_text__c != nObj.Equipment_Type_text__c
+ // || (nObj.Queue_Number__c == 0 || nObj.Queue_Number__c == null))
+ // ) {
+ // if (executeed_refreshQueueNumber.contains(nObj.Id) && executeed_refreshQueueNumber.contains(oObj.Id)) {
+ // continue;
+ // }
+ // else if (executeed_refreshQueueNumber.contains(nObj.Id) == false) {
+ // executeed_refreshQueueNumber.add(nObj.Id);
+ // } else { // executeed_refreshQueueNumber.contains(oObj.Id) == false
+ // executeed_refreshQueueNumber.add(oObj.Id);
+ // }
+ // // TODO 鎯冲畾 鐢婚潰銇嬨倝銇�1 record 銇椼亱銇亜
+ // List<Rental_Apply_Equipment_Set_Detail__c> updateList = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ // List<Rental_Apply_Equipment_Set_Detail__c> refreshTargetList = [
+ // Select Id, Queue_Number__c
+ // from Rental_Apply_Equipment_Set_Detail__c
+ // where Cancel_Select__c = false
+ // and Fixture_Model_No_text__c = :oObj.Fixture_Model_No_text__c
+ // and Salesdepartment_before__c = :oObj.Salesdepartment_before__c
+ // and Product_category_text__c = :oObj.Product_category_text__c
+ // and Equipment_Type_text__c = :oObj.Equipment_Type_text__c
+ // and Queue_Number__c > 0
+ // Order by Queue_Number__c];
+ // for (Integer i = 0; i < refreshTargetList.size(); i++) {
+ // Rental_Apply_Equipment_Set_Detail__c refreshTarget = refreshTargetList[i];
+ // if (refreshTarget.Queue_Number__c != (i + 1)) {
+ // refreshTarget.Queue_Number__c = i + 1;
+ // executeed_refreshQueueNumber.add(refreshTarget.Id);
+ // updateList.add(refreshTarget);
+ // }
+ // }
+ // if (!updateList.isEmpty()) { update updateList; }
+ // }
+ // }
+ // }
+
+ // 4-XX 涓嬫灦鍚�, 鍑哄簱鍓嶆娴嬬殑Action涓�瀵逛竴鍒嗛厤鐨勮瘽, 鍜屼富浣撲竴璧� Cancel
+ private void oneToOne4XX() {
+ //涓讳綋CnacelSet
+ Set<Id> raesdBodyCnacelSet = new Set<Id>();
+ Set<Id> raesdBodyNGSet = new Set<Id>();
+ //鏆傛椂鍙�冭檻涓讳綋NG鎴栬�呭彇娑堢殑鏃跺��
+ Map<Id, String> raesdCancel_Remarks = new Map<Id, String>();
+ //妫�娴婲G鎴栬�呮湰鏉ュ氨Cancel鐨勪笉闇�瑕佸啀鏇存柊
+ Set<Id> raesdIdSet = new Set<Id>();
+ String ra_RecordTypeId = DEVELOPERNAMEMAP.get('AgencyRequest')
+ .getRecordTypeId();
+
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ // 鍔炰簨澶勯檮灞炲搧涓嶉渶瑕侀殢涓讳綋鍙栨秷
+ if (
+ nObj.RA_RecordTypeId__c.substring(0, 15) ==
+ ra_RecordTypeId.substring(0, 15)
+ ) {
+ continue;
+ }
+ Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
+ //Set娌℃湁cancel鐨勮瘽閮介渶瑕佹嫹璐�
+ //涓讳綋鍑哄簱鍓嶆娴婲G 缁翠慨
+ if (
+ nObj.Is_Body__c == true &&
+ nObj.Inspection_result__c == 'NG' &&
+ oObj.Inspection_result__c != nObj.Inspection_result__c &&
+ nObj.Inspection_result_NG__c == '缁翠慨'
+ ) {
+ //闇�瑕侀噸鏂板垎閰嶄竴瀵逛竴闄勫睘鍝佺殑涓�瑙�
+ raesdBodyNGSet.add(nObj.Rental_Apply_Equipment_Set__c);
+ raesdCancel_Remarks.put(
+ nObj.Rental_Apply_Equipment_Set__c,
+ nObj.Loaner_cancel_Remarks__c
+ );
+ raesdIdSet.add(nObj.Id);
+ }
+ //涓讳綋鍑哄簱鍓嶆娴婲G 搴熷純
+ else if (
+ nObj.Is_Body__c == true &&
+ nObj.Inspection_result__c == 'NG' &&
+ oObj.Inspection_result__c != nObj.Inspection_result__c &&
+ nObj.Inspection_result_NG__c == '搴熷純'
+ ) {
+ //闇�瑕侀噸鏂板垎閰嶄竴瀵逛竴闄勫睘鍝佺殑涓�瑙�
+ raesdBodyNGSet.add(nObj.Rental_Apply_Equipment_Set__c);
+ raesdCancel_Remarks.put(
+ nObj.Rental_Apply_Equipment_Set__c,
+ nObj.Loaner_cancel_Remarks__c
+ );
+ raesdIdSet.add(nObj.Id);
+ }
+ //闄勫睘鍝佸嚭搴撳墠妫�娴婲G 缁翠慨 骞朵笖鏄竴瀵逛竴鍒嗛厤
+ else if (
+ nObj.Is_Body__c == false &&
+ nObj.Inspection_result__c == 'NG' &&
+ oObj.Inspection_result__c != nObj.Inspection_result__c &&
+ nObj.Inspection_result_NG__c == '缁翠慨' &&
+ nObj.OneToOne_Flag__c == true
+ ) {
+ raesdIdSet.add(nObj.Id);
+ }
+ //闄勫睘鍝佸嚭搴撳墠妫�娴婲G 搴熷純 骞朵笖鏄竴瀵逛竴鍒嗛厤
+ else if (
+ nObj.Is_Body__c == false &&
+ nObj.Inspection_result__c == 'NG' &&
+ oObj.Inspection_result__c != nObj.Inspection_result__c &&
+ nObj.Inspection_result_NG__c == '搴熷純' &&
+ nObj.OneToOne_Flag__c == true
+ ) {
+ raesdIdSet.add(nObj.Id);
+ }
+ //OLY_OCM-152 涓嬫灦鍚庝富浣撳彇娑堢殑璇濅竴瀵逛竴闄勫睘鍝佷篃瑕佷竴璧峰彇娑�
+ else if (
+ String.isBlank(nObj.DeliverySlip__c) &&
+ nObj.Is_Body__c == true &&
+ nObj.StockDown__c == true &&
+ oObj.Cancel_Select__c == false &&
+ nObj.Cancel_Select__c == true
+ ) {
+ raesdIdSet.add(nObj.Id);
+ raesdBodyCnacelSet.add(nObj.Rental_Apply_Equipment_Set__c);
+ raesdCancel_Remarks.put(
+ nObj.Rental_Apply_Equipment_Set__c,
+ nObj.Loaner_cancel_Remarks__c
+ );
+ }
+ }
+ if (raesdBodyNGSet.isEmpty() && raesdBodyCnacelSet.isEmpty()) {
+ return;
+ }
+ List<Rental_Apply_Equipment_Set_Detail__c> raesds = [
+ SELECT
+ Id,
+ UniqueKey__c,
+ Rental_Apply_Equipment_Set__c,
+ Rental_Apply__c,
+ Fixture_Set_Detail__c,
+ Cancel_Reason__c
+ FROM Rental_Apply_Equipment_Set_Detail__c
+ //涓讳綋鍑哄簱鍓嶆娴婲G涓�瑙堢殑鎵�鏈変竴瀵逛竴鍒嗛厤鐨勬槑缁�
+ WHERE
+ (Rental_Apply_Equipment_Set__c = :raesdBodyNGSet
+ //涓嬫灦鍚庝富浣撳彇娑堜竴瀵逛竴闄勫睘鍝佷篃瑕佷竴璧峰彇娑�
+ OR Rental_Apply_Equipment_Set__c = :raesdBodyCnacelSet)
+ AND OneToOne_Flag__c = TRUE
+ //鍜屼富浣撲竴璧锋娴婲G鐨勪笉鍐嶆洿鏂�
+ AND Id != :raesdIdSet
+ ];
+ List<Rental_Apply_Equipment_Set_Detail__c> raesdList = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ for (Rental_Apply_Equipment_Set_Detail__c raesd : raesds) {
+ raesd.OnStock_By_Cancel__c = true;
+ raesd.Cancel_Select__c = true;
+ // OLY_OCM-163#comment-20120592 閫氳繃鍙栨秷鏃ュ垽鏂� -銆� 鏇存柊鐨勬椂鍊檅efore璁剧疆
+ //raesd.Cancel_Date__c = Date.today();
+ raesd.Cancel_Reason__c = '閲嶆柊鍒嗛厤';
+ raesd.Loaner_cancel_reason__c = '鍏朵粬'; // 20210830 ljh SFDC-C448KZ add
+ //涓讳綋鍑哄簱鍓嶆鏌G鐨勮瘽鍙栨秷澶囨敞鍥炶嚜鍔ㄨ缃负鍑哄簱鍓嶆鏌G
+ raesd.Loaner_cancel_Remarks__c = raesdCancel_Remarks.get(
+ raesd.Rental_Apply_Equipment_Set__c
+ );
+ // }
+ raesdList.add(raesd);
+ }
+ System.debug('raesdList size' + raesdList.size());
+ if (!raesdList.isEmpty()) {
+ update raesdList;
+ }
+ }
+
+ //涓�瑙堝崟浣嶅彇娑堝悗鐨勬嫹璐濆湪涓�瑙堢殑Handler閲岄潰鍋�
+ // 鍥犱负cancel鏄富浣撶殑璇滷irst搴斿紑濮嬫嫹璐濆嚭鏉ョ殑涓讳綋鎵�浠irst鐨勬洿鏂伴�昏緫绉诲姩鍒癱ancelcopy
+ private void cancelCopy() {
+ List<Rental_Apply_Equipment_Set_Detail__c> raesdList = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ List<Rental_Apply_Equipment_Set_Detail__c> raesdListup = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ Map<Id, Rental_Apply_Equipment_Set__c> raesMap = new Map<Id, Rental_Apply_Equipment_Set__c>();
+ String ra_RecordTypeId = DEVELOPERNAMEMAP.get('AgencyRequest')
+ .getRecordTypeId();
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
+ //Set娌℃湁cancel鐨勮瘽閮介渶瑕佹嫹璐�
+ //Cancel_Select__c 銇痜alse銇嬨倝true銇鏇淬仾銇仹銇伄銇rigger浜屽洖銇仐銇︺倐瀹熻銇欍倠銇伅锛戝洖銇犮亼
+ if (
+ nObj.Set_Cancel_Select__c == false &&
+ (oObj.Cancel_Select__c == false &&
+ nObj.Cancel_Select__c == true) &&
+ nObj.StockDown__c == true &&
+ nObj.Cancel_Reason__c == '閲嶆柊鍒嗛厤' &&
+ // 鍔炰簨澶勫彇娑堟椂涓嶈鎷疯礉鏄庣粏锛屽湪controller閲屾墜鍔ㄩ��
+ nObj.RA_RecordTypeId__c.substring(0, 15) !=
+ ra_RecordTypeId.substring(0, 15)
+ ) {
+ Rental_Apply_Equipment_Set_Detail__c craesd = new Rental_Apply_Equipment_Set_Detail__c();
+ craesd.Rental_Apply_Equipment_Set__c = nObj.Rental_Apply_Equipment_Set__c;
+ craesd.Rental_Apply__c = nObj.Rental_Apply__c;
+ craesd.Fixture_Set_Detail__c = nObj.Fixture_Set_Detail__c;
+ craesd.Fixture_Model_No_text__c = nObj.FSD_Fixture_Model_No__c;
+ craesd.Fixture_Name_text__c = nObj.FSD_Name_CHN__c;
+ craesd.IndexFromUniqueKey_Text__c = nObj.IndexFromUniqueKey_Text__c;
+ craesd.Canceled__c = nObj.Id;
+ craesd.FSD_Id__c = nObj.FSD_Id__c;
+ craesd.FSD_Is_Optional__c = nObj.FSD_Is_Optional_F__c;
+ craesd.FSD_Is_OneToOne__c = nObj.FSD_Is_OneToOne_F__c;
+ craesd.FSD_Name_CHN__c = nObj.FSD_Name_CHN__c;
+ craesd.FSD_OneToOneAccessory_Cnt__c = nObj.FSD_OneToOneAccessory_Cnt_F__c;
+ craesd.FSD_Fixture_Model_No__c = nObj.FSD_Fixture_Model_No__c;
+ // 20211125 ljh add 鎺掗槦鎻掗槦 start
+ if (nObj.Is_Body__c) {
+ craesd.Allow_Adjust_Queue_Flag__c = true;
+ craesd.jumpReason__c = '鍙戣揣鍓嶆娴婲G閲嶆柊鍒嗛厤';
+ }
+ // 20211125 ljh add 鎺掗槦鎻掗槦 end
+ if (
+ nObj.DataMigration_Flag__c == false &&
+ (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))
+ ) {
+ craesd.Rental_Num__c = nObj.Rental_Num__c;
+ craesd.IndexFromUniqueKey__c = nObj.IndexFromUniqueKey__c;
+ }
+ //cancel閲嶆柊鍒嗛厤鐨勪笉绠楄拷鍔犻檮灞炲搧 272銉併偙銉冦儓
+ craesd.Create_State__c = 0;
+ raesdList.add(craesd);
+ }
+ // 濡傛灉鏄富浣� cancel鐨勮瘽First搴旇鏄嫹璐濆嚭鏉ョ殑涓讳綋
+ if (
+ (oObj.Cancel_Select__c == false &&
+ nObj.Cancel_Select__c == true) &&
+ nObj.Is_First_RAESD_F__c == true &&
+ nObj.Set_Cancel_Select__c == false &&
+ nObj.DataMigration_Flag__c == false &&
+ (!Trigger.isUpdate || String.isNotBlank(nObj.Fixture_Set_Id__c))
+ ) {
+ Rental_Apply_Equipment_Set__c raes = new Rental_Apply_Equipment_Set__c(
+ Id = nObj.Rental_Apply_Equipment_Set__c,
+ First_RAESD__c = null
+ );
+ raesMap.put(nObj.Rental_Apply_Equipment_Set__c, raes);
+ }
+ }
+ //娌′笅鏋剁殑瀛楁娓呯┖鍦╞efore閲岄潰鍋�
+ if (!raesdList.isEmpty()) {
+ insert raesdList;
+ }
+ if (!raesMap.isEmpty()) {
+ List<Rental_Apply_Equipment_Set_Detail__c> raess = [
+ SELECT Id, Rental_Apply_Equipment_Set__c
+ FROM Rental_Apply_Equipment_Set_Detail__c
+ WHERE
+ Rental_Apply_Equipment_Set__c = :raesMap.keySet()
+ AND Cancel_Select__c = FALSE
+ ORDER BY
+ Rental_Apply_Equipment_Set__c,
+ Fixture_Set_Detail__r.SortInt__c ASC NULLS LAST
+ ];
+ System.debug(raess);
+ Id raesId = null;
+ // 涓�浠剁洰銈扚irst_RAESD__c銇ō瀹�
+ for (Rental_Apply_Equipment_Set_Detail__c raes : raess) {
+ if (raesId != raes.Rental_Apply_Equipment_Set__c) {
+ raesMap.get(raes.Rental_Apply_Equipment_Set__c)
+ .First_RAESD__c = raes.Id;
+ raesId = raes.Rental_Apply_Equipment_Set__c;
+ }
+ }
+ }
+ //涓�瑙團irst鏇存柊
+ if (!raesMap.isEmpty()) {
+ update raesMap.values();
+ }
+ }
+
+ // afterdelete銇伩
+ private void deleteReFirst() {
+ Map<Id, Rental_Apply_Equipment_Set__c> raesMap = new Map<Id, Rental_Apply_Equipment_Set__c>();
+ for (Rental_Apply_Equipment_Set_Detail__c oObj : oldList) {
+ if (oObj.Is_First_RAESD_F__c == true) {
+ Rental_Apply_Equipment_Set__c raes = new Rental_Apply_Equipment_Set__c(
+ Id = oObj.Rental_Apply_Equipment_Set__c,
+ First_RAESD__c = null
+ );
+ raesMap.put(oObj.Rental_Apply_Equipment_Set__c, raes);
+ }
+ }
+ //淇敼涓�瑙堢殑FirstMap
+ if (raesMap.isEmpty()) {
+ return;
+ }
+ if (!raesMap.isEmpty()) {
+ List<Rental_Apply_Equipment_Set_Detail__c> raess = [
+ SELECT Id, Rental_Apply_Equipment_Set__c
+ FROM Rental_Apply_Equipment_Set_Detail__c
+ WHERE
+ Rental_Apply_Equipment_Set__c = :raesMap.keySet()
+ AND Cancel_Select__c = FALSE
+ //涓�瑕с倐鍓婇櫎銇椼仧銈夋洿鏂般仐銇俱仜銈�
+ AND IsDeleted = FALSE
+ // RAESD_SortInt_F__c -> IndexFromUniqueKey_Text__c(澶囧搧閰嶅鏄庣粏.SortInt__c)
+ // 1搴旇鏄富浣�
+ ORDER BY
+ Rental_Apply_Equipment_Set__c,
+ IndexFromUniqueKey_Text__c ASC NULLS LAST
+ ];
+ Id raesId = null;
+ // 涓�浠剁洰銈扚irst_RAESD__c銇ō瀹�
+ for (Rental_Apply_Equipment_Set_Detail__c raes : raess) {
+ if (raesId != raes.Rental_Apply_Equipment_Set__c) {
+ raesMap.get(raes.Rental_Apply_Equipment_Set__c)
+ .First_RAESD__c = raes.Id;
+ raesId = raes.Rental_Apply_Equipment_Set__c;
+ }
+ }
+ }
+ //涓�瑙團irst鏇存柊
+ if (!raesMap.isEmpty()) {
+ update raesMap.values();
+ }
+ }
+ // 鏈�绲傜姸鎱嬪強銇矨sset澶夋洿
+ private Boolean finishOrChangeAsset(
+ Boolean isDelete,
+ Rental_Apply_Equipment_Set_Detail__c oObj,
+ Rental_Apply_Equipment_Set_Detail__c nObj
+ ) {
+ Boolean rtn = false;
+ if (isDelete) {
+ // oObj 銈掔⒑瑾嶃仚銈嬨�乷ld銇� 銈傘仺銈傘仺 finish銇倐銇�乫alse銈掕繑銇欍��
+ rtn = !//鍥炲簱纭
+ ((oObj.Arrival_in_wh__c) ||
+ //鍙栨秷鍒嗛厤, (涓嬫灦鍚�, 鍘熷垯闇�瑕佷笂鏋�, 鎵�浠ヤ笉鑳藉崟绾殑鏂紑)
+ (oObj.Cancel_Select__c == true &&
+ oObj.StockDown__c == false) ||
+ //涓嬫灦鍓�, 鍒嗛厤澶囧搧鏈夊彉鍖� (鍙樻垚鍒殑閰嶅, or 鍙� null)
+ (oObj.Asset__c == null &&
+ oObj.StockDown__c == false) ||
+ //鍙栨秷鍒嗛厤, (涓嬫灦鍚�, 鍘熷垯闇�瑕佷笂鏋�, 鎵�浠ヤ笉鑳藉崟绾殑鏂紑)
+ (oObj.Cancel_Select__c == true &&
+ nObj.StockDown__c == false) ||
+ //鏀惧純娆犲搧
+ (oObj.Lost_item_giveup__c == true) ||
+ //宸叉秷鑰�
+ (oObj.Check_lost_Item_F__c == '娑堣��'));
+ } else {
+ rtn =
+ //鍥炲簱纭
+ ((!oObj.Arrival_in_wh__c && nObj.Arrival_in_wh__c) ||
+ //鍙栨秷鍒嗛厤, (涓嬫灦鍚�, 鍘熷垯闇�瑕佷笂鏋�, 鎵�浠ヤ笉鑳藉崟绾殑鏂紑)
+ (oObj.Cancel_Select__c == false &&
+ nObj.Cancel_Select__c == true &&
+ nObj.StockDown__c == false) ||
+ //涓嬫灦鍓�, 鍒嗛厤澶囧搧鏈夊彉鍖� (鍙樻垚鍒殑閰嶅, or 鍙� null)
+ (oObj.Asset__c != null &&
+ oObj.Asset__c != nObj.Asset__c &&
+ nObj.StockDown__c == false) ||
+ //鍙栨秷鍒嗛厤, (涓嬫灦鍚�, 鍘熷垯闇�瑕佷笂鏋�, 鎵�浠ヤ笉鑳藉崟绾殑鏂紑)
+ (oObj.Cancel_Select__c == false &&
+ nObj.Cancel_Select__c == true &&
+ nObj.StockDown__c == false) ||
+ //鏀惧純娆犲搧
+ (oObj.Lost_item_giveup__c == false &&
+ nObj.Lost_item_giveup__c == true &&
+ oObj.Check_lost_Item_F__c != '娑堣��') ||
+ //宸叉秷鑰�
+ (oObj.Check_lost_Item_F__c != '娑堣��' &&
+ nObj.Check_lost_Item_F__c == '娑堣��' &&
+ oObj.Lost_item_giveup__c == false));
+ }
+ return rtn;
+ }
+ //before 鏁板紡銇�ゃ亴null銇仾銈嬪彲鑳芥�с亴銇傘倞銇俱仚銇仹銇撱亾銇с倐涓�鍥炪儊銈с儍銈仐銇俱仚
+ private void formulaToTextCheck() {
+ List<Rental_Apply_Equipment_Set_Detail__c> raesds = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ //鏄庣粏鐘舵�佹病鏈変慨鐞嗗畬姣曟墍浠ヤ慨鐞嗗畬姣曠殑鏃跺�欎笉鎷疯礉鐘舵�佸埌Text瀛楁
+ if (
+ (nObj.Repair_Status_Text__c != nObj.Repair_Status_F__c &&
+ nObj.Repair_Status_F__c != '淇悊瀹屾瘯') ||
+ nObj.Return_Status_Text__c != nObj.Return_Status_F__c ||
+ nObj.Shipment_Status_Text__c != nObj.Shipment_Status_F__c ||
+ (nObj.ApplyPersonAppended__c != nObj.ApplyPersonAppended_F__c &&
+ Trigger.isInsert)
+ ) {
+ Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c(
+ Id = nObj.Id
+ );
+ //鏄庣粏鐘舵�佹病鏈変慨鐞嗗畬姣曟墍浠ヤ慨鐞嗗畬姣曠殑鏃跺�欎笉鎷疯礉鐘舵�佸埌Text瀛楁
+ if (nObj.Repair_Status_F__c != '淇悊瀹屾瘯') {
+ raesd.Repair_Status_Text__c = nObj.Repair_Status_F__c;
+ }
+ raesd.Return_Status_Text__c = nObj.Return_Status_F__c;
+ raesd.Shipment_Status_Text__c = nObj.Shipment_Status_F__c;
+ if (Trigger.isInsert) {
+ raesd.ApplyPersonAppended__c = nObj.ApplyPersonAppended_F__c;
+ }
+ raesds.add(raesd);
+ }
+ }
+ if (!raesds.isEmpty()) {
+ // 澶囧搧浼樺寲杩藉姞 20230518 lc Start
+ if (skipUpdateAgain) {
+ Oly_TriggerHandler.bypass('RentalApplyEquipmentSetDetailHandler');
+ update raesds;
+ Oly_TriggerHandler.clearBypass('RentalApplyEquipmentSetDetailHandler');
+ } else {
+ update raesds;
+ }
+ // 澶囧搧浼樺寲杩藉姞 20230518 lc End
+ }
+ }
+ // 20211116 ljh 涓嬩竴娆″�熺敤棰勮鍑哄簱鏃堕棿 鐨勮祴鍊� 鍥炴敹鍚�-妫�娴嬬粨鏋淥K閫昏緫 start
+ /*
鏍规嵁褰撳墠鐘舵�侊紝if 鍥炴敹鍚�-妫�娴嬬粨鏋� Inspection_result_after_F_New__c 鏈夊�� && new =OK old != OK {
妫�娴婳K鏃堕棿+3涓伐浣滄棩(濂ユ灄宸存柉鏃ュ巻)
}
*/
- private void NextShippmentDate() {
- Date minDate = Date.newInstance(4000, 12, 31);
- Date maxDate = Date.newInstance(1700, 1, 1);
- Map<Date, List<Rental_Apply_Equipment_Set_Detail__c>> dLMap = new Map<Date, List<Rental_Apply_Equipment_Set_Detail__c>>();
- List<Rental_Apply_Equipment_Set_Detail__c> upRdList = new List<Rental_Apply_Equipment_Set_Detail__c>();
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- if(nObj.RA_RecordTypeId__c != '01210000000NPGK'){
- Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
- if(nObj.Inspection_result_after_F_New__c != null && nObj.Inspection_result_after_F_New__c == 'OK' && oObj.Inspection_result_after_F_New__c != nObj.Inspection_result_after_F_New__c){
- // 妫�娴婳K鏃堕棿+3涓伐浣滄棩(濂ユ灄宸存柉鏃ュ巻)
- Date date1 = nObj.After_Inspection_time_F_New__c.date();
- if (minDate > date1) {
- minDate = date1;
- }
- if (maxDate < date1) {
- maxDate = date1;
- }
- if(!dLMap.containsKey(date1)){
- dLMap.put(date1,new List<Rental_Apply_Equipment_Set_Detail__c>());
- }
- dLMap.get(date1).add(nObj);
- }
- // 妫�娴婲G鍜屾瑺鍝佺殑锛氫笉鏄剧ず鏃堕棿
- if((
- // (
- nObj.RAESD_Status__c == '娆犲搧涓�' || nObj.RAESD_Status__c == '寰呬慨鐞�' || nObj.RAESD_Status__c == '寰呯Щ鑷虫姤搴熷尯')
- // || (nObj.Arrival_in_wh__c && oObj.Arrival_in_wh__c != nObj.Arrival_in_wh__c))
- && nObj.NextShippmentDate__c != null){
- Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c();
- raesd.Id = nObj.Id;
- raesd.NextShippmentDate__c = null;
- upRdList.add(raesd);
- }
- }
+ private void NextShippmentDate() {
+ Date minDate = Date.newInstance(4000, 12, 31);
+ Date maxDate = Date.newInstance(1700, 1, 1);
+ Map<Date, List<Rental_Apply_Equipment_Set_Detail__c>> dLMap = new Map<Date, List<Rental_Apply_Equipment_Set_Detail__c>>();
+ List<Rental_Apply_Equipment_Set_Detail__c> upRdList = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ if (nObj.RA_RecordTypeId__c != '01210000000NPGK') {
+ Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
+ if (
+ nObj.Inspection_result_after_F_New__c != null &&
+ nObj.Inspection_result_after_F_New__c == 'OK' &&
+ oObj.Inspection_result_after_F_New__c !=
+ nObj.Inspection_result_after_F_New__c
+ ) {
+ // 妫�娴婳K鏃堕棿+3涓伐浣滄棩(濂ユ灄宸存柉鏃ュ巻)
+ Date date1 = nObj.After_Inspection_time_F_New__c.date();
+ if (minDate > date1) {
+ minDate = date1;
+ }
+ if (maxDate < date1) {
+ maxDate = date1;
+ }
+ if (!dLMap.containsKey(date1)) {
+ dLMap.put(date1, new List<Rental_Apply_Equipment_Set_Detail__c>());
+ }
+ dLMap.get(date1).add(nObj);
}
- if(dLMap.size() > 0){
- List<OlympusCalendar__c> ocList = [SELECT Id
- , Date__c
- FROM OlympusCalendar__c
- WHERE Date__c >= :minDate
- AND Date__c <= :maxDate.addDays(30)
- AND IsWorkDay__c = 1
- ORDER BY Date__c ASC];
- Map<Date, Date> dateadd3Map = new Map<Date, Date>();
- Integer ocListSize = ocList.size();
- if (ocListSize > 3) {
- for (Integer i = 0; i < ocListSize - 3; i ++) {
- dateadd3Map.put(ocList[i].Date__c, ocList[i + 3].Date__c);
- }
- for(Date d:dLMap.keySet()){
- // 鍥犱负 妫�娴嬫槸宸ヤ綔鏃� 涓�鑸笉浼氬嚭鐜� else 鎯呭喌
- if (dateadd3Map.containsKey(d)) {
- for(Rental_Apply_Equipment_Set_Detail__c rd:dLMap.get(d)){
- Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c();
- raesd.Id = rd.id;
- raesd.NextShippmentDate__c = dateadd3Map.get(d);
- upRdList.add(raesd);
- }
- }
- // 寰堝皯鍙戠敓
- else{
- for (Integer i = 0; i < ocListSize - 3; i ++) {
- if(d < ocList[i].Date__c){
- for(Rental_Apply_Equipment_Set_Detail__c rd:dLMap.get(d)){
- Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c();
- raesd.Id = rd.id;
- raesd.NextShippmentDate__c = ocList[i + 2].Date__c;
- upRdList.add(raesd);
- }
- break;
- }
- }
- }
- }
-
- }
+ // 妫�娴婲G鍜屾瑺鍝佺殑锛氫笉鏄剧ず鏃堕棿
+ if (
+ (// (
+ nObj.RAESD_Status__c == '娆犲搧涓�' ||
+ nObj.RAESD_Status__c == '寰呬慨鐞�' ||
+ nObj.RAESD_Status__c == '寰呯Щ鑷虫姤搴熷尯') &&
+ // || (nObj.Arrival_in_wh__c && oObj.Arrival_in_wh__c != nObj.Arrival_in_wh__c))
+ nObj.NextShippmentDate__c != null
+ ) {
+ Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c();
+ raesd.Id = nObj.Id;
+ raesd.NextShippmentDate__c = null;
+ upRdList.add(raesd);
}
- if(upRdList.size() > 0){
- update upRdList;
- }
+ }
}
- /*
+ if (dLMap.size() > 0) {
+ List<OlympusCalendar__c> ocList = [
+ SELECT Id, Date__c
+ FROM OlympusCalendar__c
+ WHERE
+ Date__c >= :minDate
+ AND Date__c <= :maxDate.addDays(30)
+ AND IsWorkDay__c = 1
+ ORDER BY Date__c ASC
+ ];
+ Map<Date, Date> dateadd3Map = new Map<Date, Date>();
+ Integer ocListSize = ocList.size();
+ if (ocListSize > 3) {
+ for (Integer i = 0; i < ocListSize - 3; i++) {
+ dateadd3Map.put(ocList[i].Date__c, ocList[i + 3].Date__c);
+ }
+ for (Date d : dLMap.keySet()) {
+ // 鍥犱负 妫�娴嬫槸宸ヤ綔鏃� 涓�鑸笉浼氬嚭鐜� else 鎯呭喌
+ if (dateadd3Map.containsKey(d)) {
+ for (Rental_Apply_Equipment_Set_Detail__c rd : dLMap.get(d)) {
+ Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c();
+ raesd.Id = rd.id;
+ raesd.NextShippmentDate__c = dateadd3Map.get(d);
+ upRdList.add(raesd);
+ }
+ }
+ // 寰堝皯鍙戠敓
+ else {
+ for (Integer i = 0; i < ocListSize - 3; i++) {
+ if (d < ocList[i].Date__c) {
+ for (Rental_Apply_Equipment_Set_Detail__c rd : dLMap.get(d)) {
+ Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c();
+ raesd.Id = rd.id;
+ raesd.NextShippmentDate__c = ocList[i + 2].Date__c;
+ upRdList.add(raesd);
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (upRdList.size() > 0) {
+ update upRdList;
+ }
+ }
+ /*
鏍规嵁褰撳墠鐘舵�侊紝if 鍥炴敹鍚�-妫�娴嬬粨鏋� DeliverySlip__c 鏈夊�� && new != old {
鍑哄簱鏈�鏂伴瀹氬綊杩樻棩RAES_Final_reply_day__c+8涓伐浣滄棩(濂ユ灄宸存柉鏃ュ巻)
}
*/
- private void NextShippmentDate_out() {
- Date minDate = Date.newInstance(4000, 12, 31);
- Date maxDate = Date.newInstance(1700, 1, 1);
- Map<Date, List<Rental_Apply_Equipment_Set_Detail__c>> dLMap = new Map<Date, List<Rental_Apply_Equipment_Set_Detail__c>>();
- List<Rental_Apply_Equipment_Set_Detail__c> upRdList = new List<Rental_Apply_Equipment_Set_Detail__c>();
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- if(nObj.RA_RecordTypeId__c != '01210000000NPGK'){
- Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
- if(nObj.DeliverySlip__c != null && oObj.DeliverySlip__c != nObj.DeliverySlip__c){
- // 妫�娴婳K鏃堕棿+3涓伐浣滄棩(濂ユ灄宸存柉鏃ュ巻)
- Date date1 = nObj.RAES_Final_reply_day__c;
- if (minDate > date1) {
- minDate = date1;
- }
- if (maxDate < date1) {
- maxDate = date1;
- }
- if(!dLMap.containsKey(date1)){
- dLMap.put(date1,new List<Rental_Apply_Equipment_Set_Detail__c>());
- }
- dLMap.get(date1).add(nObj);
- }
- }
+ private void NextShippmentDate_out() {
+ Date minDate = Date.newInstance(4000, 12, 31);
+ Date maxDate = Date.newInstance(1700, 1, 1);
+ Map<Date, List<Rental_Apply_Equipment_Set_Detail__c>> dLMap = new Map<Date, List<Rental_Apply_Equipment_Set_Detail__c>>();
+ List<Rental_Apply_Equipment_Set_Detail__c> upRdList = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ if (nObj.RA_RecordTypeId__c != '01210000000NPGK') {
+ Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
+ if (
+ nObj.DeliverySlip__c != null &&
+ oObj.DeliverySlip__c != nObj.DeliverySlip__c
+ ) {
+ // 妫�娴婳K鏃堕棿+3涓伐浣滄棩(濂ユ灄宸存柉鏃ュ巻)
+ Date date1 = nObj.RAES_Final_reply_day__c;
+ if (minDate > date1) {
+ minDate = date1;
+ }
+ if (maxDate < date1) {
+ maxDate = date1;
+ }
+ if (!dLMap.containsKey(date1)) {
+ dLMap.put(date1, new List<Rental_Apply_Equipment_Set_Detail__c>());
+ }
+ dLMap.get(date1).add(nObj);
}
- if(dLMap.size() > 0){
- List<OlympusCalendar__c> ocList = [SELECT Id
- , Date__c
- FROM OlympusCalendar__c
- WHERE Date__c >= :minDate
- AND Date__c <= :maxDate.addDays(30)
- AND IsWorkDay__c = 1
- ORDER BY Date__c ASC];
- Map<Date, Date> dateadd3Map = new Map<Date, Date>();
- Integer ocListSize = ocList.size();
- if (ocListSize > 8) {
- for (Integer i = 0; i < ocListSize - 8; i ++) {
- dateadd3Map.put(ocList[i].Date__c, ocList[i + 8].Date__c);
- }
- for(Date d:dLMap.keySet()){
- if (dateadd3Map.containsKey(d)) {
- for(Rental_Apply_Equipment_Set_Detail__c rd:dLMap.get(d)){
- Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c();
- raesd.Id = rd.id;
- raesd.NextShippmentDate__c = dateadd3Map.get(d);
- upRdList.add(raesd);
- }
- }
- else{
- for (Integer i = 0; i < ocListSize - 8; i ++) {
- if(d < ocList[i].Date__c){
- for(Rental_Apply_Equipment_Set_Detail__c rd:dLMap.get(d)){
- Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c();
- raesd.Id = rd.id;
- raesd.NextShippmentDate__c = ocList[i + 7].Date__c;
- upRdList.add(raesd);
- }
- break;
- }
- }
- }
- }
- if(upRdList.size() > 0){
- update upRdList;
- }
- }
- }
+ }
}
- // 20211116 ljh 涓嬩竴娆″�熺敤棰勮鍑哄簱鏃堕棿 鐨勮祴鍊� 鍥炴敹鍚�-妫�娴嬬粨鏋淥K閫昏緫 end
- //added by denny
- public void reQueueAndSequence(){
- Map<Id, Rental_Apply_Equipment_Set_Detail__c> newdetailMap = (Map<Id, Rental_Apply_Equipment_Set_Detail__c>) Trigger.newMap;
- List<Rental_Apply_Equipment_Set_Detail__c> updateList = new List<Rental_Apply_Equipment_Set_Detail__c>();
- List<String> detailIds = new List<String>();
- List<String> externalKeyList = new List<String>();
- Map<String,Decimal> minNumberMap = new Map<String,Decimal>();
- for(Rental_Apply_Equipment_Set_Detail__c olddetail : (List<Rental_Apply_Equipment_Set_Detail__c>)trigger.old){
- Rental_Apply_Equipment_Set_Detail__c detail ;
- if(Trigger.isUpdate){
- detail = newdetailMap.get(olddetail.Id);
- }
- if((Trigger.isUpdate && (
- (oldDetail.Queue_Number__c > 0 && detail.Queue_Number__c == 0)// 鏆傚畾鍒嗛厤
- // 20220127 ljh update start
- // || (!oldDetail.Cancel_Select__c && detail.Cancel_Select__c && olddetail.Queue_Number__c >= 0) //鍙栨秷(鎺掗槦涓紝鏆傚畾鍒嗛厤)
- || (!oldDetail.Cancel_Select__c && detail.Cancel_Select__c && olddetail.Queue_Number__c > 0) //鍙栨秷(鎺掗槦涓紝鏆傚畾鍒嗛厤)
- // 20220127 ljh update end
- || (oldDetail.Queue_Number__c > 0 && detail.Queue_Number__c == null )//鍒嗗崟
- || (oldDetail.Queue_Number__c > 0 && olddetail.ExternalKey__c != detail.ExternalKey__c)))//閲嶆帓
- || (Trigger.isDelete && olddetail.Queue_Number__c > 0 )){
-
- updateList.add(olddetail);
- detailIds.add(olddetail.Id);
- externalKeyList.add(olddetail.ExternalKey__c);
- if(!minNumberMap.containsKey(olddetail.Externalkey__c)){
- minNumberMap.put(olddetail.Externalkey__c,olddetail.Queue_Number__c);
- }else{
- if(minNumberMap.get(olddetail.Externalkey__c) > olddetail.Queue_Number__c){
- minNumberMap.put(olddetail.Externalkey__c,olddetail.Queue_Number__c);
- }
- }
- }
+ if (dLMap.size() > 0) {
+ List<OlympusCalendar__c> ocList = [
+ SELECT Id, Date__c
+ FROM OlympusCalendar__c
+ WHERE
+ Date__c >= :minDate
+ AND Date__c <= :maxDate.addDays(30)
+ AND IsWorkDay__c = 1
+ ORDER BY Date__c ASC
+ ];
+ Map<Date, Date> dateadd3Map = new Map<Date, Date>();
+ Integer ocListSize = ocList.size();
+ if (ocListSize > 8) {
+ for (Integer i = 0; i < ocListSize - 8; i++) {
+ dateadd3Map.put(ocList[i].Date__c, ocList[i + 8].Date__c);
}
-
- if (!detailIds.isEmpty()) {
- List<String> sequencekeylist = new List<String>();
- List<String> changeSequenceIds = new List<String>();
- Map<String,Decimal> changesequenceMap = new Map<String,Decimal>();
- List<Rental_Apply_Sequence__c> assignSequence = [SELECT Id,Series_No__c,Invalid_Flag__c,Externalkey__c
- FROM Rental_Apply_Sequence__c
- WHERE Apply_Set_Detail__c IN: detailIds
- AND Invalid_Flag__c = false
- AND Series_No__c > 0];
- for(Rental_Apply_Sequence__c se:assignSequence){
- // sequencekeylist.add(se.Externalkey__c);
- changeSequenceIds.add(se.Id);
- // if(!changesequenceMap.containsKey(se.Externalkey__c)){
- // changesequenceMap.put(se.Externalkey__c,se.Series_No__c);
- // }else{
- // if(changesequenceMap.get(se.Externalkey__c) > se.Series_No__c){
- // changesequenceMap.put(se.Externalkey__c,se.Series_No__c);
- // }
- // }
- se.Invalid_Flag__c = true;
- se.Series_No__c = 0;
- }
- List<Rental_Apply_Equipment_Set_Detail__c> changeDetailList = new List<Rental_Apply_Equipment_Set_Detail__c>();
- List<Rental_Apply_Equipment_Set_Detail__c> raesdList = [SELECT Id, Rental_Apply_Equipment_Set__c, Asset__c,Rental_Apply_Equipment_Set__r.Fixture_Set__r.Product_Type__c,
- FSD_Fixture_Model_No__c, Fixture_Model_No_text__c,Rental_Apply__r.demo_purpose2__c,Queue_Day__c,ExternalKey__c,
- Is_Body__c, FSD_Is_OneToOne__c, Select_Time__c,Rental_Apply__r.EquipmentGuaranteeFlg__c,Allow_Adjust_Queue_Flag__c,
- Cancel_Select__c, Fixture_Model_No_F__c, Queue_Number__c, Internal_asset_location__c,Fixture_Model_No__c,Rental_Apply__c,
- Internal_asset_location_before__c,Salesdepartment__c, Product_category_F__c, Product_category_text__c,Equipment_Type_text__c,
- Salesdepartment_before__c,Rental_Apply__r.Request_shipping_day__c,QuenType__c,IsAdjust__c,Rental_Apply__r.Request_approval_time__c,
- Equipment_Type__c, Rental_Apply__r.Internal_asset_location_F__c,Cancel_Reason__c,Loaner_cancel_reason__c,
- Loaner_cancel_Remarks__c ,Rental_Apply_Equipment_Set__r.Name
- FROM Rental_Apply_Equipment_Set_Detail__c
- WHERE Queue_Number__c > 0
- AND Cancel_Select__c = false
- AND ExternalKey__c IN:externalKeyList
- AND Id NOT IN :detailIds
- ORDER BY Queue_Number__c ASC ];
- Map<String,List<Rental_Apply_Equipment_Set_Detail__c>> detailsMap = new Map<String,List<Rental_Apply_Equipment_Set_Detail__c>>();
- for(Rental_Apply_Equipment_Set_Detail__c setdetail:raesdList){
- if(!detailsMap.containsKey(setdetail.Externalkey__c)){
- detailsMap.put(setdetail.Externalkey__c,new List<Rental_Apply_Equipment_Set_Detail__c>());
+ for (Date d : dLMap.keySet()) {
+ if (dateadd3Map.containsKey(d)) {
+ for (Rental_Apply_Equipment_Set_Detail__c rd : dLMap.get(d)) {
+ Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c();
+ raesd.Id = rd.id;
+ raesd.NextShippmentDate__c = dateadd3Map.get(d);
+ upRdList.add(raesd);
+ }
+ } else {
+ for (Integer i = 0; i < ocListSize - 8; i++) {
+ if (d < ocList[i].Date__c) {
+ for (Rental_Apply_Equipment_Set_Detail__c rd : dLMap.get(d)) {
+ Rental_Apply_Equipment_Set_Detail__c raesd = new Rental_Apply_Equipment_Set_Detail__c();
+ raesd.Id = rd.id;
+ raesd.NextShippmentDate__c = ocList[i + 7].Date__c;
+ upRdList.add(raesd);
}
- detailsMap.get(setdetail.Externalkey__c).add(setdetail);
-
-
+ break;
+ }
}
- for(String key:detailsMap.keySet()){
- Decimal queueNo = minNumberMap.get(key);
- System.debug(LoggingLevel.INFO, '*** queueNo: ' + queueNo);
- Decimal i = 0;
- for(Rental_Apply_Equipment_Set_Detail__c detail : detailsMap.get(key)){
- System.debug(LoggingLevel.INFO, '*** detail.Queue_Number__c: ' + detail.Queue_Number__c);
- if(detail.Queue_Number__c > queueNo){
- RentalFixtureSetAssignController.KeyObj dobj = RentalFixtureSetAssignController.getSequenceInfo(detail);
- sequencekeylist.addAll(dobj.sequencekeylist);
- detail.Queue_Number__c = queueNo + i;
- i ++;
- System.debug(LoggingLevel.INFO, '**111* detail.Queue_Number__c: ' + detail.Queue_Number__c);
- changeDetailList.add(detail);
- }
- }
- }
- List<String> nodusequencekeylist = new List<String>(new Set<String>(sequencekeylist));
- List<Rental_Apply_Sequence__c> sequenceList = [SELECT Id,ExternalKey__c,Demo_Purpose2__c,
- Apply_Set_Detail__c,Apply_Set_Detail_ExternalKey__c,
- Series_No__c,Salesdepartment__c,Product_category__c,
- Rental_Apply__c,Internal_asset_location__c,
- Apply_Set_Detail__r.Queue_Number__c,Series_Unequal_Queue_Flag__c,
- Fixture_Model_No__c,Equipment_Type__c
- FROM Rental_Apply_Sequence__c
- WHERE ExternalKey__c IN: nodusequencekeylist
- AND Id NOT IN:changeSequenceIds
- AND Series_No__c > 0
- AND Invalid_Flag__c = false
- FOR UPDATE
- ];
- System.debug(LoggingLevel.INFO, '*** sequenceList: ' + sequenceList);
- Map<String,List<Rental_Apply_Sequence__c>> sequenceMap = new Map<String,List<Rental_Apply_Sequence__c>>();
- List<FixtureUtil.SequenceWrapper> Wrappers = new List<FixtureUtil.SequenceWrapper>();
- for(Rental_Apply_Sequence__c se: sequenceList){
- Wrappers.add(new FixtureUtil.SequenceWrapper(se));
- }
- Wrappers.sort();
- sequenceList = new List<Rental_Apply_Sequence__c>();
- for(FixtureUtil.SequenceWrapper wrapper:wrappers){
- sequenceList.add(wrapper.sequence);
- }
- for(Rental_Apply_Sequence__c se: sequenceList){
- if(!sequenceMap.containsKey(se.Externalkey__c)){
- sequenceMap.put(se.Externalkey__c,new List<Rental_Apply_Sequence__c>());
- }
- sequenceMap.get(se.Externalkey__c).add(se);
- }
- List<Rental_Apply_Sequence__c> changeSequenceList = new List<Rental_Apply_Sequence__c>();
- for(String key:sequenceMap.keyset()){
- Decimal i = 1;
- for(Rental_Apply_Sequence__c se: sequenceMap.get(key)){
- if(se.Series_No__c != i){
- se.Series_No__c = i;
- changeSequenceList.add(se);
- }
- i ++ ;
- }
- }
- update assignSequence;
- update changeSequenceList;
- update changeDetailList;
+ }
}
+ if (upRdList.size() > 0) {
+ // 澶囧搧浼樺寲杩藉姞 20230518 lc Start
+ if (skipUpdateAgain) {
+ Oly_TriggerHandler.bypass('RentalApplyEquipmentSetDetailHandler');
+ update upRdList;
+ Oly_TriggerHandler.clearBypass(
+ 'RentalApplyEquipmentSetDetailHandler'
+ );
+ } else {
+ update upRdList;
+ }
+ // 澶囧搧浼樺寲杩藉姞 20230518 lc End
+ }
+ }
+ }
+ }
+ // 20211116 ljh 涓嬩竴娆″�熺敤棰勮鍑哄簱鏃堕棿 鐨勮祴鍊� 鍥炴敹鍚�-妫�娴嬬粨鏋淥K閫昏緫 end
+ //added by denny
+ public void reQueueAndSequence() {
+ Map<Id, Rental_Apply_Equipment_Set_Detail__c> newdetailMap = (Map<Id, Rental_Apply_Equipment_Set_Detail__c>) Trigger.newMap;
+ List<Rental_Apply_Equipment_Set_Detail__c> updateList = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ List<String> detailIds = new List<String>();
+ List<String> externalKeyList = new List<String>();
+ Map<String, Decimal> minNumberMap = new Map<String, Decimal>();
+ for (
+ Rental_Apply_Equipment_Set_Detail__c olddetail : (List<Rental_Apply_Equipment_Set_Detail__c>) Trigger.old
+ ) {
+ Rental_Apply_Equipment_Set_Detail__c detail;
+ if (Trigger.isUpdate) {
+ detail = newdetailMap.get(olddetail.Id);
+ }
+ if (
+ (Trigger.isUpdate &&
+ ((oldDetail.Queue_Number__c > 0 &&
+ detail.Queue_Number__c == 0) || // 鏆傚畾鍒嗛厤
+ // 20220127 ljh update start
+ // || (!oldDetail.Cancel_Select__c && detail.Cancel_Select__c && olddetail.Queue_Number__c >= 0) //鍙栨秷(鎺掗槦涓紝鏆傚畾鍒嗛厤)
+ (!oldDetail.Cancel_Select__c &&
+ detail.Cancel_Select__c &&
+ olddetail.Queue_Number__c > 0) || //鍙栨秷(鎺掗槦涓紝鏆傚畾鍒嗛厤)
+ // 20220127 ljh update end
+ (oldDetail.Queue_Number__c > 0 &&
+ detail.Queue_Number__c == null) || //鍒嗗崟
+ (oldDetail.Queue_Number__c > 0 &&
+ olddetail.ExternalKey__c != detail.ExternalKey__c))) || //閲嶆帓
+ (Trigger.isDelete && olddetail.Queue_Number__c > 0)
+ ) {
+ updateList.add(olddetail);
+ detailIds.add(olddetail.Id);
+ externalKeyList.add(olddetail.ExternalKey__c);
+ if (!minNumberMap.containsKey(olddetail.Externalkey__c)) {
+ minNumberMap.put(olddetail.Externalkey__c, olddetail.Queue_Number__c);
+ } else {
+ if (
+ minNumberMap.get(olddetail.Externalkey__c) >
+ olddetail.Queue_Number__c
+ ) {
+ minNumberMap.put(
+ olddetail.Externalkey__c,
+ olddetail.Queue_Number__c
+ );
+ }
+ }
+ }
}
- private void setUniqueKeyQueue(){
- Map<Id, Rental_Apply_Equipment_Set_Detail__c> olddetailMap = (Map<Id, Rental_Apply_Equipment_Set_Detail__c>) Trigger.oldMap;
-
- System.debug('寮�濮嬪鐞�------------------------------------');
- System.debug('(List<Rental_Apply_Equipment_Set_Detail__c>) Trigger.new---------------' + (List<Rental_Apply_Equipment_Set_Detail__c>) Trigger.new);
- for(Rental_Apply_Equipment_Set_Detail__c newdetail : (List<Rental_Apply_Equipment_Set_Detail__c>) Trigger.new){
- System.debug(newdetail.Id + ' 鐢宠鍗曞彿锛�' + newdetail.Rental_Apply__r.name);
- Rental_Apply_Equipment_Set_Detail__c olddetail = olddetailMap.get(newdetail.Id);
- System.debug('鏃ф帓闃烴o锛�' + olddetail.Queue_Number__c);
- System.debug('鏂版帓闃烴o锛�' + newdetail.Queue_Number__c);
-
- if((olddetail.Queue_Number__c > 0 && newdetail.Queue_Number__c == 0)// 鏆傚畾鍒嗛厤
- || (!olddetail.Cancel_Select__c && newdetail.Cancel_Select__c && olddetail.Queue_Number__c > 0) //鍙栨秷(鎺掗槦涓紝鏆傚畾鍒嗛厤)
- || (olddetail.Queue_Number__c > 0 && newdetail.Queue_Number__c == null )//鍒嗗崟
- ){
- // 娓呯┖鎺掗槦鐨刄niqueKey
- newdetail.UniqueKey_Queue__c = null;
- System.debug('鏂版帓闃烾niqueKey_Queue__c锛�' + newdetail.UniqueKey_Queue__c);
- }
-
- // 閲嶆帓鎴栬�呮帓闃烴o鍙樺寲鏃舵洿鏂�
- if (!newdetail.Cancel_Select__c && newdetail.Queue_Number__c > 0 && newdetail.ExternalKey__c != null
- && (newdetail.Queue_Number__c != olddetail.Queue_Number__c
- || newdetail.ExternalKey__c != olddetail.ExternalKey__c)) {
- // 鎺掗槦鐨刄niqueKey璁惧��
- newdetail.UniqueKey_Queue__c = newdetail.ExternalKey__c + ':' + newdetail.Queue_Number__c;
- System.debug('鏂版帓闃烾niqueKey_Queue__c锛�' + newdetail.UniqueKey_Queue__c);
- }
+ if (!detailIds.isEmpty()) {
+ List<String> sequencekeylist = new List<String>();
+ List<String> changeSequenceIds = new List<String>();
+ Map<String, Decimal> changesequenceMap = new Map<String, Decimal>();
+ List<Rental_Apply_Sequence__c> assignSequence = [
+ SELECT Id, Series_No__c, Invalid_Flag__c, Externalkey__c
+ FROM Rental_Apply_Sequence__c
+ WHERE
+ Apply_Set_Detail__c IN :detailIds
+ AND Invalid_Flag__c = FALSE
+ AND Series_No__c > 0
+ ];
+ for (Rental_Apply_Sequence__c se : assignSequence) {
+ // sequencekeylist.add(se.Externalkey__c);
+ changeSequenceIds.add(se.Id);
+ // if(!changesequenceMap.containsKey(se.Externalkey__c)){
+ // changesequenceMap.put(se.Externalkey__c,se.Series_No__c);
+ // }else{
+ // if(changesequenceMap.get(se.Externalkey__c) > se.Series_No__c){
+ // changesequenceMap.put(se.Externalkey__c,se.Series_No__c);
+ // }
+ // }
+ se.Invalid_Flag__c = true;
+ se.Series_No__c = 0;
+ }
+ List<Rental_Apply_Equipment_Set_Detail__c> changeDetailList = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ List<Rental_Apply_Equipment_Set_Detail__c> raesdList = [
+ SELECT
+ Id,
+ Rental_Apply_Equipment_Set__c,
+ Asset__c,
+ Rental_Apply_Equipment_Set__r.Fixture_Set__r.Product_Type__c,
+ FSD_Fixture_Model_No__c,
+ Fixture_Model_No_text__c,
+ Rental_Apply__r.demo_purpose2__c,
+ Queue_Day__c,
+ ExternalKey__c,
+ Is_Body__c,
+ FSD_Is_OneToOne__c,
+ Select_Time__c,
+ Rental_Apply__r.EquipmentGuaranteeFlg__c,
+ Allow_Adjust_Queue_Flag__c,
+ Cancel_Select__c,
+ Fixture_Model_No_F__c,
+ Queue_Number__c,
+ Internal_asset_location__c,
+ Fixture_Model_No__c,
+ Rental_Apply__c,
+ Internal_asset_location_before__c,
+ Salesdepartment__c,
+ Product_category_F__c,
+ Product_category_text__c,
+ Equipment_Type_text__c,
+ Salesdepartment_before__c,
+ Rental_Apply__r.Request_shipping_day__c,
+ QuenType__c,
+ IsAdjust__c,
+ Rental_Apply__r.Request_approval_time__c,
+ Equipment_Type__c,
+ Rental_Apply__r.Internal_asset_location_F__c,
+ Cancel_Reason__c,
+ Loaner_cancel_reason__c,
+ Loaner_cancel_Remarks__c,
+ Rental_Apply_Equipment_Set__r.Name
+ FROM Rental_Apply_Equipment_Set_Detail__c
+ WHERE
+ Queue_Number__c > 0
+ AND Cancel_Select__c = FALSE
+ AND ExternalKey__c IN :externalKeyList
+ AND Id NOT IN :detailIds
+ ORDER BY Queue_Number__c ASC
+ ];
+ Map<String, List<Rental_Apply_Equipment_Set_Detail__c>> detailsMap = new Map<String, List<Rental_Apply_Equipment_Set_Detail__c>>();
+ for (Rental_Apply_Equipment_Set_Detail__c setdetail : raesdList) {
+ if (!detailsMap.containsKey(setdetail.Externalkey__c)) {
+ detailsMap.put(
+ setdetail.Externalkey__c,
+ new List<Rental_Apply_Equipment_Set_Detail__c>()
+ );
}
- System.debug('缁撴潫澶勭悊------------------------------------');
+ detailsMap.get(setdetail.Externalkey__c).add(setdetail);
+ }
+ for (String key : detailsMap.keySet()) {
+ Decimal queueNo = minNumberMap.get(key);
+ System.debug(LoggingLevel.INFO, '*** queueNo: ' + queueNo);
+ Decimal i = 0;
+ for (
+ Rental_Apply_Equipment_Set_Detail__c detail : detailsMap.get(key)
+ ) {
+ System.debug(
+ LoggingLevel.INFO,
+ '*** detail.Queue_Number__c: ' + detail.Queue_Number__c
+ );
+ if (detail.Queue_Number__c > queueNo) {
+ RentalFixtureSetAssignController.KeyObj dobj = RentalFixtureSetAssignController.getSequenceInfo(
+ detail
+ );
+ sequencekeylist.addAll(dobj.sequencekeylist);
+ detail.Queue_Number__c = queueNo + i;
+ i++;
+ System.debug(
+ LoggingLevel.INFO,
+ '**111* detail.Queue_Number__c: ' + detail.Queue_Number__c
+ );
+ changeDetailList.add(detail);
+ }
+ }
+ }
+ List<String> nodusequencekeylist = new List<String>(
+ new Set<String>(sequencekeylist)
+ );
+ List<Rental_Apply_Sequence__c> sequenceList = [
+ SELECT
+ Id,
+ ExternalKey__c,
+ Demo_Purpose2__c,
+ Apply_Set_Detail__c,
+ Apply_Set_Detail_ExternalKey__c,
+ Series_No__c,
+ Salesdepartment__c,
+ Product_category__c,
+ Rental_Apply__c,
+ Internal_asset_location__c,
+ Apply_Set_Detail__r.Queue_Number__c,
+ Series_Unequal_Queue_Flag__c,
+ Fixture_Model_No__c,
+ Equipment_Type__c
+ FROM Rental_Apply_Sequence__c
+ WHERE
+ ExternalKey__c IN :nodusequencekeylist
+ AND Id NOT IN :changeSequenceIds
+ AND Series_No__c > 0
+ AND Invalid_Flag__c = FALSE
+ FOR UPDATE
+ ];
+ System.debug(LoggingLevel.INFO, '*** sequenceList: ' + sequenceList);
+ Map<String, List<Rental_Apply_Sequence__c>> sequenceMap = new Map<String, List<Rental_Apply_Sequence__c>>();
+ List<FixtureUtil.SequenceWrapper> Wrappers = new List<FixtureUtil.SequenceWrapper>();
+ for (Rental_Apply_Sequence__c se : sequenceList) {
+ Wrappers.add(new FixtureUtil.SequenceWrapper(se));
+ }
+ Wrappers.sort();
+ sequenceList = new List<Rental_Apply_Sequence__c>();
+ for (FixtureUtil.SequenceWrapper wrapper : wrappers) {
+ sequenceList.add(wrapper.sequence);
+ }
+ for (Rental_Apply_Sequence__c se : sequenceList) {
+ if (!sequenceMap.containsKey(se.Externalkey__c)) {
+ sequenceMap.put(
+ se.Externalkey__c,
+ new List<Rental_Apply_Sequence__c>()
+ );
+ }
+ sequenceMap.get(se.Externalkey__c).add(se);
+ }
+ List<Rental_Apply_Sequence__c> changeSequenceList = new List<Rental_Apply_Sequence__c>();
+ for (String key : sequenceMap.keyset()) {
+ Decimal i = 1;
+ for (Rental_Apply_Sequence__c se : sequenceMap.get(key)) {
+ if (se.Series_No__c != i) {
+ se.Series_No__c = i;
+ changeSequenceList.add(se);
+ }
+ i++;
+ }
+ }
+ update assignSequence;
+ update changeSequenceList;
+ update changeDetailList;
}
+ }
- /*
+ private void setUniqueKeyQueue() {
+ Map<Id, Rental_Apply_Equipment_Set_Detail__c> olddetailMap = (Map<Id, Rental_Apply_Equipment_Set_Detail__c>) Trigger.oldMap;
+
+ System.debug('寮�濮嬪鐞�------------------------------------');
+ System.debug(
+ '(List<Rental_Apply_Equipment_Set_Detail__c>) Trigger.new---------------' +
+ (List<Rental_Apply_Equipment_Set_Detail__c>) Trigger.new
+ );
+ for (
+ Rental_Apply_Equipment_Set_Detail__c newdetail : (List<Rental_Apply_Equipment_Set_Detail__c>) Trigger.new
+ ) {
+ System.debug(
+ newdetail.Id + ' 鐢宠鍗曞彿锛�' + newdetail.Rental_Apply__r.name
+ );
+ Rental_Apply_Equipment_Set_Detail__c olddetail = olddetailMap.get(
+ newdetail.Id
+ );
+ System.debug('鏃ф帓闃烴o锛�' + olddetail.Queue_Number__c);
+ System.debug('鏂版帓闃烴o锛�' + newdetail.Queue_Number__c);
+
+ if (
+ (olddetail.Queue_Number__c > 0 &&
+ newdetail.Queue_Number__c == 0) || // 鏆傚畾鍒嗛厤
+ (!olddetail.Cancel_Select__c &&
+ newdetail.Cancel_Select__c &&
+ olddetail.Queue_Number__c > 0) || //鍙栨秷(鎺掗槦涓紝鏆傚畾鍒嗛厤)
+ (olddetail.Queue_Number__c > 0 &&
+ newdetail.Queue_Number__c == null) //鍒嗗崟
+ ) {
+ // 娓呯┖鎺掗槦鐨刄niqueKey
+ newdetail.UniqueKey_Queue__c = null;
+ System.debug(
+ '鏂版帓闃烾niqueKey_Queue__c锛�' + newdetail.UniqueKey_Queue__c
+ );
+ }
+
+ // 閲嶆帓鎴栬�呮帓闃烴o鍙樺寲鏃舵洿鏂�
+ if (
+ !newdetail.Cancel_Select__c &&
+ newdetail.Queue_Number__c > 0 &&
+ newdetail.ExternalKey__c != null &&
+ (newdetail.Queue_Number__c != olddetail.Queue_Number__c ||
+ newdetail.ExternalKey__c != olddetail.ExternalKey__c)
+ ) {
+ // 鎺掗槦鐨刄niqueKey璁惧��
+ newdetail.UniqueKey_Queue__c =
+ newdetail.ExternalKey__c +
+ ':' +
+ newdetail.Queue_Number__c;
+ System.debug(
+ '鏂版帓闃烾niqueKey_Queue__c锛�' + newdetail.UniqueKey_Queue__c
+ );
+ }
+ }
+ System.debug('缁撴潫澶勭悊------------------------------------');
+ }
+
+ /*
private void reQueueNumber() {
Map<String, List<Rental_Apply_Equipment_Set_Detail__c>> queueRaesdMap = new Map<String, List<Rental_Apply_Equipment_Set_Detail__c>>();
String wher = '';
@@ -4750,286 +2465,384 @@
update raesdList;
}
}*/
- //鐢宠鑰呮敹鍥濶G鍚庢槑缁嗗洖瀵勬椂鐨勯偖浠跺洖瀵勫崟鍐呭璁剧疆
- //鍙湪Afterupdate閲岄潰璋冪敤
- private void receivedConfirmNGSetReturnDeliverySlipText() {
- //涓�瑙圛d鍜屽搴旂殑鍥炲瘎鍙戣揣鍗旾D
- Map<Id, Id> raesRDSMap = new Map<Id, Id>();
- Map<Id, String> raesDateMap = new Map<Id, String>();
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
- //鐢宠鑰呮敹璐G鐨勬槑缁�
- if (nObj.Received_Confirm_F__c == 'NG') {
- //鍥炲瘎杩愯緭鍗曡祴鍊�
- if (String.isBlank(oObj.Return_DeliverySlip__c) && String.isNotBlank(nObj.Return_DeliverySlip__c)) {
- //鍥犱负鏄互涓轰竴瑙堜负鍗曚綅锛屾墍浠ュ彧鏈変竴鏉″洖瀵勫崟
- //鐢宠鑰呮敹璐G鐨勬槑缁嗘媶鎴愪袱涓洖瀵勫崟鍥炲瘎鐨勬儏鍐垫殏鏃朵笉鑰冭檻锛堝簲璇ユ病鏈夎繖绉嶆儏鍐碉級
- if (!raesRDSMap.containsKey(nObj.Rental_Apply_Equipment_Set__c)) {
- raesRDSMap.put(nObj.Rental_Apply_Equipment_Set__c, nObj.Return_DeliverySlip__c);
- raesDateMap.put(nObj.Rental_Apply_Equipment_Set__c, nObj.Asset_return_time__c.format());
- }
- }
- }
+ //鐢宠鑰呮敹鍥濶G鍚庢槑缁嗗洖瀵勬椂鐨勯偖浠跺洖瀵勫崟鍐呭璁剧疆
+ //鍙湪Afterupdate閲岄潰璋冪敤
+ private void receivedConfirmNGSetReturnDeliverySlipText() {
+ //涓�瑙圛d鍜屽搴旂殑鍥炲瘎鍙戣揣鍗旾D
+ Map<Id, Id> raesRDSMap = new Map<Id, Id>();
+ Map<Id, String> raesDateMap = new Map<Id, String>();
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
+ //鐢宠鑰呮敹璐G鐨勬槑缁�
+ if (nObj.Received_Confirm_F__c == 'NG') {
+ //鍥炲瘎杩愯緭鍗曡祴鍊�
+ if (
+ String.isBlank(oObj.Return_DeliverySlip__c) &&
+ String.isNotBlank(nObj.Return_DeliverySlip__c)
+ ) {
+ //鍥犱负鏄互涓轰竴瑙堜负鍗曚綅锛屾墍浠ュ彧鏈変竴鏉″洖瀵勫崟
+ //鐢宠鑰呮敹璐G鐨勬槑缁嗘媶鎴愪袱涓洖瀵勫崟鍥炲瘎鐨勬儏鍐垫殏鏃朵笉鑰冭檻锛堝簲璇ユ病鏈夎繖绉嶆儏鍐碉級
+ if (!raesRDSMap.containsKey(nObj.Rental_Apply_Equipment_Set__c)) {
+ raesRDSMap.put(
+ nObj.Rental_Apply_Equipment_Set__c,
+ nObj.Return_DeliverySlip__c
+ );
+ raesDateMap.put(
+ nObj.Rental_Apply_Equipment_Set__c,
+ nObj.Asset_return_time__c.format()
+ );
+ }
}
- if (raesRDSMap.isEmpty()) {
- return;
- }
- //NG_Return_DeliverySlip__c涓虹┖鐨勪竴瑙堟墠鍋氶偖浠跺彂閫�
- Map<Id, Rental_Apply_Equipment_Set__c> raessMap = new Map<Id, Rental_Apply_Equipment_Set__c>([Select Id From Rental_Apply_Equipment_Set__c
- WHERE Id =: raesRDSMap.keySet()
- AND NG_Return_DeliverySlip__c = null]);
- Map<Id, FixtureDeliverySlip__c> fdss = new Map<Id, FixtureDeliverySlip__c>([Select Id, Name, Combine_Pack__c, Wh_Staff__c, DeliveryCompany__c, Shippment_loaner_time__c,
- Distributor_method__c, DeliveryCompany_SlipNo__c, DeliveryType__c
- From FixtureDeliverySlip__c
- Where Id =: raesRDSMap.values()]);
- System.debug('fdss is ' + fdss);
- List<Rental_Apply_Equipment_Set__c> raess = new List<Rental_Apply_Equipment_Set__c>();
- for (Id key: raesRDSMap.keySet()) {
- //褰揘G_Return_DeliverySlip__c涓嶄负绌烘椂涓嶅彂閭欢
- if (!raessMap.containsKey(key)) {
- continue;
- }
- FixtureDeliverySlip__c fds = fdss.get(raesRDSMap.get(key));
- String message = '鍙戣揣-鍙戣揣杩愯緭鍗曞彿锛�'
- + fds.Name + '<BR>'
- + '鍙戣揣-鐗╂祦鍏徃锛�'
- + fds.DeliveryCompany__c + '<BR>'
- + '鍙戣揣-杩愯緭鏂瑰紡锛�'
- + fds.Distributor_method__c + '<BR>'
- + '鐗╂祦鎻愯揣鏃堕棿锛�'
- + raesDateMap.get(key) + '<BR>';
- raess.add(new Rental_Apply_Equipment_Set__c(Id = key,
- NG_Return_DeliverySlip_Information__c = message,
- NG_Return_DeliverySlip__c = fds.Id));
- }
- if (!raess.isEmpty()) {
- update raess;
- }
+ }
}
-
- //璁剧疆鐢宠涔︾殑鍥炲瘎閫氱煡鏂囨湰
- @future
- private static void setRequestAsset_return_Text(Set<Id> raesdIdSet) {
- List<Rental_Apply_Equipment_Set_Detail__c> raesdList = [SELECT Id,
- Rental_Apply__c,
- Return_DeliverySlip__c,
- Rental_Apply_Equipment_Set__c,
- Fixture_Model_No_text__c,
- Lost_Item_return__c,
- NoItemReturn__c,
- Rental_Apply__r.Name,
- Rental_Apply__r.Id,
- Return_DeliverySlip__r.Id,
- Return_DeliverySlip__r.Name,
- Return_DeliverySlip__r.DeliveryCompany__c,
- Return_DeliverySlip__r.Distributor_method__c,
- Return_DeliverySlip__r.Shippment_loaner_time__c
- FROM Rental_Apply_Equipment_Set_Detail__c
- WHERE Id = :raesdIdSet
- // 鍥炲瘎閫氱煡鍙彂閫佹湁閾炬帴鍥炲瘎鍗曠殑鏄庣粏淇℃伅
- AND Return_DeliverySlip__c != null
- ORDER BY Rental_Apply__c, Rental_Apply_Equipment_Set__c, Name];
- // 鏀堕泦鍥炲瘎鏄庣粏 {raesId -> raesdList}
- Map<Id, List<Rental_Apply_Equipment_Set_Detail__c>> raesdListMap = new Map<Id, List<Rental_Apply_Equipment_Set_Detail__c>>();
- Map<Id, FixtureDeliverySlip__c> return_DeliverySlipMap = new Map<Id, FixtureDeliverySlip__c>();
- for (Rental_Apply_Equipment_Set_Detail__c raesd : raesdList) {
- if (!raesdListMap.containsKey(raesd.Rental_Apply_Equipment_Set__c)) {
- raesdListMap.put(raesd.Rental_Apply_Equipment_Set__c, new List<Rental_Apply_Equipment_Set_Detail__c>());
- }
-
- raesdListMap.get(raesd.Rental_Apply_Equipment_Set__c).add(raesd);
- /* --------- 璁剧疆杩愯緭鍗昅ap Start --------- */
- if (return_DeliverySlipMap.containsKey(raesd.Rental_Apply__c) == false) {
- FixtureDeliverySlip__c fds = raesd.Return_DeliverySlip__r;
- // 鏃犲疄鐗╁洖瀵勭殑鍥炲瘎鍗曚笉鏄剧ず鐗╂祦鍗曚俊鎭�
- if (fds.Name == raesd.Rental_Apply__r.Name + '_Dummy') {
- continue;
- }
- return_DeliverySlipMap.put(raesd.Rental_Apply__c, fds);
- }
- /* --------- 璁剧疆杩愯緭鍗昅ap End --------- */
- }
- if (raesdListMap.isEmpty()) {
- return;
- }
- // 妫�绱㈠洖瀵勭殑涓�瑙� {raId -> raesList}
- Map<Id, List<Rental_Apply_Equipment_Set__c>> raesListMap = new Map<Id, List<Rental_Apply_Equipment_Set__c>>();
- List<Rental_Apply_Equipment_Set__c> raesList = [SELECT Id,
- Loaner_code_F__c,
- Rental_Apply__c,
- Asset_return_Status__c,
- Received_Confirm__c
- FROM Rental_Apply_Equipment_Set__c
- WHERE Id =: raesdListMap.keySet()];
- for (Rental_Apply_Equipment_Set__c raes : raesList) {
- if (!raesListMap.containsKey(raes.Rental_Apply__c)) {
- raesListMap.put(raes.Rental_Apply__c, new List<Rental_Apply_Equipment_Set__c>());
- }
- raes.recalculateFormulas();
- System.debug(raes.Wei_Return__c);
- raesListMap.get(raes.Rental_Apply__c).add(raes);
- }
- List<Rental_Apply__c> raList = new List<Rental_Apply__c>();
- List<Rental_Apply__c> raList2 = new List<Rental_Apply__c>();
- String message = '';
- Integer i = 0;
- // 鐢宠涔﹀崟浣嶉兘鏄瑺鍝佸洖瀵勭殑鏄庣粏
- Boolean allLostItemReturnFlag = true;
- // 鏌ョ湅鎵�鏈夌殑鐢宠涔�
- for (Id raId : raesListMap.keySet()) {
- allLostItemReturnFlag = true;
- i = 0;
- // 鏌ョ湅鐢宠涔︿笅闈㈢殑鎵�鏈変竴瑙�
- for (Rental_Apply_Equipment_Set__c raes : raesListMap.get(raId)) {
- i++;
- message += '閰嶅' + i + '锛�' + raes.Loaner_code_F__c;
- String message2 = '<BR>';
- Boolean haveLost_Item_return = false;
- // 鏌ョ湅涓�瑙堜笅鐨勬墍鏈夋槑缁�
- for (Rental_Apply_Equipment_Set_Detail__c nObj : raesdListMap.get(raes.Id)) {
- message2 += ' ' + nObj.Fixture_Model_No_text__c;
- if (nObj.Lost_Item_return__c) {
- message2 += ' (娆犲搧褰掕繕)';
- haveLost_Item_return = true;
- }
- else {
- // 濡傛灉鏈変竴鏉′笉鏄瑺鍝佸洖瀵勯偅涔堝氨涓嶆樉绀烘瑺鍝佸洖瀵�
- allLostItemReturnFlag = false;
- }
- if (nObj.NoItemReturn__c == true) {
- message2 += ' (鏃犲疄鐗╁綊杩�)';
- }
- // if (nObj.Received_Confirm_F__c == 'NG') {
- // message += '(NG褰掕繕)';
- // }
- message2 += '<BR>';
- }
- if (haveLost_Item_return == false && raes.Received_Confirm__c == 'NG') {
- message += ' (NG褰掕繕)';
- }
- message += message2;
- }
-
- message += '<BR>';
- FixtureDeliverySlip__c fds = new FixtureDeliverySlip__c();
- if (return_DeliverySlipMap.containsKey(raId)) {
- fds = return_DeliverySlipMap.get(raId);
- }
- message += '鍥炲瘎-鍙戣揣杩愯緭鍗曞彿锛�' + (String.isBlank(fds.Name)? '' : fds.Name) + '<BR>';
- message += '鍥炲瘎-鐗╂祦鍏徃锛�' + (String.isBlank(fds.DeliveryCompany__c)? '' : fds.DeliveryCompany__c) + '<BR>';
- message += '鍥炲瘎-杩愯緭鏂瑰紡锛�' + (String.isBlank(fds.Distributor_method__c)? '' : fds.Distributor_method__c) + '<BR>';
- String sdate = fds.Shippment_loaner_time__c == null ? '' : fds.Shippment_loaner_time__c.format();
- message += '鐗╂祦鎻愯揣鏃堕棿锛�' + sdate + '<BR>';
- if (String.isNotBlank(message)) {
- raList.add(new Rental_Apply__c(Id = raId,
- Asset_return_Text__c = message,
- Lost_item_Return_Flag__c = allLostItemReturnFlag));
- raList2.add(new Rental_Apply__c(Id = raId,
- Asset_return_Text__c = null));
- message = '';
- }
- }
- if (raList.size() > 0) {
- FixtureUtil.withoutUpdate(raList2);
- FixtureUtil.withoutUpdate(raList);
- }
+ if (raesRDSMap.isEmpty()) {
+ return;
}
-
- private void setAssginPerson(Set<Id> raId) {
- List<Rental_Apply__c> raList = [select Id, Assign_Person__c from Rental_Apply__c where Id in :raId];
- List<Rental_Apply__c> updateList = new List<Rental_Apply__c>();
- for (Rental_Apply__c ra : raList) {
- if (ra.Assign_Person__c == null) {
- ra.Assign_Person__c = UserInfo.getUserId();
- updateList.add(ra);
- }
- }
- if (updateList.size() > 0) update updateList;
+ //NG_Return_DeliverySlip__c涓虹┖鐨勪竴瑙堟墠鍋氶偖浠跺彂閫�
+ Map<Id, Rental_Apply_Equipment_Set__c> raessMap = new Map<Id, Rental_Apply_Equipment_Set__c>(
+ [
+ SELECT Id
+ FROM Rental_Apply_Equipment_Set__c
+ WHERE Id = :raesRDSMap.keySet() AND NG_Return_DeliverySlip__c = NULL
+ ]
+ );
+ Map<Id, FixtureDeliverySlip__c> fdss = new Map<Id, FixtureDeliverySlip__c>(
+ [
+ SELECT
+ Id,
+ Name,
+ Combine_Pack__c,
+ Wh_Staff__c,
+ DeliveryCompany__c,
+ Shippment_loaner_time__c,
+ Distributor_method__c,
+ DeliveryCompany_SlipNo__c,
+ DeliveryType__c
+ FROM FixtureDeliverySlip__c
+ WHERE Id = :raesRDSMap.values()
+ ]
+ );
+ System.debug('fdss is ' + fdss);
+ List<Rental_Apply_Equipment_Set__c> raess = new List<Rental_Apply_Equipment_Set__c>();
+ for (Id key : raesRDSMap.keySet()) {
+ //褰揘G_Return_DeliverySlip__c涓嶄负绌烘椂涓嶅彂閭欢
+ if (!raessMap.containsKey(key)) {
+ continue;
+ }
+ FixtureDeliverySlip__c fds = fdss.get(raesRDSMap.get(key));
+ String message =
+ '鍙戣揣-鍙戣揣杩愯緭鍗曞彿锛�' +
+ fds.Name +
+ '<BR>' +
+ '鍙戣揣-鐗╂祦鍏徃锛�' +
+ fds.DeliveryCompany__c +
+ '<BR>' +
+ '鍙戣揣-杩愯緭鏂瑰紡锛�' +
+ fds.Distributor_method__c +
+ '<BR>' +
+ '鐗╂祦鎻愯揣鏃堕棿锛�' +
+ raesDateMap.get(key) +
+ '<BR>';
+ raess.add(
+ new Rental_Apply_Equipment_Set__c(
+ Id = key,
+ NG_Return_DeliverySlip_Information__c = message,
+ NG_Return_DeliverySlip__c = fds.Id
+ )
+ );
}
-
- private void changeAssetConsumable_Guaranteen_end() {
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- Rental_Apply_Equipment_Set_Detail__c oObj;
- if (trigger.isUpdate) {
- oObj = oldMap.get(nObj.Id);
- }
-
- if (oObj.Shippment_loaner_time__c == null
- && nObj.Shippment_loaner_time__c != null
- && nObj.NeedSet_Consumable_Guaranteen_end_F__c == true) {
- Asset nass = assMap.get(nObj.Asset__c);
- if (assUpdMap.containsKey(nObj.Asset__c)) {
- nass = assUpdMap.get(nObj.Asset__c);
- } else if (String.isNotBlank(nObj.Asset__c)) {
- nass = new Asset(Id = nObj.Asset__c);
- }
- Datetime dt = nObj.Shippment_loaner_time__c.addYears(1);
- nass.Consumable_Guaranteen_end__c = Date.newinstance(dT.year(), dT.month(), dT.day());
- nass.HaveSet_Consumable_Guaranteen_end__c = true;
- }
- }
+ if (!raess.isEmpty()) {
+ update raess;
}
- // 鍏佽鎻掗槦閭欢 20211125 ljh
- private void setToRa_Email_Text() {
- Set<Id> raesdIdJumpSet = new Set<Id>();//鎻掗槦鐨勬槑缁�
- for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
- Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
- // 鐢宠鎻掗槦 && 鎻掗槦鍘熷洜鍙戠敓鍙樺寲鐨�
- if((nObj.Allow_Adjust_Queue_Flag__c && oObj.Allow_Adjust_Queue_Flag__c != nObj.Allow_Adjust_Queue_Flag__c)
- ||(!String.isBlank(nObj.jumpReason__c) && oObj.jumpReason__c != nObj.jumpReason__c)
- ){
- raesdIdJumpSet.add(nObj.Id);
- }
- }
- System.debug('zheli:'+raesdIdJumpSet);
- List<Rental_Apply__c> raList = new List<Rental_Apply__c>();
- List<Rental_Apply__c> raList2 = new List<Rental_Apply__c>();
- if(raesdIdJumpSet.size() > 0){
- Map<ID,List<Rental_Apply_Equipment_Set_Detail__c>> radMap = new Map<ID,List<Rental_Apply_Equipment_Set_Detail__c>>();
- List<Rental_Apply_Equipment_Set_Detail__c> radList =[ SELECT Id, Name,RAESD_Status__c,Rental_Apply__c,Fixture_Model_No__c,Rental_Apply_Equipment_Set__c,Rental_Apply_Equipment_Set__r.Name,
- Allow_Adjust_Queue_Flag__c,jumpReason__c
- FROM Rental_Apply_Equipment_Set_Detail__c
- WHERE Id = :raesdIdJumpSet
- AND Allow_Adjust_Queue_Flag__c = TRUE
- ORDER BY Rental_Apply__c
- ];
- for (Rental_Apply_Equipment_Set_Detail__c rad:radList) {
- List<Rental_Apply_Equipment_Set_Detail__c> tempL = new List<Rental_Apply_Equipment_Set_Detail__c>();
- if(radMap.containsKey(rad.Rental_Apply__c)) {
- tempL = radMap.get(rad.Rental_Apply__c);
- }
- tempL.add(rad);
- radMap.put(rad.Rental_Apply__c,tempL);
- }
- for (Id raId: radMap.keySet()) {
- Rental_Apply__c tempRa = new Rental_Apply__c();
- Rental_Apply__c tempRa2 = new Rental_Apply__c();
- tempRa.Id = raId;
- tempRa2.Id = raId;
- String htmlStr = '';
- htmlStr += '<table border="1">';
- htmlStr += '<tr> <th>涓�瑙圢o.</th><th>鍨嬪彿</th><th>鍊熷嚭澶囧搧涓�瑙堟槑缁嗙姸鎬�</th><th>鎻掗槦鍘熷洜</th></tr>';
- for (Rental_Apply_Equipment_Set_Detail__c rad : radMap.get(raId)) {
- htmlStr += '<tr><td>'+rad.Rental_Apply_Equipment_Set__r.Name+'</td><td>'+rad.Fixture_Model_No__c+'</td><td>'+rad.RAESD_Status__c+'</td><td>'+rad.jumpReason__c+'</td></tr>';
- }
- htmlStr += '</table>';
- tempRa.Email_Jump_List__c = htmlStr;
- tempRa2.Email_Jump_List__c = null;
- tempRa.Email_Jump__c = TRUE;
- tempRa2.Email_Jump__c = FALSE;
- raList.add(tempRa);
- raList2.add(tempRa2);
- }
- }
- if (raList.size() > 0) {
- FixtureUtil.withoutUpdate(raList2);
- FixtureUtil.withoutUpdate(raList);
- }
- }
+ }
- // 20220121 鎺掗槦涓婄嚎
- //澶囧搧浠诲姟瀹屾垚鍒ゆ柇 mzy 2021-12-14
- /*private void FinishRentalTask() {
+ //璁剧疆鐢宠涔︾殑鍥炲瘎閫氱煡鏂囨湰
+ @future
+ private static void setRequestAsset_return_Text(Set<Id> raesdIdSet) {
+ List<Rental_Apply_Equipment_Set_Detail__c> raesdList = [
+ SELECT
+ Id,
+ Rental_Apply__c,
+ Return_DeliverySlip__c,
+ Rental_Apply_Equipment_Set__c,
+ Fixture_Model_No_text__c,
+ Lost_Item_return__c,
+ NoItemReturn__c,
+ Rental_Apply__r.Name,
+ Rental_Apply__r.Id,
+ Return_DeliverySlip__r.Id,
+ Return_DeliverySlip__r.Name,
+ Return_DeliverySlip__r.DeliveryCompany__c,
+ Return_DeliverySlip__r.Distributor_method__c,
+ Return_DeliverySlip__r.Shippment_loaner_time__c
+ FROM Rental_Apply_Equipment_Set_Detail__c
+ WHERE
+ Id = :raesdIdSet
+ // 鍥炲瘎閫氱煡鍙彂閫佹湁閾炬帴鍥炲瘎鍗曠殑鏄庣粏淇℃伅
+ AND Return_DeliverySlip__c != NULL
+ ORDER BY Rental_Apply__c, Rental_Apply_Equipment_Set__c, Name
+ ];
+ // 鏀堕泦鍥炲瘎鏄庣粏 {raesId -> raesdList}
+ Map<Id, List<Rental_Apply_Equipment_Set_Detail__c>> raesdListMap = new Map<Id, List<Rental_Apply_Equipment_Set_Detail__c>>();
+ Map<Id, FixtureDeliverySlip__c> return_DeliverySlipMap = new Map<Id, FixtureDeliverySlip__c>();
+ for (Rental_Apply_Equipment_Set_Detail__c raesd : raesdList) {
+ if (!raesdListMap.containsKey(raesd.Rental_Apply_Equipment_Set__c)) {
+ raesdListMap.put(
+ raesd.Rental_Apply_Equipment_Set__c,
+ new List<Rental_Apply_Equipment_Set_Detail__c>()
+ );
+ }
+
+ raesdListMap.get(raesd.Rental_Apply_Equipment_Set__c).add(raesd);
+ /* --------- 璁剧疆杩愯緭鍗昅ap Start --------- */
+ if (return_DeliverySlipMap.containsKey(raesd.Rental_Apply__c) == false) {
+ FixtureDeliverySlip__c fds = raesd.Return_DeliverySlip__r;
+ // 鏃犲疄鐗╁洖瀵勭殑鍥炲瘎鍗曚笉鏄剧ず鐗╂祦鍗曚俊鎭�
+ if (fds.Name == raesd.Rental_Apply__r.Name + '_Dummy') {
+ continue;
+ }
+ return_DeliverySlipMap.put(raesd.Rental_Apply__c, fds);
+ }
+ /* --------- 璁剧疆杩愯緭鍗昅ap End --------- */
+ }
+ if (raesdListMap.isEmpty()) {
+ return;
+ }
+ // 妫�绱㈠洖瀵勭殑涓�瑙� {raId -> raesList}
+ Map<Id, List<Rental_Apply_Equipment_Set__c>> raesListMap = new Map<Id, List<Rental_Apply_Equipment_Set__c>>();
+ List<Rental_Apply_Equipment_Set__c> raesList = [
+ SELECT
+ Id,
+ Loaner_code_F__c,
+ Rental_Apply__c,
+ Asset_return_Status__c,
+ Received_Confirm__c
+ FROM Rental_Apply_Equipment_Set__c
+ WHERE Id = :raesdListMap.keySet()
+ ];
+ for (Rental_Apply_Equipment_Set__c raes : raesList) {
+ if (!raesListMap.containsKey(raes.Rental_Apply__c)) {
+ raesListMap.put(
+ raes.Rental_Apply__c,
+ new List<Rental_Apply_Equipment_Set__c>()
+ );
+ }
+ raes.recalculateFormulas();
+ System.debug(raes.Wei_Return__c);
+ raesListMap.get(raes.Rental_Apply__c).add(raes);
+ }
+ List<Rental_Apply__c> raList = new List<Rental_Apply__c>();
+ List<Rental_Apply__c> raList2 = new List<Rental_Apply__c>();
+ String message = '';
+ Integer i = 0;
+ // 鐢宠涔﹀崟浣嶉兘鏄瑺鍝佸洖瀵勭殑鏄庣粏
+ Boolean allLostItemReturnFlag = true;
+ // 鏌ョ湅鎵�鏈夌殑鐢宠涔�
+ for (Id raId : raesListMap.keySet()) {
+ allLostItemReturnFlag = true;
+ i = 0;
+ // 鏌ョ湅鐢宠涔︿笅闈㈢殑鎵�鏈変竴瑙�
+ for (Rental_Apply_Equipment_Set__c raes : raesListMap.get(raId)) {
+ i++;
+ message += '閰嶅' + i + '锛�' + raes.Loaner_code_F__c;
+ String message2 = '<BR>';
+ Boolean haveLost_Item_return = false;
+ // 鏌ョ湅涓�瑙堜笅鐨勬墍鏈夋槑缁�
+ for (
+ Rental_Apply_Equipment_Set_Detail__c nObj : raesdListMap.get(raes.Id)
+ ) {
+ message2 +=
+ ' ' + nObj.Fixture_Model_No_text__c;
+ if (nObj.Lost_Item_return__c) {
+ message2 += ' (娆犲搧褰掕繕)';
+ haveLost_Item_return = true;
+ } else {
+ // 濡傛灉鏈変竴鏉′笉鏄瑺鍝佸洖瀵勯偅涔堝氨涓嶆樉绀烘瑺鍝佸洖瀵�
+ allLostItemReturnFlag = false;
+ }
+ if (nObj.NoItemReturn__c == true) {
+ message2 += ' (鏃犲疄鐗╁綊杩�)';
+ }
+ // if (nObj.Received_Confirm_F__c == 'NG') {
+ // message += '(NG褰掕繕)';
+ // }
+ message2 += '<BR>';
+ }
+ if (haveLost_Item_return == false && raes.Received_Confirm__c == 'NG') {
+ message += ' (NG褰掕繕)';
+ }
+ message += message2;
+ }
+
+ message += '<BR>';
+ FixtureDeliverySlip__c fds = new FixtureDeliverySlip__c();
+ if (return_DeliverySlipMap.containsKey(raId)) {
+ fds = return_DeliverySlipMap.get(raId);
+ }
+ message +=
+ '鍥炲瘎-鍙戣揣杩愯緭鍗曞彿锛�' +
+ (String.isBlank(fds.Name) ? '' : fds.Name) +
+ '<BR>';
+ message +=
+ '鍥炲瘎-鐗╂祦鍏徃锛�' +
+ (String.isBlank(fds.DeliveryCompany__c) ? '' : fds.DeliveryCompany__c) +
+ '<BR>';
+ message +=
+ '鍥炲瘎-杩愯緭鏂瑰紡锛�' +
+ (String.isBlank(fds.Distributor_method__c)
+ ? ''
+ : fds.Distributor_method__c) +
+ '<BR>';
+ String sdate = fds.Shippment_loaner_time__c == null
+ ? ''
+ : fds.Shippment_loaner_time__c.format();
+ message += '鐗╂祦鎻愯揣鏃堕棿锛�' + sdate + '<BR>';
+ if (String.isNotBlank(message)) {
+ raList.add(
+ new Rental_Apply__c(
+ Id = raId,
+ Asset_return_Text__c = message,
+ Lost_item_Return_Flag__c = allLostItemReturnFlag
+ )
+ );
+ raList2.add(
+ new Rental_Apply__c(Id = raId, Asset_return_Text__c = null)
+ );
+ message = '';
+ }
+ }
+ if (raList.size() > 0) {
+ FixtureUtil.withoutUpdate(raList2);
+ FixtureUtil.withoutUpdate(raList);
+ }
+ }
+
+ private void setAssginPerson(Set<Id> raId) {
+ List<Rental_Apply__c> raList = [
+ SELECT Id, Assign_Person__c
+ FROM Rental_Apply__c
+ WHERE Id IN :raId
+ ];
+ List<Rental_Apply__c> updateList = new List<Rental_Apply__c>();
+ for (Rental_Apply__c ra : raList) {
+ if (ra.Assign_Person__c == null) {
+ ra.Assign_Person__c = UserInfo.getUserId();
+ updateList.add(ra);
+ }
+ }
+ if (updateList.size() > 0)
+ update updateList;
+ }
+
+ private void changeAssetConsumable_Guaranteen_end() {
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ Rental_Apply_Equipment_Set_Detail__c oObj;
+ if (Trigger.isUpdate) {
+ oObj = oldMap.get(nObj.Id);
+ }
+
+ if (
+ oObj.Shippment_loaner_time__c == null &&
+ nObj.Shippment_loaner_time__c != null &&
+ nObj.NeedSet_Consumable_Guaranteen_end_F__c == true
+ ) {
+ Asset nass = assMap.get(nObj.Asset__c);
+ if (assUpdMap.containsKey(nObj.Asset__c)) {
+ nass = assUpdMap.get(nObj.Asset__c);
+ } else if (String.isNotBlank(nObj.Asset__c)) {
+ nass = new Asset(Id = nObj.Asset__c);
+ }
+ Datetime dt = nObj.Shippment_loaner_time__c.addYears(1);
+ nass.Consumable_Guaranteen_end__c = Date.newinstance(
+ dT.year(),
+ dT.month(),
+ dT.day()
+ );
+ nass.HaveSet_Consumable_Guaranteen_end__c = true;
+ }
+ }
+ }
+ // 鍏佽鎻掗槦閭欢 20211125 ljh
+ private void setToRa_Email_Text() {
+ Set<Id> raesdIdJumpSet = new Set<Id>(); //鎻掗槦鐨勬槑缁�
+ for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
+ Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
+ // 鐢宠鎻掗槦 && 鎻掗槦鍘熷洜鍙戠敓鍙樺寲鐨�
+ if (
+ (nObj.Allow_Adjust_Queue_Flag__c &&
+ oObj.Allow_Adjust_Queue_Flag__c != nObj.Allow_Adjust_Queue_Flag__c) ||
+ (!String.isBlank(nObj.jumpReason__c) &&
+ oObj.jumpReason__c != nObj.jumpReason__c)
+ ) {
+ raesdIdJumpSet.add(nObj.Id);
+ }
+ }
+ System.debug('zheli:' + raesdIdJumpSet);
+ List<Rental_Apply__c> raList = new List<Rental_Apply__c>();
+ List<Rental_Apply__c> raList2 = new List<Rental_Apply__c>();
+ if (raesdIdJumpSet.size() > 0) {
+ Map<ID, List<Rental_Apply_Equipment_Set_Detail__c>> radMap = new Map<ID, List<Rental_Apply_Equipment_Set_Detail__c>>();
+ List<Rental_Apply_Equipment_Set_Detail__c> radList = [
+ SELECT
+ Id,
+ Name,
+ RAESD_Status__c,
+ Rental_Apply__c,
+ Fixture_Model_No__c,
+ Rental_Apply_Equipment_Set__c,
+ Rental_Apply_Equipment_Set__r.Name,
+ Allow_Adjust_Queue_Flag__c,
+ jumpReason__c
+ FROM Rental_Apply_Equipment_Set_Detail__c
+ WHERE Id = :raesdIdJumpSet AND Allow_Adjust_Queue_Flag__c = TRUE
+ ORDER BY Rental_Apply__c
+ ];
+ for (Rental_Apply_Equipment_Set_Detail__c rad : radList) {
+ List<Rental_Apply_Equipment_Set_Detail__c> tempL = new List<Rental_Apply_Equipment_Set_Detail__c>();
+ if (radMap.containsKey(rad.Rental_Apply__c)) {
+ tempL = radMap.get(rad.Rental_Apply__c);
+ }
+ tempL.add(rad);
+ radMap.put(rad.Rental_Apply__c, tempL);
+ }
+ for (Id raId : radMap.keySet()) {
+ Rental_Apply__c tempRa = new Rental_Apply__c();
+ Rental_Apply__c tempRa2 = new Rental_Apply__c();
+ tempRa.Id = raId;
+ tempRa2.Id = raId;
+ String htmlStr = '';
+ htmlStr += '<table border="1">';
+ htmlStr += '<tr> <th>涓�瑙圢o.</th><th>鍨嬪彿</th><th>鍊熷嚭澶囧搧涓�瑙堟槑缁嗙姸鎬�</th><th>鎻掗槦鍘熷洜</th></tr>';
+ for (Rental_Apply_Equipment_Set_Detail__c rad : radMap.get(raId)) {
+ htmlStr +=
+ '<tr><td>' +
+ rad.Rental_Apply_Equipment_Set__r.Name +
+ '</td><td>' +
+ rad.Fixture_Model_No__c +
+ '</td><td>' +
+ rad.RAESD_Status__c +
+ '</td><td>' +
+ rad.jumpReason__c +
+ '</td></tr>';
+ }
+ htmlStr += '</table>';
+ tempRa.Email_Jump_List__c = htmlStr;
+ tempRa2.Email_Jump_List__c = null;
+ tempRa.Email_Jump__c = true;
+ tempRa2.Email_Jump__c = false;
+ raList.add(tempRa);
+ raList2.add(tempRa2);
+ }
+ }
+ if (raList.size() > 0) {
+ FixtureUtil.withoutUpdate(raList2);
+ FixtureUtil.withoutUpdate(raList);
+ }
+ }
+
+ // 20220121 鎺掗槦涓婄嚎
+ //澶囧搧浠诲姟瀹屾垚鍒ゆ柇 mzy 2021-12-14
+ /*private void FinishRentalTask() {
Set<String> RentalList = new Set<String>();
for (Rental_Apply_Equipment_Set_Detail__c nObj : newList) {
Rental_Apply_Equipment_Set_Detail__c oObj = oldMap.get(nObj.Id);
@@ -5193,5 +3006,5 @@
}
}*/
- // 20220121 鎺掗槦涓婄嚎
-}
\ No newline at end of file
+ // 20220121 鎺掗槦涓婄嚎
+}
diff --git a/force-app/main/default/classes/ResponseBodyLWCTest.cls b/force-app/main/default/classes/ResponseBodyLWCTest.cls
new file mode 100644
index 0000000..686be82
--- /dev/null
+++ b/force-app/main/default/classes/ResponseBodyLWCTest.cls
@@ -0,0 +1,18 @@
+@isTest
+public class ResponseBodyLWCTest {
+ static testMethod void test1() {
+ ResponseBodyLWC l1 = new ResponseBodyLWC();
+ ResponseBodyLWC l2 = new ResponseBodyLWC(
+ 'status',
+ 200,
+ 'testmsg',
+ new Map<String, String>()
+ );
+ ResponseBodyLWC l3 = new ResponseBodyLWC(
+ 'status',
+ 200,
+ 'testmsg',
+ new List<Object>()
+ );
+ }
+}
diff --git a/force-app/main/default/classes/ResponseBodyLWCTest.cls-meta.xml b/force-app/main/default/classes/ResponseBodyLWCTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/ResponseBodyLWCTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/classes/lexSearchAgencyHospitalControllerTest.cls b/force-app/main/default/classes/lexSearchAgencyHospitalControllerTest.cls
new file mode 100644
index 0000000..b4bbcbf
--- /dev/null
+++ b/force-app/main/default/classes/lexSearchAgencyHospitalControllerTest.cls
@@ -0,0 +1,107 @@
+@isTest
+private class lexSearchAgencyHospitalControllerTest {
+ @isTest
+ static void testInit() {
+ User myUser_test;
+ Account myAccount2;
+ Product2__c pro2;
+ User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
+ System.runAs(thisUser) {
+ 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)'
+ ];
+ Product2 prod02 = new Product2(
+ Name = 'Test02181',
+ ProductCode = 'Test0218',
+ Asset_Model_No__c = 'Test0218',
+ SFDA_Status__c = '鏈夊姽',
+ Dealer_special_Object__c = true,
+ SFDA_Approbation_No__c = 'Test002',
+ Packing_list_manual__c = 12,
+ SFDA_Expiration_Date__c = Date.today(),
+ Category5__c = 'tset8',
+ Manual_Entry__c = false
+ );
+ pro2 = new Product2__c(
+ Name = 'Pro002181',
+ OT_CODE_Text__c = 'Test002181',
+ Product2__c = prod02.Id
+ );
+ insert pro2;
+ myAccount2 = new Account(
+ name = 'Testaccount003',
+ Dealer_discount__c = 20,
+ RecordTypeId = rectCo[0].Id,
+ AgentCode_Ext__c = '2'
+ );
+ insert myAccount2;
+
+ Contact core = new Contact(
+ email = 'wan@salesforce.com',
+ firstname = 'wan',
+ lastname = 'Plumbers',
+ accountid = myAccount2.id
+ );
+ insert core;
+ 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 = 'ENG',
+ Work_Location__c = '鍖椾含'
+ );
+ insert myUser_test;
+ myUser_test.UserPro_Type__c = '';
+ update myUser_test;
+ }
+ System.runAs(MyUser_Test) {
+ System.Test.startTest();
+ String accountId = myUser_test.accountid;
+ String agencyProType = myUser_test.UserPro_Type__c;
+ String searchName = '';
+ List<Agency_Hospital_Link__c> ahlInfo = [
+ SELECT Hospital__c, Hospital__r.Name
+ FROM Agency_Hospital_Link__c
+ WHERE Agency__c = :accountId AND Hosptial_Type__c != NULL
+ LIMIT 1
+ ];
+ Set<Id> whoIds = new Set<Id>();
+ for (Agency_Hospital_Link__c ahl : ahlInfo) {
+ whoIds.add(ahl.Hospital__c);
+ if (String.isBlank(searchName)) {
+ searchName = ahl.Hospital__r.Name;
+ }
+ }
+ Map<ID, Account> accInfo = new Map<ID, Account>(
+ [
+ SELECT Id, Name, State_Master__c, State_Master__r.Name
+ FROM Account
+ WHERE Id IN :whoIds
+ ]
+ );
+ Map<String, object> data = new Map<String, object>();
+ data.put('accInfo', accInfo);
+ String ctype = 'ET';
+ lexSearchAgencyHospitalController.init(ctype);
+ lexSearchAgencyHospitalController.serContact(searchName, ctype);
+ System.Test.stopTest();
+ }
+ }
+}
diff --git a/force-app/main/default/classes/lexSearchAgencyHospitalControllerTest.cls-meta.xml b/force-app/main/default/classes/lexSearchAgencyHospitalControllerTest.cls-meta.xml
new file mode 100644
index 0000000..a9fd6e9
--- /dev/null
+++ b/force-app/main/default/classes/lexSearchAgencyHospitalControllerTest.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+ <apiVersion>57.0</apiVersion>
+ <status>Active</status>
+</ApexClass>
diff --git a/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.html b/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.html
index 9a4bd7e..78a8aec 100644
--- a/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.html
+++ b/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.html
@@ -1,201 +1,354 @@
<template>
- <template if:true={showSpinner}>
- <!-- <lightning-spinner size="medium" variant="brand"></lightning-spinner> -->
- <div class="slds-spinner_container">
- <div role="status" class="slds-spinner slds-spinner_medium slds-spinner_brand">
- <span class="slds-assistive-text">Loading</span>
- <div class="slds-spinner__dot-a"></div>
- <div class="slds-spinner__dot-b"></div>
+ <template if:true={showSpinner}>
+ <!-- <lightning-spinner size="medium" variant="brand"></lightning-spinner> -->
+ <div class="slds-spinner_container">
+ <div
+ role="status"
+ class="slds-spinner slds-spinner_medium slds-spinner_brand"
+ >
+ <span class="slds-assistive-text">Loading</span>
+ <div class="slds-spinner__dot-a"></div>
+ <div class="slds-spinner__dot-b"></div>
+ </div>
+ </div>
+ </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: 74px">
+ <div style="color: #696969; font-size: 16px">
+ 璁㈠崟鍚嶇О
+ </div>
+ </td>
+ <td style="width: 200px">
+ <lightning-formatted-text
+ style="font-size: 16px"
+ value={coc.Name}
+ ></lightning-formatted-text>
+ </td>
+ <td style="width: 30px"></td>
+ <td style="width: 74px">
+ <div style="color: #696969; font-size: 16px">
+ 璁㈠崟鎬绘暟
+ </div>
+ </td>
+ <td style="width: 100px">
+ <lightning-formatted-number
+ style="font-size: 16px"
+ value={coc.Total_num__c}
+ ></lightning-formatted-number>
+ </td>
+ <td style="width: 30px"></td>
+ <td style="width: 90px">
+ <div style="color: #696969; font-size: 16px">
+ 宸插埌璐ф暟閲�
+ </div>
+ </td>
+ <td style="width: 100px">
+ <lightning-formatted-number
+ style="font-size: 16px"
+ value={coc.OrderNumber_arrived__c}
+ ></lightning-formatted-number>
+ </td>
+ <td style="width: 30px"></td>
+ <td style="width: 106px">
+ <div style="color: #696969; font-size: 16px">
+ 杩樻病鍙戣揣鏁伴噺
+ </div>
+ </td>
+ <td style="width: 100px">
+ <lightning-formatted-number
+ style="font-size: 16px"
+ 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>
- <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> -->
+ <!-- 璀﹀憡鎻愰啋 -->
+ <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> 璀﹀憡</strong>
</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> 璀﹀憡</strong>
- </div>
- <template for:each={warningMsgs} for:item="msg">
- <p key={msg} style="color:#ff6a00;padding-left:7px;font-size:14px;"> 銉� {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> 閿欒</strong>
- </div>
- <template for:each={errorMsgs} for:item="msg">
- <p key={msg} style="color:red;padding-left:7px;font-size:14px;"> 銉� {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" style="word-wrap:break-word; word-break:break-all;" 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" style="word-wrap:break-word; word-break:break-all;" 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" style="word-wrap:break-word; word-break:break-all;" 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;">
+ <template for:each={warningMsgs} for:item="msg">
+ <p
+ key={msg}
+ style="color: #ff6a00; padding-left: 7px; font-size: 14px"
+ >
+ 銉� {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> 閿欒</strong>
+ </div>
+ <template for:each={errorMsgs} for:item="msg">
+ <p
+ key={msg}
+ style="color: red; padding-left: 7px; font-size: 14px"
+ >
+ 銉� {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"
+ style="word-wrap: break-word; word-break: break-all"
+ 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"
+ style="word-wrap: break-word; word-break: break-all"
+ 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"
+ style="word-wrap: break-word; word-break: break-all"
+ 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">
@@ -209,23 +362,37 @@
<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" style="word-wrap:break-word; word-break:break-all;" hide-checkbox-column key-field="recordId" columns={errorDetailCols} data={consumableorderdetailsRecordserror}></lightning-datatable>
- </div>
- </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"
+ style="word-wrap: break-word; word-break: break-all"
+ hide-checkbox-column
+ key-field="recordId"
+ columns={errorDetailCols}
+ data={consumableorderdetailsRecordserror}
+ ></lightning-datatable>
+ </div>
</div>
- </template>
-</template>
\ No newline at end of file
+ </div>
+ </div>
+ </template>
+</template>
diff --git a/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.js b/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.js
index 796a99c..50cb5f6 100644
--- a/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.js
+++ b/force-app/main/default/lwc/lexArriveGoods/lexArriveGoods.js
@@ -1,482 +1,800 @@
-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 { 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;
+ //椤甸潰鍙橀噺
+ @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 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;
- }
+ //鏄惁鏈夐敊璇�
+ 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:55,cellAttributes: { alignment: "right" }},
- {label:'CFDA鐘舵��' , fieldName:'status', hideDefaultActions: true,wrapText:true,initialWidth:120},
- {label:'娉ㄥ唽璇佺紪鐮佸彿' , fieldName:'reportProductApprobation', hideDefaultActions: true,wrapText:true,initialWidth:190},
- {label:'娉ㄥ唽璇佹晥鏈�' , fieldName:'ReportProductExpirationDate', hideDefaultActions: true,wrapText:true,initialWidth:110},
- {label:'BarCode' , fieldName:'barCode', hideDefaultActions: true,wrapText: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,initialWidth:180});
- // 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,wrapText: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:150});
- // cols.push({label:'杩斿搧鍘熷洜' , fieldName:'returnReason', hideDefaultActions: true});
- return cols;
+ //鏈鍒拌揣浜у搧姹囨�籧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
- get inDetailCols(){
- var cols = [];
- cols.push({label:'娑堣�楀搧鍚嶇О' , fieldName:'prodName', hideDefaultActions: true,wrapText:true});
- cols.push({label:'BarCode' , fieldName:'barCodeNo', hideDefaultActions: true,wrapText:true,initialWidth:500});
- 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 arrDetailCols = [
+ {
+ label: "娑堣�楀搧鍚嶇О",
+ fieldName: "prodName",
+ hideDefaultActions: true,
+ wrapText: true
+ },
+ {
+ label: "瑙勬牸",
+ fieldName: "productPackingListManual",
+ hideDefaultActions: true,
+ wrapText: true,
+ initialWidth: 55,
+ cellAttributes: { alignment: "right" }
+ },
+ {
+ label: "CFDA鐘舵��",
+ fieldName: "status",
+ hideDefaultActions: true,
+ wrapText: true,
+ initialWidth: 120
+ },
+ {
+ label: "娉ㄥ唽璇佺紪鐮佸彿",
+ fieldName: "reportProductApprobation",
+ hideDefaultActions: true,
+ wrapText: true,
+ initialWidth: 190
+ },
+ {
+ label: "娉ㄥ唽璇佹晥鏈�",
+ fieldName: "ReportProductExpirationDate",
+ hideDefaultActions: true,
+ wrapText: true,
+ initialWidth: 110
+ },
+ {
+ label: "BarCode",
+ fieldName: "barCode",
+ hideDefaultActions: true,
+ wrapText: true,
+ initialWidth: 400
}
- //閿欒鏄庣粏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}
- ];
+ ];
+ //杩斿搧鏄庣粏cols
+ get returnDetailCols() {
+ var cols = [];
+ cols.push({
+ label: "鍑哄簱鍗�",
+ fieldName: "orderUrl",
+ type: "url",
+ typeAttributes: {
+ label: { fieldName: "orderNo" },
+ target: "_blank"
+ },
+ hideDefaultActions: true,
+ wrapText: true,
+ initialWidth: 180
+ });
+ // 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,
+ wrapText: 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: 150
+ });
+ // 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: 500
+ });
+ 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;
- }
+ // 鑾峰彇鍙傛暟
+ @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;
- }
+ 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");
- });
- }
+ 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');
+ //鍒濆鍖�
+ 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;
}
- })
- .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){
- this.consumableorderdetailsRecords[i]['dataType'] = 'DataileRecords';
- consumableorderdetailsRecordsview.push(this.consumableorderdetailsRecords[i]);
- }
- for(var i in this.consumableInventory){
- this.consumableInventory[i]['dataType'] = 'Inventory';
- 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]['dataType'] == 'Inventory'){
- this.consumableorderdetailsRecordsview[i]['barCode'] = this.consumableorderdetailsRecordsview[i].barCodeNo;
- }else if(this.consumableorderdetailsRecordsview[i].esd != null){
- this.consumableorderdetailsRecordsview[i]['barCode'] = this.consumableorderdetailsRecordsview[i].esd.Bar_Code__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;
- }
- }
- 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){
- this.showGoodsofReturnList[i]['dataType'] = 'GoodsoOfReturn';
- showGoodsofReturnListView.push(this.showGoodsofReturnList[i]);
- }
- for(var i in this.consumableInventory){
- this.consumableInventory[i]['dataType'] = 'Inventory';
- 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]['dataType'] == 'Inventory'){
- this.showGoodsofReturnListView[i]['barCode'] = this.showGoodsofReturnListView[i].barCodeNo;
- }else if(this.showGoodsofReturnListView[i].esd != null){
- this.showGoodsofReturnListView[i]['barCode'] = this.showGoodsofReturnListView[i].esd.Bar_Code__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]['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;
- if(this.errorMsgs.length < 1){
- 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');
+ }
+ console.log(
+ "this.detailsSummary:" + JSON.stringify(this.detailsSummary)
+ );
+ this.consumableorderdetailsRecords =
+ result.consumableorderdetailsRecords;
+ var consumableorderdetailsRecordsview = [];
+ for (var i in this.consumableorderdetailsRecords) {
+ this.consumableorderdetailsRecords[i]["dataType"] =
+ "DataileRecords";
+ consumableorderdetailsRecordsview.push(
+ this.consumableorderdetailsRecords[i]
+ );
+ }
+ for (var i in this.consumableInventory) {
+ this.consumableInventory[i]["dataType"] = "Inventory";
+ 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;
}
- })
- .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;
- }
+ if (
+ this.consumableorderdetailsRecordsview[i]["dataType"] ==
+ "Inventory"
+ ) {
+ this.consumableorderdetailsRecordsview[i]["barCode"] =
+ this.consumableorderdetailsRecordsview[i].barCodeNo;
+ } else if (this.consumableorderdetailsRecordsview[i].esd != null) {
+ this.consumableorderdetailsRecordsview[i]["barCode"] =
+ this.consumableorderdetailsRecordsview[i].esd.Bar_Code__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;
+ }
+ }
+ 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) {
+ this.showGoodsofReturnList[i]["dataType"] = "GoodsoOfReturn";
+ showGoodsofReturnListView.push(this.showGoodsofReturnList[i]);
+ }
+ for (var i in this.consumableInventory) {
+ this.consumableInventory[i]["dataType"] = "Inventory";
+ 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]["dataType"] == "Inventory") {
+ this.showGoodsofReturnListView[i]["barCode"] =
+ this.showGoodsofReturnListView[i].barCodeNo;
+ } else if (this.showGoodsofReturnListView[i].esd != null) {
+ this.showGoodsofReturnListView[i]["barCode"] =
+ this.showGoodsofReturnListView[i].esd.Bar_Code__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]["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;
+ if (this.errorMsgs.length < 1) {
+ 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
- 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;
- }
+ //杩斿搧鏁伴噺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;
}
+ }
}
+ }
- // 鍒拌揣纭
- 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');
+ //杩斿搧鍘熷洜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
}
- })
- .catch(error=>{
- this.showSpinner = false;
- console.log("error2:"+error);
- this.showMyToast('鍒拌揣纭澶辫触',error,'error');
- })
- }
+ };
+ 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 {
- console.log("error1:"+result.errorMsg);
- this.showSpinner = false;
- this.warningMsgs = result.warningMsgList;
- this.errorMsgs = result.errorMsgList;
- if(result.errorMsg.includes('鏃犳硶淇濆瓨姝よ褰�')){
- result.errorMsg = '鏃犳硶淇濆瓨璁板綍';
- }
- this.showMyToast('鐧诲綍杩斿搧澶辫触',result.errorMsg,'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
}
- })
- .catch(error=>{
- this.showSpinner = false;
- console.log("error2:"+JSON.stringify(error));
- this.showMyToast('鐧诲綍杩斿搧澶辫触',error,'error');
- })
- }
+ };
+ this[NavigationMixin.Navigate](config);
+ } else {
+ console.log("error1:" + result.errorMsg);
+ this.showSpinner = false;
+ this.warningMsgs = result.warningMsgList;
+ this.errorMsgs = result.errorMsgList;
+ if (result.errorMsg.includes("鏃犳硶淇濆瓨姝よ褰�")) {
+ 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);
- }
-}
\ No newline at end of file
+ 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/pages/OFSInsReportLayout.page b/force-app/main/default/pages/OFSInsReportLayout.page
index c1826ae..ec0e16f 100644
--- a/force-app/main/default/pages/OFSInsReportLayout.page
+++ b/force-app/main/default/pages/OFSInsReportLayout.page
@@ -1,38 +1,79 @@
-<apex:page id="Page" showHeader="false" sidebar="false" controller="OFSInsReportLayoutController" applyBodyTag="false" applyHtmlTag="false" action="{!init}" lightningStylesheets="true">
-<!-- <apex:page id="Page" showHeader="false" sidebar="false" standardcontroller="Inspection_Item__c" extensions="OFSInsReportLayoutController" applyBodyTag="false" applyHtmlTag="false" action="{!init}"> -->
-<html>
-<head>
- <meta name="viewport" content="width=1150,user-scalable=yes" /> <!-- TODO 1150銇偝銉炽儐銉炽儎銇箙 -->
- <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
- <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
- <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
- <apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
- <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
- <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
- <style type="text/css">
+<apex:page
+ id="Page"
+ showHeader="false"
+ sidebar="false"
+ controller="OFSInsReportLayoutController"
+ applyBodyTag="false"
+ applyHtmlTag="false"
+ action="{!init}"
+ lightningStylesheets="true"
+>
+ <!-- <apex:page id="Page" showHeader="false" sidebar="false" standardcontroller="Inspection_Item__c" extensions="OFSInsReportLayoutController" applyBodyTag="false" applyHtmlTag="false" action="{!init}"> -->
+ <html>
+ <head>
+ <meta name="viewport" content="width=1150,user-scalable=yes" />
+ <!-- TODO 1150銇偝銉炽儐銉炽儎銇箙 -->
+ <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}" />
+ <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}" />
+ <apex:includeScript value="{!URLFOR($Resource.connection20)}" />
+ <apex:includeScript value="{!URLFOR($Resource.apex20)}" />
+ <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}" />
+ <apex:includeScript
+ value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"
+ />
+ <style type="text/css">
table#AssetTable select {
- width: 98%;
+ width: 98%;
}
table#AssetTableHeader .headerCell {
- box-sizing: border-box;
- padding: 2px 1px;
+ box-sizing: border-box;
+ padding: 2px 1px;
}
table#AssetTable .dataCell {
- box-sizing: border-box;
- padding: 1px 1px;
+ box-sizing: border-box;
+ padding: 1px 1px;
}
.bPageBlock .dataCol .requiredInput {
- display: inline-table;
+ display: inline-table;
}
.bPageBlock .detailList .labelCol {
- width: 1%;
+ width: 1%;
}
- .dateFormat {
- display: none;
+ .dateFormat {
+ display: none;
}
-
- </style>
- <script type="text/javascript">
+ table.detailList td:nth-child(4) .requiredInput select {
+ min-width: 150px;
+ width: 150px;
+ }
+ table.detailList td:nth-child(4) .requiredInput .lookupInput input {
+ min-width: 180px;
+ width: 180px;
+ }
+ body .bPageBlock .detailList .labelCol,
+ .slds-vf-scope .bPageBlock .detailList .labelCol {
+ width: 9%;
+ }
+ body .bPageBlock .detailList .dataCol {
+ width: auto;
+ }
+ table.detailList tr:nth-child(2) .dataCol .requiredInput span input,
+ table.detailList tr:nth-child(3) .dataCol span.dateInput > input {
+ min-width: 150px;
+ width: 100px;
+ }
+ table.detailList td.dataCol.last input {
+ min-width: 150px;
+ width: 150px;
+ }
+
+ table.detailList tr:nth-child(2) .dataCol:nth-child(4) > input,
+ table.detailList tr:nth-child(3) .dataCol:nth-child(4) > input {
+ width: 20px;
+ min-width: 50px;
+ }
+ </style>
+ <script type="text/javascript">
var tmpaid = "";
var tmpan = "";
var tmpahid = "";
@@ -44,706 +85,1420 @@
var tmpinsid = "";
var tmpinsn = "";
var tmprstr = "";
- sforce.connection.sessionId = '{!$Api.Session_ID}';
+ sforce.connection.sessionId = "{!$Api.Session_ID}";
function toggleIrNameDisabled(checker) {
- if (checker.checked) {
- j$(escapeVfId('Page:Form:Block:Ir_Name')).prop("disabled", false);
- } else {
- j$(escapeVfId('Page:Form:Block:Ir_Name')).prop("disabled", true);
- }
+ if (checker.checked) {
+ j$(escapeVfId("Page:Form:Block:Ir_Name")).prop("disabled", false);
+ } else {
+ j$(escapeVfId("Page:Form:Block:Ir_Name")).prop("disabled", true);
+ }
}
function changeAllCheckResult(val) {
- var cnt = j$(escapeVfId('ProductCnt')).val();
- for (var i = 0; i < cnt; i++) {
- if (val == ' ') {
- document.getElementById('Page:Form:Block:CheckSection:CheckedInfoList:' + i + ':AssetRowCheckboxIsNormal').value = '';
- } else {
- document.getElementById('Page:Form:Block:CheckSection:CheckedInfoList:' + i + ':AssetRowCheckboxIsNormal').value = val;
- }
+ var cnt = j$(escapeVfId("ProductCnt")).val();
+ for (var i = 0; i < cnt; i++) {
+ if (val == " ") {
+ document.getElementById(
+ "Page:Form:Block:CheckSection:CheckedInfoList:" +
+ i +
+ ":AssetRowCheckboxIsNormal"
+ ).value = "";
+ } else {
+ document.getElementById(
+ "Page:Form:Block:CheckSection:CheckedInfoList:" +
+ i +
+ ":AssetRowCheckboxIsNormal"
+ ).value = val;
}
+ }
}
function clearAndSearch() {
- document.getElementById("Page:Form:Block:UnCheckSection:text1").value = "";
- document.getElementById("Page:Form:Block:UnCheckSection:cond1").value = "equals";
- document.getElementById("Page:Form:Block:UnCheckSection:val1").value = "";
- blockme();
- searchfunc();
+ document.getElementById(
+ "Page:Form:Block:UnCheckSection:text1"
+ ).value = "";
+ document.getElementById(
+ "Page:Form:Block:UnCheckSection:cond1"
+ ).value = "equals";
+ document.getElementById("Page:Form:Block:UnCheckSection:val1").value =
+ "";
+ blockme();
+ searchfunc();
}
function searchJs() {
- blockme();
- searchfunc();
+ blockme();
+ searchfunc();
}
function sortTableJs(key) {
- blockme();
- sortTablefunc(key);
+ blockme();
+ sortTablefunc(key);
}
function exchangeAssetJs() {
+ blockme();
+ exchangeAssetfunc();
+ }
+
+ function saveByRepairJs(
+ aid,
+ an,
+ ahid,
+ ahn,
+ adid,
+ adn,
+ aaid,
+ aan,
+ rstr
+ ) {
+ tmpaid = aid;
+ tmpan = an;
+ tmpahid = ahid;
+ tmpahn = ahn;
+ tmpadid = adid;
+ tmpadn = adn;
+ tmpaaid = aaid;
+ tmpaan = aan;
+ tmprstr = rstr;
+ // 鐐规鍫卞憡鏇稿鏇淬仹銇嶃仾銇忋仸銈傘�佷慨鐞嗐倰浣溿倢銈嬶紵
+ if (tmpinsid == "") {
blockme();
- exchangeAssetfunc();
+ saveByRepair();
+ } else {
+ openRepair();
+ }
}
- function saveByRepairJs(aid, an, ahid, ahn, adid, adn, aaid, aan, rstr) {
- tmpaid = aid;
- tmpan = an;
- tmpahid = ahid;
- tmpahn = ahn;
- tmpadid = adid;
- tmpadn = adn;
- tmpaaid = aaid;
- tmpaan = aan;
- tmprstr = rstr;
- // 鐐规鍫卞憡鏇稿鏇淬仹銇嶃仾銇忋仸銈傘�佷慨鐞嗐倰浣溿倢銈嬶紵
- if (tmpinsid == "") {
- blockme();
- saveByRepair();
- } else {
- openRepair();
- }
-}
-
-function openRepair() {
- // TODO 浠婂緦鎺$暘銉嗐兗銉栥儷銈掍娇銇凬ame銈掑彇寰椼�佺偣妞滃牨鍛婃浉銇竴鏅傜殑銇倐銇仹銇�
- window.open('/a0J/e?retURL=%2F' + tmpaid + '&CF00N10000002Dx66_lkid=' + tmpahid + '&CF00N10000002Dx66=' + encodeURIComponent(tmpahn) + '&CF00N10000002Dx5t_lkid=' + tmpadid + '&CF00N10000002Dx5t=' + encodeURIComponent(tmpadn) + '&CF00N10000002Dx5n_lkid=' + tmpaaid + '&CF00N10000002Dx5n=' + encodeURIComponent(tmpaan) + '&CF00N10000002Dx1X_lkid=' + tmpaid + '&CF00N10000002Dx1X=' + encodeURIComponent(tmpan) + '&00N10000002FH86=' + encodeURIComponent(tmprstr) + '&CF00N10000006PRCp=' + encodeURIComponent(tmpinsn) + '&CF00N10000006PRCp_lkid=' + tmpinsid, '_blank');
-}
-//add by rentx 20210809 鍏ㄩ�夊姛鑳� start
-function checkAll(checker) {
- var cnt = j$(escapeVfId('ProductCnt')).val();
- for (var i = 0; i < cnt; i++) {
- if (j$(escapeVfId('Page:Form:Block:CheckSection:CheckedInfoList:'+i+':AssetRowCheckbox1')).size() == 0) {
- break;
+ function openRepair() {
+ // TODO 浠婂緦鎺$暘銉嗐兗銉栥儷銈掍娇銇凬ame銈掑彇寰椼�佺偣妞滃牨鍛婃浉銇竴鏅傜殑銇倐銇仹銇�
+ window.open(
+ "/a0J/e?retURL=%2F" +
+ tmpaid +
+ "&CF00N10000002Dx66_lkid=" +
+ tmpahid +
+ "&CF00N10000002Dx66=" +
+ encodeURIComponent(tmpahn) +
+ "&CF00N10000002Dx5t_lkid=" +
+ tmpadid +
+ "&CF00N10000002Dx5t=" +
+ encodeURIComponent(tmpadn) +
+ "&CF00N10000002Dx5n_lkid=" +
+ tmpaaid +
+ "&CF00N10000002Dx5n=" +
+ encodeURIComponent(tmpaan) +
+ "&CF00N10000002Dx1X_lkid=" +
+ tmpaid +
+ "&CF00N10000002Dx1X=" +
+ encodeURIComponent(tmpan) +
+ "&00N10000002FH86=" +
+ encodeURIComponent(tmprstr) +
+ "&CF00N10000006PRCp=" +
+ encodeURIComponent(tmpinsn) +
+ "&CF00N10000006PRCp_lkid=" +
+ tmpinsid,
+ "_blank"
+ );
}
- document.getElementById('Page:Form:Block:CheckSection:CheckedInfoList:'+i+':AssetRowCheckbox1').checked = checker.checked;
- }
-}
-function checkAll2(checker) {
- var cnt = j$(escapeVfId('ProductCnt2')).val();
- var tempi = parseInt(cnt / 900 )+1;
- for (var j = 0; j < tempi; j++) {
- for (var i = 0; i < 900; i++) {
- if (j$(escapeVfId('Page:Form:Block:UnCheckSection:unCheckedInfoListForThousend:'+j+':UnCheckedInfoList:'+i+':AssetRowCheckbox2')).size() == 0) {
+ //add by rentx 20210809 鍏ㄩ�夊姛鑳� start
+ function checkAll(checker) {
+ var cnt = j$(escapeVfId("ProductCnt")).val();
+ for (var i = 0; i < cnt; i++) {
+ if (
+ j$(
+ escapeVfId(
+ "Page:Form:Block:CheckSection:CheckedInfoList:" +
+ i +
+ ":AssetRowCheckbox1"
+ )
+ ).size() == 0
+ ) {
+ break;
+ }
+ document.getElementById(
+ "Page:Form:Block:CheckSection:CheckedInfoList:" +
+ i +
+ ":AssetRowCheckbox1"
+ ).checked = checker.checked;
+ }
+ }
+ function checkAll2(checker) {
+ var cnt = j$(escapeVfId("ProductCnt2")).val();
+ var tempi = parseInt(cnt / 900) + 1;
+ for (var j = 0; j < tempi; j++) {
+ for (var i = 0; i < 900; i++) {
+ if (
+ j$(
+ escapeVfId(
+ "Page:Form:Block:UnCheckSection:unCheckedInfoListForThousend:" +
+ j +
+ ":UnCheckedInfoList:" +
+ i +
+ ":AssetRowCheckbox2"
+ )
+ ).size() == 0
+ ) {
break;
+ }
+ document.getElementById(
+ "Page:Form:Block:UnCheckSection:unCheckedInfoListForThousend:" +
+ j +
+ ":UnCheckedInfoList:" +
+ i +
+ ":AssetRowCheckbox2"
+ ).checked = checker.checked;
}
- document.getElementById('Page:Form:Block:UnCheckSection:unCheckedInfoListForThousend:'+j+':UnCheckedInfoList:'+i+':AssetRowCheckbox2').checked = checker.checked;
+ }
}
- }
-
-}
-//add by rentx 20210809 鍏ㄩ�夊姛鑳� end
+ //add by rentx 20210809 鍏ㄩ�夊姛鑳� end
+ AWSService.sfSessionId = "{!GETSESSIONID()}";
+ var staticResource = JSON.parse("{!staticResource}");
+ var aws_data = {};
+ var txid = null;
+ function Encrypt(callback) {
+ blockme();
+ //callback();return;
+ //<input type="hidden" value="{!ir.Id}" id="IrId"/>
+ let e_id = document.getElementById("IrId");
+ let url = staticResource.newUrl;
-AWSService.sfSessionId = '{!GETSESSIONID()}';
-var staticResource = JSON.parse('{!staticResource}');
-var aws_data = {};
-var txid = null;
-function Encrypt(callback){
- blockme();
- //callback();return;
- //<input type="hidden" value="{!ir.Id}" id="IrId"/>
- let e_id = document.getElementById("IrId");
- let url = staticResource.newUrl;
+ aws_data = {
+ phone: j$("[field-api='phone__c']").val(),
+ responsiblePerson: j$("[field-api='Responsible_Person__c']").val()
+ };
- aws_data = {
- "phone":j$("[field-api='phone__c']").val(),
- "responsiblePerson":j$("[field-api='Responsible_Person__c']").val(),
- };
+ if (e_id && e_id.value) {
+ url = staticResource.updateUrl;
+ aws_data.dataId = document.getElementById(
+ "Page:Form:Block:AWS_Data_Id__c"
+ ).value;
+ }
- if(e_id && e_id.value){
- url = staticResource.updateUrl;
- aws_data.dataId = document.getElementById("Page:Form:Block:AWS_Data_Id__c").value;
- }
+ AWSService.post(
+ url,
+ JSON.stringify([aws_data]),
+ function (data) {
+ if (!(data && data.object && data.object.length)) {
+ console.log("AWSService.post failed");
+ return;
+ }
+ let aws_data1 = data.object[0];
+ txid = data.txId;
-
+ document.getElementById("Page:Form:Block:AWS_Data_Id__c").value =
+ aws_data1.dataId;
+ j$("[field-api='phone__c']").val(aws_data1.phone);
+ j$("[field-api='Responsible_Person__c']").val(
+ aws_data1.responsiblePerson
+ );
- AWSService.post(url, JSON.stringify([aws_data]), function(data){
-
- if (!(data && data.object && data.object.length)) {
- console.log('AWSService.post failed');
- return;
+ if (callback) {
+ callback();
+ }
+ },
+ staticResource.token
+ );
}
- let aws_data1 = data.object[0];
- txid = data.txId;
- document.getElementById("Page:Form:Block:AWS_Data_Id__c").value = aws_data1.dataId;
- j$("[field-api='phone__c']").val(aws_data1.phone);
- j$("[field-api='Responsible_Person__c']").val(aws_data1.responsiblePerson);
-
- if (callback) {
- callback();
+ function saveBtnJs() {
+ Encrypt(saveBtn);
}
- }, staticResource.token);
-}
-
-function saveBtnJs(){
- Encrypt(saveBtn);
-}
-function submitJs(){
- Encrypt(submit);
-}
-function showPDFJs(){
- Encrypt(showPDF);
-}
-
-function afterSaveBtnJs(){
- Trans();
-}
-
-function afterSubmitJs(){
- Trans();
-}
-
-function afterShowPDFJs(){
- Trans(function(){
- if (!HasError()) {
- window.location.href = '/apex/InsReportPDFOuter?id=' + document.getElementById("IrId").value;
+ function submitJs() {
+ Encrypt(submit);
}
-
- });
-}
+ function showPDFJs() {
+ Encrypt(showPDF);
+ }
-function HasError(){
-
- // if (IsAddmessage) {
- // return true;
- // }
- let e = document.getElementById("Page:Form:MessageP");
- if (!e) {
- return false;
- }
+ function afterSaveBtnJs() {
+ Trans();
+ }
- let divs = j$(e).find("div.message");
- for (let i = 0; i < divs.length; i++) {
- for (let j = 0; j < divs[i].classList.length; j++) {
- for(let clsi in divs[i].classList){let cls=divs[i].classList[clsi];
- if (typeof cls == 'string' && cls.indexOf('error')>-1) {
- return true;
- }
+ function afterSubmitJs() {
+ Trans();
+ }
+
+ function afterShowPDFJs() {
+ Trans(function () {
+ if (!HasError()) {
+ window.location.href =
+ "/apex/InsReportPDFOuter?id=" +
+ document.getElementById("IrId").value;
}
-
+ });
}
-
- }
-
- return false;
-}
-
-function Decrypt(data){
-
- j$("[field-api='phone__c']").val(data.phone);
- j$("[field-api='Responsible_Person__c']").val(data.responsiblePerson);
-
-
-}
-
-function Trans(callback){
- let payload = {
- "txId":txid,
- "sfRecordId":document.getElementById("IrId").value,
- "isSuccess":(txid && !HasError()) ? 1 : 0
- };
- AWSService.post(staticResource.transactionUrl, JSON.stringify(payload), function(result){
- Decrypt(aws_data);
- if(callback)callback();
- unblockUI();
- }, staticResource.token);
-}
-
-function Query(){
- let ele = document.getElementById("Page:Form:Block:AWS_Data_Id__c");
- if (ele && ele.value) {
- blockme();
- AWSService.query(staticResource.queryUrl, ele.value, function(data){
- if (data && data.object) {
- Decrypt(data.object);
- }
- unblockUI();
- }, staticResource.token);
- }
-}
-
-j$(function(){
- Query();
-})
-
-</script>
-<title>{!ir.Name}</title>
-</head>
-<body>
- <!-- HWAG-B4Q3G5 20180918Start -->
- <apex:form id="Form" style="margin:0 5px;" onkeydown="if(event.keyCode==13){return false;}">>
- <!-- HWAG-B4Q3G5 20180918End -->
- <script type="text/javascript">
- // 淇濆瓨寰屻�佹柊瑕忋伄鍫卞憡鏇窱D銈掑彇寰�
- tmpinsid = '{!ir.Id}';
- tmpinsn = '{!JSENCODE(ir.Name)}';
- //var IsAddmessage = {IsAddmessage};
- var isPDF = {!isPDF};
-
-</script>
-<apex:actionFunction name="searchfunc" action="{!searchBtn}" rerender="Form,Block,UnCheckSection" onComplete="unblockUI();"></apex:actionFunction>
-
-<apex:actionFunction name="exchangeAssetfunc" action="{!exchangeAsset}" rerender="Form" onComplete="unblockUI();"></apex:actionFunction>
-
-<apex:actionFunction name="sortTablefunc" action="{!sortTable}" rerender="Form" onComplete="unblockUI();">
-<apex:param name="firstParam" assignTo="{!sortKey}" value="" />
-</apex:actionFunction>
-
-<apex:actionFunction name="getAssetFromHp" action="{!getAssetFromHp}" rerender="Form" onComplete="unblockUI();" />
-
-<apex:actionFunction name="saveByRepair" action="{!saveBtn}" rerender="Form" onComplete="unblockUI();openRepair();"/>
-
-<apex:actionFunction name="saveBtn" action="{!saveBtn}" rerender="Form" onComplete="afterSaveBtnJs();"/>
-<apex:actionFunction name="submit" action="{!submit}" rerender="Form" onComplete="afterSubmitJs();"/>
-<apex:actionFunction name="showPDF" action="{!showPDF}" rerender="Form" onComplete="afterShowPDFJs();"/>
-
-<apex:outputPanel id="MessageP">
-<apex:pageMessages />
-</apex:outputPanel>
-
-
-<div><apex:pageBlock mode="maindetail" Id="Block" rendered="{!initFlag}">
- <div style="position: relative;top:0;width:100%;">
- <table>
- <tr>
- <td><apex:outputLabel value="{!$ObjectType.Inspection_Report__c.Label}:" style="font-size:18px;font-weight:bold;padding-right: 5px;"/></td>
- <td>锛�<apex:inputCheckBox value="{!ir.Name_Manual__c}" id="Name_Manual" onchange="toggleIrNameDisabled(this);return false;"/>
- <apex:outputLabel value="{!$ObjectType.Inspection_Report__c.fields.Name_Manual__c.Label}" for="Name_Manual"/>锛�
- <apex:inputField value="{!ir.Name}" id="Ir_Name" html-disabled="disabled" style="border-width:0px;font-size:18px;font-weight:bold;padding-right:20px;-webkit-text-fill-color:black;"/>
- </td>
- <td style="text-align: center;padding-right: 100px;"><input class="btn" type="Button" style="width:80px;" value="淇濆瓨" action="" onclick="saveBtnJs();" rerender="Form" onComplete="unblockUI();"/></td>
- <td style="text-align: center;padding-right: 100px;"><input class="btn" type="Button" value="鎻愪氦" action="" onclick="submitJs();" style="width:80px" rerender="Form" id="submitButton" onComplete="unblockUI();"/></td>
- <td style="text-align: center;padding-right: 100px;"><apex:commandButton style="width:80px;" value="鍏抽棴绐楀彛" onclick="location.href='/apex/OFSWindowClose';return false;" id="closeButton"/></td>
- <td style="text-align: center;"><input class="btn" type="Button" style="width:80px;" value="PDF" action="" onclick="showPDFJs();" rerender="Form" onComplete="unblockUI();"/></td>
- </tr>
- </table>
- <apex:pageBlockSection title="{!sectionList[0].title}" columns="{!sectionList[0].column}" showHeader="{!sectionList[0].showHeader}" rendered="{!sectionList.size>0}">
- <apex:repeat value="{!sectionList[0].sectionItemList}" var="sectionItem" id="SectionItemList">
- <apex:outputField value="{!ir[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&&NOT(sectionItem.isInput)}"/>
- <apex:inputField style="width:{!sectionItem.width};height:{!sectionItem.height};" value="{!ir[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&§ionItem.isInput}" required="{!sectionItem.isRequired}" html-tabindex="{!sectionItem.index}"/>
- <apex:pageblockSectionItem rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&Not(isNull(sectionItem.customizeLable))}">
- <apex:outputLabel value="{!sectionItem.customizeLable}"/>
- <apex:outputPanel layout="none">
- <apex:repeat value="{!sectionItem.apiList}" var="api">
- <!-- 淇濆瓨寰屻�佺梾闄€伅寮峰埗outputField -->
- <apex:outputPanel layout="none" rendered="{!api == 'Hospital__c' && ir.Id != ''}">
- <apex:outputField value="{!ir[api]}"/>
- </apex:outputPanel>
- <apex:outputPanel layout="none" rendered="{!NOT(api == 'Hospital__c' && ir.Id != '')}">
- <apex:outputLabel style="font-weight: bold; padding-right: 5px;" value="{!sectionItem.apiLabelMap[api]}"/>
- <apex:inputField value="{!ir[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/>
- <apex:outputPanel style="display:inline-block;{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}">
- <apex:outputField value="{!ir[api]}"/>
-</apex:outputPanel>
-</apex:outputPanel>
-</apex:repeat>
-</apex:outputPanel>
-</apex:pageblockSectionItem>
-<apex:pageblockSectionItem rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&(isNull(sectionItem.customizeLable))}">
-<apex:outputPanel layout="none">
-<apex:repeat value="{!sectionItem.apiList}" var="api">
-<apex:outputLabel style="font-weight: bold; padding-right: 5px;" value="{!sectionItem.apiLabelMap[api]}"/>
-<apex:inputField value="{!ir[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/>
-<apex:outputPanel style="display:inline-block;{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}">
-<apex:outputField value="{!ir[api]}"/>
-</apex:outputPanel>
-</apex:repeat>
-</apex:outputPanel>
-</apex:pageblockSectionItem>
-<apex:pageBlockSectionItem rendered="{!sectionItem.isDummy}"/>
-</apex:repeat>
-</apex:pageBlockSection>
-</div>
-<div style="position: relative;top:0;height:700px;overflow:hidden;overflow-y:auto;-webkit-overflow-scrolling: touch;">
- <input type="hidden" value="{!ir.Id}" id="IrId"/>
- <apex:inputHidden value="{!ir.AWS_Data_Id__c}" id="AWS_Data_Id__c"/>
-
-
-
-
- <apex:repeat value="{!sectionList}" var="section" id="SectionList">
- <apex:pageBlockSection title="{!section.title}" columns="{!section.column}" showHeader="{!section.showHeader}" rendered="{!!section.isTop}">
- <apex:repeat value="{!section.sectionItemList}" var="sectionItem" id="SectionItemList">
- <apex:outputField value="{!ir[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&&NOT(sectionItem.isInput)}"/>
- <apex:inputField html-field-api="{!sectionItem.api}" style="width:{!sectionItem.width};height:{!sectionItem.height};" value="{!ir[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&§ionItem.isInput}" required="{!sectionItem.isRequired}" html-tabindex="{!sectionItem.index}"/>
- <apex:pageblockSectionItem rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&Not(isNull(sectionItem.customizeLable))}">
- <apex:outputLabel value="{!sectionItem.customizeLable}"/>
- <apex:outputPanel layout="none">
- <apex:repeat value="{!sectionItem.apiList}" var="api">
- <!-- 淇濆瓨寰屻�佺梾闄€伅寮峰埗outputField -->
- <apex:outputPanel layout="none" rendered="{!api == 'Hospital__c' && ir.Id != ''}">
- <apex:outputField value="{!ir[api]}"/>
-</apex:outputPanel>
-<apex:outputPanel layout="none" rendered="{!NOT(api == 'Hospital__c' && ir.Id != '')}">
-<apex:outputLabel style="font-weight: bold; padding-right: 5px;" value="{!sectionItem.apiLabelMap[api]}"/>
-<apex:inputField html-field-api="{!api}" value="{!ir[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/>
-<apex:outputPanel style="display:inline-block;{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}">
-<apex:outputField value="{!ir[api]}"/>
-</apex:outputPanel>
-</apex:outputPanel>
-</apex:repeat>
-</apex:outputPanel>
-</apex:pageblockSectionItem>
-<apex:pageblockSectionItem rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&(isNull(sectionItem.customizeLable))}">
-<apex:outputPanel layout="none">
-<apex:repeat value="{!sectionItem.apiList}" var="api">
-<apex:outputLabel style="font-weight: bold; padding-right: 5px;" value="{!sectionItem.apiLabelMap[api]}"/>
-<apex:inputField html-field-api="api" value="{!ir[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/>
-<apex:outputPanel style="display:inline-block;{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}">
-<apex:outputField value="{!ir[api]}"/>
-</apex:outputPanel>
-</apex:repeat>
-</apex:outputPanel>
-</apex:pageblockSectionItem>
-<apex:pageBlockSectionItem rendered="{!sectionItem.isDummy}"/>
-</apex:repeat>
-</apex:pageBlockSection>
-</apex:repeat>
-
-<script type="text/javascript">
- // 鐥呴櫌銇乏鍋淬�屽埛鏂般�嶃儨銈裤兂杩藉姞
- var labels = document.getElementsByTagName("label");
- for (var i = 0; i < labels.length; i++) {
- var lbl = labels[i];
- if (lbl.innerText == "鍖婚櫌" || lbl.innerText == "鐥呴櫌") {
- var html = lbl.parentNode.innerHTML;
- html = "<input type='button' value='鍒锋柊' class='btn' onclick='blockme();getAssetFromHp();' /> " + html;
- lbl.parentNode.innerHTML = html;
- break;
- }
- }
-</script>
-<apex:pageBlockSection title="宸查�変繚鏈夎澶囧瓧娈靛巻鍙�" columns="1" id="CheckSection">
-<input type="hidden" id="ProductCnt" value="{!productCount}" />
-
-<apex:outputPanel >
-<table width="100%">
- <tr>
- <td> </td>
- <td width="100px">
- <span>鍏�</span>
- <select style="vertical-align:text-bottom" id="allCheckResult" size="1" onchange="changeAllCheckResult(this.value);">
- <option value=" ">--鏃�--</option>
- <!-- 榛樿鍏∣K -->
- <option value="OK" selected = "selected" >OK</option>
- <!-- 榛樿鍏∣K -->
- <option value="NG">NG</option>
- <!-- add by rentx 20210630 start -->
- <option value="鍖婚櫌鏀惧純">鍖婚櫌鏀惧純</option>
- <!-- add by rentx 20210630 end -->
- </select>
- </td>
- <td width="500px"> </td>
- </tr>
-</table>
-<!-- TODO minus scroll with -->
-<table id="AssetTableHeader" class="list" style="border-bottom-width: 0px; font-size:13px;" border="0" cellspacing="0" cellpadding="0">
- <tr style="border-bottom: 1px groove rgba(254, 254, 254, 0.48);background: #f2f3f3;">
- <!-- add by rentx 20210809 -->
- <th class="headerCell" style="width:14px"> <apex:inputCheckbox id="checkAll1" onclick="checkAll(this)" /> </th>
- <!-- <th class="headerCell" style="width:14px" /> -->
- <!-- add by rentx 202120809 -->
- <th class="headerCell" style="width:24px"/>
- <th class="headerCell" style="width:60px">{!$ObjectType.Asset.fields.Asset_situation__c.label}</th>
- <th class="headerCell">{!$ObjectType.Asset.fields.Name.label}</th>
- <th class="headerCell" style="width:100px">{!$ObjectType.Inspection_Item__c.Fields.SerialNumber__c.Label}</th>
- <!-- TODO 闋呯洰銇綔鎴� -->
- <th class="headerCell" style="width:80px">涓婃鐐规鏃�</th>
- <th class="headerCell" style="width:100px">涓婃淇悊瀹屾瘯鏃�</th>
- <th class="headerCell" style="width:80px">
- {!$ObjectType.Inspection_Item__c.Fields.ItemStatus__c.Label}
- </th>
- <th class="headerCell" style="width:100px">{!$ObjectType.Inspection_Item__c.Fields.Fault_Classification1__c.Label}</th>
- <th class="headerCell" style="width:100px">{!$ObjectType.Inspection_Item__c.Fields.Fault_Classification2__c.Label}</th>
- <th class="headerCell" style="width:100px">{!$ObjectType.Inspection_Item__c.Fields.Fault_Classification3__c.Label}</th>
- <th class="headerCell" style="width:100px">{!$ObjectType.Inspection_Item__c.Fields.Diagnosis__c.Label}</th>
- <!-- add by rentx 20210630 -->
- <th class="headerCell" style="width:85px">{!$ObjectType.Inspection_Item__c.Fields.Abandonment_Reasons__c.Label}</th>
- <!-- add by rentx 20210630 -->
- <th class="headerCell" style="width:35px">{!$ObjectType.Asset.Fields.Create_repair__c.Label}</th>
- <!-- <td class="headerScroll"></td> -->
- </tr>
-</table>
-
-<div style="height:320px; width:100%; overflow:auto;">
- <table style="border-collapse:collapse; width:100%;" id="AssetTable">
- <apex:variable value="{!1}" var="cnt" />
- <apex:repeat value="{!checkedInfoList}" var="cInfo" id="CheckedInfoList" >
- <tr style="border-bottom: 1px groove rgba(254, 254, 254, 0.48);">
- <td style="width:14px">
- <apex:inputCheckbox value="{!cInfo.rec_checkBox_c}" id="AssetRowCheckbox1" rendered="{!Not(cInfo.IsManual)}"/>
- <apex:outputText value="{!cInfo.IsManual}" id="IsManual" style="display:none;" />
- <input type="hidden" value="{!cInfo.rec.Id}" id="CheckAssetId"/>
- </td>
- <td style="font-weight:bold; text-align:right; width:24px;">{!cnt}</td>
- <td class="dataCell" style="width:60px">
- <apex:outputField value="{!cInfo.rec.Asset_situation__c}"/>
- </td>
- <td class="dataCell">
- <!-- HWAG-BDCA9J 娣诲姞浜� onclick blurProduct 鍐呭 start-->
- <apex:outputField value="{!cInfo.rec.Name}" rendered="{!Not(cInfo.IsManual)}"/>
- <apex:inputField value="{!cInfo.ah.Product_Manual__c}" id="Assert" style="width:90%;" rendered="{!cInfo.IsManual}"
- onclick="if(!blurProduct(this))return false;"/>
- <!-- HWAG-BDCA9J 娣诲姞浜� onclick blurProduct 鍐呭 end-->
- </td>
- <td class="dataCell" style="width:100px">
- <apex:outputField value="{!cInfo.ah.SerialNumber__c}" rendered="{!Not(cInfo.IsManual)}"/>
- <apex:inputField value="{!cInfo.ah.SerialNo_Manual__c}" id="SerialNo" style="width:90%;" rendered="{!cInfo.IsManual}" />
- </td>
- <td class="dataCell" style="width:80px">
- <apex:outputField value="{!cInfo.rec.Final_Examination_Date__c}" rendered="{!Not(cInfo.IsManual)}"/>
- </td>
- <td class="dataCell" style="width:100px">
- <apex:outputField value="{!cInfo.rec.After_repair_last_internal_check_day__c}" rendered="{!Not(cInfo.IsManual)}"/>
- </td>
- <td class="dataCell" style="width:80px">
- <apex:inputField value="{!cInfo.ah.ItemStatus__c}" id="AssetRowCheckboxIsNormal" style="width:98%"/>
- </td>
- <td class="dataCell" style="width:100px">
- <apex:inputField value="{!cInfo.ah.Fault_Classification1__c}" />
- </td>
- <td class="dataCell" style="width:100px">
- <apex:inputField value="{!cInfo.ah.Fault_Classification2__c}" id="cat2" />
- </td>
- <td class="dataCell" style="width:100px">
- <apex:inputField value="{!cInfo.ah.Fault_Classification3__c}" id="cat3" />
- </td>
- <td class="dataCell" style="width:100px">
- <apex:inputField value="{!cInfo.ah.Diagnosis__c}" style="width:93%"/>
- </td>
- <!-- add by rentx 20210630 -->
- <td class="dataCell" style="width:85px">
- <apex:inputField value="{!cInfo.ah.Abandonment_Reasons__c}" style="width:93%" />
- </td>
- <!-- add by rentx 20210630 -->
- <td class="dataCell" style="width:35px">
- <apex:outputPanel layout="none" rendered="{!Not(cInfo.IsManual)}">
- <a href="#" onclick="saveByRepairJs('{!cInfo.rec.Id}', '{!JSENCODE(cInfo.rec.Name)}', '{!cInfo.rec.Hospital__r.Id}', '{!JSENCODE(cInfo.rec.Hospital__r.Name)}', '{!cInfo.rec.Department_Class__r.Id}', '{!JSENCODE(cInfo.rec.Department_Class__r.Name)}', '{!cInfo.rec.Account.Id}', '{!JSENCODE(cInfo.rec.Account.Name)}', '鍙慨鐞�');">鈻�</a>
- </apex:outputPanel>
- </td>
- </tr>
-<apex:variable value="{!cnt + 1}" var="cnt" />
-</apex:repeat>
-</table>
-</div>
-</apex:outputPanel>
-
-</apex:pageBlockSection>
-
-<apex:outputPanel id="ButtonPanel">
-<table style="width:100%;">
- <tr>
- <td>
- <apex:commandButton value="琛岃拷鍔�" action="{!addNewRows}" disabled="{!Not($ObjectType.Inspection_Item__c.createable)}"
- style="margin-left:10px;float:left;" onclick="blockme();" oncomplete="unblockUI();" rerender="Form" />
- <apex:commandButton value="鍒锋柊閫変腑鐨勪繚鏈夎澶�" onclick="exchangeAssetJs();return false;" rerender="dummy"/>
- <!-- <apex:commandButton value="鍒锋柊閫変腑鐨勪繚鏈夎澶�" action="{!exchangeAsset}" onclick="blockme();" oncomplete="unblockUI();" rerender="Form" /> -->
- <!-- <apex:commandButton value="鍒锋柊鍖婚櫌涓嬬殑鍏ㄩ儴淇濇湁璁惧" action="{!getAssetFromHp}" onclick="blockme();" oncomplete="unblockUI();" rerender="Form" /> -->
- </td>
- </tr>
-</table>
-</apex:outputPanel>
-<table>
- <tr>
- <td><div id="ErrorName" style="color: red;font-weight: bold;">{!alertMessage}</div>
- </td>
- </tr>
-</table>
-<!-- HWAG-B4Q3G5 20180918Start -->
-<apex:pageBlockSection title="鏈�変繚鏈夎澶囧瓧娈靛巻鍙�" columns="1" id="UnCheckSection" onkeydown="if(event.keyCode==13){searchJs(); return false;}">
-<!-- HWAG-B4Q3G5 20180918End -->
-<input type="hidden" id="ProductCnt2" value="{!productCount2}" />
-<apex:outputPanel >
-<div align="center">
- <apex:outputPanel id="countorder">绗瑊!countorder}椤�</apex:outputPanel>
- <apex:commandButton value="涓婁竴椤�" action="{!UpPage}" onclick="blockme();" disabled="{!IF(countorder=1,true,false)}" oncomplete="unblockUI();" reRender="Form"/>
- <apex:commandButton value="涓嬩竴椤�" action="{!DownPage}" onclick="blockme();" disabled="{!IF(countorder >=nowAssetcount ,true,false)}" oncomplete="unblockUI();" rerender="Form"/>
- <apex:outputPanel id="NowOrdercount">鍏眥!nowAssetcount}椤�</apex:outputPanel>
-</div>
-
-<table>
- <tr>
- <td style="width:85px" align="right">閫夋嫨鏉′欢</td>
- <td style="width:85px" align="right"><apex:selectList value="{!text1}" id="text1" size="1" style="width:80px"><apex:selectOptions value="{!textOpts}"/></apex:selectList></td>
- <td style="width:85px" align="center"><apex:selectList value="{!cond1}" id="cond1" size="1" style="width:80px"><apex:selectOptions value="{!equalOpts}"/></apex:selectList></td>
- <td style="width:95px" align="left"><apex:inputText value="{!val1}" id="val1" style="width:100px"/></td>
- <td align="left">
-
- <apex:commandButton value="妫�绱�" onclick="searchJs();return false;" style="width:130px" rerender="dummy"/>
-
- <apex:commandButton value="娓呴櫎鏉′欢" onclick="clearAndSearch();" style="width:130px" rerender="dummy"/>
-
- <span style="vertical-align: text-bottom;">浣跨敤涓�<apex:inputCheckBox value="{!activeOn}" /></span>
- </td>
- </tr>
-</table>
-<table style="border-collapse:collapse;" id="AssetTable2">
- <tr style="border-bottom: 1px groove rgba(254, 254, 254, 0.48);background: #f2f3f3;">
- <!-- add by rentx 20210809 start 鍏ㄩ�夊姛鑳� -->
- <!-- <th class="headerCell" style="width:25px"></th> -->
- <th class="headerCell" style="padding: 2px 5px; width:25px"><apex:inputCheckbox id="checkAll1" onclick="checkAll2(this)" /> </th>
- <!-- add by rentx 20210809 end 鍏ㄩ�夊姛鑳� -->
- <th class="headerCell" style="width:70px">
- <a href="#" onclick="sortTableJs('0');return false;" style="text-decoration: underline;">{!$ObjectType.Asset.fields.Asset_situation__c.label}</a>{!sortOrder[0]}
- </th>
- <th class="headerCell">
- <a href="#" onclick="sortTableJs('1');return false;" style="text-decoration: underline;">{!$ObjectType.Asset.fields.Name.label}</a>{!sortOrder[1]}
- </th>
- <th class="headerCell" style="width:70px">
- <a href="#" onclick="sortTableJs('2');return false;" style="text-decoration: underline;">{!$ObjectType.Asset.fields.SerialNumber.label}</a>{!sortOrder[2]}
- </th>
- <th class="headerCell" style="width:70px">
- <a href="#" onclick="sortTableJs('3');return false;" style="text-decoration: underline;">{!$ObjectType.Asset.fields.CurrentContract__c.label}</a>{!sortOrder[3]}
- </th>
- <th class="headerCell" style="width:70px">
- <a href="#" onclick="sortTableJs('4');return false;" style="text-decoration: underline;">{!$ObjectType.Asset.fields.Department_Name__c.label}</a>{!sortOrder[4]}
- </th>
- <th class="headerCell" style="width:70px">
- <a href="#" onclick="sortTableJs('5');return false;" style="text-decoration: underline;">{!$ObjectType.Asset.fields.Status.label}</a>{!sortOrder[5]}
- </th>
- <th class="headerCell" style="width:90px">
- <a href="#" onclick="sortTableJs('6');return false;" style="text-decoration: underline;">{!$ObjectType.Asset.fields.Installation_Site__c.label}</a>{!sortOrder[6]}
- </th>
- <th class="headerCell" style="width:90px">
- <a href="#" onclick="sortTableJs('7');return false;" style="text-decoration: underline;">{!$ObjectType.Asset.fields.Room_Number__c.label}</a>{!sortOrder[7]}
- </th>
- <th class="headerCell" style="width:90px">
- <a href="#" onclick="sortTableJs('8');return false;" style="text-decoration: underline;">{!$ObjectType.Asset.fields.InstallDate.label}</a>{!sortOrder[8]}
- </th>
- <th class="headerCell" style="width:90px">
- <a href="#" onclick="sortTableJs('9');return false;" style="text-decoration: underline;">{!$ObjectType.Asset.fields.Asset_Owner__c.label}</a>{!sortOrder[9]}
- </th>
- <th class="headerCell" style="width:90px">
- <a href="#" onclick="sortTableJs('10');return false;" style="text-decoration: underline;">{!$ObjectType.Asset.fields.Accumulation_Repair_Amount__c.label}</a>{!sortOrder[10]}
- </th>
- </tr>
- <apex:variable value="{!1}" var="cnt" />
- <apex:variable value="{!0}" var="cntOut" />
- <apex:repeat value="{!IF(ThousandFLG>0,unCheckedInfoListForThousend,1)}" var="Thoinfo" id="unCheckedInfoListForThousend">
- <apex:repeat value="{!IF(ThousandFLG>0,Thoinfo,unCheckedInfoList)}" var="ucInfo" id="UnCheckedInfoList" >
-
- <tr style="border-bottom: 1px groove rgba(254, 254, 254, 0.48);">
- <td style="padding: 2px 5px; width:25px">
- <apex:inputCheckbox value="{!ucInfo.rec_checkBox_c}" id="AssetRowCheckbox2"/>
- <input type="hidden" value="{!ucInfo.rec.Id}" id="UncheckAssetId"/>
- </td>
- <td style="padding: 2px 5px; width:70px">
- <apex:outputField value="{!ucInfo.rec.Asset_situation__c}"/>
- </td>
- <td style="padding: 2px 5px;">
- <a href="#" onclick="window.open('/{!ucInfo.rec.Id}', '_blank');">{!ucInfo.rec.Name}</a>
- <!-- <apex:outputField value="{!ucInfo.rec.name}" id="assetName"/> -->
- </td>
- <td style="padding: 2px 5px; width:70px">
- <apex:outputField value="{!ucInfo.rec.SerialNumber}"/>
- </td>
- <td style="padding: 2px 5px; width:70px">
- <!-- <apex:outputField value="{!ucInfo.rec.CurrentContract__c}"/> -->
- <a href="#" onclick="window.open('/{!ucInfo.rec.CurrentContract__c}', '_blank');">{!ucInfo.rec.CurrentContract__r.Management_Code__c}</a>
- </td>
- <td style="padding: 2px 5px; width:70px">
- <apex:outputField value="{!ucInfo.rec.Department_Name__c}"/>
- </td>
- <td style="padding: 2px 5px; width:70px">
- <apex:outputField value="{!ucInfo.rec.Status}"/>
- </td>
- <td style="padding: 2px 5px; width:70px">
- <apex:outputField value="{!ucInfo.rec.Installation_Site__c}"/>
- </td>
- <td style="padding: 2px 5px; width:70px">
- <apex:outputField value="{!ucInfo.rec.Room_Number__c}"/>
- </td>
- <td style="padding: 2px 5px; width:90px;text-align:center">
- <apex:outputField value="{!ucInfo.rec.InstallDate}"/>
- </td>
- <td style="padding: 2px 5px; width:90px">
- <apex:outputField value="{!ucInfo.rec.Asset_Owner__c}"/>
- </td>
- <td style="padding: 2px 5px; width:90px;text-align:center">
- <apex:outputField value="{!ucInfo.rec.Accumulation_Repair_Amount__c}"/>
- </td>
- </tr>
- <apex:variable value="{!cnt + 1}" var="cnt" />
-</apex:repeat>
-<apex:variable value="{!cntOut + 1}" var="cntOut" />
-</apex:repeat>
-</table>
-</apex:outputPanel>
-</apex:pageBlockSection>
-<!-- fxk 2021/8/4 鏂板姞 Start-->
-<apex:pageBlockSection title="鎵撳嵃鏃舵礂娑堜俊鎭�" columns="1" id="UnCheckSection1" >
-<apex:outputPanel >
-<table class="edittable" border="0" style="border-collapse: collapse; width:600px; table-layout:fixed;">
- <tr>
- <td>{!$ObjectType.Inspection_Report__c.fields.CleaningFluid__c.Label}:</td>
- <td><apex:inputField value="{!ir.CleaningFluid__c}" style="width: 90%"/></td>
- <!-- 鏂瑰紡 add by rentx 20210927 start-->
- <td>{!$ObjectType.Inspection_Report__c.fields.Mode__c.Label}:</td>
- <td><apex:inputField value="{!ir.Mode__c}" style="width: 90%"/></td>
- <!-- 鏂瑰紡 add by rentx 20210927 end -->
- <td>{!$ObjectType.Inspection_Report__c.fields.SterilizationMethod__c.Label}:</td>
- <td><apex:inputField value="{!ir.SterilizationMethod__c}" style="width: 90%"/></td>
- <td>{!$ObjectType.Inspection_Report__c.fields.Remarks__c.Label}:</td>
- <td><apex:inputText value="{!ir.Remarks__c}" style="width: 90%"/></td>
- </tr>
- <tr>
- <td>{!$ObjectType.Inspection_Report__c.fields.Disinfectant__c.Label}:</td>
- <td><apex:inputField value="{!ir.Disinfectant__c}" style="width: 90%"/></td>
- <td>{!$ObjectType.Inspection_Report__c.fields.UsedMachine__c.Label}:</td>
- <td><apex:inputField value="{!ir.UsedMachine__c}" style="width: 90%"/></td>
- <td>{!$ObjectType.Inspection_Report__c.fields.Used_ET__c.Label}:</td>
- <td><apex:inputText value="{!ir.Used_ET__c}" style="width: 90%"/></td>
- </tr>
-</table>
-</apex:outputPanel>
-</apex:pageBlockSection>
-<!-- fxk 2021/8/4 鏂板姞 End-->
-</div>
-</apex:pageBlock></div>
-<script type="text/javascript">
- // 宸茬瀛椼伄鍫村悎銆佸鏇翠笉鑳姐伀銇欍倠
- var status = '{!ir.Status__c}';
- if (status == "鐢宠涓�" || status == "鎵瑰噯") {
- var inputs = document.getElementsByTagName("input");
- for (var i = 0; i < inputs.length; i++) {
- var obj = inputs[i];
-
- if (obj.id == "Page:Form:Block:closeButton") continue;
- //if (obj.id == "Page:Form:Block:submitButton") continue;
- //if (status == "宸茬瀛�" && obj.id == "Page:Form:Block:submitButton") continue;
-
- if (obj.type == "button") {
- setButtonDisable(obj, true);
- } else {
- obj.disabled = true;
- }
- }
- var selects = document.getElementsByTagName("select");
- console.log(selects);
- for (var i = 0; i < selects.length; i++) {
- selects[i].disabled = true;
- }
- } else {
- //var smb = j$(escapeVfId("Page:Form:Block:submitButton"))[0];
- //setButtonDisable(smb, true);
- }
- // HWAG-BDCA9J 鎻愰啋鏈繚瀛樺拰鍒锋柊鍓嶄笉鑳介�夋嫨浜у搧 start
- function blurProduct(obj) {
- var irID = "{!ir.Id}";
- var productCount2 = "{!productCount2}";
- if(!irID && productCount2 == 0){
- alert('璇峰厛杈撳叆鍖婚櫌骞剁偣鍑诲埛鏂版寜閽皟鍑轰繚鏈夎澶囷紝鍚﹀垯鐐规缁撴灉鏃犳硶涓庤澶囧叧鑱斻��');
- obj.blur();
+ function HasError() {
+ // if (IsAddmessage) {
+ // return true;
+ // }
+ let e = document.getElementById("Page:Form:MessageP");
+ if (!e) {
return false;
+ }
+
+ let divs = j$(e).find("div.message");
+ for (let i = 0; i < divs.length; i++) {
+ for (let j = 0; j < divs[i].classList.length; j++) {
+ for (let clsi in divs[i].classList) {
+ let cls = divs[i].classList[clsi];
+ if (typeof cls == "string" && cls.indexOf("error") > -1) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
}
- return true;
- }
- // HWAG-BDCA9J 鎻愰啋鏈繚瀛樺拰鍒锋柊鍓嶄笉鑳介�夋嫨浜у搧 end
-</script>
-</apex:form>
-</body>
-</html>
-</apex:page>
\ No newline at end of file
+
+ function Decrypt(data) {
+ j$("[field-api='phone__c']").val(data.phone);
+ j$("[field-api='Responsible_Person__c']").val(data.responsiblePerson);
+ }
+
+ function Trans(callback) {
+ let payload = {
+ txId: txid,
+ sfRecordId: document.getElementById("IrId").value,
+ isSuccess: txid && !HasError() ? 1 : 0
+ };
+ AWSService.post(
+ staticResource.transactionUrl,
+ JSON.stringify(payload),
+ function (result) {
+ Decrypt(aws_data);
+ if (callback) callback();
+ unblockUI();
+ },
+ staticResource.token
+ );
+ }
+
+ function Query() {
+ let ele = document.getElementById("Page:Form:Block:AWS_Data_Id__c");
+ if (ele && ele.value) {
+ blockme();
+ AWSService.query(
+ staticResource.queryUrl,
+ ele.value,
+ function (data) {
+ if (data && data.object) {
+ Decrypt(data.object);
+ }
+ unblockUI();
+ },
+ staticResource.token
+ );
+ }
+ }
+
+ j$(function () {
+ Query();
+ });
+ </script>
+ <title>{!ir.Name}</title>
+ </head>
+ <body>
+ <!-- HWAG-B4Q3G5 20180918Start -->
+ <apex:form
+ id="Form"
+ style="margin: 0 5px"
+ onkeydown="if(event.keyCode==13){return false;}"
+ >
+ <!-- HWAG-B4Q3G5 20180918End -->
+ <script type="text/javascript">
+ // 淇濆瓨寰屻�佹柊瑕忋伄鍫卞憡鏇窱D銈掑彇寰�
+ tmpinsid = '{!ir.Id}';
+ tmpinsn = '{!JSENCODE(ir.Name)}';
+ //var IsAddmessage = {IsAddmessage};
+ var isPDF = {!isPDF};
+ </script>
+ <apex:actionFunction
+ name="searchfunc"
+ action="{!searchBtn}"
+ rerender="Form,Block,UnCheckSection"
+ onComplete="unblockUI();"
+ ></apex:actionFunction>
+
+ <apex:actionFunction
+ name="exchangeAssetfunc"
+ action="{!exchangeAsset}"
+ rerender="Form"
+ onComplete="unblockUI();"
+ ></apex:actionFunction>
+
+ <apex:actionFunction
+ name="sortTablefunc"
+ action="{!sortTable}"
+ rerender="Form"
+ onComplete="unblockUI();"
+ >
+ <apex:param name="firstParam" assignTo="{!sortKey}" value="" />
+ </apex:actionFunction>
+
+ <apex:actionFunction
+ name="getAssetFromHp"
+ action="{!getAssetFromHp}"
+ rerender="Form"
+ onComplete="unblockUI();"
+ />
+
+ <apex:actionFunction
+ name="saveByRepair"
+ action="{!saveBtn}"
+ rerender="Form"
+ onComplete="unblockUI();openRepair();"
+ />
+
+ <apex:actionFunction
+ name="saveBtn"
+ action="{!saveBtn}"
+ rerender="Form"
+ onComplete="afterSaveBtnJs();"
+ />
+ <apex:actionFunction
+ name="submit"
+ action="{!submit}"
+ rerender="Form"
+ onComplete="afterSubmitJs();"
+ />
+ <apex:actionFunction
+ name="showPDF"
+ action="{!showPDF}"
+ rerender="Form"
+ onComplete="afterShowPDFJs();"
+ />
+
+ <apex:outputPanel id="MessageP">
+ <apex:pageMessages />
+ </apex:outputPanel>
+
+ <div>
+ <apex:pageBlock mode="maindetail" Id="Block" rendered="{!initFlag}">
+ <div style="position: relative; top: 0; width: 100%">
+ <table>
+ <tr>
+ <td>
+ <apex:outputLabel
+ value="{!$ObjectType.Inspection_Report__c.Label}:"
+ style="
+ font-size: 18px;
+ font-weight: bold;
+ padding-right: 5px;
+ "
+ />
+ </td>
+ <td>
+ 锛�<apex:inputCheckBox
+ value="{!ir.Name_Manual__c}"
+ id="Name_Manual"
+ onchange="toggleIrNameDisabled(this);return false;"
+ />
+ <apex:outputLabel
+ value="{!$ObjectType.Inspection_Report__c.fields.Name_Manual__c.Label}"
+ for="Name_Manual"
+ />锛�
+ <apex:inputField
+ value="{!ir.Name}"
+ id="Ir_Name"
+ html-disabled="disabled"
+ style="
+ border-width: 0px;
+ font-size: 18px;
+ font-weight: bold;
+ padding-right: 20px;
+ -webkit-text-fill-color: black;
+ "
+ />
+ </td>
+ <td style="text-align: center; padding-right: 100px">
+ <input
+ class="btn"
+ type="Button"
+ style="width: 80px"
+ value="淇濆瓨"
+ action=""
+ onclick="saveBtnJs();"
+ rerender="Form"
+ onComplete="unblockUI();"
+ />
+ </td>
+ <td style="text-align: center; padding-right: 100px">
+ <input
+ class="btn"
+ type="Button"
+ value="鎻愪氦"
+ action=""
+ onclick="submitJs();"
+ style="width: 80px"
+ rerender="Form"
+ id="submitButton"
+ onComplete="unblockUI();"
+ />
+ </td>
+ <td style="text-align: center; padding-right: 100px">
+ <apex:commandButton
+ style="width: 90px"
+ value="鍏抽棴绐楀彛"
+ onclick="location.href='/apex/OFSWindowClose';return false;"
+ id="closeButton"
+ />
+ </td>
+ <td style="text-align: center">
+ <input
+ class="btn"
+ type="Button"
+ style="width: 80px"
+ value="PDF"
+ action=""
+ onclick="showPDFJs();"
+ rerender="Form"
+ onComplete="unblockUI();"
+ />
+ </td>
+ </tr>
+ </table>
+ <apex:pageBlockSection
+ title="{!sectionList[0].title}"
+ columns="{!sectionList[0].column}"
+ showHeader="{!sectionList[0].showHeader}"
+ rendered="{!sectionList.size>0}"
+ >
+ <apex:repeat
+ value="{!sectionList[0].sectionItemList}"
+ var="sectionItem"
+ id="SectionItemList"
+ >
+ <apex:outputField
+ value="{!ir[sectionItem.api]}"
+ rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&&NOT(sectionItem.isInput)}"
+ />
+ <apex:inputField
+ style="width:{!sectionItem.width};height:{!sectionItem.height};"
+ value="{!ir[sectionItem.api]}"
+ rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&§ionItem.isInput}"
+ required="{!sectionItem.isRequired}"
+ html-tabindex="{!sectionItem.index}"
+ />
+ <apex:pageblockSectionItem
+ rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&Not(isNull(sectionItem.customizeLable))}"
+ >
+ <apex:outputLabel value="{!sectionItem.customizeLable}" />
+ <apex:outputPanel layout="none">
+ <apex:repeat value="{!sectionItem.apiList}" var="api">
+ <!-- 淇濆瓨寰屻�佺梾闄€伅寮峰埗outputField -->
+ <apex:outputPanel
+ layout="none"
+ rendered="{!api == 'Hospital__c' && ir.Id != ''}"
+ >
+ <apex:outputField value="{!ir[api]}" />
+ </apex:outputPanel>
+ <apex:outputPanel
+ layout="none"
+ rendered="{!NOT(api == 'Hospital__c' && ir.Id != '')}"
+ >
+ <apex:outputLabel
+ style="font-weight: bold; padding-right: 5px"
+ value="{!sectionItem.apiLabelMap[api]}"
+ />
+ <apex:inputField
+ value="{!ir[api]}"
+ style="{!sectionItem.apiStyleMap[api]}"
+ rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}"
+ required="{!sectionItem.apiRequireMap[api]}"
+ html-tabindex="{!sectionItem.index}"
+ />
+ <apex:outputPanel
+ style="display:inline-block;{!sectionItem.apiStyleMap[api]}"
+ rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}"
+ >
+ <apex:outputField value="{!ir[api]}" />
+ </apex:outputPanel>
+ </apex:outputPanel>
+ </apex:repeat>
+ </apex:outputPanel>
+ </apex:pageblockSectionItem>
+ <apex:pageblockSectionItem
+ rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&(isNull(sectionItem.customizeLable))}"
+ >
+ <apex:outputPanel layout="none">
+ <apex:repeat value="{!sectionItem.apiList}" var="api">
+ <apex:outputLabel
+ style="font-weight: bold; padding-right: 5px"
+ value="{!sectionItem.apiLabelMap[api]}"
+ />
+ <apex:inputField
+ value="{!ir[api]}"
+ style="{!sectionItem.apiStyleMap[api]}"
+ rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}"
+ required="{!sectionItem.apiRequireMap[api]}"
+ html-tabindex="{!sectionItem.index}"
+ />
+ <apex:outputPanel
+ style="display:inline-block;{!sectionItem.apiStyleMap[api]}"
+ rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}"
+ >
+ <apex:outputField value="{!ir[api]}" />
+ </apex:outputPanel>
+ </apex:repeat>
+ </apex:outputPanel>
+ </apex:pageblockSectionItem>
+ <apex:pageBlockSectionItem
+ rendered="{!sectionItem.isDummy}"
+ />
+ </apex:repeat>
+ </apex:pageBlockSection>
+ </div>
+ <div
+ style="
+ position: relative;
+ top: 0;
+ height: 700px;
+ overflow: hidden;
+ overflow-y: auto;
+ -webkit-overflow-scrolling: touch;
+ "
+ >
+ <input type="hidden" value="{!ir.Id}" id="IrId" />
+ <!-- zhj 鏂版柟妗堟敼閫� 2022-12-05 start-->
+ <!-- <apex:inputHidden value="{!ir.Responsible_Person_Encrypted__c}" id="Responsible_Person_Encrypted__c"/>
+ <apex:inputHidden value="{!ir.phone_Encrypted__c}" id="phone_Encrypted__c"/> -->
+ <!-- zhj 鏂版柟妗堟敼閫� 2022-12-05 end-->
+ <apex:inputHidden
+ value="{!ir.AWS_Data_Id__c}"
+ id="AWS_Data_Id__c"
+ />
+
+ <apex:repeat
+ value="{!sectionList}"
+ var="section"
+ id="SectionList"
+ >
+ <apex:pageBlockSection
+ title="{!section.title}"
+ columns="{!section.column}"
+ showHeader="{!section.showHeader}"
+ rendered="{!!section.isTop}"
+ >
+ <apex:repeat
+ value="{!section.sectionItemList}"
+ var="sectionItem"
+ id="SectionItemList"
+ >
+ <apex:outputField
+ value="{!ir[sectionItem.api]}"
+ rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&&NOT(sectionItem.isInput)}"
+ />
+ <apex:inputField
+ html-field-api="{!sectionItem.api}"
+ style="width:{!sectionItem.width};height:{!sectionItem.height};margin-left:17px;"
+ value="{!ir[sectionItem.api]}"
+ rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&§ionItem.isInput}"
+ required="{!sectionItem.isRequired}"
+ html-tabindex="{!sectionItem.index}"
+ />
+ <apex:pageblockSectionItem
+ rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&Not(isNull(sectionItem.customizeLable))}"
+ >
+ <apex:outputLabel value="{!sectionItem.customizeLable}" />
+ <apex:outputPanel layout="none">
+ <apex:repeat value="{!sectionItem.apiList}" var="api">
+ <!-- 淇濆瓨寰屻�佺梾闄€伅寮峰埗outputField -->
+ <apex:outputPanel
+ layout="none"
+ rendered="{!api == 'Hospital__c' && ir.Id != ''}"
+ >
+ <apex:outputField value="{!ir[api]}" />
+ </apex:outputPanel>
+ <apex:outputPanel
+ layout="none"
+ rendered="{!NOT(api == 'Hospital__c' && ir.Id != '')}"
+ >
+ <apex:outputLabel
+ style="font-weight: bold; padding-right: 5px"
+ value="{!sectionItem.apiLabelMap[api]}"
+ />
+ <apex:inputField
+ html-field-api="{!api}"
+ value="{!ir[api]}"
+ style="{!sectionItem.apiStyleMap[api]}"
+ rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}"
+ required="{!sectionItem.apiRequireMap[api]}"
+ html-tabindex="{!sectionItem.index}"
+ />
+ <apex:outputPanel
+ style="display:inline-block;{!sectionItem.apiStyleMap[api]}"
+ rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}"
+ >
+ <apex:outputField value="{!ir[api]}" />
+ </apex:outputPanel>
+ </apex:outputPanel>
+ </apex:repeat>
+ </apex:outputPanel>
+ </apex:pageblockSectionItem>
+ <apex:pageblockSectionItem
+ rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&(isNull(sectionItem.customizeLable))}"
+ >
+ <apex:outputPanel layout="none">
+ <apex:repeat value="{!sectionItem.apiList}" var="api">
+ <apex:outputLabel
+ style="font-weight: bold; padding-right: 5px"
+ value="{!sectionItem.apiLabelMap[api]}"
+ />
+ <apex:inputField
+ html-field-api="api"
+ value="{!ir[api]}"
+ style="{!sectionItem.apiStyleMap[api]}"
+ rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}"
+ required="{!sectionItem.apiRequireMap[api]}"
+ html-tabindex="{!sectionItem.index}"
+ />
+ <apex:outputPanel
+ style="display:inline-block;{!sectionItem.apiStyleMap[api]}"
+ rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}"
+ >
+ <apex:outputField value="{!ir[api]}" />
+ </apex:outputPanel>
+ </apex:repeat>
+ </apex:outputPanel>
+ </apex:pageblockSectionItem>
+ <apex:pageBlockSectionItem
+ rendered="{!sectionItem.isDummy}"
+ />
+ </apex:repeat>
+ </apex:pageBlockSection>
+ </apex:repeat>
+
+ <script type="text/javascript">
+ // 鐥呴櫌銇乏鍋淬�屽埛鏂般�嶃儨銈裤兂杩藉姞
+ var labels = document.getElementsByTagName("label");
+ for (var i = 0; i < labels.length; i++) {
+ var lbl = labels[i];
+ if (lbl.innerText == "鍖婚櫌" || lbl.innerText == "鐥呴櫌") {
+ var html = lbl.parentNode.innerHTML;
+ html =
+ "<input type='button' value='鍒锋柊' class='btn' onclick='blockme();getAssetFromHp();' /> " +
+ html;
+ lbl.parentNode.innerHTML = html;
+ break;
+ }
+ }
+ </script>
+ <apex:pageBlockSection
+ title="宸查�変繚鏈夎澶囧瓧娈靛巻鍙�"
+ columns="1"
+ id="CheckSection"
+ >
+ <input type="hidden" id="ProductCnt" value="{!productCount}" />
+
+ <apex:outputPanel>
+ <table width="100%">
+ <tr>
+ <td> </td>
+ <td width="120px">
+ <span>鍏�</span>
+ <select
+ style="vertical-align: text-bottom"
+ id="allCheckResult"
+ size="1"
+ onchange="changeAllCheckResult(this.value);"
+ >
+ <option value=" ">--鏃�--</option>
+ <!-- 榛樿鍏∣K -->
+ <option value="OK" selected="selected">OK</option>
+ <!-- 榛樿鍏∣K -->
+ <option value="NG">NG</option>
+ <!-- add by rentx 20210630 start -->
+ <option value="鍖婚櫌鏀惧純">鍖婚櫌鏀惧純</option>
+ <!-- add by rentx 20210630 end -->
+ </select>
+ </td>
+ <td width="500px"> </td>
+ </tr>
+ </table>
+ <!-- TODO minus scroll with -->
+ <table
+ id="AssetTableHeader"
+ class="list"
+ style="border-bottom-width: 0px; font-size: 13px"
+ border="0"
+ cellspacing="0"
+ cellpadding="0"
+ >
+ <tr
+ style="
+ border-bottom: 1px groove rgba(254, 254, 254, 0.48);
+ background: #f2f3f3;
+ "
+ >
+ <!-- add by rentx 20210809 -->
+ <th class="headerCell" style="width: 14px">
+ <apex:inputCheckbox
+ id="checkAll1"
+ onclick="checkAll(this)"
+ />
+ </th>
+ <!-- <th class="headerCell" style="width:14px" /> -->
+ <!-- add by rentx 202120809 -->
+ <th class="headerCell" style="width: 24px" />
+ <th class="headerCell" style="width: 60px">
+ {!$ObjectType.Asset.fields.Asset_situation__c.label}
+ </th>
+ <th class="headerCell">
+ {!$ObjectType.Asset.fields.Name.label}
+ </th>
+ <th class="headerCell" style="width: 100px">
+ {!$ObjectType.Inspection_Item__c.Fields.SerialNumber__c.Label}
+ </th>
+ <!-- TODO 闋呯洰銇綔鎴� -->
+ <th class="headerCell" style="width: 80px">涓婃鐐规鏃�</th>
+ <th class="headerCell" style="width: 100px">
+ 涓婃淇悊瀹屾瘯鏃�
+ </th>
+ <th class="headerCell" style="width: 80px">
+ {!$ObjectType.Inspection_Item__c.Fields.ItemStatus__c.Label}
+ </th>
+ <th class="headerCell" style="width: 100px">
+ {!$ObjectType.Inspection_Item__c.Fields.Fault_Classification1__c.Label}
+ </th>
+ <th class="headerCell" style="width: 100px">
+ {!$ObjectType.Inspection_Item__c.Fields.Fault_Classification2__c.Label}
+ </th>
+ <th class="headerCell" style="width: 100px">
+ {!$ObjectType.Inspection_Item__c.Fields.Fault_Classification3__c.Label}
+ </th>
+ <th class="headerCell" style="width: 100px">
+ {!$ObjectType.Inspection_Item__c.Fields.Diagnosis__c.Label}
+ </th>
+ <!-- add by rentx 20210630 -->
+ <th class="headerCell" style="width: 85px">
+ {!$ObjectType.Inspection_Item__c.Fields.Abandonment_Reasons__c.Label}
+ </th>
+ <!-- add by rentx 20210630 -->
+ <th class="headerCell" style="width: 35px">
+ {!$ObjectType.Asset.Fields.Create_repair__c.Label}
+ </th>
+ <!-- <td class="headerScroll"></td> -->
+ </tr>
+ </table>
+
+ <div style="height: 400px; width: 100%; overflow: auto">
+ <table
+ style="border-collapse: collapse; width: 100%"
+ id="AssetTable"
+ >
+ <apex:variable value="{!1}" var="cnt" />
+ <apex:repeat
+ value="{!checkedInfoList}"
+ var="cInfo"
+ id="CheckedInfoList"
+ >
+ <tr
+ style="
+ border-bottom: 1px groove rgba(254, 254, 254, 0.48);
+ "
+ >
+ <td style="width: 14px">
+ <apex:inputCheckbox
+ value="{!cInfo.rec_checkBox_c}"
+ id="AssetRowCheckbox1"
+ rendered="{!Not(cInfo.IsManual)}"
+ />
+ <apex:outputText
+ value="{!cInfo.IsManual}"
+ id="IsManual"
+ style="display: none"
+ />
+ <input
+ type="hidden"
+ value="{!cInfo.rec.Id}"
+ id="CheckAssetId"
+ />
+ </td>
+ <td
+ style="
+ font-weight: bold;
+ text-align: right;
+ width: 24px;
+ "
+ >
+ {!cnt}
+ </td>
+ <td class="dataCell" style="width: 60px">
+ <apex:outputField
+ value="{!cInfo.rec.Asset_situation__c}"
+ />
+ </td>
+ <td class="dataCell">
+ <!-- HWAG-BDCA9J 娣诲姞浜� onclick blurProduct 鍐呭 start-->
+ <apex:outputField
+ value="{!cInfo.rec.Name}"
+ rendered="{!Not(cInfo.IsManual)}"
+ />
+ <apex:inputField
+ value="{!cInfo.ah.Product_Manual__c}"
+ id="Assert"
+ style="width: 100%"
+ rendered="{!cInfo.IsManual}"
+ onclick="if(!blurProduct(this))return false;"
+ />
+ <!-- HWAG-BDCA9J 娣诲姞浜� onclick blurProduct 鍐呭 end-->
+ </td>
+ <td class="dataCell" style="width: 100px">
+ <apex:outputField
+ value="{!cInfo.ah.SerialNumber__c}"
+ rendered="{!Not(cInfo.IsManual)}"
+ />
+ <apex:inputField
+ value="{!cInfo.ah.SerialNo_Manual__c}"
+ id="SerialNo"
+ style="width: 90%"
+ rendered="{!cInfo.IsManual}"
+ />
+ </td>
+ <td class="dataCell" style="width: 80px">
+ <apex:outputField
+ value="{!cInfo.rec.Final_Examination_Date__c}"
+ rendered="{!Not(cInfo.IsManual)}"
+ />
+ </td>
+ <td class="dataCell" style="width: 100px">
+ <apex:outputField
+ value="{!cInfo.rec.After_repair_last_internal_check_day__c}"
+ rendered="{!Not(cInfo.IsManual)}"
+ />
+ </td>
+ <td class="dataCell" style="width: 80px">
+ <apex:inputField
+ value="{!cInfo.ah.ItemStatus__c}"
+ id="AssetRowCheckboxIsNormal"
+ style="width: 98%"
+ />
+ </td>
+ <td class="dataCell" style="width: 100px">
+ <apex:inputField
+ value="{!cInfo.ah.Fault_Classification1__c}"
+ />
+ </td>
+ <td class="dataCell" style="width: 100px">
+ <apex:inputField
+ value="{!cInfo.ah.Fault_Classification2__c}"
+ id="cat2"
+ />
+ </td>
+ <td class="dataCell" style="width: 100px">
+ <apex:inputField
+ value="{!cInfo.ah.Fault_Classification3__c}"
+ id="cat3"
+ />
+ </td>
+ <td class="dataCell" style="width: 100px">
+ <apex:inputField
+ value="{!cInfo.ah.Diagnosis__c}"
+ style="width: 93%"
+ />
+ </td>
+ <!-- add by rentx 20210630 -->
+ <td class="dataCell" style="width: 85px">
+ <apex:inputField
+ value="{!cInfo.ah.Abandonment_Reasons__c}"
+ style="width: 93%"
+ />
+ </td>
+ <!-- add by rentx 20210630 -->
+ <td class="dataCell" style="width: 35px">
+ <apex:outputPanel
+ layout="none"
+ rendered="{!Not(cInfo.IsManual)}"
+ >
+ <a
+ href="#"
+ onclick="saveByRepairJs('{!cInfo.rec.Id}', '{!JSENCODE(cInfo.rec.Name)}', '{!cInfo.rec.Hospital__r.Id}', '{!JSENCODE(cInfo.rec.Hospital__r.Name)}', '{!cInfo.rec.Department_Class__r.Id}', '{!JSENCODE(cInfo.rec.Department_Class__r.Name)}', '{!cInfo.rec.Account.Id}', '{!JSENCODE(cInfo.rec.Account.Name)}', '鍙慨鐞�');"
+ >鈻�</a
+ >
+ </apex:outputPanel>
+ </td>
+ </tr>
+ <apex:variable value="{!cnt + 1}" var="cnt" />
+ </apex:repeat>
+ </table>
+ </div>
+ </apex:outputPanel>
+ </apex:pageBlockSection>
+
+ <apex:outputPanel id="ButtonPanel">
+ <table style="width: 100%">
+ <tr>
+ <td>
+ <apex:commandButton
+ value="琛岃拷鍔�"
+ action="{!addNewRows}"
+ disabled="{!Not($ObjectType.Inspection_Item__c.createable)}"
+ style="margin-left: 10px; float: left"
+ onclick="blockme();"
+ oncomplete="unblockUI();"
+ rerender="Form"
+ />
+ <apex:commandButton
+ value="鍒锋柊閫変腑鐨勪繚鏈夎澶�"
+ onclick="exchangeAssetJs();return false;"
+ rerender="dummy"
+ />
+ <!-- <apex:commandButton value="鍒锋柊閫変腑鐨勪繚鏈夎澶�" action="{!exchangeAsset}" onclick="blockme();" oncomplete="unblockUI();" rerender="Form" /> -->
+ <!-- <apex:commandButton value="鍒锋柊鍖婚櫌涓嬬殑鍏ㄩ儴淇濇湁璁惧" action="{!getAssetFromHp}" onclick="blockme();" oncomplete="unblockUI();" rerender="Form" /> -->
+ </td>
+ </tr>
+ </table>
+ </apex:outputPanel>
+ <table>
+ <tr>
+ <td>
+ <div id="ErrorName" style="color: red; font-weight: bold">
+ {!alertMessage}
+ </div>
+ </td>
+ </tr>
+ </table>
+ <!-- HWAG-B4Q3G5 20180918Start -->
+ <apex:pageBlockSection
+ title="鏈�変繚鏈夎澶囧瓧娈靛巻鍙�"
+ columns="1"
+ id="UnCheckSection"
+ onkeydown="if(event.keyCode==13){searchJs(); return false;}"
+ >
+ <!-- HWAG-B4Q3G5 20180918End -->
+ <input
+ type="hidden"
+ id="ProductCnt2"
+ value="{!productCount2}"
+ />
+ <apex:outputPanel>
+ <div align="center">
+ <apex:outputPanel id="countorder"
+ >绗瑊!countorder}椤�</apex:outputPanel
+ >
+ <apex:commandButton
+ value="涓婁竴椤�"
+ action="{!UpPage}"
+ onclick="blockme();"
+ disabled="{!IF(countorder=1,true,false)}"
+ oncomplete="unblockUI();"
+ reRender="Form"
+ />
+ <apex:commandButton
+ value="涓嬩竴椤�"
+ action="{!DownPage}"
+ onclick="blockme();"
+ disabled="{!IF(countorder >=nowAssetcount ,true,false)}"
+ oncomplete="unblockUI();"
+ rerender="Form"
+ />
+ <apex:outputPanel id="NowOrdercount"
+ >鍏眥!nowAssetcount}椤�</apex:outputPanel
+ >
+ </div>
+
+ <table>
+ <tr>
+ <td style="width: 85px" align="right">閫夋嫨鏉′欢</td>
+ <td style="width: 85px" align="right">
+ <apex:selectList
+ value="{!text1}"
+ id="text1"
+ size="1"
+ style="width: 80px"
+ ><apex:selectOptions value="{!textOpts}"
+ /></apex:selectList>
+ </td>
+ <td style="width: 85px" align="center">
+ <apex:selectList
+ value="{!cond1}"
+ id="cond1"
+ size="1"
+ style="width: 80px"
+ ><apex:selectOptions value="{!equalOpts}"
+ /></apex:selectList>
+ </td>
+ <td style="width: 95px" align="left">
+ <apex:inputText
+ value="{!val1}"
+ id="val1"
+ style="width: 100px"
+ />
+ </td>
+ <td align="left">
+
+ <apex:commandButton
+ value="妫�绱�"
+ onclick="searchJs();return false;"
+ style="width: 130px"
+ rerender="dummy"
+ />
+
+ <apex:commandButton
+ value="娓呴櫎鏉′欢"
+ onclick="clearAndSearch();"
+ style="width: 130px"
+ rerender="dummy"
+ />
+
+ <span style="vertical-align: text-bottom"
+ >浣跨敤涓�<apex:inputCheckBox value="{!activeOn}"
+ /></span>
+ </td>
+ </tr>
+ </table>
+ <table style="border-collapse: collapse" id="AssetTable2">
+ <tr
+ style="
+ border-bottom: 1px groove rgba(254, 254, 254, 0.48);
+ background: #f2f3f3;
+ "
+ >
+ <!-- add by rentx 20210809 start 鍏ㄩ�夊姛鑳� -->
+ <!-- <th class="headerCell" style="width:25px"></th> -->
+ <th
+ class="headerCell"
+ style="padding: 2px 5px; width: 25px"
+ >
+ <apex:inputCheckbox
+ id="checkAll1"
+ onclick="checkAll2(this)"
+ />
+ </th>
+ <!-- add by rentx 20210809 end 鍏ㄩ�夊姛鑳� -->
+ <th class="headerCell" style="width: 70px">
+ <a
+ href="#"
+ onclick="sortTableJs('0');return false;"
+ style="text-decoration: underline"
+ >{!$ObjectType.Asset.fields.Asset_situation__c.label}</a
+ >{!sortOrder[0]}
+ </th>
+ <th class="headerCell">
+ <a
+ href="#"
+ onclick="sortTableJs('1');return false;"
+ style="text-decoration: underline"
+ >{!$ObjectType.Asset.fields.Name.label}</a
+ >{!sortOrder[1]}
+ </th>
+ <th class="headerCell" style="width: 70px">
+ <a
+ href="#"
+ onclick="sortTableJs('2');return false;"
+ style="text-decoration: underline"
+ >{!$ObjectType.Asset.fields.SerialNumber.label}</a
+ >{!sortOrder[2]}
+ </th>
+ <th class="headerCell" style="width: 70px">
+ <a
+ href="#"
+ onclick="sortTableJs('3');return false;"
+ style="text-decoration: underline"
+ >{!$ObjectType.Asset.fields.CurrentContract__c.label}</a
+ >{!sortOrder[3]}
+ </th>
+ <th class="headerCell" style="width: 70px">
+ <a
+ href="#"
+ onclick="sortTableJs('4');return false;"
+ style="text-decoration: underline"
+ >{!$ObjectType.Asset.fields.Department_Name__c.label}</a
+ >{!sortOrder[4]}
+ </th>
+ <th class="headerCell" style="width: 70px">
+ <a
+ href="#"
+ onclick="sortTableJs('5');return false;"
+ style="text-decoration: underline"
+ >{!$ObjectType.Asset.fields.Status.label}</a
+ >{!sortOrder[5]}
+ </th>
+ <th class="headerCell" style="width: 90px">
+ <a
+ href="#"
+ onclick="sortTableJs('6');return false;"
+ style="text-decoration: underline"
+ >{!$ObjectType.Asset.fields.Installation_Site__c.label}</a
+ >{!sortOrder[6]}
+ </th>
+ <th class="headerCell" style="width: 90px">
+ <a
+ href="#"
+ onclick="sortTableJs('7');return false;"
+ style="text-decoration: underline"
+ >{!$ObjectType.Asset.fields.Room_Number__c.label}</a
+ >{!sortOrder[7]}
+ </th>
+ <th class="headerCell" style="width: 90px">
+ <a
+ href="#"
+ onclick="sortTableJs('8');return false;"
+ style="text-decoration: underline"
+ >{!$ObjectType.Asset.fields.InstallDate.label}</a
+ >{!sortOrder[8]}
+ </th>
+ <th class="headerCell" style="width: 90px">
+ <a
+ href="#"
+ onclick="sortTableJs('9');return false;"
+ style="text-decoration: underline"
+ >{!$ObjectType.Asset.fields.Asset_Owner__c.label}</a
+ >{!sortOrder[9]}
+ </th>
+ <th class="headerCell" style="width: 90px">
+ <a
+ href="#"
+ onclick="sortTableJs('10');return false;"
+ style="text-decoration: underline"
+ >{!$ObjectType.Asset.fields.Accumulation_Repair_Amount__c.label}</a
+ >{!sortOrder[10]}
+ </th>
+ </tr>
+ <apex:variable value="{!1}" var="cnt" />
+ <apex:variable value="{!0}" var="cntOut" />
+ <apex:repeat
+ value="{!IF(ThousandFLG>0,unCheckedInfoListForThousend,1)}"
+ var="Thoinfo"
+ id="unCheckedInfoListForThousend"
+ >
+ <apex:repeat
+ value="{!IF(ThousandFLG>0,Thoinfo,unCheckedInfoList)}"
+ var="ucInfo"
+ id="UnCheckedInfoList"
+ >
+ <tr
+ style="
+ border-bottom: 1px groove rgba(254, 254, 254, 0.48);
+ "
+ >
+ <td style="padding: 2px 5px; width: 25px">
+ <apex:inputCheckbox
+ value="{!ucInfo.rec_checkBox_c}"
+ id="AssetRowCheckbox2"
+ />
+ <input
+ type="hidden"
+ value="{!ucInfo.rec.Id}"
+ id="UncheckAssetId"
+ />
+ </td>
+ <td style="padding: 2px 5px; width: 70px">
+ <apex:outputField
+ value="{!ucInfo.rec.Asset_situation__c}"
+ />
+ </td>
+ <td style="padding: 2px 5px">
+ <a
+ href="#"
+ onclick="window.open('/{!ucInfo.rec.Id}', '_blank');"
+ >{!ucInfo.rec.Name}</a
+ >
+ <!-- <apex:outputField value="{!ucInfo.rec.name}" id="assetName"/> -->
+ </td>
+ <td style="padding: 2px 5px; width: 70px">
+ <apex:outputField
+ value="{!ucInfo.rec.SerialNumber}"
+ />
+ </td>
+ <td style="padding: 2px 5px; width: 70px">
+ <!-- <apex:outputField value="{!ucInfo.rec.CurrentContract__c}"/> -->
+ <a
+ href="#"
+ onclick="window.open('/{!ucInfo.rec.CurrentContract__c}', '_blank');"
+ >{!ucInfo.rec.CurrentContract__r.Management_Code__c}</a
+ >
+ </td>
+ <td style="padding: 2px 5px; width: 70px">
+ <apex:outputField
+ value="{!ucInfo.rec.Department_Name__c}"
+ />
+ </td>
+ <td style="padding: 2px 5px; width: 70px">
+ <apex:outputField value="{!ucInfo.rec.Status}" />
+ </td>
+ <td style="padding: 2px 5px; width: 70px">
+ <apex:outputField
+ value="{!ucInfo.rec.Installation_Site__c}"
+ />
+ </td>
+ <td style="padding: 2px 5px; width: 70px">
+ <apex:outputField
+ value="{!ucInfo.rec.Room_Number__c}"
+ />
+ </td>
+ <td
+ style="
+ padding: 2px 5px;
+ width: 90px;
+ text-align: center;
+ "
+ >
+ <apex:outputField
+ value="{!ucInfo.rec.InstallDate}"
+ />
+ </td>
+ <td style="padding: 2px 5px; width: 90px">
+ <apex:outputField
+ value="{!ucInfo.rec.Asset_Owner__c}"
+ />
+ </td>
+ <td
+ style="
+ padding: 2px 5px;
+ width: 90px;
+ text-align: center;
+ "
+ >
+ <apex:outputField
+ value="{!ucInfo.rec.Accumulation_Repair_Amount__c}"
+ />
+ </td>
+ </tr>
+ <apex:variable value="{!cnt + 1}" var="cnt" />
+ </apex:repeat>
+ <apex:variable value="{!cntOut + 1}" var="cntOut" />
+ </apex:repeat>
+ </table>
+ </apex:outputPanel>
+ </apex:pageBlockSection>
+ <!-- fxk 2021/8/4 鏂板姞 Start-->
+ <apex:pageBlockSection
+ title="鎵撳嵃鏃舵礂娑堜俊鎭�"
+ columns="1"
+ id="UnCheckSection1"
+ >
+ <apex:outputPanel>
+ <table
+ class="edittable"
+ border="0"
+ style="
+ border-collapse: collapse;
+ width: 600px;
+ table-layout: fixed;
+ "
+ >
+ <tr>
+ <td>
+ {!$ObjectType.Inspection_Report__c.fields.CleaningFluid__c.Label}:
+ </td>
+ <td>
+ <apex:inputField
+ value="{!ir.CleaningFluid__c}"
+ style="width: 90%"
+ />
+ </td>
+ <!-- 鏂瑰紡 add by rentx 20210927 start-->
+ <td>
+ {!$ObjectType.Inspection_Report__c.fields.Mode__c.Label}:
+ </td>
+ <td>
+ <apex:inputField
+ value="{!ir.Mode__c}"
+ style="width: 90%"
+ />
+ </td>
+ <!-- 鏂瑰紡 add by rentx 20210927 end -->
+ <td>
+ {!$ObjectType.Inspection_Report__c.fields.SterilizationMethod__c.Label}:
+ </td>
+ <td>
+ <apex:inputField
+ value="{!ir.SterilizationMethod__c}"
+ style="width: 90%"
+ />
+ </td>
+ <td>
+ {!$ObjectType.Inspection_Report__c.fields.Remarks__c.Label}:
+ </td>
+ <td>
+ <apex:inputText
+ value="{!ir.Remarks__c}"
+ style="width: 90%"
+ />
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {!$ObjectType.Inspection_Report__c.fields.Disinfectant__c.Label}:
+ </td>
+ <td>
+ <apex:inputField
+ value="{!ir.Disinfectant__c}"
+ style="width: 90%"
+ />
+ </td>
+ <td>
+ {!$ObjectType.Inspection_Report__c.fields.UsedMachine__c.Label}:
+ </td>
+ <td>
+ <apex:inputField
+ value="{!ir.UsedMachine__c}"
+ style="width: 90%"
+ />
+ </td>
+ <td>
+ {!$ObjectType.Inspection_Report__c.fields.Used_ET__c.Label}:
+ </td>
+ <td>
+ <apex:inputText
+ value="{!ir.Used_ET__c}"
+ style="width: 90%"
+ />
+ </td>
+ </tr>
+ </table>
+ </apex:outputPanel>
+ </apex:pageBlockSection>
+ <!-- fxk 2021/8/4 鏂板姞 End-->
+ </div>
+ </apex:pageBlock>
+ </div>
+ <script type="text/javascript">
+ // 宸茬瀛椼伄鍫村悎銆佸鏇翠笉鑳姐伀銇欍倠
+ var status = "{!ir.Status__c}";
+ if (status == "鐢宠涓�" || status == "鎵瑰噯") {
+ var inputs = document.getElementsByTagName("input");
+ for (var i = 0; i < inputs.length; i++) {
+ var obj = inputs[i];
+
+ if (obj.id == "Page:Form:Block:closeButton") continue;
+ //if (obj.id == "Page:Form:Block:submitButton") continue;
+ //if (status == "宸茬瀛�" && obj.id == "Page:Form:Block:submitButton") continue;
+
+ if (obj.type == "button") {
+ setButtonDisable(obj, true);
+ } else {
+ obj.disabled = true;
+ }
+ }
+ var selects = document.getElementsByTagName("select");
+ console.log(selects);
+ for (var i = 0; i < selects.length; i++) {
+ selects[i].disabled = true;
+ }
+ } else {
+ //var smb = j$(escapeVfId("Page:Form:Block:submitButton"))[0];
+ //setButtonDisable(smb, true);
+ }
+ // HWAG-BDCA9J 鎻愰啋鏈繚瀛樺拰鍒锋柊鍓嶄笉鑳介�夋嫨浜у搧 start
+ function blurProduct(obj) {
+ var irID = "{!ir.Id}";
+ var productCount2 = "{!productCount2}";
+ if (!irID && productCount2 == 0) {
+ alert(
+ "璇峰厛杈撳叆鍖婚櫌骞剁偣鍑诲埛鏂版寜閽皟鍑轰繚鏈夎澶囷紝鍚﹀垯鐐规缁撴灉鏃犳硶涓庤澶囧叧鑱斻��"
+ );
+ obj.blur();
+ return false;
+ }
+ return true;
+ }
+ // HWAG-BDCA9J 鎻愰啋鏈繚瀛樺拰鍒锋柊鍓嶄笉鑳介�夋嫨浜у搧 end
+ </script>
+ </apex:form>
+ </body>
+ </html>
+</apex:page>
diff --git a/force-app/main/default/pages/StraightBackAddress.page b/force-app/main/default/pages/StraightBackAddress.page
index 7c49578..9448640 100644
--- a/force-app/main/default/pages/StraightBackAddress.page
+++ b/force-app/main/default/pages/StraightBackAddress.page
@@ -5,1109 +5,1333 @@
@last modified on : 03-30-2022
@last modified by : ChangeMeIn@UserSettingsUnder.SFDoc
-->
-<apex:page controller="StraightBackAddressController" action="{!init}" showHeader="false" sidebar="true" id="allPage" title="鐩磋繑鏀惰揣鍦板潃">
- <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
- <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
- <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
- <apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/>
- <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
- <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
- <apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
- <script type="text/javascript">
- var checkedTrue;
- var tableDataStr = '';
- var staticResource = JSON.parse('{!staticResource}');
- var staticResourceContact = JSON.parse('{!staticResourceContact}');
- var staticResourceRepair = JSON.parse('{!staticResourceRepair}');
-
- var PIData = {};
- var contactDataIds = [];
- var ObjIdDecrypt = '';
- var closeField = '';
- var add_aws_result = '';
- var con_aws_result = '';
- var isAddCon = false;
- var contactInfoStr = '';
+<apex:page
+ controller="StraightBackAddressController"
+ action="{!init}"
+ showHeader="false"
+ sidebar="true"
+ id="allPage"
+ title="鐩磋繑鏀惰揣鍦板潃"
+ lightningStylesheets="true"
+>
+ <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}" />
+ <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}" />
+ <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}" />
+ <apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}" />
+ <apex:includeScript
+ value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"
+ />
+ <apex:includeScript value="{!URLFOR($Resource.connection20)}" />
+ <apex:includeScript value="{!URLFOR($Resource.apex20)}" />
+ <script type="text/javascript">
+ var checkedTrue;
+ var tableDataStr = '';
+ var staticResource = JSON.parse('{!staticResource}');
+ var staticResourceContact = JSON.parse('{!staticResourceContact}');
+ var staticResourceRepair = JSON.parse('{!staticResourceRepair}');
- var addressAwsData = {};
+ var PIData = {};
+ var contactDataIds = [];
+ var ObjIdDecrypt = '';
+ var closeField = '';
+ var add_aws_result = '';
+ var con_aws_result = '';
+ var isAddCon = false;
+ var contactInfoStr = '';
- var isBlocking = false;
+ var addressAwsData = {};
- var contactNamePlaintext = '';
- var telePhonePlaintext = '';
- var zipCodePlaintext = '';
- var detailedAddressPlaintext = '';
- function b(){
- if (!isBlocking) {
- blockme();
- isBlocking = true;
- }
- }
+ var isBlocking = false;
- function ub(){
- if (isBlocking) {
- unblockUI();
- isBlocking = false;
- }
- }
-
- //鏇挎崲vlookup
- var newSearchContactWindow = null;
- window.onload = function () {
- document.getElementById("tab01").style.height = screen.availHeight*0.07+'px';
- document.getElementById("tab02").style.height = screen.availHeight*0.53+'px';
- document.getElementById("tab03").style.height = screen.availHeight*0.25+'px';
- }
- //缂栬緫鎸夐挳
- function onEditorJs(ObjId){
- ObjIdDecrypt = ObjId;
- onEditor(ObjId);
+ var contactNamePlaintext = '';
+ var telePhonePlaintext = '';
+ var zipCodePlaintext = '';
+ var detailedAddressPlaintext = '';
+ function b(){
+ if (!isBlocking) {
+ blockme();
+ isBlocking = true;
}
- //澶嶅埗鎸夐挳
- function onCopyJs(ObjId){
- ObjIdDecrypt = ObjId;
- if(ObjId == ''){
- onCopy('绌�');//璁剧疆涓虹┖锛屼究浜庡悗绔仛鏁版嵁澶勭悊
- }else{
- onCopy(ObjId);
- }
- }
- //aws 纭
- function Trans(){
- let b = HasError();
- if(b){
- //杩樺師鑱旂郴浜虹數璇濆湴鍧�閭紪
- document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ContactName__c').value = contactNamePlaintext;
- document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Telephone__c').value = telePhonePlaintext;
- document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c').value = zipCodePlaintext
- document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c').value = detailedAddressPlaintext
- return
- }
+ }
- //{!IF(isSearchBtn,'searchBtnJs()',false)};
- let b1= false;
- let b2= false;
+ function ub(){
+ if (isBlocking) {
+ unblockUI();
+ isBlocking = false;
+ }
+ }
- let Foo = function(){
- // if (b1 && b2 && !b) {
- // window.location.reload();
- // }
- if (b1 && !b) {
- window.location.reload();
- }
- }
+ //鏇挎崲vlookup
+ var newSearchContactWindow = null;
+ window.onload = function () {
+ document.getElementById("tab01").style.height = screen.availHeight*0.07+'px';
+ document.getElementById("tab02").style.height = screen.availHeight*0.53+'px';
+ document.getElementById("tab03").style.height = screen.availHeight*0.25+'px';
+ }
+ //缂栬緫鎸夐挳
+ function onEditorJs(ObjId){
+ ObjIdDecrypt = ObjId;
+ onEditor(ObjId);
+ }
+ //澶嶅埗鎸夐挳
+ function onCopyJs(ObjId){
+ ObjIdDecrypt = ObjId;
+ if(ObjId == ''){
+ onCopy('绌�');//璁剧疆涓虹┖锛屼究浜庡悗绔仛鏁版嵁澶勭悊
+ }else{
+ onCopy(ObjId);
+ }
+ }
+ //aws 纭
+ function Trans(){
+ let b = HasError();
+ if(b){
+ //杩樺師鑱旂郴浜虹數璇濆湴鍧�閭紪
+ document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ContactName__c').value = contactNamePlaintext;
+ document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Telephone__c').value = telePhonePlaintext;
+ document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c').value = zipCodePlaintext
+ document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c').value = detailedAddressPlaintext
+ return
+ }
- AWSService.post(staticResource.transactionUrl, JSON.stringify({
- "txId":add_aws_result.txId,
- "isSuccess":b ? 0 : 1
- }), function(result){
- b1 = true;
- Foo();
- }, staticResource.token);
+ //{!IF(isSearchBtn,'searchBtnJs()',false)};
+ let b1= false;
+ let b2= false;
- //涓嶄細鍐嶆柊寤鸿仈绯讳汉鏃犻渶纭浜嬪姟
- // if(isAddCon){
- // AWSService.post(staticResourceContact.transactionUrl, JSON.stringify({
- // "txId":con_aws_result.txId,
- // "isSuccess":b ? 0 : 1
- // }), function(result){
- // b2 = true;
- // Foo();
- // }, staticResourceContact.token);
- // }else{
- // b2 = true;
- // Foo();
- // }
-
-
- }
+ let Foo = function(){
+ // if (b1 && b2 && !b) {
+ // window.location.reload();
+ // }
+ if (b1 && !b) {
+ window.location.reload();
+ }
+ }
- function HasError(){
- // if (IsAddmessage) {
- // return true;
- // }
- let e = document.getElementById("allPage:allForm:message");
- if (!e) {
- return false;
- }
+ AWSService.post(staticResource.transactionUrl, JSON.stringify({
+ "txId":add_aws_result.txId,
+ "isSuccess":b ? 0 : 1
+ }), function(result){
+ b1 = true;
+ Foo();
+ }, staticResource.token);
- let divs = j$(e).find("div.message");
- for (let i = 0; i < divs.length; i++) {
- for (let j = 0; j < divs[i].classList.length; j++) {
- for(let cls in divs[i].classList){
- if (cls.indexOf('error')>-1) {
- return true;
- }
- }
-
- }
-
- }
+ //涓嶄細鍐嶆柊寤鸿仈绯讳汉鏃犻渶纭浜嬪姟
+ // if(isAddCon){
+ // AWSService.post(staticResourceContact.transactionUrl, JSON.stringify({
+ // "txId":con_aws_result.txId,
+ // "isSuccess":b ? 0 : 1
+ // }), function(result){
+ // b2 = true;
+ // Foo();
+ // }, staticResourceContact.token);
+ // }else{
+ // b2 = true;
+ // Foo();
+ // }
- return false;
- }
- //瑙e瘑
- function decrypt(){
- if(PIData[ObjIdDecrypt] == null){
- // document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Contacts__c').value = '';
- //document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:contactIdValue').value = '000000000000000';
- document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ContactName__c').value = '';
- document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Telephone__c').value = '';
- document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c').value = '';
- document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c').value = '';
- }else{
- // document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Contacts__c').value = PIData[ObjIdDecrypt].lastName!=null?PIData[ObjIdDecrypt].lastName:'';
- document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ContactName__c').value = PIData[ObjIdDecrypt].lastName;
- document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Telephone__c').value = PIData[ObjIdDecrypt].telephone;
- document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c').value = PIData[ObjIdDecrypt].zipCode;
- document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c').value = PIData[ObjIdDecrypt].detailedAddress;
- }
- }
- function getPIPayload() {
- let leadPayloadList = [];
- var telePhone = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Telephone__c').value;
- var zipCode = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c').value;
- var detailedAddress = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c').value;
- let leadPIData = new Object();
- leadPIData.telePhone = telePhone;
- leadPIData.zipCode = zipCode;
- leadPIData.detailedAddress = detailedAddress;
- leadPIData.sfRecordId = '';
- leadPayloadList.push(leadPIData);
- console.log(JSON.stringify(leadPayloadList));
- return JSON.stringify(leadPayloadList);
- }
- //WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 start
- //淇濆瓨鏂规硶
- function savaJs(){
- //b();
- //涓嶄細鏂板缓鑱旂郴浜猴紝鎵�浠ヨ繖閲屼笉闇�瑕佸皢isAddCon璁剧疆涓簍rue
- // if(document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ContactName__c').value != ''){
- // isAddCon = true;
- // }
- document.getElementById("errorMsg").innerHTML = '';
-
- if(!document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ContactName__c").value){
- document.getElementById("errorMsg").innerHTML = '<strong>銆愯仈绯讳汉銆戜笉鑳戒负绌猴紒</strong> ';
- return;
- }
- // else if(document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Contacts__c").value&&document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c").value){
- // document.getElementById("errorMsg").innerHTML = '<strong>銆愯仈绯讳汉銆戝拰銆愯仈绯讳汉锛堟柊寤猴級銆戜笉鑳藉悓鏃舵湁鍊硷紒</strong> ';
- // return;
- // }
- b();
- console.log('{!insUpdData}')
- // if(document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c").value){
- // //new contact
- // ProcessPI({},GetEditObj('contact'),'contact',function(){
- // //new address
- // ProcessPI({},
- // GetEditObj('address'),'address',function(){
- // save();
- // });
- // });
- // }else{
- //new address
- ProcessPI({},GetEditObj('address'),'address',function(){
- save();
- });
- // }
- }
- //WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 end
+ }
- function ProcessPI(sobjJson, payloadForNewPI,type,callback) {
- var sr = ''
- // if(type == 'contact'){
- // sr = staticResourceContact
- // }
- if(type == 'address'){
- sr = staticResource
- }
- let url = sr.newUrl
- /*if (now_edit_id) {
- url = sr.updateUrl
- }*/
- AWSService.post(url, payloadForNewPI, function(result){
- // if(type == 'contact'){
- // con_aws_result = result
- // }
- if(type == 'address'){
- add_aws_result = result
- }
- SetEditObj(type);
- if(callback){
- callback();
- }
- }, sr.token);
- }
- function SetEditObj(type){
- let obj = GetAWSResultObj(type);
- if(obj){
- // if(type=='contact'){
- // document.getElementById("allPage:allForm:oppBlock2:Con_AWS_Data_Id__c").value = obj.dataId;
- // document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ContactName__c").value = obj.lastName;
- // document.getElementById("allPage:allForm:oppBlock2:LastName_Encrypted__c").value = obj.lastNameEncrypt;
- // }
- if(type=='address'){
- document.getElementById("allPage:allForm:oppBlock2:Add_AWS_Data_Id__c").value = obj.dataId;
- document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ContactName__c').value = obj.contactName;
- //document.getElementById('allPage:allForm:oppBlock2:ContactName_Encrypted__c').value = obj.contactNameEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-05
- document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Telephone__c").value = obj.telephone;
- //document.getElementById("allPage:allForm:oppBlock2:Telephone_Encrypted__c").value = obj.telephoneEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-05
- document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c").value = obj.zipCode;
- //document.getElementById("allPage:allForm:oppBlock2:ZipCode_Encrypted__c").value = obj.zipCodeEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-05
- document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c").value = obj.detailedAddress;
- //document.getElementById("allPage:allForm:oppBlock2:Detailed_Address_Encrypted__c").value = obj.detailedAddressEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-05
+ function HasError(){
+ // if (IsAddmessage) {
+ // return true;
+ // }
+ let e = document.getElementById("allPage:allForm:message");
+ if (!e) {
+ return false;
+ }
- }
- }
-
- }
- function GetAWSResultObj(type){
- // if(type == 'contact'){
- // if(con_aws_result && con_aws_result.object && con_aws_result.object.length > 0){
- // return con_aws_result.object[0];
- // }
- // }
- if(type == 'address'){
- if(add_aws_result && add_aws_result.object && add_aws_result.object.length > 0){
- return add_aws_result.object[0];
- }
- }
- return null;
- }
+ let divs = j$(e).find("div.message");
+ for (let i = 0; i < divs.length; i++) {
+ for (let j = 0; j < divs[i].classList.length; j++) {
+ for(let cls in divs[i].classList){
+ if (cls.indexOf('error')>-1) {
+ return true;
+ }
+ }
- function GetEditObj(type){
- // if(type=='contact'){
- // //new contact
- // return JSON.stringify([{
- // lastName : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ContactName__c").value,
- // dataId : document.getElementById("allPage:allForm:oppBlock2:Con_AWS_Data_Id__c").value,
- // }]);
- // }
- contactNamePlaintext = document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ContactName__c").value;
- telePhonePlaintext = document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Telephone__c").value;
- zipCodePlaintext = document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c").value
- detailedAddressPlaintext = document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c").value;
- if(type == 'address'){
- //new address
- return JSON.stringify([{
- dataId : document.getElementById("allPage:allForm:oppBlock2:Add_AWS_Data_Id__c").value,
- contactName : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ContactName__c").value,
- telephone : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Telephone__c").value,
- zipCode : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c").value,
- detailedAddress : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c").value,
- }]);
- }
-
- }
+ }
- //澶嶉�夋閫変腑瑙﹀彂浜嬩欢
- //obj 褰撳墠瀵硅薄 checkIndex 褰撳墠鐐瑰嚮鐨勭鍑犺
- function onCheckBoxJd(obj,checkIndex){
- //濡傛灉涓簍rue,閭d箞鍏朵粬鐨勬墍鏈夊閫夋蹇呴』涓轰笉閫夋嫨鐘舵��
- if(obj.checked){
- checkedTrue = checkIndex;
- var lawtable = document.getElementById("tableHeader_L");//鑾峰彇id涓簍ableHeader_L鐨則able
- var rows = lawtable.rows;//鑾峰彇鎵�鏈夎
- for(var i=1; i < rows.length; i++){
- var InputObj = rows[i].cells[0].getElementsByTagName("input")[0];
- if(obj != InputObj){
- InputObj.checked = false;
- }
- }
- }else{
- checkedTrue = null;
- }
- }
- function searchBtnJs(){
- b();
- var addressDataIds = '';
- //鏌ヨ鍦板潃
- if(document.getElementById('allPage:allForm:searchBlock:txtAddressId').value != ''){
- //鍙戦�乤ws璇锋眰锛岀劧鍚庡啀鍙戦�佺粰controller
- new Promise(function(resolve, reject){
- let queryBack = function queryBack(result){
- if(result.object==null || result.object.length==0){
- searchBtn('\''+addressName+'\'');
- return
+ }
+
+
+ return false;
+ }
+ //瑙e瘑
+ function decrypt(){
+ if(PIData[ObjIdDecrypt] == null){
+ // document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Contacts__c').value = '';
+ //document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:contactIdValue').value = '000000000000000';
+ document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ContactName__c').value = '';
+ document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Telephone__c').value = '';
+ document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c').value = '';
+ document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c').value = '';
+ }else{
+ // document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Contacts__c').value = PIData[ObjIdDecrypt].lastName!=null?PIData[ObjIdDecrypt].lastName:'';
+ document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ContactName__c').value = PIData[ObjIdDecrypt].lastName;
+ document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Telephone__c').value = PIData[ObjIdDecrypt].telephone;
+ document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c').value = PIData[ObjIdDecrypt].zipCode;
+ document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c').value = PIData[ObjIdDecrypt].detailedAddress;
+ }
+ }
+ function getPIPayload() {
+ let leadPayloadList = [];
+ var telePhone = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Telephone__c').value;
+ var zipCode = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c').value;
+ var detailedAddress = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c').value;
+ let leadPIData = new Object();
+ leadPIData.telePhone = telePhone;
+ leadPIData.zipCode = zipCode;
+ leadPIData.detailedAddress = detailedAddress;
+ leadPIData.sfRecordId = '';
+ leadPayloadList.push(leadPIData);
+ console.log(JSON.stringify(leadPayloadList));
+ return JSON.stringify(leadPayloadList);
+ }
+ //WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 start
+ //淇濆瓨鏂规硶
+ function savaJs(){
+ //b();
+ //涓嶄細鏂板缓鑱旂郴浜猴紝鎵�浠ヨ繖閲屼笉闇�瑕佸皢isAddCon璁剧疆涓簍rue
+ // if(document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ContactName__c').value != ''){
+ // isAddCon = true;
+ // }
+ document.getElementById("errorMsg").innerHTML = '';
+
+ if(!document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ContactName__c").value){
+ document.getElementById("errorMsg").innerHTML = '<strong>銆愯仈绯讳汉銆戜笉鑳戒负绌猴紒</strong> ';
+ return;
+ }
+ // else if(document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Contacts__c").value&&document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c").value){
+ // document.getElementById("errorMsg").innerHTML = '<strong>銆愯仈绯讳汉銆戝拰銆愯仈绯讳汉锛堟柊寤猴級銆戜笉鑳藉悓鏃舵湁鍊硷紒</strong> ';
+ // return;
+ // }
+ b();
+ console.log('{!insUpdData}')
+ // if(document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Create_Contacts__c").value){
+ // //new contact
+ // ProcessPI({},GetEditObj('contact'),'contact',function(){
+ // //new address
+ // ProcessPI({},
+ // GetEditObj('address'),'address',function(){
+ // save();
+ // });
+ // });
+ // }else{
+ //new address
+ ProcessPI({},GetEditObj('address'),'address',function(){
+ save();
+ });
+ // }
+ }
+ //WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 end
+
+ function ProcessPI(sobjJson, payloadForNewPI,type,callback) {
+ var sr = ''
+ // if(type == 'contact'){
+ // sr = staticResourceContact
+ // }
+ if(type == 'address'){
+ sr = staticResource
+ }
+ let url = sr.newUrl
+ /*if (now_edit_id) {
+ url = sr.updateUrl
+ }*/
+ AWSService.post(url, payloadForNewPI, function(result){
+ // if(type == 'contact'){
+ // con_aws_result = result
+ // }
+ if(type == 'address'){
+ add_aws_result = result
+ }
+ SetEditObj(type);
+ if(callback){
+ callback();
+ }
+ }, sr.token);
+ }
+ function SetEditObj(type){
+ let obj = GetAWSResultObj(type);
+ if(obj){
+ // if(type=='contact'){
+ // document.getElementById("allPage:allForm:oppBlock2:Con_AWS_Data_Id__c").value = obj.dataId;
+ // document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ContactName__c").value = obj.lastName;
+ // document.getElementById("allPage:allForm:oppBlock2:LastName_Encrypted__c").value = obj.lastNameEncrypt;
+ // }
+ if(type=='address'){
+ document.getElementById("allPage:allForm:oppBlock2:Add_AWS_Data_Id__c").value = obj.dataId;
+ document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:ContactName__c').value = obj.contactName;
+ //document.getElementById('allPage:allForm:oppBlock2:ContactName_Encrypted__c').value = obj.contactNameEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-05
+ document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Telephone__c").value = obj.telephone;
+ //document.getElementById("allPage:allForm:oppBlock2:Telephone_Encrypted__c").value = obj.telephoneEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-05
+ document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c").value = obj.zipCode;
+ //document.getElementById("allPage:allForm:oppBlock2:ZipCode_Encrypted__c").value = obj.zipCodeEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-05
+ document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c").value = obj.detailedAddress;
+ //document.getElementById("allPage:allForm:oppBlock2:Detailed_Address_Encrypted__c").value = obj.detailedAddressEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-05
+
+ }
+ }
+
+ }
+ function GetAWSResultObj(type){
+ // if(type == 'contact'){
+ // if(con_aws_result && con_aws_result.object && con_aws_result.object.length > 0){
+ // return con_aws_result.object[0];
+ // }
+ // }
+ if(type == 'address'){
+ if(add_aws_result && add_aws_result.object && add_aws_result.object.length > 0){
+ return add_aws_result.object[0];
+ }
+ }
+ return null;
+ }
+
+ function GetEditObj(type){
+ // if(type=='contact'){
+ // //new contact
+ // return JSON.stringify([{
+ // lastName : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ContactName__c").value,
+ // dataId : document.getElementById("allPage:allForm:oppBlock2:Con_AWS_Data_Id__c").value,
+ // }]);
+ // }
+ contactNamePlaintext = document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ContactName__c").value;
+ telePhonePlaintext = document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Telephone__c").value;
+ zipCodePlaintext = document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c").value
+ detailedAddressPlaintext = document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c").value;
+ if(type == 'address'){
+ //new address
+ return JSON.stringify([{
+ dataId : document.getElementById("allPage:allForm:oppBlock2:Add_AWS_Data_Id__c").value,
+ contactName : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ContactName__c").value,
+ telephone : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Telephone__c").value,
+ zipCode : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:ZipCode__c").value,
+ detailedAddress : document.getElementById("allPage:allForm:oppBlock2:UpdAddressId:Detailed_Address__c").value,
+ }]);
+ }
+
+ }
+
+ //澶嶉�夋閫変腑瑙﹀彂浜嬩欢
+ //obj 褰撳墠瀵硅薄 checkIndex 褰撳墠鐐瑰嚮鐨勭鍑犺
+ function onCheckBoxJd(obj,checkIndex){
+ //濡傛灉涓簍rue,閭d箞鍏朵粬鐨勬墍鏈夊閫夋蹇呴』涓轰笉閫夋嫨鐘舵��
+ if(obj.checked){
+ checkedTrue = checkIndex;
+ var lawtable = document.getElementById("tableHeader_L");//鑾峰彇id涓簍ableHeader_L鐨則able
+ var rows = lawtable.rows;//鑾峰彇鎵�鏈夎
+ for(var i=1; i < rows.length; i++){
+ var InputObj = rows[i].cells[0].getElementsByTagName("input")[0];
+ if(obj != InputObj){
+ InputObj.checked = false;
+ }
+ }
+ }else{
+ checkedTrue = null;
+ }
+ }
+ function searchBtnJs(){
+ b();
+ var addressDataIds = '';
+ //鏌ヨ鍦板潃
+ if(document.getElementById('allPage:allForm:searchBlock:txtAddressId').value != ''){
+ //鍙戦�乤ws璇锋眰锛岀劧鍚庡啀鍙戦�佺粰controller
+ new Promise(function(resolve, reject){
+ let queryBack = function queryBack(result){
+ if(result.object==null || result.object.length==0){
+ searchBtn('\''+addressName+'\'');
+ return
+ }else{
+
+ for(var i=0;i<result.object.length;i++){
+ addressDataIds += ',\''+ result.object[i].dataId + '\'';
+ addressAwsData[result.object[i].dataId] = result.object[i];
+ }
+ addressDataIds = addressDataIds.substring(1);
+ resolve('success');
+ }
+ };
+ var addressName = document.getElementById('allPage:allForm:searchBlock:txtAddressId').value;
+ AWSService.post(staticResource.searchUrl,{
+ detailedAddress:addressName.trim()
+ },queryBack,staticResource.token);
+ }).then(function(data){
+ console.log('data = '+data)
+ console.log('addressDataIds = '+addressDataIds)
+ searchBtn(addressDataIds);
+ });
+ }else{
+ searchBtn(addressDataIds);
+ }
+ }
+ //鍔犲瘑瀹㈡埛鍚嶅瓧娈�
+ // function encryptCustomer(e){
+ // let obj = JSON.parse(payloadForNewPI);
+ // let payloadForNewPIJson = JSON.stringify(obj);
+ // let payloadForNewPI = jQuery(e.target).closest("tr").find("a.cusmer__c");
+ // AWSService.update(staticResources.updateUrl, '', payloadForNewPI, updateMethod, staticResources.token, staticResources.transactionUrl, false, insertOrUpdateBack, redirectCallBack);
+ // },
+
+ sforce.connection.sessionId = '{!GETSESSIONID()}';
+ function UpdateSobject(staticResource,sobj,transId,callback){
+
+ let result = sforce.connection.update([sobj]);
+ let tobj = {
+ txId: transId
+ };
+ let b = result[0].getBoolean('success');
+ if(b) {
+ console.log('call sf Log Id: ' + result[0].id);
+ tobj.sfRecordId = result[0].id;
+ tobj.isSuccess = 1;
+
+ //return result[0].id;
+ }else {
+ console.log('call sf to insert log');
+ tobj.isSuccess = 0;
+ //return '';
+ }
+
+ AWSService.post(staticResource.transactionUrl,tobj,function(data){
+ if (callback) {
+ data.isSuccess = b;
+ callback(data)
+ }
+ },staticResource.token);
+ }
+
+
+
+ function adoptSaveJs(address,isUpload){
+ //鐢变簬瑕佹妸閲囩敤鏃堕棿璁板綍鍒板湴鍧�琛ㄤ腑锛屾墍浠ユ柊寤轰竴涓湴鍧�瀵硅薄
+ // Address__c DatetimeUpdate = new Address__c();
+ // DatetimeUpdate = tableData[i].address;
+ //璇︾粏鍦板潃
+ let address_str = address.Detailed_Address__c.trim();
+ if (addressAwsData.hasOwnProperty(address.AWS_Data_Id__c)) {
+ address_str = addressAwsData[address.AWS_Data_Id__c].detailedAddress;
+ }
+ let cityName = '';//甯�
+ //甯備笉涓虹┖锛屽洜涓鸿浣跨敤 __r.Name 濡傛灉涓虹┖锛屼細鎶ラ敊
+ if(address.City__c){
+ cityName = address.City__r.Name.trim();
+ //鐪� 鍚屼笂
+ if(address.Province__c){
+ let ProvinceCity = address.Province__r.Name.trim()+cityName;
+ //闃叉璇︾粏鍦板潃閲岄潰甯︾潃鐪佷唤鍜屽競
+ if(address_str.indexOf(ProvinceCity) < 0){
+ address_str = ProvinceCity + address_str;
+ }
+ }
+ }
+ //鑱旂郴浜�
+ let contactsName = '';
+ // WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 start
+ if(address.ContactName__c){
+ contactsName = address.ContactName__c;
+ }
+ // WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 end
+
+ // if (addressAwsData.hasOwnProperty(address.Contacts__r.AWS_Data_Id__c)) {
+ // contactsName = addressAwsData[address.Contacts__r.AWS_Data_Id__c].lastName;
+ // }
+ if(PIData[address.Id]){
+ contactsName = PIData[address.Id].lastName;
+ }
+
+ //瀹㈡埛
+ let ContactPerson = '';
+ if(address.Customer__c){
+ ContactPerson = address.Customer__r.Name;
+ }
+ try{
+ //淇濆瓨鏁版嵁鍒颁慨鐞嗚〃涓�
+ let rc = new sforce.SObject('Repair__c');
+ rc.Id='{!RepairId}';
+ rc.address_Contacts__c=contactsName;
+ rc.address_ZipCode__c = address.ZipCode__c;
+ rc.address_City__c = cityName;
+ rc.address_Contacts_Name__c = ContactPerson;
+ let AddressTypeIndex = {!AddressTypeIndex};
+ //isUpload锛氭槸鍚︿笂浼燬AP FSEApplyForRepairTime锛歋AP淇悊鐢宠鏃堕棿
+ if(isUpload && '{!pc.SAP_Transfer_time__c}'){
+ rc.Address_type__c = 'X';
+ rc.Address_Type_Index__c = AddressTypeIndex+1;
+ }
+ rc.address_Telephone__c=address.Telephone__c;
+ rc.Detailed_Address__c=address_str;
+
+ if (addressAwsData.hasOwnProperty(address.AWS_Data_Id__c)) {
+ rc.address_Telephone__c=addressAwsData[address.AWS_Data_Id__c].telephone;
+ rc.address_ZipCode__c=addressAwsData[address.AWS_Data_Id__c].zipCode;
+ }
+
+ let GetAsset = function(){
+ let ast = new sforce.SObject('Asset');
+ ast.Id = '{!pc.Delivered_Product__c}',
+ ast.address_Contacts__c= contactsName,
+ ast.address_ZipCode__c = address.ZipCode__c,
+ ast.address_City__c = cityName,
+ ast.address_Telephone__c = address.Telephone__c,
+ ast.address_Contacts_Name__c = ContactPerson,
+ ast.Detailed_Address__c= address_str
+ if (addressAwsData.hasOwnProperty(address.AWS_Data_Id__c)) {
+ ast.address_ZipCode__c=addressAwsData[address.AWS_Data_Id__c].zipCode;
+ ast.address_Telephone__c=addressAwsData[address.AWS_Data_Id__c].telephone;
+ }
+ return ast;
+ }
+
+ //淇濆瓨鏁版嵁鍒颁繚鏈夎澶囪〃涓�
+ let UpdateAsset = function(){
+ let ast = GetAsset();
+ let result = sforce.connection.update([ast]);
+ let b = result[0].getBoolean('success');
+ return b;
+ }
+
+ let UpdateRepair = function(callback){
+ AWSService.post(staticResourceRepair.updateUrl+'V2',[{
+ dataId:'{!pc.AWS_Data_Id__c}',
+ addressContactsName:rc.address_Contacts_Name__c,
+ addressContacts:rc.address_Contacts__c,
+ addressTelephone:rc.address_Telephone__c,
+ addressZipCode:rc.address_ZipCode__c,
+ detailedAddress:rc.Detailed_Address__c
+ }],function(data){
+ if(data && data.object){
+ console.log(data);
+ rc.address_Contacts_Name__c = data.object[0].addressContactsName;
+ //rc.Address_Contacts_Name_Encrypt__c = data.object[0].addressContactsNameEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-29
+ rc.address_Contacts__c = data.object[0].addressContacts;
+ //rc.Address_Contacts_Encrypt__c = data.object[0].addressContactsEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-29
+ rc.address_Telephone__c = data.object[0].addressTelephone;
+ //rc.Address_Telephone_Encrypt__c = data.object[0].addressTelephoneEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-29
+ rc.address_ZipCode__c = data.object[0].addressZipCode;
+ //rc.Address_ZipCode_Encrypt__c = data.object[0].addressZipCodeEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-29
+ rc.Detailed_Address__c = data.object[0].detailedAddress;
+ //rc.Detailed_Address_Encrypt__c = data.object[0].detailedAddressEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-29
+
+ //UpdateSobject(staticResourceRepair,rc,data.txId,callback);
+ Visualforce.remoting.Manager.invokeAction(
+ 'StraightBackAddressController.SaveEx',
+ JSON.stringify(rc), JSON.stringify(GetAsset()), address.Id,
+ function (result, event) {
+
+ let message = '';
+ if (event.status) {
+ if (result) {
+ message = result;
+ }else{
+ }
+ }else{
+ }
+ let tobj = {
+ txId: data.txId
+ };
+ if(message) {
+ console.log('call sf to insert log');
+ tobj.isSuccess = 0;
+ }else {
+ console.log('call sf Log Id: ' + rc.id);
+ tobj.sfRecordId = rc.id;
+ tobj.isSuccess = 1;
+ }
+
+ AWSService.post(staticResource.transactionUrl,tobj,function(data){
+ if (message) {
+ ub();
+ alert(message);
+ }else{
+ window.location.href = '/{!RepairId}';
+ }
+ },staticResource.token);
+ },
+ { escape: true }
+ );
+ }else{
+ alert('AWS鏇存柊淇悊澶辫触');
+ ub();
+ }
+ },staticResourceRepair.token)
+ }
+
+
+
+
+ let UpdateAddress = function(){
+ let add = new sforce.SObject('Address__c');
+ add.Id = address.Id;
+ //鏈�鍚庢妸褰撳墠鏃堕棿淇濆瓨鍒板湴鍧�琛ㄤ腑锛屼綔涓洪噰鐢ㄦ椂闂�
+ add.Using_Datetime__c = new Date();
+ let result = sforce.connection.update([add]);
+ let b = result[0].getBoolean('success');
+ return b;
+ }
+
+ b();
+ UpdateRepair();
+ /*
+ UpdateRepair(function(data){
+ if (data.isSuccess) {
+ let b = UpdateAsset();
+ if (b) {
+ b = UpdateAddress();
+ if (b) {
+ window.location.href = '/{!RepairId}';
}else{
-
- for(var i=0;i<result.object.length;i++){
- addressDataIds += ',\''+ result.object[i].dataId + '\'';
- addressAwsData[result.object[i].dataId] = result.object[i];
- }
- addressDataIds = addressDataIds.substring(1);
- resolve('success');
- }
- };
- var addressName = document.getElementById('allPage:allForm:searchBlock:txtAddressId').value;
- AWSService.post(staticResource.searchUrl,{
- detailedAddress:addressName.trim()
- },queryBack,staticResource.token);
- }).then(function(data){
- console.log('data = '+data)
- console.log('addressDataIds = '+addressDataIds)
- searchBtn(addressDataIds);
- });
- }else{
- searchBtn(addressDataIds);
- }
- }
- //鍔犲瘑瀹㈡埛鍚嶅瓧娈�
- // function encryptCustomer(e){
- // let obj = JSON.parse(payloadForNewPI);
- // let payloadForNewPIJson = JSON.stringify(obj);
- // let payloadForNewPI = jQuery(e.target).closest("tr").find("a.cusmer__c");
- // AWSService.update(staticResources.updateUrl, '', payloadForNewPI, updateMethod, staticResources.token, staticResources.transactionUrl, false, insertOrUpdateBack, redirectCallBack);
- // },
-
- sforce.connection.sessionId = '{!GETSESSIONID()}';
- function UpdateSobject(staticResource,sobj,transId,callback){
-
- let result = sforce.connection.update([sobj]);
- let tobj = {
- txId: transId
- };
- let b = result[0].getBoolean('success');
- if(b) {
- console.log('call sf Log Id: ' + result[0].id);
- tobj.sfRecordId = result[0].id;
- tobj.isSuccess = 1;
-
- //return result[0].id;
- }else {
- console.log('call sf to insert log');
- tobj.isSuccess = 0;
- //return '';
- }
-
- AWSService.post(staticResource.transactionUrl,tobj,function(data){
- if (callback) {
- data.isSuccess = b;
- callback(data)
- }
- },staticResource.token);
- }
-
-
-
- function adoptSaveJs(address,isUpload){
- //鐢变簬瑕佹妸閲囩敤鏃堕棿璁板綍鍒板湴鍧�琛ㄤ腑锛屾墍浠ユ柊寤轰竴涓湴鍧�瀵硅薄
- // Address__c DatetimeUpdate = new Address__c();
- // DatetimeUpdate = tableData[i].address;
- //璇︾粏鍦板潃
- let address_str = address.Detailed_Address__c.trim();
- if (addressAwsData.hasOwnProperty(address.AWS_Data_Id__c)) {
- address_str = addressAwsData[address.AWS_Data_Id__c].detailedAddress;
- }
- let cityName = '';//甯�
- //甯備笉涓虹┖锛屽洜涓鸿浣跨敤 __r.Name 濡傛灉涓虹┖锛屼細鎶ラ敊
- if(address.City__c){
- cityName = address.City__r.Name.trim();
- //鐪� 鍚屼笂
- if(address.Province__c){
- let ProvinceCity = address.Province__r.Name.trim()+cityName;
- //闃叉璇︾粏鍦板潃閲岄潰甯︾潃鐪佷唤鍜屽競
- if(address_str.indexOf(ProvinceCity) < 0){
- address_str = ProvinceCity + address_str;
- }
- }
- }
- //鑱旂郴浜�
- let contactsName = '';
- // WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 start
- if(address.ContactName__c){
- contactsName = address.ContactName__c;
- }
- // WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 end
-
- // if (addressAwsData.hasOwnProperty(address.Contacts__r.AWS_Data_Id__c)) {
- // contactsName = addressAwsData[address.Contacts__r.AWS_Data_Id__c].lastName;
- // }
- if(PIData[address.Id]){
- contactsName = PIData[address.Id].lastName;
- }
-
- //瀹㈡埛
- let ContactPerson = '';
- if(address.Customer__c){
- ContactPerson = address.Customer__r.Name;
- }
- try{
- //淇濆瓨鏁版嵁鍒颁慨鐞嗚〃涓�
- let rc = new sforce.SObject('Repair__c');
- rc.Id='{!RepairId}';
- rc.address_Contacts__c=contactsName;
- debugger
- rc.address_ZipCode__c = address.ZipCode__c;
- rc.address_City__c = cityName;
- rc.address_Contacts_Name__c = ContactPerson;
- let AddressTypeIndex = {!AddressTypeIndex};
- //isUpload锛氭槸鍚︿笂浼燬AP FSEApplyForRepairTime锛歋AP淇悊鐢宠鏃堕棿
- if(isUpload && '{!pc.SAP_Transfer_time__c}'){
- rc.Address_type__c = 'X';
- rc.Address_Type_Index__c = AddressTypeIndex+1;
- }
- rc.address_Telephone__c=address.Telephone__c;
- rc.Detailed_Address__c=address_str;
-
- if (addressAwsData.hasOwnProperty(address.AWS_Data_Id__c)) {
- rc.address_Telephone__c=addressAwsData[address.AWS_Data_Id__c].telephone;
- rc.address_ZipCode__c=addressAwsData[address.AWS_Data_Id__c].zipCode;
- }
-
- let GetAsset = function(){
- let ast = new sforce.SObject('Asset');
- ast.Id = '{!pc.Delivered_Product__c}',
- ast.address_Contacts__c= contactsName,
- ast.address_ZipCode__c = address.ZipCode__c,
- ast.address_City__c = cityName,
- ast.address_Telephone__c = address.Telephone__c,
- ast.address_Contacts_Name__c = ContactPerson,
- ast.Detailed_Address__c= address_str
- if (addressAwsData.hasOwnProperty(address.AWS_Data_Id__c)) {
- ast.address_ZipCode__c=addressAwsData[address.AWS_Data_Id__c].zipCode;
- ast.address_Telephone__c=addressAwsData[address.AWS_Data_Id__c].telephone;
- }
- return ast;
- }
-
- //淇濆瓨鏁版嵁鍒颁繚鏈夎澶囪〃涓�
- let UpdateAsset = function(){
- let ast = GetAsset();
- let result = sforce.connection.update([ast]);
- let b = result[0].getBoolean('success');
- return b;
- }
-
- let UpdateRepair = function(callback){
- AWSService.post(staticResourceRepair.updateUrl+'V2',[{
- dataId:'{!pc.AWS_Data_Id__c}',
- addressContactsName:rc.address_Contacts_Name__c,
- addressContacts:rc.address_Contacts__c,
- addressTelephone:rc.address_Telephone__c,
- addressZipCode:rc.address_ZipCode__c,
- detailedAddress:rc.Detailed_Address__c
- }],function(data){
- if(data && data.object){
- console.log(data);
- rc.address_Contacts_Name__c = data.object[0].addressContactsName;
- //rc.Address_Contacts_Name_Encrypt__c = data.object[0].addressContactsNameEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-29
- rc.address_Contacts__c = data.object[0].addressContacts;
- //rc.Address_Contacts_Encrypt__c = data.object[0].addressContactsEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-29
- rc.address_Telephone__c = data.object[0].addressTelephone;
- //rc.Address_Telephone_Encrypt__c = data.object[0].addressTelephoneEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-29
- rc.address_ZipCode__c = data.object[0].addressZipCode;
- //rc.Address_ZipCode_Encrypt__c = data.object[0].addressZipCodeEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-29
- rc.Detailed_Address__c = data.object[0].detailedAddress;
- //rc.Detailed_Address_Encrypt__c = data.object[0].detailedAddressEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-29
-
- //UpdateSobject(staticResourceRepair,rc,data.txId,callback);
- Visualforce.remoting.Manager.invokeAction(
- 'StraightBackAddressController.SaveEx',
- JSON.stringify(rc), JSON.stringify(GetAsset()), address.Id,
- function (result, event) {
-
- let message = '';
- if (event.status) {
- if (result) {
- message = result;
- }else{
- }
- }else{
- }
- let tobj = {
- txId: data.txId
- };
- if(message) {
- console.log('call sf to insert log');
- tobj.isSuccess = 0;
- }else {
- console.log('call sf Log Id: ' + rc.id);
- tobj.sfRecordId = rc.id;
- tobj.isSuccess = 1;
- }
-
- AWSService.post(staticResource.transactionUrl,tobj,function(data){
- if (message) {
- ub();
- alert(message);
- }else{
- window.location.href = '/{!RepairId}';
- }
- },staticResource.token);
- },
- { escape: true }
- );
- }else{
- alert('AWS鏇存柊淇悊澶辫触');
- ub();
- }
- },staticResourceRepair.token)
- }
-
-
-
-
- let UpdateAddress = function(){
- let add = new sforce.SObject('Address__c');
- add.Id = address.Id;
- //鏈�鍚庢妸褰撳墠鏃堕棿淇濆瓨鍒板湴鍧�琛ㄤ腑锛屼綔涓洪噰鐢ㄦ椂闂�
- add.Using_Datetime__c = new Date();
- let result = sforce.connection.update([add]);
- let b = result[0].getBoolean('success');
- return b;
- }
-
- b();
- UpdateRepair();
- /*
- UpdateRepair(function(data){
- if (data.isSuccess) {
- let b = UpdateAsset();
- if (b) {
- b = UpdateAddress();
- if (b) {
- window.location.href = '/{!RepairId}';
- }else{
- ub();
- alert('閲囩敤澶辫触');
- }
- }else{
- ub();
- alert('閲囩敤澶辫触');
- }
- }else{
-
- ub();
- alert('SF鏇存柊淇悊澶辫触');
- }
- })*/
-
- //椤甸潰閲嶅畾鍚�
- //return redirectPag();
- }catch( e){
- //澶辫触鎻愮ず
- //ApexPages.addMessages(e);
- }
- }
- //閲囩敤鎸夐挳
- function onAdoptJs(e, address){
-
- //鍒ゆ柇褰撳墠淇悊鍗曟槸鍚﹀凡缁忕敵璇蜂慨鐞�
- var uploadTime = '{!FSEApplyForRepairTime}';
- if(uploadTime != 'null' && uploadTime){
- var prompt = '鐢变簬褰撳墠淇悊鍗曞凡鐢宠淇悊锛岃闂槸鍚﹂噰鐢ㄥ苟涓婁紶鏁版嵁鍒癝AP锛�';
- if(confirm(prompt)){
- adoptSaveJs(address,true);
- }
- }else{
- adoptSaveJs(address,false);
- }
-
- }
- /* function onAdoptJs(){
- if(checkedTrue != null){
- b();
- var lawtable = document.getElementById("tableHeader_L");//鑾峰彇id涓簍ableHeader_L鐨則able
- var rows = lawtable.rows;//鑾峰彇鎵�鏈夎
- var InputObj = rows[checkedTrue].cells[0].getElementsByTagName("input")[0];
- if(InputObj.checked){
- //鍒ゆ柇褰撳墠淇悊鍗曟槸鍚﹀凡缁忕敵璇蜂慨鐞�
- var uploadTime = '{!FSEApplyForRepairTime}';
- if(uploadTime != null){
- var prompt = '鐢变簬褰撳墠淇悊鍗曞凡鐢宠淇悊锛岃闂槸鍚﹂噰鐢ㄥ苟涓婁紶鏁版嵁鍒癝AP锛�';
- if(confirm(prompt)){
- adoptSave(InputObj.value+"",true);
- }else{
- adoptSave(InputObj.value+"",false);
+ ub();
+ alert('閲囩敤澶辫触');
}
}else{
- adoptSave(InputObj.value+"",false);
- }
- }
- }else{
- alert('璇烽�変腑浣犺閲囩敤鐨勫湴鍧�锛�');
- return false;
- }
- }*/
- //杩斿洖鐖堕〉闈�
- function sendBackJs(){
- redirectPag();
- }
- //鍒锋柊褰撳墠椤甸潰
- function refreshJs(){
- window.location.reload();
- }
-
- //2022 02 28 寮犲崕寤� display PI Data start
-
- //queryPI();
- function q1(){
- debugger
- var index = 0;
- var correct = 0;
- var p = new Promise(function(resolve, reject){
- //鏌ヨ鍦板潃鐨凱I鏁版嵁
- let searchCallBack = function searchCallBack(result,Id,awsDataId){
- index++;
- let contacts = result.object;
- if(contacts == null){
- console.log('contacts == null')
- return;
- }
- let temp = {}
- temp.telephone = result.object.telephone;
- temp.zipCode = result.object.zipCode;
- temp.detailedAddress = result.object.detailedAddress;
- //temp.awsDataId = awsDataId;
- temp.lastName = result.object.contactName;
- PIData[Id] = temp;
- };
- for(var i=0;i<tableDataStr.length;i++){
- if(tableDataStr[i].address.AWS_Data_Id__c){
- correct++;
- AWSService.queryRepair(staticResource.queryUrl,
- tableDataStr[i].address.AWS_Data_Id__c,
- tableDataStr[i].address.Id,
- //tableDataStr[i].address.Contacts__r.AWS_Data_Id__c,
- null,
- searchCallBack,
- staticResource.token);
- }
- }
- var interval=self.setInterval(function (){
- console.log('setInterval index= ' + index);
- if(index == correct){
- console.log('PIDATA = ' + JSON.stringify(PIData))
- resolve('success')
- clearInterval(interval)
- }
- },1000);
- });
- return p;
- }
-
- //zhj PIPL 2022-06-08 start
- function q2(){
- // sforce.connection.sessionId = '{!GETSESSIONID()}';
- // var p = new Promise(function(resolve, reject){
- // //鏌ヨ鑱旂郴浜虹殑鏁版嵁
- // let queryBack = function queryBack(result) {
- // let contacts = result.object;
- // if(contacts == null){
- // return;
- // }
- // for(var i=0;i<result.object.length;i++){
- // for(let key in PIData){
- // if(result.object[i].dataId == PIData[key].awsDataId){
- // PIData[key].lastName = result.object[i].lastName;
- // }
- // }
- // }
- // }
- // var condition = ''
- // for(var i=0;i<tableDataStr.length;i++){
- // if(tableDataStr[i].address.Contacts__c){
- // condition += "," + "\'"+tableDataStr[i].address.Contacts__c+"\'";
- // }
- // }
- // condition = condition.substr(1);
- // console.log('condition = ' + condition);
- // var record = sforce.connection.query("select AWS_Data_Id__c from Contact where id in("+condition+")");
- // var records = record.getArray("records");
- // for(var i =0;i<records.length;i++){
- // if(records[i].AWS_Data_Id__c){
- // contactDataIds.push(records[i].AWS_Data_Id__c);
- // }
- // }
- // let searchPayload = new Object();
- // searchPayload.dataIds = contactDataIds;
- // searchPayload.contactName = '';
- // console.log('contactDataIds = ' + contactDataIds);
- // AWSService.search(staticResourceContact.searchUrl, JSON.stringify(searchPayload), queryBack, staticResourceContact.token);
- // });
- }
-
- //zhj PIPL 2022-06-08 end
-
-
- //鏌ヨ鏁忔劅瀛楁
- function queryPI(){
- //b();
- tableDataStr = JSON.parse(document.getElementById('allPage:allForm:tableValueFrontEnd').value);
- PIData = {};
- contactDataIds = [];
- console.log(tableDataStr)
- q1().then(function(data){
- return q2(data);
- })
- //ub();
- }
-
-
- function showPIDiv(awsDataId){
- if(awsDataId.length == 0 || PIData[awsDataId]==null){
- return
- }
- console.log('awsDataId Value:'+awsDataId);
- let parentNode = document.getElementById(awsDataId);
- let createDiv = document.createElement("div");
- createDiv.id = awsDataId+"_PI";
- let piInformation = '';
-
- if(PIData[awsDataId].lastName){
- piInformation = '鑱旂郴浜�: '+PIData[awsDataId].lastName+
- '\n鐢佃瘽: '+PIData[awsDataId].telephone+
- '\n閭紪: '+PIData[awsDataId].zipCode+
- '\n璇︾粏鍦板潃: '+PIData[awsDataId].detailedAddress
- }else{
- piInformation = '鑱旂郴浜�: null'+
- '\n鐢佃瘽: '+PIData[awsDataId].telephone+
- '\n閭紪: '+PIData[awsDataId].zipCode+
- '\n璇︾粏鍦板潃: '+PIData[awsDataId].detailedAddress
- }
- //let piInformation = 'Name:'+contact['943114607025717249'].lastName +'\n' +'Phone:'+contact['943114607025717249'].phone
- createDiv.innerText = piInformation;
- let x=window.event.x;
- let y=window.event.y;
- createDiv.style.left=x;
- createDiv.style.top=y;
- createDiv.style.height='100px';
- createDiv.style.width='120px';
- createDiv.style.background="#dddddd";
- createDiv.style.position = "absolute";
- parentNode.appendChild(createDiv);
- parentNode.style.position = "relative";
- }
-
- function hidePIDiv(awsDataId){
- if(awsDataId.length == 0 || PIData[awsDataId]==null){
- return
- }
- document.getElementById(awsDataId+'_PI').remove();
- }
-
- // function replaceSearchContactLookup() {
- // if(document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Contacts__c') != null){
- // let contactHtmlString = '<img src="/img/s.gif" onclick="searchContact(\'allPage:allForm:contactId\',\'allPage:allForm:oppBlock2:UpdAddressId:Contacts__c\')" alt="Reference Document Number Lookup" class="lookupIcon" title="Reference Document Number Lookup (New Window)"/>';
- // let lookUpNode = htmlToElement(contactHtmlString);
- // console.log(lookUpNode);
- // let parentNode = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Contacts__c').parentNode;
- // parentNode.appendChild(lookUpNode);
- // if(contactInfoStr){
- // console.log('closePopup:'+contactInfoStr);
- // let contactInfo = JSON.parse(contactInfoStr);
- // let contactNodeId = 'allPage:allForm:oppBlock2:UpdAddressId:contactIdValue';
- // document.getElementById(contactNodeId).value = contactInfo.ContactId;
- // document.getElementById(closeField).value = contactInfo.Name;
- // }
- // }
- // }
-
- function htmlToElement(html) {
- var template = document.createElement('template');
- html = html.trim(); // Never return a text node of whitespace as the result
- template.innerHTML = html;
- return template.content.firstChild;
- }
-
- //鑷畾涔塴ookup鏌ヨ
- // function searchContact(contactNodeId,field){
- // closeField = field;
- // let accountValue = "";
- // if (document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Customer__r_Name')!=null) {
- // let accountNodeId = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Customer__r_Name').id + '_lkid';
- // accountValue = document.getElementById(accountNodeId).value;
- // }
- // console.log(accountValue);
- // if(accountValue !='000000000000000'){
- // let baseUrl = "/apex/SearchContactPage";
- // let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue;
- // let newSearchContactParam = 'height=600,width=800,left=100,top=100,dialogHide=true,resizable=no,scrollbars=yes,toolbar=no,status=no';
- // newSearchContactWindow = window.open(baseUrl+suffixUrl, 'Popup', newSearchContactParam);
- // if (window.focus) {
- // newSearchContactWindow.focus();
- // }
- // return false;
- // }else{
- // console.log('璇峰厛閫夋嫨瀹㈡埛鍐嶉�夋嫨鑱旂郴浜�')
- // }
- // }
-
- function closePopupWindow() {
- if (null != newSearchContactWindow) {
- newSearchContactWindow.close();
- }
- contactInfoStr = document.getElementById('allPage:allForm:contactId').value;
- console.log('closePopup:'+contactInfoStr);
- let contactInfo = JSON.parse(contactInfoStr);
- let contactNodeId = 'allPage:allForm:oppBlock2:UpdAddressId:contactIdValue';
- document.getElementById(contactNodeId).value = contactInfo.ContactId;
- document.getElementById(closeField).value = contactInfo.Name;
- }
- //2022 02 28 寮犲崕寤� display PI Data end
- </script>
- <script type="text/javascript">
-
- function DecryptAddress(){
- debugger
- let arr1 = [];let a1=false;
- let arr2 = [];let a2=false;
- j$('td.oraddress').each(function(i,e){
- let did = j$(e).attr('address-data-id');
- if (did) {
- arr1.push(did);
- }
-
- did = j$(e).attr('contact-data-id');
- if (did) {
- arr2.push(did);
- }
- })
-
- if (arr1.length) {
- b();
- AWSService.post(staticResource.searchUrl,{
- dataIds:arr1
- },function(data){
- ub();
- if(data && data.object && data.object.length > 0){
- for (let di in data.object) {
- if (data.object[di] && data.object[di].dataId) {
- addressAwsData[data.object[di].dataId] = data.object[di];
- }
+ ub();
+ alert('閲囩敤澶辫触');
}
-
- }
- },staticResource.token)
- }
+ }else{
- if (arr2.length) {
- b();
- AWSService.post(staticResourceContact.searchUrl,{
- dataIds:arr2
- },function(data){
- ub();
- if(data && data.object && data.object.length > 0){
- for (let di in data.object) {
- if (data.object[di] && data.object[di].dataId) {
- addressAwsData[data.object[di].dataId] = data.object[di];
- }
- }
-
- }
- },staticResourceContact.token)
- }
+ ub();
+ alert('SF鏇存柊淇悊澶辫触');
+ }
+ })*/
+
+ //椤甸潰閲嶅畾鍚�
+ //return redirectPag();
+ }catch( e){
+ //澶辫触鎻愮ず
+ //ApexPages.addMessages(e);
+ }
+ }
+ //閲囩敤鎸夐挳
+ function onAdoptJs(e, address){
+
+ //鍒ゆ柇褰撳墠淇悊鍗曟槸鍚﹀凡缁忕敵璇蜂慨鐞�
+ var uploadTime = '{!FSEApplyForRepairTime}';
+ if(uploadTime != 'null' && uploadTime){
+ var prompt = '鐢变簬褰撳墠淇悊鍗曞凡鐢宠淇悊锛岃闂槸鍚﹂噰鐢ㄥ苟涓婁紶鏁版嵁鍒癝AP锛�';
+ if(confirm(prompt)){
+ adoptSaveJs(address,true);
+ }
+ }else{
+ adoptSaveJs(address,false);
+ }
+
+ }
+ /* function onAdoptJs(){
+ if(checkedTrue != null){
+ b();
+ var lawtable = document.getElementById("tableHeader_L");//鑾峰彇id涓簍ableHeader_L鐨則able
+ var rows = lawtable.rows;//鑾峰彇鎵�鏈夎
+ var InputObj = rows[checkedTrue].cells[0].getElementsByTagName("input")[0];
+ if(InputObj.checked){
+ //鍒ゆ柇褰撳墠淇悊鍗曟槸鍚﹀凡缁忕敵璇蜂慨鐞�
+ var uploadTime = '{!FSEApplyForRepairTime}';
+ if(uploadTime != null){
+ var prompt = '鐢变簬褰撳墠淇悊鍗曞凡鐢宠淇悊锛岃闂槸鍚﹂噰鐢ㄥ苟涓婁紶鏁版嵁鍒癝AP锛�';
+ if(confirm(prompt)){
+ adoptSave(InputObj.value+"",true);
+ }else{
+ adoptSave(InputObj.value+"",false);
+ }
+ }else{
+ adoptSave(InputObj.value+"",false);
+ }
+ }
+ }else{
+ alert('璇烽�変腑浣犺閲囩敤鐨勫湴鍧�锛�');
+ return false;
+ }
+ }*/
+ //杩斿洖鐖堕〉闈�
+ function sendBackJs(){
+ redirectPag();
+ }
+ //鍒锋柊褰撳墠椤甸潰
+ function refreshJs(){
+ window.location.reload();
+ }
+
+ //2022 02 28 寮犲崕寤� display PI Data start
+
+ //queryPI();
+ function q1(){
+ debugger
+ var index = 0;
+ var correct = 0;
+ var p = new Promise(function(resolve, reject){
+ //鏌ヨ鍦板潃鐨凱I鏁版嵁
+ let searchCallBack = function searchCallBack(result,Id,awsDataId){
+ index++;
+ let contacts = result.object;
+ if(contacts == null){
+ console.log('contacts == null')
+ return;
+ }
+ let temp = {}
+ temp.telephone = result.object.telephone;
+ temp.zipCode = result.object.zipCode;
+ temp.detailedAddress = result.object.detailedAddress;
+ //temp.awsDataId = awsDataId;
+ temp.lastName = result.object.contactName;
+ PIData[Id] = temp;
+ };
+ for(var i=0;i<tableDataStr.length;i++){
+ if(tableDataStr[i].address.AWS_Data_Id__c){
+ correct++;
+ AWSService.queryRepair(staticResource.queryUrl,
+ tableDataStr[i].address.AWS_Data_Id__c,
+ tableDataStr[i].address.Id,
+ //tableDataStr[i].address.Contacts__r.AWS_Data_Id__c,
+ null,
+ searchCallBack,
+ staticResource.token);
+ }
+ }
+ var interval=self.setInterval(function (){
+ console.log('setInterval index= ' + index);
+ if(index == correct){
+ console.log('PIDATA = ' + JSON.stringify(PIData))
+ resolve('success')
+ clearInterval(interval)
+ }
+ },1000);
+ });
+ return p;
+ }
+
+ //zhj PIPL 2022-06-08 start
+ function q2(){
+ // sforce.connection.sessionId = '{!GETSESSIONID()}';
+ // var p = new Promise(function(resolve, reject){
+ // //鏌ヨ鑱旂郴浜虹殑鏁版嵁
+ // let queryBack = function queryBack(result) {
+ // let contacts = result.object;
+ // if(contacts == null){
+ // return;
+ // }
+ // for(var i=0;i<result.object.length;i++){
+ // for(let key in PIData){
+ // if(result.object[i].dataId == PIData[key].awsDataId){
+ // PIData[key].lastName = result.object[i].lastName;
+ // }
+ // }
+ // }
+ // }
+ // var condition = ''
+ // for(var i=0;i<tableDataStr.length;i++){
+ // if(tableDataStr[i].address.Contacts__c){
+ // condition += "," + "\'"+tableDataStr[i].address.Contacts__c+"\'";
+ // }
+ // }
+ // condition = condition.substr(1);
+ // console.log('condition = ' + condition);
+ // var record = sforce.connection.query("select AWS_Data_Id__c from Contact where id in("+condition+")");
+ // var records = record.getArray("records");
+ // for(var i =0;i<records.length;i++){
+ // if(records[i].AWS_Data_Id__c){
+ // contactDataIds.push(records[i].AWS_Data_Id__c);
+ // }
+ // }
+ // let searchPayload = new Object();
+ // searchPayload.dataIds = contactDataIds;
+ // searchPayload.contactName = '';
+ // console.log('contactDataIds = ' + contactDataIds);
+ // AWSService.search(staticResourceContact.searchUrl, JSON.stringify(searchPayload), queryBack, staticResourceContact.token);
+ // });
+ }
+
+ //zhj PIPL 2022-06-08 end
+
+
+ //鏌ヨ鏁忔劅瀛楁
+ function queryPI(){
+ //b();
+ tableDataStr = JSON.parse(document.getElementById('allPage:allForm:tableValueFrontEnd').value);
+ PIData = {};
+ contactDataIds = [];
+ console.log(tableDataStr)
+ q1().then(function(data){
+ return q2(data);
+ })
+ //ub();
+ }
+
+
+ function showPIDiv(awsDataId){
+ if(awsDataId.length == 0 || PIData[awsDataId]==null){
+ return
+ }
+ console.log('awsDataId Value:'+awsDataId);
+ let parentNode = document.getElementById(awsDataId);
+ let createDiv = document.createElement("div");
+ createDiv.id = awsDataId+"_PI";
+ let piInformation = '';
+
+ if(PIData[awsDataId].lastName){
+ piInformation = '鑱旂郴浜�: '+PIData[awsDataId].lastName+
+ '\n鐢佃瘽: '+PIData[awsDataId].telephone+
+ '\n閭紪: '+PIData[awsDataId].zipCode+
+ '\n璇︾粏鍦板潃: '+PIData[awsDataId].detailedAddress
+ }else{
+ piInformation = '鑱旂郴浜�: null'+
+ '\n鐢佃瘽: '+PIData[awsDataId].telephone+
+ '\n閭紪: '+PIData[awsDataId].zipCode+
+ '\n璇︾粏鍦板潃: '+PIData[awsDataId].detailedAddress
+ }
+ //let piInformation = 'Name:'+contact['943114607025717249'].lastName +'\n' +'Phone:'+contact['943114607025717249'].phone
+ createDiv.innerText = piInformation;
+ let x=window.event.x;
+ let y=window.event.y;
+ createDiv.style.left=x;
+ createDiv.style.top=y;
+ createDiv.style.height='100px';
+ createDiv.style.width='120px';
+ createDiv.style.background="#dddddd";
+ createDiv.style.position = "absolute";
+ parentNode.appendChild(createDiv);
+ parentNode.style.position = "relative";
+ }
+
+ function hidePIDiv(awsDataId){
+ if(awsDataId.length == 0 || PIData[awsDataId]==null){
+ return
+ }
+ document.getElementById(awsDataId+'_PI').remove();
+ }
+
+ // function replaceSearchContactLookup() {
+ // if(document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Contacts__c') != null){
+ // let contactHtmlString = '<img src="/img/s.gif" onclick="searchContact(\'allPage:allForm:contactId\',\'allPage:allForm:oppBlock2:UpdAddressId:Contacts__c\')" alt="Reference Document Number Lookup" class="lookupIcon" title="Reference Document Number Lookup (New Window)"/>';
+ // let lookUpNode = htmlToElement(contactHtmlString);
+ // console.log(lookUpNode);
+ // let parentNode = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Contacts__c').parentNode;
+ // parentNode.appendChild(lookUpNode);
+ // if(contactInfoStr){
+ // console.log('closePopup:'+contactInfoStr);
+ // let contactInfo = JSON.parse(contactInfoStr);
+ // let contactNodeId = 'allPage:allForm:oppBlock2:UpdAddressId:contactIdValue';
+ // document.getElementById(contactNodeId).value = contactInfo.ContactId;
+ // document.getElementById(closeField).value = contactInfo.Name;
+ // }
+ // }
+ // }
+
+ function htmlToElement(html) {
+ var template = document.createElement('template');
+ html = html.trim(); // Never return a text node of whitespace as the result
+ template.innerHTML = html;
+ return template.content.firstChild;
+ }
+
+ //鑷畾涔塴ookup鏌ヨ
+ // function searchContact(contactNodeId,field){
+ // closeField = field;
+ // let accountValue = "";
+ // if (document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Customer__r_Name')!=null) {
+ // let accountNodeId = document.getElementById('allPage:allForm:oppBlock2:UpdAddressId:Customer__r_Name').id + '_lkid';
+ // accountValue = document.getElementById(accountNodeId).value;
+ // }
+ // console.log(accountValue);
+ // if(accountValue !='000000000000000'){
+ // let baseUrl = "/apex/SearchContactPage";
+ // let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue;
+ // let newSearchContactParam = 'height=600,width=800,left=100,top=100,dialogHide=true,resizable=no,scrollbars=yes,toolbar=no,status=no';
+ // newSearchContactWindow = window.open(baseUrl+suffixUrl, 'Popup', newSearchContactParam);
+ // if (window.focus) {
+ // newSearchContactWindow.focus();
+ // }
+ // return false;
+ // }else{
+ // console.log('璇峰厛閫夋嫨瀹㈡埛鍐嶉�夋嫨鑱旂郴浜�')
+ // }
+ // }
+
+ function closePopupWindow() {
+ if (null != newSearchContactWindow) {
+ newSearchContactWindow.close();
+ }
+ contactInfoStr = document.getElementById('allPage:allForm:contactId').value;
+ console.log('closePopup:'+contactInfoStr);
+ let contactInfo = JSON.parse(contactInfoStr);
+ let contactNodeId = 'allPage:allForm:oppBlock2:UpdAddressId:contactIdValue';
+ document.getElementById(contactNodeId).value = contactInfo.ContactId;
+ document.getElementById(closeField).value = contactInfo.Name;
+ }
+ //2022 02 28 寮犲崕寤� display PI Data end
+ </script>
+ <script type="text/javascript">
+ function DecryptAddress() {
+ debugger;
+ let arr1 = [];
+ let a1 = false;
+ let arr2 = [];
+ let a2 = false;
+ j$("td.oraddress").each(function (i, e) {
+ let did = j$(e).attr("address-data-id");
+ if (did) {
+ arr1.push(did);
}
- </script>
- <apex:form id="allForm">
- <apex:inputHidden id="tableValueFrontEnd" value="{!tableDataStr}"/>
- <apex:inputHidden value="{!contactId}" id="contactId"/>
- <apex:inputHidden value="{!insUpdDataStr}" id="insUpdDataStr"/>
- <div id="tab01">
- <!-- 椤甸潰鏁版嵁鍒濆鍖栨柟娉� -->
- <apex:actionFunction name="init" action="{!init}" rerender="oppBlock1,message,checEventFrame" onComplete="ub();"></apex:actionFunction>
- <!-- 妫�绱㈡暟鎹煡璇㈡柟娉� -->
- <apex:actionFunction name="searchBtn" action="{!searchBtn}" rerender="oppBlock1,message,checEventFrame,tableValueFrontEnd" onComplete="ub();DecryptAddress();">
- <apex:param name="addressDataIds" assignTo="{!addressDataIds}" value=""></apex:param>
- </apex:actionFunction>
- <!-- 閲囩敤鏂规硶 -->
- <!--<actionFunction name="adoptSave" action="{!adoptSave}" rerender="oppBlock2,message" onComplete="ub();">
+
+ did = j$(e).attr("contact-data-id");
+ if (did) {
+ arr2.push(did);
+ }
+ });
+
+ if (arr1.length) {
+ b();
+ AWSService.post(
+ staticResource.searchUrl,
+ {
+ dataIds: arr1
+ },
+ function (data) {
+ ub();
+ if (data && data.object && data.object.length > 0) {
+ for (let di in data.object) {
+ if (data.object[di] && data.object[di].dataId) {
+ addressAwsData[data.object[di].dataId] = data.object[di];
+ }
+ }
+ }
+ },
+ staticResource.token
+ );
+ }
+
+ if (arr2.length) {
+ b();
+ AWSService.post(
+ staticResourceContact.searchUrl,
+ {
+ dataIds: arr2
+ },
+ function (data) {
+ ub();
+ if (data && data.object && data.object.length > 0) {
+ for (let di in data.object) {
+ if (data.object[di] && data.object[di].dataId) {
+ addressAwsData[data.object[di].dataId] = data.object[di];
+ }
+ }
+ }
+ },
+ staticResourceContact.token
+ );
+ }
+ }
+ </script>
+ <apex:form id="allForm">
+ <apex:inputHidden id="tableValueFrontEnd" value="{!tableDataStr}" />
+ <apex:inputHidden value="{!contactId}" id="contactId" />
+ <apex:inputHidden value="{!insUpdDataStr}" id="insUpdDataStr" />
+ <div id="tab01">
+ <!-- 椤甸潰鏁版嵁鍒濆鍖栨柟娉� -->
+ <apex:actionFunction
+ name="init"
+ action="{!init}"
+ rerender="oppBlock1,message,checEventFrame"
+ onComplete="ub();"
+ ></apex:actionFunction>
+ <!-- 妫�绱㈡暟鎹煡璇㈡柟娉� -->
+ <apex:actionFunction
+ name="searchBtn"
+ action="{!searchBtn}"
+ rerender="oppBlock1,message,checEventFrame,tableValueFrontEnd"
+ onComplete="ub();DecryptAddress();"
+ >
+ <apex:param
+ name="addressDataIds"
+ assignTo="{!addressDataIds}"
+ value=""
+ ></apex:param>
+ </apex:actionFunction>
+ <!-- 閲囩敤鏂规硶 -->
+ <!--<actionFunction name="adoptSave" action="{!adoptSave}" rerender="oppBlock2,message" onComplete="ub();">
<apex:param name="adoptId" assignTo="{!adoptId}" value="" />
<apex:param name="isUpload" assignTo="{!isUpload}" value="" />
</actionFunction>-->
- <!-- 淇濆瓨鍜屼慨鏀规柟娉� -->
- <apex:actionFunction name="save" action="{!save}" rerender="oppBlock2,message" onComplete="ub();Trans()"></apex:actionFunction>
- <!-- 鐐瑰嚮淇敼鎸夐挳鑾峰彇淇敼鏁版嵁鏂规硶 -->
- <apex:actionFunction name="onEditor" action="{!onEditor}" rerender="oppBlock2,checEventFrame,insUpdDataStr" onComplete="decrypt();ub();">
- <apex:param name="UpdId" assignTo="{!UpdId}" value="" />
- </apex:actionFunction>
- <!-- 澶嶅埗鏂规硶 -->
- <apex:actionFunction name="onCopy" action="{!onCopy}" rerender="oppBlock2,checEventFrame," onComplete="decrypt();ub();">
- <apex:param name="UpdId" assignTo="{!UpdId}" value="" />
- </apex:actionFunction>
- <!-- 杩斿洖鐖堕〉闈� -->
- <apex:actionFunction name="redirectPag" action="{!redirectPag}" rerender="true" onComplete="ub();"></apex:actionFunction>
- <apex:pageBlock id="searchBlock" tabStyle="Report">
- <table style="border-bottom-width: 0px; font-size:12px;width:100%">
- <tr>
- <td style="width: 15%">
- <font>绫� 鍨� </font>
- <!-- <apex:selectList id="numtextA1Id" value="{!numtextA1}" size="1" style="width:110px">
+ <!-- 淇濆瓨鍜屼慨鏀规柟娉� -->
+ <apex:actionFunction
+ name="save"
+ action="{!save}"
+ rerender="oppBlock2,message"
+ onComplete="ub();Trans()"
+ ></apex:actionFunction>
+ <!-- 鐐瑰嚮淇敼鎸夐挳鑾峰彇淇敼鏁版嵁鏂规硶 -->
+ <apex:actionFunction
+ name="onEditor"
+ action="{!onEditor}"
+ rerender="oppBlock2,checEventFrame,insUpdDataStr"
+ onComplete="decrypt();ub();"
+ >
+ <apex:param name="UpdId" assignTo="{!UpdId}" value="" />
+ </apex:actionFunction>
+ <!-- 澶嶅埗鏂规硶 -->
+ <apex:actionFunction
+ name="onCopy"
+ action="{!onCopy}"
+ rerender="oppBlock2,checEventFrame,"
+ onComplete="decrypt();ub();"
+ >
+ <apex:param name="UpdId" assignTo="{!UpdId}" value="" />
+ </apex:actionFunction>
+ <!-- 杩斿洖鐖堕〉闈� -->
+ <apex:actionFunction
+ name="redirectPag"
+ action="{!redirectPag}"
+ rerender="true"
+ onComplete="ub();"
+ ></apex:actionFunction>
+ <apex:pageBlock id="searchBlock" tabStyle="Report">
+ <table style="border-bottom-width: 0px; font-size: 12px; width: 100%">
+ <tr>
+ <td style="width: 15%">
+ <font>绫� 鍨� </font>
+ <!-- <apex:selectList id="numtextA1Id" value="{!numtextA1}" size="1" style="width:110px">
<apex:selectOptions value="{!optionType}"/>
</apex:selectList> -->
- <apex:inputField value="{!optionAddressClassification.Address_Classification__c}" id="AddressClassificationId"/>
- </td>
- <td style="width: 20%">
- <font>瀹� 鎴� 鍚� </font>
- <apex:inputText id="txtNameId" value="{!txtName}"/>
- <a class="inlineEditUndoLink" title="娓呯┖" href="#" onclick="document.getElementById('allPage:allForm:searchBlock:txtNameId').value = '';document.getElementById('allPage:allForm:searchBlock:txtNameId').focus();" style="display: inline;">
- <img width="16px" height="16px" src="/img/s.gif" alt="娓呯┖" class="inlineEditUndo"/>
- </a>
- </td>
- <td style="width: 20%">
- <font>鍦� 鍧� </font>
- <apex:inputText id="txtAddressId" value="{!txtAddress}"/>
- <a class="inlineEditUndoLink" title="娓呯┖" href="#" onclick="document.getElementById('allPage:allForm:searchBlock:txtAddressId').value = '';document.getElementById('allPage:allForm:searchBlock:txtAddressId').focus(); " style="display: inline;">
- <img width="16px" height="16px" src="/s.gif" alt="娓呯┖" class="inlineEditUndo"/>
- </a>
- </td>
- <td style="width: 20%">
- <apex:commandButton onclick="searchBtnJs();return false;" rendered="true" value="妫�绱�" style="width:60px;" onComplete=""/>
-
- <!-- <apex:commandButton onclick="onAdoptJs();return false;" rendered="true" value="閲囩敤" style="width:60px;background:#98c1fbf7"/>
+ <apex:inputField
+ value="{!optionAddressClassification.Address_Classification__c}"
+ id="AddressClassificationId"
+ />
+ </td>
+ <td style="width: 20%">
+ <font>瀹� 鎴� 鍚� </font>
+ <apex:inputText id="txtNameId" value="{!txtName}" />
+ <a
+ class="inlineEditUndoLink"
+ title="娓呯┖"
+ href="#"
+ onclick="document.getElementById('allPage:allForm:searchBlock:txtNameId').value = '';document.getElementById('allPage:allForm:searchBlock:txtNameId').focus();"
+ style="display: inline"
+ >
+ <img
+ width="16px"
+ height="16px"
+ src="/img/s.gif"
+ alt="娓呯┖"
+ class="inlineEditUndo"
+ />
+ </a>
+ </td>
+ <td style="width: 20%">
+ <font>鍦� 鍧� </font>
+ <apex:inputText id="txtAddressId" value="{!txtAddress}" />
+ <a
+ class="inlineEditUndoLink"
+ title="娓呯┖"
+ href="#"
+ onclick="document.getElementById('allPage:allForm:searchBlock:txtAddressId').value = '';document.getElementById('allPage:allForm:searchBlock:txtAddressId').focus(); "
+ style="display: inline"
+ >
+ <img
+ width="16px"
+ height="16px"
+ src="/s.gif"
+ alt="娓呯┖"
+ class="inlineEditUndo"
+ />
+ </a>
+ </td>
+ <td style="width: 20%">
+ <apex:commandButton
+ onclick="searchBtnJs();return false;"
+ rendered="true"
+ value="妫�绱�"
+ style="width: 60px"
+ onComplete=""
+ />
+
+ <!-- <apex:commandButton onclick="onAdoptJs();return false;" rendered="true" value="閲囩敤" style="width:60px;background:#98c1fbf7"/>
-->
- <apex:commandButton onclick="sendBackJs();return false;" rendered="true" value="杩斿洖" style="width:60px;"/>
- </td>
- <td style="width: 25%">
-
- </td>
- </tr>
- </table>
- </apex:pageBlock>
-
- </div>
- <div>
- <apex:outputPanel id="message">
- <apex:pageMessages />
- </apex:outputPanel>
- </div>
- <div id="tab02" style="overflow-x: auto; overflow-y: auto;">
- <apex:pageBlock id="oppBlock1" tabStyle="Report">
- <apex:pageblocksection title="鍦板潃鍒楄〃" id="edmpdDetails" rendered="true" columns="1" >
- <apex:outputPanel >
- <table class="list" style="border-bottom-width: 0px; font-size:11px; border-spacing:0;" border="" id="tableHeader_L" >
- <thead>
- <tr class="headerRow" height="30px" align="center">
- <!--鏍囬 -->
- <td style="">搴忓彿</td>
- <td style="">绫诲瀷</td>
- <td style="">瀹㈡埛鍚�</td>
- <td style="">鑱旂郴浜�</td>
- <td style="">鐢佃瘽</td>
- <td style="">閭紪</td>
- <td style="">鐪�</td>
- <td style="">甯�</td>
- <td style="">璇︾粏鍦板潃</td>
- <td style="" colspan="3">
- 鎿嶄綔
- </td>
- </tr>
- </thead>
- <tbody>
- <apex:variable value="{!0}" var="cnt" />
- <apex:repeat value="{!tableData}" var="or" id="oppTable">
- <tr class="dataRow {!IF(MOD(cnt, 2)==0, 'odd', 'even')} {!IF(cnt==1, 'first', '')}" onmouseover="if (window.hiOn){hiOn(this);} " onmouseout="if (window.hiOff){hiOff(this);} " onblur="if (window.hiOff){hiOff(this);}" onfocus="if (window.hiOn){hiOn(this);}">
- <td align="center" style="vertical-align: inherit;width:25px;border-width: 0px 1px 1px 0px;">
- {!cnt+1}
- </td>
- <td align="center" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
- <apex:outputText value="{!or.address.Address_Classification__c}" />
- </td>
- <td align="left" class="Customer__c" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
- <apex:outputfield value="{!or.address.Customer__c}" />
- </td>
- <td align="left" class="oraddress" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;" address-data-id="{!or.address.AWS_Data_Id__c}" contact-data-id="{!or.address.Contacts__r.AWS_Data_Id__c}">
- <!-- <apex:outputfield value="{!or.address.Contacts__c}" id="{!or.address.Contacts__c}_{!or.address.Id}"/> -->
- <!-- <a href="#" id="{!or.address.Id}" onmouseover="showPIDiv('{!or.address.Id}')" onmouseout="hidePIDiv('{!or.address.Id}')" aws-data-id="{!or.address.Contacts__r.AWS_Data_Id__c}">{!or.address.Contacts__r.Name}</a> -->
- <a href="#" id="{!or.address.Id}" onmouseover="showPIDiv('{!or.address.Id}')" onmouseout="hidePIDiv('{!or.address.Id}')" aws-data-id="{!or.address.AWS_Data_Id__c}">{!or.address.ContactName__c}</a>
- </td>
- <td align="left" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
- <apex:outputText value="{!or.address.Telephone__c}" />
- </td>
- <td align="left" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
- <apex:outputText value="{!or.address.ZipCode__c}" />
- </td>
- <td align="center" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
- <apex:outputfield value="{!or.address.Province__c}" />
- </td>
- <td align="center" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
- <apex:outputfield value="{!or.address.City__c}" />
- </td>
- <td align="left" style="vertical-align: inherit;border-width: 0px 1px 1px 0px;">
- <apex:outputText value="{!or.address.Detailed_Address__c}" />
- </td>
- <td align="center" style="vertical-align: inherit;width:30px;">
- <apex:commandButton value=" 缂栬緫 " onclick="onEditorJs('{!or.address.id}');return false;" style="background:#98c1fbf7;display:{!or.canEdit};"/>
- </td>
- <td align="center" style="vertical-align: inherit;width:30px;">
- <apex:commandButton value=" 澶嶅埗 " onclick="onCopyJs('{!or.address.id}');return false;" style="background: #98c1fbf7;display:{!or.canCopy};"/>
- </td>
- <td align="center" style="vertical-align: inherit;width:30px;">
- <apex:commandButton value=" 閲囩敤 " onclick="onAdoptJs(event,JSON.parse('{!or.addressJson}'));return false;" style="background: #98c1fbf7;display:{!or.canAdopt};"/>
- </td>
- </tr>
- <apex:variable value="{!cnt + 1}" var="cnt" />
- </apex:repeat>
- </tbody>
- <script>
- console.log('queryPI();')
- queryPI();
- </script>
- </table>
- </apex:outputPanel>
- </apex:pageblocksection>
- </apex:pageBlock>
-
- </div>
- <div id="tab03">
- <apex:pageBlock id="oppBlock2" tabStyle="Report">
- <!-- <apex:inputHidden id="LastName_Encrypted__c" value="{!newCon.LastName_Encrypted__c}"/>
+ <apex:commandButton
+ onclick="sendBackJs();return false;"
+ rendered="true"
+ value="杩斿洖"
+ style="width: 60px"
+ />
+ </td>
+ <td style="width: 25%"> </td>
+ </tr>
+ </table>
+ </apex:pageBlock>
+ </div>
+ <div>
+ <apex:outputPanel id="message">
+ <apex:pageMessages />
+ </apex:outputPanel>
+ </div>
+ <div id="tab02" style="overflow-x: auto; overflow-y: auto">
+ <apex:pageBlock id="oppBlock1" tabStyle="Report">
+ <apex:pageblocksection
+ title="鍦板潃鍒楄〃"
+ id="edmpdDetails"
+ rendered="true"
+ columns="1"
+ >
+ <apex:outputPanel>
+ <table
+ class="list"
+ style="
+ border-bottom-width: 0px;
+ font-size: 11px;
+ border-spacing: 0;
+ "
+ border=""
+ id="tableHeader_L"
+ >
+ <thead>
+ <tr class="headerRow" height="30px" align="center">
+ <!--鏍囬 -->
+ <td style="">搴忓彿</td>
+ <td style="">绫诲瀷</td>
+ <td style="">瀹㈡埛鍚�</td>
+ <td style="">鑱旂郴浜�</td>
+ <td style="">鐢佃瘽</td>
+ <td style="">閭紪</td>
+ <td style="">鐪�</td>
+ <td style="">甯�</td>
+ <td style="">璇︾粏鍦板潃</td>
+ <td style="" colspan="3">鎿嶄綔</td>
+ </tr>
+ </thead>
+ <tbody>
+ <apex:variable value="{!0}" var="cnt" />
+ <apex:repeat value="{!tableData}" var="or" id="oppTable">
+ <tr
+ class="dataRow {!IF(MOD(cnt, 2)==0, 'odd', 'even')} {!IF(cnt==1, 'first', '')}"
+ onmouseover="if (window.hiOn){hiOn(this);} "
+ onmouseout="if (window.hiOff){hiOff(this);} "
+ onblur="if (window.hiOff){hiOff(this);}"
+ onfocus="if (window.hiOn){hiOn(this);}"
+ >
+ <td
+ align="center"
+ style="
+ vertical-align: inherit;
+ width: 25px;
+ border-width: 0px 1px 1px 0px;
+ "
+ >
+ {!cnt+1}
+ </td>
+ <td
+ align="center"
+ style="
+ vertical-align: inherit;
+ border-width: 0px 1px 1px 0px;
+ "
+ >
+ <apex:outputText
+ value="{!or.address.Address_Classification__c}"
+ />
+ </td>
+ <td
+ align="left"
+ class="Customer__c"
+ style="
+ vertical-align: inherit;
+ border-width: 0px 1px 1px 0px;
+ "
+ >
+ <apex:outputfield value="{!or.address.Customer__c}" />
+ </td>
+ <td
+ align="left"
+ class="oraddress"
+ style="
+ vertical-align: inherit;
+ border-width: 0px 1px 1px 0px;
+ "
+ address-data-id="{!or.address.AWS_Data_Id__c}"
+ contact-data-id="{!or.address.Contacts__r.AWS_Data_Id__c}"
+ >
+ <!-- <apex:outputfield value="{!or.address.Contacts__c}" id="{!or.address.Contacts__c}_{!or.address.Id}"/> -->
+ <!-- <a href="#" id="{!or.address.Id}" onmouseover="showPIDiv('{!or.address.Id}')" onmouseout="hidePIDiv('{!or.address.Id}')" aws-data-id="{!or.address.Contacts__r.AWS_Data_Id__c}">{!or.address.Contacts__r.Name}</a> -->
+ <a
+ href="#"
+ id="{!or.address.Id}"
+ onmouseover="showPIDiv('{!or.address.Id}')"
+ onmouseout="hidePIDiv('{!or.address.Id}')"
+ aws-data-id="{!or.address.AWS_Data_Id__c}"
+ >{!or.address.ContactName__c}</a
+ >
+ </td>
+ <td
+ align="left"
+ style="
+ vertical-align: inherit;
+ border-width: 0px 1px 1px 0px;
+ "
+ >
+ <apex:outputText value="{!or.address.Telephone__c}" />
+ </td>
+ <td
+ align="left"
+ style="
+ vertical-align: inherit;
+ border-width: 0px 1px 1px 0px;
+ "
+ >
+ <apex:outputText value="{!or.address.ZipCode__c}" />
+ </td>
+ <td
+ align="center"
+ style="
+ vertical-align: inherit;
+ border-width: 0px 1px 1px 0px;
+ "
+ >
+ <apex:outputfield value="{!or.address.Province__c}" />
+ </td>
+ <td
+ align="center"
+ style="
+ vertical-align: inherit;
+ border-width: 0px 1px 1px 0px;
+ "
+ >
+ <apex:outputfield value="{!or.address.City__c}" />
+ </td>
+ <td
+ align="left"
+ style="
+ vertical-align: inherit;
+ border-width: 0px 1px 1px 0px;
+ "
+ >
+ <apex:outputText
+ value="{!or.address.Detailed_Address__c}"
+ />
+ </td>
+ <td
+ align="center"
+ style="vertical-align: inherit; width: 30px"
+ >
+ <apex:commandButton
+ value=" 缂栬緫 "
+ onclick="onEditorJs('{!or.address.id}');return false;"
+ style="background:#98c1fbf7;display:{!or.canEdit};"
+ />
+ </td>
+ <td
+ align="center"
+ style="vertical-align: inherit; width: 30px"
+ >
+ <apex:commandButton
+ value=" 澶嶅埗 "
+ onclick="onCopyJs('{!or.address.id}');return false;"
+ style="background: #98c1fbf7;display:{!or.canCopy};"
+ />
+ </td>
+ <td
+ align="center"
+ style="vertical-align: inherit; width: 30px"
+ >
+ <apex:commandButton
+ value=" 閲囩敤 "
+ onclick="onAdoptJs(event,JSON.parse('{!or.addressJson}'));return false;"
+ style="background: #98c1fbf7;display:{!or.canAdopt};"
+ />
+ </td>
+ </tr>
+ <apex:variable value="{!cnt + 1}" var="cnt" />
+ </apex:repeat>
+ </tbody>
+ <script>
+ console.log("queryPI();");
+ queryPI();
+ </script>
+ </table>
+ </apex:outputPanel>
+ </apex:pageblocksection>
+ </apex:pageBlock>
+ </div>
+ <div id="tab03">
+ <apex:pageBlock id="oppBlock2" tabStyle="Report">
+ <!-- <apex:inputHidden id="LastName_Encrypted__c" value="{!newCon.LastName_Encrypted__c}"/>
<apex:inputHidden id="Con_AWS_Data_Id__c" value="{!newCon.AWS_Data_Id__c}"/> -->
- <apex:inputHidden id="Add_AWS_Data_Id__c" value="{!insUpdData.AWS_Data_Id__c}"/>
- <!-- zhj 鏂版柟妗堟敼閫� 2022-12-05 start -->
- <!-- <apex:inputHidden id="Telephone_Encrypted__c" value="{!insUpdData.Telephone_Encrypted__c}"/>
+ <apex:inputHidden
+ id="Add_AWS_Data_Id__c"
+ value="{!insUpdData.AWS_Data_Id__c}"
+ />
+ <!-- zhj 鏂版柟妗堟敼閫� 2022-12-05 start -->
+ <!-- <apex:inputHidden id="Telephone_Encrypted__c" value="{!insUpdData.Telephone_Encrypted__c}"/>
<apex:inputHidden id="ContactName_Encrypted__c" value="{!insUpdData.ContactName_Encrypted__c}"/>
<apex:inputHidden id="ZipCode_Encrypted__c" value="{!insUpdData.ZipCode_Encrypted__c}"/>
<apex:inputHidden id="Detailed_Address_Encrypted__c" value="{!insUpdData.Detailed_Address_Encrypted__c}"/> -->
- <!-- zhj 鏂版柟妗堟敼閫� 2022-12-05 end -->
- <apex:pageblocksection title="缂栬緫鍦板潃" id="UpdAddressId" rendered="true" columns="3">
- <apex:inputfield value="{!insUpdData.Address_Classification__c}" id="Address_Classification__c"/>
- <apex:inputfield value="{!insUpdData.Customer__c}" id="Customer__r_Name" required="false" />
- <!-- Before PIPL 20220308 -->
- <!-- <apex:inputfield value="{!insUpdData.Contacts__c}" id="Contacts__c" required="false"/> -->
- <!-- WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 start -->
- <!-- Add By Li Jun for PIPL 20220308 Start -->
- <!-- <apex:inputText label="鑱旂郴浜�" disabled="true" value="{!contactNameValue}" id="Contacts__c">
+ <!-- zhj 鏂版柟妗堟敼閫� 2022-12-05 end -->
+ <apex:pageblocksection
+ title="缂栬緫鍦板潃"
+ id="UpdAddressId"
+ rendered="true"
+ columns="3"
+ >
+ <apex:inputfield
+ value="{!insUpdData.Address_Classification__c}"
+ id="Address_Classification__c"
+ />
+ <apex:inputfield
+ value="{!insUpdData.Customer__c}"
+ id="Customer__r_Name"
+ required="false"
+ />
+ <!-- Before PIPL 20220308 -->
+ <!-- <apex:inputfield value="{!insUpdData.Contacts__c}" id="Contacts__c" required="false"/> -->
+ <!-- WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 start -->
+ <!-- Add By Li Jun for PIPL 20220308 Start -->
+ <!-- <apex:inputText label="鑱旂郴浜�" disabled="true" value="{!contactNameValue}" id="Contacts__c">
</apex:inputText>
<apex:inputHidden id="contactIdValue" value="{!contactIdValue}"/> -->
- <apex:inputfield value="{!insUpdData.ContactName__c}" id="ContactName__c"/>
- <!-- Add By Li Jun for PIPL 20220308 End -->
- <!-- <apex:inputfield value="{!insUpdData.Create_Contacts__c}" id="Create_Contacts__c" required="false"/> -->
- <!-- WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 end -->
- <apex:inputfield value="{!insUpdData.Province__c}" id="Province__r_Name" style="" />
- <apex:inputfield value="{!insUpdData.City__c}" id="City__r_name" />
- <apex:inputfield value="{!insUpdData.Telephone__c}" id="Telephone__c" />
- <apex:inputfield value="{!insUpdData.ZipCode__c}" id="ZipCode__c" />
- <!-- <apex:pageblockSectionItem /> -->
- <!-- <apex:inputTextarea value="{!insUpdData.Detailed_Address__c}" id="Detailed_Address__c" style="resize:vertical;width: 90%" rows="3" cols="3"/> -->
- <apex:inputfield value="{!insUpdData.Detailed_Address__c}" id="Detailed_Address__c" style="resize:vertical;width: 98%"/>
+ <apex:inputfield
+ value="{!insUpdData.ContactName__c}"
+ id="ContactName__c"
+ />
+ <!-- Add By Li Jun for PIPL 20220308 End -->
+ <!-- <apex:inputfield value="{!insUpdData.Create_Contacts__c}" id="Create_Contacts__c" required="false"/> -->
+ <!-- WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 end -->
+ <apex:inputfield
+ value="{!insUpdData.Province__c}"
+ id="Province__r_Name"
+ style=""
+ />
+ <apex:inputfield value="{!insUpdData.City__c}" id="City__r_name" />
+ <apex:inputfield
+ value="{!insUpdData.Telephone__c}"
+ id="Telephone__c"
+ />
+ <apex:inputfield value="{!insUpdData.ZipCode__c}" id="ZipCode__c" />
+ <!-- <apex:pageblockSectionItem /> -->
+ <!-- <apex:inputTextarea value="{!insUpdData.Detailed_Address__c}" id="Detailed_Address__c" style="resize:vertical;width: 90%" rows="3" cols="3"/> -->
+ <apex:inputfield
+ value="{!insUpdData.Detailed_Address__c}"
+ id="Detailed_Address__c"
+ style="resize: vertical; width: 98%"
+ />
- <div id="errorMsg" class="errorMsg"></div>
- </apex:pageblocksection>
+ <div id="errorMsg" class="errorMsg"></div>
+ </apex:pageblocksection>
- <div style="text-align: center;">
- <apex:commandButton immediate="true" value="淇濆瓨" onclick="savaJs();" rerender="dummy" />
- </div>
- <!-- <script>
+ <div style="text-align: center">
+ <apex:commandButton
+ immediate="true"
+ value="淇濆瓨"
+ onclick="savaJs();"
+ rerender="dummy"
+ />
+ </div>
+ <!-- <script>
replaceSearchContactLookup();
</script> -->
- </apex:pageBlock>
- </div>
-
- </apex:form>
- <apex:outputPanel id="checEventFrame">
- <script type="text/javascript">
-
-
- j$("select option[value='鍔炰簨澶�']")[1].remove();
-
- DecryptAddress();
-
- </script>
- </apex:outputPanel>
-
-</apex:page>
\ No newline at end of file
+ </apex:pageBlock>
+ </div>
+ </apex:form>
+ <apex:outputPanel id="checEventFrame">
+ <script type="text/javascript">
+ j$("select option[value='鍔炰簨澶�']")[1].remove();
+
+ DecryptAddress();
+ </script>
+ </apex:outputPanel>
+</apex:page>
diff --git a/force-app/main/default/pages/StraightBackAddress.page-meta.xml b/force-app/main/default/pages/StraightBackAddress.page-meta.xml
index 5dc8817..75ff233 100644
--- a/force-app/main/default/pages/StraightBackAddress.page-meta.xml
+++ b/force-app/main/default/pages/StraightBackAddress.page-meta.xml
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8" ?>
<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>45.0</apiVersion>
- <availableInTouch>true</availableInTouch>
+ <availableInTouch>false</availableInTouch>
<confirmationTokenRequired>false</confirmationTokenRequired>
<label>StraightBackAddress</label>
</ApexPage>
diff --git a/force-app/main/default/permissionsets/Community_Consumable_LEX_PS.permissionset-meta.xml b/force-app/main/default/permissionsets/Community_Consumable_LEX_PS.permissionset-meta.xml
new file mode 100644
index 0000000..1b4f021
--- /dev/null
+++ b/force-app/main/default/permissionsets/Community_Consumable_LEX_PS.permissionset-meta.xml
@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
+ <classAccesses>
+ <apexClass>LexArriveGoodsController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexArriveGoodsMainController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexArriveGsDetailsController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexCancelRemoveBoxController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexConInvoiceList</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexConInvoiceViewController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexConInvoicedetailsController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexConsumableAccountController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexConsumableAccountInfoController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexConsumableAccountSOQL</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexConsumableController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexConsumableGoodsInfo</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexConsumableOrderManageController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexDealerInquiryModifyStateController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexInventoryController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexInventoryListController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexInventoryViewController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexLicenceReminderController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexOutboundorderImportController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexOverdueStockController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexProductLimitEditController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexRemoveBoxController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexSaleAndDeliveryController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexSaleOrderController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexSearchContractController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexSearchHospitalController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexSummonsCreatController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexTopPageController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexUpAccountProLimit</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>LexUtility</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <classAccesses>
+ <apexClass>lexSearchAgencyHospitalController</apexClass>
+ <enabled>true</enabled>
+ </classAccesses>
+ <flowAccesses>
+ <enabled>true</enabled>
+ <flow>
+CommunityWeeklyReport;
+ </flow>
+ </flowAccesses>
+ <hasActivationRequired>false</hasActivationRequired>
+ <label>Community Consumable LEX PS</label>
+ <objectPermissions>
+ <allowCreate>true</allowCreate>
+ <allowDelete>false</allowDelete>
+ <allowEdit>false</allowEdit>
+ <allowRead>true</allowRead>
+ <modifyAllRecords>false</modifyAllRecords>
+ <object>Agency_Report_Header__c</object>
+ <viewAllRecords>false</viewAllRecords>
+ </objectPermissions>
+ <objectPermissions>
+ <allowCreate>true</allowCreate>
+ <allowDelete>false</allowDelete>
+ <allowEdit>false</allowEdit>
+ <allowRead>true</allowRead>
+ <modifyAllRecords>false</modifyAllRecords>
+ <object>Agency_Report__c</object>
+ <viewAllRecords>false</viewAllRecords>
+ </objectPermissions>
+ <userPermissions>
+ <enabled>true</enabled>
+ <name>ChatterEnabledForUser</name>
+ </userPermissions>
+ <userPermissions>
+ <enabled>true</enabled>
+ <name>ViewContent</name>
+ </userPermissions>
+</PermissionSet>
diff --git a/manifest/LEXC01packagelexcommunitynew.xml b/manifest/LEXC01packagelexcommunitynew.xml
index 63caf00..decdc04 100644
--- a/manifest/LEXC01packagelexcommunitynew.xml
+++ b/manifest/LEXC01packagelexcommunitynew.xml
@@ -1,94 +1,82 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<?xml version="1.0" encoding="UTF-8" ?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
+ <fullName>DeployToProducton_New</fullName>
+ <description
+ >LexArriveGoodsMainControllerTest LexArriveGsDetailsControllerTest LexCancelRemoveBoxControllerTest LexRemoveBoxControllerTest LexConInvoicedetailsControllerTest LexConInvoiceListTest LexConInvoiceViewControllerTest LexConsumableAccountControllerTest exConsumableAccountInfoControllerTest LexConsumableControllerTest LexConsumableGoodsInfoTest LexConsumableOrderManageControllerTest LexInventoryControllerTest LexInventoryListControllerTest LexInventoryViewControllerTest LexLicenceReminderControllerTest LexOutboundorderImportControllerTest LexOverdueStockControllerTest LexProductLimitEditControllerTest LexRemoveBoxControllerTest LexSaleAndDeliveryControllerTest LexSaleOrderControllerTest lexSearchAgencyHospitalControllerTest LexSearchContractControllerTest LexSearchHospitalControllerTest LexTopPageControllerTest LexUpAccountProLimitControllerTest LexUtilityTest LookupSearchResultTest LexConsumableAccountSOQLTest</description>
<types>
<members>LexArriveGoodsMainController</members>
+ <members>LexArriveGoodsMainControllerTest</members>
<members>LexArriveGsDetailsController</members>
+ <members>LexArriveGsDetailsControllerTest</members>
<members>LexCancelRemoveBoxController</members>
+ <members>LexCancelRemoveBoxControllerTest</members>
<members>LexConInvoiceList</members>
+ <members>LexConInvoiceListTest</members>
<members>LexConInvoiceViewController</members>
+ <members>LexConInvoiceViewControllerTest</members>
<members>LexConInvoicedetailsController</members>
+ <members>LexConInvoicedetailsControllerTest</members>
<members>LexConsumableAccountController</members>
+ <members>LexConsumableAccountControllerTest</members>
<members>LexConsumableAccountInfoController</members>
+ <members>LexConsumableAccountInfoControllerTest</members>
<members>LexConsumableAccountSOQL</members>
+ <members>LexConsumableAccountSOQLTest</members>
<members>LexConsumableController</members>
+ <members>LexConsumableControllerTest</members>
<members>LexConsumableGoodsInfo</members>
+ <members>LexConsumableGoodsInfoTest</members>
<members>LexConsumableOrderManageController</members>
- <members>LexDealerInquiryModifyStateController</members>
+ <members>LexConsumableOrderManageControllerTest</members>
<members>LexInventoryController</members>
+ <members>LexInventoryControllerTest</members>
<members>LexInventoryListController</members>
+ <members>LexInventoryListControllerTest</members>
<members>LexInventoryViewController</members>
+ <members>LexInventoryViewControllerTest</members>
<members>LexLicenceReminderController</members>
+ <members>LexLicenceReminderControllerTest</members>
<members>LexOutboundorderImportController</members>
+ <members>LexOutboundorderImportControllerTest</members>
<members>LexOverdueStockController</members>
+ <members>LexOverdueStockControllerTest</members>
<members>LexProductLimitEditController</members>
+ <members>LexProductLimitEditControllerTest</members>
<members>LexRemoveBoxController</members>
+ <members>LexRemoveBoxControllerTest</members>
<members>LexSaleAndDeliveryController</members>
+ <members>LexSaleAndDeliveryControllerTest</members>
<members>LexSaleOrderController</members>
+ <members>LexSaleOrderControllerTest</members>
<members>LexSearchContractController</members>
+ <members>LexSearchContractControllerTest</members>
<members>LexSearchHospitalController</members>
+ <members>LexSearchHospitalControllerTest</members>
<members>LexSummonsCreatController</members>
<members>LexTopPageController</members>
+ <members>LexTopPageControllerTest</members>
<members>LexUpAccountProLimit</members>
+ <members>LexUpAccountProLimitControllerTest</members>
<members>LexUtility</members>
+ <members>LexUtilityTest</members>
<members>LookupSearchResult</members>
+ <members>LookupSearchResultTest</members>
<members>ResponseBodyLWC</members>
<members>lexSearchAgencyHospitalController</members>
+ <members>lexSearchAgencyHospitalControllerTest</members>
+ <members>LexSummonsCreatControllerTest</members>
+ <members>ResponseBodyLWCTest</members>
<name>ApexClass</name>
</types>
<types>
- <members>ContentDocumentLink</members>
- <members>ContentDocumentTrigger</members>
- <members>ContentVersionTrigger</members>
- <name>ApexTrigger</name>
+ <members>LicenceReminderDate__c.ReminderDays__c</members>
+ <members>NoteStay__c.IsStay__c</members>
+ <name>CustomField</name>
</types>
<types>
- <members>boxorpieceType</members>
- <members>commonToast</members>
- <members>customLightningDatatable</members>
- <members>customOutboundCountComp</members>
- <members>customOutputGood</members>
- <members>customShipmentAmountComp</members>
- <members>customShipmentNumberComp</members>
- <members>customShippingUnitPriceComp</members>
- <members>customUnitComp</members>
- <members>customWeeklyReportComp</members>
- <members>datatableWithCustomTypes</members>
- <members>lexAgencyInfo</members>
- <members>lexAgencyOppCusCell</members>
- <members>lexArriveGoodsMain</members>
- <members>lexArriveGsDetails</members>
- <members>lexCancelRemoveBox</members>
- <members>lexConInvoiceView</members>
- <members>lexConsumable</members>
- <members>lexConsumableAccount</members>
- <members>lexConsumableAccountInfoPrint</members>
- <members>lexConsumableOrderManage</members>
- <members>lexCssUtility</members>
- <members>lexCustomAttachmentTypeComp</members>
- <members>lexCustomDiffReasonComp</members>
- <members>lexCustomInventoryColor</members>
- <members>lexCustomLightningDatatable</members>
- <members>lexCustomTableInput</members>
- <members>lexDealerInquiryModifyState</members>
- <members>lexInventory</members>
- <members>lexLicenceReminder</members>
- <members>lexLookup</members>
- <members>lexNewOrder</members>
- <members>lexOutboundorderImport</members>
- <members>lexOverdueStock</members>
- <members>lexProductLimitEdit</members>
- <members>lexRemoveBox</members>
- <members>lexReturnGoodCusInput</members>
- <members>lexSaleAndDelivery</members>
- <members>lexSummonsCreat</members>
- <members>lexTableCellIcon</members>
- <members>lexTopPage</members>
- <members>lexinventoryViewLWC</members>
- <members>lwcDatatableUtility</members>
- <members>myCustomTypeDatatable</members>
- <members>paginator</members>
- <members>navigateToRecord</members>
- <name>LightningComponentBundle</name>
+ <members>LicenceReminderDate__c</members>
+ <members>NoteStay__c</members>
+ <name>CustomObject</name>
</types>
- <version>57.0</version>
-</Package>
\ No newline at end of file
+ <version>50.0</version>
+</Package>
diff --git a/manifest/LEXC02packagelexcommunityupdate.xml b/manifest/LEXC02packagelexcommunityupdate.xml
index 89a67b5..5495c5a 100644
--- a/manifest/LEXC02packagelexcommunityupdate.xml
+++ b/manifest/LEXC02packagelexcommunityupdate.xml
@@ -1,10 +1,15 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<?xml version="1.0" encoding="UTF-8" ?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
+ <fullName>DeployToProducton_Update</fullName>
<types>
<members>ArriveGoodsController</members>
<members>ArriveGoodsControllerTest</members>
- <members>LexArriveGoodsController</members>
+ <members>ArriveGoodsControllerTestV2</members>
<members>DealerInquiryModifyStateController</members>
+ <members>DealerInquiryModifyStateControllerTest</members>
+ <members>LexArriveGoodsController</members>
+ <members>LexArriveGoodsControllerTest</members>
+ <members>LexArriveGoodsControllerTest1</members>
<name>ApexClass</name>
</types>
<types>
@@ -12,18 +17,8 @@
<name>ApexPage</name>
</types>
<types>
- <members>CreateTarget</members>
- <members>WeeklyReport</members>
- <members>RetrospectiveWeeklyReport</members>
- <name>AuraDefinitionBundle</name>
- </types>
- <types>
- <members>lexArriveGoods</members>
- <name>LightningComponentBundle</name>
- </types>
- <types>
<members>ConsumableOrderDetail2Trigger</members>
<name>ApexTrigger</name>
</types>
- <version>57.0</version>
-</Package>
\ No newline at end of file
+ <version>50.0</version>
+</Package>
diff --git a/manifest/package.xml b/manifest/package.xml
index 3929886..dbed6a8 100644
--- a/manifest/package.xml
+++ b/manifest/package.xml
@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
- <members>LayoutDescriberHelperTest</members>
- <members>LayoutDescriberHelper</members>
- <members>NewAndEditLeadController</members>
- <members>NewAndEditLeadControllerTest</members>
+ <members>LexUpAccountProLimit</members>
<name>ApexClass</name>
</types>
<version>52.0</version>
--
Gitblit v1.9.1