hwh
2024-07-02 34bfa7df61921f7d1798fc08db0b8d81828da96b
Wms/Wms/Controllers/BasisController.cs
@@ -422,15 +422,10 @@
        /// <param name="DepartmentNo">部门号</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetDepartmentList(string DepartmentName, string DepartmentNo)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<List<DepartmentDto>> GetDepartmentList(string DepartmentName, string DepartmentNo)
        {
            List<DepartmentDto> departmentlist = _department.GetDepartmentList(DepartmentName, DepartmentNo);
            return Ok(new
            {
                data = departmentlist,
                code = 0,
                msg = "获取部门信息列表成功"
            });
            return await _department.GetDepartmentList(DepartmentName, DepartmentNo);
        }
        /// <summary>
@@ -439,15 +434,10 @@
        /// <param name="id">部门id</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetDepartmentById(int id)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<SysDepartment> GetDepartmentById(int id)
        {
            SysDepartment department = _department.GetDepartmentById(id);
            return Ok(new
            {
                data = department,
                msg = "成功",
                code = 0
            });
            return await _department.GetDepartmentById(id);
        }
        /// <summary>
@@ -457,56 +447,19 @@
        /// <returns></returns>
        /// <exception cref="Exception">捕获异常</exception>
        [HttpPost]
        public async Task<IActionResult> AddDepartment(DepartmentDto departmentdto)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        [UnitOfWork]
        public async Task AddDepartment(DepartmentDto departmentdto)
        {
            //捕获异常
            try
            await _department.AddDepartment(departmentdto);
            await _operation.InsertOperation(new OperationInputVm()
            {
                //获取当前操作用户id
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                int uid = Convert.ToInt32(userId);
                //更改人
                departmentdto.CreateUser = uid;
                int i = await _department.AddDepartment(departmentdto);
                //判断是否新增成功
                if (i == 0)
                {
                    return Ok(new
                    {
                        data = i,
                        code = 1,
                        msg = "新增失败"
                ParentName = "基础信息",
                MenuName = "部门管理",
                FkNo = departmentdto.DepartmentNo,
                TypeName = "添加",
                Msg = "添加部门信息 部门号:" + departmentdto.DepartmentNo
                    });
                }
                else if (i == 3)
                {
                    return Ok(new
                    {
                        data = i,
                        code = 3,
                        msg = "部门号必须唯一"
                    });
                }
                else
                {
                    await _operation.InsertOperation("基础信息", "部门管理", departmentdto.DepartmentNo, "添加", "添加部门信息 部门号:" + departmentdto.DepartmentNo, uid);
                    return Ok(new
                    {
                        data = i,
                        code = 0,
                        msg = "新增成功"
                    });
                }
            }
            catch (Exception ex)
            {
                //抛出异常
                throw new Exception("新增部门异常", ex);
            }
        }
        /// <summary>
@@ -516,46 +469,20 @@
        /// <returns></returns>
        /// <exception cref="Exception">捕获异常</exception>
        [HttpGet]
        public async Task<IActionResult> DelDepartment(int Id)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        [UnitOfWork]
        public async Task DelDepartment(int Id)
        {
            //捕获异常
            try
            SysDepartment department = await _department.GetDepartmentById(Id);
            await _department.DelDepartment(department);
            await _operation.InsertOperation(new OperationInputVm()
            {
                SysDepartment department = _department.GetDepartmentById(Id);
                //获取当前操作用户id
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                int uid = Convert.ToInt32(userId);
                //更改人
                department.UpdateUser = uid;
                int i = await _department.DelDepartment(department);
                //判断是否删除成功
                if (i == 0)
                {
                    return Ok(new
                    {
                        data = i,
                        code = 1,
                        msg = "删除失败"
                ParentName = "基础信息",
                MenuName = "部门管理",
                FkNo = department.DepartmentNo,
                TypeName = "删除",
                Msg = "删除部门信息 部门号:" + department.DepartmentNo
                    });
                }
                else
                {
                    await _operation.InsertOperation("基础信息", "部门管理", department.DepartmentNo, "删除", "删除部门信息 部门号:" + department.DepartmentNo, uid);
                    return Ok(new
                    {
                        data = i,
                        code = 0,
                        msg = "删除成功"
                    });
                }
            }
            catch (Exception ex)
            {
                //抛出异常
                throw new Exception("删除部门异常", ex);
            }
        }
        /// <summary>
@@ -565,44 +492,19 @@
        /// <returns></returns>
        /// <exception cref="Exception">捕获异常</exception>
        [HttpPost]
        public async Task<IActionResult> ExitDepartment(DepartmentDto departmentdto)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        [UnitOfWork]
        public async Task ExitDepartment(DepartmentDto departmentdto)
        {
            //捕获异常
            try
            await _department.ExitDepartment(departmentdto);
            await _operation.InsertOperation(new OperationInputVm()
            {
                //获取当前操作用户id
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                int uid = Convert.ToInt32(userId);
                //更改人
                departmentdto.UpdateUser = uid;
                int i = await _department.ExitDepartment(departmentdto);
                //判断是否编辑成功
                if (i == 0)
                {
                    return Ok(new
                    {
                        data = i,
                        code = 1,
                        msg = "编辑失败"
                ParentName = "基础信息",
                MenuName = "部门管理",
                FkNo = departmentdto.DepartmentNo,
                TypeName = "编辑",
                Msg = "编辑部门信息 部门号:" + departmentdto.DepartmentNo
                    });
                }
                else
                {
                    await _operation.InsertOperation("基础信息", "部门管理", departmentdto.DepartmentNo, "修改", "编辑部门信息 部门号:" + departmentdto.DepartmentNo, uid);
                    return Ok(new
                    {
                        data = i,
                        code = 0,
                        msg = "编辑成功"
                    });
                }
            }
            catch (Exception ex)
            {
                //抛出异常
                throw new Exception("编辑部门异常", ex);
            }
        }
        #endregion
@@ -617,15 +519,10 @@
        /// <param name="GroupNo">组号</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetFunSettingList(string FunSetName, string IsEnable, string GroupNo)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<List<FunSettingDto>> GetFunSettingList(string FunSetName, string IsEnable, string GroupNo)
        {
            List<FunSettingDto> settinglist = _setting.GetFunSettingList(FunSetName, IsEnable, GroupNo);
            return Ok(new
            {
                data = settinglist,
                code = 0,
                msg = "成功"
            });
            return await _setting.GetFunSettingList(FunSetName, IsEnable, GroupNo);
        }
        /// <summary>
@@ -634,15 +531,10 @@
        /// <param name="id">功能id</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetFunSettingById(int id)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<SysFunSetting> GetFunSettingById(int id)
        {
            SysFunSetting settinglist = _setting.GetFunSettingById(id);
            return Ok(new
            {
                data = settinglist,
                code = 0,
                msg = "成功"
            });
            return await _setting.GetFunSettingById(id);
        }
        /// <summary>
@@ -651,18 +543,10 @@
        /// <param name="funSetNo">功能编号</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetFunSettingByNo(string funSetNo)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<SysFunSetting> GetFunSettingByNo(string funSetNo)
        {
            try
            {
                var models = _setting.GetFunSettingByNo(funSetNo);
                return Ok(new { code = 0, msg = "功能设定信息", data = models });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
            return await _setting.GetFunSettingByNo(funSetNo);
        }
        /// <summary>
        /// 新增功能信息
@@ -671,80 +555,19 @@
        /// <returns></returns>
        /// <exception cref="Exception">捕获异常</exception>
        [HttpPost]
        public async Task<IActionResult> AddFunSettings(FunSettingDto settingdto)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        [UnitOfWork]
        public async Task AddFunSettings(FunSettingDto settingdto)
        {
            //捕获异常
            try
            await _setting.AddFunSettings(settingdto);
            await _operation.InsertOperation(new OperationInputVm()
            {
                //获取当前操作用户id
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                int uid = Convert.ToInt32(userId);
                //创建人
                settingdto.CreateUser = uid;
                //新增
                int i = await _setting.AddFunSettings(settingdto);
                //判断是否新增成功
                if (i == 0)
                {
                    return Ok(new
                    {
                        data = i,
                        code = 1,
                        msg = "失败"
                ParentName = "系统设置",
                MenuName = "功能设定",
                FkNo = settingdto.FunSetNo,
                TypeName = "添加",
                Msg = "添加功能设定 功能号:" + settingdto.FunSetNo
                    });
                }
                else if (i == 3)
                {
                    return Ok(new
                    {
                        data = i,
                        code = 3,
                        msg = "功能号必须唯一"
                    });
                }
                else if (i == 4)
                {
                    return Ok(new
                    {
                        data = i,
                        code = 4,
                        msg = "显示顺序范围为1---5"
                    });
                }
                else if (i == 5)
                {
                    return Ok(new
                    {
                        data = i,
                        code = 5,
                        msg = "请输入正确组号"
                    });
                }
                else if (i == 6)
                {
                    return Ok(new
                    {
                        data = i,
                        code = 6,
                        msg = "每一组只能开启一个功能"
                    });
                }
                else
                {
                    await _operation.InsertOperation("系统设置", "功能设定", settingdto.FunSetNo, "添加", "添加功能设定 功能号:" + settingdto.FunSetNo, uid);
                    return Ok(new
                    {
                        data = i,
                        code = 0,
                        msg = "成功"
                    });
                }
            }
            catch (Exception ex)
            {
                return Ok(new { data = "", code = 1, msg = "新增功能异常:" + ex.Message });
            }
        }
        /// <summary>
@@ -754,46 +577,20 @@
        /// <returns></returns>
        /// <exception cref="Exception">捕获异常</exception>
        [HttpGet]
        public async Task<IActionResult> DelFunSettings(int id)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        [UnitOfWork]
        public async Task DelFunSettings(int id)
        {
            //捕获异常
            try
            SysFunSetting funSetting = await _setting.GetFunSettingById(id);
            await _setting.DelFunSettings(funSetting);
            await _operation.InsertOperation(new OperationInputVm()
            {
                SysFunSetting funSetting = _setting.GetFunSettingById(id);
                //获取当前操作用户id
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                int uid = Convert.ToInt32(userId);
                //更改人
                funSetting.UpdateUser = uid;
                //删除
                int i = await _setting.DelFunSettings(funSetting);
                //判断是否删除成功
                if (i == 0)
                {
                    return Ok(new
                    {
                        data = i,
                        code = 1,
                        msg = "失败"
                ParentName = "系统设置",
                MenuName = "功能设定",
                FkNo = funSetting.FunSetNo,
                TypeName = "删除",
                Msg = "删除功能设定 功能号:" + funSetting.FunSetNo
                    });
                }
                else
                {
                    await _operation.InsertOperation("系统设置", "功能设定", funSetting.FunSetNo, "删除", "删除功能设定 功能号:" + funSetting.FunSetNo, uid);
                    return Ok(new
                    {
                        data = i,
                        code = 0,
                        msg = "成功"
                    });
                }
            }
            catch (Exception ex)
            {
                //抛出异常
                throw new Exception("删除功能异常", ex);
            }
        }
        /// <summary>
@@ -803,79 +600,24 @@
        /// <returns></returns>
        /// <exception cref="Exception">捕获异常</exception>
        [HttpPost]
        public async Task<IActionResult> ExitFunSettings(FunSettingDto settingdto)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        [UnitOfWork]
        public async Task ExitFunSettings(FunSettingDto settingdto)
        {
            //捕获异常
            try
            await _setting.ExitFunSettings(settingdto);
            await _operation.InsertOperation(new OperationInputVm()
            {
                //获取当前操作用户id
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                int uid = Convert.ToInt32(userId);
                //更改人
                settingdto.UpdateUser = uid;
                //编辑
                int i = await _setting.ExitFunSettings(settingdto);
                //判断是否编辑成功
                if (i == 0)
                {
                    return Ok(new
                    {
                        data = i,
                        code = 1,
                        msg = "失败"
                ParentName = "系统设置",
                MenuName = "功能设定",
                FkNo = settingdto.FunSetNo,
                TypeName = "编辑",
                Msg = "修改功能设定 功能号:" + settingdto.FunSetNo
                    });
                }
                else if (i == 6)
                {
                    return Ok(new
                    {
                        data = i,
                        code = 6,
                        msg = "每一组只能开启一个功能"
                    });
                }
                else
                {
                    await _operation.InsertOperation("系统设置", "功能设定", settingdto.FunSetNo, "修改", "修改功能设定 功能号:" + settingdto.FunSetNo, uid);
                    return Ok(new
                    {
                        data = i,
                        code = 0,
                        msg = "成功"
                    });
                }
            }
            catch (Exception ex)
            {
                return Ok(new { data = "", code = 1, msg = "编辑功能异常:" + ex.Message });
            }
        }
        #endregion
        #region 物料管理
        ///// <summary>
        ///// 查询物料信息
        ///// </summary>
        ///// <param name="matevm">物料编码视图模型</param>
        ///// <returns></returns>
        //[HttpPost]
        //public IActionResult GetMaterialsList(GetMaterialsVm matevm)
        //{
        //    try
        //    {
        //        var bolls = _mate.GetMaterialsList(matevm.SkuNo, matevm.SkuName, matevm.Type, matevm.IsInspect, matevm.Page, matevm.Limit, out int count);
        //        return Ok(new { code = 0, count, msg = "物料信息", data = bolls });
        //    }
        //    catch (Exception e)
        //    {
        //        return Ok(new { code = 1, msg = e.Message });
        //    }
        //}
        #region yyk
@@ -894,15 +636,10 @@
        /// <param name="categoryNo">类别编码</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetMateList(string skuNo, string skuName, string auditStatusNo, string type, string isControlled, string isInspect, string environment, string categoryNo)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<List<MaterialsDto>> GetMateList(string skuNo, string skuName, string auditStatusNo, string type, string isControlled, string isInspect, string environment, string categoryNo)
        {
            List<MaterialsDto> matedto = _mate.GetMateList(skuNo, skuName, auditStatusNo, type, isControlled, isInspect, environment, categoryNo);
            return Ok(new
            {
                data = matedto,
                code = 0,
                msg = "成功"
            });
            return await _mate.GetMateList(skuNo, skuName, auditStatusNo, type, isControlled, isInspect, environment, categoryNo);
        }
        /// <summary>
@@ -911,15 +648,10 @@
        /// <param name="id">物料id</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetMateById(int id)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<SysMaterials> GetMateById(int id)
        {
            SysMaterials mate = _mate.GetMateById(id);
            return Ok(new
            {
                data = mate,
                code = 0,
                msg = "成功"
            });
            return await _mate.GetMateById(id);
        }
        /// <summary>
@@ -927,31 +659,19 @@
        /// </summary>
        /// <param name="matedto">物料dto</param>
        /// <returns></returns>
        /// <exception cref="Exception">捕获异常</exception>
        [HttpPost]
        public async Task<IActionResult> AddMate(MaterialsDto matedto)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task AddMate(MaterialsDto matedto)
        {
            //捕获异常
            try
            await _mate.AddMate(matedto);
            await _operation.InsertOperation(new OperationInputVm()
            {
                //获取当前操作用户id
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                int uid = Convert.ToInt32(userId);
                //创建人
                matedto.CreateUser = uid;
                //新增
                int i = await _mate.AddMate(matedto);
                await _operation.InsertOperation("基础信息", "物料管理", matedto.SkuNo, "添加", "添加物料信息 物料号:" + matedto.SkuNo, uid);
                return Ok(new { data = i, code = 0, msg = "成功" });
            }
            catch (Exception ex)
            {
                //抛出异常
                return Ok(new { code = 1, msg = "新增物料异常" + ex.Message });
            }
                ParentName = "基础信息",
                MenuName = "物料管理",
                FkNo = matedto.SkuNo,
                TypeName = "添加",
                Msg = "添加物料信息 物料号:" + matedto.SkuNo
            });
        }
        /// <summary>
@@ -961,45 +681,19 @@
        /// <returns></returns>
        /// <exception cref="Exception">捕获异常</exception>
        [HttpGet]
        public async Task<IActionResult> DelMate(int id)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task DelMate(int id)
        {
            //捕获异常
            try
            SysMaterials mate = await _mate.GetMateById(id);
            await _mate.DelMate(mate);
            await _operation.InsertOperation(new OperationInputVm()
            {
                SysMaterials mate = _mate.GetMateById(id);
                //获取当前操作用户id
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                int uid = Convert.ToInt32(userId);
                mate.UpdateUser = uid;
                //删除
                int i = await _mate.DelMate(mate);
                //判断是否删除成功
                if (i == 0)
                {
                    return Ok(new
                    {
                        data = i,
                        code = 1,
                        msg = "失败"
                ParentName = "基础信息",
                MenuName = "物料管理",
                FkNo = mate.SkuNo,
                TypeName = "删除",
                Msg = "删除物料信息 物料号:" + mate.SkuNo
                    });
                }
                else
                {
                    await _operation.InsertOperation("基础信息", "物料管理", mate.SkuNo, "删除", "删除物料信息 物料号:" + mate.SkuNo, uid);
                    return Ok(new
                    {
                        data = i,
                        code = 0,
                        msg = "成功"
                    });
                }
            }
            catch (Exception ex)
            {
                //抛出异常
                throw new Exception("删除物料异常", ex);
            }
        }
        /// <summary>
@@ -1009,43 +703,18 @@
        /// <returns></returns>
        /// <exception cref="Exception">捕获异常</exception>
        [HttpPost]
        public async Task<IActionResult> ExitMate(MaterialsDto matedto)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task ExitMate(MaterialsDto matedto)
        {
            //捕获异常
            try
            await _mate.ExitMate(matedto);
            await _operation.InsertOperation(new OperationInputVm()
            {
                //获取当前操作用户id
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                int uid = Convert.ToInt32(userId);
                //更新人
                matedto.UpdateUser = uid;
                //编辑
                int i = await _mate.ExitMate(matedto);
                //判断是否编辑成功
                if (i == 0)
                {
                    return Ok(new { data = i, code = 1, msg = "修改失败" });
                }
                else if (i == 2)
                {
                    return Ok(new { data = i, code = 2, msg = "临期天数不可大于365及小于30" });
                }
                //else if (i == 4)
                //{
                //    return Ok(new { data = i, code = 4, msg = "低库存不可高于1000" });
                //}
                else
                {
                    await _operation.InsertOperation("基础信息", "物料管理", matedto.SkuNo, "修改", "编辑物料信息 物料号:" + matedto.SkuNo, uid);
                    return Ok(new { data = i, code = 0, msg = "修改成功" });
                }
            }
            catch (Exception ex)
            {
                //抛出异
                return Ok(new { code = 1, msg = "编辑物料异常" + ex.Message });
            }
                ParentName = "基础信息",
                MenuName = "物料管理",
                FkNo = matedto.SkuNo,
                TypeName = "编辑",
                Msg = "编辑物料信息 物料号:" + matedto.SkuNo
            });
        }
        #region 包装 单位
@@ -1055,15 +724,10 @@
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetUnitList()
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<List<SysUnit>> GetUnitList()
        {
            List<SysUnit> unitlist = _mate.GetUnitList();
            return Ok(new
            {
                data = unitlist,
                code = 0,
                msg = "成功"
            });
            return await _mate.GetUnitList();
        }
        /// <summary>
@@ -1071,15 +735,10 @@
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetPackagList()
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<List<SysPackag>> GetPackagList()
        {
            List<SysPackag> packlist = _mate.GetPackagList();
            return Ok(new
            {
                data = packlist,
                code = 0,
                msg = "成功"
            });
            return await _mate.GetPackagList();
        }
        #endregion