Pārlūkot izejas kodu

新增官网接口缓存

zhoufan 7 gadi atpakaļ
vecāks
revīzija
73acbcced8

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

852
             string strpagesize = RequestString.GetQueryString("pagesize");
852
             string strpagesize = RequestString.GetQueryString("pagesize");
853
             int pagesize = 10;
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
             var sql = " and 1=1 ";
867
             var sql = " and 1=1 ";
856
             if (type != 0)
868
             if (type != 0)
857
             {
869
             {
861
             {
873
             {
862
                 sql += " and bt like '%" + name + "%'";
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
             var recordCount = 0;
877
             var recordCount = 0;
875
             var dt = BLL.PagerBLL.GetListPager(
878
             var dt = BLL.PagerBLL.GetListPager(
915
                 rows = dt,
918
                 rows = dt,
916
                 total = recordCount
919
                 total = recordCount
917
             };
920
             };
921
+
922
+            RedisHelper.StringSet($"WebNewsList_{type}_{name}_{pageindex}_{pagesize}", obj.ToJson(), new TimeSpan(0, 10, 0));
923
+
918
             return Content(obj.ToJson());
924
             return Content(obj.ToJson());
919
         }
925
         }
920
 
926
 
927
             int type = RequestString.GetInt("type", 0);
933
             int type = RequestString.GetInt("type", 0);
928
             string name = RequestString.GetQueryString("name");
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
             var sql = " 1=1 ";
942
             var sql = " 1=1 ";
931
             if (type != 0)
943
             if (type != 0)
932
             {
944
             {
963
                     dr["urlname"] = configfj.F_ParamValue + smallurl;
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
             return Success("成功", dt);
979
             return Success("成功", dt);
968
         }
980
         }
969
 
981
 
975
         {
987
         {
976
             int num = RequestString.GetInt("num", 8);
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
             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 ";
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
             sql += " order by F_CreateTime desc";
998
             sql += " order by F_CreateTime desc";
981
 
999
 
982
             var dt = DbHelperSQL.Query(sql).Tables[0];
1000
             var dt = DbHelperSQL.Query(sql).Tables[0];
983
-
1001
+            RedisHelper.StringSet($"TopReleaseList_{num}", dt.ToJson(), new TimeSpan(0, 10, 0));
984
             return Success("成功", dt);
1002
             return Success("成功", dt);
985
         }
1003
         }
986
 
1004
 
1005
             string strpagesize = RequestString.GetQueryString("pagesize");
1023
             string strpagesize = RequestString.GetQueryString("pagesize");
1006
             int pagesize = 10;
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
             var sql = " and isnull(F_IsRelease,0) = 1 and F_IsDelete=0 ";
1037
             var sql = " and isnull(F_IsRelease,0) = 1 and F_IsDelete=0 ";
1009
             if (!string.IsNullOrEmpty(title))
1038
             if (!string.IsNullOrEmpty(title))
1010
             {
1039
             {
1043
                 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 ";
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
                 sql += " and F_WorkOrderID in(" + sqlwhere + ")";
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
             var recordCount = 0;
1076
             var recordCount = 0;
1057
             string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetOverState(F_WorkOrderId) as OverState,"
1077
             string cols = "*,dbo.GetUserName(F_CreateUser) as UserName,dbo.GetDictionaryName(F_InfoType) as TypeName,dbo.GetOverState(F_WorkOrderId) as OverState,"
1073
                 rows = dt,
1093
                 rows = dt,
1074
                 total = recordCount
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
             return Content(obj.ToJson());
1098
             return Content(obj.ToJson());
1077
         }
1099
         }
1078
 
1100
 
1117
         {
1139
         {
1118
 
1140
 
1119
             string workorderid = RequestString.GetQueryString("workorderid");
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
             Model.T_Bus_WorkOrder baseModel = new BLL.T_Bus_WorkOrder().GetModel(workorderid);
1148
             Model.T_Bus_WorkOrder baseModel = new BLL.T_Bus_WorkOrder().GetModel(workorderid);
1122
             if (baseModel != null && baseModel.F_IsRelease == 1)
1149
             if (baseModel != null && baseModel.F_IsRelease == 1)
1130
                     classname = DbHelperSQL.GetSingle(" select dbo.GetDictionaryName(" + baseModel.F_InfoType + ")"),
1157
                     classname = DbHelperSQL.GetSingle(" select dbo.GetDictionaryName(" + baseModel.F_InfoType + ")"),
1131
                     sourcename= DbHelperSQL.GetSingle(" select dbo.GetDictionaryName(" + baseModel.F_InfoSource + ")")
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
                 return Success("加载成功", obj);
1162
                 return Success("加载成功", obj);
1134
             }
1163
             }
1135
             else
1164
             else
1147
         {
1176
         {
1148
 
1177
 
1149
             string name = RequestString.GetQueryString("name");
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
             string where = " select * from T_Web_Link where 1=1 ";
1186
             string where = " select * from T_Web_Link where 1=1 ";
1151
             Dictionary<string, string> paras = new Dictionary<string, string>();
1187
             Dictionary<string, string> paras = new Dictionary<string, string>();
1152
             if (!string.IsNullOrEmpty(name))
1188
             if (!string.IsNullOrEmpty(name))
1156
             }
1192
             }
1157
 
1193
 
1158
             var dt = DbHelperSQL.Query(where, paras).Tables[0];
1194
             var dt = DbHelperSQL.Query(where, paras).Tables[0];
1195
+
1196
+            RedisHelper.StringSet($"WebLinkList{name}", dt.ToJson(), new TimeSpan(0, 10, 0));
1197
+
1159
             return Success("列表加载成功", dt);
1198
             return Success("列表加载成功", dt);
1160
         }
1199
         }
1161
 
1200
 
1165
         /// <returns></returns>
1204
         /// <returns></returns>
1166
         public ActionResult GetWebTypeList()
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
             string sql = "select * from T_Sys_DictionaryValue where F_ItemId=2 and F_State=0 ";
1213
             string sql = "select * from T_Sys_DictionaryValue where F_ItemId=2 and F_State=0 ";
1170
             var dt = DbHelperSQL.Query(sql).Tables[0];
1214
             var dt = DbHelperSQL.Query(sql).Tables[0];
1171
 
1215
 
1216
+            RedisHelper.StringSet($"WebTypeList", dt.ToJson(), new TimeSpan(0, 10, 0));
1217
+
1172
             return Success("列表加载成功", dt);
1218
             return Success("列表加载成功", dt);
1173
         }
1219
         }
1174
 
1220
 
1178
         /// <returns></returns>
1224
         /// <returns></returns>
1179
         public ActionResult GetWebAreaList()
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
             string sql = "select * from T_Sys_Area where isnull(F_PrentId,0)=0 and F_State=0 ";
1232
             string sql = "select * from T_Sys_Area where isnull(F_PrentId,0)=0 and F_State=0 ";
1183
             var dt = DbHelperSQL.Query(sql).Tables[0];
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
             return Success("列表加载成功", dt);
1256
             return Success("列表加载成功", dt);
1186
         }
1257
         }
1187
 
1258
 
1191
         /// <returns></returns>
1262
         /// <returns></returns>
1192
         public ActionResult GetWebKeyList()
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
             string sql = "select * from T_Sys_DictionaryValue where F_ItemId=3 and F_State=0 ";
1270
             string sql = "select * from T_Sys_DictionaryValue where F_ItemId=3 and F_State=0 ";
1196
             var dt = DbHelperSQL.Query(sql).Tables[0];
1271
             var dt = DbHelperSQL.Query(sql).Tables[0];
1197
-
1272
+            RedisHelper.StringSet($"WebKeyList", dt.ToJson(), new TimeSpan(0, 10, 0));
1198
             return Success("列表加载成功", dt);
1273
             return Success("列表加载成功", dt);
1199
         }
1274
         }
1200
 
1275
 
1204
         /// <returns></returns>
1279
         /// <returns></returns>
1205
         public ActionResult GetWebDeptList()
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
             DataTable dt = new DataTable();
1288
             DataTable dt = new DataTable();
1208
             dt = new BLL.T_Sys_Department().GetList(0, "F_State=0", " F_Sort").Tables[0];
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
             return Success("加载成功", dt);
1291
             return Success("加载成功", dt);
1210
         }
1292
         }
1211
 
1293
 
1468
         /// <returns></returns>
1550
         /// <returns></returns>
1469
         public ActionResult GetWebSourceCount()
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
             string sql = " select F_Value Source,(select COUNT(1) from T_Bus_WorkOrder where F_IsDelete=0 "
1559
             string sql = " select F_Value Source,(select COUNT(1) from T_Bus_WorkOrder where F_IsDelete=0 "
1472
                 + " and  F_InfoSource=F_ValueId) Count from  dbo.T_Sys_DictionaryValue where F_ItemId=1 and F_State=0 ";
1560
                 + " and  F_InfoSource=F_ValueId) Count from  dbo.T_Sys_DictionaryValue where F_ItemId=1 and F_State=0 ";
1473
             DataTable dt = DbHelperSQL.Query(sql).Tables[0];
1561
             DataTable dt = DbHelperSQL.Query(sql).Tables[0];
1481
                 total = dt,
1569
                 total = dt,
1482
                 day = dtday
1570
                 day = dtday
1483
             };
1571
             };
1572
+
1573
+            RedisHelper.StringSet($"WebSourceCount", obj.ToJson(), new TimeSpan(0, 10, 0));
1574
+
1484
             return Success("加载成功", obj);
1575
             return Success("加载成功", obj);
1485
         }
1576
         }
1486
 
1577
 
1490
         /// <returns></returns>
1581
         /// <returns></returns>
1491
         public ActionResult GetWebTypePercent()
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
             var typelist = new BLL.T_Sys_DictionaryValue().GetModelList(" F_ItemId=2 ");
1590
             var typelist = new BLL.T_Sys_DictionaryValue().GetModelList(" F_ItemId=2 ");
1494
             string sql = " select count(1) from dbo.T_Bus_WorkOrder where F_IsDelete = 0 ";
1591
             string sql = " select count(1) from dbo.T_Bus_WorkOrder where F_IsDelete = 0 ";
1495
             var tl = Int32.Parse(DbHelperSQL.GetSingle(sql).ToString());
1592
             var tl = Int32.Parse(DbHelperSQL.GetSingle(sql).ToString());
1503
                     percent = tl > 0 ? Math.Round(((double)cl * 100 / tl), 2) : 0
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
             return Success("加载成功", obj);
1606
             return Success("加载成功", obj);
1507
         }
1607
         }
1508
 
1608
 
1609
+
1509
         /// <summary>
1610
         /// <summary>
1510
         /// 获取类型比例
1611
         /// 获取类型比例
1511
         /// </summary>
1612
         /// </summary>
1512
         /// <returns></returns>
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
             string strwhere = " F_ItemId=3 ";
1622
             string strwhere = " F_ItemId=3 ";
1516
             if (isscqt > 0)
1623
             if (isscqt > 0)
1517
             {
1624
             {
1528
                     keyname = p.F_Value,
1635
                     keyname = p.F_Value,
1529
                     count = cl
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
             return Success("加载成功", obj);
1641
             return Success("加载成功", obj);
1533
         }
1642
         }
1534
 
1643