Commit 7bfa8031 by zhangkb

添加单位得分结果表和存储逻辑代码

parent 2e9a436e
...@@ -76,10 +76,10 @@ public class ObjScoreRuleCtrl { ...@@ -76,10 +76,10 @@ public class ObjScoreRuleCtrl {
@ApiOperation(value = "根据单位评分规则计算单位评分", notes = "根据单位评分规则计算单位评分") @ApiOperation(value = "根据单位评分规则计算单位评分", notes = "根据单位评分规则计算单位评分")
@PostMapping(value = "/calculateObjectScore") @PostMapping(value = "/calculateObjectScore")
public List<Map<String,String>> calculateObjectScore(@RequestParam String reportId, public void calculateObjectScore(
@RequestParam String compareId,@RequestParam List<String> indIds, @RequestParam String compareId,@RequestParam List<String> indIds,
@RequestParam List<String> compareObjs,@RequestParam int date, @RequestParam List<String> compareObjs,@RequestParam int date,
@RequestParam Integer scoreRuleId){ @RequestParam Integer scoreRuleId){
return scoreRuleService.calObjScore(reportId, compareId, indIds, compareObjs, date, scoreRuleId); scoreRuleService.calObjScore(compareId, indIds, compareObjs, date, scoreRuleId);
} }
} }
package com.keymobile.indicators.model.entity.objscorerule;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
/**
*author:zhangkb time:2020-6-22 desc:单位评分结果存放实体
*/
@Data
@Table(name ="obj_score_cal_result")
public class ObjScoreCalResult {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String compareId;//对标单元id
private String compareObj;//对标对象
private String indIds;//对标考核指标id
private Integer date;//对标日期
private String scoreValue;//考核对象得分
private String improveValue;//考核对象改善得分
}
...@@ -4,10 +4,9 @@ import java.util.List; ...@@ -4,10 +4,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.indicators.BaseIndDef; import com.keymobile.indicators.model.entity.indicators.BaseIndDef;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
...@@ -16,7 +15,7 @@ public interface BaseIndDefMapper extends BaseMapper<BaseIndDef>{ ...@@ -16,7 +15,7 @@ public interface BaseIndDefMapper extends BaseMapper<BaseIndDef>{
public int getByKeywordCount(Map<String,Object> param); public int getByKeywordCount(Map<String,Object> param);
public void deleteByCatalogIdIn(@Param("list")List<Integer> catalogIds); public void deleteByCatalogIdIn(@Param("catalogIds")List<Integer> catalogIds);
public String getMaxIndId(@Param("code")String code,@Param("length")int length); public String getMaxIndId(@Param("code")String code,@Param("length")int length);
} }
...@@ -4,10 +4,9 @@ import java.util.List; ...@@ -4,10 +4,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.indicators.DriveIndDef; import com.keymobile.indicators.model.entity.indicators.DriveIndDef;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
...@@ -16,9 +15,9 @@ public interface DriveIndDefMapper extends BaseMapper<DriveIndDef>{ ...@@ -16,9 +15,9 @@ public interface DriveIndDefMapper extends BaseMapper<DriveIndDef>{
public int getByKeywordCount(Map<String,Object> param); public int getByKeywordCount(Map<String,Object> param);
public void deleteByCatalogIdIn(@Param("list")List<Integer> catalogIds); public void deleteByCatalogIdIn(@Param("catalogIds")List<Integer> catalogIds);
public String getMaxIndId(@Param("code")String code,@Param("length")int length); public String getMaxIndId(@Param("code")String code,@Param("length")int length);
public List<DriveIndDef> getByIdList(@Param("list")List<String> ids); public List<DriveIndDef> getByIdList(@Param("ids")List<String> ids);
} }
...@@ -4,10 +4,9 @@ import java.util.List; ...@@ -4,10 +4,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef; import com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
......
...@@ -4,14 +4,14 @@ import java.util.List; ...@@ -4,14 +4,14 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.indicators.DriveIndCatalog; import com.keymobile.indicators.model.entity.indicators.DriveIndCatalog;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
public interface DriveIndCatalogMapper extends BaseMapper<DriveIndCatalog>{ public interface DriveIndCatalogMapper extends BaseMapper<DriveIndCatalog>{
public void deleteByIdIn(@Param("list")List<Integer> ids); public void deleteByIdIn(@Param("ids")List<Integer> ids);
public List<DriveIndCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params); public List<DriveIndCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params);
......
...@@ -4,15 +4,15 @@ import java.util.List; ...@@ -4,15 +4,15 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.indicators.IndCatalog; import com.keymobile.indicators.model.entity.indicators.IndCatalog;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
public interface IndCatalogMapper extends BaseMapper<IndCatalog>{ public interface IndCatalogMapper extends BaseMapper<IndCatalog>{
public void deleteByIdIn(@Param("list")List<Integer> ids); public void deleteByIdIn(@Param("ids")List<Integer> ids);
public List<IndCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params); public List<IndCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params);
......
...@@ -3,20 +3,19 @@ package com.keymobile.indicators.model.mapper.indmapper; ...@@ -3,20 +3,19 @@ package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.scorecard.IndScorecard; import com.keymobile.indicators.model.entity.scorecard.IndScorecard;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
public interface IndScorecardMapper extends BaseMapper<IndScorecard>{ public interface IndScorecardMapper extends BaseMapper<IndScorecard>{
public void deleteByCatalogIdIn(@Param("list")List<Integer> catalogIds); public void deleteByCatalogIdIn(@Param("catalogIds")List<Integer> catalogIds);
public List<IndScorecard> findByCatalogId(@Param("catalogId")Integer catalogId, public List<IndScorecard> findByCatalogId(@Param("catalogId")Integer catalogId,
@Param("start") int start,@Param("end") int end); @Param("start") int start,@Param("end") int end);
public int countByCatalogId(@Param("catalogId")Integer catalogId); public int countByCatalogId(@Param("catalogId")Integer catalogId);
public List<IndScorecard> findByIdList(@Param("list")List<Integer> ids); public List<IndScorecard> findByIdList(@Param("ids")List<Integer> ids);
} }
package com.keymobile.indicators.model.mapper.indmapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.objscorerule.ObjScoreCalResult;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface ObjScoreCalResultMapper extends BaseMapper<ObjScoreCalResult>{
public ObjScoreCalResult getObjScoreCalResultByParam(@Param("compareId")String compareId,
@Param("compareObj")String compareObj,@Param("date")Integer date);
}
...@@ -4,15 +4,14 @@ import java.util.List; ...@@ -4,15 +4,14 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.objscorerule.ScoreRuleCatalog; import com.keymobile.indicators.model.entity.objscorerule.ScoreRuleCatalog;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
public interface ScoreRuleCatalogMapper extends BaseMapper<ScoreRuleCatalog>{ public interface ScoreRuleCatalogMapper extends BaseMapper<ScoreRuleCatalog>{
public void deleteByIdIn(@Param("list")List<Integer> ids); public void deleteByIdIn(@Param("ids")List<Integer> ids);
public List<ScoreRuleCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params); public List<ScoreRuleCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params);
......
...@@ -3,17 +3,16 @@ package com.keymobile.indicators.model.mapper.indmapper; ...@@ -3,17 +3,16 @@ package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.objscorerule.ScoreRule; import com.keymobile.indicators.model.entity.objscorerule.ScoreRule;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
public interface ScoreRuleMapper extends BaseMapper<ScoreRule>{ public interface ScoreRuleMapper extends BaseMapper<ScoreRule>{
public List<ScoreRule> findByCode(@Param("code")String code); public List<ScoreRule> findByCode(@Param("code")String code);
public void deleteByCatalogIdIn(@Param("list")List<Integer> ids); public void deleteByCatalogIdIn(@Param("ids")List<Integer> ids);
public List<ScoreRule> findByCatalogId(@Param("catalogId")Integer catalogId, public List<ScoreRule> findByCatalogId(@Param("catalogId")Integer catalogId,
@Param("start") int start,@Param("end") int end); @Param("start") int start,@Param("end") int end);
......
...@@ -4,15 +4,14 @@ import java.util.List; ...@@ -4,15 +4,14 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.scorecard.ScorecardCatalog; import com.keymobile.indicators.model.entity.scorecard.ScorecardCatalog;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
public interface ScorecardCatalogMapper extends BaseMapper<ScorecardCatalog>{ public interface ScorecardCatalogMapper extends BaseMapper<ScorecardCatalog>{
public void deleteByIdIn(@Param("list")List<Integer> ids); public void deleteByIdIn(@Param("ids")List<Integer> ids);
public List<ScorecardCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params); public List<ScorecardCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params);
......
...@@ -4,14 +4,14 @@ import java.util.List; ...@@ -4,14 +4,14 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import com.keymobile.indicators.model.entity.shortboard.ShortboardCatalog; import org.apache.ibatis.annotations.Param;
import feign.Param; import com.keymobile.indicators.model.entity.shortboard.ShortboardCatalog;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
public interface ShortboardCatalogMapper extends BaseMapper<ShortboardCatalog>{ public interface ShortboardCatalogMapper extends BaseMapper<ShortboardCatalog>{
public void deleteByIdIn(@Param("list")List<Integer> ids); public void deleteByIdIn(@Param("ids")List<Integer> ids);
public List<ShortboardCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params); public List<ShortboardCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params);
......
...@@ -3,10 +3,9 @@ package com.keymobile.indicators.model.mapper.indmapper; ...@@ -3,10 +3,9 @@ package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.shortboard.ShortboardDriveIndRel; import com.keymobile.indicators.model.entity.shortboard.ShortboardDriveIndRel;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
......
...@@ -3,15 +3,14 @@ package com.keymobile.indicators.model.mapper.indmapper; ...@@ -3,15 +3,14 @@ package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.shortboard.ShortboardRule; import com.keymobile.indicators.model.entity.shortboard.ShortboardRule;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
public interface ShortboardRuleMapper extends BaseMapper<ShortboardRule>{ public interface ShortboardRuleMapper extends BaseMapper<ShortboardRule>{
public void deleteByCatalogIdIn(@Param("list")List<Integer> ids); public void deleteByCatalogIdIn(@Param("ids")List<Integer> ids);
public List<ShortboardRule> findByCatalogId(@Param("catalogId")Integer catalogId, public List<ShortboardRule> findByCatalogId(@Param("catalogId")Integer catalogId,
@Param("start") int start,@Param("end") int end); @Param("start") int start,@Param("end") int end);
......
...@@ -4,15 +4,14 @@ import java.util.List; ...@@ -4,15 +4,14 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.shortboard.ShortboardUnitCatalog; import com.keymobile.indicators.model.entity.shortboard.ShortboardUnitCatalog;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
public interface ShortboardUnitCatalogMapper extends BaseMapper<ShortboardUnitCatalog>{ public interface ShortboardUnitCatalogMapper extends BaseMapper<ShortboardUnitCatalog>{
public void deleteByIdIn(@Param("list")List<Integer> ids); public void deleteByIdIn(@Param("ids")List<Integer> ids);
public List<ShortboardUnitCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params); public List<ShortboardUnitCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params);
......
...@@ -3,15 +3,14 @@ package com.keymobile.indicators.model.mapper.indmapper; ...@@ -3,15 +3,14 @@ package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.keymobile.indicators.model.entity.shortboard.ShortboardUnit; import com.keymobile.indicators.model.entity.shortboard.ShortboardUnit;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper; import tk.mybatis.mapper.common.BaseMapper;
@Mapper @Mapper
public interface ShortboardUnitMapper extends BaseMapper<ShortboardUnit>{ public interface ShortboardUnitMapper extends BaseMapper<ShortboardUnit>{
public void deleteByCatalogIdIn(@Param("list")List<Integer> ids); public void deleteByCatalogIdIn(@Param("ids")List<Integer> ids);
public List<ShortboardUnit> findByCatalogId(@Param("catalogId")Integer catalogId, public List<ShortboardUnit> findByCatalogId(@Param("catalogId")Integer catalogId,
@Param("start") int start,@Param("end") int end); @Param("start") int start,@Param("end") int end);
......
...@@ -19,9 +19,11 @@ import com.googlecode.aviator.AviatorEvaluator; ...@@ -19,9 +19,11 @@ import com.googlecode.aviator.AviatorEvaluator;
import com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef; import com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef;
import com.keymobile.indicators.model.entity.indicators.DriveIndDef; import com.keymobile.indicators.model.entity.indicators.DriveIndDef;
import com.keymobile.indicators.model.entity.objscorerule.IndTypeWeight; import com.keymobile.indicators.model.entity.objscorerule.IndTypeWeight;
import com.keymobile.indicators.model.entity.objscorerule.ObjScoreCalResult;
import com.keymobile.indicators.model.entity.objscorerule.ScoreRule; import com.keymobile.indicators.model.entity.objscorerule.ScoreRule;
import com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper; import com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper;
import com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper; import com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper;
import com.keymobile.indicators.model.mapper.indmapper.ObjScoreCalResultMapper;
import com.keymobile.indicators.model.mapper.indmapper.ScoreRuleMapper; import com.keymobile.indicators.model.mapper.indmapper.ScoreRuleMapper;
import com.keymobile.indicators.utils.CalculateUtils; import com.keymobile.indicators.utils.CalculateUtils;
...@@ -35,6 +37,8 @@ public class ScoreRuleService { ...@@ -35,6 +37,8 @@ public class ScoreRuleService {
private DriveIndDefMapper driveIndDefMapper; private DriveIndDefMapper driveIndDefMapper;
@Autowired @Autowired
private DriveIndCalResultDefMapper driveIndCalResultDefMapper; private DriveIndCalResultDefMapper driveIndCalResultDefMapper;
@Autowired
private ObjScoreCalResultMapper objScoreCalResultMapper;
private static final Pattern P = Pattern.compile("(\\[[^\\]]*\\])"); private static final Pattern P = Pattern.compile("(\\[[^\\]]*\\])");
...@@ -84,13 +88,13 @@ public class ScoreRuleService { ...@@ -84,13 +88,13 @@ public class ScoreRuleService {
} }
//计算组内考核指标平均值 //计算组内考核指标平均值
private Map<String,String> calGroupIndAverage(ScoreRule scoreRule,List<String> indIds, private ObjScoreCalResult calGroupIndAverage(ObjScoreCalResult objResult,ScoreRule scoreRule,List<String> indIds,
String compareObj,int date){ String compareObj,int date){
Map<String,String> result = new HashMap<>(); objResult.setCompareObj(compareObj);
result.put("compareObj", compareObj); objResult.setScoreValue("0.0");
result.put("scoreValue", "0.0"); objResult.setImproveValue("0.0");
result.put("improveValue", "0.0"); objResult.setDate(date);
result.put("date",String.valueOf(date)); objResult.setIndIds(String.join(",", indIds));
//根据日期,对标对象和考核的指标获取考核指标结果详情 //根据日期,对标对象和考核的指标获取考核指标结果详情
Map<String,Object> paremMap = new HashMap<>(); Map<String,Object> paremMap = new HashMap<>();
paremMap.put("compareObj", compareObj); paremMap.put("compareObj", compareObj);
...@@ -140,19 +144,19 @@ public class ScoreRuleService { ...@@ -140,19 +144,19 @@ public class ScoreRuleService {
if(!improveValues.isEmpty()) { if(!improveValues.isEmpty()) {
averageImproveValue = CalculateUtils.averageValue(improveValues,0); averageImproveValue = CalculateUtils.averageValue(improveValues,0);
} }
result.put("scoreValue", averageValue); objResult.setScoreValue(averageValue);
result.put("improveValue", averageImproveValue); objResult.setImproveValue(averageImproveValue);
} }
return result; return objResult;
} }
private Map<String,String> calSingleIndWeight(ScoreRule scoreRule, private ObjScoreCalResult calSingleIndWeight(ObjScoreCalResult objResult,ScoreRule scoreRule,
String compareObj,int date){ String compareObj,int date){
Map<String,String> result = new HashMap<>(); objResult.setCompareObj(compareObj);
result.put("compareObj", compareObj); objResult.setScoreValue("0.0");
result.put("scoreValue", "0.0"); objResult.setImproveValue("0.0");
result.put("improveValue", "0.0"); objResult.setDate(date);
result.put("date",String.valueOf(date));
String calFormula = scoreRule.getCalFormula();//计算综合评分分数 String calFormula = scoreRule.getCalFormula();//计算综合评分分数
String improveCalFormula = scoreRule.getCalFormula();//计算改善提升分数 String improveCalFormula = scoreRule.getCalFormula();//计算改善提升分数
if(StringUtils.isNotBlank(calFormula)) { if(StringUtils.isNotBlank(calFormula)) {
...@@ -211,25 +215,24 @@ public class ScoreRuleService { ...@@ -211,25 +215,24 @@ public class ScoreRuleService {
//得分类型:0 指标值直接参与计算 //得分类型:0 指标值直接参与计算
if("0".equals(scoreRule.getScoreType()) || if("0".equals(scoreRule.getScoreType()) ||
"2".equals(scoreRule.getScoreType())) { "2".equals(scoreRule.getScoreType())) {
result.put("scoreValue", AviatorEvaluator.execute(calFormula).toString()); objResult.setScoreValue(AviatorEvaluator.execute(calFormula).toString());
result.put("improveValue","0.0"); objResult.setImproveValue("0.0");
}else if("1".equals(scoreRule.getScoreType())) {//1 指标得分分数参与计算(综合评分和改善提升分开算) }else if("1".equals(scoreRule.getScoreType())) {//1 指标得分分数参与计算(综合评分和改善提升分开算)
result.put("scoreValue", AviatorEvaluator.execute(calFormula).toString()); objResult.setScoreValue(AviatorEvaluator.execute(calFormula).toString());
result.put("improveValue",AviatorEvaluator.execute(improveCalFormula).toString()); objResult.setImproveValue(AviatorEvaluator.execute(improveCalFormula).toString());
} }
} }
return result; return objResult;
} }
//按照指标类别进行分类分别计算平均分后再跟类别权重相乘后相加得到最终分数 //按照指标类别进行分类分别计算平均分后再跟类别权重相乘后相加得到最终分数
private Map<String,String> calIndCatalogTypeAverage(ScoreRule scoreRule, private ObjScoreCalResult calIndCatalogTypeAverage(ObjScoreCalResult objResult,ScoreRule scoreRule,
String compareObj,int date){ String compareObj,int date){
Map<String,String> result = new HashMap<>();
Gson gson = new Gson(); Gson gson = new Gson();
result.put("compareObj", compareObj); objResult.setCompareObj(compareObj);
result.put("scoreValue", "0.0"); objResult.setScoreValue("0.0");
result.put("improveValue", "0.0"); objResult.setImproveValue("0.0");
result.put("date",String.valueOf(date)); objResult.setDate(date);
//根据对标对象,日期查找该对标对象对标的所有指标结果 //根据对标对象,日期查找该对标对象对标的所有指标结果
List<DriveIndCalResultDef> calResults = driveIndCalResultDefMapper. List<DriveIndCalResultDef> calResults = driveIndCalResultDefMapper.
...@@ -247,9 +250,9 @@ public class ScoreRuleService { ...@@ -247,9 +250,9 @@ public class ScoreRuleService {
} }
} }
} }
result.put("scoreValue", String.valueOf(scoreValue)); objResult.setScoreValue(String.valueOf(scoreValue));
result.put("improveValue", String.valueOf(improveValue)); objResult.setImproveValue(String.valueOf(improveValue));
return result; return objResult;
} }
//根据指标分类计算指标平均值 //根据指标分类计算指标平均值
...@@ -308,29 +311,38 @@ public class ScoreRuleService { ...@@ -308,29 +311,38 @@ public class ScoreRuleService {
} }
//根据单位评分规则计算单位分数 //根据单位评分规则计算单位分数
public List<Map<String,String>> calObjScore(String reportId,String compareId,List<String> indIds, public void calObjScore(String compareId,List<String> indIds,
List<String> compareObjs,int date,Integer scoreRuleId) { List<String> compareObjs,int date,Integer scoreRuleId) {
List<Map<String,String>> results = new ArrayList<>();
//根据单位得分评分卡id获取评分卡详情 //根据单位得分评分卡id获取评分卡详情
ScoreRule scoreRule = this.getById(scoreRuleId); ScoreRule scoreRule = this.getById(scoreRuleId);
if(scoreRule!=null) { if(scoreRule!=null) {
for(String compareObj : compareObjs) { for(String compareObj : compareObjs) {
Map<String,String> resultMap = new HashMap<>(); //判断库表是否已存在改结果数据
ObjScoreCalResult objScoreCalResult = objScoreCalResultMapper.
getObjScoreCalResultByParam(compareId, compareObj, date);
if(objScoreCalResult == null) {
objScoreCalResult = new ObjScoreCalResult();
}
//计算类型:0 计算组内所有考核指标平均数 //计算类型:0 计算组内所有考核指标平均数
if("0".equals(scoreRule.getCalType())) { if("0".equals(scoreRule.getCalType())) {
resultMap = this.calGroupIndAverage(scoreRule, indIds, compareObj, date); objScoreCalResult = this.calGroupIndAverage(objScoreCalResult, scoreRule,
indIds, compareObj, date);
}else if("1".equals(scoreRule.getCalType())) {//1 根据目录类别分类算平均分后根据权重计算考核指标 }else if("1".equals(scoreRule.getCalType())) {//1 根据目录类别分类算平均分后根据权重计算考核指标
resultMap = this.calIndCatalogTypeAverage(scoreRule, compareObj, date); objScoreCalResult = this.calIndCatalogTypeAverage(objScoreCalResult, scoreRule,
compareObj, date);
}else {//2单个指标权重计算 }else {//2单个指标权重计算
resultMap = this.calSingleIndWeight(scoreRule, compareObj, date); objScoreCalResult = this.calSingleIndWeight(objScoreCalResult ,scoreRule,
compareObj, date);
}
objScoreCalResult.setCompareId(compareId);
if(objScoreCalResult.getId()==null) {
objScoreCalResultMapper.insert(objScoreCalResult);
}else {
objScoreCalResultMapper.updateByPrimaryKey(objScoreCalResult);
} }
resultMap.put("reportId", reportId);
resultMap.put("compareId", compareId);
results.add(resultMap);
} }
}else { }else {
logger.info("单位评分卡id:"+scoreRuleId+" 不存在"); logger.info("单位评分卡id:"+scoreRuleId+" 不存在");
} }
return results;
} }
} }
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
delete delete
from base_ind_def from base_ind_def
where catalog_id in where catalog_id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="catalogIds" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
delete delete
from drive_ind_catalog from drive_ind_catalog
where id in where id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
delete delete
from drive_ind_def from drive_ind_def
where catalog_id in where catalog_id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="catalogIds" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
select * select *
from drive_ind_def from drive_ind_def
where ind_id in where ind_id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</select> </select>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
delete delete
from base_ind_catalog from base_ind_catalog
where id in where id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
delete delete
from drive_ind_score_card from drive_ind_score_card
where catalog_id in where catalog_id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="catalogIds" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
select * select *
from drive_ind_score_card from drive_ind_score_card
where id in where id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</select> </select>
......
<?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.keymobile.indicators.model.mapper.indmapper.ObjScoreCalResultMapper">
<select id="getObjScoreCalResultByParam" resultType="com.keymobile.indicators.model.entity.objscorerule.ObjScoreCalResult" >
select *
from obj_score_cal_result
where compare_id=#{compareId} and
compare_obj=#{compareObj} and
date=#{date}
</select>
</mapper>
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
delete delete
from obj_score_rule_catalog from obj_score_rule_catalog
where id in where id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
delete delete
from obj_score_rule from obj_score_rule
where catalog_id in where catalog_id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
delete delete
from score_card_catalog from score_card_catalog
where id in where id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
delete delete
from ind_short_board_catalog from ind_short_board_catalog
where id in where id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
delete delete
from short_board_rule from short_board_rule
where catalog_id in where catalog_id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
delete delete
from short_board_unit_catalog from short_board_unit_catalog
where id in where id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
delete delete
from short_board_unit from short_board_unit
where catalog_id in where catalog_id in
<foreach item="id" collection="list" open="(" close=")" separator=","> <foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
......
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