安全巡检接入真实数据库:编码字段自动生成、公示牌二维码修复、安全问题统计排除作废

- 安全巡检表新增编码字段(Code,全局唯一 XJ-序号),WebAPI/桌面端新增时自动生成,不可重复
- 修复危大超危工程公示牌二维码不显示:urlName 含非法字符?导致 image.Save 抛异常,改用主键+内容哈希安全文件名
- 安全问题统计(mainProject/main3)排除作废数据(States=4),图表口径与顶部计数一致
- Word 导出文件名改为 监督巡视部位+编号
- Model.cs 由 SqlMetal 重新生成,补齐巡检人ID/签收人ID/发现问题/处理要求等字段;新增 HSSE_SafetyPatrol.Code.cs 补充 Code 列
- 新增安全巡检完整建表脚本(SGGLDB_V2026-08-25-001);删除已过时的接口文档 SafetyPatrol_API.md
This commit is contained in:
2026-08-26 19:13:11 +08:00
parent 55944d732a
commit 192824ea90
27 changed files with 1601 additions and 309 deletions
+72 -3
View File
@@ -29,13 +29,21 @@ namespace BLL
select new Model.SafetyPatrolItem
{
PatrolId = x.PatrolId,
Code = x.Code,
ProjectId = x.ProjectId,
HazardProjectId = x.HazardProjectId,
HazardProjectName = x.HazardProjectName,
PatrolDate = x.PatrolDate,
PatrolMan = x.PatrolMan,
PatrolManId = x.PatrolManId,
PatrolStatus = x.PatrolStatus,
Content = x.Content
Content = x.Content,
Problems = x.Problems,
Receiver = x.Receiver,
ReceiverId = x.ReceiverId,
HandleRequire = x.HandleRequire,
RectifyReview = x.RectifyReview,
Remarks = x.Remarks
};
return list.ToList();
}
@@ -58,13 +66,21 @@ namespace BLL
return new Model.SafetyPatrolItem
{
PatrolId = x.PatrolId,
Code = x.Code,
ProjectId = x.ProjectId,
HazardProjectId = x.HazardProjectId,
HazardProjectName = x.HazardProjectName,
PatrolDate = x.PatrolDate,
PatrolMan = x.PatrolMan,
PatrolManId = x.PatrolManId,
PatrolStatus = x.PatrolStatus,
Content = x.Content
Content = x.Content,
Problems = x.Problems,
Receiver = x.Receiver,
ReceiverId = x.ReceiverId,
HandleRequire = x.HandleRequire,
RectifyReview = x.RectifyReview,
Remarks = x.Remarks
};
}
}
@@ -82,16 +98,29 @@ namespace BLL
}
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
////编码为空时自动生成(全局唯一)
if (string.IsNullOrEmpty(item.Code))
{
item.Code = GetNewCode(db);
}
Model.HSSE_SafetyPatrol newItem = new Model.HSSE_SafetyPatrol
{
PatrolId = item.PatrolId,
Code = item.Code,
ProjectId = item.ProjectId,
HazardProjectId = item.HazardProjectId,
HazardProjectName = item.HazardProjectName,
PatrolDate = item.PatrolDate,
PatrolMan = item.PatrolMan,
PatrolManId = item.PatrolManId,
PatrolStatus = item.PatrolStatus,
Content = item.Content
Content = item.Content,
Problems = item.Problems,
Receiver = item.Receiver,
ReceiverId = item.ReceiverId,
HandleRequire = item.HandleRequire,
RectifyReview = item.RectifyReview,
Remarks = item.Remarks
};
db.HSSE_SafetyPatrol.InsertOnSubmit(newItem);
db.SubmitChanges();
@@ -101,6 +130,11 @@ namespace BLL
{
APIUpLoadFileService.SaveAttachUrl(Const.SafetyPatrolMenuId, item.PatrolId, item.AttachUrl, "0");
}
////保存整改图片附件
if (!string.IsNullOrEmpty(item.RectifyAttachUrl))
{
APIUpLoadFileService.SaveAttachUrl(Const.SafetyPatrolRectifyMenuId, item.PatrolId, item.RectifyAttachUrl, "0");
}
return item.PatrolId;
}
@@ -123,8 +157,15 @@ namespace BLL
newItem.HazardProjectName = item.HazardProjectName;
newItem.PatrolDate = item.PatrolDate;
newItem.PatrolMan = item.PatrolMan;
newItem.PatrolManId = item.PatrolManId;
newItem.PatrolStatus = item.PatrolStatus;
newItem.Content = item.Content;
newItem.Problems = item.Problems;
newItem.Receiver = item.Receiver;
newItem.ReceiverId = item.ReceiverId;
newItem.HandleRequire = item.HandleRequire;
newItem.RectifyReview = item.RectifyReview;
newItem.Remarks = item.Remarks;
db.SubmitChanges();
}
////保存巡检图片附件
@@ -132,7 +173,35 @@ namespace BLL
{
APIUpLoadFileService.SaveAttachUrl(Const.SafetyPatrolMenuId, item.PatrolId, item.AttachUrl, "0");
}
////保存整改图片附件
if (!string.IsNullOrEmpty(item.RectifyAttachUrl))
{
APIUpLoadFileService.SaveAttachUrl(Const.SafetyPatrolRectifyMenuId, item.PatrolId, item.RectifyAttachUrl, "0");
}
return true;
}
/// <summary>
/// 生成新的巡检编码(全局唯一,前缀 XJ-,三位递增序号)
/// </summary>
/// <param name="db">数据库上下文</param>
/// <returns></returns>
private static string GetNewCode(Model.SGGLDB db)
{
int max = 0;
foreach (Model.HSSE_SafetyPatrol item in db.HSSE_SafetyPatrol.ToList())
{
string code = item.Code;
if (!string.IsNullOrEmpty(code) && code.StartsWith("XJ-"))
{
int num = 0;
if (int.TryParse(code.Substring(3), out num) && num > max)
{
max = num;
}
}
}
return string.Format("XJ-{0:D3}", max + 1);
}
}
}