Browse Source

优化:统计月报生成和导出

zhongwei
ty 7 months ago
parent
commit
f5ff2db991
  1. 14
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/MonthReportController.java
  2. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/schedule/OperStationCreateMonthReport.java
  3. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IMonthReportService.java
  4. 57
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/MonthReportServiceImpl.java
  5. 17
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java
  6. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/RunReportVO.java
  7. 17
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/allTicket/fegin/TicketInfoAllClient.java

14
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/MonthReportController.java

@ -75,6 +75,20 @@ public class MonthReportController {
StationRunReportAllVO stationReportAllVO = monthReportService.getStationMonthReportByStationCode(deptId,month); StationRunReportAllVO stationReportAllVO = monthReportService.getStationMonthReportByStationCode(deptId,month);
return R.data(stationReportAllVO); return R.data(stationReportAllVO);
} }
@ApiLog
@GetMapping("/setStationMonthReportByStationCode")
@ApiOperation(value = "根据站点编码生成站点月报",notes = "根据站点编码获取站点月报")
@ApiOperationSupport(order = 1)
@OperationAnnotation(moduleName = "生产月报",
title = "生成统计月报",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,
action = "生成统计月报")
public void setStationMonthReportByStationCode(@RequestParam("deptId") Long deptId,@RequestParam("month") String month) throws Exception {
// LocalDate startDate = DateUtil.getFirstDayByYearMonth(month);
// LocalDate endDate = DateUtil.getLastDayByYearMonth(month);
// return R.data(taskMonthService.getStationMonthReport(startDate,endDate,deptId.toString()));
monthReportService.setStationMonthReportByStationCode(deptId,month);
}
// //
// @ApiLog // @ApiLog
// @GetMapping("/getPersonalMonthReport") // @GetMapping("/getPersonalMonthReport")

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/schedule/OperStationCreateMonthReport.java

@ -61,6 +61,7 @@ public class OperStationCreateMonthReport {
eq(OperMonthReportEntity::getMonth,yearAndMonth); eq(OperMonthReportEntity::getMonth,yearAndMonth);
eq(OperMonthReportEntity::getType, DictConstant.MONTH_REPORT_STATION); eq(OperMonthReportEntity::getType, DictConstant.MONTH_REPORT_STATION);
eq(OperMonthReportEntity::getStationCode, deptVO.getId()); eq(OperMonthReportEntity::getStationCode, deptVO.getId());
eq(OperMonthReportEntity::getIsDeleted, 0);
}}); }});
if(CollectionUtil.isEmpty(operMonthReportEntityList)){ if(CollectionUtil.isEmpty(operMonthReportEntityList)){
//按站点生成各电站运维月报 //按站点生成各电站运维月报
@ -76,15 +77,18 @@ public class OperStationCreateMonthReport {
entityList.add(operMonthReportEntity); entityList.add(operMonthReportEntity);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
log.error(e.toString());
} }
//修改为每运行一次,保存一次
monthReportService.save(operMonthReportEntity);
} }
} }
else{ else{
log.info("该月{}已生成月报",deptVO.getDeptName()); log.info("该月{}已生成月报",deptVO.getDeptName());
} }
}//); }//);
monthReportService.saveBatch(entityList);
log.info("---{}月份电站月报生成完成---",yearAndMonth); log.info("---{}月份电站月报生成完成---",yearAndMonth);
log.info("---{}月份电站月报生成完成---"+entityList.toString());
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }
} }

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/IMonthReportService.java

@ -5,6 +5,7 @@ import com.hnac.hzims.operational.report.vo.StationReportAllVO;
import com.hnac.hzims.operational.report.entity.OperMonthReportEntity; import com.hnac.hzims.operational.report.entity.OperMonthReportEntity;
import com.hnac.hzims.operational.report.vo.StationRunReportAllVO; import com.hnac.hzims.operational.report.vo.StationRunReportAllVO;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import org.springblade.core.tool.api.R;
public interface IMonthReportService extends BaseService<OperMonthReportEntity> { public interface IMonthReportService extends BaseService<OperMonthReportEntity> {
/** /**
@ -16,6 +17,8 @@ public interface IMonthReportService extends BaseService<OperMonthReportEntity>
*/ */
StationRunReportAllVO getStationMonthReportByStationCode(Long deptId, String month) throws Exception; StationRunReportAllVO getStationMonthReportByStationCode(Long deptId, String month) throws Exception;
void setStationMonthReportByStationCode(Long deptId, String month) throws Exception;
/** /**
* 查询个人月报 * 查询个人月报
* @param month * @param month

57
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/MonthReportServiceImpl.java

@ -1,6 +1,7 @@
package com.hnac.hzims.operational.report.service.impl; package com.hnac.hzims.operational.report.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.IOperPersonalMonthReportService;
import com.hnac.hzims.operational.report.service.IOperStationMonthReportService; import com.hnac.hzims.operational.report.service.IOperStationMonthReportService;
import com.hnac.hzims.operational.report.vo.PersonalMonthReportVO; 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.mp.base.BaseServiceImpl;
import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil; 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.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.system.entity.Dept; import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
import org.springblade.system.vo.DeptVO; import org.springblade.system.vo.DeptVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException;
import java.time.YearMonth; import java.time.YearMonth;
import java.util.List;
@Service @Service
@AllArgsConstructor @AllArgsConstructor
@ -37,24 +42,64 @@ public class MonthReportServiceImpl extends BaseServiceImpl<MonthReportMapper, O
public StationRunReportAllVO getStationMonthReportByStationCode(Long deptId, String month) throws Exception { public StationRunReportAllVO getStationMonthReportByStationCode(Long deptId, String month) throws Exception {
StationRunReportAllVO stationReportAllVO = new StationRunReportAllVO(); StationRunReportAllVO stationReportAllVO = new StationRunReportAllVO();
Dept dept = sysClient.getDept(deptId).getData(); 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>(){{ OperMonthReportEntity operMonthReportEntity = this.getOne(new LambdaQueryWrapper<OperMonthReportEntity>(){{
eq(OperMonthReportEntity::getMonth,month); eq(OperMonthReportEntity::getMonth,month);
eq(OperMonthReportEntity::getStationCode, dept.getId()); eq(OperMonthReportEntity::getStationCode, dept.getId());
eq(OperMonthReportEntity::getIsDeleted, 0);
orderByDesc(OperMonthReportEntity::getObject); orderByDesc(OperMonthReportEntity::getObject);
last("limit 1;"); 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()) stationReportAllVO = ObjectUtil.isNotEmpty(operMonthReportEntity) ? (StationRunReportAllVO) ObjectHelper.byte2obj(operMonthReportEntity.getObject())
: operStationMonthReportService.getStationMonthReportV2(month, BeanUtil.copy(dept, DeptVO.class)); : operStationMonthReportService.getStationMonthReportV2(month, BeanUtil.copy(dept, DeptVO.class));
} }
return stationReportAllVO; 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 // @Override
// public PersonalMonthReportVO getPersonalMonthReport(String month) throws Exception { // public PersonalMonthReportVO getPersonalMonthReport(String month) throws Exception {
// PersonalMonthReportVO personalMonthReportVO = new PersonalMonthReportVO(); // PersonalMonthReportVO personalMonthReportVO = new PersonalMonthReportVO();

17
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java

@ -75,9 +75,7 @@ import java.time.LocalTime;
import java.time.YearMonth; import java.time.YearMonth;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -114,7 +112,11 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor
/** /**
* 通过线程池异步获取月报各模块内容 主要分为八块内容 * 通过线程池异步获取月报各模块内容 主要分为八块内容
**/ **/
private static final ExecutorService pool = Executors.newFixedThreadPool(POOL_QUANTITY); // private static final ExecutorService pool = Executors.newFixedThreadPool(POOL_QUANTITY);
private static final ExecutorService pool = new ThreadPoolExecutor(8, 10,
1, TimeUnit.HOURS, new ArrayBlockingQueue<>(5, true),
Executors.defaultThreadFactory(), new ThreadPoolExecutor.CallerRunsPolicy());
/** /**
* 统计月报-电站-对内 * 统计月报-电站-对内
@ -1222,9 +1224,10 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor
int sum = stationReportAllVo.getTicketInfoStatisticVOList().stream().filter(s->"合计".equals(s.getTicketInfoType())).mapToInt(TicketInfoStatisticVO::getTicketInfoNumber).sum(); int sum = stationReportAllVo.getTicketInfoStatisticVOList().stream().filter(s->"合计".equals(s.getTicketInfoType())).mapToInt(TicketInfoStatisticVO::getTicketInfoNumber).sum();
int qualifiedNum = stationReportAllVo.getTicketInfoStatisticVOList().stream().filter(s->"合计".equals(s.getTicketInfoType())).mapToInt(TicketInfoStatisticVO::getTicketInfoQualifiedNum).sum(); int qualifiedNum = stationReportAllVo.getTicketInfoStatisticVOList().stream().filter(s->"合计".equals(s.getTicketInfoType())).mapToInt(TicketInfoStatisticVO::getTicketInfoQualifiedNum).sum();
// double ticketInfoProportion = new BigDecimal(qualifiedNum ).divide(sum,2, RoundingMode.HALF_DOWN).doubleValue(); // double ticketInfoProportion = new BigDecimal(qualifiedNum ).divide(sum,2, RoundingMode.HALF_DOWN).doubleValue();
double ticketInfoProportion = sum == 0 ? 0 : new BigDecimal(qualifiedNum).divide(new BigDecimal(sum*100),2, double ticketInfoProportion = sum == 0 ? 0 : new BigDecimal(qualifiedNum).divide(new BigDecimal(sum),2,
RoundingMode.HALF_DOWN).doubleValue(); RoundingMode.HALF_DOWN).multiply(new BigDecimal(100))
String phenomenonConclusion = "5、本月开票%s张,合格率%s;"; .setScale(2,RoundingMode.HALF_DOWN).doubleValue();
String phenomenonConclusion = "5、本月开票%s张,合格率百分之%s%%";
conclusion.append(String.format(phenomenonConclusion, sum, ticketInfoProportion)).append(";\r\n"); conclusion.append(String.format(phenomenonConclusion, sum, ticketInfoProportion)).append(";\r\n");
}else { }else {
conclusion.append("5、本月未开票;\r\n"); conclusion.append("5、本月未开票;\r\n");

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/vo/RunReportVO.java

@ -17,11 +17,11 @@ public class RunReportVO implements Serializable {
@ApiModelProperty("姓名") @ApiModelProperty("姓名")
private String userName; private String userName;
@ApiModelProperty("完成次数") @ApiModelProperty("完成次数")
private Integer completeNum; private Integer completeNum=0;
@ApiModelProperty("完成任务数量") @ApiModelProperty("完成任务数量")
private List<String> completeList; private List<String> completeList;
@ApiModelProperty("未完成次数") @ApiModelProperty("未完成次数")
private Integer incompleteNum; private Integer incompleteNum=0;
@ApiModelProperty("完成任务数量") @ApiModelProperty("完成任务数量")
private List<String> incompleteList; private List<String> incompleteList;
@ApiModelProperty("备注") @ApiModelProperty("备注")

17
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/allTicket/fegin/TicketInfoAllClient.java

@ -71,15 +71,16 @@ public class TicketInfoAllClient implements ITicketInfoAllClient {
TicketInfoStatisticVO ticketInfoStatisticVO=new TicketInfoStatisticVO(); TicketInfoStatisticVO ticketInfoStatisticVO=new TicketInfoStatisticVO();
ticketInfoStatisticVO.setTicketInfoType("合计"); ticketInfoStatisticVO.setTicketInfoType("合计");
int sum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoNumber).sum(); int sum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoNumber).sum();
int CompleteNum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoCompleteNum).sum(); int completeNum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoCompleteNum).sum();
int InvalidatedNum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoInvalidatedNum).sum(); int invalidatedNum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoInvalidatedNum).sum();
int QualifiedNum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoQualifiedNum).sum(); int qualifiedNum = workTicketStatistic.stream().mapToInt(TicketInfoStatisticVO::getTicketInfoQualifiedNum).sum();
Double Proportion = new BigDecimal(QualifiedNum).divide(new BigDecimal(sum),2, RoundingMode.UP).doubleValue(); Double proportion = new BigDecimal(qualifiedNum).divide(new BigDecimal(sum),2, RoundingMode.UP)
.multiply(new BigDecimal(100)).setScale(2, RoundingMode.UP).doubleValue();
ticketInfoStatisticVO.setTicketInfoNumber(sum); ticketInfoStatisticVO.setTicketInfoNumber(sum);
ticketInfoStatisticVO.setTicketInfoCompleteNum(CompleteNum); ticketInfoStatisticVO.setTicketInfoCompleteNum(completeNum);
ticketInfoStatisticVO.setTicketInfoInvalidatedNum(InvalidatedNum); ticketInfoStatisticVO.setTicketInfoInvalidatedNum(invalidatedNum);
ticketInfoStatisticVO.setTicketInfoQualifiedNum(QualifiedNum); ticketInfoStatisticVO.setTicketInfoQualifiedNum(qualifiedNum);
ticketInfoStatisticVO.setTicketInfoProportion(Proportion); ticketInfoStatisticVO.setTicketInfoProportion(proportion);
workTicketStatistic.add(ticketInfoStatisticVO); workTicketStatistic.add(ticketInfoStatisticVO);
}else { }else {
TicketInfoStatisticVO ticketInfoStatisticVO=new TicketInfoStatisticVO(); TicketInfoStatisticVO ticketInfoStatisticVO=new TicketInfoStatisticVO();

Loading…
Cancel
Save