diff --git a/SGGL/FineUIPro.Web/DCGL/ServerCheck/CheckNotice.aspx.cs b/SGGL/FineUIPro.Web/DCGL/ServerCheck/CheckNotice.aspx.cs index a7d158c9..a08899ac 100644 --- a/SGGL/FineUIPro.Web/DCGL/ServerCheck/CheckNotice.aspx.cs +++ b/SGGL/FineUIPro.Web/DCGL/ServerCheck/CheckNotice.aspx.cs @@ -396,7 +396,7 @@ namespace FineUIPro.Web.DCGL.ServerCheck JArray arr = JArray.Parse(data); if (arr.Count() > 0) { - using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString)) { List ids = new List(); foreach (var item in arr) diff --git a/SGGL/FineUIPro.Web/DCGL/ServerCheck/CheckRectify.aspx.cs b/SGGL/FineUIPro.Web/DCGL/ServerCheck/CheckRectify.aspx.cs index 931c3f1e..995b16c5 100644 --- a/SGGL/FineUIPro.Web/DCGL/ServerCheck/CheckRectify.aspx.cs +++ b/SGGL/FineUIPro.Web/DCGL/ServerCheck/CheckRectify.aspx.cs @@ -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 /// 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 - + /// /// 从集团获取 /// @@ -387,8 +393,9 @@ namespace FineUIPro.Web.DCGL.ServerCheck #region 获取 + /// - /// 获取 + /// 获取督查检查整改 /// /// /// @@ -397,7 +404,239 @@ namespace FineUIPro.Web.DCGL.ServerCheck var responeData = new Model.ResponeData(); try { - string unitId =CommonService.GetThisUnitId(); + string unitId = CommonService.GetThisUnitId(); + 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.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString)) + { + List ids = new List(); + 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 resultList = new List(); + 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 resultList = new List(); + 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 获取 + /// + /// 获取 + /// + /// + /// + public static Model.ResponeData getCheck_CheckRectifyListToSUBOld() + { + var responeData = new Model.ResponeData(); + try + { + string unitId = CommonService.GetThisUnitId(); string baseurl = SysConstSetService.CNCECPath + "/api/HSSEData/getDCGLCheckRectify?unitId=" + unitId; string contenttype = "application/json;charset=unicode"; Hashtable newToken = new Hashtable @@ -416,7 +655,7 @@ namespace FineUIPro.Web.DCGL.ServerCheck JArray getData = JArray.Parse(obj["data"].ToString()); if (getData.Count() > 0) { - using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString)) { List ids = new List(); foreach (var item in getData) @@ -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(), diff --git a/SGGL/FineUIPro.Web/DCGL/ServerCheck/CheckRectifyEdit.aspx b/SGGL/FineUIPro.Web/DCGL/ServerCheck/CheckRectifyEdit.aspx index cbec1d1f..c545431f 100644 --- a/SGGL/FineUIPro.Web/DCGL/ServerCheck/CheckRectifyEdit.aspx +++ b/SGGL/FineUIPro.Web/DCGL/ServerCheck/CheckRectifyEdit.aspx @@ -6,11 +6,36 @@ 隐患整改单 + + + @@ -57,7 +82,7 @@ @@ -74,10 +99,16 @@ - + + + + + <%-- - + --%> @@ -108,12 +139,19 @@ - + --%> + + + + +