1.采购建议报表下推采购订单
This commit is contained in:
		
							parent
							
								
									e45ef4505f
								
							
						
					
					
						commit
						6bcecdcd09
					
				|  | @ -1,11 +1,15 @@ | |||
| package tqq9.lc123.cloud.app.plugin.form.pm; | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSONArray; | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import kd.bos.bill.AbstractBillPlugIn; | ||||
| import kd.bos.bill.BillShowParameter; | ||||
| import kd.bos.bill.OperationStatus; | ||||
| import kd.bos.coderule.api.CodeRuleInfo; | ||||
| import kd.bos.dataentity.entity.DynamicObject; | ||||
| import kd.bos.dataentity.entity.DynamicObjectCollection; | ||||
| import kd.bos.dataentity.utils.ObjectUtils; | ||||
| import kd.bos.dataentity.utils.StringUtils; | ||||
| import kd.bos.entity.datamodel.IDataModel; | ||||
| import kd.bos.entity.datamodel.ListSelectedRow; | ||||
| import kd.bos.entity.datamodel.ListSelectedRowCollection; | ||||
|  | @ -25,9 +29,12 @@ import kd.bos.logging.LogFactory; | |||
| import kd.bos.orm.query.QCP; | ||||
| import kd.bos.orm.query.QFilter; | ||||
| import kd.bos.servicehelper.BusinessDataServiceHelper; | ||||
| import kd.bos.servicehelper.coderule.CodeRuleServiceHelper; | ||||
| import kd.bos.servicehelper.user.UserServiceHelper; | ||||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Date; | ||||
| import java.util.EventObject; | ||||
| import java.util.List; | ||||
| 
 | ||||
|  | @ -37,6 +44,20 @@ import java.util.List; | |||
|  */ | ||||
| public class PurorderEntryIntroPaybillPlugin extends AbstractBillPlugIn implements HyperLinkClickListener { | ||||
|     private final static Log logger = LogFactory.getLog(PurorderEntryIntroPaybillPlugin.class); | ||||
|     private static DynamicObject BILLTYPE; | ||||
|     private static DynamicObject BIZTYPE; | ||||
|     private static DynamicObject LINETYPE; | ||||
| 
 | ||||
|     static { | ||||
|         //订单 | ||||
|         DynamicObject billtype = BusinessDataServiceHelper.loadSingle("bos_billtype", new QFilter[]{new QFilter("number", QCP.equals, "pm_PurOrderBill_STD_BT_S")}); | ||||
|         BILLTYPE = billtype; | ||||
| 
 | ||||
|         DynamicObject biztype = BusinessDataServiceHelper.loadSingle("bd_biztype", new QFilter[]{new QFilter("number", QCP.equals, "110")}); | ||||
|         BIZTYPE = biztype; | ||||
|         DynamicObject linetype = BusinessDataServiceHelper.loadSingle("bd_linetype", new QFilter[]{new QFilter("number", QCP.equals, "010")}); | ||||
|         LINETYPE = linetype; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void registerListener(EventObject e) { | ||||
|  | @ -94,7 +115,7 @@ public class PurorderEntryIntroPaybillPlugin extends AbstractBillPlugIn implemen | |||
|             int length = entryGrid.getSelectRows()[0];//获取点击分录序号从0开始 | ||||
|             DynamicObject pm_purorderbill = model.getDataEntity(true);//采购订单 | ||||
|             BigDecimal totalallamount = pm_purorderbill.getBigDecimal("totalallamount");//价税合计 | ||||
|             if (totalallamount.compareTo(BigDecimal.ZERO)<0) { | ||||
|             if (totalallamount.compareTo(BigDecimal.ZERO) < 0) { | ||||
|                 this.getView().showMessage("价税合计不能为空"); | ||||
|                 evt.setCancel(true); | ||||
|             } | ||||
|  | @ -155,8 +176,9 @@ public class PurorderEntryIntroPaybillPlugin extends AbstractBillPlugIn implemen | |||
|     } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 点击付款单字段跳转至付款单 | ||||
|      */ | ||||
|     @Override | ||||
|     public void hyperLinkClick(HyperLinkClickEvent hyperLinkClickEvent) { | ||||
|         int rowIndex = hyperLinkClickEvent.getRowIndex(); | ||||
|  | @ -185,9 +207,107 @@ public class PurorderEntryIntroPaybillPlugin extends AbstractBillPlugIn implemen | |||
|         view.showForm(lsp); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 点击下推付款申请单跳转至付款申请单 | ||||
|      */ | ||||
|     @Override | ||||
|     public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) { | ||||
|         super.afterDoOperation(afterDoOperationEventArgs); | ||||
|         OperationResult operationResult = afterDoOperationEventArgs.getOperationResult(); | ||||
|     public void afterCreateNewData(EventObject e) { | ||||
|         super.afterCreateNewData(e); | ||||
|         FormShowParameter formShowParameter = this.getView().getFormShowParameter(); | ||||
|         JSONObject tqq9_pursuggestrpt = (JSONObject) formShowParameter.getCustomParam("pm_purorderbill"); | ||||
|         if (tqq9_pursuggestrpt != null) { | ||||
|             IDataModel model = this.getModel(); | ||||
|             DynamicObjectCollection billentry = model.getDataEntity(true).getDynamicObjectCollection("billentry"); | ||||
|             billentry.clear(); | ||||
|             //采购建议报表 | ||||
|             JSONArray tqq9_pursuggestrptentry = tqq9_pursuggestrpt.getJSONArray("tqq9_pursuggestrptentry"); | ||||
| 
 | ||||
|             long currentUserId = UserServiceHelper.getCurrentUserId(); | ||||
|             DynamicObject user = BusinessDataServiceHelper.loadSingle("bos_user", new QFilter[]{new QFilter("id", QCP.equals, currentUserId)}); | ||||
|             DynamicObjectCollection entryentity = user.getDynamicObjectCollection("entryentity"); | ||||
|             DynamicObject dept = null;//部门 | ||||
|             for (DynamicObject dynamicObject : entryentity) { | ||||
|                 boolean ispartjob = dynamicObject.getBoolean("ispartjob"); | ||||
|                 if (!ispartjob) { | ||||
|                     dept = dynamicObject.getDynamicObject("dpt"); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             DynamicObject currency = BusinessDataServiceHelper.loadSingle("bd_currency", | ||||
|                     new QFilter[]{new QFilter("number", QCP.equals, "CNY")});//币别 | ||||
|             DynamicObject taxrate = BusinessDataServiceHelper.loadSingle("bd_taxrate", | ||||
|                     new QFilter[]{new QFilter("number", QCP.equals, "V13")});//税率 | ||||
|             Date date = new Date(); | ||||
|             DynamicObject org = null;//组织 | ||||
|             int i = 0; | ||||
|             for (Object dynamicObject : tqq9_pursuggestrptentry) { | ||||
|                 JSONObject entry = (JSONObject) dynamicObject; | ||||
|                 if (entry.getBoolean("tqq9_ischange")) { | ||||
|                     billentry.addNew(); | ||||
|                     if (i == 0) { | ||||
|                         JSONObject tqq9_org = entry.getJSONObject("tqq9_org"); | ||||
|                         org = BusinessDataServiceHelper.loadSingle(tqq9_org.getLong("id"), "bos_org");//组织 | ||||
|                         model.setValue("org", org);//申请组织 | ||||
|                         model.setValue("dept", dept);//申请部门 | ||||
|                         model.setValue("creator", user);//创建人 | ||||
|                         model.setValue("lastupdateuser", user);//修改人 | ||||
|                         model.setValue("currency", currency);//币别 | ||||
|                         model.setValue("lastupdatetime", date);//修改时间 | ||||
|                         model.setValue("billtype", BILLTYPE);//单据类型 | ||||
|                         model.setValue("biztype", BIZTYPE);//业务类型 | ||||
|                         model.setValue("biztime", date);//申请日期 | ||||
|                         model.setValue("billstatus", "A");//单据状态 | ||||
|                         model.setValue("closestatus", "A");//关闭状态 | ||||
|                         model.setValue("cancelstatus", "A");//作废状态 | ||||
|                         model.setValue("changestatus", "A");//变更状态 | ||||
|                         model.setValue("subversion", "1");//子版本号 | ||||
|                         model.setValue("version", "1");//版本号 | ||||
|                         model.setValue("tqq9_sfsyhf", "false");//是否使用货返 | ||||
|                         model.setValue("tqq9_hshfsysl", taxrate);//含税货返使用税率 | ||||
|                         model.setValue("tqq9_hshfsygs", "A");//含税货返使用归属 | ||||
|                         model.setValue("tqq9_sfsyxf", "false");//是否使用现返 | ||||
|                         model.setValue("tqq9_hsxfsysl", taxrate);//含税现返使用税率 | ||||
|                         model.setValue("tqq9_hsxfsygs", "A");//含税现返使用归属 | ||||
|                     } | ||||
|                     JSONObject material = entry.getJSONObject("tqq9_material");//物料 | ||||
|                     DynamicObject tqq9_material = BusinessDataServiceHelper.loadSingle(material.getLong("id"), "bd_material");//物料 | ||||
|                     DynamicObject materialpurchaseinfo = BusinessDataServiceHelper.loadSingle("bd_materialpurchaseinfo", new QFilter[]{new QFilter("masterid", QCP.equals, tqq9_material.getLong("id"))});//物料采购信息 | ||||
|                     BigDecimal tqq9_saledates = entry.getBigDecimal("tqq9_saledates"); | ||||
| //                    model.setValue("seq", i + 1);//分录号 | ||||
|                     model.setValue("material", materialpurchaseinfo, i);//物料 | ||||
|                     model.setValue("materialname", tqq9_material.getString("name"), i);//物料名称 | ||||
|                     model.setValue("unit", tqq9_material.getDynamicObject("baseunit"), i);//计量单位 | ||||
|                     model.setValue("baseunit", tqq9_material.getDynamicObject("baseunit"), i);//基本单位 | ||||
|                     model.setValue("tqq9_brand", tqq9_material.getDynamicObject("tqq9_brand"), i);//品牌 | ||||
|                     model.setValue("entrycreator", user, i);//创建人 | ||||
|                     model.setValue("rowclosestatus", "A", i);//行关闭状态 | ||||
|                     model.setValue("rowterminatestatus", "A", i);//行终止状态 | ||||
|                     model.setValue("entrychangetype", "B",i);//变更方式 | ||||
|                     model.setValue("entryrecorg", org, i);//收货组织 | ||||
|                     model.setValue("entryreqorg", org, i);//需求组织 | ||||
|                     model.setValue("entryreqdept", dept, i);//需求部门 | ||||
|                     model.setValue("entryrecdept", org, i);//收货部门 | ||||
|                     model.setValue("entrysettleorg", org, i);//结算组织 | ||||
|                     model.setValue("entrypayorg", org, i);//付款组织 | ||||
|                     model.setValue("deliverdate", date, i);//交货日期 | ||||
|                     model.setValue("linetype", LINETYPE, i);//行类型 | ||||
|                     model.setValue("entryrecdept", org, i);//收货部门 | ||||
|                     model.setValue("discounttype", "C", i);//折扣方式 | ||||
|                     model.setValue("tqq9_expectsaletime", tqq9_saledates, i);//预计销售时间(月) | ||||
|                     if (StringUtils.equals(org.getString("number"), "SHLC")) { | ||||
|                         model.setValue("tqq9_zgcgxj", tqq9_material.getBigDecimal("tqq9_maxprice_sh"), i);//最高采购限价 | ||||
|                         model.setValue("priceandtax", tqq9_material.getBigDecimal("tqq9_maxprice_sh"), i);//含税单价 | ||||
|                     } else if (StringUtils.equals(org.getString("number"), "BJLC")) { | ||||
|                         model.setValue("tqq9_zgcgxj", tqq9_material.getBigDecimal("tqq9_maxprice_bj"), i);//最高采购限价 | ||||
|                         model.setValue("priceandtax", tqq9_material.getBigDecimal("tqq9_maxprice_bj"), i);//含税单价 | ||||
|                     } else if (StringUtils.equals(org.getString("number"), "GZLC")) { | ||||
|                         model.setValue("tqq9_zgcgxj", tqq9_material.getBigDecimal("tqq9_maxprice_gz"), i);//最高采购限价 | ||||
|                         model.setValue("priceandtax", tqq9_material.getBigDecimal("tqq9_maxprice_gz"), i);//含税单价 | ||||
|                     } | ||||
|                     i++; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue