Merge remote-tracking branch 'origin/master'

This commit is contained in:
2023-04-19 14:09:20 +08:00
93 changed files with 8047 additions and 3702 deletions

View File

@@ -3,6 +3,7 @@ package com.njcn.algorithm.api;
import com.njcn.algorithm.api.fallback.DevModelFeignClientFallbackFactory;
import com.njcn.algorithm.pojo.param.CsDevModelAddParm;
import com.njcn.algorithm.pojo.param.CsDevModelQueryListParm;
import com.njcn.algorithm.pojo.po.CsDevModelPO;
import com.njcn.algorithm.pojo.vo.CsDevModelPageVO;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
@@ -19,7 +20,7 @@ import org.springframework.web.bind.annotation.RequestBody;
public interface DevModelFeignClient {
@PostMapping("/addDevModel")
HttpResult<Boolean> addDevModel(@RequestBody @Validated CsDevModelAddParm csDevModelAddParm);
HttpResult<CsDevModelPO> addDevModel(@RequestBody @Validated CsDevModelAddParm csDevModelAddParm);
@PostMapping("/queryDevModelOne")
HttpResult<CsDevModelPageVO> queryDevModelOne(@RequestBody CsDevModelQueryListParm csDevModelQueryListParm);

View File

@@ -18,4 +18,7 @@ public interface EquipmentFeignClient {
@PostMapping("/queryEquipmentByndid")
HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(@RequestParam("ndid") String ndid);
@PostMapping("/updateStatusBynDid")
HttpResult<Boolean> updateStatusBynDid(@RequestParam("nDId") String nDid,@RequestParam("status") Integer status);
}

View File

@@ -3,6 +3,7 @@ package com.njcn.algorithm.api.fallback;
import com.njcn.algorithm.api.DevModelFeignClient;
import com.njcn.algorithm.pojo.param.CsDevModelAddParm;
import com.njcn.algorithm.pojo.param.CsDevModelQueryListParm;
import com.njcn.algorithm.pojo.po.CsDevModelPO;
import com.njcn.algorithm.pojo.vo.CsDevModelPageVO;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
@@ -35,7 +36,7 @@ public class DevModelFeignClientFallbackFactory implements FallbackFactory<DevMo
return new DevModelFeignClient() {
@Override
public HttpResult<Boolean> addDevModel(CsDevModelAddParm csDevModelAddParm) {
public HttpResult<CsDevModelPO> addDevModel(CsDevModelAddParm csDevModelAddParm) {
log.error("{}异常,降级处理,异常为:{}","新增装置模板版本信息",cause.toString());
throw new BusinessException(finalExceptionEnum);
}

View File

@@ -8,6 +8,7 @@ import com.njcn.common.pojo.response.HttpResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @author xy
@@ -31,6 +32,12 @@ public class EquipmentFeignClientFallbackFactory implements FallbackFactory<Equi
log.error("{}异常,降级处理,异常为:{}","通过ndid查询出厂设备异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<Boolean> updateStatusBynDid(String nDid, Integer status) {
log.error("{}异常,降级处理,异常为:{}","通过ndid修改装置的状态",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -17,7 +17,7 @@ public enum AlgorithmResponseEnum {
PROJECT_COMMON_ERROR("A00500","同一用户下项目名不能相同"),
DICT_DATA_ERROR("A00501","暂无此字典表类型"),
NDID_ERROR("A00502","存在相同的ndid"),
DATA_ERROR("A00503","存在相同的数据"),
;

View File

@@ -0,0 +1,57 @@
package com.njcn.algorithm.pojo.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import java.util.Date;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 9:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
@ApiModel(value="装置数据有效性新增model")
@Data
public class CsDataEffectiveAddParm {
/**
* 项目id
*/
@ApiModelProperty(value="项目id")
@NotBlank(message="项目id不能为空")
private String projectId;
/**
* 设备id
*/
@ApiModelProperty(value="设备id")
@NotBlank(message="设备id不能为空")
private String devId;
/**
* 注册时间
*/
@ApiModelProperty(value="注册时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date registerTime;
/**
* 退役时间
*/
@ApiModelProperty(value="退役时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date retireeTime;
}

View File

@@ -0,0 +1,62 @@
package com.njcn.algorithm.pojo.param;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import java.util.Date;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 9:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
@ApiModel(value="装置数据有效性修改model")
@Data
public class CsDataEffectiveAuditParm {
@ApiModelProperty(value = "id")
@NotBlank(message="id不能为空")
private String id;
/**
* 项目id
*/
@ApiModelProperty(value="项目id")
@NotBlank(message="项目id不能为空")
private String projectId;
/**
* 设备id
*/
@ApiModelProperty(value="设备id")
@NotBlank(message="设备id不能为空")
private String devId;
/**
* 注册时间
*/
@ApiModelProperty(value="注册时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date registerTime;
/**
* 退役时间
*/
@ApiModelProperty(value="退役时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date retireeTime;
}

View File

@@ -0,0 +1,39 @@
package com.njcn.algorithm.pojo.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 9:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
@ApiModel(value="装置数据查询有效性model")
@Data
public class CsDataEffectiveQueryParm {
@ApiModelProperty(value = "id")
private String id;
/**
* 项目id
*/
@ApiModelProperty(value="项目id")
private String projectId;
/**
* 设备id
*/
@ApiModelProperty(value="设备id")
private String devId;
}

View File

@@ -0,0 +1,32 @@
package com.njcn.algorithm.pojo.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 13:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
@ApiModel(value="装置与模板表新增Model")
@Data
public class CsDevModelRelationAddParm {
@ApiModelProperty(value="装置 id")
@NotNull(message="装置 id不能为空")
private String devId;
@ApiModelProperty(value="模板 id")
@NotNull(message="模板 id不能为空")
private String modelId;
}

View File

@@ -0,0 +1,32 @@
package com.njcn.algorithm.pojo.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 13:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
@ApiModel(value="装置与模板表修改Model")
@Data
public class CsDevModelRelationAuidtParm {
@NotBlank(message="id不能为空")
@ApiModelProperty(value="id")
private String id;
@NotBlank(message="装置id不能为空")
private String devId;
@ApiModelProperty(value="模板 id")
private String modelId;
@ApiModelProperty(value="状态(0删除 1正常)")
private String status;
}

View File

@@ -0,0 +1,28 @@
package com.njcn.algorithm.pojo.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 13:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
public class CsDevModelRelationQueryParm {
@ApiModelProperty(value="id")
private String id;
@ApiModelProperty(value="装置 id")
private String devId;
@ApiModelProperty(value="模板 id")
private String modelId;
@ApiModelProperty(value="状态(0删除 1正常)")
private String status;
}

View File

@@ -0,0 +1,62 @@
package com.njcn.algorithm.pojo.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.njcn.db.bo.BaseEntity;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 9:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
/**
* 装置数据有效性表
*/
@Data
@TableName(value = "cs_data_effective")
public class CsDataEffectivePO extends BaseEntity {
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private String id;
/**
* 项目id
*/
@TableField(value = "project_id")
private String projectId;
/**
* 设备id
*/
@TableField(value = "dev_id")
private String devId;
/**
* 注册时间
*/
@TableField(value = "register_time")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date registerTime;
/**
* 退役时间
*/
@TableField(value = "retiree_time")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date retireeTime;
}

View File

@@ -0,0 +1,41 @@
package com.njcn.algorithm.pojo.po;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 13:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
@TableName(value = "cs_dev_model_relation")
public class CsDevModelRelationPO extends BaseEntity {
/**
* id
*/
@TableId(value = "id",type = IdType.ASSIGN_UUID)
private String id;
@TableField(value = "dev_id")
private String devId;
@TableField(value = "model_id")
private String modelId;
/**
* 状态(0删除 1正常)
*/
@TableField(value = "status")
@ApiModelProperty(value="状态(0删除 1正常)")
private String status;
}

View File

@@ -0,0 +1,58 @@
package com.njcn.algorithm.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.njcn.db.bo.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 9:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
@ApiModel(value="装置数据Modle")
@Data
public class CsDataEffectiveVO extends BaseEntity {
@ApiModelProperty(value = "id")
private String id;
/**
* 项目id
*/
@ApiModelProperty(value="项目id")
private String projectId;
/**
* 设备id
*/
@ApiModelProperty(value="设备id")
private String devId;
/**
* 注册时间
*/
@ApiModelProperty(value="注册时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date registerTime;
/**
* 退役时间
*/
@ApiModelProperty(value="退役时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date retireeTime;
}

View File

@@ -0,0 +1,37 @@
package com.njcn.algorithm.pojo.vo;
import com.njcn.db.bo.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 13:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
@ApiModel(value="装置与模板表的对应Model")
@Data
public class CsDevModelRelationVO extends BaseEntity {
/**
* id
*/
@ApiModelProperty(value="id")
private String id;
@ApiModelProperty(value="装置 id")
private String devId;
@ApiModelProperty(value="模板 id")
private String modelId;
/**
* 状态(0删除 1正常)
*/
@ApiModelProperty(value="状态(0删除 1正常)")
private String status;
}

View File

@@ -5,6 +5,7 @@ import com.njcn.algorithm.pojo.param.CsDevModelAddParm;
import com.njcn.algorithm.pojo.param.CsDevModelAuditParm;
import com.njcn.algorithm.pojo.param.CsDevModelQueryListParm;
import com.njcn.algorithm.pojo.param.CsDevModelQueryParm;
import com.njcn.algorithm.pojo.po.CsDevModelPO;
import com.njcn.algorithm.pojo.vo.CsDevModelPageVO;
import com.njcn.algorithm.service.CsDevModelService;
import com.njcn.common.pojo.annotation.OperateInfo;
@@ -45,10 +46,9 @@ public class DevModelController extends BaseController {
@PostMapping("/addDevModel")
@ApiOperation("新增设备模板")
@ApiImplicitParam(name = "csDevModelAddParm", value = "新增设备模板参数", required = true)
public HttpResult<Boolean> addDevModel(@RequestBody @Validated CsDevModelAddParm csDevModelAddParm){
public HttpResult<CsDevModelPO> addDevModel(@RequestBody @Validated CsDevModelAddParm csDevModelAddParm){
String methodDescribe = getMethodDescribe("addDevModel");
Boolean flag = csDevModelService.addDevModel (csDevModelAddParm);
CsDevModelPO flag = csDevModelService.addDevModel (csDevModelAddParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}

View File

@@ -0,0 +1,84 @@
package com.njcn.algorithm.controller.Equipment;
import com.njcn.algorithm.pojo.param.CsDevModelRelationAddParm;
import com.njcn.algorithm.pojo.param.CsDevModelRelationAuidtParm;
import com.njcn.algorithm.pojo.param.CsDevModelRelationQueryParm;
import com.njcn.algorithm.pojo.po.CsDevModelRelationPO;
import com.njcn.algorithm.pojo.vo.CsDevModelRelationVO;
import com.njcn.algorithm.service.CsDevModelRelationService;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/3/27 15:31【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Slf4j
@RestController
@RequestMapping("/devmodelRelation")
@Api(tags = "设备模板关联")
@AllArgsConstructor
public class DevModelRelationController extends BaseController {
private final CsDevModelRelationService csDevModelRelationService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addDevModelRelation")
@ApiOperation("绑定设备与模板")
@ApiImplicitParam(name = "addParm", value = "新增参数", required = true)
public HttpResult<CsDevModelRelationPO> addDevModelRelation(@RequestBody @Validated CsDevModelRelationAddParm addParm){
String methodDescribe = getMethodDescribe("addDevModelRelation");
CsDevModelRelationPO flag = csDevModelRelationService.addDevModelRelation (addParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/AuditDevModelRelation")
@ApiOperation("更新/删除出厂设备")
@ApiImplicitParam(name = "auditParm", value = "更新/删除参数", required = true)
public HttpResult<Boolean> AuditDevModelRelation(@RequestBody @Validated CsDevModelRelationAuidtParm auditParm ){
String methodDescribe = getMethodDescribe("AuditDevModelRelation");
Boolean flag = csDevModelRelationService.AuditDevModelRelation(auditParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryDevModelRelationList")
@ApiOperation("设备模板查询")
@ApiImplicitParam(name = "queryParm", value = "查询参数", required = true)
public HttpResult<List<CsDevModelRelationVO>> queryDevModelRelationList(@RequestBody CsDevModelRelationQueryParm queryParm){
String methodDescribe = getMethodDescribe("queryDevModelRelationList");
List<CsDevModelRelationVO> list = csDevModelRelationService.queryDevModelRelation(queryParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -15,6 +15,7 @@ import com.njcn.common.utils.HttpResultUtil;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -95,6 +96,18 @@ public class EquipmentDeliveryController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, projectEquipmentVOS, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateStatusBynDid")
@ApiOperation("根据网关id调整设备状态")
@ApiImplicitParams({
@ApiImplicitParam(name = "nDId", value = "网关id", required = true),
@ApiImplicitParam(name = "status", value = "状态", required = true)
})
public HttpResult<Boolean> updateStatusBynDid(@RequestParam("nDId") String nDid,@RequestParam("status") Integer status){
String methodDescribe = getMethodDescribe("updateStatusBynDid");
csEquipmentDeliveryService.updateStatusBynDid(nDid,status);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -0,0 +1,79 @@
package com.njcn.algorithm.controller.data;
import com.njcn.algorithm.pojo.param.CsDataEffectiveAddParm;
import com.njcn.algorithm.pojo.param.CsDataEffectiveAuditParm;
import com.njcn.algorithm.pojo.param.CsDataEffectiveQueryParm;
import com.njcn.algorithm.pojo.vo.AppBaseInformationVO;
import com.njcn.algorithm.pojo.vo.CsDataEffectiveVO;
import com.njcn.algorithm.service.CsDataEffectiveService;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/4 9:02【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Slf4j
@RestController
@RequestMapping("/dataEffective")
@Api(tags = "数据有效性")
@AllArgsConstructor
public class DataEffectiveController extends BaseController {
private final CsDataEffectiveService csDataEffectiveService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addDataEffective")
@ApiOperation("新增app数据有效性表")
@ApiImplicitParam(name = "csDataEffectiveAddParm", value = "新增app数据有效性表参数", required = true)
public HttpResult<Boolean> addDataEffective(@RequestBody @Validated CsDataEffectiveAddParm csDataEffectiveAddParm){
String methodDescribe = getMethodDescribe("addDataEffective");
boolean save = csDataEffectiveService.add (csDataEffectiveAddParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, save, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/auditDataEffective")
@ApiOperation("修改app数据有效性表")
@ApiImplicitParam(name = "auditParm", value = "修改app数据有效性表参数", required = true)
public HttpResult<Boolean> auditDataEffective(@RequestBody @Validated CsDataEffectiveAuditParm auditParm){
String methodDescribe = getMethodDescribe("auditDataEffective");
boolean save = csDataEffectiveService.auditDataEffective (auditParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, save, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryDataEffective")
@ApiOperation("查询app数据有效性表")
@ApiImplicitParam(name = "csDataEffectiveQueryParm", value = "查询app数据有效性表参数", required = true)
public HttpResult<List<CsDataEffectiveVO>> queryDataEffective(@RequestBody @Validated CsDataEffectiveQueryParm csDataEffectiveQueryParm ){
String methodDescribe = getMethodDescribe("queryDataEffective");
AppBaseInformationVO appBaseInformationVO = new AppBaseInformationVO();
List<CsDataEffectiveVO> list = csDataEffectiveService.queryDataEffective(csDataEffectiveQueryParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -1,23 +1,11 @@
package com.njcn.algorithm.controller.dict;
import com.njcn.algorithm.pojo.param.CsDictAddParm;
import com.njcn.algorithm.pojo.vo.CsDictVO;
import com.njcn.algorithm.service.CsDictService;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Description:
@@ -30,28 +18,28 @@ import java.util.List;
@Slf4j
@RestController
@RequestMapping("/dict")
@Api(tags = "字典表")
@Api(tags = "字典表/表结构更改弃用")
@AllArgsConstructor
public class DictDataController extends BaseController {
private final CsDictService csDictService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addDict")
@ApiOperation("新增字典")
@ApiImplicitParam(name = "csDictAddParms", value = "新增项目参数", required = true)
public HttpResult<Boolean> addDict(@RequestBody @Validated List<CsDictAddParm> csDictAddParms){
String methodDescribe = getMethodDescribe("addDictType");
Boolean flag = csDictService.addDict(csDictAddParms);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryDictData")
@ApiOperation("查询字典")
@ApiImplicitParam(name = "dictType", value = "字典类型", required = true)
public HttpResult<List<CsDictVO>> queryDictData(@RequestParam("dictType")String dictType ){
String methodDescribe = getMethodDescribe("queryDictData");
List<CsDictVO> csDictVOList = csDictService.queryDictData(dictType);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csDictVOList, methodDescribe);
}
// private final CsDictService csDictService;
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
// @PostMapping("/addDict")
// @ApiOperation("新增字典")
// @ApiImplicitParam(name = "csDictAddParms", value = "新增项目参数", required = true)
// public HttpResult<Boolean> addDict(@RequestBody @Validated List<CsDictAddParm> csDictAddParms){
// String methodDescribe = getMethodDescribe("addDictType");
// Boolean flag = csDictService.addDict(csDictAddParms);
//
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
// }
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
// @PostMapping("/queryDictData")
// @ApiOperation("查询字典")
// @ApiImplicitParam(name = "dictType", value = "字典类型", required = true)
// public HttpResult<List<CsDictVO>> queryDictData(@RequestParam("dictType")String dictType ){
// String methodDescribe = getMethodDescribe("queryDictData");
// List<CsDictVO> csDictVOList = csDictService.queryDictData(dictType);
//
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csDictVOList, methodDescribe);
// }
}

View File

@@ -0,0 +1,16 @@
package com.njcn.algorithm.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.algorithm.pojo.po.CsDataEffectivePO;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 9:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface CsDataEffectiveMapper extends BaseMapper<CsDataEffectivePO> {
}

View File

@@ -0,0 +1,16 @@
package com.njcn.algorithm.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.algorithm.pojo.po.CsDevModelRelationPO;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 13:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface CsDevModelRelationMapper extends BaseMapper<CsDevModelRelationPO> {
}

View File

@@ -0,0 +1,21 @@
<?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.njcn.algorithm.mapper.CsDataEffectiveMapper">
<resultMap id="BaseResultMap" type="com.njcn.algorithm.pojo.po.CsDataEffectivePO">
<!--@mbg.generated-->
<!--@Table cs_data_effective-->
<result column="project_id" jdbcType="VARCHAR" property="projectId" />
<result column="dev_id" jdbcType="VARCHAR" property="devId" />
<result column="register_time" jdbcType="TIMESTAMP" property="registerTime" />
<result column="retiree_time" jdbcType="TIMESTAMP" property="retireeTime" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
project_id, dev_id, register_time, retiree_time, create_by, create_time, update_by,
update_time
</sql>
</mapper>

View File

@@ -0,0 +1,20 @@
<?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.njcn.algorithm.mapper.CsDevModelRelationMapper">
<resultMap id="BaseResultMap" type="com.njcn.algorithm.pojo.po.CsDevModelRelationPO">
<!--@mbg.generated-->
<!--@Table cs_dev_model_relation-->
<result column="id" jdbcType="VARCHAR" property="id" />
<result column="dev_id" jdbcType="VARCHAR" property="devId" />
<result column="model id" jdbcType="VARCHAR" property="modelId" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="status" jdbcType="BOOLEAN" property="status" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, dev_id, `model id`, create_by, create_time, update_by, update_time, `status`
</sql>
</mapper>

View File

@@ -0,0 +1,47 @@
package com.njcn.algorithm.service;
import com.njcn.algorithm.pojo.param.CsDataEffectiveAddParm;
import com.njcn.algorithm.pojo.param.CsDataEffectiveAuditParm;
import com.njcn.algorithm.pojo.param.CsDataEffectiveQueryParm;
import com.njcn.algorithm.pojo.po.CsDataEffectivePO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.algorithm.pojo.vo.CsDataEffectiveVO;
import java.util.List;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 9:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface CsDataEffectiveService extends IService<CsDataEffectivePO>{
/**
* @Description: add
* @Param: [csDataEffectiveAddParm]
* @return: boolean
* @Author: clam
* @Date: 2023/4/18
*/
boolean add(CsDataEffectiveAddParm csDataEffectiveAddParm);
/**
* @Description: queryDataEffective
* @Param: [csDataEffectiveQueryParm]
* @return: java.util.List<com.njcn.algorithm.pojo.vo.CsDataEffectiveVO>
* @Author: clam
* @Date: 2023/4/18
*/
List<CsDataEffectiveVO> queryDataEffective(CsDataEffectiveQueryParm csDataEffectiveQueryParm);
/**
* @Description: auditDataEffective
* @Param: [auditParm]
* @return: boolean
* @Author: clam
* @Date: 2023/4/18
*/
boolean auditDataEffective(CsDataEffectiveAuditParm auditParm);
}

View File

@@ -0,0 +1,41 @@
package com.njcn.algorithm.service;
import com.njcn.algorithm.pojo.param.CsDevModelRelationAddParm;
import com.njcn.algorithm.pojo.param.CsDevModelRelationAuidtParm;
import com.njcn.algorithm.pojo.param.CsDevModelRelationQueryParm;
import com.njcn.algorithm.pojo.po.CsDevModelRelationPO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.algorithm.pojo.vo.CsDevModelRelationVO;
import java.util.List;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 13:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface CsDevModelRelationService extends IService<CsDevModelRelationPO>{
/**
* @Description: addDevModelRelation
* @Param: [addParm]
* @return: com.njcn.algorithm.pojo.po.CsDevModelRelationPO
* @Author: clam
* @Date: 2023/4/18
*/
CsDevModelRelationPO addDevModelRelation(CsDevModelRelationAddParm addParm);
/**
* @Description: AuditDevModelRelation
* @Param: [auditParm]
* @return: java.lang.Boolean
* @Author: clam
* @Date: 2023/4/18
*/
Boolean AuditDevModelRelation(CsDevModelRelationAuidtParm auditParm);
List<CsDevModelRelationVO> queryDevModelRelation(CsDevModelRelationQueryParm queryParm);
}

View File

@@ -26,8 +26,8 @@ public interface CsDevModelService extends IService<CsDevModelPO>{
* @return: java.lang.Boolean
* @Author: clam
* @Date: 2023/4/10
*/
Boolean addDevModel(CsDevModelAddParm csDevModelAddParm);
*/
CsDevModelPO addDevModel(CsDevModelAddParm csDevModelAddParm);
/**
* @Description: AuditDevModel
* @Param: [csDevModelAuditParm]

View File

@@ -54,4 +54,10 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
IPage<ProjectEquipmentVO> queryEquipmentByProject(ProjectEquipmentQueryParm projectEquipmentQueryParm);
Boolean updateEquipmentDelivery(CsEquipmentDeliveryAuditParm csEquipmentDeliveryAuditParm);
/**
* 根据网关id修改装置的状态
* @param nDid 网关id
*/
void updateStatusBynDid(String nDid,Integer status);
}

View File

@@ -0,0 +1,84 @@
package com.njcn.algorithm.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.algorithm.enums.AlgorithmResponseEnum;
import com.njcn.algorithm.mapper.CsDataEffectiveMapper;
import com.njcn.algorithm.pojo.param.CsDataEffectiveAddParm;
import com.njcn.algorithm.pojo.param.CsDataEffectiveAuditParm;
import com.njcn.algorithm.pojo.param.CsDataEffectiveQueryParm;
import com.njcn.algorithm.pojo.po.CsDataEffectivePO;
import com.njcn.algorithm.pojo.vo.CsDataEffectiveVO;
import com.njcn.algorithm.service.CsDataEffectiveService;
import com.njcn.common.pojo.exception.BusinessException;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 9:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class CsDataEffectiveServiceImpl extends ServiceImpl<CsDataEffectiveMapper, CsDataEffectivePO> implements CsDataEffectiveService{
@Override
@Transactional(rollbackFor = {Exception.class})
public boolean add(CsDataEffectiveAddParm csDataEffectiveAddParm) {
CsDataEffectiveQueryParm csDataEffectiveQueryParm = new CsDataEffectiveQueryParm();
csDataEffectiveQueryParm.setDevId (csDataEffectiveAddParm.getDevId ());
csDataEffectiveQueryParm.setProjectId (csDataEffectiveAddParm.getProjectId ());
List<CsDataEffectiveVO> list = this.queryDataEffective (csDataEffectiveQueryParm);
if(list.size ()>0){
throw new BusinessException (AlgorithmResponseEnum.DATA_ERROR);
}
CsDataEffectivePO csDataEffectivePO = new CsDataEffectivePO ();
BeanUtils.copyProperties (csDataEffectiveAddParm, csDataEffectivePO);
boolean save = this.save (csDataEffectivePO);
return save;
}
@Override
public List<CsDataEffectiveVO> queryDataEffective(CsDataEffectiveQueryParm csDataEffectiveQueryParm) {
QueryWrapper<CsDataEffectivePO> queryWrapper = new QueryWrapper<> ();
queryWrapper.eq (StringUtils.isNotBlank (csDataEffectiveQueryParm.getId ()),"id",csDataEffectiveQueryParm.getId ()).
eq (StringUtils.isNotBlank (csDataEffectiveQueryParm.getProjectId ()),"project_id",csDataEffectiveQueryParm.getProjectId ()).
eq (StringUtils.isNotBlank (csDataEffectiveQueryParm.getDevId ()),"dev_id",csDataEffectiveQueryParm.getDevId ());
List<CsDataEffectivePO> csDataEffectivePOS = this.getBaseMapper ( ).selectList (queryWrapper);
List<CsDataEffectiveVO> collect = csDataEffectivePOS.stream ( ).map (temp -> {
CsDataEffectiveVO vo = new CsDataEffectiveVO ( );
BeanUtils.copyProperties (temp, vo);
return vo;
}).collect (Collectors.toList ( ));
return collect;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean auditDataEffective(CsDataEffectiveAuditParm auditParm) {
CsDataEffectiveQueryParm csDataEffectiveQueryParm = new CsDataEffectiveQueryParm();
csDataEffectiveQueryParm.setDevId (auditParm.getDevId ());
csDataEffectiveQueryParm.setProjectId (auditParm.getProjectId ());
List<CsDataEffectiveVO> list = this.queryDataEffective (csDataEffectiveQueryParm);
if(list.size ()>0){
throw new BusinessException (AlgorithmResponseEnum.DATA_ERROR);
}
CsDataEffectivePO csDataEffectivePO = new CsDataEffectivePO ();
BeanUtils.copyProperties (auditParm, csDataEffectivePO);
boolean flag = this.updateById (csDataEffectivePO);
return flag;
}
}

View File

@@ -0,0 +1,90 @@
package com.njcn.algorithm.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.algorithm.enums.AlgorithmResponseEnum;
import com.njcn.algorithm.mapper.CsDevModelRelationMapper;
import com.njcn.algorithm.pojo.param.CsDevModelRelationAddParm;
import com.njcn.algorithm.pojo.param.CsDevModelRelationAuidtParm;
import com.njcn.algorithm.pojo.param.CsDevModelRelationQueryParm;
import com.njcn.algorithm.pojo.po.CsDevModelRelationPO;
import com.njcn.algorithm.pojo.vo.CsDevModelRelationVO;
import com.njcn.algorithm.service.CsDevModelRelationService;
import com.njcn.common.pojo.exception.BusinessException;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/18 13:49【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class CsDevModelRelationServiceImpl extends ServiceImpl<CsDevModelRelationMapper, CsDevModelRelationPO> implements CsDevModelRelationService{
@Override
@Transactional(rollbackFor = Exception.class)
public CsDevModelRelationPO addDevModelRelation(CsDevModelRelationAddParm addParm) {
CsDevModelRelationQueryParm queryParm = new CsDevModelRelationQueryParm();
queryParm.setDevId (addParm.getDevId ());
queryParm.setModelId (addParm.getModelId ());
queryParm.setStatus ("1");
List<CsDevModelRelationVO> csDevModelRelationVOS = this.queryDevModelRelation (queryParm);
if(csDevModelRelationVOS.size ()>0){
throw new BusinessException (AlgorithmResponseEnum.DATA_ERROR);
}
CsDevModelRelationPO csDevModelRelationPO = new CsDevModelRelationPO();
BeanUtils.copyProperties (addParm, csDevModelRelationPO);
csDevModelRelationPO.setStatus ("1");
this.save (csDevModelRelationPO);
return csDevModelRelationPO;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean AuditDevModelRelation(CsDevModelRelationAuidtParm auditParm) {
CsDevModelRelationQueryParm queryParm = new CsDevModelRelationQueryParm();
queryParm.setId (auditParm.getId ());
List<CsDevModelRelationVO> csDevModelRelationVOS = this.queryDevModelRelation (queryParm);
CsDevModelRelationVO csDevModelRelationVO = csDevModelRelationVOS.get (0);
CsDevModelRelationQueryParm queryParm2 = new CsDevModelRelationQueryParm();
queryParm2.setDevId (StringUtils.isNotBlank (auditParm.getDevId ())?auditParm.getDevId ():csDevModelRelationVO.getDevId ());
queryParm2.setModelId (StringUtils.isNotBlank (auditParm.getModelId ())?auditParm.getModelId ():csDevModelRelationVO.getModelId ());
queryParm2.setStatus ("1");
List<CsDevModelRelationVO> csDevModelRelationVOS2 = this.queryDevModelRelation (queryParm2);
if(csDevModelRelationVOS.size ()>0){
throw new BusinessException (AlgorithmResponseEnum.DATA_ERROR);
}
CsDevModelRelationPO csDevModelRelationPO = new CsDevModelRelationPO();
BeanUtils.copyProperties (auditParm, csDevModelRelationPO);
boolean b = this.updateById (csDevModelRelationPO);
return b;
}
@Override
public List<CsDevModelRelationVO> queryDevModelRelation(CsDevModelRelationQueryParm queryParm) {
QueryWrapper<CsDevModelRelationPO> queryWrapper = new QueryWrapper<> ();
queryWrapper.eq (StringUtils.isNotBlank (queryParm.getId ()),"id",queryParm.getId ()).
eq (StringUtils.isNotBlank (queryParm.getModelId ()),"model_id",queryParm.getModelId ()).
eq (StringUtils.isNotBlank (queryParm.getDevId ()),"dev_id",queryParm.getDevId ()).
eq (StringUtils.isNotBlank (queryParm.getStatus ()),"status",queryParm.getStatus ());
List<CsDevModelRelationPO> csDevModelRelationPOS = this.getBaseMapper ( ).selectList (queryWrapper);
List<CsDevModelRelationVO> collect = csDevModelRelationPOS.stream ( ).map (temp -> {
CsDevModelRelationVO vo = new CsDevModelRelationVO ( );
BeanUtils.copyProperties (temp, vo);
return vo;
}).collect (Collectors.toList ( ));
return collect;
}
}

View File

@@ -29,13 +29,12 @@ public class CsDevModelServiceImpl extends ServiceImpl<CsDevModelMapper, CsDevMo
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean addDevModel(CsDevModelAddParm csDevModelAddParm) {
public CsDevModelPO addDevModel(CsDevModelAddParm csDevModelAddParm) {
CsDevModelPO csDevModelPO = new CsDevModelPO ();
BeanUtils.copyProperties (csDevModelAddParm, csDevModelPO);
csDevModelPO.setStatus ("1");
boolean save = this.save (csDevModelPO);
return save;
this.save (csDevModelPO);
return csDevModelPO;
}
@Override

View File

@@ -1,6 +1,8 @@
package com.njcn.algorithm.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -93,4 +95,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return b;
}
@Override
public void updateStatusBynDid(String nDId,Integer status) {
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.set(CsEquipmentDeliveryPO::getStatus,status).eq(CsEquipmentDeliveryPO::getNdid,nDId);
this.update(lambdaUpdateWrapper);
}
}

View File

@@ -9,6 +9,7 @@ import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
@@ -118,6 +119,7 @@ public class DeviceParam {
@ApiModelProperty(name = "sort",value = "排序",required = true)
@NotNull(message = "排序不可为空")
@Min(value = 0,message = "排序格式有误")
private Integer sort;

View File

@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
@@ -29,6 +30,7 @@ public class GdInformationParam {
@ApiModelProperty(name = "sort",value = "排序",required = true)
@NotNull(message = "排序不可为空")
@Min(value = 0,message = "排序格式有误")
private Integer sort;
/**

View File

@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
@@ -33,6 +34,7 @@ public class LineParam {
*/
@ApiModelProperty(name = "pt1",value = "PT一次变比",required = true)
@NotNull(message = "PT一次变比不可为空")
@Min(value = 1,message = "PT一次变比最小值应大于等于1")
private Float pt1;
/**
@@ -40,6 +42,7 @@ public class LineParam {
*/
@ApiModelProperty(name = "pt2",value = "PT二次变比",required = true)
@NotNull(message = "PT二次变比不可为空")
@Min(value = 1,message = "PT二次变比最小值应大于等于1")
private Float pt2;
/**
@@ -47,6 +50,7 @@ public class LineParam {
*/
@ApiModelProperty(name = "ct1",value = "CT一次变比",required = true)
@NotNull(message = "CT一次变比不可为空")
@Min(value = 1,message = "CT一次变比最小值应大于等于1")
private Float ct1;
/**
@@ -54,6 +58,7 @@ public class LineParam {
*/
@ApiModelProperty(name = "ct2",value = "CT二次变比",required = true)
@NotNull(message = "CT二次变比不可为空")
@Min(value = 1,message = "CT二次变比最小值应大于等于1")
private Float ct2;
/**
@@ -61,6 +66,7 @@ public class LineParam {
*/
@ApiModelProperty(name = "devCapacity",value = "设备容量",required = true)
@NotNull(message = "设备容量不可为空")
@Min(value = 1,message = "设备容量格式有误")
private Float devCapacity;
/**
@@ -68,6 +74,7 @@ public class LineParam {
*/
@ApiModelProperty(name = "shortCapacity",value = "短路容量",required = true)
@NotNull(message = "短路容量不可为空")
@Min(value = 1,message = "设备容量格式有误")
private Float shortCapacity;
/**
@@ -75,6 +82,7 @@ public class LineParam {
*/
@ApiModelProperty(name = "dealCapacity",value = "协议容量",required = true)
@NotNull(message = "协议容量不可为空")
@Min(value = 1,message = "设备容量格式有误")
private Float dealCapacity;
/**
@@ -82,6 +90,7 @@ public class LineParam {
*/
@ApiModelProperty(name = "standardCapacity",value = "基准容量新增时候可为空",required = true)
@NotNull(message = "基准容量不可为空")
@Min(value = 1,message = "设备容量格式有误")
private Float standardCapacity;
@@ -117,6 +126,7 @@ public class LineParam {
*/
@ApiModelProperty(name = "ptType",value = "接线类型(0:星型接法;1:三角型接法;2:开口三角型接法)",required = true)
@NotNull(message = "接线类型不可为空")
@Range(min = 0,max = 2,message = "接线类型有误")
private Integer ptType;
@ApiModelProperty(name = "num",value = "监测点序列",required = true)
@@ -125,8 +135,9 @@ public class LineParam {
@ApiModelProperty(name = "sort",value = "排序",required = true)
@NotNull(message = "排序不可为空")
@Min(value = 0,message = "排序格式有误")
private Integer sort;
/**
* 电压上偏差限值
*/

View File

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
@@ -29,6 +30,7 @@ public class ProvinceParam {
@ApiModelProperty(name = "sort",value = "排序",required = true)
@NotNull(message = "排序不可为空")
@Min(value = 0,message = "排序格式有误")
private Integer sort;
/**

View File

@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
@@ -31,6 +32,7 @@ public class SubStationParam {
@ApiModelProperty(name = "sort",value = "排序",required = true)
@NotNull(message = "排序不可为空")
@Min(value = 0,message = "排序格式有误")
private Integer sort;
/**

View File

@@ -7,6 +7,7 @@ import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
@@ -52,6 +53,7 @@ public class SubVoltageParam {
@ApiModelProperty(name = "sort",value = "排序",required = true)
@NotNull(message = "排序不可为空")
@Min(value = 0,message = "排序格式有误")
private Integer sort;
@ApiModelProperty(name = "lineParam",value = "监测点集合")

View File

@@ -21,13 +21,6 @@ public class TerminalOnlineRateDataParam extends DeviceInfoParam.BusinessParam{
/**
* 字段表监测点等级
*/
@ApiModelProperty(name = "lineGrade",value = "字段表监测点等级0极重要 1重要 2普通 3不重要")
private String lineGrade;
/**
* 调用模块分类
*/

View File

@@ -0,0 +1,30 @@
package com.njcn.device.pq.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @version 1.0.0
* @author: zbj
* @date: 2023/04/18
*/
@Data
public class EventListVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 结果集合
*/
@ApiModelProperty("结果集合")
private List<EventVO> list;
/**
* 总次数
*/
@ApiModelProperty("总次数")
private Integer size;
}

View File

@@ -0,0 +1,30 @@
package com.njcn.device.pq.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @version 1.0.0
* @author: zbj
* @date: 2023/04/18
*/
@Data
public class MiddleLimitRateListVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 结果集合
*/
@ApiModelProperty("结果集合")
private List<MiddleLimitRateVO> list;
/**
* 总次数
*/
@ApiModelProperty("总次数")
private Integer size;
}

View File

@@ -0,0 +1,31 @@
package com.njcn.device.pq.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @version 1.0.0
* @author: zbj
* @date: 2023/04/18
*/
@Data
public class MiddleTerminalListVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 结果集合
*/
@ApiModelProperty("结果集合")
private List<MiddleTerminalVO> list;
/**
* 总次数
*/
@ApiModelProperty("总次数")
private Integer size;
}

View File

@@ -489,8 +489,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
throw new BusinessException(DeviceResponseEnum.PROVINCE_EMPTY);
}
Line province = new Line();
province.setId(updateTerminalParam.getProjectUpdateParam().getProjectIndex());
province.setSort(updateTerminalParam.getProjectUpdateParam().getSort());
province.setId(updateTerminalParam.getProvinceUpdateParam().getProvinceIndex());
province.setSort(updateTerminalParam.getProvinceUpdateParam().getSort());
this.updateById(province);
}
@@ -517,6 +517,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
Line subStation = new Line();
subStation.setId(updateTerminalParam.getSubStationUpdateParam().getSubIndex());
subStation.setName(updateTerminalParam.getSubStationUpdateParam().getName());
subStation.setSort(updateTerminalParam.getSubStationUpdateParam().getSort());
checkUpdateName(updateTerminalParam, 3, subStationRes.getPid());
this.updateById(subStation);
@@ -701,10 +702,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
//获取用户信息
String userName = RequestUtil.getUsername();
String index = RequestUtil.getUserIndex();
//String userName = "zbj";
//String index = "123456";
LineDetail lineDetailResOld = lineDetailMapper.selectById(lineId);
queryUpdateAndInsertLog(userName, index, lineDetailRes, lineDetailResOld);
queryUpdateAndInsertLog(userName, index, lineDetail, lineDetailRes);
}
}
}

View File

@@ -239,8 +239,15 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
String areaId = areaDetail.getId();
if (CollectionUtil.isNotEmpty(allList)) {
List<TerminalTree> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode()) && lineMapper.selectProject(areaId).contains(item.getId())).collect(Collectors.toList());
List<TerminalTree> provinceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROVINCE_LEVEL.getCode()) && item.getName().equals(areaId)).collect(Collectors.toList());
List<TerminalTree> projectList;
List<TerminalTree> provinceList;
if(!"0".equals(areaId)){
projectList=allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode()) && lineMapper.selectProject(areaId).contains(item.getId())).collect(Collectors.toList());
provinceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROVINCE_LEVEL.getCode()) && item.getName().equals(areaId)).collect(Collectors.toList());
}else{
projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).collect(Collectors.toList());
provinceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROVINCE_LEVEL.getCode())).collect(Collectors.toList());
}
for (TerminalTree terminalTree : provinceList) {
terminalTree.setName(lineMapper.getProviceName(terminalTree.getName()));
}
@@ -314,8 +321,15 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
String areaId = areaDetail.getId();
if (CollectionUtil.isNotEmpty(allList)) {
List<TerminalTree> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode()) && lineMapper.selectProject(areaId).contains(item.getId())).collect(Collectors.toList());
List<TerminalTree> provinceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROVINCE_LEVEL.getCode()) && item.getName().equals(areaId)).collect(Collectors.toList());
List<TerminalTree> projectList;
List<TerminalTree> provinceList;
if(!"0".equals(areaId)){
projectList=allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode()) && lineMapper.selectProject(areaId).contains(item.getId())).collect(Collectors.toList());
provinceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROVINCE_LEVEL.getCode()) && item.getName().equals(areaId)).collect(Collectors.toList());
}else{
projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).collect(Collectors.toList());
provinceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROVINCE_LEVEL.getCode())).collect(Collectors.toList());
}
for (TerminalTree terminalTree : provinceList) {
terminalTree.setName(lineMapper.getProviceName(terminalTree.getName()));
}
@@ -380,8 +394,15 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
String areaId = areaDetail.getId();
if (CollectionUtil.isNotEmpty(allList)) {
List<TerminalTree> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode()) && lineMapper.selectProject(areaId).contains(item.getId())).collect(Collectors.toList());
List<TerminalTree> provinceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROVINCE_LEVEL.getCode()) && item.getName().equals(areaId)).collect(Collectors.toList());
List<TerminalTree> projectList;
List<TerminalTree> provinceList;
if(!"0".equals(areaId)){
projectList=allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode()) && lineMapper.selectProject(areaId).contains(item.getId())).collect(Collectors.toList());
provinceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROVINCE_LEVEL.getCode()) && item.getName().equals(areaId)).collect(Collectors.toList());
}else{
projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).collect(Collectors.toList());
provinceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROVINCE_LEVEL.getCode())).collect(Collectors.toList());
}
for (TerminalTree terminalTree : provinceList) {
terminalTree.setName(lineMapper.getProviceName(terminalTree.getName()));
}
@@ -454,8 +475,15 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
String areaId = areaDetail.getId();
if (CollectionUtil.isNotEmpty(allList)) {
List<TerminalTree> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode()) && lineMapper.selectProject(areaId).contains(item.getId())).collect(Collectors.toList());
List<TerminalTree> provinceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROVINCE_LEVEL.getCode()) && item.getName().equals(areaId)).collect(Collectors.toList());
List<TerminalTree> projectList;
List<TerminalTree> provinceList;
if(!"0".equals(areaId)){
projectList=allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode()) && lineMapper.selectProject(areaId).contains(item.getId())).collect(Collectors.toList());
provinceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROVINCE_LEVEL.getCode()) && item.getName().equals(areaId)).collect(Collectors.toList());
}else{
projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).collect(Collectors.toList());
provinceList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROVINCE_LEVEL.getCode())).collect(Collectors.toList());
}
for (TerminalTree terminalTree : provinceList) {
terminalTree.setName(lineMapper.getProviceName(terminalTree.getName()));
}

View File

@@ -109,9 +109,9 @@ public class LargeScreenController extends BaseController {
@PostMapping("/getMiddleDown")
@ApiOperation("大屏中间暂态")
@ApiImplicitParam(name = "largeScreenParam", value = "大屏中间暂态", required = true)
public HttpResult<List<EventVO>> getMiddleDown(@RequestBody @Validated LargeScreenParam largeScreenParam) {
public HttpResult<EventListVO> getMiddleDown(@RequestBody @Validated LargeScreenParam largeScreenParam) {
String methodDescribe = getMethodDescribe("getMiddleDown");
List<EventVO> result = largeScreenService.getMiddleDown(largeScreenParam);
EventListVO result = largeScreenService.getMiddleDown(largeScreenParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@@ -122,9 +122,9 @@ public class LargeScreenController extends BaseController {
@PostMapping("/getMiddleTerminal")
@ApiOperation("大屏中间终端异常信息")
@ApiImplicitParam(name = "largeScreenParam", value = "大屏中间终端异常信息", required = true)
public HttpResult<List<MiddleTerminalVO>> getMiddleTerminal(@RequestBody @Validated LargeScreenParam largeScreenParam) {
public HttpResult<MiddleTerminalListVO> getMiddleTerminal(@RequestBody @Validated LargeScreenParam largeScreenParam) {
String methodDescribe = getMethodDescribe("getMiddleTerminal");
List<MiddleTerminalVO> result = largeScreenService.getMiddleTerminal(largeScreenParam);
MiddleTerminalListVO result = largeScreenService.getMiddleTerminal(largeScreenParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@@ -135,9 +135,9 @@ public class LargeScreenController extends BaseController {
@PostMapping("/getMiddleLimitRate")
@ApiOperation("大屏中间稳态越线信息")
@ApiImplicitParam(name = "largeScreenParam", value = "大屏中间稳态越线信息", required = true)
public HttpResult<List<MiddleLimitRateVO>> getMiddleLimitRate(@RequestBody @Validated LargeScreenParam largeScreenParam) {
public HttpResult<MiddleLimitRateListVO> getMiddleLimitRate(@RequestBody @Validated LargeScreenParam largeScreenParam) {
String methodDescribe = getMethodDescribe("getMiddleLimitRate");
List<MiddleLimitRateVO> result = largeScreenService.getMiddleLimitRate(largeScreenParam);
MiddleLimitRateListVO result = largeScreenService.getMiddleLimitRate(largeScreenParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -32,10 +32,16 @@ public interface LargeScreenMapper {
List<EventVO> getMiddleDown (Page<EventVO> page,@Param("lineIds") List<String> lineIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<EventVO> getMiddleDownChind (@Param("lineIds") List<String> lineIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<MiddleChildVO> getMiddleTerminal (Page<MiddleChildVO> page,@Param("deviceIds") List<String> deviceIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<MiddleChildVO> getMiddleTerminalChild (@Param("deviceIds") List<String> deviceIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<MiddleLimitRateVO> getMiddleLimitRate (Page<MiddleLimitRateVO> page,@Param("lineIds") List<String> deviceIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<MiddleLimitRateVO> getMiddleLimitRateChild (@Param("lineIds") List<String> deviceIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<Map<String,Object>> getHomeostasisArea (@Param("indexIds") List<String> indexIds, @Param("startTime") String startTime, @Param("endTime") String endTime);
/**

View File

@@ -108,11 +108,14 @@
<select id="getMiddleDown" resultType="com.njcn.device.pq.pojo.vo.EventVO">
SELECT
ed.create_time "time",pl.`Name` "name",sdd.`Name` reason,sdd.`Name` "type",ed.feature_amplitude amplitude,ed.duration
ed.create_time "time",
pl.`Name` "name",
ed.advance_reason reason,
ed.advance_type "type",
ed.feature_amplitude amplitude,
ed.duration
from r_mp_event_detail ed
left join pq_line pl on pl.id = ed.measurement_point_id
left join sys_dict_data sdd on sdd.id = ed.advance_reason
left join sys_dict_data sdd2 on sdd.id = ed.advance_type
where
ed.measurement_point_id in
<foreach collection="lineIds" item="item" open="(" close=")" separator=",">
@@ -267,4 +270,97 @@
GROUP BY line_id
</select>
<select id="getMiddleDownChind" resultType="com.njcn.device.pq.pojo.vo.EventVO">
SELECT
ed.create_time "time",
pl.`Name` "name",
ed.advance_reason reason,
ed.advance_type "type",
ed.feature_amplitude amplitude,
ed.duration
from r_mp_event_detail ed
left join pq_line pl on pl.id = ed.measurement_point_id
where
ed.measurement_point_id in
<foreach collection="lineIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="startTime != null and startTime != ''">
and date_format(ed.create_time,'%y%m%d') &gt;= date_format(#{startTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''">
and date_format(ed.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if>
order by ed.create_time desc
</select>
<select id="getMiddleLimitRateChild" resultType="com.njcn.device.pq.pojo.vo.MiddleLimitRateVO">
select pl.`Name` mName,
pl3.`Name` subName,
t.count from pq_line pl
inner join(select rslr.my_index,
sum(rslr.all_time) count
from r_stat_limit_rate_d rslr
WHERE
rslr.my_index IN
<foreach collection="lineIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="startTime != null and startTime != ''">
and date_format(rslr.Time_Id,'%y%m%d') &gt;= date_format(#{startTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''">
and date_format(rslr.Time_Id,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if>
group by rslr.my_index)t on pl.Id = t.my_index
left join pq_line pl1 on pl.Pid = pl1.Id
left join pq_line pl2 on pl1.Pid = pl2.Id
left join pq_line pl3 on pl2.Pid = pl3.Id
</select>
<select id="getMiddleTerminalChild" resultType="com.njcn.device.pq.pojo.vo.MiddleChildVO">
SELECT
pd.id,
IFNULL(
cfm1.flow,(
SELECT
cfm.flow
FROM
cld_flow_meal cfm
WHERE
cfm.type = 0
AND cfm.flag = 1
)) base,
IFNULL( cfm2.flow, 0 ) ream,
IFNULL( cmf.Statis_Value, 0 ) statusValue,
pl1.`Name` "name",
pd.IP ip,
pd.`Port` "port",
case
when pd.Com_Flag = '0' then '通讯中断'
when pd.Com_Flag = '1' then '通讯正常'
end comFlag
FROM
pq_line pl
LEFT JOIN pq_device pd ON pl.id = pd.id
LEFT JOIN cld_dev_meal cdm ON cdm.Line_Id = pd.id
LEFT JOIN cld_flow_meal cfm1 ON cfm1.Id = cdm.Base_Meal_Id
LEFT JOIN cld_flow_meal cfm2 ON cfm2.Id = cdm.Ream_Meal_Id
LEFT JOIN cld_month_flow cmf ON cmf.Dev_Id = pd.id
LEFT JOIN pq_line pl1 ON pl1.id = pl.pid
WHERE
pd.id IN
<foreach collection="deviceIds" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="startTime != null and startTime != ''">
and date_format(cmf.Time_Id,'%y%m%d') &gt;= date_format(#{startTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''">
and date_format(cmf.Time_Id,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if>
</select>
</mapper>

View File

@@ -357,7 +357,7 @@ public class LargeScreenServiceImpl implements LargeScreenService {
* 大屏中间暂态
*/
@Override
public List<EventVO> getMiddleDown(LargeScreenParam largeScreenParam) {
public EventListVO getMiddleDown(LargeScreenParam largeScreenParam) {
DeviceInfoParam.BusinessParam deviceInfoParam = new DeviceInfoParam.BusinessParam();
//部门索引
deviceInfoParam.setDeptIndex(largeScreenParam.getDeptIndex());
@@ -374,14 +374,20 @@ public class LargeScreenServiceImpl implements LargeScreenService {
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
//获取所有监测点集合
List<String> lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
return largeScreenMapper.getMiddleDown(new Page<>(largeScreenParam.getPageNum(), largeScreenParam.getPageSize()),lineIds, largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
List<EventVO> eventVOS = largeScreenMapper.getMiddleDown(new Page<>(largeScreenParam.getPageNum(), largeScreenParam.getPageSize()), lineIds, largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
//获取没分页前的总数据
List<EventVO> chind = largeScreenMapper.getMiddleDownChind(lineIds, largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
EventListVO listVO = new EventListVO();
listVO.setList(eventVOS);
listVO.setSize(chind.size());
return listVO;
}
/**
* 大屏中间终端异常信息
*/
@Override
public List<MiddleTerminalVO> getMiddleTerminal(LargeScreenParam largeScreenParam) {
public MiddleTerminalListVO getMiddleTerminal(LargeScreenParam largeScreenParam) {
//创建返回VO
List<MiddleTerminalVO> result = new ArrayList<>();
DeviceInfoParam.BusinessParam deviceInfoParam = new DeviceInfoParam.BusinessParam();
@@ -399,7 +405,9 @@ public class LargeScreenServiceImpl implements LargeScreenService {
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
//获取所有监测点集合
List<String> deviceIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getDeviceIndexes().stream()).collect(Collectors.toList());
List<MiddleChildVO> map = largeScreenMapper.getMiddleTerminal(new Page<>(largeScreenParam.getPageNum(), largeScreenParam.getPageSize()),deviceIds, largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
List<MiddleChildVO> map = largeScreenMapper.getMiddleTerminal(new Page<>(largeScreenParam.getPageNum(), largeScreenParam.getPageSize()), deviceIds, largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
//获取没分页前的总数据
List<MiddleChildVO> child = largeScreenMapper.getMiddleTerminalChild(deviceIds, largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
float base = 0.0f;
float ream = 0.0f;
@@ -421,7 +429,10 @@ public class LargeScreenServiceImpl implements LargeScreenService {
vo.setProportion(s);
result.add(vo);
}
return result;
MiddleTerminalListVO listVO = new MiddleTerminalListVO();
listVO.setList(result);
listVO.setSize(child.size());
return listVO;
}
public static String formatFloat(Float value) {
@@ -436,7 +447,7 @@ public class LargeScreenServiceImpl implements LargeScreenService {
* 大屏中间稳态越线信息
*/
@Override
public List<MiddleLimitRateVO> getMiddleLimitRate(LargeScreenParam largeScreenParam) {
public MiddleLimitRateListVO getMiddleLimitRate(LargeScreenParam largeScreenParam) {
DeviceInfoParam.BusinessParam deviceInfoParam = new DeviceInfoParam.BusinessParam();
//部门索引
deviceInfoParam.setDeptIndex(largeScreenParam.getDeptIndex());
@@ -452,7 +463,13 @@ public class LargeScreenServiceImpl implements LargeScreenService {
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
//获取所有监测点集合
List<String> lineIds = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
return largeScreenMapper.getMiddleLimitRate(new Page<>(largeScreenParam.getPageNum(), largeScreenParam.getPageSize()),lineIds, largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
List<MiddleLimitRateVO> middleLimitRate = largeScreenMapper.getMiddleLimitRate(new Page<>(largeScreenParam.getPageNum(), largeScreenParam.getPageSize()), lineIds, largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
//获取没分页前的总数据
List<MiddleLimitRateVO> child = largeScreenMapper.getMiddleLimitRateChild(lineIds, largeScreenParam.getSearchBeginTime(), largeScreenParam.getSearchEndTime());
MiddleLimitRateListVO listVO = new MiddleLimitRateListVO();
listVO.setList(middleLimitRate);
listVO.setSize(child.size());
return listVO;
}

View File

@@ -294,32 +294,39 @@ public class TransientServiceImpl implements TransientService {
//按部门分类的实际运行终端综合信息
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceInfoClient.getPracticalRunDeviceInfo(transientParam).getData();
if (!CollectionUtils.isEmpty(generalDeviceDTOList)) {
//获取按终端分类的监测点索引集合
List<String> lineList = generalDeviceDTOList.stream().flatMap(dto -> dto.getLineIndexes().stream()).collect(Collectors.toList());
if(CollUtil.isNotEmpty(lineList)){
Page<RmpEventDetailPO> pageInfo = eventDetailService.page(new Page<>(transientParam.getPageNum(), transientParam.getPageSize()), new LambdaQueryWrapper<RmpEventDetailPO>()
LambdaQueryWrapper<RmpEventDetailPO> wrapper = new LambdaQueryWrapper<RmpEventDetailPO>()
.in(RmpEventDetailPO::getMeasurementPointId, lineList)
.ge(StringUtils.isNotBlank(transientParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(transientParam.getSearchBeginTime())))
.ge(StringUtils.isNotBlank(transientParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(transientParam.getSearchBeginTime())))
.le(StringUtils.isNotBlank(transientParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(transientParam.getSearchEndTime())))
//暂态幅值最小值
.ge(Objects.nonNull(transientParam.getEventValueMin().divide(new BigDecimal(100),2,BigDecimal.ROUND_UP)),RmpEventDetailPO::getFeatureAmplitude, transientParam.getEventValueMin().divide(new BigDecimal(100),2,BigDecimal.ROUND_UP))
.le(Objects.nonNull(transientParam.getEventValueMax().divide(new BigDecimal(100),2,BigDecimal.ROUND_UP)),RmpEventDetailPO::getFeatureAmplitude, transientParam.getEventValueMax().divide(new BigDecimal(100),2,BigDecimal.ROUND_UP))
//持续时间最小值
.ge(Objects.nonNull(transientParam.getPersistMin()),RmpEventDetailPO::getDuration, transientParam.getPersistMin())
.le(Objects.nonNull(transientParam.getPersistMax()),RmpEventDetailPO::getDuration, transientParam.getPersistMax())
//严重度最小值
.ge(Objects.nonNull(transientParam.getSeverityMin()),RmpEventDetailPO::getSeverity, transientParam.getSeverityMin())
.le(Objects.nonNull(transientParam.getSeverityMax()),RmpEventDetailPO::getSeverity, transientParam.getSeverityMax())
//波形文件
.eq(Objects.nonNull(transientParam.getFileFlag()),RmpEventDetailPO::getFileFlag, transientParam.getFileFlag())
//事件
.in(CollUtil.isNotEmpty(transientParam.getWaveType()),RmpEventDetailPO::getEventType, transientParam.getWaveType())
.in(CollUtil.isNotEmpty(transientParam.getEventReason()),RmpEventDetailPO::getAdvanceReason, transientParam.getEventReason())
.in(CollUtil.isNotEmpty(transientParam.getEventType()),RmpEventDetailPO::getAdvanceType, transientParam.getEventType())
.orderByDesc(RmpEventDetailPO::getStartTime)
);
.in(CollUtil.isNotEmpty(transientParam.getWaveType()), RmpEventDetailPO::getEventType, transientParam.getWaveType())
.in(CollUtil.isNotEmpty(transientParam.getEventReason()), RmpEventDetailPO::getAdvanceReason, transientParam.getEventReason())
.in(CollUtil.isNotEmpty(transientParam.getEventType()), RmpEventDetailPO::getAdvanceType, transientParam.getEventType())
.orderByDesc(RmpEventDetailPO::getStartTime);
//暂态幅值
if (Objects.nonNull(transientParam.getEventValueMin())) {
wrapper.ge(RmpEventDetailPO::getFeatureAmplitude, transientParam.getEventValueMin().divide(new BigDecimal(100), 2, BigDecimal.ROUND_UP));
}
if (Objects.nonNull(transientParam.getEventValueMax())) {
wrapper.le(RmpEventDetailPO::getFeatureAmplitude, transientParam.getEventValueMax().divide(new BigDecimal(100), 2, BigDecimal.ROUND_UP));
}
if (Objects.nonNull(transientParam.getPersistMin()) && Objects.nonNull(transientParam.getSeverityMax())) {
wrapper.ge(RmpEventDetailPO::getDuration, transientParam.getPersistMin()).le(RmpEventDetailPO::getDuration, transientParam.getPersistMax());
}
//严重度
if (Objects.nonNull(transientParam.getSeverityMin()) && Objects.nonNull(transientParam.getSeverityMax())) {
wrapper.ge(RmpEventDetailPO::getSeverity, transientParam.getSeverityMin()).le(Objects.nonNull(transientParam.getSeverityMax()), RmpEventDetailPO::getSeverity, transientParam.getSeverityMax());
}
//波形文件
if (Objects.nonNull(transientParam.getFileFlag())) {
wrapper.eq(Objects.nonNull(transientParam.getFileFlag()), RmpEventDetailPO::getFileFlag, transientParam.getFileFlag());
}
Page<RmpEventDetailPO> pageInfo = eventDetailService.page(new Page<>(transientParam.getPageNum(), transientParam.getPageSize()),wrapper);
List<EventDetailNew> eventDetailData=BeanUtil.copyToList(pageInfo.getRecords(),EventDetailNew.class);
page= BeanUtil.copyProperties(pageInfo,Page.class);

View File

@@ -25,11 +25,11 @@ public interface LargeScreenService {
List<AllDataVO> getAllData(LargeScreenParam largeScreenParam);
List<EventVO> getMiddleDown(LargeScreenParam largeScreenParam);
EventListVO getMiddleDown(LargeScreenParam largeScreenParam);
List<MiddleTerminalVO> getMiddleTerminal(LargeScreenParam largeScreenParam);
MiddleTerminalListVO getMiddleTerminal(LargeScreenParam largeScreenParam);
List<MiddleLimitRateVO> getMiddleLimitRate(LargeScreenParam largeScreenParam);
MiddleLimitRateListVO getMiddleLimitRate(LargeScreenParam largeScreenParam);
List<PQSComAssesPO> getComAccessData(List<String> lineIndexes, String searchBeginTime, String searchEndTime);

View File

@@ -27,4 +27,10 @@ public class ReportQueryParam {
@NotBlank(message = "结束时间不可为空")
private String endTime;
@ApiModelProperty(name = "b",value = "判断时间是否是当天true 当天 false不是当天")
private Boolean b ;
@ApiModelProperty(name = "lineId",value = "95条数取值")
private double count;
}

View File

@@ -0,0 +1,81 @@
package com.njcn.harmonic.pojo.po.report;
import lombok.Data;
import org.influxdb.annotation.Column;
import org.influxdb.annotation.Measurement;
import java.time.Instant;
/**
* data_v influxDB别名映射表
*
* @author qijian
* @version 1.0.0
* @createTime 2022/10/27 15:27
*/
@Data
@Measurement(name = "data_i")
public class DataI {
@Column(name = "time")
private Instant time;
@Column(name = "phasic_type")
private String phaseType;
@Column(name = "value_type")
private String valueType;
@Column(name = "rms")
private Double rms;
@Column(name = "line_id")
private String lineId;
@Column(name = "freq_max")
private Double frepMAX;
@Column(name = "freq_min")
private Double frepMIN;
@Column(name = "rms_max")
private Double rmsMAX;
@Column(name = "rms_min")
private Double rmsMIN;
@Column(name = "rms_lvr_max")
private Double rmsLvrMAX;
@Column(name = "rms_lvr_min")
private Double rmsLvrMIN;
@Column(name = "v_thd_max")
private Double vThdMAX;
@Column(name = "v_thd_min")
private Double vThdMIN;
@Column(name = "v_unbalance_max")
private Double vUnbalanceMAX;
@Column(name = "v_unbalance_min")
private Double vUnbalanceMIN;
@Column(name = "freq_count")
private Integer freqCount;
@Column(name = "rms_count")
private Integer rmsCount;
@Column(name = "rms_lvr_count")
private Integer rmsLvrCount;
@Column(name = "v_thd_count")
private Integer vThdCount;
@Column(name = "v_unbalance_count")
private Integer vUnbalanceCount;
}

View File

@@ -0,0 +1,35 @@
package com.njcn.harmonic.pojo.po.report;
public enum EnumPass {
MAX(1, "使用最大值与国标限值比较,判断指标是否合格"),
MIN(2, "使用最小值与国标限值比较,判断指标是否合格"),
MEAN(3, "使用平均值与国标限值比较,判断指标是否合格"),
CP95(4, "使用CP95值与国标限值比较判断指标是否合格"),
DEFAULT(5, "不作比较"),
PASS(0, "合格"),
FPYVALUE(98, "合格率限值"),
FPYV(1, "UHARM_0_OVERTIME"),
FPYI(2, "IHARM_0_OVERTIME"),
FPYVOLTAGE(3, "VOLTAGE_DEV_OVERTIME"),
FPYTHREE(4, "UBALANCE_OVERTIME"),
FPYTHDV(5, "UABERRANCE_OVERTIME"),
FPYRATE(6, "FREQ_DEV_OVERTIME"),
FPYFLICKER(7, "FLICKER_OVERTIME"),
NOPASS(-1, "不合格");
private Integer code;
private String describe;
EnumPass(Integer code, String describe) {
this.code = code;
this.describe = describe;
}
public Integer getCode() {
return code;
}
public String getDescribe() {
return describe;
}
}

View File

@@ -0,0 +1,20 @@
package com.njcn.harmonic.pojo.po.report;
import com.njcn.device.pq.pojo.po.Overlimit;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class OverLimitInfo implements Serializable {
private static final long serialVersionUID = 7466469972886414616L;
private List<Overlimit> overLimitRate;
private Double count;
private Double pltCount;
private Double pstCount;
private List<String> list;
private String mode;
}

View File

@@ -0,0 +1,24 @@
package com.njcn.harmonic.pojo.po.report;
import lombok.Data;
/**
* @author wr
* @description
* @date 2023/4/12 11:40
*/
@Data
public class Pass {
private Float overLimit;
private Integer code;
public Pass(Float overLimit) {
this.code = EnumPass.DEFAULT.getCode();
this.overLimit = overLimit;
}
public Pass(Float overLimit, Integer code) {
this.overLimit = overLimit;
this.code = code;
}
}

View File

@@ -0,0 +1,17 @@
package com.njcn.harmonic.pojo.po.report;
import com.njcn.harmonic.pojo.vo.ReportValue;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class ReportTarget implements Serializable {
private static final long serialVersionUID = -6931764660060228127L;
private List<ReportValue> list;
private Float overLimit; //指标的国标限值
private Integer pass;
}

View File

@@ -0,0 +1,77 @@
package com.njcn.harmonic.pojo.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author wr
* @description
* @date 2023/4/10 15:36
*/
@NoArgsConstructor
public class ReportValue implements Serializable {
private String phaseType; //A(AB)相B(BC)相C(CA)相T总功
private Float fmaxValue; //最大值
private Float minValue; //最小值
private Float meanValue; //平均值
private Float cp95Value; //CP95值
public String getPhaseType() {
return phaseType;
}
public Float getFmaxValue() {
return fmaxValue;
}
public Float getMinValue() {
return minValue;
}
public Float getMeanValue() {
return meanValue;
}
public Float getCp95Value() {
return cp95Value;
}
public void setPhaseType(String phaseType) {
this.phaseType = phaseType;
}
public void setFmaxValue(Float fmaxValue) {
this.fmaxValue = transData(fmaxValue);
}
public void setMinValue(Float minValue) {
this.minValue = transData(minValue);
}
public void setMeanValue(Float meanValue) {
this.meanValue = transData(meanValue);
}
public void setCp95Value(Float cp95Value) {
this.cp95Value = transData(cp95Value);
}
public ReportValue(String phaseType, Float maxValue, Float minValue, Float meanValue, Float cp95Value) {
this.phaseType = phaseType;
this.fmaxValue = transData(maxValue);
this.minValue = transData(minValue);
this.meanValue = transData(meanValue);
this.cp95Value = transData(cp95Value);
}
private Float transData(Float f) {
if (f == null) {
return f;
}
float f1 = (float) (Math.round(f.floatValue() * 100)) / 100;
return new Float(f1);
}
}

View File

@@ -0,0 +1,141 @@
package com.njcn.harmonic.utils;
/**
* @author hongawen
* @date: 2020/8/20 13:36
*/
public class ClearPathUtil {
/**
* 针对漏洞,新增的特殊字符替换的扫描方法
*/
public static String cleanString(String str) {
if (str == null){
return null;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < str.length(); ++i) {
sb.append(cleanChar(str.charAt(i)));
}
return sb.toString();
}
private static char cleanChar(char ch) {
// 0 - 9
for (int i = 48; i < 58; ++i) {
if (ch == i) {
return (char) i;
}
}
// 'A' - 'Z'
for (int i = 65; i < 91; ++i) {
if (ch == i) {
return (char) i;
}
}
// 'a' - 'z'
for (int i = 97; i < 123; ++i) {
if (ch == i) {
return (char) i;
}
}
// other valid characters
switch (ch) {
case '/':
return '/';
case '.':
return '.';
case '-':
return '-';
case '_':
return '_';
case ',':
return ',';
case ' ':
return ' ';
case '!':
return '!';
case '@':
return '@';
case '#':
return '#';
case '$':
return '$';
case '%':
return '%';
case '^':
return '^';
case '&':
return '&';
case '*':
return '*';
case '(':
return '(';
case ')':
return ')';
case '+':
return '+';
case '=':
return '=';
case ':':
return ':';
case ';':
return ';';
case '?':
return '?';
case '"':
return '"';
case '<':
return '<';
case '>':
return '>';
case '`':
return '`';
case '\\':
return '/';
case 'I':
return 'I';
case 'Ⅱ':
return 'Ⅱ';
case 'Ⅲ':
return 'Ⅲ';
case 'Ⅳ':
return 'Ⅳ';
case '':
return '';
case 'Ⅵ':
return 'Ⅵ';
case 'Ⅶ':
return 'Ⅶ';
case 'Ⅷ':
return 'Ⅷ';
case 'Ⅸ':
return 'Ⅸ';
case 'V':
return 'V';
case 'X':
return 'X';
case '':
return '';
}
if (isChineseChar(ch)){
return ch;
}
return '%';
}
// 根据Unicode编码判断中文汉字和符号
private static boolean isChineseChar(char c) {
Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
return ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION;
}
}

View File

@@ -0,0 +1,83 @@
package com.njcn.harmonic.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlToken;
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;
import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;
import java.io.IOException;
import java.io.InputStream;
@Slf4j
public class CustomXWPFDocument extends XWPFDocument {
// 日志记录
public CustomXWPFDocument(InputStream in) throws IOException {
super(in);
}
public CustomXWPFDocument() {
super();
}
public CustomXWPFDocument(OPCPackage pkg) throws IOException {
super(pkg);
}
/**
* @param id
* @param width
* 宽
* @param height
* 高
* @param paragraph
* 段落
*/
public void createPicture(int id, int width, int height,String blipId, XWPFParagraph paragraph) {
final int EMU = 9525;
width *= EMU;
height *= EMU;
// String blipId = getAllPictures().get(id).getPackageRelationship().getId();
CTInline inline = paragraph.createRun().getCTR().addNewDrawing().addNewInline();
String picXml = "" + "<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">"
+ " <a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">"
+ " <pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">"
+ " <pic:nvPicPr>" + " <pic:cNvPr id=\"" + id + "\" name=\"Generated\"/>"
+ " <pic:cNvPicPr/>" + " </pic:nvPicPr>" + " <pic:blipFill>"
+ " <a:blip r:embed=\"" + blipId
+ "\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"/>"
+ " <a:stretch>" + " <a:fillRect/>" + " </a:stretch>"
+ " </pic:blipFill>" + " <pic:spPr>" + " <a:xfrm>"
+ " <a:off x=\"0\" y=\"0\"/>" + " <a:ext cx=\"" + width + "\" cy=\""
+ height + "\"/>" + " </a:xfrm>" + " <a:prstGeom prst=\"rect\">"
+ " <a:avLst/>" + " </a:prstGeom>" + " </pic:spPr>"
+ " </pic:pic>" + " </a:graphicData>" + "</a:graphic>";
inline.addNewGraphic().addNewGraphicData();
XmlToken xmlToken = null;
try {
xmlToken = XmlToken.Factory.parse(picXml);
} catch (XmlException xe) {
log.error("生成报表发生异常,异常是"+xe.getMessage());
}
inline.set(xmlToken);
inline.setDistT(0);
inline.setDistB(0);
inline.setDistL(0);
inline.setDistR(0);
CTPositiveSize2D extent = inline.addNewExtent();
extent.setCx(width);
extent.setCy(height);
CTNonVisualDrawingProps docPr = inline.addNewDocPr();
docPr.setId(id);
docPr.setName("图片" + id);
docPr.setDescr("测试");
}
}

View File

@@ -0,0 +1,88 @@
package com.njcn.harmonic.utils;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.util.Properties;
/**
* @author wr
* @description
* @date 2023/4/10 17:39
*/
@Slf4j
public class PubUtils {
public static boolean createFile(String destFileName) {
File file = new File(destFileName);
if (file.exists()) {
log.warn("创建单个文件" + destFileName + "失败,目标文件已存在!");
return false;
}
if (destFileName.endsWith(File.separator)) {
log.warn("创建单个文件" + destFileName + "失败,目标文件不能为目录!");
return false;
}
//判断目标文件所在的目录是否存在
if (!file.getParentFile().exists()) {
//如果目标文件所在的目录不存在,则创建父目录
log.warn("目标文件所在目录不存在,准备创建它!");
if (!file.getParentFile().mkdirs()) {
log.warn("创建目标文件所在目录失败!");
return false;
}
}
//创建目标文件
try {
if (file.createNewFile()) {
log.warn("创建单个文件" + destFileName + "成功!");
return true;
} else {
log.warn("创建单个文件" + destFileName + "失败!");
return false;
}
} catch (IOException e) {
log.warn("创建单个文件" + destFileName + "失败!" + e.getMessage());
return false;
}
}
/**
* 读取配置文件
*
* @param cl 类名字
* @param strPropertiesName 配置文件名称
*/
public static Properties readProperties(ClassLoader cl, String strPropertiesName) {
Properties pros = new Properties();
InputStream in = null;
try {
in = cl.getResourceAsStream(strPropertiesName);
pros.load(in);
} catch (Exception e) {
log.error("读取配置文件失败失败:" + e.getMessage());
} finally {
if (in != null) {
PubUtils.safeClose(in, "安全关闭读取配置文件失败,异常为:");
}
}
return pros;
}
/**
* 安全关闭InputStream
*
* @param s
*/
public static void safeClose(InputStream s, String strError) {
if (s != null) {
try {
s.close();
} catch (IOException e) {
log.error(strError + e.toString());
}
}
}
}

View File

@@ -0,0 +1,360 @@
package com.njcn.harmonic.utils;
import org.apache.poi.xwpf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.*;
import java.net.URLEncoder;
import java.util.*;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class WordUtil2 {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(WordUtil2.class);
public void getWord(String path, Map<String, Object> params, String fileName, HttpServletResponse response, HttpSession session)
throws Exception {
path = ClearPathUtil.cleanString(path);
File file = new File(path);
InputStream inStream = null;
CustomXWPFDocument doc = null;
//读取报告模板
try {
inStream = new FileInputStream(file);
doc = new CustomXWPFDocument(inStream);
this.replaceInTable(doc, params); // 替换表格里面的变量
this.replaceInPara(doc, params); // 替换文本里面的变量
} catch (IOException e) {
logger.error("获取报告模板异常,原因为:" + e.toString());
} finally {
if (null != inStream) {
inStream.close();
}
}
// //读取配置文件
// Properties pros = PubUtils.readProperties(getClass().getClassLoader(), "java.properties");
// String tmpPath = pros.get("TMP_PATH").toString() +File.separator+ "offlinereoprt";
// tmpPath= ClearPathUtil.cleanString(tmpPath);
// OutputStream os = null;
// File tmpfile = new File(tmpPath);
// if(!tmpfile.exists()){
// tmpfile.mkdir();
// }
// tmpPath = tmpPath +File.separator+ fileName;
// tmpPath= ClearPathUtil.cleanString(tmpPath);
// File tmp = new File(tmpPath);
// if(tmp.exists()){
// tmp.delete();
// }
// PubUtils.createFile(tmpPath);
try {
// os = new FileOutputStream(tmpPath);
// if (doc != null) {
// doc.write(os);
// }
ServletOutputStream outputStream = response.getOutputStream();
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
response.setContentType("application/octet-stream;charset=UTF-8");
doc.write(outputStream);
outputStream.close();
// session.setAttribute("tmpPath", tmpPath);
// session.setAttribute("fileName", fileName);
} catch (Exception e) {
session.setAttribute("tmpPath", "");
session.setAttribute("fileName", "");
logger.error("输出稳态报告异常,原因为:" + e.toString());
} finally {
// if (os != null) {
// os.close();
// }
if (doc != null) {
doc.close();
}
}
}
/**
* 替换段落里面的变量
*
* @param doc 要替换的文档
* @param params 参数
*/
private void replaceInPara(CustomXWPFDocument doc, Map<String, Object> params) {
Iterator<XWPFParagraph> iterator = doc.getParagraphsIterator();
List<XWPFParagraph> paragraphList = new ArrayList<>();
XWPFParagraph para;
while (iterator.hasNext()) {
para = iterator.next();
paragraphList.add(para);
}
processParagraphs(paragraphList, params, doc);
}
private void replaceInTable(CustomXWPFDocument doc, Map<String, Object> params) {
Iterator<XWPFTable> it = doc.getTablesIterator();
while (it.hasNext()) {
XWPFTable table = it.next();
List<XWPFTableRow> rows = table.getRows();
for (XWPFTableRow row : rows) {
List<XWPFTableCell> cells = row.getTableCells();
for (XWPFTableCell cell : cells) {
List<XWPFParagraph> paragraphListTable = cell.getParagraphs();
processParagraphs(paragraphListTable, params, doc);
}
}
}
}
public static void processParagraphs(List<XWPFParagraph> paragraphList, Map<String, Object> param,
CustomXWPFDocument doc) {
if (paragraphList != null && paragraphList.size() > 0) {
for (XWPFParagraph paragraph : paragraphList) {
List<XWPFRun> runs = paragraph.getRuns();
if (runs.size() > 0) {
for (XWPFRun run : runs) {
String bflag = "";
String text = run.getText(0);
if (text != null) {
boolean isSetText = false;
for (Entry<String, Object> entry : param.entrySet()) {
String key = entry.getKey();
if (text.indexOf(key) != -1) {
isSetText = true;
Object value = entry.getValue();
if (value instanceof String) {// 文本替换
text = text.replace(key, value.toString());
} else if (value instanceof Map) {// 图片替换
text = text.replace(key, "");
Map pic = (Map) value;
int width = Integer.parseInt(pic.get("width").toString());
int height = Integer.parseInt(pic.get("height").toString());
int picType = getPictureType(pic.get("type").toString());
byte[] byteArray = (byte[]) pic.get("content");
ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray);
try {
String s = doc.addPictureData(byteInputStream, picType);
doc.createPicture(doc.getAllPictures().size() - 1, width, height,
s,paragraph);
bflag = "break";
} catch (Exception e) {
logger.error("文本替换发生异常,异常是" + e.getMessage());
}
}
}
}
if (isSetText) {
run.setText(text, 0);
}
}
if (bflag == "break") {
break;
}
}
}
}
}
}
/**
* 替换段落里面的变量
*
* @param para 要替换的段落
* @param params 参数
*/
private void replaceInPara(XWPFParagraph para, Map<String, Object> params, CustomXWPFDocument doc) {
List<XWPFRun> runs;
Matcher matcher;
// if (this.matcher(para.getParagraphText()).find()) {
runs = para.getRuns();
int start = -1;
int end = -1;
String str = "";
for (int i = 0; i < runs.size(); i++) {
XWPFRun run = runs.get(i);
String runText = run.toString();
if ('$' == runText.charAt(0) && '{' == runText.charAt(1)) {
start = i;
}
if ((start != -1)) {
str += runText;
}
if ('}' == runText.charAt(runText.length() - 1)) {
if (start != -1) {
end = i;
break;
}
}
}
for (int i = start; i <= end; i++) {
para.removeRun(i);
i--;
end--;
}
for (Entry<String, Object> entry : params.entrySet()) {
String key = entry.getKey();
if (str.indexOf(key) != -1) {
Object value = entry.getValue();
if (value instanceof String) {
str = str.replace(key, value.toString());
para.createRun().setText(str, 0);
break;
} else if (value instanceof Map) {
str = str.replace(key, "");
Map pic = (Map) value;
int width = Integer.parseInt(pic.get("width").toString());
int height = Integer.parseInt(pic.get("height").toString());
int picType = getPictureType(pic.get("type").toString());
byte[] byteArray = (byte[]) pic.get("content");
ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray);
try {
// int ind = doc.addPicture(byteInputStream,picType);
// doc.createPicture(ind, width , height,para);
String s = doc.addPictureData(byteInputStream, picType);
doc.createPicture(doc.getAllPictures().size() - 1, width, height,s, para);
para.createRun().setText(str, 0);
break;
} catch (Exception e) {
logger.error("文件替换发生异常,异常是" + e.getMessage());
}
}
}
}
// }
}
/**
* 为表格插入数据,行数不够添加新行
*
* @param table 需要插入数据的表格
* @param tableList 插入数据集合
*/
private static void insertTable(XWPFTable table, List<String[]> tableList) {
// 创建行,根据需要插入的数据添加新行,不处理表头
for (int i = 0; i < tableList.size(); i++) {
XWPFTableRow row = table.createRow();
}
// 遍历表格插入数据
List<XWPFTableRow> rows = table.getRows();
int length = table.getRows().size();
for (int i = 1; i < length - 1; i++) {
XWPFTableRow newRow = table.getRow(i);
List<XWPFTableCell> cells = newRow.getTableCells();
for (int j = 0; j < cells.size(); j++) {
XWPFTableCell cell = cells.get(j);
String s = tableList.get(i - 1)[j];
cell.setText(s);
}
}
}
/**
* 替换表格里面的变量
*
* @param doc 要替换的文档
* @param params 参数
*/
private void replaceInTable(CustomXWPFDocument doc, Map<String, Object> params, List<String[]> tableList) {
Iterator<XWPFTable> iterator = doc.getTablesIterator();
XWPFTable table;
List<XWPFTableRow> rows;
List<XWPFTableCell> cells;
List<XWPFParagraph> paras;
while (iterator.hasNext()) {
table = iterator.next();
if (table.getRows().size() > 1) {
// 判断表格是需要替换还是需要插入,判断逻辑有$为替换,表格无$为插入
if (this.matcher(table.getText()).find()) {
rows = table.getRows();
for (XWPFTableRow row : rows) {
cells = row.getTableCells();
for (XWPFTableCell cell : cells) {
paras = cell.getParagraphs();
for (XWPFParagraph para : paras) {
this.replaceInPara(para, params, doc);
}
}
}
} else {
insertTable(table, tableList); // 插入数据
}
}
}
}
/**
* 正则匹配字符串
*
* @param str
* @return
*/
private Matcher matcher(String str) {
Pattern pattern = Pattern.compile("\\$\\{(.+?)\\}", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(str);
return matcher;
}
/**
* 根据图片类型,取得对应的图片类型代码
*
* @param picType
* @return int
*/
private static int getPictureType(String picType) {
int res = CustomXWPFDocument.PICTURE_TYPE_PICT;
if (picType != null) {
if (picType.equalsIgnoreCase("image/png")) {
res = CustomXWPFDocument.PICTURE_TYPE_PNG;
} else if (picType.equalsIgnoreCase("image/dib")) {
res = CustomXWPFDocument.PICTURE_TYPE_DIB;
} else if (picType.equalsIgnoreCase("image/emf")) {
res = CustomXWPFDocument.PICTURE_TYPE_EMF;
} else if (picType.equalsIgnoreCase("image/jpg") || picType.equalsIgnoreCase("image/jpeg")) {
res = CustomXWPFDocument.PICTURE_TYPE_JPEG;
} else if (picType.equalsIgnoreCase("image/wmf")) {
res = CustomXWPFDocument.PICTURE_TYPE_WMF;
}
}
return res;
}
/**
* 关闭输入流
*
* @param is
*/
private void close(InputStream is) {
if (is != null) {
try {
is.close();
} catch (IOException e) {
logger.error("关闭输入流发生异常,异常是" + e.getMessage());
}
}
}
/**
* 关闭输出流
*
* @param os
*/
private void close(OutputStream os) {
if (os != null) {
try {
os.close();
} catch (IOException e) {
logger.error("关闭输出流发生异常,异常是" + e.getMessage());
}
}
}
}

View File

@@ -95,6 +95,16 @@
<build>
<finalName>harmonicboot</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>docx</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>

View File

@@ -0,0 +1,16 @@
package com.njcn.harmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.day.RStatDataIDPO;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wr
* @since 2023-04-17
*/
public interface RStatDataIDMapper extends BaseMapper<RStatDataIDPO> {
}

View File

@@ -0,0 +1,130 @@
package com.njcn.harmonic.mapper;
import com.njcn.harmonic.pojo.param.ReportQueryParam;
import com.njcn.harmonic.pojo.vo.ReportValue;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 谐波报告查询
*/
public interface ReportMapper {
/**
* 获取电流有效值
* @return
*/
List<ReportValue> getVirtualDataI(@Param("param") ReportQueryParam param);
/**
* 获取电压有效值
* @return
*/
List<ReportValue> getVirtualDataV(@Param("param") ReportQueryParam param);
/**
* CP95条数
* @param param
* @return
*/
Integer getTotalCP95Day(@Param("param")ReportQueryParam param);
/**
* CP95条数
* @param param
* @return
*/
Integer getTotalPltCP95Day(@Param("param")ReportQueryParam param);
/**
* CP95条数
* @param param
* @return
*/
Integer getTotalPstCP95Day(@Param("param")ReportQueryParam param);
List<ReportValue> getVVirtualData(@Param("param")ReportQueryParam param);
/**
* 获取有功功率
* @param param
* @return
*/
List<ReportValue> getPowerP(@Param("param")ReportQueryParam param);
/**
* 无功功率
* @param param
* @return
*/
List<ReportValue> getPowerQ(@Param("param")ReportQueryParam param);
/**
* 视在功率
* @param param
* @return
*/
List<ReportValue> getPowerS(@Param("param")ReportQueryParam param);
/**
* 功率因数
* @param param
* @return
*/
List<ReportValue> getPF(@Param("param")ReportQueryParam param);
/**
* 短时闪变
* @param param
* @return
*/
List<ReportValue> getFlickerData(@Param("param")ReportQueryParam param);
/**
* 长时闪变
* @param param
* @return
*/
List<ReportValue> getLFlickerData(@Param("param")ReportQueryParam param);
/**
* 电压负偏差
* @param param
* @return
*/
List<ReportValue> getUVdeviationData(@Param("param")ReportQueryParam param);
/**
* 电压正偏差
* @param param
* @return
*/
List<ReportValue> getLVdeviationData(@Param("param")ReportQueryParam param);
/**
* 获取电压畸变率
* @param param
* @return
*/
List<ReportValue> getDistortionDataV(@Param("param")ReportQueryParam param);
/**
* 获取电流畸变率
* @param param
* @return
*/
List<ReportValue> getDistortionDataI(@Param("param")ReportQueryParam param);
/**
*频率
* @param param
* @return
*/
List<ReportValue> getFrequencyData(@Param("param")ReportQueryParam param);
/**
*
* @param param
* @return
*/
List<ReportValue> getDEVFrequencyData(@Param("param")ReportQueryParam param);
}

View File

@@ -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.njcn.harmonic.mapper.RStatDataIDMapper">
</mapper>

View File

@@ -0,0 +1,905 @@
<?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.njcn.harmonic.mapper.ReportMapper">
<select id="getVirtualDataI" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
rms,
@rank := IF( @CI := phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_i_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN 1
WHEN value_type = 'MAX' THEN 2
WHEN value_type = 'MIN' THEN 3
WHEN value_type = 'AVG' THEN 4
ELSE 5
END
),
rms DESC
) AS t1
) a
GROUP BY
`phasic_type`;
</select>
<select id="getVirtualDataV" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
rms,
@rank := IF( @CI = phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_v_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN 1
WHEN value_type = 'MAX' THEN 2
WHEN value_type = 'MIN' THEN 3
WHEN value_type = 'AVG' THEN 4
ELSE 5
END
),
rms DESC
) AS t1
) a
GROUP BY
`phasic_type`
</select>
<select id="getTotalCP95Day" resultType="java.lang.Integer">
SELECT
count( rms ) total
FROM
r_stat_data_v_d
<where>
phasic_type IN ( 'A' )
AND value_type = "CP95"
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
</select>
<select id="getTotalPltCP95Day" resultType="java.lang.Integer">
SELECT
count( plt ) total
FROM
r_stat_data_plt_d
<where>
phasic_type IN ( 'A' )
AND value_type = "CP95"
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
</select>
<select id="getTotalPstCP95Day" resultType="java.lang.Integer">
SELECT
count( plt ) total
FROM
r_stat_data_flicker_d
<where>
phasic_type IN ( 'A' )
AND value_type = "CP95"
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
</select>
<select id="getVVirtualData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
rms_lvr as rms,
@rank := IF( @CI = phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_v_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN 1
WHEN value_type = 'MAX' THEN 2
WHEN value_type = 'MIN' THEN 3
WHEN value_type = 'AVG' THEN 4
ELSE 5
END
),
rms_lvr DESC
) AS t1
) a
GROUP BY
`phasic_type`
</select>
<select id="getPowerP" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
p as rms,
@rank :=
IF
( @CI = phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_harmpower_p_d
<where>
phasic_type IN ( 'A', 'B', 'C' ,'T')
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN
1
WHEN value_type = 'MAX' THEN
2
WHEN value_type = 'MIN' THEN
3
WHEN value_type = 'AVG' THEN
4 ELSE 5
END
),
p DESC
) AS t1
) a
GROUP BY
`phasic_type`
</select>
<select id="getPF" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
pf as rms,
@rank :=
IF
( @CI = phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_harmpower_p_d
<where>
phasic_type IN ( 'A', 'B', 'C' ,'T')
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN
1
WHEN value_type = 'MAX' THEN
2
WHEN value_type = 'MIN' THEN
3
WHEN value_type = 'AVG' THEN
4 ELSE 5
END
),
pf DESC
) AS t1
) a
GROUP BY
`phasic_type`
</select>
<select id="getPowerQ" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
q as rms,
@rank :=
IF
( @CI = phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_harmpower_q_d
<where>
phasic_type IN ( 'A', 'B', 'C' ,'T')
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN
1
WHEN value_type = 'MAX' THEN
2
WHEN value_type = 'MIN' THEN
3
WHEN value_type = 'AVG' THEN
4 ELSE 5
END
),
q DESC
) AS t1
) a
GROUP BY
`phasic_type`
</select>
<select id="getPowerS" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
s as rms,
@rank :=
IF
( @CI = phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_harmpower_s_d
<where>
phasic_type IN ( 'A', 'B', 'C' ,'T')
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN
1
WHEN value_type = 'MAX' THEN
2
WHEN value_type = 'MIN' THEN
3
WHEN value_type = 'AVG' THEN
4 ELSE 5
END
),
s DESC
) AS t1
) a
GROUP BY
`phasic_type`
</select>
<select id="getFlickerData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
plt as rms,
@rank :=
IF
( @CI = phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_flicker_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN
1
WHEN value_type = 'MAX' THEN
2
WHEN value_type = 'MIN' THEN
3
WHEN value_type = 'AVG' THEN
4 ELSE 5
END
),
plt DESC
) AS t1
) a
GROUP BY
`phasic_type`
</select>
<select id="getLFlickerData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
pst as rms,
@rank :=
IF
( @CI = phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_flicker_d
<where>
phasic_type IN ( 'A', 'B', 'C')
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN
1
WHEN value_type = 'MAX' THEN
2
WHEN value_type = 'MIN' THEN
3
WHEN value_type = 'AVG' THEN
4 ELSE 5
END
),
pst DESC
) AS t1
) a
GROUP BY
`phasic_type`
</select>
<select id="getUVdeviationData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
vu_dev as rms,
@rank := IF( @CI := phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_v_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN 1
WHEN value_type = 'MAX' THEN 2
WHEN value_type = 'MIN' THEN 3
WHEN value_type = 'AVG' THEN 4
ELSE 5
END
),
vu_dev DESC
) AS t1
) a
GROUP BY
`phasic_type`;
</select>
<select id="getLVdeviationData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
vl_dev as rms,
@rank := IF( @CI := phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_v_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN 1
WHEN value_type = 'MAX' THEN 2
WHEN value_type = 'MIN' THEN 3
WHEN value_type = 'AVG' THEN 4
ELSE 5
END
),
vl_dev DESC
) AS t1
) a
GROUP BY
`phasic_type`;
</select>
<select id="getDistortionDataV" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
v_thd as rms,
@rank := IF( @CI := phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_v_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN 1
WHEN value_type = 'MAX' THEN 2
WHEN value_type = 'MIN' THEN 3
WHEN value_type = 'AVG' THEN 4
ELSE 5
END
),
v_thd DESC
) AS t1
) a
GROUP BY
`phasic_type`;
</select>
<select id="getDistortionDataI" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
i_thd as rms,
@rank := IF( @CI := phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_i_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN 1
WHEN value_type = 'MAX' THEN 2
WHEN value_type = 'MIN' THEN 3
WHEN value_type = 'AVG' THEN 4
ELSE 5
END
),
i_thd DESC
) AS t1
) a
GROUP BY
`phasic_type`;
</select>
<select id="getFrequencyData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
freq as rms,
@rank := IF( @CI := phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_v_d
<where>
phasic_type = 'T'
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN 1
WHEN value_type = 'MAX' THEN 2
WHEN value_type = 'MIN' THEN 3
WHEN value_type = 'AVG' THEN 4
ELSE 5
END
),
freq DESC
) AS t1
) a
GROUP BY
`phasic_type`;
</select>
<select id="getDEVFrequencyData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
`phasic_type` AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN rank = #{param.count} THEN rms END ) AS cp95Value
FROM
(
SELECT
phasic_type,
value_type,
rms,
rank
FROM
(
SELECT
phasic_type,
value_type,
freq_dev as rms,
@rank := IF( @CI := phasic_type, @rank + 1, 1 ) AS rank,
@CI := phasic_type
FROM
r_stat_data_v_d
<where>
phasic_type = 'T'
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and `time` >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and `time` &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
ORDER BY
phasic_type,
(
CASE
WHEN value_type = 'CP95' THEN 1
WHEN value_type = 'MAX' THEN 2
WHEN value_type = 'MIN' THEN 3
WHEN value_type = 'AVG' THEN 4
ELSE 5
END
),
freq_dev DESC
) AS t1
) a
GROUP BY
`phasic_type`;
</select>
</mapper>

View File

@@ -0,0 +1,83 @@
package com.njcn.harmonic.service;
import com.njcn.harmonic.pojo.param.ReportQueryParam;
import com.njcn.harmonic.pojo.po.report.OverLimitInfo;
import com.njcn.harmonic.pojo.vo.ReportValue;
import java.util.List;
/**
* 谐波报告
*/
public interface ReportService {
/**
*
* @param param
* @return
*/
OverLimitInfo getOverLimitData(ReportQueryParam param);
/**
* 基波增幅
* @param param
* @return
*/
List<ReportValue> getVirtualData(ReportQueryParam param);
/**
* 功率
* @param param
* @return
*/
List<ReportValue> getPowerData(ReportQueryParam param);
/**
* 闪变
* @param param
* @return
*/
List<ReportValue> getFlickerData(ReportQueryParam param);
/**
* 电压偏差
* @param param
* @return
*/
List<ReportValue> getVdeviation(ReportQueryParam param);
/**
* 畸变率
* @param param
* @return
*/
List<ReportValue> getDistortionData(ReportQueryParam param);
/**
* 频率
* @param param
* @return
*/
List<ReportValue> getFrequencyData(ReportQueryParam param);
/**
* 三相不平衡
* @param param
* @return
*/
List<ReportValue> getThreephase(ReportQueryParam param);
/**
* 谐波电流
* @param param
* @return
*/
List<ReportValue> getICurrent(ReportQueryParam param);
/**
* 谐波电压
* @param param
* @return
*/
List<ReportValue> getVoltageRate(ReportQueryParam param);
}

View File

@@ -0,0 +1,44 @@
package com.njcn.harmonic.service.impl;
import com.njcn.harmonic.pojo.vo.ReportValue;
import java.util.List;
public class RegroupData {
public static void regroupData(List<ReportValue> list, boolean... b) {
if (1 == b.length || (2 == b.length && b[1] == false)) {
if (0 < list.size()) {
return;
}
}
Float value = null;
int length = b[0] ? 3 : 1;
length = (b.length == 2 && !b[1]) ? 4 : length;
for (int i = 0; i < length; i++) {
String str = null;
if (b[0]) {
switch (i) {
case 0:
str = "A";
break;
case 1:
str = "B";
break;
case 2:
str = "C";
break;
case 3:
str = "T";
break;
}
}
ReportValue reportValue = new ReportValue(str, value, value, value, value);
list.add(reportValue);
}
}
}

View File

@@ -0,0 +1,484 @@
package com.njcn.harmonic.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.harmonic.mapper.RStatDataIDMapper;
import com.njcn.harmonic.mapper.ReportMapper;
import com.njcn.harmonic.pojo.po.RStatDataVD;
import com.njcn.harmonic.pojo.po.day.RStatDataIDPO;
import com.njcn.harmonic.pojo.param.ReportQueryParam;
import com.njcn.harmonic.pojo.po.report.OverLimitInfo;
import com.njcn.harmonic.pojo.vo.ReportValue;
import com.njcn.harmonic.service.IRStatDataVDService;
import com.njcn.harmonic.service.ReportService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Service
@AllArgsConstructor
public class ReportServiceImpl implements ReportService {
private final ReportMapper reportMapper;
private final IRStatDataVDService statDataVDService;
private final RStatDataIDMapper rStatDataIDMapper;
@Override
public OverLimitInfo getOverLimitData(ReportQueryParam param) {
OverLimitInfo overLimitInfo = new OverLimitInfo();
//查询时间段内共有多少条记录,并*0.95取整处理用来计算CP95值 降序*0.05进一位计算
double count = 0;
double pstCount = 0;
double pltCount = 0;
if (param.getB()) {
count = Math.ceil(1);
pltCount = Math.ceil(1);
pstCount = Math.ceil(1);
} else {
count = Math.ceil(reportMapper.getTotalCP95Day(param).intValue() * 0.05);
pltCount = Math.ceil(reportMapper.getTotalPltCP95Day(param).intValue() * 0.05);
pstCount = Math.ceil(reportMapper.getTotalPstCP95Day(param).intValue() * 0.05);
}
overLimitInfo.setCount(count);
overLimitInfo.setPltCount(pltCount);
overLimitInfo.setPstCount(pstCount);
return overLimitInfo;
}
@Override
public List<ReportValue> getVirtualData(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
// 获取电流有效值
List<ReportValue> listI = reportMapper.getVirtualDataI(param);
//获取电压有效值
List<ReportValue> listV = reportMapper.getVirtualDataV(param);
//获取线电压有效值
List<ReportValue> listVV = reportMapper.getVVirtualData(param);
RegroupData.regroupData(listV, true);
RegroupData.regroupData(listI, true);
RegroupData.regroupData(listVV, true);
list.addAll(listV);
list.addAll(listI);
list.addAll(listVV);
return list;
}
@Override
public List<ReportValue> getPowerData(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//获取有功功率
List<ReportValue> listP = reportMapper.getPowerP(param);
//获取无功功率
List<ReportValue> listQ = reportMapper.getPowerQ(param);
//获取视在功率
List<ReportValue> listS = reportMapper.getPowerS(param);
//获取功率因数
List<ReportValue> listF = reportMapper.getPF(param);
RegroupData.regroupData(listP, true, false);
RegroupData.regroupData(listQ, true, false);
RegroupData.regroupData(listS, true, false);
RegroupData.regroupData(listF, true, false);
list.addAll(listP);
list.addAll(listQ);
list.addAll(listS);
list.addAll(listF);
return list;
}
@Override
public List<ReportValue> getFlickerData(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//短时闪变
List<ReportValue> listFlicker = reportMapper.getFlickerData(param);
//长时闪变
List<ReportValue> listLFlicker = reportMapper.getLFlickerData(param);
RegroupData.regroupData(listFlicker, true);
RegroupData.regroupData(listLFlicker, true);
list.addAll(listFlicker);
list.addAll(listLFlicker);
return list;
}
@Override
public List<ReportValue> getVdeviation(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//获取电压偏差
List<ReportValue> listU = reportMapper.getUVdeviationData(param);
List<ReportValue> listL = reportMapper.getLVdeviationData(param);
RegroupData.regroupData(listU, true);
RegroupData.regroupData(listL, true);
list.addAll(listU);
list.addAll(listL);
return list;
}
@Override
public List<ReportValue> getDistortionData(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//获取电压畸变率
List<ReportValue> listU = reportMapper.getDistortionDataV(param);
//获取电流畸变率
List<ReportValue> listI = reportMapper.getDistortionDataI(param);
//添加之前判断数据库是否有数据,如果没有数据模拟数据添加到集合中
RegroupData.regroupData(listU, true);
RegroupData.regroupData(listI, true);
list.addAll(listU);
list.addAll(listI);
return list;
}
@Override
public List<ReportValue> getFrequencyData(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
List<ReportValue> listFre = reportMapper.getFrequencyData(param);
List<ReportValue> listFreDEV = reportMapper.getDEVFrequencyData(param);
RegroupData.regroupData(listFre, true);
RegroupData.regroupData(listFreDEV, true);
list.addAll(listFre);
list.addAll(listFreDEV);
return list;
}
@Override
public List<ReportValue> getThreephase(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//电压三相不平衡度
List<ReportValue> listV = dataV(param, Arrays.asList("T"),1, 5,true,0);
//电流三相不平衡度
List<ReportValue> listI = dataI(param, Arrays.asList("T"),1, 5,true,0);
if (CollUtil.isNotEmpty(listV)) {
list.addAll(listV);
} else {
regroupData(list);
}
if (CollUtil.isNotEmpty(listI)) {
list.addAll(listI);
} else {
regroupData(list);
}
return list;
}
@Override
public List<ReportValue> getICurrent(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//获取电流幅值,包含基波
List<ReportValue> listI = dataI(param, Arrays.asList("A","B","C"),1, 51,false,0);
if (CollUtil.isEmpty(listI)) {
for (int i = 0; i < 50; i++) {
RegroupData.regroupData(list, true, true);
}
} else {
list.addAll(listI);
}
return list;
}
@Override
public List<ReportValue> getVoltageRate(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//获取基波电压幅值单位kV
List<ReportValue> listV = dataV(param, Arrays.asList("A","B","C"),0, 1,true,5);
if (CollUtil.isEmpty(listV)) {
RegroupData.regroupData(list, true, true);
} else {
list.addAll(listV);
}
//获取电压含有率,不包含基波
List<ReportValue> listRate = dataV(param, Arrays.asList("A","B","C"),2, 51,false,1);
if (CollUtil.isEmpty(listRate)) {
for (int i = 0; i < 49; i++) {
RegroupData.regroupData(list, true, true);
}
} else {
list.addAll(listRate);
}
//获取电压畸变率
List<ReportValue> listU = reportMapper.getDistortionDataV(param);
RegroupData.regroupData(listU, true);
list.addAll(listU);
return list;
}
private void regroupData(List<ReportValue> list) {
for (int i = 0; i < 4; i++) {
List<ReportValue> list1 = new ArrayList<>();
RegroupData.regroupData(list1, false);
list.addAll(list1);
}
}
/**
* 电压信息
* @param param 查询条件
* @param valueTypes 区分类别 例如"A","B","C"
* @param num 循环开始
* @param size 循环结束
* @param fly 否是启用获取属性电压
* @param index 获取属性位置名称
* @return
*/
private List<ReportValue> dataV(ReportQueryParam param,List<String> valueTypes,Integer num,Integer size,Boolean fly,Integer index){
List<RStatDataVD> rStatDataVDS = statDataVDService.list(new LambdaQueryWrapper<RStatDataVD>()
.eq(RStatDataVD::getLineId, param.getLineId())
.in(CollUtil.isNotEmpty(valueTypes),RStatDataVD::getPhasicType,valueTypes)
.ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataVD::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())))
.le(StrUtil.isNotBlank(param.getEndTime()), RStatDataVD::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime())))
);
String max = "MAX";
String avg = "AVG";
String min = "MIN";
String cp95 = "CP95";
List<ReportValue> a = new ArrayList<>();
Map<String, List<RStatDataVD>> collect = rStatDataVDS.stream().collect(Collectors.groupingBy(RStatDataVD::getPhasicType));
collect.forEach((key, value) -> {
Map<String, List<RStatDataVD>> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataVD::getValueType));
for (int i = num; i < size; i++) {
ReportValue reportValue = new ReportValue();
String attribute="";
if(fly){
if (index==0){
attribute = attributeV(i);
}else{
attribute = attributeV(index);
}
}else{
attribute = "v"+i;
}
if (valueTypeMap.containsKey(max)) {
List<Float> aa = reflectDataV(valueTypeMap.get(max), max,attribute);
reportValue.setPhaseType(key);
Float maxNum = aa.stream().distinct().max(Float::compareTo).get();
reportValue.setFmaxValue(maxNum);
}
if (valueTypeMap.containsKey(avg)) {
List<Float> aa = reflectDataV(valueTypeMap.get(avg), avg,attribute);
reportValue.setPhaseType(key);
Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue));
reportValue.setMeanValue(avgNum.floatValue());
}
if (valueTypeMap.containsKey(min)) {
List<Float> aa = reflectDataV(valueTypeMap.get(min), min,attribute);
reportValue.setPhaseType(key);
double minNum = aa.stream().distinct().min(Float::compareTo).get();
reportValue.setMinValue((float) minNum);
}
if (valueTypeMap.containsKey(cp95)) {
List<Float> aa = reflectDataV(valueTypeMap.get(cp95), cp95,attribute);
reportValue.setPhaseType(key);
List<Float> cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList());
reportValue.setCp95Value(cp95Num.get(0).floatValue());
}
a.add(reportValue);
}
});
return a;
}
/**
* 电压反射取属性值
*
* @param value
* @param name
* @return
*/
private List<Float> reflectDataV(List<RStatDataVD> value, String name,String attribute) {
Field field = null;
try {
field = RStatDataVD.class.getDeclaredField(attribute);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
field.setAccessible(true);
Field finalField = field;
return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> {
BigDecimal o = null;
try {
o = (BigDecimal) finalField.get(temp);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
return o.floatValue();
}).collect(Collectors.toList());
}
/**
* 电流信息
* @param param
* @return
*/
private List<ReportValue> dataI(ReportQueryParam param,List<String> valueTypes,Integer num,Integer size,Boolean fly,Integer index){
List<RStatDataIDPO> rStatDataVDS = rStatDataIDMapper.selectList(new LambdaQueryWrapper<RStatDataIDPO>()
.eq(RStatDataIDPO::getLineId, param.getLineId())
.in(CollUtil.isNotEmpty(valueTypes),RStatDataIDPO::getPhaseType,valueTypes)
.ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataIDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())))
.le(StrUtil.isNotBlank(param.getEndTime()), RStatDataIDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime())))
);
String max = "MAX";
String avg = "AVG";
String min = "MIN";
String cp95 = "CP95";
List<ReportValue> a = new ArrayList<>();
Map<String, List<RStatDataIDPO>> collect = rStatDataVDS.stream().collect(Collectors.groupingBy(RStatDataIDPO::getPhaseType));
collect.forEach((key, value) -> {
Map<String, List<RStatDataIDPO>> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataIDPO::getValueType));
for (int i = num; i < size; i++) {
ReportValue reportValue = new ReportValue();
String attribute="";
if(fly){
if (index==0){
attribute = attributeI(i);
}else{
attribute = attributeI(index);
}
}else{
attribute = "i"+i;
}
if (valueTypeMap.containsKey(max)) {
List<Float> aa = reflectDataI(valueTypeMap.get(max), max,attribute);
reportValue.setPhaseType(key);
Float maxNum = aa.stream().distinct().max(Float::compareTo).get();
reportValue.setFmaxValue(maxNum);
}
if (valueTypeMap.containsKey(avg)) {
List<Float> aa = reflectDataI(valueTypeMap.get(avg), avg,attribute);
reportValue.setPhaseType(key);
Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue));
reportValue.setMeanValue(avgNum.floatValue());
}
if (valueTypeMap.containsKey(min)) {
List<Float> aa = reflectDataI(valueTypeMap.get(min), min,attribute);
reportValue.setPhaseType(key);
double minNum = aa.stream().distinct().min(Float::compareTo).get();
reportValue.setMinValue((float) minNum);
}
if (valueTypeMap.containsKey(cp95)) {
List<Float> aa = reflectDataI(valueTypeMap.get(cp95), cp95,attribute);
reportValue.setPhaseType(key);
List<Float> cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList());
reportValue.setCp95Value(cp95Num.get(0).floatValue());
}
a.add(reportValue);
}
});
return a;
}
/**
* 电流反射取属性值
*
* @param value
* @param name
* @return
*/
private List<Float> reflectDataI(List<RStatDataIDPO> value, String name, String attribute) {
Field field = null;
try {
field = RStatDataIDPO.class.getDeclaredField(attribute);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
field.setAccessible(true);
Field finalField = field;
return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> {
Double o = null;
try {
o = (Double) finalField.get(temp);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
return o.floatValue();
}).collect(Collectors.toList());
}
/**
* 获取属性电压
* @param i
* @return
*/
private String attributeV(Integer i) {
String str=null;
switch (i) {
case 1:
str = "vUnbalance";
break;
case 2:
str = "vPos";
break;
case 3:
str = "vNeg";
break;
case 4:
str = "vZero";
break;
case 5:
str = "v1";
break;
default:
break;
}
return str;
}
/**
* 获取属性电流
* @param i
* @return
*/
private String attributeI(Integer i) {
String str=null;
switch (i) {
case 1:
str = "iUnbalance";
break;
case 2:
str = "iPos";
break;
case 3:
str = "iNeg";
break;
case 4:
str = "iZero";
break;
default:
break;
}
return str;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@@ -12,6 +12,10 @@ import java.time.format.DateTimeFormatter;
@Slf4j
@Component
@AllArgsConstructor
/**
* 终端装置异常告警每日统计
* @date 2023/4/18
*/
public class DeviceAbnormalStatisticsJob {
private final DeviceAbnormalFeignClient deviceAbnormalFeignClient;

View File

@@ -1,29 +0,0 @@
package com.njcn.executor.handler;
import com.njcn.prepare.harmonic.api.line.DistortionRateFeignClient;
import com.njcn.prepare.harmonic.pojo.param.LineParam;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
@Slf4j
@Component
@AllArgsConstructor
public class DistortionRateJob {
private final DistortionRateFeignClient distortionRateFeignClient;
@XxlJob("DistortionRateJob")
public void DistortionRateJob () {
log.info("===================DistortionRateJob Start===================");
LineParam lineParam = new LineParam();
lineParam.setDataDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
log.info(lineParam.toString());
distortionRateFeignClient.distortionRate(lineParam);
log.info("===================DistortionRateJob End=====================");
}
}

View File

@@ -1,592 +0,0 @@
/*
package com.njcn.executor.handler;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.po.Overlimit;
import com.njcn.executor.pojo.dto.PollutionDTO;
import com.njcn.executor.pojo.vo.*;
import com.njcn.harmonic.pojo.dto.PublicDTO;
import com.njcn.influxdb.config.InfluxDbConfig;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.InfluxDB;
import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.influxdb.querybuilder.SelectQueryImpl;
import org.influxdb.querybuilder.WhereNested;
import org.influxdb.querybuilder.WhereQueryImpl;
import org.influxdb.querybuilder.clauses.Clause;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.BinaryOperator;
import java.util.stream.Collectors;
import java.util.stream.Stream;
*/
/**
* @author xuy
* @version 1.0.0
* @date 2022年04月07日 09:54
*//*
@Slf4j
@Component
@AllArgsConstructor
public class PollutionJob {
private final InfluxDbConfig influxDbConfig;
private final InfluxDbUtils influxDbUtils;
private final LineFeignClient lineFeignClient;
*/
/**
* 监测点污染指标
*//*
@XxlJob("pollutionJobHandler")
public void pollutionJobHandler() {
List<PublicDTO> list = new ArrayList<>();
//谐波电压
List<PublicDTO> uaberranceList = new ArrayList<>();
//谐波电流
List<PublicDTO> iHarmList = new ArrayList<>();
//频率偏差
List<PublicDTO> freqList = new ArrayList<>();
//电压偏差
List<PublicDTO> devList = new ArrayList<>();
//三相电压不平衡度
List<PublicDTO> uBalanceList = new ArrayList<>();
//负序电流
List<PublicDTO> iNegList = new ArrayList<>();
//间谐波电压含有率
List<PublicDTO> iNuharmList = new ArrayList<>();
//长时电压闪变
List<PublicDTO> flickerList = new ArrayList<>();
List<String> lineList = getAllLinesLimitData().stream().map(Overlimit::getId).collect(Collectors.toList());
List<PollutionDTO> pollutionList = new ArrayList<>();
lineList.forEach(item->{
PollutionDTO pollutionDTO = new PollutionDTO();
pollutionDTO.setId(item);
pollutionList.add(pollutionDTO);
});
//谐波电压污染数值
Map<String, Optional<PublicDTO>> map1 = getDistortionData();
for (String key : map1.keySet()) {
list.add(map1.get(key).get());
}
Map<String, Optional<PublicDTO>> map2 = getContentData();
for (String key : map2.keySet()) {
list.add(map2.get(key).get());
}
Comparator<PublicDTO> comparator = Comparator.comparing(PublicDTO::getData);
Map<String, Optional<PublicDTO>> result = list.stream().collect(Collectors.groupingBy(PublicDTO::getId,Collectors.reducing(BinaryOperator.maxBy(comparator))));
for (String key : result.keySet()) {
uaberranceList.add(result.get(key).get());
}
//谐波电流污染数值
Map<String, Optional<PublicDTO>> map3 = getIharm();
for (String key : map3.keySet()) {
iHarmList.add(map3.get(key).get());
}
//频率偏差污染数值
Map<String, Optional<PublicDTO>> map4 = getFreq();
for (String key : map4.keySet()) {
freqList.add(map4.get(key).get());
}
//电压偏差
Map<String, Optional<PublicDTO>> map5 = getDev();
for (String key : map5.keySet()) {
devList.add(map5.get(key).get());
}
//三相电压不平衡度
Map<String, Optional<PublicDTO>> map6 = getUbalance();
for (String key : map6.keySet()) {
uBalanceList.add(map6.get(key).get());
}
//负序电流
Map<String, Optional<PublicDTO>> map7 = getIneg();
for (String key : map7.keySet()) {
iNegList.add(map7.get(key).get());
}
//间谐波电压含有率
Map<String, Optional<PublicDTO>> map8 = getInuharm();
for (String key : map8.keySet()) {
iNuharmList.add(map8.get(key).get());
}
//长时电压闪变
Map<String, Optional<PublicDTO>> map9 = getFlicker();
for (String key : map9.keySet()) {
flickerList.add(map9.get(key).get());
}
//组装数据
for (PollutionDTO item1 : pollutionList) {
for (PublicDTO item2 : uaberranceList) {
if (Objects.equals(item1.getId(),item2.getId())){
item1.setData5(BigDecimal.valueOf(item2.getData()).setScale(4, RoundingMode.HALF_UP).doubleValue());
}
}
}
for (PollutionDTO item1 : pollutionList) {
for (PublicDTO item2 : iHarmList) {
if (Objects.equals(item1.getId(),item2.getId())){
item1.setData6(BigDecimal.valueOf(item2.getData()).setScale(4, RoundingMode.HALF_UP).doubleValue());
}
}
}
for (PollutionDTO item1 : pollutionList) {
for (PublicDTO item2 : freqList) {
if (Objects.equals(item1.getId(),item2.getId())){
item1.setData1(BigDecimal.valueOf(item2.getData()).setScale(4, RoundingMode.HALF_UP).doubleValue());
}
}
}
for (PollutionDTO item1 : pollutionList) {
for (PublicDTO item2 : devList) {
if (Objects.equals(item1.getId(),item2.getId())){
item1.setData2(BigDecimal.valueOf(item2.getData()).setScale(4, RoundingMode.HALF_UP).doubleValue());
}
}
}
for (PollutionDTO item1 : pollutionList) {
for (PublicDTO item2 : uBalanceList) {
if (Objects.equals(item1.getId(),item2.getId())){
item1.setData3(BigDecimal.valueOf(item2.getData()).setScale(4, RoundingMode.HALF_UP).doubleValue());
}
}
}
for (PollutionDTO item1 : pollutionList) {
for (PublicDTO item2 : iNegList) {
if (Objects.equals(item1.getId(),item2.getId())){
item1.setData4(BigDecimal.valueOf(item2.getData()).setScale(4, RoundingMode.HALF_UP).doubleValue());
}
}
}
for (PollutionDTO item1 : pollutionList) {
for (PublicDTO item2 : iNuharmList) {
if (Objects.equals(item1.getId(),item2.getId())){
item1.setData7(BigDecimal.valueOf(item2.getData()).setScale(4, RoundingMode.HALF_UP).doubleValue());
}
}
}
for (PollutionDTO item1 : pollutionList) {
for (PublicDTO item2 : flickerList) {
if (Objects.equals(item1.getId(),item2.getId())){
item1.setData8(BigDecimal.valueOf(item2.getData()).setScale(4, RoundingMode.HALF_UP).doubleValue());
}
}
}
//将处理好的数据存入influxDB表中
Calendar calendar = Calendar.getInstance();
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)-1, 0, 0, 0);
calendar.set(Calendar.MILLISECOND,0);
createMeasurement(pollutionList,calendar.getTimeInMillis());
}
*/
/**
* 获取限值表中的所有监测点信息
*//*
private List<Overlimit> getAllLinesLimitData() {
return lineFeignClient.getAllLineOverLimit("harmonic-boot","").getData();
}
private void whereAndNested(List<Clause> clauses, WhereQueryImpl<SelectQueryImpl> whereQuery) {
WhereNested<WhereQueryImpl<SelectQueryImpl>> andNested = whereQuery.andNested();
for (Clause clause : clauses) {
andNested.or(clause);
}
andNested.close();
}
*/
/**
* 谐波电压 -> 电压总谐波畸变率
* 各监测点最新的A、B、C三相数据
* 按照监测点分组,每个监测点取最大
*//*
private Map<String, Optional<PublicDTO>> getDistortionData(){
String sql = "SELECT * FROM day_v where value_type = 'CP95' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') group by line_id order by time desc limit 3 tz('Asia/Shanghai')";
QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<Double> data;
PublicDTO publicDTO;
List<PublicDTO> lineData = new ArrayList<>();
List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
List<Overlimit> overLimitList = getAllLinesLimitData();
for (DayV item1 : list) {
for (Overlimit item2 : overLimitList) {
if (Objects.equals(item1.getLineId(),item2.getId())){
double vUnbalance = item1.getVUnbalance()/item2.getUaberrance();
data = Stream.of(vUnbalance).collect(Collectors.toList());
double result = data.stream().max(Comparator.comparing(Double::doubleValue)).get();
publicDTO = new PublicDTO();
publicDTO.setId(item1.getLineId());
publicDTO.setData(result);
lineData.add(publicDTO);
}
}
}
Comparator<PublicDTO> comparator = Comparator.comparing(PublicDTO::getData);
return lineData.stream().collect(Collectors.groupingBy(PublicDTO::getId,Collectors.reducing(BinaryOperator.maxBy(comparator))));
}
*/
/**
* 谐波电压 -> 各次谐波电压含有率2~25次
* 各监测点最新的A、B、C三相数据
*//*
private Map<String, Optional<PublicDTO>> getContentData(){
String sql = "SELECT * FROM day_harmrate_v where value_type = 'CP95' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') group by line_id order by time desc limit 3 tz('Asia/Shanghai')";
QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<Double> data;
PublicDTO publicDTO;
List<PublicDTO> lineData = new ArrayList<>();
List<DayHarmrateV> list = resultMapper.toPOJO(sqlResult, DayHarmrateV.class);
List<Overlimit> overLimitList = getAllLinesLimitData();
for (DayHarmrateV dayHarmrateV : list) {
for (Overlimit overlimit : overLimitList) {
if (Objects.equals(dayHarmrateV.getLineId(),overlimit.getId())){
double v2 = dayHarmrateV.getV2()/overlimit.getUharm2();
double v3 = dayHarmrateV.getV3()/overlimit.getUharm3();
double v4 = dayHarmrateV.getV4()/overlimit.getUharm4();
double v5 = dayHarmrateV.getV5()/overlimit.getUharm5();
double v6 = dayHarmrateV.getV6()/overlimit.getUharm6();
double v7 = dayHarmrateV.getV7()/overlimit.getUharm7();
double v8 = dayHarmrateV.getV8()/overlimit.getUharm8();
double v9 = dayHarmrateV.getV9()/overlimit.getUharm9();
double v10 = dayHarmrateV.getV10()/overlimit.getUharm10();
double v11 = dayHarmrateV.getV11()/overlimit.getUharm11();
double v12 = dayHarmrateV.getV12()/overlimit.getUharm12();
double v13 = dayHarmrateV.getV13()/overlimit.getUharm13();
double v14 = dayHarmrateV.getV14()/overlimit.getUharm14();
double v15 = dayHarmrateV.getV15()/overlimit.getUharm15();
double v16 = dayHarmrateV.getV16()/overlimit.getUharm16();
double v17 = dayHarmrateV.getV17()/overlimit.getUharm17();
double v18 = dayHarmrateV.getV18()/overlimit.getUharm18();
double v19 = dayHarmrateV.getV19()/overlimit.getUharm19();
double v20 = dayHarmrateV.getV20()/overlimit.getUharm20();
double v21 = dayHarmrateV.getV21()/overlimit.getUharm21();
double v22 = dayHarmrateV.getV22()/overlimit.getUharm22();
double v23 = dayHarmrateV.getV23()/overlimit.getUharm23();
double v24 = dayHarmrateV.getV24()/overlimit.getUharm24();
double v25 = dayHarmrateV.getV25()/overlimit.getUharm25();
data = Stream.of(v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v23,v24,v25).collect(Collectors.toList());
double result = data.stream().max(Comparator.comparing(Double::doubleValue)).get();
publicDTO = new PublicDTO();
publicDTO.setId(dayHarmrateV.getLineId());
publicDTO.setData(result);
lineData.add(publicDTO);
}
}
}
Comparator<PublicDTO> comparator = Comparator.comparing(PublicDTO::getData);
return lineData.stream().collect(Collectors.groupingBy(PublicDTO::getId,Collectors.reducing(BinaryOperator.maxBy(comparator))));
}
*/
/**
* 谐波电流 -> 各次谐波电流2~25次
* 各监测点最新的A、B、C三相数据
*//*
private Map<String, Optional<PublicDTO>> getIharm(){
String sql = "SELECT * FROM day_i where value_type = 'CP95' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') group by line_id order by time desc limit 3 tz('Asia/Shanghai')";
QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<Double> data;
PublicDTO publicDTO;
List<PublicDTO> lineData = new ArrayList<>();
List<DayI> list = resultMapper.toPOJO(sqlResult, DayI.class);
List<Overlimit> overLimitList = getAllLinesLimitData();
for (DayI dayI : list) {
for (Overlimit overlimit : overLimitList) {
if (Objects.equals(dayI.getLineId(),overlimit.getId())){
double v2 = dayI.getI2()/overlimit.getIharm2();
double v3 = dayI.getI3()/overlimit.getIharm3();
double v4 = dayI.getI4()/overlimit.getIharm4();
double v5 = dayI.getI5()/overlimit.getIharm5();
double v6 = dayI.getI6()/overlimit.getIharm6();
double v7 = dayI.getI7()/overlimit.getIharm7();
double v8 = dayI.getI8()/overlimit.getIharm8();
double v9 = dayI.getI9()/overlimit.getIharm9();
double v10 = dayI.getI10()/overlimit.getIharm10();
double v11 = dayI.getI11()/overlimit.getIharm11();
double v12 = dayI.getI12()/overlimit.getIharm12();
double v13 = dayI.getI13()/overlimit.getIharm13();
double v14 = dayI.getI14()/overlimit.getIharm14();
double v15 = dayI.getI15()/overlimit.getIharm15();
double v16 = dayI.getI16()/overlimit.getIharm16();
double v17 = dayI.getI17()/overlimit.getIharm17();
double v18 = dayI.getI18()/overlimit.getIharm18();
double v19 = dayI.getI19()/overlimit.getIharm19();
double v20 = dayI.getI20()/overlimit.getIharm20();
double v21 = dayI.getI21()/overlimit.getIharm21();
double v22 = dayI.getI22()/overlimit.getIharm22();
double v23 = dayI.getI23()/overlimit.getIharm23();
double v24 = dayI.getI24()/overlimit.getIharm24();
double v25 = dayI.getI25()/overlimit.getIharm25();
data = Stream.of(v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,v21,v22,v23,v24,v25).collect(Collectors.toList());
double result = data.stream().max(Comparator.comparing(Double::doubleValue)).get();
publicDTO = new PublicDTO();
publicDTO.setId(dayI.getLineId());
publicDTO.setData(result);
lineData.add(publicDTO);
}
}
}
Comparator<PublicDTO> comparator = Comparator.comparing(PublicDTO::getData);
return lineData.stream().collect(Collectors.groupingBy(PublicDTO::getId,Collectors.reducing(BinaryOperator.maxBy(comparator))));
}
*/
/**
* 频率偏差 -> 绝对值
* 各监测点最新的T相数据
*//*
private Map<String, Optional<PublicDTO>> getFreq(){
String sql = "SELECT line_id,abs(freq_dev) AS freq_dev FROM day_v where phasic_type = 'T' and (value_type = 'MIN' or value_type = 'MAX') group by line_id order by time desc limit 2 tz('Asia/Shanghai')";
QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<Double> data;
PublicDTO publicDTO;
List<PublicDTO> lineData = new ArrayList<>();
List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
List<Overlimit> overLimitList = getAllLinesLimitData();
for (DayV dayV : list) {
for (Overlimit overlimit : overLimitList) {
if (Objects.equals(dayV.getLineId(),overlimit.getId())){
double freqDev = dayV.getFreqDev()/overlimit.getFreqDev();
data = Stream.of(freqDev).collect(Collectors.toList());
double result = data.stream().max(Comparator.comparing(Double::doubleValue)).get();
publicDTO = new PublicDTO();
publicDTO.setId(dayV.getLineId());
publicDTO.setData(result);
lineData.add(publicDTO);
}
}
}
Comparator<PublicDTO> comparator = Comparator.comparing(PublicDTO::getData);
return lineData.stream().collect(Collectors.groupingBy(PublicDTO::getId,Collectors.reducing(BinaryOperator.maxBy(comparator))));
}
*/
/**
* 电压偏差 -> 绝对值
* 各监测点最新的A、B、C三相数据
*//*
private Map<String, Optional<PublicDTO>> getDev(){
String sql = "SELECT line_id,vu_dev,vl_dev,value_type FROM day_v where (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and (value_type = 'MIN' or value_type = 'MAX') group by line_id order by time desc limit 6 tz('Asia/Shanghai')";
QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<Double> data;
PublicDTO publicDTO;
List<PublicDTO> lineData = new ArrayList<>();
List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
List<Overlimit> overLimitList = getAllLinesLimitData();
for (DayV dayV : list) {
for (Overlimit overlimit : overLimitList) {
if (Objects.equals(dayV.getLineId(),overlimit.getId())){
double vlDev = Math.abs(dayV.getVlDev()/overlimit.getUvoltageDev());
double vuDev = Math.abs(dayV.getVuDev()/overlimit.getVoltageDev());
data = Stream.of(vuDev,vlDev).collect(Collectors.toList());
double result = data.stream().max(Comparator.comparing(Double::doubleValue)).get();
publicDTO = new PublicDTO();
publicDTO.setId(dayV.getLineId());
publicDTO.setData(result);
lineData.add(publicDTO);
}
}
}
Comparator<PublicDTO> comparator = Comparator.comparing(PublicDTO::getData);
return lineData.stream().collect(Collectors.groupingBy(PublicDTO::getId,Collectors.reducing(BinaryOperator.maxBy(comparator))));
}
*/
/**
* 三相电压不平衡度
* 各监测点最新的T相数据
*//*
private Map<String, Optional<PublicDTO>> getUbalance(){
String sql = "SELECT line_id,v_unbalance,value_type FROM day_v where phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') group by line_id order by time desc limit 2 tz('Asia/Shanghai')";
QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<Double> data;
PublicDTO publicDTO;
List<PublicDTO> lineData = new ArrayList<>();
List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
List<Overlimit> overLimitList = getAllLinesLimitData();
for (DayV dayV : list) {
for (Overlimit overlimit : overLimitList) {
if (Objects.equals(dayV.getLineId(),overlimit.getId())){
double vUnbalance = Math.abs(dayV.getVUnbalance()/overlimit.getUbalance());
data = Stream.of(vUnbalance).collect(Collectors.toList());
double result = data.stream().max(Comparator.comparing(Double::doubleValue)).get();
publicDTO = new PublicDTO();
publicDTO.setId(dayV.getLineId());
publicDTO.setData(result);
lineData.add(publicDTO);
}
}
}
Comparator<PublicDTO> comparator = Comparator.comparing(PublicDTO::getData);
return lineData.stream().collect(Collectors.groupingBy(PublicDTO::getId,Collectors.reducing(BinaryOperator.maxBy(comparator))));
}
*/
/**
* 负序电流
* 各监测点最新的T相数据
*//*
private Map<String, Optional<PublicDTO>> getIneg(){
String sql = "SELECT line_id,i_neg,value_type FROM day_i where phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') group by line_id order by time desc limit 2 tz('Asia/Shanghai')";
QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<Double> data;
PublicDTO publicDTO;
List<PublicDTO> lineData = new ArrayList<>();
List<DayI> list = resultMapper.toPOJO(sqlResult, DayI.class);
List<Overlimit> overLimitList = getAllLinesLimitData();
for (DayI dayI : list) {
for (Overlimit overlimit : overLimitList) {
if (Objects.equals(dayI.getLineId(),overlimit.getId())){
double iNeg = Math.abs(dayI.getINeg()/overlimit.getINeg());
data = Stream.of(iNeg).collect(Collectors.toList());
double result = data.stream().max(Comparator.comparing(Double::doubleValue)).get();
publicDTO = new PublicDTO();
publicDTO.setId(dayI.getLineId());
publicDTO.setData(result);
lineData.add(publicDTO);
}
}
}
Comparator<PublicDTO> comparator = Comparator.comparing(PublicDTO::getData);
return lineData.stream().collect(Collectors.groupingBy(PublicDTO::getId,Collectors.reducing(BinaryOperator.maxBy(comparator))));
}
*/
/**
* 间谐波电压含有率
* 各监测点最新的A、B、C三相数据
*//*
private Map<String, Optional<PublicDTO>> getInuharm(){
String sql = "SELECT * FROM day_inharm_v where (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' group by line_id order by time desc limit 3 tz('Asia/Shanghai')";
QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<Double> data;
PublicDTO publicDTO;
List<PublicDTO> lineData = new ArrayList<>();
List<DayInharmV> list = resultMapper.toPOJO(sqlResult, DayInharmV.class);
List<Overlimit> overLimitList = getAllLinesLimitData();
for (DayInharmV dayInharmV : list) {
for (Overlimit overlimit : overLimitList) {
if (Objects.equals(dayInharmV.getLineId(),overlimit.getId())){
double v1 = Math.abs(dayInharmV.getV1()/overlimit.getInuharm1());
double v2 = Math.abs(dayInharmV.getV2()/overlimit.getInuharm2());
double v3 = Math.abs(dayInharmV.getV3()/overlimit.getInuharm3());
double v4 = Math.abs(dayInharmV.getV4()/overlimit.getInuharm4());
double v5 = Math.abs(dayInharmV.getV5()/overlimit.getInuharm5());
double v6 = Math.abs(dayInharmV.getV6()/overlimit.getInuharm6());
double v7 = Math.abs(dayInharmV.getV7()/overlimit.getInuharm7());
double v8 = Math.abs(dayInharmV.getV8()/overlimit.getInuharm8());
double v9 = Math.abs(dayInharmV.getV9()/overlimit.getInuharm9());
double v10 = Math.abs(dayInharmV.getV10()/overlimit.getInuharm10());
double v11 = Math.abs(dayInharmV.getV11()/overlimit.getInuharm11());
double v12 = Math.abs(dayInharmV.getV12()/overlimit.getInuharm12());
double v13 = Math.abs(dayInharmV.getV13()/overlimit.getInuharm13());
double v14 = Math.abs(dayInharmV.getV14()/overlimit.getInuharm14());
double v15 = Math.abs(dayInharmV.getV15()/overlimit.getInuharm15());
double v16 = Math.abs(dayInharmV.getV16()/overlimit.getInuharm16());
data = Stream.of(v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16).collect(Collectors.toList());
double result = data.stream().max(Comparator.comparing(Double::doubleValue)).get();
publicDTO = new PublicDTO();
publicDTO.setId(dayInharmV.getLineId());
publicDTO.setData(result);
lineData.add(publicDTO);
}
}
}
Comparator<PublicDTO> comparator = Comparator.comparing(PublicDTO::getData);
return lineData.stream().collect(Collectors.groupingBy(PublicDTO::getId,Collectors.reducing(BinaryOperator.maxBy(comparator))));
}
*/
/**
* 长时电压闪变
* 各监测点最新的A、B、C三相数据
*//*
private Map<String, Optional<PublicDTO>> getFlicker(){
String sql = "SELECT * FROM day_plt where (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' group by line_id order by time desc limit 3 tz('Asia/Shanghai')";
QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<Double> data;
PublicDTO publicDTO;
List<PublicDTO> lineData = new ArrayList<>();
List<DayPlt> list = resultMapper.toPOJO(sqlResult, DayPlt.class);
List<Overlimit> overLimitList = getAllLinesLimitData();
for (DayPlt dayPlt : list) {
for (Overlimit overlimit : overLimitList) {
if (Objects.equals(dayPlt.getLineId(),overlimit.getId())){
double plt = Math.abs(dayPlt.getPlt()/overlimit.getFlicker());
data = Stream.of(plt).collect(Collectors.toList());
double result = data.stream().max(Comparator.comparing(Double::doubleValue)).get();
publicDTO = new PublicDTO();
publicDTO.setId(dayPlt.getLineId());
publicDTO.setData(result);
lineData.add(publicDTO);
}
}
}
Comparator<PublicDTO> comparator = Comparator.comparing(PublicDTO::getData);
return lineData.stream().collect(Collectors.groupingBy(PublicDTO::getId,Collectors.reducing(BinaryOperator.maxBy(comparator))));
}
*/
/**
* 生成谐波污区图污染指标表
*//*
private void createMeasurement(List<PollutionDTO> list, long time){
List<String> records = new ArrayList<String>();
list.forEach(item->{
Map<String, String> tags = new HashMap<>();
Map<String, Object> fields = new HashMap<>();
tags.put("line_id",item.getId());
fields.put("freq",item.getData1());
fields.put("freq_dev",item.getData2());
fields.put("unbalance",item.getData3());
fields.put("ineg",item.getData4());
fields.put("harmonic_v",item.getData5());
fields.put("harmonic_i",item.getData6());
fields.put("inuharm",item.getData7());
fields.put("flicker",item.getData8());
Point point = influxDbUtils.pointBuilder("harmonic_pollution", time, TimeUnit.MILLISECONDS,tags, fields);
BatchPoints batchPoints = BatchPoints.database(influxDbConfig.getDatabase()).tag("line_id", item.getId()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
batchPoints.point(point);
records.add(batchPoints.lineProtocol());
});
influxDbUtils.batchInsert(influxDbConfig.getDatabase(),"", InfluxDB.ConsistencyLevel.ALL, records);
}
}
*/

View File

@@ -1,191 +0,0 @@
/*
package com.njcn.executor.handler;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.po.LineDetail;
import com.njcn.executor.pojo.vo.*;
import com.njcn.influxdb.config.InfluxDbConfig;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.InfluxDB;
import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.influxdb.querybuilder.SelectQueryImpl;
import org.influxdb.querybuilder.WhereNested;
import org.influxdb.querybuilder.WhereQueryImpl;
import org.influxdb.querybuilder.clauses.Clause;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.njcn.influxdb.param.InfluxDBPublicParam.*;
import static com.njcn.influxdb.param.InfluxDBPublicParam.LINE_ID;
import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.*;
import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
*/
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2022/7/8 13:44
*//*
@Slf4j
@Component
@AllArgsConstructor
public class PqsIntegrityJob {
private final InfluxDbUtils influxDbUtils;
private final InfluxDbConfig influxDbConfig;
private final LineFeignClient lineFeignClient;
@XxlJob("pqsIntegrityJobHandler")
public void pqsIntegrityJobHandler() throws ParseException {
List<PqsIntegrity> result = new ArrayList<>();
List<String> paramList = new ArrayList<>(),lineList = new ArrayList<>();
List<DataV> dataList = new ArrayList<>();
String command = XxlJobHelper.getJobParam();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)-1, 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
Calendar calendar2 = Calendar.getInstance();
calendar2.set(calendar2.get(Calendar.YEAR), calendar2.get(Calendar.MONTH), calendar2.get(Calendar.DAY_OF_MONTH)-1, 23, 59, 59);
calendar2.set(Calendar.MILLISECOND, 0);
String startTime = format.format(calendar.getTime());
String endTime = format.format(calendar2.getTime());
if (!StringUtils.isEmpty(command)){
paramList = Arrays.asList(command.split(","));
startTime = paramList.get(0);
endTime = paramList.get(1);
lineList = paramList.subList(2,paramList.size());
boolean s1 = Pattern.matches(PatternRegex.TIME_FORMAT,startTime);
boolean e1 = Pattern.matches(PatternRegex.TIME_FORMAT,endTime);
if (!s1 || !e1){
log.error("补招时间格式错误");
return;
} else {
startTime = startTime + START_TIME;
endTime = endTime + END_TIME;
}
}
List<LineDetail> lineDetail = lineFeignClient.getLineDetail(lineList).getData();
if (!CollectionUtils.isEmpty(lineDetail)){
//获取dataV表中监测点的数据数量
lineList = lineDetail.stream().map(LineDetail::getId).collect(Collectors.toList());
long diff,diffDays,a,b = 0;
Date d1 = format.parse(startTime);
Date d2 = format.parse(endTime);
diff = d2.getTime() - d1.getTime();
diffDays = diff / (24 * 60 * 60 * 1000-1000);
int days = (int) diffDays;
for (int i = 1; i <= days; i++) {
a = d1.getTime() + (long)(i-1)*(24 * 60 * 60) * 1000;
b = d1.getTime() + (long)i*(24 * 60 * 60) * 1000-1000;
startTime = format.format(a);
endTime = format.format(b);
dataList = getDataV(lineList,startTime,endTime);
for (LineDetail detail : lineDetail) {
PqsIntegrity pqsIntegrity = new PqsIntegrity();
pqsIntegrity.setTime(Instant.ofEpochMilli(a));
pqsIntegrity.setLineId(detail.getId());
pqsIntegrity.setDue(DAY_MINUTE/detail.getTimeInterval());
if (!CollectionUtils.isEmpty(dataList)){
Map<String,List<DataV>> lineMap = dataList.stream().collect(Collectors.groupingBy(DataV::getLineId));
List<DataV> l1 = lineMap.get(detail.getId());
if (!CollectionUtils.isEmpty(l1)){
Map<Instant,List<DataV>> timeMap = l1.stream().collect(Collectors.groupingBy(DataV::getTime));
pqsIntegrity.setReal(timeMap.size());
}
}
result.add(pqsIntegrity);
}
}
}
insertData(result);
}
*/
/**
* 获取dataV数据
* @param list 监测点集合
* @return dataV数据
*//*
private List<DataV> getDataV(List<String> list, String startTime, String endTime){
SelectQueryImpl selectQuery = select().from(influxDbConfig.getDatabase(), DATA_V);
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
whereAndNested(list, where);
where.and(gte(TIME, startTime)).and(lte(TIME, endTime));
where.tz(TZ);
QueryResult queryResult = influxDbUtils.query(selectQuery.getCommand());
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
return resultMapper.toPOJO(queryResult, DataV.class);
}
*/
/**
* 拼接监测点条件
* @param list 监测点集合
* @param whereQuery WhereQueryImpl
*//*
private void whereAndNested(List<String> list, WhereQueryImpl<SelectQueryImpl> whereQuery) {
List<Clause> clauses = new ArrayList<>();
list.forEach(item->{
Clause clause = eq(LINE_ID, item);
clauses.add(clause);
});
WhereNested<WhereQueryImpl<SelectQueryImpl>> andNested = whereQuery.andNested();
for (Clause clause : clauses) {
andNested.or(clause);
}
andNested.close();
}
*/
/**
* 功能描述:插入pqs_integrity表数据
* @author xy
* @param list 数据集合
* @date 2022/5/12 8:55
*//*
private void insertData(List<PqsIntegrity> list){
List<String> records = new ArrayList<>();
list.forEach(item->{
Map<String, String> tags = new HashMap<>();
Map<String, Object> fields = new HashMap<>();
tags.put(LINE_ID,item.getLineId());
fields.put(DUE,item.getDue());
fields.put(REAL,item.getReal());
Point point = influxDbUtils.pointBuilder(PQS_INTEGRITY, item.getTime().toEpochMilli(), TimeUnit.MILLISECONDS, tags, fields);
BatchPoints batchPoints = BatchPoints.database(influxDbConfig.getDatabase()).tag(LINE_ID, item.getLineId()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
batchPoints.point(point);
records.add(batchPoints.lineProtocol());
});
influxDbUtils.batchInsert(influxDbConfig.getDatabase(),"", InfluxDB.ConsistencyLevel.ALL, records);
}
}
*/

View File

@@ -1,294 +0,0 @@
/*
package com.njcn.executor.handler;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.energy.pojo.constant.ModelState;
import com.njcn.executor.pojo.vo.PqsCommunicate;
import com.njcn.executor.pojo.vo.PqsOnlineRate;
import com.njcn.influxdb.config.InfluxDbConfig;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.influxdb.InfluxDB;
import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.QueryResult;
import org.influxdb.impl.InfluxDBResultMapper;
import org.influxdb.querybuilder.SelectQueryImpl;
import org.influxdb.querybuilder.WhereNested;
import org.influxdb.querybuilder.WhereQueryImpl;
import org.influxdb.querybuilder.clauses.Clause;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.njcn.influxdb.param.InfluxDBPublicParam.*;
import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.*;
*/
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2022/7/8 13:43
*//*
@Slf4j
@Component
@AllArgsConstructor
public class PqsOnlineRateJob {
private final InfluxDbUtils influxDbUtils;
private final InfluxDbConfig influxDbConfig;
private final LineFeignClient lineFeignClient;
@XxlJob("pqsOnlineRateJobHandler")
public void pqsOnlineRateJobHandler() throws ParseException {
List<PqsOnlineRate> result = new ArrayList<>();
List<String> paramList = new ArrayList<>(),deviceList = new ArrayList<>();
String command = XxlJobHelper.getJobParam();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)-1, 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
Calendar calendar2 = Calendar.getInstance();
calendar2.set(calendar2.get(Calendar.YEAR), calendar2.get(Calendar.MONTH), calendar2.get(Calendar.DAY_OF_MONTH)-1, 23, 59, 59);
calendar2.set(Calendar.MILLISECOND, 0);
String startTime = format.format(calendar.getTime());
String endTime = format.format(calendar2.getTime());
if (!StringUtils.isEmpty(command)){
paramList = Arrays.asList(command.split(","));
startTime = paramList.get(0);
endTime = paramList.get(1);
deviceList = paramList.subList(2,paramList.size());
boolean s1 = Pattern.matches(PatternRegex.TIME_FORMAT,startTime);
boolean e1 = Pattern.matches(PatternRegex.TIME_FORMAT,endTime);
if (!s1 || !e1){
log.error("补招时间格式错误");
return;
} else {
startTime = startTime + START_TIME;
endTime = endTime + END_TIME;
}
}
if (CollectionUtils.isEmpty(deviceList)){
deviceList = lineFeignClient.getDeviceList().getData();
}
if (!CollectionUtils.isEmpty(deviceList)){
long diff,diffDays,a,b = 0;
List<PqsCommunicate> l1 = new ArrayList<>(),l2 = new ArrayList<>();
Date d1 = format.parse(startTime);
Date d2 = format.parse(endTime);
diff = d2.getTime() - d1.getTime();
diffDays = diff / (24 * 60 * 60 * 1000-1000);
int days = (int) diffDays;
for (int i = 1; i <= days; i++) {
a = d1.getTime() + (long)(i-1)*(24 * 60 * 60) * 1000;
b = d1.getTime() + (long)i*(24 * 60 * 60) * 1000-1000;
startTime = format.format(a);
endTime = format.format(b);
//获取装置的最新的一条数据
List<PqsCommunicate> latestList = getData(deviceList);
if (!CollectionUtils.isEmpty(latestList)){
for (PqsCommunicate item : latestList) {
if (item.getTime().toEpochMilli() < a){
l1.add(item);
} else if (a <= item.getTime().toEpochMilli() && item.getTime().toEpochMilli() < b){
l2.add(item);
}
}
}
if (!CollectionUtils.isEmpty(l1)){
for (PqsCommunicate item : l1) {
PqsOnlineRate onlineRate = new PqsOnlineRate();
if (Objects.equals(item.getType(), ModelState.offline)){
onlineRate.setOfflineMin(DAY_MINUTE);
onlineRate.setOnlineMin(0);
onlineRate.setOnlineRate(0.0);
} else {
onlineRate.setOfflineMin(0);
onlineRate.setOnlineMin(DAY_MINUTE);
onlineRate.setOnlineRate(100.0);
}
onlineRate.setTime(Instant.ofEpochMilli(a));
onlineRate.setDevId(item.getDevId());
result.add(onlineRate);
}
}
if (!CollectionUtils.isEmpty(l2)){
List<String> devList = l2.stream().map(PqsCommunicate::getDevId).collect(Collectors.toList());
List<PqsCommunicate> list = getPqsCommunicate(devList,startTime,endTime);
//根据装置的id进行分组
Map<String,List<PqsCommunicate>> groupMap = list.stream().collect(Collectors.groupingBy(PqsCommunicate::getDevId));
try {
if (!CollectionUtils.isEmpty(groupMap)){
for (String key : groupMap.keySet()) {
int offTime = 0;
int onTime = 0;
PqsOnlineRate onlineRate = new PqsOnlineRate();
List<PqsCommunicate> infoList = groupMap.get(key);
if (infoList.size() > 1){
//获取最早一条记录
PqsCommunicate first = infoList.stream().min(Comparator.comparing(PqsCommunicate::getTime)).get();
//将上线和下线分组
Map<Integer,List<PqsCommunicate>> typeMap = infoList.stream().collect(Collectors.groupingBy(PqsCommunicate::getType));
List<PqsCommunicate> off = typeMap.get(0);
List<PqsCommunicate> on = typeMap.get(1);
if (first.getType() == 0){
if (off.size() == on.size()){
for (int j = 0; j < off.size(); j++) {
offTime = offTime + (int) (on.get(j).getTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() + 1000L - off.get(j).getTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / (1000*60);
}
} else {
for (int j = 0; j < off.size(); j++) {
if (j == off.size() - 1){
offTime = offTime + (int) (format.parse(endTime).getTime() + 1000L - off.get(j).getTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / (1000*60);
} else {
offTime = offTime + (int) (on.get(j).getTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() + 1000L - off.get(j).getTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / (1000*60);
}
}
}
onTime = DAY_MINUTE-offTime;
} else {
if (off.size() == on.size()){
for (int j = 0; j < on.size(); j++) {
onTime = onTime + (int) (off.get(j).getTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() + 1000L - on.get(j).getTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / (1000*60);
}
} else {
for (int j = 0; j < on.size(); j++) {
if (j == on.size() - 1){
onTime = onTime + (int) (format.parse(endTime).getTime() + 1000L - on.get(j).getTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / (1000*60);
} else {
onTime = onTime + (int) (off.get(j).getTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() + 1000L - on.get(j).getTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / (1000*60);
}
}
}
offTime = DAY_MINUTE-onTime;
}
} else {
LocalDateTime updateTime = LocalDateTime.ofInstant(infoList.get(0).getTime(), ZoneId.systemDefault());
if (Objects.equals(infoList.get(0).getType(),0)) {
onTime = 0;
offTime = (int) (format.parse(endTime).getTime() + 1000L - updateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / (1000*60);
} else {
offTime = 0;
onTime = (int) (format.parse(endTime).getTime() + 1000L - updateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()) / (1000*60);
}
}
onlineRate.setDevId(infoList.get(0).getDevId());
onlineRate.setOnlineMin(onTime);
onlineRate.setOfflineMin(offTime);
onlineRate.setOnlineRate(Double.parseDouble(String.format("%.2f",onTime*1.0/DAY_MINUTE*100)));
onlineRate.setTime(Instant.ofEpochMilli(a));
result.add(onlineRate);
}
}
} catch (ParseException e) {
e.getMessage();
}
}
}
}
insertData(result);
}
*/
/**
* 获取pqs_communicate数据
* @param list 装置集合
* @param startTime 开始时间
* @param endTime 结束时间
* @return pqs_communicate数据
*//*
private List<PqsCommunicate> getPqsCommunicate(List<String> list, String startTime, String endTime){
SelectQueryImpl selectQuery = select().from(influxDbConfig.getDatabase(), PQS_COMMUNICATE);
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
whereAndNested(list, where);
where.and(gte(TIME, startTime)).and(lte(TIME, endTime));
where.tz(TZ);
QueryResult queryResult = influxDbUtils.query(selectQuery.getCommand());
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
return resultMapper.toPOJO(queryResult, PqsCommunicate.class);
}
*/
/**
* 拼接装置条件
* @param list 装置集合
* @param whereQuery WhereQueryImpl
*//*
private void whereAndNested(List<String> list, WhereQueryImpl<SelectQueryImpl> whereQuery) {
List<Clause> clauses = new ArrayList<>();
list.forEach(item->{
Clause clause = eq(DEV_ID, item);
clauses.add(clause);
});
WhereNested<WhereQueryImpl<SelectQueryImpl>> andNested = whereQuery.andNested();
for (Clause clause : clauses) {
andNested.or(clause);
}
andNested.close();
}
*/
/**
* 获取pqs_communicate数据最新一条数据
* @param list 装置id集合
* @return pqs_communicate数据
*//*
private List<PqsCommunicate> getData(List<String> list){
SelectQueryImpl selectQuery = select().from(influxDbConfig.getDatabase(), PQS_COMMUNICATE);
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
whereAndNested(list, where);
where.groupBy(DEV_ID).orderBy(desc()).limit(1);
where.tz(TZ);
QueryResult queryResult = influxDbUtils.query(selectQuery.getCommand());
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
return resultMapper.toPOJO(queryResult, PqsCommunicate.class);
}
*/
/**
* 功能描述:插入pqs_integrity表数据
* @author xy
* @param list 数据集合
* @date 2022/5/12 8:55
*//*
private void insertData(List<PqsOnlineRate> list){
List<String> records = new ArrayList<>();
list.forEach(item->{
Map<String, String> tags = new HashMap<>();
Map<String, Object> fields = new HashMap<>();
tags.put(DEV_ID,item.getDevId());
fields.put(ONLINE_MIN,item.getOnlineMin());
fields.put(OFFLINE_MIN,item.getOfflineMin());
fields.put(ONLINE_RATE,item.getOnlineRate());
Point point = influxDbUtils.pointBuilder(PQS_ONLINERATE, item.getTime().toEpochMilli(), TimeUnit.MILLISECONDS, tags, fields);
BatchPoints batchPoints = BatchPoints.database(influxDbConfig.getDatabase()).tag(DEV_ID, item.getDevId()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
batchPoints.point(point);
records.add(batchPoints.lineProtocol());
});
influxDbUtils.batchInsert(influxDbConfig.getDatabase(),"", InfluxDB.ConsistencyLevel.ALL, records);
}
}
*/

View File

@@ -56,6 +56,7 @@ public class EventTemplateParam {
/**
* 区分监测点与区域报告
*/
@NotNull(message = "type不能为空")
private Integer type;
}

View File

@@ -1,6 +1,7 @@
package com.njcn.system.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
@@ -26,6 +27,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* <p>
@@ -45,6 +47,7 @@ public class ConfigController extends BaseController {
private final IConfigService iConfigService;
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@GetMapping("/getSysConfig")
@ApiOperation("获取系统配置")
@@ -68,7 +71,8 @@ public class ConfigController extends BaseController {
public HttpResult<List<Config>> getSysConfigData() {
String methodDescribe = getMethodDescribe("getSysConfigData");
LogUtil.njcnDebug(log, "{}", methodDescribe, methodDescribe);
List<Config> res = iConfigService.list();
List<Config> res = iConfigService.getList();
if (CollectionUtils.isEmpty(res)) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
} else {

View File

@@ -5,17 +5,19 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.system.pojo.po.Resinformation;
import com.njcn.system.service.IResourceAdministrationService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* @version 1.0.0
@@ -46,4 +48,17 @@ public class ResourceAdministrationController extends BaseController {
Boolean flag = iResourceAdministrationService.uploadFile(multipartFile, name, type, describe, systemType);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
}
/**
* 查询数据
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryData")
@ApiOperation("查询数据")
@ApiImplicitParam(name = "baseParam",value = "查询数据",required = true)
public HttpResult<List<Resinformation>> queryData(@RequestBody @Validated BaseParam baseParam) {
String methodDescribe = getMethodDescribe("queryData");
List<Resinformation> result = iResourceAdministrationService.queryData(baseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -1,8 +1,11 @@
package com.njcn.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.system.pojo.po.Config;
import java.util.List;
/**
* <p>
* Mapper 接口
@@ -13,4 +16,5 @@ import com.njcn.system.pojo.po.Config;
*/
public interface ConfigMapper extends BaseMapper<Config> {
List<Config> getList();
}

View File

@@ -12,5 +12,4 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface ResourceAdministrationMapper extends BaseMapper<Resinformation> {
}

View File

@@ -2,4 +2,19 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.system.mapper.ConfigMapper">
<select id="getList" resultType="Config">
SELECT
sys_config.*,
sys_usera.NAME AS createBy,
sys_userb.NAME AS updateBy
FROM
sys_config sys_config
LEFT JOIN sys_user sys_usera ON sys_config.create_by = sys_usera.id
LEFT JOIN sys_user sys_userb ON sys_config.update_by = sys_userb.id
WHERE
sys_config.state = 1
ORDER BY
sys_config.create_time DESC
</select>
</mapper>

View File

@@ -1,4 +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.njcn.system.mapper.ResourceAdministrationMapper">
</mapper>

View File

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.system.pojo.param.ConfigParam;
import com.njcn.system.pojo.po.Config;
import java.util.List;
/**
* <p>
* 服务类
@@ -26,4 +28,6 @@ public interface IConfigService extends IService<Config> {
* @return
*/
boolean updateSysConfig(ConfigParam.ConfigUpdateParam configUpdateParam);
List<Config> getList();
}

View File

@@ -3,8 +3,11 @@ package com.njcn.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.system.pojo.po.Resinformation;
import com.njcn.web.pojo.param.BaseParam;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* @version 1.0.0
* @author: zbj
@@ -14,4 +17,5 @@ public interface IResourceAdministrationService extends IService<Resinformation>
Boolean uploadFile(MultipartFile multipartFile, String name, String type, String describe,String systemType);
List<Resinformation> queryData(BaseParam baseParam);
}

View File

@@ -208,6 +208,9 @@ public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements IA
areaQueryWrapper.eq("sys_area.type", type);
areaQueryWrapper.eq("sys_area.state", DataStateEnum.ENABLE.getCode());
Area area = this.baseMapper.selectOne(areaQueryWrapper);
if (area.getPid().equals("-1")) {
return area;
}
if (!area.getPid().equals("0")) {
id = area.getPid();
area = areaPro(id, type);

View File

@@ -10,6 +10,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
/**
@@ -50,5 +51,10 @@ public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> impleme
return false;
}
@Override
public List<Config> getList() {
return this.baseMapper.getList();
}
}

View File

@@ -1,18 +1,23 @@
package com.njcn.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.mapper.ResourceAdministrationMapper;
import com.njcn.system.pojo.po.Resinformation;
import com.njcn.system.service.IResourceAdministrationService;
import com.njcn.web.pojo.param.BaseParam;
import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
/**
@@ -50,4 +55,15 @@ public class ResourceAdministrationServiceImpl extends ServiceImpl<ResourceAdmin
resinformation.setType(type);
return this.save(resinformation);
}
@Override
public List<Resinformation> queryData(BaseParam baseParam) {
if (!StringUtils.isBlank(baseParam.getSearchValue())) {
LambdaQueryWrapper<Resinformation> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Resinformation::getType, baseParam.getSearchValue());
return resourceAdministrationMapper.selectPage(new Page<>(baseParam.getPageNum(), baseParam.getPageSize()), wrapper).getRecords();
} else {
return this.page(new Page<>(baseParam.getPageNum(), baseParam.getPageSize())).getRecords();
}
}
}