分享泛微公司OA系統用於二次開發的sql腳本

 本單位用的oa系統就是泛微公司的oa協同辦公平臺,下面是我對他進行二次開發統計用到的寫數據庫腳本,只作開發參考使用,對於該系統的二次開發技術交流能夠加我q:2050372586sql

【儀表盤】格式sql編寫規則:
?    只支持select語句而且, Select的結果必須爲四列一行,且沒列值爲數值,其中
?    第一個值爲最小值
?    第二個值爲最大值
?    第三個值爲安全值
?    第四個值爲當前值
例如

Select 0,400,300,count(id) from hrmresource


【其餘圖形】格式sql編寫規則(餅狀、柱狀、折線等等)
    只支持select語句而且,select的結果必須爲兩列N(N>=1)行,且第二列必須爲數值,其中
    第一列值爲顯示項目(分類)名稱
    第二列值爲對應項目(分類)的值

例如

員工數機構

sql:
select top 10 (select subcompanyname from hrmsubcompany where id=subCompanyId1),count(id) As cids  from hrmresource group by subCompanyId1 order by cids desc
oracle:
select (select subcompanyname from hrmsubcompany where id=subCompanyId1),count(id) As cids  from hrmresource group by subCompanyId1 order by cids desc

合同金額前十機構
select top 10 (select subcompanyname from hrmsubcompany where id=subCompanyId1),floor(sum(price/10000)) As cids  from CRM_Contract where subCompanyId1 is not null group by subCompanyId1 order by cids desc

銷售機會金額前十機構
select top 10 (select subcompanyname from hrmsubcompany where id=subCompanyId),floor(sum(preyield/10000)) As cids  from CRM_SellChance group by subCompanyId order by cids desc

耗時前五長流程

sql:
select top 5 (select workflowname from workflow_base where id=workflowid),24*avg(convert(float,convert(datetime,lastoperatedate))-convert(float,convert(datetime,createdate))) cids from workflow_requestbase where workflowid>0 and workflowid!=5 group by workflowid order by cids desc

oracle:
select (select workflowname from workflow_base where id=workflowid),avg(nvl(to_date(lastoperatedate,'yyyy-mm-dd'),to_date(to_char(sysdate,'YYYY-MM-DD'),'yyyy-mm-dd'))-
to_date(createdate,'yyyy-mm-dd')) as cids from workflow_requestbase where workflowid>0 and workflowid!=5 and rownum<=5 group by workflowid order by cids desc

 銷售機會前十機構
 select top 10 (select subcompanyname from hrmsubcompany where id=subCompanyId),count(id) As cids  from CRM_SellChance group by subCompanyId order by cids desc

 項目統計前十機構

 select top 10 (select subcompanyname from hrmsubcompany where id=hrmdepartment.subcompanyid1),count(*)  as cid from Prj_ProjectInfo ,hrmdepartment where Prj_ProjectInfo.department=hrmdepartment.id group by hrmdepartment.subcompanyid1 order by cid desc

 人員性別統計

 select  case sex when '0' then '' else '' end, count(id)  as cid  from hrmresource group by sex

 典型客戶前十機構

 select top 10 (select provincename from hrmprovince where id=province) ,province,count(id) as cids from CRM_CustomerInfo  
where   status=4  and province>0 group by province  order by cids desc

建立文擋前十名統計
sql:
select top 10 (select lastname from hrmresource where id=doccreaterid) ,count(id) as cid from docdetail  group by doccreaterid  order by cid  desc
oracle:
select (select lastname from hrmresource where id=doccreaterid) ,count(id) as cid from docdetail  where rownum<=10  group by doccreaterid  order by cid  desc

待辦事宜數量前十機構統計

slq:
select top 10 (select subcompanyname from hrmsubcompany where id=subcompanyid1),count(requestid) as cid from workflow_currentoperator,hrmresource where hrmresource.id=workflow_currentoperator.userid and isremark in (0,1,8,9) and islasttimes=1 group by subcompanyid1 order by cid desc

oracle:
select (select subcompanyname from hrmsubcompany where id=subcompanyid1),count(requestid) as cid from workflow_currentoperator,hrmresource where hrmresource.id=workflow_currentoperator.userid and isremark in (0,1,8,9) and islasttimes=1 and rownum<=10 group by subcompanyid1 order by cid desc


學歷人員分佈

oracle:
select (select name from hrmeducationlevel where id=educationlevel) as 學歷,count(id) as 人數 from hrmresource where educationlevel != 0 group by educationlevel order by educationlevel desc




辦公地點人員分佈


oracle:
select (select locationname from hrmlocations where id=locationid) as 辦公地點,count(id) as 人數 from hrmresource group by locationid



年齡段人員分佈


oracle:
select 年齡段,age1 from( select count(id) age1,'40後' 年齡段 from hrmresource t1 where t1.birthday between '1940-01-01' and '1949-12-31' union select count(id) age1,'50後' 年齡段 from hrmresource t1 where t1.birthday between '1950-01-01' and '1959-12-31' union select count(id) age1,'60後' 年齡段 from hrmresource t1 where t1.birthday between '1960-01-01' and '1969-12-31' union select count(id) age1,'70後' 年齡段 from hrmresource t1 where t1.birthday between '1970-01-01' and '1979-12-31' union select count(id) age1,'80後' 年齡段 from hrmresource t1 where t1.birthday between '1980-01-01' and '1989-12-31' union select count(id) age1,'90後' 年齡段 from hrmresource t1 where t1.birthday between '1990-01-01' and '1999-12-31') order by 年齡段



職務人員分佈

sql:
select count(id) as 人數,'總裁' as 職務 from hrmresource where seclevel=80 
union all select count(id) as 人數,'中心領導' as 職務 from hrmresource where seclevel=70 or seclevel=60 
union all select count(id) as 人數,'經理' as 職務 from hrmresource where seclevel=40 
union all select count(id) as 人數,'副經理' as 職務 from hrmresource where seclevel=30 
union all select count(id) as 人數,'主管' as 職務 from hrmresource where seclevel=20 
union all select count(id) as 人數,'普通員工' as 職務 from hrmresource where seclevel=10 
union all select count(id) as 人數,'實習生' as 職務 from hrmresource where seclevel=5

oracle:
select 人數,職務 from( select count(id) as 人數,'總裁' as 職務 from hrmresource where seclevel=80 union all select count(id) as 人數,'中心領導' as 職務 from hrmresource where seclevel=70 or seclevel=60 union all select count(id) as 人數,'經理' as 職務 from hrmresource where seclevel=40 union all select count(id) as 人數,'副經理' as 職務 from hrmresource where seclevel=30 union all select count(id) as 人數,'主管' as 職務 from hrmresource where seclevel=20 
union all select count(id) as 人數,'普通員工' as 職務 from hrmresource where seclevel=10 union all select count(id) as 人數,'實習生' as 職務 from hrmresource where level=5 )





U8系統-主營業務收入期間圖
select case b.iperiod when '1' then '一月' when '2' then '二月' when '3' then '三月' when '4' then '四月' when '5' then '五月' when '6' then '六月' when '7' then '七月' when '8' then '八月' when '9' then '九月' when '10' then '十月' when '11' then '十一月' when '12' then '十二月' end,sum(b.md) as 金額 from fitemss00 as a,GL_accass as b,code as c where a.citemcode=b.citem_id and b.ccode=c.ccode and c.ccode like '6001%' group by iperiod



U8系統-主營業務成本期間圖
select case b.iperiod when '1' then '一月' when '2' then '二月' when '3' then '三月' when '4' then '四月' when '5' then '五月' when '6' then '六月' when '7' then '七月' when '8' then '八月' when '9' then '九月' when '10' then '十月' when '11' then '十一月' when '12' then '十二月' end,sum(b.md) as 金額 from fitemss00 as a,GL_accass as b,code as c where a.citemcode=b.citem_id and b.ccode=c.ccode and c.ccode like '6401%' group by iperiod




U8系統-主營業務利潤
select '成本' as 項,sum(md) as 金額 from fitemss00 as a,GL_accass as b,code as c where a.citemcode=b.citem_id and b.ccode=c.ccode and c.ccode like '6401%'
union all
select '收入' as 項,sum(mc) as 金額 from fitemss00 as a,GL_accass as b,code as c where a.citemcode=b.citem_id and b.ccode=c.ccode and c.ccode like '6001%'


U8系統-主營業務每個月利潤表
select '一月' as 月份,(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6001%' and iperiod='1')-(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6401%' and iperiod='1') as 金額 union all select '二月' as 月份,(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6001%' and iperiod='2')-(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6401%' and iperiod='2') as 金額 union all select '三月' as 月份,(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6001%' and iperiod='3')-(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6401%' and iperiod='3') as 金額 union all select '四月' as 月份,(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6001%' and iperiod='4')-(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6401%' and iperiod='4') as 金額 union all select '五月' as 月份,(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6001%' and iperiod='5')-(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6401%' and iperiod='5') as 金額 union all select '六月' as 月份,(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6001%' and iperiod='6')-(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6401%' and iperiod='6') as 金額 union all select '七月' as 月份,(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6001%' and iperiod='7')-(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6401%' and iperiod='7') as 金額 union all select '八月' as 月份,(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6001%' and iperiod='8')-(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6401%' and iperiod='8') as 金額 union all select '九月' as 月份,(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6001%' and iperiod='9')-(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6401%' and iperiod='9') as 金額 union all select '十月' as 月份,(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6001%' and iperiod='10')-(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6401%' and iperiod='10') as 金額 union all select '十一月' as 月份,(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6001%' and iperiod='11')-(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6401%' and iperiod='11') as 金額 union all select '十二月' as 月份,(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6001%' and iperiod='12')-(select sum(b.md) from GL_accass as b,code as c where b.ccode=c.ccode and c.ccode like '6401%' and iperiod='12') as 金額


fitemss00       產品
code            科目
fitemss00class  產品分類表
GL_accass       資金錶


GL_CashTable    總帳現金流量數據表
GL_accvouch     憑證及明細帳
Code            會計科目檔案
Department      部門基本信息
Person          職員檔案
Customer        客戶檔案
CustomerClass   客戶分類檔案
Vendor          供應商檔案
VendorClass     供應商分類檔案
fitemss98       現金流量項目目錄
fitemss98class  現金流量分類目錄

序號數據庫

查詢語句安全

功能oracle

1spa

Select* from DocDetail where maincategory=17code

查看通知blog

2ip

SELECT * from HrmResourceci

查看我的信息資源

3

select * from workflow_requestbase

流程申請表

select * from workflow_requestbase where status='提醒'

查看會議提醒()

4

 

 

Select * from workflow_currentoperator where userid=606 and isremark =0  (其中userid是用戶信息表的帳號)

查看當前待辦流程

select * from workflow_requestbase WHERE requestid in ( Select requestid from workflow_currentoperator where userid=10 and isremark =0 )

 

5

Update workflow_currentoperator

 

6

select * from Meeting

查看會議

7

select * from MeetingRoom

會議室

8

SELECT a.name,b.lastname,c.lastname,d.name,a.begindate,a.begintime,a.enddate,

a.endtime, a.createdate,a.createtime,a.totalmember,a.description,a.requestid

FROM Meeting a

LEFT JOIN HrmResource b ON a.caller=b.id

LEFT JOIN HrmResource c ON a.contacter=c.id

LEFT JOIN MeetingRoom d ON a.address=d.id

where DateDiff(dd, begindate,getdate())<=14

ORDER BY begindate asc

14天之後的會議詳細查看

9

Where DateDiff(dd,a.createdate,getdate())=0

今天的全部數據

10

Where DateDiff(dd,a.createdate,getdate())=1

昨天

11

select * from Meeting where DateDiff(dd, begindate,getdate())<=14 ORDER BY begindate desc

14天內

12

select * from Meeting where DateDiff(mm, createdate,getdate())=0

本月申報

13

select * from Meeting where DateDiff(yy, createdate,getdate())=0

本年申報

14

HrmDepartment 人力資源部門表

HrmJobGroups  人力資源職務類型表                  

HrmJobTitles  人力資源崗位表        

 

15

select loginid as 工號,lastname as  姓名 from HrmResource  where  isnull(loginid,'')<>''

sql 查詢帳號不爲空的:

16

select * from workflow_billfield

select * from workflow_base  

select * from workflow_selectitem

 

一下三個表關聯起來能夠查詢到選擇項的對應流程

相關文章
相關標籤/搜索