|
|
|
|
using Aucma.Scada.Model.domain;
|
|
|
|
|
using HighWayIot.Common;
|
|
|
|
|
using HighWayIot.Log4net;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Linq.Expressions;
|
|
|
|
|
|
|
|
|
|
namespace HighWayIot.Repository.service.Impl
|
|
|
|
|
{
|
|
|
|
|
public class ExecutePlanInfoServiceImpl : IExecutePlanInfoService
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private Repository<ExecutePlanInfo> _scadaRepository = new Repository<ExecutePlanInfo>("scada");
|
|
|
|
|
|
|
|
|
|
private Repository<dynamic> _mesRepository = new Repository<dynamic>("mes");
|
|
|
|
|
|
|
|
|
|
private LogHelper logHelper = LogHelper.Instance;
|
|
|
|
|
|
|
|
|
|
private JsonChange jsonChange = JsonChange.Instance;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过产线工位获取执行顺序(默认+1)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="productLineCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public int GetExecuteOrderByProductLineCode(string productLineCode)
|
|
|
|
|
{
|
|
|
|
|
int result = 0;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Expression<Func<ExecutePlanInfo, bool>> exp = s1 => true;
|
|
|
|
|
exp = exp.And(x => x.productLineCode == productLineCode);
|
|
|
|
|
|
|
|
|
|
List<ExecutePlanInfo> planInfos = _scadaRepository.GetList(exp);
|
|
|
|
|
|
|
|
|
|
int order = planInfos.OrderByDescending(x => x.executeOrder).First().executeOrder;
|
|
|
|
|
|
|
|
|
|
result = order + 1;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("通过产线工位获取执行顺异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过执行计划编号获取执行计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="executePlanCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public ExecutePlanInfo GetExecutePlanInfoByPlanCode(string executePlanCode)
|
|
|
|
|
{
|
|
|
|
|
ExecutePlanInfo planInfo = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Expression<Func<ExecutePlanInfo, bool>> exp = s1 => true;
|
|
|
|
|
exp = exp.And(x => x.executePlanCode == executePlanCode);
|
|
|
|
|
|
|
|
|
|
planInfo = _scadaRepository.GetFirst(exp);
|
|
|
|
|
|
|
|
|
|
logHelper.Info($"根据执行计划编号{executePlanCode};获取到的执行计划信息:{jsonChange.ModeToJson(planInfo)}");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("通过执行计划编号获取执行计划异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return planInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过产线工位获取执行计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="productLineCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<ExecutePlanInfo> GetExecutePlanInfosByProductLineCode(string productLineCode)
|
|
|
|
|
{
|
|
|
|
|
List<ExecutePlanInfo> planInfos = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Expression<Func<ExecutePlanInfo, bool>> exp = s1 => true;
|
|
|
|
|
exp = exp.And(x => x.productLineCode == productLineCode);
|
|
|
|
|
|
|
|
|
|
planInfos = _scadaRepository.GetList(exp);
|
|
|
|
|
|
|
|
|
|
logHelper.Info($"根据产线工位编号:{productLineCode};获取到的执行计划信息:{jsonChange.ModeToJson(planInfos)}");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("通过产线工位获取执行计划异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return planInfos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过生产计划编号获取执行计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="productPlanCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<ExecutePlanInfo> GetExecutePlanInfosByProductPlanCode(string productPlanCode)
|
|
|
|
|
{
|
|
|
|
|
List<ExecutePlanInfo> planInfos = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Expression<Func<ExecutePlanInfo, bool>> exp = s1 => true;
|
|
|
|
|
exp = exp.And(x => x.productPlanCode == productPlanCode);
|
|
|
|
|
|
|
|
|
|
planInfos = _scadaRepository.GetList(exp);
|
|
|
|
|
|
|
|
|
|
logHelper.Info($"根据生产计划编号:{productPlanCode};获取到的执行计划信息:{jsonChange.ModeToJson(planInfos)}");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("通过生产计划编号获取执行计划异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return planInfos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 新增执行计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="executePlanInfo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool InsertExecutePlanInfo(ExecutePlanInfo executePlanInfo)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
result = _scadaRepository.Insert(executePlanInfo);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("新增执行计划异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 修改执行计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="executePlanInfo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool UpdateExecutePlanInfo(ExecutePlanInfo executePlanInfo)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
result = _scadaRepository.Update(executePlanInfo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("修改执行计划异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量修改执行计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="executePlanInfos"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool UpdateRangeExecutePlanInfo(List<ExecutePlanInfo> executePlanInfos)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
result = _scadaRepository.UpdateRange(executePlanInfos);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("修改执行计划异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据执行计划编号删除执行计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="executePlanCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool DeleteExecutePlanInfoByPlanCode(string executePlanCode)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ExecutePlanInfo planInfo = this.GetExecutePlanInfoByPlanCode(executePlanCode);
|
|
|
|
|
|
|
|
|
|
result = _scadaRepository.Delete(planInfo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("根据执行计划编号删除执行计划异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<dynamic> GetStationHourAmount(string stationCode)
|
|
|
|
|
{
|
|
|
|
|
List<dynamic> result = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var _db = _mesRepository.Context;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = _db.Queryable<dynamic>().AS("GET_STATION_HOURAMOUNT").Where("PRODUCTLINE_CODE = @stationCode", new { stationCode = stationCode }).ToList();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("获取小时产量数据异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<dynamic> GetStationMaterialStats(string stationCode)
|
|
|
|
|
{
|
|
|
|
|
List<dynamic> result = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var _db = _mesRepository.Context;
|
|
|
|
|
|
|
|
|
|
result = _db.Queryable<dynamic>().AS("GET_STATION_MATERIALSTATS").Where("PRODUCTLINE_CODE = @stationCode", new { stationCode = stationCode }).ToList();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("获取型号统计数据异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|