using HH.WCS.Mobox3.HD.core;
|
using HH.WCS.Mobox3.HD.device;
|
using HH.WCS.Mobox3.HD.models;
|
using HH.WCS.Mobox3.HD.util;
|
using Newtonsoft.Json;
|
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Reflection;
|
using System.ServiceProcess;
|
using static HH.WCS.Mobox3.HD.api.WmsController;
|
using static HH.WCS.Mobox3.HD.core.MQTTCore;
|
using static HH.WCS.Mobox3.HD.util.Settings;
|
|
namespace HH.WCS.Mobox3.HD.wms
|
{
|
internal class LocationHelper
|
{
|
public class LocationExt
|
{
|
public string S_PICKUP_POINT { get; internal set; }
|
public string S_LOC_CODE { get; internal set; }
|
public string S_AGV_SITE { get; internal set; }
|
}
|
private static Dictionary<string, Location> Locations = null;
|
private static Dictionary<string, LocationExt> LocationExts = null;
|
|
static LocationHelper()
|
{
|
try
|
{
|
//初始化Location加入到字典缓存
|
Locations = new Dictionary<string, Location>();
|
var list = GetAllLocList();
|
if (list.Count > 0)
|
{
|
list.ForEach(a =>
|
{
|
if (!Locations.ContainsKey(a.S_CODE))
|
{
|
Locations.Add(a.S_CODE, a);
|
}
|
});
|
}
|
//初始化LocationExt加入到集合缓存
|
//LocationExts = new Dictionary<string, LocationExt>();
|
//var exts = GetAllLocExtList();
|
//if (exts.Count > 0) {
|
// exts.ForEach(a => {
|
// var key = $"{a.S_LOC_CODE.Trim()}_{a.S_PICKUP_POINT.Trim()}";
|
// if (!LocationExts.ContainsKey(key)) {
|
// LocationExts.Add(key, a);
|
|
// }
|
// });
|
//}
|
}
|
catch (Exception ex)
|
{
|
Console.WriteLine(ex.Message);
|
}
|
}
|
|
internal static bool CheckExist(string loc)
|
{
|
return Locations.Keys.Contains(loc);
|
}
|
internal static Location GetLocation(string loc)
|
{
|
/*if (CheckExist(loc.Trim()))
|
{
|
return Locations[loc.Trim()];
|
}*/
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<Location>().Where(a => a.S_CODE == loc).Includes(a => a.LocCntrRel ,a => a.CntrItemRel).First();
|
}
|
internal static List<FunctionArea> GetFunctionAreas(string masterCls, string msterCode)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<FunctionArea>().Where(a => a.S_MASTER_CLS == masterCls && a.S_MASTER_CODE == msterCode).ToList();
|
}
|
internal static List<FunctionArea> GetFunctionAreas(string masterCls, string msterCode, int nType)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<FunctionArea>().Where(a => a.S_MASTER_CLS == masterCls && a.S_MASTER_CODE == msterCode && a.N_TYPE == nType).ToList();
|
}
|
internal static FunctionArea GetFunctionAreaByCode(string faCode, int faType, int nType)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
// && a.N_FA_TYPE == faType
|
return db.Queryable<FunctionArea>().Where(a => a.S_FA_CODE == faCode && a.N_TYPE == nType).First();
|
}
|
/// <summary>
|
/// 获取货位站点信息
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <returns></returns>
|
internal static string GetAgvSite(string loc)
|
{
|
var site = "0";
|
if (Locations.Keys.Contains(loc.Trim()))
|
{
|
var Location = Locations[loc.Trim()];
|
site = Location.S_AGV_SITE;
|
}
|
else
|
{
|
var Location = GetLoc(loc.Trim());
|
if (Location != null)
|
{
|
Locations.Add(loc.Trim(), Location);
|
site = Location.S_AGV_SITE;
|
}
|
}
|
return site;
|
}
|
|
internal static int GetAgvSite(string loc, string actionType)
|
{
|
var site = 0;
|
var key = $"{loc.Trim()}_{actionType.Trim()}";
|
if (LocationExts.Keys.Contains(loc.Trim()))
|
{
|
var Location = LocationExts[loc.Trim()];
|
site = int.Parse(Location.S_AGV_SITE);
|
}
|
return site;
|
}
|
|
internal static object connect_lock = new object();
|
|
/// <summary>
|
/// 查询库区接驳位(未上锁)
|
/// actType 1、入库 2.出库
|
/// roadway 巷道选择排序 1.顺序 2.倒叙
|
/// lockFlag 0.未上锁货位 1.全部(不区分是否上锁)
|
/// 入库 - 先获取接驳位,后选定入库终点货位
|
/// 出库 - 先选定出库物料货位,后获取接驳位
|
/// </summary>
|
/// <returns></returns>
|
internal static List<string> GetConnectLocation(string areaCode ,int actType ,int roadway = 1 , int lockFlag = 0 , string externalArea = null) {
|
LogHelper.Info($"库区:{areaCode},巷道:{roadway}", "Mobox");
|
lock (connect_lock) {
|
StoreAreaInfo storeAreaInfo = Settings.storeAreaInfos.Where(a => a.areaCode == areaCode).FirstOrDefault();
|
if (storeAreaInfo != null)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
var query = db.Queryable<Location>()
|
/* .LeftJoin<FunctionArea>((a, b) => a.S_CODE == b.S_FA_CODE && b.N_FA_TYPE == 1)*/
|
.LeftJoin<LinePlcInfo>((a, b) => a.S_CODE == b.localtion && b.deviceType == 1)
|
.LeftJoin<WCSTask>((a, b, c) => a.S_CODE == c.S_END_LOC && c.N_B_STATE < 3)
|
.Where((a, b, c) => a.S_AREA_CODE == storeAreaInfo.accessArea && a.N_LOCK_STATE != 3 && a.C_ENABLE == "Y" );
|
|
if (lockFlag == 0) {
|
query.Where((a, b, c) => a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM == 0);
|
}
|
|
List<string> areaCodes = Settings.getStoreAreaCodes(2, 1);
|
if (areaCodes.Contains(areaCode))
|
{
|
if (actType == 1)
|
{
|
query = query.Where((a, b, c) => b.actType == "入库" && b.sort == 1);
|
}
|
else if (actType == 2)
|
{
|
// 出库需选择巷道
|
query = query.Where((a, b, c) => a.N_ROADWAY == roadway && b.actType == "出库" && b.sort == 1);
|
}
|
}
|
|
// 查询空货位最多的巷道,优先入库
|
var lessRoadwayMap = db.Queryable<Location>()
|
.Where(a => a.N_CURRENT_NUM == 0 && a.S_AREA_CODE == areaCode)
|
.GroupBy(a => a.N_ROADWAY)
|
.Select(a => new { roadway = a.N_ROADWAY, count = SqlFunc.AggregateCount(a.S_CODE), })
|
.OrderByDescending(a => a.count)
|
.First();
|
|
int lessRoadway = 0;
|
if (lessRoadwayMap != null) {
|
lessRoadway = lessRoadwayMap.roadway;
|
}
|
|
// 对接驳位按任务数量排序
|
var conLocList = query.GroupBy((a, b, c) => new { a.S_CODE , a.N_ROW ,a.N_ROADWAY })
|
.Select((a, b, c) => new {
|
count = SqlFunc.AggregateCount(c.S_END_LOC),
|
name = a.S_CODE,
|
row = a.N_ROW,
|
roadway = a.N_ROADWAY,
|
})
|
.MergeTable()//需要加MergeTable才能排序统计过的列
|
.OrderBy(it => it.count)
|
.OrderByDescending(it => it.roadway == lessRoadway ? 1 : 0)
|
.ToList();
|
|
LogHelper.Info("接驳点排序顺序1:" + JsonConvert.SerializeObject(conLocList), "Mobox");
|
|
// 优先从关联接驳位出入库
|
LogHelper.Info("查询物流库区关联关系入参,externalArea:" + externalArea + ",actType:" + actType + ",areaCode:" + areaCode, "Mobox");
|
var areaRelevance = WMSHelper.getAreaRelevance(externalArea, actType, areaCode);
|
if (areaRelevance != null) {
|
LogHelper.Info("物流库区关联关系:" + JsonConvert.SerializeObject(areaRelevance), "Mobox");
|
conLocList = conLocList.OrderByDescending(it => it.count < 2).ThenByDescending(it => it.row == areaRelevance.N_CON_ROW).ThenBy(it => it.count).ThenByDescending(it => it.roadway == lessRoadway).ToList();
|
LogHelper.Info("接驳点排序顺序2:" + JsonConvert.SerializeObject(conLocList), "Mobox");
|
}
|
|
// 输送线处于非正常状态,停止向输送线分配任务
|
List<string> locCodeList = conLocList.Select(a => a.name).ToList();
|
string faultInfo = "";
|
if (locCodeList.Count > 0)
|
{
|
foreach (var loc in conLocList)
|
{
|
// 1.输送线故障信息判断
|
var linePlcInfo = WCSHelper.GetLinePlcInfo(loc.name);
|
if (linePlcInfo != null)
|
{
|
LogHelper.Info("开始读取输送线故障信息,接驳位:" + loc.name + ",设备号" + linePlcInfo.deviceNo + ",读地址:" + linePlcInfo.readAddr, "输送线");
|
short faultMessage = S7Helper.ReadInt(linePlcInfo.deviceNo, 100, linePlcInfo.readAddr + 10);
|
LogHelper.Info("故障信息:" + JsonConvert.SerializeObject(faultMessage), "输送线");
|
|
if (faultMessage != 0)
|
{
|
faultInfo = $"输送线:{linePlcInfo.code}处于非正常状态 ,故障编码为:{faultMessage} ";
|
locCodeList.Remove(loc.name);
|
LogHelper.Info(linePlcInfo.code + "线体处于非正常状态,故障编码为:" + faultMessage + ",停止向该输送线分配任务", "输送线");
|
}
|
}
|
|
// 2.堆垛机故障信息判断
|
var ddjPlcInfo = Settings.devicePlcInfos.Where(a => a.deviceType == 1 && a.area == areaCode && a.roadway == loc.roadway).FirstOrDefault();
|
if (ddjPlcInfo != null)
|
{
|
LogHelper.Info("开始读取堆垛机故障信息,巷道:" + loc.roadway, "堆垛机");
|
short[] resSignal1 = S7Helper.ReadInt(ddjPlcInfo.deviceNo, 551, 0, 8);
|
LogHelper.Info("故障信息:" + JsonConvert.SerializeObject(resSignal1[3]), "堆垛机");
|
if (resSignal1 != null && resSignal1.Length > 0 && resSignal1[3] != 1)
|
{
|
faultInfo = $"堆垛机:{ddjPlcInfo.deviceName}处于非正常状态,故障编码为:{resSignal1[3]}";
|
locCodeList.Remove(loc.name);
|
LogHelper.Info(ddjPlcInfo.deviceName + "处于非正常状态,故障编码为:" + resSignal1[3] + ",停止向该输送线分配任务", "堆垛机");
|
}
|
}
|
}
|
|
if (locCodeList.Count == 0)
|
{
|
throw new BusinessException($"库区:{areaCode},{faultInfo}");
|
}
|
}
|
LogHelper.Info("接驳点排序顺序3:" + JsonConvert.SerializeObject(locCodeList), "Mobox");
|
return locCodeList;
|
}
|
}
|
return null;
|
}
|
|
/// <summary>
|
/// 获取所有货位信息
|
/// </summary>
|
/// <returns></returns>
|
internal static Area GetArea(string areaCode)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<Area>().Where(a => a.S_CODE == areaCode).First();
|
}
|
/// <summary>
|
/// 获取所有货位信息
|
/// </summary>
|
/// <returns></returns>
|
internal static List<Location> GetAllLocList()
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<Location>().ToList();
|
}
|
|
internal static Location GetLoc(string code)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<Location>().Where(a => a.S_CODE.Trim() == code.Trim()).Includes(a => a.LocCntrRel ,a => a .CntrItemRel).First();
|
}
|
|
/// <summary>
|
///获取所有货位扩展信息
|
/// </summary>
|
/// <returns></returns>
|
internal static List<LocationExt> GetAllLocExtList()
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<LocationExt>().ToList();
|
}
|
|
/// <summary>
|
/// 判断没有入库锁和出库锁
|
/// </summary>
|
/// <param name="code"></param>
|
/// <returns></returns>
|
internal static bool CheckLocFree(string code)
|
{
|
var result = false;
|
var loc = GetLoc(code);
|
if (loc != null)
|
{
|
result = loc.S_LOCK_STATE.Trim() == "无";
|
}
|
return result;
|
}
|
internal static List<LocCntrRel> GetLocCntr(string loc)
|
{
|
var result = new List<LocCntrRel>();
|
//1.0 查货位容器表
|
var db = new SqlHelper<object>().GetInstance();
|
var list = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE == loc.Trim()).OrderBy(a => a.T_CREATE).ToList();
|
if (list.Count > 0)
|
{
|
list.ForEach(a =>
|
{
|
//获取容器信息
|
var cntr = db.Queryable<Container>().Where(b => b.S_CODE == a.S_CNTR_CODE).First();
|
if (cntr != null)
|
{
|
a.Container = cntr;
|
result.Add(a);
|
}
|
});
|
}
|
return result;
|
|
}
|
internal static List<LocCntrRel> GetLocCntrRel(string loc)
|
{
|
//1.0 查货位容器表
|
var db = new SqlHelper<object>().GetInstance();
|
var result = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE == loc.Trim()).ToList();
|
return result;
|
|
}
|
|
/// <summary>
|
/// 根据货位集合获取有容器的货位
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <returns></returns>
|
internal static List<Location> GetLocList(List<string> loc)
|
{
|
//1.0 查货位容器表
|
var db = new SqlHelper<object>().GetInstance();
|
var list = db.Queryable<Location>().Where(a => loc.Contains(a.S_CODE) && a.N_CURRENT_NUM > 0).ToList();
|
return list;
|
|
}
|
|
/// <summary>
|
/// 根据货位编码获取货位信息,不管有没有容器
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <returns></returns>
|
internal static List<Location> GetLocListAny(List<string> loc)
|
{
|
//1.0 查货位容器表
|
var db = new SqlHelper<object>().GetInstance();
|
var list = db.Queryable<Location>().Where(a => loc.Contains(a.S_CODE)).ToList();
|
return list;
|
|
}
|
|
/// <summary>
|
/// 根据货位集合获取有容器 没有锁的货位
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <returns></returns>
|
internal static List<Location> GetLocListFree(List<string> loc)
|
{
|
//1.0 查货位容器表
|
var db = new SqlHelper<object>().GetInstance();
|
var list = db.Queryable<Location>().Where(a => loc.Contains(a.S_CODE) && a.N_CURRENT_NUM > 0 && a.S_LOCK_STATE.Trim() == "无").ToList();
|
return list;
|
|
}
|
|
/// <summary>
|
/// 获取固定数量容器 没有锁的货位
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <param name="current"></param>
|
/// <returns></returns>
|
internal static List<Location> GetLocListFree(List<string> loc, int current)
|
{
|
//1.0 查货位容器表
|
var db = new SqlHelper<object>().GetInstance();
|
var list = db.Queryable<Location>().Where(a => loc.Contains(a.S_CODE) && a.N_CURRENT_NUM == current && a.S_LOCK_STATE.Trim() == "无").ToList();
|
return list;
|
|
}
|
|
/// <summary>
|
/// 获取数量大于等于固定数量容器 没有锁的货位
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <param name="current"></param>
|
/// <returns></returns>
|
internal static List<Location> GetLocList(List<string> loc, int current)
|
{
|
//1.0 查货位容器表
|
var db = new SqlHelper<object>().GetInstance();
|
var list = db.Queryable<Location>().Where(a => loc.Contains(a.S_CODE) && a.N_CURRENT_NUM >= current && a.S_LOCK_STATE.Trim() == "无").ToList();
|
return list;
|
|
}
|
|
/// <summary>
|
/// 根据货位集合获取 没有容器 没有锁的货位
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <returns></returns>
|
internal static List<Location> GetLocListEmptyFree(List<string> loc)
|
{
|
//1.0 查货位容器表
|
var db = new SqlHelper<object>().GetInstance();
|
var list = db.Queryable<Location>().Where(a => loc.Contains(a.S_CODE) && a.N_CURRENT_NUM == 0 && a.S_LOCK_STATE.Trim() == "无").ToList();
|
return list;
|
|
}
|
|
/// <summary>
|
/// 入库锁定终点,出库锁定起点
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <param name="lockState">1:入库锁、2:出库锁、2:其它锁</param>
|
/// <returns></returns>
|
public static bool LockLoc(string loc, int lockState)
|
{
|
var res = false;
|
var db = new SqlHelper<object>().GetInstance();
|
var model = db.Queryable<Location>().Where(a => a.S_CODE == loc).First();
|
if (model != null && model.S_LOCK_STATE.Trim() == "无")
|
{
|
model.N_LOCK_STATE = lockState;
|
model.S_LOCK_STATE = Location.GetLockStateStr(lockState);
|
res = db.Updateable(model).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE }).ExecuteCommand() > 0;
|
}
|
return res;
|
}
|
|
/// <summary>
|
/// 取货完解锁起点,卸货完解锁终点,可检验锁的来源,也可以不校验
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <returns></returns>
|
public static bool UnLockLoc(string loc)
|
{
|
LogHelper.Info("UnLockLoc:" + loc);
|
var res = false;
|
var db = new SqlHelper<object>().GetInstance();
|
var model = db.Queryable<Location>().Where(a => a.S_CODE == loc).First();
|
if (model != null)
|
{
|
model.S_LOCK_STATE = "无";
|
model.N_LOCK_STATE = 0;
|
res = db.Updateable(model).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE }).ExecuteCommand() > 0;
|
LogHelper.Info("UnLockLoc:解锁结果" + res);
|
}
|
else
|
{
|
LogHelper.Info("UnLockLoc 失败");
|
}
|
return res;
|
}
|
|
/// <summary>
|
/// 删除货位容器表记录,修改货位容器数量
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <param name="cntrs"></param>
|
/// <returns></returns>
|
public static bool UnBindingLoc(string loc, List<string> cntrs)
|
{
|
var res = false;
|
var db = new SqlHelper<object>().GetInstance();
|
var location = db.Queryable<Location>().Where(a => a.S_CODE == loc).Includes(a=> a.LocCntrRel ,a => a.CntrItemRel).First();
|
try
|
{
|
if (location != null)
|
{
|
db.BeginTran();
|
var lcrList = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE == loc).ToList();
|
var count = db.Deleteable<LocCntrRel>().Where(it => cntrs.Contains(it.S_CNTR_CODE) && it.S_LOC_CODE == loc).ExecuteCommand();
|
|
location.N_CURRENT_NUM = lcrList.Count - count;
|
location.S_LOCK_STATE = "无";
|
location.N_LOCK_STATE = 0;
|
location.T_EMPTY_TIME = DateTime.Now;
|
db.Updateable(location).UpdateColumns(it => new {
|
it.N_CURRENT_NUM,
|
it.S_LOCK_STATE,
|
it.N_LOCK_STATE,
|
it.T_EMPTY_TIME,
|
}).ExecuteCommand();
|
db.CommitTran();
|
|
// 货位状态发生变化,推送数字孪生 货品状态
|
MQTTCore.pushLocStatus(location.S_CODE, 0);
|
res = true;
|
}
|
}
|
catch (Exception ex)
|
{
|
db.RollbackTran();
|
}
|
return res;
|
}
|
|
/// <summary>
|
/// 货位绑定容器
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <param name="cntrs"></param>
|
/// <returns></returns>
|
public static bool BindingLoc(string loc, List<string> cntrs)
|
{
|
var res = false;
|
var db = new SqlHelper<object>().GetInstance();
|
var location = db.Queryable<Location>().Where(a => a.S_CODE == loc).Includes(a => a.LocCntrRel ,a => a.CntrItemRel).First();
|
try
|
{
|
if (location != null) {
|
var lcrList = db.Queryable<LocCntrRel>().Includes(a => a.Container).Where(a => a.S_LOC_CODE == loc).ToList();
|
db.BeginTran();
|
int count = 0;
|
cntrs.ForEach(a =>
|
{
|
if (lcrList.Count(b => b.S_CNTR_CODE.Trim() == a) == 0)
|
{
|
db.Insertable<LocCntrRel>(new LocCntrRel { S_LOC_CODE = loc, S_CNTR_CODE = a }).ExecuteCommand();
|
count++;
|
}
|
|
var cntrItems = ItemHelper.GetCntrItemByCntrCode(a);
|
if (cntrItems != null && cntrItems.Count > 0)
|
{
|
foreach (var cntrItem in cntrItems)
|
{
|
// 记录物料入库时间
|
cntrItem.T_IN_STOCK = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
db.Updateable<CntrItemRel>(cntrItem).UpdateColumns(it => new { it.T_IN_STOCK }).ExecuteCommand();
|
}
|
location.T_FULL_TIME = DateTime.Now;
|
}
|
});
|
location.N_CURRENT_NUM = lcrList.Count + count;
|
location.N_LOCK_STATE = 0;
|
location.S_LOCK_STATE = "无";
|
|
db.Updateable(location).UpdateColumns(it => new {
|
it.N_CURRENT_NUM,
|
it.S_LOCK_STATE,
|
it.N_LOCK_STATE,
|
it.T_FULL_TIME,
|
}).ExecuteCommand();
|
db.CommitTran();
|
|
// 货位状态发生变化,推送数字孪生 货位状态信息、货品物料信息
|
MQTTCore.pushLocStatus(location.S_CODE, 1);
|
res = true;
|
}
|
}
|
catch (Exception ex)
|
{
|
Console.WriteLine(ex.Message);
|
db.RollbackTran();
|
}
|
return res;
|
}
|
|
/// <summary>
|
/// 判断逻辑库区是否有可用货位
|
/// </summary>
|
/// <param name="zone"></param>
|
/// <exception cref="NotImplementedException"></exception>
|
internal static bool CheckZoneFree(string zone)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
var count = db.Queryable<ZoneLoc>().Includes(a => a.Loc).Where(a => a.S_ZONE_CODE == zone && a.Loc.N_LOCK_STATE == 0).Count();
|
return count > 0;
|
}
|
internal static ZoneLoc GetZoneLoc(string zone)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<ZoneLoc>().Includes(a => a.Loc).Where(a => a.S_ZONE_CODE == zone && a.Loc.N_LOCK_STATE == 0 && a.Loc.N_CURRENT_NUM == 0).First();
|
|
}
|
internal static List<ZoneLoc> GetZoneByLoc(string loc)
|
{
|
var db = new SqlHelper<object>().GetInstance();
|
return db.Queryable<ZoneLoc>().Where(a => a.S_LOC_CODE == loc).ToList();
|
|
}
|
|
internal static object GetFunctionCodeByArea(string v1, int v2, int v3)
|
{
|
throw new NotImplementedException();
|
}
|
|
internal static List<FreeLineInfo> GetAllFreeLineInfo()
|
{
|
try
|
{
|
var db = new SqlHelper<FreeLineInfo>().GetInstance();
|
return db.Queryable<FreeLineInfo>().ToList();
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.Message, ex);
|
return null;
|
}
|
}
|
|
internal static ItemInfo GetLocCntrItem(string loc)
|
{
|
ItemInfo result = null;
|
var db = new SqlHelper<object>().GetInstance();
|
var location = db.Queryable<Location>().Where(a => a.S_CODE == loc).Includes(a => a.LocCntrRel, a => a.CntrItemRel).First();
|
if (location != null && location.LocCntrRel != null && location.LocCntrRel.CntrItemRel != null)
|
{
|
result = ItemHelper.GetItemInfo(location.LocCntrRel.CntrItemRel.S_ITEM_CODE);
|
}
|
return result;
|
}
|
|
internal static bool UpdateLocInfo(string locCode,int cntrNum ,int lockStatus) {
|
var res = false;
|
var db = new SqlHelper<Location>().GetInstance();
|
var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == locCode).First();
|
if (location != null)
|
{
|
location.N_CURRENT_NUM += cntrNum;
|
location.N_LOCK_STATE = lockStatus;
|
//需要判断任务是否失败或者已完成,不允许再修改
|
res = db.Updateable(location).UpdateColumns(it => new { it.N_CURRENT_NUM, it.N_LOCK_STATE }).ExecuteCommand() > 0;
|
}
|
return res;
|
}
|
|
}
|
}
|