自定义分析功能扩展
正在显示
1 个修改的文件
包含
40 行增加
和
7 行删除
sk-module-biz/src/main/java/com/skua/modules/dataAnalysis/service/impl/CustomConsumeServiceImpl.java
... | @@ -141,25 +141,42 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { | ... | @@ -141,25 +141,42 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { |
141 | //获取当天同比数据map | 141 | //获取当天同比数据map |
142 | Map<String,Object> tb = tbMap.get(DateUtils.formatAddTime(time,formatPattern,Calendar.YEAR,-1)); | 142 | Map<String,Object> tb = tbMap.get(DateUtils.formatAddTime(time,formatPattern,Calendar.YEAR,-1)); |
143 | if(tb!=null&&tb.size()>0) { | 143 | if(tb!=null&&tb.size()>0) { |
144 | double value = ConvertUtils.getDouble(map.get(index), 0); | ||
145 | double tb_value = 0; | ||
144 | if(index.contains("JSLL")||index.contains("CSLL")) { | 146 | if(index.contains("JSLL")||index.contains("CSLL")) { |
145 | tempMap.put(index+"_tb", DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(tb.get(realKey), 0.0), 2)); | 147 | tb_value = DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(tb.get(realKey), 0.0), 2); |
146 | }else { | 148 | }else { |
147 | tempMap.put(index+"_tb", DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(tb.get(realKey), 0.0)/ConvertUtils.getDouble(tb.get(realKey+"_tag"), 1.0), 2)); | 149 | tb_value = DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(tb.get(realKey), 0.0)/ConvertUtils.getDouble(tb.get(realKey+"_tag"), 1.0), 2); |
150 | } | ||
151 | tempMap.put(index+"_tb", tb_value); | ||
152 | //添加同比比例 | ||
153 | if(tb_value==0) { | ||
154 | map.put(index+"_tb_rate", 0); | ||
155 | }else { | ||
156 | map.put(index+"_tb_rate", DoubleOperaUtils.bigDecimalRound((value - tb_value)/tb_value*100, 2)); | ||
148 | } | 157 | } |
149 | } | 158 | } |
150 | } | 159 | } |
151 | if(!StringUtils.isEmpty(contrastType)&&contrastType.contains("hb")) { | 160 | if(!StringUtils.isEmpty(contrastType)&&contrastType.contains("hb")) { |
152 | //获取当天同比数据map | 161 | //获取当天同比数据map |
153 | |||
154 | Map<String,Object> hb = hbMap.get(DateUtils.formatAddTime(time,formatPattern,Calendar.MONTH,-1)); | 162 | Map<String,Object> hb = hbMap.get(DateUtils.formatAddTime(time,formatPattern,Calendar.MONTH,-1)); |
155 | if("hour".equals(granularity)) { | 163 | if("hour".equals(granularity)) { |
156 | hb = hbMap.get(DateUtils.formatAddTime(time,formatPattern,Calendar.DAY_OF_YEAR,-1)); | 164 | hb = hbMap.get(DateUtils.formatAddTime(time,formatPattern,Calendar.DAY_OF_YEAR,-1)); |
157 | } | 165 | } |
158 | if(hb!=null&&hb.size()>0) { | 166 | if(hb!=null&&hb.size()>0) { |
167 | double value = ConvertUtils.getDouble(map.get(index), 0); | ||
168 | double hb_value = 0; | ||
159 | if(index.contains("JSLL")||index.contains("CSLL")) { | 169 | if(index.contains("JSLL")||index.contains("CSLL")) { |
160 | tempMap.put(index+"_hb", DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(hb.get(realKey), 0.0), 2)); | 170 | hb_value = DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(hb.get(realKey), 0.0), 2); |
161 | }else { | 171 | }else { |
162 | tempMap.put(index+"_hb", DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(hb.get(realKey), 0.0)/ConvertUtils.getDouble(hb.get(realKey+"_tag"), 1.0), 2)); | 172 | hb_value = DoubleOperaUtils.bigDecimalRound(ConvertUtils.getDouble(hb.get(realKey), 0.0)/ConvertUtils.getDouble(hb.get(realKey+"_tag"), 1.0), 2); |
173 | } | ||
174 | tempMap.put(index+"_hb", hb_value); | ||
175 | //添加同比比例 | ||
176 | if(hb_value==0) { | ||
177 | map.put(index+"_hb_rate", 0); | ||
178 | }else { | ||
179 | map.put(index+"_hb_rate", DoubleOperaUtils.bigDecimalRound((value - hb_value)/hb_value*100, 2)); | ||
163 | } | 180 | } |
164 | } | 181 | } |
165 | } | 182 | } |
... | @@ -385,7 +402,15 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { | ... | @@ -385,7 +402,15 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { |
385 | Map<String,Object> tb = tbMap.get(DateUtils.formatAddTime(time,pattern,Calendar.YEAR,-1)+""+map.get("departId")); | 402 | Map<String,Object> tb = tbMap.get(DateUtils.formatAddTime(time,pattern,Calendar.YEAR,-1)+""+map.get("departId")); |
386 | if(tb!=null&&tb.size()>0) { | 403 | if(tb!=null&&tb.size()>0) { |
387 | for(String key : indexArray) { | 404 | for(String key : indexArray) { |
388 | map.put(key+"_tb", tb.get(key)); | 405 | double value = ConvertUtils.getDouble(map.get(key), 0); |
406 | double tb_value = ConvertUtils.getDouble(tb.get(key), 0); | ||
407 | map.put(key+"_tb", String.valueOf(tb_value)); | ||
408 | //添加同比比例 | ||
409 | if(tb_value==0) { | ||
410 | map.put(key+"_tb_rate", 0); | ||
411 | }else { | ||
412 | map.put(key+"_tb_rate", DoubleOperaUtils.bigDecimalRound((value - tb_value)/tb_value*100, 2)); | ||
413 | } | ||
389 | } | 414 | } |
390 | } | 415 | } |
391 | } | 416 | } |
... | @@ -393,7 +418,15 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { | ... | @@ -393,7 +418,15 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { |
393 | Map<String,Object> hb = hbMap.get(DateUtils.formatAddTime(time,pattern,Calendar.MONTH,-1)+""+map.get("departId")); | 418 | Map<String,Object> hb = hbMap.get(DateUtils.formatAddTime(time,pattern,Calendar.MONTH,-1)+""+map.get("departId")); |
394 | if(hb!=null&&hb.size()>0) { | 419 | if(hb!=null&&hb.size()>0) { |
395 | for(String key : indexArray) { | 420 | for(String key : indexArray) { |
396 | map.put(key+"_hb", hb.get(key)); | 421 | double value = ConvertUtils.getDouble(map.get(key), 0); |
422 | double hb_value = ConvertUtils.getDouble(hb.get(key), 0); | ||
423 | map.put(key+"_hb", String.valueOf(hb_value)); | ||
424 | //添加同比比例 | ||
425 | if(hb_value==0) { | ||
426 | map.put(key+"_hb_rate", 0); | ||
427 | }else { | ||
428 | map.put(key+"_hb_rate", DoubleOperaUtils.bigDecimalRound((value - hb_value)/hb_value*100, 2)); | ||
429 | } | ||
397 | } | 430 | } |
398 | } | 431 | } |
399 | } | 432 | } | ... | ... |
-
请 注册 或 登录 后发表评论