队伍导出:导出表格内容包括队伍名称、队长、队员信息等所有的资料都放到表中

main
15036302109 9 months ago
parent 750490c106
commit 65968dac2a

@ -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<EhsRescueTeam> list = ehsRescueTeamService.selectEhsRescueTeamList(ehsRescueTeam);
ExcelUtil<EhsRescueTeam> 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<EhsRescueTeam> list = ehsRescueTeamService.selectEhsRescueTeamList(ehsRescueTeam);
// Map的key为队伍id,map的value为负责人
Map<Long, String> map = list.stream().collect(Collectors.toMap(
EhsRescueTeam::getId,
item -> item.getDutyer() == null ? "" : item.getDutyer()
));
List<Long> teamIds = list.stream().map(EhsRescueTeam::getId).collect(Collectors.toList());
// 根据teamIdList查询人员表
List<EhsRescueTeamWorker> teamWorkerList = ehsRescueTeamWorkerService.listWorkerByTeamIds(teamIds);
teamWorkerList.forEach(item -> {
// 给每个人员的负责人属性赋值
item.setDutyer(map.get(item.getRescueTeamId()));
});
ExcelUtil<EhsRescueTeamWorker> util = new ExcelUtil<>(EhsRescueTeamWorker.class);
util.exportExcel(response, teamWorkerList, "应急救援队伍管理数据");
}
/**

@ -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<EhsRescueTeamWorker> list = ehsRescueTeamWorkerService.selectEhsRescueTeamWorkerList(ehsRescueTeamWorker);
ExcelUtil<EhsRescueTeamWorker> util = new ExcelUtil<EhsRescueTeamWorker>(EhsRescueTeamWorker.class);
list.stream().forEach(item -> item.setDutyer(team.getDutyer()));
ExcelUtil<EhsRescueTeamWorker> util = new ExcelUtil<>(EhsRescueTeamWorker.class);
util.exportExcel(response, list, "应急救援队人员信息数据");
}

@ -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;
/**
*
*/

@ -35,4 +35,11 @@ public interface EhsRescueTeamWorkerMapper extends BaseMapper<EhsRescueTeamWorke
public boolean updateWorkerByTeamId(EhsRescueTeamWorker worker);
List<EhsRescueTeamWorker> listWorker(Long rescueTeamId);
/**
* teamIds
* @param teamIds id
* @return
*/
List<EhsRescueTeamWorker> listWorkerByTeamIds(List<Long> teamIds);
}

@ -44,4 +44,11 @@ public interface IEhsRescueTeamWorkerService extends IService<EhsRescueTeamWorke
* id()
*/
List<EhsRescueTeamWorker> listWorker(Long rescueTeamId);
/**
* teamIds
* @param teamIds id
* @return
*/
List<EhsRescueTeamWorker> listWorkerByTeamIds(List<Long> teamIds);
}

@ -134,6 +134,16 @@ public class EhsRescueTeamWorkerServiceImpl extends ServiceImpl<EhsRescueTeamWor
return ehsRescueTeamWorkerMapper.listWorker(rescueTeamId);
}
/**
* teamIds
* @param teamIds id
* @return
*/
@Override
public List<EhsRescueTeamWorker> listWorkerByTeamIds(List<Long> teamIds) {
return ehsRescueTeamWorkerMapper.listWorkerByTeamIds(teamIds);
}
private LambdaQueryWrapper<EhsRescueTeamWorker> buildQueryWrapper(EhsRescueTeamWorker query) {
Map<String, Object> params = query.getParams();

@ -66,6 +66,15 @@
<include refid="selectEhsRescueTeamWorkerVo"/>
where rescue_team_id = #{rescueTeamId}
</select>
<select id="listWorkerByTeamIds" resultType="com.ruoyi.ehsRescueTeamWorker.domain.EhsRescueTeamWorker">
select *
from ehs_rescue_team_worker
where rescue_team_id in
<foreach collection="list" separator="," open="(" close=")" item="item">
#{item}
</foreach>
order by rescue_team_id asc
</select>
<delete id="removeWorkerByTeamIds">
delete from ehs_rescue_team_worker

Loading…
Cancel
Save