| | |
| | | public async Task<PageResult<WmsControlRuleDetailOutput>> Page([FromQuery] WmsControlRuleDetailSearch input) |
| | | { |
| | | var wmsControlRuleDetails = await _wmsControlRuleDetailRep.DetachedEntities |
| | | .Where(input.ControlRuleId != null, u => u.ControlRuleId == input.ControlRuleId) |
| | | .Where(!string.IsNullOrEmpty(input.RuleCode), u => u.RuleCode == input.RuleCode) |
| | | .Where(input.MaxImumqty != null, u => u.MaxImumqty == input.MaxImumqty) |
| | | .Where(input.MinImumqty != null, u => u.MinImumqty == input.MinImumqty) |
| | | .Where(input.SafeImumqty != null, u => u.SafeImumqty == input.SafeImumqty) |
| | |
| | | [HttpGet("WmsControlRuleDetail/listNonPage")] |
| | | public async Task<List<WmsControlRuleDetailOutput>> ListNonPageAsync([FromQuery] WmsControlRuleDetailSearchNonPage input) |
| | | { |
| | | var pControlRuleId = input.ControlRuleId; |
| | | var pRuleCode = input.RuleCode?.Trim() ?? ""; |
| | | var pMaxImumqty = input.MaxImumqty; |
| | | var pMinImumqty = input.MinImumqty; |
| | | var pSafeImumqty = input.SafeImumqty; |
| | |
| | | var pCreatedUserName = input.CreatedUserName?.Trim() ?? ""; |
| | | var pUpdatedUserName = input.UpdatedUserName?.Trim() ?? ""; |
| | | var wmsControlRuleDetails = await _wmsControlRuleDetailRep.DetachedEntities |
| | | .Where(pControlRuleId != null, u => u.ControlRuleId == pControlRuleId) |
| | | .Where(!string.IsNullOrEmpty(pRuleCode), u => u.RuleCode == pRuleCode) |
| | | .Where(pMaxImumqty != null, u => u.MaxImumqty == pMaxImumqty) |
| | | .Where(pMinImumqty != null, u => u.MinImumqty == pMinImumqty) |
| | | .Where(pSafeImumqty != null, u => u.SafeImumqty == pSafeImumqty) |
| | |
| | | UpdatedUserName = SysHelper.GetUserName() |
| | | }; |
| | | #region 定义变量 |
| | | var _ControlRuleId = "";//控制属性规则ID |
| | | var _RuleCode = "";//控制属性规则编号 |
| | | var _MaxImumqty = "";//最高库存 |
| | | var _MinImumqty = "";//最低库存 |
| | | var _SafeImumqty = "";//安全库存 |
| | |
| | | |
| | | |
| | | #region 取值 |
| | | _ControlRuleId = row["控制属性规则ID"]?.ToString() ; |
| | | _RuleCode = row["控制属性规则编号"]?.ToString() ; |
| | | _MaxImumqty = row["最高库存"]?.ToString() ; |
| | | _MinImumqty = row["最低库存"]?.ToString() ; |
| | | _SafeImumqty = row["安全库存"]?.ToString() ; |
| | |
| | | |
| | | #region 验证 |
| | | |
| | | if (string.IsNullOrEmpty(_ControlRuleId)) |
| | | if (string.IsNullOrEmpty(_RuleCode)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[控制属性规则ID]{_ControlRuleId}不能为空!"); |
| | | throw Oops.Oh($"第{index}行[控制属性规则编号]{_RuleCode}不能为空!"); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_ControlRuleId)) |
| | | if(!string.IsNullOrEmpty(_RuleCode)) |
| | | { |
| | | if (!long.TryParse(_ControlRuleId, out long outControlRuleId)&&!string.IsNullOrEmpty(_ControlRuleId)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[控制属性规则ID]{_ControlRuleId}值不正确!"); |
| | | addItem.RuleCode = (string)_RuleCode; |
| | | } |
| | | if (outControlRuleId <= 0&&!string.IsNullOrEmpty(_ControlRuleId)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[控制属性规则ID]{_ControlRuleId}值不能小于等于0!"); |
| | | } |
| | | else |
| | | { |
| | | addItem.ControlRuleId = outControlRuleId; |
| | | } |
| | | |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(_MaxImumqty)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[最高库存]{_MaxImumqty}不能为空!"); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_MaxImumqty)) |
| | | { |
| | | if (!decimal.TryParse(_MaxImumqty, out decimal outMaxImumqty)&&!string.IsNullOrEmpty(_MaxImumqty)) |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(_MinImumqty)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[最低库存]{_MinImumqty}不能为空!"); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_MinImumqty)) |
| | | { |
| | | if (!decimal.TryParse(_MinImumqty, out decimal outMinImumqty)&&!string.IsNullOrEmpty(_MinImumqty)) |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(_SafeImumqty)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[安全库存]{_SafeImumqty}不能为空!"); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_SafeImumqty)) |
| | | { |
| | | if (!decimal.TryParse(_SafeImumqty, out decimal outSafeImumqty)&&!string.IsNullOrEmpty(_SafeImumqty)) |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(_MinStorageAge)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[最小库龄]{_MinStorageAge}不能为空!"); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_MinStorageAge)) |
| | | { |
| | | if (!decimal.TryParse(_MinStorageAge, out decimal outMinStorageAge)&&!string.IsNullOrEmpty(_MinStorageAge)) |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(_MaxStorageAge)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[最大库龄]{_MaxStorageAge}不能为空!"); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_MaxStorageAge)) |
| | | { |
| | | if (!decimal.TryParse(_MaxStorageAge, out decimal outMaxStorageAge)&&!string.IsNullOrEmpty(_MaxStorageAge)) |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(_IsNotChek)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[是否免检]{_IsNotChek}不能为空!"); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_IsNotChek)) |
| | | { |
| | | if(!_IsNotChek.Equals("是") && !_IsNotChek.Equals("否")) |
| | |
| | | bool outIsNotChek = _IsNotChek.Equals("是") ? true : false; |
| | | addItem.IsNotChek = outIsNotChek; |
| | | } |
| | | } |
| | | |
| | | |
| | | if (string.IsNullOrEmpty(_ShelfLifeDays)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[保质期天数]{_ShelfLifeDays}不能为空!"); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_ShelfLifeDays)) |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(_IsDisabled)) |
| | | { |
| | | throw Oops.Oh($"第{index}行[是否禁用]{_IsDisabled}不能为空!"); |
| | | } |
| | | |
| | | if(!string.IsNullOrEmpty(_IsDisabled)) |
| | | { |
| | | if(!_IsDisabled.Equals("是") && !_IsDisabled.Equals("否")) |
| | |
| | | { |
| | | //数据是否存在重复 |
| | | isExist = await _wmsControlRuleDetailRep.AnyAsync(u => |
| | | u.ControlRuleId.Equals(input.ControlRuleId) |
| | | u.RuleCode.Equals(input.RuleCode) |
| | | ,false); |
| | | } |
| | | else//编辑 |
| | |
| | | //当前编辑数据以外是否存在重复 |
| | | isExist = await _wmsControlRuleDetailRep.AnyAsync(u => |
| | | u.Id != input.Id |
| | | &&u.ControlRuleId.Equals(input.ControlRuleId) |
| | | &&u.RuleCode.Equals(input.RuleCode) |
| | | ,false); |
| | | } |
| | | |
| | |
| | | } |
| | | //数据是否重复 |
| | | var existExcelItem = inputs.GroupBy(g => new { |
| | | g.ControlRuleId |
| | | g.RuleCode |
| | | }) |
| | | .Where(g => g.Count() > 1) |
| | | .Select(s => new { |
| | | s.Key.ControlRuleId |
| | | s.Key.RuleCode |
| | | }).FirstOrDefault(); |
| | | if (existExcelItem != null) |
| | | { |
| | | var wmsControlRuleDetail = existExcelItem.Adapt<WmsControlRuleDetail>(); |
| | | var item= existExcelItem.Adapt<WmsControlRuleDetail>(); |
| | | throw Oops.Oh($"导入的表格中,控制属性规则ID[{item.ControlRuleId}]已存在"); |
| | | throw Oops.Oh($"导入的表格中,控制属性规则编号[{item.RuleCode}]已存在"); |
| | | } |
| | | |
| | | |
| | |
| | | //根据联合主键验证数据库中是否已存在相同数据 |
| | | var existDBItem = await _wmsControlRuleDetailRep.DetachedEntities.FirstOrDefaultAsync(w=> |
| | | inputs.Select(s=>"" |
| | | +s.ControlRuleId |
| | | +s.RuleCode |
| | | ) |
| | | .Contains("" |
| | | +w.ControlRuleId |
| | | +w.RuleCode |
| | | )); |
| | | if (existDBItem != null) |
| | | { |
| | | var wmsControlRuleDetail = existExcelItem.Adapt<WmsControlRuleDetail>(); |
| | | var item= existExcelItem.Adapt<WmsControlRuleDetail>(); |
| | | throw Oops.Oh($"系统中,控制属性规则ID[{item.ControlRuleId}]已存在"); |
| | | throw Oops.Oh($"系统中,控制属性规则编号[{item.RuleCode}]已存在"); |
| | | } |
| | | } |
| | | |