浏览代码

单位营业收入功能完善

hlf 11 月之前
父节点
当前提交
b0f02d5728
共有 1 个文件被更改,包括 68 次插入32 次删除
  1. 68 32
      ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/MultipleBrandServiceImpl.java

+ 68 - 32
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/MultipleBrandServiceImpl.java

@@ -5,16 +5,21 @@ 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.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.dto.result.R;
+import com.ims.eval.service.IBinSectionService;
 import com.ims.eval.service.IMultipleBrandService;
+import com.ims.eval.service.IOrganizationStructureService;
 import com.ims.eval.util.ExcelUtil;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -38,6 +43,12 @@ import java.util.stream.Collectors;
 @Service
 public class MultipleBrandServiceImpl extends ServiceImpl<MultipleBrandMapper, MultipleBrand> implements IMultipleBrandService {
 
+	@Autowired
+	private IOrganizationStructureService organizationStructureService;
+
+	@Autowired
+	private IBinSectionService binSectionService;
+
 	@Override
 	public IPage<MultipleBrand> getMultipleBranTree(Integer pageNum, Integer pageSize, String id, String parentId, String binSection, String checkCycle, String year, String month) {
 		Page<Indicator> page = new Page<>(pageNum, pageSize);
@@ -88,28 +99,21 @@ public class MultipleBrandServiceImpl extends ServiceImpl<MultipleBrandMapper, M
 
 		// 填充数据到工作表
 		int rowIndex = 1; // 从第二行开始填充数据(第一行是表头)
-		for (MultipleBrand multipleBrand : multipleBrandList) {
-			Row row = sheet.createRow(rowIndex++);
-
-			// 设置ID
-			row.createCell(0).setCellValue(multipleBrand.getId());
-
-			// 设置其他数据
-			row.createCell(1).setCellValue(multipleBrand.getOrganizationName());
-			row.createCell(2).setCellValue(multipleBrand.getBinSectionName());
-			if ("NDKP".equals(multipleBrand.getCheckCycle())) {
-				checkCycle = "年度考评";
-			} else if ("JDKP".equals(multipleBrand.getCheckCycle())) {
-				checkCycle = "季度考评";
-			} else if ("YDKP".equals(multipleBrand.getCheckCycle())) {
-				checkCycle = "月度考评";
+		for (MultipleBrand rootMultipleBrand : multipleBrandList) {
+			Row parentRow = sheet.createRow(rowIndex++);
+			writeRow(parentRow, rootMultipleBrand);
+
+			for (MultipleBrand childMultipleBrand : rootMultipleBrand.getChildren()) {
+				Row childRow = sheet.createRow(rowIndex++);
+				writeRow(childRow, childMultipleBrand);
 			}
-			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());
+
+			rowIndex++;
+		}
+
+		// 自动调整列宽
+		for (int i = 0; i < headers.size(); i++) {
+			sheet.autoSizeColumn(i);
 		}
 
 		// 隐藏第一列(ID列)
@@ -140,7 +144,7 @@ public class MultipleBrandServiceImpl extends ServiceImpl<MultipleBrandMapper, M
 
 		// 创建表头
 		Row headerRow = sheet.createRow(0);
-		List<String> headers = Arrays.asList("单位名称", "业务属性", "考评周期", "利润金额", "分数", "年", "月", "备注");
+		List<String> headers = Arrays.asList("单位名称", "上级单位名称", "业务属性", "考评周期", "利润金额", "分数", "年", "月", "备注");
 		for (int i = 0; i < headers.size(); i++) {
 			Cell cell = headerRow.createCell(i);
 			cell.setCellValue(headers.get(i));
@@ -182,16 +186,28 @@ public class MultipleBrandServiceImpl extends ServiceImpl<MultipleBrandMapper, M
 						multipleBrand.setRemark(str[8]);
 						multipleBrandList.add(multipleBrand);
 					} else {
-						/*multipleBrand.setOrganizationId();
-						multipleBrand.setOrganizationName();
-						multipleBrand.setParentId();
-						multipleBrand.setProfit();
-						multipleBrand.setScore();
-						multipleBrand.setBinSection();
-						multipleBrand.setCheckCycle();
-						multipleBrand.setYear();
-						multipleBrand.setMonth();
-						multipleBrand.setRemark();*/
+						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);
 					}
 				}
@@ -258,4 +274,24 @@ public class MultipleBrandServiceImpl extends ServiceImpl<MultipleBrandMapper, M
 		}
 		return treeSelectVO;
 	}
+
+	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());
+		String checkCycle = "";
+		if ("NDKP".equals(multipleBrand.getCheckCycle())) {
+			checkCycle = "年度考评";
+		} else if ("JDKP".equals(multipleBrand.getCheckCycle())) {
+			checkCycle = "季度考评";
+		} 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());
+	}
 }