|
|
using Estsh.Core.Model.EnumUtil;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Quartz.BaseService;
|
|
|
using Estsh.Core.Util;
|
|
|
using Estsh.Core.Wms.IRepositories;
|
|
|
|
|
|
namespace Estsh.Core.Wms.Jobs
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 处理成品下线报工业务--滑轨
|
|
|
/// </summary>
|
|
|
public class OutPdlineHGJob : IJobService
|
|
|
{
|
|
|
private readonly IOutPdlineHgRepository repository;
|
|
|
private readonly IPdlineRepository pdlineRepository;
|
|
|
private readonly IBomRepository bomRepository;
|
|
|
|
|
|
public OutPdlineHGJob(IOutPdlineHgRepository _repository,
|
|
|
IPdlineRepository _pdlineRepository,
|
|
|
IBomRepository _bomRepository)
|
|
|
{
|
|
|
this.repository = _repository;
|
|
|
this.pdlineRepository = _pdlineRepository;
|
|
|
this.bomRepository = _bomRepository;
|
|
|
|
|
|
}
|
|
|
|
|
|
public string ExecuteService(string parameter)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
List<MesWmsHgOutPdline> wmsRetrs = repository.GetFinishedLineOffInfo();
|
|
|
if (wmsRetrs.Count > 0)
|
|
|
{
|
|
|
repository.InsertFinishedLineOffInfo(wmsRetrs); // "没有待处理的成品下线数据!";
|
|
|
}
|
|
|
|
|
|
List<MesHgOutPdline> outPdlines = repository.GetOutPdlineInfo();
|
|
|
if (outPdlines.Count <= 0)
|
|
|
{
|
|
|
return "没有待报工数据!";
|
|
|
}
|
|
|
List<SysPdline> pdlines = pdlineRepository.GetPdlineInfo();
|
|
|
|
|
|
List<SysBomDetail> bomDetailList = bomRepository.GetReportBomInfo("");
|
|
|
foreach (var outPdline in outPdlines)
|
|
|
{
|
|
|
List<SysBomDetail> bomDetails = bomDetailList.Where(a => a.PartId == outPdline.PartId).ToList();
|
|
|
if (bomDetails.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;
|
|
|
}
|
|
|
repository.DoOutPdline(outPdline, bomDetails, pdline, bomDetailList);
|
|
|
}
|
|
|
return "滑轨下线报工成功!";
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("滑轨下线报工错误!" + ex);
|
|
|
return "滑轨下线报工错误!" + ex.Message;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|