机台原料设定
This commit is contained in:
@@ -228,4 +228,9 @@ public partial class EqpEquipment : BaseEntity<string>
|
|||||||
/// 入库仓库id
|
/// 入库仓库id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? instock_warehouse_id { get; set; }
|
public string? instock_warehouse_id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 截料阀
|
||||||
|
/// </summary>
|
||||||
|
public string stop_valve { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,20 @@ public partial class PrdRawMaterialBarcode : BaseEntity<string>
|
|||||||
public string bill_code { get; set; } = string.Empty;
|
public string bill_code { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 料仓id/机台id
|
/// 料仓id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string equip_id { get; set; } = string.Empty;
|
public string equip_id { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 机台id
|
||||||
|
/// </summary>
|
||||||
|
public string equip_ids { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 截料阀
|
||||||
|
/// </summary>
|
||||||
|
public string stop_valve { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物料id
|
/// 物料id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -52,12 +62,12 @@ public partial class PrdRawMaterialBarcode : BaseEntity<string>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开始时间
|
/// 开始时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime start_time { get; set; } = DateTime.Now;
|
public DateTime? start_time { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 结束时间
|
/// 结束时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime end_time { get; set; } = DateTime.Now;
|
public DateTime? end_time { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 备注
|
/// 备注
|
||||||
|
|||||||
@@ -20,10 +20,20 @@ public partial class PrdRawMaterialBarcodeRecord : BaseEntity<string>
|
|||||||
public string bill_code { get; set; } = string.Empty;
|
public string bill_code { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 料仓id/机台id
|
/// 料仓id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string equip_id { get; set; } = string.Empty;
|
public string equip_id { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 机台id
|
||||||
|
/// </summary>
|
||||||
|
public string equip_ids { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 截料阀
|
||||||
|
/// </summary>
|
||||||
|
public string stop_valve { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 物料id
|
/// 物料id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ using Tnb.WarehouseMgr.Entities.Configs;
|
|||||||
using Tnb.Common.Utils;
|
using Tnb.Common.Utils;
|
||||||
using Tnb.WarehouseMgr.Entities.Consts;
|
using Tnb.WarehouseMgr.Entities.Consts;
|
||||||
using HttpClientHelper = Tnb.Common.Utils.HttpClientHelper;
|
using HttpClientHelper = Tnb.Common.Utils.HttpClientHelper;
|
||||||
|
using Tnb.Common.Redis;
|
||||||
|
|
||||||
namespace Tnb.ProductionMgr
|
namespace Tnb.ProductionMgr
|
||||||
{
|
{
|
||||||
@@ -46,11 +47,13 @@ namespace Tnb.ProductionMgr
|
|||||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||||
private readonly IVisualDevService _visualDevService;
|
private readonly IVisualDevService _visualDevService;
|
||||||
private readonly IRunService _runService;
|
private readonly IRunService _runService;
|
||||||
|
private readonly RedisData _redisData;
|
||||||
|
|
||||||
public PrdRawMaterialBarcodeService(ISqlSugarRepository<PrdRawMaterialBarcode> repository,
|
public PrdRawMaterialBarcodeService(ISqlSugarRepository<PrdRawMaterialBarcode> repository,
|
||||||
IUserManager userManager,
|
IUserManager userManager,
|
||||||
IBillRullService billRuleService,
|
IBillRullService billRuleService,
|
||||||
IVisualDevService visualDevService,
|
IVisualDevService visualDevService,
|
||||||
|
RedisData redisData,
|
||||||
IRunService runService,
|
IRunService runService,
|
||||||
IDictionaryDataService dictionaryDataService)
|
IDictionaryDataService dictionaryDataService)
|
||||||
{
|
{
|
||||||
@@ -60,6 +63,7 @@ namespace Tnb.ProductionMgr
|
|||||||
_dictionaryDataService = dictionaryDataService;
|
_dictionaryDataService = dictionaryDataService;
|
||||||
_visualDevService = visualDevService;
|
_visualDevService = visualDevService;
|
||||||
_runService = runService;
|
_runService = runService;
|
||||||
|
_redisData = redisData;
|
||||||
OverideFuncs.UpdateAsync = Update;
|
OverideFuncs.UpdateAsync = Update;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,6 +294,7 @@ namespace Tnb.ProductionMgr
|
|||||||
.SetColumns(x => x.end_time == null)
|
.SetColumns(x => x.end_time == null)
|
||||||
.SetColumns(x => x.is_update == 0)
|
.SetColumns(x => x.is_update == 0)
|
||||||
.SetColumns(x => x.material_id == "")
|
.SetColumns(x => x.material_id == "")
|
||||||
|
.SetColumns(x=>x.absorb_material_finish==0)
|
||||||
.Where(x => x.id == item.id)
|
.Where(x => x.id == item.id)
|
||||||
.ExecuteCommandAsync();
|
.ExecuteCommandAsync();
|
||||||
|
|
||||||
@@ -331,5 +336,198 @@ namespace Tnb.ProductionMgr
|
|||||||
}
|
}
|
||||||
return "成功";
|
return "成功";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新截料阀
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> UpdateStopValve(List<string> ids)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
List<PrdRawMaterialBarcode> prdRawMaterialBarcodeList = await _db.Queryable<PrdRawMaterialBarcode>()
|
||||||
|
.Where(x => ids.Contains(x.id)).ToListAsync();
|
||||||
|
foreach (var item in prdRawMaterialBarcodeList)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(item.stop_valve))
|
||||||
|
{
|
||||||
|
throw Oops.Bah($"{item.bill_code}未设置截料阀");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(item.equip_ids))
|
||||||
|
{
|
||||||
|
throw Oops.Bah($"{item.bill_code}未设置机台");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<string> equipIdList = JsonConvert.DeserializeObject<List<string>>(item.equip_ids);
|
||||||
|
List<EqpEquipment> eqpEquipments = await _db.Queryable<EqpEquipment>().Where(x => equipIdList.Contains(x.id)).ToListAsync();
|
||||||
|
foreach (var equipment in eqpEquipments)
|
||||||
|
{
|
||||||
|
EqpDaq eqpDaq = await _db.Queryable<EqpDaq>().Where(x => x.equip_id == equipment.id && x.label_name.Contains("原料选择")).FirstAsync();
|
||||||
|
|
||||||
|
if (eqpDaq == null)
|
||||||
|
{
|
||||||
|
throw Oops.Bah($"{equipment.name}未设置原料选择数据采集项");
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, string> dicCommand3 = new(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
["DevName"] = eqpDaq.equip_code,
|
||||||
|
["token"] = _eleCtlCfg.token,
|
||||||
|
["TagName"] = eqpDaq.label_name,
|
||||||
|
["Value"] = item.stop_valve,
|
||||||
|
};
|
||||||
|
Log.Information($"{eqpDaq.equip_code}{eqpDaq.label_name}更新参数:{JsonConvert.SerializeObject(dicCommand3)}");
|
||||||
|
string responseresult3 = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand3, false);
|
||||||
|
Log.Information($"{eqpDaq.equip_code}{eqpDaq.label_name}更新返回结果:{responseresult3}");
|
||||||
|
|
||||||
|
await _db.Updateable<PrdRawMaterialBarcode>()
|
||||||
|
.SetColumns(x => x.start_time == DateTime.Now)
|
||||||
|
.SetColumns(x => x.is_update == 1)
|
||||||
|
.Where(x => x.id == item.id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
await _db.Ado.RollbackTranAsync();
|
||||||
|
throw Oops.Bah(e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return "成功";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 管道状态
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> GetPipingStatus(List<string> ids)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
List<PrdRawMaterialBarcode> prdRawMaterialBarcodeList = await _db.Queryable<PrdRawMaterialBarcode>()
|
||||||
|
.Where(x => ids.Contains(x.id)).ToListAsync();
|
||||||
|
foreach (var item in prdRawMaterialBarcodeList)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(item.equip_ids))
|
||||||
|
{
|
||||||
|
throw Oops.Bah($"{item.bill_code}未设置机台");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<string> equipIdList = JsonConvert.DeserializeObject<List<string>>(item.equip_ids);
|
||||||
|
List<EqpEquipment> eqpEquipments = await _db.Queryable<EqpEquipment>().Where(x => equipIdList.Contains(x.id)).ToListAsync();
|
||||||
|
foreach (var equipment in eqpEquipments)
|
||||||
|
{
|
||||||
|
EqpDaq eqpDaq = await _db.Queryable<EqpDaq>().Where(x => x.equip_id == equipment.id && x.label_name.Contains("配管状态")).FirstAsync();
|
||||||
|
|
||||||
|
if (eqpDaq == null)
|
||||||
|
{
|
||||||
|
throw Oops.Bah($"{equipment.name}未设置配管状态数据采集项");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool data = await _redisData.TryGetValueByKeyField<bool>(eqpDaq.equip_code, eqpDaq.label_name);
|
||||||
|
|
||||||
|
int pipingStatus = data ? 1 : 0;
|
||||||
|
await _db.Updateable<PrdRawMaterialBarcode>()
|
||||||
|
.SetColumns(x => x.piping_status == pipingStatus)
|
||||||
|
.Where(x => x.id == item.id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
await _db.Ado.RollbackTranAsync();
|
||||||
|
throw Oops.Bah(e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return "成功";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 机台原料设定吸料完成
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<dynamic> MaterialSuctionCompleted2(List<string> ids)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _db.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
List<PrdRawMaterialBarcode> prdRawMaterialBarcodeList = await _db.Queryable<PrdRawMaterialBarcode>()
|
||||||
|
.Where(x => ids.Contains(x.id)).ToListAsync();
|
||||||
|
List<PrdRawMaterialBarcodeRecord> insertList = new List<PrdRawMaterialBarcodeRecord>();
|
||||||
|
foreach (var item in prdRawMaterialBarcodeList)
|
||||||
|
{
|
||||||
|
List<string> equipIdList = JsonConvert.DeserializeObject<List<string>>(item.equip_ids);
|
||||||
|
List<EqpEquipment> eqpEquipments = await _db.Queryable<EqpEquipment>().Where(x => equipIdList.Contains(x.id)).ToListAsync();
|
||||||
|
foreach (var equipment in eqpEquipments)
|
||||||
|
{
|
||||||
|
EqpDaq eqpDaq = await _db.Queryable<EqpDaq>().Where(x => x.equip_id == equipment.id && x.label_name.Contains("原料选择")).FirstAsync();
|
||||||
|
|
||||||
|
if (eqpDaq == null)
|
||||||
|
{
|
||||||
|
throw Oops.Bah($"{equipment.name}未设置原料选择数据采集项");
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, string> dicCommand3 = new(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
["DevName"] = eqpDaq.equip_code,
|
||||||
|
["token"] = _eleCtlCfg.token,
|
||||||
|
["TagName"] = eqpDaq.label_name,
|
||||||
|
["Value"] = "",
|
||||||
|
};
|
||||||
|
Log.Information($"{eqpDaq.equip_code}{eqpDaq.label_name}吸料完成参数:{JsonConvert.SerializeObject(dicCommand3)}");
|
||||||
|
string responseresult3 = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand3, false);
|
||||||
|
Log.Information($"{eqpDaq.equip_code}{eqpDaq.label_name}吸料完成返回结果:{responseresult3}");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PrdRawMaterialBarcodeRecord prdRawMaterialBarcodeRecord = item.Adapt<PrdRawMaterialBarcodeRecord>();
|
||||||
|
prdRawMaterialBarcodeRecord.id = SnowflakeIdHelper.NextId();
|
||||||
|
prdRawMaterialBarcodeRecord.end_time = DateTime.Now;
|
||||||
|
insertList.Add(prdRawMaterialBarcodeRecord);
|
||||||
|
|
||||||
|
await _db.Updateable<PrdRawMaterialBarcode>()
|
||||||
|
.SetColumns(x => x.bill_code == "")
|
||||||
|
.SetColumns(x => x.start_time == null)
|
||||||
|
.SetColumns(x => x.end_time == null)
|
||||||
|
.SetColumns(x => x.is_update == 0)
|
||||||
|
.SetColumns(x=>x.piping_status == 0)
|
||||||
|
.SetColumns(x=>x.absorb_material_finish==0)
|
||||||
|
.Where(x => x.id == item.id)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!insertList.IsEmpty())
|
||||||
|
{
|
||||||
|
await _db.Insertable(insertList).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
await _db.Ado.RollbackTranAsync();
|
||||||
|
throw Oops.Bah(e.Message);
|
||||||
|
}
|
||||||
|
return "成功";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user