EventTemplate控制器编写
This commit is contained in:
@@ -3,9 +3,11 @@ package com.njcn.device.pojo.param;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.hibernate.validator.constraints.Range;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,4 +32,14 @@ public class TerminalParam {
|
|||||||
private String extendMealId;
|
private String extendMealId;
|
||||||
@ApiModelProperty(name = "flowStrategyId",value = "流量策略")
|
@ApiModelProperty(name = "flowStrategyId",value = "流量策略")
|
||||||
private String flowStrategyId;
|
private String flowStrategyId;
|
||||||
|
|
||||||
|
@ApiModelProperty("页码")
|
||||||
|
@NotNull(message = "页码不可为空")
|
||||||
|
@Range(min = 1,message = "页码必须大于0")
|
||||||
|
private Integer pageNum;
|
||||||
|
|
||||||
|
@ApiModelProperty("条数")
|
||||||
|
@NotNull(message = "条数不可为空")
|
||||||
|
@Range(min = 1,message = "条数必须大于0")
|
||||||
|
private Integer pageSize;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.device.controller;
|
package com.njcn.device.controller;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.constant.OperateType;
|
import com.njcn.common.pojo.constant.OperateType;
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
@@ -8,9 +9,9 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
|||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
import com.njcn.device.enums.DeviceResponseEnum;
|
|
||||||
import com.njcn.device.pojo.param.TerminalMainQueryParam;
|
import com.njcn.device.pojo.param.TerminalMainQueryParam;
|
||||||
import com.njcn.device.pojo.param.TerminalParam;
|
import com.njcn.device.pojo.param.TerminalParam;
|
||||||
|
import com.njcn.device.pojo.po.MonthFlow;
|
||||||
import com.njcn.device.pojo.vo.TerminalMaintainVO;
|
import com.njcn.device.pojo.vo.TerminalMaintainVO;
|
||||||
import com.njcn.device.service.TerminalMaintainService;
|
import com.njcn.device.service.TerminalMaintainService;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
@@ -22,9 +23,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@@ -106,6 +105,18 @@ public class TerminalMaintainController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resList, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resList, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流量统计主界面
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/getFlowStatisticsList")
|
||||||
|
@ApiOperation("查看流量统计列表")
|
||||||
|
public HttpResult<Page<MonthFlow>> getFlowStatisticsList(@RequestBody TerminalParam terminalParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("getFlowStatisticsList");
|
||||||
|
Page<MonthFlow> resList = terminalMaintainService.getFlowStatic(terminalParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resList, methodDescribe);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 批量修改终端状态
|
* 批量修改终端状态
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.njcn.device.service;
|
package com.njcn.device.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.njcn.device.pojo.param.TerminalMainQueryParam;
|
import com.njcn.device.pojo.param.TerminalMainQueryParam;
|
||||||
import com.njcn.device.pojo.param.TerminalParam;
|
import com.njcn.device.pojo.param.TerminalParam;
|
||||||
|
import com.njcn.device.pojo.po.MonthFlow;
|
||||||
import com.njcn.device.pojo.vo.TerminalMaintainVO;
|
import com.njcn.device.pojo.vo.TerminalMaintainVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -29,6 +31,10 @@ public interface TerminalMaintainService {
|
|||||||
*/
|
*/
|
||||||
List<TerminalMaintainVO> getManageList(List<String> ids,Integer type);
|
List<TerminalMaintainVO> getManageList(List<String> ids,Integer type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流量统计主界面
|
||||||
|
*/
|
||||||
|
Page<MonthFlow> getFlowStatic(TerminalParam terminalParam);
|
||||||
/**
|
/**
|
||||||
* 修改终端参数
|
* 修改终端参数
|
||||||
* @author cdf
|
* @author cdf
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.device.service.impl;
|
package com.njcn.device.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.device.enums.DeviceResponseEnum;
|
import com.njcn.device.enums.DeviceResponseEnum;
|
||||||
@@ -11,6 +12,7 @@ import com.njcn.device.pojo.param.TerminalParam;
|
|||||||
import com.njcn.device.pojo.po.DevMeal;
|
import com.njcn.device.pojo.po.DevMeal;
|
||||||
import com.njcn.device.pojo.po.DevStrategy;
|
import com.njcn.device.pojo.po.DevStrategy;
|
||||||
import com.njcn.device.pojo.po.Device;
|
import com.njcn.device.pojo.po.Device;
|
||||||
|
import com.njcn.device.pojo.po.MonthFlow;
|
||||||
import com.njcn.device.pojo.vo.TerminalMaintainVO;
|
import com.njcn.device.pojo.vo.TerminalMaintainVO;
|
||||||
import com.njcn.device.pojo.vo.TerminalVersionVO;
|
import com.njcn.device.pojo.vo.TerminalVersionVO;
|
||||||
import com.njcn.device.service.IDevMealService;
|
import com.njcn.device.service.IDevMealService;
|
||||||
@@ -92,6 +94,14 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService {
|
|||||||
throw new BusinessException(CommonResponseEnum.FAIL);
|
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<MonthFlow> getFlowStatic(TerminalParam terminalParam) {
|
||||||
|
Page<MonthFlow> page = new Page<>();
|
||||||
|
page.setSize(terminalParam.getPageSize());
|
||||||
|
page.setCurrent(terminalParam.getPageNum());
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateRunFlagManage(TerminalParam terminalParam){
|
public boolean updateRunFlagManage(TerminalParam terminalParam){
|
||||||
//终端状态管理
|
//终端状态管理
|
||||||
@@ -150,7 +160,4 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package com.njcn.system.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hany
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2022年09月08日
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum EventResponseEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用能模块异常响应码的范围:
|
||||||
|
* A00450 ~ A00549
|
||||||
|
*/
|
||||||
|
ENERGY_COMMON_ERROR("A00450","用能模块异常"),
|
||||||
|
NET_DEV_NAME_REPEAT("A00451", "网关设备名称重复"),
|
||||||
|
DEV_VERSION_REPEAT("A00451", "设备版本信息重复"),
|
||||||
|
STRATEGY_REPEAT("A00453","空调策略名称重复"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用能模板交互应答code
|
||||||
|
*/
|
||||||
|
SUCCESS("200","success"),
|
||||||
|
PROCESSING("202","请求处理中"),
|
||||||
|
|
||||||
|
AUTO_OFFLINE("300","设备有异常,主动下线"),
|
||||||
|
FAIL("400","请求失败"),
|
||||||
|
PARAM_FAIL_TIMESTAMP("400","请求失败,时间戳不能为空,请检查timestamp字段"),
|
||||||
|
PARAM_ERROR_TIMESTAMP("400","请求失败,时间戳格式错误,请检查timestamp字段"),
|
||||||
|
PARAM_FAIL_TYPE("400","请求失败,消息类型不能为空,请检查type字段"),
|
||||||
|
TYPE_ERROR("400","请求失败,接口名称不匹配,请检查type字段"),
|
||||||
|
REGISTER_ERROR("400","注册失败,注册的联网设备不存在,请先平台录入"),
|
||||||
|
REPEAT_ERROR("400","注册失败,有重复装置注册"),
|
||||||
|
EXIST_ERROR("400","注册失败,存在已注册的装置"),
|
||||||
|
CANCEL_ERROR("400","取消注册失败,存在未注册或者接入的装置,无法取消注册"),
|
||||||
|
NO_MODEL_FIND("402","接入失败,模板未找到"),
|
||||||
|
MISSING_MODEL("402","接入失败,模板数据缺失"),
|
||||||
|
MISSING_TOPIC("402","接入失败,缺少网关主题相关信息"),
|
||||||
|
NO_DID_FIND("400","接入失败,需要接入的装置未找到"),
|
||||||
|
MODULE_MATCH_ERROR("400","接入失败,接入的装置和模板数量不匹配"),
|
||||||
|
SAME_DEV_ERROR("400","模板数据错误,存在重复的装置信息"),
|
||||||
|
MODEL_ERROR("400","模板数据错误,模板未找到"),
|
||||||
|
NET_DEV_MODEL_ERROR("400","网关模板解析错误,平台未找到此网关"),
|
||||||
|
LINE_REPEAT_ERROR("400","网关模板解析错误,库中存在相同的监测点id"),
|
||||||
|
|
||||||
|
|
||||||
|
CERTIFICATION_ERROR("401","请求未认证/认证错误"),
|
||||||
|
REQUEST_REFUSE("403","请求被拒绝"),
|
||||||
|
FUNCTION_MISSING("404","请求的资源不存在"),
|
||||||
|
OVER_WAITING_TIME("408","请求超时"),
|
||||||
|
OTHER_ERROR("500","其他错误"),
|
||||||
|
|
||||||
|
NO_DICT("501","字典表无此数据"),
|
||||||
|
NO_TABLE("501","字典表无influxDB表名数据"),
|
||||||
|
DEV_LINE_EMPTY("501","设备监测点不可为空"),
|
||||||
|
DIC_NAME_REPEAT("502","字典名称不可重复"),
|
||||||
|
CHILDREN_EXIT("503","存在子节点,不可删除"),
|
||||||
|
|
||||||
|
|
||||||
|
CAI_BIND("504","用能负荷未绑定监测点"),
|
||||||
|
LOAD_VAL_CONFLICT("505","负荷类型与值类型冲突"),
|
||||||
|
ENERGY_EMPTY("506","用能查询数据为空"),
|
||||||
|
TASK_CREATE_ERROR("507","定时任务创建失败"),
|
||||||
|
|
||||||
|
TASK_HAS_START("508","任务已经执行完毕"),
|
||||||
|
TASK_DEL_ERROR("509","定时任务删除失败,请联系管理员"),
|
||||||
|
TASK_RUNING("510","任务正在执行无法操作,请先停止任务"),
|
||||||
|
TASK_TIME_ERROR("511","两条策略时间差应在5分钟以上"),
|
||||||
|
TASK_NO_RUN("512","策略不在执行中"),
|
||||||
|
TASK_STOP_ERROR("513","策略停止失败,请联系管理员"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
EventResponseEnum(String code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.njcn.system.pojo.param;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
|
import com.njcn.web.constant.ValidMessage;
|
||||||
|
import com.njcn.web.pojo.param.BaseParam;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hany
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2022/09/13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EventTemplateParam {
|
||||||
|
|
||||||
|
@ApiModelProperty("名称")
|
||||||
|
@NotBlank(message = ValidMessage.NAME_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.DIC_REGEX, message = ValidMessage.NAME_FORMAT_ERROR)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("父节点")
|
||||||
|
@NotBlank(message = ValidMessage.PID_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.DIC_REGEX, message = ValidMessage.PID_FORMAT_ERROR)
|
||||||
|
private String pid;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty("排序")
|
||||||
|
@NotNull(message = ValidMessage.SORT_NOT_NULL)
|
||||||
|
@Min(value = 0, message = ValidMessage.SORT_FORMAT_ERROR)
|
||||||
|
@Max(value = 999, message = ValidMessage.SORT_FORMAT_ERROR)
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新操作实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class EventTemplateUpdateParam extends EventTemplateParam {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表Id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("id")
|
||||||
|
@NotBlank(message = ValidMessage.ID_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR)
|
||||||
|
private String id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class EventTemplateQueryParam extends BaseParam {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.njcn.system.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.bo.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author hany
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2022/09/10
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName(value = "eventreport_dict")
|
||||||
|
public class EventDict extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典数据表Id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父节点
|
||||||
|
*/
|
||||||
|
private String pid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上层所有父节点
|
||||||
|
*/
|
||||||
|
private String pids;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态:0-删除 1-正常
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.njcn.system.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典树
|
||||||
|
* @author hany
|
||||||
|
* @date 2022/09/09
|
||||||
|
*/
|
||||||
|
@ApiModel
|
||||||
|
@Data
|
||||||
|
public class EventTemplateTree implements Serializable {
|
||||||
|
private String id;
|
||||||
|
@ApiModelProperty(name = "parentId",value = "父id")
|
||||||
|
private String pid;
|
||||||
|
@ApiModelProperty(name = "level",value = "等级")
|
||||||
|
private Integer level;
|
||||||
|
@ApiModelProperty(name = "name",value = "名称")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty(name = "sort",value = "排序")
|
||||||
|
private Integer sort;
|
||||||
|
@ApiModelProperty(name = "comFlag",value = "设备状态")
|
||||||
|
private Integer comFlag;
|
||||||
|
@ApiModelProperty(name = "children",value = "子节点")
|
||||||
|
private List<EventTemplateTree> children = new ArrayList<>();
|
||||||
|
|
||||||
|
private String pids;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 终端厂家
|
||||||
|
*/
|
||||||
|
private String manufacturer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电压等级Id,字典表
|
||||||
|
*/
|
||||||
|
private String scale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 干扰源类型,字典表
|
||||||
|
*/
|
||||||
|
private String loadType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接线方式
|
||||||
|
*/
|
||||||
|
private Integer ptType;
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.njcn.system.pojo.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hany
|
||||||
|
* @version 1.0.0
|
||||||
|
* @date 2022/09/13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EventTemplateVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典数据表Id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父节点
|
||||||
|
*/
|
||||||
|
private String pid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有父节点
|
||||||
|
*/
|
||||||
|
private String pids;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态:0-删除 1-正常
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
package com.njcn.system.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
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.common.utils.LogUtil;
|
||||||
|
import com.njcn.system.pojo.param.DictDataParam;
|
||||||
|
import com.njcn.system.pojo.param.EventTemplateParam;
|
||||||
|
import com.njcn.system.pojo.vo.DictDataVO;
|
||||||
|
import com.njcn.system.pojo.vo.EventTemplateTree;
|
||||||
|
import com.njcn.system.pojo.vo.EventTemplateVO;
|
||||||
|
import com.njcn.system.service.IEventTemplateService;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pqs
|
||||||
|
*
|
||||||
|
* @author hany
|
||||||
|
* @date 2022/9/7
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Api(tags = "事件模板")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/EventTemplate")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Validated
|
||||||
|
public class EventTemplateController extends BaseController{
|
||||||
|
|
||||||
|
private final IEventTemplateService iEventTemplateService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典树
|
||||||
|
* @author hany
|
||||||
|
* @date 2022/09/09
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取字典树")
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
|
||||||
|
@GetMapping("/getEventTemplateTree")
|
||||||
|
public HttpResult<List<EventTemplateTree>> getEventTemplateTree(){
|
||||||
|
String methodDescribe = getMethodDescribe("getEventTemplateTree");
|
||||||
|
List<EventTemplateTree> tree = iEventTemplateService.getEventTemplateTree();
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, tree, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询字典类型数据
|
||||||
|
* @author hany
|
||||||
|
* @date 2022/09/09
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@PostMapping("/list")
|
||||||
|
@ApiOperation("查询字典数据")
|
||||||
|
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||||
|
public HttpResult<Page<EventTemplateVO>> list(@RequestBody @Validated EventTemplateParam.EventTemplateQueryParam queryParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("list");
|
||||||
|
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||||
|
Page<EventTemplateVO> result = iEventTemplateService.listEventTemplateData(queryParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增模板
|
||||||
|
* @author hany
|
||||||
|
* @date 2022/09/09
|
||||||
|
*/
|
||||||
|
@PostMapping("/add")
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@ApiOperation("新增模板")
|
||||||
|
@ApiImplicitParam(name = "dictDataParam", value = "模板数据", required = true)
|
||||||
|
public HttpResult<Boolean> add(@RequestBody EventTemplateParam eventTemplateParam){
|
||||||
|
String methodDescribe = getMethodDescribe("add");
|
||||||
|
LogUtil.njcnDebug(log, "{},模板数据为:{}", methodDescribe, eventTemplateParam);
|
||||||
|
boolean result = iEventTemplateService.add(eventTemplateParam);
|
||||||
|
if (result) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
* @author hany
|
||||||
|
* @date 2022/09/08
|
||||||
|
*/
|
||||||
|
@PostMapping("/update")
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@ApiOperation("修改字典")
|
||||||
|
@ApiImplicitParam(name = "dictDataUpdateParam", value = "字典表数据", required = true)
|
||||||
|
public HttpResult<Boolean> update(@RequestBody EventTemplateParam.EventTemplateUpdateParam eventTemplateUpdateParam){
|
||||||
|
String methodDescribe = getMethodDescribe("update");
|
||||||
|
LogUtil.njcnDebug(log, "{},字典表数据数据为:{}", methodDescribe, eventTemplateUpdateParam);
|
||||||
|
boolean result = iEventTemplateService.update(eventTemplateUpdateParam);
|
||||||
|
if (result) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
* @author hany
|
||||||
|
* @date 2022/09/08
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@ApiOperation("删除字典")
|
||||||
|
@ApiImplicitParam(name = "id", value = "字典表索引", required = true)
|
||||||
|
public HttpResult<Boolean> delete(@RequestParam("id") String id){
|
||||||
|
String methodDescribe = getMethodDescribe("delete");
|
||||||
|
iEventTemplateService.delete(id);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.njcn.system.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.njcn.system.pojo.po.EventDict;
|
||||||
|
import com.njcn.system.pojo.vo.DictDataVO;
|
||||||
|
import com.njcn.system.pojo.vo.EventTemplateVO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hany
|
||||||
|
* @createTime 2022/09/08
|
||||||
|
*/
|
||||||
|
public interface EventTemplateMapper extends BaseMapper<EventDict> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询字典数据
|
||||||
|
* @param page 分页数据
|
||||||
|
* @param queryWrapper 查询条件
|
||||||
|
* @return 字典数据
|
||||||
|
*/
|
||||||
|
Page<EventTemplateVO> page(@Param("page")Page<EventTemplateVO> page, @Param("ew")QueryWrapper<EventTemplateVO> queryWrapper);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?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.EventTemplateMapper">
|
||||||
|
|
||||||
|
<!--获取字典分页列表-->
|
||||||
|
<select id="page" resultType="EventTemplateVO">
|
||||||
|
SELECT eventreport_dict.*
|
||||||
|
FROM eventreport_dict eventreport_dict
|
||||||
|
WHERE ${ew.sqlSegment}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.njcn.system.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.njcn.system.pojo.param.DictDataParam;
|
||||||
|
import com.njcn.system.pojo.param.EventTemplateParam;
|
||||||
|
import com.njcn.system.pojo.vo.EventTemplateTree;
|
||||||
|
import com.njcn.system.pojo.vo.EventTemplateVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: hany
|
||||||
|
* @date: 2022/09/08
|
||||||
|
* @Description: <描述>
|
||||||
|
*/
|
||||||
|
public interface IEventTemplateService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典树
|
||||||
|
*/
|
||||||
|
List<EventTemplateTree> getEventTemplateTree();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据前台传递参数,分页查询字典数据
|
||||||
|
* @param queryParam 查询参数
|
||||||
|
* @return 字典列表
|
||||||
|
*/
|
||||||
|
Page<EventTemplateVO> listEventTemplateData(EventTemplateParam.EventTemplateQueryParam queryParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*/
|
||||||
|
boolean add(EventTemplateParam eventDataParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
* @param eventDataUpdateParam
|
||||||
|
*/
|
||||||
|
boolean update(EventTemplateParam.EventTemplateUpdateParam eventDataUpdateParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
boolean delete(String id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
package com.njcn.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.db.constant.DbConstant;
|
||||||
|
import com.njcn.system.enums.EventResponseEnum;
|
||||||
|
import com.njcn.system.mapper.EventTemplateMapper;
|
||||||
|
import com.njcn.system.pojo.param.EventTemplateParam;
|
||||||
|
import com.njcn.system.pojo.po.EventDict;
|
||||||
|
import com.njcn.system.pojo.vo.EventTemplateTree;
|
||||||
|
import com.njcn.system.pojo.vo.EventTemplateVO;
|
||||||
|
import com.njcn.system.service.IEventTemplateService;
|
||||||
|
import com.njcn.web.factory.PageFactory;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: hany
|
||||||
|
* @date: 2022/09/07
|
||||||
|
* @Description: <描述>
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class EventTemplateServiceImpl extends ServiceImpl<EventTemplateMapper, EventDict> implements IEventTemplateService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字典树
|
||||||
|
* @author hany
|
||||||
|
* @date 2022/09/09
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<EventTemplateTree> getEventTemplateTree() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询字典类型数据
|
||||||
|
* @author hany
|
||||||
|
* @date 2022/09/13
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Page<EventTemplateVO> listEventTemplateData(EventTemplateParam.EventTemplateQueryParam queryParam) {
|
||||||
|
QueryWrapper<EventTemplateVO> queryWrapper = new QueryWrapper<>();
|
||||||
|
if (ObjectUtil.isNotNull(queryParam)) {
|
||||||
|
//查询参数不为空,进行条件填充
|
||||||
|
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
||||||
|
//字典类型表,仅提供名称、编码模糊查询
|
||||||
|
queryWrapper
|
||||||
|
.and(param -> param.like("eventreport_dict.name", queryParam.getSearchValue())
|
||||||
|
.or().like("eventreport_dict.pid", queryParam.getSearchValue()));
|
||||||
|
}
|
||||||
|
//排序
|
||||||
|
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||||
|
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||||
|
} else {
|
||||||
|
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||||
|
queryWrapper.orderBy(true, true, "eventreport_dict.sort");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
queryWrapper.ne("eventreport_dict.state", DataStateEnum.DELETED.getCode());
|
||||||
|
//初始化分页数据
|
||||||
|
return this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
* @author hany
|
||||||
|
* @date 2022/09/08
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean add(EventTemplateParam eventTemplateParam) {
|
||||||
|
checkName(eventTemplateParam,true);
|
||||||
|
EventDict eventDict = new EventDict();
|
||||||
|
BeanUtils.copyProperties(eventTemplateParam,eventDict);
|
||||||
|
eventDict.setState(DataStateEnum.ENABLE.getCode());
|
||||||
|
return this.save(eventDict);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean update(EventTemplateParam.EventTemplateUpdateParam eventTemplateUpdateParam) {
|
||||||
|
checkName(eventTemplateUpdateParam,false);
|
||||||
|
EventDict eventDict = new EventDict();
|
||||||
|
BeanUtils.copyProperties(eventTemplateUpdateParam,eventDict);
|
||||||
|
return this.updateById(eventDict);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean delete(String id) {
|
||||||
|
LambdaQueryWrapper<EventDict> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(EventDict::getPid,id).eq(EventDict::getState,DataStateEnum.ENABLE.getCode());
|
||||||
|
int resCount = this.count(lambdaQueryWrapper);
|
||||||
|
if(resCount>0){
|
||||||
|
throw new BusinessException(EventResponseEnum.CHILDREN_EXIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateWrapper<EventDict> updateWrapper = new UpdateWrapper<>();
|
||||||
|
updateWrapper.lambda().eq(EventDict::getState,DataStateEnum.ENABLE.getCode()).set(EventDict::getState,DataStateEnum.DELETED.getCode()).eq(EventDict::getId,id);
|
||||||
|
return this.update(updateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称重复校验
|
||||||
|
*/
|
||||||
|
private void checkName(EventTemplateParam eventTemplateParam,boolean flag){
|
||||||
|
LambdaQueryWrapper<EventDict> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(EventDict::getName,eventTemplateParam.getName())
|
||||||
|
.eq(EventDict::getState, DataStateEnum.ENABLE.getCode());
|
||||||
|
//修改
|
||||||
|
if(!flag){
|
||||||
|
if(eventTemplateParam instanceof EventTemplateParam.EventTemplateUpdateParam ){
|
||||||
|
lambdaQueryWrapper.ne(EventDict::getId,((EventTemplateParam.EventTemplateUpdateParam)eventTemplateParam).getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int res = this.count(lambdaQueryWrapper);
|
||||||
|
//大于等于1个则表示重复
|
||||||
|
if (res >= 1) {
|
||||||
|
throw new BusinessException(EventResponseEnum.DIC_NAME_REPEAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user