| | |
| | | public with sharing class LexOverdueStockController { |
| | | |
| | | /*****************検索用******************/ |
| | | public static String barcode { get; set; } |
| | | |
| | |
| | | } |
| | | |
| | | public LexOverdueStockController() { |
| | | |
| | | } |
| | | |
| | | // 画面初始化 |
| | |
| | | codPageRecords = new List<orderBean>(); |
| | | overduePageRecords = new List<orderBean>(); |
| | | // 获取用户和经销商信息 |
| | | user Useracc = [select Accountid, Work_Location__c,UserPro_Type__c from user where id =: UserInfo.getUserId()]; |
| | | user Useracc = [ |
| | | SELECT Accountid, Work_Location__c, UserPro_Type__c |
| | | FROM user |
| | | WHERE id = :UserInfo.getUserId() |
| | | ]; |
| | | userWorkLocation = Useracc.Work_Location__c; |
| | | agencyProType = Useracc.UserPro_Type__c; |
| | | if(String.isBlank(Useracc.UserPro_Type__c)){ |
| | | agencyProType = 'ET'; |
| | | } |
| | | sqlagencyProType = '%' + agencyProType + '%'; |
| | | accountInfo = [SELECT id,Name,Dealer_discount__c FROM account WHERE id =:Useracc.accountid]; |
| | | accountInfo = [ |
| | | SELECT id, Name, Dealer_discount__c |
| | | FROM account |
| | | WHERE id = :Useracc.accountid |
| | | ]; |
| | | // 过期库存汇总信息 |
| | | List<AggregateResult> orderDetZaiku = [SELECT count(Id) countsum, |
| | | List<AggregateResult> orderDetZaiku = [ |
| | | SELECT |
| | | count(Id) countsum, |
| | | Consumable_Product__c prodid, |
| | | Consumable_Product__r.Name_Text__c prodname, |
| | | Box_Piece__c boxPiece |
| | | FROM Consumable_order_details2__c |
| | | WHERE Dealer_Arrive__c = true |
| | | AND Dealer_Shipment__c = false |
| | | AND Dealer_Saled__c = false |
| | | AND Lose_Flag__c = false |
| | | WHERE |
| | | Dealer_Arrive__c = TRUE |
| | | AND Dealer_Shipment__c = FALSE |
| | | AND Dealer_Saled__c = FALSE |
| | | AND Lose_Flag__c = FALSE |
| | | AND Isoverdue__c = 0 |
| | | AND Dealer_Returned__c = false |
| | | AND Cancellation_Flag__c = false |
| | | AND Bar_Code__c !=null |
| | | AND Product_Type__c like : sqlagencyProType |
| | | AND Dealer_Returned__c = FALSE |
| | | AND Cancellation_Flag__c = FALSE |
| | | AND Bar_Code__c != NULL |
| | | AND Product_Type__c LIKE :sqlagencyProType |
| | | AND Dealer_Info_text__c = :accountInfo.Name |
| | | AND Arrive_Owner_Work_Location__c = :userWorkLocation |
| | | group by Consumable_Product__c,Box_Piece__c,Consumable_Product__r.Name_Text__c]; |
| | | GROUP BY |
| | | Consumable_Product__c, |
| | | Box_Piece__c, |
| | | Consumable_Product__r.Name_Text__c |
| | | ]; |
| | | |
| | | for(AggregateResult overdue : orderDetZaiku){ |
| | | codPageRecords.add(new orderBean(overdue)); |
| | |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | | return res; |
| | | |
| | | } |
| | | |
| | | // BarCode录入 |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC searchorderBean(String agencyProTypeLWC,String userWorkLocationLWC,String accountNameLWC,String barcodeLWC,String codPageRecordsLWC){ |
| | | public static ResponseBodyLWC searchorderBean( |
| | | String agencyProTypeLWC, |
| | | String userWorkLocationLWC, |
| | | String accountNameLWC, |
| | | String barcodeLWC, |
| | | String codPageRecordsLWC |
| | | ) { |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | List<orderBean> codPageRecords = (List<orderBean>)JSON.deserialize(codPageRecordsLWC,List<orderBean>.class); |
| | | List<orderBean> codPageRecords = (List<orderBean>) JSON.deserialize( |
| | | codPageRecordsLWC, |
| | | List<orderBean>.class |
| | | ); |
| | | sqlagencyProType = '%' + agencyProTypeLWC + '%'; |
| | | system.debug('sqlagencyProType==>'+ sqlagencyProType); |
| | | barcode = barcodeLWC; |
| | |
| | | userWorkLocation = userWorkLocationLWC; |
| | | // add by Wang Xueqin 2023/04/12 |
| | | // 获取用户和经销商信息 |
| | | user Useracc = [select Accountid, Work_Location__c,UserPro_Type__c from user where id =: UserInfo.getUserId()]; |
| | | accountInfo = [SELECT id,Name,Dealer_discount__c FROM account WHERE id =:Useracc.accountid]; |
| | | |
| | | user Useracc = [ |
| | | SELECT Accountid, Work_Location__c, UserPro_Type__c |
| | | FROM user |
| | | WHERE id = :UserInfo.getUserId() |
| | | ]; |
| | | accountInfo = [ |
| | | SELECT id, Name, Dealer_discount__c |
| | | FROM account |
| | | WHERE id = :Useracc.accountid |
| | | ]; |
| | | |
| | | iSinventory = true; |
| | | Set<String> barCodeoverdue = new Set<String>(); |
| | |
| | | codPage.pandian = 0; |
| | | } |
| | | // 查询所有过期库存 |
| | | List<Consumable_order_details2__c> orderDetZaiku = [select Id, Name,Consumable_Product__c, |
| | | Bar_Code__c,Consumable_Product__r.Name__c,Dealer_Info_text__c, |
| | | Asset_Model_No__c,Isoverdue__c,Box_Piece__c,Sterilization_limit__c, |
| | | List<Consumable_order_details2__c> orderDetZaiku = [ |
| | | SELECT |
| | | Id, |
| | | Name, |
| | | Consumable_Product__c, |
| | | Bar_Code__c, |
| | | Consumable_Product__r.Name__c, |
| | | Dealer_Info_text__c, |
| | | Asset_Model_No__c, |
| | | Isoverdue__c, |
| | | Box_Piece__c, |
| | | Sterilization_limit__c, |
| | | Bar_Code_search__c |
| | | FROM Consumable_order_details2__c |
| | | WHERE Dealer_Arrive__c = true |
| | | AND Dealer_Shipment__c = false |
| | | AND Dealer_Saled__c = false |
| | | AND Lose_Flag__c = false |
| | | WHERE |
| | | Dealer_Arrive__c = TRUE |
| | | AND Dealer_Shipment__c = FALSE |
| | | AND Dealer_Saled__c = FALSE |
| | | AND Lose_Flag__c = FALSE |
| | | AND Isoverdue__c = 0 |
| | | AND Dealer_Returned__c = false |
| | | AND Cancellation_Flag__c = false |
| | | AND Bar_Code__c !=null |
| | | AND Product_Type__c like : sqlagencyProType |
| | | AND Dealer_Returned__c = FALSE |
| | | AND Cancellation_Flag__c = FALSE |
| | | AND Bar_Code__c != NULL |
| | | AND Product_Type__c LIKE :sqlagencyProType |
| | | AND Dealer_Info_text__c = :accountInfo.Name |
| | | AND Arrive_Owner_Work_Location__c = :userWorkLocation]; |
| | | AND Arrive_Owner_Work_Location__c = :userWorkLocation |
| | | ]; |
| | | // 没有输入条码时,循环页面,所有打钩产品全部销存 |
| | | // 取得所有 |
| | | overdueList = new List<Consumable_order_details2__c>(); |
| | |
| | | for(orderBean codPage : codPageRecords){ |
| | | if (codPage.check) { |
| | | for(Consumable_order_details2__c cod2 : orderDetZaiku){ |
| | | if(cod2.Consumable_Product__c == codPage.prodid && codPage.boxPiece == cod2.Box_Piece__c){ |
| | | if ( |
| | | cod2.Consumable_Product__c == codPage.prodid && |
| | | codPage.boxPiece == cod2.Box_Piece__c |
| | | ) { |
| | | overduePageRecords.add(new orderBean(cod2,'过期库存销存')); |
| | | overdueList.add(cod2); |
| | | } |
| | |
| | | // 输入barcode时 |
| | | |
| | | // BarCode的检索 所有在库 |
| | | List<Consumable_order_details2__c> reSet = [select Id,Consumable_Product__c, |
| | | Consumable_Product__r.Name__c,Box_Piece__c,Bar_Code_search__c, |
| | | Dealer_Shipment__c,Dealer_Saled__c,Lose_Flag__c,Bar_Code__c, |
| | | Cancellation_Flag__c,Isoverdue__c,Sterilization_limit__c |
| | | from Consumable_order_details2__c |
| | | where Bar_Code_search__c in :BarCodeListP |
| | | AND Dealer_Arrive__c = true |
| | | AND Cancellation_Flag__c = false |
| | | and Dealer_Returned__c = false |
| | | and Bar_Code__c !=null |
| | | AND Product_Type__c like : sqlagencyProType |
| | | List<Consumable_order_details2__c> reSet = [ |
| | | SELECT |
| | | Id, |
| | | Consumable_Product__c, |
| | | Consumable_Product__r.Name__c, |
| | | Box_Piece__c, |
| | | Bar_Code_search__c, |
| | | Dealer_Shipment__c, |
| | | Dealer_Saled__c, |
| | | Lose_Flag__c, |
| | | Bar_Code__c, |
| | | Cancellation_Flag__c, |
| | | Isoverdue__c, |
| | | Sterilization_limit__c |
| | | FROM Consumable_order_details2__c |
| | | WHERE |
| | | Bar_Code_search__c IN :BarCodeListP |
| | | AND Dealer_Arrive__c = TRUE |
| | | AND Cancellation_Flag__c = FALSE |
| | | AND Dealer_Returned__c = FALSE |
| | | AND Bar_Code__c != NULL |
| | | AND Product_Type__c LIKE :sqlagencyProType |
| | | AND Arrive_Owner_Work_Location__c =: userWorkLocation |
| | | AND Dealer_Info_text__c = :accountInfo.Name |
| | | order by Name]; |
| | | ORDER BY Name |
| | | ]; |
| | | |
| | | System.debug('reSet===>'+reSet); |
| | | |
| | | |
| | | for(Consumable_order_details2__c cod2 : reSet){ |
| | | if ((cod2.Dealer_Shipment__c == false && cod2.Dealer_Saled__c == false |
| | | && cod2.Lose_Flag__c == false && cod2.Cancellation_Flag__c == false) && cod2.Isoverdue__c == 0) { |
| | | if ( |
| | | (cod2.Dealer_Shipment__c == false && |
| | | cod2.Dealer_Saled__c == false && |
| | | cod2.Lose_Flag__c == false && |
| | | cod2.Cancellation_Flag__c == false) && cod2.Isoverdue__c == 0 |
| | | ) { |
| | | for (orderBean codPage : codPageRecords) { |
| | | if(cod2.Consumable_Product__c == codPage.prodid && cod2.Box_Piece__c == codPage.boxPiece){ |
| | | if ( |
| | | cod2.Consumable_Product__c == codPage.prodid && |
| | | cod2.Box_Piece__c == codPage.boxPiece |
| | | ) { |
| | | overduePageRecords.add(new orderBean(cod2,'过期库存销存')); |
| | | overdueList.add(cod2); |
| | | codPage.pandian ++; |
| | |
| | | return res; |
| | | } |
| | | |
| | | |
| | | // 保存按钮 |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC save(Boolean iSinventory,string saveCodPageRecords,List<Consumable_order_details2__c> saveoverdueList) { |
| | | public static ResponseBodyLWC save( |
| | | Boolean iSinventory, |
| | | string saveCodPageRecords, |
| | | List<Consumable_order_details2__c> saveoverdueList |
| | | ) { |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | |
| | | |
| | | // } |
| | | |
| | | List<orderBean> codPageRecords = (List<orderBean>)JSON.deserialize(saveCodPageRecords,List<orderBean>.class); |
| | | List<orderBean> codPageRecords = (List<orderBean>) JSON.deserialize( |
| | | saveCodPageRecords, |
| | | List<orderBean>.class |
| | | ); |
| | | // List<Consumable_order_details2__c> overdueList = (List<Consumable_order_details2__c>)JSON.deserialize(saveoverdueList,List<Consumable_order_details2__c>.class); |
| | | // add by Wang Xueqin 2023/04/12 |
| | | // 获取用户和经销商信息 |
| | | user Useracc = [select Accountid, Work_Location__c,UserPro_Type__c from user where id =: UserInfo.getUserId()]; |
| | | accountInfo = [SELECT id,Name,Dealer_discount__c FROM account WHERE id =:Useracc.accountid]; |
| | | user Useracc = [ |
| | | SELECT Accountid, Work_Location__c, UserPro_Type__c |
| | | FROM user |
| | | WHERE id = :UserInfo.getUserId() |
| | | ]; |
| | | accountInfo = [ |
| | | SELECT id, Name, Dealer_discount__c |
| | | FROM account |
| | | WHERE id = :Useracc.accountid |
| | | ]; |
| | | |
| | | // 跳过明细2不必要更新 |
| | | StaticParameter.EscapeConsumableOrderDetail2Trigger = true; |
| | | if(!iSinventory){ |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'请先点【BarCode录入】')); |
| | | return new ResponseBodyLWC('Error',500, '请先点击获取明细', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请先录入BarCode', ''); |
| | | // return null; |
| | | } |
| | | integer Lo = 0; |
| | |
| | | po.RecordTypeid = System.Label.RT_ConOrder_Overdue; |
| | | try{ |
| | | insert po; |
| | | Consumable_order__c order = [SELECT Name FROM Consumable_order__c WHERE id =:po.id]; |
| | | List<Consumable_orderdetails__c> InsList = New List<Consumable_orderdetails__c>(); |
| | | Consumable_order__c order = [ |
| | | SELECT Name |
| | | FROM Consumable_order__c |
| | | WHERE id = :po.id |
| | | ]; |
| | | List<Consumable_orderdetails__c> InsList = new List<Consumable_orderdetails__c>(); |
| | | for(orderBean header : codPageRecords){ |
| | | if(header.check==true){ |
| | | Consumable_orderdetails__c insPan = new Consumable_orderdetails__c(); |
| | |
| | | cod.Inventory_date__c = Date.today(); |
| | | cod.Lose_reason__c = '过期库存销存'; |
| | | cod.Lose_Flag__c = true; |
| | | |
| | | } |
| | | if(overdueList.size()>0){ |
| | | ControllerUtil.updateOrderDetailsSatus(overdueList); |
| | | } |
| | | |
| | | }catch (Exception ex) { |
| | | Database.rollback(sp); |
| | | ApexPages.addMessages(ex); |
| | |
| | | // 将页面或取得BarCode去掉重复的,转换成List |
| | | public static List<String> ParseBarCode(String Code){ |
| | | Map<String,Integer> barcodeCountMap = new Map<String,Integer>(); |
| | | String[] Cache = new String[]{}; |
| | | String[] Cache = new List<String>{}; |
| | | Cache = Code.split('\n'); |
| | | List <String> Buff = new List<String>(); |
| | | for(String A : Cache){ |
| | |
| | | } |
| | | |
| | | // Data Bean |
| | | @TestVisible |
| | | class orderBean implements Comparable { |
| | | @AuraEnabled |
| | | public Consumable_order_details2__c orderdetails2 { get; set; } |