From 94b11f93e7985e8ca499465af228f78301fd6e86 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 11 三月 2025 17:32:27 +0800
Subject: [PATCH] 1
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs | 199 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 196 insertions(+), 3 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs"
index 9fd4301..4e165fe 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs"
@@ -1,4 +1,5 @@
锘縰sing AutoMapper;
+using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -14,12 +15,14 @@
using WIDESEA_Core.Utilities;
using WIDESEA_DTO;
using WIDESEA_DTO.Inbound;
+using WIDESEA_DTO.WCSInfo;
using WIDESEA_IBasicService;
using WIDESEA_IInboundRepository;
using WIDESEA_IInboundService;
using WIDESEA_IStockService;
using WIDESEA_ITaskInfoRepository;
using WIDESEA_Model.Models;
+using WIDESEAWCS_DTO.WCSInfo;
namespace WIDESEA_InboundService
{
@@ -33,11 +36,149 @@
/// <returns></returns>
public Dt_InboundOrder GetInboundOrder(string inboundOrderNo)
{
- return BaseDal.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).First(x => x.OrderNo == inboundOrderNo); ;
+ return BaseDal.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).First(x => x.OrderNo == inboundOrderNo);
+ }
+ public bool UpdateDataWithDetail(Dt_InboundOrder inboundOrder)
+ {
+ return Db.UpdateNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
+ }
+ /// <summary>
+ /// 绌烘墭缁勭洏鍏ュ簱
+ /// </summary>
+ /// <param name="materielGroupDTO"></param>
+ /// <returns></returns>
+ public WebResponseContent PdaAddEmptyStockInfo(PdaMaterielGroupDTO materielGroupDTO)
+ {
+ try
+ {
+ #region 娣诲姞涓�涓┖鎵樼粍鐩樹俊鎭強绌烘墭浠诲姟骞朵笅鍙戠粰WCS
+ Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(materielGroupDTO.PalletCode);
+ if (stockInfo != null) throw new Exception($"鎵樼洏鍙枫�恵stockInfo.PalletCode}銆戝凡瀛樺湪缁勭洏淇℃伅");
+ Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == materielGroupDTO.PalletCode && x.TaskType == TaskTypeEnum.PalletInbound.ObjToInt());
+ if (task == null)
+ {
+ task = new Dt_Task()
+ {
+ CurrentAddress = "",
+ NextAddress = "SC01",
+ SourceAddress = "",
+ TargetAddress = "SC01",
+ Creater = "System",
+ PalletCode = materielGroupDTO.PalletCode,
+ Roadway = "SC01",
+ OrderNo = DateTime.Now.ToString("yyMMdd"),
+ TaskNum = _taskRepository.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+ TaskState = InTaskStatusEnum.InNew.ObjToInt(),
+ TaskType = TaskTypeEnum.PalletInbound.ObjToInt(),
+ CreateDate = DateTime.Now,
+ Dispatchertime = DateTime.Now,
+ };
+ Db.Ado.BeginTran();
+ _stockService.StockInfoService.AddStockEmpty(materielGroupDTO.PalletCode);
+ _taskRepository.AddData(task);
+ Db.Ado.CommitTran();
+ }
+ List<WMSTaskDTO> wMSTaskDTOs = _mapper.Map<List<WMSTaskDTO>>(task);
+ var ResultData = HttpHelper.PostAsync(WCSInterfaceAddress.ReceiveTask, wMSTaskDTOs.ToJson(), headers: new Dictionary<string, string>());
+ if (ResultData.Result == null) throw new Exception($"鍚慦CS涓嬪彂绌烘墭鍏ュ簱浠诲姟瓒呮椂");
+ WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(ResultData.Result);
+ if (content == null) throw new Exception($"涓嬪彂绌烘墭鍏ュ簱浠诲姟WCS鏃犲搷搴�");
+ if (!content.Status) throw new Exception(content.Message);
+ #endregion
+ return WebResponseContent.Instance.OK();
+ }
+ catch (Exception ex)
+ {
+ Db.Ado.RollbackTran();
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
+ /// <summary>
+ /// PDA缁勭洏
+ /// 鍗曠鐗╂枡缁勭洏
+ /// </summary>
+ /// <param name="pdaMaterielGroupDTO"></param>
+ /// <returns></returns>
+ public WebResponseContent PdaAddStockInfo(PdaMaterielGroupDTO pdaMaterielGroupDTO)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ Dt_MaterielInfo materielInfo = _basicService.MaterielInfoService.GetMaterielInfo(pdaMaterielGroupDTO.MaterielCode);
+
+ Dt_InboundOrder inboundOrder = GetInboundOrder(pdaMaterielGroupDTO.OrderNo);
+
+ Dt_StockInfo? stockInfo = _stockService.StockInfoService.GetStockByPalletCode(pdaMaterielGroupDTO.PalletCode);
+
+ var result = CheckMaterielGroupParam(pdaMaterielGroupDTO, materielInfo, inboundOrder, stockInfo);
+ if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
+
+ if (stockInfo == null)
+ {
+ stockInfo = new Dt_StockInfo();
+ stockInfo.Details = new List<Dt_StockInfoDetail>();
+ }
+ var stockInfoDetail = stockInfo.Details.Where(x => pdaMaterielGroupDTO.MaterielCode == x.MaterielCode && x.BatchNo == pdaMaterielGroupDTO.BatchNo).FirstOrDefault();
+ if (stockInfoDetail == null)
+ {
+ stockInfoDetail = new Dt_StockInfoDetail()
+ {
+ Status = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt(),
+ OrderNo = inboundOrder.OrderNo,
+ StockId = stockInfo.Id != 0 ? stockInfo.Id : 0,
+ MaterielName = materielInfo.MaterielName,
+ MaterielCode = materielInfo.MaterielCode,
+ BatchNo = pdaMaterielGroupDTO.BatchNo,
+ StockQuantity = pdaMaterielGroupDTO.ReceiptQuantity,
+ SerialNumber = $"{inboundOrder.OrderNo} | {materielInfo.MaterielCode} | {pdaMaterielGroupDTO.BatchNo} | {pdaMaterielGroupDTO.ReceiptQuantity}",
+ Creater = "System"
+ };
+ if (stockInfo.Id == 0)
+ {
+ stockInfo.PalletCode = pdaMaterielGroupDTO.PalletCode;
+ stockInfo.StockStatus = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt();
+ stockInfo.Creater = "System";
+ }
+ stockInfo.Details.Add(stockInfoDetail);
+ }
+ else
+ {
+ stockInfoDetail.StockQuantity += pdaMaterielGroupDTO.ReceiptQuantity;
+ stockInfoDetail.SerialNumber = $"{inboundOrder.OrderNo} | {materielInfo.MaterielCode} | {pdaMaterielGroupDTO.BatchNo} | {(int)stockInfoDetail.StockQuantity}";
+ }
+
+
+ Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.Where(x => materielInfo.MaterielCode == x.MaterielCode && x.BatchNo == pdaMaterielGroupDTO.BatchNo).FirstOrDefault();//璁㈠崟璇︽儏
+
+ inboundOrderDetail.ReceiptQuantity++;
+ inboundOrderDetail.OrderDetailStatus = inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity ? OrderDetailStatusEnum.Over.ObjToInt() : OrderDetailStatusEnum.GroupAndInbound.ObjToInt();
+
+ if (inboundOrder.Details.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) == null)
+ {
+ inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt();
+ }
+ else if (inboundOrder.OrderStatus == InboundStatusEnum.鏈紑濮�.ObjToInt())
+ {
+ inboundOrder.OrderStatus = InboundStatusEnum.鍏ュ簱涓�.ObjToInt();
+ }
+
+ _unitOfWorkManage.BeginTran();
+ UpdateData(inboundOrder);
+ _inboundOrderDetailService.UpdateData(inboundOrderDetail);
+ _stockService.StockInfoService.AddMaterielGroup(stockInfo);
+ _unitOfWorkManage.CommitTran();
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ content.Error(ex.Message);
+ }
+ return content;
}
/// <summary>
- /// 缁勭洏
+ /// MES涓嬪彂缁勭洏
/// </summary>
/// <param name="materielGroupDTO"></param>
/// <returns></returns>
@@ -71,7 +212,7 @@
List<Dt_StockInfoDetail> stockInfoDetails = _mapper.Map<List<Dt_StockInfoDetail>>(matSerialNumberDTOs);
stockInfoDetails.ForEach(x =>
{
- x.Status = 0;
+ x.Status = StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt();
x.OrderNo = inboundOrder.OrderNo;
x.MaterielName = materielInfos.FirstOrDefault(v => v.MaterielCode == x.MaterielCode)?.MaterielName ?? "";
x.StockId = stockInfo.Id != 0 ? stockInfo.Id : 0;
@@ -136,6 +277,58 @@
return WebResponseContent.Instance.Error(ex.Message);
}
}
+ /// <summary>
+ /// 楠岃瘉PDA缁勭洏鏁版嵁
+ /// </summary>
+ /// <param name="materielGroupDTO"></param>
+ /// <param name="materielInfo"></param>
+ /// <param name="inboundOrder"></param>
+ /// <param name="stockInfo"></param>
+ /// <returns></returns>
+ public (bool, string, object?) CheckMaterielGroupParam(PdaMaterielGroupDTO materielGroupDTO, Dt_MaterielInfo materielInfo, Dt_InboundOrder inboundOrder, Dt_StockInfo? stockInfo)
+ {
+ if (_taskRepository.QueryFirst(x => x.PalletCode == materielGroupDTO.PalletCode) != null)
+ {
+ return (false, "璇ユ墭鐩樺彿宸叉湁浠诲姟", materielGroupDTO);
+ }
+ if (stockInfo != null && !string.IsNullOrEmpty(stockInfo.LocationCode) && stockInfo.StockStatus != StockStatusEmun.缁勭洏鏆傚瓨.ObjToInt())
+ {
+ return (false, "宸蹭笂鏋剁殑鎵樼洏涓嶈兘鍐嶆缁勭洏", materielGroupDTO);
+ }
+ if (stockInfo != null)
+ {
+ return (false, "宸茬粍鐩樼殑鎵樼洏涓嶈兘鍐嶆缁勭洏", materielGroupDTO);
+ }
+ if (materielInfo == null)
+ {
+ return (false, "鏈夌墿鏂欎俊鎭湭褰曞叆锛岃褰曞叆鐗╂枡淇℃伅", materielGroupDTO);
+ }
+ if (inboundOrder == null)
+ {
+ return (false, "鍗曟嵁涓嶅瓨鍦�", materielGroupDTO);
+ }
+ if (inboundOrder.Details == null || inboundOrder.Details.Count == 0)
+ {
+ return (false, "鏃犲崟鎹槑缁嗕俊鎭�", materielGroupDTO);
+ }
+
+ if (inboundOrder.OrderStatus != InboundStatusEnum.鏈紑濮�.ObjToInt() && inboundOrder.OrderStatus != InboundStatusEnum.鍏ュ簱涓�.ObjToInt())
+ {
+ return (false, "璇ュ崟鎹笉鍙啀缁勭洏", materielGroupDTO);
+ }
+
+ Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.Where(x => materielInfo.MaterielCode == x.MaterielCode && x.BatchNo == materielGroupDTO.BatchNo).FirstOrDefault();
+ if (inboundOrderDetail == null)
+ {
+ return (false, "鐗╂枡鎴栨壒娆″彿鏈夎", materielGroupDTO);
+ }
+ if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < 1)
+ {
+ //return (false, "鏈夌墿鏂欒秴鍑哄崟鎹暟閲�", materielGroupDTO);
+ return (false, "缁勭洏瓒呭嚭鍗曟嵁鏁伴噺", materielGroupDTO);
+ }
+ return (true, "鎴愬姛", inboundOrderDetail);
+ }
/// <summary>
/// 楠岃瘉缁勭洏鏁版嵁
--
Gitblit v1.9.3