From 1a814d2b0cf40234248128e5ed065141aadf8c17 Mon Sep 17 00:00:00 2001
From: geh <1923421292@qq.com>
Date: Wed, 2 Apr 2025 17:53:26 +0800
Subject: [PATCH] =?UTF-8?q?fix:=E4=BA=A4=E5=B7=A5=E8=B5=84=E6=96=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../WebAPI/Controllers/JGZL/JGZLController.cs | 282 ++++++++++++++++++
1 file changed, 282 insertions(+)
create mode 100644 SGGL/WebAPI/Controllers/JGZL/JGZLController.cs
diff --git a/SGGL/WebAPI/Controllers/JGZL/JGZLController.cs b/SGGL/WebAPI/Controllers/JGZL/JGZLController.cs
new file mode 100644
index 00000000..dbbaac30
--- /dev/null
+++ b/SGGL/WebAPI/Controllers/JGZL/JGZLController.cs
@@ -0,0 +1,282 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Web.Http;
+using Model;
+using BLL;
+
+
+namespace WebAPI.Controllers.JGZL
+{
+ public class JGZLController : ApiController
+ {
+ #region 用户基本数据,单位,项目,单位工程,签审岗位(无),机构(无)
+
+ ///
+ /// 用户基本数据,单位,项目,单位工程,签审岗位(无),机构(无)
+ ///
+ ///
+ public Model.ResponeData getUserList(string UserName,int? PageIndex,int? PageSize)
+ {
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ var getUserListQuery = from x in db.Sys_User
+ join u in db.Base_Unit on x.UnitId equals u.UnitId into uGrouped
+ from ug in uGrouped.DefaultIfEmpty()
+ select new
+ {
+ x.UserId,
+ x.Account,
+ x.UserName,
+ x.Telephone,
+ x.IdentityCard,
+ x.BirthDay,
+ x.Email,
+ x.IsPost,
+ x.Sex,
+ ug.UnitId,
+ ug.UnitName,
+ ProjectItems = from proj in db.Base_Project
+ join pu in db.Project_ProjectUser on proj.ProjectId equals pu.ProjectId
+ where pu.UserId == x.UserId
+ select new
+ {
+ proj.ProjectId,
+ proj.ProjectName,
+ pu.WorkAreaId // 假设 WorkAreaId 是 UnitWorkIds 的来源
+ }
+ };
+
+ var getList = getUserListQuery.AsEnumerable()
+ .Select(user => new UserItem
+ {
+ UserId = user.UserId,
+ Account = user.Account,
+ UserName = user.UserName,
+ Telephone = user.Telephone,
+ IdentityCard = user.IdentityCard,
+ BirthDay = user.BirthDay,
+ Email = user.Email,
+ IsPost = user.IsPost,
+ Sex = user.Sex,
+ UnitId = user.UnitId,
+ UnitName = user.UnitName,
+ ProjectItemList = user.ProjectItems.Select(projectItem => new ProjectItem
+ {
+ ProjectId = projectItem.ProjectId,
+ ProjectName = projectItem.ProjectName,
+ UnitWorkItemList = string.IsNullOrEmpty(projectItem.WorkAreaId)
+ ? new List()
+ : db.WBS_UnitWork
+ .Where(uw => projectItem.WorkAreaId.Split(',')
+ .Contains(uw.UnitWorkId))
+ .Select(uw => new UnitWorkItem
+ {
+ UnitWorkId = uw.UnitWorkId,
+ UnitWorkName = uw.UnitWorkName
+ })
+ .ToList()
+ }).ToList()
+ }).ToList();
+
+ if (!string.IsNullOrEmpty(UserName))
+ {
+ getList = getList.Where(x => x.UserName.Contains(UserName)).ToList();
+ }
+
+ if (PageIndex > 0 && PageSize > 0)
+ {
+ getList = getList.Skip(((int)PageIndex - 1) * (int)PageSize).Take((int)PageSize).ToList();
+ }
+
+ responeData.data = new { getList };
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+ return responeData;
+ }
+ }
+
+ #endregion
+
+ #region 项目数据
+
+ ///
+ /// 项目数据
+ ///
+ ///
+ public Model.ResponeData getProjedtList()
+ {
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ var getList = (from x in db.Base_Project
+ select new
+ {
+ x.ProjectId,
+ x.ProjectCode,
+ x.ProjectName,
+ x.StartDate,
+ }).ToList();
+
+ responeData.data = new { getList };
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+ return responeData;
+ }
+ }
+
+ #endregion
+
+
+ #region 根据项目获取单位工程数据
+
+ ///
+ /// 根据项目获取单位工程数据
+ ///
+ ///
+ public Model.ResponeData getUnitWorkListByProjectId(string ProjectId)
+ {
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ var getList = (from x in db.WBS_UnitWork
+ where x.ProjectId==ProjectId
+ select new
+ {
+ x.UnitWorkId,
+ x.UnitWorkName,
+ x.UnitWorkCode,
+ }).ToList();
+
+ responeData.data = new { getList };
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+ return responeData;
+ }
+ }
+
+ #endregion
+
+
+ #region 根据项目获取装置数据
+
+ ///
+ /// 根据项目获取装置数据
+ ///
+ ///
+ public Model.ResponeData getInstallationListByProjectId(string ProjectId)
+ {
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ var getList = (from x in db.Project_Installation
+ where x.ProjectId==ProjectId
+ select new
+ {
+ x.InstallationId,
+ x.InstallationName,
+ x.InstallationCode,
+ }).ToList();
+
+ responeData.data = new { getList };
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+ return responeData;
+ }
+ }
+
+ #endregion
+
+
+ #region 单位数据
+
+ ///
+ /// 单位数据
+ ///
+ ///
+ public Model.ResponeData getUnitList()
+ {
+ using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
+ {
+ var responeData = new Model.ResponeData();
+ try
+ {
+ var getList = (from x in db.Base_Unit
+ select new
+ {
+ x.UnitId,
+ x.UnitCode,
+ x.UnitName,
+ }).ToList();
+
+ responeData.data = new { getList };
+ }
+ catch (Exception ex)
+ {
+ responeData.code = 0;
+ responeData.message = ex.Message;
+ }
+ return responeData;
+ }
+ }
+
+ #endregion
+
+ public class UserItem
+ {
+ public string UserId { get; set; }
+ public string Account { get; set; }
+ public string UserName { get; set; }
+ public string Telephone { get; set; }
+ public string IdentityCard { get; set; }
+ public DateTime? BirthDay { get; set; }
+ public string Email { get; set; }
+ public System.Nullable IsPost { get; set; }
+ public string Sex { get; set; }
+ public string UnitId { get; set; }
+ public string UnitName { get; set; }
+ public List ProjectItemList { get; set; }
+
+ }
+
+ public class ProjectItem
+ {
+ public string ProjectId { get; set; }
+ public string ProjectName { get; set; }
+ public List UnitWorkItemList { get; set; }
+ }
+
+ public class UnitWorkItem
+ {
+ public string UnitWorkId { get; set; }
+ public string UnitWorkName { get; set; }
+ }
+ }
+}
\ No newline at end of file