From 00e147ec892cb1e89d0698787a8c60da1014cdb7 Mon Sep 17 00:00:00 2001
From: binxie <137736985@qq.com>
Date: 星期一, 26 六月 2023 17:42:22 +0800
Subject: [PATCH] Community升级
---
force-app/main/default/classes/LexConsumableAccountController.cls | 217 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 212 insertions(+), 5 deletions(-)
diff --git a/force-app/main/default/classes/LexConsumableAccountController.cls b/force-app/main/default/classes/LexConsumableAccountController.cls
index b966c13..1c613df 100644
--- a/force-app/main/default/classes/LexConsumableAccountController.cls
+++ b/force-app/main/default/classes/LexConsumableAccountController.cls
@@ -34,7 +34,7 @@
//鍒濆鍖�
@AuraEnabled
- public static ResponseBodyLWC init(Integer pageSizeLWC, Integer pageTokenLWC) {
+ public static ResponseBodyLWC init(Integer pageSizeLWC, Integer pageTokenLWC, String fiscalYear) {
try {
ResponseBodyLWC res = new ResponseBodyLWC();
Map<String, object> data = new Map<String, object>();
@@ -113,6 +113,92 @@
paginatedAccounts.totalRecords = totalCount;
//閿�閲忓墠鍗佺殑瀹㈡埛
+ // List<Account> acList = [
+ // SELECT
+ // id,
+ // Name,
+ // State_Master__c,
+ // State_Master__r.Name,
+ // Salesdepartment_HP__c,
+ // CreatedDate,
+ // Is_Active__c,
+ // RecordType.Name,
+ // Grade__c,
+ // OCM_Category__c,
+ // City_Master__c,
+ // City_Master__r.Name,
+ // Town__c,
+ // Phone
+ // FROM Account
+ // WHERE State_Master__r.Name != '' AND City_Master__r.Name != '' AND Is_Active__c = '鏈夊姽' AND RecordType.Name = '鐥呴櫌'
+ // LIMIT 10
+ // ];
+ TopInfo topInfo = new TopInfo();
+
+ Date today = Date.today();
+ Integer lastYear = today.year() - 1;
+ Integer thisYear = today.year();
+ Integer nextYear = today.year() + 1;
+ Date lastDatetime = Date.newInstance(lastYear, 4, 1);
+ Date thisDatetime = Date.newInstance(thisYear, 4, 1);
+ Date thisDatetime2 = Date.newInstance(thisYear, 4, 1);
+ Date nextDatetime = Date.newInstance(nextYear, 4, 1);
+
+ AggregateResult[] arList = null;
+
+ System.debug('fiscalYear = ' + fiscalYear);
+ if (fiscalYear == 'thisYear') {
+ AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(thisDatetime, nextDatetime);
+ topInfo.saleAmount = Decimal.valueOf(String.valueOf(saleAmountList[0].get('saleAmount')));
+ System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
+ arList = LexConsumableAccountSOQL.getAccountBySales(thisDatetime, nextDatetime);
+ } else if (fiscalYear == 'lastYear') {
+ AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(lastDatetime, thisDatetime2);
+ topInfo.saleAmount = Decimal.valueOf(String.valueOf(saleAmountList[0].get('saleAmount')));
+ System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
+ arList = LexConsumableAccountSOQL.getAccountBySales(lastDatetime, thisDatetime2);
+ } else {
+ AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(lastDatetime, nextDatetime);
+ topInfo.saleAmount = Decimal.valueOf(String.valueOf(saleAmountList[0].get('saleAmount')));
+ System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
+ arList = LexConsumableAccountSOQL.getAccountBySales(lastDatetime, nextDatetime);
+ }
+
+ // Map<String,Decimal> mapTemp = new Map<String,Decimal>();
+ // for (AggregateResult ar : arList) {
+ // if(!mapTemp.get(String.valueOf(ar.get('hospitalName')))){
+ // mapTemp.put(String.valueOf(ar.get('hospitalName'),Decimal.valueOf(String.valueOf(ar.get('thisAmount')))));
+ // }else {
+ // Decimal decimal = mapTemp.get(String.valueOf(ar.get('hospitalName')));
+ // decimal += Decimal.valueOf(String.valueOf(ar.get('thisAmount')));
+ // mapTemp.put(String.valueOf(ar.get('hospitalName'),decimal));
+ // }
+ // }
+ // System.debug('mapTemp = ' + mapTemp);
+ // //鎺掑簭Decimal浠庡ぇ鍒板皬
+ // List<Decimal> decimalList = new List<Decimal>(mapTemp.values());
+ // decimalList.sort((a, b) => b.compareTo(a));
+ // Map<String, Decimal> sortedMap = new Map<String, Decimal>();
+ // for (String key : mapTemp.keySet()) {
+ // sortedMap.put(key, mapTemp.get(key));
+ // }
+
+ // System.debug('Sorted Map: ' + sortedMap);
+
+ //鏌ヨ瀹㈡埛淇℃伅锛堝悕绉帮紝鐪侊紝鍘匡級
+ System.debug('arList = ' + arList);
+ List<String> accountList = new List<String>();
+ for (AggregateResult ar : arList) {
+ System.debug('thisAmount = ' + String.valueOf(ar.get('thisAmount')));
+ if(String.valueOf(ar.get('thisAmount')) != '0.0'){
+ accountList.add(String.valueOf(ar.get('Order_ForHospital__c')));
+ topInfo.deList.add(Decimal.valueOf(String.valueOf(ar.get('thisAmount'))));
+ }
+ }
+
+ System.debug('accountList = ' + accountList);
+ System.debug('topInfo = ' + topInfo);
+
List<Account> acList = [
SELECT
id,
@@ -130,10 +216,22 @@
Town__c,
Phone
FROM Account
- WHERE State_Master__r.Name != '' AND City_Master__r.Name != '' AND Is_Active__c = '鏈夊姽' AND RecordType.Name = '鐥呴櫌'
- LIMIT 10
+ WHERE Id = :accountList
];
- data.put('acList', acList);
+
+ List<Account> acListTemp = new List<Account>();
+
+ for (String s : accountList) {
+ for (Account a : acList) {
+ if (s == a.id) {
+ acListTemp.add(a);
+ }
+ }
+ }
+
+ topInfo.acList = acListTemp;
+
+ data.put('topInfo', topInfo);
data.put('pageRecords', selectAccList);
data.put('paginatedAccounts', paginatedAccounts);
data.put('accountId', accountId);
@@ -144,7 +242,101 @@
res.msg = '';
return res;
} catch (Exception e) {
- return new ResponseBodyLWC('Error', 500, e.getMessage(), '');
+ return new ResponseBodyLWC('Error', 500, e.getMessage() + e.getLineNumber(), '');
+ }
+ }
+
+ @AuraEnabled
+ public static ResponseBodyLWC changeFiscalYearView(String fiscalYear) {
+ ResponseBodyLWC res = new ResponseBodyLWC();
+ Map<String, object> data = new Map<String, object>();
+ res.entity = data;
+ try {
+ TopInfo topInfo = new TopInfo();
+
+ Date today = Date.today();
+ Integer lastYear = today.year() - 1;
+ Integer thisYear = today.year();
+ Integer nextYear = today.year() + 1;
+ Date lastDatetime = Date.newInstance(lastYear, 4, 1);
+ Date thisDatetime = Date.newInstance(thisYear, 4, 1);
+ Date thisDatetime2 = Date.newInstance(thisYear, 4, 1);
+ Date nextDatetime = Date.newInstance(nextYear, 4, 1);
+
+ AggregateResult[] arList = null;
+
+ System.debug('fiscalYear = ' + fiscalYear);
+ System.debug('thisYear = ' + thisYear);
+ System.debug('lastYear = ' + lastYear);
+
+ if (fiscalYear == 'thisYear') {
+ AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(thisDatetime, nextDatetime);
+ if (saleAmountList[0].get('saleAmount') != null) {
+ topInfo.saleAmount = Decimal.valueOf(String.valueOf(saleAmountList[0].get('saleAmount')));
+ System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
+ }
+ arList = LexConsumableAccountSOQL.getAccountBySales(thisDatetime, nextDatetime);
+ } else if (fiscalYear == 'lastYear') {
+ AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(lastDatetime, thisDatetime2);
+ if (saleAmountList[0].get('saleAmount') != null) {
+ topInfo.saleAmount = Decimal.valueOf(String.valueOf(saleAmountList[0].get('saleAmount')));
+ System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
+ }
+ arList = LexConsumableAccountSOQL.getAccountBySales(lastDatetime, thisDatetime2);
+ } else {
+ AggregateResult[] saleAmountList = LexConsumableAccountSOQL.getAccountTotalSales(lastDatetime, nextDatetime);
+ if (saleAmountList[0].get('saleAmount') != null) {
+ topInfo.saleAmount = Decimal.valueOf(String.valueOf(saleAmountList[0].get('saleAmount')));
+ System.debug('topInfo.saleAmount = ' + topInfo.saleAmount);
+ }
+ arList = LexConsumableAccountSOQL.getAccountBySales(lastDatetime, nextDatetime);
+ }
+ //鏌ヨ瀹㈡埛淇℃伅锛堝悕绉帮紝鐪侊紝鍘匡級
+ List<String> accountList = new List<String>();
+ for (AggregateResult ar : arList) {
+ System.debug('thisAmount = ' + String.valueOf(ar.get('thisAmount')));
+ if (String.valueOf(ar.get('thisAmount')) != '0.0') {
+ accountList.add(String.valueOf(ar.get('Order_ForHospital__c')));
+ topInfo.deList.add(Decimal.valueOf(String.valueOf(ar.get('thisAmount'))));
+ }
+ }
+ System.debug('accountList = ' + accountList);
+ System.debug('topInfo = ' + topInfo);
+ List<Account> acList = [
+ SELECT
+ id,
+ Name,
+ State_Master__c,
+ State_Master__r.Name,
+ Salesdepartment_HP__c,
+ CreatedDate,
+ Is_Active__c,
+ RecordType.Name,
+ Grade__c,
+ OCM_Category__c,
+ City_Master__c,
+ City_Master__r.Name,
+ Town__c,
+ Phone
+ FROM Account
+ WHERE Id = :accountList
+ ];
+ List<Account> acListTemp = new List<Account>();
+ for (String s : accountList) {
+ for (Account a : acList) {
+ if (s == a.id) {
+ acListTemp.add(a);
+ }
+ }
+ }
+ topInfo.acList = acListTemp;
+ data.put('topInfo', topInfo);
+ res.status = 'Success';
+ res.code = 200;
+ res.msg = '';
+ return res;
+ } catch (Exception e) {
+ return new ResponseBodyLWC('Error', 500, e.getMessage() + e.getLineNumber(), '');
}
}
@@ -242,4 +434,19 @@
@AuraEnabled
public Integer recordEnd { get; set; }
}
+
+ //top10 Account
+ public class TopInfo {
+ @AuraEnabled
+ public Decimal saleAmount { get; set; }
+ @AuraEnabled
+ public List<Account> acList { get; set; }
+ @AuraEnabled
+ public List<Decimal> deList { get; set; }
+
+ public TopInfo() {
+ acList = new List<Account>();
+ deList = new List<Decimal>();
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1