xingxingd32 发表于 2009-11-3 08:52:51

UAP版块,我是第一贴!

其实UAP很简单,它的功能类似于Excel,难就难在要会写存储过程,也就是SQL语句。SQL语句也不难,很简单的。
告诉大家一个秘决:SQL语句是装几个简单的语句组合起来就变成一个复杂而实用的存储过程了。
写SQL存储过程还要有一定思路及思维能力。多的不说了,发一个报表的SQL语句。大家去拆分吧。
思路:建立一张集订单数、实收数、生产数、入库数、发货数、现存数以及是否生产逾期的表。
1、订单数、实收数、生产数取系统(其中订单数为自定义,取自定义项cdefine22)   
2、建立视图xinhe_xxx01表汇总入库数量
3、建立视图xinhe_xxx02表汇总发货数量
4、建立视图xinhe_xxx04表取产成品入库的最前时间,因为有的单可能分几批入库
5、建立报表查询主语句
关于几个case语句的说明:
第一个CASE:是为了取得现存量,意思是如果发货数量为空,则入库数量不能加减乘除NULL,所以在这里用CASE来赋值那些发货数量为空的数据行为0。
第二个CASE:是为了取得完工日期,但有的订单还未生产,肯定是没有完工日期数值的,所以用CASE来将这些没有完工日期的行赋于当前的系统日期来于预发货日期作比较判断是否逾期。
第三个CASE:这里只是作为判断条件赋值用,如果满足条件则为‘否’,不满足则为‘逾期’,如果条件相等,则为‘定期完成’。
--新建视图XINHE_XXX01
create view XINHE_XXX01 as
SELECT csocode, iorderseq, SUM(iQuantity) AS rq
FROM dbo.RdRecords
WHERE (copdesc LIKE '%全检')
GROUP BY csocode, iorderseq
--新建视图XINHE_XXX02
create view XINHE_XXX02 as
SELECT csocode, iorderseq, SUM(iNQuantity) AS fh
FROM dbo.RdRecords
WHERE (copdesc IS NULL)
GROUP BY csocode, iorderseq
--建立视图xinhe_xxx03,取发货单列表中的最小日期(未使用)
create view xinhe_xxx03 as
select dispatchlists.cordercode,dispatchlists.iorderrowno,MIN(CONVERT(varchar(100), DispatchList.dcreatesystime, 23)) rtime from DispatchLists
left join dispatchlist on dispatchlists.dlid=dispatchlist.dlid
group by cordercode,iorderrowno
--建立视图xinhe_xxx04,取产成品入库单列表中的最小日期(销售进销存报表已用)
create view xinhe_xxx04 as
SELECT RdRecords.csocode, RdRecords.iorderseq, MIN(CONVERT(varchar(100), RdRecord.dnmaketime, 23)) rqtime,
SUM(dbo.RdRecords.iQuantity) rqsl
FROM RdRecords
LEFT OUTER JOIN RdRecord ON RdRecords.ID = RdRecord.ID
WHERE RdRecord.cBusType = '成品入库'
GROUP BY RdRecords.csocode, RdRecords.iorderseq
--进销存查询报表语句
select
      so_somain.dDate 制单日期,inventory.cInvDepCode 部门,so_sodetails.csocode 订单号,
      iRowNo 行号,Customer.cCusAbbName 客户简称,inventory.cinvcode 存货编码,inventory.cinvname 存货名称,
      inventory.cInvStd 规格型号,so_sodetails.cMemo 备注,so_sodetails.cdefine22 订单数量,so_sodetails.iQuantity 实收数量,
      mom_orderdetail.qty 生产数量,xinhe_xxx01.rq 入库数量,xinhe_xxx02.fh 发货数量,xinhe_xxx01.rq-(case when xinhe_xxx02.fh is null then 0 else xinhe_xxx02.fh end)现存数量,
      Convert(varchar(100),so_sodetails.dPreDate,23) 预发货日期,
case when xinhe_xxx04.rqtime is null then convert(char(10),getdate(),23)
else xinhe_xxx04.rqtime end完工日期,
case when (so_sodetails.dPreDate>xinhe_xxx04.rqtime) or so_sodetails.dPreDate>=convert(char(10),getdate(),23) then '否'
when so_sodetails.dPreDate=xinhe_xxx04.rqtime and xinhe_xxx01.rq is not null then '定期完成'
else '逾期' end 是否逾期
from so_sodetails
join so_somain on so_sodetails.csocode=so_somain.csocode
   join customer on so_somain.ccuscode=customer.ccuscode
    join inventory on so_sodetails.cinvcode=inventory.cinvcode
   left join mom_orderdetail on so_sodetails.csocode=mom_orderdetail.SoCode and so_sodetails.irowno=mom_orderdetail.SoSeq
      left join xinhe_xxx01 on so_sodetails.csocode=xinhe_xxx01.csocode and so_sodetails.irowno=xinhe_xxx01.iorderseq
       left join xinhe_xxx02 on so_sodetails.csocode=xinhe_xxx02.csocode and so_sodetails.irowno=xinhe_xxx02.iorderseq
      left join xinhe_xxx04 on so_sodetails.csocode=xinhe_xxx04.csocode and so_sodetails.irowno=xinhe_xxx04.iorderseq
group by so_somain.dDate,inventory.cInvDepCode,so_sodetails.csocode,
iRowNo,Customer.cCusAbbName,inventory.cinvcode ,inventory.cinvname,
inventory.cInvStd,so_sodetails.cMemo,so_sodetails.cdefine22,so_sodetails.iQuantity,
mom_orderdetail.qty,xinhe_xxx01.rq,xinhe_xxx02.fh,so_sodetails.dPreDate,xinhe_xxx04.rqtime

naojin 发表于 2009-11-3 09:35:02

楼上说的仅仅是UAP报表,UAP涵盖了从基础档案录入到工作流二次开发等不同的业务

hsufida 发表于 2009-11-3 09:49:28

好东西。留个脚印,收藏

xingxingd32 发表于 2009-11-3 11:17:44

回复 2# naojin

呵呵,表单开发,我没那么大本事.再说了我也才入门.

lspfjm 发表于 2009-11-29 12:22:38

UAP是个快捷开发单据和报表的实用工具,但是毕竟是在其他编程工具基础上开发出来的针对Ufida的开发工具,其还有好多不够灵活的地方

shanghaivincent 发表于 2010-5-14 15:52:15

有无UAP详细介绍的?

lostsjz 发表于 2011-3-22 11:20:39

顶下 无私的楼主

lrm521 发表于 2014-6-4 11:03:07

谢谢楼主的无私分享,我在学习uap报表开发,头脑中有点思路了
页: [1]
查看完整版本: UAP版块,我是第一贴!