模具保养运行,代码优化
This commit is contained in:
62
WarehouseMgr/Tnb.WarehouseMgr/BasRegionUserService.cs
Normal file
62
WarehouseMgr/Tnb.WarehouseMgr/BasRegionUserService.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class BasRegionUserService : IOverideVisualDevService, IBasRegionUserService, IDynamicApiController, ITransient
|
||||
{
|
||||
private const string ModuleId = "26169876750629";
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private static Dictionary<string, object> _dicRegion = new Dictionary<string, object>();
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
public BasRegionUserService(ISqlSugarRepository<BasRegionUser> repository, IRunService runService, IVisualDevService visualDevService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
OverideFuncs.CreateAsync = Create;
|
||||
}
|
||||
|
||||
private async Task<dynamic> Create(VisualDevModelDataCrInput input)
|
||||
{
|
||||
if (_dicRegion.Count < 1)
|
||||
{
|
||||
_dicRegion = await _db.Queryable<BasRegion>().ToDictionaryAsync(x => x.id, x => x.region_name);
|
||||
}
|
||||
if (input.data.ContainsKey(nameof(BasRegionUser.region_id)) && input.data.ContainsKey(nameof(BasRegionUser.user_id)))
|
||||
{
|
||||
var regionId = input.data[nameof(BasRegionUser.region_id)].ToString();
|
||||
var userId = input.data[nameof(BasRegionUser.user_id)].ToString();
|
||||
var user = await _db.Queryable<BasRegionUser>().Where(it => it.region_id == regionId && it.user_id == userId).FirstAsync();
|
||||
if (user != null)
|
||||
{
|
||||
throw new AppFriendlyException($"区域【{_dicRegion[regionId]}】,已存在用户【{user.user_name}】", 500);
|
||||
}
|
||||
}
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
await _runService.Create(templateEntity, input);
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
106
WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs
Normal file
106
WarehouseMgr/Tnb.WarehouseMgr/WmsCarryLedgerService.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using SqlSugar;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using Aspose.Cells.Drawing;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 载具台账服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
//[OverideVisualDev(ModuleId)]
|
||||
public class WmsCarryLedgerService : IOverideVisualDevService, IWmsCarryLedgerService, IDynamicApiController, ITransient
|
||||
{
|
||||
private const string ModuleId = "26038721525029";
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private static Dictionary<int, string> _dicCarryStatus = new(); //载具状态
|
||||
private static Dictionary<int, string> _dicOutStatus = new(); //出库类型
|
||||
private static Dictionary<int, string> _dicIsCheck = new() //是否检验
|
||||
{
|
||||
[0] = "未检验",
|
||||
[1] = "已检验",
|
||||
};
|
||||
private static Dictionary<int, string> _dicIsEnabled = new()
|
||||
{
|
||||
[0] = "启用",
|
||||
[1] = "禁用",
|
||||
};
|
||||
private static Dictionary<int, string> _dicIsLock = new()
|
||||
{
|
||||
[0] = "未锁定",
|
||||
[1] = "锁定",
|
||||
};
|
||||
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
public WmsCarryLedgerService(ISqlSugarRepository<WmsCarryH> repository, IRunService runService, IVisualDevService visualDevService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
//OverideFuncs.GetListAsync = GetList;
|
||||
}
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
if (_dicCarryStatus.Count < 1)
|
||||
{
|
||||
_dicCarryStatus = typeof(EnumCarryStatus).GetEnumDictionary();
|
||||
}
|
||||
if (_dicOutStatus.Count < 1)
|
||||
{
|
||||
_dicOutStatus = typeof(EnumOutStatus).GetEnumDictionary();
|
||||
}
|
||||
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
var data = await _runService.GetListResult(templateEntity, input);
|
||||
if (data?.list?.Count > 0)
|
||||
{
|
||||
//foreach (var item in data.list)
|
||||
//{
|
||||
// if (item.ContainsKey(nameof(WmsCarryH.carry_status)) && item[nameof(WmsCarryH.carry_status)].IsNotEmptyOrNull())
|
||||
// {
|
||||
// item[nameof(WmsCarryH.carry_status)] = _dicCarryStatus[item[nameof(WmsCarryH.carry_status)].ParseToInt()];
|
||||
// }
|
||||
// if (item.ContainsKey(nameof(WmsCarryH.out_status)) && item[nameof(WmsCarryH.out_status)].IsNotEmptyOrNull())
|
||||
// {
|
||||
// item[nameof(WmsCarryH.out_status)] = _dicOutStatus[item[nameof(WmsCarryH.out_status)].ParseToInt()];
|
||||
// }
|
||||
// if (item.ContainsKey(nameof(WmsCarryH.is_lock)) && item[nameof(WmsCarryH.is_lock)].IsNotEmptyOrNull())
|
||||
// {
|
||||
// item[nameof(WmsCarryH.is_lock)] = _dicIsLock[item[nameof(WmsCarryH.is_lock)].ParseToInt()];
|
||||
// }
|
||||
// if (item.ContainsKey(nameof(WmsCarryH.is_check)) && item[nameof(WmsCarryH.is_check)].IsNotEmptyOrNull())
|
||||
// {
|
||||
// item[nameof(WmsCarryH.is_check)] = _dicIsCheck[item[nameof(WmsCarryH.is_check)].ParseToInt()];
|
||||
// }
|
||||
// if (item.ContainsKey(nameof(WmsCarryH.status)) && item[nameof(WmsCarryH.status)].IsNotEmptyOrNull())
|
||||
// {
|
||||
// item[nameof(WmsCarryH.status)] = _dicIsEnabled[item[nameof(WmsCarryH.status)].ParseToInt()];
|
||||
// }
|
||||
//}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,7 @@ namespace Tnb.WarehouseMgr
|
||||
newCarry.create_time = DateTime.Now;
|
||||
var row = await _db.Updateable(newCarry).ExecuteCommandAsync();
|
||||
WmsCarryReplaceH wmsCarryReplaceH = oldCarry.Adapt<WmsCarryReplaceH>();
|
||||
wmsCarryReplaceH.id = SnowflakeIdHelper.NextId();
|
||||
wmsCarryReplaceH.org_id = oldCarry.org_id;
|
||||
wmsCarryReplaceH.bill_code = await _billRullService.GetBillNumber(WmsCarryConst.WMS_CARRY_REPLACE_ENCODE);
|
||||
wmsCarryReplaceH.carry_id = oldCarry.id;
|
||||
|
||||
@@ -41,16 +41,17 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
dicMaterial = await _db.Queryable<BasMaterial>().ToDictionaryAsync(x => x.id, x => x.name);
|
||||
}
|
||||
var items = await _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carryId)
|
||||
.Select(it => new CarryCodeDetailOutput
|
||||
var items = await _db.Queryable<WmsCarryCode>().Where(a => a.carry_id == carryId)
|
||||
.Select(a => new CarryCodeDetailOutput
|
||||
{
|
||||
barcode = it.barcode,
|
||||
code_batch = it.code_batch,
|
||||
codeqty = it.codeqty,
|
||||
material_code = it.material_code,
|
||||
material_id = it.material_id,
|
||||
barcode = a.barcode,
|
||||
code_batch = a.code_batch,
|
||||
codeqty = a.codeqty,
|
||||
material_code = a.material_code,
|
||||
material_id = a.material_id,
|
||||
unit_id = a.unit_id,
|
||||
})
|
||||
.Mapper(it => it.material_name = dicMaterial.ContainsKey(it.material_id) ? dicMaterial[it.material_id].ToString() : "")
|
||||
.Mapper(it => it.material_name = dicMaterial.ContainsKey(it.material_id) ? dicMaterial[it.material_id].ToString()! : "")
|
||||
.ToListAsync();
|
||||
return items;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user