From 50c80c5b21d2ed2ce208defae08620e77a7fcc48 Mon Sep 17 00:00:00 2001 From: 付煜 <fuyu3103346691@163.com> Date: 星期四, 05 五月 2022 09:40:18 +0800 Subject: [PATCH] 经销商周报导入 --- force-app/main/default/classes/WeeklyReportCmp.cls | 126 +++++++++++++++++++++++++++++++++++------ 1 files changed, 107 insertions(+), 19 deletions(-) diff --git a/force-app/main/default/classes/WeeklyReportCmp.cls b/force-app/main/default/classes/WeeklyReportCmp.cls index 5197381..104e822 100644 --- a/force-app/main/default/classes/WeeklyReportCmp.cls +++ b/force-app/main/default/classes/WeeklyReportCmp.cls @@ -258,7 +258,10 @@ @AuraEnabled public static List<Agency_Hospital_Link__c> getHospitalList(String hospital_name) { hospital_name = '%' + hospital_name.trim() + '%'; - return [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('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 @@ -370,15 +373,15 @@ */ @RemoteAction - @AuraEnabled//SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start SupportNeedsc - public static String saveAgencyReport(String Department_Cateogy, String Purpose_Type, String Agency_Report_Header,String SupportNeedsc, + @AuraEnabled//SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� 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 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start SupportNeedsc + Product_Category1, Product_Category2, Product_Category3,//SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start SupportNeedsc ,SupportNeedsc Result, Opportunity, StageName, oppAmount, oppOCMPrice, Close_Forecasted_Date, Report_Date,SupportNeedsc); agency_report = LightningUtil.insertAgencyReport(agency_report); @@ -386,7 +389,7 @@ } 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 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start SupportNeeds__c + String Product_Category1, String Product_Category2, String Product_Category3,//SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� 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(); @@ -455,15 +458,15 @@ @RemoteAction @AuraEnabled - public static String editAgencyReport(String Agency_Report_Id, String Department_Cateogy, String Purpose_Type, String Agency_Report_Header, + 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 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start SupportNeeds__c - String Result, String Opportunity, String StageName, String oppAmount, String oppOCMPrice, String Close_Forecasted_Date, String Report_Date,String SupportNeedsc) + String Product_Category1, String Product_Category2, String Product_Category3, //SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� 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 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� start SupportNeeds__c - Agency_Report__c agency_report = [select Id, Name, Department_Cateogy__c, Purpose_Type__c, Agency_Hospital__c,SupportNeeds__c, + }//SWAG-CBX68C fy 銆愬鎵樸�慏AMS绯荤粺鍛ㄦ姤妯″潡鍐呭闇�姹傚鍔� 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]; Date week = Date.valueOf(Submit_date); @@ -588,19 +591,85 @@ // 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; + public Integer isDelete; + public String name; + public String nameEncrypt; + public String sfRecordId; + public String type; + public String typeEncrypt; + } @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'); + + // 缁忛攢鍟嗗尰闄㈠悕绉發ist + 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鐨刲ist + List<String> ahlOcsmIdList = new List<String>(); + 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]; + + for(Agency_Hospital_Link__c ahl : ahlList){ + ahlOcsmIdList.add(ahl.Hospital__c); + } + List<Agency_Contact__c> doctor2list = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c,AWS_Data_Id__c,Name_Encrypted__c FROM Agency_Contact__c WHERE Hospital_ID18__c= :ahlOcsmIdList order by Name]; + + if(errorMag != ''){ + return errorMag; + } + String doctor2listStr = JSON.serialize(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); + // System.debug('Agency_ContactListjson::::'+Agency_ContactListjson); 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'); // 鎷呭綋鍚嶇О鐨刲ist @@ -622,6 +691,7 @@ 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){ @@ -717,7 +787,8 @@ errorMag += '='; } } - if(inputvalues[9] != '\r' && getResultlist(inputvalues[9])){ + // if(inputvalues[9] != '\r' && getResultlist(inputvalues[9])){ + if(inputvalues[9] != '' && getResultlist(inputvalues[9])){ // return 'error3 绗�'+i+'琛屾暟鎹粨鏋滈�夐」鍒楄〃鐨勫��'+inputvalues[9]+'涓嶅瓨鍦�'; errorMag += 'error3 绗�'+i+'琛屾暟鎹粨鏋滈�夐」鍒楄〃鐨勫��'+inputvalues[9]+'涓嶅瓨鍦�'; errorMag += '='; @@ -732,6 +803,7 @@ 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]); @@ -805,9 +877,14 @@ // for(ProductTypes__c protype : proTypeList){ // protypeMap.put(protype.Name, protype.Id); // } - List<Agency_Contact__c> doctor2list = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c FROM Agency_Contact__c WHERE Hospital_ID18__c= :ahlOcsmIdList order by Name]; + //fy 20220424 start AWS_Data_Id__c + List<Agency_Contact__c> doctor2list = [select id,Name,Doctor_Division1__c,Type__c,Agency_Hospital__c,AWS_Data_Id__c,Name_Encrypted__c FROM Agency_Contact__c WHERE Hospital_ID18__c= :ahlOcsmIdList order by Name]; for(Agency_Contact__c ac : doctor2list){ - doctor2Map.put(ac.Name.replace(' ',''), ac.Id); + //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); + //fy 20220424 end } @@ -920,9 +997,15 @@ // errorMag += 'error2 绗�'+hang+'琛屾暟鎹瀹�'+lineList[3]+'涓嶅瓨鍦�'; // errorMag += '='; } - - if(doctor2Map.containsKey(lineList[4].replace(' ',''))){ - agencyReport.doctor2__c = doctor2Map.get(lineList[4].replace(' ','')); // 鎷滆浜� + //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]+'涓嶅瓨鍦�'; @@ -986,6 +1069,11 @@ // 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; // 鍛ㄦ姤涓�瑙� @@ -1025,7 +1113,7 @@ return 'success'; }catch(Exception e){ System.debug('exception'+e); - return 'exception'+e; + return e.getLineNumber()+'exception:'+e; } return 'success'; } -- Gitblit v1.9.1