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; + } }