From 76eef0389848065963a295c66163a630697054fa Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期日, 07 七月 2024 09:47:01 +0800
Subject: [PATCH] PDA
---
代码管理/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 151 insertions(+), 18 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs"
index dfff658..aa074ec 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs"
@@ -1,4 +1,6 @@
-锘縰sing Newtonsoft.Json;
+锘縰sing Microsoft.EntityFrameworkCore;
+using Newtonsoft.Json;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -8,6 +10,7 @@
using WIDESEA_Comm.MES_Info.Request;
using WIDESEA_Comm.TaskNo;
using WIDESEA_Common;
+using WIDESEA_Core.BaseProvider;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Core.ManageUser;
using WIDESEA_Core.Utilities;
@@ -22,6 +25,123 @@
{
public partial class ToMesServer
{
+ /// <summary>
+ /// 浜哄伐鍑哄簱
+ /// </summary>
+ /// <param name="saveModel"></param>
+ /// <returns></returns>
+ public WebResponseContent Outsource(SaveModel saveModel)
+ {
+ WebResponseContent content = new WebResponseContent();
+ VOLContext context = new VOLContext();
+ Idt_inventoryRepository inventoryRepository = new dt_inventoryRepository(context);
+ Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
+ string sn = saveModel.MainData["dataSN"].ToString(); //杞﹁疆SN鍙�
+ string user = saveModel.MainData["creator"].ToString();
+ string str = "";
+ try
+ {
+ List<string> list = new List<string>();
+ foreach (var SN in sn.Split(","))
+ {
+ if (!string.IsNullOrEmpty(SN))
+ list.Add(SN);
+ }
+ var inventoryList = inventoryRepository.Find(x => list.Contains(x.SN)).ToList();
+
+ foreach (var inventorys in inventoryList.GroupBy(x => x.stationCode))
+ {
+ try
+ {
+ List<detail> lists = new List<detail>();
+ foreach (var inventory in inventorys)
+ {
+ detail detail = new detail();
+ detail.sn = inventory.SN;
+ lists.Add(detail);
+ str += str == "" ? inventory.SN : "," + inventory.SN;
+ }
+ agvInWarehousePara outWarehousePara = new agvInWarehousePara()
+ {
+ zoneID = inventorys.Key,
+ details = lists,
+ layerNo = 1,
+ stackID = "1",
+ warehouseName = "Agv搴�",
+ Operator = UserContext.Current.UserName,
+ };
+
+ Idt_info_to_mesRepository mesRepository = new dt_info_to_mesRepository(context);
+ var postJson = JsonConvert.SerializeObject(outWarehousePara);
+ dt_info_to_mes info_To_Mes = new dt_info_to_mes()
+ {
+ Info = postJson,
+ ActionName = "agvOutWarehouse",
+ Createtime = DateTime.Now,
+ Remark = "浜哄伐鍚屾MES杞﹁疆鍑哄簱",
+ State = false
+ };
+ mesRepository.Add(info_To_Mes, true);
+
+ foreach (var inventory in inventorys)
+ {
+ var station = stationinfoRepository.Find(x => x.stationCode == inventory.stationCode).FirstOrDefault();
+ station.quantity = station.quantity - 1;
+ if (station.quantity < 1)
+ {
+ station.quantity = 0;
+ station.stationType = string.Empty;
+ station.heatNumber = string.Empty;
+ station.Number = string.Empty;
+ station.billetID = string.Empty;
+ station.bindSN = string.Empty;
+ station.enable = false;
+ station.tray_status = string.Empty;
+ station.location_state = LocationStateEnum.Empty.ToString();
+ }
+ else
+ {
+ var bindSNS = station.bindSN.Split(",");
+ station.bindSN = OperStr(bindSNS, inventory.SN);
+ var billetS = station.billetID.Split(",");
+ station.billetID = OperStr(billetS, inventory.BilletNumber.ToString());
+ }
+
+ #region 鍙栨秷璺熻釜DbContext涓璺熻釜鐨勫疄浣�
+ var currentEntry = stationinfoRepository.DbContext.ChangeTracker.Entries<dt_stationinfo>().FirstOrDefault();
+ if (currentEntry != null) currentEntry.State = EntityState.Detached;
+ #endregion
+
+ stationinfoRepository.Update(station, true);
+ inventoryRepository.Delete(inventory, true);
+ }
+ WriteDBLog.Write($"浜哄伐鍑哄簱鎴愬姛 ", $"璐т綅缂栧彿锛歿inventorys.Key}锛汼N鍙凤細{str}", LogState.Sucess, "PDA", user);
+
+ }
+ catch (Exception ex)
+ {
+ content.Message = ex.Message;
+ WriteDBLog.Write($"浜哄伐鍑哄簱澶辫触 ", new { 閿欒淇℃伅 = ex.Message, 鏁版嵁 = str }, LogState.Error, "PDA", user);
+ }
+
+ }
+
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ content.Error($"浜哄伐鍑哄簱澶辫触锛�:{ex.Message}");
+ WriteDBLog.Write($"浜哄伐鍑哄簱澶辫触 ", new { 閿欒淇℃伅 = ex.Message, 鏁版嵁 = sn }, LogState.Error, "PDA", user);
+ }
+ return content;
+ }
+ public static string OperStr(string[] strArrty, string SN)
+ {
+ string[] newstr = strArrty.Where(x => x != SN).ToArray();
+ string Newsn = string.Join(",", newstr);
+
+ return Newsn;
+ }
/// <summary>
/// 澶栧崗鍑哄簱(妫�娴嬩笂鏂�)
/// </summary>
@@ -56,21 +176,34 @@
return content.Error("杞﹁疆SN鍙锋湁璇紒璇烽噸鏂版壂鎻忥紒");
#endregion
- dt_mes_detail info = null;
- dt_mes_head mes_head = null;
+ //dt_mes_detail info = null;
+ //dt_mes_head mes_head = null;
+ VV_Mes_Workinfo mes_Work = null;
int count = 0; //杞﹁疆鏁伴噺
- foreach (var item in sn.Split(","))
+ string bindSN = "";
+ List<string> list = new List<string>();
+ foreach (var SN in sn.Split(","))
+ {
+ if (!string.IsNullOrEmpty(SN))
+ list.Add(SN);
+ }
+ foreach (var item in list)
{
if (item != null)
{
count++;
- info = freeDB.Select<dt_mes_detail>().Where(x => x.SN == item).First();
- if (info == null)
- return content.Error($"绗瑊count}涓溅杞棤妫�娴嬩笂鏂欏伐鍗曡鎯咃紝璇锋牳鏌ュ伐鍗曞悗鍦ㄦ壂鎻忥紒");
- mes_head = freeDB.Select<dt_mes_head>().Where(x => x.jobID == info.jobID && x.processCode == "28").First();
- if (mes_head == null)
+ bindSN += bindSN == "" ? item : "," + item;
+
+ mes_Work = freeDB.Select<VV_Mes_Workinfo>().Where(x => x.SN == item && x.processCode == "28").First();
+ if (mes_Work == null)
return content.Error($"绗瑊count}涓溅杞棤妫�娴嬩笂鏂欏伐鍗曚俊鎭紝璇锋牳鏌ュ伐鍗曞悗鍦ㄦ壂鎻忥紒");
+ //info = freeDB.Select<dt_mes_detail>().Where(x => x.SN == item).First();
+ //if (info == null)
+ // return content.Error($"绗瑊count}涓溅杞棤妫�娴嬩笂鏂欏伐鍗曡鎯咃紝璇锋牳鏌ュ伐鍗曞悗鍦ㄦ壂鎻忥紒");
+ //mes_head = freeDB.Select<dt_mes_head>().Where(x => x.jobID == info.jobID && x.processCode == "28").First();
+ //if (mes_head == null)
+ // return content.Error($"绗瑊count}涓溅杞棤妫�娴嬩笂鏂欏伐鍗曚俊鎭紝璇锋牳鏌ュ伐鍗曞悗鍦ㄦ壂鎻忥紒");
}
}
VOLContext Context = new VOLContext();
@@ -81,12 +214,12 @@
if (!station.enable)
return content.Error($"涓嬫枡鍙stationNo}琚鐢紝璇锋牳瀹烇紒");
station.quantity = count;
- station.bindSN = sn;
- station.stationType = mes_head.drawingNo;
+ station.bindSN = bindSN;
+ station.stationType = mes_Work.drawingNo;
station.location_state = "Stroge";
- station.Number = mes_head.jobID;
- if (info.heatID != null)
- station.heatNumber = info.heatID;
+ station.Number = mes_Work.jobID;
+ if (mes_Work.heatID != null)
+ station.heatNumber = mes_Work.heatID;
station.tray_status = "StrogeTray";
stationinfoRepository.Update(station, true);
@@ -110,7 +243,7 @@
agv_fromaddress = station.stationCode,
agv_id = Guid.NewGuid(),
agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
- agv_grade = 2,
+ agv_grade = 3,
agv_createtime = DateTime.Now,
agv_taskstate = "Queue",
agv_materielid = station.stationType,
@@ -118,10 +251,10 @@
agv_tasktype = "TaskType_OutsourceOutbound",
agv_toaddress = "",
agv_userid = user,//"绯荤粺",
- jobID = mes_head.jobID,
+ jobID = mes_Work.jobID,
bindSN = station.bindSN,
- agv_worktype = Convert.ToInt32(mes_head.processCode),
- agv_materbarcode = mes_head.materialCode,
+ agv_worktype = Convert.ToInt32(mes_Work.processCode),
+ agv_materbarcode = mes_Work.materialCode,
agv_Traytype = station.tray_type,
agv_TrayStatus = station.tray_status
};
--
Gitblit v1.9.3