Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
yang_shj 1 year ago
parent
commit
913215e561
  1. 10
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java
  2. 5
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java
  3. 2
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/TicketConstants.java
  4. 19
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java
  5. 5
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  6. 11
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java
  7. 2
      hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java
  8. 4
      hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java
  9. 15
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java
  10. 10
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java
  11. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java
  12. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/CentralMonitorService.java
  13. 31
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java
  14. 45
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/PointDataVo.java
  15. 236
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/BarChartDemo.java
  16. 30
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java
  17. 501
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java
  18. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java
  19. 33
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java
  20. 44
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/JFreeUtil.java
  21. 35
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java
  22. 88
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/WordUtils.java
  23. BIN
      hzims-service/operational/src/main/resources/template/waterMonReport.docx

10
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java

@ -79,7 +79,7 @@ public interface IEmInfoClient {
String GET_EM_INFO_TREE_BY_EM_CODE = API_PREFIX + "/getEmInfoTreeByEmCode"; String GET_EM_INFO_TREE_BY_EM_CODE = API_PREFIX + "/getEmInfoTreeByEmCode";
String UPDATE_BY_EM_CODE = API_PREFIX + "/updateByEmCode"; String UPDATE_BY_EM_CODE = API_PREFIX + "/updateByEmCode";
String UPDATE_BATCH_EM_STATE = API_PREFIX + "/updateBachEmState"; String UPDATE_BATCH_EM_STATE = API_PREFIX + "/updateBachEmState";
String GET_CHILDREN_BY_EM_CODE = API_PREFIX + "/getChildrenByEmCode";
String GET_EM_CREATE_TABLE = API_PREFIX + "/getEmCreateTable"; String GET_EM_CREATE_TABLE = API_PREFIX + "/getEmCreateTable";
@PostMapping(DETAIL) @PostMapping(DETAIL)
@ -153,4 +153,12 @@ public interface IEmInfoClient {
@PostMapping(GET_EM_CREATE_TABLE) @PostMapping(GET_EM_CREATE_TABLE)
List<CreateTableVO> getEmCreateTable(@RequestParam("list") List<String> tableNames); List<CreateTableVO> getEmCreateTable(@RequestParam("list") List<String> tableNames);
/**
* 获取设备下的子设备编号列表
* @param emCode 设备编号
* @return 子设备编号列表
*/
@GetMapping(GET_CHILDREN_BY_EM_CODE)
R<List<String>> getChildrenByEmCode(@RequestParam("emCode") String emCode);
} }

5
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java

@ -98,4 +98,9 @@ public class IEmInfoClientBack implements IEmInfoClient {
public List<CreateTableVO> getEmCreateTable(List<String> tableNames) { public List<CreateTableVO> getEmCreateTable(List<String> tableNames) {
return new ArrayList<>(); return new ArrayList<>();
} }
@Override
public R<List<String>> getChildrenByEmCode(String emCode) {
return R.fail("远程调用失败");
}
} }

2
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/TicketConstants.java

@ -169,7 +169,7 @@ public interface TicketConstants {
} }
public static String getTicketNameByType(String type) { public static String getTicketNameByType(String type) {
Optional<WordFileNameEnum> optional = Arrays.stream(WordFileNameEnum.values()).filter(e -> type.equals(e.getType())).findFirst(); Optional<TicketTypeNameEnum> optional = Arrays.stream(TicketTypeNameEnum.values()).filter(e -> type.equals(e.getType())).findFirst();
return optional.map(e -> e.fileName).orElse(null); return optional.map(e -> e.fileName).orElse(null);
} }
} }

19
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java

@ -3,19 +3,20 @@ package com.hnac.hzims.equipment.feign;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.service.IEmInfoService;
import com.hnac.hzims.equipment.vo.DeviceVO; import com.hnac.hzims.equipment.vo.DeviceVO;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.system.vo.CreateTableVO; import org.springblade.system.vo.CreateTableVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@RestController @RestController
@ -133,6 +134,16 @@ public class EmInfoClient implements IEmInfoClient {
return service.getEmCreateTable(tableNames); return service.getEmCreateTable(tableNames);
} }
@Override
public R<List<String>> getChildrenByEmCode(@RequestParam String emCode) {
EmInfoEntity emInfo = service.getOne(Wrappers.<EmInfoEntity>lambdaQuery().eq(EmInfoEntity::getNumber, emCode));
if(ObjectUtil.isEmpty(emInfo)) {
return R.data(Lists.newArrayList());
}
LambdaQueryWrapper<EmInfoEntity> wrapper = Wrappers.<EmInfoEntity>lambdaQuery().like(EmInfoEntity::getPath, emInfo.getPath());
return R.data(service.list(wrapper).stream().map(EmInfoEntity::getNumber).distinct().collect(Collectors.toList()));
}
/** /**
* *
* @param emCode * @param emCode

5
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java

@ -599,14 +599,15 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
.flatMap(path -> Arrays.stream(path.split("/"))).distinct().collect(Collectors.toList()); .flatMap(path -> Arrays.stream(path.split("/"))).distinct().collect(Collectors.toList());
emCodes.addAll(childrenEmCode); emCodes.addAll(childrenEmCode);
} }
EmInfoEntity emInfo = this.getOne(Wrappers.<EmInfoEntity>lambdaQuery().eq(EmInfoEntity::getNumber, parentCode));
// 获取parentCode下的子设备集合 // 获取parentCode下的子设备集合
LambdaQueryWrapper<EmInfoEntity> queryWrapper = Wrappers.<EmInfoEntity>lambdaQuery() LambdaQueryWrapper<EmInfoEntity> queryWrapper = Wrappers.<EmInfoEntity>lambdaQuery()
.eq(EmInfoEntity::getGpid, parentCode) .eq(EmInfoEntity::getGpid, Optional.ofNullable(emInfo).map(EmInfoEntity::getId).orElse(0L))
.eq(EmInfoEntity::getDepartment,deptId); .eq(EmInfoEntity::getDepartment,deptId);
List<EmInfoEntity> emInfoList = this.list(queryWrapper); List<EmInfoEntity> emInfoList = this.list(queryWrapper);
List<JSONObject> result = emInfoList.stream().map(emInfoEntity -> { List<JSONObject> result = emInfoList.stream().map(emInfoEntity -> {
JSONObject object = JSONObject.parseObject(JSON.toJSONString(emInfoEntity)); JSONObject object = JSONObject.parseObject(JSON.toJSONString(emInfoEntity));
object.put("disabled", emCodes.contains(emInfoEntity.getNumber()) ? true : false); object.put("disabled", emCodes.contains(emInfoEntity.getNumber()) ? false : true);
return object; return object;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return result; return result;

11
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ObjectServiceImpl.java

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.hnac.hzims.equipment.feign.IEmInfoClient;
import com.hnac.hzinfo.inspect.Constants; import com.hnac.hzinfo.inspect.Constants;
import com.hnac.hzinfo.inspect.obj.ObjectConstants; import com.hnac.hzinfo.inspect.obj.ObjectConstants;
import com.hnac.hzinfo.inspect.obj.entity.*; import com.hnac.hzinfo.inspect.obj.entity.*;
@ -58,6 +59,8 @@ public class ObjectServiceImpl extends BaseServiceImpl<InspectObjectMapper, Obje
private IObjectDangerService objectDangerService; private IObjectDangerService objectDangerService;
@Autowired @Autowired
private ProjectService projectService; private ProjectService projectService;
@Autowired
private IEmInfoClient emInfoClient;
/** pdf文件存储路径 */ /** pdf文件存储路径 */
@Value("${hzinfo.task.pdf.file-path}") @Value("${hzinfo.task.pdf.file-path}")
@ -268,15 +271,15 @@ public class ObjectServiceImpl extends BaseServiceImpl<InspectObjectMapper, Obje
templateProjectService.remove(queryWrapper); templateProjectService.remove(queryWrapper);
// 保存巡检模板与巡检项目的绑定关系 // 保存巡检模板与巡检项目的绑定关系
List<String> emCodeList = Func.toStrList(",", object.getEmCodes()); List<String> emCodeList = Func.toStrList(",", object.getEmCodes());
Function<Integer,TemplateProjectEntity> getTemplateProjectByEmCode = index -> { Function<String,TemplateProjectEntity> getTemplateProjectByEmCode = emCode -> {
ProjectEntity project = new ProjectEntity(); ProjectEntity project = new ProjectEntity();
project.setEmCode(emCodeList.get(index)); project.setEmCode(emCode);
project.setStatus(ObjectConstants.ProjectEnableEnum.YES.getEnableType()); project.setStatus(ObjectConstants.ProjectEnableEnum.YES.getEnableType());
ProjectEntity one = projectService.getOne(project); ProjectEntity one = projectService.getOne(project);
return TemplateProjectEntity.builder().templateId(template.getId()).projectId(one.getId()).sort(index).build(); return TemplateProjectEntity.builder().templateId(template.getId()).projectId(one.getId()).build();
}; };
List<TemplateProjectEntity> templateProjectList = Stream.iterate(0,n -> n + 1).limit(emCodeList.size()) List<TemplateProjectEntity> templateProjectList = Stream.iterate(0,n -> n + 1).limit(emCodeList.size())
.map(getTemplateProjectByEmCode).collect(Collectors.toList()); .flatMap(index -> emInfoClient.getChildrenByEmCode(emCodeList.get(index)).getData().stream()).map(getTemplateProjectByEmCode).collect(Collectors.toList());
templateProjectService.saveBatch(templateProjectList); templateProjectService.saveBatch(templateProjectList);
} }
} }

2
hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java

@ -25,6 +25,6 @@ public class ThreadPoolConfig {
@Bean @Bean
public ExecutorService appMessagePushExecutor() { public ExecutorService appMessagePushExecutor() {
return new ThreadPoolExecutor(2, 5, 5L, TimeUnit.SECONDS,new LinkedBlockingQueue<Runnable>()); return new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS,new LinkedBlockingQueue<Runnable>());
} }
} }

4
hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java

@ -51,7 +51,7 @@ public class MessagePushRecordController extends BladeController {
@ApiOperation("查询消息推送记录列表") @ApiOperation("查询消息推送记录列表")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
public R<List<MessagePushRecordEntity>> list(MessagePushRecordEntity request) { public R<List<MessagePushRecordEntity>> list(MessagePushRecordEntity request) {
return R.data(messagePushRecordService.list(request)); return R.data(messagePushRecordService.listNoUserScope(request));
} }
@GetMapping("/listPage") @GetMapping("/listPage")
@ -62,7 +62,7 @@ public class MessagePushRecordController extends BladeController {
title = "消息管理", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE, title = "消息管理", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE,
action = "分页查询消息推送记录列表") action = "分页查询消息推送记录列表")
public R<IPage<MessagePushRecordEntity>> listPage(MessagePushRecordEntity request, Query query) { public R<IPage<MessagePushRecordEntity>> listPage(MessagePushRecordEntity request, Query query) {
return R.data(messagePushRecordService.listPage(request, query)); return R.data(messagePushRecordService.listPageNoUserScope(request, query));
} }
@GetMapping("/send/{id}") @GetMapping("/send/{id}")

15
hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java

@ -22,6 +22,13 @@ public interface IMessagePushRecordService extends BaseService<MessagePushRecord
List<MessagePushRecordEntity> list(MessagePushRecordEntity request); List<MessagePushRecordEntity> list(MessagePushRecordEntity request);
/** /**
* 查询消息推送记录列表 - 无数据权限
* @param request
* @return
*/
List<MessagePushRecordEntity> listNoUserScope(MessagePushRecordEntity request);
/**
* 分页查询消息推送记录列表 * 分页查询消息推送记录列表
* @param request 查询条件 * @param request 查询条件
* @param query 分页 * @param query 分页
@ -29,6 +36,14 @@ public interface IMessagePushRecordService extends BaseService<MessagePushRecord
*/ */
IPage<MessagePushRecordEntity> listPage(MessagePushRecordEntity request, Query query); IPage<MessagePushRecordEntity> listPage(MessagePushRecordEntity request, Query query);
/**
* 分页查询消息推送记录列表 - 无数据权限
* @param request 查询条件
* @param query 分页
* @return 消息记录列表
*/
IPage<MessagePushRecordEntity> listPageNoUserScope(MessagePushRecordEntity request, Query query);
/** @Author hx /** @Author hx
* @Description 根据ID发送短信 * @Description 根据ID发送短信
* @Date 2023/4/4 17:37 * @Date 2023/4/4 17:37

10
hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java

@ -57,10 +57,20 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl<MessagePushRec
} }
@Override @Override
public List<MessagePushRecordEntity> listNoUserScope(MessagePushRecordEntity request) {
return noAurhScopeMapper.selectList(this.getQueryWrapper(request));
}
@Override
public IPage<MessagePushRecordEntity> listPage(MessagePushRecordEntity request, Query query) { public IPage<MessagePushRecordEntity> listPage(MessagePushRecordEntity request, Query query) {
return this.page(Condition.getPage(query), this.getQueryWrapper(request)); return this.page(Condition.getPage(query), this.getQueryWrapper(request));
} }
@Override
public IPage<MessagePushRecordEntity> listPageNoUserScope(MessagePushRecordEntity request, Query query) {
return noAurhScopeMapper.selectPage(Condition.getPage(query), this.getQueryWrapper(request));
}
/** /**
* @return java.lang.Boolean 推送结果 * @return java.lang.Boolean 推送结果
* @Author hx * @Author hx

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/controller/CentralMonitorController.java

@ -1,7 +1,9 @@
package com.hnac.hzims.operational.config.controller; package com.hnac.hzims.operational.config.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.config.service.CentralMonitorService; import com.hnac.hzims.operational.config.service.CentralMonitorService;
import com.hnac.hzims.operational.config.vo.PointDataVo;
import com.hnac.hzims.operational.station.service.IRealMonitorService; import com.hnac.hzims.operational.station.service.IRealMonitorService;
import com.hnac.hzims.operational.main.vo.RealStationVo; import com.hnac.hzims.operational.main.vo.RealStationVo;
import com.hnac.hzinfo.datasearch.PointData; import com.hnac.hzinfo.datasearch.PointData;
@ -57,7 +59,7 @@ public class CentralMonitorController extends BladeController {
public R selectCommunication(@PathVariable Integer page, public R selectCommunication(@PathVariable Integer page,
@PathVariable Integer size, @PathVariable Integer size,
String roleId){ String roleId){
HzPage<PointData> result = monitorService.selectOriginalDataByRealIds(page, size, roleId); IPage<PointDataVo> result = monitorService.selectOriginalDataByRealIds(page, size, roleId);
return R.data(result); return R.data(result);
} }
} }

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/CentralMonitorService.java

@ -1,6 +1,8 @@
package com.hnac.hzims.operational.config.service; package com.hnac.hzims.operational.config.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.config.vo.PointDataVo;
import com.hnac.hzims.operational.main.vo.RealStationVo; import com.hnac.hzims.operational.main.vo.RealStationVo;
import com.hnac.hzinfo.datasearch.PointData; import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.HzPage;
@ -26,6 +28,6 @@ public interface CentralMonitorService{
* @param roleId * @param roleId
* @return * @return
*/ */
HzPage<PointData> selectOriginalDataByRealIds(Integer page, Integer size, String roleId); IPage<PointDataVo> selectOriginalDataByRealIds(Integer page, Integer size, String roleId);
} }

31
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/service/impl/CentralMonitorServiceImpl.java

@ -1,10 +1,14 @@
package com.hnac.hzims.operational.config.service.impl; package com.hnac.hzims.operational.config.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.operational.config.service.CentralMonitorService; import com.hnac.hzims.operational.config.service.CentralMonitorService;
import com.hnac.hzims.operational.config.vo.PointDataVo;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.main.vo.RealStationVo; import com.hnac.hzims.operational.main.vo.RealStationVo;
import com.hnac.hzims.operational.ticket.fegin.StationFeginService;
import com.hnac.hzinfo.datasearch.PointData; import com.hnac.hzinfo.datasearch.PointData;
import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient;
import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; import com.hnac.hzinfo.datasearch.history.OriginalDataQuery;
@ -12,12 +16,15 @@ import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.core.response.Result;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
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.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -81,24 +88,38 @@ public class CentralMonitorServiceImpl implements CentralMonitorService {
* @return * @return
*/ */
@Override @Override
public HzPage<PointData> selectOriginalDataByRealIds(Integer page, Integer size, String roleId) { public IPage<PointDataVo> selectOriginalDataByRealIds(Integer page, Integer size, String roleId) {
OriginalDataQuery originalDataQuery = new OriginalDataQuery(); OriginalDataQuery originalDataQuery = new OriginalDataQuery();
originalDataQuery.setRealId(roleId); originalDataQuery.setRealId(roleId);
originalDataQuery.setLimit(size); originalDataQuery.setLimit(size);
LocalDateTime startTime = LocalDateTime.now(); LocalDateTime endTime = LocalDateTime.now();
LocalDateTime endTime = startTime.minusHours(1); LocalDateTime startTime = endTime.minusHours(1);
originalDataQuery.setBeginTime(this.getOriginalDate(startTime)); originalDataQuery.setBeginTime(this.getOriginalDate(startTime));
originalDataQuery.setEndTime(this.getOriginalDate(endTime)); originalDataQuery.setEndTime(this.getOriginalDate(endTime));
Result<HzPage<PointData>> originalDataByRealIds = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery); Result<HzPage<PointData>> originalDataByRealIds = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery);
if (!originalDataByRealIds.isSuccess()) { if (!originalDataByRealIds.isSuccess()) {
throw new IllegalArgumentException("数据不存在"); throw new ServiceException("数据不存在");
} }
return originalDataByRealIds.getData(); HzPage<PointData> data = originalDataByRealIds.getData();
List<PointDataVo> collect = data.getRecords().stream().map(item -> {
PointDataVo pointDataVo = new PointDataVo();
BeanUtils.copyProperties(item, pointDataVo);
//通过站点id获取站点名称
String station = pointDataVo.getStation();
String stationName = stationService.selectStationById(station);
pointDataVo.setStationName(stationName);
return pointDataVo;
}).collect(Collectors.toList());
IPage<PointDataVo> iPage = new Page(data.getCurrent(), data.getSize());
iPage.setRecords(collect);
return iPage;
} }
/** /**
* LocalDateTime date * LocalDateTime date
*
* @param localDateTime * @param localDateTime
* @return * @return
*/ */

45
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/vo/PointDataVo.java

@ -0,0 +1,45 @@
package com.hnac.hzims.operational.config.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/8/1 10:37
*/
@Data
public class PointDataVo {
/**
* 站点id
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
private String station;
/**
* 站点名称
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
private String stationName;
/**
* 数据采集时间
*/
private String time;
/**
* 数据
*/
private String value;
/**
* 质量值
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer q;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String signage;
}

236
hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/controller/BarChartDemo.java

@ -1,236 +0,0 @@
package com.hnac.hzims.operational.data.controller;
import java.awt.*;
import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import com.hnac.hzims.operational.report.vo.TicketChartCell;
import com.hnac.hzims.operational.report.vo.TicketChartVo;
import com.hnac.hzims.ticket.constants.TicketConstants;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.ChartUtils;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.StandardBarPainter;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
public class BarChartDemo {
// public static void main(String[] args) {
// // 1. 得到数据
// CategoryDataset dataset = getDataSetTicket();
//// CategoryDataset dataset = getDataSet();
//// CategoryDataset dataset = getDataSet3();
// // 2. 构造chart
// JFreeChart chart = ChartFactory.createBarChart(
// "水果产量图", // 图表标题
// "水果", // 目录轴的显示标签--横轴
// "产量", // 数值轴的显示标签--纵轴
// dataset, // 数据集
// PlotOrientation.VERTICAL, // 图表方向:水平、
// true, // 是否显示图例(对于简单的柱状图必须
// false, // 是否生成工具
// false // 是否生成URL链接
// );
// // 3. 处理chart中文显示问题
// iSetBarChart(chart);
//
// // 4. chart输出图片
//// writeChartAsImage(chart, "fruit.jpg");
// writeChartAsImage(chart, "ticket.jpg");
//
//// writeChartAsImage(chart, "fruit2.jpg");
//
// // 5. chart 以swing形式输出
// ChartFrame pieFrame = new ChartFrame("水果生产", chart);
// pieFrame.pack();
// pieFrame.setVisible(true);
//
// }
/**
* 获取一个演示用的组合数据集对象
*
* @return
*/
private static CategoryDataset getDataSet() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(100, "北京", "苹果");
dataset.addValue(120, "上海", "苹果");
dataset.addValue(160, "广州", "苹果");
dataset.addValue(210, "北京", "梨子");
dataset.addValue(220, "上海", "梨子");
dataset.addValue(230, "广州", "梨子");
dataset.addValue(330, "北京", "葡萄");
dataset.addValue(340, "上海", "葡萄");
dataset.addValue(340, "广州", "葡萄");
dataset.addValue(420, "北京", "香蕉");
dataset.addValue(430, "上海", "香蕉");
dataset.addValue(400, "广州", "香蕉");
dataset.addValue(510, "北京", "荔枝");
dataset.addValue(530, "上海", "荔枝");
dataset.addValue(510, "广州", "荔枝");
return dataset;
}
private static CategoryDataset getDataSet3() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(100, "北京", "苹果");
dataset.addValue(210, "北京", "梨子");
dataset.addValue(330, "北京", "葡萄");
dataset.addValue(420, "北京", "香蕉");
dataset.addValue(510, "北京", "荔枝");
return dataset;
}
private static CategoryDataset getDataSetTicket() {
List<TicketChartVo> ticketList = new ArrayList<>();
TicketConstants.TicketTypeNameEnum[] values = TicketConstants.TicketTypeNameEnum.values();
TicketChartVo sum=new TicketChartVo();
List<TicketChartCell> sas = new ArrayList<>();
sum.setDeptName("总计");
for (TicketConstants.TicketTypeNameEnum value : values) {
TicketChartCell ticketChartCell = new TicketChartCell();
ticketChartCell.setTicketType(value.getType());
ticketChartCell.setTicketName(value.getFileName());
Integer integer = Integer.valueOf(value.getType());
ticketChartCell.setTicketMon(30+ integer);
BigDecimal d=BigDecimal.valueOf(integer).divide(BigDecimal.valueOf(100),2,BigDecimal.ROUND_UP);
ticketChartCell.setTicketMonPerc(0.3+ d.doubleValue());
sas.add(ticketChartCell);
}
sum.setChartCells(sas);
ticketList.add(sum);
//两票柱状图数据
// 创建数据
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
// for (TicketChartVo chartVo : ticketList) {
// for (int i = 0; i < chartVo.getChartCells().size(); i++) {
// TicketChartCell ticketChartCell = chartVo.getChartCells().get(i);
// dataset.addValue(ticketChartCell.getTicketMon(), ticketChartCell.getTicketName(), ticketChartCell.getTicketName());
// }
// }
dataset.addValue(33+1, "", "倒闸操作票");
dataset.addValue(33+2,"", "开机操作票");
dataset.addValue(33+3,"", "停机操作票");
dataset.addValue(33+4,"", "第一种工作票");
dataset.addValue(33+5,"", "第二种工作票");
dataset.addValue(33+6,"", "水力机械票");
return dataset;
}
/**
* 解决图表汉字显示问题
*
* @param chart
*/
private static void processChart(JFreeChart chart) {
CategoryPlot plot = chart.getCategoryPlot();
CategoryAxis domainAxis = plot.getDomainAxis();
ValueAxis rAxis = plot.getRangeAxis();
chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
TextTitle textTitle = chart.getTitle();
textTitle.setFont(new Font("宋体", Font.PLAIN, 20));
domainAxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 11));
domainAxis.setLabelFont(new Font("宋体", Font.PLAIN, 12));
rAxis.setTickLabelFont(new Font("sans-serif", Font.PLAIN, 12));
rAxis.setLabelFont(new Font("宋体", Font.PLAIN, 12));
chart.getLegend().setItemFont(new Font("宋体", Font.PLAIN, 12));
// renderer.setItemLabelGenerator(new LabelGenerator(0.0));
// renderer.setItemLabelFont(new Font("宋体", Font.PLAIN, 12));
// renderer.setItemLabelsVisible(true);
}
/**
* 输出图片
*
* @param chart
*/
private static void writeChartAsImage(JFreeChart chart, String fileName) {
FileOutputStream fos_jpg = null;
try {
fos_jpg = new FileOutputStream("D:\\test\\"+fileName);
ChartUtils.writeChartAsJPEG(fos_jpg, 1, chart, 400, 300, null);
// ChartUtilities.writeChartAsJPEG(fos_jpg, 1, chart, 400, 300, null);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fos_jpg.close();
} catch (Exception e) {
}
}
}
public static void iSetBarChart(JFreeChart chart) {
CategoryPlot categoryplot = chart.getCategoryPlot();// 图本身
ValueAxis rangeAxis = categoryplot.getRangeAxis();
CategoryAxis domainAxis = categoryplot.getDomainAxis();
// 设置Y轴的提示文字样式
rangeAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// 设置Y轴刻度线的长度
rangeAxis.setTickMarkInsideLength(10f);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); // 横轴上的
domainAxis.setLowerMargin(0.1);
domainAxis.setUpperMargin(0.1);
// rangeAxis.setTickMarkOutsideLength(10f);
// 设置X轴下的标签文字
domainAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// 设置X轴上提示文字样式
domainAxis.setTickLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
NumberAxis vn = (NumberAxis) categoryplot.getRangeAxis();
// 设置Y轴的数字为百分比样式显示设置Y轴的数字为百分比样式显示
DecimalFormat df = new DecimalFormat("0.0");
vn.setNumberFormatOverride(df);
// 使柱状图反过来显示
// vn.setInverted(true);
// vn.setVerticalTickLabels(true);
// 自定义柱状图中柱子的样式
CustomRenderer brender = new CustomRenderer();
// 设置柱状图的顶端显示数字
brender.setIncludeBaseInRange(true);
brender.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
brender.setDefaultItemLabelsVisible(true);
// 设置柱子为平面图不是立体的
brender.setBarPainter(new StandardBarPainter());
// 设置柱状图之间的距离0.1代表10%;
brender.setItemMargin(0.3);
// 设置柱子的阴影,false代表没有阴影
brender.setShadowVisible(false);
// 设置图的背景为白色
categoryplot.setBackgroundPaint(Color.WHITE);
// 设置背景虚线的颜色
categoryplot.setRangeGridlinePaint(Color.decode("#B6A2DE"));
// 去掉柱状图的背景边框,使边框不可见
categoryplot.setOutlineVisible(false);
// 设置标题的字体样式
chart.getTitle().setFont(new Font("微软雅黑", Font.PLAIN, 24));
// 设置图表下方图例上的字体样式
chart.getLegend().setItemFont(new Font("微软雅黑", Font.PLAIN, 12));
categoryplot.setRenderer(brender);
}
}

30
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java

@ -14,6 +14,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog; import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
@ -22,8 +23,11 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@ -121,14 +125,32 @@ public class AreaMonthReportController extends BladeController {
public R exportHydropowerStationMonthReport(HttpServletResponse response, @ApiParam(value = "日期-年", required = true) Integer year,@ApiParam(value = "日期-月", required = true) Integer month, public R exportHydropowerStationMonthReport(HttpServletResponse response, @ApiParam(value = "日期-年", required = true) Integer year,@ApiParam(value = "日期-月", required = true) Integer month,
@ApiParam(value = "日期-日", required = true) Integer date,@ApiParam(value = "站点Id", required = true) Long stationId,@ApiParam(value = "月报类型", required = true) Long type) { @ApiParam(value = "日期-日", required = true) Integer date,@ApiParam(value = "站点Id", required = true) Long stationId,@ApiParam(value = "月报类型", required = true) Long type) {
if (type==1){
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
if (type==1){
service.exportHydropowerStationMonthReport(response, map,year,month,date,stationId); service.exportHydropowerStationMonthReport(response, map,year,month,date,stationId);
WordUtils.exportWord("template/waterMonV3.docx", "F:/", "生成月报.docx", map);
//word模板相对路径、word生成路径、word生成的文件名称、数据源 //word模板相对路径、word生成路径、word生成的文件名称、数据源
} }
XWPFDocument xwpfDocument = WordUtils.exportWordV2("template/waterMonReport.docx", map);
// 下载导出
String filename = "(" + year+"年"+month+"月"+ ")水电站月报";
// 设置头信息
response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel");
ServletOutputStream outputStream = null;
try {
//设置xlsx格式
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".docx", "UTF-8"));
//创建一个输出流
outputStream = response.getOutputStream();
return R.success("测试成功"); //写入数据
xwpfDocument.write(outputStream);
// 关闭
outputStream.close();
xwpfDocument.close();
} catch (IOException e) {
e.printStackTrace();
}
return R.data("导出成功");
} }
} }

501
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java

@ -3,6 +3,7 @@ package com.hnac.hzims.operational.main.service.impl;
import cn.afterturn.easypoi.entity.ImageEntity; import cn.afterturn.easypoi.entity.ImageEntity;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; import com.hnac.hzims.equipment.entity.PlanGenerationEntity;
import com.hnac.hzims.equipment.feign.IEmParamClient; import com.hnac.hzims.equipment.feign.IEmParamClient;
import com.hnac.hzims.equipment.feign.IPlanGenertionClient; import com.hnac.hzims.equipment.feign.IPlanGenertionClient;
@ -25,7 +26,6 @@ import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.util.JFreeUtil; import com.hnac.hzims.operational.util.JFreeUtil;
import com.hnac.hzims.operational.util.TimeUtils; import com.hnac.hzims.operational.util.TimeUtils;
import com.hnac.hzims.operational.util.WordUtils;
import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO; import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO;
import com.hnac.hzims.safeproduct.feign.ISafeCheckClient; import com.hnac.hzims.safeproduct.feign.ISafeCheckClient;
import com.hnac.hzims.safeproduct.feign.ISafeEquipmentTrialClient; import com.hnac.hzims.safeproduct.feign.ISafeEquipmentTrialClient;
@ -69,6 +69,7 @@ import java.math.BigDecimal;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@ -119,8 +120,6 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
private final ISafeCheckClient safeCheckClient; private final ISafeCheckClient safeCheckClient;
@Value("${hzims.operation.area.report}") @Value("${hzims.operation.area.report}")
private String area_month_report_key; private String area_month_report_key;
@ -202,9 +201,12 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
} }
return R.data("success"); return R.data("success");
} }
@Override @Override
public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Integer date, Long deptId) { public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap<String, Object> map, Integer year, Integer month, Integer date, Long deptId) {
R<List<Dept>> deptByCurrentUser = sysClient.getDeptByCurrentUser();
if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()!=null){
return R.fail("用户权限查询失败");
}
R<String> deptNameR = sysClient.getDeptName(deptId); R<String> deptNameR = sysClient.getDeptName(deptId);
if (!deptNameR.isSuccess()) { if (!deptNameR.isSuccess()) {
return R.fail("暂无该机构"); return R.fail("暂无该机构");
@ -218,7 +220,18 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
if (deptList == null) { if (deptList == null) {
return R.fail("该机构不包含水站信息"); return R.fail("该机构不包含水站信息");
} }
List<Long> deptByUser = deptByCurrentUser.getData().stream().map(s -> s.getId()).collect(Collectors.toList());
if (!deptByUser.contains(deptId)){
return R.fail("该用户不包含该机构权限,请申请权限再试");
}
List<Long> deptIds = deptList.stream().map(s -> s.getId()).collect(Collectors.toList()); List<Long> deptIds = deptList.stream().map(s -> s.getId()).collect(Collectors.toList());
List<StationEntity> stationEntityList = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.in(StationEntity::getRefDept, deptIds)
.eq(StationEntity::getType, HomePageConstant.HYDROPOWER));
Integer commissionTime = stationEntityList.stream().map(s -> {
Duration dur = Duration.between(s.getCommissionTime(), LocalDateTime.now());
return (int) dur.toDays();}).reduce(Integer::max).get();
List<Long> stationIds = stationEntityList.stream().map(s -> s.getId()).collect(Collectors.toList());
//其它普通数据 //其它普通数据
map.put("year", year); map.put("year", year);
Integer yearBefore = year - 1; Integer yearBefore = year - 1;
@ -227,48 +240,40 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
Integer monthBefore = month - 1; Integer monthBefore = month - 1;
map.put("monthBefore", monthBefore); map.put("monthBefore", monthBefore);
map.put("date", date); map.put("date", date);
map.put("commissionTime", "commissionTime"); map.put("commissionTime", commissionTime.toString());
map.put("stationName", deptName); map.put("stationName", deptName);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
map.put("writeTime", simpleDateFormat.format(new Date()));
List<HashMap<String, String>> safelist=new ArrayList<>();
List<HashMap<String, String>> form=new ArrayList<>();
for (Dept dept : deptList) {
HashMap<String, String> temp = new HashMap<>();
HashMap<String, String> temp2 = new HashMap<>();
temp.put("name", dept.getDeptName());
temp2.put("name", dept.getDeptName());
safelist.add(temp);
form.add(temp2);
}
map.put("safelist",safelist);
map.put("form",form);
map.put("form2",form);
// 今年年度 // 今年年度
String yearStart = TimeUtils.getYear(year); String yearStart = TimeUtils.getYear(year);
String yearEnd = TimeUtils.getYearEnd(year);
String yearEndV2 = TimeUtils.getYearEndV2(year); String yearEndV2 = TimeUtils.getYearEndV2(year);
//去年年度
String yearBeforeStart = TimeUtils.getYear(yearBefore);
String yearBeforeEnd = TimeUtils.getYearEnd(yearBefore);
// 今年当月 // 今年当月
String monthStart = TimeUtils.getMonthStart(year, month); String monthStart = TimeUtils.getMonthStart(year, month);
String monthEnd = TimeUtils.getMonthEnd(year, month);
String monthEndV2 = TimeUtils.getMonthEndV2(year, month); String monthEndV2 = TimeUtils.getMonthEndV2(year, month);
// 今年上个月
String beforeMonthStart = TimeUtils.getMonthStart(year, monthBefore);
String beforeMonthEnd = TimeUtils.getMonthEnd(year, monthBefore);
// 去年当月
String monthStartBeforeYear = TimeUtils.getMonthStart(yearBefore, month);
String monthEndBeforeYear = TimeUtils.getMonthEnd(yearBefore, month);
// 所有设备信息
List<EminfoAndEmParamVo> devices = mainSystemMonitoringService.getEmInfoList();
List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); List<HydropowerUnitRealVo> reals = (List<HydropowerUnitRealVo>) redisTemplate.opsForValue().get(load_hydropower_unit_real_key);
// R<Integer> installedCapacityCountByDepts = emParamClient.getInstalledCapacityCountByDepts(deptIds); List<HydropowerUnitRealVo> realsByDept = reals.stream().filter(s -> deptIds.contains(s.getDeptId())).collect(Collectors.toList());
// if (installedCapacityCountByDepts.isSuccess()){
// double sum = Optional.ofNullable(installedCapacityCountByDepts.getData())
// .orElse(new ArrayList<>()).stream()
// .filter(s -> s.getInstalledCapacity() != null)
// .mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum();
// map.put("installedCapacity", 0);
// }
// List<HydropowerUnitRealVo> realsByDept = reals.stream().filter(s -> deptIds.contains(s.getDeptId())).collect(Collectors.toList());
// TODO 伪造数据
List<HydropowerUnitRealVo> realsByDept = reals.stream().filter(s -> deptIds.contains(s.getDeptId())).map(s->{s.setInstalledCapacity(3.2);return s;}).collect(Collectors.toList());
// 装机容量占比数据组装 // 装机容量占比数据组装
//总容量 //总容量
double sum = Optional.ofNullable(realsByDept) double sum = Optional.ofNullable(realsByDept)
.orElse(new ArrayList<>()).stream() .orElse(new ArrayList<>()).stream()
.filter(s -> s.getInstalledCapacity() != null) .filter(s -> s.getInstalledCapacity() != null)
.mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum(); .mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum();
map.put("installedCapacity", sum); BigDecimal sumData=new BigDecimal(sum).divide(new BigDecimal(1000),2,BigDecimal.ROUND_UP);
map.put("installedCapacity", sumData);
//各站点分组 //各站点分组
Map<Long, List<HydropowerUnitRealVo>> listMap = Optional.ofNullable(realsByDept) Map<Long, List<HydropowerUnitRealVo>> listMap = Optional.ofNullable(realsByDept)
.orElse(new ArrayList<>()).stream() .orElse(new ArrayList<>()).stream()
@ -290,103 +295,60 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
ImageEntity capacityProportionChart = JFreeUtil.pieChartByDouble("水电项目装机容量占比图", capacityProportionMap, 500, 400); ImageEntity capacityProportionChart = JFreeUtil.pieChartByDouble("水电项目装机容量占比图", capacityProportionMap, 500, 400);
map.put("capacityProportionChart", capacityProportionChart); map.put("capacityProportionChart", capacityProportionChart);
//各发电站发电量环比图+表格数据组装 //各发电站发电量环比图+表格数据组装
List<String> deptIdsString = deptIds.stream().map(s -> String.valueOf(s)).collect(Collectors.toList());
List<PlanGenerationEntity> planYearData = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString());
List<MonPowerPercentageVo> powerPercentageVoList = new ArrayList<>(); List<MonPowerPercentageVo> powerPercentageVoList = new ArrayList<>();
for (Dept dept : deptList) { //水电站,光伏站和带代运维数据近三年数据
Map<Long, Map<String, Float>> powerMapThree = (Map<Long, Map<String, Float>>) redisTemplate.opsForValue().get(RECENT_YEAR_POWER_DATA);
List<String> listByYear = TimeUtils.getListByYear(year);
List<String> listByYearBefore = TimeUtils.getListByYear(yearBefore);
String monStart = TimeUtils.getMon(year, month);
String monStartYearBefore = TimeUtils.getMon(yearBefore, month);
String monStartMonBefore = TimeUtils.getMon(year, monthBefore);
for (Map.Entry<Long, Map<String, Float>> deviceMap : powerMapThree.entrySet()) {
String deptNameByKey = "";
if (stationIds.contains(deviceMap.getKey())) {
MonPowerPercentageVo powerVo = new MonPowerPercentageVo(); MonPowerPercentageVo powerVo = new MonPowerPercentageVo();
powerVo.setDeptId(dept.getId()); powerVo.setDeptId(deviceMap.getKey());
powerVo.setDeptName(dept.getDeptName()); List<StationEntity> collect = stationEntityList.stream().filter(s -> deviceMap.getKey().equals(s.getId())).collect(Collectors.toList());
if (collect!=null) {
Long dept = collect.get(0).getRefDept();
List<Dept> dep = deptList.stream().filter(s -> dept.equals(s.getId())).collect(Collectors.toList());
deptNameByKey=dep.get(0).getDeptName();
}
powerVo.setDeptName(deptNameByKey);
BigDecimal powerYear = new BigDecimal(0); BigDecimal powerYear = new BigDecimal(0);
BigDecimal powerYearBefore = new BigDecimal(0); BigDecimal powerYearBefore = new BigDecimal(0);
BigDecimal powerMonth = new BigDecimal(0); BigDecimal powerMonth = new BigDecimal(0);
BigDecimal powerMonthBefore = new BigDecimal(0); BigDecimal powerMonthBefore = new BigDecimal(0);
BigDecimal powerMonthYearBefore = new BigDecimal(0); BigDecimal powerMonthYearBefore = new BigDecimal(0);
Double planGeneration = 0d; Double planGeneration = 0d;
// todo shuju List<PlanGenerationEntity> planGenerationById = planYearData.stream().filter(s -> collect.get(0).getRefDept().equals(s.getStationDeptId())).collect(Collectors.toList());
// List<PlanGenerationEntity> planYearData = planGenertionClient.getPlanGenerationByParam(null, Arrays.asList(dept.getId().toString()), year.toString()); if (CollectionUtils.isNotEmpty(planGenerationById)) {
PlanGenerationEntity planGenerationEntity=new PlanGenerationEntity(); planGeneration = Double.valueOf(planGenerationById.get(0).getPlanGeneration());
planGenerationEntity.setPlanGeneration(2f);
List<PlanGenerationEntity> planYearData =new ArrayList<>();
planYearData.add(planGenerationEntity);
if (CollectionUtils.isNotEmpty(planYearData)) {
planGeneration = Double.valueOf(planYearData.get(0).getPlanGeneration());
} }
// 站点设备集合 //当前机构近三年的数据
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(dept.getId())).collect(Collectors.toList()); Map<String, Float> value = deviceMap.getValue();
for (EminfoAndEmParamVo device : stationDevices) {
//今年发电量 //今年发电量
// List<AnalyseDataTaosVO> analyseData = analyseDataService.periodTargetData(yearStart, yearEnd, 3, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION); powerYear=value.entrySet().stream().filter(s->listByYear.contains(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
AnalyseDataTaosVO analyseData1=new AnalyseDataTaosVO(); //转换单位kwh-》万Kwh
analyseData1.setVal("2"); powerYear=powerYear.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
List<AnalyseDataTaosVO> analyseData =new ArrayList<>(); powerYearBefore=value.entrySet().stream().filter(s->listByYearBefore.contains(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
analyseData.add(analyseData1); powerYearBefore=powerYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
// todo 数据还原 powerMonth=value.entrySet().stream().filter(s->monStart.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
if (CollectionUtil.isNotEmpty(analyseData)) { powerMonth=powerMonth.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
BigDecimal yearPower = analyseData.stream().filter(ktv -> ktv.getVal() != null) powerMonthBefore=value.entrySet().stream().filter(s->monStartMonBefore.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal()))) powerMonthBefore=powerMonthBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
.reduce(BigDecimal.ZERO, BigDecimal::add); powerMonthYearBefore=value.entrySet().stream().filter(s->monStartYearBefore.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add);
powerYear = powerYear.add(yearPower); powerMonthYearBefore=powerMonthYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP);
}
//去年发电量
// List<AnalyseDataTaosVO> analyseDataYearBefore = analyseDataService.periodTargetData(yearBeforeStart, yearBeforeEnd, 3, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
AnalyseDataTaosVO analyseDataYearBefore1=new AnalyseDataTaosVO();
analyseDataYearBefore1.setVal("16");
List<AnalyseDataTaosVO> analyseDataYearBefore =new ArrayList<>();
analyseDataYearBefore.add(analyseDataYearBefore1);
// todo 数据还原
if (CollectionUtil.isNotEmpty(analyseDataYearBefore)) {
BigDecimal powerBefore = analyseDataYearBefore.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerYearBefore = powerYearBefore.add(powerBefore);
}
//今年当月发电量
// List<AnalyseDataTaosVO> analyseDataMonth = analyseDataService.periodTargetData(monthStart, monthEnd, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
AnalyseDataTaosVO analyseDataMonth1=new AnalyseDataTaosVO();
analyseDataMonth1.setVal("0.66");
List<AnalyseDataTaosVO> analyseDataMonth =new ArrayList<>();
analyseDataMonth.add(analyseDataMonth1);
// todo 数据还原
if (CollectionUtil.isNotEmpty(analyseDataMonth)) {
BigDecimal powerBefore = analyseDataMonth.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonth = powerMonth.add(powerBefore);
}
//上个月发电量
// List<AnalyseDataTaosVO> analyseDataMonthBefore = analyseDataService.periodTargetData(beforeMonthStart, beforeMonthEnd, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
AnalyseDataTaosVO analyseDataMonthBefore1=new AnalyseDataTaosVO();
analyseDataMonthBefore1.setVal("0.56");
List<AnalyseDataTaosVO> analyseDataMonthBefore =new ArrayList<>();
analyseDataMonthBefore.add(analyseDataMonthBefore1);
// todo 数据还原
if (CollectionUtil.isNotEmpty(analyseDataMonthBefore)) {
BigDecimal powerBefore = analyseDataMonthBefore.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthBefore = powerMonthBefore.add(powerBefore);
}
//去年当月发电量
// List<AnalyseDataTaosVO> analyseDataMonthBeforeYear = analyseDataService.periodTargetData(monthStartBeforeYear, monthEndBeforeYear, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
AnalyseDataTaosVO analyseDataMonthBeforeYear1=new AnalyseDataTaosVO();
analyseDataMonthBeforeYear1.setVal("0.3");
List<AnalyseDataTaosVO> analyseDataMonthBeforeYear =new ArrayList<>();
analyseDataMonthBeforeYear.add(analyseDataMonthBeforeYear1);
// todo 数据还原
if (CollectionUtil.isNotEmpty(analyseDataMonthBeforeYear)) {
BigDecimal powerBefore = analyseDataMonthBeforeYear.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthYearBefore = powerMonthYearBefore.add(powerBefore);
}
}
powerVo.setPowerYear(powerYear.doubleValue()); powerVo.setPowerYear(powerYear.doubleValue());
powerVo.setPowerYearBefore(powerYearBefore.doubleValue()); powerVo.setPowerYearBefore(powerYearBefore.doubleValue());
BigDecimal yearPercentage = new BigDecimal(0); BigDecimal yearPercentage = new BigDecimal(0);
BigDecimal planPercentage = new BigDecimal(0); BigDecimal planPercentage = new BigDecimal(0);
if (powerYearBefore.compareTo(BigDecimal.ZERO)!=0) { if (powerYearBefore.compareTo(BigDecimal.ZERO) != 0) {
yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP); yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP);
} }
if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO)!=0) { if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO) != 0) {
planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP); planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP);
} }
powerVo.setPlanPercentage(planPercentage.doubleValue()); powerVo.setPlanPercentage(planPercentage.doubleValue());
@ -395,35 +357,35 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
powerVo.setPowerMonBefore(powerMonthBefore.doubleValue()); powerVo.setPowerMonBefore(powerMonthBefore.doubleValue());
powerVo.setPowerMonYearBefore(powerMonthYearBefore.doubleValue()); powerVo.setPowerMonYearBefore(powerMonthYearBefore.doubleValue());
BigDecimal monPercentage = new BigDecimal(0); BigDecimal monPercentage = new BigDecimal(0);
if (powerMonthYearBefore.compareTo(BigDecimal.ZERO)!=0) { if (powerMonthYearBefore.compareTo(BigDecimal.ZERO) != 0) {
monPercentage = (powerMonth.subtract(powerMonthYearBefore)).divide(powerMonthYearBefore, 2, BigDecimal.ROUND_UP); monPercentage = (powerMonth.subtract(powerMonthYearBefore)).divide(powerMonthYearBefore, 2, BigDecimal.ROUND_UP);
} }
powerVo.setPowerMonPercentage(monPercentage.doubleValue()); powerVo.setPowerMonPercentage(monPercentage.doubleValue());
powerPercentageVoList.add(powerVo); powerPercentageVoList.add(powerVo);
} }
}
// getPowerData(deptList, yearStart, yearEnd, yearBeforeStart, yearBeforeEnd, monthStart, monthEnd, beforeMonthStart, beforeMonthEnd, monthStartBeforeYear, monthEndBeforeYear, devices, planYearData, powerPercentageVoList);
// 各发电站发电量环比图数据组装 // 各发电站发电量环比图数据组装
//柱状图图数据 //柱状图图数据
// 创建数据 // 创建数据
DefaultCategoryDataset powerDataset = new DefaultCategoryDataset(); DefaultCategoryDataset powerDataset = new DefaultCategoryDataset();
for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) { for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) {
powerDataset.addValue(monPowerPercentageVo.getPowerMonYearBefore(),monthBefore +"月", monPowerPercentageVo.getDeptName()); powerDataset.addValue(monPowerPercentageVo.getPowerMonBefore(),monthBefore +"月", monPowerPercentageVo.getDeptName());
powerDataset.addValue(monPowerPercentageVo.getPowerMon(), month +"月", monPowerPercentageVo.getDeptName()); powerDataset.addValue(monPowerPercentageVo.getPowerMon(), month +"月", monPowerPercentageVo.getDeptName());
} }
String powerTitle=deptName+"水电运维项目各电站发电量环比对比图(万kWh)"; String powerTitle = deptName + "水电运维项目各电站发电量环比对比图(万kWh)";
String powerDomainAxis="发电量"; String powerDomainAxis = "发电量";
String powerRangeAxis="站点名称"; String powerRangeAxis = "站点名称";
ImageEntity powerChainHistogram = JFreeUtil.iCreateBarChart( powerTitle, powerDomainAxis, powerRangeAxis, powerDataset, 500, 400); ImageEntity powerChainHistogram = JFreeUtil.iCreateBarChart(powerTitle, powerDomainAxis, powerRangeAxis, powerDataset, 500, 400);
map.put("powerChainHistogram", powerChainHistogram); map.put("powerChainHistogram", powerChainHistogram);
//柱状图下的表格 //柱状图下添加的表格
if (powerPercentageVoList != null) { if (powerPercentageVoList != null) {
ArrayList<HashMap<String, String>> powerMap = new ArrayList<>(powerPercentageVoList.size()); ArrayList<HashMap<String, String>> powerMap = new ArrayList<>(powerPercentageVoList.size());
for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) { for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) {
HashMap<String, String> power = new HashMap<>(); HashMap<String, String> power = new HashMap<>();
power.put("name", monPowerPercentageVo.getDeptName()); power.put("name", monPowerPercentageVo.getDeptName());
power.put("monthBefore", String.valueOf(monPowerPercentageVo.getPowerMonBefore())); power.put("monthBefore", monPowerPercentageVo.getPowerMonBefore()+"MW");
power.put("month", String.valueOf(monPowerPercentageVo.getPowerMon())); power.put("month",monPowerPercentageVo.getPowerMon()+"MW");
powerMap.add(power); powerMap.add(power);
} }
map.put("power", powerMap); map.put("power", powerMap);
@ -440,11 +402,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
temp.put("name", monPowerPercentageVo.getDeptName()); temp.put("name", monPowerPercentageVo.getDeptName());
temp.put("powerMonBefore", String.valueOf(monPowerPercentageVo.getPowerMonYearBefore())); temp.put("powerMonBefore", String.valueOf(monPowerPercentageVo.getPowerMonYearBefore()));
temp.put("powerYearBefore", String.valueOf(monPowerPercentageVo.getPowerYearBefore())); temp.put("powerYearBefore", String.valueOf(monPowerPercentageVo.getPowerYearBefore()));
temp.put("mon",String.valueOf(monPowerPercentageVo.getPowerMon())); temp.put("mon", String.valueOf(monPowerPercentageVo.getPowerMon()));
temp.put("year",String.valueOf(monPowerPercentageVo.getPowerYear())); temp.put("year", String.valueOf(monPowerPercentageVo.getPowerYear()));
temp.put("monPercentage", monPowerPercentageVo.getPowerMonPercentage()*100+"%"); temp.put("monPercentage", monPowerPercentageVo.getPowerMonPercentage() * 100 + "%");
temp.put("yearPercentage", monPowerPercentageVo.getPowerYearPercentage()*100+"%"); temp.put("yearPercentage", monPowerPercentageVo.getPowerYearPercentage() * 100 + "%");
temp.put("plan",monPowerPercentageVo.getPlanPercentage()*100+"%"); temp.put("plan", monPowerPercentageVo.getPlanPercentage() * 100 + "%");
list.add(temp); list.add(temp);
} }
map.put("powerGeneration", list); map.put("powerGeneration", list);
@ -459,12 +421,14 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
wrapper.eq(OperPhenomenonEntity::getDiscriminateStatus, TreatMethodConstant.AUTO_SCREENED); wrapper.eq(OperPhenomenonEntity::getDiscriminateStatus, TreatMethodConstant.AUTO_SCREENED);
wrapper.in(OperPhenomenonEntity::getCreateDept, deptIds); wrapper.in(OperPhenomenonEntity::getCreateDept, deptIds);
List<OperPhenomenonEntity> monPhenomenonList = operPhenomenonService.list(wrapper); List<OperPhenomenonEntity> monPhenomenonList = operPhenomenonService.list(wrapper);
monPhenomenonList= monPhenomenonList.stream().filter(s -> s.getDefectLevel() != null).collect(Collectors.toList()); monPhenomenonList = monPhenomenonList.stream().filter(s -> s.getDefectLevel() != null).collect(Collectors.toList());
List<OperPhenomenonEntity> monConclusionList = monPhenomenonList.stream().filter(s -> s.getConclusionStatus().equals(1)).collect(Collectors.toList()); List<OperPhenomenonEntity> monConclusionList = monPhenomenonList.stream().filter(s -> s.getConclusionStatus().equals("1")).collect(Collectors.toList());
// 只填写二类及以上缺陷
List<OperPhenomenonEntity> monConclusionListBy = monConclusionList.stream().filter(s -> !s.getDefectGrading().equals("1")).collect(Collectors.toList());
// 各电站缺陷处理统计表 // 各电站缺陷处理统计表
monConclusionList.stream().sorted(Comparator.comparing(OperPhenomenonEntity::getDefectGrading).reversed().thenComparing(OperPhenomenonEntity::getCreateTime)); monConclusionListBy.stream().sorted(Comparator.comparing(OperPhenomenonEntity::getCreateDept).reversed().thenComparing(OperPhenomenonEntity::getDefectGrading));
ArrayList<HashMap<String, String>> checkList = new ArrayList<>(monConclusionList.size()); ArrayList<HashMap<String, String>> checkList = new ArrayList<>();
for (OperPhenomenonEntity operPhenomenonEntity : monConclusionList) { for (OperPhenomenonEntity operPhenomenonEntity : monConclusionListBy) {
Long createDept = operPhenomenonEntity.getCreateDept(); Long createDept = operPhenomenonEntity.getCreateDept();
R<String> createDeptName = sysClient.getDeptName(createDept); R<String> createDeptName = sysClient.getDeptName(createDept);
if (!createDeptName.isSuccess() && createDeptName.getData() != null) { if (!createDeptName.isSuccess() && createDeptName.getData() != null) {
@ -473,9 +437,21 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
//表格数据 //表格数据
HashMap<String, String> temp = new HashMap<>(); HashMap<String, String> temp = new HashMap<>();
temp.put("name", createDeptName.getData()); temp.put("name", createDeptName.getData());
temp.put("level", operPhenomenonEntity.getDefectGrading()); String checkLevel="";
temp.put("createTime", operPhenomenonEntity.getCreateTime().toString()); if(operPhenomenonEntity.getDefectGrading().equals("1")) {
temp.put("findTime", operPhenomenonEntity.getFindTime().toString()); checkLevel="Ⅰ级缺陷";
}
if(operPhenomenonEntity.getDefectGrading().equals("2") ){
checkLevel="Ⅱ级缺陷";
}
if(operPhenomenonEntity.getDefectGrading().equals("3") ){
checkLevel="Ⅲ级缺陷";
}
temp.put("level", checkLevel);
String createTime= simpleDateFormat.format(operPhenomenonEntity.getCreateTime());
temp.put("createTime", createTime);
String findTime= simpleDateFormat.format(operPhenomenonEntity.getFindTime());
temp.put("findTime", findTime);
temp.put("descripiton", operPhenomenonEntity.getDescripiton()); temp.put("descripiton", operPhenomenonEntity.getDescripiton());
temp.put("disposeDesc", operPhenomenonEntity.getDisposeDesc()); temp.put("disposeDesc", operPhenomenonEntity.getDisposeDesc());
checkList.add(temp); checkList.add(temp);
@ -490,8 +466,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
wrapperYear.eq(OperPhenomenonEntity::getDiscriminateStatus, TreatMethodConstant.AUTO_SCREENED); wrapperYear.eq(OperPhenomenonEntity::getDiscriminateStatus, TreatMethodConstant.AUTO_SCREENED);
wrapperYear.in(OperPhenomenonEntity::getCreateDept, deptIds); wrapperYear.in(OperPhenomenonEntity::getCreateDept, deptIds);
List<OperPhenomenonEntity> yearPhenomenonEntities = operPhenomenonService.list(wrapperYear); List<OperPhenomenonEntity> yearPhenomenonEntities = operPhenomenonService.list(wrapperYear);
yearPhenomenonEntities= yearPhenomenonEntities.stream().filter(s ->StringUtil.isNotBlank(s.getDefectGrading())).filter(s -> ObjectUtil.isNotEmpty(s.getCreateDept())).collect(Collectors.toList()); yearPhenomenonEntities = yearPhenomenonEntities.stream().filter(s -> StringUtil.isNotBlank(s.getDefectGrading())).filter(s -> ObjectUtil.isNotEmpty(s.getCreateDept())).collect(Collectors.toList());
List<OperPhenomenonEntity> yearConclusionList = yearPhenomenonEntities.stream().filter(s -> s.getConclusionStatus().equals(1)).collect(Collectors.toList()); List<OperPhenomenonEntity> yearConclusionList = yearPhenomenonEntities.stream().filter(s -> s.getConclusionStatus().equals("1")).collect(Collectors.toList());
ArrayList<HashMap<String, String>> checkStatistics = new ArrayList<>(); ArrayList<HashMap<String, String>> checkStatistics = new ArrayList<>();
List<CheckChartVo> checkChartRes = new ArrayList<>(); List<CheckChartVo> checkChartRes = new ArrayList<>();
@ -499,13 +475,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
//表格数据 //表格数据
HashMap<String, String> temp = new HashMap<>(); HashMap<String, String> temp = new HashMap<>();
temp.put("deptName", "总计"); temp.put("deptName", "总计");
temp.put("checkLevel", "0"); temp.put("checkLevel", "无等级");
temp.put("findShortagesMon", "0"); temp.put("findShortagesMon", "0");
temp.put("shortagesMon", "0"); temp.put("shortagesMon", "0");
temp.put("findShortagesYear", "0"); temp.put("findShortagesYear", "0");
temp.put("shortagesYear", "0"); temp.put("shortagesYear", "0");
temp.put("shortagesRate", "0"); temp.put("shortagesRate", "0%");
checkList.add(temp); checkStatistics.add(temp);
map.put("checkStatistics", checkStatistics); map.put("checkStatistics", checkStatistics);
} else { } else {
Map<Long, Map<String, List<OperPhenomenonEntity>>> phenomenonMap = yearPhenomenonEntities.stream().collect( Map<Long, Map<String, List<OperPhenomenonEntity>>> phenomenonMap = yearPhenomenonEntities.stream().collect(
@ -515,13 +491,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
R<String> deptName1 = sysClient.getDeptName(deptMapEntry.getKey()); R<String> deptName1 = sysClient.getDeptName(deptMapEntry.getKey());
for (Map.Entry<String, List<OperPhenomenonEntity>> levelList : deptMapEntry.getValue().entrySet()) { for (Map.Entry<String, List<OperPhenomenonEntity>> levelList : deptMapEntry.getValue().entrySet()) {
Integer findShortagesYear = levelList.getValue().size(); Integer findShortagesYear = levelList.getValue().size();
Integer shortagesYear = yearConclusionList.stream().filter(s -> s.getDefectLevel().equals(deptMapEntry)).filter(s -> s.getDefectLevel().equals(deptMapEntry)).collect(Collectors.toList()).size(); Integer shortagesYear = yearConclusionList.stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).collect(Collectors.toList()).size();
Double shortagesRate = 0d; Double shortagesRate = 0d;
if (findShortagesYear != 0 && shortagesYear != 0) { if (findShortagesYear != 0 && shortagesYear != 0) {
shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, BigDecimal.ROUND_UP).doubleValue(); shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, BigDecimal.ROUND_UP).doubleValue();
} }
Integer findShortagesMon = Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(deptMapEntry)).filter(s -> s.getDefectLevel().equals(deptMapEntry)).collect(Collectors.toList()).size(); Integer findShortagesMon = Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).collect(Collectors.toList()).size();
Integer shortagesMon = Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(deptMapEntry)).filter(s -> s.getDefectLevel().equals(deptMapEntry)).collect(Collectors.toList()).size(); Integer shortagesMon = Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelList.getKey())).collect(Collectors.toList()).size();
CheckChartVo checkChartVo = new CheckChartVo(deptName1.getData(), levelList.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate); CheckChartVo checkChartVo = new CheckChartVo(deptName1.getData(), levelList.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate);
checkChartRes.add(checkChartVo); checkChartRes.add(checkChartVo);
} }
@ -530,37 +506,41 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
Map<String, List<OperPhenomenonEntity>> levelPhenomenonList = yearPhenomenonEntities.stream().collect(Collectors.groupingBy(OperPhenomenonEntity::getDefectGrading)); Map<String, List<OperPhenomenonEntity>> levelPhenomenonList = yearPhenomenonEntities.stream().collect(Collectors.groupingBy(OperPhenomenonEntity::getDefectGrading));
for (Map.Entry<String, List<OperPhenomenonEntity>> levelPhenomenon : levelPhenomenonList.entrySet()) { for (Map.Entry<String, List<OperPhenomenonEntity>> levelPhenomenon : levelPhenomenonList.entrySet()) {
Integer findShortagesYear = levelPhenomenon.getValue().size(); Integer findShortagesYear = levelPhenomenon.getValue().size();
Integer shortagesYear = Optional.ofNullable(yearConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(levelPhenomenon)).collect(Collectors.toList()).size(); Integer shortagesYear = Optional.ofNullable(yearConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).collect(Collectors.toList()).size();
Double shortagesRate = 0d; Double shortagesRate = 0d;
if (findShortagesYear != 0 && shortagesYear != 0) { if (findShortagesYear != 0 && shortagesYear != 0) {
shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, BigDecimal.ROUND_UP).doubleValue(); shortagesRate = BigDecimal.valueOf(shortagesYear).divide(BigDecimal.valueOf(findShortagesYear), 2, BigDecimal.ROUND_UP).doubleValue();
} }
Integer findShortagesMon = Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(levelPhenomenon)).collect(Collectors.toList()).size(); Integer findShortagesMon = Optional.ofNullable(monPhenomenonList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).collect(Collectors.toList()).size();
Integer shortagesMon = Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectLevel().equals(levelPhenomenon)).collect(Collectors.toList()).size(); Integer shortagesMon = Optional.ofNullable(monConclusionList).orElse(new ArrayList<>()).stream().filter(s -> s.getDefectGrading().equals(levelPhenomenon.getKey())).collect(Collectors.toList()).size();
CheckChartVo checkChartVo = new CheckChartVo("总计", levelPhenomenon.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate); CheckChartVo checkChartVo = new CheckChartVo("总计", levelPhenomenon.getKey(), findShortagesMon, shortagesMon, findShortagesYear, shortagesYear, shortagesRate);
checkChartRes.add(checkChartVo); checkChartRes.add(checkChartVo);
} }
}
for (CheckChartVo checkChartRe : checkChartRes) { for (CheckChartVo checkChartRe : checkChartRes) {
//表格数据 //表格数据
HashMap<String, String> temp = new HashMap<>(); HashMap<String, String> temp = new HashMap<>();
temp.put("deptName", checkChartRe.getDeptName()); temp.put("deptName", checkChartRe.getDeptName());
temp.put("checkLevel", checkChartRe.getCheckLevel()); String checkLevel=null;
temp.put("findShortagesMon",checkChartRe.getFindShortagesMon().toString()); if(checkChartRe.getCheckLevel().equals("1")) {
temp.put("shortagesMon",checkChartRe.getShortagesMon().toString()); checkLevel="Ⅰ级缺陷";
}
if(checkChartRe.getCheckLevel().equals("2")) {
checkLevel="Ⅱ级缺陷";
}
if(checkChartRe.getCheckLevel().equals("3")) {
checkLevel="Ⅲ级缺陷";
}
temp.put("checkLevel", checkLevel);
temp.put("findShortagesMon", checkChartRe.getFindShortagesMon().toString());
temp.put("shortagesMon", checkChartRe.getShortagesMon().toString());
temp.put("findShortagesYear", checkChartRe.getShortagesYear().toString()); temp.put("findShortagesYear", checkChartRe.getShortagesYear().toString());
temp.put("shortagesYear", checkChartRe.getFindShortagesYear().toString()); temp.put("shortagesYear", checkChartRe.getFindShortagesYear().toString());
temp.put("shortagesRate", checkChartRe.getShortagesRate().toString()); temp.put("shortagesRate", checkChartRe.getShortagesRate()* 100 + "%");
checkList.add(temp); checkStatistics.add(temp);
map.put("checkStatistics", checkStatistics); map.put("checkStatistics", checkStatistics);
} }
}
// if (CollectionUtils.isNotEmpty(ticketNumbers)) {
// String percent = PercentCountUtils.getPercent(evaluateEntities.size(), ticketNumbers.size());
// ticketCount.setPercentPassTicket(percent);
// }
// 两票执行情况 // 两票执行情况
R<List<WorkTicketInfoEntity>> yearTicket = ticketInfoClient.getWorkTicketByTime(yearStart, yearEndV2); R<List<WorkTicketInfoEntity>> yearTicket = ticketInfoClient.getWorkTicketByTime(yearStart, yearEndV2);
R<List<StandardTicketInfoEntity>> yearOperateTicket = ticketInfoClient.getOperateTicketByTime(yearStart, yearEndV2); R<List<StandardTicketInfoEntity>> yearOperateTicket = ticketInfoClient.getOperateTicketByTime(yearStart, yearEndV2);
@ -572,7 +552,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
List<TicketChartVo> ticketList = new ArrayList<>(); List<TicketChartVo> ticketList = new ArrayList<>();
for (Dept dept : deptList) { for (Dept dept : deptList) {
String stationId = dept.getStationId(); String stationId = dept.getStationId();
if (stationId==null){ if (stationId == null) {
continue; continue;
} }
TicketChartVo chartVo = new TicketChartVo(); TicketChartVo chartVo = new TicketChartVo();
@ -582,61 +562,61 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
TicketChartCell ticketChartCell = new TicketChartCell(); TicketChartCell ticketChartCell = new TicketChartCell();
ticketChartCell.setTicketType(value.getType()); ticketChartCell.setTicketType(value.getType());
ticketChartCell.setTicketName(value.getFileName()); ticketChartCell.setTicketName(value.getFileName());
if (value.getTicketType()==2){ if (value.getTicketType() == 2) {
List<WorkTicketInfoEntity> yearTicketCollect = Optional.ofNullable(yearTicket.getData()).orElse(new ArrayList<>()).stream() List<WorkTicketInfoEntity> yearTicketCollect = Optional.ofNullable(yearTicket.getData()).orElse(new ArrayList<>()).stream()
.filter(s ->stationId.equals(s.getSignageCode())) .filter(s -> stationId.equals(s.getSignageCode()))
.filter(s -> s.getType().equals(value.getType())).collect(Collectors.toList()); .filter(s -> s.getType().equals(value.getType())).collect(Collectors.toList());
List<WorkTicketInfoEntity> monthTicketCollect = Optional.ofNullable(monthTicket.getData()).orElse(new ArrayList<>()).stream() List<WorkTicketInfoEntity> monthTicketCollect = Optional.ofNullable(monthTicket.getData()).orElse(new ArrayList<>()).stream()
.filter(s -> s.getSignageCode().equals(stationId)) .filter(s -> s.getSignageCode().equals(stationId))
.filter(s -> s.getType().equals(value.getType())).collect(Collectors.toList()); .filter(s -> s.getType().equals(value.getType())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(yearTicketCollect)){ if (CollectionUtils.isNotEmpty(yearTicketCollect)) {
//年合格率和数量 //年合格率和数量
Integer count = yearTicketCollect.size(); Integer count = yearTicketCollect.size();
ticketChartCell.setTicketYear(count); ticketChartCell.setTicketYear(count);
List<Long> ticketIds = yearTicketCollect.stream().map(s -> s.getId()).collect(Collectors.toList()); List<Long> ticketIds = yearTicketCollect.stream().map(s -> s.getId()).collect(Collectors.toList());
R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds); R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds);
if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null&&count!=0) { if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) {
Double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); Double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketYeaPercr(ticketYearPerc); ticketChartCell.setTicketYeaPercr(ticketYearPerc);
} }
} }
if (CollectionUtils.isNotEmpty(monthTicketCollect)){ if (CollectionUtils.isNotEmpty(monthTicketCollect)) {
//月合格率和数量 //月合格率和数量
Integer count = monthTicketCollect.size(); Integer count = monthTicketCollect.size();
ticketChartCell.setTicketMon(count); ticketChartCell.setTicketMon(count);
List<Long> monthTicketIds = monthTicketCollect.stream().map(s -> s.getId()).collect(Collectors.toList()); List<Long> monthTicketIds = monthTicketCollect.stream().map(s -> s.getId()).collect(Collectors.toList());
R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds); R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds);
if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null&&count!=0) { if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) {
Double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); Double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketMonPerc(ticketMonthPerc); ticketChartCell.setTicketMonPerc(ticketMonthPerc);
} }
} }
} }
if (value.getTicketType()==1){ if (value.getTicketType() == 1) {
List<StandardTicketInfoEntity> yearOperateCollect = Optional.ofNullable(yearOperateTicket.getData()).orElse(new ArrayList<>()).stream() List<StandardTicketInfoEntity> yearOperateCollect = Optional.ofNullable(yearOperateTicket.getData()).orElse(new ArrayList<>()).stream()
.filter(s ->stationId.equals(s.getSignageCode())) .filter(s -> stationId.equals(s.getSignageCode()))
.filter(s -> s.getTicketType().equals(value.getType())).collect(Collectors.toList()); .filter(s -> s.getTicketType().equals(value.getType())).collect(Collectors.toList());
List<StandardTicketInfoEntity> monthOperateCollect = Optional.ofNullable(monthOperateTicket.getData()).orElse(new ArrayList<>()).stream() List<StandardTicketInfoEntity> monthOperateCollect = Optional.ofNullable(monthOperateTicket.getData()).orElse(new ArrayList<>()).stream()
.filter(s -> s.getSignageCode().equals(stationId)) .filter(s -> s.getSignageCode().equals(stationId))
.filter(s -> s.getTicketType().equals(value.getType())).collect(Collectors.toList()); .filter(s -> s.getTicketType().equals(value.getType())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(yearOperateCollect)){ if (CollectionUtils.isNotEmpty(yearOperateCollect)) {
//年合格率和数量 //年合格率和数量
Integer count = yearOperateCollect.size(); Integer count = yearOperateCollect.size();
ticketChartCell.setTicketYear(count); ticketChartCell.setTicketYear(count);
List<Long> ticketIds = yearOperateCollect.stream().map(s -> s.getId()).collect(Collectors.toList()); List<Long> ticketIds = yearOperateCollect.stream().map(s -> s.getId()).collect(Collectors.toList());
R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds); R<Long> ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds);
if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null&&count!=0) { if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) {
Double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); Double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketYeaPercr(ticketYearPerc); ticketChartCell.setTicketYeaPercr(ticketYearPerc);
} }
} }
if (CollectionUtils.isNotEmpty(monthOperateCollect)){ if (CollectionUtils.isNotEmpty(monthOperateCollect)) {
//月合格率和数量 //月合格率和数量
Integer count = monthOperateCollect.size(); Integer count = monthOperateCollect.size();
ticketChartCell.setTicketMon(count); ticketChartCell.setTicketMon(count);
List<Long> monthTicketIds = monthOperateCollect.stream().map(s -> s.getId()).collect(Collectors.toList()); List<Long> monthTicketIds = monthOperateCollect.stream().map(s -> s.getId()).collect(Collectors.toList());
R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds); R<Long> ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds);
if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null&&count!=0) { if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) {
Double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); Double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue();
ticketChartCell.setTicketMonPerc(ticketMonthPerc); ticketChartCell.setTicketMonPerc(ticketMonthPerc);
} }
@ -647,11 +627,14 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
chartVo.setChartCells(cellList); chartVo.setChartCells(cellList);
ticketList.add(chartVo); ticketList.add(chartVo);
} }
List<TicketChartCell> sumCollect=new ArrayList<>(); List<TicketChartCell> allCollect = new ArrayList<>();
ticketList.stream().map(s -> sumCollect.addAll(s.getChartCells())); List<TicketChartCell> sumCollect = new ArrayList<>();
Map<String, List<TicketChartCell>> groupingCollect = sumCollect.stream().collect(Collectors.groupingBy(TicketChartCell::getTicketType)); for (TicketChartVo ticketChartVo : ticketList) {
allCollect.addAll( ticketChartVo.getChartCells());
}
Map<String, List<TicketChartCell>> groupingCollect = allCollect.stream().collect(Collectors.groupingBy(TicketChartCell::getTicketType));
for (Map.Entry<String, List<TicketChartCell>> mapTicketChart : groupingCollect.entrySet()) { for (Map.Entry<String, List<TicketChartCell>> mapTicketChart : groupingCollect.entrySet()) {
TicketChartCell sumCell=new TicketChartCell(); TicketChartCell sumCell = new TicketChartCell();
sumCell.setTicketType(mapTicketChart.getKey()); sumCell.setTicketType(mapTicketChart.getKey());
sumCell.setTicketName(TicketConstants.TicketTypeNameEnum.getTicketNameByType(mapTicketChart.getKey())); sumCell.setTicketName(TicketConstants.TicketTypeNameEnum.getTicketNameByType(mapTicketChart.getKey()));
List<TicketChartCell> ticketChartValue = mapTicketChart.getValue(); List<TicketChartCell> ticketChartValue = mapTicketChart.getValue();
@ -661,72 +644,132 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
sumCell.setTicketYeaPercr(ticketChartValue.stream().mapToDouble(TicketChartCell::getTicketYeaPercr).sum()); sumCell.setTicketYeaPercr(ticketChartValue.stream().mapToDouble(TicketChartCell::getTicketYeaPercr).sum());
sumCollect.add(sumCell); sumCollect.add(sumCell);
} }
TicketChartVo ticketChartVo=new TicketChartVo(); TicketChartVo ticketChartVo = new TicketChartVo();
ticketChartVo.setDeptName("总计"); ticketChartVo.setDeptName("总计");
ticketChartVo.setChartCells(sumCollect); ticketChartVo.setChartCells(sumCollect);
ticketList.add(ticketChartVo);
// 两票排序
ticketList.sort(Comparator.comparing(TicketChartVo::getDeptName,Comparator.reverseOrder()));
//两票表格数据 //两票表格数据
ArrayList<HashMap<String, String>> ticketListRes = new ArrayList<>(); ArrayList<HashMap<String, String>> ticketListRes = new ArrayList<>();
for (TicketChartVo chartVo : ticketList) { for (TicketChartVo chartVo : ticketList) {
HashMap<String, String> ticketMap = new HashMap<>(); HashMap<String, String> ticketMap = new HashMap<>();
HashMap<String, String> ticketMap2 = new HashMap<>();
for (TicketChartCell chartCell : chartVo.getChartCells()) { for (TicketChartCell chartCell : chartVo.getChartCells()) {
String ticketType = chartCell.getTicketType(); String ticketType = chartCell.getTicketType();
ticketMap.put("deptName",chartVo.getDeptName()); ticketMap.put("deptName", chartVo.getDeptName());
ticketMap.put("info","执行"); ticketMap2.put("deptName", chartVo.getDeptName());
ticketMap.put("infoPass","合格率"); ticketMap.put("info", "执行");
ticketMap.put("ticketMon"+ticketType,String.valueOf(chartCell.getTicketMon())); ticketMap2.put("info", "合格率");
ticketMap.put("ticketYear"+ticketType,String.valueOf(chartCell.getTicketYear())); ticketMap.put("ticketMon" + ticketType, String.valueOf(chartCell.getTicketMon()));
ticketMap.put("ticketMonPerc"+ticketType,String.valueOf(chartCell.getTicketMonPerc())); ticketMap.put("ticketYear" + ticketType, String.valueOf(chartCell.getTicketYear()));
ticketMap.put("ticketYeaPercr"+ticketType,String.valueOf(chartCell.getTicketYeaPercr())); ticketMap2.put("ticketMon" + ticketType, chartCell.getTicketMonPerc()* 100 + "%");
ticketMap2.put("ticketYear" + ticketType, chartCell.getTicketYeaPercr()* 100 + "%");
} }
ticketListRes.add(ticketMap); ticketListRes.add(ticketMap);
ticketListRes.add(ticketMap2);
} }
ticketListRes.sort(Comparator.comparing(o -> o.get("deptName")));
map.put("ticketList", ticketListRes); map.put("ticketList", ticketListRes);
//两票柱状图数据 //两票柱状图数据
// 创建数据 // 创建柱状和折线数据
DefaultCategoryDataset dataset = new DefaultCategoryDataset(); DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (TicketChartVo chartVo : ticketList) { for (TicketChartCell sumTicket : sumCollect) {
for (int i = 0; i < chartVo.getChartCells().size(); i++) { dataset.addValue(sumTicket.getTicketMon(), "数量", sumTicket.getTicketName());
TicketChartCell ticketChartCell = chartVo.getChartCells().get(i);
dataset.addValue(ticketChartCell.getTicketMon(), String.valueOf(i), ticketChartCell.getTicketName());
}
} }
DefaultCategoryDataset datasetLine = new DefaultCategoryDataset(); DefaultCategoryDataset datasetLine = new DefaultCategoryDataset();
for (TicketChartVo chartVo : ticketList) { for (TicketChartCell sumTicket : sumCollect) {
for (int i = 0; i < chartVo.getChartCells().size(); i++) { datasetLine.addValue(sumTicket.getTicketMonPerc(), "合格率", sumTicket.getTicketName());
TicketChartCell ticketChartCell = chartVo.getChartCells().get(i);
datasetLine.addValue(ticketChartCell.getTicketMonPerc(), ticketChartCell.getTicketName(), ticketChartCell.getTicketName());
}
} }
String title=deptName+"水电运维项目两票统计表"; String title = deptName + "水电运维项目两票统计表";
String domainAxis="数量"; String rangeAxis = "数量";
String rangeAxis="票据类型"; ImageEntity ticketImage = JFreeUtil.iCreateBarLineChart(true, title, null, rangeAxis, dataset, datasetLine, 662, 378);
ImageEntity ticketImage = JFreeUtil.iCreateBarLineChart(true, title, domainAxis, rangeAxis, dataset, datasetLine,662, 378);
map.put("ticketImage", ticketImage); map.put("ticketImage", ticketImage);
// //模拟表格数据
// ArrayList<HashMap<String, String>> list = new ArrayList<>(2);
//
// HashMap<String, String> temp = new HashMap<>(3);
// temp.put("name", "name1");
//// temp.put("name", "第一个人");
//// temp.put("age", "23");
// list.add(temp);
// temp = new HashMap<>(3);
// temp.put("name", "2");
//// temp.put("name", "第二个人");
//// temp.put("age", "24");
// list.add(temp);
// map.put("safelist", list);
// //模拟柱状图图数据
// String[] monthArray = {"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月"};
// double[] value = {20, 30, 25, 50, 40, 25, 50, 40};
// ImageEntity lineEntity = JFreeUtil.lineChart("测试111", monthArray, value, 300, 200);
// map.put("lineEntity", lineEntity);
return R.success("成功"); return R.success("成功");
}
private void getPowerData(List<Dept> deptList, String yearStart, String yearEnd, String yearBeforeStart, String yearBeforeEnd, String monthStart, String monthEnd, String beforeMonthStart, String beforeMonthEnd, String monthStartBeforeYear, String monthEndBeforeYear, List<EminfoAndEmParamVo> devices, List<PlanGenerationEntity> planYearData, List<MonPowerPercentageVo> powerPercentageVoList) {
for (Dept dept : deptList) {
MonPowerPercentageVo powerVo = new MonPowerPercentageVo();
powerVo.setDeptId(dept.getId());
powerVo.setDeptName(dept.getDeptName());
BigDecimal powerYear = new BigDecimal(0);
BigDecimal powerYearBefore = new BigDecimal(0);
BigDecimal powerMonth = new BigDecimal(0);
BigDecimal powerMonthBefore = new BigDecimal(0);
BigDecimal powerMonthYearBefore = new BigDecimal(0);
Double planGeneration = 0d;
List<PlanGenerationEntity> planGenerationById = planYearData.stream().filter(s -> dept.getId().equals(s.getCreateDept())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(planGenerationById)) {
planGeneration = Double.valueOf(planGenerationById.get(0).getPlanGeneration());
}
// 站点设备集合
List<EminfoAndEmParamVo> stationDevices = devices.stream().filter(device -> device.getCreateDept().equals(dept.getId())).collect(Collectors.toList());
for (EminfoAndEmParamVo device : stationDevices) {
//今年发电量
List<AnalyseDataTaosVO> analyseData = analyseDataService.periodTargetData(yearStart, yearEnd, 3, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
if (CollectionUtil.isNotEmpty(analyseData)) {
BigDecimal yearPower = analyseData.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerYear = powerYear.add(yearPower);
}
//去年发电量
List<AnalyseDataTaosVO> analyseDataYearBefore = analyseDataService.periodTargetData(yearBeforeStart, yearBeforeEnd, 3, EquipmentConstants.CycleTypeEnum.YEAR_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
if (CollectionUtil.isNotEmpty(analyseDataYearBefore)) {
BigDecimal powerBefore = analyseDataYearBefore.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerYearBefore = powerYearBefore.add(powerBefore);
}
//今年当月发电量
List<AnalyseDataTaosVO> analyseDataMonth = analyseDataService.periodTargetData(monthStart, monthEnd, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
if (CollectionUtil.isNotEmpty(analyseDataMonth)) {
BigDecimal powerBefore = analyseDataMonth.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonth = powerMonth.add(powerBefore);
}
//上个月发电量
List<AnalyseDataTaosVO> analyseDataMonthBefore = analyseDataService.periodTargetData(beforeMonthStart, beforeMonthEnd, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
if (CollectionUtil.isNotEmpty(analyseDataMonthBefore)) {
BigDecimal powerBefore = analyseDataMonthBefore.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthBefore = powerMonthBefore.add(powerBefore);
}
//去年当月发电量
List<AnalyseDataTaosVO> analyseDataMonthBeforeYear = analyseDataService.periodTargetData(monthStartBeforeYear, monthEndBeforeYear, 3, EquipmentConstants.CycleTypeEnum.MONTH_CYCLE.getType(), device.getEmCode(), HomePageConstant.ELECTRICITY_CONSUMPTION);
if (CollectionUtil.isNotEmpty(analyseDataMonthBeforeYear)) {
BigDecimal powerBefore = analyseDataMonthBeforeYear.stream().filter(ktv -> ktv.getVal() != null)
.map(ktv -> BigDecimal.valueOf(Double.valueOf(ktv.getVal())))
.reduce(BigDecimal.ZERO, BigDecimal::add);
powerMonthYearBefore = powerMonthYearBefore.add(powerBefore);
}
}
powerVo.setPowerYear(powerYear.doubleValue());
powerVo.setPowerYearBefore(powerYearBefore.doubleValue());
BigDecimal yearPercentage = new BigDecimal(0);
BigDecimal planPercentage = new BigDecimal(0);
if (powerYearBefore.compareTo(BigDecimal.ZERO) != 0) {
yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP);
}
if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO) != 0) {
planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP);
}
powerVo.setPlanPercentage(planPercentage.doubleValue());
powerVo.setPowerYearPercentage(yearPercentage.doubleValue());
powerVo.setPowerMon(powerMonth.doubleValue());
powerVo.setPowerMonBefore(powerMonthBefore.doubleValue());
powerVo.setPowerMonYearBefore(powerMonthYearBefore.doubleValue());
BigDecimal monPercentage = new BigDecimal(0);
if (powerMonthYearBefore.compareTo(BigDecimal.ZERO) != 0) {
monPercentage = (powerMonth.subtract(powerMonthYearBefore)).divide(powerMonthYearBefore, 2, BigDecimal.ROUND_UP);
}
powerVo.setPowerMonPercentage(monPercentage.doubleValue());
powerPercentageVoList.add(powerVo);
}
} }
private static void getTabelSum(Long deptId, List<MonPowerPercentageVo> powerPercentageVoList, List<PlanGenerationEntity> planYearAll, List<PlanGenerationEntity> planMonAll, HashMap<String, Object> map) { private static void getTabelSum(Long deptId, List<MonPowerPercentageVo> powerPercentageVoList, List<PlanGenerationEntity> planYearAll, List<PlanGenerationEntity> planMonAll, HashMap<String, Object> map) {
@ -752,15 +795,15 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
powerVo.setPowerYearBefore(powerYearBefore.doubleValue()); powerVo.setPowerYearBefore(powerYearBefore.doubleValue());
BigDecimal yearPercentage = new BigDecimal(0); BigDecimal yearPercentage = new BigDecimal(0);
BigDecimal planPercentage = new BigDecimal(0); BigDecimal planPercentage = new BigDecimal(0);
if (powerYearBefore.compareTo(BigDecimal.ZERO)!=0) { if (powerYearBefore.compareTo(BigDecimal.ZERO) != 0) {
// 年累计环比 // 年累计环比
yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP); yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP);
} }
if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO)!=0) { if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO) != 0) {
planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP); planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP);
// 年计划完成率 // 年计划完成率
map.put("yearCompletionRate", planPercentage.toString()); map.put("yearCompletionRate", planPercentage.toString());
}else { } else {
map.put("yearCompletionRate", 0); map.put("yearCompletionRate", 0);
} }
powerVo.setPowerYearPercentage(yearPercentage.doubleValue()); powerVo.setPowerYearPercentage(yearPercentage.doubleValue());
@ -773,7 +816,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
map.put("powerMon", powerMonth.toString()); map.put("powerMon", powerMonth.toString());
// 项目月计划完成量 // 项目月计划完成量
BigDecimal planMonPercentage = new BigDecimal(0); BigDecimal planMonPercentage = new BigDecimal(0);
if (powerMonth.compareTo(BigDecimal.ZERO)!=0 &&BigDecimal.valueOf(planMonGeneration).compareTo(BigDecimal.ZERO)!=0) { if (powerMonth.compareTo(BigDecimal.ZERO) != 0 && BigDecimal.valueOf(planMonGeneration).compareTo(BigDecimal.ZERO) != 0) {
planMonPercentage = powerMonth.divide(BigDecimal.valueOf(planMonGeneration), 2, BigDecimal.ROUND_UP); planMonPercentage = powerMonth.divide(BigDecimal.valueOf(planMonGeneration), 2, BigDecimal.ROUND_UP);
} }
map.put("monCompletionRate", planMonPercentage); map.put("monCompletionRate", planMonPercentage);
@ -786,12 +829,12 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService {
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
powerVo.setPowerMonYearBefore(powerMonthYearBefore.doubleValue()); powerVo.setPowerMonYearBefore(powerMonthYearBefore.doubleValue());
BigDecimal monPercentage = new BigDecimal(0); BigDecimal monPercentage = new BigDecimal(0);
if (powerMonthYearBefore.compareTo(BigDecimal.ZERO)!=0) { if (powerMonthYearBefore.compareTo(BigDecimal.ZERO) != 0) {
monPercentage =(powerMonth.subtract(powerMonthYearBefore)).divide(powerMonthYearBefore, 2, BigDecimal.ROUND_UP); monPercentage = (powerMonth.subtract(powerMonthYearBefore)).divide(powerMonthYearBefore, 2, BigDecimal.ROUND_UP);
} }
//发电量环比增加 //发电量环比增加
BigDecimal monAdd = powerMonth.subtract(powerMonthBefore); BigDecimal monAdd = powerMonth.subtract(powerMonthBefore);
if (powerMonthBefore.compareTo(BigDecimal.ZERO)==0) { if (powerMonthBefore.compareTo(BigDecimal.ZERO) == 0) {
map.put("percentageAdd", 0); map.put("percentageAdd", 0);
} else { } else {
map.put("percentageAdd", monAdd.divide(powerMonthBefore, 2, BigDecimal.ROUND_UP).toString()); map.put("percentageAdd", monAdd.divide(powerMonthBefore, 2, BigDecimal.ROUND_UP).toString());

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java

@ -131,4 +131,10 @@ public interface IStationService extends BaseService<StationEntity> {
*/ */
void uniqueStationByStation(String signage); void uniqueStationByStation(String signage);
/**
* 通过站点id获取站点名称
* @param station
* @return
*/
String selectStationById(String station);
} }

33
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -2,6 +2,7 @@ package com.hnac.hzims.operational.station.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.service.UserAuthDataService; import com.hnac.hzims.common.service.UserAuthDataService;
@ -37,6 +38,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
@ -106,19 +108,20 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
/** /**
* 推送站点 * 推送站点
*
* @param req 推送站点内容 * @param req 推送站点内容
*/ */
private void pushStation(StationEntity req) { private void pushStation(StationEntity req) {
// 读取站点类型配置确定是否推送FDP // 读取站点类型配置确定是否推送FDP
StationPushConfigEntity config = StationPushConfigEntity.builder().stationType(req.getType()).build(); StationPushConfigEntity config = StationPushConfigEntity.builder().stationType(req.getType()).build();
StationPushConfigVO configVO = stationPushConfigService.getOne(BeanUtil.copy(config, StationPushConfigDTO.class)); StationPushConfigVO configVO = stationPushConfigService.getOne(BeanUtil.copy(config, StationPushConfigDTO.class));
if(ObjectUtil.isNotEmpty(configVO) && configVO.getIsPush()) { if (ObjectUtil.isNotEmpty(configVO) && configVO.getIsPush()) {
log.info("{}站点开始智能诊断站点推送",req.getCode()); log.info("{}站点开始智能诊断站点推送", req.getCode());
new Thread(() -> questionClient.submitStationInfo(configVO.getFdpStationType(), req.getCode(), "运维平台推送"), "智能诊断站点推送").start(); new Thread(() -> questionClient.submitStationInfo(configVO.getFdpStationType(), req.getCode(), "运维平台推送"), "智能诊断站点推送").start();
} }
// 如果设备数据来源未选定其他 则进行站点初始化操作 // 如果设备数据来源未选定其他 则进行站点初始化操作
if (StationConstants.GATHER.equals(req.getDataOrigin()) && !StationConstants.HZ3000_OTHER.equals(req.getDataSource())) { if (StationConstants.GATHER.equals(req.getDataOrigin()) && !StationConstants.HZ3000_OTHER.equals(req.getDataSource())) {
log.info("{}站点开始数据平台新建项目",req.getCode()); log.info("{}站点开始数据平台新建项目", req.getCode());
new Thread(() -> this.instanceProject(req), "数据平台新建项目").start(); new Thread(() -> this.instanceProject(req), "数据平台新建项目").start();
} }
} }
@ -697,8 +700,30 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
LambdaQueryWrapper<StationEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StationEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StationEntity::getSignage, signage); queryWrapper.eq(StationEntity::getSignage, signage);
Integer count = baseMapper.selectCount(queryWrapper); Integer count = baseMapper.selectCount(queryWrapper);
if (count > 0){ if (count > 0) {
throw new ServiceException("两票编号抬头已存在"); throw new ServiceException("两票编号抬头已存在");
} }
} }
/**
* 通过站点id获取站点名称
*
* @param station
* @return
*/
@Override
public String selectStationById(String station) {
if (StringUtils.isEmpty(station)) {
return null;
}
QueryWrapper<StationEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(BaseEntity::getId, station);
queryWrapper.lambda().or().eq(StationEntity::getCode, station);
StationEntity stationEntity = baseMapper.selectOne(queryWrapper);
if (stationEntity != null) {
return stationEntity.getName();
}
return null;
}
} }

44
hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/JFreeUtil.java

@ -2,6 +2,7 @@ package com.hnac.hzims.operational.util;
import cn.afterturn.easypoi.entity.ImageEntity; import cn.afterturn.easypoi.entity.ImageEntity;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import com.hnac.hzims.operational.data.controller.CustomRenderer;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.XWPFTable; import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFactory;
@ -12,9 +13,7 @@ import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions; import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; import org.jfree.chart.labels.*;
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.DatasetRenderingOrder; import org.jfree.chart.plot.DatasetRenderingOrder;
import org.jfree.chart.plot.PiePlot; import org.jfree.chart.plot.PiePlot;
@ -23,6 +22,7 @@ import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.chart.renderer.category.LineAndShapeRenderer;
import org.jfree.chart.renderer.category.StandardBarPainter; import org.jfree.chart.renderer.category.StandardBarPainter;
import org.jfree.chart.ui.TextAnchor;
import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.DefaultPieDataset;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVMerge; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVMerge;
@ -288,14 +288,20 @@ public class JFreeUtil {
CategoryPlot categoryplot = chart.getCategoryPlot(); CategoryPlot categoryplot = chart.getCategoryPlot();
categoryplot.setDataset(1, datasetLine); categoryplot.setDataset(1, datasetLine);
LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer(); LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer();
//数据标签展示
lineandshaperenderer.setDefaultToolTipGenerator(new StandardCategoryToolTipGenerator()); lineandshaperenderer.setDefaultToolTipGenerator(new StandardCategoryToolTipGenerator());
lineandshaperenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator()); lineandshaperenderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
lineandshaperenderer.setDefaultLinesVisible(true); lineandshaperenderer.setDefaultLinesVisible(true);
lineandshaperenderer.setSeriesPaint(0, Color.decode("#9BBB59")); // lineandshaperenderer.setDefaultItemLabelPaint(Color.BLACK);
// lineandshaperenderer.setDefaultItemLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// lineandshaperenderer.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(
// ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_RIGHT));
lineandshaperenderer.setSeriesPaint(0, Color.BLACK);
categoryplot.setRenderer(1, lineandshaperenderer); categoryplot.setRenderer(1, lineandshaperenderer);
NumberAxis numberaxis = new NumberAxis("平均值"); NumberAxis numberaxis = new NumberAxis("合格率");
numberaxis.setLabelFont(new Font("宋体", Font.TRUETYPE_FONT, 12)); numberaxis.setLabelFont(new Font("微软雅黑", Font.TRUETYPE_FONT, 12));
categoryplot.setRangeAxis(1, numberaxis); categoryplot.setRangeAxis(1, numberaxis);
// // 显示折线图,1,1坐标轴都在右侧
categoryplot.mapDatasetToRangeAxis(1, 1); categoryplot.mapDatasetToRangeAxis(1, 1);
categoryplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); categoryplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
} }
@ -345,13 +351,16 @@ public class JFreeUtil {
CategoryAxis domainAxis = categoryplot.getDomainAxis(); CategoryAxis domainAxis = categoryplot.getDomainAxis();
// 设置Y轴的提示文字样式 // 设置Y轴的提示文字样式
rangeAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12)); rangeAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
// chart.setTextAntiAlias(false);
// 设置Y轴刻度线的长度 // 设置Y轴刻度线的长度
rangeAxis.setTickMarkInsideLength(10f); rangeAxis.setTickMarkInsideLength(10f);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); // 横轴上的 domainAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); // 横轴上的
domainAxis.setLowerMargin(0.1); domainAxis.setLowerMargin(0.1);
domainAxis.setUpperMargin(0.1); domainAxis.setUpperMargin(0.1);
// 设置横轴的label为45度
domainAxis.setMaximumCategoryLabelWidthRatio(4f);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
// rangeAxis.setTickMarkOutsideLength(10f); // rangeAxis.setTickMarkOutsideLength(10f);
// 设置X轴下的标签文字 // 设置X轴下的标签文字
domainAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12)); domainAxis.setLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
@ -367,17 +376,17 @@ public class JFreeUtil {
// vn.setVerticalTickLabels(true); // vn.setVerticalTickLabels(true);
// 自定义柱状图中柱子的样式 // 自定义柱状图中柱子的样式
BarRenderer brender = new BarRenderer(); CustomRenderer brender = new CustomRenderer();
brender.setSeriesPaint(0, Color.decode("#C0504D")); // 给series1 Bar
brender.setSeriesPaint(1, Color.decode("#E46C0A")); // 给series2 Bar
brender.setSeriesPaint(2, Color.decode("#4F81BD")); // 给series3 Bar
brender.setSeriesPaint(3, Color.decode("#00B050")); // 给series4 Bar
brender.setSeriesPaint(4, Color.decode("#7030A0")); // 给series5 Bar
brender.setSeriesPaint(5, Color.decode("#00BF00")); // 给series6 Bar
// 设置柱状图的顶端显示数字 // 设置柱状图的顶端显示数字
brender.setDefaultItemLabelsVisible(true);
brender.setIncludeBaseInRange(true); brender.setIncludeBaseInRange(true);
brender.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator()); brender.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
brender.setDefaultItemLabelsVisible(true); brender.setDefaultItemLabelPaint(Color.WHITE);
brender.setDefaultItemLabelFont(new Font("微软雅黑", Font.PLAIN, 12));
brender.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.INSIDE11, TextAnchor.TOP_LEFT));
brender.setMinimumBarLength(10);
// 设置柱子为平面图不是立体的 // 设置柱子为平面图不是立体的
brender.setBarPainter(new StandardBarPainter()); brender.setBarPainter(new StandardBarPainter());
// 设置柱状图之间的距离0.1代表10%; // 设置柱状图之间的距离0.1代表10%;
@ -437,8 +446,8 @@ public class JFreeUtil {
// brender.setSeriesPaint(5, Color.decode("#00BF00")); // 给series6 Bar // brender.setSeriesPaint(5, Color.decode("#00BF00")); // 给series6 Bar
// 设置柱状图的顶端显示数字 // 设置柱状图的顶端显示数字
brender.setIncludeBaseInRange(true); brender.setIncludeBaseInRange(true);
// brender.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); brender.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
// brender.setBaseItemLabelsVisible(isBaseItemLabelsVisible()); brender.setDefaultItemLabelsVisible(true);
// 设置柱子为平面图不是立体的 // 设置柱子为平面图不是立体的
brender.setBarPainter(new StandardBarPainter()); brender.setBarPainter(new StandardBarPainter());
// 设置柱状图之间的距离0.1代表10%; // 设置柱状图之间的距离0.1代表10%;
@ -459,7 +468,6 @@ public class JFreeUtil {
categoryplot.setRenderer(brender); categoryplot.setRenderer(brender);
} }

35
hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java

@ -2,8 +2,10 @@ package com.hnac.hzims.operational.util;
import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.DateUtil;
import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List;
public class TimeUtils { public class TimeUtils {
@ -108,4 +110,37 @@ public class TimeUtils {
String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 23:59:59"; String end = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) + " 23:59:59";
return end; return end;
} }
public static List<String> getListByYear(Integer year) {
List<String> monthList=new ArrayList<>();
for (int i = 1; i <13; i++) {
// 创建一个Calendar对象
Calendar calendar = Calendar.getInstance();
// 设置年份
calendar.set(Calendar.YEAR, Integer.valueOf(year));
// 设置月份为1(即一月)
calendar.set(Calendar.MONTH, i);
calendar.set(Calendar.DAY_OF_MONTH, 1);
// 将日期对象减去一天,即为当月的最后一天
String mon = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE);
monthList.add(mon);
}
return monthList;
}
public static String getMon(Integer year,Integer month) {
// 创建一个Calendar对象
Calendar calendar = Calendar.getInstance();
// 设置年份
calendar.set(Calendar.YEAR, year);
// 设置月份为1(即一月)
calendar.set(Calendar.MONTH, month-1);
// 设置日期为1
calendar.set(Calendar.DATE, 1);
// 设置时间为0点0分0秒
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) ;
return start;
}
} }

88
hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/WordUtils.java

@ -7,12 +7,17 @@ import com.hnac.hzims.operational.util.pojo.HttpResponse;
import freemarker.cache.StringTemplateLoader; import freemarker.cache.StringTemplateLoader;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.poi.xwpf.usermodel.XWPFTableCell;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -83,4 +88,87 @@ public abstract class WordUtils {
} }
} }
public static XWPFDocument exportWordV2(String templatePath, Map<String, Object> params) {
try {
XWPFDocument doc = WordExportUtil.exportWord07(templatePath, params);
// 合并第一列相同行的数据
tableIfSame(doc);
return doc;
} catch (Exception e) {
e.printStackTrace();
return new XWPFDocument();
}
}
/**
* 合并第一列相同行的数据
* @param xwpfDocument
*/
public static void tableIfSame(XWPFDocument xwpfDocument){
//获取文档中所有的表格
List<XWPFTable> tableList = xwpfDocument.getTables();
if (tableList.size()>0){
//循环表格
for (int tabIndex=0;tabIndex<tableList.size();tabIndex++){
XWPFTable xwpfTable = tableList.get(tabIndex);
//获取表格所有行数
List<XWPFTableRow> rows = xwpfTable.getRows();
for (int i = 0; i < rows.size(); i++) {
if (i==rows.size()-1){
continue;
}
XWPFTableCell cell = rows.get(i).getCell(0);
XWPFTableCell cell2 = rows.get(i+1).getCell(0);
String text = cell.getText();
String text2 = cell2.getText();
if (text2.equals(text)){
mergeCellsVertically(xwpfTable,0,i,i+1);
}
}
}
}
}
/**
* word单元格列合并
* @param table 表格
* @param row 合并列所在行
* @param startCell 开始列
* @param endCell 结束列
* @date 2020年4月8日 下午4:43:54
*/
public static void mergeCellsHorizontal(XWPFTable table, int row, int startCell, int endCell) {
for (int i = startCell; i <= endCell; i++) {
XWPFTableCell cell = table.getRow(row).getCell(i);
if (i == startCell) {
// The first merged cell is set with RESTART merge value
cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.RESTART);
} else {
// Cells which join (merge) the first one, are set with CONTINUE
cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.CONTINUE);
}
}
}
/**
* word单元格行合并
* @param table 表格
* @param col 合并行所在列
* @param startRow 开始行
* @param endRow 结束行
* @date 2020年4月8日 下午4:46:18
*/
public static void mergeCellsVertically(XWPFTable table, int col, int startRow, int endRow) {
for (int i = startRow; i <= endRow; i++) {
XWPFTableCell cell = table.getRow(i).getCell(col);
if (i == startRow) {
// The first merged cell is set with RESTART merge value
cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.RESTART);
} else {
// Cells which join (merge) the first one, are set with CONTINUE
cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.CONTINUE);
}
}
}
} }

BIN
hzims-service/operational/src/main/resources/template/waterMonReport.docx

Binary file not shown.
Loading…
Cancel
Save