+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.datareport.dao.fact;
+
+import com.epmet.evaluationindex.screen.dto.result.IndexDictResultDTO;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 评价指标字典
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-09-02
+ */
+@Mapper
+public interface IndexDictDao {
+
+ /**
+ * @param
+ * @Description 查询指标字典表是百分比类型的数据
+ * @author sun
+ */
+ List selectList();
+
+ /**
+ * @param
+ * @Description 根据indexCode查询指标字典表具体数据
+ * @author sun
+ */
+ IndexDictResultDTO selectIndexDict(@Param("indexCode") String indexCode);
+}
diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java
index 523bf3a7e5..68b3fd1f60 100644
--- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java
+++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java
@@ -15,12 +15,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
+import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.*;
/**
* 数据改版api
@@ -47,6 +45,8 @@ public class FactIndexServiceImpl implements FactIndexService {
private FactIndexGridScoreDao factIndexGridScoreDao;
@Autowired
private FactIndexGridSubScoreDao factIndexGridSubScoreDao;
+ @Autowired
+ private IndexDictDao indexDictDao;
/**
* @param formDTO
@@ -125,19 +125,27 @@ public class FactIndexServiceImpl implements FactIndexService {
AblityIndexResultDTO nl = new AblityIndexResultDTO();
nl.setIndexCode(FactConstant.NLZB);
nl.setScoreList(nlList);
- if(null != nlList){resultList.add(nl);}
+ if (null != nlList) {
+ resultList.add(nl);
+ }
AblityIndexResultDTO dj = new AblityIndexResultDTO();
dj.setIndexCode(FactConstant.DJNL);
dj.setScoreList(djList);
- if(null != djList){resultList.add(dj);}
+ if (null != djList) {
+ resultList.add(dj);
+ }
AblityIndexResultDTO zl = new AblityIndexResultDTO();
zl.setIndexCode(FactConstant.ZLNL);
zl.setScoreList(zlList);
- if(null != zlList){resultList.add(zl);}
+ if (null != zlList) {
+ resultList.add(zl);
+ }
AblityIndexResultDTO fw = new AblityIndexResultDTO();
fw.setIndexCode(FactConstant.FWNL);
fw.setScoreList(fwList);
- if(null != fwList){resultList.add(fw);}
+ if (null != fwList) {
+ resultList.add(fw);
+ }
return resultList;
}
@@ -203,9 +211,15 @@ public class FactIndexServiceImpl implements FactIndexService {
throw new RenException(String.format("按月份查询各项能力分数,orgType类型错误,组织Id:%s,类型Type:%s", formDTO.getOrgId(), formDTO.getOrgType()));
}
//5.封装数据并返回
- if(null != dj){resultList.add(dj);}
- if(null != zl){resultList.add(zl);}
- if(null != fw){resultList.add(fw);}
+ if (null != dj) {
+ resultList.add(dj);
+ }
+ if (null != zl) {
+ resultList.add(zl);
+ }
+ if (null != fw) {
+ resultList.add(fw);
+ }
return resultList;
}
@@ -278,15 +292,21 @@ public class FactIndexServiceImpl implements FactIndexService {
MonthScoreListResultDTO dj = new MonthScoreListResultDTO();
dj.setIndexCode(FactConstant.DJNL);
dj.setScoreList(djList);
- if(null != djList){resultList.add(dj);}
+ if (null != djList) {
+ resultList.add(dj);
+ }
MonthScoreListResultDTO zl = new MonthScoreListResultDTO();
zl.setIndexCode(FactConstant.ZLNL);
zl.setScoreList(zlList);
- if(null != zlList){resultList.add(zl);}
+ if (null != zlList) {
+ resultList.add(zl);
+ }
MonthScoreListResultDTO fw = new MonthScoreListResultDTO();
fw.setIndexCode(FactConstant.FWNL);
fw.setScoreList(fwList);
- if(null != fwList){resultList.add(fw);}
+ if (null != fwList) {
+ resultList.add(fw);
+ }
return resultList;
}
@@ -333,7 +353,28 @@ public class FactIndexServiceImpl implements FactIndexService {
throw new RenException(String.format("按月查询各项指标数据,orgType类型错误,组织Id:%s,类型Type:%s", formDTO.getOrgId(), formDTO.getOrgType()));
}
- //4.调用方法判断各项指标是数字指标还是百分比指标 //TODO 记得value值保留一位小数 是数的保留零位小数 是百分比的保留一位小数
+ //4.查询指标字典表数据
+ List list = indexDictDao.selectList();
+ //5.遍历数据,判断数据类型并处理
+ /*NumberFormat nf = NumberFormat.getPercentInstance();
+ nf.setMaximumFractionDigits(1);*/
+ resultList.forEach(result -> {
+ list.forEach(l -> {
+ if (result.getKey().equals(l.getIndexCode())) {
+ //小数类型,四舍五入保留小数点后一位
+ if (FactConstant.DECIMAL.equals(l.getValueType())) {
+ BigDecimal num = new BigDecimal(result.getValue()).setScale(1, BigDecimal.ROUND_HALF_UP);
+ result.setValue(num.toString());
+ }
+ //百分数类型,四舍五入保留小数点后一位并转成百分比
+ if (FactConstant.PERCENT.equals(l.getValueType())) {
+ BigDecimal num = new BigDecimal(result.getValue()).setScale(1, BigDecimal.ROUND_HALF_UP);
+ result.setValue(num+"%");
+ }
+ }
+ });
+ });
+
return resultList;
}
@@ -373,7 +414,30 @@ public class FactIndexServiceImpl implements FactIndexService {
throw new RenException(String.format("按月查询各项指标最近12个月数据,orgType类型错误,组织Id:%s,类型Type:%s", formDTO.getOrgId(), formDTO.getOrgType()));
}
- //6.调用方法判断各项指标是数字指标还是百分比指标//TODO 记得value值保留一位小数 是数的保留零位小数 是百分比的保留一位小数
+ //6.查询指标字典表具体数据
+ IndexDictResultDTO dictDTO = indexDictDao.selectIndexDict(formDTO.getKey());
+ if (null == dictDTO) {
+ throw new RenException(String.format("根据评价指标indexCode未查询到字典表数据,indexCode值:%s", formDTO.getKey()));
+ }
+
+ //7.遍历数据,判断数据类型并处理
+ /*NumberFormat nf = NumberFormat.getPercentInstance();
+ nf.setMaximumFractionDigits(1);*/
+ //小数类型,四舍五入保留小数点后一位
+ if (FactConstant.DECIMAL.equals(dictDTO.getValueType())) {
+ resultList.forEach(result -> {
+ BigDecimal num = new BigDecimal(result.getAblity()).setScale(1, BigDecimal.ROUND_HALF_UP);
+ result.setAblity(num.toString());
+ });
+ }
+ //百分数类型,四舍五入保留小数点后一位并转成百分比
+ if (FactConstant.PERCENT.equals(dictDTO.getValueType())) {
+ resultList.forEach(result -> {
+ BigDecimal num = new BigDecimal(result.getAblity()).setScale(1, BigDecimal.ROUND_HALF_UP);
+ result.setAblity(num+"%");
+ });
+ }
+
return resultList;
}
diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml
index 879d8b521e..9744157016 100644
--- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml
+++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml
@@ -6,7 +6,7 @@