andon呼叫 aql 模具保养
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Joins;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells.Drawing;
|
||||
using DingTalk.Api.Request;
|
||||
using JNPF.Common.Core.Manager;
|
||||
@@ -13,7 +15,10 @@ using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
@@ -93,6 +98,68 @@ namespace Tnb.EquipMgr
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetMaintainInfo()
|
||||
{
|
||||
List<dynamic> result = new();
|
||||
var plans = await _db.Queryable<ToolMoldMaintainPlan>().ToListAsync();
|
||||
var ToolMolds = await _db.Queryable<ToolMolds>().ToListAsync();
|
||||
var ToolMoldsEquipments = await _db.Queryable<ToolMoldsEquipment>().ToListAsync();
|
||||
var EqpEquipments = await _db.Queryable<EqpEquipment>().ToListAsync();
|
||||
var dic = await _db.Queryable<DictionaryDataEntity>().Where(p => p.DictionaryTypeId == "26149299883285").ToListAsync();
|
||||
var users = await _db.Queryable<UserEntity>().ToListAsync();
|
||||
foreach (var plan in plans)
|
||||
{
|
||||
var planMoldRelations = await _db.Queryable<ToolMoldMaintainPlanRelation>()
|
||||
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)//ToolMoldMaintainPlan
|
||||
.LeftJoin<ToolMoldMaintainRunRecord>((a, b, c) => b.plan_code == c.plan_code)
|
||||
.Where(a => a.maintain_plan_id == plan.id)
|
||||
.Select((a, b, c) => new
|
||||
{
|
||||
mold_id = a.mold_id,
|
||||
plan_start_time = c.plan_start_time,
|
||||
}).ToListAsync();
|
||||
if (planMoldRelations?.Count > 0)
|
||||
{
|
||||
var mids = planMoldRelations.Select(x => x.mold_id).ToList();
|
||||
var molds = ToolMolds.Where(it => mids.Contains(it.id)).ToList();
|
||||
if (molds?.Count > 0)
|
||||
{
|
||||
List<dynamic> infos = new List<dynamic> { };
|
||||
for (int i = 0, cnt = molds.Count; i < cnt; i++)
|
||||
{
|
||||
var mold = molds[i];
|
||||
dynamic info = new ExpandoObject();
|
||||
info.mold_id = mold.id;
|
||||
info.mold_code = mold.mold_code;
|
||||
info.mold_name = mold.mold_name;
|
||||
info.mold_status = dic.Where(p => p.Id == mold.mold_status).Any() ? dic.Where(p => p.Id == mold.mold_status).First().FullName : "";
|
||||
info.maintain_qty = mold.maintain_qty;
|
||||
info.plan_start_time = planMoldRelations[i].plan_start_time == null ? "" : ((DateTime)planMoldRelations[i].plan_start_time).ToString("yyyy-MM-dd");
|
||||
info.createtime = plan.create_time == null ? "" : ((DateTime)plan.create_time).ToString("yyyy-MM-dd");
|
||||
info.status = plan.status == "UnMaintain" ? "待保养" : "已完成";
|
||||
info.createuser = string.IsNullOrEmpty(plan.create_id) ? "" : users.Where(p => p.Id == plan.create_id).First().RealName;
|
||||
info.plan_id = plan.id;
|
||||
var moldEqpRelation = ToolMoldsEquipments.Where(it => it.mold_id == mold.id).FirstOrDefault();
|
||||
if (moldEqpRelation != null)
|
||||
{
|
||||
var eqp = EqpEquipments.Where(it => it.id == moldEqpRelation.equipment_id).FirstOrDefault();
|
||||
if (eqp != null)
|
||||
{
|
||||
info.eqp_code = eqp.code;
|
||||
info.eqp_name = eqp.name;
|
||||
}
|
||||
}
|
||||
result.Add(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据计划Id、模具ID获取,保养组及项目信息
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class AndonRecordInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 关联工单
|
||||
/// </summary>
|
||||
public string? mo_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 故障
|
||||
/// </summary>
|
||||
public string? breakdown { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities
|
||||
{
|
||||
[SugarTable("andon_breakdown")]
|
||||
public partial class AndonBreakDown : BaseEntity<string>
|
||||
{
|
||||
public AndonBreakDown()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
public string? name { get; set; }
|
||||
public string? code { get; set; }
|
||||
public string? description { get; set; }
|
||||
|
||||
public string? type_id { get; set; }
|
||||
public string? remark { get; set; }
|
||||
public string? create_id { get; set; }
|
||||
public DateTime? create_time { get; set; }
|
||||
public string? modify_id { get; set; }
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities
|
||||
{
|
||||
[SugarTable("andon_records")]
|
||||
public partial class AndonRecords : BaseEntity<string>
|
||||
{
|
||||
public AndonRecords()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 关联工单
|
||||
/// </summary>
|
||||
public string? mo_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 故障类别
|
||||
/// </summary>
|
||||
public string? breakdown_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 故障
|
||||
/// </summary>
|
||||
public string? breakdown { get; set; }
|
||||
|
||||
public string? create_id { get; set; }
|
||||
public DateTime? create_time { get; set; }
|
||||
public string? modify_id { get; set; }
|
||||
public DateTime? modify_time { get; set; }
|
||||
public string? remark { get; set; }
|
||||
}
|
||||
}
|
||||
16
ProductionMgr/Tnb.ProductionMgr.Interfaces/IAndonService.cs
Normal file
16
ProductionMgr/Tnb.ProductionMgr.Interfaces/IAndonService.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||
|
||||
namespace Tnb.ProductionMgr.Interfaces
|
||||
{
|
||||
public interface IAndonService
|
||||
{
|
||||
public Task<dynamic> GetPrdTask(string stationId);
|
||||
|
||||
public Task SaveData(AndonRecordInput AndonRecordInput);
|
||||
}
|
||||
}
|
||||
86
ProductionMgr/Tnb.ProductionMgr/AndonService.cs
Normal file
86
ProductionMgr/Tnb.ProductionMgr/AndonService.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reactive.Joins;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Message.Service;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.TaskScheduler;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||
using Tnb.ProductionMgr.Entities.Entity;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class AndonService : IAndonService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IUserManager _userManager;
|
||||
public AndonService(ISqlSugarRepository<AndonRecords> repository,IUserManager userManager)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_db = repository.AsSugarClient();
|
||||
}
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetPrdTask(string stationId)
|
||||
{
|
||||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||||
dic.Add("ToBeStarted", "待开工");
|
||||
dic.Add("InProgress", "进行中");
|
||||
dic.Add("Closed", "关闭");
|
||||
dic.Add("Complated", "完工");
|
||||
dic.Add("ToBeScheduled", "待下发");
|
||||
dic.Add("Pause", "暂停");
|
||||
dic.Add("Exception", "异常");
|
||||
dic.Add("Revoke", "撤销");
|
||||
List<dynamic> result = new();
|
||||
var List = await _db.Queryable<PrdMoTask>()
|
||||
.WhereIF(!string.IsNullOrEmpty(stationId), p => p.workstation_id == stationId)
|
||||
.ToListAsync();
|
||||
var materials = await _db.Queryable<BasMaterial>().ToListAsync();
|
||||
foreach (var data in List)
|
||||
{
|
||||
dynamic info = new ExpandoObject();
|
||||
info.id = data.id;
|
||||
info.material_id = materials.Where(p => p.id == data.material_id).Any() ? materials.Where(p => p.id == data.material_id).First().name : "";
|
||||
info.material_id_id = data.material_id;
|
||||
info.status = dic.Where(p => p.Key == data.mo_task_status).Any() ? dic.Where(p => p.Key == data.mo_task_status).First().Value : "";
|
||||
info.mo_code = data.mo_task_code;
|
||||
info.mo_type = data.schedule_type == 1 ? "注塑工单" : "组装工单";
|
||||
info.plan_gty = data.plan_qty;
|
||||
info.plan_start_date = data.estimated_start_date == null ? "" : ((DateTime)data.estimated_start_date!).ToString("yyyy-MM-dd");
|
||||
info.plan_end_date = data.estimated_end_date == null ? "" : ((DateTime)data.estimated_end_date!).ToString("yyyy-MM-dd");
|
||||
result.Add(info);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
[HttpPost]
|
||||
public async Task SaveData(AndonRecordInput AndonRecordInput)
|
||||
{
|
||||
var list = _db.Queryable<AndonBreakDown>().ToList();
|
||||
AndonRecords andonRecord = new AndonRecords();
|
||||
andonRecord.mo_id = AndonRecordInput.mo_id;
|
||||
andonRecord.breakdown_type = list.Where(p => p.id == AndonRecordInput.breakdown).Any() ? list.Where(p => p.id == AndonRecordInput.breakdown).First().type_id : "";
|
||||
andonRecord.breakdown = AndonRecordInput.breakdown;
|
||||
andonRecord.create_time = DateTime.Now;
|
||||
andonRecord.create_id = _userManager.UserId;
|
||||
await _db.Insertable(andonRecord).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
43
QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSampleCode.cs
Normal file
43
QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSampleCode.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.QcMgr.Entities
|
||||
{
|
||||
// <summary>
|
||||
/// 抽样检验程序样本量字码表
|
||||
/// </summary>
|
||||
[SugarTable("qc_aql_sample_code")]
|
||||
public partial class QcAqlSampleCode : BaseEntity<string>
|
||||
{
|
||||
public QcAqlSampleCode()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 检验水平
|
||||
/// </summary>
|
||||
public string? checklevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最小值
|
||||
/// </summary>
|
||||
public int? min { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大值
|
||||
/// </summary>
|
||||
public int? max { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 字码
|
||||
/// </summary>
|
||||
public string? code { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
53
QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSamplePlan.cs
Normal file
53
QcMgr/Tnb.QcMgr.Entities/Entity/QcAqlSamplePlan.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.QcMgr.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// aql抽样方案
|
||||
/// </summary>
|
||||
[SugarTable("qc_aql_sample_plan")]
|
||||
public partial class QcAqlSamplePlan : BaseEntity<string>
|
||||
{
|
||||
public QcAqlSamplePlan()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 检验类型
|
||||
/// </summary>
|
||||
public string? checktype { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 字码
|
||||
/// </summary>
|
||||
public string? code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 样本量
|
||||
/// </summary>
|
||||
public int? samplesize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// aql值
|
||||
/// </summary>
|
||||
public decimal? aqlvalue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 接受
|
||||
/// </summary>
|
||||
public int? ac { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 拒收
|
||||
/// </summary>
|
||||
public int? re { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ using JNPF.Common.Enums;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Spire.Xls.Core;
|
||||
using SqlSugar;
|
||||
@@ -377,5 +378,8 @@ namespace Tnb.QcMgr
|
||||
}
|
||||
return floats.Average();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user