Browse Source

解析短期文件

xusl 2 năm trước cách đây
mục cha
commit
81a31d50dd
19 tập tin đã thay đổi với 835 bổ sung42 xóa
  1. 41 0
      backend/src/main/java/com/jiayue/ssi/controller/SysOperlogController.java
  2. 1 0
      backend/src/main/java/com/jiayue/ssi/controller/SysRoleController.java
  3. 11 0
      backend/src/main/java/com/jiayue/ssi/controller/SysUserController.java
  4. 54 0
      backend/src/main/java/com/jiayue/ssi/entity/ForecastPowerShortTerm.java
  5. 1 1
      backend/src/main/java/com/jiayue/ssi/entity/SysUser.java
  6. 24 22
      backend/src/main/java/com/jiayue/ssi/filter/JwtAuthenticationTokenFilter.java
  7. 30 0
      backend/src/main/java/com/jiayue/ssi/job/FileAnalysisJob.java
  8. 16 0
      backend/src/main/java/com/jiayue/ssi/mapper/ForecastPowerShortTermMapper.java
  9. 7 7
      backend/src/main/java/com/jiayue/ssi/mapper/SysRoleMapper.java
  10. 26 0
      backend/src/main/java/com/jiayue/ssi/service/ForecastPowerShortTermService.java
  11. 5 0
      backend/src/main/java/com/jiayue/ssi/service/SysRoleService.java
  12. 535 0
      backend/src/main/java/com/jiayue/ssi/service/impl/FileAnalysisService.java
  13. 40 0
      backend/src/main/java/com/jiayue/ssi/service/impl/ForecastPowerShortTermServiceImpl.java
  14. 11 0
      backend/src/main/java/com/jiayue/ssi/service/impl/SysRoleServiceImpl.java
  15. 8 1
      backend/src/main/java/com/jiayue/ssi/util/FileUtil.java
  16. 8 5
      backend/src/main/resources/mapper/system/SysRoleMapper.xml
  17. 8 3
      ui/src/views/auditManager/operlog/index.vue
  18. 1 1
      ui/src/views/sysManager/roleManager/index.vue
  19. 8 2
      ui/src/views/sysManager/userManager/index.vue

+ 41 - 0
backend/src/main/java/com/jiayue/ssi/controller/SysOperlogController.java

@@ -8,7 +8,9 @@ import com.jiayue.ssi.backenum.AuditType;
 import com.jiayue.ssi.backenum.BusinessType;
 import com.jiayue.ssi.constant.CustomException;
 import com.jiayue.ssi.entity.SysOperLog;
+import com.jiayue.ssi.entity.SysRole;
 import com.jiayue.ssi.service.SysOperLogService;
+import com.jiayue.ssi.service.SysRoleService;
 import com.jiayue.ssi.util.DateUtils;
 import com.jiayue.ssi.util.ResponseVO;
 import lombok.extern.slf4j.Slf4j;
@@ -31,6 +33,40 @@ import java.util.stream.Collectors;
 public class SysOperlogController {
     @Autowired
     SysOperLogService sysOperLogService;
+    @Autowired
+    SysRoleService sysRoleService;
+
+    /**
+     * 获取审计类型
+     */
+    @GetMapping(value = "/getAuditType")
+    public ResponseVO getAuditType() throws CustomException {
+        List<Map> list = new ArrayList<>();
+        try {
+            // 根据当前用户获取角色
+            SysRole sysRole = sysRoleService.selectRoleListByUserId();
+            if ("ywsjy".equals(sysRole.getRoleKey())){
+                // 业务审计员
+                Map<String,String> map = new HashMap<>();
+                map.put("value","1");
+                map.put("label","业务");
+                list.add(map);
+            }
+            else {
+                Map<String,String> map1 = new HashMap<>();
+                map1.put("value","0");
+                map1.put("label","系统");
+                list.add(map1);
+                Map<String,String> map2 = new HashMap<>();
+                map2.put("value","1");
+                map2.put("label","业务");
+                list.add(map2);
+            }
+        } catch (Exception e) {
+            throw new CustomException("操作日志删除异常", e);
+        }
+        return ResponseVO.success(list);
+    }
 
     /**
      * 获取列表分页信息
@@ -91,6 +127,11 @@ public class SysOperlogController {
                     wrapper.orderByDesc(sortDbField);
                 }
             }
+            SysRole sysRole = sysRoleService.selectRoleListByUserId();
+            if (!"sjgly".equals(sysRole.getRoleKey())){
+                // 业务审计员
+                wrapper.eq("audit_type", "1");
+            }
 
             Page<SysOperLog> result = sysOperLogService.page(new Page<>(currentPage, pageSize), wrapper);
             return ResponseVO.success(result);

+ 1 - 0
backend/src/main/java/com/jiayue/ssi/controller/SysRoleController.java

@@ -69,6 +69,7 @@ public class SysRoleController {
             if (StringUtils.isNotEmpty(roleKey)) {
                 wrapper.like("role_key", roleKey);
             }
+            wrapper.orderByAsc("role_sort");
             Page<SysRole> result = roleService.page(new Page<>(currentPage, pageSize), wrapper);
             return ResponseVO.success(result);
         } catch (Exception e) {

+ 11 - 0
backend/src/main/java/com/jiayue/ssi/controller/SysUserController.java

@@ -16,9 +16,11 @@ import com.jiayue.ssi.config.SendMailUtil;
 import com.jiayue.ssi.constant.CustomException;
 import com.jiayue.ssi.constant.SecretKeyConstants;
 import com.jiayue.ssi.entity.SysApprove;
+import com.jiayue.ssi.entity.SysRole;
 import com.jiayue.ssi.entity.SysUser;
 import com.jiayue.ssi.entity.SysUserRole;
 import com.jiayue.ssi.service.SysApproveService;
+import com.jiayue.ssi.service.SysRoleService;
 import com.jiayue.ssi.service.SysUserRoleService;
 import com.jiayue.ssi.service.SysUserService;
 import com.jiayue.ssi.service.impl.SysPermissionService;
@@ -51,6 +53,8 @@ public class SysUserController {
     SysUserRoleService sysUserRoleService;
     @Autowired
     SysApproveService sysApproveService;
+    @Autowired
+    SysRoleService sysRoleService;
 
     /**
      * 获取用户分页信息
@@ -82,6 +86,13 @@ public class SysUserController {
             if (StringUtils.isNotEmpty(status)) {
                 wrapper.eq("status", status);
             }
+
+            SysRole sysRole = sysRoleService.selectRoleListByUserId();
+            if (!"xtgly".equals(sysRole.getRoleKey())){
+                // 业务管理员员
+                wrapper.eq("usertype", "1");
+            }
+
             Page<SysUser> result = sysUserService.page(new Page<>(currentPage, pageSize), wrapper);
             List<SysUser> records = result.getRecords();
             //遍历对象数组的方法

+ 54 - 0
backend/src/main/java/com/jiayue/ssi/entity/ForecastPowerShortTerm.java

@@ -0,0 +1,54 @@
+package com.jiayue.ssi.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import javax.validation.constraints.Digits;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+
+/**
+ * 短期预测功率实体
+ *
+ * @author zzy
+ * @version 1.0
+ * @since 2018/10/23 9:17
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName(value = "t_forecast_power_short_term")
+public class ForecastPowerShortTerm {
+    /**
+     * 主键ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private String id;
+
+
+    /**
+     * 数据生成日期
+     */
+    private Date genDate;
+
+
+    /**
+     * 预测时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Long forecastTime;
+
+
+    /**
+     * 预测数据
+     */
+    @Digits(integer = 10, fraction = 2)
+    private BigDecimal fpValue = new BigDecimal(-99);
+}

+ 1 - 1
backend/src/main/java/com/jiayue/ssi/entity/SysUser.java

@@ -67,7 +67,7 @@ public class SysUser extends BaseEntity implements UserDetails {
     private Date loginDate;
 
     /**
-     * 用户类型(0管理员、1普通用户)
+     * 用户类型(0管理员、1业务用户)
      */
     private String usertype;
 

+ 24 - 22
backend/src/main/java/com/jiayue/ssi/filter/JwtAuthenticationTokenFilter.java

@@ -25,6 +25,7 @@ import com.jiayue.ssi.util.JwtTokenUtil;
 
 /**
  * jwt过滤器
+ *
  * @author xsl
  * @since 2023/02/20
  **/
@@ -36,45 +37,44 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
     UserServiceImpl userServiceImpl;
     JwtTokenUtil jwtTokenUtil;
 
-    public JwtAuthenticationTokenFilter(UserServiceImpl userServiceImpl, JwtTokenUtil jwtTokenUtil){
+    public JwtAuthenticationTokenFilter(UserServiceImpl userServiceImpl, JwtTokenUtil jwtTokenUtil) {
         this.userServiceImpl = userServiceImpl;
         this.jwtTokenUtil = jwtTokenUtil;
     }
 
     @Override
     protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws
-        ServletException, IOException {
-         SecurityContextHolder.getContext().getAuthentication();
+            ServletException, IOException {
+        SecurityContextHolder.getContext().getAuthentication();
         String token = request.getHeader("Authorization");
         if (!StringUtils.isEmpty(token)) {
             String username = jwtTokenUtil.getUsernameFromToken(token);
-            if (username != null){
-                if (CacheConstants.LOGIN_TOKEN_MAP.get(username)==null){
+            if (username != null) {
+                if (CacheConstants.LOGIN_TOKEN_MAP.get(username) == null) {
                     ResponseInfo.doResponse(response, "登录超时,请重新登录!", 403);
                     return;
-                }
-                else{
+                } else {
                     String cacheToken = CacheConstants.LOGIN_TOKEN_MAP.get(username);
                     //内存token和当前token一致  说明是当前登陆用户访问
-                    if(!token.equals(cacheToken)){
+                    if (!token.equals(cacheToken)) {
                         ResponseInfo.doResponse(response, "账号已在另一台机器登录,请重新登录!", 403);
                         return;
                     }
                 }
             }
 
-            if (username != null && SecurityContextHolder.getContext().getAuthentication() == null){
+            if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
                 UserDetails userDetails = userServiceImpl.loadUserByUsername(username);
                 SysUser user = (SysUser) userDetails;
-                if (user.getExpDate()!=null){
+                if (user.getExpDate() != null) {
                     // 判断账号截止日期
                     Date lastDate = DateUtils.getDayLastTime(user.getExpDate());
-                    if (new Date().after(lastDate)){
+                    if (new Date().after(lastDate)) {
                         ResponseInfo.doResponse(response, "账号有效期已失效,请联系管理员!", 403);
                         return;
                     }
                 }
-                if (jwtTokenUtil.validateToken(token, userDetails)){
+                if (jwtTokenUtil.validateToken(token, userDetails)) {
                     // 将用户信息存入 authentication,方便后续校验
                     UsernamePasswordAuthenticationToken
                             authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
@@ -83,19 +83,21 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
                     SecurityContextHolder.getContext().setAuthentication(authentication);
                 }
             }
-        }
-        else{
+        } else {
             if ("POST".equalsIgnoreCase(request.getMethod()) && defaultFilterProcessUrl.equals(request.getServletPath())) {
                 // 用户名密码登录提交,判断账号有效期
-                UserDetails userDetails = userServiceImpl.loadUserByUsername(request.getParameter("username"));
-                SysUser user = (SysUser) userDetails;
-                if (user.getExpDate()!=null){
-                    // 判断账号截止日期
-                    Date lastDate = DateUtils.getDayLastTime(user.getExpDate());
-                    if (new Date().after(lastDate)){
-                        ResponseInfo.doResponse(response, "账号有效期已失效,请联系管理员!", 403);
-                        return;
+                try {
+                    UserDetails userDetails = userServiceImpl.loadUserByUsername(request.getParameter("username"));
+                    SysUser user = (SysUser) userDetails;
+                    if (user.getExpDate() != null) {
+                        // 判断账号截止日期
+                        Date lastDate = DateUtils.getDayLastTime(user.getExpDate());
+                        if (new Date().after(lastDate)) {
+                            ResponseInfo.doResponse(response, "账号有效期已失效,请联系管理员!", 403);
+                            return;
+                        }
                     }
+                } catch (Exception e) {
                 }
             }
         }

+ 30 - 0
backend/src/main/java/com/jiayue/ssi/job/FileAnalysisJob.java

@@ -0,0 +1,30 @@
+package com.jiayue.ssi.job;
+
+import com.jiayue.ssi.service.impl.FileAnalysisService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+/**
+ * 文件解析
+ *
+ * @author bizy
+ * @version 3.0
+ */
+@Slf4j
+@Service
+@EnableScheduling
+public class FileAnalysisJob {
+
+    @Autowired
+    private FileAnalysisService fileAnalysisService;
+
+    @Scheduled(cron = "0 0/1 * * * *")
+    public void fxglFileAnalysis() {
+        log.debug("文件解析定时任务执行开始");
+        fileAnalysisService.analysisJob();
+        log.debug("文件解析定时任务执行完成");
+    }
+}

+ 16 - 0
backend/src/main/java/com/jiayue/ssi/mapper/ForecastPowerShortTermMapper.java

@@ -0,0 +1,16 @@
+package com.jiayue.ssi.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jiayue.ssi.entity.ForecastPowerShortTerm;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ *  短期Mapper
+ *
+ * @author xsl
+ * @since 2023-03-10
+ */
+@Mapper
+public interface ForecastPowerShortTermMapper extends BaseMapper<ForecastPowerShortTerm> {
+
+}

+ 7 - 7
backend/src/main/java/com/jiayue/ssi/mapper/SysRoleMapper.java

@@ -50,13 +50,13 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
 //     */
 //    public List<SysRole> selectRoleAll();
 //
-//    /**
-//     * 根据用户ID获取角色选择框列表
-//     *
-//     * @param userId 用户ID
-//     * @return 选中角色ID列表
-//     */
-//    public List<Long> selectRoleListByUserId(Long userId);
+    /**
+     * 根据用户ID获取角色选择框列表
+     *
+     * @param userId 用户ID
+     * @return 选中角色ID列表
+     */
+    public SysRole selectRoleListByUserId(Long userId);
 //
 //    /**
 //     * 通过角色ID查询角色

+ 26 - 0
backend/src/main/java/com/jiayue/ssi/service/ForecastPowerShortTermService.java

@@ -0,0 +1,26 @@
+package com.jiayue.ssi.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jiayue.ssi.entity.ElectricField;
+import com.jiayue.ssi.entity.ForecastPowerShortTerm;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+
+/**
+* 短期接口
+* @author xsl
+* @date 2023/2/16
+*/
+public interface ForecastPowerShortTermService extends IService<ForecastPowerShortTerm> {
+    /**
+     * 按时间段删除数据
+     *
+     * @param startTime
+     * @param endTime
+     * @param listDq
+     */
+    void deleteBetweenAndGenTime(Long startTime, Long endTime, List<ForecastPowerShortTerm> listDq);
+}

+ 5 - 0
backend/src/main/java/com/jiayue/ssi/service/SysRoleService.java

@@ -146,6 +146,11 @@ public interface SysRoleService extends IService<SysRole> {
      * @return SysRole
      */
     SysRole queryRoleKey(String roleKey);
+    /**
+     * 根据用户id找对应的角色
+     * @return 结果
+     */
+    SysRole selectRoleListByUserId();
 //
 //    /**
 //     * 取消授权用户角色

+ 535 - 0
backend/src/main/java/com/jiayue/ssi/service/impl/FileAnalysisService.java

@@ -0,0 +1,535 @@
+package com.jiayue.ssi.service.impl;
+
+import cn.hutool.core.util.StrUtil;
+import com.jiayue.ssi.entity.ForecastPowerShortTerm;
+import com.jiayue.ssi.service.ForecastPowerShortTermService;
+import com.jiayue.ssi.util.DateUtils;
+import com.jiayue.ssi.util.FileUtil;
+import lombok.AllArgsConstructor;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.io.*;
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 解析电科院NWP和DQ文件
+ *
+ * @author cuil
+ * @version 2.0
+ * @since 2018/12/03 11:24
+ */
+
+@AllArgsConstructor
+@Service
+@Slf4j
+@Transactional
+public class FileAnalysisService {
+
+    @Autowired
+    ForecastPowerShortTermService forecastPowerShortTermService;
+
+    @SneakyThrows
+    public void analysisJob() {
+        log.info("-----------------开始执行文件解析任务----------------------");
+        long timeD = 15 * 60 * 1000;
+        Long currentDate = DateUtils.getDayStartTime(new Date()).getTime();//今日凌晨
+        boolean flag = false;
+        // 路径
+        String path = FileUtil.getAnalysisPath() + File.separator + "new";
+
+        File dirFile = new File(path);
+        //判断该目录是否存在,不存在时创建
+        if (!dirFile.exists()) {
+            dirFile.mkdirs();
+            log.info("【" + dirFile.getPath() + "】目录不存在,系统自动创建文件目录");
+        }
+        log.info("系统扫描路径【" + dirFile.getPath() + "】");
+
+        Collection<File> files = FileUtils.listFiles(dirFile, new String[]{"RB", "txt"}, false);
+        String dayStr = new SimpleDateFormat("yyyyMMdd").format(new Date());//当前时间格式化为年月日
+        if (files != null && files.size() > 0) {
+            for (File file : files) {
+                flag = false;
+                String fileName = file.getName();
+                if (fileName.indexOf(dayStr) < 0) {
+                    file.delete();
+                    log.warn(fileName + "不是当天的文件,删除!");
+                    break;
+                }
+                if (fileName.length() < 30) {
+                    if (file.getName().startsWith("DQ")) {
+                        try {
+                            List<ForecastPowerShortTerm> listDq = fileAnalysisShortTerm(file, currentDate);
+                            ForecastPowerShortTerm forecastPowerShortTerm = null;
+                            if (listDq != null && listDq.size() > 0) {
+                                //如果数据不全,进行补入
+                                while (listDq.get(listDq.size() - 1).getForecastTime() <  currentDate + 4 * 24 * 60 * 60 * 1000 - timeD) {
+                                    forecastPowerShortTerm = new ForecastPowerShortTerm();
+                                    forecastPowerShortTerm.setFpValue(listDq.get(listDq.size() - 96).getFpValue());//修正前值
+                                    forecastPowerShortTerm.setGenDate(new Date()); //装机容量
+                                    forecastPowerShortTerm.setForecastTime(currentDate);
+                                    listDq.add(forecastPowerShortTerm);
+                                }
+
+                                try {
+                                    //短期数据修正
+                                    Long startTime = listDq.get(0).getForecastTime();
+                                    Long endTime = listDq.get(listDq.size() - 1).getForecastTime();//删除相同时间数据
+                                    forecastPowerShortTermService.deleteBetweenAndGenTime(startTime, endTime, listDq);
+                                    flag = true;
+                                } catch (Exception e) {
+                                    log.error("保存短期数据报错", e);
+                                    flag = false;
+                                }
+                            } else {
+                                log.info(file.getName() + "文件数据内容为空、不能正常解析 、移除该文件、执行数据修正功能");
+                                flag = false;
+                            }
+                        } catch (Exception e) {
+                            flag = false;
+                            log.error("解析DQ文件失败", e);
+                        }
+                    }
+
+                    //用于解析一体化数据,将解析出的数据保存短期历史表和一体化实时表
+//                    if (file.getName().startsWith("NWP")) {
+//                        try {
+//                            List<Nwp> listNwp = fileAnalysisNwp(file);
+//                            Nwp nwpData = null;
+//                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+//                            if (listNwp != null && listNwp.size() > 0) {
+//                                while (listNwp.get(listNwp.size() - 1).getPreTime() < DateTimeUtil.getMillisecondsSubDay() + 4 * 24 * 60 * 60 * 1000 - timeD) {
+//                                    nwpData = new Nwp();
+//                                    long time = 0;
+//                                    try {
+//                                        time = sdf.parse(listNwp.get(listNwp.size() - 96).getPreDate()).getTime() + 24 * 60 * 60 * 1000;
+//                                    } catch (ParseException e) {
+//                                        e.printStackTrace();
+//                                    }
+//                                    nwpData.setFarmId(listNwp.get(listNwp.size() - 96).getFarmId());
+//                                    nwpData.setScDate(listNwp.get(listNwp.size() - 96).getScDate());
+//                                    nwpData.setScTime(listNwp.get(listNwp.size() - 96).getScTime());
+//                                    nwpData.setPreDate(sdf.format(time));
+//                                    nwpData.setPreTime(listNwp.get(listNwp.size() - 1).getPreTime() + timeD);
+//                                    nwpData.setT(listNwp.get(listNwp.size() - 96).getT());//温度
+//                                    nwpData.setRh(listNwp.get(listNwp.size() - 96).getRh());//湿度
+//                                    nwpData.setPressure(listNwp.get(listNwp.size() - 96).getPressure());//气压
+//                                    nwpData.setSwr(listNwp.get(listNwp.size() - 96).getSwr());//辐射
+//                                    nwpData.setLwr(listNwp.get(listNwp.size() - 96).getLwr());//辐射
+//                                    nwpData.setDiffuseRadiation(listNwp.get(listNwp.size() - 96).getDiffuseRadiation());//散接辐射
+//                                    nwpData.setDirectRadiation(listNwp.get(listNwp.size() - 96).getDirectRadiation());//直接辐射
+//
+//                                    nwpData.setSenf(listNwp.get(listNwp.size() - 96).getSenf());//热感通量
+//
+//                                    nwpData.setWs10(listNwp.get(listNwp.size() - 96).getWs10());//10 m 风速
+//                                    nwpData.setWs30(listNwp.get(listNwp.size() - 96).getWs30());//30 m 风速
+//                                    nwpData.setWs50(listNwp.get(listNwp.size() - 96).getWs50());//50 m 风速
+//                                    nwpData.setWs70(listNwp.get(listNwp.size() - 96).getWs70());//70 m 风速
+//                                    nwpData.setWs80(listNwp.get(listNwp.size() - 96).getWs80());//80 m 风速
+//                                    nwpData.setWs90(listNwp.get(listNwp.size() - 96).getWs90());//90 m 风速
+//                                    nwpData.setWs100(listNwp.get(listNwp.size() - 96).getWs100());//100 m 风速
+//                                    nwpData.setWs170(listNwp.get(listNwp.size() - 96).getWs170());//170 m 风速
+//
+//                                    nwpData.setWd10(listNwp.get(listNwp.size() - 96).getWd10());//10 m 风向
+//                                    nwpData.setWd30(listNwp.get(listNwp.size() - 96).getWd30());//30 m 风向
+//                                    nwpData.setWd50(listNwp.get(listNwp.size() - 96).getWd50());//50 m 风向
+//                                    nwpData.setWd70(listNwp.get(listNwp.size() - 96).getWd70());//70 m 风向
+//                                    nwpData.setWd80(listNwp.get(listNwp.size() - 96).getWd80());//80 m 风向
+//                                    nwpData.setWd90(listNwp.get(listNwp.size() - 96).getWd90());//90 m 风向
+//                                    nwpData.setWd100(listNwp.get(listNwp.size() - 96).getWd100());//100 m 风向
+//                                    nwpData.setWd170(listNwp.get(listNwp.size() - 96).getWd170());//170 m 风向
+//                                    listNwp.add(nwpData);
+//                                }
+//                            } else {
+//                                flag = false;
+//                                log.info(file.getName() + "文件数据内容为空、不能正常解析 、移除该文件、执行数据修正功能");
+//                            }
+//
+//                            //保存NWP实时数据
+//                            Long startTime = listNwp.get(0).getPreTime();
+//                            Long endTime = listNwp.get(listNwp.size() - 1).getPreTime();//删除相同时间数据
+//                            nwpService.deleteBetweenAndPreTime(startTime, endTime, listNwp);
+//                            flag = true;
+//                        } catch (Exception e) {
+//                            log.error("解析NWP文件失败", e);
+//                            flag = false;
+//                        }
+//                    }
+
+                    if (flag) {
+                        //移除文件备份到临时文件下
+                        moveFile(file);
+                    } else {
+                        //移除文件备份到error文件下
+                        moveFileError(file);
+                    }
+                }
+            }
+        }
+        log.info("-----------------执行文件解析任务完成----------------------");
+    }
+
+    public static void mvFile(File file, String fdPath) {
+        try {
+            FileUtils.copyFile(file, new File(fdPath), true);
+        } catch (IOException e) {
+            log.error("文件移动错误", e);
+        }
+    }
+
+//    /**
+//     * NWP解析
+//     *
+//     * @param file 文件路径
+//     * @return 样例集合
+//     */
+//    private List<Nwp> fileAnalysisNwp(File file) {
+//        List<Nwp> listNwp = new ArrayList<>();
+//        if (file.renameTo(file)) {
+//            InputStreamReader readNwp = null;
+//            BufferedReader bufferedReaderNwp = null;
+//            try {
+//                readNwp = new InputStreamReader(new FileInputStream(file), "utf-8");//考虑到编码格式
+//                bufferedReaderNwp = new BufferedReader(readNwp);
+//                String fileName = file.getName();
+//                fileName = fileName.substring(fileName.indexOf("_") + 1, fileName.lastIndexOf("."));
+//                String lineTxt;
+//                Nwp nwpData = null;
+//                BigDecimal nwpDirectRadiation = new BigDecimal(0.7); //直接辐射
+//                BigDecimal nwpDiffuseRadiation = new BigDecimal(0.3); //散接辐射
+//
+//                while ((lineTxt = bufferedReaderNwp.readLine()) != null) {
+//                    //NWP文件按照Tab方式截取
+//                    String[] datas = lineTxt.split("\t");
+//                    if (datas.length >= 35 && datas[0].startsWith("#")) {
+//                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//                        if (datas != null && datas.length > 0) {
+//                            //过滤当天的数据
+//                            //if (sdf.parse(datas[5]).getTime() >= TimeUtils.getMillisecondsSubDay() + 24 * 60 * 60 *
+//                            // 1000) {
+//                            nwpData = new Nwp();
+//
+//                            //将截取的文件放入nwpData中
+//                            nwpData.setFarmId(datas[1]);
+//                            nwpData.setScDate(datas[2]);
+//                            nwpData.setScTime(datas[3]);
+//                            nwpData.setPreDate(datas[4]);
+//                            nwpData.setPreTime(sdf.parse(datas[5]).getTime());//采集时间 与 短期预测时间关联
+//                            nwpData.setT(NumberUtils.subtract(new BigDecimal(datas[6]), new BigDecimal(273.15)));//温度
+//
+//                            nwpData.setSenf(new BigDecimal(datas[11]).setScale(2, RoundingMode.HALF_UP));//感热
+//                            nwpData.setSwr(new BigDecimal(datas[9]).setScale(2, RoundingMode.HALF_UP));//短波辐射(相当于总辐射)
+//                            nwpData.setLwr(new BigDecimal(datas[10]).setScale(2, RoundingMode.HALF_UP));//短波辐射(相当于总辐射)
+//                            nwpData.setPressure(new BigDecimal(datas[8]).setScale(2, RoundingMode.HALF_UP));//地表气压
+//                            nwpData.setRh(new BigDecimal(datas[7]).setScale(2, RoundingMode.HALF_UP));//2m相对湿度
+//                            nwpData.setDiffuseRadiation(new BigDecimal(datas[9]).multiply(nwpDiffuseRadiation).setScale(2, RoundingMode.HALF_UP));//散接辐射
+//                            nwpData.setDirectRadiation(new BigDecimal(datas[9]).multiply(nwpDirectRadiation).setScale(2, RoundingMode.HALF_UP));//直接辐射
+//
+//                            nwpData.setWs10(new BigDecimal(datas[19]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWs30(new BigDecimal(datas[20]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWs50(new BigDecimal(datas[21]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWs70(new BigDecimal(datas[22]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWs80(new BigDecimal(datas[23]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWs90(new BigDecimal(datas[24]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWs100(new BigDecimal(datas[25]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWs170(new BigDecimal(datas[26]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWd10(new BigDecimal(datas[27]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWd30(new BigDecimal(datas[28]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWd50(new BigDecimal(datas[29]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWd70(new BigDecimal(datas[30]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWd80(new BigDecimal(datas[31]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWd90(new BigDecimal(datas[32]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWd100(new BigDecimal(datas[33]).setScale(2, RoundingMode.HALF_UP));
+//                            nwpData.setWd170(new BigDecimal(datas[34]).setScale(2, RoundingMode.HALF_UP));
+//                            listNwp.add(nwpData);
+//                            //}
+//                        }
+//                    }
+//                }
+//            } catch (IOException | ParseException | RuntimeException e) {
+//                log.error("系统错误:", e);
+//                // 进行告警
+//                String name = "NWP文件解析失败";
+//                String describe = "请查看NWP文件格式是否正常";
+////                String errorInfo = CommonUtil.printStackTraceToString(e);
+//                String solution = "请修改NWP文件内容";
+////                super.saveSysAlarm(SysAlarmTypeEnum.Other.name(), name, describe, SysAlarmPritorityEnum
+////                .AlarmPritorityLow.name(), errorInfo, solution);
+//                File destFile = new File(file.getPath().replaceFirst("new", "error"));
+//                if (destFile.exists()) {
+//                    destFile.delete();
+//                }
+//                try {
+//                    FileUtils.moveFile(file, destFile);
+//                } catch (IOException e1) {
+//                    log.error(file.getName() + "文件解析失败", e);
+//                }
+//            } finally {
+//                close(bufferedReaderNwp, readNwp);
+//            }
+//        }
+//        return listNwp;
+//    }
+
+    /**
+     * update文件解析
+     *
+     * @param file 文件路径
+     * @return 样例集合
+     */
+    private List<String> fileAnalysisUP(File file) {
+        List<String> sqlList = new ArrayList<>();
+
+        if (file.renameTo(file)) {
+            InputStreamReader readup = null;
+            BufferedReader bufferedReaderup = null;
+            try {
+                readup = new InputStreamReader(new FileInputStream(file), "utf-8");//考虑到编码格式
+                bufferedReaderup = new BufferedReader(readup);
+                String lineTxt;
+                while ((lineTxt = bufferedReaderup.readLine()) != null) {
+                    if (!lineTxt.startsWith("<")) {
+                        if (lineTxt.startsWith("//") || lineTxt.startsWith("@@")) {
+                            lineTxt = lineTxt.substring(2);
+                        }
+                        sqlList.add(StrUtil.trim(lineTxt));
+                    }
+                }
+            } catch (IOException e) {
+                log.error("系统错误:", e);
+                File destFile = new File(file.getPath().replaceFirst("new", "error"));
+                if (destFile.exists()) {
+                    destFile.delete();
+                }
+                try {
+                    FileUtils.moveFile(file, destFile);
+                } catch (IOException e1) {
+                    log.error(file.getName() + "文件解析失败", e);
+                }
+            } finally {
+                close(bufferedReaderup, readup);
+            }
+        } else {
+            log.error("当前配置文件没有读权限:{}", file.getAbsoluteFile());
+        }
+        return sqlList;
+    }
+
+    private List<String> fileAnalysisUP(File file, String v) {
+        List<String> sqlList = new ArrayList<>();
+        if (file.renameTo(file)) {
+            InputStreamReader readup = null;
+            BufferedReader bufferedReaderup = null;
+            try {
+                readup = new InputStreamReader(new FileInputStream(file), "utf-8");//考虑到编码格式
+                bufferedReaderup = new BufferedReader(readup);
+                String lineTxt;
+                while ((lineTxt = bufferedReaderup.readLine()) != null) {
+                    if (lineTxt.startsWith("#")) {
+                        sqlList.add(StrUtil.trim(lineTxt));
+                    }
+                }
+            } catch (IOException e) {
+                log.error("系统错误:", e);
+                File destFile = new File(file.getPath().replaceFirst("new", "error"));
+                if (destFile.exists()) {
+                    destFile.delete();
+                }
+                try {
+                    FileUtils.moveFile(file, destFile);
+                } catch (IOException e1) {
+                    log.error(file.getName() + "文件解析失败", e);
+                }
+            } finally {
+                close(bufferedReaderup, readup);
+            }
+        }
+        return sqlList;
+    }
+
+    /**
+     * 短期解析
+     *
+     * @param file        文件路径
+     * @param currentDate 当前时间
+     * @return 样例集合
+     */
+    private List<ForecastPowerShortTerm> fileAnalysisShortTerm(File file, Long currentDate) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        List<ForecastPowerShortTerm> forecastPowerShortTerm = new ArrayList<>();
+        // 当文件未被使用时,进行解析上报
+        if (file.renameTo(file)) {
+            InputStreamReader read = null;
+            BufferedReader bufferedReader = null;
+            String stringLine;
+            ForecastPowerShortTerm stf;
+            try {
+                read = new InputStreamReader(new FileInputStream(file), "utf-8");
+                bufferedReader = new BufferedReader(read);
+                while ((stringLine = bufferedReader.readLine()) != null) {
+                    String[] string_arr = stringLine.split("\t");
+                    if (string_arr.length == 4 && string_arr[0].startsWith("#")) {
+                        if (StringUtils.isNotEmpty(string_arr[2])) {
+                            //过滤当天的数据
+                            //if (sdf.parse(string_arr[2]).getTime() >= TimeUtils.getMillisecondsSubDay() + 24 * 60 *
+                            // 60 * 1000) {
+                            stf = new ForecastPowerShortTerm();
+                            stf.setFpValue(new BigDecimal(string_arr[3] + ""));
+                            stf.setForecastTime(sdf.parse(string_arr[2]).getTime());
+                            stf.setGenDate(new Date(currentDate));
+                            forecastPowerShortTerm.add(stf);
+                            // }
+                        }
+                    }
+                }
+            } catch (IOException | ParseException | RuntimeException e) {
+                log.error("系统错误:", e);
+                File destFile = new File(file.getPath().replaceFirst("new", "error"));
+                if (destFile.exists()) {
+                    destFile.delete();
+                }
+                try {
+                    FileUtils.moveFile(file, destFile);
+                } catch (IOException e1) {
+                    log.error(file.getName() + "文件解析失败", e);
+                }
+            } finally {
+                close(bufferedReader, read);
+            }
+        }
+        return forecastPowerShortTerm;
+    }
+
+
+    /**
+     * 移动文件到临时目录下
+     *
+     * @param file 文件
+     */
+    private void moveFile(File file) {
+        // 移动文件到处理目录
+        File destFile = new File(file.getPath().replaceFirst("new", "backupsTemp"));
+        log.info("move file :{}, dest file:{}", file, destFile);
+        if (destFile.exists()) {
+            destFile.delete();
+        }
+        try {
+            FileUtils.moveFile(file, destFile);
+        } catch (IOException e) {
+            log.error("系统移除文件错误:", e);
+            // 进行告警
+//      String name = file.getName();
+//      String describe = "移除" + name + "失败";
+//      String errorInfo = CommonUtil.printStackTraceToString(e);
+//      String solution = "";
+//      super.saveSysAlarm(SysAlarmTypeEnum.Other.name(), name, describe, SysAlarmPritorityEnum.AlarmPritorityLow
+//      .name(), errorInfo, solution);
+        }
+        moveFileBackups(destFile.getParent());
+    }
+
+    /**
+     * 移动文件到处理目录
+     *
+     * @param filePath 文件路径
+     */
+    private void moveFileBackups(String filePath) {
+        String targetRoot = filePath.replaceFirst("backupsTemp", "backups");
+        String path = mkDirForTime(targetRoot, null);
+        path = mkDirForTime(path, "yyyy");
+        path = mkDirForTime(path, "MM");
+        path = mkDirForTime(path, "yyyyMMdd");
+        path = mkDirForTime(path, "HHmm");
+        // 移动文件夹内容
+        File sourceFile = new File(filePath);
+        if (sourceFile.exists()) {
+            try {
+                File[] files = sourceFile.listFiles();
+                if (files != null && files.length > 0) {
+                    for (File f : files) {
+                        if (f.renameTo(new File(path + f.getName()))) {
+                            log.info("move file :{}, dest file:{}", path, f.getName());
+                        }
+                    }
+                }
+            } catch (Exception e) {
+            }
+        }
+    }
+
+    /**
+     * 移动文件到处理错误目录下
+     *
+     * @param file 文件
+     */
+    private void moveFileError(File file) {
+        File destFile = new File(file.getPath().replaceFirst("new", "error"));
+        if (destFile.exists()) {
+            destFile.delete();
+        }
+        try {
+            FileUtils.moveFile(file, destFile);
+        } catch (IOException e) {
+            log.error(file.getName() + "文件解析失败", e);
+        }
+    }
+
+    /**
+     * 创建备份文件夹
+     *
+     * @param targetRoot
+     * @param format
+     * @return
+     */
+    public static String mkDirForTime(String targetRoot, String format) {
+        String path = null;
+        File file = null;
+        if (StringUtils.isNotEmpty(format)) {
+            Long current = System.currentTimeMillis();
+            path = DateFormatUtils.format(current, format);
+            file = new File(targetRoot + File.separator + path + File.separator);
+
+        } else {
+            file = new File(targetRoot + File.separator);
+        }
+
+        if (!file.exists() && !file.isFile()) {
+
+            if (file.mkdir()) {
+                log.info("已创建文件夹");
+            } else {
+                log.info("创建文件夹失败,路径:" + file.getPath());
+            }
+        }
+        return file.getPath() + File.separator;
+    }
+
+    /**
+     * 关闭文件流
+     *
+     * @param bufferedReader 字符数据
+     * @param read           字节流
+     */
+    private void close(BufferedReader bufferedReader, InputStreamReader read) {
+        try {
+            if (bufferedReader != null) {
+                bufferedReader.close();
+            }
+            if (read != null) {
+                read.close();
+            }
+        } catch (IOException e) {
+            log.error("关闭文件流失败:", e);
+        }
+    }
+}

+ 40 - 0
backend/src/main/java/com/jiayue/ssi/service/impl/ForecastPowerShortTermServiceImpl.java

@@ -0,0 +1,40 @@
+package com.jiayue.ssi.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jiayue.ssi.entity.ForecastPowerShortTerm;
+import com.jiayue.ssi.mapper.ForecastPowerShortTermMapper;
+import com.jiayue.ssi.service.ForecastPowerShortTermService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import java.util.List;
+
+
+@Service
+@Slf4j
+public class ForecastPowerShortTermServiceImpl extends ServiceImpl<ForecastPowerShortTermMapper, ForecastPowerShortTerm> implements ForecastPowerShortTermService {
+  @Autowired
+  ForecastPowerShortTermMapper forecastPowerShortTermMapper;
+
+  /**
+   * 按时间段删除数据
+   *
+   * @param startTime
+   * @param endTime
+   * @param listDq
+   */
+  @Transactional(propagation = Propagation.REQUIRED)
+  @Override
+  public void deleteBetweenAndGenTime(Long startTime, Long endTime, List<ForecastPowerShortTerm> listDq) {
+    QueryWrapper wrapper = new QueryWrapper<>();
+    wrapper.ge("forecast_time",startTime);
+    wrapper.le("forecast_time",endTime);
+    this.remove(wrapper);
+    //保存短期数据
+    this.saveBatch(listDq);
+  }
+
+}

+ 11 - 0
backend/src/main/java/com/jiayue/ssi/service/impl/SysRoleServiceImpl.java

@@ -178,4 +178,15 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
         roleMenuMapper.deleteRoleMenuByRoleId(username, roleId);
         return roleMapper.deleteRoleById(username, roleId);
     }
+
+    /**
+     * 根据用户id找对应的角色
+     * @return 结果
+     */
+    @Override
+    public SysRole selectRoleListByUserId() {
+        Long userId = SecurityContextUtil.getSysUser().getId();
+        SysRole sysRole = roleMapper.selectRoleListByUserId(userId);
+        return sysRole;
+    }
 }

+ 8 - 1
backend/src/main/java/com/jiayue/ssi/util/FileUtil.java

@@ -98,7 +98,14 @@ public class FileUtil {
 
     return pathStr;
   }
-
+  /**
+   * 获取解析目录路径
+   *
+   * @return
+   */
+  public static String getAnalysisPath() {
+    return createDir("analysis");
+  }
   /**
    * 获取日志目录路径
    *

+ 8 - 5
backend/src/main/resources/mapper/system/SysRoleMapper.xml

@@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="menuCheckStrictly"  column="menu_check_strictly"   />
 		<result property="deptCheckStrictly"  column="dept_check_strictly"   />
 		<result property="status"             column="status"                />
+		<result property="roleType"             column="role_type"                />
 		<result property="delFlag"            column="del_flag"              />
 		<result property="createBy"           column="create_by"             />
 		<result property="createTime"         column="create_time"           />
@@ -23,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 	<sql id="selectRoleVo">
 	    select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly,
-            r.status, r.del_flag, r.create_time, r.remark
+            r.status, r.del_flag, r.create_time, r.remark,r.role_type
         from sys_role r
 -- 	        left join sys_user_role ur on ur.role_id = r.role_id
 -- 	        left join sys_user u on u.user_id = ur.user_id
@@ -65,12 +66,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<include refid="selectRoleVo"/>
 	</select>
 
-	<select id="selectRoleListByUserId" parameterType="Long" resultType="Long">
-		select r.role_id
+	<select id="selectRoleListByUserId" parameterType="Long" resultMap="SysRoleResult">
+		select r.*
         from sys_role r
 	        left join sys_user_role ur on ur.role_id = r.role_id
-	        left join sys_user u on u.user_id = ur.user_id
-	    where u.user_id = #{userId}
+	        left join sys_user u on u.id = ur.user_id
+	    where u.id = #{userId}
 	</select>
 
 	<select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult">
@@ -103,6 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="menuCheckStrictly != null">menu_check_strictly,</if>
  			<if test="deptCheckStrictly != null">dept_check_strictly,</if>
  			<if test="status != null and status != ''">status,</if>
+ 			<if test="roleType != null and roleType != ''">role_type,</if>
  			<if test="remark != null and remark != ''">remark,</if>
  			<if test="createBy != null and createBy != ''">create_by,</if>
  			create_time,
@@ -116,6 +118,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
  			<if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
  			<if test="status != null and status != ''">#{status},</if>
+ 			<if test="roleType != null and roleType != ''">#{roleType},</if>
  			<if test="remark != null and remark != ''">#{remark},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
  			sysdate(),

+ 8 - 3
ui/src/views/auditManager/operlog/index.vue

@@ -150,7 +150,6 @@
         </vxe-table-column>
       </vxe-table>
       <vxe-pager
-        v-show="showTable"
         perfect
         :current-page.sync="currentPage"
         :page-size.sync="pageSize"
@@ -233,8 +232,8 @@ export default {
       ],
       ///** 审计类型(0=系统,1=业务) */
       auditTypeOptions: [
-        {value: '0', label: '系统'},
-        {value: '1', label: '业务'}
+        // {value: '0', label: '系统'},
+        // {value: '1', label: '业务'}
       ],
       statusOptions: [
         {value: '0', label: '成功'},
@@ -272,6 +271,12 @@ export default {
     };
   },
   created() {
+    // 获取审计类型
+    this.$axios.get('/sysOperlogController/getAuditType').then((res) => {
+      this.auditTypeOptions = res.data
+    }).catch((error) => {
+    })
+
     this.getList();
   },
   methods: {

+ 1 - 1
ui/src/views/sysManager/roleManager/index.vue

@@ -94,7 +94,7 @@
         :radio-config="{trigger: 'row'}"
       >
         <vxe-column type="radio" width="60"/>
-        <vxe-table-column field="roleId" title="角色编号"/>
+<!--        <vxe-table-column field="roleId" title="角色编号"/>-->
         <vxe-table-column field="roleName" title="角色名称"/>
         <vxe-table-column field="roleType" title="类型" :formatter="typeFormat"/>
         <vxe-table-column field="roleKey" title="字符标识"/>

+ 8 - 2
ui/src/views/sysManager/userManager/index.vue

@@ -286,7 +286,7 @@ export default {
       ],
       typeOptions: [
         {value: '0', label: '管理员'},
-        {value: '1', label: '普通用户'}
+        {value: '1', label: '业务用户'}
       ],
       // 遮罩层
       loading: true,
@@ -750,7 +750,13 @@ export default {
       if (_selectData.length==1){
         roleid = _selectData[0].roleId
       }
-
+      else{
+        this.$message({
+          type: 'warning',
+          message: '请选择角色!'
+        });
+        return
+      }
       // 提交后台角色分配
       const param = {
         userId: this.jsuserid,