Commit c4c70b6a by zhangkb

提交整合考核指标报表2数据代码

parent 94282e26
......@@ -33,4 +33,12 @@ public class IndicatorReportCtrl {
indicatorsReportService.dealBaseIndReportOneData(date, compareObjs);
return "基础项本期同期报表数据开始整合...";
}
@ApiOperation(value = "整合考核指标报表数据2", notes = "整合考核指标报表数据2")
@PostMapping(value = "/dealDriveReportTwo")
public String dealDriveReportTwo(@RequestParam String compareUnitId,@RequestParam List<String> indIds,
@RequestParam List<String> compareObjs,@RequestParam Integer date) {
indicatorsReportService.dealDriveIndReportTwoData(compareUnitId, indIds, compareObjs, date);
return "整合考核指标报表数据2开始整合...";
}
}
......@@ -24,7 +24,7 @@ public class BaseIndDef {
private String indUnit;//数据项单位
private String indDesc;//说明
private Integer indSource;//数据项来源 1:excel导入 2:手工填报
private String indFrequency;//数据源频度 0:月度 1:季度 2:年度
private String indFrequency;//数据源频度 0:月度 1:季度 2:年度 3:半年度
private String indFormat;//指标公式
private String indFormatDesc;//指标公式描述
private String creater;
......
......@@ -28,7 +28,7 @@ public class DriveIndDef {
private Integer indCalScoreRule;//计分规则
private String indCalScoreRuleDesc;//计分规则描述
private String isUnitCalScore;//是否参与单位得分计算 是:1 否:0
private String indFrequency;//指标频度 0:月度给数 1:季度给数 2:年度给数
private String indFrequency;//指标频度 0:月度给数 1:季度给数 2:年度给数 3:半年度
private String growCalType;//增幅计算类型 0:本期-同期 1:(本期-同期)/同期*100
private String version;//版本号
private String code;//标识编码
......
......@@ -25,7 +25,7 @@ public class IndicatorsReportOne {
private String compareType;//对标类型: 1:日 2:月 3:季 4:年
private String unit;//指标单位
private String depart;//指标归属部门
private String catalogType;//指标归属类别
private Integer catalogType;//指标归属类别
private String currentValue;//本期值
private String lastSameValue;// 同期值
private String valueRate;//同比
......
......@@ -24,6 +24,7 @@ public class IndicatorsReportTwo {
private Integer compareDate;//对标时间
private String compareType;//对标类型
private String unit;//单位
private Integer catalogType;//指标归属类别
private String currentActualAverage;//本期全省平均值
private String sameActualAverage;//同期全省平均值
private String averageRate;//全省平均分同比
......
package com.keymobile.indicators.model.mapper.report;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -11,4 +13,8 @@ import tk.mybatis.mapper.common.BaseMapper;
public interface ReportTwoMapper extends BaseMapper<IndicatorsReportTwo>{
public IndicatorsReportTwo getDataByParam(@Param("indId")String indId,@Param("compareUnitId")String compareUnitId,
@Param("date")Integer date,@Param("type")String type);
public void batchSave(@Param("datas")List<IndicatorsReportTwo> datas);
public void batchUpdate(@Param("datas")List<IndicatorsReportTwo> datas);
}
package com.keymobile.indicators.utils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -227,6 +230,41 @@ public class CalculateUtils {
Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2,
LinkedHashMap::new));
}
//type:0从小到大 1从大到小
public static Map<String, Integer> sortMapByValue(Map<String, Integer> oriMap,Integer type) {
if (oriMap == null || oriMap.isEmpty()) {
return null;
}
Map<String, Integer> sortedMap = new LinkedHashMap<String, Integer>();
List<Map.Entry<String, Integer>> entryList = new ArrayList<Map.Entry<String, Integer>>(
oriMap.entrySet());
Collections.sort(entryList, new MapValueComparator(type));
Iterator<Map.Entry<String, Integer>> iter = entryList.iterator();
Map.Entry<String, Integer> tmpEntry = null;
while (iter.hasNext()) {
tmpEntry = iter.next();
sortedMap.put(tmpEntry.getKey(), tmpEntry.getValue());
}
return sortedMap;
}
public static class MapValueComparator implements Comparator<Map.Entry<String, Integer>> {
private Integer type;//0:从小到大 1:从大到小
public MapValueComparator(Integer type) {
this.type = type;
}
@Override
public int compare(Entry<String, Integer> me1, Entry<String, Integer> me2) {
if(type==0) {
return me1.getValue().compareTo(me2.getValue());//按照从小到大
}
return me2.getValue().compareTo(me1.getValue());//按照从大到小
}
}
public static void main(String[] args) {
Map<String,String> map = new HashMap<>();
......@@ -240,6 +278,7 @@ public class CalculateUtils {
map.put("1008", "-6");
CalculateUtils cal = new CalculateUtils();
Map<String,Integer> result = cal.rankValue(map, "0");
result = cal.sortMapByValue(result,1);
System.out.println(result);
//
// String formula = "([1001]+[1002])/2";
......
......@@ -10,4 +10,111 @@
compare_date = #{date} and
compare_type = #{type}
</select>
<insert id="batchSave" parameterType="java.util.List">
insert into indicators_report_two(
ind_id,ind_name,compare_unit_id,compare_unit_name,compare_date,compare_type,unit,catalog_type,current_actual_average,
same_actual_average,average_rate,trend,current_average,best_unit,best_unit_desc,best_unit_value,
best_average_units,same_improve_units,rank_head_three,rank_head_three_desc,rank_after_three,
rank_after_three_desc,same_improve_head_three,same_improve_head_three_desc,same_improve_after_three,
same_improve_after_three_desc)
values
<foreach collection="datas" item="val" separator=",">
(
#{val.indId}, #{val.indName}, #{val.compareUnitId}, #{val.compareUnitName}, #{val.compareDate},
#{val.compareType},#{val.unit},#{val.catalogType},#{val.currentActualAverage},#{val.sameActualAverage},#{val.averageRate},
#{val.trend},#{val.currentAverage},#{val.bestUnit},#{val.bestUnitDesc},#{val.bestUnitValue},
#{val.bestAverageUnits},#{val.sameImproveUnits},#{val.rankHeadThree},#{val.rankHeadThreeDesc},
#{val.rankAfterThree},#{val.rankAfterThreeDesc},#{val.sameImproveHeadThree},#{val.sameImproveHeadThreeDesc},
#{val.sameImproveAfterThree},#{val.sameImproveAfterThreeDesc}
)
</foreach>
</insert>
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="datas" item="val" separator=";">
update indicators_report_two
<set>
<if test="val.indId != null">
ind_id = #{val.indId},
</if>
<if test="val.indName != null">
ind_name = #{val.indName},
</if>
<if test="val.compareUnitId != null">
compare_unit_id = #{val.compareUnitId},
</if>
<if test="val.compareUnitName != null">
compare_unit_name = #{val.compareUnitName},
</if>
<if test="val.compareDate != null">
compare_date = #{val.compareDate},
</if>
<if test="val.compareType != null">
compare_type = #{val.compareType},
</if>
<if test="val.unit != null">
unit = #{val.unit},
</if>
<if test="val.catalogType != null">
catalog_type = #{val.catalogType},
</if>
<if test="val.currentActualAverage != null">
current_actual_average = #{val.currentActualAverage},
</if>
<if test="val.sameActualAverage != null">
same_actual_average = #{val.sameActualAverage},
</if>
<if test="val.averageRate != null">
average_rate = #{val.averageRate},
</if>
<if test="val.trend != null">
trend = #{val.trend},
</if>
<if test="val.currentAverage != null">
current_average = #{val.currentAverage},
</if>
<if test="val.bestUnit != null">
best_unit = #{val.bestUnit},
</if>
<if test="val.bestUnitDesc != null">
best_unit_desc = #{val.bestUnitDesc},
</if>
<if test="val.bestUnitValue != null">
best_unit_value = #{val.bestUnitValue},
</if>
<if test="val.bestAverageUnits != null">
best_average_units = #{val.bestAverageUnits},
</if>
<if test="val.sameImproveUnits != null">
same_improve_units = #{val.sameImproveUnits},
</if>
<if test="val.rankHeadThree != null">
rank_head_three = #{val.rankHeadThree},
</if>
<if test="val.rankHeadThreeDesc != null">
rank_head_three_desc = #{val.rankHeadThreeDesc},
</if>
<if test="val.rankAfterThree != null">
rank_after_three = #{val.rankAfterThree},
</if>
<if test="val.rankAfterThreeDesc != null">
rank_after_three_desc = #{val.rankAfterThreeDesc},
</if>
<if test="val.sameImproveHeadThree != null">
same_improve_head_three = #{val.sameImproveHeadThree},
</if>
<if test="val.sameImproveHeadThreeDesc != null">
same_improve_head_three_desc = #{val.sameImproveHeadThreeDesc},
</if>
<if test="val.sameImproveAfterThree != null">
same_improve_after_three = #{val.sameImproveAfterThree},
</if>
<if test="val.sameImproveAfterThreeDesc != null">
same_improve_after_three_desc = #{val.sameImproveAfterThreeDesc},
</if>
</set>
where id = ${val.id}
</foreach>
</update>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment