Quellcode durchsuchen

一体化云端:
外网接口修改
1.短期原始数据可查历史
2.短期原始数据可查多个场站
3.新增nwp原始文件下载

zhangchenglong vor 1 Jahr
Ursprung
Commit
0333669db4

+ 21 - 2
in-cloud/src/main/java/com/jiayue/insu/incloud/constants/CommonStant.java

@@ -15,6 +15,16 @@ public interface CommonStant {
     String RECORD_TYPE_PULL_INIT = "PULL_INIT";
 
     /**
+     * 日志类型:下拉原始数据
+     */
+    String RECORD_TYPE_PULL_NWP_INIT = "PULL_NWP_INIT";
+
+    /**
+     * 日志类型:下拉原始超短期数据
+     */
+    String RECORD_TYPE_PULL_CDQ = "PULL_INIT_CDQ";
+
+    /**
      * 日志类型:推送原始
      */
     String RECORD_TYPE_PUSH_INIT = "PUSH_INIT";
@@ -30,7 +40,17 @@ public interface CommonStant {
     String RECORD_TYPE_PULL_CORRECT = "PULL_CORRECT";
 
     /**
-     * 日志类型:下拉修正数据
+     * 日志类型:接收修正短期数据
+     */
+    String RECORD_TYPE_PUT_DQ_CORRECT = "PULL_PUT_DQ_CORRECT";
+
+    /**
+     * 日志类型:接收修正超短期数据
+     */
+    String RECORD_TYPE_PUT_CDQ_CORRECT = "PULL_PUT_CDQ_CORRECT";
+
+    /**
+     * 日志类型:推送修正数据到minIo
      */
     String RECORD_TYPE_PUSH_CORRECT_TO_MIN_IO = "PUSH_CORRECT_TO_MIN_IO";
 
@@ -136,5 +156,4 @@ public interface CommonStant {
      */
     String AUTHORIZATION = "Authorization";
 
-
 }

+ 1 - 1
in-cloud/src/main/java/com/jiayue/insu/incloud/constants/enums/StatusEnum.java

@@ -14,7 +14,7 @@ public enum StatusEnum {
     CREATE_FILE_FAIL("create_file_fail","create_file_fail","生成文件失败"),
     PUSH_URL_ERROR("push_url_error","push_url_error","推送sftp地址/端口错误"),
     DOWNLOAD_FILE_ERROR("response_fail","response_fail","下载文件异常"),
-    FILE_NULL("file_null","file_null","文件为空"),
+    FILE_NULL("file_null","file_null","下载文件为空"),
     STATION_CODE_NULL("station_code_null","station_code_null","场站编码为空"),
 
 

+ 118 - 38
in-cloud/src/main/java/com/jiayue/insu/incloud/controller/ApiController.java

@@ -1,5 +1,6 @@
 package com.jiayue.insu.incloud.controller;
 
+import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import com.jiayue.insu.incloud.constants.CommonStant;
 import com.jiayue.insu.incloud.entity.Record;
@@ -15,6 +16,7 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.time.LocalDateTime;
+import java.util.Map;
 
 /**
  * 对外接口
@@ -49,13 +51,13 @@ public class ApiController {
         JSONObject checkResult = checkAuthorization(request);
         // 如果校验结果为失败
         if (JsonResultUtil.Type.failure.value().equals(checkResult.get(JsonResultUtil.CODE_TAG))) {
-            Record record = new Record(CommonStant.RECORD_TYPE_COM_PERMISSON,"CSGS",null,null,LocalDateTime.now(),LocalDateTime.now(),JsonResultUtil.Type.failure.msg(),JsonResultUtil.Type.failure.value());
+            Record record = new Record(CommonStant.RECORD_TYPE_COM_PERMISSON,null,null,null,LocalDateTime.now(),LocalDateTime.now(),JsonResultUtil.Type.failure.msg(),JsonResultUtil.Type.failure.value());
             recordService.save(record);
-            return JsonResultUtil.failure();
+            return checkResult;
         }
         // 根据用户名密码获取token
         JSONObject result = apiService.getToken(checkResult.getJSONObject(JsonResultUtil.DATA_TAG));
-        Record record = new Record(CommonStant.RECORD_TYPE_COM_PERMISSON,"CSGS",null,null,LocalDateTime.now(),LocalDateTime.now(),result.getStr(JsonResultUtil.MSG_TAG),result.getStr(JsonResultUtil.CODE_TAG));
+        Record record = new Record(CommonStant.RECORD_TYPE_COM_PERMISSON,null,null,null,LocalDateTime.now(),LocalDateTime.now(),result.getStr(JsonResultUtil.MSG_TAG),result.getStr(JsonResultUtil.CODE_TAG));
         recordService.save(record);
         return result;
     }
@@ -68,17 +70,44 @@ public class ApiController {
      */
     @PostMapping("/getShortWpfData")
     public JSONObject getShortWpfData(HttpServletRequest request, @RequestBody JSONObject data) {
+        Station station = new Station();
         // 入参验证
-        JSONObject checkResult = checkRequest(request,data);
+        JSONObject checkResult = checkRequest(request,data,station);
+        String inCode = getInCode(station);
         // 如果校验结果为失败
         if (JsonResultUtil.Type.failure.value().equals(checkResult.get(JsonResultUtil.CODE_TAG))) {
-            Record record = new Record(CommonStant.RECORD_TYPE_PULL_INIT,"CSGS",data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),JsonResultUtil.Type.failure.msg(),JsonResultUtil.Type.failure.value());
+            Record record = new Record(CommonStant.RECORD_TYPE_PULL_INIT,inCode,data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),JsonResultUtil.Type.failure.msg(),JsonResultUtil.Type.failure.value());
             recordService.save(record);
-            return JsonResultUtil.failure();
+            return checkResult;
         }
         // 返回短期数据json格式
         JSONObject result = apiService.getShortWpfData(data);
-        Record record = new Record(CommonStant.RECORD_TYPE_PULL_INIT,"CSGS",data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),result.getStr(JsonResultUtil.MSG_TAG),result.getStr(JsonResultUtil.CODE_TAG));
+        Record record = new Record(CommonStant.RECORD_TYPE_PULL_INIT,inCode,data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),result.getStr(JsonResultUtil.MSG_TAG),result.getStr(JsonResultUtil.CODE_TAG));
+        recordService.save(record);
+        return result;
+    }
+
+    /**
+     * 获取nwp原始数据
+     *
+     * @param request
+     * @return
+     */
+    @PostMapping("/getNwpData")
+    public JSONObject getNwpData(HttpServletRequest request, @RequestBody JSONObject data) {
+        Station station = new Station();
+        // 入参验证
+        JSONObject checkResult = checkRequest(request,data,station);
+        String inCode = getInCode(station);
+        // 如果校验结果为失败
+        if (JsonResultUtil.Type.failure.value().equals(checkResult.get(JsonResultUtil.CODE_TAG))) {
+            Record record = new Record(CommonStant.RECORD_TYPE_PULL_NWP_INIT,inCode,data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),JsonResultUtil.Type.failure.msg(),JsonResultUtil.Type.failure.value());
+            recordService.save(record);
+            return checkResult;
+        }
+        // 返回短期数据json格式
+        JSONObject result = apiService.getNwpData(data);
+        Record record = new Record(CommonStant.RECORD_TYPE_PULL_NWP_INIT,inCode,data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),result.getStr(JsonResultUtil.MSG_TAG),result.getStr(JsonResultUtil.CODE_TAG));
         recordService.save(record);
         return result;
     }
@@ -91,16 +120,18 @@ public class ApiController {
      */
     @PostMapping("/putShortWpfData")
     public JSONObject putShortWpfData(HttpServletRequest request, @RequestBody JSONObject data) {
+        Station station = new Station();
         // 入参验证
-        JSONObject checkResult = checkRequest(request,data);
+        JSONObject checkResult = checkRequest(request,data,station);
+        String inCode = getInCode(station);
         // 如果校验结果为失败
         if (JsonResultUtil.Type.failure.value().equals(checkResult.get(JsonResultUtil.CODE_TAG))) {
-            Record record = new Record(CommonStant.RECORD_TYPE_PULL_CORRECT,"CSGS",data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),JsonResultUtil.Type.failure.msg(),JsonResultUtil.Type.failure.value());
+            Record record = new Record(CommonStant.RECORD_TYPE_PUT_DQ_CORRECT,inCode,data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),JsonResultUtil.Type.failure.msg(),JsonResultUtil.Type.failure.value());
             recordService.save(record);
-            return JsonResultUtil.failure();
+            return checkResult;
         }
         JSONObject result = apiService.putShortWpfData(data);
-        Record record = new Record(CommonStant.RECORD_TYPE_PULL_CORRECT,"CSGS",data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),result.getStr(JsonResultUtil.MSG_TAG),result.getStr(JsonResultUtil.CODE_TAG));
+        Record record = new Record(CommonStant.RECORD_TYPE_PUT_DQ_CORRECT,inCode,data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),result.getStr(JsonResultUtil.MSG_TAG),result.getStr(JsonResultUtil.CODE_TAG));
         recordService.save(record);
         // 返回短期数据json格式
         return result;
@@ -114,14 +145,21 @@ public class ApiController {
      */
     @PostMapping("/getSShortWpfData")
     public JSONObject getSShortWpfData(HttpServletRequest request, @RequestBody JSONObject data) {
-        //校验token
-        JSONObject checkResult = checkToken(request);
+        Station station = new Station();
+        // 入参验证
+        JSONObject checkResult = checkRequest(request,data,station);
+        String inCode = getInCode(station);
         // 如果校验结果为失败
         if (JsonResultUtil.Type.failure.value().equals(checkResult.get(JsonResultUtil.CODE_TAG))) {
-            return JsonResultUtil.failure();
+            Record record = new Record(CommonStant.RECORD_TYPE_PULL_CDQ,inCode,data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),JsonResultUtil.Type.failure.msg(),JsonResultUtil.Type.failure.value());
+            recordService.save(record);
+            return checkResult;
         }
         // 返回超短期数据json格式
-        return apiService.getSShortWpfData(data);
+        JSONObject result =apiService.getSShortWpfData(data);
+        Record record = new Record(CommonStant.RECORD_TYPE_PULL_CDQ,inCode,data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),result.getStr(JsonResultUtil.MSG_TAG),result.getStr(JsonResultUtil.CODE_TAG));
+        recordService.save(record);
+        return result;
     }
 
     /**
@@ -132,14 +170,21 @@ public class ApiController {
      */
     @PostMapping("/putSShortWpfData")
     public JSONObject putSShortWpfData(HttpServletRequest request, @RequestBody JSONObject data) {
-        //校验token
-        JSONObject checkResult = checkToken(request);
+        Station station = new Station();
+        // 入参验证
+        JSONObject checkResult = checkRequest(request,data,station);
+        String inCode = getInCode(station);
         // 如果校验结果为失败
         if (JsonResultUtil.Type.failure.value().equals(checkResult.get(JsonResultUtil.CODE_TAG))) {
-            return JsonResultUtil.failure();
+            Record record = new Record(CommonStant.RECORD_TYPE_PUT_CDQ_CORRECT,inCode,data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),JsonResultUtil.Type.failure.msg(),JsonResultUtil.Type.failure.value());
+            recordService.save(record);
+            return checkResult;
         }
         // 返回短期数据json格式
-        return apiService.putSShortWpfData(data);
+        JSONObject result = apiService.putSShortWpfData(data);
+        Record record = new Record(CommonStant.RECORD_TYPE_PUT_CDQ_CORRECT,inCode,data.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),result.getStr(JsonResultUtil.MSG_TAG),result.getStr(JsonResultUtil.CODE_TAG));
+        recordService.save(record);
+        return result;
     }
 
     /**
@@ -152,20 +197,33 @@ public class ApiController {
         String authorization = request.getHeader(CommonStant.AUTHORIZATION);
         // 如果授权信息不存在,返回失败
         if (authorization == null) {
-            return JsonResultUtil.failure();
+            return JsonResultUtil.failure("authorization授权不存在");
         }
         // 将"用户名:密码"格式的数据拆分
         String[] authorizationArr = authorization.split(CommonStant.CHARACTER_COLON);
         // 如果根据冒号拆分后的数据长度小于2,则返回失败
         if (authorizationArr.length < 2) {
-            return JsonResultUtil.failure();
+            return JsonResultUtil.failure("用户名:密码 格式不正确");
+        }
+        // 获取用户列表
+        Map<String, String> userMap = redisTemplate.opsForHash().entries(CommonStant.REDIS_USERS);
+        // 如果用户列表为空,返回失败
+        if (userMap == null) {
+            return JsonResultUtil.failure("用户列表为空");
         }
+        // 根据用户名(authorizationArr[0])查找密码
+        String password = userMap.get(authorizationArr[0]);
+        // 如果密码为空,则证明用户不存在
+        if (password == null) {
+            return JsonResultUtil.failure("用户名不存在");
+        }
+
         // 放入用户信息
         JSONObject userInfo = new JSONObject();
-        // 请求的用户名
-        userInfo.set(CommonStant.REQUEST_USER_NAME, authorizationArr[0]);
         // 请求的密码
         userInfo.set(CommonStant.REQUEST_USER_PASS, authorizationArr[1]);
+        // 请求的用户名
+        userInfo.set(CommonStant.REQUEST_USER_NAME, authorizationArr[0]);
         return JsonResultUtil.success(userInfo);
     }
 
@@ -179,7 +237,7 @@ public class ApiController {
         JSONObject checkResult = checkAuthorization(request);
         // 如果校验结果为失败
         if (JsonResultUtil.Type.failure.value().equals(checkResult.get(JsonResultUtil.CODE_TAG))) {
-            return JsonResultUtil.failure();
+            return checkResult;
         }
         // 如果授权格式校验成功,获取用户名和token
         JSONObject userInfo = checkResult.getJSONObject(JsonResultUtil.DATA_TAG);
@@ -193,7 +251,7 @@ public class ApiController {
         String token = String.valueOf(redisTemplate.opsForValue().get(key));
         // 如果token不同,校验失败
         if (!token.equals(requestToken)) {
-            return JsonResultUtil.failure();
+            return JsonResultUtil.failure("token校验失败");
         }
         return JsonResultUtil.success();
     }
@@ -203,32 +261,54 @@ public class ApiController {
      *
      * @return
      */
-    public JSONObject checkRequest(HttpServletRequest httpRequest,JSONObject requestJson) {
+    public JSONObject checkRequest(HttpServletRequest httpRequest,JSONObject requestJson,Station station) {
         // 验证token
         JSONObject tokenResult = checkToken(httpRequest);
         if (JsonResultUtil.Type.failure.value().equals(tokenResult.get(JsonResultUtil.CODE_TAG))) {
-            return JsonResultUtil.failure();
+            return tokenResult;
         }
 
         if (requestJson == null) {
             log.info("接收到的数据为空");
-            return JsonResultUtil.failure();
+            return JsonResultUtil.failure("接收到的数据为空");
         }
+
+        JSONArray stationCodeArr = new JSONArray();
         // 获取场站id
-        String stationCode = requestJson.getStr("wfId");
+        if((requestJson.get("wfId") instanceof JSONArray)){
+            stationCodeArr = (requestJson.getJSONArray("wfId"));
+        }else{
+            stationCodeArr.add(requestJson.get("wfId"));
+        }
+
         // 如果场站id为空
-        if (stationCode == null || "".equals(stationCode)) {
+        if (stationCodeArr == null || stationCodeArr.size()==0) {
             log.info("场站id为空");
-            return JsonResultUtil.failure();
-        }
-        // 根据场站编号查询场站信息
-        Station station = stationService.findByStationCode(stationCode);
-        // 如果场站信息为空
-        if (station == null) {
-            log.info("场站信息为空");
-            return JsonResultUtil.failure();
+            return JsonResultUtil.failure("场站id为空");
         }
 
+        if(stationCodeArr.size() == 1){
+            // 根据场站编号查询场站信息
+            station = stationService.findByStationCode(stationCodeArr.get(0).toString());
+            // 如果场站信息为空
+            if (station == null) {
+                log.info("场站信息为空");
+                return JsonResultUtil.failure("场站信息为空");
+            }
+        }
         return JsonResultUtil.success();
     }
+
+    /**
+     * 获取inCode
+     * @param station
+     * @return
+     */
+    public String getInCode(Station station){
+        String inCode = "";
+        if(station!=null){
+            inCode = station.getInCode();
+        }
+        return inCode;
+    }
 }

+ 14 - 6
in-cloud/src/main/java/com/jiayue/insu/incloud/entity/Station.java

@@ -3,10 +3,7 @@ package com.jiayue.insu.incloud.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 lombok.Data;
-import org.springframework.format.annotation.DateTimeFormat;
-
 import java.time.LocalDateTime;
 
 /**
@@ -72,14 +69,25 @@ public class Station extends BaseEntity {
      */
     Integer days;
 
-    //下载原始数据时间
+    /**
+     * 下载原始数据时间
+     */
     String initDownTime;
 
-    //上送原始数据时间
+    /**
+     * 上送原始数据时间
+     */
     String initPushTime;
 
-    //下载修正数据时间
+    /**
+     * 下载修正数据时间
+     */
     String correctDownTime;
 
+    /**
+     * 是否将修正数据下发到场站外网
+     */
+    String isPushCorr;
+
 
 }

+ 7 - 0
in-cloud/src/main/java/com/jiayue/insu/incloud/service/ApiService.java

@@ -26,6 +26,13 @@ public interface ApiService  {
     JSONObject getShortWpfData(JSONObject requestJson);
 
     /**
+     * 获取nwp原始json数据
+     * @param requestJson
+     * @return
+     */
+    JSONObject getNwpData(JSONObject requestJson);
+
+    /**
      * 获取短期修正数据json
      * @param requestJson
      * @return

+ 251 - 119
in-cloud/src/main/java/com/jiayue/insu/incloud/service/impl/ApiServiceImpl.java

@@ -31,6 +31,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.util.DigestUtils;
+
 import java.io.*;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
@@ -89,16 +90,8 @@ public class ApiServiceImpl implements ApiService {
         String requestUserPass = userInfo.getStr(CommonStant.REQUEST_USER_PASS);
         // 获取用户列表
         Map<String, String> userMap = redisTemplate.opsForHash().entries(CommonStant.REDIS_USERS);
-        // 如果用户列表为空,返回失败
-        if (userMap == null) {
-            return JsonResultUtil.failure();
-        }
         // 根据用户名获取密码
         String password = userMap.get(requestUserName);
-        // 如果密码为空
-        if (password == null) {
-            return JsonResultUtil.failure();
-        }
         // 加密后的密码
         String passwordMD5t = DigestUtils.md5DigestAsHex(password.getBytes()).toUpperCase();
         // 如果密码匹配成功
@@ -114,6 +107,7 @@ public class ApiServiceImpl implements ApiService {
                 if (timeout > 360) {
                     result = JsonResultUtil.success();
                     result.set("token", token);
+                    log.info("用户:" + requestUserName + "获取token,剩余有效期" + timeout + "秒");
                     return result;
                 }
             }
@@ -130,11 +124,12 @@ public class ApiServiceImpl implements ApiService {
             result.set(CommonStant.TOKEN, token);
             // 成功生成token后,将toke存入redis 有效期24小时
             redisTemplate.opsForValue().set(key, token, 24, TimeUnit.HOURS);
+            log.info("用户:" + requestUserName + "获取token,剩余有效期86400秒");
             // 返回结果
             return result;
         } else {
-            log.info("用户不存在或密码错误");
-            return JsonResultUtil.failure();
+            log.info("密码错误");
+            return JsonResultUtil.failure("密码错误");
         }
     }
 
@@ -146,14 +141,68 @@ public class ApiServiceImpl implements ApiService {
      */
     @Override
     public JSONObject getShortWpfData(JSONObject requestJson) {
-        JSONObject result;
-        String stationCode = requestJson.getStr("wfId");
-        // 根据场站编号查询场站信息
-        Station station = stationService.findByStationCode(stationCode);
-        // 从minIo获取文件
-        File file = downLoadFileFromMinIo(station, "dq", requestJson.getStr("beginDate"), requestJson.getStr("endDate"));
-        //解析短期文件
-        result = fileAnalysis(file, station, "dq", requestJson.getStr("beginDate"), requestJson.getStr("endDate"));
+        JSONObject result = new JSONObject();
+        JSONArray stationCodeArr = requestJson.getJSONArray("wfId");
+        JSONArray dataArr = new JSONArray();
+        boolean getStatus = false;
+        //
+        for (int i = 0; i < stationCodeArr.size(); i++) {
+            // 根据场站编号查询场站信息
+            Station station = stationService.findByStationCode(stationCodeArr.get(i).toString());
+            JSONObject errMsg = new JSONObject();
+            // 从minIo获取文件
+            File file = downLoadFileFromMinIo(station, "dq", requestJson.getStr("beginDate"), requestJson.getStr("endDate"), errMsg);
+            // 解析短期文件
+            JSONObject fileResult = fileAnalysis(file, station, "dq", requestJson.getStr("beginDate"), requestJson.getStr("beginDate"));
+            // 如果解析文件成功,则放入data集合中
+            if (JsonResultUtil.Type.success.value().equals(fileResult.get(JsonResultUtil.CODE_TAG))) {
+                result = fileResult;
+                dataArr.addAll(fileResult.getJSONArray("data"));
+                getStatus = true;
+            } else {
+                dataArr.add(stationCodeArr.get(i).toString() + ":" + errMsg.getStr("msg"));
+            }
+        }
+        // 如果全部文件都未下载,返回失败原因
+        if (!getStatus) {
+            return JsonResultUtil.failure(dataArr);
+        }
+
+        result.set("data", dataArr);
+        // 如果解析完的短期文件列表为空
+        return result;
+    }
+
+    @Override
+    public JSONObject getNwpData(JSONObject requestJson) {
+        JSONObject result = new JSONObject();
+        JSONArray stationCodeArr = requestJson.getJSONArray("wfId");
+        JSONArray dataArr = new JSONArray();
+        boolean getStatus = false;
+        //
+        for (int i = 0; i < stationCodeArr.size(); i++) {
+            // 根据场站编号查询场站信息
+            Station station = stationService.findByStationCode(stationCodeArr.get(i).toString());
+            JSONObject errMsg = new JSONObject();
+            // 从minIo获取文件
+            File file = downLoadFileFromMinIo(station, "nwp", requestJson.getStr("beginDate"), requestJson.getStr("endDate"), errMsg);
+            // 解析短期文件
+            JSONObject fileResult = fileAnalysis(file, station, "nwp", requestJson.getStr("beginDate"), requestJson.getStr("beginDate"));
+            // 如果解析文件成功,则放入data集合中
+            if (JsonResultUtil.Type.success.value().equals(fileResult.get(JsonResultUtil.CODE_TAG))) {
+                getStatus = true;
+                result = fileResult;
+                dataArr.addAll(fileResult.getJSONArray("data"));
+            } else {
+                dataArr.add(stationCodeArr.get(i).toString() + ":" + errMsg.getStr("msg"));
+            }
+        }
+        // 如果全部文件都未下载,返回失败原因
+        if (!getStatus) {
+            return JsonResultUtil.failure(dataArr);
+        }
+        // 将data放入列表
+        result.set("data", dataArr);
         // 如果解析完的短期文件列表为空
         return result;
     }
@@ -175,13 +224,13 @@ public class ApiServiceImpl implements ApiService {
         // 明日修正后数据Arr
         JSONArray datas = values.getJSONArray("datas");
         // 将json数据转化为ListMap
-        List<Map<String, Object>> dqListMap = getDqListMap(station,datas, station.getName());
+        List<Map<String, Object>> dqListMap = getDqListMap(station, datas, station.getName());
         // 短期文件模板
         String vmsPath = SystermUtils.getResourceBasePath() + "/vms/DQ.vm";
         // 生成dq文件
-        JSONObject result = genFile(station, dqListMap, vmsPath);
-        if(JsonResultUtil.Type.failure.value().equals(result.get(JsonResultUtil.CODE_TAG))){
-            Record record = new Record(CommonStant.RECORD_TYPE_PUSH_CORRECT_TO_MIN_IO,"CSGS",requestJson.getStr("wfId"),null,LocalDateTime.now(),LocalDateTime.now(),JsonResultUtil.Type.failure.msg(),JsonResultUtil.Type.failure.value());
+        JSONObject result = genFile(station, dqListMap, vmsPath, "_CORR", "DQ");
+        if (JsonResultUtil.Type.failure.value().equals(result.get(JsonResultUtil.CODE_TAG))) {
+            Record record = new Record(CommonStant.RECORD_TYPE_PUSH_CORRECT_TO_MIN_IO, "CSGS", requestJson.getStr("wfId"), null, LocalDateTime.now(), LocalDateTime.now(), JsonResultUtil.Type.failure.msg(), JsonResultUtil.Type.failure.value());
             recordService.save(record);
         }
         return JsonResultUtil.success();
@@ -199,8 +248,9 @@ public class ApiServiceImpl implements ApiService {
         String stationCode = requestJson.getStr("wfId");
         // 根据场站编号查询场站信息
         Station station = stationService.findByStationCode(stationCode);
+        JSONObject errMsg = new JSONObject();
         // 从minIo下载文件
-        File file = downLoadFileFromMinIo(station, "cdq", requestJson.getStr("beginDate"), requestJson.getStr("endDate"));
+        File file = downLoadFileFromMinIo(station, "cdq", requestJson.getStr("beginDate"), requestJson.getStr("endDate"), errMsg);
         //解析短期文件
         result = fileAnalysis(file, station, "cdq", requestJson.getStr("beginDate"), requestJson.getStr("endDate"));
         return result;
@@ -223,11 +273,11 @@ public class ApiServiceImpl implements ApiService {
         // 所有日期的数据Arr
         JSONArray datas = values.getJSONArray("datas");
         // 将json数据转化为ListMap
-        List<Map<String, Object>> dqListMap = getDqListMap(station,datas, station.getName());
+        List<Map<String, Object>> dqListMap = getDqListMap(station, datas, station.getName());
         // 短期文件模板
-        String vmsPath = SystermUtils.getResourceBasePath() + "/vms/DQ.vm";
-        // 生成dq文件
-        genFile(station, dqListMap, vmsPath);
+        String vmsPath = SystermUtils.getResourceBasePath() + "/vms/CDQ.vm";
+        // 生成cdq文件
+        genFile(station, dqListMap, vmsPath, "_CORR", "CDQ");
         return JsonResultUtil.success();
     }
 
@@ -241,9 +291,9 @@ public class ApiServiceImpl implements ApiService {
      * @return
      */
     public JSONObject fileAnalysis(File dqFile, Station station, String type, String startDate, String endDate) {
-        if (dqFile == null){
-            log.info("从minIo下载的文件为空");
-            return  JsonResultUtil.failure();
+        if (dqFile == null) {
+            log.info("请求的文件不存在");
+            return JsonResultUtil.failure("请求的文件不存在");
         }
         JSONArray resultArr = new JSONArray();
         boolean jx = true;
@@ -281,7 +331,7 @@ public class ApiServiceImpl implements ApiService {
                                 //当条的日期
                                 String thisDate = string_arr[2].split(" ")[0];
                                 // 如果是短期
-                                if("dq".equals(type)){
+                                if ("dq".equals(type)) {
                                     // 如果  当条日期<开始时间 || 当条日期>结束时间 跳过当次循环
                                     if (thisDate.compareTo(startDate) < 0 || thisDate.compareTo(endDate) > 0) {
                                         continue;
@@ -320,10 +370,7 @@ public class ApiServiceImpl implements ApiService {
                     valuesArr.add(dayInfoJson);
 
                     // 将短期预测数据放入powerJson中
-                    JSONObject powerJson = new JSONObject();
-                    powerJson.set("values", valuesArr);
-                    powerJson.set("type", "power");
-                    powerJson.set("wfId", station.getStationCode());
+                    JSONObject powerJson = putPowerJson(station.getStationCode(), "power", valuesArr);
                     //返回短期数据JSONArray
                     resultArr.add(powerJson);
                     // 如果是超短期
@@ -359,17 +406,61 @@ public class ApiServiceImpl implements ApiService {
                     dayInfoJson.set("datas", datas);
                     valuesArr.add(dayInfoJson);
                     // 将短期预测数据放入powerJson中
-                    JSONObject powerJson = new JSONObject();
-                    powerJson.set("type", "power");
-                    powerJson.set("values", valuesArr);
-                    powerJson.set("wfId", station.getStationCode());
+                    JSONObject powerJson = putPowerJson(station.getStationCode(), "power", valuesArr);
+                    //返回短期数据JSONArray
+                    resultArr.add(powerJson);
+                }else if("nwp".equals(type)){
+                    while ((stringLine = dqBufferedReader.readLine()) != null) {
+                        String[] string_arr = stringLine.split("\t");
+                        if (string_arr[0].startsWith("#")) {
+                            if (StrUtil.isNotEmpty(string_arr[2])) {
+                                // 每一条数据的json,放入预测数据和预测时间
+                                oneJson = new JSONObject();
+                                oneJson.set("farmId", string_arr[1]);
+                                oneJson.set("scDate",string_arr[2]);
+                                oneJson.set("scTime", string_arr[3]);
+                                oneJson.set("preDate", string_arr[4]);
+                                oneJson.set("preTime", string_arr[5]);
+                                oneJson.set("t", new BigDecimal(string_arr[6]).subtract(new BigDecimal("273.15")));
+                                oneJson.set("rh", new BigDecimal(string_arr[7]));
+                                oneJson.set("pressure", new BigDecimal(string_arr[8]));
+                                oneJson.set("swr", new BigDecimal(string_arr[9]));
+                                oneJson.set("lwr", new BigDecimal(string_arr[10]));
+                                oneJson.set("senf", new BigDecimal(string_arr[11]));
+                                oneJson.set("ws10", new BigDecimal(string_arr[12]));
+                                oneJson.set("ws30", new BigDecimal(string_arr[13]));
+                                oneJson.set("ws50", new BigDecimal(string_arr[14]));
+                                oneJson.set("ws70", new BigDecimal(string_arr[15]));
+                                oneJson.set("ws80", new BigDecimal(string_arr[16]));
+                                oneJson.set("ws90", new BigDecimal(string_arr[17]));
+                                oneJson.set("ws100", new BigDecimal(string_arr[18]));
+                                oneJson.set("ws170", new BigDecimal(string_arr[19]));
+                                oneJson.set("wd10",new BigDecimal( string_arr[20]));
+                                oneJson.set("wd30", new BigDecimal(string_arr[21]));
+                                oneJson.set("wd50", new BigDecimal(string_arr[22]));
+                                oneJson.set("wd70", new BigDecimal(string_arr[23]));
+                                oneJson.set("wd80", new BigDecimal(string_arr[24]));
+                                oneJson.set("wd90", new BigDecimal(string_arr[25]));
+                                oneJson.set("wd100", new BigDecimal(string_arr[26]));
+                                oneJson.set("wd170", new BigDecimal(string_arr[27]));
+                                // 将一每条数据放入datas(一天的json)中
+                                datas.add(oneJson);
+                            }
+                        }
+                    }
+                    // 将最后一日数据放入valuesArr
+                    dayInfoJson.set("datas", datas);
+                    valuesArr.add(dayInfoJson);
+                    // 将短期预测数据放入powerJson中
+                    JSONObject powerJson = putPowerJson(station.getStationCode(), "nwp", valuesArr);
                     //返回短期数据JSONArray
                     resultArr.add(powerJson);
+
                 }
             } catch (Exception e) {
                 jx = false;
                 log.error(station.getStationCode() + " 解析当天DQ文件错误:", e);
-                return JsonResultUtil.failure();
+                return JsonResultUtil.failure(" 解析当天DQ文件错误:");
             } finally {
                 close(dqBufferedReader, dqRead);
             }
@@ -378,7 +469,7 @@ public class ApiServiceImpl implements ApiService {
         if (jx) {
             return JsonResultUtil.success(resultArr);
         } else {
-            return JsonResultUtil.failure();
+            return JsonResultUtil.failure("解析失败");
         }
     }
 
@@ -407,31 +498,30 @@ public class ApiServiceImpl implements ApiService {
      * @param dqDate
      * @param stationName
      * @param station
-     *
      * @return
      */
-    public List<Map<String, Object>> getDqListMap(Station station ,JSONArray dqDate, String stationName) {
+    public List<Map<String, Object>> getDqListMap(Station station, JSONArray dqDate, String stationName) {
         List<Map<String, Object>> result = new ArrayList<>();
-        BigDecimal rowData = BigDecimal.ZERO;
         // 获取当前时间
         String dateNow = DateUtil.format(new Date(), "yyyy-MM-dd");
+        JSONObject errMsg = new JSONObject();
         // 下载当天文件
-        File file = downLoadFileFromMinIo(station, "dq", dateNow,dateNow);
+        File file = downLoadFileFromMinIo(station, "dq", dateNow, dateNow, errMsg);
         //解析短期文件,并获取当天数据
         JSONObject todayData = fileAnalysis(file, station, "dq", dateNow, dateNow);
-        if(JsonResultUtil.Type.success.value().equals(todayData.get(JsonResultUtil.CODE_TAG))){
-            addListData(result,todayData,stationName,"minIo");
+        if (JsonResultUtil.Type.success.value().equals(todayData.get(JsonResultUtil.CODE_TAG))) {
+            addListData(result, todayData, stationName, "minIo");
         }
         // 将修正后的明天的数据放入
-        addListData(result,JsonResultUtil.success(dqDate),stationName,"other");
+        addListData(result, JsonResultUtil.success(dqDate), stationName, "other");
         // 获取后天日期
         LocalDateTime dayAfterTomorrowDateTime = LocalDateTime.now().plus(2, ChronoUnit.DAYS);
         String dayAfterTomorrowStr = dayAfterTomorrowDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
         //解析短期文件,并获取后天之后的数据
         JSONObject otherData = fileAnalysis(file, station, "dq", dayAfterTomorrowStr, "2123-01-01");
         // 放入后天之后的数据
-        if(JsonResultUtil.Type.success.value().equals(otherData.get(JsonResultUtil.CODE_TAG))){
-            addListData(result,otherData,stationName,"minIo");
+        if (JsonResultUtil.Type.success.value().equals(otherData.get(JsonResultUtil.CODE_TAG))) {
+            addListData(result, otherData, stationName, "minIo");
         }
         return result;
     }
@@ -439,15 +529,18 @@ public class ApiServiceImpl implements ApiService {
     /**
      * 生成文件
      *
-     * @param station
-     * @param listDate
+     * @param station  场站信息
+     * @param listDate 数据列表
+     * @param vmsPath  模板路径
+     * @param dateType 数据类型(CORR:修正)
+     * @param fileType 文件类型(DQ/CDQ)
      * @return
      */
-    public JSONObject genFile(Station station, List<Map<String, Object>> listDate, String vmsPath) {
+    public JSONObject genFile(Station station, List<Map<String, Object>> listDate, String vmsPath, String dateType, String fileType) {
         Template template = this.velocityEngine.getTemplate(vmsPath);
         if (template == null) {
             log.info("模板为空");
-            return JsonResultUtil.failure();
+            return JsonResultUtil.failure("生成模板为空");
         }
         // 初始化模板
         VelocityContext velocityContext = new VelocityContext();
@@ -467,7 +560,8 @@ public class ApiServiceImpl implements ApiService {
             fileUrl.mkdirs();
         }
         // 文件名
-        String fileName = "DQ_" + DateUtil.format(new Date(), "yyyyMMddHHmmss") + "0.RB";
+        String fileName = fileType + "_" + DateUtil.format(new Date(), "yyyyMMddHHmmss") + "0" + dateType + ".RB";
+
         // 根据文件路径和文件名,初始化文件
         File file = new File(fUrl + File.separatorChar + fileName);
         // 文件输出入流
@@ -482,12 +576,12 @@ public class ApiServiceImpl implements ApiService {
                 os.write(writer.toString().getBytes("UTF-8"));
                 os.flush();
             } else {
-                log.warn(station.getStationCode() + " 生成DQ文件失败");
+                log.warn(station.getStationCode() + " 生成" + fileType + "文件失败");
             }
         } catch (IOException e) {
             e.printStackTrace();
-            log.warn(station.getStationCode() + " 创建DQ文件失败");
-            return JsonResultUtil.failure();
+            log.warn(station.getStationCode() + " 创建" + fileType + "文件失败");
+            return JsonResultUtil.failure(" 创建" + fileType + "文件失败");
         } finally {
             if (os != null) {
                 try {
@@ -501,16 +595,16 @@ public class ApiServiceImpl implements ApiService {
         // 将生成的文件放入MinIo
         JSONObject pushMinIoResult = pushFileToMinIo(file, station.getStationCode());
         if (JsonResultUtil.Type.failure.value().equals(pushMinIoResult.get(JsonResultUtil.CODE_TAG))) {
-            return JsonResultUtil.failure();
+            return JsonResultUtil.failure(pushMinIoResult.get(JsonResultUtil.DETAIL_TAG));
         }
-
+        // 获取推送到minIo的文件名
         String minIoFileUrl = pushMinIoResult.getStr(JsonResultUtil.DATA_TAG);
-        String [] minIoFileUrlArr = minIoFileUrl.split(";");
-        if(minIoFileUrlArr.length>1){
-            for(String url : minIoFileUrlArr ){
+        String[] minIoFileUrlArr = minIoFileUrl.split(";");
+        if (minIoFileUrlArr.length > 1) {
+            for (String url : minIoFileUrlArr) {
                 postFileCreateInfoToCloud(station.getStationCode(), file.getName(), url);
             }
-        }else{
+        } else {
             // 如果文件放成功,回传文件生成信息到云端
             postFileCreateInfoToCloud(station.getStationCode(), file.getName(), pushMinIoResult.getStr(JsonResultUtil.DATA_TAG));
         }
@@ -526,32 +620,33 @@ public class ApiServiceImpl implements ApiService {
      * @return
      */
     public JSONObject pushFileToMinIo(File file, String stationCode) {
-        boolean flag = false;
         // 存放完文件后返回的文件路径
-        String minIoFileUrl = "";
+        String minIoFileUrl;
         try {
             // 查看桶名称是否存在
-            flag = minioUtilService.bucketExists(bucketName);
+            boolean flag = minioUtilService.bucketExists(bucketName);
             if (!flag) {
-                return JsonResultUtil.failure();
+                return JsonResultUtil.failure("MinIo桶不存在");
             }
             // 向minIo中放入文件
             InputStream in = new FileInputStream(file);
             String fileName = "/" + stationCode + "/" + file.getName();
             minIoFileUrl = minioUtilService.putObject(bucketName, fileName, in);
             // 如果是AB机,向B中也放入文件
-            if(stationCode.indexOf("-A")>0){
-                String fileNameB = "/" + stationCode.replace("-A","-B") + "/" + file.getName();
-                minIoFileUrl = minIoFileUrl + ";"+minioUtilService.putObject(bucketName, fileNameB, in);
+            if (stationCode.indexOf("-A") > 0) {
+                String fileNameB = "/" + stationCode.replace("-A", "-B") + "/" + file.getName();
+                minIoFileUrl = minIoFileUrl + ";" + minioUtilService.putObject(bucketName, fileNameB, in);
             }
         } catch (Exception e) {
             e.printStackTrace();
-            return JsonResultUtil.failure();
+            return JsonResultUtil.failure("推送MinIo失败");
         }
         return JsonResultUtil.success(minIoFileUrl);
     }
 
     /**
+     * 请求V3云平台返回上传minIo文件信息
+     *
      * @param stationCode
      * @param fileName
      * @param fileDownloadUrl
@@ -583,88 +678,102 @@ public class ApiServiceImpl implements ApiService {
      * @param type
      * @return
      */
-    public File downLoadFileFromMinIo(Station station, String type, String startTime, String endTime) {
+    public File downLoadFileFromMinIo(Station station, String type, String startTime, String endTime, JSONObject errMsg) {
         // 如果场站信息为空
         if (station == null) {
             log.info("场站信息为空");
+            errMsg.set("msg", "场站信息为空");
             return null;
         }
 
         if (startTime == null || "".equals(startTime)) {
-            log.info("超短期文件获取失败,开始时间为空");
+            log.info("文件获取失败,开始时间为空");
+            errMsg.set("msg", "文件获取失败,开始时间为空");
+            return null;
+        }
+
+        // 校验日期格式
+        if (startTime.indexOf("-") == -1) {
+            log.info("文件获取失败,开始时间格式不正确,正确格式为yyyy-MM-dd");
+            errMsg.set("msg", "文件获取失败,开始时间格式不正确,正确格式为yyyy-MM-dd");
             return null;
         }
 
         Record record = new Record();
         log.info("下载minIo原始RB文件 --> {}" + station.getStationCode());
         try {
-            HttpRequest httpRequest = HttpRequest.get(url + station.getStationCode());
+            // 从云上获取minIo中指定日期的文件信息 格式https://117.78.19.70:9010/client/getFileLogsForAio/J00260/2023-08-11
+            String getUrl = url + station.getStationCode() + "/" + startTime;
+            HttpRequest httpRequest = HttpRequest.get(getUrl);
             httpRequest.setGlobalTimeout(20000);
             String body = httpRequest.execute().body();
             JSONObject json = JSONUtil.parseObj(body);
-            String code = json.get("code").toString();
             String data = json.get("data").toString();
+            String code = json.get("code").toString();
             if (!code.equals("0") || data.length() <= 0) {
                 record.setState(StatusEnum.RESPONSE_FAIL.getCode());
                 log.error("下载minIo原始RB文件 --> {} 失败,失败原因:{}", station.getStationCode(), StatusEnum.RESPONSE_FAIL.getMsg());
+                errMsg.set("msg", "下载原始文件失败");
                 return null;
             }
-            // 获取文件文件内容
+            // 获取文件信息列表
             JSONArray array = JSONUtil.parseArray(data);
             // 文件列表
             List<FileCreateLog> list = array.toList(FileCreateLog.class);
-            // 获取当前时间
-            String dateNow = DateUtil.format(new Date(), "yyyyMMdd");
             // 如果文件列表为空,则未获取到文件
             if (CollectionUtil.isEmpty(list)) {
                 record.setState(StatusEnum.FILE_NULL.getCode());
-                log.error("下载minIo原始RB文件 --> {} 失败,失败原因:{}", station.getStationCode(), StatusEnum.FILE_NULL.getMsg());
+                log.info("下载minIo原始RB文件 --> {} 失败,失败原因:{}", station.getStationCode(), StatusEnum.FILE_NULL.getMsg());
+                errMsg.set("msg", "下载原始文件失败");
                 return null;
             }
 
             // 保存文件路径
             String fileSaveUrl = fileDir + File.separatorChar + "init" + File.separatorChar + station.getStationCode();
-            log.info(fileSaveUrl);
+            log.info("文件保存路径" + fileSaveUrl);
             File dir = new File(fileSaveUrl);
             if (!dir.exists()) {// 判断目录是否存在
                 dir.mkdirs();
                 log.info("创建目录:" + fileSaveUrl);
             }
-            // 筛选当日短期文件
-            List<FileCreateLog> listNow = new ArrayList<>();
+            // 筛选指定日期短期文件
+            List<FileCreateLog> listFile = new ArrayList<>();
             String nowUrl = "";
             String downloadFileName = "";
             // 如果是短期
             if ("dq".equals(type)) {
-                listNow = list.stream().filter(f -> f.getFileName().contains("DQ_" + dateNow.replace("-", ""))).collect(Collectors.toList());
+                listFile = list.stream().filter(f -> f.getFileName().contains("DQ_" + startTime.replace("-", ""))).collect(Collectors.toList());
                 //  如果文件为空,
-                if (CollectionUtil.isEmpty(listNow)) {
+                if (CollectionUtil.isEmpty(listFile)) {
                     record.setState(StatusEnum.FILE_NULL.getCode());
-                    log.error("下载minIo原始RB文件 --> {} 失败,失败原因:{}", station.getStationCode()+" DQ文件", StatusEnum.FILE_NULL.getMsg());
+                    log.error("下载minIo原始RB文件 --> {} 失败,失败原因:{}", station.getStationCode() + " DQ文件", StatusEnum.FILE_NULL.getMsg());
+                    errMsg.set("msg", "下载原始文件失败");
                     return null;
                 }
                 // 将短期文件倒序,获取最新的文件
-                listNow.sort(Comparator.comparing(FileCreateLog::getFileName).reversed());
+                listFile.sort(Comparator.comparing(FileCreateLog::getFileName).reversed());
                 // 拼接下载文件url=fileUrl(下载文件请求地址)+从minIo获取的最新一条的文件id
-                nowUrl = fileurl + listNow.get(0).getId();
-                downloadFileName = listNow.get(0).getFileName();
+                nowUrl = fileurl + listFile.get(0).getId();
+                downloadFileName = listFile.get(0).getFileName();
                 // 如果是超短期
             } else if ("cdq".equals(type)) {
                 // 格式化开始时间 将时间2019-10-10 01:15 转为=》201910100115
                 String formatStartTime = startTime.replace("-", "").replace(" ", "").replace(":", "");
                 // 根据CDQ_201910100115 筛选超短期文件
-                listNow = list.stream().filter(f -> f.getFileName().contains("CDQ_" + formatStartTime)).collect(Collectors.toList());
-                //  如果文件为空,
-                if (CollectionUtil.isEmpty(listNow)) {
-                    record.setState(StatusEnum.FILE_NULL.getCode());
-                    log.error("下载minIo原始RB文件 --> {} 失败,失败原因:{}", station.getStationCode(), StatusEnum.FILE_NULL.getMsg());
-                    return null;
-                }
+                listFile = list.stream().filter(f -> f.getFileName().contains("CDQ_" + formatStartTime)).collect(Collectors.toList());
+            } else if("nwp".equals(type)){
+                listFile = list.stream().filter(f -> f.getFileName().contains("NWP_" + startTime.replace("-", ""))).collect(Collectors.toList());
+                // 将短期文件倒序,获取最新的文件
+                listFile.sort(Comparator.comparing(FileCreateLog::getFileName).reversed());
+                // 拼接下载文件url=fileUrl(下载文件请求地址)+从minIo获取的最新一条的文件id
+                nowUrl = fileurl + listFile.get(0).getId();
+                downloadFileName = listFile.get(0).getFileName();
             }
             //  如果文件为空,
-            if (CollectionUtil.isEmpty(listNow)) {
-                record.setState(StatusEnum.FILE_NULL.getCode());
+            if (CollectionUtil.isEmpty(listFile)) {
                 log.error("下载minIo原始RB文件 --> {} 失败,失败原因:{}", station.getStationCode(), StatusEnum.FILE_NULL.getMsg());
+                record.setState(StatusEnum.FILE_NULL.getCode());
+                errMsg.set("msg", "下载原始文件失败");
                 return null;
             }
 
@@ -673,28 +782,33 @@ public class ApiServiceImpl implements ApiService {
                 File nowFile = HttpUtil.downloadFileFromUrl(nowUrl, fileSaveUrl + File.separatorChar + downloadFileName);
                 if (nowFile == null) {
                     record.setState(StatusEnum.DOWNLOAD_FILE_ERROR.getCode());
-                    log.error("下载minIo原始RB文件 --> {} 失败,失败原因:{}", station.getStationCode(), StatusEnum.DOWNLOAD_FILE_ERROR.getMsg());
+                    log.error("下载minIo原始RB文件 --> {} 失败,失败原因:{}", station.getStationCode(), StatusEnum.FILE_NULL.getMsg());
+                    errMsg.set("msg", "下载原始文件失败");
+                    return null;
                 }
 
                 // 回传dq和nwp文件状态
-                this.postBackMinIoState(station.getStationCode(),nowFile.getName(),"down","是");
+                this.postBackMinIoState(station.getStationCode(), nowFile.getName(), "down", "是");
                 // 返回文件
                 return nowFile;
             } catch (Exception e) {
                 record.setState(StatusEnum.DOWNLOAD_FILE_FAIL.getCode());
                 log.error("下载minIo原始RB文件 --> {} 失败,失败原因:{}", station.getStationCode(), StatusEnum.DOWNLOAD_FILE_FAIL.getMsg());
                 e.printStackTrace();
+                errMsg.set("msg", "下载原始文件失败");
                 return null;
             }
         } catch (Exception e) {
             record.setState(StatusEnum.RESPONSE_FAIL.getCode());
             log.error("下载minIo原始RB文件 --> {} 失败,失败原因:{}", station.getStationCode(), StatusEnum.RESPONSE_FAIL.getMsg());
             e.printStackTrace();
+            errMsg.set("msg", "下载原始文件失败");
             return null;
         }
     }
 
     /**
+     * 向list中添加数据
      *
      * @param list
      * @param data
@@ -702,37 +816,38 @@ public class ApiServiceImpl implements ApiService {
      * @param type
      * @return
      */
-    public List<Map<String, Object>> addListData(List<Map<String, Object>> list,JSONObject data,String stationName,String type){
-        if(JsonResultUtil.Type.success.value().equals(data.get(JsonResultUtil.CODE_TAG))) {
-            JSONArray dataArr = new JSONArray();
-            if("minIo".equals(type)){
+    public List<Map<String, Object>> addListData(List<Map<String, Object>> list, JSONObject data, String stationName, String type) {
+        if (JsonResultUtil.Type.success.value().equals(data.get(JsonResultUtil.CODE_TAG))) {
+            JSONArray dataArr;
+            if ("minIo".equals(type)) {
                 dataArr = data.getJSONArray("data").getJSONObject(0).getJSONArray("values");
-                for(Object one :dataArr){
+                for (Object one : dataArr) {
                     JSONArray oneDaysData = JSONUtil.parseObj(one).getJSONArray("datas");
-                    addOneDay(list,oneDaysData,stationName);
+                    addOneDay(list, oneDaysData, stationName);
                 }
-            }else if("other".equals(type)){
+            } else if ("other".equals(type)) {
                 dataArr = data.getJSONArray("data");
-                addOneDay(list,dataArr,stationName);
+                addOneDay(list, dataArr, stationName);
             }
         }
         return list;
     }
 
     /**
+     * 添加1天的数据
      *
      * @param list
      * @param dataArr
      * @param stationName
      * @return
      */
-    public List<Map<String, Object>> addOneDay(List<Map<String, Object>> list,JSONArray dataArr,String stationName){
-        for(Object one :dataArr){
+    public List<Map<String, Object>> addOneDay(List<Map<String, Object>> list, JSONArray dataArr, String stationName) {
+        for (Object one : dataArr) {
             JSONObject oneJson = JSONUtil.parseObj(one);
             Map<String, Object> map = new HashMap<>();
             map.put("stationName", stationName);
-            map.put("fpValue", oneJson.getStr("data") == null ? "-99" : new BigDecimal(oneJson.getStr("data")).divide(new BigDecimal("1000"),2,BigDecimal.ROUND_HALF_UP));
-            map.put("forecastTime", oneJson.getStr("time").length()==16? oneJson.getStr("time")+ CommonStant.CHARACTER_TIME_ZERO:oneJson.getStr("time"));
+            map.put("fpValue", oneJson.getStr("data") == null ? "-99" : new BigDecimal(oneJson.getStr("data")).divide(new BigDecimal("1000"), 2, BigDecimal.ROUND_HALF_UP));
+            map.put("forecastTime", oneJson.getStr("time").length() == 16 ? oneJson.getStr("time") + CommonStant.CHARACTER_TIME_ZERO : oneJson.getStr("time"));
             list.add(map);
         }
         return list;
@@ -740,20 +855,37 @@ public class ApiServiceImpl implements ApiService {
 
     /**
      * 从minIo下载文件后,回传状态
+     *
      * @param stationCode
      * @param fileName
      * @param type
      * @param status
      */
     @Override
-    public void postBackMinIoState(String stationCode ,String fileName,String type,String status){
+    public void postBackMinIoState(String stationCode, String fileName, String type, String status) {
         Map urlParams = new HashMap(4);
-        urlParams.put("stationCode",stationCode);
-        urlParams.put("forecastFileName",fileName);
-        urlParams.put("type",type);
-        urlParams.put("status",status);
-        log.debug("回传文件状态给新平台,请求参数",JSONUtil.toJsonStr(urlParams));
-        String repose = HttpUtil.post(postBackUrl,urlParams,10000);
+        urlParams.put("stationCode", stationCode);
+        urlParams.put("forecastFileName", fileName);
+        urlParams.put("type", type);
+        urlParams.put("status", status);
+        log.debug("回传文件状态给新平台,请求参数", JSONUtil.toJsonStr(urlParams));
+        String repose = HttpUtil.post(postBackUrl, urlParams, 10000);
         log.info("回传文件状态给新平台,请求相应 {}", repose);
     }
+
+    /**
+     * 设置短期数据
+     *
+     * @param stationCode
+     * @param type
+     * @param valuesArr
+     * @return
+     */
+    public JSONObject putPowerJson(String stationCode, String type, JSONArray valuesArr) {
+        JSONObject result = new JSONObject();
+        result.set("wfId", stationCode);
+        result.set("type", type);
+        result.set("values", valuesArr);
+        return result;
+    }
 }

+ 43 - 7
in-cloud/src/main/java/com/jiayue/insu/incloud/utils/JsonResultUtil.java

@@ -20,6 +20,9 @@ public class JsonResultUtil {
     /** 返回内容 */
     public static final String MSG_TAG = "msg";
 
+    /** 返回内容 */
+    public static final String DETAIL_TAG = "detail";
+
     /** 数据对象 */
     public static final String DATA_TAG = "data";
 
@@ -29,23 +32,25 @@ public class JsonResultUtil {
     public enum Type
     {
         /** 成功 */
-        success("1","success"),
+        success("1","success",""),
         /** 忽略 */
-        ignore("666","ignore"),
+        ignore("666","ignore",""),
         /** 警告 */
-        warn("301","warn"),
+        warn("301","warn",""),
         /** 失败 */
-        failure("0","failure"),
+        failure("0","failure",""),
         /** 错误 */
-        error("-1","error");
+        error("-1","error","");
 
         private final String value;
         private final String msg;
+        private final String detail;
 
-        Type(String value , String msg)
+        Type(String value , String msg ,String detail)
         {
             this.value = value;
             this.msg = msg;
+            this.detail = detail;
         }
 
         public String value()
@@ -57,6 +62,11 @@ public class JsonResultUtil {
         {
             return this.msg;
         }
+
+        public String detail()
+        {
+            return this.detail;
+        }
     }
 
     /**
@@ -81,8 +91,8 @@ public class JsonResultUtil {
     public static JSONObject jsonResult(Type type, Object data)
     {
         JSONObject result = new JSONObject();
-        result.set(CODE_TAG, type.value);
         result.set(MSG_TAG, type.msg);
+        result.set(CODE_TAG, type.value);
         if (data != null) {
             result.set(DATA_TAG, data);
         }
@@ -90,6 +100,21 @@ public class JsonResultUtil {
     }
 
     /**
+     * 存入code、data
+     *
+     * @param type 状态类型
+     * @param detail 数据对象
+     */
+    public static JSONObject jsonResult(Type type, String detail)
+    {
+        JSONObject result = new JSONObject();
+        result.set(MSG_TAG, type.msg);
+        result.set(CODE_TAG, type.value);
+        result.set(DETAIL_TAG, detail);
+        return result;
+    }
+
+    /**
      * 返回成功消息
      *
      * @return 成功消息
@@ -171,4 +196,15 @@ public class JsonResultUtil {
     {
         return jsonResult(Type.failure,data);
     }
+
+    /**
+     * 返回错误消息
+     *
+     * @param detail 错误信息
+     * @return 警告消息
+     */
+    public static JSONObject failure(String detail)
+    {
+        return jsonResult(Type.failure,detail);
+    }
 }