From 4aa0982cda47312a7a1a2289a0ea405e96ea1b13 Mon Sep 17 00:00:00 2001
From: liwentao <1376563863@qq.com>
Date: 星期五, 21 七月 2023 17:58:00 +0800
Subject: [PATCH] 待确认 vf页面:
---
force-app/main/default/classes/GuaranteePeriodAlterationController.cls | 169 +++++++++++++++++++++++++++++++-------------------------
1 files changed, 94 insertions(+), 75 deletions(-)
diff --git a/force-app/main/default/classes/GuaranteePeriodAlterationController.cls b/force-app/main/default/classes/GuaranteePeriodAlterationController.cls
index 4dfc08a..b0740c1 100644
--- a/force-app/main/default/classes/GuaranteePeriodAlterationController.cls
+++ b/force-app/main/default/classes/GuaranteePeriodAlterationController.cls
@@ -17,29 +17,29 @@
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();
}
@@ -48,16 +48,16 @@
public String Id { get; set; }
public Boolean isShow { get; set; }
public List<Attachment> attachments { get; set; }
-
+ public List<ContentDocument> contents { get; set; }
//鍒嗛〉鍔熻兘
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');
Id = ApexPages.currentPage().getParameters().get('Id');
-
+ System.debug('id:'+Id+' and sId:'+Statu_AchievementsId);
statusEdit = ApexPages.currentPage().getParameters().get('KeyWords');
guaranteePeriodAlterationDetailRecords = new List<GuaranteePeriodAlterationDetailInfo>();
guaranteePeriodAlterationDetaiRecordsview = new List<GuaranteePeriodAlterationDetailInfo>();
@@ -66,11 +66,21 @@
pageLimit = Integer.valueOf(System.Label.orderdetPageLimitsize);
attachments = new List<Attachment>();
+ //update 鏉庢枃娑� 2023/07/13 鏇存柊lightning闄勪欢涓婁紶 start
+ List<ContentDocumentLink> cdlList = [SELECT ContentDocumentId
+ FROM ContentDocumentLink
+ WHERE LinkedEntityId = :Id];
+ List<ID> fileIDs = new List<ID>();
+ for (ContentDocumentLink docLink : cdlList) {
+ fileIDs.add(docLink.ContentDocumentId);
+ }
+ contents=[SELECT Title,OwnerId,ContentModifiedDate from ContentDocument WHERE id IN :fileIDs];
+ //update 鏉庢枃娑� 2023/07/13 鏇存柊lightning闄勪欢涓婁紶 end
}
// 鐢婚潰鍒濆鍖�
public void init() {
-
+
if(Id!=null&&Id!=''&&statusEdit==''&&statusEdit==null){
editAble = false;
}else if((Id == null||Id=='')&&(statusEdit==''||statusEdit==null)){
@@ -82,16 +92,16 @@
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]));
}
@@ -101,7 +111,7 @@
}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
@@ -129,7 +139,7 @@
for(GuaranteePeriodAlterationDetailInfo ass:MidMap.values()){
guaranteePeriodAlterationDetailRecords.add(ass);
-
+
}
for(GuaranteePeriodAlterationDetailInfo ass : guaranteePeriodAlterationDetailRecords){
@@ -139,17 +149,17 @@
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);
@@ -164,7 +174,7 @@
if(!MidMap.containsKey(asListed[i].Id)){
MidMap.put(asListed[i].Id, new GuaranteePeriodAlterationDetailInfo(asListed[i]));
}
-
+
}
@@ -184,6 +194,7 @@
} else {
statu_AchievementId = ambc.GpaaStatu_Achievements__c;
}
+ statu_AchievementId='';
String soql = 'select Id,name,SerialNumber,Asset_situation__c,Order_No__c,Account.Name,Status,Installation_Site__c,CurrentContract__c,guarantee_period__c,RepairQuantity__c from Asset where Backorder__c = \'' + statu_AchievementId +'\'';
soql += ' AND AssetMark__c != \'鑰楁潗\'';
if(!String.isBlank(text1)){
@@ -213,14 +224,14 @@
//鍒犻櫎鎸夐挳
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;
@@ -229,7 +240,7 @@
} catch (Exception e) {
ApexPages.addMessages(e);
return null;
- }
+ }
//return null;
}
@@ -239,7 +250,7 @@
ref.setRedirect(true);
return ref;
}
-
+
//鏌ユ壘褰撳墠"淇濅慨鏈熼檺鍙樻洿鐢宠"鎵�鏈夌殑闄勪欢
public List<Attachment> seekAttachment() {
return [select Id, ParentId, Name, OwnerId, CreatedDate, BodyLength FROM Attachment where ParentId = :Id];
@@ -251,7 +262,15 @@
ref.setRedirect(true);
return ref;
}
-
+ //update 鏉庢枃娑� 2023/07/13 鏇存柊lightning闄勪欢涓婁紶 start
+ //璺宠浆鍒颁笂浼犻檮浠堕〉闈ightning
+ public PageReference uploadingAttachmentLightning(){
+ //PageReference ref = new Pagereference('/p/attach/NoteAttach?pid=' + Id +'&retURL=%2Fapex/AssetGuaranteePeriodAlteration?Id='+Id);
+ PageReference ref = new Pagereference('/lightning/n/lightning?objectApiName&context=RECORD_DETAIL&backgroundContext=%2Flightning%2Fr%2FAssetGuaranteePeriodAlteration__c%2F'+Id+'%2Fedit%3F0.source%3DalohaHeader&0.recordId='+Id+'');
+ ref.setRedirect(true);
+ return ref;
+ }
+ //update 鏉庢枃娑� 2023/07/13 鏇存柊lightning闄勪欢涓婁紶 start
//鏌ユ壘"淇濇湁璁惧"鏄惁鍚湁"QIS"鍜�"淇悊"鍜�"淇濇湁璁惧鐨勪繚淇湡闄愬彉鏇磋繃"
public Boolean find_QIS_Repair(List<String> assetIdList) {
@@ -262,7 +281,7 @@
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+'(鍚慨鐞�)');
}
@@ -283,7 +302,7 @@
}
return true;
- }
+ }
return false;
}
@@ -297,9 +316,9 @@
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{
@@ -312,32 +331,32 @@
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;
}
@@ -351,7 +370,7 @@
}
if (Count == FLG) {
- ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '璇烽�夋嫨瑕佷慨鏀圭殑淇濇湁璁惧'));
+ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '璇烽�夋嫨瑕佷慨鏀圭殑淇濇湁璁惧'));
return true;
}
@@ -362,10 +381,10 @@
// 淇濆瓨鎸夐挳
public PageReference save() {
//return null;
-
+
GuaranteePeriodAlterationApplication__c agAlteration = new GuaranteePeriodAlterationApplication__c ();
List<GuaranteePeriodAlterationDetail__c> Ins = New List<GuaranteePeriodAlterationDetail__c>();
-
+
//鏂板缓鍙樻洿鍗曟椂
Savepoint sp = Database.setSavepoint();
try {
@@ -373,11 +392,11 @@
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)) {
@@ -392,23 +411,23 @@
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>();
@@ -424,23 +443,23 @@
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;
@@ -450,26 +469,26 @@
}
}
//淇敼涔嬪悗 淇濆瓨璁㈠崟
- 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>();
@@ -479,15 +498,15 @@
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);
@@ -496,10 +515,10 @@
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;
@@ -550,6 +569,6 @@
ast = e;
canSelect = true;
}
-
+
}
-}
\ No newline at end of file
+}
--
Gitblit v1.9.1