Commit 00742ab1 authored by tangwei's avatar tangwei

修改异步方法事务

parent 238f5f42
package com.yeejoin.amos.boot.module.hygf.biz.scheduled; package com.yeejoin.amos.boot.module.hygf.biz.scheduled;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.JpStationServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
...@@ -17,7 +18,7 @@ import com.yeejoin.amos.boot.module.hygf.biz.service.impl.TdHygfJpInvertorElecHi ...@@ -17,7 +18,7 @@ import com.yeejoin.amos.boot.module.hygf.biz.service.impl.TdHygfJpInvertorElecHi
public class WindSpeedScheduled { public class WindSpeedScheduled {
@Autowired @Autowired
MonthPowerServiceImpl monthPowerServiceImpl; JpStationServiceImpl jpStationServiceImpl;
@Autowired @Autowired
TdHygfJpCollectorHistoryServiceImpl tdHygfJpCollectorHistoryServiceImpl; TdHygfJpCollectorHistoryServiceImpl tdHygfJpCollectorHistoryServiceImpl;
...@@ -27,7 +28,7 @@ public class WindSpeedScheduled { ...@@ -27,7 +28,7 @@ public class WindSpeedScheduled {
@Scheduled(cron = "${cheduled.crons}") @Scheduled(cron = "${cheduled.crons}")
private void initData() { private void initData() {
monthPowerServiceImpl.getMonthPower(); jpStationServiceImpl.getMonthPower();
tdHygfJpCollectorHistoryServiceImpl.syncData(); tdHygfJpCollectorHistoryServiceImpl.syncData();
tdHygfJpInvertorElecHistoryServiceImpl.syncData(); tdHygfJpInvertorElecHistoryServiceImpl.syncData();
} }
......
...@@ -12,6 +12,7 @@ import com.yeejoin.amos.boot.module.hygf.api.dto.JpStationDto; ...@@ -12,6 +12,7 @@ import com.yeejoin.amos.boot.module.hygf.api.dto.JpStationDto;
import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.MonthPowerMapper; import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.MonthPowerMapper;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -32,6 +33,8 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS ...@@ -32,6 +33,8 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
JpStationMapper jpStationMapper; JpStationMapper jpStationMapper;
@Autowired @Autowired
MonthPowerMapper monthPowerMapper; MonthPowerMapper monthPowerMapper;
@Autowired
MonthPowerServiceImpl monthPowerServiceImpl;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -46,6 +49,12 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS ...@@ -46,6 +49,12 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
pagenew.setRecords(page.getList()); pagenew.setRecords(page.getList());
return pagenew; return pagenew;
} }
@Async
public void getMonthPower() {
monthPowerServiceImpl.getMonthPower();
}
@Override @Override
......
...@@ -52,7 +52,7 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower, ...@@ -52,7 +52,7 @@ public class MonthPowerServiceImpl extends BaseService<MonthPowerDto,MonthPower,
@Override @Override
@Async @Transactional
public void getMonthPower() { public void getMonthPower() {
List<MonthPower> list= monthPowerMapper.getMonthPowerint(); List<MonthPower> list= monthPowerMapper.getMonthPowerint();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
......
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