global with sharing class InventoryReportDetailController extends CreateRelationListPagingCtrlBase {
|
public override Integer getSearchNumMax() {
|
//各ページに制御あれば、最大件数を指定する
|
// searchNumMax = Integer.valueOf(Label.Product_Select_Limit);
|
// searchNumMax = 100;
|
pagesize = '200';
|
return 20000;
|
}
|
public override Boolean getIsNeedRunSearch() {
|
return true;
|
}
|
public override String getWidth0Field() {
|
return '';
|
}
|
/* 選択されたデータ取得用Soql Fromから*/
|
public override String getSelectedDataSql() {
|
myComponentController.columnRightRW.put('Inventory_Chujie_Count_Jia__c', 'r');
|
myComponentController.columnRightRW.put('WH_Location__c', 'r');
|
myComponentController.columnRightRW.put('SerialNumber__c', 'r');
|
myComponentController.columnRightRW.put('Equipment_Type__c', 'r');
|
myComponentController.columnRightRW.put('Fixture_Model_No__c', 'r');
|
myComponentController.columnRightRW.put('Internal_asset_location__c', 'r');
|
myComponentController.columnRightRW.put('Salesdepartment__c', 'r');
|
myComponentController.columnRightRW.put('Inventory_Diaobo_Count_Jia__c', 'r');//20210531 you 1650
|
return '';
|
}
|
public override List<String> getWritableColumnFieldList() {
|
return new List<String>{'Remarks_Person__c', 'Inventory_Remarks__c'};
|
}
|
public override String getOriginObjName() {
|
// オブジェクトAPI名
|
if(this.isConsum){
|
originObjName = 'Consum_Inventory_Detail__c';
|
}
|
else{
|
originObjName = 'Inventory_Detail__c';
|
}
|
return originObjName;
|
}
|
public override String getOriginObjColumns() {
|
// 項目セット
|
originObjColumns = 'Id';
|
return originObjColumns;
|
}
|
public override String getObjName() {
|
// オブジェクトAPI名
|
if(this.isConsum){
|
objName = 'Consum_Inventory_Detail__c';
|
}
|
else{
|
objName = 'Inventory_Detail__c';
|
}
|
return objName;
|
}
|
// ページコントローラに検索処理は、WhereSoql作成のみ、パラメータとして、コンポーネントに渡される
|
public override String getSqlWhereStr() {
|
sqlWhereStr = '';
|
|
if (getIsNeedRunSearch()) {
|
sqlWhereStr = this.makeSoql(keywdSort);
|
system.debug(sqlWhereStr);
|
}
|
return sqlWhereStr;
|
}
|
public override String getColumnLeftFieldSetName() {
|
// 左の項目セット
|
// columnLeftFieldSetName = 'InventoryReportRecord_FieldSet';
|
// return columnLeftFieldSetName;
|
return '';
|
}
|
public override String getColumnRightFieldSetName() {
|
// 右の項目セット
|
if(this.isConsum){
|
columnRightFieldSetName = 'ConsumInventoryReportRecord_FieldSet';
|
} else if(angecylookrole==false){//20210628 you 1650
|
columnRightFieldSetName = 'InventoryReportRecord_FieldSet_Angecy';
|
}else{
|
columnRightFieldSetName = 'InventoryReportRecord_FieldSet';
|
}
|
return columnRightFieldSetName;
|
}
|
public override List<String> getColumnFieldList() {
|
// strColumus 里加 field
|
return new List<String>{'Asset__c'};
|
}
|
public override String getFKColumnField() {
|
// getObjName 连 getOriginObjName 的 FK
|
return '';
|
}
|
public override String getRecordTypeId() {
|
//ページレイアウトを収得するのレコードタイプ
|
recordTypeId = '';
|
return recordTypeId;
|
}
|
public override String getOrderbyStr() {
|
return 'order by Inventory_Remarks__c ASC nulls last, Fixture_Model_No__c, SerialNumber__c';
|
}
|
|
private String keywdSort = null;
|
public String saveType { get; set; }
|
public String keyword { get; set; }
|
public Inventory_Header__c parentObj { get; private set; }
|
public String invDetailResultRemark {get; private set;} // 盘点明细画面查询结果说明
|
public static bp3_Setting__c conf = bp3_Setting__c.getOrgDefaults();
|
public String assetStatus {get; set;} // 备品状态 Asset_Status__c
|
public String compareOperator {get; set;}
|
public Consum_Inventory_Detail__c sampleCiDetail {get;set;}
|
//public Asset sonObj { get; set; }
|
public Boolean isConsum {get;set;}
|
public Boolean angecylookrole {get; set;} // 只读权限 1650 20210628
|
public String bieCunFangDi { get; set; } //别存放地, 肯定有值 不为null
|
|
public List<SelectOption> assetStatusOptionList {
|
get {
|
List<SelectOption> selectOptions = new List<SelectOption> {new SelectOption('', '--全部--') };
|
selectOptions.add(new SelectOption('未盘点', '未盘点'));
|
selectOptions.add(new SelectOption('已盘点', '已盘点'));
|
return selectOptions;
|
}
|
}
|
|
private void searchOppSetParam() {
|
this.keywdSort = this.keyword;
|
}
|
public PageReference searchOpp() {
|
searchOppSetParam();
|
|
if (!getIsNeedRunSearch()) {
|
return null;
|
}
|
|
getSqlWhereStr();
|
myComponentController.searchAndPaging();
|
return null;
|
}
|
|
public InventoryReportDetailController() {
|
}
|
public InventoryReportDetailController(ApexPages.StandardController controller) {
|
try {
|
angecylookrole = false;
|
isNeedCheckEvent = true;
|
this.parentId = ApexPages.currentPage().getParameters().get('ivt_headId');
|
this.invDetailResultRemark = conf.Inventory_Detail_Result_Remark__c;
|
this.sampleCiDetail = new Consum_Inventory_Detail__c();
|
this.isConsum = false;
|
|
// 盘点表头の情報を取得--有ivt_headId的话根据id取盘点表头,否则取当前用户所在备品存放地最新一条
|
if (!String.isBlank(this.parentId)) {
|
List<Inventory_Header__c> parentObjs = [
|
SELECT Id, Internal_asset_location__c, Name, Inventory_Start_Date__c
|
, Inventory_Status__c, InventoryPIC__c, Fixture_Header__c
|
FROM Inventory_Header__c
|
WHERE Id = :parentId
|
];
|
if (!parentObjs.isEmpty()) {
|
parentObj = parentObjs.get(0);
|
//20210628 you 1650 办事处看不到 货架号
|
bieCunFangDi = parentObj.Internal_asset_location__c;
|
system.debug('zheli0'+bieCunFangDi);
|
if (bieCunFangDi=='广州 备品中心' || bieCunFangDi=='北京 备品中心' || bieCunFangDi=='上海 备品中心') {
|
angecylookrole =true;
|
}
|
} else {
|
throw new ControllerUtil.myException('没有可以操作的盘点明细或者盘点表头数据不正确。');
|
}
|
} else {
|
User currUser = [
|
SELECT Id, Name, Default_Referable_Apply_Equipment_Center__c
|
FROM User
|
WHERE Id = :UserInfo.getUserId()
|
];
|
if (String.isBlank(currUser.Default_Referable_Apply_Equipment_Center__c)) {
|
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, '当前用户所在地不能为空'));
|
}
|
//20210628 you 1650 办事处看不到 货架号
|
bieCunFangDi = currUser.Default_Referable_Apply_Equipment_Center__c;
|
if (bieCunFangDi=='广州 备品中心' || bieCunFangDi=='北京 备品中心' || bieCunFangDi=='上海 备品中心') {
|
angecylookrole =true;
|
}
|
List<Inventory_Header__c> ihObjList = [
|
SELECT Id, Internal_asset_location__c, Name, Inventory_Start_Date__c
|
, Inventory_Status__c, InventoryPIC__c, Fixture_Header__c
|
FROM Inventory_Header__c
|
WHERE Internal_asset_location__c = :currUser.Default_Referable_Apply_Equipment_Center__c
|
AND Inventory_Status__c <> '处理中'
|
ORDER BY Inventory_Start_Date__c desc
|
LIMIT 1
|
];
|
if (ihObjList.size() == 0) {
|
this.parentId = 'temp'; // 如果parentId为空,当前controller的myexception会被共通的'Id必须指定'覆盖
|
throw new ControllerUtil.myException('当前用户所在地区没有盘点报告, 或者盘点报告状态为处理中');
|
} else {
|
parentObj = ihObjList[0];
|
this.parentId = parentObj.Id;
|
}
|
}
|
this.isConsum = String.isNotBlank(parentObj.Fixture_Header__c);
|
|
} catch (ControllerUtil.myException me) {
|
System.debug(LoggingLevel.ERROR, 'myException caught when init: ' + me.getMessage() + me.getStackTraceString());
|
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'when init ' + me.getMessage()));
|
return;
|
} catch (Exception e) {
|
System.debug(LoggingLevel.ERROR, 'Exception caught when init: ' + e.getMessage() + e.getStackTraceString());
|
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'when init ' + e.getMessage()));
|
return;
|
}
|
}
|
// 画面初始化
|
public void init() {
|
try {
|
|
assetStatus = '';
|
isNeedSearchFirst = true;
|
isNeedCheckEvent = true;
|
|
searchOppSetParam();
|
getSqlWhereStr();
|
|
} catch (ControllerUtil.myException me) {
|
System.debug('myException caught when init: ' + me.getMessage());
|
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, me.getMessage()));
|
return;
|
} catch (Exception e) {
|
System.debug('Exception caught when init: ' + e.getStackTraceString());
|
ApexPages.addMessages(e);
|
return;
|
}
|
}
|
|
public override void setViewList(List<sObject> queryList) {
|
system.debug('●●●●● setViewList START ' );
|
viewList = new List<WrapperInfo>();
|
|
if (queryList.size() > 0) {
|
final String soqlStr = 'SELECT {0} {1} ';
|
String whereStr = ' FROM ' + this.getObjName() + ' WHERE ID IN: queryList';
|
String soql = String.format(soqlStr, new String[] {myComponentController.strColumus , whereStr});
|
|
List<sObject> InDList = null;
|
InDList = Database.query(soql);
|
|
Set<Id> assetSet = new Set<Id>();
|
Map<Id, sObject> orderMap = null;
|
if(this.isConsum){
|
orderMap = new Map<Id, Consum_Inventory_Detail__c>();
|
for (sObject sObj : InDList) {
|
Consum_Inventory_Detail__c InD = (Consum_Inventory_Detail__c) sObj;
|
orderMap.put(InD.Id, InD);
|
assetSet.add(InD.Asset__c);
|
}
|
}
|
else{
|
orderMap = new Map<Id, Inventory_Detail__c>();
|
for (sObject sObj : InDList) {
|
Inventory_Detail__c InD = (Inventory_Detail__c) sObj;
|
orderMap.put(InD.Id, InD);
|
assetSet.add(InD.Asset__c);
|
}
|
}
|
List<AggregateResult> statusArList = new List<AggregateResult>();
|
List<AggregateResult> statusYList = new List<AggregateResult>();
|
List<AggregateResult> statusKList = new List<AggregateResult>();
|
|
if(this.isConsum){
|
statusArList = [
|
SELECT Asset_Status__c status, sum(Amount__c) quantity
|
, sum(Inventory_Count__c) invShipanCount, sum(Inventory_Deviation__c) deviaCount, sum(Asset__r.Abandoned_Inventory__c) abCount
|
, Asset__c assetId
|
FROM Consum_Inventory_Detail__c
|
WHERE Asset__c in :assetSet
|
AND Inventory_Header__c = :parentId
|
AND Asset_Status__c!='已消耗明细'
|
GROUP BY Asset_Status__c, Asset__c
|
];
|
// 页面显示"盘盈/盘亏"只计算有盘点时间的
|
statusYList = [
|
SELECT Asset_Status__c status, sum(Inventory_Deviation__c) yDeviaCount
|
, Asset__c assetId
|
FROM Consum_Inventory_Detail__c
|
WHERE Asset__c in :assetSet
|
AND Inventory_Header__c = :parentId
|
AND Inventory_Time__c <> null
|
AND Inventory_Deviation__c > 0 // 盘盈
|
AND Asset_Status__c!='已消耗明细'
|
GROUP BY Asset_Status__c, Asset__c
|
];
|
statusKList = [
|
SELECT Asset_Status__c status, sum(Inventory_Deviation__c) kDeviaCount
|
, Asset__c assetId
|
FROM Consum_Inventory_Detail__c
|
WHERE Asset__c in :assetSet
|
AND Inventory_Header__c = :parentId
|
AND Inventory_Time__c <> null
|
AND Inventory_Deviation__c < 0 // 盘亏
|
AND Asset_Status__c!='已消耗明细'
|
GROUP BY Asset_Status__c, Asset__c
|
];
|
}
|
else{
|
statusArList = [
|
SELECT Asset_Status__c status, sum(Amount__c) quantity
|
, sum(Inventory_Count__c) invShipanCount, sum(Inventory_Deviation__c) deviaCount
|
, Asset__c assetId
|
FROM Inventory_Detail__c
|
WHERE Asset__c in :assetSet
|
AND Inventory_Header__c = :parentId
|
AND Asset_Status__c <> '丢失借出明细'
|
GROUP BY Asset_Status__c, Asset__c
|
];
|
// 页面显示"盘盈/盘亏"只计算有盘点时间的
|
statusYList = [
|
SELECT Asset_Status__c status, sum(Inventory_Deviation__c) yDeviaCount
|
, Asset__c assetId
|
FROM Inventory_Detail__c
|
WHERE Asset__c in :assetSet
|
AND Inventory_Header__c = :parentId
|
AND Asset_Status__c <> '丢失借出明细'
|
AND Inventory_Time__c <> null
|
AND Inventory_Deviation__c > 0 // 盘盈
|
GROUP BY Asset_Status__c, Asset__c
|
];
|
statusKList = [
|
SELECT Asset_Status__c status, sum(Inventory_Deviation__c) kDeviaCount
|
, Asset__c assetId
|
FROM Inventory_Detail__c
|
WHERE Asset__c in :assetSet
|
AND Inventory_Header__c = :parentId
|
AND Asset_Status__c <> '丢失借出明细'
|
AND Inventory_Time__c <> null
|
AND Inventory_Deviation__c < 0 // 盘亏
|
GROUP BY Asset_Status__c, Asset__c
|
];
|
}
|
|
Map<Id, StatusCount> assetCountMap = new Map<Id, StatusCount>();
|
for (AggregateResult ar : statusArList) {
|
StatusCount statusCount = new StatusCount(0);
|
Integer amount = (Integer.valueOf(ar.get('quantity')) == null) ? 0 : Integer.valueOf(ar.get('quantity')); // 应盘数
|
Integer acAmount = (Integer.valueOf(ar.get('invShipanCount')) == null) ? 0 : Integer.valueOf(ar.get('invShipanCount')); // 实盘数 (没有实盘的话显示空)
|
Integer abmount = 0;
|
if(isConsum){
|
abmount = (Integer.valueOf(ar.get('abCount')) == null) ? 0 : Integer.valueOf(ar.get('abCount')); // 应盘数
|
}
|
|
Id assId = String.valueof(ar.get('assetId'));
|
if (assetCountMap.get(assId) != null) {
|
statusCount = assetCountMap.get(assId);
|
}
|
if (Integer.valueOf(ar.get('invShipanCount')) != null) {
|
statusCount.ifSPNotNull = true; // 有实盘记录
|
}
|
|
if (ar.get('status') == '在库') {
|
statusCount.zaikuNum += amount;
|
statusCount.quantity += abmount;
|
} else if (ar.get('status') == '维修中') {
|
statusCount.weixiuNum += amount; // 应盘维修中
|
} else if (ar.get('status') == '出借中') {
|
statusCount.chujieNum += amount; // 应盘出借中
|
} else if (ar.get('status') == '丢失') {
|
statusCount.diushiNum += amount; // 应盘丢失
|
} else if (ar.get('status') == '冻结') {
|
statusCount.zaikuNum += amount; // 盘点在库数='在库'应盘数+'冻结'应盘数
|
} else if (ar.get('status') == '已消耗') {
|
statusCount.xiaohaoNum += amount;
|
} else if (ar.get('status') == '调拨中') {//20210531 you 1650 应盘调拨中
|
statusCount.diaoboNum += amount;
|
}
|
if(ar.get('status') != '已消耗'){
|
statusCount.quantity += amount; // 应盘数量
|
statusCount.shipanNum += acAmount; // 实盘数量
|
}
|
|
assetCountMap.put(assId, statusCount);
|
|
for (AggregateResult yAggr : statusYList) {
|
Integer yWuchaAmount = (Integer.valueOf(yAggr.get('yDeviaCount')) == null) ? 0 : Integer.valueOf(yAggr.get('yDeviaCount')); // 盘点误差(盘盈/盘亏)
|
if (String.valueof(ar.get('assetId')) == String.valueof(yAggr.get('assetId'))
|
&& String.valueOf(ar.get('status')) == String.valueOf(yAggr.get('status'))) {
|
if (assetCountMap.containsKey(assId)) {
|
statusCount = assetCountMap.get(assId);
|
}
|
statusCount.wuchaNum += yWuchaAmount; // 盘点误差(盘盈/盘亏)
|
statusCount.panyinNum += yWuchaAmount; // 实际盘盈
|
assetCountMap.put(assId, statusCount);
|
break;
|
}
|
}
|
for (AggregateResult kAggr : statusKList) {
|
Integer kWuchaAmount = (Integer.valueOf(kAggr.get('kDeviaCount')) == null) ? 0 : Integer.valueOf(kAggr.get('kDeviaCount')); // 盘点误差(盘盈/盘亏)
|
if (String.valueof(ar.get('assetId')) == String.valueof(kAggr.get('assetId'))
|
&& String.valueOf(ar.get('status')) == String.valueOf(kAggr.get('status'))) {
|
if (assetCountMap.containsKey(assId)) {
|
statusCount = assetCountMap.get(assId);
|
}
|
statusCount.wuchaNum += kWuchaAmount; // 盘点误差(盘盈/盘亏)
|
statusCount.pankuiNum += -kWuchaAmount; // 实际盘亏
|
assetCountMap.put(assId, statusCount);
|
break;
|
}
|
}
|
}
|
|
for (Integer i = 0; i < queryList.size(); i++) {
|
if(this.isConsum){
|
Consum_Inventory_Detail__c idcQueryObj = (Consum_Inventory_Detail__c) orderMap.get(queryList[i].Id);
|
Id eachId = idcQueryObj.Asset__c;
|
StatusCount eachSCount = assetCountMap.get(eachId);
|
if (eachSCount != null) {
|
idcQueryObj.Inventory_Zaiku_Count_Jia__c = eachSCount.zaikuNum;
|
// 实盘数 (没有实盘的话显示空)
|
if (eachSCount.shipanNum == 0 && eachSCount.ifSPNotNull == false) {
|
idcQueryObj.Inventory_Shipan_Count_Jia__c = null;
|
} else {
|
idcQueryObj.Inventory_Shipan_Count_Jia__c = eachSCount.shipanNum;
|
}
|
idcQueryObj.Inventory_Chujie_Count_Jia__c = eachSCount.chujieNum;
|
idcQueryObj.Inventory_Quantity_Jia__c = eachSCount.quantity;
|
idcQueryObj.Inventory_Deviation_Jia__c = eachSCount.wuchaNum;
|
idcQueryObj.Inventory_Profit_Quantity__c = eachSCount.panyinNum;
|
idcQueryObj.Inventory_Loss_Quantity__c = eachSCount.pankuiNum;
|
idcQueryObj.Consumed_Count_Jia__c = eachSCount.xiaohaoNum;
|
}
|
if (idcQueryObj != null) {
|
viewList.add(new WrapperInfo(idcQueryObj, myComponentController));
|
viewList[viewList.size() - 1].lineNo = viewList.size() - 1; // setChangeFlg用到
|
viewList[viewList.size() - 1].check = true;
|
viewList[viewList.size() - 1].oldCheck = true;
|
}
|
}
|
else{
|
Inventory_Detail__c idcQueryObj = (Inventory_Detail__c) orderMap.get(queryList[i].Id);
|
Id eachId = idcQueryObj.Asset__c;
|
StatusCount eachSCount = assetCountMap.get(eachId);
|
if (eachSCount != null) {
|
idcQueryObj.Inventory_Zaiku_Count_Jia__c = eachSCount.zaikuNum;
|
// 实盘数 (没有实盘的话显示空)
|
if (eachSCount.shipanNum == 0 && eachSCount.ifSPNotNull == false) {
|
idcQueryObj.Inventory_Shipan_Count_Jia__c = null;
|
} else {
|
idcQueryObj.Inventory_Shipan_Count_Jia__c = eachSCount.shipanNum;
|
}
|
idcQueryObj.Inventory_Weixiu_Count_Jia__c = eachSCount.weixiuNum;
|
idcQueryObj.Inventory_Chujie_Count_Jia__c = eachSCount.chujieNum;
|
idcQueryObj.Inventory_Quantity_Jia__c = eachSCount.quantity;
|
idcQueryObj.Inventory_Deviation_Jia__c = eachSCount.wuchaNum;
|
idcQueryObj.Inventory_Profit_Quantity__c = eachSCount.panyinNum;
|
idcQueryObj.Inventory_Loss_Quantity__c = eachSCount.pankuiNum;
|
idcQueryObj.Inventory_Daibaofei_Diushi_Count_Jia__c = eachSCount.diushiNum;
|
idcQueryObj.Inventory_Diaobo_Count_Jia__c = eachSCount.diaoboNum;//20210531 you 1650
|
|
}
|
if (idcQueryObj != null) {
|
viewList.add(new WrapperInfo(idcQueryObj, myComponentController));
|
viewList[viewList.size() - 1].lineNo = viewList.size() - 1; // setChangeFlg用到
|
viewList[viewList.size() - 1].check = true;
|
viewList[viewList.size() - 1].oldCheck = true;
|
}
|
}
|
}
|
}
|
system.debug('●●●●● setViewList END ' );
|
}
|
|
/**
|
* 保存备注&备注人
|
*/
|
public void save() {
|
try{
|
if(this.isConsum){
|
List<Consum_Inventory_Detail__c> changedAsset = new List<Consum_Inventory_Detail__c>();
|
for (WrapperInfo wrapper : this.viewList) {
|
if (wrapper.changeFlg != '0') {
|
changedAsset.add((Consum_Inventory_Detail__c)wrapper.sobj);
|
}
|
}
|
upsert changedAsset;
|
}
|
else{
|
List<Inventory_Detail__c> changedAsset = new List<Inventory_Detail__c>();
|
for (WrapperInfo wrapper : this.viewList) {
|
if (wrapper.changeFlg != '0') {
|
changedAsset.add((Inventory_Detail__c)wrapper.sobj);
|
}
|
}
|
upsert changedAsset;
|
}
|
|
if (saveType == '1') {
|
searchOpp();
|
saveType = '';
|
}
|
} catch (Exception e) {
|
System.debug('Exception caught when save: ' + e.getStackTraceString());
|
ApexPages.addMessages(e);
|
}
|
}
|
|
/************************** 检索条件 **************************/
|
public String modelNo { get; set; } // 备品型号
|
public String assetNumberKey { get; set; } // 固定资产号(key)
|
public String serialNo { get; set; } // 机身号
|
public String whLocation { get; set; } // 货架号
|
public String bpPankuiYing { get; set; } // 盘亏/盘盈
|
public String bpBodyFushupin { get; set; } // 主体/附属品
|
public String ifInternalAsset { get; set; } // 是否固定资产
|
public String bieChanPinFenLei { get; set; } // 产品分类(GI/SP)
|
public String bieBeiPinFenLei { get; set; } // 备品分类
|
public String bieManageType { get; set; } // 管理种类
|
|
// 盘亏/盘盈 SelectOption
|
public List<SelectOption> getbpPankuiYingOps() {
|
return new List<SelectOption>{new SelectOption('', '--全部--'), new SelectOption('Panying', '盘盈'), new SelectOption('Pankui', '盘亏')};
|
}
|
// 主体/附属品 SelectOption
|
public List<SelectOption> getbpBodyFushupinOps() {
|
return new List<SelectOption>{new SelectOption('', '--全部--'), new SelectOption('Zhuti', '主体'), new SelectOption('Fushupin', '附属品')};
|
}
|
// 是否固定资产 SelectOption
|
public List<SelectOption> getifInternalAssetOps() {
|
return new List<SelectOption>{new SelectOption('', '--全部--'), new SelectOption('true', '固定资产'), new SelectOption('false', '非固定资产')};
|
}
|
// 产品分类 SelectOption
|
public List<SelectOption> getbieChanPinFenLeiOps() {
|
return FixtureUtil.bieChanPinFenLeiOpsMap.get('GISP');
|
}
|
// 备品分类 SelectOption
|
public List<SelectOption> getbieBeiPinFenLeiOps() {
|
List<SelectOption> bpfl = FixtureUtil.bieBeiPinFenLeiOpsMap.get('备品分类');
|
if(bpfl.get(3).getLabel() != '检测用备品'){
|
bpfl.add(3, new SelectOption('检测用备品','检测用备品'));
|
}
|
if(bpfl.get(4).getLabel() != '空白'){
|
bpfl.add(4, new SelectOption('空白','空白'));
|
}
|
return bpfl;
|
}
|
// 管理种类 SelectOption
|
public List<SelectOption> getbieManageTypeOps() {
|
return new List<SelectOption>{new SelectOption('', '--全部--'), new SelectOption('数量管理', '数量管理'), new SelectOption('个体管理', '个体管理')};
|
}
|
// 消耗品有效期至 比较符 SelectOption
|
public List<SelectOption> getCompareOperatorOps() {
|
List<SelectOption> options = new List<SelectOption>();
|
options.add(new SelectOption('=', '等于'));
|
options.add(new SelectOption('>', '大于'));
|
options.add(new SelectOption('<', '小于'));
|
options.add(new SelectOption('>=', '大于等于'));
|
options.add(new SelectOption('<=', '小于等于'));
|
return options;
|
}
|
|
// 检索条件
|
private String makeSoql(String keyword) {
|
String soql =' WHERE Sync_Asset_Record_Flag__c = true';
|
soql += ' AND Inventory_Header__c = \'' + String.escapeSingleQuotes(parentId) + '\'';
|
soql += ' AND Internal_asset_location__c = \'' + String.escapeSingleQuotes(parentObj.Internal_asset_location__c) + '\'';
|
if (String.isNotBlank(keyword)) {
|
String[] vals = keyword.split(' ');
|
soql += ' AND (';
|
String fmodelno = '';
|
for (String v : vals) {
|
// 关键字 -- 盘点备注
|
// fmodelno += ' Asset_Status__c LIKE \'%' + String.escapeSingleQuotes(v.replaceAll('%', '\\%')) + '%\' ';
|
fmodelno += ' Inventory_Remarks__c LIKE \'%' + String.escapeSingleQuotes(v.replaceAll('%', '\\%')) + '%\'';
|
fmodelno += 'OR';
|
}
|
fmodelno = fmodelno.removeEnd('OR');
|
soql += fmodelno + ' )';
|
}
|
// 备品配套明细型号
|
if (String.isNotBlank(modelNo)) {
|
soql += ' AND Fixture_Model_No__c = \'' + String.escapeSingleQuotes(modelNo) + '\'';
|
}
|
// 固定资产号(key)
|
if (String.isNotBlank(assetNumberKey)) {
|
soql += ' AND Internal_Asset_number__c = \'' + String.escapeSingleQuotes(assetNumberKey) + '\'';
|
}
|
// 机身号
|
if (String.isNotBlank(serialNo)) {
|
soql += ' AND SerialNumber__c = \'' + String.escapeSingleQuotes(serialNo) + '\'';
|
}
|
// 备品状态
|
if (String.isNotBlank(assetStatus)) {
|
if (assetStatus == '未盘点') soql += ' AND Asset_Inventory_Flg__c = false ';
|
if (assetStatus == '已盘点') soql += ' AND Asset_Inventory_Flg__c = true ';
|
}
|
// 货架号
|
if (String.isNotBlank(whLocation)) {
|
soql += ' AND WH_location__c = \'' + String.escapeSingleQuotes(whLocation) + '\'';
|
}
|
// 盘亏/盘盈
|
if (bpPankuiYing == 'Panying') {
|
soql += ' AND Sync_Asset_Profit_Quantity__c > 0 ';
|
} else if (bpPankuiYing == 'Pankui') {
|
soql += ' AND Sync_Asset_Frozen_Quantity__c > 0 ';
|
}
|
// 主体/附属品
|
if (bpBodyFushupin == 'Zhuti') {
|
soql += ' AND Main_OneToOne__c = true ';
|
} else if (bpBodyFushupin == 'Fushupin') {
|
soql += ' AND Loaner_accsessary__c = true ';
|
}
|
// 是否固定资产
|
if (ifInternalAsset == 'true') {
|
soql += ' AND Internal_Asset_number__c <> null ';
|
} else if (ifInternalAsset == 'false') {
|
soql += ' AND Internal_Asset_number__c = null ';
|
}
|
// 产品分类(GI/SP)
|
if (String.isNotBlank(bieChanPinFenLei)) {
|
soql += ' AND Product_category__c = \'' + String.escapeSingleQuotes(bieChanPinFenLei) + '\'';
|
}
|
// 备品分类
|
if (String.isNotBlank(bieBeiPinFenLei)) {
|
if((bieBeiPinFenLei) == '空白'){
|
soql += ' AND Equipment_Type__c = null';
|
}
|
else {
|
soql += ' AND Equipment_Type__c = \'' + String.escapeSingleQuotes(bieBeiPinFenLei) + '\'';
|
}
|
}
|
// 管理种类
|
if (String.isNotBlank(bieManageType)) {
|
soql += ' AND Manage_type__c = \'' + String.escapeSingleQuotes(bieManageType) + '\'';
|
}
|
// 消耗品有效期
|
if (this.isConsum && String.isNotBlank(String.valueOf(sampleCiDetail.Consumable_Guaranteen_end__c))) {
|
soql += ' AND Consumable_Guaranteen_end__c ' + compareOperator + String.escapeSingleQuotes(String.valueOf(sampleCiDetail.Consumable_Guaranteen_end__c));
|
}
|
|
return soql;
|
}
|
|
public class StatusCount {
|
public Integer zaikuNum; // 应盘在库+应盘冻结
|
public Integer shipanNum; // 实盘
|
public Integer weixiuNum; // 实盘维修
|
public Integer chujieNum; // 实盘出借
|
public Integer diushiNum; // 实盘丢失
|
public Integer xiaohaoNum; // 实盘消耗
|
public Integer quantity; // 应盘数量
|
public Integer wuchaNum; // 盘点误差(盘盈/盘亏)
|
public Integer panyinNum; // 盘点误差(盘盈)
|
public Integer pankuiNum; // 盘点误差(盘亏)
|
public Boolean ifSPNotNull;// 是否实盘过
|
public Integer diaoboNum; // 实盘调拨 20210531 you 1650
|
|
public StatusCount(Integer initData) {
|
this.zaikuNum = initData;
|
this.shipanNum = initData;
|
this.weixiuNum = initData;
|
this.chujieNum = initData;
|
this.diushiNum = initData;
|
this.xiaohaoNum = initData;
|
this.quantity = initData;
|
this.wuchaNum = initData;
|
this.panyinNum = initData;
|
this.pankuiNum = initData;
|
this.ifSPNotNull = false;
|
this.diaoboNum = initData;// 20210531 you 1650
|
}
|
}
|
|
}
|