This commit is contained in:
2025-09-18 14:22:42 +08:00
parent cb92dcb730
commit 490a942589
14 changed files with 558 additions and 29 deletions
@@ -13,10 +13,12 @@ namespace FineUIPro.Web.DCGL.ServerCheck
{
public partial class CheckRectify : PageBase
{
private static string proType;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
proType = Request.Params["proType"] ?? string.Empty;
this.GetButtonPower();
//btnNew.OnClientClick = Window1.GetShowReference("CheckRectifyEdit.aspx") + "return false;";
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
@@ -30,15 +32,19 @@ namespace FineUIPro.Web.DCGL.ServerCheck
/// </summary>
private void BindGrid()
{
string strSql = string.Empty;
StringBuilder sb = new StringBuilder();
sb.Append($@"SELECT S.CheckRectifyId,S.CheckRectifyCode,S.ProjectId,S.ProjectName,S.UnitId,U.UnitName,S.CheckDate,CASE S.HandleState WHEN '{BLL.Const.State_1}' THEN '未签发' WHEN '{BLL.Const.State_2}' THEN '未上报' ELSE '已上报' END AS HandleState,
S.IssueMan,S.IssueDate,ISNULL(TotalCount.TotalCount,0) AS TotalCount ,ISNULL(CompleteCount.CompleteCount,0) AS CompleteCount,(ISNULL(TotalCount.TotalCount,0) -ISNULL(CompleteCount.CompleteCount,0)) AS UnCompleteCount ");
sb.Append("FROM dbo.DCGL_Check_CheckRectify AS S LEFT JOIN dbo.Base_Unit AS U ON U.UnitId = S.UnitId ");
sb.Append(" LEFT JOIN (SELECT COUNT(*) AS TotalCount, CheckRectifyId FROM dbo.DCGL_Check_CheckRectifyItem GROUP BY CheckRectifyId) AS TotalCount ON S.CheckRectifyId=TotalCount.CheckRectifyId ");
sb.Append(" LEFT JOIN (SELECT COUNT(*) AS CompleteCount, CheckRectifyId FROM dbo.DCGL_Check_CheckRectifyItem WHERE RealEndDate IS NOT NULL GROUP BY CheckRectifyId) AS CompleteCount ON S.CheckRectifyId=CompleteCount.CheckRectifyId ");
if (!string.IsNullOrWhiteSpace(proType) && proType == "1")
{//只查询本项目检查数据
sb.Append($"WHERE S.ProjectId='{this.CurrUser.LoginProjectId}' ");
}
sb.Append("ORDER BY HandleState");
SqlParameter[] parameter = new SqlParameter[] { };
strSql = "SELECT S.CheckRectifyId,S.CheckRectifyCode,S.ProjectId,S.ProjectName,S.UnitId,U.UnitName,S.CheckDate,CASE S.HandleState WHEN '" + BLL.Const.State_1 + "' THEN '未签发' WHEN '" + BLL.Const.State_2 + "' THEN '未上报' ELSE '已上报' END AS HandleState,"
+ @" S.IssueMan,S.IssueDate,ISNULL(TotalCount.TotalCount,0) AS TotalCount ,ISNULL(CompleteCount.CompleteCount,0) AS CompleteCount,(ISNULL(TotalCount.TotalCount,0) -ISNULL(CompleteCount.CompleteCount,0)) AS UnCompleteCount"
+ @" FROM dbo.DCGL_Check_CheckRectify AS S LEFT JOIN dbo.Base_Unit AS U ON U.UnitId = S.UnitId"
+ @" LEFT JOIN (SELECT COUNT(*) AS TotalCount, CheckRectifyId FROM dbo.DCGL_Check_CheckRectifyItem GROUP BY CheckRectifyId) AS TotalCount ON S.CheckRectifyId=TotalCount.CheckRectifyId"
+ @" LEFT JOIN (SELECT COUNT(*) AS CompleteCount, CheckRectifyId FROM dbo.DCGL_Check_CheckRectifyItem WHERE RealEndDate IS NOT NULL GROUP BY CheckRectifyId) AS CompleteCount ON S.CheckRectifyId=CompleteCount.CheckRectifyId"
+ @" ORDER BY HandleState";
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
DataTable tb = SQLHelper.GetDataTableRunText(sb.ToString(), parameter);
// 2.获取当前分页数据
//var table = this.GetPagedDataTable(Grid1, tb1);
@@ -365,7 +371,7 @@ namespace FineUIPro.Web.DCGL.ServerCheck
#endregion
#endregion
/// <summary>
/// 从集团获取
/// </summary>
@@ -387,8 +393,9 @@ namespace FineUIPro.Web.DCGL.ServerCheck
#region
/// <summary>
/// 获取
/// 获取督查检查整改
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
@@ -397,7 +404,239 @@ namespace FineUIPro.Web.DCGL.ServerCheck
var responeData = new Model.ResponeData();
try
{
string unitId =BLL.Const.UnitId_SEDIN;
string unitId = BLL.Const.UnitId_SEDIN;
string baseurl = SysConstSetService.CNCECPath + "/api/HSSEData/getDCGLCheckInfoRectify?unitId=" + unitId;
string contenttype = "application/json;charset=unicode";
Hashtable newToken = new Hashtable
{
{ "token", ServerService.GetToken().Token }
};
var strJosn = APIGetHttpService.Http(baseurl, "GET", contenttype, newToken, null);
if (!string.IsNullOrEmpty(strJosn))
{
JObject obj = JObject.Parse(strJosn);
responeData.code = Funs.GetNewIntOrZero(obj["code"].ToString());
responeData.message = obj["message"].ToString();
if (responeData.code == 1)
{
JArray getData = JArray.Parse(obj["data"].ToString());
if (getData.Count() > 0)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<string> ids = new List<string>();
foreach (var item in getData)
{
string getCheckRectifyId = item["CheckRectifyId"].ToString();
if (!ids.Contains(getCheckRectifyId))
{
var newRectify = db.DCGL_Check_CheckRectify.FirstOrDefault(e => e.CheckRectifyId == getCheckRectifyId);
if (newRectify == null)
{
ids.Add(getCheckRectifyId);
Model.DCGL_Check_CheckRectify newCheckRectify = new Model.DCGL_Check_CheckRectify
{
CheckRectifyId = getCheckRectifyId,
CheckRectifyCode = item["CheckRectifyCode"].ToString(),
ProjectId = item["ProjectId"].ToString(),
ProjectName = item["ProjectName"].ToString(),
UnitId = unitId,
CheckDate = Funs.GetNewDateTime(item["CheckDate"].ToString()),
IssueMan = item["IssueMan"].ToString(),
IssueDate = Funs.GetNewDateTime(item["IssueDate"].ToString()),
HandleState = item["HandleState"].ToString()
};
db.DCGL_Check_CheckRectify.InsertOnSubmit(newCheckRectify);
db.SubmitChanges();
}
else
{
newRectify.CheckRectifyCode = item["CheckRectifyCode"].ToString();
db.SubmitChanges();
}
//获取对应主表主键的明细集合
string getNoticeItemId = item["NoticeItemId"].ToString();
var notice = db.DCGL_Check_CheckInfo_TableNoticeItem.FirstOrDefault(x => x.ID == getNoticeItemId);
if (notice == null)
{
Model.DCGL_Check_CheckInfo_TableNoticeItem newCheckRectifyItem = new Model.DCGL_Check_CheckInfo_TableNoticeItem
{
ID = getNoticeItemId,
CheckInfoId = item["CheckInfoId"].ToString(),
SortIndex = Funs.GetNewInt(item["SortIndex"].ToString()),
Describe = item["Describe"].ToString(),
Standards = item["Standards"].ToString(),
Advice = item["Advice"].ToString(),
LimitTime = Funs.GetNewDateTime(item["LimitTime"].ToString()),
Situation = item["Situation"].ToString(),
Remark = item["Remark"].ToString(),
Url = item["Url"].ToString(),
AffUrl = item["AffUrl"].ToString(),
RiskLevel = item["RiskLevel"].ToString(),
ProblemTypes = item["ProblemTypes"].ToString(),
ProblemSubTypeId = item["ProblemSubTypeId"].ToString(),
ProblemSubType = item["ProblemSubType"].ToString(),
States = item["States"].ToString(),
//WorkType = item["WorkType"].ToString(),
//DangerPoint = item["DangerPoint"].ToString(),
//RiskExists = item["RiskExists"].ToString(),
//IsProject = Convert.ToBoolean(item["IsProject"].ToString()),
//CheckMan = item["CheckMan"].ToString(),
//SubjectUnitMan = item["SubjectUnitMan"].ToString(),
};
db.DCGL_Check_CheckInfo_TableNoticeItem.InsertOnSubmit(newCheckRectifyItem);
db.SubmitChanges();
}
BLL.CommonService.DeleteAttachFileById(getNoticeItemId);//删除附件
////上传附件
string getAttachFileId = item["AttachFileId"].ToString();
if (!string.IsNullOrEmpty(getAttachFileId))
{
List<byte[]> resultList = new List<byte[]>();
string filePath = item["FilePath"].ToString();
string attachSource = item["AttachSource"].ToString();
string attachUrl = item["AttachUrl"].ToString();
BLL.FileInsertService.InsertAttachFileRecord(getAttachFileId, getNoticeItemId, attachSource, attachUrl);
//if (!string.IsNullOrWhiteSpace(filePath) && !string.IsNullOrWhiteSpace(attachSource) && !string.IsNullOrWhiteSpace(attachUrl))
//{
// resultList = FileInsertService.FilePathTransStream(filePath, attachUrl);
//}
//BLL.FileInsertService.InsertAttachFile(getAttachFileId, getNoticeItemId, attachSource, attachUrl, resultList);
}
string getCheckRectifyItemId = item["CheckRectifyItemId"].ToString();
var oldItem = db.DCGL_Check_CheckRectifyItem.FirstOrDefault(e => e.CheckRectifyItemId == getCheckRectifyItemId);
if (oldItem == null)
{
Model.DCGL_Check_CheckRectifyItem newCheckRectifyItem = new Model.DCGL_Check_CheckRectifyItem
{
CheckRectifyItemId = getCheckRectifyItemId,
CheckRectifyId = getCheckRectifyId,
NoticeItemId = getNoticeItemId,
ConfirmMan = item["ConfirmMan"].ToString(),
ConfirmManName = item["ConfirmManName"].ToString(),
ConfirmDate = Funs.GetNewDateTime(item["ConfirmDate"].ToString()),
OrderEndDate = Funs.GetNewDateTime(item["OrderEndDate"].ToString()),
OrderEndPerson = item["OrderEndPerson"].ToString(),
RealEndDate = Funs.GetNewDateTime(item["RealEndDate"].ToString()),
};
db.DCGL_Check_CheckRectifyItem.InsertOnSubmit(newCheckRectifyItem);
db.SubmitChanges();
}
}
else
{
//获取对应主表主键的明细集合
string getNoticeItemId = item["NoticeItemId"].ToString();
var notice = db.DCGL_Check_CheckInfo_TableNoticeItem.FirstOrDefault(x => x.ID == getNoticeItemId);
if (notice == null)
{
Model.DCGL_Check_CheckInfo_TableNoticeItem newCheckRectifyItem = new Model.DCGL_Check_CheckInfo_TableNoticeItem
{
ID = getNoticeItemId,
CheckInfoId = item["CheckInfoId"].ToString(),
SortIndex = Funs.GetNewInt(item["SortIndex"].ToString()),
Describe = item["Describe"].ToString(),
Standards = item["Standards"].ToString(),
Advice = item["Advice"].ToString(),
LimitTime = Funs.GetNewDateTime(item["LimitTime"].ToString()),
Situation = item["Situation"].ToString(),
Remark = item["Remark"].ToString(),
Url = item["Url"].ToString(),
AffUrl = item["AffUrl"].ToString(),
RiskLevel = item["RiskLevel"].ToString(),
ProblemTypes = item["ProblemTypes"].ToString(),
ProblemSubTypeId = item["ProblemSubTypeId"].ToString(),
ProblemSubType = item["ProblemSubType"].ToString(),
States = item["States"].ToString(),
//WorkType = item["WorkType"].ToString(),
//DangerPoint = item["DangerPoint"].ToString(),
//RiskExists = item["RiskExists"].ToString(),
//IsProject = Convert.ToBoolean(item["IsProject"].ToString()),
//CheckMan = item["CheckMan"].ToString(),
//SubjectUnitMan = item["SubjectUnitMan"].ToString(),
};
db.DCGL_Check_CheckInfo_TableNoticeItem.InsertOnSubmit(newCheckRectifyItem);
db.SubmitChanges();
}
BLL.CommonService.DeleteAttachFileById(getNoticeItemId);//删除附件
////上传附件
string getAttachFileId = item["AttachFileId"].ToString();
if (!string.IsNullOrEmpty(getAttachFileId))
{
List<byte[]> resultList = new List<byte[]>();
string attachSource = item["AttachSource"].ToString();
string attachUrl = item["AttachUrl"].ToString();
BLL.FileInsertService.InsertAttachFileRecord(getAttachFileId, getNoticeItemId, attachSource, attachUrl);
//if (!string.IsNullOrWhiteSpace(filePath) && !string.IsNullOrWhiteSpace(attachSource) && !string.IsNullOrWhiteSpace(attachUrl))
//{
// resultList = FileInsertService.FilePathTransStream(filePath, attachUrl);
//}
//BLL.FileInsertService.InsertAttachFile(getAttachFileId, getNoticeItemId, attachSource, attachUrl, resultList);
}
string getCheckRectifyItemId = item["CheckRectifyItemId"].ToString();
var oldItem = db.DCGL_Check_CheckRectifyItem.FirstOrDefault(e => e.CheckRectifyItemId == getCheckRectifyItemId);
if (oldItem == null)
{
Model.DCGL_Check_CheckRectifyItem newCheckRectifyItem = new Model.DCGL_Check_CheckRectifyItem
{
CheckRectifyItemId = getCheckRectifyItemId,
CheckRectifyId = getCheckRectifyId,
NoticeItemId = getNoticeItemId,
ConfirmMan = item["ConfirmMan"].ToString(),
ConfirmManName = item["ConfirmManName"].ToString(),
ConfirmDate = Funs.GetNewDateTime(item["ConfirmDate"].ToString()),
OrderEndDate = Funs.GetNewDateTime(item["OrderEndDate"].ToString()),
OrderEndPerson = item["OrderEndPerson"].ToString(),
RealEndDate = Funs.GetNewDateTime(item["RealEndDate"].ToString()),
};
db.DCGL_Check_CheckRectifyItem.InsertOnSubmit(newCheckRectifyItem);
db.SubmitChanges();
}
}
}
}
}
responeData.message = "获取成功:整改明细记录" + getData.Count().ToString() + "条";
}
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = "获取失败:" + ex.Message;
ErrLogInfo.WriteLog("督查检查通知单获取!", ex);
}
return responeData;
}
#endregion
#region
/// <summary>
/// 获取
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static Model.ResponeData getCheck_CheckRectifyListToSUBOld()
{
var responeData = new Model.ResponeData();
try
{
string unitId = BLL.Const.UnitId_SEDIN;
string baseurl = SysConstSetService.CNCECPath + "/api/HSSEData/getDCGLCheckRectify?unitId=" + unitId;
string contenttype = "application/json;charset=unicode";
Hashtable newToken = new Hashtable
@@ -591,6 +830,7 @@ namespace FineUIPro.Web.DCGL.ServerCheck
CheckRectifyId = getCheckRectifyId,
NoticeItemId = getNoticeItemId,
ConfirmMan = item["ConfirmMan"].ToString(),
ConfirmManName = item["ConfirmManName"].ToString(),
ConfirmDate = Funs.GetNewDateTime(item["ConfirmDate"].ToString()),
OrderEndDate = Funs.GetNewDateTime(item["OrderEndDate"].ToString()),
OrderEndPerson = item["OrderEndPerson"].ToString(),