public with sharing class SetPersonalTargetController {
|
// 当前期
|
public String currentPeriod { get; private set; }
|
public String currentPeriodOld;//20210225 ljh WLIG-BV8CHF add 财年
|
// 上年度按钮制御
|
public Boolean previousRendered { get; private set; }
|
// 下年度按钮制御
|
public Boolean nextRendered { get; private set; }
|
// 数据集
|
public List<DataBean> dataBeans { get; set; }
|
// 金额分类
|
public List<String> opportunity_category { get; private set; }
|
// 是否是过去年度
|
public Boolean isPast { get; private set; }
|
// 年度変化時セーブかどうか
|
public Boolean saveFlg { get; set; }
|
// 本部の選択値
|
public String salesDpt { get; set; }
|
// 職位のチェックボックス
|
public List<Position> plist { get; set; }
|
// 登陆用户
|
public User loginUser { get; set; }
|
// checkAll値保持用
|
public Boolean checkAll { get; set; }
|
// 製品担当の選択値
|
public String productUser { get; set; }
|
|
// 医院担当 プルダウン
|
public static List<SelectOption> productUserOptions { get; private set; }
|
static {
|
productUserOptions = new List<SelectOption>();
|
//wangweipeng SWAG-C6V8W5 2021/09/16 start
|
productUserOptions.add(new SelectOption('', 'All'));
|
//wangweipeng SWAG-C6V8W5 2021/09/16 end
|
productUserOptions.add(new SelectOption('医院担当', '医院担当'));
|
productUserOptions.add(new SelectOption('医院担当以外', '医院担当以外'));
|
}
|
|
public SetPersonalTargetController() {
|
//Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');
|
}
|
|
// ユーザ数
|
public Integer getUserSize() {
|
return users.size();
|
}
|
// 職位数
|
public Integer getPSize() {
|
return plist.size();
|
}
|
// 本部プルダウン
|
public static List<SelectOption> salesDptOpts { get; private set; }
|
static {
|
salesDptOpts = new List<SelectOption>();
|
salesDptOpts.add(new SelectOption('', '--无--'));
|
salesDptOpts.add(new SelectOption('1.华北', '1.华北'));
|
salesDptOpts.add(new SelectOption('2.东北', '2.东北'));
|
salesDptOpts.add(new SelectOption('3.西北', '3.西北'));
|
salesDptOpts.add(new SelectOption('4.西南', '4.西南'));
|
salesDptOpts.add(new SelectOption('5.华东', '5.华东'));
|
salesDptOpts.add(new SelectOption('6.华南', '6.华南'));
|
}
|
|
// 职种
|
public static List<SelectOption> userJobCategorys { get; private set; }
|
static {
|
userJobCategorys = new List<SelectOption>();
|
userJobCategorys.add(new SelectOption('', '--无--'));
|
userJobCategorys.add(new SelectOption('销售推广', '销售推广'));
|
userJobCategorys.add(new SelectOption('销售市场', '销售市场'));
|
}
|
|
// 现在年度
|
private Integer currentYear;
|
// 当前年度
|
private Integer iYear;
|
// 当前月份
|
private Integer iMonth;
|
// 当前日期
|
private Integer iDay;
|
// 4月可编辑期限
|
private Integer iBuffer;
|
|
private RecordType rt; // 目标的数据类型
|
private User[] users; // 担当人员
|
private Map<String, List<Double>> proportion; // 比重
|
private String adminDpt = null;
|
|
//2020/06/05 SWAG-BQ7CM9 中间表既存数据 by ljh
|
private Map<String, Amount_Major_Product__c> Amount_Major_ProductMap;
|
|
|
|
// 既存目标数据
|
private Map<String, Opportunity> oppMap;
|
private Map<Id, OpportunityLineItem> oliMap;//20200605 add
|
// 金额分类
|
//private static String[] amountCategory = new String[] {'GI','ET','BF','GS','URO','GYN','ENT','OTH'};
|
// 个人目标(SetPersonalTarget):隐藏OTH。
|
// CHAN-BBLCYP 20190509 LHJ Start
|
//private static String[] amountCategory = new String[] {'GI','ET','BF','GS','URO','GYN','ENT'};
|
private static String[] amountCategory = new String[] {'GI', 'ET', 'BF', 'GS', 'URO', 'GYN', 'ENT', 'ENG'};
|
// CHAN-BBLCYP 20190509 LHJ End
|
|
//CHAN-BDQBLX 20210125 you start
|
private List<Amount_Major_Product__c> upsertAMPList ;//= new List<Amount_Major_Product__c>();
|
private Map<String, Amount_Major_Product__c> Amount_Major_ProductMap1;
|
public Boolean isFlg { get; set; }//判断走哪个查询方法
|
public Boolean isFlg1 { get; set; }
|
//public Blob csvFileBody {get; set;}
|
public string csvAsString {get; set;}
|
public String[] csvFileLines {get; set;}
|
//wangweipeng 20210616 新加负责产品分类(兼) 导出导入表头
|
private static String[] titlepage = new String[] {'本部', '省', '角色', '担当', '职位', '负责产品分类(主)', '负责产品分类(兼)', 'GI', 'ET', 'BF', 'GS', 'URO', 'GYN', 'ENT', 'ENG'};
|
|
public Integer detailCountLimit{get;private set;}
|
//CHAN-BDQBLX 20210125 you end
|
|
// 画面初始化
|
public Pagereference init() {
|
// 现在时间
|
Date dateNow = Date.today();
|
Integer year = dateNow.year();
|
Integer month = dateNow.month();
|
//CHAN-BDQBLX 20210125 you start
|
Amount_Major_ProductMap1 = new Map<String, Amount_Major_Product__c>();
|
upsertAMPList = new List<Amount_Major_Product__c>();
|
detailCountLimit = 10000;
|
//CHAN-BDQBLX 20210125 you end
|
if (month < 4) {
|
year -= 1;
|
}
|
// 初始化
|
currentYear = year;
|
iYear = year;
|
iMonth = month;
|
iDay = dateNow.day();
|
iBuffer = Integer.valueOf(System.Label.SetPersonalTarget_buffer_day);
|
isPast = false;
|
// if (month == 3) isPast = true;
|
//20210225 ljh WLIG-BV8CHF update 财年 start
|
//currentPeriod = String.valueOf(iYear - 1867 + 'P');
|
currentPeriodOld = String.valueOf(iYear - 1867 + 'P');
|
Integer tempiYear = iYear+1;
|
currentPeriod = String.valueOf('FY'+tempiYear);
|
//20210225 ljh WLIG-BV8CHF update 财年 end
|
previousRendered = true;
|
nextRendered = true;
|
saveFlg = false;
|
// 金额分类
|
opportunity_category = amountCategory;
|
|
// 每月比重
|
if (proportion == null) {
|
proportion = new Map<String, List<Double>>();
|
String strObjectiveProportionGI = System.Label.ObjectiveProportionGI;
|
List<String> objectiveProportionGI = strObjectiveProportionGI.split(',');
|
List<Double> doubleGI = new List<Double>();
|
for (String strGI : objectiveProportionGI) {
|
doubleGI.add(Double.valueOf(strGI));
|
}
|
proportion.put('GI', doubleGI);
|
|
String strObjectiveProportionET = System.Label.ObjectiveProportionET;
|
List<String> objectiveProportionET = strObjectiveProportionET.split(',');
|
List<Double> doubleET = new List<Double>();
|
for (String strET : objectiveProportionET) {
|
doubleET.add(Double.valueOf(strET));
|
}
|
proportion.put('ET', doubleET);
|
|
String strObjectiveProportionBF = System.Label.ObjectiveProportionBF;
|
List<String> objectiveProportionBF = strObjectiveProportionBF.split(',');
|
List<Double> doubleBF = new List<Double>();
|
for (String strBF : objectiveProportionBF) {
|
doubleBF.add(Double.valueOf(strBF));
|
}
|
proportion.put('BF', doubleBF);
|
|
String strObjectiveProportionGS = System.Label.ObjectiveProportionGS;
|
List<String> objectiveProportionGS = strObjectiveProportionGS.split(',');
|
List<Double> doubleGS = new List<Double>();
|
for (String strGS : objectiveProportionGS) {
|
doubleGS.add(Double.valueOf(strGS));
|
}
|
proportion.put('GS', doubleGS);
|
|
String strObjectiveProportionURO = System.Label.ObjectiveProportionURO;
|
List<String> objectiveProportionURO = strObjectiveProportionURO.split(',');
|
List<Double> doubleURO = new List<Double>();
|
for (String strURO : objectiveProportionURO) {
|
doubleURO.add(Double.valueOf(strURO));
|
}
|
proportion.put('URO', doubleURO);
|
|
String strObjectiveProportionGYN = System.Label.ObjectiveProportionGYN;
|
List<String> objectiveProportionGYN = strObjectiveProportionGYN.split(',');
|
List<Double> doubleGYN = new List<Double>();
|
for (String strGYN : objectiveProportionGYN) {
|
doubleGYN.add(Double.valueOf(strGYN));
|
}
|
proportion.put('GYN', doubleGYN);
|
|
String strObjectiveProportionENT = System.Label.ObjectiveProportionENT;
|
List<String> objectiveProportionENT = strObjectiveProportionENT.split(',');
|
List<Double> doubleENT = new List<Double>();
|
for (String strENT : objectiveProportionENT) {
|
doubleENT.add(Double.valueOf(strENT));
|
}
|
proportion.put('ENT', doubleENT);
|
|
String strObjectiveProportionOTH = System.Label.ObjectiveProportionOTH;
|
List<String> objectiveProportionOTH = strObjectiveProportionOTH.split(',');
|
List<Double> doubleOTH = new List<Double>();
|
for (String strOTH : objectiveProportionOTH) {
|
doubleOTH.add(Double.valueOf(strOTH));
|
}
|
proportion.put('OTH', doubleOTH);
|
|
String strObjectiveProportionENG = System.Label.ObjectiveProportionENG;
|
List<String> objectiveProportionENG = strObjectiveProportionENG.split(',');
|
List<Double> doubleENG = new List<Double>();
|
for (String strENG : objectiveProportionENG) {
|
doubleENG.add(Double.valueOf(strENG));
|
}
|
proportion.put('ENG', doubleENG);
|
}
|
// 職位
|
if (plist == null) {
|
plist = new List<Position>();
|
plist.add(new Position('一般', true));
|
plist.add(new Position('高级', true));
|
plist.add(new Position('主管', true));
|
//20220402 lt SWAG-CD28H3 【委托】【期初修改4月6日开始修改】目标录入相关判断修改 start
|
// plist.add(new Position('副经理', true));
|
// plist.add(new Position('经理', false));
|
// plist.add(new Position('副部长', false));
|
// plist.add(new Position('部长', false));
|
plist.add(new Position('经理级', true));
|
plist.add(new Position('总监级', false));
|
//20220402 lt SWAG-CD28H3 【委托】【期初修改4月6日开始修改】目标录入相关判断修改 start
|
}
|
|
// 当前用户信息
|
if (loginUser == null) {
|
loginUser = [Select Id, Salesdepartment__c, Province__c, ProfileId, Job_Category__c From User where Id = :Userinfo.getUserId()];
|
loginUser.Job_Category__c = null;
|
}
|
adminDpt = loginUser.Salesdepartment__c;
|
if (String.isBlank(adminDpt)
|
&& (loginUser.ProfileId == System.Label.ProfileId_SystemAdmin
|
|| loginUser.ProfileId == System.Label.ProfileId_103
|
)
|
) {
|
adminDpt = '4.华东';
|
}
|
//repFlg =adminDpt;
|
// province = loginUser.Province__c;
|
users = this.getUserList(false, false, true);
|
//CHAN-BDQBLX 20210125 you start
|
isFlg1=true;
|
//CHAN-BDQBLX 20210125 you end
|
// 目标的数据类型
|
if (rt == null) {
|
rt = [select Id from RecordType where SobjectType = 'Opportunity' and IsActive = true and DeveloperName = 'Target'];
|
}
|
// 数据赋值
|
setBean(iYear);
|
// 保存成功のメッセージ
|
String s = System.currentPageReference().getParameters().get('s');
|
if (s == '1') {
|
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, '保存成功。'));
|
}
|
return null;
|
}
|
|
// 点击上年度
|
public void previous() {
|
if (saveFlg) {
|
this.saveLogic();
|
}
|
|
iYear -= 1;
|
//20210225 ljh WLIG-BV8CHF update 财年 start
|
//currentPeriod = String.valueOf(iYear - 1867 + 'P');
|
currentPeriodOld = String.valueOf(iYear - 1867 + 'P');
|
Integer tempiYear = iYear+1;
|
currentPeriod = String.valueOf('FY'+tempiYear);
|
//20210225 ljh WLIG-BV8CHF update 财年 end
|
// 是否是过去数据
|
isPast = false;
|
if (iYear < currentYear && !(currentYear - iYear == 1 && iMonth == 4 && iDay <= iBuffer)) {
|
isPast = true;
|
}// else if (iYear == currentYear) {
|
// if (Date.today().month() == 3) {
|
// isPast = true;
|
// }
|
// }
|
previousRendered = true;
|
nextRendered = true;
|
// 数据赋值
|
setBean(iYear);
|
}
|
|
// 点击下年度
|
public void next() {
|
if (saveFlg) {
|
this.saveLogic();
|
}
|
|
iYear += 1;
|
//20210225 ljh WLIG-BV8CHF update 财年 start
|
//currentPeriod = String.valueOf(iYear - 1867 + 'P');
|
currentPeriodOld = String.valueOf(iYear - 1867 + 'P');
|
Integer tempiYear = iYear+1;
|
currentPeriod = String.valueOf('FY'+tempiYear);
|
//20210225 ljh WLIG-BV8CHF update 财年 end
|
// 是否是过去数据
|
isPast = false;
|
if (iYear < currentYear && !(currentYear - iYear == 1 && iMonth == 4 && iDay <= iBuffer)) {
|
isPast = true;
|
}// else if (iYear == currentYear) {
|
// if (Date.today().month() == 3) {
|
// isPast = true;
|
// }
|
// }
|
previousRendered = true;
|
nextRendered = true;
|
// 只显示到现在时间的下一年数据
|
if (iYear > currentYear) {
|
nextRendered = false;
|
}
|
// 数据赋值
|
setBean(iYear);
|
}
|
|
// 本部プルダウン変更時の処理、システム管理者専用
|
public void searchByDpt() {
|
if (saveFlg) {
|
this.saveLogic();
|
}
|
//CHAN-BDQBLX 20210125 you start
|
isFlg = true;
|
isFlg1=false;
|
//CHAN-BDQBLX 20210125 you end
|
users = this.getUserList(true, false, false);
|
// 数据赋值
|
setBean(iYear);
|
}
|
|
// 省プルダウン変更時の処理
|
public void searchByProvince() {
|
if (saveFlg) {
|
this.saveLogic();
|
}
|
//CHAN-BDQBLX 20210125 you start
|
isFlg = false;
|
isFlg1= false;
|
//CHAN-BDQBLX 20210125 you end
|
users = this.getUserList(false, true, false);
|
// 数据赋值
|
setBean(iYear);
|
}
|
|
// 職位変更時の処理
|
public void searchByFilter() {
|
if (saveFlg) {
|
this.saveLogic();
|
}
|
users = this.getUserList(false, false, false);
|
//CHAN-BDQBLX 20210125 you start
|
isFlg1=false;
|
//CHAN-BDQBLX 20210125 you end
|
// 数据赋值
|
setBean(iYear);
|
}
|
//CHAN-BDQBLX 20210125 you start 导出方法
|
public Pagereference exportBycsv() {
|
system.debug('isFlg==' + isFlg);
|
boolflag(isFlg1,isFlg);//判断执行哪个查询得方法
|
|
system.debug('进来了');
|
return page.SetPersonalTargetcsv;
|
}
|
//导入方法
|
public PageReference importCSVFile() {
|
|
try {
|
String csvData = ApexPages.currentPage().getParameters().get('csvData');
|
// 将内容转换成为中文
|
if(!Test.isRunningTest()){
|
//csvAsString = bitToString(csvFileBody, 'gb2312');
|
csvAsString = csvData;
|
system.debug('==csvAsString=='+csvAsString);
|
}
|
// 拆成每一行
|
csvFileLines = csvAsString.split('\n');
|
system.debug(csvFileLines.size());
|
Boolean ValFlag = false;
|
String exportByVal = '';
|
ApexPages.Message successMsg = new ApexPages.Message(ApexPages.severity.INFO, '');
|
// 需要根据情况来解析,查看表头是否一致
|
if (csvFileLines.size() > 0) {
|
string[] titlecsv = csvFileLines[0].trim().split(',');//
|
system.debug(titlecsv + '==titlepage==' + titlepage);
|
for (integer j = 0; j < titlecsv.size(); j++) {
|
if (!titlepage.contains(titlecsv[j])) {
|
system.debug('表头不一致得列===' + titlecsv[j]);
|
ValFlag = true;
|
exportByVal = '表头不一致,请严格按照导出模板填写';
|
break;
|
}
|
|
|
}
|
|
}
|
if (ValFlag) {
|
successMsg = new ApexPages.Message(ApexPages.severity.INFO, exportByVal);
|
ApexPages.addMessage(successMsg);
|
|
} else {
|
List<String> UserInfoList = new List<String>();
|
Map<String, List<String>> szMap = new Map<String, List<String>>();
|
Set<String> sfs = new Set<String>();//省份
|
Set<String> bus = new Set<String>();//本部
|
Set<String> zws = new Set<String>();//职位
|
Set<String> yydds = new Set<String>();//医院担当
|
Set<String> zzs = new Set<String>();//职种
|
|
for (Integer i = 1; i < csvFileLines.size(); i++) {
|
string[] csvRecordData = csvFileLines[i].split(',');
|
if (csvRecordData.size() > 0) {
|
String bu = csvRecordData[0].replace(' ', '');
|
String sf = csvRecordData[1].replace(' ', '');
|
String dandang = csvRecordData[3].replace(' ', '');
|
String zw = csvRecordData[4].replace(' ', '');
|
UserInfoList.add(bu + sf + dandang + zw);
|
szMap.put(bu + sf + dandang + zw, csvRecordData);
|
sfs.add(sf);//把省份放进去
|
bus.add(bu);//本部
|
zws.add(zw);//职位
|
|
}
|
}
|
if (null != sfs && sfs.size() > 0) {
|
this.getAmount_Major_Product(sfs);//根据省份年份,获取当前系统中已经存在得数据 放到map中
|
|
}
|
List<User> userList = new List<User>();
|
System.debug('==UserInfoList=='+UserInfoList);
|
if (null != UserInfoList && UserInfoList.size() > 0) {
|
userList = this.getUserList(UserInfoList);//返回用户得一些信息
|
}
|
Map<String, User> userMap = new Map<String, User>();
|
for (User userl : userList) {
|
yydds.add(userl.Sales_Speciality__c);//医院担当
|
zzs.add(userl.Job_Category__c);//职种
|
userMap.put(userl.UserInfos__c, userl);
|
|
}
|
Integer GI_Number = 7;
|
Integer ET_Number = 8;
|
Integer BF_Number = 9;
|
Integer GS_Number = 10;
|
Integer URO_Number = 11;
|
Integer GYN_Number = 12;
|
Integer ENT_Number = 13;
|
Integer ENG_Number = 14;
|
|
upsertAMPList = new List<Amount_Major_Product__c>();//初始化,解决重复导入数据 id重复得问题
|
for (String key : szMap.keySet()) {
|
//取用户的Id
|
String userid = '';
|
User userinfors=new User();
|
if (userMap.containskey(key)) {
|
userid = userMap.get(key).Id;
|
userinfors = userMap.get(key);
|
} else {
|
System.debug('==key==='+key);
|
//用户不存在要提醒
|
continue;
|
}
|
|
|
List<String> csvRecordData = szMap.get(key);
|
Amount_Major_Product__c upsertAMP = new Amount_Major_Product__c();
|
//获取导入数量
|
Decimal GI_Amount = String.isNotBlank(csvRecordData[GI_Number]) ? Decimal.valueof(csvRecordData[GI_Number]) : 0.00;
|
|
DataSplicing(GI_Amount,userid + '_GI',Amount_Major_ProductMap1,userinfors);
|
|
Decimal ET_Amount = String.isNotBlank(csvRecordData[ET_Number]) ? Decimal.valueOf(csvRecordData[ET_Number]) : 0.00;
|
DataSplicing(ET_Amount,userid + '_ET',Amount_Major_ProductMap1,userinfors);
|
|
Decimal BF_Amount = String.isNotBlank(csvRecordData[BF_Number]) ? Decimal.valueOf(csvRecordData[BF_Number]) : 0.00;
|
DataSplicing(BF_Amount,userid + '_BF',Amount_Major_ProductMap1,userinfors);
|
|
Decimal GS_Amount = String.isNotBlank(csvRecordData[GS_Number]) ? Decimal.valueOf(csvRecordData[GS_Number]) : 0.00;
|
DataSplicing(GS_Amount,userid + '_GS',Amount_Major_ProductMap1,userinfors);
|
|
Decimal URO_Amount = String.isNotBlank(csvRecordData[URO_Number]) ? Decimal.valueOf(csvRecordData[URO_Number]) : 0.00;
|
DataSplicing(URO_Amount,userid + '_URO',Amount_Major_ProductMap1,userinfors);
|
|
Decimal GYN_Amount = String.isNotBlank(csvRecordData[GYN_Number]) ? Decimal.valueOf(csvRecordData[GYN_Number]) : 0.00;
|
DataSplicing(GYN_Amount,userid + '_GYN',Amount_Major_ProductMap1,userinfors);
|
|
Decimal ENT_Amount = String.isNotBlank(csvRecordData[ENT_Number]) ? Decimal.valueOf(csvRecordData[ENT_Number]) : 0.00;
|
DataSplicing(ENT_Amount,userid + '_ENT',Amount_Major_ProductMap1,userinfors);
|
system.debug('ENG_Number--->'+csvRecordData[ENG_Number]);
|
//因为最后一列数据有空格,所以加.trim()
|
Decimal ENG_Amount = String.isNotBlank(csvRecordData[ENG_Number]) ? Decimal.valueOf(csvRecordData[ENG_Number].trim()) : 0.00;
|
// Decimal.valueOf(String str)
|
DataSplicing(ENG_Amount,userid + '_ENG',Amount_Major_ProductMap1,userinfors);
|
|
|
|
//拼接Key
|
}
|
|
if(null!=upsertAMPList && upsertAMPList.size()>0){
|
upsert upsertAMPList;
|
}
|
|
system.debug('==UserInfoList==' + UserInfoList + '==' + userList);
|
boolflag(isFlg1,isFlg);
|
|
successMsg = new ApexPages.Message(ApexPages.severity.INFO, '导入成功');
|
ApexPages.addMessage(successMsg);
|
}
|
|
|
|
|
} catch (Exception e) {
|
ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR, e.getMessage());
|
ApexPages.addMessage(errorMessage);
|
}
|
return null;
|
}
|
// 最终得数据处理,
|
private void DataSplicing(Decimal amount, String key, Map<String, Amount_Major_Product__c> ampMap,User userinfors ) {//去进行最终数据得插入,更新或删除操作
|
Amount_Major_Product__c upsertAMP = new Amount_Major_Product__c();
|
Amount_Major_Product__c Amount_Major_Product = Amount_Major_ProductMap.get(key);
|
system.debug('==amount=='+amount+'==key=='+key+'==ampMap=='+ampMap+'==userinfors=='+userinfors+'\n');
|
if (ampMap.containskey(key)) {
|
upsertAMP = ampMap.get(key);
|
if (amount > 0) {
|
if(amount!=upsertAMP.Amount__c){
|
upsertAMP.Amount__c = amount;
|
upsertAMP.Use_Start_Date__c = userinfors.Use_Start_Date__c;
|
upsertAMP.Is_Processing__c = true;
|
upsertAMPList.add(upsertAMP);
|
//更新
|
}
|
|
} else {
|
//不用删除了,允许 数据是空的存在
|
upsertAMP.Amount__c = null;
|
upsertAMP.Is_Processing__c = true;
|
upsertAMPList.add(upsertAMP);
|
}
|
} else {
|
if (amount > 0) {
|
upsertAMP.Amount__c = amount;
|
upsertAMP.key__c = key;
|
upsertAMP.user_Alias__c = userinfors.Alias;
|
upsertAMP.SAP_Province__c = userinfors.Province__c;
|
upsertAMP.Use_Start_Date__c = userinfors.Use_Start_Date__c;
|
upsertAMP.iYear__c = iYear;
|
upsertAMP.Is_Processing__c = true;
|
upsertAMPList.add(upsertAMP);
|
} else {
|
//允许 数据是空的存在
|
upsertAMP.Amount__c = null;
|
upsertAMP.key__c = key;
|
upsertAMP.user_Alias__c = userinfors.Alias;
|
upsertAMP.SAP_Province__c = userinfors.Province__c;
|
upsertAMP.Use_Start_Date__c = userinfors.Use_Start_Date__c;
|
upsertAMP.iYear__c = iYear;
|
upsertAMP.Is_Processing__c = true;
|
upsertAMPList.add(upsertAMP);
|
}
|
}
|
|
}
|
|
|
|
private void getAmount_Major_Product(Set<String> sfs) {//根据省份年份,获取当前系统中已经存在得数据
|
Amount_Major_ProductMap1 = new Map<String, Amount_Major_Product__c>();
|
|
list<Amount_Major_Product__c> Existed_Amount_Major_Products = [select key__c, Amount__c, user_Alias__c,
|
Is_Processing__c, iYear__c from Amount_Major_Product__c where iYear__c = : iYear and SAP_Province__c in :sfs];
|
//system.debug('Existed_Amount_Major_Products' + Existed_Amount_Major_Products);
|
|
for ( Amount_Major_Product__c Amount_Major_Product : Existed_Amount_Major_Products ) {
|
if (String.isBlank(Amount_Major_Product.key__c)) {
|
continue;
|
}
|
|
Amount_Major_ProductMap1.put(Amount_Major_Product.key__c, Amount_Major_Product);
|
|
}
|
}
|
private List<User> getUserList(List<String> UserInfoList) {//根据上传文件中得本部,省份,担当,职位 得到了user 信息
|
String soql = 'select Id, UserInfos__c, Salesdepartment__c, Province__c, Alias, Product_specialist_incharge_product__c,Responsible_for_Products_Concurrently__c, Use_Start_Date__c,'
|
+ ' ProfileId, Profile.Name, UserRoleId, UserRole.Name, Sales_Speciality__c, Post__c,Job_Category__c'
|
+ ' from User where IsActive = true and Test_staff__c = false and UserType = \'Standard\' '
|
+ ' and Salesdepartment__c <> \'7.能量\' '
|
+ ' and UserInfos__c IN :UserInfoList order by Salesdepartment__c, Province__c';
|
System.debug('==soql==' + soql);
|
return Database.query(soql);
|
}
|
private void boolflag(Boolean isFlg1, Boolean isFlg) {//判断走哪个查询方法,进行导出数据
|
if(isFlg1!=null && isFlg1){
|
system.debug('初始化');
|
users = this.getUserList(false, false, true);
|
}else if (isFlg != null && isFlg) {
|
system.debug('进1');
|
users = this.getUserList(true, false, false);
|
} else if ( isFlg != null && !isFlg) {
|
system.debug('进2');
|
users = this.getUserList(false, true, false);
|
} else {
|
system.debug('进3');
|
users = this.getUserList(false, false, false);
|
}
|
// 数据赋值
|
setBean(iYear);
|
}
|
/**
|
以前是这样写,现在改成在js里面处理 中文乱码得问题
|
csvAsString = bitToString(csvFileBody, 'gb2312');
|
public static String bitToString(Blob input, String inCharset) {
|
//转换成16进制
|
String hex = EncodingUtil.convertToHex(input);
|
//一个String类型两个字节 32位(bit),则一个String长度应该为两个16进制的长度,所以此处向右平移一个单位,即除以2
|
//向右平移一个单位在正数情况下等同于除以2,负数情况下不等
|
//eg 9 00001001 >>1 00000100 结果为49
|
final Integer bytesCount = hex.length() >> 1;
|
// //声明String数组,长度为16进制转换成字符串的长度1
|
String[] bytes = new String[bytesCount];
|
for (Integer i = 0; i < bytesCount; ++i) {
|
//将相邻两位的16进制字符串放在一个String中
|
bytes[i] = hex.mid(i << 1, 2);
|
}
|
//解码成指定charset的字符串
|
return EncodingUtil.urlDecode('%' + String.join(bytes, '%'), inCharset);
|
|
}
|
**/
|
//CHAN-BDQBLX 20210125 you end
|
// 点击保存按钮
|
public Pagereference saveBtn() {
|
this.saveLogic();
|
PageReference ref = new Pagereference('/apex/SetPersonalTarget?s=1');
|
ref.setRedirect(true);
|
return ref;
|
}
|
// 2020/06/05 SWAG-BQ7CM9 点击更新按钮 by ljh
|
public Pagereference UpdateBtn() {
|
system.debug('=====UpdateBtn-1');
|
Boolean rs = saveLogic();
|
setBean(iYear);
|
Id execBTId = Database.executeBatch(new SetPersonalTargetBatch(), 20);
|
system.debug('===execBTId===' + execBTId);
|
if (rs && String.isNotBlank(execBTId)) {
|
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, '反映到目标成功'));
|
}
|
return null;
|
}
|
|
// 点击返回按钮
|
public Pagereference backBtn() {
|
// HOMEに戻る
|
PageReference ref = new Pagereference('/home/home.jsp');
|
ref.setRedirect(true);
|
return ref;
|
}
|
// 2020/06/05 SWAG-BQ7CM9 从中间表获取既有数据,并以key__c为key存入map中 by ljh
|
//String key = opp.OwnerId + '_' + opp.Opportunity_Category__c ;
|
private boolean getAmount_Major_Productmap() {
|
Amount_Major_ProductMap = new Map<String, Amount_Major_Product__c>();
|
if (getUserSize() == 0) {
|
return false;
|
}
|
|
list<Amount_Major_Product__c> Existed_Amount_Major_Products = [select key__c, Amount__c, user_Alias__c,
|
Is_Processing__c, iYear__c from Amount_Major_Product__c where iYear__c = : iYear ];
|
//system.debug('Existed_Amount_Major_Products' + Existed_Amount_Major_Products);
|
if (Existed_Amount_Major_Products.size() <= 0 ) {
|
return false;
|
}
|
for ( Amount_Major_Product__c Amount_Major_Product : Existed_Amount_Major_Products ) {
|
if (String.isBlank(Amount_Major_Product.key__c)) {
|
continue;
|
}
|
// 2020/06/05 SWAG-BQ7CM9 仅获取当前用户数据存入map中 start by ljh
|
boolean flag = false;
|
for (User user : users) {
|
if (user.Alias.equals(Amount_Major_Product.user_Alias__c)) {
|
flag = true;
|
break;
|
}
|
}
|
if (flag) {
|
Amount_Major_ProductMap.put(Amount_Major_Product.key__c, Amount_Major_Product);
|
}
|
// 2020/06/05 SWAG-BQ7CM9 仅获取当前用户数据存入map中 start by ljh
|
}
|
//ApexPages.addmessage(new ApexPages.message('aa'));
|
//'Amount_Major_ProductMap' + Amount_Major_ProductMap.keySet()
|
return true;
|
}
|
|
// ユーザの検索
|
private List<User> getUserList(Boolean searchByDpt, Boolean searchByProvince, Boolean defaultSearch) {
|
String soql = 'select Id, Salesdepartment__c, Province__c, Alias, Product_specialist_incharge_product__c,Responsible_for_Products_Concurrently__c, Use_Start_Date__c,'
|
+ ' ProfileId, Profile.Name, UserRoleId, UserRole.Name, Sales_Speciality__c, Post__c'
|
+ ' from User where IsActive = true and Test_staff__c = false and UserType = \'Standard\' '
|
// CHAN-BBLCYP 20190509 LHJ Start
|
+ ' and Salesdepartment__c <> \'7.能量\' ';
|
// CHAN-BBLCYP 20190509 LHJ End
|
|
//wangweipeng SWAG-C6V8W5 2021/09/16 start
|
/*if (String.isBlank(productUser) || productUser == '医院担当') {
|
soql += ' and Sales_Speciality__c = \'医院担当\'';
|
} else {
|
soql += ' and Sales_Speciality__c <> \'医院担当\'';
|
}*/
|
if (productUser == '医院担当') {
|
soql += ' and Sales_Speciality__c = \'医院担当\'';
|
} else if(productUser == '医院担当以外') {
|
soql += ' and Sales_Speciality__c <> \'医院担当\'';
|
}
|
//wangweipeng SWAG-C6V8W5 2021/09/16 end
|
|
// 职种
|
if (defaultSearch || String.isBlank(loginUser.Job_Category__c)) {
|
soql += ' and (Job_Category__c = \'销售推广\' or Job_Category__c = \'销售市场\')';
|
} else {
|
soql += ' and Job_Category__c = \'' + loginUser.Job_Category__c + '\'';
|
}
|
// 本部にて検索の場合、省を無視
|
if (searchByDpt) {
|
loginUser.Province__c = null;
|
// 省にて検索の場合、本部を無視
|
} else if (searchByProvince) {
|
salesDpt = null;
|
// 職位にて検索の場合
|
} else {}
|
system.debug('==defaultSearch==' + defaultSearch + '==本部==' + searchByDpt + '==salesDpt=本部=' + salesDpt + '==省==' + searchByProvince + '==loginUser.Province__c==' + loginUser.Province__c + '==adminDpt==' + adminDpt);
|
if (!String.isBlank(salesDpt)) {
|
soql += ' and Salesdepartment__c = \'' + salesDpt + '\'';
|
}
|
if (!String.isBlank(loginUser.Province__c)) {
|
soql += ' and Province__c = \'' + loginUser.Province__c + '\'';
|
}
|
if (String.isBlank(salesDpt) && String.isBlank(loginUser.Province__c)) {
|
soql += ' and Salesdepartment__c = \'' + adminDpt + '\'';
|
}
|
if (searchByProvince) {
|
salesDpt = adminDpt;
|
}
|
|
// 職位条件
|
List<String> positionNames = new List<String>();
|
for (Position p : plist) {
|
if (p.check) {
|
positionNames.add(p.positionName);
|
//20220406 lt SWAG-CD28H3 【委托】【期初修改4月6日开始修改】目标录入相关判断修改 start
|
if(p.positionName == '经理级'){
|
positionNames.add('副经理');
|
positionNames.add('经理');
|
}
|
if(p.positionName == '总监级'){
|
positionNames.add('副部长');
|
positionNames.add('部长');
|
positionNames.add('总监');
|
}
|
//20220406 lt SWAG-CD28H3 【委托】【期初修改4月6日开始修改】目标录入相关判断修改end
|
}
|
}
|
if (positionNames.size() > 0) {
|
|
soql += ' and (';
|
for (Integer i = 0; i < positionNames.size(); i++) {
|
if (i == positionNames.size() - 1) {
|
soql += ' Post__c = \'' + positionNames[i] + '\'';
|
} else {
|
soql += ' Post__c = \'' + positionNames[i] + '\' or';
|
}
|
}
|
soql += ')';
|
}
|
soql += ' order by Salesdepartment__c, Province__c, UserRole.Name';
|
System.debug('**********123'+soql);
|
return Database.query(soql);
|
}
|
|
// 数据赋值
|
private void setBean(Integer year) {
|
// 取得当前年度目标数据
|
//Opportunity[] opportunitys = ControllerUtil.oppSelectForPersonTaget(rt.Id, users, currentPeriod);
|
// OLY_OCM-202
|
Opportunity[] opportunitys = [select
|
Id, OwnerId, Opportunity_Category__c, Proportion__c, CloseDate,
|
Amount, Objective__c, Target_category__c,
|
SAP_Province__c, RecordTypeId, OCM_Target_period__c
|
from Opportunity
|
where Target_category__c = '担当目标'
|
and RecordTypeId = :rt.Id
|
and OwnerId in :users
|
//20210225 ljh WLIG-BV8CHF update 财年 start
|
//and OCM_Target_period__c = :currentPeriod];
|
and OCM_Target_period__c = :currentPeriodOld];
|
//20210225 ljh WLIG-BV8CHF update 财年 end
|
//--------------20200605 ljh add start ------
|
/*list<Amount_Major_Product__c> Existed_Amount_Major_Products = [select key__c, Amount__c, user_Alias__c,
|
Is_Processing__c, iYear__c from Amount_Major_Product__c where iYear__c = : iYear ];*/
|
//--------------20200605 ljh end start ------
|
// 当前年度没有数据时,显示信息
|
//&& opportunitys.size() <= 0 Existed_Amount_Major_Products.size()<=0
|
if (opportunitys.size() <= 0 && isPast && iYear < currentYear) {
|
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.INFO, '没有上年度的数据。');
|
ApexPages.addMessage(msg);
|
previousRendered = false;
|
iYear += 1;
|
//20210225 ljh WLIG-BV8CHF update 财年 start
|
//currentPeriod = String.valueOf(iYear - 1867 + 'P');
|
currentPeriodOld = String.valueOf(iYear - 1867 + 'P');
|
Integer tempiYear = iYear+1;
|
currentPeriod = String.valueOf('FY'+tempiYear);
|
//20210225 ljh WLIG-BV8CHF update 财年 end
|
isPast = false;
|
if (iYear < currentYear && !(currentYear - iYear == 1 && iMonth == 4 && iDay <= iBuffer)) {
|
isPast = true;
|
}// else if (iYear == currentYear) {
|
// if (Date.today().month() == 3) {
|
// isPast = true;
|
// }
|
// }
|
// 今表示しているデータを再取得
|
setBean(iYear);
|
return;
|
}
|
// 保存当前年度所有既存目标数据
|
oppMap = new Map<String, Opportunity>();
|
for (Opportunity opp : opportunitys) {
|
if (opp.OwnerId != null && opp.Opportunity_Category__c != null && opp.CloseDate != null) {
|
// 目标 key : OwnerId + _ + Opportunity_Category__c + _ + CloseDate(yyyy-mm-dd)
|
String key = opp.OwnerId + '_' + opp.Opportunity_Category__c + '_' + String.valueOf(opp.CloseDate);
|
oppMap.put(key, opp);
|
}
|
}
|
// 2020/06/05 SWAG-BQ7CM9 读取中间既存表 by ljh
|
getAmount_Major_Productmap();
|
|
// 建立数据集
|
dataBeans = new List<DataBean>();
|
for (Integer u = 0; u < users.size(); u++) {
|
DataBean dataBean = new DataBean(users[u], oppMap, iYear);
|
// 2020/06/05 SWAG-BQ7CM9 与既有中间表数据进行对比,然后更新至visualforce page by ljh start
|
// 数据检索Key
|
for (Integer j = 0; j < amountCategory.size(); j++) {
|
String key = users[u].Id + '_' + amountCategory[j] ;
|
if (Amount_Major_ProductMap.containsKey(key)) {
|
Amount_Major_Product__c Amount_Major_Product = Amount_Major_ProductMap.get(key);
|
dataBean.amount[j].Amount = Amount_Major_Product.Amount__c;
|
} else {
|
// dataBean.amount[j].Amount = null;
|
}
|
}
|
// 2020/06/05 SWAG-BQ7CM9 与既有中间表数据进行对比,然后更新至visualforce page by ljh end
|
dataBeans.add(dataBean);
|
}
|
}
|
|
// 実際の保存ロジック
|
/*private void saveLogic() {
|
List<Opportunity> saveList = new List<Opportunity>();
|
List<Opportunity> deleteList = new List<Opportunity>();
|
// 只处理当前本部数据
|
for (Integer d = 0; d < dataBeans.size(); d++) {
|
DataBean db = dataBeans[d];
|
|
// 寄存数据比例值是否变化
|
Boolean proportionChanged = false;
|
for (Integer i = 0; i < 12; i++) {
|
Integer y = iYear;
|
Integer m = 4 + i;
|
if (m > 12) {
|
y += 1;
|
m -= 12;
|
}
|
String syear = String.valueOf(y);
|
String smonth = String.valueOf(m);
|
if (m < 10) {
|
smonth = '0' + smonth;
|
}
|
String sTargetDay = syear + '-' + smonth + '-01';
|
// 按金额分类顺序处理
|
for (Integer j = 0; j < amountCategory.size(); j++) {
|
String amountC = amountCategory[j];
|
// 数据检索Key
|
String key = db.user.Id + '_' + amountC + '_' + sTargetDay;
|
// 每月数据赋值
|
Opportunity opp = new Opportunity();
|
if (oppMap.containskey(key)) {
|
opp = oppMap.get(key);
|
if (opp.Proportion__c != proportion.get(amountC)[i]) {
|
proportionChanged = true;
|
break;
|
}
|
}
|
}
|
if (proportionChanged) {
|
break;
|
}
|
}
|
if (db.isChanged == '0' && !proportionChanged) {
|
continue;
|
}
|
// 使用开始后目标金额补正系数计算
|
//Decimal proportionSum = 0.0;
|
Map<String, Decimal> proportionSumMap = new Map<String, Decimal>();
|
for (Integer j = 0; j < amountCategory.size(); j++) {
|
String amountC = amountCategory[j];
|
proportionSumMap.put(amountC, 0.0);
|
}
|
for (Integer i = 0; i < 12; i++) {
|
Integer y = iYear;
|
Integer m = 4 + i;
|
if (m > 12) {
|
y += 1;
|
m -= 12;
|
}
|
String syear = String.valueOf(y);
|
String smonth = String.valueOf(m);
|
if (m < 10) {
|
smonth = '0' + smonth;
|
}
|
String sTagetDay = syear + '-' + smonth + '-01';
|
Date tagetDay = Date.valueOf(sTagetDay);
|
if (db.user.Use_Start_Date__c < tagetDay) {
|
//proportionSum += proportion.get(amountC)[i];
|
for (Integer j = 0; j < amountCategory.size(); j++) {
|
String amountC = amountCategory[j];
|
proportionSumMap.put(amountC, proportionSumMap.get(amountC) + proportion.get(amountC)[i]);
|
}
|
}
|
}
|
//proportionSum = proportionSum / 100;
|
for (Integer j = 0; j < amountCategory.size(); j++) {
|
String amountC = amountCategory[j];
|
proportionSumMap.put(amountC, proportionSumMap.get(amountC) / 100);
|
}
|
// 一年分成12条数据
|
for (Integer i = 0; i < 12; i++) {
|
Integer y = iYear;
|
Integer m = 4 + i;
|
if (m > 12) {
|
y += 1;
|
m -= 12;
|
}
|
String syear = String.valueOf(y);
|
String smonth = String.valueOf(m);
|
if (m < 10) {
|
smonth = '0' + smonth;
|
}
|
String sTagetDay = syear + '-' + smonth + '-01';
|
Date tagetDay = Date.valueOf(sTagetDay);
|
if (db.user.Use_Start_Date__c >= tagetDay) {
|
// 使用開始当月 及び 開始前 は目標を登録しない,无视。
|
continue;
|
}
|
// 按金额分类顺序处理
|
for (Integer j = 0; j < amountCategory.size(); j++) {
|
String amountC = amountCategory[j];
|
// 数据检索Key
|
String key = db.user.Id + '_' + amountC + '_' + sTagetDay;
|
// 每月数据赋值
|
Opportunity opp = new Opportunity();
|
if (oppMap.containskey(key)) {
|
opp = oppMap.get(key);
|
if (db.amount[j].Amount == null || db.amount[j].Amount == 0) {
|
deleteList.add(opp);
|
continue;
|
}
|
opp.Proportion__c = proportion.get(amountC)[i];
|
opp.Amount = db.amount[j].Amount / proportionSumMap.get(amountC);
|
} else {
|
if (db.amount[j].Amount == null || db.amount[j].Amount == 0) {
|
continue;
|
}
|
opp.Name = db.user.Alias + ' 担当目标';
|
opp.StageName = '目標';
|
opp.OwnerId = db.user.Id;
|
// トリガをスルーのため、ここでやります
|
opp.Owner_System__c = db.user.Id;
|
opp.Opportunity_Category__c = amountC;
|
opp.Proportion__c = proportion.get(amountC)[i];
|
opp.CloseDate = tagetDay;
|
opp.Amount = db.amount[j].Amount / proportionSumMap.get(amountC);
|
opp.Target_category__c = '担当目标';
|
opp.SAP_Province__c = db.user.Province__c;
|
opp.RecordTypeId = rt.Id;
|
opp.OCM_Target_period__c = currentPeriod;
|
}
|
// 加入保存列表
|
saveList.add(opp);
|
}
|
}
|
// 数据库限制小于10000条
|
if (saveList.size() + deleteList.size() >= 4000) {
|
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, '操作数据量过大,截止至' + db.user.Alias + '的数据操作完成,之后的数据请再次输入并保存。'));
|
break;
|
}
|
}
|
// トリガをスルー
|
StaticParameter.EscapeOpportunityBefUpdTrigger = true;
|
StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true;
|
StaticParameter.EscapeNFM007Trigger = true;
|
|
// 更新数据库
|
if (saveList.size() > 0) upsert saveList;
|
if (deleteList.size() > 0) delete deleteList;
|
|
|
|
}*/
|
private Boolean saveLogic() {
|
List<Opportunity> saveList = new List<Opportunity>();
|
List<Opportunity> deleteList = new List<Opportunity>();
|
|
list<Amount_Major_Product__c> InsertAmount_Major_Products = new list<Amount_Major_Product__c>();
|
list<Amount_Major_Product__c> UpdateAmount_Major_Products = new list<Amount_Major_Product__c>();
|
// 只处理当前本部数据
|
|
//system.debug('===dataBeans==='+dataBeans);
|
for (Integer d = 0; d < dataBeans.size(); d++) {
|
DataBean db = dataBeans[d];
|
for (Integer j = 0; j < amountCategory.size(); j++) {
|
// 数据检索Key
|
string key = db.user.Id + '_' + amountCategory[j];
|
if (Amount_Major_ProductMap.containsKey(key)) {
|
//临时表已经有了
|
Amount_Major_Product__c Amount_Major_Product = Amount_Major_ProductMap.get(key);
|
|
if (Amount_Major_Product.Amount__c == db.amount[j].Amount) {
|
continue;
|
} else {
|
Amount_Major_Product.Amount__c = db.amount[j].Amount;
|
Amount_Major_Product.user_Alias__c = db.user.Alias;
|
Amount_Major_Product.SAP_Province__c = db.user.Province__c;
|
Amount_Major_Product.Use_Start_Date__c = db.user.Use_Start_Date__c;
|
Amount_Major_Product.iYear__c = iYear;
|
Amount_Major_Product.Is_Processing__c = true;
|
UpdateAmount_Major_Products.add(Amount_Major_Product);
|
}
|
|
} else {
|
|
/*if (db.amount[j].Amount == null) {
|
//if (db.amount[j].Amount == null || db.amount[j].Amount == 0) {
|
continue;
|
}else{*/
|
//临时表里没有分 执行和没有执行
|
// 金额是否发生变化
|
Boolean proportionChanged = false;
|
for (Integer i = 0; i < 12; i++) {
|
Integer y = iYear;
|
Integer m = 4 + i;
|
if (m > 12) {
|
y += 1;
|
m -= 12;
|
}
|
String syear = String.valueOf(y);
|
String smonth = String.valueOf(m);
|
if (m < 10) {
|
smonth = '0' + smonth;
|
}
|
String sTargetDay = syear + '-' + smonth + '-01';
|
String amountC = amountCategory[j];
|
String keyOpp = db.user.Id + '_' + amountC + '_' + sTargetDay;
|
Opportunity opp = new Opportunity();
|
if (oppMap.containskey(keyOpp)) {
|
opp = oppMap.get(keyOpp);
|
//if (opp.Proportion__c != proportion.get(amountC)[i]) {
|
if (opp.Amount != db.amount[j].Amount) {
|
proportionChanged = true;
|
break;
|
}
|
} else {
|
if (db.amount[j].Amount != null) {
|
proportionChanged = true;
|
break;
|
}
|
|
}
|
}
|
system.debug('===proportionChanged===' + proportionChanged);
|
if (proportionChanged) {
|
Amount_Major_Product__c Amount_Major_Product = new Amount_Major_Product__c();
|
Amount_Major_Product.key__c = key;
|
Amount_Major_Product.Amount__c = db.amount[j].Amount;
|
Amount_Major_Product.user_Alias__c = db.user.Alias;
|
Amount_Major_Product.SAP_Province__c = db.user.Province__c;
|
Amount_Major_Product.Use_Start_Date__c = db.user.Use_Start_Date__c;
|
Amount_Major_Product.iYear__c = iYear;
|
Amount_Major_Product.Is_Processing__c = true;
|
InsertAmount_Major_Products.add(Amount_Major_Product);
|
}
|
//}
|
}
|
}
|
}
|
if ( InsertAmount_Major_Products.size() > 0 ) {
|
insert InsertAmount_Major_Products;
|
}
|
if ( UpdateAmount_Major_Products.size() > 0 ) {
|
update UpdateAmount_Major_Products;
|
}
|
return true;
|
}
|
|
// 数据类
|
class DataBean {
|
// 担当者信息
|
public User user { get; private set; }
|
// 总金额,画面用
|
public Opportunity[] amount { get; set; }
|
// 是否变化 0:无 1:有
|
public String isChanged { get; set; }
|
|
// 构造方法
|
DataBean(User user, Map<String, Opportunity> oppMap, Integer iYear) {
|
this.user = user;
|
this.amount = new List<Opportunity>();
|
this.isChanged = '0';
|
|
|
// 按金额分类,查找数据,并设值
|
for (Integer i = 0; i < amountCategory.size(); i++) {
|
String amountC = amountCategory[i];
|
Opportunity a = new Opportunity();
|
a.Opportunity_Category__c = amountC;
|
Decimal amountSum = 0.0;
|
// 2020/06/05 SWAG-BQ7CM9 从Opportunity赋值到vf page上 by ljh start
|
for (Integer j = 0; j < 12; j++) {
|
Integer y = iYear;
|
Integer m = 4 + j;
|
if (m > 12) {
|
y += 1;
|
m -= 12;
|
}
|
String strY = String.valueOf(y);
|
String strM = String.valueOf(m);
|
if (strM.length() < 2) {
|
strM = '0' + strM;
|
}
|
String key = user.Id + '_' + amountC + '_' + strY + '-' + strM + '-01';
|
if (oppMap.containskey(key)) {
|
//a.Amount = oppMap.get(key).Amount;
|
amountSum += oppMap.get(key).Objective__c == null ? 0 : oppMap.get(key).Objective__c;
|
}
|
}
|
if (amountSum > 0) {
|
amountSum = amountSum.setScale(2);
|
a.Amount = amountSum;
|
}
|
// 2020/06/05 SWAG-BQ7CM9 从Opportunity赋值到vf page上 by ljh end
|
this.amount.add(a);
|
}
|
}
|
}
|
|
// 職位チェックボックスリスト作成
|
class Position {
|
public String positionName { get; private set; }
|
public Boolean check { get; set; }
|
|
public Position(String positionName, Boolean flg) {
|
this.positionName = positionName;
|
this.check = flg;
|
}
|
}
|
}
|