调wms接口返回成功后再操作数据库

This commit is contained in:
2023-07-20 14:06:35 +08:00
parent 716c1f5d14
commit 818e259205
8 changed files with 177 additions and 29 deletions

View File

@@ -43,6 +43,9 @@ using Microsoft.ClearScript.Util.Web;
using Newtonsoft.Json;
using Tnb.BasicData.Entities.Dto;
using NPOI.SS.Formula.Functions;
using Tnb.PerMgr.Entities;
// using Tnb.PerMgr.Entities;
namespace Tnb.ProductionMgr
{
@@ -1711,5 +1714,39 @@ namespace Tnb.ProductionMgr
{
return await _db.Queryable<PrdMoTask>().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync();
}
[HttpPost]
public async Task<dynamic> GetEstimatedEndTime(CountEstimatedEndTimeInput input)
{
var db = _repository.AsSugarClient();
if (input.type == 1)
{
PerProcessStandardsH processStandardsH = await db.Queryable<PerProcessStandardsH>()
.Where(x => x.equip_id == input.equip_id && x.molds_id == input.molds_id &&
x.output_material_id == input.material_id && x.enabled == 1)
.OrderByDescending(x => x.create_time).FirstAsync();
ToolMolds toolMolds = await db.Queryable<ToolMolds>().SingleAsync(x => x.id == input.molds_id);
if(toolMolds==null) throw Oops.Bah("没找到模具");
if(toolMolds?.mold_cavity<=0) throw Oops.Bah("模穴数错误");
if (processStandardsH == null) throw Oops.Bah("工艺标准成型周期错误");
if (processStandardsH?.moulding_cycle <= 0) throw Oops.Bah("工艺标准成型周期错误");
decimal? addTime = (input.scheduled_qty * toolMolds.mold_cavity - 1) / processStandardsH?.moulding_cycle + 1;
return input.estimated_start_date.AddSeconds((double)addTime.Value).ToString("yyyy-MM-dd HH:mm:ss");
}
else
{
var list = await db.Queryable<BasMbomProcess>()
.LeftJoin<BasStandardTime>((a,b)=>a.process_id==b.process_id)
.Where((a,b)=>a.mbom_id==input.mbom_id).Select((a,b)=>b).ToListAsync();
decimal max = list.Select(x => Convert.ToDecimal(x.standard_time)).Max(x => x);
decimal? addTime = input.scheduled_qty * max;
return input.estimated_start_date.AddSeconds((double)addTime.Value).ToString("yyyy-MM-dd HH:mm:ss");
}
}
}
}