binxie
2023-06-20 39644c307e98c90e45aea98292c86d70740989e3
force-app/main/default/classes/WeeklyReportCmp.cls
@@ -1,12 +1,19 @@
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;}
  @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() {
    }
@@ -47,8 +54,13 @@
    //zhj 新方案改造 2022-12-21 start
    @RemoteAction
    @AuraEnabled
    public static Map<String, String> saveAgencyContact(String name, String type, String doctorDivision1,
        String agencyHospitalid, String awsid) {
  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;
@@ -66,12 +78,26 @@
    // PIPL update Yin Mingjie 21/02/2022 end
    @RemoteAction
    @AuraEnabled
    public static List<Map<String,String>> getProductList(String dc, String opdsis){
  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];
      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];
      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>();
@@ -87,8 +113,7 @@
        return pts;
    }
    
    public void setalldata()
    {
  public void setalldata() {
        /*** create allselectlist ***/
        this.allselectlist = new Map<String,List<Map<String,String>>>();
@@ -138,19 +163,37 @@
        */
        
        // 科室分类 Department_Cateogy__c 
        this.allselectlist.put('Department_Cateogy__c', WeeklyReportCmp.getPicklistValues('Agency_Report__c','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'));
    this.allselectlist.put(
      'Purpose_Type__c',
      WeeklyReportCmp.getPicklistValues('Agency_Report__c', 'Purpose_Type__c')
    );
        // 结果 Result__c
        this.allselectlist.put('Result__c', WeeklyReportCmp.getPicklistValues('Agency_Report__c','Result__c'));
    this.allselectlist.put(
      'Result__c',
      WeeklyReportCmp.getPicklistValues('Agency_Report__c', 'Result__c')
    );
        //阶段 StageName__c
        this.allselectlist.put('StageName__c', WeeklyReportCmp.getPicklistValues('Agency_Opportunity__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'));
    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'));
@@ -179,8 +222,10 @@
        this.contactawsurl = getAwsurl('Contact');// 20220222 PI改造 by Bright
    }
    
    public static List<Map<String,String>> getPicklistValues(String objstr, String fld){
  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', '');
@@ -191,11 +236,13 @@
        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();
    list<Schema.PicklistEntry> values = fieldMap.get(fld)
      .getDescribe()
      .getPickListValues();
        system.debug(objstr + '=' + values);
        for (Schema.PicklistEntry a : values)
        {
            if (!a.isActive()) continue;
    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());
@@ -205,16 +252,17 @@
        return options;
    }
    
    public  Map<String,String> getfiledsmap()
    {
  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, 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())
        {
    for (Schema.SObjectField sfield : fieldMap.Values()) {
            Schema.describefieldresult dfield = sfield.getDescribe();
            String lab = '';
            lab = dfield.getLabel();
@@ -222,8 +270,7 @@
            mappingmap.put(dfield.name,lab);
        }
        fieldMap = schemaMap.get('Agency_Report__c').getDescribe().fields.getMap();
        for(Schema.SObjectField sfield : fieldMap.Values())
        {
    for (Schema.SObjectField sfield : fieldMap.Values()) {
            Schema.describefieldresult dfield = sfield.getDescribe();
            String lab = '';
            lab = dfield.getLabel();
@@ -244,19 +291,39 @@
    @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];
    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);
  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);
        system.debug('report Id:'+);
    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){
  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 + ')';
@@ -266,10 +333,16 @@
        // READ OlympusCalendar__c
        system.debug(week);
        OlympusCalendar__c olympus_calendar = [select Id,Date__c from OlympusCalendar__c where Date__c=: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; }
    if (olympus_calendar_id != '') {
      agency_report_header.OlympusDate__c = olympus_calendar_id;
    }
        system.debug(agency_report_header);
        return agency_report_header;
@@ -277,10 +350,18 @@
    
    @RemoteAction
    @AuraEnabled
    public static List<Agency_Hospital_Link__c> getHospitalList(String hospital_name) {
  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];
    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;
    }
@@ -288,7 +369,9 @@
    @RemoteAction
    @AuraEnabled
    // PIPL update Yin Mingjie 21/02/2022 start
    public static Map<String,Map<String,String>> getDoctorList(String hospital_id){
  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>>();
@@ -301,7 +384,11 @@
    // 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];
    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
        /*
@@ -319,12 +406,21 @@
            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)
        {
    for (Agency_Contact__c row : doctor_list) {
            if(row.AWS_Data_Id__c == '' || row.AWS_Data_Id__c == null){
                continue;
            }
@@ -336,7 +432,9 @@
            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');
    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);
@@ -395,24 +493,70 @@
    @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);
  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;
    }
    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)
    {
  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;
@@ -437,23 +581,54 @@
        //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; }
    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; }
    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 (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 (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 != '' ||
        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;
                }
@@ -479,11 +654,27 @@
    @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)
    {
  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
@@ -493,14 +684,44 @@
        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];
      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];
      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);
@@ -522,22 +743,67 @@
        }
        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; }
    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 (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 (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 != '' ||
        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;
                }
@@ -555,7 +821,9 @@
                }
                update aopp;
            }
        } else { agency_report.Opportunity__c = null; }
    } else {
      agency_report.Opportunity__c = null;
    }
        system.debug(agency_report);
        
        agency_report = LightningUtil.updateAgencyReport(agency_report);
@@ -565,10 +833,16 @@
    
    @RemoteAction
    @AuraEnabled
    public static List<Agency_Opportunity__c> selectOpportunityByIdAndHospitalLinkId(String opportunity_id, String agency_hospital_link_id) {
  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);
    ret = LightningUtil.selectOpportunityByIdAndHospitalLinkId(
      opportunity_id,
      agency_hospital_link_id
    );
        
        return ret;
    }
@@ -600,7 +874,10 @@
    // 批量添加周报by vivek start
    @RemoteAction
    @AuraEnabled
    public static List<Agency_Report__c> getReportsByDate(String date1, String date2) {
  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();
@@ -623,7 +900,7 @@
        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];
    return [SELECT id, Name, Agency_User__c FROM contact];
    }
    // fy 导入 20220424 start
    public class GeDatass {
@@ -644,7 +921,7 @@
       // 创建周报
       try{
            if(fileData!=null){ 
                String[] fileLines = new String[]{};
        String[] fileLines = new List<String>{};
                fileLines = fileData.split('\n');
              
                // 经销商医院名称list
@@ -664,22 +941,36 @@
                // 经销商医院的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];
        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
          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);
        System.debug('doctor2listStr = ' + doctor2listStr);
                return doctor2listStr;  
            }
        }catch(Exception e){
@@ -691,7 +982,11 @@
    // 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) {
  public static String processData(
    String fileData,
    String sobjectName,
    List<String> fields
  ) {
        DateTime now =System.now();
        System.debug('当前时间:::'+now);
       System.debug('fileData:::'+filedata);
@@ -702,7 +997,6 @@
       // 创建周报
       try{
            if(fileData!=null){ 
                // List<GeDatass> Agency_ContactList = (List<GeDatass>)JSON.deserialize(Agency_ContactListjson,List<GeDatass>.class);
                // System.debug('Agency_ContactList::::'+Agency_ContactList);
@@ -710,7 +1004,7 @@
                // for(GeDatass agconobj :Agency_ContactList){
                //     Agency_ContactMap.put(agconobj.name.replace(' ',''),agconobj.dataId);
                // }
                String[] fileLines = new String[]{};
        String[] fileLines = new List<String>{};
                fileLines = fileData.split('\n');
                // 担当名称的list
                List<String> nameList = new List<String>();
@@ -748,7 +1042,11 @@
                         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]));
            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();
@@ -757,7 +1055,10 @@
                         if(rDate > endDay || rDate < startDay){
                             system.debug('rDate >= ssDate');
                             // return 'error1 第'+i+'行数据活动日不能为空';
                             errorMag += 'error1 第'+i+'行数据,导入周报仅可补报最近一月周报';
              errorMag +=
                'error1 第' +
                i +
                '行数据,导入周报仅可补报最近一月周报';
                             errorMag += '=';
                         }
                         //SWAG-C7AASP 【委托】DAMS系统周报补录时间调整  2022-1-10 pk end
@@ -772,9 +1073,18 @@
                            errorMag += '=';
                        }
                        String departmentstr = GetDepartment_Cateogy(inputvalues[3]);
                        if(departmentstr == 'no' && inputvalues[3] != '' && inputvalues[3] != null){
            if (
              departmentstr == 'no' &&
              inputvalues[3] != '' &&
              inputvalues[3] != null
            ) {
                            // return 'error3 第'+i+'行数据科室选项列表的值'+inputvalues[3]+'不存在';
                            errorMag += 'error3 第'+i+'行数据科室选项列表的值'+inputvalues[3]+'不存在';
              errorMag +=
                'error3 第' +
                i +
                '行数据科室选项列表的值' +
                inputvalues[3] +
                '不存在';
                            errorMag += '=';
                        }
                        if(inputvalues[4] == '' || inputvalues[4] == null){
@@ -787,21 +1097,40 @@
                            errorMag += 'error1 第'+i+'行数据产品区分1不能为空';
                            errorMag += '=';
                        }
                        if((inputvalues[6] != '' && inputvalues[6] != null)&& inputvalues[5] == inputvalues[6]){
            if (
              (inputvalues[6] != '' && inputvalues[6] != null) &&
              inputvalues[5] == inputvalues[6]
            ) {
                            // return 'error1 第'+i+'行数据产品区分1和产品区分2的值不能重复';
                            errorMag += 'error1 第'+i+'行数据产品区分1和产品区分2的值不能重复';
              errorMag +=
                'error1 第' +
                i +
                '行数据产品区分1和产品区分2的值不能重复';
                            errorMag += '=';
                        }
                        if((inputvalues[7] != '' && inputvalues[7] != null)&& inputvalues[5] == inputvalues[7]){
            if (
              (inputvalues[7] != '' && inputvalues[7] != null) &&
              inputvalues[5] == inputvalues[7]
            ) {
                            // return 'error1 第'+i+'行数据产品区分1和产品区分3的值不能重复';
                            errorMag += '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]){
            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 +=
                'error1 第' +
                i +
                '行数据产品区分2和产品区分3的值不能重复';
                            errorMag += '=';
                        }
                        if(inputvalues[8] == '' || inputvalues[8] == null){
@@ -810,27 +1139,50 @@
                            errorMag += '=';
                        }
                        boolean purposeType = GetPurposeType(inputvalues[8]);
                        if(!purposeType && inputvalues[8] != '' && inputvalues[8] != null){
            if (
              !purposeType &&
              inputvalues[8] != '' &&
              inputvalues[8] != null
            ) {
                            // return 'error3 第'+i+'行数据活动区分选项列表的值'+inputvalues[8]+'不存在';
                            errorMag += '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'){
            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 +=
                  '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 +=
                'error3 第' +
                i +
                '行数据结果选项列表的值' +
                inputvalues[9] +
                '不存在';
                            errorMag += '=';
                        }
                       system.debug('inputvalues[0]=================>'+inputvalues[0]);
@@ -845,11 +1197,16 @@
                        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]));
            departmentSet.add(
              '%' +
                GetDepartment_Cateogy(inputvalues[3]) +
                '%' +
                '-' +
                GetEPurposeType(inputvalues[8])
            );
                        inputList.add(inputvalues);
                    }
                }
@@ -882,23 +1239,34 @@
                // 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 ];
        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
          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{
          } 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()];
        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);
                }
@@ -919,7 +1287,18 @@
                // }
                //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
          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);
@@ -929,8 +1308,6 @@
                        //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){
@@ -946,7 +1323,9 @@
                    String s_agencyname = null;
                    System.debug('dateMap===='+dateMap);
                    // System.debug('lineList[0]====不等于空'+lineList[1]);
                    if(dateMap.get(Date.valueOf(lineList[1].replace('/','-'))) != null){
          if (
            dateMap.get(Date.valueOf(lineList[1].replace('/', '-'))) != null
          ) {
                        System.debug('dateMap====不等于空');
                        week = dateMap.get(Date.valueOf(lineList[1].replace('/','-')));
                        System.debug('===='+week);
@@ -955,7 +1334,9 @@
                    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(' ','')));
            s_agencyname = nameConMap.get(
              nameIdMap.get(lineList[0].replace(' ', ''))
            );
                        System.debug('===='+s_agency);
                    }
                    // if(s_agency == null || s_agencyname == null){
@@ -965,17 +1346,27 @@
                    // }
                    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.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);
          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+'');
@@ -992,7 +1383,9 @@
                    String s_agency = null;
                    System.debug('dateMap===='+dateMap);
                    System.debug('lineList[0]====不等于空'+lineList[1]);
                    if(dateMap.get(Date.valueOf(lineList[1].replace('/','-'))) != null){
          if (
            dateMap.get(Date.valueOf(lineList[1].replace('/', '-'))) != null
          ) {
                        System.debug('dateMap====不等于空');
                        week = dateMap.get(Date.valueOf(lineList[1].replace('/','-')));
                        System.debug('===='+week);
@@ -1006,18 +1399,35 @@
                    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 +=
              'error2 第' +
              hang +
              '行数据报告日' +
              lineList[1] +
              '填写有误';
                        errorMag += '=';
                    }
                    agencyReport.Submit_date__c = week;   // 提出周
                    if((s_agency == null || s_agency == '')&& lineList[0] != '' && lineList[0] != null){
          if (
            (s_agency == null ||
            s_agency == '') &&
            lineList[0] != '' &&
            lineList[0] != null
          ) {
                        // return 'error2 第'+hang+'行数据担当'+lineList[0]+'不存在';
                        errorMag += '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('/','-')); // 活动日
            agencyReport.Report_Date__c = Date.valueOf(
              lineList[1].replace('/', '-')
            ); // 活动日
                    }
                    if(ahlMap.containsKey(lineList[2])){
                        agencyReport.Agency_Hospital__c = ahlMap.get(lineList[2]).Id; //经销商医院
@@ -1025,12 +1435,15 @@
                        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 +=
                'error2 第' +
                hang +
                '行数据经销商医院' +
                lineList[2] +
                '不存在';
                            errorMag += '=';
                        }
                    }
                    
                    String departmentE = GetDepartment_Cateogy(lineList[3]);
@@ -1053,10 +1466,14 @@
                    }else{
                        if(lineList[4] != '' && lineList[4] != null){
                            // return 'error2 第'+hang+'行数据拜访人'+lineList[4]+'不存在';
                            errorMag += 'error2 第'+hang+'行数据拜访人'+lineList[4]+'不存在';
              errorMag +=
                'error2 第' +
                hang +
                '行数据拜访人' +
                lineList[4] +
                '不存在';
                            errorMag += '=';
                        }
                    }
                    if(GetPurposeType(lineList[8])){
@@ -1068,39 +1485,73 @@
                    }
                    // 科室产品区分关系判断
                    // 如果能找到,就是正确的
                    String departandprokey = '%'+GetDepartment_Cateogy(lineList[3])+'%'+'-'+GetEPurposeType(lineList[8]);
          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(
              '---===---===---===' +
              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]);
              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 +=
                '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]);
              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 +=
                  '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]);
              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 +=
                  'error4 第' +
                  hang +
                  '行数据产品区分3的赋值不正确' +
                  lineList[7];
                                errorMag += '=';
                            }
                        }
                    }
                    
                    // 通过map 科室,产品区分名 判断取值是否符合要求
                    // if(protypeMap.containsKey(lineList[5])){
@@ -1120,7 +1571,10 @@
                    }
                    String headerStr = createHeader(week,s_agency);
                    if(agency_report_headerMap.containsKey(headerStr)){
                        agencyReport.Agency_Report_Header__c = agency_report_headerMap.get(headerStr).Id; // 周报一览
            agencyReport.Agency_Report_Header__c = agency_report_headerMap.get(
                headerStr
              )
              .Id; // 周报一览
                    }
                    // if(aoMap.containsKey(lineList[6])){
                    //     agencyReport.Opportunity__c = aoMap.get(lineList[6]).Id; // 经销商询价
@@ -1151,8 +1605,6 @@
                    // insert arList;
                    LightningUtil.insertMAgencyReport(arList);
                }
            }
            return 'success';  
        }catch(Exception e){
@@ -1215,11 +1667,19 @@
        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');
      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());
        System.debug(
          'weixiaoweixiao' + resultlist + '' + pickListVal.getValue()
        );
                return false;
            }
        }
@@ -1238,7 +1698,10 @@
    }
    // 判断产品区分是否满足要求
    public static String ifTrueProduct(List<Map<String,String>> prolist,String str){
  public static String ifTrueProduct(
    List<Map<String, String>> prolist,
    String str
  ) {
        system.debug('=ifTrueProduct==============ifTrueProduct========='+str);
        system.debug('=prolist==============prolist========='+prolist);
@@ -1251,16 +1714,31 @@
        return '';
    }
    // 获取导入数据的科室和产品区分的匹配
    public static Map<String,List<Map<String,String>>> getImplProductList(Set<String> ptdc){
  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]];
        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]];
        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){
@@ -1270,15 +1748,27 @@
                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]];
        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]];
        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){
@@ -1293,9 +1783,22 @@
            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]];
        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]];
        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){
@@ -1310,9 +1813,22 @@
            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]];
        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]];
        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){
@@ -1327,9 +1843,22 @@
            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]];
        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]];
        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){
@@ -1344,9 +1873,22 @@
            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]];
        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]];
        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){
@@ -1361,9 +1903,22 @@
            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]];
        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]];
        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){
@@ -1378,9 +1933,22 @@
            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]];
        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]];
        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){
@@ -1396,9 +1964,22 @@
            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]];
        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]];
        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){
@@ -1413,9 +1994,22 @@
            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]];
        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]];
        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){
@@ -1430,9 +2024,22 @@
            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]];
        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]];
        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){
@@ -1447,9 +2054,22 @@
            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]];
        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]];
        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){
@@ -1464,9 +2084,22 @@
            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]];
        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]];
        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){
@@ -1481,9 +2114,22 @@
            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]];
        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]];
        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){
@@ -1498,9 +2144,22 @@
            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]];
        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]];
        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){
@@ -1515,9 +2174,22 @@
            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]];
        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]];
        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){
@@ -1532,9 +2204,22 @@
            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]];
        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]];
        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){
@@ -1549,9 +2234,22 @@
            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]];
        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]];
        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){
@@ -1566,9 +2264,22 @@
            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]];
        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]];
        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){
@@ -1583,9 +2294,22 @@
            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]];
        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]];
        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){
@@ -1600,9 +2324,22 @@
            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]];
        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]];
        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){
@@ -1617,9 +2354,22 @@
            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]];
        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]];
        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){
@@ -1634,9 +2384,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]];
        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]];
        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){
@@ -1651,9 +2414,22 @@
            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]];
        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]];
        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){
@@ -1666,7 +2442,6 @@
        }
        return impProMap;
    }
    // 批量添加周报by vivek end 
@@ -1680,7 +2455,11 @@
                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];
      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;