From 65968dac2a87ca66f0386edfff2e73b993dd3e05 Mon Sep 17 00:00:00 2001 From: 15036302109 Date: Tue, 12 Mar 2024 16:21:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=9F=E4=BC=8D=E5=AF=BC=E5=87=BA=EF=BC=9A?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=A1=A8=E6=A0=BC=E5=86=85=E5=AE=B9=E5=8C=85?= =?UTF-8?q?=E6=8B=AC=E9=98=9F=E4=BC=8D=E5=90=8D=E7=A7=B0=E3=80=81=E9=98=9F?= =?UTF-8?q?=E9=95=BF=E3=80=81=E9=98=9F=E5=91=98=E4=BF=A1=E6=81=AF=E7=AD=89?= =?UTF-8?q?=E6=89=80=E6=9C=89=E7=9A=84=E8=B5=84=E6=96=99=E9=83=BD=E6=94=BE?= =?UTF-8?q?=E5=88=B0=E8=A1=A8=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ehs/EhsRescueTeamController.java | 34 ++++++++++++++++--- .../ehs/EhsRescueTeamWorkerController.java | 11 ++---- .../domain/EhsRescueTeamWorker.java | 5 +++ .../mapper/EhsRescueTeamWorkerMapper.java | 7 ++++ .../service/IEhsRescueTeamWorkerService.java | 7 ++++ .../impl/EhsRescueTeamWorkerServiceImpl.java | 10 ++++++ .../mapper/ehs/EhsRescueTeamWorkerMapper.xml | 9 +++++ 7 files changed, 71 insertions(+), 12 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamController.java index d6b587c..da97f67 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamController.java @@ -11,6 +11,7 @@ import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.ehsRescueTeam.domain.EhsRescueTeam; import com.ruoyi.ehsRescueTeam.service.IEhsRescueTeamService; +import com.ruoyi.ehsRescueTeamWorker.domain.EhsRescueTeamWorker; import com.ruoyi.ehsRescueTeamWorker.service.IEhsRescueTeamWorkerService; import com.ruoyi.system.service.ISysDictDataService; import io.swagger.annotations.Api; @@ -22,9 +23,8 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** * 应急救援队伍管理Controller @@ -59,13 +59,39 @@ public class EhsRescueTeamController extends BaseController { /** * 导出应急救援队伍管理列表 */ - @PreAuthorize("@ss.hasPermi('ehs:ehsRescueTeam:export')") + /*@PreAuthorize("@ss.hasPermi('ehs:ehsRescueTeam:export')") @Log(title = "应急救援队伍管理", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, EhsRescueTeam ehsRescueTeam) { List list = ehsRescueTeamService.selectEhsRescueTeamList(ehsRescueTeam); ExcelUtil util = new ExcelUtil<>(EhsRescueTeam.class); util.exportExcel(response, list, "应急救援队伍管理数据"); + }*/ + + /** + * 要求队导出表格内容包含:队伍名称,队长,队员信息 + * @param response + * @param ehsRescueTeam + */ + //@PreAuthorize("@ss.hasPermi('ehs:ehsRescueTeam:export')") + @Log(title = "应急救援队伍管理", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EhsRescueTeam ehsRescueTeam) { + List list = ehsRescueTeamService.selectEhsRescueTeamList(ehsRescueTeam); + // Map的key为队伍id,map的value为负责人 + Map map = list.stream().collect(Collectors.toMap( + EhsRescueTeam::getId, + item -> item.getDutyer() == null ? "" : item.getDutyer() + )); + List teamIds = list.stream().map(EhsRescueTeam::getId).collect(Collectors.toList()); + // 根据teamIdList查询人员表 + List teamWorkerList = ehsRescueTeamWorkerService.listWorkerByTeamIds(teamIds); + teamWorkerList.forEach(item -> { + // 给每个人员的负责人属性赋值 + item.setDutyer(map.get(item.getRescueTeamId())); + }); + ExcelUtil util = new ExcelUtil<>(EhsRescueTeamWorker.class); + util.exportExcel(response, teamWorkerList, "应急救援队伍管理数据"); } /** diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamWorkerController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamWorkerController.java index 2c7f6f8..f768d7f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamWorkerController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamWorkerController.java @@ -1,20 +1,15 @@ package com.ruoyi.web.controller.ehs; -import com.baomidou.mybatisplus.core.metadata.TableInfo; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.domain.ExcelExp; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.ExcelExportUtil; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.ehsRescueTeam.domain.EhsRescueTeam; -import com.ruoyi.ehsRescueTeam.domain.RescueTeamImportTemplate; import com.ruoyi.ehsRescueTeam.service.IEhsRescueTeamService; import com.ruoyi.ehsRescueTeam.vo.TeamResponseVo; import com.ruoyi.ehsRescueTeamWorker.domain.EhsRescueTeamWorker; -import com.ruoyi.ehsRescueTeamWorker.domain.RescueTeamWorkerImportTemplate; import com.ruoyi.ehsRescueTeamWorker.service.IEhsRescueTeamWorkerService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -23,8 +18,6 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -61,8 +54,10 @@ public class EhsRescueTeamWorkerController extends BaseController { @Log(title = "应急救援队人员信息", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, EhsRescueTeamWorker ehsRescueTeamWorker) { + EhsRescueTeam team = ehsRescueTeamService.selectEhsRescueTeamById(ehsRescueTeamWorker.getRescueTeamId()); List list = ehsRescueTeamWorkerService.selectEhsRescueTeamWorkerList(ehsRescueTeamWorker); - ExcelUtil util = new ExcelUtil(EhsRescueTeamWorker.class); + list.stream().forEach(item -> item.setDutyer(team.getDutyer())); + ExcelUtil util = new ExcelUtil<>(EhsRescueTeamWorker.class); util.exportExcel(response, list, "应急救援队人员信息数据"); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/domain/EhsRescueTeamWorker.java b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/domain/EhsRescueTeamWorker.java index ebedc14..c84de6b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/domain/EhsRescueTeamWorker.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/domain/EhsRescueTeamWorker.java @@ -46,6 +46,11 @@ public class EhsRescueTeamWorker extends BaseEntity { @Excel(name = "应急救援队伍名称", type = Excel.Type.EXPORT) private String rescueTeamName; + /** 队伍负责人 */ + @TableField(exist = false) + @Excel(name = "负责人") + private String dutyer; + /** * 人员姓名 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/mapper/EhsRescueTeamWorkerMapper.java b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/mapper/EhsRescueTeamWorkerMapper.java index 8e96023..367010e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/mapper/EhsRescueTeamWorkerMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/mapper/EhsRescueTeamWorkerMapper.java @@ -35,4 +35,11 @@ public interface EhsRescueTeamWorkerMapper extends BaseMapper listWorker(Long rescueTeamId); + + /** + * 根据多个teamIds获取人员信息 + * @param teamIds 队伍id + * @return + */ + List listWorkerByTeamIds(List teamIds); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/IEhsRescueTeamWorkerService.java b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/IEhsRescueTeamWorkerService.java index 49e6854..af2bbcf 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/IEhsRescueTeamWorkerService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/IEhsRescueTeamWorkerService.java @@ -44,4 +44,11 @@ public interface IEhsRescueTeamWorkerService extends IService listWorker(Long rescueTeamId); + + /** + * 根据多个teamIds获取人员信息 + * @param teamIds 队伍id + * @return + */ + List listWorkerByTeamIds(List teamIds); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/impl/EhsRescueTeamWorkerServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/impl/EhsRescueTeamWorkerServiceImpl.java index fb9251d..6de812a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/impl/EhsRescueTeamWorkerServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/impl/EhsRescueTeamWorkerServiceImpl.java @@ -134,6 +134,16 @@ public class EhsRescueTeamWorkerServiceImpl extends ServiceImpl listWorkerByTeamIds(List teamIds) { + return ehsRescueTeamWorkerMapper.listWorkerByTeamIds(teamIds); + } + private LambdaQueryWrapper buildQueryWrapper(EhsRescueTeamWorker query) { Map params = query.getParams(); diff --git a/ruoyi-system/src/main/resources/mapper/ehs/EhsRescueTeamWorkerMapper.xml b/ruoyi-system/src/main/resources/mapper/ehs/EhsRescueTeamWorkerMapper.xml index bb0d084..a148677 100644 --- a/ruoyi-system/src/main/resources/mapper/ehs/EhsRescueTeamWorkerMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/ehs/EhsRescueTeamWorkerMapper.xml @@ -66,6 +66,15 @@ where rescue_team_id = #{rescueTeamId} + delete from ehs_rescue_team_worker