入站申请完成
This commit is contained in:
parent
87b1223350
commit
bee558fa5d
23
MDM/Attribute/RIZOFlowAttribute.cs
Normal file
23
MDM/Attribute/RIZOFlowAttribute.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Attribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
|
||||
public class RIZOFlowAttribute : System.Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// 流程类型
|
||||
/// </summary>
|
||||
public string FlowType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程码
|
||||
/// </summary>
|
||||
public string FlowCode { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
90
MDM/Controllers/Session/SessionManagerController.cs
Normal file
90
MDM/Controllers/Session/SessionManagerController.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using DOAN.Model.MES.recipe;
|
||||
using DOAN.Model.MES.recipe.Dto;
|
||||
using DOAN.Service.MES.recipe.IService;
|
||||
using DOAN.ServiceCore.Middleware;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Controllers;
|
||||
using Infrastructure.Enums;
|
||||
using Mapster;
|
||||
using MDM.Models.Flow;
|
||||
using MDM.Models.Session;
|
||||
using MDM.Services.Session.IService;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace MDM.Controllers.Session
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 回会管理
|
||||
/// </summary>
|
||||
[Route("mes/session_managemer")]
|
||||
[AllowAnonymous]
|
||||
public class SessionManagerController : BaseController
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 会话管理接口
|
||||
/// </summary>
|
||||
private readonly ISessionManagerService _ISessionManagerService;
|
||||
public SessionManagerController(ISessionManagerService ISessionManagerService)
|
||||
{
|
||||
_ISessionManagerService = ISessionManagerService;
|
||||
}
|
||||
|
||||
|
||||
//TODO 开工申请
|
||||
/// <summary>
|
||||
/// 开工申请
|
||||
/// </summary>
|
||||
/// <param name="ProcessCode">过程码</param>
|
||||
/// <param name="WorkOrder">当前工单号</param>
|
||||
/// <param name="LineCode">当前产线码</param>
|
||||
/// <param name="GroupCode">当前组码</param>
|
||||
/// <returns>1:开工成功 0:异常 -1:重复开工 -2 参数异常</returns>
|
||||
[HttpGet("start_work_apply")]
|
||||
public IActionResult StartWorkApply(string ProcessCode,string WorkOrder,string LineCode,string GroupCode)
|
||||
{
|
||||
if(string.IsNullOrEmpty(ProcessCode)||string.IsNullOrEmpty(WorkOrder)||string.IsNullOrEmpty(GroupCode))
|
||||
{
|
||||
return SUCCESS(-2);
|
||||
}
|
||||
|
||||
int result= _ISessionManagerService.StartWorkApply(ProcessCode, WorkOrder, LineCode, GroupCode);
|
||||
|
||||
return SUCCESS(result);
|
||||
}
|
||||
|
||||
//TODO 入站申请
|
||||
|
||||
/// <summary>
|
||||
/// 入站申请
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("in_station_apply")]
|
||||
public IActionResult InStationApply(string OperationCode, string ProcessCode)
|
||||
{
|
||||
|
||||
InStationApplyResult result = _ISessionManagerService.InStationApply(OperationCode, ProcessCode);
|
||||
return SUCCESS(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//TODO 出站申请
|
||||
[HttpGet("out_station_apply")]
|
||||
public IActionResult OutStationApply(string OperationCode, string ProcessCode)
|
||||
{
|
||||
|
||||
InStationApplyResult result = _ISessionManagerService.OutStationApply(OperationCode, ProcessCode);
|
||||
return SUCCESS(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
using Infrastructure.Attribute;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Flows
|
||||
{
|
||||
/// <summary>
|
||||
/// 普通流程功能函数
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(CommonFlowfunction), ServiceLifetime = LifeTime.Singleton)]
|
||||
public class CommonFlowfunction
|
||||
{
|
||||
/// <summary>
|
||||
/// 开工
|
||||
/// </summary>
|
||||
/// <param name="workorder">工单号</param>
|
||||
/// <param name="processcode">过程码</param>
|
||||
/// <returns></returns>
|
||||
public static int CommenceWork(string workorder,string processcode)
|
||||
{
|
||||
return 1;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 普通入站站流程
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static int CommonInboundStationFlow()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Flows
|
||||
namespace MDM.Models.Flow
|
||||
{
|
||||
/// <summary>
|
||||
/// 普通入站站流程结果枚举
|
||||
@ -68,4 +68,69 @@ namespace MDM.Flows
|
||||
Reset = 0,
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进站申请结果状态
|
||||
/// </summary>
|
||||
public enum InStationApplyResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 成功 准许进站
|
||||
/// </summary>
|
||||
Success = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 传入 参数无效,禁止入站
|
||||
/// </summary>
|
||||
InvalidParameters = -7,
|
||||
|
||||
/// <summary>
|
||||
/// 产品未开工,禁止入站
|
||||
/// </summary>
|
||||
ProductNotStartWork = -2,
|
||||
|
||||
/// <summary>
|
||||
/// 产品已完工,,禁止入站
|
||||
/// </summary>
|
||||
ProductCompleted = -3,
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重复进站,,禁止入站
|
||||
/// </summary>
|
||||
RepeatInStation = -5,
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 本工序不存在,禁止入站
|
||||
/// </summary>
|
||||
OperationNotFound = -8,
|
||||
|
||||
/// <summary>
|
||||
/// 找不到上一工序,禁止入站
|
||||
/// </summary>
|
||||
PreviousOperationNotFound = -9,
|
||||
|
||||
/// <summary>
|
||||
/// 未知状态,,禁止入站
|
||||
/// </summary>
|
||||
UnknownStatus = -10,
|
||||
|
||||
/// <summary>
|
||||
/// 上一工序未进站,,禁止入站
|
||||
/// </summary>
|
||||
PreviousOperationNotStarted = -1,
|
||||
|
||||
/// <summary>
|
||||
/// 上一工序进站但未出站,,禁止入站
|
||||
/// </summary>
|
||||
PreviousOperationInProgress = -2,
|
||||
|
||||
/// <summary>
|
||||
/// 上一工序有异常,,禁止入站
|
||||
/// </summary>
|
||||
PreviousOperationHasException = -3
|
||||
}
|
||||
}
|
||||
@ -64,19 +64,19 @@ namespace MDM.Model.Process
|
||||
/// 是否允许跳过该工序(跳站)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_skippable")]
|
||||
public string IsSkippable { get; set; }
|
||||
public int IsSkippable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否允许返工
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_reworkable")]
|
||||
public string IsReworkable { get; set; }
|
||||
public int IsReworkable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否准许并行
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_parallel")]
|
||||
public string IsParallel { get; set; }
|
||||
public int IsParallel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 并行组编号(如有)
|
||||
|
||||
104
MDM/Models/Session/ProductLifecycle.cs
Normal file
104
MDM/Models/Session/ProductLifecycle.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Models.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// 产品生命周期表
|
||||
/// </summary>
|
||||
[SugarTable("product_lifecycle")]
|
||||
public class ProductLifecycle
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "workorder")]
|
||||
public string Workorder { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当前生产状态
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "product_status")]
|
||||
public int ProductStatus { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 过程码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "product_SN")]
|
||||
public string ProductSN { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 产线码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "line_code")]
|
||||
public string LineCode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 组码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "group_code")]
|
||||
public string GroupCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工艺路线
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "routing_code")]
|
||||
public string RoutingCode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 产品开工时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "product_start_time")]
|
||||
public DateTime? ProductStartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品返工时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "product_rework_time")]
|
||||
public DateTime? ProductReworkTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品结束时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "product_finish_time")]
|
||||
public DateTime? ProductFinishTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品报废时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "product_scrap_time")]
|
||||
public DateTime? ProductScrapTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "created_time")]
|
||||
public DateTime? CreatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "updated_time")]
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
114
MDM/Models/Session/ProductPassstationRecord.cs
Normal file
114
MDM/Models/Session/ProductPassstationRecord.cs
Normal file
@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Models.Session
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 过站记录表
|
||||
/// </summary>
|
||||
[SugarTable("product_passstation_record")]
|
||||
public class ProductPassstationRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false)] // 注意:这里没有自增标识
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "workorder", Length = 50)]
|
||||
public string Workorder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 过程码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "product_SN", Length = 100)]
|
||||
public string ProductSN { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工位号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "workstationCode", Length = 50)]
|
||||
public string WorkstationCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工艺路线code
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "routingcode", Length = 50)]
|
||||
public string Routingcode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "operationCode", Length = 50)]
|
||||
public string OperationCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 进站时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "InStationTime")]
|
||||
public DateTime? InStationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 出站时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "OutStationTime")]
|
||||
public DateTime? OutStationTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 产品状态
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "prouduct_status", Length = 50)]
|
||||
public int? ProuductStatus { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 停留时间,秒
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "DurationSeconds")]
|
||||
public int? DurationSeconds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 处理结果
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "ProcessResult")]
|
||||
public int? ProcessResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作人员
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "operator", Length = 50)]
|
||||
public string Operator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 不良代码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "NgCode", Length = 50)]
|
||||
public string NgCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 不良描述
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "NgDescription", Length = 255)]
|
||||
public string NgDescription { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "created_time")]
|
||||
public DateTime? CreatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "updated_time")]
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
}
|
||||
}
|
||||
141
MDM/Models/Session/ProductProcessData.cs
Normal file
141
MDM/Models/Session/ProductProcessData.cs
Normal file
@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Models.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// 工艺数据采集
|
||||
/// </summary>
|
||||
[SugarTable("product_process_data")]
|
||||
public class ProductProcessData
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "fk_workorder", Length = 50)]
|
||||
public string FkWorkorder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产线编码(U01)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "lineCode", Length = 50)]
|
||||
public string LineCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工位编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "workstationCode", Length = 50)]
|
||||
public string WorkstationCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工艺路线编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "routingCode", Length = 50)]
|
||||
public string RoutingCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "operationCode", Length = 50)]
|
||||
public string OperationCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "productCode", Length = 50)]
|
||||
public string ProductCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "productname", Length = 50)]
|
||||
public string Productname { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// SN码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "SNnumber", Length = 50)]
|
||||
public string SNnumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 参数名
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "paramter_name", Length = 50)]
|
||||
public string ParamterName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标准值
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "standard_paramter_value", DecimalDigits = 2)]
|
||||
public decimal? StandardParamterValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 参数值
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "real_paramter_value", DecimalDigits = 2)]
|
||||
public decimal? RealParamterValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上限
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "up_range_limit", DecimalDigits = 2)]
|
||||
public decimal? UpRangeLimit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下限
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "low_range_limit", DecimalDigits = 2)]
|
||||
public decimal? LowRangeLimit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "unit", Length = 50)]
|
||||
public string Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 检测结果
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "checkResult")]
|
||||
public int? CheckResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 参数时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "paramTime")]
|
||||
public DateTime? ParamTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "createdby", Length = 50)]
|
||||
public string Createdby { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新人
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "updatedby", Length = 50)]
|
||||
public string Updatedby { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "created_time")]
|
||||
public DateTime? CreatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "updated_time")]
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
}
|
||||
}
|
||||
10
MDM/Models/Session/ProductRunning.cs
Normal file
10
MDM/Models/Session/ProductRunning.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Models.Session
|
||||
{
|
||||
|
||||
}
|
||||
54
MDM/Models/Session/ProductScanRecord.cs
Normal file
54
MDM/Models/Session/ProductScanRecord.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Models.Session
|
||||
{
|
||||
[SugarTable("product_scan_record")]
|
||||
public class ProductScanRecord
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false)] // bigint类型,非自增
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际扫到码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "actual_scan_code", Length = 100)]
|
||||
public string ActualScanCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 期望扫到的码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "expected_code", Length = 100)]
|
||||
public string ExpectedCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扫码结果 (建议:0-失败,1-成功)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "scan_result")]
|
||||
public int? ScanResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误码代号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "error_code", Length = 50)]
|
||||
public string ErrorCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误信息
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "error_message", Length = 255)]
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扫码时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "scan_time")]
|
||||
public DateTime? ScanTime { get; set; }
|
||||
}
|
||||
}
|
||||
154
MDM/Services/Flows/CommonFlowService.cs
Normal file
154
MDM/Services/Flows/CommonFlowService.cs
Normal file
@ -0,0 +1,154 @@
|
||||
|
||||
using Infrastructure.Attribute;
|
||||
using JinianNet.JNTemplate;
|
||||
using MDM.Attribute;
|
||||
using MDM.Model.Material;
|
||||
using MDM.Model.Process;
|
||||
using MDM.Models.Flow;
|
||||
using MDM.Models.Session;
|
||||
using MDM.Service;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Services.Flows
|
||||
{
|
||||
/// <summary>
|
||||
/// 普通流程功能函数
|
||||
/// </summary>
|
||||
// [AppService(ServiceType = typeof(CommonFlowService), ServiceLifetime = LifeTime.Singleton)]
|
||||
public class CommonFlowService : BaseService<Object>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 普通入站站流程
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[RIZOFlow(FlowType = "common_inbound_flow")]
|
||||
public InStationApplyResult CommonInboundStationFlow(string operationCode, string processCode)
|
||||
{
|
||||
// 参数验证
|
||||
if (string.IsNullOrWhiteSpace(operationCode) || string.IsNullOrWhiteSpace(processCode))
|
||||
{
|
||||
return InStationApplyResult.InvalidParameters;
|
||||
}
|
||||
|
||||
// 获取产品是否开工
|
||||
var product = GetProductBySn(processCode);
|
||||
if (product == null)
|
||||
{
|
||||
// 产品未开工,不得入站
|
||||
return InStationApplyResult.ProductNotStartWork;
|
||||
}
|
||||
|
||||
// 判断正常件还是返工件,完工件
|
||||
|
||||
if (product.ProductStatus == 2)
|
||||
{
|
||||
// 完工件不得入站
|
||||
return InStationApplyResult.ProductCompleted;
|
||||
}
|
||||
|
||||
// 返工件进行 进站处理
|
||||
if (product.ProductStatus == 3)
|
||||
{
|
||||
// 返工件入站
|
||||
return InStationApplyResult.Success;
|
||||
}
|
||||
|
||||
// 正常件进行 进站处理
|
||||
if (product.ProductStatus == 1)
|
||||
{
|
||||
return HandleInProductionProduct(product, operationCode);
|
||||
}
|
||||
|
||||
return InStationApplyResult.Success;
|
||||
}
|
||||
|
||||
private ProductLifecycle GetProductBySn(string productSn)
|
||||
{
|
||||
return Context.Queryable<ProductLifecycle>()
|
||||
.Where(it => it.ProductSN == productSn)
|
||||
.First();
|
||||
}
|
||||
|
||||
private InStationApplyResult HandleInProductionProduct(ProductLifecycle product, string operationCode)
|
||||
{
|
||||
// 检查是否重复进站
|
||||
if (IsRepeatInStation(product.ProductSN, operationCode))
|
||||
{
|
||||
//重复入站,禁止入站
|
||||
return InStationApplyResult.RepeatInStation;
|
||||
}
|
||||
|
||||
// 获取工序信息
|
||||
var processOperation = GetProcessOperation(product.RoutingCode, operationCode);
|
||||
if (processOperation == null)
|
||||
{
|
||||
// 工序不存在 异常
|
||||
return InStationApplyResult.OperationNotFound;
|
||||
}
|
||||
|
||||
// 检查是否可以跳站
|
||||
if (processOperation.IsSkippable == 1)
|
||||
{
|
||||
// 允许跳站,直接入站成功
|
||||
return InStationApplyResult.Success;
|
||||
}
|
||||
|
||||
// 检查上一工序状态
|
||||
return CheckPreviousOperationStatus(product.ProductSN, product.RoutingCode, processOperation.OperationSeq);
|
||||
}
|
||||
|
||||
private bool IsRepeatInStation(string productSn, string operationCode)
|
||||
{
|
||||
return Context.Queryable<ProductPassstationRecord>()
|
||||
.Where(it => it.ProductSN == productSn && it.OperationCode == operationCode)
|
||||
.Any();
|
||||
}
|
||||
|
||||
private ProcessOperation GetProcessOperation(string routingCode, string operationCode)
|
||||
{
|
||||
return Context.Queryable<ProcessOperation>()
|
||||
.Where(it => it.FkRoutingCode == routingCode && it.OperationCode == operationCode)
|
||||
.First();
|
||||
}
|
||||
|
||||
private InStationApplyResult CheckPreviousOperationStatus(string productSn, string routingCode, int? currentOperationSeq)
|
||||
{
|
||||
// 获取上一个工序
|
||||
var lastOperation = Context.Queryable<ProcessOperation>()
|
||||
.Where(it => it.FkRoutingCode == routingCode)
|
||||
.Where(it => it.OperationSeq < currentOperationSeq)
|
||||
.OrderByDescending(it => it.OperationSeq)
|
||||
.First();
|
||||
|
||||
if (lastOperation == null)
|
||||
{
|
||||
return InStationApplyResult.PreviousOperationNotFound;
|
||||
}
|
||||
|
||||
// 获取上一工序的通过记录状态
|
||||
var lastOperationStatus = Context.Queryable<ProductPassstationRecord>()
|
||||
.Where(it => it.ProductSN == productSn && it.OperationCode == lastOperation.OperationCode)
|
||||
.Select(it => it.ProuductStatus)
|
||||
.First();
|
||||
|
||||
return lastOperationStatus switch
|
||||
{
|
||||
// 上一个工序未入站,禁止入站
|
||||
null => InStationApplyResult.PreviousOperationNotStarted,
|
||||
// 上一个工序进站但未出站,禁止入站
|
||||
1 => InStationApplyResult.PreviousOperationInProgress,
|
||||
// 上一个工序已完成,允许入站
|
||||
2 => InStationApplyResult.Success,
|
||||
// 上一个工序有异常,禁止入站
|
||||
3 => InStationApplyResult.PreviousOperationHasException,
|
||||
_ => InStationApplyResult.UnknownStatus
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
20
MDM/Services/Session/IService/ISessionManagerService.cs
Normal file
20
MDM/Services/Session/IService/ISessionManagerService.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using MDM.Models.Flow;
|
||||
using MDM.Models.Session;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Services.Session.IService
|
||||
{
|
||||
public interface ISessionManagerService
|
||||
{
|
||||
|
||||
int StartWorkApply(string ProcessCode, string WorkOrder, string LineCode, string GroupCode);
|
||||
|
||||
InStationApplyResult InStationApply(string OperationCode, string ProcessCode);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
134
MDM/Services/Session/SessionManagerService.cs
Normal file
134
MDM/Services/Session/SessionManagerService.cs
Normal file
@ -0,0 +1,134 @@
|
||||
using DOAN.Model.MES.product;
|
||||
using DOAN.Model.MES.recipe;
|
||||
using DOAN.Service.MES.recipe.IService;
|
||||
using Infrastructure.Attribute;
|
||||
using MDM.Attribute;
|
||||
using MDM.Model.Process;
|
||||
using MDM.Models.Flow;
|
||||
using MDM.Models.Process;
|
||||
using MDM.Models.Session;
|
||||
using MDM.Service;
|
||||
using MDM.Services.Session.IService;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Services.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// 产品配方关联表Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISessionManagerService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SessionManagerService : BaseService<Object>, ISessionManagerService
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 开工申请
|
||||
/// </summary>
|
||||
/// <param name="ProcessCode">过程码</param>
|
||||
/// <returns></returns>
|
||||
public int StartWorkApply(string ProcessCode, string WorkOrder, string LineCode, string GroupCode)
|
||||
{
|
||||
//校验重复开工
|
||||
bool isRepeat = Context.Queryable<ProductLifecycle>().Where(it => it.Workorder == WorkOrder && it.ProductSN == ProcessCode).Any();
|
||||
|
||||
if (isRepeat)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
//根据工单号查询工艺路线
|
||||
|
||||
ProcessRouting processRouting = Context.Queryable<ProcessRouting>()
|
||||
.Where(it => it.FkProductMaterialCode == SqlFunc.Subqueryable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == WorkOrder).Select(s => s.ProductionCode))
|
||||
.First();
|
||||
|
||||
ProductLifecycle lifecycle = new ProductLifecycle();
|
||||
lifecycle.Workorder = WorkOrder;
|
||||
lifecycle.ProductSN = ProcessCode;
|
||||
lifecycle.LineCode = LineCode;
|
||||
lifecycle.GroupCode = GroupCode;
|
||||
lifecycle.ProductStatus = 1;
|
||||
lifecycle.RoutingCode = processRouting.RoutingCode ?? "";
|
||||
lifecycle.ProductStartTime = DateTime.Now;
|
||||
lifecycle.CreatedTime = DateTime.Now;
|
||||
|
||||
|
||||
return Context.Insertable(lifecycle).ExecuteCommand();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 进站申请
|
||||
/// </summary>
|
||||
/// <param name="OperationCode"></param>
|
||||
/// <param name="ProcessCode"></param>
|
||||
/// <returns></returns>
|
||||
public InStationApplyResult InStationApply(string OperationCode, string ProcessCode)
|
||||
{
|
||||
// 查询本工序的 入站流程
|
||||
if (string.IsNullOrEmpty(OperationCode) && string.IsNullOrEmpty(ProcessCode))
|
||||
{
|
||||
return InStationApplyResult.InvalidParameters;
|
||||
}
|
||||
|
||||
var lifecycle = Context.Queryable<ProductLifecycle>()
|
||||
.Where(it => it.ProductSN == ProcessCode)
|
||||
.First();
|
||||
|
||||
if (lifecycle == null)
|
||||
{
|
||||
return InStationApplyResult.InvalidParameters;
|
||||
}
|
||||
|
||||
ProcessOperationFlow operationFlow = Context.Queryable<ProcessOperationFlow>()
|
||||
.Where(it => it.FkRoutingCode == lifecycle.RoutingCode && it.FkOperationCode == OperationCode)
|
||||
.First();
|
||||
|
||||
if (operationFlow != null)
|
||||
{
|
||||
// 已知程序集和类名
|
||||
string assemblyName = "MDM.Services.Flows";
|
||||
string className = "CommonFlowService"; // 具体的类名
|
||||
|
||||
// 加载程序集并获取指定类型
|
||||
Assembly assembly = Assembly.Load(assemblyName);
|
||||
Type targetType = assembly.GetType($"{assemblyName}.{className}");
|
||||
|
||||
if (targetType != null)
|
||||
{
|
||||
// 获取类型中带有RIZOFlow特性的方法
|
||||
var methods = targetType.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
|
||||
|
||||
foreach (var method in methods)
|
||||
{
|
||||
var rizoFlow = method.GetCustomAttribute<RIZOFlowAttribute>();
|
||||
if (rizoFlow != null && rizoFlow.FlowType == operationFlow.FlowTypeCode)
|
||||
{
|
||||
// 找到匹配的方法并调用
|
||||
var instance = Activator.CreateInstance(targetType);
|
||||
var result = method.Invoke(instance, new object[] { OperationCode, ProcessCode });
|
||||
|
||||
// 处理返回结果
|
||||
if (result is InStationApplyResult applyResult)
|
||||
{
|
||||
return applyResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return InStationApplyResult.UnknownStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user