|
using HH.WCS.QingXigongchang.core;
|
using HH.WCS.QingXigongchang.device;
|
using HH.WCS.QingXigongchang.process;
|
using HH.WCS.QingXigongchang.util;
|
using HH.WCS.QingXigongchang.wms;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Diagnostics;
|
using System.Linq;
|
using System.Reflection;
|
using System.Text.RegularExpressions;
|
using System.Threading;
|
using System.Web.Http;
|
using System.Web.Http.Results;
|
using static HH.WCS.QingXigongchang.api.ApiHelper;
|
using static HH.WCS.QingXigongchang.api.ApiModel;
|
using static HH.WCS.QingXigongchang.process.DeviceProcess;
|
using static HH.WCS.QingXigongchang.util.HttpHelper;
|
using Monitor = HH.WCS.QingXigongchang.core.Monitor;
|
|
namespace HH.WCS.QingXigongchang.api
|
{
|
/// <summary>
|
/// 第三方调用的接口
|
/// </summary>
|
[RoutePrefix("api")]
|
public class WmsController : System.Web.Http.ApiController
|
{
|
//[HttpPost]
|
//public SimpleResult AddTask(AddTaskModel model) {
|
// ApiHelper.AddTask(model);
|
// return new SimpleResult();
|
//}
|
|
//已经改用mobox上lua脚本处理
|
//[HttpPost]
|
//[Route("CleanReport")]
|
//public SimpleResult CleanReport(LocationModel model) {
|
// LogHelper.Debug("CleanReport Request:" + JsonConvert.SerializeObject(model));
|
// return ApiHelper.CleanReport(model);
|
|
//}
|
|
|
|
[HttpPost]
|
[Route("ResetDevice")]
|
public SimpleResult ResetDevice(DeviceModel model)
|
{
|
LogHelper.Info("ResetDevice Request:" + JsonConvert.SerializeObject(model));
|
return ApiHelper.ResetDevice(model);
|
|
}
|
|
|
/// <summary>
|
/// 锁一排
|
/// </summary>
|
/// <param name="itemCode"></param>
|
/// <param name="qty"></param>
|
/// <returns></returns>
|
[HttpGet]
|
[Route("LockRow")]
|
public SimpleResult LockRow(string area, int row)
|
{
|
SimpleResult result = new SimpleResult();
|
List<int> rows = new List<int>();
|
var areas = area?.Split(':').ToList();
|
var index = 0;
|
if (areas.Count() > 1) //KKQ split count =1
|
{
|
area = areas[0];
|
index = 1;
|
areas.RemoveAt(0);
|
rows = Array.ConvertAll<string, int>(areas.ToArray(), s => int.Parse(s)).ToList();
|
}
|
else
|
{
|
if (index < 1 && row == 0)
|
{
|
result.resultCode = 2;
|
result.resultMsg = $"库区排不可为空;";
|
return result;
|
}
|
rows.Add(row);
|
}
|
if (rows.Count == 0)
|
{
|
result.resultCode = 2;
|
result.resultMsg = $"库区排不可为空;";
|
return result;
|
}
|
|
return ApiHelper.Outgo1(area, rows);
|
}
|
|
[HttpGet]
|
[Route("ClearLoc")]
|
public SimpleResult ClearLoc(string area, int row)
|
{
|
SimpleResult result = new SimpleResult() { resultCode = 0 };
|
|
if (string.IsNullOrEmpty(area) || row < 1)
|
{
|
result.resultCode = 2;
|
result.resultMsg = $"库区排不可为空;";
|
return result;
|
}
|
|
return ApiHelper.clearLoc(area, new List<int> { row });
|
}
|
|
[HttpGet]
|
[Route("LockR")]
|
public SimpleResult LockR(string area, int row)
|
{
|
SimpleResult result = new SimpleResult() { resultCode = 0 };
|
|
if (string.IsNullOrEmpty(area) || row < 1)
|
{
|
result.resultCode = 2;
|
result.resultMsg = $"库区排不可为空;";
|
return result;
|
}
|
|
return ApiHelper.clearloc(area, new List<int> { row });
|
}
|
|
[HttpGet]
|
[Route("unLockR")]
|
public SimpleResult unLockR(string area, int row)
|
{
|
SimpleResult result = new SimpleResult() { resultCode = 0 };
|
|
if (string.IsNullOrEmpty(area) || row < 1)
|
{
|
result.resultCode = 2;
|
result.resultMsg = $"库区排不可为空;";
|
return result;
|
}
|
|
return ApiHelper.unlockrow(area, new List<int> { row });
|
}
|
|
|
[HttpGet]
|
[Route("unLockRow")]
|
public SimpleResult unLockRow(string area, int row)
|
{
|
List<int> rows = new List<int>();
|
var areas = area?.Split(':').ToList();
|
var index = 0;
|
if (areas.Count() > 1) //KKQ split count =1
|
{
|
area = areas[0];
|
index = 1;
|
areas.RemoveAt(0);
|
rows = Array.ConvertAll<string, int>(areas.ToArray(), s => int.Parse(s)).ToList();
|
}
|
else
|
{
|
SimpleResult result = new SimpleResult();
|
if (index < 1 && row == 0)
|
{
|
result.resultCode = 2;
|
result.resultMsg = $"库区排不可为空;";
|
return result;
|
}
|
rows.Add(row);
|
}
|
return ApiHelper.Outgo2(area, rows);
|
}
|
|
/// <summary>
|
/// 绑定单个
|
/// </summary>
|
/// <param name="itemCode"></param>
|
/// <param name="qty"></param>
|
/// <returns></returns>
|
[HttpGet]
|
[Route("BindLoc")]
|
public SimpleResult BindLoc(string loc, string IsJCJY)
|
{
|
SimpleResult res;
|
try
|
{
|
res = ApiHelper.Outgo3("---货位有库区。 。----", IsJCJY, loc);
|
}
|
catch (Exception ex)
|
{
|
res = new SimpleResult() { resultCode = 2, resultMsg = ex.Message };
|
}
|
return res;
|
}
|
|
[HttpGet]
|
[Route("RunOrder")]
|
public SimpleResult RunOrder(string WorkNo)
|
{
|
LogHelper.Info("RunOrder" + WorkNo);
|
SimpleResult res = new SimpleResult() { resultCode = 0, resultMsg = "" };
|
try
|
{
|
var Order = WCSHelper.GetWorkOrderByOrderNo(WorkNo);
|
|
if (Order == null)
|
return new SimpleResult() { resultCode = -1, resultMsg = "工单号不存在!" };
|
var sdvi = Settings.GetDeviceInfoList().Find(x => x.deviceName == Order.SQL_PLineNo);
|
if (sdvi == null)
|
return new SimpleResult() { resultCode = -1, resultMsg = "工单对应的产线号DeviceInfo不存在!" };
|
|
for (var i = 0; i < sdvi.location.Length; i++)
|
{
|
PlcHelper.SendHex(sdvi.address, "3F00" + (i + 1) + "0" + "0d0a");
|
}
|
}
|
catch (Exception ex)
|
{
|
res = new SimpleResult() { resultCode = -1, resultMsg = ex.Message };
|
}
|
return res;
|
}
|
|
/// <summary>
|
/// 成品绑定。
|
/// </summary>
|
/// <param name="loc">货位。</param>
|
/// <param name="LineNo">产线号 ,.防止因为后期增加多个产线 - </param>
|
/// <returns></returns>
|
[HttpGet]
|
[Route("BindCP")]
|
public SimpleResult BindLocCP(string loc, string LineNo, string arco)
|
{
|
SimpleResult res;
|
try
|
{
|
res = ApiHelper.BindCp(loc, LineNo, arco);
|
}
|
catch (Exception ex)
|
{
|
res = new SimpleResult() { resultCode = -1, resultMsg = ex.Message };
|
}
|
return res;
|
}
|
|
/// <summary>
|
/// 绑定 货位所在aroc 成品用
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <param name="btype"></param>
|
/// <param name="arco"></param>
|
/// <returns></returns>
|
[HttpGet]
|
[Route("BindLoc2")]
|
public SimpleResult BindLoc2(string loc, string btype, string arco)
|
{
|
SimpleResult res;
|
try
|
{
|
res = ApiHelper.Outgo31(loc, btype, arco);
|
}
|
catch (Exception ex)
|
{
|
res = new SimpleResult() { resultCode = 2, resultMsg = ex.Message };
|
}
|
return res;
|
}
|
|
/// <summary>
|
/// 瓶坯。 满眶入库,转绑满眶出库。
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <param name="LineNo"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[Route("BindLoc3")]
|
public SimpleResult BindLoc3(dynamic ooo)
|
{
|
var loc = ooo.loc.ToString();
|
var LineNo = ooo.LineNo.ToString();
|
string ItemCode = ooo.ItemCode.ToString();
|
|
LogHelper.Info("BindLoc3" + JsonConvert.SerializeObject(ooo));
|
if (string.IsNullOrEmpty(ItemCode) || string.IsNullOrEmpty(LineNo))
|
{
|
return SimpleResult.Error($"物料{ItemCode} 或 产线{LineNo} 不能空。");
|
}
|
SimpleResult res;
|
try
|
{
|
if (!ItemCode.Contains("纸箱"))
|
{
|
var item = ContainerHelper.GetItem(ItemCode);
|
if (item == null) { return SimpleResult.Error(ItemCode + "数据不存在"); }
|
ItemCode = item.S_ITEM_CODE;
|
}
|
res = ApiHelper.Outgo33(loc, LineNo + ">" + ItemCode);
|
}
|
catch (Exception ex)
|
{
|
res = new SimpleResult() { resultCode = 2, resultMsg = ex.Message };
|
}
|
return res;
|
}
|
|
/// <summary>
|
/// 空筐解绑。
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <param name="LineNo"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[Route("unBindLoc3")]
|
public SimpleResult unBindLoc3(dynamic ooo)
|
{
|
var loc = ooo.loc.ToString();
|
|
LogHelper.Info("unBindLoc3" + JsonConvert.SerializeObject(ooo));
|
if (string.IsNullOrEmpty(loc))
|
{
|
return SimpleResult.Error($"参数:{loc} 不能空。");
|
}
|
SimpleResult res;
|
try
|
{
|
res = ApiHelper.unOutgo33(loc);
|
}
|
catch (Exception ex)
|
{
|
res = new SimpleResult() { resultCode = 2, resultMsg = ex.Message };
|
}
|
return res;
|
}
|
|
/// <summary>
|
/// 瓶坯 空 满 即产 绑定。
|
/// </summary>
|
/// <param name="loc">货位</param>
|
/// <param name="arco">area row col one</param>
|
/// <param name="JF">J 即产 F 非即产</param>
|
/// <returns></returns>
|
[HttpPost]
|
[Route("PPBindLocs")]
|
public SimpleResult PPBindLocs(dynamic ooo)
|
{
|
string loc = ooo.loc.ToString();
|
string arco = ooo.arco.ToString();
|
string item = ooo.item.ToString();
|
|
if (string.IsNullOrEmpty(item))
|
{
|
return SimpleResult.Error($"物料{item} 找不到物料");
|
}
|
SimpleResult res;
|
try
|
{
|
res = ApiHelper.Outgo34(loc, "", arco, item);
|
}
|
catch (Exception ex)
|
{
|
res = new SimpleResult() { resultCode = 2, resultMsg = ex.Message };
|
}
|
return res;
|
}
|
[HttpGet]
|
[Route("PPunBindLocs")]
|
public SimpleResult unPPBindLocs(string loc, string arco)
|
{
|
SimpleResult res;
|
try
|
{
|
res = ApiHelper.Outgo34(loc, "", arco, "", false);
|
}
|
catch (Exception ex)
|
{
|
res = new SimpleResult() { resultCode = 2, resultMsg = ex.Message };
|
}
|
return res;
|
}
|
|
|
|
[HttpGet]
|
[Route("unBindLoc")]
|
public SimpleResult unBindLoc(string loc, string arco)
|
{
|
return ApiHelper.unOutgo3("--- 不用传。----", loc, arco);
|
}
|
/// <summary>
|
/// 按列绑定
|
/// </summary>
|
/// <param name="area"></param>
|
/// <param name="col"></param>
|
/// <returns></returns>
|
[HttpGet]
|
[Route("BindLocs")]
|
public SimpleResult BindLocs(string area, string col)
|
{
|
SimpleResult result = new SimpleResult();
|
List<int> rows = new List<int>();
|
var areas = area?.Split(':').ToList();
|
var index = 0;
|
if (areas.Count() > 1) //KKQ split count =1
|
{
|
area = areas[0];
|
index = 1;
|
areas.RemoveAt(0);
|
rows = Array.ConvertAll<string, int>(areas.ToArray(), s => int.Parse(s)).ToList();
|
}
|
else
|
{
|
if (index < 1 && string.IsNullOrEmpty(col))
|
{
|
result.resultCode = 2;
|
result.resultMsg = $"库区列不可为空;";
|
return result;
|
}
|
rows.Add(Convert.ToInt32(col));
|
}
|
//KKQ:1:2:3
|
return ApiHelper.Outgo4(area, rows);
|
}
|
|
|
|
[HttpGet]
|
[Route("GetAREACount")]
|
public SimpleResult GetAREACount(string area, int count)
|
{
|
List<string> strl = new List<string>();
|
IEnumerable<Settings.deviceInfo> Li = from x in Settings.GetDeviceInfoList()
|
where x.deviceType == 8
|
select x;
|
Dictionary<string, int> dic = new Dictionary<string, int>();
|
foreach (Settings.deviceInfo i in Li)
|
{
|
ApiModel.SimpleResult r = ApiHelper.GetAREACount(i.deviceNo[0]);
|
string no = i.deviceNo[0];
|
if (!string.IsNullOrEmpty(Regex.Match(no, "^[1-9]+").Groups[0].Value))
|
{
|
no = "o" + no;
|
}
|
dic.Add(no, r.resultCode);
|
}
|
|
//dic.Add("o1PPMK", 1);
|
//dic.Add("o2PPMK", 2);
|
//dic.Add("o3PPMK", 3);
|
//dic.Add("o4PPMK", 4);
|
//dic.Add("o5PPMK", 5);
|
//dic.Add("o6PPMK", 6);
|
return new ApiModel.SimpleResult
|
{
|
resultCode = 1,
|
result = new List<object>
|
{
|
dic
|
}
|
};
|
//return new SimpleResult { resultCode = strl.Count > 0 ? 1 : 0, resultMsg = strl.Count > 0 ? $"库区大于{count}的库区有" + string.Join(",", strl) : $"暂时没有满框大于{count}的库区!" };
|
}
|
|
|
//{"No":"TN23060665395","State":6}
|
public class classs
|
{
|
public string No; public string State; public string ForkliftNo;
|
}
|
|
[HttpPost]
|
[Route("TestTask")]
|
public ReturnResult TestTask(classs c)
|
{
|
if (string.IsNullOrEmpty(c.No) || string.IsNullOrEmpty(c.State))
|
{
|
return new ReturnResult()
|
{
|
ResultCode = -1,
|
ResultMsg = "参数为空"
|
};
|
}
|
var b = c.State?.Split(';');
|
string msg = c.No + "";
|
foreach (string item in b)
|
{
|
ReturnResult rrr = TaskCore.OperateTaskStatus(new AgvTaskState
|
{
|
No = c.No,
|
State = Convert.ToInt32(item),
|
ForkliftNo = c.ForkliftNo
|
});
|
msg += $"执行任务状态“{item}” {(rrr.ResultCode == 0 ? "成功" : "失败")}!";
|
if (rrr.ResultCode != 0)
|
{
|
rrr.ResultMsg += ":::::" + msg;
|
return rrr;
|
}
|
Thread.Sleep(200);
|
}
|
|
return new ReturnResult();
|
//if (loc != "996")
|
// return loc ?? "222222222";
|
//else throw new System.Exception("Exception");
|
}
|
|
|
|
|
/// <summary>
|
/// 货位绑定 -
|
/// </summary>
|
/// <param name="loc">货位</param>
|
/// <param name="traylayers">层数 2、3</param>
|
/// <param name="type"> 空框, 1234号瓶盖</param>
|
/// <returns></returns>
|
/// <exception cref="System.Exception"></exception>
|
[HttpGet]
|
[Route("BindTrays")]
|
public SimpleResult BindTrays(string loc, int traylayers, string Note)
|
{
|
if (string.IsNullOrEmpty(loc) || !new string[] { "空框", "1号瓶盖", "2号瓶盖", "3号瓶盖", "4号瓶盖" }.Contains(Note) || !new int[] { 2, 3 }.Contains(traylayers))
|
{
|
return new SimpleResult() { resultCode = 2, resultMsg = $"参数不符合!货位:{loc},标识:{Note},层数:{traylayers}" };
|
}
|
var _bindloc = LocationHelper.GetLoc(loc);
|
if (_bindloc == null) return new SimpleResult() { resultCode = 2, resultMsg = "货位不存在。 " };
|
if (_bindloc.S_AREA_CODE != "IWF360" && _bindloc.S_AREA_CODE != "IWT11") return new SimpleResult() { resultCode = 2, resultMsg = "货位库区不是瓶盖大库。 " };
|
if ((_bindloc.N_CURRENT_NUM == 0 && traylayers == 3) || (_bindloc.N_CURRENT_NUM == 3 && traylayers == 2))
|
{
|
LocationHelper.lOCReSetValue(x => x.S_LOC_CODE == _bindloc.S_LOC_CODE, x =>
|
{
|
x.N_CURRENT_NUM = _bindloc.N_CURRENT_NUM + traylayers;
|
x.S_NOTE = Note;
|
});
|
}
|
else if (_bindloc.S_AREA_CODE == "IWT11")
|
{
|
LocationHelper.lOCReSetValue(x => x.S_LOC_CODE == _bindloc.S_LOC_CODE, x =>
|
{
|
x.N_CURRENT_NUM = traylayers;
|
x.S_NOTE = Note;
|
});
|
}
|
else
|
return new SimpleResult() { resultCode = 2, resultMsg = $"托盘数{traylayers} 和货位托盘数{_bindloc.N_CURRENT_NUM} 无法叠筐" };
|
return new SimpleResult() { resultCode = 0, resultMsg = "" };
|
}
|
|
|
/// <summary>
|
/// 报废货位
|
/// </summary>
|
/// <param name="loc"></param
|
/// <param name="all">1/0</param>
|
/// <returns></returns>
|
[HttpGet]
|
[Route("BFloc")]
|
public SimpleResult BFloc(string loc, string all)
|
{
|
if (string.IsNullOrEmpty(loc))
|
{
|
return new SimpleResult() { resultCode = 2, resultMsg = $"参数不符合!货位:{loc}" };
|
}
|
var _bindloc = LocationHelper.GetLoc(loc);
|
if (_bindloc == null) return new SimpleResult() { resultCode = 2, resultMsg = "货位不存在。 " };
|
//if (_bindloc.S_AREA_CODE != "IWF360") return new SimpleResult() { resultCode = 2, resultMsg = "货位库区不是瓶盖大库。 " };
|
if ((_bindloc.S_LOCK_STATE != "无" && _bindloc.S_LOCK_STATE != "空间锁"))
|
return new SimpleResult() { resultCode = 2, resultMsg = $"货位状态{_bindloc.S_LOCK_STATE} 不能报废。 " };
|
else
|
{
|
if (all == "1")
|
{
|
LocationHelper.lOCReSetValue(x => x.S_AREA_CODE == _bindloc.S_AREA_CODE && x.N_ROW == _bindloc.N_ROW, x =>
|
{
|
x.S_LOCK_STATE = "报废";
|
});
|
}
|
else
|
LocationHelper.lOCReSetValue(x => x.S_LOC_CODE == _bindloc.S_LOC_CODE, x =>
|
{
|
x.S_LOCK_STATE = "报废";
|
});
|
}
|
return new SimpleResult() { resultCode = 0, resultMsg = "" };
|
}
|
|
/// <summary>
|
/// 报废货位解除
|
/// </summary>
|
/// <param name="loc"></param>
|
/// <returns></returns>
|
[HttpGet]
|
[Route("unBFloc")]
|
public SimpleResult unBFloc(string loc, string all, string clear)
|
{
|
if (string.IsNullOrEmpty(loc))
|
{
|
return new SimpleResult() { resultCode = 2, resultMsg = $"参数不符合!货位:{loc}" };
|
}
|
var _bindloc = LocationHelper.GetLoc(loc);
|
if (_bindloc == null) return new SimpleResult() { resultCode = 2, resultMsg = "货位不存在。 " };
|
//if (_bindloc.S_AREA_CODE != "IWF360") return new SimpleResult() { resultCode = 2, resultMsg = "货位库区不是瓶盖大库。 " };
|
if (_bindloc.S_LOCK_STATE != "报废" && all != "1" && clear != "1")
|
{
|
return new SimpleResult() { resultCode = 2, resultMsg = $"货位状态{_bindloc.S_LOCK_STATE} 无需解除。 " };
|
}
|
|
{
|
if (all == "1")
|
{
|
LocationHelper.lOCReSetValue(x => x.S_AREA_CODE == _bindloc.S_AREA_CODE && x.N_ROW == _bindloc.N_ROW, x =>
|
{
|
x.S_LOCK_STATE = "无";
|
if (clear == "1")
|
{
|
x.S_NOTE = "";
|
x.N_CURRENT_NUM = 0;
|
x.T_EMPTY_TIME = null;
|
x.T_FULL_TIME = null;
|
}
|
});
|
}
|
else
|
LocationHelper.lOCReSetValue(x => x.S_LOC_CODE == _bindloc.S_LOC_CODE, x =>
|
{
|
x.S_LOCK_STATE = "无";
|
if (clear == "1")
|
{
|
x.S_NOTE = "";
|
x.N_CURRENT_NUM = 0;
|
x.T_EMPTY_TIME = null;
|
x.T_FULL_TIME = null;
|
}
|
});
|
}
|
if (clear == "1")
|
{ //这里清 托盘 -- 上面是清货位数据。
|
if (all == "1")
|
{
|
var loclist = LocationHelper.GetLocList(x => x.S_AREA_CODE == _bindloc.S_AREA_CODE && x.N_ROW == _bindloc.N_ROW)?.Select(x => x.S_LOC_CODE.Trim());
|
LocationHelper.DoAction(db =>
|
{
|
return db.Deleteable<LocCntrRel>().Where(it => loclist.Contains(it.S_LOC_CODE.Trim())).ExecuteCommand() > 0;
|
});
|
}
|
else
|
{
|
LocationHelper.DoAction(db =>
|
{
|
return db.Deleteable<LocCntrRel>().Where(it => it.S_LOC_CODE == _bindloc.S_LOC_CODE).ExecuteCommand() > 0;
|
});
|
}
|
}
|
return new SimpleResult() { resultCode = 0, resultMsg = "" };
|
}
|
|
|
[HttpGet]
|
[Route("Testttt")]
|
public string Testttt(string loc)
|
{
|
if (loc != "996")
|
return loc ?? "222222222";
|
else throw new System.Exception("Exception");
|
}
|
|
[HttpGet]
|
[Route("MeFlux")]
|
public dynamic Mescs()
|
{
|
var apih = new HttpHelper();
|
string token = HttpHelper.GetMd5Hash(Settings.securityKey + "from" + Settings.tokenfrom + "timestamp" + apih._time);
|
|
return new
|
{
|
token = token,
|
from = Settings.tokenfrom,
|
timestamp = apih._time
|
};
|
}
|
|
[HttpPost]
|
[Route("WebPost")]
|
public string WebPost(PostStyle postStyle)
|
{
|
return new HttpHelper().WebPost(postStyle.url, postStyle.postData);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="Floc"></param>
|
/// <param name="Tloc"></param>
|
/// <returns></returns>
|
[HttpGet]
|
[Route("TakeP2P")]
|
public SimpleResult TakeP2P(string Floc, string Tloc)
|
{
|
Console.WriteLine($"TakeP2P:::::==>>>>>> floc {Floc} tloc{Tloc}");
|
LogHelper.Info($"floc {Floc} tloc{Tloc}");
|
if (string.IsNullOrEmpty(Floc))
|
Floc = "";
|
|
try
|
{
|
var FlociNFO = LocationHelper.GetLoc(Floc.Trim());
|
var TlociNFO = LocationHelper.GetLoc(Tloc.Trim());
|
|
if (FlociNFO == null || TlociNFO == null)
|
{
|
return SimpleResult.Error($"{(FlociNFO == null ? "起点货位数据为空。" : "")}{(TlociNFO == null ? "终点货位数据为空。" : "")}");
|
}
|
if (FlociNFO.S_LOCK_STATE != "无" || TlociNFO.S_LOCK_STATE != "无")
|
{
|
return SimpleResult.Error($"{(FlociNFO.S_LOCK_STATE != "无" ? $"起点货位状态{FlociNFO.S_LOCK_STATE}。" : "")}{(TlociNFO.S_LOCK_STATE != "无" ? $"起点货位状态{TlociNFO.S_LOCK_STATE}。" : "")}");
|
}
|
|
var B = TaskProcess.CreateTransport("", Floc.Trim(), Tloc.Trim(), "自由点对点转运", new List<string> { "不管控托盘" }, 1, 1, 1, 60);
|
|
LogHelper.Info($"创建自由点对点转运 指定点 {Floc.Trim()}->{Tloc.Trim()}");
|
if (B) return new SimpleResult();
|
return SimpleResult.Error("自由点对点转运 创建成功");
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.Message, ex);
|
return SimpleResult.Error(ex.Message);
|
}
|
}
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="Floc"></param>
|
/// <param name="Tloc"></param>
|
/// <returns></returns>
|
[HttpGet]
|
[Route("TakeP2PWithAllCntr")]
|
public SimpleResult TakeP2PWithAllCntr(string Floc, string Tloc)
|
{
|
Console.WriteLine($"TakeP2P:::::==>>>>>> floc {Floc} tloc{Tloc}");
|
LogHelper.Info($"floc {Floc} tloc{Tloc}");
|
if (string.IsNullOrEmpty(Floc))
|
Floc = "";
|
|
try
|
{
|
var FlociNFO = LocationHelper.GetLoc(Floc.Trim());
|
var TlociNFO = LocationHelper.GetLoc(Tloc.Trim());
|
|
if (FlociNFO == null || TlociNFO == null)
|
{
|
return SimpleResult.Error($"{(FlociNFO == null ? "起点货位数据为空。" : "")}{(TlociNFO == null ? "终点货位数据为空。" : "")}");
|
}
|
if (FlociNFO.S_LOCK_STATE != "无" || TlociNFO.S_LOCK_STATE != "无")
|
{
|
return SimpleResult.Error($"{(FlociNFO.S_LOCK_STATE != "无" ? $"起点货位状态{FlociNFO.S_LOCK_STATE}。" : "")}{(TlociNFO.S_LOCK_STATE != "无" ? $"起点货位状态{TlociNFO.S_LOCK_STATE}。" : "")}");
|
}
|
|
if (FlociNFO.N_CURRENT_NUM == 0 || TlociNFO.N_CURRENT_NUM > 0)
|
{
|
return SimpleResult.Error($"{Floc}起点无托盘 或者 {Tloc}终点有托盘。 任务不成立");
|
}
|
var loccntrs = LocationHelper.GetList<LocCntrRel>(x => x.S_LOC_CODE == FlociNFO.S_LOC_CODE);
|
if (loccntrs.Count == 0)
|
{
|
return SimpleResult.Error($"{Floc}起点有数量,但是没有绑定的托盘。");
|
}
|
|
var B = TaskProcess.CreateTransport("", Floc.Trim(), Tloc.Trim(), "带托盘点对点转运", loccntrs.Select(x => x.S_CNTR_CODE).ToList(), 1, 1, 1, 60);
|
|
LogHelper.Info($"创建 带托盘点对点转运 指定点 {Floc.Trim()}->{Tloc.Trim()}");
|
if (B) return new SimpleResult();
|
return SimpleResult.Error("带托盘点对点转运 创建失败");
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.Message, ex);
|
return SimpleResult.Error(ex.Message);
|
}
|
}
|
|
/// <summary>
|
/// 使用领料做 批量任务
|
/// </summary>
|
/// <param name="Endloc">直接写终点 是 输送线流程。 写 area-2-终点 是提升机流程。</param>
|
/// <param name="item"></param>
|
/// <param name="qty"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[Route("GuoLai")]
|
public SimpleResult GuoLai(dynamic dyc)
|
{
|
LogHelper.Info($"GuoLai 使用领料做 批量任务 {JsonConvert.SerializeObject(dyc)}");
|
string Endloc = dyc.Endloc;
|
string item = dyc.item;
|
int qty = dyc.qty;
|
if (string.IsNullOrEmpty(Endloc) || (string.IsNullOrEmpty(item) && !Endloc.Contains("-2-")) || qty <= 0)
|
return SimpleResult.Error($"有参数为空或,数量不大于0{Endloc},{item},{qty}");
|
var db = new SqlHelper<object>().GetInstance();
|
var alr = db.Queryable<LingItemOrder>().Where(x => x.WorkFromNo == "Auto" && x.DeviceNo == Endloc.Trim() && x.State == "执行").First();
|
if (alr != null)
|
return SimpleResult.Error($"{Endloc} 已经存在执行中的。领料信息。 物料为{alr.ItemCode}");
|
var res = db.Insertable(new LingItemOrder
|
{
|
WorkNo = "LIOauto" + DateTime.Now.ToString("yyMMdd HH:mm"),
|
WorkFromNo = "Auto",
|
ItemCode = item,
|
OutAreaNum = qty + "",
|
DeviceNo = Endloc.Trim(),//// 直接写终点 是 输送线流程。 写 area-2-终点-2-任务类型 是提升机流程。
|
OutCurrentNum = "0",
|
State = "执行"
|
}).ExecuteCommand() > 0;
|
return res ? new SimpleResult() : SimpleResult.Error($"{Endloc}-{item} 创建叫料单据失败!请重来。");
|
}
|
|
[HttpPost]
|
[Route("GuoLaiCancle")]
|
public SimpleResult GuoLaiCancle(string Endloc, string item)
|
{
|
if (string.IsNullOrEmpty(Endloc) || string.IsNullOrEmpty(item))
|
return SimpleResult.Error($"有参数为空或,数量不大于0{Endloc},{item}");
|
var db = new SqlHelper<object>().GetInstance();
|
var alr = db.Queryable<LingItemOrder>().Where(x => x.WorkFromNo == "Auto" && x.DeviceNo == Endloc.Trim() && x.State == "执行").First();
|
if (alr == null)
|
return SimpleResult.Error($"{Endloc} 没有执行中的。领料信息。");
|
alr.State = "取消";
|
var res = db.Updateable(alr).UpdateColumns(it => new { it.State }).ExecuteCommand() > 0;
|
return res ? new SimpleResult() : SimpleResult.Error($"{Endloc} 执行取消叫料单据失败!");
|
}
|
|
[HttpGet]
|
[Route("Ctcp")]
|
public List<string> WebGst()
|
{
|
return TcpServer.clients.Keys.ToList();
|
}
|
|
[HttpGet]
|
[Route("Cdoor")]
|
public string WebGstDoor()
|
{
|
return JsonConvert.SerializeObject(new
|
{
|
clients = TcpServer.clients.Keys.ToList(),
|
doorStatus = DeviceProcess.doorStatus,
|
dsi = Monitor.dsi
|
});
|
return JsonConvert.SerializeObject(DeviceProcess.doorStatus);
|
}
|
|
|
|
[HttpGet]
|
[Route("GetUpu")]
|
public dynamic GetUpu()
|
{
|
Process currentProcess = Process.GetCurrentProcess();
|
string processName = currentProcess.ProcessName;
|
int processId = currentProcess.Id;
|
List<dynamic> data = new List<dynamic>();
|
foreach (ProcessThread thread in currentProcess.Threads)
|
{
|
string counterPath = $"Process({processName})\\Thread({thread.Id})";
|
var counter = new PerformanceCounter("Thread", "% Processor Time", thread.Id.ToString(), processName);
|
float cpuUsage = counter.NextValue();
|
data.Add(new
|
{
|
thread.Id,
|
counter,
|
cpu = $"{cpuUsage:F2}%"
|
});
|
}
|
return data;
|
}
|
|
|
[HttpGet]
|
[Route("CntrSplit")]
|
public SimpleResult CntrSplit()
|
{
|
List<LocCntrRel> lcrl = new List<LocCntrRel>();
|
var db = new SqlHelper<object>().GetInstance();
|
lcrl = db.Queryable<LocCntrRel>().Includes(x => x.CntrItemRel).Where(x => x.S_CNTR_CODE.Length == 48 && x.S_CNTR_CODE.StartsWith("F")).ToList();
|
int si = 0;
|
string msg = "";
|
var gP = lcrl.GroupBy(x => x.S_LOC_CODE);
|
Console.WriteLine($"托盘拆分。 总共{gP.Count()}个货位,{lcrl.Count}个合并的托盘。");
|
foreach (var s in gP)
|
{
|
si++;
|
db.BeginTran();
|
msg = "";
|
try
|
{
|
var loc = db.Queryable<Location>().Where(x => x.S_LOC_CODE == s.Key).First();
|
if (loc == null)
|
continue;
|
else
|
{
|
foreach (LocCntrRel item in s.ToList())
|
{
|
string cntrCode = item.S_CNTR_CODE;
|
|
var lcr = item.Clone();
|
var lcr2 = item.Clone();
|
|
lcr.S_CNTR_CODE = cntrCode.Substring(1, 23);
|
lcr.S_ID = Guid.NewGuid().ToString();
|
|
lcr2.S_CNTR_CODE = cntrCode.Substring(25, 23);
|
lcr2.S_ID = Guid.NewGuid().ToString();
|
|
var cir = item.CntrItemRel.Clone();
|
var cir2 = cir.Clone();
|
|
cir.S_CNTR_CODE = lcr.S_CNTR_CODE;
|
cir.S_ID = lcr.S_ID;
|
|
cir2.S_CNTR_CODE = lcr2.S_CNTR_CODE;
|
cir2.S_ID = lcr2.S_ID;
|
|
db.Insertable(lcr).ExecuteCommand();
|
db.Insertable(lcr2).ExecuteCommand();
|
db.Insertable(cir).ExecuteCommand();
|
db.Insertable(cir2).ExecuteCommand();
|
|
db.Deleteable(item).ExecuteCommand();
|
db.Deleteable(item.CntrItemRel).ExecuteCommand();
|
}
|
//loc.N_CAPACITY *= 2;
|
//loc.N_CURRENT_NUM *= 2;
|
if (loc.N_CURRENT_NUM > 0)
|
{
|
loc.T_EMPTY_TIME = null;
|
db.Updateable(loc).UpdateColumns(it => new { it.T_EMPTY_TIME }).ExecuteCommand();
|
}
|
//db.Updateable(loc).UpdateColumns(it => new { it.N_CAPACITY, it.N_CURRENT_NUM }).ExecuteCommand();
|
}
|
db.CommitTran();
|
Console.WriteLine($"{DateTime.Now.ToShortTimeString()} 提交第{si}个货位{s.Key}拆分数据");
|
}
|
catch (Exception ex)
|
{
|
db.RollbackTran();
|
Console.WriteLine(s.Key + " " + ex.Message);
|
}
|
finally
|
{
|
msg += s.Key;
|
}
|
}
|
|
return SimpleResult.Success(msg);
|
}
|
|
}
|
public class InmiTask
|
{
|
public string StartArea { get; set; }
|
public string EndbitArea { get; set; }
|
public string ItemCode { get; set; }
|
}
|
}
|