public with sharing class TenderDeleteLwcController { @AuraEnabled public static String GetTenderinformationcData(String ParamIdStr) { List arrays = Database.query('Select Id,Name,InfoId__c,Logical_delete__c,ProjectId__c,Retain_Tender__c From Tender_information__c Where id = : ParamIdStr'); return JSON.serialize(arrays); } // 查询招标项目 @AuraEnabled public static String searchTender(String content){ String soql = 'Select Id, Name, TenderManageCode__c, Logical_delete__c, Retain_Tender__c From Tender_information__c where Logical_delete__c = false '; if (String.isNotBlank(content) && String.isNotBlank(content.replaceAll(' ', ''))) { content = '%'+content+'%'; soql += ' and TenderManageCode__c like :content '; } system.debug('System.Label.BiddingProjectRecordTypeID+++'+System.Label.BiddingProjectRecordTypeID); String RecordTypeIdvalue=System.Label.BiddingProjectRecordTypeID; //DB202308327700 【重要】新需求-招标项目中导入众成数据 fy 20231106 start // soql += 'and RecordTypeId =\''+RecordTypeIdvalue+'\' Order by CreatedDate desc limit 5'; soql += ' Order by CreatedDate desc limit 5'; //DB202308327700 【重要】新需求-招标项目中导入众成数据 fy 20231106 end String jsonData = JSON.serialize(Database.query(soql)); return jsonData; } @AuraEnabled public static String saveData(String Tenderinformationc) { Boolean QLMflg = false; //DB202308327700 20230920 lt add String QLMrecordId = Schema.SObjectType.Tender_information__c.getRecordTypeInfosByDeveloperName().get('QLM').getRecordTypeId();//DB202308327700 20230920 lt add system.debug('Tenderinformationc++'+Tenderinformationc); Tender_information__c TenInfo=(Tender_information__c)JSON.deserialize(Tenderinformationc,Tender_information__c.class); List updateTenInfoList = new List(); // 更新保留招投标 // List updateBTenList = new List(); // 如果点击保存后,未选则保留招投标则报错 // SaveErrorflag = false; System.debug('--------' + TenInfo.Retain_Tender__c); if (String.isNotBlank(TenInfo.Retain_Tender__c)) { System.debug('---------2--------' + TenInfo.Retain_Tender__c); //要保留的招投标 //DB202308327700 20230920 lt add ,RecordTypeId Tender_information__c delTender = [select Id, RecordTypeId from Tender_information__c where Id = :TenInfo.Id]; Tender_information__c BTen = [select Id, InfoId__c,RecordTypeId From Tender_information__c Where Id = : TenInfo.Retain_Tender__c]; //DB202308327700 20230920 lt start if(delTender.RecordTypeId == QLMrecordId && BTen.RecordTypeId == QLMrecordId){ QLMflg = true; } // update 20240304 By DTT-亚楠 去除fileaddress start //FILEADDRESS检索 // List faList = [select Id, name,ParentRecordId__c From FileAddress__c // Where ParentRecordId__c = : TenInfo.Id]; // if(faList.Size() > 0 ){ // for(FileAddress__c fa : faList){ // fa.ParentRecordId__c = BTen.Id; // } // } List cdList = [SELECT Id, ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId = :TenInfo.Id]; List insertConDocuList = new List(); if (cdList.size() > 0) { for (ContentDocumentLink conDocu : cdList) { ContentDocumentLink link = new ContentDocumentLink(); link.ContentDocumentId = conDocu.ContentDocumentId; link.LinkedEntityId = BTen.Id; // link.ShareType = 'I'; link.Visibility = 'AllUsers'; insertConDocuList.add(link); } } // update 20240304 By DTT-亚楠 去除fileaddress end //DB202308327700 20230920 lt end // 保留招投标关联的询价 System.debug('---------BTen--------' + BTen); List BlinksList = [select Opportunity__c from Tender_Opportunity_Link__c where Tender_information__c = :BTen.Id]; Set BlinkOppId = new Set(); // if (BlinksList.size() > 0) { for (Tender_Opportunity_Link__c Blink : BlinksList) { BlinkOppId.add(Blink.Opportunity__c); } // 删除项目关联但不与保留项目关联的询价关联信息 List linksList = [select id, Opportunity__c, Tender_information__c from Tender_Opportunity_Link__c where Tender_information__c = :TenInfo.Id ]; // and Opportunity__c not in : BlinkOppId]; // 把删除招投标 关联的询价 赋给 保留招投标上 List addlinksList = new List(); // 删除招投标关联的询价 // 增加一个判断 看看是否还会写空进去 if (linksList != null && linksList.size() > 0) { for (Tender_Opportunity_Link__c link : linksList) { if(!BlinkOppId.contains(link.Opportunity__c)){ Tender_Opportunity_Link__c linkinfo = new Tender_Opportunity_Link__c(); linkinfo.Tender_information__c = BTen.Id; linkinfo.Opportunity__c = link.Opportunity__c; linkinfo.Tender_Opportunity_Uniq__c = BTen.Id + '' + link.Opportunity__c; linkinfo.IsRelated__c = true; // if (BlinksList.contains(linkinfo)) { addlinksList.add(linkinfo); // } } } // 删除项目删掉关联询价 StaticParameter.EscapeTOLinkTrigger = true;//DB202307199492 lt 注释 20230810 add delete linksList; StaticParameter.EscapeTOLinkTrigger = false;//DB202307199492 lt 注释 20230810 add // 保留项目新增关联询价 if (addlinksList.size() > 0) { insert addlinksList; } } // 【委托】招标项目-逻辑删除的项目需要自动取消与询价的关系 fy 2022.3.7 start //DB202307199492 lt 注释 20230810 start // List linksListdelect = [select id, Opportunity__c, Tender_information__c // from Tender_Opportunity_Link__c // where Tender_information__c = :TenInfo.Id]; // if(linksListdelect.size()>0){ // delete linksListdelect; // } //DB202307199492 lt 注释 20230810 end // 【委托】招标项目-逻辑删除的项目需要自动取消与询价的关系 fy 2022.3.7 end // } // 互换保留招投标与删除招投标的信息Id TenInfo.Retain_Tender__c = BTen.Id; // 【委托】招标项目-逻辑删除的项目需要自动取消与询价的关系 fy 2022.3.7 start TenInfo.Name = '逻辑删除:'+TenInfo.Name; // 20221018 ljh SWAG-CKB9NR add start if(TenInfo.Name.length() > 80){ TenInfo.Name = TenInfo.Name.substring(0,80); } // 20221018 ljh SWAG-CKB9NR add end // 【委托】招标项目-逻辑删除的项目需要自动取消与询价的关系 fy 2022.3.7 end String BTenInfo = BTen.InfoId__c; //DB202308327700 20230920 lt add if条件 if(QLMflg){ BTen.InfoId__c = TenInfo.InfoId__c;//保留招投标的信息Id赋给删除招投标的信息Id TenInfo.InfoId__c = BTenInfo;//删除招投标的信息Id赋给保留招投标的信息Id } // 点击保存后 删除招投标上的逻辑删除字段变为true TenInfo.Logical_delete__c = true; //20231115 lt 询价数量清空 add 1行 TenInfo.OpportunityNum__c = null; //DB202307199492 lt 注释 20230810 start TenInfo.Strategic_department_MainId__c = null; TenInfo.Strategic_department_MainId1__c = null; TenInfo.Strategic_department_MainId2__c = null; TenInfo.Strategic_department_MainId3__c = null; TenInfo.Strategic_department_MainId4__c = null; //DB202307199492 lt 注释 20230810 end // update TenInfo; // 反正要更新 放在一起也是一样的 updateTenInfoList.add(TenInfo); updateTenInfoList.add(BTen); if (!TenInfo.Id.equals(BTen.Id)) { update updateTenInfoList; // update 20240304 By DTT-亚楠 去除fileaddress start //DB202308327700 20230920 lt start 更新文件地址 // if(faList.Size() > 0 ){ // update faList; // } //DB202308327700 20230920 lt end if(insertConDocuList.size() > 0) { insert insertConDocuList; } //if(cdList.size() > 0) { //delete cdList; //} // update 20240304 By DTT-亚楠 去除fileaddress end } // updateBTenList.add(BTen); // update updateBTenList; } if (String.isNotBlank(TenInfo.Retain_Tender__c)&&String.isNotBlank(TenInfo.ProjectId__c)&&String.isNotBlank(TenInfo.InfoId__c)) { // 调用接口 //DB202308327700 20230920 lt add if条件 if(QLMflg){ String userId = UserInfo.getUserId(); String batchUser = System.Label.Batch_User_Id; if (userId.contains(batchUser)) { // 暂不执行接口 ssm // NFM504Controller.sendRequestNotFuture(TenInfo.Id); } else { NFM504Controller.sendRequest(TenInfo.Id); } } } // System.debug('1111111122222' + SaveErrorflag); return '成功'; // return Tenderinformationc; } // public PageReference returnFresh() { // // System.debug('1234567891234567890'); // String url = '/' + TenIds; // PageReference ref = new Pagereference(url); // ref.setRedirect(true); // return ref; // } }