| | |
| | | // 到货订单来的时候 |
| | | if (getExistarrive()) { |
| | | if (editAble) { |
| | | alertMessage = '到货订单直接出库,出库单明细不可编辑。'; |
| | | alertMessage = '到货订单直接出库,出库单明细不可编辑'; |
| | | } |
| | | if (coc.SummonsStatus_c__c == '已提交' || coc.SummonsStatus_c__c == '批准') { |
| | | system.debug('coc.SummonsStatus_c__c : ' + coc.SummonsStatus_c__c); |
| | |
| | | res.entity = data; |
| | | //订单信息确认 |
| | | if (coc.SummonsForDirction__c == '' || coc.SummonsForDirction__c == null) { |
| | | // coc.SummonsForDirction__c.addError('请输入指示单目的。'); |
| | | // coc.SummonsForDirction__c.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)) { |
| | | // coc.addError('请输入医院。'); |
| | | // coc.addError('请输入医院'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入医院。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入医院', ''); |
| | | } |
| | | if (String.isBlank(coc.Order_ForCustomerText__c)) { |
| | | // coc.Order_ForCustomerText__c.addError('请输入科室。'); |
| | | // coc.Order_ForCustomerText__c.addError('请输入科室'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入科室。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入科室', ''); |
| | | } else if (String.isNotBlank(SecondDealer) || String.isNotBlank(coc.Order_ForDealerText__c)) { |
| | | // coc.addError('不需要二级经销商和经销商(录入)信息。' ); |
| | | // 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)) { |
| | | // coc.addError('请输入医院。'); |
| | | // coc.addError('请输入医院'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入医院。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入医院', ''); |
| | | } |
| | | if (String.isBlank(coc.Order_ForCustomerText__c)) { |
| | | // coc.Order_ForCustomerText__c.addError('请输入科室。'); |
| | | // 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)) { |
| | | // coc.addError('必须输入二级经销商或经销商(录入)。'); |
| | | // coc.addError('必须输入二级经销商或经销商(录入)'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '必须输入二级经销商或经销商(录入)。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '必须输入二级经销商或经销商(录入)', ''); |
| | | } |
| | | if (String.isBlank(HospitalInfo) || String.isBlank(HospitalName)) { |
| | | // coc.addError('请输入医院。'); |
| | | // coc.addError('请输入医院'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入医院。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入医院', ''); |
| | | } |
| | | if (String.isBlank(coc.Order_ForCustomerText__c)) { |
| | | // coc.Order_ForCustomerText__c.addError('请输入科室。'); |
| | | // 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)) { |
| | | // coc.addError('不需要输入医院。'); |
| | | // coc.addError('不需要输入医院'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '不需要输入医院。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '不需要输入医院', ''); |
| | | } |
| | | if (String.isNotBlank(coc.Order_ForCustomerText__c)) { |
| | | // coc.Order_ForCustomerText__c.addError('不需要输入科室。'); |
| | | // 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)) { |
| | | // coc.addError('必须输入二级经销商或经销商(录入)。'); |
| | | // coc.addError('必须输入二级经销商或经销商(录入)'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '必须输入二级经销商或经销商(录入)。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '必须输入二级经销商或经销商(录入)', ''); |
| | | } |
| | | } |
| | | |
| | |
| | | return new ResponseBodyLWC( |
| | | 'Error', |
| | | 500, |
| | | '经销商:' + coc.Order_ForDealerText__c + ' 没有消耗品:' + proStr.substring(0, proStr.length() - 1) + ' 的特价', |
| | | '经销商:' + |
| | | coc.Order_ForDealerText__c + |
| | | ' 没有消耗品:' + |
| | | proStr.substring(0, proStr.length() - 1) + |
| | | ' 的特价', |
| | | '' |
| | | ); |
| | | } |
| | |
| | | for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) { |
| | | if (ass.check == true) { |
| | | if (ass.orderdetails1.Delivery_List_RMB__c < 0) { |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入正确的出货单价 (元)。'); |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入正确的出货单价 (元)'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入正确的出货单价 (元)。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入正确的出货单价 (元)', ''); |
| | | } |
| | | if (ass.orderdetails1.Delivery_List_RMB__c == null && coc.SummonsForDirction__c != '医院试用') { |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)。'); |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入正确的出货单价 (元)。', ''); |
| | | 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('请输入出货单价 (元)。'); |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货单价 (元)。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货单价 (元)', ''); |
| | | } |
| | | if (ass.orderdetails1.Shipment_Count__c == null || ass.orderdetails1.Shipment_Count__c == 0) { |
| | | // ass.orderdetails1.Shipment_Count__c.addError('请输入出货数量。'); |
| | | // ass.orderdetails1.Shipment_Count__c.addError('请输入出货数量'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货数量。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货数量', ''); |
| | | } |
| | | |
| | | if (ass.orderdetails1.Box_Piece__c == null || ass.orderdetails1.Box_Piece__c == '') { |
| | | // ass.orderdetails1.Box_Piece__c.addError('请输入单位。'); |
| | | // ass.orderdetails1.Box_Piece__c.addError('请输入单位'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入单位。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入单位', ''); |
| | | } |
| | | if (ass.orderdetails1.Box_Piece__c == '盒') { |
| | | if (ass.orderdetails1.Shipment_Count__c > ass.Boxnumber) { |
| | |
| | | return new ResponseBodyLWC( |
| | | 'Error', |
| | | 500, |
| | | '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', |
| | | '消耗品' + |
| | | ass.orderdetails1.Consumable_Product__r.Name__c + |
| | | '库存不足', |
| | | '' |
| | | ); |
| | | } |
| | |
| | | return new ResponseBodyLWC( |
| | | 'Error', |
| | | 500, |
| | | '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', |
| | | '消耗品' + |
| | | ass.orderdetails1.Consumable_Product__r.Name__c + |
| | | '库存不足', |
| | | '' |
| | | ); |
| | | } |
| | |
| | | for (ConsumableorderdetailsInfoLwc ass : pageRecordsLwc) { |
| | | if (ass.check == true) { |
| | | if (ass.orderdetails1.Delivery_List_RMB__c < 0) { |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入正确的出货单价 (元)。'); |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入正确的出货单价 (元)'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入正确的出货单价 (元)。', ''); |
| | | 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('请输入出货单价 (元)。'); |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货单价 (元)。', ''); |
| | | 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('请输入出货单价 (元)。'); |
| | | // ass.orderdetails1.Delivery_List_RMB__c.addError('请输入出货单价 (元)'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货单价 (元)。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货单价 (元)', ''); |
| | | } |
| | | if (ass.orderdetails1.Box_Piece__c == null || ass.orderdetails1.Box_Piece__c == '') { |
| | | // ass.orderdetails1.Box_Piece__c.addError('请输入单位。'); |
| | | // ass.orderdetails1.Box_Piece__c.addError('请输入单位'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入单位。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入单位', ''); |
| | | } |
| | | if (ass.orderdetails1.Box_Piece__c == '盒') { |
| | | if (ass.orderdetails1.Shipment_Count__c > ass.Boxnumber) { |
| | |
| | | return new ResponseBodyLWC( |
| | | 'Error', |
| | | 500, |
| | | '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', |
| | | '消耗品' + |
| | | ass.orderdetails1.Consumable_Product__r.Name__c + |
| | | '库存不足', |
| | | '' |
| | | ); |
| | | } |
| | |
| | | return new ResponseBodyLWC( |
| | | 'Error', |
| | | 500, |
| | | '消耗品' + ass.orderdetails1.Consumable_Product__r.Name__c + '库存不足', |
| | | '消耗品' + |
| | | 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('请输入出货数量。'); |
| | | // ass.orderdetails1.Shipment_Count__c.addError('请输入出货数量'); |
| | | // return null; |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货数量。', ''); |
| | | return new ResponseBodyLWC('Error', 500, '请输入出货数量', ''); |
| | | } else { |
| | | String str = string.valueOf(i); |
| | | if (str.length() == 1) { |
| | |
| | | public static List<LookupSearchResult> search(String searchTerm) { |
| | | System.debug('searchTerm = ' + searchTerm); |
| | | String nameCondition = ''; |
| | | nameCondition += '%' + String.escapeSingleQuotes(''.replaceAll('%', '\\%')) + '%'; |
| | | List<Account> accs; |
| | | nameCondition += '%' + String.escapeSingleQuotes(searchTerm.replaceAll('%', '\\%')) + '%'; |
| | | List<Account> accs = new List<Account>(); |
| | | 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() |
| | | ]; |
| | | //查询条件修改 |
| | | //筛选判断条件:当前财年的4/1 ~ 第二年的6/30 & ET or ENG类型 & 当前用户类型 |
| | | //1 and 2 |
| | | //1. Integer year 2022/4/1 ~ 2023/6/30 |
| | | //开始日期 + 结束日期 |
| | | //Contract_Decide_Start_Date__c>=开始日期 and Contract_Decide_End_Date__c<结束日期 |
| | | //2. 添加经销商允销类型:ET经销商协议;ENG耗材经销商协议 |
| | | //取当前用户的类型,如果用户类型是ET,ET经销商协议 = true |
| | | // Date today = Date.today(); |
| | | // Integer thisYear = today.year(); |
| | | // Integer nextYear = today.year() + 1; |
| | | // Date thisDatetime = Date.newInstance(thisYear, 4, 1); |
| | | // Date nextDatetime = Date.newInstance(nextYear, 6, 30); |
| | | // System.debug('thisDatetime = ' + thisDatetime); |
| | | // System.debug('nextDatetime = ' + nextDatetime); |
| | | |
| | | // User UserProTypecTemp = [select UserPro_Type__c from User where id =: UserInfo.getUserId()]; |
| | | // System.debug('UserInfo.getUserId() = ' + UserInfo.getUserId()); |
| | | // System.debug('UserProTypecTemp = ' + UserProTypecTemp); |
| | | // System.debug('UserProTypecTemp.UserPro_Type__c = ' + UserProTypecTemp.UserPro_Type__c); |
| | | // if (UserProTypecTemp.UserPro_Type__c == 'ENG') { |
| | | // accs = [ |
| | | // SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity |
| | | // FROM Account |
| | | // WHERE |
| | | // // Name = '奥林巴斯(北京)销售服务有限公司' |
| | | // // AND |
| | | // Name LIKE :nameCondition |
| | | // AND RecordType.DeveloperName = 'AgencyContract' |
| | | // AND Contract_Decide_Start_Date__c >= :thisDatetime |
| | | // AND Contract_Decide_End_Date__c <= :nextDatetime |
| | | // AND ENG_Dealer__c = true |
| | | // ORDER BY Name |
| | | // LIMIT 49 |
| | | // ]; |
| | | // } |
| | | // if (UserProTypecTemp.UserPro_Type__c == 'ET') { |
| | | // accs = [ |
| | | // SELECT Id, Name, Department_Class__c, Department_Class__r.Name, Hospital__c, Hospital__r.Name, BillingCity |
| | | // FROM Account |
| | | // WHERE |
| | | // // Name = '奥林巴斯(北京)销售服务有限公司' |
| | | // // AND |
| | | // Name LIKE :nameCondition |
| | | // AND RecordType.DeveloperName = 'AgencyContract' |
| | | // AND Contract_Decide_Start_Date__c >= :thisDatetime |
| | | // AND Contract_Decide_End_Date__c <= :nextDatetime |
| | | // AND ET_SP_Dealer__c = true |
| | | // ORDER BY Name |
| | | // LIMIT 49 |
| | | // ]; |
| | | // } |
| | | |
| | | |
| | | Date today = Date.today(); |
| | | //Date today = Date.newInstance(2023, 3, 1); |
| | | Integer thisMonth = today.month(); |
| | | System.debug('thisMonth = ' + thisMonth); |
| | | |
| | | Integer lastYear = today.year() - 1; |
| | | Integer thisYear = today.year(); |
| | | Integer nextYear = today.year() + 1; |
| | | |
| | | Date lastDatetime = Date.newInstance(lastYear, 4, 1); |
| | | Date thisDatetime = Date.newInstance(thisYear, 4, 1); |
| | | Date thisDatetime2 = Date.newInstance(thisYear, 7, 1); |
| | | Date nextDatetime = Date.newInstance(nextYear, 7, 1); |
| | | System.debug('lastDatetime = ' + lastDatetime); |
| | | System.debug('thisDatetime = ' + thisDatetime); |
| | | System.debug('thisDatetime2 = ' + thisDatetime2); |
| | | System.debug('nextDatetime = ' + nextDatetime); |
| | | System.debug('UserInfo.getUserId() = ' + UserInfo.getUserId()); |
| | | User UserProTypecTemp = [select UserPro_Type__c from User where id =: UserInfo.getUserId()]; |
| | | |
| | | String sql = 'SELECT id, Parentid FROM Account WHERE Parent.Name LIKE :nameCondition '; |
| | | if(thisMonth < 4){ |
| | | sql += 'AND Contract_Decide_Start_Date__c >= :lastDatetime AND Contract_Decide_End_Date__c < :thisDatetime2 '; |
| | | }else if(thisMonth >= 4 && thisMonth <= 6){ |
| | | sql += 'AND Contract_Decide_Start_Date__c >= :lastDatetime AND Contract_Decide_End_Date__c < :nextDatetime '; |
| | | }else{ |
| | | sql += 'AND Contract_Decide_Start_Date__c >= :thisDatetime AND Contract_Decide_End_Date__c < :nextDatetime '; |
| | | } |
| | | if (UserProTypecTemp.UserPro_Type__c == 'ENG') { |
| | | sql += 'AND ENG_Dealer__c = true'; |
| | | } |
| | | if (UserProTypecTemp.UserPro_Type__c == 'ET') { |
| | | sql += 'AND ET_SP_Dealer__c = true'; |
| | | } |
| | | System.debug('sql = ' + sql); |
| | | accs = Database.query(sql); |
| | | // 用于保存特约经销商匹配到的其父类的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 |
| | |
| | | OR (Name = '奥林巴斯(北京)销售服务有限公司' |
| | | AND Name LIKE :nameCondition)) |
| | | AND RecordType.DeveloperName = 'Agency' |
| | | AND Is_Active__c != '無効' |
| | | ORDER BY Name |
| | | LIMIT 5 |
| | | LIMIT 49 |
| | | ]; |
| | | |
| | | // 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 |
| | | // ]; |
| | | System.debug('accs = ' + accs); |
| | | List<LookupSearchResult> results = new List<LookupSearchResult>(); |
| | | String accountIcon = 'standard:account'; |
| | | for (Account account : accs) { |
| | |
| | | Map<String, object> data = new Map<String, object>(); |
| | | res.entity = data; |
| | | List<ContentVersion> cvList = [ |
| | | SELECT id, Title, CreatedBy.Name, PathOnClient, CreatedDate |
| | | SELECT id, Title, CreatedBy.Name, PathOnClient, CreatedDate, ContentDocumentId |
| | | FROM ContentVersion |
| | | WHERE FirstPublishLocationId = :recordId |
| | | ]; |
| | |
| | | @AuraEnabled |
| | | public Integer recordEnd { get; set; } |
| | | } |
| | | } |
| | | } |