应急救援物资,公文办理,队伍管理,队伍人员导入导出功能优化

main
15036302109 10 months ago
parent 7b707fb2f7
commit f8419f24cc

@ -2,9 +2,18 @@ package com.ruoyi.ehsMaterial.controller;
import java.util.List; import java.util.List;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.ehsRisk.domain.EhsRisk; import com.ruoyi.ehsRisk.domain.EhsRisk;
import com.ruoyi.materialClass.domain.MaterialClassMaster;
import com.ruoyi.materialClass.domain.MaterialClassSub;
import com.ruoyi.materialClass.mapper.MaterialClassSubMapper;
import com.ruoyi.materialClass.service.IMaterialClassMasterService;
import com.ruoyi.materialClass.service.IMaterialClassSubService;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -40,6 +49,10 @@ public class EhsMaterialController extends BaseController
{ {
@Autowired @Autowired
private IEhsMaterialService ehsMaterialService; private IEhsMaterialService ehsMaterialService;
@Autowired
private IMaterialClassMasterService materialClassMastService;
@Autowired
private IMaterialClassSubService materialClassSubService;
/** /**
* *
@ -62,6 +75,29 @@ public class EhsMaterialController extends BaseController
public void export(HttpServletResponse response, EhsMaterial ehsMaterial) public void export(HttpServletResponse response, EhsMaterial ehsMaterial)
{ {
List<EhsMaterial> list = ehsMaterialService.selectEhsMaterialList(ehsMaterial); List<EhsMaterial> list = ehsMaterialService.selectEhsMaterialList(ehsMaterial);
// 类别替换为中文
MaterialClassMaster msm = new MaterialClassMaster();
msm.setClassMastType(ehsMaterial.getClassFirst().toString());
List<MaterialClassMaster> materialClassMasters = materialClassMastService.selectMaterialClassMastList(msm);
// 物资分类一级分类对象,对应的是"类别"字段;收集为map,key是 v1,v2,v3... value是"常用工具","个人防护物资和装备"...
Map<String, String> map1 = materialClassMasters.stream().collect(Collectors.toMap(MaterialClassMaster::getClassMastId, MaterialClassMaster::getClassNameMast));
// 物资名称替换为中文
MaterialClassSub mcs = new MaterialClassSub();
mcs.setClassMastType(ehsMaterial.getClassFirst().toString());
List<MaterialClassSub> mlist = materialClassSubService.selectMaterialClassSubList(mcs);
// 物资分类二级分类对象,对应的是"物资名称"字段;收集为map,key是 v1-1,v1-2,v2-1... value是"卫星电话"...
Map<String, String> map2 = mlist.stream()
.collect(Collectors.toMap(MaterialClassSub::getClassSubId, MaterialClassSub::getClassNameSub));
list.stream().forEach((item)->{
String value = map1.get(item.getClassSecond());
if (StringUtils.isNotBlank(value)) {
item.setClassSecond(value);
}
String val = map2.get(item.getMaterialName());
if (StringUtils.isNotBlank(val)) {
item.setMaterialName(val);
}
});
ExcelUtil<EhsMaterial> util = new ExcelUtil<EhsMaterial>(EhsMaterial.class); ExcelUtil<EhsMaterial> util = new ExcelUtil<EhsMaterial>(EhsMaterial.class);
util.exportExcel(response, list, "物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”数据"); util.exportExcel(response, list, "物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”数据");
} }

@ -76,21 +76,9 @@ public class EhsRescueTeamController extends BaseController {
* *
*/ */
@PostMapping("/importTemplate") @PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) throws IOException { public void importTemplate(HttpServletResponse response) throws Exception {
List<EhsRescueTeam> ehsRescueTeamList = new ArrayList<>(); ExcelUtil<EhsRescueTeam> util = new ExcelUtil<EhsRescueTeam>(EhsRescueTeam.class);
String[] header = util.importComboTemplateExcel(response, "应急救援队伍信息数据");
{"队伍名称#",
"队伍级别#",
"负责人#",
"联系电话#",
"所属单位#",
"驻地#",
"队伍属性(0-其他,1-政府,2-企业,3-社会)#",
"备注#"};
ExcelExp e1 = new ExcelExp("应急救援队伍信息", header, ehsRescueTeamList, EhsRescueTeam.class);
List<ExcelExp> mysheet = new ArrayList<>();
mysheet.add(e1);
ExcelExportUtil.exportManySheetExcel("应急救援队伍信息批量导入模板", mysheet, response);
} }
/** /**
@ -98,8 +86,8 @@ public class EhsRescueTeamController extends BaseController {
*/ */
@PostMapping("/importData") @PostMapping("/importData")
public AjaxResult importHubManage(MultipartFile file, Boolean updateSupport) throws Exception { public AjaxResult importHubManage(MultipartFile file, Boolean updateSupport) throws Exception {
ExcelUtil<RescueTeamImportTemplate> util = new ExcelUtil<>(RescueTeamImportTemplate.class); ExcelUtil<EhsRescueTeam> util = new ExcelUtil<>(EhsRescueTeam.class);
List<RescueTeamImportTemplate> list = util.importExcel(file.getInputStream()); List<EhsRescueTeam> list = util.importExcel(file.getInputStream());
String message = ehsRescueTeamService.importRescueTeam(list, updateSupport); String message = ehsRescueTeamService.importRescueTeam(list, updateSupport);
return AjaxResult.success(message); return AjaxResult.success(message);
} }

@ -120,23 +120,9 @@ public class EhsRescueTeamWorkerController extends BaseController {
* *
*/ */
@PostMapping("/importTemplate") @PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) throws IOException { public void importTemplate(HttpServletResponse response) throws Exception {
List<EhsRescueTeamWorker> teamWorkerList = new ArrayList<>(); ExcelUtil<EhsRescueTeamWorker> util = new ExcelUtil<>(EhsRescueTeamWorker.class);
String[] header = util.importComboTemplateExcel(response, "应急救援队伍人员信息");
{"人员姓名#",
"年龄#",
"性别(0男 1女)#",
"身份证号#",
"联系方式#",
"队内职务#",
"工作年限#",
"救援技能特长#",
"培训次数#",
"备注#"};
ExcelExp e1 = new ExcelExp("应急救援队伍人员信息", header, teamWorkerList, EhsRescueTeamWorker.class);
List<ExcelExp> mysheet = new ArrayList<>();
mysheet.add(e1);
ExcelExportUtil.exportManySheetExcel("应急救援队伍人员信息批量导入模板", mysheet, response);
} }
@ -145,8 +131,8 @@ public class EhsRescueTeamWorkerController extends BaseController {
*/ */
@PostMapping("/importData") @PostMapping("/importData")
public AjaxResult importData(MultipartFile file, Boolean updateSupport, Long params) throws Exception { public AjaxResult importData(MultipartFile file, Boolean updateSupport, Long params) throws Exception {
ExcelUtil<RescueTeamWorkerImportTemplate> util = new ExcelUtil<>(RescueTeamWorkerImportTemplate.class); ExcelUtil<EhsRescueTeamWorker> util = new ExcelUtil<>(EhsRescueTeamWorker.class);
List<RescueTeamWorkerImportTemplate> list = util.importExcel(file.getInputStream()); List<EhsRescueTeamWorker> list = util.importExcel(file.getInputStream());
String message = ehsRescueTeamWorkerService.importRescueTeamWorker(list, updateSupport, params); String message = ehsRescueTeamWorkerService.importRescueTeamWorker(list, updateSupport, params);
return AjaxResult.success(message); return AjaxResult.success(message);
} }

@ -57,6 +57,7 @@ public class BaseEntity implements Serializable
private Date updateTime; private Date updateTime;
/** 备注 */ /** 备注 */
@Excel(name = "备注")
private String remark; private String remark;
/** 请求参数 */ /** 请求参数 */

@ -55,7 +55,7 @@ public class EhsDocument extends BaseEntity {
/** /**
* *
*/ */
@Excel(name = "公文类型") @Excel(name = "公文类型", dictType = "doc_type")
private Integer docType; private Integer docType;
/** /**
@ -74,6 +74,6 @@ public class EhsDocument extends BaseEntity {
/** /**
* *
*/ */
@Excel(name = "状态") @Excel(name = "状态", dictType = "doc_status")
private Integer status; private Integer status;
} }

@ -70,13 +70,13 @@ public class EhsRescueTeam extends BaseEntity {
/** /**
* *
*/ */
@Excel(name = "队伍属性(0-其他,1-政府,2-企业,3-社会)") @Excel(name = "队伍属性", dictType = "team_property")
private Integer teamProperty; private Long teamProperty;
/** /**
* *
*/ */
@Excel(name = "救援人员数量") @Excel(name = "救援人员数量", type = Excel.Type.EXPORT)
@TableField(exist = false) @TableField(exist = false)
private Long rescueWorkerNum; private Long rescueWorkerNum;

@ -37,7 +37,7 @@ public interface IEhsRescueTeamService extends IService<EhsRescueTeam> {
* @param updateSupport * @param updateSupport
* @return * @return
*/ */
public String importRescueTeam(List<RescueTeamImportTemplate> list, Boolean updateSupport) throws Exception; public String importRescueTeam(List<EhsRescueTeam> list, Boolean updateSupport) throws Exception;
/** /**
* :id * :id

@ -83,7 +83,7 @@ public class EhsRescueTeamServiceImpl extends ServiceImpl<EhsRescueTeamMapper, E
* @return * @return
*/ */
@Override @Override
public String importRescueTeam(List<RescueTeamImportTemplate> list, Boolean updateSupport) throws Exception { public String importRescueTeam(List<EhsRescueTeam> list, Boolean updateSupport) throws Exception {
if (StringUtils.isNull(list) || list.size() == 0) { if (StringUtils.isNull(list) || list.size() == 0) {
throw new Exception("导入救援队伍信息数据不能为空!"); throw new Exception("导入救援队伍信息数据不能为空!");
} }
@ -92,7 +92,7 @@ public class EhsRescueTeamServiceImpl extends ServiceImpl<EhsRescueTeamMapper, E
StringBuilder successMsg = new StringBuilder(); StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder();
for (RescueTeamImportTemplate rescueTeamTemplate : list) { for (EhsRescueTeam team : list) {
EhsRescueTeam temp = new EhsRescueTeam(); EhsRescueTeam temp = new EhsRescueTeam();
/** /**
@ -100,14 +100,14 @@ public class EhsRescueTeamServiceImpl extends ServiceImpl<EhsRescueTeamMapper, E
* id,,id * id,,id
*/ */
// temp.setId(IdUtils.fastSimpleUUID()); // temp.setId(IdUtils.fastSimpleUUID());
temp.setTeamName(rescueTeamTemplate.getTeamName()); //队伍名称 temp.setTeamName(team.getTeamName()); //队伍名称
temp.setTeamLevel(rescueTeamTemplate.getTeamLevel()); //队伍级别 temp.setTeamLevel(team.getTeamLevel()); //队伍级别
temp.setDutyer(rescueTeamTemplate.getDutyer());// 负责人 temp.setDutyer(team.getDutyer());// 负责人
temp.setPhone(rescueTeamTemplate.getPhone());// 联系电话 temp.setPhone(team.getPhone());// 联系电话
temp.setUnit(rescueTeamTemplate.getUnit());// 所属单位 temp.setUnit(team.getUnit());// 所属单位
temp.setStation(rescueTeamTemplate.getStation());// 驻地 temp.setStation(team.getStation());// 驻地
temp.setTeamProperty(rescueTeamTemplate.getTeamProperty());// 队伍属性 temp.setTeamProperty(team.getTeamProperty());// 队伍属性
temp.setRemark(rescueTeamTemplate.getRemark()); // 备注 temp.setRemark(team.getRemark()); // 备注
try { try {
//插入数据 //插入数据
this.save(temp); this.save(temp);

@ -43,7 +43,7 @@ public class EhsRescueTeamWorker extends BaseEntity {
/** /**
* *
*/ */
@Excel(name = "应急救援队伍名称") @Excel(name = "应急救援队伍名称", type = Excel.Type.EXPORT)
private String rescueTeamName; private String rescueTeamName;
/** /**
@ -59,7 +59,7 @@ public class EhsRescueTeamWorker extends BaseEntity {
/** /**
* *
*/ */
@Excel(name = "性别(0男 1女)") @Excel(name = "性别", dictType = "sys_user_sex")
private Integer gender; private Integer gender;

@ -35,7 +35,7 @@ public interface IEhsRescueTeamWorkerService extends IService<EhsRescueTeamWorke
boolean removeWorkerByTeamIds(List<Long> teamIds); boolean removeWorkerByTeamIds(List<Long> teamIds);
// 批量导入数据 // 批量导入数据
public String importRescueTeamWorker(List<RescueTeamWorkerImportTemplate> list, Boolean updateSupport, Long params) throws Exception; public String importRescueTeamWorker(List<EhsRescueTeamWorker> list, Boolean updateSupport, Long params) throws Exception;
// 根据teamId更新应急救援人员信息 // 根据teamId更新应急救援人员信息
public boolean updateWorkerByTeamId(EhsRescueTeam ehsRescueTeam); public boolean updateWorkerByTeamId(EhsRescueTeam ehsRescueTeam);

@ -69,7 +69,7 @@ public class EhsRescueTeamWorkerServiceImpl extends ServiceImpl<EhsRescueTeamWor
* @return * @return
*/ */
@Override @Override
public String importRescueTeamWorker(List<RescueTeamWorkerImportTemplate> list, Boolean updateSupport, Long params) throws Exception { public String importRescueTeamWorker(List<EhsRescueTeamWorker> list, Boolean updateSupport, Long params) throws Exception {
if (StringUtils.isNull(list) || list.size() == 0) { if (StringUtils.isNull(list) || list.size() == 0) {
throw new Exception("导入应急救援队伍人员信息数据不能为空!"); throw new Exception("导入应急救援队伍人员信息数据不能为空!");
} }
@ -78,7 +78,7 @@ public class EhsRescueTeamWorkerServiceImpl extends ServiceImpl<EhsRescueTeamWor
StringBuilder successMsg = new StringBuilder(); StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder();
for (RescueTeamWorkerImportTemplate rescueTeamWorkerTemplate : list) { for (EhsRescueTeamWorker item : list) {
EhsRescueTeamWorker temp = new EhsRescueTeamWorker(); EhsRescueTeamWorker temp = new EhsRescueTeamWorker();
/** /**
@ -90,16 +90,16 @@ public class EhsRescueTeamWorkerServiceImpl extends ServiceImpl<EhsRescueTeamWor
TeamResponseVo teamResponseVo = ehsRescueTeamMapper.getTeamInfoByTeamId(params); TeamResponseVo teamResponseVo = ehsRescueTeamMapper.getTeamInfoByTeamId(params);
temp.setRescueTeamId(teamResponseVo.getRescueTeamId());// 队伍id temp.setRescueTeamId(teamResponseVo.getRescueTeamId());// 队伍id
temp.setRescueTeamName(teamResponseVo.getRescueTeamName());// 队伍名称 temp.setRescueTeamName(teamResponseVo.getRescueTeamName());// 队伍名称
temp.setWorkerName(rescueTeamWorkerTemplate.getWorkerName());// 人员姓名 temp.setWorkerName(item.getWorkerName());// 人员姓名
temp.setGender(rescueTeamWorkerTemplate.getGender());// 性别(0男 1女) temp.setGender(item.getGender());// 性别(0男 1女)
temp.setIdCard(rescueTeamWorkerTemplate.getIdCard());// 身份证号 temp.setIdCard(item.getIdCard());// 身份证号
temp.setPhone(rescueTeamWorkerTemplate.getPhone());// 联系方式 temp.setPhone(item.getPhone());// 联系方式
temp.setWorkYear(rescueTeamWorkerTemplate.getWorkYear());// 工作年限 temp.setWorkYear(item.getWorkYear());// 工作年限
temp.setSpeciality(rescueTeamWorkerTemplate.getSpeciality());// 救援技能特长 temp.setSpeciality(item.getSpeciality());// 救援技能特长
temp.setRemark(rescueTeamWorkerTemplate.getRemark());// 备注 temp.setRemark(item.getRemark());// 备注
temp.setWorkerAge(rescueTeamWorkerTemplate.getWorkerAge());// 年龄 temp.setWorkerAge(item.getWorkerAge());// 年龄
temp.setTeamPost(rescueTeamWorkerTemplate.getTeamPost());// 队内职务 temp.setTeamPost(item.getTeamPost());// 队内职务
temp.setTrainNum(rescueTeamWorkerTemplate.getTrainNum());// 培训次数 temp.setTrainNum(item.getTrainNum());// 培训次数
try { try {
//插入数据 //插入数据

Loading…
Cancel
Save