using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.ZZDT_EC;
using Learun.Util;
using Learun.Util.SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using static Learun.Application.TwoDevelopment.ZZDT_EC.IO_WorkFlowService;
namespace Learun.Application.Web.Areas.ZZDT_EC.Controllers
{
///
/// 版 本 PIT-ADMS V7.0.3 敏捷开发框架
/// Copyright (c) 2013-2018 Hexagon PPM
/// 创 建:超级管理员
/// 日 期:2023-02-23 11:30
/// 描 述:信号通知表
///
public class ec_WireGroupNoticeController : MvcControllerBase
{
#region 视图功能
///
/// 主页面
///
///
[HttpGet]
public ActionResult Index()
{
return View();
}
#endregion
#region 获取数据
///
/// 获取列表数据
///
///
[HttpGet]
[AjaxOnly]
public ActionResult GetList(string queryJson)
{
var queryParam = queryJson.ToJObject();
string projId = queryParam["ProjectId"]?.ToString();
var NoticeTableName = ProjectSugar.TableName(projId);
var SignalTableName = ProjectSugar.TableName(projId);
//SugarRedis 需要 NET Standard 2.1,不支持Framework
var users = SqlSugarHelper.Db.Queryable().ToList();
#region 只需要对方的
var _User = users.Single(x => x.F_UserId == LoginUserInfo.Get().userId);
var _Company = SqlSugarHelper.Db.Queryable().First(x => x.F_CompanyId == _User.F_CompanyId);
var DepartmentStr = "";
Department _Department;
if (_Company != null)
{
DepartmentStr = _Company.F_FullName;
if (DepartmentStr.Contains("轮机"))
{
_Department = Department.轮机;
}
else
{
_Department = Department.电气;
}
}
else
{
_Department = Department.电气;
}
var res = SqlSugarHelper.Db.Queryable().AS(NoticeTableName).
Where(x => !string.IsNullOrEmpty(x.WireGroupID) && !x.CheckFLG).
OrderByDescending(x => x.CreateTime).
Where(x => x.CompanyID == _Department).ToList();
//Where(x => x.CompanyID == _Department).ToList();//收到本专业的通知即可
#endregion
foreach (ec_wire_group_noticeEntity noticeEntity in res)
{
var signal = SqlSugarHelper.Db.Queryable().AS(SignalTableName).First(x => x.Wire_Group_ID == noticeEntity.WireGroupID);
var user_Send = users.FirstOrDefault(x => x.F_UserId == noticeEntity?.CreateUserID);
var user_Confrim = users.FirstOrDefault(x => x.F_UserId == noticeEntity?.UpdateUserID);
if (signal != null)
{
noticeEntity.Group_Name = signal.Group_Name;
noticeEntity.Group_Desc = signal.Group_Desc;
noticeEntity.Group_Desc_EN = signal.Group_Desc_EN;
noticeEntity.IO_Type = signal.IO_Type;
noticeEntity.CreateUserName = user_Send?.F_RealName;
noticeEntity.UpdateUserName = user_Confrim?.F_RealName;
noticeEntity.Action = noticeEntity.ActionID.ToString();
}
else
{
//信号都没了
noticeEntity.WireGroupID = "-1";
}
}
return Success(res.Where(x => !string.IsNullOrEmpty(x.Group_Name) || x.WireGroupID != "-1").ToList());
}
#endregion
#region 提交数据
///
/// 已读
/// 主键
///
///
[HttpPost]
[AjaxOnly]
public ActionResult Read(string ProjectId, string keyValue)
{
var bll = new ec_Wire_GroupBLL();
List NoticeIds = new List();
NoticeIds.Add(keyValue);
var res = bll.ReadNotification(ProjectId, NoticeIds);
return Success("OK");
}
///
/// 保存实体数据(新增、修改)
/// 主键
///
///
[HttpPost]
[AjaxOnly]
public ActionResult Reads(string ProjectId, List NoticeIds)
{
var bll = new ec_Wire_GroupBLL();
var res = bll.ReadNotification(ProjectId, NoticeIds);
return Success("全部已阅!");
}
#endregion
}
}