排产至工位 pc端注塑挤出任务管理 组装包装任务管理添加工位过滤
This commit is contained in:
23
BasicData/Tnb.BasicData.Interfaces/IBasQrcodeService.cs
Normal file
23
BasicData/Tnb.BasicData.Interfaces/IBasQrcodeService.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace Tnb.BasicData.Interfaces
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 二维码
|
||||
/// </summary>
|
||||
public interface IBasQrcodeService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据code获取qrcode
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GetQrcodeByCode(Dictionary<string, string> dic);
|
||||
|
||||
/// <summary>
|
||||
/// 根据code获取工位信息
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GetWorkStationByCode(Dictionary<string, string> dic);
|
||||
}
|
||||
}
|
||||
84
BasicData/Tnb.BasicData/BasQrcodeService.cs
Normal file
84
BasicData/Tnb.BasicData/BasQrcodeService.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Entities.Dto;
|
||||
using Tnb.BasicData.Entitys.Dto.BasProcess;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
|
||||
namespace Tnb.BasicData
|
||||
{
|
||||
/// <summary>
|
||||
/// 二维码
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class BasQrcodeService : IBasQrcodeService,IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<BasMaterial> _repository;
|
||||
private readonly DataBaseManager _dbManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
|
||||
public BasQrcodeService(
|
||||
ISqlSugarRepository<BasMaterial> repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_repository = repository;
|
||||
_dbManager = dbManager;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetQrcodeByCode(Dictionary<string, string> dic)
|
||||
{
|
||||
string code = dic.ContainsKey("code") ? dic["code"] : "";
|
||||
if (string.IsNullOrEmpty(code)) return null;
|
||||
var result = await _repository.AsSugarClient().Queryable<BasQrcode>()
|
||||
.LeftJoin<OrganizeEntity>((a, b) => a.source_id == b.Id)
|
||||
.LeftJoin<EqpEquipment>((a, b, c) => a.source_id == c.id)
|
||||
.LeftJoin<ToolLocation>((a, b, c, d) => a.source_id == d.id)
|
||||
.Where((a, b, c, d) => a.code == code)
|
||||
.Select((a, b, c, d) => new
|
||||
{
|
||||
id = a.id,
|
||||
source_id = a.source_id,
|
||||
source_name = a.source_name,
|
||||
org_code = b.EnCode,
|
||||
org_name = b.FullName,
|
||||
equip_code = a.code,
|
||||
equip_name = c.name,
|
||||
tool_location_code = d.location_code,
|
||||
}).FirstAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetWorkStationByCode(Dictionary<string, string> dic)
|
||||
{
|
||||
string code = dic.ContainsKey("code") ? dic["code"] : "";
|
||||
if (string.IsNullOrEmpty(code)) return null;
|
||||
var result = await _repository.AsSugarClient().Queryable<BasQrcode>()
|
||||
.LeftJoin<OrganizeEntity>((a, b) => a.source_id == b.Id)
|
||||
.LeftJoin<OrganizeRelationEntity>((a,b,c)=>a.source_id==c.ObjectId && c.ObjectType=="Eqp")
|
||||
.LeftJoin<OrganizeEntity>((a,b,c,d)=>c.OrganizeId==d.Id)
|
||||
.Where((a, b, c) => a.code == code)
|
||||
.Select((a, b, c,d) => new
|
||||
{
|
||||
id = a.id,
|
||||
source_id = a.source_id,
|
||||
source_name = a.source_name,
|
||||
org_id = b.Id,
|
||||
org_code = b.EnCode,
|
||||
org_name = b.FullName,
|
||||
org_id2 = d.Id,
|
||||
org_code2 = d.EnCode,
|
||||
org_name2 = d.FullName,
|
||||
}).FirstAsync();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\EquipMgr\Tnb.EquipMgr.Entities\Tnb.EquipMgr.Entities.csproj" />
|
||||
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
|
||||
<ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr.Entities\Tnb.WarehouseMgr.Entities.csproj" />
|
||||
<ProjectReference Include="..\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" />
|
||||
|
||||
@@ -31,5 +31,9 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// 工序
|
||||
/// </summary>
|
||||
public string process { get; set; }
|
||||
/// <summary>
|
||||
/// 工位id
|
||||
/// </summary>
|
||||
public string stationId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,6 +678,13 @@ namespace Tnb.ProductionMgr
|
||||
moTask.scheduled_qty = input.scheduled_qty;
|
||||
moTask.unit_id = mo.unit_id;
|
||||
|
||||
if (!string.IsNullOrEmpty(input.eqp_id))
|
||||
{
|
||||
OrganizeRelationEntity organizeRelationEntity = await db.Queryable<OrganizeRelationEntity>()
|
||||
.Where(x => x.ObjectId == input.eqp_id && x.ObjectType == "Eqp").FirstAsync();
|
||||
moTask.workstation_id = organizeRelationEntity?.OrganizeId ?? "";
|
||||
}
|
||||
|
||||
var moCode = mo?.mo_code;
|
||||
var taskCode = await _billRuleService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.PRDMOTASK_CODE);
|
||||
moTask.mo_task_code = taskCode;
|
||||
@@ -944,10 +951,19 @@ namespace Tnb.ProductionMgr
|
||||
.ToListAsync();
|
||||
if (subTaskList?.Count > 0)
|
||||
{
|
||||
List<string> workstationIds = await _db.Queryable<OrganizeEntity>().Where(x =>
|
||||
x.Category == DictConst.RegionCategoryStationCode &&
|
||||
x.OrganizeIdTree.Contains(input.workline_id)).Select(x=>x.Id).ToListAsync();
|
||||
|
||||
|
||||
List<PrdMoTask> subMoTasks = new();
|
||||
List<PrdTaskLog> subMoTaskLogs = new();
|
||||
foreach (var item in subTaskList)
|
||||
{
|
||||
BasMbomProcess basMbomProcess = await _db.Queryable<BasMbomProcess>().SingleAsync(x=>x.id==item.mbom_process_id);
|
||||
List<string> mbomProcessStationIds = JsonConvert.DeserializeObject<string[][]>(basMbomProcess.station).Select(x=>x[x.Length-1]).ToList();
|
||||
List<string>? resultList = workstationIds.Intersect(mbomProcessStationIds).ToList();
|
||||
|
||||
PrdMoTask subMoTask = new();
|
||||
subMoTask.mo_id = input.mo_id;
|
||||
subMoTask.material_id = item.material_id;
|
||||
@@ -956,6 +972,7 @@ namespace Tnb.ProductionMgr
|
||||
subMoTask.bom_id = input.bom_id;
|
||||
subMoTask.process_id = item.process_id;
|
||||
subMoTask.mbom_process_id = item.mbom_process_id;
|
||||
subMoTask.workstation_id = resultList?.FirstOrDefault() ?? "";
|
||||
subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
||||
subMoTask.workroute_id = item.route_id;
|
||||
subMoTask.workline_id = input.workline_id;
|
||||
|
||||
@@ -49,6 +49,8 @@ namespace Tnb.ProductionMgr
|
||||
public async Task<dynamic> GetList(PrdPackReportQueryInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
if (string.IsNullOrEmpty(input.stationId)) return Array.Empty<string>();
|
||||
|
||||
List<PackReportTreeOutput> trees = new();
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
var list = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workline").ToListAsync();
|
||||
@@ -75,12 +77,16 @@ namespace Tnb.ProductionMgr
|
||||
endTimes[1] = GetDateTimeMilliseconds(input.estimated_end_date![1]);
|
||||
|
||||
}
|
||||
var items = await _db.Queryable<PrdMoTask>().LeftJoin<BasProcess>((a, b) => a.process_id == b.id).LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id)
|
||||
var items = await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasProcess>((a, b) => a.process_id == b.id)
|
||||
.LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id)
|
||||
.LeftJoin<PrdMoTask>((a,b,c,d)=>a.id==d.parent_id)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.mo_task_code), a => a.mo_task_code == input.mo_task_code.Trim())
|
||||
// .WhereIF(start, a => a.estimated_start_date != null&& startTimes[0] <= a.estimated_start_date && startTimes[1] >= a.estimated_start_date)
|
||||
// .WhereIF(end, a => a.estimated_end_date != null && endTimes[0] <= a.estimated_end_date && endTimes[1] >= a.estimated_end_date)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.workline), a => list.Where(p => p.EnCode.Contains(input.workline) || p.FullName.Contains(input.workline)).Select(p => p.Id).ToList().Contains(a.workline_id!))
|
||||
.Where(a => string.IsNullOrEmpty(a.parent_id) && a.schedule_type == 2 && a.mo_task_status != "ToBeScheduled")
|
||||
.Where((a,b,c,d)=>d.workstation_id==input.stationId)
|
||||
.OrderByDescending(a=>a.create_time)
|
||||
.Select((a, b, c) => new PrdMoTask
|
||||
{
|
||||
@@ -122,7 +128,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
node.plan_start_date = item.plan_start_date.HasValue ? item.plan_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
node.plan_end_date = item.plan_end_date.HasValue ? item.plan_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
await GetChild(item.id, trees, dic);
|
||||
await GetChild(item.id, trees, dic,input.stationId);
|
||||
trees.Add(node);
|
||||
}
|
||||
}
|
||||
@@ -170,13 +176,13 @@ namespace Tnb.ProductionMgr
|
||||
return dt;
|
||||
|
||||
}
|
||||
private async Task GetChild(string parentId, List<PackReportTreeOutput> nodes, Dictionary<string, object> dic)
|
||||
private async Task GetChild(string parentId, List<PackReportTreeOutput> nodes, Dictionary<string, object> dic,string stationId)
|
||||
{
|
||||
var items = await _db.Queryable<PrdMoTask>()
|
||||
.LeftJoin<BasProcess>((a, b) => a.process_id == b.id)
|
||||
.LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id)
|
||||
.LeftJoin<BasMbomProcess>((a, b, c, d) => a.mbom_process_id == d.id)
|
||||
.Where(a => a.parent_id == parentId && a.mo_task_status != "ToBeScheduled")
|
||||
.Where(a => a.parent_id == parentId && a.mo_task_status != "ToBeScheduled" && a.workstation_id==stationId)
|
||||
.OrderBy((a, b, c, d) => d.ordinal)
|
||||
.Select((a, b, c) => new PrdMoTask
|
||||
{
|
||||
@@ -222,7 +228,7 @@ namespace Tnb.ProductionMgr
|
||||
nodes.AddRange(nsChild);
|
||||
foreach (var item in items)
|
||||
{
|
||||
await GetChild(item.id, nodes, dic);
|
||||
await GetChild(item.id, nodes, dic,stationId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,6 +119,13 @@ namespace Tnb.ProductionMgr
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string, object> queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, object>>(input.queryJson) : new Dictionary<string, object>();
|
||||
string moTaskCode = queryJson!=null && queryJson.ContainsKey("mo_task_code") ? queryJson["mo_task_code"].ToString() : "";
|
||||
string stationId = queryJson!=null && queryJson.ContainsKey("stationId") ? queryJson["stationId"].ToString() : "";
|
||||
|
||||
if (string.IsNullOrEmpty(stationId))
|
||||
{
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
|
||||
Dictionary<string, object> dic = await _dictionaryDataService.GetDicByKey(DictConst.TaskStatus);
|
||||
|
||||
DateTime[] planStartDateArr = null;
|
||||
@@ -142,6 +149,7 @@ namespace Tnb.ProductionMgr
|
||||
.WhereIF(!string.IsNullOrEmpty(moTaskCode),(a,b,c,d)=>a.mo_task_code.Contains(moTaskCode))
|
||||
.WhereIF(planStartDateArr!=null, (a, b, c, d) => a.estimated_start_date>=planStartDateArr[0] && a.estimated_start_date<=planStartDateArr[1])
|
||||
.WhereIF(planEndDateArr!=null, (a, b, c, d) => a.estimated_end_date>=planEndDateArr[0] && a.estimated_end_date<=planEndDateArr[1])
|
||||
.Where((a,b,c,d)=>a.workstation_id==stationId)
|
||||
.OrderByDescending((a, b, c, d) => a.create_time)
|
||||
.Select((a, b, c, d) => new PrdTaskManageListOutput()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user