集团主数据在建项目数据分析
This commit is contained in:
@@ -711,6 +711,7 @@
|
||||
<Compile Include="Person\Person_TrainingPlanService.cs" />
|
||||
<Compile Include="ProjectData\MainItemService.cs" />
|
||||
<Compile Include="ProjectData\ProjectData_CodeTemplateRuleService.cs" />
|
||||
<Compile Include="ProjectData\ProjectMasterDataAnalysisService.cs" />
|
||||
<Compile Include="ProjectData\ProjectMasterDataUsageService.cs" />
|
||||
<Compile Include="ProjectData\ProjectSateService.cs" />
|
||||
<Compile Include="ProjectData\ProjectService.cs" />
|
||||
|
||||
@@ -18,6 +18,22 @@ namespace BLL
|
||||
return Funs.DB.DCGL_Check_CheckRectify.FirstOrDefault(e => e.CheckRectifyId == checkRectifyId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主表ID撤回整改
|
||||
/// </summary>
|
||||
/// <param name="checkRectifyId">主表ID</param>
|
||||
public static void RevokeByRectifyId(string checkRectifyId)
|
||||
{
|
||||
var items = (from x in Funs.DB.DCGL_Check_CheckRectify
|
||||
where x.CheckRectifyId == checkRectifyId && x.HandleState == "3"
|
||||
select x).ToList();
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.HandleState = "2";
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加督查检查整改
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
|
||||
using Model;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 集团主数据在建项目数据分析
|
||||
/// </summary>
|
||||
public static class ProjectMasterDataAnalysisService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据主键获取分析数据
|
||||
/// </summary>
|
||||
/// <param name="useId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.Project_MasterDataAnalysis GetProjectMasterDataAnalysisById(string Id)
|
||||
{
|
||||
return Funs.DB.Project_MasterDataAnalysis.FirstOrDefault(e => e.Id == Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据CollCropCode获取分析数据【取最近一条】
|
||||
/// </summary>
|
||||
/// <param name="CollCropCode"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.Project_MasterDataAnalysis GetProjectMasterDataAnalysisByCollCropCode(string CollCropCode)
|
||||
{
|
||||
return Funs.DB.Project_MasterDataAnalysis.OrderByDescending(x => x.DataDate).FirstOrDefault(e => e.CollCropCode == CollCropCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分析数据【取最近一条】
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Model.Project_MasterDataAnalysis GetLastProjectMasterDataAnalysis()
|
||||
{
|
||||
return Funs.DB.Project_MasterDataAnalysis.OrderByDescending(x => x.DataDate).FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加分析数据
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public static void AddProjectMasterDataAnalysis(Model.Project_MasterDataAnalysis model)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.Project_MasterDataAnalysis newModel = new Model.Project_MasterDataAnalysis
|
||||
{
|
||||
Id = model.Id,
|
||||
CollCropCode = model.CollCropCode,
|
||||
UnitId = model.UnitId,
|
||||
ReportDate = model.ReportDate,
|
||||
DataDate = model.DataDate,
|
||||
Total = model.Total,
|
||||
MasterTotal = model.MasterTotal,
|
||||
QHSETotal = model.QHSETotal,
|
||||
ZhengChang = model.ZhengChang,
|
||||
DaiJian = model.DaiJian,
|
||||
BuYong = model.BuYong,
|
||||
YuLiXiang = model.YuLiXiang,
|
||||
//ZiJian = model.ZiJian,
|
||||
CreateUser = model.CreateUser,
|
||||
};
|
||||
db.Project_MasterDataAnalysis.InsertOnSubmit(newModel);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改分析数据
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public static void UpdateProjectMasterDataAnalysis(Model.Project_MasterDataAnalysis model)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.Project_MasterDataAnalysis newModel = db.Project_MasterDataAnalysis.FirstOrDefault(e => e.Id == model.Id);
|
||||
if (newModel != null)
|
||||
{
|
||||
//newModel.Id = model.Id;
|
||||
//newModel.CollCropCode = model.CollCropCode;
|
||||
//newModel.UnitId = model.UnitId;
|
||||
//newModel.ReportDate = model.ReportDate;
|
||||
//newModel.DataDate = model.DataDate;
|
||||
newModel.Total = model.Total;
|
||||
newModel.MasterTotal = model.MasterTotal;
|
||||
newModel.QHSETotal = model.QHSETotal;
|
||||
newModel.ZhengChang = model.ZhengChang;
|
||||
newModel.DaiJian = model.DaiJian;
|
||||
newModel.BuYong = model.BuYong;
|
||||
newModel.YuLiXiang = model.YuLiXiang;
|
||||
//newModel.ZiJian = model.ZiJian;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键删除分析数据
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
public static void DeleteProjectMasterDataAnalysisById(string Id)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.Project_MasterDataAnalysis model = db.Project_MasterDataAnalysis.FirstOrDefault(e => e.Id == Id);
|
||||
if (model != null)
|
||||
{
|
||||
db.Project_MasterDataAnalysis.DeleteOnSubmit(model);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取最近的汇总记录【近一小时】
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<Model.Project_MasterDataAnalysis> GetRecentHourAnalysisReportList()
|
||||
{
|
||||
var list = (from x in Funs.DB.Project_MasterDataAnalysis
|
||||
where x.DataDate > DateTime.Now.AddHours(-1)
|
||||
orderby x.DataDate descending
|
||||
select x).ToList();
|
||||
return list;
|
||||
}
|
||||
|
||||
#region 汇总上报
|
||||
|
||||
/// <summary>
|
||||
/// 集团主数据在建项目使用情况上报
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
public static string ReportProjectMasterDataAnalysis(string userName,ref string message)
|
||||
{
|
||||
string code = "0";
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
#region 汇总数据
|
||||
|
||||
//获取集团在建主数据
|
||||
List<Model.Ads_pms_pro_info_build> masterProDatas = ProjectService.GetMasterProjectDataInfos();
|
||||
//获取集团在建主数据
|
||||
List<Model.Base_Project> projects = ProjectService.GetProjectWorkList();
|
||||
|
||||
int masterTotal = masterProDatas.Count();
|
||||
int qhseTotal = projects.Count();
|
||||
|
||||
//1、正常
|
||||
int zhengChang = (from x in masterProDatas
|
||||
join pro in db.Base_Project on x.Pro_id equals pro.MasterSysId into proGroup
|
||||
from pro in proGroup.DefaultIfEmpty()
|
||||
where pro != null && pro.MasterSysId != null
|
||||
//&& pro.ProjectState == Const.ProjectState_1
|
||||
select x).Count();
|
||||
//2、待建
|
||||
int daiJian = (from x in masterProDatas
|
||||
join pro in db.Base_Project on x.Pro_id equals pro.MasterSysId into proGroup
|
||||
from pro in proGroup.DefaultIfEmpty()
|
||||
join use in db.Project_MasterDataUsage on x.Pro_id equals use.Pro_id into useGroup
|
||||
from use in useGroup.DefaultIfEmpty()
|
||||
where pro == null && (use == null || (use != null && (use.Reason == null || use.Reason == "")))
|
||||
select x).Count();
|
||||
//3、申请不用
|
||||
int buYong = (from x in masterProDatas
|
||||
join pro in db.Base_Project on x.Pro_id equals pro.MasterSysId into proGroup
|
||||
from pro in proGroup.DefaultIfEmpty()
|
||||
join use in db.Project_MasterDataUsage on x.Pro_id equals use.Pro_id into useGroup
|
||||
from use in useGroup.DefaultIfEmpty()
|
||||
where pro == null && use != null && use.Reason != null && use.Reason != ""
|
||||
select x).Count();
|
||||
//4、预立项
|
||||
int yuLiXiang = (from x in projects where x.MasterSysId == null select x).Count();
|
||||
|
||||
var thisUnit = CommonService.GetIsThisUnit();
|
||||
var now = DateTime.Now;
|
||||
//保存汇总数据
|
||||
Model.Project_MasterDataAnalysis analysis = new Project_MasterDataAnalysis
|
||||
{
|
||||
Id = SQLHelper.GetNewID(typeof(Model.Project_MasterDataAnalysis)),
|
||||
CollCropCode = thisUnit.CollCropCode,
|
||||
UnitId = thisUnit.UnitId,
|
||||
ReportDate = now.Date,
|
||||
DataDate = now,
|
||||
Total = zhengChang + daiJian + yuLiXiang,
|
||||
MasterTotal = masterTotal,
|
||||
QHSETotal = qhseTotal,
|
||||
ZhengChang = zhengChang,
|
||||
DaiJian = daiJian,
|
||||
BuYong = buYong,
|
||||
YuLiXiang = yuLiXiang,
|
||||
CreateUser = userName
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
#region 上报数据
|
||||
|
||||
string filePath = Funs.SGGLUrl;
|
||||
try
|
||||
{
|
||||
//var upReport = GetLastProjectMasterDataAnalysis();
|
||||
var upReport = analysis;
|
||||
|
||||
string baseurl = SysConstSetService.CNCECPath + "/api/Common/ProjectMasterDataAnalysis";
|
||||
string contenttype = "application/json;charset=unicode";
|
||||
Hashtable newToken = new Hashtable
|
||||
{
|
||||
{ "token", ServerService.GetToken().Token }
|
||||
};
|
||||
var pushContent = JsonConvert.SerializeObject(upReport);
|
||||
|
||||
//ErrLogInfo.WriteLog($"【集团主数据在建项目使用情况上报】:{pushContent}");
|
||||
var strJosn = APIGetHttpService.Http(baseurl, "Post", contenttype, newToken, pushContent);
|
||||
if (!string.IsNullOrEmpty(strJosn))
|
||||
{
|
||||
//ErrLogInfo.WriteLog($"【集团主数据在建项目使用情况上报】:{strJosn}");
|
||||
JObject obj = JObject.Parse(strJosn);
|
||||
code = obj["code"].ToString();
|
||||
message = obj["message"].ToString();
|
||||
|
||||
if (code == "1")
|
||||
{
|
||||
AddProjectMasterDataAnalysis(upReport);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrLogInfo.WriteLog("【集团主数据在建项目使用情况上报】上传到服务器", ex);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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