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 {
///
/// [ 具体业务 ] 帮助类
///
public class WMSHelper {
///
/// 检查容器类型
///
///
///
///
///
public static (bool, string) CheckCntrType(string cntrCode, string cntrType, out TN_Container cntr) {
var db = new SqlHelper().GetInstance();
cntr = db.Queryable().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, "检查容器类型成功!!");
}
///
///
///
///
///
///
///
public static (bool, string) FindStartLocUnbind(string locCode, List areas, out TN_Location startLoc) {
var db = new SqlHelper().GetInstance();
startLoc = db.Queryable().Where(DbExpr.StartLocUnbind(locCode, areas)).First();
if (startLoc == null) {
return (false, LogMsg.StartLocUnbindNotFound(locCode, areas));
}
return (true, "");
}
///
/// 根据容器号 , 查找旧的货位 / 货位绑定 / 物料信息 ( 将待删除 / 更新数据写入 obj )
///
///
///
///
///
///
public static LocCntrCg FindCntrOldInfo(CreateTaskObj obj, string cntrCode, bool skipCgDetail = true) {
var oldLocCntrCg = WCSHelper.GetLocCntrCg(cntrCode, skipCgDetail);
obj.Old = oldLocCntrCg;
return oldLocCntrCg;
}
///
/// 绑定货位容器 ( 修改 [ 货位容器表 ] [ 货位类型 ] = cntrType ; 将 [ 待插入 ] 货位容器关系 加入到 obj 中 )
///
///
///
///
///
///
///
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;
}
///
/// 创建任务 ( 构造任务项 / 起点终点上锁 ; 将 插入任务 / 更新货位 的对象写入 obj )
///
///
///
///
///
///
///
///
///
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;
}
}
}