/** * 見積PDFのコントローラです。 */ public class QuotePDFExtensionController { /** 処理対象の見積オブジェクトのIDです。 */ private Id targetQuoteId; /** 処理対象の見積オブジェクトです。 */ private Quote targetObj; /** 1ページに表示する明細の数です。 */ private Integer rowSize = 32; private Shipment_address__c shipmentAddress; /** 最終ページに表示する明細の数です。 */ private Integer lastRowSize = 24; /** 製品名を開業する文字数です。 */ private Integer nameMax = 23; /** 印刷するページ数です。 */ public Integer maxPageNumber { get; set; } /** 印刷対象の見積の配下にある見積品目データです。 */ public List printRecords {get; private set;} private boolean contractFlag = false; /** * 印刷するデータを格納するオブジェクを定義する、インナークラスです。 */ public class QuoteLineItemBean { public QuoteLineItem qli {get; private set;} public Decimal UnitPrice_c {get; private set;} public Decimal TotalPrice_c {get; private set;} public String ApprobationNo_c {get; private set;} public String ProduceCompany_c {get; private set;} public String SalesPackagingUnit_c {get; private set;} public Decimal PackingListManual_c {get; private set;} public String PackingListManual2_c {get; private set;} public QuoteLineItemBean(QuoteLineItem qli) { this.qli = qli; this.UnitPrice_c = qli.UnitPrice__c; this.TotalPrice_c = qli.TotalPrice__c; if (qli.PricebookEntry.Product2.SFDA_Status__c != '不要') { this.ApprobationNo_c = qli.PricebookEntry.Product2.SFDA_Approbation_No__c; } //this.ProduceCompany_c = qli.PricebookEntry.Product2.ProduceCompany_F__c; this.ProduceCompany_c = qli.Description; this.SalesPackagingUnit_c = qli.PricebookEntry.Product2.SalesPackagingUnit_Chinese__c; if (this.qli.Item_Order__c != null && (SalesPackagingUnit_c == null || SalesPackagingUnit_c == '')) { this.SalesPackagingUnit_c = '件'; } this.PackingListManual_c = qli.PricebookEntry.Product2.Packing_list_manual__c; this.PackingListManual2_c = this.PackingListManual_c == null ? '' : 'Pcs'; } } private static Map addressNameApiMap = new Map { '湖南省' => '奥林巴斯(北京)销售服务有限公司广州分公司', '四川省' => '奥林巴斯(北京)销售服务有限公司广州分公司', '广东省' => '奥林巴斯(北京)销售服务有限公司广州分公司', '贵州省' => '奥林巴斯(北京)销售服务有限公司广州分公司', '云南省' => '奥林巴斯(北京)销售服务有限公司广州分公司', '广西自治区' => '奥林巴斯(北京)销售服务有限公司广州分公司', '深圳市' => '奥林巴斯(北京)销售服务有限公司广州分公司', '湖北省' => '奥林巴斯(北京)销售服务有限公司广州分公司', '重庆市' => '奥林巴斯(北京)销售服务有限公司广州分公司', '北京市' => '奥林巴斯(北京)销售服务有限公司', '吉林省' => '奥林巴斯(北京)销售服务有限公司', '大连市' => '奥林巴斯(北京)销售服务有限公司', '黑龙江省' => '奥林巴斯(北京)销售服务有限公司', '内蒙古' => '奥林巴斯(北京)销售服务有限公司', '山东省' => '奥林巴斯(北京)销售服务有限公司', '甘肃省' => '奥林巴斯(北京)销售服务有限公司', '青岛市' => '奥林巴斯(北京)销售服务有限公司', '辽宁省' => '奥林巴斯(北京)销售服务有限公司', '河北省' => '奥林巴斯(北京)销售服务有限公司', '山西省' => '奥林巴斯(北京)销售服务有限公司', '天津市' => '奥林巴斯(北京)销售服务有限公司', '新疆自治区' => '奥林巴斯(北京)销售服务有限公司', '陕西省' => '奥林巴斯(北京)销售服务有限公司', '青海省' => '奥林巴斯(北京)销售服务有限公司', '宁夏自治区' => '奥林巴斯(北京)销售服务有限公司', '河南省' => '奥林巴斯(北京)销售服务有限公司', '浙江省' => '奥林巴斯(北京)销售服务有限公司上海分公司', '安徽省' => '奥林巴斯(北京)销售服务有限公司上海分公司', 'OSH-安徽省' => '奥林巴斯贸易(上海)有限公司', //20230323 lt DB202303088261 两票制 add '江西省' => '奥林巴斯(北京)销售服务有限公司上海分公司', '福建省' => '奥林巴斯(北京)销售服务有限公司上海分公司', '江苏省' => '奥林巴斯(北京)销售服务有限公司上海分公司', '上海市' => '奥林巴斯(北京)销售服务有限公司上海分公司' }; /** * 印刷するデータを格納するオブジェクトです。 * ページ側は、このオブジェクト経由で印刷するデータにアクセスします。 */ public Parameters params { get; set;} /** * 印刷するデータを格納するオブジェクを定義する、インナークラスです。 */ public class Parameters { public String quoteNo {get; set;} public String departmentName {get; set;} public String ownerName {get; set;} public String mobilePhone {get; set;} public String trade {get; set;} public Boolean isUnitPrice {get; set;} public Boolean isOfferAmount {get; set;} public Boolean isTotalPrice {get; set;} public Boolean isDiscountRate {get; set;} public Boolean isDiscountAmount {get; set;} public Boolean isTradingPrice {get; set;} public Boolean isContractDetail {get; set;} // LHJ 多年保修 Start public Boolean isGuranteePeriod {get;set;} // LHJ 多年保修 End public Decimal totalPrice {get; set;} public Decimal discountRate {get; set;} public Decimal discountAmount {get; set;} public Decimal tradingPrice {get; set;} public Date quoteDate {get; set;} public String quoteDateString {get; set;} public String clientName {get; set;} public Date offerPrintDate {get; set;} public String offerPrintDateString {get; set;} public String offerPrintDateStringContract {get; set;} //电子签收ID号 wql 精琢技术 2020/11/20 start public String esignAgencyNum {get; set;} //电子签收ID号 wql 精琢技术 2020/11/20 end public String agent1Name {get; set;} public String agent1Phone {get; set;} public String agent1Fax {get; set;} public String agent2Name {get; set;} public String agent2Phone {get; set;} public String agent2Fax {get; set;} public Integer lenAgentName{get; set;} public String address {get; set;} public String postCode {get;set;} public String addressName {get;set;} public String addressName1 {get;set;}//20230323 lt DB202303088261 两票制 start 报价单用 public String salesRoot {get;set;} public Decimal newTotalPrice {get;set;} //WLIG-BYRD37 【委托】询价 打印配置单 字段修改 精琢技术 wql 2021/03/08 start public String PurchaseType {get;set;} //WLIG-BYRD37 【委托】询价 打印配置单 字段修改 精琢技术 wql 2021/03/08 end public Date Quote_Print_Date {get;set;} public String getAgentNameForContract() { String ret = null; if ( agent1Name == null && agent2Name == null) { ret = ''; } else if ( agent1Name != null && agent2Name == null) { ret = agent1Name; } else if ( agent1Name == null && agent2Name != null) { ret = agent2Name; } else if ( agent1Name != null && agent2Name != null) { ret = agent1Name; } lenAgentName = ret.length(); return ret; } } /** * コンストラクタです。 * テスト用に作成しました。本来は不要です。 */ public QuotePDFExtensionController( String quoteId) { this.mainProc( quoteId); } /** * Visualforceページがアクセスするコンストラクタです。 * 印刷するデータを収集し、インスタンス変数にセットします。 * @param controller スタンダードコントローラーのインスタンス */ public QuotePDFExtensionController(ApexPages.StandardController controller) { this.targetQuoteId = controller.getRecord().Id; } /** * 見積書で、actionから呼ばれます。 */ public void startQuote() { this.contractFlag = false; this.rowSize = 35; this.lastRowSize = 28; this.nameMax = 27; this.mainProc( this.targetQuoteId); } /** * 契約内訳で、actionから呼ばれます。 */ public void startContract() { this.contractFlag = true; // 2022-02-11 SWAG-CBJ8TN 外贸报价配置单打印问题 // 超长报价单,单页最多只能打印下30行,最终客户名称也超长需要换行,单页明细行改为28行 this.rowSize = 28; this.lastRowSize = 28; // this.rowSize = 44; // this.lastRowSize = 44; //this.nameMax = 18;因为一行显示不完全,为防止错版,改为17; // this.nameMax = 16; this.nameMax = 12; this.mainProc( this.targetQuoteId); } /** * 主処理です。 * @param quoteId 見積番号 */ private void mainProc( String quoteId) { this.params = new Parameters(); // 見積情報を取得 List quotes = [SELECT Id, Opportunity.Trade__c, Opportunity.Owner.Name, Opportunity.Owner.MobilePhone, Opportunity.Department_Name__c, Quote_No__c, Name, Unit_Price__c, TotalPrice__c, Offer_Amount__c, TOTAL__c, Preferential_Gurantee_Period__c, Discount__c, Discount_Amount__c, Discount_Amount_Calculate__c, Pricing__c, Preferential_Trading_Price__c, Contract__c, Quote_Date__c, quoteSavedDate__c, Print_HP_Name__c, Agency1__r.Name, Agency1__r.Phone, Agency1__r.Fax, Agency2__r.Name, Agency2__r.Phone, Agency2__r.Fax, Opportunity.Account.RecordType.DeveloperName, Opportunity.Account.Agent_Ref__r.Phone, Opportunity.Account.Agent_Ref__r.Fax, Opportunity.SAP_Province__c, OCM_Agent1_Price__c, Dealer_Final_Price__c, //电子签收ID号 增加字段检索 wql start Opportunity.Sales_Root__c,Opportunity.Agency1__r.Management_FormulaCode__c //电子签收ID号 增加字段检索 wql end //WLIG-BYRD37 【委托】询价 打印配置单 字段修改 精琢技术 wql 2021/03/08 start ,Opportunity.Purchase_Type__c ,Quote_Print_Date__c //WLIG-BYRD37 【委托】询价 打印配置单 字段修改 精琢技术 wql 2021/03/08 end FROM Quote WHERE Id = :quoteId]; // 見積を取得できない場合 if ( quotes.size() != 1) { return; } this.targetObj = quotes[0]; this.setQueryStringData(); this.bindQuoteData( quoteId); this.bindQuoteLineData(); this.getShipmentaddress(); } /** * URLパラメータを取得して、インスタンス変数にセットします。 */ private void setQueryStringData() { try { String rawRowSize = ApexPages.currentPage().getParameters().get( 'rowSize'); this.rowSize = rawRowSize != null ? Integer.valueOf( rawRowSize) : this.rowSize; } catch ( Exception e) { } } /** * 見積データを、インスタンス変数にセットします。 * @param quoteId 見積ID */ private void bindQuoteData( String quoteId) { this.params.quoteNo = this.targetObj.Quote_No__c; this.params.isUnitPrice = this.targetObj.Unit_Price__c; this.params.isOfferAmount = this.targetObj.Offer_Amount__c; this.params.isTotalPrice = this.targetObj.TOTAL__c; this.params.isDiscountRate = this.targetObj.Discount__c; this.params.isDiscountAmount = this.targetObj.Pricing__c; this.params.isTradingPrice = this.targetObj.Preferential_Trading_Price__c; this.params.isContractDetail = this.targetObj.Contract__c; // LHJ 多年保修 Start // this.params.quoteDate = this.targetObj.Quote_Date__c; // this.params.quoteDateString = this.targetObj.Quote_Date__c == null ? '' : this.targetObj.Quote_Date__c.year() + '-' + this.targetObj.Quote_Date__c.month() + '-' + this.targetObj.Quote_Date__c.day(); this.params.quoteDate = this.targetObj.quoteSavedDate__c; this.params.quoteDateString = this.targetObj.quoteSavedDate__c == null ? '' : this.targetObj.quoteSavedDate__c.year() + '-' + this.targetObj.quoteSavedDate__c.month() + '-' + this.targetObj.quoteSavedDate__c.day(); this.params.isGuranteePeriod = this.targetObj.Preferential_Gurantee_Period__c; // LHJ 多年保修 End this.params.clientName = this.targetObj.Print_HP_Name__c; this.params.totalPrice = this.targetObj.totalPrice__c; this.params.discountRate = 100 - ( this.targetObj.Discount_Amount_Calculate__c == null ? 0 : this.targetObj.Discount_Amount_Calculate__c); this.params.discountAmount = ( this.targetObj.Discount_Amount__c == null ? 0 : this.targetObj.Discount_Amount__c) * 1; this.params.ownerName = this.targetObj.Opportunity.owner.Name; this.params.departmentName = this.targetObj.Opportunity.Department_Name__c; this.params.trade = this.targetObj.Opportunity.Trade__c == '内貿' ? 'RMB' : this.targetObj.Opportunity.Trade__c == '外貿' ? 'USD' : '不明'; this.params.MobilePhone = this.targetObj.Opportunity.Owner.MobilePhone; this.params.offerPrintDate = this.targetObj.Quote_Date__c; this.params.offerPrintDateString = this.targetObj.Quote_Date__c == null ? '' : this.targetObj.Quote_Date__c.year() + '-' + this.targetObj.Quote_Date__c.month() + '-' + this.targetObj.Quote_Date__c.day(); this.params.offerPrintDateStringContract = this.targetObj.Quote_Date__c == null ? '' : this.targetObj.Quote_Date__c.year() + '/' + this.targetObj.Quote_Date__c.month() + '/' + this.targetObj.Quote_Date__c.day(); if (this.targetObj.Opportunity.Account.RecordType.DeveloperName == 'AgencyContract') { this.params.agent1Name = this.targetObj.Print_HP_Name__c; this.params.agent1Phone = this.targetObj.Opportunity.Account.Agent_Ref__r.Phone; this.params.agent1Fax = this.targetObj.Opportunity.Account.Agent_Ref__r.Fax; } else { this.params.agent1Name = this.targetObj.Agency1__r.Name; this.params.agent1Phone = this.targetObj.Agency1__r.Phone; this.params.agent1Fax = this.targetObj.Agency1__r.Fax; } this.params.agent2Name = this.targetObj.Agency2__r.Name; this.params.agent2Phone = this.targetObj.Agency2__r.Phone; this.params.agent2Fax = this.targetObj.Agency2__r.Fax; this.params.salesRoot = this.targetObj.Opportunity.Sales_Root__c; this.params.newTotalPrice = this.targetObj.Opportunity.Sales_Root__c == '販売店' ? this.targetObj.OCM_Agent1_Price__c : this.targetObj.Dealer_Final_Price__c; //电子签收ID号 wql 精琢技术 2020/11/20 start this.params.esignAgencyNum = this.targetObj.Opportunity.Sales_Root__c == '販売店' ? this.targetObj.Opportunity.Agency1__r.Management_FormulaCode__c : ''; //电子签收ID号 wql 精琢技术 2020/11/20 end //打印日期 this.params.Quote_Print_Date = this.targetObj.Quote_Print_Date__c; //WLIG-BYRD37 【委托】询价 打印配置单 字段修改 精琢技术 wql 2021/03/08 start this.params.PurchaseType = this.targetObj.Opportunity.Purchase_Type__c ; //WLIG-BYRD37 【委托】询价 打印配置单 字段修改 精琢技术 wql 2021/03/08 end // 20150416 xudan 単価など金額列が出ると、Name列の幅が縮む、改行の文字数を合わせて変更必要 // 同じく、最終ページの明細数も、合計行が出る/出ないにより、調整 // TODO xud NameよりCodeが長い場合は未対応、等幅文字ではない限り、ここまでか if (this.params.isUnitPrice && contractFlag == false) nameMax = nameMax - 2; if (this.params.isOfferAmount && contractFlag == false) nameMax = nameMax - 2; if (this.params.isTotalPrice && contractFlag == false) lastRowSize--; if (this.params.isDiscountRate && contractFlag == false) lastRowSize--; if (this.params.isDiscountAmount && contractFlag == false) lastRowSize--; if (this.params.isTradingPrice && contractFlag == false) lastRowSize--; } /** * 見積品目データを取得して、インスタンス変数にセットします。 */ private void bindQuoteLineData(){ this.maxPageNumber = 0; String nowId = targetObj.Id; Integer rowNum = 1; Map itemsNum = new Map(); Integer repeatCount = null; String nowName = null, nowRightAsstModelNo = null; List nameStringArray = null; // String nowCompany = null; List companyStringArray = null; boolean hasEnglish = false; QuoteLineItem work = null; QuoteLineItem[] itemsOrg = [SELECT id, Description, Asset_Model_No__c, Name__c, UnitPrice__c, Quantity, TotalPrice__c, Item_Order__c, PricebookEntry.Product2.SFDA_Approbation_No__c, PricebookEntry.Product2.ProduceCompany__c, PricebookEntry.Product2.ProduceCompanySummary__c, //生产企业 WLIG-BZ699Z 精琢技术 wql 2021/03/19 start 如果需要传注册证再打开 //PricebookEntry.Product2.SFDA_Approbated_Status__c, //生产企业 WLIG-BZ699Z 精琢技术 wql 2021/03/19 end PricebookEntry.Product2.ProduceCompany_F__c, PricebookEntry.Product2.SalesPackagingUnit_Chinese__c, PricebookEntry.Product2.Packing_list_manual__c, PricebookEntry.Product2.SFDA_Status__c // LHJ 多年保修 Start , GuaranteePeriod__c ,PricebookEntry.Product2.GuranteeType__c,lastestGuaranteePeriod__c // LHJ 多年保修 End //不可取消多年保 增加检索不可取消多年保 和 市场保修期(年) 精琢技术 wql 2020/09/02 start ,PricebookEntry.Product2.CanNotCancelledGurantee__c,PricebookEntry.Product2.Entend_gurantee_period_MD__c //不可取消多年保 增加检索不可取消多年保 和 市场保修期(年) 精琢技术 wql 2020/09/02 end // Gzw CHAN-BGU53N Start 10/8前Decided的报价单,打印合同配置单时,显示 服务多年保的年限,其他都默认空 , Quote.Opportunity.DecideQuoteDate__c, Quote.Opportunity.Estimation_Decision__c // Gzw 多年保修 End //lt 20220223 CHAN-CBW9FX 特殊交货期影响的对应 start ,DeliveryDate__c //lt 20220223 CHAN-CBW9FX 特殊交货期影响的对应 end FROM QuoteLineItem WHERE QuoteId = :nowId ORDER BY Item_Order__c ASC]; QuoteLineItem[] items = new List(); for ( Integer i = 0; i < itemsOrg.size(); i++) { // 2018/10/11 CHAN-B5F35C 内贸时不显示 注册证号/备案凭证编号start if('内貿'.equals(this.targetObj.Opportunity.Trade__c)){ itemsOrg[i].PricebookEntry.Product2.SFDA_Approbation_No__c = null; } // 2018/10/11 CHAN-B5F35C end nowName = itemsOrg[i].Name__c == null ? '' : itemsOrg[i].Name__c; // Gzw CHAN-BGU53N Start 10/8前Decided的报价单,打印合同配置单时,显示 服务多年保的年限,其他都默认空 Boolean oldDate = false; //if (itemsOrg[i].Quote.Opportunity.DecideQuoteDate__c == null || itemsOrg[i].Quote.Opportunity.DecideQuoteDate__c < Date.valueOf(Label.GuaranteeWin)) { if (itemsOrg[i].Quote.Opportunity.Estimation_Decision__c ==true && (itemsOrg[i].Quote.Opportunity.DecideQuoteDate__c == null || itemsOrg[i].Quote.Opportunity.DecideQuoteDate__c < Date.valueOf(Label.GuaranteeWin))) { oldDate = true; } else { oldDate = false; } //外贸多年保修 精琢技术 wql 2021/03/23 start //上线前decide的询价标识 Boolean oldDecideDateUSD = false; //已经decide 并且在上线前decide //itemsOrg[i].Quote.Opportunity.DecideQuoteDate__c== null || wql 没有这一段逻辑 这一段属于还未decide不影响 if((itemsOrg[i].Quote.Opportunity.DecideQuoteDate__c!= null &&itemsOrg[i].Quote.Opportunity.DecideQuoteDate__c < Date.valueOf(Label.GuaranteeUSD)&&'外貿'.equals(this.targetObj.Opportunity.Trade__c))){ oldDecideDateUSD = true; }else{ oldDecideDateUSD = false; } //外贸多年保修 精琢技术 wql 2021/03/23 end // CHAN-BGU53N End //CHAN-B368WS 当产品编号为:N/A时,打印报价单/合同配置单/系统合同配置单时,打印的产品型号处空白(现在显示产品CODE) // LHJ 多年保修 Start if (!oldDate && itemsOrg[i].PricebookEntry.Product2.GuranteeType__c == null) { itemsOrg[i].GuaranteePeriod__c = null; } // LHJ 多年保修 End // Gzw CHAN-BGU53N Start if (oldDate && itemsOrg[i].PricebookEntry.Product2.GuranteeType__c == '服务') { itemsOrg[i].GuaranteePeriod__c = itemsOrg[i].lastestGuaranteePeriod__c; } //外贸多年保修 4.1 切换 start // 20211230 外贸和内贸保持一致 LHJ Start // if('外貿'.equals(this.targetObj.Opportunity.Trade__c)){ // if(oldDecideDateUSD){ // itemsOrg[i].GuaranteePeriod__c = null; // }else{ // itemsOrg[i].GuaranteePeriod__c = itemsOrg[i].lastestGuaranteePeriod__c; // } // } // 20211230 外贸和内贸保持一致 LHJ End //外贸多年保修 4.1 切换 end //不可取消多年保 增加检索不可取消多年保 和 市场保修期(年) 精琢技术 wql 2020/09/02 start //因为市场保修期(年) 是一个选项列表字段 所以需要转一下 因为就4个值所以直接匹配就行 // if(itemsOrg[i].PricebookEntry.Product2.CanNotCancelledGurantee__c){ // if(itemsOrg[i].PricebookEntry.Product2.Entend_gurantee_period_MD__c !=null){ // if(itemsOrg[i].PricebookEntry.Product2.Entend_gurantee_period_MD__c.equals('两年')){ // itemsOrg[i].GuaranteePeriod__c = 2; // }else if(itemsOrg[i].PricebookEntry.Product2.Entend_gurantee_period_MD__c.equals('三年')){ // itemsOrg[i].GuaranteePeriod__c = 3; // }else if(itemsOrg[i].PricebookEntry.Product2.Entend_gurantee_period_MD__c.equals('四年')){ // itemsOrg[i].GuaranteePeriod__c = 4; // }else if(itemsOrg[i].PricebookEntry.Product2.Entend_gurantee_period_MD__c.equals('五年')){ // itemsOrg[i].GuaranteePeriod__c = 5; // } // } // } //不可取消多年保 增加检索不可取消多年保 和 市场保修期(年) 精琢技术 wql 2020/09/02 end // Gzw CHAN-BGU53N end if(itemsOrg[i].Asset_Model_No__c == 'N/A'){ nowRightAsstModelNo = ''; }else if( nowName.indexOf( ':') >= 0) { nowRightAsstModelNo = nowName.subString( 0, nowName.indexOf( ':')); nowName = nowName.subString( nowName.indexOf( ':')+1); } else if( nowName.indexOf( ':') >= 0) { nowRightAsstModelNo = nowName.subString( 0, nowName.indexOf( ':')); nowName = nowName.subString( nowName.indexOf( ':')+1); } else { nowRightAsstModelNo = ''; } //nameStringArray = new List(); Integer repeatCount1 = (nowName.length() / nameMax) + ( Math.mod( nowName.length(), nameMax) > 0 ? 1 : 0); String nowCompany = null; //companyStringArray = new List(); ////生产企业 WLIG-BZ699Z 精琢技术 wql 2021/03/19 start 注释原代码 //nowCompany = itemsOrg[i].PricebookEntry.Product2.ProduceCompany_F__c; //CHAN-C4X63A 【委托】NFM204字段“生产企业地址”优化 XHL 20210716 Start //if(itemsOrg[i].PricebookEntry.Product2.ProduceCompany__c !=null){ // nowCompany = getProduceCompanyName(itemsOrg[i].PricebookEntry.Product2.ProduceCompany__c); //} if(itemsOrg[i].PricebookEntry.Product2.ProduceCompanySummary__c !=null){ nowCompany = getProduceCompanyName(itemsOrg[i].PricebookEntry.Product2.ProduceCompanySummary__c); } //CHAN-C4X63A 【委托】NFM204字段“生产企业地址”优化 XHL 20210716 End // //如果需要传注册证状态的话 // if(itemsOrg[i].PricebookEntry.Product2.ProduceCompany__c !=null&&itemsOrg[i].PricebookEntry.Product2.SFDA_Approbated_Status__c != null){ // nowCompany = getProduceCompanyName(itemsOrg[i].PricebookEntry.Product2.ProduceCompany__c,itemsOrg[i].PricebookEntry.Product2.SFDA_Approbated_Status__c); // } ////生产企业 WLIG-BZ699Z 精琢技术 wql 2021/03/19 end if (nowCompany == null) nowCompany = ''; hasEnglish = Pattern.matches('.*[a-zA-Z]+.*', nowCompany); Integer companyMax = hasEnglish ? 14 : 10; Integer repeatCount2 = (nowCompany.length() / companyMax) + ( Math.mod( nowCompany.length(), companyMax) > 0 ? 1 : 0); String descri = itemsOrg[i].Description == null ? '' : itemsOrg[i].Description; Integer repeetCount3 = (descri.length() / 10) + (Math.mod(descri.length(), 10) > 0 ? 1 : 0); repeatCount = repeatCount1 >= repeatCount2 ? (repeatCount1 >= repeetCount3 ? repeatCount1 : repeetCount3) : (repeatCount2 >= repeetCount3 ? repeatCount2 : repeetCount3); /* nameStringArray.add(nowName); companyStringArray.add(nowCompany);*/ work = itemsOrg[i]; work.NameForPrintDelimiter__c = ':'; work.Asset_Model_No_forPrint__c = nowRightAsstModelNo; work.NameForPrint__c = nowName; work.Description = nowCompany.trim(); items.add( work); //合同换行逻辑修改 /*for ( Integer j = 0; j < repeatCount; j++) { if (( j + 1) == repeatCount1) { nameStringArray.add( nowName.substring( j * nameMax)); } else if ((j + 1) > repeatCount1) { nameStringArray.add(''); } else { nameStringArray.add( nowName.substring( j * nameMax, (j+1) * nameMax)); } if (( j + 1) == repeatCount2) { companyStringArray.add( nowCompany.substring( j * companyMax)); } else if ((j + 1) > repeatCount2) { companyStringArray.add(''); } else { companyStringArray.add( nowCompany.substring( j * companyMax, (j+1) * companyMax)); } }*/ /*for ( Integer k = 0; k < repeatCount; k++) { if ( k == 0) { rowNum = 1; } else { rowNum++; }*/ //} itemsNum.put(itemsOrg[i].id, repeatCount); } printRecords = new List(); QuoteLineItemBean[] pageItems = new QuoteLineItemBean[]{}; Integer counter = 0; for ( QuoteLineItem c : items) { if ( counter < rowSize) { pageItems.add(new QuoteLineItemBean(c)); counter+= itemsNum.get(c.id); } if ( counter >= rowSize) { counter = 0; printRecords.add( pageItems); pageItems = new QuoteLineItemBean[]{}; this.maxPageNumber += 1; } } if ( !pageItems.isEmpty()) { printRecords.add( pageItems); this.maxPageNumber += 1; } if ( printRecords.size() > 0) { List lastList = printRecords[printRecords.size()-1]; system.debug('=====lastList:' + lastList.size()); system.debug('=====lastRowSize:' + lastRowSize); if ( lastList.size() > lastRowSize) { printRecords.add( new List()); this.maxPageNumber += 1; } } this.params.tradingPrice = params.totalPrice - params.discountAmount; } //获取办事处地址 private void getShipmentaddress(){ String province = this.targetObj.Opportunity.SAP_Province__c; //20230323 lt DB202303088261 两票制 start String province1 = this.targetObj.Opportunity.SAP_Province__c; if(province == 'OSH-安徽省'){ province = '安徽省'; } //20230323 lt DB202303088261 两票制 end List shipmentAddresses = [SELECT id, Address__c, Post_Code__c FROM Shipment_address__c WHERE Name=:province]; // 見積を取得できない場合 if ( shipmentAddresses.size() != 1) { return; } this.shipmentAddress = shipmentAddresses[0]; //20230323 lt DB202303088261 两票制 start if(province1 == 'OSH-安徽省'){ this.params.addressName1 = ' '; if(addressNameApiMap.get(province1) != null){ this.params.addressName = addressNameApiMap.get(province1); }else{ this.params.addressName = ' '; } }else //20230323 lt DB202303088261 两票制 end if(addressNameApiMap.get(province) != null){ this.params.addressName = addressNameApiMap.get(province); this.params.addressName1 = addressNameApiMap.get(province); //20230323 lt DB202303088261 两票制 add }else{ this.params.addressName = ' '; this.params.addressName1 = ' '; //20230323 lt DB202303088261 两票制 add } this.params.address = this.shipmentAddress.Address__c; this.params.postCode = this.shipmentAddress.Post_Code__c; } //生产企业 WLIG-BZ699Z 精琢技术 wql 2021/03/19 start //产品主数据生产企业 获取企业名称 (生产企业) private String getProduceCompanyName(String produceCompany){ //获取企业名称 (生产企业,注册证状态) //getProduceCompanyName(String produceCompany,String sfdaApprobatedStatus) //取前一部分 eg: 生产企业名称 : //String firstHalf = ''; //①统一中英文符号 找不到就返回原数据 String tempProduceCompany = produceCompany.replace(';', ';'); tempProduceCompany = tempProduceCompany.replace(':', ':'); //②先截取第一个分号前的数据 if(tempProduceCompany.indexOf(';')>0){ tempProduceCompany = tempProduceCompany.substring(0, tempProduceCompany.indexOf(';')); } //③截取第一个分号前 冒号后 分号前的数据 if(tempProduceCompany.indexOf(':') > 0){ //如果需要传入注册证状态的话 再拼接前一部分 //firstHalf = tempProduceCompany.substring(0, tempProduceCompany.indexOf(':')+1); tempProduceCompany = tempProduceCompany.substring(tempProduceCompany.indexOf(':')+1, tempProduceCompany.length()); } //④正则 只取出中文 不包括 全角符号 # % 不包括英文名 //[\u4E00-\u9FA5\\s]+ 多个汉字,包括空格 //[\u4E00-\u9FA5]+ 多个汉字,不包括空格 //[\u4E00-\u9FA5] 一个汉字 ///u0800-/u4e00 日文 //输出中日文 Pattern p = Pattern.compile('[\u0800-\u9fa5()()]{2,}'); Matcher pm = p.matcher(tempProduceCompany); if( pm.find() ){ system.debug('123'); tempProduceCompany = pm.group(0); } //如果注册证等于不要 拼接前一部分 // if(sfdaApprobatedStatus == '不要'){ // //如果前半部分不为空 则拼接上前半部分 // if(firstHalf!= ''){ // tempProduceCompany = firstHalf +tempProduceCompany; // } // } return tempProduceCompany; } //生产企业 WLIG-BZ699Z 精琢技术 wql 2021/03/19 end }