| | |
| | | |
| | | @RestResource(urlMapping = '/NFM624/*') |
| | | global with sharing class NFM624Rest { |
| | | //add to AWS 回复 start sushanhu 20220225 |
| | | static Boolean SFStatus=true; |
| | | static String SFMessage=''; |
| | | //add to AWS 回复 end sushanhu 20220225 |
| | | private static final String LOG_TYPE = 'NFM624'; |
| | | // global class GeDatasRest { |
| | | // public GeDatas GeDatas; |
| | |
| | | } |
| | | |
| | | global class GeData { |
| | | public String ContactId; //统一平台ID |
| | | public String ContactId; //统一平台ID//Update to aws 存储的AWSContactId 20220225 SUSHANHU |
| | | public String ServiceUserId; //服务平台用户ID |
| | | public String PersonManagementCode; //人员管理编码 |
| | | public String HospitalManagementCode2; //医院平台编码 平台编码 PlatformCode__c |
| | | public String DepartmentManagementCode2; //科室平台编码 平台编码 PlatformCode__c |
| | | public String Name; //姓名 |
| | | public String NameEncrypted;//姓名密文 add 20220215 |
| | | public String Mobile; //手机号码 |
| | | public String MobileEncrypted;//手机号码密文 add 20220215 |
| | | public String State; //单位所在省份 |
| | | public String City; //市 |
| | | public String AccountName; //医院名 |
| | |
| | | public String RelatedDepartment; //关联SFDC科室 客户管理编码(手写) AgentCode_Ext__c |
| | | public String Type; //职种 |
| | | public String ContactAddress; //联系地址 |
| | | public Boolean ForbiddenStatus; //平台用户禁用标识 |
| | | public String ContactAddressEncrypted;//联系地址密文 |
| | | public Boolean ForbiddenStatus; //平台用户禁用标识 |
| | | public String RegSource; //注册平台来源 |
| | | public Boolean AgentFlag; //经销商标识 |
| | | public String ApproverID; //审核人员员工编码 |
| | | public String DataId;//aws存储凭据 |
| | | } |
| | | |
| | | @HttpPost |
| | |
| | | // 取得接口传输内容 |
| | | String strData = RestContext.request.requestBody.toString(); |
| | | GeDatas ges = (GeDatas) JSON.deserializeStrict(strData, GeDatas.class); |
| | | |
| | | system.debug('ges---'+ges); |
| | | |
| | | if (ges == null) { |
| | | return; |
| | |
| | | RestResponse res = RestContext.response; |
| | | res.addHeader('Content-Type', 'application/json'); |
| | | res.statusCode = 200; |
| | | String jsonResponse = '{"status": "Success", "Message":""}'; |
| | | res.responseBody = blob.valueOf(jsonResponse); |
| | | // String jsonResponse = '{"status": "Success", "Message":""}'; |
| | | // res.responseBody = blob.valueOf(jsonResponse); |
| | | //updata response toAWS 20220225 sushanhu start |
| | | NFMUtil.NFMResponse result = NFMUtil.getNFMResponse(); |
| | | result.SFStatus=SFStatus; |
| | | result.SFMessage=SFMessage; |
| | | String jsonResponse =JSON.serialize(result); |
| | | system.debug('result---'+jsonResponse); |
| | | res.responseBody = blob.valueOf(jsonResponse); |
| | | //updata response toAWS 20220225 sushanhu end |
| | | return; |
| | | } |
| | | |
| | |
| | | try { //根据传过来的管理编码查询如果可以查询得到结果则更新,查询不到则新增 |
| | | List < Gedata > newGeDataList = new List < Gedata > (); |
| | | for (Gedata gedata: GeDataList) { |
| | | string dataComplete = verify(gedata); |
| | | //for test |
| | | gedata.AgentFlag=false; |
| | | // string dataComplete = verify(gedata); |
| | | string dataComplete =null; |
| | | // test end for pi |
| | | if (!String.isBlank(dataComplete)) { |
| | | logstr += dataComplete; |
| | | rowData.Is_Error__c = 1; |
| | |
| | | ct.MobilePhone = gedata.Mobile; |
| | | ct.RegSource__c = comefrom; |
| | | ct.UnifiedI_Contact_ID__c = gedata.ContactId; //统一平台Id |
| | | // //UPDATE TO AWS 存储的统一平台id |
| | | // ct.AWS_UnifiedI_Contact_ID__c=gedata.ContactId; //统一平台Id |
| | | ct.ServicePlatformCode__c = gedata.ServiceUserId; //服务平台用户Id |
| | | ct.Contact_address__c = gedata.ContactAddress;//联系地址 |
| | | ct.Contact_address_Encrypted__c=gedata.ContactAddressEncrypted;//联系地址密文 add 20220215 |
| | | ct.Platform_disabled_representation__c = gedata.ForbiddenStatus;//平台禁用标识 |
| | | //ct.IsFromPlatform__c = true; //来自智慧医疗创建 |
| | | ct.Ignore_Same_Name__c = true; //不是重复的客户名 |
| | | //ct.SendToComPlat__c = true; |
| | | ct.AWS_Data_Id__c =gedata.DataId;//add 20220215 aws存储凭证 |
| | | ct.MobilePhone_Encrypted__c =gedata.MobileEncrypted;//add 20220215 手机密文 |
| | | ct.LastName_Encrypted__c =gedata.NameEncrypted;//add 20220215 姓名密文 |
| | | |
| | | String personCode = gedata.PersonManagementCode; |
| | | |
| | |
| | | //2022/2/10 修改 在新建联系人之后手动执行NFM620RestBatch NFM623RestBatch |
| | | // Database.executeBatch(new NFM620RestBatch(), 1); |
| | | // Database.executeBatch(new NFM623RestBatch(), 1); |
| | | // supplement(gedata.ContactId); |
| | | supplement(gedata.ContactId); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (string.isblank(gda.Name)) { |
| | | result += 'DataError:姓名为空\n'; |
| | | } |
| | | if (string.isblank(gda.NameEncrypted)) { |
| | | result += 'DataError:姓名密文为空\n'; |
| | | } |
| | | if (string.isblank(gda.Mobile)) { |
| | | result += 'DataError:手机号为空\n'; |
| | | } |
| | | if (string.isblank(gda.MobileEncrypted)) { |
| | | result += 'DataError:手机号密文为空\n'; |
| | | } |
| | | if (string.isblank(gda.RegSource)) { |
| | | result += 'DataError:注册平台来源为空\n'; |
| | | }if (string.isblank(gda.DataId)) { |
| | | result += 'DataError:AWS加密凭据为空\n'; |
| | | } |
| | | if (gda.AgentFlag) { |
| | | if (string.isblank(gda.PersonManagementCode)) { |
| | |
| | | //把620Batch 和 623Batch 搬过来 |
| | | //补充询问单部分 start |
| | | //更新用 |
| | | List<CampaignMember__c> campaignMemberList = new List<CampaignMember__c>(); |
| | | List<Inquiry_form__c> inquiryFormList = new List<Inquiry_form__c>(); |
| | | //根据统一用户Id查询询问单 |
| | | List<Inquiry_form__c> InquiryList = [select Id,Inquiry_No__c,ContactId__c,Hospital_Name__c,Department_Class__c,Contact_Name__c from Inquiry_form__c where ContactId__c = :ContactId]; |
| | |
| | | //根据统一用户Id查询联系人 |
| | | List<Contact> contactList = [select Id,Name,UnifiedI_Contact_ID__c,Account.Id,Strategic_dept_Class__c,AccountId,Account.Name,Strategic_dept_Class__r.OwnerId from Contact where UnifiedI_Contact_ID__c = :ContactId]; |
| | | system.debug('contactList' + contactList); |
| | | //统一用户ID存入List、询问单ID存Map |
| | | Map<String, String> inquiryMap = new Map<String, String>(); |
| | | //List<String> contactIdList = new List<String>(); |
| | | for (Inquiry_form__c inquiryInfo : inquiryList) { |
| | | //contactIdList.add(inquiryInfo.ContactId__c); |
| | | inquiryMap.put(inquiryInfo.ContactId__c, inquiryInfo.Id); |
| | | } |
| | | if (contactList.size() >0 ) { |
| | | for (Contact contactInfo : contactList) { |
| | | Inquiry_form__c inquiry = new Inquiry_form__c(); |
| | | inquiry.Id = inquiryMap.get(contactInfo.UnifiedI_Contact_ID__c); //ID |
| | | inquiry.Hospital_Name__c = contactInfo.Account.Id; //科室名 |
| | | inquiry.Department_Class__c = contactInfo.Strategic_dept_Class__c; //战略科室分类 |
| | | inquiry.Contact_Name__c = contactInfo.Id; //客户姓名 |
| | | inquiry.OwnerId = contactInfo.Strategic_dept_Class__r.OwnerId; //所有人 |
| | | inquiryFormList.add(inquiry); |
| | | |
| | | if(InquiryList.size()>0){ |
| | | //统一用户ID存入List、询问单ID存Map |
| | | Map<String, String> inquiryMap = new Map<String, String>(); |
| | | //List<String> contactIdList = new List<String>(); |
| | | for (Inquiry_form__c inquiryInfo : inquiryList) { |
| | | //contactIdList.add(inquiryInfo.ContactId__c); |
| | | inquiryMap.put(inquiryInfo.ContactId__c, inquiryInfo.Id); |
| | | } |
| | | } |
| | | if(inquiryFormList.size()>0){ |
| | | update inquiryFormList; |
| | | if (contactList.size() >0 ) { |
| | | for (Contact contactInfo : contactList) { |
| | | Inquiry_form__c inquiry = new Inquiry_form__c(); |
| | | inquiry.Id = inquiryMap.get(contactInfo.UnifiedI_Contact_ID__c); //ID |
| | | inquiry.Hospital_Name__c = contactInfo.Account.Id; //科室名 |
| | | inquiry.Department_Class__c = contactInfo.Strategic_dept_Class__c; //战略科室分类 |
| | | inquiry.Contact_Name__c = contactInfo.Id; //客户姓名 |
| | | inquiry.OwnerId = contactInfo.Strategic_dept_Class__r.OwnerId; //所有人 |
| | | inquiryFormList.add(inquiry); |
| | | } |
| | | } |
| | | system.debug('inquiryFormList=========>'+inquiryFormList); |
| | | if(inquiryFormList.size()>0){ |
| | | update inquiryFormList; |
| | | } |
| | | } |
| | | //补充询问单部分 end |
| | | |
| | | //补充学会部分 start |
| | | List<CampaignMember__c> campaignMemberList = new List<CampaignMember__c>(); |
| | | //List<CampaignMember__c> campaignMemberList = new List<CampaignMember__c>(); |
| | | List<CampaignMember__c> capMemList = [select Id,Contact_ID__c,Campaign__c,Campaign__r.Num__c,ViewContactId__c from CampaignMember__c where Contact_ID__c = :ContactId]; |
| | | Map<String, String> capMemMap = new Map<String, String>(); |
| | | //统一用户ID存入List,参会人员记录ID存入MAP |
| | | //List<String> contactIdList = new List<String>(); |
| | | for (CampaignMember__c capMemInfo : capMemList) { |
| | | //contactIdList.add(capMemInfo.ViewContactId__c); |
| | | capMemMap.put(capMemInfo.ViewContactId__c,capMemInfo.Id); |
| | | } |
| | | //List<Contact> contactList = [select Id,Name,UnifiedI_Contact_ID__c,Account.Id,Strategic_dept_Class__c,AccountId,Account.Name,Strategic_dept_Class__r.OwnerId,Id from Contact where UnifiedI_Contact_ID__c = ContactId]; |
| | | if (contactList.size() > 0) { |
| | | for (Contact contactInfo : contactList) { |
| | | CampaignMember__c camMemberInfo = new CampaignMember__c(); |
| | | camMemberInfo.Id = capMemMap.get(contactInfo.UnifiedI_Contact_ID__c); |
| | | camMemberInfo.Contact_ID__c = contactInfo.ID; //参会人员ID |
| | | camMemberInfo.Department_ID__c = contactInfo.AccountId; //医院科室 |
| | | camMemberInfo.Department__c = contactInfo.Account.Name; //医院科室(文本) |
| | | camMemberInfo.Contact__c = contactInfo.Name; //客户人员姓名 |
| | | campaignMemberList.add(camMemberInfo); |
| | | if(capMemList.size() > 0){ |
| | | system.debug('capMemList=================>'+capMemList); |
| | | Map<String, String> capMemMap = new Map<String, String>(); |
| | | //统一用户ID存入List,参会人员记录ID存入MAP |
| | | //List<String> contactIdList = new List<String>(); |
| | | for (CampaignMember__c capMemInfo : capMemList) { |
| | | //contactIdList.add(capMemInfo.ViewContactId__c); |
| | | capMemMap.put(capMemInfo.ViewContactId__c,capMemInfo.Id); |
| | | } |
| | | |
| | | } |
| | | if (campaignMemberList.size() > 0) { |
| | | update campaignMemberList; |
| | | system.debug('capMemMap======>'+capMemMap); |
| | | //List<Contact> contactList = [select Id,Name,UnifiedI_Contact_ID__c,Account.Id,Strategic_dept_Class__c,AccountId,Account.Name,Strategic_dept_Class__r.OwnerId,Id from Contact where UnifiedI_Contact_ID__c = ContactId]; |
| | | if (contactList.size() > 0) { |
| | | for (Contact contactInfo : contactList) { |
| | | CampaignMember__c camMemberInfo = new CampaignMember__c(); |
| | | camMemberInfo.Id = capMemMap.get(contactInfo.UnifiedI_Contact_ID__c); |
| | | camMemberInfo.Contact_ID__c = contactInfo.Id; //参会人员ID |
| | | camMemberInfo.Department_ID__c = contactInfo.AccountId; //医院科室 |
| | | camMemberInfo.Department__c = contactInfo.Account.Name; //医院科室(文本) |
| | | camMemberInfo.Contact__c = contactInfo.Name; //客户人员姓名 |
| | | campaignMemberList.add(camMemberInfo); |
| | | } |
| | | } |
| | | system.debug('campaignMemberList================>'+campaignMemberList); |
| | | if (campaignMemberList.size() > 0) { |
| | | System.debug('--------1-------'); |
| | | update campaignMemberList; |
| | | } |
| | | } |
| | | //补充学会部分 end |
| | | } |