diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs
new file mode 100644
index 00000000..e419ce92
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.DirectoryServices.Protocols;
+using System.Linq;
+using System.Security.Principal;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
+{
+ public class PrdMoTaskOutput
+ {
+ ///
+ /// 生产任务单号
+ ///
+ public string mo_task_code { get; set; }
+ ///
+ /// 任务单状态
+ ///
+ public string mo_task_status { get; set; }
+ ///
+ /// 物料编号
+ ///
+ public string material_code { get; set; }
+ ///
+ /// 物料名称
+ ///
+ public string material_name { get; set; }
+ ///
+ /// 模具编码
+ ///
+ public string mold_code { get; set; }
+ ///
+ /// 模具名称
+ ///
+ public string mold_name { get; set; }
+ ///
+ /// 设备编码
+ ///
+ public string eqp_code { get; set; }
+ ///
+ /// 设备名称
+ ///
+ public string eqp_name { get; set; }
+ ///
+ /// 设备型号
+ ///
+ public string eqp_type_code { get; set; }
+ ///
+ /// 任务单数量
+ ///
+ public int mo_task_qty { get; set; }
+ ///
+ /// 完成数量
+ ///
+ public int complete_qty { get; set; }
+ ///
+ /// 计划生产数量
+ ///
+ public int plan_qty { get; set; }
+ public int scheduled_qty { get; set; }
+ ///
+ /// 预计开工时间
+ ///
+ public DateTime estimated_start_date { get; set; }
+ ///
+ /// 预计完工时间
+ ///
+ public DateTime estimated_end_date { get; set; }
+
+
+ }
+}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskSortOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskSortOutput.cs
index d6a0fd2b..0805c22e 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskSortOutput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdTaskSortOutput.cs
@@ -10,11 +10,41 @@ namespace Tnb.ProductionMgr.Entities.Dto
///
/// 生产任务重新排序输出参数
///
- public class PrdTaskSortOutput : PrdTask
+ public class PrdTaskSortOutput
{
///
/// 序号
///
public int no { get; set; }
+ ///
+ /// 生产任务编号
+ ///
+ public string mo_status_code { get; set; }
+ ///
+ /// 生产任务状态
+ /// 生产任务状态
+ ///
+ public string status { get; set;}
+ ///
+ /// 是否同组标识
+ ///
+ public int group_flag { get; set; }
+ ///
+ /// 计划生产量
+ ///
+ public int plan_qty { get; set; }
+ ///
+ /// 已完工数量
+ ///
+ public int comple_qty { get; set; }
+ ///
+ /// 产品名称
+ ///
+ public string item_name { get; set; }
+ ///
+ /// 模具编码
+ ///
+ public string mold_code { get; set; }
+
}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ProductionSchedulingCrInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ProductionSchedulingCrInput.cs
index 5c43f44b..1af7cedc 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ProductionSchedulingCrInput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ProductionSchedulingCrInput.cs
@@ -37,19 +37,19 @@ namespace Tnb.ProductionMgr.Entities.Dto
///
public DateTime? plan_end_date { get; set; }
- /////
- ///// Desc:预计开始时间
- ///// Default:
- ///// Nullable:True
- /////
- //public DateTime? estimated_start_date { get; set; }
+ ///
+ /// Desc:预计开始时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? estimated_start_date { get; set; }
- /////
- ///// Desc:预计结束时间
- ///// Default:
- ///// Nullable:True
- /////
- //public DateTime? estimated_end_date { get; set; }
+ ///
+ /// Desc:预计结束时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? estimated_end_date { get; set; }
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/Molds.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/Molds.cs
index 923f7cc9..8ec40565 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/Molds.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/Molds.cs
@@ -64,7 +64,7 @@ namespace Tnb.ProductionMgr.Entities
/// Default:
/// Nullable:True
///
- public int? cavity_qty { get; set; }
+ public int cavity_qty { get; set; }
///
/// Desc:模具寿命
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs
index 98d1f3b9..aa61f547 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs
@@ -49,14 +49,14 @@ namespace Tnb.ProductionMgr.Entities
/// Default:
/// Nullable:False
///
- public decimal plan_qty {get;set;}
+ public int plan_qty {get;set;}
///
/// Desc:已投入数量
/// Default:
/// Nullable:True
///
- public decimal? input_qty {get;set;}
+ public int input_qty {get;set;}
///
/// Desc:已完工数量
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs
index f848f220..c9b236bd 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs
@@ -11,193 +11,225 @@ namespace DbModels
[SugarTable("prd_mo_task")]
public partial class PrdMoTask
{
- public PrdMoTask(){
+ public PrdMoTask()
+ {
- }
- ///
- /// Desc:排产类型:1、注塑、挤出2、组装、包装
- /// Default:
- /// Nullable:True
- ///
- public int? schedule_type {get;set;}
+ }
+ ///
+ /// Desc:排产类型:1、注塑、挤出2、组装、包装
+ /// Default:
+ /// Nullable:True
+ ///
+ public int? schedule_type { get; set; }
- ///
- /// Desc:计划开始时间
- /// Default:
- /// Nullable:True
- ///
- public DateTime? plan_start_date {get;set;}
+ ///
+ /// Desc:计划开始时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? plan_start_date { get; set; }
- ///
- /// Desc:计划结束时间
- /// Default:
- /// Nullable:True
- ///
- public DateTime? plan_end_date {get;set;}
+ ///
+ /// Desc:计划结束时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? plan_end_date { get; set; }
- ///
- /// Desc:实际开工日期
- /// Default:
- /// Nullable:True
- ///
- public DateTime? act_start_date {get;set;}
+ ///
+ /// Desc:实际开工日期
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? act_start_date { get; set; }
- ///
- /// Desc:实际完工日期
- /// Default:
- /// Nullable:True
- ///
- public DateTime? act_end_date {get;set;}
+ ///
+ /// Desc:实际完工日期
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? act_end_date { get; set; }
- ///
- /// Desc:创建人
- /// Default:
- /// Nullable:True
- ///
- public string create_id {get;set;}
+ ///
+ /// Desc:创建人
+ /// Default:
+ /// Nullable:True
+ ///
+ public string create_id { get; set; }
- ///
- /// Desc:创建时间
- /// Default:
- /// Nullable:True
- ///
- public DateTime? create_time {get;set;}
+ ///
+ /// Desc:创建时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? create_time { get; set; }
- ///
- /// Desc:修改人
- /// Default:
- /// Nullable:True
- ///
- public string modify_id {get;set;}
+ ///
+ /// Desc:修改人
+ /// Default:
+ /// Nullable:True
+ ///
+ public string modify_id { get; set; }
- ///
- /// Desc:修改时间
- /// Default:
- /// Nullable:True
- ///
- public DateTime? modify_time {get;set;}
+ ///
+ /// Desc:修改时间
+ /// Default:
+ /// Nullable:True
+ ///
+ public DateTime? modify_time { get; set; }
- ///
- /// Desc:扩展字段
- /// Default:
- /// Nullable:True
- ///
- public string extras {get;set;}
+ ///
+ /// Desc:扩展字段
+ /// Default:
+ /// Nullable:True
+ ///
+ public string extras { get; set; }
- ///
- /// Desc:编号
- /// Default:
- /// Nullable:False
- ///
- [SugarColumn(IsPrimaryKey=true)]
- public string id {get;set;}
+ ///
+ /// Desc:编号
+ /// Default:
+ /// Nullable:False
+ ///
+ [SugarColumn(IsPrimaryKey = true)]
+ public string id { get; set; }
- ///
- /// Desc:生产任务编号
- /// Default:
- /// Nullable:True
- ///
- public string mo_task_code {get;set;}
+ ///
+ /// Desc:生产任务编号
+ /// Default:
+ /// Nullable:True
+ ///
+ public string mo_task_code { get; set; }
- ///
- /// Desc:工单Id
- /// Default:NULL::character varying
- /// Nullable:True
- ///
- public string mo_id {get;set;}
+ ///
+ /// Desc:工单Id
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string mo_id { get; set; }
- ///
- /// Desc:物料Id
- /// Default:NULL::character varying
- /// Nullable:True
- ///
- public string material_id {get;set;}
+ ///
+ /// Desc:物料Id
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string material_id { get; set; }
- ///
- /// Desc:模具Id
- /// Default:NULL::character varying
- /// Nullable:True
- ///
- public string mold_id {get;set;}
+ ///
+ /// Desc:模具Id
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string mold_id { get; set; }
- ///
- /// Desc:设备Id
- /// Default:NULL::character varying
- /// Nullable:True
- ///
- public string eqp_id {get;set;}
+ ///
+ /// Desc:设备Id
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string eqp_id { get; set; }
- ///
- /// Desc:产线id
- /// Default:NULL::character varying
- /// Nullable:True
- ///
- public string workline_id {get;set;}
+ ///
+ /// Desc:产线id
+ /// Default:NULL::character varying
+ /// Nullable:True
+ ///
+ public string workline_id { get; set; }
- ///
- /// Desc:工位id
- /// Default:
- /// Nullable:True
- ///
- public string workstation_id {get;set;}
+ ///
+ /// Desc:工位id
+ /// Default:
+ /// Nullable:True
+ ///
+ public string workstation_id { get; set; }
- ///
- /// Desc:工艺路线id
- /// Default:
- /// Nullable:True
- ///
- public string workroute_id {get;set;}
+ ///
+ /// Desc:工艺路线id
+ /// Default:
+ /// Nullable:True
+ ///
+ public string workroute_id { get; set; }
- ///
- /// Desc:生产bom id
- /// Default:
- /// Nullable:True
- ///
- public string bom_id {get;set;}
+ ///
+ /// Desc:生产bom id
+ /// Default:
+ /// Nullable:True
+ ///
+ public string bom_id { get; set; }
- ///
- /// Desc:任务单状态
- /// Default:
- /// Nullable:True
- ///
- public string mo_task_status {get;set;}
+ ///
+ /// Desc:任务单状态
+ /// Default:
+ /// Nullable:True
+ ///
+ public string mo_task_status { get; set; }
- ///
- /// Desc:计划数量
- /// Default:
- /// Nullable:True
- ///
- public int plan_qty {get;set;}
+ ///
+ /// Desc:计划数量
+ /// Default:
+ /// Nullable:True
+ ///
+ public int plan_qty { get; set; }
- ///
- /// Desc:已投入数量
- /// Default:
- /// Nullable:True
- ///
- public int input_qty {get;set;}
+ ///
+ /// Desc:已投入数量
+ /// Default:
+ /// Nullable:True
+ ///
+ public int input_qty { get; set; }
- ///
- /// Desc:已完工数量
- /// Default:
- /// Nullable:True
- ///
- public decimal? complete_qty {get;set;}
+ ///
+ /// Desc:已完工数量
+ /// Default:
+ /// Nullable:True
+ ///
+ public int complete_qty { get; set; }
- ///
- /// Desc:报废数量
- /// Default:
- /// Nullable:True
- ///
- public int scrap_qty {get;set;}
+ ///
+ /// Desc:报废数量
+ /// Default:
+ /// Nullable:True
+ ///
+ public int scrap_qty { get; set; }
+
+ ///
+ /// Desc:已排产数量
+ /// Default:
+ /// Nullable:True
+ ///
+ public int scheduled_qty { get; set; }
+ ///
+ /// 预计开工时间
+ ///
+ public DateTime estimated_start_date { get; set; }
+ ///
+ /// 预计完工时间
+ ///
+ public DateTime estimated_end_date { get; set; }
+ ///
+ /// 是否同组标识
+ ///
+ public int group_flag { get; set; }
+ ///
+ /// 设备编码
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string eqp_type_code { get; set; }
+ ///
+ /// 模具编码
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string mold_code { get; set; }
+
+ [SugarColumn(IsIgnore = true)]
+ public string mold_name { get; set; }
+ ///
+ ///模穴数
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public int mold_cavity_qty { get; set; }
- ///
- /// Desc:已排产数量
- /// Default:
- /// Nullable:True
- ///
- public int scheduled_qty {get;set;}
}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdTaskLog.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdTaskLog.cs
index 3b49a401..accca185 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdTaskLog.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdTaskLog.cs
@@ -102,7 +102,7 @@ namespace Tnb.ProductionMgr.Entities
///
/// 生产任务ID
///
- public string task_id { get;set;}
+ public string mo_task_id { get;set;}
}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Mapper/Mapper.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Mapper/Mapper.cs
index 8b8a1671..e178d8ac 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Mapper/Mapper.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Mapper/Mapper.cs
@@ -9,7 +9,7 @@ namespace Tnb.ProductionMgr.Entities.Mapper
public void Register(TypeAdapterConfig config)
{
config.ForType()
- .Map(dest => dest.task_id, src => src.prd_task_id);
+ .Map(dest => dest.mo_task_id, src => src.prd_task_id);
}
}
}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index 4e3657b8..7baab894 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -31,6 +31,7 @@ using JNPF.VisualDev.Interfaces;
using JNPF.VisualDev.Entitys;
using Aop.Api.Domain;
using Senparc.Weixin.MP.AdvancedAPIs.Card;
+using Aspose.Cells.Drawing.Texts;
namespace Tnb.ProductionMgr
{
@@ -47,6 +48,7 @@ namespace Tnb.ProductionMgr
private readonly IRunService _runService;
private readonly IVisualDevService _visualDevService;
private static Dictionary _dicDefect = new Dictionary();
+ private readonly ISqlSugarClient _db;
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
@@ -63,6 +65,7 @@ namespace Tnb.ProductionMgr
_dictionaryDataService = dictionaryDataService;
_runService = runService;
_visualDevService = visualDevService;
+ _db = _repository.AsSugarClient();
OverideFuncs.DeleteAsync = Delete;
OverideFuncs.GetListAsync = GetList;
@@ -162,14 +165,27 @@ namespace Tnb.ProductionMgr
public async Task PrdTaskSort(string eqpId)
{
var taskStatusDic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
- var list = await _repository.AsSugarClient().Queryable()
- .Where(it => it.eqp_id == eqpId)
- .OrderBy(o => o.estimated_start_date)
+ var list = await _repository.AsSugarClient().Queryable()
+ .LeftJoin((a, b) => a.mo_id == b.id)
+ .LeftJoin((a, b, c) => a.material_id == c.id)
+ .LeftJoin((a, b, c, d) => a.mold_id == d.id)
+ .Where((a, b, c, d) => a.eqp_id == eqpId)
+ .OrderBy((a, b, c, d) => a.estimated_start_date)
+ .Select((a, b, c, d) => new PrdTaskSortOutput
+ {
+ mo_status_code = a.mo_task_code,
+ status = a.mo_task_status,
+ group_flag = a.group_flag,
+ plan_qty = b.plan_qty,
+ comple_qty = a.complete_qty,
+ item_name = c.name,
+ mold_code = d.mold_code,
+ })
.ToListAsync();
var data = list.Select((x, idx) => new PrdTaskSortOutput
{
no = idx + 1,
- mo_id = x.mo_id,
+ mo_status_code = x.mo_status_code,
status = taskStatusDic.ContainsKey(x.status) ? taskStatusDic[x.status].ToString() : "",
group_flag = x.group_flag,
plan_qty = x.plan_qty,
@@ -188,7 +204,7 @@ namespace Tnb.ProductionMgr
[HttpGet("{taskId}")]
public async Task GetMoOperRecord(string taskId)
{
- var list = await _repository.AsSugarClient().Queryable().Where(it => it.id == taskId).ToListAsync();
+ var list = await _repository.AsSugarClient().Queryable().Where(it => it.mo_task_id == taskId).ToListAsync();
var data = list.Adapt>();
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
_repository.AsSugarClient().ThenMapper(data, x => x.statusName = dic.ContainsKey(x.status) ? dic[x.status].ToString() : "");
@@ -284,7 +300,7 @@ namespace Tnb.ProductionMgr
{
scrap_qty = t.Sum(d => d.defective_item_qty),
batch = t.Key.batch,
- create_time =t.Key.batch.ParseToDateTime().ToString("yyyy-MM-dd HH:mm:ss"),
+ create_time = t.Key.batch.ParseToDateTime().ToString("yyyy-MM-dd HH:mm:ss"),
categoryItems = t.GroupBy(g => g.defective_cagetory_id).Select(c => new CategoryItem
{
name = _dicDefect[c.Key]?.ToString(),
@@ -299,6 +315,65 @@ namespace Tnb.ProductionMgr
}
return output;
}
+ ///
+ /// 根据工单Id获取任务单列表
+ ///
+ ///
+ ///
+ /// output:
+ ///
{
+ ///
mo_task_code:生产任务单号
+ ///
material_code:物料编码
+ ///
mold_code:模具编码
+ ///
mold_name:模具名称
+ ///
eqp_code:设备编码
+ ///
eqp_name:设备名称
+ ///
eqp_type_code:设备型号
+ ///
mo_task_qty:任务单数量
+ ///
mo_task_status:任务状态
+ ///
scheduled_qty:计划生产数量
+ ///
complete_qty:完成数量
+ ///
estimated_start_date:预计开工时间
+ ///
estimated_end_date:预计完工时间
+ ///
}
+ ///
+ [HttpGet("{moId}")]
+ public async Task GetPrdTaskInfoByMoId(string moId)
+ {
+
+ var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
+ var result = await _db.Queryable().LeftJoin((a, b) => a.mo_id == b.id)
+ .LeftJoin((a, b, c) => a.material_id == c.id)
+ .LeftJoin((a, b, c, d) => a.mold_id == d.id)
+ .LeftJoin((a, b, c, d, e) => a.eqp_id == e.id)
+ .Where((a, b, c, d, e) => a.mo_id == moId)
+ .Select((a, b, c, d, e) => new PrdMoTaskOutput
+ {
+ mo_task_code = a.mo_task_code,
+ mo_task_status = a.mo_task_status,
+ mold_code = d.mold_code,
+ mold_name = d.mold_name,
+ material_code = c.code,
+ material_name = c.name,
+ eqp_code = e.code,
+ eqp_name = e.name,
+ eqp_type_code = SqlFunc.Subqueryable().Where(it => it.id == e.equip_type_id).Select(it => it.code),
+ mo_task_qty = SqlFunc.Subqueryable().Where(a => a.mo_id == moId).Count(),
+ estimated_start_date = a.estimated_start_date,
+ estimated_end_date = a.estimated_end_date,
+ plan_qty = b.plan_qty,
+ complete_qty = a.complete_qty,
+ })
+ .Mapper(it =>
+ {
+ it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString() : "";
+ })
+ .ToListAsync();
+ return result;
+
+ }
+
+
#endregion
@@ -335,6 +410,8 @@ namespace Tnb.ProductionMgr
moTask.create_id = _userManager.UserId;
moTask.create_time = DateTime.Now;
moTask.mo_task_status = DictConst.ToBeScheduledEncode;
+ moTask.scheduled_qty = input.scheduled_qty;
+
var mo = await db.Queryable().FirstAsync(it => it.id == input.mo_id);
var moCode = mo?.mo_code;
var taskCode = await db.Queryable().Where(it => !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode)).OrderByDescending(it => it.mo_task_code).Select(it => it.mo_task_code).FirstAsync();
@@ -349,7 +426,7 @@ namespace Tnb.ProductionMgr
{
var sb = new StringBuilder();
var num = taskCode.AsSpan().Slice(pos + 1).ToString().ParseToInt();
- var code = taskCode.AsSpan().Slice(pos + 1).ToString();
+ var code = taskCode.AsSpan().Slice(0, pos).ToString();
var n = (num + 1).ToString().PadLeft(2, '0');
moTask.mo_task_code = sb.Append(code).Append("-").Append(n).ToString();
}
@@ -362,16 +439,17 @@ namespace Tnb.ProductionMgr
//根据工单号获取当前工单包含的已排产数
var schedQty = db.Queryable().Where(it => it.mo_id == input.mo_id)?.Sum(d => d.scheduled_qty);
//判断如果当前 工单的已排产数大于工单计划数量则更新工单状态为 已排产
- if (schedQty >= mo.plan_qty)
+ if (mo != null && schedQty.HasValue && schedQty.Value >= mo.plan_qty)
{
mo.mo_status = DictConst.AlreadyId;
row = await db.Updateable(mo).ExecuteCommandAsync();
}
+ var material = await db.Queryable().FirstAsync(it => it.id == moTask.material_id);
//将生产任务插入到自检报废记录表
var sacipRecord = new PrdMoTaskDefectRecord();
sacipRecord.id = SnowflakeIdHelper.NextId();
- sacipRecord.material_code = (await db.Queryable().FirstAsync(it => it.id == moTask.material_id))?.code;
- sacipRecord.material_name = (await db.Queryable().FirstAsync(it => it.id == moTask.material_id))?.name;
+ sacipRecord.material_code = material?.code;
+ sacipRecord.material_name = material?.name;
sacipRecord.eqp_code = (await db.Queryable().FirstAsync(it => it.id == moTask.eqp_id))?.code;
sacipRecord.mold_name = (await db.Queryable().FirstAsync(it => it.id == moTask.mold_id))?.mold_name;
sacipRecord.estimated_start_date = moTask.plan_start_date;
@@ -384,6 +462,7 @@ namespace Tnb.ProductionMgr
sacipRecord.mo_task_id = moTask.id;
sacipRecord.mo_task_code = moTask.mo_task_code;
await db.Insertable(sacipRecord).ExecuteCommandAsync();
+
await db.Ado.CommitTranAsync();
}
catch (Exception ex)
@@ -427,9 +506,10 @@ namespace Tnb.ProductionMgr
PrdTaskBehavior behavior = input.Behavior.ToEnum();
var status = SetTaskStatus(behavior);
var db = _repository.AsSugarClient();
+ var list = await db.Queryable().Where(it => input.TaskIds.Contains(it.id)).Select(it => it).ToListAsync();
if (behavior == PrdTaskBehavior.Compled)
{
- var list = await db.Queryable().Where(it => input.TaskIds.Contains(it.id)).Select(it => it).ToListAsync();
+
if (list?.Count > 0)
{
var schedQtySum = list.Sum(x => x.scheduled_qty);
@@ -444,6 +524,55 @@ namespace Tnb.ProductionMgr
.SetColumns(it => new PrdMoTask { mo_task_status = status })
.Where(it => input.TaskIds.Contains(it.id))
.ExecuteCommandAsync();
+ //插入操作记录日志
+ List taskLogEntities = new();
+ foreach (var taskId in input.TaskIds)
+ {
+ var taskLog = await db.Queryable().FirstAsync(it => it.mo_task_id == taskId);
+ if (taskLog is null)
+ {
+ var taskItem = list?.Find(x => x.id == taskId);
+ taskLog = new PrdTaskLog();
+ taskLog.id = SnowflakeIdHelper.NextId();
+ if (taskItem != null)
+ {
+ if (taskItem.mo_id.IsNotEmptyOrNull())
+ {
+ taskLog.mo_code = (await db.Queryable().FirstAsync(it => it.id == taskItem.mo_id))?.mo_code;
+ }
+ if (taskItem.eqp_id.IsNotEmptyOrNull())
+ {
+ taskLog.eqp_code = (await db.Queryable().FirstAsync(it => it.id == taskItem.eqp_id))?.code;
+ }
+ if (taskItem.mold_id.IsNotEmptyOrNull())
+ {
+ taskLog.mold_code = (await db.Queryable().FirstAsync(it => it.id == taskItem.mold_id))?.mold_code;
+ }
+ if (taskItem.material_id.IsNotEmptyOrNull())
+ {
+ var material = await db.Queryable().FirstAsync(it => it.id == taskItem.material_id);
+ taskLog.item_code = material?.code;
+ taskLog.item_standard = material?.material_standard;
+ }
+ taskLog.operator_name = _userManager.RealName;
+ taskLog.status = status;
+ taskLog.create_id = _userManager.UserId;
+ taskLog.create_time = DateTime.Now;
+ taskLog.mo_task_id = taskItem.id;
+ }
+ taskLogEntities.Add(taskLog);
+ }
+ else
+ {
+ if (taskLog.status != status)
+ {
+ taskLog.id = SnowflakeIdHelper.NextId();
+ taskLog.status = status;
+ taskLogEntities.Add(taskLog);
+ }
+ }
+ }
+ row = await db.Insertable(taskLogEntities).ExecuteCommandAsync();
return (row > 0);
}
@@ -460,7 +589,7 @@ namespace Tnb.ProductionMgr
var db = _repository.AsSugarClient();
if (input.icmo_id.IsNullOrWhiteSpace())
throw new ArgumentNullException(nameof(input.icmo_id));
- var icmoItem = await db.Queryable().FirstAsync(it => it.id == input.icmo_id);
+ var icmoItem = await db.Queryable().FirstAsync(it => it.id == input.icmo_id);
switch (input.category)
{
case 1: //设备
@@ -489,7 +618,7 @@ namespace Tnb.ProductionMgr
}
break;
}
- row = await db.Updateable(icmoItem).ExecuteCommandAsync();
+ row = await db.Updateable(icmoItem).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
return (row > 0);
}
///
@@ -513,8 +642,8 @@ namespace Tnb.ProductionMgr
var row = -1;
var db = _repository.AsSugarClient();
var report = await db.Queryable().FirstAsync(it => it.mo_task_code == input.mo_task_code);
-
-
+
+
if (report is not null)
{
report.mo_task_code = input.mo_task_code;
@@ -535,7 +664,7 @@ namespace Tnb.ProductionMgr
var record = prdTask.Adapt();
if (prdTask != null)
{
- record.id =SnowflakeIdHelper.NextId();
+ record.id = SnowflakeIdHelper.NextId();
record.eqp_code = (await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id))?.code;
record.completed_qty = input.reported_qty;
row = await db.Insertable(record).ExecuteCommandAsync();