using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Security.Cryptography;
|
using System.Text;
|
using System.Threading.Tasks;
|
using HH.WCS.Mobox3.DSZSH.models;
|
using HH.WCS.Mobox3.DSZSH.util;
|
using Newtonsoft.Json;
|
using static HH.WCS.Mobox3.DSZSH.api.ApiModel;
|
using static HH.WCS.Mobox3.DSZSH.util.Config;
|
|
namespace HH.WCS.Mobox3.DSZSH.wms {
|
/// <summary>
|
/// [ 具体业务 ] 帮助类
|
/// </summary>
|
public class WMSHelper {
|
/// <summary>
|
/// 检查容器类型
|
/// </summary>
|
/// <param name="cntrCode"></param>
|
/// <param name="cntrType"></param>
|
/// <param name="cntr"></param>
|
/// <returns></returns>
|
public static (bool, string) CheckCntrType(string cntrCode, string cntrType, out TN_Container cntr) {
|
var db = new SqlHelper<object>().GetInstance();
|
|
cntr = db.Queryable<TN_Container>().Where(c => c.S_CODE == cntrCode).First();
|
if (cntr == null) {
|
return (false, $"容器'{cntrCode}'在[容器表]中不存在,请在前台页面中维护!!");
|
}
|
if (cntr.S_TYPE != cntrType) {
|
return (false, $"容器'{cntrCode}'在[容器表]中的类型为'{cntr.S_TYPE}',与当前流程所需容器类型'{cntrType}'不同!!");
|
}
|
return (true, "检查容器类型成功!!");
|
}
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="locCode"></param>
|
/// <param name="areas"></param>
|
/// <param name="startLoc"></param>
|
/// <returns></returns>
|
public static (bool, string) FindStartLocUnbind(string locCode, List<string> areas, out TN_Location startLoc) {
|
var db = new SqlHelper<object>().GetInstance();
|
startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLocUnbind(locCode, areas)).First();
|
if (startLoc == null) {
|
return (false, LogMsg.StartLocUnbindNotFound(locCode, areas));
|
}
|
return (true, "");
|
}
|
/// <summary>
|
/// 根据容器号 , 查找旧的货位 / 货位绑定 / 物料信息 ( 将待删除 / 更新数据写入 obj )
|
/// </summary>
|
/// <remarks><code><![CDATA[obj.Old = oldLocCntrCg;]]></code></remarks>
|
/// <param name="obj"></param>
|
/// <param name="cntrCode"></param>
|
/// <param name="skipCgDetail"></param>
|
/// <returns></returns>
|
public static LocCntrCg FindCntrOldInfo(CreateTaskObj obj, string cntrCode, bool skipCgDetail = true) {
|
var oldLocCntrCg = WCSHelper.GetLocCntrCg(cntrCode, skipCgDetail);
|
obj.Old = oldLocCntrCg;
|
return oldLocCntrCg;
|
}
|
/// <summary>
|
/// 绑定货位容器 ( 修改 [ 货位容器表 ] [ 货位类型 ] = cntrType ; 将 [ 待插入 ] 货位容器关系 加入到 obj 中 )
|
/// </summary>
|
/// <remarks><code><![CDATA[obj.New = new LocCntrCg { LocCntrRel = locCntrRel };]]></code></remarks>
|
/// <param name="obj"></param>
|
/// <param name="loc"></param>
|
/// <param name="cntrCode"></param>
|
/// <param name="cntrType"></param>
|
/// <returns></returns>
|
public static TN_Loc_Container BindLocCntr(CreateTaskObj obj, TN_Location loc, string cntrCode, string cntrType = "") {
|
var locCntrRel = WCSHelper.BindLocCntr(loc, cntrCode);
|
if (!string.IsNullOrEmpty(cntrType)) {
|
locCntrRel.S_CNTR_TYPE = cntrType;
|
}
|
obj.New = new LocCntrCg { LocCntrRel = locCntrRel };
|
return locCntrRel;
|
}
|
/// <summary>
|
/// 创建任务 ( 构造任务项 / 起点终点上锁 ; 将 插入任务 / 更新货位 的对象写入 obj )
|
/// </summary>
|
/// <remarks><code><![CDATA[
|
/// obj.TaskToInsert = task;
|
/// obj.StartLocToUpdate = startLoc;
|
/// obj.EndLocToUpdate = endLoc;
|
/// ]]></code></remarks>
|
/// <param name="obj"></param>
|
/// <param name="startLoc"></param>
|
/// <param name="endLoc"></param>
|
/// <param name="cntId"></param>
|
/// <param name="type"></param>
|
/// <param name="pri"></param>
|
/// <param name="agv"></param>
|
public static TN_Task CreateTask(CreateTaskObj obj, TN_Location startLoc, TN_Location endLoc, string cntId, string type,
|
int pri = 3, int agv = 1) {
|
|
var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, type, pri);
|
WCSHelper.LockStartLoc(startLoc, task.S_CODE);
|
WCSHelper.LockEndLoc(endLoc, task.S_CODE);
|
|
obj.TaskToInsert = task;
|
obj.StartLocToUpdate = startLoc;
|
obj.EndLocToUpdate = endLoc;
|
|
return task;
|
}
|
}
|
}
|