Bladeren bron

新增官网接口缓存

zhoufan 7 jaren geleden
bovenliggende
commit
73acbcced8

+ 134 - 25
CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/WebController.cs

@@ -852,6 +852,18 @@ namespace CallCenterApi.Interface.Controllers
852 852
             string strpagesize = RequestString.GetQueryString("pagesize");
853 853
             int pagesize = 10;
854 854
 
855
+
856
+            if (strpageindex.Trim() != "")
857
+                pageindex = Convert.ToInt32(strpageindex);
858
+            if (strpagesize.Trim() != "")
859
+                pagesize = Convert.ToInt32(strpagesize);
860
+
861
+            var dtCache = RedisHelper.StringGet($"WebNewsList_{type}_{name}_{pageindex}_{pagesize}");
862
+            if (dtCache != null)
863
+            {
864
+                return Content(dtCache.ToString());
865
+            }
866
+
855 867
             var sql = " and 1=1 ";
856 868
             if (type != 0)
857 869
             {
@@ -861,15 +873,6 @@ namespace CallCenterApi.Interface.Controllers
861 873
             {
862 874
                 sql += " and bt like '%" + name + "%'";
863 875
             }
864
-            if (strpageindex.Trim() != "")
865
-            {
866
-                pageindex = Convert.ToInt32(strpageindex);
867
-            }
868
-
869
-            if (strpagesize.Trim() != "")
870
-            {
871
-                pagesize = Convert.ToInt32(strpagesize);
872
-            }
873 876
 
874 877
             var recordCount = 0;
875 878
             var dt = BLL.PagerBLL.GetListPager(
@@ -915,6 +918,9 @@ namespace CallCenterApi.Interface.Controllers
915 918
                 rows = dt,
916 919
                 total = recordCount
917 920
             };
921
+
922
+            RedisHelper.StringSet($"WebNewsList_{type}_{name}_{pageindex}_{pagesize}", obj.ToJson(), new TimeSpan(0, 10, 0));
923
+
918 924
             return Content(obj.ToJson());
919 925
         }
920 926
 
@@ -927,6 +933,12 @@ namespace CallCenterApi.Interface.Controllers
927 933
             int type = RequestString.GetInt("type", 0);
928 934
             string name = RequestString.GetQueryString("name");
929 935
 
936
+            var dtCache = RedisHelper.StringGet($"AllWebNews_{type}_{name}");
937
+            if (dtCache != null)
938
+            {
939
+                return Success("成功", dtCache.ToString().ToObject<DataTable>());
940
+            }
941
+
930 942
             var sql = " 1=1 ";
931 943
             if (type != 0)
932 944
             {
@@ -963,7 +975,7 @@ namespace CallCenterApi.Interface.Controllers
963 975
                     dr["urlname"] = configfj.F_ParamValue + smallurl;
964 976
                 }
965 977
             }
966
-
978
+            RedisHelper.StringSet($"AllWebNews_{type}_{name}", dt.ToJson(), new TimeSpan(0, 10, 0));
967 979
             return Success("成功", dt);
968 980
         }
969 981
 
@@ -975,12 +987,18 @@ namespace CallCenterApi.Interface.Controllers
975 987
         {
976 988
             int num = RequestString.GetInt("num", 8);
977 989
 
990
+            var dtCache = RedisHelper.StringGet($"TopReleaseList_{num}");
991
+            if (dtCache != null)
992
+            {
993
+                return Success("成功", dtCache.ToString().ToObject<DataTable>());
994
+            }
995
+
978 996
             var sql = " select top " + num + " *,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetDictionaryName(F_InfoSource) as SourceName from T_Bus_WorkOrder where isnull(F_IsRelease,0) = 1 and F_IsDelete=0 ";
979 997
 
980 998
             sql += " order by F_CreateTime desc";
981 999
 
982 1000
             var dt = DbHelperSQL.Query(sql).Tables[0];
983
-
1001
+            RedisHelper.StringSet($"TopReleaseList_{num}", dt.ToJson(), new TimeSpan(0, 10, 0));
984 1002
             return Success("成功", dt);
985 1003
         }
986 1004
 
@@ -1005,6 +1023,17 @@ namespace CallCenterApi.Interface.Controllers
1005 1023
             string strpagesize = RequestString.GetQueryString("pagesize");
1006 1024
             int pagesize = 10;
1007 1025
 
1026
+            if (strpageindex.Trim() != "")
1027
+                pageindex = Convert.ToInt32(strpageindex);
1028
+            if (strpagesize.Trim() != "")
1029
+                pagesize = Convert.ToInt32(strpagesize);
1030
+
1031
+            var dtCache = RedisHelper.StringGet($"WebReleaseList_{title}_{cont}_{workorderid}_{starttime}_{endtime}_{type}_{deptid}_{keyid}_{pageindex}_{pagesize}");
1032
+            if (dtCache != null)
1033
+            {
1034
+                return Content(dtCache.ToString());
1035
+            }
1036
+
1008 1037
             var sql = " and isnull(F_IsRelease,0) = 1 and F_IsDelete=0 ";
1009 1038
             if (!string.IsNullOrEmpty(title))
1010 1039
             {
@@ -1043,15 +1072,6 @@ namespace CallCenterApi.Interface.Controllers
1043 1072
                 string sqlwhere = "select F_WorkOrderID from T_Bus_AssignedInfo where F_MainDeptId = '" + deptid + "' and F_IsSure in (0,1) and F_State=1 and F_IsDelete=0 ";
1044 1073
                 sql += " and F_WorkOrderID in(" + sqlwhere + ")";
1045 1074
             }
1046
-            if (strpageindex.Trim() != "")
1047
-            {
1048
-                pageindex = Convert.ToInt32(strpageindex);
1049
-            }
1050
-
1051
-            if (strpagesize.Trim() != "")
1052
-            {
1053
-                pagesize = Convert.ToInt32(strpagesize);
1054
-            }
1055 1075
 
1056 1076
             var recordCount = 0;
1057 1077
             string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetOverState(F_WorkOrderId) as OverState,"
@@ -1073,6 +1093,8 @@ namespace CallCenterApi.Interface.Controllers
1073 1093
                 rows = dt,
1074 1094
                 total = recordCount
1075 1095
             };
1096
+
1097
+            RedisHelper.StringSet($"WebReleaseList_{title}_{cont}_{workorderid}_{starttime}_{endtime}_{type}_{deptid}_{keyid}_{pageindex}_{pagesize}", obj.ToJson(), new TimeSpan(0, 10, 0));
1076 1098
             return Content(obj.ToJson());
1077 1099
         }
1078 1100
 
@@ -1117,6 +1139,11 @@ namespace CallCenterApi.Interface.Controllers
1117 1139
         {
1118 1140
 
1119 1141
             string workorderid = RequestString.GetQueryString("workorderid");
1142
+            var dtCache = RedisHelper.StringGet($"WebRelease{workorderid}");
1143
+            if (dtCache != null)
1144
+            {
1145
+                return Success("成功", dtCache.ToString().ToJObject());
1146
+            }
1120 1147
 
1121 1148
             Model.T_Bus_WorkOrder baseModel = new BLL.T_Bus_WorkOrder().GetModel(workorderid);
1122 1149
             if (baseModel != null && baseModel.F_IsRelease == 1)
@@ -1130,6 +1157,8 @@ namespace CallCenterApi.Interface.Controllers
1130 1157
                     classname = DbHelperSQL.GetSingle(" select dbo.GetDictionaryName(" + baseModel.F_InfoType + ")"),
1131 1158
                     sourcename= DbHelperSQL.GetSingle(" select dbo.GetDictionaryName(" + baseModel.F_InfoSource + ")")
1132 1159
                 };
1160
+
1161
+                RedisHelper.StringSet($"WebRelease{workorderid}", obj.ToJson(), new TimeSpan(0, 10, 0));
1133 1162
                 return Success("加载成功", obj);
1134 1163
             }
1135 1164
             else
@@ -1147,6 +1176,13 @@ namespace CallCenterApi.Interface.Controllers
1147 1176
         {
1148 1177
 
1149 1178
             string name = RequestString.GetQueryString("name");
1179
+
1180
+            var dtCache = RedisHelper.StringGet($"WebLinkList{name}");
1181
+            if (dtCache != null)
1182
+            {
1183
+                return Success("成功", dtCache.ToString().ToObject<DataTable>());
1184
+            }
1185
+
1150 1186
             string where = " select * from T_Web_Link where 1=1 ";
1151 1187
             Dictionary<string, string> paras = new Dictionary<string, string>();
1152 1188
             if (!string.IsNullOrEmpty(name))
@@ -1156,6 +1192,9 @@ namespace CallCenterApi.Interface.Controllers
1156 1192
             }
1157 1193
 
1158 1194
             var dt = DbHelperSQL.Query(where, paras).Tables[0];
1195
+
1196
+            RedisHelper.StringSet($"WebLinkList{name}", dt.ToJson(), new TimeSpan(0, 10, 0));
1197
+
1159 1198
             return Success("列表加载成功", dt);
1160 1199
         }
1161 1200
 
@@ -1165,10 +1204,17 @@ namespace CallCenterApi.Interface.Controllers
1165 1204
         /// <returns></returns>
1166 1205
         public ActionResult GetWebTypeList()
1167 1206
         {
1207
+            var dtCache = RedisHelper.StringGet($"WebTypeList");
1208
+            if (dtCache != null)
1209
+            {
1210
+                return Success("成功", dtCache.ToString().ToObject<DataTable>());
1211
+            }
1168 1212
 
1169 1213
             string sql = "select * from T_Sys_DictionaryValue where F_ItemId=2 and F_State=0 ";
1170 1214
             var dt = DbHelperSQL.Query(sql).Tables[0];
1171 1215
 
1216
+            RedisHelper.StringSet($"WebTypeList", dt.ToJson(), new TimeSpan(0, 10, 0));
1217
+
1172 1218
             return Success("列表加载成功", dt);
1173 1219
         }
1174 1220
 
@@ -1178,10 +1224,35 @@ namespace CallCenterApi.Interface.Controllers
1178 1224
         /// <returns></returns>
1179 1225
         public ActionResult GetWebAreaList()
1180 1226
         {
1181
-
1227
+            var dtCache = RedisHelper.StringGet($"WebAreaList");
1228
+            if (dtCache != null)
1229
+            {
1230
+                return Success("成功", dtCache.ToString().ToObject<DataTable>());
1231
+            }
1182 1232
             string sql = "select * from T_Sys_Area where isnull(F_PrentId,0)=0 and F_State=0 ";
1183 1233
             var dt = DbHelperSQL.Query(sql).Tables[0];
1234
+            RedisHelper.StringSet($"WebAreaList", dt.ToJson(), new TimeSpan(0, 10, 0));
1235
+            return Success("列表加载成功", dt);
1236
+        }
1237
+
1238
+        /// <summary>
1239
+        /// 获取事发地域列表
1240
+        /// </summary>
1241
+        /// <param name="id"></param>
1242
+        /// <returns></returns>
1243
+        public ActionResult GetWebAreaListById(int id = 0)
1244
+        {
1245
+            var dtCache = RedisHelper.StringGet($"WebAreaListById{id}");
1246
+            if (dtCache != null)
1247
+            {
1248
+                return Success("成功", dtCache.ToString().ToObject<DataTable>());
1249
+            }
1250
+
1251
+            Dictionary<string, string> paras = new Dictionary<string, string>();
1252
+            paras.Add("@Id", id.ToString());
1253
+            DataTable dt = DbHelperSQL.Query(" select * from T_Sys_Area where isnull(F_PrentId,0)=@id and F_State=0 ", paras).Tables[0];
1184 1254
 
1255
+            RedisHelper.StringSet($"WebAreaListById{id}", dt.ToJson(), new TimeSpan(0, 10, 0));
1185 1256
             return Success("列表加载成功", dt);
1186 1257
         }
1187 1258
 
@@ -1191,10 +1262,14 @@ namespace CallCenterApi.Interface.Controllers
1191 1262
         /// <returns></returns>
1192 1263
         public ActionResult GetWebKeyList()
1193 1264
         {
1194
-
1265
+            var dtCache = RedisHelper.StringGet($"WebKeyList");
1266
+            if (dtCache != null)
1267
+            {
1268
+                return Success("成功", dtCache.ToString().ToObject<DataTable>());
1269
+            }
1195 1270
             string sql = "select * from T_Sys_DictionaryValue where F_ItemId=3 and F_State=0 ";
1196 1271
             var dt = DbHelperSQL.Query(sql).Tables[0];
1197
-
1272
+            RedisHelper.StringSet($"WebKeyList", dt.ToJson(), new TimeSpan(0, 10, 0));
1198 1273
             return Success("列表加载成功", dt);
1199 1274
         }
1200 1275
 
@@ -1204,8 +1279,15 @@ namespace CallCenterApi.Interface.Controllers
1204 1279
         /// <returns></returns>
1205 1280
         public ActionResult GetWebDeptList()
1206 1281
         {
1282
+            var dtCache = RedisHelper.StringGet($"WebDeptList");
1283
+            if (dtCache != null)
1284
+            {
1285
+                return Success("成功", dtCache.ToString().ToObject<DataTable>());
1286
+            }
1287
+
1207 1288
             DataTable dt = new DataTable();
1208 1289
             dt = new BLL.T_Sys_Department().GetList(0, "F_State=0", " F_Sort").Tables[0];
1290
+            RedisHelper.StringSet($"WebDeptList", dt.ToJson(), new TimeSpan(0, 10, 0));
1209 1291
             return Success("加载成功", dt);
1210 1292
         }
1211 1293
 
@@ -1468,6 +1550,12 @@ namespace CallCenterApi.Interface.Controllers
1468 1550
         /// <returns></returns>
1469 1551
         public ActionResult GetWebSourceCount()
1470 1552
         {
1553
+            var dtCache = RedisHelper.StringGet($"WebSourceCount");
1554
+            if (dtCache != null)
1555
+            {
1556
+                return Success("成功", dtCache.ToString().ToJObject());
1557
+            }
1558
+
1471 1559
             string sql = " select F_Value Source,(select COUNT(1) from T_Bus_WorkOrder where F_IsDelete=0 "
1472 1560
                 + " and  F_InfoSource=F_ValueId) Count from  dbo.T_Sys_DictionaryValue where F_ItemId=1 and F_State=0 ";
1473 1561
             DataTable dt = DbHelperSQL.Query(sql).Tables[0];
@@ -1481,6 +1569,9 @@ namespace CallCenterApi.Interface.Controllers
1481 1569
                 total = dt,
1482 1570
                 day = dtday
1483 1571
             };
1572
+
1573
+            RedisHelper.StringSet($"WebSourceCount", obj.ToJson(), new TimeSpan(0, 10, 0));
1574
+
1484 1575
             return Success("加载成功", obj);
1485 1576
         }
1486 1577
 
@@ -1490,6 +1581,12 @@ namespace CallCenterApi.Interface.Controllers
1490 1581
         /// <returns></returns>
1491 1582
         public ActionResult GetWebTypePercent()
1492 1583
         {
1584
+            var dtCache = RedisHelper.StringGet($"WebTypePercent");
1585
+            if (dtCache != null)
1586
+            {
1587
+                return Success("成功", dtCache.ToString().ToObject<object>());
1588
+            }
1589
+
1493 1590
             var typelist = new BLL.T_Sys_DictionaryValue().GetModelList(" F_ItemId=2 ");
1494 1591
             string sql = " select count(1) from dbo.T_Bus_WorkOrder where F_IsDelete = 0 ";
1495 1592
             var tl = Int32.Parse(DbHelperSQL.GetSingle(sql).ToString());
@@ -1503,15 +1600,25 @@ namespace CallCenterApi.Interface.Controllers
1503 1600
                     percent = tl > 0 ? Math.Round(((double)cl * 100 / tl), 2) : 0
1504 1601
                 };
1505 1602
             });
1603
+
1604
+            RedisHelper.StringSet($"WebTypePercent", obj.ToJson(), new TimeSpan(0, 10, 0));
1605
+
1506 1606
             return Success("加载成功", obj);
1507 1607
         }
1508 1608
 
1609
+
1509 1610
         /// <summary>
1510 1611
         /// 获取类型比例
1511 1612
         /// </summary>
1512 1613
         /// <returns></returns>
1513
-        public ActionResult GetWebKeyCount(int isscqt = 0)
1614
+        public ActionResult GetWebKeyCount(int num = 7, int isscqt = 0)
1514 1615
         {
1616
+            var dtCache = RedisHelper.StringGet($"WebKeyCount_{num}_{isscqt}");
1617
+            if (dtCache != null)
1618
+            {
1619
+                return Success("成功", dtCache.ToString().ToObject<object>());
1620
+            }
1621
+
1515 1622
             string strwhere = " F_ItemId=3 ";
1516 1623
             if (isscqt > 0)
1517 1624
             {
@@ -1528,7 +1635,9 @@ namespace CallCenterApi.Interface.Controllers
1528 1635
                     keyname = p.F_Value,
1529 1636
                     count = cl
1530 1637
                 };
1531
-            }).OrderByDescending(p => p.count).Take(7);
1638
+            }).OrderByDescending(p => p.count).Take(num);
1639
+
1640
+            RedisHelper.StringSet($"WebKeyCount_{num}_{isscqt}", obj.ToJson(), new TimeSpan(0, 10, 0));
1532 1641
             return Success("加载成功", obj);
1533 1642
         }
1534 1643