优化
This commit is contained in:
69
BasicData/Tnb.BasicData/BasStandardTimeService.cs
Normal file
69
BasicData/Tnb.BasicData/BasStandardTimeService.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Interfaces.Permission;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
|
||||
namespace Tnb.BasicData
|
||||
{
|
||||
/// <summary>
|
||||
/// 标准工时
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class BasStandardTimeService : IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<BasStandardTime> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IOrganizeService _organizeService;
|
||||
|
||||
public BasStandardTimeService(
|
||||
ISqlSugarRepository<BasStandardTime> repository,
|
||||
IOrganizeService organizeService,
|
||||
IUserManager userManager
|
||||
)
|
||||
{
|
||||
_repository = repository;
|
||||
_organizeService = organizeService;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic?> SaveDate(BasStandardTime input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
if (input.enabled != null && input.enabled == 1)
|
||||
{
|
||||
await db.Updateable<BasStandardTime>()
|
||||
.SetColumns(x => x.enabled == 0)
|
||||
.Where(x => x.process_id == input.process_id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (input.id != null && !input.id.IsEmpty())
|
||||
{
|
||||
input.modify_id = _userManager.UserId;
|
||||
input.modify_time = DateTime.Now;
|
||||
await _repository.UpdateAsync(input);
|
||||
}
|
||||
else
|
||||
{
|
||||
input.id = SnowflakeIdHelper.NextId();
|
||||
input.create_time = DateTime.Now;
|
||||
input.create_id = _userManager.UserId;
|
||||
await db.Insertable(input).ExecuteCommandAsync();
|
||||
}
|
||||
});
|
||||
|
||||
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result.IsSuccess ? "保存成功" : result.ErrorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,6 +165,16 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
|
||||
public string warehouse_name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库库位id
|
||||
/// </summary>
|
||||
public string? as_location_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库库位编号
|
||||
/// </summary>
|
||||
public string? as_location_code { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,10 @@
|
||||
///<br/> Compled(任务完成)
|
||||
/// </summary>
|
||||
public string Behavior { get; set; }
|
||||
/// <summary>
|
||||
/// 暂停原因
|
||||
/// </summary>
|
||||
public String PauseReeson { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,5 +202,9 @@ public partial class PrdMoTask : BaseEntity<string>
|
||||
/// 批号
|
||||
/// </summary>
|
||||
public string? batch { get; set; }
|
||||
/// <summary>
|
||||
/// 暂停原因
|
||||
/// </summary>
|
||||
public string? pause_reason { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -558,6 +558,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
// string location_code = "ZCR01";//todo <20>̹ܼ<CCB9><DCBC><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>λ֮<CEBB><D6AE><EFBFBD><EFBFBD>
|
||||
//todo <20><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD>ٸ<EFBFBD>
|
||||
string warehouse_id = "2";
|
||||
|
||||
PrdInstockH? prdInstockH = null;
|
||||
|
||||
@@ -261,7 +261,12 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
if (!await db.Queryable<BasEbomH>().AnyAsync(x => x.material_id == item.material_id && x.version == item.ebom_version))
|
||||
{
|
||||
throw Oops.Bah($"系统中无法找到{item.ebom_version}版本");
|
||||
throw Oops.Bah($"系统中无法找到物料清单{item.ebom_version}版本");
|
||||
}
|
||||
|
||||
if (!await db.Queryable<BasMbom>().LeftJoin<BasEbomH>((a, b) => a.ebom_id == b.id).Where((a, b) => a.material_id == item.material_id && b.version == item.ebom_version).AnyAsync())
|
||||
{
|
||||
throw Oops.Bah($"系统中无法找到物料清单对应的生产bom{item.ebom_version}版本");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1151,6 +1151,8 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
throw Oops.Bah("状态错误无法暂停");
|
||||
}
|
||||
|
||||
item.pause_reason = input.PauseReeson;
|
||||
break;
|
||||
case PrdTaskBehavior.Compled:
|
||||
if (item.mo_task_status == status)
|
||||
|
||||
@@ -417,7 +417,7 @@ namespace Tnb.ProductionMgr
|
||||
.LeftJoin<EqpEquipment>((a, b, c, d, e, f) => a.eqp_id == f.id)
|
||||
.LeftJoin<ToolMolds>((a, b, c, d, e, f, g) => a.mold_id == g.id)
|
||||
.LeftJoin<PerProcessStandardsH>((a, b, c, d, e, f, g, h) => a.material_id == h.output_material_id && a.eqp_id == h.equip_id && a.mold_id == h.molds_id && h.enabled == 1)
|
||||
.LeftJoin<BasStandardTime>((a, b, c, d, e, f, g, h, i) => a.process_id == i.process_id && i.enabled == 1)
|
||||
.LeftJoin<BasStandardTime>((a, b, c, d, e, f, g, h, i) => a.process_id == i.process_id && i.enabled == 1 && a.schedule_type==1)
|
||||
.LeftJoin<PrdMo>((a, b, c, d, e, f, g, h, i, j) => a.mo_id == j.id)
|
||||
.LeftJoin<BasMaterialUnit>((a, b, c, d, e, f, g, h, i, j, k) => a.material_id == k.material_id && k.auxiliary_unit_id == "kg")
|
||||
.LeftJoin<EqpDaq>((a, b, c, d, e, f, g, h, i, j, k, l) => a.eqp_id == l.equip_id && l.enabled == 1 && l.label_point == "注塑空满箱请求")
|
||||
@@ -469,11 +469,32 @@ namespace Tnb.ProductionMgr
|
||||
deputy_num = k.number_of_auxiliary_unit,
|
||||
third_equip_code = l.equip_code,
|
||||
weight_name = l.label_name,
|
||||
category_id = b.category_id
|
||||
category_id = b.category_id,
|
||||
as_location_id = f.as_location_id
|
||||
})
|
||||
.MergeTable()
|
||||
.OrderBy($"{input.sidx} {input.sort}")
|
||||
.ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
if (!result.list.IsEmpty())
|
||||
{
|
||||
foreach (var item in result.list)
|
||||
{
|
||||
if (item.as_location_id!=null && !item.as_location_id.IsEmpty())
|
||||
{
|
||||
BasLocation basLocation = await _db.Queryable<BasLocation>().SingleAsync(x => x.id == item.as_location_id);
|
||||
item.as_location_code = basLocation.location_code;
|
||||
}
|
||||
|
||||
if (item.schedule_type == 2)
|
||||
{
|
||||
PerProcessStandardsH processStandardsH = await _db.Queryable<PerProcessStandardsH>()
|
||||
.Where(x => x.equip_id == item.equip_id && x.molds_id == item.mold_id &&
|
||||
x.output_material_id == item.material_id && x.enabled == 1)
|
||||
.OrderByDescending(x => x.create_time).FirstAsync();
|
||||
item.standard_time = processStandardsH?.moulding_cycle?.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PageResult<PADPackageTaskPageOutput>.SqlSugarPageResult(result);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user