Commit 424c441f authored by 李腾威's avatar 李腾威

联动单位导出增加过滤

parent bafa05be
......@@ -60,6 +60,6 @@ public interface LinkageUnitMapper extends BaseMapper<LinkageUnit> {
Page<List<LinkageUnitDto>> getEmergencyLinkageUnitList(IPage<LinkageUnitDto> page,String unitName,
String linkageUnitType, String linkageUnitTypeCode, String emergencyLinkageUnitCode);
List<LinkageUnitDto> exportToExcel();
List<LinkageUnitDto> exportToExcel(String unitName,String linkageUnitTypeCode);
}
package com.yeejoin.amos.boot.module.common.api.service;
import java.util.List;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.Menu;
......@@ -9,6 +7,8 @@ import com.yeejoin.amos.boot.module.common.api.dto.LinkageUnitDto;
import com.yeejoin.amos.boot.module.common.api.dto.LinkageUnitZhDto;
import com.yeejoin.amos.boot.module.common.api.dto.RequestData;
import java.util.List;
/**
* 联动单位接口类
*
......@@ -43,7 +43,7 @@ public interface ILinkageUnitService {
*/
public List<Menu> getEmergencyLinkageUnitCodeGroupBy(String type, String rootName);
List<LinkageUnitDto> exportToExcel();
List<LinkageUnitDto> exportToExcel(String unitName,String linkageUnitTypeCode);
List<LinkageUnitDto> queryForLinkageUnitList(Boolean isDelete);
}
......@@ -104,36 +104,44 @@
<select id="exportToExcel"
resultType="com.yeejoin.amos.boot.module.common.api.dto.LinkageUnitDto">
select
a.unit_name unitName,
a.linkage_unit_type
linkageUnitType,
a.address ,
a.latitude,
a.longitude,
a.agreement_start_date agreementStartDate,
a.agreement_end_date
agreementEndDate,
a.contact_user contactUser,
a.contact_phone
contactPhone,
b.*
from cb_linkage_unit a LEFT JOIN
(SELECT
m.instance_id,
max(case m.field_code when 'emergencyServiceContent' then
m.field_value end) emergencyServiceContent,
max(case m.field_code when
'fireRescueCapability' then m.field_value end) fireRescueCapability,
max(case m.field_code when 'responsibilitiesSituation' then
m.field_value end) responsibilitiesSituation,
max(case m.field_code
when 'unitSituation' then m.field_value end) unitSituation
FROM
cb_dynamic_form_instance m GROUP BY m.instance_id) b
on
b.instance_id=a.instance_id where a.unit_name is not null and a.is_delete=0
select
a.unit_name unitName,
a.linkage_unit_type
linkageUnitType,
a.linkage_unit_type_code
linkageUnitTypeCode,
a.address ,
a.latitude,
a.longitude,
a.agreement_start_date agreementStartDate,
a.agreement_end_date
agreementEndDate,
a.contact_user contactUser,
a.contact_phone
contactPhone,
b.*
from cb_linkage_unit a LEFT JOIN
(SELECT
m.instance_id,
max(case m.field_code when 'emergencyServiceContent' then
m.field_value end) emergencyServiceContent,
max(case m.field_code when
'fireRescueCapability' then m.field_value end) fireRescueCapability,
max(case m.field_code when 'responsibilitiesSituation' then
m.field_value end) responsibilitiesSituation,
max(case m.field_code
when 'unitSituation' then m.field_value end) unitSituation
FROM
cb_dynamic_form_instance m GROUP BY m.instance_id) b
on
b.instance_id=a.instance_id where a.unit_name is not null and a.is_delete=0
<if test="unitName != null and unitName != ''">
AND a.unit_name LIKE concat('%',#{unitName}, '%')
</if>
<if test="linkageUnitTypeCode != null and linkageUnitTypeCode != ''">
AND a.linkage_unit_type_code =#{linkageUnitTypeCode}
</if>
order by a.rec_date desc
</select>
<!--联动单位列表按时间倒叙排列add order by clu.rec_date desc 同时处理单位根节点-1时查询全部数据问题 2021-09-08 by kongfm -->
......
......@@ -304,8 +304,8 @@ public class LinkageUnitServiceImpl extends BaseService<LinkageUnitDto, LinkageU
}
@Override
public List<LinkageUnitDto> exportToExcel() {
return linkageUnitMapper.exportToExcel();
public List<LinkageUnitDto> exportToExcel(String unitName,String linkageUnitTypeCode) {
return linkageUnitMapper.exportToExcel(unitName,linkageUnitTypeCode);
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -66,6 +67,7 @@ import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyPersonServiceImp
import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyPersonShiftServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.DutyShiftServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.DynamicFormColumnServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.DynamicFormInstanceServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.FireChemicalServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.FireExpertsServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.FireStationServiceImpl;
......@@ -113,6 +115,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
* @author tb
......@@ -191,6 +194,9 @@ public class ExcelServiceImpl {
@Autowired
IDutyFirstAidService dutyFirstAidService;
@Autowired
DynamicFormInstanceServiceImpl dynamicFormInstanceService;
public void templateExport(HttpServletResponse response, ExcelDto excelDto) throws ClassNotFoundException {
String url = excelDto.getClassUrl();
Class<?> clz = Class.forName(url);
......@@ -305,9 +311,40 @@ public class ExcelServiceImpl {
OrgUsrExcelDto.class, null, false);
break;
case "LDDW":
List<LinkageUnitDto> LinkageUnitDtoList = linkageUnitServiceImpl.exportToExcel();
List<LinkageUnitDto> LinkageUnitDtoList = null;
String inAgreement = par.containsKey("inAgreement")?par.get("inAgreement").toString():"";
if(par.size()>0) {
LinkageUnitDtoList = linkageUnitServiceImpl.exportToExcel(par.containsKey("unitName")?par.get("unitName").toString():null,
par.containsKey("linkageUnitTypeCode")?par.get("linkageUnitTypeCode").toString():null
);
}else{
LinkageUnitDtoList = linkageUnitServiceImpl.exportToExcel(null,null);
}
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), LinkageUnitDtoList,
List<Map> linkageUnitListMap =JSONArray.parseArray(JSONArray.toJSONString(LinkageUnitDtoList), Map.class);
List<Map<String, Object>> pageList = dynamicFormInstanceService.listAll("linkageUnit");
linkageUnitListMap.forEach(i -> {
String mainString = i.get("instanceId").toString();
pageList.stream().forEach(detail -> {
if (detail.get("instanceId").toString().equals(mainString)) {
i.putAll(detail);
}
});
});
List<LinkageUnitDto> resultDtoList = JSONArray.parseArray(JSONArray.toJSONString(linkageUnitListMap),
LinkageUnitDto.class);
List<LinkageUnitDto> detaiList = resultDtoList.stream().map(item -> {
Date now = new Date();
boolean isInAgreement = DateUtils.belongCalendar(now, item.getAgreementStartDate(),
item.getAgreementEndDate());
item.setInAgreement(isInAgreement ? "是" : "否");
return item;
}).filter(item -> org.apache.commons.lang3.StringUtils.isEmpty(inAgreement) || inAgreement.equals(item.getInAgreement()))
.collect(Collectors.toList());
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), detaiList,
LinkageUnitDto.class, null, false);
break;
default:
......@@ -1602,7 +1639,7 @@ public class ExcelServiceImpl {
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(),
maintenancePersonExcelDtoList, MaintenancePersonExcleDto.class, null, false);
break;
// case "KEYSITE":
// case "KEYSITE": 已废弃
// List<KeySiteExcleDto> keySiteDtoList = keySiteService.exportToExcel();
// ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), keySiteDtoList,
// KeySiteExcleDto.class, null, false);
......@@ -1620,12 +1657,12 @@ public class ExcelServiceImpl {
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), orgUsrList,
OrgUsrExcelDto.class, null, false);
break;
case "LDDW":
List<LinkageUnitDto> LinkageUnitDtoList = linkageUnitServiceImpl.exportToExcel();
ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), LinkageUnitDtoList,
LinkageUnitDto.class, null, false);
break;
// case "LDDW": 已废弃
// List<LinkageUnitDto> LinkageUnitDtoList = linkageUnitServiceImpl.exportToExcel();
//
// ExcelUtil.createTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), LinkageUnitDtoList,
// LinkageUnitDto.class, null, false);
// break;
default:
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment