|
|
using Estsh.Core.Model.EnumUtil;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Quartz.BaseService;
|
|
|
using Estsh.Core.Util;
|
|
|
using Estsh.Core.Wms.IRepositories;
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
namespace Estsh.Core.Wms.Jobs
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 处理成品下线报工业务
|
|
|
/// </summary>
|
|
|
public class OutPdlineJob : IJobService
|
|
|
{
|
|
|
private readonly IOutPdlineRepository repository;
|
|
|
private readonly IPdlineRepository pdlineRepository;
|
|
|
private readonly IBomRepository bomRepository;
|
|
|
|
|
|
public OutPdlineJob(IOutPdlineRepository _repository,
|
|
|
IPdlineRepository _pdlineRepository,
|
|
|
IBomRepository _bomRepository)
|
|
|
{
|
|
|
this.repository = _repository;
|
|
|
this.pdlineRepository = _pdlineRepository;
|
|
|
this.bomRepository = _bomRepository;
|
|
|
|
|
|
}
|
|
|
|
|
|
public string ExecuteService(string parameter)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(parameter))
|
|
|
{
|
|
|
return "需要配置产线代码!";
|
|
|
}
|
|
|
List<MesWmsOutPdline> wmsRetrs = repository.GetFinishedLineOffInfo(parameter);
|
|
|
if (wmsRetrs.Count > 0)
|
|
|
{
|
|
|
repository.InsertFinishedLineOffInfo(wmsRetrs); // "没有待处理的成品下线数据!";
|
|
|
}
|
|
|
|
|
|
List<MesOutPdline> outPdlines = repository.GetOutPdlineInfo(parameter);
|
|
|
if (outPdlines.Count <= 0)
|
|
|
{
|
|
|
return "没有待报工数据!";
|
|
|
}
|
|
|
List<SysPdline> pdlines = pdlineRepository.GetPdlineInfo();
|
|
|
|
|
|
//LogHelper.Info("当前操作:开始本次执行《成品下线JOB》,共计"+ outPdlines.Count+ "条下线数据,当前时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
|
List<SysBomDetail> bomDetails = bomRepository.GetReportBomInfo("");//查BOM信息作为实体查询
|
|
|
foreach (var outPdline in outPdlines)
|
|
|
{
|
|
|
//LogHelper.Info("当前操作:开始执行第" + (outPdlines.IndexOf(outPdline)+1) + "条," + outPdline.SerialNumber + "条码(判断是否有库位),当前时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
List<SysBomDetail> bomDetail = bomDetails.Where(a => a.PartId == outPdline.PartId).ToList();
|
|
|
if (bomDetail.Count <= 0)
|
|
|
{
|
|
|
repository.UpdateOutPdlineInfo(outPdline, MesEnumUtil.OutPdlineReportStatus.EXCEPTION, "找不到BOM信息!");
|
|
|
continue;
|
|
|
}
|
|
|
var pdline = pdlines.Where(a => a.PdlineCode == outPdline.PdlineCode).FirstOrDefault();
|
|
|
if (outPdline.ProductType == (int)MesEnumUtil.OutPdlineProductType.FINISHED_PRODUCT &&
|
|
|
(pdline == null || string.IsNullOrEmpty(pdline.DestLocateName)))
|
|
|
{
|
|
|
repository.UpdateOutPdlineInfo(outPdline, MesEnumUtil.OutPdlineReportStatus.EXCEPTION, "成品入库找不到产线默认的入库库位!");
|
|
|
continue;
|
|
|
}
|
|
|
if (outPdline.ProductType == (int)MesEnumUtil.OutPdlineProductType.WIP &&
|
|
|
(pdline == null || string.IsNullOrEmpty(pdline.DestLocateName)))
|
|
|
{
|
|
|
repository.UpdateOutPdlineInfo(outPdline, MesEnumUtil.OutPdlineReportStatus.EXCEPTION, "半成品入库找不到产线默认的入库库位!");
|
|
|
continue;
|
|
|
}
|
|
|
//LogHelper.Info("当前操作:结束执行第" + (outPdlines.IndexOf(outPdline) + 1) + "条," + outPdline.SerialNumber + "条码(判断是否有库位),当前时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
//LogHelper.Info("当前操作:开始执行第" + (outPdlines.IndexOf(outPdline) + 1) + "条," + outPdline.SerialNumber + "条码(逻辑处理),当前时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
repository.DoOutPdline(outPdline, bomDetail, pdline, bomDetails);
|
|
|
//LogHelper.Info("当前操作:结束执行第" + (outPdlines.IndexOf(outPdline) + 1) + "条," + outPdline.SerialNumber + "条码(逻辑处理),当前时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
}
|
|
|
//LogHelper.Info("当前操作:结束执行《成品下线JOB》,当前时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
return "成品下线报工成功!";
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("成品下线报工错误!" + ex);
|
|
|
return "成品下线报工错误!" + ex.Message;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|