| | |
| | | |
| | | /***************表格数据*********************/ |
| | | public List<AddressData> tableData { get; set; } |
| | | public String tableDataStr{ get; set; } |
| | | public String staticResource {get; set;} |
| | | public String staticResourceContact {get; set;} |
| | | public String staticResourceRepair {get; set;} |
| | | public Contact newCon{get; set;} |
| | | |
| | | /***************底部 编辑和新增的 对象*******************/ |
| | | public Address__c insUpdData{get;set;} |
| | | public String insUpdDataStr{get;set;} |
| | | |
| | | /***************被编辑数据的id********************/ |
| | | public String UpdId{get;set;} |
| | |
| | | /***************是否发生数据接口的序号*************/ |
| | | public Integer AddressTypeIndex{get;set;} |
| | | |
| | | public String contactId{set;get;}//For Lookup field |
| | | |
| | | // Add by Li Jun for PIPL 20220308 Start |
| | | public String contactNameValue{set;get;} |
| | | public String contactIdValue{set;get;} |
| | | public String addressDataIds{set;get;} |
| | | public String sfRecordId{set;get;} |
| | | // Add by Li Jun for PIPL 20220308 End |
| | | |
| | | public String accRecordTypeId {set;get;}//当前 记录类型id |
| | | |
| | | public String accOfficeTypeId {set;get;}//记录类型id 办事处 |
| | | public String accAgencyTypeId {set;get;}//记录类型id 販売店 |
| | | public String accAgencyContactTypeId {set;get;}//记录类型id 经销商联系人 |
| | | |
| | | public StraightBackAddressController() { |
| | | //获取url数据 |
| | | RepairId = System.currentPageReference().getParameters().get('id'); |
| | |
| | | addContact = new Contact(); |
| | | //查询到所有的科室类别 |
| | | hospitalTypp = '診療科 その他,診療科 呼吸科,診療科 婦人科,診療科 普外科,診療科 泌尿科,診療科 消化科,診療科 耳鼻喉科,診療科(共通)'; |
| | | |
| | | |
| | | staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('Address__c')); |
| | | staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact')); |
| | | staticResourceRepair = JSON.serialize(PIHelper.getPIIntegrationInfo('Repair__c')); |
| | | } |
| | | |
| | | /** |
| | | * 开始方法 |
| | | */ |
| | | public PageReference init(){ |
| | | Schema.RecordTypeInfo recordTypeValue = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Office'); |
| | | if(recordTypeValue == null){ |
| | | recordTypeValue = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('office'); |
| | | } |
| | | accOfficeTypeId = recordTypeValue.getRecordTypeId(); |
| | | accAgencyTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId(); |
| | | accAgencyContactTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('AgencyContact').getRecordTypeId(); |
| | | String RepairSql = makeTextRepairSql(RepairId); |
| | | try{ |
| | | pc = Database.query(RepairSql); |
| | | system.debug('pc = ' + pc); |
| | | //给一个全局变量赋值医院id |
| | | if(!String.isBlank(pc.HP_ID__c)){ |
| | | hospitalId = pc.HP_ID__c; |
| | |
| | | ApexPages.addMessages(e); |
| | | } |
| | | insUpdData = new Address__c(); |
| | | newCon = new Contact(); |
| | | return null; |
| | | } |
| | | |
| | | |
| | | //查询客户记录类型 |
| | | public PageReference queryRecordType(){ |
| | | if(insUpdData.Customer__c!=null){ |
| | | String accid = insUpdData.Customer__c; |
| | | Account acc = [SELECT id,name,RecordTypeId FROM Account WHERE id =: accid]; |
| | | System.debug('acc---'+acc); |
| | | System.debug('insUpdData---'+insUpdData); |
| | | if(acc!=null&&acc.RecordTypeId!=null&&insUpdData.Customer__c!=null){ |
| | | accRecordTypeId = acc.RecordTypeId; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | //编辑获取数据 |
| | | public PageReference onEditor(){ |
| | | if(!String.isBlank(UpdId)){ |
| | |
| | | insUpdData = tableData[i].address; |
| | | } |
| | | } |
| | | insUpdDataStr = JSON.serialize(insUpdData); |
| | | } |
| | | } |
| | | return null; |
| | |
| | | } |
| | | } |
| | | } |
| | | insUpdDataStr = JSON.serialize(insUpdData); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | /* |
| | | //采用按钮 |
| | | public PageReference adoptSave(){ |
| | | //adoptId 要采用的地址数据id |
| | |
| | | } |
| | | //联系人 |
| | | String contactsName = ''; |
| | | String contactsNameEncrypt =''; |
| | | String contactawsDataId = ''; |
| | | if(!String.isBlank(tableData[i].address.Contacts__c)){ |
| | | contactsName = tableData[i].address.Contacts__r.Name; |
| | | contactsNameEncrypt = tableData[i].address.Contacts__r.LastName_Encrypted__c; |
| | | contactawsDataId = tableData[i].address.Contacts__r.AWS_Data_Id__c; |
| | | } |
| | | //客户 |
| | | String ContactPerson = ''; |
| | |
| | | try{ |
| | | //保存数据到修理表中 |
| | | Repair__c rc = new Repair__c(); |
| | | rc.id=RepairId; |
| | | rc.address_Contacts__c=contactsName; |
| | | rc.id = RepairId; |
| | | rc.Address_AWS_Data_Id__c = tableData[i].address.AWS_Data_Id__c; |
| | | rc.Contact_AWS_Data_Id__c = contactawsDataId; |
| | | rc.address_Contacts__c = contactsName; |
| | | rc.Address_Contacts_Encrypt__c = contactsNameEncrypt; |
| | | rc.address_ZipCode__c = tableData[i].address.ZipCode__c; |
| | | rc.Address_ZipCode_Encrypt__c = tableData[i].address.ZipCode_Encrypted__c; |
| | | rc.address_City__c = cityName; |
| | | rc.address_Contacts_Name__c = ContactPerson; |
| | | rc.Detailed_Address__c = tableData[i].address.Detailed_Address__c; |
| | | rc.Detailed_Address_Encrypt__c = tableData[i].address.Detailed_Address_Encrypted__c; |
| | | rc.address_Telephone__c = tableData[i].address.Telephone__c; |
| | | rc.Address_Telephone_Encrypt__c = tableData[i].address.Telephone_Encrypted__c; |
| | | //isUpload:是否上传SAP FSEApplyForRepairTime:SAP修理申请时间 |
| | | if(isUpload && (FSEApplyForRepairTime != null)){ |
| | | rc.Address_type__c = 'X'; |
| | |
| | | } |
| | | rc.address_Telephone__c=tableData[i].address.Telephone__c; |
| | | rc.Detailed_Address__c=address; |
| | | update rc; |
| | | if(!Test.isRunningTest()){ |
| | | update rc; |
| | | } |
| | | |
| | | //保存数据到保有设备表中 |
| | | Asset ast = new Asset( |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | */ |
| | | //重定向到 修理页面 |
| | | public PageReference redirectPag(){ |
| | | PageReference ref = new Pagereference('/' + RepairId); |
| | | ref.setRedirect(true); |
| | | return ref; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 检索数据查询 |
| | |
| | | List<Address__c> dataList = Database.query(AddressSql); |
| | | if(dataList != null && dataList.size()> 0){ |
| | | indexCou += dataList.size(); |
| | | System.debug('dataList-----'+dataList); |
| | | for(Integer i = 0;i<dataList.size();i++){ |
| | | String createID = dataList[i].CreatedByid; |
| | | createId = createId.substring(0,15); |
| | | //办事处的地址不可修改 |
| | | |
| | | if(dataList[i].Address_Classification__c == '办事处'){ |
| | | tableData.add(new AddressData(dataList[i],'none','none','inline')); |
| | | tableData.add(new AddressData(dataList[i],'none','none','inline')); |
| | | }else{ |
| | | //只能改自己创建的地址数据,系统管理员、GPI_系统管理员New 没限制 |
| | | if(loginPerson == createId ||loginPerson == '00e10000000dzzG' ||loginPerson == '00e10000000Y3o5'){ |
| | |
| | | } |
| | | } |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '共有 '+indexCou+' 条数据')); |
| | | tableDataStr = JSON.serialize(tableData); |
| | | system.debug('tableDataStr = ' + tableDataStr); |
| | | }catch(Exception e){ |
| | | //失败提示 |
| | | ApexPages.addMessages(e); |
| | |
| | | * 保存和修改的方法 |
| | | */ |
| | | public PageReference save(){ |
| | | system.debug('Address value:'+JSON.serialize(insUpdData)); |
| | | if(String.isNotBlank(contactIdValue)&&String.isNotEmpty(contactIdValue)){ |
| | | system.debug('Contact Value:'+contactIdValue); |
| | | insUpdData.Contacts__c = contactIdValue; |
| | | } |
| | | system.debug('Address value:'+JSON.serialize(insUpdData)); |
| | | savepoint sp = Database.setsavepoint(); |
| | | if(insUpdData != null){ |
| | | boolean flag = true; |
| | |
| | | monicker = surname.substring(1,surname.length()); |
| | | surname = surname.substring(0,1); |
| | | } |
| | | addContact = new Contact(LastName=surname,FirstName=monicker,AccountId=insUpdData.Customer__c,RecordTypeId=typeL); |
| | | System.debug('newCon = '+newCon); |
| | | addContact = new Contact(LastName = surname, |
| | | FirstName = monicker, |
| | | AccountId = insUpdData.Customer__c, |
| | | RecordTypeId = typeL, |
| | | AWS_Data_Id__c = newCon.AWS_Data_Id__c, |
| | | LastName_Encrypted__c = newCon.LastName_Encrypted__c); |
| | | try{ |
| | | //新增一条联系人数据 |
| | | insert addContact; |
| | | sfRecordId = addContact.id; |
| | | insUpdData.Create_Contacts__c = ''; |
| | | }catch(Exception e){ |
| | | //ApexPages.addMessages(e); |
| | |
| | | try{ |
| | | //新增或修改数据 |
| | | upsert insUpdData; |
| | | |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '保存成功!')); |
| | | isSearchBtn = true; |
| | | //保存成功,需要初始化一下此对象,防止再次点击此按钮保存一个条同样的数据 |
| | |
| | | |
| | | //查询修理表数据 |
| | | private String makeTextRepairSql(String uuid){ |
| | | String RepairSql = 'SELECT ID,NAME,HP_ID__c,HP_Name__c,Delivered_Product__c,FSE_ApplyForRepair_time__c,SAP_Transfer_time__c,Dealer__c,Dealer__r.Name,Returns_Product_way__c,Address_Type_Index__c FROM Repair__c where id = \''+RepairId+'\''; |
| | | String RepairSql = 'SELECT ID,NAME,HP_ID__c,HP_Name__c,Delivered_Product__c,FSE_ApplyForRepair_time__c,SAP_Transfer_time__c,Dealer__c,Dealer__r.Name,Returns_Product_way__c,Address_Type_Index__c,AWS_Data_Id__c FROM Repair__c where id = \''+RepairId+'\''; |
| | | return RepairSql; |
| | | } |
| | | //查询地址表数据 |
| | | private String makeTextAddressSql(String typeSearchId) { |
| | | String AddressSql = 'SELECT ID,Address_Classification__c,Customer__c,Customer__r.Name,Contacts__c,Contacts__r.Name,Telephone__c' |
| | | +',Province__c,Province__r.Name,City__c,City__r.name,Detailed_Address__c,Create_Contacts__c,ZipCode__c,CreatedByid ' |
| | | String AddressSql = 'SELECT AWS_Data_Id__c,ID,Address_Classification__c,Customer__c,Customer__r.Name,Customer__r.Type,Customer__r.RecordTypeId,Contacts__c,Contacts__r.Name,Contacts__r.AWS_Data_Id__c,Telephone__c' |
| | | +',Province__c,Province__r.Name,City__c,City__r.name,Detailed_Address__c,Create_Contacts__c,ZipCode__c,CreatedByid,Detailed_Address_Encrypted__c,Telephone_Encrypted__c,ZipCode_Encrypted__c,Contacts__r.LastName_Encrypted__c' |
| | | + ' FROM Address__c where id != null'; |
| | | //类型筛选 |
| | | if(!String.isBlank(typeText)){ |
| | |
| | | AddressSql += ' and Customer__r.Name LIKE \'%' + txtName.trim() + '%\'' ; |
| | | } |
| | | //详细地址筛选 |
| | | if(!String.isBlank(txtAddress)){ |
| | | AddressSql += ' and Detailed_Address__c LIKE \'%' + txtAddress.trim() + '%\'' ; |
| | | // if(!String.isBlank(txtAddress)){ |
| | | // AddressSql += ' and Detailed_Address__c LIKE \'%' + txtAddress.trim() + '%\'' ; |
| | | // } |
| | | if(!String.isBlank(addressDataIds)){ |
| | | AddressSql += ' and AWS_Data_Id__c in('+addressDataIds.trim()+')'; |
| | | } |
| | | //排序,根据上次修改时间和采用时间进行降序排序,值为空放到后面 |
| | | AddressSql += ' order by LastModifiedDate desc,Using_Datetime__c desc NULLS LAST'; |
| | |
| | | if(String.isBlank(typeSearchId)){ |
| | | AddressSql += ' limit 1000 '; |
| | | } |
| | | System.debug('AddressSql = '+AddressSql); |
| | | return AddressSql; |
| | | } |
| | | //查询医院客户人员信息 |
| | |
| | | + ' RecordType.name,Parent.Parent.Id FROM Account WHERE ID = \'' + accId + '\''; |
| | | return AccountSql; |
| | | } |
| | | |
| | | @RemoteAction |
| | | public static string SaveEx(string repaire_json,string asset_json, string address_id){ |
| | | return SaveExCore(repaire_json,asset_json,address_id); |
| | | } |
| | | |
| | | public static string SaveExCore(string repaire_json,string asset_json, string address_id){ |
| | | string message = null; |
| | | string savemessage = null; |
| | | savepoint sp = Database.setsavepoint(); |
| | | try { |
| | | Repair__c r = (Repair__c)JSON.deserialize(repaire_json,Repair__c.class); |
| | | Asset ast = (Asset)JSON.deserialize(asset_json,Asset.class); |
| | | Address__c add = new Address__c(Id=address_id,Using_Datetime__c = Datetime.now()); |
| | | update r; |
| | | update ast; |
| | | update add; |
| | | }catch(DmlException e) { |
| | | Integer index = 0; |
| | | System.debug(e.getNumDml()); |
| | | System.debug(e.getDmlFields(index)); |
| | | System.debug(e.getDmlId(index)); |
| | | System.debug(e.getDmlIndex(index)); |
| | | System.debug(e.getDmlMessage(index)); |
| | | System.debug(e.getDmlStatusCode(index)); |
| | | System.debug(e.getDmlType(index)); |
| | | system.debug(e.getMessage()); |
| | | system.debug(e.getStackTraceString()); |
| | | |
| | | System.debug('into catch'+e.getMessage()); |
| | | Database.rollback(sp); |
| | | |
| | | message ='保存失败,原因:'+ e.getDmlMessage(index); |
| | | savemessage = e.getMessage()+e.getStackTraceString(); |
| | | } catch (Exception e) { |
| | | System.debug('into catch'+e.getMessage()); |
| | | Database.rollback(sp); |
| | | |
| | | savemessage = e.getMessage()+e.getStackTraceString(); |
| | | message = '保存失败'; |
| | | } finally { |
| | | PIHelper.saveTransLog('StraightBackAddressController',address_id,address_id,address_id, repaire_json ,asset_json,message); |
| | | } |
| | | return message; |
| | | } |
| | | |
| | | /** |
| | | * 为了方便前段table获取值 |
| | |
| | | class AddressData { |
| | | //数据 |
| | | public Address__c address { get; set; } |
| | | |
| | | public string addressJson { get{ |
| | | if (address == null) { |
| | | return null; |
| | | } |
| | | return JSON.serialize(address); |
| | | } } |
| | | |
| | | //编辑按钮是否展示 |
| | | public String canEdit { get; private set; } |
| | | //编辑按钮是否展示 |