loging.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. package log
  2. import (
  3. "encoding/json"
  4. "github.com/gin-gonic/gin"
  5. "go.uber.org/zap"
  6. "log-server/global"
  7. "log-server/model/common/response"
  8. log2 "log-server/model/log"
  9. "log-server/model/log/request"
  10. "log-server/service/log"
  11. loging2 "log-server/service/log/loging"
  12. "log-server/utils"
  13. "strconv"
  14. )
  15. type ApiLoging struct {
  16. }
  17. // @Tags loging
  18. // @Summary 添加日志
  19. // @Security ApiKeyAuth
  20. // @accept application/json
  21. // @Produce application/json
  22. // @Param data body request.AddLogRequest true "simulator_ip(模拟器ip),simulator_mac(模拟器mac地址),pc_code(租机编号),pc_mac(租机mac地址),pc_ip(租机ip),device_id(绑定的设备id),account(账号),game_id(游戏id),coding(上传编码),computer_type(电脑类型),env_code(环境编号),log_uuid(日志uuid唯一,可以时间戳加随机数。上报一轮后更换),operator(脚本开发员),account_type(账号类型),remarks(备注),report_points_data(打点数据),task_type(1新增,2活跃),script_type(1中控,2脚本)脚本类型"
  23. // @Success 200 {object} response.Response{msg=string} "添加日志"
  24. // @Router /loging/setLog [Post]
  25. func (s *ApiLoging) CreateLog(c *gin.Context) {
  26. var api request.AddLogRequest
  27. _ = c.ShouldBindJSON(&api)
  28. body, _ := json.Marshal(api)
  29. global.GVA_LOG.Info(string(body))
  30. if err := utils.Verify(api, utils.LogAddVerify); err != nil {
  31. response.FailWithMessage(err.Error(), c)
  32. return
  33. }
  34. coding := strconv.Itoa(api.Coding)
  35. if len(coding) != 7 {
  36. response.FailWithMessage("该日志码没有7位"+coding, c)
  37. return
  38. }
  39. nodeCoding := coding[:3]
  40. status := coding[5:]
  41. noLogStatus := coding[3:5]
  42. var logical log.ServiceLoging
  43. switch nodeCoding {
  44. case "410":
  45. logical = new(loging2.PullAccountLog)
  46. break
  47. case "430":
  48. logical = new(loging2.SimulatorStartLog)
  49. break
  50. case "450":
  51. logical = new(loging2.GameStartLog)
  52. break
  53. case "460":
  54. logical = new(loging2.LoginLog)
  55. break
  56. case "470":
  57. logical = new(loging2.EnterMainLog)
  58. break
  59. case "480":
  60. logical = new(loging2.FeeLog)
  61. break
  62. default:
  63. logical = new(loging2.OtherLog)
  64. break
  65. }
  66. go ServiceLogList.CreateLog(c, api, logical, status, noLogStatus)
  67. response.OkWithMessage("后台已接收数据", c)
  68. }
  69. // @Tags loging
  70. // @Summary 获取log
  71. // @Security ApiKeyAuth
  72. // @accept application/json
  73. // @Produce application/json
  74. // @Param data body request.GetLogListRequest true "获取log"
  75. // @Success 200 {object} response.Response{data=response.GetLogCodingReply} "根据id获取coding,返回包括coding详情"
  76. // @Router /loging/getLogList [post]
  77. func (s *ApiLoging) GetLogList(c *gin.Context) {
  78. var paramsInfo request.GetLogListRequest
  79. _ = c.ShouldBindJSON(&paramsInfo)
  80. if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
  81. response.FailWithMessage(err.Error(), c)
  82. return
  83. }
  84. list, total, err := ServiceLogList.GetCodeLogList(c, paramsInfo.Loging, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc, paramsInfo.Code)
  85. if err != nil {
  86. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  87. response.FailWithMessage("获取失败", c)
  88. } else {
  89. response.OkWithDetailed(response.PageResult{
  90. List: list,
  91. Total: total,
  92. Page: paramsInfo.Page,
  93. PageSize: paramsInfo.PageSize,
  94. }, "获取成功", c)
  95. }
  96. }
  97. // @Tags loging
  98. // @Summary 获取打点log
  99. // @Security ApiKeyAuth
  100. // @accept application/json
  101. // @Produce application/json
  102. // @Param data body request.GetLogListRequest true "获取打点log"
  103. // @Success 200 {object} response.Response{data=response.GetLogCodingReply} "获取打点log列表"
  104. // @Router /loging/getReportLogList [post]
  105. func (s *ApiLoging) GetReportPointsLogList(c *gin.Context) {
  106. var paramsInfo request.ReportPointsListRequest
  107. _ = c.ShouldBindJSON(&paramsInfo)
  108. if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
  109. response.FailWithMessage(err.Error(), c)
  110. return
  111. }
  112. list, total, err := ServiceReportPointsLog.GetReportPointsLogList(paramsInfo.ReportPointsLog, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
  113. if err != nil {
  114. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  115. response.FailWithMessage("获取失败", c)
  116. } else {
  117. response.OkWithDetailed(response.PageResult{
  118. List: list,
  119. Total: total,
  120. Page: paramsInfo.Page,
  121. PageSize: paramsInfo.PageSize,
  122. }, "获取成功", c)
  123. }
  124. }
  125. // @Tags loging
  126. // @Summary 获取iplog
  127. // @Security ApiKeyAuth
  128. // @accept application/json
  129. // @Produce application/json
  130. // @Param data body request.IpLogListRequest true "获取iplog"
  131. // @Success 200 {object} response.Response{data=log2.IpLog} "获取iplog列表"
  132. // @Router /loging/getIpLogList [post]
  133. func (s *ApiLoging) GetIpLogList(c *gin.Context) {
  134. var paramsInfo request.IpLogListRequest
  135. _ = c.ShouldBindJSON(&paramsInfo)
  136. if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
  137. response.FailWithMessage(err.Error(), c)
  138. return
  139. }
  140. list, total, err := ServiceIpLog.GetIpLogList(paramsInfo.IpLogRequest, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
  141. if err != nil {
  142. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  143. response.FailWithMessage("获取失败", c)
  144. } else {
  145. response.OkWithDetailed(response.PageResult{
  146. List: list,
  147. Total: total,
  148. Page: paramsInfo.Page,
  149. PageSize: paramsInfo.PageSize,
  150. }, "获取成功", c)
  151. }
  152. }
  153. // @Tags loging
  154. // @Summary 获取某天具体ip
  155. // @Security ApiKeyAuth
  156. // @accept application/json
  157. // @Produce application/json
  158. // @Param data body log2.IpLog true "获取ip"
  159. // @Success 200 {object} response.Response{data=log2.IpResponse} "获取iplog列表"
  160. // @Router /loging/getIp [post]
  161. func (s *ApiLoging) GetIp(c *gin.Context) {
  162. var ip log2.IpLogResponse
  163. _ = c.ShouldBindJSON(&ip)
  164. if ip.GameId == 0 {
  165. response.FailWithMessage("游戏id不能为空", c)
  166. return
  167. }
  168. if ip.PcCode == "" {
  169. response.FailWithMessage("租机编号不能为空", c)
  170. return
  171. }
  172. if ip.CreateDate == ""{
  173. response.FailWithMessage("创建日期不能为空", c)
  174. return
  175. }
  176. list, total, err := ServiceIpLog.GetIp(ip)
  177. if err != nil {
  178. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  179. response.FailWithMessage("获取失败", c)
  180. } else {
  181. response.OkWithDetailed(response.PageResult{
  182. List: list,
  183. Total: total,
  184. }, "获取成功", c)
  185. }
  186. }
  187. // @Tags loging
  188. // @Summary 获取统计节点log
  189. // @Security ApiKeyAuth
  190. // @accept application/json
  191. // @Produce application/json
  192. // @Success 200 {object} response.Response{data=interface{}} "获取统计log"
  193. // @Router /loging/getNodeStatisticsLogList [post]
  194. func (s *ApiLoging) GetNodeStatisticsLogList(c *gin.Context) {
  195. var paramsInfo request.GetStatisticsLogRequest
  196. _ = c.ShouldBindJSON(&paramsInfo)
  197. if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
  198. response.FailWithMessage(err.Error(), c)
  199. return
  200. }
  201. list, total, err := ServiceStatisticsLog.StatisticsNodeLogList(c, paramsInfo.StatisticsLog, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
  202. if err != nil {
  203. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  204. response.FailWithMessage("获取失败", c)
  205. } else {
  206. response.OkWithDetailed(response.PageResult{
  207. List: list,
  208. Total: total,
  209. Page: paramsInfo.Page,
  210. PageSize: paramsInfo.PageSize,
  211. }, "获取成功", c)
  212. }
  213. }
  214. // @Tags loging
  215. // @Summary 获取统计log
  216. // @Security ApiKeyAuth
  217. // @accept application/json
  218. // @Produce application/json
  219. // @Success 200 {object} response.Response{data=interface{}} "获取统计log"
  220. // @Router /loging/getStatisticsLogList [post]
  221. func (s *ApiLoging) GetStatisticsLogList(c *gin.Context) {
  222. var paramsInfo request.GetStatisticsLogRequest
  223. _ = c.ShouldBindJSON(&paramsInfo)
  224. if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
  225. response.FailWithMessage(err.Error(), c)
  226. return
  227. }
  228. list, total, err := ServiceStatisticsLog.OtherStatisticsLogList(c, paramsInfo.StatisticsLog, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
  229. if err != nil {
  230. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  231. response.FailWithMessage("获取失败", c)
  232. } else {
  233. response.OkWithDetailed(response.PageResult{
  234. List: list,
  235. Total: total,
  236. Page: paramsInfo.Page,
  237. PageSize: paramsInfo.PageSize,
  238. }, "获取成功", c)
  239. }
  240. }
  241. // @Tags loging
  242. // @Summary 重置统计log
  243. // @Security ApiKeyAuth
  244. // @accept application/json
  245. // @Produce application/json
  246. // @Param data body request.GetById true "根据id重置统计log"
  247. // @Success 200 {object} response.Response{data=interface{}} "重置统计log"
  248. // @Router /loging/resetStatisticsLog [post]
  249. //func (s *ApiLoging) ResetStatisticsLog(c *gin.Context) {
  250. // var paramsInfo request.GetById
  251. // _ = c.ShouldBindJSON(&paramsInfo)
  252. // if err := utils.Verify(paramsInfo, utils.IdVerify); err != nil {
  253. // response.FailWithMessage(err.Error(), c)
  254. // return
  255. // }
  256. // current := time.Now().Format("2006-01-02")
  257. // key := current + ":" + strconv.Itoa(paramsInfo.ID) + ":reset"
  258. // i, err := global.GVA_REDIS.Exists(c, key).Result()
  259. // if err != nil {
  260. // global.GVA_LOG.Error("重置统计数据检测key失败", zap.Error(err))
  261. // response.FailWithMessage("重置失败", c)
  262. // return
  263. // }
  264. // if i != 0 {
  265. // global.GVA_LOG.Info("还在重置中", zap.Error(err))
  266. // response.FailWithMessage("在重置中", c)
  267. // return
  268. // }
  269. // go ServiceStatisticsLog.ResetStatisticsLog(c, paramsInfo.ID, current)
  270. // response.OkWithMessage("后台重置中", c)
  271. //}
  272. // @Tags loging
  273. // @Summary 获取统计电脑
  274. // @Security ApiKeyAuth
  275. // @accept application/json
  276. // @Produce application/json
  277. // @Success 200 {object} response.Response{data=interface{}} "获取统计电脑"
  278. // @Router /loging/getComputerStatistics [post]
  279. func (s *ApiLoging) GetComputerStatistics(c *gin.Context) {
  280. var paramsInfo request.GetStatisticsComputerRequest
  281. _ = c.ShouldBindJSON(&paramsInfo)
  282. /*if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
  283. response.FailWithMessage(err.Error(), c)
  284. return
  285. }*/
  286. list, total, err := ServiceStatisticsLog.ComputerStatistics(c, paramsInfo.LogComputer, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
  287. if err != nil {
  288. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  289. response.FailWithMessage("获取失败", c)
  290. } else {
  291. response.OkWithDetailed(response.PageResult{
  292. List: list,
  293. Total: total,
  294. Page: paramsInfo.Page,
  295. PageSize: paramsInfo.PageSize,
  296. }, "获取成功", c)
  297. }
  298. }
  299. // @Tags loging
  300. // @Summary 在线电脑
  301. // @Security ApiKeyAuth
  302. // @accept application/json
  303. // @Produce application/json
  304. // @Success 200 {object} response.Response{data=interface{}} "在线电脑"
  305. // @Router /loging/getOnlineComputer [post]
  306. func (s *ApiLoging) GetOnlineComputer(c *gin.Context) {
  307. var paramsInfo request.GetStatisticsComputerRequest
  308. _ = c.ShouldBindJSON(&paramsInfo)
  309. list, total, err := ServiceStatisticsLog.OnlineComputerStatistics(c, paramsInfo.LogComputer, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
  310. if err != nil {
  311. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  312. response.FailWithMessage("获取失败", c)
  313. } else {
  314. response.OkWithDetailed(response.PageResult{
  315. List: list,
  316. Total: total,
  317. Page: paramsInfo.Page,
  318. PageSize: paramsInfo.PageSize,
  319. }, "获取成功", c)
  320. }
  321. }
  322. // @Tags loging
  323. // @Summary 获取统计电脑数量
  324. // @Security ApiKeyAuth
  325. // @accept application/json
  326. // @Produce application/json
  327. // @Success 200 {object} response.Response{data=interface{}} "获取统计电脑数量"
  328. // @Router /loging/getComputerNum [post]
  329. func (s *ApiLoging) GetComputerNum(c *gin.Context) {
  330. var paramsInfo request.GetStatisticsComputerRequest
  331. _ = c.ShouldBindJSON(&paramsInfo)
  332. num := ServiceStatisticsLog.GetComputerNum(paramsInfo.CreateDate)
  333. response.OkWithDetailed(num, "获取成功", c)
  334. }
  335. // @Tags loging
  336. // @Summary 获取统计数据通过GameId
  337. // @Security ApiKeyAuth
  338. // @accept application/json
  339. // @Produce application/json
  340. // @Success 200 {object} response.Response{data=interface{}} "获取统计数据通过GameId"
  341. // @Router /loging/getGameIdStatistics [post]
  342. func (s *ApiLoging) GetGameIdStatistics(c *gin.Context) {
  343. var paramsInfo request.GetStatisticsComputerRequest
  344. _ = c.ShouldBindJSON(&paramsInfo)
  345. /*if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
  346. response.FailWithMessage(err.Error(), c)
  347. return
  348. }*/
  349. list, total, err := ServiceStatisticsLog.GameStatistics(c, paramsInfo.LogComputer, paramsInfo.PageInfo)
  350. if err != nil {
  351. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  352. response.FailWithMessage("获取失败", c)
  353. } else {
  354. response.OkWithDetailed(response.PageResult{
  355. List: list,
  356. Total: total,
  357. Page: paramsInfo.Page,
  358. PageSize: paramsInfo.PageSize,
  359. }, "获取成功", c)
  360. }
  361. }
  362. // @Tags loging
  363. // @Summary 获取统计电脑数量
  364. // @Security ApiKeyAuth
  365. // @accept application/json
  366. // @Produce application/json
  367. // @Success 200 {object} response.Response{data=interface{}} "获取统计电脑数量"
  368. // @Router /loging/computerHeartbeat [post]
  369. func (s *ApiLoging) ComputerHeartbeat(c *gin.Context) {
  370. var paramsInfo request.OnlineComputerRequest
  371. _ = c.ShouldBindJSON(&paramsInfo)
  372. if paramsInfo.PcCode == "" || paramsInfo.Operator == "" {
  373. global.GVA_LOG.Error("参数错误!")
  374. response.FailWithMessage("参数错误", c)
  375. return
  376. }
  377. num := ServiceStatisticsLog.ComputerHeartbeat(c, paramsInfo)
  378. response.OkWithDetailed(num, "上报成功", c)
  379. }
  380. // @Tags loging
  381. // @Summary 获取统计电脑数量
  382. // @Security ApiKeyAuth
  383. // @accept application/json
  384. // @Produce application/json
  385. // @Success 200 {object} response.Response{data=interface{}} "获取统计电脑数量"
  386. // @Router /loging/test [post]
  387. func (s *ApiLoging) ComputerTest(c *gin.Context) {
  388. var paramsInfo request.OnlineComputerRequest
  389. _ = c.ShouldBindJSON(&paramsInfo)
  390. ServiceStatisticsLog.RegularCheckPc()
  391. response.OkWithDetailed("b", "上报成功", c)
  392. }
  393. // @Tags loging
  394. // @Summary 导出Excel
  395. // @Security ApiKeyAuth
  396. // @accept application/json
  397. // @Produce application/octet-stream
  398. // @Param data body request.GetStatisticsComputerRequest true "导出Excel文件信息"
  399. // @Success 200
  400. // @Router /loging/exportExcel [post]
  401. func (e *ApiLoging) ExportExcel(c *gin.Context) {
  402. var excelInfo request.ExcelInfo
  403. _ = c.ShouldBindJSON(&excelInfo)
  404. paramsInfo := excelInfo.InfoList
  405. paramsInfo.PageSize = 300
  406. paramsInfo.Page = 1
  407. list, _, err := ServiceStatisticsLog.OnlineComputerStatistics(c, paramsInfo.LogComputer, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
  408. if err != nil {
  409. global.GVA_LOG.Error("获取电脑数据失败!", zap.Error(err))
  410. response.FailWithMessage("获取电脑数据失败", c)
  411. return
  412. }
  413. filePath := global.GVA_CONFIG.Excel.Dir + excelInfo.FileName
  414. err = ServiceStatisticsLog.ParseInfoList2Excel(list, filePath)
  415. if err != nil {
  416. global.GVA_LOG.Error("转换Excel失败!", zap.Error(err))
  417. response.FailWithMessage("转换Excel失败", c)
  418. return
  419. }
  420. c.Writer.Header().Add("success", "true")
  421. c.File(filePath)
  422. }
  423. // @Tags loging
  424. // @Summary 修改租机使用备注信息
  425. // @Security ApiKeyAuth
  426. // @accept application/json
  427. // @Produce application/json
  428. // @Param data body log2.ComputerUseRemarks true "id, 租机编号, 使用者, 租机供应商"
  429. // @Success 200 {object} response.Response{msg=string} "修改租机使用备注信息"
  430. // @Router /computer/updatePcRemarks [post]
  431. func (s *ApiLoging) UpdatePcRemarks(c *gin.Context) {
  432. var paramsInfo log2.ComputerUseRemarks
  433. _ = c.ShouldBindJSON(&paramsInfo)
  434. if err := utils.Verify(paramsInfo, utils.PcVerify); err != nil {
  435. response.FailWithMessage(err.Error(), c)
  436. return
  437. }
  438. if paramsInfo.PcCode == "" || paramsInfo.CreateDate == "" {
  439. response.FailWithMessage("有必要的参数未添加", c)
  440. return
  441. }
  442. if err := ServiceStatisticsLog.UpdateComputerUseLog(paramsInfo); err != nil {
  443. global.GVA_LOG.Error("修改失败!", zap.Error(err))
  444. response.FailWithMessage(err.Error(), c)
  445. } else {
  446. response.OkWithMessage("修改成功", c)
  447. }
  448. }
  449. // @Tags loging
  450. // @Summary 上报扫码订单信息
  451. // @Security ApiKeyAuth
  452. // @accept application/json
  453. // @Produce application/json
  454. // @Param data body request.GetCardListRequest true "扫码订单列表"
  455. // @Success 200 {object} response.Response{data=response.GetGameTaskListReply,msg=string} "分页游戏任务列表,返回包括列表,总数,页码,每页数量"
  456. // @Router /loging/getLogScanningList [post]
  457. func (s *ApiLoging) GetLogScanningList(c *gin.Context) {
  458. var paramsInfo request.GetLogScanningCodeRequest
  459. _ = c.ShouldBindJSON(&paramsInfo)
  460. if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
  461. response.FailWithMessage(err.Error(), c)
  462. return
  463. }
  464. if list, total, err := ServiceStatisticsLog.GetScanningInfoList(paramsInfo.LogScanningRequest, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc); err != nil {
  465. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  466. response.FailWithMessage("获取失败"+err.Error(), c)
  467. } else {
  468. response.OkWithDetailed(response.PageResult{
  469. List: list,
  470. Total: total,
  471. Page: paramsInfo.Page,
  472. PageSize: paramsInfo.PageSize,
  473. }, "获取成功", c)
  474. }
  475. }
  476. // @Tags loging
  477. // @Summary 导出Excel
  478. // @Security ApiKeyAuth
  479. // @accept application/json
  480. // @Produce application/octet-stream
  481. // @Param data body request.GetStatisticsComputerRequest true "导出Excel文件信息"
  482. // @Success 200
  483. // @Router /loging/computerRateExport [post]
  484. func (e *ApiLoging) ComputerRateExport(c *gin.Context) {
  485. var excelInfo request.ExcelInfo
  486. _ = c.ShouldBindJSON(&excelInfo)
  487. paramsInfo := excelInfo.InfoList
  488. paramsInfo.PageSize = 300
  489. paramsInfo.Page = 1
  490. list, _, err := ServiceStatisticsLog.ComputerStatistics(c, paramsInfo.LogComputer, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
  491. if err != nil {
  492. global.GVA_LOG.Error("获取电脑数据失败!", zap.Error(err))
  493. response.FailWithMessage("获取电脑数据失败", c)
  494. return
  495. }
  496. filePath := global.GVA_CONFIG.Excel.Dir + excelInfo.FileName
  497. err = ServiceStatisticsLog.ComputeRateList2Excel(list, filePath)
  498. if err != nil {
  499. global.GVA_LOG.Error("转换Excel失败!", zap.Error(err))
  500. response.FailWithMessage("转换Excel失败", c)
  501. return
  502. }
  503. c.Writer.Header().Add("success", "true")
  504. c.File(filePath)
  505. }
  506. // @Tags loging
  507. // @Summary 七天電腦效率
  508. // @Security ApiKeyAuth
  509. // @accept application/json
  510. // @Produce application/octet-stream
  511. // @Param data body request.GetStatisticsComputerRequest true "导出Excel文件信息"
  512. // @Success 200
  513. // @Router /loging/computerSevenRate [post]
  514. func (e *ApiLoging) ComputerSevenRate(c *gin.Context) {
  515. var paramsInfo request.GetStatisticsComputerRequest
  516. _ = c.ShouldBindJSON(&paramsInfo)
  517. paramsInfo.PageSize = 300
  518. paramsInfo.Page = 1
  519. list, _, err := ServiceStatisticsLog.ComputerSevenStatistics(c, paramsInfo.LogComputer, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
  520. if err != nil {
  521. global.GVA_LOG.Error("获取失败!", zap.Error(err))
  522. response.FailWithMessage("获取失败", c)
  523. } else {
  524. response.OkWithDetailed(response.PageResult{
  525. List: list,
  526. Total: 1,
  527. Page: paramsInfo.Page,
  528. PageSize: paramsInfo.PageSize,
  529. }, "获取成功", c)
  530. }
  531. }