|
@@ -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();
|
|
|
+ }
|
|
|
}
|