From 8fa660d19c6cf0bb6e7c515d92d7a38463967e65 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 9 Apr 2024 11:20:33 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E4=BD=9C=E4=B8=9A=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E8=B4=9F=E8=B4=A3=E4=BA=BA=E5=90=8D=E7=A7=B0=E5=92=8C?= =?UTF-8?q?=E5=88=86=E7=AE=A1=E9=A2=86=E5=AF=BC=E5=90=8D=E7=A7=B0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/risk/vo/HazardWorkVO.java | 23 +++++++++++ .../risk/controller/HazardWorkController.java | 10 ++--- .../risk/service/HazardWorkService.java | 12 +++++- .../risk/service/impl/HazardWorkServiceImpl.java | 47 +++++++++++++++++++++- 4 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/risk/vo/HazardWorkVO.java diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/risk/vo/HazardWorkVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/risk/vo/HazardWorkVO.java new file mode 100644 index 0000000..6d6312b --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/risk/vo/HazardWorkVO.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.safeproduct.risk.vo; + +import com.hnac.hzims.safeproduct.risk.entity.HazardWork; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author liwen + * @date 2024-04-09 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "作业区域管理页面VO类") +public class HazardWorkVO extends HazardWork { + + @ApiModelProperty("负责人名称") + private String headName; + + @ApiModelProperty("分管领导名称") + private String managerName; +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/controller/HazardWorkController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/controller/HazardWorkController.java index cad2485..4203b1b 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/controller/HazardWorkController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/controller/HazardWorkController.java @@ -1,11 +1,10 @@ package com.hnac.hzims.safeproduct.risk.controller; - import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.safeproduct.risk.dto.CorrelationDTO; import com.hnac.hzims.safeproduct.risk.entity.HazardWork; import com.hnac.hzims.safeproduct.risk.service.HazardWorkService; +import com.hnac.hzims.safeproduct.risk.vo.HazardWorkVO; import com.hnac.hzims.safeproduct.risk.vo.PersonalCheckItemVO; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -68,15 +67,16 @@ public class HazardWorkController { return R.data(service.getById(id)); } - /** * 分页 */ @GetMapping("/pageList") @ApiOperationSupport(order = 60) @ApiOperation(value = "分页", notes = "查询条件:item") - public R> page(HazardWork entity, Query query) { - return R.data(service.page(Condition.getPage(query),Condition.getQueryWrapper(entity))); + public R> page(HazardWork entity, Query query) { + IPage page = service.getHazardWorkPage(entity, query); + return R.data(page); +// return R.data(service.page(Condition.getPage(query),Condition.getQueryWrapper(entity))); } @GetMapping("/getCheckItemByDutyPerson") diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/HazardWorkService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/HazardWorkService.java index 35cfefa..545d6d3 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/HazardWorkService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/HazardWorkService.java @@ -1,9 +1,11 @@ package com.hnac.hzims.safeproduct.risk.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.safeproduct.risk.entity.HazardWork; +import com.hnac.hzims.safeproduct.risk.vo.HazardWorkVO; import com.hnac.hzims.safeproduct.risk.vo.PersonalCheckItemVO; -import com.hnac.hzims.safeproduct.risk.vo.StationRiskLevelVo; import org.springblade.core.mp.base.BaseService; +import org.springblade.core.mp.support.Query; import java.util.List; @@ -15,4 +17,12 @@ public interface HazardWorkService extends BaseService { boolean deleteBacth(List workIds); List getCheckItemByDutyPerson(Long userId,Long categoryId); + + /** + * 查询作业区域页面数据 + * @param entity 入参 + * @param query 分页类 + * @return 作业区域页面 + */ + IPage getHazardWorkPage(HazardWork entity, Query query); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardWorkServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardWorkServiceImpl.java index f013a4f..5941240 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardWorkServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/risk/service/impl/HazardWorkServiceImpl.java @@ -1,6 +1,8 @@ package com.hnac.hzims.safeproduct.risk.service.impl; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.safeproduct.risk.entity.Correlation; import com.hnac.hzims.safeproduct.risk.entity.HazardCategory; import com.hnac.hzims.safeproduct.risk.entity.HazardSource; @@ -10,18 +12,23 @@ import com.hnac.hzims.safeproduct.risk.service.CorrelationService; import com.hnac.hzims.safeproduct.risk.service.HazardCategoryService; import com.hnac.hzims.safeproduct.risk.service.HazardSourceService; import com.hnac.hzims.safeproduct.risk.service.HazardWorkService; +import com.hnac.hzims.safeproduct.risk.vo.HazardWorkVO; import com.hnac.hzims.safeproduct.risk.vo.PersonalCheckItemVO; -import com.hnac.hzims.safeproduct.risk.vo.StationRiskLevelVo; 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.Condition; +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.CollectionUtil; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -38,6 +45,8 @@ public class HazardWorkServiceImpl extends BaseServiceImpl getHazardWorkPage(HazardWork entity, Query query) { + IPage hazardWorkPage = this.page(Condition.getPage(query), Condition.getQueryWrapper(entity)); + List records = hazardWorkPage.getRecords(); + List res = new ArrayList<>(); + // 遍历获取负责人和分管领导名称 + for (HazardWork record : records) { + HazardWorkVO hazardWorkVO = new HazardWorkVO(); + BeanUtil.copyProperties(record, hazardWorkVO); + Long headId = record.getHead(); + if (headId != null) { + R header = userClient.userInfoById(headId); + if (header.isSuccess()) { + hazardWorkVO.setHeadName(header.getData().getRealName()); + } + } + Long manageId = record.getManage(); + if (manageId != null) { + R manager = userClient.userInfoById(headId); + if (manager.isSuccess()) { + hazardWorkVO.setManagerName(manager.getData().getRealName()); + } + } + res.add(hazardWorkVO); + } + // 分页 + IPage page = new Page<>(query.getCurrent(), query.getSize()); + page.setRecords(res); + page.setTotal(hazardWorkPage.getTotal()); + page.setPages(hazardWorkPage.getPages()); + return page; + } }