浏览代码

单位权重配置导入导出

hlf 11 月之前
父节点
当前提交
3c68a2d8e8

+ 58 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/controller/EvaluateRuleController.java

@@ -3,13 +3,20 @@ package com.ims.eval.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ims.eval.config.CustomException;
-import com.ims.eval.entity.dto.result.R;
 import com.ims.eval.entity.EvaluateRule;
+import com.ims.eval.entity.dto.result.R;
 import com.ims.eval.service.IEvaluateRuleService;
+import com.ims.eval.util.ExcelUtil;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -118,4 +125,54 @@ public class EvaluateRuleController {
 			return R.error().data("删除失败!");
 		}
 	}
+
+	/**
+	 * 导出
+	 */
+	@GetMapping(value = "/exportExcel", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
+	public void exportExcel(@RequestParam(value = "binSection", required = false) String binSection,
+							@RequestParam(value = "checkCycle", required = false) String checkCycle,
+							@RequestParam(value = "year", required = false) String year,
+							HttpServletResponse response) throws IOException {
+		evaluateRuleService.exportExcel(binSection, checkCycle, year, response);
+	}
+
+	/**
+	 * 导入
+	 */
+	@PostMapping(value = "/importExcel")
+	public R importExcel(@RequestParam("file") MultipartFile file) {
+		if (!file.isEmpty()) {
+			try {
+				//获取原始的文件名
+				String originalFilename = file.getOriginalFilename();
+				//获取文件类型
+				String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1, originalFilename.length());
+				//默认从第一行开始读取
+				int startRows = 1;
+				//获取输入流
+				InputStream is = file.getInputStream();
+				List<EvaluateRule> evaluateRuleList = new ArrayList<>();
+				//Excel导入导出的单元类
+				List<String[]> strings = ExcelUtil.readData(fileType, startRows, true, is);
+				//遍历Excel表每一行的数据
+				for (String[] str : strings) {
+					EvaluateRule evaluateRule = new EvaluateRule();
+					evaluateRule.setId(str[0]);
+					evaluateRule.setRuleName(str[1]);
+					evaluateRule.setDes(str[6]);
+					evaluateRuleList.add(evaluateRule);
+				}
+				boolean b = evaluateRuleService.updateBatchById(evaluateRuleList);
+				if (b) {
+					return R.ok().data(b);
+				} else {
+					return R.error("导入失败!");
+				}
+			} catch (Exception e) {
+				return R.customError(e.getMessage()).data("失败!");
+			}
+		}
+		return R.error("上传文件为空!");
+	}
 }

+ 44 - 14
ims-service/ims-eval/src/main/java/com/ims/eval/controller/OrganizationEvaluationRuleController.java

@@ -2,7 +2,6 @@ package com.ims.eval.controller;
 
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
-
 import com.ims.eval.cache.CacheContext;
 import com.ims.eval.config.CustomException;
 import com.ims.eval.entity.OrganizationEvaluationRule;
@@ -10,8 +9,12 @@ import com.ims.eval.entity.dto.result.R;
 import com.ims.eval.service.IOrganizationEvaluationRuleService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
 
@@ -59,23 +62,23 @@ public class OrganizationEvaluationRuleController {
 				  @RequestParam(value = "binStage", required = false) String binStage,
 				  @RequestParam(value = "evaluationCycle", required = false) String evaluationCycle,
 				  @RequestParam(value = "year", required = false) String year) {
-		IPage<OrganizationEvaluationRule> list = organizationEvaluationRuleService.list2(pageNum, pageSize, id, organizationName, organizationId, organizationType, binSection, binStage, evaluationCycle,year);
+		IPage<OrganizationEvaluationRule> list = organizationEvaluationRuleService.list2(pageNum, pageSize, id, organizationName, organizationId, organizationType, binSection, binStage, evaluationCycle, year);
 		return R.ok().data(list);
 	}
 
 
 	@GetMapping(value = "list2")
 	public R list2(@RequestParam(value = "pageNum") Integer pageNum,
-				  @RequestParam(value = "pageSize") Integer pageSize,
-				  @RequestParam(value = "id", required = false) String id,
-				  @RequestParam(value = "organizationName", required = false) String organizationName,
-				  @RequestParam(value = "organizationId", required = false) String organizationId,
-				  @RequestParam(value = "organizationType", required = false) String organizationType,
-				  @RequestParam(value = "binSection", required = false) String binSection,
-				  @RequestParam(value = "binStage", required = false) String binStage,
-				  @RequestParam(value = "evaluationCycle", required = false) String evaluationCycle,
-				  @RequestParam(value = "year", required = false) String year) {
-		IPage<OrganizationEvaluationRule> list = organizationEvaluationRuleService.list(pageNum, pageSize, id, organizationName, organizationId, organizationType, binSection, binStage, evaluationCycle,year);
+				   @RequestParam(value = "pageSize") Integer pageSize,
+				   @RequestParam(value = "id", required = false) String id,
+				   @RequestParam(value = "organizationName", required = false) String organizationName,
+				   @RequestParam(value = "organizationId", required = false) String organizationId,
+				   @RequestParam(value = "organizationType", required = false) String organizationType,
+				   @RequestParam(value = "binSection", required = false) String binSection,
+				   @RequestParam(value = "binStage", required = false) String binStage,
+				   @RequestParam(value = "evaluationCycle", required = false) String evaluationCycle,
+				   @RequestParam(value = "year", required = false) String year) {
+		IPage<OrganizationEvaluationRule> list = organizationEvaluationRuleService.list(pageNum, pageSize, id, organizationName, organizationId, organizationType, binSection, binStage, evaluationCycle, year);
 		return R.ok().data(list);
 	}
 
@@ -102,7 +105,7 @@ public class OrganizationEvaluationRuleController {
 		@RequestParam(value = "binStage", required = false) String binStage,
 		@RequestParam(value = "evaluationCycle", required = false) String evaluationCycle,
 		@RequestParam(value = "year", required = false) String year) {
-		List<OrganizationEvaluationRule> list = organizationEvaluationRuleService.listAll(id, organizationName, organizationId, organizationType, binSection, binStage, evaluationCycle,year);
+		List<OrganizationEvaluationRule> list = organizationEvaluationRuleService.listAll(id, organizationName, organizationId, organizationType, binSection, binStage, evaluationCycle, year);
 		return R.ok().data(list);
 	}
 
@@ -155,6 +158,7 @@ public class OrganizationEvaluationRuleController {
 
 	/**
 	 * 更具目标责任书获取对应的组织考评股则id
+	 *
 	 * @param id
 	 * @param type (目标责任书:mb;考评记录:kp)
 	 * @return
@@ -163,9 +167,35 @@ public class OrganizationEvaluationRuleController {
 	public R getOrganizationRule(
 		@RequestParam(value = "id", required = false) String id,
 		@RequestParam(value = "type", required = true) String type) {
-		List<OrganizationEvaluationRule>  list = organizationEvaluationRuleService.getOrganizationRuleId(id,type);
+		List<OrganizationEvaluationRule> list = organizationEvaluationRuleService.getOrganizationRuleId(id, type);
 		return R.ok().data(list);
 	}
 
+	/**
+	 * 导出
+	 */
+	@GetMapping(value = "/exportExcel", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
+	public void exportExcel(@RequestParam(value = "organizationName", required = false) String organizationName,
+							@RequestParam(value = "binSection", required = false) String binSection,
+							@RequestParam(value = "evaluationCycle", required = false) String evaluationCycle,
+							@RequestParam(value = "year", required = false) String year,
+							HttpServletResponse response) throws IOException {
+		organizationEvaluationRuleService.exportExcel(organizationName, binSection, evaluationCycle, year, response);
+	}
+
+	/**
+	 * 导入模板
+	 */
+	@GetMapping(value = "/importTemplate", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
+	public void importTemplate(HttpServletResponse response) throws IOException {
+		organizationEvaluationRuleService.importTemplate(response);
+	}
 
+	/**
+	 * 导入
+	 */
+	@PostMapping(value = "/importExcel")
+	public R importExcel(@RequestParam("file") MultipartFile file) {
+		return organizationEvaluationRuleService.importExcel(file);
+	}
 }

+ 6 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/IEvaluateRuleService.java

@@ -5,6 +5,8 @@ import com.ims.eval.entity.EvaluateRule;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ims.eval.entity.dto.response.EvaluateRuleInfoResDTO;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -33,4 +35,8 @@ public interface IEvaluateRuleService extends IService<EvaluateRule> {
 	List<EvaluateRule> getEvaluateRuleList(String binSection, String binStage, String checkCycle, String year);
 
 	EvaluateRule getEvaluateRuleListByYear(String year, String checkCycle, String manageCategory);
+
+	void exportExcel(String binSection, String checkCycle, String year, HttpServletResponse response) throws IOException;
+
+	EvaluateRule getEvaluateRuleByRuleName(String evaluateRuleName, String year);
 }

+ 9 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/service/IOrganizationEvaluationRuleService.java

@@ -1,10 +1,13 @@
 package com.ims.eval.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.ims.eval.entity.OrganizationEvaluationRule;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.ims.eval.entity.dto.request.OrganizationEvaluationRuleDTO;
+import com.ims.eval.entity.OrganizationEvaluationRule;
+import com.ims.eval.entity.dto.result.R;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -38,5 +41,9 @@ public interface IOrganizationEvaluationRuleService extends IService<Organizatio
 	List<OrganizationEvaluationRule> getOrganizationEvaluationRuleByYearAndCycle(String organizationType,String evaluationCycle, String year,String organizationId);
 
 
+    void exportExcel(String organizationName, String binSection, String evaluationCycle, String year, HttpServletResponse response) throws IOException;
+
+	void importTemplate(HttpServletResponse response) throws IOException;
 
+	R importExcel(MultipartFile file);
 }

+ 81 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluateRuleServiceImpl.java

@@ -3,16 +3,24 @@ package com.ims.eval.service.impl;
 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.cache.CacheContext;
 import com.ims.eval.config.CustomException;
-import com.ims.eval.entity.EvaluateRule;
 import com.ims.eval.dao.EvaluateRuleMapper;
+import com.ims.eval.entity.EvaluateRule;
 import com.ims.eval.entity.dto.response.EvaluateRuleInfoResDTO;
 import com.ims.eval.service.IEvaluateRuleService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+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.stereotype.Service;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -223,4 +231,75 @@ public class EvaluateRuleServiceImpl extends ServiceImpl<EvaluateRuleMapper, Eva
 		}
 		return baseMapper.getEvaluateRuleListByYear(year, checkCycle, manageCategory);
 	}
+
+	@Override
+	public void exportExcel(String binSection, String checkCycle, String year, HttpServletResponse response) throws IOException {
+		// 设置响应头信息,以附件形式下载
+		response.setHeader("Content-Disposition", "attachment; filename=evaluate_rule_data.xlsx");
+		response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+
+		// 创建新的Excel工作簿
+		Workbook workbook = new XSSFWorkbook();
+
+		// 创建新的工作表
+		Sheet sheet = workbook.createSheet("Sheet1");
+
+		// 创建表头
+		Row headerRow = sheet.createRow(0);
+		List<String> headers = Arrays.asList("ID", "规则名称", "业务阶段", "业务属性", "考评周期", "年份", "描述");
+		for (int i = 0; i < headers.size(); i++) {
+			Cell cell = headerRow.createCell(i);
+			cell.setCellValue(headers.get(i));
+		}
+
+		//行数据
+		List<EvaluateRule> evaluateRuleList = baseMapper.selectEvaluateRuleList(binSection, "", checkCycle, year);
+
+		// 填充数据到工作表
+		int rowIndex = 1; // 从第二行开始填充数据(第一行是表头)
+		for (EvaluateRule evaluateRule : evaluateRuleList) {
+			Row row = sheet.createRow(rowIndex++);
+
+			// 设置ID
+			row.createCell(0).setCellValue(evaluateRule.getId());
+
+			// 设置其他数据
+			row.createCell(1).setCellValue(evaluateRule.getRuleName());
+			row.createCell(2).setCellValue(evaluateRule.getBinStageName());
+			row.createCell(3).setCellValue(evaluateRule.getBinSectionName());
+			if ("NDKP".equals(evaluateRule.getCheckCycle())){
+				checkCycle = "年度考评";
+			}else {
+				checkCycle = "月/季度考评";
+			}
+			row.createCell(4).setCellValue(checkCycle);
+			row.createCell(5).setCellValue(evaluateRule.getYear());
+			row.createCell(6).setCellValue(evaluateRule.getDes());
+		}
+
+		// 隐藏第一列(ID列)
+		sheet.setColumnHidden(0, true);
+
+		// 将工作簿写入到输出流
+		try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
+			workbook.write(outputStream);
+			response.getOutputStream().write(outputStream.toByteArray());
+			response.getOutputStream().flush();
+		}
+
+		// 关闭工作簿
+		workbook.close();
+	}
+
+	@Override
+	public EvaluateRule getEvaluateRuleByRuleName(String evaluateRuleName, String year) {
+		QueryWrapper<EvaluateRule> qw = new QueryWrapper<>();
+		if (StringUtils.isNotEmpty(evaluateRuleName)) {
+			qw.lambda().eq(EvaluateRule::getRuleName, evaluateRuleName);
+		}
+		if (StringUtils.isNotEmpty(year)) {
+			qw.lambda().eq(EvaluateRule::getYear, year);
+		}
+		return baseMapper.selectOne(qw);
+	}
 }

+ 290 - 51
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationEvaluationRuleServiceImpl.java

@@ -8,15 +8,29 @@ import com.ims.eval.cache.CacheContext;
 import com.ims.eval.config.CustomException;
 import com.ims.eval.entity.*;
 import com.ims.eval.dao.OrganizationEvaluationRuleMapper;
-import com.ims.eval.service.IDeptResponsibilityService;
-import com.ims.eval.service.IEvaluateRuleService;
-import com.ims.eval.service.IOrganizationEvaluationRuleService;
+import com.ims.eval.entity.dto.result.R;
+import com.ims.eval.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ims.eval.service.IOrganizationEvaluationService;
+import com.ims.eval.util.ExcelUtil;
+import net.sourceforge.pinyin4j.PinyinHelper;
+import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
+import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
+import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
+import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
+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.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.Serializable;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -32,17 +46,17 @@ import java.util.stream.Collectors;
 @Service
 public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<OrganizationEvaluationRuleMapper, OrganizationEvaluationRule> implements IOrganizationEvaluationRuleService {
 
-
 	@Autowired
 	private IEvaluateRuleService evaluateRuleService;
 
 	@Autowired
 	private IOrganizationEvaluationService organizationEvaluationService;
 
-
 	@Autowired
 	private IDeptResponsibilityService deptResponsibilityService;
 
+	@Autowired
+	private IOrganizationStructureService organizationStructureService;
 
 	@Override
 	public IPage<OrganizationEvaluationRule> list(Integer pageNum, Integer pageSize, String id, String organizationName, String organizationId, String organizationType, String binSection, String binStage, String evaluationCycle, String year) {
@@ -90,8 +104,8 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 
 		IPage<OrganizationEvaluationRule> list = baseMapper.selectPage(page, qw);
 
-		list.getRecords().stream().forEach(l->{
-			l.setBinSectionName(null == CacheContext.ddNameMap.get(l.getBinSection()) ? "" :CacheContext.ddNameMap.get(l.getBinSection()));
+		list.getRecords().stream().forEach(l -> {
+			l.setBinSectionName(null == CacheContext.ddNameMap.get(l.getBinSection()) ? "" : CacheContext.ddNameMap.get(l.getBinSection()));
 		});
 
 
@@ -102,31 +116,31 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 	public List<OrganizationEvaluationRule> listAll(String id, String organizationName, String organizationId, String organizationType, String binSection, String binStage, String evaluationCycle, String year) {
 
 
-		List<OrganizationEvaluationRule> list = baseMapper.selectListAll(id, organizationName, organizationId, organizationType, binSection, binStage, evaluationCycle,year);
+		List<OrganizationEvaluationRule> list = baseMapper.selectListAll(id, organizationName, organizationId, organizationType, binSection, binStage, evaluationCycle, year);
 
-		List<EvaluateRule> dtoList = evaluateRuleService.getEvaluateRuleList("","","",year);
+		List<EvaluateRule> dtoList = evaluateRuleService.getEvaluateRuleList("", "", "", year);
 		Map<String, EvaluateRule> dtoMap = dtoList.stream().collect(Collectors.toMap(EvaluateRule::getId, dto -> dto));
 
 		try {
-			list().stream().forEach(l->{
-				l.setBinSectionName(null == CacheContext.ddNameMap.get(l.getBinSection()) ? "" :CacheContext.ddNameMap.get(l.getBinSection()));
+			list().stream().forEach(l -> {
+				l.setBinSectionName(null == CacheContext.ddNameMap.get(l.getBinSection()) ? "" : CacheContext.ddNameMap.get(l.getBinSection()));
 
-				StringBuilder binStageName =  new StringBuilder();
-				for (String stage : l.getBinStage().split(",")){
-					binStageName.append(null == CacheContext.ddNameMap.get(stage) ? "" :CacheContext.ddNameMap.get(stage)).append(",");
+				StringBuilder binStageName = new StringBuilder();
+				for (String stage : l.getBinStage().split(",")) {
+					binStageName.append(null == CacheContext.ddNameMap.get(stage) ? "" : CacheContext.ddNameMap.get(stage)).append(",");
 				}
 
-				l.setBinStageName(binStageName.toString().length()>0?binStageName.toString().substring(0,binStageName.toString().length()-1):"");
+				l.setBinStageName(binStageName.toString().length() > 0 ? binStageName.toString().substring(0, binStageName.toString().length() - 1) : "");
 
 				StringBuilder ruleName = new StringBuilder();
 
-				for (String ruleId :l.getEvaluateRuleId().split(",")){
+				for (String ruleId : l.getEvaluateRuleId().split(",")) {
 					EvaluateRule rulebyid = dtoMap.get(ruleId);
-					if(null != rulebyid){
+					if (null != rulebyid) {
 						ruleName.append(rulebyid.getRuleName()).append(",");
 					}
 				}
-				l.setEvaluateRuleName(ruleName.toString().length()>0?ruleName.toString().substring(0,ruleName.toString().length()-1):"");
+				l.setEvaluateRuleName(ruleName.toString().length() > 0 ? ruleName.toString().substring(0, ruleName.toString().length() - 1) : "");
 
 			});
 		} catch (Exception e) {
@@ -139,25 +153,25 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 	@Override
 	public IPage<OrganizationEvaluationRule> list2(Integer pageNum, Integer pageSize, String id, String organizationName, String organizationId, String organizationType, String binSection, String binStage, String evaluationCycle, String year) {
 		Page<OrganizationEvaluationRule> page = new Page<>(pageNum, pageSize);
-		IPage<OrganizationEvaluationRule>  list = baseMapper.list(page, id, organizationName, organizationId, organizationType, binSection, binStage, evaluationCycle,year);
-		list.getRecords().stream().forEach(l->{
+		IPage<OrganizationEvaluationRule> list = baseMapper.list(page, id, organizationName, organizationId, organizationType, binSection, binStage, evaluationCycle, year);
+		list.getRecords().stream().forEach(l -> {
 
-			StringBuilder binStageName =  new StringBuilder();
-			for (String stage : l.getBinStage().split(",")){
-				binStageName.append(null == CacheContext.bseIdMap.get(stage) ? "" :CacheContext.bseIdMap.get(stage)).append(",");
+			StringBuilder binStageName = new StringBuilder();
+			for (String stage : l.getBinStage().split(",")) {
+				binStageName.append(null == CacheContext.bseIdMap.get(stage) ? "" : CacheContext.bseIdMap.get(stage)).append(",");
 			}
 
-			l.setBinStageName(binStageName.toString().length()>0?binStageName.toString().substring(0,binStageName.toString().length()-1):"");
+			l.setBinStageName(binStageName.toString().length() > 0 ? binStageName.toString().substring(0, binStageName.toString().length() - 1) : "");
 
 			StringBuilder ruleName = new StringBuilder();
-			for (String ruleId :l.getEvaluateRuleId().split(",")){
+			for (String ruleId : l.getEvaluateRuleId().split(",")) {
 				EvaluateRule rulebyid = evaluateRuleService.getById(ruleId);
-				if(null != rulebyid){
+				if (null != rulebyid) {
 					ruleName.append(rulebyid.getRuleName()).append(",");
 				}
 
 			}
-			l.setEvaluateRuleName(ruleName.toString().length()>0?ruleName.toString().substring(0,ruleName.toString().length()-1):"");
+			l.setEvaluateRuleName(ruleName.toString().length() > 0 ? ruleName.toString().substring(0, ruleName.toString().length() - 1) : "");
 
 		});
 		return list;
@@ -165,7 +179,7 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 
 
 	@Override
-	public List<OrganizationEvaluationRule> listByIsCheck(String organizationType,String evaluationCycle, String year,Boolean isCheck, Boolean delFlag) {
+	public List<OrganizationEvaluationRule> listByIsCheck(String organizationType, String evaluationCycle, String year, Boolean isCheck, Boolean delFlag) {
 
 		if (StringUtils.isEmpty(organizationType) || StringUtils.isEmpty(evaluationCycle)) {
 			throw new CustomException("获取考评配置时,考评类型为空");
@@ -202,23 +216,23 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 	public List<OrganizationEvaluationRule> getOrganizationRuleId(String evalOrRespId, String type) {
 
 		List<String> ids = new ArrayList<>();
-		if("mb".equals(type)){
-			DeptResponsibility deptResponsibility  = deptResponsibilityService.getById(evalOrRespId);
-			if(null == deptResponsibility){
+		if ("mb".equals(type)) {
+			DeptResponsibility deptResponsibility = deptResponsibilityService.getById(evalOrRespId);
+			if (null == deptResponsibility) {
 				throw new CustomException("考评记录为空");
 			}
 			ids = Arrays.asList(deptResponsibility.getOrganizationEvaluationRuleId().split(","));
 		}
-		if("kp".equals(type)){
-			OrganizationEvaluation  organizationEvaluation = organizationEvaluationService.getById(evalOrRespId);
-			if(null == organizationEvaluation){
+		if ("kp".equals(type)) {
+			OrganizationEvaluation organizationEvaluation = organizationEvaluationService.getById(evalOrRespId);
+			if (null == organizationEvaluation) {
 				throw new CustomException("考评记录为空");
 			}
 			ids = Arrays.asList(organizationEvaluation.getOrganizationEvaluationRuleId().split(","));
 		}
 
 
-		if(ids.size()<=0){
+		if (ids.size() <= 0) {
 			throw new CustomException("考评记录重配置为空");
 		}
 //		QueryWrapper<OrganizationEvaluationRule> qw = new QueryWrapper<>();
@@ -229,7 +243,7 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 	}
 
 	@Override
-	public OrganizationEvaluationRule getByIdIsCheck(String id,Boolean isCheck,Boolean delFlag) {
+	public OrganizationEvaluationRule getByIdIsCheck(String id, Boolean isCheck, Boolean delFlag) {
 
 		QueryWrapper<OrganizationEvaluationRule> qw = new QueryWrapper<>();
 		if (StringUtils.isNotEmpty(id)) {
@@ -237,8 +251,8 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 		}
 		qw.lambda().eq(OrganizationEvaluationRule::getIsCheck, isCheck);
 		qw.lambda().eq(OrganizationEvaluationRule::getDelFlag, delFlag);
-		List<OrganizationEvaluationRule> list  = baseMapper.selectList(qw);
-		if(null != list && list.size()>0){
+		List<OrganizationEvaluationRule> list = baseMapper.selectList(qw);
+		if (null != list && list.size() > 0) {
 			return list.get(0);
 		}
 		return null;
@@ -256,13 +270,13 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 			qw.lambda().like(OrganizationEvaluationRule::getBinSection, binSection);
 		}
 
-		List<OrganizationEvaluationRule> list  = baseMapper.selectList(qw);
+		List<OrganizationEvaluationRule> list = baseMapper.selectList(qw);
 
 		return list;
 	}
 
 	@Override
-	public List<OrganizationEvaluationRule> getOrganizationEvaluationRuleByYearAndCycle(String organizationType,String evaluationCycle, String year,String organizationId) {
+	public List<OrganizationEvaluationRule> getOrganizationEvaluationRuleByYearAndCycle(String organizationType, String evaluationCycle, String year, String organizationId) {
 
 		QueryWrapper<OrganizationEvaluationRule> qw = new QueryWrapper<>();
 
@@ -284,14 +298,201 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 		qw.lambda().eq(OrganizationEvaluationRule::getDelFlag, false);
 		qw.lambda().eq(OrganizationEvaluationRule::getIsCheck, true);
 
-		List<OrganizationEvaluationRule> list  = baseMapper.selectList(qw);
+		List<OrganizationEvaluationRule> list = baseMapper.selectList(qw);
 
-		if(null != list && list.size()>0){
+		if (null != list && list.size() > 0) {
 			return list;
 		}
 		return null;
 	}
 
+	@Override
+	public void exportExcel(String organizationName, String binSection, String evaluationCycle, String year, HttpServletResponse response) throws IOException {
+		// 设置响应头信息,以附件形式下载
+		response.setHeader("Content-Disposition", "attachment; filename=organization_evaluation_rule.xlsx");
+		response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+
+		// 创建新的Excel工作簿
+		Workbook workbook = new XSSFWorkbook();
+
+		// 创建新的工作表
+		Sheet sheet = workbook.createSheet("Sheet1");
+
+		// 创建表头
+		Row headerRow = sheet.createRow(0);
+		List<String> headers = Arrays.asList("ID", "单位名称", "考评周期", "考评规则", "是否考评", "考评年份", "生产经营权重", "前期权重", "基建权重");
+		for (int i = 0; i < headers.size(); i++) {
+			Cell cell = headerRow.createCell(i);
+			cell.setCellValue(headers.get(i));
+		}
+
+		//行数据
+		List<OrganizationEvaluationRule> organizationEvaluationRuleList = baseMapper.selectListAll("", organizationName, "", "", binSection, "", evaluationCycle, year);
+		organizationEvaluationRuleList.forEach(l -> {
+			StringBuilder ruleName = new StringBuilder();
+			for (String ruleId : l.getEvaluateRuleId().split(",")) {
+				EvaluateRule rulebyid = evaluateRuleService.getById(ruleId);
+				if (null != rulebyid) {
+					ruleName.append(rulebyid.getRuleName()).append(",");
+				}
+			}
+			l.setEvaluateRuleName(ruleName.toString().length() > 0 ? ruleName.toString().substring(0, ruleName.toString().length() - 1) : "");
+		});
+
+		// 填充数据到工作表
+		int rowIndex = 1; // 从第二行开始填充数据(第一行是表头)
+		for (OrganizationEvaluationRule organizationEvaluationRule : organizationEvaluationRuleList) {
+			Row row = sheet.createRow(rowIndex++);
+
+			// 设置ID
+			row.createCell(0).setCellValue(organizationEvaluationRule.getId());
+
+			// 设置其他数据
+			row.createCell(1).setCellValue(organizationEvaluationRule.getOrganizationShortName());
+			if (null != organizationEvaluationRule.getEvaluationCycle()) {
+				if ("NDKP".equals(organizationEvaluationRule.getEvaluationCycle())) {
+					evaluationCycle = "年度考评";
+				} else if ("JDKP".equals(organizationEvaluationRule.getEvaluationCycle())) {
+					evaluationCycle = "季度考评";
+				} else if ("YDKP".equals(organizationEvaluationRule.getEvaluationCycle())) {
+					evaluationCycle = "月度考评";
+				}
+				row.createCell(2).setCellValue(evaluationCycle);
+			}
+			row.createCell(3).setCellValue(organizationEvaluationRule.getEvaluateRuleName());
+			if (null != organizationEvaluationRule.getIsCheck()) {
+				String isCheck;
+				if (organizationEvaluationRule.getIsCheck()) {
+					isCheck = "是";
+				} else {
+					isCheck = "否";
+				}
+				row.createCell(4).setCellValue(isCheck);
+			}
+			row.createCell(5).setCellValue(organizationEvaluationRule.getYear());
+			row.createCell(6).setCellValue(organizationEvaluationRule.getScjyWeight());
+			row.createCell(7).setCellValue(organizationEvaluationRule.getQqWeight());
+			row.createCell(8).setCellValue(organizationEvaluationRule.getJjWeight());
+		}
+
+		// 隐藏第一列(ID列)
+		sheet.setColumnHidden(0, true);
+
+		// 将工作簿写入到输出流
+		try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
+			workbook.write(outputStream);
+			response.getOutputStream().write(outputStream.toByteArray());
+			response.getOutputStream().flush();
+		}
+
+		// 关闭工作簿
+		workbook.close();
+	}
+
+	@Override
+	public void importTemplate(HttpServletResponse response) throws IOException {
+		// 设置响应头信息,以附件形式下载
+		response.setHeader("Content-Disposition", "attachment; filename=organization_evaluation_rule.xlsx");
+		response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+
+		// 创建新的Excel工作簿
+		Workbook workbook = new XSSFWorkbook();
+
+		// 创建新的工作表
+		Sheet sheet = workbook.createSheet("Sheet1");
+
+		// 创建表头
+		Row headerRow = sheet.createRow(0);
+		List<String> headers = Arrays.asList("单位名称", "考评周期", "考评规则", "是否考评", "考评年份", "生产经营权重", "前期权重", "基建权重");
+		for (int i = 0; i < headers.size(); i++) {
+			Cell cell = headerRow.createCell(i);
+			cell.setCellValue(headers.get(i));
+		}
+
+		// 将工作簿写入到输出流
+		try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
+			workbook.write(outputStream);
+			response.getOutputStream().write(outputStream.toByteArray());
+			response.getOutputStream().flush();
+		}
+
+		// 关闭工作簿
+		workbook.close();
+	}
+
+	@Override
+	public R importExcel(MultipartFile file) {
+		if (!file.isEmpty()) {
+			try {
+				//获取原始的文件名
+				String originalFilename = file.getOriginalFilename();
+				//获取文件类型
+				String fileType = originalFilename.substring(originalFilename.lastIndexOf(".") + 1, originalFilename.length());
+				//默认从第一行开始读取
+				int startRows = 1;
+				//获取输入流
+				InputStream is = file.getInputStream();
+				List<OrganizationEvaluationRule> organizationEvaluationRuleList = new ArrayList<>();
+				//Excel导入导出的单元类
+				List<String[]> strings = ExcelUtil.readData(fileType, startRows, true, is);
+				//遍历Excel表每一行的数据
+				for (String[] str : strings) {
+					OrganizationEvaluationRule organizationEvaluationRule = new OrganizationEvaluationRule();
+					if (isValidUUIDWithoutHyphens(str[0])) {
+						organizationEvaluationRule.setId(str[0]);
+						organizationEvaluationRule.setScjyWeight(Double.parseDouble(str[6]));
+						organizationEvaluationRule.setQqWeight(Double.parseDouble(str[7]));
+						organizationEvaluationRule.setJjWeight(Double.parseDouble(str[8]));
+						organizationEvaluationRuleList.add(organizationEvaluationRule);
+					} else {
+						List<OrganizationStructure> organizationStructureList = organizationStructureService.getList2("", null, "");
+						OrganizationStructure organizationStructure = organizationStructureList.stream().filter(item -> item.getShortName().equals(str[0])).findFirst().orElse(null);
+						if (null != organizationStructure) {
+							organizationEvaluationRule.setOrganizationName(organizationStructure.getName());
+							organizationEvaluationRule.setOrganizationId(organizationStructure.getId());
+							organizationEvaluationRule.setOrganizationShortName(organizationStructure.getShortName());
+							organizationEvaluationRule.setBusinessType(organizationStructure.getBusinessType());
+						}
+						organizationEvaluationRule.setOrganizationType("DWKP");
+						organizationEvaluationRule.setEvaluationCycle(toFullSpell(str[1]));
+						String[] evaluateRuleNames = str[2].split(",");
+						StringBuilder evaluateRuleIds = new StringBuilder();
+						StringBuilder binSections = new StringBuilder();
+						StringBuilder binStages = new StringBuilder();
+						for (String evaluateRuleName : evaluateRuleNames){
+							EvaluateRule evaluateRule = evaluateRuleService.getEvaluateRuleByRuleName(evaluateRuleName, str[4]);
+							evaluateRuleIds.append(evaluateRule.getId());
+							binSections.append(evaluateRule.getBinSection());
+							binStages.append(evaluateRule.getBinStage());
+						}
+						organizationEvaluationRule.setEvaluateRuleId(evaluateRuleIds.toString());
+						organizationEvaluationRule.setBinSection(binSections.toString());
+						organizationEvaluationRule.setBinStage(binStages.toString());
+						organizationEvaluationRule.setDelFlag(true);
+						if ("是".equals(str[3])) {
+							organizationEvaluationRule.setIsCheck(true);
+						} else if ("否".equals(str[3])) {
+							organizationEvaluationRule.setIsCheck(false);
+						}
+						organizationEvaluationRule.setScjyWeight(Double.parseDouble(str[5]));
+						organizationEvaluationRule.setQqWeight(Double.parseDouble(str[6]));
+						organizationEvaluationRule.setJjWeight(Double.parseDouble(str[7]));
+						organizationEvaluationRule.setYear(str[4]);
+						organizationEvaluationRuleList.add(organizationEvaluationRule);
+					}
+				}
+				boolean b = super.saveOrUpdateBatch(organizationEvaluationRuleList);
+				if (b) {
+					return R.ok().data(b);
+				} else {
+					return R.error("导入失败!");
+				}
+			} catch (Exception e) {
+				return R.customError(e.getMessage()).data("失败!");
+			}
+		}
+		return R.error("上传文件为空!");
+	}
 
 	@Transactional
 	@Override
@@ -314,20 +515,20 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 			QueryWrapper<OrganizationEvaluationRule> qw = new QueryWrapper<>();
 			qw.lambda().eq(OrganizationEvaluationRule::getOrganizationId, entity.getOrganizationId());
 			qw.lambda().eq(OrganizationEvaluationRule::getEvaluationCycle, entity.getEvaluationCycle());
-			qw.lambda().eq(OrganizationEvaluationRule::getYear,entity.getYear());
+			qw.lambda().eq(OrganizationEvaluationRule::getYear, entity.getYear());
 			qw.lambda().eq(OrganizationEvaluationRule::getDelFlag, false);
 			List<OrganizationEvaluationRule> list = baseMapper.selectList(qw);
 			if (null != list && list.size() > 0) {
 				throw new CustomException("已存在同期考评配置");
 			}
-		}else{
-			OrganizationEvaluationRule orirule  = baseMapper.selectById(entity.getId());
-			if(null == entity.getOrganizationShortName() || "".equals(entity.getOrganizationShortName())){
+		} else {
+			OrganizationEvaluationRule orirule = baseMapper.selectById(entity.getId());
+			if (null == entity.getOrganizationShortName() || "".equals(entity.getOrganizationShortName())) {
 				entity.setOrganizationShortName(orirule.getOrganizationShortName());
 			}
 		}
 		//判断排序字段是否有值
-		if(null==entity.getOrderNum()){
+		if (null == entity.getOrderNum()) {
 			int count = baseMapper.selectCount(null);
 			entity.setOrderNum(count);
 		}
@@ -340,18 +541,56 @@ public class OrganizationEvaluationRuleServiceImpl extends ServiceImpl<Organizat
 	@Override
 	public boolean removeByIds(Collection<? extends Serializable> idList) {
 
-		for (Serializable ids  :idList){
+		for (Serializable ids : idList) {
 			OrganizationEvaluationRule rule = baseMapper.selectById(ids);
-			if(null == rule){
+			if (null == rule) {
 				throw new CustomException("查无该记录");
 			}
 			rule.setDelFlag(true);
 			rule.setUpdateTime(new Date());
 			int num = baseMapper.updateById(rule);
-			if (num<=0){
+			if (num <= 0) {
 				throw new CustomException("删除失败");
 			}
 		}
 		return true;
 	}
+
+	public static boolean isValidUUIDWithoutHyphens(String uuid) {
+		if (uuid == null || (uuid.length() != 32 && uuid.length() != 36)) {
+			return false;
+		}
+		try {
+			// 尝试将不带连字符的字符串转换为UUID
+			UUID.fromString(uuid);
+			return true;
+		} catch (IllegalArgumentException e) {
+			// 如果转换失败,说明不是有效的UUID
+			return false;
+		}
+	}
+
+	public static String toFullSpell(String chinese) {
+		HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
+		format.setCaseType(HanyuPinyinCaseType.UPPERCASE);
+		format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
+
+		StringBuilder sb = new StringBuilder();
+		char[] chars = chinese.toCharArray();
+		for (char ch : chars) {
+			if (Character.isUpperCase(ch)) {
+				sb.append(String.valueOf(ch).toUpperCase());
+			} else {
+				try {
+					String[] pinyin = PinyinHelper.toHanyuPinyinStringArray(ch, format);
+					if (pinyin != null) {
+						sb.append(pinyin[0].charAt(0));
+					}
+				} catch (BadHanyuPinyinOutputFormatCombination e) {
+					e.printStackTrace();
+				}
+			}
+		}
+		return sb.toString().replaceAll("[^A-Z]", "").toUpperCase();
+	}
 }