根据生产bom拆分子工单代码调整
This commit is contained in:
@@ -35,5 +35,26 @@ namespace Tnb.BasicData.Entities.Dto
|
||||
/// 数量
|
||||
/// </summary>
|
||||
public string num { get; set;}
|
||||
/// <summary>
|
||||
/// 单位id
|
||||
/// </summary>
|
||||
public string unit_id { get; set; }
|
||||
/// <summary>
|
||||
/// bomid
|
||||
/// </summary>
|
||||
public string bom_id { get; set; }
|
||||
/// <summary>
|
||||
/// 工序id
|
||||
/// </summary>
|
||||
public string process_id { get; set; }
|
||||
/// <summary>
|
||||
/// bom版本
|
||||
/// </summary>
|
||||
public string version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工艺路线名称
|
||||
/// </summary>
|
||||
public string route_name { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,35 +133,51 @@ namespace Tnb.BasicData
|
||||
/// <summary>
|
||||
/// 根据bomid获取对应的子bom列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="bomId">bomId</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
/// <remarks>
|
||||
/// returns:
|
||||
/// <br/>{
|
||||
/// <br/> version:bom版本
|
||||
/// <br/> unit_id:单位id
|
||||
/// <br/> route_name:工艺路线名称
|
||||
/// <br/> process_id:工序id
|
||||
/// <br/> material_id:物料id
|
||||
/// <br/> material_code:物料编码
|
||||
/// <br/> material_name:物料名称
|
||||
/// <br/> material_category_code:类别code
|
||||
/// <br/> output_qty:输出参数
|
||||
/// <br/>}
|
||||
/// </remarks>
|
||||
[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
|
||||
var result = await _db.Queryable<BasMbom>()
|
||||
.LeftJoin<BasRouteH>((a, b) => a.route_id == b.id)
|
||||
.LeftJoin<BasRouteD>((a, b, c) => b.id == c.route_id)
|
||||
.LeftJoin<BasMbomProcess>((a, b, c, d) => c.process_id == d.process_id)
|
||||
.LeftJoin<BasMbomOutput>((a, b, c, d, e) => e.mbom_id == a.id && e.mbom_process_id == d.id)
|
||||
.Where((a, b, c, d, e) => a.id == bomId && a.material_id != e.material_id && !string.IsNullOrEmpty(e.material_id))
|
||||
.Select((a, b, c, d, e) => new SubBomListOutput
|
||||
{
|
||||
material_id = e.id,
|
||||
material_code = e.code,
|
||||
material_name = e.name,
|
||||
material_category_code = f.category_code,
|
||||
num = d.num
|
||||
version = a.version,
|
||||
unit_id = a.unit_id,
|
||||
route_name = b.name,
|
||||
process_id = c.process_id,
|
||||
material_id = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.id),
|
||||
material_code = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.code),
|
||||
material_name = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.name),
|
||||
material_category_code = "",
|
||||
num = e.num,
|
||||
})
|
||||
.Mapper(it => it.output_qty = it.num.ParseToInt())
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据物料id获取生产bom
|
||||
/// </summary>
|
||||
@@ -182,6 +198,7 @@ namespace Tnb.BasicData
|
||||
[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)
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
@@ -16,7 +17,7 @@ namespace Tnb.EquipMgr.Interfaces
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <returns></returns>
|
||||
public Task<List<EquipmentListOutput>> GetEquipmentLists(ToolMoldInput ToolMoldInput);
|
||||
public Task<List<Entities.Dto.EquipmentListOutput>> GetEquipmentLists(ToolMoldInput ToolMoldInput);
|
||||
/// <summary>
|
||||
/// 增加模具设备绑定
|
||||
/// </summary>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ProductionMgr\Tnb.ProductionMgr.Entities\Tnb.ProductionMgr.Entities.csproj" />
|
||||
<ProjectReference Include="..\Tnb.EquipMgr.Entities\Tnb.EquipMgr.Entities.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -141,6 +141,7 @@ namespace Tnb.EquipMgr
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var maintainRules = await _db.Queryable<ToolMoldMaintainRule>().Where(it => input.ruleIds.Contains(it.id)).ToListAsync();
|
||||
var ruleMoldRelations = await _db.Queryable<ToolMoldMaintainRuleRelation>().Where(it=>input.ruleIds.Contains(it.rule_id)).ToListAsync();
|
||||
if (maintainRules?.Count > 0)
|
||||
{
|
||||
List<ToolMoldMaintainPlan> maintainPlans = new();
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Tnb.EquipMgr
|
||||
public async Task<dynamic> GetMaintainInfoFromByPlanId([FromRoute] string planId)
|
||||
{
|
||||
dynamic info = new ExpandoObject();
|
||||
var planMoldRelation = await _db.Queryable<ToolMoldMaintainPlanRelation>().FirstAsync(it => it.id == planId);
|
||||
var planMoldRelation = await _db.Queryable<ToolMoldMaintainPlanRelation>().FirstAsync(it => it.maintain_plan_id == planId);
|
||||
if (planMoldRelation != null)
|
||||
{
|
||||
var mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == planMoldRelation.mold_id);
|
||||
|
||||
@@ -18,6 +18,7 @@ using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{ /// <summary>
|
||||
@@ -67,7 +68,7 @@ namespace Tnb.EquipMgr
|
||||
/// <param name="mold"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<List<EquipmentListOutput>> GetEquipmentLists(ToolMoldInput ToolMoldInput)
|
||||
public async Task<List<Tnb.EquipMgr.Entities.Dto.EquipmentListOutput>> GetEquipmentLists(ToolMoldInput ToolMoldInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var list = await db.Queryable<EqpEquipment, ToolMoldsEquipment>((a, b) => new object[]
|
||||
@@ -75,7 +76,7 @@ namespace Tnb.EquipMgr
|
||||
JoinType.Inner, a.id == b.equipment_id,
|
||||
})
|
||||
.Where((a, b) => b.mold_id == ToolMoldInput.mold)
|
||||
.Select((a, b) => new EquipmentListOutput
|
||||
.Select((a, b) => new Tnb.EquipMgr.Entities.Dto.EquipmentListOutput
|
||||
{
|
||||
id = a.id,
|
||||
eqp_code = a.code,
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto
|
||||
{
|
||||
public class DictionaryTreeOutput
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string parentId { get; set; }
|
||||
public List<dynamic> Child { get; set; }
|
||||
public bool HasChild { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,14 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class GenSubMoCrInput
|
||||
{
|
||||
public string bom_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 父工单id
|
||||
/// </summary>
|
||||
public string mo_id { get; set; }
|
||||
/// <summary>
|
||||
/// 子物料ids
|
||||
/// 工序ids
|
||||
/// </summary>
|
||||
public List<string> ids { get; set; }
|
||||
|
||||
|
||||
@@ -7,8 +7,12 @@ using JNPF.Common.Security;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class PrdMotreeOutput : TreeModel
|
||||
public class PrdMoTreeOutput : TreeModel
|
||||
{
|
||||
|
||||
//public Dictionary<string, object> row { get; set; }
|
||||
|
||||
#region 注释代码
|
||||
public string? org_id { get; set; }
|
||||
/// <summary>
|
||||
/// 工单id
|
||||
@@ -25,6 +29,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// 物料编号
|
||||
/// </summary>
|
||||
public string? material_code { get; set; }
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string material_name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单类型:1-正常工单、2-返工工单、3-试制工单
|
||||
@@ -39,37 +47,37 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// <summary>
|
||||
/// 计划生产数量
|
||||
/// </summary>
|
||||
public int? plan_qty { get; set; }
|
||||
public string plan_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已投入数量
|
||||
/// </summary>
|
||||
public int? input_qty { get; set; }
|
||||
public string input_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已完工数量
|
||||
/// </summary>
|
||||
public int? complete_qty { get; set; }
|
||||
public string complete_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报废数量
|
||||
/// </summary>
|
||||
public int? scrap_qty { get; set; }
|
||||
public string scrap_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划开始时间
|
||||
/// </summary>
|
||||
public DateTime? plan_start_date { get; set; }
|
||||
public string plan_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划结束时间
|
||||
/// </summary>
|
||||
public DateTime? plan_end_date { get; set; }
|
||||
public string plan_end_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否生派工单
|
||||
/// </summary>
|
||||
public int? is_create_dispatch { get; set; }
|
||||
public string is_create_dispatch { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -80,7 +88,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// <summary>
|
||||
/// 是否合并
|
||||
/// </summary>
|
||||
public int? is_merge { get; set; }
|
||||
public string is_merge { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组合工单
|
||||
@@ -100,7 +108,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
public string create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
@@ -110,19 +118,20 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
public string modify_time { get; set; }
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
public string? material_id { get; set; }
|
||||
|
||||
public string? material_id_id { get; set; }
|
||||
/// <summary>
|
||||
/// 已排产数量
|
||||
/// </summary>
|
||||
public int? scheduled_qty { get; set; }
|
||||
public string scheduled_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 父工单id
|
||||
/// </summary>
|
||||
public string parent_id { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,5 +48,9 @@ public partial class PrdMoTaskDefect : BaseEntity<string>
|
||||
/// 批次
|
||||
/// </summary>
|
||||
public string? batch { get; set; }
|
||||
/// <summary>
|
||||
/// 报废数量
|
||||
/// </summary>
|
||||
public int scrap_qty { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,11 @@ using Aspose.Cells.Drawing.Texts;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using WebSocketSharp.Frame;
|
||||
using JNPF.Logging;
|
||||
using System.Dynamic;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using JNPF.Common.Filter;
|
||||
using Tnb.BasicData.Entities.Dto;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
@@ -45,6 +50,7 @@ namespace Tnb.ProductionMgr
|
||||
public class PrdMoTaskService : IOverideVisualDevService, IPrdMoTaskService, IDynamicApiController, ITransient
|
||||
{
|
||||
private const string ModuleId = "25567924238373";
|
||||
private const string MoModuleId = "25018860321301";
|
||||
private readonly ISqlSugarRepository<PrdTask> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
@@ -98,12 +104,12 @@ namespace Tnb.ProductionMgr
|
||||
[HttpGet("{materialId}")]
|
||||
public async Task<dynamic> GetMoldListByItemId(string materialId)
|
||||
{
|
||||
var result = new List<MoldListOutput>();
|
||||
var result = new List<Tnb.ProductionMgr.Entities.Dto.MoldListOutput>();
|
||||
result = await _db.Queryable<ToolMoldsMaterial>()
|
||||
.InnerJoin<ToolMolds>((a, b) => a.mold_id == b.id)
|
||||
.InnerJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||
.Where((a, b, c) => a.material_id == materialId)
|
||||
.Select((a, b, c) => new MoldListOutput
|
||||
.Select((a, b, c) => new Tnb.ProductionMgr.Entities.Dto.MoldListOutput
|
||||
{
|
||||
mold_id = a.id,
|
||||
mold_code = b.mold_code,
|
||||
@@ -125,7 +131,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
var items = await _db.Queryable<ToolMoldsEquipment>().InnerJoin<EqpEquipment>((a, b) => a.equipment_id == b.id)
|
||||
.Where((a, b) => a.mold_id == moldId)
|
||||
.Select((a, b) => new EquipmentListOutput
|
||||
.Select((a, b) => new Entities.Dto.EquipmentListOutput
|
||||
{
|
||||
eqp_id = b.id,
|
||||
eqp_code = b.code,
|
||||
@@ -255,7 +261,7 @@ namespace Tnb.ProductionMgr
|
||||
material_code = materialCode,
|
||||
material_name = materialName,
|
||||
prd_qty = it.prd_qty,
|
||||
//scrap_qty = SqlFunc.Subqueryable<PrdScrapped>().Select(x => x.scrap_qty),
|
||||
scrap_qty = SqlFunc.Subqueryable<PrdMoTaskDefect>().Where(pmtd => pmtd.mo_task_id == it.mo_task_id).Select(x => x.scrap_qty),
|
||||
})
|
||||
.Mapper(it =>
|
||||
{
|
||||
@@ -271,7 +277,7 @@ namespace Tnb.ProductionMgr
|
||||
icmo_qty = db.Queryable<PrdMoTask>().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty,
|
||||
reported_work_qty = 0,
|
||||
prd_qty = 0,
|
||||
//scrap_qty = 0,
|
||||
scrap_qty = 0,
|
||||
};
|
||||
return res;
|
||||
}
|
||||
@@ -471,29 +477,74 @@ namespace Tnb.ProductionMgr
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetUnSchedulingList()
|
||||
public async Task<dynamic> GetUnSchedulingList([FromQuery] VisualDevModelListQueryInput input)
|
||||
{
|
||||
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)
|
||||
List<PrdMoTreeOutput> trees = new();
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(MoModuleId, true);
|
||||
var data = await _runService.GetListResult(templateEntity, input);
|
||||
|
||||
if (data?.list?.Count > 0)
|
||||
{
|
||||
var node = item.Adapt<PrdMotreeOutput>();
|
||||
node.mo_id = item.id;
|
||||
node.id = SnowflakeIdHelper.NextId();
|
||||
var parentIdField = nameof(PrdMo.parent_id);
|
||||
var nodes = data.list.Where(it => it.ContainsKey(parentIdField) && it[parentIdField].IsNullOrEmpty()).ToList();
|
||||
foreach (var row in nodes)
|
||||
{
|
||||
var pkName = "material_id_id";
|
||||
var dic = row.ToDictionary(x => x.Key, x => x.Value);
|
||||
|
||||
PrdMoTreeOutput node = DictionaryToObject<PrdMoTreeOutput>(row);
|
||||
node.parentId = "0";
|
||||
var items = await _db.Queryable<PrdMo>().Where(it => it.parent_id == item.id).ToListAsync();
|
||||
if (items?.Count() > 0)
|
||||
node.mo_id = node.id;
|
||||
if (dic.ContainsKey(pkName))
|
||||
{
|
||||
var childNodes = items.Adapt<List<PrdMotreeOutput>>();
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
var materialId = dic[pkName]?.ToString();
|
||||
var material = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == materialId);
|
||||
node.material_id_id = materialId;
|
||||
node.material_code = material?.code;
|
||||
node.material_name = material?.name;
|
||||
}
|
||||
|
||||
var queryObj = new { parent_id = node.id };
|
||||
input.superQueryJson = "";
|
||||
input.queryJson = queryObj.ToJsonString();
|
||||
var subData = await _runService.GetListResult(templateEntity, input);
|
||||
if (subData?.list?.Count > 0)
|
||||
{
|
||||
childNodes[i].mo_id = items[i].id;
|
||||
var childNodes = new List<PrdMoTreeOutput>();
|
||||
foreach (var item in subData.list)
|
||||
{
|
||||
dic = item.ToDictionary(x => x.Key, x => x.Value);
|
||||
PrdMoTreeOutput subNode = DictionaryToObject<PrdMoTreeOutput>(item);
|
||||
subNode.parentId = node.id;
|
||||
subNode.mo_id = subNode.id;
|
||||
if (dic.ContainsKey(pkName))
|
||||
{
|
||||
var materialId = dic[pkName]?.ToString();
|
||||
var material = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == materialId);
|
||||
subNode.material_id_id = materialId;
|
||||
subNode.material_code = material?.code;
|
||||
subNode.material_name = material?.name;
|
||||
}
|
||||
childNodes.Add(subNode);
|
||||
}
|
||||
trees.AddRange(childNodes);
|
||||
}
|
||||
trees.Add(node);
|
||||
}
|
||||
return trees.ToTree();
|
||||
}
|
||||
var treeList = trees.ToTree();
|
||||
var list = treeList.Skip(input.currentPage - 1).Take(input.pageSize).ToList();
|
||||
SqlSugarPagedList<PrdMoTreeOutput> pagedList = new()
|
||||
{
|
||||
list = treeList,
|
||||
pagination = new Pagination
|
||||
{
|
||||
CurrentPage = input.currentPage,
|
||||
PageSize = input.pageSize,
|
||||
Total = treeList.Count
|
||||
}
|
||||
};
|
||||
return PageResult<PrdMoTreeOutput>.SqlSugarPageResult(pagedList);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -769,7 +820,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("组装包装排产时报错", ex);
|
||||
JNPF.Logging.Log.Error("组装包装排产时报错", ex);
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
}
|
||||
return row > 0;
|
||||
@@ -1037,7 +1088,7 @@ namespace Tnb.ProductionMgr
|
||||
defect.defective_item = dItem.defective_item;
|
||||
defect.defective_item_qty = dItem.defective_item_qty;
|
||||
defect.create_id = _userManager.UserId;
|
||||
|
||||
defect.scrap_qty = input.scrap_qty;
|
||||
destDefects.Add(defect);
|
||||
}
|
||||
}
|
||||
@@ -1084,22 +1135,31 @@ namespace Tnb.ProductionMgr
|
||||
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
|
||||
|
||||
|
||||
var outMaterials = await _db.Queryable<BasMbom>().InnerJoin<BasMbomProcess>((a, b) => a.id == b.mbom_id)
|
||||
.InnerJoin<BasMbomOutput>((a, b, c) => a.id == c.mbom_id && b.id == c.mbom_process_id)
|
||||
.Where((a, b, c) => a.id == input.bom_id && input.ids.Contains(b.process_id))
|
||||
.Select((a, b, c) => new
|
||||
{
|
||||
material_id = a.id,
|
||||
material_code = a.code,
|
||||
num = b.num,
|
||||
material_id = a.material_id,
|
||||
num = c.num,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
if (outMaterials?.Count > 0)
|
||||
{
|
||||
var mids = await _db.Queryable<PrdMo>().Where(it => it.id == input.mo_id).Select(it => it.material_id).ToListAsync();
|
||||
var ids = outMaterials.Select(x => x.material_id).Except(mids).ToList();
|
||||
var dicOutMaterialNum = outMaterials.ToDictionary(x => x.material_id, x => x.num.ParseToInt());
|
||||
List<PrdMo> subMoList = new();
|
||||
var outputMaterials = await _db.Queryable<BasMaterial>().Where(it => ids.Contains(it.id)).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.material_id = om.id;
|
||||
subMo.material_code = om.code;
|
||||
subMo.plan_qty = dicOutMaterialNum.ContainsKey(om.id) ? dicOutMaterialNum[om.id] * curMo.plan_qty : 0;
|
||||
subMo.mo_type = curMo.mo_type;
|
||||
subMo.parent_id = curMo.id;
|
||||
subMo.plan_start_date = curMo.plan_start_date;
|
||||
@@ -1113,16 +1173,54 @@ namespace Tnb.ProductionMgr
|
||||
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}";
|
||||
subMoList[i].mo_code = $"{curMo.mo_code}-{num}";
|
||||
}
|
||||
var row = await _db.Insertable(subMoList).ExecuteCommandAsync();
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
private static dynamic DictionaryToObject(IDictionary<String, Object> dictionary)
|
||||
{
|
||||
var expandoObj = new ExpandoObject();
|
||||
var expandoObjCollection = (ICollection<KeyValuePair<String, Object>>)expandoObj;
|
||||
|
||||
foreach (var keyValuePair in dictionary)
|
||||
{
|
||||
expandoObjCollection.Add(keyValuePair);
|
||||
}
|
||||
dynamic eoDynamic = expandoObj;
|
||||
return eoDynamic;
|
||||
}
|
||||
|
||||
private static Dictionary<string, string[]> dicProperties = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase);
|
||||
private static T DictionaryToObject<T>(IDictionary<String, Object> dictionary) where T : class, new()
|
||||
{
|
||||
var name = typeof(T).Name;
|
||||
T instance = new();
|
||||
if (!dicProperties.TryGetValue(name, out string[] properies))
|
||||
{
|
||||
properies = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(p => p.Name).ToArray();
|
||||
dicProperties[name] = properies;
|
||||
}
|
||||
//var properies = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(p => p.Name).ToArray();
|
||||
foreach (var pn in properies)
|
||||
{
|
||||
if (dictionary.ContainsKey(pn))
|
||||
{
|
||||
instance.PropertySetValue(pn, dictionary[pn]);
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using JNPF.DependencyInjection;
|
||||
using System.Reflection;
|
||||
using JNPF.DependencyInjection;
|
||||
|
||||
namespace JNPF.Common.Extension;
|
||||
|
||||
@@ -8,6 +9,7 @@ namespace JNPF.Common.Extension;
|
||||
[SuppressSniffer]
|
||||
public static class DictionaryExtensions
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 从字典中获取值,不存在则返回字典<typeparamref name="TValue"/>类型的默认值.
|
||||
/// </summary>
|
||||
@@ -55,4 +57,31 @@ public static class DictionaryExtensions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<string, string[]> dicProperties = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase);
|
||||
/// <summary>
|
||||
/// 字典转换成指定类型实例
|
||||
/// added by ly on 20230524
|
||||
/// </summary>
|
||||
/// <typeparam name="T">转换的目标类型</typeparam>
|
||||
/// <param name="dictionary">被转换的字典</param>
|
||||
/// <returns>转换后的目标类型对象实例</returns>
|
||||
public static T ToObject<T>(this Dictionary<String, Object> dictionary) where T : class, new()
|
||||
{
|
||||
var name = typeof(T).Name;
|
||||
T instance = new();
|
||||
if (!dicProperties.TryGetValue(name, out string[] properies))
|
||||
{
|
||||
properies = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(p => p.Name).ToArray();
|
||||
dicProperties[name] = properies;
|
||||
}
|
||||
foreach (var pn in properies)
|
||||
{
|
||||
if (dictionary.ContainsKey(pn))
|
||||
{
|
||||
instance.PropertySetValue(pn, dictionary[pn]);
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,22 @@ namespace JNPF.Common.Extension
|
||||
}
|
||||
setAction(instance, value);
|
||||
}
|
||||
|
||||
public static void PropertySetValue<T>(this T instance, string propertyName, object value)
|
||||
{
|
||||
if (!PropertySet<T>.ValueFactories2.TryGetValue(propertyName, out Action<T, object> setAction))
|
||||
{
|
||||
setAction = PropertySet<T>.CreateSetPropertyValueAction2(propertyName);
|
||||
PropertySet<T>.ValueFactories2.Add(propertyName, setAction);
|
||||
}
|
||||
setAction(instance, value);
|
||||
}
|
||||
}
|
||||
|
||||
public class PropertySet<T>
|
||||
{
|
||||
public static Dictionary<string, Action<object, object>> ValueFactories = new Dictionary<string, Action<object, object>>(StringComparer.OrdinalIgnoreCase);
|
||||
public static Dictionary<string, Action<T, object>> ValueFactories2 = new Dictionary<string, Action<T, object>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public static Action<object, object> CreateSetPropertyValueAction(string propertyName)
|
||||
{
|
||||
@@ -35,5 +46,17 @@ namespace JNPF.Common.Extension
|
||||
return Expression.Lambda<Action<object, object>>(setPropertyValue, target, propertyValue).Compile();
|
||||
}
|
||||
|
||||
public static Action<T, object> CreateSetPropertyValueAction2(string propertyName)
|
||||
{
|
||||
var property = typeof(T).GetProperty(propertyName);
|
||||
var target = Expression.Parameter(typeof(T));
|
||||
var propExp = Expression.Property(target, propertyName);
|
||||
var propertyValue = Expression.Parameter(typeof(object));
|
||||
var castPropertyValue = Expression.Convert(propertyValue, property!.PropertyType);
|
||||
var assignExp = Expression.Assign(propExp, castPropertyValue);
|
||||
|
||||
return Expression.Lambda<Action<T, object>>(assignExp, new[] { target,propertyValue }).Compile();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ public static class TreeHelper
|
||||
return resData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region 私有成员
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3023,7 +3023,11 @@ public class RunService : IRunService, ITransient
|
||||
{
|
||||
if (item.Value.IsNullOrEmpty()) continue;
|
||||
var itemValue = item.Value.ToString().Contains("[") ? item.Value.ToJsonString() : item.Value.ToString();
|
||||
|
||||
JArray jarr = null;
|
||||
if (itemValue!.Contains("["))
|
||||
{
|
||||
jarr = JArray.Parse(itemValue);
|
||||
}
|
||||
if (model.searchType == 1)
|
||||
{
|
||||
conModels.Add(new ConditionalCollections()
|
||||
@@ -3040,6 +3044,14 @@ public class RunService : IRunService, ITransient
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (jarr?.Children() != null && jarr?.Children().ToList().Count > 1)
|
||||
{
|
||||
var values = string.Join(",", jarr.ToList().Select(t => t.Value<string>()));
|
||||
conModels.Add(new ConditionalModel { FieldName = item.Key, ConditionalType = ConditionalType.In, FieldValue = values });
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
conModels.Add(new ConditionalCollections()
|
||||
{
|
||||
@@ -3055,6 +3067,7 @@ public class RunService : IRunService, ITransient
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user