|
@@ -225,7 +225,7 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
|
|
|
* 单位考评评级
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<OrganizationRating> grade(List<OrganizationRating> orgRating) {
|
|
|
+ public R grade(List<OrganizationRating> orgRating) {
|
|
|
XSSFWorkbook xwb = new XSSFWorkbook();
|
|
|
Sheet st = xwb.createSheet();
|
|
|
List<OrganizationRatingRule> rules = iOrganizationRatingRuleService.list(null);
|
|
@@ -238,14 +238,18 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
|
|
|
.findFirst()
|
|
|
.ifPresent(b -> col.put(b.getId(), value)));
|
|
|
|
|
|
- calcSCJYrating(rulesYear, col, st, xwb);
|
|
|
- calcQQXMrating(rulesYear, col, st, xwb);
|
|
|
- calcJJXMrating(rulesYear, col, st, xwb);
|
|
|
- calcNDrating(rulesYear, orgRating, st, xwb);
|
|
|
+ R r1=calcSCJYrating(rulesYear, col, st, xwb);
|
|
|
+ R r2=calcQQXMrating(rulesYear, col, st, xwb);
|
|
|
+ R r3=calcJJXMrating(rulesYear, col, st, xwb);
|
|
|
+ R r4=calcNDrating(rulesYear, orgRating, st, xwb);
|
|
|
+ if (r1.getSuccess().equals(false) && r2.getSuccess().equals(false) && r3.getSuccess().equals(false)) {
|
|
|
+ return R.error("评级失败");
|
|
|
+ }
|
|
|
Map<String, OrganizationRating> map = orgRating.stream().collect(Collectors.toMap(OrganizationRating::getId, Function.identity()));
|
|
|
List<OrganizationRating> organizationRatings = baseMapper.selectBatchIds(map.keySet());
|
|
|
savePortal(organizationRatings);
|
|
|
- return organizationRatings;
|
|
|
+// return organizationRatings;
|
|
|
+ return R.ok().data(organizationRatings);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -273,7 +277,7 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
|
|
|
/**
|
|
|
* 年度评级
|
|
|
*/
|
|
|
- private void calcNDrating(List<OrganizationRatingRule> list, List<OrganizationRating> orgRating, Sheet st, XSSFWorkbook xwb) {
|
|
|
+ private R calcNDrating(List<OrganizationRatingRule> list, List<OrganizationRating> orgRating, Sheet st, XSSFWorkbook xwb) {
|
|
|
List<String> ls = new ArrayList<>();
|
|
|
for (OrganizationRating or : orgRating) {
|
|
|
ls.add(or.getId());
|
|
@@ -308,12 +312,12 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
|
|
|
String content = matcher.group(1);
|
|
|
if ("scjy_rate".equals(content)) {
|
|
|
if (or.getScjyRate() == null) {
|
|
|
- return;
|
|
|
+ return R.error();
|
|
|
}
|
|
|
key = or.getScjyRate();
|
|
|
} else if ("qq_rate".equals(content)) {
|
|
|
if (or.getQqRate() == null) {
|
|
|
- return;
|
|
|
+ return R.error();
|
|
|
}
|
|
|
key = or.getQqRate();
|
|
|
}
|
|
@@ -323,29 +327,43 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
|
|
|
placeholders.put(key, content);
|
|
|
}
|
|
|
String form = replace;
|
|
|
- CellValue cv = setFormula(st, xwb, form);
|
|
|
+ Row rr = st.createRow(0);
|
|
|
+ Cell cc = rr.createCell(0);
|
|
|
+ // 这里要设置为公式类型
|
|
|
+ try {
|
|
|
+ cc.setCellFormula(form);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.error("公式错误:"+form);
|
|
|
+ }
|
|
|
+ FormulaEvaluator fe = new XSSFFormulaEvaluator(xwb);
|
|
|
+ CellValue cv=fe.evaluate(cc);
|
|
|
UpdateWrapper<OrganizationRating> uw = new UpdateWrapper<>();
|
|
|
uw.eq("id", or.getId()).set("year_rate", cv.formatAsString());
|
|
|
iOrganizationRatingService.update(uw);
|
|
|
}
|
|
|
}
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
|
|
|
- private CellValue setFormula(Sheet st, XSSFWorkbook xwb, String form) {
|
|
|
+ /*private CellValue setFormula(Sheet st, XSSFWorkbook xwb, String form) {
|
|
|
Row rr = st.createRow(0);
|
|
|
Cell cc = rr.createCell(0);
|
|
|
// 这里要设置为公式类型
|
|
|
- cc.setCellFormula(form);
|
|
|
+ try {
|
|
|
+ cc.setCellFormula(form);
|
|
|
+ } catch (Exception e) {
|
|
|
+ R.error("公式错误");
|
|
|
+ }
|
|
|
FormulaEvaluator fe = new XSSFFormulaEvaluator(xwb);
|
|
|
return fe.evaluate(cc);
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 基建评级
|
|
|
*/
|
|
|
- private void calcJJXMrating(List<OrganizationRatingRule> list, Map<String, List<OrganizationRating>> orgRating, Sheet st, XSSFWorkbook xwb) {
|
|
|
+ private R calcJJXMrating(List<OrganizationRatingRule> list, Map<String, List<OrganizationRating>> orgRating, Sheet st, XSSFWorkbook xwb) {
|
|
|
List<OrganizationRatingRule> rules = list.stream().filter(orr -> "基建评级".equals(orr.getCheckCycle())).collect(Collectors.toList());
|
|
|
for (Map.Entry<String, List<OrganizationRating>> orgMap : orgRating.entrySet()) {
|
|
|
List<OrganizationRatingRule> collect = rules.stream().filter(rul -> orgMap.getKey().equals(rul.getBinSection())).collect(Collectors.toList());
|
|
@@ -375,19 +393,29 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
|
|
|
placeholders.put(key, content);
|
|
|
}
|
|
|
String form = replace;
|
|
|
- CellValue cv = setFormula(st, xwb, form);
|
|
|
+ Row rr = st.createRow(0);
|
|
|
+ Cell cc = rr.createCell(0);
|
|
|
+ // 这里要设置为公式类型
|
|
|
+ try {
|
|
|
+ cc.setCellFormula(form);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.error("公式错误:"+form);
|
|
|
+ }
|
|
|
+ FormulaEvaluator fe = new XSSFFormulaEvaluator(xwb);
|
|
|
+ CellValue cv=fe.evaluate(cc);
|
|
|
UpdateWrapper<OrganizationRating> uw = new UpdateWrapper<>();
|
|
|
uw.eq("id", or.getId()).set("jj_rate", cv.formatAsString()).set("composite_score_raking", or.getCompositeScoreRaking())
|
|
|
.set("project_level", or.getProjectLevel());
|
|
|
iOrganizationRatingService.update(uw);
|
|
|
}
|
|
|
}
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生产经营评级
|
|
|
*/
|
|
|
- private void calcSCJYrating(List<OrganizationRatingRule> list, Map<String, List<OrganizationRating>> orgRating, Sheet st, XSSFWorkbook xwb) {
|
|
|
+ private R calcSCJYrating(List<OrganizationRatingRule> list, Map<String, List<OrganizationRating>> orgRating, Sheet st, XSSFWorkbook xwb) {
|
|
|
List<OrganizationRatingRule> rules = list.stream().filter(orr -> "生产经营评级".equals(orr.getCheckCycle())).collect(Collectors.toList());
|
|
|
for (Map.Entry<String, List<OrganizationRating>> orgMap : orgRating.entrySet()) {
|
|
|
List<OrganizationRatingRule> collect = rules.stream().filter(rul -> orgMap.getKey().equals(rul.getBinSection())).collect(Collectors.toList());
|
|
@@ -424,19 +452,29 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
|
|
|
placeholders.put(key, content);
|
|
|
}
|
|
|
String form = replace;
|
|
|
- CellValue cv = setFormula(st, xwb, form);
|
|
|
+ Row rr = st.createRow(0);
|
|
|
+ Cell cc = rr.createCell(0);
|
|
|
+ // 这里要设置为公式类型
|
|
|
+ try {
|
|
|
+ cc.setCellFormula(form);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.error("公式错误:"+form);
|
|
|
+ }
|
|
|
+ FormulaEvaluator fe = new XSSFFormulaEvaluator(xwb);
|
|
|
+ CellValue cv = fe.evaluate(cc);
|
|
|
UpdateWrapper<OrganizationRating> uw = new UpdateWrapper<>();
|
|
|
uw.eq("id", or.getId()).set("scjy_rate", cv.formatAsString()).set("safety_env_protection", or.getSafetyEnvProtection())
|
|
|
.set("veto", or.getVeto()).set("net_profit", or.getNetProfit()).set("composite_score", or.getCompositeScore());
|
|
|
iOrganizationRatingService.update(uw);
|
|
|
}
|
|
|
}
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 前期评级
|
|
|
*/
|
|
|
- private void calcQQXMrating(List<OrganizationRatingRule> list, Map<String, List<OrganizationRating>> orgRating, Sheet st, XSSFWorkbook xwb) {
|
|
|
+ private R calcQQXMrating(List<OrganizationRatingRule> list, Map<String, List<OrganizationRating>> orgRating, Sheet st, XSSFWorkbook xwb) {
|
|
|
List<OrganizationRatingRule> rules = list.stream().filter(orr -> "前期评级".equals(orr.getCheckCycle())).collect(Collectors.toList());
|
|
|
for (Map.Entry<String, List<OrganizationRating>> orgMap : orgRating.entrySet()) {
|
|
|
List<OrganizationRatingRule> collect = rules.stream().filter(rul -> orgMap.getKey().equals(rul.getBinSection())).collect(Collectors.toList());
|
|
@@ -466,12 +504,22 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
|
|
|
placeholders.put(key, content);
|
|
|
}
|
|
|
String form = replace;
|
|
|
- CellValue cv = setFormula(st, xwb, form);
|
|
|
+ Row rr = st.createRow(0);
|
|
|
+ Cell cc = rr.createCell(0);
|
|
|
+ // 这里要设置为公式类型
|
|
|
+ try {
|
|
|
+ cc.setCellFormula(form);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.error("公式错误:"+form);
|
|
|
+ }
|
|
|
+ FormulaEvaluator fe = new XSSFFormulaEvaluator(xwb);
|
|
|
+ CellValue cv = fe.evaluate(cc);
|
|
|
UpdateWrapper<OrganizationRating> uw = new UpdateWrapper<>();
|
|
|
uw.eq("id", or.getId()).set("qq_rate", cv.formatAsString()).set("annual_target", or.getAnnualTarget()).set("bonus_point", or.getBonusPoint());
|
|
|
iOrganizationRatingService.update(uw);
|
|
|
}
|
|
|
}
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -486,8 +534,20 @@ public class OrganizationRatingServiceImpl extends ServiceImpl<OrganizationRatin
|
|
|
IPage<OrganizationRating> list = baseMapper.selectList(page, id, organizationYearRatingId, binSection, year, organizationShortName,
|
|
|
organizationId, safetyEnvProtection, veto, netProfit, compositeScore, annualTarget, bonusPoint, compositeScoreRaking, projectLevel);
|
|
|
if (list.getRecords().isEmpty()) {
|
|
|
- int c = iOrganizationRatingService.count();
|
|
|
- if (c > 0) {
|
|
|
+ IPage<OrganizationRating> ls = baseMapper.selectList(page, null, null, null, null, null,
|
|
|
+ null, null, null, null, null, null, null, null,
|
|
|
+ null);
|
|
|
+ if (!ls.getRecords().isEmpty()) {
|
|
|
+ if (organizationYearRatingId != null) {
|
|
|
+ Map<String, OrganizationRating> map = ls.getRecords().stream().filter(rec -> organizationYearRatingId.equals(rec.getOrganizationYearRatingId()))
|
|
|
+ .collect(Collectors.toMap(OrganizationRating::getId, Function.identity()));
|
|
|
+ if (!map.isEmpty()) {
|
|
|
+ int i = baseMapper.deleteBatchIds(map.keySet());
|
|
|
+ getOrgRatingInfo(organizationYearRatingId);
|
|
|
+ list = baseMapper.selectList(page, id, organizationYearRatingId, binSection, year, organizationShortName, organizationId,
|
|
|
+ safetyEnvProtection, veto, netProfit, compositeScore, annualTarget, bonusPoint, compositeScoreRaking, projectLevel);
|
|
|
+ }
|
|
|
+ }
|
|
|
return list;
|
|
|
}
|
|
|
getOrgRatingInfo(organizationYearRatingId);
|