From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新
---
force-app/main/default/classes/RentalFixtureSetAssignAgencyController.cls | 156 ++++++++++++++++++++++++++++++++++------------------
1 files changed, 102 insertions(+), 54 deletions(-)
diff --git a/force-app/main/default/classes/RentalFixtureSetAssignAgencyController.cls b/force-app/main/default/classes/RentalFixtureSetAssignAgencyController.cls
index 47cf35d..55e2639 100644
--- a/force-app/main/default/classes/RentalFixtureSetAssignAgencyController.cls
+++ b/force-app/main/default/classes/RentalFixtureSetAssignAgencyController.cls
@@ -1,3 +1,4 @@
+// RentalFixtureSetAssignAgencyCtrlTest
public with sharing class RentalFixtureSetAssignAgencyController {
public List<EsdInfo> esdList { get; set; }
public FixtureDeliverySlip__c slip { get; set; }
@@ -48,9 +49,9 @@
+ ', Loaner_cancel_request__c'//20210707 SFDC-C448KZ you
+ ', Equipment_Type_F__c' //20210508 LJH ADD 1672
+ ', Wei_Assigned_Cnt__c' // 20210624 ljh add SFDC-C448GR start
- + ', Campaign__c, Campaign__r.IF_Approved__c, Campaign__r.Meeting_Approved_No__c'
- + ', Campaign__r.Meeting_Approved_No__r.ProcessState__c'
- + ', Campaign__r.Meeting_Approved_No__r.MeetingApprovedNo__c' //20220217 sx add 澶囧搧鍊熷嚭鐢宠-鍐宠鎺у埗
+ + ', Campaign__r.IF_Approved__c' // 20220315 ljh add
+ + ', Campaign__r.Meeting_Approved_No__r.Name' // 20220315 ljh add
+ + ', Campaign__r.Approved_Status__c' // 20220315 ljh add
+ ' FROM Rental_Apply__c'
+ ' WHERE Id=\'' + taId + '\'';
List<Rental_Apply__c> raList = (List<Rental_Apply__c>) Consum_ApplyUtil.withoutQueryList(rasql);
@@ -251,6 +252,7 @@
, Rental_Apply__r.Status__c //20210519 ljh add 1829 end
, Rental_Apply__r.Request_approval_time__c //20220309 SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀�
, Add_Request_approval_time__c //20220309 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀�
+ , ApplyToShipmentWorkTime__c //20220309 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀�
, Rental_Num__c
, Rental_Start_Date__c
, Select_Time__c
@@ -427,18 +429,22 @@
}
}
private Boolean isRaStatusOK() {
+
+ List<String> statusList = System.Label.StatusProcessState.split(',');
+
//妫�鏌ユ槸鍚﹀彲浠ョ户缁�
// 20210809 ljh SFDC-C5HDC7 update start
List<Rental_Apply__c> RaTarList = [
SELECT Campaign__c
, Repair__c
, Campaign__r.Status
- ,Campaign__r.IF_Approved__c
- ,Campaign__r.Meeting_Approved_No__c
+ , Campaign__r.IF_Approved__c
+ , Campaign__r.Meeting_Approved_No__c
+ , Campaign__r.Approved_Status__c //20220315 sx obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀�
// ,repair__r.Return_Without_Repair_Date__c
, Return_Without_Repair_Date_F__c
// , Repair__r.Repair_Final_Inspection_Date__c
- ,Repair_Final_Inspection_Date_F__c
+ , Repair_Final_Inspection_Date_F__c
// , Repair__r.Repair_Shipped_Date__c
, RC_return_to_office__c
, demo_purpose2__c //1822 yc 20211025 宸茶喘寰呰揣鐩殑锛屾柊鍝佸凡鏈夊彂璐ф棩涓嶈兘鍑哄簱
@@ -449,8 +455,18 @@
WHERE id =:taId
];
for (Rental_Apply__c RaTar : RaTarList) {
- if( RaTar.Campaign__r.Status == '鍙栨秷'){
- ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '瀛︿細宸插彇娑堬紝涓嶈兘缁х画鎿嶄綔浜�'));
+ // 20230215 ljh DB202301265636 瀛︿細鍙栨秷鐢宠涔熸嫤鎴� start
+ // if( RaTar.Campaign__r.Status == '鍙栨秷'){
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '瀛︿細宸插彇娑堬紝涓嶈兘缁х画鎿嶄綔浜�'));
+ if( RaTar.Campaign__r.Status == '鍙栨秷' || RaTar.Campaign__r.Status == '鍙栨秷鐢宠涓�' ){
+ String tempS = '';
+ if(RaTar.Campaign__r.Status == '鍙栨秷'){
+ tempS = '宸插彇娑�';
+ }else{
+ tempS = '鐢宠鍙栨秷涓�';
+ }
+ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '瀛︿細'+tempS+'锛屼笉鑳界户缁搷浣滀簡'));
+ // 20230215 ljh DB202301265636 瀛︿細鍙栨秷鐢宠涔熸嫤鎴� end
return false;
}
// else if(RaTar.Repair__r.Repair_Final_Inspection_Date__c != null){
@@ -480,10 +496,18 @@
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '绱㈣禂QIS鐩殑锛孮IS宸叉湁鏂板搧鍙戣揣鏃�,涓嶈兘缁х画浜�'));
return false;
}//1822 yc 20211108 end
- //20220225 sx add obpm 鍔炰簨澶勫鍔犲垽鏂細鏄惁鐢宠鍐宠鍕剧潃娌℃湁鍐宠缂栧彿涓嶈兘杩涜鎿嶄綔
+ //20220225 sx start obpm 鍔炰簨澶勫鍔犲垽鏂細鏄惁鐢宠鍐宠鍕剧潃娌℃湁鍐宠缂栧彿涓嶈兘杩涜鎿嶄綔
else if(RaTar.Campaign__c != null && RaTar.Campaign__r.IF_Approved__c && RaTar.Campaign__r.Meeting_Approved_No__c == null){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, '宸茬敵璇峰喅瑁佷絾鍐宠缂栫爜涓虹┖'));
+ return false;
}
+ //20220225 sx end obpm 鍔炰簨澶勫鍔犲垽鏂細鏄惁鐢宠鍐宠鍕剧潃娌℃湁鍐宠缂栧彿涓嶈兘杩涜鎿嶄綔
+ //20220315 sx obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀� add start
+ else if(RaTar.Campaign__c != null && RaTar.Campaign__r.IF_Approved__c && RaTar.Campaign__r.Meeting_Approved_No__c != null && statusList.contains(RaTar.Campaign__r.Approved_Status__c)){
+ ApexPages.addMessage(new ApexPages.message(ApexPages.severity.Error, '宸茬敵璇峰喅瑁佷絾鍐宠鐘舵�佷笉绗﹀悎鏉′欢'));
+ return false;
+ }
+ //20220315 sx obpm澶囧搧鍐宠鐘舵�佺浉鍏充慨鏀� add end
}
return true;
}
@@ -603,17 +627,8 @@
robj.Cancel_Select__c = false;
robj.Cancel_Reason__c = '';
robj.Rental_Start_Date__c = RentalStartDateMap.containsKey(esd.tempOldRaesIdSub)?RentalStartDateMap.get(esd.tempOldRaesIdSub):craes.Rental_Start_Date__c ;
- switch on parentObj.demo_purpose2__c{
- when '璇曠敤锛堟棤璇环锛�','璇曠敤锛堟湁璇环锛�','鏂颁骇鍝佽瘎浠�','鍏朵粬','鍗忚鍊熺敤' {
- robj.Rental_End_Date__c = robj.Rental_Start_Date__c + intValueOf(parentObj.Hope_Lonaer_date_Num__c);
- }
- when '涓�鑸敤鎴�','淇濅慨鐢ㄦ埛','甯傚満澶氬勾淇濅慨','鍐嶄慨鐞�','绱㈣禂QIS','宸茶喘寰呰揣','鏁呴殰鎺掓煡' {
- robj.Rental_End_Date__c = robj.Rental_Start_Date__c + 30;
- }
- when '瀛︿細灞曚細' {
- robj.Rental_End_Date__c = parentObj.Campaign_EndDate_F__c + 5;
- }
- }
+ robj.Rental_End_Date__c = setRentalEndDate(robj.Rental_Start_Date__c, parentObj);
+
//robj.Rental_End_Date__c = robj.Rental_Start_Date__c + Integer.valueOf(craes.Test_Day__c);
// 鏂拌褰� Canceled__c & Canceled_Id__c 涓洪�変腑涓�瑙堢殑Id
robj.Canceled__c = craes.canDelete__c?craes.Canceled__c:craes.Id;
@@ -1695,6 +1710,7 @@
if(!isRaStatusOK()) {
return;
}
+
Id userId = Userinfo.getUserId(); // 20210624 ljh add SFDC-C448GR
Datetime now = System.now();
if(isSameCity) {
@@ -1714,7 +1730,7 @@
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '娌℃湁鏄庣粏锛屼笉鑳藉彂璐�!'));
return;
}
- Map<String, List<Rental_Apply_Equipment_Set_Detail__c>> approvalMap = new Map<String, List<Rental_Apply_Equipment_Set_Detail__c>>();// 20220309 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀�
+ Map<Datetime, List<Rental_Apply_Equipment_Set_Detail__c>> approvalMap = new Map<Datetime, List<Rental_Apply_Equipment_Set_Detail__c>>();// 20220309 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀�
for(EsdInfo esd:esdList) {
if(!raesdMap.containsKey(esd.rec.Id)) {
continue;
@@ -1724,7 +1740,16 @@
if(raesd.Is_Body__c) {
mainIdList.add(raesd.Asset__c);
raesIdSet.add(esd.rec.Rental_Apply_Equipment_Set__c);
+
+ // add lc 20220927 SFDC-CJ48VE 澶囧搧棰勮鍑哄簱鏃ラ�昏緫璋冩暣 start
+ // 澶囧搧棰勮鍑哄簱鏃ュ簲璇ョ瓑浜庝粖澶╋紝鍚﹀垯涓嶈兘鍙戣揣
+ if( esd.rec.Rental_Apply_Equipment_Set__r.Rental_Start_Date__c != Date.today() ){
+ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '澶囧搧棰勮鍑鸿揣鏃ュ簲璇ョ瓑浜庝粖澶╋紝鍚﹀垯涓嶈兘鍙戣揣!'));
+ return;
+ }
+ // add lc 20220927 SFDC-CJ48VE 澶囧搧棰勮鍑哄簱鏃ラ�昏緫璋冩暣 end
}
+
// 鍒嗛厤鏃朵复鏃跺彇娑堢殑鍦ㄥ彂璐у悗褰诲簳鍙栨秷
if(raesd.AgencyTempCancel__c) {
raesd.Cancel_Select__c = true;
@@ -1774,13 +1799,13 @@
// 20220309 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀� start
Datetime keyDt = raesd.Add_Request_approval_time__c != null?raesd.Add_Request_approval_time__c:raesd.Rental_Apply__r.Request_approval_time__c;
List<Rental_Apply_Equipment_Set_Detail__c> tempRaesdL;
- if(approvalMap.containsKey(keyDt.format())){
- tempRaesdL = approvalMap.get(keyDt.format());
+ if(approvalMap.containsKey(keyDt)){
+ tempRaesdL = approvalMap.get(keyDt);
}else{
tempRaesdL = new List<Rental_Apply_Equipment_Set_Detail__c>();
}
tempRaesdL.add(raesd);
- approvalMap.put(keyDt.format(),tempRaesdL);
+ approvalMap.put(keyDt,tempRaesdL);
// 20220309 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀� end
updateRaesdList.add(raesd);
}
@@ -1811,16 +1836,6 @@
return;
}
//20201209 ljh update end
-
- //20220217 sx add 澶囧搧鍊熷嚭鐢宠-鍐宠鎺у埗
- if (String.isNotBlank(parentObj.Campaign__c) && parentObj.Campaign__r.IF_Approved__c) {
- if (String.isBlank(parentObj.Campaign__r.Meeting_Approved_No__c)
- || String.isBlank(parentObj.Campaign__r.Meeting_Approved_No__r.MeetingApprovedNo__c)) {
- ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '璇ョ敵璇峰崟宸茬敵璇峰喅瑁佷絾鍐宠缂栫爜涓虹┖,涓嶈兘鍙戣揣锛�'));
- return;
- }
- }
-
// 鍒犻櫎link
if(!mainIdList.isEmpty()) {
Oly_TriggerHandler.bypass(AssetHandlerCheck.class.getName());
@@ -1830,35 +1845,35 @@
if(!updateRaesdList.isEmpty()) {
slip.Shippment_loaner_time__c = now;
FixtureUtil.withoutUpsertObjects(new List<FixtureDeliverySlip__c> {slip});
- // 鏄庣粏鍜岀敵璇疯繛鍒板彂璐у崟涓�
- for(Rental_Apply_Equipment_Set_Detail__c raesd: updateRaesdList) {
- if(!raesd.Cancel_Select__c) {
- raesd.DeliverySlip__c = slip.Id;
- }
- }
// 20220309 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀� start
map<String,Decimal> ApplyToShipmentMap = new map<String,Decimal>();
if(approvalMap.size() > 0 ){
// dtList[0] 绗竴涓氨鏄渶灏忔椂闂�
- List<String> dtList = new List<String>(approvalMap.keySet());
- Date startDateSOQL = date.newinstance(Datetime.valueOf(dtList[0]).year(), Datetime.valueOf(dtList[0]).month(), Datetime.valueOf(dtList[0]).day());
+ List<Datetime> dtList = new List<Datetime>(approvalMap.keySet());
+ Date startDateSOQL = date.newinstance(dtList[0].year(), dtList[0].month(), dtList[0].day());
List<OlympusCalendar__c> ocList = [SELECT Id, Date__c,IsWorkDay__c
FROM OlympusCalendar__c
WHERE Date__c >= :startDateSOQL
AND Date__c <= :Date.today()
ORDER BY Date__c ASC];
- for(String dt:dtList){
+ Map<Date,String> ocMap = new Map<Date,String>();
+ for(OlympusCalendar__c oc:ocList){
+ String IsWorkDay = oc.IsWorkDay__c.format();
+ ocMap.put(oc.Date__c,IsWorkDay);
+ }
+ for(Datetime dt:dtList){
Boolean startFlag = false;
Boolean endFlag = false;
- Datetime startTime = Datetime.valueOf(dt);
+ Datetime startTime = dt;
Date startDate = Date.newInstance(startTime.year(),startTime.month(),startTime.day());
Datetime endTime = Datetime.now();
Date endDate = Date.today();
// 瀹℃壒鏃堕棿鏄潪濂ユ灄宸存柉宸ヤ綔鏃�
- if(ocList[0].IsWorkDay__c == 0){
+ // if(ocList[0].IsWorkDay__c == 0){
+ if(ocMap.get(startDate) == '0'){
for(OlympusCalendar__c oc:ocList){
- if(oc.IsWorkDay__c == 1){
- startTime = oc.Date__c;
+ if(startDate < oc.Date__c && oc.IsWorkDay__c == 1){
+ startTime = Datetime.newInstance(oc.Date__c.year(),oc.Date__c.month(),oc.Date__c.day(),0,0,0);
startDate = oc.Date__c;
startFlag = true;
break;
@@ -1867,9 +1882,9 @@
}
// 鍙戣揣鏃堕棿鏄潪濂ユ灄宸存柉宸ヤ綔鏃�
if(ocList[ocList.size() - 1].IsWorkDay__c == 0){
- for(Integer i = ocList.size() - 1; i <= 0;i--){
+ for(Integer i = ocList.size() - 1; i >= 0;i--){
if(ocList[i].IsWorkDay__c == 1){
- endTime = ocList[i].Date__c.addDays(1);
+ endTime = Datetime.newInstance(ocList[i].Date__c.addDays(1).year(),ocList[i].Date__c.addDays(1).month(),ocList[i].Date__c.addDays(1).day(),0,0,0);
endDate = ocList[i].Date__c.addDays(1);
endFlag = true;
break;
@@ -1888,7 +1903,7 @@
timeDifLast = time11/time12;
Integer tempWeek = 0;
for(OlympusCalendar__c oc:ocList){
- if(startDate < oc.Date__c && oc.Date__c < endDate){
+ if(oc.IsWorkDay__c == 0 && startDate < oc.Date__c && oc.Date__c < endDate){
tempWeek++;
}
}
@@ -1901,6 +1916,17 @@
}
}
// 20220309 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀� end
+ // 鏄庣粏鍜岀敵璇疯繛鍒板彂璐у崟涓�
+ for(Rental_Apply_Equipment_Set_Detail__c raesd: updateRaesdList) {
+ if(!raesd.Cancel_Select__c) {
+ raesd.DeliverySlip__c = slip.Id;
+ }
+ // 20220315 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀� start
+ if(ApplyToShipmentMap.containsKey(raesd.Id)){
+ raesd.ApplyToShipmentWorkTime__c = ApplyToShipmentMap.get(raesd.Id);
+ }
+ // 20220315 ljh SFDC-CC6CLJ phase5涓婄嚎璇鹃131 鎻愪氦鐢宠鍒板鍝佸嚭搴撴椂闀� end
+ }
FixtureUtil.withoutUpdate(updateRaesdList);
// 20210624 ljh update SFDC-C448GR start
// Rental_Apply__c ra = new Rental_Apply__c(Id=parentObj.Id, DeliverySlip__c = slip.Id, Delivery_Agency__c = parentObj.Delivery_Agency__c, Agency_Address_Id__c = addressId );
@@ -1916,16 +1942,19 @@
//20220217 sx add 澶囧搧鍊熷嚭鐢宠-鍐宠鎺у埗 No.4 鍑哄簱鎴愬姛鏃讹紝鎶婃鏃剁偣鐨勫喅瑁佺紪鍙峰拰鍐宠鐘舵�佸啓鍒板喅瑁佺紪鍙凤紙鍑哄簱锛夊拰鍐宠鐘舵�侊紙鍑哄簱锛変笂
if (String.isNotBlank(parentObj.Campaign__c) && parentObj.Campaign__r.IF_Approved__c){
- ra.ApprovedNo_Delivery__c = parentObj.Campaign__r.Meeting_Approved_No__r.MeetingApprovedNo__c;
- ra.Approved_State_Delivery__c = parentObj.Campaign__r.Meeting_Approved_No__r.ProcessState__c;
+ // ra.ApprovedNo_Delivery__c = parentObj.Campaign__r.Meeting_Approved_No__r.MeetingApprovedNo__c;
+ // ra.Approved_State_Delivery__c = parentObj.Campaign__r.Meeting_Approved_No__r.ProcessState__c;
+ ra.ApprovedNo_Delivery__c = parentObj.Campaign__r.Meeting_Approved_No__r.Name;
+ ra.Approved_State_Delivery__c = parentObj.Campaign__r.Approved_Status__c;
}
FixtureUtil.withoutUpdate(new List<Rental_Apply__c> {ra});
}
// 鍚屽煄鏃惰嚜鍔ㄦ敹璐�
if(isSameCity && !raesIdSet.isEmpty()) {
List<Rental_Apply_Equipment_Set__c> raesList = new List<Rental_Apply_Equipment_Set__c>();
+ Date rentalEndDate = setRentalEndDate(Date.today(), parentObj);
for(Id raesId:raesIdSet) {
- raesList.add(new Rental_Apply_Equipment_Set__c(Id=raesId, Received_Confirm__c = 'OK'));
+ raesList.add(new Rental_Apply_Equipment_Set__c(Id=raesId, Received_Confirm__c = 'OK', Rental_Start_Date__c = Date.today(), Rental_End_Date__c = rentalEndDate));
}
FixtureUtil.withoutUpdate(raesList);
}
@@ -1934,7 +1963,8 @@
}
catch (Exception ex) {
system.debug('=====' + ex.getMessage());
- ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, ex.getDmlMessage(0)));
+ // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, ex.getDmlMessage(0)));
+ ApexPages.addMessages(ex);
Database.rollback(sp);
// 杩愯緭鍗曟彃鍏ユ垚鍔燂紝浣嗘槑缁嗘垨鐢宠鏇存柊澶辫触鏃讹紝杩愯緭鍗曠殑鍋嘔d瑕佹竻鎺�
if(insertSlip) {
@@ -1944,6 +1974,24 @@
}
}
+ public Date setRentalEndDate(Date startDate, Rental_Apply__c rentalApplyObj) {
+ Date endDate = null;
+ switch on rentalApplyObj.demo_purpose2__c{
+ when '璇曠敤锛堟棤璇环锛�','璇曠敤锛堟湁璇环锛�','鏂颁骇鍝佽瘎浠�','鍏朵粬','鍗忚鍊熺敤' {
+ endDate = startDate + intValueOf(rentalApplyObj.Hope_Lonaer_date_Num__c);
+ }
+ when '涓�鑸敤鎴�','淇濅慨鐢ㄦ埛','甯傚満澶氬勾淇濅慨','鍐嶄慨鐞�','绱㈣禂QIS','宸茶喘寰呰揣','鏁呴殰鎺掓煡' {
+ endDate = startDate + 30;
+ }
+ when '瀛︿細灞曚細' {
+ endDate = rentalApplyObj.Campaign_EndDate_F__c + 5;
+ }
+ }
+
+ return endDate;
+ }
+
+
public class EsdInfo {
public Rental_Apply_Equipment_Set_Detail__c rec { get; set; }
public Boolean checked {get;set;}
--
Gitblit v1.9.1