生产管理,新增修改任务单接口
This commit is contained in:
@@ -8,10 +8,12 @@ using JNPF.Systems.Interfaces.System;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.BasicData.Entitys;
|
||||
using Tnb.BasicData.Entitys.Entity;
|
||||
using Tnb.ProductionMgr.Entitys.Dto;
|
||||
using Tnb.ProductionMgr.Entitys.Entity;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
@@ -90,16 +92,27 @@ namespace Tnb.ProductionMgr
|
||||
public async Task<dynamic> GetEquipmentListByMoldId(string moldId)
|
||||
{
|
||||
var items = await _repository.AsSugarClient().Queryable<EqpEquipment>()
|
||||
.InnerJoin<PrdTask>((a, b) => a.id == b.eqp_id)
|
||||
.Where((a, b) => a.mold_id == moldId)
|
||||
.Select((a, b) => new
|
||||
{
|
||||
eqp_code = a.eqp_code,
|
||||
eqp_type_code = a.eqp_type_code,
|
||||
tonnage = b.tonnage,
|
||||
task_list_qty = SqlFunc.Subqueryable<PrdTask>().Where(it => it.eqp_id == a.id).Count(),
|
||||
first_date = SqlFunc.Subqueryable<PrdTask>().Where(it => it.eqp_id == a.id).OrderByDesc(o => o.estimated_end_date).Select(it => it.estimated_end_date)
|
||||
}).ToListAsync();
|
||||
.Where(it => it.mold_id == moldId)
|
||||
.Select(it => new
|
||||
{
|
||||
eqp_code = it.eqp_code,
|
||||
eqp_type_code = it.eqp_type_code,
|
||||
tonnage = it.tonnage,
|
||||
task_list_qty = SqlFunc.Subqueryable<PrdTask>().Where(x => x.eqp_id == it.id).Count(),
|
||||
first_date = SqlFunc.Subqueryable<PrdTask>().Where(x => x.eqp_id == it.id).OrderByDesc(o => o.estimated_end_date).Select(x => x.estimated_end_date)
|
||||
})
|
||||
.ToListAsync();
|
||||
//var items = await _repository.AsSugarClient().Queryable<EqpEquipment>()
|
||||
// .InnerJoin<PrdTask>((a, b) => a.id == b.eqp_id)
|
||||
// .Where((a, b) => a.mold_id == moldId)
|
||||
// .Select((a, b) => new
|
||||
// {
|
||||
// eqp_code = a.eqp_code,
|
||||
// eqp_type_code = a.eqp_type_code,
|
||||
// tonnage = b.tonnage,
|
||||
// task_list_qty = SqlFunc.Subqueryable<PrdTask>().Where(it => it.eqp_id == a.id).Count(),
|
||||
// first_date = SqlFunc.Subqueryable<PrdTask>().Where(it => it.eqp_id == a.id).OrderByDesc(o => o.estimated_end_date).Select(it => it.estimated_end_date)
|
||||
// }).ToListAsync();
|
||||
return items;
|
||||
|
||||
}
|
||||
@@ -441,25 +454,37 @@ namespace Tnb.ProductionMgr
|
||||
/// <summary>
|
||||
/// 生产任务单修改
|
||||
/// </summary>
|
||||
/// <param name="input">生产任务单修改输入参数</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> ICMOModify()
|
||||
public async Task<dynamic> IcmoModify(IcmoUpInput input)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 工单调整-转移机台
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic?> TransferPlatform(TransferPlatformUpInput input)
|
||||
{
|
||||
return await _repository.AsSugarClient().Updateable<PrdTask>()
|
||||
.SetColumns(it => new PrdTask { eqp_id = input.eqp_id })
|
||||
.Where(it => it.id == input.icmo_id)
|
||||
.ExecuteCommandHasChangeAsync();
|
||||
var row = -1;
|
||||
var db = _repository.AsSugarClient();
|
||||
var icmoItem = await db.Queryable<PrdTask>().FirstAsync(it => it.id == input.icmo_id);
|
||||
switch (input.category)
|
||||
{
|
||||
case 1: //设备
|
||||
var eqpItem = await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.eqp_id);
|
||||
icmoItem.eqp_id = eqpItem.id;
|
||||
icmoItem.eqp_type_code = eqpItem.eqp_type_code;
|
||||
if (input.scheduled_qty > icmoItem.plan_qty)
|
||||
{
|
||||
throw new AppFriendlyException("任务单数量不能大于计划数量", 500);
|
||||
}
|
||||
row = await db.Updateable<PrdMo>().SetColumns(it => new PrdMo { input_qty = input.scheduled_qty }).Where(it => it.id == input.mo_id).ExecuteCommandAsync();
|
||||
break;
|
||||
case 2: //模具
|
||||
var moldItem = await db.Queryable<Molds>().FirstAsync(it => it.id == input.mold_id);
|
||||
icmoItem.mold_id = moldItem.id;
|
||||
icmoItem.mold_code = moldItem.mold_code;
|
||||
icmoItem.mold_name = moldItem.mold_name;
|
||||
icmoItem.mold_cavity_qty = moldItem.cavity_qty;
|
||||
break;
|
||||
}
|
||||
row = await db.Updateable(icmoItem).WhereColumns(it => new { input.icmo_id }).ExecuteCommandAsync();
|
||||
return (row > 0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -13,7 +13,7 @@ using JNPF.Systems.Entitys.System;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.ProductionMgr.Entitys.Entity;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user