From d4a6d65f5e449c3e5464aa18ae97bf8953987217 Mon Sep 17 00:00:00 2001
From: LR-20210131IOQH\Administrator <jackcold@163.com>
Date: 星期二, 10 八月 2021 15:44:14 +0800
Subject: [PATCH] Merge branch 'master' of http://47.108.235.38:8080/r/zhengcaioa

---
 zhengcaioa/zhengcaioa/Controllers/LiaotianController.cs |  155 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 153 insertions(+), 2 deletions(-)

diff --git a/zhengcaioa/zhengcaioa/Controllers/LiaotianController.cs b/zhengcaioa/zhengcaioa/Controllers/LiaotianController.cs
index 37f91c7..c467b76 100644
--- a/zhengcaioa/zhengcaioa/Controllers/LiaotianController.cs
+++ b/zhengcaioa/zhengcaioa/Controllers/LiaotianController.cs
@@ -261,7 +261,9 @@
         [CheckLogin]
         public string GetLiaotianList(LiaotianDTOSearch search)
         {
-           
+            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
+            ViewData["curentuser"] = curentuser;
+            search.ShouCangCreater = curentuser.Id;
             //JsonResult jsonResult =   new JsonResult(_liaotianService.SearchByPaging(search), new Newtonsoft.Json.Serialization.DefaultContractResolver());
             return  JsonConvert.SerializeObject(_liaotianService.SearchByPaging(search)); 
         }
@@ -276,6 +278,16 @@
             if (!String.IsNullOrEmpty(id))
             {
                 liaotianDTO = _liaotianService.GetLiaotianEntity(id);
+                var liaotianShoucangDTOs = _liaotianService.getListLiaotianShoucang(curentuser.Id, id);
+                if(liaotianShoucangDTOs!=null&& liaotianShoucangDTOs.Count > 0)
+                {
+                    liaotianDTO.ShouCangStatus = "A";
+                }
+                else
+                {
+                    liaotianDTO.ShouCangStatus = "D";
+
+                }
             }
             ViewData.Model = liaotianDTO;
 
@@ -287,6 +299,7 @@
             ViewData["questiontype"] = _liaotianService.GetSYScode("Liaotian", "questiontype");
 
             ViewData["problemtype"] = _liaotianService.GetSYScode("Liaotian", "problemtype").Where(x=>x.Contents == liaotianDTO.Questiontype).ToList();
+
 
             return View();
         }
@@ -314,12 +327,16 @@
         [CheckLogin]
         public async Task<string> SaveAsync(LiaotianDTO data)
         {
+
+           
             ResultEntity resultEntity = new ResultEntity();
             resultEntity.Result = false;
             var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
             ViewData["curentuser"] = curentuser;
             data.RecStatus = "A";
             data.Clientid = "D";
+            data.Shenheer = null;
+            data.Shenhetime = null;
             if (String.IsNullOrEmpty(data.Id))
             {
                 data.Creater= curentuser.Id;
@@ -369,6 +386,8 @@
            
 
               resultEntity = _liaotianService.saveLiaotian(data);
+
+           
 
 
             //string api_domain = _configuration.GetSection("Elasticsearchurl").Value;
@@ -427,9 +446,138 @@
             return JsonConvert.SerializeObject(resultEntity);
         }
 
+        /// <summary>
+        /// 鎻愪氦骞跺鏍�
+        /// </summary>
+        /// <param name="data">宀椾綅瀹炰綋绫诲璞�</param>
+        /// <returns></returns>
+        [HttpPost]
+        [CheckLogin]
+        public IActionResult  ShouCang(LiaotianDTO data)
+        {
+            ResultEntity resultEntity = new ResultEntity();
+            resultEntity.Result = false;
+            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
+            ViewData["curentuser"] = curentuser;
+
+            var liaotianShoucangDTOs = _liaotianService.getListLiaotianShoucang(curentuser.Id, data.Id);
+            if (data.ShouCangStatus == "A")
+            {
+                if (liaotianShoucangDTOs == null || liaotianShoucangDTOs.Count == 0)
+                {
+                    LiaotianShoucangDTO liaotianShoucangDTO = new LiaotianShoucangDTO();
+                    liaotianShoucangDTO.LiaotianId = data.Id;
+                    liaotianShoucangDTO.RecStatus = "A";
+                    liaotianShoucangDTO.Creater = curentuser.Id;
+                    liaotianShoucangDTO.Createtime = DateTime.Now;
+                    liaotianShoucangDTO.Modifier = curentuser.Id;
+                    liaotianShoucangDTO.Modifytime = DateTime.Now;
+                    resultEntity =  _liaotianService.saveLiaotianShoucang(liaotianShoucangDTO);
+                }
+            }
+            else
+            {
+                if (liaotianShoucangDTOs != null || liaotianShoucangDTOs.Count > 0)
+                {
+                    foreach (var liaotianShoucangDTO in liaotianShoucangDTOs)
+                    {
+                        resultEntity = _liaotianService.ModifyStatusLiaotianShoucang(liaotianShoucangDTO.Id, curentuser.Id);
+                    }
+                }
+            }
+
+            return new JsonResult(resultEntity); ;
+        }
+
 
         /// <summary>
-        /// 淇濆瓨
+        /// 鎻愪氦骞跺鏍�
+        /// </summary>
+        /// <param name="data">宀椾綅瀹炰綋绫诲璞�</param>
+        /// <returns></returns>
+        [HttpPost]
+        [CheckLogin]
+        public async Task<string> TijiaobingshenheAsync(LiaotianDTO data)
+        {
+          
+            ResultEntity resultEntity = new ResultEntity();
+            resultEntity.Result = false;
+            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
+            ViewData["curentuser"] = curentuser;
+            data.RecStatus = "A";
+            data.Clientid = "A";
+            data.Shenheer = curentuser.Id;
+            data.Shenhetime = DateTime.Now;
+            if (String.IsNullOrEmpty(data.Id))
+            {
+                data.Creater = curentuser.Id;
+                data.Createtime = DateTime.Now;
+            }
+            data.Modifier = curentuser.Id;
+            data.Modifytime = DateTime.Now;
+       
+
+
+            resultEntity = _liaotianService.saveLiaotian(data);
+
+            
+
+            string api_domain = _configuration.GetSection("Elasticsearchurl").Value;
+            string url = $"{api_domain}/liaotian/person/" + data.Id;
+            LiaotianElasticsearchDTO liaotianElasticsearchDTO = new LiaotianElasticsearchDTO();
+            liaotianElasticsearchDTO.id = data.Id;
+            liaotianElasticsearchDTO.question = data.Question;
+            liaotianElasticsearchDTO.anwser = data.Anwser;
+
+
+            string requestJson = JsonConvert.SerializeObject(liaotianElasticsearchDTO); ; 
+            try
+            {
+                string result = string.Empty;
+                Uri postUrl = new Uri(url);
+
+                using (HttpContent httpContent = new StringContent(requestJson))
+                {
+                    httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+
+                    var httpClient = _clientFactory.CreateClient();
+                    httpClient.Timeout = new TimeSpan(0, 0, 60);
+                    var Result = await httpClient.PutAsync(postUrl, httpContent);
+                    result = Result.Content.ReadAsStringAsync().Result;
+
+
+
+                }
+
+                Newtonsoft.Json.Linq.JObject jobject = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(result);
+
+                if (jobject["error"] == null && jobject["_shards"]["successful"].ToString() == "1")
+                {
+                    resultEntity.Result = true;
+                }
+                else
+                {
+                    resultEntity.Result = false;
+                }
+
+            }
+            catch (Exception e)
+            {
+                resultEntity.Result = false;
+                throw e;
+
+
+            }
+
+
+
+
+
+            return JsonConvert.SerializeObject(resultEntity);
+        }
+
+        /// <summary>
+        /// 瀹℃牳
         /// </summary>
         /// <param name="data">宀椾綅瀹炰綋绫诲璞�</param>
         /// <returns></returns>
@@ -446,6 +594,9 @@
 
 
             LiaotianDTO data = _liaotianService.GetLiaotianEntity(Id);
+
+            data.Shenheer = curentuser.Id;
+            data.Shenhetime = DateTime.Now;
             data.Clientid = "A";
             data.Modifier = curentuser.Id;
             data.Modifytime = DateTime.Now;

--
Gitblit v1.9.1