Commit 355de78b authored by 廖旭伟's avatar 廖旭伟

绩效规则分数统计

parent 789e712a
...@@ -12,7 +12,7 @@ import lombok.Data; ...@@ -12,7 +12,7 @@ import lombok.Data;
*/ */
@Data @Data
public class PerformRulesVo extends BaseEntityLong { public class PerformRulesVo extends BaseEntityLong {
/** 类型名称 **/
private String typeName;
} }
\ No newline at end of file
package com.mortals.xhx.module.perform.service; package com.mortals.xhx.module.perform.service;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ICRUDCacheService; import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.perform.model.PerformRulesEntity; import com.mortals.xhx.module.perform.model.PerformRulesEntity;
import com.mortals.xhx.module.perform.dao.PerformRulesDao; import com.mortals.xhx.module.perform.dao.PerformRulesDao;
import java.util.List;
import java.util.Map;
/** /**
* PerformRulesService * PerformRulesService
* *
...@@ -14,4 +19,11 @@ import com.mortals.xhx.module.perform.dao.PerformRulesDao; ...@@ -14,4 +19,11 @@ import com.mortals.xhx.module.perform.dao.PerformRulesDao;
public interface PerformRulesService extends ICRUDCacheService<PerformRulesEntity,Long> { public interface PerformRulesService extends ICRUDCacheService<PerformRulesEntity,Long> {
PerformRulesDao getDao(); PerformRulesDao getDao();
/**
* 规则分数统计
* @return
* @throws AppException
*/
Map<String,Object> summaryRules() throws AppException;
} }
\ No newline at end of file
...@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil; ...@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.pinyin.PinyinUtil; import cn.hutool.extra.pinyin.PinyinUtil;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.xhx.base.system.idgenerator.service.IdgeneratorService; import com.mortals.xhx.base.system.idgenerator.service.IdgeneratorService;
import com.mortals.xhx.common.code.CheckTypeEnum;
import com.mortals.xhx.common.code.CommentTypeEnum; import com.mortals.xhx.common.code.CommentTypeEnum;
import com.mortals.xhx.common.code.PerformRulesTypeEnum; import com.mortals.xhx.common.code.PerformRulesTypeEnum;
import com.mortals.xhx.common.code.PerformTypeEnum; import com.mortals.xhx.common.code.PerformTypeEnum;
...@@ -19,6 +20,13 @@ import com.mortals.xhx.module.perform.service.PerformRulesService; ...@@ -19,6 +20,13 @@ import com.mortals.xhx.module.perform.service.PerformRulesService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.mortals.xhx.base.system.idgenerator.service.impl.IdgeneratorServiceImpl.IdGeneratorKey.*; import static com.mortals.xhx.base.system.idgenerator.service.impl.IdgeneratorServiceImpl.IdGeneratorKey.*;
/** /**
...@@ -93,4 +101,31 @@ public class PerformRulesServiceImpl extends AbstractCRUDCacheServiceImpl<Perfor ...@@ -93,4 +101,31 @@ public class PerformRulesServiceImpl extends AbstractCRUDCacheServiceImpl<Perfor
System.out.println(PinyinUtil.getFirstLetter(str, "")); System.out.println(PinyinUtil.getFirstLetter(str, ""));
} }
@Override
public Map<String,Object> summaryRules() throws AppException {
Map<String,Object> resultMap = new HashMap<>();
List<PerformRulesEntity> all = this.getAllList();
List<PerformRulesEntity> resultList = new ArrayList<>();
BigDecimal totalScore = new BigDecimal(0);
Map<Integer,List<PerformRulesEntity>> groupMap = all.stream().collect(Collectors.groupingBy(PerformRulesEntity::getType));
for (Map.Entry<Integer, List<PerformRulesEntity>> entry:groupMap.entrySet()){
BigDecimal sum = new BigDecimal(0);
for(PerformRulesEntity item:entry.getValue()){
sum = sum.add(item.getScore());
}
PerformRulesEntity entity = new PerformRulesEntity();
entity.setType(entry.getKey());
CheckTypeEnum type = CheckTypeEnum.getByValue(entry.getKey());
if(type!=null){
entity.setTypeName(type.getDesc());
}
entity.setScore(sum);
totalScore = totalScore.add(sum);
resultList.add(entity);
}
resultMap.put("totalScore",totalScore);
resultMap.put("list",resultList);
return resultMap;
}
} }
\ No newline at end of file
package com.mortals.xhx.module.perform.web; package com.mortals.xhx.module.perform.web;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.OrderCol; import com.mortals.framework.model.OrderCol;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.user.model.UserQuery; import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService; import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.CheckTypeEnum;
import com.mortals.xhx.module.perform.model.PerformRulesCategoryQuery; import com.mortals.xhx.module.perform.model.PerformRulesCategoryQuery;
import com.mortals.xhx.module.perform.model.PerformRulesEntity; import com.mortals.xhx.module.perform.model.PerformRulesEntity;
import com.mortals.xhx.module.perform.service.PerformRulesCategoryService; import com.mortals.xhx.module.perform.service.PerformRulesCategoryService;
import com.mortals.xhx.module.perform.service.PerformRulesService; import com.mortals.xhx.module.perform.service.PerformRulesService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static java.util.stream.Collectors.toMap; import static java.util.stream.Collectors.toMap;
...@@ -47,7 +56,7 @@ public class PerformRulesController extends BaseCRUDJsonBodyMappingController<Pe ...@@ -47,7 +56,7 @@ public class PerformRulesController extends BaseCRUDJsonBodyMappingController<Pe
protected void init(Map<String, Object> model, Context context) { protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "subAddType", paramService.getParamBySecondOrganize("PerformRules", "subAddType")); this.addDict(model, "subAddType", paramService.getParamBySecondOrganize("PerformRules", "subAddType"));
this.addDict(model, "assoOwner", paramService.getParamBySecondOrganize("PerformRules", "assoOwner")); this.addDict(model, "assoOwner", paramService.getParamBySecondOrganize("PerformRules", "assoOwner"));
this.addDict(model, "type", paramService.getParamBySecondOrganize("PerformRules", "type")); this.addDict(model, "type", CheckTypeEnum.getEnumMap());
this.addDict(model, "categoryId", categoryService.find(new PerformRulesCategoryQuery()).stream().collect(toMap(x -> x.getId().toString(), y -> y.getName(), (o, n) -> n))); this.addDict(model, "categoryId", categoryService.find(new PerformRulesCategoryQuery()).stream().collect(toMap(x -> x.getId().toString(), y -> y.getName(), (o, n) -> n)));
this.addDict(model, "createUserId", userService.find(new UserQuery()).stream().collect(toMap(x -> x.getId().toString(), y -> y.getRealName(), (o, n) -> n))); this.addDict(model, "createUserId", userService.find(new UserQuery()).stream().collect(toMap(x -> x.getId().toString(), y -> y.getRealName(), (o, n) -> n)));
super.init(model, context); super.init(model, context);
...@@ -58,4 +67,33 @@ public class PerformRulesController extends BaseCRUDJsonBodyMappingController<Pe ...@@ -58,4 +67,33 @@ public class PerformRulesController extends BaseCRUDJsonBodyMappingController<Pe
super.doListBefore(query, model, context); super.doListBefore(query, model, context);
query.setOrderColList(Arrays.asList(new OrderCol("createTime", OrderCol.DESCENDING))); query.setOrderColList(Arrays.asList(new OrderCol("createTime", OrderCol.DESCENDING)));
} }
@PostMapping({"summary"})
@UnAuth
public Rest<Object> summary() {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "查询规则分数统计";
int code = 1;
try {
Map<String,Object> result = this.getService().summaryRules();
model.put("data", result);
model.put("message_info", busiDesc + "成功");
if (!ObjectUtils.isEmpty(context) && !ObjectUtils.isEmpty(context.getUser())) {
this.recordSysLog(this.request, busiDesc + " 【成功】");
}
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
this.init(model, context);
ret.setCode(code);
ret.setData(model.get("data"));
ret.setDict(model.get("dict"));
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
} }
\ 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