| | |
| | | textOpts.add(new SelectOption('SerialNumber' , Schema.SObjectType.Asset.fields.SerialNumber.label)); |
| | | //textOpts.add(new SelectOption('Installation_Site__c', Schema.SObjectType.Asset.fields.Installation_Site__c.label)); |
| | | //textOpts.add(new SelectOption('Department_Name__c' , Schema.SObjectType.Asset.fields.Department_Name__c.label)); |
| | | |
| | | |
| | | changeReasonOpts = new List<SelectOption>(); |
| | | changeReasonOpts.add(new SelectOption('' , '-无-')); |
| | | changeReasonOpts.add(new SelectOption('集中采购,未分配到医院' , '集中采购,未分配到医院')); |
| | | changeReasonOpts.add(new SelectOption('其他' , '其他')); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /*****************画面初始化用********************************/ |
| | | |
| | | |
| | | public Boolean editAble {get;set;} |
| | | public Boolean spoLinkFlag {get;set;} |
| | | public String statusEdit {get;set;} |
| | | /*****************画面表示Bean******************/ |
| | | |
| | | |
| | | private List<GuaranteePeriodAlterationDetailInfo> guaranteePeriodAlterationDetailRecords = new List<GuaranteePeriodAlterationDetailInfo>(); |
| | | public List<GuaranteePeriodAlterationDetailInfo> guaranteePeriodAlterationDetaiRecordsview { get; set; } |
| | | public Integer ConsumableorderdetailsCount { |
| | | public Integer ConsumableorderdetailsCount { |
| | | get { |
| | | return guaranteePeriodAlterationDetailRecords == null ? 0 : guaranteePeriodAlterationDetailRecords.size(); |
| | | } |
| | | } |
| | | public Integer ConsumableorderdetailsviewCount { |
| | | public Integer ConsumableorderdetailsviewCount { |
| | | get { |
| | | return guaranteePeriodAlterationDetaiRecordsview == null ? 0 : guaranteePeriodAlterationDetaiRecordsview.size(); |
| | | } |
| | |
| | | public String Id { get; set; } |
| | | public Boolean isShow { get; set; } |
| | | public List<Attachment> attachments { get; set; } |
| | | public List<ContentDocument> contents { get; set; } |
| | | public List<ContentDocument> contents { get; set; }//update by liwentao 更新lightning附件上传 |
| | | //分页功能 |
| | | public Integer pageLimit{get;set;} |
| | | public String soql {get;set;} |
| | | |
| | | |
| | | public GuaranteePeriodAlterationController(ApexPages.StandardController stdController) { |
| | | isShow = false; |
| | | Statu_AchievementsId = ApexPages.currentPage().getParameters().get('Statu_AchievementsId'); |
| | |
| | | |
| | | // 画面初始化 |
| | | public void init() { |
| | | |
| | | |
| | | if(Id!=null&&Id!=''&&statusEdit==''&&statusEdit==null){ |
| | | editAble = false; |
| | | }else if((Id == null||Id=='')&&(statusEdit==''||statusEdit==null)){ |
| | |
| | | guaranteePeriodAlterationDetailRecords = new List<GuaranteePeriodAlterationDetailInfo>(); |
| | | List<Asset> assetListed = new List<Asset>(); |
| | | Map<String,GuaranteePeriodAlterationDetailInfo> MidMap = new Map<String,GuaranteePeriodAlterationDetailInfo>(); |
| | | |
| | | |
| | | if(Id== NULL || Id==''){ |
| | | List<Statu_Achievements__c> statuAchievements = [select Id,InstallDate__c from Statu_Achievements__c where Id = :Statu_AchievementsId]; |
| | | List<Statu_Achievements__c> statuAchievements = [select Id,InstallDate__c from Statu_Achievements__c where Id = :Statu_AchievementsId]; |
| | | ambc.WarrantyStartDate__c = statuAchievements[0].InstallDate__c; |
| | | soql = this.makeSoql1('',''); |
| | | assetListed = Database.query(soql); |
| | | |
| | | for (Integer i = 0; i < assetListed.size(); i++) { |
| | | guaranteePeriodAlterationDetailRecords.add(new GuaranteePeriodAlterationDetailInfo(assetListed[i])); |
| | | |
| | | |
| | | MidMap.put(assetListed[i].Id, new GuaranteePeriodAlterationDetailInfo(assetListed[i])); |
| | | } |
| | | |
| | |
| | | }else{ |
| | | List<GuaranteePeriodAlterationDetail__c> changeDetailList = new List<GuaranteePeriodAlterationDetail__c>(); |
| | | List<GuaranteePeriodAlterationApplication__c> assetChangeList = new List<GuaranteePeriodAlterationApplication__c>(); |
| | | |
| | | |
| | | assetChangeList = [select Id, Name,Change_status__c, |
| | | ChangeReason__c,WarrantyStartDate__c, |
| | | ChangeReason_text__c,GpaaStatu_Achievements__c |
| | |
| | | |
| | | for(GuaranteePeriodAlterationDetailInfo ass:MidMap.values()){ |
| | | guaranteePeriodAlterationDetailRecords.add(ass); |
| | | |
| | | |
| | | } |
| | | |
| | | for(GuaranteePeriodAlterationDetailInfo ass : guaranteePeriodAlterationDetailRecords){ |
| | |
| | | guaranteePeriodAlterationDetaiRecordsview.add(ass); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | isShow = true; |
| | | attachments = seekAttachment(); |
| | | } |
| | | } |
| | | } |
| | | // 检索 |
| | | public void searchConsumableorderdetails() { |
| | | |
| | | |
| | | Map<String,GuaranteePeriodAlterationDetailInfo> MidMap = new Map<String,GuaranteePeriodAlterationDetailInfo>(); |
| | | List<Asset> asListed = new List<Asset>(); |
| | | soql = this.makeSoql1(text1,val1); |
| | |
| | | if(!MidMap.containsKey(asListed[i].Id)){ |
| | | MidMap.put(asListed[i].Id, new GuaranteePeriodAlterationDetailInfo(asListed[i])); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | //删除按钮 |
| | | public PageReference DelConsumable(){ |
| | | GuaranteePeriodAlterationApplication__c ambc = new GuaranteePeriodAlterationApplication__c(Id = Id); |
| | | List<GuaranteePeriodAlterationDetail__c> changeDetailList = [Select Id,GuaranteePeriodAlteration__r.GpaaStatu_Achievements__c |
| | | from GuaranteePeriodAlterationDetail__c |
| | | where GuaranteePeriodAlteration__c = :Id]; |
| | | String rawAccountIded = ''; |
| | | List<GuaranteePeriodAlterationDetail__c> changeDetailList = [Select Id,GuaranteePeriodAlteration__r.GpaaStatu_Achievements__c |
| | | from GuaranteePeriodAlterationDetail__c |
| | | where GuaranteePeriodAlteration__c = :Id]; |
| | | String rawAccountIded = ''; |
| | | if(changeDetailList.size()> 0){ |
| | | rawAccountIded = changeDetailList[0].GuaranteePeriodAlteration__r.GpaaStatu_Achievements__c; |
| | | } |
| | | |
| | | |
| | | try { |
| | | delete changeDetailList; |
| | | delete ambc; |
| | |
| | | } catch (Exception e) { |
| | | ApexPages.addMessages(e); |
| | | return null; |
| | | } |
| | | } |
| | | //return null; |
| | | } |
| | | |
| | |
| | | ref.setRedirect(true); |
| | | return ref; |
| | | } |
| | | |
| | | |
| | | //查找当前"保修期限变更申请"所有的附件 |
| | | public List<Attachment> seekAttachment() { |
| | | return [select Id, ParentId, Name, OwnerId, CreatedDate, BodyLength FROM Attachment where ParentId = :Id]; |
| | |
| | | if (repairList.size() > 0 || qIS_ReportList.size() > 0 || assets.size() > 0) { |
| | | |
| | | if (repairList.size() > 0) { |
| | | |
| | | |
| | | for (Repair__c repair :repairList) { |
| | | assetIdMap.put(repair.Delivered_Product__c,repair.Delivered_Product__r.SerialNumber+'(含修理)'); |
| | | } |
| | |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | |
| | | agAlteration.Id = Id; |
| | | attachments = seekAttachment(); |
| | | if (ambc.ChangeReason__c == '集中采购,未分配到医院' && attachments.size() == 0) { |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请上传标书')); |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请上传标书')); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | try{ |
| | | |
| | |
| | | Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest(); |
| | | psr.setObjectId(Id); |
| | | Approval.ProcessResult submitResult = Approval.process(psr); |
| | | return ref; |
| | | return ref; |
| | | } |
| | | catch (Exception e) { |
| | | //ApexPages.addmessages(e); |
| | | Database.rollback(sp); |
| | | return null; |
| | | return null; |
| | | } |
| | | |
| | | //return null; |
| | | //return UnabletoEdit(); |
| | | //return UnabletoEdit(); |
| | | } |
| | | |
| | | //验证字段 |
| | | public Boolean warning() { |
| | | |
| | | if (String.isBlank(ambc.ChangeReason__c)) { |
| | | |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请输入变更原因')); |
| | | |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请输入变更原因')); |
| | | return true; |
| | | } else if (ambc.ChangeReason__c == '其他' && String.isBlank(ambc.ChangeReason_text__c)) { |
| | | |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '变更原因为"其他"时,请输入"变更原因其他"')); |
| | | |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '变更原因为"其他"时,请输入"变更原因其他"')); |
| | | return true; |
| | | } else if (ambc.WarrantyStartDate__c == null) { |
| | | |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请输入保修开始日')); |
| | | |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请输入保修开始日')); |
| | | return true; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | if (Count == FLG) { |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请选择要修改的保有设备')); |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请选择要修改的保有设备')); |
| | | return true; |
| | | } |
| | | |
| | |
| | | // 保存按钮 |
| | | public PageReference save() { |
| | | //return null; |
| | | |
| | | |
| | | GuaranteePeriodAlterationApplication__c agAlteration = new GuaranteePeriodAlterationApplication__c (); |
| | | List<GuaranteePeriodAlterationDetail__c> Ins = New List<GuaranteePeriodAlterationDetail__c>(); |
| | | |
| | | |
| | | //新建变更单时 |
| | | Savepoint sp = Database.setSavepoint(); |
| | | try { |
| | |
| | | agAlteration.ChangeReason_text__c = ambc.ChangeReason_text__c; |
| | | agAlteration.WarrantyStartDate__c = ambc.WarrantyStartDate__c; |
| | | agAlteration.ChangeReason__c = ambc.ChangeReason__c; |
| | | |
| | | |
| | | if (warning()) { |
| | | |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | if (String.isBlank(Id)) { |
| | | |
| | |
| | | |
| | | ApexPages.addMessages(e); |
| | | } |
| | | |
| | | |
| | | |
| | | Map<String,String> assetGuaranteeTimeMap = new Map<String,String>(); |
| | | List<GuaranteePeriodAlterationApplication__c> saveGpaApplicationList = |
| | | [SELECT Id,Name,WarrantyStartDate__c |
| | | FROM GuaranteePeriodAlterationApplication__c |
| | | List<GuaranteePeriodAlterationApplication__c> saveGpaApplicationList = |
| | | [SELECT Id,Name,WarrantyStartDate__c |
| | | FROM GuaranteePeriodAlterationApplication__c |
| | | WHERE id = :agAlteration.id]; |
| | | |
| | | |
| | | if ( saveGpaApplicationList.size() > 0) { |
| | | |
| | | List<Asset> assetList = [Select Id,Guarantee_period_for_products__c,guarantee_period__c,RepairQuantity__c,SerialNumber |
| | | from Asset |
| | | where Backorder__c = :Statu_AchievementsId]; |
| | | Map<String,Integer> assetMap = new Map<String,Integer>(); |
| | | Map<String,Integer> assetMap = new Map<String,Integer>(); |
| | | for (Asset ass :assetList) { |
| | | assetMap.put(ass.Id,Integer.valueOf(ass.guarantee_period__c)); |
| | | } |
| | | } |
| | | |
| | | |
| | | List<String> assetIds = new List<String>(); |
| | |
| | | gpaDetail.Name = saveGpaApplicationList[0].Name + '-'+ str; |
| | | gpaDetail.GuaranteePeriodAlteration__c = saveGpaApplicationList[0].Id; |
| | | gpaDetail.Asset__c = ass.ast.Id; |
| | | gpaDetail.GuaranteeTime__c = saveGpaApplicationList[0].WarrantyStartDate__c.addDays(assetMap.get(ass.ast.Id)); |
| | | gpaDetail.GuaranteeTime__c = saveGpaApplicationList[0].WarrantyStartDate__c.addDays(assetMap.get(ass.ast.Id)); |
| | | i++; |
| | | Ins.add(gpaDetail); |
| | | assetIds.add(ass.ast.Id); |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | if (find_QIS_Repair(assetIds)) { |
| | | |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '以下保有设备含有"QIS"或"修理"或"保修期限变更过"不适合变更"保修期限"' + assetIdMap.values())); |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '以下保有设备含有"QIS"或"修理"或"保修期限变更过"不适合变更"保修期限"' + assetIdMap.values())); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | //update saveGpaApplicationList; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | Id = agAlteration.id; |
| | | |
| | |
| | | } |
| | | } |
| | | //修改之后 保存订单 |
| | | else if(!String.isBlank(Id)){ |
| | | |
| | | else if(!String.isBlank(Id)){ |
| | | |
| | | agAlteration.Id = Id; |
| | | agAlteration.GpaaStatu_Achievements__c = ambc.GpaaStatu_Achievements__c; |
| | | |
| | | agAlteration.GpaaStatu_Achievements__c = ambc.GpaaStatu_Achievements__c; |
| | | |
| | | update agAlteration; |
| | | |
| | | List<GuaranteePeriodAlterationDetail__c> delIns = |
| | | List<GuaranteePeriodAlterationDetail__c> delIns = |
| | | [select Id from GuaranteePeriodAlterationDetail__c |
| | | where GuaranteePeriodAlteration__r.Id = :Id]; |
| | | |
| | | |
| | | if(delIns.size()>0){ |
| | | |
| | | delete delIns; |
| | | } |
| | | |
| | | Integer i = 1; |
| | | List<GuaranteePeriodAlterationApplication__c> saveGpaApplicationList = |
| | | [SELECT Id,Name |
| | | FROM GuaranteePeriodAlterationApplication__c |
| | | List<GuaranteePeriodAlterationApplication__c> saveGpaApplicationList = |
| | | [SELECT Id,Name |
| | | FROM GuaranteePeriodAlterationApplication__c |
| | | WHERE id =:agAlteration.id]; |
| | | |
| | | List<String> assetIds = new List<String>(); |
| | |
| | | |
| | | GuaranteePeriodAlterationDetail__c gpaDetail = new GuaranteePeriodAlterationDetail__c(); |
| | | String str = string.valueOf(i); |
| | | |
| | | |
| | | if(str.length() == 1){ |
| | | |
| | | |
| | | str = '0' + str; |
| | | } |
| | | |
| | | gpaDetail.Name = saveGpaApplicationList[0].Name + '-'+ str; |
| | | gpaDetail.GuaranteePeriodAlteration__c = saveGpaApplicationList[0].Id; |
| | | gpaDetail.Asset__c = ass.ast.Id; |
| | | gpaDetail.Asset__c = ass.ast.Id; |
| | | i++; |
| | | Ins.add(gpaDetail); |
| | | assetIds.add(ass.ast.Id); |
| | |
| | | |
| | | if (find_QIS_Repair(assetIds)) { |
| | | |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '以下保有设备含有"QIS"或"修理"或"保修期限变更过"不适合变更"保修期限"' + assetIdMap.values())); |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '以下保有设备含有"QIS"或"修理"或"保修期限变更过"不适合变更"保修期限"' + assetIdMap.values())); |
| | | return null; |
| | | } |
| | | |
| | | |
| | | if(Ins.size()>0){ |
| | | |
| | | insert Ins; |
| | |
| | | ast = e; |
| | | canSelect = true; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | } |