无需写插件,生产订单执行明细表增加自定义字段原创
69人赞赏了该文章
714次浏览
编辑于2023年11月17日 10:51:38
需要用到账表的SQL脚本功能,我对这个功能的理解是,在插件内取到数据并建立临时表后,执行此处的SQL语句,重新渲染数据包。
直接上干货
1、扩展生产订单执行明细表过滤里把字段添加上去
2、扩展生产订单执行明细表,添加需要的字段,并将SQL脚本复制出来
3、备份系统自带的SQL脚本(一定要备份)
/*修改前请备份 1.SQL中的占位符请不要修改,程序会将其替换为对应的语句或表名({0}、{1}、{2}) {0}: 创建查询出来的数据的顺序号 {1}: 报表最终取数的表名 {2}: 业务数据临时表名,存储中间临时数据,其结构可参见oracle : TM_PRD_MOEXECUTESDRPT */ SELECT T.FORDERBY,T.FPRDUNITDIGIT,T.FFORMID,T.FMOBILLID,T.FMOENTRYID, T.FREQUESTORGID,T.FREQUESTORGNAME, T.FINSTOCKOWNERTYPEID,T.FINSTOCKOWNERTYPENAME,T.FINSTOCKOWNERID,T.FINSTOCKOWNERNAME, T.FMATERIALID,T.FMATERIALNUMBER,T.FMATERIALNAME,T.FMATERIALMODEL, T.FWORKSHOPID,T.FWORKSHOPNAME,T.FPRDUNITID,T.FPRDUNITNAME, T.FMOBILLTYPEID,T.FMOBILLTYPENAME,T.FMOBILLNO,T.FMOENTRYSEQ,T.FPRODUCTTYPEID,T.FPRODUCTTYPENAME, T.FAUXPROPID,T.FAUXPROP,T.FBOMID,T.FBOMNUMBER, T.FPLANSTARTDATE,T.FPLANFINISHDATE,T.FREQSRC,T.FCONVEYDATE,T.FSTARTDATE,T.FFINISHDATE, T.FSTATUSNAME,T.FCLOSETYPENAME, T.FPLANQTY,T.FFINISHQTY,T.FSTOCKINQUAQTY,T.FSTOCKINFAILQTY, T.FSTOCKINSCRAPQTY, T.FSTOCKINREMADEQTY, T.FPLANFINISHPERCENT,T.FQUAPERCENT,T.FPICKEDQTY, T.FRESTKQTY,T.FNOSTOCKINQTY, T.FPRDURNUM,T.FPRDURNOM,T.FMTONO,T.FREPORTQTY,T.FAPPINSPECTQTY,T.FINSPECTQTY,T2.FSALEORDERNO,T2.FSALEORDERENTRYSEQ /*可在这里加上自定义字段*/ , {0} INTO {1} FROM {2} T INNER JOIN T_PRD_MOENTRY T2 ON T.FMOENTRYID=T2.FENTRYID/*可关联{2}的表,关联自己要的表*/ WHERE 1 = 1
4、扩展原SQL语句
/*修改前请备份 1.SQL中的占位符请不要修改,程序会将其替换为对应的语句或表名({0}、{1}、{2}) {0}: 创建查询出来的数据的顺序号 {1}: 报表最终取数的表名 {2}: 业务数据临时表名,存储中间临时数据,其结构可参见oracle : TM_PRD_MOEXECUTESDRPT */ SELECT T.FORDERBY,T.FPRDUNITDIGIT,T.FFORMID,T.FMOBILLID,T.FMOENTRYID, T.FREQUESTORGID,T.FREQUESTORGNAME, T.FINSTOCKOWNERTYPEID,T.FINSTOCKOWNERTYPENAME,T.FINSTOCKOWNERID,T.FINSTOCKOWNERNAME, T.FMATERIALID,T.FMATERIALNUMBER,T.FMATERIALNAME,T.FMATERIALMODEL, T.FWORKSHOPID,T.FWORKSHOPNAME,T.FPRDUNITID,T.FPRDUNITNAME, T.FMOBILLTYPEID,T.FMOBILLTYPENAME,T.FMOBILLNO,T.FMOENTRYSEQ,T.FPRODUCTTYPEID,T.FPRODUCTTYPENAME, T.FAUXPROPID,T.FAUXPROP,T.FBOMID,T.FBOMNUMBER, T.FPLANSTARTDATE,T.FPLANFINISHDATE,T.FREQSRC,T.FCONVEYDATE,T.FSTARTDATE,T.FFINISHDATE, T.FSTATUSNAME,T.FCLOSETYPENAME, T.FPLANQTY,T.FFINISHQTY,T.FSTOCKINQUAQTY,T.FSTOCKINFAILQTY, T.FSTOCKINSCRAPQTY, T.FSTOCKINREMADEQTY, T.FPLANFINISHPERCENT,T.FQUAPERCENT,T.FPICKEDQTY, T.FRESTKQTY,T.FNOSTOCKINQTY, T.FPRDURNUM,T.FPRDURNOM,T.FMTONO,T.FREPORTQTY,T.FAPPINSPECTQTY,T.FINSPECTQTY,T2.FSALEORDERNO,T2.FSALEORDERENTRYSEQ, 添加自定义字段,字段名与报表和过滤框添加的字段名一致 ISNULL(T3.F_HCH_QualifiedQty,0) as F_HCH_QualifiedQty, ISNULL(T3.F_HCH_SecondQty,0) as F_HCH_SecondQty, ISNULL(T3.F_HCH_ShuffsQty,0) as F_HCH_ShuffsQty, ISNULL(T3.F_HCH_OffcutQty,0) as F_HCH_OffcutQty, CONVERT(DECIMAL(10, 2), ISNULL(ISNULL(T3.F_HCH_QualifiedQty, 0) / T.FFINISHQTY * 100,0)) AS F_HCH_PassRate /*可在这里加上自定义字段*/ , {0} INTO {1} FROM {2} T INNER JOIN T_PRD_MOENTRY T2 ON T.FMOENTRYID=T2.FENTRYID 编写关联关系,拿到需要的数据 left join ( select t0.FMOBILLNO as F_HCH_FMOBILLNO, SUM(CASE F_HCH_COMBO WHEN 'A' THEN FREALQTY ELSE 0 END) AS F_HCH_QualifiedQty, SUM(CASE F_HCH_COMBO WHEN 'B' THEN FREALQTY ELSE 0 END) AS F_HCH_SecondQty, SUM(CASE F_HCH_COMBO WHEN 'C' THEN FREALQTY ELSE 0 END) AS F_HCH_ShuffsQty, SUM(CASE F_HCH_COMBO WHEN 'D' THEN FREALQTY ELSE 0 END) AS F_HCH_OffcutQty from T_PRD_INSTOCKENTRY as t0 left join t_BD_Stock as t1 on t0.FSTOCKID = t1.FSTOCKID left join HCH_t_WarehouseType as t2 on t1.F_HCH_WAREHOUSETYPE = t2.FID group by FMOBILLNO) as T3 on T.FMOBILLNO = T3.F_HCH_FMOBILLNO/*可关联{2}的表,关联自己要的表*/ WHERE 1 = 1
5、替换生产订单执行明细表SQL脚本,然后进行测试
搞定,撒花。
赞 69
69人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读