工序计划列表显示二开字段
【应用场景】
工序计划列表需要体现未汇报的工时数,根据标准工时进行计算,工时数是跟汇报选单数量计算相关,所以在列表加载的时候通过数据库查询进行计算得到工时,加载到界面上。
【实现步骤】
<1>编写列表插件,代码如下。
using Kingdee.BOS; using Kingdee.BOS.Core.List; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Util; using Kingdee.K3.Core.MFG.EntityHelper; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; namespace Kingdee.K3.MFG.SFC.Business.PlugIn.Bill { /// <summary> /// 工序计划_列表插件显示未完成工时 /// </summary> [Description("工序计划_列表插件显示未完成工时")] [HotUpdate] public class OperationPlanningList4GS : BaseControlList { /// <summary> /// 未完成工时字典 /// </summary> private Dictionary<long, decimal> dicWWCGS = new Dictionary<long, decimal>(); #region 用于标识FormatCellValue只加载一次的变量 /// <summary> /// 用于标识FormatCellValue只加载一次数据 /// </summary> private bool IsNeedLoadData = true; /// <summary> /// 当前页面第一条数据的临时分录id /// </summary> private long tempPageFirstDetailId = 0; /// <summary> /// 当前页的临时分录条数 /// </summary> private int tempPageCount = 0; /// <summary> /// 当前页面第一条数据的分录id /// </summary> private long CurrentPageFirstDetailId = 0; /// <summary> /// 当前页的分录条数 /// </summary> private int CurrentPageCount = 0; #endregion /// <summary> /// 翻页、切换过滤、刷新等都会触发该事件,此时IsNeedLoadData=true,方便formatcellvalue重新取数 /// </summary> /// <param name="e"></param> public override void OnLoad(EventArgs e) { base.OnLoad(e); IsNeedLoadData = true; } /// <summary> /// 此时IsNeedLoadData=true,方便翻页时formatcellvalue重新取数 /// </summary> public override void AfterGetData() { base.AfterGetData(); IsNeedLoadData = true; } /// <summary> /// 显示条数切换的时候,不会调用onload,所以此时根据CurrentPageFirstDetailId和CurrentPageCount的变化去触发重新取数 /// </summary> /// <param name="args"></param> public override void FormatCellValue(BOS.Core.List.PlugIn.Args.FormatCellValueArgs args) { base.FormatCellValue(args); if (!args.Header.Key.Equals("FQty_qtr")) { return; } DynamicObject tempDynamicObject = ((Kingdee.BOS.DynamicObjectDataRow)(args.DataRow)).DynamicObject; long detailId = 0; detailId = tempDynamicObject.GetDynamicObjectItemValue<long>("t2_FDETAILID"); if (IsNeedLoadData) { //数据量大时,this.ListView.CurrentPageRowsInfo.Count这个方法频繁访问有性能问题,所以要改成如下方式 tempPageCount = this.ListView.CurrentPageRowsInfo.Count; } if (tempPageCount > 0 && IsNeedLoadData) { string s = "0"; this.ListView.CurrentPageRowsInfo[0].FieldValues.TryGetValue("FSubEntity", out s); tempPageFirstDetailId = Convert.ToInt64(s); } if (IsNeedLoadData || CurrentPageFirstDetailId != tempPageFirstDetailId || CurrentPageCount != tempPageCount ) { IsNeedLoadData = false; CurrentPageFirstDetailId = tempPageFirstDetailId; CurrentPageCount = tempPageCount; GetWIPQtyDic(); } switch (args.Header.FieldName) { case "FQTY_QTR": // if (this.dicWWCGS.Count > 0 && this.dicWWCGS.ContainsKey(detailId)) { args.FormateValue = Convert.ToString(this.dicWWCGS[detailId]); } break; } } /// <summary> /// 主菜单点击 /// </summary> /// <param name="e"></param> public override void BarItemClick(BOS.Core.DynamicForm.PlugIn.Args.BarItemClickEventArgs e) { base.BarItemClick(e); switch (e.BarItemKey) { case "tbRefresh": this.dicWWCGS.Clear(); break; } } /// <summary> /// 获取未完成工时字典 /// </summary> private void GetWIPQtyDic() { this.dicWWCGS.Clear(); List<ListSelectedRow> tempListView = this.ListView.CurrentPageRowsInfo.ToList(); List<long> detailIdLst = new List<long>(); foreach (var singleRow in tempListView) { var operObject = ((Kingdee.BOS.DynamicObjectDataRow)(singleRow.DataRow)).DynamicObject; detailIdLst.Add(Convert.ToInt64(operObject["t2_FDETAILID"])); } if (detailIdLst.IsEmpty()) { return; } detailIdLst = detailIdLst.Distinct().ToList(); string sql = string.Format(@" SELECT PD.FDETAILID, (PD.FOperQty-PDB.FReportQty)*PDD.FActivity1BaseQty AS FQty_qtr FROM T_SFC_OPERPLANNINGDETAIL PD INNER JOIN T_SFC_OPERPLANNINGDETAIL_B PDB ON PDB.FDETAILID = PD.FDETAILID INNER JOIN T_SFC_OPERPLANNINGDETAIL_C PDD ON PDD.FDETAILID = PD.FDETAILID WHERE EXISTS ({0} WHERE b.FID = PD.FDETAILID) ", StringUtils.GetSqlWithCardinality(detailIdLst.Count, "@DetailId", 1, false)); List<SqlParam> lstParam = new List<SqlParam>(); lstParam.Add(new SqlParam("@DetailId", KDDbType.udt_inttable, detailIdLst.ToArray())); using (var rd = DBServiceHelper.ExecuteReader(this.Context, sql, lstParam)) { while (rd.Read()) { this.dicWWCGS[Convert.ToInt64(rd["FDETAILID"])] = Convert.ToDecimal(rd["FQty_qtr"]); } } } } }
<2>拷贝插件组件到应用站点的WebSite\Bin目录下,重启IIS。
<3>BOSIDE扩展工序计划,添加二开字段(未完成工时字段),注册列表插件,保存元数据,开发完毕。
【功能验证】
<1>打开工序计划列表界面,过滤出二开字段。
【参考资料】
【二开案例.基础资料.联动查询(GetValue)】
https://vip.kingdee.com/article/127710528226504960
【金蝶云星空BOS二次开发案例演示】
https://vip.kingdee.com/article/94751030918525696
工序计划列表显示二开字段
【应用场景】工序计划列表需要体现未汇报的工时数,根据标准工时进行计算,工时数是跟汇报选单数量计算相关,所以在列表加载的时候通过数据...
点击下载文档
本文2024-09-23 03:29:17发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-159178.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章