Commit 238f5f42 authored by wujiang's avatar wujiang

Merge branch 'developer' of http://39.98.45.134:8090/moa/amos-boot-biz into developer

parents f86d0e7e 6056d9dd
......@@ -60,11 +60,11 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
map= gethourList();
data =monthPowerMapper.getDayPowercount(date, statioId);
}else if(type.equals("month")){
map= getDayListOfMonth();
map= getDayListOfMonth(date);
data=monthPowerMapper.getMonthPower(date, statioId);
}else if(type.equals("year")){
map= getyearListOfMonth();
map= getyearListOfMonth(date);
data= monthPowerMapper.getYearPower(date,statioId);
}else{
map= getyearList();
......@@ -105,31 +105,36 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
public static Map<String, List<Object>> getDayListOfMonth() {
public static Map<String, List<Object>> getDayListOfMonth(String date) {
Map<String, List<Object>> map =new HashMap<>();
List<Object> listx =new ArrayList<>();
List<Object> listy =new ArrayList<>();
Calendar aCalendar = Calendar.getInstance(Locale.CHINA);
int year = aCalendar.get(Calendar.YEAR);//年份
int month = aCalendar.get(Calendar.MONTH) + 1;//月份
int day = aCalendar.getActualMaximum(Calendar.DATE);
for (int i = 1; i <= day; i++) {
String aDate = month+"-"+i;
listx.add(aDate);
listy.add(0);
try {
List<Object> listx =new ArrayList<>();
List<Object> listy =new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
Date dat = sdf.parse(date);
Calendar aCalendar = Calendar.getInstance();
aCalendar.setTime(dat);
int month = aCalendar.get(Calendar.MONTH) + 1;//月份
int day = aCalendar.getActualMaximum(Calendar.DATE);
for (int i = 1; i <= day; i++) {
String aDate = month+"-"+i;
listx.add(aDate);
listy.add(0);
}
map.put("x",listx);
map.put("y",listy);
}catch (Exception e){
e.printStackTrace();
throw new RuntimeException("系统异常!");
}
map.put("x",listx);
map.put("y",listy);
return map;
}
public static Map<String, List<Object>> getyearListOfMonth() {
public static Map<String, List<Object>> getyearListOfMonth(String date) {
Map<String, List<Object>> map =new HashMap<>();
List<Object> listx =new ArrayList<>();
List<Object> listy =new ArrayList<>();
Calendar aCalendar = Calendar.getInstance(Locale.CHINA);
int year = aCalendar.get(Calendar.YEAR);//年份
for (int i = 1; i <= 12; i++) {
String aDate = String.valueOf(year)+"-"+i;
String aDate = date+"-"+i;
listx.add(aDate);
listy.add(0);
}
......@@ -159,18 +164,9 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
List<Object> listx =new ArrayList<>();
List<Object> listy =new ArrayList<>();
try {
Date day=new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
SimpleDateFormat format=new SimpleDateFormat("HH:mm");
String s = df.format(day);
Date date = df.parse(s);
ArrayList<String> dates = new ArrayList<String>();
for (int i = 0; i < 24; i++) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.HOUR, 1);
date = cal.getTime();
String s1 = format.format(date);
String s1 =i+":00";
listx.add(s1);
listy.add(0);
}
......@@ -185,7 +181,4 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
}
}
\ No newline at end of file
......@@ -53,13 +53,27 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower,
@Override
@Async
@Transactional
public void getMonthPower() {
List<MonthPower> list= monthPowerMapper.getMonthPowerint();
this.saveBatch(list);
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatterday = DateTimeFormatter.ofPattern("YYYY-MM-dd");
String formattedDateday = now.format(formatterday);
LambdaQueryWrapper<MonthPower> wrapperday = new LambdaQueryWrapper<>();
wrapperday.eq(MonthPower::getDay, formattedDateday);
List<MonthPower> listdday= this.list(wrapperday);
if(listdday!=null&&!listdday.isEmpty()){
for (MonthPower monthPower : listdday) {
for (MonthPower power : list) {
if(monthPower.getThirdStationId().equals(power.getThirdStationId())){
monthPower.setPower(power.getPower());
}
}
}
this.saveBatch(listdday);
}else{
this.saveBatch(list);
}
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("YYYY-MM");
String formattedDate = now.format(formatter);
List<YearPower> listd= monthPowerMapper.getSumMonthPower(formattedDate);
......
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