| | |
| | | using System.Security.Cryptography; |
| | | using Model.ModelDto; |
| | | using Model.ModelDto.LogDto; |
| | | using Newtonsoft.Json.Linq; |
| | | |
| | | namespace Wms.Controllers |
| | | { |
| | |
| | | private readonly IOperationSysServer _operation; //操作日志 |
| | | private readonly IExceptionServer _table; //异常处理 |
| | | private readonly IHeaderSettingsServer _headerSet;//表头设置 |
| | | |
| | | private readonly IMaterialCategoryServer _category;//物料类别 |
| | | |
| | | /// <summary> |
| | | /// 构造函数 |
| | | /// </summary> |
| | |
| | | /// <param name="dic">数据字典</param> |
| | | /// <param name="operation">操作日志</param> |
| | | /// <param name="table">异常处理</param> |
| | | public SysController(IWareHouseServer wareHouseSvc, IStorageAreaServer areaSvc, IStorageRoadwayServer roadwaySvc, IStorageLocatServer locatSvc, IPalletsServer palletSvc, IPalletTrackServer palletTrackSvc, IMenuServer menuSvc, IDictionaryServer dic, IOperationSysServer operation, IExceptionServer table, IHeaderSettingsServer headerSet) |
| | | /// <param name="category">物料类别</param> |
| | | public SysController(IWareHouseServer wareHouseSvc, IStorageAreaServer areaSvc, IStorageRoadwayServer roadwaySvc, IStorageLocatServer locatSvc, IPalletsServer palletSvc, IPalletTrackServer palletTrackSvc, IMenuServer menuSvc, IDictionaryServer dic, IOperationSysServer operation, IExceptionServer table, IHeaderSettingsServer headerSet, IMaterialCategoryServer category) |
| | | { |
| | | _wareHouseSvc = wareHouseSvc; //仓库 |
| | | _areaSvc = areaSvc; //区域 |
| | |
| | | _table = table; //异常处理 |
| | | |
| | | _headerSet = headerSet;//表头设置 |
| | | _category = category;//物料类别 |
| | | } |
| | | |
| | | #region 菜单管理 |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return Ok(new { data = "", code = 3, msg = "新增菜单信息异常:"+ ex.Message }); |
| | | return Ok(new { data = "", code = 3, msg = "新增菜单信息异常:" + ex.Message }); |
| | | } |
| | | |
| | | } |
| | |
| | | return Ok(new { code = 1, msg = e.Message }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加区域信息 |
| | | /// </summary> |
| | | /// <param name="model">模型</param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public IActionResult InsertStorageArea(SysStorageArea model) |
| | | { |
| | | try |
| | | { |
| | | //获取当前登录的用户ID |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | if (claimsIdentity == null) |
| | | { |
| | | return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); |
| | | } |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | if (string.IsNullOrWhiteSpace(userId)) |
| | | { |
| | | return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); |
| | | } |
| | | model.CreateUser = int.Parse(userId); |
| | | string bolls = _areaSvc.InsertStorageArea(model); |
| | | var arr = bolls.Split(":"); |
| | | if (arr[0] != "-1") |
| | | { |
| | | SysStorageArea area = _areaSvc.GetStorageMaxArea(); |
| | | _operation.InsertOperation("仓库设置", "区域管理", area.AreaNo, "添加", "添加区域信息 区域号:" + area.AreaNo, Convert.ToInt32(userId)); |
| | | return Ok(new { code = 0, msg = bolls, data = "" }); |
| | | } |
| | | else |
| | | { |
| | | return Ok(new { code = 1, msg = bolls, data = "" }); |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return Ok(new { code = 1, msg = e.Message }); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 修改区域信息 |
| | | /// </summary> |
| | |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 添加储位信息 |
| | | /// 添加立体库储位信息 |
| | | /// </summary> |
| | | /// <param name="model">模型</param> |
| | | /// <returns></returns> |
| | |
| | | return Ok(new { code = 400, ErrorMsg = "数据格式错误" }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加平库储位信息 |
| | | /// </summary> |
| | | /// <param name="model">模型</param> |
| | | /// <returns></returns> |
| | | [AllowAnonymous] |
| | | [HttpPost] |
| | | public async Task<IActionResult> AddPkStorageLocat(AddLocateVm model) |
| | | { |
| | | if (ModelState.IsValid) |
| | | { |
| | | try |
| | | { |
| | | //获取当前登录的用户ID |
| | | //var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | //if (claimsIdentity == null) |
| | | //{ |
| | | // return Ok(new { code = 400, ErrorMsg = "为获取到当前操作人信息" }); |
| | | //} |
| | | //var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | //if (string.IsNullOrWhiteSpace(userId)) |
| | | //{ |
| | | // return Ok(new { code = 400, ErrorMsg = "为获取到当前操作人信息" }); |
| | | //} |
| | | var bolls = await _locatSvc.AddPkStorageLocat(model, 1); |
| | | if (bolls > 0) |
| | | { |
| | | await _operation.InsertOperation("仓库设置", "储位管理", model.RoadwayNo, "添加", "添加储位信息 储位号:" + model.RoadwayNo, 1); |
| | | return Ok(new { code = 200, ErrorMsg = "添加成功", data = bolls }); |
| | | } |
| | | else |
| | | { |
| | | return Ok(new { code = 400, ErrorMsg = "添加失败", data = "" }); |
| | | } |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return Ok(new { code = 400, ErrorMsg = "请联系管理员/" + e.Message }); |
| | | } |
| | | } |
| | | else //数据格式错误 |
| | | { |
| | | return Ok(new { code = 400, ErrorMsg = "数据格式错误" }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 修改储位信息 |
| | | /// </summary> |
| | |
| | | string msg = "储位状态 储位号:" + storage.RoadwayNo; |
| | | if (model.Id.Count > 1) |
| | | { |
| | | foreach (var item in model.Id) |
| | | var sstorage = _locatSvc.GetStorageLocat(model.Id); |
| | | foreach (var item in sstorage) |
| | | { |
| | | storage = _locatSvc.GetStorageLocat(item); |
| | | _operation.InsertOperation("仓库设置", "储位管理", storage.LocatNo, "批量编辑", "批量修改储位信息 储位号:" + storage.LocatNo, Convert.ToInt32(userId)); |
| | | _operation.InsertOperation("仓库设置", "储位管理", item.LocatNo, "批量编辑", "批量修改储位信息 储位号:" + item.LocatNo, Convert.ToInt32(userId)); |
| | | } |
| | | //foreach (var item in model.Id) |
| | | //{ |
| | | // storage = _locatSvc.GetStorageLocat(item); |
| | | // _operation.InsertOperation("仓库设置", "储位管理", storage.LocatNo, "批量编辑", "批量修改储位信息 储位号:" + storage.LocatNo, Convert.ToInt32(userId)); |
| | | //} |
| | | } |
| | | else |
| | | { |
| | | _operation.InsertOperation("仓库设置", "储位管理", storage.LocatNo, "修改", "修改储位信息 储位号:" + storage.LocatNo, Convert.ToInt32(userId)); |
| | | } |
| | | |
| | | |
| | | return Ok(new { code = 0, msg = "编辑成功", data = "" }); |
| | | } |
| | | else |
| | |
| | | { |
| | | throw new Exception("当前显示的条码不是最新条码,请重新添加"); |
| | | } |
| | | string str = model.PalletNo.Substring(3, 5); |
| | | string remove = model.PalletNo.Substring(0, 3); |
| | | string str = model.PalletNo.Substring(2, 6); |
| | | string remove = model.PalletNo.Substring(0, 2); |
| | | int sibelius = Convert.ToInt16(str); |
| | | for (int i = 0; i < model.GroupCount; i++) |
| | | { |
| | | if (sibelius>999999) |
| | | { |
| | | throw new Exception("托盘组中已有托盘码位数已达上线"); |
| | | } |
| | | if (i != 0) |
| | | { |
| | | sibelius += 1; |
| | | } |
| | | |
| | | string code = remove + Convert.ToString(sibelius).PadLeft(5, '0'); |
| | | string code = remove + Convert.ToString(sibelius).PadLeft(6, '0'); |
| | | for (int j = 0; j < model.SameCount; j++) |
| | | { |
| | | var re = BarcodeHelper.GetCodeBarBase64(code, 80, 50); |
| | |
| | | int uid = Convert.ToInt32(userId); |
| | | //更改人 |
| | | tabledto.UpdateUser = uid; |
| | | string strMesage = _table.EditStatus(tabledto); |
| | | string strMesage = _table.EditStatus(tabledto); |
| | | if (strMesage == "") |
| | | { |
| | | return Ok(new { code = 0, msg = "处理成功" }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | return Ok(new { code = 1, msg = strMesage }); |
| | |
| | | |
| | | #region 储位图例 |
| | | |
| | | #region 立库 |
| | | /// <summary> |
| | | /// 根据仓库 排 |
| | | /// </summary> |
| | | /// <param name="wareHouseNo">仓库</param> |
| | | /// <param name="roadway">巷道号</param> |
| | | /// <param name="row">排</param> |
| | | /// <param name="depth">深度</param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetStorageLocatLists(string wareHouseNo, string roadway,string row) |
| | | public IActionResult GetStorageLocatLists(string wareHouseNo, string roadway, string row, string depth) |
| | | { |
| | | //获取储位信息 |
| | | List<SysStorageLocat> storagelist = _locatSvc.GetStorageLocatLists(wareHouseNo, roadway, row); |
| | | List<SysStorageLocat> storagelist = _locatSvc.GetStorageLocatLists(wareHouseNo, roadway, row, depth); |
| | | |
| | | //获取最大层级 |
| | | int maxLayer = _locatSvc.GetMaxLayer(wareHouseNo, roadway, row); |
| | |
| | | [HttpGet] |
| | | public IActionResult GetStorageProportion1(string wareHouseNo, string roadwayNo) |
| | | { |
| | | List<GetLocateVm> getLocateVms = _locatSvc.GetStorageProportion1(wareHouseNo,roadwayNo); |
| | | List<GetLocateVm> getLocateVms = _locatSvc.GetStorageProportion1(wareHouseNo, roadwayNo); |
| | | return Ok(new |
| | | { |
| | | data = getLocateVms, |
| | |
| | | msg = "获取仓库巷道成功" |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region 平库 |
| | | |
| | | /// <summary> |
| | | /// 根据仓库 排 |
| | | /// </summary> |
| | | /// <param name="wareHouseNo">仓库</param> |
| | | /// <param name="row">排</param> |
| | | /// <param name="depth">深度</param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetFlatLibraryLegend(string wareHouseNo, string row) |
| | | { |
| | | //获取储位信息 |
| | | List<SysStorageLocat> storagelist = _locatSvc.GetFlatLibraryLegend(wareHouseNo, row); |
| | | |
| | | //Dictionary<string, int> dic = new Dictionary<string, int>() |
| | | //{ |
| | | // "B01" |
| | | //}; |
| | | |
| | | return Ok(new |
| | | { |
| | | data = storagelist, |
| | | //dic, |
| | | code = 0, |
| | | msg = "" |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 根据储位地址获取储位上的托盘和物品信息 |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region 物料类别 |
| | | |
| | | /// <summary> |
| | | /// 获取物料类别信息 |
| | | /// </summary> |
| | | /// <param name="categoryName">类别名称</param> |
| | | /// <param name="areaNo">区域编码</param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | [HttpGet] |
| | | public IActionResult GetMaterialCategories(string categoryName, string areaNo) |
| | | { |
| | | try |
| | | { |
| | | var list = _category.GetMaterialCategories(categoryName, areaNo); |
| | | return Ok(new |
| | | { |
| | | data = list, |
| | | code = 1, |
| | | msg = "获取物料类别信息成功" |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = "", |
| | | code = 0, |
| | | msg = ex.Message |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取物料类别下拉菜单信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | [HttpGet] |
| | | public IActionResult GetMaterialCategories1() |
| | | { |
| | | try |
| | | { |
| | | var list = _category.GetMaterialCategories(); |
| | | return Ok(new |
| | | { |
| | | data = list, |
| | | code = 1, |
| | | msg = "获取物料类别信息成功" |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = "", |
| | | code = 0, |
| | | msg = ex.Message |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 根据Id获取物料类别信息 |
| | | /// </summary> |
| | | /// <param name="Id">Id</param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | [HttpGet] |
| | | public IActionResult GetMaterialCategoriesById(int Id) |
| | | { |
| | | try |
| | | { |
| | | var list = _category.GetMaterialCategoriesById(Id); |
| | | return Ok(new |
| | | { |
| | | data = list, |
| | | code = 1, |
| | | msg = "根据Id获取物料类别信息成功" |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = "", |
| | | code = 0, |
| | | msg = ex.Message |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取区域信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public IActionResult GetStorageAreaList() |
| | | { |
| | | try |
| | | { |
| | | var bolls = _category.GetStorageAreaList(); |
| | | |
| | | List<XmSelectDto> list = new List<XmSelectDto>(); |
| | | |
| | | foreach (var item in bolls) |
| | | { |
| | | XmSelectDto list1 = new XmSelectDto() |
| | | { |
| | | name = item.AreaName, //区域名称 |
| | | value = item.AreaNo, //区域号 |
| | | selected = false, //是否选中 |
| | | }; |
| | | list.Add(list1); |
| | | } |
| | | |
| | | return Ok(new { code = 0, msg = "区域信息", data = bolls, list }); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | return Ok(new { code = 1, msg = e.Message }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 新增类别信息 |
| | | /// </summary> |
| | | /// <param name="category">物料类别实体</param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | [HttpPost] |
| | | public IActionResult InsertMaterialCategories(SysMaterialCategory category) |
| | | { |
| | | try |
| | | { |
| | | //获取当前登录的用户ID |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | if (claimsIdentity == null) |
| | | { |
| | | return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); |
| | | } |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | if (string.IsNullOrWhiteSpace(userId)) |
| | | { |
| | | return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); |
| | | } |
| | | category.CreateUser = int.Parse(userId); |
| | | |
| | | var list = _category.InsertMaterialCategories(category); |
| | | |
| | | _operation.InsertOperation("基础信息", "物料类别", category.CategoryNo, "添加", "添加类别信息 类别号:" + category.CategoryNo, Convert.ToInt32(userId)); |
| | | |
| | | return Ok(new |
| | | { |
| | | data = list, |
| | | code = 1, |
| | | msg = "新增物料类别信息成功" |
| | | }); |
| | | |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = "", |
| | | code = 0, |
| | | msg = ex.Message |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 编辑类别信息 |
| | | /// </summary> |
| | | /// <param name="category">物料类别实体</param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | [HttpPost] |
| | | public IActionResult ExitMaterialCategories(SysMaterialCategory category) |
| | | { |
| | | try |
| | | { |
| | | //获取当前登录的用户ID |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | if (claimsIdentity == null) |
| | | { |
| | | return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); |
| | | } |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | if (string.IsNullOrWhiteSpace(userId)) |
| | | { |
| | | return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); |
| | | } |
| | | category.UpdateUser = int.Parse(userId); |
| | | |
| | | var list = _category.ExitMaterialCategories(category); |
| | | |
| | | _operation.InsertOperation("基础信息", "物料类别", category.CategoryNo, "编辑", "编辑类别信息 类别号:" + category.CategoryNo, Convert.ToInt32(userId)); |
| | | |
| | | return Ok(new |
| | | { |
| | | data = list, |
| | | code = 1, |
| | | msg = "编辑物料类别信息成功" |
| | | }); |
| | | |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = "", |
| | | code = 0, |
| | | msg = ex.Message |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除类别信息 |
| | | /// </summary> |
| | | /// <param name="category">物料类别实体</param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | [HttpPost] |
| | | public IActionResult DeleteMaterialCategories(MaterialCategoryDto category) |
| | | { |
| | | try |
| | | { |
| | | //获取当前登录的用户ID |
| | | var claimsIdentity = this.User.Identity as ClaimsIdentity; |
| | | if (claimsIdentity == null) |
| | | { |
| | | return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); |
| | | } |
| | | var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value; |
| | | if (string.IsNullOrWhiteSpace(userId)) |
| | | { |
| | | return Ok(new { code = 1, msg = "为获取到当前操作人信息" }); |
| | | } |
| | | category.UpdateUser = userId; |
| | | |
| | | var list = _category.DeleteMaterialCategories(category); |
| | | |
| | | _operation.InsertOperation("基础信息", "物料类别", category.CategoryNo, "删除", "删除类别信息 类别号:" + category.CategoryNo, Convert.ToInt32(userId)); |
| | | |
| | | return Ok(new |
| | | { |
| | | data = list, |
| | | code = 1, |
| | | msg = "删除物料类别信息成功" |
| | | }); |
| | | |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return Ok(new |
| | | { |
| | | data = "", |
| | | code = 0, |
| | | msg = ex.Message |
| | | }); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region 数据表格表头自定义(通用方法) |