| | |
| | | public without sharing class LexSummonsCreatController { |
| | | |
| | | public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe(); |
| | | |
| | | /*****************検索用******************/ |
| | |
| | | public static List<SelectOption> category4OptionList { get; set; } |
| | | public static List<SelectOption> category5OptionList { get; set; } |
| | | @AuraEnabled |
| | | public static Map<String,String> categoryOptionMap { get; set; } |
| | | public static Map<String, String> categoryOptionMap { get; set; } |
| | | @AuraEnabled |
| | | public static Map<String,String> category4OptionMap { get; set; } |
| | | public static Map<String, String> category4OptionMap { get; set; } |
| | | @AuraEnabled |
| | | public static Map<String,String> category5OptionMap { get; set; } |
| | | public static Map<String, String> category5OptionMap { get; set; } |
| | | /*****************画面表示Bean******************/ |
| | | private static List<ConsumableorderdetailsInfo> consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>(); |
| | | //明细2 |
| | | @AuraEnabled |
| | | public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecords { get; set; } |
| | | //错误明细 |
| | | @AuraEnabled |
| | | public static List<ConsumableorderdetailsInfo> consumableorderdetailsRecordserror { get; set; } |
| | | @AuraEnabled |
| | | public static List<ConsumableorderdetailsInfo> pageRecords { get; set; } |
| | | public static List<ConsumableorderdetailsInfoLwc> pageRecordsLwc { get; set; } |
| | |
| | | private static List<ConsumableorderdetailsInfo> consumableproductdetailsRecords = new List<ConsumableorderdetailsInfo>(); |
| | | private static List<Attachment> attachmentinfo = new List<Attachment>(); |
| | | public static List<Product2__c> product2Selected = new List<Product2__c>(); |
| | | @AuraEnabled |
| | | public static Map<String, String> orderpieceorboxMap { get; set; } |
| | | @AuraEnabled |
| | | public static List<Consumable_orderdetails__c> orderdetails { get; set; } |
| | | @AuraEnabled |
| | | public static Map<String, Decimal> orderagencypriceMap { get; set; } |
| | | @AuraEnabled |
| | | public static Map<String, Decimal> orderpriceMap { get; set; } |
| | | @AuraEnabled |
| | | public static Map<String, Decimal> orderdetCountMap { get; set; } |
| | | @AuraEnabled |
| | | public static Boolean hasSpecialHos { get; set; } |
| | | //选择产品size |
| | | public static Integer consumableorderdetailsCount { |
| | | get { |
| | |
| | | public static Boolean EditDelCommitBtnDisabled { get; private set; } |
| | | public static Boolean saveBtnDisabled { get; private set; } |
| | | public static Boolean SorderBtnDisabled { get; private set; } |
| | | |
| | | // page |
| | | public static Integer pagesize { get; set; } |
| | | public static Integer pageToken { get; set; } |
| | | //public static String sortField { get; set; } |
| | | //public static String sortOrder { get; set; } |
| | | public static Integer totalcount { get; set; } |
| | | public static Integer addSize { get; set; } |
| | | //List<ConsumableorderdetailsInfoLwc> reSetLwc |
| | | public static List<ConsumableorderdetailsInfo> addData { get; set; } |
| | | public static Map<String, String> skipData { get; set; } |
| | | // 保存后动作: 1.检索 2.排序 |
| | | public static String sortKey { get; set; } |
| | | public static String preSortKey { get; private set; } |
| | | public static Boolean sortOrderAsc { get; private set; } |
| | | public static String[] sortOrder { get; private set; } |
| | | private static String[] columus = new List<String>{ |
| | | 'Consumable_Product__r.Name', |
| | | 'Consumable_Product__r.Asset_Model_No__c', |
| | | 'Consumable_Product__r.Intra_Trade_List_RMB__c', |
| | | '', |
| | | '', |
| | | 'Consumable_Product__r.Category3__c', |
| | | 'Consumable_Product__r.Category4__c', |
| | | 'Consumable_Product__r.Category5__c' |
| | | }; |
| | | private static String[] columus_no = new List<String>{ |
| | | 'Product2__c.Name', |
| | | 'Product2__c.Asset_Model_No__c', |
| | | 'Product2__c.Intra_Trade_List_RMB__c', |
| | | '', |
| | | '', |
| | | 'Category3__c', |
| | | 'Category4__c', |
| | | 'Category5__c' |
| | | }; |
| | | // public static String sortKey { get; set; } |
| | | // public static String preSortKey { get; private set; } |
| | | // public static Boolean sortOrderAsc { get; private set; } |
| | | // public static String[] sortOrder { get; private set; } |
| | | // private static String[] columus = new List<String>{ |
| | | // 'Consumable_Product__r.Name', |
| | | // 'Consumable_Product__r.Asset_Model_No__c', |
| | | // 'Consumable_Product__r.Intra_Trade_List_RMB__c', |
| | | // '', |
| | | // '', |
| | | // 'Consumable_Product__r.Category3__c', |
| | | // 'Consumable_Product__r.Category4__c', |
| | | // 'Consumable_Product__r.Category5__c' |
| | | // }; |
| | | // private static String[] columus_no = new List<String>{ |
| | | // 'Product2__c.Name', |
| | | // 'Product2__c.Asset_Model_No__c', |
| | | // 'Product2__c.Intra_Trade_List_RMB__c', |
| | | // '', |
| | | // '', |
| | | // 'Category3__c', |
| | | // 'Category4__c', |
| | | // 'Category5__c' |
| | | // }; |
| | | |
| | | //到货单明细1 |
| | | private static List<Consumable_Orderdetails__c> consumableorderdetailsSelected = new List<Consumable_Orderdetails__c>(); |
| | |
| | | category4OptionList = new List<SelectOption>(); |
| | | category5OptionList = new List<SelectOption>(); |
| | | |
| | | categoryOptionMap = new Map<String,String>(); |
| | | category4OptionMap = new Map<String,String>(); |
| | | category5OptionMap = new Map<String,String>(); |
| | | categoryOptionMap = new Map<String, String>(); |
| | | category4OptionMap = new Map<String, String>(); |
| | | category5OptionMap = new Map<String, String>(); |
| | | |
| | | outOutPatternOptionMap = new Map<String, String>(); |
| | | outOutPatternOptionMap.put('', '-无-'); |
| | |
| | | HospitalName = ''; |
| | | } |
| | | |
| | | public static void firstInit(String ESetidJs){ |
| | | public static void firstInit(String ESetidJs) { |
| | | System.debug('enter firstInit'); |
| | | ESetid = ESetidJs; |
| | | System.debug('ESetid = ' + ESetid); |
| | |
| | | category4OptionList = new List<SelectOption>(); |
| | | category5OptionList = new List<SelectOption>(); |
| | | |
| | | categoryOptionMap = new Map<String,String>(); |
| | | category4OptionMap = new Map<String,String>(); |
| | | category5OptionMap = new Map<String,String>(); |
| | | categoryOptionMap = new Map<String, String>(); |
| | | category4OptionMap = new Map<String, String>(); |
| | | category5OptionMap = new Map<String, String>(); |
| | | |
| | | outOutPatternOptionMap = new Map<String, String>(); |
| | | outOutPatternOptionMap.put('', '-无-'); |
| | |
| | | |
| | | // 画面初始化 |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC init(String ESetidJs) { |
| | | public static ResponseBodyLWC init(String ESetidJs, String statusEdit, Integer pageSizeLWC, Integer pageTokenLWC) { |
| | | // try { |
| | | firstInit(ESetidJs); |
| | | statusEdit = statusEdit; |
| | | arriveorder = ''; |
| | | HospitalName = ''; |
| | | provinceOpts = new List<SelectOption>(); |
| | |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | // public static Integer pagesize { get; set; } |
| | | // public static Integer pageToken { get; set; } |
| | | // public static String sortField { get; set; } |
| | | // public static String sortOrder { get; set; } |
| | | pagesize = pageSizeLWC; |
| | | pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC; |
| | | |
| | | sortKey = '1'; |
| | | preSortKey = '1'; |
| | | sortOrderAsc = false; |
| | | sortOrder = new String[8]; |
| | | sortOrder = new List<String>{ ' ', ' ', ' ', ' ', '↓', '', '', '' }; |
| | | // sortKey = '1'; |
| | | // preSortKey = '1'; |
| | | // sortOrderAsc = false; |
| | | // sortOrder = new List<String>(8); |
| | | // sortOrder = new List<String>{ ' ', ' ', ' ', ' ', '↓', '', '', '' }; |
| | | //cate1ForSort = ''; |
| | | sumPrice = 0; |
| | | IdCheck = EsetId; |
| | |
| | | for (AggregateResult orderdetail : orderdetailCount) { |
| | | zaikuId.add(String.valueOf(orderdetail.get('cpc'))); |
| | | } |
| | | System.debug('sqlagencyProType = ' + sqlagencyProType); |
| | | System.debug('userWorkLocation = ' + userWorkLocation); |
| | | System.debug('accountName = ' + accountName); |
| | | List<Consumable_order_details2__c> CountDel = [ |
| | | SELECT |
| | | Id, |
| | |
| | | SummonsFlag = 'hidden'; |
| | | String msoql = makeSoqlinventory(); |
| | | initStandardController(msoql); |
| | | System.debug('msoql = ' + msoql); |
| | | product2Selected = Database.query(msoql); |
| | | //product2Selected = product2s(); |
| | | if (String.isBlank(arriveorder)) { |
| | | EditDelCommitBtnDisabled = true; |
| | | for (Integer i = 0; i < product2Selected.size(); i++) { |
| | |
| | | MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage); |
| | | } |
| | | } |
| | | System.debug('MidMap2.size() = ' + MidMap2.size()); |
| | | /*//然后循环CountDel去修改map里的allnumber |
| | | if(MidMap.containsKey(CountDel[i].Consumable_Product__c)){ |
| | | ConsumableorderdetailsInfo Jstage = MidMap.get(CountDel[i].Consumable_Product__c); |
| | |
| | | |
| | | Integer ishosnum = 0; |
| | | for (ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords) { |
| | | ass.sortBy = sortOrderAsc; |
| | | //ass.sortBy = sortOrderAsc; |
| | | //add by rentx 2021-3-10 |
| | | if (ass.hospitalSpecialOffer) { |
| | | ishosnum = ishosnum + 1; |
| | |
| | | |
| | | Integer ishosnum = 0; |
| | | for (ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords) { |
| | | ass.sortBy = sortOrderAsc; |
| | | //ass.sortBy = sortOrderAsc; |
| | | for (Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected) { |
| | | cdc1.Shipment_Count__c = cdc1.Consumable_count__c; |
| | | if (ass.prod.Id == cdc1.Consumable_Product__c) { |
| | |
| | | consumableproductdetailsRecords.add(new ConsumableorderdetailsInfo(consumablearriveproductdetailsSelected[i])); |
| | | } |
| | | } |
| | | } |
| | | // 更新、 |
| | | else { |
| | | } else { |
| | | // 更新、 |
| | | SummonsFlag = 'visible'; |
| | | // update start by vivek 2019-7-15 add “NoConfirmedPrice__c” in select |
| | | consumableInvoiceRecords = [ |
| | |
| | | AND Invoice_status__c != '草案中' |
| | | ]; |
| | | |
| | | System.debug('coc ESetId = ' + ESetId); |
| | | System.debug('coc userWorkLocation = ' + userWorkLocation); |
| | | coc = [ |
| | | SELECT |
| | | Id, |
| | |
| | | for (Integer i = 0; i < consumablearriveproductdetailsSelected.size(); i++) { |
| | | consumableproductdetailsRecords.add(new ConsumableorderdetailsInfo(consumablearriveproductdetailsSelected[i])); |
| | | } |
| | | } |
| | | // 不是到货订单来的时候 |
| | | else { |
| | | } else { |
| | | // 不是到货订单来的时候 |
| | | if (coc.SummonsStatus_c__c == '已提交' || coc.SummonsStatus_c__c == '批准') { |
| | | system.debug('coc.SummonsStatus_c__c : ' + coc.SummonsStatus_c__c); |
| | | saveBtnDisabled = true; |
| | |
| | | for (Integer i = 0; i < product2Selected.size(); i++) { |
| | | MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i])); |
| | | } |
| | | |
| | | |
| | | for (Integer i = 0; i < CountDel.size(); i++) { |
| | | String str = ''; |
| | | if (CountDel[i].hospitalSpecialOffer__c) { |
| | |
| | | // return null; |
| | | Integer ishosnum = 0; |
| | | for (ConsumableorderdetailsInfo ass : consumableorderdetailsSelectRecords) { |
| | | ass.sortBy = sortOrderAsc; |
| | | //ass.sortBy = sortOrderAsc; |
| | | for (Consumable_Orderdetails__c cdc1 : consumableorderdetailsSelected) { |
| | | //update by rentx 2012-3-1 start |
| | | // if(ass.prod.Id == cdc1.Consumable_Product__c){ |
| | |
| | | |
| | | categoryOptionList = new List<SelectOption>(); |
| | | categoryOptionList.add(new SelectOption('', '-无-')); |
| | | categoryOptionMap = new Map<String,String>(); |
| | | categoryOptionMap = new Map<String, String>(); |
| | | categoryOptionMap.put('', '-无-'); |
| | | for (AggregateResult category3Search : categoryList) { |
| | | String deliverycnt = String.valueOf(category3Search.get('c3c')); |
| | |
| | | |
| | | category4OptionList = new List<SelectOption>(); |
| | | category4OptionList.add(new SelectOption('', '-无-')); |
| | | category4OptionMap = new Map<String,String>(); |
| | | category4OptionMap = new Map<String, String>(); |
| | | category4OptionMap.put('', '-无-'); |
| | | /*for(AggregateResult category4Search : category4List) { |
| | | String deliverycnt4 = String.valueOf(category4Search.get('c4c')); |
| | |
| | | |
| | | category5OptionList = new List<SelectOption>(); |
| | | category5OptionList.add(new SelectOption('', '-无-')); |
| | | category5OptionMap = new Map<String,String>(); |
| | | category5OptionMap = new Map<String, String>(); |
| | | category5OptionMap.put('', '-无-'); |
| | | |
| | | //分页 |
| | | PaginatedAccounts paginatedAccounts = new PaginatedAccounts(); |
| | | totalCount = pageRecords.size(); |
| | | System.debug('pageToken = ' + pageToken); |
| | | System.debug('pageSize = ' + pageSize); |
| | | System.debug('totalCount = ' + totalCount); |
| | | paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount) ? pageToken + pageSize : null; |
| | | System.debug('paginatedAccounts.nextPageToken = ' + paginatedAccounts.nextPageToken); |
| | | paginatedAccounts.recordStart = pageToken + 1; |
| | | paginatedAccounts.pageNumber = pageToken / pageSize + 1; |
| | | Integer recordEnd = pageSize * paginatedAccounts.pageNumber; |
| | | paginatedAccounts.recordEnd = totalCount >= recordEnd ? recordEnd : totalCount; |
| | | paginatedAccounts.totalRecords = totalCount; |
| | | |
| | | Integer startIdx; |
| | | Integer endIdx; |
| | | startIdx = pageToken; |
| | | endIdx = pageToken + pageSize; |
| | | List<ConsumableorderdetailsInfo> pageRecordsTemp = new List<ConsumableorderdetailsInfo>(); |
| | | if (endIdx > pageRecords.size()) { |
| | | endIdx = pageRecords.size(); |
| | | } |
| | | for (Integer i = startIdx; i < endIdx; i++) { |
| | | pageRecordsTemp.add(pageRecords.get(i)); |
| | | } |
| | | |
| | | Boolean Existarrive = (coc.Arrive_Order__c != null); |
| | | String ConsumableOut_report = System.Label.ConsumableOut_report; |
| | | System.debug('consumableproductdetailsRecords = ' + consumableproductdetailsRecords); |
| | | data.put('ConsumableOut_report','ConsumableOut_report'); |
| | | data.put('accountid',accountid); |
| | | data.put('consumableproductdetailsRecords',consumableproductdetailsRecords); |
| | | data.put('agencyProType',agencyProType); |
| | | data.put('accountName',accountName); |
| | | data.put('userWorkLocation',userWorkLocation); |
| | | data.put('categoryOptionMap',categoryOptionMap); |
| | | data.put('category4OptionMap',category4OptionMap); |
| | | data.put('category5OptionMap',category5OptionMap); |
| | | data.put('outOutPatternOptionMap',outOutPatternOptionMap); |
| | | data.put('hasHosPro',hasHosPro); |
| | | data.put('Existarrive',Existarrive); |
| | | data.put('sumPrice',sumPrice); |
| | | |
| | | data.put('paginatedAccounts', paginatedAccounts); |
| | | data.put('ConsumableOut_report', ConsumableOut_report); |
| | | data.put('accountid', accountid); |
| | | data.put('consumableproductdetailsRecords', consumableproductdetailsRecords); |
| | | data.put('agencyProType', agencyProType); |
| | | data.put('accountName', accountName); |
| | | data.put('userWorkLocation', userWorkLocation); |
| | | data.put('categoryOptionMap', categoryOptionMap); |
| | | data.put('category4OptionMap', category4OptionMap); |
| | | data.put('category5OptionMap', category5OptionMap); |
| | | data.put('outOutPatternOptionMap', outOutPatternOptionMap); |
| | | data.put('hasHosPro', hasHosPro); |
| | | data.put('Existarrive', Existarrive); |
| | | data.put('sumPrice', sumPrice); |
| | | data.put('HospitalName', HospitalName); |
| | | data.put('provinceOptsMap', provinceOptsMap); |
| | | data.put('SummonsFlag', SummonsFlag); |
| | | data.put('EditDelCommitBtnDisabled', EditDelCommitBtnDisabled); |
| | | data.put('EditAble', EditAble); |
| | | data.put('coc', coc); |
| | | data.put('pageRecords', pageRecords); |
| | | data.put('arriveorder',arriveorder); |
| | | data.put('pageRecords', pageRecordsTemp); |
| | | data.put('arriveorder', arriveorder); |
| | | data.put('consumableorderdetails2Count', consumableorderdetails2Count); |
| | | data.put('consumableorderdetails2Records', consumableorderdetails2Records); |
| | | data.put('HospitalInfo', HospitalInfo); |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | |
| | | // } |
| | | } |
| | | |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC categoryAllload(String category3Lwc) { |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | |
| | | category3 = category3Lwc; |
| | | AggregateResult[] category4List = [ |
| | | SELECT Count(id), Category4_text__c c4c |
| | | FROM Product2__c |
| | | WHERE Category3_text__c = :category3 AND Category4_text__c != NULL AND Category5_text__c != NULL |
| | | GROUP BY Category4_text__c |
| | | ]; |
| | | category4OptionList = new List<SelectOption>(); |
| | | category4OptionList.add(new SelectOption('', '-无-')); |
| | | category4OptionMap = new Map<String, String>(); |
| | | category4OptionMap.put('', '-无-'); |
| | | for (AggregateResult category4Search : category4List) { |
| | | String deliverycnt4 = String.valueOf(category4Search.get('c4c')); |
| | | category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4)); |
| | | category4OptionMap.put(deliverycnt4, deliverycnt4); |
| | | } |
| | | |
| | | AggregateResult[] category5List = [ |
| | | SELECT Count(id), Category5_text__c c5c |
| | | FROM Product2__c |
| | | WHERE Category3_text__c = :category3 AND Category4_text__c != NULL AND Category5_text__c != NULL |
| | | GROUP BY Category5_text__c |
| | | ]; |
| | | |
| | | category5OptionList = new List<SelectOption>(); |
| | | category5OptionList.add(new SelectOption('', '-无-')); |
| | | category5OptionMap = new Map<String, String>(); |
| | | category5OptionMap.put('', '-无-'); |
| | | for (AggregateResult category5Search : category5List) { |
| | | String deliverycnt5 = String.valueOf(category5Search.get('c5c')); |
| | | category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5)); |
| | | category5OptionMap.put(deliverycnt5, deliverycnt5); |
| | | } |
| | | data.put('category4OptionMap', category4OptionMap); |
| | | data.put('category5OptionMap', category5OptionMap); |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | | return res; |
| | | } |
| | | |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC categoryload(String category3Lwc, String category4Lwc) { |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | |
| | | category3 = category3Lwc; |
| | | category4 = category4Lwc; |
| | | AggregateResult[] category4List = [ |
| | | SELECT Count(id), Category4_text__c c4c |
| | | FROM Product2__c |
| | | WHERE Category3_text__c = :category3 AND Category4_text__c != NULL AND Category5_text__c != NULL |
| | | GROUP BY Category4_text__c |
| | | ]; |
| | | category4OptionList = new List<SelectOption>(); |
| | | category4OptionList.add(new SelectOption('', '-无-')); |
| | | category4OptionMap = new Map<String, String>(); |
| | | category4OptionMap.put('', '-无-'); |
| | | for (AggregateResult category4Search : category4List) { |
| | | String deliverycnt4 = String.valueOf(category4Search.get('c4c')); |
| | | category4OptionList.add(new SelectOption(deliverycnt4, deliverycnt4)); |
| | | category4OptionMap.put(deliverycnt4, deliverycnt4); |
| | | } |
| | | |
| | | AggregateResult[] category5List = [ |
| | | SELECT Count(id), Category5_text__c c5c |
| | | FROM Product2__c |
| | | WHERE Category3_text__c = :category3 AND Category4_text__c = :category4 AND Category5_text__c != NULL |
| | | GROUP BY Category5_text__c |
| | | ]; |
| | | |
| | | category5OptionList = new List<SelectOption>(); |
| | | category5OptionList.add(new SelectOption('', '-无-')); |
| | | category5OptionMap = new Map<String, String>(); |
| | | category5OptionMap.put('', '-无-'); |
| | | for (AggregateResult category5Search : category5List) { |
| | | String deliverycnt5 = String.valueOf(category5Search.get('c5c')); |
| | | category5OptionList.add(new SelectOption(deliverycnt5, deliverycnt5)); |
| | | category5OptionMap.put(deliverycnt5, deliverycnt5); |
| | | } |
| | | data.put('category4OptionMap', category4OptionMap); |
| | | data.put('category5OptionMap', category5OptionMap); |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | | return res; |
| | | } |
| | | |
| | | // 检索 |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC searchConsumableorderdetails(String agencyProTypeLwc,String accountNameLwc,String userWorkLocationLwc,String outOutPattern,String category1,String category3,String category4,String category5,Boolean editAbleLwc,List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc,List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc,String arriveorderLwc) { |
| | | public static ResponseBodyLWC searchConsumableorderdetails( |
| | | String agencyProTypeLwc, |
| | | String accountNameLwc, |
| | | String userWorkLocationLwc, |
| | | String outOutPattern, |
| | | String category1, |
| | | String category3, |
| | | String category4, |
| | | String category5, |
| | | Boolean editAbleLwc, |
| | | List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc, |
| | | List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc, |
| | | String arriveorderLwc, |
| | | Integer pageSizeLWC, |
| | | Integer pageTokenLWC |
| | | ) { |
| | | consumableproductdetailsRecords = consumableproductdetailsRecordsLwc; |
| | | pageRecordsLwc = pageRecordsLwcLwc; |
| | | System.debug('pageRecordsLwc = ' + pageRecordsLwc); |
| | |
| | | accountName = accountNameLwc; |
| | | userWorkLocation = userWorkLocationLwc; |
| | | agencyProType = agencyProTypeLwc; |
| | | product2Selected = new List<Product2__c>(); |
| | | pagesize = pageSizeLWC; |
| | | pageToken = pageTokenLWC > 2000 ? 2000 : pageTokenLWC; |
| | | addSize = 0; |
| | | addData = new List<ConsumableorderdetailsInfo>(); |
| | | System.debug('start addData = ' + addData); |
| | | System.debug('accountName = ' + accountName); |
| | | System.debug('userWorkLocation = ' + userWorkLocation); |
| | | String sqlagencyProType = '%' + agencyProTypeLwc + '%'; |
| | | List<AggregateResult> orderdetailCount = [ |
| | | SELECT count(id), Consumable_Product__c cpc, Box_Piece__c |
| | |
| | | SearchDone = 'SearchDone'; |
| | | Map<String, String> selectedIdMap = new Map<String, String>(); |
| | | List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>(); |
| | | Map<String,ConsumableorderdetailsInfo> MidMap = new Map<String,ConsumableorderdetailsInfo>(); |
| | | Map<String, ConsumableorderdetailsInfo> MidMap = new Map<String, ConsumableorderdetailsInfo>(); |
| | | //update by rentx 2021-01-29 |
| | | Map<String,ConsumableorderdetailsInfo> MidMap2 = new Map<String,ConsumableorderdetailsInfo>(); |
| | | Map<String, ConsumableorderdetailsInfo> MidMap2 = new Map<String, ConsumableorderdetailsInfo>(); |
| | | String countdelSoql = 'SELECT Id,Bar_Code__c,Name,Inventory_date__c,Consumable_Product__c,Consumable_Product__r.Asset_Model_No__c,Recordtypeid,Box_Piece__c,ProductPacking_list_manual__c,hospitalSpecialOffer__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = true AND Dealer_Shipment__c = false AND Dealer_Saled__c = false AND Dealer_Returned__c = false AND Lose_Flag__c = false AND Bar_Code__c != null AND Isoverdue__c = 1 AND Arrive_Owner_Work_Location__c = :userWorkLocation AND Dealer_Info_text__c = :accountName '; |
| | | if (String.isNotBlank(outOutPattern) && outOutPattern.equals('ishos')) { |
| | | countdelSoql += ' AND hospitalSpecialOffer__c = true'; |
| | | }else if (String.isNotBlank(outOutPattern) && outOutPattern.equals('nothos')) { |
| | | } else if (String.isNotBlank(outOutPattern) && outOutPattern.equals('nothos')) { |
| | | countdelSoql += ' AND hospitalSpecialOffer__c = false'; |
| | | } |
| | | System.debug('countdelSoql = ' + countdelSoql); |
| | |
| | | |
| | | consumableorderdetailsSelectRecords = new List<ConsumableorderdetailsInfo>(); |
| | | //consumableorderdetailsSelectRecords = reSet; |
| | | String soql = makeSoql(category1,category3,category4,category5); |
| | | System.debug('soql = ' + soql); |
| | | String soql = makeSoql(category1, category3, category4, category5); |
| | | size = Integer.valueOf(System.Label.orderdetLimitsize); |
| | | initStandardController(soql); |
| | | System.debug('soql = ' + soql); |
| | | product2Selected = Database.query(soql); |
| | | for (Integer i = 0; i < product2Selected.size(); i++) { |
| | | MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i])); |
| | | } |
| | | |
| | | for (Integer i = 0; i < CountDel.size() ;i++ ) { |
| | | for (Integer i = 0; i < CountDel.size(); i++) { |
| | | String str = ''; |
| | | if (CountDel[i].hospitalSpecialOffer__c) { |
| | | str = 'isHos'; |
| | | }else{ |
| | | } else { |
| | | str = 'notHos'; |
| | | } |
| | | System.debug('MidMap = ' + MidMap); |
| | |
| | | if (MidMap.containsKey(CountDel[i].Consumable_Product__c)) { |
| | | //设置map中key的后缀 用于区分医院特价和非医院特价 |
| | | if (MidMap2.containsKey(CountDel[i].Consumable_Product__c + str)) { |
| | | ConsumableorderdetailsInfo Jstage = MidMap2.get(CountDel[i].Consumable_Product__c+str); |
| | | Jstage.allnumber = Jstage.allnumber+1 ; |
| | | if(CountDel[i].Box_Piece__c == '盒'){ |
| | | ConsumableorderdetailsInfo Jstage = MidMap2.get(CountDel[i].Consumable_Product__c + str); |
| | | Jstage.allnumber = Jstage.allnumber + 1; |
| | | if (CountDel[i].Box_Piece__c == '盒') { |
| | | Jstage.Boxnumber = Jstage.Boxnumber + 1; |
| | | }else if(CountDel[i].Box_Piece__c == '个'){ |
| | | } else if (CountDel[i].Box_Piece__c == '个') { |
| | | Jstage.Piecenumber = Jstage.Piecenumber + 1; |
| | | } |
| | | if (CountDel[i].hospitalSpecialOffer__c) { |
| | | Jstage.hospitalSpecialOffer = true; |
| | | }else{ |
| | | } else { |
| | | Jstage.hospitalSpecialOffer = false; |
| | | } |
| | | if (HosProMap.containsKey(Jstage.Prod.Id)) { |
| | | Jstage.hosPro = true; |
| | | } |
| | | MidMap2.put(CountDel[i].Consumable_Product__c+str, Jstage); |
| | | }else{ |
| | | MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage); |
| | | } else { |
| | | //midmap2中没有对应的产品 |
| | | ConsumableorderdetailsInfo Jstage = MidMap.get(CountDel[i].Consumable_Product__c).clone(); |
| | | Jstage.allnumber = Jstage.allnumber+1 ; |
| | | if(CountDel[i].Box_Piece__c == '盒'){ |
| | | Jstage.allnumber = Jstage.allnumber + 1; |
| | | if (CountDel[i].Box_Piece__c == '盒') { |
| | | Jstage.Boxnumber = Jstage.Boxnumber + 1; |
| | | }else if(CountDel[i].Box_Piece__c == '个'){ |
| | | } else if (CountDel[i].Box_Piece__c == '个') { |
| | | Jstage.Piecenumber = Jstage.Piecenumber + 1; |
| | | } |
| | | if (CountDel[i].hospitalSpecialOffer__c) { |
| | | Jstage.hospitalSpecialOffer = true; |
| | | }else{ |
| | | } else { |
| | | Jstage.hospitalSpecialOffer = false; |
| | | } |
| | | if (HosProMap.containsKey(Jstage.Prod.Id)) { |
| | | Jstage.hosPro = true; |
| | | } |
| | | //Jstage.BoxPiece = CountDel[i].Box_Piece__c; |
| | | MidMap2.put(CountDel[i].Consumable_Product__c+str, Jstage); |
| | | MidMap2.put(CountDel[i].Consumable_Product__c + str, Jstage); |
| | | } |
| | | } |
| | | } |
| | | Integer ishosnum = 0; |
| | | System.debug('MidMap2 = ' + MidMap2); |
| | | for(ConsumableorderdetailsInfo bss : MidMap2.values()){ |
| | | if(selectedIdMap.containsKey(bss.Prod.id)){ |
| | | for (ConsumableorderdetailsInfo bss : MidMap2.values()) { |
| | | if (selectedIdMap.containsKey(bss.Prod.id)) { |
| | | continue; |
| | | }else{ |
| | | } else { |
| | | bss.sortBy = false; |
| | | bss.packinglist = Integer.valueOf(bss.Prod.Product2__r.Packing_list_manual__c); |
| | | bss.approbation_No = bss.Prod.Product2__r.SFDA_Approbation_No__c; |
| | |
| | | } |
| | | } |
| | | } |
| | | if (ishosnum > 0) { |
| | | if (ishosnum > 0) { |
| | | hasHosPro = true; |
| | | }else{ |
| | | } else { |
| | | hasHosPro = false; |
| | | } |
| | | |
| | | |
| | | consumableorderdetailsSelectRecords.sort(); |
| | | //add by rentx |
| | | //noOfRecords = consumableorderdetailsSelectRecords.size(); |
| | | //add by rentx |
| | | //makepagerecords(); |
| | | makepagerecordsLwc(); |
| | | // this.sortKey = '1'; |
| | | // this.preSortKey = '1'; |
| | | // this.sortOrderAsc = false; |
| | | // this.sortOrder = new String[8]; |
| | | // this.sortOrder = new String[]{' ',' ',' ',' ','↓','','',''}; |
| | | data.put('pageRecords', pageRecords); |
| | | data.put('test','test'); |
| | | //分页 |
| | | PaginatedAccounts paginatedAccounts = new PaginatedAccounts(); |
| | | totalCount = pageRecords.size(); |
| | | paginatedAccounts.nextPageToken = (pageToken + pageSize < totalCount) ? pageToken + pageSize : null; |
| | | paginatedAccounts.recordStart = pageToken + 1; |
| | | paginatedAccounts.pageNumber = pageToken / pageSize + 1; |
| | | Integer recordEnd = pageSize * paginatedAccounts.pageNumber; |
| | | paginatedAccounts.recordEnd = totalCount >= recordEnd ? recordEnd : totalCount; |
| | | paginatedAccounts.totalRecords = totalCount; |
| | | |
| | | System.debug('addSize = ' + addSize); |
| | | Integer startIdx; |
| | | Integer endIdx; |
| | | startIdx = pageToken; |
| | | endIdx = pageToken + pageSize; |
| | | List<ConsumableorderdetailsInfo> pageRecordsTemp = new List<ConsumableorderdetailsInfo>(); |
| | | if (endIdx > pageRecords.size()) { |
| | | endIdx = pageRecords.size(); |
| | | } |
| | | |
| | | System.debug('addData.size() = ' + addData.size()); |
| | | for (ConsumableorderdetailsInfo ci : addData) { |
| | | pageRecordsTemp.add(ci); |
| | | } |
| | | System.debug('startIdx = ' + startIdx); |
| | | System.debug('endIdx = ' + endIdx); |
| | | System.debug('skipData = ' + skipData); |
| | | System.debug('pageRecords = ' + pageRecords.size()); |
| | | String hos = ''; |
| | | for (Integer i = startIdx; i < endIdx; i++) { |
| | | System.debug('skipData.get(pageRecords.get(i).Prod.Id) = ' + skipData.get(pageRecords.get(i).Prod.Id)); |
| | | if (pageRecords.get(i).hospitalSpecialOffer == true) { |
| | | hos = 'ishos'; |
| | | } else { |
| | | hos = 'nothos'; |
| | | } |
| | | if (skipData.get(pageRecords.get(i).Prod.Id + hos) == null) { |
| | | pageRecordsTemp.add(pageRecords.get(i)); |
| | | } |
| | | } |
| | | |
| | | System.debug('pageRecordsTemp = ' + pageRecordsTemp.size()); |
| | | data.put('paginatedAccounts', paginatedAccounts); |
| | | data.put('pageRecords', pageRecordsTemp); |
| | | data.put('SearchDone', SearchDone); |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | | return res; |
| | | } |
| | | |
| | | private static String makeSoql(String CateName,String Category3,String Category4,String Category5){ |
| | | private static String makeSoql(String CateName, String Category3, String Category4, String Category5) { |
| | | String sqlTail1 = '(\''; |
| | | for(Integer i = 0 ; i< zaikuId.size();i++){ |
| | | if(i<zaikuId.size()-1){ |
| | | sqlTail1 += zaikuId[i]+'\',\''; |
| | | }else{ |
| | | sqlTail1 += zaikuId[i]; |
| | | for (Integer i = 0; i < zaikuId.size(); i++) { |
| | | if (zaikuId[i] != null) { |
| | | if (i < zaikuId.size() - 1) { |
| | | sqlTail1 += zaikuId[i] + '\',\''; |
| | | } else { |
| | | sqlTail1 += zaikuId[i]; |
| | | } |
| | | } |
| | | } |
| | | sqlTail1 += '\')'; |
| | | String soql = 'SELECT Id, Name,Name__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,Product2__r.Packing_list_manual__c,SFDA_Status__c,Product2__r.SFDA_Approbation_No__c,Product2__r.SFDA_Expiration_Date__c,Category3__c,Category4__c,Category5__c FROM Product2__c '; |
| | | soql += ' WHERE Id in' + sqlTail1; |
| | | if(!String.isBlank(CateName)){ |
| | | soql += ' AND (Name__c like \'%' + String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) + '%\' or Asset_Model_No__c like \'%' + String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) + '%\')'; |
| | | }if(!String.isBlank(Category3)){ |
| | | soql += ' AND Category3__c = \'' + Category3 + '\''; |
| | | }if(!String.isBlank(Category4)){ |
| | | soql += ' AND Category4__c = \'' + Category4 + '\''; |
| | | }if(!String.isBlank(Category5)){ |
| | | soql += ' AND Category5__c = \'' + Category5 + '\''; |
| | | if (!String.isBlank(CateName)) { |
| | | soql += |
| | | ' AND (Name__c like \'%' + |
| | | String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) + |
| | | '%\' or Asset_Model_No__c like \'%' + |
| | | String.escapeSingleQuotes(CateName.replaceAll('%', '\\%')) + |
| | | '%\')'; |
| | | } |
| | | if (!String.isBlank(Category3)) { |
| | | soql += ' AND Category3__c = \'' + Category3 + '\''; |
| | | } |
| | | if (!String.isBlank(Category4)) { |
| | | soql += ' AND Category4__c = \'' + Category4 + '\''; |
| | | } |
| | | if (!String.isBlank(Category5)) { |
| | | soql += ' AND Category5__c = \'' + Category5 + '\''; |
| | | } |
| | | return soql; |
| | | } |
| | |
| | | public static String makeSoqlinventory() { |
| | | String sqlTail = '(\''; |
| | | for (Integer i = 0; i < zaikuId.size(); i++) { |
| | | if (i < zaikuId.size() - 1) { |
| | | sqlTail += zaikuId[i] + '\',\''; |
| | | } else { |
| | | sqlTail += zaikuId[i]; |
| | | if (zaikuId[i] != null) { |
| | | if (i < zaikuId.size() - 1) { |
| | | sqlTail += zaikuId[i] + '\',\''; |
| | | } else { |
| | | sqlTail += zaikuId[i]; |
| | | } |
| | | } |
| | | } |
| | | sqlTail += '\')'; |
| | |
| | | } |
| | | System.debug('zhj3'); |
| | | pageRecords = new List<ConsumableorderdetailsInfo>(); |
| | | System.debug('reSet.size() = ' + reSet.size()); |
| | | if (editAble && String.isBlank(arriveorder)) { |
| | | pageRecords = reSet; |
| | | } |
| | |
| | | //Integer pageendNo = (setCon.getPageNumber() * size)>noOfRecords ? noOfRecords :(setCon.getPageNumber() * size-1); |
| | | Integer addNo = 0; |
| | | //update by rentx 2021-2-26 start |
| | | System.debug('consumableorderdetailsSelectRecords = ' + consumableorderdetailsSelectRecords); |
| | | System.debug('consumableorderdetailsSelectRecords.size() = ' + consumableorderdetailsSelectRecords.size()); |
| | | for (ConsumableorderdetailsInfo info : consumableorderdetailsSelectRecords) { |
| | | Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c(); |
| | | if ( |
| | |
| | | public static List<ConsumableorderdetailsInfo> makepagerecordsLwc() { |
| | | List<ConsumableorderdetailsInfoLwc> reSetLwc = new List<ConsumableorderdetailsInfoLwc>(); |
| | | Map<String, String> selectedIdMap = new Map<String, String>(); |
| | | skipData = new Map<String, String>(); |
| | | System.debug('makepagerecordsLwc pageRecordsLwc = ' + pageRecordsLwc); |
| | | //取出选择的产品 |
| | | if (pageRecordsLwc != null) { |
| | |
| | | if (ass.check == true) { |
| | | if (ass.hospitalSpecialOffer == true) { |
| | | selectedIdMap.put(ass.Prod.Id + 'ishos', ass.Prod.Id); |
| | | skipData.put(ass.Prod.Id + 'ishos', ass.Prod.Id); |
| | | } else { |
| | | selectedIdMap.put(ass.Prod.Id + 'nothos', ass.Prod.Id); |
| | | skipData.put(ass.Prod.Id + 'nothos', ass.Prod.Id); |
| | | } |
| | | reSetLwc.add(ass); |
| | | } |
| | | } |
| | | } |
| | | System.debug('reSetLwc = ' + reSetLwc); |
| | | System.debug('selectedIdMap = ' + selectedIdMap); |
| | | pageRecords = new List<ConsumableorderdetailsInfo>(); |
| | | if (editAble && String.isBlank(arriveorder)) { |
| | | List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>(); |
| | | for(ConsumableorderdetailsInfoLwc assLwc : reSetLwc){ |
| | | System.debug('reSetLwc = ' + reSetLwc); |
| | | for (ConsumableorderdetailsInfoLwc assLwc : reSetLwc) { |
| | | ConsumableorderdetailsInfo ci = new ConsumableorderdetailsInfo(); |
| | | ci.check = assLwc.check; |
| | | ci.oldCheck = assLwc.oldCheck; |
| | |
| | | reSet.add(ci); |
| | | } |
| | | pageRecords = reSet; |
| | | System.debug('reSet = ' + reSet); |
| | | addData = reSet.clone(); |
| | | System.debug('addData = reSet = ' + addData); |
| | | } |
| | | //Integer pagestartNo = (setCon.getPageNumber() * size)-size; |
| | | //Integer pageendNo = (setCon.getPageNumber() * size)>noOfRecords ? noOfRecords :(setCon.getPageNumber() * size-1); |
| | | Integer addNo = 0; |
| | | //update by rentx 2021-2-26 start |
| | | System.debug('consumableorderdetailsSelectRecords = ' + consumableorderdetailsSelectRecords); |
| | | System.debug('consumableorderdetailsSelectRecords.size() = ' + consumableorderdetailsSelectRecords.size()); |
| | | for (ConsumableorderdetailsInfo info : consumableorderdetailsSelectRecords) { |
| | | Consumable_Orderdetails__c orderdetails1 = new Consumable_Orderdetails__c(); |
| | | if ( |
| | | (info.hospitalSpecialOffer && selectedIdMap.containsKey(info.Prod.Id + 'ishos')) || |
| | | (info.hospitalSpecialOffer == false && selectedIdMap.containsKey(info.Prod.Id + 'nothos')) |
| | | ) { |
| | | System.debug('去掉的id : ' + info.Prod.Id); |
| | | addNo++; |
| | | addSize++; |
| | | } else { |
| | | if (info.check == false) { |
| | | info.orderdetails1 = orderdetails1; |
| | |
| | | addNo++; |
| | | } |
| | | } |
| | | System.debug('pageRecords = ' + pageRecords); |
| | | System.debug('pageRecords.size() = ' + pageRecords.size()); |
| | | System.debug('end addData = ' + addData); |
| | | return pageRecords; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // 保存按钮 |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC save(Consumable_order__c cocLwc,String hospitalInfoLwc,String hospitalNameLwc,String secondaryDistributor,List<ConsumableorderdetailsInfoLwc> pageRecordsLwc,String accountid,String ESetId,List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc) { |
| | | System.debug('cocLwc = ' + cocLwc); |
| | | public static ResponseBodyLWC save( |
| | | Consumable_order__c cocLwc, |
| | | String hospitalInfoLwc, |
| | | String hospitalNameLwc, |
| | | String secondaryDistributorLwc, |
| | | List<ConsumableorderdetailsInfoLwc> pageRecordsLwc, |
| | | String accountidLwc, |
| | | String ESetIdLwc, |
| | | List<ConsumableorderdetailsInfo> consumableproductdetailsRecordsLwc, |
| | | String agencyProTypeLwc, |
| | | String userWorkLocationLwc |
| | | ) { |
| | | coc = cocLwc; |
| | | HospitalInfo = hospitalInfoLwc; |
| | | HospitalName = hospitalNameLwc; |
| | | SecondDealer = secondaryDistributor; |
| | | SecondDealer = secondaryDistributorLwc; |
| | | pageRecordsLwc = pageRecordsLwc; |
| | | accountid = accountidLwc; |
| | | consumableproductdetailsRecords = consumableproductdetailsRecordsLwc; |
| | | ESetId = ESetIdLwc; |
| | | agencyProType = agencyProTypeLwc; |
| | | userWorkLocation = userWorkLocationLwc; |
| | | |
| | | System.debug('coc = ' + coc); |
| | | System.debug('HospitalInfo = ' + HospitalInfo); |
| | | System.debug('HospitalName = ' + HospitalName); |
| | | System.debug('SecondDealer = ' + SecondDealer); |
| | | System.debug('pageRecordsLwc = ' + pageRecordsLwc); |
| | | System.debug('accountid = ' + accountid); |
| | | System.debug('consumableproductdetailsRecords = ' + consumableproductdetailsRecords); |
| | | System.debug('ESetId = ' + ESetId); |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | //订单信息确认 |
| | | if(coc.SummonsForDirction__c ==''||coc.SummonsForDirction__c == null){ |
| | | if (coc.SummonsForDirction__c == '' || coc.SummonsForDirction__c == null) { |
| | | // coc.SummonsForDirction__c.addError('请输入指示单目的。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入指示单目的。', ''); |
| | | } |
| | | else if(coc.SummonsForDirction__c =='直接销售给医院'){ |
| | | if(String.isBlank(HospitalInfo) || String.isBlank(HospitalName)){ |
| | | return new ResponseBodyLWC('Error', 500, '请输入指示单目的。', ''); |
| | | } else if (coc.SummonsForDirction__c == '直接销售给医院') { |
| | | if (String.isBlank(HospitalInfo) || String.isBlank(HospitalName)) { |
| | | // coc.addError('请输入医院。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入医院。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入医院。', ''); |
| | | } |
| | | if(String.isBlank(coc.Order_ForCustomerText__c)){ |
| | | if (String.isBlank(coc.Order_ForCustomerText__c)) { |
| | | // coc.Order_ForCustomerText__c.addError('请输入科室。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入科室。', ''); |
| | | } |
| | | else if(String.isNotBlank(SecondDealer) || String.isNotBlank(coc.Order_ForDealerText__c)){ |
| | | return new ResponseBodyLWC('Error', 500, '请输入科室。', ''); |
| | | } else if (String.isNotBlank(SecondDealer) || String.isNotBlank(coc.Order_ForDealerText__c)) { |
| | | // coc.addError('不需要二级经销商和经销商(录入)信息。' ); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '不需要二级经销商和经销商(录入)信息。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '不需要二级经销商和经销商(录入)信息。', ''); |
| | | } |
| | | }else if(coc.SummonsForDirction__c =='医院试用'){ |
| | | if(String.isBlank(HospitalInfo) || String.isBlank(HospitalName)){ |
| | | } else if (coc.SummonsForDirction__c == '医院试用') { |
| | | if (String.isBlank(HospitalInfo) || String.isBlank(HospitalName)) { |
| | | // coc.addError('请输入医院。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入医院。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入医院。', ''); |
| | | } |
| | | if(String.isBlank(coc.Order_ForCustomerText__c)){ |
| | | if (String.isBlank(coc.Order_ForCustomerText__c)) { |
| | | // coc.Order_ForCustomerText__c.addError('请输入科室。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入科室。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入科室。', ''); |
| | | } |
| | | } |
| | | else if(coc.SummonsForDirction__c =='销售给二级经销商'){ |
| | | if(String.isBlank(SecondDealer) && String.isBlank(coc.Order_ForDealerText__c)){ |
| | | } else if (coc.SummonsForDirction__c == '销售给二级经销商') { |
| | | if (String.isBlank(SecondDealer) && String.isBlank(coc.Order_ForDealerText__c)) { |
| | | // coc.addError('必须输入二级经销商或经销商(录入)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '必须输入二级经销商或经销商(录入)。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '必须输入二级经销商或经销商(录入)。', ''); |
| | | } |
| | | if(String.isBlank(HospitalInfo) || String.isBlank(HospitalName)){ |
| | | if (String.isBlank(HospitalInfo) || String.isBlank(HospitalName)) { |
| | | // coc.addError('请输入医院。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入医院。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入医院。', ''); |
| | | } |
| | | if(String.isBlank(coc.Order_ForCustomerText__c)){ |
| | | if (String.isBlank(coc.Order_ForCustomerText__c)) { |
| | | // coc.Order_ForCustomerText__c.addError('请输入科室。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入科室。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入科室。', ''); |
| | | } |
| | | } |
| | | else if(coc.SummonsForDirction__c =='互相调货'){ |
| | | if(String.isNotBlank(HospitalInfo) || String.isNotBlank(HospitalName)){ |
| | | } else if (coc.SummonsForDirction__c == '互相调货') { |
| | | if (String.isNotBlank(HospitalInfo) || String.isNotBlank(HospitalName)) { |
| | | // coc.addError('不需要输入医院。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '不需要输入医院。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '不需要输入医院。', ''); |
| | | } |
| | | if(String.isNotBlank(coc.Order_ForCustomerText__c)){ |
| | | if (String.isNotBlank(coc.Order_ForCustomerText__c)) { |
| | | // coc.Order_ForCustomerText__c.addError('不需要输入科室。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '不需要输入科室。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '不需要输入科室。', ''); |
| | | } |
| | | if(String.isBlank(SecondDealer) && String.isBlank(coc.Order_ForDealerText__c)){ |
| | | if (String.isBlank(SecondDealer) && String.isBlank(coc.Order_ForDealerText__c)) { |
| | | // coc.addError('必须输入二级经销商或经销商(录入)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '必须输入二级经销商或经销商(录入)。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '必须输入二级经销商或经销商(录入)。', ''); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | Integer FLG = 0; |
| | | Integer Count = 0; |
| | | for(ConsumableorderdetailsInfoLwc CheckCount : pageRecordsLwc) { |
| | | for (ConsumableorderdetailsInfoLwc CheckCount : pageRecordsLwc) { |
| | | FLG = FLG + 1; |
| | | if(CheckCount.check == false){ |
| | | if (CheckCount.check == false) { |
| | | Count = Count + 1; |
| | | }else{ |
| | | } else { |
| | | //add by rentx |
| | | if (CheckCount.hospitalSpecialOffer) { |
| | | isHos = isHos+1; |
| | | isHos = isHos + 1; |
| | | } |
| | | //add by rentx |
| | | } |
| | | } |
| | | if(Count == FLG){ |
| | | if (Count == FLG) { |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请选择所需消耗品')); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请选择所需消耗品', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请选择所需消耗品', ''); |
| | | } |
| | | // gzw 注释 判断提前 20210308 |
| | | //checkOutPattern(); |
| | | //根据用户选中的产品给 出库单上的是否医院特价出库字段赋值 |
| | | Integer isHosCheckOutPattern = 0; |
| | | for(ConsumableorderdetailsInfoLwc CheckCount : pageRecordsLwc) { |
| | | for (ConsumableorderdetailsInfoLwc CheckCount : pageRecordsLwc) { |
| | | if (CheckCount.check == true && CheckCount.hospitalSpecialOffer == true) { |
| | | isHosCheckOutPattern = isHosCheckOutPattern +1; |
| | | isHosCheckOutPattern = isHosCheckOutPattern + 1; |
| | | } |
| | | } |
| | | if (isHosCheckOutPattern > 0) { |
| | | coc.OutPattern__c = true; |
| | | }else{ |
| | | } else { |
| | | coc.OutPattern__c = false; |
| | | } |
| | | |
| | | // add by rentx 2021-3-10 start |
| | | //特价医院出库非本医院维护的特价商品时,报错 非特价医院出库维护在医院特价关系表的产品时 报错 |
| | | if(coc.SummonsForDirction__c !='互相调货'){ |
| | | if (coc.SummonsForDirction__c != '互相调货') { |
| | | //非特价医院出库特价产品时 报错(当前经销商下没有特价医院除外) |
| | | List<hospitalprice__c> hopList = [select id,hospital__c,product__c from hospitalprice__c where account__c = :accountid]; |
| | | List<hospitalprice__c> hopList = [SELECT id, hospital__c, product__c FROM hospitalprice__c WHERE account__c = :accountid]; |
| | | //经销商对应医院下的所有特价产品 |
| | | Map<String,String> proMap = new Map<String,String>(); |
| | | Map<String, String> proMap = new Map<String, String>(); |
| | | //经销商下的所有特价产品 |
| | | Map<String,String> allProMap = new Map<String,String>(); |
| | | Map<String, String> allProMap = new Map<String, String>(); |
| | | |
| | | if (hopList != null && hopList.size() > 0) { |
| | | Boolean flag = false; |
| | |
| | | allProMap.put(hp.product__c, ''); |
| | | //如果当前 医院特价关系中的医院对应出库单上出库的医院,则放产品id到map |
| | | if (hp.hospital__c == HospitalInfo) { |
| | | flag = true; |
| | | flag = true; |
| | | proMap.put(hp.product__c, ''); |
| | | } |
| | | |
| | | } |
| | | } |
| | | for(ConsumableorderdetailsInfoLwc ass : pageRecordsLwc){ |
| | | for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) { |
| | | if (ass.check == true) { |
| | | //判断选中的医院特价产品 |
| | | if (ass.hospitalSpecialOffer == true) { |
| | | //用户选中了当前医院下的特价产品 |
| | | if (proMap.containsKey(ass.Prod.Id)) { |
| | | continue; |
| | | //用户选中了没有维护特价医院的特价产品 |
| | | }else if (!allProMap.containsKey(ass.Prod.Id)) { |
| | | //用户选中了没有维护特价医院的特价产品 |
| | | } else if (!allProMap.containsKey(ass.Prod.Id)) { |
| | | continue; |
| | | }else{ |
| | | } else { |
| | | //用户选中非当前医院维护的特价产品 |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '当前医院没有维护 消耗品:'+ ass.Prod.Name__c +' 的特价')); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '当前医院没有维护 消耗品:' + ass.Prod.Name__c + '的特价', ''); |
| | | return new ResponseBodyLWC('Error', 500, '当前医院没有维护 消耗品:' + ass.Prod.Name__c + '的特价', ''); |
| | | } |
| | | }//非医院特价产品可以出库给任意医院,所以不需要判断 |
| | | } //非医院特价产品可以出库给任意医院,所以不需要判断 |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | //如果是互相调货,判断 经销商(录入) 是否维护了 当前选中的特价产品 |
| | | List<hospitalprice__c> hopList = [select id,hospital__c,product__c from hospitalprice__c where account__c = :coc.Order_ForDealerTextID__c]; |
| | | Map<Id,String> proMap = new Map<Id,String>(); |
| | | } else { |
| | | //如果是互相调货,判断 经销商(录入) 是否维护了 当前选中的特价产品 |
| | | List<hospitalprice__c> hopList = [ |
| | | SELECT id, hospital__c, product__c |
| | | FROM hospitalprice__c |
| | | WHERE account__c = :coc.Order_ForDealerTextID__c |
| | | ]; |
| | | Map<Id, String> proMap = new Map<Id, String>(); |
| | | if (hopList != null && hopList.size() > 0) { |
| | | for (hospitalprice__c hpc : hopList) { |
| | | proMap.put(hpc.product__c, ''); |
| | | } |
| | | |
| | | String proStr = ''; |
| | | for(ConsumableorderdetailsInfoLwc ass : pageRecordsLwc){ |
| | | for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) { |
| | | if (ass.check == true) { |
| | | if (ass.hospitalSpecialOffer == true) { |
| | | if (!proMap.containsKey(ass.Prod.Id)) { |
| | | proStr += ass.Prod.Name__c+','; |
| | | proStr += ass.Prod.Name__c + ','; |
| | | } |
| | | } |
| | | } |
| | |
| | | if (proStr != '') { |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '经销商:'+coc.Order_ForDealerText__c +' 没有消耗品:'+proStr.substring(0,proStr.length()-1) + ' 的特价')); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '经销商:' + coc.Order_ForDealerText__c + ' 没有消耗品:' + proStr.substring(0,proStr.length()-1) + ' 的特价', ''); |
| | | return new ResponseBodyLWC( |
| | | 'Error', |
| | | 500, |
| | | '经销商:' + coc.Order_ForDealerText__c + ' 没有消耗品:' + proStr.substring(0, proStr.length() - 1) + ' 的特价', |
| | | '' |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // checkOutPattern(); |
| | | Consumable_order__c p = new Consumable_order__c(); |
| | | List<Consumable_orderdetails__c> Ins = New List<Consumable_orderdetails__c>(); |
| | | List<Consumable_order_details2__c> InsProduct = New List<Consumable_order_details2__c>(); |
| | | List<Consumable_orderdetails__c> Ins = new List<Consumable_orderdetails__c>(); |
| | | List<Consumable_order_details2__c> InsProduct = new List<Consumable_order_details2__c>(); |
| | | Savepoint sp = Database.setSavepoint(); |
| | | // try { |
| | | //新建订单时 |
| | | if(String.isEmpty(ESetId)){ |
| | | p.Name = '*'; |
| | | p.Order_type__c = '传票'; |
| | | p.Order_ProType__c = agencyProType; |
| | | if(coc.SummonsStatus_c__c ==null||String.isBlank(coc.SummonsStatus_c__c))coc.SummonsStatus_c__c ='草案中'; |
| | | // update strat by vivek 2019-7-12 |
| | | p.NoConfirmedPrice__c = coc.NoConfirmedPrice__c; |
| | | // update end by vivek 2019-7-12 |
| | | p.SummonsStatus_c__c = coc.SummonsStatus_c__c; |
| | | if(coc.Arrive_Order__c != null){ |
| | | p.Arrive_Order__c = coc.Arrive_Order__c; |
| | | } |
| | | p.Offers_Price__c = coc.Offers_Price__c; |
| | | p.Dealer_Info__c = accountid; |
| | | if(String.isBlank(SecondDealer)){ |
| | | p.Order_ForHospital__c =String.isNotBlank(HospitalInfo) ? HospitalInfo : null; |
| | | p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c; |
| | | }else { |
| | | p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null; |
| | | p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c; |
| | | p.Order_ForDealer__c = SecondDealer; |
| | | } |
| | | P.Order_ForDealerText__c = coc.Order_ForDealerText__c; |
| | | P.Order_ForDealerTextID__c = coc.Order_ForDealerTextID__c; |
| | | p.Order_date__c = coc.Order_date__c; |
| | | p.SummonsForDirction__c = coc.SummonsForDirction__c; |
| | | p.RecordTypeid = System.Label.RT_ConOrder_Outboundorder; |
| | | // update start by vivek 2019-7-15 |
| | | p.NoConfirmedPrice__c = coc.NoConfirmedPrice__c; |
| | | // update end by vivek 2019-7-15 |
| | | //add by rentx |
| | | p.OutPattern__c = coc.OutPattern__c; |
| | | //add by rentx |
| | | //Map<String,String> ProductNewMap = new Map<String, String>(); |
| | | for(ConsumableorderdetailsInfoLwc ass : pageRecordsLwc){ |
| | | if(ass.check == true){ |
| | | if(ass.orderdetails1.Delivery_List_RMB__c < 0){ |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入正确的出货单价 (元)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入正确的出货单价 (元)。', ''); |
| | | } |
| | | if(ass.orderdetails1.Delivery_List_RMB__c == null && coc.SummonsForDirction__c !='医院试用'){ |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入正确的出货单价 (元)。', ''); |
| | | } |
| | | if(ass.orderdetails1.Delivery_List_RMB__c == 0 && (coc.SummonsForDirction__c =='销售给二级经销商' || coc.SummonsForDirction__c =='直接销售给医院')){ |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入出货单价 (元)。', ''); |
| | | } |
| | | if(ass.orderdetails1.Shipment_Count__c == null ||ass.orderdetails1.Shipment_Count__c ==0){ |
| | | // ass.orderdetails1.Shipment_Count__c.addError('请输入出货数量。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入出货数量。', ''); |
| | | } |
| | | //新建订单时 |
| | | if (String.isEmpty(ESetId)) { |
| | | p.Name = '*'; |
| | | p.Order_type__c = '传票'; |
| | | p.Order_ProType__c = agencyProType; |
| | | if (coc.SummonsStatus_c__c == null || String.isBlank(coc.SummonsStatus_c__c)) |
| | | coc.SummonsStatus_c__c = '草案中'; |
| | | // update strat by vivek 2019-7-12 |
| | | p.NoConfirmedPrice__c = coc.NoConfirmedPrice__c; |
| | | // update end by vivek 2019-7-12 |
| | | p.SummonsStatus_c__c = coc.SummonsStatus_c__c; |
| | | if (coc.Arrive_Order__c != null) { |
| | | p.Arrive_Order__c = coc.Arrive_Order__c; |
| | | } |
| | | p.Offers_Price__c = coc.Offers_Price__c; |
| | | p.Dealer_Info__c = accountid; |
| | | if (String.isBlank(SecondDealer)) { |
| | | p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null; |
| | | p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c; |
| | | } else { |
| | | p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null; |
| | | p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c; |
| | | p.Order_ForDealer__c = SecondDealer; |
| | | } |
| | | P.Order_ForDealerText__c = coc.Order_ForDealerText__c; |
| | | P.Order_ForDealerTextID__c = coc.Order_ForDealerTextID__c; |
| | | p.Order_date__c = coc.Order_date__c; |
| | | p.SummonsForDirction__c = coc.SummonsForDirction__c; |
| | | p.RecordTypeid = System.Label.RT_ConOrder_Outboundorder; |
| | | // update start by vivek 2019-7-15 |
| | | p.NoConfirmedPrice__c = coc.NoConfirmedPrice__c; |
| | | // update end by vivek 2019-7-15 |
| | | //add by rentx |
| | | p.OutPattern__c = coc.OutPattern__c; |
| | | //add by rentx |
| | | //Map<String,String> ProductNewMap = new Map<String, String>(); |
| | | for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) { |
| | | if (ass.check == true) { |
| | | if (ass.orderdetails1.Delivery_List_RMB__c < 0) { |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入正确的出货单价 (元)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入正确的出货单价 (元)。', ''); |
| | | } |
| | | if (ass.orderdetails1.Delivery_List_RMB__c == null && coc.SummonsForDirction__c != '医院试用') { |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入正确的出货单价 (元)。', ''); |
| | | } |
| | | if ( |
| | | ass.orderdetails1.Delivery_List_RMB__c == 0 && |
| | | (coc.SummonsForDirction__c == '销售给二级经销商' || |
| | | coc.SummonsForDirction__c == '直接销售给医院') |
| | | ) { |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货单价 (元)。', ''); |
| | | } |
| | | if (ass.orderdetails1.Shipment_Count__c == null || ass.orderdetails1.Shipment_Count__c == 0) { |
| | | // ass.orderdetails1.Shipment_Count__c.addError('请输入出货数量。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货数量。', ''); |
| | | } |
| | | |
| | | if(ass.orderdetails1.Box_Piece__c == null ||ass.orderdetails1.Box_Piece__c ==''){ |
| | | // ass.orderdetails1.Box_Piece__c.addError('请输入单位。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入单位。', ''); |
| | | } |
| | | if(ass.orderdetails1.Box_Piece__c == '盒'){ |
| | | if(ass.orderdetails1.Shipment_Count__c > ass.Boxnumber){ |
| | | //ass.orderdetails1.Shipment_Count__c.addError('库存不足'); |
| | | if(ass.oldCheck == false){ |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC('Error',500, '消耗品'+ ass.Prod.Name__c + '库存不足', ''); |
| | | }else{ |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC('Error',500, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', ''); |
| | | } |
| | | if (ass.orderdetails1.Box_Piece__c == null || ass.orderdetails1.Box_Piece__c == '') { |
| | | // ass.orderdetails1.Box_Piece__c.addError('请输入单位。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入单位。', ''); |
| | | } |
| | | if (ass.orderdetails1.Box_Piece__c == '盒') { |
| | | if (ass.orderdetails1.Shipment_Count__c > ass.Boxnumber) { |
| | | //ass.orderdetails1.Shipment_Count__c.addError('库存不足'); |
| | | if (ass.oldCheck == false) { |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC('Error', 500, '消耗品' + ass.Prod.Name__c + '库存不足', ''); |
| | | } else { |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC( |
| | | 'Error', |
| | | 500, |
| | | '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', |
| | | '' |
| | | ); |
| | | } |
| | | }else if(ass.orderdetails1.Box_Piece__c == '个'){ |
| | | if(ass.orderdetails1.Shipment_Count__c > ass.Piecenumber){ |
| | | //ass.orderdetails1.Shipment_Count__c.addError('库存不足'); |
| | | if(ass.oldCheck == false){ |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC('Error',500, '消耗品'+ ass.Prod.Name__c + '库存不足', ''); |
| | | }else{ |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC('Error',500, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', ''); |
| | | } |
| | | } |
| | | } else if (ass.orderdetails1.Box_Piece__c == '个') { |
| | | if (ass.orderdetails1.Shipment_Count__c > ass.Piecenumber) { |
| | | //ass.orderdetails1.Shipment_Count__c.addError('库存不足'); |
| | | if (ass.oldCheck == false) { |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC('Error', 500, '消耗品' + ass.Prod.Name__c + '库存不足', ''); |
| | | } else { |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC( |
| | | 'Error', |
| | | 500, |
| | | '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', |
| | | '' |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | insert p; |
| | | ESetId = p.id; |
| | | List<Consumable_order__c> detailName = new List<Consumable_order__c>(); |
| | | detailName = [SELECT id,Name FROM Consumable_order__c WHERE id =:ESetId]; |
| | | Integer i = 1; |
| | | for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) { |
| | | if(ass.check == true){ |
| | | Consumable_orderdetails__c InsAfterDel = new Consumable_orderdetails__c(); |
| | | } |
| | | insert p; |
| | | ESetId = p.id; |
| | | List<Consumable_order__c> detailName = new List<Consumable_order__c>(); |
| | | detailName = [SELECT id, Name FROM Consumable_order__c WHERE id = :ESetId]; |
| | | Integer i = 1; |
| | | for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) { |
| | | if (ass.check == true) { |
| | | Consumable_orderdetails__c InsAfterDel = new Consumable_orderdetails__c(); |
| | | String str = string.valueOf(i); |
| | | if (str.length() == 1) { |
| | | str = '0' + str; |
| | | } |
| | | InsAfterDel.Name = detailName[0].name + '-' + str; |
| | | InsAfterDel.Shipment_Count__c = ass.orderdetails1.Shipment_Count__c; |
| | | InsAfterDel.Consumable_order__c = p.id; |
| | | InsAfterDel.Consumable_Product__c = ass.Prod.id; |
| | | InsAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c; |
| | | InsAfterDel.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c; |
| | | // TODO 默认 盒 ,需要修正 |
| | | InsAfterDel.Box_Piece__c = ass.orderdetails1.Box_Piece__c; |
| | | InsAfterDel.Out_unit__c = ass.orderdetails1.Box_Piece__c; |
| | | //InsAfterDel.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c; |
| | | InsAfterDel.Dealer_Custom_Price__c = ass.orderdetails1.Dealer_Custom_Price__c; |
| | | InsAfterDel.RecordTypeId = System.Label.RT_ConOrderDetail1_Order; |
| | | //add by rentx 2021-2-26 start |
| | | InsAfterDel.isOutPattern__c = ass.hospitalSpecialOffer; |
| | | //add by rentx 2021-2-26 end |
| | | i++; |
| | | Ins.add(InsAfterDel); |
| | | } |
| | | } |
| | | // 如果 出库单 和 OCM发货Header连 的话,发货的Detail2 Copy到 出库单的Detail2里 |
| | | if (getExistarrive()) { |
| | | for (ConsumableorderdetailsInfo ass : consumableproductdetailsRecords) { |
| | | //BlockForP; |
| | | Consumable_order_details2__c InsProductDet = new Consumable_order_details2__c(); |
| | | InsProductDet.Id = ass.orderdetails2.Id; |
| | | InsProductDet.Consumable_ZS_order__c = p.id; |
| | | i++; |
| | | InsProduct.add(InsProductDet); |
| | | } |
| | | } |
| | | if (Ins.size() > 0) { |
| | | insert Ins; |
| | | } |
| | | if (InsProduct.size() > 0) { |
| | | //ControllerUtil.updateOrderDetailsSatus(InsProduct); |
| | | update InsProduct; |
| | | } |
| | | } else if (ESetId != null || ESetId.length() > 0) { |
| | | //修改之后 保存订单 |
| | | List<Consumable_order__c> cocinfo = new List<Consumable_order__c>(); |
| | | // update start by vivek 2019-7-15 add "NoConfirmedPrice__c" in select |
| | | cocinfo = [ |
| | | SELECT Id, Name, SummonsStatus_c__c, NoConfirmedPrice__c, Dealer_Info__c, Order_ForHospital__c, SummonsForDirction__c |
| | | FROM Consumable_order__c |
| | | WHERE Id = :ESetId |
| | | ]; |
| | | // update end by vivek 2019-7-15 |
| | | if (cocinfo.size() > 0) { |
| | | p = cocinfo[0]; |
| | | } |
| | | p.Name = coc.Name; |
| | | p.Dealer_Info__c = accountid; |
| | | p.Order_ProType__c = agencyProType; |
| | | if (String.isEmpty(SecondDealer)) { |
| | | p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null; |
| | | p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c; |
| | | System.debug('SecondDealer = ' + SecondDealer); |
| | | p.Order_ForDealer__c = null; |
| | | } else { |
| | | p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null; |
| | | p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c; |
| | | p.Order_ForDealer__c = SecondDealer; |
| | | } |
| | | P.Order_ForDealerText__c = coc.Order_ForDealerText__c; |
| | | P.Order_ForDealerTextID__c = coc.Order_ForDealerTextID__c; |
| | | p.Order_date__c = coc.Order_date__c; |
| | | p.SummonsForDirction__c = coc.SummonsForDirction__c; |
| | | //add by rentx |
| | | p.OutPattern__c = coc.OutPattern__c; |
| | | // update start by vivek 2019-7-15 |
| | | if (p.SummonsStatus_c__c == '价格未定') { |
| | | p.NoConfirmedPrice__c = false; |
| | | p.SummonsStatus_c__c = '已完成'; |
| | | } else { |
| | | p.SummonsStatus_c__c = '草案中'; |
| | | } |
| | | // p.SummonsStatus_c__c = '草案中'; |
| | | // update end by vivek 2019-7-15 |
| | | Integer i = 1; |
| | | //Map<String,String> ProductOldMap = new Map<String, String>(); |
| | | for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) { |
| | | if (ass.check == true) { |
| | | if (ass.orderdetails1.Delivery_List_RMB__c < 0) { |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入正确的出货单价 (元)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入正确的出货单价 (元)。', ''); |
| | | } |
| | | Consumable_orderdetails__c InsAfterDel = new Consumable_orderdetails__c(); |
| | | if (ass.orderdetails1.Delivery_List_RMB__c == null && coc.SummonsForDirction__c != '医院试用') { |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货单价 (元)。', ''); |
| | | } |
| | | if ( |
| | | ass.orderdetails1.Delivery_List_RMB__c == 0 && |
| | | (coc.SummonsForDirction__c == '销售给二级经销商' || |
| | | coc.SummonsForDirction__c == '直接销售给医院') |
| | | ) { |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货单价 (元)。', ''); |
| | | } |
| | | if (ass.orderdetails1.Box_Piece__c == null || ass.orderdetails1.Box_Piece__c == '') { |
| | | // ass.orderdetails1.Box_Piece__c.addError('请输入单位。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入单位。', ''); |
| | | } |
| | | if (ass.orderdetails1.Box_Piece__c == '盒') { |
| | | if (ass.orderdetails1.Shipment_Count__c > ass.Boxnumber) { |
| | | //ass.orderdetails1.Shipment_Count__c.addError('库存不足'); |
| | | if (ass.oldCheck == false) { |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC('Error', 500, '消耗品' + ass.Prod.Name__c + '库存不足', ''); |
| | | } else { |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC( |
| | | 'Error', |
| | | 500, |
| | | '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', |
| | | '' |
| | | ); |
| | | } |
| | | } |
| | | } else if (ass.orderdetails1.Box_Piece__c == '个') { |
| | | if (ass.orderdetails1.Shipment_Count__c > ass.Piecenumber) { |
| | | if (ass.oldCheck == false) { |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC('Error', 500, '消耗品' + ass.Prod.Name__c + '库存不足', ''); |
| | | } else { |
| | | //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC( |
| | | 'Error', |
| | | 500, |
| | | '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', |
| | | '' |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | if (ass.orderdetails1.Shipment_Count__c == null || ass.orderdetails1.Shipment_Count__c == 0) { |
| | | // ass.orderdetails1.Shipment_Count__c.addError('请输入出货数量。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货数量。', ''); |
| | | } else { |
| | | String str = string.valueOf(i); |
| | | if(str.length() == 1){ |
| | | if (str.length() == 1) { |
| | | str = '0' + str; |
| | | } |
| | | InsAfterDel.Name = detailName[0].name + '-'+ str; |
| | | InsAfterDel.Name = p.name + '-' + str; |
| | | InsAfterDel.Shipment_Count__c = ass.orderdetails1.Shipment_Count__c; |
| | | InsAfterDel.Consumable_order__c = p.id; |
| | | InsAfterDel.Consumable_order__c = ESetId; |
| | | InsAfterDel.Consumable_Product__c = ass.Prod.id; |
| | | InsAfterDel.Intra_Trade_List_RMB__c =ass.Prod.Intra_Trade_List_RMB__c; |
| | | InsAfterDel.Intra_Trade_List_RMB__c = ass.Prod.Intra_Trade_List_RMB__c; |
| | | InsAfterDel.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c; |
| | | // TODO 默认 盒 ,需要修正 |
| | | InsAfterDel.Box_Piece__c = ass.orderdetails1.Box_Piece__c; |
| | | InsAfterDel.Out_unit__c = ass.orderdetails1.Box_Piece__c; |
| | | //InsAfterDel.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c; |
| | |
| | | Ins.add(InsAfterDel); |
| | | } |
| | | } |
| | | // 如果 出库单 和 OCM发货Header连 的话,发货的Detail2 Copy到 出库单的Detail2里 |
| | | if (getExistarrive()) { |
| | | for (ConsumableorderdetailsInfo ass : consumableproductdetailsRecords) { |
| | | //BlockForP; |
| | | Consumable_order_details2__c InsProductDet = new Consumable_order_details2__c(); |
| | | InsProductDet.Id = ass.orderdetails2.Id; |
| | | InsProductDet.Consumable_ZS_order__c = p.id; |
| | | i++; |
| | | InsProduct.add(InsProductDet); |
| | | } |
| | | } |
| | | if(Ins.size()>0){ |
| | | insert Ins; |
| | | } |
| | | if(InsProduct.size() >0){ |
| | | ControllerUtil.updateOrderDetailsSatus(InsProduct); |
| | | } |
| | | } |
| | | //修改之后 保存订单 |
| | | else if(ESetId != null || ESetId.length() >0 ){ |
| | | List<Consumable_order__c> cocinfo = New List<Consumable_order__c>(); |
| | | // update start by vivek 2019-7-15 add "NoConfirmedPrice__c" in select |
| | | cocinfo = [SELECT Id, |
| | | Name, |
| | | SummonsStatus_c__c, |
| | | NoConfirmedPrice__c, |
| | | Dealer_Info__c, |
| | | Order_ForHospital__c, |
| | | SummonsForDirction__c |
| | | FROM Consumable_order__c |
| | | WHERE Id =:ESetId]; |
| | | // update end by vivek 2019-7-15 |
| | | if (cocinfo.size()>0){ |
| | | p = cocinfo[0]; |
| | | } |
| | | p.Name = coc.Name; |
| | | p.Dealer_Info__c = accountid; |
| | | p.Order_ProType__c = agencyProType; |
| | | if(SecondDealer == null){ |
| | | p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null; |
| | | p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c; |
| | | p.Order_ForDealer__c = SecondDealer; |
| | | }else { |
| | | p.Order_ForHospital__c = String.isNotBlank(HospitalInfo) ? HospitalInfo : null; |
| | | p.Order_ForCustomerText__c = coc.Order_ForCustomerText__c; |
| | | p.Order_ForDealer__c = SecondDealer; |
| | | } |
| | | P.Order_ForDealerText__c = coc.Order_ForDealerText__c; |
| | | P.Order_ForDealerTextID__c = coc.Order_ForDealerTextID__c; |
| | | p.Order_date__c = coc.Order_date__c; |
| | | p.SummonsForDirction__c = coc.SummonsForDirction__c; |
| | | //add by rentx |
| | | p.OutPattern__c = coc.OutPattern__c; |
| | | // update start by vivek 2019-7-15 |
| | | if(p.SummonsStatus_c__c== '价格未定'){ |
| | | p.NoConfirmedPrice__c = false; |
| | | p.SummonsStatus_c__c= '已完成'; |
| | | }else{ |
| | | p.SummonsStatus_c__c = '草案中'; |
| | | } |
| | | // p.SummonsStatus_c__c = '草案中'; |
| | | // update end by vivek 2019-7-15 |
| | | Integer i = 1; |
| | | //Map<String,String> ProductOldMap = new Map<String, String>(); |
| | | for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) { |
| | | if(ass.check == true){ |
| | | if(ass.orderdetails1.Delivery_List_RMB__c < 0){ |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入正确的出货单价 (元)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入正确的出货单价 (元)。', ''); |
| | | } |
| | | Consumable_orderdetails__c InsAfterDel = new Consumable_orderdetails__c(); |
| | | if(ass.orderdetails1.Delivery_List_RMB__c == null && coc.SummonsForDirction__c !='医院试用'){ |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入出货单价 (元)。', ''); |
| | | } |
| | | if(ass.orderdetails1.Delivery_List_RMB__c == 0 && (coc.SummonsForDirction__c =='销售给二级经销商' || coc.SummonsForDirction__c =='直接销售给医院')){ |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入出货单价 (元)。', ''); |
| | | } |
| | | if(ass.orderdetails1.Box_Piece__c == null ||ass.orderdetails1.Box_Piece__c ==''){ |
| | | // ass.orderdetails1.Box_Piece__c.addError('请输入单位。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入单位。', ''); |
| | | } |
| | | if(ass.orderdetails1.Box_Piece__c == '盒'){ |
| | | if(ass.orderdetails1.Shipment_Count__c > ass.Boxnumber){ |
| | | //ass.orderdetails1.Shipment_Count__c.addError('库存不足'); |
| | | if(ass.oldCheck == false){ |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC('Error',500, '消耗品'+ ass.Prod.Name__c + '库存不足', ''); |
| | | }else{ |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC('Error',500, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', ''); |
| | | } |
| | | } |
| | | }else if(ass.orderdetails1.Box_Piece__c == '个'){ |
| | | if(ass.orderdetails1.Shipment_Count__c > ass.Piecenumber){ |
| | | if(ass.oldCheck == false){ |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.Prod.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC('Error',500, '消耗品'+ ass.Prod.Name__c + '库存不足', ''); |
| | | }else{ |
| | | //ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足')); |
| | | return new ResponseBodyLWC('Error',500, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', ''); |
| | | } |
| | | } |
| | | } |
| | | if(ass.orderdetails1.Shipment_Count__c == null||ass.orderdetails1.Shipment_Count__c==0){ |
| | | // ass.orderdetails1.Shipment_Count__c.addError('请输入出货数量。'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error',500, '请输入出货数量。', ''); |
| | | }else{ |
| | | |
| | | String str = string.valueOf(i); |
| | | if(str.length() == 1){ |
| | | str = '0' + str; |
| | | } |
| | | InsAfterDel.Name = p.name + '-'+ str; |
| | | InsAfterDel.Shipment_Count__c = ass.orderdetails1.Shipment_Count__c; |
| | | InsAfterDel.Consumable_order__c = ESetId; |
| | | InsAfterDel.Consumable_Product__c = ass.Prod.id; |
| | | InsAfterDel.Intra_Trade_List_RMB__c =ass.Prod.Intra_Trade_List_RMB__c; |
| | | InsAfterDel.Delivery_List_RMB__c = ass.orderdetails1.Delivery_List_RMB__c; |
| | | InsAfterDel.Box_Piece__c = ass.orderdetails1.Box_Piece__c; |
| | | InsAfterDel.Out_unit__c = ass.orderdetails1.Box_Piece__c; |
| | | //InsAfterDel.Unitprice_To_agency__c = ass.orderdetails1.Unitprice_To_agency__c; |
| | | InsAfterDel.Dealer_Custom_Price__c = ass.orderdetails1.Dealer_Custom_Price__c; |
| | | InsAfterDel.RecordTypeId = System.Label.RT_ConOrderDetail1_Order; |
| | | //add by rentx 2021-2-26 start |
| | | InsAfterDel.isOutPattern__c = ass.hospitalSpecialOffer; |
| | | //add by rentx 2021-2-26 end |
| | | i++; |
| | | Ins.add(InsAfterDel); |
| | | } |
| | | } |
| | | } |
| | | update p; |
| | | List<Consumable_orderdetails__c> qs = New List<Consumable_orderdetails__c>(); |
| | | qs = [SELECT Id FROM Consumable_orderdetails__c WHERE Consumable_order__c =:ESetId]; |
| | | if (qs.size()>0){ |
| | | delete qs; |
| | | } |
| | | if(Ins.size()>0){ |
| | | insert Ins; |
| | | } |
| | | |
| | | update p; |
| | | List<Consumable_orderdetails__c> qs = new List<Consumable_orderdetails__c>(); |
| | | qs = [SELECT Id FROM Consumable_orderdetails__c WHERE Consumable_order__c = :ESetId]; |
| | | if (qs.size() > 0) { |
| | | delete qs; |
| | | } |
| | | if (Ins.size() > 0) { |
| | | insert Ins; |
| | | } |
| | | } |
| | | // }catch (Exception ex) { |
| | | // Database.rollback(sp); |
| | | // // ApexPages.addMessages(ex); |
| | |
| | | // //return new ResponseBodyLWC('Error',500, ex.getMessage(), ''); |
| | | // return new ResponseBodyLWC('Error',500, JSON.serialize(ex), ''); |
| | | // } |
| | | data.put('ESetId',ESetId); |
| | | data.put('ESetId', ESetId); |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | | return res; |
| | | } |
| | | |
| | | public static void checkOutPattern(){ |
| | | public static void checkOutPattern() { |
| | | //根据用户选中的产品给 出库单上的是否医院特价出库字段赋值 |
| | | Integer isHos = 0; |
| | | for(ConsumableorderdetailsInfo CheckCount : pageRecords) { |
| | | for (ConsumableorderdetailsInfo CheckCount : pageRecords) { |
| | | if (CheckCount.check == true && CheckCount.hospitalSpecialOffer == true) { |
| | | ishos = ishos +1; |
| | | ishos = ishos + 1; |
| | | } |
| | | } |
| | | if (isHos > 0) { |
| | | coc.OutPattern__c = true; |
| | | }else{ |
| | | } else { |
| | | coc.OutPattern__c = false; |
| | | } |
| | | } |
| | | |
| | | //打印PDF |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC PraseToPDF(Consumable_order__c cocLwc,String ESetId){ |
| | | public static ResponseBodyLWC PraseToPDF(Consumable_order__c cocLwc, String ESetId) { |
| | | System.debug('cocLwc = ' + cocLwc); |
| | | System.debug('ESetId = ' + ESetId); |
| | | coc = cocLwc; |
| | |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | |
| | | if(coc.SummonsStatus_c__c =='批准'){ |
| | | if (coc.SummonsStatus_c__c == '批准') { |
| | | Consumable_order__c P = new Consumable_order__c(); |
| | | List<Consumable_order__c> cocinfo = New List<Consumable_order__c>(); |
| | | // update start by vivek 2019-7-15 add “NoConfirmedPrice__c” in select |
| | | cocinfo = [SELECT Id,Name,SummonsStatus_c__c,NoConfirmedPrice__c,Dealer_Info__c,Order_ForHospital__c,SummonsForDirction__c,Billed_Status__c FROM Consumable_order__c WHERE Id =:ESetId]; |
| | | List<Consumable_order__c> cocinfo = new List<Consumable_order__c>(); |
| | | // update start by vivek 2019-7-15 add “NoConfirmedPrice__c” in select |
| | | cocinfo = [ |
| | | SELECT |
| | | Id, |
| | | Name, |
| | | SummonsStatus_c__c, |
| | | NoConfirmedPrice__c, |
| | | Dealer_Info__c, |
| | | Order_ForHospital__c, |
| | | SummonsForDirction__c, |
| | | Billed_Status__c |
| | | FROM Consumable_order__c |
| | | WHERE Id = :ESetId |
| | | ]; |
| | | // update end by vivek 2019-7-15 |
| | | if (cocinfo.size()>0){ |
| | | p = cocinfo[0]; |
| | | } |
| | | if (cocinfo.size() > 0) { |
| | | p = cocinfo[0]; |
| | | } |
| | | p.SummonsStatus_c__c = '出库单已打印'; |
| | | update p; |
| | | } |
| | | data.put('ESetId',ESetId); |
| | | data.put('ESetId', ESetId); |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | | return res; |
| | | } |
| | | |
| | | //查找经销商 |
| | | @AuraEnabled(cacheable=true scope='global') |
| | | public static List<LookupSearchResult> search(String searchTerm) { |
| | | System.debug('searchTerm = ' + searchTerm); |
| | | String nameCondition = ''; |
| | | nameCondition += '%' + String.escapeSingleQuotes(''.replaceAll('%', '\\%')) + '%'; |
| | | List<Account> accs; |
| | | System.debug('nameCondition = ' + nameCondition); |
| | | accs = [ |
| | | SELECT id, Parentid |
| | | FROM Account |
| | | WHERE |
| | | Parent.Name LIKE :nameCondition |
| | | AND Contract_Decide_Start_Date__c <= :Date.Today() |
| | | AND Contract_Decide_End_Date__c >= :Date.Today() |
| | | ]; |
| | | |
| | | // 用于保存特约经销商匹配到的其父类的id |
| | | Set<String> pids = new Set<String>(); |
| | | for (Account acc : accs) { |
| | | pids.add(acc.Parentid); |
| | | } |
| | | accs = [ |
| | | SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity |
| | | FROM Account |
| | | WHERE |
| | | (Id IN :pids |
| | | OR (Name = '奥林巴斯(北京)销售服务有限公司' |
| | | AND Name LIKE :nameCondition)) |
| | | AND RecordType.DeveloperName = 'Agency' |
| | | AND Is_Active__c != '無効' |
| | | ORDER BY Name |
| | | LIMIT 5 |
| | | ]; |
| | | |
| | | List<LookupSearchResult> results = new List<LookupSearchResult>(); |
| | | String accountIcon = 'standard:account'; |
| | | for (Account account : accs) { |
| | | String subtitle = account.BillingCity == null ? 'Account' : 'Account • ' + account.BillingCity; |
| | | results.add(new LookupSearchResult(account.Id, 'Account', accountIcon, account.Name, subtitle)); |
| | | } |
| | | results.sort(); |
| | | System.debug('results = ' + results); |
| | | return results; |
| | | } |
| | | |
| | | //保存附件 |
| | | @AuraEnabled |
| | | public static String saveFile(Id recordId, String fileName, String base64Data) { |
| | | base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8'); |
| | | ContentVersion cv = new ContentVersion(); |
| | | cv.Title = fileName; |
| | | cv.PathOnClient = '/' + fileName; |
| | | cv.FirstPublishLocationId = recordId; |
| | | cv.VersionData = EncodingUtil.base64Decode(base64Data); |
| | | cv.IsMajorVersion = true; |
| | | insert cv; |
| | | return cv.Id; |
| | | } |
| | | |
| | | //获取附件 |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC getFiles(Id recordId) { |
| | | System.debug('getFiles recordId = ' + recordId); |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | List<ContentVersion> cvList = [ |
| | | SELECT id, Title, CreatedBy.Name, PathOnClient, CreatedDate |
| | | FROM ContentVersion |
| | | WHERE FirstPublishLocationId = :recordId |
| | | ]; |
| | | data.put('cvList', cvList); |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | | return res; |
| | | } |
| | | |
| | | //跳转出货/销售 |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC GoodsDelivery( |
| | | Consumable_order__c cocLwc, |
| | | String ESetId, |
| | | List<ConsumableorderdetailsInfoLwc> pageRecordsLwcLwc |
| | | ) { |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | coc = cocLwc; |
| | | ESetId = ESetId; |
| | | pageRecordsLwc = pageRecordsLwcLwc; |
| | | if (coc.SummonsForDirction__c == '互相调货') { |
| | | List<Account> accList = [ |
| | | SELECT Id |
| | | FROM Account |
| | | WHERE Name = :coc.Order_ForDealerText__c AND RecordType.DeveloperName = 'Agency' |
| | | ]; |
| | | if (accList.size() < 1) { |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请输入二级经销商全称!')); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入二级经销商全称!', ''); |
| | | } |
| | | } |
| | | if (coc.SummonsStatus_c__c == '批准') { |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '请先打印指示单!')); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请先打印指示单!', ''); |
| | | } |
| | | for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) { |
| | | if (ass.orderdetails1.Shipment_Count__c > ass.allnumber) { |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '消耗品'+ ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足')); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', ''); |
| | | } |
| | | } |
| | | data.put('ESetid', ESetid); |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | | return res; |
| | | } |
| | | |
| | | //删除按钮 |
| | | @AuraEnabled |
| | | public static ResponseBodyLWC DelConsumable(String ESetId) { |
| | | ResponseBodyLWC res = new ResponseBodyLWC(); |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | |
| | | ESetId = ESetId; |
| | | |
| | | Savepoint sp = Database.setSavepoint(); |
| | | try { |
| | | List<Consumable_order__c> qs = new List<Consumable_order__c>(); |
| | | List<Consumable_orderdetails__c> Dqs = new List<Consumable_orderdetails__c>(); |
| | | Dqs = [SELECT Id FROM Consumable_orderdetails__c WHERE Consumable_order__c = :ESetId]; |
| | | qs = [SELECT Id FROM Consumable_order__c WHERE Id = :ESetId]; |
| | | if (Dqs.size() > 0 || qs.size() > 0) { |
| | | delete Dqs; |
| | | delete qs; |
| | | } |
| | | } catch (Exception e) { |
| | | Database.rollback(sp); |
| | | System.debug(e.getMessage() + e.getLineNumber()); |
| | | return new ResponseBodyLWC('Error', 500, e.getMessage(), ''); |
| | | } |
| | | res.status = 'Success'; |
| | | res.code = 200; |
| | | System.debug('res = ' + res); |
| | |
| | | @AuraEnabled |
| | | public Boolean hosPro { get; set; } |
| | | |
| | | public ConsumableorderdetailsInfo(){} |
| | | public ConsumableorderdetailsInfo() { |
| | | } |
| | | |
| | | public ConsumableorderdetailsInfo(Consumable_Orderdetails__c e) { |
| | | check = true; |
| | |
| | | hospitalSpecialOffer = false; |
| | | hosPro = false; |
| | | } |
| | | |
| | | public ConsumableorderdetailsInfo(Product2__c e) { |
| | | check = false; |
| | | oldCheck = false; |
| | |
| | | } |
| | | } |
| | | |
| | | class ConsumableorderdetailsInfoLwc{ |
| | | class ConsumableorderdetailsInfoLwc { |
| | | @AuraEnabled |
| | | public Boolean check { get; set; } |
| | | @AuraEnabled |
| | |
| | | @AuraEnabled |
| | | public Boolean hosPro { get; set; } |
| | | @AuraEnabled |
| | | public List<Map<String,String>> unitOptions{ get; set; } |
| | | public List<Map<String, String>> unitOptions { get; set; } |
| | | @AuraEnabled |
| | | public String unitValue{ get; set; } |
| | | public String unitValue { get; set; } |
| | | @AuraEnabled |
| | | public Integer shipmentNumber{ get; set; } |
| | | public Integer shipmentNumber { get; set; } |
| | | @AuraEnabled |
| | | public Decimal shippingUnitPrice{ get; set; } |
| | | public Decimal shippingUnitPrice { get; set; } |
| | | @AuraEnabled |
| | | public String recordId{ get; set; } |
| | | public String recordId { get; set; } |
| | | @AuraEnabled |
| | | public String Id{ get; set; } |
| | | public String Id { get; set; } |
| | | @AuraEnabled |
| | | public String Name{ get; set; } |
| | | public String Name { get; set; } |
| | | @AuraEnabled |
| | | public String Category3{ get; set; } |
| | | public String Category3 { get; set; } |
| | | @AuraEnabled |
| | | public String Category4{ get; set; } |
| | | public String Category4 { get; set; } |
| | | @AuraEnabled |
| | | public String Category5{ get; set; } |
| | | public String Category5 { get; set; } |
| | | } |
| | | } |
| | | |
| | | //分页Bean |
| | | public class PaginatedAccounts { |
| | | @AuraEnabled |
| | | public Integer nextPageToken; |
| | | @AuraEnabled |
| | | public Integer pageNumber { get; set; } |
| | | @AuraEnabled |
| | | public Integer totalRecords { get; set; } |
| | | @AuraEnabled |
| | | public Integer recordStart { get; set; } |
| | | @AuraEnabled |
| | | public Integer recordEnd { get; set; } |
| | | } |
| | | } |