|
@@ -4,9 +4,11 @@ using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
+using WCS_Client.Extensions;
|
|
|
+using WCS_Client.Frm;
|
|
|
using WCS_Client.Models;
|
|
|
using WCS_Client.Utility;
|
|
|
-using WCS_Client.From.From_Montior;
|
|
|
+using WCS_TASK = WCS_Client.Models.WCS_TASK;
|
|
|
|
|
|
namespace WCS_Client
|
|
|
{
|
|
@@ -18,6 +20,7 @@ namespace WCS_Client
|
|
|
重下RGV下料 = 4,
|
|
|
重下任务 = 5
|
|
|
}
|
|
|
+
|
|
|
public enum WkStatus
|
|
|
{
|
|
|
未下发 = 0,
|
|
@@ -30,6 +33,7 @@ namespace WCS_Client
|
|
|
取消任务 = 106,
|
|
|
手动过账 = 109
|
|
|
}
|
|
|
+
|
|
|
public enum TaskType
|
|
|
{
|
|
|
组盘 = 0,
|
|
@@ -37,6 +41,7 @@ namespace WCS_Client
|
|
|
出库 = 2,
|
|
|
输送 = 5,
|
|
|
}
|
|
|
+
|
|
|
public class BaseWorkflow
|
|
|
{
|
|
|
public static bool Login(string use_No, string use_Pwd, out string errMsg)
|
|
@@ -135,6 +140,7 @@ namespace WCS_Client
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
public static PageData QueryDatatble(DataTable dt, int PageIndex, int PageSize)
|
|
|
{
|
|
|
if (PageSize <= 0) PageSize = 2000;
|
|
@@ -142,7 +148,6 @@ namespace WCS_Client
|
|
|
int endRecord = startRecord + PageSize - 1;
|
|
|
try
|
|
|
{
|
|
|
-
|
|
|
int count = dt.Rows.Count;
|
|
|
int PageCount = count / PageSize;
|
|
|
if (count % PageSize > 0)
|
|
@@ -164,8 +169,8 @@ namespace WCS_Client
|
|
|
{
|
|
|
}
|
|
|
return null;
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
public static PageData QueryPageData(string _SQLText, string orderText, List<string> WhereStringList, int PageIndex, int PageSize)
|
|
|
{
|
|
|
var sb = new StringBuilder();
|
|
@@ -180,6 +185,7 @@ namespace WCS_Client
|
|
|
}
|
|
|
return QueryPageSql(sb.ToString(), orderText, PageIndex, PageSize);
|
|
|
}
|
|
|
+
|
|
|
private static PageData QueryPageSql(string SQLText, string OrderText, int PageIndex, int PageSize)
|
|
|
{
|
|
|
if (PageSize <= 0) PageSize = 2000;
|
|
@@ -195,6 +201,42 @@ namespace WCS_Client
|
|
|
TryCachHelper.TryExecute((db) =>
|
|
|
{
|
|
|
dt = db.Ado.GetDataTable(sql);
|
|
|
+ //新增列
|
|
|
+ string ADDRCURRENT = "ADDRCURRENT";
|
|
|
+ string ADDRline = "ADDRline";
|
|
|
+ dt.addDataColumn(new List<string> { ADDRCURRENT, ADDRline });
|
|
|
+ //获取当前所有任务对应的AGV任务
|
|
|
+ List<int> agvIDs = (from d in dt.AsEnumerable() select d.Field<int>("AgvTask")).Where(p => p > 0).ToList();
|
|
|
+ string ids = "";
|
|
|
+ agvIDs.ForEach(p =>
|
|
|
+ {
|
|
|
+ ids += p;
|
|
|
+ if (p != agvIDs[agvIDs.Count - 1]) ids += ",";
|
|
|
+ });
|
|
|
+ var _sql = $"select * from WCS_AGVTask where ID in ({ids})";
|
|
|
+ List<WCS_AGVTask> _AGVTASKs = db.SqlQueryable<WCS_AGVTask>(_sql).ToList();
|
|
|
+ //向新增列写入数据
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ //写入输送线
|
|
|
+ dt.Rows[i][ADDRCURRENT] = eqpData.deviceDataPack.StationDatas.Datas.Where(p => p.D521.TASKNUM == (int)dt.Rows[i][1] && p.D521.PH_STATUS).FirstOrDefault()?.Code;
|
|
|
+ //不在输送线,尝试写入RGV
|
|
|
+ if (string.IsNullOrEmpty(dt.Rows[i][ADDRCURRENT].ToString()))
|
|
|
+ {
|
|
|
+ dt.Rows[i][ADDRCURRENT] = eqpData.deviceDataPack.RGVDatas.Datas.Where(p => p.D521.TaskID == (int)dt.Rows[i][1] && p.D521.PH_Status).FirstOrDefault()?.Code;
|
|
|
+ }
|
|
|
+ //不在输送线/RGV,尝试写入堆垛机
|
|
|
+ if (string.IsNullOrEmpty(dt.Rows[i][ADDRCURRENT].ToString()))
|
|
|
+ {
|
|
|
+ dt.Rows[i][ADDRCURRENT] = eqpData.deviceDataPack.SCDatas.Datas.Where(p => p.D521.TaskID == (int)dt.Rows[i][1]).FirstOrDefault()?.Code;
|
|
|
+ }
|
|
|
+ var a = _AGVTASKs.Where(p => p.ID == (int)dt.Rows[i]["AgvTask"]).FirstOrDefault()?.Position;
|
|
|
+ //开始写入产线
|
|
|
+ dt.Rows[i][ADDRline] = _AGVTASKs.Where(p => p.ID == (int)dt.Rows[i]["AgvTask"]).FirstOrDefault()?.Position;
|
|
|
+
|
|
|
+ dt.AcceptChanges();
|
|
|
+ }
|
|
|
+
|
|
|
count = Convert.ToInt32(db.Ado.GetScalar(CountStr));
|
|
|
});
|
|
|
int PageCount = count / PageSize;
|
|
@@ -230,6 +272,7 @@ namespace WCS_Client
|
|
|
}
|
|
|
return QueryPageSql2(sb.ToString(), orderText, PageIndex, PageSize);
|
|
|
}
|
|
|
+
|
|
|
private static PageData QueryPageSql2(string SQLText, string OrderText, int PageIndex, int PageSize)
|
|
|
{
|
|
|
if (PageSize <= 0) PageSize = 2000;
|
|
@@ -292,6 +335,7 @@ namespace WCS_Client
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
public static DataTable CommonQueryUser(string sql)
|
|
|
{
|
|
|
DataTable dt = null;
|
|
@@ -329,12 +373,13 @@ namespace WCS_Client
|
|
|
}
|
|
|
return dt;
|
|
|
}
|
|
|
+
|
|
|
public static DataTable CommonQuery(string sql)
|
|
|
{
|
|
|
DataTable dt = null;
|
|
|
TryCachHelper.TryExecute((db) =>
|
|
|
{
|
|
|
- dt = db.Ado.GetDataTable(sql);
|
|
|
+ dt = db.Ado.GetDataTable(sql);
|
|
|
});
|
|
|
return dt;
|
|
|
}
|
|
@@ -423,7 +468,7 @@ namespace WCS_Client
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public static string AdminModifyPwd(string user_no,string user_pwd)
|
|
|
+ public static string AdminModifyPwd(string user_no, string user_pwd)
|
|
|
{
|
|
|
string result = string.Empty;
|
|
|
try
|
|
@@ -471,7 +516,7 @@ namespace WCS_Client
|
|
|
// else
|
|
|
// {
|
|
|
// result = LangConst.UserNotExists;
|
|
|
- // }
|
|
|
+ // }
|
|
|
//}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -486,14 +531,17 @@ namespace WCS_Client
|
|
|
{
|
|
|
return CommonQuery(string.Format("SELECT * FROM WCS_Mappingentry where Mep_MappingType='Sex'"));
|
|
|
}
|
|
|
+
|
|
|
public static DataTable QueryUse_Role()
|
|
|
{
|
|
|
return CommonQuery(string.Format("SELECT * FROM WCS_Mappingentry where Mep_MappingType='RoleId'"));
|
|
|
}
|
|
|
+
|
|
|
public static DataTable QueryTaskType()
|
|
|
{
|
|
|
return CommonQuery(string.Format("SELECT * FROM WCS_Mappingentry where Mep_MappingType='COMTYPE'"));
|
|
|
}
|
|
|
+
|
|
|
public static void AddWCS_TASK_DTL(SqlSugarClient db, int task_id, int task_no, string posIdCur, string posIdNext, string msg)
|
|
|
{
|
|
|
var task_dtl = new WCS_TASK_DTL();
|
|
@@ -506,6 +554,7 @@ namespace WCS_Client
|
|
|
task_dtl.EXECUTEDATE = DateTime.Now;
|
|
|
db.Insertable(task_dtl).ExecuteCommand();
|
|
|
}
|
|
|
+
|
|
|
public static string UpdateTask(int taskid, TaskStatusType taskStatusType)
|
|
|
{
|
|
|
string result = string.Empty;
|
|
@@ -768,7 +817,8 @@ namespace WCS_Client
|
|
|
.Where(it => it.EQUIPMENTNO == equipmentNo).ExecuteCommand();
|
|
|
});
|
|
|
}
|
|
|
- public static List<Frm.WCS_SC521> QueryStackerdDataDDJ(List<string> plcnameSet)
|
|
|
+
|
|
|
+ public static List<Frm.WCS_SC521> QueryStackerdDataDDJ(List<string> plcnameSet)
|
|
|
{
|
|
|
var stackerdDataSet = new List<Frm.WCS_SC521>();
|
|
|
TryCachHelper.TryExecute((db) =>
|
|
@@ -777,6 +827,7 @@ namespace WCS_Client
|
|
|
});
|
|
|
return stackerdDataSet;
|
|
|
}
|
|
|
+
|
|
|
public static List<Frm.WCS_RGV521> QueryStackerdDataRGV(List<string> plcnameSet)
|
|
|
{
|
|
|
var stackerdDataSet = new List<Frm.WCS_RGV521>();
|
|
@@ -809,6 +860,7 @@ namespace WCS_Client
|
|
|
throw new Exception(string.Format("任务[{0}]修改优先级为[{0}]失败", task_no, priority));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 任务完成
|
|
|
/// </summary>
|
|
@@ -821,6 +873,7 @@ namespace WCS_Client
|
|
|
message = string.Empty;
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 任务取消
|
|
|
/// </summary>
|
|
@@ -832,6 +885,7 @@ namespace WCS_Client
|
|
|
msg = string.Empty;
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
public static string RestartTask(int task_no)
|
|
|
{
|
|
|
string result = TryCachHelper.TryExecute((db) =>
|
|
@@ -843,8 +897,7 @@ namespace WCS_Client
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
- if (task.TYPE == Frm.TaskType.出库 && task.STATUS > 0 && task.STATUS < 99)
|
|
|
+ if (task.TYPE == Frm.TaskType.出库 && task.STATUS > 0 && task.STATUS < 99)
|
|
|
{
|
|
|
if (db.Updateable<Frm.WCS_TASK>()
|
|
|
.UpdateColumns(it => new Frm.WCS_TASK
|
|
@@ -865,6 +918,7 @@ namespace WCS_Client
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
public static string SrmInfoSet(string convNo, bool isStop)
|
|
|
{
|
|
|
string result = TryCachHelper.TryExecute((db) =>
|
|
@@ -907,6 +961,7 @@ namespace WCS_Client
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
public static string OnUpMatRestart(int task_no)
|
|
|
{
|
|
|
string result = TryCachHelper.TryExecute((db) =>
|
|
@@ -942,6 +997,7 @@ namespace WCS_Client
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
public static string OnMatRestart(int task_no)
|
|
|
{
|
|
|
string result = TryCachHelper.TryExecute((db) =>
|
|
@@ -977,6 +1033,7 @@ namespace WCS_Client
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
public static string UpMatRestart(int task_no)
|
|
|
{
|
|
|
string result = TryCachHelper.TryExecute((db) =>
|
|
@@ -1013,6 +1070,7 @@ namespace WCS_Client
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
public static string FinishTask(int task_no)
|
|
|
{
|
|
|
string result = TryCachHelper.TryExecute((db) =>
|
|
@@ -1024,29 +1082,29 @@ namespace WCS_Client
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
- if (task.STATUS > 1)
|
|
|
- {
|
|
|
- if (db.Updateable<Frm.WCS_TASK>()
|
|
|
- .UpdateColumns(it => new Frm.WCS_TASK
|
|
|
- {
|
|
|
- STATUS = 99,
|
|
|
- UPDATEUSER = CurrentHelper.User.USER_NO,
|
|
|
- UPDATETIME = DateTime.Now
|
|
|
- })
|
|
|
- .Where(v => v.ID == task_no).ExecuteCommand() < 0)
|
|
|
- {
|
|
|
- throw new Exception(string.Format("任务[{0}]手动完成失败", task_no));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
+ if (task.STATUS > 1)
|
|
|
+ {
|
|
|
+ if (db.Updateable<Frm.WCS_TASK>()
|
|
|
+ .UpdateColumns(it => new Frm.WCS_TASK
|
|
|
+ {
|
|
|
+ STATUS = 99,
|
|
|
+ UPDATEUSER = CurrentHelper.User.USER_NO,
|
|
|
+ UPDATETIME = DateTime.Now
|
|
|
+ })
|
|
|
+ .Where(v => v.ID == task_no).ExecuteCommand() < 0)
|
|
|
{
|
|
|
- throw new Exception(string.Format("任务[{0}]未执行,不能执行[手动完成].", task_no));
|
|
|
+ throw new Exception(string.Format("任务[{0}]手动完成失败", task_no));
|
|
|
}
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new Exception(string.Format("任务[{0}]未执行,不能执行[手动完成].", task_no));
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
public static string ClearTask(int task_no)
|
|
|
{
|
|
|
string result = TryCachHelper.TryTranExecute((db) =>
|
|
@@ -1058,25 +1116,24 @@ namespace WCS_Client
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
- if (task.STATUS < 99)
|
|
|
- {
|
|
|
- if (db.Updateable<Frm.WCS_TASK>()
|
|
|
- .UpdateColumns(it => new Frm.WCS_TASK
|
|
|
- {
|
|
|
- STATUS = 106,
|
|
|
- UPDATETIME = DateTime.Now
|
|
|
- })
|
|
|
- .Where(v => v.ID == task_no).ExecuteCommand() < 0)
|
|
|
- {
|
|
|
- throw new Exception(string.Format("任务[{0}]取消失败", task_no));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
+ if (task.STATUS < 99)
|
|
|
+ {
|
|
|
+ if (db.Updateable<Frm.WCS_TASK>()
|
|
|
+ .UpdateColumns(it => new Frm.WCS_TASK
|
|
|
+ {
|
|
|
+ STATUS = 106,
|
|
|
+ UPDATETIME = DateTime.Now
|
|
|
+ })
|
|
|
+ .Where(v => v.ID == task_no).ExecuteCommand() < 0)
|
|
|
{
|
|
|
- throw new Exception(string.Format("任务[{0}]已完成或已取消,不能执行取消动作。", task_no));
|
|
|
+ throw new Exception(string.Format("任务[{0}]取消失败", task_no));
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new Exception(string.Format("任务[{0}]已完成或已取消,不能执行取消动作。", task_no));
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
@@ -1162,7 +1219,7 @@ namespace WCS_Client
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public static string UpdateTaskPriority(int task_no,int priority)
|
|
|
+ public static string UpdateTaskPriority(int task_no, int priority)
|
|
|
{
|
|
|
string result = TryCachHelper.TryTranExecute((db) =>
|
|
|
{
|
|
@@ -1192,32 +1249,39 @@ namespace WCS_Client
|
|
|
result = string.Format("任务[{0}]调整优先级[{1}]成功。", task_no, priority);
|
|
|
}
|
|
|
return result;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
public class WCS_SCANN
|
|
|
{
|
|
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
|
|
public string SCANN_ID { get; set; }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 扫描位置编号
|
|
|
/// </summary>
|
|
|
public string SCANN_STATIONNO { get; set; }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 扫描到的条码
|
|
|
/// </summary>
|
|
|
public string SCANN_BARCODE { get; set; }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 顺序
|
|
|
/// </summary>
|
|
|
public int SCANN_SEQUENCE { get; set; }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// PLC名称
|
|
|
/// </summary>
|
|
|
public string SCANN_PLCNAME { get; set; }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 起点地址
|
|
|
/// </summary>
|
|
|
public int SCANN_STARTADDRESS { get; set; }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 扫描长度
|
|
|
/// </summary>
|
|
@@ -1229,4 +1293,4 @@ namespace WCS_Client
|
|
|
public DateTime SCANN_UPDATETIME { get; set; }
|
|
|
public DateTime SYSDATE { get; set; }
|
|
|
}
|
|
|
-}
|
|
|
+}
|