From 23e4f986644298cb23ac43173414b7e1404b6657 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期六, 15 六月 2024 17:26:23 +0800
Subject: [PATCH] 任务逻辑优化
---
代码管理/WMS/WMS_Server/WIDESEA_WMS/Services/Taskinfo/Partial/dt_agvtaskService.cs | 307 +++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 270 insertions(+), 37 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/Taskinfo/Partial/dt_agvtaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/Taskinfo/Partial/dt_agvtaskService.cs"
index 93a35a3..cd823f3 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/Taskinfo/Partial/dt_agvtaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/Taskinfo/Partial/dt_agvtaskService.cs"
@@ -24,6 +24,13 @@
using WIDESEA_Common;
using WIDESEA_Core.ManageUser;
using WIDESEA_Comm.LogInfo;
+using StackExchange.Redis;
+using WIDESEA_Comm;
+using WIDESEA_Entity.DomainModels.Mes;
+using WIDESEA_WMS.Common;
+using System.Reflection.Emit;
+using System.Threading.Tasks;
+using System.Net;
namespace WIDESEA_WMS.Services
{
@@ -45,59 +52,285 @@
//base.Init(dbRepository);
}
/// <summary>
- /// 娣诲姞浠诲姟
+ /// 浠诲姟鏆傚仠
/// </summary>
- /// <param name="saveDataModel"></param>
+ /// <param name="saveModel"></param>
/// <returns></returns>
+ public WebResponseContent PauseTask(SaveModel saveModel)
+ {
+ WebResponseContent response = new WebResponseContent().OK();
+
+ foreach (var Key in saveModel.DelKeys)
+ {
+ try
+ {
+ var task = repository.Find(x => x.agv_id.ToString() == Key.ToString()).FirstOrDefault();
+ if (task.agv_taskstate == AGVTaskStateEnum.Queue.ToString())
+ {
+ task.agv_taskstate = AGVTaskStateEnum.Pause.ToString();
+ repository.Update(task, x => new { x.agv_taskstate }, true);
+ response.OK(response.Message += $"{task.agv_tasknum}鏆傚仠鎴愬姛!");
+ }
+ }
+ catch (Exception ex)
+ {
+ response.Error(response.Message += ex.Message);
+ }
+ }
+ return response;
+ }
+ /// <summary>
+ /// 浠诲姟缁х画
+ /// </summary>
+ /// <param name="saveModel"></param>
+ /// <returns></returns>
+ public WebResponseContent ContinueTask(SaveModel saveModel)
+ {
+ WebResponseContent response = new WebResponseContent().OK();
+
+ foreach (var Key in saveModel.DelKeys)
+ {
+ try
+ {
+ var task = repository.Find(x => x.agv_id.ToString() == Key.ToString()).FirstOrDefault();
+ if (task.agv_taskstate == AGVTaskStateEnum.Pause.ToString())
+ {
+ task.agv_taskstate = AGVTaskStateEnum.Queue.ToString();
+ repository.Update(task, x => new { x.agv_taskstate }, true);
+ response.OK(response.Message += $"{task.agv_tasknum}鎭㈠鎴愬姛!");
+ }
+ }
+ catch (Exception ex)
+ {
+ response.Error(response.Message += ex.Message);
+ }
+ }
+ return response;
+ }
+ public override WebResponseContent Del(object[] keys, bool delList = true)
+ {
+ #region 鎵归噺淇敼璐т綅鐘舵��
+ //VOLContext context = new VOLContext();
+ //Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
+ //var fromaddress = repository.Find(x => keys.Contains(x.agv_id)).Select(x => x.agv_fromaddress).ToList();
+ //var stations = stationinfoRepository.Find(x => fromaddress.Contains(x.stationCode)).ToList();
+ //foreach (var station in stations)
+ //{
+ // station.location_state = LocationStateEnum.Stroge.ToString();
+ // //station.tray_type= TrayTypeEnum.SmallTray.ToString();
+ // //station.tray_status= TrayStateEnum.StrogeTray.ToString();
+ //}
+ //stationinfoRepository.UpdateRange(stations, x => new { x.location_state }, true);
+ #endregion
+ VOLContext volContext = new VOLContext();
+ Idt_agvtask_htyRepository agvtask_HtyRepository = new dt_agvtask_htyRepository(volContext);
+ var agvtasks = repository.Find(x => keys.Contains(x.agv_id)).ToList();
+ List<dt_agvtask_hty> dt_Agvtask_Hties = new List<dt_agvtask_hty>();
+ foreach (var task in agvtasks)
+ {
+ dt_agvtask_hty agvtask_Hty = new dt_agvtask_hty()
+ {
+ hty_pkid = Guid.NewGuid(),
+ agv_id = task.agv_id,
+ agv_tasknum = task.agv_tasknum,
+ agv_materielid = task.agv_materielid,
+ agv_qty = task.agv_qty,
+ agv_createtime = task.agv_createtime,
+ agv_realesstime = task.agv_realesstime,
+ agv_executingBeginTime = task.agv_executingBeginTime,
+ agv_executingEndTime = task.agv_executingEndTime,
+ agv_completeBeginTime = task.agv_completeBeginTime,
+ agv_finishedtime = task.agv_finishedtime,
+ agv_taskstate = task.agv_taskstate,
+ agv_tasktype = task.agv_tasktype,
+ agv_fromaddress = task.agv_fromaddress,
+ agv_toaddress = task.agv_toaddress,
+ agv_operatetype = "Del",
+ agv_compeletor = UserContext.Current.UserName,
+ agv_completedate = DateTime.Now,
+ agv_grade = task.agv_grade,
+ agv_userid = task.agv_userid,
+ agv_Traytype = task.agv_Traytype,
+ agv_TrayStatus = task.agv_TrayStatus,
+ agv_worktype = task.agv_worktype,
+ agv_remark = task.agv_remark,
+ bindSN = task.bindSN,
+ jobID = task.jobID,
+ agv_materbarcode = task.agv_materbarcode,
+ };
+ dt_Agvtask_Hties.Add(agvtask_Hty);
+ }
+ agvtask_HtyRepository.AddRange(dt_Agvtask_Hties, true);
+ return base.Del(keys, delList);
+ }
+ public WebResponseContent addNgTask(MesRequestTemp requestTemp)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ var fromaddress = requestTemp.from_address;
+ VOLContext context = new VOLContext();
+ Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
+ IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context);
+ var station = stationinfoRepository.Find(x => x.stationCode == fromaddress).FirstOrDefault();
+ if (_repository.Find(x => x.agv_fromaddress == fromaddress || x.agv_toaddress == fromaddress).Any())
+ throw new Exception($"璐т綅{fromaddress}宸插瓨鍦ㄤ换鍔★紒");
+ if (station == null) throw new Exception($"鏈壘鍒拌揣浣峽fromaddress}锛�");
+ if (!station.enable) throw new Exception($"璐т綅{fromaddress}鏈惎鐢紒");
+ if (station.quantity < 1) throw new Exception($"璐т綅{fromaddress}鏃犺溅杞紒");
+ var Work = workinfoRepository.Find(x => x.workOrder == station.Number && x.processCode == "17").FirstOrDefault();
+ if (Work == null) throw new Exception($"鏈壘鍒拌揣浣峽fromaddress}鐨勬満鍔犲伐宸ュ崟淇℃伅");
+ dt_agvtask agvtask = new dt_agvtask()
+ {
+ agv_fromaddress = station.stationCode,
+ agv_id = Guid.NewGuid(),
+ agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
+ agv_grade = 2,
+ agv_createtime = DateTime.Now,
+ agv_taskstate = "Queue",
+ agv_materielid = station.stationType,
+ agv_qty = station.quantity,
+ agv_tasktype = "TaskType_OutsourceInbound",
+ agv_toaddress = "",
+ agv_userid = UserContext.Current.UserName,
+ bindSN = station.bindSN,
+ agv_worktype = Convert.ToInt32(Work.processCode),
+ agv_materbarcode = Work.materialCode,
+ agv_Traytype = station.tray_type,
+ jobID = station.Number,
+ agv_TrayStatus = station.tray_status
+ };
+ _repository.Add(agvtask, true);
+ station.location_state = LocationStateEnum.InBusy.ToString();
+ stationinfoRepository.Update(station, true);
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ content.Message = ex.Message;
+ }
+ return content;
+ }
+ public override WebResponseContent Update(SaveModel saveModel)
+ {
+ WebResponseContent content = new WebResponseContent();
+ var agv_id = saveModel.MainData["agv_id"].ToString();
+ var task = _repository.Find(x => x.agv_id.ToString() == agv_id).FirstOrDefault();
+ if (task.agv_taskstate != AGVTaskStateEnum.Queue.ToString()) return content.Error("褰撳墠浠诲姟涓嶅彲鏇存敼锛�");
+ WriteDBLog.Success($"鎵嬪姩淇敼浠诲姟", new { 鏁版嵁 = saveModel }, "WMS", UserContext.Current.UserName);
+ return base.Update(saveModel);
+ }
+ #region 娣诲姞NG浠诲姟
public override WebResponseContent Add(SaveModel saveDataModel)
{
WebResponseContent content = new WebResponseContent();
try
{
+ var fromaddress = saveDataModel.MainData["agv_fromaddress"].ToString();
VOLContext context = new VOLContext();
Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
- var fromaddress = saveDataModel.MainData["agv_fromaddress"].ToString();
- var toaddress = saveDataModel.MainData["agv_toaddress"].ToString();
- var tasktype = saveDataModel.MainData["agv_tasktype"].ToString();
- var grade = saveDataModel.MainData["agv_grade"].ToInt();
- var station1 = stationinfoRepository.FindFirst(x => x.stationCode == fromaddress);
- var station2 = stationinfoRepository.FindFirst(x => x.stationCode == toaddress);
- if (station1 == null || station2 == null)
- throw new Exception($"璧风偣鍦板潃{fromaddress}鎴栫粓鐐瑰湴鍧�{toaddress}涓嶅瓨鍦紒");
- if (string.IsNullOrEmpty(station1.stationType))
- throw new Exception($"璧风偣{fromaddress}鏈粦瀹氱墿鏂欑被鍨嬶紒");
- var task = _repository.Find(t => t.agv_fromaddress == fromaddress
- || t.agv_fromaddress == toaddress
- || t.agv_toaddress == fromaddress
- || t.agv_toaddress == toaddress
- ).Any();
- if (task)
- throw new Exception("璧峰鎴栫洰鐨勫湴鍧�锛屽凡瀛樺湪浠诲姟涓紒");
- dt_agvtask agvtask = new dt_agvtask();
- agvtask.agv_id = Guid.NewGuid();
- agvtask.agv_fromaddress = fromaddress;
- agvtask.agv_toaddress = toaddress;
- agvtask.agv_tasknum = IdenxManager.GetTaskNo("KH-");
- agvtask.agv_code = "AGV";
- agvtask.agv_taskstate = AGVTaskStateEnum.Create.ToString();
- agvtask.agv_tasktype = tasktype;
- agvtask.agv_worktype = 1;//宸ヤ綔绫诲瀷
- agvtask.agv_materielid = station1.stationType;//鐗╂枡绫诲瀷
- agvtask.agv_qty = station1.quantity;
- agvtask.agv_createtime = DateTime.Now;
- agvtask.agv_grade = grade;//浠诲姟浼樺厛绾�
- agvtask.agv_userid = UserContext.Current.UserName;
+ IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(context);
+ var station = stationinfoRepository.Find(x => x.stationCode == fromaddress).FirstOrDefault();
+ if (_repository.Find(x => x.agv_fromaddress == fromaddress || x.agv_toaddress == fromaddress).Any())
+ throw new Exception($"璐т綅{fromaddress}宸插瓨鍦ㄤ换鍔★紒");
+ if (station == null) throw new Exception($"鏈壘鍒拌揣浣峽fromaddress}锛�");
+ if (!station.enable) throw new Exception($"璐т綅{fromaddress}鏈惎鐢紒");
+ if (station.quantity < 1) throw new Exception($"璐т綅{fromaddress}鏃犺溅杞紒");
+ var Work = workinfoRepository.Find(x => x.workOrder == station.Number && x.processCode == "17").FirstOrDefault();
+ if (Work == null) throw new Exception($"鏈壘鍒拌揣浣峽fromaddress}鐨勬満鍔犲伐宸ュ崟淇℃伅");
+ dt_agvtask agvtask = new dt_agvtask()
+ {
+ agv_fromaddress = station.stationCode,
+ agv_id = Guid.NewGuid(),
+ agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
+ agv_grade = 2,
+ agv_createtime = DateTime.Now,
+ agv_taskstate = "Queue",
+ agv_materielid = station.stationType,
+ agv_qty = station.quantity,
+ agv_tasktype = "TaskType_OutsourceInbound",
+ agv_toaddress = "",
+ agv_userid = UserContext.Current.UserName,
+ bindSN = station.bindSN,
+ agv_worktype = Convert.ToInt32(Work.processCode),
+ agv_materbarcode = Work.materialCode,
+ agv_Traytype = station.tray_type,
+ jobID = station.Number,
+ agv_TrayStatus = station.tray_status
+ };
_repository.Add(agvtask, true);
+ station.location_state = LocationStateEnum.InBusy.ToString();
+ stationinfoRepository.Update(station, true);
content.OK();
- WriteDBLog.Success($"鎵嬪姩娣诲姞浠诲姟", new { 鏁版嵁 = saveDataModel }, "WMS", UserContext.Current.UserName);
}
catch (Exception ex)
{
- WriteDBLog.Error($"鎵嬪姩娣诲姞浠诲姟", new { 鏁版嵁 = saveDataModel, 寮傚父淇℃伅 = ex.Message }, "WMS", UserContext.Current.UserName);
- content.Error(ex.Message);
+ content.Message = ex.Message;
}
-
return content;
}
+ #endregion
+
+ #region 娣诲姞浠诲姟
+ /// <summary>
+ /// 娣诲姞浠诲姟
+ /// </summary>
+ /// <param name="saveDataModel"></param>
+ /// <returns></returns>
+ //public override WebResponseContent Add(SaveModel saveDataModel)
+ //{
+ // WebResponseContent content = new WebResponseContent();
+ // try
+ // {
+ // VOLContext context = new VOLContext();
+ // Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
+ // var fromaddress = saveDataModel.MainData["agv_fromaddress"].ToString();
+ // var toaddress = saveDataModel.MainData["agv_toaddress"].ToString();
+ // var tasktype = saveDataModel.MainData["agv_tasktype"].ToString();
+ // var grade = saveDataModel.MainData["agv_grade"].ToInt();
+ // var worktype = saveDataModel.MainData["agv_worktype"].ToInt();
+ // var station1 = stationinfoRepository.FindFirst(x => x.stationCode == fromaddress);
+ // var station2 = stationinfoRepository.FindFirst(x => x.stationCode == toaddress);
+ // if (station1 == null || station2 == null)
+ // throw new Exception($"璧风偣鍦板潃{fromaddress}鎴栫粓鐐瑰湴鍧�{toaddress}涓嶅瓨鍦紒");
+ // if (string.IsNullOrEmpty(station1.stationType))
+ // throw new Exception($"璧风偣{fromaddress}鏈粦瀹氱墿鏂欑被鍨嬶紒");
+ // var task = _repository.Find(t => t.agv_fromaddress == fromaddress
+ // || t.agv_fromaddress == toaddress
+ // || t.agv_toaddress == fromaddress
+ // || t.agv_toaddress == toaddress
+ // ).Any();
+ // if (task)
+ // throw new Exception("璧峰鎴栫洰鐨勫湴鍧�锛屽凡瀛樺湪浠诲姟涓紒");
+ // dt_agvtask agvtask = new dt_agvtask();
+ // agvtask.agv_id = Guid.NewGuid();
+ // agvtask.agv_fromaddress = fromaddress;
+ // agvtask.agv_toaddress = toaddress;
+ // agvtask.agv_tasknum = IdenxManager.GetTaskNo("KH-");
+ // agvtask.agv_TrayStatus = station1.tray_status;
+ // agvtask.agv_Traytype = station1.tray_type;
+ // agvtask.agv_taskstate = AGVTaskStateEnum.Create.ToString();
+ // agvtask.agv_tasktype = tasktype;
+ // agvtask.agv_worktype = worktype;//宸ヤ綔绫诲瀷
+ // agvtask.bindSN = station1.bindSN;
+ // agvtask.agv_materielid = station1.stationType;//鐗╂枡绫诲瀷
+ // agvtask.agv_qty = station1.quantity;
+ // agvtask.agv_createtime = DateTime.Now;
+ // agvtask.agv_grade = grade;//浠诲姟浼樺厛绾�
+ // agvtask.agv_userid = UserContext.Current.UserName;
+ // _repository.Add(agvtask, true);
+ // content.OK();
+ // WriteDBLog.Success($"鎵嬪姩娣诲姞浠诲姟", new { 鏁版嵁 = saveDataModel }, "WMS", UserContext.Current.UserName);
+ // }
+ // catch (Exception ex)
+ // {
+ // WriteDBLog.Error($"鎵嬪姩娣诲姞浠诲姟", new { 鏁版嵁 = saveDataModel, 寮傚父淇℃伅 = ex.Message }, "WMS", UserContext.Current.UserName);
+ // content.Error(ex.Message);
+ // }
+
+ // return content;
+ //}
+ #endregion
+
}
}
--
Gitblit v1.9.3