From 1906fc9ad36aa766b4134f619a3a268d6fe761a9 Mon Sep 17 00:00:00 2001
From: zhou keda <1315948824@qq.com>
Date: Tue, 25 Jun 2024 14:23:53 +0800
Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=94=9F=E4=BA=A7=E6=8F=90?=
=?UTF-8?q?=E6=8A=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Entity/PrdVisionResultRecord.cs | 4 +
.../IPrdMoTaskService.cs | 3 +
.../Tnb.ProductionMgr/PrdMoTaskService.cs | 78 ++++++++++++++++---
.../Tnb.ProductionMgr/TimeWorkService.cs | 32 ++++++++
4 files changed, 106 insertions(+), 11 deletions(-)
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdVisionResultRecord.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdVisionResultRecord.cs
index 87c4c4ab..d03c0fb7 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdVisionResultRecord.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdVisionResultRecord.cs
@@ -13,5 +13,9 @@ namespace Tnb.ProductionMgr.Entities
public string result { get; set; }
public int num { get; set; }
public DateTime create_time { get; set; }
+ ///
+ /// 0 未入库 1 已入库
+ ///
+ public int status { get; set; }
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs
index 3a28f090..dba4f2aa 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs
@@ -1,5 +1,6 @@
using Tnb.ProductionMgr.Entities;
using Tnb.ProductionMgr.Entities.Dto;
+using Tnb.ProductionMgr.Entities.Dto.PrdManage;
namespace Tnb.ProductionMgr.Interfaces
{
@@ -50,5 +51,7 @@ namespace Tnb.ProductionMgr.Interfaces
///
Task GetLabelInfoByStationId(MarkingLabelInput input);
+ Task PrdReport(PrdReportCrInput input);
+
}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index cbdde078..ce6917fc 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -1699,7 +1699,16 @@ namespace Tnb.ProductionMgr
}
report.warehouse_id = WmsWareHouseConst.WAREHOUSE_JXK_ID;
- report.location_code = "ZZ-01-01";//TODO 组装工单库位先写死
+ Dictionary worklineWarehouseDic = new Dictionary()
+ {
+ [WmsWareHouseConst.XUELUGUAN1XIAN] = "ZZ-01-01",
+ [WmsWareHouseConst.XUELUGUAN2XIAN] = "ZZ-01-02",
+ };
+ report.location_code = worklineWarehouseDic.GetOrDefault(prdMoTask.workline_id);
+ if (string.IsNullOrEmpty(report.location_code))
+ {
+ report.location_code = "ZZ-01-01";
+ }
}
else
{
@@ -1732,7 +1741,7 @@ namespace Tnb.ProductionMgr
// report.location_code = input.location_code;
- report.create_id = _userManager.UserId;
+ report.create_id = _userManager?.UserId ?? WmsWareHouseConst.AdministratorUserId;
report.create_time = DateTime.Now;
report.batch = batch;
report.barcode = input.mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
@@ -1970,6 +1979,23 @@ namespace Tnb.ProductionMgr
{
throw Oops.Bah(x2ServerResult.Msg);
}
+
+ Dictionary dicCommand4 = new(StringComparer.OrdinalIgnoreCase)
+ {
+ ["DevName"] = "外包装箱码垛线",
+ ["token"] = _eleCtlCfg.token,
+ ["TagName"] = "WBZX_x1_Enquantity",
+ ["Value"] = "0",
+ };
+
+ Log.Information($"清除提报码垛数参数:{JsonConvert.SerializeObject(dicCommand4)}");
+ string responseresult2 = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand4);
+ Log.Information($"清除提报码垛数成返回结果:{responseresult2}");
+ X2ServerResult x2ServerResult2 = JsonConvert.DeserializeObject(responseresult2);
+ if (x2ServerResult2.Result != X2ServerResult.Ok)
+ {
+ throw Oops.Bah(x2ServerResult2.Msg);
+ }
}
if (basMaterial.category_id.Contains("ZSJ") || basMaterial.category_id.Contains("DGJCJ"))
@@ -2025,6 +2051,7 @@ namespace Tnb.ProductionMgr
bindCarryCodeInput.location_id = location.id;
bindCarryCodeInput.location_code = location.location_code;
bindCarryCodeInput.code_batch = prdMoTask.batch;
+ bindCarryCodeInput.create_id = _userManager?.UserId ?? WmsWareHouseConst.AdministratorUserId;
Log.Information($"载具绑定参数:${JsonConvert.SerializeObject(bindCarryCodeInput)}");
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result1 = await _wmsCarryService.BindCarryMaterial(bindCarryCodeInput);
@@ -2045,6 +2072,7 @@ namespace Tnb.ProductionMgr
wmsPrdInstockInput.type = prdMo.mo_type;
wmsPrdInstockInput.create_id = report.create_id;
wmsPrdInstockInput.prdInstockDs = new List();
+ wmsPrdInstockInput.prdInstockCodes = new List();
wmsPrdInstockInput.prdInstockDs.Add(new WmsPrdInstockDInput()
{
task_bill_code = prdMoTask.mo_task_code,
@@ -2052,16 +2080,43 @@ namespace Tnb.ProductionMgr
startlocation_id = location.id,
carry_id = wmsCarryH.id,
});
- wmsPrdInstockInput.prdInstockCodes = new List();
- wmsPrdInstockInput.prdInstockCodes.Add(new WmsPrdInstockCodeInput()
+
+ if (prdMoTask.schedule_type == 1)
{
- planqty = prdMoTask.scheduled_qty.Value,
- pqty = input.reported_qty,
- code_batch = batch,
- code = report.barcode,
- unit_id = prdMoTask.unit_id,
- carry_id = wmsCarryH.id,
- });
+ wmsPrdInstockInput.prdInstockCodes.Add(new WmsPrdInstockCodeInput()
+ {
+ planqty = prdMoTask.scheduled_qty.Value,
+ pqty = input.reported_qty,
+ code_batch = batch,
+ code = report.barcode,
+ unit_id = prdMoTask.unit_id,
+ carry_id = wmsCarryH.id,
+ });
+ }
+ else
+ {
+ List prdVisionResultRecords = await _db.Queryable()
+ .Where(x => x.status == 0 && x.result.ToUpper()=="OK").OrderByDescending(x => x.create_time).Take(report.reported_qty.Value).ToListAsync();
+
+ List ids = prdVisionResultRecords.Select(x => x.id).ToList();
+
+ foreach (var record in prdVisionResultRecords)
+ {
+ wmsPrdInstockInput.prdInstockCodes.Add(new WmsPrdInstockCodeInput()
+ {
+ planqty = prdMoTask.scheduled_qty.Value,
+ pqty = 1,
+ code_batch = batch,
+ code = record.info,
+ unit_id = prdMoTask.unit_id,
+ carry_id = wmsCarryH.id,
+ });
+ }
+
+ await db.Updateable()
+ .SetColumns(x => x.status == 1).Where(x => ids.Contains(x.id)).ExecuteCommandAsync();
+ }
+
Log.Information($"生产入库参数:${JsonConvert.SerializeObject(wmsPrdInstockInput)}");
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = await _wmsPrdInstockHService.PrdInstock(wmsPrdInstockInput, _db);
@@ -3399,6 +3454,7 @@ namespace Tnb.ProductionMgr
reocrd.result = input.result;
reocrd.create_time = DateTime.Now;
reocrd.num = int.Parse(input.station_id);
+ reocrd.status = 0;
await _db.Insertable(reocrd).ExecuteCommandAsync();
return $"接收到参数:{JsonConvert.SerializeObject(input)}";
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs
index 4411c88e..24191b7c 100644
--- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs
@@ -28,6 +28,9 @@ using Tnb.BasicData;
using Tnb.EquipMgr.Entities;
using Tnb.WarehouseMgr;
using Tnb.WarehouseMgr.Entities;
+using Tnb.ProductionMgr.Entities;
+using Tnb.ProductionMgr.Interfaces;
+using Tnb.ProductionMgr.Entities.Dto.PrdManage;
namespace Tnb.ProductionMgr
{
@@ -42,6 +45,7 @@ namespace Tnb.ProductionMgr
private readonly RedisData _redisData;
private readonly IWmsEmptyOutstockService _wmsEmptyOutstockService;
private readonly IWareHouseService _wareHouseService;
+ private readonly IPrdMoTaskService _prdMoTaskService;
public TimeWorkService(
RedisData redisData,
@@ -49,6 +53,7 @@ namespace Tnb.ProductionMgr
IBillRullService billRullService,
IOrganizeService organizeService,
IWmsEmptyOutstockService wmsEmptyOutstockService,
+ IPrdMoTaskService prdMoTaskService,
IWareHouseService wareHouseService
)
{
@@ -59,6 +64,7 @@ namespace Tnb.ProductionMgr
_billRullService = billRullService;
_wmsEmptyOutstockService = wmsEmptyOutstockService;
_wareHouseService = wareHouseService;
+ _prdMoTaskService = prdMoTaskService;
}
[HttpGet]
@@ -333,6 +339,32 @@ namespace Tnb.ProductionMgr
return msg;
}
+
+ [HttpGet]
+ [AllowAnonymous]
+ public async Task AutoPrdReport()
+ {
+ string carryCode = await _redisData.TryGetValueByKeyField("外包装箱码垛线", "WBZX_x1_take_tp");
+ int num = await _redisData.TryGetValueByKeyField("外包装箱码垛线", "WBZX_x1_Enquantity");
+ if (string.IsNullOrEmpty(carryCode) || num<=0)
+ {
+ return "无载具或数量为0";
+ }
+ PrdMoTask prdMoTask = await _db.Queryable().Where(x => x.workline_id == WmsWareHouseConst.XUELUGUAN1XIAN && x.mo_task_status == DictConst.InProgressEnCode && x.parent_id == null).FirstAsync();
+ if (prdMoTask == null)
+ {
+ return "血路管1线没有进行中的任务单";
+ }
+
+ PrdReportCrInput input = new PrdReportCrInput();
+ input.mo_task_code = prdMoTask.mo_task_code;
+ input.mo_task_id = prdMoTask.id;
+ input.reported_qty = num;
+ input.station = "";
+ input.material_box_code = carryCode;
+ await _prdMoTaskService.PrdReport(input);
+ return "true";
+ }
}
}
\ No newline at end of file