|
@@ -1,14 +1,13 @@
|
|
|
package com.ims.eval.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.ims.common.utils.StringUtils;
|
|
|
import com.ims.eval.dao.MultipleBrandMapper;
|
|
|
-import com.ims.eval.entity.BinSection;
|
|
|
-import com.ims.eval.entity.Indicator;
|
|
|
-import com.ims.eval.entity.MultipleBrand;
|
|
|
-import com.ims.eval.entity.OrganizationStructure;
|
|
|
+import com.ims.eval.entity.*;
|
|
|
import com.ims.eval.entity.dto.result.R;
|
|
|
import com.ims.eval.service.IBinSectionService;
|
|
|
import com.ims.eval.service.IMultipleBrandService;
|
|
@@ -86,7 +85,7 @@ public class MultipleBrandServiceImpl extends ServiceImpl<MultipleBrandMapper, M
|
|
|
|
|
|
// 创建表头
|
|
|
Row headerRow = sheet.createRow(0);
|
|
|
- List<String> headers = Arrays.asList("ID", "单位名称", "业务属性", "考评周期", "利润金额", "分数", "年", "月", "备注");
|
|
|
+ List<String> headers = Arrays.asList("单位名称", "业务属性", "考评周期", "利润金额", "分数", "年", "月", "备注");
|
|
|
for (int i = 0; i < headers.size(); i++) {
|
|
|
Cell cell = headerRow.createCell(i);
|
|
|
cell.setCellValue(headers.get(i));
|
|
@@ -116,9 +115,6 @@ public class MultipleBrandServiceImpl extends ServiceImpl<MultipleBrandMapper, M
|
|
|
sheet.autoSizeColumn(i);
|
|
|
}
|
|
|
|
|
|
- // 隐藏第一列(ID列)
|
|
|
- sheet.setColumnHidden(0, true);
|
|
|
-
|
|
|
// 将工作簿写入到输出流
|
|
|
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
|
|
workbook.write(outputStream);
|
|
@@ -179,36 +175,37 @@ public class MultipleBrandServiceImpl extends ServiceImpl<MultipleBrandMapper, M
|
|
|
//遍历Excel表每一行的数据
|
|
|
for (String[] str : strings) {
|
|
|
MultipleBrand multipleBrand = new MultipleBrand();
|
|
|
- if (OrganizationEvaluationRuleServiceImpl.verifyID(str[0])) {
|
|
|
- multipleBrand.setId(str[0]);
|
|
|
- multipleBrand.setProfit(Double.valueOf(str[4]));
|
|
|
- multipleBrand.setScore(Double.valueOf(str[5]));
|
|
|
- multipleBrand.setRemark(str[8]);
|
|
|
- multipleBrandList.add(multipleBrand);
|
|
|
- } else {
|
|
|
- List<OrganizationStructure> organizationStructureList = organizationStructureService.getList2("", null, "");
|
|
|
- OrganizationStructure organizationStructure0 = organizationStructureList.stream().filter(item -> item.getShortName().equals(str[0])).findFirst().orElse(null);
|
|
|
- if (null != organizationStructure0) {
|
|
|
- multipleBrand.setOrganizationId(organizationStructure0.getId());
|
|
|
- multipleBrand.setOrganizationName(organizationStructure0.getName());
|
|
|
- }
|
|
|
- if (null != str[1] && !"".equals(str[1])){
|
|
|
- OrganizationStructure organizationStructure1 = organizationStructureList.stream().filter(item -> item.getShortName().equals(str[1])).findFirst().orElse(null);
|
|
|
- if (null != organizationStructure1) {
|
|
|
- multipleBrand.setParentId(organizationStructure1.getId());
|
|
|
+ BinSection binSection = binSectionService.getBinSectionBySectionName(str[2]);
|
|
|
+ if (null != binSection) {
|
|
|
+ MultipleBrand obj = this.checkForExistence(str[0], OrganizationEvaluationRuleServiceImpl.toFullSpell(str[3]), binSection.getId(), str[6], str[7]);
|
|
|
+ if (null != obj) {
|
|
|
+ multipleBrand.setId(obj.getId());
|
|
|
+ multipleBrand.setProfit(Double.valueOf(str[4]));
|
|
|
+ multipleBrand.setScore(Double.valueOf(str[5]));
|
|
|
+ multipleBrand.setRemark(str[8]);
|
|
|
+ multipleBrandList.add(multipleBrand);
|
|
|
+ } else {
|
|
|
+ List<OrganizationStructure> organizationStructureList = organizationStructureService.getList2("", null, "");
|
|
|
+ OrganizationStructure organizationStructure0 = organizationStructureList.stream().filter(item -> item.getShortName().equals(str[0])).findFirst().orElse(null);
|
|
|
+ if (null != organizationStructure0) {
|
|
|
+ multipleBrand.setOrganizationId(organizationStructure0.getId());
|
|
|
+ multipleBrand.setOrganizationName(organizationStructure0.getName());
|
|
|
+ }
|
|
|
+ if (null != str[1] && !"".equals(str[1])) {
|
|
|
+ OrganizationStructure organizationStructure1 = organizationStructureList.stream().filter(item -> item.getShortName().equals(str[1])).findFirst().orElse(null);
|
|
|
+ if (null != organizationStructure1) {
|
|
|
+ multipleBrand.setParentId(organizationStructure1.getId());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- BinSection binSection = binSectionService.getBinSectionBySectionName(str[2]);
|
|
|
- if (null != binSection){
|
|
|
multipleBrand.setBinSection(binSection.getId());
|
|
|
+ multipleBrand.setCheckCycle(OrganizationEvaluationRuleServiceImpl.toFullSpell(str[3]));
|
|
|
+ multipleBrand.setProfit(Double.valueOf(str[4]));
|
|
|
+ multipleBrand.setScore(Double.valueOf(str[5]));
|
|
|
+ multipleBrand.setYear(str[6]);
|
|
|
+ multipleBrand.setMonth(str[7]);
|
|
|
+ multipleBrand.setRemark(str[8]);
|
|
|
+ multipleBrandList.add(multipleBrand);
|
|
|
}
|
|
|
- multipleBrand.setCheckCycle(OrganizationEvaluationRuleServiceImpl.toFullSpell(str[3]));
|
|
|
- multipleBrand.setProfit(Double.valueOf(str[4]));
|
|
|
- multipleBrand.setScore(Double.valueOf(str[5]));
|
|
|
- multipleBrand.setYear(str[6]);
|
|
|
- multipleBrand.setMonth(str[7]);
|
|
|
- multipleBrand.setRemark(str[8]);
|
|
|
- multipleBrandList.add(multipleBrand);
|
|
|
}
|
|
|
}
|
|
|
boolean b = super.saveOrUpdateBatch(multipleBrandList);
|
|
@@ -224,6 +221,26 @@ public class MultipleBrandServiceImpl extends ServiceImpl<MultipleBrandMapper, M
|
|
|
return R.error("上传文件为空!");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public MultipleBrand checkForExistence(String organizationName, String checkCycle, String binSection, String year, String month) {
|
|
|
+ QueryWrapper<MultipleBrand> qw = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotEmpty(organizationName)) {
|
|
|
+ qw.lambda().eq(MultipleBrand::getOrganizationName, organizationName);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(checkCycle)) {
|
|
|
+ qw.lambda().eq(MultipleBrand::getCheckCycle, checkCycle);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(binSection)) {
|
|
|
+ qw.lambda().eq(MultipleBrand::getBinSection, binSection);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(year)) {
|
|
|
+ qw.lambda().eq(MultipleBrand::getYear, year);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(month)) {
|
|
|
+ qw.lambda().eq(MultipleBrand::getMonth, month);
|
|
|
+ }
|
|
|
+ return baseMapper.selectOne(qw);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 转换为有树形结构的列表
|
|
@@ -276,9 +293,8 @@ public class MultipleBrandServiceImpl extends ServiceImpl<MultipleBrandMapper, M
|
|
|
}
|
|
|
|
|
|
private static void writeRow(Row row, MultipleBrand multipleBrand) {
|
|
|
- row.createCell(0).setCellValue(multipleBrand.getId());
|
|
|
- row.createCell(1).setCellValue(multipleBrand.getOrganizationName());
|
|
|
- row.createCell(2).setCellValue(multipleBrand.getBinSectionName());
|
|
|
+ row.createCell(0).setCellValue(multipleBrand.getOrganizationName());
|
|
|
+ row.createCell(1).setCellValue(multipleBrand.getBinSectionName());
|
|
|
String checkCycle = "";
|
|
|
if ("NDKP".equals(multipleBrand.getCheckCycle())) {
|
|
|
checkCycle = "年度考评";
|
|
@@ -287,11 +303,11 @@ public class MultipleBrandServiceImpl extends ServiceImpl<MultipleBrandMapper, M
|
|
|
} else if ("YDKP".equals(multipleBrand.getCheckCycle())) {
|
|
|
checkCycle = "月度考评";
|
|
|
}
|
|
|
- row.createCell(3).setCellValue(checkCycle);
|
|
|
- row.createCell(4).setCellValue(multipleBrand.getProfit());
|
|
|
- row.createCell(5).setCellValue(multipleBrand.getScore());
|
|
|
- row.createCell(6).setCellValue(multipleBrand.getYear());
|
|
|
- row.createCell(7).setCellValue(multipleBrand.getMonth());
|
|
|
- row.createCell(8).setCellValue(multipleBrand.getRemark());
|
|
|
+ row.createCell(2).setCellValue(checkCycle);
|
|
|
+ row.createCell(3).setCellValue(multipleBrand.getProfit());
|
|
|
+ row.createCell(4).setCellValue(multipleBrand.getScore());
|
|
|
+ row.createCell(5).setCellValue(multipleBrand.getYear());
|
|
|
+ row.createCell(6).setCellValue(multipleBrand.getMonth());
|
|
|
+ row.createCell(7).setCellValue(multipleBrand.getRemark());
|
|
|
}
|
|
|
}
|