报表支持文本
This commit is contained in:
parent
0c77031e46
commit
7fa3c31aac
|
|
@ -127,7 +127,7 @@ public class SalaryStatisticsItemPO implements Serializable {
|
|||
private String medianRule;
|
||||
|
||||
|
||||
private String medianRule;
|
||||
// private String medianRule;
|
||||
|
||||
//顺序")
|
||||
private Integer indexValue;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.cloudstore.eccom.pc.table.WeaTableColumn;
|
|||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
||||
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
|
||||
import com.engine.salary.report.entity.dto.SalaryStatisticsItemFormDTO;
|
||||
import com.engine.salary.report.entity.param.SalaryStatisticsItemSaveParam;
|
||||
import com.engine.salary.report.entity.po.SalaryStatisticsItemPO;
|
||||
|
|
@ -55,22 +56,24 @@ public class SalaryStatisticsItemWrapper extends Service {
|
|||
String itemValue = salaryStatisticsItem.getItemValue();
|
||||
if (StringUtils.isNotBlank(itemValue)) {
|
||||
List<SalaryItemPO> salaryItems = getSalaryItemService(user).listAll();
|
||||
Map<String, String> itemsMap = SalaryEntityUtil.convert2Map(salaryItems, k -> k.getId().toString(), SalaryItemPO::getName);
|
||||
Map<String, SalaryItemPO> itemsMap = SalaryEntityUtil.convert2Map(salaryItems, k -> k.getId().toString());
|
||||
List<Map<String, String>> welfareItems = new ArrayList<>();
|
||||
Arrays.stream(itemValue.split(",")).forEach(value -> {
|
||||
Map<String, String> welfareItem = new HashMap<>();
|
||||
welfareItem.put("id", value);
|
||||
welfareItem.put("name", itemsMap.get(value));
|
||||
welfareItem.put("name", itemsMap.get(value).getName());
|
||||
welfareItem.put("dataType", itemsMap.get(value).getDataType());
|
||||
welfareItems.add(welfareItem);
|
||||
});
|
||||
Map map = new HashMap();
|
||||
map.put("itemValue", welfareItems);
|
||||
//版本变更,由多选变成单选
|
||||
map.put("itemValue", welfareItems.get(0));
|
||||
map.put("itemName", salaryStatisticsItem.getItemName());
|
||||
weaForm.put("data", map);
|
||||
ruleData = buildRule(salaryStatisticsItem);
|
||||
ruleData = buildRule(SalaryDataTypeEnum.parseByValue(welfareItems.get(0).get("dataType")), salaryStatisticsItem);
|
||||
}
|
||||
} else {
|
||||
ruleData = buildRule(null);
|
||||
ruleData = buildRule(null, null);
|
||||
}
|
||||
|
||||
return SalaryStatisticsItemFormDTO.builder()
|
||||
|
|
@ -80,89 +83,174 @@ public class SalaryStatisticsItemWrapper extends Service {
|
|||
.build();
|
||||
}
|
||||
|
||||
public Map buildRule(SalaryStatisticsItemPO salaryStatisticsItem) {
|
||||
public Map buildRule(SalaryDataTypeEnum dataType, SalaryStatisticsItemPO salaryStatisticsItem) {
|
||||
Map<String, Object> weaTable = new HashMap<>();
|
||||
List<WeaTableColumn> list = new ArrayList<>();
|
||||
WeaTableColumn ruleName = new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(157532, "统计规则"), "ruleName");
|
||||
WeaTableColumn ratio = new WeaTableColumn("10%", SalaryI18nUtil.getI18nLabel(162990, "占比"), "ratio");
|
||||
WeaTableColumn m2m = new WeaTableColumn("10%", SalaryI18nUtil.getI18nLabel(157533, "环比"), "m2m");
|
||||
WeaTableColumn m2mLimit = new WeaTableColumn("25%", SalaryI18nUtil.getI18nLabel(157536, "环比增幅正常区间设置"), "m2mLimit");
|
||||
WeaTableColumn y2y = new WeaTableColumn("10%", SalaryI18nUtil.getI18nLabel(162991, "同比"), "y2y");
|
||||
WeaTableColumn y2yLimit = new WeaTableColumn("25%", SalaryI18nUtil.getI18nLabel(162992, "同比增幅正常区间设置"), "y2yLimit");
|
||||
list.add(ruleName);
|
||||
list.add(ratio);
|
||||
list.add(m2m);
|
||||
list.add(m2mLimit);
|
||||
list.add(y2y);
|
||||
list.add(y2yLimit);
|
||||
weaTable.put("columns", list);
|
||||
if (dataType == null || dataType == SalaryDataTypeEnum.NUMBER) {
|
||||
List<WeaTableColumn> list = new ArrayList<>();
|
||||
WeaTableColumn ruleName = new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(157532, "统计规则"), "ruleName");
|
||||
WeaTableColumn ratio = new WeaTableColumn("10%", SalaryI18nUtil.getI18nLabel(162990, "占比"), "ratio");
|
||||
WeaTableColumn m2m = new WeaTableColumn("10%", SalaryI18nUtil.getI18nLabel(157533, "环比"), "m2m");
|
||||
WeaTableColumn m2mLimit = new WeaTableColumn("25%", SalaryI18nUtil.getI18nLabel(157536, "环比增幅正常区间设置"), "m2mLimit");
|
||||
WeaTableColumn y2y = new WeaTableColumn("10%", SalaryI18nUtil.getI18nLabel(162991, "同比"), "y2y");
|
||||
WeaTableColumn y2yLimit = new WeaTableColumn("25%", SalaryI18nUtil.getI18nLabel(162992, "同比增幅正常区间设置"), "y2yLimit");
|
||||
list.add(ruleName);
|
||||
list.add(ratio);
|
||||
list.add(m2m);
|
||||
list.add(m2mLimit);
|
||||
list.add(y2y);
|
||||
list.add(y2yLimit);
|
||||
weaTable.put("columns", list);
|
||||
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
List<String> ruleList = Arrays.asList("count", "sum", "avg", "max", "min", "median");
|
||||
List<String> ruleNameList = Arrays.asList(
|
||||
SalaryI18nUtil.getI18nLabel(157268, "计数"),
|
||||
SalaryI18nUtil.getI18nLabel(157266, "求和"),
|
||||
SalaryI18nUtil.getI18nLabel(100132, "平均值"),
|
||||
SalaryI18nUtil.getI18nLabel(163001, "最大值"),
|
||||
SalaryI18nUtil.getI18nLabel(163002, "最小值"),
|
||||
SalaryI18nUtil.getI18nLabel(163003, "中位数"));
|
||||
if (salaryStatisticsItem == null) {
|
||||
for (int i = 0; i < ruleList.size(); i++) {
|
||||
Map<String, Object> rule = new HashMap<>();
|
||||
rule.put("id", ruleList.get(i));
|
||||
rule.put("ruleName", ruleNameList.get(i));
|
||||
rule.put("totalValue", 0);
|
||||
rule.put("ratioValue", 0);
|
||||
rule.put("m2mValue", 0);
|
||||
rule.put("m2mUpperLimit", "");
|
||||
rule.put("m2mLowerLimit", "");
|
||||
rule.put("y2yValue", 0);
|
||||
rule.put("y2yUpperLimit", "");
|
||||
rule.put("y2yLowerLimit", "");
|
||||
result.add(rule);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < ruleList.size(); i++) {
|
||||
Map<String, Object> rule = new HashMap<>();
|
||||
switch (ruleList.get(i)) {
|
||||
case "count":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getCountRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "sum":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getSumRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "avg":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getAvgRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "max":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getMaxRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "min":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getMinRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "median":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getMedianRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
List<String> ruleList = Arrays.asList("count", "sum", "avg", "max", "min", "median");
|
||||
List<String> ruleNameList = Arrays.asList(
|
||||
SalaryI18nUtil.getI18nLabel(157268, "计数"),
|
||||
SalaryI18nUtil.getI18nLabel(157266, "求和"),
|
||||
SalaryI18nUtil.getI18nLabel(100132, "平均值"),
|
||||
SalaryI18nUtil.getI18nLabel(163001, "最大值"),
|
||||
SalaryI18nUtil.getI18nLabel(163002, "最小值"),
|
||||
SalaryI18nUtil.getI18nLabel(163003, "中位数"));
|
||||
if (salaryStatisticsItem == null) {
|
||||
for (int i = 0; i < ruleList.size(); i++) {
|
||||
Map<String, Object> rule = new HashMap<>();
|
||||
rule.put("id", ruleList.get(i));
|
||||
rule.put("ruleName", ruleNameList.get(i));
|
||||
rule.put("totalValue", 0);
|
||||
rule.put("ratioValue", 0);
|
||||
rule.put("m2mValue", 0);
|
||||
rule.put("m2mUpperLimit", "");
|
||||
rule.put("m2mLowerLimit", "");
|
||||
rule.put("y2yValue", 0);
|
||||
rule.put("y2yUpperLimit", "");
|
||||
rule.put("y2yLowerLimit", "");
|
||||
result.add(rule);
|
||||
}
|
||||
if (rule == null) {
|
||||
rule = new HashMap<>();
|
||||
} else {
|
||||
for (int i = 0; i < ruleList.size(); i++) {
|
||||
Map<String, Object> rule = new HashMap<>();
|
||||
switch (ruleList.get(i)) {
|
||||
case "count":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getCountRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "sum":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getSumRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "avg":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getAvgRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "max":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getMaxRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "min":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getMinRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "median":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getMedianRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (rule == null) {
|
||||
rule = new HashMap<>();
|
||||
}
|
||||
rule.put("id", ruleList.get(i));
|
||||
rule.put("ruleName", ruleNameList.get(i));
|
||||
rule.put("totalValue", Optional.ofNullable(rule.get("totalValue")).orElse(0));
|
||||
rule.put("ratioValue", Optional.ofNullable(rule.get("ratioValue")).orElse(0));
|
||||
rule.put("m2mValue", Optional.ofNullable(rule.get("m2mValue")).orElse(0));
|
||||
rule.put("m2mUpperLimit", Optional.ofNullable(rule.get("m2mUpperLimit")).orElse(""));
|
||||
rule.put("m2mLowerLimit", Optional.ofNullable(rule.get("m2mLowerLimit")).orElse(""));
|
||||
rule.put("y2yValue", Optional.ofNullable(rule.get("y2yValue")).orElse(0));
|
||||
rule.put("y2yUpperLimit", Optional.ofNullable(rule.get("y2yUpperLimit")).orElse(""));
|
||||
rule.put("y2yLowerLimit", Optional.ofNullable(rule.get("y2yLowerLimit")).orElse(""));
|
||||
result.add(rule);
|
||||
}
|
||||
rule.put("id", ruleList.get(i));
|
||||
rule.put("ruleName", ruleNameList.get(i));
|
||||
rule.put("totalValue", Optional.ofNullable(rule.get("totalValue")).orElse(0));
|
||||
rule.put("ratioValue", Optional.ofNullable(rule.get("ratioValue")).orElse(0));
|
||||
rule.put("m2mValue", Optional.ofNullable(rule.get("m2mValue")).orElse(0));
|
||||
rule.put("m2mUpperLimit", Optional.ofNullable(rule.get("m2mUpperLimit")).orElse(""));
|
||||
rule.put("m2mLowerLimit", Optional.ofNullable(rule.get("m2mLowerLimit")).orElse(""));
|
||||
rule.put("y2yValue", Optional.ofNullable(rule.get("y2yValue")).orElse(0));
|
||||
rule.put("y2yUpperLimit", Optional.ofNullable(rule.get("y2yUpperLimit")).orElse(""));
|
||||
rule.put("y2yLowerLimit", Optional.ofNullable(rule.get("y2yLowerLimit")).orElse(""));
|
||||
result.add(rule);
|
||||
}
|
||||
weaTable.put("data", result);
|
||||
}else {
|
||||
List<WeaTableColumn> list = new ArrayList<>();
|
||||
WeaTableColumn ruleName = new WeaTableColumn("20%", SalaryI18nUtil.getI18nLabel(157532, "统计规则"), "ruleName");
|
||||
WeaTableColumn ratio = new WeaTableColumn("10%", SalaryI18nUtil.getI18nLabel(162990, "占比"), "ratio");
|
||||
WeaTableColumn m2m = new WeaTableColumn("10%", SalaryI18nUtil.getI18nLabel(157533, "环比"), "m2m");
|
||||
WeaTableColumn m2mLimit = new WeaTableColumn("25%", SalaryI18nUtil.getI18nLabel(157536, "环比增幅正常区间设置"), "m2mLimit");
|
||||
WeaTableColumn y2y = new WeaTableColumn("10%", SalaryI18nUtil.getI18nLabel(162991, "同比"), "y2y");
|
||||
WeaTableColumn y2yLimit = new WeaTableColumn("25%", SalaryI18nUtil.getI18nLabel(162992, "同比增幅正常区间设置"), "y2yLimit");
|
||||
list.add(ruleName);
|
||||
list.add(ratio);
|
||||
list.add(m2m);
|
||||
list.add(m2mLimit);
|
||||
list.add(y2y);
|
||||
list.add(y2yLimit);
|
||||
weaTable.put("columns", list);
|
||||
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
List<String> ruleList = Arrays.asList("count", "sum", "avg", "max", "min", "median");
|
||||
List<String> ruleNameList = Arrays.asList(
|
||||
SalaryI18nUtil.getI18nLabel(157268, "计数"),
|
||||
SalaryI18nUtil.getI18nLabel(157266, "求和"),
|
||||
SalaryI18nUtil.getI18nLabel(100132, "平均值"),
|
||||
SalaryI18nUtil.getI18nLabel(163001, "最大值"),
|
||||
SalaryI18nUtil.getI18nLabel(163002, "最小值"),
|
||||
SalaryI18nUtil.getI18nLabel(163003, "中位数"));
|
||||
if (salaryStatisticsItem == null) {
|
||||
for (int i = 0; i < ruleList.size(); i++) {
|
||||
Map<String, Object> rule = new HashMap<>();
|
||||
rule.put("id", ruleList.get(i));
|
||||
rule.put("ruleName", ruleNameList.get(i));
|
||||
rule.put("totalValue", 0);
|
||||
rule.put("ratioValue", 0);
|
||||
rule.put("m2mValue", 0);
|
||||
rule.put("m2mUpperLimit", "");
|
||||
rule.put("m2mLowerLimit", "");
|
||||
rule.put("y2yValue", 0);
|
||||
rule.put("y2yUpperLimit", "");
|
||||
rule.put("y2yLowerLimit", "");
|
||||
result.add(rule);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < ruleList.size(); i++) {
|
||||
Map<String, Object> rule = new HashMap<>();
|
||||
switch (ruleList.get(i)) {
|
||||
case "count":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getCountRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "sum":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getSumRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "avg":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getAvgRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "max":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getMaxRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "min":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getMinRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
case "median":
|
||||
rule = JSON.parseObject(salaryStatisticsItem.getMedianRule(), new HashMap<String, String>().getClass());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (rule == null) {
|
||||
rule = new HashMap<>();
|
||||
}
|
||||
rule.put("id", ruleList.get(i));
|
||||
rule.put("ruleName", ruleNameList.get(i));
|
||||
rule.put("totalValue", Optional.ofNullable(rule.get("totalValue")).orElse(0));
|
||||
rule.put("ratioValue", Optional.ofNullable(rule.get("ratioValue")).orElse(0));
|
||||
rule.put("m2mValue", Optional.ofNullable(rule.get("m2mValue")).orElse(0));
|
||||
rule.put("m2mUpperLimit", Optional.ofNullable(rule.get("m2mUpperLimit")).orElse(""));
|
||||
rule.put("m2mLowerLimit", Optional.ofNullable(rule.get("m2mLowerLimit")).orElse(""));
|
||||
rule.put("y2yValue", Optional.ofNullable(rule.get("y2yValue")).orElse(0));
|
||||
rule.put("y2yUpperLimit", Optional.ofNullable(rule.get("y2yUpperLimit")).orElse(""));
|
||||
rule.put("y2yLowerLimit", Optional.ofNullable(rule.get("y2yLowerLimit")).orElse(""));
|
||||
result.add(rule);
|
||||
}
|
||||
}
|
||||
weaTable.put("data", result);
|
||||
}
|
||||
weaTable.put("data", result);
|
||||
|
||||
return weaTable;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue