From c455612b03e6ecac994884dde5b5f4bc4909c181 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 11 三月 2025 17:12:52 +0800
Subject: [PATCH] 1

---
 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_ProductionLine.cs |  229 +++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 135 insertions(+), 94 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_ProductionLine.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_ProductionLine.cs"
index 4b3d9bb..1699356 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_ProductionLine.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_ProductionLine.cs"
@@ -24,102 +24,143 @@
             WebResponseContent content = new WebResponseContent();
             try
             {
-                switch (productionlineDTO.traytype)
+                #region MyRegion
+                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(productionlineDTO.Barcode);
+                if (stockInfo != null) throw new Exception($"鎵樼洏銆恵productionlineDTO.Barcode}銆戝凡瀛樺湪搴撳瓨淇℃伅");
+                stockInfo = new Dt_StockInfo();
+                stockInfo.Details = new List<Dt_StockInfoDetail>();
+                var OrderNo = productionlineDTO.batchNo.Split('T')[0];
+                Dt_InboundOrder inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(OrderNo);
+                if (inboundOrder == null) throw new Exception($"鏈壘鍒板叆搴撳崟銆恵OrderNo}銆�");
+                Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == productionlineDTO.batchNo);
+                if (inboundOrderDetail == null) throw new Exception($"鏈壘鍒版壒鍙枫�恵productionlineDTO.batchNo}銆戠殑鍏ュ簱璇︽儏");
+                if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < 1) throw new Exception($"鎵瑰彿銆恵productionlineDTO.batchNo}銆戠粍鐩樻暟閲忚秴鍑�");
+
+                Dt_Task dt_Task = new Dt_Task()
                 {
-                    case 1://鏀剧┖鎵�
-                    case 3://鏀剧┖鐩�
-                           //case 5://鏀炬弧鐩�
-                        {
-                            //鏌ユ壘鐗╂枡鎵�鏈夊簱瀛�
-                            var stockInfos = _stockService.StockInfoService.Repository.GetStockInfos(productionlineDTO.traytype.ToString());
-                            //鏌ユ壘鍏堝叆鐗╂枡璐т綅鏈�鍚庡叆搴撶墿鏂�
-                            var stockInfo = stockInfos.Where(x => x.LocationCode == stockInfos.OrderBy(x => x.InDate).FirstOrDefault()?.LocationCode).OrderByDescending(x => x.InDate).FirstOrDefault();
-                            if (stockInfo == null) throw new Exception($"鏃犵墿鏂欑紪鍙枫�恵productionlineDTO.traytype}銆戠殑搴撳瓨");
-                            var location = _basicService.LocationInfoService.GetLocation(stockInfo.LocationCode);
-                            #region 鐢熸垚鍑哄簱浠诲姟
-                            Dt_Task dt_Task = new Dt_Task()
-                            {
-                                CurrentAddress = stockInfo.LocationCode,
-                                NextAddress = "SC01",
-                                SourceAddress = stockInfo.LocationCode,
-                                TargetAddress = productionlineDTO.stationCode,
-                                Creater = "System",
-                                PalletCode = stockInfo.PalletCode,
-                                OrderNo = null,
-                                Roadway = "SC01",
-                                TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
-                                TaskState = OutTaskStatusEnum.OutNew.ObjToInt(),
-                                TaskType = productionlineDTO.traytype == 1 ? TaskTypeEnum.PalletOutbound.ObjToInt() : TaskTypeEnum.PalletFillOutbound.ObjToInt(),
-                                IsPickPlace = location.MaxQty - location.CurrentQty == 0,
-                                CreateDate = DateTime.Now,
-                                Dispatchertime = DateTime.Now,
-                            };
-                            #endregion
-                            location.CurrentQty--;
-                            location.LocationStatus = LocationStatusEnum.Outbounding.ObjToInt();
-                            stockInfo.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
-                            stockInfo.Details.FirstOrDefault().Status = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
+                    CurrentAddress = productionlineDTO.stationCode,
+                    NextAddress = "SC01",
+                    SourceAddress = productionlineDTO.stationCode,
+                    TargetAddress = "SC01",
+                    Creater = "System",
+                    PalletCode = productionlineDTO.Barcode,
+                    Roadway = "SC01",
+                    OrderNo = OrderNo,
+                    TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
+                    TaskState = InTaskStatusEnum.InNew.ObjToInt(),
+                    TaskType = TaskTypeEnum.Inbound.ObjToInt(),
+                    //TaskType = productionlineDTO.traytype == 2 ? TaskTypeEnum.PalletInbound.ObjToInt() : TaskTypeEnum.PalletReturnInbound.ObjToInt(),
+                    CreateDate = DateTime.Now,
+                    Dispatchertime = DateTime.Now,
+                };
 
-                            Db.Ado.BeginTran();
-                            AddData(dt_Task);
-                            _basicService.LocationInfoService.UpdateData(location);
-                            _stockService.StockInfoService.Repository.UpdateDataWithDetail(stockInfo);
-                            content.OK(data: dt_Task);
-                            Db.Ado.CommitTran();
-                        }
-                        break;
-                    case 2://鍙栫┖鎵�
-                    case 4://鍙栨弧鐩�
-                    case 6://鍙栫┖鐩�
-                        {
-                            Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(productionlineDTO.Barcode);
-                            if (stockInfo != null) throw new Exception($"鎵樼洏銆恵productionlineDTO.Barcode}銆戝凡瀛樺湪搴撳瓨淇℃伅");
-                            productionlineDTO.QtySum = Array.ConvertAll(productionlineDTO.productQty.Split(","), s => decimal.Parse(s)).Sum();//鍏ュ簱鎬绘暟
-                            stockInfo = new Dt_StockInfo();
-                            stockInfo.Details = new List<Dt_StockInfoDetail>();
-                            Dt_InboundOrder inboundOrder = null;
-                            #region 鐢熸垚鍏ュ簱浠诲姟
-                            Dt_Task dt_Task = new Dt_Task()
-                            {
-                                CurrentAddress = productionlineDTO.stationCode,
-                                NextAddress = "SC01",
-                                SourceAddress = productionlineDTO.stationCode,
-                                TargetAddress = "SC01",
-                                Creater = "System",
-                                PalletCode = productionlineDTO.Barcode,
-                                Roadway = "SC01",
-                                TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
-                                TaskState = InTaskStatusEnum.InNew.ObjToInt(),
-                                TaskType = productionlineDTO.traytype == 2 ? TaskTypeEnum.PalletInbound.ObjToInt() : TaskTypeEnum.PalletReturnInbound.ObjToInt(),
-                                CreateDate = DateTime.Now,
-                                Dispatchertime = DateTime.Now,
-                            };
-                            #endregion
-                            if (productionlineDTO.traytype == 4)
-                            {
-                                var OrderNo = productionlineDTO.batchNo.Split('T')[0];
-                                inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(OrderNo);
-                                if (inboundOrder == null) throw new Exception($"鏈壘鍒板叆搴撳崟銆恵OrderNo}銆�");
-                                Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == productionlineDTO.batchNo);
-                                if (inboundOrderDetail == null) throw new Exception($"鏈壘鍒版壒鍙枫�恵productionlineDTO.batchNo}銆戠殑鍏ュ簱璇︽儏");
-                                if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < 1) throw new Exception($"鎵瑰彿銆恵productionlineDTO.batchNo}銆戠粍鐩樻暟閲忚秴鍑�");
+                content = _stockService.StockInfoService.AddStockInfo(ref stockInfo, ref inboundOrder, productionlineDTO);
+                if (!content.Status) throw new Exception(content.Message);
+                Db.Ado.BeginTran();
+                _inboundService.InbounOrderService.UpdateDataWithDetail(inboundOrder);
+                _stockService.StockInfoService.AddMaterielGroup(stockInfo);
+                AddData(dt_Task);
+                content.OK(data: dt_Task);
+                Db.Ado.CommitTran();
+                #endregion
+                #region MyRegion
+                //switch (productionlineDTO.traytype)
+                //{
+                //    case 1://鏀剧┖鎵�
+                //    case 3://鏀剧┖鐩�
+                //           //case 5://鏀炬弧鐩�
+                //        {
+                //            //鏌ユ壘鐗╂枡鎵�鏈夊簱瀛�
+                //            var stockInfos = _stockService.StockInfoService.Repository.GetStockInfos(productionlineDTO.traytype.ToString());
+                //            //鏌ユ壘鍏堝叆鐗╂枡璐т綅鏈�鍚庡叆搴撶墿鏂�
+                //            var stockInfo = stockInfos.Where(x => x.LocationCode == stockInfos.OrderBy(x => x.InDate).FirstOrDefault()?.LocationCode).OrderByDescending(x => x.InDate).FirstOrDefault();
+                //            if (stockInfo == null) throw new Exception($"鏃犵墿鏂欑紪鍙枫�恵productionlineDTO.traytype}銆戠殑搴撳瓨");
+                //            var location = _basicService.LocationInfoService.GetLocation(stockInfo.LocationCode);
+                //            #region 鐢熸垚鍑哄簱浠诲姟
+                //            Dt_Task dt_Task = new Dt_Task()
+                //            {
+                //                CurrentAddress = stockInfo.LocationCode,
+                //                NextAddress = "SC01",
+                //                SourceAddress = stockInfo.LocationCode,
+                //                TargetAddress = productionlineDTO.stationCode,
+                //                Creater = "System",
+                //                PalletCode = stockInfo.PalletCode,
+                //                OrderNo = null,
+                //                Roadway = "SC01",
+                //                TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
+                //                TaskState = OutTaskStatusEnum.OutNew.ObjToInt(),
+                //                TaskType = productionlineDTO.traytype == 1 ? TaskTypeEnum.PalletOutbound.ObjToInt() : TaskTypeEnum.PalletFillOutbound.ObjToInt(),
+                //                IsPickPlace = location.MaxQty - location.CurrentQty == 0,
+                //                CreateDate = DateTime.Now,
+                //                Dispatchertime = DateTime.Now,
+                //            };
+                //            #endregion
+                //            location.CurrentQty--;
+                //            location.LocationStatus = LocationStatusEnum.Outbounding.ObjToInt();
+                //            stockInfo.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
+                //            stockInfo.Details.FirstOrDefault().Status = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
 
-                                dt_Task.OrderNo = OrderNo;
-                                dt_Task.TaskType = TaskTypeEnum.Inbound.ObjToInt();
-                            }
-                            content = _stockService.StockInfoService.AddStockInfo(ref stockInfo, ref inboundOrder, productionlineDTO);
-                            if (!content.Status) throw new Exception(content.Message);
-                            Db.Ado.BeginTran();
-                            if (inboundOrder != null) _inboundService.InbounOrderService.UpdateDataWithDetail(inboundOrder);
-                            _stockService.StockInfoService.AddMaterielGroup(stockInfo);
-                            AddData(dt_Task);
-                            content.OK(data: dt_Task);
-                            Db.Ado.CommitTran();
-                        }
-                        break;
-                    default:
-                        throw new Exception("鏈畾涔夋墭鐩樼被鍨�");
-                }
+                //            Db.Ado.BeginTran();
+                //            AddData(dt_Task);
+                //            _basicService.LocationInfoService.UpdateData(location);
+                //            _stockService.StockInfoService.Repository.UpdateDataWithDetail(stockInfo);
+                //            content.OK(data: dt_Task);
+                //            Db.Ado.CommitTran();
+                //        }
+                //        break;
+                //    case 2://鍙栫┖鎵�
+                //    case 4://鍙栨弧鐩�
+                //    case 6://鍙栫┖鐩�
+                //        {
+                //            Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(productionlineDTO.Barcode);
+                //            if (stockInfo != null) throw new Exception($"鎵樼洏銆恵productionlineDTO.Barcode}銆戝凡瀛樺湪搴撳瓨淇℃伅");
+                //            productionlineDTO.QtySum = Array.ConvertAll(productionlineDTO.productQty.Split(","), s => decimal.Parse(s)).Sum();//鍏ュ簱鎬绘暟
+                //            stockInfo = new Dt_StockInfo();
+                //            stockInfo.Details = new List<Dt_StockInfoDetail>();
+                //            Dt_InboundOrder inboundOrder = null;
+                //            #region 鐢熸垚鍏ュ簱浠诲姟
+                //            Dt_Task dt_Task = new Dt_Task()
+                //            {
+                //                CurrentAddress = productionlineDTO.stationCode,
+                //                NextAddress = "SC01",
+                //                SourceAddress = productionlineDTO.stationCode,
+                //                TargetAddress = "SC01",
+                //                Creater = "System",
+                //                PalletCode = productionlineDTO.Barcode,
+                //                Roadway = "SC01",
+                //                TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
+                //                TaskState = InTaskStatusEnum.InNew.ObjToInt(),
+                //                TaskType = productionlineDTO.traytype == 2 ? TaskTypeEnum.PalletInbound.ObjToInt() : TaskTypeEnum.PalletReturnInbound.ObjToInt(),
+                //                CreateDate = DateTime.Now,
+                //                Dispatchertime = DateTime.Now,
+                //            };
+                //            #endregion
+                //            if (productionlineDTO.traytype == 4)
+                //            {
+                //                var OrderNo = productionlineDTO.batchNo.Split('T')[0];
+                //                inboundOrder = _inboundService.InbounOrderService.GetInboundOrder(OrderNo);
+                //                if (inboundOrder == null) throw new Exception($"鏈壘鍒板叆搴撳崟銆恵OrderNo}銆�");
+                //                Dt_InboundOrderDetail inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == productionlineDTO.batchNo);
+                //                if (inboundOrderDetail == null) throw new Exception($"鏈壘鍒版壒鍙枫�恵productionlineDTO.batchNo}銆戠殑鍏ュ簱璇︽儏");
+                //                if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < 1) throw new Exception($"鎵瑰彿銆恵productionlineDTO.batchNo}銆戠粍鐩樻暟閲忚秴鍑�");
+
+                //                dt_Task.OrderNo = OrderNo;
+                //                dt_Task.TaskType = TaskTypeEnum.Inbound.ObjToInt();
+                //            }
+                //            content = _stockService.StockInfoService.AddStockInfo(ref stockInfo, ref inboundOrder, productionlineDTO);
+                //            if (!content.Status) throw new Exception(content.Message);
+                //            Db.Ado.BeginTran();
+                //            if (inboundOrder != null) _inboundService.InbounOrderService.UpdateDataWithDetail(inboundOrder);
+                //            _stockService.StockInfoService.AddMaterielGroup(stockInfo);
+                //            AddData(dt_Task);
+                //            content.OK(data: dt_Task);
+                //            Db.Ado.CommitTran();
+                //        }
+                //        break;
+                //    default:
+                //        throw new Exception("鏈畾涔夋墭鐩樼被鍨�");
+                //} 
+                #endregion
             }
             catch (Exception ex)
             {
@@ -158,7 +199,7 @@
                     PalletCode = lineDTO.Barcode,
                     OrderNo = StockInfoDetails.Count() == 1 ? StockInfoDetails.First().OrderNo : null,
                     Roadway = "SC01",
-                    TaskNum = Convert.ToInt32(DateTime.Now.ToString("HHmmss")),
+                    TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
                     TaskState = InTaskStatusEnum.InNew.ObjToInt(),
                     TaskType = TaskTypeEnum.Inbound.ObjToInt(),
                 };

--
Gitblit v1.9.3