Commit 79288489 authored by tangwei's avatar tangwei

修改bug

parent 82b2fa84
...@@ -51,6 +51,7 @@ public class MetaHandler implements MetaObjectHandler { ...@@ -51,6 +51,7 @@ public class MetaHandler implements MetaObjectHandler {
// if(metaObject.getValue("createDate")==null){ // if(metaObject.getValue("createDate")==null){
// } // }
this.setFieldValByName("createDate", currentDate, metaObject); this.setFieldValByName("createDate", currentDate, metaObject);
this.setFieldValByName("recDate", currentDate, metaObject);
} }
private void autoFillUser(MetaObject metaObject, Object entity) { private void autoFillUser(MetaObject metaObject, Object entity) {
......
...@@ -145,6 +145,7 @@ public class ImasterUtils { ...@@ -145,6 +145,7 @@ public class ImasterUtils {
} }
} }
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace();
return result; return result;
} }
return result; return result;
......
...@@ -10,7 +10,7 @@ public class ImasterConstant { ...@@ -10,7 +10,7 @@ public class ImasterConstant {
public static final HashMap<String, String> stationStaus = new HashMap<String, String>() { public static final HashMap<String, String> stationStaus = new HashMap<String, String>() {
{ {
put("1", "离线"); put("1", "离线");
put("2", "警"); put("2", "警");
put("3", "在线"); put("3", "在线");
} }
}; };
......
...@@ -174,6 +174,17 @@ public class ImasterDataServiceImpl implements ImasterDataService { ...@@ -174,6 +174,17 @@ public class ImasterDataServiceImpl implements ImasterDataService {
ImasterStationDetailsYear.class ImasterStationDetailsYear.class
); );
List<ImasterInverterListDetails> result4 = imasterUtils.getResPonseOther(ImasterConstant.collectorDetailUrl,
GoLangConstant.requestPost,
requestParaminfo,
ImasterConstant.resovleRule_data_page_records,
ImasterInverterListDetails.class
);
for (int j = 0; j < result.size(); j++) { for (int j = 0; j < result.size(); j++) {
QueryWrapper<ImasterStationList> queryWrapper = new QueryWrapper<>(); QueryWrapper<ImasterStationList> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("plant_code", result.get(j).getStationCode()); queryWrapper.eq("plant_code", result.get(j).getStationCode());
...@@ -203,7 +214,7 @@ public class ImasterDataServiceImpl implements ImasterDataService { ...@@ -203,7 +214,7 @@ public class ImasterDataServiceImpl implements ImasterDataService {
jpStation.setOnGridType("自发自用"); jpStation.setOnGridType("自发自用");
//jpStation.setOnGridTime(new Date("2023-05-22")); //jpStation.setOnGridTime(new Date("2023-05-22"));
// jpStation.setRealTimePower(); // jpStation.setRealTimePower();
jpStation.setCumulativeIncome(imasterStationDetail.getTotal_income());
jpStation.setPrice(0.45); jpStation.setPrice(0.45);
jpStation.setRatedPower(100D); jpStation.setRatedPower(100D);
jpStation.setStationContact(imasterStationList.getContactPerson()); jpStation.setStationContact(imasterStationList.getContactPerson());
...@@ -249,7 +260,19 @@ public class ImasterDataServiceImpl implements ImasterDataService { ...@@ -249,7 +260,19 @@ public class ImasterDataServiceImpl implements ImasterDataService {
} }
} }
//实时功率
Double active_power=0.0;
for (ImasterInverterListDetails imasterInverterListDetails : result4) {
active_power=active_power+ (imasterInverterListDetails.getActive_power()!=null?imasterInverterListDetails.getActive_power():0.0);
}
jpStation.setRealTimePower(active_power);
jpStation.setAccumulatedPower(imasterStationDetail.getTotal_power()); jpStation.setAccumulatedPower(imasterStationDetail.getTotal_power());
jpStation.setCumulativeIncome(imasterStationDetail.getTotal_power()!=null?imasterStationDetail.getTotal_power()*0.45:0.0);
jpStation.setDayIncome(imasterStationDetail.getDay_income()); jpStation.setDayIncome(imasterStationDetail.getDay_income());
jpStation.setCumulativeIncome(imasterStationDetail.getTotal_income()); jpStation.setCumulativeIncome(imasterStationDetail.getTotal_income());
jpStation.setState(ImasterConstant.stationStaus.get(String.valueOf(imasterStationDetail.getReal_health_state()))); jpStation.setState(ImasterConstant.stationStaus.get(String.valueOf(imasterStationDetail.getReal_health_state())));
...@@ -287,7 +310,9 @@ public class ImasterDataServiceImpl implements ImasterDataService { ...@@ -287,7 +310,9 @@ public class ImasterDataServiceImpl implements ImasterDataService {
hygfjpDayPower.setTationId(imasterStationList.getPlantCode()); hygfjpDayPower.setTationId(imasterStationList.getPlantCode());
hygfjpDayPower.setHour(hour); hygfjpDayPower.setHour(hour);
hygfjpDayPower.setYearMonthDay(today); hygfjpDayPower.setYearMonthDay(today);
// hygfjpDayPower.setPower(imasterStationDetail.getPower());
hygfjpDayPower.setPower(active_power);
if (ObjectUtils.isEmpty(hygfjpDayPower.getCreatedTime())) { if (ObjectUtils.isEmpty(hygfjpDayPower.getCreatedTime())) {
hygfjpDayPower.setCreatedTime(System.currentTimeMillis()); hygfjpDayPower.setCreatedTime(System.currentTimeMillis());
hygfjpDayPowerMapper.insert(hygfjpDayPower); hygfjpDayPowerMapper.insert(hygfjpDayPower);
...@@ -463,9 +488,15 @@ public class ImasterDataServiceImpl implements ImasterDataService { ...@@ -463,9 +488,15 @@ public class ImasterDataServiceImpl implements ImasterDataService {
ImasterConstant.resovleRule_data_page_records, ImasterConstant.resovleRule_data_page_records,
ImasterInverterYear.class ImasterInverterYear.class
); );
Double active_power=0.0;
String third_station_id=null;
for (int j = 0; j < result.size(); j++) { for (int j = 0; j < result.size(); j++) {
ImasterInverterListDetails inverterDetailDto = result.get(j); ImasterInverterListDetails inverterDetailDto = result.get(j);
active_power=active_power+ (inverterDetailDto.getActive_power()!=null?inverterDetailDto.getActive_power():0.0);
//获取所有逆变器实时功率总和
inverterDetailDto.setCreatedTime((System.currentTimeMillis())); inverterDetailDto.setCreatedTime((System.currentTimeMillis()));
imasterInverterListDetailsMapper.insert(result.get(j)); imasterInverterListDetailsMapper.insert(result.get(j));
...@@ -474,7 +505,7 @@ public class ImasterDataServiceImpl implements ImasterDataService { ...@@ -474,7 +505,7 @@ public class ImasterDataServiceImpl implements ImasterDataService {
queryWrapper.orderByDesc("created_time"); queryWrapper.orderByDesc("created_time");
List<ImasterInverterList> imasterInverterLists = imasterInverterListMapper.selectList(queryWrapper); List<ImasterInverterList> imasterInverterLists = imasterInverterListMapper.selectList(queryWrapper);
ImasterInverterList imasterInverterList = imasterInverterLists.get(0); ImasterInverterList imasterInverterList = imasterInverterLists.get(0);
third_station_id=imasterInverterList.getStationCode();
QueryWrapper<ImasterCollectorList> queryWrapper1 = new QueryWrapper<>(); QueryWrapper<ImasterCollectorList> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.eq("dev_name", imasterInverterList.getDevName()); queryWrapper1.eq("dev_name", imasterInverterList.getDevName());
queryWrapper1.orderByDesc("created_time"); queryWrapper1.orderByDesc("created_time");
...@@ -495,6 +526,8 @@ public class ImasterDataServiceImpl implements ImasterDataService { ...@@ -495,6 +526,8 @@ public class ImasterDataServiceImpl implements ImasterDataService {
jpInverter.setDayPowerGeneration(inverterDetailDto.getDay_cap() ); jpInverter.setDayPowerGeneration(inverterDetailDto.getDay_cap() );
jpInverter.setState(ImasterConstant.inverterStaus.get(String.valueOf(inverterDetailDto.getRun_state()))); jpInverter.setState(ImasterConstant.inverterStaus.get(String.valueOf(inverterDetailDto.getRun_state())));
jpInverter.setTotalPowerGeneration(inverterDetailDto.getTotal_cap()); jpInverter.setTotalPowerGeneration(inverterDetailDto.getTotal_cap());
jpInverter.setCurrentPower(inverterDetailDto.getActive_power());
Long currentTime = System.currentTimeMillis(); Long currentTime = System.currentTimeMillis();
Long monthStart = CalendarAdjust.getMonthStartTime(currentTime, "GMT+8:00"); Long monthStart = CalendarAdjust.getMonthStartTime(currentTime, "GMT+8:00");
...@@ -675,6 +708,8 @@ public class ImasterDataServiceImpl implements ImasterDataService { ...@@ -675,6 +708,8 @@ public class ImasterDataServiceImpl implements ImasterDataService {
hygfjpInverterHistoryMapper.insert(hygfjpInverterHistory); hygfjpInverterHistoryMapper.insert(hygfjpInverterHistory);
} }
} }
} }
......
...@@ -171,7 +171,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -171,7 +171,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
// 业主姓名 // 业主姓名
jpStation.setUserName(ksolarStation.getUserName()); jpStation.setUserName(ksolarStation.getUserName());
jpStation.setState(KSolarConstant.collectStaus.get(String.valueOf(ksolarStation.getStatus()))); jpStation.setState(KSolarConstant.collectStaus.get(String.valueOf(ksolarStation.getStatus())));
jpStation.setRealTimePower(ksolarStation.getPowerInter()); jpStation.setRealTimePower(ksolarStation.getPowerInter()!=null?ksolarStation.getPowerInter()/1000000:0.0);
jpStation.setDayGenerate(ksolarStation.getDayGeneration()); jpStation.setDayGenerate(ksolarStation.getDayGeneration());
jpStation.setAccumulatedPower(ksolarStation.getTotalGeneration()); jpStation.setAccumulatedPower(ksolarStation.getTotalGeneration());
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
SELECT SELECT
avg(power) power, avg(power) power,
third_station_id thirdStationId third_station_id thirdStationId
FROM house_pv_data.td_hygf_jp_station_power_history where created_time <![CDATA[>=]]> today()-8h and created_time <![CDATA[<]]> today()+1d-8h GROUP BY third_station_id FROM house_pv_data.td_hygf_jp_station_power_history where created_time <![CDATA[>=]]> today()-1d-8h and created_time <![CDATA[<]]> today()-8h GROUP BY third_station_id
</select> </select>
......
...@@ -2,7 +2,15 @@ ...@@ -2,7 +2,15 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.TdHygfJpInverterHistoryMapper"> <mapper namespace="com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.TdHygfJpInverterHistoryMapper">
<select id="sum" resultType="Map"> <select id="sum" resultType="Map">
SELECT sum(power_generation) AS power,sum(daily_return) AS dailyReturn,sum(generation_hours) AS hours FROM house_pv_data.td_hygf_jp_inverter_history SELECT
sum(power_generation) AS power,
sum(daily_return) AS dailyReturn,
sum(generation_hours) AS hours
FROM house_pv_data.td_hygf_jp_inverter_history
<where> <where>
<if test="snCode!=null"> <if test="snCode!=null">
AND `sn_code` = #{snCode} AND `sn_code` = #{snCode}
......
...@@ -25,6 +25,7 @@ import org.springframework.core.env.Environment; ...@@ -25,6 +25,7 @@ import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
import java.net.InetAddress; import java.net.InetAddress;
...@@ -57,6 +58,7 @@ public class AmosHygfApplication { ...@@ -57,6 +58,7 @@ public class AmosHygfApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
ConfigurableApplicationContext context = SpringApplication.run(AmosHygfApplication.class, args); ConfigurableApplicationContext context = SpringApplication.run(AmosHygfApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment(); Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress(); String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port"); String port = env.getProperty("server.port");
......
...@@ -9,6 +9,8 @@ import io.swagger.annotations.ApiOperation; ...@@ -9,6 +9,8 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -106,7 +108,18 @@ public class JpCollectorController extends BaseController { ...@@ -106,7 +108,18 @@ public class JpCollectorController extends BaseController {
LambdaQueryWrapper<JpInverter> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<JpInverter> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JpInverter::getCollectorSnCode, jpCollectorDto.getSnCode()); queryWrapper.eq(JpInverter::getCollectorSnCode, jpCollectorDto.getSnCode());
List<JpInverter> list = jpInverterServiceImpl.list(queryWrapper); List<JpInverter> list = jpInverterServiceImpl.list(queryWrapper);
jpCollectorDto.setJpInverters(list); List<JpInverter> listData =new ArrayList<>();
for (JpInverter jpInverter : list) {
jpInverter.setDayPowerGeneration(jpInverter.getDayPowerGeneration()!=null?jpInverter.getDayPowerGeneration()/1000:0);
jpInverter.setMonthPowerGeneration(jpInverter.getMonthPowerGeneration()!=null?jpInverter.getMonthPowerGeneration()/1000:0);
jpInverter.setYearPowerGeneration(jpInverter.getYearPowerGeneration()!=null?jpInverter.getYearPowerGeneration()/1000:0);
jpInverter.setTotalPowerGeneration(jpInverter.getTotalPowerGeneration()!=null?jpInverter.getTotalPowerGeneration()/1000:0);
listData.add(jpInverter);
}
jpCollectorDto.setJpInverters(listData);
return ResponseHelper.buildResponse(jpCollectorDto); return ResponseHelper.buildResponse(jpCollectorDto);
} }
......
...@@ -95,7 +95,12 @@ public class JpInverterController extends BaseController { ...@@ -95,7 +95,12 @@ public class JpInverterController extends BaseController {
@GetMapping(value = "/{sequenceNbr}") @GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个户用光伏监盘逆变器表", notes = "根据sequenceNbr查询单个户用光伏监盘逆变器表") @ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个户用光伏监盘逆变器表", notes = "根据sequenceNbr查询单个户用光伏监盘逆变器表")
public ResponseModel<JpInverterDto> selectOne(@PathVariable Long sequenceNbr) { public ResponseModel<JpInverterDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(jpInverterServiceImpl.queryBySeq(sequenceNbr)); JpInverterDto jpInverter= jpInverterServiceImpl.queryBySeq(sequenceNbr);
jpInverter.setDayPowerGeneration(jpInverter.getDayPowerGeneration()!=null?jpInverter.getDayPowerGeneration()/1000:0);
jpInverter.setMonthPowerGeneration(jpInverter.getMonthPowerGeneration()!=null?jpInverter.getMonthPowerGeneration()/1000:0);
jpInverter.setYearPowerGeneration(jpInverter.getYearPowerGeneration()!=null?jpInverter.getYearPowerGeneration()/1000:0);
jpInverter.setTotalPowerGeneration(jpInverter.getTotalPowerGeneration()!=null?jpInverter.getTotalPowerGeneration()/1000:0);
return ResponseHelper.buildResponse(jpInverter);
} }
/** /**
......
...@@ -14,8 +14,11 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -14,8 +14,11 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -55,16 +58,26 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower, ...@@ -55,16 +58,26 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower,
@Transactional @Transactional
public void getMonthPower() { public void getMonthPower() {
List<MonthPower> list= monthPowerMapper.getMonthPowerint(); List<MonthPower> list= monthPowerMapper.getMonthPowerint();
LocalDateTime now = LocalDateTime.now(); // LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatterday = DateTimeFormatter.ofPattern("YYYY-MM-dd"); Calendar cal = Calendar.getInstance();
String formattedDateday = now.format(formatterday); cal.add(Calendar.DATE, -1);
Date dayTime = cal.getTime();
// DateTimeFormatter formatterday = DateTimeFormatter.ofPattern("YYYY-MM-dd");
// String formattedDateday = now.format(formatterday);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("YYYY-MM-dd");
String formattedDateday =simpleDateFormat.format(dayTime);
LambdaQueryWrapper<MonthPower> wrapperday = new LambdaQueryWrapper<>(); LambdaQueryWrapper<MonthPower> wrapperday = new LambdaQueryWrapper<>();
wrapperday.eq(MonthPower::getDay, formattedDateday); wrapperday.eq(MonthPower::getDay, formattedDateday);
List<MonthPower> listdday= this.list(wrapperday); List<MonthPower> listdday= this.list(wrapperday);
if(listdday!=null&&!listdday.isEmpty()){ if(listdday!=null&&!listdday.isEmpty()){
for (MonthPower monthPower : list) { for (MonthPower monthPower : list) {
for (MonthPower power : listdday) { for (MonthPower power : listdday) {
if(monthPower.getThirdStationId().equals(power.getThirdStationId())){ if(monthPower.getThirdStationId().equals(power.getThirdStationId())
&&monthPower.getYearMonth().equals(power.getYearMonth())
&&monthPower.getDay().equals(power.getDay())
){
monthPower.setCreatedTime(power.getCreatedTime()); monthPower.setCreatedTime(power.getCreatedTime());
}else{ }else{
...@@ -76,8 +89,12 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower, ...@@ -76,8 +89,12 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower,
this.saveBatch(list); this.saveBatch(list);
} }
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("YYYY-MM"); // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("YYYY-MM");
String formattedDate = now.format(formatter); // String formattedDate = now.format(formatter);
SimpleDateFormat formatter = new SimpleDateFormat("YYYY-MM");
String formattedDate =formatter.format(dayTime);
List<YearPower> listd= monthPowerMapper.getSumMonthPower(formattedDate); List<YearPower> listd= monthPowerMapper.getSumMonthPower(formattedDate);
...@@ -87,7 +104,10 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower, ...@@ -87,7 +104,10 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower,
if(listdY!=null&&!listdY.isEmpty()){ if(listdY!=null&&!listdY.isEmpty()){
for (YearPower yearPower : listd) { for (YearPower yearPower : listd) {
for (YearPower power : listdY) { for (YearPower power : listdY) {
if(yearPower.getThirdStationId()!=null&&yearPower.getThirdStationId().equals(power.getThirdStationId())){ if(yearPower.getThirdStationId()!=null&&yearPower.getThirdStationId().equals(power.getThirdStationId())
&&yearPower.getYear().equals(power.getYear())
&&yearPower.getMonth().equals(power.getMonth())
){
//yearPower.setPower(power.getPower()); //yearPower.setPower(power.getPower());
yearPower.setCreatedTime(power.getCreatedTime()); yearPower.setCreatedTime(power.getCreatedTime());
} }
...@@ -98,8 +118,12 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower, ...@@ -98,8 +118,12 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower,
yearPowerServiceImpl.saveBatch(listd); yearPowerServiceImpl.saveBatch(listd);
} }
DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("YYYY"); // DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("YYYY");
String formattedDate1 = now.format(formatter1); // String formattedDate1 = now.format(formatter1);
SimpleDateFormat formatter1 = new SimpleDateFormat("YYYY");
String formattedDate1 =formatter1.format(dayTime);
List<AllPower> listdy= monthPowerMapper.getSumYearPower(formattedDate1); List<AllPower> listdy= monthPowerMapper.getSumYearPower(formattedDate1);
LambdaQueryWrapper<AllPower> wrapper1 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<AllPower> wrapper1 = new LambdaQueryWrapper<>();
...@@ -108,7 +132,9 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower, ...@@ -108,7 +132,9 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower,
if(listdall!=null&&!listdall.isEmpty()){ if(listdall!=null&&!listdall.isEmpty()){
for (AllPower yearPower : listdy) { for (AllPower yearPower : listdy) {
for (AllPower power : listdall) { for (AllPower power : listdall) {
if(yearPower.getThirdStationId()!=null&&yearPower.getThirdStationId().equals(power.getThirdStationId())){ if(yearPower.getThirdStationId()!=null&&yearPower.getThirdStationId().equals(power.getThirdStationId())
&&yearPower.getYear().equals(power.getYear())
){
// yearPower.setPower(power.getPower()); // yearPower.setPower(power.getPower());
yearPower.setCreatedTime(power.getCreatedTime()); yearPower.setCreatedTime(power.getCreatedTime());
} }
......
package com.yeejoin.amos.boot.module.hygf.biz.service.impl; package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
...@@ -59,6 +60,8 @@ public class TdHygfJpCollectorHistoryServiceImpl ...@@ -59,6 +60,8 @@ public class TdHygfJpCollectorHistoryServiceImpl
if (!list.isEmpty()) { if (!list.isEmpty()) {
list.forEach(i -> { list.forEach(i -> {
i.setTimeFormat(TimeUtil.minuteFormat(i.getTime())); i.setTimeFormat(TimeUtil.minuteFormat(i.getTime()));
i.setSignalStrength(i.getSignalStrength()==null?0D:i.getSignalStrength());
}); });
} }
return list; return list;
...@@ -117,6 +120,8 @@ public class TdHygfJpCollectorHistoryServiceImpl ...@@ -117,6 +120,8 @@ public class TdHygfJpCollectorHistoryServiceImpl
int day = cal.get(Calendar.DATE); int day = cal.get(Calendar.DATE);
int month = cal.get(Calendar.MONTH) + 1; int month = cal.get(Calendar.MONTH) + 1;
int year = cal.get(Calendar.YEAR); int year = cal.get(Calendar.YEAR);
// 月表 // 月表
List<Map<String, Object>> monthList = this.baseMapper.dayToMonth(TimeUtil.getStartTimeOfDay(dayTime), List<Map<String, Object>> monthList = this.baseMapper.dayToMonth(TimeUtil.getStartTimeOfDay(dayTime),
TimeUtil.getEndTimeOfDay(dayTime)); TimeUtil.getEndTimeOfDay(dayTime));
...@@ -134,7 +139,12 @@ public class TdHygfJpCollectorHistoryServiceImpl ...@@ -134,7 +139,12 @@ public class TdHygfJpCollectorHistoryServiceImpl
for (Map<String, Object> map : monthList) { for (Map<String, Object> map : monthList) {
for (JpCollectorHistoryMonthDto jpCollectorHistoryMonthDto : listold) { for (JpCollectorHistoryMonthDto jpCollectorHistoryMonthDto : listold) {
if(map.get("third_station_id").toString().equals(jpCollectorHistoryMonthDto.getThirdStationId())&&map.get("sn_code").toString().trim().equals(jpCollectorHistoryMonthDto.getSnCode().trim())&&map.get("day").toString().equals(jpCollectorHistoryMonthDto.getDay())){ if(map.get("third_station_id").toString().equals(jpCollectorHistoryMonthDto.getThirdStationId())
&&map.get("sn_code").toString().trim().equals(jpCollectorHistoryMonthDto.getSnCode().trim())
&&map.get("day").toString().equals(jpCollectorHistoryMonthDto.getDay())
&&map.get("year_month").toString().equals(jpCollectorHistoryMonthDto.getDay())
){
map.put("created_time",jpCollectorHistoryMonthDto.getCreatedTime()) ; map.put("created_time",jpCollectorHistoryMonthDto.getCreatedTime()) ;
} }
} }
......
package com.yeejoin.amos.boot.module.hygf.biz.service.impl; package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
...@@ -70,11 +71,70 @@ public class TdHygfJpInvertorElecHistoryServiceImpl extends ...@@ -70,11 +71,70 @@ public class TdHygfJpInvertorElecHistoryServiceImpl extends
String monthStr = String.valueOf(cal.get(Calendar.YEAR)) + "-" + String.valueOf(cal.get(Calendar.MONTH) + 1); String monthStr = String.valueOf(cal.get(Calendar.YEAR)) + "-" + String.valueOf(cal.get(Calendar.MONTH) + 1);
if (invertor != null) { if (invertor != null) {
List<JpInvertorElecHistoryMonthDto> li= this.baseMapper.monthList(invertor.getSnCode().trim(), invertor.getThirdStationId(), monthStr); List<JpInvertorElecHistoryMonthDto> li= this.baseMapper.monthList(invertor.getSnCode().trim(), invertor.getThirdStationId(), monthStr);
return li;
List<JpInvertorElecHistoryMonthDto> lidata=new ArrayList<>();
List<String> list= dayReport(month);
for (String s : list) {
JpInvertorElecHistoryMonthDto da=null;
for (JpInvertorElecHistoryMonthDto jpInvertorElecHistoryMonthDto : li) {
if(jpInvertorElecHistoryMonthDto.getDay().equals(s)){
da=jpInvertorElecHistoryMonthDto;
break;
}
}
if(da==null){
da=new JpInvertorElecHistoryMonthDto();
da.setDay(s);
da.setSnCode(invertor.getSnCode().trim());
da.setYearMonth(monthStr);
da.setUAcCurrent(0D);
da.setUAcVoltage(0D);
da.setVAcVoltage(0D);
da.setVAcCurrent(0D);
da.setWAcCurrent(0D);
da.setWAcVoltage(0D);
}
lidata.add(da) ;
}
return lidata;
} }
return new ArrayList<>(); return new ArrayList<>();
} }
public static List<String> dayReport(Date month) {
List<String> list=new ArrayList<>();
Calendar cal = Calendar.getInstance();
cal.setTime(month);//month 为指定月份任意日期
int year = cal.get(Calendar.YEAR);
int m = cal.get(Calendar.MONTH)+1;
int dayNumOfMonth = getDaysByYearMonth(year, m);
cal.set(Calendar.DAY_OF_MONTH, 1);// 从一号开始
for (int i = 0; i < dayNumOfMonth; i++ ) {
list.add(String.valueOf(i+1));
}
return list;
}
public static int getDaysByYearMonth(int year, int month) {
Calendar a = Calendar.getInstance();
a.set(Calendar.YEAR, year);
a.set(Calendar.MONTH, month - 1);
a.set(Calendar.DATE, 1);
a.roll(Calendar.DATE, -1);
int maxDate = a.get(Calendar.DATE);
return maxDate;
}
/** /**
* 列表查询 示例 * 列表查询 示例
*/ */
...@@ -84,7 +144,33 @@ public class TdHygfJpInvertorElecHistoryServiceImpl extends ...@@ -84,7 +144,33 @@ public class TdHygfJpInvertorElecHistoryServiceImpl extends
cal.setTime(year); cal.setTime(year);
String yearStr = String.valueOf(cal.get(Calendar.YEAR)); String yearStr = String.valueOf(cal.get(Calendar.YEAR));
if (invertor != null) { if (invertor != null) {
return this.baseMapper.yearList(invertor.getSnCode().trim(), invertor.getThirdStationId(), yearStr); List<JpInvertorElecHistoryYearDto> list=this.baseMapper.yearList(invertor.getSnCode().trim(), invertor.getThirdStationId(), yearStr);
List<JpInvertorElecHistoryYearDto> lidata=new ArrayList<>();
for (int i = 1; i < 13; i++) {
JpInvertorElecHistoryYearDto da=null;
for (JpInvertorElecHistoryYearDto jpInvertorElecHistoryYearDto : list) {
if(jpInvertorElecHistoryYearDto.getMonth().equals(String.valueOf(i))){
da=jpInvertorElecHistoryYearDto;
break;
}
}
if(da==null){
da=new JpInvertorElecHistoryYearDto();
da.setMonth(String.valueOf(i));
da.setSnCode(invertor.getSnCode().trim());
da.setYear(yearStr);
da.setUAcCurrent(0D);
da.setUAcVoltage(0D);
da.setVAcVoltage(0D);
da.setVAcCurrent(0D);
da.setWAcCurrent(0D);
da.setWAcVoltage(0D);
}
lidata.add(da) ;
}
return lidata;
} }
return new ArrayList<>(); return new ArrayList<>();
} }
...@@ -96,7 +182,35 @@ public class TdHygfJpInvertorElecHistoryServiceImpl extends ...@@ -96,7 +182,35 @@ public class TdHygfJpInvertorElecHistoryServiceImpl extends
JpInverter invertor = jpInvertorServiceImpl.getById(id); JpInverter invertor = jpInvertorServiceImpl.getById(id);
if (invertor != null) { if (invertor != null) {
return this.baseMapper.allList(invertor.getSnCode().trim(), invertor.getThirdStationId()); List<JpInvertorElecHistoryAllDto> li= this.baseMapper.allList(invertor.getSnCode().trim(), invertor.getThirdStationId());
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
int monthStr = cal.get(Calendar.YEAR);
List<JpInvertorElecHistoryAllDto> lidata=new ArrayList<>();
for (int i = monthStr-5; i < monthStr+1; i++) {
JpInvertorElecHistoryAllDto da=null;
for (JpInvertorElecHistoryAllDto jpInvertorElecHistoryAllDto : li) {
if(jpInvertorElecHistoryAllDto.getYear().equals(String.valueOf(i))){
da=jpInvertorElecHistoryAllDto;
break;
}
}
if(da==null){
da=new JpInvertorElecHistoryAllDto();
da.setYear(String.valueOf(i));
da.setSnCode(invertor.getSnCode().trim());
da.setUAcCurrent(0D);
da.setUAcVoltage(0D);
da.setVAcVoltage(0D);
da.setVAcCurrent(0D);
da.setWAcCurrent(0D);
da.setWAcVoltage(0D);
}
lidata.add(da) ;
}
return lidata;
} }
return new ArrayList<>(); return new ArrayList<>();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment