优化调整

This commit is contained in:
2024-05-28 09:29:28 +08:00
parent 6674d10880
commit 7fe6784007
3 changed files with 345 additions and 275 deletions

View File

@@ -1,4 +1,5 @@
using System.Reflection;
using JNPF;
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
@@ -22,6 +23,7 @@ using SqlSugar;
using Tnb.BasicData;
using Tnb.BasicData.Entities;
using Tnb.BasicData.Entities.Dto;
using Tnb.Common.Extension;
using Tnb.EquipMgr.Entities;
using Tnb.PerMgr.Entities;
using Tnb.ProductionMgr.Entities;
@@ -32,6 +34,8 @@ using Tnb.ProductionMgr.Interfaces;
using Tnb.QcMgr.Entities;
using Tnb.QcMgr.Entities.Enums;
using Tnb.QcMgr.Interfaces;
using Tnb.WarehouseMgr.Entities.Configs;
using Tnb.Common.Utils;
// using Tnb.PerMgr.Entities;
@@ -57,6 +61,7 @@ namespace Tnb.ProductionMgr
private readonly IBillRullService _billRuleService;
private readonly IPrdInstockService _prdInstockService;
private readonly IQcCheckPlanService _qcCheckPlanService;
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>();
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
public PrdMoTaskService(
@@ -1051,6 +1056,10 @@ namespace Tnb.ProductionMgr
{
throw new ArgumentException($"{nameof(input.Behavior)} not be null or empty");
}
ISqlSugarClient db = _repository.AsSugarClient();
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
{
List<PrdMoTask> prdTaskList = new List<PrdMoTask>();
//var taskList = await _db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id) && it.mo_task_status == DictConst.ToBeScheduledEncode).ToListAsync();
//if (taskList?.Count > 0)
{
@@ -1069,7 +1078,7 @@ namespace Tnb.ProductionMgr
PrdTaskBehavior behavior = input.Behavior.ToEnum<PrdTaskBehavior>();
string status = SetTaskStatus(behavior);
ISqlSugarClient db = _repository.AsSugarClient();
List<PrdMoTask>? list = await db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id)).Select(it => it).ToListAsync();
if (behavior == PrdTaskBehavior.Compled)
{
@@ -1095,7 +1104,7 @@ namespace Tnb.ProductionMgr
List<PrdMoTask> taskReportLogs = new();
List<PrdMoTask> prdTaskList = await db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id)).ToListAsync();
prdTaskList = await db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id)).ToListAsync();
if (prdTaskList?.Count > 0)
{
#region
@@ -1349,10 +1358,66 @@ namespace Tnb.ProductionMgr
}
}
}
foreach (var item in prdTaskList)
{
if (PrdTaskBehavior.Start==behavior && item.schedule_type == 2)
{
PrdMo prdMo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == item.mo_id);
if (prdMo.mo_type == DictConst.PrdMoTypeBZ)
{
if (await _db.Queryable<PrdOutPackMarkLabel>().Where(x =>
x.mo_task_code == item.mo_task_code && x.status == "0" && x.is_label == null && x.is_mark==0).AnyAsync())
{
await _db.Updateable<PrdOutPackMarkLabel>()
.SetColumns(x => x.is_label == 0)
.Where(x => x.mo_task_code == item.mo_task_code && x.status == "0" && x.is_label == null &&
x.is_mark == 0)
.ExecuteCommandAsync();
}
else
{
PrdOutPackMarkLabel prdOutPackMarkLabel = new PrdOutPackMarkLabel()
{
is_mark = null,
is_label = 0,
mo_task_code = item.mo_task_code,
material_code = item.material_code,
create_time = DateTime.Now,
};
await _db.Insertable<PrdOutPackMarkLabel>(prdOutPackMarkLabel).ExecuteCommandAsync();
}
PrdMoTask parent = await _db.Queryable<PrdMoTask>().SingleAsync(x => x.id == item.parent_id);
BasMaterial basMaterial = await _db.Queryable<BasMaterial>().SingleAsync(x=>x.id==parent.material_id);
string code = $"(01){basMaterial.di ?? ""}(11){DateTime.Now.ToString("yyMMdd")}(17){DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyMMdd")}(10){parent.batch??""}#{basMaterial.material_standard}*{DateTime.Now.ToString("yyyyMMdd")}*{DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyyyMMdd")}*{basMaterial.container_no}";
Dictionary<string, string> dicCommand1 = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = "外包装箱码垛线",
["token"] = _eleCtlCfg.token,
["TagName"] = "WBZX_tb_cs",
["Value"] = code,
};
Dictionary<string, string> dicCommand2 = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = "外包装箱码垛线",
["token"] = _eleCtlCfg.token,
["TagName"] = "WBZX_pm_cs",
["Value"] = code,
};
await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand1);
await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2);
}
}
}
}
});
//else
// throw new AppFriendlyException("只有待下发状态的任务才可下发", 500);
return row > 0;
return result.IsSuccess ? "保存成功" : result.ErrorMessage;
}
/// <summary>
@@ -2208,22 +2273,22 @@ namespace Tnb.ProductionMgr
ToolMolds toolMolds = await db.Queryable<ToolMolds>().SingleAsync(x => x.id == input.molds_id);
if (toolMolds == null)
{
throw Oops.Bah("没找到模具");
throw Oops.Bah("没找到模具,预计完成时间无法计算");
}
if (toolMolds?.mold_cavity <= 0)
{
throw Oops.Bah("模穴数错误");
throw Oops.Bah("模穴数错误,预计完成时间无法计算");
}
if (processStandardsH == null)
{
throw Oops.Bah("工艺标准成型周期错误");
throw Oops.Bah("工艺标准成型周期错误,预计完成时间无法计算");
}
if (processStandardsH?.moulding_cycle <= 0)
{
throw Oops.Bah("工艺标准成型周期错误");
throw Oops.Bah("工艺标准成型周期错误,预计完成时间无法计算");
}
decimal? addTime = (((input.scheduled_qty * processStandardsH?.moulding_cycle) - 1) / toolMolds.mold_cavity) + 1;
@@ -2235,6 +2300,10 @@ namespace Tnb.ProductionMgr
.LeftJoin<BasStandardTime>((a, b) => a.process_id == b.process_id && b.enabled == 1)
.Where((a, b) => a.mbom_id == input.mbom_id).Select((a, b) => b).ToListAsync();
if (list.IsEmpty())
{
throw Oops.Bah("无标准工时,预计完成时间无法计算");
}
decimal max = list.Select(x => Convert.ToDecimal(x.standard_time)).Max(x => x);
decimal? addTime = input.scheduled_qty * max;
return input.estimated_start_date.AddSeconds((double)addTime.Value).ToString("yyyy-MM-dd HH:mm:ss");
@@ -2939,6 +3008,7 @@ namespace Tnb.ProductionMgr
public async Task<dynamic> GetLabelInfo(MarkingLabelInput input)
{
Log.Information($"获取喷码贴标信息参数:{JsonConvert.SerializeObject(input)}");
//TODO 之后要改
Dictionary<String, String> dic = new Dictionary<string, string>()
{
["WBZX1"] = "30019971917589",//血路管自动生产线1线

View File

@@ -108,10 +108,10 @@ namespace Tnb.ProductionMgr
["TagName"] = eqpDaq3.label_point,
["Value"] = "false",
};
Log.Information($"称重完成参数:{JsonConvert.SerializeObject(dicCommand)}");
Log.Information($"称重完成参数:{JsonConvert.SerializeObject(dicCommand2)}");
for (int i = 0; i < 5; i++)
{
await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand);
await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2);
}
}

View File

@@ -225,8 +225,8 @@ namespace Tnb.ProductionMgr
string startLocationCode = cs01==false ? "ZSSSXCTU01" : cs03==false ? "ZSSSXCTU02" : "";
if (startLocationCode.IsEmpty())
{
Log.Error($"起始库位为空");
return "起始库位为空";
Log.Error($"输送线无空载具");
return "输送线无空载具";
}
var db = _repository.AsSugarClient();