Forráskód Böngészése

Merge branch 'master' of http://git.xt.wenhq.top:8083/liwei19941102/cbwqpf

MSI\liwei 3 éve
szülő
commit
30e4bc6dc4

+ 1 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/BlackGasController.java

@@ -65,6 +65,7 @@ public class BlackGasController extends BaseController {
         equalsCondition.put("shipRegionType", shipRecognition.getShipRegionType());
         equalsCondition.put("rcgSoot", shipRecognition.getRcgSoot());
         equalsCondition.put("illegalStatus", shipRecognition.getIllegalStatus());
+        equalsCondition.put("orgName", shipRecognition.getOrgName());
         // 组装范围查询条件
         Map<String, Object> rangeCondition = new HashMap<>();
         if (ObjectUtil.isNotEmpty(params.get("beginTime"))) {

+ 23 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/GasCommonController.java

@@ -1,12 +1,10 @@
 package com.ruoyi.web.controller.gas;
 
 import cn.hutool.core.convert.Convert;
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
 import com.ruoyi.common.constant.ElasticConstants;
 import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.core.domain.BaseEntity;
 import com.ruoyi.framework.config.ElasticSearchClient;
+import com.ruoyi.system.domain.IllegalInfo;
 import com.ruoyi.system.domain.SyncPost;
 import com.ruoyi.web.service.IGasCommonService;
 import io.swagger.annotations.Api;
@@ -17,9 +15,12 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -67,4 +68,23 @@ public class GasCommonController {
         return AjaxResult.success(result);
     }
 
+    @GetMapping("/queryIllegalInfoList")
+    @ApiOperation("获取嫌疑或违规船舶信息")
+    public AjaxResult queryIllegalInfoList(@RequestParam String illegalStatus, @RequestParam(required = false, defaultValue = "20") Integer size) {
+        Map<String, Object> equalsCondition = new HashMap<>();
+        equalsCondition.put("illegalStatus", illegalStatus);
+        List<String> orderBy = new ArrayList<>();
+        orderBy.add("-createTime");
+        Map<String, Object> stringObjectMap = client.searchDocument(equalsCondition,
+                null,
+                orderBy,
+                1,
+                size,
+                ElasticConstants.AIS_ILLEGAL_SHIP,
+                ElasticConstants.SO2_ALERT,
+                ElasticConstants.HEIYAN_SHIP_RECOGNITION);
+
+        return AjaxResult.success(Convert.toList(IllegalInfo.class, stringObjectMap.get("pageList")));
+    }
+
 }

+ 16 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/So2Controller.java

@@ -277,14 +277,26 @@ public class So2Controller extends BaseController {
 
     @GetMapping("/timeStatic")
     @ApiOperation("超标船舶统计-按时间")
-    public AjaxResult monthStatic(@RequestParam(required = false) String interval) {
+    public AjaxResult monthStatic(@RequestParam(required = false) String interval, @RequestParam(required = false) String startMonth, @RequestParam(required = false) String endMonth) {
         if (StrUtil.isBlank(interval)) {
             // 默认值为1个月
             interval = "1M";
         }
-        Map<Object, Object> aisAggs = client.dateHistogramAggs(ElasticConstants.AIS_ILLEGAL_SHIP, AggsType.count, "peakTime", "id", null, null, new DateHistogramInterval(interval));
-        Map<Object, Object> so2Aggs = client.dateHistogramAggs(ElasticConstants.SO2_ALERT, AggsType.count, "createTime", "id", null, null, new DateHistogramInterval(interval));
-        Map<Object, Object> heiyanAggs = client.dateHistogramAggs(ElasticConstants.HEIYAN_SHIP_RECOGNITION, AggsType.count, "snapTimeFmt", "id", null, null, new DateHistogramInterval(interval));
+        Map<String, Object> so2RangeCondition = new HashMap<>();
+        Map<String, Object> heiyanRangeCondition = new HashMap<>();
+        if (!StrUtil.isAllBlank(startMonth, endMonth)) {
+            if (StrUtil.isNotBlank(startMonth)) {
+                startMonth = startMonth + "-01 00:00:00";
+            }
+            if (StrUtil.isNotBlank(endMonth)) {
+                endMonth = DateUtil.formatDate(DateUtil.endOfMonth(DateUtil.parseDate(endMonth + "-01 00:00:00"))) + " 23:59:59";
+            }
+            so2RangeCondition.put("createTime", StrUtil.concat(true, "[", startMonth, ",", endMonth, "]"));
+            heiyanRangeCondition.put("snapTimeFmt", StrUtil.concat(true, "[", startMonth, ",", endMonth, "]"));
+        }
+        Map<Object, Object> aisAggs = client.dateHistogramAggs(ElasticConstants.AIS_ILLEGAL_SHIP, AggsType.count, "peakTime", "id", null, so2RangeCondition, new DateHistogramInterval(interval));
+        Map<Object, Object> so2Aggs = client.dateHistogramAggs(ElasticConstants.SO2_ALERT, AggsType.count, "createTime", "id", null, so2RangeCondition, new DateHistogramInterval(interval));
+        Map<Object, Object> heiyanAggs = client.dateHistogramAggs(ElasticConstants.HEIYAN_SHIP_RECOGNITION, AggsType.count, "snapTimeFmt", "id", null, heiyanRangeCondition, new DateHistogramInterval(interval));
         Map<String, Map<Object, Object>> result = new HashMap<>();
         result.put("ais", aisAggs);
         result.put("so2", so2Aggs);

+ 7 - 7
ruoyi-admin/src/main/java/com/ruoyi/web/job/CanalScheduling.java

@@ -173,8 +173,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 "monitor_point",
                 "device",
                 "illegal_ship",
-                "sem_instrument",
-                "sem_instrument_test")) {
+                "sem_instrument")) {
             return;
         }
 
@@ -215,8 +214,8 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                         if (ObjectUtil.isNotEmpty(afterDataMap.get("snapPos"))) {
                             afterDataMap.put("orgName", orgMap.get(Convert.toStr(afterDataMap.get("snapPos"))));
                         }
-                        // 嫌疑船舶
-                        afterDataMap.put("illegalStatus", 2);
+                        // 超过阈值后直接判定为违规船舶
+                        afterDataMap.put("illegalStatus", 3);
                         afterDataMap.put("uploadFlag", 1);
                         // TODO 上报行政检查系统
 
@@ -274,7 +273,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     }
                     afterDataMap.put("illegalType", "guangpu");
                     client.createDocument(ElasticConstants.SO2_ALERT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
-                } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument_test") || StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
+                } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
                     client.createDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                     redisCache.deleteObject(CollUtil.set(false,
@@ -284,6 +283,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     // 嗅探系统-违规船舶
                     afterDataMap.put("mmsi", afterDataMap.get("shipMmsi"));
                     afterDataMap.put("createTime", afterDataMap.get("peakTime"));
+                    afterDataMap.put("so2Percent", afterDataMap.get("sPercent"));
                     if (ObjectUtil.isNotEmpty(afterDataMap.get("sPercent")) && NumberUtil.isGreaterOrEqual(Convert.toBigDecimal(afterDataMap.get("sPercent")), Convert.toBigDecimal(so2ThresholdVal))) {
                         // 查询检测点和船舶信息、船舶进出港记录
                         if (ObjectUtil.isNotEmpty(afterDataMap.get("mmsi"))) {
@@ -334,7 +334,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC));
-                } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument_test") || StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
+                } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
                     client.updateDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                     redisCache.deleteObject(CollUtil.set(false,
@@ -356,7 +356,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     redisCache.deleteObject(CollUtil.set(false,
                             CacheConstants.DEVICE_STATIC,
                             CacheConstants.DEVICE_TYPE_STATIC));
-                } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument_test") || StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
+                } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
                     client.deleteDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")));
                     redisCache.deleteObject(CollUtil.set(false,

+ 3 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/service/Impl/GasCommonServiceImpl.java

@@ -53,7 +53,7 @@ public class GasCommonServiceImpl implements IGasCommonService {
         if (StrUtil.isNotBlank(syncPost.getEndTime())) {
             syncPost.setEndTime(syncPost.getEndTime() + " 23:59:59");
         }
-        if (StrUtil.equalsIgnoreCase(schema, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument_test") || StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
+        if (StrUtil.equalsIgnoreCase(schema, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
             // 嗅探站点信息
             List<Map<String, Object>> map = gasCommonMapper.querySemInstrument(table);
             for (Map<String, Object> stringObjectMap : map) {
@@ -69,6 +69,7 @@ public class GasCommonServiceImpl implements IGasCommonService {
                 stringObjectMap.put("illegalType", "xiutan");
                 stringObjectMap.put("uploadFlag", 0);
                 stringObjectMap.put("orgName", orgMap.get(Convert.toStr(stringObjectMap.get("monitorPointName"))));
+                stringObjectMap.put("so2Percent", stringObjectMap.get("sPercent"));
                 saveOrUpdate(ElasticConstants.AIS_ILLEGAL_SHIP, Convert.toStr(stringObjectMap.get("id")), stringObjectMap);
             }
         } else if (StrUtil.equalsIgnoreCase(schema, "heiyan") && StrUtil.equalsIgnoreCase(table, "ship_recognition")) {
@@ -77,6 +78,7 @@ public class GasCommonServiceImpl implements IGasCommonService {
             for (Map<String, Object> stringObjectMap : map) {
                 stringObjectMap.put("illegalStatus", 1);
                 stringObjectMap.put("uploadFlag", 0);
+                stringObjectMap.put("orgName", orgMap.get(Convert.toStr(stringObjectMap.get("snapPos"))));
                 saveOrUpdate(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(stringObjectMap.get("id")), stringObjectMap);
             }
         } else if (StrUtil.equalsIgnoreCase(schema, "so2") && StrUtil.equalsIgnoreCase(table, "alert")) {

+ 14 - 11
ruoyi-admin/src/main/resources/application-test.yml

@@ -6,9 +6,9 @@ spring:
     druid:
       # 主库数据源
       master:
-        url: jdbc:mysql://200.200.19.126:3306/cbwqpf?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        url: jdbc:mysql://212.129.138.23:3306/cbwqpf?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
         username: root
-        password: root
+        password: YbNL5_h]6a4kk
       # 从库数据源(嗅探)
       slaveais:
         # 从数据源开关/默认关闭
@@ -20,16 +20,16 @@ spring:
       slaveso2:
         # 从数据源开关/默认关闭
         enabled: true
-        url: jdbc:mysql://200.200.19.126:3306/so2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        url: jdbc:mysql://212.129.138.23:3306/so2?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
         username: root
-        password: root
+        password: YbNL5_h]6a4kk
       # 从库数据源(黑烟)
       slaveblack:
         # 从数据源开关/默认关闭
         enabled: true
-        url: jdbc:mysql://200.200.19.126:3306/heiyan?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        url: jdbc:mysql://212.129.138.23:3306/heiyan?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
         username: root
-        password: root
+        password: YbNL5_h]6a4kk
       # 初始连接数
       initialSize: 5
       # 最小连接池数量
@@ -77,9 +77,9 @@ spring:
     # 端口,默认为6379
     port: 6379
     # 数据库索引
-    database: 0
+    database: 10
     # 密码
-    password:
+    password: xintong
     # 连接超时时间
     timeout: 10s
     lettuce:
@@ -94,7 +94,7 @@ spring:
         max-wait: -1ms
 elasticsearch:
   port: 9200
-  ip: 200.200.19.122
+  ip: 212.129.138.23
   type: http  #访问方式
   numberOfReplicas: 2  #副本数
   numberOfShards: 5  #分片数
@@ -104,12 +104,15 @@ elasticsearch:
 
 canal:
   configs:
-    - hostname: 127.0.0.1
+    - hostname: 212.129.138.23
       port: 11111
       destination: heiyan
-    - hostname: 127.0.0.1
+    - hostname: 212.129.138.23
       port: 11111
       destination: so2
+    - hostname: 212.129.138.23
+      port: 11111
+      destination: ais
 
 # Swagger配置
 swagger:

+ 39 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/IllegalInfo.java

@@ -0,0 +1,39 @@
+package com.ruoyi.system.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 嫌疑船舶
+ *
+ * @author ruoyi
+ * @date 2021-08-24
+ */
+@Data
+public class IllegalInfo {
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    private String illegalType;
+
+    private String monitorPointName;
+
+    private String mmsi;
+
+    private String shipName;
+
+    private BigDecimal sPercent;
+
+    private String snapTimeFmt;
+
+    private String snapPos;
+
+    private String aisMmsi;
+
+    private String aisShipName;
+
+    private Integer rcgSoot;
+}

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/IllegalShip.java

@@ -43,6 +43,8 @@ public class IllegalShip extends BaseEntity {
     private String berthName;
 
     private BigDecimal sPercent;
+    
+    private BigDecimal so2Percent;
 
     private BigDecimal so2Concentration;
 

+ 4 - 2
ruoyi-system/src/main/resources/mapper/system/AisDatabaseMapper.xml

@@ -6,12 +6,14 @@
 
     <select id="queryDeviceStatic" resultType="java.util.Map">
         select Category point, count(1) count
-        from sem_instrument_test
+        from sem_instrument
+        where Category is not null
         group by Category;
     </select>
 
     <select id="queryDeviceCount" resultType="java.lang.Integer">
         select count(1)
-        from sem_instrument_test
+        from sem_instrument
+        where Category is not null
     </select>
 </mapper>

+ 1 - 1
ruoyi-system/src/main/resources/mapper/system/GasCommonMapper.xml

@@ -46,7 +46,7 @@
                wind_angle                                      windAngle,
                confirmed
         from illegal_ship t1
-                 left join sem_instrument_test t2 on t1.sem_id = t2.id
+                 left join sem_instrument t2 on t1.sem_id = t2.id
     </select>
 
     <select id="queryShipRecognition" resultType="java.util.Map">

+ 79 - 70
ruoyi-ui/src/views/components/table/userTable.vue

@@ -23,11 +23,11 @@
 
         <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange" :header-cell-style="{ background: 'linear-gradient(white, #ccebf9)'}">
           <!-- <el-table-column type="selection" width="50" align="center" /> -->
-          <el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" />
-          <el-table-column label="用户名" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
-          <el-table-column label="密码" align="center" key="nickName" prop="nickName" v-if="columns[2].visible" :show-overflow-tooltip="true" />
-          <el-table-column label="权限" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" />
-          <el-table-column label="所属机构" align="center" key="deptName" prop="dept.deptName" v-if="columns[4].visible" width="120" />
+          <el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible"/>
+          <el-table-column label="用户名" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true"/>
+          <el-table-column label="姓名" align="center" key="nickName" prop="nickName" v-if="columns[2].visible" :show-overflow-tooltip="true"/>
+          <el-table-column label="权限" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true"/>
+          <el-table-column label="所属机构" align="center" key="deptName" prop="dept.deptName" v-if="columns[4].visible" width="120"/>
           <!-- <el-table-column label="状态" align="center" key="status" v-if="columns[5].visible">
             <template slot-scope="scope">
               <el-switch
@@ -56,23 +56,27 @@
                 icon="el-icon-edit"
                 @click="handleUpdate(scope.row)"
                 v-hasPermi="['system:user:edit']"
-              >修改</el-button>
+              >修改
+              </el-button>
               <el-button
                 size="mini"
                 type="text"
                 icon="el-icon-delete"
                 @click="handleDelete(scope.row)"
                 v-hasPermi="['system:user:remove']"
-              >删除</el-button>
+              >删除
+              </el-button>
               <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)">
                 <span class="el-dropdown-link">
                   <i class="el-icon-d-arrow-right el-icon--right"></i>更多
                 </span>
                 <el-dropdown-menu slot="dropdown">
                   <el-dropdown-item command="handleResetPwd" icon="el-icon-key"
-                    v-hasPermi="['system:user:resetPwd']">重置密码</el-dropdown-item>
+                                    v-hasPermi="['system:user:resetPwd']">重置密码
+                  </el-dropdown-item>
                   <el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check"
-                    v-hasPermi="['system:user:edit']">分配角色</el-dropdown-item>
+                                    v-hasPermi="['system:user:edit']">分配角色
+                  </el-dropdown-item>
                 </el-dropdown-menu>
               </el-dropdown>
             </template>
@@ -95,36 +99,36 @@
         <el-row>
           <el-col :span="12">
             <el-form-item label="用户昵称" prop="nickName">
-              <el-input v-model="form.nickName" placeholder="请输入用户昵称" maxlength="30" />
+              <el-input v-model="form.nickName" placeholder="请输入用户昵称" maxlength="30"/>
             </el-form-item>
           </el-col>
           <el-col :span="12">
             <el-form-item label="归属部门" prop="deptId">
-              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
+              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门"/>
             </el-form-item>
           </el-col>
         </el-row>
         <el-row>
           <el-col :span="12">
             <el-form-item label="手机号码" prop="phonenumber">
-              <el-input v-model="form.phonenumber" placeholder="请输入手机号码" maxlength="11" />
+              <el-input v-model="form.phonenumber" placeholder="请输入手机号码" maxlength="11"/>
             </el-form-item>
           </el-col>
           <el-col :span="12">
             <el-form-item label="邮箱" prop="email">
-              <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
+              <el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50"/>
             </el-form-item>
           </el-col>
         </el-row>
         <el-row>
           <el-col :span="12">
             <el-form-item v-if="form.userId == undefined" label="用户名称" prop="userName">
-              <el-input v-model="form.userName" placeholder="请输入用户名称" maxlength="30" />
+              <el-input v-model="form.userName" placeholder="请输入用户名称" maxlength="30"/>
             </el-form-item>
           </el-col>
           <el-col :span="12">
             <el-form-item v-if="form.userId == undefined" label="用户密码" prop="password">
-              <el-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20" />
+              <el-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20"/>
             </el-form-item>
           </el-col>
         </el-row>
@@ -148,7 +152,8 @@
                   v-for="dict in statusOptions"
                   :key="dict.dictValue"
                   :label="dict.dictValue"
-                >{{dict.dictLabel}}</el-radio>
+                >{{ dict.dictLabel }}
+                </el-radio>
               </el-radio-group>
             </el-form-item>
           </el-col>
@@ -215,7 +220,8 @@
           <em>点击上传</em>
         </div>
         <div class="el-upload__tip" slot="tip">
-          <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
+          <el-checkbox v-model="upload.updateSupport"/>
+          是否更新已经存在的用户数据
           <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
         </div>
         <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
@@ -229,15 +235,15 @@
 </template>
 
 <script>
-import { listUser, getUser, delUser, addUser, updateUser, exportUser, resetUserPwd, changeUserStatus, importTemplate } from "@/api/system/user";
-import { getToken } from "@/utils/auth";
-import { treeselect } from "@/api/system/dept";
+import {addUser, changeUserStatus, delUser, exportUser, getUser, importTemplate, listUser, resetUserPwd, updateUser} from "@/api/system/user";
+import {getToken} from "@/utils/auth";
+import {treeselect} from "@/api/system/dept";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 
 export default {
   name: "User",
-  components: { Treeselect },
+  components: {Treeselect},
   data() {
     return {
       // 遮罩层
@@ -293,7 +299,7 @@ export default {
         // 是否更新已经存在的用户数据
         updateSupport: 0,
         // 设置上传的请求头部
-        headers: { Authorization: "Bearer " + getToken() },
+        headers: {Authorization: "Bearer " + getToken()},
         // 上传的地址
         url: process.env.VUE_APP_BASE_API + "/system/user/importData"
       },
@@ -308,25 +314,25 @@ export default {
       },
       // 列信息
       columns: [
-        { key: 0, label: `用户编号`, visible: true },
-        { key: 1, label: `用户名称`, visible: true },
-        { key: 2, label: `用户昵称`, visible: true },
-        { key: 3, label: `部门`, visible: true },
-        { key: 4, label: `手机号码`, visible: true },
-        { key: 5, label: `状态`, visible: true },
-        { key: 6, label: `创建时间`, visible: true }
+        {key: 0, label: `用户编号`, visible: true},
+        {key: 1, label: `用户名称`, visible: true},
+        {key: 2, label: `用户昵称`, visible: true},
+        {key: 3, label: `部门`, visible: true},
+        {key: 4, label: `手机号码`, visible: true},
+        {key: 5, label: `状态`, visible: true},
+        {key: 6, label: `创建时间`, visible: true}
       ],
       // 表单校验
       rules: {
         userName: [
-          { required: true, message: "用户名称不能为空", trigger: "blur" }
+          {required: true, message: "用户名称不能为空", trigger: "blur"}
         ],
         nickName: [
-          { required: true, message: "用户昵称不能为空", trigger: "blur" }
+          {required: true, message: "用户昵称不能为空", trigger: "blur"}
         ],
         password: [
-          { required: true, message: "用户密码不能为空", trigger: "blur" },
-          { min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur' }
+          {required: true, message: "用户密码不能为空", trigger: "blur"},
+          {min: 5, max: 20, message: '用户密码长度必须介于 5 和 20 之间', trigger: 'blur'}
         ],
         email: [
           {
@@ -395,16 +401,16 @@ export default {
     handleStatusChange(row) {
       let text = row.status === "0" ? "启用" : "停用";
       this.$confirm('确认要"' + text + '""' + row.userName + '"用户吗?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(function() {
-          return changeUserStatus(row.userId, row.status);
-        }).then(() => {
-          this.msgSuccess(text + "成功");
-        }).catch(function() {
-          row.status = row.status === "0" ? "1" : "0";
-        });
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(function () {
+        return changeUserStatus(row.userId, row.status);
+      }).then(() => {
+        this.msgSuccess(text + "成功");
+      }).catch(function () {
+        row.status = row.status === "0" ? "1" : "0";
+      });
     },
     // 取消按钮
     cancel() {
@@ -495,19 +501,20 @@ export default {
         closeOnClickModal: false,
         inputPattern: /^.{5,20}$/,
         inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
-      }).then(({ value }) => {
-          resetUserPwd(row.userId, value).then(response => {
-            this.msgSuccess("修改成功,新密码是:" + value);
-          });
-        }).catch(() => {});
+      }).then(({value}) => {
+        resetUserPwd(row.userId, value).then(response => {
+          this.msgSuccess("修改成功,新密码是:" + value);
+        });
+      }).catch(() => {
+      });
     },
     /** 分配角色操作 */
-    handleAuthRole: function(row) {
+    handleAuthRole: function (row) {
       const userId = row.userId;
       this.$router.push("/auth/role/" + userId);
     },
     /** 提交按钮 */
-    submitForm: function() {
+    submitForm: function () {
       this.$refs["form"].validate(valid => {
         if (valid) {
           if (this.form.userId != undefined) {
@@ -530,30 +537,32 @@ export default {
     handleDelete(row) {
       const userIds = row.userId || this.ids;
       this.$confirm('是否确认删除用户编号为"' + userIds + '"的数据项?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(function() {
-          return delUser(userIds);
-        }).then(() => {
-          this.getList();
-          this.msgSuccess("删除成功");
-        }).catch(() => {});
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(function () {
+        return delUser(userIds);
+      }).then(() => {
+        this.getList();
+        this.msgSuccess("删除成功");
+      }).catch(() => {
+      });
     },
     /** 导出按钮操作 */
     handleExport() {
       const queryParams = this.queryParams;
       this.$confirm('是否确认导出所有用户数据项?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(() => {
-          this.exportLoading = true;
-          return exportUser(queryParams);
-        }).then(response => {
-          this.download(response.msg);
-          this.exportLoading = false;
-        }).catch(() => {});
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(() => {
+        this.exportLoading = true;
+        return exportUser(queryParams);
+      }).then(response => {
+        this.download(response.msg);
+        this.exportLoading = false;
+      }).catch(() => {
+      });
     },
     /** 导入按钮操作 */
     handleImport() {
@@ -575,7 +584,7 @@ export default {
       this.upload.open = false;
       this.upload.isUploading = false;
       this.$refs.upload.clearFiles();
-      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
+      this.$alert(response.msg, "导入结果", {dangerouslyUseHTMLString: true});
       this.getList();
     },
     // 提交上传文件