|
@@ -11,6 +11,10 @@ import com.ims.eval.entity.dto.response.OrganizationEvaluationInfoResDTO;
|
|
|
import com.ims.eval.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
+import org.apache.commons.io.output.ByteArrayOutputStream;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -331,11 +335,11 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map getEvaluationInfoList(String organizationEvaluationId, String indicatorId, HttpServletRequest request) {
|
|
|
+ public Map getEvaluationInfoList(String organizationEvaluationId, String indicatorId, String binSection, String binStage, HttpServletRequest request) {
|
|
|
|
|
|
Map data = new HashMap();
|
|
|
boolean titlemark = true;//标记生成标题
|
|
|
- List<OrganizationEvaluationInfoResDTO> infoResDTOList = baseMapper.selectEvaluationInfoList(organizationEvaluationId, indicatorId);
|
|
|
+ List<OrganizationEvaluationInfoResDTO> infoResDTOList = baseMapper.selectEvaluationInfoList(organizationEvaluationId, indicatorId,binSection,binStage);
|
|
|
List<IndicatorDictionary> dictionaryList = indicatorDictionaryService.list("", indicatorId, "", "");
|
|
|
|
|
|
//根据组织(公司)id分组
|
|
@@ -399,7 +403,7 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
|
|
|
indicatormap.put(d.getChildCode() + "_" + d.getOptionCode(), null == resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getNonQuantifiedValue() ? "" : resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getNonQuantifiedValue());
|
|
|
//指标id
|
|
|
indicatormap.put("ID_" + d.getChildCode() + "_" + d.getOptionCode(), resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getId());
|
|
|
-
|
|
|
+ //是否量化
|
|
|
indicatormap.put("IS_LH_" +d.getChildCode() + "_" + d.getOptionCode(),resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getIsQuantified2());
|
|
|
}
|
|
|
mapList.add(indicatormap);
|
|
@@ -409,6 +413,189 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public byte[] downloadExcel(String organizationEvaluationId, String indicatorId, String binSection, String binStage,HttpServletRequest request) throws Exception{
|
|
|
+
|
|
|
+
|
|
|
+ Map<String ,List<Map<String,String>>> title = new LinkedHashMap();//标题
|
|
|
+ List<Map<String,String>> mapList = new ArrayList<>();//数据list
|
|
|
+ boolean titlemark = true;//标记生成标题
|
|
|
+ List<OrganizationEvaluationInfoResDTO> infoResDTOList = baseMapper.selectEvaluationInfoList(organizationEvaluationId, indicatorId,binSection,binStage);
|
|
|
+ List<IndicatorDictionary> dictionaryList = indicatorDictionaryService.list("", indicatorId, "", "");
|
|
|
+
|
|
|
+ //根据组织(公司)id分组
|
|
|
+ Map<String, List<OrganizationEvaluationInfoResDTO>> groupedData = infoResDTOList.stream()
|
|
|
+ .collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getOrganizationId));
|
|
|
+
|
|
|
+ //遍历按照公司分组后的数据
|
|
|
+ for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> entry : groupedData.entrySet()) {
|
|
|
+
|
|
|
+ Map indicatormap = new LinkedHashMap();
|
|
|
+ List<OrganizationEvaluationInfoResDTO> dtoList = entry.getValue();
|
|
|
+
|
|
|
+ Map<String, OrganizationEvaluationInfoResDTO> resultMap = dtoList.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ dto -> dto.getChildCode() + "_" + dto.getOptionCode(),
|
|
|
+ dto -> dto,
|
|
|
+ (oldValue, newValue) -> oldValue)); // 解决键重复的情况
|
|
|
+ boolean mark = true;//标记给公司名赋值
|
|
|
+
|
|
|
+ //将子指标分组
|
|
|
+ Map<String, List<IndicatorDictionary>> groupedChildCode = dictionaryList.stream()
|
|
|
+ .collect(Collectors.groupingBy(d -> d.getChildCode() + "," + d.getChildName()));
|
|
|
+
|
|
|
+ if (titlemark) {
|
|
|
+ for (Map.Entry<String, List<IndicatorDictionary>> childCodeEntry : groupedChildCode.entrySet()) {
|
|
|
+
|
|
|
+
|
|
|
+ List<Map<String,String>> titleArray = new ArrayList<>();
|
|
|
+ Map titlemap = new LinkedHashMap();
|
|
|
+ for (IndicatorDictionary d : childCodeEntry.getValue()) {
|
|
|
+ if (!d.getIsShow()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ titlemap.put(d.getChildCode()+"_"+d.getOptionCode(), d.getOptionName());//名称
|
|
|
+ titlemap.put("ID_" +d.getChildCode()+"_"+d.getOptionCode(), "ID隐藏");//id
|
|
|
+ titlemap.put("IS_LH_" +d.getChildCode()+"_"+d.getOptionCode(), "是否量化隐藏");//是否量化
|
|
|
+ }
|
|
|
+ titleArray.add(titlemap);
|
|
|
+ title.put(childCodeEntry.getKey().split(",")[1], titleArray);
|
|
|
+
|
|
|
+ }
|
|
|
+ titlemark = false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for (IndicatorDictionary d : dictionaryList) {
|
|
|
+ if (!d.getIsShow()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (mark) {
|
|
|
+ indicatormap.put("organizationShortName", resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getOrganizationShortName());//公司名
|
|
|
+ mark = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println(resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getId());
|
|
|
+ //指标属性
|
|
|
+ indicatormap.put(d.getChildCode() + "_" + d.getOptionCode(), null == resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getNonQuantifiedValue() ? "" : resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getNonQuantifiedValue());
|
|
|
+ //指标id
|
|
|
+ indicatormap.put("ID_" + d.getChildCode() + "_" + d.getOptionCode(), resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getId());
|
|
|
+ //是否量化
|
|
|
+ indicatormap.put("IS_LH_" +d.getChildCode() + "_" + d.getOptionCode(),resultMap.get(d.getChildCode()+"_"+d.getOptionCode()).getIsQuantified2().toString());
|
|
|
+ }
|
|
|
+ mapList.add(indicatormap);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 创建Workbook对象
|
|
|
+ Workbook workbook = new XSSFWorkbook();
|
|
|
+
|
|
|
+ // 创建工作表
|
|
|
+ Sheet sheet = workbook.createSheet(infoResDTOList.get(0).getIndicatorName());
|
|
|
+
|
|
|
+ // 创建单元格样式
|
|
|
+ CellStyle cellStyle = workbook.createCellStyle();
|
|
|
+ cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+
|
|
|
+ // 设置边框样式
|
|
|
+ cellStyle.setBorderTop(BorderStyle.THIN);
|
|
|
+ cellStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
+ cellStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
+ cellStyle.setBorderRight(BorderStyle.THIN);
|
|
|
+
|
|
|
+ // 创建1、2行作为标题行
|
|
|
+ Row headerRow0 = sheet.createRow(0);
|
|
|
+ Row headerRow1 = sheet.createRow(1);
|
|
|
+ Row headerRow2 = sheet.createRow(2);
|
|
|
+ Row headerRow3 = sheet.createRow(3);
|
|
|
+
|
|
|
+
|
|
|
+ // 设置首行的单元格值
|
|
|
+ Cell header0Cell0 = headerRow0.createCell(0);
|
|
|
+ header0Cell0.setCellValue(infoResDTOList.get(0).getIndicatorName());
|
|
|
+
|
|
|
+
|
|
|
+ Cell headerCell0 = headerRow1.createCell(0);
|
|
|
+ headerCell0.setCellValue("序号");
|
|
|
+ headerCell0.setCellStyle(cellStyle);
|
|
|
+ headerCell0.setCellStyle(cellStyle);
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(1, 2, 0, 0));
|
|
|
+
|
|
|
+ Cell headerCell1 = headerRow1.createCell(1);
|
|
|
+ headerCell1.setCellValue("单位名称");
|
|
|
+ headerCell1.setCellStyle(cellStyle);
|
|
|
+ headerCell1.setCellStyle(cellStyle);
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(1, 2, 1, 1));
|
|
|
+
|
|
|
+
|
|
|
+ Integer colsize = 1;
|
|
|
+ Integer optioncols = 2;
|
|
|
+ for (String key : title.keySet()) {//存在多个标题
|
|
|
+ List<Map<String,String>> titleArray2 = title.get(key);
|
|
|
+ Cell headerCellcolsize = headerRow1.createCell(colsize+1);
|
|
|
+ headerCellcolsize.setCellValue(key);
|
|
|
+ headerCellcolsize.setCellStyle(cellStyle);
|
|
|
+ headerCellcolsize.setCellStyle(cellStyle);
|
|
|
+
|
|
|
+ System.out.println("key="+key);
|
|
|
+
|
|
|
+ for (Map<String,String> key2 : titleArray2) {
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(1, 1, colsize+1, colsize + key2.size()));
|
|
|
+ colsize = colsize + key2.size();
|
|
|
+ for (String key3 : key2.keySet()) {
|
|
|
+
|
|
|
+ Cell header3Cell2 = headerRow3.createCell(optioncols);
|
|
|
+ header3Cell2.setCellValue(key3);
|
|
|
+ header3Cell2.setCellStyle(cellStyle);
|
|
|
+
|
|
|
+ Cell header2Cell2 = headerRow2.createCell(optioncols);
|
|
|
+ header2Cell2.setCellValue(key2.get(key3));
|
|
|
+ header2Cell2.setCellStyle(cellStyle);
|
|
|
+
|
|
|
+ // 隐藏列
|
|
|
+ if(key3.startsWith("ID_") || key3.startsWith("IS_LH_")){
|
|
|
+ sheet.setColumnHidden(optioncols, true);
|
|
|
+ }
|
|
|
+ optioncols++;
|
|
|
+ System.out.println(key2.get(key3)+"="+key3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer rowdate = 4;
|
|
|
+ for (Map<String,String > datamaps : mapList) {
|
|
|
+ Integer colsdata = 1;
|
|
|
+ Row headerRowdate = sheet.createRow(rowdate);
|
|
|
+ Cell dataCell0 = headerRowdate.createCell(0);
|
|
|
+ dataCell0.setCellValue(rowdate-3);
|
|
|
+ dataCell0.setCellStyle(cellStyle);
|
|
|
+ for (String datakey: datamaps.keySet()) {
|
|
|
+
|
|
|
+ Cell dataCell1 = headerRowdate.createCell(colsdata);
|
|
|
+ dataCell1.setCellValue(datamaps.get(datakey).toString());
|
|
|
+ dataCell1.setCellStyle(cellStyle);
|
|
|
+ colsdata++;
|
|
|
+ }
|
|
|
+ rowdate++;
|
|
|
+ }
|
|
|
+
|
|
|
+ //隐藏行
|
|
|
+ sheet.getRow(3).setZeroHeight(true);
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, colsize));
|
|
|
+ header0Cell0.setCellStyle(cellStyle);
|
|
|
+
|
|
|
+ // 将Workbook写入字节数组输出流
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
+ workbook.write(outputStream);
|
|
|
+
|
|
|
+
|
|
|
+ // 将字节数组作为响应体返回,并设置响应头
|
|
|
+ byte[] excelBytes = outputStream.toByteArray();
|
|
|
+ return excelBytes;
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public boolean updateEvaluationInfo(List<JSONObject> jsonObjects) {
|
|
@@ -425,7 +612,6 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
List<OrganizationEvaluationInfo> evaluationInfos =new ArrayList<>();
|
|
|
for (Map.Entry<String,Object > entry : idMap.entrySet()) {
|
|
|
OrganizationEvaluationInfo info = new OrganizationEvaluationInfo();
|