009_DI-Elec/Learun.Application.Web/AppApi/NotificationApiController.cs

147 lines
5.1 KiB
C#
Raw Normal View History

2025-08-13 11:14:39 +08:00
using System;
using System.Collections.Generic;
using System.Data.Entity.Core.Metadata.Edm;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Web.Http;
using Common.Logging;
using Learun.Application.Base.SystemModule;
using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.ZZDT_EC;
using Learun.Loger;
using Learun.Util;
using Learun.Util.Operat;
using Learun.Util.SqlSugar;
using log4net.Config;
using Pipelines.Sockets.Unofficial.Arenas;
namespace Learun.Application.Web.AppApi
{
/// <summary>
/// 通知消息的接口By YuXH
/// </summary>
[RoutePrefix("api/NotificationApi")]
[HandlerApiLogin(FilterMode.Ignore)]
public class NotificationApiController : WebApiControllerBase
{
#region
/// <summary>
/// 为图纸最新的一个检入记录发起通知
/// </summary>
/// <param name="ProjectId"></param>
/// <param name="Users">用户之间逗号分开</param>
/// <param name="DrawingID"></param>
/// <returns></returns>
[HttpGet]
[HandlerApiLogin(FilterMode.Enforce)]
public IHttpActionResult Add(string ProjectId, string Users, string DrawingID)
{
var synRecord = new ec_drawing_synBLL().GetList(ProjectId, DrawingID, null);
2025-08-13 11:14:39 +08:00
var LatestSyn = synRecord.OrderByDescending(x => x.CreateTime).FirstOrDefault();
if (LatestSyn != null)
{
foreach (var userName in Users.Replace("|", ",").Replace("", ",").Split(','))
{
ec_notificationEntity ec_NotificationEntity = new ec_notificationEntity
{
SenderUserID = LoginUserInfo.Get().realName,
RetrieveUserID = userName,
DrawingSynID = LatestSyn.DrawingSynID,
CheckFLG = 0
};
new ec_notificationBLL().SaveEntity("", ec_NotificationEntity, ProjectId);
}
}
return Success("OK");
}
/// <summary>
/// 获取某一个用户所有的未读通知
/// </summary>
/// <param name="ProjectId"></param>
/// <param name="User">当前用户</param>
/// <param name="mode">0接收到的信息1发出去的信息</param>
/// <returns></returns>
[HttpGet]
[HandlerApiLogin(FilterMode.Ignore)]
public IHttpActionResult GetUserAllNotification(string ProjectId, string User, int mode = 0)
{
if (mode == 0)
{
var res = new ec_notificationBLL().GetUserAllNotification(ProjectId, User);
return Success(res);
}
else
{
var res = new ec_notificationBLL().GetUserSendOutNotification(ProjectId, User);
return Success(res);
}
}
/// <summary>
/// 批量确认消息
/// </summary>
/// <param name="ProjectId"></param>
/// <param name="IDs">多个主键,逗号隔开</param>
/// <returns></returns>
[HttpGet]
[HandlerApiLogin(FilterMode.Enforce)]
public IHttpActionResult ApproveNofity(string ProjectId, string IDs)
{
IDs = WebHelper.UrlDecode(IDs);
new ec_notificationBLL().Approve(IDs, ProjectId);
return Success("OK");
}
#endregion
#region
/// <summary>
/// 获取所有图纸,需要生产确认的检入记录
/// </summary>
/// <param name="projectId">项目ID</param>
/// <param name="drawingFileID">图纸文件ID</param>
/// <returns></returns>
[HttpGet]
public IHttpActionResult GetCheckInLogNeedApprove(string projectId)
{
try
{
var listDrawingSyn = new ec_drawing_synBLL().GetList(projectId, "", 1);
2025-08-13 11:14:39 +08:00
return Success(listDrawingSyn.GroupBy(x => x.DrawingFileID).ToList());
}
catch (Exception ex)
{
return Fail(ex.Message);
}
}
/// <summary>
/// 批量确认捡入记录里需要生产主管确认的
/// </summary>
/// <param name="ProjectId"></param>
/// <param name="userId">主管人的用户id</param>
/// <param name="IDs">DrawingSynID,逗号隔开</param>
/// <returns></returns>
[HttpGet]
[HandlerApiLogin(FilterMode.Enforce)]
public IHttpActionResult ApproveCheckInLog(string ProjectId, string userId, string IDs)
{
var tbName = ProjectSugar.TableName<ec_drawing_synEntity>(ProjectId);
SqlSugarHelper.Db.Updateable<ec_drawing_synEntity>().AS(tbName)
.SetColumns(x => x.ApproveByAdmin == 1)
.SetColumns(x => x.UpdateUserID == userId)
.Where(x => IDs.Split(',').Contains(x.DrawingSynID))
.ExecuteCommand();
return Success("OK");
}
#endregion
}
}