Commit b2749988 by zhangkb

修改指标计分规则,单位评分和短板评分实体加载转换

parent 323bf45b
...@@ -20,7 +20,7 @@ import com.keymobile.indicators.service.hytobacco.ScorecardCatalogService; ...@@ -20,7 +20,7 @@ import com.keymobile.indicators.service.hytobacco.ScorecardCatalogService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@Api(tags={"规则管理-指标分规则CRUD"}) @Api(tags={"规则管理-指标分规则CRUD"})
@RestController @RestController
@RequestMapping(value = "/indScorecard") @RequestMapping(value = "/indScorecard")
public class IndScorecardCtrl { public class IndScorecardCtrl {
......
...@@ -91,19 +91,31 @@ public class IndScorecardService { ...@@ -91,19 +91,31 @@ public class IndScorecardService {
} }
public List<IndScorecard> getAll(){ public List<IndScorecard> getAll(){
return indScorecardMapper.selectAll(); List<IndScorecard> scorecards = indScorecardMapper.selectAll();
List<IndScorecard> result = new ArrayList<>();
for(IndScorecard scorecard : scorecards) {
IndScorecard scorecard1 = this.changeJson(scorecard);
result.add(scorecard1);
}
return result;
} }
public IndScorecard findById(Integer id) { public IndScorecard findById(Integer id) {
IndScorecard result = indScorecardMapper.selectByPrimaryKey(id); IndScorecard result = indScorecardMapper.selectByPrimaryKey(id);
if(result!=null) { if(result!=null) {
return result; return this.changeJson(result);
} }
return null; return null;
} }
public List<IndScorecard> findByIdList(List<Integer> ids) throws Exception{ public List<IndScorecard> findByIdList(List<Integer> ids) throws Exception{
return indScorecardMapper.findByIdList(ids); List<IndScorecard> scorecards = indScorecardMapper.findByIdList(ids);
List<IndScorecard> result = new ArrayList<>();
for(IndScorecard scorecard : scorecards) {
IndScorecard scorecard1 = this.changeJson(scorecard);
result.add(scorecard1);
}
return result;
} }
public Map<String,Object> getByCatalogId(Integer catalogId,int page,int rows){ public Map<String,Object> getByCatalogId(Integer catalogId,int page,int rows){
...@@ -113,8 +125,13 @@ public class IndScorecardService { ...@@ -113,8 +125,13 @@ public class IndScorecardService {
int start = (page-1)*rows; int start = (page-1)*rows;
count = indScorecardMapper.countByCatalogId(catalogId); count = indScorecardMapper.countByCatalogId(catalogId);
List<IndScorecard> datas = indScorecardMapper.findByCatalogId(catalogId,start,rows); List<IndScorecard> datas = indScorecardMapper.findByCatalogId(catalogId,start,rows);
List<IndScorecard> resultDatas = new ArrayList<>();
for(IndScorecard data : datas) {
IndScorecard data1 = this.changeJson(data);
resultDatas.add(data1);
}
result.put("count", count); result.put("count", count);
result.put("data", datas); result.put("data", resultDatas);
return result; return result;
} }
...@@ -378,4 +395,25 @@ public class IndScorecardService { ...@@ -378,4 +395,25 @@ public class IndScorecardService {
} }
return value; return value;
} }
private IndScorecard changeJson(IndScorecard scorecard) {
Gson gson = new Gson();
if(StringUtils.isNotBlank(scorecard.getAddScoreItemJson())) {
List<RankScoreDef> addScoreItem = gson.
fromJson(scorecard.getAddScoreItemJson(), new TypeToken<List<RankScoreDef>>(){}.getType());
scorecard.setAddScoreItem(addScoreItem);
}
if(StringUtils.isNotBlank(scorecard.getMinusScoreItemJson())) {
List<RankScoreDef> minusScoreItem = gson.
fromJson(scorecard.getMinusScoreItemJson(), new TypeToken<List<RankScoreDef>>(){}.getType());
scorecard.setMinusScoreItem(minusScoreItem);
}
if(StringUtils.isNotBlank(scorecard.getImproveScoreItemJson())) {
List<ImproveScoreDef> importScoreDefList = gson.
fromJson(scorecard.getImproveScoreItemJson(),
new TypeToken<List<ImproveScoreDef>>(){}.getType());
scorecard.setImproveScoreItem(importScoreDefList);
}
return scorecard;
}
} }
...@@ -77,15 +77,20 @@ public class ScoreRuleService { ...@@ -77,15 +77,20 @@ public class ScoreRuleService {
int start = (page-1)*rows; int start = (page-1)*rows;
count = scoreRuleMapper.countByCatalogId(catalogId); count = scoreRuleMapper.countByCatalogId(catalogId);
List<ScoreRule> datas = scoreRuleMapper.findByCatalogId(catalogId, start, rows); List<ScoreRule> datas = scoreRuleMapper.findByCatalogId(catalogId, start, rows);
List<ScoreRule> resultDatas = new ArrayList<>();
for(ScoreRule data : datas) {
ScoreRule data1 = this.changeJson(data);
resultDatas.add(data1);
}
result.put("count", count); result.put("count", count);
result.put("data", datas); result.put("data", resultDatas);
return result; return result;
} }
public ScoreRule getById(Integer id) { public ScoreRule getById(Integer id) {
ScoreRule scoreRule = scoreRuleMapper.selectByPrimaryKey(id); ScoreRule scoreRule = scoreRuleMapper.selectByPrimaryKey(id);
if(scoreRule!=null) { if(scoreRule!=null) {
return scoreRule; return this.changeJson(scoreRule);
} }
return null; return null;
} }
...@@ -348,4 +353,14 @@ public class ScoreRuleService { ...@@ -348,4 +353,14 @@ public class ScoreRuleService {
logger.info("单位评分卡id:"+scoreRuleId+" 不存在"); logger.info("单位评分卡id:"+scoreRuleId+" 不存在");
} }
} }
private ScoreRule changeJson(ScoreRule scoreRule) {
Gson gson = new Gson();
if(StringUtils.isNotBlank(scoreRule.getIndTypeWeightsJson())) {
List<IndTypeWeight> indTypeWeights = gson.
fromJson(scoreRule.getIndTypeWeightsJson(), new TypeToken<List<IndTypeWeight>>(){}.getType());
scoreRule.setIndTypeWeights(indTypeWeights);
}
return scoreRule;
}
} }
...@@ -69,15 +69,20 @@ public class ShortboardRuleService { ...@@ -69,15 +69,20 @@ public class ShortboardRuleService {
int start = (page-1)*rows; int start = (page-1)*rows;
count = shortboardRuleMapper.countByCatalogId(catalogId); count = shortboardRuleMapper.countByCatalogId(catalogId);
List<ShortboardRule> datas = shortboardRuleMapper.findByCatalogId(catalogId, start, rows); List<ShortboardRule> datas = shortboardRuleMapper.findByCatalogId(catalogId, start, rows);
List<ShortboardRule> resultDatas = new ArrayList<>();
for(ShortboardRule data : datas) {
ShortboardRule data1 = this.changeJson(data);
resultDatas.add(data1);
}
result.put("count", count); result.put("count", count);
result.put("data", datas); result.put("data", resultDatas);
return result; return result;
} }
public ShortboardRule getById(Integer id) { public ShortboardRule getById(Integer id) {
ShortboardRule shortboardRule = shortboardRuleMapper.selectByPrimaryKey(id); ShortboardRule shortboardRule = shortboardRuleMapper.selectByPrimaryKey(id);
if(shortboardRule!=null) { if(shortboardRule!=null) {
return shortboardRule; return this.changeJson(shortboardRule);
} }
return null; return null;
} }
...@@ -502,4 +507,14 @@ public class ShortboardRuleService { ...@@ -502,4 +507,14 @@ public class ShortboardRuleService {
} }
return realCalResults; return realCalResults;
} }
private ShortboardRule changeJson(ShortboardRule shortboardRule) {
Gson gson = new Gson();
if(StringUtils.isNotBlank(shortboardRule.getShortboardItemJson())) {
List<ShortboardItem> shortboardItems = gson.
fromJson(shortboardRule.getShortboardItemJson(), new TypeToken<List<ShortboardItem>>(){}.getType());
shortboardRule.setShortboardItem(shortboardItems);
}
return shortboardRule;
}
} }
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