using iWareCc.Conveyor.EnumType;
|
using iWareCc.DecomposeTask.Entity;
|
using iWareCc.Properties;
|
using iWareCommon.Common.Entity;
|
using iWareCommon.Common.EnumType;
|
using iWareCommon.Utils;
|
using iWareDataCore.ORM;
|
using iWareDataCore.TASK.Entity;
|
using iWareDataCore.TASK.EnumType;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace iWareCc.CreateOutMainTask.chain
|
{
|
public class 生成出库主任务 : IHandler
|
{
|
/// <summary>
|
/// 该节点的下一个节点
|
/// </summary>
|
private IHandler nextHandler = null;
|
public IHandler NextHandler
|
{
|
set { nextHandler = value; }
|
}
|
|
private MainTaskContainer MainTaskContainer;
|
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
/// <param name="resultContainer">结果容器</param>
|
/// <param name="decompositionTaskContainer">WIP任务容器</param>
|
public 生成出库主任务(MainTaskContainer mainTaskContainer)
|
{
|
this.MainTaskContainer = mainTaskContainer;
|
}
|
|
|
public void Handle()
|
{
|
|
using (var dbModel = new DbModelCore())
|
{
|
try
|
{
|
|
|
var inoutlistdetail = dbModel.BASEInOutListDetailViews.FirstOrDefault(x => x.isfinish == 0 && x.typename == "出库");
|
if (inoutlistdetail == null)
|
{
|
|
LogTextHelper.WriteLine(Resources.LogDir + @"/自动生成出库主任务流程", "在出库批次中未找到要出库的任务");
|
return;
|
}
|
string materialcode = inoutlistdetail.materialcode;
|
var placematerial = dbModel.BASEPlaceMaterialViews.FirstOrDefault(x => x.materialcode == materialcode);
|
if (placematerial == null)
|
{
|
inoutlistdetail.isfinish = 1;
|
dbModel.SaveChanges();
|
// alarm.SendGateAlarmTask((int)ESendCode.已在立库中不能入库);
|
LogTextHelper.WriteLine(Resources.LogDir + @"/自动生成出库主任务流程", "物料号:{0}", materialcode + "不在立库中");
|
return;
|
}
|
var tasknew = dbModel.TASKPartTasks.FirstOrDefault(x => x.type == (int)EPartTaskType.输送机任务 && x.isreleased == (int)EYesOrNo.否 && x.isfinished == (int)EYesOrNo.否 && x.materialcode == materialcode && x.maintasktype == (int)EMainTaskType.出库任务);
|
if (tasknew != null)
|
{
|
LogTextHelper.WriteLine(Resources.LogDir + @"/自动生成出库主任务流程", "物料号:{0}", materialcode + "已在要执行的任务序列中");
|
return;
|
}
|
var task = dbModel.TASKMainTasks.FirstOrDefault(x => x.materialcode == materialcode && x.tasktype == (int)EMainTaskType.出库任务 && x.status == 0);
|
if (task != null)
|
{
|
LogTextHelper.WriteLine(Resources.LogDir + @"/自动生成出库主任务流程", "物料号:{0}", "该任务已存在");
|
return;
|
}
|
TASKMainTask matask = new TASKMainTask()
|
{
|
taskno = DateTime.Now.ToFileTime().ToString(),
|
tasktype = (int)EMainTaskType.出库任务,
|
materialcode = materialcode,
|
syscode = "1",
|
sendtime = DateTime.Now,
|
sourceplace = "100101",
|
toplace = inoutlistdetail.placecode,
|
packageno = "",
|
processcardnumber = "",
|
quantity = 1,
|
status = 0,
|
decompositiontime = DateTime.Now,
|
wipstatus = 0,
|
decompositiontimes = 0,
|
islots = 0,
|
priority = 0,
|
|
|
//赋值 【Editby shaocx,2025-09-29】
|
InOutListDetailId = inoutlistdetail.id,
|
ListNo = inoutlistdetail.listno,
|
};
|
MainTaskContainer.MainTask = new MainTaskEntity(matask);
|
|
if (nextHandler != null)
|
{
|
nextHandler.Handle();
|
}
|
|
}
|
catch (Exception ex)
|
{
|
LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "Handle", ex.Message);
|
}
|
}
|
}
|
}
|
}
|