Просмотр исходного кода

Merge branch 'master' of http://git.izouma.com/xiongzhu/raex_back into dev

sunkean 3 лет назад
Родитель
Сommit
09446985c8

+ 8 - 0
src/main/java/com/izouma/nineth/config/MetaConstants.java

@@ -0,0 +1,8 @@
+package com.izouma.nineth.config;
+
+import java.util.List;
+
+public interface MetaConstants {
+
+    List<Long> GAME_COPY_IDS = List.of(2822644L, 8746067L, 8734418L, 8734417L);
+}

+ 1 - 1
src/main/java/com/izouma/nineth/domain/MetaTaskToUser.java

@@ -20,7 +20,7 @@ import java.time.LocalDateTime;
 @NoArgsConstructor
 @Entity
 @ApiModel("元宇宙玩家领取任务情况")
-public class MetaTaskToUser extends BaseEntity{
+public class MetaTaskToUser extends BaseEntity {
 
     @ApiModelProperty("用户id")
     @Searchable

+ 28 - 0
src/main/java/com/izouma/nineth/domain/MetaZombieFinishRecord.java

@@ -0,0 +1,28 @@
+package com.izouma.nineth.domain;
+
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Entity;
+import javax.persistence.Transient;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@ApiModel("僵尸游戏完成记录")
+public class MetaZombieFinishRecord extends BaseEntity {
+
+    private Long userId;
+
+    @Transient
+    private boolean finish;
+
+    @Transient
+    private boolean send;
+
+    @Transient
+    private int point;
+}

+ 49 - 0
src/main/java/com/izouma/nineth/domain/Snapshot.java

@@ -0,0 +1,49 @@
+package com.izouma.nineth.domain;
+
+import com.alibaba.excel.annotation.ExcelIgnore;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.izouma.nineth.enums.OperationSource;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.*;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@ApiModel("元宇宙快照")
+public class Snapshot extends BaseEntity {
+
+    @ApiModelProperty("快照名称")
+    @ExcelIgnore
+    private String name;
+
+    @ApiModelProperty("作用")
+    @ExcelIgnore
+    private String rule;
+
+    @ApiModelProperty("场景")
+    @ExcelIgnore
+    @Enumerated(EnumType.STRING)
+    private OperationSource source;
+
+    @ExcelProperty("用户id")
+    @Transient
+    private Long userId;
+
+    @ExcelProperty("用户名称")
+    @Transient
+    private String nickName;
+
+    @ExcelProperty("用户手机号")
+    @Transient
+    private String phone;
+
+    @ExcelProperty("持有数量")
+    @Transient
+    private Long countNum;
+}

+ 29 - 0
src/main/java/com/izouma/nineth/dto/SnapshotDTO.java

@@ -0,0 +1,29 @@
+package com.izouma.nineth.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("元宇宙快照")
+public class SnapshotDTO {
+
+    @ExcelProperty("用户id")
+    private String userId;
+
+    @ExcelProperty("用户名称")
+    private String nickName;
+
+    @ExcelProperty("用户手机号")
+    private String phone;
+
+    @ExcelProperty("持有数量")
+    private String countNum;
+}

+ 18 - 0
src/main/java/com/izouma/nineth/repo/MetaGameProcessRepo.java

@@ -5,6 +5,10 @@ import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Query;
 
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Map;
+
 public interface MetaGameProcessRepo extends JpaRepository<MetaGameProcess, Long>, JpaSpecificationExecutor<MetaGameProcess> {
 
     @Query(value = "select * from meta_game_process m where m.user_id = ?1 and m.meta_game_copy_id = ?2 order by m.created_at desc limit 1", nativeQuery = true)
@@ -12,4 +16,18 @@ public interface MetaGameProcessRepo extends JpaRepository<MetaGameProcess, Long
 
     @Query(value = "select * from meta_game_process m where m.user_id = ?1 and m.completed = true order by m.point desc limit 1", nativeQuery = true)
     MetaGameProcess findTopPoint(Long userId);
+
+    @Query(value = "select sum(m.point) from MetaGameProcess m where m.userId = ?1 and m.metaGameCopyId in ?2 and m.del = false")
+    Long sumPoint(Long userId, List<Long> metaGameCopyIds);
+
+    @Query(value = " SELECT m.userId as userId," +
+            "u.nickname as nickName," +
+            "u.phone as phone FROM" +
+            "( SELECT user_id userId, sum( point ) point FROM meta_game_process WHERE meta_game_copy_id IN ?2 AND created_at <= ?3 GROUP BY user_id ) m LEFT JOIN USER u ON m.userId = u.id WHERE m.point > ?1 " +
+            "AND m.userId NOT IN ( SELECT m.userId userId " +
+            "FROM" +
+            "( SELECT user_id userId, sum( point ) point FROM meta_game_process WHERE meta_game_copy_id IN ?2 AND created_at <= ?4 GROUP BY user_id ) m LEFT JOIN USER u ON m.userId = u.id " +
+            "WHERE m.point > ?1 )"
+            , nativeQuery = true)
+    List<Map<String, Object>> snapshot(int point, List<Long> metaGameCopyIds, LocalDateTime createdAt, LocalDateTime lastCreatedAt);
 }

+ 4 - 0
src/main/java/com/izouma/nineth/repo/MetaSwitchRepo.java

@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 
 import javax.transaction.Transactional;
+import java.util.List;
 
 public interface MetaSwitchRepo extends JpaRepository<MetaSwitch, Long>, JpaSpecificationExecutor<MetaSwitch> {
     @Query("update MetaSwitch t set t.del = true where t.id = ?1")
@@ -20,4 +21,7 @@ public interface MetaSwitchRepo extends JpaRepository<MetaSwitch, Long>, JpaSpec
     @Modifying
     @Transactional
     void updateStatus(Long id, boolean status);
+
+    List<MetaSwitch> findByDel(boolean del);
+
 }

+ 11 - 0
src/main/java/com/izouma/nineth/repo/MetaZombieFinishRecordRepo.java

@@ -0,0 +1,11 @@
+package com.izouma.nineth.repo;
+
+import com.izouma.nineth.domain.MetaZombieFinishRecord;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+
+public interface MetaZombieFinishRecordRepo extends JpaRepository<MetaZombieFinishRecord, Long>, JpaSpecificationExecutor<MetaZombieFinishRecord> {
+    MetaZombieFinishRecord findByUserIdAndDel(Long userId, boolean del);
+
+}

+ 9 - 0
src/main/java/com/izouma/nineth/repo/SnapshotRepo.java

@@ -0,0 +1,9 @@
+package com.izouma.nineth.repo;
+
+import com.izouma.nineth.domain.Snapshot;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface SnapshotRepo extends JpaRepository<Snapshot, Long>, JpaSpecificationExecutor<Snapshot> {
+
+}

+ 20 - 0
src/main/java/com/izouma/nineth/service/SnapshotService.java

@@ -0,0 +1,20 @@
+package com.izouma.nineth.service;
+
+import com.izouma.nineth.domain.Snapshot;
+import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.repo.SnapshotRepo;
+import com.izouma.nineth.utils.JpaUtils;
+import lombok.AllArgsConstructor;
+import org.springframework.data.domain.Page;
+import org.springframework.stereotype.Service;
+
+@Service
+@AllArgsConstructor
+public class SnapshotService {
+
+    private SnapshotRepo snapshotRepo;
+
+    public Page<Snapshot> all(PageQuery pageQuery) {
+        return snapshotRepo.findAll(JpaUtils.toSpecification(pageQuery, Snapshot.class), JpaUtils.toPageRequest(pageQuery));
+    }
+}

+ 31 - 4
src/main/java/com/izouma/nineth/web/MetaGameCopyController.java

@@ -1,9 +1,6 @@
 package com.izouma.nineth.web;
 
-import com.izouma.nineth.domain.Asset;
-import com.izouma.nineth.domain.MetaGameCopy;
-import com.izouma.nineth.domain.MetaGameProcess;
-import com.izouma.nineth.domain.MetaZombie;
+import com.izouma.nineth.domain.*;
 import com.izouma.nineth.dto.CommonMatchDTO;
 import com.izouma.nineth.dto.MetaRestResult;
 import com.izouma.nineth.dto.PageQuery;
@@ -12,9 +9,11 @@ import com.izouma.nineth.enums.MetaGame;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.MetaGameCopyRepo;
 import com.izouma.nineth.repo.MetaGameProcessRepo;
+import com.izouma.nineth.repo.MetaZombieFinishRecordRepo;
 import com.izouma.nineth.repo.MetaZombieRepo;
 import com.izouma.nineth.service.AssetService;
 import com.izouma.nineth.service.MetaGameCopyService;
+import com.izouma.nineth.service.SysConfigService;
 import com.izouma.nineth.utils.ObjUtils;
 import com.izouma.nineth.utils.SecurityUtils;
 import com.izouma.nineth.utils.excel.ExcelUtils;
@@ -45,6 +44,10 @@ public class MetaGameCopyController extends BaseController {
 
     private AssetService assetService;
 
+    private SysConfigService sysConfigService;
+
+    private MetaZombieFinishRecordRepo metaZombieFinishRecordRepo;
+
     //@PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     public MetaGameCopy save(@RequestBody MetaGameCopy record) {
@@ -150,6 +153,30 @@ public class MetaGameCopyController extends BaseController {
         return MetaRestResult.returnSuccess(metaGameProcess.getPoint());
     }
 
+    @GetMapping("/sumPoint")
+    public MetaRestResult<MetaZombieFinishRecord> sumPoint() {
+        Long userId = SecurityUtils.getAuthenticatedUser().getId();
+        Long sum = metaGameProcessRepo.sumPoint(userId, List.of(8746067L, 8734418L, 8734417L));
+        if (Objects.isNull(sum)) {
+            return MetaRestResult.returnSuccess(new MetaZombieFinishRecord(userId, false, false, 0));
+        }
+        int sumPoint = sum.intValue();
+        int point = sysConfigService.getInt("zombie_point");
+        if (sumPoint < point) {
+            return MetaRestResult.returnSuccess(new MetaZombieFinishRecord(userId, false, false, sumPoint));
+        }
+        MetaZombieFinishRecord metaZombieFinishRecord = metaZombieFinishRecordRepo.findByUserIdAndDel(userId, false);
+        if (Objects.isNull(metaZombieFinishRecord)) {
+            metaZombieFinishRecord = new MetaZombieFinishRecord(userId, true, false, sumPoint);
+            metaZombieFinishRecordRepo.save(metaZombieFinishRecord);
+            return MetaRestResult.returnSuccess(metaZombieFinishRecord);
+        }
+        metaZombieFinishRecord.setFinish(true);
+        metaZombieFinishRecord.setSend(true);
+        metaZombieFinishRecord.setPoint(sumPoint);
+        return MetaRestResult.returnSuccess(metaZombieFinishRecord);
+    }
+
     @GetMapping("/queryAsset")
     public MetaRestResult<Page<Asset>> queryAsset(@RequestParam Long id, @RequestParam(defaultValue = "1") Long companyId, Pageable pageable) {
         MetaGameCopy metaGameCopy = metaGameCopyRepo.findByIdAndDelAndPublish(id, false, true);

+ 6 - 0
src/main/java/com/izouma/nineth/web/MetaSwitchController.java

@@ -1,6 +1,7 @@
 package com.izouma.nineth.web;
 
 import com.izouma.nineth.domain.MetaSwitch;
+import com.izouma.nineth.dto.MetaRestResult;
 import com.izouma.nineth.dto.PageQuery;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.MetaSwitchRepo;
@@ -66,5 +67,10 @@ public class MetaSwitchController extends BaseController {
         List<MetaSwitch> data = all(pageQuery).getContent();
         ExcelUtils.export(response, data);
     }
+
+    @GetMapping("/metaQuery")
+    public MetaRestResult<List<MetaSwitch>> metaQuery() {
+        return MetaRestResult.returnSuccess(metaSwitchRepo.findByDel(false));
+    }
 }
 

+ 68 - 0
src/main/java/com/izouma/nineth/web/SnapshotController.java

@@ -0,0 +1,68 @@
+package com.izouma.nineth.web;
+
+import com.alibaba.fastjson.JSONArray;
+import com.izouma.nineth.config.MetaConstants;
+import com.izouma.nineth.domain.Snapshot;
+import com.izouma.nineth.dto.PageQuery;
+import com.izouma.nineth.exception.BusinessException;
+import com.izouma.nineth.repo.MetaGameProcessRepo;
+import com.izouma.nineth.repo.SnapshotRepo;
+import com.izouma.nineth.service.SnapshotService;
+import com.izouma.nineth.service.SysConfigService;
+import com.izouma.nineth.utils.excel.ExcelUtils;
+import lombok.AllArgsConstructor;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.data.domain.Page;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/snapshot")
+@AllArgsConstructor
+public class SnapshotController extends BaseController {
+    private SnapshotService snapshotService;
+    private SnapshotRepo snapshotRepo;
+
+    private MetaGameProcessRepo metaGameProcessRepo;
+
+    private SysConfigService sysConfigService;
+
+    //@PreAuthorize("hasRole('ADMIN')")
+    @PostMapping("/all")
+    public Page<Snapshot> all(@RequestBody PageQuery pageQuery) {
+        return snapshotService.all(pageQuery);
+    }
+
+    @GetMapping("/get/{id}")
+    public Snapshot get(@PathVariable Long id) {
+        return snapshotRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+    }
+
+    @GetMapping("/snapshot")
+    @ResponseBody
+    public void snapshot(HttpServletResponse response, Long id, String sqlParams) throws IOException {
+        if (1L == id) {
+            int point = sysConfigService.getInt("zombie_point");
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            LocalDateTime endTime = LocalDate.parse(sqlParams, formatter).atTime(LocalTime.MAX);
+            LocalDateTime lastEndTime = endTime.plusDays(-1);
+            List<Map<String, Object>> map = metaGameProcessRepo.snapshot(point, MetaConstants.GAME_COPY_IDS, endTime, lastEndTime);
+            if (CollectionUtils.isEmpty(map)) {
+                throw new BusinessException("无数据");
+            }
+            JSONArray jsonArray = new JSONArray();
+            jsonArray.addAll(map);
+            List<Snapshot> snapshot = jsonArray.toJavaList(Snapshot.class);
+            ExcelUtils.export(response, snapshot);
+        }
+    }
+}
+

+ 1 - 0
src/main/resources/genjson/Snapshot.json

@@ -0,0 +1 @@
+{"tableName":"Snapshot","className":"Snapshot","remark":"快照管理","genTable":true,"genClass":true,"genList":true,"genForm":true,"genRouter":true,"javaPath":"/Users/xiaohuoban/IdeaProjects/raex_back/src/main/java/com/izouma/nineth","viewPath":"/Users/xiaohuoban/IdeaProjects/raex_back/src/main/vue/src/views","routerPath":"/Users/xiaohuoban/IdeaProjects/raex_back/src/main/vue/src","resourcesPath":"/Users/xiaohuoban/IdeaProjects/raex_back/src/main/resources","dataBaseType":"Mysql","fields":[{"name":"name","modelName":"name","remark":"名称","showInList":true,"showInForm":true,"formType":"singleLineText","required":true},{"name":"rule","modelName":"rule","remark":"作用","showInList":true,"showInForm":true,"formType":"textarea","required":true},{"name":"source","modelName":"source","remark":"操作来源","showInList":true,"showInForm":true,"formType":"select","required":true,"apiFlag":"1","optionsValue":"[{\"label\":\"元宇宙\",\"value\":\"META\"},{\"label\":\"绿洲\",\"value\":\"RAEX\"}]"}],"readTable":false,"dataSourceCode":"dataSource","genJson":"","subtables":[],"update":false,"basePackage":"com.izouma.nineth","tablePackage":"com.izouma.nineth.domain.Snapshot"}

+ 17 - 1
src/main/vue/src/router.js

@@ -1628,7 +1628,23 @@ const router = new Router({
                     meta: {
                         title: '元宇宙开关配置',
                     },
-                }
+                },
+                {
+                    path: '/snapshotEdit',
+                    name: 'SnapshotEdit',
+                    component: () => import(/* webpackChunkName: "snapshotEdit" */ '@/views/SnapshotEdit.vue'),
+                    meta: {
+                       title: '快照管理查看',
+                    },
+                },
+                {
+                    path: '/snapshotList',
+                    name: 'SnapshotList',
+                    component: () => import(/* webpackChunkName: "snapshotList" */ '@/views/SnapshotList.vue'),
+                    meta: {
+                       title: '快照管理',
+                    },
+               }
                 /**INSERT_LOCATION**/
             ]
         },

+ 68 - 10
src/main/vue/src/views/MetaEmailList.vue

@@ -47,17 +47,19 @@
 			<el-table-column prop="title" align="center" label="邮件标题" width="200"> </el-table-column>
 			<el-table-column prop="author" align="center" label="邮件作者" width="100"> </el-table-column>
 			<el-table-column prop="description" align="center" label="邮件内容"> </el-table-column>
-            <el-table-column prop="publish" align="center" label="是否发布" width="80">
-                <template slot-scope="{ row }">
-                    <el-tag :type="row.publish ? '' : 'info'"> {{ row.publish }} </el-tag>
-                </template>
-            </el-table-column>
+			<el-table-column prop="publish" align="center" label="是否发布" width="80">
+				<template slot-scope="{ row }">
+					<el-tag :type="row.publish ? '' : 'info'"> {{ row.publish }} </el-tag>
+				</template>
+			</el-table-column>
 			<el-table-column label="操作" align="center" fixed="right" width="300">
 				<template slot-scope="{ row }">
-					<el-button @click="publish(row)" type="primary" size="mini" plain v-if="row && !row.publish"> 发布 </el-button>
+					<el-button @click="publish(row)" type="primary" size="mini" plain v-if="row && !row.publish">
+						发布
+					</el-button>
 					<el-button @click="editRow(row)" type="primary" size="mini" plain v-if="row && !row.publish">
 						编辑
-					</el-button>					
+					</el-button>
 					<el-button @click="deleteRow(row)" type="danger" size="mini" plain v-if="row && !row.publish">
 						删除
 					</el-button>
@@ -88,12 +90,23 @@ export default {
 	mixins: [pageableTable],
 	data() {
 		return {
+			timer: null,
+			websock: null,
 			multipleMode: false,
 			search: '',
 			url: '/metaEmail/all',
 			downloading: false
 		};
 	},
+	created() {
+		// 初始化websocket
+		this.initWebSocket();
+	},
+	destroyed() {
+		window.clearInterval(this.timer);
+		//离开路由之后断开websocket连接
+		this.websock.close();
+	},
 	computed: {
 		selection() {
 			return this.$refs.table.selection.map(i => i.id);
@@ -165,19 +178,64 @@ export default {
 				});
 		},
 		publish(row) {
+			if (!this.websock.readyState === 1) {
+				this.$message.error('当前socket连接异常,请刷新页面重试!');
+				return;
+			}
 			this.$alert('邮件发布之后不能编辑和删除,请确定是否发布邮件!', '提示', { type: 'info' })
 				.then(() => {
-					return this.$http.post(`/metaEmail/${row.id}/publish`);
+					this.$http.post(`/metaEmail/${row.id}/publish`);
+					this.websocketsend(JSON.stringify({ type: 'META_WEBSOCKET_NOTICE_EMAIL_NOTICE' }));
+					return;
 				})
 				.then(() => {
-					this.$message.success('发布成功');
-					this.getData();
+					setTimeout(() => {
+						this.$message.success('发布成功');
+						this.getData();
+					}, 1000);
 				})
 				.catch(e => {
 					if (e !== 'cancel') {
 						this.$message.error(e.error);
 					}
 				});
+		},
+		initWebSocket() {
+			let wsuri = 'ws://127.0.0.1:8088/websocket/' + this.$store.state.userInfo.id;
+			if (location.host === 'raex.vip') {
+				wsuri = 'wss://mmo.raex.vip/websocket/' + this.$store.state.userInfo.id;
+			}
+			if (location.host === 'test.raex.vip') {
+				wsuri = 'wss://test.mmo.raex.vip/websocket/' + this.$store.state.userInfo.id;
+			}
+			console.log('初始化websocket:' + wsuri);
+			this.websock = new WebSocket(wsuri);
+			this.websock.onmessage = this.websocketonmessage;
+			this.websock.onopen = this.websocketonopen;
+			this.websock.onerror = this.websocketonerror;
+			this.websock.onclose = this.websocketclose;
+		},
+		websocketonopen() {
+			this.websocketsend('META_PING');
+			this.timer = window.setInterval(() => {
+				setTimeout(() => {
+					this.websocketsend('META_PING');
+				}, 0);
+			}, 10000);
+		},
+		websocketonerror() {
+			console.log('socket连接异常');
+			this.initWebSocket();
+		},
+		websocketonmessage(e) {
+			console.log('socket接收数据:' + e.data);
+		},
+		websocketsend(Data) {
+			console.log('socket发送数据:' + Data);
+			this.websock.send(Data);
+		},
+		websocketclose(e) {
+			console.log('socket断开连接:', e);
 		}
 	}
 };

+ 251 - 243
src/main/vue/src/views/MetaSwitchList.vue

@@ -1,253 +1,261 @@
 <template>
-    <div class="list-view">
-        <page-title>
-            <el-button
-                @click="addRow"
-                type="primary"
-                icon="el-icon-plus"
-                :disabled="fetchingData || downloading"
-                class="filter-item"
-            >
-                新增
-            </el-button>
-            <el-button
-                @click="download"
-                icon="el-icon-upload2"
-                :loading="downloading"
-                :disabled="fetchingData"
-                class="filter-item"
-            >
-                导出
-            </el-button>
-        </page-title>
-        <div class="filters-container">
-            <el-input
-                placeholder="搜索..."
-                v-model="search"
-                clearable
-                class="filter-item search"
-                @keyup.enter.native="getData"
-            >
-                <el-button @click="getData" slot="append" icon="el-icon-search"> </el-button>
-            </el-input>
-        </div>
-        <el-table
-            :data="tableData"
-            row-key="id"
-            ref="table"
-            header-row-class-name="table-header-row"
-            header-cell-class-name="table-header-cell"
-            row-class-name="table-row"
-            cell-class-name="table-cell"
-            :height="tableHeight"
-            v-loading="fetchingData"
-        >
-            <el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
-            <el-table-column prop="id" align="center" label="ID" width="100"> </el-table-column>
-            <el-table-column prop="name" align="center" label="名称" width="250"> </el-table-column>
-            <el-table-column prop="description" align="center" label="描述"> </el-table-column>
-            <el-table-column prop="status" align="center" label="状态" width="100">
-                <template v-slot="{ row }">
-                    <template>
-                        {{ row.status ? '开' : '关' }}
-                    </template>
-                </template>
-            </el-table-column>
-            <el-table-column label="操作" align="center" fixed="right" width="300">
-                <template slot-scope="{ row }">
-                    <el-button @click="editRow(row)" type="primary" size="mini" plain> 编辑 </el-button>
-                    <el-button @click="deleteRow(row)" type="danger" size="mini" plain> 删除 </el-button>
-                    <el-button
-                        @click="updateStatus(row, true)"
-                        type="primary"
-                        size="mini"
-                        plain
-                        v-if="row && !row.status"
-                    >
-                        
-                    </el-button>
-                    <el-button
-                        @click="updateStatus(row, false)"
-                        type="danger"
-                        size="mini"
-                        plain
-                        v-if="row && row.status"
-                    >
-                        
-                    </el-button>
-                </template>
-            </el-table-column>
-        </el-table>
-        <div class="pagination-wrapper">
-            <el-pagination
-                background
-                @size-change="onSizeChange"
-                @current-change="onCurrentChange"
-                :current-page="page"
-                :page-sizes="[10, 20, 30, 40, 50]"
-                :page-size="pageSize"
-                layout="total, sizes, prev, pager, next, jumper"
-                :total="totalElements"
-            >
-            </el-pagination>
-        </div>
-    </div>
+	<div class="list-view">
+		<page-title>
+			<el-button
+				@click="addRow"
+				type="primary"
+				icon="el-icon-plus"
+				:disabled="fetchingData || downloading"
+				class="filter-item"
+			>
+				新增
+			</el-button>
+			<el-button
+				@click="download"
+				icon="el-icon-upload2"
+				:loading="downloading"
+				:disabled="fetchingData"
+				class="filter-item"
+			>
+				导出
+			</el-button>
+		</page-title>
+		<div class="filters-container">
+			<el-input
+				placeholder="搜索..."
+				v-model="search"
+				clearable
+				class="filter-item search"
+				@keyup.enter.native="getData"
+			>
+				<el-button @click="getData" slot="append" icon="el-icon-search"> </el-button>
+			</el-input>
+		</div>
+		<el-table
+			:data="tableData"
+			row-key="id"
+			ref="table"
+			header-row-class-name="table-header-row"
+			header-cell-class-name="table-header-cell"
+			row-class-name="table-row"
+			cell-class-name="table-cell"
+			:height="tableHeight"
+			v-loading="fetchingData"
+		>
+			<el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
+			<el-table-column prop="id" align="center" label="ID" width="100"> </el-table-column>
+			<el-table-column prop="name" align="center" label="名称" width="250"> </el-table-column>
+			<el-table-column prop="description" align="center" label="描述"> </el-table-column>
+			<el-table-column prop="status" align="center" label="状态" width="100">
+				<template v-slot="{ row }">
+					<template>
+						{{ row.status ? '开' : '关' }}
+					</template>
+				</template>
+			</el-table-column>
+			<el-table-column label="操作" align="center" fixed="right" width="300">
+				<template slot-scope="{ row }">
+					<el-button @click="editRow(row)" type="primary" size="mini" plain> 编辑 </el-button>
+					<el-button @click="deleteRow(row)" type="danger" size="mini" plain> 删除 </el-button>
+					<el-button
+						@click="updateStatus(row, true)"
+						type="primary"
+						size="mini"
+						plain
+						v-if="row && !row.status"
+					>
+						
+					</el-button>
+					<el-button
+						@click="updateStatus(row, false)"
+						type="danger"
+						size="mini"
+						plain
+						v-if="row && row.status"
+					>
+						
+					</el-button>
+				</template>
+			</el-table-column>
+		</el-table>
+		<div class="pagination-wrapper">
+			<el-pagination
+				background
+				@size-change="onSizeChange"
+				@current-change="onCurrentChange"
+				:current-page="page"
+				:page-sizes="[10, 20, 30, 40, 50]"
+				:page-size="pageSize"
+				layout="total, sizes, prev, pager, next, jumper"
+				:total="totalElements"
+			>
+			</el-pagination>
+		</div>
+	</div>
 </template>
 <script>
 import { mapState } from 'vuex';
 import pageableTable from '@/mixins/pageableTable';
 
 export default {
-    name: 'MetaSwitchList',
-    mixins: [pageableTable],
-    data() {
-        return {
-            timer: null,
-            websock: null,
-            multipleMode: false,
-            search: '',
-            url: '/metaSwitch/all',
-            downloading: false
-        };
-    },
-    created() {
-        this.initWebSocket();
-    },
-    destroyed() {
-        window.clearInterval(this.timer);
-        this.websock.close(); //离开路由之后断开websocket连接
-    },
-    computed: {
-        selection() {
-            return this.$refs.table.selection.map(i => i.id);
-        }
-    },
-    methods: {
-        beforeGetData() {
-            return { search: this.search, query: { del: false } };
-        },
-        toggleMultipleMode(multipleMode) {
-            this.multipleMode = multipleMode;
-            if (!multipleMode) {
-                this.$refs.table.clearSelection();
-            }
-        },
-        addRow() {
-            this.$router.push({
-                path: '/metaSwitchEdit',
-                query: {
-                    ...this.$route.query
-                }
-            });
-        },
-        editRow(row) {
-            this.$router.push({
-                path: '/metaSwitchEdit',
-                query: {
-                    id: row.id
-                }
-            });
-        },
-        download() {
-            this.downloading = true;
-            this.$axios
-                .get('/metaSwitch/excel', {
-                    responseType: 'blob',
-                    params: { size: 10000 }
-                })
-                .then(res => {
-                    console.log(res);
-                    this.downloading = false;
-                    const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
-                    const link = document.createElement('a');
-                    link.href = downloadUrl;
-                    link.setAttribute('download', res.headers['content-disposition'].split('filename=')[1]);
-                    document.body.appendChild(link);
-                    link.click();
-                    link.remove();
-                })
-                .catch(e => {
-                    console.log(e);
-                    this.downloading = false;
-                    this.$message.error(e.error);
-                });
-        },
-        deleteRow(row) {
-            this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
-                .then(() => {
-                    return this.$http.post(`/metaSwitch/del/${row.id}`);
-                })
-                .then(() => {
-                    this.$message.success('删除成功');
-                    this.getData();
-                })
-                .catch(e => {
-                    if (e !== 'cancel') {
-                        this.$message.error(e.error);
-                    }
-                });
-        },
-        updateStatus(row, status) {
-            this.$alert(status ? '确定要打开此开关吗?' : '确定要关闭此开关吗?', status ? '提示' : '警告', {
-                type: status ? 'info' : 'error'
-            })
-                .then(() => {
-                    this.$http.post(`/metaSwitch/updateStatus/${row.id}/${status}`);
-                    this.websocketsend(
-                        status
-                            ? JSON.stringify({ type: row.name + '_OPEN' })
-                            : JSON.stringify({ type: row.name + '_CLOSE' })
-                    );
-                    return;
-                })
-                .then(() => {
-                    this.$message.success('操作成功');
-                    this.getData();
-                })
-                .catch(e => {
-                    if (e !== 'cancel') {
-                        this.$message.error(e.error);
-                    }
-                });
-        },
-        initWebSocket() {
-            let wsuri = 'ws://127.0.0.1:8088/websocket/1';
-            if (location.host === 'raex.vip') {
-                wsuri = 'wss://mmo.raex.vip/websocket/1';
-            }
-            if (location.host === 'test.raex.vip') {
-                wsuri = 'wss://test.mmo.raex.vip/websocket/1';
-            }
-            console.log('初始化websocket' + wsuri);
-            this.websock = new WebSocket(wsuri);
-            this.websock.onmessage = this.websocketonmessage;
-            this.websock.onopen = this.websocketonopen;
-            this.websock.onerror = this.websocketonerror;
-            this.websock.onclose = this.websocketclose;
-        },
-        websocketonopen() {
-            this.websocketsend('META_PING');
-            this.timer = window.setInterval(() => {
-                setTimeout(() => {
-                    this.websocketsend('META_PING');
-                }, 0);
-            }, 10000);
-        },
-        websocketonerror() {
-            console.log('连接建立失败重连');
-            this.initWebSocket();
-        },
-        websocketonmessage(e) {
-            console.log('数据接收' + e.data);
-        },
-        websocketsend(Data) {
-            console.log('数据发送' + Data);
-            this.websock.send(Data);
-        },
-        websocketclose(e) {
-            console.log('断开连接', e);
-        }
-    }
+	name: 'MetaSwitchList',
+	mixins: [pageableTable],
+	data() {
+		return {
+			timer: null,
+			websock: null,
+			multipleMode: false,
+			search: '',
+			url: '/metaSwitch/all',
+			downloading: false
+		};
+	},
+	created() {
+		// 初始化websocket
+		this.initWebSocket();
+	},
+	destroyed() {
+		window.clearInterval(this.timer);
+		//离开路由之后断开websocket连接
+		this.websock.close();
+	},
+	computed: {
+		selection() {
+			return this.$refs.table.selection.map(i => i.id);
+		}
+	},
+	methods: {
+		beforeGetData() {
+			return { search: this.search, query: { del: false } };
+		},
+		toggleMultipleMode(multipleMode) {
+			this.multipleMode = multipleMode;
+			if (!multipleMode) {
+				this.$refs.table.clearSelection();
+			}
+		},
+		addRow() {
+			this.$router.push({
+				path: '/metaSwitchEdit',
+				query: {
+					...this.$route.query
+				}
+			});
+		},
+		editRow(row) {
+			this.$router.push({
+				path: '/metaSwitchEdit',
+				query: {
+					id: row.id
+				}
+			});
+		},
+		download() {
+			this.downloading = true;
+			this.$axios
+				.get('/metaSwitch/excel', {
+					responseType: 'blob',
+					params: { size: 10000 }
+				})
+				.then(res => {
+					console.log(res);
+					this.downloading = false;
+					const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
+					const link = document.createElement('a');
+					link.href = downloadUrl;
+					link.setAttribute('download', res.headers['content-disposition'].split('filename=')[1]);
+					document.body.appendChild(link);
+					link.click();
+					link.remove();
+				})
+				.catch(e => {
+					console.log(e);
+					this.downloading = false;
+					this.$message.error(e.error);
+				});
+		},
+		deleteRow(row) {
+			this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
+				.then(() => {
+					return this.$http.post(`/metaSwitch/del/${row.id}`);
+				})
+				.then(() => {
+					this.$message.success('删除成功');
+					this.getData();
+				})
+				.catch(e => {
+					if (e !== 'cancel') {
+						this.$message.error(e.error);
+					}
+				});
+		},
+		updateStatus(row, status) {
+			if (!this.websock.readyState === 1) {
+				this.$message.error('当前socket连接异常,请刷新页面重试!');
+				return;
+			}
+			this.$alert(status ? '确定要打开此开关吗?' : '确定要关闭此开关吗?', status ? '提示' : '警告', {
+				type: status ? 'info' : 'error'
+			})
+				.then(() => {
+					this.$http.post(`/metaSwitch/updateStatus/${row.id}/${status}`);
+					this.websocketsend(
+						status
+							? JSON.stringify({ type: row.name + '_OPEN' })
+							: JSON.stringify({ type: row.name + '_CLOSE' })
+					);
+					return;
+				})
+				.then(() => {
+					setTimeout(() => {
+						this.$message.success('操作成功');
+						this.getData();
+					}, 1000);
+				})
+				.catch(e => {
+					if (e !== 'cancel') {
+						this.$message.error(e.error);
+					}
+				});
+		},
+		initWebSocket() {
+			let wsuri = 'ws://127.0.0.1:8088/websocket/' + this.$store.state.userInfo.id;
+			if (location.host === 'raex.vip') {
+				wsuri = 'wss://mmo.raex.vip/websocket/' + this.$store.state.userInfo.id;
+			}
+			if (location.host === 'test.raex.vip') {
+				wsuri = 'wss://test.mmo.raex.vip/websocket/' + this.$store.state.userInfo.id;
+			}
+			console.log('初始化websocket:' + wsuri);
+			this.websock = new WebSocket(wsuri);
+			this.websock.onmessage = this.websocketonmessage;
+			this.websock.onopen = this.websocketonopen;
+			this.websock.onerror = this.websocketonerror;
+			this.websock.onclose = this.websocketclose;
+		},
+		websocketonopen() {
+			this.websocketsend('META_PING');
+			this.timer = window.setInterval(() => {
+				setTimeout(() => {
+					this.websocketsend('META_PING');
+				}, 0);
+			}, 10000);
+		},
+		websocketonerror() {
+			console.log('socket连接异常');
+			this.initWebSocket();
+		},
+		websocketonmessage(e) {
+			console.log('socket接收数据:' + e.data);
+		},
+		websocketsend(Data) {
+			console.log('socket发送数据:' + Data);
+			this.websock.send(Data);
+		},
+		websocketclose(e) {
+			console.log('socket断开连接:', e);
+		}
+	}
 };
 </script>
 <style lang="less" scoped>

+ 229 - 182
src/main/vue/src/views/MetaZouMaLightList.vue

@@ -1,192 +1,239 @@
 <template>
-    <div class="list-view">
-        <page-title>
-            <el-button
-                @click="addRow"
-                type="primary"
-                icon="el-icon-plus"
-                :disabled="fetchingData || downloading"
-                class="filter-item"
-            >
-                新增
-            </el-button>
-            <el-button
-                @click="download"
-                icon="el-icon-upload2"
-                :loading="downloading"
-                :disabled="fetchingData"
-                class="filter-item"
-            >
-                导出
-            </el-button>
-        </page-title>
-        <div class="filters-container">
-            <el-input
-                placeholder="搜索..."
-                v-model="search"
-                clearable
-                class="filter-item search"
-                @keyup.enter.native="getData"
-            >
-                <el-button @click="getData" slot="append" icon="el-icon-search"> </el-button>
-            </el-input>
-        </div>
-        <el-table
-            :data="tableData"
-            row-key="id"
-            ref="table"
-            header-row-class-name="table-header-row"
-            header-cell-class-name="table-header-cell"
-            row-class-name="table-row"
-            cell-class-name="table-cell"
-            :height="tableHeight"
-            v-loading="fetchingData"
-        >
-            <el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
-            <el-table-column prop="id" align="center" label="ID" width="100"> </el-table-column>
-            <el-table-column prop="description" align="center" label="走马灯详情"> </el-table-column>
-            <el-table-column prop="publish" align="center" label="是否发布" width="100">
-                <template slot-scope="{ row }">
-                    <el-tag :type="row.publish ? '' : 'info'"> {{ row.publish }} </el-tag>
-                </template>
-            </el-table-column>
-            <el-table-column label="操作" align="center" fixed="right" width="300">
-                <template slot-scope="{ row }">
-                    <el-button @click="publish(row)" type="primary" size="mini" plain v-if="row && !row.publish">
-                        发布
-                    </el-button>
-                    <el-button @click="editRow(row)" type="primary" size="mini" plain> 编辑 </el-button>
-                    <el-button @click="deleteRow(row)" type="danger" size="mini" plain> 删除 </el-button>
-                </template>
-            </el-table-column>
-        </el-table>
-        <div class="pagination-wrapper">
-            <el-pagination
-                background
-                @size-change="onSizeChange"
-                @current-change="onCurrentChange"
-                :current-page="page"
-                :page-sizes="[10, 20, 30, 40, 50]"
-                :page-size="pageSize"
-                layout="total, sizes, prev, pager, next, jumper"
-                :total="totalElements"
-            >
-            </el-pagination>
-        </div>
-    </div>
+	<div class="list-view">
+		<page-title>
+			<el-button
+				@click="addRow"
+				type="primary"
+				icon="el-icon-plus"
+				:disabled="fetchingData || downloading"
+				class="filter-item"
+			>
+				新增
+			</el-button>
+			<el-button
+				@click="download"
+				icon="el-icon-upload2"
+				:loading="downloading"
+				:disabled="fetchingData"
+				class="filter-item"
+			>
+				导出
+			</el-button>
+		</page-title>
+		<div class="filters-container">
+			<el-input
+				placeholder="搜索..."
+				v-model="search"
+				clearable
+				class="filter-item search"
+				@keyup.enter.native="getData"
+			>
+				<el-button @click="getData" slot="append" icon="el-icon-search"> </el-button>
+			</el-input>
+		</div>
+		<el-table
+			:data="tableData"
+			row-key="id"
+			ref="table"
+			header-row-class-name="table-header-row"
+			header-cell-class-name="table-header-cell"
+			row-class-name="table-row"
+			cell-class-name="table-cell"
+			:height="tableHeight"
+			v-loading="fetchingData"
+		>
+			<el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
+			<el-table-column prop="id" align="center" label="ID" width="100"> </el-table-column>
+			<el-table-column prop="description" align="center" label="走马灯详情"> </el-table-column>
+			<el-table-column prop="publish" align="center" label="是否发布" width="100">
+				<template slot-scope="{ row }">
+					<el-tag :type="row.publish ? '' : 'info'"> {{ row.publish }} </el-tag>
+				</template>
+			</el-table-column>
+			<el-table-column label="操作" align="center" fixed="right" width="300">
+				<template slot-scope="{ row }">
+					<el-button @click="publish(row)" type="primary" size="mini" plain v-if="row && !row.publish">
+						发布
+					</el-button>
+					<el-button @click="editRow(row)" type="primary" size="mini" plain> 编辑 </el-button>
+					<el-button @click="deleteRow(row)" type="danger" size="mini" plain> 删除 </el-button>
+				</template>
+			</el-table-column>
+		</el-table>
+		<div class="pagination-wrapper">
+			<el-pagination
+				background
+				@size-change="onSizeChange"
+				@current-change="onCurrentChange"
+				:current-page="page"
+				:page-sizes="[10, 20, 30, 40, 50]"
+				:page-size="pageSize"
+				layout="total, sizes, prev, pager, next, jumper"
+				:total="totalElements"
+			>
+			</el-pagination>
+		</div>
+	</div>
 </template>
 <script>
 import { mapState } from 'vuex';
 import pageableTable from '@/mixins/pageableTable';
 
 export default {
-    name: 'MetaZouMaLightList',
-    mixins: [pageableTable],
-    data() {
-        return {
-            multipleMode: false,
-            search: '',
-            url: '/metaZouMaLight/all',
-            downloading: false
-        };
-    },
-    computed: {
-        selection() {
-            return this.$refs.table.selection.map(i => i.id);
-        }
-    },
-    methods: {
-        beforeGetData() {
-            return { search: this.search, query: { del: false } };
-        },
-        toggleMultipleMode(multipleMode) {
-            this.multipleMode = multipleMode;
-            if (!multipleMode) {
-                this.$refs.table.clearSelection();
-            }
-        },
-        addRow() {
-            this.$router.push({
-                path: '/metaZouMaLightEdit',
-                query: {
-                    ...this.$route.query
-                }
-            });
-        },
-        editRow(row) {
-            this.$router.push({
-                path: '/metaZouMaLightEdit',
-                query: {
-                    id: row.id
-                }
-            });
-        },
-        download() {
-            this.downloading = true;
-            this.$axios
-                .get('/metaZouMaLight/excel', {
-                    responseType: 'blob',
-                    params: { size: 10000 }
-                })
-                .then(res => {
-                    console.log(res);
-                    this.downloading = false;
-                    const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
-                    const link = document.createElement('a');
-                    link.href = downloadUrl;
-                    link.setAttribute('download', res.headers['content-disposition'].split('filename=')[1]);
-                    document.body.appendChild(link);
-                    link.click();
-                    link.remove();
-                })
-                .catch(e => {
-                    console.log(e);
-                    this.downloading = false;
-                    this.$message.error(e.error);
-                });
-        },
-        operation1() {
-            this.$notify({
-                title: '提示',
-                message: this.selection
-            });
-        },
-        operation2() {
-            this.$message('操作2');
-        },
-        deleteRow(row) {
-            this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
-                .then(() => {
-                    return this.$http.post(`/metaZouMaLight/del/${row.id}`);
-                })
-                .then(() => {
-                    this.$message.success('删除成功');
-                    this.getData();
-                })
-                .catch(e => {
-                    if (e !== 'cancel') {
-                        this.$message.error(e.error);
-                    }
-                });
-        },
-        publish(row) {
-            this.$alert('请确定是否发布!如存在已发布走马灯信息,会将已发布走马灯状态改为未发布。', '提示', {
-                type: 'info'
-            })
-                .then(() => {
-                    return this.$http.post(`/metaZouMaLight/${row.id}/publish`);
-                })
-                .then(() => {
-                    this.$message.success('发布成功');
-                    this.getData();
-                })
-                .catch(e => {
-                    if (e !== 'cancel') {
-                        this.$message.error(e.error);
-                    }
-                });
-        }
-    }
+	name: 'MetaZouMaLightList',
+	mixins: [pageableTable],
+	data() {
+		return {
+			timer: null,
+			websock: null,
+			multipleMode: false,
+			search: '',
+			url: '/metaZouMaLight/all',
+			downloading: false
+		};
+	},
+	created() {
+		// 初始化websocket
+		this.initWebSocket();
+	},
+	destroyed() {
+		window.clearInterval(this.timer);
+		//离开路由之后断开websocket连接
+		this.websock.close();
+	},
+	computed: {
+		selection() {
+			return this.$refs.table.selection.map(i => i.id);
+		}
+	},
+	methods: {
+		beforeGetData() {
+			return { search: this.search, query: { del: false } };
+		},
+		toggleMultipleMode(multipleMode) {
+			this.multipleMode = multipleMode;
+			if (!multipleMode) {
+				this.$refs.table.clearSelection();
+			}
+		},
+		addRow() {
+			this.$router.push({
+				path: '/metaZouMaLightEdit',
+				query: {
+					...this.$route.query
+				}
+			});
+		},
+		editRow(row) {
+			this.$router.push({
+				path: '/metaZouMaLightEdit',
+				query: {
+					id: row.id
+				}
+			});
+		},
+		download() {
+			this.downloading = true;
+			this.$axios
+				.get('/metaZouMaLight/excel', {
+					responseType: 'blob',
+					params: { size: 10000 }
+				})
+				.then(res => {
+					console.log(res);
+					this.downloading = false;
+					const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
+					const link = document.createElement('a');
+					link.href = downloadUrl;
+					link.setAttribute('download', res.headers['content-disposition'].split('filename=')[1]);
+					document.body.appendChild(link);
+					link.click();
+					link.remove();
+				})
+				.catch(e => {
+					console.log(e);
+					this.downloading = false;
+					this.$message.error(e.error);
+				});
+		},
+		deleteRow(row) {
+			this.$alert('删除将无法恢复,确认要删除么?', '警告', { type: 'error' })
+				.then(() => {
+					return this.$http.post(`/metaZouMaLight/del/${row.id}`);
+				})
+				.then(() => {
+					this.$message.success('删除成功');
+					this.getData();
+				})
+				.catch(e => {
+					if (e !== 'cancel') {
+						this.$message.error(e.error);
+					}
+				});
+		},
+		publish(row) {
+			if (!this.websock.readyState === 1) {
+				this.$message.error('当前socket连接异常,请刷新页面重试!');
+				return;
+			}
+			this.$alert('请确定是否发布!如存在已发布走马灯信息,会将已发布走马灯状态改为未发布。', '提示', {
+				type: 'info'
+			})
+				.then(() => {
+					this.$http.post(`/metaZouMaLight/${row.id}/publish`);
+					this.websocketsend(JSON.stringify({ type: 'META_WEBSOCKET_NOTICE_ZOU_MA_LIGHT_NOTICE' }));
+					return;
+				})
+				.then(() => {
+					setTimeout(() => {
+						this.$message.success('发布成功');
+						this.getData();
+					}, 1000);
+				})
+				.catch(e => {
+					if (e !== 'cancel') {
+						this.$message.error(e.error);
+					}
+				});
+		},
+		initWebSocket() {
+			let wsuri = 'ws://127.0.0.1:8088/websocket/' + this.$store.state.userInfo.id;
+			if (location.host === 'raex.vip') {
+				wsuri = 'wss://mmo.raex.vip/websocket/' + this.$store.state.userInfo.id;
+			}
+			if (location.host === 'test.raex.vip') {
+				wsuri = 'wss://test.mmo.raex.vip/websocket/' + this.$store.state.userInfo.id;
+			}
+			console.log('初始化websocket:' + wsuri);
+			this.websock = new WebSocket(wsuri);
+			this.websock.onmessage = this.websocketonmessage;
+			this.websock.onopen = this.websocketonopen;
+			this.websock.onerror = this.websocketonerror;
+			this.websock.onclose = this.websocketclose;
+		},
+		websocketonopen() {
+			this.websocketsend('META_PING');
+			this.timer = window.setInterval(() => {
+				setTimeout(() => {
+					this.websocketsend('META_PING');
+				}, 0);
+			}, 10000);
+		},
+		websocketonerror() {
+			console.log('socket连接异常');
+			this.initWebSocket();
+		},
+		websocketonmessage(e) {
+			console.log('socket接收数据:' + e.data);
+		},
+		websocketsend(Data) {
+			console.log('socket发送数据:' + Data);
+			this.websock.send(Data);
+		},
+		websocketclose(e) {
+			console.log('socket断开连接:', e);
+		}
+	}
 };
 </script>
 <style lang="less" scoped>

+ 64 - 0
src/main/vue/src/views/SnapshotEdit.vue

@@ -0,0 +1,64 @@
+<template>
+	<div class="edit-view">
+		<div class="edit-view__content-wrapper">
+			<div class="edit-view__content-section">
+				<el-form
+					:model="formData"
+					ref="form"
+					label-width="80px"
+					label-position="right"
+					size="small"
+					style="max-width: 500px"
+				>
+					<el-form-item prop="name" label="名称">
+						<el-input v-model="formData.name" :disabled="true"> </el-input>
+					</el-form-item>
+					<el-form-item prop="rule" label="作用">
+						<el-input type="textarea" v-model="formData.rule" :disabled="true"> </el-input>
+					</el-form-item>
+					<el-form-item prop="source" label="场景">
+						<el-select v-model="formData.source" clearable filterable placeholder="请选择" :disabled="true">
+							<el-option
+								v-for="item in sourceOptions"
+								:key="item.value"
+								:label="item.label"
+								:value="item.value"
+							>
+							</el-option>
+						</el-select>
+					</el-form-item>
+				</el-form>
+			</div>
+		</div>
+	</div>
+</template>
+<script>
+export default {
+	name: 'SnapshotEdit',
+	created() {
+		if (this.$route.query.id) {
+			this.$http
+				.get('snapshot/get/' + this.$route.query.id)
+				.then(res => {
+					this.formData = res;
+				})
+				.catch(e => {
+					console.log(e);
+					this.$message.error(e.error);
+				});
+		}
+	},
+	data() {
+		return {
+			formData: {},
+			sourceOptions: [
+				{ label: '元宇宙', value: 'META' },
+				{ label: '绿洲', value: 'RAEX' }
+			]
+		};
+	}
+};
+</script>
+<style lang="less" scoped>
+
+</style>

+ 169 - 0
src/main/vue/src/views/SnapshotList.vue

@@ -0,0 +1,169 @@
+<template>
+	<div class="list-view">
+		<div class="filters-container">
+			<el-input
+				placeholder="搜索..."
+				v-model="search"
+				clearable
+				class="filter-item search"
+				@keyup.enter.native="getData"
+			>
+				<el-button @click="getData" slot="append" icon="el-icon-search"> </el-button>
+			</el-input>
+		</div>
+		<el-table
+			:data="tableData"
+			row-key="id"
+			ref="table"
+			header-row-class-name="table-header-row"
+			header-cell-class-name="table-header-cell"
+			row-class-name="table-row"
+			cell-class-name="table-cell"
+			:height="tableHeight"
+			v-loading="fetchingData"
+		>
+			<el-table-column v-if="multipleMode" align="center" type="selection" width="50"> </el-table-column>
+			<el-table-column prop="id" align="center" label="ID" width="100"> </el-table-column>
+			<el-table-column prop="name" align="center" label="名称" width="200"> </el-table-column>
+			<el-table-column prop="rule" align="center" label="作用"> </el-table-column>
+			<el-table-column prop="source" label="用途" :formatter="sourceFormatter" width="100"> </el-table-column>
+			<el-table-column label="操作" align="center" fixed="right" width="200">
+				<template slot-scope="{ row }">
+					<el-button @click="addParams(row.id)" type="primary" size="mini" plain> 生成快照 </el-button>
+                    <el-button @click="detail(row)" type="primary" size="mini" plain> 查看 </el-button>
+				</template>
+			</el-table-column>
+		</el-table>
+		<el-dialog :visible.sync="showParamsDialog" title="添加参数" width="600px" :close-on-click-modal="false">
+			<el-form ref="paramsForm">
+				<el-form-item :rules="[{ required: true, message: '请输入参数' }]">
+					<el-input
+						v-model="sqlParams"
+						type="textarea"
+						:autosize="{ minRows: 3, maxRows: 20 }"
+						placeholder="多个参数用','隔开'"
+					>
+					</el-input>
+					<div class="tip">{{ tips }}</div>
+				</el-form-item>
+			</el-form>
+			<div slot="footer">
+				<el-button @click="showParamsDialog = false" size="mini"> 取消 </el-button>
+				<el-button @click="snapshot" size="mini" :loading="loading" type="primary"> 生成快照数据 </el-button>
+			</div>
+		</el-dialog>
+		<div class="pagination-wrapper">
+			<el-pagination
+				background
+				@size-change="onSizeChange"
+				@current-change="onCurrentChange"
+				:current-page="page"
+				:page-sizes="[10, 20, 30, 40, 50]"
+				:page-size="pageSize"
+				layout="total, sizes, prev, pager, next, jumper"
+				:total="totalElements"
+			>
+			</el-pagination>
+		</div>
+	</div>
+</template>
+<script>
+import { mapState } from 'vuex';
+import pageableTable from '@/mixins/pageableTable';
+
+export default {
+	name: 'SnapshotList',
+	mixins: [pageableTable],
+	data() {
+		return {
+			tips: '',
+			id: '',
+			loading: false,
+			sqlParams: '',
+			showParamsDialog: false,
+			multipleMode: false,
+			search: '',
+			url: '/snapshot/all',
+			sourceOptions: [
+				{ label: '元宇宙', value: 'META' },
+				{ label: '绿洲', value: 'RAEX' }
+			]
+		};
+	},
+	computed: {
+		selection() {
+			return this.$refs.table.selection.map(i => i.id);
+		}
+	},
+	methods: {
+		sourceFormatter(row, column, cellValue, index) {
+			let selectedOption = this.sourceOptions.find(i => i.value === cellValue);
+			if (selectedOption) {
+				return selectedOption.label;
+			}
+			return '';
+		},
+		beforeGetData() {
+			return { search: this.search, query: { del: false } };
+		},
+		toggleMultipleMode(multipleMode) {
+			this.multipleMode = multipleMode;
+			if (!multipleMode) {
+				this.$refs.table.clearSelection();
+			}
+		},
+		detail(row) {
+			this.$router.push({
+				path: '/snapshotEdit',
+				query: {
+					id: row.id
+				}
+			});
+		},
+		addParams(id) {
+			this.sqlParams = '';
+			this.id = id;
+			this.showParamsDialog = true;
+			if (id === '2858643') {
+				this.tips = '该快照需要一个参数:统计日期。模板:2023-01-23';
+			} else if (id === '1') {
+                this.tips = '该快照不需要任何参数';
+			} else {
+				this.$message.error('快照模板不存在,请联系研发人员添加相关模板');
+                this.showParamsDialog = false;
+				return;
+			}
+			if (this.$refs.paramsForm) {
+				this.$nextTick(() => {
+					this.$refs.paramsForm.clearValidate();
+				});
+			}
+		},
+		snapshot() {
+			this.loading = true;
+			this.$axios
+				.get('/snapshot/snapshot', { responseType: 'blob', params: { id: this.id, sqlParams: this.sqlParams } })
+				.then(res => {
+					console.log(res);
+					const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
+					const link = document.createElement('a');
+					link.href = downloadUrl;
+					link.setAttribute('download', res.headers['content-disposition'].split('filename=')[1]);
+					document.body.appendChild(link);
+					link.click();
+					link.remove();
+					this.loading = false;
+					this.showParamsDialog = false;
+				})
+				.catch(e => {
+					console.log(e);
+					this.loading = false;
+					this.$message.error(e.error);
+				});
+		}
+	}
+};
+</script>
+<style lang="less" scoped>
+
+</style>