|  |  |  | 
|---|
|  |  |  | //1.只查找100条保有设备数据 | 
|---|
|  |  |  | String fuselageNumberTrim = String.isNotBlank(FuselageNumber)?FuselageNumber.trim():''; | 
|---|
|  |  |  | String serialNumber = '%' + String.escapeSingleQuotes(fuselageNumberTrim.replaceAll('%', '\\%')) + '%'; | 
|---|
|  |  |  | List < Asset > assetListed =    [SELECT Id,name,SerialNumber,InstallDate,Information_From__c,Asset_situation__c, | 
|---|
|  |  |  | List < Asset > assetListed =    [SELECT Id,name,SerialNumber,InstallDate, | 
|---|
|  |  |  | // Information_From__c,// 20220927 ljh XLIU-CJN62G | 
|---|
|  |  |  | Asset_situation__c, | 
|---|
|  |  |  | Order_No__c,Account.Name,Status,Department_Class__c,Hospital__r.Owner.Name, | 
|---|
|  |  |  | Hospital__r.Owner.Phone,Installation_Site__c,CurrentContract__c, | 
|---|
|  |  |  | Product2.Asset_Model_No__c,Hospital__r.Name,Department_Class__r.Name , | 
|---|
|  |  |  | Department_Class__r.Id,Ji_Zhong_Guan_Li_Ku_Cun__c,Account.RecordTypeId | 
|---|
|  |  |  | Department_Class__r.Id, | 
|---|
|  |  |  | // Ji_Zhong_Guan_Li_Ku_Cun__c,// 20220927 ljh XLIU-CJN62G | 
|---|
|  |  |  | Posting_Date__c,Extend_Gurantee_DateTo__c,CurrentContract_End_Date__c,// 20220927 ljh XLIU-CJN62G | 
|---|
|  |  |  | Account.RecordTypeId | 
|---|
|  |  |  | ,Account.Parent.Parent.FSE_SP_Main_Leader__r.Work_Location__c | 
|---|
|  |  |  | ,Account.Parent.FSE_SP_Main_Leader__r.Work_Location__c | 
|---|
|  |  |  | //XLIU-CJM7Z9 【委托】新建修理提示信息(停产及非修理对象品)LY 20221012 start | 
|---|
|  |  |  | ,PartSupplyFinishDate__c | 
|---|
|  |  |  | //XLIU-CJM7Z9 【委托】新建修理提示信息(停产及非修理对象品)LY 20221012 end | 
|---|
|  |  |  | FROM Asset where Id != null AND Repairing_Count__c >= 0 AND SerialNumber like :serialNumber LIMIT 100 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ]; | 
|---|
|  |  |  | 
|---|
|  |  |  | for (Asset ast: assetListed) { | 
|---|
|  |  |  | choiceAssetInfoRecordsview.add(new ChoiceAssetInfo(ast)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 检索 | 
|---|
|  |  |  | 
|---|
|  |  |  | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '只能选择一个保有设备')); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //XLIU-CJM7Z9 【委托】新建修理提示信息(停产及非修理对象品)LY 20221012 start | 
|---|
|  |  |  | List<Asset> ass = [select id,Product_ID__c from Asset where ID = :ast.Id]; | 
|---|
|  |  |  | List<Product2> p2 = [select id,Name,Can_Repair__c | 
|---|
|  |  |  | from Product2 where | 
|---|
|  |  |  | ID = :ass[0].Product_ID__c]; | 
|---|
|  |  |  | String canRepair = p2[0].Can_Repair__c; | 
|---|
|  |  |  | if (canRepair=='第三方'){ | 
|---|
|  |  |  | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '非我司修理对象,无法新建修理,如有不明请咨询CIC')); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (canRepair=='不' || String.isBlank(canRepair)){ | 
|---|
|  |  |  | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '本设备无法新建修理')); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //XLIU-CJM7Z9 【委托】新建修理提示信息(停产及非修理对象品)LY 20221012 end | 
|---|
|  |  |  | return createData(ast); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public PageReference createData(Asset ast) { | 
|---|
|  |  |  | String url = '/'; | 
|---|
|  |  |  | String joint_1 = '='; | 
|---|
|  |  |  | String joint_2 = '_lkid='; | 
|---|
|  |  |  | String joint_3 = '&CF'; | 
|---|
|  |  |  | String joint_4 = '&'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //XLIU-CJM7Z9 【委托】新建修理提示信息(停产及非修理对象品)LY 20221110 start | 
|---|
|  |  |  | List<Asset> ass = [select id,Product_ID__c from Asset where ID = :ast.Id]; | 
|---|
|  |  |  | List<Product2> p2 = [select id,Name,Can_Repair__c | 
|---|
|  |  |  | from Product2 where | 
|---|
|  |  |  | ID = :ass[0].Product_ID__c]; | 
|---|
|  |  |  | String canRepair = p2[0].Can_Repair__c; | 
|---|
|  |  |  | system.debug('1111111111111111111'+canRepair); | 
|---|
|  |  |  | //XLIU-CJM7Z9 【委托】新建修理提示信息(停产及非修理对象品)LY 20221110 end | 
|---|
|  |  |  | if ('Repair'.equals(dataType)) { | 
|---|
|  |  |  | String Delivered_Product_Id = '00N10000002Dx1X'; //设备型号 | 
|---|
|  |  |  | String Account_Id = '00N10000002Dx5n'; //科室 | 
|---|
|  |  |  | 
|---|
|  |  |  | String  ActualVisitDateThird_Id= '';//三次上门日 | 
|---|
|  |  |  | String  SubOrderCompleteDate_Id= '';//报修单处理完成日 | 
|---|
|  |  |  | String  SubOrderCreatedDate_Id= '';//报修单申请修理日 | 
|---|
|  |  |  | //LLIU-CGX5E9 LY 20220812 start | 
|---|
|  |  |  | String  DateReceiptQuestions_Id = '';//问题联络收到日 | 
|---|
|  |  |  | //LLIU-CGX5E9 LY 20220812 end | 
|---|
|  |  |  | //XLIU-CJM7Z9 【委托】新建修理提示信息(停产及非修理对象品)LY 20221110 start | 
|---|
|  |  |  | String  Excwork_location_Id = '';//跳过维修中心 | 
|---|
|  |  |  | //XLIU-CJM7Z9 【委托】新建修理提示信息(停产及非修理对象品)LY 20221110 end | 
|---|
|  |  |  | String  engineerSendDate_Id= '';//工程师修理品寄送日 | 
|---|
|  |  |  | if (NFMUtil.isSandbox()) { //测试环境 | 
|---|
|  |  |  | RepairApplicant_Id = '00N1m0000054ufW'; //报修人 | 
|---|
|  |  |  | // RepairApplicantPosition_Id = '00N1m0000054ufV'; //报修人岗位 | 
|---|
|  |  |  | RepairApplicantHospital_Id = '00N1m0000054ufU'; //报修人医院 | 
|---|
|  |  |  | RepairApplicantDepartment_Id = '00N1m0000054ufT'; //报修人科室 | 
|---|
|  |  |  | baoxiuzidan = '00N1m0000054ufZ'; //报修子单 | 
|---|
|  |  |  | faqiri = '00N1m0000054ufa'; //报修发起日 | 
|---|
|  |  |  | shouliri = '00N1m0000054ufS'; //工程师受理日 | 
|---|
|  |  |  | // if (NFMUtil.isSandbox()) { //测试环境 | 
|---|
|  |  |  | //     RepairApplicant_Id = '00N1m0000054ufW'; //报修人 | 
|---|
|  |  |  | //     // RepairApplicantPosition_Id = '00N1m0000054ufV'; //报修人岗位 | 
|---|
|  |  |  | //     RepairApplicantHospital_Id = '00N1m0000054ufU'; //报修人医院 | 
|---|
|  |  |  | //     RepairApplicantDepartment_Id = '00N1m0000054ufT'; //报修人科室 | 
|---|
|  |  |  | //     //baoxiuzidan = '00N1m0000054ufZ'; //报修子单 | 
|---|
|  |  |  | //     baoxiuzidan = '00N10000009H1rR'; //报修子单 | 
|---|
|  |  |  | //     faqiri = '00N1m0000054ufa'; //报修发起日 | 
|---|
|  |  |  | //     shouliri = '00N1m0000054ufS'; //工程师受理日 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PlannedVisitDay_Id= '00N1m000005SRiF';//计划上门日 | 
|---|
|  |  |  | ActualVisitDateFirst_Id= '00N1m000005SRiK';//一次上门日 | 
|---|
|  |  |  | ActualVisitDateSecond_Id= '00N1m000005SRiP';//二次上门日 | 
|---|
|  |  |  | ActualVisitDateThird_Id= '00N1m000005SRiU';//三次上门日 | 
|---|
|  |  |  | SubOrderCompleteDate_Id= '00N1m000005SRmg';//报修单处理完成日 | 
|---|
|  |  |  | SubOrderCreatedDate_Id= '00N1m000005SRmW';//报修单申请修理日 | 
|---|
|  |  |  | } else { //正式环境 | 
|---|
|  |  |  | //     PlannedVisitDay_Id= '00N1m000005SRiF';//计划上门日 | 
|---|
|  |  |  | //     ActualVisitDateFirst_Id= '00N1m000005SRiK';//一次上门日 | 
|---|
|  |  |  | //     ActualVisitDateSecond_Id= '00N1m000005SRiP';//二次上门日 | 
|---|
|  |  |  | //     ActualVisitDateThird_Id= '00N1m000005SRiU';//三次上门日 | 
|---|
|  |  |  | //     SubOrderCompleteDate_Id= '00N1m000005SRmg';//报修单处理完成日 | 
|---|
|  |  |  | //     SubOrderCreatedDate_Id= '00N1m000005SRmW';//报修单申请修理日 | 
|---|
|  |  |  | // } else { //正式环境 | 
|---|
|  |  |  | RepairApplicant_Id = '00N10000009H1rQ'; //报修人 | 
|---|
|  |  |  | // RepairApplicantPosition_Id = ''; //报修人岗位 | 
|---|
|  |  |  | RepairApplicantHospital_Id = '00N10000009H1rP'; //报修人医院 | 
|---|
|  |  |  | 
|---|
|  |  |  | ActualVisitDateThird_Id= '00N10000009H1r8';//三次上门日 | 
|---|
|  |  |  | SubOrderCompleteDate_Id= '00N10000009H1ri';//报修单处理完成日 | 
|---|
|  |  |  | SubOrderCreatedDate_Id= '00N10000009H1rj';//报修单申请修理日 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //LLIU-CGX5E9 LY 20220812 start | 
|---|
|  |  |  | DateReceiptQuestions_Id= '00N10000008rsVQ';//问题联络收到日 | 
|---|
|  |  |  | //LLIU-CGX5E9 LY 20220812 end | 
|---|
|  |  |  | //XLIU-CJM7Z9 【委托】新建修理提示信息(停产及非修理对象品)LY 20221110 start | 
|---|
|  |  |  | Excwork_location_Id = '00N10000009HAJl';//跳过维修中心 | 
|---|
|  |  |  | //XLIU-CJM7Z9 【委托】新建修理提示信息(停产及非修理对象品)LY 20221110 end | 
|---|
|  |  |  | //} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | url += 'a0J/e?retURL=%2F'; | 
|---|
|  |  |  | //XLIU-CJM7Z9 【委托】新建修理提示信息(停产及非修理对象品)LY 20221110 start | 
|---|
|  |  |  | if (canRepair=='RC送修'){ | 
|---|
|  |  |  | url += joint_4 + Excwork_location_Id + joint_1 + true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //XLIU-CJM7Z9 【委托】新建修理提示信息(停产及非修理对象品)LY 20221110 end | 
|---|
|  |  |  | url += joint_3 + Delivered_Product_Id + joint_1 + ast.Name; | 
|---|
|  |  |  | url += joint_3 + Delivered_Product_Id + joint_2 + ast.Id; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | url += joint_4 +  ActualVisitDateSecond_Id+ joint_1 + NFMUtil.formatDateTime2StrSprit(repairSubOrder.ActualVisitDateSecon__c);//二次上门日 | 
|---|
|  |  |  | url += joint_4 +  ActualVisitDateThird_Id+ joint_1 + NFMUtil.formatDateTime2StrSprit(repairSubOrder.ActualVisitDateThird__c);//三次上门日 | 
|---|
|  |  |  | url += joint_4 +  SubOrderCompleteDate_Id+ joint_1 + NFMUtil.formatDateTime2StrSprit(repairSubOrder.ApplicationTime__c);//报修单处理完成日 | 
|---|
|  |  |  | //LLIU-CGX5E9 LY 20220812 start | 
|---|
|  |  |  | url += joint_4 +  DateReceiptQuestions_Id+ joint_1 + NFMUtil.formatDateTime2StrSprit(repairSubOrder.ApplicationTime__c);//问题联络收到日 | 
|---|
|  |  |  | //LLIU-CGX5E9 LY 20220812 end | 
|---|
|  |  |  | url += joint_4 +  SubOrderCreatedDate_Id+ joint_1 + NFMUtil.formatDateTime2StrSprit(Date.today());//报修单申请修理日 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | url += joint_4 + shouliri + joint_1 + NFMUtil.formatDateTime2StrSprit(repairSubOrder.ReceiverTime__c); | 
|---|
|  |  |  | 
|---|
|  |  |  | //add     wangweipeng        2022/01/26       end | 
|---|
|  |  |  | //add     zhangyuheng        2022/04/07       start | 
|---|
|  |  |  | if (String.isNotBlank(ast.Account.RecordTypeId)) { | 
|---|
|  |  |  | if (ast.Account.RecordTypeId == '01210000000QemQAAS') { //战略科室 | 
|---|
|  |  |  | if (ast.Account.RecordTypeId == '01210000000QemQAAS' || //战略科室 ET | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000QemL' || //战略科室 消化科 | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000Qezy' || //战略科室 其他 | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000Qf03' || //战略科室 不明 | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000QezZ' || //战略科室 呼吸科 | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000Qezo' || //战略科室 妇科 | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000Qeze' || //战略科室 普外科 | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000Qezj' || //战略科室 泌尿科 | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000Qezt'    //战略科室 耳鼻喉科 | 
|---|
|  |  |  | ) { //战略科室 | 
|---|
|  |  |  | if (String.isNotBlank(ast.Account.Parent.FSE_SP_Main_Leader__r.Work_Location__c)) { | 
|---|
|  |  |  | url += joint_4 +  SalesOfficeCode_selection_Id+ joint_1 + ast.Account.Parent.FSE_SP_Main_Leader__r.Work_Location__c;//修理品返送地 | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | // continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (ast.Account.RecordTypeId == '01210000000QfmRAAS') { //科室 | 
|---|
|  |  |  | if (ast.Account.RecordTypeId == '01210000000QfmRAAS' || //科室 呼吸科 | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000QfmH' || //科室 普外科 | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000Qfmb' || //科室 其他 | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000QfmM' || //科室 妇科 | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000QfmC' || //科室 泌尿科 | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000Qfm7' || //科室 消化科 | 
|---|
|  |  |  | ast.Account.RecordTypeId == '01210000000Qfm2'    //科室 耳鼻喉科 | 
|---|
|  |  |  | ) { //科室 | 
|---|
|  |  |  | if (String.isNotBlank(ast.Account.Parent.Parent.FSE_SP_Main_Leader__r.Work_Location__c)) { | 
|---|
|  |  |  | url += joint_4 +  SalesOfficeCode_selection_Id+ joint_1 + ast.Account.Parent.Parent.FSE_SP_Main_Leader__r.Work_Location__c;//修理品返送地 | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | 
|---|
|  |  |  | String Generation_Source_Id = '00N10000002FHF6';//QIS来源 | 
|---|
|  |  |  | String Name_Id = 'Name';//QIS管理号码 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (NFMUtil.isSandbox()) { | 
|---|
|  |  |  | baoxiuzidan = '00N1m000005STFv'; //报修子单 | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | // if (NFMUtil.isSandbox()) { | 
|---|
|  |  |  | //     baoxiuzidan = '00N1m000005STFv'; //报修子单 | 
|---|
|  |  |  | // } else { | 
|---|
|  |  |  | baoxiuzidan = '00N10000009H22X'; //报修子单 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // } | 
|---|
|  |  |  | url += 'a0f/e?retURL=%2Fa0f%2Fo&RecordType=01210000000RLWc&ent=01I10000000T5b1'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | url += joint_3 + Delivered_Product_Id + joint_1 + ast.Name; | 
|---|
|  |  |  | 
|---|
|  |  |  | private String makeSoql() { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String start = ''; | 
|---|
|  |  |  | String soql = 'select Id,name,SerialNumber,InstallDate,Information_From__c,Asset_situation__c,Order_No__c,Account.Name,Status,Department_Class__c, '; | 
|---|
|  |  |  | String soql = 'select Id,name,SerialNumber,InstallDate,Asset_situation__c,Order_No__c,Account.Name,Status,Department_Class__c, '; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | soql += 'Hospital__r.Owner.Name,Hospital__r.Owner.Phone,Installation_Site__c,CurrentContract__c,Product2.Asset_Model_No__c,Hospital__r.Name,Department_Class__r.Name ,Department_Class__r.Id,'; | 
|---|
|  |  |  | soql += 'Ji_Zhong_Guan_Li_Ku_Cun__c,Account.Parent.Parent.FSE_SP_Main_Leader__r.Work_Location__c'; | 
|---|
|  |  |  | soql += 'Account.Parent.Parent.FSE_SP_Main_Leader__r.Work_Location__c,Account.RecordTypeId'; | 
|---|
|  |  |  | soql += ',Posting_Date__c,Extend_Gurantee_DateTo__c,CurrentContract_End_Date__c  ';// 20220927 ljh XLIU-CJN62G | 
|---|
|  |  |  | soql += ',PartSupplyFinishDate__c ';//XLIU-CJM7Z9 【委托】新建修理提示信息(停产及非修理对象品)LY 20221012 | 
|---|
|  |  |  | soql += ' from Asset where Id != null AND Repairing_Count__c = 0 '; | 
|---|
|  |  |  | if (String.isNotBlank(FuselageNumber) || String.isNotBlank(AssetModel) || String.isNotBlank(HospitalName)) { | 
|---|
|  |  |  | soql += ' AND ('; | 
|---|