using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Mvc;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Security.Claims;
|
using System.Threading.Tasks;
|
using Microsoft.AspNetCore.Authorization;
|
using Model.ModelDto.SysDto;
|
using Model.ModelVm;
|
using WMS.Entity;
|
using WMS.Entity.SysEntity;
|
using WMS.IBLL.ISysServer;
|
using SqlSugar;
|
using Model.ModelVm.SysVm;
|
using Microsoft.Extensions.FileSystemGlobbing.Internal.PathSegments;
|
using Utility.Tools;
|
using WMS.IBLL.ILogServer;
|
using WMS.Entity.LogEntity;
|
using System.Security.Cryptography;
|
using System.Data;
|
using Model.ModelDto.LogDto;
|
using Utility;
|
using Model.ModelVm.LogVm;
|
using System.Diagnostics;
|
|
namespace Wms.Controllers
|
{
|
[Route("api/[controller]/[action]")]
|
[ApiController]
|
[Authorize]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
public class BasisController : ControllerBase
|
{
|
/// <summary>
|
/// 依赖注入
|
/// </summary>
|
private readonly ICustomerServer _customerSvc;//客户Svc
|
private readonly ILogisticsInfoServer _logisticsSvc;//物流Svc
|
private readonly IUnitServer _unitSvc;//单位Svc
|
private readonly IPackagServer _packagSvc; // 包装
|
private readonly IMaterialsServer _mate; // 包装
|
private readonly IUserInforServer _userInforServer; //用户
|
private readonly IRolesServer _rolesServer; //角色
|
private readonly IRoleRightServer _roleRightServer; //角色权限
|
private readonly IRBACServer _rBACServer; //RBAC
|
private readonly IDepartmentServer _department; //部门
|
private readonly IFunSettingServer _setting; //功能设定
|
private readonly IInterfaceServer _interface;//接口管理
|
private readonly IOperationSysServer _operation; //操作日志
|
private readonly UserManager _userManager;
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
/// <param name="customerSvc">客户</param>
|
/// <param name="logisticsSvc">物流</param>
|
/// <param name="userInforServer">用户</param>
|
/// <param name="rolesServer">角色</param>
|
/// <param name="roleRightServer">角色权限</param>
|
/// <param name="rBACServer">RBAC</param>
|
/// <param name="unitSvc">单位</param>
|
/// <param name="mate">物料</param>
|
/// <param name="department">部门</param>
|
/// <param name="setting">功能设定</param>
|
/// <param name="operation">操作日志</param>
|
public BasisController(ICustomerServer customerSvc, ILogisticsInfoServer logisticsSvc, IUserInforServer userInforServer,
|
IRolesServer rolesServer, IRoleRightServer roleRightServer, IRBACServer rBACServer, IUnitServer unitSvc,
|
IPackagServer packagServer, IMaterialsServer mate, IDepartmentServer department, IFunSettingServer setting,
|
IInterfaceServer interfaceS, IOperationSysServer operation, UserManager userManager)
|
{
|
_customerSvc = customerSvc;//客户Svc
|
_logisticsSvc = logisticsSvc;//物流Svc
|
_userInforServer = userInforServer;//用户
|
_rolesServer = rolesServer;//角色
|
_roleRightServer = roleRightServer;//角色权限
|
_rBACServer = rBACServer;//RBAC
|
_unitSvc = unitSvc;//单位
|
_packagSvc = packagServer; // 包装
|
_mate = mate; //物料
|
_department = department;//部门
|
_setting = setting; //功能设定
|
_interface = interfaceS;//接口管理
|
_operation = operation; //操作日志
|
_userManager = userManager;
|
}
|
//基本信息管理
|
|
#region 用户管理
|
|
#region 用户管理
|
|
/// <summary>
|
/// 获取用户角色信息
|
/// </summary>
|
/// <param name="UserName">登录名称</param>
|
/// <param name="DepartmentNo">部门号</param>
|
/// <param name="RoleNo">角色号</param>
|
/// <param name="Status">状态</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<UserInfoDto>> GetUserRoleList(string UserName, string DepartmentNo, string RoleNo, string Status)
|
{
|
return await _userInforServer.GetUserRoleList(UserName, DepartmentNo, RoleNo, Status);
|
}
|
|
/// <summary>
|
/// 根据id获取用户信息列表
|
/// </summary>
|
/// <param name="id">用户id</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<SysUserInfor> GetUserinfoListById(int id)
|
{
|
return await _userInforServer.GetUserInfoById(id);
|
}
|
|
|
/// <summary>
|
/// 新增用户信息
|
/// </summary>
|
/// <param name="UserInfoDto">用户dto模型</param>
|
/// <returns></returns>
|
/// <exception cref="System.Exception">捕获异常</exception>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task InsertUserinfo(UserInfoDto UserInfoDto)
|
{
|
await _userInforServer.InsertUserInfo(UserInfoDto);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "用户管理",
|
FkNo = UserInfoDto.UserNo,
|
TypeName = "添加",
|
Msg = "添加用户信息 用户号:" + UserInfoDto.UserNo
|
});
|
}
|
|
|
/// <summary>
|
/// 删除\批删用户信息
|
/// </summary>
|
/// <param name="userids">用户id</param>
|
/// <returns></returns>
|
/// <exception cref="System.Exception">异常</exception>
|
[HttpGet]
|
[UnitOfWork]
|
public async Task DeleteUserInfo(int userids)
|
{
|
//获取用户信息
|
SysUserInfor user = await _userInforServer.GetUserInfoById(userids);
|
await _userInforServer.DeleteUserinfo(user);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "用户管理",
|
FkNo = user.UserNo,
|
TypeName = "删除",
|
Msg = "删除用户信息 用户号:" + user.UserNo
|
});
|
}
|
|
|
/// <summary>
|
/// 编辑用户信息
|
/// </summary>
|
/// <param name="userdto">用户dto模型</param>
|
/// <returns></returns>
|
/// <exception cref="System.Exception">捕获异常</exception>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task UpdateUserinfo(UserInfoDto userdto)
|
{
|
await _userInforServer.UpdateUserinfo(userdto);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "用户管理",
|
FkNo = userdto.UserNo,
|
TypeName = "编辑",
|
Msg = "修改用户信息 用户号:" + userdto.UserNo
|
});
|
}
|
|
|
#endregion
|
|
#region 修改密码
|
|
///// <param name="userId">用户id</param>
|
/// <summary>
|
/// 修改用户密码
|
/// </summary>
|
/// <param name="pwdOld">原密码</param>
|
/// <param name="pwdNew">新密码</param>
|
/// <param name="pwdNewTwo">确认密码</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
[HttpGet]
|
public async Task UptUserPassWord(string pwdOld, string pwdNew, string pwdNewTwo/*, int userId*/)
|
{
|
pwdOld = Md5Tools.CalcMd5(pwdOld);
|
pwdNew = Md5Tools.CalcMd5(pwdNew);
|
//pwdNewTwo = Md5Tools.CalcMd5(pwdNewTwo);
|
//获取当前操作用户id
|
SysUserInfor user = await _userInforServer.GetUserInfoById(_userManager.UserId);
|
if (user == null)
|
throw Oops.Bah("找不到用户信息");
|
if (user.PassWord != pwdOld)
|
throw Oops.Bah("原密码不正确");
|
//修改密码
|
int i = await _userInforServer.UptUserPassWord(pwdNew, pwdNewTwo, _userManager.UserId);
|
if (i <= 0)
|
throw Oops.Bah("修改密码失败");
|
}
|
/// <summary>
|
/// x天后提醒用户修改密码
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<int> IsPassWordTime()
|
{
|
return await _userInforServer.IsPassWordTime(_userManager.UserId);
|
}
|
#endregion
|
|
#endregion
|
|
#region 角色管理
|
|
/// <summary>
|
/// 查询角色信息列表
|
/// </summary>
|
/// <param name="RoleNo">角色号</param>
|
/// <param name="RoleName">角色名称</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<RoleDto>> GetRolesList(string RoleNo, string RoleName)
|
{
|
return await _rolesServer.GetRoleList(RoleNo, RoleName);
|
}
|
|
/// <summary>
|
/// 根据id获取角色信息列表
|
/// </summary>
|
/// <param name="roleid">角色id</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<SysRoles> GetRolesListById(int roleid)
|
{
|
return await _rolesServer.GetRoleInfoById(roleid);
|
}
|
|
/// <summary>
|
/// 新增角色信息
|
/// </summary>
|
/// <param name="roledto">角色dto</param>
|
/// <returns></returns>
|
/// <exception cref="System.Exception">捕获异常</exception>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task InsertRoleInfo(RoleDto roledto)
|
{
|
await _rolesServer.InsertRoleInfo(roledto);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "角色权限",
|
FkNo = roledto.RoleNo,
|
TypeName = "添加",
|
Msg = "添加角色信息 角色号:" + roledto.RoleNo
|
});
|
}
|
|
/// <summary>
|
/// 删除角色信息
|
/// </summary>
|
/// <param name="roleids">角色id</param>
|
/// <returns></returns>
|
/// <exception cref="System.Exception"></exception>
|
[HttpGet]
|
[UnitOfWork]
|
public async Task DeleteRoleInfo(int roleids)
|
{
|
//根据角色id获取角色信息
|
SysRoles role = await _rolesServer.GetRoleInfoById(roleids);
|
await _rolesServer.DeleteRoleInfo(role);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "角色权限",
|
FkNo = role.RoleNo,
|
TypeName = "删除",
|
Msg = "删除角色信息 角色号:" + role.RoleNo
|
});
|
}
|
|
/// <summary>
|
/// 编辑角色信息
|
/// </summary>
|
/// <param name="role">角色实体模型</param>
|
/// <returns></returns>
|
/// <exception cref="System.Exception">捕获异常</exception>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task UpdateRolesInfo(SysRoles role)
|
{
|
await _rolesServer.UpdateRoleInfo(role);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "角色权限",
|
FkNo = role.RoleNo,
|
TypeName = "编辑",
|
Msg = "修改角色信息 角色号:" + role.RoleNo
|
});
|
}
|
|
#endregion
|
|
#region 角色权限管理
|
|
/// <summary>
|
/// 根据角色id获取当前所拥有权限
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<FunctionMenuDto>> GetRBACLists(int id)
|
{
|
return await _rBACServer.GetMenuByroleIdNew(id);
|
}
|
|
|
/// <summary>
|
/// 根据角色id获取当前所拥有权限
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<FunctionMenuDto>> GetRoleRightRBAC(int id, string MenuNo)
|
{
|
return await _rBACServer.GetRoleRightRBAC(MenuNo, _userManager.UserId.ToString());
|
}
|
|
/// <summary>
|
/// 根据角色id获取当前所拥有权限
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<RoleRightDto>> GetRoleRightLists(int id)
|
{
|
return await _rBACServer.GetRoleRightList(id);
|
}
|
|
/// <summary>
|
/// 获取角色权限信息列表
|
/// 多表:角色权限、角色、菜单
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<RoleRightDto>> GetRoleRightList()
|
{
|
Stopwatch stopwatch = new Stopwatch();
|
stopwatch.Start();
|
var model = await _roleRightServer.GetRoleMenuList();
|
stopwatch.Stop();
|
|
var time = stopwatch.ElapsedMilliseconds;
|
return model;
|
}
|
|
/// <summary>
|
/// 获取角色权限信息列表(单表)
|
/// </summary>
|
/// <param name="id">角色权限id</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<SysRoleRight>> GetRoleRightOneListById(int id)
|
{
|
return await _roleRightServer.GetRoleRightOneListById(id);
|
}
|
|
/// <summary>
|
/// 分配角色权限信息
|
/// </summary>
|
/// <param name="MenuNo">菜单号</param>
|
/// <param name="id">角色id</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task InsertRoleRight(string MenuNo, int id)
|
{
|
//根据Id获取角色号
|
SysRoles roles = await _rolesServer.GetRoleInfoById(id);
|
//保存角色权限信息
|
await _roleRightServer.InsertRoleRight(MenuNo, roles.RoleNo);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "角色权限",
|
FkNo = roles.RoleNo,
|
TypeName = "编辑",
|
Msg = "分配角色权限 角色号:" + roles.RoleNo
|
});
|
}
|
|
#endregion
|
|
#region 部门管理
|
|
/// <summary>
|
/// 获取部门信息列表
|
/// </summary>
|
/// <param name="DepartmentName">部门名称</param>
|
/// <param name="DepartmentNo">部门号</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<DepartmentDto>> GetDepartmentList(string DepartmentName, string DepartmentNo)
|
{
|
return await _department.GetDepartmentList(DepartmentName, DepartmentNo);
|
}
|
|
/// <summary>
|
/// 根据id获取部门信息
|
/// </summary>
|
/// <param name="id">部门id</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<SysDepartment> GetDepartmentById(int id)
|
{
|
return await _department.GetDepartmentById(id);
|
}
|
|
/// <summary>
|
/// 新增部门信息
|
/// </summary>
|
/// <param name="departmentdto">部门dto</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task AddDepartment(DepartmentDto departmentdto)
|
{
|
await _department.AddDepartment(departmentdto);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "基础信息",
|
MenuName = "部门管理",
|
FkNo = departmentdto.DepartmentNo,
|
TypeName = "添加",
|
Msg = "添加部门信息 部门号:" + departmentdto.DepartmentNo
|
});
|
}
|
|
/// <summary>
|
/// 删除部门信息
|
/// </summary>
|
/// <param name="Id">部门id</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
[HttpGet]
|
[UnitOfWork]
|
public async Task DelDepartment(int Id)
|
{
|
SysDepartment department = await _department.GetDepartmentById(Id);
|
await _department.DelDepartment(department);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "基础信息",
|
MenuName = "部门管理",
|
FkNo = department.DepartmentNo,
|
TypeName = "删除",
|
Msg = "删除部门信息 部门号:" + department.DepartmentNo
|
});
|
}
|
|
/// <summary>
|
/// 编辑部门信息
|
/// </summary>
|
/// <param name="departmentdto">部门dto</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task ExitDepartment(DepartmentDto departmentdto)
|
{
|
await _department.ExitDepartment(departmentdto);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "基础信息",
|
MenuName = "部门管理",
|
FkNo = departmentdto.DepartmentNo,
|
TypeName = "编辑",
|
Msg = "编辑部门信息 部门号:" + departmentdto.DepartmentNo
|
});
|
}
|
|
#endregion
|
|
#region 功能设定
|
|
/// <summary>
|
/// 获取功能设定信息列表
|
/// </summary>
|
/// <param name="FunSetName">功能名称</param>
|
/// <param name="IsEnable">开启状态</param>
|
/// <param name="GroupNo">组号</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<FunSettingDto>> GetFunSettingList(string FunSetName, string IsEnable, string GroupNo)
|
{
|
return await _setting.GetFunSettingList(FunSetName, IsEnable, GroupNo);
|
}
|
|
/// <summary>
|
/// 根据id查询功能设定信息
|
/// </summary>
|
/// <param name="id">功能id</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<SysFunSetting> GetFunSettingById(int id)
|
{
|
return await _setting.GetFunSettingById(id);
|
}
|
|
/// <summary>
|
/// 根据编号查询功能设定消息
|
/// </summary>
|
/// <param name="funSetNo">功能编号</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<SysFunSetting> GetFunSettingByNo(string funSetNo)
|
{
|
return await _setting.GetFunSettingByNo(funSetNo);
|
}
|
/// <summary>
|
/// 新增功能信息
|
/// </summary>
|
/// <param name="settingdto">功能设定dto</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task AddFunSettings(FunSettingDto settingdto)
|
{
|
await _setting.AddFunSettings(settingdto);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "功能设定",
|
FkNo = settingdto.FunSetNo,
|
TypeName = "添加",
|
Msg = "添加功能设定 功能号:" + settingdto.FunSetNo
|
});
|
}
|
|
/// <summary>
|
/// 删除功能信息
|
/// </summary>
|
/// <param name="id">功能id</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
[HttpGet]
|
[UnitOfWork]
|
public async Task DelFunSettings(int id)
|
{
|
SysFunSetting funSetting = await _setting.GetFunSettingById(id);
|
await _setting.DelFunSettings(funSetting);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "功能设定",
|
FkNo = funSetting.FunSetNo,
|
TypeName = "删除",
|
Msg = "删除功能设定 功能号:" + funSetting.FunSetNo
|
});
|
}
|
|
/// <summary>
|
/// 编辑功能信息
|
/// </summary>
|
/// <param name="settingdto">功能设定dto</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task ExitFunSettings(FunSettingDto settingdto)
|
{
|
await _setting.ExitFunSettings(settingdto);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "功能设定",
|
FkNo = settingdto.FunSetNo,
|
TypeName = "编辑",
|
Msg = "修改功能设定 功能号:" + settingdto.FunSetNo
|
});
|
}
|
|
#endregion
|
|
#region 物料管理
|
|
#region yyk
|
|
#region wms
|
|
/// <summary>
|
/// 获取物料信息列表
|
/// </summary>
|
/// <param name="skuNo">物料编码</param>
|
/// <param name="skuName">物料名称</param>
|
/// <param name="auditStatusNo">审核状态</param>
|
/// <param name="type">类型</param>
|
/// <param name="isControlled">是否受控</param>
|
/// <param name="isInspect">是否免检</param>
|
/// <param name="environment">存储环境</param>
|
/// <param name="categoryNo">类别编码</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<MaterialsDto>> GetMateList(string skuNo, string skuName, string auditStatusNo, string type, string isControlled, string isInspect, string environment, string categoryNo)
|
{
|
return await _mate.GetMateList(skuNo, skuName, auditStatusNo, type, isControlled, isInspect, environment, categoryNo);
|
}
|
|
/// <summary>
|
/// 根据id查询物料信息
|
/// </summary>
|
/// <param name="id">物料id</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<SysMaterials> GetMateById(int id)
|
{
|
return await _mate.GetMateById(id);
|
}
|
|
/// <summary>
|
/// 新增物料信息
|
/// </summary>
|
/// <param name="matedto">物料dto</param>
|
/// <returns></returns>
|
[HttpPost]
|
public async Task AddMate(MaterialsDto matedto)
|
{
|
await _mate.AddMate(matedto);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "基础信息",
|
MenuName = "物料管理",
|
FkNo = matedto.SkuNo,
|
TypeName = "添加",
|
Msg = "添加物料信息 物料号:" + matedto.SkuNo
|
});
|
}
|
|
/// <summary>
|
/// 删除物料信息
|
/// </summary>
|
/// <param name="id">物料id</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
[HttpGet]
|
public async Task DelMate(int id)
|
{
|
SysMaterials mate = await _mate.GetMateById(id);
|
await _mate.DelMate(mate);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "基础信息",
|
MenuName = "物料管理",
|
FkNo = mate.SkuNo,
|
TypeName = "删除",
|
Msg = "删除物料信息 物料号:" + mate.SkuNo
|
});
|
}
|
|
/// <summary>
|
/// 编辑物料信息
|
/// </summary>
|
/// <param name="matedto">物料dto</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
[HttpPost]
|
public async Task ExitMate(MaterialsDto matedto)
|
{
|
await _mate.ExitMate(matedto);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "基础信息",
|
MenuName = "物料管理",
|
FkNo = matedto.SkuNo,
|
TypeName = "编辑",
|
Msg = "编辑物料信息 物料号:" + matedto.SkuNo
|
});
|
}
|
|
#region 包装 单位
|
|
/// <summary>
|
/// 获取计量单位信息列表
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<SysUnit>> GetUnitList()
|
{
|
return await _mate.GetUnitList();
|
}
|
|
/// <summary>
|
/// 获取包装信息列表
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<SysPackag>> GetPackagList()
|
{
|
return await _mate.GetPackagList();
|
}
|
|
#endregion
|
|
#endregion
|
|
#region erp
|
|
/// <summary>
|
/// 获取erp数据
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
public IActionResult GetERPList()
|
{
|
List<ERPTestDto> list = _mate.GetERPList();
|
return Ok(new
|
{
|
data = list,
|
msg = "成功",
|
code = 0
|
});
|
}
|
|
/// <summary>
|
/// 根据id获取erp数据
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
public IActionResult GetERPListById(int id)
|
{
|
SysERPTest erp = _mate.GetERPListById(id);
|
return Ok(new
|
{
|
data = erp,
|
msg = "成功",
|
code = 0
|
});
|
}
|
|
/// <summary>
|
/// 新增erp数据
|
/// </summary>
|
/// <param name="erpdto">erp测试dto</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
[HttpPost]
|
public async Task<IActionResult> AddERP(ERPTestDto erpdto)
|
{
|
//捕获异常
|
try
|
{
|
//获取当前操作用户id
|
var claimsIdentity = this.User.Identity as ClaimsIdentity;
|
var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
|
int uid = Convert.ToInt32(userId);
|
//创建人
|
erpdto.CreateUser = uid;
|
//新增
|
int i = await _mate.AddERP(erpdto);
|
//判断是否新增成功
|
if (i == 0)
|
{
|
return Ok(new
|
{
|
data = i,
|
code = 1,
|
msg = "失败"
|
});
|
}
|
else if (i == 3)
|
{
|
return Ok(new
|
{
|
data = i,
|
code = 3,
|
msg = "物料号必须唯一"
|
});
|
}
|
else
|
{
|
return Ok(new
|
{
|
data = i,
|
code = 0,
|
msg = "成功"
|
});
|
}
|
}
|
catch (Exception ex)
|
{
|
//抛出异常
|
throw new Exception("新增erp异常", ex);
|
}
|
}
|
|
/// <summary>
|
/// 删除erp信息
|
/// </summary>
|
/// <param name="erpdto">erp测试dto</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
[HttpPost]
|
public async Task<int> DelERP(ERPTestDto erpdto)
|
{
|
//捕获异常
|
try
|
{
|
//根据id获取数据
|
SysERPTest erp = _mate.GetERPListById(erpdto.Id);
|
// 获取当前操作用户id
|
var claimsIdentity = this.User.Identity as ClaimsIdentity;
|
var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
|
int uid = Convert.ToInt32(userId);
|
erp.UpdateUser = uid;
|
//删除
|
int i = await _mate.DelERP(erp);
|
return i;
|
}
|
catch (Exception ex)
|
{
|
//抛出异常
|
throw new Exception("删除erp异常", ex);
|
}
|
}
|
|
/// <summary>
|
/// 编辑erp数据
|
/// </summary>
|
/// <param name="erpdto">erp测试dto</param>
|
/// <returns></returns>
|
/// <exception cref="Exception">捕获异常</exception>
|
[HttpPost]
|
public async Task<IActionResult> EditERP(ERPTestDto erpdto)
|
{
|
//捕获异常
|
try
|
{
|
//获取当前操作用户id
|
var claimsIdentity = this.User.Identity as ClaimsIdentity;
|
var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
|
int uid = Convert.ToInt32(userId);
|
//创建人
|
erpdto.UpdateUser = uid;
|
//新增
|
int i = await _mate.EditERP(erpdto);
|
//判断是否编辑成功
|
if (i == 0)
|
{
|
return Ok(new
|
{
|
data = i,
|
code = 1,
|
msg = "失败"
|
});
|
}
|
else
|
{
|
return Ok(new
|
{
|
data = i,
|
code = 0,
|
msg = "成功"
|
});
|
}
|
}
|
catch (Exception ex)
|
{
|
//抛出异常
|
throw new Exception("编辑erp异常", ex);
|
}
|
}
|
|
#endregion
|
|
#endregion
|
|
|
#endregion
|
|
#region 客户管理
|
/// <summary>
|
/// 查询客户信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public async Task<SqlSugarPagedList> GetCustomerList(GetCustomerVm model)
|
{
|
RefAsync<int> count = new RefAsync<int>();
|
var bolls = await _customerSvc.GetCustomerList(model.CustomerNo, model.CustomerName, model.Type, model.LinkMan, model.Phone, model.Page, model.Limit, count);
|
return new SqlSugarPagedList() { Items = bolls, Total = count };
|
}
|
/// <summary>
|
/// 查询单条客户信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public async Task<SysCustomer> GetCustomer(IdVm model)
|
{
|
return await _customerSvc.GetCustomer(model.Id);
|
}
|
/// <summary>
|
/// 查询全部客户信息
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<SysCustomer>> GetCustomerSelect()
|
{
|
return await _customerSvc.GetCustomerSelect();
|
}
|
/// <summary>
|
/// 添加客户信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task AddCustomer(AddCustomerVm model)
|
{
|
await _customerSvc.AddCustomer(model.CustomerNo, model.CustomerName, model.Type, model.Address, model.LinkMan, model.Phone, model.BankAccount, model.CreditRating, model.Demo, _userManager.UserId);
|
await _operation.InsertOperation("基础信息", "客户管理", model.CustomerNo, "添加", "添加客户信息 客户号:" + model.CustomerNo, _userManager.UserId);
|
}
|
/// <summary>
|
/// 编辑客户信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task EditCustomer(EditCustomerVm model)
|
{
|
await _customerSvc.EditCustomer(model.Id, model.CustomerNo, model.CustomerName, model.Type, model.Address, model.LinkMan, model.Phone, model.BankAccount, model.CreditRating, model.Demo, _userManager.UserId);
|
await _operation.InsertOperation("基础信息", "客户管理", model.CustomerNo, "编辑", "编辑客户信息 客户号:" + model.CustomerNo, _userManager.UserId);
|
}
|
/// <summary>
|
/// 删除客户信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task DelCustomer(IdVm model)
|
{
|
SysCustomer customer = await _customerSvc.GetCustomer(model.Id);
|
var bolls = await _customerSvc.DelCustomer(model.Id, _userManager.UserId);
|
await _operation.InsertOperation("基础信息", "客户管理", customer.CustomerNo, "删除", "删除客户信息 客户号:" + customer.CustomerNo, _userManager.UserId);
|
}
|
/// <summary>
|
/// 删除客户信息(多删除)
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task DelsCustomer(IdVm model)
|
{
|
await _customerSvc.DelsCustomer(model.Ids, _userManager.UserId);
|
}
|
#endregion
|
|
#region 物流信息管理
|
/// <summary>
|
/// 查询物流信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public async Task<SqlSugarPagedList> GetLogisticsInfoList(GetLogisticsInfoVm model)
|
{
|
RefAsync<int> count = new RefAsync<int>();
|
var list = await _logisticsSvc.GetLogisticsInfoList(model.CarrierName, model.LinkMan, model.Phone, model.LicensePlate, model.Type, model.Page, model.Limit, count);
|
return new SqlSugarPagedList() { Items = list, Total = count };
|
}
|
/// <summary>
|
/// 查询单条物流信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public async Task<SysLogisticsInfo> GetLogisticsInfo(IdVm model)
|
{
|
return await _logisticsSvc.GetLogisticsInfo(model.Id);
|
}
|
/// <summary>
|
/// 查询全部物流信息
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<SysLogisticsInfo>> GetLogisticsInfoSelect()
|
{
|
return await _logisticsSvc.GetLogisticsInfoSelect();
|
}
|
|
/// <summary>
|
/// 添加物流信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task AddLogisticsInfo(AddLogisticsInfoVm model)
|
{
|
await _logisticsSvc.AddLogisticsInfo(model, _userManager.UserId);
|
await _operation.InsertOperation("基础信息", "物流管理", model.CarrierName, "添加", "添加物流信息 公司名称:" + model.CarrierName, _userManager.UserId);
|
}
|
/// <summary>
|
/// 编辑物流信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task EditLogisticsInfo(EditLogisticsInfoVm model)
|
{
|
await _logisticsSvc.EditLogisticsInfo(model, _userManager.UserId);
|
await _operation.InsertOperation("基础信息", "物流管理", model.CarrierName, "编辑", "编辑物流信息 公司名称:" + model.CarrierName, _userManager.UserId);
|
}
|
/// <summary>
|
/// 删除物流信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task DelLogisticsInfo(IdVm model)
|
{
|
await _logisticsSvc.DelLogisticsInfo(model.Id, _userManager.UserId);
|
SysLogisticsInfo logisit = await _logisticsSvc.GetLogisticsDelInfo(model.Id);
|
await _operation.InsertOperation("基础信息", "物流管理", logisit.CarrierName, "删除", "删除物流信息 公司名称:" + logisit.CarrierName, _userManager.UserId);
|
}
|
/// <summary>
|
/// 删除物流信息(多条信息)
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task DelsLogisticsInfo(IdVm model)
|
{
|
await _logisticsSvc.DelsLogisticsInfo(model.Ids, _userManager.UserId);
|
}
|
#endregion
|
|
#region 计量单位管理
|
|
/// <summary>
|
/// 查询计量单位信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public async Task<SqlSugarPagedList> GetUnitList(GetUnitVm model)
|
{
|
RefAsync<int> count = new RefAsync<int>();
|
var list = await _unitSvc.GetUnitList(model.UnitNo, model.UnitName, model.Page, model.Limit, count);
|
return new SqlSugarPagedList() { Items = list, Total = count };
|
}
|
/// <summary>
|
/// 查询单条单位信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public async Task<SysUnit> GetUnit(IdVm model)
|
{
|
return await _unitSvc.GetUnit(model.Id);
|
}
|
/// <summary>
|
/// 添加计量信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task AddUnit(AddEditUnitVm model)
|
{
|
if (ModelState.IsValid)
|
{
|
await _unitSvc.AddUnit(model.UnitName, model.Abbrev, _userManager.UserId);
|
}
|
else
|
{
|
throw Oops.Bah("数据格式错误");
|
}
|
|
}
|
/// <summary>
|
/// 编辑计量单位信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task EditUnit(AddEditUnitVm model)
|
{
|
if (ModelState.IsValid)
|
{
|
await _unitSvc.EditUnit(model.Id, model.UnitName, model.Abbrev, _userManager.UserId);
|
SysUnit unit = await _unitSvc.GetUnit(model.Id);
|
await _operation.InsertOperation("基础信息", "计量单位", unit.UnitNo, "编辑", "编辑计量单位 单位名称:" + unit.UnitNo, _userManager.UserId);
|
}
|
else
|
{
|
throw Oops.Bah("数据格式错误");
|
}
|
|
}
|
/// <summary>
|
/// 删除计量单位信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task DelUnit(IdVm model)
|
{
|
await _unitSvc.DelUnit(model.Id, _userManager.UserId);
|
}
|
/// <summary>
|
/// 删除计量单位信息(多删除)
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task DelsUnit(IdVm model)
|
{
|
var bolls = await _unitSvc.DelsUnit(model.Ids, _userManager.UserId);
|
}
|
#endregion
|
|
#region 包装管理
|
|
/// <summary>
|
/// 查询包装信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public async Task<SqlSugarPagedList> GetPackagList(GetPackagVm model)
|
{
|
RefAsync<int> count = new RefAsync<int>();
|
var list = await _packagSvc.GetPackagList(model.PackagNo, model.PackagName, model.Level, model.Page, model.Limit, count);
|
return new SqlSugarPagedList { Items = list, Total = count };
|
}
|
|
/// <summary>
|
/// 根据id获取包装信息
|
/// </summary>
|
/// <param name="id">包装id</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<SysPackag> GetPackagById(int id)
|
{
|
return await _packagSvc.GetPackagById(id);
|
}
|
|
/// <summary>
|
/// 添加包装信息
|
/// </summary>
|
/// <param name="model">包装信息</param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task AddPackag(AddEditPackagVm model)
|
{
|
await _packagSvc.AddPackag(model);
|
await _operation.InsertOperation("基础信息", "包装管理", model.PackagNo, "添加", "添加包装信息 包装编号:" + model.PackagNo, _userManager.UserId);
|
}
|
|
/// <summary>
|
/// 编辑包装信息
|
/// </summary>
|
/// <param name="model">包装信息</param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task EditPackag(AddEditPackagVm model)
|
{
|
await _packagSvc.EditPackag(model);
|
await _operation.InsertOperation("基础信息", "包装管理", model.PackagNo, "编辑", "编辑包装信息 包装编号:" + model.PackagNo, _userManager.UserId);
|
}
|
|
/// <summary>
|
/// 逻辑删除包装信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task DelPackag(AddEditPackagVm model)
|
{
|
await _packagSvc.DelPackag(model.Id, _userManager.UserId);
|
await _operation.InsertOperation("基础信息", "包装管理", model.PackagNo, "删除", "删除包装信息 包装编号:" + model.PackagNo, _userManager.UserId);
|
}
|
#endregion
|
|
#region 系统操作日志
|
|
/// <summary>
|
/// 获取操作日志信息列表
|
/// </summary>
|
/// <returns></returns>
|
[HttpPost]
|
public async Task<SqlSugarPagedList> GetSysOperationList(GetOperationVm model)
|
{
|
return await _operation.GetSysOperationList(model);
|
}
|
|
/// <summary>
|
/// 获取类型菜单
|
/// </summary>
|
/// <param name="dicName">字典名称</param>
|
/// <returns></returns>
|
[HttpGet]
|
public async Task<List<SysDictionary>> GetDicTypeList(string dicName)
|
{
|
return await _operation.GetDicTypeList(dicName);
|
}
|
|
#endregion
|
|
#region 接口管理
|
/// <summary>
|
/// 获取接口列表
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public async Task<SqlSugarPagedList> GetInterfaceList(InterfaceVm model)
|
{
|
return await _interface.GetInterfaceList(model);
|
}
|
|
/// <summary>
|
/// 获取接口明细列表
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public async Task<SqlSugarPagedList> GetInterfaceDetailList(InterfaceDetailVm model)
|
{
|
return await _interface.GetInterfaceDetailList(model);
|
}
|
|
/// <summary>
|
/// 添加接口信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task AddInterface(InterfaceVm model)
|
{
|
await _interface.AddInterface(model);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "接口管理",
|
FkNo = model.InterfaceNo,
|
TypeName = "添加",
|
Msg = $"添加了接口编号为{model.InterfaceNo}的接口信息"
|
});
|
}
|
|
/// <summary>
|
/// 编辑接口信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task EditInterface(InterfaceVm model)
|
{
|
await _interface.EditInterface(model);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "接口管理",
|
FkNo = model.InterfaceNo,
|
TypeName = "编辑",
|
Msg = $"编辑了接口编号为{model.InterfaceNo}的接口信息"
|
});
|
}
|
|
/// <summary>
|
/// 删除接口信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task DelInterface(InterfaceVm model)
|
{
|
await _interface.DelInterface(model);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "接口管理",
|
FkNo = model.InterfaceNo,
|
TypeName = "编辑",
|
Msg = $"删除了接口编号为{model.InterfaceNo}的接口信息"
|
});
|
}
|
|
/// <summary>
|
/// 删除接口明细信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
public async Task DelInterfaceDetail(InterfaceDetailVm model)
|
{
|
await _interface.DelInterfaceDetail(model);
|
await _operation.InsertOperation(new OperationInputVm()
|
{
|
ParentName = "系统设置",
|
MenuName = "接口管理",
|
FkNo = model.InterfaceNo,
|
TypeName = "编辑",
|
Msg = $"删除了接口编号为{model.InterfaceNo}的接口信息,本系统字段为{model.Field}的接口信息"
|
});
|
}
|
#endregion
|
}
|
}
|