Commit 0274405b authored by chenzhao's avatar chenzhao

Merge branch 'developer' of http://39.98.45.134:8090/moa/amos-boot-biz into developer

# Conflicts: # amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/entity/IdxBizFelk.java # amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/mapper2/IdxBizUxfvMapper.java # amos-boot-system-jxiop/amos-boot-module-jxiop-analyse-biz/src/main/resources/mapper/cluster/IdxBizUxfvMapper.xml
parents 43ca2635 c9a930ad
......@@ -26,6 +26,11 @@
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.22</version>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-influxdb</artifactId>
<version>1.8.5-SNAPSHOT</version>
......
......@@ -16,8 +16,6 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
/**
*
*
* @author system_generator
* @date 2023-08-11
*/
......@@ -35,22 +33,31 @@ public class TestController extends BaseController {
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "列表全部数据查询-风电", notes = "列表全部数据查询")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "列表全部数据查询-风电", notes = "列表全部数据查询")
@GetMapping(value = "/listfan")
public ResponseModel<List<IdxBizC80c>> selectForListFan() {
return ResponseHelper.buildResponse(commonServiceImpl.getAllFanstationTestPoint().subList(0,20));
return ResponseHelper.buildResponse(commonServiceImpl.getAllFanstationTestPoint().subList(0, 20));
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "列表全部数据查询-光伏", notes = "列表全部数据查询")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "列表全部数据查询-光伏", notes = "列表全部数据查询")
@GetMapping(value = "/listpv")
public ResponseModel<List<IdxBizHjev>> selectForListPV() {
return ResponseHelper.buildResponse(commonServiceImpl.getAllPVstationTestPoint().subList(0,20));
return ResponseHelper.buildResponse(commonServiceImpl.getAllPVstationTestPoint().subList(0, 20));
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "test", notes = "列表全部数据查询")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "test", notes = "列表全部数据查询")
@GetMapping(value = "/test")
public void selectForListTest() {
commonServiceImpl.getGateWayId();
commonServiceImpl.getIdxBizUxfvList();
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "test", notes = "列表全部数据查询")
@GetMapping(value = "/getDateByTime")
public void getDateByTime(@RequestParam String startTime, @RequestParam String endTime) {
commonServiceImpl.getConditionVariablesByTime(startTime, endTime);
}
}
......@@ -45,10 +45,10 @@ public class IdxBizC80cDto {
private Double correlationCoefficient;
@TableField("ANALYSIS_POINT_ID")
private Integer analysisPointId;
private Long analysisPointId;
@TableField("PROCESS_POINT_ID")
private Integer processPointId;
private Long processPointId;
@ApiModelProperty(value = "片区")
@TableField("ARAE")
......
......@@ -45,10 +45,10 @@ public class IdxBizHjevDto {
private Double correlationCoefficient;
@TableField("ANALYSIS_POINT_ID")
private Integer analysisPointId;
private Long analysisPointId;
@TableField("PROCESS_POINT_ID")
private Integer processPointId;
private Long processPointId;
@ApiModelProperty(value = "片区")
@TableField("ARAE")
......
......@@ -4,7 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -36,7 +37,7 @@ public class IdxBiz208l {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......@@ -96,13 +97,13 @@ public class IdxBiz208l {
*
*/
@TableField("ANALYSIS_START_TIME")
private LocalDateTime analysisStartTime;
private Date analysisStartTime;
/**
*
*/
@TableField("ANALYSIS_END_TIME")
private LocalDateTime analysisEndTime;
private Date analysisEndTime;
/**
* 片区
......
......@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -39,7 +38,7 @@ public class IdxBiz3yud {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......
......@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -39,7 +38,7 @@ public class IdxBiz59c8 {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......
......@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -39,7 +38,7 @@ public class IdxBizAahn {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......
......@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -39,7 +38,7 @@ public class IdxBizBtlq {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......
......@@ -69,13 +69,13 @@ public class IdxBizC80c {
*
*/
@TableField("ANALYSIS_POINT_ID")
private Integer analysisPointId;
private Long analysisPointId;
/**
*
*/
@TableField("PROCESS_POINT_ID")
private Integer processPointId;
private Long processPointId;
/**
* 片区
......
......@@ -40,7 +40,7 @@ public class IdxBizFelk {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......@@ -70,7 +70,7 @@ public class IdxBizFelk {
* 分析维度seq
*/
@TableField("ANALYSIS_OBJ_SEQ")
private Integer analysisObjSeq;
private Long analysisObjSeq;
/**
*
......@@ -100,13 +100,14 @@ public class IdxBizFelk {
*
*/
@TableField("ANALYSIS_START_TIME")
private LocalDateTime analysisStartTime;
private Date analysisStartTime;
/**
*
*/
@TableField("ANALYSIS_END_TIME")
private LocalDateTime analysisEndTime;
private Date analysisEndTime;
/**
* 片区
......
......@@ -68,13 +68,13 @@ public class IdxBizHjev {
*
*/
@TableField("ANALYSIS_POINT_ID")
private Integer analysisPointId;
private Long analysisPointId;
/**
*
*/
@TableField("PROCESS_POINT_ID")
private Integer processPointId;
private Long processPointId;
/**
* 片区
......
......@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -39,7 +38,7 @@ public class IdxBizIegc {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......
......@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -39,7 +38,7 @@ public class IdxBizKsia {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......
......@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -39,7 +38,7 @@ public class IdxBizP2z9 {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......
......@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -39,7 +38,7 @@ public class IdxBizPldo {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......
......@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -39,7 +38,7 @@ public class IdxBizUhef {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......
......@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -39,7 +38,7 @@ public class IdxBizUxfv {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......
......@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -39,7 +38,7 @@ public class IdxBizYh88 {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......
......@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -39,7 +38,7 @@ public class IdxBizZrdb {
*
*/
@TableField("REC_DATE")
private LocalDateTime recDate;
private Date recDate;
/**
*
......
......@@ -14,5 +14,9 @@ import java.util.List;
* @date 2023-08-14
*/
public interface IdxBizUxfvMapper extends BaseMapper<IdxBizUxfv> {
List<IdxBizUxfvDto> getInfluxDBData();
List<String> gateWayIdListFan();
}
......@@ -50,4 +50,7 @@
GROUP BY b.SEQUENCE_NBR
</select>
<select id="gateWayIdListFan" resultType="java.lang.String">
select GATEWAY_ID from idx_biz_uxfv group by GATEWAY_ID;
</select>
</mapper>
package com.yeejoin.amos.boot.module.jxiop.api.Enum;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum QrcodeColorEnum {
GREEN("绿码", "green"),
RED("红码", "red"),
YELLOW("黄码", "yellow");
private String name;
private String code;
public static String getCode(String name) {
for (QrcodeColorEnum qrcodeColorEnum : QrcodeColorEnum.values()) {
if (qrcodeColorEnum.getName().equals(name)) {
return qrcodeColorEnum.getCode();
}
}
return null;
}
}
package com.yeejoin.amos.boot.module.jxiop.api.Enum;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum QrcodePostEnum {
ZZ("站长", "登高证,调度证,高压电工证"),
FZZ("副站长", "登高证,调度证,高压电工证"),
JXBZ("检修班长", "登高证,高压电工证"),
JXY("检修员", "登高证,高压电工证"),
YWZZ("运维值长", "登高证,调度证,高压电工证"),
YWY("运维员", "登高证,调度证,高压电工证"),
CS("厨师", "健康证"),
AQY("安全员", "安全员证"),
SJ("司机", "驾照"),
XFY("消防员", "消防设施操作证");
private String name;
private String code;
public static String getCode(String name) {
for (QrcodePostEnum qrcodePostEnum : QrcodePostEnum.values()) {
if (qrcodePostEnum.getName().equals(name)) {
return qrcodePostEnum.getCode();
}
}
return null;
}
}
package com.yeejoin.amos.boot.module.jxiop.api.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class CertificateDto implements Serializable {
/**
* 证书集合 【逗号隔开】
*/
private String certificates;
/**
* 距过期还有多少天 【已过期的不会出现在这里】
*/
private Integer expirationDays;
}
package com.yeejoin.amos.boot.module.jxiop.api.dto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.PersonCertificate;
import lombok.Data;
import java.util.List;
@Data
public class CertificationInfo {
private List<PersonCertificate> certificationInfo;
}
......@@ -17,7 +17,8 @@ public class PersonDto {
private PersonUser personUser;
//资质信息
private PersonCertificate personCertificate;
// private CertificationInfo personCertificate;
private CertificationInfo personCertificate;
//账户信息
private PersonAccount personAccount;
......
package com.yeejoin.amos.boot.module.jxiop.api.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class PersonYardDto implements Serializable {
/**
* 岗位
*/
private String postName;
/**
* 人员表主键ID
*/
private Long personId;
/**
* 证书信息
*/
private List<CertificateDto> certificateDtoList;
}
......@@ -150,4 +150,9 @@ public class PersonBasic extends BaseEntity {
@TableField("post_name")
private String postName;
/**
* 岗位
*/
@TableField("qrcode_color")
private String qrcodeColor;
}
......@@ -11,6 +11,8 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.text.ParseException;
import java.util.List;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.PersonBasicServiceImpl;
import org.springframework.web.context.request.RequestContextHolder;
......@@ -50,10 +52,9 @@ public class PersonBasicController extends BaseController {
@ApiOperation(httpMethod = "POST", value = "新增人员基本信息", notes = "新增人员基本信息")
public ResponseModel<Object> save(@RequestBody PersonDto model,HttpServletRequest httpServletRequest) {
try {
personBasicServiceImpl.addPerson(model,httpServletRequest);
}catch (InnerInvokException e){
personBasicServiceImpl.addPerson(model, httpServletRequest);
}catch (InnerInvokException | ParseException e){
e.printStackTrace();
return this.buildResponseFalse(e.getMessage());
}
......@@ -76,7 +77,7 @@ public class PersonBasicController extends BaseController {
public ResponseModel<PersonDto> updateBySequenceNbrPersonBasic(@RequestBody PersonDto model,@RequestParam(value = "sequenceNbr") Long sequenceNbr,HttpServletRequest httpServletRequest) {
try {
personBasicServiceImpl.updatePerson(model,httpServletRequest,sequenceNbr);
}catch (InnerInvokException e){
}catch (InnerInvokException | ParseException e){
e.printStackTrace();
return this.buildResponseFalse(e.getMessage());
}
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.api.Enum.QrcodeColorEnum;
import com.yeejoin.amos.boot.module.jxiop.api.Enum.QrcodePostEnum;
import com.yeejoin.amos.boot.module.jxiop.api.entity.PersonBasic;
import com.yeejoin.amos.boot.module.jxiop.api.entity.PersonCertificate;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.PersonBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.PersonCertificateMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Component
public class PersonYardTimeTask {
@Autowired
PersonBasicMapper personBasicMapper;
@Autowired
PersonBasicServiceImpl personBasicService;
//人员资质信息service
@Autowired
PersonCertificateMapper personCertificateMapper;
@Scheduled(cron = "0 0 0 1/1 * ? ")
public void timeYardTimeTask() {
List<PersonBasic> personBasicList = personBasicMapper.selectList(null);
List<PersonCertificate> personCertificates = personCertificateMapper.selectList(null);
Map<Long, List<PersonCertificate>> perCertificateMap = personCertificates.stream().filter(item -> ObjectUtils.isNotEmpty(item.getPersonId())).collect(Collectors.groupingBy(PersonCertificate::getPersonId));
List<PersonBasic> personBasics = new ArrayList<>();
personBasicList.forEach(personBasic -> {
List<PersonCertificate> personCertificateList = perCertificateMap.get(personBasic.getSequenceNbr());
//默认红码
personBasic.setQrcodeColor(QrcodeColorEnum.RED.getCode());
// 该岗位应获得的证书
List<String> list2 = new ArrayList<>();
if (StringUtils.isNotEmpty(personBasic.getPostName())) {
String certificates = QrcodePostEnum.getCode(personBasic.getPostName());
list2 = Arrays.asList(certificates.split(","));
}
List<String> list = new ArrayList(list2);
//人员资质信息
Integer isInMonth = 0;
Integer isOver = 0;
if (CollectionUtils.isNotEmpty(personCertificateList)) {
for (PersonCertificate item : personCertificateList) {
Date date = DateUtils.dateAddYears(item.getCertificateTime(), Integer.parseInt(item.getValidPeriod()));
if (list.contains(item.getCertificateName()) &&
DateUtils.dateCompare(date, new Date()) == -1) {
isOver = 1;
}
try {
if (list.contains(item.getCertificateName()) &&
DateUtils.dateBetweenIncludeToday(date, new Date()) < 30 &&
DateUtils.dateCompare(date, new Date()) == 1) {
isInMonth = 1;
}
} catch (ParseException e) {
e.printStackTrace();
}
list.remove(item.getCertificateName());
}
}
if (CollectionUtils.isEmpty(list) && isInMonth == 0 && isOver == 0) {
personBasic.setQrcodeColor(QrcodeColorEnum.GREEN.getCode());
} else if (CollectionUtils.isEmpty(list) && isOver == 1) {
personBasic.setQrcodeColor(QrcodeColorEnum.RED.getCode());
} else if (CollectionUtils.isEmpty(list) && isOver == 0 && isInMonth == 1) {
personBasic.setQrcodeColor(QrcodeColorEnum.YELLOW.getCode());
}
personBasics.add(personBasic);
});
personBasicService.updateBatchById(personBasics);
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author: tw
* @createDate: 2023/8/14
*/
@Data
public class SeriesData {
private List<Map<String,Object>> seriesData;
private List<String> axisData;
}
......@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationPlan;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationPlanMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.SeriesData;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.TimeDate;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.DateUtil;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
......@@ -14,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
......@@ -42,14 +45,14 @@ public class LargeScreenImpl {
*/
public Map<String, Double> getqg() {
Map<String, Double> mapdta = new HashMap<>();
mapdta.put("SS", 0.0);
mapdta.put("ZFS", 0.0);
mapdta.put("ZFSLJ", 0.0);
mapdta.put("RSD", 0.0);
mapdta.put("YFD", 0.0);
mapdta.put("NFD", 0.0);
mapdta.put("YJHWC", 0.0);
mapdta.put("NJHWC", 0.0);
mapdta.put("SS", 0d);
mapdta.put("ZFS", 0d);
mapdta.put("ZFSLJ", 0d);
mapdta.put("RSD", 0d);
mapdta.put("YFD", 0d);
mapdta.put("NFD", 0d);
mapdta.put("YJHWC", 0d);
mapdta.put("NJHWC", 0d);
//平均数
List<String> value = new ArrayList<>();
value.add(SS);
......@@ -139,17 +142,16 @@ public class LargeScreenImpl {
/**
* 区域
**/
public Map<String, Double> getqy(List<String> gatewayId) {
Map<String, Double> mapdta = new HashMap<>();
mapdta.put("SS", 0.0);
mapdta.put("ZFS", 0.0);
mapdta.put("ZFSLJ", 0.0);
mapdta.put("RSD", 0.0);
mapdta.put("YFD", 0.0);
mapdta.put("NFD", 0.0);
mapdta.put("YJHWC", 0.0);
mapdta.put("NJHWC", 0.0);
mapdta.put("SS", 0d);
mapdta.put("ZFS", 0d);
mapdta.put("ZFSLJ", 0d);
mapdta.put("RSD", 0d);
mapdta.put("YFD", 0d);
mapdta.put("NFD", 0d);
mapdta.put("YJHWC", 0d);
mapdta.put("NJHWC", 0d);
//平均数
List<String> value = new ArrayList<>();
value.add(SS);
......@@ -236,20 +238,203 @@ public class LargeScreenImpl {
}
//获取月日发电量
public List<TimeDate> gettimedate(){
//全国发电趋势
public SeriesData getSeriesDataqg(){
//获取今年当月 日发电趋势
List<Double> listjn= gettimedate( new Date());
//获取去年当月 日发电趋势
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.YEAR, -1);
Date oneYearAgoToday = calendar.getTime();
List<Double> listqn= gettimedate( oneYearAgoToday);
Map<String,Object> mapjn=new HashMap<>();
mapjn.put("data",listjn);
mapjn.put("name","当前值");
Map<String,Object> mapqn=new HashMap<>();
mapjn.put("data",listqn);
mapjn.put("name","同期值");
List<Map<String,Object>> list=new ArrayList<>();
list.add(mapjn);
list.add(mapqn);
SeriesData seriesData=new SeriesData();
seriesData.setSeriesData(list);
//获取日期
List<String> listdate= dayReportnq(new Date());
seriesData.setAxisData(listdate);
return seriesData;
}
//区域发电趋势
public SeriesData getSeriesDataqy( Date date,List<String> gatewayId){
//获取今年当月 日发电趋势
List<Double> listjn= gettimedateqy( new Date(),gatewayId);
//获取去年当月 日发电趋势
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.YEAR, -1);
Date oneYearAgoToday = calendar.getTime();
List<Double> listqn= gettimedateqy( oneYearAgoToday,gatewayId);
Map<String,Object> mapjn=new HashMap<>();
mapjn.put("data",listjn);
mapjn.put("name","当前值");
Map<String,Object> mapqn=new HashMap<>();
mapjn.put("data",listqn);
mapjn.put("name","同期值");
List<Map<String,Object>> list=new ArrayList<>();
list.add(mapjn);
list.add(mapqn);
SeriesData seriesData=new SeriesData();
seriesData.setSeriesData(list);
//获取日期
List<String> listdate= dayReportnq(new Date());
seriesData.setAxisData(listdate);
return seriesData;
}
//获取全国月日发电量
public List<Double> gettimedate( Date date){
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyyMM");
String monthy= myFmt2.format(date);
List<Double> listdate= new ArrayList<>();
List<String> value=new ArrayList<>();
value.add(RSD);
Map<String,List<String>> map=new HashMap<>();
map.put("equipmentIndexName.keyword",value);
List<String> value1=new ArrayList<>();
value1.add(monthy);
map.put("moon.keyword",value1);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"value" ,"day.keyword",ESEquipments.class);
Map<String,Double> mapdta=new HashMap<>();
DecimalFormat format2 = new DecimalFormat("#.0000");
for (Terms.Bucket bucket : lidate) {
Aggregations aggregation= bucket.getAggregations();
List<Aggregation> listdata= Objects.nonNull(aggregation)?aggregation.asList():null;
for (Aggregation agg : listdata) {
ParsedSum parsedSum =(ParsedSum)agg;
mapdta.put(bucket.getKeyAsString(), Double.valueOf(format2.format(parsedSum.getValue())));
}
}
//组装数据
List<String> list= dayReport(date);
for (String s : list) {
if(mapdta!=null&&mapdta.containsKey(s)){
listdate.add(mapdta.get(s));
}else{
listdate.add(0d);
}
}
return listdate;
return null;
}
//获取区域月日发电量
public List<Double> gettimedateqy( Date date,List<String> gatewayId){
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyyMM");
String monthy= myFmt2.format(date);
List<Double> listdate= new ArrayList<>();
List<String> value=new ArrayList<>();
value.add(RSD);
Map<String,List<String>> map=new HashMap<>();
map.put("equipmentIndexName.keyword",value);
map.put("gatewayId.keyword", gatewayId);
List<String> value1=new ArrayList<>();
value1.add(monthy);
map.put("moon.keyword",value1);
List<? extends Terms.Bucket> lidate= commonServiceImpl.getgroupsum(map,"value" ,"day.keyword",ESEquipments.class);
Map<String,Double> mapdta=new HashMap<>();
DecimalFormat format2 = new DecimalFormat("#.0000");
for (Terms.Bucket bucket : lidate) {
Aggregations aggregation= bucket.getAggregations();
List<Aggregation> listdata= Objects.nonNull(aggregation)?aggregation.asList():null;
for (Aggregation agg : listdata) {
ParsedSum parsedSum =(ParsedSum)agg;
mapdta.put(bucket.getKeyAsString(), Double.valueOf(format2.format(parsedSum.getValue())));
}
}
//组装数据
List<String> list= dayReport(date);
for (String s : list) {
if(mapdta!=null&&mapdta.containsKey(s)){
listdate.add(mapdta.get(s));
}else{
listdate.add(0d);
}
}
return listdate;
}
public List<String> dayReport(Date month) {
List<String> list=new ArrayList<>();
Calendar cal = Calendar.getInstance();
cal.setTime(month);//month 为指定月份任意日期
int year = cal.get(Calendar.YEAR);
int m = cal.get(Calendar.MONTH);
int dayNumOfMonth = DateUtil.getDaysByYearMonth(year, m);
cal.set(Calendar.DAY_OF_MONTH, 1);// 从一号开始
for (int i = 0; i < dayNumOfMonth; i++ ) {
list.add(String.valueOf(i+1));
}
return list;
}
public List<String> dayReportnq (Date month) {
List<String> list=new ArrayList<>();
Calendar cal = Calendar.getInstance();
cal.setTime(month);//month 为指定月份任意日期
int year = cal.get(Calendar.YEAR);
int m = cal.get(Calendar.MONTH);
int dayNumOfMonth = DateUtil.getDaysByYearMonth(year, m);
cal.set(Calendar.DAY_OF_MONTH, 1);// 从一号开始
for (int i = 0; i < dayNumOfMonth; i++ ) {
list.add(m+"-"+String.valueOf(i+1));
}
return list;
}
}
\ No newline at end of file
......@@ -83,13 +83,23 @@ public class PowerGenerationImpl {
int day = calendar.get(Calendar.DATE);
int month = calendar.get(Calendar.MONTH) + 1;
int year = calendar.get(Calendar.YEAR);
SimpleDateFormat myFmt2=new SimpleDateFormat("yyyyMM");
Date now=new Date();
String monthy= myFmt2.format(now);
SimpleDateFormat myFmty=new SimpleDateFormat("yyyy");
Date nowy=new Date();
String yeary= myFmty.format(nowy);
switch (type) {
case "day":
List<ESDailyPowerGeneration> listd= this.getESDailyPowerGeneration(stationCacheInfoDto,indexDto,daty,String.valueOf(day),String.valueOf(month));
List<ESDailyPowerGeneration> listd= this.getESDailyPowerGeneration(stationCacheInfoDto,indexDto,daty,String.valueOf(day),monthy);
dailyPowerGenerationRepository.saveAll(listd);
break;
case "moon":
List<ESMoonPowerGeneration> listm= this.getESMoonPowerGeneration(stationCacheInfoDto,indexDto,daty,String.valueOf(month),String.valueOf(year));
List<ESMoonPowerGeneration> listm= this.getESMoonPowerGeneration(stationCacheInfoDto,indexDto,daty,String.valueOf(month),yeary);
moonPowerGenerationRepository.saveAll(listm);
break;
case "year":
......
package com.yeejoin.amos.boot.module.jxiop.biz.utils;
import io.micrometer.core.instrument.util.TimeUtils;
import java.sql.Time;
import java.text.ParseException;
import java.text.ParsePosition;
......@@ -420,4 +422,19 @@ public static String cronTime(Date date){
}
public static int getDaysByYearMonth(int year, int month) {
Calendar a = Calendar.getInstance();
a.set(Calendar.YEAR, year);
a.set(Calendar.MONTH, month - 1);
a.set(Calendar.DATE, 1);
a.roll(Calendar.DATE, -1);
int maxDate = a.get(Calendar.DATE);
return maxDate;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment