检测脚本
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
package com.njcn.gather.device.script.controller;
|
||||
|
||||
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.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptParam;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.device.script.service.IPqScriptService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
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 javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "检测脚本管理")
|
||||
@RestController
|
||||
@RequestMapping("/pqScript")
|
||||
@RequiredArgsConstructor
|
||||
public class PqScriptController extends BaseController {
|
||||
private final IPqScriptService pqScriptService;
|
||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("分页查询检测脚本")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<PqScript>> list(@RequestBody @Validated PqScriptParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
Page<PqScript> result = pqScriptService.listPqScript(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增检测脚本")
|
||||
@ApiImplicitParam(name = "pqDevParam", value = "检测脚本", required = true)
|
||||
public HttpResult<Object> add(@RequestBody @Validated PqScriptParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||
boolean result = pqScriptService.addPqScript(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改检测脚本")
|
||||
@ApiImplicitParam(name = "updateParam", value = "检测脚本", required = true)
|
||||
public HttpResult<Object> update(@RequestBody @Validated PqScriptParam.UpdateParam param) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
|
||||
boolean result = pqScriptService.updatePqScript(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除检测脚本")
|
||||
@ApiImplicitParam(name = "ids", value = "检测脚本id", required = true)
|
||||
public HttpResult<Object> delete(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},删除ID数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
|
||||
boolean result = pqScriptService.deletePqScript(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("getScriptDtlsByScriptId")
|
||||
@ApiOperation("根据脚本id查询检测脚本详情")
|
||||
@ApiImplicitParam(name = "id", value = "检测脚本id", required = true)
|
||||
public HttpResult<List<PqScriptDtls>> getScriptDtlsByScriptId(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, id);
|
||||
List<PqScriptDtls> result = pqScriptDtlsService.listPqScriptDtlByScriptId(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@GetMapping("/upgradeToTemplate")
|
||||
@ApiOperation("升级为模板")
|
||||
@ApiImplicitParam(name = "id", value = "检测脚本id", required = true)
|
||||
public HttpResult<Object> upgradeToTemplate(@RequestParam("id") String id, HttpServletRequest request) {
|
||||
String methodDescribe = getMethodDescribe("upgradeToTemplate");
|
||||
LogUtil.njcnDebug(log, "{},升级ID数据为:{}", methodDescribe, id);
|
||||
boolean result = pqScriptService.upgradeToTemplate(id);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.device.script.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
public interface PqScriptDtlsMapper extends MPJBaseMapper<PqScriptDtls> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.device.script.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
public interface PqScriptMapper extends MPJBaseMapper<PqScript> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?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.gather.device.script.mapper.PqScriptDtlsMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?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.gather.device.script.mapper.PqScriptMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.njcn.gather.device.script.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DeviceValidMessage;
|
||||
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/18
|
||||
*/
|
||||
@Data
|
||||
public class PqScriptParam {
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 检测脚本类型,字典表(脚本还是模板)
|
||||
*/
|
||||
@ApiModelProperty("类型")
|
||||
@NotNull(message = DeviceValidMessage.SCRIPT_TYPE_NOT_BLANK)
|
||||
@Min(value = 1, message = DeviceValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
|
||||
@Max(value = 2, message = DeviceValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 检测脚本模式,字典表(数字、模拟、比对)
|
||||
*/
|
||||
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
* 检测脚本值类型(在非比对模式情况下,分为相对值检测脚本和绝对值检测脚本)
|
||||
*/
|
||||
@ApiModelProperty("值类型")
|
||||
private String valueType;
|
||||
|
||||
/**
|
||||
* 参照标准名称
|
||||
*/
|
||||
@ApiModelProperty("参照标准名称")
|
||||
@NotBlank(message = DeviceValidMessage.STANDARD_NAME_NOT_BLANK)
|
||||
private String standardName;
|
||||
|
||||
/**
|
||||
* 标准推行时间
|
||||
*/
|
||||
@ApiModelProperty("标准推行时间")
|
||||
@DateTimeStrValid(message = DeviceValidMessage.STANDARD_TIME_FORMAT_ERROR)
|
||||
@NotBlank(message = DeviceValidMessage.STANDARD_TIME_NOT_BLANK)
|
||||
private String standardTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty("值类型")
|
||||
private String valueType;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class UpdateParam extends PqScriptParam {
|
||||
@ApiModelProperty("检测脚本ID")
|
||||
@NotBlank(message = DeviceValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.njcn.gather.device.script.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("pq_script")
|
||||
public class PqScript extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = -61550003510158595L;
|
||||
/**
|
||||
* 检测脚本ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 检测脚本名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 检测脚本类型,字典表(脚本还是模板)
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 检测脚本模式,字典表(数字、模拟、比对)
|
||||
*/
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
* 检测脚本值类型(在非比对模式情况下,分为相对值检测脚本和绝对值检测脚本)
|
||||
*/
|
||||
private String valueType;
|
||||
|
||||
/**
|
||||
* 参照标准名称
|
||||
*/
|
||||
private String standardName;
|
||||
|
||||
/**
|
||||
* 标准推行时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
private LocalDate standardTime;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.njcn.gather.device.script.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Data
|
||||
@TableName("pq_script_dtls")
|
||||
public class PqScriptDtls implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 111579281505485316L;
|
||||
/**
|
||||
* 检测脚本子表ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 检测脚本ID
|
||||
*/
|
||||
private String scriptId;
|
||||
|
||||
/**
|
||||
* 检测脚本类型,树形字典表(没有树形表则需要拆分字段)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 相别,字典表
|
||||
*/
|
||||
private String phase;
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private Float value;
|
||||
|
||||
/**
|
||||
* 相角
|
||||
*/
|
||||
private Float angle;
|
||||
|
||||
/**
|
||||
* 状态:0-不启用 1-启用
|
||||
*/
|
||||
private Integer enable;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.njcn.gather.device.script.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
public interface IPqScriptDtlsService extends IService<PqScriptDtls> {
|
||||
|
||||
/**
|
||||
* 保存脚本详情
|
||||
*
|
||||
* @param pqScriptDtls 脚本详情
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean savePqScriptDtls(PqScriptDtls pqScriptDtls);
|
||||
|
||||
/**
|
||||
* 根据id删除脚本详情
|
||||
*
|
||||
* @param ids 脚本详情ids
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean deletePqScriptDtlsByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据脚本id删除脚本详情
|
||||
*
|
||||
* @param scriptIds 脚本id
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean deletePqScriptDtlsByScriptId(List<String> scriptIds);
|
||||
|
||||
/**
|
||||
* 修改脚本详情
|
||||
*
|
||||
* @param pqScriptDtls 脚本详情
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean updatePqScriptDtls(PqScriptDtls pqScriptDtls);
|
||||
|
||||
/**
|
||||
* 根据脚本id查询脚本详情
|
||||
*
|
||||
* @param scriptId 脚本id
|
||||
* @return 脚本详情列表
|
||||
*/
|
||||
List<PqScriptDtls> listPqScriptDtlByScriptId(String scriptId);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.njcn.gather.device.script.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptParam;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
public interface IPqScriptService extends IService<PqScript> {
|
||||
|
||||
/**
|
||||
* 分页查询检测脚本
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return
|
||||
*/
|
||||
Page<PqScript> listPqScript(PqScriptParam.QueryParam param);
|
||||
|
||||
/**
|
||||
* 新增检测脚本
|
||||
*
|
||||
* @param param 检测脚本
|
||||
* @return 成功返回true, 失败返回false
|
||||
*/
|
||||
boolean addPqScript(PqScriptParam param);
|
||||
|
||||
/**
|
||||
* 删除检测脚本
|
||||
*
|
||||
* @param param 检测脚本id
|
||||
* @return 成功返回true, 失败返回false
|
||||
*/
|
||||
boolean updatePqScript(PqScriptParam.UpdateParam param);
|
||||
|
||||
/**
|
||||
* 批量删除检测脚本
|
||||
*
|
||||
* @param ids 检测脚本id列表
|
||||
* @return 成功返回true, 失败返回false
|
||||
*/
|
||||
boolean deletePqScript(List<String> ids);
|
||||
|
||||
/**
|
||||
* 将脚本升级为模板
|
||||
* @param id 脚本id
|
||||
* @return 成功返回true, 失败返回false
|
||||
*/
|
||||
boolean upgradeToTemplate(String id);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.njcn.gather.device.script.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.gather.device.script.mapper.PqScriptDtlsMapper;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqScriptDtls> implements IPqScriptDtlsService {
|
||||
|
||||
@Override
|
||||
public boolean savePqScriptDtls(PqScriptDtls pqScriptDtls) {
|
||||
return this.save(pqScriptDtls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqScriptDtlsByIds(List<String> ids) {
|
||||
LambdaQueryWrapper<PqScriptDtls> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(PqScriptDtls::getId, ids);
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqScriptDtlsByScriptId(List<String> scriptIds) {
|
||||
LambdaQueryWrapper<PqScriptDtls> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(PqScriptDtls::getScriptId, scriptIds);
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePqScriptDtls(PqScriptDtls pqScriptDtls) {
|
||||
return this.updateById(pqScriptDtls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqScriptDtls> listPqScriptDtlByScriptId(String scriptId) {
|
||||
MPJLambdaWrapper<PqScriptDtls> queryWrapper = new MPJLambdaWrapper<>();
|
||||
queryWrapper.selectAll(PqScriptDtls.class)
|
||||
.leftJoin(PqScript.class, PqScript::getId, PqScriptDtls::getScriptId)
|
||||
.eq(PqScript::getState, DataStateEnum.ENABLE.getCode())
|
||||
.eq(PqScriptDtls::getScriptId, scriptId);
|
||||
return this.getBaseMapper().selectJoinList(PqScriptDtls.class, queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.njcn.gather.device.script.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
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.gather.device.script.mapper.PqScriptMapper;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptParam;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.device.script.service.IPqScriptService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> implements IPqScriptService {
|
||||
|
||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||
private final IDictDataService dictDataService;
|
||||
|
||||
@Override
|
||||
public Page<PqScript> listPqScript(PqScriptParam.QueryParam param) {
|
||||
QueryWrapper<PqScript> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(param)) {
|
||||
queryWrapper.like(StrUtil.isNotBlank(param.getName()), "pq_script.name", param.getName())
|
||||
.eq(StrUtil.isNotBlank(param.getType()), "pq_script.type", param.getType())
|
||||
.eq(StrUtil.isNotBlank(param.getValueType()), "pq_script.Value_Type", param.getValueType());
|
||||
}
|
||||
queryWrapper.eq("pq_script.state", DataStateEnum.ENABLE.getCode()).orderByAsc("pq_script.create_time");
|
||||
return this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPqScript(PqScriptParam param) {
|
||||
PqScript pqScript = new PqScript();
|
||||
BeanUtils.copyProperties(param, pqScript);
|
||||
pqScript.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(pqScript);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePqScript(PqScriptParam.UpdateParam param) {
|
||||
PqScript pqScript = new PqScript();
|
||||
BeanUtils.copyProperties(param, pqScript);
|
||||
pqScript.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.updateById(pqScript);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqScript(List<String> ids) {
|
||||
//删除对应的脚本详情
|
||||
pqScriptDtlsService.deletePqScriptDtlsByScriptId(ids);
|
||||
LambdaUpdateWrapper<PqScript> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(PqScript::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(PqScript::getId, ids);
|
||||
return this.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean upgradeToTemplate(String id) {
|
||||
PqScript pqScript = this.lambdaQuery().eq(PqScript::getId, id).one();
|
||||
if (pqScript != null) {
|
||||
pqScript.setType(1);
|
||||
return this.updateById(pqScript);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user