挤出批号修改 erp接口另起线程调用

This commit is contained in:
2024-09-29 16:03:05 +08:00
parent e6a0066616
commit a04831bbae
8 changed files with 76 additions and 28 deletions

View File

@@ -11,6 +11,6 @@ namespace Tnb.BasicData.Interfaces
/// <param name="id"></param> /// <param name="id"></param>
/// <param name="send_type">手动 自动</param> /// <param name="send_type">手动 自动</param>
/// <returns></returns> /// <returns></returns>
Task<ThirdResult> Send(List<ThirdWebapiRecord> records, string send_type,ISqlSugarClient db=null); Task<ThirdResult> Send(List<ThirdWebapiRecord> records, string send_type,ISqlSugarClient db=null,bool ThreadFlag = true);
} }
} }

View File

@@ -44,7 +44,7 @@ namespace Tnb.BasicData
public async Task<string> Send(string id) public async Task<string> Send(string id)
{ {
ThirdWebapiRecord record = await _repository.GetSingleAsync(x=>x.id==id); ThirdWebapiRecord record = await _repository.GetSingleAsync(x=>x.id==id);
ThirdResult thirdResult = await Send(Arrays.AsList(record), "手动"); ThirdResult thirdResult = await Send(Arrays.AsList(record), "手动",null,false);
return thirdResult.msgResult; return thirdResult.msgResult;
} }
@@ -89,7 +89,25 @@ namespace Tnb.BasicData
return "失败"; return "失败";
} }
public async Task<ThirdResult> Send(List<ThirdWebapiRecord> records, string send_type,ISqlSugarClient db=null) public async Task<ThirdResult> Send(List<ThirdWebapiRecord> records, string send_type,ISqlSugarClient db=null,bool threadFlag=true)
{
ThirdResult thirdResult = new ThirdResult();
if (threadFlag)
{
Task.Run(() =>
{
Send(records, send_type, db);
});
}
else
{
thirdResult = await Send(records, send_type, db);
}
return thirdResult;
}
private async Task<ThirdResult> Send(List<ThirdWebapiRecord> records, string send_type, ISqlSugarClient db = null)
{ {
ThirdResult thirdResult = null; ThirdResult thirdResult = null;
bool tranFlag = true; bool tranFlag = true;
@@ -273,8 +291,6 @@ namespace Tnb.BasicData
Log.Error(e.Message,e); Log.Error(e.Message,e);
if(tranFlag) await db.Ado.RollbackTranAsync(); if(tranFlag) await db.Ado.RollbackTranAsync();
} }
return thirdResult; return thirdResult;
} }
} }

View File

@@ -169,4 +169,14 @@ public partial class PrdReport : BaseEntity<string>
/// </summary> /// </summary>
public string erp_pk_wr_product { get; set; } public string erp_pk_wr_product { get; set; }
/// <summary>
/// 合格数
/// </summary>
public decimal? pqty { get; set; }
/// <summary>
/// 不合格数
/// </summary>
public decimal? rqty { get; set; }
} }

View File

@@ -2092,22 +2092,12 @@ namespace Tnb.ProductionMgr
}else if (mo.mo_type == DictConst.PrdMoTypeJC) }else if (mo.mo_type == DictConst.PrdMoTypeJC)
{ {
if (changeBatchFlag) ToolMolds toolMolds = await _db.Queryable<ToolMolds>().SingleAsync(x => x.id == prdMoTask.mold_id);
{ batch = $"6{toolMolds.mold_code.Substring(toolMolds.mold_code.Length - 4, 2)}{DateTime.Now.ToString("yyMMdd")}";
EqpEquipment equipment = await _db.Queryable<EqpEquipment>().SingleAsync(x => x.id == prdMoTask.eqp_id); await db.Updateable<PrdMoTask>()
ToolMolds toolMolds = await _db.Queryable<ToolMolds>().SingleAsync(x => x.id == prdMoTask.mold_id); .SetColumns(x => x.batch == batch)
batch = $"{toolMolds.mold_code.Substring(toolMolds.mold_code.Length - 2, 2)}{equipment.code.Substring(equipment.code.Length - 2, 2)}{prdMoTask.act_start_date.Value.ToString("yyMMdd")}"; .Where(x => x.id == prdMoTask.id)
await db.Updateable<PrdMoTask>() .ExecuteCommandAsync();
.SetColumns(x => x.batch == batch)
.SetColumns(x=>x.change_batch_count_by_day==changeCountNumByDay)
.SetColumns(x=>x.change_batch_count_by_qty==changeCountNumByQty)
.Where(x => x.id == prdMoTask.id)
.ExecuteCommandAsync();
}
else
{
batch = prdMoTask.batch;
}
}else }else
{ {
// OrganizeEntity organizeEntity = await _db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == prdMoTask.workline_id); // OrganizeEntity organizeEntity = await _db.Queryable<OrganizeEntity>().SingleAsync(x => x.Id == prdMoTask.workline_id);
@@ -2496,6 +2486,12 @@ namespace Tnb.ProductionMgr
throw Oops.Bah(result1.msg); throw Oops.Bah(result1.msg);
} }
await _db.Updateable<PrdReport>()
.SetColumns(x => x.pqty == input.pqty)
.SetColumns(x => x.rqty == input.rqty)
.Where(x => x.id == report.id)
.ExecuteCommandAsync();
WmsPrdInstockInput wmsPrdInstockInput = new WmsPrdInstockInput(); WmsPrdInstockInput wmsPrdInstockInput = new WmsPrdInstockInput();
wmsPrdInstockInput.prd_bill_code = prdMo.mo_code; wmsPrdInstockInput.prd_bill_code = prdMo.mo_code;
wmsPrdInstockInput.material_id = prdMoTask.material_id; wmsPrdInstockInput.material_id = prdMoTask.material_id;
@@ -2627,8 +2623,8 @@ namespace Tnb.ProductionMgr
// ["cbastunitid"] = erpExtendFields.Find(x=>x.table_id==report.unit_id)?.cunitid ?? "", // ["cbastunitid"] = erpExtendFields.Find(x=>x.table_id==report.unit_id)?.cunitid ?? "",
["cbunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == report.unit_id)?.Id ?? ""))?.cunitid ?? "", ["cbunitid"] = erpExtendFields.Find(x => x.table_id == (unitDatas.Find(x => x.EnCode == report.unit_id)?.Id ?? ""))?.cunitid ?? "",
["cbastunitid"] = erpExtendFields.Find(x =>x.table_id == (unitDatas.Find(x => x.EnCode == report.unit_id)?.Id ?? ""))?.cunitid ?? "", ["cbastunitid"] = erpExtendFields.Find(x =>x.table_id == (unitDatas.Find(x => x.EnCode == report.unit_id)?.Id ?? ""))?.cunitid ?? "",
["nbplanwrnum"] = report.reported_qty, ["nbplanwrnum"] = input.pqty,
["nbwrnum"] = report.reported_qty, ["nbwrnum"] = input.pqty,
["tbendtime"] = nowStr, ["tbendtime"] = nowStr,
["tbstarttime"] = prdMoTask.act_start_date != null ? prdMoTask.act_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", ["tbstarttime"] = prdMoTask.act_start_date != null ? prdMoTask.act_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
["vbinbatchcode"] = report.batch, ["vbinbatchcode"] = report.batch,
@@ -2751,6 +2747,29 @@ namespace Tnb.ProductionMgr
} }
[HttpPost]
public async Task<string> DelPrdReport(string id)
{
PrdReport prdReport = await _db.Queryable<PrdReport>().SingleAsync(x => x.id == id);
PrdMoTask prdMoTask = await _db.Queryable<PrdMoTask>().SingleAsync(x => x.id == prdReport.mo_task_id);
DbResult<bool> result = await _db.Ado.UseTranAsync(async () =>
{
await _db.Updateable<PrdMoTask>()
.SetColumns(x => x.reported_work_qty == x.reported_work_qty - prdReport.reported_qty)
.Where(x => x.id == prdMoTask.id)
.ExecuteCommandAsync();
await _db.Updateable<PrdMo>()
.SetColumns(x => x.reported_work_qty == x.reported_work_qty - prdReport.reported_qty)
.Where(x => x.id == prdMoTask.mo_id)
.ExecuteCommandAsync();
await _db.Deleteable<PrdReport>().Where(x => x.id == id).ExecuteCommandAsync();
});
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result.IsSuccess ? "保存成功" : result.ErrorMessage);
}
/// <summary> /// <summary>
/// 自检报废提交 /// 自检报废提交
/// </summary> /// </summary>

View File

@@ -164,4 +164,9 @@ public partial class WmsPurchaseH : BaseEntity<string>, IPurchaseAndSaleAuitEnti
/// 制单方式(自制 同步) /// 制单方式(自制 同步)
/// </summary> /// </summary>
public string make_method { get; set; } public string make_method { get; set; }
/// <summary>
/// erp流水号
/// </summary>
public string service_num { get; set; }
} }

View File

@@ -402,6 +402,7 @@ namespace Tnb.WarehouseMgr
erpRequestData.Add("vbillcode", instock.bill_code); erpRequestData.Add("vbillcode", instock.bill_code);
erpRequestData.Add("vtrantypecode", tranType?.EnCode ?? ""); erpRequestData.Add("vtrantypecode", tranType?.EnCode ?? "");
erpRequestData.Add("csourcebillhid", wmsPurchaseH?.erp_arriveorder_pk ?? ""); erpRequestData.Add("csourcebillhid", wmsPurchaseH?.erp_arriveorder_pk ?? "");
erpRequestData.Add("vdef3", wmsPurchaseH?.service_num ?? "");
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>(); List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
foreach (WmsInstockD item in allInstockDetails) foreach (WmsInstockD item in allInstockDetails)

View File

@@ -479,11 +479,7 @@ namespace Tnb.WarehouseMgr
BasFactoryConfig callErp = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.CALLERP); BasFactoryConfig callErp = await _db.Queryable<BasFactoryConfig>().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.CALLERP);
if(callErp.value=="1") if(callErp.value=="1")
{ {
Thread thread = new(() => _thirdApiRecordService.Send(new List<ThirdWebapiRecord> { thirdWebapiRecord }, "自动", _db);
{
_thirdApiRecordService.Send(new List<ThirdWebapiRecord> { thirdWebapiRecord }, "自动", _db);
});
thread.Start();
} }
} }

View File

@@ -183,6 +183,7 @@ namespace Tnb.WarehouseMgr
erpRequestData.Add("vbillcode", instock.bill_code); erpRequestData.Add("vbillcode", instock.bill_code);
erpRequestData.Add("vtrantypecode", tranType?.EnCode ?? ""); erpRequestData.Add("vtrantypecode", tranType?.EnCode ?? "");
erpRequestData.Add("csourcebillhid", wmsPurchaseH?.erp_arriveorder_pk ?? ""); erpRequestData.Add("csourcebillhid", wmsPurchaseH?.erp_arriveorder_pk ?? "");
erpRequestData.Add("vdef3", wmsPurchaseH?.service_num ?? "");
List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>(); List<Dictionary<string, object>> erpRequestDataDetails = new List<Dictionary<string, object>>();
foreach (WmsInstockD item in allInstockDetails) foreach (WmsInstockD item in allInstockDetails)