设备绑定相关接口
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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> {
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
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 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
|
||||||
|
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
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user