字典录入功能调整
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.njcn.system.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.system.api.fallback.EleEvtFeignClientFallbackFactory;
|
||||
import com.njcn.system.pojo.param.EleEvtParam;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @date 2021年05月08日 15:11
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.SYSTEM,path = "/eleEvtParm",fallbackFactory = EleEvtFeignClientFallbackFactory.class,contextId = "eleEvtParm")
|
||||
public interface EleEvtFeignClient {
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增事件拓展数据")
|
||||
HttpResult<EleEpdPqd> add(@RequestBody EleEvtParam evtParam);
|
||||
|
||||
}
|
||||
@@ -25,6 +25,9 @@ public interface EpdFeignClient {
|
||||
@PostMapping("/addByModel")
|
||||
HttpResult<String> addByModel(@RequestBody List<EleEpdPqdParam> eleEpdPqdParam);
|
||||
|
||||
@PostMapping("/add")
|
||||
HttpResult<EleEpdPqd> add(@RequestBody EleEpdPqdParam eleEpdPqdParam);
|
||||
|
||||
@PostMapping("/dictMarkByDataType")
|
||||
HttpResult<List<EleEpdPqd>> dictMarkByDataType(@RequestParam("dataType") String dataType);
|
||||
|
||||
@@ -37,4 +40,6 @@ public interface EpdFeignClient {
|
||||
@PostMapping("/selectByIds")
|
||||
HttpResult<List<EleEpdPqd>> selectByIds(@RequestBody List<String> ids);
|
||||
|
||||
@PostMapping("/judgeExist")
|
||||
HttpResult<List<EleEpdPqd>> judgeExist(@RequestParam("name") String name,@RequestParam("dataType") String dataType);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.njcn.system.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.system.api.EleEvtFeignClient;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.pojo.param.EleEpdPqdParam;
|
||||
import com.njcn.system.pojo.param.EleEvtParam;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.utils.SystemEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/5/24 18:46
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EleEvtFeignClientFallbackFactory implements FallbackFactory<EleEvtFeignClient> {
|
||||
@Override
|
||||
public EleEvtFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if(cause.getCause() instanceof BusinessException){
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = SystemEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new EleEvtFeignClient() {
|
||||
@Override
|
||||
public HttpResult<EleEpdPqd> add(EleEvtParam evtParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}","新增事件拓展数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,12 @@ public class EpdFeignClientFallbackFactory implements FallbackFactory<EpdFeignCl
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<EleEpdPqd> add(EleEpdPqdParam eleEpdPqdParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}","新增字典数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<EleEpdPqd>> dictMarkByDataType(String dataType) {
|
||||
log.error("{}异常,降级处理,异常为:{}","通过数据模型获取字典数据组装唯一标识",cause.toString());
|
||||
@@ -63,6 +69,12 @@ public class EpdFeignClientFallbackFactory implements FallbackFactory<EpdFeignCl
|
||||
log.error("{}异常,降级处理,异常为:{}","根据ids查询字典数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<EleEpdPqd>> judgeExist(String name, String dataType) {
|
||||
log.error("{}异常,降级处理,异常为:{}","校验字典是否存在",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,6 +373,8 @@ public enum DicDataEnum {
|
||||
/**
|
||||
* 治理数据模型
|
||||
*/
|
||||
APF("APF","Apf"),
|
||||
DVR("DVR","Dvr"),
|
||||
EPD("电能数据","Epd"),
|
||||
PQD("电能质量数据","Pqd"),
|
||||
BMD("基础测量数据","Bmd"),
|
||||
|
||||
@@ -81,10 +81,10 @@ public class EleEpdPqdParam {
|
||||
private Integer ctlSts;
|
||||
|
||||
@ApiModelProperty(value = "设置最大值")
|
||||
private Integer maxNum;
|
||||
private Double maxNum;
|
||||
|
||||
@ApiModelProperty(value = "设置最小值")
|
||||
private Integer minNum;
|
||||
private Double minNum;
|
||||
|
||||
@ApiModelProperty(value = "参数为enum可设置的所有值序列")
|
||||
private String setValue;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.system.pojo.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/7/31 14:44
|
||||
*/
|
||||
@Data
|
||||
public class EleEvtParam {
|
||||
|
||||
private String pid;
|
||||
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
|
||||
private String unit;
|
||||
|
||||
private String data;
|
||||
}
|
||||
@@ -120,12 +120,12 @@ public class EleEpdPqd {
|
||||
/**
|
||||
* 设置最大值
|
||||
*/
|
||||
private Integer maxNum;
|
||||
private Double maxNum;
|
||||
|
||||
/**
|
||||
* 设置最小值
|
||||
*/
|
||||
private Integer minNum;
|
||||
private Double minNum;
|
||||
|
||||
/**
|
||||
* 参数为enum可设置的所有值序列
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.njcn.system.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件拓展表
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-07-31
|
||||
*/
|
||||
@Data
|
||||
@TableName("cs_evt_parm")
|
||||
public class EleEvtParm {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id;
|
||||
|
||||
private String pid;
|
||||
|
||||
private String name;
|
||||
|
||||
private String type;
|
||||
|
||||
private String unit;
|
||||
|
||||
private String data;
|
||||
|
||||
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import com.njcn.system.service.IEleEpdPqdService;
|
||||
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.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -61,12 +62,12 @@ public class EleEpdPqdController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("新增字典数据")
|
||||
@ApiImplicitParam(name = "eleEpdPqdParam", value = "字典数据", required = true)
|
||||
public HttpResult<String> add(@RequestBody @Validated EleEpdPqdParam eleEpdPqdParam){
|
||||
public HttpResult<EleEpdPqd> add(@RequestBody @Validated EleEpdPqdParam eleEpdPqdParam){
|
||||
log.info("录入字典数据");
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},模板当前解析字典数据为:", methodDescribe);
|
||||
eleEpdPqdService.add(eleEpdPqdParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
EleEpdPqd eleEpdPqd = eleEpdPqdService.add(eleEpdPqdParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eleEpdPqd, methodDescribe);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@@ -162,6 +163,19 @@ public class EleEpdPqdController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eleEpdPqds, methodDescribe);
|
||||
}
|
||||
|
||||
@PostMapping("/judgeExist")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("校验字典是否存在")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "name", value = "指标名称", required = true),
|
||||
@ApiImplicitParam(name = "dataType", value = "数据模型", required = true)
|
||||
})
|
||||
public HttpResult<List<EleEpdPqd>> judgeExist(@RequestParam("name") @Validated String name, @RequestParam("dataType") @Validated String dataType){
|
||||
String methodDescribe = getMethodDescribe("judgeExist");
|
||||
LogUtil.njcnDebug(log, "{},校验字典是否存在:", methodDescribe);
|
||||
List<EleEpdPqd> list = eleEpdPqdService.judgeExist(name,dataType);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.njcn.system.controller;
|
||||
|
||||
|
||||
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.EleEpdPqdParam;
|
||||
import com.njcn.system.pojo.param.EleEvtParam;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.service.IEleEvtParmService;
|
||||
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.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件拓展表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-07-31
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/eleEvtParm")
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "事件字典录入")
|
||||
@Validated
|
||||
public class EleEvtParmController extends BaseController {
|
||||
|
||||
private final IEleEvtParmService eleEvtParmService;
|
||||
|
||||
@PostMapping("/add")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("新增事件拓展数据")
|
||||
@ApiImplicitParam(name = "evtParam", value = "字典数据", required = true)
|
||||
public HttpResult<EleEpdPqd> add(@RequestBody @Validated EleEvtParam evtParam){
|
||||
log.info("录入字典数据");
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},模板当前解析字典数据为:", methodDescribe);
|
||||
eleEvtParmService.add(evtParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.system.pojo.po.EleEvtParm;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件拓展表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-07-31
|
||||
*/
|
||||
public interface EleEvtParmMapper extends BaseMapper<EleEvtParm> {
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public interface IEleEpdPqdService extends IService<EleEpdPqd> {
|
||||
* 存储字典数据
|
||||
* @param eleEpdPqdParam
|
||||
*/
|
||||
void add(EleEpdPqdParam eleEpdPqdParam);
|
||||
EleEpdPqd add(EleEpdPqdParam eleEpdPqdParam);
|
||||
|
||||
/**
|
||||
* 删除字典数据
|
||||
@@ -85,4 +85,13 @@ public interface IEleEpdPqdService extends IService<EleEpdPqd> {
|
||||
* @return
|
||||
*/
|
||||
List<EleEpdPqd> selectByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 校验字典是否存在
|
||||
* @param name
|
||||
* @param dataType
|
||||
* @return
|
||||
*/
|
||||
List<EleEpdPqd> judgeExist(String name, String dataType);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.system.pojo.param.EleEvtParam;
|
||||
import com.njcn.system.pojo.po.EleEvtParm;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件拓展表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-07-31
|
||||
*/
|
||||
public interface IEleEvtParmService extends IService<EleEvtParm> {
|
||||
|
||||
void add(EleEvtParam eleEvtParam);
|
||||
|
||||
}
|
||||
@@ -51,13 +51,18 @@ public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdPqdMapper, EleEpdPqd
|
||||
eleEpdPqd.setType("");
|
||||
}
|
||||
eleEpdPqd.setStatus(1);
|
||||
if (CollectionUtil.isNotEmpty(item.getStatMethod())){
|
||||
eleEpdPqd.setStatMethod(String.join(",", item.getStatMethod()));
|
||||
}
|
||||
return eleEpdPqd;
|
||||
}).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(list)){
|
||||
this.saveBatch(list,1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(EleEpdPqdParam eleEpdPqdParam) {
|
||||
public EleEpdPqd add(EleEpdPqdParam eleEpdPqdParam) {
|
||||
checkEleEpdPqdParam(eleEpdPqdParam,false);
|
||||
EleEpdPqd eleEpdPqd = new EleEpdPqd();
|
||||
BeanUtils.copyProperties(eleEpdPqdParam,eleEpdPqd);
|
||||
@@ -72,6 +77,7 @@ public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdPqdMapper, EleEpdPqd
|
||||
}
|
||||
eleEpdPqd.setStatus(1);
|
||||
this.save(eleEpdPqd);
|
||||
return eleEpdPqd;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -186,6 +192,13 @@ public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdPqdMapper, EleEpdPqd
|
||||
return this.lambdaQuery().in(EleEpdPqd::getId,ids).orderByAsc(EleEpdPqd::getSort).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EleEpdPqd> judgeExist(String name, String dataType) {
|
||||
LambdaQueryWrapper<EleEpdPqd> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(EleEpdPqd::getDataType,dataType).eq(EleEpdPqd::getName,name).eq(EleEpdPqd::getStatus,1);
|
||||
return this.baseMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数,
|
||||
* 1.检查是否存在相同名称的菜单
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.system.mapper.EleEvtParmMapper;
|
||||
import com.njcn.system.pojo.param.EleEvtParam;
|
||||
import com.njcn.system.pojo.po.EleEvtParm;
|
||||
import com.njcn.system.service.IEleEvtParmService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 事件拓展表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xuyang
|
||||
* @since 2023-07-31
|
||||
*/
|
||||
@Service
|
||||
public class EleEvtParmServiceImpl extends ServiceImpl<EleEvtParmMapper, EleEvtParm> implements IEleEvtParmService {
|
||||
|
||||
@Override
|
||||
public void add(EleEvtParam eleEvtParam) {
|
||||
EleEvtParm eleEvtParm = new EleEvtParm();
|
||||
BeanUtils.copyProperties(eleEvtParam,eleEvtParm);
|
||||
this.save(eleEvtParm);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user