组装包装,生产排产代码调整
This commit is contained in:
39
BasicData/Tnb.BasicData.Entities/Dto/SubBomListOutput.cs
Normal file
39
BasicData/Tnb.BasicData.Entities/Dto/SubBomListOutput.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Tnb.BasicData.Entities.Dto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 子工单列表
|
||||||
|
/// </summary>
|
||||||
|
public class SubBomListOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 物料id
|
||||||
|
/// </summary>
|
||||||
|
public string material_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料编码
|
||||||
|
/// </summary>
|
||||||
|
public string material_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料名称
|
||||||
|
/// </summary>
|
||||||
|
public string material_name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料型号
|
||||||
|
/// </summary>
|
||||||
|
public string material_category_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///输出数量
|
||||||
|
/// </summary>
|
||||||
|
public int output_qty { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 数量
|
||||||
|
/// </summary>
|
||||||
|
public string num { get; set;}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,14 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace Tnb.BasicData.Interfaces
|
namespace Tnb.BasicData.Interfaces
|
||||||
{
|
{
|
||||||
public interface IBasMbomService
|
public interface IBasMbomService
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>id<69><64>ȡ<EFBFBD><C8A1>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bomId">bomid</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<dynamic> GetSubMoListByBomId([FromRoute] string bomId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,8 @@ using SqlSugar;
|
|||||||
using Tnb.BasicData.Entities;
|
using Tnb.BasicData.Entities;
|
||||||
using Tnb.BasicData.Interfaces;
|
using Tnb.BasicData.Interfaces;
|
||||||
using Tnb.BasicData.Entities.Dto;
|
using Tnb.BasicData.Entities.Dto;
|
||||||
|
using NPOI.OpenXmlFormats.Dml;
|
||||||
|
using JNPF.Common.Extension;
|
||||||
|
|
||||||
namespace Tnb.BasicData
|
namespace Tnb.BasicData
|
||||||
{
|
{
|
||||||
@@ -22,13 +24,14 @@ namespace Tnb.BasicData
|
|||||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
|
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
|
||||||
[Route("api/[area]/[controller]/[action]")]
|
[Route("api/[area]/[controller]/[action]")]
|
||||||
[OverideVisualDev(ModelId)]
|
[OverideVisualDev(ModelId)]
|
||||||
public class BasMbomService : IBasMbomService,IOverideVisualDevService,IDynamicApiController, ITransient
|
public class BasMbomService : IBasMbomService, IOverideVisualDevService, IDynamicApiController, ITransient
|
||||||
{
|
{
|
||||||
public const string ModelId = "25574817510421";
|
public const string ModelId = "25574817510421";
|
||||||
private readonly ISqlSugarRepository<BasMbom> _repository;
|
private readonly ISqlSugarRepository<BasMbom> _repository;
|
||||||
private readonly DataBaseManager _dbManager;
|
private readonly DataBaseManager _dbManager;
|
||||||
private readonly IDictionaryDataService _dictionaryDataService;
|
private readonly IDictionaryDataService _dictionaryDataService;
|
||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
|
private readonly ISqlSugarClient _db;
|
||||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||||
|
|
||||||
public BasMbomService(
|
public BasMbomService(
|
||||||
@@ -41,6 +44,7 @@ namespace Tnb.BasicData
|
|||||||
_dbManager = dbManager;
|
_dbManager = dbManager;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_dictionaryDataService = dictionaryDataService;
|
_dictionaryDataService = dictionaryDataService;
|
||||||
|
_db = repository.AsSugarClient();
|
||||||
// OverideFuncs.GetAsync = GetInfo;
|
// OverideFuncs.GetAsync = GetInfo;
|
||||||
OverideFuncs.GetListAsync = GetList;
|
OverideFuncs.GetListAsync = GetList;
|
||||||
}
|
}
|
||||||
@@ -55,14 +59,14 @@ namespace Tnb.BasicData
|
|||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
Dictionary<string, object> queryJson = string.IsNullOrEmpty(input.queryJson) ? null : input.queryJson.ToObject<Dictionary<string, object>>();
|
Dictionary<string, object> queryJson = string.IsNullOrEmpty(input.queryJson) ? null : input.queryJson.ToObject<Dictionary<string, object>>();
|
||||||
string materialInfo = queryJson?["query_info"]?.ToString();
|
string materialInfo = queryJson?["query_info"]?.ToString();
|
||||||
var list = await db.Queryable<BasMbom, BasMaterial, BasEbomH, BasRouteH>((a, b, c,d) => new object[]
|
var list = await db.Queryable<BasMbom, BasMaterial, BasEbomH, BasRouteH>((a, b, c, d) => new object[]
|
||||||
{
|
{
|
||||||
JoinType.Left, a.material_id == b.id,
|
JoinType.Left, a.material_id == b.id,
|
||||||
JoinType.Left, a.ebom_id == c.id,
|
JoinType.Left, a.ebom_id == c.id,
|
||||||
JoinType.Left, a.route_id == d.id,
|
JoinType.Left, a.route_id == d.id,
|
||||||
})
|
})
|
||||||
.WhereIF(!string.IsNullOrEmpty(materialInfo),(a,b,c,d)=>b.code.Contains(materialInfo) || b.name.Contains(materialInfo))
|
.WhereIF(!string.IsNullOrEmpty(materialInfo), (a, b, c, d) => b.code.Contains(materialInfo) || b.name.Contains(materialInfo))
|
||||||
.Select((a, b, c,d) => new MbomListOutput
|
.Select((a, b, c, d) => new MbomListOutput
|
||||||
{
|
{
|
||||||
id = a.id,
|
id = a.id,
|
||||||
material_id = b.code + "-" + b.name,
|
material_id = b.code + "-" + b.name,
|
||||||
@@ -73,12 +77,41 @@ namespace Tnb.BasicData
|
|||||||
route_id_id = c.id,
|
route_id_id = c.id,
|
||||||
start_time = a.start_time.Value.ToString("yyyy-MM-dd"),
|
start_time = a.start_time.Value.ToString("yyyy-MM-dd"),
|
||||||
end_time = a.start_time.Value.ToString("yyyy-MM-dd"),
|
end_time = a.start_time.Value.ToString("yyyy-MM-dd"),
|
||||||
is_first = SqlFunc.IIF(a.is_first==0 , "否","是"),
|
is_first = SqlFunc.IIF(a.is_first == 0, "否", "是"),
|
||||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||||
|
|
||||||
return PageResult<MbomListOutput>.SqlSugarPageResult(list);
|
return PageResult<MbomListOutput>.SqlSugarPageResult(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据bomid获取对应的子bom列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<dynamic> GetSubMoListByBomId([FromRoute] string bomId)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(bomId)) throw new ArgumentException($"parameter {nameof(bomId)} not be null or empty");
|
||||||
|
var result = await _db.Queryable<BasMbom>().LeftJoin<BasRouteD>((a, b) => a.route_id == b.route_id)
|
||||||
|
.LeftJoin<BasProcess>((a, b, c) => b.process_id == c.id)
|
||||||
|
.LeftJoin<BasMbomOutput>((a, b, c, d) => c.id == d.process_id)
|
||||||
|
.LeftJoin<BasMaterial>((a, b, c, d, e) => d.material_id == e.id)
|
||||||
|
.LeftJoin<BasMaterialCategory>((a, b, c, d, e, f) => e.category_id == f.id)
|
||||||
|
.Where((a, b, c, d, e, f) => a.id == bomId)
|
||||||
|
.Select((a, b, c, d, e, f) => new SubBomListOutput
|
||||||
|
{
|
||||||
|
material_id = e.id,
|
||||||
|
material_code = e.code,
|
||||||
|
material_name = e.name,
|
||||||
|
material_category_code = f.category_code,
|
||||||
|
num = d.num
|
||||||
|
})
|
||||||
|
.Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||||
|
.Distinct()
|
||||||
|
.ToListAsync();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取编辑信息
|
/// 获取编辑信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -87,7 +120,7 @@ namespace Tnb.BasicData
|
|||||||
public async Task<dynamic> GetInfo(string id)
|
public async Task<dynamic> GetInfo(string id)
|
||||||
{
|
{
|
||||||
var db = _repository.AsSugarClient();
|
var db = _repository.AsSugarClient();
|
||||||
BasMbom mbom = await _repository.GetSingleAsync(x=>x.id==id);
|
BasMbom mbom = await _repository.GetSingleAsync(x => x.id == id);
|
||||||
List<BasMbomProcess> processes = await db.Queryable<BasMbomProcess>().Where(x => x.mbom_id == id).ToListAsync();
|
List<BasMbomProcess> processes = await db.Queryable<BasMbomProcess>().Where(x => x.mbom_id == id).ToListAsync();
|
||||||
List<BasMbomInput> inputs = await db.Queryable<BasMbomInput>().Where(x => x.mbom_id == id).ToListAsync();
|
List<BasMbomInput> inputs = await db.Queryable<BasMbomInput>().Where(x => x.mbom_id == id).ToListAsync();
|
||||||
List<BasMbomOutput> outputs = await db.Queryable<BasMbomOutput>().Where(x => x.mbom_id == id).ToListAsync();
|
List<BasMbomOutput> outputs = await db.Queryable<BasMbomOutput>().Where(x => x.mbom_id == id).ToListAsync();
|
||||||
@@ -125,6 +158,44 @@ namespace Tnb.BasicData
|
|||||||
return mbomDataOutput;
|
return mbomDataOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据物料id获取生产bom
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="materialId"></param>
|
||||||
|
/// <remarks>
|
||||||
|
/// returns:
|
||||||
|
/// <br/>{
|
||||||
|
/// <br/> bom_id:bomid
|
||||||
|
/// <br/> material_code:物料编码
|
||||||
|
/// <br/> material_name:物料名称
|
||||||
|
/// <br/> start_time:有效开始时间
|
||||||
|
/// <br/> end_time:有效结束时间
|
||||||
|
/// <br/> version:bom版本
|
||||||
|
/// <br/> route_id:工艺路线id
|
||||||
|
/// <br/> route_name:工艺路线名称
|
||||||
|
/// <br/>}
|
||||||
|
/// </remarks>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<dynamic> GetMBomListByMaterialId([FromRoute] string materialId)
|
||||||
|
{
|
||||||
|
return await _db.Queryable<BasMbom>()
|
||||||
|
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||||
|
.LeftJoin<BasRouteH>((a, b, c) => a.route_id == c.id)
|
||||||
|
.Where((a, b, c) => a.material_id == materialId)
|
||||||
|
.Select((a, b, c) => new
|
||||||
|
{
|
||||||
|
bom_id = a.id,
|
||||||
|
material_code = b.code,
|
||||||
|
material_name = b.name,
|
||||||
|
start_time = a.start_time.HasValue ? a.start_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : null,
|
||||||
|
end_time = a.end_time.HasValue ? a.end_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : null,
|
||||||
|
version = a.version,
|
||||||
|
route_id = c.id,
|
||||||
|
route_name = c.name,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存生产bom
|
/// 保存生产bom
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -144,7 +215,7 @@ namespace Tnb.BasicData
|
|||||||
{
|
{
|
||||||
id = mbomId,
|
id = mbomId,
|
||||||
org_id = orgId,
|
org_id = orgId,
|
||||||
material_id= mbomSaveDataInput.material_id,
|
material_id = mbomSaveDataInput.material_id,
|
||||||
num = mbomSaveDataInput.num,
|
num = mbomSaveDataInput.num,
|
||||||
unit_id = mbomSaveDataInput.unit_id,
|
unit_id = mbomSaveDataInput.unit_id,
|
||||||
version = mbomSaveDataInput.version,
|
version = mbomSaveDataInput.version,
|
||||||
@@ -170,7 +241,7 @@ namespace Tnb.BasicData
|
|||||||
{
|
{
|
||||||
id = mbomProcessId,
|
id = mbomProcessId,
|
||||||
org_id = orgId,
|
org_id = orgId,
|
||||||
mbom_id= mbomId,
|
mbom_id = mbomId,
|
||||||
process_id = process.process_id,
|
process_id = process.process_id,
|
||||||
preparation_time = process.preparation_time,
|
preparation_time = process.preparation_time,
|
||||||
station = process.station,
|
station = process.station,
|
||||||
@@ -234,10 +305,10 @@ namespace Tnb.BasicData
|
|||||||
else//修改
|
else//修改
|
||||||
{
|
{
|
||||||
string orgId = _userManager.GetUserInfo().Result.organizeId;
|
string orgId = _userManager.GetUserInfo().Result.organizeId;
|
||||||
await _repository.UpdateAsync(x=>new BasMbom()
|
await _repository.UpdateAsync(x => new BasMbom()
|
||||||
{
|
{
|
||||||
// org_id = orgId,
|
// org_id = orgId,
|
||||||
material_id= mbomSaveDataInput.material_id,
|
material_id = mbomSaveDataInput.material_id,
|
||||||
num = mbomSaveDataInput.num,
|
num = mbomSaveDataInput.num,
|
||||||
unit_id = mbomSaveDataInput.unit_id,
|
unit_id = mbomSaveDataInput.unit_id,
|
||||||
version = mbomSaveDataInput.version,
|
version = mbomSaveDataInput.version,
|
||||||
@@ -250,7 +321,7 @@ namespace Tnb.BasicData
|
|||||||
modify_id = _userManager.UserId,
|
modify_id = _userManager.UserId,
|
||||||
modify_time = DateTime.Now,
|
modify_time = DateTime.Now,
|
||||||
|
|
||||||
},x=>x.id==mbomSaveDataInput.id);
|
}, x => x.id == mbomSaveDataInput.id);
|
||||||
List<BasMbomProcess> processes = new List<BasMbomProcess>();
|
List<BasMbomProcess> processes = new List<BasMbomProcess>();
|
||||||
List<BasMbomInput> inputs = new List<BasMbomInput>();
|
List<BasMbomInput> inputs = new List<BasMbomInput>();
|
||||||
List<BasMbomOutput> outputs = new List<BasMbomOutput>();
|
List<BasMbomOutput> outputs = new List<BasMbomOutput>();
|
||||||
@@ -262,7 +333,7 @@ namespace Tnb.BasicData
|
|||||||
{
|
{
|
||||||
id = mbomProcessId,
|
id = mbomProcessId,
|
||||||
org_id = orgId,
|
org_id = orgId,
|
||||||
mbom_id= mbomSaveDataInput.id,
|
mbom_id = mbomSaveDataInput.id,
|
||||||
process_id = process.process_id,
|
process_id = process.process_id,
|
||||||
preparation_time = process.preparation_time,
|
preparation_time = process.preparation_time,
|
||||||
station = process.station,
|
station = process.station,
|
||||||
@@ -309,9 +380,9 @@ namespace Tnb.BasicData
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await _repository.AsSugarClient().Deleteable<BasMbomProcess>().Where(x=>x.mbom_id==mbomSaveDataInput.id).ExecuteCommandAsync();
|
await _repository.AsSugarClient().Deleteable<BasMbomProcess>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||||
await _repository.AsSugarClient().Deleteable<BasMbomInput>().Where(x=>x.mbom_id==mbomSaveDataInput.id).ExecuteCommandAsync();
|
await _repository.AsSugarClient().Deleteable<BasMbomInput>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||||
await _repository.AsSugarClient().Deleteable<BasMbomOutput>().Where(x=>x.mbom_id==mbomSaveDataInput.id).ExecuteCommandAsync();
|
await _repository.AsSugarClient().Deleteable<BasMbomOutput>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||||
if (processes.Count > 0)
|
if (processes.Count > 0)
|
||||||
{
|
{
|
||||||
await _repository.AsSugarClient().Insertable<BasMbomProcess>(processes).ExecuteCommandAsync();
|
await _repository.AsSugarClient().Insertable<BasMbomProcess>(processes).ExecuteCommandAsync();
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Tnb.EquipMgr.Interfaces
|
||||||
|
{
|
||||||
|
public interface IToolMoldMaintainPlanRunService
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -83,111 +83,7 @@ namespace Tnb.EquipMgr
|
|||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
[HttpGet]
|
|
||||||
public async Task<dynamic> GetMaintainInfoFromByPlanId([FromRoute] string planId)
|
|
||||||
{
|
|
||||||
dynamic info = new ExpandoObject();
|
|
||||||
var planMoldRelation = await _db.Queryable<ToolMoldMaintainPlanRelation>().FirstAsync(it => it.id == planId);
|
|
||||||
if (planMoldRelation != null)
|
|
||||||
{
|
|
||||||
var mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == planMoldRelation.mold_id);
|
|
||||||
if (mold != null)
|
|
||||||
{
|
|
||||||
info.mold_code = mold.mold_code;
|
|
||||||
info.mold_name = mold.mold_name;
|
|
||||||
var moldEqpRelation = await _db.Queryable<ToolMoldsEquipment>().FirstAsync(it => it.mold_id == mold.id);
|
|
||||||
if (moldEqpRelation != null)
|
|
||||||
{
|
|
||||||
var eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moldEqpRelation.equipment_id);
|
|
||||||
info.eqp_code = eqp.code;
|
|
||||||
info.eqp_name = eqp.name;
|
|
||||||
}
|
|
||||||
var itemGroupRelation = await _db.Queryable<ToolMoldMaintainGroupRelation>().FirstAsync(it => it.mold_id == mold.id);
|
|
||||||
if (itemGroupRelation != null)
|
|
||||||
{
|
|
||||||
var itemGroup = await _db.Queryable<ToolMoldMaintainGroup>().FirstAsync(it => it.id == itemGroupRelation.item_group_id);
|
|
||||||
if (itemGroup != null)
|
|
||||||
{
|
|
||||||
info.item_group_name = itemGroup.name;
|
|
||||||
}
|
|
||||||
var itemRelation = await _db.Queryable<ToolMoldMaintainGroupItem>().FirstAsync(it => it.item_group_id == itemGroupRelation.item_group_id);
|
|
||||||
if (itemRelation != null)
|
|
||||||
{
|
|
||||||
var checkItem = await _db.Queryable<ToolMoldMaintainItem>().FirstAsync(it => it.id == itemRelation.item_id);
|
|
||||||
if (checkItem != null)
|
|
||||||
{
|
|
||||||
info.item_name = checkItem.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 模具保养计划执行-开始模具保养
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input">
|
|
||||||
/// {
|
|
||||||
/// plan_id:执行计划id
|
|
||||||
/// }
|
|
||||||
/// </param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpPost]
|
|
||||||
public async Task MaintainStart(MoldMaintainRunUpInput input)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await _db.Ado.BeginTranAsync();
|
|
||||||
|
|
||||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.MaintainStatusTypeId);
|
|
||||||
var plan = await _db.Queryable<ToolMoldMaintainPlan>().FirstAsync(it => it.id == input.plan_id);
|
|
||||||
if (plan != null)
|
|
||||||
{
|
|
||||||
plan.status = DictConst.MoldMaintainStatusDBYCode;
|
|
||||||
var row = await _db.Updateable(plan).ExecuteCommandAsync();
|
|
||||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
|
||||||
ToolMoldMaintainRunRecord record = new();
|
|
||||||
record.plan_code = plan.plan_code;
|
|
||||||
record.mode = plan.mode;
|
|
||||||
record.plan_status = dic.ContainsKey(plan.plan_code) ? dic[plan.plan_code].ToString() : "";
|
|
||||||
record.designer = _userManager.RealName;
|
|
||||||
record.designer_time = DateTime.Now;
|
|
||||||
var moldPlanRelation = await _db.Queryable<ToolMoldMaintainPlanRelation>().FirstAsync(it => it.maintain_plan_id == input.plan_id);
|
|
||||||
if (moldPlanRelation != null)
|
|
||||||
{
|
|
||||||
var mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == moldPlanRelation.mold_id);
|
|
||||||
record.mold_code = mold?.mold_code;
|
|
||||||
record.mold_name = mold?.mold_name;
|
|
||||||
var moldGroupRelation = await _db.Queryable<ToolMoldMaintainGroupRelation>().FirstAsync(it => it.mold_id == mold.id);
|
|
||||||
if (moldGroupRelation != null)
|
|
||||||
{
|
|
||||||
var maintainGroup = await _db.Queryable<ToolMoldMaintainGroup>().FirstAsync(it => it.id == moldGroupRelation.item_group_id);
|
|
||||||
record.group_name = maintainGroup.name;
|
|
||||||
var itemGrpRelation = await _db.Queryable<ToolMoldMaintainGroupItem>().FirstAsync(it => it.item_group_id == maintainGroup.id);
|
|
||||||
if (itemGrpRelation != null)
|
|
||||||
{
|
|
||||||
var checkItem = await _db.Queryable<ToolMoldMaintainItem>().FirstAsync(it => it.id == itemGrpRelation.item_id);
|
|
||||||
record.check_item_name = checkItem.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
record.plan_start_time = DateTime.Now;
|
|
||||||
row = await _db.Insertable(record).ExecuteCommandAsync();
|
|
||||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
|
||||||
|
|
||||||
await _db.Ado.CommitTranAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Error("开始模具保养失败", ex);
|
|
||||||
await _db.Ado.RollbackTranAsync();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 关联模具
|
/// 关联模具
|
||||||
|
|||||||
162
EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs
Normal file
162
EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Dynamic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Aspose.Cells.Drawing;
|
||||||
|
using JNPF.Common.Core.Manager;
|
||||||
|
using JNPF.Common.Enums;
|
||||||
|
using JNPF.DependencyInjection;
|
||||||
|
using JNPF.DynamicApiController;
|
||||||
|
using JNPF.FriendlyException;
|
||||||
|
using JNPF.Logging;
|
||||||
|
using JNPF.Systems.Interfaces.System;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using SqlSugar;
|
||||||
|
using Tnb.BasicData;
|
||||||
|
using Tnb.EquipMgr.Entities;
|
||||||
|
using Tnb.EquipMgr.Entities.Dto;
|
||||||
|
using Tnb.EquipMgr.Interfaces;
|
||||||
|
|
||||||
|
namespace Tnb.EquipMgr
|
||||||
|
{
|
||||||
|
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||||
|
[Route("api/[area]/[controller]/[action]")]
|
||||||
|
|
||||||
|
public class ToolMoldMaintainPlanRunService : IToolMoldMaintainPlanRunService, IDynamicApiController, ITransient
|
||||||
|
{
|
||||||
|
private readonly ISqlSugarClient _db;
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
private readonly IDictionaryDataService _dictionaryDataService;
|
||||||
|
|
||||||
|
public ToolMoldMaintainPlanRunService(ISqlSugarRepository<ToolMoldMaintainRule> repository, IUserManager userManager, IDictionaryDataService dictionaryDataService)
|
||||||
|
{
|
||||||
|
_db = repository.AsSugarClient();
|
||||||
|
_userManager = userManager;
|
||||||
|
_dictionaryDataService = dictionaryDataService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据计划id,获取相关联模具、设备、保养项目组、保养项,信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="planId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<dynamic> GetMaintainInfoFromByPlanId([FromRoute] string planId)
|
||||||
|
{
|
||||||
|
dynamic info = new ExpandoObject();
|
||||||
|
var planMoldRelation = await _db.Queryable<ToolMoldMaintainPlanRelation>().FirstAsync(it => it.id == planId);
|
||||||
|
if (planMoldRelation != null)
|
||||||
|
{
|
||||||
|
var mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == planMoldRelation.mold_id);
|
||||||
|
if (mold != null)
|
||||||
|
{
|
||||||
|
info.mold_code = mold.mold_code;
|
||||||
|
info.mold_name = mold.mold_name;
|
||||||
|
var moldEqpRelation = await _db.Queryable<ToolMoldsEquipment>().FirstAsync(it => it.mold_id == mold.id);
|
||||||
|
if (moldEqpRelation != null)
|
||||||
|
{
|
||||||
|
var eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moldEqpRelation.equipment_id);
|
||||||
|
info.eqp_code = eqp.code;
|
||||||
|
info.eqp_name = eqp.name;
|
||||||
|
}
|
||||||
|
var itemGroupRelation = await _db.Queryable<ToolMoldMaintainGroupRelation>().FirstAsync(it => it.mold_id == mold.id);
|
||||||
|
if (itemGroupRelation != null)
|
||||||
|
{
|
||||||
|
var itemGroup = await _db.Queryable<ToolMoldMaintainGroup>().FirstAsync(it => it.id == itemGroupRelation.item_group_id);
|
||||||
|
if (itemGroup != null)
|
||||||
|
{
|
||||||
|
info.item_group_name = itemGroup.name;
|
||||||
|
}
|
||||||
|
var itemRelation = await _db.Queryable<ToolMoldMaintainGroupItem>().FirstAsync(it => it.item_group_id == itemGroupRelation.item_group_id);
|
||||||
|
if (itemRelation != null)
|
||||||
|
{
|
||||||
|
var checkItem = await _db.Queryable<ToolMoldMaintainItem>().FirstAsync(it => it.id == itemRelation.item_id);
|
||||||
|
if (checkItem != null)
|
||||||
|
{
|
||||||
|
info.item_name = checkItem.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 模具保养计划执行-开始模具保养
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">
|
||||||
|
/// {
|
||||||
|
/// plan_id:执行计划id
|
||||||
|
/// }
|
||||||
|
/// </param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task MaintainStart(MoldMaintainRunUpInput input)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.MaintainStatusTypeId);
|
||||||
|
var plan = await _db.Queryable<ToolMoldMaintainPlan>().FirstAsync(it => it.id == input.plan_id);
|
||||||
|
if (plan != null)
|
||||||
|
{
|
||||||
|
plan.status = DictConst.MoldMaintainStatusDBYCode;
|
||||||
|
var row = await _db.Updateable(plan).ExecuteCommandAsync();
|
||||||
|
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
|
ToolMoldMaintainRunRecord record = new();
|
||||||
|
record.plan_code = plan.plan_code;
|
||||||
|
record.mode = plan.mode;
|
||||||
|
record.plan_status = dic.ContainsKey(plan.plan_code) ? dic[plan.plan_code].ToString() : "";
|
||||||
|
record.designer = _userManager.RealName;
|
||||||
|
record.designer_time = DateTime.Now;
|
||||||
|
var moldPlanRelation = await _db.Queryable<ToolMoldMaintainPlanRelation>().FirstAsync(it => it.maintain_plan_id == input.plan_id);
|
||||||
|
if (moldPlanRelation != null)
|
||||||
|
{
|
||||||
|
var mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == moldPlanRelation.mold_id);
|
||||||
|
record.mold_code = mold?.mold_code;
|
||||||
|
record.mold_name = mold?.mold_name;
|
||||||
|
var moldGroupRelation = await _db.Queryable<ToolMoldMaintainGroupRelation>().FirstAsync(it => it.mold_id == mold.id);
|
||||||
|
if (moldGroupRelation != null)
|
||||||
|
{
|
||||||
|
var maintainGroup = await _db.Queryable<ToolMoldMaintainGroup>().FirstAsync(it => it.id == moldGroupRelation.item_group_id);
|
||||||
|
record.group_name = maintainGroup.name;
|
||||||
|
var itemGrpRelation = await _db.Queryable<ToolMoldMaintainGroupItem>().FirstAsync(it => it.item_group_id == maintainGroup.id);
|
||||||
|
if (itemGrpRelation != null)
|
||||||
|
{
|
||||||
|
var checkItem = await _db.Queryable<ToolMoldMaintainItem>().FirstAsync(it => it.id == itemGrpRelation.item_id);
|
||||||
|
record.check_item_name = checkItem.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
record.plan_start_time = DateTime.Now;
|
||||||
|
row = await _db.Insertable(record).ExecuteCommandAsync();
|
||||||
|
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||||
|
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error("开始模具保养失败", ex);
|
||||||
|
await _db.Ado.RollbackTranAsync();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 模具保养计划执行-保养完成
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task MaintainFinish(MoldMaintainRunUpInput input)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Aspose.Cells.Drawing;
|
using Aspose.Cells.Drawing;
|
||||||
|
using JNPF.Common.Dtos.VisualDev;
|
||||||
using JNPF.Common.Enums;
|
using JNPF.Common.Enums;
|
||||||
using JNPF.Common.Extension;
|
using JNPF.Common.Extension;
|
||||||
using JNPF.DependencyInjection;
|
using JNPF.DependencyInjection;
|
||||||
@@ -47,9 +48,11 @@ namespace Tnb.EquipMgr
|
|||||||
_runService = runService;
|
_runService = runService;
|
||||||
_visualDevService = visualDevService;
|
_visualDevService = visualDevService;
|
||||||
OverideFuncs.GetListAsync = GetList;
|
OverideFuncs.GetListAsync = GetList;
|
||||||
|
//OverideFuncs.CreateAsync = Create;
|
||||||
}
|
}
|
||||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||||
|
|
||||||
|
|
||||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||||
{
|
{
|
||||||
if (_dicMold.Count < 1)
|
if (_dicMold.Count < 1)
|
||||||
|
|||||||
@@ -8,14 +8,22 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
|||||||
{
|
{
|
||||||
public class ClosedownHistoryOutput
|
public class ClosedownHistoryOutput
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设备编码
|
||||||
|
/// </summary>
|
||||||
|
public string eqp_code { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 设备名称
|
||||||
|
/// </summary>
|
||||||
|
public string eqp_name { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 停机开始时间
|
/// 停机开始时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? closedown_start_time { get; set; }
|
public string? closedown_start_time { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 停机结束时间
|
/// 停机结束时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? closedown_end_time { get; set; }
|
public string? closedown_end_time { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 停机时间
|
/// 停机时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||||
|
{
|
||||||
|
public class GenSubMoCrInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 父工单id
|
||||||
|
/// </summary>
|
||||||
|
public string mo_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 子物料ids
|
||||||
|
/// </summary>
|
||||||
|
public List<string> ids { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//public class SubMo
|
||||||
|
//{
|
||||||
|
// /// <summary>
|
||||||
|
// /// 物料id
|
||||||
|
// /// </summary>
|
||||||
|
// public string material_id { get; set; }
|
||||||
|
// /// <summary>
|
||||||
|
// /// 物料编码
|
||||||
|
// /// </summary>
|
||||||
|
// public string material_code { get; set; }
|
||||||
|
// /// <summary>
|
||||||
|
// /// 物料名称
|
||||||
|
// /// </summary>
|
||||||
|
// public string material_name { get; set; }
|
||||||
|
// /// <summary>
|
||||||
|
// /// 物料型号
|
||||||
|
// /// </summary>
|
||||||
|
// public string material_category_code { get; set; }
|
||||||
|
// /// <summary>
|
||||||
|
// ///输出数量
|
||||||
|
// /// </summary>
|
||||||
|
// public int output_qty { get; set; }
|
||||||
|
//}
|
||||||
|
}
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using JNPF.Common.Security;
|
||||||
|
|
||||||
|
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||||
|
{
|
||||||
|
public class PrdMotreeOutput : TreeModel
|
||||||
|
{
|
||||||
|
public string? org_id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 工单id
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
public string mo_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工单代码
|
||||||
|
/// </summary>
|
||||||
|
public string mo_code { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 物料编号
|
||||||
|
/// </summary>
|
||||||
|
public string? material_code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工单类型:1-正常工单、2-返工工单、3-试制工单
|
||||||
|
/// </summary>
|
||||||
|
public string? mo_type { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生产状态 Initial: 初始, Confirm:确认 Release: 下发, Open: 生产中, Close: 关单, Pending: 暂停
|
||||||
|
/// </summary>
|
||||||
|
public string? mo_status { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 计划生产数量
|
||||||
|
/// </summary>
|
||||||
|
public int? plan_qty { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 已投入数量
|
||||||
|
/// </summary>
|
||||||
|
public int? input_qty { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 已完工数量
|
||||||
|
/// </summary>
|
||||||
|
public int? complete_qty { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 报废数量
|
||||||
|
/// </summary>
|
||||||
|
public int? scrap_qty { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 计划开始时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? plan_start_date { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 计划结束时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? plan_end_date { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否生派工单
|
||||||
|
/// </summary>
|
||||||
|
public int? is_create_dispatch { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 产线代码
|
||||||
|
/// </summary>
|
||||||
|
public string? production_linecode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否合并
|
||||||
|
/// </summary>
|
||||||
|
public int? is_merge { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 组合工单
|
||||||
|
/// </summary>
|
||||||
|
public string? combine_mo_code { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 时间戳
|
||||||
|
/// </summary>
|
||||||
|
public string? time_stamp { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建用户
|
||||||
|
/// </summary>
|
||||||
|
public string? create_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? create_time { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改用户
|
||||||
|
/// </summary>
|
||||||
|
public string? modify_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? modify_time { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 物料ID
|
||||||
|
/// </summary>
|
||||||
|
public string? material_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 已排产数量
|
||||||
|
/// </summary>
|
||||||
|
public int? scheduled_qty { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 父工单id
|
||||||
|
/// </summary>
|
||||||
|
public string parent_id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -218,5 +218,9 @@ public partial class PrdMo : BaseEntity<string>
|
|||||||
/// 已排产数量
|
/// 已排产数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? scheduled_qty { get; set; }
|
public int? scheduled_qty { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 父工单id
|
||||||
|
/// </summary>
|
||||||
|
public string parent_id { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,15 +139,17 @@ namespace Tnb.ProductionMgr
|
|||||||
{
|
{
|
||||||
var pagedList = await _db.Queryable<PrdCancelClosedownRecord>()
|
var pagedList = await _db.Queryable<PrdCancelClosedownRecord>()
|
||||||
.WhereIF(!string.IsNullOrEmpty(input.eqpName), it => it.eqp_name.Contains(input.eqpName))
|
.WhereIF(!string.IsNullOrEmpty(input.eqpName), it => it.eqp_name.Contains(input.eqpName))
|
||||||
.WhereIF(input.beginTime.HasValue, it => it.closedown_start_time.Value == input.beginTime)
|
.WhereIF(input.beginTime.HasValue, it => it.closedown_start_time.Value >= input.beginTime)
|
||||||
.WhereIF(input.endTime.HasValue, it => it.closedown_end_time.Value == input.endTime)
|
.WhereIF(input.endTime.HasValue, it => it.closedown_start_time.Value <= input.endTime)
|
||||||
.Select(it => new ClosedownHistoryOutput
|
.Select(it => new ClosedownHistoryOutput
|
||||||
{
|
{
|
||||||
closedown_start_time = it.closedown_start_time,
|
eqp_code = it.eqp_code,
|
||||||
closedown_end_time = it.closedown_end_time,
|
eqp_name = it.eqp_name,
|
||||||
|
closedown_start_time = it.closedown_start_time.HasValue ? it.closedown_start_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : null,
|
||||||
|
closedown_end_time = it.closedown_end_time.HasValue ? it.closedown_end_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : null,
|
||||||
closedown_time = it.closedown_time,
|
closedown_time = it.closedown_time,
|
||||||
})
|
})
|
||||||
.ToPagedListAsync(input.currentPage, input.pageSize);
|
.ToListAsync();
|
||||||
return pagedList;
|
return pagedList;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -216,8 +218,9 @@ namespace Tnb.ProductionMgr
|
|||||||
var mold = await _moldService.GetListById(moldId);
|
var mold = await _moldService.GetListById(moldId);
|
||||||
var maintaindTask = new ToolMoldMaintainTask();
|
var maintaindTask = new ToolMoldMaintainTask();
|
||||||
maintaindTask.mold_id = moldId;
|
maintaindTask.mold_id = moldId;
|
||||||
maintaindTask.code = DictConst.MaintainStatusDWXCode;
|
maintaindTask.code = mold.mold_code;
|
||||||
maintaindTask.create_id = _userManager.UserId;
|
maintaindTask.create_id = _userManager.UserId;
|
||||||
|
maintaindTask.status = DictConst.UnMaintainStatusCode;
|
||||||
maintaindTask.create_time = DateTime.Now;
|
maintaindTask.create_time = DateTime.Now;
|
||||||
|
|
||||||
await _maintainTaskService.Create(maintaindTask);
|
await _maintainTaskService.Create(maintaindTask);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ namespace Tnb.ProductionMgr
|
|||||||
private readonly IDictionaryDataService _dictionaryDataService;
|
private readonly IDictionaryDataService _dictionaryDataService;
|
||||||
private readonly IRunService _runService;
|
private readonly IRunService _runService;
|
||||||
private readonly IVisualDevService _visualDevService;
|
private readonly IVisualDevService _visualDevService;
|
||||||
|
private readonly ISqlSugarClient _db;
|
||||||
|
|
||||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ namespace Tnb.ProductionMgr
|
|||||||
_dictionaryDataService = dictionaryDataService;
|
_dictionaryDataService = dictionaryDataService;
|
||||||
_runService = runService;
|
_runService = runService;
|
||||||
_visualDevService = visualDevService;
|
_visualDevService = visualDevService;
|
||||||
|
_db = _repository.AsSugarClient();
|
||||||
OverideFuncs.GetListAsync = GetList;
|
OverideFuncs.GetListAsync = GetList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,6 +243,8 @@ namespace Tnb.ProductionMgr
|
|||||||
.ExecuteCommandHasChangeAsync();
|
.ExecuteCommandHasChangeAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -466,6 +466,35 @@ namespace Tnb.ProductionMgr
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取组装、包装 待排产工单树形列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<dynamic> GetUnSchedulingList()
|
||||||
|
{
|
||||||
|
List<PrdMotreeOutput> trees = new();
|
||||||
|
var list = await _db.Queryable<PrdMo>().Where(it => string.IsNullOrEmpty(it.parent_id) && it.mo_status == DictConst.ScheduledId).ToListAsync();
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
var node = item.Adapt<PrdMotreeOutput>();
|
||||||
|
node.mo_id = item.id;
|
||||||
|
node.id = SnowflakeIdHelper.NextId();
|
||||||
|
node.parentId = "0";
|
||||||
|
var items = await _db.Queryable<PrdMo>().Where(it => it.parent_id == item.id).ToListAsync();
|
||||||
|
if (items?.Count() > 0)
|
||||||
|
{
|
||||||
|
var childNodes = items.Adapt<List<PrdMotreeOutput>>();
|
||||||
|
for (int i = 0; i < items.Count; i++)
|
||||||
|
{
|
||||||
|
childNodes[i].mo_id = items[i].id;
|
||||||
|
}
|
||||||
|
trees.AddRange(childNodes);
|
||||||
|
}
|
||||||
|
trees.Add(node);
|
||||||
|
}
|
||||||
|
return trees.ToTree();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -653,6 +682,24 @@ namespace Tnb.ProductionMgr
|
|||||||
taskLog.mo_task_id = moTask.id;
|
taskLog.mo_task_id = moTask.id;
|
||||||
taskLog.mo_task_code = moTask.mo_task_code!;
|
taskLog.mo_task_code = moTask.mo_task_code!;
|
||||||
row = await _db.Insertable(taskLog).ExecuteCommandAsync();
|
row = await _db.Insertable(taskLog).ExecuteCommandAsync();
|
||||||
|
//将生产任务插入到自检报废记录表
|
||||||
|
//var sacipRecord = new PrdMoTaskDefectRecord();
|
||||||
|
//sacipRecord.id = SnowflakeIdHelper.NextId();
|
||||||
|
//sacipRecord.material_code = material?.code!;
|
||||||
|
//sacipRecord.material_name = material?.name!;
|
||||||
|
//sacipRecord.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moTask.eqp_id))?.code!;
|
||||||
|
//sacipRecord.mold_name = (await db.Queryable<ToolMolds>().FirstAsync(it => it.id == moTask.mold_id))?.mold_name!;
|
||||||
|
//sacipRecord.estimated_start_date = moTask.plan_start_date;
|
||||||
|
//sacipRecord.estimated_end_date = moTask.plan_end_date;
|
||||||
|
//sacipRecord.plan_qty = moTask.plan_qty;
|
||||||
|
//sacipRecord.scrap_qty = moTask.scrap_qty;
|
||||||
|
//sacipRecord.status = moTask.mo_task_status;
|
||||||
|
//sacipRecord.create_id = _userManager.UserId;
|
||||||
|
//sacipRecord.create_time = DateTime.Now;
|
||||||
|
//sacipRecord.mo_task_id = moTask.id;
|
||||||
|
//sacipRecord.mo_task_code = moTask.mo_task_code;
|
||||||
|
//await db.Insertable(sacipRecord).ExecuteCommandAsync();
|
||||||
|
|
||||||
//根据工单号获取当前工单包含的已排产数
|
//根据工单号获取当前工单包含的已排产数
|
||||||
var schedQty = _db.Queryable<PrdMoTask>().Where(it => it.mo_id == input.mo_id)?.Sum(d => d.scheduled_qty);
|
var schedQty = _db.Queryable<PrdMoTask>().Where(it => it.mo_id == input.mo_id)?.Sum(d => d.scheduled_qty);
|
||||||
if (mo != null)
|
if (mo != null)
|
||||||
@@ -1026,6 +1073,54 @@ namespace Tnb.ProductionMgr
|
|||||||
return row > 0;
|
return row > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成子工单
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task GenSubMo(GenSubMoCrInput input)
|
||||||
|
{
|
||||||
|
if (input is null) throw new ArgumentNullException("input");
|
||||||
|
if (input.ids is null || input.ids.Count == 0) throw new ArgumentException($"{nameof(input.ids)} not be null or count zero");
|
||||||
|
var curMo = await _db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id);
|
||||||
|
if (curMo == null) throw new ArgumentNullException("创建子工单时的父工单不能为null");
|
||||||
|
List<PrdMo> subMoList = new();
|
||||||
|
var outputMaterials = await _db.Queryable<BasMaterial>().LeftJoin<BasMbomOutput>((a, b) => a.id == b.material_id)
|
||||||
|
.Where((a, b) => input.ids.Contains(a.id))
|
||||||
|
.Select((a, b) => new
|
||||||
|
{
|
||||||
|
material_id = a.id,
|
||||||
|
material_code = a.code,
|
||||||
|
num = b.num,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
foreach (var om in outputMaterials)
|
||||||
|
{
|
||||||
|
PrdMo subMo = new();
|
||||||
|
subMo.material_id = om.material_id;
|
||||||
|
subMo.material_code = om.material_code;
|
||||||
|
subMo.plan_qty = om.num.ParseToInt() * curMo.plan_qty;
|
||||||
|
subMo.mo_type = curMo.mo_type;
|
||||||
|
subMo.parent_id = curMo.id;
|
||||||
|
subMo.plan_start_date = curMo.plan_start_date;
|
||||||
|
subMo.plan_end_date = curMo.plan_end_date;
|
||||||
|
subMo.create_id = _userManager.UserId;
|
||||||
|
subMo.create_time = DateTime.Now;
|
||||||
|
subMo.mo_status = DictConst.WaitProductId;
|
||||||
|
subMoList.Add(subMo);
|
||||||
|
}
|
||||||
|
//生成子工单编码
|
||||||
|
for (int i = 0; i < subMoList.Count; i++)
|
||||||
|
{
|
||||||
|
var num = (i + 1).ToString().PadLeft(2, '0');
|
||||||
|
subMoList[i].mo_code = $"{subMoList[i].mo_code}-{num}";
|
||||||
|
}
|
||||||
|
var row = await _db.Insertable(subMoList).ExecuteCommandAsync();
|
||||||
|
if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user