集团主数据在建项目数据分析
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static BLL.UnitHazardRegisterService;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
@@ -38,6 +39,46 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主表ID驳回所有明细
|
||||
/// </summary>
|
||||
/// <param name="registerId">主表ID</param>
|
||||
public static void RejectItemsByRegisterId(string registerId)
|
||||
{
|
||||
var items = (from x in Funs.DB.Supervise_UnitHazardRegisterItem
|
||||
where x.UnitHazardRegisterId == registerId && x.CompleteStatus == 1
|
||||
select x).ToList();
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.CompleteStatus = 0;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ItemID驳回明细整改
|
||||
/// </summary>
|
||||
/// <param name="ItemId">主表ID</param>
|
||||
public static void RejectItemByRegisterItemId(string ItemId)
|
||||
{
|
||||
var item = (from x in Funs.DB.Supervise_UnitHazardRegisterItem
|
||||
where x.UnitHazardRegisterItemId == ItemId && x.CompleteStatus == 1
|
||||
select x).FirstOrDefault();
|
||||
if (item != null)
|
||||
{
|
||||
item.CompleteStatus = 0;
|
||||
Funs.DB.SubmitChanges();
|
||||
var obj = (from x in Funs.DB.Supervise_UnitHazardRegister
|
||||
where x.UnitHazardRegisterId == item.UnitHazardRegisterId && x.States == (int)StateInt.已闭环
|
||||
select x).FirstOrDefault();
|
||||
if (obj != null)
|
||||
{
|
||||
obj.States = (int)StateInt.部分整改;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除明细记录
|
||||
/// </summary>
|
||||
@@ -214,10 +255,10 @@ namespace BLL
|
||||
ProjectId = r.ProjectId,
|
||||
CheckUnitName = u.UnitName,
|
||||
States = r.States,
|
||||
ProblemStatesName = i.CompleteStatus==1 ? "已整改":"未整改",
|
||||
ProblemStatesName = i.CompleteStatus == 1 ? "已整改" : "未整改",
|
||||
ProblemStates = i.CompleteStatus,
|
||||
InsResponsibleUserId = r.InsResponsibleUserId,
|
||||
InsResponsibleUserName= user.UserName
|
||||
InsResponsibleUserName = user.UserName
|
||||
};
|
||||
|
||||
// 应用检查大类过滤
|
||||
@@ -281,17 +322,24 @@ namespace BLL
|
||||
var thisUnit = BLL.CommonService.GetIsThisUnit();
|
||||
if (thisUnit.UnitId != input.UnitId)
|
||||
{
|
||||
// 先获取用户有权限的项目ID列表
|
||||
var projectIds = (from p in Funs.DB.Base_Project
|
||||
where p.UnitId == input.UnitId
|
||||
select p.ProjectId).ToList();
|
||||
//// 先获取用户有权限的项目ID列表
|
||||
//var projectIds = (from p in Funs.DB.Base_Project
|
||||
// where p.UnitId == input.UnitId
|
||||
// select p.ProjectId).ToList();
|
||||
|
||||
//// 过滤查询结果
|
||||
//query = query.Where(x => Funs.DB.Supervise_UnitHazardRegister
|
||||
// .Any(r => Funs.DB.Supervise_UnitHazardRegisterItem
|
||||
// .Any(i => i.UnitHazardRegisterItemId == x.UnitHazardRegisterItemId &&
|
||||
// i.UnitHazardRegisterId == r.UnitHazardRegisterId &&
|
||||
// projectIds.Contains(r.ProjectId))));
|
||||
|
||||
// 过滤查询结果
|
||||
query = query.Where(x => Funs.DB.Supervise_UnitHazardRegister
|
||||
.Any(r => Funs.DB.Supervise_UnitHazardRegisterItem
|
||||
.Any(i => i.UnitHazardRegisterItemId == x.UnitHazardRegisterItemId &&
|
||||
i.UnitHazardRegisterId == r.UnitHazardRegisterId &&
|
||||
projectIds.Contains(r.ProjectId))));
|
||||
input.UnitId == r.CheckUnitId)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace BLL
|
||||
|
||||
public enum StateInt : int
|
||||
{
|
||||
待提交 = 0,
|
||||
待整改= 1,
|
||||
部分整改 = 2,
|
||||
已闭环 = 3,
|
||||
待提交 = 0,
|
||||
待整改 = 1,
|
||||
部分整改 = 2,
|
||||
已闭环 = 3,
|
||||
}
|
||||
|
||||
#endregion Enums
|
||||
@@ -51,6 +51,7 @@ namespace BLL
|
||||
CheckDate = register.CheckDate,
|
||||
CheckMainType = register.CheckMainType,
|
||||
CheckType = register.CheckType,
|
||||
InspectionUnit = register.InspectionUnit,
|
||||
ProjectId = register.ProjectId,
|
||||
CheckUnitId = register.CheckUnitId,
|
||||
CheckTeam = register.CheckTeam,
|
||||
@@ -59,7 +60,7 @@ namespace BLL
|
||||
InsResponsibleUserId = register.InsResponsibleUserId,
|
||||
EvaluationResult = register.EvaluationResult,
|
||||
AttachUrl = register.AttachUrl,
|
||||
States = register.States??0,
|
||||
States = register.States ?? 0,
|
||||
CompileMan = register.CompileMan,
|
||||
CreateDate = DateTime.Now
|
||||
};
|
||||
@@ -102,6 +103,22 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 驳回企业级检查记录
|
||||
/// </summary>
|
||||
/// <param name="registerId">检查记录ID</param>
|
||||
public static void RejectUnitHazardRegisterById(string registerId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var register = db.Supervise_UnitHazardRegister.FirstOrDefault(e => e.UnitHazardRegisterId == registerId);
|
||||
if (register != null)
|
||||
{
|
||||
register.States = (int)StateInt.待整改;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据项目和时间段获取检查数量
|
||||
@@ -118,8 +135,8 @@ namespace BLL
|
||||
}
|
||||
public static int GetCount(string checkMainType)
|
||||
{
|
||||
return (from x in Funs.DB.Supervise_UnitHazardRegister
|
||||
where x.CheckMainType ==checkMainType
|
||||
return (from x in Funs.DB.Supervise_UnitHazardRegister
|
||||
where x.CheckMainType == checkMainType
|
||||
select x.UnitHazardRegisterId).Count();
|
||||
}
|
||||
/// <summary>
|
||||
@@ -143,11 +160,27 @@ namespace BLL
|
||||
if (register == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 只有"待提交"状态可以删除,其他状态不能删除
|
||||
return register.States <= (int)StateInt.待提交;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否可以驳回检查记录整改结果
|
||||
/// </summary>
|
||||
/// <param name="registerId">检查记录ID</param>
|
||||
/// <returns>true=可以驳回,false=不能驳回</returns>
|
||||
public static bool CanRejectRegister(string registerId)
|
||||
{
|
||||
var register = GetUnitHazardRegisterById(registerId);
|
||||
if (register == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// 只有"已闭环"和"部分整改"状态可以撤回,其他状态不能撤回
|
||||
return register.States == (int)StateInt.已闭环 || register.States == (int)StateInt.部分整改;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取企业级检查列表(使用input对象,返回总数)
|
||||
/// </summary>
|
||||
@@ -171,6 +204,9 @@ namespace BLL
|
||||
on new { MainType = x.CheckMainType, TypeCode = x.CheckType }
|
||||
equals new { MainType = ct.CheckMainType, TypeCode = ct.CheckTypeCode } into ctGroup
|
||||
from ct in ctGroup.DefaultIfEmpty()
|
||||
join inu in db.Base_Unit
|
||||
on x.InspectionUnit equals inu.UnitId into inuGroup
|
||||
from inu in inuGroup.DefaultIfEmpty()
|
||||
join u in db.Base_Unit
|
||||
on x.CheckUnitId equals u.UnitId into uGroup
|
||||
from u in uGroup.DefaultIfEmpty()
|
||||
@@ -185,7 +221,9 @@ namespace BLL
|
||||
CheckMainTypeName = x.CheckMainType == "0" ? "安全" : "质量",
|
||||
CheckType = x.CheckType,
|
||||
CheckTypeName = ct.CheckTypeName,
|
||||
InspectionUnitName = inu.UnitName,
|
||||
CheckObjectText = p.ProjectName,
|
||||
CheckUnitId = x.CheckUnitId,
|
||||
CheckUnitName = u.UnitName,
|
||||
CheckTeam = x.CheckTeam,
|
||||
EvaluationResult = x.EvaluationResult,
|
||||
@@ -219,6 +257,10 @@ namespace BLL
|
||||
{
|
||||
query = query.Where(x => x.ProjectId != null && x.ProjectId == input.ProjectId);
|
||||
}
|
||||
if (input != null && !string.IsNullOrEmpty(input.CheckUnitId) && input.CheckUnitId != CommonService.GetThisUnitId())
|
||||
{
|
||||
query = query.Where(x => x.CheckUnitId != null && x.CheckUnitId == input.CheckUnitId);
|
||||
}
|
||||
|
||||
// 获取总数
|
||||
totalCount = query.Count();
|
||||
@@ -235,7 +277,7 @@ namespace BLL
|
||||
.Skip(pageIndex * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新企业级检查记录
|
||||
@@ -253,6 +295,7 @@ namespace BLL
|
||||
newRegister.CheckDate = register.CheckDate;
|
||||
newRegister.CheckMainType = register.CheckMainType;
|
||||
newRegister.CheckType = register.CheckType;
|
||||
newRegister.InspectionUnit = register.InspectionUnit;
|
||||
newRegister.ProjectId = register.ProjectId;
|
||||
newRegister.CheckUnitId = register.CheckUnitId;
|
||||
newRegister.CheckTeam = register.CheckTeam;
|
||||
|
||||
Reference in New Issue
Block a user