项目主数据
This commit is contained in:
@@ -848,6 +848,7 @@
|
||||
<Compile Include="ProjectData\MainItemService.cs" />
|
||||
<Compile Include="ProjectData\ProjectData_CodeTemplateRuleService.cs" />
|
||||
<Compile Include="ProjectData\ProjectDeviceService.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.SUBQHSEDB 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.SUBQHSEDB 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.SUBQHSEDB 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.SUBQHSEDB db = new Model.SUBQHSEDB(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
|
||||
}
|
||||
}
|
||||
@@ -197,6 +197,7 @@
|
||||
SubjectProject = project.SubjectProject,
|
||||
SubjectUnitApiUrl = project.SubjectUnitApiUrl,
|
||||
SubjectUnitWebUrl = project.SubjectUnitWebUrl,
|
||||
IsCNCECShow = project.IsCNCECShow,
|
||||
|
||||
};
|
||||
db.Base_Project.InsertOnSubmit(newProject);
|
||||
@@ -252,12 +253,26 @@
|
||||
newProject.SubjectProject = project.SubjectProject;
|
||||
newProject.SubjectUnitApiUrl = project.SubjectUnitApiUrl;
|
||||
newProject.SubjectUnitWebUrl = project.SubjectUnitWebUrl;
|
||||
|
||||
newProject.IsCNCECShow = project.IsCNCECShow;
|
||||
db.SubmitChanges();
|
||||
//Project_HSSEData_HSSEService.StatisticalData(project.ProjectId, Project_HSSEData_HSSEService.HSSEDateType.ProjectInformation);
|
||||
HSEDataCollectService.ProjectHSEDataCollectSubmission(newProject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取施工中项目集合
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<Model.Base_Project> GetCNCECShowProjectList()
|
||||
{
|
||||
var list = (from x in Funs.DB.Base_Project
|
||||
where x.IsCNCECShow == true
|
||||
orderby x.ProjectCode descending
|
||||
select x).ToList();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据项目Id删除一个项目信息
|
||||
@@ -282,9 +297,9 @@
|
||||
public static List<Model.Base_Project> GetProjectWorkList()
|
||||
{
|
||||
var list = (from x in Funs.DB.Base_Project
|
||||
where (x.ProjectState == null || x.ProjectState == BLL.Const.ProjectState_1) && (x.IsDelete == null || x.IsDelete == false)
|
||||
orderby x.ProjectCode descending
|
||||
select x).ToList();
|
||||
where x.IsCNCECShow == true && (x.ProjectState == null || x.ProjectState == BLL.Const.ProjectState_1)
|
||||
orderby x.ProjectCode descending
|
||||
select x).ToList();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -7334,7 +7334,8 @@
|
||||
//查询所有在建项目
|
||||
var upReport = (from x in db.Base_Project
|
||||
where (x.ProjectState == "1" || x.ProjectState == null) && (x.IsDelete == null || x.IsDelete == false)
|
||||
select new Model.BaseProjectItem
|
||||
&& x.IsCNCECShow == true
|
||||
select new Model.BaseProjectItem
|
||||
{
|
||||
ProjectId = x.ProjectId,
|
||||
MasterSysId = x.MasterSysId,
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace BLL
|
||||
join sysConst in Funs.DB.Sys_Const on new { ProjectState2 = project.ProjectState2, GroupId = BLL.ConstValue.GroupId_ProjectState } equals new { ProjectState2 = sysConst.ConstValue, GroupId = sysConst.GroupId } into sysConstJoin
|
||||
from sysConst in sysConstJoin.DefaultIfEmpty()
|
||||
where (project.ProjectAttribute == "GONGCHENG" || project.ProjectAttribute == null) && (project.IsDelete == null || project.IsDelete == false) && project.ProjectState == "1"
|
||||
&& project.IsCNCECShow == true
|
||||
select new ProjectOutput
|
||||
{
|
||||
ProjectId = project.ProjectId,
|
||||
@@ -71,6 +72,7 @@ namespace BLL
|
||||
join sysConst in Funs.DB.Sys_Const on new { ProjectState2 = project.ProjectState2, GroupId = BLL.ConstValue.GroupId_ProjectState } equals new { ProjectState2 = sysConst.ConstValue, GroupId = sysConst.GroupId } into sysConstJoin
|
||||
from sysConst in sysConstJoin.DefaultIfEmpty()
|
||||
where (project.ProjectAttribute == "GONGCHENG" || project.ProjectAttribute == null) && (project.IsDelete == null || project.IsDelete == false) && project.ProjectState == "2"
|
||||
&& project.IsCNCECShow == true
|
||||
select new ProjectOutput
|
||||
{
|
||||
ProjectId = project.ProjectId,
|
||||
@@ -116,6 +118,7 @@ namespace BLL
|
||||
join sysConst in Funs.DB.Sys_Const on new { ProjectState2 = project.ProjectState2, GroupId = BLL.ConstValue.GroupId_ProjectState } equals new { ProjectState2 = sysConst.ConstValue, GroupId = sysConst.GroupId } into sysConstJoin
|
||||
from sysConst in sysConstJoin.DefaultIfEmpty()
|
||||
where (project.ProjectAttribute == "GONGCHENG" || project.ProjectAttribute == null) && (project.IsDelete == null || project.IsDelete == false) && project.ProjectState == "3"
|
||||
&& project.IsCNCECShow == true
|
||||
select new ProjectOutput
|
||||
{
|
||||
ProjectId = project.ProjectId,
|
||||
@@ -153,7 +156,8 @@ namespace BLL
|
||||
join sysConst in Funs.DB.Sys_Const on new { ProjectState2 = project.ProjectState2, GroupId = BLL.ConstValue.GroupId_ProjectState } equals new { ProjectState2 = sysConst.ConstValue, GroupId = sysConst.GroupId } into sysConstJoin
|
||||
from sysConst in sysConstJoin.DefaultIfEmpty()
|
||||
where (project.ProjectAttribute == "GONGCHENG" || project.ProjectAttribute == null) && (project.IsDelete == null || project.IsDelete == false)
|
||||
select new ProjectOutput
|
||||
&& project.IsCNCECShow == true
|
||||
select new ProjectOutput
|
||||
{
|
||||
ProjectId = project.ProjectId,
|
||||
ProjectCode = project.ProjectCode,
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -103,6 +103,22 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 驳回企业级检查记录
|
||||
/// </summary>
|
||||
/// <param name="registerId">检查记录ID</param>
|
||||
public static void RejectUnitHazardRegisterById(string registerId)
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
var register = db.Supervise_UnitHazardRegister.FirstOrDefault(e => e.UnitHazardRegisterId == registerId);
|
||||
if (register != null)
|
||||
{
|
||||
register.States = (int)StateInt.待整改;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据项目和时间段获取检查数量
|
||||
@@ -149,6 +165,22 @@ namespace BLL
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user