From 1d1bb876ba9453287d29f412096caa693544035a Mon Sep 17 00:00:00 2001 From: huangzj <826100833@qq.com> Date: Tue, 18 Apr 2023 15:07:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=BB=91=E5=AE=9A=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/param/CsDevModelRelationAddParm.java | 32 +++++++ .../param/CsDevModelRelationAuidtParm.java | 32 +++++++ .../param/CsDevModelRelationQueryParm.java | 28 ++++++ .../pojo/po/CsDevModelRelationPO.java | 41 +++++++++ .../pojo/vo/CsDevModelRelationVO.java | 37 ++++++++ .../Equipment/DevModelRelationController.java | 84 ++++++++++++++++++ .../mapper/CsDevModelRelationMapper.java | 16 ++++ .../mapping/CsDevModelRelationMapper.xml | 20 +++++ .../service/CsDevModelRelationService.java | 41 +++++++++ .../impl/CsDevModelRelationServiceImpl.java | 87 +++++++++++++++++++ 10 files changed, 418 insertions(+) create mode 100644 pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/param/CsDevModelRelationAddParm.java create mode 100644 pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/param/CsDevModelRelationAuidtParm.java create mode 100644 pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/param/CsDevModelRelationQueryParm.java create mode 100644 pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/po/CsDevModelRelationPO.java create mode 100644 pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/vo/CsDevModelRelationVO.java create mode 100644 pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/Equipment/DevModelRelationController.java create mode 100644 pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/mapper/CsDevModelRelationMapper.java create mode 100644 pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/mapper/mapping/CsDevModelRelationMapper.xml create mode 100644 pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/CsDevModelRelationService.java create mode 100644 pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/impl/CsDevModelRelationServiceImpl.java diff --git a/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/param/CsDevModelRelationAddParm.java b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/param/CsDevModelRelationAddParm.java new file mode 100644 index 000000000..0e95b91bf --- /dev/null +++ b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/param/CsDevModelRelationAddParm.java @@ -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; + + +} \ No newline at end of file diff --git a/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/param/CsDevModelRelationAuidtParm.java b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/param/CsDevModelRelationAuidtParm.java new file mode 100644 index 000000000..c2be7e2f3 --- /dev/null +++ b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/param/CsDevModelRelationAuidtParm.java @@ -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; +} \ No newline at end of file diff --git a/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/param/CsDevModelRelationQueryParm.java b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/param/CsDevModelRelationQueryParm.java new file mode 100644 index 000000000..16450617b --- /dev/null +++ b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/param/CsDevModelRelationQueryParm.java @@ -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; +} \ No newline at end of file diff --git a/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/po/CsDevModelRelationPO.java b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/po/CsDevModelRelationPO.java new file mode 100644 index 000000000..9714e7701 --- /dev/null +++ b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/po/CsDevModelRelationPO.java @@ -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; +} \ No newline at end of file diff --git a/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/vo/CsDevModelRelationVO.java b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/vo/CsDevModelRelationVO.java new file mode 100644 index 000000000..bd602d7ad --- /dev/null +++ b/pqs-algorithm/algorithm-api/src/main/java/com/njcn/algorithm/pojo/vo/CsDevModelRelationVO.java @@ -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; +} \ No newline at end of file diff --git a/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/Equipment/DevModelRelationController.java b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/Equipment/DevModelRelationController.java new file mode 100644 index 000000000..a330a5450 --- /dev/null +++ b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/controller/Equipment/DevModelRelationController.java @@ -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 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 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> queryDevModelRelationList(@RequestBody CsDevModelRelationQueryParm queryParm){ + String methodDescribe = getMethodDescribe("queryDevModelRelationList"); + + List list = csDevModelRelationService.queryDevModelRelation(queryParm); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); + } + + + +} diff --git a/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/mapper/CsDevModelRelationMapper.java b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/mapper/CsDevModelRelationMapper.java new file mode 100644 index 000000000..2e8cfc918 --- /dev/null +++ b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/mapper/CsDevModelRelationMapper.java @@ -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 { +} \ No newline at end of file diff --git a/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/mapper/mapping/CsDevModelRelationMapper.xml b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/mapper/mapping/CsDevModelRelationMapper.xml new file mode 100644 index 000000000..511be2730 --- /dev/null +++ b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/mapper/mapping/CsDevModelRelationMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + id, dev_id, `model id`, create_by, create_time, update_by, update_time, `status` + + \ No newline at end of file diff --git a/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/CsDevModelRelationService.java b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/CsDevModelRelationService.java new file mode 100644 index 000000000..6fcac744f --- /dev/null +++ b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/CsDevModelRelationService.java @@ -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{ + + /** + * @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 queryDevModelRelation(CsDevModelRelationQueryParm queryParm); + } diff --git a/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/impl/CsDevModelRelationServiceImpl.java b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/impl/CsDevModelRelationServiceImpl.java new file mode 100644 index 000000000..7e8ac3668 --- /dev/null +++ b/pqs-algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/impl/CsDevModelRelationServiceImpl.java @@ -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 implements CsDevModelRelationService{ + + @Override + public CsDevModelRelationPO addDevModelRelation(CsDevModelRelationAddParm addParm) { + CsDevModelRelationQueryParm queryParm = new CsDevModelRelationQueryParm(); + queryParm.setDevId (addParm.getDevId ()); + queryParm.setModelId (addParm.getModelId ()); + queryParm.setStatus ("1"); + List 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 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 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 queryDevModelRelation(CsDevModelRelationQueryParm queryParm) { + QueryWrapper 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 csDevModelRelationPOS = this.getBaseMapper ( ).selectList (queryWrapper); + List collect = csDevModelRelationPOS.stream ( ).map (temp -> { + CsDevModelRelationVO vo = new CsDevModelRelationVO ( ); + BeanUtils.copyProperties (temp, vo); + return vo; + }).collect (Collectors.toList ( )); + return collect; + } +}