binxie
2023-06-20 39644c307e98c90e45aea98292c86d70740989e3
backup
4个文件已修改
11629 ■■■■■ 已修改文件
force-app/main/default/aura/WeeklyReport/WeeklyReport.cmp 1547 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/aura/WeeklyReport/WeeklyReportController.js 629 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/aura/WeeklyReport/WeeklyReportHelper.js 5538 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/WeeklyReportCmp.cls 3915 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/aura/WeeklyReport/WeeklyReport.cmp
@@ -1,315 +1,499 @@
<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="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>
          </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>
            <!-- 代理店担当者 -->
            <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>
  <!-- 批量添加周报 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>
      </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;">
                        </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
  </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>
      <!-- 代理店担当者 -->
      <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>
  <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
                            <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"
                >{!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}</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">
      <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,286 +502,511 @@
                        <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">{!v.dialog_type}</h4>
                <h2 id="headerTarget" class="slds-text-heading--medium">周报({!v.selected_date}&nbsp;{!v.selected_agency_person})</h2>
                <ui:button aura:id="close_button" label="关闭" class="close_button slds-button slds-button--neutral slds-order--1" press="{!c.toggle_report}"/>
  <div
    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}&nbsp;{!v.selected_agency_person})
        </h2>
        <ui:button
          aura:id="close_button"
          label="关闭"
          class="close_button slds-button slds-button--neutral slds-order--1"
          press="{!c.toggle_report}"
        />
      </div>
      <div class="slds-modal__content slds-grow slds-p-around--medium">
        <div class="slds-box slds-theme--shade">
          <div class="slds-grid slds-wrap slds-grid--pull-padded">
            <div
              class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-6"
            >
              活动日
              <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
              <force:inputField
                value="{!v.data.Report_Date__c}"
                aura:id="input-report-date"
              />
            </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">
                            活动日
                            <!-- <ui:inputSelect aura:id="select_opportunity" class="slds-select"/> -->
                            <force:inputField value="{!v.data.Report_Date__c}" aura:id="input-report-date"/>
            <!-- 医院 -->
            <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"
              data-select="single"
            >
              <ui:inputText
                aura:id="hospital_input_text"
                label="医院"
                class="field"
                value="{!v.hospital}"
                updateOn="keyup"
              />
              <div class="slds-lookup__menu" id="lookup-66">
                <ul class="slds-lookup__list" role="listbox">
                  <aura:iteration var="hospital" items="{!v.hospitalList}">
                    <li
                      role="presentation"
                      onclick="{!c.selectHos}"
                      data-accName="{!hospital.Hospital_Name_readonly__c}"
                      data-accId="{!hospital.Hospital__c}"
                    >
                      <span
                        class="slds-lookup__item-action slds-media"
                        id="lookup-option-498"
                        role="option"
                      >
                        <div class="slds-media__body">
                          <div class="slds-lookup__result-text">
                            {!hospital.Hospital_Name_readonly__c}
                          </div>
                        </div>
                        <!-- 医院 -->
                        <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" data-select="single">
                            <ui:inputText aura:id="hospital_input_text" label="医院" class="field" value="{!v.hospital}" updateOn="keyup"/>
                            <div class="slds-lookup__menu" id="lookup-66">
                                <ul class="slds-lookup__list" role="listbox">
                                    <aura:iteration var="hospital" items="{!v.hospitalList}">
                                        <li role="presentation" onclick="{!c.selectHos}" data-accName="{!hospital.Hospital_Name_readonly__c}" data-accId="{!hospital.Hospital__c}">
                                            <span class="slds-lookup__item-action slds-media" id="lookup-option-498" role="option">
                                                <div class="slds-media__body">
                                                    <div class="slds-lookup__result-text">{!hospital.Hospital_Name_readonly__c}</div>
                                                </div>
                                            </span>
                                        </li>
                                    </aura:iteration>
                                </ul>
                            </div>
                        </div>
                        <!-- 科室分类 -->
                        <div class="slds-p-horizontal--small slds-size--1-of-1 slds-medium-size--1-of-5 slds-large-size--1-of-8">
                            {!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">
                            {!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">
                            <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">
                            {!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">
                            {!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">
                            {!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">
                        </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_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">
                            {!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">
                            {!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">
                            {!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">
                            {!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">
                            {!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">
                            {!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 【委托】DAMS系统周报模块内容需求增加 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">
                            {!v.fieldsmap.SupportNeeds__c}
                            <ui:inputSelect aura:id="SupportNeeds__c" class="slds-select" />
                        </div>
                        <!--SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 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">
                            {!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"
            >
              {!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"
            >
              {!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"
            >
              <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"
            >
              {!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"
            >
              {!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"
            >
              {!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"
            ></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_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"
            >
              {!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"
            >
              {!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"
            >
              {!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"
            >
              {!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"
            >
              {!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"
            >
              {!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 【委托】DAMS系统周报模块内容需求增加 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"
            >
              {!v.fieldsmap.SupportNeeds__c}
              <ui:inputSelect aura:id="SupportNeeds__c" class="slds-select" />
            </div>
            <!--SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 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"
            >
              {!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">
      <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>
  </div>
</aura:component>
force-app/main/default/aura/WeeklyReport/WeeklyReportController.js
@@ -1,325 +1,354 @@
({
    doInit : function(component, event, helper) {
        console.log('zhj 新方案weeklyReport');
        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 新方案weeklyReport");
    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', '保存并新建');
        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方法查询出医院下面所有客户人员dataid
            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方法查询出医院下面所有客户人员dataid
      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.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 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);
    },
})
  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);
  }
});
force-app/main/default/aura/WeeklyReport/WeeklyReportHelper.js
Diff too large
force-app/main/default/classes/WeeklyReportCmp.cls
@@ -1,125 +1,150 @@
public with sharing class WeeklyReportCmp {
    @AuraEnabled public List<Agency_Report__c> reports{get;set;}
    @AuraEnabled public Map<String,List<Map<String,String>>> allselectlist{get;set;}
    @AuraEnabled public Map<String,String> fieldsMap{get;set;}
    @AuraEnabled public Map<String,List<Map<String,String>>> docmap{get;set;}
    @AuraEnabled public List<Map<String,String>> doctorList{get;set;}
  @AuraEnabled
  public List<Agency_Report__c> reports { get; set; }
  @AuraEnabled
  public Map<String, List<Map<String, String>>> allselectlist { get; set; }
  @AuraEnabled
  public Map<String, String> fieldsMap { get; set; }
  @AuraEnabled
  public Map<String, List<Map<String, String>>> docmap { get; set; }
  @AuraEnabled
  public List<Map<String, String>> doctorList { get; set; }
  // PIPL update Yin Mingjie 21/02/2022 start
  @AuraEnabled
  public Map<String, String> awsurl { get; set; }
  @AuraEnabled
  public Map<String, String> contactawsurl { get; set; }
  // PIPL update Yin Mingjie 21/02/2022 end
  public WeeklyReportCmp() {
  }
  // PIPL update Yin Mingjie 21/02/2022 start
  @RemoteAction
  @AuraEnabled
  public static Map<String, String> getAwsurl(String sobj) {
    PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo(sobj);
    Map<String, String> awsmap = new Map<String, String>();
    awsmap.put('token', piIntegration.token);
    awsmap.put('newUrl', piIntegration.newUrl);
    awsmap.put('searchUrl', piIntegration.searchUrl);
    awsmap.put('transactionURL', piIntegration.transactionURL);
    return awsmap;
  }
  // @RemoteAction
  // @AuraEnabled
  // public static Map<String, String> saveAgencyContact(String name, String nameEncrypt, String type, String typeEncrypt, String doctorDivision1,
  //     String doctorDivision1Encrypt, String agencyHospitalid, String awsid) {
  //     Agency_Contact__c agency_contact = new Agency_Contact__c();
  //     agency_contact.Name = name;
  //     agency_contact.Name_Encrypted__c = nameEncrypt;
  //     agency_contact.Type__c = type;
  //     agency_contact.Type_Encrypted__c = typeEncrypt;
  //     agency_contact.Doctor_Division1__c = doctorDivision1;
  //     agency_contact.Doctor_Division1_Encrypted__c = doctorDivision1Encrypt;
  //     agency_contact.Agency_Hospital__c = agencyHospitalid;
  //     agency_contact.AWS_Data_Id__c = awsid;
  //     Map<String, String> acMap = new Map<String, String>();
  //     acMap = LightningUtil.insertAgencyContact(agency_contact);
  //     return acMap;
  // }
  //zhj 新方案改造 2022-12-21 start
  @RemoteAction
  @AuraEnabled
  public static Map<String, String> saveAgencyContact(
    String name,
    String type,
    String doctorDivision1,
    String agencyHospitalid,
    String awsid
  ) {
    Agency_Contact__c agency_contact = new Agency_Contact__c();
    agency_contact.Name = name;
    agency_contact.Type__c = type;
    agency_contact.Doctor_Division1__c = doctorDivision1;
    agency_contact.Agency_Hospital__c = agencyHospitalid;
    agency_contact.AWS_Data_Id__c = awsid;
    Map<String, String> acMap = new Map<String, String>();
    acMap = LightningUtil.insertAgencyContact(agency_contact);
    return acMap;
  }
  //zhj 新方案改造 2022-12-21 end
  // PIPL update Yin Mingjie 21/02/2022 end
  @RemoteAction
  @AuraEnabled
  public static List<Map<String, String>> getProductList(
    String dc,
    String opdsis
  ) {
    List<ProductTypes__c> ptList;
    if (opdsis != '') {
      ptList = [
        SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
        FROM ProductTypes__c
        WHERE
          DeleteFlg__c = FALSE
          AND Department_Cateogy_Text__c LIKE :dc
          AND OPD_SIS_Type__c = :opdsis
      ];
    } else {
      ptList = [
        SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
        FROM ProductTypes__c
        WHERE DeleteFlg__c = FALSE AND Department_Cateogy_Text__c LIKE :dc
      ];
    }
    List<Map<String, String>> pts = new List<Map<String, String>>();
    Map<String, String> blank = new Map<String, String>();
    blank.put('label', '');
    blank.put('value', '');
    pts.add(blank);
    for (ProductTypes__c pt : ptList) {
      Map<String, String> ptMap = new Map<String, String>();
      ptMap.put('label', pt.Name);
      ptMap.put('value', pt.Id);
      pts.add(ptMap);
    }
    return pts;
  }
  public void setalldata() {
    /*** create allselectlist ***/
    this.allselectlist = new Map<String, List<Map<String, String>>>();
    Map<String, List<Map<String, String>>> alldata = new Map<String, List<Map<String, String>>>();
    // プルダウン初期値の空白
    List<Map<String, String>> tmp = new List<Map<String, String>>();
    Map<String, String> space = new Map<String, String>();
    space.put('label', '');
    space.put('value', '');
    // PIPL update Yin Mingjie 21/02/2022 start
    @AuraEnabled public Map<String,String> awsurl{get;set;}
    @AuraEnabled public Map<String,String> contactawsurl{get;set;}
    space.put('awsid', '');
    // PIPL update Yin Mingjie 21/02/2022 end
    public WeeklyReportCmp() {
    space.put('selected', 'true');
    tmp.add(space);
    // 代理店担当者 AgencyPerson__c
    List<Contact> agency_person_data = LightningUtil.selectAgencyPerson();
    for (Contact var : agency_person_data) {
      Map<String, String> om = new Map<String, String>();
      om.put('label', var.Name);
      om.put('value', var.Id);
      // PIPL update Yin Mingjie 21/02/2022 start
      om.put('awsid', var.AWS_Data_Id__c);
      // PIPL update Yin Mingjie 21/02/2022 end
      om.put('selected', 'false');
      tmp.add(om);
    }
    // PIPL update Yin Mingjie 21/02/2022 start
    @RemoteAction
    @AuraEnabled
    public static Map<String,String> getAwsurl(String sobj){
        PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo(sobj);
        Map<String,String> awsmap = new Map<String,String>();
        awsmap.put('token', piIntegration.token);
        awsmap.put('newUrl', piIntegration.newUrl);
        awsmap.put('searchUrl', piIntegration.searchUrl);
        awsmap.put('transactionURL', piIntegration.transactionURL);
        return awsmap;
    }
    // @RemoteAction
    // @AuraEnabled
    // public static Map<String, String> saveAgencyContact(String name, String nameEncrypt, String type, String typeEncrypt, String doctorDivision1,
    //     String doctorDivision1Encrypt, String agencyHospitalid, String awsid) {
    //     Agency_Contact__c agency_contact = new Agency_Contact__c();
    this.allselectlist.put('AgencyPerson__c', tmp);
    //     agency_contact.Name = name;
    //     agency_contact.Name_Encrypted__c = nameEncrypt;
    //     agency_contact.Type__c = type;
    //     agency_contact.Type_Encrypted__c = typeEncrypt;
    //     agency_contact.Doctor_Division1__c = doctorDivision1;
    //     agency_contact.Doctor_Division1_Encrypted__c = doctorDivision1Encrypt;
    //     agency_contact.Agency_Hospital__c = agencyHospitalid;
    //     agency_contact.AWS_Data_Id__c = awsid;
    //     Map<String, String> acMap = new Map<String, String>();
    //     acMap = LightningUtil.insertAgencyContact(agency_contact);
    //     return acMap;
    // }
    //zhj 新方案改造 2022-12-21 start
    @RemoteAction
    @AuraEnabled
    public static Map<String, String> saveAgencyContact(String name, String type, String doctorDivision1,
        String agencyHospitalid, String awsid) {
        Agency_Contact__c agency_contact = new Agency_Contact__c();
        agency_contact.Name = name;
        agency_contact.Type__c = type;
        agency_contact.Doctor_Division1__c = doctorDivision1;
        agency_contact.Agency_Hospital__c = agencyHospitalid;
        agency_contact.AWS_Data_Id__c = awsid;
        Map<String, String> acMap = new Map<String, String>();
        acMap = LightningUtil.insertAgencyContact(agency_contact);
        return acMap;
    }
    //zhj 新方案改造 2022-12-21 end
    // PIPL update Yin Mingjie 21/02/2022 end
    @RemoteAction
    @AuraEnabled
    public static List<Map<String,String>> getProductList(String dc, String opdsis){
        List<ProductTypes__c> ptList;
        if (opdsis != '') {
            ptList = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dc and OPD_SIS_Type__c =:opdsis];
        } else {
            ptList = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dc];
        }
        List<Map<String,String>> pts = new List<Map<String,String>>();
        Map<String,String> blank = new Map<String,String>();
        blank.put('label', '');
        blank.put('value', '');
        pts.add(blank);
        for (ProductTypes__c pt : ptList) {
            Map<String,String> ptMap = new Map<String,String>();
            ptMap.put('label', pt.Name);
            ptMap.put('value', pt.Id);
            pts.add(ptMap);
        }
        return pts;
    }
    public void setalldata()
    {
        /*** create allselectlist ***/
        this.allselectlist = new Map<String,List<Map<String,String>>>();
        Map<String,List<Map<String,String>>> alldata = new Map<String,List<Map<String,String>>>();
        // プルダウン初期値の空白
        List<Map<String,String>> tmp = new List<Map<String,String>>();
        Map<String,String> space = new Map<String,String>();
        space.put('label', '');
        space.put('value', '');
        // PIPL update Yin Mingjie 21/02/2022 start
        space.put('awsid', '');
        // PIPL update Yin Mingjie 21/02/2022 end
        space.put('selected', 'true');
        tmp.add(space);
        // 代理店担当者 AgencyPerson__c
        List<Contact> agency_person_data = LightningUtil.selectAgencyPerson();
        for(Contact var : agency_person_data) {
            Map<String,String> om = new Map<String,String>();
            om.put('label', var.Name);
            om.put('value', var.Id);
            // PIPL update Yin Mingjie 21/02/2022 start
            om.put('awsid', var.AWS_Data_Id__c);
            // PIPL update Yin Mingjie 21/02/2022 end
            om.put('selected', 'false');
            tmp.add(om);
        }
        this.allselectlist.put('AgencyPerson__c', tmp);
        /*
    /*
        List<AgencyPerson__c> agency_person_data = [Select Id,Name,CurrencyIsoCode From AgencyPerson__c];
        List<Map<String,String>> tmp = new List<Map<String,String>>();
        Map<String,String> space = new Map<String,String>();
@@ -136,159 +161,217 @@
        }
        this.allselectlist.put('AgencyPerson__c', tmp);
        */
        // 科室分类 Department_Cateogy__c
        this.allselectlist.put('Department_Cateogy__c', WeeklyReportCmp.getPicklistValues('Agency_Report__c','Department_Cateogy__c'));
        // 活动区分 Purpose_Type__c
        this.allselectlist.put('Purpose_Type__c', WeeklyReportCmp.getPicklistValues('Agency_Report__c','Purpose_Type__c'));
    // 科室分类 Department_Cateogy__c
    this.allselectlist.put(
      'Department_Cateogy__c',
      WeeklyReportCmp.getPicklistValues(
        'Agency_Report__c',
        'Department_Cateogy__c'
      )
    );
        // 结果 Result__c
        this.allselectlist.put('Result__c', WeeklyReportCmp.getPicklistValues('Agency_Report__c','Result__c'));
    // 活动区分 Purpose_Type__c
    this.allselectlist.put(
      'Purpose_Type__c',
      WeeklyReportCmp.getPicklistValues('Agency_Report__c', 'Purpose_Type__c')
    );
        //阶段 StageName__c
        this.allselectlist.put('StageName__c', WeeklyReportCmp.getPicklistValues('Agency_Opportunity__c','StageName__c'));
        //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start
        // 支援需求 SupportNeeds__c
        this.allselectlist.put('SupportNeeds__c', WeeklyReportCmp.getPicklistValues('Agency_Report__c','SupportNeeds__c'));
        //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 end
        // 职位
//        this.allselectlist.put('visitor_title__c', WeeklyReportCmp.getPicklistValues('Agency_Report__c','visitor_title__c'));
    // 结果 Result__c
    this.allselectlist.put(
      'Result__c',
      WeeklyReportCmp.getPicklistValues('Agency_Report__c', 'Result__c')
    );
        // 製品区分
        //List<ProductTypes__c> ProductTypes = [select id,Name from ProductTypes__c];
        //List<Map<String,String>> tmp2 = new List<Map<String,String>>();
        //tmp2.add(space);
        //for(ProductTypes__c var : ProductTypes){
        //    Map<String,String> om = new Map<String,String>();
        //    om.put('label', var.Name);
        //    om.put('value', var.Id);
        //    om.put('selected', 'false');
        //    tmp2.add(om);
        //}
        //this.allselectlist.put('Product_Category__c', tmp2);
        // 見出し設定
        this.fieldsMap = new Map<String,String>();
        this.fieldsMap = this.getfiledsmap();
        //System.debug('fieldsMap is ' + fieldsMap);
        //System.debug('allselectlist is ' + this.allselectlist);
    //阶段 StageName__c
    this.allselectlist.put(
      'StageName__c',
      WeeklyReportCmp.getPicklistValues('Agency_Opportunity__c', 'StageName__c')
    );
    //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start
    // 支援需求 SupportNeeds__c
    this.allselectlist.put(
      'SupportNeeds__c',
      WeeklyReportCmp.getPicklistValues('Agency_Report__c', 'SupportNeeds__c')
    );
    //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 end
    // 职位
    //        this.allselectlist.put('visitor_title__c', WeeklyReportCmp.getPicklistValues('Agency_Report__c','visitor_title__c'));
        this.awsurl = getAwsurl('Agency_Contact__c');// 20220222 PI改造 by Bright
        this.contactawsurl = getAwsurl('Contact');// 20220222 PI改造 by Bright
    // 製品区分
    //List<ProductTypes__c> ProductTypes = [select id,Name from ProductTypes__c];
    //List<Map<String,String>> tmp2 = new List<Map<String,String>>();
    //tmp2.add(space);
    //for(ProductTypes__c var : ProductTypes){
    //    Map<String,String> om = new Map<String,String>();
    //    om.put('label', var.Name);
    //    om.put('value', var.Id);
    //    om.put('selected', 'false');
    //    tmp2.add(om);
    //}
    //this.allselectlist.put('Product_Category__c', tmp2);
    // 見出し設定
    this.fieldsMap = new Map<String, String>();
    this.fieldsMap = this.getfiledsmap();
    //System.debug('fieldsMap is ' + fieldsMap);
    //System.debug('allselectlist is ' + this.allselectlist);
    this.awsurl = getAwsurl('Agency_Contact__c'); // 20220222 PI改造 by Bright
    this.contactawsurl = getAwsurl('Contact'); // 20220222 PI改造 by Bright
  }
  public static List<Map<String, String>> getPicklistValues(
    String objstr,
    String fld
  ) {
    List<Map<String, String>> options = new List<Map<String, String>>();
    Map<String, String> space = new Map<String, String>();
    space.put('label', '');
    space.put('value', '');
    space.put('selected', 'true');
    options.add(space);
    Schema.sObjectType objType = Schema.getGlobalDescribe().get(objstr);
    Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
    map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
    list<Schema.PicklistEntry> values = fieldMap.get(fld)
      .getDescribe()
      .getPickListValues();
    system.debug(objstr + '=' + values);
    for (Schema.PicklistEntry a : values) {
      if (!a.isActive())
        continue;
      Map<String, String> ses = new Map<String, String>();
      ses.put('label', a.getLabel());
      ses.put('value', a.getValue());
      ses.put('selected', 'false');
      options.add(ses);
    }
    public static List<Map<String,String>> getPicklistValues(String objstr, String fld){
        List<Map<String,String>> options = new List<Map<String,String>>();
        Map<String,String> space = new Map<String,String>();
        space.put('label', '');
        space.put('value', '');
        space.put('selected', 'true');
        options.add(space);
    return options;
  }
        Schema.sObjectType objType = Schema.getGlobalDescribe().get(objstr);
        Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
        map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();
        list<Schema.PicklistEntry> values = fieldMap.get(fld).getDescribe().getPickListValues();
        system.debug(objstr + '=' + values);
        for (Schema.PicklistEntry a : values)
        {
            if (!a.isActive()) continue;
            Map<String,String> ses = new Map<String,String>();
            ses.put('label', a.getLabel());
            ses.put('value', a.getValue());
            ses.put('selected', 'false');
            options.add(ses);
        }
        return options;
  public Map<String, String> getfiledsmap() {
    Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
    Map<String, List<String>> typemap = new Map<String, List<String>>();
    Map<String, Schema.SObjectField> fieldMap = schemaMap.get(
        'Agency_Opportunity__c'
      )
      .getDescribe()
      .fields.getMap();
    Map<String, String> mappingmap = new Map<String, String>();
    for (Schema.SObjectField sfield : fieldMap.Values()) {
      Schema.describefieldresult dfield = sfield.getDescribe();
      String lab = '';
      lab = dfield.getLabel();
      system.debug(lab);
      mappingmap.put(dfield.name, lab);
    }
    public  Map<String,String> getfiledsmap()
    {
        Map<String,Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String,List<String>>   typemap = new Map<String,List<String>>  ();
        Map<String,Schema.SObjectField> fieldMap = schemaMap.get('Agency_Opportunity__c').getDescribe().fields.getMap();
        Map<String,String> mappingmap = new Map<String,String>();
        for(Schema.SObjectField sfield : fieldMap.Values())
        {
            Schema.describefieldresult dfield = sfield.getDescribe();
            String lab = '';
            lab = dfield.getLabel();
            system.debug(lab);
            mappingmap.put(dfield.name,lab);
        }
        fieldMap = schemaMap.get('Agency_Report__c').getDescribe().fields.getMap();
        for(Schema.SObjectField sfield : fieldMap.Values())
        {
            Schema.describefieldresult dfield = sfield.getDescribe();
            String lab = '';
            lab = dfield.getLabel();
            system.debug(lab);
            mappingmap.put(dfield.name,lab);
        }
        return mappingmap;
    fieldMap = schemaMap.get('Agency_Report__c').getDescribe().fields.getMap();
    for (Schema.SObjectField sfield : fieldMap.Values()) {
      Schema.describefieldresult dfield = sfield.getDescribe();
      String lab = '';
      lab = dfield.getLabel();
      system.debug(lab);
      mappingmap.put(dfield.name, lab);
    }
    @RemoteAction
    @AuraEnabled
    public static WeeklyReportCmp getalldata(){
        WeeklyReportCmp li = new WeeklyReportCmp();
        li.setalldata();
        return li;
    return mappingmap;
  }
  @RemoteAction
  @AuraEnabled
  public static WeeklyReportCmp getalldata() {
    WeeklyReportCmp li = new WeeklyReportCmp();
    li.setalldata();
    return li;
  }
  @RemoteAction
  @AuraEnabled
  public static ProductTypes__c getProduct(String id) {
    return [
      SELECT Department_Cateogy__c, OPD_Flg__c, Id, SIS_Flg__c
      FROM ProductTypes__c
      WHERE Id = :id
    ];
  }
  @RemoteAction
  @AuraEnabled
  public static String createReportHeader(
    String name,
    String s_date,
    String s_agency,
    String head_key
  ) {
    Agency_Report_Header__c agency_report_header = makeReportHeader(
      name,
      s_date,
      s_agency,
      head_key
    );
    agency_report_header = LightningUtil.upsertAgencyReportHeader(
      agency_report_header
    );
    return agency_report_header.Id;
  }
  public static Agency_Report_Header__c makeReportHeader(
    String name,
    String s_date,
    String s_agency,
    String head_key
  ) {
    Date week = Date.valueOf(s_date);
    Agency_Report_Header__c agency_report_header = new Agency_Report_Header__c();
    agency_report_header.Name = name + ' (' + s_date + ')';
    agency_report_header.HeaderInputKey__c = head_key;
    agency_report_header.Week__c = week;
    agency_report_header.Agency_Person2__c = s_agency;
    // READ OlympusCalendar__c
    system.debug(week);
    OlympusCalendar__c olympus_calendar = [
      SELECT Id, Date__c
      FROM OlympusCalendar__c
      WHERE Date__c = :week
    ];
    system.debug(olympus_calendar);
    String olympus_calendar_id = olympus_calendar.Id;
    if (olympus_calendar_id != '') {
      agency_report_header.OlympusDate__c = olympus_calendar_id;
    }
    @RemoteAction
    @AuraEnabled
    public static ProductTypes__c getProduct(String id){
        return [select Department_Cateogy__c, OPD_Flg__c, Id, SIS_Flg__c from ProductTypes__c where Id =:id];
    }
    @RemoteAction
    @AuraEnabled
    public static String createReportHeader(String name, String s_date, String s_agency, String head_key){
        Agency_Report_Header__c agency_report_header = makeReportHeader(name, s_date, s_agency, head_key);
    system.debug(agency_report_header);
    return agency_report_header;
  }
        agency_report_header = LightningUtil.upsertAgencyReportHeader(agency_report_header);
        system.debug('report Id:'+);
        return agency_report_header.Id;
    }
    public static Agency_Report_Header__c makeReportHeader(String name, String s_date, String s_agency, String head_key){
        Date week = Date.valueOf(s_date);
        Agency_Report_Header__c agency_report_header = new Agency_Report_Header__c();
        agency_report_header.Name = name + ' (' + s_date + ')';
        agency_report_header.HeaderInputKey__c = head_key;
        agency_report_header.Week__c = week;
        agency_report_header.Agency_Person2__c = s_agency;
  @RemoteAction
  @AuraEnabled
  public static List<Agency_Hospital_Link__c> getHospitalList(
    String hospital_name
  ) {
    hospital_name = '%' + hospital_name.trim() + '%';
    system.debug('hospital_name+++' + hospital_name);
    List<Agency_Hospital_Link__c> ahllist = [
      SELECT Hospital_Name_readonly__c, Id, Hospital__c
      FROM Agency_Hospital_Link__c
      WHERE
        Hospital_Name_readonly__c LIKE :hospital_name
        AND Agency_Campaign_Obj__c = TRUE
    ];
    system.debug('Agency_Campaign_Obj__c+++' + ahllist);
    return ahllist;
  }
        // READ OlympusCalendar__c
        system.debug(week);
        OlympusCalendar__c olympus_calendar = [select Id,Date__c from OlympusCalendar__c where Date__c=:week];
        system.debug(olympus_calendar);
        String olympus_calendar_id = olympus_calendar.Id;
        if (olympus_calendar_id != '') { agency_report_header.OlympusDate__c = olympus_calendar_id; }
        system.debug(agency_report_header);
        return agency_report_header;
    }
    @RemoteAction
    @AuraEnabled
    public static List<Agency_Hospital_Link__c> getHospitalList(String hospital_name) {
        hospital_name = '%' + hospital_name.trim() + '%';
        system.debug('hospital_name+++'+hospital_name);
        List<Agency_Hospital_Link__c> ahllist = [select Hospital_Name_readonly__c, Id, Hospital__c from Agency_Hospital_Link__c where Hospital_Name_readonly__c like :hospital_name and Agency_Campaign_Obj__c = true];
        system.debug('Agency_Campaign_Obj__c+++'+ahllist);
        return ahllist;
    }
    @RemoteAction
    @AuraEnabled
    // PIPL update Yin Mingjie 21/02/2022 start
    public static Map<String,Map<String,String>> getDoctorList(String hospital_id){
  @RemoteAction
  @AuraEnabled
  // PIPL update Yin Mingjie 21/02/2022 start
  public static Map<String, Map<String, String>> getDoctorList(
    String hospital_id
  ) {
    /*
    public static List<Map<String,String>> getDoctorList(String hospital_id){
        List<Map<String,String>> ret = new List<Map<String,String>>();
@@ -300,11 +383,15 @@
    */
    // PIPL update Yin Mingjie 21/02/2022 end
        // 戦略科室IDを取得して、それをもとに顧客をSELECT
        Agency_Hospital_Link__c ahl = [select Hospital__c from Agency_Hospital_Link__c where id = :hospital_id];
    // 戦略科室IDを取得して、それをもとに顧客をSELECT
    Agency_Hospital_Link__c ahl = [
      SELECT Hospital__c
      FROM Agency_Hospital_Link__c
      WHERE id = :hospital_id
    ];
        // PIPL update Yin Mingjie 21/02/2022 start
        /*
    // PIPL update Yin Mingjie 21/02/2022 start
    /*
        List<Agency_Contact__c> doctor_list = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c 
            FROM Agency_Contact__c WHERE Hospital_ID18__c=:ahl.Hospital__c order by Name];
@@ -319,32 +406,43 @@
            ret.add(tmp);
        }
        */
        List<Agency_Contact__c> doctor_list = [select id,Name,AWS_Data_Id__c,Doctor_Division1__c,Type__c,Agency_Hospital__c
            FROM Agency_Contact__c WHERE Hospital_ID18__c=:ahl.Hospital__c order by Name];
    List<Agency_Contact__c> doctor_list = [
      SELECT
        id,
        Name,
        AWS_Data_Id__c,
        Doctor_Division1__c,
        Type__c,
        Agency_Hospital__c
      FROM Agency_Contact__c
      WHERE Hospital_ID18__c = :ahl.Hospital__c
      ORDER BY Name
    ];
        Map<String,Map<String,String>> ret_test = new Map<String,Map<String,String>>();
        for (Agency_Contact__c row : doctor_list)
        {
            if(row.AWS_Data_Id__c == '' || row.AWS_Data_Id__c == null){
                continue;
            }
            Map<String,String> tmp = new Map<String,String>();
            tmp.put('label', row.Name);
            tmp.put('value', row.Id);
            tmp.put('awsid', row.AWS_Data_Id__c);
            tmp.put('selected', 'false');
            tmp.put('Doctor_Division1__c', row.Doctor_Division1__c);
            ret_test.put(row.AWS_Data_Id__c, tmp);
        }
        PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo('Agency_Contact__c');
        Map<String, String> sre = new Map<String, String>();
        sre.put('token', piIntegration.token);
        sre.put('searchUrl', piIntegration.searchUrl);
        ret_test.put('sre', sre);
        return ret_test;
        // PIPL update Yin Mingjie 21/02/2022 end
        /*
    Map<String, Map<String, String>> ret_test = new Map<String, Map<String, String>>();
    for (Agency_Contact__c row : doctor_list) {
      if (row.AWS_Data_Id__c == '' || row.AWS_Data_Id__c == null) {
        continue;
      }
      Map<String, String> tmp = new Map<String, String>();
      tmp.put('label', row.Name);
      tmp.put('value', row.Id);
      tmp.put('awsid', row.AWS_Data_Id__c);
      tmp.put('selected', 'false');
      tmp.put('Doctor_Division1__c', row.Doctor_Division1__c);
      ret_test.put(row.AWS_Data_Id__c, tmp);
    }
    PIHelper.PIIntegration piIntegration = PIHelper.getPIIntegrationInfo(
      'Agency_Contact__c'
    );
    Map<String, String> sre = new Map<String, String>();
    sre.put('token', piIntegration.token);
    sre.put('searchUrl', piIntegration.searchUrl);
    ret_test.put('sre', sre);
    return ret_test;
    // PIPL update Yin Mingjie 21/02/2022 end
    /*
        String record_type_id = LightningUtil.getRecordTypeId(department);
        List<Contact> doctor_list = LightningUtil.selectContactList(hospital_id, record_type_id);
@@ -360,14 +458,14 @@
        }
        */
        // PIPL update Yin Mingjie 21/02/2022 start
        /*
    // PIPL update Yin Mingjie 21/02/2022 start
    /*
        return ret;
        */
        // PIPL update Yin Mingjie 21/02/2022 end
    }
    /*
    // PIPL update Yin Mingjie 21/02/2022 end
  }
  /*
    @RemoteAction
    @AuraEnabled
    public static List<Map<String,String>> getOpportunityList(String record_type, String hospital_link_id){
@@ -393,1304 +491,1985 @@
    }
    */
    @RemoteAction
    @AuraEnabled//SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeedsc ,String SupportNeedsc
    public static String saveAgencyReport(String Department_Cateogy, String Purpose_Type,String SupportNeedsc, String Agency_Report_Header,
            String Agency_Hospital, String Person_In_Charge2, String doctor, String Submit_date,
            String Product_Category1, String Product_Category2, String Product_Category3,
            String Result, String Opportunity, String StageName, String oppAmount, String oppOCMPrice, String Close_Forecasted_Date, String Report_Date)
    {
        Agency_Report__c agency_report = makeAgencyReport(Department_Cateogy, Purpose_Type, Agency_Report_Header,
            Agency_Hospital, Person_In_Charge2, doctor, Submit_date,
            Product_Category1, Product_Category2, Product_Category3,//SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeedsc   ,SupportNeedsc
            Result, Opportunity, StageName, oppAmount, oppOCMPrice, Close_Forecasted_Date, Report_Date,SupportNeedsc);
  @RemoteAction
  @AuraEnabled //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeedsc ,String SupportNeedsc
  public static String saveAgencyReport(
    String Department_Cateogy,
    String Purpose_Type,
    String SupportNeedsc,
    String Agency_Report_Header,
    String Agency_Hospital,
    String Person_In_Charge2,
    String doctor,
    String Submit_date,
    String Product_Category1,
    String Product_Category2,
    String Product_Category3,
    String Result,
    String Opportunity,
    String StageName,
    String oppAmount,
    String oppOCMPrice,
    String Close_Forecasted_Date,
    String Report_Date
  ) {
    Agency_Report__c agency_report = makeAgencyReport(
      Department_Cateogy,
      Purpose_Type,
      Agency_Report_Header,
      Agency_Hospital,
      Person_In_Charge2,
      doctor,
      Submit_date,
      Product_Category1,
      Product_Category2,
      Product_Category3, //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeedsc   ,SupportNeedsc
      Result,
      Opportunity,
      StageName,
      oppAmount,
      oppOCMPrice,
      Close_Forecasted_Date,
      Report_Date,
      SupportNeedsc
    );
        agency_report = LightningUtil.insertAgencyReport(agency_report);
        return agency_report.Id;
    agency_report = LightningUtil.insertAgencyReport(agency_report);
    return agency_report.Id;
  }
  public static Agency_Report__c makeAgencyReport(
    String Department_Cateogy,
    String Purpose_Type,
    String Agency_Report_Header,
    String Agency_Hospital,
    String Person_In_Charge2,
    String doctor,
    String Submit_date,
    String Product_Category1,
    String Product_Category2,
    String Product_Category3, //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeeds__c   ,String SupportNeedsc
    String Result,
    String Opportunity,
    String StageName,
    String oppAmount,
    String oppOCMPrice,
    String Close_Forecasted_Date,
    String Report_Date,
    String SupportNeedsc
  ) {
    Agency_Report__c agency_report = new Agency_Report__c();
    Date week = Date.valueOf(Submit_date);
    agency_report.Submit_date__c = week;
    Date reportDate = Date.valueOf(Report_Date);
    agency_report.Report_Date__c = reportDate;
    // MaxActivityDate__c 更新
    if (Person_In_Charge2 != '') {
      agency_report.Person_In_Charge2__c = Person_In_Charge2;
      //Contact contact = LightningUtil.selectContact(Person_In_Charge2)[0];
      //LightningUtil.updateAccMaxActivityDate(contact.AccountId, reportDate);
    } else {
      agency_report.Person_In_Charge2__c = null;
    }
    public static Agency_Report__c makeAgencyReport(String Department_Cateogy, String Purpose_Type, String Agency_Report_Header,
            String Agency_Hospital, String Person_In_Charge2, String doctor, String Submit_date,
            String Product_Category1, String Product_Category2, String Product_Category3,//SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeeds__c   ,String SupportNeedsc
            String Result, String Opportunity, String StageName, String oppAmount, String oppOCMPrice, String Close_Forecasted_Date, String Report_Date,String SupportNeedsc)
    {
        Agency_Report__c agency_report = new Agency_Report__c();
        Date week = Date.valueOf(Submit_date);
        agency_report.Submit_date__c = week;
        Date reportDate = Date.valueOf(Report_Date);
        agency_report.Report_Date__c = reportDate;
        // MaxActivityDate__c 更新
        if (Person_In_Charge2 != '') {
            agency_report.Person_In_Charge2__c = Person_In_Charge2;
            //Contact contact = LightningUtil.selectContact(Person_In_Charge2)[0];
            //LightningUtil.updateAccMaxActivityDate(contact.AccountId, reportDate);
        } else {
            agency_report.Person_In_Charge2__c = null;
        }
    if (Agency_Hospital != '') {
      LightningUtil.updateAccMaxActivityDate(Agency_Hospital, week);
    }
        if (Agency_Hospital != '')  {
            LightningUtil.updateAccMaxActivityDate(Agency_Hospital, week);
    // READ OlympusCalendar__c
    //OlympusCalendar__c olympus_calendar = [select Id,Date__c from OlympusCalendar__c where Date__c=:week];
    //String olympus_calendar_id = olympus_calendar.Id;
    // WRITE Agency Report__c
    if (doctor != '') {
      agency_report.doctor2__c = doctor;
    } else {
      agency_report.doctor2__c = null;
    }
    if (Department_Cateogy != '') {
      agency_report.Department_Cateogy__c = Department_Cateogy;
    }
    if (Purpose_Type != '') {
      agency_report.Purpose_Type__c = Purpose_Type;
    }
    //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start
    if (SupportNeedsc != '') {
      agency_report.SupportNeeds__c = SupportNeedsc;
    }
    //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 end
    if (Agency_Report_Header != '') {
      agency_report.Agency_Report_Header__c = Agency_Report_Header;
    }
    if (Agency_Hospital != '') {
      agency_report.Agency_Hospital__c = Agency_Hospital;
    }
    //if (olympus_calendar_id != '') { agency_report.Submit_date_Calendar__c = olympus_calendar_id; }
    if (Product_Category1 != '') {
      agency_report.Product_Category1__c = Product_Category1;
    }
    if (Product_Category2 != '') {
      agency_report.Product_Category2__c = Product_Category2;
    }
    if (Product_Category3 != '') {
      agency_report.Product_Category3__c = Product_Category3;
    }
    if (Result != '') {
      agency_report.Result__c = Result;
    }
    if (Opportunity != '') {
      agency_report.Opportunity__c = Opportunity;
      if (
        StageName != '' ||
        oppAmount != '' ||
        Close_Forecasted_Date != '' ||
        oppOCMPrice != ''
      ) {
        Agency_Opportunity__c aopp = [
          SELECT Id, StageName__c, Amount__c, Close_Forecasted_Date__c
          FROM Agency_Opportunity__c
          WHERE Id = :Opportunity
        ];
        if (StageName != '') {
          aopp.StageName__c = StageName;
        }
        // READ OlympusCalendar__c
        //OlympusCalendar__c olympus_calendar = [select Id,Date__c from OlympusCalendar__c where Date__c=:week];
        //String olympus_calendar_id = olympus_calendar.Id;
        // WRITE Agency Report__c
        if (doctor != '') { agency_report.doctor2__c = doctor; } else { agency_report.doctor2__c = null; }
        if (Department_Cateogy != '') { agency_report.Department_Cateogy__c = Department_Cateogy; }
        if (Purpose_Type != '') { agency_report.Purpose_Type__c = Purpose_Type; }
        //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start
        if (SupportNeedsc != '') { agency_report.SupportNeeds__c = SupportNeedsc; }
        //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 end
        if (Agency_Report_Header != '') { agency_report.Agency_Report_Header__c = Agency_Report_Header; }
        if (Agency_Hospital != '') { agency_report.Agency_Hospital__c = Agency_Hospital; }
        //if (olympus_calendar_id != '') { agency_report.Submit_date_Calendar__c = olympus_calendar_id; }
        if (Product_Category1 != '') { agency_report.Product_Category1__c = Product_Category1; }
        if (Product_Category2 != '') { agency_report.Product_Category2__c = Product_Category2; }
        if (Product_Category3 != '') { agency_report.Product_Category3__c = Product_Category3; }
        if (Result != '') { agency_report.Result__c = Result; }
        if (Opportunity != '') {
            agency_report.Opportunity__c = Opportunity;
            if (StageName != '' || oppAmount != '' || Close_Forecasted_Date != '' || oppOCMPrice != '') {
                Agency_Opportunity__c aopp = [select Id, StageName__c, Amount__c, Close_Forecasted_Date__c from Agency_Opportunity__c where Id = :Opportunity];
                if (StageName != '') {
                    aopp.StageName__c = StageName;
                }
                if (String.isNotBlank(oppAmount)) {
                    Decimal amt = Decimal.valueOf(oppAmount);
                    aopp.Amount__c = amt;
                }
                if (String.isNotBlank(oppOCMPrice)) {
                    Decimal amt = Decimal.valueOf(oppOCMPrice);
                    aopp.OCMSale_Price__c = amt;
                }
                if (Close_Forecasted_Date != '') {
                    Date closeForecastedDate = Date.valueOf(Close_Forecasted_Date);
                    aopp.Close_Forecasted_Date__c = closeForecastedDate;
                }
                update aopp;
        if (String.isNotBlank(oppAmount)) {
          Decimal amt = Decimal.valueOf(oppAmount);
          aopp.Amount__c = amt;
        }
        if (String.isNotBlank(oppOCMPrice)) {
          Decimal amt = Decimal.valueOf(oppOCMPrice);
          aopp.OCMSale_Price__c = amt;
        }
        if (Close_Forecasted_Date != '') {
          Date closeForecastedDate = Date.valueOf(Close_Forecasted_Date);
          aopp.Close_Forecasted_Date__c = closeForecastedDate;
        }
        update aopp;
      }
    }
    system.debug(agency_report);
    return agency_report;
  }
  @RemoteAction
  @AuraEnabled
  public static String editAgencyReport(
    String Agency_Report_Id,
    String Department_Cateogy,
    String Purpose_Type,
    String SupportNeedsc,
    String Agency_Report_Header,
    String Agency_Hospital,
    String Person_In_Charge2,
    String doctor,
    String Submit_date,
    String Product_Category1,
    String Product_Category2,
    String Product_Category3, //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeeds__c  ,String SupportNeedsc
    String Result,
    String Opportunity,
    String StageName,
    String oppAmount,
    String oppOCMPrice,
    String Close_Forecasted_Date,
    String Report_Date
  ) {
    if (String.isBlank(Agency_Report_Id)) {
      return null;
    } //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeeds__c   ,SupportNeeds__c
    // Agency_Report__c agency_report = [select Id, Name, Department_Cateogy__c, Purpose_Type__c,SupportNeeds__c, Agency_Hospital__c,
    //                                   Person_In_Charge2__c, doctor2__c, Submit_date__c, Product_Category__c, Result__c, visitor_title__c, Opportunity__c
    //                                   from Agency_Report__c where id=:Agency_Report_Id];
    Agency_Report__c agency_report = new Agency_Report__c();
    if (Test.isRunningTest()) {
      List<Agency_Report__c> agency_report_tests = [
        SELECT
          Id,
          Name,
          Department_Cateogy__c,
          Purpose_Type__c,
          SupportNeeds__c,
          Agency_Hospital__c,
          Person_In_Charge2__c,
          doctor2__c,
          Submit_date__c,
          Product_Category__c,
          Result__c,
          visitor_title__c,
          Opportunity__c
        FROM Agency_Report__c
        LIMIT 1
      ];
      agency_report = agency_report_tests[0];
    } else {
      agency_report = [
        SELECT
          Id,
          Name,
          Department_Cateogy__c,
          Purpose_Type__c,
          SupportNeeds__c,
          Agency_Hospital__c,
          Person_In_Charge2__c,
          doctor2__c,
          Submit_date__c,
          Product_Category__c,
          Result__c,
          visitor_title__c,
          Opportunity__c
        FROM Agency_Report__c
        WHERE id = :Agency_Report_Id
      ];
    }
    Date week = Date.valueOf(Submit_date);
    agency_report.Submit_date__c = week;
    Date reportDate = Date.valueOf(Report_Date);
    agency_report.Report_Date__c = reportDate;
    // MaxActivityDate__c 更新
    if (Person_In_Charge2 != '') {
      agency_report.Person_In_Charge2__c = Person_In_Charge2;
      //Contact contact = LightningUtil.selectContact(Person_In_Charge2)[0];
      //LightningUtil.updateAccMaxActivityDate(contact.AccountId, reportDate);
    } else {
      agency_report.Person_In_Charge2__c = null;
    }
    if (Agency_Hospital != '') {
      LightningUtil.updateAccMaxActivityDate(Agency_Hospital, week);
    }
    system.debug('Purpose_Type+++==++===' + Purpose_Type);
    // WRITE Agency Report__c
    if (doctor != '') {
      agency_report.doctor2__c = doctor;
    } else {
      agency_report.doctor2__c = null;
    }
    if (Department_Cateogy != '') {
      agency_report.Department_Cateogy__c = Department_Cateogy;
    } else {
      agency_report.Department_Cateogy__c = null;
    }
    if (Purpose_Type != '') {
      agency_report.Purpose_Type__c = Purpose_Type;
    } else {
      agency_report.Purpose_Type__c = null;
    }
    //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeeds__c
    if (SupportNeedsc != '') {
      agency_report.SupportNeeds__c = SupportNeedsc;
    } else {
      agency_report.SupportNeeds__c = null;
    }
    if (Agency_Hospital != '') {
      agency_report.Agency_Hospital__c = Agency_Hospital;
    } else {
      agency_report.Agency_Hospital__c = null;
    }
    if (Product_Category1 != '') {
      agency_report.Product_Category1__c = Product_Category1;
    } else {
      agency_report.Product_Category1__c = null;
    }
    if (Product_Category2 != '') {
      agency_report.Product_Category2__c = Product_Category2;
    } else {
      agency_report.Product_Category2__c = null;
    }
    if (Product_Category3 != '') {
      agency_report.Product_Category3__c = Product_Category3;
    } else {
      agency_report.Product_Category3__c = null;
    }
    //if (Product_Category != '') { agency_report.Product_Category__c = Product_Category; } else { agency_report.Product_Category__c = null; }
    if (Result != '') {
      agency_report.Result__c = Result;
    } else {
      agency_report.Result__c = null;
    }
    //if (Opportunity != '') { agency_report.Opportunity__c = Opportunity; } else { agency_report.Opportunity__c = null; }
    if (Opportunity != '') {
      agency_report.Opportunity__c = Opportunity;
      if (
        StageName != '' ||
        oppAmount != '' ||
        Close_Forecasted_Date != '' ||
        oppOCMPrice != ''
      ) {
        Agency_Opportunity__c aopp = [
          SELECT Id, StageName__c, Amount__c, Close_Forecasted_Date__c
          FROM Agency_Opportunity__c
          WHERE Id = :Opportunity
        ];
        if (StageName != '') {
          aopp.StageName__c = StageName;
        }
        if (String.isNotBlank(oppAmount)) {
          Decimal amt = Decimal.valueOf(oppAmount);
          aopp.Amount__c = amt;
        }
        if (String.isNotBlank(oppOCMPrice)) {
          Decimal amt = Decimal.valueOf(oppOCMPrice);
          aopp.OCMSale_Price__c = amt;
        }
        if (Close_Forecasted_Date != '') {
          Date closeForecastedDate = Date.valueOf(Close_Forecasted_Date);
          aopp.Close_Forecasted_Date__c = closeForecastedDate;
        }
        update aopp;
      }
    } else {
      agency_report.Opportunity__c = null;
    }
    system.debug(agency_report);
    agency_report = LightningUtil.updateAgencyReport(agency_report);
    return agency_report.Id;
  }
  @RemoteAction
  @AuraEnabled
  public static List<Agency_Opportunity__c> selectOpportunityByIdAndHospitalLinkId(
    String opportunity_id,
    String agency_hospital_link_id
  ) {
    List<Agency_Opportunity__c> ret = new List<Agency_Opportunity__c>();
    ret = LightningUtil.selectOpportunityByIdAndHospitalLinkId(
      opportunity_id,
      agency_hospital_link_id
    );
    return ret;
  }
  @RemoteAction
  @AuraEnabled
  public static WeeklyReportCmp getReports(String date_str, String person_str) {
    WeeklyReportCmp li = new WeeklyReportCmp();
    li.get_reports(date_str, person_str);
    return li;
  }
  public void get_reports(String date_str, String person_str) {
    // 週報データを取得
    Date week = Date.valueOf(date_str);
    this.reports = LightningUtil.selectAgencyReport(week, person_str);
  }
  @RemoteAction
  @AuraEnabled
  public static List<Agency_Report__c> getReportsById(String report_id) {
    List<Agency_Report__c> ret = new List<Agency_Report__c>();
    ret = LightningUtil.selectAgencyReportById(report_id);
    return ret;
  }
  // 批量添加周报by vivek start
  @RemoteAction
  @AuraEnabled
  public static List<Agency_Report__c> getReportsByDate(
    String date1,
    String date2
  ) {
    Date date1_date = Date.valueOf(date1);
    Date date2_date = Date.valueOf(date2);
    WeeklyReportCmp li = new WeeklyReportCmp();
    // li.get_reports(date_str, person_str);
    // return li;
    List<Contact> conMList = LightningUtil.selectAgencyPerson();
    // LightningUtil.selectAgencyPerson();
    System.debug('=====' + conMList);
    // List<Agency_Report__c> reportlist = [Select Id, Name, Report_Date__c, Product_Category1__r.Name, Product_Category2__r.Name, Product_Category3__r.Name, Product_Category1__c, Product_Category2__c, Product_Category3__c, Department_Cateogy__c, Purpose_Type__c, Agency_Report_Header__c, Agency_Hospital__r.Name, Agency_Hospital__r.Hospital__c, OppName__c,
    //                     Person_In_Charge2__c, Person_In_Charge2__r.Name, doctor2__c, doctor2__r.Name, Submit_date__c,
    //                     Product_Category__c, Product_Category__r.Name, Result__c, visitor_title__c, Opportunity__c, Opportunity__r.Name
    //                     From Agency_Report__c
    //                     where Person_In_Charge2__c in :conMList and Report_Date__c >= :date1_date and Report_Date__c <= :date2_date ];
    // return reportlist;
    return LightningUtil.selectMAgencyReport(date1_date, date2_date, conMList);
  }
  public List<contact> selectMAgencyPerson() {
    String login_user_id = UserInfo.getUserId();
    // return [select id, Name, Agency_User__c from contact where Agency_User__c = true and Isactive__c = '有效' and AccountId in (select AccountId from User where id=:login_user_id)];
    // return [select id, Name, Agency_User__c from contact where Agency_User__c = true  and AccountId in (select AccountId from User where id=:login_user_id)];
    return [SELECT id, Name, Agency_User__c FROM contact];
  }
  // fy 导入 20220424 start
  public class GeDatass {
    public String dataId;
    public String doctorDivision1;
    //public String doctorDivision1Encrypt;         //zhj MEBG新方案改造 2022-11-29
    public Integer isDelete;
    public String name;
    //public String nameEncrypt;                    //zhj MEBG新方案改造 2022-11-29
    public String sfRecordId;
    public String type;
    //public String typeEncrypt;                    //zhj MEBG新方案改造 2022-11-29
  }
  @AuraEnabled
  public static String processDataAWSId(String fileData) {
    System.debug('fileData:::' + filedata);
    String errorMag = '';
    // 创建周报
    try {
      if (fileData != null) {
        String[] fileLines = new List<String>{};
        fileLines = fileData.split('\n');
        // 经销商医院名称list
        List<String> ahlNameList = new List<String>();
        //for content
        system.debug('fileLines.size()==============>' + fileLines.size());
        for (Integer i = 1, j = fileLines.size(); i < j; i++) {
          List<String> inputvalues = new List<String>();
          inputvalues = fileLines[i].split(',');
          if (inputvalues != null) {
            if (inputvalues[2] == '' || inputvalues[2] == null) {
              errorMag += 'error1 第' + i + '行数据医院不能为空';
            }
            ahlNameList.add(inputvalues[2]);
          }
        }
        system.debug(agency_report);
        return agency_report;
    }
        // 经销商医院的ocsm医院id的list
        List<String> ahlOcsmIdList = new List<String>();
        System.debug('ahlNameList = ' + ahlNameList);
        List<Agency_Hospital_Link__c> ahlList = [
          SELECT id, name, Hospital__c, MaxActivityDate__c
          FROM Agency_Hospital_Link__c
          WHERE name = :ahlNameList AND Agency_Campaign_Obj__c = TRUE
        ];
    @RemoteAction
    @AuraEnabled
    public static String editAgencyReport(String Agency_Report_Id, String Department_Cateogy, String Purpose_Type,String SupportNeedsc, String Agency_Report_Header,
                                        String Agency_Hospital, String Person_In_Charge2, String doctor, String Submit_date,
                                        String Product_Category1, String Product_Category2, String Product_Category3, //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeeds__c  ,String SupportNeedsc
                                        String Result, String Opportunity, String StageName, String oppAmount, String oppOCMPrice, String Close_Forecasted_Date, String Report_Date)
    {
        if (String.isBlank(Agency_Report_Id)) {
            return null;
        }//SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeeds__c   ,SupportNeeds__c
        // Agency_Report__c agency_report = [select Id, Name, Department_Cateogy__c, Purpose_Type__c,SupportNeeds__c, Agency_Hospital__c,
        //                                   Person_In_Charge2__c, doctor2__c, Submit_date__c, Product_Category__c, Result__c, visitor_title__c, Opportunity__c
        //                                   from Agency_Report__c where id=:Agency_Report_Id];
        Agency_Report__c agency_report = new Agency_Report__c();
        if(Test.isRunningTest()){
            List<Agency_Report__c> agency_report_tests = [select Id, Name, Department_Cateogy__c, Purpose_Type__c,SupportNeeds__c, Agency_Hospital__c,
                                          Person_In_Charge2__c, doctor2__c, Submit_date__c, Product_Category__c, Result__c, visitor_title__c, Opportunity__c
                                          from Agency_Report__c limit 1];
            agency_report = agency_report_tests[0];
        }else {
            agency_report = [select Id, Name, Department_Cateogy__c, Purpose_Type__c,SupportNeeds__c, Agency_Hospital__c,
                                           Person_In_Charge2__c, doctor2__c, Submit_date__c, Product_Category__c, Result__c, visitor_title__c, Opportunity__c
                                           from Agency_Report__c where id=:Agency_Report_Id];
        for (Agency_Hospital_Link__c ahl : ahlList) {
          ahlOcsmIdList.add(ahl.Hospital__c);
        }
        Date week = Date.valueOf(Submit_date);
        agency_report.Submit_date__c = week;
        Date reportDate = Date.valueOf(Report_Date);
        agency_report.Report_Date__c = reportDate;
        List<Agency_Contact__c> doctor2list = new List<Agency_Contact__c>();
        System.debug('ahlOcsmIdList = ' + ahlOcsmIdList);
        if (!Test.isRunningTest())
          doctor2list = [
            SELECT
              id,
              Name,
              Doctor_Division1__c,
              Type__c,
              Agency_Hospital__c,
              AWS_Data_Id__c
            FROM Agency_Contact__c
            WHERE Hospital_ID18__c = :ahlOcsmIdList
            ORDER BY Name
          ]; //zhj 新方案改造 2022-12-21 去掉Name_Encrypted__c
        // MaxActivityDate__c 更新
        if (Person_In_Charge2 != '') {
            agency_report.Person_In_Charge2__c = Person_In_Charge2;
            //Contact contact = LightningUtil.selectContact(Person_In_Charge2)[0];
            //LightningUtil.updateAccMaxActivityDate(contact.AccountId, reportDate);
        } else {
            agency_report.Person_In_Charge2__c = null;
        if (errorMag != '') {
          return errorMag;
        }
        if (Agency_Hospital != '')  {
            LightningUtil.updateAccMaxActivityDate(Agency_Hospital, week);
        }
        system.debug('Purpose_Type+++==++==='+Purpose_Type);
        // WRITE Agency Report__c
        if (doctor != '') { agency_report.doctor2__c = doctor; } else { agency_report.doctor2__c = null; }
        if (Department_Cateogy != '') { agency_report.Department_Cateogy__c = Department_Cateogy; } else { agency_report.Department_Cateogy__c = null; }
        if (Purpose_Type != '') { agency_report.Purpose_Type__c = Purpose_Type; } else { agency_report.Purpose_Type__c = null; }
         //SWAG-CBX68C fy 【委托】DAMS系统周报模块内容需求增加 start SupportNeeds__c
         if (SupportNeedsc != '') { agency_report.SupportNeeds__c = SupportNeedsc; } else { agency_report.SupportNeeds__c = null; }
        if (Agency_Hospital != '') { agency_report.Agency_Hospital__c = Agency_Hospital; } else { agency_report.Agency_Hospital__c = null; }
        if (Product_Category1 != '') { agency_report.Product_Category1__c = Product_Category1; } else { agency_report.Product_Category1__c = null; }
        if (Product_Category2 != '') { agency_report.Product_Category2__c = Product_Category2; } else { agency_report.Product_Category2__c = null; }
        if (Product_Category3 != '') { agency_report.Product_Category3__c = Product_Category3; } else { agency_report.Product_Category3__c = null; }
        //if (Product_Category != '') { agency_report.Product_Category__c = Product_Category; } else { agency_report.Product_Category__c = null; }
        if (Result != '') { agency_report.Result__c = Result; } else { agency_report.Result__c = null; }
        //if (Opportunity != '') { agency_report.Opportunity__c = Opportunity; } else { agency_report.Opportunity__c = null; }
        if (Opportunity != '') {
            agency_report.Opportunity__c = Opportunity;
            if (StageName != '' || oppAmount != '' || Close_Forecasted_Date != '' || oppOCMPrice != '') {
                Agency_Opportunity__c aopp = [select Id, StageName__c, Amount__c, Close_Forecasted_Date__c from Agency_Opportunity__c where Id = :Opportunity];
                if (StageName != '') {
                    aopp.StageName__c = StageName;
                }
                if (String.isNotBlank(oppAmount)) {
                    Decimal amt = Decimal.valueOf(oppAmount);
                    aopp.Amount__c = amt;
                }
                if (String.isNotBlank(oppOCMPrice)) {
                    Decimal amt = Decimal.valueOf(oppOCMPrice);
                    aopp.OCMSale_Price__c = amt;
                }
                if (Close_Forecasted_Date != '') {
                    Date closeForecastedDate = Date.valueOf(Close_Forecasted_Date);
                    aopp.Close_Forecasted_Date__c = closeForecastedDate;
                }
                update aopp;
            }
        } else { agency_report.Opportunity__c = null; }
        system.debug(agency_report);
        agency_report = LightningUtil.updateAgencyReport(agency_report);
        return agency_report.Id;
        String doctor2listStr = JSON.serialize(doctor2list);
        System.debug('doctor2listStr = ' + doctor2listStr);
        return doctor2listStr;
      }
    } catch (Exception e) {
      System.debug('exception' + e);
      return e.getLineNumber() + 'exception:' + e;
    }
    @RemoteAction
    @AuraEnabled
    public static List<Agency_Opportunity__c> selectOpportunityByIdAndHospitalLinkId(String opportunity_id, String agency_hospital_link_id) {
        List<Agency_Opportunity__c> ret = new List<Agency_Opportunity__c>();
        ret = LightningUtil.selectOpportunityByIdAndHospitalLinkId(opportunity_id, agency_hospital_link_id);
        return ret;
    }
    @RemoteAction
    @AuraEnabled
    public static WeeklyReportCmp getReports(String date_str, String person_str) {
        WeeklyReportCmp li = new WeeklyReportCmp();
        li.get_reports(date_str, person_str);
        return li;
    }
    public void get_reports(String date_str, String person_str) {
        // 週報データを取得
        Date week = Date.valueOf(date_str);
        this.reports = LightningUtil.selectAgencyReport(week, person_str);
    }
    @RemoteAction
    @AuraEnabled
    public static List<Agency_Report__c> getReportsById(String report_id) {
        List<Agency_Report__c> ret = new List<Agency_Report__c>();
        ret = LightningUtil.selectAgencyReportById(report_id);
        return ret;
    }
    // 批量添加周报by vivek start
    @RemoteAction
    @AuraEnabled
    public static List<Agency_Report__c> getReportsByDate(String date1, String date2) {
        Date date1_date = Date.valueOf(date1);
        Date date2_date = Date.valueOf(date2);
        WeeklyReportCmp li = new WeeklyReportCmp();
        // li.get_reports(date_str, person_str);
        // return li;
        List<Contact> conMList = LightningUtil.selectAgencyPerson();
        // LightningUtil.selectAgencyPerson();
        System.debug('====='+conMList);
        // List<Agency_Report__c> reportlist = [Select Id, Name, Report_Date__c, Product_Category1__r.Name, Product_Category2__r.Name, Product_Category3__r.Name, Product_Category1__c, Product_Category2__c, Product_Category3__c, Department_Cateogy__c, Purpose_Type__c, Agency_Report_Header__c, Agency_Hospital__r.Name, Agency_Hospital__r.Hospital__c, OppName__c,
        //                     Person_In_Charge2__c, Person_In_Charge2__r.Name, doctor2__c, doctor2__r.Name, Submit_date__c,
        //                     Product_Category__c, Product_Category__r.Name, Result__c, visitor_title__c, Opportunity__c, Opportunity__r.Name
        //                     From Agency_Report__c
        //                     where Person_In_Charge2__c in :conMList and Report_Date__c >= :date1_date and Report_Date__c <= :date2_date ];
        // return reportlist;
        return LightningUtil.selectMAgencyReport(date1_date, date2_date, conMList);
    }
    public List<contact> selectMAgencyPerson() {
        String login_user_id = UserInfo.getUserId();
        // return [select id, Name, Agency_User__c from contact where Agency_User__c = true and Isactive__c = '有效' and AccountId in (select AccountId from User where id=:login_user_id)];
        // return [select id, Name, Agency_User__c from contact where Agency_User__c = true  and AccountId in (select AccountId from User where id=:login_user_id)];
        return [select id, Name, Agency_User__c from contact];
    }
    // fy 导入 20220424 start
    public class GeDatass {
        public String dataId;
        public String doctorDivision1;
        //public String doctorDivision1Encrypt;         //zhj MEBG新方案改造 2022-11-29
        public Integer isDelete;
        public String name;
        //public String nameEncrypt;                    //zhj MEBG新方案改造 2022-11-29
        public String sfRecordId;
        public String type;
        //public String typeEncrypt;                    //zhj MEBG新方案改造 2022-11-29
    }
    @AuraEnabled
    public static String processDataAWSId(String fileData) {
       System.debug('fileData:::'+filedata);
       String errorMag = '';
       // 创建周报
       try{
            if(fileData!=null){
                String[] fileLines = new String[]{};
                fileLines = fileData.split('\n');
                // 经销商医院名称list
                List<String> ahlNameList = new List<String>();
                //for content
                system.debug('fileLines.size()==============>'+fileLines.size());
                for (Integer i=1,j=fileLines.size();i<j;i++){
                    List<String> inputvalues = new List<String>();
                    inputvalues = fileLines[i].split(',');
                    if(inputvalues != null){
                        if(inputvalues[2] == '' || inputvalues[2] == null){
                            errorMag += 'error1 第'+i+'行数据医院不能为空';
                        }
                        ahlNameList.add(inputvalues[2]);
                    }
                }
                // 经销商医院的ocsm医院id的list
                List<String> ahlOcsmIdList = new List<String>();
                System.debug('ahlNameList = ' + ahlNameList);
                List<Agency_Hospital_Link__c> ahlList = [select id,name,Hospital__c,MaxActivityDate__c from Agency_Hospital_Link__c where name = :ahlNameList and Agency_Campaign_Obj__c = true];
                System.debug('ahlList.size() = ' + ahlList.size());
                for(Agency_Hospital_Link__c ahl : ahlList){
                    ahlOcsmIdList.add(ahl.Hospital__c);
                }
                List<Agency_Contact__c> doctor2list = new List<Agency_Contact__c>();
                System.debug('ahlOcsmIdList = ' + ahlOcsmIdList);
                if(!Test.isRunningTest())
                    doctor2list = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c,AWS_Data_Id__c FROM Agency_Contact__c WHERE Hospital_ID18__c= :ahlOcsmIdList order by Name];     //zhj 新方案改造 2022-12-21 去掉Name_Encrypted__c
                if(errorMag != ''){
                    return errorMag;
                }
                String doctor2listStr = JSON.serialize(doctor2list);
                System.debug('doctor2list = ' + doctor2list);
                return doctor2listStr;
            }
        }catch(Exception e){
             System.debug('exception'+e);
             return e.getLineNumber()+'exception:'+e;
        }
        return 'success';
    }
    // fy 导入 20220424 end
    @AuraEnabled// fy 导入 20220424  start  String sobjectName,List<String> fields,
    // public static String processData(String fileData,String Agency_ContactListjson) {
    public static String processData(String fileData,String sobjectName,List<String> fields) {
        DateTime now =System.now();
        System.debug('当前时间:::'+now);
       System.debug('fileData:::'+filedata);
       System.debug('sobjectName:::'+sobjectName);
       System.debug('fields:::'+fields);
    return 'success';
  }
  // fy 导入 20220424 end
  @AuraEnabled // fy 导入 20220424  start  String sobjectName,List<String> fields,
  // public static String processData(String fileData,String Agency_ContactListjson) {
  public static String processData(
    String fileData,
    String sobjectName,
    List<String> fields
  ) {
    DateTime now = System.now();
    System.debug('当前时间:::' + now);
    System.debug('fileData:::' + filedata);
    System.debug('sobjectName:::' + sobjectName);
    System.debug('fields:::' + fields);
    //    System.debug('Agency_ContactListjson::::'+Agency_ContactListjson);
       String errorMag = '';
    String errorMag = '';
       // 创建周报
       try{
            if(fileData!=null){
                // List<GeDatass> Agency_ContactList = (List<GeDatass>)JSON.deserialize(Agency_ContactListjson,List<GeDatass>.class);
                // System.debug('Agency_ContactList::::'+Agency_ContactList);
                // Map<String,String> Agency_ContactMap = new Map<String,String>();
                // for(GeDatass agconobj :Agency_ContactList){
                //     Agency_ContactMap.put(agconobj.name.replace(' ',''),agconobj.dataId);
                // }
                String[] fileLines = new String[]{};
                fileLines = fileData.split('\n');
                // 担当名称的list
                List<String> nameList = new List<String>();
                // 报告日的list
                List<Date> dateList = new List<Date>();
                // List<String> s_dateList = new List<String>();
                // 导入的数据
                List<List<String>> inputList = new List<List<String>>();
                // 经销商医院名称list
                List<String> ahlNameList = new List<String>();
                // 科室Set
                Set<String> departmentSet = new Set<String>();
                // 经销商询价名称list
                // List<String> ahlOppNameList = new List<String>();
                //for content
                system.debug('fileLines.size()==============>'+fileLines.size());
                for (Integer i=1,j=fileLines.size();i<j;i++){
                    system.debug('for2022161329');
                    List<String> inputvalues = new List<String>();
                    inputvalues = fileLines[i].split(',');
                    System.debug('inputvalues++'+inputvalues);
                    if(inputvalues != null){
                        system.debug('if2022161333');
                        if(inputvalues[0] == '' || inputvalues[0] == null){
                            // return 'error1 第'+i+'行数据担当不能为空';
                            errorMag += 'error1 第'+i+'行数据担当不能为空';
                            errorMag += '=';
                        }
                        if(inputvalues[1] == '' || inputvalues[1] == null){
                            // return 'error1 第'+i+'行数据活动日不能为空';
                            errorMag += 'error1 第'+i+'行数据活动日不能为空';
                            errorMag += '=';
                        }
                         //SWAG-C7AASP 【委托】DAMS系统周报补录时间调整  2022-1-10 pk start
                         List<String> R = new List<String>();
                         R = inputvalues[1].split('/');
                         system.debug('R202216'+R);
                         Date rDate = Date.newInstance(Integer.Valueof(R[0]),Integer.Valueof(R[1]),Integer.Valueof(R[2]));
                         system.debug('rDate202216'+rDate);
                         Date start = Date.today().addMonths(-1);
                         Date startDay = start.toStartOfWeek();
                         Date firstDayOfweek = System.today().toStartOfWeek();
                         Date endDay = firstDayOfweek.addDays(6);
                         if(rDate > endDay || rDate < startDay){
                             system.debug('rDate >= ssDate');
                             // return 'error1 第'+i+'行数据活动日不能为空';
                             errorMag += 'error1 第'+i+'行数据,导入周报仅可补报最近一月周报';
                             errorMag += '=';
                         }
                         //SWAG-C7AASP 【委托】DAMS系统周报补录时间调整  2022-1-10 pk end
                        if(inputvalues[2] == '' || inputvalues[2] == null){
                            // return 'error1 第'+i+'行数据医院不能为空';
                            errorMag += 'error1 第'+i+'行数据医院不能为空';
                            errorMag += '=';
                        }
                        if(inputvalues[3] == '' || inputvalues[3] == null){
                            // return 'error1 第'+i+'行数据科室不能为空';
                            errorMag += 'error1 第'+i+'行数据科室不能为空';
                            errorMag += '=';
                        }
                        String departmentstr = GetDepartment_Cateogy(inputvalues[3]);
                        if(departmentstr == 'no' && inputvalues[3] != '' && inputvalues[3] != null){
                            // return 'error3 第'+i+'行数据科室选项列表的值'+inputvalues[3]+'不存在';
                            errorMag += 'error3 第'+i+'行数据科室选项列表的值'+inputvalues[3]+'不存在';
                            errorMag += '=';
                        }
                        if(inputvalues[4] == '' || inputvalues[4] == null){
                            // return 'error1 第'+i+'行数据拜访人不能为空';
                            errorMag += 'error1 第'+i+'行数据拜访人不能为空';
                            errorMag += '=';
                        }
                        if(inputvalues[5] == '' || inputvalues[5] == null){
                            // return 'error1 第'+i+'行数据产品区分1不能为空';
                            errorMag += 'error1 第'+i+'行数据产品区分1不能为空';
                            errorMag += '=';
                        }
                        if((inputvalues[6] != '' && inputvalues[6] != null)&& inputvalues[5] == inputvalues[6]){
                            // return 'error1 第'+i+'行数据产品区分1和产品区分2的值不能重复';
                            errorMag += 'error1 第'+i+'行数据产品区分1和产品区分2的值不能重复';
                            errorMag += '=';
                        }
                        if((inputvalues[7] != '' && inputvalues[7] != null)&& inputvalues[5] == inputvalues[7]){
                            // return 'error1 第'+i+'行数据产品区分1和产品区分3的值不能重复';
                            errorMag += 'error1 第'+i+'行数据产品区分1和产品区分3的值不能重复';
                            errorMag += '=';
                        }
                        if((inputvalues[6] != '' && inputvalues[6] != null) && (inputvalues[7] != '' && inputvalues[7] != null) && inputvalues[6] == inputvalues[7]){
                            // return 'error1 第'+i+'行数据产品区分2和产品区分3的值不能重复';
                            errorMag += 'error1 第'+i+'行数据产品区分2和产品区分3的值不能重复';
                            errorMag += '=';
                        }
                        if(inputvalues[8] == '' || inputvalues[8] == null){
                            // return 'error1 第'+i+'行数据活动区分不能为空';
                            errorMag += 'error1 第'+i+'行数据活动区分不能为空';
                            errorMag += '=';
                        }
                        boolean purposeType = GetPurposeType(inputvalues[8]);
                        if(!purposeType && inputvalues[8] != '' && inputvalues[8] != null){
                            // return 'error3 第'+i+'行数据活动区分选项列表的值'+inputvalues[8]+'不存在';
                            errorMag += 'error3 第'+i+'行数据活动区分选项列表的值'+inputvalues[8]+'不存在';
                            errorMag += '=';
                        }
                        // if(inputvalues[9] == '\r' || inputvalues[9] == null){
                        //     return 'error1 结果不能为空';
                        // }
                        if(inputvalues[8] == '询价挖掘-OPD' || inputvalues[8] == '询价挖掘-SIS' || inputvalues[8] == '询价推进-OPD' || inputvalues[8] == '询价推进-SIS'){
                            System.debug(']]]]]1'+inputvalues[9]+'=====');
                            if(inputvalues[9] == '\r'){
                                // return 'error5 第'+i+'行数据当活动区分为'+inputvalues[8]+'结果不能为空';
                                errorMag += 'error5 第'+i+'行数据当活动区分为'+inputvalues[8]+'结果不能为空';
                                errorMag += '=';
                            }
                        }
                        // if(inputvalues[9] != '\r' && getResultlist(inputvalues[9])){
                        if(inputvalues[9] != '' && getResultlist(inputvalues[9])){
                            // return 'error3 第'+i+'行数据结果选项列表的值'+inputvalues[9]+'不存在';
                            errorMag += 'error3 第'+i+'行数据结果选项列表的值'+inputvalues[9]+'不存在';
                            errorMag += '=';
                        }
                       system.debug('inputvalues[0]=================>'+inputvalues[0]);
                        system.debug('inputvalues[1]=================>'+inputvalues[1]);
                        system.debug('inputvalues[2]=================>'+inputvalues[2]);
                        system.debug('inputvalues[3]=================>'+inputvalues[3]);
                        system.debug('inputvalues[4]=================>'+inputvalues[4]);
                        system.debug('inputvalues[5]=================>'+inputvalues[5]);
                        system.debug('inputvalues[6]=================>'+inputvalues[6]);
                        system.debug('inputvalues[7]=================>'+inputvalues[7]);
                        system.debug('inputvalues[8]=================>'+inputvalues[8]);
                        system.debug('inputvalues[9]=================>'+inputvalues[9]);
                        // system.debug('inputvalues[10]=================>'+inputvalues[10]);
                        nameList.add(inputvalues[0]);
                        dateList.add(Date.valueOf(inputvalues[1].replace('/','-')));
                        ahlNameList.add(inputvalues[2]);
                        departmentSet.add('%'+GetDepartment_Cateogy(inputvalues[3])+'%'+'-'+GetEPurposeType(inputvalues[8]));
                        inputList.add(inputvalues);
                    }
                }
                system.debug('snduksbdnjsvbdskjv');
                // 担当名称匹配的map
                Map<String,String> nameIdMap = new Map<String,String>();
                Map<String,String> nameConMap = new Map<String,String>();
                // 经销商医院名称匹配的map
                Map<String,Agency_Hospital_Link__c> ahlMap = new Map<String,Agency_Hospital_Link__c>();
                // 产品区分的map
                Map<String,String> protypeMap = new Map<String,String>();
                // 经销商医院的ocsm医院id的list
                List<String> ahlOcsmIdList = new List<String>();
                // 经销商医院id的List
                List<String> ahlIdList = new List<String>();
                // 获取每周第一天的map
                Map<Date,Date> dateMap = new Map<Date,Date>();
                // 根据日期获取olympus日历id的map
                Map<Date,String> dateIdMap = new Map<Date,String>();
                // 根据经销商医院的ocsm医院获取的所有.客户人员的信息的名称和id的map
                Map<String,String> doctor2Map = new Map<String,String>();
                // 经销商询价的map
                Map<String,Agency_Opportunity__c> aoMap = new Map<String,Agency_Opportunity__c>();
                // 科室和产品区分关系map
                Map<String,List<Map<String,String>>> impProMap = new  Map<String,List<Map<String,String>>>();
                impProMap = getImplProductList(departmentSet);
                System.debug('---===---===---==='+impProMap);
                // return nameList[0];
                // List<Contact> conList = [select id,name from Contact where name = :nameList];
                // List<Contact> conList = [select id,name from Contact];
                List<Contact> conList = LightningUtil.selectAgencyPerson();
                System.debug('---===---===---====='+conList);
                List<OlympusCalendar__c> olympusDateList = [select Id,Date__c,FirstDayOfWeek__c,DayOfTheWeek__c from OlympusCalendar__c where Date__c= :dateList ];
                // test用
                // String testuse = '';
                // testuse += '====='+ahlNameList;
                List<Agency_Hospital_Link__c> ahlList = [select id,name,Hospital__c,MaxActivityDate__c from Agency_Hospital_Link__c where name = :ahlNameList and Agency_Campaign_Obj__c = true];
                // List<Agency_Hospital_Link__c> ahlList = [select id,name,Hospital__c,MaxActivityDate__c from Agency_Hospital_Link__c ];
                // List<ProductTypes__c> proTypeList = [select id,name from ProductTypes__c];
                for(OlympusCalendar__c olym : olympusDateList){
                    if(olym.DayOfTheWeek__c == 'Sun'){
                        dateMap.put(olym.Date__c, olym.Date__c.addDays(1));
                    }
                    else{
                        dateMap.put(olym.Date__c, olym.FirstDayOfWeek__c);
                    }
                }
                System.debug('x'+dateMap);
                List<OlympusCalendar__c> olympusIdList = [select Id,Date__c,FirstDayOfWeek__c from OlympusCalendar__c where Date__c= :dateMap.values()];
                for(OlympusCalendar__c olym : olympusIdList){
                    dateIdMap.put(olym.FirstDayOfWeek__c, olym.id);
                }
                System.debug('dateIdMap===='+dateIdMap);
                for(Contact con :conList){
                    nameIdMap.put(con.Name.replace(' ',''), con.Id);
                    nameConMap.put(con.Id, con.Name);
                }
                // testuse += '======'+ahlList;
                // return testuse;
                for(Agency_Hospital_Link__c ahl : ahlList){
                    ahlMap.put(ahl.Name, ahl);
                    ahlOcsmIdList.add(ahl.Hospital__c);
                    ahlIdList.add(ahl.Id);
                }
                // for(ProductTypes__c protype : proTypeList){
                //     protypeMap.put(protype.Name, protype.Id);
                // }
                //fy 20220424 start AWS_Data_Id__c
                if(!Test.isRunningTest()){
                    List<Agency_Contact__c> doctor2list = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c,AWS_Data_Id__c FROM Agency_Contact__c WHERE Hospital_ID18__c= :ahlOcsmIdList order by Name];     //zhj 新方案改造 2022-12-21 去掉Name_Encrypted__c
                    for(Agency_Contact__c ac : doctor2list){
                        //fy 20220424 start
                        // doctor2Map.put(ac.AWS_Data_Id__c, ac.Id);
                        // doctor2Map.put(ac.Name.replace(' ',''), ac.Id);
                        //doctor2Map.put(ac.Name_Encrypted__c, ac.Id);
                        doctor2Map.put(ac.AWS_Data_Id__c, ac.Id);           //zhj 新方案改造 不再存的nameEncrpt而是awsdataid 2022-12-21
                        //fy 20220424 end
                    }
                }
                // List<Agency_Opportunity__c> aoList = [select id,name,StageName__c,Amount__c,OCMSale_Price__c,Close_Forecasted_Date__c,Agency_Hospital__c from Agency_Opportunity__c where Agency_Hospital__c = :ahlIdList and name = :ahlOppNameList];
                // for(Agency_Opportunity__c ao : aoList){
                //     aoMap.put(ao.Name, ao);
                // }
                System.debug('nameIdMap===='+nameIdMap);
                // 创建周报
                List<Agency_Report_Header__c> agency_report_headerlist = new List<Agency_Report_Header__c>();
                Map<String,Agency_Report_Header__c> agency_report_headerMap = new Map<String,Agency_Report_Header__c>();
                for(List<String> lineList :inputList){
                    Date week = Date.today();
                    String s_agency = null;
                    String s_agencyname = null;
                    System.debug('dateMap===='+dateMap);
                    // System.debug('lineList[0]====不等于空'+lineList[1]);
                    if(dateMap.get(Date.valueOf(lineList[1].replace('/','-'))) != null){
                        System.debug('dateMap====不等于空');
                        week = dateMap.get(Date.valueOf(lineList[1].replace('/','-')));
                        System.debug('===='+week);
                    }
                    System.debug('lineList[0].replace()'+lineList[0].replace(' ',''));
                    if(nameIdMap.get(lineList[0].replace(' ','')) != null){
                        System.debug('nameIdMap====不等于空');
                        s_agency = nameIdMap.get(lineList[0].replace(' ',''));
                        s_agencyname = nameConMap.get(nameIdMap.get(lineList[0].replace(' ','')));
                        System.debug('===='+s_agency);
                    }
                    // if(s_agency == null || s_agencyname == null){
                    //     // return 'error0 担当 '+lineList[0]+'填写不正确';
                    //     errorMag += 'error0 担当 '+lineList[0]+'不存在';
                    //     errorMag += '=';
                    // }
                    Agency_Report_Header__c agency_report_header = new Agency_Report_Header__c();
                    // agency_report_header.Name = lineList[0] + ' (' + week.format() + ')';
                    agency_report_header.Name = s_agencyname + ' (' + week.format().replace('/','-') + ')';
                    agency_report_header.HeaderInputKey__c = createHeader(week,s_agency);
                    agency_report_header.Week__c = week;
                    agency_report_header.Agency_Person2__c = s_agency;
                    if(dateIdMap.containsKey(week)){
                        agency_report_header.OlympusDate__c = dateIdMap.get(week);
                    }
                    if(s_agencyname != null && s_agencyname != '' && s_agencyname != 'null'){
                        agency_report_headerMap.put(agency_report_header.HeaderInputKey__c, agency_report_header);
                    }
                }
                agency_report_headerlist = agency_report_headerMap.values();
                System.debug('==========='+agency_report_headerlist+'');
                // upsert agency_report_headerlist Agency_Report_Header__c.HeaderInputKey__c;
                if(agency_report_headerlist.size() > 0){
                    LightningUtil.upsertMAgencyReportHeader(agency_report_headerlist);
                }
                List<Agency_Report__c> arList = new List<Agency_Report__c>();
                Integer hang = 1;
                for(List<String> lineList :inputList){
                    // 创建周报明细
                    Date week = null;
                    String s_agency = null;
                    System.debug('dateMap===='+dateMap);
                    System.debug('lineList[0]====不等于空'+lineList[1]);
                    if(dateMap.get(Date.valueOf(lineList[1].replace('/','-'))) != null){
                        System.debug('dateMap====不等于空');
                        week = dateMap.get(Date.valueOf(lineList[1].replace('/','-')));
                        System.debug('===='+week);
                    }
                    if(nameIdMap.get(lineList[0].replace(' ','')) != null){
                        System.debug('nameIdMap====不等于空');
                        s_agency = nameIdMap.get(lineList[0].replace(' ',''));
                        System.debug('===='+s_agency);
                    }
                    Agency_Report__c agencyReport = new Agency_Report__c();
                    if(week == null && lineList[1] != '' && lineList[1] != null){
                        // return 'error2 第'+hang+'行数据报告日'+lineList[1]+'填写有误';
                        errorMag += 'error2 第'+hang+'行数据报告日'+lineList[1]+'填写有误';
                        errorMag += '=';
                    }
                    agencyReport.Submit_date__c = week;   // 提出周
                    if((s_agency == null || s_agency == '')&& lineList[0] != '' && lineList[0] != null){
                        // return 'error2 第'+hang+'行数据担当'+lineList[0]+'不存在';
                        errorMag += 'error2 第'+hang+'行数据担当'+lineList[0]+'不存在';
                        errorMag += '=';
                    }
                    agencyReport.Person_In_Charge2__c = s_agency;  // 担当
                    if(lineList[1] != null && lineList[1] != ''){
                        agencyReport.Report_Date__c = Date.valueOf(lineList[1].replace('/','-')); // 活动日
                    }
                    if(ahlMap.containsKey(lineList[2])){
                        agencyReport.Agency_Hospital__c = ahlMap.get(lineList[2]).Id; //经销商医院
                        // 更新经销商医院的最新周
                        ahlMap.get(lineList[2]).MaxActivityDate__c = week;
                    }else{
                        if(lineList[2] != '' && lineList[2] != null){
                            // return 'error2 第'+hang+'行数据经销商医院'+lineList[2]+'不存在';
                            errorMag += 'error2 第'+hang+'行数据经销商医院'+lineList[2]+'不存在';
                            errorMag += '=';
                        }
                    }
                    String departmentE = GetDepartment_Cateogy(lineList[3]);
                    if(departmentE != 'no'){
                        agencyReport.Department_Cateogy__c = departmentE;  // 科室
                    }else{
                        // return 'error2 第'+hang+'行数据科室'+lineList[3]+'不存在';
                        // errorMag += 'error2 第'+hang+'行数据科室'+lineList[3]+'不存在';
                        // errorMag += '=';
                    }
                    //fy 20220424 start
                    // if(doctor2Map.containsKey(lineList[4].replace(' ',''))){
                    if(doctor2Map.containsKey(lineList[4])){
                    // if(Agency_ContactMap.containsKey(lineList[4].replace(' ',''))){
                    //     if(doctor2Map.containsKey(Agency_ContactMap.get(lineList[4].replace(' ','')))){
                            // agencyReport.doctor2__c = doctor2Map.get(lineList[4].replace(' ','')); // 拜访人
                            agencyReport.doctor2__c = doctor2Map.get(lineList[4]); // 拜访人
                            // agencyReport.doctor2__c = doctor2Map.get(Agency_ContactMap.get(lineList[4].replace(' ',''))); // 拜访人
                        // }
                    }else{
                        if(lineList[4] != '' && lineList[4] != null){
                            // return 'error2 第'+hang+'行数据拜访人'+lineList[4]+'不存在';
                            errorMag += 'error2 第'+hang+'行数据拜访人'+lineList[4]+'不存在';
                            errorMag += '=';
                        }
                    }
                    if(GetPurposeType(lineList[8])){
                        agencyReport.Purpose_Type__c = lineList[8]; // 活动区分
                    }else{
                        // return 'error3 第'+hang+'行数据活动区分选项列表值'+lineList[8]+'不存在';
                        // errorMag += 'error3 第'+hang+'行数据活动区分选项列表值'+lineList[8]+'不存在';
                        // errorMag += '=';
                    }
                    // 科室产品区分关系判断
                    // 如果能找到,就是正确的
                    String departandprokey = '%'+GetDepartment_Cateogy(lineList[3])+'%'+'-'+GetEPurposeType(lineList[8]);
                    System.debug('---===---===---==='+departandprokey);
                    if(impProMap.containsKey(departandprokey)){
                        System.debug('---===---===---==='+ifTrueProduct(impProMap.get(departandprokey),lineList[5]));
                        if(ifTrueProduct(impProMap.get(departandprokey),lineList[5]) != ''){
                            System.debug(']]]不等于空进入');
                            agencyReport.Product_Category1__c = ifTrueProduct(impProMap.get(departandprokey),lineList[5]);
                        }else{
                            System.debug(']]]等于空进入');
                            // return 'error4 第'+hang+'行数据产品区分1的赋值不正确'+lineList[5];
                            errorMag += 'error4 第'+hang+'行数据产品区分1的赋值不正确'+lineList[5];
                            errorMag += '=';
                        }
                        if(lineList[6] != '' && lineList[6] != null){
                            if(ifTrueProduct(impProMap.get(departandprokey),lineList[6]) != ''){
                                agencyReport.Product_Category2__c = ifTrueProduct(impProMap.get(departandprokey),lineList[6]);
                            }else{
                                // return 'error4 第'+hang+'行数据产品区分2的赋值不正确'+lineList[6];
                                errorMag += 'error4 第'+hang+'行数据产品区分2的赋值不正确'+lineList[6];
                                errorMag += '=';
                            }
                        }
                        if(lineList[7] != '' && lineList[7] != null){
                            if(ifTrueProduct(impProMap.get(departandprokey),lineList[7]) != ''){
                                agencyReport.Product_Category3__c = ifTrueProduct(impProMap.get(departandprokey),lineList[7]);
                            }else{
                                // return 'error4 第'+hang+'行数据产品区分3的赋值不正确'+lineList[7];
                                errorMag += 'error4 第'+hang+'行数据产品区分3的赋值不正确'+lineList[7];
                                errorMag += '=';
                            }
                        }
                    }
                    // 通过map 科室,产品区分名 判断取值是否符合要求
                    // if(protypeMap.containsKey(lineList[5])){
                    //     agencyReport.Product_Category1__c = protypeMap.get(lineList[5]);// 产品区分1
                    // }
                    // if(protypeMap.containsKey(lineList[6])){
                    //     agencyReport.Product_Category2__c = protypeMap.get(lineList[6]);// 产品区分2
                    // }
                    // if(protypeMap.containsKey(lineList[7])){
                    //     agencyReport.Product_Category3__c = protypeMap.get(lineList[7]);// 产品区分3
                    // }
                    agencyReport.Result__c = lineList[9];
                    if(lineList.size()==11){
                        if(lineList[10] != null && lineList[10] != ''){
                            agencyReport.SupportNeeds__c = lineList[10];
                        }
                    }
                    String headerStr = createHeader(week,s_agency);
                    if(agency_report_headerMap.containsKey(headerStr)){
                        agencyReport.Agency_Report_Header__c = agency_report_headerMap.get(headerStr).Id; // 周报一览
                    }
                    // if(aoMap.containsKey(lineList[6])){
                    //     agencyReport.Opportunity__c = aoMap.get(lineList[6]).Id; // 经销商询价
                    //     // 经销商询价更新字段
                    //     aoMap.get(lineList[6]).StageName__c = lineList[5]; // 询价阶段
                    //     aoMap.get(lineList[6]).Amount__c = Decimal.valueOf(lineList[6]); // 医院采购预算(含税,元)
                    //     aoMap.get(lineList[6]).OCMSale_Price__c = Decimal.valueOf(lineList[7]); // 订货金额(含税,元)
                    //     aoMap.get(lineList[6]).Close_Forecasted_Date__c = Date.valueOf(lineList[8].replace('/','-')); // 预测于OLY签约日
                    // }
                    hang++;
                    arList.add(agencyReport);
                }
                if(errorMag != ''){
                    return errorMag;
                }
                // 更新经销商意愿的最新周
                if(ahlMap.values().size() > 0 ){
                    update ahlMap.values();
                }
                // 更新经销商询价
                // if(aoMap.values().size() > 0 ){
                //     update aoMap.values();
                // }
                // 新增周报明细
                if(arList.size() > 0 ){
                    // insert arList;
                    LightningUtil.insertMAgencyReport(arList);
                }
    // 创建周报
    try {
      if (fileData != null) {
        // List<GeDatass> Agency_ContactList = (List<GeDatass>)JSON.deserialize(Agency_ContactListjson,List<GeDatass>.class);
        // System.debug('Agency_ContactList::::'+Agency_ContactList);
        // Map<String,String> Agency_ContactMap = new Map<String,String>();
        // for(GeDatass agconobj :Agency_ContactList){
        //     Agency_ContactMap.put(agconobj.name.replace(' ',''),agconobj.dataId);
        // }
        String[] fileLines = new List<String>{};
        fileLines = fileData.split('\n');
        // 担当名称的list
        List<String> nameList = new List<String>();
        // 报告日的list
        List<Date> dateList = new List<Date>();
        // List<String> s_dateList = new List<String>();
        // 导入的数据
        List<List<String>> inputList = new List<List<String>>();
        // 经销商医院名称list
        List<String> ahlNameList = new List<String>();
        // 科室Set
        Set<String> departmentSet = new Set<String>();
        // 经销商询价名称list
        // List<String> ahlOppNameList = new List<String>();
        //for content
        system.debug('fileLines.size()==============>' + fileLines.size());
        for (Integer i = 1, j = fileLines.size(); i < j; i++) {
          system.debug('for2022161329');
          List<String> inputvalues = new List<String>();
          inputvalues = fileLines[i].split(',');
          System.debug('inputvalues++' + inputvalues);
          if (inputvalues != null) {
            system.debug('if2022161333');
            if (inputvalues[0] == '' || inputvalues[0] == null) {
              // return 'error1 第'+i+'行数据担当不能为空';
              errorMag += 'error1 第' + i + '行数据担当不能为空';
              errorMag += '=';
            }
            return 'success';
        }catch(Exception e){
             System.debug('exception'+e);
             return e.getLineNumber()+'exception:'+e;
        }
        return 'success';
    }
    // 创建唯一键
    public static String createHeader(Date s_date,String nameid){
        String str = s_date.format();
        String str1 = str.replace('/', '');
        return nameid+':'+str1;
    }
    // 科室对应翻译
    public static String GetDepartment_Cateogy(String department){
        String departmentE = 'no';
        if(department == '呼吸科'){
            departmentE = 'BF';
        }
        if(department == '耳鼻喉科'){
            departmentE = 'ENT';
        }
        if(department == 'ET耗材'){
            departmentE = 'ET';
        }
        if(department == '消化科'){
            departmentE = 'GI';
        }
        if(department == '普外科'){
            departmentE = 'GS';
        }
        if(department == '妇科'){
            departmentE = 'GYN';
        }
        if(department == '其他'){
            departmentE = 'OTH';
        }
        if(department == '泌尿科'){
            departmentE = 'URO';
        }
        return departmentE;
    }
    // 判断活动分区是否存在
    public static boolean GetPurposeType(String purposeType){
        Schema.DescribeFieldResult fieldResult = Agency_Report__c.Purpose_Type__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        for( Schema.PicklistEntry pickListVal : ple){
            if(pickListVal.getValue() == purposeType){
                return true;
            if (inputvalues[1] == '' || inputvalues[1] == null) {
              // return 'error1 第'+i+'行数据活动日不能为空';
              errorMag += 'error1 第' + i + '行数据活动日不能为空';
              errorMag += '=';
            }
        }
        return false;
    }
    public static boolean getResultlist(String resultlist){
        system.debug('resultlist===============>'+resultlist);
        Schema.DescribeFieldResult fieldResult = Agency_Report__c.Result__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        for( Schema.PicklistEntry pickListVal : ple){
            System.debug('weixiao'+resultlist.trim()+'111111'+pickListVal.getValue()+'222222');
            string temp = string.ValueOf(pickListVal.getValue());
            if(temp.equals(resultlist.trim())){
            // if(pickListVal.getValue().equals(resultlist)){
                System.debug('weixiaoweixiao'+resultlist+''+pickListVal.getValue());
                return false;
            //SWAG-C7AASP 【委托】DAMS系统周报补录时间调整  2022-1-10 pk start
            List<String> R = new List<String>();
            R = inputvalues[1].split('/');
            system.debug('R202216' + R);
            Date rDate = Date.newInstance(
              Integer.Valueof(R[0]),
              Integer.Valueof(R[1]),
              Integer.Valueof(R[2])
            );
            system.debug('rDate202216' + rDate);
            Date start = Date.today().addMonths(-1);
            Date startDay = start.toStartOfWeek();
            Date firstDayOfweek = System.today().toStartOfWeek();
            Date endDay = firstDayOfweek.addDays(6);
            if (rDate > endDay || rDate < startDay) {
              system.debug('rDate >= ssDate');
              // return 'error1 第'+i+'行数据活动日不能为空';
              errorMag +=
                'error1 第' +
                i +
                '行数据,导入周报仅可补报最近一月周报';
              errorMag += '=';
            }
            //SWAG-C7AASP 【委托】DAMS系统周报补录时间调整  2022-1-10 pk end
            if (inputvalues[2] == '' || inputvalues[2] == null) {
              // return 'error1 第'+i+'行数据医院不能为空';
              errorMag += 'error1 第' + i + '行数据医院不能为空';
              errorMag += '=';
            }
            if (inputvalues[3] == '' || inputvalues[3] == null) {
              // return 'error1 第'+i+'行数据科室不能为空';
              errorMag += 'error1 第' + i + '行数据科室不能为空';
              errorMag += '=';
            }
            String departmentstr = GetDepartment_Cateogy(inputvalues[3]);
            if (
              departmentstr == 'no' &&
              inputvalues[3] != '' &&
              inputvalues[3] != null
            ) {
              // return 'error3 第'+i+'行数据科室选项列表的值'+inputvalues[3]+'不存在';
              errorMag +=
                'error3 第' +
                i +
                '行数据科室选项列表的值' +
                inputvalues[3] +
                '不存在';
              errorMag += '=';
            }
            if (inputvalues[4] == '' || inputvalues[4] == null) {
              // return 'error1 第'+i+'行数据拜访人不能为空';
              errorMag += 'error1 第' + i + '行数据拜访人不能为空';
              errorMag += '=';
            }
            if (inputvalues[5] == '' || inputvalues[5] == null) {
              // return 'error1 第'+i+'行数据产品区分1不能为空';
              errorMag += 'error1 第' + i + '行数据产品区分1不能为空';
              errorMag += '=';
            }
            if (
              (inputvalues[6] != '' && inputvalues[6] != null) &&
              inputvalues[5] == inputvalues[6]
            ) {
              // return 'error1 第'+i+'行数据产品区分1和产品区分2的值不能重复';
              errorMag +=
                'error1 第' +
                i +
                '行数据产品区分1和产品区分2的值不能重复';
              errorMag += '=';
            }
            if (
              (inputvalues[7] != '' && inputvalues[7] != null) &&
              inputvalues[5] == inputvalues[7]
            ) {
              // return 'error1 第'+i+'行数据产品区分1和产品区分3的值不能重复';
              errorMag +=
                'error1 第' +
                i +
                '行数据产品区分1和产品区分3的值不能重复';
              errorMag += '=';
            }
            if (
              (inputvalues[6] != '' &&
              inputvalues[6] != null) &&
              (inputvalues[7] != '' &&
              inputvalues[7] != null) &&
              inputvalues[6] == inputvalues[7]
            ) {
              // return 'error1 第'+i+'行数据产品区分2和产品区分3的值不能重复';
              errorMag +=
                'error1 第' +
                i +
                '行数据产品区分2和产品区分3的值不能重复';
              errorMag += '=';
            }
            if (inputvalues[8] == '' || inputvalues[8] == null) {
              // return 'error1 第'+i+'行数据活动区分不能为空';
              errorMag += 'error1 第' + i + '行数据活动区分不能为空';
              errorMag += '=';
            }
            boolean purposeType = GetPurposeType(inputvalues[8]);
            if (
              !purposeType &&
              inputvalues[8] != '' &&
              inputvalues[8] != null
            ) {
              // return 'error3 第'+i+'行数据活动区分选项列表的值'+inputvalues[8]+'不存在';
              errorMag +=
                'error3 第' +
                i +
                '行数据活动区分选项列表的值' +
                inputvalues[8] +
                '不存在';
              errorMag += '=';
            }
            // if(inputvalues[9] == '\r' || inputvalues[9] == null){
            //     return 'error1 结果不能为空';
            // }
            if (
              inputvalues[8] == '询价挖掘-OPD' ||
              inputvalues[8] == '询价挖掘-SIS' ||
              inputvalues[8] == '询价推进-OPD' ||
              inputvalues[8] == '询价推进-SIS'
            ) {
              System.debug(']]]]]1' + inputvalues[9] + '=====');
              if (inputvalues[9] == '\r') {
                // return 'error5 第'+i+'行数据当活动区分为'+inputvalues[8]+'结果不能为空';
                errorMag +=
                  'error5 第' +
                  i +
                  '行数据当活动区分为' +
                  inputvalues[8] +
                  '结果不能为空';
                errorMag += '=';
              }
            }
            // if(inputvalues[9] != '\r' && getResultlist(inputvalues[9])){
            if (inputvalues[9] != '' && getResultlist(inputvalues[9])) {
              // return 'error3 第'+i+'行数据结果选项列表的值'+inputvalues[9]+'不存在';
              errorMag +=
                'error3 第' +
                i +
                '行数据结果选项列表的值' +
                inputvalues[9] +
                '不存在';
              errorMag += '=';
            }
            system.debug('inputvalues[0]=================>' + inputvalues[0]);
            system.debug('inputvalues[1]=================>' + inputvalues[1]);
            system.debug('inputvalues[2]=================>' + inputvalues[2]);
            system.debug('inputvalues[3]=================>' + inputvalues[3]);
            system.debug('inputvalues[4]=================>' + inputvalues[4]);
            system.debug('inputvalues[5]=================>' + inputvalues[5]);
            system.debug('inputvalues[6]=================>' + inputvalues[6]);
            system.debug('inputvalues[7]=================>' + inputvalues[7]);
            system.debug('inputvalues[8]=================>' + inputvalues[8]);
            system.debug('inputvalues[9]=================>' + inputvalues[9]);
            // system.debug('inputvalues[10]=================>'+inputvalues[10]);
            nameList.add(inputvalues[0]);
            dateList.add(Date.valueOf(inputvalues[1].replace('/', '-')));
            ahlNameList.add(inputvalues[2]);
            departmentSet.add(
              '%' +
                GetDepartment_Cateogy(inputvalues[3]) +
                '%' +
                '-' +
                GetEPurposeType(inputvalues[8])
            );
            inputList.add(inputvalues);
          }
        }
        system.debug('snduksbdnjsvbdskjv');
        // 担当名称匹配的map
        Map<String, String> nameIdMap = new Map<String, String>();
        Map<String, String> nameConMap = new Map<String, String>();
        // 经销商医院名称匹配的map
        Map<String, Agency_Hospital_Link__c> ahlMap = new Map<String, Agency_Hospital_Link__c>();
        // 产品区分的map
        Map<String, String> protypeMap = new Map<String, String>();
        // 经销商医院的ocsm医院id的list
        List<String> ahlOcsmIdList = new List<String>();
        // 经销商医院id的List
        List<String> ahlIdList = new List<String>();
        // 获取每周第一天的map
        Map<Date, Date> dateMap = new Map<Date, Date>();
        // 根据日期获取olympus日历id的map
        Map<Date, String> dateIdMap = new Map<Date, String>();
        // 根据经销商医院的ocsm医院获取的所有.客户人员的信息的名称和id的map
        Map<String, String> doctor2Map = new Map<String, String>();
        // 经销商询价的map
        Map<String, Agency_Opportunity__c> aoMap = new Map<String, Agency_Opportunity__c>();
        // 科室和产品区分关系map
        Map<String, List<Map<String, String>>> impProMap = new Map<String, List<Map<String, String>>>();
        impProMap = getImplProductList(departmentSet);
        System.debug('---===---===---===' + impProMap);
        // return nameList[0];
        // List<Contact> conList = [select id,name from Contact where name = :nameList];
        // List<Contact> conList = [select id,name from Contact];
        List<Contact> conList = LightningUtil.selectAgencyPerson();
        System.debug('---===---===---=====' + conList);
        List<OlympusCalendar__c> olympusDateList = [
          SELECT Id, Date__c, FirstDayOfWeek__c, DayOfTheWeek__c
          FROM OlympusCalendar__c
          WHERE Date__c = :dateList
        ];
        // test用
        // String testuse = '';
        // testuse += '====='+ahlNameList;
        List<Agency_Hospital_Link__c> ahlList = [
          SELECT id, name, Hospital__c, MaxActivityDate__c
          FROM Agency_Hospital_Link__c
          WHERE name = :ahlNameList AND Agency_Campaign_Obj__c = TRUE
        ];
        // List<Agency_Hospital_Link__c> ahlList = [select id,name,Hospital__c,MaxActivityDate__c from Agency_Hospital_Link__c ];
        // List<ProductTypes__c> proTypeList = [select id,name from ProductTypes__c];
        for (OlympusCalendar__c olym : olympusDateList) {
          if (olym.DayOfTheWeek__c == 'Sun') {
            dateMap.put(olym.Date__c, olym.Date__c.addDays(1));
          } else {
            dateMap.put(olym.Date__c, olym.FirstDayOfWeek__c);
          }
        }
        System.debug('x' + dateMap);
        List<OlympusCalendar__c> olympusIdList = [
          SELECT Id, Date__c, FirstDayOfWeek__c
          FROM OlympusCalendar__c
          WHERE Date__c = :dateMap.values()
        ];
        for (OlympusCalendar__c olym : olympusIdList) {
          dateIdMap.put(olym.FirstDayOfWeek__c, olym.id);
        }
        System.debug('dateIdMap====' + dateIdMap);
        for (Contact con : conList) {
          nameIdMap.put(con.Name.replace(' ', ''), con.Id);
          nameConMap.put(con.Id, con.Name);
        }
        // testuse += '======'+ahlList;
        // return testuse;
        for (Agency_Hospital_Link__c ahl : ahlList) {
          ahlMap.put(ahl.Name, ahl);
          ahlOcsmIdList.add(ahl.Hospital__c);
          ahlIdList.add(ahl.Id);
        }
        // for(ProductTypes__c protype : proTypeList){
        //     protypeMap.put(protype.Name, protype.Id);
        // }
        //fy 20220424 start AWS_Data_Id__c
        if (!Test.isRunningTest()) {
          List<Agency_Contact__c> doctor2list = [
            SELECT
              id,
              Name,
              Doctor_Division1__c,
              Type__c,
              Agency_Hospital__c,
              AWS_Data_Id__c
            FROM Agency_Contact__c
            WHERE Hospital_ID18__c = :ahlOcsmIdList
            ORDER BY Name
          ]; //zhj 新方案改造 2022-12-21 去掉Name_Encrypted__c
          for (Agency_Contact__c ac : doctor2list) {
            //fy 20220424 start
            // doctor2Map.put(ac.AWS_Data_Id__c, ac.Id);
            // doctor2Map.put(ac.Name.replace(' ',''), ac.Id);
            //doctor2Map.put(ac.Name_Encrypted__c, ac.Id);
            doctor2Map.put(ac.AWS_Data_Id__c, ac.Id); //zhj 新方案改造 不再存的nameEncrpt而是awsdataid 2022-12-21
            //fy 20220424 end
          }
        }
        // List<Agency_Opportunity__c> aoList = [select id,name,StageName__c,Amount__c,OCMSale_Price__c,Close_Forecasted_Date__c,Agency_Hospital__c from Agency_Opportunity__c where Agency_Hospital__c = :ahlIdList and name = :ahlOppNameList];
        // for(Agency_Opportunity__c ao : aoList){
        //     aoMap.put(ao.Name, ao);
        // }
        System.debug('nameIdMap====' + nameIdMap);
        // 创建周报
        List<Agency_Report_Header__c> agency_report_headerlist = new List<Agency_Report_Header__c>();
        Map<String, Agency_Report_Header__c> agency_report_headerMap = new Map<String, Agency_Report_Header__c>();
        for (List<String> lineList : inputList) {
          Date week = Date.today();
          String s_agency = null;
          String s_agencyname = null;
          System.debug('dateMap====' + dateMap);
          // System.debug('lineList[0]====不等于空'+lineList[1]);
          if (
            dateMap.get(Date.valueOf(lineList[1].replace('/', '-'))) != null
          ) {
            System.debug('dateMap====不等于空');
            week = dateMap.get(Date.valueOf(lineList[1].replace('/', '-')));
            System.debug('====' + week);
          }
          System.debug('lineList[0].replace()' + lineList[0].replace(' ', ''));
          if (nameIdMap.get(lineList[0].replace(' ', '')) != null) {
            System.debug('nameIdMap====不等于空');
            s_agency = nameIdMap.get(lineList[0].replace(' ', ''));
            s_agencyname = nameConMap.get(
              nameIdMap.get(lineList[0].replace(' ', ''))
            );
            System.debug('====' + s_agency);
          }
          // if(s_agency == null || s_agencyname == null){
          //     // return 'error0 担当 '+lineList[0]+'填写不正确';
          //     errorMag += 'error0 担当 '+lineList[0]+'不存在';
          //     errorMag += '=';
          // }
          Agency_Report_Header__c agency_report_header = new Agency_Report_Header__c();
          // agency_report_header.Name = lineList[0] + ' (' + week.format() + ')';
          agency_report_header.Name =
            s_agencyname +
            ' (' +
            week.format().replace('/', '-') +
            ')';
          agency_report_header.HeaderInputKey__c = createHeader(week, s_agency);
          agency_report_header.Week__c = week;
          agency_report_header.Agency_Person2__c = s_agency;
          if (dateIdMap.containsKey(week)) {
            agency_report_header.OlympusDate__c = dateIdMap.get(week);
          }
          if (
            s_agencyname != null &&
            s_agencyname != '' &&
            s_agencyname != 'null'
          ) {
            agency_report_headerMap.put(
              agency_report_header.HeaderInputKey__c,
              agency_report_header
            );
          }
        }
        agency_report_headerlist = agency_report_headerMap.values();
        System.debug('===========' + agency_report_headerlist + '');
        // upsert agency_report_headerlist Agency_Report_Header__c.HeaderInputKey__c;
        if (agency_report_headerlist.size() > 0) {
          LightningUtil.upsertMAgencyReportHeader(agency_report_headerlist);
        }
        List<Agency_Report__c> arList = new List<Agency_Report__c>();
        Integer hang = 1;
        for (List<String> lineList : inputList) {
          // 创建周报明细
          Date week = null;
          String s_agency = null;
          System.debug('dateMap====' + dateMap);
          System.debug('lineList[0]====不等于空' + lineList[1]);
          if (
            dateMap.get(Date.valueOf(lineList[1].replace('/', '-'))) != null
          ) {
            System.debug('dateMap====不等于空');
            week = dateMap.get(Date.valueOf(lineList[1].replace('/', '-')));
            System.debug('====' + week);
          }
          if (nameIdMap.get(lineList[0].replace(' ', '')) != null) {
            System.debug('nameIdMap====不等于空');
            s_agency = nameIdMap.get(lineList[0].replace(' ', ''));
            System.debug('====' + s_agency);
          }
          Agency_Report__c agencyReport = new Agency_Report__c();
          if (week == null && lineList[1] != '' && lineList[1] != null) {
            // return 'error2 第'+hang+'行数据报告日'+lineList[1]+'填写有误';
            errorMag +=
              'error2 第' +
              hang +
              '行数据报告日' +
              lineList[1] +
              '填写有误';
            errorMag += '=';
          }
          agencyReport.Submit_date__c = week; // 提出周
          if (
            (s_agency == null ||
            s_agency == '') &&
            lineList[0] != '' &&
            lineList[0] != null
          ) {
            // return 'error2 第'+hang+'行数据担当'+lineList[0]+'不存在';
            errorMag +=
              'error2 第' +
              hang +
              '行数据担当' +
              lineList[0] +
              '不存在';
            errorMag += '=';
          }
          agencyReport.Person_In_Charge2__c = s_agency; // 担当
          if (lineList[1] != null && lineList[1] != '') {
            agencyReport.Report_Date__c = Date.valueOf(
              lineList[1].replace('/', '-')
            ); // 活动日
          }
          if (ahlMap.containsKey(lineList[2])) {
            agencyReport.Agency_Hospital__c = ahlMap.get(lineList[2]).Id; //经销商医院
            // 更新经销商医院的最新周
            ahlMap.get(lineList[2]).MaxActivityDate__c = week;
          } else {
            if (lineList[2] != '' && lineList[2] != null) {
              // return 'error2 第'+hang+'行数据经销商医院'+lineList[2]+'不存在';
              errorMag +=
                'error2 第' +
                hang +
                '行数据经销商医院' +
                lineList[2] +
                '不存在';
              errorMag += '=';
            }
          }
          String departmentE = GetDepartment_Cateogy(lineList[3]);
          if (departmentE != 'no') {
            agencyReport.Department_Cateogy__c = departmentE; // 科室
          } else {
            // return 'error2 第'+hang+'行数据科室'+lineList[3]+'不存在';
            // errorMag += 'error2 第'+hang+'行数据科室'+lineList[3]+'不存在';
            // errorMag += '=';
          }
          //fy 20220424 start
          // if(doctor2Map.containsKey(lineList[4].replace(' ',''))){
          if (doctor2Map.containsKey(lineList[4])) {
            // if(Agency_ContactMap.containsKey(lineList[4].replace(' ',''))){
            //     if(doctor2Map.containsKey(Agency_ContactMap.get(lineList[4].replace(' ','')))){
            // agencyReport.doctor2__c = doctor2Map.get(lineList[4].replace(' ','')); // 拜访人
            agencyReport.doctor2__c = doctor2Map.get(lineList[4]); // 拜访人
            // agencyReport.doctor2__c = doctor2Map.get(Agency_ContactMap.get(lineList[4].replace(' ',''))); // 拜访人
            // }
          } else {
            if (lineList[4] != '' && lineList[4] != null) {
              // return 'error2 第'+hang+'行数据拜访人'+lineList[4]+'不存在';
              errorMag +=
                'error2 第' +
                hang +
                '行数据拜访人' +
                lineList[4] +
                '不存在';
              errorMag += '=';
            }
          }
          if (GetPurposeType(lineList[8])) {
            agencyReport.Purpose_Type__c = lineList[8]; // 活动区分
          } else {
            // return 'error3 第'+hang+'行数据活动区分选项列表值'+lineList[8]+'不存在';
            // errorMag += 'error3 第'+hang+'行数据活动区分选项列表值'+lineList[8]+'不存在';
            // errorMag += '=';
          }
          // 科室产品区分关系判断
          // 如果能找到,就是正确的
          String departandprokey =
            '%' +
            GetDepartment_Cateogy(lineList[3]) +
            '%' +
            '-' +
            GetEPurposeType(lineList[8]);
          System.debug('---===---===---===' + departandprokey);
          if (impProMap.containsKey(departandprokey)) {
            System.debug(
              '---===---===---===' +
              ifTrueProduct(impProMap.get(departandprokey), lineList[5])
            );
            if (
              ifTrueProduct(impProMap.get(departandprokey), lineList[5]) != ''
            ) {
              System.debug(']]]不等于空进入');
              agencyReport.Product_Category1__c = ifTrueProduct(
                impProMap.get(departandprokey),
                lineList[5]
              );
            } else {
              System.debug(']]]等于空进入');
              // return 'error4 第'+hang+'行数据产品区分1的赋值不正确'+lineList[5];
              errorMag +=
                'error4 第' +
                hang +
                '行数据产品区分1的赋值不正确' +
                lineList[5];
              errorMag += '=';
            }
            if (lineList[6] != '' && lineList[6] != null) {
              if (
                ifTrueProduct(impProMap.get(departandprokey), lineList[6]) != ''
              ) {
                agencyReport.Product_Category2__c = ifTrueProduct(
                  impProMap.get(departandprokey),
                  lineList[6]
                );
              } else {
                // return 'error4 第'+hang+'行数据产品区分2的赋值不正确'+lineList[6];
                errorMag +=
                  'error4 第' +
                  hang +
                  '行数据产品区分2的赋值不正确' +
                  lineList[6];
                errorMag += '=';
              }
            }
            if (lineList[7] != '' && lineList[7] != null) {
              if (
                ifTrueProduct(impProMap.get(departandprokey), lineList[7]) != ''
              ) {
                agencyReport.Product_Category3__c = ifTrueProduct(
                  impProMap.get(departandprokey),
                  lineList[7]
                );
              } else {
                // return 'error4 第'+hang+'行数据产品区分3的赋值不正确'+lineList[7];
                errorMag +=
                  'error4 第' +
                  hang +
                  '行数据产品区分3的赋值不正确' +
                  lineList[7];
                errorMag += '=';
              }
            }
          }
          // 通过map 科室,产品区分名 判断取值是否符合要求
          // if(protypeMap.containsKey(lineList[5])){
          //     agencyReport.Product_Category1__c = protypeMap.get(lineList[5]);// 产品区分1
          // }
          // if(protypeMap.containsKey(lineList[6])){
          //     agencyReport.Product_Category2__c = protypeMap.get(lineList[6]);// 产品区分2
          // }
          // if(protypeMap.containsKey(lineList[7])){
          //     agencyReport.Product_Category3__c = protypeMap.get(lineList[7]);// 产品区分3
          // }
          agencyReport.Result__c = lineList[9];
          if (lineList.size() == 11) {
            if (lineList[10] != null && lineList[10] != '') {
              agencyReport.SupportNeeds__c = lineList[10];
            }
          }
          String headerStr = createHeader(week, s_agency);
          if (agency_report_headerMap.containsKey(headerStr)) {
            agencyReport.Agency_Report_Header__c = agency_report_headerMap.get(
                headerStr
              )
              .Id; // 周报一览
          }
          // if(aoMap.containsKey(lineList[6])){
          //     agencyReport.Opportunity__c = aoMap.get(lineList[6]).Id; // 经销商询价
          //     // 经销商询价更新字段
          //     aoMap.get(lineList[6]).StageName__c = lineList[5]; // 询价阶段
          //     aoMap.get(lineList[6]).Amount__c = Decimal.valueOf(lineList[6]); // 医院采购预算(含税,元)
          //     aoMap.get(lineList[6]).OCMSale_Price__c = Decimal.valueOf(lineList[7]); // 订货金额(含税,元)
          //     aoMap.get(lineList[6]).Close_Forecasted_Date__c = Date.valueOf(lineList[8].replace('/','-')); // 预测于OLY签约日
          // }
          hang++;
          arList.add(agencyReport);
        }
        if (errorMag != '') {
          return errorMag;
        }
        // 更新经销商意愿的最新周
        if (ahlMap.values().size() > 0) {
          update ahlMap.values();
        }
        // 更新经销商询价
        // if(aoMap.values().size() > 0 ){
        //     update aoMap.values();
        // }
        // 新增周报明细
        if (arList.size() > 0) {
          // insert arList;
          LightningUtil.insertMAgencyReport(arList);
        }
      }
      return 'success';
    } catch (Exception e) {
      System.debug('exception' + e);
      return e.getLineNumber() + 'exception:' + e;
    }
    return 'success';
  }
  // 创建唯一键
  public static String createHeader(Date s_date, String nameid) {
    String str = s_date.format();
    String str1 = str.replace('/', '');
    return nameid + ':' + str1;
  }
  // 科室对应翻译
  public static String GetDepartment_Cateogy(String department) {
    String departmentE = 'no';
    if (department == '呼吸科') {
      departmentE = 'BF';
    }
    if (department == '耳鼻喉科') {
      departmentE = 'ENT';
    }
    if (department == 'ET耗材') {
      departmentE = 'ET';
    }
    if (department == '消化科') {
      departmentE = 'GI';
    }
    if (department == '普外科') {
      departmentE = 'GS';
    }
    if (department == '妇科') {
      departmentE = 'GYN';
    }
    if (department == '其他') {
      departmentE = 'OTH';
    }
    if (department == '泌尿科') {
      departmentE = 'URO';
    }
    return departmentE;
  }
  // 判断活动分区是否存在
  public static boolean GetPurposeType(String purposeType) {
    Schema.DescribeFieldResult fieldResult = Agency_Report__c.Purpose_Type__c.getDescribe();
    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
    for (Schema.PicklistEntry pickListVal : ple) {
      if (pickListVal.getValue() == purposeType) {
        return true;
      }
    }
    public static String GetEPurposeType(String purposeType){
        // String purpose_Type='';
        if(purposeType.substring(purposeType.length()-3) == 'OPD'){
            purposeType = 'OPD';
        }else if(purposeType.substring(purposeType.length()-3) == 'SIS'){
            purposeType = 'SIS';
        }else{
            purposeType = '';
        }
        return purposeType;
    return false;
  }
  public static boolean getResultlist(String resultlist) {
    system.debug('resultlist===============>' + resultlist);
    Schema.DescribeFieldResult fieldResult = Agency_Report__c.Result__c.getDescribe();
    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
    for (Schema.PicklistEntry pickListVal : ple) {
      System.debug(
        'weixiao' +
          resultlist.trim() +
          '111111' +
          pickListVal.getValue() +
          '222222'
      );
      string temp = string.ValueOf(pickListVal.getValue());
      if (temp.equals(resultlist.trim())) {
        // if(pickListVal.getValue().equals(resultlist)){
        System.debug(
          'weixiaoweixiao' + resultlist + '' + pickListVal.getValue()
        );
        return false;
      }
    }
    return true;
  }
  public static String GetEPurposeType(String purposeType) {
    // String purpose_Type='';
    if (purposeType.substring(purposeType.length() - 3) == 'OPD') {
      purposeType = 'OPD';
    } else if (purposeType.substring(purposeType.length() - 3) == 'SIS') {
      purposeType = 'SIS';
    } else {
      purposeType = '';
    }
    return purposeType;
  }
  // 判断产品区分是否满足要求
  public static String ifTrueProduct(
    List<Map<String, String>> prolist,
    String str
  ) {
    system.debug('=ifTrueProduct==============ifTrueProduct=========' + str);
    system.debug('=prolist==============prolist=========' + prolist);
    for (Map<String, String> strmap : prolist) {
      System.debug('---===---===---===' + str + '===' + strmap.get('label'));
      if (strmap.get('label') == str) {
        return strmap.get('value');
      }
    }
    return '';
  }
  // 获取导入数据的科室和产品区分的匹配
  public static Map<String, List<Map<String, String>>> getImplProductList(
    Set<String> ptdc
  ) {
    Map<String, List<Map<String, String>>> impProMap = new Map<String, List<Map<String, String>>>();
    List<String> dc = new List<String>(ptdc);
    if (dc.size() > 0) {
      List<ProductTypes__c> ptList1 = new List<ProductTypes__c>();
      List<String> dcList = dc[0].split('-');
      if (dcList.size() > 1) {
        ptList1 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList1 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList1) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[0], impProList);
    }
    if (dc.size() > 1) {
      List<ProductTypes__c> ptList2 = new List<ProductTypes__c>();
      List<String> dcList = dc[1].split('-');
      if (dcList.size() > 1) {
        ptList2 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList2 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList2) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[1], impProList);
    }
    if (dc.size() > 2) {
      List<ProductTypes__c> ptList3 = new List<ProductTypes__c>();
      List<String> dcList = dc[2].split('-');
      if (dcList.size() > 1) {
        ptList3 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList3 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList3) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[2], impProList);
    }
    if (dc.size() > 3) {
      List<ProductTypes__c> ptList4 = new List<ProductTypes__c>();
      List<String> dcList = dc[3].split('-');
      if (dcList.size() > 1) {
        ptList4 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList4 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList4) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[3], impProList);
    }
    if (dc.size() > 4) {
      List<ProductTypes__c> ptList5 = new List<ProductTypes__c>();
      List<String> dcList = dc[4].split('-');
      if (dcList.size() > 1) {
        ptList5 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList5 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList5) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[4], impProList);
    }
    if (dc.size() > 5) {
      List<ProductTypes__c> ptList6 = new List<ProductTypes__c>();
      List<String> dcList = dc[5].split('-');
      if (dcList.size() > 1) {
        ptList6 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList6 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList6) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[5], impProList);
    }
    if (dc.size() > 6) {
      List<ProductTypes__c> ptList7 = new List<ProductTypes__c>();
      List<String> dcList = dc[6].split('-');
      if (dcList.size() > 1) {
        ptList7 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList7 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList7) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[6], impProList);
    }
    if (dc.size() > 7) {
      List<ProductTypes__c> ptList8 = new List<ProductTypes__c>();
      List<String> dcList = dc[7].split('-');
      if (dcList.size() > 1) {
        ptList8 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList8 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList8) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[7], impProList);
    }
    // 判断产品区分是否满足要求
    public static String ifTrueProduct(List<Map<String,String>> prolist,String str){
        system.debug('=ifTrueProduct==============ifTrueProduct========='+str);
        system.debug('=prolist==============prolist========='+prolist);
        for(Map<String,String> strmap :prolist){
            System.debug('---===---===---==='+str+'==='+strmap.get('label'));
            if(strmap.get('label')==str){
                return strmap.get('value');
            }
        }
        return '';
    if (dc.size() > 8) {
      List<ProductTypes__c> ptList9 = new List<ProductTypes__c>();
      List<String> dcList = dc[8].split('-');
      if (dcList.size() > 1) {
        ptList9 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList9 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList9) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[8], impProList);
    }
    // 获取导入数据的科室和产品区分的匹配
    public static Map<String,List<Map<String,String>>> getImplProductList(Set<String> ptdc){
         Map<String,List<Map<String,String>>> impProMap = new  Map<String,List<Map<String,String>>>();
         List<String> dc = new List<String>(ptdc);
        if(dc.size() > 0){
            List<ProductTypes__c> ptList1 = new List<ProductTypes__c>();
            List<String> dcList = dc[0].split('-');
            if (dcList.size() > 1) {
                ptList1 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList1 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList1){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[0], impProList);
        }
        if(dc.size() > 1){
            List<ProductTypes__c> ptList2 = new List<ProductTypes__c>();
            List<String> dcList = dc[1].split('-');
            if (dcList.size() > 1) {
                ptList2 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList2 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList2){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[1], impProList);
        }
        if(dc.size() > 2){
            List<ProductTypes__c> ptList3 = new List<ProductTypes__c>();
            List<String> dcList = dc[2].split('-');
            if (dcList.size() > 1) {
                ptList3 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList3 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList3){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[2], impProList);
        }
        if(dc.size() > 3){
            List<ProductTypes__c> ptList4 = new List<ProductTypes__c>();
            List<String> dcList = dc[3].split('-');
            if (dcList.size() > 1) {
                ptList4 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList4 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList4){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[3], impProList);
        }
        if(dc.size() > 4){
            List<ProductTypes__c> ptList5 = new List<ProductTypes__c>();
            List<String> dcList = dc[4].split('-');
            if (dcList.size() > 1) {
                ptList5 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList5 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList5){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[4], impProList);
        }
        if(dc.size() > 5){
            List<ProductTypes__c> ptList6 = new List<ProductTypes__c>();
            List<String> dcList = dc[5].split('-');
            if (dcList.size() > 1) {
                ptList6 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList6 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList6){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[5], impProList);
        }
        if(dc.size() > 6){
            List<ProductTypes__c> ptList7 = new List<ProductTypes__c>();
            List<String> dcList = dc[6].split('-');
            if (dcList.size() > 1) {
                ptList7 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList7 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList7){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[6], impProList);
        }
        if(dc.size() > 7){
            List<ProductTypes__c> ptList8 = new List<ProductTypes__c>();
            List<String> dcList = dc[7].split('-');
            if (dcList.size() > 1) {
                ptList8 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList8 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList8){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[7], impProList);
        }
        if(dc.size() > 8){
            List<ProductTypes__c> ptList9 = new List<ProductTypes__c>();
            List<String> dcList = dc[8].split('-');
            if (dcList.size() > 1) {
                ptList9 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList9 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList9){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[8], impProList);
        }
        if(dc.size() > 9){
            List<ProductTypes__c> ptList10 = new List<ProductTypes__c>();
            List<String> dcList = dc[9].split('-');
            if (dcList.size() > 1) {
                ptList10 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList10 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList10){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[9], impProList);
        }
        if(dc.size() > 10){
            List<ProductTypes__c> ptList11 = new List<ProductTypes__c>();
            List<String> dcList = dc[10].split('-');
            if (dcList.size() > 1) {
                ptList11 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList11 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList11){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[10], impProList);
        }
        if(dc.size() > 11){
            List<ProductTypes__c> ptList12 = new List<ProductTypes__c>();
            List<String> dcList = dc[11].split('-');
            if (dcList.size() > 1) {
                ptList12 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList12 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList12){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[11], impProList);
        }
        if(dc.size() > 12){
            List<ProductTypes__c> ptList13 = new List<ProductTypes__c>();
            List<String> dcList = dc[12].split('-');
            if (dcList.size() > 1) {
                ptList13 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList13 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList13){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[12], impProList);
        }
        if(dc.size() > 13){
            List<ProductTypes__c> ptList14 = new List<ProductTypes__c>();
            List<String> dcList = dc[13].split('-');
            if (dcList.size() > 1) {
                ptList14 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList14 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList14){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[13], impProList);
        }
        if(dc.size() > 14){
            List<ProductTypes__c> ptList15 = new List<ProductTypes__c>();
            List<String> dcList = dc[14].split('-');
            if (dcList.size() > 1) {
                ptList15 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList15 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList15){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[14], impProList);
        }
        if(dc.size() > 15){
            List<ProductTypes__c> ptList16 = new List<ProductTypes__c>();
            List<String> dcList = dc[15].split('-');
            if (dcList.size() > 1) {
                ptList16 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList16 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList16){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[15], impProList);
        }
        if(dc.size() > 16){
            List<ProductTypes__c> ptList17 = new List<ProductTypes__c>();
            List<String> dcList = dc[16].split('-');
            if (dcList.size() > 1) {
                ptList17 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList17 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList17){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[16], impProList);
        }
        if(dc.size() > 17){
            List<ProductTypes__c> ptList18 = new List<ProductTypes__c>();
            List<String> dcList = dc[17].split('-');
            if (dcList.size() > 1) {
                ptList18 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList18 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList18){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[17], impProList);
        }
        if(dc.size() > 18){
            List<ProductTypes__c> ptList19 = new List<ProductTypes__c>();
            List<String> dcList = dc[18].split('-');
            if (dcList.size() > 1) {
                ptList19 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList19 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList19){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[18], impProList);
        }
        if(dc.size() > 19){
            List<ProductTypes__c> ptList20 = new List<ProductTypes__c>();
            List<String> dcList = dc[19].split('-');
            if (dcList.size() > 1) {
                ptList20 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList20 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList20){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[19], impProList);
        }
        if(dc.size() > 20){
            List<ProductTypes__c> ptList21 = new List<ProductTypes__c>();
            List<String> dcList = dc[20].split('-');
            if (dcList.size() > 1) {
                ptList21 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList21 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList21){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[20], impProList);
        }
        if(dc.size() > 21){
            List<ProductTypes__c> ptList22 = new List<ProductTypes__c>();
            List<String> dcList = dc[21].split('-');
            if (dcList.size() > 1) {
                ptList22 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList22 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList22){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[21], impProList);
        }
        if(dc.size() > 22){
            List<ProductTypes__c> ptList23 = new List<ProductTypes__c>();
            List<String> dcList = dc[22].split('-');
            if (dcList.size() > 1) {
                ptList23 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList23 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList23){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[22], impProList);
        }
        if(dc.size() > 23){
            List<ProductTypes__c> ptList24 = new List<ProductTypes__c>();
            List<String> dcList = dc[23].split('-');
            if (dcList.size() > 1) {
                ptList24 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0] and OPD_SIS_Type__c =:dcList[1]];
            } else {
                ptList24 = [select Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c from ProductTypes__c where DeleteFlg__c = false and Department_Cateogy_Text__c like :dcList[0]];
            }
            List<Map<String,String>> impProList = new List<Map<String,String>>();
            for(ProductTypes__c pt : ptList24){
                Map<String,String> productMap = new Map<String,String>();
                productMap.put('label', pt.Name);
                productMap.put('value', pt.Id);
                impProList.add(productMap);
            }
            impProMap.put(dc[23], impProList);
        }
        return impProMap;
    if (dc.size() > 9) {
      List<ProductTypes__c> ptList10 = new List<ProductTypes__c>();
      List<String> dcList = dc[9].split('-');
      if (dcList.size() > 1) {
        ptList10 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList10 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList10) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[9], impProList);
    }
    // 批量添加周报by vivek end
    //zhj MEBG新方案改造 2022-11-29 start
    @AuraEnabled
    public static ControllerResponse searchAgencyDataId(String hospitalId){
        ControllerResponse r = new ControllerResponse();
        try{
            if(String.isBlank(hospitalId)){
                r.IsSuccess = true;
                r.Message = 'noHospitalId';
                return r;
            }
            List<Agency_Contact__c> acList = [select id,AWS_Data_Id__c,Agency_Hospital__r.Name from Agency_Contact__c where Agency_Hospital__c=:hospitalId];
            r.IsSuccess = true;
            r.Message = '';
            r.Data = acList;
            return r;
        }catch(Exception e) {
            System.debug('into catch'+e.getMessage());
            r.IsSuccess = false;
            r.message = e.getMessage()+e.getStackTraceString();
            return r;
        }
    if (dc.size() > 10) {
      List<ProductTypes__c> ptList11 = new List<ProductTypes__c>();
      List<String> dcList = dc[10].split('-');
      if (dcList.size() > 1) {
        ptList11 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList11 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList11) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[10], impProList);
    }
    //zhj MEBG新方案改造 2022-11-29 end
}
    if (dc.size() > 11) {
      List<ProductTypes__c> ptList12 = new List<ProductTypes__c>();
      List<String> dcList = dc[11].split('-');
      if (dcList.size() > 1) {
        ptList12 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList12 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList12) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[11], impProList);
    }
    if (dc.size() > 12) {
      List<ProductTypes__c> ptList13 = new List<ProductTypes__c>();
      List<String> dcList = dc[12].split('-');
      if (dcList.size() > 1) {
        ptList13 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList13 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList13) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[12], impProList);
    }
    if (dc.size() > 13) {
      List<ProductTypes__c> ptList14 = new List<ProductTypes__c>();
      List<String> dcList = dc[13].split('-');
      if (dcList.size() > 1) {
        ptList14 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList14 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList14) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[13], impProList);
    }
    if (dc.size() > 14) {
      List<ProductTypes__c> ptList15 = new List<ProductTypes__c>();
      List<String> dcList = dc[14].split('-');
      if (dcList.size() > 1) {
        ptList15 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList15 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList15) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[14], impProList);
    }
    if (dc.size() > 15) {
      List<ProductTypes__c> ptList16 = new List<ProductTypes__c>();
      List<String> dcList = dc[15].split('-');
      if (dcList.size() > 1) {
        ptList16 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList16 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList16) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[15], impProList);
    }
    if (dc.size() > 16) {
      List<ProductTypes__c> ptList17 = new List<ProductTypes__c>();
      List<String> dcList = dc[16].split('-');
      if (dcList.size() > 1) {
        ptList17 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList17 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList17) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[16], impProList);
    }
    if (dc.size() > 17) {
      List<ProductTypes__c> ptList18 = new List<ProductTypes__c>();
      List<String> dcList = dc[17].split('-');
      if (dcList.size() > 1) {
        ptList18 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList18 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList18) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[17], impProList);
    }
    if (dc.size() > 18) {
      List<ProductTypes__c> ptList19 = new List<ProductTypes__c>();
      List<String> dcList = dc[18].split('-');
      if (dcList.size() > 1) {
        ptList19 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList19 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList19) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[18], impProList);
    }
    if (dc.size() > 19) {
      List<ProductTypes__c> ptList20 = new List<ProductTypes__c>();
      List<String> dcList = dc[19].split('-');
      if (dcList.size() > 1) {
        ptList20 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList20 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList20) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[19], impProList);
    }
    if (dc.size() > 20) {
      List<ProductTypes__c> ptList21 = new List<ProductTypes__c>();
      List<String> dcList = dc[20].split('-');
      if (dcList.size() > 1) {
        ptList21 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList21 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList21) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[20], impProList);
    }
    if (dc.size() > 21) {
      List<ProductTypes__c> ptList22 = new List<ProductTypes__c>();
      List<String> dcList = dc[21].split('-');
      if (dcList.size() > 1) {
        ptList22 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList22 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList22) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[21], impProList);
    }
    if (dc.size() > 22) {
      List<ProductTypes__c> ptList23 = new List<ProductTypes__c>();
      List<String> dcList = dc[22].split('-');
      if (dcList.size() > 1) {
        ptList23 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList23 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList23) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[22], impProList);
    }
    if (dc.size() > 23) {
      List<ProductTypes__c> ptList24 = new List<ProductTypes__c>();
      List<String> dcList = dc[23].split('-');
      if (dcList.size() > 1) {
        ptList24 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
            AND OPD_SIS_Type__c = :dcList[1]
        ];
      } else {
        ptList24 = [
          SELECT Id, Name, Department_Cateogy__c, OPD_Flg__c, SIS_Flg__c
          FROM ProductTypes__c
          WHERE
            DeleteFlg__c = FALSE
            AND Department_Cateogy_Text__c LIKE :dcList[0]
        ];
      }
      List<Map<String, String>> impProList = new List<Map<String, String>>();
      for (ProductTypes__c pt : ptList24) {
        Map<String, String> productMap = new Map<String, String>();
        productMap.put('label', pt.Name);
        productMap.put('value', pt.Id);
        impProList.add(productMap);
      }
      impProMap.put(dc[23], impProList);
    }
    return impProMap;
  }
  // 批量添加周报by vivek end
  //zhj MEBG新方案改造 2022-11-29 start
  @AuraEnabled
  public static ControllerResponse searchAgencyDataId(String hospitalId) {
    ControllerResponse r = new ControllerResponse();
    try {
      if (String.isBlank(hospitalId)) {
        r.IsSuccess = true;
        r.Message = 'noHospitalId';
        return r;
      }
      List<Agency_Contact__c> acList = [
        SELECT id, AWS_Data_Id__c, Agency_Hospital__r.Name
        FROM Agency_Contact__c
        WHERE Agency_Hospital__c = :hospitalId
      ];
      r.IsSuccess = true;
      r.Message = '';
      r.Data = acList;
      return r;
    } catch (Exception e) {
      System.debug('into catch' + e.getMessage());
      r.IsSuccess = false;
      r.message = e.getMessage() + e.getStackTraceString();
      return r;
    }
  }
  //zhj MEBG新方案改造 2022-11-29 end
}