新增:安全技术数据

This commit is contained in:
2026-09-11 11:14:08 +08:00
parent 9bce0d340f
commit 5a2830d36a
24 changed files with 5065 additions and 292 deletions
+443
View File
@@ -0,0 +1,443 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace BLL
{
/// <summary>
/// PDF 书籍模块 WebAPI 数据服务(移动端 / 第三方系统集成用)。
/// 对应 PC 页面 HSSE/PDFDOC/PdfBookView.aspx 的完整功能:书籍、多级章节目录、章节正文(富文本 HTML)的
/// 查询与维护(新增书籍 / 新增·编辑·删除章节 / 保存章节正文),并额外提供章节关键词检索。
/// 数据表:Sys_PdfBook / Sys_PdfChapter(正文存 [Text] 列,为 UMeditor 生成的 HTML)。
/// 说明:目录结构用 ParentChapterId + Level(1章 2节 3小节) 表达多级层级,SortNo 控制同级顺序。
/// </summary>
public static class APIPdfBookService
{
#region 返回模型
/// <summary>书籍列表项。</summary>
public class BookItem
{
/// <summary>书籍主键。</summary>
public string BookId { get; set; }
/// <summary>书名。</summary>
public string Title { get; set; }
/// <summary>章节总数。</summary>
public int ChapterCount { get; set; }
/// <summary>登记时间。</summary>
public DateTime? CreateTime { get; set; }
}
/// <summary>章节目录树节点(多级嵌套)。</summary>
public class ChapterTreeNode
{
/// <summary>章节主键。</summary>
public string ChapterId { get; set; }
/// <summary>章节名称。</summary>
public string ChapterTitle { get; set; }
/// <summary>层级:1章 2节 3小节。</summary>
public int Level { get; set; }
/// <summary>起始页码(无则为0)。</summary>
public int PageStart { get; set; }
/// <summary>结束页码(无则为0)。</summary>
public int PageEnd { get; set; }
/// <summary>是否已有正文内容(用于客户端标识可读章节)。</summary>
public bool HasContent { get; set; }
/// <summary>子章节列表(叶子章节为空数组)。</summary>
public List<ChapterTreeNode> Children { get; set; }
}
/// <summary>章节正文详情。</summary>
public class ChapterDetailItem
{
/// <summary>章节主键。</summary>
public string ChapterId { get; set; }
/// <summary>所属书籍主键。</summary>
public string BookId { get; set; }
/// <summary>所属书籍名称。</summary>
public string BookTitle { get; set; }
/// <summary>章节名称。</summary>
public string ChapterTitle { get; set; }
/// <summary>父章节主键(顶级为 null)。</summary>
public string ParentChapterId { get; set; }
/// <summary>层级:1章 2节 3小节。</summary>
public int Level { get; set; }
/// <summary>起始页码(无则为0)。</summary>
public int PageStart { get; set; }
/// <summary>结束页码(无则为0)。</summary>
public int PageEnd { get; set; }
/// <summary>正文(富文本 HTML,可直接用 WebView 渲染)。</summary>
public string Content { get; set; }
/// <summary>正文纯文本(去掉 HTML 标签,便于全文展示/搜索)。</summary>
public string ContentText { get; set; }
}
/// <summary>章节关键词检索命中项。</summary>
public class SearchHitItem
{
/// <summary>书籍主键。</summary>
public string BookId { get; set; }
/// <summary>书籍名称。</summary>
public string BookTitle { get; set; }
/// <summary>章节主键。</summary>
public string ChapterId { get; set; }
/// <summary>章节名称。</summary>
public string ChapterTitle { get; set; }
/// <summary>起始页码(无则为0)。</summary>
public int PageStart { get; set; }
/// <summary>结束页码(无则为0)。</summary>
public int PageEnd { get; set; }
/// <summary>命中片段(关键词前后各约40字)。</summary>
public string Snippet { get; set; }
}
#endregion
#region 查询:书籍列表
/// <summary>
/// 获取全部书籍(按登记时间升序,与页面下拉一致)。
/// </summary>
public static List<BookItem> GetBooks()
{
var list = new List<BookItem>();
DataTable dt = SQLHelper.GetDataTableRunText(
"SELECT b.BookId, b.Title, b.CreateTime, " +
"(SELECT COUNT(*) FROM dbo.Sys_PdfChapter c WHERE c.BookId = b.BookId) AS ChapterCount " +
"FROM dbo.Sys_PdfBook b ORDER BY b.CreateTime", new SqlParameter[] { });
if (dt == null)
return list;
foreach (DataRow r in dt.Rows)
{
list.Add(new BookItem
{
BookId = r["BookId"] == null ? "" : r["BookId"].ToString(),
Title = r["Title"] == null ? "" : r["Title"].ToString(),
ChapterCount = r["ChapterCount"] == DBNull.Value ? 0 : Convert.ToInt32(r["ChapterCount"]),
CreateTime = r["CreateTime"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(r["CreateTime"])
});
}
return list;
}
#endregion
#region 查询:多级章节目录树
/// <summary>
/// 获取某本书的多级章节目录树(嵌套 Children,顶级为根的数组;按 SortNo 排序)。
/// </summary>
public static List<ChapterTreeNode> GetChapterTree(string bookId)
{
if (string.IsNullOrWhiteSpace(bookId))
throw new Exception("bookId 不能为空");
var chapters = PdfBookService.GetChapters(bookId);
var result = new List<ChapterTreeNode>();
if (chapters == null || chapters.Count == 0)
return result;
// 有正文标记(一次查询)
var hasContentSet = new HashSet<string>();
DataTable dt = SQLHelper.GetDataTableRunText(
"SELECT ChapterId FROM dbo.Sys_PdfChapter " +
"WHERE BookId = @BookId AND [Text] IS NOT NULL AND LTRIM(RTRIM([Text])) <> N''",
new[] { new SqlParameter("@BookId", bookId) });
if (dt != null)
foreach (DataRow r in dt.Rows)
hasContentSet.Add(r["ChapterId"] == null ? "" : r["ChapterId"].ToString());
// 1) 先为每个章节建节点
var nodeMap = new Dictionary<string, ChapterTreeNode>();
foreach (PdfChapter c in chapters)
{
nodeMap[c.ChapterId] = new ChapterTreeNode
{
ChapterId = c.ChapterId,
ChapterTitle = c.Title,
Level = c.Level,
PageStart = c.PageStart,
PageEnd = c.PageEnd,
HasContent = hasContentSet.Contains(c.ChapterId),
Children = new List<ChapterTreeNode>()
};
}
// 2) 按父章节挂接(父不在列表中的作为顶级)
foreach (PdfChapter c in chapters)
{
var node = nodeMap[c.ChapterId];
if (!string.IsNullOrWhiteSpace(c.ParentChapterId) && nodeMap.ContainsKey(c.ParentChapterId))
nodeMap[c.ParentChapterId].Children.Add(node);
else
result.Add(node);
}
return result;
}
#endregion
#region 查询:章节正文
/// <summary>
/// 获取章节正文详情(含 HTML 与纯文本);章节不存在返回 null。
/// </summary>
public static ChapterDetailItem GetChapterDetail(string chapterId)
{
if (string.IsNullOrWhiteSpace(chapterId))
throw new Exception("chapterId 不能为空");
DataTable dt = SQLHelper.GetDataTableRunText(
"SELECT c.ChapterId, c.BookId, b.Title AS BookTitle, c.ParentChapterId, c.[Level], " +
"c.ChapterTitle, c.PageStart, c.PageEnd, c.[Text] " +
"FROM dbo.Sys_PdfChapter c INNER JOIN dbo.Sys_PdfBook b ON c.BookId = b.BookId " +
"WHERE c.ChapterId = @ChapterId",
new[] { new SqlParameter("@ChapterId", chapterId) });
if (dt == null || dt.Rows.Count == 0)
return null;
DataRow r = dt.Rows[0];
string html = r["Text"] == DBNull.Value ? "" : r["Text"].ToString();
var item = new ChapterDetailItem
{
ChapterId = r["ChapterId"] == null ? "" : r["ChapterId"].ToString(),
BookId = r["BookId"] == null ? "" : r["BookId"].ToString(),
BookTitle = r["BookTitle"] == null ? "" : r["BookTitle"].ToString(),
ParentChapterId = r["ParentChapterId"] == DBNull.Value ? null : r["ParentChapterId"].ToString(),
Level = r["Level"] == DBNull.Value ? 1 : Convert.ToInt32(r["Level"]),
ChapterTitle = r["ChapterTitle"] == null ? "" : r["ChapterTitle"].ToString(),
PageStart = r["PageStart"] == DBNull.Value ? 0 : Convert.ToInt32(r["PageStart"]),
PageEnd = r["PageEnd"] == DBNull.Value ? 0 : Convert.ToInt32(r["PageEnd"]),
Content = html,
ContentText = HtmlToPlainText(html)
};
return item;
}
#endregion
#region 查询:章节关键词检索
/// <summary>
/// 章节关键词检索:在章节正文中按关键词做字面匹配(正文为 HTML,匹配前先剔除标签)。
/// bookId 可空:不传则全库检索。
/// </summary>
public static List<SearchHitItem> SearchChapter(string keyword, string bookId)
{
if (string.IsNullOrWhiteSpace(keyword))
throw new Exception("keyword 不能为空");
// LIKE 通配符转义(ESCAPE 字符为反斜杠)
string esc = keyword.Replace("\\", "\\\\").Replace("%", "\\%").Replace("_", "\\_");
var ps = new List<SqlParameter>
{
new SqlParameter("@Keyword", "%" + esc + "%")
};
string where = "c.[Text] LIKE @Keyword ESCAPE '\\'";
if (!string.IsNullOrWhiteSpace(bookId))
{
where += " AND c.BookId = @BookId";
ps.Add(new SqlParameter("@BookId", bookId));
}
DataTable dt = SQLHelper.GetDataTableRunText(
"SELECT c.ChapterId, c.ChapterTitle, c.BookId, b.Title AS BookTitle, " +
"c.PageStart, c.PageEnd, c.[Text] " +
"FROM dbo.Sys_PdfChapter c INNER JOIN dbo.Sys_PdfBook b ON c.BookId = b.BookId " +
"WHERE " + where + " ORDER BY b.Title, c.SortNo", ps.ToArray());
var list = new List<SearchHitItem>();
if (dt == null)
return list;
foreach (DataRow r in dt.Rows)
{
string html = r["Text"] == DBNull.Value ? "" : r["Text"].ToString();
string plain = HtmlToPlainText(html);
list.Add(new SearchHitItem
{
BookId = r["BookId"] == null ? "" : r["BookId"].ToString(),
BookTitle = r["BookTitle"] == null ? "" : r["BookTitle"].ToString(),
ChapterId = r["ChapterId"] == null ? "" : r["ChapterId"].ToString(),
ChapterTitle = r["ChapterTitle"] == null ? "" : r["ChapterTitle"].ToString(),
PageStart = r["PageStart"] == DBNull.Value ? 0 : Convert.ToInt32(r["PageStart"]),
PageEnd = r["PageEnd"] == DBNull.Value ? 0 : Convert.ToInt32(r["PageEnd"]),
Snippet = BuildSnippet(plain, keyword)
});
}
return list;
}
/// <summary>取关键词命中片段(前后各约40字)。</summary>
private static string BuildSnippet(string plain, string keyword)
{
if (string.IsNullOrEmpty(plain))
return "";
int idx = plain.IndexOf(keyword, StringComparison.OrdinalIgnoreCase);
if (idx < 0)
return plain.Length > 120 ? plain.Substring(0, 120) + "……" : plain;
int start = Math.Max(0, idx - 40);
int len = Math.Min(plain.Length - start, keyword.Length + 80);
return (start > 0 ? "……" : "") + plain.Substring(start, len) + (start + len < plain.Length ? "……" : "");
}
/// <summary>HTML 转纯文本(去标签、解码实体、压缩空白)。</summary>
private static string HtmlToPlainText(string html)
{
if (string.IsNullOrEmpty(html))
return "";
string s = Regex.Replace(html, "(?i)<(br|/p|/div|/li|/tr|/h[1-6])[^>]*>", "\n");
s = Regex.Replace(s, "<[^>]+>", "");
s = System.Net.WebUtility.HtmlDecode(s);
s = Regex.Replace(s, "[\r\n]+", "\n");
s = Regex.Replace(s, "[ \t]+", " ");
return s.Trim();
}
#endregion
#region 维护:书籍
/// <summary>
/// 新增书籍(仅书名;FilePath/TotalPages/IndexStatus 与页面一致:NULL/0/2)。
/// </summary>
public static string AddBook(string title, string createUser)
{
if (string.IsNullOrWhiteSpace(title))
throw new Exception("书名不能为空");
if (string.IsNullOrWhiteSpace(createUser))
createUser = "api";
string bookId = NewId("PB");
SQLHelper.ExecutSql(
"INSERT INTO dbo.Sys_PdfBook (BookId, Title, FilePath, TotalPages, IndexStatus, CreateUser, CreateTime) VALUES ('"
+ SqlEsc(bookId) + "',N'" + SqlEsc(title.Trim()) + "',NULL,0,2,N'"
+ SqlEsc(createUser) + "',GETDATE())");
return bookId;
}
#endregion
#region 维护:章节(新增 / 改名 / 删除 / 保存正文)
/// <summary>
/// 新增章节:parentChapterId 为空则为顶级章节,否则挂到指定父章节下(层级=父级+1)。
/// SortNo 取全书当前最大值+1(与页面逻辑一致)。
/// </summary>
public static string AddChapter(string bookId, string parentChapterId, string chapterTitle, string createUser)
{
if (string.IsNullOrWhiteSpace(bookId))
throw new Exception("bookId 不能为空");
if (string.IsNullOrWhiteSpace(chapterTitle))
throw new Exception("章节名称不能为空");
int level = 1;
if (!string.IsNullOrWhiteSpace(parentChapterId))
{
int parentLevel = GetInt(
"SELECT ISNULL([Level],1) FROM dbo.Sys_PdfChapter WHERE ChapterId='" + SqlEsc(parentChapterId) + "'");
if (parentLevel <= 0)
throw new Exception("父章节不存在:" + parentChapterId);
level = parentLevel + 1;
}
int sort = GetInt(
"SELECT ISNULL(MAX(SortNo),0) FROM dbo.Sys_PdfChapter WHERE BookId='" + SqlEsc(bookId) + "'") + 1;
string chapterId = NewId("CH");
SQLHelper.ExecutSql(
"INSERT INTO dbo.Sys_PdfChapter (ChapterId, BookId, ParentChapterId, [Level], ChapterTitle, PageStart, PageEnd, [Text], SortNo) VALUES ('"
+ SqlEsc(chapterId) + "','" + SqlEsc(bookId) + "',"
+ (string.IsNullOrWhiteSpace(parentChapterId) ? "NULL" : "'" + SqlEsc(parentChapterId) + "'")
+ "," + level + ",N'" + SqlEsc(chapterTitle.Trim()) + "',NULL,NULL,N''," + sort + ")");
return chapterId;
}
/// <summary>
/// 编辑章节:仅修改章节名称。
/// </summary>
public static void EditChapter(string chapterId, string chapterTitle)
{
if (string.IsNullOrWhiteSpace(chapterId))
throw new Exception("chapterId 不能为空");
if (string.IsNullOrWhiteSpace(chapterTitle))
throw new Exception("章节名称不能为空");
if (GetInt("SELECT COUNT(*) FROM dbo.Sys_PdfChapter WHERE ChapterId='" + SqlEsc(chapterId) + "'") == 0)
throw new Exception("章节不存在:" + chapterId);
SQLHelper.ExecutSql("UPDATE dbo.Sys_PdfChapter SET ChapterTitle=N'" + SqlEsc(chapterTitle.Trim())
+ "' WHERE ChapterId='" + SqlEsc(chapterId) + "'");
}
/// <summary>
/// 删除章节及其全部子章节(递归收集自身+后代后一次性删除)。
/// </summary>
public static int DeleteChapter(string chapterId)
{
if (string.IsNullOrWhiteSpace(chapterId))
throw new Exception("chapterId 不能为空");
DataTable dt = SQLHelper.GetDataTableRunText(
"SELECT BookId FROM dbo.Sys_PdfChapter WHERE ChapterId=@ChapterId",
new[] { new SqlParameter("@ChapterId", chapterId) });
if (dt == null || dt.Rows.Count == 0)
throw new Exception("章节不存在:" + chapterId);
string bookId = dt.Rows[0]["BookId"].ToString();
var all = PdfBookService.GetChapters(bookId);
var ids = new List<string> { chapterId };
bool changed = true;
while (changed)
{
changed = false;
foreach (PdfChapter c in all)
{
if (!ids.Contains(c.ChapterId) && ids.Contains(c.ParentChapterId ?? ""))
{
ids.Add(c.ChapterId);
changed = true;
}
}
}
var sb = new StringBuilder();
foreach (string id in ids)
{
if (sb.Length > 0)
sb.Append(",");
sb.Append("'").Append(id.Replace("'", "''")).Append("'");
}
SQLHelper.ExecutSql("DELETE FROM dbo.Sys_PdfChapter WHERE ChapterId IN (" + sb + ")");
return ids.Count;
}
/// <summary>
/// 保存章节正文(富文本 HTML,与页面"保存内容"一致)。
/// </summary>
public static void SaveContent(string chapterId, string content)
{
if (string.IsNullOrWhiteSpace(chapterId))
throw new Exception("chapterId 不能为空");
if (GetInt("SELECT COUNT(*) FROM dbo.Sys_PdfChapter WHERE ChapterId='" + SqlEsc(chapterId) + "'") == 0)
throw new Exception("章节不存在:" + chapterId);
SQLHelper.ExecutSql("UPDATE dbo.Sys_PdfChapter SET [Text]=N'" + SqlEsc(content ?? "")
+ "' WHERE ChapterId='" + SqlEsc(chapterId) + "'");
}
#endregion
#region 工具
/// <summary>SQL 字符串转义。</summary>
private static string SqlEsc(string s)
{
return (s ?? "").Replace("'", "''");
}
/// <summary>执行 SELECT 首行首列并转 int(查无返回0)。</summary>
private static int GetInt(string sql)
{
DataTable dt = SQLHelper.GetDataTableRunText(sql, new SqlParameter[] { });
if (dt == null || dt.Rows.Count == 0)
return 0;
object v = dt.Rows[0][0];
return v == DBNull.Value || v == null ? 0 : Convert.ToInt32(v);
}
/// <summary>生成业务主键(前缀+时间+随机,与页面一致)。</summary>
private static string NewId(string prefix)
{
return prefix + DateTime.Now.ToString("yyyyMMddHHmmss")
+ Guid.NewGuid().ToString("N").Substring(0, 4);
}
#endregion
}
}
+3 -1
View File
@@ -169,6 +169,7 @@
<Compile Include="API\APIUnitService.cs" />
<Compile Include="API\APIUpLoadFileService.cs" />
<Compile Include="API\APIUserService.cs" />
<Compile Include="API\APIPdfBookService.cs" />
<Compile Include="API\CQMS\ApiInspectionManagementService.cs" />
<Compile Include="API\CQMS\APIQuantityManagementService.cs" />
<Compile Include="API\CQMS\BreakdownProjectService.cs" />
@@ -818,6 +819,7 @@
<Compile Include="ErrLogInfo.cs" />
<Compile Include="FriendlyException.cs" />
<Compile Include="Common\Funs.cs" />
<Compile Include="PdfBookService.cs" />
<Compile Include="MethodRefelect.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SessionName.cs" />
@@ -1165,4 +1167,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
+202
View File
@@ -0,0 +1,202 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
namespace BLL
{
/// <summary>PDF 书籍视图模型。</summary>
public class PdfBook
{
public string BookId { get; set; }
public string Title { get; set; }
public int ChapterCount { get; set; }
public string Tag { get; set; }
}
/// <summary>PDF 章节(目录项)视图模型,支持多级目录(含父章节与层级)。</summary>
public class PdfChapter
{
public string ChapterId { get; set; }
public string BookId { get; set; }
public string ParentChapterId { get; set; } // 上一级章节,NULL=顶级
public int Level { get; set; } // 层级:1章 2节 3小节
public string Title { get; set; }
public int PageStart { get; set; }
public int PageEnd { get; set; }
public int SortNo { get; set; }
}
/// <summary>章节正文视图模型。</summary>
public class PdfChapterDetail
{
public string ChapterId { get; set; }
public string Title { get; set; }
public int PageStart { get; set; }
public int PageEnd { get; set; }
public string Content { get; set; }
}
/// <summary>
/// PDF 书籍目录/正文读取服务。
/// 优先读取数据库表 Sys_PdfBook / Sys_PdfChapter;当库无数据或未建表时,回退到内置示例数据,便于界面预览。
/// </summary>
public static class PdfBookService
{
// —— 内置示例数据(仅用于 UI 预览)——
private const string SampleBookId = "SAMPLE_SP_001";
private static readonly List<PdfBook> _sampleBooks = new List<PdfBook>
{
new PdfBook { BookId = SampleBookId, Title = "《建筑施工安全防护(示例)》", Tag = "示例数据", ChapterCount = 15 }
};
// 多级目录示例(对应真实书籍:第一章 → 1.1 → 1.2.1)
private static readonly List<PdfChapter> _sampleChapters = new List<PdfChapter>
{
Ch("CH01", "第一章 安全防护", 1, 1, 1, 1, null),
Ch("CH011", "1.1 \u201c三宝\u201d\u201c四口\u201d\u201c五临边\u201d", 1, 1, 2, 2, "CH01"),
Ch("CH012", "1.2 三宝", 1, 3, 3, 2, "CH01"),
Ch("CH0121", "1.2.1 安全帽", 1, 1, 4, 3, "CH012"),
Ch("CH0122", "1.2.2 安全带", 2, 2, 5, 3, "CH012"),
Ch("CH0123", "1.2.3 安全网", 3, 3, 6, 3, "CH012"),
Ch("CH013", "1.3 \u201c四口\u201d安全防护", 4, 6, 7, 2, "CH01"),
Ch("CH0131", "1.3.1 电梯井竖向洞口防护", 4, 4, 8, 3, "CH013"),
Ch("CH0132", "1.3.2 预留洞口安全防护", 5, 5, 9, 3, "CH013"),
Ch("CH0133", "1.3.3 通道口安全防护", 6, 6, 10, 3, "CH013"),
Ch("CH014", "1.4 \u201c五临边\u201d安全防护", 10, 12, 11, 2, "CH01"),
Ch("CH0141", "1.4.1 临边作业", 10, 10, 12, 3, "CH014"),
Ch("CH0142", "1.4.2 基坑临边防护", 10, 10, 13, 3, "CH014"),
Ch("CH0143", "1.4.3 楼层临边防护", 11, 11, 14, 3, "CH014"),
Ch("CH0144", "1.4.4 楼梯临边防护", 12, 12, 15, 3, "CH014")
};
private static readonly Dictionary<string, PdfChapterDetail> _sampleContents = new Dictionary<string, PdfChapterDetail>
{
{ "CH01", Detail("CH01", "第一章 安全防护", 1, 1, "本章为施工现场安全防护的总述,涵盖\u201c三宝\u201d\u201c四口\u201d\u201c五临边\u201d等基本防护要求。") },
{ "CH011", Detail("CH011", "1.1 \u201c三宝\u201d\u201c四口\u201d\u201c五临边\u201d", 1, 1, "本节概述安全帽、安全带、安全网\u201c三宝\u201d,简称、预留洞口等\u201c四口\u201d以及临边等\u201c五临边\u201d的防护要点。") },
{ "CH012", Detail("CH012", "1.2 三宝", 1, 3, "三宝指安全帽、安全带、安全网,是施工现场最基本的个人防护用品。") },
{ "CH0121", Detail("CH0121", "1.2.1 安全帽", 1, 1, "进入施工现场必须正确佩戴安全帽,并系紧下颏带;安全帽应符合国家标准,不得使用破损或过期的安全帽。") },
{ "CH0122", Detail("CH0122", "1.2.2 安全带", 2, 2, "高处作业应正确使用安全带,做到高挂低用,系挂在牢固可靠的结构上,严禁低挂高用。") },
{ "CH0123", Detail("CH0123", "1.2.3 安全网", 3, 3, "作业面周围应按要求张挂安全平网或立网,安全网应绑扎牢固、无破损,严禁随意拆除。") },
{ "CH013", Detail("CH013", "1.3 \u201c四口\u201d安全防护", 4, 6, "四口指楼梯口、电梯井口、预留洞口、通道口,均应设置可靠的防护设施。") },
{ "CH0131", Detail("CH0131", "1.3.1 电梯井竖向洞口防护", 4, 4, "电梯井口应设置固定式防护门,井内每隔两层并不超过10m设置一道安全平网。") },
{ "CH0132", Detail("CH0132", "1.3.2 预留洞口安全防护", 5, 5, "楼板、屋面等预留洞口应设置盖板或围挡防护,并设置警示标志。") },
{ "CH0133", Detail("CH0133", "1.3.3 通道口安全防护", 6, 6, "通道口应搭设防护棚,并设置明显的安全警示标志和夜间警示灯。") },
{ "CH014", Detail("CH014", "1.4 \u201c五临边\u201d安全防护", 10, 12, "五临边指基坑边、楼层边、屋面边、阳台边、楼梯边等临边作业场所,均应设置防护栏杆。") },
{ "CH0141", Detail("CH0141", "1.4.1 临边作业", 10, 10, "临边作业应设置防护栏杆并挂设安全网,作业人员应正确佩戴和使用安全带。") },
{ "CH0142", Detail("CH0142", "1.4.2 基坑临边防护", 10, 10, "基坑周边应设置高度不低于1.2m的防护栏杆,并设置警示与夜间警示灯。") },
{ "CH0143", Detail("CH0143", "1.4.3 楼层临边防护", 11, 11, "楼层临边应设置防护栏杆和挡脚板,严防人员坠落和物件坠落伤人。") },
{ "CH0144", Detail("CH0144", "1.4.4 楼梯临边防护", 12, 12, "楼梯临边、休息平台等部位应设置临时防护栏杆,随层随设。") }
};
private static PdfChapter Ch(string id, string title, int start, int end, int sort, int level, string parent)
{
return new PdfChapter
{
ChapterId = id, BookId = SampleBookId, Title = title,
PageStart = start, PageEnd = end, SortNo = sort, Level = level, ParentChapterId = parent
};
}
private static PdfChapterDetail Detail(string id, string title, int pageStart, int pageEnd, string content)
{
return new PdfChapterDetail { ChapterId = id, Title = title, PageStart = pageStart, PageEnd = pageEnd, Content = content };
}
/// <summary>获取书籍列表。</summary>
public static List<PdfBook> GetBooks()
{
try
{
DataTable dt = SQLHelper.GetDataTableRunText(
"SELECT BookId, Title FROM dbo.Sys_PdfBook ORDER BY CreateTime", new SqlParameter[] { });
if (dt != null && dt.Rows.Count > 0)
{
var list = new List<PdfBook>();
foreach (DataRow r in dt.Rows)
list.Add(new PdfBook
{
BookId = r["BookId"] == null ? "" : r["BookId"].ToString(),
Title = r["Title"] == null ? "" : r["Title"].ToString(),
Tag = "数据库"
});
return list;
}
}
catch (Exception)
{
// 未建表或查询失败,回退示例数据
}
return _sampleBooks;
}
/// <summary>获取某本书的章节(目录,含层级与父章节,供页面递归建树)。</summary>
public static List<PdfChapter> GetChapters(string bookId)
{
if (bookId == SampleBookId)
return _sampleChapters;
try
{
DataTable dt = SQLHelper.GetDataTableRunText(
"SELECT ChapterId, BookId, ParentChapterId, [Level], ChapterTitle, PageStart, PageEnd, SortNo " +
"FROM dbo.Sys_PdfChapter WHERE BookId=@BookId ORDER BY SortNo",
new[] { new SqlParameter("@BookId", bookId) });
var list = new List<PdfChapter>();
if (dt != null)
foreach (DataRow r in dt.Rows)
{
var c = new PdfChapter
{
ChapterId = r["ChapterId"] == null ? "" : r["ChapterId"].ToString(),
BookId = r["BookId"] == null ? "" : r["BookId"].ToString(),
ParentChapterId = r["ParentChapterId"] == DBNull.Value ? null : r["ParentChapterId"].ToString(),
Title = r["ChapterTitle"] == null ? "" : r["ChapterTitle"].ToString(),
SortNo = r["SortNo"] == DBNull.Value ? 0 : Convert.ToInt32(r["SortNo"]),
Level = r["Level"] == DBNull.Value ? 1 : Convert.ToInt32(r["Level"])
};
c.PageStart = r["PageStart"] == DBNull.Value ? 0 : Convert.ToInt32(r["PageStart"]);
c.PageEnd = r["PageEnd"] == DBNull.Value ? 0 : Convert.ToInt32(r["PageEnd"]);
list.Add(c);
}
return list;
}
catch (Exception)
{
return new List<PdfChapter>();
}
}
/// <summary>获取章节正文。</summary>
public static PdfChapterDetail GetChapterContent(string chapterId)
{
if (!string.IsNullOrWhiteSpace(chapterId) && chapterId.StartsWith("CH") && _sampleContents.ContainsKey(chapterId))
return _sampleContents[chapterId];
try
{
DataTable dt = SQLHelper.GetDataTableRunText(
"SELECT ChapterId, ChapterTitle, PageStart, PageEnd, [Text] FROM dbo.Sys_PdfChapter WHERE ChapterId=@ChapterId",
new[] { new SqlParameter("@ChapterId", chapterId) });
if (dt != null && dt.Rows.Count > 0)
{
DataRow r = dt.Rows[0];
return new PdfChapterDetail
{
ChapterId = r["ChapterId"] == null ? "" : r["ChapterId"].ToString(),
Title = r["ChapterTitle"] == null ? "" : r["ChapterTitle"].ToString(),
PageStart = r["PageStart"] == DBNull.Value ? 0 : Convert.ToInt32(r["PageStart"]),
PageEnd = r["PageEnd"] == DBNull.Value ? 0 : Convert.ToInt32(r["PageEnd"]),
Content = r["Text"] == DBNull.Value ? "" : r["Text"].ToString()
};
}
}
catch (Exception)
{
// 未建表或查询失败
}
return null;
}
}
}
+21 -43
View File
@@ -284,13 +284,7 @@ namespace BLL
}
public static ListItem[] GetUnitWork(string projectId)
{
List<Model.WBS_UnitWork> q = (from x in Funs.DB.WBS_UnitWork where x.ProjectId == projectId && x.SuperUnitWork == null orderby x.UnitWorkCode select x).ToList();
ListItem[] item = new ListItem[q.Count()];
for (int i = 0; i < q.Count(); i++)
{
item[i] = new ListItem((q[i].UnitWorkCode + "-" + q[i].UnitWorkName + GetProjectType(q[i].ProjectType)) ?? "", q[i].UnitWorkId.ToString());
}
return item;
return GetUnitWorkList(projectId);
}
public static ListItem[] GetUnitWork(string projectId,string installationId)
{
@@ -335,16 +329,9 @@ namespace BLL
Funs.FineUIPleaseSelect(dropName);
}
}
public static void InitUnitWorkDownList(FineUIPro.DropDownList dropName, string projectId,string unitId, bool isShowPlease)
public static void InitUnitWorkDownList(FineUIPro.DropDownList dropName, string projectId, string unitId, bool isShowPlease)
{
dropName.DataValueField = "Value";
dropName.DataTextField = "Text";
dropName.DataSource = BLL.UnitWorkService.GetUnitWorkList(projectId);
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
InitUnitWorkDownList(dropName, projectId, isShowPlease);
}
/// <summary>
/// 单位工程表下拉框
@@ -484,26 +471,29 @@ namespace BLL
return unitWorkName;
}
/// <summary>
/// 获取单位工程下拉列表数据源
/// </summary>
private static object GetUnitWorkDropDownSource(string projectId)
{
return from x in Funs.DB.WBS_UnitWork
where x.ProjectId == projectId && x.SuperUnitWork == null
orderby x.UnitWorkCode
select new
{
x.UnitWorkId,
UnitWorkName = GetUnitWorkALLName(x.UnitWorkId)
};
}
/// <summary>
/// 获取单位工程下拉列表
/// </summary>
/// <param name="dropName"></param>
/// <param name="projectId"></param>
/// <param name="isShowPlease"></param>
public static void InitUnitWorkDropDownList(FineUIPro.DropDownList dropName, string projectId, bool isShowPlease)
{
var unitWorks = from x in Funs.DB.WBS_UnitWork
where x.ProjectId == projectId && x.SuperUnitWork == null
orderby x.UnitWorkCode
select new
{
x.UnitWorkId,
UnitWorkName = GetUnitWorkALLName(x.UnitWorkId)
};
dropName.DataValueField = "UnitWorkId";
dropName.DataTextField = "UnitWorkName";
dropName.DataSource = unitWorks;
dropName.DataSource = GetUnitWorkDropDownSource(projectId);
dropName.DataBind();
if (isShowPlease)
{
@@ -512,25 +502,13 @@ namespace BLL
}
/// <summary>
/// 获取单位工程下拉列表
/// 获取单位工程名称下拉列表
/// </summary>
/// <param name="dropName"></param>
/// <param name="projectId"></param>
/// <param name="isShowPlease"></param>
public static void InitUnitWorkNameDropDownList(FineUIPro.DropDownList dropName, string projectId, bool isShowPlease)
{
var unitWorks = from x in Funs.DB.WBS_UnitWork
where x.ProjectId == projectId && x.SuperUnitWork == null
orderby x.UnitWorkCode
select new
{
x.UnitWorkId,
UnitWorkName = GetUnitWorkALLName(x.UnitWorkId)
};
dropName.DataValueField = "UnitWorkName";
dropName.DataTextField = "UnitWorkName";
dropName.DataSource = unitWorks;
dropName.DataSource = GetUnitWorkDropDownSource(projectId);
dropName.DataBind();
if (isShowPlease)
{
+47 -76
View File
@@ -289,6 +289,51 @@ namespace BLL
select x).FirstOrDefault();
return q;
}
/// <summary>
/// 汇总项目质量数据生成单位级CQMS汇总记录
/// </summary>
private static CQMSData_CQMS BuildCqmsSummary(string unitId, Model.Base_Unit baseUnit, List<Model.Project_CQMSData_CQMS> projectData)
{
return new CQMSData_CQMS
{
UnitId = unitId,
CollCropCode = baseUnit.CollCropCode,
UnitName = baseUnit.UnitName,
ReportDate = DateTime.Now.Date,
TrainPersonNum = projectData.Sum(x => x.TrainPersonNum),
TechnicalDisclosePersonNum = projectData.Sum(x => x.TechnicalDisclosePersonNum),
UseNum = projectData.Sum(x => x.UseNum),
OKNum = projectData.Sum(x => x.OKNum),
CompanyPersonNum = GetCompanyPersonNum(),
BranchPersonNum = GetBranchPersonNum(),
ProjectPersonNum = projectData.Sum(x => x.ProjectPersonNum),
ProblemNum = projectData.Sum(x => x.ProblemNum),
ProblemCompletedNum = projectData.Sum(x => x.ProblemCompletedNum),
ProblemNotCompletedNum = projectData.Sum(x => x.ProblemNotCompletedNum),
SNum = projectData.Sum(x => x.SNum),
ANum = projectData.Sum(x => x.ANum),
BNum = projectData.Sum(x => x.BNum),
CNum = projectData.Sum(x => x.CNum),
KeyProcessNum = projectData.Sum(x => x.KeyProcessNum),
KeyProcessOKNum = projectData.Sum(x => x.KeyProcessOKNum),
SpecialProcessNum = projectData.Sum(x => x.SpecialProcessNum),
SpecialProcessOKNum = projectData.Sum(x => x.SpecialProcessOKNum),
ConcealedWorksNum = projectData.Sum(x => x.ConcealedWorksNum),
ConcealedWorksOKNum = projectData.Sum(x => x.ConcealedWorksOKNum),
UnitProjectOnesNum = projectData.Sum(x => x.UnitProjectOnesNum),
UnitProjectOnesOKNum = projectData.Sum(x => x.UnitProjectOnesOKNum),
MaterialInRecheckNum = projectData.Sum(x => x.MaterialInRecheckNum),
MaterialInRecheckOKNum = projectData.Sum(x => x.MaterialInRecheckOKNum),
SingleProjectNum = projectData.Sum(x => x.SingleProjectNum),
UnitProjectNum = projectData.Sum(x => x.UnitProjectNum),
SubProjectNum = projectData.Sum(x => x.SubProjectNum),
SubdivisionalWorksNum = projectData.Sum(x => x.SubdivisionalWorksNum),
InspectionLotNum = projectData.Sum(x => x.InspectionLotNum),
CreateMan = Const.sysglyId,
CreateDate = DateTime.Now
};
}
public static CQMSData_CQMS GetSubUnitCqmsDataByDate(string Unitid, DateTime? reportdate)
{
@@ -302,44 +347,7 @@ namespace BLL
var ProjectData = (from x in Funs.DB.Project_CQMSData_CQMS
where x.ReportDate == reportdate && projectlist.Select(e => e.ProjectId).Contains(x.ProjectId)
select x).ToList();
result = new CQMSData_CQMS
{
UnitId = Unitid,
CollCropCode = base_Unit.CollCropCode,
UnitName = base_Unit.UnitName,
ReportDate = DateTime.Now.Date,
TrainPersonNum = ProjectData.Sum(x => x.TrainPersonNum),
TechnicalDisclosePersonNum = ProjectData.Sum(x => x.TechnicalDisclosePersonNum),
UseNum = ProjectData.Sum(x => x.UseNum),
OKNum = ProjectData.Sum(x => x.OKNum),
CompanyPersonNum = GetCompanyPersonNum(),
BranchPersonNum = GetBranchPersonNum(),
ProjectPersonNum = ProjectData.Sum(x => x.ProjectPersonNum),
ProblemNum = ProjectData.Sum(x => x.ProblemNum),
ProblemCompletedNum = ProjectData.Sum(x => x.ProblemCompletedNum),
ProblemNotCompletedNum = ProjectData.Sum(x => x.ProblemNotCompletedNum),
SNum = ProjectData.Sum(x => x.SNum),
ANum = ProjectData.Sum(x => x.ANum),
BNum = ProjectData.Sum(x => x.BNum),
CNum = ProjectData.Sum(x => x.CNum),
KeyProcessNum = ProjectData.Sum(x => x.KeyProcessNum),
KeyProcessOKNum = ProjectData.Sum(x => x.KeyProcessOKNum),
SpecialProcessNum = ProjectData.Sum(x => x.SpecialProcessNum),
SpecialProcessOKNum = ProjectData.Sum(x => x.SpecialProcessOKNum),
ConcealedWorksNum = ProjectData.Sum(x => x.ConcealedWorksNum),
ConcealedWorksOKNum = ProjectData.Sum(x => x.ConcealedWorksOKNum),
UnitProjectOnesNum = ProjectData.Sum(x => x.UnitProjectOnesNum),
UnitProjectOnesOKNum = ProjectData.Sum(x => x.UnitProjectOnesOKNum),
MaterialInRecheckNum = ProjectData.Sum(x => x.MaterialInRecheckNum),
MaterialInRecheckOKNum = ProjectData.Sum(x => x.MaterialInRecheckOKNum),
SingleProjectNum = ProjectData.Sum(x => x.SingleProjectNum),
UnitProjectNum = ProjectData.Sum(x => x.UnitProjectNum),
SubProjectNum = ProjectData.Sum(x => x.SubProjectNum),
SubdivisionalWorksNum = ProjectData.Sum(x => x.SubdivisionalWorksNum),
InspectionLotNum = ProjectData.Sum(x => x.InspectionLotNum),
CreateMan = Const.sysglyId,
CreateDate = DateTime.Now
};
result = BuildCqmsSummary(Unitid, base_Unit, ProjectData);
return result;
}
public static void UpdateTodyData_State()
@@ -396,44 +404,7 @@ namespace BLL
var ProjectData = (from x in Funs.DB.Project_CQMSData_CQMS
where x.ReportDate < DateTime.Now.AddDays(1).Date && x.ReportDate >= DateTime.Now.Date
select x).ToList();
var table = new CQMSData_CQMS
{
UnitId = thisUnitId,
CollCropCode = base_Unit.CollCropCode,
UnitName = base_Unit.UnitName,
ReportDate = DateTime.Now.Date,
TrainPersonNum = ProjectData.Sum(x => x.TrainPersonNum),
TechnicalDisclosePersonNum = ProjectData.Sum(x => x.TechnicalDisclosePersonNum),
UseNum = ProjectData.Sum(x => x.UseNum),
OKNum = ProjectData.Sum(x => x.OKNum),
CompanyPersonNum = GetCompanyPersonNum(),
BranchPersonNum = GetBranchPersonNum(),
ProjectPersonNum = ProjectData.Sum(x => x.ProjectPersonNum),
ProblemNum = ProjectData.Sum(x => x.ProblemNum),
ProblemCompletedNum = ProjectData.Sum(x => x.ProblemCompletedNum),
ProblemNotCompletedNum = ProjectData.Sum(x => x.ProblemNotCompletedNum),
SNum = ProjectData.Sum(x => x.SNum),
ANum = ProjectData.Sum(x => x.ANum),
BNum = ProjectData.Sum(x => x.BNum),
CNum = ProjectData.Sum(x => x.CNum),
KeyProcessNum = ProjectData.Sum(x => x.KeyProcessNum),
KeyProcessOKNum = ProjectData.Sum(x => x.KeyProcessOKNum),
SpecialProcessNum = ProjectData.Sum(x => x.SpecialProcessNum),
SpecialProcessOKNum = ProjectData.Sum(x => x.SpecialProcessOKNum),
ConcealedWorksNum = ProjectData.Sum(x => x.ConcealedWorksNum),
ConcealedWorksOKNum = ProjectData.Sum(x => x.ConcealedWorksOKNum),
UnitProjectOnesNum = ProjectData.Sum(x => x.UnitProjectOnesNum),
UnitProjectOnesOKNum = ProjectData.Sum(x => x.UnitProjectOnesOKNum),
MaterialInRecheckNum = ProjectData.Sum(x => x.MaterialInRecheckNum),
MaterialInRecheckOKNum = ProjectData.Sum(x => x.MaterialInRecheckOKNum),
SingleProjectNum = ProjectData.Sum(x => x.SingleProjectNum),
UnitProjectNum = ProjectData.Sum(x => x.UnitProjectNum),
SubProjectNum = ProjectData.Sum(x => x.SubProjectNum),
SubdivisionalWorksNum = ProjectData.Sum(x => x.SubdivisionalWorksNum),
InspectionLotNum = ProjectData.Sum(x => x.InspectionLotNum),
CreateMan = Const.sysglyId,
CreateDate = DateTime.Now
};
var table = BuildCqmsSummary(thisUnitId, base_Unit, ProjectData);
if (IsReportByToday())
{
table.Id = GetTodayData().Id;
+16 -82
View File
@@ -2968,10 +2968,10 @@ namespace BLL
}
/// <summary>
/// 获取一般事故数
/// 按事故等级获取在施项目事故列表
/// </summary>
/// <returns></returns>
public static List<Model.AccidentOutput> GetGeneralAccident()
/// <param name="accidentDegree">事故等级(1一般 2较大 3重大 4特别重大)</param>
private static List<Model.AccidentOutput> GetAccidentByDegree(string accidentDegree)
{
var query = from Record in Funs.DB.Accident_AccidentReport
join AccidentType in Funs.DB.Sys_Const on new { ConstValue = Record.AccidentTypeId, GroupId = "AccidentReportRegistration" } equals new { ConstValue = AccidentType.ConstValue, GroupId = AccidentType.GroupId } into AccidentTypeGroup
@@ -2980,7 +2980,7 @@ namespace BLL
from Project in ProjectGroup.DefaultIfEmpty()
join Unit in Funs.DB.Base_Unit on Record.UnitId equals Unit.UnitId into UnitGroup
from Unit in UnitGroup.DefaultIfEmpty()
where Record.AccidentDate > Const.DtmarkTime && BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDegree == "1"
where Record.AccidentDate > Const.DtmarkTime && BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDegree == accidentDegree
select new AccidentOutput
{
Id = Record.AccidentReportId,
@@ -2995,10 +2995,15 @@ namespace BLL
Info = Record.Abstract
};
var result = query.ToList();
return query.ToList();
}
return result;
/// <summary>
/// 获取一般事故数
/// </summary>
public static List<Model.AccidentOutput> GetGeneralAccident()
{
return GetAccidentByDegree("1");
}
public static async Task<List<Model.AccidentOutput>> GetGeneralAccidentAsync()
@@ -3009,33 +3014,9 @@ namespace BLL
/// <summary>
/// 获取较大事故数
/// </summary>
/// <returns></returns>
public static List<Model.AccidentOutput> GetMajorAccident()
{
var query = from Record in Funs.DB.Accident_AccidentReport
join AccidentType in Funs.DB.Sys_Const on new { ConstValue = Record.AccidentTypeId, GroupId = "AccidentReportRegistration" } equals new { ConstValue = AccidentType.ConstValue, GroupId = AccidentType.GroupId } into AccidentTypeGroup
from AccidentType in AccidentTypeGroup.DefaultIfEmpty()
join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup
from Project in ProjectGroup.DefaultIfEmpty()
join Unit in Funs.DB.Base_Unit on Record.UnitId equals Unit.UnitId into UnitGroup
from Unit in UnitGroup.DefaultIfEmpty()
where Record.AccidentDate > Const.DtmarkTime && BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDegree == "2"
select new AccidentOutput
{
Id = Record.AccidentReportId,
ProjectId = Record.ProjectId,
ProjectCode = Project.ProjectCode,
ProjectName = Project.ProjectName,
AccidentTypeName = AccidentType.ConstText,
AccidentDate = Record.AccidentDate,
UnitId = Unit.UnitId,
UnitName = Unit.UnitName,
PeopleNum = Record.PeopleNum,
Info = Record.Abstract
};
var result = query.ToList();
return result;
return GetAccidentByDegree("2");
}
public static async Task<List<Model.AccidentOutput>> GetMajorAccidentAsync()
@@ -3046,69 +3027,22 @@ namespace BLL
/// <summary>
/// 获取重大事故数
/// </summary>
/// <returns></returns>
public static List<Model.AccidentOutput> GetSeriousAccident()
{
var query = from Record in Funs.DB.Accident_AccidentReport
join AccidentType in Funs.DB.Sys_Const on new { ConstValue = Record.AccidentTypeId, GroupId = "AccidentReportRegistration" } equals new { ConstValue = AccidentType.ConstValue, GroupId = AccidentType.GroupId } into AccidentTypeGroup
from AccidentType in AccidentTypeGroup.DefaultIfEmpty()
join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup
from Project in ProjectGroup.DefaultIfEmpty()
join Unit in Funs.DB.Base_Unit on Record.UnitId equals Unit.UnitId into UnitGroup
from Unit in UnitGroup.DefaultIfEmpty()
where Record.AccidentDate > Const.DtmarkTime && BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDegree == "3"
select new AccidentOutput
{
Id = Record.AccidentReportId,
ProjectId = Record.ProjectId,
ProjectCode = Project.ProjectCode,
ProjectName = Project.ProjectName,
AccidentTypeName = AccidentType.ConstText,
AccidentDate = Record.AccidentDate,
UnitId = Unit.UnitId,
UnitName = Unit.UnitName,
PeopleNum = Record.PeopleNum,
Info = Record.Abstract
};
var result = query.ToList();
return result;
return GetAccidentByDegree("3");
}
public static async Task<List<Model.AccidentOutput>> GetSeriousAccidentAsync()
{
return await Task.Run(GetSeriousAccident);
}
/// <summary>
/// 获取特别重大事故数
/// </summary>
/// <returns></returns>
public static List<Model.AccidentOutput> GetSpecialSeriousAccident()
{
var query = from Record in Funs.DB.Accident_AccidentReport
join AccidentType in Funs.DB.Sys_Const on new { ConstValue = Record.AccidentTypeId, GroupId = "AccidentReportRegistration" } equals new { ConstValue = AccidentType.ConstValue, GroupId = AccidentType.GroupId } into AccidentTypeGroup
from AccidentType in AccidentTypeGroup.DefaultIfEmpty()
join Project in Funs.DB.Base_Project on Record.ProjectId equals Project.ProjectId into ProjectGroup
from Project in ProjectGroup.DefaultIfEmpty()
join Unit in Funs.DB.Base_Unit on Record.UnitId equals Unit.UnitId into UnitGroup
from Unit in UnitGroup.DefaultIfEmpty()
where Record.AccidentDate > Const.DtmarkTime && BeUnderConstructionList.Contains(Record.ProjectId) && Record.AccidentDegree == "4"
select new AccidentOutput
{
Id = Record.AccidentReportId,
ProjectId = Record.ProjectId,
ProjectCode = Project.ProjectCode,
ProjectName = Project.ProjectName,
AccidentTypeName = AccidentType.ConstText,
AccidentDate = Record.AccidentDate,
UnitId = Unit.UnitId,
UnitName = Unit.UnitName,
PeopleNum = Record.PeopleNum,
Info = Record.Abstract
};
var result = query.ToList();
return result;
return GetAccidentByDegree("4");
}
public static async Task<List<Model.AccidentOutput>> GetSpecialSeriousAccidentAsync()
@@ -523,173 +523,132 @@ namespace BLL
return result;
}
/// <summary>
/// 按质量控制点级别(S/A/B/C)统计数量
/// </summary>
private static int GetClassNum(string projectid, string classType)
{
return (from x in Funs.DB.WBS_BreakdownProject
where x.ProjectId == projectid && x.Class.Contains(classType) && x.IsSelected == true && x.CompileDate > Const.DtmarkTime
select x).Count();
}
/// <summary>
/// 获取S级数
/// </summary>
/// <returns></returns>
public static int GetSNum(string projectid)
{
int result = (from x in Funs.DB.WBS_BreakdownProject
where x.ProjectId == projectid && x.Class.Contains("S") && x.IsSelected == true && x.CompileDate > Const.DtmarkTime
select x).Count();
return result;
return GetClassNum(projectid, "S");
}
/// <summary>
/// 获取A级数
/// </summary>
/// <returns></returns>
public static int GetANum(string projectid)
{
int result = (from x in Funs.DB.WBS_BreakdownProject
where x.ProjectId == projectid && x.Class.Contains("A") && x.IsSelected == true && x.CompileDate > Const.DtmarkTime
select x).Count();
return result;
return GetClassNum(projectid, "A");
}
/// <summary>
/// 获取B级数
/// </summary>
/// <returns></returns>
public static int GetBNum(string projectid)
{
int result = (from x in Funs.DB.WBS_BreakdownProject
where x.ProjectId == projectid && x.Class.Contains("B") && x.IsSelected == true && x.CompileDate > Const.DtmarkTime
select x).Count();
return result;
return GetClassNum(projectid, "B");
}
/// <summary>
/// 获取C级数
/// </summary>
/// <returns></returns>
public static int GetCNum(string projectid)
{
int result = (from x in Funs.DB.WBS_BreakdownProject
where x.ProjectId == projectid && x.Class.Contains("C") && x.IsSelected == true && x.CompileDate > Const.DtmarkTime
select x).Count();
return result;
return GetClassNum(projectid, "C");
}
/// <summary>
/// 按验收类型统计验收数
/// </summary>
private static int GetInspectionNum(string projectid, string checkAcceptType)
{
return (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
where y.ProjectId == projectid && y.CheckAcceptType == checkAcceptType && x.CreateDate > Const.DtmarkTime
select x).Count();
}
/// <summary>
/// 按验收类型统计一次验收合格数
/// </summary>
private static int GetInspectionOkNum(string projectid, string checkAcceptType)
{
return (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId
where y.ProjectId == projectid && y.CheckAcceptType == checkAcceptType && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime
select x).Count();
}
/// <summary>
/// 获取关键工序验收数
/// </summary>
/// <returns></returns>
public static int GetKeyProcessNum(string projectid)
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
where y.ProjectId == projectid && y.CheckAcceptType == "1" && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
return GetInspectionNum(projectid, "1");
}
/// <summary>
/// 获取关键工序验收合格数
/// </summary>
/// <returns></returns>
public static int GetKeyProcessOkNum(string projectid)
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId
where y.ProjectId == projectid && y.CheckAcceptType == "1" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
return GetInspectionOkNum(projectid, "1");
}
/// <summary>
/// 获取特殊过程验收数
/// </summary>
/// <returns></returns>
public static int GetSpecialProcessNum(string projectid)
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
where y.ProjectId == projectid && y.CheckAcceptType == "2" && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
return GetInspectionNum(projectid, "2");
}
/// <summary>
/// 获取特殊过程验收合格数
/// </summary>
/// <returns></returns>
public static int GetSpecialProcessOkNum(string projectid)
{
var result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId
where y.ProjectId == projectid && y.CheckAcceptType == "2" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
return GetInspectionOkNum(projectid, "2");
}
/// <summary>
/// 获取隐蔽工程验收数
/// </summary>
/// <returns></returns>
public static int GetConcealedWorksNum(string projectid)
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
where y.ProjectId == projectid && y.CheckAcceptType == "3" && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
return GetInspectionNum(projectid, "3");
}
/// <summary>
/// 获取隐蔽工程验收合格数
/// </summary>
/// <returns></returns>
public static int GetConcealedWorksOkNum(string projectid)
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId
where y.ProjectId == projectid && y.CheckAcceptType == "3" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
return GetInspectionOkNum(projectid, "3");
}
/// <summary>
/// 获取单位工程一次验收数
/// </summary>
/// <returns></returns>
public static int GetUnitProjectOnesNum(string projectid)
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
where y.ProjectId == projectid && y.CheckAcceptType == "4" && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
return GetInspectionNum(projectid, "4");
}
/// <summary>
/// 获取单位工程一次验收合格数
/// </summary>
/// <returns></returns>
public static int GetUnitProjectOnesOKNum(string projectid)
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId
where y.ProjectId == projectid && y.CheckAcceptType == "4" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
return GetInspectionOkNum(projectid, "4");
}
/// <summary>
/// 获取材料进场复验数
/// </summary>
/// <returns></returns>
public static int GetMaterialInRecheckNum(string projectid)
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
where y.ProjectId == projectid && y.CheckAcceptType == "5" && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
return GetInspectionNum(projectid, "5");
}
/// <summary>
/// 获取材料进场复验合格数
/// </summary>
/// <returns></returns>
public static int GetMaterialInRecheckOKNum(string projectid)
{
int result = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.WBS_BreakdownProject on x.ControlPointType equals y.BreakdownProjectId
join z in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals z.InspectionId
where y.ProjectId == projectid && y.CheckAcceptType == "5" && z.IsOnceQualified == true && x.CreateDate > Const.DtmarkTime
select x).Count();
return result;
return GetInspectionOkNum(projectid, "5");
}
/// <summary>
/// 获取单项工程个数