diff --git a/BasicData/Tnb.BasicData.Entities/Dto/BasMbom/MbomSaveDataInput.cs b/BasicData/Tnb.BasicData.Entities/Dto/BasMbom/MbomSaveDataInput.cs
index aa3bd507..51c21c63 100644
--- a/BasicData/Tnb.BasicData.Entities/Dto/BasMbom/MbomSaveDataInput.cs
+++ b/BasicData/Tnb.BasicData.Entities/Dto/BasMbom/MbomSaveDataInput.cs
@@ -16,6 +16,7 @@ namespace Tnb.BasicData.Entities.Dto
/// 数量
///
public int num { get; set; }
+ public int full_qty { get; set; }
///
/// 单位id
diff --git a/BasicData/Tnb.BasicData/BasMbomService.cs b/BasicData/Tnb.BasicData/BasMbomService.cs
index 4d2a2482..57e5fe01 100644
--- a/BasicData/Tnb.BasicData/BasMbomService.cs
+++ b/BasicData/Tnb.BasicData/BasMbomService.cs
@@ -586,6 +586,7 @@ namespace Tnb.BasicData
org_id = orgId,
material_id = mbomSaveDataInput.material_id,
num = mbomSaveDataInput.num,
+ full_qty = mbomSaveDataInput.full_qty,
unit_id = mbomSaveDataInput.unit_id,
version = mbomSaveDataInput.version,
start_time = mbomSaveDataInput.start_time,
@@ -711,6 +712,7 @@ namespace Tnb.BasicData
// org_id = orgId,
material_id = mbomSaveDataInput.material_id,
num = mbomSaveDataInput.num,
+ full_qty = mbomSaveDataInput.full_qty,
unit_id = mbomSaveDataInput.unit_id,
version = mbomSaveDataInput.version,
start_time = mbomSaveDataInput.start_time,
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs
index 70c6719b..779063b1 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs
@@ -88,6 +88,11 @@ public partial class PrdReport : BaseEntity
/// 条码
///
public string? barcode { get; set; }
+
+ ///
+ /// 条码数量
+ ///
+ public int barqty { get; set; }
///
@@ -134,5 +139,10 @@ public partial class PrdReport : BaseEntity
/// 入库库位
///
public string location_code { get; set; }
+
+ ///
+ /// 入库仓库
+ ///
+ public string warehouse_id { get; set; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index faa22951..5879e267 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -7,6 +7,7 @@ using JNPF.Common.Filter;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
+using JNPF.Extras.CollectiveOAuth.Models;
using JNPF.FriendlyException;
using JNPF.Logging;
using JNPF.Systems.Entitys.Permission;
@@ -19,6 +20,7 @@ using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
+using SQLitePCL;
using SqlSugar;
using Tnb.BasicData;
using Tnb.BasicData.Entities;
@@ -36,6 +38,12 @@ using Tnb.QcMgr.Entities.Enums;
using Tnb.QcMgr.Interfaces;
using Tnb.WarehouseMgr.Entities.Configs;
using Tnb.Common.Utils;
+using Tnb.Common.Redis;
+using Tnb.WarehouseMgr.Entities.Consts;
+using JNPF.Extras.CollectiveOAuth.Utils;
+using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Entities.Dto;
+using Tnb.WarehouseMgr.Entities.Dto.Inputs;
// using Tnb.PerMgr.Entities;
@@ -62,6 +70,7 @@ namespace Tnb.ProductionMgr
private readonly IPrdInstockService _prdInstockService;
private readonly IQcCheckPlanService _qcCheckPlanService;
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build();
+ private readonly RedisData _redisData;
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
public PrdMoTaskService(
@@ -1052,7 +1061,8 @@ namespace Tnb.ProductionMgr
{
throw new ArgumentNullException(nameof(input.TaskIds));
}
- if (input.Behavior.IsNullOrWhiteSpace())
+ // if (input.Behavior.IsNullOrWhiteSpace())
+ if (input.Behavior!=null && !input.Behavior.IsEmpty())
{
throw new ArgumentException($"{nameof(input.Behavior)} not be null or empty");
}
@@ -1431,7 +1441,7 @@ namespace Tnb.ProductionMgr
{
int row = -1;
ISqlSugarClient db = _repository.AsSugarClient();
- if (input.icmo_id.IsNullOrWhiteSpace())
+ if (input.icmo_id!=null && !input.mo_id.IsEmpty())
{
throw new ArgumentNullException(nameof(input.icmo_id));
}
@@ -1541,16 +1551,34 @@ namespace Tnb.ProductionMgr
EqpEquipment equip = await db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id);
BasMaterial basMaterial = await db.Queryable().SingleAsync(x => x.id == prdMoTask.material_id);
PrdReport report = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id);
- DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
+ Dictionary dic = new Dictionary()
{
+ ["30019971917589"] = "外包装箱码垛线"
+ };
+ string materialBoxCode = input.material_box_code;
+ BasLocation location = null;
+ try
+ {
+ await _db.Ado.BeginTranAsync();
int row = -1;
PrdMo prdMo = await db.Queryable().SingleAsync(x => x.id == prdMoTask.mo_id);
BasMbomProcess? mbomProcess = await db.Queryable().SingleAsync(x => x.id == prdMoTask.mbom_process_id);
-
+
if (prdMoTask.mo_task_status == DictConst.MoStatusPauseCode)
{
throw Oops.Bah("暂停的任务单无法提报");
}
+
+ if (mbomProcess == null)
+ {
+ throw Oops.Bah("未找到生产bom对应工序");
+ }
+ BasMbom mbom = await db.Queryable().SingleAsync(x => x.id == mbomProcess.mbom_id);
+
+ if (mbom == null)
+ {
+ throw Oops.Bah("未找到生产bom");
+ }
if ((prdMoTask.reported_work_qty ?? 0) + input.reported_qty > prdMoTask.scheduled_qty)
{
@@ -1594,15 +1622,48 @@ namespace Tnb.ProductionMgr
throw Oops.Bah("提报数量为正数");
}
+
report = input.Adapt();
report.id = SnowflakeIdHelper.NextId();
report.reported_qty = input.reported_qty;
report.material_box_code = input.material_box_code;
+ if (prdMoTask.schedule_type == 2)
+ {
+ if (dic.TryGetValue(prdMoTask.workline_id, out string value))
+ {
+ materialBoxCode = await _redisData.GetHash("value", "WBZX_x1_take_tp");
+ if (materialBoxCode == null || materialBoxCode.IsEmpty())
+ {
+ throw Oops.Bah("托盘条码信息未空");
+ }
+ report.material_box_code = materialBoxCode;
+ }
+ else
+ {
+ throw Oops.Bah("未找到对应产线");
+ }
+
+ report.warehouse_id = WmsWareHouseConst.WAREHOUSE_JXK_ID;
+ report.location_code = "ZZ-01-01";//TODO 组装工单库位先写死
+ }
+ else
+ {
+ report.warehouse_id = equip.instock_warehouse_id;
+ if (equip.as_location_id == null || equip.as_location_id.IsEmpty())
+ {
+ throw Oops.Bah("设备未绑定入库库位");
+ }
+ location = await db.Queryable().SingleAsync(x=>x.id==equip.as_location_id);
+ report.location_code = location.location_code;
+ }
+
+
report.location_code = input.location_code;
report.create_id = _userManager.UserId;
report.create_time = DateTime.Now;
// report.batch = input.mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
report.barcode = input.mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
+ report.barqty = mbom.full_qty;
// report.barcode = input.mo_task_code+"0001";
report.equip_id = prdMoTask.eqp_id;
report.mbom_process_id = prdMoTask.mbom_process_id;
@@ -1818,30 +1879,126 @@ namespace Tnb.ProductionMgr
// }
-
- });
-
- if (result.IsSuccess)
- {
- if (!string.IsNullOrEmpty(basMaterial.category_id))
+ Dictionary header = new()
{
- string[] arr = JsonConvert.DeserializeObject(basMaterial.category_id);
- if (arr.Length > 0 && arr.Contains("DGJCJ"))//短管挤出件入库申请
- {
- // string resultMsg = await _prdInstockService.InstockTubeOne(report);
- // return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg);
- return true;
- }
+ ["Authorization"] = App.HttpContext != null ? App.HttpContext.Request.Headers["Authorization"] : ""
+ };
+ BasFactoryConfig config = await _repository.AsSugarClient().Queryable().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN);
+ WmsCarryH wmsCarryH = await db.Queryable().SingleAsync((x => x.carry_code == materialBoxCode));
+
+ BindCarryCodeInput bindCarryCodeInput = new BindCarryCodeInput();
+ bindCarryCodeInput.carry_id = wmsCarryH.id;
+ bindCarryCodeInput.barcode = report.barcode;
+ bindCarryCodeInput.codeqty = report.reported_qty.Value;
+ bindCarryCodeInput.material_id = prdMoTask.material_id;
+ bindCarryCodeInput.material_code = basMaterial.code;
+ bindCarryCodeInput.material_name = basMaterial.name;
+ bindCarryCodeInput.location_id = location.id;
+ bindCarryCodeInput.location_code = location.location_code;
+ bindCarryCodeInput.code_batch = prdMoTask.batch;
- if (arr.Length > 0 && arr.Contains("CGJCJ"))//短管挤出件入库申请
- {
- string resultMsg = await _prdInstockService.InstockTubeThree(report);
- return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg);
- }
+ // string response1 = HttpUtils.RequestPost($"{config.value}/api/wms/wms-carry/bind-carry-material",JsonConvert.SerializeObject(bindCarryCodeInput), header);
+ string response1 = HttpUtils.RequestPost($"http://localhost:9232/api/wms/wms-carry/bind-carry-material",JsonConvert.SerializeObject(bindCarryCodeInput), header);
+ AuthResponse authResponse1 = JsonConvert.DeserializeObject(response1);
+ AuthResponse authResponse11 = JsonConvert.DeserializeObject(authResponse1.data.ToString());
+ if (authResponse11.code != 200)
+ {
+ throw Oops.Bah(authResponse11.msg);
+ }
+
+ WmsPrdInstockInput wmsPrdInstockInput = new WmsPrdInstockInput();
+ wmsPrdInstockInput.prd_bill_code = prdMo.mo_code;
+ wmsPrdInstockInput.material_id = prdMoTask.material_id;
+ wmsPrdInstockInput.material_code = prdMoTask.material_code;
+ wmsPrdInstockInput.material_name = basMaterial.name;
+ wmsPrdInstockInput.material_spec = basMaterial.material_standard;
+ wmsPrdInstockInput.planqty = prdMoTask.scheduled_qty.Value;
+ wmsPrdInstockInput.pqty = input.reported_qty;
+ wmsPrdInstockInput.rqty = 0;
+ wmsPrdInstockInput.type = WmsWareHouseConst.BIZTYPE_WMSPRDINSTOCK_ID;
+ wmsPrdInstockInput.create_id = report.create_id;
+ wmsPrdInstockInput.prdInstockDs = new List();
+ wmsPrdInstockInput.prdInstockDs.Add(new WmsPrdInstockDInput()
+ {
+ task_bill_code = prdMoTask.mo_task_code,
+ warehouse_id = report.warehouse_id,
+ startlocation_id = location.id,
+ carry_id = wmsCarryH.id,
+ });
+ wmsPrdInstockInput.prdInstockCodes = new List();
+ wmsPrdInstockInput.prdInstockCodes.Add(new WmsPrdInstockCodeInput()
+ {
+ planqty = prdMoTask.scheduled_qty.Value,
+ pqty = input.reported_qty,
+ code_batch = prdMoTask.batch,
+ code = report.barcode,
+ unit_id = prdMoTask.unit_id,
+ carry_id = wmsCarryH.id,
+ });
+
+ // string response2 = HttpUtils.RequestPost($"{config.value}/api/wms/wms-prd-instock-h/prd-instock",JsonConvert.SerializeObject(wmsPrdInstockInput), header);
+ string response2 = HttpUtils.RequestPost($"http://localhost:9232/api/wms/wms-prd-instock-h/prd-instock",JsonConvert.SerializeObject(wmsPrdInstockInput), header);
+ AuthResponse authResponse2 = JsonConvert.DeserializeObject(response2);
+ AuthResponse authResponse22 = JsonConvert.DeserializeObject(authResponse2.data.ToString());
+ if (authResponse22.code != 200)
+ {
+ throw Oops.Bah(authResponse22.msg);
+ }
+
+ if (prdMoTask.schedule_type == 2)
+ {
+ Dictionary dicCommand2 = new(StringComparer.OrdinalIgnoreCase)
+ {
+ ["DevName"] = dic[prdMoTask.workline_id],
+ ["token"] = _eleCtlCfg.token,
+ ["TagName"] = "WBZX_x1_ok",
+ ["Value"] = "true",
+ };
+ Log.Information($"提拔确认完成参数:{JsonConvert.SerializeObject(dicCommand2)}");
+ await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2);
}
- }
- return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)result.IsSuccess;
+
+ await _db.Ado.CommitTranAsync();
+
+ }
+ catch (Exception ex)
+ {
+ Log.Error("提报失败", ex);
+ await _db.Ado.RollbackTranAsync();
+ throw Oops.Bah("提报失败:"+ex.Message);
+ }
+
+ // DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
+ // {
+ //
+ //
+ //
+ // });
+
+ // if (result.IsSuccess)
+ // {
+ // if (!string.IsNullOrEmpty(basMaterial.category_id))
+ // {
+ // string[] arr = JsonConvert.DeserializeObject(basMaterial.category_id);
+ // if (arr.Length > 0 && arr.Contains("DGJCJ"))//短管挤出件入库申请
+ // {
+ // // string resultMsg = await _prdInstockService.InstockTubeOne(report);
+ // // return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg);
+ // return true;
+ // }
+ //
+ // if (arr.Length > 0 && arr.Contains("CGJCJ"))//短管挤出件入库申请
+ // {
+ // string resultMsg = await _prdInstockService.InstockTubeThree(report);
+ // return resultMsg == "true" ? (dynamic)true : throw Oops.Bah(resultMsg);
+ // }
+ // }
+ //
+ //
+ // }
+
+ return true;
}
///
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
index b69bd880..2504ced4 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
@@ -18,6 +18,11 @@
/// 成品仓库ID
///
public const string WAREHOUSE_CP_ID = "26103372441637";
+ ///
+ /// 四楼解析库
+ ///
+ public const string WAREHOUSE_JXK_ID = "26103367464997";
+
///
/// 出入库单据状态TypeID