136 lines
7.6 KiB
OpenEdge ABL
136 lines
7.6 KiB
OpenEdge ABL
/**
|
|
* @description :
|
|
* author : Satyam Mishra
|
|
* @group :
|
|
* @last modified on : 04-26-2024
|
|
* @last modified by : Satyam Mishra
|
|
**/
|
|
public class orgObjSynchCountController {
|
|
|
|
@AuraEnabled(cacheable=true)
|
|
public static List<OrgObjectSynchCountVO> getOrgObjSynchCheckList() {
|
|
List<OrgObjectSynchCountVO> countList = new List<OrgObjectSynchCountVO>();
|
|
//add values
|
|
countList.add(new OrgObjectSynchCountVO(getUUID(),'Customers',getPreviousHourCustomerCount(),getCurrentHourCustomerCount(),getCumulativeCustomerCount()));
|
|
countList.add(new OrgObjectSynchCountVO(getUUID(),'Customer Orders',getPreviousHourOrderCount(),getCurrentHourOrderCount(),getCumulativeOrderCount()));
|
|
countList.add(new OrgObjectSynchCountVO(getUUID(),'Order Line Items',getPreviousHourOrderItemCount(),getCurrentHourOrderItemCount(),getCumulativeOrderItemCount()));
|
|
return countList;
|
|
}
|
|
|
|
static String getUUID() {
|
|
Blob b = Crypto.GenerateAESKey(128);
|
|
String h = EncodingUtil.ConvertTohex(b);
|
|
String guid = h.SubString(0,8).toUpperCase();
|
|
return guid;
|
|
}
|
|
|
|
public class OrgObjectSynchCountVO implements Comparable {
|
|
public Double scale=0;
|
|
@AuraEnabled public String color;
|
|
@AuraEnabled public String prevHourTotal;
|
|
@AuraEnabled public String currentHourTotal;
|
|
@AuraEnabled public String dayTotal;
|
|
@AuraEnabled public String name;
|
|
@AuraEnabled public String id;
|
|
|
|
final String OK = '#34cceb';
|
|
final String CAUTION = '#ebd334';
|
|
final String BAD = '#eb5934';
|
|
|
|
public Integer compareTo(Object compareTo) {
|
|
OrgObjectSynchCountVO ohcvo = (OrgObjectSynchCountVO) compareTo;
|
|
if (this.scale == ohcvo.scale) return 0;
|
|
if (this.scale > ohcvo.scale) return 1;
|
|
return -1;
|
|
}
|
|
|
|
OrgObjectSynchCountVO(String id,String name,String prevHourTotal,String currentHourTotal,String dayTotal) {
|
|
this.id=id;
|
|
this.name=name;
|
|
this.prevHourTotal=prevHourTotal;
|
|
this.currentHourTotal=currentHourTotal;
|
|
this.dayTotal=dayTotal;
|
|
}
|
|
}
|
|
|
|
@AuraEnabled(cacheable=true)
|
|
public static String getToday() {
|
|
String sThis_day_c = ''+System.Now();
|
|
Datetime this_day = Datetime.newInstance(Integer.valueOf(((sThis_day_c.split(' ')[0]).split('-')[0])),
|
|
Integer.valueOf(((sThis_day_c.split(' ')[0]).split('-')[1])),
|
|
Integer.valueOf(((sThis_day_c.split(' ')[0]).split('-')[2])),
|
|
23,59,59);
|
|
return (''+this_day).split(' ')[1];
|
|
}
|
|
|
|
@AuraEnabled(cacheable=true)
|
|
public static String getPrevious() {
|
|
TimeZone tz = UserInfo.getTimeZone();
|
|
String offset = tz.getDisplayName().substring(tz.getDisplayName().indexOf('GMT')+4,tz.getDisplayName().indexOf('GMT')+6);
|
|
//Previous hour
|
|
String sPrev_Hour_c = ''+System.Now().addHours(+1).addHours(Integer.valueOf(offset));
|
|
Integer hour = Integer.valueOf(((sPrev_Hour_c.split(' ')[1]).split(':')[0]));
|
|
Datetime prev_hour = Datetime.newInstance(Integer.valueOf(((sPrev_Hour_c.split(' ')[0]).split('-')[0])),
|
|
Integer.valueOf(((sPrev_Hour_c.split(' ')[0]).split('-')[1])),
|
|
Integer.valueOf(((sPrev_Hour_c.split(' ')[0]).split('-')[2])),
|
|
hour,0,0).addHours(Integer.valueOf(offset));
|
|
return ((''+prev_hour).split(' ')[1]).replace(':00','')+':00';
|
|
}
|
|
|
|
@AuraEnabled(cacheable=true)
|
|
public static String getCurrent() {
|
|
TimeZone tz = UserInfo.getTimeZone();
|
|
String offset = tz.getDisplayName().substring(tz.getDisplayName().indexOf('GMT')+4,tz.getDisplayName().indexOf('GMT')+6);
|
|
// Current hour
|
|
String sCurr_Hour_c = ''+System.now().addHours(+2).addHours(Integer.valueOf(offset));
|
|
Integer hour = Integer.valueOf(((sCurr_Hour_c.split(' ')[1]).split(':')[0]));
|
|
Datetime curr_hour = Datetime.newInstance(Integer.valueOf(((sCurr_Hour_c.split(' ')[0]).split('-')[0])),
|
|
Integer.valueOf(((sCurr_Hour_c.split(' ')[0]).split('-')[1])),
|
|
Integer.valueOf(((sCurr_Hour_c.split(' ')[0]).split('-')[2])),
|
|
hour,0,0).addHours(Integer.valueOf(offset));
|
|
return ((''+curr_hour).split(' ')[1]).replace(':00','')+':00';
|
|
}
|
|
|
|
/************************************************************************Account***************************************************/
|
|
public static String getCumulativeCustomerCount() {
|
|
return ''+[select count(id)total from Account where CreatedDate >= :orgObjSynchUtil.getTodaysBaseTime() and CreatedDate <= :orgObjSynchUtil.getTodaysBaseTimeMax()][0].get('total');
|
|
}
|
|
|
|
static String getCurrentHourCustomerCount() {
|
|
return ''+[select count(id)total from Account where CreatedDate >= :orgObjSynchUtil.getCurrentHour() and CreatedDate < :orgObjSynchUtil.getNextHour()][0].get('total');
|
|
}
|
|
|
|
static String getPreviousHourCustomerCount() {
|
|
return ''+[select count(id)total from Account where CreatedDate >= :orgObjSynchUtil.getPreviousHour() and CreatedDate < :orgObjSynchUtil.getCurrentHour()][0].get('total');
|
|
}
|
|
/*_____________________________________________________________________________________________________________________________________________*/
|
|
|
|
/************************************************************************ORDER***************************************************/
|
|
public static String getCumulativeOrderCount() {
|
|
return ''+[select count(OrderNumber)total from Order where CreatedDate >= :orgObjSynchUtil.getTodaysBaseTime() and CreatedDate <= :orgObjSynchUtil.getTodaysBaseTimeMax()][0].get('total');
|
|
}
|
|
|
|
static String getCurrentHourOrderCount() {
|
|
return ''+[select count(OrderNumber)total from Order where CreatedDate >= :orgObjSynchUtil.getCurrentHour() and CreatedDate < :orgObjSynchUtil.getNextHour()][0].get('total');
|
|
}
|
|
|
|
static String getPreviousHourOrderCount() {
|
|
return ''+[select count(OrderNumber)total from Order where CreatedDate >= :orgObjSynchUtil.getPreviousHour() and CreatedDate < :orgObjSynchUtil.getCurrentHour()][0].get('total');
|
|
}
|
|
/*_____________________________________________________________________________________________________________________________________________*/
|
|
|
|
/************************************************************************ORDER LINE ITEM ***************************************************/
|
|
static String getCumulativeOrderItemCount() {
|
|
return ''+[select count(id)total from OrderItem where CreatedDate >= :orgObjSynchUtil.getTodaysBaseTime() and CreatedDate <= :orgObjSynchUtil.getTodaysBaseTimeMax()][0].get('total');
|
|
}
|
|
|
|
static String getCurrentHourOrderItemCount() {
|
|
return ''+[select count(id)total from OrderItem where CreatedDate >= :orgObjSynchUtil.getCurrentHour() and CreatedDate < :orgObjSynchUtil.getNextHour()][0].get('total');
|
|
}
|
|
|
|
static String getPreviousHourOrderItemCount() {
|
|
return ''+[select count(id)total from OrderItem where CreatedDate >= :orgObjSynchUtil.getPreviousHour() and CreatedDate < :orgObjSynchUtil.getCurrentHour()][0].get('total');
|
|
}
|
|
/*_____________________________________________________________________________________________________________________________________________*/
|
|
|
|
} |