You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
159 lines
5.2 KiB
C#
159 lines
5.2 KiB
C#
using Admin.Core.Common;
|
|
using Admin.Core.IRepository;
|
|
using Admin.Core.IService;
|
|
using Admin.Core.Model;
|
|
using Admin.Core.Model.Model_New;
|
|
using log4net;
|
|
using Microsoft.IdentityModel.Logging;
|
|
using StackExchange.Profiling.Internal;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Admin.Core.Service
|
|
{
|
|
public class ProductPlanInfoServices : BaseServices<ProductPlanInfo>, IProductPlanInfoServices
|
|
{
|
|
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(ProductPlanInfoServices));
|
|
private readonly IBaseRepository<ProductPlanInfo> _dal;
|
|
private readonly IBaseOrderInfoRepository _baseOrderInfoRepository;
|
|
|
|
public ProductPlanInfoServices(IBaseRepository<ProductPlanInfo> dal, IBaseOrderInfoRepository baseOrderInfoRepository)
|
|
{
|
|
this._dal = dal;
|
|
base.BaseDal = dal;
|
|
_baseOrderInfoRepository = baseOrderInfoRepository;
|
|
}
|
|
|
|
#region 查询计划执行信息
|
|
/// <summary>
|
|
/// 查询计划执行信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task<List<PlanMaintenanceView>> QueryPlanInfo(string station)
|
|
{
|
|
List<ProductPlanInfo> planList = await _dal.QueryAsync(d => d.ProductLineCode == station);
|
|
|
|
var list = (from p in planList
|
|
select new PlanMaintenanceView
|
|
{
|
|
PlanCode = p.PlanCode,
|
|
OrderCode = p.OrderCode,
|
|
MaterialCode = p.MaterialCode,
|
|
MaterialName = p.MaterialName,
|
|
PlanAmount = p.PlanAmount,
|
|
ResidueAmount = p.PlanAmount - p.CompleteAmount
|
|
}).ToList();
|
|
|
|
return list;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 通过计划编号获取计划信息
|
|
/// <summary>
|
|
/// 通过计划编号获取计划信息
|
|
/// </summary>
|
|
/// <param name="planCode"></param>
|
|
/// <returns></returns>
|
|
public async Task<ProductPlanInfo> GetProductPlanByPlanCode(string planCode)
|
|
{
|
|
ProductPlanInfo planInfo = null;
|
|
try
|
|
{
|
|
//Expression<Func<ProductPlanInfo, bool>> exp = s1 => true;
|
|
//exp = exp.And(x => x.PlanCode == planCode);
|
|
|
|
//var info = await _dal.QueryAsync(exp);
|
|
|
|
var info = _dal.Query(x=>x.PlanCode == planCode);
|
|
|
|
if (info != null)
|
|
{
|
|
planInfo = info.OrderBy(x => x.CreatedTime).First();
|
|
}
|
|
|
|
//logHelper.Info($"根据计划编号{planCode};获取到的计划信息:{planInfo.ToJson()}");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logHelper.Error("通过计划编号获取计划信息异常", ex);
|
|
}
|
|
return planInfo;
|
|
}
|
|
#endregion
|
|
|
|
#region 通过产线工位获取生产计划
|
|
/// <summary>
|
|
/// 通过产线工位获取生产计划
|
|
/// </summary>
|
|
/// <param name="productLineCode"></param>
|
|
/// <returns></returns>
|
|
public async Task<List<ProductPlanInfo>> GetProductPlanInfosByProductLineCode(string productLineCode)
|
|
{
|
|
List<ProductPlanInfo> planInfos = null;
|
|
try
|
|
{
|
|
Expression<Func<ProductPlanInfo, bool>> exp = s1 => true;
|
|
exp = exp.And(x => x.ProductLineCode == productLineCode);
|
|
|
|
planInfos = await _dal.QueryAsync(exp);
|
|
|
|
logHelper.Info($"根据产线工位编号:{productLineCode};获取到的计划信息:{planInfos.ToJson()}");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logHelper.Error("通过产线工位获取生产计划异常", ex);
|
|
}
|
|
return planInfos;
|
|
}
|
|
#endregion
|
|
|
|
#region 添加生产计划
|
|
/// <summary>
|
|
/// 添加生产计划
|
|
/// </summary>
|
|
/// <param name="productPlanInfo"></param>
|
|
/// <returns></returns>
|
|
public async Task<bool> InsertProductPlanInfo(ProductPlanInfo productPlanInfo)
|
|
{
|
|
bool result = false;
|
|
try
|
|
{
|
|
int r = await _dal.AddAsync(productPlanInfo);
|
|
if (r > 0) result = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logHelper.Error("添加生产计划异常", ex);
|
|
}
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 修改生产计划
|
|
/// <summary>
|
|
/// 修改生产计划
|
|
/// </summary>
|
|
/// <param name="productPlanInfo"></param>
|
|
/// <returns></returns>
|
|
public async Task<bool> UpdateProductPlanInfo(ProductPlanInfo productPlanInfo)
|
|
{
|
|
bool result = false;
|
|
try
|
|
{
|
|
result = await _dal.UpdateAsync(productPlanInfo);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logHelper.Error("修改生产计划异常", ex);
|
|
}
|
|
return result;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|