| | |
| | | public without sharing class NFM606Controller { |
| | | |
| | | public static String logstr; |
| | | public static String status; |
| | | public static String status; |
| | | //add aws respnse sushanhu 20220228 start |
| | | public static String responseBody; |
| | | //add aws respnse sushanhu 20220228 end |
| | | private static final String LOG_TYPE = 'NFM606'; |
| | | private static final String API = '/admin/api/user/save'; |
| | | public class NFM606 { |
| | |
| | | public String AgentCode; //经销商编码 |
| | | public String AgentUserType; //人员类型 |
| | | public String Email; //电子邮件 |
| | | //add aws pi start sushanhu 20220228 |
| | | public String DataId;//aws 存储凭据 |
| | | //add aws pi end sushanhu 20220228 |
| | | |
| | | } |
| | | |
| | |
| | | Account.ParentId, |
| | | Account.Parent.ParentId, |
| | | UniqueNumber__c, |
| | | AWS_Data_Id__c, |
| | | ChargeState__c, // 20220829 ljh LLIU-CHR8FF add |
| | | Account.RecordTypeId,// 20220829 ljh LLIU-CHR8FF add |
| | | ChargeState__r.Level1_Code__c,// 20220829 ljh LLIU-CHR8FF add |
| | | Name, Email from Contact where id in: conIdList AND RecordTypeId != '01210000000QtkyAAC' |
| | | ]; |
| | | String logstr = iflog.Log__c + ' ' + 'NumberOfRecord=' + conList.size() + '\n'; |
| | |
| | | String flag = ''; |
| | | GeData ged = new GeData(); |
| | | ged.ContactId = String.isBlank(con.UnifiedI_Contact_ID__c) ? '':con.UnifiedI_Contact_ID__c; //智慧医疗ID |
| | | //update to AWS_UnifiedI_Contact_ID__c sushanhu 20220228 start |
| | | //ged.ContactId = String.isBlank(con.) ? '':con.AWS_UnifiedI_Contact_ID__c; //AWS 智慧医疗ID |
| | | ////update to AWS_UnifiedI_Contact_ID__c sushanhu 20220228 end |
| | | ged.ServiceUserId = String.isBlank(con.ServicePlatformCode__c) ? '':con.ServicePlatformCode__c; //服务平台用户ID??? |
| | | ged.Mobile = String.isNotBlank(con.UniqueNumber__c) ? con.UniqueNumber__c:con.MobilePhone;//手机 |
| | | //ged.Mobile = String.isNotBlank(con.UniqueNumber__c) ? con.UniqueNumber__c:con.MobilePhone;//手机 |
| | | ged.Mobile = con.MobilePhone;//手机 zhj 新方案改造 不需要UniqueNumber__c |
| | | ged.PersonManagementCode = con.CManageCode__c; //人员管理编码 |
| | | ged.Status = '有效'.equals(con.Isactive__c) ? true:false ;//状态 |
| | | ged.Name = con.Name;//姓名 |
| | |
| | | ged.Hospital = con.Account.Parent_Management_Code__c;//医院编码 |
| | | ged.Department = con.Account.Management_Code__c; //科室编码 |
| | | ged.AgentFlag = false;//医院 |
| | | |
| | | } |
| | | // 经销商 |
| | | if ('01210000000QfWiAAK'.equals(con.RecordTypeId)) { |
| | |
| | | ged.AgentFlag = true;//经销商 |
| | | ged.Email = con.Email; |
| | | } |
| | | ged.DataId =con.AWS_Data_Id__c;//add aws 存储凭据 |
| | | ged = getStateAndCity(ged,con); |
| | | gds.GeData.add(ged); |
| | | |
| | |
| | | String city = ''; |
| | | String salesdepartment_Dept = ''; |
| | | if (String.isBlank(con.Account.ParentId)) {//医院/经销商下的联系人,获取医院/经销商的省和市的编码;销售本部 |
| | | state = con.Account.State_Master__r.Level1_Code__c; |
| | | // 20220829 ljh LLIU-CHR8FF update start |
| | | // state = con.Account.State_Master__r.Level1_Code__c; |
| | | Id AgencyId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); |
| | | // System.debug('aaa000zheli'+con.ChargeState__c+'~'+AgencyId+'~'+con.Account.RecordTypeId+'~'+con.Account.State_Master__c); |
| | | if(String.isNotBlank(con.ChargeState__c) && con.Account.RecordTypeId == AgencyId &&String.valueOf(con.ChargeState__c).substring(0,15) != String.valueOf(con.Account.State_Master__c).substring(0,15)){ |
| | | state = con.ChargeState__r.Level1_Code__c; |
| | | }else{ |
| | | state = con.Account.State_Master__r.Level1_Code__c; |
| | | } |
| | | // 20220829 ljh LLIU-CHR8FF update end |
| | | city = con.Account.City_Master__r.Level2_Code__c; |
| | | salesdepartment_Dept = con.Account.Salesdepartment_Dept__c; //销售本部 |
| | | } else if(String.isNotBlank(con.Account.Parent.ParentId)){//科室下的联系人, 获取医院的省和市的编码;销售本部 |
| | |
| | | city = con.Account.Hospital_Department_Class__r.City_Master__r.Level2_Code__c;//市 |
| | | salesdepartment_Dept = con.Account.Hospital_Department_Class__r.Salesdepartment_Dept__c;//销售本部 |
| | | } |
| | | //LLIU-CKQ5FS 【委托】SFDC上“复旦大学附属中山医院厦门医院”省市问题 LY 20221101 end |
| | | system.debug('1111111111111111111111111111'); |
| | | if (con.Account.Parent_Management_Code__c =='8045004') { |
| | | state = 'CN-19'; |
| | | city = 'CN-1917'; |
| | | } |
| | | //LLIU-CKQ5FS 【委托】SFDC上“复旦大学附属中山医院厦门医院”省市问题 LY 20221101 end |
| | | ged.State = state; |
| | | ged.City = city; |
| | | ged.SalesBusinessDivision = salesdepartment_Dept; |
| | |
| | | try { |
| | | |
| | | |
| | | // 发往PO |
| | | status = NFMUtil.sendToSapRet(rowDataStr, NFMUtil.NFM606_ENDPOINT); |
| | | System.debug('NFM606Log--status->'+ status); |
| | | // status = '' |
| | | if ('Accepted'.equals(status)) { |
| | | // // 发往PO |
| | | // status = NFMUtil.sendToSapRet(rowDataStr, NFMUtil.NFM606_ENDPOINT); |
| | | // System.debug('NFM606Log--status->'+ status); |
| | | // // status = '' |
| | | // if ('Accepted'.equals(status)) { |
| | | // logstr += status+'\n'; |
| | | // rowDataSFDC.retry_cnt__c = 0; |
| | | // } |
| | | // else { |
| | | // rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, null, status); |
| | | // } |
| | | //update to aws 20220228 sushanhu satrt |
| | | PIHelper.PIIntegration pi =PIHelper.getPIIntegrationInfo('NFM606'); |
| | | NFMUtil.response result =NFMUtil.sendToPiAWS(rowDataStr,pi.newUrl,pi.token); |
| | | system.debug('aws result---'+result); |
| | | responseBody=result.responseBody; |
| | | //Map<String, Object> res = (Map<String, Object>)JSON.deserializeUntyped(responseBody); |
| | | //status=(String)res.get(status); |
| | | status =result.status; |
| | | system.debug('stadtucode--'+result.status); |
| | | if ('202'.equals(status)) { |
| | | logstr += status+'\n'; |
| | | rowDataSFDC.retry_cnt__c = 0; |
| | | } |
| | | rowDataSFDC.retry_cnt__c = 0; |
| | | } |
| | | else { |
| | | logstr+=responseBody+'\n'; |
| | | rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, null, status); |
| | | } |
| | | //update to aws 20220228 sushanhu end |
| | | } catch (Exception ex) { |
| | | // TODO IOException |
| | | // 异常重发 |