| | |
| | | /* |
| | | * @Description: |
| | | * @version: |
| | | * @Author: chen jing wu |
| | | * @Date: 2023-07-12 11:08:28 |
| | | * @LastEditors: chen jing wu |
| | | * @LastEditTime: 2023-08-08 18:43:40 |
| | | */ |
| | | public with sharing class InventoryResultRecordController { |
| | | // 按钮区域 |
| | | public Boolean inventoryBlueFlag {get; private set;} // 查看盘点蓝色按钮Flag |
| | | public Boolean rentBlueFlag {get; private set;} // 查看备品蓝色按钮Flag |
| | | public Boolean consumBlueFlag {get; private set;} // 查看耗材盘点蓝色按钮Flag |
| | | // 检索区域 |
| | | public String fixtureModelNo {get; set;} // 备品配套明细型号 Fixture_Model_No__c |
| | | public String assetStatus {get; set;} // 备品状态 Asset_Status__c |
| | |
| | | private String mainAstQR = ''; |
| | | public boolean doneFlg {get; set;} |
| | | public boolean canDoFlg {get; set;} |
| | | public List<AggregateResult> idListBean = new List<AggregateResult>(); |
| | | public List<AggregateResult> cidListBean = new List<AggregateResult>(); |
| | | |
| | | public List<SelectOption> assetStatusOptionList { |
| | | get { |
| | |
| | | selectOptions.add(new SelectOption('耗材', '耗材')); |
| | | return selectOptions; |
| | | } |
| | | } |
| | | |
| | | // 初始化按钮颜色 |
| | | public void initSearchButtonColor() { |
| | | inventoryBlueFlag = true; |
| | | rentBlueFlag = false; |
| | | consumBlueFlag = false; |
| | | } |
| | | |
| | | // 所在地区(本部)PlickList |
| | |
| | | |
| | | // 画面初始化 |
| | | public void init() { |
| | | initSearchButtonColor(); |
| | | angecylookrole = false; |
| | | bpPankuiYing = NONE; |
| | | ifInternalAsset = NONE; |
| | |
| | | inventoryHeader = ih; |
| | | canDoFlg = canDoFlg || !System.Approval.isLocked(inventoryHeader.Id); |
| | | |
| | | List<AggregateResult> fixAssetList = [ |
| | | idListBean = [ |
| | | Select Internal_Asset_Flg__c fix, Asset_Status__c status, sum(toAbandon_amount__c) abAmount, sum(Amount__c) amount, sum(Inventory_Count__c) acAmount |
| | | From Inventory_Detail__c//20210525 you 1650 |
| | | Where Inventory_Header__c = :inventoryHeader.Id AND Asset_Status__c <> '丢失借出明细' AND Asset_Status__c <> '丢失调拨明细' |
| | | group by Internal_Asset_Flg__c, Asset_Status__c]; |
| | | unfixAssetMap = getInitData(fixAssetList, 'unfix'); |
| | | fixAssetMap = getInitData(fixAssetList, 'fix'); |
| | | //20230506 sx DB202303526794【系统调查】备品中心盘点系统调查 start |
| | | // unfixAssetMap = getInitData(aBean, 'unfix'); |
| | | // fixAssetMap = getInitData(aBean, 'fix'); |
| | | //20230506 sx DB202303526794【系统调查】备品中心盘点系统调查 end |
| | | } |
| | | } |
| | | else{ |
| | |
| | | else{ |
| | | consumInventoryHeader = ih; |
| | | canDoFlg = canDoFlg || !System.Approval.isLocked(consumInventoryHeader.Id); |
| | | List<AggregateResult> consumAssetList = [ |
| | | cidListBean = [ |
| | | Select Internal_Asset_Flg__c fix, Asset_Status__c status, sum(toAbandon_amount__c) abAmount, sum(Amount__c) amount, sum(Inventory_Count__c) acAmount |
| | | From Consum_Inventory_Detail__c |
| | | Where Inventory_Header__c = :consumInventoryHeader.Id |
| | | AND Asset_Status__c != '已消耗明细' |
| | | group by Internal_Asset_Flg__c, Asset_Status__c]; |
| | | consumAssetMap = getInitData(consumAssetList, 'consum'); |
| | | //20230506 sx DB202303526794【系统调查】备品中心盘点系统调查 start |
| | | //consumAssetMap = getInitData(aBean, 'consum'); |
| | | //20230506 sx DB202303526794【系统调查】备品中心盘点系统调查 end |
| | | } |
| | | } |
| | | else{ |
| | |
| | | } |
| | | } |
| | | } |
| | | //System.assertEquals('qyj','unfixAssetMap'+unfixAssetMap); |
| | | //System.assertEquals('qyj','fixAssetMap'+fixAssetMap); |
| | | //System.assertEquals('qyj','consumAssetMap'+consumAssetMap); |
| | | sumRateMap = getRateMap(unfixAssetMap.get('allsum')+fixAssetMap.get('allsum')+consumAssetMap.get('allsum') |
| | | , unfixAssetMap.get('dsum')+fixAssetMap.get('dsum')+consumAssetMap.get('dsum') |
| | | , unfixAssetMap.get('acsum')+fixAssetMap.get('acsum')+consumAssetMap.get('acsum')); |
| | | |
| | | //sumRateMap = getRateMap(unfixAssetMap.get('allsum')+fixAssetMap.get('allsum')+consumAssetMap.get('allsum') |
| | | // , unfixAssetMap.get('dsum')+fixAssetMap.get('dsum')+consumAssetMap.get('dsum') |
| | | // , unfixAssetMap.get('acsum')+fixAssetMap.get('acsum')+consumAssetMap.get('acsum')); |
| | | } |
| | | |
| | | //20230506 sx DB202303526794【系统调查】备品中心盘点系统调查 start |
| | | public void showResult() { |
| | | unfixAssetMap = getInitData(new List<AggregateResult>(), 'unfix'); |
| | | fixAssetMap = getInitData(new List<AggregateResult>(), 'fix'); |
| | | consumAssetMap = getInitData(new List<AggregateResult>(), 'consum'); |
| | | List<Inventory_Header__c> ihList = [ |
| | | select Id, Inventory_Status__c, Name, Internal_asset_location__c, Inventory_Start_Date__c, Fixture_Header__c |
| | | from Inventory_Header__c |
| | | where Inventory_Status__c <> '已批准' and Internal_asset_location__c =:bieCunFangDi |
| | | and Inventory_Start_Date__c = LAST_N_DAYS:30 |
| | | ORDER BY Fixture_Header__c NULLS FIRST]; |
| | | System.debug('20230710 00:28--ihList--' + ihList); |
| | | for(Inventory_Header__c ih:ihList){ |
| | | if(String.isBlank(ih.Fixture_Header__c)) { |
| | | if( String.isNotBlank(ih.Inventory_Status__c)){ |
| | | if (ih.Inventory_Status__c == '处理中') { |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '盘点处理中,请等待Batch处理完毕。Batch处理完毕后会发送处理结果邮件。')); |
| | | } |
| | | else{ |
| | | unfixAssetMap = getInitData(idListBean, 'unfix'); |
| | | fixAssetMap = getInitData(idListBean, 'fix'); |
| | | } |
| | | } |
| | | else{ |
| | | unfixAssetMap = getInitData(new List<AggregateResult>(), 'unfix'); |
| | | fixAssetMap = getInitData(new List<AggregateResult>(), 'fix'); |
| | | } |
| | | } |
| | | else { |
| | | if (String.isNotBlank(ih.Inventory_Status__c)) { |
| | | if (ih.Inventory_Status__c == '处理中') { |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '耗材盘点处理中,请等待Batch处理完毕。Batch处理完毕后会发送处理结果邮件。')); |
| | | } |
| | | else{ |
| | | consumAssetMap = getInitData(cidListBean, 'consum'); |
| | | } |
| | | } |
| | | else{ |
| | | consumAssetMap = getInitData(new List<AggregateResult>(), 'consum'); |
| | | } |
| | | } |
| | | } |
| | | |
| | | sumRateMap = getRateMap(unfixAssetMap.get('allsum')+fixAssetMap.get('allsum')+consumAssetMap.get('allsum') |
| | | , unfixAssetMap.get('dsum')+fixAssetMap.get('dsum')+consumAssetMap.get('dsum') |
| | | , unfixAssetMap.get('acsum')+fixAssetMap.get('acsum')+consumAssetMap.get('acsum')); |
| | | } |
| | | //20230506 sx DB202303526794【系统调查】备品中心盘点系统调查 end |
| | | |
| | | //public void checkQRCode() { |
| | | // String soqlWhere = ''; |
| | |
| | | Decimal newCount_int = newCount == null ? 0 : newCount; |
| | | if (oldCount_int == newCount_int && !((oldCount == null && newCount == 0) || (oldCount == 0 && newCount == null))) continue; |
| | | |
| | | // 【FY24大及巨大课题】北京新法规项目对应 DB202307428742 20230804 by lc Start |
| | | if (String.isBlank(idc.Appearance_Check_Result__c) || String.isBlank(idc.Package_Check_Result__c)) { |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '外观和包装必须有值,请重新确认。')); |
| | | return; |
| | | } |
| | | // 【FY24大及巨大课题】北京新法规项目对应 DB202307428742 20230804 by lc End |
| | | if (idc.Inventory_Count__c != null) { |
| | | idc.InventoryPerson1__c = inventoryUser1 == NONE ? null : inventoryUser1; |
| | | idc.InventoryPerson2__c = inventoryUser2 == NONE ? null : inventoryUser2; |
| | |
| | | Decimal newCount_int = newCount == null ? 0 : newCount; |
| | | if (oldCount_int == newCount_int && !((oldCount == null && newCount == 0) || (oldCount == 0 && newCount == null))) continue; |
| | | |
| | | // 【FY24大及巨大课题】北京新法规项目对应 DB202307428742 20230804 by lc Start |
| | | if (String.isBlank(idc.Expiration_Check_Result__c) || String.isBlank(idc.Appearance_Check_Result__c) || String.isBlank(idc.Package_Check_Result__c)) { |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '效期、外观和包装必须有值,请重新确认。')); |
| | | return; |
| | | } |
| | | // 【FY24大及巨大课题】北京新法规项目对应 DB202307428742 20230804 by lc End |
| | | if (idc.Inventory_Count__c != null) { |
| | | idc.InventoryPerson1__c = inventoryUser1 == NONE ? null : inventoryUser1; |
| | | idc.InventoryPerson2__c = inventoryUser2 == NONE ? null : inventoryUser2; |
| | |
| | | } catch (exception e) { |
| | | doneFlg = false; |
| | | System.debug(e.getStackTraceString()); |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,e.getMessage())); |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,e.getDmlMessage(0))); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void searchBtn() { |
| | |
| | | } |
| | | String soqlAsset = 'select ' |
| | | + 'Id, Asset__r.SerialNumber, Inventory_Count__c, Asset__c, Asset__r.Manage_type__c, ' |
| | | + ' Fixture_Model_No__c, Fixture_QRCode__c, Asset_Status__c, WH_location__c, Amount__c, Salesdepartment__c,Asset__r.Product2.Packing_list_Fixture_F__c'; |
| | | + ' Fixture_Model_No__c, Fixture_QRCode__c, Asset_Status__c, WH_location__c, Amount__c, Salesdepartment__c,Asset__r.Product2.Packing_list_Fixture_F__c' |
| | | // 【FY24大及巨大课题】北京新法规项目对应 DB202307428742 20230801 by lc Start |
| | | + ', Appearance_Check_Result__c, Package_Check_Result__c'; |
| | | // 【FY24大及巨大课题】北京新法规项目对应 DB202307428742 20230801 by lc End |
| | | if(isConsum){ |
| | | soqlAsset += ', Barcode__c, Asset__r.Product_Serial_No__c '; |
| | | //add by rentx 20210823 start 耗材盘点时记录code ---- |
| | | soqlAsset += ', HCCodes__c '; |
| | | //add by rentx 20210823 end 耗材盘点时记录code |
| | | // 【FY24大及巨大课题】北京新法规项目对应 DB202307428742 20230801 by lc Start |
| | | soqlAsset += ', Expiration_Check_Result__c, Consumable_Guaranteen_end__c '; |
| | | // 【FY24大及巨大课题】北京新法规项目对应 DB202307428742 20230801 by lc End |
| | | soqlAsset += 'from Consum_Inventory_Detail__c '; |
| | | } |
| | | else{ |
| | |
| | | allHCCodelist.add(idl.HCCodes__c); |
| | | //add by rentx 20210901 end |
| | | } |
| | | List<AggregateResult> consumAssetList = [ |
| | | Select Internal_Asset_Flg__c fix, Asset_Status__c status, sum(toAbandon_amount__c) abAmount, sum(Amount__c) amount, sum(Inventory_Count__c) acAmount |
| | | From Consum_Inventory_Detail__c |
| | | Where Inventory_Header__c = : ih.Id |
| | | and Asset_Status__c != '已消耗明细' |
| | | group by Internal_Asset_Flg__c, Asset_Status__c]; |
| | | consumAssetMap = getInitData(consumAssetList, 'consum'); |
| | | //20230506 sx DB202303526794【系统调查】备品中心盘点系统调查 start |
| | | // List<AggregateResult> consumAssetList = [ |
| | | // Select Internal_Asset_Flg__c fix, Asset_Status__c status, sum(toAbandon_amount__c) abAmount, sum(Amount__c) amount, sum(Inventory_Count__c) acAmount |
| | | // From Consum_Inventory_Detail__c |
| | | // Where Inventory_Header__c = : ih.Id |
| | | // and Asset_Status__c != '已消耗明细' |
| | | // group by Internal_Asset_Flg__c, Asset_Status__c]; |
| | | // consumAssetMap = getInitData(consumAssetList, 'consum'); |
| | | //20230506 sx DB202303526794【系统调查】备品中心盘点系统调查 end |
| | | } |
| | | else{ |
| | | inventoryDetailList = Database.query(soqlAsset); |
| | |
| | | oldCountMap.put(idl.Id, idl.Inventory_Count__c); |
| | | } |
| | | |
| | | List<AggregateResult> fixAssetList = [ |
| | | //20230506 sx DB202303526794【系统调查】备品中心盘点系统调查 start |
| | | /*List<AggregateResult> fixAssetList = [ |
| | | Select Internal_Asset_Flg__c fix, Asset_Status__c status, sum(toAbandon_amount__c) abAmount, sum(Amount__c) amount, sum(Inventory_Count__c) acAmount |
| | | From Inventory_Detail__c //20210525 you 1650 |
| | | Where Inventory_Header__c = :ih.Id AND Asset_Status__c <> '丢失借出明细' AND Asset_Status__c <> '丢失调拨明细' |
| | | group by Internal_Asset_Flg__c, Asset_Status__c]; |
| | | unfixAssetMap = getInitData(fixAssetList, 'unfix'); |
| | | fixAssetMap = getInitData(fixAssetList, 'fix'); |
| | | fixAssetMap = getInitData(fixAssetList, 'fix');*/ |
| | | //20230506 sx DB202303526794【系统调查】备品中心盘点系统调查 end |
| | | } |
| | | } |
| | | sumRateMap = getRateMap(unfixAssetMap.get('allsum')+fixAssetMap.get('allsum')+consumAssetMap.get('allsum') |
| | | |
| | | //20230506 sx DB202303526794【系统调查】备品中心盘点系统调查 start |
| | | /*sumRateMap = getRateMap(unfixAssetMap.get('allsum')+fixAssetMap.get('allsum')+consumAssetMap.get('allsum') |
| | | , unfixAssetMap.get('dsum')+fixAssetMap.get('dsum')+consumAssetMap.get('dsum') |
| | | , unfixAssetMap.get('acsum')+fixAssetMap.get('acsum')+consumAssetMap.get('acsum')); |
| | | //System.assertEquals('qyj',''+sumRateMap); |
| | | |
| | | |
| | | , unfixAssetMap.get('acsum')+fixAssetMap.get('acsum')+consumAssetMap.get('acsum'));*/ |
| | | //20230506 sx DB202303526794【系统调查】备品中心盘点系统调查 end |
| | | |
| | | List<Inventory_User_Permission__mdt> usrList = [select InventoryUser__c from Inventory_User_Permission__mdt where Label = :bieCunFangDi]; |
| | | Id[] usrArray = usrList[0].InventoryUser__c.split(','); |
| | |
| | | } |
| | | return rateMap; |
| | | } |
| | | @TestVisible private static void test() { |
| | | Integer i = 0; |
| | | |
| | | } |
| | | } |