This commit is contained in:
FanLian
2023-09-06 09:53:16 +08:00
24 changed files with 540 additions and 23 deletions

View 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);
}
}

View 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;
}
}
}

View File

@@ -9,6 +9,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\EquipMgr\Tnb.EquipMgr.Entities\Tnb.EquipMgr.Entities.csproj" />
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" /> <ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
<ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr.Entities\Tnb.WarehouseMgr.Entities.csproj" /> <ProjectReference Include="..\..\WarehouseMgr\Tnb.WarehouseMgr.Entities\Tnb.WarehouseMgr.Entities.csproj" />
<ProjectReference Include="..\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" /> <ProjectReference Include="..\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" />

View File

@@ -26,6 +26,9 @@ public partial class ToolMoldMaintainPlanRelation : BaseEntity<string>
/// </summary> /// </summary>
public string mold_id { get; set; } = string.Empty; public string mold_id { get; set; } = string.Empty;
public string group_id { get; set; } = string.Empty;
} }

View File

@@ -39,4 +39,6 @@ public partial class ToolMoldMaintainRunRecordD : BaseEntity<string>
/// </summary> /// </summary>
public string? check_item_name { get; set; } public string? check_item_name { get; set; }
public string? mainid { get; set; }
} }

View File

@@ -129,7 +129,7 @@ namespace Tnb.EquipMgr
foreach (var item in input.details) foreach (var item in input.details)
{ {
await db.Updateable<EqpMaintainRecordD>() await db.Updateable<EqpMaintainRecordD>()
.SetColumns(x => x.repeat_descrip == item["repeat_descrip"]) .SetColumnsIF(item.ContainsKey("repeat_descrip"),x => x.repeat_descrip == item["repeat_descrip"])
.SetColumns(x => x.repeat_result == item["repeat_result"]) .SetColumns(x => x.repeat_result == item["repeat_result"])
.Where(x => x.id == item["id"]).ExecuteCommandAsync(); .Where(x => x.id == item["id"]).ExecuteCommandAsync();
} }
@@ -187,5 +187,32 @@ namespace Tnb.EquipMgr
return PageResult<EquipMaintainRecordQueryOutput>.SqlSugarPageResult(result); return PageResult<EquipMaintainRecordQueryOutput>.SqlSugarPageResult(result);
} }
/// <summary>
/// 根据id获取保养相关信息
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> GetEqpMaintainRecordInfoById(Dictionary<string,string> dic)
{
string id = dic.ContainsKey("id") ? dic["id"] : "";
if (string.IsNullOrEmpty(id)) return null;
var db = _repository.AsSugarClient();
return await db.Queryable<EqpMaintainRecordH>()
.LeftJoin<EqpEquipment>((a, b) => a.equip_id==b.id)
.Where((a, b) => a.id == id)
.Select((a, b) => new
{
id = a.id,
equip_id = a.equip_id,
equip_code = b.code,
equip_name = b.name,
create_time = a.create_time==null ? "" : a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
result_remark = a.result_remark,
result = a.result,
status = a.status,
}).FirstAsync();
}
} }
} }

View File

@@ -162,5 +162,32 @@ namespace Tnb.EquipMgr
return PageResult<EquipSpotInsRecordQueryOutput>.SqlSugarPageResult(result); return PageResult<EquipSpotInsRecordQueryOutput>.SqlSugarPageResult(result);
} }
/// <summary>
/// 根据id获取点巡检相关信息
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<dynamic> GetEqpSpotInsRecordInfoById(Dictionary<string,string> dic)
{
string id = dic.ContainsKey("id") ? dic["id"] : "";
if (string.IsNullOrEmpty(id)) return null;
var db = _repository.AsSugarClient();
return await db.Queryable<EqpSpotInsRecordH>()
.LeftJoin<EqpEquipment>((a, b) => a.equip_id==b.id)
.Where((a, b) => a.id == id)
.Select((a, b) => new
{
id = a.id,
equip_id = a.equip_id,
equip_code = b.code,
equip_name = b.name,
create_time = a.create_time==null ? "" : a.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
result_remark = a.result_remark,
result = a.result,
status = a.status,
}).FirstAsync();
}
} }
} }

View File

@@ -11,6 +11,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\BasicData\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" /> <ProjectReference Include="..\..\BasicData\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" />
<ProjectReference Include="..\..\system\Tnb.Systems\Tnb.Systems.csproj" /> <ProjectReference Include="..\..\system\Tnb.Systems\Tnb.Systems.csproj" />
<ProjectReference Include="..\..\taskschedule\Tnb.TaskScheduler\Tnb.TaskScheduler.csproj" />
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" /> <ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
<ProjectReference Include="..\..\workflow\Tnb.WorkFlow\Tnb.WorkFlow.csproj" /> <ProjectReference Include="..\..\workflow\Tnb.WorkFlow\Tnb.WorkFlow.csproj" />
<ProjectReference Include="..\Tnb.EquipMgr.Interfaces\Tnb.EquipMgr.Interfaces.csproj" /> <ProjectReference Include="..\Tnb.EquipMgr.Interfaces\Tnb.EquipMgr.Interfaces.csproj" />

View File

@@ -2,11 +2,14 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Dynamic; using System.Dynamic;
using System.Linq; using System.Linq;
using System.Reactive;
using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Aop.Api.Domain; using Aop.Api.Domain;
using Aspose.Cells.Drawing; using Aspose.Cells.Drawing;
using JNPF.Common.Core.Manager; using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Enums; using JNPF.Common.Enums;
using JNPF.Common.Security; using JNPF.Common.Security;
using JNPF.DependencyInjection; using JNPF.DependencyInjection;
@@ -14,11 +17,18 @@ using JNPF.DynamicApiController;
using JNPF.FriendlyException; using JNPF.FriendlyException;
using JNPF.Logging; using JNPF.Logging;
using JNPF.Systems.Interfaces.System; using JNPF.Systems.Interfaces.System;
using JNPF.TaskScheduler;
using JNPF.TaskScheduler.Entitys.Dto.TaskScheduler;
using JNPF.TaskScheduler.Entitys.Model;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
using Mapster; using Mapster;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
using SqlSugar; using SqlSugar;
using Tnb.BasicData; using Tnb.BasicData;
using Tnb.BasicData.Entities;
using Tnb.EquipMgr.Entities; using Tnb.EquipMgr.Entities;
using Tnb.EquipMgr.Entities.Dto; using Tnb.EquipMgr.Entities.Dto;
using Tnb.EquipMgr.Interfaces; using Tnb.EquipMgr.Interfaces;
@@ -30,17 +40,78 @@ namespace Tnb.EquipMgr
/// </summary> /// </summary>
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")] [Route("api/[area]/[controller]/[action]")]
public class ToolMoldMaintainRuleService : IToolMoldMaintainRuleService, IDynamicApiController, ITransient [OverideVisualDev(ModuleId)]
public class ToolMoldMaintainRuleService : IOverideVisualDevService, IToolMoldMaintainRuleService, IDynamicApiController, ITransient
{ {
private const string ModuleId = "26164864904981";
private readonly ISqlSugarClient _db; private readonly ISqlSugarClient _db;
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IDictionaryDataService _dictionaryDataService; private readonly IDictionaryDataService _dictionaryDataService;
private readonly TimeTaskService _timeTaskService;
public ToolMoldMaintainRuleService(ISqlSugarRepository<ToolMoldMaintainRule> repository, IUserManager userManager, IDictionaryDataService dictionaryDataService) private readonly IVisualDevService _visualDevService;
private readonly IRunService _runService;
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
public ToolMoldMaintainRuleService(ISqlSugarRepository<ToolMoldMaintainRule> repository, IUserManager userManager, IDictionaryDataService dictionaryDataService, TimeTaskService timeTaskService, IVisualDevService visualDevService, IRunService runService)
{ {
_db = repository.AsSugarClient(); _db = repository.AsSugarClient();
_userManager = userManager; _userManager = userManager;
_dictionaryDataService = dictionaryDataService; _dictionaryDataService = dictionaryDataService;
_timeTaskService = timeTaskService;
_visualDevService = visualDevService;
_runService = runService;
OverideFuncs.DeleteAsync = Delete;
OverideFuncs.CreateAsync = Create;
}
private async Task<dynamic> Create(VisualDevModelDataCrInput input)
{
int cycle = int.Parse(input.data["cycle"].ToString()!);
var startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddMilliseconds(long.Parse(input.data["startandend_date"].ToString()!));
ToolMoldMaintainRule toolMoldMaintainRule = new ToolMoldMaintainRule();
toolMoldMaintainRule.id = SnowflakeIdHelper.NextId();
toolMoldMaintainRule.mode = input.data["mode"].ToString();
toolMoldMaintainRule.cycle = cycle;
toolMoldMaintainRule.startandend_date = startTime.ToString("yyyy-MM-dd HH:mm:ss");
await _db.Insertable(toolMoldMaintainRule).ExecuteCommandAsync();
if (toolMoldMaintainRule.mode == "27118635748885")
{
string id = toolMoldMaintainRule.id;
var comtentModel = new ContentModel();
comtentModel.cron = "0 0 9 "+ startTime.Day + "/"+ toolMoldMaintainRule.cycle + " * ?";
comtentModel.interfaceId = "";
comtentModel.interfaceName = "";
comtentModel.parameter = new List<InterfaceParameter>();
comtentModel.parameter!.Add(new InterfaceParameter() { field = "id", value = id, defaultValue = "" });
comtentModel.localHostTaskId = "MoldMaintainTask/CreateTask";
comtentModel.startTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
comtentModel.TenantId = _userManager?.TenantId!;
comtentModel.TenantDbName = _userManager?.TenantDbName!;
comtentModel.ConnectionConfig = _userManager?.ConnectionConfig!;
comtentModel.Token = _userManager?.ToKen!;
TimeTaskCrInput timeTaskCrInput = new TimeTaskCrInput()
{
enCode = DateTime.Now.ToString("yyyyMMddHHmmss"),
fullName = "生成模具保养任务" + id,
executeType = "3",
executeContent = comtentModel.ToJsonString(),
description = "",
sortCode = 99,
enabledMark = 1,
};
await _timeTaskService.DeleteByName(timeTaskCrInput.fullName);
await _timeTaskService.Create(timeTaskCrInput, false);
}
return await Task.FromResult(true);
}
private async Task Delete(string id)
{
var ToolMoldMaintainRule = await _db.Queryable<ToolMoldMaintainRule>().Where(p => p.id == id).FirstAsync();
var ToolMoldMaintainRuleRelations = await _db.Queryable<ToolMoldMaintainRuleRelation>().Where(p => p.rule_id == id).ToListAsync();
await _timeTaskService.DeleteByName("生成模具保养任务" + id);
await _db.Ado.BeginTranAsync();
await _db.Deleteable(ToolMoldMaintainRule).ExecuteCommandAsync();
await _db.Deleteable(ToolMoldMaintainRuleRelations).ExecuteCommandAsync();
await _db.Ado.CommitTranAsync();
} }
/// <summary> /// <summary>
/// 根据规则Id获取匹配的模具列表 /// 根据规则Id获取匹配的模具列表

View File

@@ -135,6 +135,10 @@ namespace Tnb.EquipMgr
item_name = e.name, item_name = e.name,
}) })
.ToListAsync(); .ToListAsync();
//新增功能
var ToolMoldMaintainPlanRelation= _db.Queryable<ToolMoldMaintainPlanRelation>().Where((a) => a.maintain_plan_id == input.plan_id && a.mold_id == input.mold_id&& !string.IsNullOrEmpty(a.group_id)).First();
if (ToolMoldMaintainPlanRelation != null)
items = items.Where(a => a.item_group_id == ToolMoldMaintainPlanRelation.group_id).ToList();
var checkItems = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(it => it.plan_id == input.plan_id && it.mold_id == input.mold_id).Select(it => new var checkItems = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(it => it.plan_id == input.plan_id && it.mold_id == input.mold_id).Select(it => new
{ {
plan_id = it.plan_id, plan_id = it.plan_id,
@@ -183,7 +187,7 @@ namespace Tnb.EquipMgr
var isOk = await _db.Updateable<ToolMolds>(mold).Where(it => it.id == input.mold_id).ExecuteCommandHasChangeAsync(); var isOk = await _db.Updateable<ToolMolds>(mold).Where(it => it.id == input.mold_id).ExecuteCommandHasChangeAsync();
if (!isOk) throw Oops.Oh(ErrorCode.COM1001); if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
var plan = await _db.Queryable<ToolMoldMaintainPlanRelation>().LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id) var plan = await _db.Queryable<ToolMoldMaintainPlanRelation>().LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)
.Where(a => a.mold_id == input.mold_id).Select((a, b) => b).FirstAsync(); .Where(a => a.mold_id == input.mold_id && a.maintain_plan_id == input.plan_id).Select((a, b) => b).FirstAsync();
if (plan is not null) if (plan is not null)
{ {
@@ -200,6 +204,10 @@ namespace Tnb.EquipMgr
var row = await _db.Insertable(record).ExecuteCommandAsync(); var row = await _db.Insertable(record).ExecuteCommandAsync();
if (row < 1) throw Oops.Oh(ErrorCode.COM1001); if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
var groupids = _db.Queryable<ToolMoldMaintainPlanRelation>().Where(a => !string.IsNullOrEmpty(a.group_id) && a.mold_id == input.mold_id && a.maintain_plan_id == input.plan_id).ToList().Select(p => p.group_id);
/*
var maintainInfos = await _db.Queryable<ToolMoldMaintainGroupRelation>() var maintainInfos = await _db.Queryable<ToolMoldMaintainGroupRelation>()
.LeftJoin<ToolMoldMaintainGroup>((a, b) => a.item_group_id == b.id) .LeftJoin<ToolMoldMaintainGroup>((a, b) => a.item_group_id == b.id)
.LeftJoin<ToolMoldMaintainGroupItem>((a, b, c) => b.id == c.item_group_id) .LeftJoin<ToolMoldMaintainGroupItem>((a, b, c) => b.id == c.item_group_id)
@@ -213,12 +221,27 @@ namespace Tnb.EquipMgr
check_item_name = d.name check_item_name = d.name
}) })
.ToListAsync(); .ToListAsync();
*/
var maintainInfos = await _db.Queryable<ToolMoldMaintainGroupRelation>()
.LeftJoin<ToolMoldMaintainGroup>((a, b) => a.item_group_id == b.id)
.LeftJoin<ToolMoldMaintainGroupItem>((a, b, c) => b.id == c.item_group_id)
.LeftJoin<ToolMoldMaintainItem>((a, b, c, d) => c.item_id == d.id)
.WhereIF(groupids.Count() > 0, (a) => groupids.Contains(a.item_group_id))
.Where(a => a.mold_id == input.mold_id)
.Select((a, b, c, d) => new
{
group_id = b.id,
group_name = b.name,
check_item_id = d.id,
check_item_name = d.name
}).ToListAsync();
if (maintainInfos?.Count > 0) if (maintainInfos?.Count > 0)
{ {
List<ToolMoldMaintainRunRecordD> recordDs = new(); List<ToolMoldMaintainRunRecordD> recordDs = new();
foreach (var info in maintainInfos) foreach (var info in maintainInfos)
{ {
ToolMoldMaintainRunRecordD record_d = new(); ToolMoldMaintainRunRecordD record_d = new();
record_d.mainid = record.id;
record_d.group_id = info.group_id; record_d.group_id = info.group_id;
record_d.group_name = info.group_name; record_d.group_name = info.group_name;
record_d.check_item_id = info.check_item_id; record_d.check_item_id = info.check_item_id;
@@ -253,6 +276,7 @@ namespace Tnb.EquipMgr
record.mold_id = input.mold_id; record.mold_id = input.mold_id;
record.item_group_id = item.item_group_id; record.item_group_id = item.item_group_id;
record.item_id = item.item_id; record.item_id = item.item_id;
record.status = 1;
records.Add(record); records.Add(record);
} }
var row = await _db.Insertable(records).ExecuteCommandAsync(); var row = await _db.Insertable(records).ExecuteCommandAsync();
@@ -283,6 +307,11 @@ namespace Tnb.EquipMgr
item_name = e.name, item_name = e.name,
}) })
.ToListAsync(); .ToListAsync();
//新增功能
var ToolMoldMaintainPlanRelation = _db.Queryable<ToolMoldMaintainPlanRelation>().Where((a) => a.maintain_plan_id == input.plan_id && a.mold_id == input.mold_id && !string.IsNullOrEmpty(a.group_id)).First();
if (ToolMoldMaintainPlanRelation != null)
items = items.Where(a => a.item_group_id == ToolMoldMaintainPlanRelation.group_id).ToList();
var checkItems = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(it => it.plan_id == input.plan_id && it.mold_id == input.mold_id).Select(it => new var checkItems = await _db.Queryable<ToolMoldMaintainItemRecord>().Where(it => it.plan_id == input.plan_id && it.mold_id == input.mold_id).Select(it => new
{ {
plan_id = it.plan_id, plan_id = it.plan_id,

View File

@@ -31,5 +31,9 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
/// 工序 /// 工序
/// </summary> /// </summary>
public string process { get; set; } public string process { get; set; }
/// <summary>
/// 工位id
/// </summary>
public string stationId { get; set; }
} }
} }

View File

@@ -678,6 +678,13 @@ namespace Tnb.ProductionMgr
moTask.scheduled_qty = input.scheduled_qty; moTask.scheduled_qty = input.scheduled_qty;
moTask.unit_id = mo.unit_id; 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 moCode = mo?.mo_code;
var taskCode = await _billRuleService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.PRDMOTASK_CODE); var taskCode = await _billRuleService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.PRDMOTASK_CODE);
moTask.mo_task_code = taskCode; moTask.mo_task_code = taskCode;
@@ -944,10 +951,19 @@ namespace Tnb.ProductionMgr
.ToListAsync(); .ToListAsync();
if (subTaskList?.Count > 0) 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<PrdMoTask> subMoTasks = new();
List<PrdTaskLog> subMoTaskLogs = new(); List<PrdTaskLog> subMoTaskLogs = new();
foreach (var item in subTaskList) 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(); PrdMoTask subMoTask = new();
subMoTask.mo_id = input.mo_id; subMoTask.mo_id = input.mo_id;
subMoTask.material_id = item.material_id; subMoTask.material_id = item.material_id;
@@ -956,6 +972,7 @@ namespace Tnb.ProductionMgr
subMoTask.bom_id = input.bom_id; subMoTask.bom_id = input.bom_id;
subMoTask.process_id = item.process_id; subMoTask.process_id = item.process_id;
subMoTask.mbom_process_id = item.mbom_process_id; subMoTask.mbom_process_id = item.mbom_process_id;
subMoTask.workstation_id = resultList?.FirstOrDefault() ?? "";
subMoTask.mo_task_status = DictConst.ToBeScheduledEncode; subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
subMoTask.workroute_id = item.route_id; subMoTask.workroute_id = item.route_id;
subMoTask.workline_id = input.workline_id; subMoTask.workline_id = input.workline_id;

View File

@@ -49,6 +49,15 @@ namespace Tnb.ProductionMgr
public async Task<dynamic> GetList(PrdPackReportQueryInput input) public async Task<dynamic> GetList(PrdPackReportQueryInput input)
{ {
if (input == null) throw new ArgumentNullException("input"); if (input == null) throw new ArgumentNullException("input");
if (string.IsNullOrEmpty(input.stationId))
{
return new
{
pagination = new PageResult(),
list = Array.Empty<string>()
};
}
List<PackReportTreeOutput> trees = new(); List<PackReportTreeOutput> trees = new();
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
var list = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workline").ToListAsync(); var list = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workline").ToListAsync();
@@ -75,13 +84,17 @@ namespace Tnb.ProductionMgr
endTimes[1] = GetDateTimeMilliseconds(input.estimated_end_date![1]); 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(!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(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(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!)) .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 => string.IsNullOrEmpty(a.parent_id) && a.schedule_type == 2 && a.mo_task_status != "ToBeScheduled")
.OrderByDescending(a=>a.create_time) .Where((a,b,c,d)=>d.workstation_id==input.stationId)
.OrderByDescending(a=>a.create_time)
.Select((a, b, c) => new PrdMoTask .Select((a, b, c) => new PrdMoTask
{ {
id = a.id, id = a.id,
@@ -122,7 +135,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_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") : ""; 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); trees.Add(node);
} }
} }
@@ -170,13 +183,13 @@ namespace Tnb.ProductionMgr
return dt; 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>() var items = await _db.Queryable<PrdMoTask>()
.LeftJoin<BasProcess>((a, b) => a.process_id == b.id) .LeftJoin<BasProcess>((a, b) => a.process_id == b.id)
.LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id) .LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id)
.LeftJoin<BasMbomProcess>((a, b, c, d) => a.mbom_process_id == d.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) .OrderBy((a, b, c, d) => d.ordinal)
.Select((a, b, c) => new PrdMoTask .Select((a, b, c) => new PrdMoTask
{ {
@@ -222,7 +235,7 @@ namespace Tnb.ProductionMgr
nodes.AddRange(nsChild); nodes.AddRange(nsChild);
foreach (var item in items) foreach (var item in items)
{ {
await GetChild(item.id, nodes, dic); await GetChild(item.id, nodes, dic,stationId);
} }
} }
} }

View File

@@ -119,6 +119,17 @@ namespace Tnb.ProductionMgr
var db = _repository.AsSugarClient(); var db = _repository.AsSugarClient();
Dictionary<string, object> queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject<Dictionary<string, object>>(input.queryJson) : new Dictionary<string, object>(); 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 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 new
{
pagination = new PageResult(),
list = Array.Empty<string>()
};
}
Dictionary<string, object> dic = await _dictionaryDataService.GetDicByKey(DictConst.TaskStatus); Dictionary<string, object> dic = await _dictionaryDataService.GetDicByKey(DictConst.TaskStatus);
DateTime[] planStartDateArr = null; DateTime[] planStartDateArr = null;
@@ -142,6 +153,7 @@ namespace Tnb.ProductionMgr
.WhereIF(!string.IsNullOrEmpty(moTaskCode),(a,b,c,d)=>a.mo_task_code.Contains(moTaskCode)) .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(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]) .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) .OrderByDescending((a, b, c, d) => a.create_time)
.Select((a, b, c, d) => new PrdTaskManageListOutput() .Select((a, b, c, d) => new PrdTaskManageListOutput()
{ {

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using JNPF.Common.Extension;
using Spire.Pdf.Widget;
using Tnb.WarehouseMgr.Entities.Enums;
namespace Tnb.WarehouseMgr.Entities.Consts
{
public class GenericEnumDicionary<T> where T : Enum
{
private static string tn = typeof(T).Name;
private static ConcurrentDictionary<string, Dictionary<int, string>> enumDescMap = new();
private static ConcurrentDictionary<string, FieldInfo[]?> enumMemberMap = new();
static GenericEnumDicionary()
{
enumMemberMap.GetOrAdd(tn, f => typeof(T).GetFields(BindingFlags.Public | BindingFlags.Static));
if (enumMemberMap[tn]?.All(f => f.GetCustomAttribute<DescriptionAttribute>() != null) ?? false)
{
enumDescMap.GetOrAdd(tn, dic => typeof(T).GetEnumDescDictionary());
}
}
public static string GetEnumDesc(int enumVal)
{
return enumDescMap.ContainsKey(tn) ? enumDescMap[tn]?[enumVal] ?? string.Empty : string.Empty;
}
}
}

View File

@@ -158,5 +158,16 @@ public partial class WmsOutstockH : BaseEntity<string>
/// 修改时间 /// 修改时间
/// </summary> /// </summary>
public DateTime modify_time { get; set; } = DateTime.Now; public DateTime modify_time { get; set; } = DateTime.Now;
/// <summary>
/// 工位Id
/// </summary>
public string station_id { get; set; }
/// <summary>
/// 工位编码
/// </summary>
public string station_code { get; set; }
/// <summary>
/// 载具Id
/// </summary>
public string carry_id { get; set; }
} }

View File

@@ -6,6 +6,7 @@ using Tnb.WarehouseMgr.Entities.Dto.Outputs;
using Tnb.Common; using Tnb.Common;
using JNPF.Common.Extension; using JNPF.Common.Extension;
using Tnb.WarehouseMgr.Entities.Enums; using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Entities.Consts;
namespace Tnb.WarehouseMgr.Entities.Mapper namespace Tnb.WarehouseMgr.Entities.Mapper
{ {
@@ -23,7 +24,7 @@ namespace Tnb.WarehouseMgr.Entities.Mapper
config.ForType<WmsCarryH, CarryQueryOutput>() config.ForType<WmsCarryH, CarryQueryOutput>()
.Map(dest => dest.qc_status, src => src.is_check == 0 ? "不合格" : "合格"); .Map(dest => dest.qc_status, src => src.is_check == 0 ? "不合格" : "合格");
config.ForType<WmsCarryCode, CarryCodeQueryOutput>() config.ForType<WmsCarryCode, CarryCodeQueryOutput>()
.Map(dest => dest.check_conclusion, src => src.check_conclusion.ToEnum<EnumCheckConclusion>().GetDescription()); .Map(dest => dest.check_conclusion, src => GenericEnumDicionary<EnumCheckConclusion>.GetEnumDesc(src.check_conclusion));
} }
} }
} }

View File

@@ -3,11 +3,18 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using JNPF;
using JNPF.Common.Core.Manager; using JNPF.Common.Core.Manager;
using JNPF.Common.Enums; using JNPF.Common.Enums;
using JNPF.Common.Extension; using JNPF.Common.Extension;
using JNPF.Common.Manager;
using JNPF.Common.Net;
using JNPF.Common.Security;
using JNPF.EventBus;
using JNPF.EventHandler;
using JNPF.FriendlyException; using JNPF.FriendlyException;
using JNPF.Logging; using JNPF.Logging;
using JNPF.Systems.Entitys.System;
using JNPF.Systems.Interfaces.System; using JNPF.Systems.Interfaces.System;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -33,12 +40,22 @@ namespace Tnb.WarehouseMgr
{ {
private readonly ISqlSugarClient _db; private readonly ISqlSugarClient _db;
private readonly IWareHouseService _wareHouseService; private readonly IWareHouseService _wareHouseService;
private readonly ICacheManager _cacheManager;
private readonly IEventPublisher _eventPublisher;
private readonly IUserManager _userManager;
public DeviceProviderService(ISqlSugarRepository<WmsInstockH> repository, IWareHouseService wareHouseService)
public DeviceProviderService(ISqlSugarRepository<WmsInstockH> repository, IWareHouseService wareHouseService,
ICacheManager cacheManager,
IEventPublisher eventPublisher,
IUserManager userManger
)
{ {
_db = repository.AsSugarClient(); _db = repository.AsSugarClient();
_wareHouseService = wareHouseService; _wareHouseService = wareHouseService;
_cacheManager = cacheManager;
_eventPublisher = eventPublisher;
_userManager = userManger;
} }
/// <summary> /// <summary>
@@ -101,7 +118,7 @@ namespace Tnb.WarehouseMgr
/// 任务链状态上报 /// 任务链状态上报
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost, NonUnify,AllowAnonymous] [HttpPost, NonUnify, AllowAnonymous]
public async Task<Result> TaskChainCallBack(TaskChainCallBackInput input) public async Task<Result> TaskChainCallBack(TaskChainCallBackInput input)
{ {
try try
@@ -110,8 +127,9 @@ namespace Tnb.WarehouseMgr
switch (input.status) switch (input.status)
{ {
case "CREATED": break; case "CREATED": break;
case "ALLOCATED":break; case "ALLOCATED": break;
case "PROCESSING": case "PROCESSING":
//if (await _cacheManager.GetAsync($"{input.taskChainCode}") == "任务链状态上报,上报状态PROCESSING") break;
if (input.taskChainCode.Trim().IsNullOrEmpty()) break; if (input.taskChainCode.Trim().IsNullOrEmpty()) break;
var disTasks = await _db.Queryable<WmsDistaskH>().Where(it => it.bill_code.Contains(input.taskChainCode)).ToListAsync(); var disTasks = await _db.Queryable<WmsDistaskH>().Where(it => it.bill_code.Contains(input.taskChainCode)).ToListAsync();
var eps = await _db.Queryable<EqpEquipment>().Where(it => it.code.Contains(input.deviceID)).ToListAsync(); var eps = await _db.Queryable<EqpEquipment>().Where(it => it.code.Contains(input.deviceID)).ToListAsync();
@@ -127,6 +145,24 @@ namespace Tnb.WarehouseMgr
case "FINISHED": break; case "FINISHED": break;
default: break; default: break;
} }
//写入redis
//await _cacheManager.SetAsync($"{input.taskChainCode}", $"任务链状态上报,上报状态{input.status}");
var opts = App.GetOptions<ConnectionConfigOptions>();
UserAgent userAgent = new(App.HttpContext);
//写系统日志
await _eventPublisher.PublishAsync(new LogEventSource("Log:CreateOpLog", opts, new SysLogEntity
{
Id = SnowflakeIdHelper.NextId(),
Category = 4,
UserId = _userManager.UserId,
UserName = _userManager.User.RealName,
IPAddress = NetHelper.Ip,
RequestURL = App.HttpContext.Request.Path,
RequestMethod = App.HttpContext.Request.Method,
Json = $"任务链状态上报,任务链编号:{input.taskChainCode},上报状态:{input.status},设备编号:{input.deviceID}",
PlatForm = string.Format("{0}-{1}", userAgent.OS.ToString(), userAgent.RawValue),
CreatorTime = DateTime.Now
}));
} }
catch (Exception) catch (Exception)
{ {

View File

@@ -360,7 +360,7 @@ namespace Tnb.WarehouseMgr
{ {
dynamic reqBody = new ExpandoObject(); dynamic reqBody = new ExpandoObject();
reqBody.taskChainCode = k; reqBody.taskChainCode = k;
reqBody.type = (int)EnumTaskChainType.KIVA; reqBody.type = (int)EnumTaskChainType.AGV;
reqBody.sequential = false; reqBody.sequential = false;
reqBody.taskChainPriority = 0; reqBody.taskChainPriority = 0;
reqBody.taskList = v; reqBody.taskList = v;

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Aop.Api.Domain; using Aop.Api.Domain;
@@ -10,12 +11,14 @@ using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Extension; using JNPF.Common.Extension;
using JNPF.Common.Security; using JNPF.Common.Security;
using JNPF.FriendlyException; using JNPF.FriendlyException;
using JNPF.Systems.Entitys.Permission;
using JNPF.Systems.Interfaces.System; using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev; using JNPF.VisualDev;
using JNPF.VisualDev.Entitys; using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces; using JNPF.VisualDev.Interfaces;
using Mapster; using Mapster;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using SqlSugar; using SqlSugar;
using SqlSugar.DbConvert; using SqlSugar.DbConvert;
using Tnb.BasicData.Entities; using Tnb.BasicData.Entities;
@@ -101,10 +104,15 @@ namespace Tnb.WarehouseMgr
code_batch = os.code_batch, code_batch = os.code_batch,
}; };
var outStkCarrys = await _wareHouseService.OutStockStrategy(OutStockStrategyInput); var outStkCarrys = await _wareHouseService.OutStockStrategy(OutStockStrategyInput);
var carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id) Expression<Func<WmsCarryH, WmsCarryCode, bool>> whereExp = input.data.ContainsKey(nameof(WmsOutstockH.carry_id))
.Where((a, b) => outStkCarrys.Select(x => x.id).Contains(b.carry_id)) ? (a, b) => a.id == input.data[nameof(WmsOutstockH.carry_id)].ToString()
.Select<WmsCarryCode>() : (a, b) => outStkCarrys.Select(x => x.id).Contains(b.carry_id);
.ToListAsync();
List<WmsCarryCode>? carryCodesPart = await _db.Queryable<WmsCarryH>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.carry_id).InnerJoin<BasLocation>((a, b, c) => a.location_id == c.id)
.Where(whereExp)
.Select<WmsCarryCode>()
.ToListAsync();
if (carryCodesPart?.Count > 0) if (carryCodesPart?.Count > 0)
{ {
var codeQty = carryCodesPart.Sum(x => x.codeqty); var codeQty = carryCodesPart.Sum(x => x.codeqty);
@@ -199,6 +207,37 @@ namespace Tnb.WarehouseMgr
{ {
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString()); ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString());
} }
else if (input.data.ContainsKey(nameof(WmsOutstockH.station_id)))
{
//多个投料库位
/*
* 潍柴
* 1、那个库位状态是空的出那个
* 1.1、没有空位直接抛异常
*
* 天益
* 2、不管库位是否为空 获取到所有库位 A B
* 2.1 根据这些库位去查任务执行 目的库位是这些库位的未完成任务数。 A 10 B 9
* 2.2 哪个最少给哪个
*/
var org = await _db.Queryable<OrganizeEntity>().FirstAsync(it => it.Id == input.data[nameof(WmsOutstockH.station_id)].ToString());
if (!org?.FeedingLocationId.IsNullOrWhiteSpace() ?? false)
{
var fLocIds = JArray.Parse(org.FeedingLocationId).Values<string>();
var minTaskNumLoc = await _db.Queryable<WmsPretaskH>().Where(it => it.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && fLocIds.Contains(it.endlocation_id))
.GroupBy(it => it.endlocation_id)
.Select(it => new
{
it.endlocation_id,
count = SqlFunc.AggregateCount(it.endlocation_id)
})
.MergeTable()
.OrderBy(it => it.count)
.FirstAsync();
ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == minTaskNumLoc.endlocation_id);
}
}
if (sPoint != null && ePoint != null) if (sPoint != null && ePoint != null)
{ {
var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id);

View File

@@ -83,6 +83,7 @@ namespace Tnb.WarehouseMgr
if (input.data.ContainsKey("tablefield115")) if (input.data.ContainsKey("tablefield115"))
{ {
jArr = JArray.Parse(input.data["tablefield115"].ToString()!); jArr = JArray.Parse(input.data["tablefield115"].ToString()!);
} }
//入库取终点 //出库起点 //入库取终点 //出库起点
var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 }; var inStockStrategyInput = new InStockStrategyQuery { warehouse_id = input.data[nameof(InStockStrategyQuery.warehouse_id)].ToString()!, Size = 1 };

View File

@@ -10,7 +10,7 @@ namespace JNPF.Systems.Entitys.Permission;
/// 日 期2017.09.20. /// 日 期2017.09.20.
/// </summary> /// </summary>
[SugarTable("BASE_ORGANIZE")] [SugarTable("BASE_ORGANIZE")]
public class OrganizeEntity : CLDEntityBase public partial class OrganizeEntity : CLDEntityBase
{ {
/// <summary> /// <summary>
/// 机构上级. /// 机构上级.

View File

@@ -0,0 +1,14 @@
using JNPF.Common.Contracts;
using SqlSugar;
namespace JNPF.Systems.Entitys.Permission;
public partial class OrganizeEntity
{
/// <summary>
///
/// </summary>
[SugarColumn(ColumnName = "F_FEEDING_LOCATIONID")]
public string FeedingLocationId { get; set; }
}

View File

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JNPF;
using JNPF.Common.Security;
using JNPF.Systems.Entitys.System;
using JNPF.TaskScheduler;
using JNPF.TaskScheduler.Entitys.Model;
using SqlSugar;
using Tnb.EquipMgr.Entities;
using Tnb.ProductionMgr.Entities;
using Tnb.QcMgr.Entities;
using Tnb.QcMgr.Entities.Entity;
namespace Tnb.TaskScheduler.Listener
{
internal class MoldMaintainTask : ISpareTimeWorker
{
private ISqlSugarRepository<ToolMoldMaintainRule> repository => App.GetService<ISqlSugarRepository<ToolMoldMaintainRule>>();
[SpareTime("0 0 0 * * ?", "生成模具保养任务", ExecuteType = SpareTimeExecuteTypes.Serial, StartNow = false)]
public async void CreateTask(SpareTimer timer, long count)
{
try
{
var timeTaskEntity = await repository.AsSugarClient().Queryable<TimeTaskEntity>().Where(p => p.Id == timer.WorkerName && p.EnabledMark == 1).FirstAsync();
if (timeTaskEntity == null)
return;
ContentModel? comtentModel = timeTaskEntity.ExecuteContent.ToObject<ContentModel>();
var ToolMoldMaintainRule = await repository.AsSugarClient().Queryable<ToolMoldMaintainRule>().Where(p => p.id == comtentModel.parameter.Where(p => p.field == "id").First().value).FirstAsync();
if (ToolMoldMaintainRule == null)
return;
var ToolMoldMaintainRuleRelations= await repository.AsSugarClient().Queryable<ToolMoldMaintainRuleRelation>().Where(p => p.rule_id == ToolMoldMaintainRule.id).ToListAsync();
if (ToolMoldMaintainRuleRelations.Count() > 0)
{
var now = DateTime.Now;
Random rNum = new Random();
ToolMoldMaintainPlan toolMoldMaintainPlan=new ToolMoldMaintainPlan();
toolMoldMaintainPlan.id = SnowflakeIdHelper.NextId();
toolMoldMaintainPlan.plan_code = "JHDM" + now.ToString("yyyyMMdd") + rNum.Next(1000, 9999).ToString();
toolMoldMaintainPlan.mode = ToolMoldMaintainRule.mode;
toolMoldMaintainPlan.status = "UnMaintain";
toolMoldMaintainPlan.plan_start_date = now;
toolMoldMaintainPlan.plan_end_date = now.AddDays((double)ToolMoldMaintainRule.cycle!);
List<ToolMoldMaintainPlanRelation> toolMoldMaintainPlanRelations = new List<ToolMoldMaintainPlanRelation>();
foreach (var ToolMoldMaintainRuleRelation in ToolMoldMaintainRuleRelations)
{
ToolMoldMaintainPlanRelation toolMoldMaintainPlanRelation = new ToolMoldMaintainPlanRelation();
toolMoldMaintainPlanRelation.id= SnowflakeIdHelper.NextId();
toolMoldMaintainPlanRelation.maintain_plan_id = toolMoldMaintainPlan.id;
toolMoldMaintainPlanRelation.mold_id = ToolMoldMaintainRuleRelation.mold_id;
toolMoldMaintainPlanRelation.group_id = ToolMoldMaintainRuleRelation.item_group_id;
toolMoldMaintainPlanRelations.Add(toolMoldMaintainPlanRelation);
}
await repository.AsSugarClient().Insertable(toolMoldMaintainPlanRelations).ExecuteCommandAsync();
await repository.AsSugarClient().Insertable(toolMoldMaintainPlan).ExecuteCommandAsync();
}
}
catch (Exception)
{
}
}
}
}