Commit d0559eb4 authored by chenhao's avatar chenhao

提交120急救站excle魔板下载和导出

parent d4e9c15b
......@@ -84,7 +84,7 @@ public class ExcelUtil {
*/
public static void createDutyTemplate(HttpServletResponse response, String fileName, String sheetName,
List<? extends Object> data, Class<?> model, List<String> dayByMonth, String[] dutyNameList,
DataSources dataDictionaryMapper, boolean flag, boolean typeFlag) {
DataSources dataDictionaryMapper, boolean flag, String typeFlag,boolean isTemplete) {
HorizontalCellStyleStrategy horizontalCellStyleStrategy = setMyCellStyle();
try {
......@@ -126,9 +126,12 @@ public class ExcelUtil {
}
// String s = new String(fileName.getBytes(), "UTF-8");
// response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(s, "UTF-8"));
ExcelWriterSheetBuilder excelWriterSheetBuilder = null;
;
if (typeFlag) {
ExcelWriterSheetBuilder excelWriterSheetBuilder =EasyExcel
.write(getOutputStream(fileName, response, ExcelTypeEnum.XLSX))
.head(dutyCarTitleList)
.excelType(ExcelTypeEnum.XLSX).sheet(sheetName);
if ("WXXFZB".equals(typeFlag) && isTemplete) {
List<Map<Integer, String[]>> fireStationExplicitListConstraintMap = new ArrayList<Map<Integer, String[]>>();
List<List<Object>> resultList =new ArrayList<List<Object>>();
data.stream().forEach(i -> {
......@@ -143,27 +146,49 @@ public class ExcelUtil {
detail.remove(detail.size()-1);
resultList.add(detail);
});
excelWriterSheetBuilder= EasyExcel
.write(getOutputStream(fileName, response, ExcelTypeEnum.XLSX))
.head(dutyCarTitleList)
.excelType(ExcelTypeEnum.XLSX).sheet(sheetName)
excelWriterSheetBuilder.registerWriteHandler(
new TemplateDynamicCellWriteHandlerDate(fireStationExplicitListConstraintMap))
.registerWriteHandler(new TemplateCellWriteHandler())
.registerWriteHandler(horizontalCellStyleStrategy);
excelWriterSheetBuilder.doWrite(resultList);
}
else if("JJZB".equals(typeFlag) && isTemplete){
List<Map<Integer, String[]>> fireStationExplicitListConstraintMap = new ArrayList<Map<Integer, String[]>>();
List<List<Object>> resultList =new ArrayList<List<Object>>();
data.stream().forEach(i -> {
Map<Integer, String[]> map = new HashMap<>();
List<Object> detail = (List<Object>) i;
// 微型消防站中的对应单位微型消防站下拉列表数据的集合
List<String> fireStationDetailList = (List<String>) detail.get(detail.size()-1);
String[] strings = new String[fireStationDetailList.size()];
List<String> postTypeNameDetailList = (List<String>) detail.get(detail.size()-2);
String[] postTypeNamestrings = new String[postTypeNameDetailList.size()];
List<String> userNameDetailList = (List<String>) detail.get(detail.size()-3);
String[] userNamestrings = new String[userNameDetailList.size()];
map.put(4, fireStationDetailList.toArray(strings));
map.put(3, postTypeNameDetailList.toArray(postTypeNamestrings));
map.put(2, userNameDetailList.toArray(userNamestrings));
map.putAll(explicitListConstraintMap);
fireStationExplicitListConstraintMap.add(map);
detail.remove(detail.size()-1);
detail.remove(detail.size()-1);
detail.remove(detail.size()-1);
resultList.add(detail);
});
excelWriterSheetBuilder
.registerWriteHandler(
new TemplateDynamicCellWriteHandlerDate(fireStationExplicitListConstraintMap))
.registerWriteHandler(new TemplateCellWriteHandler())
.registerWriteHandler(horizontalCellStyleStrategy);
excelWriterSheetBuilder.doWrite(resultList);
} else {
excelWriterSheetBuilder= EasyExcel
.write(getOutputStream(fileName, response, ExcelTypeEnum.XLSX))
.head(dutyCarTitleList)
.excelType(ExcelTypeEnum.XLSX).sheet(sheetName)
}else {
excelWriterSheetBuilder = excelWriterSheetBuilder
.registerWriteHandler(
new TemplateCellWriteHandlerDate(explicitListConstraintMap))
.registerWriteHandler(new TemplateCellWriteHandler())
.registerWriteHandler(horizontalCellStyleStrategy);
excelWriterSheetBuilder.doWrite(data);
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("系统异常!");
......
......@@ -128,4 +128,8 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> {
* @return
*/
List<Map<String, Object>> getDutyForSpecifyDate(String duty);
Map<String, Object> getFireTeamBySequenceNbr (Long sequenceNbr);
List<Map<String, Object>> getFirstAidForTypeCodeAndCompanyId(Long company);
}
......@@ -242,4 +242,7 @@ public interface IOrgUsrService {
public List<OrgUsr> getPersonListByParentIds(List<String> ids) ;
List<OrgUsrFormDto> getUnSyncOrgCompanyList(List<Long> companyIdList);
public OrgUsr getDetailById( Long id);
}
......@@ -14,17 +14,13 @@ import org.typroject.tyboot.core.foundation.utils.Bean;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.module.common.api.dto.DutyFirstAidDto;
import com.yeejoin.amos.boot.module.common.api.entity.FireTeam;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper;
import com.yeejoin.amos.boot.module.common.api.service.IDutyFirstAidService;
import com.yeejoin.amos.boot.module.common.api.service.IFireTeamService;
@Service
public class DutyFirstAidServiceImpl extends DutyCommonServiceImpl implements IDutyFirstAidService {
@Autowired
IFireTeamService fireTeamService;
@Autowired
DutyPersonShiftMapper dutyPersonShiftMapper;
......@@ -41,8 +37,11 @@ public class DutyFirstAidServiceImpl extends DutyCommonServiceImpl implements ID
@Override
public DutyFirstAidDto save(DutyFirstAidDto dto) {
FireTeam fireStationDtoResult = fireTeamService.getFireTeamBySequenceNbr(Long.parseLong(dto.getFirstAidId()));
dto.setFirstAid(fireStationDtoResult.getName());
Map<String, Object> fireStationDtoResult = dutyPersonShiftMapper.getFireTeamBySequenceNbr(Long.parseLong(dto.getFirstAidId()));
if(fireStationDtoResult==null || !fireStationDtoResult.containsKey("name")) {
throw new RuntimeException("此120急救站不存在");
}
dto.setFirstAid(fireStationDtoResult.get("name").toString());
Map<String, Object> map = Bean.BeantoMap(dto);
Long instanceId = excuteDynamicFormInstance(dto.getUserId(), map, this.getGroupCode());
saveDutyPersonShiftDetail(instanceId, dto.getDutyShift(), dto.getStartTime());
......@@ -114,35 +113,36 @@ public class DutyFirstAidServiceImpl extends DutyCommonServiceImpl implements ID
public List< Map<String, Object>> getFirstAidExportData(List<String> ids) {
List< Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
String dicCodeString = "830";
String typeString = "XFJGLX";
List<OrgUsr> personList = orgUsrServiceImpl.getPersonListByParentIds(ids);
personList.stream().forEach(i -> {
String userNameString =i.getBizOrgName()+ "@" +i.getSequenceNbr();
Map<String, Object> map = new HashMap<String, Object>();
List<FireTeam> list = fireTeamService.getFirstAidForTypeCodeAndCompanyId(dicCodeString, typeString,
Long.parseLong(i.getParentId()));
List<String> firstAidSimpleList = new ArrayList<String>();
List<String> companySimpleList = new ArrayList<String>();
list.stream().forEach(m -> {
String firstAidNameString = m.getName() + "@" + m.getSequenceNbr();
String companyNameString = m.getCompanyName() + "@" + m.getCompany();
firstAidSimpleList.add(firstAidNameString);
companySimpleList.add(companyNameString);
ids.stream().forEach(i->{
Map<String, Object> detailMap = new HashMap<String, Object>();
List<OrgUsr> personList = orgUsrServiceImpl.getPersonListByParentId(Long.parseLong(i));
List<String> userNameList= new ArrayList<String>();
personList.stream().forEach(m -> {
String userNameString =m.getBizOrgName()+ "@" +m.getSequenceNbr();
userNameList.add(userNameString);
});
detailMap.put("userName", userNameList);
OrgUsr companyDetail = orgUsrServiceImpl.getDetailById(Long.parseLong(i));
String companyNameString = companyDetail.getBizOrgName()+ "@" +companyDetail.getSequenceNbr();
detailMap.put("companyName", companyNameString);
List<DataDictionary> dataDicList= dataDictionaryService.getByType(typeString);
List<String> dataDicSimpleList = new ArrayList<String>();
dataDicList.stream().forEach(l->{
String dataDic = l.getName() + "@" +l.getCode();
dataDicSimpleList.add(dataDic);
});
map.put("firstAidName", firstAidSimpleList);
map.put("companyName", companySimpleList);
map.put("userName", userNameString);
map.put("postTypeName",dataDicSimpleList);
resultList.add(map);
detailMap.put("postTypeName",dataDicSimpleList);
List<Map<String, Object>> list = dutyPersonShiftMapper.getFirstAidForTypeCodeAndCompanyId(
Long.parseLong(i));
List<String> firstAidSimpleList = new ArrayList<String>();
list.stream().forEach(m -> {
String firstAidNameString = m.get("name").toString() + "@" + m.get("sequence_nbr").toString();
firstAidSimpleList.add(firstAidNameString);
});
detailMap.put("firstAidName", firstAidSimpleList);
resultList.add(detailMap);
});
return resultList;
}
......
......@@ -1733,4 +1733,12 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
}
return allUnSyncCompanyList;
}
public OrgUsr getDetailById( Long id){
LambdaQueryWrapper<OrgUsr> queryWrapper = new LambdaQueryWrapper<OrgUsr>();
queryWrapper.eq(OrgUsr::getIsDelete, false);
queryWrapper.eq(OrgUsr::getSequenceNbr, id);
return this.baseMapper.selectOne(queryWrapper);
}
}
......@@ -17,6 +17,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dto.CompanyPerson;
import com.yeejoin.amos.boot.module.common.api.dto.DutyCarDto;
import com.yeejoin.amos.boot.module.common.api.dto.DutyFireFightingDto;
import com.yeejoin.amos.boot.module.common.api.dto.DutyFirstAidDto;
import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonDto;
import com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto;
import com.yeejoin.amos.boot.module.common.api.dto.DutyShiftDto;
......@@ -186,7 +187,7 @@ public class ExcelServiceImpl {
@Autowired
OrgUsrSafeReportServiceImpl orgUsrSafeReportService;
@Autowired
IDutyFirstAidService dutyFirstAidService;
......@@ -965,10 +966,11 @@ public class ExcelServiceImpl {
&& !fileName.toLowerCase().endsWith(ExcelTypeEnum.XLSX.getValue())) {
throw new Exception("文件类型异常!");
}
List<OrgUsrSafeReportExcelDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile, OrgUsrSafeReportExcelDto.class, 1);
List<OrgUsrSafeReportExcelDto> excelDtoList = ExcelUtil.readFirstSheetExcel(multipartFile,
OrgUsrSafeReportExcelDto.class, 1);
List<OrgUsrSafeReport> excelEntityList = new ArrayList<>();
excelDtoList.forEach(fireExpertsDto -> {
OrgUsrSafeReport reportExcel= new OrgUsrSafeReport();
OrgUsrSafeReport reportExcel = new OrgUsrSafeReport();
reportExcel = Bean.toPo(fireExpertsDto, reportExcel);
reportExcel = Bean.toPo(getCurrentInfo(), reportExcel);
if (reportExcel.getCompany() != null) {
......@@ -1192,19 +1194,16 @@ public class ExcelServiceImpl {
} else if (ExcelEnums.WXXFZB.getType().equals(excelDto.getType())) {
data = initDutyDutyFireFightingTemplate(ids);
} else if (ExcelEnums.JJZB.getType().equals(excelDto.getType())) {
//data = initDutyDutyFirstAidTemplate(ids);
data = initDutyDutyFirstAidTemplate(ids);
}
// 获取日期
List<Map<String, Object>> rangeDate = dutyPersonShiftService.getBaseMapper().genRangeDate(beginDate, endDate);
List<String> dayByMonth = new ArrayList<>();
rangeDate.forEach(item -> dayByMonth.add((String) item.get("date")));
if (ExcelEnums.WXXFZB.getType().equals(excelDto.getType())) {
exportDutyTemplate(response, excelDto.getClassUrl(), dayByMonth, excelDto, data, true, true);
} else {
exportDutyTemplate(response, excelDto.getClassUrl(), dayByMonth, excelDto, data, true, false);
}
exportDutyTemplate(response, excelDto.getClassUrl(), dayByMonth, excelDto, data, true,
excelDto.getType(),true);
}
private List<List<Object>> initDutyDutyFirstAidTemplate(String ids) {
List<List<Object>> data = new ArrayList<>();
// 根据id列表获取单位下的微型消防站集合
......@@ -1219,15 +1218,16 @@ public class ExcelServiceImpl {
personDetailList.forEach(o -> {
ArrayList<Object> list = new ArrayList<>();
list.add(row.getAndIncrement());
list.add(null);
list.add(null);
list.add(null);
list.add(o.get("fireStation"));
list.add(o.get("companyName"));
list.add(o.get("userName"));
list.add(o.get("postTypeName"));
list.add(o.get("firstAidName"));
data.add(list);
});
}
return data;
}
private List<List<Object>> initDutyDutyFireFightingTemplate(String ids) {
List<List<Object>> data = new ArrayList<>();
// 根据id列表获取单位下的微型消防站集合
......@@ -1265,13 +1265,37 @@ public class ExcelServiceImpl {
} else if (ExcelEnums.RYZB.getType().equals(excelDto.getType())) {
data = initDutyPersonInfo(beginDate, endDate, dayByMonth);
} else if (ExcelEnums.WXXFZB.getType().equals(excelDto.getType())) {
data = initDutyDutyFireFightingTemplate(beginDate, endDate, dayByMonth);
data = initDutyDutyFireFighting(beginDate, endDate, dayByMonth);
} else if (ExcelEnums.JJZB.getType().equals(excelDto.getType())) {
data = initDutyDutyFirstAid(beginDate, endDate, dayByMonth);
}
exportDutyTemplate(response, excelDto.getClassUrl(), dayByMonth, excelDto, data, false, false);
exportDutyTemplate(response, excelDto.getClassUrl(), dayByMonth, excelDto, data, false, ExcelEnums.WXXFZB.getType(),false);
}
private List<List<Object>> initDutyDutyFirstAid(String beginDate, String endDate, List<String> dayByMonth) throws ParseException {
List<DutyFirstAidDto> list = dutyFirstAidService.downloadList(beginDate, endDate);
List<List<Object>> data = new ArrayList<>();
// 组装导出数据
if (!list.isEmpty()) {
AtomicInteger row = new AtomicInteger(1);
list.forEach(o -> {
ArrayList<Object> detailList = new ArrayList<>();
detailList.add(row.getAndIncrement());
detailList.add(o.getTeamName());
detailList.add(o.getUserName());
detailList.add(o.getPostTypeName());
detailList.add(o.getFirstAid());
List<DutyPersonShiftDto> dutyShift = o.getDutyShift();
initDutyShift(dayByMonth, dutyShift, detailList);
data.add(detailList);
});
}
return data;
}
private List<List<Object>> initDutyDutyFireFightingTemplate(String beginDate, String endDate,
private List<List<Object>> initDutyDutyFireFighting(String beginDate, String endDate,
List<String> dayByMonth) throws ParseException {
List<DutyFireFightingDto> list = dutyFireFightingService.downloadList(beginDate, endDate);
......@@ -1352,13 +1376,13 @@ public class ExcelServiceImpl {
}
private void exportDutyTemplate(HttpServletResponse response, String classUrl, List<String> dayByMonth,
ExcelDto excelDto, List<? extends Object> data, Boolean flag, Boolean typeFlag) {
ExcelDto excelDto, List<? extends Object> data, Boolean flag, String typeFlag,boolean isTemplete) {
try {
// 获取排班类型
String[] dutyNameList = getDutyNameList();
Class<?> clz = Class.forName(classUrl);
ExcelUtil.createDutyTemplate(response, excelDto.getFileName(), excelDto.getSheetName(), data, clz,
dayByMonth, dutyNameList, dataSourcesImpl, flag, typeFlag);
dayByMonth, dutyNameList, dataSourcesImpl, flag, typeFlag,isTemplete);
} catch (ClassNotFoundException e) {
e.printStackTrace();
......
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