|
|
|
@ -2,9 +2,18 @@ package com.ruoyi.ehsMaterial.controller;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
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.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
@ -40,6 +49,10 @@ public class EhsMaterialController extends BaseController
|
|
|
|
|
{
|
|
|
|
|
@Autowired
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
util.exportExcel(response, list, "物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”数据");
|
|
|
|
|
}
|
|
|
|
|