|
|
|
|
@@ -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<ElevatorControlConfiguration>();
|
|
|
|
|
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<EqpEquipment>().SingleAsync(x => x.id == prdMoTask.eqp_id);
|
|
|
|
|
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == prdMoTask.material_id);
|
|
|
|
|
PrdReport report = await db.Queryable<PrdReport>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
|
|
|
|
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
|
|
|
|
Dictionary<String, String> dic = new Dictionary<string, string>()
|
|
|
|
|
{
|
|
|
|
|
["30019971917589"] = "外包装箱码垛线"
|
|
|
|
|
};
|
|
|
|
|
string materialBoxCode = input.material_box_code;
|
|
|
|
|
BasLocation location = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await _db.Ado.BeginTranAsync();
|
|
|
|
|
int row = -1;
|
|
|
|
|
PrdMo prdMo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == prdMoTask.mo_id);
|
|
|
|
|
BasMbomProcess? mbomProcess = await db.Queryable<BasMbomProcess>().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<BasMbom>().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<PrdReport>();
|
|
|
|
|
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<BasLocation>().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<string, object> header = new()
|
|
|
|
|
{
|
|
|
|
|
string[] arr = JsonConvert.DeserializeObject<string[]>(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<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN);
|
|
|
|
|
WmsCarryH wmsCarryH = await db.Queryable<WmsCarryH>().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<AuthResponse>(response1);
|
|
|
|
|
AuthResponse authResponse11 = JsonConvert.DeserializeObject<AuthResponse>(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<WmsPrdInstockDInput>();
|
|
|
|
|
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<WmsPrdInstockCodeInput>();
|
|
|
|
|
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<AuthResponse>(response2);
|
|
|
|
|
AuthResponse authResponse22 = JsonConvert.DeserializeObject<AuthResponse>(authResponse2.data.ToString());
|
|
|
|
|
if (authResponse22.code != 200)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah(authResponse22.msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (prdMoTask.schedule_type == 2)
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, string> 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<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
|
|
|
|
// {
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// if (result.IsSuccess)
|
|
|
|
|
// {
|
|
|
|
|
// if (!string.IsNullOrEmpty(basMaterial.category_id))
|
|
|
|
|
// {
|
|
|
|
|
// string[] arr = JsonConvert.DeserializeObject<string[]>(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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|