| | |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.http.pojo.TqdianbiaoEleRecord; |
| | | import com.ruoyi.http.service.TqdianbiaoEleRecordManageService; |
| | | import com.ruoyi.http.service.TqdianbiaoEleSyncService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @RestController |
| | | @Tag(name = "电量记录管理") |
| | |
| | | @RequiredArgsConstructor |
| | | public class TqdianbiaoEleRecordController extends BaseController { |
| | | |
| | | private static final DateTimeFormatter HOUR_FMT = DateTimeFormatter.ofPattern("yyyyMMddHH"); |
| | | |
| | | private final TqdianbiaoEleRecordManageService eleRecordManageService; |
| | | private final TqdianbiaoEleSyncService eleSyncService; |
| | | |
| | | @GetMapping("/listPage") |
| | | @Operation(summary = "电量记录-分页查询") |
| | |
| | | public AjaxResult prevReading(Long meterId, String timeKey) { |
| | | return AjaxResult.success(eleRecordManageService.getPrevReading(meterId, timeKey)); |
| | | } |
| | | |
| | | @PostMapping("/syncRecentOnce") |
| | | @Log(title = "电量记录-近三天补数", businessType = BusinessType.OTHER) |
| | | @Operation(summary = "同步前三天至当前小时电量(一次性补数)") |
| | | public AjaxResult syncRecentOnce() { |
| | | LocalDateTime start = LocalDate.now().minusDays(3).atStartOfDay(); |
| | | LocalDateTime end = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0); |
| | | int count = eleSyncService.syncLast3DaysHourData(); |
| | | Map<String, Object> data = new HashMap<>(); |
| | | data.put("count", count); |
| | | data.put("startTime", start.format(HOUR_FMT)); |
| | | data.put("endTime", end.format(HOUR_FMT)); |
| | | return AjaxResult.success("同步完成:" + data.get("startTime") + " ~ " + data.get("endTime") + " 共 " + count + " 条", data); |
| | | } |
| | | } |