班组管理岗位初始化
This commit is contained in:
parent
059e11f95d
commit
3d5d69f5bf
@ -38,6 +38,11 @@ namespace DOAN.Admin.WebApi.Controllers
|
||||
var response = _DeviceAccountService.GetList(parm);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询绑定或者未绑定巡检任务的设备台账
|
||||
/// </summary>
|
||||
|
||||
109
DOAN.Admin.WebApi/Controllers/MES/group/GroupPostController.cs
Normal file
109
DOAN.Admin.WebApi/Controllers/MES/group/GroupPostController.cs
Normal file
@ -0,0 +1,109 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using DOAN.Model.Dto;
|
||||
using DOAN.Model.MES.group;
|
||||
using DOAN.Model.MES.group.Dto;
|
||||
using DOAN.Service.group.IService;
|
||||
using DOAN.Admin.WebApi.Filters;
|
||||
|
||||
//创建时间:2024-08-07
|
||||
namespace DOAN.Admin.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 岗位
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("mes/groupManagement/GroupPost")]
|
||||
public class GroupPostController : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// 岗位接口
|
||||
/// </summary>
|
||||
private readonly IGroupPostService _GroupPostService;
|
||||
|
||||
public GroupPostController(IGroupPostService GroupPostService)
|
||||
{
|
||||
_GroupPostService = GroupPostService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询岗位列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
[ActionPermissionFilter(Permission = "groupManagement:grouppost:list")]
|
||||
public IActionResult QueryGroupPost([FromQuery] GroupPostQueryDto parm)
|
||||
{
|
||||
var response = _GroupPostService.GetList(parm);
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询岗位详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{Id}")]
|
||||
[ActionPermissionFilter(Permission = "groupManagement:grouppost:query")]
|
||||
public IActionResult GetGroupPost(string Id)
|
||||
{
|
||||
var response = _GroupPostService.GetInfo(Id);
|
||||
|
||||
var info = response.Adapt<GroupPost>();
|
||||
return SUCCESS(info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加岗位
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[ActionPermissionFilter(Permission = "groupManagement:grouppost:add")]
|
||||
[Log(Title = "岗位", BusinessType = BusinessType.INSERT)]
|
||||
public IActionResult AddGroupPost([FromBody] GroupPostDto parm)
|
||||
{
|
||||
var modal = parm.Adapt<GroupPost>().ToCreate(HttpContext);
|
||||
|
||||
var response = _GroupPostService.AddGroupPost(modal);
|
||||
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新岗位
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[ActionPermissionFilter(Permission = "groupManagement:grouppost:edit")]
|
||||
[Log(Title = "岗位", BusinessType = BusinessType.UPDATE)]
|
||||
public IActionResult UpdateGroupPost([FromBody] GroupPostDto parm)
|
||||
{
|
||||
var modal = parm.Adapt<GroupPost>().ToUpdate(HttpContext);
|
||||
var response = _GroupPostService.UpdateGroupPost(modal);
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除岗位
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{ids}")]
|
||||
[ActionPermissionFilter(Permission = "groupManagement:grouppost:delete")]
|
||||
[Log(Title = "岗位", BusinessType = BusinessType.DELETE)]
|
||||
public IActionResult DeleteGroupPost(string ids)
|
||||
{
|
||||
string[] idsArr = Tools.SpitStrArrary(ids);
|
||||
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||
|
||||
var response = _GroupPostService.RemoveGroupPost(idsArr);
|
||||
|
||||
return ToResponse(response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@
|
||||
//代码生成数据库配置
|
||||
"CodeGenDbConfig": {
|
||||
//代码生成连接字符串,注意{dbName}为固定格式,不要填写数据库名
|
||||
"Conn": "Data Source=192.168.50.163;User ID=root;Password=123456;Initial Catalog={dbName};",
|
||||
"Conn": "Data Source=192.168.0.58;User ID=root;Password=123456;Initial Catalog={dbName};",
|
||||
"DbType": 0,
|
||||
"IsAutoCloseConnection": true,
|
||||
"DbName": "GXAssembly" //代码生成默认连接数据库,Oracle库是实例的名称
|
||||
|
||||
48
DOAN.Common/TreeHelper.cs
Normal file
48
DOAN.Common/TreeHelper.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DOAN.Common
|
||||
{
|
||||
|
||||
|
||||
public class Node
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int? ParentId { get; set; }
|
||||
}
|
||||
|
||||
public static class TreeNodeHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取指定节点的所有后代节点。
|
||||
/// </summary>
|
||||
/// <param name="nodes">所有节点的集合。</param>
|
||||
/// <param name="rootId">根节点的 ID。</param>
|
||||
/// <returns>所有后代节点的列表。</returns>
|
||||
public static List<Node> GetDescendants(List<Node> nodes, int rootId)
|
||||
{
|
||||
var descendants = new List<Node>();
|
||||
|
||||
void FindChildren(Node node)
|
||||
{
|
||||
var children = nodes.Where(n => n.ParentId == node.Id).ToList();
|
||||
foreach (var child in children)
|
||||
{
|
||||
descendants.Add(child);
|
||||
FindChildren(child);
|
||||
}
|
||||
}
|
||||
|
||||
var rootNode = nodes.FirstOrDefault(n => n.Id == rootId);
|
||||
if (rootNode != null)
|
||||
{
|
||||
FindChildren(rootNode);
|
||||
}
|
||||
|
||||
return descendants;
|
||||
}
|
||||
}
|
||||
}
|
||||
41
DOAN.Model/MES/group/Dto/GroupPostDto.cs
Normal file
41
DOAN.Model/MES/group/Dto/GroupPostDto.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace DOAN.Model.MES.group.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 岗位查询对象
|
||||
/// </summary>
|
||||
public class GroupPostQueryDto : PagerInfo
|
||||
{
|
||||
public string PostName { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 岗位输入输出对象
|
||||
/// </summary>
|
||||
public class GroupPostDto
|
||||
{
|
||||
[Required(ErrorMessage = "雪花不能为空")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "父id不能为空")]
|
||||
public string ParentId { get; set; }
|
||||
|
||||
public string PostName { get; set; }
|
||||
|
||||
public int? Status { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
|
||||
public string CreatedBy { get; set; }
|
||||
|
||||
public DateTime? CreatedTime { get; set; }
|
||||
|
||||
public string UpdatedBy { get; set; }
|
||||
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
63
DOAN.Model/MES/group/GroupPost.cs
Normal file
63
DOAN.Model/MES/group/GroupPost.cs
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
namespace DOAN.Model.MES.group
|
||||
{
|
||||
/// <summary>
|
||||
/// 岗位
|
||||
/// </summary>
|
||||
[SugarTable("group_post")]
|
||||
public class GroupPost
|
||||
{
|
||||
/// <summary>
|
||||
/// 雪花
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false)]
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 父id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "parent_id")]
|
||||
public string ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 岗位名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "post_name")]
|
||||
public string PostName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 1:启用 0:停用
|
||||
/// </summary>
|
||||
public int? Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "cREATED_BY")]
|
||||
public string CreatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "cREATED_TIME")]
|
||||
public DateTime? CreatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "uPDATED_BY")]
|
||||
public string UpdatedBy { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "uPDATED_TIME")]
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
135
DOAN.Service/MES/group/GroupPostService.cs
Normal file
135
DOAN.Service/MES/group/GroupPostService.cs
Normal file
@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using DOAN.Model;
|
||||
using DOAN.Model.Dto;
|
||||
using DOAN.Model.MES.group;
|
||||
using DOAN.Model.MES.group.Dto;
|
||||
using DOAN.Repository;
|
||||
using DOAN.Service.group.IService;
|
||||
using System.Linq;
|
||||
using DOAN.Common;
|
||||
|
||||
namespace DOAN.Service.group
|
||||
{
|
||||
/// <summary>
|
||||
/// 岗位Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IGroupPostService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class GroupPostService : BaseService<GroupPost>, IGroupPostService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询岗位列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<GroupPostDto> GetList(GroupPostQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<GroupPost>()
|
||||
.AndIF(!string.IsNullOrEmpty(parm.PostName), it => it.PostName.Contains(parm.PostName));
|
||||
|
||||
;
|
||||
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage<GroupPost, GroupPostDto>(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <returns></returns>
|
||||
public GroupPost GetInfo(string Id)
|
||||
{
|
||||
var response = Queryable()
|
||||
.Where(x => x.Id == Id)
|
||||
.First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加岗位
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public GroupPost AddGroupPost(GroupPost model)
|
||||
{
|
||||
model.Id = XueHua;
|
||||
if (string.IsNullOrEmpty(model.ParentId))
|
||||
{
|
||||
model.ParentId = "0";
|
||||
}
|
||||
|
||||
return Context.Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改岗位
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateGroupPost(GroupPost model)
|
||||
{
|
||||
//var response = Update(w => w.Id == model.Id, it => new GroupPost()
|
||||
//{
|
||||
// PostName = model.PostName,
|
||||
// Status = model.Status,
|
||||
// Remark = model.Remark,
|
||||
// CreatedBy = model.CreatedBy,
|
||||
// CreatedTime = model.CreatedTime,
|
||||
// UpdatedBy = model.UpdatedBy,
|
||||
// UpdatedTime = model.UpdatedTime,
|
||||
//});
|
||||
//return response;
|
||||
return Update(model, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除岗位包括子
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public int RemoveGroupPost(string[] ids)
|
||||
{
|
||||
List<GroupPost> all_nodes = Context.Queryable<GroupPost>().ToList();
|
||||
|
||||
|
||||
List<GroupPost> Descendants = GetDescendants(all_nodes, ids[0]);
|
||||
|
||||
|
||||
List<string> children = Descendants.Select(it => it.Id).ToList();
|
||||
children.Add(ids[0]);
|
||||
|
||||
return Delete(children.ToArray());
|
||||
}
|
||||
public List<GroupPost> GetDescendants(List<GroupPost> nodes, string rootId)
|
||||
{
|
||||
var descendants = new List<GroupPost>();
|
||||
|
||||
|
||||
void FindChildren(GroupPost node)
|
||||
{
|
||||
var children = nodes.Where(n => n.ParentId == node.Id).ToList();
|
||||
foreach (var child in children)
|
||||
{
|
||||
descendants.Add(child);
|
||||
FindChildren(child);
|
||||
}
|
||||
}
|
||||
|
||||
var rootNode = nodes.FirstOrDefault(n => n.Id == rootId);
|
||||
if (rootNode != null)
|
||||
{
|
||||
FindChildren(rootNode);
|
||||
}
|
||||
|
||||
return descendants;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
DOAN.Service/MES/group/IService/IGroupPostService.cs
Normal file
26
DOAN.Service/MES/group/IService/IGroupPostService.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using DOAN.Model;
|
||||
using DOAN.Model.Dto;
|
||||
using DOAN.Model.MES.group;
|
||||
using DOAN.Model.MES.group.Dto;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DOAN.Service.group.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 岗位service接口
|
||||
/// </summary>
|
||||
public interface IGroupPostService : IBaseService<GroupPost>
|
||||
{
|
||||
PagedInfo<GroupPostDto> GetList(GroupPostQueryDto parm);
|
||||
|
||||
GroupPost GetInfo(string Id);
|
||||
|
||||
GroupPost AddGroupPost(GroupPost parm);
|
||||
|
||||
int UpdateGroupPost(GroupPost parm);
|
||||
|
||||
int RemoveGroupPost(string[] ids);
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user