|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.hnac.hzims.operational.report.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.hnac.hzims.operational.report.constants.DictConstant; |
|
|
|
|
import com.hnac.hzims.operational.report.service.IOperPersonalMonthReportService; |
|
|
|
|
import com.hnac.hzims.operational.report.service.IOperStationMonthReportService; |
|
|
|
|
import com.hnac.hzims.operational.report.vo.PersonalMonthReportVO; |
|
|
|
@ -15,14 +16,18 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.secure.BladeUser; |
|
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
|
import org.springblade.system.vo.DeptVO; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.time.YearMonth; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
|
@AllArgsConstructor |
|
|
|
@ -37,24 +42,64 @@ public class MonthReportServiceImpl extends BaseServiceImpl<MonthReportMapper, O
|
|
|
|
|
public StationRunReportAllVO getStationMonthReportByStationCode(Long deptId, String month) throws Exception { |
|
|
|
|
StationRunReportAllVO stationReportAllVO = new StationRunReportAllVO(); |
|
|
|
|
Dept dept = sysClient.getDept(deptId).getData(); |
|
|
|
|
//当月查询实时数据
|
|
|
|
|
if(month.equals(YearMonth.now().toString())){ |
|
|
|
|
stationReportAllVO = operStationMonthReportService.getStationMonthReportV2(month, BeanUtil.copy(dept, DeptVO.class)); |
|
|
|
|
} |
|
|
|
|
//历史查询定时任务生成的数据
|
|
|
|
|
else{ |
|
|
|
|
OperMonthReportEntity operMonthReportEntity = this.getOne(new LambdaQueryWrapper<OperMonthReportEntity>(){{ |
|
|
|
|
eq(OperMonthReportEntity::getMonth,month); |
|
|
|
|
eq(OperMonthReportEntity::getStationCode, dept.getId()); |
|
|
|
|
eq(OperMonthReportEntity::getIsDeleted, 0); |
|
|
|
|
orderByDesc(OperMonthReportEntity::getObject); |
|
|
|
|
last("limit 1;"); |
|
|
|
|
}}); |
|
|
|
|
//查询实时数据
|
|
|
|
|
if(ObjectUtil.isEmpty(operMonthReportEntity)){ |
|
|
|
|
stationReportAllVO = operStationMonthReportService.getStationMonthReportV2(month, BeanUtil.copy(dept, DeptVO.class)); |
|
|
|
|
} |
|
|
|
|
//历史查询定时任务生成的数据
|
|
|
|
|
else{ |
|
|
|
|
stationReportAllVO = ObjectUtil.isNotEmpty(operMonthReportEntity) ? (StationRunReportAllVO) ObjectHelper.byte2obj(operMonthReportEntity.getObject()) |
|
|
|
|
: operStationMonthReportService.getStationMonthReportV2(month, BeanUtil.copy(dept, DeptVO.class)); |
|
|
|
|
} |
|
|
|
|
return stationReportAllVO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setStationMonthReportByStationCode(Long deptId, String month){ |
|
|
|
|
Dept deptVO = sysClient.getDept(deptId).getData(); |
|
|
|
|
log.info("---{}机构---",deptVO.getDeptName()); |
|
|
|
|
//查询该电站该月报是否已生成月报
|
|
|
|
|
OperMonthReportEntity operMonthReportEntityByMonth = this.getOne(new LambdaQueryWrapper<OperMonthReportEntity>() {{ |
|
|
|
|
eq(OperMonthReportEntity::getMonth, month); |
|
|
|
|
eq(OperMonthReportEntity::getType, DictConstant.MONTH_REPORT_STATION); |
|
|
|
|
eq(OperMonthReportEntity::getStationCode, deptVO.getId()); |
|
|
|
|
eq(OperMonthReportEntity::getIsDeleted, 0); |
|
|
|
|
last("limit 1;"); |
|
|
|
|
}}); |
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(operMonthReportEntityByMonth)||month.equals(YearMonth.now().toString())) { |
|
|
|
|
if (ObjectUtil.isNotEmpty(operMonthReportEntityByMonth)){ |
|
|
|
|
this.removeById(operMonthReportEntityByMonth.getId()); |
|
|
|
|
} |
|
|
|
|
//按站点生成各电站运维月报
|
|
|
|
|
StationRunReportAllVO stationReportAllVO = operStationMonthReportService.getStationMonthReportV2(month, BeanUtil.copy(deptVO, DeptVO.class)); |
|
|
|
|
if (ObjectUtil.isNotEmpty(stationReportAllVO)) { |
|
|
|
|
OperMonthReportEntity operMonthReportEntity = new OperMonthReportEntity(); |
|
|
|
|
operMonthReportEntity.setMonth(month); |
|
|
|
|
operMonthReportEntity.setType(DictConstant.MONTH_REPORT_STATION); |
|
|
|
|
operMonthReportEntity.setCreateDept(deptVO.getId()); |
|
|
|
|
operMonthReportEntity.setStationCode(deptVO.getId().toString()); |
|
|
|
|
try { |
|
|
|
|
operMonthReportEntity.setObject(ObjectHelper.obj2byte(stationReportAllVO)); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
//修改为每运行一次,保存一次
|
|
|
|
|
this.save(operMonthReportEntity); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
log.info("该月{}已生成月报", deptVO.getDeptName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
// public PersonalMonthReportVO getPersonalMonthReport(String month) throws Exception {
|
|
|
|
|
// PersonalMonthReportVO personalMonthReportVO = new PersonalMonthReportVO();
|
|
|
|
|