组态图元功能调整

This commit is contained in:
2023-07-13 19:08:47 +08:00
parent b890c7b07a
commit 285545ecd0
6 changed files with 47 additions and 2 deletions

View File

@@ -15,9 +15,11 @@ public enum CsSystemResponseEnum {
* <p>
*/
DICT_REPEAT("A0301","字典数据重复!"),
SAME_DATA_ERROR("A0301","数据重复"),
CS_SYSTEM_COMMON_ERROR("A00302","治理系统模块异常"),
;
private final String code;

View File

@@ -38,4 +38,8 @@ public class ElementParam {
@NotNull(message="图元文件不能为空!")
private MultipartFile multipartFile;
@ApiModelProperty(value = "图元类型")
@NotBlank(message="图元类型不能为空!")
private String elementForm;
}

View File

@@ -58,5 +58,10 @@ public class CsElement extends BaseEntity {
*/
private Integer status;
/**
* 图元类型
*/
private String elementForm;
}

View File

@@ -10,11 +10,13 @@ import com.njcn.cssystem.pojo.po.CsElement;
import com.njcn.cssystem.service.IElementService;
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 org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@@ -36,7 +38,7 @@ public class ElementController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/add")
@ApiOperation("组态图元新增")
@ApiOperation("新增图元")
public HttpResult<CsElement> add(@Validated ElementParam param){
String methodDescribe = getMethodDescribe("add");
CsElement csElement = csElementService.addElement(param);
@@ -45,11 +47,21 @@ public class ElementController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/find")
@ApiOperation("查询组态图元数据")
@ApiOperation("查询图元")
public HttpResult<List<CsElement>> find(){
String methodDescribe = getMethodDescribe("find");
List<CsElement> list = csElementService.findElement();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/delete")
@ApiOperation("删除图元")
@ApiImplicitParam(name = "id", value = "图元Id", required = true)
public HttpResult<String> deleteById(@RequestParam("id") String id){
String methodDescribe = getMethodDescribe("deleteById");
csElementService.deleteById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -27,4 +27,9 @@ public interface IElementService extends IService<CsElement> {
*/
List<CsElement> findElement();
/**
* 组态图元数据查询
*/
void deleteById(String id);
}

View File

@@ -1,6 +1,8 @@
package com.njcn.cssystem.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.cssystem.enums.CsSystemResponseEnum;
import com.njcn.cssystem.mapper.CsElementMapper;
import com.njcn.cssystem.pojo.param.ElementParam;
import com.njcn.cssystem.pojo.po.CsElement;
@@ -12,6 +14,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
/**
* <p>
@@ -29,6 +32,13 @@ public class CsElementServiceImpl extends ServiceImpl<CsElementMapper, CsElement
@Override
public CsElement addElement(ElementParam param) {
CsElement po = this.lambdaQuery().eq(CsElement::getStatus,1)
.eq(CsElement::getElementCode,param.getElementCode())
.eq(CsElement::getElementName,param.getElementName())
.eq(CsElement::getElementMark,param.getElementMark()).one();
if (!Objects.isNull(po)){
throw new BusinessException(CsSystemResponseEnum.SAME_DATA_ERROR);
}
CsElement csElement = new CsElement();
BeanUtils.copyProperties(param,csElement);
String path = fileStorageUtil.uploadMultipart(param.getMultipartFile(), OssPath.ELEMENT);
@@ -47,4 +57,11 @@ public class CsElementServiceImpl extends ServiceImpl<CsElementMapper, CsElement
});
return list;
}
@Override
public void deleteById(String id) {
CsElement csElement = this.lambdaQuery().eq(CsElement::getId,id).one();
csElement.setStatus(0);
this.updateById(csElement);
}
}