// 点检对象:今天所在月加上之前2个月
|
// 访问,OPD,NTC对象:今天所在月加上之前11个月
|
// 修理,重点产品OPD对象:昨天所在年度一年的。如果到了4月没有数据,结果是0
|
// FIXME goto 访问,OPD,NTC现在一年有些长
|
global class RollupToHPBatch implements Database.Batchable<sObject> {
|
String Salesdepartment_HP1;
|
String Salesdepartment_HP2;
|
String hpId;
|
// SWAG-BQ75WE update by vivek 2020/06/11 start
|
Map<String,String> filedNameMap;
|
// SWAG-BQ75WE update by vivek 2020/06/11 end
|
|
// 点检月3个月
|
Integer intMonth = -4; // 要注意:initAccountCount() も修正が必要
|
// 年度切り替えたけど、前の年度のデータを見たい期間、4日の猶予期間
|
static Integer intYearDelayDay = Integer.valueOf(System.Label.ShowLastYear_DefermentDay);
|
|
/**
|
* コンスタント
|
*/
|
global RollupToHPBatch(String Salesdepartment_HP1, String Salesdepartment_HP2) {
|
this.Salesdepartment_HP1 = Salesdepartment_HP1;
|
this.Salesdepartment_HP2 = Salesdepartment_HP2;
|
}
|
global RollupToHPBatch(String hpId) {
|
this.hpId = hpId;
|
}
|
|
/**
|
* startには、queryを実行、病院を検索
|
*/
|
global Database.QueryLocator start(Database.BatchableContext BC) {
|
if (String.isBlank(this.Salesdepartment_HP1)) {
|
// UT 用
|
if (String.isBlank(this.hpId)) {
|
return Database.getQueryLocator(
|
[select Id
|
from Account
|
where RecordType.DeveloperName = 'HP'
|
and Is_Active__c <> '無効'
|
order by Id]
|
);
|
} else {
|
return Database.getQueryLocator(
|
[select Id
|
from Account
|
where RecordType.DeveloperName = 'HP'
|
and Is_Active__c <> '無効'
|
and Id = :this.HpId
|
order by Id]
|
);
|
}
|
} else {
|
return Database.getQueryLocator(
|
[select Id
|
from Account
|
where RecordType.DeveloperName = 'HP'
|
and Is_Active__c <> '無効'
|
and (Salesdepartment_HP__c = :this.Salesdepartment_HP1 or Salesdepartment_HP__c = :this.Salesdepartment_HP2)
|
order by Id]
|
);
|
}
|
}
|
|
global void execute(Database.BatchableContext BC, List<SObject> hpList) {
|
|
|
Date targetDay2 = getTargetDay();
|
Integer targetmonth = targetDay2.month(); // 点検3ヶ月を消すため
|
Date nextMonth = targetDay2.addMonths(1);
|
|
Date sDate = Date.valueOf(nextMonth.year() - 1 + '-' + nextMonth.month() + '-1');
|
Date eDate = Date.valueOf(nextMonth.year() + '-' + nextMonth.month() + '-1');
|
// 点检月份,3个月前的1日到下个月1日
|
Date sDay = Date.valueOf(targetDay2.addMonths(intMonth).year() + '-' + targetDay2.addMonths(intMonth).month() + '-1');
|
Date eDay = Date.valueOf(nextMonth.year() + '-' + nextMonth.month() + '-1');
|
|
// 修理TAT(到客户返送日),修理TAT(到RC返送日),修理报价,发票金额 Hospital__c应与Delivered_Product__r.Hospital__c一致
|
Integer iyear = targetDay2.year();
|
if (targetDay2.month() < 4) {
|
iyear -= 1;
|
}
|
Date lastYd = Date.valueOf(iyear - 1 + '-4-1');
|
Date thisYd = Date.valueOf(iyear + '-4-1');
|
Date nextYd = Date.valueOf(iyear + 1 + '-4-1');
|
List<AggregateResult> repairList = [
|
select AVG(Elapsed_day_from_Repair__c) avg_Repair,
|
AVG(Elapsed_day_from_Repair2__c) avg_Repair2,
|
SUM(Repair_List_Price__c) sum_Price,
|
SUM(Billing_Amount__c) sum_Billing,
|
Delivered_Product__r.Hospital__c Hospital
|
from Repair__c
|
where Delivered_Product__r.Hospital__c in : hpList
|
and Hospital__c != null
|
and Failure_Occurrence_Date__c >= : thisYd
|
and Failure_Occurrence_Date__c < : nextYd
|
group by Delivered_Product__r.Hospital__c
|
];
|
Map<String, AggregateResult> repairMap = new Map<String, AggregateResult>();
|
for (AggregateResult repair : repairList) {
|
repairMap.put(String.valueOf(repair.get('Hospital')), repair);
|
}
|
List<AggregateResult> repair_LY_List = [
|
select AVG(Elapsed_day_from_Repair__c) avg_Repair,
|
AVG(Elapsed_day_from_Repair2__c) avg_Repair2,
|
SUM(Repair_List_Price__c) sum_Price,
|
SUM(Billing_Amount__c) sum_Billing,
|
Delivered_Product__r.Hospital__c Hospital
|
from Repair__c
|
where Delivered_Product__r.Hospital__c in : hpList
|
and Hospital__c != null
|
and Failure_Occurrence_Date__c >= : lastYd
|
and Failure_Occurrence_Date__c < : thisYd
|
group by Delivered_Product__r.Hospital__c
|
];
|
Map<String, AggregateResult> repair_LY_Map = new Map<String, AggregateResult>();
|
for (AggregateResult repair : repair_LY_List) {
|
repair_LY_Map.put(String.valueOf(repair.get('Hospital')), repair);
|
}
|
|
// 未回款金额 Hospital__c应与Delivered_Product__r.Hospital__c一致
|
List<AggregateResult> unpaidList = [
|
select SUM(Unpaid_Amount__c) sum_Unpaid,
|
Delivered_Product__r.Hospital__c Hospital
|
from Repair__c
|
where Delivered_Product__r.Hospital__c in : hpList
|
and Hospital__c != null
|
/* CHAN-B7J5EK 2018/12/18 未回款金额为0 则不检索 start */
|
and Unpaid_Amount__c != null
|
and Unpaid_Amount__c != 0
|
/* CHAN-B7J5EK 2018/12/18 未回款金额为0 则不检索 end */
|
group by Delivered_Product__r.Hospital__c
|
];
|
Map<String, AggregateResult> unpaidMap = new Map<String, AggregateResult>();
|
for (AggregateResult unpaid : unpaidList) {
|
unpaidMap.put(String.valueOf(unpaid.get('Hospital')), unpaid);
|
}
|
|
// 维修合同 按 状态=契約
|
List<AggregateResult> mContractList = [
|
select Count(Id) Cnt_Id, Hospital__c
|
from Maintenance_Contract__c
|
where Status__c = '契約'
|
and Hospital__c in : hplist
|
// KPI 报表修改 , 刨除多年保修合同 start
|
and (recordType.developerName = 'NewMaintenance_Contract' or recordType.developerName = 'Maintenance_Contract')
|
// KPI 报表修改 , 刨除多年保修合同 end
|
group by Hospital__c
|
];
|
Map<String, AggregateResult> mContractMap = new Map<String, AggregateResult>();
|
for (AggregateResult mContract : mContractList) {
|
mContractMap.put(String.valueOf(mContract.get('Hospital__c')), mContract);
|
}
|
|
|
// 提案书 FIXME goto 時間の範囲?
|
Map<Id, AggregateResult> proposalDocumentMap = new Map<Id, AggregateResult>([
|
select Hospital__c Id,
|
// Max(Proposal_count__c) Submit_Status
|
Max(Proposal_count__c) Proposal_Submit_Status,
|
Max(Quarterly_count__c) Quarterly_Submit_Status
|
from TemporaryFileBox__c
|
where Hospital__c in : hpList
|
and Approval_day__c >= :thisYd
|
and Approval_day__c < :nextYd
|
group by Hospital__c
|
]);
|
|
Map<Id, AggregateResult> proposalDocumentMap2 = new Map<Id, AggregateResult>([
|
select Hospital__c Id,
|
Max(Customer_submit_day__c) Submit_day
|
from TemporaryFileBox__c
|
where Hospital__c in : hpList
|
and Attached_category__c = '季报'
|
and Approval_day__c >= :thisYd
|
and Approval_day__c < :nextYd
|
group by Hospital__c
|
]);
|
|
|
Map<Id, Account2__c> updateAccount = new Map<Id, Account2__c>();
|
List<Account2__c> acc2List =
|
[select Id, Account__c, Account_Org__c from Account2__c
|
where Account_Org__c in :hpList];
|
|
for (Account2__c acc2 : acc2List) {
|
String hpid = acc2.Account_Org__c;
|
Account2__c acc = new Account2__c(Id = acc2.Id);
|
initAccountCount(acc, targetmonth);
|
// 提案书, 季报
|
if (proposalDocumentMap.containsKey(hpid)) {
|
acc.Proposal_Submit_Status__c =
|
(proposalDocumentMap.get(hpid).get('Proposal_Submit_Status') == null ? 0 : (Decimal) proposalDocumentMap.get(hpid).get('Proposal_Submit_Status'))
|
+ (proposalDocumentMap.get(hpid).get('Quarterly_Submit_Status') == null ? 0 : (Decimal) proposalDocumentMap.get(hpid).get('Quarterly_Submit_Status'));
|
}
|
// 季报
|
if (proposalDocumentMap2.containsKey(hpid)) {
|
acc.Latest_Proposal_document_Submit_day__c =
|
proposalDocumentMap2.get(hpid).get('Submit_day') == null ? null : (Date) proposalDocumentMap2.get(hpid).get('Submit_day');
|
}
|
if (repairMap.containsKey(hpid)) {
|
acc.AVG_Elapsed_day_from_Repair__c += repairMap.get(hpid).get('avg_Repair') == null ? 0 : Decimal.valueOf(String.valueOf(repairMap.get(hpid).get('avg_Repair')));
|
acc.AVG_Elapsed_day_from_Repair2__c += repairMap.get(hpid).get('avg_Repair2') == null ? 0 : Decimal.valueOf(String.valueOf(repairMap.get(hpid).get('avg_Repair2')));
|
acc.SUM_Repair_List_Price__c += repairMap.get(hpid).get('sum_Price') == null ? 0 : Decimal.valueOf(String.valueOf(repairMap.get(hpid).get('sum_Price')));
|
acc.SUM_Repair_Billing_Amount__c += repairMap.get(hpid).get('sum_Billing') == null ? 0 : Decimal.valueOf(String.valueOf(repairMap.get(hpid).get('sum_Billing')));
|
}
|
if (repair_LY_Map.containsKey(hpid)) {
|
acc.AVG_Elapsed_day_from_Repair_Lastyear__c += repair_LY_Map.get(hpid).get('avg_Repair') == null ? 0 : Decimal.valueOf(String.valueOf(repair_LY_Map.get(hpid).get('avg_Repair')));
|
acc.AVG_Elapsed_day_from_Repair2_Lastyear__c += repair_LY_Map.get(hpid).get('avg_Repair2') == null ? 0 : Decimal.valueOf(String.valueOf(repair_LY_Map.get(hpid).get('avg_Repair2')));
|
acc.SUM_Repair_List_Price_Lastyear__c += repair_LY_Map.get(hpid).get('sum_Price') == null ? 0 : Decimal.valueOf(String.valueOf(repair_LY_Map.get(hpid).get('sum_Price')));
|
acc.SUM_Repair_Billing_Amount_Lastyear__c += repair_LY_Map.get(hpid).get('sum_Billing') == null ? 0 : Decimal.valueOf(String.valueOf(repair_LY_Map.get(hpid).get('sum_Billing')));
|
}
|
if (unpaidMap.containsKey(hpid)) {
|
acc.SUM_Unpaid_Amount__c += unpaidMap.get(hpid).get('sum_Unpaid') == null ? 0 : Decimal.valueOf(String.valueOf(unpaidMap.get(hpid).get('sum_Unpaid')));
|
}
|
if (mContractMap.containsKey(hpid)) {
|
acc.Service_contract_active_number_HP__c += Integer.valueOf(mContractMap.get(hpid).get('Cnt_Id'));
|
}
|
updateAccount.put(hpid, acc);
|
|
}
|
|
|
// 戦略科室を検索
|
Map<Id, Account> dcListMap = new Map<Id, Account>(
|
[select Id, Department_Class_Label__c
|
from Account
|
where Parent.RecordType.DeveloperName = 'HP'
|
and Is_Active__c <> '無効'
|
and ParentId in : hpList]
|
);
|
|
// 2018-09-14 CHAN-B4J9TC start 额外获取归属于哪个战略科室 :Account_Org__r.RecordType_DeveloperName__c
|
Map<Id, Account2__c> OldAccount2 =
|
new Map<Id, Account2__c> (
|
[select Id, Account__c, Account_Org__r.RecordType_DeveloperName__c
|
, Account_Org__r.parentID // SWAG-BD24SU
|
from Account2__c
|
where Account_Org__c in :dcListMap.keySet()]);
|
// 2018-09-14 CHAN-B4J9TC end 额外获取归属于哪个战略科室
|
|
|
// 修理TAT(到客户返送日),修理TAT(到RC返送日),修理报价,发票金额 Department_Class__c应与Delivered_Product__r.Department_Class__c一致
|
List<AggregateResult> dc_repairList = [
|
select AVG(Elapsed_day_from_Repair__c) avg_Repair,
|
AVG(Elapsed_day_from_Repair2__c) avg_Repair2,
|
SUM(Repair_List_Price__c) sum_Price,
|
SUM(Billing_Amount__c) sum_Billing,
|
Delivered_Product__r.Department_Class__c Department_Class
|
from Repair__c
|
where Delivered_Product__r.Department_Class__c in : dcListMap.keySet()
|
and Department_Class__c != null
|
and Failure_Occurrence_Date__c >= : thisYd
|
and Failure_Occurrence_Date__c < : nextYd
|
group by Delivered_Product__r.Department_Class__c
|
];
|
Map<String, AggregateResult> dc_repairMap = new Map<String, AggregateResult>();
|
for (AggregateResult dc_repair : dc_repairList) {
|
dc_repairMap.put(String.valueOf(dc_repair.get('Department_Class')), dc_repair);
|
}
|
List<AggregateResult> dc_repair_LY_List = [
|
select AVG(Elapsed_day_from_Repair__c) avg_Repair,
|
AVG(Elapsed_day_from_Repair2__c) avg_Repair2,
|
SUM(Repair_List_Price__c) sum_Price,
|
SUM(Billing_Amount__c) sum_Billing,
|
Delivered_Product__r.Department_Class__c Department_Class
|
from Repair__c
|
where Delivered_Product__r.Department_Class__c in : dcListMap.keySet()
|
and Department_Class__c != null
|
and Failure_Occurrence_Date__c >= : lastYd
|
and Failure_Occurrence_Date__c < : thisYd
|
group by Delivered_Product__r.Department_Class__c
|
];
|
Map<String, AggregateResult> dc_repair_LY_Map = new Map<String, AggregateResult>();
|
for (AggregateResult dc_repair : dc_repair_LY_List) {
|
dc_repair_LY_Map.put(String.valueOf(dc_repair.get('Department_Class')), dc_repair);
|
}
|
|
// 未回款金额 Department_Class__c应与Delivered_Product__r.Department_Class__c一致
|
List<AggregateResult> dc_unpaidList = [
|
select SUM(Unpaid_Amount__c) sum_Unpaid,
|
Delivered_Product__r.Department_Class__c Department_Class
|
from Repair__c
|
where Delivered_Product__r.Department_Class__c in : dcListMap.keySet()
|
and Department_Class__c != null
|
/* CHAN-B7J5EK 2018/12/18 未回款金额为0 则不检索 start */
|
and Unpaid_Amount__c != null
|
and Unpaid_Amount__c != 0
|
/* CHAN-B7J5EK 2018/12/18 未回款金额为0 则不检索 end */
|
group by Delivered_Product__r.Department_Class__c
|
];
|
Map<String, AggregateResult> dc_unpaidMap = new Map<String, AggregateResult>();
|
for (AggregateResult dc_unpaid : dc_unpaidList) {
|
dc_unpaidMap.put(String.valueOf(dc_unpaid.get('Department_Class')), dc_unpaid);
|
}
|
|
// 维修合同 按 状态=契約
|
List<AggregateResult> dc_mContractList = [
|
select Count(Id) Cnt_Id, Department_Class__c
|
from Maintenance_Contract__c
|
where Status__c = '契約'
|
// KPI 报表修改 , 刨除多年保修合同 start
|
and (recordType.developerName = 'NewMaintenance_Contract' or recordType.developerName = 'Maintenance_Contract')
|
// KPI 报表修改 , 刨除多年保修合同 end
|
and Department_Class__c in : dcListMap.keySet()
|
group by Department_Class__c
|
];
|
Map<String, AggregateResult> dc_mContractMap = new Map<String, AggregateResult>();
|
for (AggregateResult dc_mContract : dc_mContractList) {
|
dc_mContractMap.put(String.valueOf(dc_mContract.get('Department_Class__c')), dc_mContract);
|
}
|
|
// 戦略科室更新
|
// 2018/08/24 SWAG-B3U67F 获取战略科室的提案书情况 存至客户2中 start
|
|
Map<Id, AggregateResult> proposalDocumentMap_dept = new Map<Id, AggregateResult>([
|
select Account_dept__c Id,
|
Max(Proposal_count__c) Proposal_Submit_Status,
|
Max(Quarterly_count__c) Quarterly_Submit_Status
|
from TemporaryFileBox__c
|
where Account_dept__r.Parent.RecordType.DeveloperName = 'HP'
|
and Account_dept__r.Is_Active__c <> '無効'
|
and Account_dept__r.parentID in : hpList
|
and Approval_day__c >= :thisYd
|
and Approval_day__c < :nextYd
|
group by Account_dept__c
|
]);
|
|
// 2018/08/24 SWAG-B3U67F 获取战略科室的提案书情况 存至客户2中 end
|
|
List<Account2__c> acc2List2 =
|
[select Id, Account__c, Account_Org__c
|
// SWAG-BD24SU 额外检索一些新东西 start
|
, Account_Org__r.ParentId, Account_Org__r.RecordType_DeveloperName__c
|
// SWAG-BD24SU 额外检索一些新东西 end
|
from Account2__c where Account_Org__c in :dcListMap.keySet()];
|
// SWAG-BD24SU 构建医院为key, 消化科战略科室客户2ID为Value 的map start
|
Map<id, id> HPtoGIAcc2Map = new Map<id, Id>();
|
Map<String, id> depToOtherDepAcc2Map = new Map<String,id>();
|
for (Account2__c tempAcc2 : acc2List2) {
|
// SWAG-BQ75WE update by vivek 2020/26/11 start
|
// if (tempAcc2.Account_Org__c != null
|
// && tempAcc2.Account_Org__r.RecordType_DeveloperName__c.equals('Department_Class_GI') ) {
|
// HPtoGIAcc2Map.put(tempAcc2.Account_Org__r.ParentId, tempAcc2.Account_Org__c)
|
// }
|
if (tempAcc2.Account_Org__c != null) {
|
depToOtherDepAcc2Map.put(tempAcc2.Account_Org__r.ParentId+tempAcc2.Account_Org__r.RecordType_DeveloperName__c, tempAcc2.Account_Org__c);
|
}
|
// SWAG-BQ75WE update by vivek 2020/26/11 end
|
}
|
// SWAG-BD24SU 额外检索一些新东西 end
|
for (Account2__c acc2 : acc2List2) {
|
String dcid = acc2.Account_Org__c;
|
Account2__c acc = new Account2__c(Id = acc2.Id);
|
initAccountCount(acc, targetmonth);
|
// 2018/08/24 SWAG-B3U67F 获取战略科室的提案书情况 存至客户2中 start
|
|
if (proposalDocumentMap_dept.containsKey(dcid)) {
|
acc.Proposal_Submit_Status_Dept__c =
|
(proposalDocumentMap_dept.get(dcid).get('Proposal_Submit_Status') == null ? 0 : (Decimal) proposalDocumentMap_dept.get(dcid).get('Proposal_Submit_Status'))
|
+ (proposalDocumentMap_dept.get(dcid).get('Quarterly_Submit_Status') == null ? 0 : (Decimal) proposalDocumentMap_dept.get(dcid).get('Quarterly_Submit_Status'));
|
}
|
|
// 2018/08/24 SWAG-B3U67F 获取战略科室的提案书情况 存至客户2中 end
|
if (dc_repairMap.containsKey(dcid)) {
|
acc.AVG_Elapsed_day_from_Repair__c += dc_repairMap.get(dcid).get('avg_Repair') == null ? 0 : Decimal.valueOf(String.valueOf(dc_repairMap.get(dcid).get('avg_Repair')));
|
acc.AVG_Elapsed_day_from_Repair2__c += dc_repairMap.get(dcid).get('avg_Repair2') == null ? 0 : Decimal.valueOf(String.valueOf(dc_repairMap.get(dcid).get('avg_Repair2')));
|
acc.SUM_Repair_List_Price__c += dc_repairMap.get(dcid).get('sum_Price') == null ? 0 : Decimal.valueOf(String.valueOf(dc_repairMap.get(dcid).get('sum_Price')));
|
acc.SUM_Repair_Billing_Amount__c += dc_repairMap.get(dcid).get('sum_Billing') == null ? 0 : Decimal.valueOf(String.valueOf(dc_repairMap.get(dcid).get('sum_Billing')));
|
}
|
if (dc_repair_LY_Map.containsKey(dcid)) {
|
acc.AVG_Elapsed_day_from_Repair_Lastyear__c += dc_repair_LY_Map.get(dcid).get('avg_Repair') == null ? 0 : Decimal.valueOf(String.valueOf(dc_repair_LY_Map.get(dcid).get('avg_Repair')));
|
acc.AVG_Elapsed_day_from_Repair2_Lastyear__c += dc_repair_LY_Map.get(dcid).get('avg_Repair2') == null ? 0 : Decimal.valueOf(String.valueOf(dc_repair_LY_Map.get(dcid).get('avg_Repair2')));
|
acc.SUM_Repair_List_Price_Lastyear__c += dc_repair_LY_Map.get(dcid).get('sum_Price') == null ? 0 : Decimal.valueOf(String.valueOf(dc_repair_LY_Map.get(dcid).get('sum_Price')));
|
acc.SUM_Repair_Billing_Amount_Lastyear__c += dc_repair_LY_Map.get(dcid).get('sum_Billing') == null ? 0 : Decimal.valueOf(String.valueOf(dc_repair_LY_Map.get(dcid).get('sum_Billing')));
|
}
|
if (dc_unpaidMap.containsKey(dcid)) {
|
acc.SUM_Unpaid_Amount__c += dc_unpaidMap.get(dcid).get('sum_Unpaid') == null ? 0 : Decimal.valueOf(String.valueOf(dc_unpaidMap.get(dcid).get('sum_Unpaid')));
|
}
|
if (dc_mContractMap.containsKey(dcid)) {
|
acc.Service_contract_active_number_HP__c += Integer.valueOf(dc_mContractMap.get(dcid).get('Cnt_Id'));
|
}
|
updateAccount.put(dcid, acc);
|
}
|
// 战略科室下的保有设备(按照重点产品区分) SWAG-BSC5WP you-20201021 start
|
for (Asset aggAst : [
|
select Department_Class__c, Product2.Key_product_147P__c,Product2Id
|
from Asset
|
where Status <> '廃棄' and Asset_Owner__c ='病院資産'
|
and Department_Class__c in : dcListMap.keySet() and Department_Class__c !=null
|
and Product2.Key_product_147P__c <> ''
|
]) {
|
Id dcid = (Id) aggAst.Department_Class__c; //战略科室id
|
Account2__c acc = updateAccount.get(dcid); //战略科室对应得 客户2
|
String tmpKey = '';
|
String tempKeyProduct = String.valueOf(aggAst.Product2.Key_product_147P__c);//重点产品区分
|
if(tempKeyProduct != null&&String.isNotBlank(tempKeyProduct)){
|
tmpKey = tempKeyProduct.substring(0,2);
|
}
|
system.debug('战略科室id:' + dcid + '==产品id=' + aggAst.Product2Id+'===重点产品区分 =='+tempKeyProduct+'==acc=='+acc);
|
if(acc!=null){
|
setAssetCount(acc, tmpKey, 1, OldAccount2, depToOtherDepAcc2Map , updateAccount);
|
|
}
|
|
}
|
//SWAG-BSC5WP you-20201021 end
|
// 资产 按 分类
|
for (AggregateResult aggAst : [
|
select Count(Id) Cnt_Id, Hospital__c, Department_Class__r.Department_Class_Label__c, Product2.Category3__c, Product2.Category4__c , Product2.Category5__c
|
from Asset
|
where Status = '使用中'
|
and Department_Class__c != null
|
and Hospital__c in : hpList
|
group by Hospital__c, Department_Class__r.Department_Class_Label__c, Product2.Category3__c, Product2.Category4__c , Product2.Category5__c
|
]) {
|
Id hpid = (Id) aggAst.get('Hospital__c');
|
Account2__c acc = updateAccount.get(hpid);
|
String strDCL = aggAst.get('Department_Class_Label__c') == null ? '' : String.valueOf(aggAst.get('Department_Class_Label__c'));
|
String strC3 = aggAst.get('Category3__c') == null ? '' : String.valueOf(aggAst.get('Category3__c'));
|
String strC4 = aggAst.get('Category4__c') == null ? '' : String.valueOf(aggAst.get('Category4__c'));
|
String strC5 = aggAst.get('Category5__c') == null ? '' : String.valueOf(aggAst.get('Category5__c'));
|
Integer cntId = Integer.valueOf(aggAst.get('Cnt_Id'));
|
setAssetCategoryCount(acc, strDCL, strC3, strC4, strC5, cntId);
|
}
|
|
// 资产 按 ProductCode
|
for (AggregateResult aggPcode : [
|
select Count(Id) Cnt_Id, Hospital__c, Product2.ProductCode
|
from Asset
|
where Status = '使用中'
|
and Product2.ProductCode in ('N4491360', 'WB91051C')
|
and Hospital__c in : hpList
|
group by Hospital__c, Product2.ProductCode
|
]) {
|
Id hpid = (Id) aggPcode.get('Hospital__c');
|
Account2__c acc = updateAccount.get(hpid);
|
String strPcode = aggPcode.get('ProductCode') == null ? '' : String.valueOf(aggPcode.get('ProductCode'));
|
Integer cntId = Integer.valueOf(aggPcode.get('Cnt_Id'));
|
setAssetPcodeCount(acc, strPcode, cntId);
|
}
|
|
//报告一览 按 月份 按照医院
|
//SWAG-BBBAKG之前的逻辑为 各个本部(包括能量)的数据都按照月累计,只区分销售推广和 销售服务(FSE)
|
/*for (AggregateResult aggEvent : [
|
select Count(Id) Cnt_Id, Account_ID__r.Parent.ParentId HPID, ActivityDate__c, Reporter_Job_Category__c
|
from Event__c
|
where Daily_Report__r.Status_With_Check__c <> '草案中'
|
and Daily_Report__r.Status_With_Check__c <> ''
|
and Account_ID__r.Parent.ParentId in : hplist
|
and ActivityDate__c >= : sDate
|
and ActivityDate__c < : eDate
|
and Reporter_Job_Category__c in ('销售推广', '销售服务')
|
group by Account_ID__r.Parent.ParentId, ActivityDate__c, Reporter_Job_Category__c
|
]) {
|
Id hpid = (Id) aggEvent.get('HPID');
|
Account2__c acc = updateAccount.get(hpid);
|
Integer iMonth = aggEvent.get('ActivityDate__c') == null ? 0 : Date.valueOf(aggEvent.get('ActivityDate__c')).month();
|
Integer cntId = Integer.valueOf(aggEvent.get('Cnt_Id'));
|
String job_Category = (String) aggEvent.get('Reporter_Job_Category__c');
|
setEventCount(acc, iMonth, cntId, job_Category);
|
}*/
|
|
/* SWAG-BBBAKG新逻辑为 销售服务(FSE)保持不变,
|
* 原销售推广按照六个本部(华东、华北之类)按月累计(排除能量本部);
|
* 对于能量本部,销售推广和销售市场统合起来按照月统计
|
*/
|
//销售服务(FSE)
|
for (AggregateResult aggEvent : [
|
select Count(Id) Cnt_Id, Account_ID__r.Parent.ParentId HPID, ActivityDate__c, Reporter_Job_Category__c
|
from Event__c
|
where Daily_Report__r.Status_With_Check__c <> '草案中'
|
and Daily_Report__r.Status_With_Check__c <> ''
|
and Account_ID__r.Parent.ParentId in : hplist
|
and ActivityDate__c >= : sDate
|
and ActivityDate__c < : eDate
|
and Reporter_Job_Category__c in ('销售服务')
|
and Daily_Report__r.Submit_OnTime_Count__c = 1
|
group by Account_ID__r.Parent.ParentId, ActivityDate__c, Reporter_Job_Category__c
|
]) {
|
Id hpid = (Id) aggEvent.get('HPID');
|
Account2__c acc = updateAccount.get(hpid);
|
Integer iMonth = aggEvent.get('ActivityDate__c') == null ? 0 : Date.valueOf(aggEvent.get('ActivityDate__c')).month();
|
Integer cntId = Integer.valueOf(aggEvent.get('Cnt_Id'));
|
String job_Category = (String) aggEvent.get('Reporter_Job_Category__c');
|
setEventCount(acc, iMonth, cntId, job_Category);
|
}
|
// 六个本部 销售推广
|
for (AggregateResult aggEvent : [
|
select Count(Id) Cnt_Id, Account_ID__r.Parent.ParentId HPID, ActivityDate__c, Reporter_Job_Category__c
|
from Event__c
|
where Daily_Report__r.Status_With_Check__c <> '草案中'
|
and Daily_Report__r.Status_With_Check__c <> ''
|
and Account_ID__r.Parent.ParentId in : hplist
|
and ActivityDate__c >= : sDate
|
and ActivityDate__c < : eDate
|
and Reporter_Job_Category__c in ('销售推广')
|
and Reporter_Dept__c in('医疗东北营业本部', '医疗华北营业本部',
|
'医疗华东营业本部', '医疗华南营业本部', '医疗西北营业本部', '医疗西南营业本部')
|
and Daily_Report__r.Submit_OnTime_Count__c = 1
|
group by Account_ID__r.Parent.ParentId, ActivityDate__c, Reporter_Job_Category__c
|
]) {
|
Id hpid = (Id) aggEvent.get('HPID');
|
Account2__c acc = updateAccount.get(hpid);
|
Integer iMonth = aggEvent.get('ActivityDate__c') == null ? 0 : Date.valueOf(aggEvent.get('ActivityDate__c')).month();
|
Integer cntId = Integer.valueOf(aggEvent.get('Cnt_Id'));
|
String job_Category = (String) aggEvent.get('Reporter_Job_Category__c');
|
setEventCount(acc, iMonth, cntId, job_Category);
|
}
|
// 能量本部 销售推广 销售市场
|
for (AggregateResult aggEvent : [
|
select Count(Id) Cnt_Id, Account_ID__r.Parent.ParentId HPID, ActivityDate__c, Reporter_Job_Category__c
|
from Event__c
|
where Daily_Report__r.Status_With_Check__c <> '草案中'
|
and Daily_Report__r.Status_With_Check__c <> ''
|
and Account_ID__r.Parent.ParentId in : hplist
|
and ActivityDate__c >= : sDate
|
and ActivityDate__c < : eDate
|
and Reporter_Job_Category__c in ('销售推广', '销售市场')
|
// LHJ 202006 恢复 Start
|
and ((Reporter_Product_specialist_incharge_pro__c = 'ENG'
|
or Reporter_Product_specialist_incharge_pro__c = 'SP(兼ENG)'
|
or Reporter_Product_specialist_incharge_pro__c = 'ALL(兼ENG/ET)'
|
or (Reporter_Product_specialist_incharge_pro__c = 'SP'
|
and Reporter_Post__c in ('经理','副经理')))
|
//2021.6.29新增负责产品(兼)逻辑
|
or
|
(Responsible_for_Products_Concurrently__c = 'ENG'
|
or Responsible_for_Products_Concurrently__c = 'ENG/ET'
|
or (Responsible_for_Products_Concurrently__c = 'SP'
|
and Reporter_Post__c in ('经理','副经理')))
|
)
|
//and Reporter_Dept__c = '能量事业本部'
|
// LHJ 202006 恢复 End
|
and Daily_Report__r.Submit_OnTime_Count__c = 1
|
group by Account_ID__r.Parent.ParentId, ActivityDate__c, Reporter_Job_Category__c
|
]) {
|
Id hpid = (Id) aggEvent.get('HPID');
|
Account2__c acc = updateAccount.get(hpid);
|
Integer iMonth = aggEvent.get('ActivityDate__c') == null ? 0 : Date.valueOf(aggEvent.get('ActivityDate__c')).month();
|
Integer cntId = Integer.valueOf(aggEvent.get('Cnt_Id'));
|
setEventCount_Eng(acc, iMonth, cntId);
|
}
|
// SWAG-BBBAKG end
|
|
// 资产 按 分类
|
for (AggregateResult aggAst : [
|
select Count(Id) Cnt_Id, Department_Class__c, Product2.Category3__c, Product2.Category4__c , Product2.Category5__c
|
from Asset
|
where Status = '使用中'
|
and Department_Class__c in : dcListMap.keySet()
|
group by Department_Class__c, Product2.Category3__c, Product2.Category4__c , Product2.Category5__c
|
]) {
|
Id dcid = (Id) aggAst.get('Department_Class__c');
|
Account2__c acc = updateAccount.get(dcid);
|
String strDCL = dcListMap.get(dcid).Department_Class_Label__c;
|
String strC3 = aggAst.get('Category3__c') == null ? '' : String.valueOf(aggAst.get('Category3__c'));
|
String strC4 = aggAst.get('Category4__c') == null ? '' : String.valueOf(aggAst.get('Category4__c'));
|
String strC5 = aggAst.get('Category5__c') == null ? '' : String.valueOf(aggAst.get('Category5__c'));
|
Integer cntId = Integer.valueOf(aggAst.get('Cnt_Id'));
|
setAssetCategoryCount(acc, strDCL, strC3, strC4, strC5, cntId);
|
}
|
|
// 资产 按 ProductCode
|
for (AggregateResult aggPcode : [
|
select Count(Id) Cnt_Id, Department_Class__c, Product2.ProductCode
|
from Asset
|
where Status = '使用中'
|
and Product2.ProductCode in ('N4491360', 'WB91051C')
|
and Department_Class__c in : dcListMap.keySet()
|
group by Department_Class__c, Product2.ProductCode
|
]) {
|
Id dcid = (Id) aggPcode.get('Department_Class__c');
|
Account2__c acc = updateAccount.get(dcid);
|
String strPcode = aggPcode.get('ProductCode') == null ? '' : String.valueOf(aggPcode.get('ProductCode'));
|
Integer cntId = Integer.valueOf(aggPcode.get('Cnt_Id'));
|
setAssetPcodeCount(acc, strPcode, cntId);
|
}
|
// 报告一览 按 月份 按照战略科室
|
//SWAG-BBBAKG之前的逻辑为 各个本部(包括能量)的数据都按照月累计,只区分销售推广和 销售服务(FSE)
|
/*
|
for (AggregateResult aggEvent : [
|
select Count(Id) Cnt_Id, Account_ID__r.ParentId DCID, ActivityDate__c, Reporter_Job_Category__c
|
from Event__c
|
where Daily_Report__r.Status_With_Check__c <> '草案中'
|
and Daily_Report__r.Status_With_Check__c <> ''
|
and Account_ID__r.ParentId in : dcListMap.keySet()
|
and ActivityDate__c >= : sDate
|
and ActivityDate__c < : eDate
|
and Reporter_Job_Category__c in ('销售推广', '销售服务')
|
group by Account_ID__r.ParentId, ActivityDate__c, Reporter_Job_Category__c
|
]) {
|
Id dcid = (Id) aggEvent.get('DCID');
|
Account2__c acc = updateAccount.get(dcid);
|
Integer iMonth = aggEvent.get('ActivityDate__c') == null ? 0 : Date.valueOf(aggEvent.get('ActivityDate__c')).month();
|
Integer cntId = Integer.valueOf(aggEvent.get('Cnt_Id'));
|
String job_Category = (String) aggEvent.get('Reporter_Job_Category__c');
|
setEventCount(acc, iMonth, cntId, job_Category);
|
}
|
*/
|
|
/* SWAG-BBBAKG新逻辑为 销售服务(FSE)保持不变,
|
* 原销售推广按照六个本部(华东、华北之类)按月累计(排除能量本部);
|
* 对于能量本部,销售推广和销售市场统合起来按照月统计
|
*/
|
|
//销售服务(FSE)
|
for (AggregateResult aggEvent : [
|
select Count(Id) Cnt_Id, Account_ID__r.ParentId DCID, ActivityDate__c, Reporter_Job_Category__c
|
from Event__c
|
where Daily_Report__r.Status_With_Check__c <> '草案中'
|
and Daily_Report__r.Status_With_Check__c <> ''
|
and Account_ID__r.ParentId in : dcListMap.keySet()
|
and ActivityDate__c >= : sDate
|
and ActivityDate__c < : eDate
|
and Reporter_Job_Category__c = '销售服务'
|
and Daily_Report__r.Submit_OnTime_Count__c = 1
|
group by Account_ID__r.ParentId, ActivityDate__c, Reporter_Job_Category__c
|
]) {
|
Id dcid = (Id) aggEvent.get('DCID');
|
Account2__c acc = updateAccount.get(dcid);
|
Integer iMonth = aggEvent.get('ActivityDate__c') == null ? 0 : Date.valueOf(aggEvent.get('ActivityDate__c')).month();
|
Integer cntId = Integer.valueOf(aggEvent.get('Cnt_Id'));
|
String job_Category = (String) aggEvent.get('Reporter_Job_Category__c');
|
setEventCount(acc, iMonth, cntId, job_Category);
|
}
|
// 六个本部 销售推广
|
for (AggregateResult aggEvent : [
|
select Count(Id) Cnt_Id, Account_ID__r.ParentId DCID, ActivityDate__c, Reporter_Job_Category__c
|
from Event__c
|
where Daily_Report__r.Status_With_Check__c <> '草案中'
|
and Daily_Report__r.Status_With_Check__c <> ''
|
and Account_ID__r.ParentId in : dcListMap.keySet()
|
and ActivityDate__c >= : sDate
|
and ActivityDate__c < : eDate
|
and Reporter_Job_Category__c in ('销售推广')
|
and Reporter_Dept__c in('医疗东北营业本部', '医疗华北营业本部',
|
'医疗华东营业本部', '医疗华南营业本部', '医疗西北营业本部', '医疗西南营业本部')
|
and Daily_Report__r.Submit_OnTime_Count__c = 1
|
group by Account_ID__r.ParentId, ActivityDate__c, Reporter_Job_Category__c
|
]) {
|
Id dcid = (Id) aggEvent.get('DCID');
|
Account2__c acc = updateAccount.get(dcid);
|
Integer iMonth = aggEvent.get('ActivityDate__c') == null ? 0 : Date.valueOf(aggEvent.get('ActivityDate__c')).month();
|
Integer cntId = Integer.valueOf(aggEvent.get('Cnt_Id'));
|
String job_Category = (String) aggEvent.get('Reporter_Job_Category__c');
|
setEventCount(acc, iMonth, cntId, job_Category);
|
}
|
// 能量本部 销售推广 销售市场
|
for (AggregateResult aggEvent : [
|
select Count(Id) Cnt_Id, Account_ID__r.ParentId DCID, ActivityDate__c, Reporter_Job_Category__c
|
from Event__c
|
where Daily_Report__r.Status_With_Check__c <> '草案中'
|
and Daily_Report__r.Status_With_Check__c <> ''
|
and Account_ID__r.ParentId in : dcListMap.keySet()
|
and ActivityDate__c >= : sDate
|
and ActivityDate__c < : eDate
|
and Reporter_Job_Category__c in ('销售推广', '销售市场')
|
// LHJ 20200624 恢复 Start
|
and ((Reporter_Product_specialist_incharge_pro__c = 'ENG'
|
or Reporter_Product_specialist_incharge_pro__c = 'SP(兼ENG)'
|
or Reporter_Product_specialist_incharge_pro__c = 'ALL(兼ENG/ET)'
|
or(Reporter_Product_specialist_incharge_pro__c = 'SP'
|
and Reporter_Post__c in ('经理','副经理')))
|
or
|
//2021.6.29 新增的逻辑 报告者・推进员工负责产品(兼)
|
(Responsible_for_Products_Concurrently__c = 'ENG'
|
or Responsible_for_Products_Concurrently__c = 'ENG/ET'
|
or (Responsible_for_Products_Concurrently__c = 'SP'
|
and Reporter_Post__c in ('经理','副经理'))
|
))
|
// and Reporter_Dept__c = '能量事业本部'
|
// LHJ 20200624 End
|
and Daily_Report__r.Submit_OnTime_Count__c = 1
|
group by Account_ID__r.ParentId, ActivityDate__c, Reporter_Job_Category__c
|
]) {
|
Id dcid = (Id) aggEvent.get('DCID');
|
Account2__c acc = updateAccount.get(dcid);
|
Integer iMonth = aggEvent.get('ActivityDate__c') == null ? 0 : Date.valueOf(aggEvent.get('ActivityDate__c')).month();
|
Integer cntId = Integer.valueOf(aggEvent.get('Cnt_Id'));
|
String job_Category = (String) aggEvent.get('Reporter_Job_Category__c');
|
setEventCount_Eng(acc, iMonth, cntId);
|
}
|
|
// SWAG-BBBAKG end
|
|
|
// 点检回数(按单据),点检回数(按设备)
|
// なぜか Inspection_Times__c 設定されない
|
List<AssetHistory__c> ahListFlag = new List<AssetHistory__c>();
|
List<AssetHistory__c> ahList0Flag = new List<AssetHistory__c>();
|
String breakInspection = '';
|
Boolean isUpdateFlag = true;
|
List<AssetHistory__c> ahs = [
|
select Inspection_report_number__c,
|
Inspection_Times__c,
|
Inspection_Count__c,
|
Inspection_Report__c,
|
Inspection_Report__r.Status__c,
|
AssetId__r.Hospital__c,
|
AssetId__r.Department_Class__c,
|
Examination_Date__c
|
from AssetHistory__c
|
where AssetId__r.Hospital__c in : hpList
|
and Field_Api_Name__c = 'Inspection_report_number__c'
|
and NewValue__c != null
|
and AssetId__r.Department_Class__c in : dcListMap.keySet()
|
and Examination_Date__c >= :sDay
|
and Examination_Date__c < :eDay
|
order by NewValue__c, Inspection_Times__c desc];
|
for (AssetHistory__c ah : ahs) {
|
System.debug('ah.Inspection_report_number__c=' + ah.Inspection_report_number__c);
|
if (ah.Inspection_Report__c != null && ah.Inspection_Report__r.Status__c == '草案中') {
|
if (ah.Inspection_Times__c == 1) {
|
ah.Inspection_Times__c = 0;
|
ahList0Flag.add(ah);
|
continue;
|
}
|
} else if (breakInspection != ah.Inspection_report_number__c) {
|
System.debug('breakInspection != ah.Inspection_report_number__c');
|
isUpdateFlag = true;
|
breakInspection = ah.Inspection_report_number__c;
|
if (ah.Inspection_Times__c != 1) {
|
ahListFlag.add(ah); // まずは処理対象
|
} else {
|
isUpdateFlag = false;
|
}
|
}
|
if (isUpdateFlag) {
|
if (ah.Inspection_Times__c == 1) {
|
isUpdateFlag = false;
|
System.debug('ah.Inspection_Times__c != 0');
|
ahListFlag.remove(ahListFlag.size() - 1);
|
}
|
}
|
}
|
if (ahListFlag.size() > 0 || ahList0Flag.size() > 0) {
|
for (AssetHistory__c ah : ahListFlag) {
|
ah.Inspection_Times__c = 1;
|
}
|
ahListFlag.addAll(ahList0Flag);
|
System.debug('ahListFlag.size()=' + ahListFlag.size());
|
update ahListFlag;
|
}
|
for (AssetHistory__c ah : ahs) {
|
if (ah.Inspection_Report__c != null && ah.Inspection_Report__r.Status__c == '草案中') {
|
continue;
|
}
|
Id hpid = ah.AssetId__r.Hospital__c;
|
Account2__c hpacc = updateAccount.get(hpid);
|
Id dcid = ah.AssetId__r.Department_Class__c;
|
Account2__c dcacc = updateAccount.get(dcid);
|
Decimal times = ah.Inspection_Times__c == null ? 0 : ah.Inspection_Times__c;
|
Decimal counts = ah.Inspection_Count__c == null ? 0 : ah.Inspection_Count__c;
|
Integer month = ah.Examination_Date__c.month();
|
setTimesAndCounts(hpacc, month, times, counts);
|
setTimesAndCounts(dcacc, month, times, counts);
|
}
|
|
// opp RankTax
|
// convertCurrencyにて、SFのレート使う(カスタム項目のレートを使うべき?)
|
|
for (Opportunity opp : [
|
select convertCurrency(RANK_A_inc_tax__c), convertCurrency(RANK_B_inc_tax__c), convertCurrency(RANK_C_inc_tax__c),
|
convertCurrency(RANK_D_inc_tax__c), convertCurrency(RANK_E_inc_tax__c),
|
Today_Rate__c, Trade__c, convertCurrency(Forecast_Amount_All_F__c), convertCurrency(ShippedAmount__c),
|
Opp_Actual_ThousandY__c, BO_Forecast_ThousandY__c,
|
OP_ThousandY__c, Opp_Forecast_ThousandY__c,
|
//Opportunity_ThousandY__c, //lt 20220318 注释
|
Amount_Without_Tax_Thousand_F__c,
|
Hospital__c, Department_Class__c
|
, OCSM_RMB_Without_Tax_1000TR__c//20220111 SWAG-C8MBB6 加7.询价 lt
|
from Opportunity
|
where Hospital__c in :hpList
|
]) {
|
|
Id hpid = opp.Hospital__c;
|
Account2__c hpacc = updateAccount.get(hpid);
|
Id dcid = opp.Department_Class__c;
|
Account2__c dcacc = updateAccount.get(dcid);
|
|
Decimal a1 = opp.RANK_A_inc_tax__c == null ? 0 : opp.RANK_A_inc_tax__c;
|
Decimal a2 = opp.RANK_B_inc_tax__c == null ? 0 : opp.RANK_B_inc_tax__c;
|
Decimal a3 = opp.RANK_C_inc_tax__c == null ? 0 : opp.RANK_C_inc_tax__c;
|
Decimal a4 = opp.RANK_D_inc_tax__c == null ? 0 : opp.RANK_D_inc_tax__c;
|
Decimal a5 = opp.RANK_E_inc_tax__c == null ? 0 : opp.RANK_E_inc_tax__c;
|
Decimal fa = opp.Forecast_Amount_All_F__c == null ? 0 : opp.Forecast_Amount_All_F__c;
|
Decimal sa = opp.ShippedAmount__c == null ? 0 : opp.ShippedAmount__c;
|
setRankTaxCount(hpacc, a1, a2, a3, a4, a5, fa, sa);
|
setRankTaxCount(dcacc, a1, a2, a3, a4, a5, fa, sa);
|
|
Decimal o1 = opp.Opp_Actual_ThousandY__c == null ? 0 : opp.Opp_Actual_ThousandY__c;
|
Decimal o2 = opp.BO_Forecast_ThousandY__c == null ? 0 : opp.BO_Forecast_ThousandY__c;
|
Decimal o3 = opp.OP_ThousandY__c == null ? 0 : opp.OP_ThousandY__c;
|
Decimal o4 = opp.Opp_Forecast_ThousandY__c == null ? 0 : opp.Opp_Forecast_ThousandY__c;
|
//Decimal o5 = opp.Opportunity_ThousandY__c == null ? 0 : opp.Opportunity_ThousandY__c;//lt 20220318 注释
|
//lt 20220318 start
|
Decimal o5 = 0 ;
|
//lt 20220318 start
|
Decimal o6 = opp.Amount_Without_Tax_Thousand_F__c == null ? 0 : opp.Amount_Without_Tax_Thousand_F__c;
|
//20220111 SWAG-C8MBB6 加7.询价 lt start
|
Decimal o7 = opp.OCSM_RMB_Without_Tax_1000TR__c == null ? 0 : opp.OCSM_RMB_Without_Tax_1000TR__c;
|
//20220111 SWAG-C8MBB6 加7.询价 lt end
|
setOppAmount(hpacc, o1, o2, o3, o4, o5, o6, o7);
|
setOppAmount(dcacc, o1, o2, o3, o4, o5, o6, o7);
|
}
|
|
// 报告书
|
for (Report__c report : [
|
select Id, Hospital_Reference__c, Department_Class_Ref__c, Date__c, RecordType.DeveloperName,
|
CDS_training_report_check__c, Reporter_Job_Category__c,
|
Important_product1__c, Important_product2__c, Important_product3__c, Important_product4__c, Important_product5__c,
|
Important_product6__c, Important_product7__c, Important_product8__c, Important_product9__c, Important_product10__c,
|
Important_product11__c, Important_product12__c, Important_product13__c, Important_product14__c, Important_product15__c,
|
Important_product16__c, Important_product17__c, Important_product18__c, Important_product19__c, Important_product20__c
|
from Report__c
|
where RecordType.DeveloperName in ('OPD', 'NTC')
|
and Status__c <> '作成中' and Status__c <> '取消し' and Status__c <> ''
|
and Date__c >= : sDate // and Date__c >= : thisYd
|
and Date__c < : nextYd
|
and Hospital_Reference__c in : hpList
|
and Department_Class_Ref__c in : dcListMap.values()
|
]) {
|
Id hpid = report.Hospital_Reference__c;
|
Account2__c hpacc = updateAccount.get(hpid);
|
Id dcid = report.Department_Class_Ref__c;
|
Account2__c dcacc = updateAccount.get(dcid);
|
String developerName = report.RecordType.DeveloperName;
|
// 重点产品OPD次数、年度単位
|
if (report.Date__c >= thisYd && developerName == 'OPD') {
|
Decimal decIP1 = report.Important_product1__c;
|
Decimal decIP2 = report.Important_product2__c;
|
Decimal decIP3 = report.Important_product3__c;
|
Decimal decIP4 = report.Important_product4__c;
|
Decimal decIP5 = report.Important_product5__c;
|
Decimal decIP6 = report.Important_product6__c;
|
Decimal decIP7 = report.Important_product7__c;
|
Decimal decIP8 = report.Important_product8__c;
|
Decimal decIP9 = report.Important_product9__c;
|
Decimal decIP10 = report.Important_product10__c;
|
Decimal decIP11 = report.Important_product11__c;
|
Decimal decIP12 = report.Important_product12__c;
|
Decimal decIP13 = report.Important_product13__c;
|
Decimal decIP14 = report.Important_product14__c;
|
Decimal decIP15 = report.Important_product15__c;
|
Decimal decIP16 = report.Important_product16__c;
|
Decimal decIP17 = report.Important_product17__c;
|
Decimal decIP18 = report.Important_product18__c;
|
Decimal decIP19 = report.Important_product19__c;
|
Decimal decIP20 = report.Important_product20__c;
|
setOpdIproductCount(hpacc, decIP1, decIP2, decIP3, decIP4, decIP5, decIP6, decIP7, decIP8, decIP9, decIP10,
|
decIP11, decIP12, decIP13, decIP14, decIP15, decIP16, decIP17, decIP18, decIP19, decIP20);
|
setOpdIproductCount(dcacc, decIP1, decIP2, decIP3, decIP4, decIP5, decIP6, decIP7, decIP8, decIP9, decIP10,
|
decIP11, decIP12, decIP13, decIP14, decIP15, decIP16, decIP17, decIP18, decIP19, decIP20);
|
}
|
// 十二肠镜CDS培训次数、年度単位
|
if (report.Date__c >= thisYd && developerName == 'NTC') {
|
Decimal cds = report.CDS_training_report_check__c;
|
setNtcCdsCount(hpacc, cds);
|
setNtcCdsCount(dcacc, cds);
|
}
|
// OPD,NTC回数、12月、回すタイプの集計
|
if (report.Date__c < eDate) {
|
Integer iMonth = report.Date__c.month();
|
String job_Category = report.Reporter_Job_Category__c;
|
setDoCount(hpacc, iMonth, developerName, job_Category);
|
setDoCount(dcacc, iMonth, developerName, job_Category);
|
}
|
}
|
|
// SWAG-BQ75WE 20200620 LHJ Start
|
// for (Report__c report : [
|
// select Id, Hospital_Reference__c, Department_Class_Ref__c, RecordType.DeveloperName,
|
// OPD_ProductCategory1__c, OPD_ProductCategory2__c, Date__c
|
// from Report__c
|
// where RecordType.DeveloperName in ('OPD', 'SIS')
|
// and Status__c in ('批准', '提交')
|
// and Date__c >= : lastYd
|
// and Date__c < : nextYd
|
// //and Hospital_Reference__c in : hpList
|
// and Department_Class_Ref__c in : dcListMap.values()
|
// ]) {
|
// Id dcid = report.Department_Class_Ref__c;
|
//Account2__c acc = updateAccount.get(dcid);
|
//Date date_c = report.Date__c;
|
//String productCategory1 = report.OPD_ProductCategory1__c;
|
//String productCategory2 = report.OPD_ProductCategory2__c;
|
// if (date_c >= lastYd && date_c < thisYd) {
|
// if (productCategory1 == '3D System' || productCategory2 == '3D System') {
|
// acc.OPD_3D_pre__c += 1;
|
// }
|
// // SWAG-BC832V 保存至客户2 不使用:OPD数(上期):CYF start
|
// if (productCategory1 == 'CYF' || productCategory2 == 'CYF') {
|
// acc.OPD_CYF_pre__c += 1;
|
// }
|
// // SWAG-BC832V 保存至客户2 不使用:OPD数(上期):CYF end
|
// if (productCategory1 == 'NBI-170' || productCategory2 == 'NBI-170') {
|
// acc.OPD_CV_170_pre__c += 1;
|
// }
|
// if (productCategory1 == 'OR Imaging Products' || productCategory2 == 'OR Imaging Products') {
|
// acc.OPD_CV_190_pre__c += 1;
|
// }
|
// if (productCategory1 == 'NBI-290' || productCategory2 == 'NBI-290') {
|
// acc.OPD_CV_290_pre__c += 1;
|
// }
|
// if (productCategory1 == 'EUS' || productCategory2 == 'EUS' || productCategory1 == 'EBUS' || productCategory2 == 'EBUS') {
|
// acc.OPD_EU_ME2_pre__c += 1;
|
// }
|
// if (productCategory1 == 'OTV-S190' || productCategory2 == 'OTV-S190') {
|
// acc.OPD_OTV_S190_pre__c += 1;
|
// }
|
// if (productCategory1 == 'STMS' || productCategory2 == 'STMS') {
|
// acc.OPD_STMS_pre__c += 1;
|
// }
|
// if (productCategory1 == 'ERCP(含导丝)' || productCategory2 == 'ERCP(含导丝)') {
|
// acc.OPD_GW_pre__c += 1;
|
// }
|
// } else if (date_c >= thisYd && date_c < nextYd) {
|
// if (productCategory1 == '3D System' || productCategory2 == '3D System') {
|
// acc.OPD_3D__c += 1;
|
// }
|
// // SWAG-BC832V 保存至客户2 不使用:OPD数(本期):CYF start
|
// if (productCategory1 == 'CYF' || productCategory2 == 'CYF') {
|
// acc.OPD_CYF__c += 1;
|
// }
|
// // SWAG-BC832V 保存至客户2 不使用:OPD数(本期):CYF end
|
// if (productCategory1 == 'NBI-170' || productCategory2 == 'NBI-170') {
|
// acc.OPD_CV_170__c += 1;
|
// }
|
// if (productCategory1 == 'OR Imaging Products' || productCategory2 == 'OR Imaging Products') {
|
// acc.OPD_CV_190__c += 1;
|
// }
|
// if (productCategory1 == 'NBI-290' || productCategory2 == 'NBI-290') {
|
// acc.OPD_CV_290__c += 1;
|
// }
|
// if (productCategory1 == 'EUS' || productCategory2 == 'EUS' || productCategory1 == 'EBUS' || productCategory2 == 'EBUS') {
|
// acc.OPD_EU_ME2__c += 1;
|
// }
|
// if (productCategory1 == 'OTV-S190' || productCategory2 == 'OTV-S190') {
|
// acc.OPD_OTV_S190__c += 1;
|
// }
|
// if (productCategory1 == 'STMS' || productCategory2 == 'STMS') {
|
// acc.OPD_STMS__c += 1;
|
// }
|
// if (productCategory1 == 'ERCP(含导丝)' || productCategory2 == 'ERCP(含导丝)') {
|
// acc.OPD_GW__c += 1;
|
// }
|
// if (productCategory1 == 'OER-AW' || productCategory2 == 'OER-AW') {
|
// acc.OPD_OER_AW__c += 1;
|
// }
|
// if (productCategory1 == 'OTV-S400' || productCategory2 == 'OTV-S400') {
|
// acc.OPD_OTV_S400__c += 1;
|
// }
|
// if (productCategory1 == 'CH-S400-XZ' || productCategory2 == 'CH-S400-XZ') {
|
// acc.OPD_CH_S400_XZ__c += 1;
|
// }
|
// if (productCategory1 == 'UCES-3' || productCategory2 == 'UCES-3') {
|
// acc.OPD_UCES_3__c += 1;
|
// }
|
// }
|
//}
|
for (Report__c report : [
|
select Id, Hospital_Reference__c, Department_Class_Ref__c, RecordType.DeveloperName,
|
OPD_ProductCategory1__c, OPD_ProductCategory2__c, Date__c,
|
Important_product1__c, Important_product2__c, Important_product3__c, Important_product4__c, Important_product5__c,
|
Important_product6__c, Important_product7__c, Important_product8__c, Important_product9__c, Important_product10__c,
|
Important_product11__c, Important_product12__c, Important_product13__c, Important_product14__c, Important_product15__c,
|
Important_product16__c, Important_product17__c, Important_product18__c, Important_product19__c, Important_product20__c,
|
Important_product21__c, Important_product22__c, Important_product23__c, Important_product24__c, Important_product25__c,
|
Important_product26__c, Important_product27__c, Important_product28__c, Important_product29__c, Important_product30__c
|
from Report__c
|
where RecordType.DeveloperName in ('OPD', 'SIS')
|
and Status__c in ('批准', '提交')
|
and Inportant_Product_total__c = 1
|
and Date__c >= : thisYd
|
and Date__c < : nextYd
|
and Department_Class_Ref__c in : dcListMap.values()
|
]) {
|
Id dcid = report.Department_Class_Ref__c;
|
Account2__c dcacc = updateAccount.get(dcid);
|
|
// String tmpKey = '';
|
List<String> tempKeyList =new List<String>();
|
for (Integer i = 1; i <= 30; i++) {
|
if (report.get('Important_product' + i + '__c') == 1) {
|
tempKeyList.add(String.ValueOf(i));
|
}
|
}
|
for (Integer i = 0; i < tempKeyList.size(); i++) {
|
System.debug('======0623======dcid='+ dcid);
|
System.debug('======0623======i='+ i);
|
setOpdCount(dcacc, tempKeyList[i], 1, OldAccount2, depToOtherDepAcc2Map , updateAccount);
|
}
|
}
|
// LHJ SWAG-BQ75WE 20200620 End
|
|
// 医療従事者 TTC参加次数,HCP
|
for (Contact cont : [
|
select Id, Number_of_participant_for_TTC__c, HCP__c, Strategic_dept_Class__r.ParentId, Strategic_dept_Class__c
|
from Contact
|
where Strategic_dept_Class__r.ParentId in : hpList
|
and Strategic_dept_Class__c in : dcListMap.values()
|
]) {
|
Id hpid = cont.Strategic_dept_Class__r.ParentId;
|
Account2__c hpacc = updateAccount.get(hpid);
|
Id dcid = cont.Strategic_dept_Class__c;
|
Account2__c dcacc = updateAccount.get(dcid);
|
Decimal decTTc = cont.Number_of_participant_for_TTC__c == null ? 0 : cont.Number_of_participant_for_TTC__c;
|
String strHCP = cont.HCP__c == null ? '' : cont.HCP__c;
|
setContactCount(hpacc, decTTc, strHCP);
|
setContactCount(dcacc, decTTc, strHCP);
|
}
|
|
// SWAG-BD24SU 检索对应的保有设备,赋值到战略科室的客户2对应的发货数 start
|
for (Asset Ast : [
|
select Id, Department_Class__c,
|
Important_product1__c, Important_product2__c,
|
Important_product3__c, Important_product4__c,
|
Important_product5__c, Important_product6__c,
|
Important_product7__c, Important_product8__c,
|
Important_product9__c, Important_product10__c,
|
Important_product11__c, Important_product12__c,
|
Important_product13__c, Important_product14__c,
|
Important_product15__c, Important_product16__c,
|
Important_product17__c, Important_product18__c,
|
Important_product19__c, Important_product20__c,
|
Important_product21__c, Important_product22__c,
|
Important_product23__c, Important_product24__c,
|
Important_product25__c, Important_product26__c,
|
Important_product27__c, Important_product28__c,
|
Important_product29__c, Important_product30__c
|
// WLIG-BTNDLX start
|
, AssetPacking_list__c
|
//WLIG-BTNDLX end
|
//WLIG-BXT9DQ 【委托】【重要】目标客户统计中的“发货数”需求 精琢技术 2021/02/26 start
|
,Shipping_Finished_Day_Func__c
|
//WLIG-BXT9DQ 【委托】【重要】目标客户统计中的“发货数”需求 精琢技术 2021/02/26 end
|
from Asset
|
//注释原逻辑 替换为询价上的20.最新发货日 start
|
//WLIG-BXT9DQ 【委托】【重要】目标客户统计中的“发货数”需求 精琢技术 2021/02/26 start
|
//SWAG-C66D25 恢复为发货日,另外增加手工除外的条件 Start
|
where Product2.Important_product__c = true
|
and Posting_Date__c
|
>= :thisYd
|
and Posting_Date__c < :nextYd
|
and Department_Class__c in : dcListMap.values()
|
and RecordTypeID__c = '01210000000kOPMAA2'
|
and Account.parent.parent.Management_Code__c != '9999999'
|
and Information_From__c != '手动输入'
|
// where Product2.Important_product__c = true
|
// and Shipping_Finished_Day_Func__c
|
// >= :thisYd
|
// and Shipping_Finished_Day_Func__c < :nextYd
|
// and Department_Class__c in : dcListMap.values()
|
// and RecordTypeID__c = '01210000000kOPMAA2'
|
// and Account.parent.parent.Management_Code__c != '9999999'
|
//注释原逻辑 替换为询价上的20.最新发货日 end
|
////SWAG-C66D25 恢复为发货日,另外增加手工除外的条件 End
|
//WLIG-BXT9DQ 【委托】【重要】目标客户统计中的“发货数”需求 精琢技术 2021/02/26 end
|
|
]) {
|
Id dcid = Ast.Department_Class__c;
|
Account2__c dcacc = updateAccount.get(dcid);
|
|
String tmpKey = '';
|
// WLIG-BTNDLX start
|
Decimal tmpCnt = Ast.AssetPacking_list__c == null ? 1: Ast.AssetPacking_list__c ;
|
// 原逻辑
|
//Decimal tmpCnt = 1;
|
// WLIG-BTNDLX end
|
for (Integer i = 1; i <= 30; i++) {
|
if (Ast.get('Important_product' + i + '__c') == true) {
|
tmpKey = '' + i;
|
break;
|
}
|
}
|
// SWAG-BQ75WE update by vivek 2020/06/11 start
|
// setDeliveryCount(dcacc, tmpKey, tmpCnt, OldAccount2, HPtoGIAcc2Map , updateAccount);
|
setDeliveryCount(dcacc, tmpKey, tmpCnt, OldAccount2, depToOtherDepAcc2Map , updateAccount);
|
// SWAG-BQ75WE update by vivek 2020/06/11 end
|
}
|
// SWAG-BD24SU 检索对应的保有设备,赋值到战略科室的客户2对应的发货数 end
|
System.debug('======thisYd'+thisYd);
|
System.debug('======nextYd'+nextYd);
|
//Map<String, String> keyMap = new Map<String, String>();
|
for (OpportunityLineItem oli : [
|
select Id, Quantity, OpportunityId, Opportunity.Department_Class__c, Opportunity.Contract_recognized_day_1__c, Opportunity.Close_Forecasted_Date__c, Opportunity.Competitor__c,
|
OCM_Sales_Forecast_Product1_Number__c, OCM_Sales_Forecast_Product2_Number__c, OCM_Sales_Forecast_Product3_Number__c,
|
OCM_Sales_Forecast_Product4_Number__c, OCM_Sales_Forecast_Product5_Number__c, OCM_Sales_Forecast_Product6_Number__c,
|
OCM_Sales_Forecast_Product7_Number__c, OCM_Sales_Forecast_Product8_Number__c, OCM_Sales_Forecast_Product9_Number__c,
|
OCM_Sales_Forecast_Product10_Number__c, OCM_Sales_Forecast_Product11_Number__c, OCM_Sales_Forecast_Product12_Number__c,
|
OCM_Sales_Forecast_Product13_Number__c, OCM_Sales_Forecast_Product14_Number__c, OCM_Sales_Forecast_Product15_Number__c,
|
OCM_Sales_Forecast_Product16_Number__c, OCM_Sales_Forecast_Product17_Number__c, OCM_Sales_Forecast_Product18_Number__c,
|
OCM_Sales_Forecast_Product19_Number__c, OCM_Sales_Forecast_Product20_Number__c, OCM_Sales_Forecast_Product21_Number__c,
|
OCM_Sales_Forecast_Product22_Number__c, OCM_Sales_Forecast_Product23_Number__c, OCM_Sales_Forecast_Product24_Number__c,
|
OCM_Sales_Forecast_Product25_Number__c, OCM_Sales_Forecast_Product26_Number__c, OCM_Sales_Forecast_Product27_Number__c,
|
OCM_Sales_Forecast_Product28_Number__c, OCM_Sales_Forecast_Product29_Number__c, OCM_Sales_Forecast_Product30_Number__c
|
from OpportunityLineItem
|
where PricebookEntry.Product2.Important_product__c = true
|
and Opportunity.order_Date_For_Report__c
|
>= :thisYd
|
and Opportunity.order_Date_For_Report__c < :nextYd
|
and Opportunity.StageName__c in ('注残', '发货', '完毕')
|
and Opportunity.Department_Class__c in : dcListMap.values()
|
]) {
|
Id dcid = oli.Opportunity.Department_Class__c;
|
Account2__c dcacc = updateAccount.get(dcid);
|
|
String tmpKey = '';
|
Decimal tmpCnt = oli.Quantity == null ? 0 : oli.Quantity;
|
for (Integer i = 1; i <= 30; i++) {
|
if (oli.get('OCM_Sales_Forecast_Product' + i + '_Number__c') == 'true') {
|
tmpKey = '' + i;
|
break;
|
}
|
}
|
//String cntKey = oli.OpportunityId + '_' + tmpKey;
|
//if (keyMap.containsKey(cntKey) == false) {
|
//keyMap.put(cntKey, cntKey);
|
// 2020-06-12 SWAG-BQ75WE 额外传递depToOtherDepAcc2Map和updateAccount start
|
// setOrderCount(dcacc, tmpKey, tmpCnt, OldAccount2);
|
setOrderCount(dcacc, tmpKey, tmpCnt, OldAccount2, depToOtherDepAcc2Map , updateAccount);
|
// 2020-06-12 SWAG-BQ75WE 额外传递depToOtherDepAcc2Map和updateAccount end
|
//}
|
}
|
|
//Map<String, String> keyMap2 = new Map<String, String>();
|
for (OpportunityLineItem oli : [
|
select Id, Quantity, OpportunityId, Opportunity.Department_Class__c, Opportunity.Contract_recognized_day_1__c, Opportunity.Close_Forecasted_Date__c, Opportunity.Competitor__c,
|
OCM_Sales_Forecast_Product1_Number__c, OCM_Sales_Forecast_Product2_Number__c, OCM_Sales_Forecast_Product3_Number__c,
|
OCM_Sales_Forecast_Product4_Number__c, OCM_Sales_Forecast_Product5_Number__c, OCM_Sales_Forecast_Product6_Number__c,
|
OCM_Sales_Forecast_Product7_Number__c, OCM_Sales_Forecast_Product8_Number__c, OCM_Sales_Forecast_Product9_Number__c,
|
OCM_Sales_Forecast_Product10_Number__c, OCM_Sales_Forecast_Product11_Number__c, OCM_Sales_Forecast_Product12_Number__c,
|
OCM_Sales_Forecast_Product13_Number__c, OCM_Sales_Forecast_Product14_Number__c, OCM_Sales_Forecast_Product15_Number__c,
|
OCM_Sales_Forecast_Product16_Number__c, OCM_Sales_Forecast_Product17_Number__c, OCM_Sales_Forecast_Product18_Number__c,
|
OCM_Sales_Forecast_Product19_Number__c, OCM_Sales_Forecast_Product20_Number__c, OCM_Sales_Forecast_Product21_Number__c,
|
OCM_Sales_Forecast_Product22_Number__c, OCM_Sales_Forecast_Product23_Number__c, OCM_Sales_Forecast_Product24_Number__c,
|
OCM_Sales_Forecast_Product25_Number__c, OCM_Sales_Forecast_Product26_Number__c, OCM_Sales_Forecast_Product27_Number__c,
|
OCM_Sales_Forecast_Product28_Number__c, OCM_Sales_Forecast_Product29_Number__c, OCM_Sales_Forecast_Product30_Number__c
|
from OpportunityLineItem
|
where PricebookEntry.Product2.Important_product__c = true
|
and Opportunity.Shipping_Date_For_Report__c >= :thisYd
|
and Opportunity.StageName__c = '询价'
|
and Opportunity.Shipping_Date_For_Report__c < :nextYd
|
and Opportunity.Competitor__c in ('A1', 'A', 'B', 'C')
|
and Opportunity.Department_Class__c in : dcListMap.values()
|
]) {
|
Id dcid = oli.Opportunity.Department_Class__c;
|
Account2__c dcacc = updateAccount.get(dcid);
|
|
String tmpKey = '';
|
Decimal tmpCnt = oli.Quantity == null ? 0 : oli.Quantity;
|
for (Integer i = 1; i <= 30; i++) {
|
if (oli.get('OCM_Sales_Forecast_Product' + i + '_Number__c') == 'true') {
|
tmpKey = '' + i;
|
break;
|
}
|
}
|
//String cntKey = oli.OpportunityId + '_' + tmpKey;
|
//if (keyMap2.containsKey(cntKey) == false) {
|
//keyMap2.put(cntKey, cntKey);
|
// 2020-06-12 SWAG-BQ75WE 额外传递depToOtherDepAcc2Map和updateAccount start
|
// setOppCount(dcacc, tmpKey, tmpCnt, OldAccount2);
|
setOppCount(dcacc, tmpKey, tmpCnt, OldAccount2, depToOtherDepAcc2Map , updateAccount);
|
// 2020-06-12 SWAG-BQ75WE 额外传递depToOtherDepAcc2Map和updateAccount end
|
|
//}
|
}
|
//20200825 ljh SWAG-BRY6PF add start
|
for (AggregateResult oli:[select Rental_Apply__c,Product2__c,Rental_Apply__r.Strategic_dept__c
|
from Rental_Apply_Equipment_Set__c where
|
//IsOPD_Account__c = 1 AND
|
Rental_Apply__r.Strategic_dept__c in : dcListMap.values()
|
AND Demo_purpose1__c = '产品试用'
|
and Bollow_Date__c >= :thisYd
|
and Bollow_Date__c < :nextYd
|
group by Rental_Apply__c,Product2__c,Rental_Apply__r.Strategic_dept__c
|
]) {
|
Id dcid = ID.valueOf(String.valueOf(oli.get('Strategic_dept__c')));
|
Account2__c dcacc = updateAccount.get(dcid);
|
String tmpKey = '';
|
String tempProduct2 = String.valueOf(oli.get('Product2__c'));
|
if(tempProduct2 != null&&String.isNotBlank(tempProduct2)){
|
tmpKey = tempProduct2.substring(0,2);
|
}
|
setRentalCount(dcacc, tmpKey, 1, OldAccount2, depToOtherDepAcc2Map , updateAccount);
|
}
|
//20200825 ljh SWAG-BRY6PF add end
|
|
|
//SWAG-C9WCE5 战略科室和目标客户设定页面增加字段 lt 20211228 start
|
|
//Map<战略科室,数量> (CountHostsNumber)
|
Map<String,Integer> CountHostsMap = new Map<String,Integer>(); //所有主机
|
Map<String,Integer> CountRivalHostsMap = new Map<String,Integer>(); //对手主机
|
|
for(Asset chn : [
|
Select Id, Department_Class__c, Product2.ProductClass__c, Product2.Brand_Name__c, Product2.ProductCategory__c
|
From Asset
|
Where ((Product2.ProductClass__c = '主机' )
|
Or (Product2.ProductClass__c = '能量'
|
And (Product2.ProductCategory__c = 'STMS'
|
Or Product2.ProductCategory__c = 'ESG-400'
|
Or Product2.ProductCategory__c = '主机')))
|
And Department_Class__c in : dcListMap.values()
|
]){
|
//所有主机数量
|
if(CountHostsMap.containsKey(chn.Department_Class__c)){
|
CountHostsMap.put(chn.Department_Class__c, CountHostsMap.get(chn.Department_Class__c)+1);
|
}else{
|
CountHostsMap.put(chn.Department_Class__c, 1);
|
}
|
|
//对手主机数量
|
System.debug('主机厂商:' + chn.Product2.Brand_Name__c);
|
System.debug('判断是否奥林巴斯主机:' + (!'奥林巴斯'.equals(chn.Product2.Brand_Name__c)) + '|' + (chn.Product2.Brand_Name__c != '奥林巴斯'));
|
if(!'奥林巴斯'.equals(chn.Product2.Brand_Name__c)){
|
if(CountRivalHostsMap.containsKey(chn.Department_Class__c)){
|
CountRivalHostsMap.put(chn.Department_Class__c, CountRivalHostsMap.get(chn.Department_Class__c)+1);
|
}else{
|
CountRivalHostsMap.put(chn.Department_Class__c, 1);
|
}
|
}
|
|
Id dcid = chn.Department_Class__c; //战略科室id
|
Account2__c acc = updateAccount.get(dcid); //战略科室对应得 客户2
|
|
if(acc != null){
|
Integer CountHostsNumber = CountHostsMap.containsKey(dcid)?CountHostsMap.get(dcid):0;
|
Integer CountRivalHostsNumber = CountRivalHostsMap.containsKey(dcid)?CountRivalHostsMap.get(dcid):0;
|
|
acc.AllHostsNumber__c = CountHostsNumber; //所有主机数
|
acc.AllHostsNumber_first__c = CountHostsNumber; //所有主机数(期初)
|
acc.RivalHostsNumber__c = CountRivalHostsNumber; //对手主机数
|
acc.RivalHostsNumber_first__c = CountRivalHostsNumber; //对手主机数(期初)
|
|
}
|
}
|
|
//SWAG-C9WCE5 战略科室和目标客户设定页面增加字段 lt 20211228 end
|
|
StaticParameter.EscapeNFM001Trigger = true;
|
StaticParameter.EscapeNFM001AgencyContractTrigger = true;
|
// for (Account2__c acc : updateAccount.values()) {
|
// System.debug(acc);
|
// }
|
update updateAccount.values();
|
|
}
|
|
global void finish(Database.BatchableContext BC) {
|
// 今回はやることないです
|
}
|
|
// batch集計の基準日
|
public static Date getTargetDay() {
|
Date targetDay2 = null;
|
{
|
Date targetDay = Date.today();
|
if (targetDay.month() == 4 && targetDay.day() <= intYearDelayDay) {
|
targetDay2 = Date.valueOf(targetDay.year() + '-4-1').addDays(-1);
|
} else {
|
targetDay2 = targetDay.addDays(-1);
|
}
|
}
|
return targetDay2;
|
}
|
|
private void initAccountCount(Account2__c acc, Integer targetmonth) {
|
// if (acc.Id == '0011000000V9OU4') {
|
// BatchIF_Log__c iflog = new BatchIF_Log__c();
|
// iflog.Type__c = 'RollupToHPBatch';
|
// iflog.Log__c = '0011000000V9OU4 initAccountCount(' + targetmonth + ')\n';
|
// insert iflog;
|
// }
|
acc.Latest_Proposal_document_Submit_day__c = null;
|
acc.Proposal_Submit_Status__c = null;
|
acc.SpecialAsset_CV_Count__c = 0;
|
acc.SpecialAsset_CV_Other_Count__c = 0;
|
acc.SpecialAsset_GIF_Count__c = 0;
|
acc.SpecialAsset_OTV_Count__c = 0;
|
acc.JF_TJF_scope_count__c = 0;
|
acc.USG_400_count__c = 0;
|
acc.SpecialAsset_C3_Electronic_Mirror__c = 0;
|
acc.SpecialAsset_C3_Fiber_Mirror__c = 0;
|
acc.CV_290_Count__c = 0;
|
acc.CV_260SL_Count__c = 0;
|
acc.CV_260_Count__c = 0;
|
acc.CV_240_Other_Count__c = 0;
|
acc.CV_Other_Count__c = 0;
|
acc.D3_System_Count__c = 0;
|
acc.CV_190_Count__c = 0;
|
acc.OTV_S190_Count__c = 0;
|
acc.OTV_S7Pro_Count__c = 0;
|
acc.CV_180_Count__c = 0;
|
acc.OTV_S7_Count__c = 0;
|
acc.OTV_S6_Count__c = 0;
|
acc.OTV_Other_Count__c = 0;
|
acc.SSG2_Count__c = 0;
|
acc.ESG_400_Count__c = 0;
|
acc.G400_Count__c = 0;
|
acc.HD_EndoEYE_Count__c = 0;
|
acc.SD_EndoEYE_Count__c = 0;
|
acc.Video_URF_Count__c = 0;
|
acc.Video_CYF_Count__c = 0;
|
acc.Video_ENF_Count__c = 0;
|
acc.Competitor_Count__c = 0;
|
acc.Competitor_Count_SP__c = 0;
|
acc.Energy_Processor_Count__c = 0;
|
acc.Energy_Processor_Count_SP__c = 0;
|
acc.Other_Competitor_Product_Count__c = 0;
|
//20200825 ljh SWAG-BRY6PF add start
|
acc.Rental_Cnt_CV290__c = 0;
|
acc.Rental_Cnt_290MiroGI__c = 0;
|
acc.Rental_Cnt_290MiroGI_Plus__c = 0;
|
acc.Rental_Cnt_290MiroGI_CF__c = 0;
|
acc.Rental_Cnt_GFUCT260__c = 0;
|
acc.Rental_Cnt_EUME2__c = 0;
|
acc.Rental_Cnt_290MiroBF__c = 0;
|
acc.Rental_Cnt_OTVS400__c = 0;
|
acc.Rental_Cnt_OTVS300__c = 0;
|
acc.Rental_Cnt_CV170__c = 0;
|
acc.Rental_Cnt_CV190__c = 0;
|
acc.Rental_Cnt_OTVS190__c = 0;
|
acc.Rental_Cnt_ESG400__c = 0;
|
acc.Rental_Cnt_USG400__c = 0;
|
acc.Rental_Cnt_TB__c = 0;
|
//SWAG-BSC5WP you-20201021 start
|
acc.Asset_Cnt_290MiroBF__c = 0;
|
acc.Asset_Cnt_290MiroGI__c = 0;
|
acc.Asset_Cnt_290MiroGI_CF__c = 0;
|
acc.Asset_Cnt_290MiroGI_Plus__c = 0;
|
acc.Asset_Cnt_CV170__c = 0;
|
acc.Asset_Cnt_CV190__c = 0;
|
acc.Asset_Cnt_CV290__c = 0;
|
acc.Asset_Cnt_ESG400__c = 0;
|
acc.Asset_Cnt_EUME2__c = 0;
|
acc.Asset_Cnt_GFUCT260__c = 0;
|
acc.Asset_Cnt_OTVS190__c = 0;
|
acc.Asset_Cnt_OTVS300__c = 0;
|
acc.Asset_Cnt_OTVS400__c = 0;
|
acc.Asset_Cnt_TB__c = 0;
|
acc.Asset_Cnt_USG400__c = 0;
|
//SWAG-BSC5WP you-20201021 end
|
|
//20200825 ljh SWAG-BRY6PF add start
|
for (Integer columnNameInt = targetmonth + intMonth; columnNameInt <= targetmonth; columnNameInt++) {
|
String columnNameStr = columnNameInt + '__c';
|
if (columnNameInt <= 0) {
|
columnNameStr = (columnNameInt + 12) + '__c';
|
}
|
acc.put('This_year_inspection_times' + columnNameStr, 0);
|
acc.put('This_year_inspection_count' + columnNameStr, 0);
|
}
|
|
acc.AVG_Elapsed_day_from_Repair__c = 0;
|
acc.AVG_Elapsed_day_from_Repair2__c = 0;
|
acc.SUM_Repair_List_Price__c = 0;
|
acc.SUM_Repair_Billing_Amount__c = 0;
|
acc.AVG_Elapsed_day_from_Repair_Lastyear__c = 0;
|
acc.AVG_Elapsed_day_from_Repair2_Lastyear__c = 0;
|
acc.SUM_Repair_List_Price_Lastyear__c = 0;
|
acc.SUM_Repair_Billing_Amount_Lastyear__c = 0;
|
acc.SUM_Unpaid_Amount__c = 0;
|
|
acc.RANK_A_tax_HP__c = 0;
|
acc.RANK_B_tax_HP__c = 0;
|
acc.RANK_C_tax_HP__c = 0;
|
acc.RANK_D_tax_HP__c = 0;
|
acc.RANK_E_tax_HP__c = 0;
|
acc.Forecast_Amount_HP__c = 0;
|
acc.ShippedAmount_HP__c = 0;
|
|
acc.Opp_Actual_ThousandY__c = 0;
|
acc.BO_Forecast_ThousandY__c = 0;
|
acc.OP_ThousandY__c = 0;
|
|
acc.Opp_Forecast_ThousandY__c = 0;
|
//acc.Opportunity_ThousandY__c = 0;//lt 20220318 注释
|
acc.Amount_Without_Tax_Thousand__c = 0;
|
|
//20220111 SWAG-C8MBB6 加7.询价 lt start
|
acc.AllOP_ThousandY__c = 0;
|
//20220111 SWAG-C8MBB6 加7.询价 lt end
|
|
acc.Important_product1__c = 0;
|
acc.Important_product2__c = 0;
|
acc.Important_product3__c = 0;
|
acc.Important_product4__c = 0;
|
acc.Important_product5__c = 0;
|
acc.Important_product6__c = 0;
|
acc.Important_product7__c = 0;
|
acc.Important_product8__c = 0;
|
acc.Important_product9__c = 0;
|
acc.Important_product10__c = 0;
|
acc.Important_product11__c = 0;
|
acc.Important_product12__c = 0;
|
acc.Important_product13__c = 0;
|
acc.Important_product14__c = 0;
|
acc.Important_product15__c = 0;
|
acc.Important_product16__c = 0;
|
acc.Important_product17__c = 0;
|
acc.Important_product18__c = 0;
|
acc.Important_product19__c = 0;
|
acc.Important_product20__c = 0;
|
|
acc.CDS_training_number_this_year__c = 0;
|
|
acc.ThisYear1__c = 0;
|
acc.ThisYear2__c = 0;
|
acc.ThisYear3__c = 0;
|
acc.ThisYear4__c = 0;
|
acc.ThisYear5__c = 0;
|
acc.ThisYear6__c = 0;
|
acc.ThisYear7__c = 0;
|
acc.ThisYear8__c = 0;
|
acc.ThisYear9__c = 0;
|
acc.ThisYear10__c = 0;
|
acc.ThisYear11__c = 0;
|
acc.ThisYear12__c = 0;
|
acc.ThisYear1_FSE__c = 0;
|
acc.ThisYear2_FSE__c = 0;
|
acc.ThisYear3_FSE__c = 0;
|
acc.ThisYear4_FSE__c = 0;
|
acc.ThisYear5_FSE__c = 0;
|
acc.ThisYear6_FSE__c = 0;
|
acc.ThisYear7_FSE__c = 0;
|
acc.ThisYear8_FSE__c = 0;
|
acc.ThisYear9_FSE__c = 0;
|
acc.ThisYear10_FSE__c = 0;
|
acc.ThisYear11_FSE__c = 0;
|
acc.ThisYear12_FSE__c = 0;
|
|
// SWAG-BBBAKG start 能量拜访数初始化 start
|
acc.ThisYear1_Eng__c = 0;
|
acc.ThisYear2_Eng__c = 0;
|
acc.ThisYear3_Eng__c = 0;
|
acc.ThisYear4_Eng__c = 0;
|
acc.ThisYear5_Eng__c = 0;
|
acc.ThisYear6_Eng__c = 0;
|
acc.ThisYear7_Eng__c = 0;
|
acc.ThisYear8_Eng__c = 0;
|
acc.ThisYear9_Eng__c = 0;
|
acc.ThisYear10_Eng__c = 0;
|
acc.ThisYear11_Eng__c = 0;
|
acc.ThisYear12_Eng__c = 0;
|
// SWAG-BBBAKG start 能量拜访数初始化 end
|
|
|
acc.DoNTCHospital_ThisYear1__c = 0;
|
acc.DoNTCHospital_ThisYear2__c = 0;
|
acc.DoNTCHospital_ThisYear3__c = 0;
|
acc.DoNTCHospital_ThisYear4__c = 0;
|
acc.DoNTCHospital_ThisYear5__c = 0;
|
acc.DoNTCHospital_ThisYear6__c = 0;
|
acc.DoNTCHospital_ThisYear7__c = 0;
|
acc.DoNTCHospital_ThisYear8__c = 0;
|
acc.DoNTCHospital_ThisYear9__c = 0;
|
acc.DoNTCHospital_ThisYear10__c = 0;
|
acc.DoNTCHospital_ThisYear11__c = 0;
|
acc.DoNTCHospital_ThisYear12__c = 0;
|
acc.DoOPDHospital_ThisYear1__c = 0;
|
acc.DoOPDHospital_ThisYear2__c = 0;
|
acc.DoOPDHospital_ThisYear3__c = 0;
|
acc.DoOPDHospital_ThisYear4__c = 0;
|
acc.DoOPDHospital_ThisYear5__c = 0;
|
acc.DoOPDHospital_ThisYear6__c = 0;
|
acc.DoOPDHospital_ThisYear7__c = 0;
|
acc.DoOPDHospital_ThisYear8__c = 0;
|
acc.DoOPDHospital_ThisYear9__c = 0;
|
acc.DoOPDHospital_ThisYear10__c = 0;
|
acc.DoOPDHospital_ThisYear11__c = 0;
|
acc.DoOPDHospital_ThisYear12__c = 0;
|
acc.DoOPDHospital_ThisYear1_FSE__c = 0;
|
acc.DoOPDHospital_ThisYear2_FSE__c = 0;
|
acc.DoOPDHospital_ThisYear3_FSE__c = 0;
|
acc.DoOPDHospital_ThisYear4_FSE__c = 0;
|
acc.DoOPDHospital_ThisYear5_FSE__c = 0;
|
acc.DoOPDHospital_ThisYear6_FSE__c = 0;
|
acc.DoOPDHospital_ThisYear7_FSE__c = 0;
|
acc.DoOPDHospital_ThisYear8_FSE__c = 0;
|
acc.DoOPDHospital_ThisYear9_FSE__c = 0;
|
acc.DoOPDHospital_ThisYear10_FSE__c = 0;
|
acc.DoOPDHospital_ThisYear11_FSE__c = 0;
|
acc.DoOPDHospital_ThisYear12_FSE__c = 0;
|
|
acc.Service_contract_active_number_HP__c = 0;
|
acc.Sum_Number_of_participant_for_TTC__c = 0;
|
acc.Academic_HCP_Count__c = 0;
|
acc.General_HCP_Count__c = 0;
|
acc.Product_HCP_Count__c = 0;
|
|
acc.OPD_3D_pre__c = 0;
|
acc.OPD_CV_170_pre__c = 0;
|
acc.OPD_CV_190_pre__c = 0;
|
acc.OPD_CV_290_pre__c = 0;
|
acc.OPD_EU_ME2_pre__c = 0;
|
acc.OPD_OTV_S190_pre__c = 0;
|
acc.OPD_STMS_pre__c = 0;
|
acc.OPD_GW_pre__c = 0;
|
|
// SWAG-BC832V 初始化 CYF 为 0 start
|
acc.OPD_CYF_pre__c = 0;
|
acc.OPD_CYF__c = 0;
|
// SWAG-BC832V 初始化 CYF 为 0 end
|
|
acc.OPD_3D__c = 0;
|
acc.OPD_CV_170__c = 0;
|
acc.OPD_CV_190__c = 0;
|
acc.OPD_CV_290__c = 0;
|
acc.OPD_EU_ME2__c = 0;
|
acc.OPD_OTV_S190__c = 0;
|
acc.OPD_STMS__c = 0;
|
acc.OPD_GW__c = 0;
|
acc.OPD_OER_AW__c = 0;
|
acc.OPD_OTV_S400__c = 0;
|
acc.OPD_CH_S400_XZ__c = 0;
|
acc.OPD_UCES_3__c = 0;
|
|
acc.Order_cnt_290Miro__c = 0;
|
acc.Order_cnt_3D__c = 0;
|
acc.Order_cnt_CHS400XZ__c = 0;
|
acc.Order_cnt_CV170__c = 0;
|
acc.Order_cnt_CV190__c = 0;
|
acc.Order_cnt_CV290__c = 0;
|
acc.Order_cnt_EUME2__c = 0;
|
acc.Order_cnt_OERAW__c = 0;
|
acc.Order_cnt_OTVS190__c = 0;
|
acc.Order_cnt_OTVS400__c = 0;
|
acc.Order_cnt_UCES3__c = 0;
|
acc.Order_cnt_USG400__c = 0;
|
acc.Order_cnt_GW__c = 0;
|
// SWAG-BD24SU 初始化发货数 start
|
acc.Delivery_cnt_3D__c = 0;
|
acc.Delivery_cnt_CV290__c = 0;
|
acc.Delivery_cnt_CYF__c = 0;
|
acc.Delivery_cnt_EUME2__c = 0;
|
acc.Delivery_cnt_OERAW__c = 0;
|
acc.Delivery_cnt_OTVS400__c = 0;
|
acc.Delivery_cnt_USG400__c = 0;
|
acc.Delivery_cnt_CV170__c = 0;
|
acc.Delivery_cnt_CV190__c = 0;
|
acc.Delivery_cnt_OTVS190__c = 0;
|
// SWAG-BD24SU 初始化发货数 end
|
|
// SWAG-BC832V 初始化 CYF 为 0 start
|
acc.Order_cnt_CYF__c = 0;
|
acc.Opp_cnt_CYF__c = 0;
|
// SWAG-BC832V 初始化 CYF 为 0 end
|
|
acc.Opp_cnt_290Miro__c = 0;
|
acc.Opp_cnt_3D__c = 0;
|
acc.Opp_cnt_CHS400XZ__c = 0;
|
acc.Opp_cnt_CV170__c = 0;
|
acc.Opp_cnt_CV190__c = 0;
|
acc.Opp_cnt_CV290__c = 0;
|
acc.Opp_cnt_EUME2__c = 0;
|
acc.Opp_cnt_OERAW__c = 0;
|
acc.Opp_cnt_OTVS190__c = 0;
|
acc.Opp_cnt_OTVS400__c = 0;
|
acc.Opp_cnt_UCES3__c = 0;
|
acc.Opp_cnt_USG400__c = 0;
|
acc.Opp_cnt_GW__c = 0;
|
// SWAG-BQ75WE 20200609 Start
|
acc.Opp_cnt_290MiroBF__c = 0;
|
acc.Opp_cnt_290MiroGI__c = 0;
|
acc.Opp_cnt_290MiroGI_Plus__c = 0;
|
acc.Opp_cnt_290MiroGI_CF__c = 0;
|
acc.Opp_cnt_GFUCT260__c = 0;
|
acc.Opp_cnt_OTVS300__c = 0;
|
acc.Opp_cnt_ESG400__c = 0;
|
acc.Opp_cnt_TB__c = 0;
|
|
acc.Delivery_cnt_290MiroBF__c = 0;
|
acc.Delivery_cnt_290MiroGI__c = 0;
|
acc.Delivery_cnt_290MiroGI_Plus__c = 0;
|
acc.Delivery_cnt_290MiroGI_CF__c = 0;
|
acc.Delivery_cnt_GFUCT260__c = 0;
|
acc.Delivery_cnt_OTVS300__c = 0;
|
acc.Delivery_cnt_ESG400__c = 0;
|
acc.Delivery_cnt_TB__c = 0;
|
|
acc.Order_cnt_290MiroBF__c = 0;
|
acc.Order_cnt_290MiroGI__c = 0;
|
acc.Order_cnt_290MiroGI_Plus__c = 0;
|
acc.Order_cnt_290MiroGI_CF__c = 0;
|
acc.Order_cnt_GFUCT260__c = 0;
|
acc.Order_cnt_OTVS300__c = 0;
|
acc.Order_cnt_ESG400__c = 0;
|
acc.Order_cnt_TB__c = 0;
|
|
acc.OPD_USG400__c = 0;
|
acc.OPD_OTV_S400__c = 0;
|
acc.OPD_290Miro_BF__c = 0;
|
acc.OPD_290Miro_GI__c = 0;
|
acc.OPD_290Miro_GICF__c = 0;
|
acc.OPD_290Miro_GIPlus__c = 0;
|
acc.OPD_GFUCT260__c = 0;
|
acc.OPD_OTV_S300__c = 0;
|
acc.OPD_ESG400__c = 0;
|
acc.OPD_TB__c = 0;
|
// SWAG-BQ75WE 20200609 End
|
|
}
|
|
private void setTimesAndCounts(Account2__c acc, Integer iMonth, Decimal times, Decimal counts) {
|
acc.put('This_year_inspection_times' + iMonth + '__c', (Decimal) acc.get('This_year_inspection_times' + iMonth + '__c') + times);
|
acc.put('This_year_inspection_count' + iMonth + '__c', (Decimal) acc.get('This_year_inspection_count' + iMonth + '__c') + counts);
|
}
|
|
private void setAssetCategoryCount(Account2__c acc, String strDCL, String strC3, String strC4, String strC5, Integer cntId) {
|
// if (acc.Id == '0011000000V9OU4') {
|
// BatchIF_Log__c iflog = new BatchIF_Log__c();
|
// iflog.Type__c = 'RollupToHPBatch';
|
// iflog.Log__c = '0011000000V9OU4 ' + strDCL + ' start\n';
|
// iflog.Log__c += 'strC3=' + strC3 + '\n';
|
// iflog.Log__c += 'strC4=' + strC4 + '\n';
|
// iflog.Log__c += 'strC5=' + strC5 + '\n';
|
// iflog.Log__c += 'cntId=' + cntId + '\n';
|
// insert iflog;
|
// }
|
if ((strDCL == '消化科' || strDCL == '呼吸科') && strC4 == 'CV') {
|
acc.SpecialAsset_CV_Count__c += cntId;
|
}
|
if (!(strDCL == '消化科' || strDCL == '呼吸科') && strC4 == 'CV') {
|
acc.SpecialAsset_CV_Other_Count__c += cntId;
|
}
|
if (strC3 == '电子镜' && strC4 == 'GIF') {
|
acc.SpecialAsset_GIF_Count__c += cntId;
|
}
|
if (strC3 == '电子镜') {
|
acc.SpecialAsset_C3_Electronic_Mirror__c += cntId;
|
}
|
if (strC3 == '纤维镜') {
|
acc.SpecialAsset_C3_Fiber_Mirror__c += cntId;
|
}
|
if (strC4 == 'OTV') {
|
acc.SpecialAsset_OTV_Count__c += cntId;
|
}
|
if (strC4 == 'JF') {
|
acc.JF_TJF_scope_count__c += cntId;
|
}
|
if (strC5 == 'USG-400') {
|
acc.USG_400_count__c += cntId;
|
}
|
if (strC4 == 'CV' && strC5 == '290系列') {
|
acc.CV_290_Count__c += cntId;
|
}
|
if (strC4 == 'CV' && strC5 == '260SL系列') {
|
acc.CV_260SL_Count__c += cntId;
|
}
|
if (strC4 == 'CV' && strC5 == '260系列') {
|
acc.CV_260_Count__c += cntId;
|
}
|
if (strC4 == 'CV' && (strC5 == '240系列' || strC5 == '200系列其他')) {
|
acc.CV_240_Other_Count__c += cntId;
|
}
|
if (strC4 == 'CV' && !(strC5 == '290系列' || strC5 == '260SL系列' || strC5 == '260系列' || strC5 == '240系列' || strC5 == '200系列其他')) {
|
acc.CV_Other_Count__c += cntId;
|
}
|
if (strC4 == 'CV' && strC5 == '190系列') {
|
acc.CV_190_Count__c += cntId;
|
}
|
if (strC4 == 'OTV' && strC5 == 'OTV-S190系列') {
|
acc.OTV_S190_Count__c += cntId;
|
}
|
if (strC4 == 'OTV' && strC5 == 'OTV-S7Pro系列') {
|
acc.OTV_S7Pro_Count__c += cntId;
|
}
|
if (strC4 == 'CV' && strC5 == '180系列') {
|
acc.CV_180_Count__c += cntId;
|
}
|
if (strC4 == 'OTV' && strC5 == 'OTV-S7系列') {
|
acc.OTV_S7_Count__c += cntId;
|
}
|
if (strC4 == 'OTV' && strC5 == 'OTV-S6系列') {
|
acc.OTV_S6_Count__c += cntId;
|
}
|
if (strC4 == 'OTV' && !(strC5 == 'OTV-S190系列' || strC5 == 'OTV-S7Pro系列' || strC5 == 'OTV-S7系列' || strC5 == 'OTV-S6系列')) {
|
acc.OTV_Other_Count__c += cntId;
|
}
|
if (strC3 == '能量主机' && strC5 == 'G2') {
|
acc.SSG2_Count__c += cntId;
|
}
|
if (strC3 == '能量主机' && strC5 == 'G400') {
|
acc.G400_Count__c += cntId;
|
}
|
if (strC3 == '电子腹腔镜' && strC5 == 'HD EndoEYE') {
|
acc.HD_EndoEYE_Count__c += cntId;
|
}
|
if (strC3 == '电子腹腔镜' && strC5 == 'SD EndoEYE') {
|
acc.SD_EndoEYE_Count__c += cntId;
|
}
|
if (strC3 == '电子镜' && strC4 == 'URF') {
|
acc.Video_URF_Count__c += cntId;
|
}
|
if (strC3 == '电子镜' && strC4 == 'CYF') {
|
acc.Video_CYF_Count__c += cntId;
|
}
|
if (strC3 == '电子镜' && strC4 == 'ENF') {
|
acc.Video_ENF_Count__c += cntId;
|
}
|
if ((strDCL == '消化科' || strDCL == '呼吸科') && strC3 == '主机' && strC5 == '竞争对手') {
|
acc.Competitor_Count__c += cntId;
|
}
|
if (!(strDCL == '消化科' || strDCL == '呼吸科') && strC3 == '主机' && strC5 == '竞争对手') {
|
acc.Competitor_Count_SP__c += cntId;
|
}
|
if ((strDCL == '消化科' || strDCL == '呼吸科') && strC3 == '能量主机' && strC5 == '竞争对手') {
|
acc.Energy_Processor_Count__c += cntId;
|
}
|
if (!(strDCL == '消化科' || strDCL == '呼吸科') && strC3 == '能量主机' && strC5 == '竞争对手') {
|
acc.Energy_Processor_Count_SP__c += cntId;
|
}
|
if (strC5 == '竞争对手' && !(strC3 == '主机' || strC3 == '能量主机')) {
|
acc.Other_Competitor_Product_Count__c += cntId;
|
}
|
// if (acc.Id == '0011000000V9OU4') {
|
// BatchIF_Log__c iflog = new BatchIF_Log__c();
|
// iflog.Type__c = 'RollupToHPBatch';
|
// iflog.Log__c = '0011000000V9OU4 ' + strDCL + ' end\n';
|
// iflog.Log__c += 'Competitor_Count__c=' + acc.Competitor_Count__c + '\n';
|
// iflog.Log__c += 'Competitor_Count_SP__c=' + acc.Competitor_Count_SP__c + '\n';
|
// iflog.Log__c += 'Energy_Processor_Count__c=' + acc.Energy_Processor_Count__c + '\n';
|
// iflog.Log__c += 'Energy_Processor_Count_SP__c=' + acc.Energy_Processor_Count_SP__c + '\n';
|
// iflog.Log__c += 'Other_Competitor_Product_Count__c=' + acc.Other_Competitor_Product_Count__c + '\n';
|
// insert iflog;
|
// }
|
}
|
|
private void setAssetPcodeCount(Account2__c acc, String strPcode, Integer cntId) {
|
if (strPcode == 'N4491360') {
|
acc.D3_System_Count__c += cntId;
|
}
|
if (strPcode == 'WB91051C') {
|
acc.ESG_400_Count__c += cntId;
|
}
|
}
|
// SWAG-BBBAKG start 保存能量的拜访情况
|
private void setEventCount_Eng(Account2__c acc, Integer iMonth, Integer cntId) {
|
acc.put('ThisYear' + iMonth + '_Eng__c', (Decimal) acc.get('ThisYear' + iMonth + '_Eng__c') + cntId);
|
}
|
// SWAG-BBBAKG end
|
private void setEventCount(Account2__c acc, Integer iMonth, Integer cntId, String jobCategory) {
|
if (jobCategory == '销售推广') {
|
acc.put('ThisYear' + iMonth + '__c', (Decimal) acc.get('ThisYear' + iMonth + '__c') + cntId);
|
} else if (jobCategory == '销售服务') {
|
acc.put('ThisYear' + iMonth + '_FSE__c', (Decimal) acc.get('ThisYear' + iMonth + '_FSE__c') + cntId);
|
}
|
}
|
|
private void setRankTaxCount(Account2__c acc, Decimal a1, Decimal a2, Decimal a3, Decimal a4, Decimal a5, Decimal fa, Decimal sa) {
|
// 正式环境空指针报错处理 2021-11-15
|
if (acc == null) {
|
return;
|
}
|
acc.RANK_A_tax_HP__c += a1;
|
acc.RANK_B_tax_HP__c += a2;
|
acc.RANK_C_tax_HP__c += a3;
|
acc.RANK_D_tax_HP__c += a4;
|
acc.RANK_E_tax_HP__c += a5;
|
acc.Forecast_Amount_HP__c += fa;
|
acc.ShippedAmount_HP__c += sa;
|
}
|
|
private void setOppAmount(Account2__c acc, Decimal o1, Decimal o2, Decimal o3, Decimal o4, Decimal o5, Decimal o6, Decimal o7) {
|
acc.Opp_Actual_ThousandY__c += o1;
|
acc.BO_Forecast_ThousandY__c += o2;
|
acc.OP_ThousandY__c += o3;
|
acc.Opp_Forecast_ThousandY__c += o4;
|
//acc.Opportunity_ThousandY__c += o5;//lt 20220318 注释
|
acc.Amount_Without_Tax_Thousand__c += o6;
|
//20220111 SWAG-C8MBB6 加7.询价 lt start
|
acc.AllOP_ThousandY__c += o7;
|
//20220111 SWAG-C8MBB6 加7.询价 lt end
|
}
|
|
private void setOpdIproductCount(Account2__c acc, Decimal decIP1, Decimal decIP2, Decimal decIP3, Decimal decIP4, Decimal decIP5, Decimal decIP6, Decimal decIP7, Decimal decIP8, Decimal decIP9, Decimal decIP10,
|
Decimal decIP11, Decimal decIP12, Decimal decIP13, Decimal decIP14, Decimal decIP15, Decimal decIP16, Decimal decIP17, Decimal decIP18, Decimal decIP19, Decimal decIP20) {
|
acc.Important_product1__c += decIP1;
|
acc.Important_product2__c += decIP2;
|
acc.Important_product3__c += decIP3;
|
acc.Important_product4__c += decIP4;
|
acc.Important_product5__c += decIP5;
|
acc.Important_product6__c += decIP6;
|
acc.Important_product7__c += decIP7;
|
acc.Important_product8__c += decIP8;
|
acc.Important_product9__c += decIP9;
|
acc.Important_product10__c += decIP10;
|
acc.Important_product11__c += decIP11;
|
acc.Important_product12__c += decIP12;
|
acc.Important_product13__c += decIP13;
|
acc.Important_product14__c += decIP14;
|
acc.Important_product15__c += decIP15;
|
acc.Important_product16__c += decIP16;
|
acc.Important_product17__c += decIP17;
|
acc.Important_product18__c += decIP18;
|
acc.Important_product19__c += decIP19;
|
acc.Important_product20__c += decIP20;
|
}
|
|
private void setNtcCdsCount(Account2__c acc, Decimal cds) {
|
acc.CDS_training_number_this_year__c += cds;
|
}
|
|
private void setDoCount(Account2__c acc, Integer iMonth, String dName, String jobCategory) {
|
if (dName == 'OPD') {
|
if (jobCategory == '销售推广') {
|
acc.put('DoOPDHospital_ThisYear' + iMonth + '__c', (Decimal) acc.get('DoOPDHospital_ThisYear' + iMonth + '__c') + 1);
|
} else if (jobCategory == '销售服务') {
|
acc.put('DoOPDHospital_ThisYear' + iMonth + '_FSE__c', (Decimal) acc.get('DoOPDHospital_ThisYear' + iMonth + '_FSE__c') + 1);
|
}
|
} else if (dName == 'NTC') {
|
acc.put('DoNTCHospital_ThisYear' + iMonth + '__c', (Decimal) acc.get('DoNTCHospital_ThisYear' + iMonth + '__c') + 1);
|
}
|
}
|
|
private void setContactCount(Account2__c acc, Decimal decTTC, String strHCP) {
|
acc.Sum_Number_of_participant_for_TTC__c += decTTC;
|
if (strHCP == '学術HCP') {
|
acc.Academic_HCP_Count__c += 1;
|
} else if (strHCP == '製品HCP') {
|
acc.Product_HCP_Count__c += 1;
|
} else if (strHCP == '一般HCP') {
|
acc.General_HCP_Count__c += 1;
|
}
|
}
|
|
// SWAG-BD24SU 累加发货数的方法 start
|
// update by vivek SWAG-BQ75WE 2020/06/11 修改参数 start
|
private void setDeliveryCount(Account2__c acc, String tmpKey,
|
Decimal tmpCnt , Map<Id, Account2__c> OldAccount2 ,
|
// Map<id, id> HPtoGIAcc2Map,
|
Map<String,id> depToOtherDepAcc2Map,
|
Map<Id, Account2__c> updateAccount) {
|
// update by vivek SWAG-BQ75WE 2020/06/11 修改参数 end
|
// switch on tmpKey {
|
// when '8' {acc.Delivery_cnt_3D__c += tmpCnt;}
|
// when '1' {
|
// Account2__c acc2 = OldAccount2.get(acc.Id);
|
// if (acc2 != null &&
|
// !acc2.Account_Org__r.RecordType_DeveloperName__c.equals('Department_Class_BF')) {
|
// ID depGIId = HPtoGIAcc2Map.get(acc2.Account_Org__r.parentID);
|
// Account2__c acc2GI = updateAccount.get(depGIId);
|
// acc2GI.Delivery_cnt_CV290__c += tmpCnt;
|
|
// } else{
|
// acc.Delivery_cnt_CV290__c += tmpCnt;
|
// }
|
// }
|
// when '18' {acc.Delivery_cnt_CYF__c += tmpCnt;}
|
// when '4' {
|
// Account2__c acc2 = OldAccount2.get(acc.Id);
|
// if (acc2 != null &&
|
// !acc2.Account_Org__r.RecordType_DeveloperName__c.equals('Department_Class_BF')) {
|
// ID depGIId = HPtoGIAcc2Map.get(acc2.Account_Org__r.parentID);
|
// Account2__c acc2GI = updateAccount.get(depGIId);
|
// acc2GI.Delivery_cnt_EUME2__c += tmpCnt;
|
|
// } else{
|
// acc.Delivery_cnt_EUME2__c += tmpCnt;
|
// }
|
|
|
// }
|
// when '27' {
|
// Account2__c acc2 = OldAccount2.get(acc.Id);
|
// if (acc2 != null &&
|
// !acc2.Account_Org__r.RecordType_DeveloperName__c.equals('Department_Class_BF')) {
|
// ID depGIId = HPtoGIAcc2Map.get(acc2.Account_Org__r.parentID);
|
// Account2__c acc2GI = updateAccount.get(depGIId);
|
// acc2GI.Delivery_cnt_OERAW__c += tmpCnt;
|
|
// } else{
|
// acc.Delivery_cnt_OERAW__c += tmpCnt;
|
// }
|
// }
|
// when '29' {acc.Delivery_cnt_OTVS400__c += tmpCnt;}
|
// when '25' {acc.Delivery_cnt_USG400__c += tmpCnt;}
|
// when '3' {acc.Delivery_cnt_CV170__c += tmpCnt;}
|
// when '9' {acc.Delivery_cnt_CV190__c += tmpCnt;}
|
// when '10' {acc.Delivery_cnt_OTVS190__c += tmpCnt;}
|
|
// when else {
|
// system.debug('=====setDeliveryCount else:' + tmpKey + '_x_' + tmpCnt);
|
// }
|
|
// update by vivek SWAG-BQ75WE 2020/06/12 通用方法修改 start
|
List<List<String>> allList = new List<List<String>>();
|
allList = getImportantProductModel(tmpKey, '2');
|
Account2__c acc2 = OldAccount2.get(acc.Id);
|
String nameType = 'Delivery_cnt_';
|
String departmentE = acc2.Account_Org__r.RecordType_DeveloperName__c.substring(17);
|
countImportantProduct(acc,nameType,tmpCnt,tmpKey,allList,departmentE,depToOtherDepAcc2Map, updateAccount, OldAccount2);
|
|
}
|
|
//SWAG-BD24SU 累加发货数的方法 end
|
|
// 2020-06-12 SWAG-BQ75WE 额外传递depToOtherDepAcc2Map和updateAccount start
|
// 2018-09-14 CHAN-B4J9TC start 额外传递下客户2对象map,用来判断战略科室
|
// private void setOrderCount(Account2__c acc, String tmpKey, Decimal tmpCnt , Map<Id, Account2__c> OldAccount2) {
|
private void setOrderCount(Account2__c acc, String tmpKey, Decimal tmpCnt , Map<Id, Account2__c> OldAccount2,Map<String,id> depToOtherDepAcc2Map,
|
Map<Id, Account2__c> updateAccount) {
|
// 2018-09-14 CHAN-B4J9TC end 额外传递下客户2对象map,用来判断战略科室
|
// 2020-06-12 SWAG-BQ75WE 额外传递depToOtherDepAcc2Map和updateAccount end
|
// switch on tmpKey {
|
// 2018-09-14 CHAN-B4J9TC start 消化科统计GI 290镜子,呼吸科统计 BF-290 镜子
|
// when '2' {
|
// Account2__c acc2 = OldAccount2.get(acc.Id);
|
// if (acc2 != null && acc2.Account_Org__r.RecordType_DeveloperName__c.equals('Department_Class_GI')) {
|
// acc.Order_cnt_290Miro__c += tmpCnt;
|
// }
|
// }
|
// when '5' {
|
// Account2__c acc2 = OldAccount2.get(acc.Id);
|
// if (acc2 != null && acc2.Account_Org__r.RecordType_DeveloperName__c.equals('Department_Class_BF')) {
|
// acc.Order_cnt_290Miro__c += tmpCnt;
|
// }
|
// }
|
// // 2018-09-14 CHAN-B4J9TC end 消化科统计GI 290镜子,呼吸科统计 BF-290 镜子
|
|
// // CHAN-B496KE 2018/09/04 订货数3D所指的重点产品,由重点製品11 LTF-3D 改为 重点产品08 3DV-190 start
|
// when '8' {acc.Order_cnt_3D__c += tmpCnt;}
|
// // CHAN-B496KE 2018/09/04 订货数3D所指的重点产品,由重点製品11 LTF-3D 改为 重点产品08 3DV-190 end
|
// when '30' {acc.Order_cnt_CHS400XZ__c += tmpCnt;}
|
// when '3' {acc.Order_cnt_CV170__c += tmpCnt;}
|
// when '9' {acc.Order_cnt_CV190__c += tmpCnt;}
|
// when '1' {acc.Order_cnt_CV290__c += tmpCnt;}
|
// when '4' {acc.Order_cnt_EUME2__c += tmpCnt;}
|
// when '27' {acc.Order_cnt_OERAW__c += tmpCnt;}
|
// when '10' {acc.Order_cnt_OTVS190__c += tmpCnt;}
|
// when '29' {acc.Order_cnt_OTVS400__c += tmpCnt;}
|
// when '28' {acc.Order_cnt_UCES3__c += tmpCnt;}
|
// when '25' {acc.Order_cnt_USG400__c += tmpCnt;}
|
// when '6' {acc.Order_cnt_GW__c += tmpCnt;}
|
// // SWAG-BC832V 订货数:CYF 累加
|
// when '18' {acc.Order_cnt_CYF__c += tmpCnt;}
|
// // SWAG-BC832V
|
// when else {
|
// system.debug('=====setOrderCount else:' + tmpKey + '_x_' + tmpCnt);
|
// }
|
|
// SWAG-BQ75WE 2020-06-12 start
|
List<List<String>> allList = new List<List<String>>();
|
allList = getImportantProductModel(tmpKey, '2');
|
Account2__c acc2 = OldAccount2.get(acc.Id);
|
String nameType = 'Order_cnt_';
|
String departmentE = acc2.Account_Org__r.RecordType_DeveloperName__c.substring(17);
|
countImportantProduct(acc,nameType,tmpCnt,tmpKey,allList,departmentE,depToOtherDepAcc2Map, updateAccount, OldAccount2);
|
// SWAG-BQ75WE 2020-06-12 start
|
}
|
|
// 2020-06-12 SWAG-BQ75WE 额外传递depToOtherDepAcc2Map和updateAccount start
|
// 2018-09-14 CHAN-B4J9TC start 额外传递下客户2对象map,用来判断战略科室
|
private void setOppCount(Account2__c acc, String tmpKey, Decimal tmpCnt , Map<Id, Account2__c> OldAccount2,Map<String,id> depToOtherDepAcc2Map,
|
Map<Id, Account2__c> updateAccount) {
|
// 2018-09-14 CHAN-B4J9TC end 额外传递下客户2对象map,用来判断战略科室
|
// 2020-06-12 SWAG-BQ75WE 额外传递depToOtherDepAcc2Map和updateAccount end
|
// switch on tmpKey {
|
// 2018-09-14 CHAN-B4J9TC start 消化科统计GI 290镜子,呼吸科统计 BF-290 镜子
|
// when '2' {
|
// Account2__c acc2 = OldAccount2.get(acc.Id);
|
// if (acc2 != null && acc2.Account_Org__r.RecordType_DeveloperName__c.equals('Department_Class_GI')) {
|
// acc.Opp_cnt_290Miro__c += tmpCnt;
|
// }
|
// }
|
// when '5' {
|
// Account2__c acc2 = OldAccount2.get(acc.Id);
|
// if (acc2 != null && acc2.Account_Org__r.RecordType_DeveloperName__c.equals('Department_Class_BF')) {
|
// acc.Opp_cnt_290Miro__c += tmpCnt;
|
// }
|
// }
|
// // 2018-09-14 CHAN-B4J9TC end 消化科统计GI 290镜子,呼吸科统计 BF-290 镜子
|
|
|
// // CHAN-B496KE 2018/09/04 询价数3D所指的重点产品,由重点製品11 LTF-3D 改为 重点产品08 3DV-190 start
|
// when '8' {acc.Opp_cnt_3D__c += tmpCnt;}
|
// // CHAN-B496KE 2018/09/04 询价数3D所指的重点产品,由重点製品11 LTF-3D 改为 重点产品08 3DV-190 end
|
// when '30' {acc.Opp_cnt_CHS400XZ__c += tmpCnt;}
|
// when '3' {acc.Opp_cnt_CV170__c += tmpCnt;}
|
// when '9' {acc.Opp_cnt_CV190__c += tmpCnt;}
|
// when '1' {acc.Opp_cnt_CV290__c += tmpCnt;}
|
// when '4' {acc.Opp_cnt_EUME2__c += tmpCnt;}
|
// when '27' {acc.Opp_cnt_OERAW__c += tmpCnt;}
|
// when '10' {acc.Opp_cnt_OTVS190__c += tmpCnt;}
|
// when '29' {acc.Opp_cnt_OTVS400__c += tmpCnt;}
|
// when '28' {acc.Opp_cnt_UCES3__c += tmpCnt;}
|
// when '25' {acc.Opp_cnt_USG400__c += tmpCnt;}
|
// when '6' {acc.Opp_cnt_GW__c += tmpCnt;}
|
// // SWAG-BC832V 订货数:CYF 累加
|
// when '18' {
|
// acc.Opp_cnt_CYF__c += tmpCnt;
|
// system.debug('=====setOppCount else:' + tmpKey + '_x_' + tmpCnt);
|
// }
|
// // SWAG-BC832V
|
// when else {
|
// system.debug('=====setOppCount else:' + tmpKey + '_x_' + tmpCnt);
|
// }
|
|
// SWAG-BQ75WE 2020-06-12 start
|
List<List<String>> allList = new List<List<String>>();
|
allList = getImportantProductModel(tmpKey, '2');
|
Account2__c acc2 = OldAccount2.get(acc.Id);
|
String nameType = 'Opp_cnt_';
|
String departmentE = acc2.Account_Org__r.RecordType_DeveloperName__c.substring(17);
|
countImportantProduct(acc,nameType,tmpCnt,tmpKey,allList,departmentE,depToOtherDepAcc2Map, updateAccount, OldAccount2);
|
|
// SWAG-BQ75WE 2020-06-12 end
|
}
|
//20200825 ljh SWAG-BRY6PF add start
|
private void setRentalCount(Account2__c acc, String tmpKey, Integer tmpCnt , Map<Id, Account2__c> OldAccount2,Map<String,id> depToOtherDepAcc2Map,
|
Map<Id, Account2__c> updateAccount) {
|
switch on tmpKey {
|
when '01' {acc.Rental_Cnt_CV290__c += tmpCnt;}
|
when '02' {acc.Rental_Cnt_290MiroGI__c += tmpCnt;}
|
when '03' {acc.Rental_Cnt_290MiroGI_Plus__c += tmpCnt;}
|
when '04' {acc.Rental_Cnt_290MiroGI_CF__c += tmpCnt;}
|
when '07' {acc.Rental_Cnt_GFUCT260__c += tmpCnt;}
|
when '05' {acc.Rental_Cnt_EUME2__c += tmpCnt;}
|
when '09' {acc.Rental_Cnt_290MiroBF__c += tmpCnt;}
|
when '14' {acc.Rental_Cnt_OTVS400__c += tmpCnt;}
|
when '15' {acc.Rental_Cnt_OTVS300__c += tmpCnt;}
|
when '16' {acc.Rental_Cnt_CV170__c += tmpCnt;}
|
when '17' {acc.Rental_Cnt_CV190__c += tmpCnt;}
|
when '18' {acc.Rental_Cnt_OTVS190__c += tmpCnt;}
|
when '28' {acc.Rental_Cnt_ESG400__c += tmpCnt;}
|
when '29' {acc.Rental_Cnt_USG400__c += tmpCnt;}
|
when '30' {acc.Rental_Cnt_TB__c += tmpCnt;}
|
when else {
|
system.debug('=====setRentalCount else:' + tmpKey + '_x_' + tmpCnt);
|
}
|
}
|
}
|
//20200825 ljh SWAG-BRY6PF add end
|
//SWAG-BSC5WP you-20201021 start
|
private void setAssetCount(Account2__c acc, String tmpKey, Integer tmpCnt , Map<Id, Account2__c> OldAccount2,Map<String,id> depToOtherDepAcc2Map,
|
Map<Id, Account2__c> updateAccount) {
|
switch on tmpKey {
|
when '01' {acc.Asset_Cnt_CV290__c += tmpCnt;}
|
when '02' {acc.Asset_Cnt_290MiroGI__c += tmpCnt;}
|
when '03' {acc.Asset_Cnt_290MiroGI_Plus__c += tmpCnt;}
|
when '04' {acc.Asset_Cnt_290MiroGI_CF__c += tmpCnt;}
|
when '07' {acc.Asset_Cnt_GFUCT260__c += tmpCnt;}
|
when '05' {acc.Asset_Cnt_EUME2__c += tmpCnt;}
|
when '09' {acc.Asset_Cnt_290MiroBF__c += tmpCnt;}
|
when '14' {acc.Asset_Cnt_OTVS400__c += tmpCnt;}
|
when '15' {acc.Asset_Cnt_OTVS300__c += tmpCnt;}
|
when '16' {acc.Asset_Cnt_CV170__c += tmpCnt;}
|
when '17' {acc.Asset_Cnt_CV190__c += tmpCnt;}
|
when '18' {acc.Asset_Cnt_OTVS190__c += tmpCnt;}
|
when '28' {acc.Asset_Cnt_ESG400__c += tmpCnt;}
|
when '29' {acc.Asset_Cnt_USG400__c += tmpCnt;}
|
when '30' {acc.Asset_Cnt_TB__c += tmpCnt;}
|
when else {
|
system.debug('=====setAssetCount else:' + tmpKey + '_x_' + tmpCnt);
|
}
|
}
|
}
|
//SWAG-BSC5WP you-20201021 end
|
|
// update by vivek SWAG-BQ75WE 2020/06/11 start
|
// 计算重点产品区分
|
private void countImportantProduct(Account2__c acc,String nameType,Decimal tmpCnt,String tmpKey, List<List<String>> modelList,String departmentE,Map<String,id> depToOtherDepAcc2Map,Map<Id, Account2__c> updateAccount,Map<Id, Account2__c> OldAccount2){
|
System.debug('======acc'+acc);
|
System.debug('======nameType'+nameType);
|
System.debug('======tmpCnt'+tmpCnt);
|
System.debug('======tmpKey'+tmpKey);
|
System.debug('======modelList'+modelList);
|
System.debug('======departmentE'+departmentE);
|
System.debug('======depToOtherDepAcc2Map'+depToOtherDepAcc2Map);
|
System.debug('======updateAccount'+updateAccount);
|
System.debug('======OldAccount2'+OldAccount2);
|
|
// 全部计算的科室
|
List<String> allCountDepList = new List<String>();
|
// 不计算的科室
|
List<String> noCountDepList = new List<String>();
|
// 只计算的科室
|
List<String> onlyCountDepList = new List<String>();
|
// 通过编号获取需要更新的字段名称
|
String filedName = filedNameMap.get(tmpKey);
|
System.debug('======filedName'+filedName);
|
if(filedName != null){
|
|
if(modelList.size() == 3){
|
allCountDepList = modelList[0];
|
noCountDepList = modelList[1];
|
onlyCountDepList = modelList[2];
|
}
|
if(allCountDepList.size() == 0 && noCountDepList.size() == 0 && onlyCountDepList.size() == 0){
|
// 都是单独计算的,都计算自己对应的战略科室
|
// Decimal tmpCntOld = (Decimal)acc.get('Delivery_cnt_'+filedName);
|
Decimal tmpCntOld = (Decimal)acc.get(nameType+filedName);
|
if(tmpCntOld == null){
|
// acc.put('Delivery_cnt_'+filedName,tmpCnt);
|
acc.put(nameType+filedName,tmpCnt);
|
}else{
|
// acc.put('Delivery_cnt_'+filedName,tmpCntOld+tmpCnt);
|
acc.put(nameType+filedName,tmpCntOld+tmpCnt);
|
}
|
}else{
|
// 需要判断具体计算哪个战略科室
|
// 如果当前科室在全部计算科室中,计算全部科室中第一个科室。
|
if(allCountDepList.size() > 0 && allCountDepList.contains(departmentE)){
|
Account2__c acc2 = OldAccount2.get(acc.Id);
|
ID depGIId = depToOtherDepAcc2Map.get(acc2.Account_Org__r.parentID+'Department_Class_'+allCountDepList[0]);
|
System.debug('depGIId======'+depGIId);
|
System.debug('======depart:'+'Department_Class_'+allCountDepList[0]);
|
Account2__c acc2Oth = updateAccount.get(depGIId);
|
// Decimal tmpCntOld = (Decimal)acc2Oth.get('Delivery_cnt_'+filedName);
|
Decimal tmpCntOld = (Decimal)acc2Oth.get(nameType+filedName);
|
if(tmpCntOld == null){
|
// acc2Oth.put('Delivery_cnt_'+filedName,tmpCnt);
|
acc2Oth.put(nameType+filedName,tmpCnt);
|
}else{
|
// acc2Oth.put('Delivery_cnt_'+filedName,tmpCntOld+tmpCnt);
|
acc2Oth.put(nameType+filedName,tmpCntOld+tmpCnt);
|
}
|
System.debug(acc2Oth);
|
|
}
|
// 如果当前科室在不计算的科室中,不需要任何操作。
|
|
// 如果当前科室在只计算的科室中,直接计算自己对应的战略科室。
|
else if(onlyCountDepList.size() > 0 && onlyCountDepList.contains(departmentE)){
|
// acc.put('Delivery_cnt_'+filedName, acc.get('Delivery_cnt_'+filedName)+tmpCnt);
|
Decimal tmpCntOld = (Decimal)acc.get(nameType+filedName);
|
if(tmpCntOld == null){
|
// acc.put('Delivery_cnt_'+filedName,tmpCnt);
|
acc.put(nameType+filedName,tmpCnt);
|
}else{
|
// acc.put('Delivery_cnt_'+filedName,tmpCntOld+tmpCnt);
|
acc.put(nameType+filedName,tmpCntOld+tmpCnt);
|
}
|
}
|
}
|
}
|
}
|
|
// 建立重点产品区分计算模型
|
public List<List<String>> getImportantProductModel(String i, String StrType){
|
// filedNameMap 赋值,名称匹配
|
// if(filedNameMap == null){
|
// filedNameMap.clear();
|
if (StrType == '1') {
|
filedNameMap = new Map<String,String>();
|
filedNameMap.put('1', 'CV_290__c');
|
filedNameMap.put('2', '290Miro_GI__c');
|
filedNameMap.put('3', '290Miro_GIPlus__c');
|
filedNameMap.put('4', '290Miro_GICF__c');
|
filedNameMap.put('7', 'GFUCT260__c');
|
// 20210602 SWAG-C3K6L7 Start
|
//filedNameMap.put('5', 'EU_ME2__c');
|
// 20210602 SWAG-C3K6L7 End
|
filedNameMap.put('9', '290Miro_BF__c');
|
filedNameMap.put('14', 'OTV_S400__c');
|
filedNameMap.put('15', 'OTV_S300__c');
|
filedNameMap.put('16', 'CV_170__c');
|
filedNameMap.put('17', 'CV_190__c');
|
// 20210602 SWAG-C3K6L7 Start
|
//filedNameMap.put('18', 'OTV_S190__c');
|
// 20210602 SWAG-C3K6L7 End
|
filedNameMap.put('28', 'ESG400__c');
|
filedNameMap.put('29', 'USG400__c');
|
filedNameMap.put('30', 'TB__c');
|
} else {
|
filedNameMap = new Map<String,String>();
|
filedNameMap.put('1', 'CV290__c');
|
filedNameMap.put('2', '290MiroGI__c');
|
filedNameMap.put('3', '290MiroGI_Plus__c');
|
filedNameMap.put('4', '290MiroGI_CF__c');
|
filedNameMap.put('7', 'GFUCT260__c');
|
// 20210602 SWAG-C3K6L7 Start
|
//filedNameMap.put('5', 'EUME2__c');
|
// 20210602 SWAG-C3K6L7 End
|
filedNameMap.put('9', '290MiroBF__c');
|
filedNameMap.put('14', 'OTVS400__c');
|
filedNameMap.put('15', 'OTVS300__c');
|
filedNameMap.put('16', 'CV170__c');
|
filedNameMap.put('17', 'CV190__c');
|
// 20210602 SWAG-C3K6L7 Start
|
//filedNameMap.put('18', 'OTVS190__c');
|
// 20210602 SWAG-C3K6L7 End
|
filedNameMap.put('28', 'ESG400__c');
|
filedNameMap.put('29', 'USG400__c');
|
filedNameMap.put('30', 'TB__c');
|
// }
|
|
}
|
|
|
// 全部科室简称
|
String departmentBF = 'BF'; // 呼吸科
|
String departmentENT = 'ENT'; // 耳鼻喉科
|
// String departmentET = 'ET'; // ET耗材
|
String departmentGI = 'GI'; // 消化科
|
String departmentGS = 'GS'; // 普外科
|
String departmentGYN = 'GYN'; // 妇科
|
String departmentOTH = 'OTH'; // 其他
|
String departmentURO = 'URO'; // 泌尿科
|
// 全部科室的list
|
List<String> allDepList = new List<String>();
|
allDepList.add(departmentBF);
|
allDepList.add(departmentENT);
|
allDepList.add(departmentGI);
|
allDepList.add(departmentGS);
|
allDepList.add(departmentGYN);
|
allDepList.add(departmentURO);
|
allDepList.add(departmentOTH);
|
List<List<String>> allList = new List<List<String>>();
|
// 全部计算的科室
|
List<String> allCountDepList = new List<String>();
|
// 不计算的科室
|
List<String> noCountDepList = new List<String>();
|
// 只计算的科室
|
List<String> onlyCountDepList = new List<String>();
|
// 20210602 SWAG-C3K6L7 Start
|
//if(i == '1' || i == '5'){
|
if(i == '1'){
|
// 20210602 SWAG-C3K6L7 End
|
// 这里是需要修改的 start
|
allCountDepList.add(departmentGI);
|
// noCountDepList.add() 这里没有不需要计算的科室
|
onlyCountDepList.add(departmentBF);
|
// 这里是需要修改的 end
|
for(String str :allDepList){
|
if(!allCountDepList.contains(str) && !noCountDepList.contains(str) && !onlyCountDepList.contains(str)){
|
allCountDepList.add(str);
|
}
|
}
|
allList.add(allCountDepList);
|
allList.add(noCountDepList);
|
allList.add(onlyCountDepList);
|
}else if(i == '2' || i == '3' || i == '4' || i == '7'){
|
// 这里是需要修改的 start
|
allCountDepList.add(departmentGI);
|
// noCountDepList.add() 这里没有不需要计算的科室
|
// onlyCountDepList.add(departmentBF); 这里也没有直接算的科室,都算在消化科里
|
// 这里是需要修改的 end
|
for(String str :allDepList){
|
if(!allCountDepList.contains(str) && !noCountDepList.contains(str) && !onlyCountDepList.contains(str)){
|
allCountDepList.add(str);
|
}
|
}
|
allList.add(allCountDepList);
|
allList.add(noCountDepList);
|
allList.add(onlyCountDepList);
|
}else if(i == '9'){
|
// 这里是需要修改的 start
|
allCountDepList.add(departmentBF); // 都计算在呼吸科里
|
// noCountDepList.add() 这里没有不需要计算的科室
|
// onlyCountDepList.add(departmentBF); 这里也没有直接算的科室,都算在呼吸科里
|
// 这里是需要修改的 end
|
for(String str :allDepList){
|
if(!allCountDepList.contains(str) && !noCountDepList.contains(str) && !onlyCountDepList.contains(str)){
|
allCountDepList.add(str);
|
}
|
}
|
allList.add(allCountDepList);
|
allList.add(noCountDepList);
|
allList.add(onlyCountDepList);
|
// 20210602 SWAG-C3K6L7 Start
|
//}else if(i == '14' || i == '15' || i == '17' || i == '18' || i == '29' || i == '28' || i == '30'){
|
} else if(i == '14' || i == '15' || i == '17' || i == '29' || i == '28' || i == '30'){
|
// 20210602 SWAG-C3K6L7 End
|
// 这里是需要修改的 start
|
allCountDepList.add(departmentGS); // 都计算在普外科里
|
// noCountDepList.add() 这里没有不需要计算的科室
|
onlyCountDepList.add(departmentGYN); //这里也没有直接算的科室,都算在呼吸科里
|
onlyCountDepList.add(departmentENT);
|
onlyCountDepList.add(departmentURO);
|
// 这里是需要修改的 end
|
for(String str :allDepList){
|
if(!allCountDepList.contains(str) && !noCountDepList.contains(str) && !onlyCountDepList.contains(str)){
|
allCountDepList.add(str);
|
}
|
}
|
allList.add(allCountDepList);
|
allList.add(noCountDepList);
|
allList.add(onlyCountDepList);
|
}else if(i == '16'){
|
// 这里是需要修改的 start
|
allCountDepList.add(departmentGS); // 都计算在普外科里
|
noCountDepList.add(departmentBF); // 这里不包含呼吸科
|
noCountDepList.add(departmentGI); // 这里不包含消化科
|
// onlyCountDepList.add(departmentBF); // 这里没有只计算的内容
|
onlyCountDepList.add(departmentGYN); //这里也没有直接算的科室,都算在呼吸科里
|
onlyCountDepList.add(departmentENT);
|
onlyCountDepList.add(departmentURO);
|
// 这里是需要修改的 end
|
for(String str :allDepList){
|
if(!allCountDepList.contains(str) && !noCountDepList.contains(str) && !onlyCountDepList.contains(str)){
|
allCountDepList.add(str);
|
}
|
}
|
allList.add(allCountDepList);
|
allList.add(noCountDepList);
|
allList.add(onlyCountDepList);
|
}else{
|
// 都是直接计算自己对应的战略科室下
|
allList.add(allCountDepList);
|
allList.add(noCountDepList);
|
allList.add(onlyCountDepList);
|
}
|
return allList;
|
}
|
// update by vivek SWAG-BQ75WE 2020/06/11 end
|
|
private void setOpdCount(Account2__c acc, String tmpKey, Decimal tmpCnt , Map<Id, Account2__c> OldAccount2,Map<String,id> depToOtherDepAcc2Map,
|
Map<Id, Account2__c> updateAccount) {
|
|
List<List<String>> allList = new List<List<String>>();
|
allList = getImportantProductModel(tmpKey, '1');
|
Account2__c acc2 = OldAccount2.get(acc.Id);
|
String nameType = 'Opd_';
|
String departmentE = acc2.Account_Org__r.RecordType_DeveloperName__c.substring(17);
|
countImportantProduct(acc,nameType,tmpCnt,tmpKey,allList,departmentE,depToOtherDepAcc2Map, updateAccount, OldAccount2);
|
|
}
|
}
|