1
This commit is contained in:
parent
ee498f5aaf
commit
b107d5bae1
@ -40,22 +40,21 @@ namespace MDM.Controllers.Session
|
||||
/// </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)
|
||||
public IActionResult StartWorkApply(string ProcessCode, string WorkOrder)
|
||||
{
|
||||
if(string.IsNullOrEmpty(ProcessCode)||string.IsNullOrEmpty(WorkOrder)||string.IsNullOrEmpty(GroupCode))
|
||||
if (string.IsNullOrEmpty(ProcessCode) || string.IsNullOrEmpty(WorkOrder))
|
||||
{
|
||||
return SUCCESS(-2);
|
||||
}
|
||||
|
||||
int result= _ISessionManagerService.StartWorkApply(ProcessCode, WorkOrder, LineCode, GroupCode);
|
||||
int result = _ISessionManagerService.StartWorkApply(ProcessCode, WorkOrder);
|
||||
|
||||
return SUCCESS(result);
|
||||
}
|
||||
|
||||
|
||||
//TODO 入站申请
|
||||
|
||||
/// <summary>
|
||||
@ -63,13 +62,16 @@ namespace MDM.Controllers.Session
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("in_station_apply")]
|
||||
public IActionResult InStationApply(string OperationCode, string ProcessCode)
|
||||
public IActionResult InStationApply(string OperationCode, string ProcessCode)
|
||||
{
|
||||
|
||||
InStationApplyResult result = _ISessionManagerService.InStationApply(OperationCode, ProcessCode);
|
||||
return SUCCESS(result);
|
||||
}
|
||||
|
||||
//TODO 中间流程/工步下发
|
||||
|
||||
|
||||
|
||||
|
||||
//TODO 出站申请
|
||||
@ -77,11 +79,50 @@ namespace MDM.Controllers.Session
|
||||
public IActionResult OutStationApply(string OperationCode, string ProcessCode)
|
||||
{
|
||||
|
||||
InStationApplyResult result = _ISessionManagerService.OutStationApply(OperationCode, ProcessCode);
|
||||
OutStationApplyResult result = _ISessionManagerService.OutStationApply(OperationCode, ProcessCode);
|
||||
return SUCCESS(result);
|
||||
}
|
||||
|
||||
|
||||
//TODO 完工申请
|
||||
/// <summary>
|
||||
/// 完工申请
|
||||
/// </summary>
|
||||
/// <param name="ProcessCode">过程码</param>
|
||||
/// <param name="WorkOrder">当前工单号</param>
|
||||
/// <returns>1:开工成功 0:异常 -1:重复开工 -2 参数异常</returns>
|
||||
[HttpGet("finish_work_apply")]
|
||||
public IActionResult FinishWorkApply(string ProcessCode, string WorkOrder)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ProcessCode) || string.IsNullOrEmpty(WorkOrder))
|
||||
{
|
||||
return SUCCESS(-2);
|
||||
}
|
||||
|
||||
int result = _ISessionManagerService.FinishWorkApply(ProcessCode, WorkOrder);
|
||||
|
||||
return SUCCESS(result);
|
||||
}
|
||||
|
||||
//TODO 返工申请
|
||||
/// <summary>
|
||||
/// 返工申请
|
||||
/// </summary>
|
||||
/// <param name="ProcessCode">过程码</param>
|
||||
/// <param name="WorkOrder">当前工单号</param>
|
||||
/// <returns>1:返工成功 0:异常 -1:重复开工 -2 参数异常</returns>
|
||||
[HttpGet("rework_apply")]
|
||||
public IActionResult ReWorkApply(string ProcessCode, string WorkOrder)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ProcessCode) || string.IsNullOrEmpty(WorkOrder))
|
||||
{
|
||||
return SUCCESS(-2);
|
||||
}
|
||||
|
||||
int result = _ISessionManagerService.ReWorkApply(ProcessCode, WorkOrder);
|
||||
|
||||
return SUCCESS(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Models.Session
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 过站记录表
|
||||
/// </summary>
|
||||
@ -16,7 +15,7 @@ namespace MDM.Models.Session
|
||||
/// <summary>
|
||||
/// 主键ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false)] // 注意:这里没有自增标识
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)] // 修正:启用自增
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -49,6 +48,24 @@ namespace MDM.Models.Session
|
||||
[SugarColumn(ColumnName = "operationCode", Length = 50)]
|
||||
public string OperationCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品生命周期阶段(1,是生产中,2是完工,3是返工)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "production_life_stage")]
|
||||
public int? ProductionLifeStage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 过站类型(IN 进站,OUT 出站)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "apply_type")]
|
||||
public ApplyTypeEnum? ApplyType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 过站状态(SUCCESS 准许过站放行,REJECTED 禁止过站)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "apply_status")]
|
||||
public ApplyStatusEnum? ApplyStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 进站时间
|
||||
/// </summary>
|
||||
@ -61,26 +78,12 @@ namespace MDM.Models.Session
|
||||
[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>
|
||||
@ -88,16 +91,16 @@ namespace MDM.Models.Session
|
||||
public string Operator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 不良代码
|
||||
/// 禁止过站代码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "NgCode", Length = 50)]
|
||||
public string NgCode { get; set; }
|
||||
[SugarColumn(ColumnName = "reject_reason_code")]
|
||||
public string RejectReasonCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 不良描述
|
||||
/// 禁止过站描述
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "NgDescription", Length = 255)]
|
||||
public string NgDescription { get; set; }
|
||||
[SugarColumn(ColumnName = "reject_reason_desc", Length = 255)]
|
||||
public string RejectReasonDesc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
@ -111,4 +114,22 @@ namespace MDM.Models.Session
|
||||
[SugarColumn(ColumnName = "updated_time")]
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 过站类型枚举
|
||||
/// </summary>
|
||||
public enum ApplyTypeEnum
|
||||
{
|
||||
IN = 0,
|
||||
OUT = 1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 过站状态枚举
|
||||
/// </summary>
|
||||
public enum ApplyStatusEnum
|
||||
{
|
||||
SUCCESS = 0,
|
||||
REJECTED = 1
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +1,16 @@
|
||||
|
||||
using DOAN.Model.MES.recipe;
|
||||
using DOAN.Model.MES.recipe.Dto;
|
||||
using Infrastructure.Attribute;
|
||||
using JinianNet.JNTemplate;
|
||||
using MDM.Attribute;
|
||||
using MDM.Model.Material;
|
||||
using MDM.Model.Process;
|
||||
using MDM.Models.Flow;
|
||||
using MDM.Models.Process;
|
||||
using MDM.Models.Session;
|
||||
using MDM.Service;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Org.BouncyCastle.Ocsp;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
|
||||
|
||||
|
||||
namespace MDM.Services.Flows
|
||||
{
|
||||
@ -27,169 +22,306 @@ namespace MDM.Services.Flows
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 普通入站站流程
|
||||
/// 普通入站流程
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <param name="operationCode">工序代码</param>
|
||||
/// <param name="processCode">产品序列号</param>
|
||||
/// <returns>入站结果</returns>
|
||||
[RIZOFlow(FlowType = "common_inbound_flow")]
|
||||
public InStationApplyResult CommonInboundStationFlow(string operationCode, string processCode)
|
||||
{
|
||||
// 参数验证
|
||||
if (string.IsNullOrWhiteSpace(operationCode) || string.IsNullOrWhiteSpace(processCode))
|
||||
if (string.IsNullOrWhiteSpace(operationCode))
|
||||
{
|
||||
return InStationApplyResult.InvalidParameters;
|
||||
}
|
||||
|
||||
// 获取产品是否开工
|
||||
var product = GetProductBySn(processCode);
|
||||
if (product == null)
|
||||
if (string.IsNullOrWhiteSpace(processCode))
|
||||
{
|
||||
return InStationApplyResult.InvalidParameters;
|
||||
}
|
||||
|
||||
//1.获取产品是正常件,完成件,返工件
|
||||
ProductLifecycle productInfo = Context.Queryable<ProductLifecycle>()
|
||||
.Where(p => p.ProductSN == processCode)
|
||||
.First();
|
||||
if (productInfo == null)
|
||||
{
|
||||
// 产品未开工,不得入站
|
||||
RecordTrace(productInfo, operationCode, 0, ApplyStatusEnum.REJECTED, InStationApplyResult.ProductNotStartWork.ToString(), "产品未开工,不得入站");
|
||||
return InStationApplyResult.ProductNotStartWork;
|
||||
}
|
||||
|
||||
// 判断正常件还是返工件,完工件
|
||||
|
||||
if (product.ProductStatus == 2)
|
||||
if (productInfo.ProductStatus == 2)
|
||||
{
|
||||
// 完工件不得入站
|
||||
// 产品已经生产完成,不得入站
|
||||
RecordTrace(productInfo, operationCode, 2, ApplyStatusEnum.REJECTED, InStationApplyResult.ProductCompleted.ToString(), "产品已经生产完成,不得入站");
|
||||
return InStationApplyResult.ProductCompleted;
|
||||
}
|
||||
|
||||
// 返工件进行 进站处理
|
||||
if (product.ProductStatus == 3)
|
||||
if (productInfo.ProductStatus == 3)
|
||||
{
|
||||
|
||||
// 返工件入站
|
||||
RecordTrace(product, operationCode, 3);
|
||||
// 返工件允许入站
|
||||
RecordTrace(productInfo, operationCode, 3, ApplyStatusEnum.SUCCESS, string.Empty, string.Empty);
|
||||
return InStationApplyResult.Success;
|
||||
}
|
||||
|
||||
// 正常件进行 进站处理
|
||||
if (product.ProductStatus == 1)
|
||||
if (productInfo.ProductStatus == 1)
|
||||
{
|
||||
return HandleInProductionProduct(product, operationCode);
|
||||
//正常件处理
|
||||
// 1.检查是否重复进站
|
||||
bool IsRepeatInStation = Context.Queryable<ProductPassstationRecord>()
|
||||
.Where(it => it.ProductSN == processCode && it.OperationCode == operationCode)
|
||||
.Any();
|
||||
if (IsRepeatInStation)
|
||||
{
|
||||
// 重复进站禁止入站
|
||||
RecordTrace(productInfo, operationCode, 3, ApplyStatusEnum.REJECTED, InStationApplyResult.RepeatInStation.ToString(), "重复进站禁止入站");
|
||||
return InStationApplyResult.RepeatInStation;
|
||||
}
|
||||
|
||||
// 获取工序信息
|
||||
ProcessOperation processOperation = Context.Queryable<ProcessOperation>()
|
||||
.Where(it => it.FkRoutingCode == productInfo.RoutingCode && it.OperationCode == operationCode).First();
|
||||
if (processOperation == null)
|
||||
{
|
||||
return InStationApplyResult.OperationNotFound;
|
||||
}
|
||||
|
||||
// 可跳过的工序直接允许入站
|
||||
if (processOperation.IsSkippable == 1)
|
||||
{
|
||||
RecordTrace(productInfo, operationCode, 1, ApplyStatusEnum.SUCCESS, null, null);
|
||||
return InStationApplyResult.Success;
|
||||
}
|
||||
|
||||
// 检查上一工序状态
|
||||
if (processOperation.OperationSeq <= 10)
|
||||
{
|
||||
// 当前是第一个工序,无需检查上一工序
|
||||
RecordTrace(productInfo, operationCode, 1, ApplyStatusEnum.SUCCESS, null, null);
|
||||
return InStationApplyResult.Success;
|
||||
}
|
||||
|
||||
// 获取上一个工序
|
||||
var lastOperation = Context.Queryable<ProcessOperation>()
|
||||
.Where(it => it.FkRoutingCode == productInfo.RoutingCode)
|
||||
.Where(it => it.OperationSeq < processOperation.OperationSeq)
|
||||
.OrderByDescending(it => it.OperationSeq)
|
||||
.First();
|
||||
|
||||
if (lastOperation == null)
|
||||
{
|
||||
return InStationApplyResult.PreviousOperationNotFound;
|
||||
}
|
||||
|
||||
// 获取上一工序的通过记录状态 判断上一站是否已经出站
|
||||
bool lastOperationStatus = Context.Queryable<ProductPassstationRecord>()
|
||||
.Where(it => it.ProductSN == processCode && it.OperationCode == lastOperation.OperationCode)
|
||||
.Where(it => it.ApplyType == ApplyTypeEnum.OUT)
|
||||
.Where(it => it.ApplyStatus == ApplyStatusEnum.SUCCESS)
|
||||
.Any();
|
||||
|
||||
if (lastOperationStatus)
|
||||
{
|
||||
// 上一工序已完成,允许入站
|
||||
RecordTrace(productInfo, operationCode, 1, ApplyStatusEnum.SUCCESS, InStationApplyResult.Success.ToString(), "上一工序已完成,允许入站");
|
||||
return InStationApplyResult.Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 上一工序未完成,禁止入站
|
||||
RecordTrace(productInfo, operationCode, 1, ApplyStatusEnum.REJECTED, InStationApplyResult.PreviousOperationNotStarted.ToString(), "上一工序未完成,禁止入站");
|
||||
return InStationApplyResult.PreviousOperationNotStarted;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
RecordTrace(product, operationCode, 1);
|
||||
return InStationApplyResult.Success;
|
||||
}
|
||||
|
||||
// 检查上一工序状态
|
||||
InStationApplyResult result = CheckPreviousOperationStatus(product.ProductSN, product.RoutingCode, processOperation.OperationSeq);
|
||||
if (result == InStationApplyResult.Success)
|
||||
{
|
||||
RecordTrace(product, operationCode, 1);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
return InStationApplyResult.UnknownStatus;
|
||||
}
|
||||
|
||||
|
||||
private void RecordTrace(ProductLifecycle product, string operationCode, int flag)
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 记录入站操作轨迹
|
||||
/// </summary>
|
||||
/// <param name="product">产品信息</param>
|
||||
/// <param name="operationCode">工序代码</param>
|
||||
/// <param name="result">入站结果</param>
|
||||
/// <param name="rejectReasonCode">拒绝原因代码</param>
|
||||
/// <param name="rejectReasonDesc">拒绝原因描述</param>
|
||||
private void RecordTrace(ProductLifecycle product, string operationCode, int ProductionLifeStage, ApplyStatusEnum isPass, string rejectReasonCode, string rejectReasonDesc)
|
||||
{
|
||||
|
||||
Context.Updateable<ProductLifecycle>()
|
||||
.SetColumns(it => new ProductLifecycle
|
||||
// 更新产品状态
|
||||
if (product != null)
|
||||
{
|
||||
ProductStatus = 1,// 设置为生产中状态
|
||||
UpdatedTime = DateTime.Now
|
||||
}).Where(it => it.ProductSN == product.ProductSN).ExecuteCommand();
|
||||
Context.Updateable<ProductLifecycle>()
|
||||
.SetColumns(it => new ProductLifecycle
|
||||
{
|
||||
ProductStatus = 1, // 设置为生产中状态
|
||||
UpdatedTime = DateTime.Now
|
||||
})
|
||||
.Where(it => it.ProductSN == product.ProductSN)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
|
||||
//插入入站记录
|
||||
ProductPassstationRecord passstationRecord = new ProductPassstationRecord
|
||||
// 构建入站记录
|
||||
var passstationRecord = new ProductPassstationRecord
|
||||
{
|
||||
Workorder = product.Workorder,
|
||||
Routingcode = product.RoutingCode,
|
||||
ProductSN = product.ProductSN,
|
||||
Workorder = product?.Workorder,
|
||||
Routingcode = product?.RoutingCode,
|
||||
ProductSN = product?.ProductSN ?? string.Empty,
|
||||
OperationCode = operationCode,
|
||||
ProuductStatus = flag, // 入站状态
|
||||
ProductionLifeStage = ProductionLifeStage, // 生产中
|
||||
ApplyType = ApplyTypeEnum.IN,
|
||||
ApplyStatus = isPass,
|
||||
RejectReasonCode = rejectReasonCode,
|
||||
RejectReasonDesc = rejectReasonDesc,
|
||||
InStationTime = DateTime.Now,
|
||||
CreatedTime = DateTime.Now
|
||||
};
|
||||
|
||||
Context.Insertable(passstationRecord).ExecuteCommand();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//TODO: 下发中间操作流程规则
|
||||
|
||||
|
||||
//public Object MiddleProcessFlowDistribution(string operationCode, string processCode)
|
||||
//{
|
||||
|
||||
// //TODO 获取这个工序的中间操作规则
|
||||
|
||||
// //1. 获取不同的流程规则
|
||||
// List<ProcessFlowList> MiddleProcessFlowLists = Context.Queryable<ProcessFlowList>().Where(it => !it.FlowTypeCode.Contains("bound_flow")).ToList();
|
||||
|
||||
// //2.分配处理不同的中间操作规则
|
||||
// foreach (var flow in MiddleProcessFlowLists)
|
||||
// {
|
||||
// //根据不同的流程类型,调用不同的处理函数
|
||||
// switch (flow.FlowTypeCode)
|
||||
// {
|
||||
// //扫码流程
|
||||
// case "Scanningcode_flow":
|
||||
// //调用质量检验流程处理函数
|
||||
// //QualityInspectionFlow(operationCode, processCode);
|
||||
// break;
|
||||
// //数据采集流程
|
||||
// case "data_collect_flow":
|
||||
// //调用返工流程处理函数
|
||||
// //ReworkProcessFlow(operationCode, processCode);
|
||||
// break;
|
||||
// //配方下发流程
|
||||
// case "recipe_distribute_flow":
|
||||
// //调用返工流程处理函数
|
||||
// //ReworkProcessFlow(operationCode, processCode);
|
||||
// break;
|
||||
// // 添加更多的流程类型处理
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
//}
|
||||
|
||||
|
||||
//TODO: 扫码流程
|
||||
[RIZOFlow(FlowType = "Scanningcode_flow")]
|
||||
public List<ProcessOperationFlowMaterialParamter> ScanningcodeFlow(string operationCode, string RoutingCode)
|
||||
{
|
||||
|
||||
|
||||
//获取这个工序d的扫码规则
|
||||
List<ProcessOperationFlowMaterialParamter> ScanningFlowList = Context.Queryable<ProcessOperationFlow>().LeftJoin<ProcessOperationFlowMaterialParamter>((f, m) => f.FkRoutingCode == m.FkRoutingCode && f.FkOperationCode == m.FkOperationCode && f.FlowCode == m.FkFlowCode)
|
||||
|
||||
.Where((f, m) => f.FkRoutingCode == RoutingCode && f.FkOperationCode == operationCode && f.FlowTypeCode == "Scanningcode_flow")
|
||||
.Select((f, m) => new ProcessOperationFlowMaterialParamter()
|
||||
{
|
||||
id = f.id,
|
||||
FkRoutingCode = f.FkRoutingCode,
|
||||
FkOperationCode = f.FkOperationCode,
|
||||
FkFlowCode = m.FkFlowCode,
|
||||
MaterialCode = m.MaterialCode,
|
||||
MaterialName = m.MaterialName,
|
||||
UseErrorProofRuleCode = m.UseErrorProofRuleCode,
|
||||
|
||||
})
|
||||
.ToList();
|
||||
return ScanningFlowList;
|
||||
|
||||
}
|
||||
|
||||
//TODO: 数采流程
|
||||
[RIZOFlow(FlowType = "data_collect_flow")]
|
||||
public List<ProcessOperationWorkstationFlowCollectParameter> DataCollectFlow( string RoutingCode, string operationCode, string ProductlinebodyCode, string WorkstationCode)
|
||||
{
|
||||
|
||||
|
||||
//获取这个工序d的扫码规则
|
||||
List<ProcessOperationWorkstationFlowCollectParameter> DataCollectFlowList = Context.Queryable<ProcessOperationFlow>().LeftJoin<ProcessOperationWorkstationFlowCollectParameter>
|
||||
((f, m) => f.FkRoutingCode == m.FkRoutingCode && f.FkOperationCode == m.FkOperationCode && f.FlowCode == m.FkFlowCode)
|
||||
.Where((f, m) => f.FkRoutingCode == RoutingCode && f.FkOperationCode == operationCode && f.FlowTypeCode == "Scanningcode_flow")
|
||||
.Where((f,m)=>m.FkProductlinebodyCode== ProductlinebodyCode&&m.FkWorkstationCode== WorkstationCode)
|
||||
.Select((f, m) => new ProcessOperationWorkstationFlowCollectParameter()
|
||||
{
|
||||
|
||||
FkRoutingCode = f.FkRoutingCode,
|
||||
FkOperationCode = f.FkOperationCode,
|
||||
FkProductlinebodyCode = m.FkProductlinebodyCode,
|
||||
FkWorkstationCode = m.FkWorkstationCode,
|
||||
FkFlowCode = m.FkFlowCode,
|
||||
ParameterCode = m.ParameterCode,
|
||||
PlcPoint = m.PlcPoint,
|
||||
ParameterName = m.ParameterName,
|
||||
Description = m.Description,
|
||||
DataType = m.DataType,
|
||||
Unit = m.Unit,
|
||||
StandardValue = m.StandardValue,
|
||||
MinValue = m.MinValue,
|
||||
MaxValue = m.MaxValue,
|
||||
IsControlled = m.IsControlled,
|
||||
IsMonitored = m.IsMonitored,
|
||||
ControlType = m.ControlType,
|
||||
DefaultValue = m.DefaultValue,
|
||||
IsRequired = m.IsRequired,
|
||||
Sequence = m.Sequence,
|
||||
|
||||
|
||||
|
||||
})
|
||||
.ToList();
|
||||
return DataCollectFlowList;
|
||||
|
||||
}
|
||||
|
||||
//TODO: 配方流程
|
||||
[RIZOFlow(FlowType = "recipe_distribute_flow")]
|
||||
public List<PfRecipeParametersDto> RecipeDistributeFlow(string operationCode, string RoutingCode)
|
||||
{
|
||||
return Context.Queryable<PfRefProductRecipe>()
|
||||
.LeftJoin<PfRecipeVersion>((refpr, ver) => refpr.RecipeCode == ver.RecipeCode)
|
||||
.LeftJoin<PfRecipeParameters>((refpr, ver, param) => ver.RecipeCode == param.RecipeCode && ver.Version == param.Version)
|
||||
.Where((refpr, ver, param) => refpr.FkRoutingCode == RoutingCode && refpr.FkOperationCode == operationCode)
|
||||
.Select((refpr, ver, param) => new PfRecipeParametersDto
|
||||
{
|
||||
Id = param.Id,
|
||||
RecipeCode = param.RecipeCode,
|
||||
Version = param.Version,
|
||||
ParamName = param.ParamName,
|
||||
Unit = param.Unit,
|
||||
UpperLimit = param.UpperLimit,
|
||||
LowerLimit = param.LowerLimit,
|
||||
StandardValue = param.StandardValue,
|
||||
Remark = param.Remark
|
||||
}).ToList();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -198,64 +330,69 @@ namespace MDM.Services.Flows
|
||||
/// <param name="operationCode"></param>
|
||||
/// <param name="processCode"></param>
|
||||
/// <returns></returns>
|
||||
[RIZOFlow(FlowType = "common_outbound_flow")]
|
||||
public OutStationApplyResult CommonOutboundStationFlow(string operationCode, string processCode)
|
||||
{
|
||||
// 参数验证
|
||||
if (string.IsNullOrWhiteSpace(operationCode) || string.IsNullOrWhiteSpace(processCode))
|
||||
{
|
||||
return OutStationApplyResult.InvalidParameters;
|
||||
}
|
||||
// 获取产品是正常件,完成件,返工件
|
||||
var product = GetProductBySn(processCode);
|
||||
if (product == null)
|
||||
{
|
||||
// 产品未开工,不得出站
|
||||
return OutStationApplyResult.ProductNotStartWork;
|
||||
}
|
||||
if (product.ProductStatus == 2)
|
||||
{
|
||||
// 产品已经生产完成,不得出站
|
||||
return OutStationApplyResult.ProductCompleted;
|
||||
}
|
||||
//如果正常件,返工件
|
||||
if (product.ProductStatus == 2)
|
||||
{
|
||||
//插入出站记录
|
||||
ProductPassstationRecord passstationRecord = new ProductPassstationRecord
|
||||
{
|
||||
Workorder = product.Workorder,
|
||||
Routingcode = product.RoutingCode,
|
||||
ProductSN = product.ProductSN,
|
||||
OperationCode = operationCode,
|
||||
ProuductStatus = 3, // 出站状态
|
||||
OutStationTime = DateTime.Now,
|
||||
CreatedTime = DateTime.Now
|
||||
};
|
||||
Context.Insertable(passstationRecord).ExecuteCommand();
|
||||
return OutStationApplyResult.Success;
|
||||
}
|
||||
//如果,返工件
|
||||
if (product.ProductStatus == 3)
|
||||
{
|
||||
//插入出站记录
|
||||
ProductPassstationRecord passstationRecord = new ProductPassstationRecord
|
||||
{
|
||||
Workorder = product.Workorder,
|
||||
Routingcode = product.RoutingCode,
|
||||
ProductSN = product.ProductSN,
|
||||
OperationCode = operationCode,
|
||||
ProuductStatus = 4, // 出站状态
|
||||
OutStationTime = DateTime.Now,
|
||||
CreatedTime = DateTime.Now
|
||||
};
|
||||
Context.Insertable(passstationRecord).ExecuteCommand();
|
||||
return OutStationApplyResult.Success;
|
||||
}
|
||||
//[RIZOFlow(FlowType = "common_outbound_flow")]
|
||||
//public OutStationApplyResult CommonOutboundStationFlow(string operationCode, string processCode)
|
||||
//{
|
||||
// // 参数验证
|
||||
// if (string.IsNullOrWhiteSpace(operationCode) || string.IsNullOrWhiteSpace(processCode))
|
||||
// {
|
||||
// return OutStationApplyResult.InvalidParameters;
|
||||
// }
|
||||
// // 获取产品是正常件,完成件,返工件
|
||||
// var product = GetProductBySn(processCode);
|
||||
// if (product == null)
|
||||
// {
|
||||
// // 产品未开工,不得出站
|
||||
// return OutStationApplyResult.ProductNotStartWork;
|
||||
// }
|
||||
// if (product.ProductStatus == 2)
|
||||
// {
|
||||
// // 产品已经生产完成,不得出站
|
||||
// return OutStationApplyResult.ProductCompleted;
|
||||
// }
|
||||
// //如果正常件
|
||||
// if (product.ProductStatus == 2)
|
||||
// {
|
||||
// // 此工序未入站,禁止出站
|
||||
|
||||
// // 此工序未完成中间流程,禁止出站
|
||||
|
||||
|
||||
// //插入出站记录
|
||||
// ProductPassstationRecord passstationRecord = new ProductPassstationRecord
|
||||
// {
|
||||
// Workorder = product.Workorder,
|
||||
// Routingcode = product.RoutingCode,
|
||||
// ProductSN = product.ProductSN,
|
||||
// OperationCode = operationCode,
|
||||
// ProuductStatus = 3, // 出站状态
|
||||
// OutStationTime = DateTime.Now,
|
||||
// CreatedTime = DateTime.Now
|
||||
// };
|
||||
// Context.Insertable(passstationRecord).ExecuteCommand();
|
||||
// return OutStationApplyResult.Success;
|
||||
// }
|
||||
// //如果,返工件
|
||||
// if (product.ProductStatus == 3)
|
||||
// {
|
||||
// //插入出站记录
|
||||
// ProductPassstationRecord passstationRecord = new ProductPassstationRecord
|
||||
// {
|
||||
// Workorder = product.Workorder,
|
||||
// Routingcode = product.RoutingCode,
|
||||
// ProductSN = product.ProductSN,
|
||||
// OperationCode = operationCode,
|
||||
// ProuductStatus = 4, // 出站状态
|
||||
// OutStationTime = DateTime.Now,
|
||||
// CreatedTime = DateTime.Now
|
||||
// };
|
||||
// Context.Insertable(passstationRecord).ExecuteCommand();
|
||||
// return OutStationApplyResult.Success;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
return OutStationApplyResult.UnknownStatus;
|
||||
}
|
||||
// return OutStationApplyResult.UnknownStatus;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,13 +8,17 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MDM.Services.Session.IService
|
||||
{
|
||||
public interface ISessionManagerService
|
||||
public interface ISessionManagerService
|
||||
{
|
||||
|
||||
int StartWorkApply(string ProcessCode, string WorkOrder, string LineCode, string GroupCode);
|
||||
public int StartWorkApply(string ProcessCode, string WorkOrder);
|
||||
|
||||
InStationApplyResult InStationApply(string OperationCode, string ProcessCode);
|
||||
InStationApplyResult OntStationApply(string OperationCode, string ProcessCode);
|
||||
OutStationApplyResult OutStationApply(string OperationCode, string ProcessCode);
|
||||
|
||||
|
||||
int FinishWorkApply(string ProcessCode, string WorkOrder);
|
||||
int ReWorkApply(string ProcessCode, string WorkOrder);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -25,16 +25,12 @@ namespace MDM.Services.Session
|
||||
[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)
|
||||
public int StartWorkApply(string ProcessCode, string WorkOrder)
|
||||
{
|
||||
//校验重复开工
|
||||
bool isRepeat = Context.Queryable<ProductLifecycle>().Where(it => it.Workorder == WorkOrder && it.ProductSN == ProcessCode).Any();
|
||||
@ -45,17 +41,17 @@ namespace MDM.Services.Session
|
||||
}
|
||||
|
||||
//根据工单号查询工艺路线
|
||||
|
||||
ProWorkorder workorder = Context.Queryable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == WorkOrder).First();
|
||||
ProcessRouting processRouting = Context.Queryable<ProcessRouting>()
|
||||
.Where(it => it.FkProductMaterialCode == SqlFunc.Subqueryable<ProWorkorder>()
|
||||
.Where(it => it.Workorder == WorkOrder).Select(s => s.ProductionCode))
|
||||
.Where(it => it.FkProductMaterialCode == workorder.ProductionCode)
|
||||
.First();
|
||||
|
||||
ProductLifecycle lifecycle = new ProductLifecycle();
|
||||
lifecycle.Workorder = WorkOrder;
|
||||
lifecycle.ProductSN = ProcessCode;
|
||||
lifecycle.LineCode = LineCode;
|
||||
lifecycle.GroupCode = GroupCode;
|
||||
lifecycle.LineCode = workorder.LineCode;
|
||||
lifecycle.GroupCode = workorder.GroupCode;
|
||||
lifecycle.ProductStatus = 1;
|
||||
lifecycle.RoutingCode = processRouting.RoutingCode ?? "";
|
||||
lifecycle.ProductStartTime = DateTime.Now;
|
||||
@ -87,11 +83,12 @@ namespace MDM.Services.Session
|
||||
|
||||
if (lifecycle == null)
|
||||
{
|
||||
return InStationApplyResult.InvalidParameters;
|
||||
return InStationApplyResult.ProductNotStartWork;
|
||||
}
|
||||
|
||||
ProcessOperationFlow operationFlow = Context.Queryable<ProcessOperationFlow>()
|
||||
.Where(it => it.FkRoutingCode == lifecycle.RoutingCode && it.FkOperationCode == OperationCode)
|
||||
.Where(it => it.FlowTypeCode.Contains("intbound_flow"))
|
||||
.First();
|
||||
|
||||
if (operationFlow != null)
|
||||
@ -132,9 +129,119 @@ namespace MDM.Services.Session
|
||||
}
|
||||
|
||||
|
||||
public InStationApplyResult OntStationApply(string OperationCode, string ProcessCode)
|
||||
/// <summary>
|
||||
/// 出站申请
|
||||
/// </summary>
|
||||
/// <param name="OperationCode"></param>
|
||||
/// <param name="ProcessCode"></param>
|
||||
/// <returns></returns>
|
||||
public OutStationApplyResult OutStationApply(string OperationCode, string ProcessCode)
|
||||
{
|
||||
|
||||
// 查询本工序的 出站流程
|
||||
if (string.IsNullOrEmpty(OperationCode) && string.IsNullOrEmpty(ProcessCode))
|
||||
{
|
||||
return OutStationApplyResult.InvalidParameters;
|
||||
}
|
||||
|
||||
var lifecycle = Context.Queryable<ProductLifecycle>()
|
||||
.Where(it => it.ProductSN == ProcessCode)
|
||||
.First();
|
||||
|
||||
if (lifecycle == null)
|
||||
{
|
||||
return OutStationApplyResult.ProductNotStartWork;
|
||||
}
|
||||
|
||||
ProcessOperationFlow operationFlow = Context.Queryable<ProcessOperationFlow>()
|
||||
.Where(it => it.FkRoutingCode == lifecycle.RoutingCode && it.FkOperationCode == OperationCode)
|
||||
.Where(it => it.FlowTypeCode.Contains("outbound_flow"))
|
||||
.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 OutStationApplyResult applyResult)
|
||||
{
|
||||
return applyResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return OutStationApplyResult.UnknownStatus;
|
||||
}
|
||||
|
||||
|
||||
public int FinishWorkApply(string ProcessCode, string WorkOrder)
|
||||
{
|
||||
//校验重复完工
|
||||
bool isRepeat = Context.Queryable<ProductLifecycle>()
|
||||
.Where(it => it.Workorder == WorkOrder && it.ProductSN == ProcessCode)
|
||||
.Where(it => it.ProductStatus == 2)
|
||||
.Any();
|
||||
|
||||
if (isRepeat)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return Context.Updateable<ProductLifecycle>()
|
||||
.SetColumns(it => new ProductLifecycle()
|
||||
{
|
||||
ProductStatus = 2,
|
||||
ProductFinishTime = DateTime.Now,
|
||||
UpdatedTime = DateTime.Now
|
||||
})
|
||||
.Where(it => it.ProductSN == ProcessCode && it.Workorder == WorkOrder)
|
||||
.ExecuteCommand();
|
||||
|
||||
}
|
||||
public int ReWorkApply(string ProcessCode, string WorkOrder)
|
||||
{
|
||||
|
||||
//校验重复返工
|
||||
bool isRepeat = Context.Queryable<ProductLifecycle>()
|
||||
.Where(it => it.Workorder == WorkOrder && it.ProductSN == ProcessCode)
|
||||
.Where(it => it.ProductStatus == 3)
|
||||
.Any();
|
||||
|
||||
if (isRepeat)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return Context.Updateable<ProductLifecycle>()
|
||||
.SetColumns(it => new ProductLifecycle()
|
||||
{
|
||||
ProductStatus = 3,
|
||||
ProductFinishTime = DateTime.Now,
|
||||
UpdatedTime = DateTime.Now
|
||||
})
|
||||
.Where(it => it.ProductSN == ProcessCode && it.Workorder == WorkOrder)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user