From 8529ae408d5e41d5982a8caab2a035e360cfc6c6 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期五, 10 五月 2024 18:26:29 +0800
Subject: [PATCH] WMS添加PDA人工出库接口
---
代码管理/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_inventoryService.cs | 9 +++
代码管理/WMS/WMS_Server/WIDESEA_WMS/ToMes/OutsourceInbound.cs | 102 +++++++++++++++++++++++++++++++++
代码管理/WMS/WMS_Server/WIDESEA_WebApi/Controllers/ToWms/ToWMSController.cs | 15 +++++
3 files changed, 125 insertions(+), 1 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_inventoryService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_inventoryService.cs"
index 8ac8691..ec2d131 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_inventoryService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WMS/Services/system/Partial/dt_inventoryService.cs"
@@ -224,6 +224,8 @@
public override WebResponseContent Del(object[] keys, bool delList = true)
{
WebResponseContent content = new WebResponseContent();
+ VOLContext context = new VOLContext();
+ Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
string str = "";
try
{
@@ -268,6 +270,13 @@
foreach (var inventory in inventorys)
{
+ var station = stationinfoRepository.Find(x => x.stationCode == inventory.stationCode).FirstOrDefault();
+ var bindSNS = station.bindSN.Split(",");
+ station.bindSN = ToMesServer.OperStr(bindSNS, inventory.SN);
+ var billetS = station.billetID.Split(",");
+ station.billetID = ToMesServer.OperStr(billetS, inventory.BilletNumber.ToString());
+ station.quantity = station.quantity - 1;
+ stationinfoRepository.Update(station, true);
_repository.Delete(inventory, true);
}
WriteDBLog.Write($"鎵嬪姩鍒犻櫎搴撳瓨 ", $"璐т綅缂栧彿锛歿inventorys.Key}锛汼N鍙凤細{str}", LogState.Sucess, "WMS", UserContext.Current.UserName);
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 7bf5815..61acc33 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,5 @@
锘縰sing Newtonsoft.Json;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
@@ -8,6 +9,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 +24,104 @@
{
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()
+ {
+ //WorkOrder = task.jobID,
+ zoneID = inventorys.Key,
+ //processCode = task.agv_worktype.ToString(),
+ details = lists,
+ layerNo = 1,
+ stackID = "1",
+ warehouseName = "Agv搴�",
+ Operator = UserContext.Current.UserName,
+ };
+ var postJson = JsonConvert.SerializeObject(outWarehousePara);
+ var mesData = Request.RequestData(postJson, MESAPIAddress.IPAddress_MES + "agvOutWarehouse");
+ if (mesData.Contains("杩炴帴灏濊瘯澶辫触")) throw new Exception(mesData);
+ MES_Response requestMes = JsonConvert.DeserializeObject<MES_Response>(mesData);
+ if (requestMes.code == "200" && requestMes.Type == "success")
+ {
+ //鏃ュ織璁板綍涓婁紶鏁版嵁鎴愬姛
+ WriteWMSLog.LogAdd("", "鎴愬姛", "MES", "PDA", postJson, mesData, "浜哄伐鍚屾MES杞﹁疆鍑哄簱", "agvOutWarehouse", requestMes.message);
+
+ foreach (var inventory in inventorys)
+ {
+ var station = stationinfoRepository.Find(x => x.stationCode == inventory.stationCode).FirstOrDefault();
+ var bindSNS = station.bindSN.Split(",");
+ station.bindSN = OperStr(bindSNS, inventory.SN);
+ var billetS = station.billetID.Split(",");
+ station.billetID = OperStr(billetS, inventory.BilletNumber.ToString());
+ station.quantity = station.quantity - 1;
+ stationinfoRepository.Update(station, true);
+ inventoryRepository.Delete(inventory, true);
+ }
+ WriteDBLog.Write($"浜哄伐鍑哄簱鎴愬姛 ", $"璐т綅缂栧彿锛歿inventorys.Key}锛汼N鍙凤細{str}", LogState.Sucess, "PDA", user);
+ }
+ else
+ {
+ WriteWMSLog.LogAdd("", "澶辫触", "MES", "PDA", postJson, mesData, "浜哄伐鍚屾MES杞﹁疆鍑哄簱", "agvOutWarehouse", requestMes.message);
+ throw new Exception("浜哄伐鍑哄簱鍚屾MES杞﹁疆鍑哄簱澶辫触锛�" + requestMes.message);
+ }
+ }
+ 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>
@@ -75,7 +175,7 @@
count++;
bindSN += bindSN == "" ? item : "," + item;
- mes_Work = freeDB.Select<VV_Mes_Workinfo>().Where(x => x.SN == item && x.processCode == "28").First();
+ 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();
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/ToWms/ToWMSController.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/ToWms/ToWMSController.cs"
index bf51130..8b4d0c3 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/ToWms/ToWMSController.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WMS_Server/WIDESEA_WebApi/Controllers/ToWms/ToWMSController.cs"
@@ -12,6 +12,7 @@
public class ToWMSController : ControllerBase
{
private static readonly object OutsourceInboundobj = new object();
+ private static readonly object Outsourceobj=new object();
private static readonly object agvTransferListobj = new object();
private static readonly object shiftingparkingobj = new object();
private static readonly object GetStationobj = new object();
@@ -80,6 +81,20 @@
}
/// <summary>
+ /// 浜哄伐鍑哄簱
+ /// </summary>
+ /// <param name="request"></param>
+ /// <returns></returns>
+ [HttpPost, Route("Outsource")]
+ public WebResponseContent Outsource([FromBody] SaveModel saveModel)
+ {
+ lock (Outsourceobj)
+ {
+ return new ToMesServer().Outsource(saveModel);
+ }
+ }
+
+ /// <summary>
/// 澶栧崗鍑哄簱(妫�娴嬩笂鏂�)
/// </summary>
/// <param name="request"></param>
--
Gitblit v1.9.3