调整生产管理代吗
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.新文件夹
|
||||
{
|
||||
public class DictionaryConstants
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产任务状态TypeId
|
||||
/// </summary>
|
||||
public const string PrdTaskStatusTypeId = "25572555259157";
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 工单状态
|
||||
/// </summary>
|
||||
public class MoStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// 已排产
|
||||
/// </summary>
|
||||
public const string AlreadyId = "25019252113685";
|
||||
/// <summary>
|
||||
/// 待排产
|
||||
/// </summary>
|
||||
public const string WaitProductId = "25019244276501";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tnb.ProductionMgr.Entitys.Entity;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entitys.Dto.PrdManage
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产任务重新排序输出参数
|
||||
/// </summary>
|
||||
public class PrdTaskSortOutput : PrdTask
|
||||
{
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
public int no { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -171,14 +171,14 @@ namespace Tnb.ProductionMgr.Entitys.Dto.WorkOrder
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? mold_cavity_num { get; set; }
|
||||
public int? mold_cavity_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划生产数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? plan_num { get; set; }
|
||||
public int? plan_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:吨位
|
||||
@@ -189,7 +189,7 @@ namespace Tnb.ProductionMgr.Entitys.Dto.WorkOrder
|
||||
/// <summary>
|
||||
/// 已排产数量
|
||||
/// </summary>
|
||||
public int scheduled_num { get; set; }
|
||||
public int scheduled_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 设备型号
|
||||
/// </summary>
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Tnb.ProductionMgr.Entitys.Entity
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? maintain_num { get; set; }
|
||||
public int? maintain_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:日定额
|
||||
@@ -64,7 +64,7 @@ namespace Tnb.ProductionMgr.Entitys.Entity
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? cavity_num { get; set; }
|
||||
public int? cavity_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具寿命
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Tnb.ProductionMgr.Entitys.Entity
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? input_qty { get; set; }
|
||||
public int input_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:已完工数量
|
||||
|
||||
@@ -99,21 +99,21 @@ namespace Tnb.ProductionMgr.Entitys.Entity
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? mold_cavity_num { get; set; }
|
||||
public int? mold_cavity_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划生产数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? plan_num { get; set; }
|
||||
public int? plan_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:完成数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? comple_num { get; set; }
|
||||
public int? comple_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:吨位
|
||||
@@ -127,7 +127,7 @@ namespace Tnb.ProductionMgr.Entitys.Entity
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? scheduled_num { get; set; }
|
||||
public int scheduled_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工单Id
|
||||
@@ -135,14 +135,24 @@ namespace Tnb.ProductionMgr.Entitys.Entity
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单数(生产任务数)
|
||||
/// </summary>
|
||||
public int mo_qty{ get; set; }
|
||||
/// <summary>
|
||||
/// Desc:模具Id
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mold_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模具编号
|
||||
/// </summary>
|
||||
public string mold_code { get; set; }
|
||||
/// <summary>
|
||||
/// 模具名称
|
||||
/// </summary>
|
||||
public string mold_name { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:设备Id
|
||||
/// Default:NULL::character varying
|
||||
@@ -172,6 +182,10 @@ namespace Tnb.ProductionMgr.Entitys.Entity
|
||||
/// </summary>
|
||||
public string item_code { get; set; }
|
||||
/// <summary>
|
||||
/// 产品名称
|
||||
/// </summary>
|
||||
public string item_name { get; set; }
|
||||
/// <summary>
|
||||
/// 产品规格型号
|
||||
/// </summary>
|
||||
public string item_standard { get; set; }
|
||||
@@ -214,6 +228,10 @@ namespace Tnb.ProductionMgr.Entitys.Entity
|
||||
/// 生产任务ID
|
||||
/// </summary>
|
||||
public string prd_task_id { get; set; }
|
||||
/// <summary>
|
||||
/// 同组标识
|
||||
/// </summary>
|
||||
public string group_flag { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ using SqlSugar;
|
||||
using Tnb.ProductionMgr.Entitys.Dto.PrdManage;
|
||||
using Tnb.ProductionMgr.Entitys.Dto.WorkOrder;
|
||||
using Tnb.ProductionMgr.Entitys.Entity;
|
||||
using Tnb.ProductionMgr.Entitys.新文件夹;
|
||||
using Tnb.ProductionPlanMgr.Entitys.Dto.WorkOrder;
|
||||
using Tnb.ProductionPlanMgr.Interfaces;
|
||||
|
||||
@@ -132,11 +133,12 @@ namespace Tnb.ProductionPlanMgr
|
||||
entity.status = "ToBeScheduled"; //任务单状态默认,待排产
|
||||
entity.create_id = _userManager.UserId;
|
||||
entity.create_time = DateTime.Now;
|
||||
|
||||
entity.prd_task_id = input.id;
|
||||
var db = _repository.AsSugarClient();
|
||||
try
|
||||
{
|
||||
await db.Ado.BeginTranAsync();
|
||||
|
||||
|
||||
row = await db.Storageable(entity).ExecuteCommandAsync();
|
||||
var taskLogEntity = input.Adapt<PrdTaskLog>();
|
||||
@@ -156,17 +158,17 @@ namespace Tnb.ProductionPlanMgr
|
||||
if (row > 0)
|
||||
{
|
||||
var obj = (await db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id));
|
||||
obj.input_qty += entity.scheduled_num;
|
||||
obj.input_qty += entity.scheduled_qty;
|
||||
var moStatus = "";
|
||||
//判断,已排产数量>=计划数量时将状态改为 已排产
|
||||
if (obj.input_qty >= obj.plan_qty)
|
||||
{
|
||||
moStatus = "25019252113685";
|
||||
moStatus = MoStatus.AlreadyId;
|
||||
}
|
||||
else
|
||||
{
|
||||
//修改工单状态为待排产,同事修改已排产数量
|
||||
moStatus = "25019244276501";
|
||||
moStatus = MoStatus.WaitProductId;
|
||||
}
|
||||
row = await db.Updateable<PrdMo>().SetColumns(it => new PrdMo
|
||||
{
|
||||
@@ -197,7 +199,7 @@ namespace Tnb.ProductionPlanMgr
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
var db = _repository.AsSugarClient(); ;
|
||||
var db = _repository.AsSugarClient();
|
||||
var row = await db.Updateable<PrdTask>()
|
||||
.SetColumns(it => new PrdTask { status = "ToBeStarted" })
|
||||
.Where(it => input.TaskIds.Contains(it.id))
|
||||
@@ -205,9 +207,6 @@ namespace Tnb.ProductionPlanMgr
|
||||
return (row > 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据产品ID获取模具列表
|
||||
/// </summary>
|
||||
@@ -221,7 +220,7 @@ namespace Tnb.ProductionPlanMgr
|
||||
/// <br/> mold_name:模具名称
|
||||
/// <br/> item_name:产品名称
|
||||
/// <br/> item_code:产品编号
|
||||
/// <br/> cavity_num:模穴数
|
||||
/// <br/> cavity_qty:模穴数
|
||||
/// <br/> }
|
||||
/// <br/>]
|
||||
/// </remarks>
|
||||
@@ -238,12 +237,63 @@ namespace Tnb.ProductionPlanMgr
|
||||
mold_name = a.mold_name,
|
||||
item_name = b.item_name,
|
||||
item_code = b.item_code,
|
||||
cavity_num = a.cavity_num,
|
||||
cavity_qty = a.cavity_qty,
|
||||
})
|
||||
.ToListAsync();
|
||||
return list;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 工单调整-生产任务重新排序
|
||||
/// </summary>
|
||||
/// <param name="eqpId">设备ID</param>
|
||||
/// <returns>排序后生产任务列表</returns>
|
||||
/// <remarks>
|
||||
/// returns:
|
||||
/// <br/>[
|
||||
/// <br/> {
|
||||
/// <br/> no:生产序号
|
||||
/// <br/> mo_id:工单编号
|
||||
/// <br/> group_flag:同组标识
|
||||
/// <br/> plan_qty:计划生产数量
|
||||
/// <br/> comple_qty:完成数量
|
||||
/// <br/> item_name:产品名称
|
||||
/// <br/> mold_code:模具编号
|
||||
/// <br/> }
|
||||
/// <br/>]
|
||||
/// </remarks>
|
||||
[HttpGet("sort/{eqpId}")]
|
||||
public async Task<dynamic> PrdTaskSort(string eqpId)
|
||||
{
|
||||
var taskStatusDic = await _dictionaryDataService.GetDicByTypeId(DictionaryConstants.PrdTaskStatusTypeId);
|
||||
var list = await _repository.AsSugarClient().Queryable<PrdTask>()
|
||||
.Where(it => it.eqp_id == eqpId)
|
||||
.OrderBy(o => o.estimated_start_date)
|
||||
.ToListAsync();
|
||||
var data = list.Select((x, idx) => new PrdTaskSortOutput
|
||||
{
|
||||
no = idx + 1,
|
||||
mo_id = x.mo_id,
|
||||
status = taskStatusDic.ContainsKey(x.status) ? taskStatusDic[x.status].ToString() : "",
|
||||
group_flag = x.group_flag,
|
||||
plan_qty = x.plan_qty,
|
||||
comple_qty = x.comple_qty,
|
||||
item_name = x.item_name,
|
||||
mold_code = x.mold_code,
|
||||
}).ToList();
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
/// 工单调整-转移机台
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("tran-platform")]
|
||||
public async Task<dynamic?> TransferPlatform()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查看工单操作记录
|
||||
/// </summary>
|
||||
@@ -252,17 +302,9 @@ namespace Tnb.ProductionPlanMgr
|
||||
[HttpGet("record/{taskId}")]
|
||||
public async Task<dynamic> GetMoOperRecord(string taskId)
|
||||
{
|
||||
//var list = await _repository.AsSugarClient().Queryable<PrdTask>().LeftJoin<PrdTaskLog>((a, b) => a.prd_task_id == b.id)
|
||||
// .WhereIF(!string.IsNullOrWhiteSpace(input.mo_no),b=>b.id == input.task_no)
|
||||
// .WhereIF(!string.IsNullOrWhiteSpace(input.task_no), b => b.prd_task_id == input.task_id)
|
||||
// .WhereIF(!string.IsNullOrWhiteSpace(input.item_code), a => a.item_code == input.item_code)
|
||||
// .WhereIF(!string.IsNullOrWhiteSpace(input.eqp_code), a => a.eqp_type_code == input.eqp_code)
|
||||
// .WhereIF(input.plan_start_date.HasValue, a => a.plan_start_date >= input.plan_start_date!.Value)
|
||||
// .WhereIF(input.plan_end_date.HasValue, a => a.plan_end_date <= input.plan_end_date!.Value)
|
||||
// .ToListAsync();
|
||||
var list = await _repository.AsSugarClient().Queryable<PrdTaskLog>().Where(it => it.id == taskId).ToListAsync();
|
||||
var data = list.Adapt<List<PrdTaskOperOutput>>();
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId("25572555259157");
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictionaryConstants.PrdTaskStatusTypeId);
|
||||
_repository.AsSugarClient().ThenMapper(data, x => x.statusName = dic.ContainsKey(x.status) ? dic[x.status].ToString() : "");
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ WHERE pcolumn.table_name='{0}' ORDER BY ordinal_position";
|
||||
{
|
||||
if (link != null && _sqlSugarClient.CurrentConnectionConfig.ConfigId != link.Id) _sqlSugarClient = ChangeDataBase(link);
|
||||
|
||||
return _sqlSugarClient.DbMaintenance.GetPrimaries(tableName);
|
||||
return _sqlSugarClient.CopyNew().DbMaintenance.GetPrimaries(tableName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -318,7 +318,7 @@ public class DbLinkService : IDbLinkService, IDynamicApiController, ITransient
|
||||
[NonAction]
|
||||
public async Task<DbLinkEntity> GetInfo(string id)
|
||||
{
|
||||
return await _repository.AsSugarClient().Queryable<DbLinkEntity>().FirstAsync(m => m.Id == id && m.DeleteMark == null);
|
||||
return await _repository.AsSugarClient().CopyNew().Queryable<DbLinkEntity>().FirstAsync(m => m.Id == id && m.DeleteMark == null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user