0118-gaofei

This commit is contained in:
gaofei 2022-01-18 09:48:03 +08:00
parent d02cd7ff74
commit 74f7cd5c17
3 changed files with 170 additions and 108 deletions

View File

@ -0,0 +1,48 @@
ALTER VIEW [dbo].[View_WBS_CostControlDetailStatistics]
AS
select InstallationId as Id,null as SupId ,InstallationCode as Code, InstallationName as Name,'Installation' as WBSType,null as OldCnProfessionId,null as OldUnitProjectCode,null as OldWbsSetCode,
ProjectId from dbo.Project_Installation where SuperInstallationId is null
Union
select InstallationId as Id,SuperInstallationId as SupId ,InstallationCode as Code, '['+InstallationCode+']'+InstallationName as Name,'Installation' as WBSType,null as OldCnProfessionId,null as OldUnitProjectCode,null as OldWbsSetCode,
ProjectId from dbo.Project_Installation where SuperInstallationId is not null
Union
select CnProfessionId as Id , InstallationId as SupId,CnProfessionCode as Code, CnProfessionName as Name,'CnProfession' as WBSType,OldId as OldCnProfessionId,null as OldUnitProjectCode,null as OldWbsSetCode,
ProjectId from dbo.WBS_CnProfession where IsApprove=1
Union all
select UnitProjectId as Id, isnull(CnProfessionId,InstallationId) as SupId,UnitProjectCode as Code,UnitProjectName as Name,'UnitProject' as WBSType,
(case when u.CnProfessionId is null then (select CnProfessionId from WBS_CnProfessionInit where CnProfessionName like (select '%'+substring(InstallationName,0,2)+'%' from Project_Installation where InstallationId=u.InstallationId)) else (select OldId from WBS_CnProfession c where c.CnProfessionId=u.CnProfessionId) end) as OldCnProfessionId,UnitProjectCode as OldUnitProjectCode,null as OldWbsSetCode,
ProjectId from dbo.Wbs_UnitProject u where IsApprove=1
Union all
select WbsSetId as id,UnitProjectId as SupId,WbsSetCode as Code, WbsSetName as Name,'WbsSet' as WBSType,
(case when w.CnProfessionId is null then (select CnProfessionId from WBS_CnProfessionInit where CnProfessionName like (select '%'+substring(InstallationName,0,2)+'%' from Project_Installation where InstallationId=w.InstallationId)) else (select OldId from WBS_CnProfession c where c.CnProfessionId=w.CnProfessionId) end) as OldCnProfessionId,(select UnitProjectCode from Wbs_UnitProject c where c.UnitProjectId=w.UnitProjectId) as OldUnitProjectCode,
WbsSetCode as OldWbsSetCode,
ProjectId from dbo.Wbs_WbsSet w where IsApprove=1 and SuperWbsSetId is null
Union all
select WbsSetId as id,SuperWbsSetId as SupId,WbsSetCode as Code, WbsSetName as Name,'WbsSet' as WBSType,
(case when w.CnProfessionId is null then (select CnProfessionId from WBS_CnProfessionInit where CnProfessionName like (select '%'+substring(InstallationName,0,2)+'%' from Project_Installation where InstallationId=w.InstallationId)) else (select OldId from WBS_CnProfession c where c.CnProfessionId=w.CnProfessionId) end) as OldCnProfessionId,(select UnitProjectCode from Wbs_UnitProject c where c.UnitProjectId=w.UnitProjectId) as OldUnitProjectCode,
(select WbsSetCode from Wbs_WbsSet ws where ws.WbsSetId=w.SuperWbsSetId) as OldWbsSetCode,
ProjectId from dbo.Wbs_WbsSet w where IsApprove=1 and SuperWbsSetId is not null
Union all
select c.CostControlId as id,c.WbsSetId as SupId,CostControlCode as Code,c.CostControlName as Name,'CostControl' as WBSType,
(case when ws.CnProfessionId is null then (select CnProfessionId from WBS_CnProfessionInit where CnProfessionName like (select '%'+substring(InstallationName,0,2)+'%' from Project_Installation where InstallationId=ws.InstallationId)) else (select OldId from WBS_CnProfession cn where cn.CnProfessionId=(select top 1 CnProfessionId from Wbs_WbsSet w where w.WbsSetId=c.WbsSetId)) end) as OldCnProfessionId,
(select UnitProjectCode from Wbs_UnitProject u where u.UnitProjectId=(select top 1 UnitProjectId from Wbs_WbsSet w where w.WbsSetId=c.WbsSetId)) as OldUnitProjectCode,
(select WbsSetCode from Wbs_WbsSet u where u.WbsSetId=(select top 1 w.SuperWbsSetId from Wbs_WbsSet w where w.WbsSetId=c.WbsSetId)) as OldWbsSetCode,
c.ProjectId from dbo.WBS_CostControl c
left join dbo.Wbs_WbsSet ws on ws.WbsSetId=c.WbsSetId
where c.IsSelected=1
GO

View File

@ -344,24 +344,35 @@ namespace BLL
/// <returns></returns>
public static List<string> GetWbsSetIdByInstallationIdAndCNCodeAndUnitProjectCodeAndWbsSetCode(string installationId, string cnCode, string unitProjectCode, string wbsSetCode)
{
List<string> ids = new List<string>();
Model.SGGLDB db = Funs.DB;
string inId = string.Empty;
Model.Project_Installation ins = db.Project_Installation.FirstOrDefault(x => x.InstallationId == installationId);
if (ins.IsEnd == true)
var childInss = from x in db.Project_Installation where x.SuperInstallationId == installationId select x;
if (childInss.Count() == 0)
{
inId = installationId;
}
else
{
inId = Project_InstallationService.GetEndInstallationId(installationId);
}
var cn = (from x in db.WBS_CnProfession where x.InstallationId == inId && x.OldId.ToString() == cnCode select x).FirstOrDefault();
if (cn != null)
{
var list = (from x in db.Wbs_WbsSet
join y in db.Wbs_UnitProject
on x.UnitProjectId equals y.UnitProjectId
where x.CnProfessionId == cn.CnProfessionId && y.UnitProjectCode == unitProjectCode && x.WbsSetCode == wbsSetCode
select x.WbsSetId).ToList();
return list;
ids.AddRange(list);
}
}
else
{
var childIns = from x in db.Project_Installation where x.SuperInstallationId == installationId select x;
foreach (var childIn in childIns)
{
ids.AddRange(GetWbsSetIdByInstallationIdAndCNCodeAndUnitProjectCodeAndWbsSetCode(childIn.InstallationId, cnCode, unitProjectCode, wbsSetCode));
}
}
return ids;
}
/// <summary>

View File

@ -372,8 +372,8 @@ namespace BLL
else
{
Model.WBS_CnProfessionInit cnInit = BLL.CnProfessionInitService.GetCnProfessionInitByCnProfessionId(cnProfessionId);
newList = (from x in newList where (x.WBSType == "Installation" && x.Name == cnInit.CnProfessionName) || (x.WBSType != "Installation" && x.OldCnProfessionId.ToString() == cnProfessionId) select x).ToList();
var cn = newList.FirstOrDefault(x => x.Name == cnInit.CnProfessionName);
newList = (from x in newList where (x.WBSType == "Installation" && x.Name.Contains(cnInit.CnProfessionName.Substring(0, 2))) || (x.WBSType != "Installation" && x.OldCnProfessionId.ToString() == cnProfessionId) select x).ToList();
var cn = newList.FirstOrDefault(x => x.Name.Contains(cnInit.CnProfessionName.Substring(0, 2)) && x.WBSType == "Installation");
parentRow = table.NewRow();
parentRow[0] = cn.Id;
parentRow[1] = "0";
@ -1169,6 +1169,8 @@ namespace BLL
newList = (from x in newList where x.WBSType != "Installation" && x.WBSType != "CnProfession" && x.WBSType != "UnitProject" && x.OldCnProfessionId.ToString() == cnProfessionId && x.OldUnitProjectCode == unitProjectCode && x.OldWbsSetCode == wbsSetCode select x).ToList();
var wb = newList.FirstOrDefault(x => x.WBSType == "WbsSet" && x.OldWbsSetCode == wbsSetCode);
parentRow = table.NewRow();
if (wb != null)
{
parentRow[0] = wb.Id;
parentRow[1] = "0";
parentRow[2] = wb.Name;
@ -1284,6 +1286,7 @@ namespace BLL
table.Rows.Add(parentRow);
}
}
}
#endregion
}
}