Browse Source

数据改版部分接口返参调整

dev_shibei_match
sunyuchao 5 years ago
parent
commit
39788c9bc2
  1. 30
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/IndexDictResultDTO.java
  2. 16
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/constant/FactConstant.java
  3. 49
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/IndexDictDao.java
  4. 96
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java
  5. 4
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml
  6. 4
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunitySubScoreDao.xml
  7. 4
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridSubScoreDao.xml
  8. 31
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/IndexDictDao.xml

30
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/IndexDictResultDTO.java

@ -0,0 +1,30 @@
package com.epmet.evaluationindex.screen.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 评价指标字典表数据--接口返参
* @Author sun
*/
@Data
public class IndexDictResultDTO implements Serializable {
private static final long serialVersionUID = 3860268744336541373L;
/**
* 指标名
*/
private String indexName;
/**
* 指标code
*/
private String indexCode;
/**
* 指标值类型 百分比percent
*/
private String valueType;
}

16
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/constant/FactConstant.java

@ -45,4 +45,20 @@ public interface FactConstant {
* 网格相关
*/
String WANG_GE_XIANG_GUAN = "wanggexiangguan";
/**
* 评价指标类型-
*/
String NONE = "none";
/**
* 评价指标类型-整数
*/
String INTEGER = "integer";
/**
* 评价指标类型-小数
*/
String DECIMAL = "decimal";
/**
* 评价指标类型-百分比
*/
String PERCENT = "percent";
}

49
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/fact/IndexDictDao.java

@ -0,0 +1,49 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<IndexDictResultDTO> selectList();
/**
* @param
* @Description 根据indexCode查询指标字典表具体数据
* @author sun
*/
IndexDictResultDTO selectIndexDict(@Param("indexCode") String indexCode);
}

96
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<IndexDictResultDTO> 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;
}

4
epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml

@ -6,7 +6,7 @@
<select id="selectAblityList" resultType="com.epmet.evaluationindex.screen.dto.result.AblityListResultDTO">
SELECT
fact.index_code AS "key",
IF(fact.origin_value='',0,IFNULL(ROUND(fact.origin_value,1),0)) AS "value",
IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS "value",
dict.index_name AS "name"
FROM
fact_index_agency_sub_score fact
@ -23,7 +23,7 @@
<select id="selectMonthAblityList" resultType="com.epmet.evaluationindex.screen.dto.result.MonthAblityListResultDTO">
SELECT
fact.month_id AS "monthId",
IF(fact.origin_value='',0,IFNULL(ROUND(fact.origin_value,1),0)) AS "ablity"
IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS "ablity"
FROM
fact_index_agency_sub_score fact
LEFT JOIN index_dict dict ON fact.index_code = dict.index_code

4
epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunitySubScoreDao.xml

@ -6,7 +6,7 @@
<select id="selectCommunityAblityList" resultType="com.epmet.evaluationindex.screen.dto.result.AblityListResultDTO">
SELECT
fact.index_code AS "key",
IF(fact.origin_value='',0,IFNULL(ROUND(fact.origin_value,1),0)) AS "value",
IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS "value",
dict.index_name AS "name"
FROM
fact_index_community_sub_score fact
@ -23,7 +23,7 @@
<select id="selectCommunityMonthAblityList" resultType="com.epmet.evaluationindex.screen.dto.result.MonthAblityListResultDTO">
SELECT
fact.month_id AS "monthId",
IF(fact.origin_value='',0,IFNULL(ROUND(fact.origin_value,1),0)) AS "ablity"
IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS "ablity"
FROM
fact_index_community_sub_score fact
LEFT JOIN index_dict dict ON fact.index_code = dict.index_code

4
epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridSubScoreDao.xml

@ -6,7 +6,7 @@
<select id="selectGridAblityList" resultType="com.epmet.evaluationindex.screen.dto.result.AblityListResultDTO">
SELECT
fact.index_code AS "key",
IF(fact.origin_value='',0,IFNULL(ROUND(fact.origin_value,1),0)) AS "value",
IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS "value",
dict.index_name AS "name"
FROM
fact_index_grid_sub_score fact
@ -23,7 +23,7 @@
<select id="selectGridMonthAblityList" resultType="com.epmet.evaluationindex.screen.dto.result.MonthAblityListResultDTO">
SELECT
fact.month_id AS "monthId",
IF(fact.origin_value='',0,IFNULL(ROUND(fact.origin_value,1),0)) AS "ablity"
IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS "ablity"
FROM
fact_index_grid_sub_score fact
LEFT JOIN index_dict dict ON fact.index_code = dict.index_code

31
epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/IndexDictDao.xml

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.datareport.dao.fact.IndexDictDao">
<select id="selectList" resultType="com.epmet.evaluationindex.screen.dto.result.IndexDictResultDTO">
SELECT
index_name AS "indexName",
index_code AS "indexCode",
value_type AS "valueType"
FROM
index_dict
WHERE
del_flag = '0'
AND value_type != 'none'
</select>
<select id="selectIndexDict" resultType="com.epmet.evaluationindex.screen.dto.result.IndexDictResultDTO">
SELECT
index_name AS "indexName",
index_code AS "indexCode",
value_type AS "valueType"
FROM
index_dict
WHERE
del_flag = '0'
AND index_code = #{indexCode}
LIMIT 1
</select>
</mapper>
Loading…
Cancel
Save