Commit 5833900e authored by litengwei's avatar litengwei

Merge remote-tracking branch 'origin/developer' into developer

parents 42756d15 860196b7
...@@ -14,16 +14,17 @@ import org.springframework.util.ObjectUtils; ...@@ -14,16 +14,17 @@ import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.cache.Redis; import org.typroject.tyboot.component.cache.Redis;
import java.util.*; import java.util.*;
@Component @Component
public class GolangRequestUtil { public class GolangRequestUtil {
private final static String API_REDIS_PREFIX = "HOUSEHOLD_API_CACHE_";
@Autowired @Autowired
private HouseholdPvProducerInfoServiceImpl householdPvProducerInfoServiceImpl; private HouseholdPvProducerInfoServiceImpl householdPvProducerInfoServiceImpl;
@Autowired @Autowired
private GolangStationMapper golangStationMapper; private GolangStationMapper golangStationMapper;
/** /**
* @return HashMap<String, Object> 发送请求前的准备 准备header信息 * @return HashMap<String, Object> 发送请求前的准备 准备header信息
* @deprecated 根据厂商编码获取厂商的hearer * @deprecated 根据厂商编码获取厂商的hearer
...@@ -43,9 +44,16 @@ public class GolangRequestUtil { ...@@ -43,9 +44,16 @@ public class GolangRequestUtil {
} }
/** /**
* @return String 请求返回的response字符串 * @desc 根据请求参数发送http请求并且对于返回的数据进行处理
* @param apiurl 请求url
* @param requestMethod 请求方式
* @param requestParmInfo 请求参数mapper
* @param ResultResolveRule 请求的解析
* @param tClass 需要转换成的bean
* @return List<T> list<Result>
* @param <T> 泛型数据
*/ */
public <T> List<T> getResPonse(String apiurl,String requestMethod,String requestParmInfo,String ResultResolveRule,Class <T> tClass) { public <T> List<T> getResPonse(String apiurl, String requestMethod, String requestParmInfo, String ResultResolveRule, Class<T> tClass) {
String respone = ""; String respone = "";
String params = ""; String params = "";
JSONArray jsonArray = null; JSONArray jsonArray = null;
...@@ -55,29 +63,15 @@ public class GolangRequestUtil { ...@@ -55,29 +63,15 @@ public class GolangRequestUtil {
String orginalAuthorization = headMap.get("Authorization") + ":"; String orginalAuthorization = headMap.get("Authorization") + ":";
String url = baseurl + apiurl; String url = baseurl + apiurl;
String appsecret = (String) producerInfo.get("appsecret"); String appsecret = (String) producerInfo.get("appsecret");
JLYHeaderMapHandler(params, headMap, orginalAuthorization, appsecret,apiurl); JLYHeaderMapHandler(params, headMap, orginalAuthorization, appsecret, apiurl);
respone = sendRequest(requestMethod, url,requestParmInfo, headMap); respone = sendRequest(requestMethod, url, requestParmInfo, headMap);
jsonArray = handlerResponseByResultResolverule(ResultResolveRule, respone); jsonArray = handlerResponseByResultResolverule(ResultResolveRule, respone);
List<T> result = JSONArray.parseArray(jsonArray.toJSONString(),tClass); List<T> result = JSONArray.parseArray(jsonArray.toJSONString(), tClass);
return result; return result;
} }
// public JSONArray getResPonse(String apiurl,String requestMethod,String requestParmInfo,String ResultResolveRule) {
// String respone = "";
// String params = "";
// JSONArray jsonArray = null;
// HashMap<String, Object> producerInfo = getHeaderOfGolang();
// String baseurl = (String) producerInfo.get("apiurl");
// HashMap<String, String> headMap = (HashMap<String, String>) producerInfo.get("header");
// String orginalAuthorization = headMap.get("Authorization") + ":";
// String url = baseurl + apiurl;
// String appsecret = (String) producerInfo.get("appsecret");
// JLYHeaderMapHandler(params, headMap, orginalAuthorization, appsecret,apiurl);
// respone = sendRequest(requestMethod, url,requestParmInfo, headMap);
// jsonArray = handlerResponseByResultResolverule(ResultResolveRule, respone);
// return jsonArray;
// }
/** /**
* @desc 根据解析规则解析请求返回数据
* @param resultResovle 请求返回的解析规则 来源与数据库 * @param resultResovle 请求返回的解析规则 来源与数据库
* @param response 请求返回的字符串 * @param response 请求返回的字符串
* @return 解析后的数据 * @return 解析后的数据
...@@ -106,57 +100,6 @@ public class GolangRequestUtil { ...@@ -106,57 +100,6 @@ public class GolangRequestUtil {
return jsonArray; return jsonArray;
} }
/**
* @param seq apiID
* @param cacheField 要缓存的字段
* @param jsonArray 处理后的数据请求
* @param measurement 要在influxdb中存储的数
* @describe 该方法用于缓存需要缓存的字段 且将需要入库的数据进行入库
*/
public void handleResponseAndCacheData(String seq, String cacheField, JSONArray jsonArray, String measurement, String produceID) {
String apiID = API_REDIS_PREFIX + seq;
List list = new ArrayList();
List saveList = new ArrayList();
if (jsonArray.size() > 0) {
for (Object o : jsonArray) {
List<Map<String, Object>> lines = new ArrayList<>();
Map<String, Object> maps1 = (Map<String, Object>) o;
LinkedHashMap<String, Object> sortHashMap = new LinkedHashMap<>();
sortHashMap.put("station_list", "station_list." + measurement);
sortHashMap.put("timestamp", System.currentTimeMillis());
sortHashMap.put("value", 10.1);
Set<String> keys = maps1.keySet();
keys.forEach((key) -> {
maps1.put(key, ObjectUtils.isEmpty(maps1.get(key)) ? "null" : maps1.get(key).toString());
});
if (!ObjectUtils.isEmpty("cacheField")) {
list.add(maps1.get(cacheField));
}
sortHashMap.put("tags", maps1);
lines.add(sortHashMap);
// Map<String, String> maps2 = new HashMap<>();
// maps2.put("key", UUID.randomUUID().toString());
if (!ObjectUtils.isEmpty(measurement)) {
// influxDbConnection.insert(measurement, maps2, maps1);
// log.error(JSONObject.toJSONString(lines));
// tdEngineUtils.writeDataIntoTdEngine(JSONObject.toJSONString(lines));
}
}
}
// tdEngineUtils.writeDataIntoTdEngine(lines.stream().map(s -> String.valueOf(s)).toArray(String[]::new));
if (!ObjectUtils.isEmpty(cacheField)) {
saveList = Redis.getRedisTemplate().opsForList().range(apiID, 0, -1);
if (saveList.size() == 0) {
Redis.getRedisTemplate().opsForList().leftPushAll(apiID, list);
}
saveList = Redis.getRedisTemplate().opsForList().range(apiID, 0, -1);
if (saveList.size() != list.size()) {
Redis.getRedisTemplate().delete(apiID);
Redis.getRedisTemplate().opsForList().leftPushAll(apiID, list);
}
}
}
public String sendRequest(String requestMethod, String url, String params, HashMap<String, String> headMap) { public String sendRequest(String requestMethod, String url, String params, HashMap<String, String> headMap) {
String respone = ""; String respone = "";
if (requestMethod.equals("POST")) { if (requestMethod.equals("POST")) {
...@@ -179,19 +122,25 @@ public class GolangRequestUtil { ...@@ -179,19 +122,25 @@ public class GolangRequestUtil {
* @desc 锦浪云请求参数及head头处理 * @desc 锦浪云请求参数及head头处理
*/ */
public void JLYHeaderMapHandler(String params, HashMap<String, String> headMap, String orginalAuthorization, String appsecret, String apiurl) { public void JLYHeaderMapHandler(String params, HashMap<String, String> headMap, String orginalAuthorization, String appsecret, String apiurl) {
String contentMD5 = GoLangHeaderUtils.getDigest(params); String contentMD5 = GoLangHeaderUtils.getDigest(params);
headMap.put("Date", GoLangHeaderUtils.getGMTTime()); headMap.put("Date", GoLangHeaderUtils.getGMTTime());
String param = "POST" + "\n" + contentMD5 + "\n" + "application/json" + "\n" + headMap.get("Date") + "\n" + apiurl; String param = "POST" + "\n" + contentMD5 + "\n" + "application/json" + "\n" + headMap.get("Date") + "\n" + apiurl;
String sign = ""; String sign = "";
try { try {
sign = GoLangHeaderUtils.HmacSHA1Encrypt(param, appsecret); sign = GoLangHeaderUtils.HmacSHA1Encrypt(param, appsecret);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
headMap.put("Content-MD5", contentMD5); headMap.put("Content-MD5", contentMD5);
headMap.put("Authorization", orginalAuthorization + sign); headMap.put("Authorization", orginalAuthorization + sign);
} }
/**
* @desc 根据分页规则 获取分页数
* @param pageSizeResovle
* @param response
* @return
*/
public Integer getPagesize(String pageSizeResovle, String response) { public Integer getPagesize(String pageSizeResovle, String response) {
Integer pageSize = 0; Integer pageSize = 0;
String[] rules = pageSizeResovle.split(","); String[] rules = pageSizeResovle.split(",");
......
...@@ -56,11 +56,11 @@ public class HouseholdTestController { ...@@ -56,11 +56,11 @@ public class HouseholdTestController {
@ApiOperation(httpMethod = "POST", value = "锦浪云", notes = "锦浪云") @ApiOperation(httpMethod = "POST", value = "锦浪云", notes = "锦浪云")
public void golangnew() throws IOException { public void golangnew() throws IOException {
// goLangDataAcquisitionService.stationList(); // goLangDataAcquisitionService.stationList();
goLangDataAcquisitionService.stationDetail(); // goLangDataAcquisitionService.stationDetail();
// goLangDataAcquisitionService.collectorList(); // goLangDataAcquisitionService.collectorList();
//// goLangDataAcquisitionService.inverterList(); //// goLangDataAcquisitionService.inverterList();
// goLangDataAcquisitionService.collectorDetail(); goLangDataAcquisitionService.collectorDetail();
// goLangDataAcquisitionService.inverterDetail(); goLangDataAcquisitionService.inverterDetail();
// goLangDataAcquisitionService.inverAlramInfo(); // goLangDataAcquisitionService.inverAlramInfo();
} }
} }
...@@ -215,5 +215,6 @@ public class JpStation implements Serializable { ...@@ -215,5 +215,6 @@ public class JpStation implements Serializable {
private Double monthPowerPse; // 月用电量 private Double monthPowerPse; // 月用电量
@TableField("year_power_use") @TableField("year_power_use")
private Double yearPowerUse; // 年用电量 private Double yearPowerUse; // 年用电量
@TableField("email")
private String email; // 电子邮箱
} }
package com.yeejoin.amos.api.householdapi.face.service; package com.yeejoin.amos.api.householdapi.face.service;
public interface GoLangDataAcquisitionService { public interface GoLangDataAcquisitionService {
/**
* @descrption 场站列表数据入库
*/
void stationList(); void stationList();
/**
* @descrption 场站详情数据入库
*/
void stationDetail(); void stationDetail();
/**
* @descrption 采集器列表数据入库
*/
void collectorList(); void collectorList();
/**
* @descrption 采集器详情数据入库
*/
void collectorDetail(); void collectorDetail();
/**
* @descrption 逆变器列表数据入库
*/
void inverterList(); void inverterList();
/**
* @descrption 逆变器详情数据入库
*/
void inverterDetail(); void inverterDetail();
/**
* @descrption 采集器告警列表数据入库
*/
void inverAlramInfo(); void inverAlramInfo();
} }
...@@ -22,14 +22,11 @@ import com.yeejoin.amos.api.householdapi.face.service.GoLangDataAcquisitionServi ...@@ -22,14 +22,11 @@ import com.yeejoin.amos.api.householdapi.face.service.GoLangDataAcquisitionServi
import com.yeejoin.amos.api.householdapi.face.orm.mapper.hygf.JpStationMapper; import com.yeejoin.amos.api.householdapi.face.orm.mapper.hygf.JpStationMapper;
import com.yeejoin.amos.openapi.enums.PVProducerInfoEnum; import com.yeejoin.amos.openapi.enums.PVProducerInfoEnum;
import fastjson.JSON; import fastjson.JSON;
import org.bouncycastle.crypto.engines.AESLightEngine;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -39,44 +36,59 @@ import java.util.concurrent.TimeUnit; ...@@ -39,44 +36,59 @@ import java.util.concurrent.TimeUnit;
@Async @Async
@Service @Service
public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionService { public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionService {
//定时任务执行频率 当前为10分钟一次
private final String dataRequstScheduled = "0 0/10 * * * *"; private final String dataRequstScheduled = "0 0/10 * * * *";
//锦浪云请求工具封装
@Autowired @Autowired
private GolangRequestUtil golangRequestUtil; private GolangRequestUtil golangRequestUtil;
//锦浪云场站mapper
@Autowired @Autowired
private GolangStationMapper golangStationMapper; private GolangStationMapper golangStationMapper;
//监盘场站mapper
@Autowired @Autowired
private JpStationMapper jpStationMapper; private JpStationMapper jpStationMapper;
//监盘采集器mapper
@Autowired @Autowired
private JpCollectorMapper jpCollectorMapper; private JpCollectorMapper jpCollectorMapper;
//监盘逆变器mapper
@Autowired @Autowired
private JpInverterMapper jpInverterMapper; private JpInverterMapper jpInverterMapper;
//监盘逆变器电量mapper
@Autowired @Autowired
private JpInverterElectricityMapper jpInverterElectricityMapper; private JpInverterElectricityMapper jpInverterElectricityMapper;
//锦浪云场站详情mapper
@Autowired @Autowired
private GolangStationDetailMapper golangStationDetailMapper; private GolangStationDetailMapper golangStationDetailMapper;
//锦浪云采集器列表mapper
@Autowired @Autowired
private GolangCollectorListMapper golangCollectorListMapper; private GolangCollectorListMapper golangCollectorListMapper;
//锦浪云逆变器列表
@Autowired @Autowired
private GolangInverterListMapper golangInverterListMapper; private GolangInverterListMapper golangInverterListMapper;
//户用光伏 场站历史 //户用光伏场站历史mapper
@Autowired @Autowired
private HYGFJPStationPowerHistoryMapper hygfjpStationPowerHistoryMapper; private HYGFJPStationPowerHistoryMapper hygfjpStationPowerHistoryMapper;
// //户用光伏逆变器历史mapper
@Autowired @Autowired
private HYGFJPInverterHistoryMapper hygfjpInverterHistoryMapper; private HYGFJPInverterHistoryMapper hygfjpInverterHistoryMapper;
//户用光伏采集器历史mapper
@Autowired @Autowired
private HYGFJPCollectorHistoryMapper hygfjpCollectorHistoryMapper; private HYGFJPCollectorHistoryMapper hygfjpCollectorHistoryMapper;
//户用光伏逆变器告警
@Autowired @Autowired
private HYGFJPInverterWarnMapper hygfjpInverterWarnMapper; private HYGFJPInverterWarnMapper hygfjpInverterWarnMapper;
//户用光伏逆变器历史mapper
@Autowired @Autowired
private HYGFJPInverterElecHistoryMapper hygfjpInverterElecHistoryMapper; private HYGFJPInverterElecHistoryMapper hygfjpInverterElecHistoryMapper;
//户用光伏日发电量
@Autowired @Autowired
private HYGFJPDayPowerMapper hygfjpDayPowerMapper; private HYGFJPDayPowerMapper hygfjpDayPowerMapper;
@Scheduled(cron = dataRequstScheduled) @Scheduled(cron = dataRequstScheduled)
@Override @Override
public void stationList() { public void stationList() {
HashMap<String, Object> requestInfo = new HashMap<>(); HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("pageNo", 1); requestInfo.put("pageNo", 1);
requestInfo.put("pageSize", 100); requestInfo.put("pageSize", 100);
...@@ -134,7 +146,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe ...@@ -134,7 +146,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
jpStation.setLatitude(golangStationDetail.getLatitude()); jpStation.setLatitude(golangStationDetail.getLatitude());
jpStation.setUserName(golangStationDetail.getUsername()); jpStation.setUserName(golangStationDetail.getUsername());
jpStation.setUserPhone(String.valueOf(golangStationDetail.getUsermobile())); jpStation.setUserPhone(String.valueOf(golangStationDetail.getUsermobile()));
jpStation.setStationContact(StrUtil.nullToDefault(String.valueOf(golangStationDetail.getMobile()), "")); jpStation.setStationContact(String.valueOf(golangStationDetail.getMobile()).toLowerCase().replace("null",""));
jpStation.setModuleCount(Math.toIntExact(golangStationDetail.getModule())); jpStation.setModuleCount(Math.toIntExact(golangStationDetail.getModule()));
//并网类型 //并网类型
jpStation.setOnGridType(GoLangConstant.stationStaus.get(String.valueOf(golangStationDetail.getState()))); jpStation.setOnGridType(GoLangConstant.stationStaus.get(String.valueOf(golangStationDetail.getState())));
...@@ -150,6 +162,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe ...@@ -150,6 +162,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
jpStation.setYearIncome(golangStationDetail.getYearincome()); jpStation.setYearIncome(golangStationDetail.getYearincome());
jpStation.setCumulativeIncome(golangStationDetail.getAllincome()); jpStation.setCumulativeIncome(golangStationDetail.getAllincome());
jpStation.setArea(golangStationDetail.getRegionstr()); jpStation.setArea(golangStationDetail.getRegionstr());
jpStation.setEmail(golangStationDetail.getUseremail());
if (!ObjectUtils.isEmpty(jpStation.getSequenceNbr())) { if (!ObjectUtils.isEmpty(jpStation.getSequenceNbr())) {
jpStationMapper.updateById(jpStation); jpStationMapper.updateById(jpStation);
} else { } else {
...@@ -315,15 +328,15 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe ...@@ -315,15 +328,15 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
@Scheduled(cron = dataRequstScheduled) @Scheduled(cron = dataRequstScheduled)
@Override @Override
public void inverterDetail() { public void inverterDetail() {
List<Long> inverterIds = golangInverterListMapper.getInverterIds(); List<String> inverterSns = golangInverterListMapper.getInverterSns();
for (int i = 0; i < inverterIds.size(); i++) { for (int i = 0; i < inverterSns.size(); i++) {
try { try {
TimeUnit.SECONDS.sleep(1); TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
HashMap<String, Object> requestInfo = new HashMap<>(); HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("id", Long.valueOf(inverterIds.get(i))); requestInfo.put("sn", inverterSns.get(i));
String requestParaminfo = JSON.toJSONString(requestInfo); String requestParaminfo = JSON.toJSONString(requestInfo);
List<InverterDetailDto> result = golangRequestUtil.getResPonse(GoLangConstant.inverterDetailUrl, List<InverterDetailDto> result = golangRequestUtil.getResPonse(GoLangConstant.inverterDetailUrl,
GoLangConstant.requestPost, GoLangConstant.requestPost,
...@@ -420,7 +433,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe ...@@ -420,7 +433,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
hygfjpInverterElecHistory.setWAcCurrent(inverterDetailDto.getIAc3()); hygfjpInverterElecHistory.setWAcCurrent(inverterDetailDto.getIAc3());
hygfjpInverterElecHistory.setUAcVoltage(inverterDetailDto.getUAc1()); hygfjpInverterElecHistory.setUAcVoltage(inverterDetailDto.getUAc1());
hygfjpInverterElecHistory.setVAcVoltage(inverterDetailDto.getUAc2()); hygfjpInverterElecHistory.setVAcVoltage(inverterDetailDto.getUAc2());
hygfjpInverterElecHistory.setUAcVoltage(inverterDetailDto.getUAc3()); hygfjpInverterElecHistory.setWAcVoltage(inverterDetailDto.getUAc3());
hygfjpInverterElecHistory.setThirdCode(PVProducerInfoEnum.JLY.getCode()); hygfjpInverterElecHistory.setThirdCode(PVProducerInfoEnum.JLY.getCode());
hygfjpInverterElecHistory.setTime(System.currentTimeMillis()); hygfjpInverterElecHistory.setTime(System.currentTimeMillis());
hygfjpInverterElecHistoryMapper.insert(hygfjpInverterElecHistory); hygfjpInverterElecHistoryMapper.insert(hygfjpInverterElecHistory);
......
...@@ -127,7 +127,7 @@ public class JpStationDto extends BaseDto { ...@@ -127,7 +127,7 @@ public class JpStationDto extends BaseDto {
private Double cumulativeIncome; private Double cumulativeIncome;
private Double dayPowerUse; // 日用电量 private Double dayPowerUse; // 日用电量
private Double month_power_use; // 月用电量 private Double monthPowerUse; // 月用电量
private Double yearPowerUse; // 年用电量 private Double yearPowerUse; // 年用电量
private int countBuiltNum;// 已建设场站数量 private int countBuiltNum;// 已建设场站数量
......
...@@ -53,6 +53,8 @@ public class TdHygfJpInverterWarnDto { ...@@ -53,6 +53,8 @@ public class TdHygfJpInverterWarnDto {
@ApiModelProperty(value = "时间") @ApiModelProperty(value = "时间")
private Long time; private Long time;
private String stationName;
private String stationContact; private String stationContact;
private String userName; private String userName;
...@@ -63,8 +65,16 @@ public class TdHygfJpInverterWarnDto { ...@@ -63,8 +65,16 @@ public class TdHygfJpInverterWarnDto {
private String address; private String address;
private String area;
private Long createdTime; private Long createdTime;
private String timeLongFormat;
private String startTimeFormat;
private String recoverTimeFormat;
private List<String> stationIds; private List<String> stationIds;
private List<String> states; private List<String> states;
......
...@@ -202,7 +202,7 @@ public class JpStation extends BaseEntity { ...@@ -202,7 +202,7 @@ public class JpStation extends BaseEntity {
@TableField("email") @TableField("email")
private Double email; //邮箱 private String email; //邮箱
......
package com.yeejoin.amos.boot.module.hygf.api.util; package com.yeejoin.amos.boot.module.hygf.api.util;
import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
...@@ -23,4 +24,50 @@ public class TimeUtil { ...@@ -23,4 +24,50 @@ public class TimeUtil {
todayEnd.set(Calendar.MILLISECOND, 999); todayEnd.set(Calendar.MILLISECOND, 999);
return todayEnd.getTime().getTime(); return todayEnd.getTime().getTime();
} }
public static String dateFormat(Long time) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return dateFormat.format(new Date(time));
}
public static String longFormat(Long time) {
if (time < 1000) {
return "0" + "秒";
}
long second = time / 1000;
long seconds = second % 60;
long minutes = second / 60;
long hours = 0;
if (minutes >= 60) {
hours = minutes / 60;
minutes = minutes % 60;
}
String timeString = "";
String secondString = "";
String minuteString = "";
String hourString = "";
if (seconds < 10) {
secondString = "0" + seconds + "秒";
} else {
secondString = seconds + "秒";
}
if (minutes < 10 && hours < 1) {
minuteString = minutes + "分";
} else if (minutes < 10) {
minuteString = "0" + minutes + "分";
} else {
minuteString = minutes + "分";
}
if (hours < 10) {
hourString = hours + "时";
} else {
hourString = hours + "" + "时";
}
if (hours != 0) {
timeString = hourString + minuteString + secondString;
} else {
timeString = minuteString + secondString;
}
return timeString;
}
} }
...@@ -5,7 +5,53 @@ ...@@ -5,7 +5,53 @@
<select id="queryForDealerReviewPage" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.JpStationDto"> <select id="queryForDealerReviewPage" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.JpStationDto">
select * from hygf_jp_station select
`sequence_nbr` sequenceNbr,
`rec_date` recDate,
`rec_user_id` recUserId,
`rec_user_name` recUserName,
`sn_code` snCode,
`capacity` capacity,
`name` ,
`code` ,
`system_code` systemCode,
`access_time` accessTime,
`create_time` createTime,
`address` ,
`longitude` ,
`latitude` ,
`price` ,
`user_name` userName,
`user_phone` userPhone,
`station_contact` stationContact,
`module_count` moduleCount,
`on_grid_type` onGridType,
`on_grid_time` onGridTime,
`third_station_id` thirdStationId,
`third_code` thirdCode,
`station_id` stationId,
`day_power_use` dayPowerUse,
`month_power_use` monthPowerUse,
`year_power_use` yearPowerUse,
FORMAT(`real_time_power`,3) realTimePower,
FORMAT(`accumulated_power`/1000,3) accumulatedPower,
`state` ,
`type`,
`organizational_code` organizationalCode,
`is_delete` isDelete,
FORMAT(`day_generate`,3) dayGenerate,
`month_generate` monthGenerate,
`year_generate` yearGenerate,
`day_income` dayIncome,
`month_income` monthIncome,
`year_income` yearIncome,
`area` ,
`cumulative_income` cumulativeIncome,
`email`
from hygf_jp_station
<where> <where>
<if test="dto.name!=null"> <if test="dto.name!=null">
and hygf_jp_station.name like concat(concat("%",#{dto.name}),"%") and hygf_jp_station.name like concat(concat("%",#{dto.name}),"%")
...@@ -37,19 +83,19 @@ ...@@ -37,19 +83,19 @@
select select
sum(real_time_power) realTimePower, FORMAT(sum(real_time_power),3) realTimePower,
sum(capacity) capacity, FORMAT(sum(capacity)/1000,3) capacity,
sum(day_generate) dayGenerate, FORMAT(sum(day_generate)/1000,3) dayGenerate,
sum(month_generate) monthGenerate, FORMAT(sum(month_generate)/1000,3) monthGenerate,
sum(year_generate) yearGenerate, FORMAT(sum(year_generate)/1000,3) yearGenerate,
sum(accumulated_power) accumulatedPower, FORMAT(sum(accumulated_power)/1000,3) accumulatedPower,
sum(day_income) dayIncome, FORMAT( sum(day_income),3) dayIncome,
sum(month_income) monthIncome, FORMAT(sum(month_income)/10000,3) monthIncome,
sum(year_income) yearIncome, FORMAT(sum(year_income)/10000,3) yearIncome,
sum(cumulative_income) cumulativeIncome, FORMAT(sum(cumulative_income)/10000,3) cumulativeIncome,
sum(day_power_use) dayPowerUse, FORMAT(sum(day_power_use)/1000,3) dayPowerUse,
sum(month_power_use) monthPowerUse, FORMAT(sum(month_power_use)/1000,3) monthPowerUse,
sum(year_power_use) yearPowerUse, FORMAT(sum(year_power_use)/1000,3) yearPowerUse,
count(*) countBuiltNum count(*) countBuiltNum
from hygf_jp_station from hygf_jp_station
<where> <where>
......
package com.yeejoin.amos.boot.module.hygf.biz.scheduled; package com.yeejoin.amos.boot.module.hygf.biz.scheduled;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.JpStationServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
...@@ -17,7 +18,7 @@ import com.yeejoin.amos.boot.module.hygf.biz.service.impl.TdHygfJpInvertorElecHi ...@@ -17,7 +18,7 @@ import com.yeejoin.amos.boot.module.hygf.biz.service.impl.TdHygfJpInvertorElecHi
public class WindSpeedScheduled { public class WindSpeedScheduled {
@Autowired @Autowired
MonthPowerServiceImpl monthPowerServiceImpl; JpStationServiceImpl jpStationServiceImpl;
@Autowired @Autowired
TdHygfJpCollectorHistoryServiceImpl tdHygfJpCollectorHistoryServiceImpl; TdHygfJpCollectorHistoryServiceImpl tdHygfJpCollectorHistoryServiceImpl;
...@@ -27,7 +28,7 @@ public class WindSpeedScheduled { ...@@ -27,7 +28,7 @@ public class WindSpeedScheduled {
@Scheduled(cron = "${cheduled.crons}") @Scheduled(cron = "${cheduled.crons}")
private void initData() { private void initData() {
monthPowerServiceImpl.getMonthPower(); jpStationServiceImpl.getMonthPower();
tdHygfJpCollectorHistoryServiceImpl.syncData(); tdHygfJpCollectorHistoryServiceImpl.syncData();
tdHygfJpInvertorElecHistoryServiceImpl.syncData(); tdHygfJpInvertorElecHistoryServiceImpl.syncData();
} }
......
...@@ -12,10 +12,12 @@ import com.yeejoin.amos.boot.module.hygf.api.dto.JpStationDto; ...@@ -12,10 +12,12 @@ import com.yeejoin.amos.boot.module.hygf.api.dto.JpStationDto;
import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.MonthPowerMapper; import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.MonthPowerMapper;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -32,6 +34,8 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS ...@@ -32,6 +34,8 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
JpStationMapper jpStationMapper; JpStationMapper jpStationMapper;
@Autowired @Autowired
MonthPowerMapper monthPowerMapper; MonthPowerMapper monthPowerMapper;
@Autowired
MonthPowerServiceImpl monthPowerServiceImpl;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -46,6 +50,12 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS ...@@ -46,6 +50,12 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
pagenew.setRecords(page.getList()); pagenew.setRecords(page.getList());
return pagenew; return pagenew;
} }
@Async
public void getMonthPower() {
monthPowerServiceImpl.getMonthPower();
}
@Override @Override
...@@ -78,7 +88,8 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS ...@@ -78,7 +88,8 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
for (int i = 0; i < listx.size(); i++) { for (int i = 0; i < listx.size(); i++) {
if(datum.getDate().equals(listx.get(i).toString())){ if(datum.getDate().equals(listx.get(i).toString())){
listy.remove(i); listy.remove(i);
listy.add(i,datum.getNum()); String format = new DecimalFormat("#.000").format(datum.getNum());
listy.add(i,format);
break; break;
} }
} }
......
...@@ -52,7 +52,7 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower, ...@@ -52,7 +52,7 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower,
@Override @Override
@Async @Transactional
public void getMonthPower() { public void getMonthPower() {
List<MonthPower> list= monthPowerMapper.getMonthPowerint(); List<MonthPower> list= monthPowerMapper.getMonthPowerint();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
......
...@@ -6,6 +6,7 @@ import java.util.HashMap; ...@@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
...@@ -23,6 +24,7 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.JpStation; ...@@ -23,6 +24,7 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.JpStation;
import com.yeejoin.amos.boot.module.hygf.api.entity.TdHygfJpInverterWarn; import com.yeejoin.amos.boot.module.hygf.api.entity.TdHygfJpInverterWarn;
import com.yeejoin.amos.boot.module.hygf.api.service.ITdHygfJpInverterWarnService; import com.yeejoin.amos.boot.module.hygf.api.service.ITdHygfJpInverterWarnService;
import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.TdHygfJpInverterWarnMapper; import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.TdHygfJpInverterWarnMapper;
import com.yeejoin.amos.boot.module.hygf.api.util.TimeUtil;
/** /**
* 户用光伏监盘逆变器报警表服务实现类 * 户用光伏监盘逆变器报警表服务实现类
...@@ -74,11 +76,20 @@ public class TdHygfJpInverterWarnServiceImpl ...@@ -74,11 +76,20 @@ public class TdHygfJpInverterWarnServiceImpl
JpStation jpStation = jpStationServiceImpl.getOne(new LambdaQueryWrapper<JpStation>() JpStation jpStation = jpStationServiceImpl.getOne(new LambdaQueryWrapper<JpStation>()
.eq(JpStation::getThirdStationId, tdHygfJpInverterWarnDto.getThirdStationId())); .eq(JpStation::getThirdStationId, tdHygfJpInverterWarnDto.getThirdStationId()));
if (jpStation != null) { if (jpStation != null) {
tdHygfJpInverterWarnDto.setStationName(jpStation.getName());
tdHygfJpInverterWarnDto.setStationContact(jpStation.getStationContact()); tdHygfJpInverterWarnDto.setStationContact(jpStation.getStationContact());
tdHygfJpInverterWarnDto.setUserName(jpStation.getUserName()); tdHygfJpInverterWarnDto.setUserName(jpStation.getUserName());
tdHygfJpInverterWarnDto.setUserPhone(jpStation.getUserPhone()); tdHygfJpInverterWarnDto.setUserPhone(jpStation.getUserPhone());
tdHygfJpInverterWarnDto.setEmail(null); tdHygfJpInverterWarnDto.setEmail(jpStation.getEmail());
tdHygfJpInverterWarnDto.setAddress(jpStation.getAddress()); tdHygfJpInverterWarnDto.setAddress(jpStation.getAddress());
tdHygfJpInverterWarnDto.setArea(jpStation.getArea());
if (tdHygfJpInverterWarnDto.getRecoverTime() != null) {
tdHygfJpInverterWarnDto
.setRecoverTimeFormat(TimeUtil.dateFormat(tdHygfJpInverterWarnDto.getRecoverTime()));
tdHygfJpInverterWarnDto.setTimeLongFormat(TimeUtil
.longFormat(tdHygfJpInverterWarnDto.getRecoverTime() - tdHygfJpInverterWarnDto.getStartTime()));
}
tdHygfJpInverterWarnDto.setStartTimeFormat(TimeUtil.dateFormat(tdHygfJpInverterWarnDto.getStartTime()));
} }
return tdHygfJpInverterWarnDto; return tdHygfJpInverterWarnDto;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment