public with sharing class ReceivingNoteListFirstController extends CreateRelationListPagingCtrlBase {
|
public override Integer getSearchNumMax() {
|
//各ページに制御あれば、最大件数を指定する
|
// searchNumMax = Integer.valueOf(Label.Product_Select_Limit);
|
// searchNumMax = 20;
|
pagesize = '20';
|
return searchNumMax;
|
}
|
|
/* 選択されたデータ取得用Soql Fromから*/
|
public override String getSelectedDataSql() {
|
// オブジェクトAPI名
|
selectedDataSql = ' From ReceivingNote__c';
|
selectedDataSql += ' where id = null ';
|
selectedDataSql += ' order by Id';
|
if (myComponentController.columnLeftRW != null) {
|
for (String key : myComponentController.columnLeftRW.keySet()) {
|
myComponentController.columnLeftRW.put(key, 'r');
|
}
|
}
|
if (myComponentController.columnRightRW != null) {
|
for (String key : myComponentController.columnRightRW.keySet()) {
|
myComponentController.columnRightRW.put(key, 'r');
|
}
|
}
|
return selectedDataSql;
|
}
|
|
public override String getOriginObjName() {
|
// オブジェクトAPI名
|
originObjName = 'ReceivingNote__c';
|
return originObjName;
|
}
|
public override String getOriginObjColumns() {
|
// 項目セット
|
// 20210312 you WLIG-BV8CHF start
|
//originObjColumns = 'Id , RN_Status__c , Internal_asset_location__c , Sales_order_number__c , OrderCode__c , ApprovalNumber__c , Asset_loaner_category__c , DateOfDelivery__c , ReceivingNoteSummary_Cnt__c , Data_Confirmation_Again_Link__c, Data_Confirmation_Link__c, ReceivingNoteNo__c,ReceivingNotePDF_LINK__c';
|
// 20210630 ljh 增加 ContactPerson__c
|
originObjColumns = 'Id ,ContactPerson__c, RN_Status__c , Internal_asset_location__c , Sales_order_number__c , OrderCode__c , ApprovalNumber__c , Asset_loaner_category__c , DateOfDelivery__c , ReceivingNoteSummary_Cnt__c , Data_Confirmation_Again_Link__c, Data_Confirmation_Link__c, ReceivingNoteNo_New__c,ReceivingNotePDF_LINK__c';
|
// 20210312 you WLIG-BV8CHF end
|
return originObjColumns;
|
}
|
|
public override String getObjName() {
|
// オブジェクトAPI名
|
objName = 'ReceivingNote__c';
|
return objName;
|
}
|
public override String getColumnLeftFieldSetName() {
|
// 左の項目セット
|
columnLeftFieldSetName = 'ReceivingNoteListFirst_L';
|
return columnLeftFieldSetName;
|
}
|
public override String getColumnRightFieldSetName() {
|
// 右の項目セット
|
columnRightFieldSetName = 'ReceivingNoteListFirst_R';
|
return columnRightFieldSetName;
|
}
|
|
public override List<String> getColumnFieldList() {
|
// strColumus 里加 field
|
// FixtureUtil#raesdGroupByAssetId()の項目も必要
|
return new List<String>{'Id'
|
};
|
}
|
|
public override String getFKColumnField() {
|
// getObjName 连 getOriginObjName 的 FK
|
return '';
|
}
|
|
public override String getRecordTypeId() {
|
//ページレイアウトを収得するのレコードタイプ
|
recordTypeId = '';
|
return recordTypeId;
|
}
|
|
// ページコントローラに検索処理は、WhereSoql作成のみ、パラメータとして、コンポーネントに渡される
|
public override String getSqlWhereStr() {
|
sqlWhereStr = '';
|
|
if (getIsNeedRunSearch()) {
|
sqlWhereStr = this.makeSoql();
|
}
|
|
return sqlWhereStr;
|
|
}
|
|
public override String getOrderbyStr() {
|
return 'order by Id';
|
}
|
|
public override Boolean getIsNeedRunSearch() {
|
return true;
|
}
|
|
public ReceivingNote__c rn { get; set; } //别存放地
|
|
public String bieCunFangDi { get; set; } //别存放地
|
public String orderCode { get; set; } //订单编码
|
public String salesOrderNumber {get;set;} // 合同编码
|
public String approvalNumber { get; set; } //采购申请裁决号
|
//wangweipeng 20210616 新增 联系人 查询条件
|
public String contactPerson { get; set; } //联系人
|
public String asset_loaner_category { get; set; } //备品类别
|
public String dateOfDelivery { get; set; } //发货日
|
public String status { get; set; } //收货状态
|
public String beiShangGuang {get; set;} // 北上广备品中心
|
|
public ReceivingNoteListFirstController() {
|
parentId = '00000';
|
status = '待数据确认';
|
String userId = Userinfo.getUserId();
|
User u = [SELECT UserRole.name from User where Id =: userId];
|
switch on u.UserRole.name {
|
when '备品中心北方管理成员' {
|
beiShangGuang = '北京 备品中心';
|
}
|
when '备品中心华东管理成员' {
|
beiShangGuang = '上海 备品中心';
|
}
|
when '备品中心南方管理成员' {
|
beiShangGuang = '广州 备品中心';
|
}
|
when else{
|
beiShangGuang = 'ALL';
|
}
|
}
|
}
|
|
public void init() {
|
rn = new ReceivingNote__c();
|
isNeedSearchFirst = true;
|
isNeedCheckEvent = true;
|
getSqlWhereStr();
|
}
|
|
public PageReference searchOpp() {
|
|
if (!getIsNeedRunSearch()) {
|
return null;
|
}
|
|
// 選択済みの製品を取得
|
myComponentController.getSelectedDataInfo();
|
|
getSqlWhereStr();
|
// コンポーネントにSoqlを発行して、ページングする
|
myComponentController.searchAndPaging();
|
return null;
|
}
|
|
public override void setViewList(List<sObject> queryList) {
|
viewList = new List<WrapperInfo>();
|
for (Integer i = 0; i < queryList.size(); i++) {
|
// 501を超えた場合前500のみを出す
|
if (i == getSearchNumMax()) { break; }
|
ReceivingNote__c mf = (ReceivingNote__c)queryList[i];
|
viewList.add(new WrapperInfo(mf, myComponentController));
|
viewList[viewList.size() - 1].lineNo = viewList.size() - 1;
|
}
|
}
|
|
//别存放地 SelectOption
|
public List<SelectOption> getbieCunFangDiOps() {
|
//备品存放地(现在)
|
// return FixtureUtil.bieCunFangDiOpsMap.get(sonObj.Internal_asset_location__c);
|
// return new List<SelectOption>{
|
// new SelectOption(sonObj.Rental_Apply__r.Internal_asset_location_F__c, sonObj.Rental_Apply__r.Internal_asset_location_F__c)
|
// };
|
// cunfangdiSet = new Set<String>();
|
List<SelectOption> opList;
|
opList = FixtureUtil.bieCunFangDiOpsMap.get('备品管理中心');
|
|
// for (SelectOption op : opList) {
|
// if (String.isNotBlank(op.getValue())) {
|
// cunfangdiSet.add(op.getValue());
|
// }
|
// }
|
return opList;
|
}
|
|
//别本部 SelectOption
|
public List<SelectOption> getbieBenBuOps() {
|
//所在地区(本部) 现在
|
// return FixtureUtil.bieBenBuOpsMap.get(sonObj.Salesdepartment__c);
|
// benbuSet = new Set<String>();
|
List<SelectOption> opList = FixtureUtil.bieBenBuOpsMap.get('All');
|
// for (SelectOption op : opList) {
|
// if (String.isNotBlank(op.getValue())) {
|
// benbuSet.add(op.getValue());
|
// }
|
// }
|
return opList;
|
}
|
|
//产品分类 SelectOption
|
public List<SelectOption> getbieChanPinFenLeiOps() {
|
//产品分类(GI/SP) F Product_category_F__c
|
// return FixtureUtil.bieChanPinFenLeiOpsMap.get(sonObj.Product_category_F__c);
|
return FixtureUtil.bieChanPinFenLeiOpsMap.get('GISP');
|
}
|
|
//别备品分类 SelectOption
|
public List<SelectOption> getbieBeiPinFenLeiOps() {
|
//备品分类(现在) Equipment_Type__c
|
// return FixtureUtil.bieBeiPinFenLeiOpsMap.get(sonObj.Equipment_Type__c);
|
return FixtureUtil.bieBeiPinFenLeiOpsMap.get('备品分类');
|
}
|
|
// 备品类别
|
public List<SelectOption> getAsset_loaner_categoryOps() {
|
return FixtureUtil.getPlickList('ReceivingNote__c', 'Asset_loaner_category__c');
|
}
|
|
public List<SelectOption> getRNStatusOpss() {
|
return ReceivingNoteListFirstController.getRNStatusOps();
|
}
|
|
// 备品类别
|
public static List<SelectOption> getRNStatusOps() {
|
List<FixtureUtil.RNStatus> rnsList = new List<FixtureUtil.RNStatus>();
|
rnsList.add(FixtureUtil.RNStatus.Dai_Shu_Ju_Que_Ren);
|
rnsList.add(FixtureUtil.RNStatus.Yi_Shu_Ju_Que_Ren);
|
rnsList.add(FixtureUtil.RNStatus.Yi_Shou_Huo_Que_Ren);
|
rnsList.add(FixtureUtil.RNStatus.Yi_Qing_Dian);
|
rnsList.add(FixtureUtil.RNStatus.Yi_Yan_Shou);
|
//rnsList.add(FixtureUtil.RNStatus.Yi_Jian_Ce);
|
rnsList.add(FixtureUtil.RNStatus.Dai_Ru_Ku_Zhi_Shi);
|
rnsList.add(FixtureUtil.RNStatus.Yi_Ru_Ku_Zhi_Shi);
|
rnsList.add(FixtureUtil.RNStatus.Yi_Ru_Ku);
|
|
List<SelectOption> opList = new List<SelectOption>();
|
opList.add(new SelectOption('', '--全部--'));
|
for (FixtureUtil.RNStatus sNum : rnsList) {
|
String value = FixtureUtil.RNStatusMap.get(sNum.ordinal());
|
opList.add(new SelectOption(value, value));
|
}
|
|
return opList;
|
}
|
|
private String makeSoql() {
|
String soql = ' Where Id != null';
|
if ('ALL' == beiShangGuang) {
|
if(String.isNotBlank(bieCunFangDi) && bieCunFangDi != 'All') {
|
soql += ' AND Internal_asset_location__c = \'' + String.escapeSingleQuotes(bieCunFangDi) + '\'';
|
}else{
|
//wangweipeng 20210615
|
soql += ' AND (Internal_asset_location__c =\'北京 备品中心\' or Internal_asset_location__c = \'上海 备品中心\' or Internal_asset_location__c = \'广州 备品中心\')';
|
}
|
}
|
else{
|
// 只有查看自己备品中心
|
soql += ' AND Internal_asset_location__c = \'' + beiShangGuang + '\'';
|
}
|
if (String.isNotBlank(orderCode)) {
|
soql += ' AND OrderCode__c LIKE \'%' + String.escapeSingleQuotes(orderCode) + '%\'';
|
}
|
|
if (String.isNotBlank(salesOrderNumber)) {
|
soql += ' AND Sales_order_number__c LIKE \'%' + String.escapeSingleQuotes(salesOrderNumber) + '%\'';
|
}
|
|
if (String.isNotBlank(approvalNumber)) {
|
soql += ' AND ApprovalNumber__c LIKE \'%' + String.escapeSingleQuotes(approvalNumber) + '%\'';
|
}
|
|
//wangweipeng 20210616 新增 联系人 查询条件
|
if(String.isNotBlank(contactPerson)){
|
soql += ' AND ContactPerson__c LIKE \'%' + String.escapeSingleQuotes(contactPerson) + '%\'';
|
}
|
|
if (String.isNotBlank(asset_loaner_category)) {
|
soql += ' AND Asset_loaner_category__c = \'' + String.escapeSingleQuotes(asset_loaner_category) + '\'';
|
}
|
|
if (String.isNotBlank(dateOfDelivery)) {
|
String dateStr = dateOfDelivery.replace('/', '-');
|
soql += ' AND DateOfDelivery__c = ' + String.escapeSingleQuotes(dateStr);
|
}
|
|
if (String.isNotBlank(status)) {
|
soql += ' AND RN_Status__c = \'' + String.escapeSingleQuotes(status) + '\'';
|
}
|
System.debug('zheli:'+soql);
|
return soql;
|
}
|
/**
|
@description 以清单为单位给明细做入库指示
|
*/
|
public PageReference inStockRequest() {
|
try{
|
// 获取打勾清单
|
Map<Id,Integer> rnRndMap = new Map<Id, Integer>();
|
for (WrapperInfo info:viewList){
|
if(info.check){
|
rnRndMap.put(info.sobj.Id, 0);
|
}
|
}
|
|
// 获取明细
|
List<ReceivingNoteDetail__c> rndList = [
|
SELECT DataConfirmationAgain__c
|
, Arrival_wh_Request_time__c
|
, ReceivingNote__r.ReceivingNoteNo__c
|
, ReceivingNote__r.Name
|
FROM ReceivingNoteDetail__c
|
WHERE Delete_Flag__c = false
|
AND ReceivingNote__c IN :rnRndMap.keySet()
|
FOR UPDATE
|
];
|
rndList = [
|
SELECT DataConfirmationAgain__c
|
, Arrival_wh_Request_time__c
|
, ReceivingNote__r.ReceivingNoteNo__c
|
, ReceivingNote__r.Name
|
FROM ReceivingNoteDetail__c
|
WHERE Delete_Flag__c = false
|
AND ReceivingNote__c IN :rnRndMap.keySet()
|
ORDER BY ReceivingNote__c
|
];
|
|
List<ReceivingNoteDetail__c> stockInRequestAvailableRndList = new List<ReceivingNoteDetail__c>(); // 可做入库指示的明细列表
|
|
Id lastRnId = null;
|
Boolean hasStockInAvailable = false;
|
Boolean hasStockInUnavailable = false;
|
ReceivingNoteDetail__c lastRnd;
|
|
Datetime now = Datetime.now();
|
for(ReceivingNoteDetail__c rnd:rndList){
|
if (String.isBlank(lastRnId)){
|
lastRnId = rnd.ReceivingNote__c;
|
}
|
else if (lastRnId != rnd.ReceivingNote__c){
|
if(hasStockInAvailable == false){
|
Apexpages.addMessage(new ApexPages.message(Apexpages.Severity.ERROR, lastRnd.ReceivingNote__r.Name + '无法入库指示'));
|
return null;
|
}
|
else if (hasStockInUnavailable){
|
Apexpages.addMessage(new ApexPages.message(Apexpages.Severity.INFO, lastRnd.ReceivingNote__r.Name + '部分入库指示'));
|
}
|
lastRnId = rnd.ReceivingNote__c;
|
hasStockInAvailable = false;
|
hasStockInUnavailable = false;
|
}
|
if(rnd.DataConfirmationAgain__c && rnd.Arrival_wh_Request_time__c == null){
|
rnd.Arrival_wh_Request_time__c = now;
|
hasStockInAvailable = true;
|
stockInRequestAvailableRndList.add(rnd);
|
}
|
else{
|
hasStockInUnavailable = true;
|
}
|
lastRnd = rnd;
|
}
|
|
if (String.isNotBlank(lastRnId)) {
|
if(hasStockInAvailable == false){
|
Apexpages.addMessage(new ApexPages.message(Apexpages.Severity.ERROR, lastRnd.ReceivingNote__r.Name + '无法入库指示'));
|
return null;
|
}
|
else if (hasStockInUnavailable){
|
Apexpages.addMessage(new ApexPages.message(Apexpages.Severity.INFO, lastRnd.ReceivingNote__r.Name + '部分入库指示'));
|
}
|
}
|
// 写入数据库
|
if (stockInRequestAvailableRndList.size()>0){
|
update stockInRequestAvailableRndList;
|
PageReference pageRef = ApexPages.CurrentPage();
|
return pageRef;
|
}
|
}
|
catch (Exception e) {
|
ApexPages.addMessages(e);
|
return null;
|
}
|
return null;
|
}
|
}
|