From 558dae4a18d393ac38daa43a354e8bc9a22e4e26 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期四, 02 十一月 2023 16:52:59 +0800
Subject: [PATCH] 班次安排座位

---
 zhengcaioa/Services/OrderBanciService.cs |  125 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 123 insertions(+), 2 deletions(-)

diff --git a/zhengcaioa/Services/OrderBanciService.cs b/zhengcaioa/Services/OrderBanciService.cs
index 5125b06..c108375 100644
--- a/zhengcaioa/Services/OrderBanciService.cs
+++ b/zhengcaioa/Services/OrderBanciService.cs
@@ -52,8 +52,66 @@
                     updateproject.Modifier = entity.Modifier;
                     updateproject.Modifytime = entity.Modifytime;
                     updateproject.Mingcheng = entity.Mingcheng;
-                    updateproject.Renshu = entity.Renshu; 
+                    updateproject.Renshu = entity.Renshu;
+                    updateproject.Hang = entity.Hang;
+                    updateproject.Lie = entity.Lie;
                 }
+                if(entity.Hang.HasValue && entity.Lie.HasValue)
+                {
+                    var orderBanciZuoweis = _context.OrderBanciZuoweis.Where(x =>x.RecStatus == "A" &&  x.BanciId == entity.Id).ToList();
+
+                  
+
+                    for(int i=0;i< entity.Hang.Value; i++)
+                    {
+                        for (int j = 0; j < entity.Lie.Value; j++)
+                        {
+                            var orderBanciZuowei = orderBanciZuoweis.Where(x => x.RowNo == (i + 1) && x.ColNo == (j + 1)).FirstOrDefault();
+                            if(orderBanciZuowei == null)
+                            {
+                                var orderBanciZuoweisss = new OrderBanciZuowei();
+                                orderBanciZuoweisss.Id =  Guid.NewGuid().ToString();
+                                orderBanciZuoweisss.BanciId = entity.Id;
+                                orderBanciZuoweisss.ZuoweiId = (i + 1)+"-"+ (j + 1);
+                                orderBanciZuoweisss.SeatNo = (i + 1) + "-" + (j + 1) + "搴�";
+                                orderBanciZuoweisss.Status = "0";
+                                orderBanciZuoweisss.RowNo = (i+1);
+                                orderBanciZuoweisss.ColNo = (j+1);
+                                orderBanciZuoweisss.RecStatus = "A";
+                                orderBanciZuoweisss.Creater = string.IsNullOrEmpty(entity.Creater)? entity.Modifier : entity.Creater;
+                                orderBanciZuoweisss.Createtime = DateTime.Now;
+                                orderBanciZuoweisss.Modifier = orderBanciZuoweisss.Creater;
+                                orderBanciZuoweisss.Modifytime = orderBanciZuoweisss.Createtime;
+                                _context.OrderBanciZuoweis.Add(orderBanciZuoweisss);
+                            }
+                        }
+                    }
+
+                    //鍒犻櫎澶氫綑鐨勫骇浣�
+                    var orderBanciZuoweisdel = orderBanciZuoweis.Where(x => x.RowNo > entity.Hang.Value || x.ColNo > entity.Lie.Value).ToList();
+                    if (orderBanciZuoweisdel != null && orderBanciZuoweisdel.Count > 0)
+                    {
+                        foreach (var orderBanciZuowei in orderBanciZuoweisdel)
+                        {
+                            orderBanciZuowei.RecStatus = "D";
+                        }
+                    }
+
+
+                }
+                else
+                {
+                    //濡傛灉娌℃湁搴т綅灏卞垹闄ゆ墍鏈夊骇浣�
+                  var orderBanciZuoweis  =  _context.OrderBanciZuoweis.Where(x => x.RecStatus == "A" && x.BanciId == entity.Id).ToList();
+                    if(orderBanciZuoweis!=null && orderBanciZuoweis.Count > 0)
+                    {
+                        foreach ( var orderBanciZuowei in orderBanciZuoweis)
+                        {
+                            orderBanciZuowei.RecStatus = "D";
+                        }
+                    }
+                }
+
 
                 _context.SaveChanges();
                 resultEntity.ReturnID = entity.Id;
@@ -166,6 +224,10 @@
                              Mingcheng = a.Mingcheng,
 
                              Renshu = a.Renshu??0,
+
+                             Hang = a.Hang ?? 0,
+
+                             Lie = a.Lie ?? 0,
 
 
                              Creater = a.Creater,
@@ -300,7 +362,8 @@
                              Didian = a.Didian,
 
                              Renshu = a.Renshu ?? 0,
-
+                             Hang = a.Hang ?? 0,
+                             Lie = a.Lie ?? 0,
 
                              Creater = a.Creater,
                              Createtime = a.Createtime,
@@ -330,5 +393,63 @@
             return query;
         }
 
+
+        public ResultEntity saveZuowei(OrderBanciZuoweiDTO dto)
+        {
+            ResultEntity resultEntity = new ResultEntity();
+            try
+            {
+
+
+                var entity = _mapper.Map<OrderBanciZuowei>(dto);
+
+
+                if (String.IsNullOrEmpty(entity.Id))
+                {
+                    entity.Id = Guid.NewGuid().ToString();
+                    dto.Id = entity.Id;
+                    _context.OrderBanciZuoweis.Add(entity);
+                }
+                else
+                {
+                    var updateproject = _context.OrderBanciZuoweis.Find(entity.Id);
+
+                    updateproject.BanciId = entity.BanciId;
+                    updateproject.ZuoweiId = entity.ZuoweiId;
+
+                    updateproject.SeatNo = entity.SeatNo;
+                    updateproject.Status = entity.Status;
+
+                    updateproject.RowNo = entity.RowNo;
+                    updateproject.ColNo = entity.ColNo;
+
+                    updateproject.RecStatus = entity.RecStatus;
+                    updateproject.Modifier = entity.Modifier;
+                    updateproject.Modifytime = entity.Modifytime;
+                    
+                }
+
+                _context.SaveChanges();
+                resultEntity.ReturnID = entity.Id;
+                resultEntity.Result = true;
+            }
+            catch (Exception ex)
+            {
+                resultEntity.Result = false;
+                resultEntity.Message = "淇濆瓨澶辫触锛岃鑱旂郴绠$悊鍛�";
+
+            }
+            return resultEntity;
+        }
+
+        public List<OrderBanciZuoweiDTO> GetOrderBanciZuoweiList(string banciId)
+        {
+            var listRole = _context.OrderBanciZuoweis.Where(r => r.RecStatus == "A" && r.BanciId == banciId).OrderBy(x=>x.RowNo).ThenBy(x=>x.ColNo).ToList();
+
+
+            var list = _mapper.Map<List<OrderBanciZuoweiDTO>>(listRole);
+
+            return list;
+        }
     }
 }

--
Gitblit v1.9.1