删除无用类
1.3.5
xins 11 months ago
parent 8862f60ea3
commit 886e034aae

@ -1,19 +0,0 @@
package com.hw;
// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
public static void main(String[] args) {
// Press Alt+Enter with your caret at the highlighted text to see how
// IntelliJ IDEA suggests fixing it.
System.out.printf("Hello and welcome!");
// Press Shift+F10 or click the green arrow button in the gutter to run the code.
for (int i = 1; i <= 5; i++) {
// Press Shift+F9 to start debugging your code. We have set one breakpoint
// for you, but you can always add more by pressing Ctrl+F8.
System.out.println("i = " + i);
}
}
}

@ -1,83 +0,0 @@
package com.hw.ems.report.controller;
import com.hw.common.core.domain.R;
import com.hw.common.core.exception.base.BaseException;
import com.hw.common.core.utils.StringUtils;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.ems.report.domain.EmsApiVo;
import com.hw.ems.report.service.IEmsApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* EMShw
* @Author Yinq
* @create 2023-07-26 17:58
*/
@RestController
@RequestMapping("/emsApi")
public class EmsApiController extends BaseController {
@Autowired
private IEmsApiService emsApiService;
/**
* cbs
* @param emsApiVo
* @return
*/
@PostMapping("/getMeterReadingData")
@Log(title = "CBS获取抄表数据", businessType = BusinessType.OTHER)
public AjaxResult getMeterReadingData(@RequestBody EmsApiVo emsApiVo)
{
return success(emsApiService.getMeterReadingData(emsApiVo));
}
/**
* cbs
* @param emsApiVo
* @return
*/
@PostMapping("/getMeterReadingDataInterface")
@Log(title = "cbs获取抄表数据返回接口", businessType = BusinessType.OTHER)
public AjaxResult getMeterReadingDataInterface(@RequestBody EmsApiVo emsApiVo)
{
return success(emsApiService.getMeterReadingDataInterface(emsApiVo));
}
/**
* CBS
* @return
*/
@PostMapping("/meterReadingDataTimingTask")
@Log(title = "CBS获取抄表数据定时任务", businessType = BusinessType.OTHER)
public R<Boolean> meterReadingDataTimingTask() {
return emsApiService.meterReadingDataTimingTask();
}
/**
* cbs
* @param emsApiVo
* @return
*/
@PostMapping("/modifyDeviceInformation")
@Log(title = "cbs获取抄表数据返回接口", businessType = BusinessType.OTHER)
public AjaxResult modifyDeviceInformation(@RequestBody EmsApiVo emsApiVo)
{
if (StringUtils.isNull(emsApiVo.getModifyType())){
return error("service == modifyDeviceInformation == exception:请传修改类型0-新增1-删除2-修改)!");
}
if (StringUtils.isNull(emsApiVo.getPhysicalCode())){
return error("service == modifyDeviceInformation == exception:请传物理编号!");
}
return success(emsApiService.modifyDeviceInformation(emsApiVo));
}
}

@ -1,138 +0,0 @@
package com.hw.ems.report.domain;
import com.hw.common.core.web.domain.BaseEntity;
import java.util.List;
/**
* cbs EmsApiVo
*
* @author YinQ
* @date 2023-09-13
*/
public class EmsApiVo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/**
*
*/
private String meterReadingTime;
/**
* cbs
*/
private String parkCode;
/**
* cbs
*/
private String roomCode;
/**
* cbs
*/
private String roomName;
/**
* ems
*/
private String poolName;
/**
* cbsList
*/
private List<String> monitorIdList;
/**
* 0-1-2-
*/
private Long modifyType;
/**
* CBS
*/
private String physicalCode;
public String getRoomName() {
return roomName;
}
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public String getPhysicalCode() {
return physicalCode;
}
public void setPhysicalCode(String physicalCode) {
this.physicalCode = physicalCode;
}
public Long getModifyType() {
return modifyType;
}
public void setModifyType(Long modifyType) {
this.modifyType = modifyType;
}
@Override
public String getPoolName() {
return poolName;
}
@Override
public void setPoolName(String poolName) {
this.poolName = poolName;
}
public List<String> getMonitorIdList() {
return monitorIdList;
}
public void setMonitorIdList(List<String> monitorIdList) {
this.monitorIdList = monitorIdList;
}
public String getMeterReadingTime() {
return meterReadingTime;
}
public void setMeterReadingTime(String meterReadingTime) {
this.meterReadingTime = meterReadingTime;
}
public String getParkCode() {
return parkCode;
}
public void setParkCode(String parkCode) {
this.parkCode = parkCode;
}
public String getRoomCode() {
return roomCode;
}
public void setRoomCode(String roomCode) {
this.roomCode = roomCode;
}
@Override
public String toString() {
return "EmsApiVo{" +
"meterReadingTime='" + meterReadingTime + '\'' +
", parkCode='" + parkCode + '\'' +
", roomCode='" + roomCode + '\'' +
", poolName='" + poolName + '\'' +
", monitorIdList=" + monitorIdList +
", modifyType=" + modifyType +
", physicalCode='" + physicalCode + '\'' +
'}';
}
}

@ -1,48 +0,0 @@
package com.hw.ems.report.service;
import com.hw.common.core.domain.R;
import com.hw.ems.base.domain.CbsMonitorReport;
import com.hw.ems.base.domain.vo.CbsMonitorReportVo;
import com.hw.ems.report.domain.EmsApiVo;
import java.util.List;
/**
* EMShwService
*
* @author YinQ
* @date 2023-04-05
*/
public interface IEmsApiService {
/**
* cbs
* @param emsApiVo
* @return
*/
List<CbsMonitorReportVo> getMeterReadingData(EmsApiVo emsApiVo);
/**
* CBS
* @return
*/
R<Boolean> meterReadingDataTimingTask();
/**
* cbs
* @param emsApiVo
* @return
*/
List<CbsMonitorReportVo> getMeterReadingDataInterface(EmsApiVo emsApiVo);
/**
* cbs
* @param emsApiVo
* @return
*/
String modifyDeviceInformation(EmsApiVo emsApiVo);
}

@ -1,292 +0,0 @@
package com.hw.ems.report.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.hw.common.core.domain.R;
import com.hw.common.core.exception.ServiceException;
import com.hw.common.core.exception.base.BaseException;
import com.hw.common.core.utils.DateUtils;
import com.hw.common.core.utils.StringUtils;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.ems.base.domain.BaseMonitorInfo;
import com.hw.ems.base.domain.CbsMonitorReport;
import com.hw.ems.base.domain.SysDatasource;
import com.hw.ems.base.domain.vo.CbsMonitorReportVo;
import com.hw.ems.base.mapper.BaseMonitorInfo1Mapper;
import com.hw.ems.base.mapper.CbsMonitorReportMapper;
import com.hw.ems.base.service.ISysDatasourceService;
import com.hw.ems.report.domain.EmsApiVo;
import com.hw.ems.report.service.IEmsApiService;
import com.hw.system.api.model.LoginUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
/**
* EMShwService
*
* @author YinQ
* @date 2023-04-09
*/
@Service
public class EmsAPIServiceImpl implements IEmsApiService {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private ISysDatasourceService datasourceService;
@Autowired
private CbsMonitorReportMapper cbsMonitorReportMapper;
@Autowired
private BaseMonitorInfo1Mapper monitorInfo1Mapper;
/**
* cbs
*
* @param emsApiVo
* @return
*/
@Override
public List<CbsMonitorReportVo> getMeterReadingData(EmsApiVo emsApiVo) {
ArrayList<CbsMonitorReportVo> monitorReportVoArrayList = new ArrayList<>();
//抄表时间(时间为空则默认当前时间
if (StringUtils.isEmpty(emsApiVo.getMeterReadingTime())) {
emsApiVo.setMeterReadingTime(DateUtils.getTime());
}
String poolName = null;
if (StringUtils.isNotEmpty(emsApiVo.getParkCode())) {
// 加载hw-cloud库的sys_datasource
SysDatasource datasource = datasourceService.selectSysDatasourceByCbsParkCode(emsApiVo.getParkCode());
poolName = datasource.getPoolName();
} else {
LoginUser loginUser = SecurityUtils.getLoginUser();
poolName = loginUser.getPoolName();
}
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
// 多房间抄表, roomCode逗号分割
if (StringUtils.isNotEmpty(emsApiVo.getRoomCode())) {
CbsMonitorReport monitorReport = new CbsMonitorReport();
monitorReport.setRoomCode(emsApiVo.getRoomCode());
List<CbsMonitorReport> cbsMonitorReports = cbsMonitorReportMapper.selectCbsMonitorReportList(monitorReport);
List<String> monitorIdList = cbsMonitorReports.stream().map(CbsMonitorReport::getMonitorId).collect(Collectors.toList());
emsApiVo.setMonitorIdList(monitorIdList);
}
try {
//获取水电实时数据
List<CbsMonitorReport> cbsMonitorReportList = this.getRealTimeData(emsApiVo);
Date nowDate = DateUtils.getNowDate();
for (CbsMonitorReport cbsMonitorReport : cbsMonitorReportList) {
//查询上次抄表数据
CbsMonitorReport lastTimeCbsMonitorReport = cbsMonitorReportMapper.selectLastTimeCbsMonitorReport(cbsMonitorReport);
if (StringUtils.isNull(lastTimeCbsMonitorReport)) {
cbsMonitorReport.setLastFlag("1");
} else {
cbsMonitorReport.setLastMonitorTime(lastTimeCbsMonitorReport.getThisMonitorTime());
if (StringUtils.isNull(lastTimeCbsMonitorReport.getThisMonitorExpend())) {
cbsMonitorReport.setLastFlag("1");
} else {
cbsMonitorReport.setLastFlag("0");
cbsMonitorReport.setLastMonitorExpend(lastTimeCbsMonitorReport.getThisMonitorExpend());
}
}
cbsMonitorReport.setCreateTime(nowDate);
cbsMonitorReportMapper.insertCbsMonitorReport(cbsMonitorReport);
}
logger.info("service == getMeterReadingData == Info:" + emsApiVo + cbsMonitorReportList);
for (CbsMonitorReport reportOne : cbsMonitorReportList) {
CbsMonitorReportVo cbsMonitorReportVo = new CbsMonitorReportVo();
cbsMonitorReportVo.setRoomCode(reportOne.getRoomCode());
cbsMonitorReportVo.setRoomName(reportOne.getRoomName());
cbsMonitorReportVo.setPhysicalCode(reportOne.getPhysicalCode());
cbsMonitorReportVo.setLoadingPosition(reportOne.getLoadingPosition());
cbsMonitorReportVo.setMonitorType(reportOne.getMonitorType().equals("2") ? "电表" : "水表");
if (reportOne.getPublicShareType().equals("0")){
cbsMonitorReportVo.setPublicShareType("公共表");
}else if (reportOne.getPublicShareType().equals("1")){
cbsMonitorReportVo.setPublicShareType("单元表");
}else {
cbsMonitorReportVo.setPublicShareType("无");
}
cbsMonitorReportVo.setLastMonitorTime(reportOne.getLastMonitorTime());
cbsMonitorReportVo.setLastMonitorExpend(reportOne.getLastMonitorExpend());
cbsMonitorReportVo.setThisMonitorTime(reportOne.getThisMonitorTime());
cbsMonitorReportVo.setThisMonitorExpend(reportOne.getThisMonitorExpend());
monitorReportVoArrayList.add(cbsMonitorReportVo);
}
return monitorReportVoArrayList;
} catch (Exception e) {
logger.error("service == getMeterReadingData == exception:", e);
throw new BaseException("service == getMeterReadingData == exception:" + e);
}
}
/**
*
*
* @param emsApiVo
* @return
*/
@DS("#header.poolName")
private List<CbsMonitorReport> getRealTimeData(EmsApiVo emsApiVo) {
return cbsMonitorReportMapper.selectRealTimeMonitorList(emsApiVo);
}
/**
* CBS
* @return
*/
@Override
public R<Boolean> meterReadingDataTimingTask() {
// 加载hw-cloud库的sys_datasource
List<SysDatasource> dateSources = datasourceService.selectSysDatasource();
ExecutorService executorService = Executors.newFixedThreadPool(dateSources.size());
try{
dateSources.forEach(dateSource ->{
logger.info("++++++++++++"+dateSource.getPoolName() +"++++开始++++++++++");
EmsApiVo emsApiVo = new EmsApiVo();
emsApiVo.setPoolName(dateSource.getPoolName());
Runnable run = () -> getMeterReadingData(emsApiVo);
executorService.execute(run);
});
}catch (Exception e){
logger.error("service == dailyConsumptionTimingTask == exception", e);
return R.fail("service == dailyConsumptionTimingTask == exception");
}finally {
executorService.shutdown();
}
return R.ok(true);
}
/**
*
* @param emsApiVo
* @return
*/
@Override
public List<CbsMonitorReportVo> getMeterReadingDataInterface(EmsApiVo emsApiVo){
List<CbsMonitorReportVo> monitorReportVoList = this.getMeterReadingData(emsApiVo);
ArrayList<CbsMonitorReportVo> monitorReportVoArrayList = new ArrayList<>();
// 使用 Collectors.groupingBy 收集具有相同 roomCode 值的对象
Map<String, List<CbsMonitorReportVo>> groupedReports = monitorReportVoList.stream().collect(Collectors.groupingBy(CbsMonitorReportVo::getRoomCode));
// String result = null;
try {
for (String roomCode : groupedReports.keySet()) {
CbsMonitorReportVo cbsMonitorReportVo = new CbsMonitorReportVo();
List<CbsMonitorReportVo> cbsMonitorReports = groupedReports.get(roomCode);
BigDecimal thisMonitorExpend = new BigDecimal(0);
BigDecimal lastMonitorExpend = new BigDecimal(0);
CbsMonitorReportVo reportOne = cbsMonitorReports.get(0);
for (CbsMonitorReportVo report : cbsMonitorReports) {
if (StringUtils.isNotNull(report.getThisMonitorExpend())){
thisMonitorExpend = thisMonitorExpend.add(report.getThisMonitorExpend());
}
if (StringUtils.isNotNull(report.getLastMonitorExpend())){
lastMonitorExpend = lastMonitorExpend.add(report.getLastMonitorExpend());
}
}
cbsMonitorReportVo.setRoomCode(reportOne.getRoomCode());
cbsMonitorReportVo.setRoomName(reportOne.getRoomName());
cbsMonitorReportVo.setPhysicalCode(reportOne.getPhysicalCode());
cbsMonitorReportVo.setLoadingPosition(reportOne.getLoadingPosition());
cbsMonitorReportVo.setMonitorType(reportOne.getMonitorType().equals("2") ? "电表" : "水表");
if (reportOne.getPublicShareType().equals("0")){
cbsMonitorReportVo.setPublicShareType("公共表");
}else if (reportOne.getPublicShareType().equals("1")){
cbsMonitorReportVo.setPublicShareType("单元表");
}else {
cbsMonitorReportVo.setPublicShareType("无");
}
cbsMonitorReportVo.setLastMonitorTime(reportOne.getLastMonitorTime());
cbsMonitorReportVo.setLastMonitorExpend(lastMonitorExpend);
cbsMonitorReportVo.setThisMonitorTime(reportOne.getThisMonitorTime());
cbsMonitorReportVo.setThisMonitorExpend(thisMonitorExpend);
monitorReportVoArrayList.add(cbsMonitorReportVo);
}
// ObjectMapper objectMapper = new ObjectMapper();
// 将对象转换为 JSON 字符串
// result = objectMapper.writeValueAsString(monitorReportVoArrayList);
} catch (Exception e) {
System.out.println(e);
}
return monitorReportVoArrayList;
}
/**
* cbs
* @param emsApiVo
* @return
*/
@Override
public String modifyDeviceInformation(EmsApiVo emsApiVo) {
Long modifyType = emsApiVo.getModifyType();
String physicalCode = emsApiVo.getPhysicalCode();
String poolName = null;
if (StringUtils.isNotEmpty(emsApiVo.getParkCode())) {
// 加载hw-cloud库的sys_datasource
SysDatasource datasource = datasourceService.selectSysDatasourceByCbsParkCode(emsApiVo.getParkCode());
poolName = datasource.getPoolName();
} else {
LoginUser loginUser = SecurityUtils.getLoginUser();
poolName = loginUser.getPoolName();
}
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
BaseMonitorInfo monitorInfo = new BaseMonitorInfo();
monitorInfo.setPhysicalCode(physicalCode);
List<BaseMonitorInfo> monitorInfoList = monitorInfo1Mapper.selectBaseMonitorInfoList(monitorInfo);
if (monitorInfoList.size() == 0){
throw new ServiceException("service == modifyDeviceInformation == exception:该物理编号:" + physicalCode + "能源系统未维护!");
}
BaseMonitorInfo monitor = monitorInfoList.get(0);
StringBuilder buffer = new StringBuilder();
//0-新增
if (modifyType == 0L){
monitor.setRoomCode(emsApiVo.getRoomCode());
monitor.setRoomName(emsApiVo.getRoomName());
monitorInfo1Mapper.updateBaseMonitorInfo(monitor);
buffer.append("新增CBS设备信息接口|物理编号:").append(physicalCode);
}
//1-删除
if (modifyType == 1L){
monitor.setRoomCode("");
monitor.setRoomName("");
monitorInfo1Mapper.updateBaseMonitorInfo(monitor);
buffer.append("删除CBS设备信息接口|物理编号:").append(physicalCode);
}
//2-修改
if (modifyType == 2L){
monitor.setRoomCode(emsApiVo.getRoomCode());
monitor.setRoomName(emsApiVo.getRoomName());
monitorInfo1Mapper.updateBaseMonitorInfo(monitor);
buffer.append("修改CBS设备信息接口|物理编号:").append(physicalCode);
}
logger.info("service == modifyDeviceInformation == Info:" + emsApiVo + monitor);
return buffer.append("|调用成功!").toString();
}
}
Loading…
Cancel
Save