Compare commits

...

2 Commits

26 changed files with 1522 additions and 9 deletions

View File

@ -188,4 +188,7 @@ public interface ErrorCodeConstants {
ErrorCode GATEWAY_CARD_INFO_NOT_EXISTS = new ErrorCode(1_002_030_003, "机床网关采集卡不存在");
ErrorCode GATEWAY_CARD_PARAMS_NOT_EXISTS = new ErrorCode(1_002_030_004, "机床网关参数不存在");
// ========== 点检管理模块 ==========
ErrorCode INSPECTION_PLAN_NOT_EXISTS = new ErrorCode(1_002_031_001, "点检方案不存在");
}

View File

@ -9,10 +9,8 @@ import com.inspur.module.system.constant.JudgeConstant;
import com.inspur.module.system.controller.admin.alarm.vo.AlarmDataSaveReqVO;
import com.inspur.module.system.controller.admin.alarm.vo.EquipAlarmDataSaveReqVO;
import com.inspur.module.system.controller.equip.vo.EquipInfoSaveReqVO;
import com.inspur.module.system.dal.dataobject.alarm.AlarmDataDO;
import com.inspur.module.system.dal.dataobject.alarm.AlarmDataDTO;
import com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDO;
import com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDTO;
import com.inspur.module.system.dal.dataobject.alarm.*;
import com.inspur.module.system.dal.dataobject.equip.EquipInfoDO;
import com.inspur.module.system.service.alarm.AlarmDataService;
import com.inspur.module.system.service.alarm.AlarmRulesService;
import com.inspur.module.system.service.alarm.EquipAlarmDataService;
@ -23,6 +21,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@ -49,14 +48,29 @@ public class AlarmRulesApiImpl implements AlarmRulesApi{
@Resource
private EquipInfoService equipInfoService;
@PostConstruct
@TenantIgnore
public void init() {
List<EquipInfoDO> equipInfoList = equipInfoService.getAllEquipInfoList();
for (EquipInfoDO equipInfoDO : equipInfoList) {
if(Boolean.TRUE.equals(stringRedisTemplate.hasKey("alarmRule-" + equipInfoDO.getEquipId()))){
stringRedisTemplate.delete("alarmRule-" + equipInfoDO.getEquipId());
}
List<AlarmRulesDTO> alarmRuleList = alarmRulesService.getAlarmRulesListByEquipId(equipInfoDO.getEquipId());
if(!alarmRuleList.isEmpty()) {
stringRedisTemplate.opsForValue().set("alarmRule-" + equipInfoDO.getEquipId(), JsonUtils.toJsonString(alarmRuleList));
}
}
}
@Override
@TenantIgnore
public List<AlarmRulesRespDTO> selectAlarmRulesListByCatch(String equipId) {
List<AlarmRulesRespDTO> alarmRules = JsonUtils.parseArray(stringRedisTemplate.opsForValue().get(equipId),AlarmRulesRespDTO.class);
List<AlarmRulesRespDTO> alarmRules = JsonUtils.parseArray(stringRedisTemplate.opsForValue().get("alarmRule-" + equipId),AlarmRulesRespDTO.class);
if(alarmRules == null || alarmRules.size() == 0){
alarmRules = BeanUtils.toBean(alarmRulesService.getAlarmRulesListByEquipId(equipId), AlarmRulesRespDTO.class);
stringRedisTemplate.opsForValue().set(equipId, JsonUtils.toJsonString(alarmRules));
stringRedisTemplate.opsForValue().set("alarmRule-" + equipId, JsonUtils.toJsonString(alarmRules));
}
return alarmRules ;
}

View File

@ -0,0 +1,113 @@
package com.inspur.module.system.controller.admin.inspection;
/**
* @Author zhangjunwen
* @create 2024/10/21
*/
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.inspur.framework.common.pojo.PageParam;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.CommonResult;
import com.inspur.framework.common.util.object.BeanUtils;
import static com.inspur.framework.common.pojo.CommonResult.success;
import com.inspur.framework.excel.core.util.ExcelUtils;
import com.inspur.framework.apilog.core.annotation.ApiAccessLog;
import static com.inspur.framework.apilog.core.enums.OperateTypeEnum.*;
import com.inspur.module.system.controller.admin.inspection.vo.*;
import com.inspur.module.system.dal.dataobject.inspection.InspectionPlanDO;
import com.inspur.module.system.service.inspection.InspectionPlanService;
@Tag(name = "管理后台 - 点检方案")
@RestController
@RequestMapping("/imt/inspection-plan")
@Validated
public class InspectionPlanController {
@Resource
private InspectionPlanService inspectionPlanService;
@PostMapping("/create")
@Operation(summary = "创建点检方案")
@PreAuthorize("@ss.hasPermission('imt:inspection-plan:create')")
public CommonResult<Long> createInspectionPlan(@Valid @RequestBody InspectionPlanSaveReqVO createReqVO) {
return success(inspectionPlanService.createInspectionPlan(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新点检方案")
@PreAuthorize("@ss.hasPermission('imt:inspection-plan:update')")
public CommonResult<Boolean> updateInspectionPlan(@Valid @RequestBody InspectionPlanSaveReqVO updateReqVO) {
inspectionPlanService.updateInspectionPlan(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除点检方案")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('imt:inspection-plan:delete')")
public CommonResult<Boolean> deleteInspectionPlan(@RequestParam("id") Long id) {
inspectionPlanService.deleteInspectionPlan(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得点检方案")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('imt:inspection-plan:query')")
public CommonResult<InspectionPlanRespVO> getInspectionPlan(@RequestParam("id") Long id) {
InspectionPlanDO inspectionPlan = inspectionPlanService.getInspectionPlan(id);
return success(BeanUtils.toBean(inspectionPlan, InspectionPlanRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得点检方案分页")
@PreAuthorize("@ss.hasPermission('imt:inspection-plan:query')")
public CommonResult<PageResult<InspectionPlanRespVO>> getInspectionPlanPage(@Valid InspectionPlanPageReqVO pageReqVO) {
PageResult<InspectionPlanDO> pageResult = inspectionPlanService.getInspectionPlanPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, InspectionPlanRespVO.class));
}
@GetMapping("/list")
@Operation(summary = "获得点检方案列表")
@PreAuthorize("@ss.hasPermission('imt:inspection-plan:query')")
public CommonResult<List<InspectionPlanRespVO>> getInspectionPlanList(@Valid InspectionPlanListReqVO reqVO) {
List<InspectionPlanDO> list = inspectionPlanService.getInspectionPlanList(reqVO);
list.sort(Comparator.comparing(InspectionPlanDO::getSort));
return success(BeanUtils.toBean(list, InspectionPlanRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出点检方案 Excel")
@PreAuthorize("@ss.hasPermission('imt:inspection-plan:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportInspectionPlanExcel(@Valid InspectionPlanPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<InspectionPlanDO> list = inspectionPlanService.getInspectionPlanPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "点检方案.xls", "数据", InspectionPlanRespVO.class,
BeanUtils.toBean(list, InspectionPlanRespVO.class));
}
}

View File

@ -0,0 +1,18 @@
package com.inspur.module.system.controller.admin.inspection.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @Author zhangjunwen
* @create 2024/10/23
*/
@Schema(description = "管理后台 - 点检方案列表 Request VO")
@Data
public class InspectionPlanListReqVO {
@Schema(description = "点检方案名")
private String inspectionName;
@Schema(description = "点检方案状态")
private Integer status;
}

View File

@ -0,0 +1,46 @@
package com.inspur.module.system.controller.admin.inspection.vo;
/**
* @Author zhangjunwen
* @create 2024/10/21
*/
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.inspur.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.inspur.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 点检方案分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class InspectionPlanPageReqVO extends PageParam {
@Schema(description = "基础点检名", example = "芋艿")
private String inspectionName;
@Schema(description = "父基础点检方案id", example = "13336")
private Long parentInspectionId;
@Schema(description = "报警规则id", example = "15168")
private String alarmRulesId;
@Schema(description = "描述", example = "随便")
private String description;
@Schema(description = "状态01", example = "1")
private Integer status;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,56 @@
package com.inspur.module.system.controller.admin.inspection.vo;
/**
* @Author zhangjunwen
* @create 2024/10/21
*/
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 点检方案 Response VO")
@Data
@ExcelIgnoreUnannotated
public class InspectionPlanRespVO {
@Schema(description = "基础点检方案id", requiredMode = Schema.RequiredMode.REQUIRED, example = "9117")
@ExcelProperty("基础点检方案id")
private Long inspectionPlanId;
@Schema(description = "基础点检名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@ExcelProperty("基础点检名")
private String inspectionName;
@Schema(description = "父基础点检方案id", example = "13336")
@ExcelProperty("父基础点检方案id")
private Long parentInspectionId;
@Schema(description = "报警规则id", example = "15168")
@ExcelProperty("报警规则id")
private String alarmRulesId;
@Schema(description = "描述", example = "随便")
@ExcelProperty("描述")
private String description;
@Schema(description = "状态01", example = "1")
@ExcelProperty("状态01")
private Integer status;
@Schema(description = "排序")
@ExcelProperty("排序")
private Integer sort;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "点检方案级别")
@ExcelProperty("点检方案级别")
private Integer level;
}

View File

@ -0,0 +1,41 @@
package com.inspur.module.system.controller.admin.inspection.vo;
/**
* @Author zhangjunwen
* @create 2024/10/21
*/
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 点检方案新增/修改 Request VO")
@Data
public class InspectionPlanSaveReqVO {
@Schema(description = "基础点检方案id", requiredMode = Schema.RequiredMode.REQUIRED, example = "9117")
private Long inspectionPlanId;
@Schema(description = "基础点检名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@NotEmpty(message = "基础点检名不能为空")
private String inspectionName;
@Schema(description = "父基础点检方案id", example = "13336")
private Long parentInspectionId;
@Schema(description = "报警规则id", example = "15168")
private String alarmRulesId;
@Schema(description = "描述", example = "随便")
private String description;
@Schema(description = "状态01", example = "1")
private Integer status;
@Schema(description = "排序")
private Integer sort;
@Schema(description = "点检方案级别")
private Integer level;
}

View File

@ -88,4 +88,8 @@ public class AlarmDataDO extends BaseDO {
* 报警类型
*/
private Integer alarmType;
/**
* 租户编号
*/
private Long tenantId;
}

View File

@ -89,4 +89,8 @@ public class AlarmRulesDO extends BaseDO {
* 排序
*/
private Integer sort;
/**
* 租户编号
*/
private Long tenantId;
}

View File

@ -61,5 +61,8 @@ public class EquipAlarmDataDO extends BaseDO {
* 机床分析状态0正常1磨损中2磨损严重
*/
private Integer equipAnalyseStatus;
/**
* 租户编号
*/
private Long tenantId;
}

View File

@ -0,0 +1,70 @@
package com.inspur.module.system.dal.dataobject.inspection;
/**
* @Author zhangjunwen
* @create 2024/10/21
*/
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.inspur.framework.mybatis.core.dataobject.BaseDO;
/**
* 点检方案 DO
*
* @author 管理员
*/
@TableName("imt_inspection_plan")
@KeySequence("imt_inspection_plan_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class InspectionPlanDO extends BaseDO {
/**
* 基础点检方案id
*/
@TableId(type = IdType.ASSIGN_ID)
private Long inspectionPlanId;
/**
* 基础点检名
*/
private String inspectionName;
/**
* 父基础点检方案id
*/
private Long parentInspectionId;
/**
* 组级列表
*/
private String ancestors;
/**
* 报警规则id
*/
private String alarmRulesId;
/**
* 描述
*/
private String description;
/**
* 状态01
*/
private Integer status;
/**
* 排序
*/
private Integer sort;
/**
* 级别
*/
private Integer level;
}

View File

@ -121,4 +121,23 @@ public interface AlarmRulesMapper extends BaseMapperX<AlarmRulesDO> {
* 根据设备id查询报警规则
*/
List<AlarmRulesDO> getAlarmRulesListByEquipId(String equipId);
/**
* 获取所有设备报警规则
*/
default List<AlarmRulesDTO> getAllAlarmRulesDetailsList(){
return selectJoinList(AlarmRulesDTO.class,new MPJLambdaWrapperX<AlarmRulesDO>()
.selectAll(AlarmRulesDO.class)
.selectAs(EquipInfoDO::getEquipNo, AlarmRulesDTO::getEquipNo)
.selectAs(EquipInfoDO::getEquipName, AlarmRulesDTO::getEquipName)
.selectAs(ModelInfoDO::getModelName, AlarmRulesDTO::getModelName)
.selectAs(CustomerInfoDO::getCustomerName, AlarmRulesDTO::getCustomerName)
.selectAs(ComponentInfoDO::getComponentName, AlarmRulesDTO::getComponentName)
.leftJoin(EquipInfoDO.class, EquipInfoDO::getEquipId, AlarmRulesDO::getEquipId)
.leftJoin(ModelInfoDO.class, ModelInfoDO::getModelId, EquipInfoDO::getModelId)
.leftJoin(CustomerInfoDO.class, CustomerInfoDO::getCustomerId, EquipInfoDO::getCustomerId)
.leftJoin(ComponentInfoDO.class, ComponentInfoDO::getComponentId, AlarmRulesDO::getComponentId)
.eq(AlarmRulesDO::getStatus, 0)
);
}
}

View File

@ -0,0 +1,44 @@
package com.inspur.module.system.dal.mysql.inspection;
/**
* @Author zhangjunwen
* @create 2024/10/21
*/
import java.util.*;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.inspur.framework.mybatis.core.mapper.BaseMapperX;
import com.inspur.module.system.dal.dataobject.inspection.InspectionPlanDO;
import org.apache.ibatis.annotations.Mapper;
import com.inspur.module.system.controller.admin.inspection.vo.*;
/**
* 点检方案 Mapper
*
* @author 管理员
*/
@Mapper
public interface InspectionPlanMapper extends BaseMapperX<InspectionPlanDO> {
default PageResult<InspectionPlanDO> selectPage(InspectionPlanPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<InspectionPlanDO>()
.likeIfPresent(InspectionPlanDO::getInspectionName, reqVO.getInspectionName())
.eqIfPresent(InspectionPlanDO::getParentInspectionId, reqVO.getParentInspectionId())
.eqIfPresent(InspectionPlanDO::getAlarmRulesId, reqVO.getAlarmRulesId())
.eqIfPresent(InspectionPlanDO::getDescription, reqVO.getDescription())
.eqIfPresent(InspectionPlanDO::getStatus, reqVO.getStatus())
.eqIfPresent(InspectionPlanDO::getSort, reqVO.getSort())
.betweenIfPresent(InspectionPlanDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(InspectionPlanDO::getInspectionPlanId));
}
default List<InspectionPlanDO> selectList(InspectionPlanListReqVO reqVO){
return selectList(new LambdaQueryWrapperX<InspectionPlanDO>()
.likeIfPresent(InspectionPlanDO::getInspectionName, reqVO.getInspectionName())
.eqIfPresent(InspectionPlanDO::getStatus, reqVO.getStatus())
);
}
}

View File

@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inspur.framework.tenant.core.aop.TenantIgnore;
import com.inspur.module.system.dal.dataobject.alarm.AlarmDataDTO;
import com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDO;
import com.inspur.module.system.dal.dataobject.equip.EquipInfoDO;
import com.inspur.module.system.service.equip.EquipInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -41,10 +43,18 @@ public class AlarmDataServiceImpl implements AlarmDataService {
@Resource
private EquipAlarmDataService equipAlarmDataService;
@Resource
private EquipInfoService equipInfoService;
@Override
public Long createAlarmData(AlarmDataSaveReqVO createReqVO) {
// 插入
AlarmDataDO alarmData = BeanUtils.toBean(createReqVO, AlarmDataDO.class);
if(Objects.nonNull(alarmData.getEquipId())){
EquipInfoDO equipInfo = equipInfoService.getEquipInfo(alarmData.getEquipId());
Optional<Long> tenantIdOptional = Optional.ofNullable(equipInfo.getTenantId());
tenantIdOptional.ifPresent(alarmData::setTenantId);
}
alarmDataMapper.insert(alarmData);
// 返回
return alarmData.getAlarmDataId();

View File

@ -57,4 +57,9 @@ public interface AlarmRulesService {
* 根据设备id查询报警规则
*/
List<AlarmRulesDTO> getAlarmRulesListByEquipId(String equipId);
/**
* 获取所有报警规则
*/
List<AlarmRulesDTO> getAlarmRulesList();
}

View File

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inspur.framework.tenant.core.aop.TenantIgnore;
import com.inspur.module.system.dal.dataobject.alarm.AlarmRulesDTO;
import com.inspur.module.system.dal.dataobject.equip.EquipInfoDO;
import com.inspur.module.system.service.equip.EquipInfoService;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -17,6 +19,8 @@ import com.inspur.framework.common.util.object.BeanUtils;
import com.inspur.module.system.dal.mysql.alarm.AlarmRulesMapper;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import static com.inspur.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.inspur.module.system.enums.ErrorCodeConstants.*;
@ -36,11 +40,22 @@ public class AlarmRulesServiceImpl implements AlarmRulesService {
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private EquipInfoService equipInfoService;
@Override
public String createAlarmRules(AlarmRulesSaveReqVO createReqVO) {
// 插入
AlarmRulesDO alarmRules = BeanUtils.toBean(createReqVO, AlarmRulesDO.class);
alarmRules.setStatus(0);//默认开启
if(Objects.nonNull(alarmRules.getEquipId())){
EquipInfoDO equipInfo = equipInfoService.getEquipInfo(alarmRules.getEquipId());
Optional<Long> tenantIdOptional = Optional.ofNullable(equipInfo.getTenantId());
tenantIdOptional.ifPresent(alarmRules::setTenantId);
}
if(Boolean.TRUE.equals(stringRedisTemplate.hasKey("alarmRule-" + alarmRules.getEquipId()))){
stringRedisTemplate.delete("alarmRule-" + alarmRules.getEquipId());
}
alarmRulesMapper.insert(alarmRules);
stringRedisTemplate.delete(createReqVO.getEquipId());
// 返回
@ -69,7 +84,7 @@ public class AlarmRulesServiceImpl implements AlarmRulesService {
if (alarmRule == null) {
throw exception(ALARM_RULES_NOT_EXISTS);
}else{
stringRedisTemplate.delete(alarmRule.getEquipId());//更新或者删除时直接删除redis缓存
stringRedisTemplate.delete("alarmRule-" +alarmRule.getEquipId());//更新或者删除时直接删除redis缓存
}
}
@ -91,4 +106,13 @@ public class AlarmRulesServiceImpl implements AlarmRulesService {
public List<AlarmRulesDTO> getAlarmRulesListByEquipId(String equipId){
return alarmRulesMapper.getAlarmRulesDetailsListByEquipId(equipId);
}
/**
* 获取所有报警规则
*/
@Override
@TenantIgnore
public List<AlarmRulesDTO> getAlarmRulesList(){
return alarmRulesMapper.getAllAlarmRulesDetailsList();
}
}

View File

@ -8,8 +8,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inspur.framework.tenant.core.aop.TenantIgnore;
import com.inspur.module.system.dal.dataobject.alarm.AlarmRulesDO;
import com.inspur.module.system.dal.dataobject.alarm.EquipAlarmDataDTO;
import com.inspur.module.system.dal.dataobject.equip.EquipInfoDO;
import com.inspur.module.system.dal.dataobject.maintenance.MaintenanceOrderDO;
import com.inspur.module.system.dal.mysql.maintenance.MaintenanceOrderMapper;
import com.inspur.module.system.service.equip.EquipInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -45,10 +47,18 @@ public class EquipAlarmDataServiceImpl implements EquipAlarmDataService {
@Resource
private MaintenanceOrderMapper maintenanceOrderMapper;
@Resource
private EquipInfoService equipInfoService;
@Override
public String createEquipAlarmData(EquipAlarmDataSaveReqVO createReqVO) {
// 插入
EquipAlarmDataDO equipAlarmData = BeanUtils.toBean(createReqVO, EquipAlarmDataDO.class);
if(Objects.nonNull(equipAlarmData.getEquipId())){
EquipInfoDO equipInfo = equipInfoService.getEquipInfo(equipAlarmData.getEquipId());
Optional<Long> tenantIdOptional = Optional.ofNullable(equipInfo.getTenantId());
tenantIdOptional.ifPresent(equipAlarmData::setTenantId);
}
equipAlarmDataMapper.insert(equipAlarmData);
// 返回
return equipAlarmData.getEquipAlarmId();

View File

@ -80,4 +80,9 @@ public interface EquipInfoService {
*/
EquipInfoDetailsVO getEquipInfoDetailsById(String id);
/**
* 获取所有设备信息
*/
List<EquipInfoDO> getAllEquipInfoList();
}

View File

@ -196,4 +196,10 @@ public class EquipInfoServiceImpl implements EquipInfoService {
throw exception(ErrorCodeConstants.EQUIP_INFO_NOT_EXISTS);
}
/**
* 获取所有设备信息
*/
public List<EquipInfoDO> getAllEquipInfoList(){
return equipInfoMapper.selectList();
}
}

View File

@ -56,6 +56,9 @@ public class GatewayInfoServiceImpl implements GatewayInfoService {
List<GatewayInfoDetailsDTO> gatewayInfoList = getGatewayInfoList();
for (GatewayInfoDetailsDTO gatewayInfo : gatewayInfoList) {
if(Boolean.TRUE.equals(stringRedisTemplate.hasKey("cardmapping_" + gatewayInfo.getGatewayId()))){
stringRedisTemplate.delete("cardmapping_" + gatewayInfo.getGatewayId());
}
getGatewayCardAndParamByCatch(gatewayInfo.getGatewayId());
}
}

View File

@ -0,0 +1,70 @@
package com.inspur.module.system.service.inspection;
/**
* @Author zhangjunwen
* @create 2024/10/21
*/
import java.util.*;
import javax.validation.*;
import com.inspur.module.system.controller.admin.inspection.vo.*;
import com.inspur.module.system.dal.dataobject.inspection.InspectionPlanDO;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.PageParam;
/**
* 点检方案 Service 接口
*
* @author 管理员
*/
public interface InspectionPlanService {
/**
* 创建点检方案
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createInspectionPlan(@Valid InspectionPlanSaveReqVO createReqVO);
/**
* 更新点检方案
*
* @param updateReqVO 更新信息
*/
void updateInspectionPlan(@Valid InspectionPlanSaveReqVO updateReqVO);
/**
* 删除点检方案
*
* @param id 编号
*/
void deleteInspectionPlan(Long id);
/**
* 获得点检方案
*
* @param id 编号
* @return 点检方案
*/
InspectionPlanDO getInspectionPlan(Long id);
/**
* 获得点检方案分页
*
* @param pageReqVO 分页查询
* @return 点检方案分页
*/
PageResult<InspectionPlanDO> getInspectionPlanPage(InspectionPlanPageReqVO pageReqVO);
/**
* 获取最大的点检方案的id
*/
Long getMaxInspectionPlanId();
/**
* 获取点检方案列表
*/
List<InspectionPlanDO> getInspectionPlanList(InspectionPlanListReqVO reqVO);
}

View File

@ -0,0 +1,109 @@
package com.inspur.module.system.service.inspection;
/**
* @Author zhangjunwen
* @create 2024/10/21
*/
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.inspur.module.system.controller.admin.inspection.vo.*;
import com.inspur.module.system.dal.dataobject.inspection.InspectionPlanDO;
import com.inspur.framework.common.pojo.PageResult;
import com.inspur.framework.common.pojo.PageParam;
import com.inspur.framework.common.util.object.BeanUtils;
import com.inspur.module.system.dal.mysql.inspection.InspectionPlanMapper;
import static com.inspur.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.inspur.module.system.enums.ErrorCodeConstants.*;
/**
* 点检方案 Service 实现类
*
* @author 管理员
*/
@Service
@Validated
public class InspectionPlanServiceImpl implements InspectionPlanService {
@Resource
private InspectionPlanMapper inspectionPlanMapper;
@Override
public Long createInspectionPlan(InspectionPlanSaveReqVO createReqVO) {
// 插入
InspectionPlanDO inspectionPlan = BeanUtils.toBean(createReqVO, InspectionPlanDO.class);
if(inspectionPlan.getParentInspectionId() == 0){
inspectionPlan.setAncestors("0");
inspectionPlan.setLevel(1);
}else{
InspectionPlanDO parentInspectionPlan = inspectionPlanMapper.selectById(inspectionPlan.getParentInspectionId());
inspectionPlan.setAncestors(parentInspectionPlan.getAncestors()+","+parentInspectionPlan.getInspectionPlanId());
inspectionPlan.setLevel(parentInspectionPlan.getLevel()+1);
}
inspectionPlanMapper.insert(inspectionPlan);
// 返回
return inspectionPlan.getInspectionPlanId();
}
@Override
public void updateInspectionPlan(InspectionPlanSaveReqVO updateReqVO) {
// 校验存在
validateInspectionPlanExists(updateReqVO.getInspectionPlanId());
// 更新
InspectionPlanDO updateObj = BeanUtils.toBean(updateReqVO, InspectionPlanDO.class);
inspectionPlanMapper.updateById(updateObj);
}
@Override
public void deleteInspectionPlan(Long id) {
// 校验存在
validateInspectionPlanExists(id);
// 删除
inspectionPlanMapper.deleteById(id);
}
private void validateInspectionPlanExists(Long id) {
if (inspectionPlanMapper.selectById(id) == null) {
throw exception(INSPECTION_PLAN_NOT_EXISTS);
}
}
@Override
public InspectionPlanDO getInspectionPlan(Long id) {
return inspectionPlanMapper.selectById(id);
}
@Override
public PageResult<InspectionPlanDO> getInspectionPlanPage(InspectionPlanPageReqVO pageReqVO) {
return inspectionPlanMapper.selectPage(pageReqVO);
}
/**
* 获取最大的点检方案的id
*/
@Override
public Long getMaxInspectionPlanId(){
QueryWrapper<InspectionPlanDO> queryWrapper = new QueryWrapper<>();
queryWrapper.select("max(inspection_plan_id)");
return inspectionPlanMapper.selectOne(queryWrapper).getInspectionPlanId();
}
/**
* 获取点检方案列表
*/
@Override
public List<InspectionPlanDO> getInspectionPlanList(InspectionPlanListReqVO reqVO){
return inspectionPlanMapper.selectList(reqVO);
}
}

View File

@ -0,0 +1,70 @@
import request from "@/utils/request";
// 创建点检方案
export function createInspectionPlan(data) {
return request({
url: "/imt/inspection-plan/create",
method: "post",
data: data,
});
}
// 更新点检方案
export function updateInspectionPlan(data) {
return request({
url: "/imt/inspection-plan/update",
method: "put",
data: data,
});
}
// 删除点检方案
export function deleteInspectionPlan(id) {
return request({
url: "/imt/inspection-plan/delete?id=" + id,
method: "delete",
});
}
// 获得点检方案
export function getInspectionPlan(id) {
return request({
url: "/imt/inspection-plan/get?id=" + id,
method: "get",
});
}
// 获得点检方案分页
export function getInspectionPlanPage(params) {
return request({
url: "/imt/inspection-plan/page",
method: "get",
params,
});
}
// 导出点检方案 Excel
export function exportInspectionPlanExcel(params) {
return request({
url: "/imt/inspection-plan/export-excel",
method: "get",
params,
responseType: "blob",
});
}
//获取点检方案最大id
export function getMaxInspectionPlanId() {
return request({
url: "/imt/inspection-plan/maxId",
method: "get",
});
}
// 获得点检方案列表
export function getInspectionPlanList(params) {
return request({
url: "/imt/inspection-plan/list",
method: "get",
params,
});
}

View File

@ -0,0 +1,236 @@
<template>
<div class="app-container">
<!-- 对话框(添加 / 修改) -->
<el-dialog
:title="dialogTitle"
:visible.sync="dialogVisible"
width="45%"
v-dialogDrag
append-to-body
>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
v-loading="formLoading"
label-width="100px"
>
<el-col :span="24">
<el-form-item
v-if="this.formData.parentInspectionId != 0"
label="父节点点检方案"
prop="parentInspectionId"
>
<!-- <el-input
v-model="formData.parentInspectionId"
placeholder="请输入父基础点检方案id"
/> -->
<treeselect
v-model="formData.parentInspectionId"
:options="inspectionOptions"
:normalizer="normalizer"
:show-count="true"
placeholder="选择上级菜单"
/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item
label="基础点检名"
prop="inspectionName"
>
<el-input
v-model="formData.inspectionName"
placeholder="请输入基础点检名"
/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="描述">
<!-- <Editor
v-model="formData.description"
:min-height="192"
/> -->
<el-input
type="textarea"
:autosize="{ minRows: 5, maxRows: 10}"
placeholder="请输入点检方案描述"
v-model="formData.description"
>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="状态"
prop="status"
>
<el-radio-group v-model="formData.status">
<el-radio
v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
:key="dict.value"
:label="parseInt(dict.value)"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="排序"
prop="sort"
>
<el-input-number
v-model="formData.sort"
controls-position="right"
:min="0"
/>
</el-form-item>
</el-col>
</el-form>
<div
slot="footer"
class="dialog-footer"
>
<el-button
type="primary"
@click="submitForm"
:disabled="formLoading"
> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import * as InspectionPlanApi from "@/api/system/inspection/plan";
import { getDictDatas, DICT_TYPE } from "@/utils/dict";
import { CommonStatusEnum } from "@/utils/constants";
import Treeselect from "@riophae/vue-treeselect";
export default {
name: "InspectionPlanForm",
components: { Treeselect },
data() {
return {
//
dialogTitle: "",
//
dialogVisible: false,
// 12
formLoading: false,
//
formData: {
inspectionPlanId: undefined,
inspectionName: undefined,
parentInspectionId: undefined,
alarmRulesId: undefined,
description: undefined,
status: CommonStatusEnum.ENABLE,
sort: undefined,
},
//
formRules: {
inspectionName: [
{ required: true, message: "点检方案名不能为空", trigger: "blur" },
],
sort: [
{
required: true,
message: "排序不能为空",
trigger: "blur",
},
],
},
//
statusDictDatas: getDictDatas(DICT_TYPE.COMMON_STATUS),
pid: undefined,
inspectionOptions: [],
};
},
methods: {
getInspectionPlanTree() {
InspectionPlanApi.getInspectionPlanList().then((res) => {
this.inspectionOptions = [];
this.inspectionOptions = this.handleTree(
res.data,
"inspectionPlanId",
"parentInspectionId"
);
console.log("inspectionOptions:", this.inspectionOptions);
});
},
/** 转换菜单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.inspectionPlanId,
label: node.inspectionName,
children: node.children,
};
},
/** 打开弹窗 */
async open(id, pid) {
this.dialogVisible = true;
this.reset();
this.getInspectionPlanTree();
this.pid = pid;
//
if (id) {
this.formLoading = true;
try {
const res = await InspectionPlanApi.getInspectionPlan(id);
this.formData = res.data;
this.dialogTitle = "修改点检方案";
} finally {
this.formLoading = false;
}
}
this.dialogTitle = "新增点检方案";
this.$nextTick(() => {
this.formData.status = CommonStatusEnum.ENABLE;
this.formData.parentInspectionId = this.pid;
});
},
/** 提交按钮 */
async submitForm() {
//
await this.$refs["formRef"].validate();
this.formLoading = true;
try {
const data = this.formData;
//
if (data.inspectionPlanId) {
await InspectionPlanApi.updateInspectionPlan(data);
this.$modal.msgSuccess("修改成功");
this.dialogVisible = false;
this.$emit("success");
return;
}
console.log("新增表单:", this.formData);
//
await InspectionPlanApi.createInspectionPlan(data);
this.$modal.msgSuccess("新增成功");
this.dialogVisible = false;
this.$emit("success");
} finally {
this.formLoading = false;
}
},
/** 表单重置 */
reset() {
this.formData = {
inspectionPlanId: undefined,
inspectionName: undefined,
parentInspectionId: undefined,
alarmRulesId: undefined,
description: undefined,
status: undefined,
sort: undefined,
};
this.resetForm("formRef");
},
},
};
</script>

View File

@ -0,0 +1,281 @@
<template>
<div class="app-container">
<!-- 搜索工作栏 -->
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
style="text-align:right"
>
<el-form-item
label="父级点检方案名"
label-width="90px"
prop="inspectionName"
>
<el-input
v-model="queryParams.inspectionName"
placeholder="请输入辅机点检方案名"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item
label="状态"
prop="status"
>
<el-select
v-model="queryParams.status"
placeholder="菜单状态"
clearable
>
<el-option
v-for="dict in statusDictDatas"
:key="parseInt(dict.value)"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
@click="handleQuery"
>搜索</el-button>
<el-button
icon="el-icon-refresh"
@click="resetQuery"
>重置</el-button>
</el-form-item>
</el-form>
<!-- 操作工具栏 -->
<el-row
:gutter="10"
class="mb8"
>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="openForm(undefined,0)"
v-hasPermi="['imt:inspection-plan:create']"
>新增父节点</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-sort"
size="mini"
@click="toggleExpandAll"
>展开/折叠</el-button>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-table
v-if="refreshTable"
v-loading="loading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
row-key="inspectionPlanId"
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column
label="基础点检名"
align="center"
prop="inspectionName"
/>
<el-table-column
label="描述"
align="center"
prop="description"
/>
<el-table-column
label="状态"
align="center"
prop="status"
>
<template v-slot="scope">
<dict-tag
:type="DICT_TYPE.COMMON_STATUS"
:value="scope.row.status"
/>
</template>
</el-table-column>
<el-table-column
label="排序"
align="center"
prop="sort"
/>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template v-slot="scope">
<el-button
v-if="scope.row.level < 4"
size="mini"
type="text"
icon="el-icon-edit"
@click="openForm(undefined,scope.row.inspectionPlanId)"
v-hasPermi="['imt:inspection-plan:update']"
>新增子节点</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="openForm(scope.row.inspectionPlanId)"
v-hasPermi="['imt:inspection-plan:update']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['imt:inspection-plan:delete']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<!-- <pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/> -->
<!-- 对话框(添加 / 修改) -->
<InspectionPlanForm
ref="formRef"
@success="getList"
/>
</div>
</template>
<script>
import * as InspectionPlanApi from "@/api/system/inspection/plan";
import InspectionPlanForm from "./InspectionPlanForm.vue";
import { getDictDatas, DICT_TYPE } from "@/utils/dict";
export default {
name: "InspectionPlan",
components: {
InspectionPlanForm,
},
data() {
return {
//
loading: true,
//
exportLoading: false,
//
showSearch: true,
//
total: 0,
//
list: [],
//
isExpandAll: true,
//
refreshTable: true,
//
currentRow: {},
//
queryParams: {
inspectionName: null,
parentInspectionId: null,
alarmRulesId: null,
description: null,
status: null,
sort: null,
createTime: [],
},
//
refreshTable: true,
//
statusDictDatas: getDictDatas(DICT_TYPE.COMMON_STATUS),
};
},
created() {
this.getList();
},
methods: {
/** 展开/折叠操作 */
toggleExpandAll() {
this.refreshTable = false;
this.isExpandAll = !this.isExpandAll;
this.$nextTick(() => {
this.refreshTable = true;
});
},
/** 查询列表 */
async getList() {
try {
this.loading = true;
const res = await InspectionPlanApi.getInspectionPlanList(
this.queryParams
);
this.list = this.handleTree(
res.data,
"inspectionPlanId",
"parentInspectionId"
);
} finally {
this.loading = false;
}
},
/** 搜索按钮操作 */
handleQuery() {
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 添加/修改操作 */
openForm(id, pid) {
this.$refs["formRef"].open(id, pid);
},
/** 删除按钮操作 */
async handleDelete(row) {
const inspectionPlanId = row.inspectionPlanId;
await this.$modal.confirm(
'是否确认删除点检方案编号为"' + inspectionPlanId + '"的数据项?'
);
try {
await InspectionPlanApi.deleteInspectionPlan(inspectionPlanId);
await this.getList();
this.$modal.msgSuccess("删除成功");
} catch {}
},
/** 导出按钮操作 */
async handleExport() {
await this.$modal.confirm("是否确认导出所有点检方案数据项?");
try {
this.exportLoading = true;
const data = await InspectionPlanApi.exportInspectionPlanExcel(
this.queryParams
);
this.$download.excel(data, "点检方案.xls");
} catch {
} finally {
this.exportLoading = false;
}
},
},
};
</script>

View File

@ -0,0 +1,249 @@
<template>
<div class="app-container">
<el-form
:model="planForm"
ref="planForm"
:rules="rules"
:inline="false"
size="small"
>
<el-table
:data="planForm.tableData"
style="width: 100%;margin-bottom: 20px;"
row-key="id"
border
default-expand-all
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column
prop="inspectionName"
label="点检方案名称"
align="center"
>
<template slot-scope="scope">
<el-form-item
:prop="'tableData['+scope.$index+'].inspectionName'"
:rules="rules.inspectionName"
>
<el-input
size="small"
v-model="scope.row.inspectionName"
placeholder="请输入点检方案名"
:maxlength="100"
show-word-limit
></el-input>
</el-form-item>
</template>
</el-table-column>
<el-table-column
prop="description"
label="描述"
align="center"
>
<template slot-scope="scope">
<el-form-item
:prop="'tableData['+scope.$index+'].description'"
:rules="rules.description"
>
<el-input
size="small"
v-model="scope.row.description"
placeholder="请输入点检方案描述"
:maxlength="200"
show-word-limit
></el-input>
</el-form-item>
</template>
</el-table-column>
<el-table-column
prop="status"
label="状态"
align="center"
>
<template v-slot="scope">
<el-form-item
:prop="'tableData['+scope.$index+'].status'"
:rules="rules.status"
>
<el-switch
v-model="scope.row.status"
active-color="#13ce66"
inactive-color="#ff4949"
:active-value="0"
:inactive-value="1"
active-text="开"
inactive-text="关"
></el-switch>
</el-form-item>
</template>
</el-table-column>
<el-table-column
prop="sort"
label="显示排序"
align="center"
>
<template v-slot="scope">
<el-form-item
:prop="'tableData['+scope.$index+'].sort'"
:rules="rules.sort"
>
<el-input-number
v-model="scope.row.sort"
controls-position="right"
:min="0"
/>
</el-form-item>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
>
<template slot-scope="scope">
<!-- <el-button
v-if="(scope.row.level && Number(scope.row.level) < 4)"
size="mini"
type="text"
@click.native.prevent="addChild(scope.row)"
>设置子字段</el-button> -->
<el-button
size="mini"
type="text"
@click.native.prevent="saveInspectionPlan(scope.row)"
>保存</el-button>
<el-button
size="mini"
type="text"
@click.native.prevent="addChild(scope.row)"
>设置子节点</el-button>
<el-button
size="mini"
type="text"
@click.native.prevent="deleteRow(scope.row, scope.$index)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
<el-button
type="primary"
icon="el-icon-plus"
size="mini"
@click.native.prevent="addNew"
>新增</el-button>
</div>
</template>
<script>
import * as InspectionPlanApi from "@/api/system/inspection/plan";
export default {
name: "InspectionPlan",
components: {},
data() {
return {
//
loading: true,
//
exportLoading: false,
//
showSearch: true,
//
total: 0,
//
rules: {
inspectionName: [
{
required: true,
message: "点检方案名不能为空",
trigger: "blur",
},
],
sort: [
{
required: true,
message: "显示排序不能为空",
trigger: "blur",
},
],
},
//
planForm: {
tableData: [],
},
idx: null,
};
},
created() {},
methods: {
async saveInspectionPlan(row) {
console.log("保存的内容:", row);
await this.$refs["planForm"].validate();
let id = await InspectionPlanApi.createInspectionPlan(row);
},
addChild(row) {
if (!row.inspectionPlanId) {
this.$message({
message: "请先保存父节点再添加子节点",
type: "warning",
});
}
this.addRow(1, row); //children
},
addNew() {
this.addRow(); //
},
addRow(type, row) {
// type-0- type-1-
let pid = type ? null : 0;
let newObj = {
id: null,
parentInspectionId: pid, //id
inspectionName: "",
description: "",
status: 0,
children: [],
};
if (type) {
if (!row.children) {
row.children = [];
}
row.children.push(newObj);
} else {
this.planForm.tableData.push(newObj);
}
},
//
deleteRow(row, i) {
if (row.pid) {
// children
this.deleteChildByid(this.tableData, row.pid, row.id);
} else {
let fid = this.tableData.findIndex((v) => {
return v.id == row.id;
});
this.tableData.splice(fid, 1);
}
},
deleteChildByid(arr, pid, id) {
let that = this;
arr.forEach((v, i) => {
if (v.id == pid) {
let item = v.children;
this.idx = item.findIndex((p) => p.id === id);
item.splice(this.idx, 1);
} else {
if (v.children && v.children.length > 0) {
that.deleteChildByid(v.children, pid, id);
}
}
});
},
},
};
</script>
<style scoped>
/* ::v-deep .el-form-item {
margin-bottom: auto;
} */
</style>