From 2e177c04047f38876f89e5d9ccabcc3bed112727 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期四, 08 七月 2021 15:06:20 +0800
Subject: [PATCH] 今日开发    问题新增   增加是否出书   是否收藏:是、否   每个人的收藏不一样                 档案客户访问:  选择短信内容,然后提交的时候发送短信给客户

---
 zhengcaioa/Services/LiaotianService.cs |  213 ++++++++++++++++++++++++++++++++++------------------
 1 files changed, 138 insertions(+), 75 deletions(-)

diff --git a/zhengcaioa/Services/LiaotianService.cs b/zhengcaioa/Services/LiaotianService.cs
index 5630f89..fac8a6b 100644
--- a/zhengcaioa/Services/LiaotianService.cs
+++ b/zhengcaioa/Services/LiaotianService.cs
@@ -9,7 +9,7 @@
 
 namespace Services
 {
-    public class LiaotianService: ILiaotianService
+    public class LiaotianService : ILiaotianService
     {
         private readonly zhengcaioaContext _context;
         private readonly IMapper _mapper;
@@ -19,7 +19,7 @@
             _mapper = mapper;
         }
 
-       public ResultEntity saveLiaotian(LiaotianDTO liaotiandto)
+        public ResultEntity saveLiaotian(LiaotianDTO liaotiandto)
         {
             ResultEntity resultEntity = new ResultEntity();
             try
@@ -42,18 +42,19 @@
                 }
                 else
                 {
-                  var updateliaotian  = _context.Liaotians.Find(liaotian.Id);
+                    var updateliaotian = _context.Liaotians.Find(liaotian.Id);
                     updateliaotian.Question = liaotian.Question;
                     updateliaotian.Anwser = liaotian.Anwser;
                     updateliaotian.RecStatus = liaotian.RecStatus;
                     updateliaotian.Clientid = liaotian.Clientid;
-                   // updateliaotian.Creater = liaotian.Creater;
+                    // updateliaotian.Creater = liaotian.Creater;
                     //updateliaotian.Createtime = liaotian.Createtime;
                     updateliaotian.Modifier = liaotian.Modifier;
                     updateliaotian.Modifytime = liaotian.Modifytime;
                     updateliaotian.Questiontype = liaotian.Questiontype;
                     updateliaotian.Problemtype = liaotian.Problemtype;
                     updateliaotian.Shiyongfatiao = liaotian.Shiyongfatiao;
+                    updateliaotian.ChushuStatus = liaotian.ChushuStatus;
                 }
 
                 _context.SaveChanges();
@@ -64,7 +65,7 @@
             {
                 resultEntity.Result = false;
                 resultEntity.Message = "淇濆瓨澶辫触锛岃鑱旂郴绠$悊鍛�";
-               
+
             }
             return resultEntity;
         }
@@ -83,21 +84,21 @@
             return liaotiandto;
         }
 
-        public List<SysCodeDtl> GetSYScode(string code_table,string code_field)
+        public List<SysCodeDtl> GetSYScode(string code_table, string code_field)
         {
 
 
             List<SysCodeDtl> sysCodeDtls = (from e in _context.SysCodes
                                             join c in _context.SysCodeDtls
-                                            on e.Id equals c.CodeId  
-                                            where e.RecStatus == "A" 
+                                            on e.Id equals c.CodeId
+                                            where e.RecStatus == "A"
                                             && c.RecStatus == "A"
-                                            && e.CodeTable == code_table 
+                                            && e.CodeTable == code_table
                                             && e.CodeField == code_field
-                                            select c).OrderBy(x=>x.Sort).ToList();
-                     
-            
-                                
+                                            select c).OrderBy(x => x.Sort).ToList();
+
+
+
 
 
 
@@ -108,29 +109,8 @@
         public ResultDataEntity<LiaotianDTO> SearchByPaging(LiaotianDTOSearch searchEntity)
         {
             ResultDataEntity<LiaotianDTO> data = new ResultDataEntity<LiaotianDTO>();
-            List<LiaotianDTO> list = new List<LiaotianDTO>();
-            //绛涢��
-            var query = _context.Liaotians
-                .Where(b => b.RecStatus=="A")
-                .ToList();
+            //List<LiaotianDTO> list = new List<LiaotianDTO>();
 
-            if (!string.IsNullOrEmpty(searchEntity.Question))
-            {
-                query = query.Where(m => m.Question.Contains(searchEntity.Question)).ToList();
-            }
-            if (!string.IsNullOrEmpty(searchEntity.Questiontype))
-            {
-                query = query.Where(m => m.Questiontype == searchEntity.Questiontype).ToList();
-            }
-            if (!string.IsNullOrEmpty(searchEntity.Problemtype))
-            {
-                query = query.Where(m => m.Problemtype.Contains(searchEntity.Problemtype)).ToList();
-            }
-            if (!string.IsNullOrEmpty(searchEntity.Shifoushenhe))
-            {
-                query = query.Where(m => m.Clientid == searchEntity.Shifoushenhe ).ToList();
-            }
-            
             DateTime Createtimestart = DateTime.Now;
             DateTime Createtimeend = DateTime.Now;
             if (!string.IsNullOrWhiteSpace(searchEntity.Createtime))
@@ -140,50 +120,61 @@
                 DateTime.TryParse(Createtimes[1], out Createtimeend);
                 Createtimeend = Createtimeend.AddDays(1);
             }
-            if (!string.IsNullOrEmpty(searchEntity.Createtime))
-            {
-                query = query.Where(m => m.Createtime >= Createtimestart).ToList();
-            }
-            if (!string.IsNullOrEmpty(searchEntity.Createtime))
-            {
-                query = query.Where(m => m.Createtime <= Createtimeend).ToList();
-            }
-            if (!string.IsNullOrEmpty(searchEntity.Creater))
-            {
-                query = query.Where(m => m.Creater == searchEntity.Creater).ToList();
-            }
-
-            if (!string.IsNullOrEmpty(searchEntity.Info))
-            {
-                var check = searchEntity.Info.Split(' ');
-                List<Liaotian> liaotians = new List<Liaotian>();
-                if(check!=null&& check.Length > 0)
-                {
-                    for(int i = 0;i< check.Length; i++)
-                    {
-                        if (!string.IsNullOrWhiteSpace(check[i])){
-                            liaotians = liaotians.Union(query.Where(m => m.Question.Contains(check[i])).ToList()).Distinct().ToList();
-                        }
-                       
-                    }
-                    
-                }
-
-                query = liaotians;
+            //绛涢��
+            var query = (from a in _context.Liaotians
 
 
-            }
-            else
-            {
-                query = query.OrderByDescending(x => x.Modifytime).ToList();
-            }
+                         join h in _context.LiaotianShoucangs.Where(x => x.RecStatus == "A" && x.Creater == searchEntity.ShouCangCreater)
+                      on a.Id equals h.LiaotianId
+                     into hsss
+                         from hhh in hsss.DefaultIfEmpty()
+
+
+                         where a.RecStatus == "A"
+                         && (string.IsNullOrWhiteSpace(searchEntity.Createtime) || (a.Createtime >= Createtimestart && a.Createtime <= Createtimeend))
+
+                    && (string.IsNullOrWhiteSpace(searchEntity.Question) || (a.Question.Contains(searchEntity.Question.Trim())))
+                     && (string.IsNullOrWhiteSpace(searchEntity.Questiontype) || (a.Questiontype == searchEntity.Questiontype.Trim()))
+                       && (string.IsNullOrWhiteSpace(searchEntity.Problemtype) || (a.Problemtype.Contains(searchEntity.Problemtype.Trim())))
+   && (string.IsNullOrWhiteSpace(searchEntity.Shifoushenhe) || (a.Clientid == searchEntity.Shifoushenhe.Trim()))
+    && (string.IsNullOrWhiteSpace(searchEntity.ChushuStatus) || (a.ChushuStatus == searchEntity.ChushuStatus.Trim()))
+     && (string.IsNullOrWhiteSpace(searchEntity.Creater) || (a.Creater == searchEntity.Creater.Trim()))
+      && (string.IsNullOrWhiteSpace(searchEntity.ShouCangStatus) || (searchEntity.ShouCangStatus == "A" && hhh.Id !=null) || (searchEntity.ShouCangStatus != "A" && hhh.Id == null))
+                         select new LiaotianDTO
+                         {
+                             Id = a.Id,
+                             Question = a.Question,
+                             Anwser = a.Anwser,
+                             RecStatus = a.RecStatus,
+                             Creater = a.Creater,
+                             Createtime = a.Createtime,
+                             Modifier = a.Modifier,
+                             Modifytime = a.Modifytime,
+                             Clientid = a.Clientid,
+                             Questiontype = a.Questiontype,
+                             Problemtype = a.Problemtype,
+                             Shiyongfatiao = a.Shiyongfatiao,
+                             ChushuStatus= a.ChushuStatus,
+                         }
+              )
+              .Distinct() .OrderByDescending(x => x.Modifytime).ToList();
 
             
+            
+           
+
+           
+           
+            
+
+            
+
+
             if (searchEntity.totalrows == 0)
                 searchEntity.totalrows = query.Count();
             var lianlist = query.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList();
-            list = _mapper.Map<List<LiaotianDTO>>(lianlist);
-            data.LoadData(searchEntity, list);
+            //list = _mapper.Map<List<LiaotianDTO>>(lianlist);
+            data.LoadData(searchEntity, query);
             return data;
         }
 
@@ -219,7 +210,7 @@
         /// <returns></returns>
         public List<LiaotianDTO> SearchForPrint(LiaotianDTOSearch searchEntity)
         {
-           
+
             List<LiaotianDTO> list = new List<LiaotianDTO>();
             //绛涢��
             var query = _context.Liaotians
@@ -262,10 +253,82 @@
 
 
             query = query.OrderByDescending(x => x.Modifytime).ToList();
-            
+
             list = _mapper.Map<List<LiaotianDTO>>(query);
-           
+
             return list;
         }
+
+
+
+        public ResultEntity saveLiaotianShoucang(LiaotianShoucangDTO dto)
+        {
+            ResultEntity resultEntity = new ResultEntity();
+            try
+            {
+
+
+                var liaotian = _mapper.Map<LiaotianShoucang>(dto);
+                if (String.IsNullOrEmpty(liaotian.Id))
+                {
+                    liaotian.Id = Guid.NewGuid().ToString();
+                    dto.Id = liaotian.Id;
+                    _context.LiaotianShoucangs.Add(liaotian);
+                }
+                else
+                {
+                    var updateliaotian = _context.LiaotianShoucangs.Find(liaotian.Id);
+                    updateliaotian.LiaotianId = liaotian.LiaotianId;
+
+                    updateliaotian.RecStatus = liaotian.RecStatus;
+
+                    // updateliaotian.Creater = liaotian.Creater;
+                    //updateliaotian.Createtime = liaotian.Createtime;
+                    updateliaotian.Modifier = liaotian.Modifier;
+                    updateliaotian.Modifytime = liaotian.Modifytime;
+
+                }
+
+                _context.SaveChanges();
+                resultEntity.ReturnID = liaotian.Id;
+                resultEntity.Result = true;
+            }
+            catch (Exception ex)
+            {
+                resultEntity.Result = false;
+                resultEntity.Message = "淇濆瓨澶辫触锛岃鑱旂郴绠$悊鍛�";
+
+            }
+            return resultEntity;
+        }
+
+        public ResultEntity ModifyStatusLiaotianShoucang(string id, string userid)
+        {
+            ResultEntity result = new ResultEntity();
+            result.Result = true;
+
+            var model = _context.LiaotianShoucangs.Find(id);
+            if (model != null)
+            {
+                model.RecStatus = "D";
+                model.Modifier = userid;
+                model.Modifytime = DateTime.Now;
+                _context.SaveChanges();
+            }
+
+            return result;
+        }
+
+        public List<LiaotianShoucangDTO> getListLiaotianShoucang(string userId, string LiaotianId)
+        {
+            List<LiaotianShoucangDTO> result = new List<LiaotianShoucangDTO>();
+
+
+            var listFiServices = _context.LiaotianShoucangs.Where(r => r.RecStatus == "A" && (string.IsNullOrEmpty(userId) || r.Creater == userId) && (string.IsNullOrEmpty(LiaotianId) || r.LiaotianId == LiaotianId)).OrderBy(x => x.Createtime).ToList();
+
+            result = _mapper.Map<List<LiaotianShoucangDTO>>(listFiServices);
+
+            return result;
+        }
     }
 }

--
Gitblit v1.9.1