From 76eef0389848065963a295c66163a630697054fa Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期日, 07 七月 2024 09:47:01 +0800
Subject: [PATCH] PDA
---
代码管理/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/dt_patternService.cs | 110 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 95 insertions(+), 15 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/dt_patternService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/dt_patternService.cs"
index c9977db..1d9eb35 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/dt_patternService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/dt_patternService.cs"
@@ -19,6 +19,12 @@
using WIDESEA_WCS.IRepositories;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Newtonsoft.Json;
+using WIDESEA_Core.EFDbContext;
+using WIDESEA_WCS.Repositories;
+using WIDESEA_Comm;
+using WIDESEA_WCS.WCSClient;
+using System.Xml.Linq;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
namespace WIDESEA_WCS.Services
{
@@ -39,29 +45,103 @@
//澶氱鎴蜂細鐢ㄥ埌杩檌nit浠g爜锛屽叾浠栨儏鍐靛彲浠ヤ笉鐢�
//base.Init(dbRepository);
}
+ /// <summary>
+ /// 妯″紡1
+ /// </summary>
+ /// <param name="v"></param>
+ /// <returns></returns>
public WebResponseContent UpdateAuto(string v)
{
WebResponseContent content = new WebResponseContent();
- var model = JsonConvert.DeserializeObject<dt_pattern>(v);
- model.pattern_state = 1;
- var cont = _repository.Update(model, true);
- if (cont > 0)
- content.OK(model.pattern_name + "璁剧疆涓鸿嚜鍔ㄥ叆搴撴垚鍔燂紒");
- else
- content.Error(model.pattern_name + "璁剧疆涓鸿嚜鍔ㄥ叆搴撳け璐ワ紒");
+ try
+ {
+ var model = JsonConvert.DeserializeObject<dt_pattern>(v);
+ if (model.pattern_state == 1) throw new Exception("褰撳墠灏辨槸妯″紡1");
+ var Gantry_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "妗佹灦");
+ if (Gantry_client == null) throw new Exception("妗佹灦璋冨害鏈嶅姟鏈紑鍚紒");
+ if (!Gantry_client.IsConnected) throw new Exception("涓庢鏋惰繛鎺ヨ秴鏃讹紒");
+ VOLContext context = new VOLContext();
+ Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
+ var stations = stationinfoRepository.Find(x => x.stationCode == "X01001001" || x.stationCode == "X01001002" || x.stationCode == "X02001001" || x.stationCode == "X02001002").ToList();
+ if (stations.Where(x => x.tray_status == TrayStateEnum.StrogeTray.ToString()).Any())
+ throw new Exception("璁剧疆涓烘ā寮�1澶辫触锛佷笅鏂欎綅瀛樺湪杞﹁疆锛�");
+
+
+ #region 鍐欏叆淇″彿鍛婅瘔妗佹灦鍒囨崲妯″紡
+ var ok = Gantry_client.ReadByOrder<bool>("o_enable_change_mode", model.pattern_name);
+ #endregion
+ if (ok)
+ {
+ Gantry_client.WriteByOrder("i_mode", (Int16)1, model.pattern_name);
+ model.pattern_state = 1;
+ var cont = _repository.Update(model, true);
+ if (cont > 0)
+ content.OK(model.pattern_name + "璁剧疆涓烘ā寮�1鎴愬姛锛�");
+ else
+ throw new Exception(model.pattern_name + "璁剧疆涓烘ā寮�2澶辫触锛�");
+ foreach (var stat in stations)
+ {
+ stat.enable = true;
+ }
+ stationinfoRepository.UpdateRange(stations, x => new { x.enable }, true);
+ }
+ else
+ content.Error(model.pattern_name + "璁剧疆涓烘ā寮�1澶辫触锛佹鏋舵湭鍏佽璁剧疆涓烘ā寮�1");
+
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
return content;
}
+ /// <summary>
+ /// 妯″紡2
+ /// </summary>
+ /// <param name="v"></param>
+ /// <returns></returns>
public WebResponseContent UpdateManual(string v)
{
WebResponseContent content = new WebResponseContent();
- var model = JsonConvert.DeserializeObject<dt_pattern>(v);
- model.pattern_state = 0;
- var cont = _repository.Update(model, true);
- if (cont > 0)
- content.OK(model.pattern_name + "璁剧疆涓烘墜鍔ㄥ叆搴撴垚鍔燂紒");
- else
- content.Error(model.pattern_name + "璁剧疆涓烘墜鍔ㄥ叆搴撳け璐ワ紒");
+ try
+ {
+ var model = JsonConvert.DeserializeObject<dt_pattern>(v);
+ if (model.pattern_state == 0) throw new Exception("褰撳墠灏辨槸妯″紡2");
+ var Gantry_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "妗佹灦");
+ if (Gantry_client == null) throw new Exception("妗佹灦璋冨害鏈嶅姟鏈紑鍚紒");
+ if (!Gantry_client.IsConnected) throw new Exception("涓庢鏋惰繛鎺ヨ秴鏃讹紒");
+ VOLContext context = new VOLContext();
+ Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
+ var stations = stationinfoRepository.Find(x => x.stationCode == "X01001001" || x.stationCode == "X01001002" || x.stationCode == "X02001001" || x.stationCode == "X02001002").ToList();
+ if (stations.Where(x => x.tray_status == TrayStateEnum.StrogeTray.ToString()).Any())
+ throw new Exception("璁剧疆涓烘ā寮�2澶辫触锛佷笅鏂欎綅瀛樺湪杞﹁疆锛�");
+ #region 鍐欏叆淇″彿鍛婅瘔妗佹灦鍒囨崲妯″紡
+ var ok = Gantry_client.ReadByOrder<bool>("o_enable_change_mode", model.pattern_name);
+ #endregion
+ if (ok)
+ {
+ Gantry_client.WriteByOrder("i_mode", (Int16)2, model.pattern_name);
+ model.pattern_state = 0;
+ var cont = _repository.Update(model, true);
+ if (cont > 0)
+ content.OK(model.pattern_name + "璁剧疆涓烘ā寮�2鎴愬姛锛�");
+ else
+ throw new Exception(model.pattern_name + "璁剧疆涓烘ā寮�2澶辫触锛�");
+ foreach (var stat in stations)
+ {
+ stat.enable = false;
+ }
+ stationinfoRepository.UpdateRange(stations, x => new { x.enable }, true);
+ }
+ else
+ content.Error(model.pattern_name + "璁剧疆涓烘ā寮�2澶辫触锛佹鏋舵湭鍏佽璁剧疆涓烘ā寮�2");
+
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
return content;
}
- }
+ }
}
--
Gitblit v1.9.3