| | |
| | | // 投标截止时间 |
| | | // 2021/01/04 18:00 |
| | | //add by sushanhu for pi 20220310 start |
| | | public static String txId; |
| | | public String txId; |
| | | |
| | | //add by sushanhu for pi 20220310 end |
| | | public String rowData_id; |
| | | public NFM501FutureController(String rowData_id) { |
| | | this.rowData_id = rowData_id; |
| | | } |
| | | //add by sushanhu for pi 20220310 start |
| | | // public NFM501FutureController(String rowData_id,String txId) { |
| | | // this.rowData_id = rowData_id; |
| | | // this.txId = txId; |
| | | // } |
| | | //add by sushanhu for pi 20220310 end |
| | | public static Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt); |
| | | public void execute(QueueableContext context /*, String iflog_Id*/ ) { |
| | | //需加一数字变量(如果获取到 html附件,其他附件,在日志中显示数量) |
| | |
| | | from BatchIF_Log__c where RowDataFlg__c = true and Id = : rowData_id |
| | | ]; |
| | | //存放报错信息 |
| | | txId =rowData.AWS_Transaction_Id__c; //add by sushanhu for pipl 20220310 |
| | | //add by sushanhu for pipl 20220311 start |
| | | system.debug('txId from log'+rowData.AWS_Transaction_Id__c); |
| | | if (!String.isEmpty(rowData.AWS_Transaction_Id__c)) { |
| | | txId =rowData.AWS_Transaction_Id__c; //add by sushanhu for pipl 20220310 |
| | | }else { |
| | | system.debug('txId from NF501'+txId); |
| | | } |
| | | //add by sushanhu for pipl 20220311 end |
| | | system.debug('nfm501future awsid'+txId); |
| | | BatchIF_Log__c iflog501Future = new BatchIF_Log__c(); |
| | | iflog501Future.Type__c = 'NFM501'; |
| | |
| | | iflog501Future.RowDataFlg__c = false; |
| | | iflog501Future.AWS_Transaction_Id__c=rowData.AWS_Transaction_Id__c; |
| | | insert iflog501Future; |
| | | NFM501FutureController.main(rowData.Id, iflog501Future.Id, false); |
| | | NFM501FutureController.main(rowData.Id, iflog501Future.Id, false,txId); |
| | | } |
| | | |
| | | @future(callout = true) |
| | | //重发(把从接口获取到的数据存入日志中,再把日志中存入的数据重新JOSN解析一遍) |
| | | public static void main(String rowData_id, String iflog_id, boolean Manual_execution501future) { |
| | | public static void main(String rowData_id, String iflog_id, boolean Manual_execution501future, |
| | | String txId //增加事务id forpipl 20220310 |
| | | ) { |
| | | BatchIF_Log__c rowData = [Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c, |
| | | Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c, |
| | | Log12__c, MessageGroupNumber__c, retry_cnt__c, NFM501Future_Count__c, |
| | |
| | | rowData.ErrorLog__c = rowData.ErrorLog__c == null ? '' : rowData.ErrorLog__c; |
| | | // System.debug('+++++++1+++++++'+iflog501Future); |
| | | String QLMDataStr = NFMUtil.QLMgetRowDataStr(rowData); |
| | | system.debug('QLMDataStr---'+QLMDataStr); |
| | | NFM501controller.AllData getQLMData1 = (NFM501controller.AllData) |
| | | JSON.deserialize(QLMDataStr, NFM501controller.AllData.class); |
| | | |
| | | system.debug('getQLMData1---'+json.serialize(getQLMData1)); |
| | | if (getQLMData1 == null) { |
| | | return; |
| | | } |
| | |
| | | SumUnit__c, AreaCity__c, AreaCountry__c, AgentUnit1__c, |
| | | AgentUnit2__c, AgentUnit3__c, AgentUnit4__c, AgentUnit5__c, |
| | | ZhaoRelationName__c, ZhongRelationName__c, |
| | | publicDate__c, noticeDate__c, ResultDate__c |
| | | publicDate__c, noticeDate__c, ResultDate__c, |
| | | AWS_Data_Id__c //ADD FOR pi SUSHANHU 20220311 |
| | | FROM Tender_information__c Where ProjectId__c in : projectIdList |
| | | ]; |
| | | Map < String, Tender_information__c > TenMap = new Map < String, Tender_information__c > (); |
| | |
| | | Set < String > TarDetailSet = new Set < String > (); |
| | | |
| | | for (NFM501Controller.ListItem LI: getQLMData1.data.list1) { |
| | | system.debug('LI----'+json.serialize(LI)); |
| | | // 項目転送のセット |
| | | Tender_information__c te1 = new Tender_information__c(); |
| | | //add aws dataid sushanhu 20220223 start |
| | | if(String.isEmpty(LI.DataId)){ |
| | | continue; |
| | | } |
| | | te1.AWS_Data_Id__c = LI.DataId; |
| | | //add aws dataid sushanhu 20220223 end |
| | | if (String.isBlank(LI.projectId)) { |
| | |
| | | //转换表(实现选项列表的下拉选项) |
| | | te1.BiddingType__c = NFMUtil.getMapValue(transferMap, 'BiddingType__c', LI.biddingType, iflog501Future); |
| | | te1.InfoQianlimaUrl__c = String.isBlank(LI.infoQianlimaUrl) ? te1.InfoQianlimaUrl__c : LI.infoQianlimaUrl; |
| | | System.debug('======111111111111========'); |
| | | //拼接字符串 |
| | | if (LI.ZhaoRelationWay != null && LI.ZhaoRelationWay.size() > 0) { |
| | | System.debug('======LI.ZhaoRelationWay========'+LI.ZhaoRelationWay); |
| | | te1.ZhaoRelationWay__c = String.join(LI.ZhaoRelationWay, ','); |
| | | //add 密文 sushanhu 20220223 start |
| | | te1.ZhaoRelationWay_Encrypted__c =String.join(LI.ZhaoRelationWayEncrypted,','); |
| | | //System.debug('======LI.ZhaoRelationWayEncrypted========'+LI.ZhaoRelationWayEncrypted); //zhj 新方案改造 2022-12-09 |
| | | //te1.ZhaoRelationWay_Encrypted__c =String.join(LI.ZhaoRelationWayEncrypted,','); //zhj 新方案改造 2022-12-09 |
| | | System.debug('======2222222222222========'); |
| | | //add 密文 sushanhu 20220223 end |
| | | } |
| | | //转换表(选项列表的下拉选项) |
| | | System.debug('======3333333333333333========'); |
| | | te1.IsElectronic__c = NFMUtil.getMapValue(transferMap, 'IsElectronic__c', LI.isElectronic, iflog501Future); |
| | | te1.XmNumber__c = String.isBlank(LI.xmNumber) ? te1.XmNumber__c : LI.xmNumber; |
| | | if ( String.isnotBlank(LI.tenderEndTime) ) { |
| | |
| | | //转换表(选项列表的下拉选项) |
| | | //接口传来其他公告 |
| | | if (String.isBlank(te1.Id)) { //判断招标项目是否存在 |
| | | if ('5'.equals(LI.infoType)) { |
| | | if ('5'.equals(LI.infoType) || '2'.equals(LI.infoType)) { //20220510 lt SWAG-CE6C45 |
| | | //招投标项目名称 |
| | | te1.InfoTitle__c = LI.infoTitle == null ? te1.InfoTitle__c : LI.infoTitle; |
| | | //项目阶段 |
| | |
| | | } |
| | | } |
| | | // 中标时间(OpenBidingTime__c) |
| | | if (String.isNotBlank(LI.openBidingTime) ) { |
| | | te1.OpenBidingTime__c = Datetime.valueOf(LI.openBidingTime); |
| | | System.debug('OpenBidingTime__c1:' + te1.OpenBidingTime__c); |
| | | } else if (te1.OpenBidingTime__c == null && '3'.equals(LI.infoType)) { |
| | | // 2022-05-17 中标日逻辑错误,接口里没有中标日字段,仅中标阶段时,用当前日期填充 ssm |
| | | // if (String.isNotBlank(LI.openBidingTime) ) { |
| | | // te1.OpenBidingTime__c = Datetime.valueOf(LI.openBidingTime); |
| | | // System.debug('OpenBidingTime__c1:' + te1.OpenBidingTime__c); |
| | | // } else |
| | | if (te1.OpenBidingTime__c == null && '3'.equals(LI.infoType)) { |
| | | te1.OpenBidingTime__c = Date.today(); |
| | | System.debug('OpenBidingTime__c2:' + te1.OpenBidingTime__c); |
| | | } |
| | | // 预告记录日 取第一次获取到预告的当前时间 |
| | | // 如果有值,不是第一次,如果没值 |
| | | if ('1'.equals(LI.infoType) && te1.noticeDate__c == null) { |
| | | if (('1'.equals(LI.infoType)) && te1.noticeDate__c == null) { //20220510 lt SWAG-CE6C45 |
| | | te1.noticeDate__c = Date.today(); |
| | | System.debug('noticeDate__c:' + te1.noticeDate__c); |
| | | } |
| | | System.debug('LI.infoType:' + LI.infoType); |
| | | System.debug('te1.ResultDate__c:' + te1.ResultDate__c); |
| | | // 结果记录日 取第一次获取到结果的当前时间 |
| | | if ('3'.equals(LI.infoType) && te1.ResultDate__c == null) { |
| | | if (('3'.equals(LI.infoType)) && te1.ResultDate__c == null) { //20220510 lt SWAG-CE6C45 |
| | | te1.ResultDate__c = Date.today(); |
| | | System.debug('ResultDate__c:' + te1.ResultDate__c); |
| | | } |
| | | // 公告记录日 取第一次获取到公告的当前时间 |
| | | if ('0'.equals(LI.infoType) && te1.publicDate__c == null) { |
| | | if (('0'.equals(LI.infoType)) && te1.publicDate__c == null) { //20220510 lt SWAG-CE6C45 |
| | | te1.publicDate__c = Date.today(); |
| | | System.debug('publicDate__c:' + te1.publicDate__c); |
| | | } |
| | | if (LI.AgentRelationWay != null && LI.AgentRelationWay.size() > 0) { |
| | | te1.AgentRelationWay__c = String.join(LI.AgentRelationWay, ','); |
| | | //add 密文 sushanhu 20220223 start |
| | | te1.AgentRelationWay_Encrypted__c =String.join(LI.AgentRelationWayEncrypted,','); |
| | | //te1.AgentRelationWay_Encrypted__c =String.join(LI.AgentRelationWayEncrypted,','); //zhj 新方案改造 2022-12-09 |
| | | //add 密文 sushanhu 20220223 end |
| | | } |
| | | // 将改附件存入招投标项目子对象中 |
| | |
| | | if (LI.AgentRelationName != null && LI.AgentRelationName.size() > 0) { |
| | | te1.AgentRelationName__c = String.join(LI.AgentRelationName, ','); |
| | | //add 密文 sushanhu 20220223 start |
| | | te1.AgentRelationName_Encrypted__c =String.join(LI.AgentRelationNameEncrypted,','); |
| | | //te1.AgentRelationName_Encrypted__c =String.join(LI.AgentRelationNameEncrypted,','); //zhj 新方案改造 2022-12-09 |
| | | //add 密文 sushanhu 20220223 end |
| | | } |
| | | if (String.isNotBlank(LI.bidingEndTime)) { |
| | |
| | | if (LI.ZhongRelationWay != null && LI.ZhongRelationWay.size() > 0) { |
| | | te1.ZhongRelationWay__c = String.join(LI.ZhongRelationWay, ','); |
| | | //add 密文 sushanhu 20220223 start |
| | | te1.ZhongRelationWay_Encrypted__c =String.join(LI.ZhongRelationWayEncrypted,','); |
| | | //te1.ZhongRelationWay_Encrypted__c =String.join(LI.ZhongRelationWayEncrypted,','); //zhj 新方案改造 2022-12-09 |
| | | //add 密文 sushanhu 20220223 end |
| | | } |
| | | if (String.isNotBlank(LI.bidingAcquireTime)) { |
| | |
| | | te.ProjectId__c = te1.ProjectId__c; |
| | | //tempList1.put(te1.InfoId__c, te); |
| | | //tempList1.add(te); |
| | | // 如果更新的数据阶段为3.结果且补充说明为3-5:中标通知,设置最终标的物为true |
| | | te.Is_Final__c = String.isNotBlank(LI.infoType) && '3'.equals(LI.infoType) && String.isNotBlank(LI.infoTypeSegment) && '11'.equals(LI.infoTypeSegment) ? true : false; |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | if (LI.ZhaoRelationName != null && LI.ZhaoRelationName.size() > 0) { |
| | | te1.ZhaoRelationName__c = String.join(LI.ZhaoRelationName, ','); |
| | | //add 密文 sushanhu 20220223 start |
| | | te1.ZhaoRelationName_Encrypted__c =String.join(LI.ZhaoRelationNameEncrypted,','); |
| | | //te1.ZhaoRelationName_Encrypted__c =String.join(LI.ZhaoRelationNameEncrypted,','); //zhj 新方案改造 2022-12-09 |
| | | //add 密文 sushanhu 20220223 end |
| | | } |
| | | if (LI.ZhongRelationName != null && LI.ZhongRelationName.size() > 0) { |
| | | te1.ZhongRelationName__c = String.join(LI.ZhaoRelationName, ','); |
| | | //add 密文 sushanhu 20220223 start |
| | | te1.ZhongRelationName_Encrypted__c =String.join(LI.ZhongRelationNameEncrypted,','); |
| | | //te1.ZhongRelationName_Encrypted__c =String.join(LI.ZhongRelationNameEncrypted,','); //zhj 新方案改造 2022-12-09 |
| | | //add 密文 sushanhu 20220223 end |
| | | } |
| | | |
| | | |
| | | System.debug('te1-----'+json.serialize(te1)); |
| | | //精琢科技 zxk 2021-11-11 SWAG-C637NF start |
| | | // 如果第一次项目阶段就传来变更状态的话,那么就不生成招投标项目(由于变更阶段项目名称传来为空,为了不让项目名自动赋值为Id) |
| | | if (String.isNotBlank(te1.InfoType__c) && String.isNotBlank(LI.projectId)) { |
| | |
| | | } |
| | | // System.debug('12345678!!!!!'+updateTenderMap.values()); |
| | | //3、通过list查招标明细,删除所以查出的明细 |
| | | List < Tender_information_details__c > DetlList = [Select Id FROM Tender_information_details__c |
| | | // 2022-06-06 中标通知的标的物为最终标的物,不再修改,其他阶段的标的物可删除 |
| | | List < Tender_information_details__c > DetlList = [Select Id, Name, Name__c, ProjectId__c, Brand__c, Model__c, Keywords__c, |
| | | NumberUnit__c, TotalPrice__c, Price__c, PriceUnit__c, TotalPriceUnit__c, Is_Final__c |
| | | FROM Tender_information_details__c |
| | | Where ProjectId__c in : TarDetailSet |
| | | ]; |
| | | if (DetlList.size() > 0) { |
| | | delete DetlList; |
| | | } |
| | | // if (DetlList.size() > 0) { |
| | | // delete DetlList; |
| | | // } |
| | | system.debug('updateTenderMap---'+json.serialize(updateTenderMap)); |
| | | if (updateTenderMap.values().size() > 0) { |
| | | upsert updateTenderMap.values(); |
| | | } |
| | |
| | | Map < string, Tender_information__c > TenderMap = new map < string, Tender_information__c > (); |
| | | |
| | | for (Tender_information__c TMap: updateTenderMap.values()) { |
| | | system.debug('TMap---'+JSON.serialize(TMap)); |
| | | TenderMap.put(TMap.ProjectId__c, TMap); |
| | | PIHelper.IdList il= new PIHelper.IdList(); |
| | | // add for pipl sushanhu 20220310 start |
| | |
| | | } |
| | | System.debug('12345678!!!!!' + TenderMap.values()); |
| | | List < Tender_information_details__c > TenList = new List < Tender_information_details__c > (); |
| | | // 新的标的物内容不为空时进入以下逻辑 |
| | | if (tempList1.size() > 0) { |
| | | // 先循环现有标的物,判断哪些删除,哪些保留 |
| | | Map<String, String> undelete_projects = new Map<String, String>(); |
| | | List<Tender_information_details__c> delete_list = new List<Tender_information_details__c>(); |
| | | for (Tender_information_details__c det : DetlList) { |
| | | // 判断最终标的物标记是否为true或新标的物里不包含project |
| | | if (det.Is_Final__c || !tempList1.containsKey(det.ProjectId__c)) { |
| | | undelete_projects.put(det.ProjectId__c, det.ProjectId__c); |
| | | } else { |
| | | delete_list.add(det); |
| | | } |
| | | } |
| | | if (delete_list != null && delete_list.size() > 0) { |
| | | delete delete_list; |
| | | } |
| | | for (String projectId: tempList1.keySet()) { |
| | | for (Tender_information_details__c vma: tempList1.get(projectId)) { |
| | | if (vma != null && TenderMap.containskey(projectId)) { |
| | | // 2022-06-06 增加判断 projectId不再undelete的列表里 |
| | | if (vma != null && TenderMap.containskey(projectId) && !undelete_projects.containsKey(projectId)) { |
| | | vma.Tender_information__c = TenderMap.get(projectId).id; |
| | | TenList.add(vma); |
| | | } |
| | |
| | | insert insertbidInfoFileList; |
| | | } |
| | | if (!Manual_execution501future) { |
| | | //测试 Open the comment by Li Jun 20220404 |
| | | System.enqueueJob(new NFM502Controller(rowData.id)); |
| | | } |
| | | // logstr += '\nend'; |
| | |
| | | throw new ControllerUtil.myException('aaa'); |
| | | } |
| | | //确认事务 add for pi sushanhu 20220310 start |
| | | PIHelper.confirmTrans('NFM501',1,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList); |
| | | // PIHelper.confirmTrans('NFM501',1,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList); |
| | | PIHelper.insertConfirmTrans('NFM501',1,null,txId,1,NFM501AWS.transactionURL,idList); |
| | | //确认事务 add for pi sushanhu 20220310 end |
| | | } catch (Exception ex) { |
| | | // 如果数据获取过程中,有错误(同一游标,如果报错,是他重新获取一遍,如果三次都没能获取到,就发送邮件报错信息,然后手动进行获取) |
| | | Database.rollback(sp); |
| | | //确认事务 add for pi sushanhu 20220310 start |
| | | PIHelper.confirmTrans('NFM501',0,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList); |
| | | // PIHelper.confirmTrans('NFM501',0,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList); |
| | | Integer rowDataStr = Integer.valueOf(rowData.get('NFM501Future_Count__c')); |
| | | if (rowDataStr == null) { |
| | | rowDataStr = 0; |
| | | } |
| | | System.debug('rowDataStr' + rowDataStr); |
| | | if (rowDataStr >= batch_retry_max_cnt) { |
| | | PIHelper.insertConfirmTrans('NFM501',0,null,txId,1,NFM501AWS.transactionURL,idList); |
| | | } |
| | | //PIHelper.insertConfirmTrans('NFM501',0,null,txId,1,NFM501AWS.transactionURL,idList); |
| | | //确认事务 add for pi sushanhu 20220310 end |
| | | System.debug(Logginglevel.ERROR, 'QLMData_' + rowData.MessageGroupNumber__c + ':' + ex.getMessage()); |
| | | System.debug(Logginglevel.ERROR, 'QLMData_' + rowData.MessageGroupNumber__c + ':' + ex.getStackTraceString()); |