Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 41cd594c13 | |||
| c63b92481b | |||
| 21a3c2f9cf | |||
| b8a3f9e0f9 | |||
| 855967d083 | |||
| 530f4396f7 | |||
| 584ad2e6e4 | |||
| 8e3aac4cea | |||
| f98a57c510 | |||
| 805cad8cb9 | |||
| 16aa6099ea | |||
| 237f79a56f | |||
| 2b70f531b4 | |||
| a853dafca3 | |||
| 2164e77b5a | |||
| 3286204dc0 | |||
| af7cc98d77 |
58
api-gateway/src/main/resources/application-prod.yml
Normal file
58
api-gateway/src/main/resources/application-prod.yml
Normal file
@ -0,0 +1,58 @@
|
||||
#网关
|
||||
server:
|
||||
port: 8001
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: api-gateway
|
||||
cloud:
|
||||
nacos:
|
||||
username: nacos
|
||||
password: nacos
|
||||
discovery:
|
||||
server-addr: 192.168.0.142:8848
|
||||
#路由配置
|
||||
gateway:
|
||||
routes:
|
||||
#用户中心
|
||||
- id: user_center_route
|
||||
uri: lb://user-center
|
||||
predicates:
|
||||
- Path=/api/sys/**
|
||||
#业务中心
|
||||
- id: business_route
|
||||
uri: lb://business-service
|
||||
predicates:
|
||||
- Path=/api/business/**
|
||||
#数据采集
|
||||
- id: datacollect_route
|
||||
uri: lb://datacollect-service
|
||||
predicates:
|
||||
- Path=/api/datacollect/**
|
||||
#定时任务中心
|
||||
- id: xxl_job_admin_route
|
||||
uri: lb://xxl-job-admin
|
||||
predicates:
|
||||
- Path=/job-admin/**
|
||||
#多媒体文件
|
||||
- id: file_center_route
|
||||
uri: lb://file-center
|
||||
predicates:
|
||||
- Path=/api/media/**
|
||||
|
||||
#告警和流程中心
|
||||
- id: flow_center_route
|
||||
uri: lb://flowable-center
|
||||
predicates:
|
||||
- Path=/api/flow/**
|
||||
|
||||
#actuator监控检查配置
|
||||
management:
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
health:
|
||||
redis:
|
||||
enabled: false
|
||||
#需要校验:true ,不需要校验:false
|
||||
isCheckLicence: false
|
||||
@ -9,9 +9,9 @@
|
||||
</appender>
|
||||
|
||||
<appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/api-gateway/api-gateway.log</file>
|
||||
<file>/www/zzkjcloud/logs/api-gateway/api-gateway.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/api-gateway/api-gateway.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>/www/zzkjcloud/logs/api-gateway/api-gateway.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>10</maxHistory>
|
||||
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
package com.ho.business.vo.resp;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 主监控汇总信息
|
||||
*/
|
||||
@Data
|
||||
public class ShipStationRespVO {
|
||||
|
||||
@ApiModelProperty(value = "储能系统累计收益,单位(元)")
|
||||
private Float incomeSum;
|
||||
@ApiModelProperty(value = "储能系统昨⽇收益")
|
||||
private Float incomeYesterday;
|
||||
@ApiModelProperty(value = "储能系统累计充电量,单位(kWh)")
|
||||
private Float positivePowerSum;
|
||||
@ApiModelProperty(value = "储能系统累计放电量,单位(kWh)")
|
||||
private Float reversePowerSum;
|
||||
@ApiModelProperty(value = "储能系统今⽇充电量,单位(kWh)")
|
||||
private Float positivePowerToday;
|
||||
@ApiModelProperty(value = "储能系统今⽇放电量,单位(kWh)")
|
||||
private Float reversePowerToday;
|
||||
@ApiModelProperty(value = "储能系统实时功率,单位(kw)")
|
||||
private Float realTimePower;
|
||||
@ApiModelProperty(value = "关⼝表电压,单位(v)")
|
||||
private Float voltage;
|
||||
@ApiModelProperty(value = "储能系统剩余电量,单位(kwh)")
|
||||
private Float surplus;
|
||||
@ApiModelProperty(value = "储能系统剩余SOC")
|
||||
private Float soc;
|
||||
@ApiModelProperty(value = "储能系统装机容量,单位(kWh)")
|
||||
private Integer capacity;
|
||||
@ApiModelProperty(value = "储能系统投运时⻓,单位(天)")
|
||||
private Integer operationTime;
|
||||
@ApiModelProperty(value = "储能系统能量链数量,单位(条)")
|
||||
private Integer eLinkNumber;
|
||||
@ApiModelProperty(value = "储能系统在线能量链数量,单位(条)")
|
||||
private Integer eLinkOnline;
|
||||
@ApiModelProperty(value = "储能系统能量块数量,单位(个)")
|
||||
private Integer eBLockNumber;
|
||||
@ApiModelProperty(value = "储能系统在线能量块数量,单位(个)")
|
||||
private Integer eBlockOnline;
|
||||
@ApiModelProperty(value = "储能系统今⽇功率和soc曲线")
|
||||
private JSONArray historyDataList;
|
||||
}
|
||||
@ -31,6 +31,8 @@ public class AnnualOverviewResp {
|
||||
@ApiModelProperty(value = "年总充")
|
||||
BigDecimal yearCharge;
|
||||
|
||||
@ApiModelProperty(value = "今日收益")
|
||||
BigDecimal todayProfit;
|
||||
|
||||
@ApiModelProperty(value = "昨日收益")
|
||||
BigDecimal yestProfit;
|
||||
|
||||
@ -29,6 +29,8 @@ public interface EarningsCalculateMapper {
|
||||
|
||||
int deleteByDay(@Param("day") String day, @Param("typeList") List<Integer> typeList);
|
||||
|
||||
int deleteByStationAndDay(@Param("day") String day, @Param("typeList") List<Integer> typeList, @Param("stationId") Integer stationId);
|
||||
|
||||
int insertBatch(List<EarningsCalculate> list);
|
||||
// 类型是传入多个
|
||||
//List<EarningsCalculate> selectList(@Param("stationId") Integer stationId, @Param("typeList") List<Integer> typeList, @Param("beginTime") String beginTime, @Param("endTime") String endTime);
|
||||
|
||||
@ -36,7 +36,7 @@ public interface StationMapper {
|
||||
|
||||
List<Station> selectByDimName(String name,Integer groupId);
|
||||
|
||||
List<Station> selectByIds(List<Integer> ids);
|
||||
List<Station> selectByIds(@Param("ids") List<Integer> ids,@Param("lang") String lang);
|
||||
|
||||
Station selectByNameAndId(@Param("name") String name, @Param("id") Integer id, @Param("deptId") Integer deptId);
|
||||
|
||||
|
||||
@ -0,0 +1,354 @@
|
||||
package com.ho.business.service;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.ho.business.constant.DeviceTypeConstant;
|
||||
import com.ho.business.entity.EarningsCalculate;
|
||||
import com.ho.business.entity.ElecMeterValue;
|
||||
import com.ho.business.mapper.EarningsCalculateMapper;
|
||||
import com.ho.business.vo.req.carbin.EarningsCalculateReq;
|
||||
import com.ho.business.vo.resp.ShipStationRespVO;
|
||||
import com.ho.common.tools.constant.CommonConstant;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.HttpUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 成都巨石 能源 储能
|
||||
* 成都巨石能源 API 接口 服务
|
||||
*
|
||||
* @author kerwin
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class BoulderEnergyService {
|
||||
|
||||
/**
|
||||
* 获取token 参数 appAccount
|
||||
*/
|
||||
private static final String APP_ACCOUNT = "cdjs_app";
|
||||
/**
|
||||
* 获取token 参数 appSecretKey
|
||||
*/
|
||||
private static final String APP_SECRET_KEY = "cdjs@0108";
|
||||
/**
|
||||
* 中车- 获取电站id
|
||||
*/
|
||||
private static final Integer BOULDER_STATION_ID = 11006;
|
||||
|
||||
|
||||
/**
|
||||
* 中车- 获取token Url
|
||||
*/
|
||||
private static final String TOKEN_URL = "http://111.15.176.77:18082/gate-newpc/zhny-openapi/openapi/v1/authentication/getAccessToken";
|
||||
|
||||
/**
|
||||
* 中车- 统计数据 Url
|
||||
*/
|
||||
private static final String BOULDER_DATA_URL = "http://111.15.176.77:18082/gate-newpc/zhny-openapi/openapi/v1/statistics/station/qryIncDayBill";
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
ElecMeterValueService elecMeterValueService;
|
||||
|
||||
@Autowired
|
||||
EarningsCalculateMapper earningsCalculateMapper;
|
||||
|
||||
/**
|
||||
* 中车能源 - 获取token
|
||||
* @return token
|
||||
*/
|
||||
public String getToken(){
|
||||
String token = null;
|
||||
if(redisService.hasKey(CommonConstant.BOULDER_ENERGY_TOKEN_KEY)){
|
||||
token = (String)redisService.get(CommonConstant.BOULDER_ENERGY_TOKEN_KEY);
|
||||
return token;
|
||||
}
|
||||
Map<String, Object> params = Maps.newHashMap();
|
||||
params.put("appAccount",APP_ACCOUNT);
|
||||
params.put("appSecretKey",APP_SECRET_KEY);
|
||||
try {
|
||||
String json = HttpUtils.postWithJson(TOKEN_URL,params);
|
||||
log.info("json:" + TOKEN_URL);
|
||||
log.info("json:" + json);
|
||||
JSONObject jsonObject = JSONObject.parseObject(json);
|
||||
Integer code = jsonObject.getInteger("code");
|
||||
if(CommonConstant.HttpCode.SUCCESS_CODE.equals(code)){
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
token = data.getString("accessToken");
|
||||
//redis 缓存
|
||||
redisService.set(CommonConstant.BOULDER_ENERGY_TOKEN_KEY,token,50, TimeUnit.SECONDS);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 中车能源 - 统计数据
|
||||
* @param beginTime 开始时间
|
||||
* @return
|
||||
*/
|
||||
public String getBoulderData(String beginTime){
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", getToken());
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("stationCode","SC020075040001");
|
||||
params.put("time",beginTime);
|
||||
String contentType = "application/json; charset=utf-8";
|
||||
try {
|
||||
String json = HttpUtils.postWithHeaders(BOULDER_DATA_URL,HttpUtils.mapToJson(params),contentType,headers);
|
||||
log.info("MAIN_URL:" + BOULDER_DATA_URL);
|
||||
log.info("json:" + json);
|
||||
JSONObject jsonObject = JSONObject.parseObject(json);
|
||||
Integer code = jsonObject.getInteger("code");
|
||||
if(CommonConstant.HttpCode.SUCCESS_CODE.equals(code)){
|
||||
String data = jsonObject.getString("data");
|
||||
JSONObject dataJson = JSONObject.parseObject(data);
|
||||
return dataJson.getString("records");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/*****************************************业务处理******************************************************/
|
||||
|
||||
/**
|
||||
* 中车 - 获取电站历史收益、充放电数据并存储
|
||||
*/
|
||||
public void getBoulderEleIncome(String beginTime){
|
||||
DateTime yesterday = DateUtil.yesterday();
|
||||
String yesterdayStr = DateUtil.formatDate(yesterday);
|
||||
if(beginTime==null){
|
||||
beginTime = yesterdayStr;
|
||||
}
|
||||
long timestamp = dateStringToTimestamp(beginTime);
|
||||
String records = getBoulderData(String.valueOf(timestamp));
|
||||
JSONArray data = JSON.parseArray(records);
|
||||
String finalBeginTime = beginTime;
|
||||
data.forEach(i->{
|
||||
List<EarningsCalculate> list = new ArrayList<>();
|
||||
List<ElecMeterValue> elecList = new ArrayList<>();
|
||||
JSONObject obj = (JSONObject) i;
|
||||
String date = timestampToDateString(obj.getLong("balanceDate"));
|
||||
if(finalBeginTime.equals(date)){
|
||||
//收益-充-尖
|
||||
EarningsCalculate sharpCharge = new EarningsCalculate();
|
||||
BigDecimal sharpChargeEle = obj.getBigDecimal("sharpChargeElectricity");
|
||||
sharpCharge.setElec(sharpChargeEle);
|
||||
sharpCharge.setType(0);
|
||||
sharpCharge.setRateType(CommonConstant.RateType.TIP);
|
||||
sharpCharge.setPrice(BigDecimal.ZERO);
|
||||
sharpCharge.setDigital(BigDecimal.ZERO);
|
||||
sharpCharge.setTotal(BigDecimal.ZERO);
|
||||
list.add(sharpCharge);
|
||||
//收益-充-峰
|
||||
EarningsCalculate peakCharge = new EarningsCalculate();
|
||||
BigDecimal peakChargeEle = obj.getBigDecimal("peakChargeElectricity");
|
||||
peakCharge.setElec(peakChargeEle);
|
||||
peakCharge.setType(0);
|
||||
peakCharge.setRateType(CommonConstant.RateType.PEAK);
|
||||
peakCharge.setPrice(BigDecimal.ZERO);
|
||||
peakCharge.setDigital(BigDecimal.ZERO);
|
||||
peakCharge.setTotal(BigDecimal.ZERO);
|
||||
list.add(peakCharge);
|
||||
//收益-充-平
|
||||
EarningsCalculate flatCharge = new EarningsCalculate();
|
||||
BigDecimal flatChargeEle = obj.getBigDecimal("flatChargeElectricity");
|
||||
flatCharge.setElec(flatChargeEle);
|
||||
flatCharge.setType(0);
|
||||
flatCharge.setRateType(CommonConstant.RateType.FLAT);
|
||||
flatCharge.setPrice(BigDecimal.ZERO);
|
||||
flatCharge.setDigital(BigDecimal.ZERO);
|
||||
flatCharge.setTotal(BigDecimal.ZERO);
|
||||
list.add(flatCharge);
|
||||
//收益-充-谷
|
||||
EarningsCalculate valleyCharge = new EarningsCalculate();
|
||||
BigDecimal valleyChargeEle = obj.getBigDecimal("valleyChargeElectricity");
|
||||
valleyCharge.setElec(valleyChargeEle);
|
||||
valleyCharge.setType(0);
|
||||
valleyCharge.setRateType(CommonConstant.RateType.VALLEY);
|
||||
valleyCharge.setPrice(BigDecimal.ZERO);
|
||||
valleyCharge.setDigital(BigDecimal.ZERO);
|
||||
valleyCharge.setTotal(BigDecimal.ZERO);
|
||||
list.add(valleyCharge);
|
||||
//收益-充-深谷
|
||||
EarningsCalculate deepValleyCharge = new EarningsCalculate();
|
||||
BigDecimal deepValleyChargeEle = obj.getBigDecimal("deepValleyChargeElectricity");
|
||||
deepValleyCharge.setElec(deepValleyChargeEle);
|
||||
deepValleyCharge.setType(0);
|
||||
deepValleyCharge.setRateType(CommonConstant.RateType.DEEP_VALLEY);
|
||||
deepValleyCharge.setPrice(BigDecimal.ZERO);
|
||||
deepValleyCharge.setDigital(BigDecimal.ZERO);
|
||||
deepValleyCharge.setTotal(BigDecimal.ZERO);
|
||||
list.add(deepValleyCharge);
|
||||
//收益-放-尖
|
||||
EarningsCalculate sharpDischarge = new EarningsCalculate();
|
||||
BigDecimal reverseSharp = obj.getBigDecimal("sharpDischargeElectricity");
|
||||
sharpDischarge.setElec(reverseSharp);
|
||||
sharpDischarge.setType(1);
|
||||
sharpDischarge.setRateType(CommonConstant.RateType.TIP);
|
||||
sharpDischarge.setPrice(BigDecimal.ZERO);
|
||||
sharpDischarge.setDigital(BigDecimal.ZERO);
|
||||
sharpDischarge.setTotal(BigDecimal.ZERO);
|
||||
list.add(sharpDischarge);
|
||||
//收益-放-峰
|
||||
EarningsCalculate peakDischarge = new EarningsCalculate();
|
||||
BigDecimal peakDischargeEle = obj.getBigDecimal("peakDischargeElectricity");
|
||||
peakDischarge.setElec(peakDischargeEle);
|
||||
peakDischarge.setType(1);
|
||||
peakDischarge.setRateType(CommonConstant.RateType.PEAK);
|
||||
peakDischarge.setPrice(BigDecimal.ZERO);
|
||||
peakDischarge.setDigital(BigDecimal.ZERO);
|
||||
peakDischarge.setTotal(BigDecimal.ZERO);
|
||||
list.add(peakDischarge);
|
||||
//收益-放-平
|
||||
EarningsCalculate flatDischarge = new EarningsCalculate();
|
||||
BigDecimal flatDischargeEle = obj.getBigDecimal("flatDischargeElectricity");
|
||||
flatDischarge.setElec(flatDischargeEle);
|
||||
flatDischarge.setType(1);
|
||||
flatDischarge.setRateType(CommonConstant.RateType.FLAT);
|
||||
flatDischarge.setPrice(BigDecimal.ZERO);
|
||||
flatDischarge.setDigital(BigDecimal.ZERO);
|
||||
flatDischarge.setTotal(BigDecimal.ZERO);
|
||||
list.add(flatDischarge);
|
||||
//收益-放-谷
|
||||
EarningsCalculate valleyDischarge = new EarningsCalculate();
|
||||
BigDecimal valleyDischargeEle = obj.getBigDecimal("valleyDischargeElectricity");
|
||||
valleyDischarge.setElec(valleyDischargeEle);
|
||||
valleyDischarge.setType(1);
|
||||
valleyDischarge.setRateType(CommonConstant.RateType.VALLEY);
|
||||
valleyDischarge.setPrice(BigDecimal.ZERO);
|
||||
valleyDischarge.setDigital(BigDecimal.ZERO);
|
||||
valleyDischarge.setTotal(BigDecimal.ZERO);
|
||||
list.add(valleyDischarge);
|
||||
//收益-放-深谷
|
||||
EarningsCalculate deepValleyDischarge = new EarningsCalculate();
|
||||
BigDecimal deepValleyDischargeEle = obj.getBigDecimal("deepValleyDischargeElectricity");
|
||||
BigDecimal income = obj.getBigDecimal("income");
|
||||
deepValleyDischarge.setElec(deepValleyDischargeEle);
|
||||
deepValleyDischarge.setType(1);
|
||||
deepValleyDischarge.setRateType(CommonConstant.RateType.DEEP_VALLEY);
|
||||
deepValleyDischarge.setPrice(BigDecimal.ZERO);
|
||||
deepValleyDischarge.setDigital(income);
|
||||
deepValleyDischarge.setTotal(income);
|
||||
list.add(deepValleyDischarge);
|
||||
// 充电
|
||||
ElecMeterValue charge = new ElecMeterValue();
|
||||
BigDecimal chargeEle = obj.getBigDecimal("chargeElectricity");
|
||||
charge.setDigital(chargeEle);
|
||||
charge.setType(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.CHARGE);
|
||||
charge.setStatus(CommonConstant.STATUS_FLAG);
|
||||
elecList.add(charge);
|
||||
// 放电
|
||||
ElecMeterValue disCharge = new ElecMeterValue();
|
||||
BigDecimal dischargeEle = obj.getBigDecimal("dischargeElectricity");
|
||||
disCharge.setDigital(dischargeEle);
|
||||
disCharge.setType(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.DISCHARGE);
|
||||
disCharge.setStatus(CommonConstant.STATUS_FLAG);
|
||||
elecList.add(disCharge);
|
||||
|
||||
if(elecList.size()>0){
|
||||
//删除
|
||||
elecMeterValueService.deleteByStationAndDay(BOULDER_STATION_ID,date,null);
|
||||
elecList.forEach(eleMeter -> {
|
||||
eleMeter.setGroupId(155);
|
||||
eleMeter.setStationId(BOULDER_STATION_ID);
|
||||
eleMeter.setCreateTime(new Date());
|
||||
eleMeter.setDay(date);
|
||||
//新增
|
||||
elecMeterValueService.insert(eleMeter);
|
||||
});
|
||||
}
|
||||
if(list.size()>0){
|
||||
//删除
|
||||
earningsCalculateMapper.deleteByStationAndDay(date,null,BOULDER_STATION_ID);
|
||||
list.forEach(a->{
|
||||
a.setGroupId(155);
|
||||
a.setStationId(BOULDER_STATION_ID);
|
||||
a.setCreateTime(new Date());
|
||||
a.setDay(date);
|
||||
a.setDiscount(BigDecimal.ONE);
|
||||
//新增
|
||||
earningsCalculateMapper.insertSelective(a);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
public void getCacheBoulderData(){
|
||||
ShipStationRespVO vo = new ShipStationRespVO();
|
||||
//查询电站收益数据
|
||||
EarningsCalculateReq ec = new EarningsCalculateReq();
|
||||
//昨日
|
||||
DateTime yesterday = DateUtil.yesterday();
|
||||
String yesterdayStr = DateUtil.formatDate(yesterday);
|
||||
//今日
|
||||
DateTime nowDay = DateUtil.date();
|
||||
String nowDayStr = DateUtil.formatDate(nowDay);
|
||||
//查询电站所有收益数据-组装参数
|
||||
ec.setStationId(BOULDER_STATION_ID);
|
||||
ec.setBeginTime(earningsCalculateMapper.getFirstTime());
|
||||
ec.setEndTime(nowDayStr);
|
||||
List<EarningsCalculate> earnList = earningsCalculateMapper.selectList(ec);
|
||||
// 累计充电、放电、收益
|
||||
BigDecimal incomeSum = earnList.stream().map(EarningsCalculate::getDigital).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal positivePowerSum = earnList.stream().filter(i->i.getType().equals(CommonConstant.ZERO)).map(EarningsCalculate::getElec).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal reversePowerSum = earnList.stream().filter(i->i.getType().equals(CommonConstant.ONE)).map(EarningsCalculate::getElec).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
vo.setIncomeSum(incomeSum.floatValue());
|
||||
vo.setPositivePowerSum(positivePowerSum.floatValue());
|
||||
vo.setReversePowerSum(reversePowerSum.floatValue());
|
||||
// 昨日收益
|
||||
BigDecimal incomeYesterday = earnList.stream().filter(i->i.getDay().equals(yesterdayStr)).map(EarningsCalculate::getDigital).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
vo.setIncomeYesterday(incomeYesterday.floatValue());
|
||||
// 今日充、放电
|
||||
BigDecimal positivePowerToday = earnList.stream().filter(i->i.getDay().equals(nowDayStr)&&i.getType().equals(CommonConstant.ZERO)).map(EarningsCalculate::getElec).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
vo.setPositivePowerToday(positivePowerToday.floatValue());
|
||||
BigDecimal reversePowerToday = earnList.stream().filter(i->i.getDay().equals(nowDayStr)&&i.getType().equals(CommonConstant.ONE)).map(EarningsCalculate::getElec).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
vo.setReversePowerToday(reversePowerToday.floatValue());
|
||||
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + BOULDER_STATION_ID;
|
||||
redisService.set(mainKey,JSONObject.toJSONString(vo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间日期 转换为时间戳
|
||||
* @param dateStr yyyy-MM-dd
|
||||
* @return long 时间戳
|
||||
*/
|
||||
public static long dateStringToTimestamp(String dateStr) {
|
||||
LocalDate localDate = LocalDate.parse(dateStr, DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
return localDate.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
}
|
||||
|
||||
/**
|
||||
* 毫秒级时间戳 转换为日期 yyyy-MM-dd
|
||||
* @param timestamp long 时间戳
|
||||
* @return yyyy-MM-dd
|
||||
*/
|
||||
public static String timestampToDateString(long timestamp) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(CommonConstant.DATE_YMD);
|
||||
return Instant.ofEpochMilli(timestamp)
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.format(formatter);
|
||||
}
|
||||
}
|
||||
@ -62,7 +62,7 @@ public interface IargeScreenShowService {
|
||||
* @param stationIds
|
||||
* @return
|
||||
*/
|
||||
List<Subdata> getCommonRegionList(List<Integer> stationIds);
|
||||
List<Subdata> getCommonRegionList(List<Integer> stationIds,String lang);
|
||||
|
||||
/**
|
||||
* 获取节能减排数据
|
||||
@ -90,27 +90,27 @@ public interface IargeScreenShowService {
|
||||
* 查询收益按电站分组
|
||||
* @return
|
||||
*/
|
||||
List<Subdata> getCommonProfit(String beginString, String endString,List<Integer> stationIds);
|
||||
List<Subdata> getCommonProfit(String beginString, String endString,List<Integer> stationIds,String lang);
|
||||
|
||||
/**
|
||||
* 通用系统转换率
|
||||
* @param stationIds
|
||||
* @return
|
||||
*/
|
||||
List<Subdata> getCommonEfficiencyDate(List<Integer> stationIds);
|
||||
List<Subdata> getCommonEfficiencyDate(List<Integer> stationIds,String lang);
|
||||
|
||||
/**
|
||||
* 获取统计电站信息
|
||||
* @param stationIds
|
||||
* @return
|
||||
*/
|
||||
List<Station> getCountStations(List<Integer> stationIds);
|
||||
List<Station> getCountStations(List<Integer> stationIds,String lang);
|
||||
|
||||
/**
|
||||
* 通用装机容量倒排
|
||||
* @return
|
||||
*/
|
||||
List<Subdata> getCommonCapacity(List<Integer> stationIds);
|
||||
List<Subdata> getCommonCapacity(List<Integer> stationIds,String lang);
|
||||
|
||||
/**
|
||||
* 通用根据天获取告警数目曲线
|
||||
|
||||
@ -0,0 +1,446 @@
|
||||
package com.ho.business.service;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.ho.business.constant.DeviceTypeConstant;
|
||||
import com.ho.business.entity.EarningsCalculate;
|
||||
import com.ho.business.entity.ElecMeterValue;
|
||||
import com.ho.business.entity.Station;
|
||||
import com.ho.business.mapper.EarningsCalculateMapper;
|
||||
import com.ho.business.vo.req.StationReqVO;
|
||||
import com.ho.business.vo.resp.ShipStationRespVO;
|
||||
import com.ho.common.tools.constant.CommonConstant;
|
||||
import com.ho.common.tools.exception.BaseResponseCode;
|
||||
import com.ho.common.tools.exception.BusinessException;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.HttpUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.jsf.FacesContextUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 西安寄点能源股份有限公司
|
||||
* 西安寄点能源 API 接口 服务
|
||||
*
|
||||
* @author kerwin
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ShipEnergyService {
|
||||
|
||||
|
||||
/**
|
||||
* 获取token 参数 platform
|
||||
*/
|
||||
private static final String PLATFORM = "f9599b6c79a5efbfc6ddce5fed1bbed5";
|
||||
|
||||
/**
|
||||
* 获取token 参数 platformsecret
|
||||
*/
|
||||
private static final String PLATFORM_SECRET = "2928b16f9cb8e85199a4caa6ba3b6620";
|
||||
|
||||
/**
|
||||
* 寄点能源- 获取token Url
|
||||
*/
|
||||
private static final String TOKEN_URL = "https://www.emind2000.cloud/rest-api/gettoken";
|
||||
|
||||
/**
|
||||
* 寄点能源- 获取项目列表 Url
|
||||
*/
|
||||
private static final String STATION_URL = "https://www.emind2000.cloud/rest-api/getStations";
|
||||
|
||||
/**
|
||||
* 寄点能源- 主监控汇总 Url
|
||||
*/
|
||||
private static final String MAIN_URL = "https://www.emind2000.cloud/rest-api/getMainTotal";
|
||||
/**
|
||||
* 寄点能源- 历史收益 Url
|
||||
*/
|
||||
private static final String INCOME_HIS_URL = "https://www.emind2000.cloud/rest-api/getIncomeHis";
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private StationService stationService;
|
||||
|
||||
@Autowired
|
||||
ElecMeterValueService elecMeterValueService;
|
||||
|
||||
@Autowired
|
||||
EarningsCalculateMapper earningsCalculateMapper;
|
||||
|
||||
/**
|
||||
* 寄点能源 - 获取token
|
||||
* @return token
|
||||
*/
|
||||
public String getToken(){
|
||||
String token = null;
|
||||
if(redisService.hasKey(CommonConstant.SHIP_ENERGY_TOKEN_KEY)){
|
||||
token = (String)redisService.get(CommonConstant.SHIP_ENERGY_TOKEN_KEY);
|
||||
return token;
|
||||
}
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
params.put("platform",PLATFORM);
|
||||
params.put("platformsecret",PLATFORM_SECRET);
|
||||
try {
|
||||
String json = HttpUtils.getWithForm(TOKEN_URL,params);
|
||||
log.info("json:" + TOKEN_URL);
|
||||
log.info("json:" + json);
|
||||
JSONObject jsonObject = JSONObject.parseObject(json);
|
||||
Integer code = jsonObject.getInteger("code");
|
||||
if(CommonConstant.HttpCode.SUCCESS_CODE.equals(code)){
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
token = data.getString("access_token");
|
||||
//redis 缓存
|
||||
redisService.set(CommonConstant.SHIP_ENERGY_TOKEN_KEY,token,10, TimeUnit.HOURS);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 寄点能源 - 获取 项目列表
|
||||
* @return 项目列表 json 字符串
|
||||
*/
|
||||
public String getStations(){
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", getToken());
|
||||
try {
|
||||
String json = HttpUtils.getWithHeaders(STATION_URL,null,headers);
|
||||
log.info("json:" + STATION_URL);
|
||||
log.info("json:" + json);
|
||||
JSONObject jsonObject = JSONObject.parseObject(json);
|
||||
Integer code = jsonObject.getInteger("code");
|
||||
if(CommonConstant.HttpCode.SUCCESS_CODE.equals(code)){
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
return data.getString("rows");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 寄点能源 - 获取 主监控汇总信息
|
||||
* @param stationId 电站id
|
||||
* @return 返回对应电站汇总信息
|
||||
*/
|
||||
public String getMainTotal(Integer stationId){
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", getToken());
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("stationId",stationId.toString());
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
String json = HttpUtils.getWithHeaders(MAIN_URL,params,headers);
|
||||
log.info("MAIN_URL:" + MAIN_URL);
|
||||
log.info("json:" + json);
|
||||
JSONObject jsonObject = JSONObject.parseObject(json);
|
||||
Integer code = jsonObject.getInteger("code");
|
||||
if(CommonConstant.HttpCode.SUCCESS_CODE.equals(code)){
|
||||
return jsonObject.getString("data");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 寄点能源 - 获取 历史收益查询
|
||||
*/
|
||||
public String getIncomeHis(Integer stationId,String beginTime){
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put("Authorization", getToken());
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("stationId",stationId.toString());
|
||||
params.put("startTime",beginTime+CommonConstant.START_SUFFIX_TIMESTAMP);
|
||||
params.put("endTime",beginTime+CommonConstant.END_SUFFIX_TIMESTAMP);
|
||||
try {
|
||||
String json = HttpUtils.getWithHeaders(INCOME_HIS_URL,params,headers);
|
||||
log.info("INCOME_HIS_URL:" + INCOME_HIS_URL);
|
||||
log.info("json:" + json);
|
||||
JSONObject jsonObject = JSONObject.parseObject(json);
|
||||
Integer code = jsonObject.getInteger("code");
|
||||
if(CommonConstant.HttpCode.SUCCESS_CODE.equals(code)){
|
||||
return jsonObject.getString("data");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/*****************************************业务处理******************************************************/
|
||||
|
||||
/**
|
||||
* 寄点能源 - 电站信息融合储能平台处理
|
||||
*/
|
||||
public void addShipEnergyStation(){
|
||||
String json = getStations();
|
||||
JSONArray jsonStation = JSON.parseArray(json);
|
||||
jsonStation.forEach(i->{
|
||||
JSONObject jsonObj = (JSONObject) i;
|
||||
Integer stationId = jsonObj.getInteger("stationId");
|
||||
String name = jsonObj.getString("name");
|
||||
String address = jsonObj.getString("address");
|
||||
String province = jsonObj.getString("province");
|
||||
String city = jsonObj.getString("city");
|
||||
BigDecimal longitude = jsonObj.getBigDecimal("longitude");
|
||||
BigDecimal latitude = jsonObj.getBigDecimal("latitude");
|
||||
BigDecimal maxPower = jsonObj.getBigDecimal("maxPower");
|
||||
BigDecimal capacity = jsonObj.getBigDecimal("capacity");
|
||||
Date commossioningTime = jsonObj.getDate("commossioningTime");
|
||||
StationReqVO vo = new StationReqVO();
|
||||
vo.setId(stationId+10000);
|
||||
vo.setName(name);
|
||||
vo.setAddress(address);
|
||||
vo.setLongitude(longitude);
|
||||
vo.setLatitude(latitude);
|
||||
vo.setCapacity(capacity);
|
||||
vo.setRatePower(maxPower);
|
||||
vo.setGridTime(commossioningTime);
|
||||
vo.setGroupId(155);
|
||||
vo.setDeptId(592);
|
||||
vo.setStatus(1);
|
||||
vo.setType(7);
|
||||
vo.setPId(0);
|
||||
vo.setIsDailyCount(0);
|
||||
vo.setTopologyType(1);
|
||||
vo.setCupboardType(2);
|
||||
Station station = stationService.selectByName(vo.getName());
|
||||
if (station != null) {
|
||||
throw new BusinessException(BaseResponseCode.STATION_ALREADY_EXISTS);
|
||||
}
|
||||
stationService.insertStation(vo);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 寄点能源 - 缓存电站监控信息
|
||||
*/
|
||||
public void getShipEnergyTotal(){
|
||||
String stations = getStations();
|
||||
JSONArray jsonStation = JSON.parseArray(stations);
|
||||
jsonStation.forEach(i->{
|
||||
JSONObject jsonObj = (JSONObject) i;
|
||||
Integer stationId = jsonObj.getInteger("stationId");
|
||||
String json = getMainTotal(stationId);
|
||||
Integer finalStationId = stationId +10000;
|
||||
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + finalStationId;
|
||||
redisService.set(mainKey,json);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 寄点能源 - 获取寄点电站历史收益 并存储
|
||||
*/
|
||||
public void getStationIncomeHis(String beginTime){
|
||||
DateTime yesterday = DateUtil.yesterday();
|
||||
String yesterdayStr = DateUtil.formatDate(yesterday);
|
||||
if(beginTime==null){
|
||||
beginTime = yesterdayStr;
|
||||
}
|
||||
String stations = getStations();
|
||||
JSONArray jsonStation = JSON.parseArray(stations);
|
||||
String finalBeginTime = beginTime;
|
||||
log.info("传入参数-统计时间:{}",beginTime);
|
||||
jsonStation.forEach(i->{
|
||||
JSONObject jsonObj = (JSONObject) i;
|
||||
Integer stationId = jsonObj.getInteger("stationId");
|
||||
String incomeHis = getIncomeHis(stationId, finalBeginTime);
|
||||
JSONArray incomes = JSON.parseArray(incomeHis);
|
||||
log.info("远程查询-历史收益数据:{}",incomes);
|
||||
incomes.forEach(j->{
|
||||
JSONObject income = (JSONObject) j;
|
||||
String date = income.getString("date");
|
||||
String price = income.getString("price");
|
||||
JsonObject jsonPrice = JsonParser.parseString(price).getAsJsonObject();
|
||||
List<EarningsCalculate> list = new ArrayList<>();
|
||||
List<ElecMeterValue> elecList = new ArrayList<>();
|
||||
BigDecimal inTotalIncome = BigDecimal.ZERO;
|
||||
BigDecimal outTotalIncome = BigDecimal.ZERO;
|
||||
log.info("远程查询-统计日期:{}",date);
|
||||
if(finalBeginTime.equals(date)){
|
||||
//收益-充-尖
|
||||
EarningsCalculate inSharp = new EarningsCalculate();
|
||||
BigDecimal positiveSharp = income.getBigDecimal("sum_e_positive_sharp");
|
||||
inSharp.setElec(positiveSharp);
|
||||
inSharp.setType(0);
|
||||
inSharp.setRateType(CommonConstant.RateType.TIP);
|
||||
BigDecimal inSharpPrice = jsonPrice.get("in_sharp_price").getAsBigDecimal();
|
||||
inSharp.setPrice(inSharpPrice);
|
||||
inSharp.setDigital(positiveSharp.multiply(inSharpPrice));
|
||||
inTotalIncome = inTotalIncome.add(inSharp.getDigital());
|
||||
inSharp.setTotal(BigDecimal.ZERO);
|
||||
list.add(inSharp);
|
||||
//收益-充-峰
|
||||
EarningsCalculate inPeak = new EarningsCalculate();
|
||||
BigDecimal positivePeak = income.getBigDecimal("sum_e_positive_peak");
|
||||
inPeak.setElec(positivePeak);
|
||||
inPeak.setType(0);
|
||||
inPeak.setRateType(CommonConstant.RateType.PEAK);
|
||||
BigDecimal inPeakPrice = jsonPrice.get("in_peak_price").getAsBigDecimal();
|
||||
inPeak.setPrice(inPeakPrice);
|
||||
inPeak.setDigital(positivePeak.multiply(inPeakPrice));
|
||||
inTotalIncome = inTotalIncome.add(inPeak.getDigital());
|
||||
inPeak.setTotal(BigDecimal.ZERO);
|
||||
list.add(inPeak);
|
||||
//收益-充-平
|
||||
EarningsCalculate inFlat = new EarningsCalculate();
|
||||
BigDecimal positiveFlat = income.getBigDecimal("sum_e_positive_flat");
|
||||
inFlat.setElec(positiveFlat);
|
||||
inFlat.setType(0);
|
||||
inFlat.setRateType(CommonConstant.RateType.FLAT);
|
||||
BigDecimal inFlatPrice = jsonPrice.get("in_flat_price").getAsBigDecimal();
|
||||
inFlat.setPrice(inFlatPrice);
|
||||
inFlat.setDigital(positiveFlat.multiply(inFlatPrice));
|
||||
inTotalIncome = inTotalIncome.add(inFlat.getDigital());
|
||||
inFlat.setTotal(BigDecimal.ZERO);
|
||||
list.add(inFlat);
|
||||
//收益-充-谷
|
||||
EarningsCalculate inValley = new EarningsCalculate();
|
||||
BigDecimal positiveValley = income.getBigDecimal("sum_e_positive_valley");
|
||||
inValley.setElec(positiveValley);
|
||||
inValley.setType(0);
|
||||
inValley.setRateType(CommonConstant.RateType.VALLEY);
|
||||
BigDecimal inValleyPrice = jsonPrice.get("in_valley_price").getAsBigDecimal();
|
||||
inValley.setPrice(inValleyPrice);
|
||||
inValley.setDigital(positiveValley.multiply(inValleyPrice));
|
||||
inTotalIncome = inTotalIncome.add(inValley.getDigital());
|
||||
inValley.setTotal(BigDecimal.ZERO);
|
||||
list.add(inValley);
|
||||
//收益-充-深谷
|
||||
EarningsCalculate inDeepValley = new EarningsCalculate();
|
||||
BigDecimal positiveDeepValley = income.getBigDecimal("sum_e_positive_deep_valley");
|
||||
inDeepValley.setElec(positiveDeepValley);
|
||||
inDeepValley.setType(0);
|
||||
inDeepValley.setRateType(CommonConstant.RateType.DEEP_VALLEY);
|
||||
BigDecimal inDeepValleyPrice = jsonPrice.get("in_deep_valley_price").getAsBigDecimal();
|
||||
inDeepValley.setPrice(inDeepValleyPrice);
|
||||
inDeepValley.setDigital(positiveDeepValley.multiply(inDeepValleyPrice));
|
||||
inTotalIncome = inTotalIncome.add(inValley.getDigital());
|
||||
inDeepValley.setTotal(inTotalIncome);
|
||||
list.add(inDeepValley);
|
||||
//收益-放-尖
|
||||
EarningsCalculate outSharp = new EarningsCalculate();
|
||||
BigDecimal reverseSharp = income.getBigDecimal("sum_e_reverse_sharp");
|
||||
outSharp.setElec(reverseSharp);
|
||||
outSharp.setType(1);
|
||||
outSharp.setRateType(CommonConstant.RateType.TIP);
|
||||
BigDecimal outSharpPrice = jsonPrice.get("out_sharp_price").getAsBigDecimal();
|
||||
outSharp.setPrice(outSharpPrice);
|
||||
outSharp.setDigital(reverseSharp.multiply(outSharpPrice));
|
||||
outTotalIncome = outTotalIncome.add(outSharp.getDigital());
|
||||
outSharp.setTotal(BigDecimal.ZERO);
|
||||
list.add(outSharp);
|
||||
//收益-放-峰
|
||||
EarningsCalculate outPeak = new EarningsCalculate();
|
||||
BigDecimal reversePeak = income.getBigDecimal("sum_e_reverse_peak");
|
||||
outPeak.setElec(reversePeak);
|
||||
outPeak.setType(1);
|
||||
outPeak.setRateType(CommonConstant.RateType.PEAK);
|
||||
BigDecimal outPeakPrice = jsonPrice.get("out_peak_price").getAsBigDecimal();
|
||||
outPeak.setPrice(outPeakPrice);
|
||||
outPeak.setDigital(reversePeak.multiply(outPeakPrice));
|
||||
outTotalIncome = outTotalIncome.add(outPeak.getDigital());
|
||||
outPeak.setTotal(BigDecimal.ZERO);
|
||||
list.add(outPeak);
|
||||
//收益-放-平
|
||||
EarningsCalculate outFlat = new EarningsCalculate();
|
||||
BigDecimal reverseFlat = income.getBigDecimal("sum_e_reverse_flat");
|
||||
outFlat.setElec(reverseFlat);
|
||||
outFlat.setType(1);
|
||||
outFlat.setRateType(CommonConstant.RateType.FLAT);
|
||||
BigDecimal outFlatPrice = jsonPrice.get("out_flat_price").getAsBigDecimal();
|
||||
outFlat.setPrice(outFlatPrice);
|
||||
outFlat.setDigital(reverseFlat.multiply(outFlatPrice));
|
||||
outTotalIncome = outTotalIncome.add(outFlat.getDigital());
|
||||
outFlat.setTotal(BigDecimal.ZERO);
|
||||
list.add(outFlat);
|
||||
//收益-放-谷
|
||||
EarningsCalculate outValley = new EarningsCalculate();
|
||||
BigDecimal reverseValley = income.getBigDecimal("sum_e_reverse_valley");
|
||||
outValley.setElec(reverseValley);
|
||||
outValley.setType(1);
|
||||
outValley.setRateType(CommonConstant.RateType.VALLEY);
|
||||
BigDecimal outValleyPrice = jsonPrice.get("out_valley_price").getAsBigDecimal();
|
||||
outValley.setPrice(outValleyPrice);
|
||||
outValley.setDigital(reverseValley.multiply(outValleyPrice));
|
||||
outTotalIncome = outTotalIncome.add(outValley.getDigital());
|
||||
outValley.setTotal(BigDecimal.ZERO);
|
||||
list.add(outValley);
|
||||
//收益-放-深谷
|
||||
EarningsCalculate outDeepValley = new EarningsCalculate();
|
||||
BigDecimal reverseDeepValley = income.getBigDecimal("sum_e_reverse_deep_valley");
|
||||
outDeepValley.setElec(reverseDeepValley);
|
||||
outDeepValley.setType(1);
|
||||
outDeepValley.setRateType(CommonConstant.RateType.DEEP_VALLEY);
|
||||
BigDecimal outDeepValleyPrice = jsonPrice.get("out_deep_valley_price").getAsBigDecimal();
|
||||
outDeepValley.setPrice(outDeepValleyPrice);
|
||||
outDeepValley.setDigital(reverseDeepValley.multiply(outDeepValleyPrice));
|
||||
outTotalIncome = outTotalIncome.add(outDeepValley.getDigital());
|
||||
outDeepValley.setTotal(outTotalIncome);
|
||||
list.add(outDeepValley);
|
||||
// 充电
|
||||
ElecMeterValue charge = new ElecMeterValue();
|
||||
BigDecimal sumEPositive = income.getBigDecimal("sum_e_positive");
|
||||
charge.setDigital(sumEPositive);
|
||||
charge.setType(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.CHARGE);
|
||||
charge.setStatus(CommonConstant.STATUS_FLAG);
|
||||
elecList.add(charge);
|
||||
// 放电
|
||||
ElecMeterValue disCharge = new ElecMeterValue();
|
||||
BigDecimal sumEReverse = income.getBigDecimal("sum_e_reverse");
|
||||
disCharge.setDigital(sumEReverse);
|
||||
disCharge.setType(DeviceTypeConstant.ELEC_METER_VALUE_TYPE.DISCHARGE);
|
||||
disCharge.setStatus(CommonConstant.STATUS_FLAG);
|
||||
elecList.add(disCharge);
|
||||
}
|
||||
if(elecList.size()>0){
|
||||
//删除
|
||||
elecMeterValueService.deleteByStationAndDay(stationId+10000,date,null);
|
||||
elecList.forEach(eleMeter -> {
|
||||
eleMeter.setGroupId(155);
|
||||
eleMeter.setStationId(stationId+10000);
|
||||
eleMeter.setCreateTime(new Date());
|
||||
eleMeter.setDay(date);
|
||||
//新增
|
||||
elecMeterValueService.insert(eleMeter);
|
||||
});
|
||||
}
|
||||
if(list.size()>0){
|
||||
//删除
|
||||
earningsCalculateMapper.deleteByStationAndDay(date,null,stationId+10000);
|
||||
list.forEach(a->{
|
||||
a.setGroupId(155);
|
||||
a.setStationId(stationId+10000);
|
||||
a.setCreateTime(new Date());
|
||||
a.setDay(date);
|
||||
a.setDiscount(BigDecimal.ONE);
|
||||
//新增
|
||||
earningsCalculateMapper.insertSelective(a);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ public interface StationService {
|
||||
|
||||
List<StationRespVO> selectByIds(List<Integer> ids);
|
||||
|
||||
List<Station> selectStationsByIds(List<Integer> ids);
|
||||
List<Station> selectStationsByIds(List<Integer> ids,String lang);
|
||||
|
||||
Station insertStation(StationReqVO vo);
|
||||
|
||||
|
||||
@ -1623,7 +1623,7 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
}
|
||||
}else if(CommonConstant.THREE.equals(vo.getType())){
|
||||
//导出电站数据
|
||||
List<Station> list = stationService.selectStationsByIds(vo.getStationIds());
|
||||
List<Station> list = stationService.selectStationsByIds(vo.getStationIds(),null);
|
||||
String fileName = "station";
|
||||
String sheetName = "data";
|
||||
try {
|
||||
|
||||
@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.excel.util.DateUtils;
|
||||
import com.alibaba.excel.util.StringUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ho.business.constant.DeviceTypeConstant;
|
||||
import com.ho.business.entity.*;
|
||||
import com.ho.business.feignclient.UserFeignClient;
|
||||
@ -24,6 +25,7 @@ import com.ho.business.vo.req.pcsStation.PcsStationReq;
|
||||
import com.ho.business.vo.req.report.ReportReqVO;
|
||||
import com.ho.business.vo.resp.CountEleData;
|
||||
import com.ho.business.vo.resp.DeviceRespVO;
|
||||
import com.ho.business.vo.resp.ShipStationRespVO;
|
||||
import com.ho.business.vo.resp.cabin.EarningsCalculateCountResp;
|
||||
import com.ho.business.vo.resp.cabin.EarningsCalculateResp;
|
||||
import com.ho.business.vo.resp.colCount.ColCountResp;
|
||||
@ -1403,6 +1405,16 @@ public class EarningsCalculateServiceImpl implements EarningsCalculateService {
|
||||
revenueOverview.setStationName(station.getName());
|
||||
revenueOverview.setCapacity(station.getCapacity());
|
||||
revenueOverview.setOperationDays((int) operationDays);
|
||||
if(station.getId()==11003 || station.getId()==10942 ||station.getId()==11006){
|
||||
// 寄点电站数据
|
||||
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + station.getId();
|
||||
String json = (String)redisService.get(mainKey);
|
||||
ShipStationRespVO respVO = JSON.parseObject(json,ShipStationRespVO.class);
|
||||
revenueOverview.setCharging(respVO.getPositivePowerSum()==null?BigDecimal.ZERO:BigDecimal.valueOf(respVO.getPositivePowerSum()));
|
||||
revenueOverview.setDischarging(respVO.getReversePowerSum()==null?BigDecimal.ZERO:BigDecimal.valueOf(respVO.getReversePowerSum()));
|
||||
revenueOverview.setTotalRevenue(respVO.getIncomeSum()==null?BigDecimal.ZERO:BigDecimal.valueOf(respVO.getIncomeSum()));
|
||||
return revenueOverview;
|
||||
}
|
||||
|
||||
List<RevenueOverviewData> list = getRevenueOverviewData(vo);
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package com.ho.business.service.impl;
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ho.business.constant.DeviceTypeConstant;
|
||||
import com.ho.business.entity.Device;
|
||||
import com.ho.business.entity.ElecMeterValue;
|
||||
@ -17,6 +18,7 @@ import com.ho.business.vo.req.colCount.ColCountReq;
|
||||
import com.ho.business.vo.resp.CountEleData;
|
||||
import com.ho.business.vo.resp.DeviceRespVO;
|
||||
import com.ho.business.vo.resp.ProvinceStation;
|
||||
import com.ho.business.vo.resp.ShipStationRespVO;
|
||||
import com.ho.business.vo.resp.colCount.ColCountResp;
|
||||
import com.ho.business.vo.resp.iargeScreen.*;
|
||||
import com.ho.business.vo.resp.profit.DayProfitType;
|
||||
@ -82,6 +84,7 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
private final static BigDecimal parameter = new BigDecimal("18.3");
|
||||
private final static BigDecimal four = new BigDecimal("0.4");
|
||||
private final static BigDecimal fours = new BigDecimal("40");
|
||||
private final static BigDecimal coalPrice = new BigDecimal("0.6");//煤炭价格
|
||||
private final static Integer maxSize = 30;
|
||||
private final static BigDecimal hundred = new BigDecimal(100);
|
||||
private final static int FENGStationId = 418;
|
||||
@ -281,6 +284,7 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
annualOverviewResp.setYestProfit(overviewProfit.getYestProfit()==null?null:overviewProfit.getYestProfit().multiply(new BigDecimal("10000")));
|
||||
annualOverviewResp.setYearProfit(overviewProfit.getYearProfit()==null?null:overviewProfit.getYearProfit().multiply(new BigDecimal("10000")));
|
||||
annualOverviewResp.setTotalProfit(overviewProfit.getTotalProfit()==null?null:overviewProfit.getTotalProfit().multiply(new BigDecimal("10000")));
|
||||
annualOverviewResp.setTodayProfit(overviewProfit.getTodayProfit()==null?null:overviewProfit.getTodayProfit().multiply(new BigDecimal("10000")));
|
||||
//时间当年
|
||||
DateTime begin = DateUtil.beginOfYear(new Date());
|
||||
String beginString = DateUtil.format(begin, CommonConstant.DATE_YMD);
|
||||
@ -292,6 +296,19 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
annualOverviewResp.setTotalCharge(incomeShow1.getYearCharge());
|
||||
annualOverviewResp.setTotalDischarge(incomeShow1.getYearDischarge());
|
||||
}
|
||||
// 寄点站点数据融合
|
||||
stations.forEach(s->{
|
||||
if(s.getId()==11003 || s.getId()==10942 || s.getId()==11006) {
|
||||
// 寄点电站数据
|
||||
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + s.getId();
|
||||
String json = (String) redisService.get(mainKey);
|
||||
ShipStationRespVO respVO = JSON.parseObject(json, ShipStationRespVO.class);
|
||||
// 日充
|
||||
annualOverviewResp.setDayCharge(annualOverviewResp.getDayCharge().add(respVO.getPositivePowerToday()==null?BigDecimal.ZERO:BigDecimal.valueOf(respVO.getPositivePowerToday())));
|
||||
// 日放
|
||||
annualOverviewResp.setDayDischarge(annualOverviewResp.getDayDischarge().add(respVO.getReversePowerToday()==null?BigDecimal.ZERO:BigDecimal.valueOf(respVO.getReversePowerToday())));
|
||||
}
|
||||
});
|
||||
return annualOverviewResp;
|
||||
}
|
||||
|
||||
@ -503,8 +520,8 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
//等效节约煤 等效节约煤=所有电站总充*节约标准煤转换系数(04)
|
||||
BigDecimal equivalentCoal = totalCharge.multiply(four);
|
||||
energySavingRespVo.setEquivalentCoal(equivalentCoal);
|
||||
//等效经济收入 等效经济收入=所有电站总充*对应谷时电价
|
||||
energySavingRespVo.setIncome(income);
|
||||
//等效经济收入 等效经济收入=等效节约煤*煤价 (600元/吨) 等效节约煤此处单位为kg,故而单价调整为0.6元/kg
|
||||
energySavingRespVo.setIncome(equivalentCoal.multiply(coalPrice));
|
||||
return energySavingRespVo;
|
||||
}
|
||||
|
||||
@ -1293,17 +1310,17 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
if (stationIds == null) {
|
||||
return new AnnualOverviewResp();
|
||||
}
|
||||
List<Station> list = stationService.selectStationsByIds(stationIds);
|
||||
List<Station> list = stationService.selectStationsByIds(stationIds,null);
|
||||
AnnualOverviewResp annualOverviewResp = getOverviewDatas(list);
|
||||
return annualOverviewResp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Subdata> getCommonRegionList(List<Integer> stationIds) {
|
||||
public List<Subdata> getCommonRegionList(List<Integer> stationIds,String lang) {
|
||||
if (stationIds == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<Station> list = getCountStations(stationIds);
|
||||
List<Station> list = getCountStations(stationIds,lang);
|
||||
List<Subdata> regionList = new ArrayList<>();
|
||||
Map<String, List<Station>> provinceMap = list.stream().filter(i -> i.getProvince() != null).collect(Collectors.groupingBy(Station::getProvince));
|
||||
if (provinceMap.size() > CommonConstant.ONE) {
|
||||
@ -1354,7 +1371,7 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
if (stationIds == null) {
|
||||
return new EnergySavingRespVo();
|
||||
}
|
||||
List<Station> list = getCountStations(stationIds);
|
||||
List<Station> list = getCountStations(stationIds,null);
|
||||
return getEnergySavingRespVo(list);
|
||||
}
|
||||
|
||||
@ -1363,7 +1380,7 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
if (stationIds == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<Station> list = getCountStations(stationIds);
|
||||
List<Station> list = getCountStations(stationIds,null);
|
||||
return getProfitCurve(vo, list);
|
||||
}
|
||||
|
||||
@ -1372,16 +1389,16 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
if (stationIds == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return getAnnualChartValues(getCountStations(stationIds));
|
||||
return getAnnualChartValues(getCountStations(stationIds,null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Subdata> getCommonProfit(String beginString, String endString, List<Integer> stationIds) {
|
||||
public List<Subdata> getCommonProfit(String beginString, String endString, List<Integer> stationIds,String lang) {
|
||||
List<Subdata> subdata = new ArrayList<>();
|
||||
if (stationIds == null) {
|
||||
return subdata;
|
||||
}
|
||||
List<Station> countStations = getCountStations(stationIds);
|
||||
List<Station> countStations = getCountStations(stationIds,lang);
|
||||
if (countStations != null && !countStations.isEmpty()) {
|
||||
if (countStations.size() >= CommonConstant.FIVE) {
|
||||
subdata = getSubdata(beginString, endString, countStations);
|
||||
@ -1399,12 +1416,12 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Subdata> getCommonEfficiencyDate(List<Integer> stationIds) {
|
||||
public List<Subdata> getCommonEfficiencyDate(List<Integer> stationIds,String lang) {
|
||||
List<Subdata> subdata = new ArrayList<>();
|
||||
if (stationIds == null) {
|
||||
return subdata;
|
||||
}
|
||||
List<Station> countStations = getCountStations(stationIds);
|
||||
List<Station> countStations = getCountStations(stationIds,lang);
|
||||
if (countStations != null && !countStations.isEmpty()) {
|
||||
subdata = getEfficiencyDate(countStations);
|
||||
// if (countStations.size() >= CommonConstant.FIVE) {
|
||||
@ -1531,7 +1548,7 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
if(beginDate == null){
|
||||
return annualOverviewResp;
|
||||
}
|
||||
Date date = DateUtil.yesterday();
|
||||
Date date = DateUtil.date();
|
||||
Date startDate = DateUtil.beginOfYear(beginDate);
|
||||
Date endDate = DateUtil.endOfDay(date);
|
||||
String begin = DateUtil.format(startDate, CommonConstant.DATE_YMD);
|
||||
@ -1545,6 +1562,7 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
profitList.add(dayProfitType);
|
||||
}
|
||||
}
|
||||
//计算总收益
|
||||
Map<String, List<DayProfitType>> dayMap = profitList.stream().collect(Collectors.groupingBy(DayProfitType::getDay));
|
||||
List<AnnualChartValue> yearProfitCurve = new ArrayList<>();
|
||||
getAnnualOverviewResp(yearProfitCurve, dateTimes, CommonConstant.DATE_Y, dayMap);
|
||||
@ -1553,6 +1571,7 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
yearProfit = yearProfit.add(chartValue.getProfit());
|
||||
}
|
||||
annualOverviewResp.setTotalProfit(yearProfit);
|
||||
//计算年收益
|
||||
startDate = DateUtil.beginOfYear(date);
|
||||
List<DateTime> nowDateTime = DateUtil.rangeToList(startDate, endDate, DateField.MONTH);
|
||||
List<AnnualChartValue> monthProfitCurve = new ArrayList<>();
|
||||
@ -1562,6 +1581,18 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
monthProfit = monthProfit.add(chartValue.getProfit());
|
||||
}
|
||||
annualOverviewResp.setYearProfit(monthProfit);
|
||||
// 计算今日收益
|
||||
List<DateTime> todayDateTime = DateUtil.rangeToList(endDate, endDate, DateField.DAY_OF_MONTH);
|
||||
List<AnnualChartValue> todayProfitCurve = new ArrayList<>();
|
||||
getAnnualOverviewResp(todayProfitCurve, todayDateTime, CommonConstant.DATE_YMD, dayMap);
|
||||
BigDecimal todayProfit = BigDecimal.ZERO;
|
||||
for (AnnualChartValue chartValue : todayProfitCurve) {
|
||||
todayProfit = todayProfit.add(chartValue.getProfit());
|
||||
}
|
||||
annualOverviewResp.setTodayProfit(todayProfit);
|
||||
// 计算昨日收益
|
||||
date = DateUtil.yesterday();
|
||||
endDate = DateUtil.endOfDay(date);
|
||||
List<DateTime> dayDateTime = DateUtil.rangeToList(endDate, endDate, DateField.DAY_OF_MONTH);
|
||||
List<AnnualChartValue> dayProfitCurve = new ArrayList<>();
|
||||
getAnnualOverviewResp(dayProfitCurve, dayDateTime, CommonConstant.DATE_YMD, dayMap);
|
||||
@ -1605,12 +1636,13 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
}
|
||||
}
|
||||
BigDecimal result = dischargeProfit.subtract(chargeProfit).divide(new BigDecimal("10000"));
|
||||
if (result.doubleValue() > 0.0) {
|
||||
annualChartValue.setProfit(result);
|
||||
} else {
|
||||
log.info("{},大屏计算收益,放电收益小于充电收益",day);
|
||||
annualChartValue.setProfit(BigDecimal.ZERO);
|
||||
}
|
||||
// if (result.doubleValue() > 0.0) {
|
||||
// annualChartValue.setProfit(result);
|
||||
// } else {
|
||||
// log.info("{},大屏计算收益,放电收益小于充电收益",day);
|
||||
// annualChartValue.setProfit(BigDecimal.ZERO);
|
||||
// }
|
||||
annualChartValue.setProfit(result);
|
||||
annualChartValue.setTime(day);
|
||||
curveResult.add(annualChartValue);
|
||||
}
|
||||
@ -1701,17 +1733,17 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Station> getCountStations(List<Integer> stationIds) {
|
||||
List<Station> list = stationService.selectStationsByIds(stationIds);
|
||||
public List<Station> getCountStations(List<Integer> stationIds,String lang) {
|
||||
List<Station> list = stationService.selectStationsByIds(stationIds,lang);
|
||||
List<Station> oneList = list.stream().filter(i -> CommonConstant.ONE.equals(i.getStatus())).collect(Collectors.toList());
|
||||
return oneList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Subdata> getCommonCapacity(List<Integer> stationIds) {
|
||||
public List<Subdata> getCommonCapacity(List<Integer> stationIds,String lang) {
|
||||
List<Subdata> subDataList = new ArrayList<>();
|
||||
if (stationIds != null) {
|
||||
List<Station> stations = getCountStations(stationIds);
|
||||
List<Station> stations = getCountStations(stationIds,lang);
|
||||
subDataList = getSubdataList(stations);
|
||||
}
|
||||
return subDataList;
|
||||
|
||||
@ -557,7 +557,7 @@ public class OpenStationServiceImpl implements OpenStationService {
|
||||
public void exportEleData(PcsStationReq req, HttpServletResponse response) {
|
||||
try {
|
||||
List<Integer> stationIds = req.getStationIds();
|
||||
List<Station> stations = stationService.selectStationsByIds(stationIds);
|
||||
List<Station> stations = stationService.selectStationsByIds(stationIds,null);
|
||||
Map<Integer, String> idNameMap = getStationMap(stations);
|
||||
List<Map<String, Object>> sheetsList = new ArrayList<>();
|
||||
//汇总
|
||||
@ -685,7 +685,7 @@ public class OpenStationServiceImpl implements OpenStationService {
|
||||
PageResult pageResult = new PageResult<>();
|
||||
try {
|
||||
List<Integer> stationIds = req.getStationIds();
|
||||
List<Station> stations = stationService.selectStationsByIds(stationIds);
|
||||
List<Station> stations = stationService.selectStationsByIds(stationIds,null);
|
||||
Map<Integer, String> idNameMap = stations.stream().collect(Collectors.toMap(Station::getId, Station::getName));
|
||||
List<PcsElecData> result = new ArrayList<>();
|
||||
String name = null;
|
||||
@ -720,7 +720,7 @@ public class OpenStationServiceImpl implements OpenStationService {
|
||||
Object obj = new Object();
|
||||
try {
|
||||
List<Integer> stationIds = req.getStationIds();
|
||||
List<Station> stations = stationService.selectStationsByIds(stationIds);
|
||||
List<Station> stations = stationService.selectStationsByIds(stationIds,null);
|
||||
Map<Integer, String> idNameMap = getStationMap(stations);
|
||||
//汇总
|
||||
BigDecimal charge = BigDecimal.ZERO;
|
||||
@ -857,7 +857,7 @@ public class OpenStationServiceImpl implements OpenStationService {
|
||||
Object obj = new Object();
|
||||
try {
|
||||
List<Integer> stationIds = req.getStationIds();
|
||||
List<Station> stations = stationService.selectStationsByIds(stationIds);
|
||||
List<Station> stations = stationService.selectStationsByIds(stationIds,null);
|
||||
Map<Integer, String> idNameMap = getStationMap(stations);
|
||||
//汇总
|
||||
String segmentType = req.getSegmentType();
|
||||
|
||||
@ -197,6 +197,7 @@ public class OutApiServiceImpl implements OutApiService {
|
||||
SysSubDictVO sysSubDictVO = new SysSubDictVO();
|
||||
sysSubDictVO.setType(CommonConstant.CF_FROZEN);
|
||||
Map<String, String> cfMap = userFeignClient.getSysSubDict(sysSubDictVO);
|
||||
stations = stations.stream().filter(i->i.getId()!=11003 && i.getId()!=10942 && i.getId()!=11006).collect(Collectors.toList());
|
||||
for (Station station : stations) {
|
||||
try {
|
||||
//先删除站的当日数据
|
||||
@ -464,7 +465,7 @@ public class OutApiServiceImpl implements OutApiService {
|
||||
ids.add(418);//新凤鸣电站
|
||||
ids.add(551);//江苏暨阳电力科技发展有限公司(1号柜)
|
||||
ids.add(564);//江苏暨阳电力科技发展有限公司(2号柜)
|
||||
List<Station> stations = stationService.selectStationsByIds(ids);
|
||||
List<Station> stations = stationService.selectStationsByIds(ids,null);
|
||||
String deviceType = DeviceTypeConstant.PCS;
|
||||
for (Station station : stations) {
|
||||
//先删除站的当日数据
|
||||
|
||||
@ -4,6 +4,7 @@ import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ho.business.constant.DeviceTypeConstant;
|
||||
import com.ho.business.entity.*;
|
||||
@ -1042,6 +1043,14 @@ public class StationHomeServiceImpl implements StationHomeService {
|
||||
dailyDischargeElec = new BigDecimal(dailyDischargeElecStr);
|
||||
pcsElecData.setChargeElec(dailyChargeElec);
|
||||
pcsElecData.setDischargeElec(dailyDischargeElec);
|
||||
if(req.getStationId()==11003 || req.getStationId()==10942 || req.getStationId()==11006){
|
||||
// 寄点电站数据
|
||||
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + req.getStationId();
|
||||
String json = (String)redisService.get(mainKey);
|
||||
ShipStationRespVO vo = JSON.parseObject(json,ShipStationRespVO.class);
|
||||
pcsElecData.setChargeElec(vo.getPositivePowerToday()==null?BigDecimal.ZERO:BigDecimal.valueOf(vo.getPositivePowerToday()));
|
||||
pcsElecData.setDischargeElec(vo.getReversePowerToday()==null?BigDecimal.ZERO:BigDecimal.valueOf(vo.getReversePowerToday()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ public class StationServiceImpl implements StationService {
|
||||
|
||||
@Override
|
||||
public List<StationRespVO> selectByIds(List<Integer> ids) {
|
||||
List<Station> stations = stationMapper.selectByIds(ids);
|
||||
List<Station> stations = stationMapper.selectByIds(ids,null);
|
||||
List<StationRespVO> stationRespVOS = getStationRespVOS(stations);
|
||||
if (stationRespVOS != null) {
|
||||
for (StationRespVO stationRespVO : stationRespVOS) {
|
||||
@ -235,8 +235,8 @@ public class StationServiceImpl implements StationService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Station> selectStationsByIds(List<Integer> ids) {
|
||||
List<Station> stations = stationMapper.selectByIds(ids);
|
||||
public List<Station> selectStationsByIds(List<Integer> ids,String lang) {
|
||||
List<Station> stations = stationMapper.selectByIds(ids,lang);
|
||||
return stations;
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,18 @@
|
||||
electricity_type,customer_type,voltage_level,batch_number,nation
|
||||
</sql>
|
||||
|
||||
<sql id="Base_Column_List1">
|
||||
id
|
||||
,pid,group_id,dept_id,
|
||||
name_en `name`,name_en,address,address_en,longitude,
|
||||
latitude,capacity,rate_power,
|
||||
status,type,create_time,
|
||||
contact,contact_details,grid_time,
|
||||
update_time,deleted,is_enable,cabin_num,district,ad_code,is_daily_count,
|
||||
topology_type,cupboard_type,plan_version,inverter_flag,icc_id,province_en province,city,
|
||||
electricity_type,customer_type,voltage_level,batch_number,nation
|
||||
</sql>
|
||||
|
||||
<select id="selectByName" resultType="com.ho.business.entity.Station">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
@ -50,7 +62,14 @@
|
||||
|
||||
<select id="selectByIds" resultType="com.ho.business.entity.Station">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
<choose>
|
||||
<when test="lang != null and lang=='en_US' ">
|
||||
<include refid="Base_Column_List1"></include>
|
||||
</when>
|
||||
<otherwise>
|
||||
<include refid="Base_Column_List"></include>
|
||||
</otherwise>
|
||||
</choose>
|
||||
from station
|
||||
<where>
|
||||
<if test="ids != null and ids.size() != 0">
|
||||
|
||||
@ -126,6 +126,9 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.2.12.RELEASE</version>
|
||||
<configuration>
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
package com.ho.business.controller;
|
||||
|
||||
import com.ho.business.service.BoulderEnergyService;
|
||||
import com.ho.common.tools.annotation.TokenIgnore;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RequestMapping(ContextConstant.BUSINESS + "boulderEnergyStation")
|
||||
@RestController
|
||||
@Api(tags = "业务模块-中车能源电站管理")
|
||||
@Slf4j
|
||||
public class BoulderEnergyController {
|
||||
|
||||
@Autowired
|
||||
BoulderEnergyService boulderEnergyService;
|
||||
|
||||
@PostMapping("getToken")
|
||||
@ApiOperation(value = "获取token")
|
||||
@TokenIgnore
|
||||
public DataResult<String> getToken() {
|
||||
return DataResult.success(boulderEnergyService.getToken());
|
||||
}
|
||||
|
||||
@PostMapping("getBoulderEleIncome")
|
||||
@ApiOperation(value = "中车-统计缓存充放电、及收益数据")
|
||||
@TokenIgnore
|
||||
public DataResult getBoulderEleIncome(@RequestBody(required = false) String beginTime) {
|
||||
log.info("参数: {} ", beginTime);
|
||||
// beginTime ==null 时统计昨日充放电、及收益数据
|
||||
// beginTime !=null 时统计beginTime充放电、及收益数据
|
||||
boulderEnergyService.getBoulderEleIncome(beginTime);
|
||||
if(beginTime!=null){
|
||||
//beginTime !=null 缓存中车电站累计数据
|
||||
boulderEnergyService.getCacheBoulderData();
|
||||
}
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@ -13,6 +13,7 @@ import com.ho.business.vo.resp.iargeScreen.EnergySavingRespVo;
|
||||
import com.ho.business.vo.resp.iargeScreen.Subdata;
|
||||
import com.ho.common.tools.annotation.CommonLargeScreenToken;
|
||||
import com.ho.common.tools.annotation.TokenIgnore;
|
||||
import com.ho.common.tools.constant.CommonConstant;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.constant.RedisKeyConstant;
|
||||
import com.ho.common.tools.entity.SimpleUser;
|
||||
@ -20,6 +21,7 @@ import com.ho.common.tools.entity.WeatherRespVo;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.BigDecimalUtil;
|
||||
import com.ho.common.tools.util.TranslateUtils;
|
||||
import com.ho.flow.vo.resp.event.EventDayNum;
|
||||
import com.ho.user.api.entity.SysDept;
|
||||
import com.ho.user.api.vo.req.QueryDeptReqVO;
|
||||
@ -33,6 +35,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@ -174,9 +177,17 @@ public class IargeScreenShowController {
|
||||
@PostMapping("/newWeather")
|
||||
@ApiOperation(value = "新大屏天气接口")
|
||||
@TokenIgnore
|
||||
public DataResult<WeatherRespVo> newWeather() {
|
||||
public DataResult<WeatherRespVo> newWeather(HttpServletRequest request) {
|
||||
String lang =request.getHeader(RedisKeyConstant.User.LANG);
|
||||
String key = RedisKeyConstant.WEATHER_PROVINCE_CITY + adCode;
|
||||
WeatherRespVo info = (WeatherRespVo) redisService.get(key);
|
||||
if(CommonConstant.EN_US.equals(lang)){
|
||||
try {
|
||||
info.setSkyCon(TranslateUtils.translate(info.getSkyCon()));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return DataResult.success(info);
|
||||
}
|
||||
|
||||
@ -199,7 +210,8 @@ public class IargeScreenShowController {
|
||||
@TokenIgnore
|
||||
@CommonLargeScreenToken
|
||||
public DataResult<List<Subdata>> getCommonRegionalDistribution(HttpServletRequest request) {
|
||||
List<Subdata> regionList = iargeScreenShowService.getCommonRegionList(getSimpleUser(request));
|
||||
String lang =request.getHeader(RedisKeyConstant.User.LANG);
|
||||
List<Subdata> regionList = iargeScreenShowService.getCommonRegionList(getSimpleUser(request),lang);
|
||||
regionList.sort(Comparator.comparing((Subdata::getRegionValue)).reversed());
|
||||
return DataResult.success(regionList);
|
||||
}
|
||||
@ -243,7 +255,8 @@ public class IargeScreenShowController {
|
||||
@TokenIgnore
|
||||
@CommonLargeScreenToken
|
||||
public DataResult<List<Subdata>> getCommonIncomeList(HttpServletRequest request) {
|
||||
List<Subdata> regionList = iargeScreenShowService.getCommonProfit(null, null, getSimpleUser(request));
|
||||
String lang =request.getHeader(RedisKeyConstant.User.LANG);
|
||||
List<Subdata> regionList = iargeScreenShowService.getCommonProfit(null, null, getSimpleUser(request),lang);
|
||||
if (regionList.size() > maxSize) {
|
||||
regionList = regionList.subList(0, maxSize);
|
||||
}
|
||||
@ -259,7 +272,8 @@ public class IargeScreenShowController {
|
||||
@TokenIgnore
|
||||
@CommonLargeScreenToken
|
||||
public DataResult<List<Subdata>> getCommonEfficiencyDate(HttpServletRequest request) {
|
||||
List<Subdata> efficiencyList = iargeScreenShowService.getCommonEfficiencyDate(getSimpleUser(request));
|
||||
String lang =request.getHeader(RedisKeyConstant.User.LANG);
|
||||
List<Subdata> efficiencyList = iargeScreenShowService.getCommonEfficiencyDate(getSimpleUser(request),lang);
|
||||
return DataResult.success(efficiencyList);
|
||||
}
|
||||
|
||||
@ -271,7 +285,7 @@ public class IargeScreenShowController {
|
||||
List<Integer> ids = getSimpleUser(request);
|
||||
List<Station> stations = new ArrayList<>();
|
||||
if (ids != null) {
|
||||
stations = iargeScreenShowService.getCountStations(ids);
|
||||
stations = iargeScreenShowService.getCountStations(ids,null);
|
||||
}
|
||||
return DataResult.success(stations);
|
||||
}
|
||||
@ -281,7 +295,8 @@ public class IargeScreenShowController {
|
||||
@TokenIgnore
|
||||
@CommonLargeScreenToken
|
||||
public DataResult<List<Subdata>> getCommonCapacity(HttpServletRequest request) {
|
||||
List<Subdata> regionList = iargeScreenShowService.getCommonCapacity(getSimpleUser(request));
|
||||
String lang =request.getHeader(RedisKeyConstant.User.LANG);
|
||||
List<Subdata> regionList = iargeScreenShowService.getCommonCapacity(getSimpleUser(request),lang);
|
||||
return DataResult.success(regionList);
|
||||
}
|
||||
|
||||
@ -339,8 +354,9 @@ public class IargeScreenShowController {
|
||||
@PostMapping("getZhongZiDistribution")
|
||||
@ApiOperation(value = "中自电站区域分布")
|
||||
@TokenIgnore
|
||||
public DataResult<List<Subdata>> getZhongZiDistribution(@RequestBody CockpitReqVO vo) {
|
||||
List<Subdata> regionList = iargeScreenShowService.getCommonRegionList((getByDeptId(vo.getDeptId())));
|
||||
public DataResult<List<Subdata>> getZhongZiDistribution(@RequestBody CockpitReqVO vo,HttpServletRequest request) {
|
||||
String lang =request.getHeader(RedisKeyConstant.User.LANG);
|
||||
List<Subdata> regionList = iargeScreenShowService.getCommonRegionList((getByDeptId(vo.getDeptId())),lang);
|
||||
regionList.sort(Comparator.comparing((Subdata::getRegionValue)).reversed());
|
||||
return DataResult.success(regionList);
|
||||
}
|
||||
@ -379,8 +395,9 @@ public class IargeScreenShowController {
|
||||
@PostMapping("getZhongZiIncomeList")
|
||||
@ApiOperation(value = "中自电站收益排名")
|
||||
@TokenIgnore
|
||||
public DataResult<List<Subdata>> getZhongZiIncomeList(@RequestBody CockpitReqVO vo) {
|
||||
List<Subdata> regionList = iargeScreenShowService.getCommonProfit(null, null, getByDeptId(vo.getDeptId()));
|
||||
public DataResult<List<Subdata>> getZhongZiIncomeList(@RequestBody CockpitReqVO vo,HttpServletRequest request) {
|
||||
String lang =request.getHeader(RedisKeyConstant.User.LANG);
|
||||
List<Subdata> regionList = iargeScreenShowService.getCommonProfit(null, null, getByDeptId(vo.getDeptId()),lang);
|
||||
if (regionList.size() > maxSize) {
|
||||
regionList = regionList.subList(0, maxSize);
|
||||
}
|
||||
@ -394,8 +411,9 @@ public class IargeScreenShowController {
|
||||
@PostMapping("getZhongZiEfficiencyDate")
|
||||
@ApiOperation(value = "中自系统转换率")
|
||||
@TokenIgnore
|
||||
public DataResult<List<Subdata>> getZhongZiEfficiencyDate(@RequestBody CockpitReqVO vo) {
|
||||
List<Subdata> efficiencyList = iargeScreenShowService.getCommonEfficiencyDate(getByDeptId(vo.getDeptId()));
|
||||
public DataResult<List<Subdata>> getZhongZiEfficiencyDate(@RequestBody CockpitReqVO vo,HttpServletRequest request) {
|
||||
String lang =request.getHeader(RedisKeyConstant.User.LANG);
|
||||
List<Subdata> efficiencyList = iargeScreenShowService.getCommonEfficiencyDate(getByDeptId(vo.getDeptId()),lang);
|
||||
return DataResult.success(efficiencyList);
|
||||
}
|
||||
|
||||
@ -406,7 +424,7 @@ public class IargeScreenShowController {
|
||||
List<Integer> ids = getByDeptId(vo.getDeptId());
|
||||
List<Station> stations = new ArrayList<>();
|
||||
if (ids != null) {
|
||||
stations = iargeScreenShowService.getCountStations(ids);
|
||||
stations = iargeScreenShowService.getCountStations(ids,null);
|
||||
}
|
||||
return DataResult.success(stations);
|
||||
}
|
||||
@ -414,8 +432,9 @@ public class IargeScreenShowController {
|
||||
@PostMapping("getZhongZiCapacity")
|
||||
@ApiOperation(value = "中自装机容量倒排")
|
||||
@TokenIgnore
|
||||
public DataResult<List<Subdata>> getZhongZiCapacity(@RequestBody CockpitReqVO vo) {
|
||||
List<Subdata> regionList = iargeScreenShowService.getCommonCapacity(getByDeptId(vo.getDeptId()));
|
||||
public DataResult<List<Subdata>> getZhongZiCapacity(@RequestBody CockpitReqVO vo,HttpServletRequest request) {
|
||||
String lang =request.getHeader(RedisKeyConstant.User.LANG);
|
||||
List<Subdata> regionList = iargeScreenShowService.getCommonCapacity(getByDeptId(vo.getDeptId()),lang);
|
||||
return DataResult.success(regionList);
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package com.ho.business.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ho.business.constant.DeviceTypeConstant;
|
||||
import com.ho.business.entity.Station;
|
||||
import com.ho.business.service.*;
|
||||
@ -10,6 +12,7 @@ import com.ho.business.vo.req.StationReq;
|
||||
import com.ho.business.vo.req.dynamicConfig.DynamicConfigQuery;
|
||||
import com.ho.business.vo.req.pcsStation.PcsStationReq;
|
||||
import com.ho.business.vo.resp.DeviceRespVO;
|
||||
import com.ho.business.vo.resp.ShipStationRespVO;
|
||||
import com.ho.business.vo.resp.cabin.CircleCtrlResp;
|
||||
import com.ho.business.vo.resp.cabin.EarningsCalculateCountResp;
|
||||
import com.ho.business.vo.resp.openStationHome.OpenStationMiddle;
|
||||
@ -44,6 +47,8 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -106,6 +111,38 @@ public class OpenStationController {
|
||||
public DataResult<List<NewRealTimeCurveVo>> realtimeCurve(@RequestBody StationReq stationReq) {
|
||||
log.info("realtimeCurve.stationRealtimeCurve:" + stationReq);
|
||||
List<NewRealTimeCurveVo> resList = stationHomeService.getRealtimeCurve(stationReq);
|
||||
// 寄点电站功率、soc曲线
|
||||
if(stationReq.getStationId()==11003 || stationReq.getStationId()==10942 || stationReq.getStationId()==11006){
|
||||
// 寄点电站数据
|
||||
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + stationReq.getStationId();
|
||||
String json = (String)redisService.get(mainKey);
|
||||
ShipStationRespVO vo = JSON.parseObject(json,ShipStationRespVO.class);
|
||||
JSONArray historyDataList = vo.getHistoryDataList();
|
||||
if(historyDataList!=null){
|
||||
NewRealTimeCurveVo soc = new NewRealTimeCurveVo();
|
||||
soc.setName("SOC");
|
||||
List<StationHomeRespVo> soclist =new ArrayList<>();
|
||||
NewRealTimeCurveVo p = new NewRealTimeCurveVo();
|
||||
p.setName("实时功率");
|
||||
List<StationHomeRespVo> plist =new ArrayList<>();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(CommonConstant.DATE);
|
||||
historyDataList.forEach(i->{
|
||||
JSONObject obj = (JSONObject) i;
|
||||
StationHomeRespVo socCurve = new StationHomeRespVo();
|
||||
socCurve.setDate(ZonedDateTime.parse(obj.getString("record_time")).format(formatter));
|
||||
socCurve.setDigital(obj.getBigDecimal("soc"));
|
||||
soclist.add(socCurve);
|
||||
StationHomeRespVo pCurve = new StationHomeRespVo();
|
||||
pCurve.setDate(ZonedDateTime.parse(obj.getString("record_time")).format(formatter));
|
||||
pCurve.setDigital(obj.getBigDecimal("p_total"));
|
||||
plist.add(pCurve);
|
||||
});
|
||||
soc.setList(soclist);
|
||||
p.setList(plist);
|
||||
resList.add(soc);
|
||||
resList.add(p);
|
||||
}
|
||||
}
|
||||
//返回值的BigDecimal类型保留两位小数
|
||||
for (NewRealTimeCurveVo newRealTimeCurveVo : resList) {
|
||||
List<StationHomeRespVo> list = newRealTimeCurveVo.getList();
|
||||
@ -221,6 +258,21 @@ public class OpenStationController {
|
||||
req.setDeviceType(deviceType);
|
||||
}
|
||||
PcsTotalData data = stationHomeService.getPcsTotalData(req);
|
||||
if(req.getStationId()==11003 || req.getStationId()==10942 || req.getStationId()==11006){
|
||||
// 寄点电站数据
|
||||
String mainKey = CommonConstant.SHIP_ENERGY_MAIN + req.getStationId();
|
||||
String json = (String)redisService.get(mainKey);
|
||||
ShipStationRespVO vo = JSON.parseObject(json,ShipStationRespVO.class);
|
||||
// 数据转换
|
||||
data.setTotalChargeElec(vo.getPositivePowerSum()==null?BigDecimal.ZERO:BigDecimal.valueOf(vo.getPositivePowerSum()));
|
||||
data.setTotalDischargeElec(vo.getReversePowerSum()==null?BigDecimal.ZERO:BigDecimal.valueOf(vo.getReversePowerSum()));
|
||||
data.setDailyChargeElec(vo.getPositivePowerToday()==null?BigDecimal.ZERO:BigDecimal.valueOf(vo.getPositivePowerToday()));
|
||||
data.setDailyDischargeElec(vo.getReversePowerToday()==null?BigDecimal.ZERO:BigDecimal.valueOf(vo.getReversePowerToday()));
|
||||
data.setCurrentPower(vo.getRealTimePower()==null?BigDecimal.ZERO:BigDecimal.valueOf(vo.getRealTimePower()));
|
||||
if(data.getTotalChargeElec().compareTo(BigDecimal.ZERO)>0){
|
||||
data.setSystemEfficiency(data.getTotalDischargeElec().divide(data.getTotalChargeElec(), 4, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
}
|
||||
BigDecimal systemEfficiency = data.getSystemEfficiency();
|
||||
bigDecimalUtil.keepTwoDecimalPlaces(data);
|
||||
bigDecimalUtil.ifIsNUll(data);
|
||||
|
||||
@ -219,7 +219,7 @@ public class OuterApiController {
|
||||
@PostMapping("selectByStationIds")
|
||||
@TokenIgnore
|
||||
public DataResult<List<Station>> selectByStationIds(@RequestBody List<Integer> ids) {
|
||||
List<Station> stations = stationService.selectStationsByIds(ids);
|
||||
List<Station> stations = stationService.selectStationsByIds(ids,null);
|
||||
return DataResult.success(stations);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
package com.ho.business.controller;
|
||||
|
||||
import com.ho.business.service.ShipEnergyService;
|
||||
import com.ho.common.tools.annotation.TokenIgnore;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RequestMapping(ContextConstant.BUSINESS + "shipEnergyStation")
|
||||
@RestController
|
||||
@Api(tags = "业务模块-寄点能源电站管理")
|
||||
public class ShipEnergyController {
|
||||
|
||||
|
||||
@Autowired
|
||||
ShipEnergyService shipEnergyService;
|
||||
|
||||
|
||||
@PostMapping("add")
|
||||
@ApiOperation(value = "新增电站接口")
|
||||
@TokenIgnore
|
||||
public DataResult add() {
|
||||
shipEnergyService.addShipEnergyStation();
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("getMainTotal")
|
||||
@ApiOperation(value = "获取主监控汇总信息")
|
||||
@TokenIgnore
|
||||
public DataResult getMainTotal() {
|
||||
shipEnergyService.getShipEnergyTotal();
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("getStationIncomeHis")
|
||||
@ApiOperation(value = "获取寄点电站历史收益")
|
||||
@TokenIgnore
|
||||
public DataResult getStationIncomeHis(@RequestBody(required = false) String beginTime) {
|
||||
shipEnergyService.getStationIncomeHis(beginTime);
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@ -20,9 +20,9 @@ spring:
|
||||
server-addr: 127.0.0.1:8848
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.100.244:3306/business_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: root
|
||||
password: 123456
|
||||
url: jdbc:mysql://1.95.170.86:3306/business_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: business_db
|
||||
password: zzkj@688737
|
||||
druid:
|
||||
initialSize: 5
|
||||
minIdle: 5
|
||||
@ -33,40 +33,25 @@ spring:
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 50000ms #连接超时
|
||||
host: 192.168.100.242 #单机
|
||||
host: 1.95.170.86 #单机
|
||||
password: 123456
|
||||
database: 0
|
||||
|
||||
#port: 6379 #端口
|
||||
#timeout: 5000ms #连接超时
|
||||
#host: 127.0.0.1 #单机
|
||||
#password:
|
||||
#database: 0
|
||||
#集群 真实环境开启
|
||||
# record:
|
||||
# nodes:
|
||||
# - 127.0.0.1:6379
|
||||
# - 127.0.0.1:6380
|
||||
# - 127.0.0.1:6381
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #连接池最大连接 默认8
|
||||
max-idle: 8 #连接池中最大空闲连接 默认8
|
||||
min-idle: 1 #连接池中最小空闲连接 默认0
|
||||
max-wait: 2000ms #连接池最大阻塞等待时间 使用负值表示没有限制
|
||||
|
||||
|
||||
|
||||
boot:
|
||||
admin:
|
||||
client:
|
||||
url: http://localhost:8019/boot
|
||||
|
||||
minio:
|
||||
accessKey: admin
|
||||
secretKey: zzkj@688737
|
||||
endpoint: http://192.168.0.236:9000
|
||||
prefixUrl: http://192.168.0.236:9000
|
||||
accessKey: minioadmin
|
||||
secretKey: minioadmin
|
||||
endpoint: http://1.95.170.86:9000
|
||||
prefixUrl: http://1.95.170.86:9000
|
||||
|
||||
formula:
|
||||
fieldmap:
|
||||
|
||||
58
business-service/src/main/resources/application-prod.yml
Normal file
58
business-service/src/main/resources/application-prod.yml
Normal file
@ -0,0 +1,58 @@
|
||||
server:
|
||||
port: 8011
|
||||
servlet:
|
||||
context-path: /api
|
||||
|
||||
#swagger2配置
|
||||
swagger2:
|
||||
enable: true #开启swagger
|
||||
projectName: 云平台--business-前端接口
|
||||
controllerPath: com.ho.business.controller
|
||||
|
||||
spring:
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
name: business-service
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.0.142:8848
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.0.236:3306/business_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: zzkj
|
||||
password: zzkj@688737
|
||||
druid:
|
||||
initialSize: 5
|
||||
minIdle: 5
|
||||
maxActive: 5
|
||||
keepAlive: true #保持长连接
|
||||
connection-error-retry-attempts: 3
|
||||
#Redis
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 50000ms #连接超时
|
||||
host: 192.168.0.236 #单机
|
||||
password: zzkj@688737
|
||||
database: 0
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #连接池最大连接 默认8
|
||||
max-idle: 8 #连接池中最大空闲连接 默认8
|
||||
min-idle: 1 #连接池中最小空闲连接 默认0
|
||||
max-wait: 2000ms #连接池最大阻塞等待时间 使用负值表示没有限制
|
||||
boot:
|
||||
admin:
|
||||
client:
|
||||
url: http://localhost:8019/boot
|
||||
|
||||
minio:
|
||||
accessKey: admin
|
||||
secretKey: zzkj@688737
|
||||
endpoint: http://192.168.0.236:9000
|
||||
prefixUrl: http://192.168.0.236:9000
|
||||
|
||||
formula:
|
||||
fieldmap:
|
||||
RT_FIELD_BEAN: RT_FIELD_BEAN
|
||||
@ -79,7 +79,7 @@ inverter:
|
||||
largeScreen:
|
||||
#收益系数
|
||||
income: 0.6
|
||||
weatherCode: 510105
|
||||
weatherCode: 510117
|
||||
|
||||
#线上环境redis密码
|
||||
openRedis:
|
||||
|
||||
@ -9,9 +9,9 @@
|
||||
</appender>
|
||||
|
||||
<appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/business-service/business-service.log</file>
|
||||
<file>/www/zzkjcloud/logs/business-service/business-service.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/business-service/business-service.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>/www/zzkjcloud/logs/business-service/business-service.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<!--180天-->
|
||||
<maxHistory>10</maxHistory>
|
||||
@ -29,9 +29,9 @@
|
||||
|
||||
<!--Error级别-->
|
||||
<appender name="errorFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/business-service/business-service-error.log</file>
|
||||
<file>/www/zzkjcloud/logs/business-service/business-service-error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/business-service/business-service-error.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>/www/zzkjcloud/logs/business-service/business-service-error.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<!--180天-->
|
||||
<maxHistory>10</maxHistory>
|
||||
|
||||
@ -146,6 +146,16 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20231013</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@ -994,4 +994,24 @@ public interface CommonConstant {
|
||||
String CF_FROZEN = "cfFrozen";
|
||||
//将数据库统配符合“_”变成普通字符
|
||||
String JOIN_STATION_ID = "\\_";
|
||||
|
||||
String EN_US="en_US";
|
||||
|
||||
interface HttpCode {
|
||||
// 调用成功code
|
||||
Integer SUCCESS_CODE = 200;
|
||||
}
|
||||
|
||||
/**
|
||||
* 寄点 token 缓存 key
|
||||
*/
|
||||
String SHIP_ENERGY_TOKEN_KEY = "ShipEnergyToken";
|
||||
/**
|
||||
* 中车 token 缓存 key
|
||||
*/
|
||||
String BOULDER_ENERGY_TOKEN_KEY = "BoulderEnergyToken";
|
||||
/**
|
||||
* 监控数据
|
||||
*/
|
||||
String SHIP_ENERGY_MAIN = "ShipEnergyMain:";
|
||||
}
|
||||
|
||||
@ -221,6 +221,8 @@ public interface RedisKeyConstant {
|
||||
String LOGIN_TYPE_ACCOUNT = "account";
|
||||
//登陆方式 phone 手机号
|
||||
String LOGIN_TYPE_PHONE = "phone";
|
||||
// 语言切换
|
||||
String LANG="lang";
|
||||
}
|
||||
|
||||
//设备相关
|
||||
|
||||
@ -0,0 +1,342 @@
|
||||
package com.ho.common.tools.util;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* HTTP工具类 - 支持GET/POST请求,支持表单和JSON传参
|
||||
*/
|
||||
public class HttpUtils {
|
||||
/**
|
||||
* 连接超时时间(毫秒)
|
||||
*/
|
||||
private static final int CONNECT_TIMEOUT = 10000;
|
||||
|
||||
/**
|
||||
* 读取超时时间(毫秒)
|
||||
*/
|
||||
private static final int READ_TIMEOUT = 30000;
|
||||
|
||||
/**
|
||||
* 发送GET请求(表单参数模式)
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param params 表单参数
|
||||
* @return 响应字符串
|
||||
* @throws IOException 网络异常
|
||||
*/
|
||||
public static String getWithForm(String url, Map<String, String> params) throws IOException {
|
||||
return get(url, buildFormParams(params), "application/x-www-form-urlencoded");
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送GET请求(JSON参数模式)
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param jsonParams JSON参数字符串
|
||||
* @return 响应字符串
|
||||
* @throws IOException 网络异常
|
||||
*/
|
||||
public static String getWithJson(String url, String jsonParams) throws IOException {
|
||||
// 注意:GET请求通常不支持请求体中的JSON参数
|
||||
// 但某些API可能支持,这里将其作为查询参数传递
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("json", jsonParams);
|
||||
return get(url, buildFormParams(params), "application/x-www-form-urlencoded");
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送POST请求(表单参数模式)
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param params 表单参数
|
||||
* @return 响应字符串
|
||||
* @throws IOException 网络异常
|
||||
*/
|
||||
public static String postWithForm(String url, Map<String, String> params) throws IOException {
|
||||
return post(url, buildFormParams(params), "application/x-www-form-urlencoded");
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送POST请求(JSON参数模式)
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param jsonParams JSON参数字符串
|
||||
* @return 响应字符串
|
||||
* @throws IOException 网络异常
|
||||
*/
|
||||
public static String postWithJson(String url, String jsonParams) throws IOException {
|
||||
return post(url, jsonParams, "application/json; charset=utf-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送POST请求(JSON参数模式,使用Map自动转换为JSON)
|
||||
*
|
||||
* @param url 请求URL
|
||||
* @param params 参数Map
|
||||
* @return 响应字符串
|
||||
* @throws IOException 网络异常
|
||||
*/
|
||||
public static String postWithJson(String url, Map<String, Object> params) throws IOException {
|
||||
String jsonParams = mapToJson(params);
|
||||
return postWithJson(url, jsonParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送GET请求(基础方法)
|
||||
*/
|
||||
private static String get(String url, String queryParams, String contentType) throws IOException {
|
||||
String fullUrl = url;
|
||||
if (queryParams != null && !queryParams.isEmpty()) {
|
||||
fullUrl = url + "?" + queryParams;
|
||||
}
|
||||
|
||||
HttpURLConnection connection = null;
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
URL requestUrl = new URL(fullUrl);
|
||||
connection = (HttpURLConnection) requestUrl.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setConnectTimeout(CONNECT_TIMEOUT);
|
||||
connection.setReadTimeout(READ_TIMEOUT);
|
||||
connection.setRequestProperty("Content-Type", contentType);
|
||||
connection.setRequestProperty("User-Agent", "HttpUtils/1.0");
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
|
||||
return readResponse(reader);
|
||||
} else {
|
||||
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8));
|
||||
String errorResponse = readResponse(reader);
|
||||
throw new IOException("HTTP GET Request Failed with Error Code: " + responseCode + ", Response: " + errorResponse);
|
||||
}
|
||||
} finally {
|
||||
reader.close();
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送POST请求(基础方法)
|
||||
*/
|
||||
private static String post(String url, String requestBody, String contentType) throws IOException {
|
||||
HttpURLConnection connection = null;
|
||||
OutputStream outputStream = null;
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
URL requestUrl = new URL(url);
|
||||
connection = (HttpURLConnection) requestUrl.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setConnectTimeout(CONNECT_TIMEOUT);
|
||||
connection.setReadTimeout(READ_TIMEOUT);
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestProperty("Content-Type", contentType);
|
||||
connection.setRequestProperty("User-Agent", "HttpUtils/1.0");
|
||||
connection.setRequestProperty("Accept", "application/json, text/plain, */*");
|
||||
|
||||
// 写入请求体
|
||||
if (requestBody != null && !requestBody.isEmpty()) {
|
||||
outputStream = connection.getOutputStream();
|
||||
outputStream.write(requestBody.getBytes(StandardCharsets.UTF_8));
|
||||
outputStream.flush();
|
||||
}
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK ||
|
||||
responseCode == HttpURLConnection.HTTP_CREATED ||
|
||||
responseCode == HttpURLConnection.HTTP_ACCEPTED) {
|
||||
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
|
||||
return readResponse(reader);
|
||||
} else {
|
||||
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8));
|
||||
String errorResponse = readResponse(reader);
|
||||
throw new IOException("HTTP POST Request Failed with Error Code: " + responseCode + ", Response: " + errorResponse);
|
||||
}
|
||||
} finally {
|
||||
outputStream.close();
|
||||
reader.close();
|
||||
connection.connect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建表单参数字符串
|
||||
*/
|
||||
private static String buildFormParams(Map<String, String> params) throws UnsupportedEncodingException {
|
||||
if (params == null || params.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringJoiner joiner = new StringJoiner("&");
|
||||
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||
String encodedKey = URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8.toString());
|
||||
String encodedValue = URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.toString());
|
||||
joiner.add(encodedKey + "=" + encodedValue);
|
||||
}
|
||||
return joiner.toString();
|
||||
}
|
||||
/**
|
||||
* 将Map转换为JSON字符串(简单实现,实际项目中建议使用Jackson/Gson等库)
|
||||
*/
|
||||
public static String mapToJson(Map<String, Object> params) {
|
||||
if (params == null || params.isEmpty()) {
|
||||
return "{}";
|
||||
}
|
||||
|
||||
StringBuilder jsonBuilder = new StringBuilder("{");
|
||||
boolean first = true;
|
||||
|
||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||
if (!first) {
|
||||
jsonBuilder.append(",");
|
||||
}
|
||||
first = false;
|
||||
|
||||
jsonBuilder.append("\"").append(escapeJson(entry.getKey())).append("\":");
|
||||
|
||||
Object value = entry.getValue();
|
||||
if (value == null) {
|
||||
jsonBuilder.append("null");
|
||||
} else if (value instanceof String) {
|
||||
jsonBuilder.append("\"").append(escapeJson((String) value)).append("\"");
|
||||
} else if (value instanceof Number || value instanceof Boolean) {
|
||||
jsonBuilder.append(value);
|
||||
} else {
|
||||
// 复杂对象需要序列化,这里简单处理
|
||||
jsonBuilder.append("\"").append(escapeJson(value.toString())).append("\"");
|
||||
}
|
||||
}
|
||||
|
||||
jsonBuilder.append("}");
|
||||
return jsonBuilder.toString();
|
||||
}
|
||||
/**
|
||||
* 转义JSON特殊字符
|
||||
*/
|
||||
private static String escapeJson(String input) {
|
||||
if (input == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return input.replace("\\", "\\\\")
|
||||
.replace("\"", "\\\"")
|
||||
.replace("\b", "\\b")
|
||||
.replace("\f", "\\f")
|
||||
.replace("\n", "\\n")
|
||||
.replace("\r", "\\r")
|
||||
.replace("\t", "\\t");
|
||||
}
|
||||
/**
|
||||
* 读取响应内容
|
||||
*/
|
||||
private static String readResponse(BufferedReader reader) throws IOException {
|
||||
StringBuilder response = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
response.append(line);
|
||||
}
|
||||
return response.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送带请求头的GET请求(扩展方法)
|
||||
*/
|
||||
public static String getWithHeaders(String url, Map<String, String> params, Map<String, String> headers) throws IOException {
|
||||
String fullUrl = url;
|
||||
if (params != null && !params.isEmpty()) {
|
||||
fullUrl = url + "?" + buildFormParams(params);
|
||||
}
|
||||
|
||||
HttpURLConnection connection = null;
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
URL requestUrl = new URL(fullUrl);
|
||||
connection = (HttpURLConnection) requestUrl.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setConnectTimeout(CONNECT_TIMEOUT);
|
||||
connection.setReadTimeout(READ_TIMEOUT);
|
||||
connection.setRequestProperty("User-Agent", "HttpUtils/1.0");
|
||||
|
||||
// 添加自定义请求头
|
||||
if (headers != null) {
|
||||
for (Map.Entry<String, String> header : headers.entrySet()) {
|
||||
connection.setRequestProperty(header.getKey(), header.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
|
||||
return readResponse(reader);
|
||||
} else {
|
||||
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8));
|
||||
String errorResponse = readResponse(reader);
|
||||
throw new IOException("HTTP GET Request Failed with Error Code: " + responseCode + ", Response: " + errorResponse);
|
||||
}
|
||||
} finally {
|
||||
reader.close();
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送带请求头的POST请求(扩展方法)
|
||||
*/
|
||||
public static String postWithHeaders(String url, String requestBody, String contentType, Map<String, String> headers) throws IOException {
|
||||
HttpURLConnection connection = null;
|
||||
OutputStream outputStream = null;
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
URL requestUrl = new URL(url);
|
||||
connection = (HttpURLConnection) requestUrl.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setConnectTimeout(CONNECT_TIMEOUT);
|
||||
connection.setReadTimeout(READ_TIMEOUT);
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestProperty("Content-Type", contentType);
|
||||
connection.setRequestProperty("User-Agent", "HttpUtils/1.0");
|
||||
|
||||
// 添加自定义请求头
|
||||
if (headers != null) {
|
||||
for (Map.Entry<String, String> header : headers.entrySet()) {
|
||||
connection.setRequestProperty(header.getKey(), header.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// 写入请求体
|
||||
if (requestBody != null && !requestBody.isEmpty()) {
|
||||
outputStream = connection.getOutputStream();
|
||||
outputStream.write(requestBody.getBytes(StandardCharsets.UTF_8));
|
||||
outputStream.flush();
|
||||
}
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK ||
|
||||
responseCode == HttpURLConnection.HTTP_CREATED ||
|
||||
responseCode == HttpURLConnection.HTTP_ACCEPTED) {
|
||||
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
|
||||
return readResponse(reader);
|
||||
} else {
|
||||
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8));
|
||||
String errorResponse = readResponse(reader);
|
||||
throw new IOException("HTTP POST Request Failed with Error Code: " + responseCode + ", Response: " + errorResponse);
|
||||
}
|
||||
} finally {
|
||||
outputStream.close();
|
||||
reader.close();
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package com.ho.common.tools.util;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* @author kerwin
|
||||
*/
|
||||
@Slf4j
|
||||
public class TranslateUtils {
|
||||
|
||||
public static final String API_KEY = "hNDgbvTzhQymYvVvcAhCWEkh";
|
||||
public static final String SECRET_KEY = "tkgqkVDEJi8xBSrToNPdJdV2CYFNZM31";
|
||||
|
||||
public static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().readTimeout(300, TimeUnit.SECONDS).build();
|
||||
|
||||
|
||||
// 静态翻译方法:输入待翻译文本,返回目标语言文本
|
||||
public static String translate(String text) throws IOException {
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
// 动态构建请求体(支持任意文本)
|
||||
String jsonBody = String.format("{\"from\":\"zh\",\"to\":\"en\",\"q\":\"%s\"}", text);
|
||||
RequestBody body = RequestBody.create(mediaType, jsonBody);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url("https://aip.baidubce.com/rpc/2.0/mt/texttrans/v1?access_token=" + getAccessToken())
|
||||
.post(body)
|
||||
.addHeader("Content-Type", "application/json")
|
||||
.addHeader("Accept", "application/json")
|
||||
.build();
|
||||
|
||||
try (Response response = HTTP_CLIENT.newCall(request).execute()) {
|
||||
String responseBody = response.body().string();
|
||||
// 解析JSON获取dst值
|
||||
return parseDstFromResponse(responseBody);
|
||||
}
|
||||
}
|
||||
|
||||
// 解析JSON响应并提取dst
|
||||
private static String parseDstFromResponse(String jsonResponse) {
|
||||
JSONObject root = new JSONObject(jsonResponse);
|
||||
JSONObject result = root.getJSONObject("result");
|
||||
JSONArray transResult = result.getJSONArray("trans_result");
|
||||
// 获取第一条翻译结果的dst字段
|
||||
return transResult.getJSONObject(0).getString("dst");
|
||||
}
|
||||
|
||||
// 示例调用
|
||||
public static void main(String[] args) throws IOException {
|
||||
String translated = translate("PCS环境过温降额[恢复]");
|
||||
System.out.println("翻译结果: " + translated); // 输出: active power
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从用户的AK,SK生成鉴权签名(Access Token)
|
||||
*
|
||||
* @return 鉴权签名(Access Token)
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
static String getAccessToken() throws IOException {
|
||||
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
||||
RequestBody body = RequestBody.create(mediaType, "grant_type=client_credentials&client_id=" + API_KEY
|
||||
+ "&client_secret=" + SECRET_KEY);
|
||||
Request request = new Request.Builder()
|
||||
.url("https://aip.baidubce.com/oauth/2.0/token")
|
||||
.method("POST", body)
|
||||
.addHeader("Content-Type", "application/x-www-form-urlencoded")
|
||||
.build();
|
||||
Response response = HTTP_CLIENT.newCall(request).execute();
|
||||
return new JSONObject(response.body().string()).getString("access_token");
|
||||
}
|
||||
|
||||
}
|
||||
@ -140,6 +140,9 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.2.12.RELEASE</version>
|
||||
<configuration>
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -151,5 +154,4 @@
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -5,6 +5,7 @@ public class AnotherMqttConfigUtil {
|
||||
public static String[] commonTopic = new String[]{
|
||||
"+/device/27d83a2844ff5866",
|
||||
"+/device/77ba753718908d1a",
|
||||
"+/device/93372fa4f4c4ebcf",
|
||||
"1/device/+"
|
||||
};
|
||||
|
||||
|
||||
@ -114,7 +114,24 @@ public class MqttConfigUtil {
|
||||
"+/device/5d4297256f02ebc2",
|
||||
"+/device/67aa37e699e1e08f",
|
||||
"+/device/ea0ebfbfa1487bd2",
|
||||
"+/device/aa8a43d326dddb3f"
|
||||
"+/device/aa8a43d326dddb3f",
|
||||
"+/device/82d40d7dbcfc884e",
|
||||
"+/device/34ee15e05a3133bc",
|
||||
"+/device/ee2508ba91664376",
|
||||
"+/device/48c18f2a756dcc28",
|
||||
"+/device/056d38ac91f61ffd",
|
||||
"+/device/60f2bbbc054bfa03",
|
||||
"+/device/50fdebcf6eb85a49",
|
||||
"+/device/227a752b9bfb6b02",
|
||||
"+/device/d60a05bcd086f160",
|
||||
"+/device/f3c813d5e3d7fd99",
|
||||
"+/device/cd6cb4a64b42bda5",
|
||||
"+/device/436de647bbf01b22",
|
||||
"+/device/e9eee97d793756fa",
|
||||
"+/device/8c062827b5c1548b",
|
||||
"+/device/d143856d757625e1",
|
||||
"+/device/3522ab4e7faf28b8",
|
||||
"1/device/+"
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -11,9 +11,9 @@ swagger2:
|
||||
|
||||
#mqtt
|
||||
mqtt:
|
||||
url: tcp://123.60.190.77:1883 # 线上环境MQTT
|
||||
url: tcp://1.95.170.86:1883
|
||||
userName: admin
|
||||
passWord: public
|
||||
passWord: zzkj688737
|
||||
timeout: 5000
|
||||
keepAlive: 60
|
||||
|
||||
@ -37,8 +37,6 @@ topic:
|
||||
cloudControlRequest: +/cloud/+/control/request
|
||||
edgeControlResponse: +/device/+/control/response
|
||||
|
||||
|
||||
|
||||
spring:
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
@ -50,12 +48,9 @@ spring:
|
||||
server-addr: 127.0.0.1:8848
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
#url: jdbc:mysql://1.95.153.121:3306/business_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://192.168.100.244:3306/business_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||
#username: zzkj
|
||||
username: root
|
||||
#password: zzkj@688737
|
||||
password: 123456
|
||||
url: jdbc:mysql://1.95.170.86:3306/business_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||
username: business_db
|
||||
password: zzkj@688737
|
||||
druid:
|
||||
initialSize: 5
|
||||
minIdle: 5
|
||||
@ -66,23 +61,9 @@ spring:
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 3000ms #连接超时
|
||||
#host: 1.95.153.121 #单机
|
||||
host: 192.168.100.242 #单机
|
||||
#password: zzkj@688737
|
||||
host: 1.95.170.86 #单机
|
||||
password: 123456
|
||||
database: 0
|
||||
|
||||
#port: 6379 #端口
|
||||
#timeout: 5000ms #连接超时
|
||||
#host: 127.0.0.1 #单机
|
||||
#password:
|
||||
#database: 0
|
||||
#集群 真实环境开启
|
||||
# cluster:
|
||||
# nodes:
|
||||
# - 127.0.0.1:6379
|
||||
# - 127.0.0.1:6380
|
||||
# - 127.0.0.1:6381
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #连接池最大连接 默认8
|
||||
@ -91,10 +72,10 @@ spring:
|
||||
max-wait: 2000ms #连接池最大阻塞等待时间 使用负值表示没有限制
|
||||
|
||||
minio:
|
||||
accessKey: admin
|
||||
secretKey: zzkj@688737
|
||||
endpoint: http://192.168.0.236:9000
|
||||
prefixUrl: http://192.168.0.236:9000
|
||||
accessKey: minioadmin
|
||||
secretKey: minioadmin
|
||||
endpoint: http://1.95.170.86:9000
|
||||
prefixUrl: http://1.95.170.86:9000
|
||||
|
||||
#跳过登录:true ,不跳过:false
|
||||
skipLogin: false
|
||||
83
data-collect-service/src/main/resources/application-prod.yml
Normal file
83
data-collect-service/src/main/resources/application-prod.yml
Normal file
@ -0,0 +1,83 @@
|
||||
server:
|
||||
port: 8010
|
||||
servlet:
|
||||
context-path: /api
|
||||
|
||||
#swagger2配置
|
||||
swagger2:
|
||||
enable: true #开启swagger
|
||||
projectName: 云平台--business-前端接口
|
||||
controllerPath: com.ho.datacollect.controller
|
||||
|
||||
#mqtt
|
||||
mqtt:
|
||||
url: tcp://123.60.190.77:1883 # hz线上环境MQTT
|
||||
userName: admin
|
||||
passWord: public
|
||||
timeout: 5000
|
||||
keepAlive: 60
|
||||
|
||||
#密钥
|
||||
secret:
|
||||
loginSecret: 6131231@#42a765#
|
||||
|
||||
#topic
|
||||
topic:
|
||||
edgeLoginRequest: +/device/+/login/request
|
||||
cloudLoginResponse: +/cloud/+/login/response
|
||||
|
||||
cloudReadRequest: +/cloud/+/read/request
|
||||
edgeReadResponse: +/device/+/read/response
|
||||
cloudWriteRequest: +/cloud/+/write/request
|
||||
edgeWriteResponse: +/device/+/write/response
|
||||
|
||||
cloudReportPush: +/cloud/+/report/push
|
||||
edgeReportPush: +/device/+/report/push
|
||||
|
||||
cloudControlRequest: +/cloud/+/control/request
|
||||
edgeControlResponse: +/device/+/control/response
|
||||
|
||||
|
||||
|
||||
spring:
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
name: datacollect-service
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.0.142:8848
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.0.236:3306/business_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||
username: zzkj
|
||||
password: zzkj@688737
|
||||
druid:
|
||||
initialSize: 5
|
||||
minIdle: 5
|
||||
maxActive: 5
|
||||
keepAlive: true #保持长连接
|
||||
connection-error-retry-attempts: 3
|
||||
#Redis
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 3000ms #连接超时
|
||||
host: 192.168.0.236 #单机
|
||||
password: zzkj@688737
|
||||
database: 0
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #连接池最大连接 默认8
|
||||
max-idle: 8 #连接池中最大空闲连接 默认8
|
||||
min-idle: 1 #连接池中最小空闲连接 默认0
|
||||
max-wait: 2000ms #连接池最大阻塞等待时间 使用负值表示没有限制
|
||||
|
||||
minio:
|
||||
accessKey: admin
|
||||
secretKey: zzkj@688737
|
||||
endpoint: http://192.168.0.236:9000
|
||||
prefixUrl: http://192.168.0.236:9000
|
||||
|
||||
#跳过登录:true ,不跳过:false
|
||||
skipLogin: false
|
||||
@ -53,7 +53,7 @@ largeScreen:
|
||||
#mqtt接外部数据使用
|
||||
mqtt1:
|
||||
url: tcp://1.95.131.171:1883
|
||||
userName: root
|
||||
userName: admin
|
||||
passWord: zzkj@688737
|
||||
timeout: 5000
|
||||
keepAlive: 60
|
||||
|
||||
@ -9,9 +9,9 @@
|
||||
</appender>
|
||||
|
||||
<appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/datacollect-service/datacollect-service.log</file>
|
||||
<file>/www/zzkjcloud/logs/datacollect-service/datacollect-service.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/datacollect-service/datacollect-service.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>/www/zzkjcloud/logs/datacollect-service/datacollect-service.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>10</maxHistory>
|
||||
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,
|
||||
@ -28,9 +28,9 @@
|
||||
|
||||
<!--Error级别-->
|
||||
<appender name="errorFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/datacollect-service/datacollect-service-error.log</file>
|
||||
<file>/www/zzkjcloud/logs/datacollect-service/datacollect-service-error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/datacollect-service/datacollect-service-error.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>/www/zzkjcloud/logs/datacollect-service/datacollect-service-error.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<!--180天-->
|
||||
<maxHistory>10</maxHistory>
|
||||
|
||||
@ -205,6 +205,9 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.2.12.RELEASE</version>
|
||||
<configuration>
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
||||
@ -0,0 +1,75 @@
|
||||
package com.ho.filecenter.config;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.ho.filecenter.util.AnotherMqttConfigUtil;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.IMqttToken;
|
||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author wp
|
||||
* @desc: Mqtt配置类
|
||||
* @date 2025/06/11
|
||||
*/
|
||||
@Configuration
|
||||
@Data
|
||||
@ConfigurationProperties("mqtt1")
|
||||
@Slf4j
|
||||
public class AnotherMqttConfig {
|
||||
|
||||
//服务器url
|
||||
@Value("${mqtt1.url}")
|
||||
String url;
|
||||
//超时时间
|
||||
@Value("${mqtt1.timeout}")
|
||||
Integer timeout;
|
||||
//会话保持时间
|
||||
@Value("${mqtt1.keepAlive}")
|
||||
Integer keepAlive;
|
||||
|
||||
@Value("${mqtt1.userName}")
|
||||
String userName;
|
||||
|
||||
@Value("${mqtt1.passWord}")
|
||||
String passWord;
|
||||
|
||||
@Autowired
|
||||
AnotherFileEdgeResponseConsumer fileEdgeResponseConsumer;
|
||||
|
||||
//文件响应
|
||||
@Bean(name = "AnotherFileEdgeResponse")
|
||||
public MqttClient initFileResponseClient() {
|
||||
String clientId = IdUtil.simpleUUID();
|
||||
log.info("clientId:" + clientId);
|
||||
MqttClient client =null;
|
||||
try {
|
||||
client = new MqttClient(url, clientId,null);
|
||||
MqttConnectOptions options = new MqttConnectOptions();
|
||||
options.setUserName(userName);
|
||||
options.setPassword(passWord.toCharArray());
|
||||
options.setCleanSession(true);
|
||||
options.setConnectionTimeout(timeout);
|
||||
options.setKeepAliveInterval(keepAlive);
|
||||
client.setCallback(fileEdgeResponseConsumer);
|
||||
IMqttToken iMqttToken = client.connectWithResult(options);
|
||||
boolean complete = iMqttToken.isComplete();
|
||||
log.info("FileResponseClient建立连接:{}", complete);
|
||||
|
||||
//这里监听的是
|
||||
String[] topic = AnotherMqttConfigUtil.getFileResponseTopic();
|
||||
int[] qos = new int[topic.length];
|
||||
client.subscribe(topic,qos);
|
||||
log.info("已订阅topic:{}", topic);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return client;
|
||||
}
|
||||
}
|
||||
@ -13,9 +13,13 @@ import com.ho.common.tools.exception.BusinessException;
|
||||
import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.CommonBytesUtil;
|
||||
import com.ho.common.tools.util.MqttUtil;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.filecenter.entity.MediaFile;
|
||||
import com.ho.filecenter.service.AnotherFileService;
|
||||
import com.ho.filecenter.service.FileService;
|
||||
import com.ho.filecenter.service.MqttTopicService;
|
||||
import com.ho.filecenter.util.MqttConfigUtil;
|
||||
import com.ho.filecenter.vo.mqtt.*;
|
||||
import com.ho.filecenter.vo.resp.*;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -53,6 +57,11 @@ public class FileController {
|
||||
@Autowired
|
||||
CommonBytesUtil bytesUtil;
|
||||
|
||||
@Autowired
|
||||
AnotherFileService anotherFileService;
|
||||
|
||||
@Autowired
|
||||
MqttTopicService mqttTopicService;
|
||||
@PostMapping("filePage")
|
||||
@ApiOperation(value = "分页查询文件")
|
||||
public DataResult<PageResult<MediaFile>> filePage(@RequestBody FilePageVO vo, HttpServletRequest request) {
|
||||
@ -152,7 +161,13 @@ public class FileController {
|
||||
fileAttributeResp.setList(new ArrayList<>());
|
||||
return DataResult.success(fileAttributeResp);
|
||||
}
|
||||
fileAttributeResp = fileService.getFileAttribute(vo);
|
||||
String serialNo = vo.getSerialNo();
|
||||
List<String> snList = mqttTopicService.getSnList();
|
||||
if(snList.stream().anyMatch(s -> s.contains(serialNo))){
|
||||
fileAttributeResp = fileService.getFileAttribute(vo);
|
||||
}else{
|
||||
fileAttributeResp = anotherFileService.getFileAttribute(vo);
|
||||
}
|
||||
return DataResult.success(fileAttributeResp);
|
||||
}
|
||||
|
||||
@ -168,7 +183,13 @@ public class FileController {
|
||||
fileDeleteResp.setMsg(msg + CommonConstant.Heartbeat.FAIL);
|
||||
return DataResult.success(fileDeleteResp);
|
||||
}
|
||||
fileDeleteResp = fileService.deleteDeviceFiles(fileDeleteReqVO);
|
||||
String serialNo = fileDeleteReqVO.getSerialNo();
|
||||
List<String> snList = mqttTopicService.getSnList();
|
||||
if(snList.stream().anyMatch(s -> s.contains(serialNo))){
|
||||
fileDeleteResp = fileService.deleteDeviceFiles(fileDeleteReqVO);
|
||||
}else{
|
||||
fileDeleteResp = anotherFileService.deleteDeviceFiles(fileDeleteReqVO);
|
||||
}
|
||||
return DataResult.success(fileDeleteResp);
|
||||
}
|
||||
|
||||
@ -193,7 +214,12 @@ public class FileController {
|
||||
resp.setMsg(CommonConstant.Heartbeat.MSG + serialNo + CommonConstant.Heartbeat.SUCCESS);
|
||||
resp.setHeartbeatStatus(CommonConstant.ONE);
|
||||
log.info("文件上传(向边端上传)开始上传");
|
||||
fileService.fileUploadForDevice(file, stationId, serialNo, filePath);
|
||||
List<String> snList = mqttTopicService.getSnList();
|
||||
if(snList.stream().anyMatch(s -> s.contains(serialNo))){
|
||||
fileService.fileUploadForDevice(file, stationId, serialNo, filePath);
|
||||
}else{
|
||||
anotherFileService.fileUploadForDevice(file, stationId, serialNo, filePath);
|
||||
}
|
||||
}
|
||||
return DataResult.success(resp);
|
||||
}
|
||||
@ -217,6 +243,13 @@ public class FileController {
|
||||
resp.setHeartbeatStatus(CommonConstant.ONE);
|
||||
log.info("文件下载(从边端下载到云端)开始下载");
|
||||
fileService.downloadFromDevice(fileForDeviceReqVO);
|
||||
String serialNo = fileForDeviceReqVO.getSerialNo();
|
||||
List<String> snList = mqttTopicService.getSnList();
|
||||
if(snList.stream().anyMatch(s -> s.contains(serialNo))){
|
||||
fileService.downloadFromDevice(fileForDeviceReqVO);
|
||||
}else{
|
||||
anotherFileService.downloadFromDevice(fileForDeviceReqVO);
|
||||
}
|
||||
}
|
||||
return DataResult.success(resp);
|
||||
}
|
||||
|
||||
@ -18,7 +18,10 @@ import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.PageResult;
|
||||
import com.ho.filecenter.feignclient.BusinessFeignClient;
|
||||
import com.ho.filecenter.feignclient.UserFeignClient;
|
||||
import com.ho.filecenter.service.AnotherOrderSendService;
|
||||
import com.ho.filecenter.service.MqttTopicService;
|
||||
import com.ho.filecenter.service.OrderSendService;
|
||||
import com.ho.filecenter.util.MqttConfigUtil;
|
||||
import com.ho.filecenter.vo.mqtt.*;
|
||||
import com.ho.filecenter.vo.resp.HeartbeatResp;
|
||||
import com.ho.filecenter.vo.resp.OrderProcessDetailResp;
|
||||
@ -60,6 +63,12 @@ public class OrderSendController {
|
||||
@Autowired
|
||||
UserFeignClient userFeignClient;
|
||||
|
||||
@Autowired
|
||||
AnotherOrderSendService anotherOrderSendService;
|
||||
|
||||
@Autowired
|
||||
MqttTopicService mqttTopicService;
|
||||
|
||||
public static final Long TIME_LIMIT = 90L;
|
||||
|
||||
@PostMapping("orderIssued")
|
||||
@ -158,7 +167,12 @@ public class OrderSendController {
|
||||
return DataResult.success(heartbeatResp);
|
||||
}
|
||||
log.info("指令下发正常开始下发");
|
||||
orderSendService.orderIssued(vo);
|
||||
List<String> snList = mqttTopicService.getSnList();
|
||||
if(snList.stream().anyMatch(s -> s.contains(sn))){
|
||||
orderSendService.orderIssued(vo);
|
||||
}else{
|
||||
anotherOrderSendService.orderIssued(vo);
|
||||
}
|
||||
if(vo.getPlanTemId() != null){
|
||||
String hourValue ="";
|
||||
String minuteValue ="";
|
||||
@ -322,7 +336,14 @@ public class OrderSendController {
|
||||
// @LogAnnotation(title = "命令下发曲线", action = "命令下发曲线")
|
||||
@TokenIgnore
|
||||
public DataResult<HeartbeatResp> sendPlanPowerOrder(@RequestBody OrderPlanPowerReq vo) {
|
||||
HeartbeatResp heartbeatResp = orderSendService.sendPlanPowerOrder(vo);
|
||||
String sn = vo.getSn();
|
||||
List<String> snList = mqttTopicService.getSnList();
|
||||
HeartbeatResp heartbeatResp = null;
|
||||
if(snList.stream().anyMatch(s -> s.contains(sn))){
|
||||
heartbeatResp = orderSendService.sendPlanPowerOrder(vo);
|
||||
}else{
|
||||
heartbeatResp = anotherOrderSendService.sendPlanPowerOrder(vo);
|
||||
}
|
||||
return DataResult.success(heartbeatResp);
|
||||
}
|
||||
|
||||
|
||||
@ -203,7 +203,7 @@ public class WeatherController {
|
||||
//每天的站级天气信息
|
||||
@PostMapping("jobStationWeathers")
|
||||
@TokenIgnore
|
||||
public DataResult jobStationWeathers() {
|
||||
public DataResult jobStationWeathers() throws InterruptedException {
|
||||
log.info("jobStationWeathers ,start");
|
||||
//先查所有电站
|
||||
DataResult<List<Station>> listDataResult = businessFeignClient.selectAllStation();
|
||||
@ -213,23 +213,9 @@ public class WeatherController {
|
||||
}
|
||||
List<Station> stations = listDataResult.getData();
|
||||
if (!stations.isEmpty()) {
|
||||
//得到不重复的电站
|
||||
// List<Station> stationList = weatherStationService.dealStation(stations);
|
||||
//生成按省市为key的缓存
|
||||
long updateTime = System.currentTimeMillis();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (Station station : stations) {
|
||||
//循环调用
|
||||
// String pinyin = PinyinUtil.getPinyin(station.getAddress());
|
||||
// log.info("pinyin:" + pinyin);
|
||||
// String longitude = String.valueOf(station.getLongitude());
|
||||
// String latitude = String.valueOf(station.getLatitude());
|
||||
// WeatherRespVo weather = weatherService.getWeatherFromApi(longitude, latitude);
|
||||
// weather.setUpdateTime(updateTime);
|
||||
// weather.setCityzh(station.getName());
|
||||
// //
|
||||
// String key = "weatherProvinceCity:" + pinyin;
|
||||
// redisService.set(key,weather );
|
||||
String adCode = station.getAdCode();
|
||||
if (null == adCode) {
|
||||
MyAddress address = AddressUntils.getAddress(String.valueOf(station.getLatitude()),String.valueOf(station.getLongitude()));
|
||||
@ -241,9 +227,15 @@ public class WeatherController {
|
||||
continue;
|
||||
}
|
||||
String key = RedisKeyConstant.WEATHER_PROVINCE_CITY + adCode;
|
||||
Thread.sleep(200);
|
||||
WeatherRespVo weatherRespVo = WeatherUntils.getWeatherRespVo(station.getAdCode());
|
||||
weatherRespVo.setUpdateTime(updateTime);
|
||||
redisService.set(key, weatherRespVo);
|
||||
if(weatherRespVo!=null){
|
||||
weatherRespVo.setUpdateTime(updateTime);
|
||||
redisService.set(key, weatherRespVo);
|
||||
log.info("更新天气站点名称:{},weatherRespVo:{}",station.getName(),weatherRespVo);
|
||||
}else{
|
||||
log.info("报错的站id:{},报错的adCode:{}",station.getId(),adCode);
|
||||
}
|
||||
map.put(adCode, adCode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
package com.ho.filecenter.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author kerwin
|
||||
*/
|
||||
public interface MqttTopicMapper {
|
||||
List<String> getSnList();
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.ho.filecenter.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author kerwin
|
||||
*/
|
||||
public interface MqttTopicService {
|
||||
|
||||
List<String> getSnList();
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.ho.filecenter.service.impl;
|
||||
|
||||
import com.ho.filecenter.mapper.MqttTopicMapper;
|
||||
import com.ho.filecenter.service.MqttTopicService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author kerwin
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MqttTopicServiceImpl implements MqttTopicService {
|
||||
|
||||
@Autowired
|
||||
MqttTopicMapper mqttTopicMapper;
|
||||
@Override
|
||||
public List<String> getSnList() {
|
||||
return mqttTopicMapper.getSnList();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.ho.filecenter.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class AnotherMqttConfigUtil {
|
||||
|
||||
public static String[] commonTopic = new String[]{
|
||||
"+/device/27d83a2844ff5866",
|
||||
"+/device/77ba753718908d1a",
|
||||
"+/device/93372fa4f4c4ebcf",
|
||||
"1/device/+"
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取文件请求监听主题
|
||||
* @return
|
||||
*/
|
||||
public static String[] getFileRequestTopic(){
|
||||
String log = "/file/request";
|
||||
String[] str = new String[commonTopic.length];
|
||||
for (int i = 0; i < commonTopic.length; i++) {
|
||||
str[i] = commonTopic[i]+log;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取文件响应监听主题
|
||||
* @return
|
||||
*/
|
||||
public static String[] getFileResponseTopic(){
|
||||
String log = "/file/response";
|
||||
String[] str = new String[commonTopic.length];
|
||||
for (int i = 0; i < commonTopic.length; i++) {
|
||||
str[i] = commonTopic[i]+log;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String[] getCurveResponseTopic(){
|
||||
String log = "/curve/response";
|
||||
String[] str = new String[commonTopic.length];
|
||||
for (int i = 0; i < commonTopic.length; i++) {
|
||||
str[i] = commonTopic[i]+log;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String[] getDispatchResponseTopic(){
|
||||
String log = "/dispatch/response";
|
||||
String[] str = new String[commonTopic.length];
|
||||
for (int i = 0; i < commonTopic.length; i++) {
|
||||
str[i] = commonTopic[i]+log;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取SN配置合集
|
||||
* @return
|
||||
*/
|
||||
public static List<String> getSnList(){
|
||||
List<String> strings = Arrays.asList(commonTopic);
|
||||
return strings;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,8 @@
|
||||
package com.ho.filecenter.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MqttConfigUtil {
|
||||
|
||||
public static String[] commonTopic = new String[]{
|
||||
@ -117,6 +120,22 @@ public class MqttConfigUtil {
|
||||
"+/device/67aa37e699e1e08f",
|
||||
"+/device/ea0ebfbfa1487bd2",
|
||||
"+/device/aa8a43d326dddb3f",
|
||||
"+/device/82d40d7dbcfc884e",
|
||||
"+/device/34ee15e05a3133bc",
|
||||
"+/device/ee2508ba91664376",
|
||||
"+/device/48c18f2a756dcc28",
|
||||
"+/device/056d38ac91f61ffd",
|
||||
"+/device/60f2bbbc054bfa03",
|
||||
"+/device/50fdebcf6eb85a49",
|
||||
"+/device/227a752b9bfb6b02",
|
||||
"+/device/d60a05bcd086f160",
|
||||
"+/device/f3c813d5e3d7fd99",
|
||||
"+/device/cd6cb4a64b42bda5",
|
||||
"+/device/436de647bbf01b22",
|
||||
"+/device/e9eee97d793756fa",
|
||||
"+/device/8c062827b5c1548b",
|
||||
"+/device/d143856d757625e1",
|
||||
"+/device/3522ab4e7faf28b8",
|
||||
"1/device/+"
|
||||
};
|
||||
|
||||
|
||||
@ -7,13 +7,14 @@ server:
|
||||
|
||||
#mqtt
|
||||
mqtt:
|
||||
url: tcp://123.60.190.77:1883
|
||||
url: tcp://1.95.170.86:1883
|
||||
userName: admin
|
||||
passWord: public
|
||||
passWord: zzkj688737
|
||||
timeout: 5000
|
||||
keepAlive: 60
|
||||
|
||||
#主题 todo 先死一个用于测试
|
||||
|
||||
#主题 todo
|
||||
topic:
|
||||
cloudFileRequest: +/cloud/+/file/request
|
||||
cloudFileResponse: +/cloud/+/file/response
|
||||
@ -61,9 +62,9 @@ spring:
|
||||
server-addr: 127.0.0.1:8848
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.100.244:3306/file_center_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: root
|
||||
password: 123456
|
||||
url: jdbc:mysql://1.95.170.86:3306/file_center_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: file_center_db
|
||||
password: zzkj@688737
|
||||
druid:
|
||||
initialSize: 5
|
||||
minIdle: 5
|
||||
@ -80,22 +81,9 @@ spring:
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 3000ms #连接超时
|
||||
host: 192.168.100.244 #单机
|
||||
host: 1.95.170.86 #单机
|
||||
password: 123456
|
||||
database: 0
|
||||
|
||||
#port: 6379 #端口
|
||||
#timeout: 5000ms #连接超时
|
||||
#host: 127.0.0.1 #单机
|
||||
#password:
|
||||
#database: 0
|
||||
#集群 真实环境开启
|
||||
# cluster:
|
||||
# nodes:
|
||||
# - 127.0.0.1:6379
|
||||
# - 127.0.0.1:6380
|
||||
# - 127.0.0.1:6381
|
||||
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #连接池最大连接 默认8
|
||||
@ -104,8 +92,8 @@ spring:
|
||||
max-wait: 2000ms #连接池最大阻塞等待时间 使用负值表示没有限制
|
||||
|
||||
minio:
|
||||
accessKey: admin
|
||||
secretKey: zzkj@688737
|
||||
endpoint: http://192.168.0.236:9000
|
||||
prefixUrl: http://192.168.0.236:9000
|
||||
accessKey: minioadmin
|
||||
secretKey: minioadmin
|
||||
endpoint: http://1.95.170.86:9000
|
||||
prefixUrl: http://1.95.170.86:9000
|
||||
|
||||
|
||||
98
file-center/src/main/resources/application-prod.yml
Normal file
98
file-center/src/main/resources/application-prod.yml
Normal file
@ -0,0 +1,98 @@
|
||||
#文件中心
|
||||
server:
|
||||
port: 8017
|
||||
servlet:
|
||||
#上下文统一使用api,屏蔽前端路径差异
|
||||
context-path: /api
|
||||
|
||||
#mqtt
|
||||
mqtt:
|
||||
url: tcp://123.60.190.77:1883 # hz线上环境MQTT
|
||||
userName: admin
|
||||
passWord: public
|
||||
timeout: 5000
|
||||
keepAlive: 60
|
||||
|
||||
#主题 todo
|
||||
topic:
|
||||
cloudFileRequest: +/cloud/+/file/request
|
||||
cloudFileResponse: +/cloud/+/file/response
|
||||
edgeFileResponse: +/device/+/file/response
|
||||
edgeFileRequest: +/device/+/file/request
|
||||
|
||||
cloudControlRequest: +/cloud/+/control/request
|
||||
edgeControlResponse: +/device/+/control/response
|
||||
|
||||
#路径 todo 先再本地
|
||||
path:
|
||||
local: /opt/file_center
|
||||
#下发文件路径
|
||||
copy: /opt/file_copy
|
||||
#天气ip2region.db路径
|
||||
weather: /opt/ip2region.db
|
||||
chartPath: /opt/image/
|
||||
|
||||
#指定字节大小
|
||||
size:
|
||||
byteSize: 102400
|
||||
|
||||
|
||||
#通用文件
|
||||
files:
|
||||
upload:
|
||||
path: D:\upload
|
||||
format: .jpg,.png,.doc,.docx,.xlsx,.xls,.pdf
|
||||
maxByte: 10485760
|
||||
|
||||
#swagger2配置
|
||||
swagger2:
|
||||
enable: true #开启标志 生产环境要关闭
|
||||
projectName: 云平台-文件中心-接口
|
||||
controllerPath: com.ho.filecenter.controller
|
||||
|
||||
spring:
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
name: file-center
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.0.142:8848
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.0.236:3306/file_center_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: file_center_db
|
||||
password: zzkj@688737
|
||||
druid:
|
||||
initialSize: 5
|
||||
minIdle: 5
|
||||
maxActive: 5
|
||||
keepAlive: true #保持长连接
|
||||
connection-error-retry-attempts: 3
|
||||
#设备文件上传大小
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 500MB
|
||||
max-request-size: 500MB
|
||||
enabled: true
|
||||
#Redis
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 3000ms #连接超时
|
||||
host: 192.168.0.236 #单机
|
||||
password: zzkj@688737
|
||||
database: 0
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #连接池最大连接 默认8
|
||||
max-idle: 8 #连接池中最大空闲连接 默认8
|
||||
min-idle: 1 #连接池中最小空闲连接 默认0
|
||||
max-wait: 2000ms #连接池最大阻塞等待时间 使用负值表示没有限制
|
||||
|
||||
minio:
|
||||
accessKey: admin
|
||||
secretKey: zzkj@688737
|
||||
endpoint: http://192.168.0.236:9000
|
||||
prefixUrl: http://192.168.0.236:9000
|
||||
|
||||
@ -78,3 +78,11 @@ switch:
|
||||
fileDefaultLogic: true
|
||||
#命令下发默认逻辑的开关 true 为打开 ,false为关闭
|
||||
orderSendDefaultLogic: true
|
||||
|
||||
#mqtt接外部数据使用
|
||||
mqtt1:
|
||||
url: tcp://1.95.131.171:1883
|
||||
userName: root
|
||||
passWord: zzkj@688737
|
||||
timeout: 5000
|
||||
keepAlive: 60
|
||||
Binary file not shown.
@ -9,9 +9,9 @@
|
||||
</appender>
|
||||
|
||||
<appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/file-center/file-center.log</file>
|
||||
<file>/www/zzkjcloud/logs/file-center/file-center.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/file-center/file-center.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>/www/zzkjcloud/logs/file-center/file-center.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>10</maxHistory>
|
||||
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,
|
||||
|
||||
10
file-center/src/main/resources/mapper/MqttTopicMapper.xml
Normal file
10
file-center/src/main/resources/mapper/MqttTopicMapper.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ho.filecenter.mapper.MqttTopicMapper">
|
||||
|
||||
<select id="getSnList" resultType="java.lang.String">
|
||||
select topic from mqtt_topic
|
||||
</select>
|
||||
</mapper>
|
||||
@ -63,6 +63,9 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.2.12.RELEASE</version>
|
||||
<configuration>
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
|
||||
@ -17,9 +17,9 @@ spring:
|
||||
server-addr: 127.0.0.1:8848
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.100.244:3306/flow_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowMultiQueries=true
|
||||
username: root
|
||||
password: 123456
|
||||
url: jdbc:mysql://1.95.170.86:3306/flow_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowMultiQueries=true
|
||||
username: flow_db
|
||||
password: zzkj@688737
|
||||
druid:
|
||||
initialSize: 5
|
||||
minIdle: 5
|
||||
@ -31,21 +31,9 @@ spring:
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 300000ms #连接超时
|
||||
host: 192.168.100.244 #单机
|
||||
host: 1.95.170.86 #单机
|
||||
password: 123456
|
||||
database: 0
|
||||
|
||||
#port: 6379 #端口
|
||||
#timeout: 5000ms #连接超时
|
||||
#host: 127.0.0.1 #单机
|
||||
#password:
|
||||
#database: 0
|
||||
#集群 真实环境开启
|
||||
# record:
|
||||
# nodes:
|
||||
# - 127.0.0.1:6379
|
||||
# - 127.0.0.1:6380
|
||||
# - 127.0.0.1:6381
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #连接池最大连接 默认8
|
||||
|
||||
84
flowable-center/src/main/resources/application-prod.yml
Normal file
84
flowable-center/src/main/resources/application-prod.yml
Normal file
@ -0,0 +1,84 @@
|
||||
#文件中心
|
||||
server:
|
||||
port: 8021
|
||||
servlet:
|
||||
#上下文统一使用api,屏蔽前端路径差异
|
||||
context-path: /api
|
||||
tomcat:
|
||||
min-spare-threads: 30
|
||||
spring:
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
name: flowable-center
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.0.142:8848
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.0.236:3306/flow_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowMultiQueries=true
|
||||
username: flow_db
|
||||
password: zzkj@688737
|
||||
druid:
|
||||
initialSize: 5
|
||||
minIdle: 5
|
||||
maxActive: 5
|
||||
keepAlive: true #保持长连接
|
||||
connection-error-retry-attempts: 3
|
||||
|
||||
#Redis
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 300000ms #连接超时
|
||||
host: 192.168.0.236 #单机
|
||||
password: zzkj@688737
|
||||
database: 0
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #连接池最大连接 默认8
|
||||
max-idle: 8 #连接池中最大空闲连接 默认8
|
||||
min-idle: 1 #连接池中最小空闲连接 默认0
|
||||
max-wait: 2000ms #连接池最大阻塞等待时间 使用负值表示没有限制
|
||||
#工作流
|
||||
activiti:
|
||||
# 自动部署,验证设置:true-开启(默认)、false-关闭
|
||||
check-process-definitions: false
|
||||
# 保存历史数据
|
||||
history-level: full
|
||||
# 检测历史表是否存在
|
||||
db-history-used: true
|
||||
# 关闭自动部署
|
||||
deployment-mode: never-fail
|
||||
# 对数据库中所有表进行更新操作,如果表不存在,则自动创建
|
||||
# create_drop:启动时创建表,在关闭时删除表(必须手动关闭引擎,才能删除表)
|
||||
# drop-create:启动时删除原来的旧表,然后在创建新表(不需要手动关闭引擎)
|
||||
database-schema-update: true
|
||||
# 解决频繁查询SQL问题
|
||||
async-executor-activate: false
|
||||
use-strong-uuids: false
|
||||
initialDelay: 5
|
||||
flag: 0
|
||||
|
||||
#自定义工作量变量
|
||||
flow:
|
||||
#工单流程配置
|
||||
workOrder:
|
||||
#流程定义的key ,根据实际的名称来
|
||||
procDefKey: workOrder
|
||||
#处理工单的岗位 ,后续可能是多个
|
||||
doing: tro,worker
|
||||
#验收工单的岗位
|
||||
check: tro,worker
|
||||
#评价工单的岗位
|
||||
appraise: ceo
|
||||
|
||||
#swagger2配置
|
||||
swagger2:
|
||||
enable: true #开启swagger
|
||||
projectName: 云平台--flow-前端接口
|
||||
controllerPath: com.ho.flow.controller
|
||||
|
||||
|
||||
|
||||
|
||||
@ -9,9 +9,9 @@
|
||||
</appender>
|
||||
|
||||
<appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/flowable-center/flowable-center.log</file>
|
||||
<file>/www/zzkjcloud/logs/flowable-center/flowable-center.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/flowable-center/flowable-center.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>/www/zzkjcloud/logs/flowable-center/flowable-center.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<!--180天-->
|
||||
<maxHistory>7</maxHistory>
|
||||
@ -29,9 +29,9 @@
|
||||
|
||||
<!--Error级别-->
|
||||
<appender name="errorFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/flowable-center/flowable-center-error.log</file>
|
||||
<file>/www/zzkjcloud/logs/flowable-center/flowable-center-error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/flowable-center/flowable-center-error.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>/www/zzkjcloud/logs/flowable-center/flowable-center-error.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<!--180天-->
|
||||
<maxHistory>7</maxHistory>
|
||||
|
||||
30
pom.xml
30
pom.xml
@ -166,11 +166,11 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--JWT-->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>${jjwt.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>io.jsonwebtoken</groupId>-->
|
||||
<!-- <artifactId>jjwt</artifactId>-->
|
||||
<!-- <version>${jjwt.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!--Lombok-->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
@ -335,16 +335,16 @@
|
||||
<version>${ip2region.version}</version>
|
||||
</dependency>
|
||||
<!-- skywalking 整合 logback -->
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>apm-toolkit-logback-1.x</artifactId>
|
||||
<version>${apm-toolkit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>apm-toolkit-trace</artifactId>
|
||||
<version>${apm-toolkit.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.skywalking</groupId>-->
|
||||
<!-- <artifactId>apm-toolkit-logback-1.x</artifactId>-->
|
||||
<!-- <version>${apm-toolkit.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.skywalking</groupId>-->
|
||||
<!-- <artifactId>apm-toolkit-trace</artifactId>-->
|
||||
<!-- <version>${apm-toolkit.version}</version>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<!--<build>
|
||||
|
||||
@ -13,23 +13,9 @@ spring:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
datasource:
|
||||
# tdengine-server:
|
||||
# #jdbc-url: jdbc:TAOS://192.168.1.198:6030/test_td_db?user=root&password=taosdata&charset=UTF-8&locale=zh_CN.UTF-8&timezone=UTC-8
|
||||
# jdbc-url: jdbc:TAOS-RS://123.60.64.124:6041/test_td_db?user=root&password=taosdata&charset=UTF-8&locale=zh_CN.UTF-8&timezone=UTC-8
|
||||
# username: root
|
||||
# password: taosdata
|
||||
# type: com.zaxxer.hikari.HikariDataSource # Hikari连接池的设置
|
||||
# minimum-idle: 5 #最小连接
|
||||
# maximum-pool-size: 15 #最大连接
|
||||
# auto-commit: true #自动提交
|
||||
# idle-timeout: 30000 #最大空闲时常
|
||||
# pool-name: TDengineDruidCP #连接池名
|
||||
# max-lifetime: 1800000 #最大生命周期
|
||||
# connection-timeout: 30000 #连接超时时间
|
||||
# connection-test-query: show tables
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
|
||||
url: jdbc:TAOS-RS://1.95.153.121:6041/test_td_db?user=root&password=taosdata&charset=UTF-8&locale=zh_CN.UTF-8&timezone=UTC-8
|
||||
url: jdbc:TAOS-RS://1.95.170.86:6041/test_td_db?user=root&password=taosdata&charset=UTF-8&locale=zh_CN.UTF-8&timezone=UTC-8
|
||||
username: root
|
||||
password: taosdata
|
||||
druid:
|
||||
@ -39,19 +25,12 @@ spring:
|
||||
max-wait: 10000
|
||||
time-between-eviction-runs-millis: 60000
|
||||
validation-query: SELECT 1 as nums
|
||||
# test-while-idle: true
|
||||
# test-on-borrow: false
|
||||
# test-on-return: false
|
||||
# pool-prepared-statements: true
|
||||
# max-pool-prepared-statement-per-connection-size: 20
|
||||
# connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
|
||||
# filters: stat # 拦截sql的开
|
||||
#Redis
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 3000ms #连接超时
|
||||
host: 1.95.153.121 #单机
|
||||
password: zzkj@688737
|
||||
host: 1.95.170.86 #单机
|
||||
password: 123456
|
||||
database: 0
|
||||
|
||||
boot:
|
||||
|
||||
39
td-service/src/main/resources/application-prod.yml
Normal file
39
td-service/src/main/resources/application-prod.yml
Normal file
@ -0,0 +1,39 @@
|
||||
server:
|
||||
port: 8013
|
||||
servlet:
|
||||
context-path: /td
|
||||
|
||||
spring:
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
name: td-service
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.0.142:8848
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
|
||||
url: jdbc:TAOS-RS://192.168.0.236:6041/test_td_db?user=root&password=taosdata&charset=UTF-8&locale=zh_CN.UTF-8&timezone=UTC-8
|
||||
username: root
|
||||
password: taosdata
|
||||
druid:
|
||||
initial-size: 6
|
||||
min-idle: 6
|
||||
max-active: 12
|
||||
max-wait: 10000
|
||||
time-between-eviction-runs-millis: 60000
|
||||
validation-query: SELECT 1 as nums
|
||||
#Redis
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 3000ms #连接超时
|
||||
host: 192.168.0.236 #单机
|
||||
password: zzkj@688737
|
||||
database: 0
|
||||
|
||||
boot:
|
||||
admin:
|
||||
client:
|
||||
url: http://localhost:8019/boot
|
||||
@ -9,9 +9,9 @@
|
||||
</appender>
|
||||
|
||||
<appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/td-service/td-service.log</file>
|
||||
<file>/www/zzkjcloud/logs/td-service/td-service.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/td-service/td-service.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>/www/zzkjcloud/logs/td-service/td-service.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>10</maxHistory>
|
||||
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,
|
||||
@ -27,9 +27,9 @@
|
||||
</appender>
|
||||
|
||||
<appender name="errorFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/td-service/td-service-error.log</file>
|
||||
<file>/www/zzkjcloud/logs/td-service/td-service-error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/td-service/td-service-error.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>/www/zzkjcloud/logs/td-service/td-service-error.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>10</maxHistory>
|
||||
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,
|
||||
|
||||
@ -19,4 +19,8 @@ public class QueryPermissionReqVo {
|
||||
@ApiModelProperty(value = "状态")
|
||||
@ApiParam
|
||||
Integer status;
|
||||
|
||||
@ApiModelProperty(value = "语言切换")
|
||||
@ApiParam
|
||||
String lang;
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package com.ho.user.api.vo.req;
|
||||
|
||||
import com.ho.common.tools.entity.UserDetailRespVO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户统一登陆
|
||||
*/
|
||||
@Data
|
||||
public class UserUnifiedLoginVo {
|
||||
|
||||
@ApiModelProperty(value = "储能登陆")
|
||||
private UserDetailRespVO energy;
|
||||
|
||||
@ApiModelProperty(value = "光伏登陆")
|
||||
private UserDetailRespVO pv;
|
||||
|
||||
}
|
||||
@ -73,6 +73,7 @@ public class ShiroConfig {
|
||||
// 配置不会被拦截的链接 顺序判断
|
||||
filterChainDefinitionMap.put("/sys/user/login", "anon");
|
||||
filterChainDefinitionMap.put("/sys/user/getToken", "anon");
|
||||
filterChainDefinitionMap.put("/sys/user/getUnifiedLogin", "anon");
|
||||
filterChainDefinitionMap.put("/sys/user/register", "anon");
|
||||
filterChainDefinitionMap.put("/sys/key/decrypt", "anon");
|
||||
filterChainDefinitionMap.put("/mongoId", "anon");
|
||||
|
||||
@ -2,6 +2,7 @@ package com.ho.user.controller;
|
||||
|
||||
import com.ho.common.tools.annotation.LogAnnotation;
|
||||
import com.ho.common.tools.constant.ContextConstant;
|
||||
import com.ho.common.tools.constant.RedisKeyConstant;
|
||||
import com.ho.common.tools.entity.PageVO;
|
||||
import com.ho.common.tools.exception.BaseResponseCode;
|
||||
import com.ho.common.tools.exception.BusinessException;
|
||||
@ -16,6 +17,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@ -47,10 +49,12 @@ public class DictController {
|
||||
@PostMapping("typeList")
|
||||
@ApiOperation(value = "查询字典列表接口(根据类型)")
|
||||
// @LogAnnotation(title = "字典管理",action = "根据类型查询字典")
|
||||
public DataResult<DictRespVo> dictList(@RequestBody @Valid DictSearchReqVO vo) {
|
||||
public DataResult<DictRespVo> dictList(@RequestBody @Valid DictSearchReqVO vo,HttpServletRequest request) {
|
||||
String lang =request.getHeader(RedisKeyConstant.User.LANG);
|
||||
DataResult<DictRespVo> result = DataResult.success();
|
||||
DictTypeAndLabelReqVO typeAndLabelReqVO = new DictTypeAndLabelReqVO();
|
||||
typeAndLabelReqVO.setType(vo.getType());
|
||||
typeAndLabelReqVO.setLang(lang);
|
||||
result.setData(dictService.selectDict(typeAndLabelReqVO));
|
||||
return result;
|
||||
}
|
||||
@ -75,9 +79,10 @@ public class DictController {
|
||||
|
||||
@PostMapping("typeAll")
|
||||
@ApiOperation(value = "查询所有字典列表接口")
|
||||
public DataResult<List<DictRespVo>> typeList() {
|
||||
public DataResult<List<DictRespVo>> typeList(HttpServletRequest request) {
|
||||
String lang =request.getHeader(RedisKeyConstant.User.LANG);
|
||||
DataResult<List<DictRespVo>> result = DataResult.success();
|
||||
result.setData(dictService.selectDictType());
|
||||
result.setData(dictService.selectDictType(lang));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -294,9 +294,10 @@ public class PermissionController {
|
||||
public DataResult<List<PermissionRespNode>> getStationPer(@RequestBody PermStationRelation permStationRelation, HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
String userTokenKey = RedisKeyConstant.User.TOKEN + token;
|
||||
String lang=request.getHeader(RedisKeyConstant.User.LANG);
|
||||
UserDetailRespVO user = (UserDetailRespVO) redisService.get(userTokenKey);
|
||||
DataResult<List<PermissionRespNode>> result = DataResult.success();
|
||||
result.setData(permissionService.getStationPer(permStationRelation.getStationId(),user));
|
||||
result.setData(permissionService.getStationPer(permStationRelation.getStationId(),user,lang));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,9 @@ package com.ho.user.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.ho.common.tools.annotation.HzPermission;
|
||||
import com.ho.common.tools.annotation.LogAnnotation;
|
||||
import com.ho.common.tools.annotation.TokenIgnore;
|
||||
@ -18,9 +21,11 @@ import com.ho.common.tools.exception.DataResult;
|
||||
import com.ho.common.tools.service.RedisService;
|
||||
import com.ho.common.tools.util.AESEncryptUtil;
|
||||
import com.ho.common.tools.util.FastUtils;
|
||||
import com.ho.common.tools.util.HttpUtils;
|
||||
import com.ho.user.api.entity.SysDept;
|
||||
import com.ho.user.api.entity.SysUser;
|
||||
import com.ho.user.api.entity.WorkOrderUser;
|
||||
import com.ho.user.api.vo.req.UserUnifiedLoginVo;
|
||||
import com.ho.user.entity.SysTheme;
|
||||
import com.ho.user.service.*;
|
||||
import com.ho.user.vo.req.*;
|
||||
@ -96,6 +101,7 @@ public class UserController {
|
||||
public DataResult<UserDetailRespVO> yourSelfInfo(@RequestParam(required = false) String type,HttpServletRequest request) {
|
||||
String token = request.getHeader(RedisKeyConstant.User.ACCESS_TOKEN);
|
||||
String userTokenKey = RedisKeyConstant.User.TOKEN + token;
|
||||
String lang =request.getHeader(RedisKeyConstant.User.LANG);
|
||||
//根据用户的登陆方式(账号还是手机号),延长对应缓存
|
||||
if (redisService.hasKey(userTokenKey)) {
|
||||
//每次获取用户信息,都会进行过期时间的延长
|
||||
@ -105,7 +111,7 @@ public class UserController {
|
||||
if(null != type){
|
||||
user.setConfigType(type);
|
||||
}
|
||||
UserDetailRespVO vo = userService.yourSelfInfo(user, simpleUser.getPlatSuper());
|
||||
UserDetailRespVO vo = userService.yourSelfInfo(user, simpleUser.getPlatSuper(),lang);
|
||||
//延长token时间
|
||||
//redisCommon.extendKeyTime(userTokenKey, null);
|
||||
//String userNameKey = RedisKeyConstant.User.USER_NAME + user.getUsername();
|
||||
@ -542,4 +548,60 @@ public class UserController {
|
||||
return DataResult.success();
|
||||
}
|
||||
|
||||
@PostMapping(value = "getUnifiedLogin")
|
||||
@ApiOperation(value = "用户统一登录接口")
|
||||
@TokenIgnore
|
||||
public DataResult<UserUnifiedLoginVo> getUnifiedLogin(@RequestBody @Valid LoginReqVO loginReqVO) {
|
||||
UserUnifiedLoginVo unifiedLoginVo = new UserUnifiedLoginVo();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
//储能登陆
|
||||
String enUrl = "http://192.168.0.142:8012/api/sys/user/login";
|
||||
String enJson = HttpUtils.postWithJson(enUrl,mapper.writeValueAsString(loginReqVO));
|
||||
JSONObject en = JSONObject.parseObject(enJson);
|
||||
Integer codeEn = en.getInteger("code");
|
||||
if(CommonConstant.HttpCode.SUCCESS_CODE.equals(codeEn)){
|
||||
String enString = en.getString("data");
|
||||
UserDetailRespVO enVo = JSON.parseObject(enString,UserDetailRespVO.class);
|
||||
unifiedLoginVo.setEnergy(enVo);
|
||||
}
|
||||
//光伏登陆
|
||||
String pvUrl = "http://192.168.0.183:18012/api/sys/user/login";
|
||||
String pvJson = HttpUtils.postWithJson(pvUrl,mapper.writeValueAsString(loginReqVO));
|
||||
JSONObject pv = JSONObject.parseObject(pvJson);
|
||||
Integer codePv = pv.getInteger("code");
|
||||
if(CommonConstant.HttpCode.SUCCESS_CODE.equals(codePv)){
|
||||
String pvString = pv.getString("data");
|
||||
UserDetailRespVO pvVo = JSON.parseObject(pvString,UserDetailRespVO.class);
|
||||
unifiedLoginVo.setPv(pvVo);
|
||||
}
|
||||
if(unifiedLoginVo.getEnergy()==null && unifiedLoginVo.getPv()==null){
|
||||
if(BaseResponseCode.NOT_ACCOUNT.getCode()==codeEn
|
||||
&&BaseResponseCode.NOT_ACCOUNT.getCode()==codePv){
|
||||
throw new BusinessException(BaseResponseCode.NOT_ACCOUNT);
|
||||
}
|
||||
if (BaseResponseCode.PASSWORD_ERROR.getCode()==codeEn
|
||||
||BaseResponseCode.PASSWORD_ERROR.getCode()==codePv ){
|
||||
throw new BusinessException(BaseResponseCode.PASSWORD_ERROR);
|
||||
}
|
||||
if (BaseResponseCode.USER_LOCK.getCode()==codeEn
|
||||
||BaseResponseCode.USER_LOCK.getCode()==codePv ){
|
||||
throw new BusinessException(BaseResponseCode.USER_LOCK);
|
||||
}
|
||||
if (BaseResponseCode.LOSE_EFFICACY.getCode()==codeEn
|
||||
||BaseResponseCode.LOSE_EFFICACY.getCode()==codePv ){
|
||||
throw new BusinessException(BaseResponseCode.LOSE_EFFICACY);
|
||||
}
|
||||
if (BaseResponseCode.TO_BELONGING_DEPT_DISABLE.getCode()==codeEn
|
||||
||BaseResponseCode.TO_BELONGING_DEPT_DISABLE.getCode()==codePv ){
|
||||
throw new BusinessException(BaseResponseCode.TO_BELONGING_DEPT_DISABLE);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return DataResult.success(unifiedLoginVo);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public interface SysDictMapper {
|
||||
SysSubDict selectBySubId(Integer id);
|
||||
|
||||
|
||||
List<SysSubDict> selectSubDictByType(String type);
|
||||
List<SysSubDict> selectSubDictByType(@Param("type") String type,@Param("lang") String lang);
|
||||
|
||||
List<SysSubDict> selectSubDictByTypeList(@Param("typeList") List<String> typeList);
|
||||
|
||||
|
||||
@ -50,5 +50,5 @@ public interface SysPermissionMapper {
|
||||
|
||||
List<SysPermission> selectByScope();
|
||||
|
||||
List<SysPermission> selectByIds(@Param("ids") List<Integer> perIds);
|
||||
List<SysPermission> selectByIds(@Param("ids") List<Integer> perIds,@Param("lang") String lang);
|
||||
}
|
||||
@ -34,11 +34,11 @@ public interface DictService {
|
||||
|
||||
// void deletedByType(String type);
|
||||
|
||||
List<DictRespVo> selectDictType();
|
||||
List<DictRespVo> selectDictType(String lang);
|
||||
|
||||
SysSubDict selectSubDictByValue(DictAddReqVO vo);
|
||||
|
||||
List<SysSubDict> selectSubDictByType(String type);
|
||||
List<SysSubDict> selectSubDictByType(String type,String lang);
|
||||
|
||||
List<SysSubDict> selectSubDictByTypeList(List<String> typeList);
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ public interface PermissionService {
|
||||
|
||||
List<SysPermission> getPermission(String userId);
|
||||
|
||||
List<SysPermission> getPermissionByRoleIds(List<Integer> roleIds);
|
||||
List<SysPermission> getPermissionByRoleIds(List<Integer> roleIds,String lang);
|
||||
|
||||
List<SysPermission> getPermissionByTop();
|
||||
|
||||
@ -66,7 +66,7 @@ public interface PermissionService {
|
||||
List<SysPermission> getSysMangeMenus(List<SysPermission> list, List<Integer> queryIds);
|
||||
|
||||
|
||||
List<PermissionRespNode> getStationPer(Integer stationId, UserDetailRespVO user);
|
||||
List<PermissionRespNode> getStationPer(Integer stationId, UserDetailRespVO user,String lang);
|
||||
|
||||
List<PermissionRespNode> getAll(QueryPermissionReqVo query);
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ public interface UserService {
|
||||
|
||||
List<SysUser> selectIds(List<String> userIds);
|
||||
|
||||
UserDetailRespVO yourSelfInfo(UserDetailRespVO user, boolean platSuper);
|
||||
UserDetailRespVO yourSelfInfo(UserDetailRespVO user, boolean platSuper,String lang);
|
||||
|
||||
//清除用户缓存
|
||||
void removeUserCache(String username, String loginChannel);
|
||||
|
||||
@ -65,7 +65,7 @@ public class DictServiceImpl implements DictService {
|
||||
}
|
||||
int upDictRet = dictMapper.updateDict(dict);
|
||||
log.info("修改sys_dict记录数:" + upDictRet);
|
||||
List<SysSubDict> sysSubDicts = selectSubDictByType(sysDict.getType());
|
||||
List<SysSubDict> sysSubDicts = selectSubDictByType(sysDict.getType(),null);
|
||||
int upSubDictRet = 0;
|
||||
for (SysSubDict sysSubDict : sysSubDicts) {
|
||||
sysSubDict.setType(vo.getType());
|
||||
@ -96,7 +96,7 @@ public class DictServiceImpl implements DictService {
|
||||
|
||||
SysSubDict subDict = new SysSubDict();
|
||||
BeanUtils.copyProperties(vo,subDict);
|
||||
List<SysSubDict> sysSubDicts = selectSubDictByType(vo.getType());
|
||||
List<SysSubDict> sysSubDicts = selectSubDictByType(vo.getType(),null);
|
||||
if (sysSubDicts.size() == 0){
|
||||
throw new BusinessException(BaseResponseCode.DICT_DELETED_EXISTS);
|
||||
}
|
||||
@ -150,8 +150,8 @@ public class DictServiceImpl implements DictService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysSubDict> selectSubDictByType(String type) {
|
||||
List<SysSubDict> sysSubDicts = dictMapper.selectSubDictByType(type);
|
||||
public List<SysSubDict> selectSubDictByType(String type,String lang) {
|
||||
List<SysSubDict> sysSubDicts = dictMapper.selectSubDictByType(type,lang);
|
||||
return sysSubDicts;
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ public class DictServiceImpl implements DictService {
|
||||
SysDict sysDict = dictMapper.selectByType(vo.getType());
|
||||
DictRespVo dictRespVo = new DictRespVo();
|
||||
BeanUtils.copyProperties(sysDict,dictRespVo);
|
||||
List<SysSubDict> sysSubDicts = selectSubDictByType(vo.getType());
|
||||
List<SysSubDict> sysSubDicts = selectSubDictByType(vo.getType(),vo.getLang());
|
||||
dictRespVo.setList(sysSubDicts);
|
||||
return dictRespVo;
|
||||
}
|
||||
@ -190,13 +190,13 @@ public class DictServiceImpl implements DictService {
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public List<DictRespVo> selectDictType() {
|
||||
public List<DictRespVo> selectDictType(String lang) {
|
||||
List<SysDict> sysDicts = dictMapper.selectTypeAll();
|
||||
List<DictRespVo> respVos = new ArrayList<>();
|
||||
for (SysDict sysDict : sysDicts) {
|
||||
DictRespVo vo = new DictRespVo();
|
||||
BeanUtils.copyProperties(sysDict,vo);
|
||||
List<SysSubDict> sysSubDicts = selectSubDictByType(sysDict.getType());
|
||||
List<SysSubDict> sysSubDicts = selectSubDictByType(sysDict.getType(),lang);
|
||||
vo.setList(sysSubDicts);
|
||||
respVos.add(vo);
|
||||
}
|
||||
|
||||
@ -91,12 +91,13 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
|
||||
//根据roleIds查询菜单
|
||||
@Override
|
||||
public List<SysPermission> getPermissionByRoleIds(List<Integer> roleIds) {
|
||||
public List<SysPermission> getPermissionByRoleIds(List<Integer> roleIds,String lang) {
|
||||
List<Integer> permissionIds = rolePermissionService.getPermissionIdsByRoles(roleIds);
|
||||
if (permissionIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryPermissionReqVo query = new QueryPermissionReqVo();
|
||||
query.setLang(lang);
|
||||
List<SysPermission> result = sysPermissionMapper.selectInfoByIds(query, permissionIds);
|
||||
return result;
|
||||
}
|
||||
@ -1120,21 +1121,21 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PermissionRespNode> getStationPer(Integer stationId, UserDetailRespVO user) {
|
||||
public List<PermissionRespNode> getStationPer(Integer stationId, UserDetailRespVO user,String lang) {
|
||||
List<SysPermission> list = new ArrayList<>();
|
||||
//查询当前登录人所拥有的菜单
|
||||
List<Integer> roleIds = user.getRoleIds();
|
||||
List<SysPermission> userPermissions = new ArrayList<>();
|
||||
if (!roleIds.isEmpty()) {
|
||||
//到关联表中根据角色id 拿到对应的菜单id
|
||||
List<SysPermission> result = getPermissionByRoleIds(roleIds);
|
||||
List<SysPermission> result = getPermissionByRoleIds(roleIds,lang);
|
||||
List<Integer> perIds = result.stream().map(s -> {
|
||||
return s.getId();
|
||||
}
|
||||
).collect(Collectors.toList());
|
||||
// List<Integer> permissionIdsByRoles = rolePermissionService.getPermissionIdsByRoles(roleIds);
|
||||
//根据菜单Id拿到菜单列表
|
||||
List<SysPermission> sysPermissions = selectByIds(perIds);
|
||||
List<SysPermission> sysPermissions = selectByIds(perIds,lang);
|
||||
//过滤掉按钮类型的数据
|
||||
userPermissions = sysPermissions.stream().filter(s -> !s.getType().equals(CommonConstant.THREE)).collect(Collectors.toList());
|
||||
}
|
||||
@ -1147,7 +1148,7 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
}
|
||||
).collect(Collectors.toList());
|
||||
if (!perIds.isEmpty()) {
|
||||
permissions = selectByIds(perIds);
|
||||
permissions = selectByIds(perIds,lang);
|
||||
}
|
||||
if (permissions.isEmpty()) {
|
||||
list = userPermissions;
|
||||
@ -1178,8 +1179,8 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
return tree;
|
||||
}
|
||||
|
||||
private List<SysPermission> selectByIds(List<Integer> perIds){
|
||||
List<SysPermission> sysPermissions = sysPermissionMapper.selectByIds(perIds);
|
||||
private List<SysPermission> selectByIds(List<Integer> perIds,String lang){
|
||||
List<SysPermission> sysPermissions = sysPermissionMapper.selectByIds(perIds,lang);
|
||||
return sysPermissions;
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,13 +115,13 @@ public class UserServiceImpl implements UserService {
|
||||
private String env;
|
||||
|
||||
@Override
|
||||
public UserDetailRespVO yourSelfInfo(UserDetailRespVO user, boolean platSuper) {
|
||||
public UserDetailRespVO yourSelfInfo(UserDetailRespVO user, boolean platSuper,String lang) {
|
||||
if (user.getRoleIds() == null) {
|
||||
//该用户无有效角色
|
||||
throw new BusinessException(BaseResponseCode.USER_DOES_NOT_VALID_ROLE);
|
||||
}
|
||||
//根据RoleIds在sys_role_permission关联表中拿到 permission_id,在根据permission_id拿到菜单
|
||||
List<SysPermission> result = permissionService.getPermissionByRoleIds(user.getRoleIds());
|
||||
List<SysPermission> result = permissionService.getPermissionByRoleIds(user.getRoleIds(),lang);
|
||||
//将其组成树结构返回
|
||||
//全量的菜单集合
|
||||
List<SysPermission> permissions = new ArrayList<>();
|
||||
@ -890,7 +890,7 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
//非超管,查询角色该有的
|
||||
else {
|
||||
permissions = permissionService.getPermissionByRoleIds(roleIds);
|
||||
permissions = permissionService.getPermissionByRoleIds(roleIds,null);
|
||||
}
|
||||
if (permissions.isEmpty()) {
|
||||
userDetail.setMenuList(new ArrayList<>());
|
||||
@ -1115,7 +1115,7 @@ public class UserServiceImpl implements UserService {
|
||||
@Override
|
||||
public Map<String, String> checkSpecialUser() {
|
||||
Map<String,String> userMap = new HashMap<>();
|
||||
List<SysSubDict> sysSubDictList = dictService.selectSubDictByType(CommonConstant.SPECIAL_USER);
|
||||
List<SysSubDict> sysSubDictList = dictService.selectSubDictByType(CommonConstant.SPECIAL_USER,null);
|
||||
for (SysSubDict sysSub:sysSubDictList) {
|
||||
userMap.put(sysSub.getValue(),sysSub.getValue());
|
||||
}
|
||||
@ -1125,7 +1125,7 @@ public class UserServiceImpl implements UserService {
|
||||
@Override
|
||||
public Map<String, String> getSysSubDict(SysSubDictVO vo) {
|
||||
Map<String,String> userMap = new HashMap<>();
|
||||
List<SysSubDict> sysSubDictList = dictService.selectSubDictByType(vo.getType());
|
||||
List<SysSubDict> sysSubDictList = dictService.selectSubDictByType(vo.getType(),null);
|
||||
for (SysSubDict sysSub:sysSubDictList) {
|
||||
if(CommonConstant.ONE.equals(vo.getKeyVal())){
|
||||
userMap.put(sysSub.getLabel(),sysSub.getValue());
|
||||
|
||||
@ -20,4 +20,7 @@ public class DictTypeAndLabelReqVO {
|
||||
@ApiModelProperty(value = "字典value类型")
|
||||
@NotBlank(message = "字典value类型不能为空")
|
||||
private String value;
|
||||
|
||||
@ApiModelProperty(value = "中英切换")
|
||||
private String lang;
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ spring:
|
||||
server-addr: 127.0.0.1:8848
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://1.95.153.121:3306/user_center_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://1.95.170.86:3306/user_center_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||
username: user_center_db
|
||||
password: zzkj@688737
|
||||
druid:
|
||||
@ -38,21 +38,9 @@ spring:
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 3000ms #连接超时
|
||||
host: 1.95.153.121 #单机
|
||||
password: zzkj@688737
|
||||
host: 1.95.170.86 #单机
|
||||
password: 123456
|
||||
database: 0
|
||||
|
||||
#port: 6379 #端口
|
||||
#timeout: 5000ms #连接超时
|
||||
#host: 127.0.0.1 #单机
|
||||
#password:
|
||||
#database: 0
|
||||
#集群 真实环境开启
|
||||
# cluster:
|
||||
# nodes:
|
||||
# - 127.0.0.1:6379
|
||||
# - 127.0.0.1:6380
|
||||
# - 127.0.0.1:6381
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #连接池最大连接 默认8
|
||||
|
||||
66
user-service/src/main/resources/application-prod.yml
Normal file
66
user-service/src/main/resources/application-prod.yml
Normal file
@ -0,0 +1,66 @@
|
||||
#用户中心
|
||||
server:
|
||||
port: 8012
|
||||
servlet:
|
||||
context-path: /api
|
||||
|
||||
#swagger2配置
|
||||
swagger2:
|
||||
enable: true #开启标志 生产环境要关闭
|
||||
projectName: 云平台-用户中心-接口
|
||||
controllerPath: com.ho.user.controller
|
||||
|
||||
spring:
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
name: user-center
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.0.142:8848
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.0.236:3306/user_center_db?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||
username: user_center_db
|
||||
password: zzkj@688737
|
||||
druid:
|
||||
initialSize: 5
|
||||
minIdle: 5
|
||||
maxActive: 5
|
||||
keepAlive: true #保持长连接
|
||||
connection-error-retry-attempts: 3
|
||||
boot:
|
||||
admin:
|
||||
client:
|
||||
url: http://localhost:8019/boot
|
||||
#Redis
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 3000ms #连接超时
|
||||
host: 192.168.0.236 #单机
|
||||
password: zzkj@688737
|
||||
database: 0
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #连接池最大连接 默认8
|
||||
max-idle: 8 #连接池中最大空闲连接 默认8
|
||||
min-idle: 1 #连接池中最小空闲连接 默认0
|
||||
max-wait: 2000ms #连接池最大阻塞等待时间 使用负值表示没有限制
|
||||
|
||||
#jwt配置
|
||||
jwt:
|
||||
secretKey: 78944878877848fg)
|
||||
accessTokenExpireTime: PT2H
|
||||
refreshTokenExpireTime: PT8H
|
||||
refreshTokenExpireAppTime: P30D
|
||||
issuer: hocloudSystem
|
||||
|
||||
#加解密
|
||||
rsa:
|
||||
pubKey: 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuG6ZABNgLQCI9iVPDuJEb7xb5zR9UGKyKXshLuJFZxyNtaEzfpjSMqsshUYA1QpwUvkmZE0lcRE4F4QtZO9rDnH2PoW1FWRbjgg0+MKWOmZr9hSPKM/BIE+knTtTaj4/0TK7QwDd9q/QAIduC1hIyxIIkxfWx0gFuTnxui0waCwIDAQAB'
|
||||
privateKey: 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAK4bpkAE2AtAIj2JU8O4kRvvFvnNH1QYrIpeyEu4kVnHI21oTN+mNIyqyyFRgDVCnBS+SZkTSVxETgXhC1k72sOcfY+hbUVZFuOCDT4wpY6Zmv2FI8oz8EgT6SdO1NqPj/RMrtDAN32r9AAh24LWEjLEgiTF9bHSAW5OfG6LTBoLAgMBAAECgYA614NfXYO6galQzMmvewAnxa0pLYbqABDIDvJ4jN8qzV+OyVI5v81AwTQ3hXjkBygC5rCu+FKxyS/pUr5oIQ90vbKvy+kozg9l0qWHfa8XrfC+E36CVuDrZYdZzl0C6J6BoNB9osJJ6HCnMA7kWLRRwU5VJBsK8CmgcJlfHNH60QJBAPz4rZgqgor69SonHG4xjRz+u4QkXIP8I+lorBSFEuUF03u22Kcxz7mcOq63m8K+oc22ql0g8QNrq6YPrEgpAPMCQQCwMUQcdZLWJrRbHp1ZA3jbt4vYg7xb1LklAM6Qmz1R9xVY0itDMtFRSTlVnrbTPZ+rldrkLUOzLJwKLHniIQiJAkEAmfeBMKwu6Af2T8GePDNMf+lKmBLJfEtqUBW1JogYB+yT2yhelORsWbwMu2plExKTyHD1H9l812ghAOFpKkJKoQJBAJ7lz2dbIXHAtib3FTCR0Q1WGujI5bZrwg19DM2dM1AYZUgVQq73xY5pWyu8V2VqzfUQ0Le3mracJJ2IPuOQpwECQF/b7Tv3auIHRaO9AD7xWIOCMYGlKhqeheMZb/mDRHedsdRvigiojDaaFbtnkvXlRbWlkOu5P5GNDpv7EuPbUs8='
|
||||
|
||||
phone:
|
||||
regexp: ^[1][3,4,5,6,7,8,9][0-9]{9}$
|
||||
|
||||
@ -9,9 +9,9 @@
|
||||
</appender>
|
||||
|
||||
<appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/user-center/user-center.log</file>
|
||||
<file>/www/zzkjcloud/logs/user-center/user-center.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/user-center/user-center.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>/www/zzkjcloud/logs/user-center/user-center.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>10</maxHistory>
|
||||
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,
|
||||
@ -27,9 +27,9 @@
|
||||
</appender>
|
||||
|
||||
<appender name="errorFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/user-center/user-center-error.log</file>
|
||||
<file>/www/zzkjcloud/logs/user-center/user-center-error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/user-center/user-center-error.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>//www/zzkjcloud/logs/user-center/user-center-error.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>10</maxHistory>
|
||||
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始,
|
||||
|
||||
@ -9,6 +9,9 @@
|
||||
<sql id="Base_Column_DictSubList">
|
||||
id,label, type,`value`, sort, `desc`,create_time, update_time, deleted
|
||||
</sql>
|
||||
<sql id="Base_Column_DictSubList1">
|
||||
id,label_en label, type,`value`, sort, `desc`,create_time, update_time, deleted
|
||||
</sql>
|
||||
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultType="com.ho.user.entity.SysDict">
|
||||
select
|
||||
@ -81,7 +84,14 @@
|
||||
|
||||
<select id="selectSubDictByType" resultType="com.ho.user.api.entity.SysSubDict">
|
||||
select
|
||||
<include refid="Base_Column_DictSubList"/>
|
||||
<choose>
|
||||
<when test="lang != null and lang=='en_US' ">
|
||||
<include refid="Base_Column_DictSubList1"></include>
|
||||
</when>
|
||||
<otherwise>
|
||||
<include refid="Base_Column_DictSubList"></include>
|
||||
</otherwise>
|
||||
</choose>
|
||||
from sys_sub_dict
|
||||
where
|
||||
type = #{type}
|
||||
|
||||
@ -8,6 +8,12 @@
|
||||
update_time, deleted, `scope`,is_config ,component, menu_name
|
||||
</sql>
|
||||
|
||||
<sql id="Base_Column_List1">
|
||||
id
|
||||
, code, name_en name, perms, url,url_app, icon, icon_app,`method`, pid, order_num, `type`,`show`, color, `status`, create_time,
|
||||
update_time, deleted, `scope`,is_config ,component, menu_name
|
||||
</sql>
|
||||
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer"
|
||||
resultType="com.ho.common.tools.entity.SysPermission">
|
||||
select
|
||||
@ -278,7 +284,14 @@
|
||||
|
||||
<select id="selectInfoByIds" resultType="com.ho.common.tools.entity.SysPermission">
|
||||
select
|
||||
<include refid="Base_Column_List"></include>
|
||||
<choose>
|
||||
<when test="query.lang != null and query.lang=='en_US' ">
|
||||
<include refid="Base_Column_List1"></include>
|
||||
</when>
|
||||
<otherwise>
|
||||
<include refid="Base_Column_List"></include>
|
||||
</otherwise>
|
||||
</choose>
|
||||
from sys_permission
|
||||
<where>
|
||||
and deleted = 1
|
||||
@ -408,7 +421,14 @@
|
||||
|
||||
<select id="selectByIds" resultType="com.ho.common.tools.entity.SysPermission">
|
||||
select
|
||||
<include refid="Base_Column_List"></include>
|
||||
<choose>
|
||||
<when test="lang != null and lang=='en_US' ">
|
||||
<include refid="Base_Column_List1"></include>
|
||||
</when>
|
||||
<otherwise>
|
||||
<include refid="Base_Column_List"></include>
|
||||
</otherwise>
|
||||
</choose>
|
||||
from sys_permission
|
||||
<where>
|
||||
<if test="ids != null and ids.size != 0">
|
||||
|
||||
@ -26,7 +26,7 @@ mybatis.mapper-locations=classpath:/mybatis-mapper/*Mapper.xml
|
||||
#mybatis.type-aliases-package=com.xxl.job.admin.core.model
|
||||
|
||||
### xxl-job, datasource
|
||||
spring.datasource.url=jdbc:mysql://1.95.153.121:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
|
||||
spring.datasource.url=jdbc:mysql://1.95.170.86:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
|
||||
spring.datasource.username=xxl_job
|
||||
spring.datasource.password=zzkj@688737
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
|
||||
67
xxl-job-admin/src/main/resources/application-prod.properties
Normal file
67
xxl-job-admin/src/main/resources/application-prod.properties
Normal file
@ -0,0 +1,67 @@
|
||||
### web
|
||||
server.port=8015
|
||||
server.servlet.context-path=/job-admin
|
||||
|
||||
### actuator
|
||||
management.server.servlet.context-path=/actuator
|
||||
management.health.mail.enabled=false
|
||||
|
||||
spring.application.name=xxl-job-admin
|
||||
###nacos
|
||||
spring.cloud.nacos.discovery.server-addr=192.168.0.142:8848
|
||||
### resources
|
||||
spring.mvc.servlet.load-on-startup=0
|
||||
spring.mvc.static-path-pattern=/static/**
|
||||
spring.resources.static-locations=classpath:/static/
|
||||
|
||||
### freemarker
|
||||
spring.freemarker.templateLoaderPath=classpath:/templates/
|
||||
spring.freemarker.suffix=.ftl
|
||||
spring.freemarker.charset=UTF-8
|
||||
spring.freemarker.request-context-attribute=request
|
||||
spring.freemarker.settings.number_format=0.##########
|
||||
|
||||
### mybatis
|
||||
mybatis.mapper-locations=classpath:/mybatis-mapper/*Mapper.xml
|
||||
#mybatis.type-aliases-package=com.xxl.job.admin.core.model
|
||||
|
||||
### xxl-job, datasource
|
||||
spring.datasource.url=jdbc:mysql://192.168.0.236:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
|
||||
spring.datasource.username=xxl_job
|
||||
spring.datasource.password=zzkj@688737
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
|
||||
### datasource-pool
|
||||
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
|
||||
spring.datasource.hikari.minimum-idle=10
|
||||
spring.datasource.hikari.maximum-pool-size=30
|
||||
spring.datasource.hikari.auto-commit=true
|
||||
spring.datasource.hikari.idle-timeout=30000
|
||||
spring.datasource.hikari.pool-name=HikariCP
|
||||
spring.datasource.hikari.max-lifetime=900000
|
||||
spring.datasource.hikari.connection-timeout=10000
|
||||
spring.datasource.hikari.connection-test-query=SELECT 1
|
||||
|
||||
### xxl-job, email
|
||||
spring.mail.host=smtp.qq.com
|
||||
spring.mail.port=25
|
||||
spring.mail.username=xxx@qq.com
|
||||
spring.mail.password=xxx
|
||||
spring.mail.properties.mail.smtp.auth=true
|
||||
spring.mail.properties.mail.smtp.starttls.enable=true
|
||||
spring.mail.properties.mail.smtp.starttls.required=true
|
||||
spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
|
||||
|
||||
### xxl-job, access token
|
||||
xxl.job.accessToken=
|
||||
|
||||
### xxl-job, i18n (default is zh_CN, and you can choose "zh_CN", "zh_TC" and "en")
|
||||
xxl.job.i18n=zh_CN
|
||||
|
||||
## xxl-job, triggerpool max size
|
||||
xxl.job.triggerpool.fast.max=200
|
||||
xxl.job.triggerpool.slow.max=100
|
||||
|
||||
### xxl-job, log retention days
|
||||
xxl.job.logretentiondays=30
|
||||
|
||||
@ -231,4 +231,55 @@ public class JobHandler {
|
||||
log.info("jobUpdateMessageInfo end !");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 寄点-站点监控数据
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@XxlJob("jobCacheShipEnergyMainInfo")
|
||||
public ReturnT<String> jobCacheShipEnergyMainInfo(String param){
|
||||
log.info("jobCacheShipEnergyMainInfo start !");
|
||||
businessFeignClient.jobCacheShipEnergyMainInfo();
|
||||
log.info("jobCacheShipEnergyMainInfo end !");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 寄点-站点充放电数据
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@XxlJob("jobCacheShipEleIncome")
|
||||
public ReturnT<String> jobCacheShipEleIncome(String param){
|
||||
log.info("jobCacheShipEnergyEle start !");
|
||||
businessFeignClient.jobCacheShipEleIncome(param);
|
||||
log.info("jobCacheShipEnergyEle end !");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
/**
|
||||
* 中车-站点收益、充放电数据 - 昨日
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@XxlJob("jobBoulderEleIncome")
|
||||
public ReturnT<String> jobBoulderEleIncome(String param){
|
||||
log.info("jobCacheShipEnergyEle start !");
|
||||
businessFeignClient.jobBoulderEleIncome(param);
|
||||
log.info("jobCacheShipEnergyEle end !");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 中车-站点收益、充放电数据 - 今日
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@XxlJob("jobBoulderEleIncomeToday")
|
||||
public ReturnT<String> jobBoulderEleIncomeToday(String param){
|
||||
log.info("jobCacheShipEnergyEle start !");
|
||||
businessFeignClient.jobBoulderEleIncome(DateUtil.formatDate(new Date()));
|
||||
log.info("jobCacheShipEnergyEle end !");
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,4 +67,13 @@ public interface BusinessFeignClient {
|
||||
@PostMapping(value = ContextConstant.ROOT_CONTEXT + ContextConstant.BUSINESS + "messageInfo/jobUpdateMessageInfo")
|
||||
void jobUpdateMessageInfo();
|
||||
|
||||
@PostMapping(value = ContextConstant.ROOT_CONTEXT + ContextConstant.BUSINESS + "shipEnergyStation/getMainTotal")
|
||||
void jobCacheShipEnergyMainInfo();
|
||||
|
||||
@PostMapping(value = ContextConstant.ROOT_CONTEXT + ContextConstant.BUSINESS + "shipEnergyStation/getStationIncomeHis")
|
||||
void jobCacheShipEleIncome(@RequestBody String dateTime);
|
||||
|
||||
@PostMapping(value = ContextConstant.ROOT_CONTEXT + ContextConstant.BUSINESS + "boulderEnergyStation/getBoulderEleIncome")
|
||||
void jobBoulderEleIncome(@RequestBody String dateTime);
|
||||
|
||||
}
|
||||
|
||||
@ -99,4 +99,22 @@ public class BusinessFeignClientFallback implements BusinessFeignClient {
|
||||
throw new BusinessException(BaseResponseCode.FEIGN_CALL_FAIL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jobCacheShipEnergyMainInfo() {
|
||||
log.error("BusinessFeignClient.jobCacheShipEnergyMainInfo error!");
|
||||
throw new BusinessException(BaseResponseCode.FEIGN_CALL_FAIL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jobCacheShipEleIncome(String dateTime) {
|
||||
log.error("BusinessFeignClient.jobCacheShipEleIncome error!");
|
||||
throw new BusinessException(BaseResponseCode.FEIGN_CALL_FAIL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jobBoulderEleIncome(String dateTime) {
|
||||
log.error("BusinessFeignClient.jobBoulderEleIncome error!");
|
||||
throw new BusinessException(BaseResponseCode.FEIGN_CALL_FAIL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -14,21 +14,9 @@ spring:
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 3000ms #连接超时
|
||||
host: 1.95.153.121 #单机
|
||||
password: zzkj@688737
|
||||
host: 1.95.170.86 #单机
|
||||
password: 123456
|
||||
database: 0
|
||||
|
||||
#port: 6379 #端口
|
||||
#timeout: 5000ms #连接超时
|
||||
#host: 127.0.0.1 #单机
|
||||
#password:
|
||||
#database: 0
|
||||
#集群 真实环境开启
|
||||
# record:
|
||||
# nodes:
|
||||
# - 127.0.0.1:6379
|
||||
# - 127.0.0.1:6380
|
||||
# - 127.0.0.1:6381
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #连接池最大连接 默认8
|
||||
@ -45,6 +33,6 @@ xxl:
|
||||
address:
|
||||
ip: 127.0.0.1
|
||||
port: 9999
|
||||
logpath: /home/hocloud/logs/xxl-job/
|
||||
logpath: /www/zzkjcloud/logs/xxl-job/
|
||||
logretentiondays: 30
|
||||
|
||||
|
||||
38
xxl-job/src/main/resources/application-prod.yml
Normal file
38
xxl-job/src/main/resources/application-prod.yml
Normal file
@ -0,0 +1,38 @@
|
||||
server:
|
||||
port: 8016
|
||||
|
||||
spring:
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
name: xxl-job
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.0.142:8848
|
||||
#Redis
|
||||
redis:
|
||||
port: 6379 #端口
|
||||
timeout: 3000ms #连接超时
|
||||
host: 192.168.0.236 #单机
|
||||
password: zzkj@688737
|
||||
database: 0
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #连接池最大连接 默认8
|
||||
max-idle: 8 #连接池中最大空闲连接 默认8
|
||||
min-idle: 1 #连接池中最小空闲连接 默认0
|
||||
max-wait: 2000ms #连接池最大阻塞等待时间 使用负值表示没有限制
|
||||
xxl:
|
||||
job:
|
||||
admin:
|
||||
addresses: http://127.0.0.1:8015/job-admin
|
||||
accessToken:
|
||||
executor:
|
||||
appname: job-executor-sample
|
||||
address:
|
||||
ip: 127.0.0.1
|
||||
port: 9999
|
||||
logpath: /home/hocloud/logs/xxl-job/
|
||||
logretentiondays: 30
|
||||
|
||||
@ -9,9 +9,9 @@
|
||||
</appender>
|
||||
|
||||
<appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/xxl-job/xxl-job.log</file>
|
||||
<file>/www/zzkjcloud/logs/xxl-job/xxl-job.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/xxl-job/xxl-job.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>/www/zzkjcloud/logs/xxl-job/xxl-job.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<!--180天-->
|
||||
<maxHistory>10</maxHistory>
|
||||
@ -29,9 +29,9 @@
|
||||
|
||||
<!--Error级别-->
|
||||
<appender name="errorFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>/home/hocloud/logs/xxl-job/xxl-job-error.log</file>
|
||||
<file>/www/zzkjcloud/logs/xxl-job/xxl-job-error.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>/home/hocloud/logs/xxl-job/xxl-job-error.%d{yyyy-MM-dd}-%i.log
|
||||
<fileNamePattern>/www/zzkjcloud/logs/xxl-job/xxl-job-error.%d{yyyy-MM-dd}-%i.log
|
||||
</fileNamePattern>
|
||||
<!--180天-->
|
||||
<maxHistory>10</maxHistory>
|
||||
|
||||
Reference in New Issue
Block a user