1. 程式人生 > >根據funID,personID獲取最新規劃包項目相關信息

根據funID,personID獲取最新規劃包項目相關信息

dbo ppi ict pla all 定義 相關信息 最新 tinc


1.定義:根據funID,personID獲取最新規劃包項目相關信息(code projecttype(階段) Pname(code+name) projectID)

項目表
tbl_cfg_Project
規劃包表
tbl_cfg_ProjectPackageHistory
項目表規劃包映射表
tbl_cfg_PackageHistoryProjectMapping
計劃版本
tbl_plan_RollMap




USE
[ITMS] GO /****** Object: StoredProcedure [dbo].[usp_padmin_GetLimitingProject] Script Date: 2018/2/27 11:22:00 *****
*/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE proc [dbo].[usp_padmin_GetLimitingProject] @FuncID uniqueidentifier,@PersonID uniqueidentifier as if exists(select * from tbl_padmin_DataScope where realprojectid = 00000000-0000-0000-0000-000000000001 and FuncID = @FuncID and PersonID =
@PersonID) begin select a.code,a.projecttype,   +isnull(a.code,‘‘) + a.name PName, a.projectID into
#pro
--最新規劃包包含的所有項目的相關信息 code projecttype(階段) Pname(code+name) projectID
from tbl_cfg_Project a , (
                SELECT * FROM tbl_cfg_ProjectPackageHistory
                where RollMapID =
(SELECT top 1 RollMapID FROM tbl_plan_RollMap order by StartDate desc , Code desc --最新規劃包) ) b, tbl_cfg_PackageHistoryProjectMapping c where a.name is not null and b.PackageHistoryID = c.PackageHistoryID and c.ProjectID = a.ProjectID select * from ( ---獲取項目中的類型 select distinct ty.* from ( select null code,-1 projecttype,未配置項目階段 PName,newid() projectID union all select null code, id projecttype,name,newid() projectID from tblCommonDict where parentid = 58 ) ty join #pro on ty.projecttype = #pro.projecttype union all select * from #pro ) tbl order by projecttype, left(code,1),len(code),code,PName end else begin select a.code, a.projecttype,   +isnull(a.code,‘‘) + a.name PName, a.projectID into #pro1 from tbl_cfg_Project a join tbl_padmin_DataScope b on a.projectID = b.realprojectID join tbl_cfg_PackageHistoryProjectMapping c on c.ProjectID = a.ProjectID join ( SELECT * FROM tbl_cfg_ProjectPackageHistory where RollMapID = (SELECT top 1 RollMapID FROM tbl_plan_RollMap order by StartDate desc , Code desc) ) d on d.PackageHistoryID = c.PackageHistoryID where a.name is not null and b.FuncID = @FuncID and b.PersonID = @PersonID select * from ( ---獲取項目中的類型 select distinct ty.* from ( select null code,-1 projecttype,未配置項目階段 PName,newid() projectID union all select null code, id projecttype,name,newid() projectID from tblCommonDict where parentid = 58 ) ty join #pro1 on ty.projecttype = #pro1.projecttype union all select * from #pro1 ) tbl order by projecttype, left(code,1),len(code),code,PName end GO

2.使用:

CREATE TABLE #tmp(
code varchar(100),
projecttype varchar(100),
PName varchar(200),
ProjectID varchar(100)
)
INSERT INTO #tmp EXEC usp_padmin_GetLimitingProject ‘68093189-0dde-4ae2-b7ba-903ff77b66e6‘,‘E87B3AB0-6901-48C2-A30C-E643320BF275‘ --‘{1}‘,‘{2}‘

drop table #tmp

根據funID,personID獲取最新規劃包項目相關信息