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

fix es增加密码
fix 新增用户登录接口,加入验证码校验
fix 大屏端统计图表修改

459242451@qq.com 3 éve
szülő
commit
644343334d

+ 1 - 1
README.md

@@ -129,7 +129,7 @@ http://198.17.188.2:83/index.html?code=BTLQ+ClrznbhOHCub6CGUcY62Y+uR1dbJR9PTNL7R
 
 > 服务器启动
 
-- cd C:\cbwq\nginx-1.18.0
+- cd C:\cbwq\nginx-1.22.0
 - start nginx
 - cd C:\Program Files\Redis
 - redis-server.exe redis.windows.conf

+ 20 - 8
pom.xml

@@ -2,16 +2,15 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<modelVersion>4.0.0</modelVersion>
-	
+    <modelVersion>4.0.0</modelVersion>
+
     <groupId>com.ruoyi</groupId>
     <artifactId>ruoyi</artifactId>
     <version>3.6.0</version>
 
     <name>ruoyi</name>
-    <url>http://www.ruoyi.vip</url>
-    <description>若依管理系统</description>
-    
+    <description>船舶尾气管理系统</description>
+
     <properties>
         <ruoyi.version>3.6.0</ruoyi.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -21,8 +20,8 @@
         <druid.version>1.2.6</druid.version>
         <bitwalker.version>1.21</bitwalker.version>
         <swagger.version>3.0.0</swagger.version>
-		<kaptcha.version>2.3.2</kaptcha.version>
-		<mybatis-spring-boot.version>2.1.4</mybatis-spring-boot.version>
+        <kaptcha.version>2.3.2</kaptcha.version>
+        <mybatis-spring-boot.version>2.1.4</mybatis-spring-boot.version>
         <pagehelper.boot.version>1.3.1</pagehelper.boot.version>
         <fastjson.version>1.2.76</fastjson.version>
         <oshi.version>5.7.5</oshi.version>
@@ -33,8 +32,9 @@
         <poi.version>4.1.2</poi.version>
         <velocity.version>1.7</velocity.version>
         <jwt.version>0.9.1</jwt.version>
+        <log4j2.version>2.18.0</log4j2.version>
     </properties>
-	
+
     <!-- 依赖声明 -->
     <dependencyManagement>
         <dependencies>
@@ -205,6 +205,18 @@
                 <version>${ruoyi.version}</version>
             </dependency>
 
+            <!-- log4j日志组件 -->
+            <dependency>
+                <groupId>org.apache.logging.log4j</groupId>
+                <artifactId>log4j-api</artifactId>
+                <version>${log4j2.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.logging.log4j</groupId>
+                <artifactId>log4j-to-slf4j</artifactId>
+                <version>${log4j2.version}</version>
+            </dependency>
+
         </dependencies>
     </dependencyManagement>
 

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

@@ -57,6 +57,7 @@ public class BlackGasController extends BaseController {
 
     @GetMapping("/list")
     @ApiOperation("列表数据")
+    @Log(title = "黑烟列表查询")
     public TableDataInfo list(ShipRecognition shipRecognition) {
         // 传来的参数
         Map<String, Object> params = shipRecognition.getParams();
@@ -147,6 +148,7 @@ public class BlackGasController extends BaseController {
 
     @GetMapping("/snapPos/static")
     @ApiOperation("黑烟抓拍分布统计")
+    @Log(title = "黑烟抓拍分布统计")
     public AjaxResult snapPosStatic(@RequestParam(required = false) String month) {
         String beginTime = "";
         String endTime = "";

+ 12 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/GasCommonController.java

@@ -13,6 +13,7 @@ import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.constant.ElasticConstants;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -106,6 +107,7 @@ public class GasCommonController {
 
     @GetMapping("/illegalShipStatic")
     @ApiOperation("获取硫、黑烟超标数量统计")
+    @Log(title = "获取硫、黑烟超标数量统计")
     public AjaxResult illegalShipStatic() {
         Map<String, Object> equalsCondition = new HashMap<>();
         equalsCondition.put("illegalStatus", 2);
@@ -120,6 +122,7 @@ public class GasCommonController {
 
     @GetMapping("/queryIllegalInfoList")
     @ApiOperation("获取嫌疑或违规船舶信息")
+    @Log(title = "获取嫌疑或违规船舶信息")
     public AjaxResult queryIllegalInfoList(@RequestParam String illegalStatus, @RequestParam(required = false, defaultValue = "20") Integer size, @RequestParam(required = false) String mmsi) {
         Map<String, Object> equalsCondition = new HashMap<>();
         equalsCondition.put("illegalStatus", illegalStatus);
@@ -142,6 +145,7 @@ public class GasCommonController {
 
     @GetMapping("/queryDeviceList")
     @ApiOperation("获取所有设备数据")
+    @Log(title = "获取所有设备数据")
     public AjaxResult queryDeviceList(@RequestParam(required = false) String monitor) {
         if (redisCache.hasKey(CacheConstants.DEVICE_LIST_STATIC)) {
             Map<String, Object> cacheMap = redisCache.getCacheMap(CacheConstants.DEVICE_LIST_STATIC);
@@ -255,6 +259,7 @@ public class GasCommonController {
 
     @GetMapping("/queryShipByDeviceId")
     @ApiOperation("根据设备id获取设备的嫌疑或违规船舶数据")
+    @Log(title = "根据设备id获取设备的嫌疑或违规船舶数据")
     public AjaxResult queryShipByDeviceId(@RequestParam String deviceId, @RequestParam String illegalStatus, @RequestParam(required = false) Integer size, @RequestParam String... index) {
         Map<String, Object> equalsCondition = new HashMap<>();
         equalsCondition.put("illegalStatus", illegalStatus);
@@ -328,6 +333,7 @@ public class GasCommonController {
 
     @GetMapping("/queryRdsShipList")
     @ApiOperation("获取redis中所有正常船舶数据-用于地图展示船舶")
+    @Log(title = "获取redis中所有正常船舶数据-用于地图展示船舶")
     public AjaxResult queryRedisShipList(@RequestParam(required = false) Double areaLatitude1,
                                          @RequestParam(required = false) Double areaLatitude2,
                                          @RequestParam(required = false) Double areaLongitude1,
@@ -366,6 +372,7 @@ public class GasCommonController {
 
     @GetMapping("/queryCurrentShip")
     @ApiOperation("获取某个船的实时位置")
+    @Log(title = "获取某个船的实时位置")
     public AjaxResult queryCurrentShip(@RequestParam String mmsi) {
         Object cacheMapValue = redisCache.getCacheMapValue("ais:ship", mmsi);
         if (cacheMapValue == null) {
@@ -406,6 +413,7 @@ public class GasCommonController {
 
     @GetMapping("/queryShipMonitorInfo")
     @ApiOperation("获取船舶监测数据")
+    @Log(title = "获取船舶监测数据")
     public AjaxResult queryShipMonitorInfo(@RequestParam String mmsi) {
         Map<String, Object> map = new HashMap<>(4);
         List<MonitorInfo> minor = new ArrayList<>();
@@ -466,6 +474,7 @@ public class GasCommonController {
 
     @GetMapping("/queryData")
     @ApiOperation("查询ES数据")
+    @Log(title = "查询ES数据")
     public Object queryData(@RequestParam(required = false) String id, @RequestParam(required = false) Integer size, @RequestParam(required = false) String orderKey, @RequestParam String... index) {
         if (size == null) {
             size = 200;
@@ -489,12 +498,14 @@ public class GasCommonController {
 
     @DeleteMapping("/deleteIndexOneData")
     @ApiOperation("删除ES中某个数据")
+    @Log(title = "删除ES中某个数据")
     public void deleteIndexData(@RequestParam String index, @RequestParam String id) {
         client.deleteDocument(index, id);
     }
 
     @PostMapping("/sendSms")
     @ApiOperation("发送短信")
+    @Log(title = "发送短信")
     public AjaxResult sendSms(@RequestBody JSONObject jsonObject) {
         String content = jsonObject.getString("content");
         String phone = jsonObject.getString("phone");
@@ -509,6 +520,7 @@ public class GasCommonController {
     @SneakyThrows
     @PostMapping("/reSyncOneData")
     @ApiOperation("重新同步某一个数据")
+    @Log(title = "重新同步某一个数据")
     public void reSyncOneData(@RequestParam String index, @RequestParam String id) {
         client.deleteDocument(index, id);
         String so2ThresholdVal = configService.selectConfigByKey("so2.so2");

+ 2 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/PortalController.java

@@ -1,6 +1,7 @@
 package com.ruoyi.web.controller.gas;
 
 import cn.hutool.core.util.StrUtil;
+import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.utils.ip.IpUtils;
 import com.ruoyi.framework.web.service.SysLoginService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +29,7 @@ public class PortalController {
     private SysLoginService sysLoginService;
 
     @RequestMapping("/portal/login")
+    @Log(title = "大交管token免登陆")
     public String thirdLogin(@RequestParam String token, HttpServletResponse response) {
         // 组装系统本身的token给前端
         String newToken = sysLoginService.nologin(token);

+ 9 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/So2Controller.java

@@ -72,6 +72,7 @@ public class So2Controller extends BaseController {
 
     @GetMapping("/list")
     @ApiOperation("硫嫌疑船舶列表数据")
+    @Log(title = "硫嫌疑船舶列表数据")
     public TableDataInfo list(IllegalShip illegalShip) {
         // 传来的参数
         Map<String, Object> params = illegalShip.getParams();
@@ -177,6 +178,7 @@ public class So2Controller extends BaseController {
 
     @GetMapping("/guangpu/monitorPoint")
     @ApiOperation("光谱-检测点数据")
+    @Log(title = "光谱-检测点数据")
     public AjaxResult monitorPoint(GuapMonitorPoint monitorPoint) {
         // 传来的参数
         Map<String, Object> equalsCondition = new HashMap<>();
@@ -188,6 +190,7 @@ public class So2Controller extends BaseController {
 
     @GetMapping("/xiutan/semInstrument")
     @ApiOperation("嗅探-设备数据")
+    @Log(title = "嗅探-设备数据")
     public AjaxResult semInstrument(XiuTanSemInstrument semInstrument) {
         // 传来的参数
         Map<String, Object> equalsCondition = new HashMap<>();
@@ -199,6 +202,7 @@ public class So2Controller extends BaseController {
 
     @GetMapping("/static/device")
     @ApiOperation("设备安装位置统计")
+    @Log(title = "设备安装位置统计")
     public AjaxResult deviceStatic() {
 
         if (redisCache.hasKey(CacheConstants.DEVICE_STATIC)) {
@@ -224,6 +228,7 @@ public class So2Controller extends BaseController {
 
     @GetMapping("/static/semDevice")
     @ApiOperation("设备安装位置及设备类型统计")
+    @Log(title = "设备安装位置及设备类型统计")
     public AjaxResult semDevice() {
         if (redisCache.hasKey(CacheConstants.DEVICE_SEM_STATIC)) {
             return AjaxResult.success(redisCache.getCacheMap(CacheConstants.DEVICE_SEM_STATIC));
@@ -246,6 +251,7 @@ public class So2Controller extends BaseController {
 
     @GetMapping("/static/deviceType")
     @ApiOperation("设备类型统计")
+    @Log(title = "设备类型统计")
     public AjaxResult deviceTypeStatic() {
         if (redisCache.hasKey(CacheConstants.DEVICE_TYPE_STATIC)) {
             return AjaxResult.success(redisCache.getCacheMap(CacheConstants.DEVICE_TYPE_STATIC));
@@ -264,6 +270,7 @@ public class So2Controller extends BaseController {
 
     @GetMapping("/snapPos/static")
     @ApiOperation("硫含量超标船舶分布统计")
+    @Log(title = "硫含量超标船舶分布统计")
     public AjaxResult so2SnapPosStatic(@RequestParam(required = false) String month) {
         String beginTime = "";
         String endTime = "";
@@ -291,6 +298,7 @@ public class So2Controller extends BaseController {
 
     @GetMapping("/timeStatic")
     @ApiOperation("超标船舶统计-按时间")
+    @Log(title = "超标船舶统计-按时间")
     public AjaxResult monthStatic(@RequestParam(required = false) String interval, @RequestParam(required = false) String startMonth, @RequestParam(required = false) String endMonth) {
         if (StrUtil.isBlank(interval)) {
             // 默认值为1个月
@@ -321,6 +329,7 @@ public class So2Controller extends BaseController {
 
     @GetMapping("/third/timeStatic")
     @ApiOperation("for-Third-超标船舶统计-按时间")
+    @Log(title = "for-Third-超标船舶统计-按时间")
     public AjaxResult thirdMonthStatic(@RequestParam(required = false) String interval, @RequestParam(required = false) String startMonth, @RequestParam(required = false) String endMonth) {
         if (StrUtil.isBlank(interval)) {
             // 默认值为1个月

+ 27 - 20
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java

@@ -1,12 +1,5 @@
 package com.ruoyi.web.controller.system;
 
-import java.util.List;
-import java.util.Set;
-import org.springframework.beans.factory.annotation.Autowired;
-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.RestController;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysMenu;
@@ -18,15 +11,22 @@ import com.ruoyi.framework.web.service.SysLoginService;
 import com.ruoyi.framework.web.service.SysPermissionService;
 import com.ruoyi.framework.web.service.TokenService;
 import com.ruoyi.system.service.ISysMenuService;
+import org.springframework.beans.factory.annotation.Autowired;
+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.RestController;
+
+import java.util.List;
+import java.util.Set;
 
 /**
  * 登录验证
- * 
+ *
  * @author ruoyi
  */
 @RestController
-public class SysLoginController
-{
+public class SysLoginController {
     @Autowired
     private SysLoginService loginService;
 
@@ -41,29 +41,37 @@ public class SysLoginController
 
     /**
      * 登录方法
-     * 
+     *
      * @param loginBody 登录信息
      * @return 结果
      */
     @PostMapping("/login")
-    public AjaxResult login(@RequestBody LoginBody loginBody)
-    {
+    public AjaxResult login(@RequestBody LoginBody loginBody) {
+        AjaxResult ajax = AjaxResult.success();
+        // 生成令牌
+        String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
+                loginBody.getUuid(), false);
+        ajax.put(Constants.TOKEN, token);
+        return ajax;
+    }
+
+    @PostMapping("/v2/login")
+    public AjaxResult loginV2(@RequestBody LoginBody loginBody) {
         AjaxResult ajax = AjaxResult.success();
         // 生成令牌
         String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
-                loginBody.getUuid());
+                loginBody.getUuid(), true);
         ajax.put(Constants.TOKEN, token);
         return ajax;
     }
 
     /**
      * 获取用户信息
-     * 
+     *
      * @return 用户信息
      */
     @GetMapping("getInfo")
-    public AjaxResult getInfo()
-    {
+    public AjaxResult getInfo() {
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         SysUser user = loginUser.getUser();
         // 角色集合
@@ -79,12 +87,11 @@ public class SysLoginController
 
     /**
      * 获取路由信息
-     * 
+     *
      * @return 路由信息
      */
     @GetMapping("getRouters")
-    public AjaxResult getRouters()
-    {
+    public AjaxResult getRouters() {
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         // 用户信息
         SysUser user = loginUser.getUser();

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

@@ -229,7 +229,6 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                                 JSONArray imgUrlList = response.getJSONObject("data").getJSONArray("imgUrlList");
                                 String sootImgUrl = response.getJSONObject("data").getString("sootImgUrl");
                                 for (Object o : imgUrlList) {
-                                    // 只保存细节、全貌开头的图片
                                     String s = Convert.toStr(o);
 //                                    if (StrUtil.containsAny(s, "全貌", "细节")) {
                                     newImgList.add("http://" + s);
@@ -273,7 +272,7 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                     }
 
                     // 保存数据(黑烟暂时不需要推送到行政检查)
-//                    saveIllegalData(afterDataMap, ElasticConstants.HEIYAN_SHIP_RECOGNITION);
+                    saveIllegalData(afterDataMap, ElasticConstants.HEIYAN_SHIP_RECOGNITION);
                     client.createDocument(ElasticConstants.HEIYAN_SHIP_RECOGNITION, Convert.toStr(afterDataMap.get("id")), afterDataMap);
                 } else if (StrUtil.equalsIgnoreCase(database, "smoke_api") && StrUtil.equalsIgnoreCase(table, "ship_snap_address")) {
                     // 删除设备和类型的统计缓存
@@ -415,7 +414,8 @@ public class CanalScheduling implements Runnable, ApplicationContextAware {
                 } else if (StrUtil.equalsIgnoreCase(database, "ais_database") && (StrUtil.equalsIgnoreCase(table, "sem_instrument"))) {
                     // 嗅探系统-站点信息
                     client.updateDocument(ElasticConstants.AIS_SEM_INSTRUMENT, Convert.toStr(afterDataMap.get("id")), afterDataMap);
-                    if (ObjectUtil.notEqual(beforeDataMap.get("latitude"), afterDataMap.get("latitude")) || ObjectUtil.notEqual(beforeDataMap.get("longitude"), afterDataMap.get("longitude"))) {
+                    if (ObjectUtil.notEqual(beforeDataMap.get("latitude"), afterDataMap.get("latitude")) || ObjectUtil.notEqual(beforeDataMap.get("longitude"), afterDataMap.get("longitude")) || ObjectUtil.notEqual(beforeDataMap.get("status"),
+                            afterDataMap.get("status"))) {
                         log.info("删除redis设备缓存");
                         redisCache.deleteObject(CollUtil.set(false,
                                 CacheConstants.DEVICE_STATIC,

+ 12 - 4
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ElasticSearchClient.java

@@ -7,6 +7,10 @@ import com.ruoyi.common.enums.AggsType;
 import com.ruoyi.framework.config.properties.ElasticSearchConfig;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.elasticsearch.action.ActionListener;
 import org.elasticsearch.action.DocWriteRequest;
 import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
@@ -26,6 +30,7 @@ import org.elasticsearch.action.update.UpdateRequest;
 import org.elasticsearch.action.update.UpdateResponse;
 import org.elasticsearch.client.RequestOptions;
 import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestClientBuilder;
 import org.elasticsearch.client.RestHighLevelClient;
 import org.elasticsearch.client.core.CountRequest;
 import org.elasticsearch.client.core.CountResponse;
@@ -63,7 +68,6 @@ import org.elasticsearch.search.sort.SortBuilder;
 import org.elasticsearch.search.sort.SortBuilders;
 import org.elasticsearch.search.sort.SortOrder;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
@@ -103,7 +107,11 @@ public class ElasticSearchClient {
             //创建
             HttpHost httpHost = new HttpHost(elasticSearchConfig.getIp(),
                     elasticSearchConfig.getPort(), elasticSearchConfig.getType());
-            client = new RestHighLevelClient(RestClient.builder(httpHost));
+            RestClientBuilder builder = RestClient.builder(httpHost);
+            CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+            credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "JSmsa@12395"));
+            builder.setHttpClientConfigCallback(f -> f.setDefaultCredentialsProvider(credentialsProvider));
+            client = new RestHighLevelClient(builder);
         } catch (IOException e) {
             e.printStackTrace();
         }
@@ -114,11 +122,11 @@ public class ElasticSearchClient {
      *
      * @return
      */
-    @Bean
+    /*@Bean
     public RestHighLevelClient client() {
         return new RestHighLevelClient(RestClient.builder(new HttpHost(elasticSearchConfig.getIp(),
                 elasticSearchConfig.getPort(), elasticSearchConfig.getType())));
-    }
+    }*/
 
     /**
      * 创建索引

+ 1 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -94,7 +94,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
                 // 过滤请求
                 .authorizeRequests()
                 // 对于登录login 验证码captchaImage 允许匿名访问
-                .antMatchers("/login", "/captchaImage", "/portal/login").anonymous()
+                .antMatchers("/v2/login", "/login", "/captchaImage", "/portal/login").anonymous()
                 .antMatchers(
                         HttpMethod.GET,
                         "/",

+ 11 - 5
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java

@@ -77,16 +77,22 @@ public class SysLoginService {
      * @param uuid     唯一标识
      * @return 结果
      */
-    public String login(String username, String password, String code, String uuid) {
-        boolean captchaOnOff = configService.selectCaptchaOnOff();
-        // 验证码开关
-        if (captchaOnOff) {
-            validateCapcha(username, code, uuid);
+    public String login(String username, String password, String code, String uuid, boolean flag) {
+        if (flag) {
+            boolean captchaOnOff = configService.selectCaptchaOnOff();
+            // 验证码开关
+            if (captchaOnOff) {
+                validateCapcha(username, code, uuid);
+            }
         }
         // 用户验证
         Authentication authentication = null;
         try {
             if ("third".equals(thirdSecurity) && !StrUtil.contains(filterUser, username)) {
+                // 走一个账号合法性校验。如果是海事账号,应该都有@和msa
+                if (!StrUtil.containsAny(username, "@", "msa")) {
+                    throw new CustomException("illegal request", 400);
+                }
                 // 走第三方的校验规则,同时将第三方的password设置为系统自动生成的
                 JSONObject jsonObject = new JSONObject();
                 jsonObject.set("account", username);

+ 2 - 2
ruoyi-ui/src/api/login.js

@@ -9,7 +9,7 @@ export function login(username, password, code, uuid) {
     uuid
   }
   return request({
-    url: '/login',
+    url: '/v2/login',
     method: 'post',
     data: data
   })
@@ -37,4 +37,4 @@ export function getCodeImg() {
     url: '/captchaImage',
     method: 'get'
   })
-}
+}

+ 92 - 85
ruoyi-ui/src/views/components/table/statisticalTable.vue

@@ -48,25 +48,25 @@
       <el-col :span="12">
         <div class="titleContent">硫含量超标船舶统计</div>
         <div>
-          <div @click="back" style="float:left;margin-top:60rem">
-            <img src="@/assets/images/return.png" class="icon_size"/>
-          </div>
-          <div id="myChart" style="width:250rem;height:145rem;float:left"></div>
-          <div @click="next" style="float:left;margin-top:60rem" v-show="nextFlag">
-            <img src="@/assets/images/next.png" class="icon_size"/>
-          </div>
+          <!--          <div @click="back" style="float:left;margin-top:60rem">
+                      <img src="@/assets/images/return.png" class="icon_size"/>
+                    </div>-->
+          <div id="myChart" style="width:250rem;height:145rem;"></div>
+          <!--          <div @click="next" style="float:left;margin-top:60rem" v-show="nextFlag">
+                      <img src="@/assets/images/next.png" class="icon_size"/>
+                    </div>-->
         </div>
       </el-col>
       <el-col :span="12">
         <div class="titleContent">黑烟抓拍统计</div>
         <div>
-          <div @click="hyback" style="float:left;margin-top:60rem">
-            <img src="@/assets/images/return.png" class="icon_size"/>
-          </div>
-          <div id="hyChart" style="width:250rem;height:145rem;float:left"></div>
-          <div @click="hynext" style="float:left;margin-top:60rem" v-show="nextFlag2">
-            <img src="@/assets/images/next.png" class="icon_size"/>
-          </div>
+          <!--          <div @click="hyback" style="float:left;margin-top:60rem">
+                      <img src="@/assets/images/return.png" class="icon_size"/>
+                    </div>-->
+          <div id="hyChart" style="width:250rem;height:145rem;"></div>
+          <!--          <div @click="hynext" style="float:left;margin-top:60rem" v-show="nextFlag2">
+                      <img src="@/assets/images/next.png" class="icon_size"/>
+                    </div>-->
         </div>
       </el-col>
     </el-row>
@@ -109,7 +109,7 @@ export default {
     };
   },
   mounted() {
-    var myDate = new Date();
+    /*var myDate = new Date();
     var tYear = myDate.getFullYear();
     var tMonth = myDate.getMonth();
     if (tMonth < 5) {
@@ -128,14 +128,27 @@ export default {
         }
       }
     }
-    console.log(tMonth)
+    console.log(tMonth)*/
+    let nowDate = new Date();
+    let year = nowDate.getFullYear();
+    let mon = nowDate.getMonth() + 1;
+    for (let i = 0; i < 8; i++) {
+      if (mon <= 0) {
+        year = year - 1;
+        mon = mon + 12;
+      }
+      if (mon < 10) {
+        mon = "0" + mon;
+      }
+      this.months[i] = year + "-" + mon;
+      this.hyMonths[i] = year + "-" + mon;
+      mon = mon - 1;
+    }
+    this.months.reverse();
+    this.hyMonths.reverse();
     this.getDicts('heiyan_snap_pos');
     this.getDicts('so2_snap_pos');
-    //   console.log(this.blackName);
-    //   this.hyLine();
     this.getSo2Time();
-    //   this.liuPie();
-    //   this.hyPie();
   },
   methods: {
     getSo2Time() {
@@ -157,112 +170,106 @@ export default {
         }
       });
     },
+    // 硫含量统计图向左切换
     back() {
-      var myDate = new Date();
-      var tYear = myDate.getFullYear();
-      var year = parseInt(this.months[0].split("-")[0])
-
-      if (parseInt(tYear) >= year) {
+      let nowDate = new Date();
+      let tYear = nowDate.getFullYear();
+      let year = parseInt(this.months[0].split("-")[0])
+      if (tYear >= year) {
         this.nextFlag = true;
       }
-
-      var month = parseInt(this.months[0].split("-")[1])
+      let mon = parseInt(this.months[0].split("-")[1])
       this.months = [];
-      if (month > 5) {
-        for (var m = 1; m < 7; m++) {
-          this.months.push(year + "-" + "0" + m);
+      for (let i = 0; i < 8; i++) {
+        mon = mon - 1;
+        if (mon <= 0) {
+          year = year - 1;
+          mon = mon + 12;
         }
-      } else {
-        for (var m = 7; m < 13; m++) {
-          if (m < 10) {
-            this.months.push((year - 1) + "-" + "0" + m);
-          } else {
-            this.months.push((year - 1) + "-" + m);
-          }
+        if (mon < 10) {
+          mon = "0" + mon;
         }
+        this.months[i] = year + "-" + mon;
       }
+      this.months.reverse();
       this.drawLine();
     },
+    // 硫含量统计图向右切换
     next() {
-      var myDate = new Date();
-      var tYear = myDate.getFullYear();
-      if (tYear == parseInt(this.months[this.months.length - 1].split("-")[0])) {
+      let nowDate = new Date();
+      let tYear = nowDate.getFullYear();
+      if (tYear === parseInt(this.months[this.months.length - 1].split("-")[0])) {
         this.nextFlag = false;
       }
-
-      var year = parseInt(this.months[0].split("-")[0]);
-      var month = parseInt(this.months[0].split("-")[1])
+      let year = parseInt(this.months[5].split("-")[0]);
+      let mon = parseInt(this.months[5].split("-")[1])
       this.months = [];
-      if (month > 5) {
-        for (var m = 1; m < 7; m++) {
-          this.months.push((year + 1) + "-" + "0" + m);
+      for (let i = 0; i < 8; i++) {
+        if (mon >= 12) {
+          year = year + 1;
+          mon = 1;
         }
-      } else {
-        for (var m = 7; m < 13; m++) {
-          if (m < 10) {
-            this.months.push(year + "-" + "0" + m);
-          } else {
-            this.months.push(year + "-" + m);
-          }
+        if (mon < 10) {
+          mon = "0" + mon;
         }
+        this.months[i] = year + "-" + mon;
+        mon = mon + 1;
       }
+      console.log(this.months);
       this.drawLine();
     },
+    // 黑烟统计图向左切换
     hyback() {
-      var myDate = new Date();
-      var tYear = myDate.getFullYear();
-      var year = parseInt(this.hyMonths[0].split("-")[0])
-      if (parseInt(tYear) >= year) {
+      let nowDate = new Date();
+      let tYear = nowDate.getFullYear();
+      let year = parseInt(this.hyMonths[0].split("-")[0])
+      if (tYear >= year) {
         this.nextFlag2 = true;
       }
-      var month = parseInt(this.hyMonths[0].split("-")[1])
+      let mon = parseInt(this.hyMonths[0].split("-")[1])
       this.hyMonths = [];
-      if (month > 5) {
-        for (var m = 1; m < 7; m++) {
-          this.hyMonths.push(year + "-" + "0" + m);
+      for (let i = 0; i < 6; i++) {
+        mon = mon - 1;
+        if (mon <= 0) {
+          year = year - 1;
+          mon = mon + 12;
         }
-      } else {
-        for (var m = 7; m < 13; m++) {
-          if (m < 10) {
-            this.hyMonths.push((year - 1) + "-" + "0" + m);
-          } else {
-            this.hyMonths.push((year - 1) + "-" + m);
-          }
+        if (mon < 10) {
+          mon = "0" + mon;
         }
+        this.hyMonths[i] = year + "-" + mon;
       }
+      this.hyMonths.reverse();
       this.hyLine();
     },
+    // 黑烟统计图向右切换
     hynext() {
-      var myDate = new Date();
-      var tYear = myDate.getFullYear();
-      if (tYear == parseInt(this.hyMonths[this.hyMonths.length - 1].split("-")[0])) {
+      let nowDate = new Date();
+      let tYear = nowDate.getFullYear();
+      if (tYear === parseInt(this.hyMonths[this.hyMonths.length - 1].split("-")[0])) {
         this.nextFlag2 = false;
       }
-      var year = parseInt(this.hyMonths[0].split("-")[0])
-      var month = parseInt(this.hyMonths[0].split("-")[1])
+      let year = parseInt(this.hyMonths[5].split("-")[0])
+      let mon = parseInt(this.hyMonths[5].split("-")[1])
       this.hyMonths = [];
-      if (month > 5) {
-        for (var m = 1; m < 7; m++) {
-          this.hyMonths.push((year + 1) + "-" + "0" + m);
+      for (let i = 0; i < 6; i++) {
+        if (mon <= 0) {
+          year = year - 1;
+          mon = mon + 12;
         }
-      } else {
-        for (var m = 7; m < 13; m++) {
-          if (m < 10) {
-            this.hyMonths.push(year + "-" + "0" + m);
-          } else {
-            this.hyMonths.push(year + "-" + m);
-          }
+        if (mon < 10) {
+          mon = "0" + mon;
         }
+        this.hyMonths[i] = year + "-" + mon;
+        mon = mon - 1;
       }
       this.hyLine();
     },
     liuPie() {
       getSo2SnapPos({'month': this.liuDate}).then(response => {
-        // console.log(response);
         var myChart = this.$echarts.init(document.getElementById('liuPieChart'));
         var series = [];
         for (var index in this.so2Name) {
-          // console.log(this.so2Name[index].dictLabel);
           var object = {
             'value': response.data[this.so2Name[index].dictLabel],
             'name': this.so2Name[index].dictLabel,