Browse Source

#电量报表功能

zhongwei
yang_shj 4 months ago
parent
commit
68ac4c613d
  1. 46
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/ThirtyEntity.java
  2. 46
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/ThreeEntity.java
  3. 23
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/TableHeadVo.java
  4. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java
  5. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java
  6. 6
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/InstitutionalEntity.java
  7. 15
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/RectificationEntity.java
  8. 6
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/TrainEntity.java
  9. 6
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/ViolationEntity.java
  10. 38
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/ElectricReportController.java
  11. 12
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThirtyMapper.java
  12. 5
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThirtyMapper.xml
  13. 13
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThreeMapper.java
  14. 5
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThreeMapper.xml
  15. 12
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IElectricReportService.java
  16. 11
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/ThirtyService.java
  17. 11
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/ThreeService.java
  18. 385
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java
  19. 20
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ThirtyServiceImpl.java
  20. 20
      hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ThreeServiceImpl.java
  21. 3
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java
  22. 14
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java
  23. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java
  24. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/train/service/impl/ViolationServiceImpl.java
  25. 15
      hzims-service/safeproduct/src/main/resources/dict/dict.sql

46
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/ThirtyEntity.java

@ -0,0 +1,46 @@
package com.hnac.hzims.electric.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import java.math.BigDecimal;
/**
* 实体类
*
* @author Chill
*/
@Data
@TableName("hzims_em_thirty_generate")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "设备30天发电量对象", description = "")
public class ThirtyEntity extends TenantEntity {
@ApiModelProperty(value = "站点编码")
private String stationId;
@ApiModelProperty(value = "站点名称")
private String stationName;
@ApiModelProperty(value = "设备编号")
private String deviceCode;
@ApiModelProperty(value = "设备名称")
private String deviceName;
@ApiModelProperty(value = "月份 : String")
private String strDay;
@ApiModelProperty(value = "月份 : Int")
private Integer day;
@ApiModelProperty(value = "发电量")
private BigDecimal generate;
@ApiModelProperty(value = "无功发电量")
private BigDecimal reactiveGenerate;
}

46
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/entity/ThreeEntity.java

@ -0,0 +1,46 @@
package com.hnac.hzims.electric.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import java.math.BigDecimal;
/**
* 实体类
*
* @author Chill
*/
@Data
@TableName("hzims_em_three_generate")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "设备3年发电量对象", description = "")
public class ThreeEntity extends TenantEntity {
@ApiModelProperty(value = "站点编码")
private String stationId;
@ApiModelProperty(value = "站点名称")
private String stationName;
@ApiModelProperty(value = "设备编号")
private String deviceCode;
@ApiModelProperty(value = "设备名称")
private String deviceName;
@ApiModelProperty(value = "月份 : String")
private String strMonth;
@ApiModelProperty(value = "月份 : Int")
private Integer month;
@ApiModelProperty(value = "发电量")
private BigDecimal generate;
@ApiModelProperty(value = "无功电量")
private BigDecimal reactiveGenerate;
}

23
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/electric/vo/TableHeadVo.java

@ -0,0 +1,23 @@
package com.hnac.hzims.electric.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author 表头
*/
@Data
public class TableHeadVo {
@ApiModelProperty(value = "表头名字")
private String tableName;
@ApiModelProperty(value = "是否存在子表头")
private Boolean isChildren;
@ApiModelProperty(value = "子表头列表")
private List<String> children;
}

5
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java

@ -33,6 +33,8 @@ public interface IStationClient {
String GET_STATIONS_BY_TYPE_AND_DURATION = API_PREFIX + "/getStationByTypeAndDuration";
String QUERY_STATION_BY_CODES = API_PREFIX + "/querySatationByCodes";
String GET_STATIONS_BY_REF_DEPTS = API_PREFIX + "/getStationsByRefDepts";
@GetMapping(GET_LIST_ALL)
R<List<StationEntity>> getListAll();
@ -86,4 +88,7 @@ public interface IStationClient {
R<List<StationEntity>> getStationByTypeAndDuration(@RequestParam(value = "startTime",required = false) String startTime,
@RequestParam(value = "endTime",required = false) String endTime,
@RequestParam(value = "type",required = false) String type);
@GetMapping(GET_STATIONS_BY_REF_DEPTS)
R<List<StationEntity>> getStationsByRefDepts(@RequestParam(value = "deptIds",required = false) List<Long> deptIds);
}

5
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java

@ -82,4 +82,9 @@ public class IStationClientFallBack implements IStationClient {
public R<List<StationEntity>> getStationByTypeAndDuration(String startTime, String endTime, String type) {
return R.fail("远程调用失败!");
}
@Override
public R<List<StationEntity>> getStationsByRefDepts(List<Long> deptIds) {
return R.fail("远程调用失败!");
}
}

6
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/InstitutionalEntity.java

@ -41,4 +41,10 @@ public class InstitutionalEntity extends TenantEntity {
@ApiModelProperty(value = "附件名称")
private String dataAttachmentName;
@ApiModelProperty(value = "添加人ID")
private String createUserId;
@ApiModelProperty(value = "添加人名称")
private String createUserName;
}

15
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/RectificationEntity.java

@ -1,11 +1,14 @@
package com.hnac.hzims.safeproduct.train.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@ -34,12 +37,18 @@ public class RectificationEntity extends TenantEntity {
private Integer rectificationType;
@ApiModelProperty(value = "限时日期")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private Date limitTime;
@ApiModelProperty(value = "提醒日期")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private Date remindTime;
@ApiModelProperty(value = "完成日期")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private Date completeTime;
@ApiModelProperty(value = "问题事项")
@ -53,4 +62,10 @@ public class RectificationEntity extends TenantEntity {
@ApiModelProperty(value = "问题附件名称")
private String problemAttachmentName;
@ApiModelProperty(value = "添加人ID")
private String createUserId;
@ApiModelProperty(value = "添加人名称")
private String createUserName;
}

6
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/TrainEntity.java

@ -62,4 +62,10 @@ public class TrainEntity extends TenantEntity {
@ApiModelProperty(value = "培训附件名称")
private String trainAttachmentName;
@ApiModelProperty(value = "添加人ID")
private String createUserId;
@ApiModelProperty(value = "添加人名称")
private String createUserName;
}

6
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/train/entity/ViolationEntity.java

@ -59,4 +59,10 @@ public class ViolationEntity extends TenantEntity {
@ApiModelProperty(value = "通知单附件名称")
private String noticeAttachmentName;
@ApiModelProperty(value = "添加人ID")
private String createUserId;
@ApiModelProperty(value = "添加人名称")
private String createUserName;
}

38
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/controller/ElectricReportController.java

@ -0,0 +1,38 @@
package com.hnac.hzims.electric.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.electric.service.IElectricReportService;
import com.hnac.hzims.equipment.entity.EmAssociationEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @author ysj
*/
@RestController
@AllArgsConstructor
@RequestMapping("/electric")
@Api(tags = "电量报表")
public class ElectricReportController extends BladeController {
private final IElectricReportService service;
@GetMapping("/basics")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "基础报表", notes = "传入 type : 0-日报 1-月报 2-年报")
public R<Map<String,Object>> basics(@RequestParam(value = "deptId",required = false) Long deptId,
@RequestParam(value = "type") Long type,
@RequestParam(value = "time") String time) {
return R.data(service.basics(deptId,type,time));
}
}

12
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThirtyMapper.java

@ -0,0 +1,12 @@
package com.hnac.hzims.electric.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.electric.entity.ThirtyEntity;
/**
* @author ysj
*/
public interface ThirtyMapper extends BaseMapper<ThirtyEntity> {
}

5
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThirtyMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.hnac.hzims.electric.mapper.ThirtyMapper">
</mapper>

13
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThreeMapper.java

@ -0,0 +1,13 @@
package com.hnac.hzims.electric.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.electric.entity.ThreeEntity;
/**
* @author ysj
*/
public interface ThreeMapper extends BaseMapper<ThreeEntity> {
}

5
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/mapper/ThreeMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.hnac.hzims.electric.mapper.ThreeMapper">
</mapper>

12
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/IElectricReportService.java

@ -0,0 +1,12 @@
package com.hnac.hzims.electric.service;
import java.util.Map;
/**
* @author ysj
*/
public interface IElectricReportService {
Map<String, Object> basics(Long deptId, Long type,String time);
}

11
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/ThirtyService.java

@ -0,0 +1,11 @@
package com.hnac.hzims.electric.service;
import com.hnac.hzims.electric.entity.ThirtyEntity;
import org.springblade.core.mp.base.BaseService;
/**
* @author ysj
*/
public interface ThirtyService extends BaseService<ThirtyEntity> {
}

11
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/ThreeService.java

@ -0,0 +1,11 @@
package com.hnac.hzims.electric.service;
import com.hnac.hzims.electric.entity.ThreeEntity;
import org.springblade.core.mp.base.BaseService;
/**
* @author ysj
*/
public interface ThreeService extends BaseService<ThreeEntity> {
}

385
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ElectricReportServiceImpl.java

@ -0,0 +1,385 @@
package com.hnac.hzims.electric.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.electric.entity.ThirtyEntity;
import com.hnac.hzims.electric.entity.ThreeEntity;
import com.hnac.hzims.electric.service.IElectricReportService;
import com.hnac.hzims.electric.service.ThirtyService;
import com.hnac.hzims.electric.service.ThreeService;
import com.hnac.hzims.electric.vo.TableHeadVo;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author ysj
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class ElectricReportServiceImpl implements IElectricReportService {
private final ThreeService threeService;
private final ThirtyService thirtyService;
private final ISysClient sysClient;
private final IStationClient stationClient;
/**
* 基础报表
* @param deptId
* @param type
* @return
*/
@Override
public Map<String, Object> basics(Long deptId, Long type,String time) {
Map<String, Object> result = new HashMap<>();
// 步骤1.查询当前用户权限机构
R<List<Dept>> depts = sysClient.getDeptByCurrentUser();
// 步骤2.确认机构级别
Integer category = this.category(depts.getData(),deptId);
if(category < 0){
return result;
}
// 步骤3.根据级别进行查询发电数据
switch (category){
case 4:
return this.station(deptId,type,time);
case 3:
List<Long> deptIds = depts.getData().stream().filter(dept->dept.getParentId().equals(deptId)).map(Dept::getId).collect(Collectors.toList());
return this.area(deptIds,type,time);
case 2:
case 1:
//return this.group();
default:
return result;
}
}
/**
* 确认机构级别
* @param deptId
* @return
*/
private Integer category(List<Dept> depts,Long deptId) {
if(ObjectUtil.isEmpty(deptId)){
if(CollectionUtil.isEmpty(depts)){
return -1;
}
Optional<Dept> optional = depts.stream().min(Comparator.comparing(Dept::getDeptCategory));
return optional.get().getDeptCategory();
}
R<Dept> dept = sysClient.getDept(deptId);
if(!dept.isSuccess() || ObjectUtil.isEmpty(dept)){
return -1;
}
return dept.getData().getDeptCategory();
}
/**
* 区域级别数据
* @param deptIds
* @param type
* @param time
* @return
*/
private Map<String, Object> area(List<Long> deptIds, Long type, String time) {
// 查询站点
R<List<StationEntity>> stations = stationClient.getStationsByRefDepts(deptIds);
if(!stations.isSuccess() || ObjectUtil.isEmpty(stations.getData())){
return new HashMap<>();
}
Map<String,Object> result = new HashMap<>();
// 月
if (type == 1) {
// 查询月数据
List<ThirtyEntity> thirtys = thirtyService.list(Wrappers.<ThirtyEntity>lambdaQuery()
//.isNotNull(ThirtyEntity::getDeviceCode)
.in(ThirtyEntity::getStationId,stations.getData().stream().map(StationEntity::getCode).collect(Collectors.toList()))
.like(ThirtyEntity::getStrDay,time)
);
if(CollectionUtil.isEmpty(thirtys)){
return new HashMap<>();
}
// 表头
List<TableHeadVo> tableHeads = new ArrayList<>();
TableHeadVo firstHead = new TableHeadVo();
firstHead.setTableName("日期");
firstHead.setIsChildren(false);
tableHeads.add(firstHead);
TableHeadVo secondHead = new TableHeadVo();
secondHead.setTableName("日总计发电量");
secondHead.setIsChildren(true);
secondHead.setChildren(Arrays.asList("日总有功","日总无功"));
tableHeads.add(secondHead);
// 根据设备分组
Map<String,List<ThirtyEntity>> group = thirtys.stream().collect(Collectors.groupingBy(ThirtyEntity::getStationName));
group.keySet().stream().sorted().forEach(key->{
TableHeadVo tableHead = new TableHeadVo();
tableHead.setTableName(key + "发电量(kWh)");
tableHead.setIsChildren(true);
tableHead.setChildren(Arrays.asList("日有功","日无功"));
tableHeads.add(tableHead);
});
result.put("tableHead",tableHeads);
// 组装数据
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse(time + "-01 00:00:00",DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.MONTH,1);
Date end = calendar.getTime();
calendar.add(Calendar.MONTH,-1);
Date start = calendar.getTime();
List<List<Object>> tableDate = new ArrayList<>();
while (start.compareTo(end) < 0){
List<Object> item = new ArrayList<>();
String day = DateUtil.format(start,DateUtil.PATTERN_DATE);
item.add(start.getDate() + "日");
// 总计:有功、无功
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum());
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum());
// 遍历站点
group.entrySet().stream().sorted(Map.Entry.
comparingByKey()).forEach(entry->{
item.add(entry.getValue().stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum());
item.add(entry.getValue().stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum());
});
calendar.add(Calendar.DAY_OF_MONTH,1);
start = calendar.getTime();
tableDate.add(item);
}
result.put("tableDate",tableDate);
}
// 年
else if (type == 2) {
// 查询月数据
List<ThreeEntity> threes = threeService.list(Wrappers.<ThreeEntity>lambdaQuery()
.isNotNull(ThreeEntity::getDeviceCode)
.in(ThreeEntity::getStationId,stations.getData().stream().map(StationEntity::getCode).collect(Collectors.toList()))
.like(ThreeEntity::getStrMonth,time)
);
if(CollectionUtil.isEmpty(threes)){
return new HashMap<>();
}
// 表头
List<TableHeadVo> tableHeads = new ArrayList<>();
TableHeadVo firstHead = new TableHeadVo();
firstHead.setTableName("月份");
firstHead.setIsChildren(false);
tableHeads.add(firstHead);
TableHeadVo secondHead = new TableHeadVo();
secondHead.setTableName("月总计发电量");
secondHead.setIsChildren(true);
secondHead.setChildren(Arrays.asList("月总有功","月总无功"));
tableHeads.add(secondHead);
// 根据站点分组
Map<String,List<ThreeEntity>> group = threes.stream().collect(Collectors.groupingBy(ThreeEntity::getStationName));
group.keySet().stream().sorted().forEach(key->{
TableHeadVo tableHead = new TableHeadVo();
tableHead.setTableName(key + "发电量(kWh)");
tableHead.setIsChildren(true);
tableHead.setChildren(Arrays.asList("月有功","月无功"));
tableHeads.add(tableHead);
});
result.put("tableHead",tableHeads);
// 组装数据
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse(time + "-01-01 00:00:00",DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.YEAR,1);
Date end = calendar.getTime();
calendar.add(Calendar.YEAR,-1);
Date start = calendar.getTime();
List<List<Object>> tableDate = new ArrayList<>();
while (start.compareTo(end) < 0){
List<Object> item = new ArrayList<>();
String mon = DateUtil.format(start,"yyyy-MM");
item.add(start.getMonth() + 1 + "月");
// 总计:有功、无功
item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum());
item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum());
// 遍历站点
group.entrySet().stream().sorted(Map.Entry.
comparingByKey()).forEach(entry->{
item.add(entry.getValue().stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum());
item.add(entry.getValue().stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum());
});
calendar.add(Calendar.MONTH,1);
start = calendar.getTime();
tableDate.add(item);
}
result.put("tableDate",tableDate);
}
return result;
}
/**
* 站点级别数据
* @param deptId
* @param type
* @return
*/
private Map<String, Object> station(Long deptId, Long type,String time) {
// 查询站点
StationEntity param = new StationEntity();
param.setRefDept(deptId);
R<StationEntity> station = stationClient.getStationByCodeOrRedDept(param);
if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){
return new HashMap<>();
}
Map<String,Object> result = new HashMap<>();
// 日
if (type == 0) {
}
// 月
else if (type == 1) {
// 查询月数据
List<ThirtyEntity> thirtys = thirtyService.list(Wrappers.<ThirtyEntity>lambdaQuery()
.isNotNull(ThirtyEntity::getDeviceCode)
.eq(ThirtyEntity::getStationId,station.getData().getCode())
.like(ThirtyEntity::getStrDay,time)
);
if(CollectionUtil.isEmpty(thirtys)){
return new HashMap<>();
}
// 表头
List<TableHeadVo> tableHeads = new ArrayList<>();
TableHeadVo firstHead = new TableHeadVo();
firstHead.setTableName("日期");
firstHead.setIsChildren(false);
tableHeads.add(firstHead);
TableHeadVo secondHead = new TableHeadVo();
secondHead.setTableName("日总计发电量");
secondHead.setIsChildren(true);
secondHead.setChildren(Arrays.asList("日总有功","日总无功"));
tableHeads.add(secondHead);
// 根据设备分组
Map<String,List<ThirtyEntity>> group = thirtys.stream().collect(Collectors.groupingBy(ThirtyEntity::getDeviceName));
group.keySet().stream().sorted().forEach(key->{
TableHeadVo tableHead = new TableHeadVo();
tableHead.setTableName(key + "发电量(kWh)");
tableHead.setIsChildren(true);
tableHead.setChildren(Arrays.asList("日有功","日无功"));
tableHeads.add(tableHead);
});
result.put("tableHead",tableHeads);
// 组装数据
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse(time + "-01 00:00:00",DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.MONTH,1);
Date end = calendar.getTime();
calendar.add(Calendar.MONTH,-1);
Date start = calendar.getTime();
List<List<Object>> tableDate = new ArrayList<>();
while (start.compareTo(end) < 0){
List<Object> item = new ArrayList<>();
String day = DateUtil.format(start,DateUtil.PATTERN_DATE);
item.add(start.getDate() + "日");
// 总计:有功、无功
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum());
item.add(thirtys.stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum());
// 遍历机组
group.entrySet().stream().sorted(Map.Entry.
comparingByKey()).forEach(entry->{
item.add(entry.getValue().stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getGenerate().doubleValue()).sum());
item.add(entry.getValue().stream().filter(thirty -> thirty.getStrDay().contains(day)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum());
});
calendar.add(Calendar.DAY_OF_MONTH,1);
start = calendar.getTime();
tableDate.add(item);
}
result.put("tableDate",tableDate);
}
// 年
else if (type == 2) {
// 查询月数据
List<ThreeEntity> threes = threeService.list(Wrappers.<ThreeEntity>lambdaQuery()
.isNotNull(ThreeEntity::getDeviceCode)
.eq(ThreeEntity::getStationId,station.getData().getCode())
.like(ThreeEntity::getStrMonth,time)
);
if(CollectionUtil.isEmpty(threes)){
return new HashMap<>();
}
// 表头
List<TableHeadVo> tableHeads = new ArrayList<>();
TableHeadVo firstHead = new TableHeadVo();
firstHead.setTableName("月份");
firstHead.setIsChildren(false);
tableHeads.add(firstHead);
TableHeadVo secondHead = new TableHeadVo();
secondHead.setTableName("月总计发电量");
secondHead.setIsChildren(true);
secondHead.setChildren(Arrays.asList("月总有功","月总无功"));
tableHeads.add(secondHead);
// 根据设备分组
Map<String,List<ThreeEntity>> group = threes.stream().collect(Collectors.groupingBy(ThreeEntity::getDeviceName));
group.keySet().stream().sorted().forEach(key->{
TableHeadVo tableHead = new TableHeadVo();
tableHead.setTableName(key + "发电量(kWh)");
tableHead.setIsChildren(true);
tableHead.setChildren(Arrays.asList("月有功","月无功"));
tableHeads.add(tableHead);
});
result.put("tableHead",tableHeads);
// 组装数据
Calendar calendar = Calendar.getInstance();
calendar.setTime(DateUtil.parse(time + "-01-01 00:00:00",DateUtil.PATTERN_DATETIME));
calendar.add(Calendar.YEAR,1);
Date end = calendar.getTime();
calendar.add(Calendar.YEAR,-1);
Date start = calendar.getTime();
List<List<Object>> tableDate = new ArrayList<>();
while (start.compareTo(end) < 0){
List<Object> item = new ArrayList<>();
String mon = DateUtil.format(start,"yyyy-MM");
item.add(start.getMonth() + 1 + "月");
// 总计:有功、无功
item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum());
item.add(threes.stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum());
// 遍历机组
group.entrySet().stream().sorted(Map.Entry.
comparingByKey()).forEach(entry->{
item.add(entry.getValue().stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getGenerate().doubleValue()).sum());
item.add(entry.getValue().stream().filter(three -> three.getStrMonth().contains(mon)).mapToDouble(o->o.getReactiveGenerate().doubleValue()).sum());
});
calendar.add(Calendar.MONTH,1);
start = calendar.getTime();
tableDate.add(item);
}
result.put("tableDate",tableDate);
}
return result;
}
}

20
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ThirtyServiceImpl.java

@ -0,0 +1,20 @@
package com.hnac.hzims.electric.service.impl;
import com.hnac.hzims.electric.entity.ThirtyEntity;
import com.hnac.hzims.electric.mapper.ThirtyMapper;
import com.hnac.hzims.electric.service.ThirtyService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* @author ysj
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class ThirtyServiceImpl extends BaseServiceImpl<ThirtyMapper, ThirtyEntity> implements ThirtyService {
}

20
hzims-service/equipment/src/main/java/com/hnac/hzims/electric/service/impl/ThreeServiceImpl.java

@ -0,0 +1,20 @@
package com.hnac.hzims.electric.service.impl;
import com.hnac.hzims.electric.entity.ThreeEntity;
import com.hnac.hzims.electric.mapper.ThreeMapper;
import com.hnac.hzims.electric.service.ThreeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* @author ysj
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class ThreeServiceImpl extends BaseServiceImpl<ThreeMapper, ThreeEntity> implements ThreeService {
}

3
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/offline/service/impl/InspectOfflineServiceImpl.java

@ -967,7 +967,8 @@ public class InspectOfflineServiceImpl implements IOfflineDataService {
public R<BladeFile> putFile(File file) throws IOException {
FileItem fileItem = new DiskFileItem("file", Files.probeContentType(file.toPath()),false,file.getName(),(int)file.length(),file.getParentFile());
try (InputStream inputStream = new FileInputStream(file); OutputStream os = fileItem.getOutputStream()){
try (InputStream inputStream = new FileInputStream(file);
OutputStream os = fileItem.getOutputStream()){
IOUtils.copy(inputStream,os);
/*

14
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java

@ -256,14 +256,14 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProces
detail.setId(null);
contentService.save(detail);
if(CollectionUtil.isNotEmpty(detail.getAccessContentDetails())){
List<OperAccessContentDetailEntity> contentDetails = contentDetailService.list(new LambdaQueryWrapper<OperAccessContentDetailEntity>() {{
eq(OperAccessContentDetailEntity::getContentId, detail.getId());
}});
// 先删除
if(CollectionUtil.isNotEmpty(contentDetails)){
contentDetailService.removeByIds(contentDetails.stream().map(OperAccessContentDetailEntity::getId).collect(Collectors.toList()));
}
for (OperAccessContentDetailDTO contentDetail : detail.getAccessContentDetails()){
List<OperAccessContentDetailEntity> contentDetails = contentDetailService.list(new LambdaQueryWrapper<OperAccessContentDetailEntity>() {{
eq(OperAccessContentDetailEntity::getContentId, detail.getId());
}});
// 先删除
if(CollectionUtil.isNotEmpty(contentDetails)){
contentDetailService.removeByIds(contentDetails.stream().map(OperAccessContentDetailEntity::getId).collect(Collectors.toList()));
}
// 再保存
contentDetail.setId(null);
contentDetail.setContentId(detail.getId());

11
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java

@ -12,6 +12,7 @@ import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
@ -150,6 +151,16 @@ public class StationClient implements IStationClient {
return R.data(stationService.list(wrapper));
}
@Override
@GetMapping("/getStationsByRefDepts")
public R<List<StationEntity>> getStationsByRefDepts(@RequestParam(value = "deptIds" , required = false) List<Long> deptIds) {
LambdaQueryWrapper<StationEntity> wrapper = new LambdaQueryWrapper<>();
if(CollectionUtil.isNotEmpty(deptIds)) {
wrapper.in(StationEntity::getRefDept,deptIds);
}
return R.data(stationService.list(wrapper));
}
@Override
@PostMapping("/getStationByCodeOrRedDept")

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/train/service/impl/ViolationServiceImpl.java

@ -30,13 +30,13 @@ public class ViolationServiceImpl extends ServiceImpl<ViolationMapper, Violation
LambdaQueryWrapper<ViolationEntity> wrapper = new LambdaQueryWrapper();
wrapper.orderByDesc(ViolationEntity::getCreateTime);
if(StringUtil.isNotBlank(params.getStationId())){
wrapper.eq(ViolationEntity::getStationId,params.getStartTime());
wrapper.eq(ViolationEntity::getStationId,params.getStationId());
}
if(StringUtil.isNotBlank(params.getStartTime())){
wrapper.ge(ViolationEntity::getDiscoverTime,params.getStartTime());
}
if(StringUtil.isNotBlank(params.getEndTime())){
wrapper.eq(ViolationEntity::getDiscoverTime,params.getEndTime());
wrapper.le(ViolationEntity::getDiscoverTime,params.getEndTime());
}
if(ObjectUtil.isNotEmpty(params.getViolationLevel())){
wrapper.eq(ViolationEntity::getViolationLevel,params.getViolationLevel());

15
hzims-service/safeproduct/src/main/resources/dict/dict.sql

@ -40,3 +40,18 @@ insert into `bladex`.`blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_v
insert into `bladex`.`blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) values (1811421133117767768, 1810401848933404699, 'inner_danger_type', '3', '物的不安全行为', 5, '', 0, 0, 1, -1, 'hzims_safeproduct');
insert into `bladex`.`blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) values (1811421133117767769, 1810401848933404699, 'inner_danger_type', '4', '管理因素', 5, '', 0, 0, 1, -1, 'hzims_safeproduct');
insert into `bladex`.`blade_dict`(`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) values (1811421133117767770, 1810401848933404699, 'inner_danger_type', '5', '其他', 5, '', 0, 0, 1, -1, 'hzims_safeproduct');
#违章级别
INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748001, 0, 'violation_level', '-1', '违章级别', 1, '', 0, 0, 0, -1, 'hzims_safeproduct');
INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748002, 1397731100361748001, 'violation_level', '0', '严重', 1, '', 0, 0, 0, -1, 'hzims_safeproduct');
INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748003, 1397731100361748001, 'violation_level', '1', '一般', 2, '', 0, 0, 0, -1, 'hzims_safeproduct');
#整改类型
INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748101, 0, 'rectification_type', '-1', '整改类型', 1, '', 0, 0, 0, -1, 'hzims_safeproduct');
INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748102, 1397731100361748101, 'rectification_type', '0', '整改闭环', 1, '', 0, 0, 0, -1, 'hzims_safeproduct');
INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748103, 1397731100361748101, 'rectification_type', '1', '会议督办', 2, '', 0, 0, 0, -1, 'hzims_safeproduct');
#整改状态
INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748201, 0, 'rectification_status', '-1', '整改状态', 1, '', 0, 0, 0, -1, 'hzims_safeproduct');
INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748202, 1397731100361748201, 'rectification_status', '0', '未整改', 1, '', 0, 0, 0, -1, 'hzims_safeproduct');
INSERT INTO `bladex`.`blade_dict` (`id`, `parent_id`, `code`, `dict_key`, `dict_value`, `sort`, `remark`, `is_sealed`, `is_deleted`, `dict_type`, `app_id`, `app_code`) VALUES (1397731100361748203, 1397731100361748201, 'rectification_status', '1', '已整改', 2, '', 0, 0, 0, -1, 'hzims_safeproduct');
Loading…
Cancel
Save