Browse Source

# 根据设备项目获取巡检项目以及巡检内容接口

zhongwei
haungxing 1 year ago
parent
commit
0917b88829
  1. 4
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/ContentEntity.java
  2. 16
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/feign/IProjectClient.java
  3. 28
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/vo/ProjectVO.java
  4. 26
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/wrapper/ProjectWrapper.java
  5. 14
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/feign/ProjectClient.java
  6. 12
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/ProjectService.java
  7. 36
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ProjectServiceImpl.java
  8. 26
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ContentDefinitionController.java
  9. 10
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java

4
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/entity/ContentEntity.java

@ -1,8 +1,10 @@
package com.hnac.hzinfo.inspect.obj.entity;
import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.hnac.hzinfo.inspect.utils.QueryField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -44,11 +46,13 @@ public class ContentEntity extends TenantEntity {
* 记录类型 0不记录 1仅选择 2仅记值 3选择并记值
*/
@ApiModelProperty(value = "记录类型 0不记录 1仅选择 2仅记值 3选择并记值")
@QueryField(condition = SqlCondition.EQUAL)
private String recordType;
/**
* 检测类型
*/
@ApiModelProperty(value = "检测类型")
@QueryField(condition = SqlCondition.EQUAL)
private String checkType;
/**

16
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/feign/IProjectClient.java

@ -1,14 +1,19 @@
package com.hnac.hzinfo.inspect.obj.feign;
import com.hnac.hzinfo.inspect.Constants;
import com.hnac.hzinfo.inspect.obj.dto.ContentDTO;
import com.hnac.hzinfo.inspect.obj.dto.ProjectDTO;
import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity;
import com.hnac.hzinfo.inspect.obj.vo.ProjectVO;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
@FeignClient(value = Constants.APP_NAME)
@ -16,6 +21,7 @@ public interface IProjectClient {
String API_PREFIX = "/feign/project";
String ADD_PROJECT_AND_CONTENT = API_PREFIX + "/addProjectAndContent";
String GET_PROJECT_AND_CONTENT_BY_EM_CODE = API_PREFIX + "/getProjectAndContentByEmCode";
/**
@ -26,4 +32,14 @@ public interface IProjectClient {
@PostMapping(ADD_PROJECT_AND_CONTENT)
R<Boolean> addProjectAndContent(@RequestBody @Valid List<ProjectDTO> request);
/**
*
* @param emCode 设备名称
* @param content namerecordTypecheckType
* @param query 分页
* @return
*/
@GetMapping(GET_PROJECT_AND_CONTENT_BY_EM_CODE)
R<ProjectVO> getProjectAndContentByEmCode(@NotNull @Valid String emCode, ContentDTO content, Query query);
}

28
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/vo/ProjectVO.java

@ -0,0 +1,28 @@
package com.hnac.hzinfo.inspect.obj.vo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzinfo.inspect.obj.dto.ProjectDTO;
import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* @ClassName ProjectVO
* @description:
* @author: hx
* @create: 2023-07-07 09:28
* @Version 4.0
**/
@ApiModel("项目VO对象")
@Data
@EqualsAndHashCode
public class ProjectVO extends ProjectEntity {
@ApiModelProperty("巡检内容列表")
private IPage<ContentVO> contentList;
}

26
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/obj/wrapper/ProjectWrapper.java

@ -0,0 +1,26 @@
package com.hnac.hzinfo.inspect.obj.wrapper;
import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity;
import com.hnac.hzinfo.inspect.obj.vo.ProjectVO;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
/**
* @ClassName ProjectWrapper
* @description:
* @author: hx
* @create: 2023-07-07 11:03
* @Version 4.0
**/
public class ProjectWrapper extends BaseEntityWrapper<ProjectEntity, ProjectVO> {
public static ProjectWrapper build() {
return new ProjectWrapper();
}
@Override
public ProjectVO entityVO(ProjectEntity entity) {
ProjectVO projectVO = BeanUtil.copy(entity, ProjectVO.class);
return projectVO;
}
}

14
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/feign/ProjectClient.java

@ -1,16 +1,23 @@
package com.hnac.hzinfo.inspect.obj.feign;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzinfo.inspect.obj.dto.ContentDTO;
import com.hnac.hzinfo.inspect.obj.dto.ProjectDTO;
import com.hnac.hzinfo.inspect.obj.services.ProjectService;
import com.hnac.hzinfo.inspect.obj.vo.ProjectVO;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
@ -32,4 +39,11 @@ public class ProjectClient extends BladeController implements IProjectClient {
public R<Boolean> addProjectAndContent(@RequestBody @Valid List<ProjectDTO> request) {
return R.data(projectService.addProjectAndContent(request));
}
@Override
@GetMapping(GET_PROJECT_AND_CONTENT_BY_EM_CODE)
public R<ProjectVO> getProjectAndContentByEmCode(@NotNull @Valid String emCode, ContentDTO content, Query query) {
return R.data(projectService.getProjectAndContentByEmCode(emCode,content,query));
}
}

12
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/ProjectService.java

@ -3,11 +3,14 @@ package com.hnac.hzinfo.inspect.obj.services;
import java.util.List;
import com.hnac.hzinfo.inspect.obj.dto.ContentDTO;
import com.hnac.hzinfo.inspect.obj.dto.ProjectDTO;
import com.hnac.hzinfo.inspect.obj.vo.ProjectOfflineVO;
import com.hnac.hzinfo.inspect.obj.vo.ProjectVO;
import org.springblade.core.mp.base.BaseService;
import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity;
import org.springblade.core.mp.support.Query;
/**
* 巡检项目service
@ -29,4 +32,13 @@ public interface ProjectService extends BaseService<ProjectEntity>{
* @return
*/
Boolean addProjectAndContent(List<ProjectDTO> request);
/**
* 根据设备编号获取项目以及内容列表分页展示
* @param emCode 设备编号
* @param content 巡检内容查询条件
* @param query 巡检内容分页查询条件
* @return
*/
ProjectVO getProjectAndContentByEmCode(String emCode, ContentDTO content, Query query);
}

36
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/services/impl/ProjectServiceImpl.java

@ -3,7 +3,8 @@ package com.hnac.hzinfo.inspect.obj.services.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzinfo.inspect.Constants;
import com.hnac.hzinfo.inspect.obj.ObjectConstants;
import com.hnac.hzinfo.inspect.obj.dto.ContentDTO;
@ -17,11 +18,15 @@ import com.hnac.hzinfo.inspect.obj.services.ProjectContentService;
import com.hnac.hzinfo.inspect.obj.services.ProjectService;
import com.hnac.hzinfo.inspect.obj.utils.CodeUtils;
import com.hnac.hzinfo.inspect.obj.vo.ProjectOfflineVO;
import com.hnac.hzinfo.inspect.obj.vo.ProjectVO;
import com.hnac.hzinfo.inspect.obj.wrapper.ContentWrapper;
import com.hnac.hzinfo.inspect.obj.wrapper.ProjectWrapper;
import com.hnac.hzinfo.inspect.utils.Condition;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.*;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
@ -40,6 +45,7 @@ import java.util.stream.Stream;
public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, ProjectEntity> implements ProjectService {
private final ContentService contentService;
//private final ProjectContentService projectContentService;
@Override
public boolean save(ProjectEntity entity) {
@ -96,4 +102,32 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectMapper, ProjectEn
});
return true;
}
@Override
public ProjectVO getProjectAndContentByEmCode(String emCode, ContentDTO content, Query query) {
LambdaQueryWrapper<ProjectEntity> queryWrapper = Wrappers.<ProjectEntity>lambdaQuery()
.eq(ProjectEntity::getEmCode, emCode)
.eq(ProjectEntity::getStatus, ObjectConstants.ProjectEnableEnum.YES.getEnableType());
// 根据设备编号获取项目
ProjectEntity project = this.getOne(queryWrapper);
if(Func.isNotEmpty(project)) {
ProjectVO projectVO = ProjectWrapper.build().entityVO(project);
// 获取巡检项目下的巡检内容
LambdaQueryWrapper<ProjectContentEntity> projectContentQuery = Wrappers.<ProjectContentEntity>lambdaQuery()
.select(ProjectContentEntity::getContentId)
.eq(ProjectContentEntity::getProjectId, project.getId());
ProjectContentService projectContentService = SpringUtil.getBean(ProjectContentServiceImpl.class);
List<ProjectContentEntity> projectContentList = projectContentService.list(projectContentQuery);
if(CollectionUtil.isNotEmpty(projectContentList)) {
List<Long> contentIdList = projectContentList.stream().map(ProjectContentEntity::getContentId).collect(Collectors.toList());
LambdaQueryWrapper<ContentEntity> wrapper = Condition.getQueryWrapper(BeanUtil.copy(content,ContentEntity.class)).lambda();
wrapper.in(CollectionUtil.isNotEmpty(contentIdList),ContentEntity::getId, contentIdList);
IPage page = contentService.page(Condition.getPage(query), wrapper);
page.setRecords(ContentWrapper.build().listVO(page.getRecords()));
projectVO.setContentList(page);
}
return projectVO;
}
return null;
}
}

26
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ContentDefinitionController.java

@ -18,10 +18,9 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
@ -56,4 +55,25 @@ public class ContentDefinitionController extends BladeController {
lambda.last("limit 1,50;");
return R.data(ContentDefinitionWrapper.build().listVO(contentDefinitionService.list(lambda)));
}
@GetMapping("/save")
@ApiOperation("保存巡检内容定义")
@ApiOperationSupport(order = 3)
public R save(@RequestBody @Valid ContentDefinitionDTO content) {
return R.status(contentDefinitionService.save(BeanUtil.copy(content,ContentDefinitionEntity.class)));
}
@PutMapping("/update")
@ApiOperation("更新巡检内容定义")
@ApiOperationSupport(order = 4)
public R update(@RequestBody ContentDefinitionDTO content) {
return R.status(contentDefinitionService.updateById(BeanUtil.copy(content,ContentDefinitionEntity.class)));
}
@PutMapping("/removeByIds")
@ApiOperation("根据ID删除")
@ApiOperationSupport(order = 5)
public R removeByIds(@RequestParam String ids) {
return R.status(contentDefinitionService.removeByIds(Func.toLongList(",",ids)));
}
}

10
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/web/ProjectController.java

@ -8,6 +8,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
import com.hnac.hzims.common.logs.enums.BusinessType;
import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzinfo.inspect.obj.dto.ContentDTO;
import com.hnac.hzinfo.inspect.obj.entity.ProjectContentEntity;
import com.hnac.hzinfo.inspect.obj.entity.ProjectEntity;
import com.hnac.hzinfo.inspect.obj.entity.TemplateProjectEntity;
@ -16,6 +17,7 @@ import com.hnac.hzinfo.inspect.obj.services.TemplateProjectService;
import com.hnac.hzinfo.inspect.obj.services.impl.ProjectContentServiceImpl;
import com.hnac.hzinfo.inspect.obj.utils.CodeUtils;
import com.hnac.hzinfo.inspect.obj.vo.ProjectListQueryVO;
import com.hnac.hzinfo.inspect.obj.vo.ProjectVO;
import com.hnac.hzinfo.inspect.utils.Condition;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -31,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.stream.Collectors;
@ -147,4 +150,11 @@ public class ProjectController {
projectContentService.databaseCopyBatch(Func.toLongList(ids), pre);
return R.success("操作成功");
}
@GetMapping("/getProjectAndContentByEmCode")
@ApiOperation(value = "根据设备编号获取项目以及内容列表(分页展示)")
@ApiOperationSupport(order = 7)
public R<ProjectVO> getProjectAndContentByEmCode(@NotNull @Valid String emCode, ContentDTO content, Query query) {
return R.data(projectService.getProjectAndContentByEmCode(emCode,content,query));
}
}

Loading…
Cancel
Save