TANG JIANG 1 年之前
父節點
當前提交
52a04597e6

+ 197 - 210
src/Sharing.DaoShu110/Controllers/PoliceDSController.cs

@@ -3,10 +3,12 @@ using MapsterMapper;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.IdentityModel.Tokens;
+using Newtonsoft.Json.Linq;
 using Sharing.DaoShu110.Dtos;
 using Sharing.DaoShu110.Extensions;
+using Sharing.Province.XieTong.Knowledge;
 using Sharing.WebCore;
-using System.Data;
 using System.Net;
 
 namespace Sharing.DaoShu110.Controllers
@@ -23,6 +25,7 @@ namespace Sharing.DaoShu110.Controllers
         private readonly IPoliceReceiveChainDealDsRepository _policeReceiveChainDealDsRepository;
         private readonly IPoliceSendChainAlarmDsRepository _policeSendChainAlarmDsRepository;
         private readonly IPoliceSendChainDealDsRepository _policeSendChainDealDsRepository;
+        private readonly IKnowledgeRawDataRepository _knowledgeRawDataRepository;
 
         /// <summary>
         /// 
@@ -32,10 +35,9 @@ namespace Sharing.DaoShu110.Controllers
         /// <param name="policeReceiveChainAlarmDsRepository"></param>
         /// <param name="policeReceiveChainDealDsRepository"></param>
         public PoliceDSController(IMapper mapper, ICapPublisher capPublisher,
-            IPoliceReceiveChainAlarmDsRepository policeReceiveChainAlarmDsRepository,
-            IPoliceReceiveChainDealDsRepository policeReceiveChainDealDsRepository,
-            IPoliceSendChainAlarmDsRepository policeSendChainAlarmDsRepository,
-            IPoliceSendChainDealDsRepository policeSendChainDealDsRepository)
+            IPoliceReceiveChainAlarmDsRepository policeReceiveChainAlarmDsRepository, IPoliceReceiveChainDealDsRepository policeReceiveChainDealDsRepository,
+            IPoliceSendChainAlarmDsRepository policeSendChainAlarmDsRepository, IPoliceSendChainDealDsRepository policeSendChainDealDsRepository,
+            IKnowledgeRawDataRepository knowledgeRawDataRepository)
         {
             _mapper = mapper;
             _capPublisher = capPublisher;
@@ -43,6 +45,7 @@ namespace Sharing.DaoShu110.Controllers
             _policeReceiveChainDealDsRepository = policeReceiveChainDealDsRepository;
             _policeSendChainAlarmDsRepository = policeSendChainAlarmDsRepository;
             _policeSendChainDealDsRepository = policeSendChainDealDsRepository;
+            _knowledgeRawDataRepository = knowledgeRawDataRepository;
         }
 
         #region receive-工单受理
@@ -68,20 +71,22 @@ namespace Sharing.DaoShu110.Controllers
             {
                 // 验证dcsm
                 string dcsmMsg = CComm.checkDcsm(Request.Headers["dcsm"].ToString(), cToken.token1_dcsm);
-                if (false == string.IsNullOrEmpty(dcsmMsg))
+                if (!string.IsNullOrEmpty(dcsmMsg))
                 {
                     apiR = ApiResultR.Failed(dcsmMsg);
                 }
                 else
                 {
                     string base64String = await CComm.getStreamBase64(HttpContext.Request);
-                    // 解密:base64通过sm4解密转json
-                    string jsonRes = Sm4Crypto.Decrypt_ECB_Base64(sm4, base64String);
-                    // json 转 实体类
-                    ChainAlarm_DS chainAlarm = System.Text.Json.JsonSerializer.Deserialize<ChainAlarm_DS>(jsonRes);
-
-                    if (chainAlarm == null)
-                        chainAlarm = new ChainAlarm_DS();
+                    ChainAlarm_DS chainAlarm = new();
+                    if (!string.IsNullOrEmpty(base64String))
+                    {
+                        // 解密:base64通过sm4解密转json
+                        string jsonRes = Sm4Crypto.Decrypt_ECB_Base64(sm4, base64String);
+                        // json 转 实体类
+                        if (!string.IsNullOrEmpty(jsonRes))
+                            chainAlarm = System.Text.Json.JsonSerializer.Deserialize<ChainAlarm_DS>(jsonRes);
+                    }
 
                     #region 数据验证
                     //数据验证
@@ -162,7 +167,7 @@ namespace Sharing.DaoShu110.Controllers
             // 退回 Jv5JJHwByfD4CXMb1l4PtPsgC6UmNeRfws6mEKz24rackMA28z27tu2GRlIyq0qm1U2lexAxHJK7Bhoyw7CNiEXjiobQjSKF2RWOrUHZINPed01DQRTw2pIL03EFsrQpEjsslviumN+BTn/cuJQp8zD2ifPclM87jEJfP2EY6D+UGvUfSebT9mMghSo2VaUeqFzlRKpJmcU6XjV7C65zddc8DEXuYzt0zqATyhac9AO3RGB5SEw9MX1olV8WwPgV4h3OkTTVZ+Dq5co/eb28YIBN+Rshjpv82RusV2thgfvudOyCDZcRDbjh6pEdtj/lvVH/BU2cDo3ch17KtzsPE+xkQvJ68zaAnS8f/klQrFrDHlkmTMi6rEa605yUhhPZFz0Jba+Axizil38YbHV9A1YoxoJNjFXIyL90yCMznb4joMQPRRddp5ky/CbT9r0q283gKBdAY6/v+ywPdalFjg==
             // 回访 Jv5JJHwByfD4CXMb1l4PtPsgC6UmNeRfws6mEKz24rackMA28z27tu2GRlIyq0qmvLqUgIfd0QkyZbzT0iQZwEXjiobQjSKF2RWOrUHZINPed01DQRTw2pIL03EFsrQpEjsslviumN+BTn/cuJQp8zD2ifPclM87jEJfP2EY6D8cMxuK/4X9pyxRWKIQtLFdh4ieC9bhojhr2XxStPHmDV4c3oNEybczbb7IXsaW2FCGMI4SLF7Z+VXDSpCGpFX+0dyUUQPnoRrgU7wndkn/6VYi2Axm19MBkwK+Wm5v85oVQ1HFptf5leUiSXomF9XCPtgWbLOFzu313JW7WQvjgllM7usjI2mbyGtQ5EMXyOGJ/AmAupELpMYVwjoGAKy6B/GE1HFyPiLAazsUE3jfaLPxn/Gld0Ef2glG1SQ/vakDtyvyoJDE83pYvBesmQMx
 
-            CToken_DaoShu cToken = new CToken_DaoShu();
+            CToken_DaoShu cToken = new();
             string sm4 = cToken.token4_sm4_mw;
 
             IApiResultR apiR;
@@ -170,20 +175,23 @@ namespace Sharing.DaoShu110.Controllers
             {
                 // 验证dcsm
                 string dcsmMsg = CComm.checkDcsm(Request.Headers["dcsm"].ToString(), cToken.token4_dcsm);
-                if (false == string.IsNullOrEmpty(dcsmMsg))
+                if (!string.IsNullOrEmpty(dcsmMsg))
                 {
                     apiR = ApiResultR.Failed(dcsmMsg);
                 }
                 else
                 {
-                    string base64String = await CComm.getStreamBase64(HttpContext.Request);
-                    // 解密:base64通过sm4解密转json
-                    string jsonRes = Sm4Crypto.Decrypt_ECB_Base64(sm4, base64String);
+                    ChainDeal_DS chainDeal = new();
 
-                    // json 转 实体类
-                    ChainDeal_DS chainDeal = System.Text.Json.JsonSerializer.Deserialize<ChainDeal_DS>(jsonRes);
-                    if (null == chainDeal)
-                        chainDeal = new ChainDeal_DS();
+                    string base64String = await CComm.getStreamBase64(HttpContext.Request);
+                    if (!string.IsNullOrEmpty(base64String))
+                    {
+                        // 解密:base64通过sm4解密转json
+                        string jsonRes = Sm4Crypto.Decrypt_ECB_Base64(sm4, base64String);
+                        if (!string.IsNullOrEmpty(jsonRes))
+                            // json 转 实体类
+                            chainDeal = System.Text.Json.JsonSerializer.Deserialize<ChainDeal_DS>(jsonRes);
+                    }
 
                     #region 数据验证
                     string strResult = chainDeal.Validate();
@@ -254,7 +262,7 @@ namespace Sharing.DaoShu110.Controllers
         {
             //{"startDate":"2023-04-01 10:43:17","endDate":"2023-04-17 10:43:17"}
             //gzWXSn3A2ZW9u3k9yrHdEqE5zRzto/Rud6LZ6JRJ1k59ou5nWABc8t8fR/sWU89lGweFQMsZkefowEBYzArADnSXjbKwfQj19UoF5RN/0mI=
-            CToken_DaoShu cToken = new CToken_DaoShu();
+            CToken_DaoShu cToken = new();
             string sm4 = cToken.token3_sm4_mw;
 
             IApiResultR apiR;
@@ -262,31 +270,26 @@ namespace Sharing.DaoShu110.Controllers
             {
                 // 验证dcsm
                 string dcsmMsg = CComm.checkDcsm(Request.Headers["dcsm"].ToString(), cToken.token3_dcsm);
-                if (false == string.IsNullOrEmpty(dcsmMsg))
+                if (!string.IsNullOrEmpty(dcsmMsg))
                 {
                     apiR = ApiResultR.Failed(dcsmMsg);
                 }
                 else
                 {
+                    OpenData openData = new();
                     string base64String = await CComm.getStreamBase64(HttpContext.Request);
-                    string startDate = "", endDate = "";
-                    if (false == string.IsNullOrEmpty(base64String))
+                    if (!string.IsNullOrEmpty(base64String))
                     {
                         // 解密:base64通过sm4解密转json
                         string jsonRes = Sm4Crypto.Decrypt_ECB_Base64(sm4, base64String);
-                        // json 转 实体类
-                        OpenData openData = System.Text.Json.JsonSerializer.Deserialize<OpenData>(jsonRes);
-                        if (null == openData)
-                        {
-                            openData = new OpenData();
-                        }
-                        startDate = openData.StartDate;
-                        endDate = openData.EndDate;
+                        if (!string.IsNullOrEmpty(jsonRes))
+                            // json 转 实体类
+                            openData = System.Text.Json.JsonSerializer.Deserialize<OpenData>(jsonRes);
                     }
 
                     var listData = await _policeSendChainAlarmDsRepository.Queryable()
-                             .WhereIF(!string.IsNullOrEmpty(startDate), p => p.CallPoliceTime >= Convert.ToDateTime(startDate))
-                             .WhereIF(!string.IsNullOrEmpty(endDate), p => p.CallPoliceTime >= Convert.ToDateTime(endDate))
+                             .WhereIF(!string.IsNullOrEmpty(openData.StartDate), p => p.CallPoliceTime >= Convert.ToDateTime(openData.StartDate))
+                             .WhereIF(!string.IsNullOrEmpty(openData.EndDate), p => p.CallPoliceTime >= Convert.ToDateTime(openData.EndDate))
                              .OrderBy(p => p.CallPoliceTime)
                              .Take(50)
                              .ToListAsync();
@@ -299,7 +302,6 @@ namespace Sharing.DaoShu110.Controllers
                         // 返回数据
                         apiR = ApiResultR.Succeed(System.Text.Json.JsonSerializer.Serialize(dto));
                     }
-
                 }
             }
             catch (System.Exception)
@@ -335,7 +337,7 @@ namespace Sharing.DaoShu110.Controllers
             // 测试Base64
             // 6RB6Hat8dpBfvCTtEpwotd/MlonxdmqZaa3TcLaua/xcjFv1SZJzKZPrhgsux63Gq/DXxtAQ25buLsI1fgFv3g==
 
-            CToken_DaoShu cToken = new CToken_DaoShu();
+            CToken_DaoShu cToken = new();
             string sm4 = cToken.token2_sm4_mw;
 
             IApiResultR apiR;
@@ -343,7 +345,7 @@ namespace Sharing.DaoShu110.Controllers
             {
                 // 验证dcsm
                 string dcsmMsg = CComm.checkDcsm(Request.Headers["dcsm"].ToString(), cToken.token2_dcsm);
-                if (false == string.IsNullOrEmpty(dcsmMsg))
+                if (!string.IsNullOrEmpty(dcsmMsg))
                 {
                     apiR = ApiResultR.Failed(dcsmMsg);
                 }
@@ -351,14 +353,14 @@ namespace Sharing.DaoShu110.Controllers
                 {
                     string base64String = await CComm.getStreamBase64(HttpContext.Request);
 
-                    OpenData openData = new OpenData();
-                    if (false == string.IsNullOrEmpty(base64String))
+                    OpenData openData = new();
+                    if (!string.IsNullOrEmpty(base64String))
                     {
                         // 解密:base64通过sm4解密转json
                         string jsonRes = Sm4Crypto.Decrypt_ECB_Base64(sm4, base64String);
-                        // json 转 实体类
-                        openData = System.Text.Json.JsonSerializer.Deserialize<OpenData>(jsonRes);
-
+                        if (!string.IsNullOrEmpty(jsonRes))
+                            // json 转 实体类
+                            openData = System.Text.Json.JsonSerializer.Deserialize<OpenData>(jsonRes);
                     }
 
                     var listData = await _policeSendChainDealDsRepository.Queryable()
@@ -398,171 +400,156 @@ namespace Sharing.DaoShu110.Controllers
 
         #endregion
 
-        //#region send-知识库列表
-
-        ///// <summary>
-        ///// 查询知识库列表
-        ///// </summary>
-        ///// <returns></returns>
-        //[HttpPost("service/api/ds/get_knowledge_info")]
-        //[AllowAnonymous]
-        //public async Task<HttpResponseMessage> Get_Knowledge_Info()
-        //{
-        //    // 测试Json
-        //    // {"createTimeBegin":"2003-04-07 10:59:14","createTimeEnd":"2023-04-07 10:59:21","keyWord":"测试"}
-        //    // {"createTimeBegin":"2003-04-07 10:59:14","createTimeEnd":"2023-04-07 10:59:21","keyWord":""}
-
-        //    // 测试Base64
-        //    // 93ObxWa6vhYID1pe3rx0ThmtcsgBLXGqvIYCMM8iUwPpItcJamHEbCHDV62/5tDIG7LZfbQCYscMo05nhdfdoQKo0xVndLdYFCsp6s291ecXIz2INGfLR7MVJjDLpg0orf2b9KCj4h8PDRwKY0FBqg==
-        //    // 93ObxWa6vhYID1pe3rx0ThmtcsgBLXGqvIYCMM8iUwPpItcJamHEbCHDV62/5tDIG7LZfbQCYscMo05nhdfdoQKo0xVndLdYFCsp6s291efskazkOkKJlTsM8iK4mdwj
-
-        //    CToken_DaoShu cToken = new CToken_DaoShu();
-        //    string sm4 = cToken.token5_sm4_mw;
-
-        //    IApiResultR apiR = null;
-        //    try
-        //    {
-        //        // 验证dcsm
-        //        string dcsmMsg = CComm.checkDcsm(Request.Headers["dcsm"].ToString(), cToken.token5_dcsm);
-        //        if (false == string.IsNullOrEmpty(dcsmMsg))
-        //        {
-        //            apiR = ApiResultR.Failed(dcsmMsg);
-        //        }
-        //        else
-        //        {
-        //            string base64String = await CComm.getStreamBase64(HttpContext.Request);
-
-        //            // 解密:base64通过sm4解密转json
-        //            string jsonRes = Sm4Crypto.Decrypt_ECB_Base64(sm4, base64String);
-        //            // json 转 实体类
-        //            Get_Knowledge getknowledge = System.Text.Json.JsonSerializer.Deserialize<Get_Knowledge>(jsonRes);
-        //            if (null == getknowledge)
-        //            {
-        //                getknowledge = new Get_Knowledge();
-        //            }
-
-        //            bool bRun = true;
-
-        //            if (string.IsNullOrEmpty(getknowledge.createTimeBegin) == false &&
-        //                Hotline.BLL.Order.Police.COrder.IsDate(getknowledge.createTimeBegin) == false)
-        //            {
-        //                bRun = false;
-        //                apiR = ApiResultR.Failed("【创建开始时间】不是日期格式 yyyy-MM-dd HH:mm:ss");
-        //            }
-        //            if (string.IsNullOrEmpty(getknowledge.createTimeEnd) == false &&
-        //                Hotline.BLL.Order.Police.COrder.IsDate(getknowledge.createTimeEnd) == false)
-        //            {
-        //                bRun = false;
-        //                apiR = ApiResultR.Failed("【创建结束时间】不是日期格式 yyyy-MM-dd HH:mm:ss");
-        //            }
-
-        //            if (bRun)
-        //            {
-        //                DataTable dtData = Hotline.BLL.Order.Police.COrder.get_knowledge_info(
-        //                    getknowledge.createTimeBegin, getknowledge.createTimeEnd, getknowledge.keyWord);
-        //                if (null == dtData)
-        //                {
-        //                    apiR = ApiResultR.Failed();
-        //                }
-        //                else
-        //                {
-        //                    apiR = ApiResultR.Succeed(dtData);
-        //                }
-        //            }
-        //        }
-        //    }
-        //    catch (System.Exception ex)
-        //    {
-        //        apiR = ApiResultR.Failed("接口异常");
-        //    }
-
-        //    // 返回数据转Json
-        //    string jsonResult = CJson.modelToJson(apiR);
-        //    // 加密:json通过sm4加密转base64
-        //    string base64 = Sm4Crypto.Encrypt_ECB_Base64(sm4, jsonResult);
-
-        //    var resp = new HttpResponseMessage(HttpStatusCode.OK);
-        //    resp.Content = new StringContent(base64, System.Text.Encoding.UTF8, "text/plain");
-        //    return resp;
-        //}
-
-        //#endregion
-
-        //#region send-知识库内容
-
-        ///// <summary>
-        ///// 查询知识库内容
-        ///// </summary>
-        ///// <returns></returns>
-        //[HttpPost("service/api/ds/get_knowledge_content")]
-        // [AllowAnonymous]
-        //public async Task<HttpResponseMessage> Get_Knowledge_Content()
-        //{
-        //    // 测试JSON
-        //    // {"id":"69040"}
-
-        //    // 测试Base64
-        //    // pBiY5NdsMjnvEjmtRPO+rQ==
-
-        //    CToken_DaoShu cToken = new CToken_DaoShu();
-        //    string dcsm = cToken.token6_dcsm;
-        //    string sm4 = cToken.token6_sm4_mw;
-
-        //    IApiResultR apiR = null;
-        //    try
-        //    {
-        //        // 验证dcsm
-        //        string dcsmMsg = CComm.checkDcsm(Request.Headers["dcsm"].ToString(), dcsm);
-        //        if (false == string.IsNullOrEmpty(dcsmMsg))
-        //        {
-        //            apiR = ApiResultR.Failed(dcsmMsg);
-        //        }
-        //        else
-        //        {
-        //            string base64String = await CComm.getStreamBase64(HttpContext.Request);
-
-        //            // 解密:base64通过sm4解密转json
-        //            string jsonRes = Sm4Crypto.Decrypt_ECB_Base64(sm4, base64String);
-        //            // json 转 实体类
-        //            Get_Knowledge getknowledge = System.Text.Json.JsonSerializer.Deserialize<Get_Knowledge>(jsonRes);
-        //            if (null == getknowledge)
-        //            {
-        //                getknowledge = new Get_Knowledge();
-        //            }
-
-        //            if (string.IsNullOrEmpty(getknowledge.id) == true)
-        //            {
-        //                apiR = ApiResultR.Failed("【知识库ID】不能为空");
-        //            }
-        //            else
-        //            {
-        //                DataTable dtData = Hotline.BLL.Order.Police.COrder.get_knowledge_content(getknowledge.id);
-        //                if (null == dtData)
-        //                {
-        //                    apiR = ApiResultR.Failed();
-        //                }
-        //                else
-        //                {
-        //                    apiR = ApiResultR.Succeed(dtData);
-        //                }
-        //            }
-        //        }
-        //    }
-        //    catch (System.Exception ex)
-        //    {
-        //        apiR = ApiResultR.Failed("接口异常");
-        //    }
-
-        //    // 返回数据转Json
-        //    string jsonResult = CJson.modelToJson(apiR);
-        //    // 加密:json通过sm4加密转base64
-        //    string base64 = Sm4Crypto.Encrypt_ECB_Base64(sm4, jsonResult);
-
-        //    var resp = new HttpResponseMessage(HttpStatusCode.OK);
-        //    resp.Content = new StringContent(base64, System.Text.Encoding.UTF8, "text/plain");
-        //    return resp;
-        //}
-
-        //#endregion
+        #region send-知识库列表
+
+        /// <summary>
+        /// 查询知识库列表
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost("service/api/ds/get_knowledge_info")]
+        [AllowAnonymous]
+        public async Task<HttpResponseMessage> Get_Knowledge_Info()
+        {
+            // 测试Json
+            // {"createTimeBegin":"2003-04-07 10:59:14","createTimeEnd":"2023-04-07 10:59:21","keyWord":"测试"}
+            // {"createTimeBegin":"2003-04-07 10:59:14","createTimeEnd":"2023-04-07 10:59:21","keyWord":""}
+
+            // 测试Base64
+            // 93ObxWa6vhYID1pe3rx0ThmtcsgBLXGqvIYCMM8iUwPpItcJamHEbCHDV62/5tDIG7LZfbQCYscMo05nhdfdoQKo0xVndLdYFCsp6s291ecXIz2INGfLR7MVJjDLpg0orf2b9KCj4h8PDRwKY0FBqg==
+            // 93ObxWa6vhYID1pe3rx0ThmtcsgBLXGqvIYCMM8iUwPpItcJamHEbCHDV62/5tDIG7LZfbQCYscMo05nhdfdoQKo0xVndLdYFCsp6s291efskazkOkKJlTsM8iK4mdwj
+
+            CToken_DaoShu cToken = new();
+            string sm4 = cToken.token5_sm4_mw;
+
+            IApiResultR apiR;
+            try
+            {
+                // 验证dcsm
+                string dcsmMsg = CComm.checkDcsm(Request.Headers["dcsm"].ToString(), cToken.token5_dcsm);
+                if (!string.IsNullOrEmpty(dcsmMsg))
+                {
+                    apiR = ApiResultR.Failed(dcsmMsg);
+                }
+                else
+                {
+                    string base64String = await CComm.getStreamBase64(HttpContext.Request);
+
+                    Get_Knowledge get_Knowledge = new Get_Knowledge();
+                    if (!string.IsNullOrEmpty(base64String))
+                    {
+                        // 解密:base64通过sm4解密转json
+                        string jsonRes = Sm4Crypto.Decrypt_ECB_Base64(sm4, base64String);
+                        if (!string.IsNullOrEmpty(jsonRes))
+                            // json 转 实体类
+                            get_Knowledge = System.Text.Json.JsonSerializer.Deserialize<Get_Knowledge>(jsonRes);
+                    }
+
+                    var listData = await _knowledgeRawDataRepository
+                        .Queryable()
+                        .WhereIF(!string.IsNullOrEmpty(get_Knowledge.createTimeBegin), p => p.CreatDate >= Convert.ToDateTime(get_Knowledge.createTimeBegin))
+                          .WhereIF(!string.IsNullOrEmpty(get_Knowledge.createTimeEnd), p => p.CreatDate <= Convert.ToDateTime(get_Knowledge.createTimeEnd))
+                          .WhereIF(!string.IsNullOrEmpty(get_Knowledge.keyWord), p => p.KName.Contains(get_Knowledge.keyWord))
+                         .OrderByDescending(p => p.CreatDate)
+                          .ToListAsync();
+
+                    if (null == listData)
+                        apiR = ApiResultR.Failed();
+                    else
+                    {
+                        var dto = _mapper.Map<IReadOnlyList<KnowledgeDto>>(listData);
+                        // 返回数据
+                        apiR = ApiResultR.Succeed(System.Text.Json.JsonSerializer.Serialize(dto));
+                    }
+
+                }
+            }
+            catch (System.Exception)
+            {
+                apiR = ApiResultR.Failed("接口异常");
+            }
+
+            // 返回数据转Json
+            string jsonResult = CJson.modelToJson(apiR);
+            // 加密:json通过sm4加密转base64
+            string base64 = Sm4Crypto.Encrypt_ECB_Base64(sm4, jsonResult);
+
+            var resp = new HttpResponseMessage(HttpStatusCode.OK);
+            resp.Content = new StringContent(base64, System.Text.Encoding.UTF8, "text/plain");
+            return resp;
+        }
+
+        #endregion
+
+        #region send-知识库内容
+
+        /// <summary>
+        /// 查询知识库内容
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost("service/api/ds/get_knowledge_content")]
+        [AllowAnonymous]
+        public async Task<HttpResponseMessage> Get_Knowledge_Content()
+        {
+            CToken_DaoShu cToken = new();
+            string sm4 = cToken.token6_sm4_mw;
+
+            IApiResultR apiR;
+            try
+            {
+                // 验证dcsm
+                string dcsmMsg = CComm.checkDcsm(Request.Headers["dcsm"].ToString(), cToken.token6_dcsm);
+                if (!string.IsNullOrEmpty(dcsmMsg))
+                {
+                    apiR = ApiResultR.Failed(dcsmMsg);
+                }
+                else
+                {
+                    string base64String = await CComm.getStreamBase64(HttpContext.Request);
+
+                    Get_Knowledge get_Knowledge = new Get_Knowledge();
+                    if (!string.IsNullOrEmpty(base64String))
+                    {
+                        // 解密:base64通过sm4解密转json
+                        string jsonRes = Sm4Crypto.Decrypt_ECB_Base64(sm4, base64String);
+                        if (!string.IsNullOrEmpty(jsonRes))
+                            // json 转 实体类
+                            get_Knowledge = System.Text.Json.JsonSerializer.Deserialize<Get_Knowledge>(jsonRes);
+                    }
+
+                    if (string.IsNullOrEmpty(get_Knowledge.id))
+                    {
+                        apiR = ApiResultR.Failed("【知识库ID】不能为空");
+                    }
+                    else
+                    {
+                        var data = await _knowledgeRawDataRepository.GetAsync(p => p.Id == get_Knowledge.id);
+                        if (null == data)
+                        {
+                            apiR = ApiResultR.Failed();
+                        }
+                        else
+                        {
+                            KeyValuePair<string, string> keyValuePair = new("content", data.KContent);
+                            apiR = ApiResultR.Succeed(keyValuePair);
+                        }
+                    }
+                }
+            }
+            catch (System.Exception)
+            {
+                apiR = ApiResultR.Failed("接口异常");
+            }
+
+            // 返回数据转Json
+            string jsonResult = CJson.modelToJson(apiR);
+            // 加密:json通过sm4加密转base64
+            string base64 = Sm4Crypto.Encrypt_ECB_Base64(sm4, jsonResult);
+
+            var resp = new HttpResponseMessage(HttpStatusCode.OK);
+            resp.Content = new StringContent(base64, System.Text.Encoding.UTF8, "text/plain");
+            return resp;
+        }
+
+        #endregion
     }
 }

+ 7 - 4
src/Sharing.DaoShu110/Dtos/Get_Knowledge.cs

@@ -8,19 +8,22 @@
         /// <summary>
         /// 创建开始时间
         /// </summary>
-        public string createTimeBegin;
+        public string createTimeBegin { get; set; }
+
         /// <summary>
         /// 创建结束时间
         /// </summary>
-        public string createTimeEnd;
+        public string createTimeEnd { get; set; }
+
         /// <summary>
         /// 关键字
         /// </summary>
-        public string keyWord;
+        public string keyWord { get; set; }
+
         /// <summary>
         /// 知识库ID
         /// </summary>
-        public string id;
+        public string id { get; set; }
     }
 }
 

+ 25 - 0
src/Sharing.DaoShu110/Dtos/KnowledgeDto.cs

@@ -0,0 +1,25 @@
+using System.Text.Json.Serialization;
+
+namespace Sharing.DaoShu110.Dtos
+{
+    public class KnowledgeDto
+    {
+        /// <summary>
+        /// 知识库ID
+        /// </summary>
+        [JsonPropertyName("id")]
+        public string Id { get; set; }
+
+        /// <summary>
+        /// 标题
+        /// </summary>
+        [JsonPropertyName("title")]
+        public string KName { get; set; }
+
+        /// <summary>
+        /// 知识创建时间
+        /// </summary>
+        [JsonPropertyName("createTime")]
+        public string CreatDate { get; set; }
+    }
+}

+ 0 - 18
src/Sharing.DaoShu110/Dtos/OpenData.cs

@@ -16,24 +16,6 @@ namespace Sharing.DaoShu110.Dtos
         [JsonPropertyName("endDate")]
         public string EndDate { get; set; }
 
-        /// <summary>
-        /// 开始时间
-        /// </summary>
-        [JsonPropertyName("createTimeBegin")]
-        public string CreateTimeBegin { get; set; }
-
-        /// <summary>
-        /// 结束时间
-        /// </summary>
-        [JsonPropertyName("createTimeEnd")]
-        public string CreateTimeEnd { get; set; }
-
-        /// <summary>
-        /// 知识唯一标识
-        /// </summary>
-        [JsonPropertyName("id")]
-        public string Id { get; set; }
-
         /// <summary>
         /// 接警单编号
         /// </summary>

+ 14 - 0
src/Sharing.Repository/Province/XieTong/Knowledge/KnowledgeRawDataRepository.cs

@@ -0,0 +1,14 @@
+using Sharing.Province.XieTong.Knowledge;
+using SqlSugar;
+using XF.Domain.Dependency;
+
+namespace Sharing.Repository.Province.XieTong.Knowledge
+{
+    public class KnowledgeRawDataRepository : BaseRepository<KnowledgeRawData>, IKnowledgeRawDataRepository, IScopeDependency
+    {
+        public KnowledgeRawDataRepository(ISugarUnitOfWork<SharingDbContext> uow) : base(uow)
+        {
+
+        }
+    }
+}

+ 8 - 0
src/Sharing/Province/XieTong/Knowledge/IKnowledgeRawDataRepository.cs

@@ -0,0 +1,8 @@
+using XF.Domain.Repository;
+
+namespace Sharing.Province.XieTong.Knowledge
+{
+    public interface IKnowledgeRawDataRepository : IRepository<KnowledgeRawData>
+    {
+    }
+}

+ 75 - 0
src/Sharing/Province/XieTong/Knowledge/KnowledgeRawData.cs

@@ -0,0 +1,75 @@
+using SqlSugar;
+using XF.Domain.Repository;
+
+namespace Sharing.Province.XieTong.Knowledge
+{
+    /// <summary>
+    /// 知识库原始数据
+    /// </summary>
+    public class KnowledgeRawData:FullStateEntity
+    {
+        /// <summary>
+        /// 知识类别code
+        /// </summary>
+        public string CategoryCode { get; set; }
+
+        /// <summary>
+        /// 知识类别名称
+        /// </summary>
+        public string CategoryName { get; set; }
+
+        /// <summary>
+        /// 发布人
+        /// </summary>
+        public string PublishPerson { get; set; }
+
+        /// <summary>
+        /// 所属部门名称
+        /// </summary>
+        public string OuName { get; set; }
+
+        /// <summary>
+        /// 知识名称
+        /// </summary>
+        public string KName { get; set; }
+
+        /// <summary>
+        /// 知识内容
+        /// </summary>
+        public string KContent { get; set; }
+
+        /// <summary>
+        /// 发布日期
+        /// </summary>
+        [SugarColumn(IsIgnore = true)]
+        public DateTime? CreatDate { get; set; }
+
+        /// <summary>
+        /// 生效时间
+        /// </summary>
+        [SugarColumn(IsIgnore = true)]
+        public DateTime? BeginDate { get; set; }
+
+        /// <summary>
+        /// 失效时间
+        /// </summary>
+        [SugarColumn(IsIgnore = true)]
+        public DateTime? DisableDate { get; set; }
+
+        /// <summary>
+        /// 上报知识唯一标识
+        /// </summary>
+        public string UID { get; set; }
+
+        /// <summary>
+        /// 行政区划代码
+        /// </summary>
+        public string AreaCode { get; set; }
+
+        /// <summary>
+        /// 材料标识
+        /// </summary>
+        [SugarColumn(IsIgnore = true)]
+        public string CliengGuid { get; set; }
+    }
+}