Commit 0c5194c7 by 张祺

Merge branch 'hy-tobacco' of http://132.232.112.242:7090/zhangkb/indicators into hy-tobacco

parents 868d7f64 60785873
...@@ -57,7 +57,7 @@ public class DriveIndCalculateActor extends AbstractActor{ ...@@ -57,7 +57,7 @@ public class DriveIndCalculateActor extends AbstractActor{
private String unit; private String unit;
private String markType; private Integer markType;
private String driveIndId; private String driveIndId;
......
...@@ -69,7 +69,7 @@ public class DriveIndCalculateRegionActor extends AbstractActor{ ...@@ -69,7 +69,7 @@ public class DriveIndCalculateRegionActor extends AbstractActor{
String value = driveIndAverageAndRankMsg.getDriveIndValue(); String value = driveIndAverageAndRankMsg.getDriveIndValue();
String id = String.valueOf(driveIndAverageAndRankMsg.getId()); String id = String.valueOf(driveIndAverageAndRankMsg.getId());
String indType = driveIndAverageAndRankMsg.getIndType(); String indType = driveIndAverageAndRankMsg.getIndType();
String markType = driveIndAverageAndRankMsg.getMarkType();//评分卡id Integer markType = driveIndAverageAndRankMsg.getMarkType();//评分卡id
valueMap.put(id, value); valueMap.put(id, value);
values.add(value); values.add(value);
compareObjs.add(driveIndAverageAndRankMsg.getCompareObj()); compareObjs.add(driveIndAverageAndRankMsg.getCompareObj());
......
...@@ -16,11 +16,11 @@ public class DriveIndAverageAndRankMsg implements Serializable{ ...@@ -16,11 +16,11 @@ public class DriveIndAverageAndRankMsg implements Serializable{
private String driveIndValue; private String driveIndValue;
private String unit; private String unit;
private String indType; private String indType;
private String markType; private Integer markType;
private String indFormula; private String indFormula;
public DriveIndAverageAndRankMsg(Integer id,String compareId,String driveIndId,String compareObj, public DriveIndAverageAndRankMsg(Integer id,String compareId,String driveIndId,String compareObj,
Integer date,String driveIndValue,String unit,String indType,String markType,String indFormula) { Integer date,String driveIndValue,String unit,String indType,Integer markType,String indFormula) {
this.id = id; this.id = id;
this.compareId = compareId; this.compareId = compareId;
this.driveIndId = driveIndId; this.driveIndId = driveIndId;
...@@ -97,11 +97,11 @@ public class DriveIndAverageAndRankMsg implements Serializable{ ...@@ -97,11 +97,11 @@ public class DriveIndAverageAndRankMsg implements Serializable{
this.indType = indType; this.indType = indType;
} }
public String getMarkType() { public Integer getMarkType() {
return markType; return markType;
} }
public void setMarkType(String markType) { public void setMarkType(Integer markType) {
this.markType = markType; this.markType = markType;
} }
......
...@@ -28,20 +28,20 @@ public class IndCatalogCtrl { ...@@ -28,20 +28,20 @@ public class IndCatalogCtrl {
@ApiOperation(value = "新建基础指标目录", notes = "新建基础指标目录") @ApiOperation(value = "新建基础指标目录", notes = "新建基础指标目录")
@PostMapping(value = "/createBaseIndCatalog") @PostMapping(value = "/createBaseIndCatalog")
public String createBaseIndCatalog(@RequestBody IndCatalog indCatalog) throws Exception{ public Integer createBaseIndCatalog(@RequestBody IndCatalog indCatalog) throws Exception{
indCatalog = indCatalogService.saveOrUpdate(indCatalog); indCatalog = indCatalogService.saveOrUpdate(indCatalog);
return indCatalog.getId(); return indCatalog.getId();
} }
@ApiOperation(value = "批量级联删除基础指标目录", notes = "批量级联删除基础指标目录") @ApiOperation(value = "批量级联删除基础指标目录", notes = "批量级联删除基础指标目录")
@PostMapping(value = "/deleteBaseIndCatalog") @PostMapping(value = "/deleteBaseIndCatalog")
public void deleteBaseIndCatalog(@RequestParam List<String> ids) throws Exception{ public void deleteBaseIndCatalog(@RequestParam List<Integer> ids) throws Exception{
indCatalogService.recursionDelete(ids); indCatalogService.recursionDelete(ids);
} }
@ApiOperation(value = "获取基础指标目录", notes = "获取基础指标目录") @ApiOperation(value = "获取基础指标目录", notes = "获取基础指标目录")
@PostMapping(value = "/getBaseIndCatalog") @PostMapping(value = "/getBaseIndCatalog")
public List<IndCatalog> getBaseIndCatalog(@RequestParam(required=false) String parentId, public List<IndCatalog> getBaseIndCatalog(@RequestParam(required=false) Integer parentId,
@RequestParam List<String> codes){ @RequestParam List<String> codes){
return indCatalogService.getCatalog(parentId, codes); return indCatalogService.getCatalog(parentId, codes);
} }
...@@ -49,20 +49,20 @@ public class IndCatalogCtrl { ...@@ -49,20 +49,20 @@ public class IndCatalogCtrl {
//考核指标目录 //考核指标目录
@ApiOperation(value = "新建考核指标目录", notes = "新建考核指标目录") @ApiOperation(value = "新建考核指标目录", notes = "新建考核指标目录")
@PostMapping(value = "/createDriveIndCatalog") @PostMapping(value = "/createDriveIndCatalog")
public String createDriveIndCatalog(@RequestBody DriveIndCatalog driveIndCatalog) throws Exception{ public Integer createDriveIndCatalog(@RequestBody DriveIndCatalog driveIndCatalog) throws Exception{
driveIndCatalog = driveIndCatalogService.saveOrUpdate(driveIndCatalog); driveIndCatalog = driveIndCatalogService.saveOrUpdate(driveIndCatalog);
return driveIndCatalog.getId(); return driveIndCatalog.getId();
} }
@ApiOperation(value = "批量级联删除考核指标目录", notes = "批量级联删除考核指标目录") @ApiOperation(value = "批量级联删除考核指标目录", notes = "批量级联删除考核指标目录")
@PostMapping(value = "/deleteDriveIndCatalog") @PostMapping(value = "/deleteDriveIndCatalog")
public void deleteDriveIndCatalog(@RequestParam List<String> ids) throws Exception{ public void deleteDriveIndCatalog(@RequestParam List<Integer> ids) throws Exception{
driveIndCatalogService.recursionDelete(ids); driveIndCatalogService.recursionDelete(ids);
} }
@ApiOperation(value = "获取考核指标目录", notes = "获取考核指标目录") @ApiOperation(value = "获取考核指标目录", notes = "获取考核指标目录")
@PostMapping(value = "/getDriveIndCatalog") @PostMapping(value = "/getDriveIndCatalog")
public List<DriveIndCatalog> getDriveIndCatalog(@RequestParam(required=false) String parentId, public List<DriveIndCatalog> getDriveIndCatalog(@RequestParam(required=false) Integer parentId,
@RequestParam List<String> codes){ @RequestParam List<String> codes){
return driveIndCatalogService.getCatalog(parentId, codes); return driveIndCatalogService.getCatalog(parentId, codes);
} }
......
...@@ -4,7 +4,6 @@ import java.util.List; ...@@ -4,7 +4,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -30,34 +29,34 @@ public class IndScorecardCtrl { ...@@ -30,34 +29,34 @@ public class IndScorecardCtrl {
@ApiOperation(value = "新增/修改评分卡目录", notes = "新增/修改评分卡目录") @ApiOperation(value = "新增/修改评分卡目录", notes = "新增/修改评分卡目录")
@PostMapping(value = "/saveOrUpdateCatalog") @PostMapping(value = "/saveOrUpdateCatalog")
public String saveOrUpdateCatalog(@RequestBody ScorecardCatalog scorecardCatalog)throws Exception{ public Integer saveOrUpdateCatalog(@RequestBody ScorecardCatalog scorecardCatalog)throws Exception{
scorecardCatalog = scorecardCatalogService.saveOrUpdate(scorecardCatalog); scorecardCatalog = scorecardCatalogService.saveOrUpdate(scorecardCatalog);
return scorecardCatalog.getId(); return scorecardCatalog.getId();
} }
@ApiOperation(value = "批量级联删除评分卡目录", notes = "批量级联删除评分卡目录") @ApiOperation(value = "批量级联删除评分卡目录", notes = "批量级联删除评分卡目录")
@PostMapping(value = "/deleteCatalog") @PostMapping(value = "/deleteCatalog")
public void deleteCatalog(@RequestParam List<String> ids) throws Exception{ public void deleteCatalog(@RequestParam List<Integer> ids) throws Exception{
scorecardCatalogService.recursionDelete(ids); scorecardCatalogService.recursionDelete(ids);
} }
@ApiOperation(value = "获取评分卡目录", notes = "获取评分卡目录") @ApiOperation(value = "获取评分卡目录", notes = "获取评分卡目录")
@PostMapping(value = "/getCatalog") @PostMapping(value = "/getCatalog")
public List<ScorecardCatalog> getCatalog(@RequestParam(required=false) String parentId, public List<ScorecardCatalog> getCatalog(@RequestParam(required=false) Integer parentId,
@RequestParam List<String> codes){ @RequestParam List<String> codes){
return scorecardCatalogService.getCatalog(parentId, codes); return scorecardCatalogService.getCatalog(parentId, codes);
} }
@ApiOperation(value = "新增/修改", notes = "新增/修改") @ApiOperation(value = "新增/修改", notes = "新增/修改")
@PostMapping(value = "/saveOrUpdate") @PostMapping(value = "/saveOrUpdate")
public String saveOrUpdate(@RequestBody IndScorecard indScorecard,@RequestParam String catalogId, public Integer saveOrUpdate(@RequestBody IndScorecard indScorecard,@RequestParam Integer catalogId,
@RequestParam String catalogIdPath,@RequestParam String user) { @RequestParam String catalogIdPath,@RequestParam String user) {
return indScorecardService.saveOrUpdate(indScorecard,catalogId,catalogIdPath,user); return indScorecardService.saveOrUpdate(indScorecard,catalogId,catalogIdPath,user);
} }
@ApiOperation(value = "删除", notes = "删除") @ApiOperation(value = "删除", notes = "删除")
@PostMapping(value = "/delete") @PostMapping(value = "/delete")
public void delete(@RequestBody List<String> ids) { public void delete(@RequestBody List<Integer> ids) {
indScorecardService.delete(ids); indScorecardService.delete(ids);
} }
...@@ -69,7 +68,7 @@ public class IndScorecardCtrl { ...@@ -69,7 +68,7 @@ public class IndScorecardCtrl {
@ApiOperation(value = "根据评分卡目录获取评分卡", notes = "根据评分卡目录获取评分卡") @ApiOperation(value = "根据评分卡目录获取评分卡", notes = "根据评分卡目录获取评分卡")
@PostMapping(value = "/getByCatalogId") @PostMapping(value = "/getByCatalogId")
public Page<IndScorecard> getByCatalogId(@RequestParam String catalogId, public Map<String,Object> getByCatalogId(@RequestParam Integer catalogId,
@RequestParam(value = "page", required = false, defaultValue = "1") int page, @RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "rows", required = false, defaultValue = "10") int rows){ @RequestParam(value = "rows", required = false, defaultValue = "10") int rows){
return indScorecardService.getByCatalogId(catalogId,page,rows); return indScorecardService.getByCatalogId(catalogId,page,rows);
...@@ -77,14 +76,14 @@ public class IndScorecardCtrl { ...@@ -77,14 +76,14 @@ public class IndScorecardCtrl {
@ApiOperation(value = "根据id获取评分卡", notes = "根据id获取评分卡") @ApiOperation(value = "根据id获取评分卡", notes = "根据id获取评分卡")
@PostMapping(value = "/findById") @PostMapping(value = "/findById")
public IndScorecard findById(@RequestParam String id) { public IndScorecard findById(@RequestParam Integer id) {
return indScorecardService.findById(id); return indScorecardService.findById(id);
} }
@ApiOperation(value = "根据评分卡计算指标分数", notes = "根据评分卡计算指标分数") @ApiOperation(value = "根据评分卡计算指标分数", notes = "根据评分卡计算指标分数")
@PostMapping(value = "/calculateIndiScore") @PostMapping(value = "/calculateIndiScore")
public Map<String,String> calculateIndiScore(@RequestParam String indId,@RequestParam int date, public Map<String,String> calculateIndiScore(@RequestParam String indId,@RequestParam int date,
@RequestParam String compareObj,@RequestParam String indScorecardId, @RequestParam String compareObj,@RequestParam Integer indScorecardId,
@RequestParam String compareId,@RequestBody List<String> compareObjs) throws Exception{ @RequestParam String compareId,@RequestBody List<String> compareObjs) throws Exception{
return indScorecardService.calculateIndiScore(indId, date, compareObj, return indScorecardService.calculateIndiScore(indId, date, compareObj,
indScorecardId,compareId,compareObjs); indScorecardId,compareId,compareObjs);
......
...@@ -32,7 +32,7 @@ public class IndicatorsDefCtrl { ...@@ -32,7 +32,7 @@ public class IndicatorsDefCtrl {
@ApiOperation(value = "新建基础指标", notes = "新建基础指标") @ApiOperation(value = "新建基础指标", notes = "新建基础指标")
@PostMapping(value = "/createBaseInd") @PostMapping(value = "/createBaseInd")
public void createBaseInd(@RequestBody BaseIndDef baseIndDef,@RequestParam String catalogId, public void createBaseInd(@RequestBody BaseIndDef baseIndDef,@RequestParam Integer catalogId,
@RequestParam String catalogIdPath,@RequestParam String user) throws Exception{ @RequestParam String catalogIdPath,@RequestParam String user) throws Exception{
baseIndDefService.saveOrUpdate(baseIndDef, catalogId, catalogIdPath, user); baseIndDefService.saveOrUpdate(baseIndDef, catalogId, catalogIdPath, user);
} }
...@@ -45,7 +45,7 @@ public class IndicatorsDefCtrl { ...@@ -45,7 +45,7 @@ public class IndicatorsDefCtrl {
@ApiOperation(value = "根据关键字查询基础指标", notes = "根据关键字查询基础指标") @ApiOperation(value = "根据关键字查询基础指标", notes = "根据关键字查询基础指标")
@PostMapping(value = "/getByPageAndKeyword") @PostMapping(value = "/getByPageAndKeyword")
public Map<String,Object> getByPageAndKeyword(@RequestParam String catalogId, public Map<String,Object> getByPageAndKeyword(@RequestParam Integer catalogId,
@RequestParam(required=false) String keyword, @RequestParam(required=false) String keyword,
@RequestParam(defaultValue = "0") int page,@RequestParam(defaultValue = "10") int rows) throws Exception{ @RequestParam(defaultValue = "0") int page,@RequestParam(defaultValue = "10") int rows) throws Exception{
return baseIndDefService.getByPageAndKeyword(catalogId, keyword, page, rows); return baseIndDefService.getByPageAndKeyword(catalogId, keyword, page, rows);
...@@ -53,7 +53,7 @@ public class IndicatorsDefCtrl { ...@@ -53,7 +53,7 @@ public class IndicatorsDefCtrl {
@ApiOperation(value = "新建考核指标", notes = "新建考核指标") @ApiOperation(value = "新建考核指标", notes = "新建考核指标")
@PostMapping(value = "/createDriveInd") @PostMapping(value = "/createDriveInd")
public void createDriveInd(@RequestBody DriveIndDef driveIndDef,@RequestParam String catalogId, public void createDriveInd(@RequestBody DriveIndDef driveIndDef,@RequestParam Integer catalogId,
@RequestParam String catalogIdPath,@RequestParam String user) throws Exception{ @RequestParam String catalogIdPath,@RequestParam String user) throws Exception{
driveIndDefService.saveOrUpdate(driveIndDef, catalogId, catalogIdPath, user); driveIndDefService.saveOrUpdate(driveIndDef, catalogId, catalogIdPath, user);
} }
...@@ -66,7 +66,7 @@ public class IndicatorsDefCtrl { ...@@ -66,7 +66,7 @@ public class IndicatorsDefCtrl {
@ApiOperation(value = "根据关键字查询考核指标", notes = "根据关键字查询考核指标") @ApiOperation(value = "根据关键字查询考核指标", notes = "根据关键字查询考核指标")
@PostMapping(value = "/getDriveByPageAndKeyword") @PostMapping(value = "/getDriveByPageAndKeyword")
public Map<String,Object> getDriveByPageAndKeyword(@RequestParam String catalogId, public Map<String,Object> getDriveByPageAndKeyword(@RequestParam Integer catalogId,
@RequestParam(required=false) String keyword, @RequestParam(required=false) String keyword,
@RequestParam(defaultValue = "0") int page,@RequestParam(defaultValue = "10") int rows) throws Exception{ @RequestParam(defaultValue = "0") int page,@RequestParam(defaultValue = "10") int rows) throws Exception{
return driveIndDefService.getByPageAndKeyword(catalogId, keyword, page, rows); return driveIndDefService.getByPageAndKeyword(catalogId, keyword, page, rows);
......
...@@ -4,7 +4,6 @@ import java.util.List; ...@@ -4,7 +4,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -30,40 +29,40 @@ public class ObjScoreRuleCtrl { ...@@ -30,40 +29,40 @@ public class ObjScoreRuleCtrl {
@ApiOperation(value = "新增/修改单位规则目录", notes = "新增/修改单位规则目录") @ApiOperation(value = "新增/修改单位规则目录", notes = "新增/修改单位规则目录")
@PostMapping(value = "/saveOrUpdateCatalog") @PostMapping(value = "/saveOrUpdateCatalog")
public String saveOrUpdateCatalog(@RequestBody ScoreRuleCatalog scoreRuleCatalog)throws Exception{ public Integer saveOrUpdateCatalog(@RequestBody ScoreRuleCatalog scoreRuleCatalog)throws Exception{
scoreRuleCatalog = scoreRuleCatalogService.saveOrUpdate(scoreRuleCatalog); scoreRuleCatalog = scoreRuleCatalogService.saveOrUpdate(scoreRuleCatalog);
return scoreRuleCatalog.getId(); return scoreRuleCatalog.getId();
} }
@ApiOperation(value = "批量级联删除单位规则目录", notes = "批量级联删除单位规则目录") @ApiOperation(value = "批量级联删除单位规则目录", notes = "批量级联删除单位规则目录")
@PostMapping(value = "/deleteCatalog") @PostMapping(value = "/deleteCatalog")
public void deleteCatalog(@RequestParam List<String> ids) throws Exception{ public void deleteCatalog(@RequestParam List<Integer> ids) throws Exception{
scoreRuleCatalogService.recursionDelete(ids); scoreRuleCatalogService.recursionDelete(ids);
} }
@ApiOperation(value = "获取单位规则目录", notes = "获取单位规则目录") @ApiOperation(value = "获取单位规则目录", notes = "获取单位规则目录")
@PostMapping(value = "/getCatalog") @PostMapping(value = "/getCatalog")
public List<ScoreRuleCatalog> getCatalog(@RequestParam(required=false) String parentId, public List<ScoreRuleCatalog> getCatalog(@RequestParam(required=false) Integer parentId,
@RequestParam List<String> codes){ @RequestParam List<String> codes){
return scoreRuleCatalogService.getCatalog(parentId, codes); return scoreRuleCatalogService.getCatalog(parentId, codes);
} }
@ApiOperation(value = "新增/修改", notes = "新增/修改") @ApiOperation(value = "新增/修改", notes = "新增/修改")
@PostMapping(value = "/saveOrUpdate") @PostMapping(value = "/saveOrUpdate")
public String saveOrUpdate(@RequestBody ScoreRule scoreRule,@RequestParam String catalogId, public Integer saveOrUpdate(@RequestBody ScoreRule scoreRule,@RequestParam Integer catalogId,
@RequestParam String catalogIdPath,@RequestParam String user) { @RequestParam String catalogIdPath,@RequestParam String user) {
return scoreRuleService.saveOrUpdate(scoreRule,catalogId,catalogIdPath,user); return scoreRuleService.saveOrUpdate(scoreRule,catalogId,catalogIdPath,user);
} }
@ApiOperation(value = "删除", notes = "删除") @ApiOperation(value = "删除", notes = "删除")
@PostMapping(value = "/delete") @PostMapping(value = "/delete")
public void delete(@RequestParam String id) { public void delete(@RequestParam Integer id) {
scoreRuleService.delete(id); scoreRuleService.delete(id);
} }
@ApiOperation(value = "根据单位评分规则目录获取单位评分规则", notes = "根据单位评分规则目录获取单位评分规则") @ApiOperation(value = "根据单位评分规则目录获取单位评分规则", notes = "根据单位评分规则目录获取单位评分规则")
@PostMapping(value = "/getByCatalogId") @PostMapping(value = "/getByCatalogId")
public Page<ScoreRule> getByCatalogId(@RequestParam String catalogId, public Map<String,Object> getByCatalogId(@RequestParam Integer catalogId,
@RequestParam(value = "page", required = false, defaultValue = "1") int page, @RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "rows", required = false, defaultValue = "10") int rows){ @RequestParam(value = "rows", required = false, defaultValue = "10") int rows){
return scoreRuleService.getByCatalogId(catalogId,page,rows); return scoreRuleService.getByCatalogId(catalogId,page,rows);
...@@ -71,7 +70,7 @@ public class ObjScoreRuleCtrl { ...@@ -71,7 +70,7 @@ public class ObjScoreRuleCtrl {
@ApiOperation(value = "根据id获取单位评分规则", notes = "根据id获取单位评分规则") @ApiOperation(value = "根据id获取单位评分规则", notes = "根据id获取单位评分规则")
@PostMapping(value = "/findById") @PostMapping(value = "/findById")
public ScoreRule findById(@RequestParam String id) { public ScoreRule findById(@RequestParam Integer id) {
return scoreRuleService.getById(id); return scoreRuleService.getById(id);
} }
...@@ -80,7 +79,7 @@ public class ObjScoreRuleCtrl { ...@@ -80,7 +79,7 @@ public class ObjScoreRuleCtrl {
public List<Map<String,String>> calculateObjectScore(@RequestParam String reportId, public List<Map<String,String>> calculateObjectScore(@RequestParam String reportId,
@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 String scoreRuleId){ @RequestParam Integer scoreRuleId){
return scoreRuleService.calObjScore(reportId, compareId, indIds, compareObjs, date, scoreRuleId); return scoreRuleService.calObjScore(reportId, compareId, indIds, compareObjs, date, scoreRuleId);
} }
} }
package com.keymobile.indicators.api.hytobacco; package com.keymobile.indicators.api.hytobacco;
import java.util.List; import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -29,40 +29,40 @@ public class ShortboardRuleCtrl { ...@@ -29,40 +29,40 @@ public class ShortboardRuleCtrl {
@ApiOperation(value = "新增/修改短板筛选规则目录", notes = "新增/修改短板筛选规则目录") @ApiOperation(value = "新增/修改短板筛选规则目录", notes = "新增/修改短板筛选规则目录")
@PostMapping(value = "/saveOrUpdateCatalog") @PostMapping(value = "/saveOrUpdateCatalog")
public String saveOrUpdateCatalog(@RequestBody ShortboardCatalog shortboardCatalog)throws Exception{ public Integer saveOrUpdateCatalog(@RequestBody ShortboardCatalog shortboardCatalog)throws Exception{
shortboardCatalog = shortboardCatalogService.saveOrUpdate(shortboardCatalog); shortboardCatalog = shortboardCatalogService.saveOrUpdate(shortboardCatalog);
return shortboardCatalog.getId(); return shortboardCatalog.getId();
} }
@ApiOperation(value = "批量级联删除短板筛选规则目录", notes = "批量级联删除短板筛选规则目录") @ApiOperation(value = "批量级联删除短板筛选规则目录", notes = "批量级联删除短板筛选规则目录")
@PostMapping(value = "/deleteCatalog") @PostMapping(value = "/deleteCatalog")
public void deleteCatalog(@RequestParam List<String> ids) throws Exception{ public void deleteCatalog(@RequestParam List<Integer> ids) throws Exception{
shortboardCatalogService.recursionDelete(ids); shortboardCatalogService.recursionDelete(ids);
} }
@ApiOperation(value = "获取短板筛选规则目录", notes = "获取短板筛选规则目录") @ApiOperation(value = "获取短板筛选规则目录", notes = "获取短板筛选规则目录")
@PostMapping(value = "/getCatalog") @PostMapping(value = "/getCatalog")
public List<ShortboardCatalog> getCatalog(@RequestParam(required=false) String parentId, public List<ShortboardCatalog> getCatalog(@RequestParam(required=false) Integer parentId,
@RequestParam List<String> codes){ @RequestParam List<String> codes){
return shortboardCatalogService.getCatalog(parentId, codes); return shortboardCatalogService.getCatalog(parentId, codes);
} }
@ApiOperation(value = "新增/修改", notes = "新增/修改") @ApiOperation(value = "新增/修改", notes = "新增/修改")
@PostMapping(value = "/saveOrUpdate") @PostMapping(value = "/saveOrUpdate")
public String saveOrUpdate(@RequestBody ShortboardRule shortboardRule,@RequestParam String catalogId, public Integer saveOrUpdate(@RequestBody ShortboardRule shortboardRule,@RequestParam Integer catalogId,
@RequestParam String catalogIdPath,@RequestParam String user) { @RequestParam String catalogIdPath,@RequestParam String user) {
return shortboardRuleService.saveOrUpdate(shortboardRule,catalogId,catalogIdPath,user); return shortboardRuleService.saveOrUpdate(shortboardRule,catalogId,catalogIdPath,user);
} }
@ApiOperation(value = "删除", notes = "删除") @ApiOperation(value = "删除", notes = "删除")
@PostMapping(value = "/delete") @PostMapping(value = "/delete")
public void delete(@RequestParam String id) { public void delete(@RequestParam Integer id) {
shortboardRuleService.delete(id); shortboardRuleService.delete(id);
} }
@ApiOperation(value = "根据短板筛选规则目录获取短板筛选规则", notes = "根据短板筛选规则目录获取短板筛选规则") @ApiOperation(value = "根据短板筛选规则目录获取短板筛选规则", notes = "根据短板筛选规则目录获取短板筛选规则")
@PostMapping(value = "/getByCatalogId") @PostMapping(value = "/getByCatalogId")
public Page<ShortboardRule> getByCatalogId(@RequestParam String catalogId, public Map<String,Object> getByCatalogId(@RequestParam Integer catalogId,
@RequestParam(value = "page", required = false, defaultValue = "1") int page, @RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "rows", required = false, defaultValue = "10") int rows){ @RequestParam(value = "rows", required = false, defaultValue = "10") int rows){
return shortboardRuleService.getByCatalogId(catalogId,page,rows); return shortboardRuleService.getByCatalogId(catalogId,page,rows);
...@@ -70,7 +70,7 @@ public class ShortboardRuleCtrl { ...@@ -70,7 +70,7 @@ public class ShortboardRuleCtrl {
@ApiOperation(value = "根据id获取短板筛选规则", notes = "根据id获取短板筛选规则") @ApiOperation(value = "根据id获取短板筛选规则", notes = "根据id获取短板筛选规则")
@PostMapping(value = "/findById") @PostMapping(value = "/findById")
public ShortboardRule findById(@RequestParam String id) { public ShortboardRule findById(@RequestParam Integer id) {
return shortboardRuleService.getById(id); return shortboardRuleService.getById(id);
} }
} }
...@@ -30,6 +30,6 @@ public class BaseIndDef { ...@@ -30,6 +30,6 @@ public class BaseIndDef {
private Integer defStaTime; private Integer defStaTime;
private Integer defEndTime; private Integer defEndTime;
private String version;//版本号 private String version;//版本号
private String catalogId;//挂靠目录id private Integer catalogId;//挂靠目录id
private String catalogIdPath;//挂靠目录idPath,方便用目录类别找到对应的挂靠指标 private String catalogIdPath;//挂靠目录idPath,方便用目录类别找到对应的挂靠指标
} }
package com.keymobile.indicators.model.entity.indicators; package com.keymobile.indicators.model.entity.indicators;
import java.io.Serializable; import java.util.Date;
import org.springframework.data.annotation.Id; import javax.persistence.Id;
import org.springframework.data.mongodb.core.mapping.Document; import javax.persistence.Table;
import com.keymobile.indicators.utils.DateUtils;
import lombok.Data; import lombok.Data;
...@@ -11,17 +13,13 @@ import lombok.Data; ...@@ -11,17 +13,13 @@ import lombok.Data;
*author:zhangkb time:2020-5-20 desc:基础项数据版本数据 *author:zhangkb time:2020-5-20 desc:基础项数据版本数据
*/ */
@Data @Data
@Document(collection="base_ind_def_version_data") @Table(name="base_ind_def_version_data")
public class BaseIndDefVersionData implements Serializable{ public class BaseIndDefVersionData{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id @Id
private String id; private Integer id;
private String indId; private String indId;
private String indName; private String indName;
private String version; private String version;
private String dataJson; private String dataJson;
private String lastUpdateTime = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
} }
...@@ -2,6 +2,8 @@ package com.keymobile.indicators.model.entity.indicators; ...@@ -2,6 +2,8 @@ package com.keymobile.indicators.model.entity.indicators;
import java.util.Date; import java.util.Date;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
...@@ -16,6 +18,7 @@ import lombok.Data; ...@@ -16,6 +18,7 @@ import lombok.Data;
@Table(name="drive_ind_cal_result_def") @Table(name="drive_ind_cal_result_def")
public class DriveIndCalResultDef { public class DriveIndCalResultDef {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id; private Integer id;
private String compareId; private String compareId;
......
package com.keymobile.indicators.model.entity.indicators; package com.keymobile.indicators.model.entity.indicators;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
import org.springframework.data.annotation.Id; import javax.persistence.GeneratedValue;
import org.springframework.data.mongodb.core.mapping.Document; import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.keymobile.indicators.utils.DateUtils; import com.keymobile.indicators.utils.DateUtils;
...@@ -14,19 +15,15 @@ import lombok.Data; ...@@ -14,19 +15,15 @@ import lombok.Data;
*author:zhangkb time:2020-5-18 desc:考核指标目录 *author:zhangkb time:2020-5-18 desc:考核指标目录
*/ */
@Data @Data
@Document(collection="drive_ind_catalog") @Table(name="drive_ind_catalog")
public class DriveIndCatalog implements Serializable{ public class DriveIndCatalog {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id @Id
private String id; @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String catalogName; private String catalogName;
//private String type; //private String type;
private String catalogType;//分为数据项级别和数据项类别 0:数据项级别 1:数据项类别 2:普通目录 private String catalogType;//分为数据项级别和数据项类别 0:数据项级别 1:数据项类别 2:普通目录
private String parentId;//顶层节点parentId为0 private Integer parentId;//顶层节点parentId为0
private String idPath; private String idPath;
private String code;//目录编码 private String code;//目录编码
private String lastUpdater; private String lastUpdater;
......
...@@ -25,12 +25,12 @@ public class DriveIndDef { ...@@ -25,12 +25,12 @@ public class DriveIndDef {
private String indFormatDesc;//指标公式描述 private String indFormatDesc;//指标公式描述
private String isCalScore;//是否计分 是:1 否:0 private String isCalScore;//是否计分 是:1 否:0
private String indRule;//指标正负属性:正向指标0 反向指标1 private String indRule;//指标正负属性:正向指标0 反向指标1
private String indCalScoreRule;//计分规则 private Integer indCalScoreRule;//计分规则
private String indCalScoreRuleDesc;//计分规则描述 private String indCalScoreRuleDesc;//计分规则描述
private String isUnitCalScore;//是否参与单位得分计算 是:1 否:0 private String isUnitCalScore;//是否参与单位得分计算 是:1 否:0
private String indFrequency;//指标频度 private String indFrequency;//指标频度
private String version;//版本号 private String version;//版本号
private String catalogId;//挂靠目录id private Integer catalogId;//挂靠目录id
private String catalogIdPath;//挂靠目录idPath,方便用目录类别找到对应的挂靠指标 private String catalogIdPath;//挂靠目录idPath,方便用目录类别找到对应的挂靠指标
private String creater; private String creater;
private Date createTime; private Date createTime;
......
package com.keymobile.indicators.model.entity.indicators; package com.keymobile.indicators.model.entity.indicators;
import java.io.Serializable; import java.util.Date;
import org.springframework.data.annotation.Id; import javax.persistence.Id;
import org.springframework.data.mongodb.core.mapping.Document; import javax.persistence.Table;
import com.keymobile.indicators.utils.DateUtils;
import lombok.Data; import lombok.Data;
...@@ -11,17 +13,13 @@ import lombok.Data; ...@@ -11,17 +13,13 @@ import lombok.Data;
*author:zhangkb time:2020-5-21 desc:考核指标数据版本数据 *author:zhangkb time:2020-5-21 desc:考核指标数据版本数据
*/ */
@Data @Data
@Document(collection="drive_ind_def_version_data") @Table(name="drive_ind_def_version_data")
public class DriveIndDefVersionData implements Serializable{ public class DriveIndDefVersionData {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id @Id
private String id; private Integer id;
private String indId; private String indId;
private String indName; private String indName;
private String version; private String version;
private String dataJson; private String dataJson;
private String lastUpdateTime = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
} }
package com.keymobile.indicators.model.entity.indicators; package com.keymobile.indicators.model.entity.indicators;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
import org.springframework.data.annotation.Id; import javax.persistence.GeneratedValue;
import org.springframework.data.mongodb.core.mapping.Document; import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.keymobile.indicators.utils.DateUtils; import com.keymobile.indicators.utils.DateUtils;
...@@ -15,19 +15,15 @@ import lombok.Data; ...@@ -15,19 +15,15 @@ import lombok.Data;
*author:zhangkb time:2020-5-18 desc:基础项目录 *author:zhangkb time:2020-5-18 desc:基础项目录
*/ */
@Data @Data
@Document(collection="ind_catalog") @Table(name="base_ind_catalog")
public class IndCatalog implements Serializable{ public class IndCatalog {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id @Id
private String id; @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String catalogName; private String catalogName;
//private String type; //private String type;
private String catalogType;//分为数据项级别和数据项类别 0:数据项级别 1:数据项类别 2:普通目录 private String catalogType;//分为数据项级别和数据项类别 0:数据项级别 1:数据项类别 2:普通目录
private String parentId;//顶层节点parentId为0 private Integer parentId;//顶层节点parentId为0
private String idPath; private String idPath;
private String code;//目录编码 private String code;//目录编码
private String lastUpdater; private String lastUpdater;
......
package com.keymobile.indicators.model.entity.indicators; package com.keymobile.indicators.model.entity.indicators;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
...@@ -12,6 +14,7 @@ import lombok.Data; ...@@ -12,6 +14,7 @@ import lombok.Data;
@Table(name="indi_data_def") @Table(name="indi_data_def")
public class IndicatorsData { public class IndicatorsData {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id; private Integer id;
private String indId; private String indId;
......
package com.keymobile.indicators.model.entity.objscorerule; package com.keymobile.indicators.model.entity.objscorerule;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.springframework.data.annotation.Id; import javax.persistence.GeneratedValue;
import org.springframework.data.mongodb.core.mapping.Document; import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.keymobile.indicators.utils.DateUtils; import com.keymobile.indicators.utils.DateUtils;
import lombok.Data; import lombok.Data;
...@@ -16,34 +16,26 @@ import lombok.Data; ...@@ -16,34 +16,26 @@ import lombok.Data;
*author:zhangkb time:2020-6-2 desc:单位评分规则实体 *author:zhangkb time:2020-6-2 desc:单位评分规则实体
*/ */
@Data @Data
@Document(collection="obj_score_rule") @Table(name ="obj_score_rule")
public class ScoreRule implements Serializable{ public class ScoreRule {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id @Id
private String id; @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String ruleName;//规则名称 private String ruleName;//规则名称
private String scoreType;//得分类型:0 指标值直接参与计算 1 指标得分分数参与计算(综合评分和改善提升分开算) 2指标得分分数参与计算(指标分数=综合+改善) private String scoreType;//得分类型:0 指标值直接参与计算 1 指标得分分数参与计算(综合评分和改善提升分开算) 2指标得分分数参与计算(指标分数=综合+改善)
private String calType;//计算类型:0 计算组内所有考核指标平均数 1 根据目录类别分类算平均分后根据权重计算考核指标 2单个指标权重计算 private String calType;//计算类型:0 计算组内所有考核指标平均数 1 根据目录类别分类算平均分后根据权重计算考核指标 2单个指标权重计算
private String indTypeWeightsJson;
private List<IndTypeWeight> indTypeWeights = new ArrayList<>();//目录类别权重数据 private List<IndTypeWeight> indTypeWeights = new ArrayList<>();//目录类别权重数据
private String calFormula;//当计算类型是2单个指标权重计算的时候,需要给出指标权重计算公式 private String calFormula;//当计算类型是2单个指标权重计算的时候,需要给出指标权重计算公式
private String calFormulaDesc;//单个指标权重计算公式描述 private String calFormulaDesc;//单个指标权重计算公式描述
private String catalogId;//单位得分计算目录id private Integer catalogId;//单位得分计算目录id
private String catalogIdPath;//单位得分计算目录idPath private String catalogIdPath;//单位得分计算目录idPath
private String code;//标识编码 private String code;//标识编码
private String desc;//规则描述 private String scoreRuleDesc;//规则描述
private String lastUpdateTime = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); private String lastUpdateTime = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
private String lastUpdater; private String lastUpdater;
public List<IndTypeWeight> getIndTypeWeights(){
return indTypeWeights;
}
public void setIndTypeWeights(List<IndTypeWeight> indTypeWeights){
this.indTypeWeights.addAll(indTypeWeights);
}
} }
package com.keymobile.indicators.model.entity.objscorerule; package com.keymobile.indicators.model.entity.objscorerule;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
import org.springframework.data.annotation.Id; import javax.persistence.GeneratedValue;
import org.springframework.data.mongodb.core.mapping.Document; import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.keymobile.indicators.utils.DateUtils; import com.keymobile.indicators.utils.DateUtils;
import lombok.Data; import lombok.Data;
...@@ -14,18 +14,14 @@ import lombok.Data; ...@@ -14,18 +14,14 @@ import lombok.Data;
*author:zhangkb time:2020-6-9 desc:单位评分规则目录实体 *author:zhangkb time:2020-6-9 desc:单位评分规则目录实体
*/ */
@Data @Data
@Document(collection="obj_score_rule_catalog") @Table(name="obj_score_rule_catalog")
public class ScoreRuleCatalog implements Serializable{ public class ScoreRuleCatalog{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id @Id
private String id; @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String catalogName; private String catalogName;
private String catalogType; private String catalogType;
private String parentId;//顶层节点parentId为0 private Integer parentId;//顶层节点parentId为0
private String idPath; private String idPath;
private String code;//目录编码 private String code;//目录编码
private String lastUpdater; private String lastUpdater;
......
package com.keymobile.indicators.model.entity.scorecard; package com.keymobile.indicators.model.entity.scorecard;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.springframework.data.annotation.Id; import javax.persistence.GeneratedValue;
import org.springframework.data.mongodb.core.mapping.Document; import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.keymobile.indicators.utils.DateUtils; import com.keymobile.indicators.utils.DateUtils;
import lombok.Data; import lombok.Data;
...@@ -16,48 +16,40 @@ import lombok.Data; ...@@ -16,48 +16,40 @@ import lombok.Data;
*author:zhangkb time:2020-5-6 desc:考核指标评分卡 *author:zhangkb time:2020-5-6 desc:考核指标评分卡
*/ */
@Data @Data
@Document(collection="drive_ind_score_card") @Table(name ="drive_ind_score_card")
public class IndScorecard implements Serializable{ public class IndScorecard {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id @Id
private String id; @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String cardName; private String cardName;
private String desc; private String cardDesc;
private String scoreType;//综合评分类型 0:定义 1:公式 private String scoreType;//综合评分类型 0:定义 1:公式
//定义综合评价 //定义综合评价
private double indBaseScore;//基础分 private Double indBaseScore;//基础分
private double moreAverage;//大于组内平均分加分 private Double moreAverage;//大于组内平均分加分
private double lessAverage;//小于组内平均分减分 private Double lessAverage;//小于组内平均分减分
private String addScoreItemJson;//加分项json
private String minusScoreItemJson;//减分项json
private List<RankScoreDef> addScoreItem = new ArrayList<>();//加分项 private List<RankScoreDef> addScoreItem = new ArrayList<>();//加分项
private List<RankScoreDef> minusScoreItem = new ArrayList<>();//减分项 private List<RankScoreDef> minusScoreItem = new ArrayList<>();//减分项
//公式综合评价 //公式综合评价
private double bestIndScore;//最佳指标分 private Double bestIndScore;//最佳指标分
private double worstIndScore;//最差指标分 private Double worstIndScore;//最差指标分
private String otherCalFormula;//其他计算公式 private String otherCalFormula;//其他计算公式
//改善提升 //改善提升
private String isIncluScore;//是否纳入单位计分 0:不纳入 1:纳入 private String isIncluScore;//是否纳入单位计分 0:不纳入 1:纳入
private double limitScore;//上限分数 private Double limitScore;//上限分数
private String improveScoreItemJson;//改善提升分数json
private List<ImproveScoreDef> improveScoreItem = new ArrayList<>();//改善提升分数 private List<ImproveScoreDef> improveScoreItem = new ArrayList<>();//改善提升分数
private String catalogId;//评分卡目录id private Integer catalogId;//评分卡目录id
private String catalogIdPath;//评分卡目录idPath private String catalogIdPath;//评分卡目录idPath
private String lastUpdateTime = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); private String lastUpdateTime = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
private String lastUpdater; private String lastUpdater;
public void setAddScoreItem(List<RankScoreDef> addScoreItem) {
this.addScoreItem.addAll(addScoreItem);
}
public void setMinusScoreItem(List<RankScoreDef> minusScoreItem) {
this.minusScoreItem.addAll(minusScoreItem);
}
public void setImproveScoreItem(List<ImproveScoreDef> improveScoreItem) {
this.improveScoreItem.addAll(improveScoreItem);
}
} }
package com.keymobile.indicators.model.entity.scorecard; package com.keymobile.indicators.model.entity.scorecard;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
import org.springframework.data.annotation.Id; import javax.persistence.GeneratedValue;
import org.springframework.data.mongodb.core.mapping.Document; import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.keymobile.indicators.utils.DateUtils; import com.keymobile.indicators.utils.DateUtils;
import lombok.Data; import lombok.Data;
...@@ -14,18 +14,14 @@ import lombok.Data; ...@@ -14,18 +14,14 @@ import lombok.Data;
*author:zhangkb time:2020-6-9 desc:指标评分卡目录实体 *author:zhangkb time:2020-6-9 desc:指标评分卡目录实体
*/ */
@Data @Data
@Document(collection="score_card_catalog") @Table(name="score_card_catalog")
public class ScorecardCatalog implements Serializable{ public class ScorecardCatalog{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id @Id
private String id; @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String catalogName; private String catalogName;
private String catalogType; private String catalogType;
private String parentId;//顶层节点parentId为0 private Integer parentId;//顶层节点parentId为0
private String idPath; private String idPath;
private String code;//目录编码 private String code;//目录编码
private String lastUpdater; private String lastUpdater;
......
package com.keymobile.indicators.model.entity.shortboard; package com.keymobile.indicators.model.entity.shortboard;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
import org.springframework.data.annotation.Id; import javax.persistence.GeneratedValue;
import org.springframework.data.mongodb.core.mapping.Document; import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.keymobile.indicators.utils.DateUtils; import com.keymobile.indicators.utils.DateUtils;
import lombok.Data; import lombok.Data;
...@@ -14,18 +14,15 @@ import lombok.Data; ...@@ -14,18 +14,15 @@ import lombok.Data;
*author:zhangkb time:2020-6-10 desc:短板筛选规则目录实体 *author:zhangkb time:2020-6-10 desc:短板筛选规则目录实体
*/ */
@Data @Data
@Document(collection="ind_short_board_catalog") @Table(name ="ind_short_board_catalog")
public class ShortboardCatalog implements Serializable{ public class ShortboardCatalog{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id @Id
private String id; @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String catalogName; private String catalogName;
private String catalogType; private String catalogType;
private String parentId;//顶层节点parentId为0 private Integer parentId;//顶层节点parentId为0
private String idPath; private String idPath;
private String code;//目录编码 private String code;//目录编码
private String lastUpdater; private String lastUpdater;
......
package com.keymobile.indicators.model.entity.shortboard; package com.keymobile.indicators.model.entity.shortboard;
import java.io.Serializable; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import org.springframework.data.annotation.Id; import javax.persistence.Id;
import org.springframework.data.mongodb.core.mapping.Document; import javax.persistence.Table;
import lombok.Data; import lombok.Data;
...@@ -11,19 +11,16 @@ import lombok.Data; ...@@ -11,19 +11,16 @@ import lombok.Data;
* author:zhangkb time:2020-6-11 desc:新增短板筛选规则和考核指标关系中间表 * author:zhangkb time:2020-6-11 desc:新增短板筛选规则和考核指标关系中间表
*/ */
@Data @Data
@Document(collection="short_board_drive_ind_rel") @Table(name ="short_board_drive_ind_rel")
public class ShortboardDriveIndRel implements Serializable{ public class ShortboardDriveIndRel{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id @Id
private String id; @GeneratedValue(strategy = GenerationType.IDENTITY)
private String shortboardRuleId;//短板规则id private Integer id;
private String driveIndDefId;//考核指标id
private Integer shortboardRuleId;//短板规则id
private Integer driveIndDefId;//考核指标id
public ShortboardDriveIndRel(String driveIndDefId,String shortboardRuleId) { public ShortboardDriveIndRel(Integer driveIndDefId,Integer shortboardRuleId) {
this.driveIndDefId = driveIndDefId; this.driveIndDefId = driveIndDefId;
this.shortboardRuleId = shortboardRuleId; this.shortboardRuleId = shortboardRuleId;
} }
......
package com.keymobile.indicators.model.entity.shortboard; package com.keymobile.indicators.model.entity.shortboard;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.springframework.data.annotation.Id; import javax.persistence.GeneratedValue;
import org.springframework.data.mongodb.core.mapping.Document; import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.keymobile.indicators.utils.DateUtils; import com.keymobile.indicators.utils.DateUtils;
...@@ -16,30 +17,22 @@ import lombok.Data; ...@@ -16,30 +17,22 @@ import lombok.Data;
*author:zhangkb time:2020-6-10 desc:短板筛选规则实体 *author:zhangkb time:2020-6-10 desc:短板筛选规则实体
*/ */
@Data @Data
@Document(collection="short_board_rule") @Table(name ="short_board_rule")
public class ShortboardRule implements Serializable{ public class ShortboardRule{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id @Id
private String id; @GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String ruleName;//规则名称 private String ruleName;//规则名称
private String ruleDesc;//规则描述 private String ruleDesc;//规则描述
private String shortboardItemJson;
private List<ShortboardItem> shortboardItem = new ArrayList<>();//短板规则选项 private List<ShortboardItem> shortboardItem = new ArrayList<>();//短板规则选项
private String code;//编码 private String code;//编码
private String catalogId; private Integer catalogId;
private String catalogIdPath; private String catalogIdPath;
private String lastUpdateTime = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"); private String lastUpdateTime = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
private String lastUpdater; private String lastUpdater;
public List<ShortboardItem> getShortboardItem(){
return shortboardItem;
}
public void setShortboardItem(List<ShortboardItem> shortboardItem){
this.shortboardItem.addAll(shortboardItem);
}
} }
...@@ -15,5 +15,5 @@ public interface BaseIndDefMapper extends BaseMapper<BaseIndDef>{ ...@@ -15,5 +15,5 @@ public interface BaseIndDefMapper extends BaseMapper<BaseIndDef>{
public int getByKeywordCount(Map<String,Object> param); public int getByKeywordCount(Map<String,Object> param);
public void deleteByCatalogIdIn(List<String> catalogIds); public void deleteByCatalogIdIn(List<Integer> catalogIds);
} }
...@@ -15,5 +15,5 @@ public interface DriveIndDefMapper extends BaseMapper<DriveIndDef>{ ...@@ -15,5 +15,5 @@ public interface DriveIndDefMapper extends BaseMapper<DriveIndDef>{
public int getByKeywordCount(Map<String,Object> param); public int getByKeywordCount(Map<String,Object> param);
public void deleteByCatalogIdIn(List<String> catalogIds); public void deleteByCatalogIdIn(List<Integer> catalogIds);
} }
package com.keymobile.indicators.model.mapper.indmapper;
import org.apache.ibatis.annotations.Mapper;
import com.keymobile.indicators.model.entity.indicators.BaseIndDefVersionData;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface BaseIndDefVersionDataMapper extends BaseMapper<BaseIndDefVersionData>{
}
package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import com.keymobile.indicators.model.entity.indicators.DriveIndCatalog;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface DriveIndCatalogMapper extends BaseMapper<DriveIndCatalog>{
public void deleteByIdIn(List<Integer> ids);
public List<DriveIndCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params);
public List<DriveIndCatalog> findByParentId(@Param("pid") Integer pid);
}
package com.keymobile.indicators.model.mapper.indmapper;
import org.apache.ibatis.annotations.Mapper;
import com.keymobile.indicators.model.entity.indicators.DriveIndDefVersionData;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface DriveIndDefVersionDataMapper extends BaseMapper<DriveIndDefVersionData>{
}
package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import com.keymobile.indicators.model.entity.indicators.IndCatalog;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface IndCatalogMapper extends BaseMapper<IndCatalog>{
public void deleteByIdIn(List<Integer> ids);
public List<IndCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params);
public List<IndCatalog> findByParentId(@Param("pid") Integer pid);
}
package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import com.keymobile.indicators.model.entity.scorecard.IndScorecard;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface IndScorecardMapper extends BaseMapper<IndScorecard>{
public void deleteByCatalogIdIn(List<Integer> catalogIds);
public List<IndScorecard> findByCatalogId(@Param("catalogId")Integer catalogId,
@Param("start") int start,@Param("end") int end);
public int countByCatalogId(@Param("catalogId")Integer catalogId);
}
package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import com.keymobile.indicators.model.entity.objscorerule.ScoreRuleCatalog;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface ScoreRuleCatalogMapper extends BaseMapper<ScoreRuleCatalog>{
public void deleteByIdIn(List<Integer> ids);
public List<ScoreRuleCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params);
public List<ScoreRuleCatalog> findByParentId(@Param("pid") Integer pid);
}
package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import com.keymobile.indicators.model.entity.objscorerule.ScoreRule;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface ScoreRuleMapper extends BaseMapper<ScoreRule>{
public List<ScoreRule> findByCode(@Param("code")String code);
public void deleteByCatalogIdIn(List<Integer> ids);
public List<ScoreRule> findByCatalogId(@Param("catalogId")Integer catalogId,
@Param("start") int start,@Param("end") int end);
public int countByCatalogId(@Param("catalogId")Integer catalogId);
}
package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import com.keymobile.indicators.model.entity.scorecard.ScorecardCatalog;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface ScorecardCatalogMapper extends BaseMapper<ScorecardCatalog>{
public void deleteByIdIn(List<Integer> ids);
public List<ScorecardCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params);
public List<ScorecardCatalog> findByParentId(@Param("pid") Integer pid);
}
package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import com.keymobile.indicators.model.entity.shortboard.ShortboardCatalog;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface ShortboardCatalogMapper extends BaseMapper<ShortboardCatalog>{
public void deleteByIdIn(List<Integer> ids);
public List<ShortboardCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(Map<String,Object> params);
public List<ShortboardCatalog> findByParentId(@Param("pid") Integer pid);
}
package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import com.keymobile.indicators.model.entity.shortboard.ShortboardDriveIndRel;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface ShortboardDriveIndRelMapper extends BaseMapper<ShortboardDriveIndRel>{
List<ShortboardDriveIndRel> findByDriveIndDefId(@Param("driveIndDefId")String driveIndDefId);
}
package com.keymobile.indicators.model.mapper.indmapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import com.keymobile.indicators.model.entity.shortboard.ShortboardRule;
import feign.Param;
import tk.mybatis.mapper.common.BaseMapper;
@Mapper
public interface ShortboardRuleMapper extends BaseMapper<ShortboardRule>{
public void deleteByCatalogIdIn(List<Integer> ids);
public List<ShortboardRule> findByCatalogId(@Param("catalogId")Integer catalogId,
@Param("start") int start,@Param("end") int end);
public int countByCatalogId(@Param("catalogId")Integer catalogId);
}
package com.keymobile.indicators.persistence.hyindicators;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.keymobile.indicators.model.entity.indicators.BaseIndDefVersionData;
public interface BaseIndDefVersionRepository extends MongoRepository<BaseIndDefVersionData,String>{
}
package com.keymobile.indicators.persistence.hyindicators;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.keymobile.indicators.model.entity.indicators.DriveIndCatalog;
public interface DriveIndCatalogRepository extends MongoRepository<DriveIndCatalog,String>{
public void deleteByIdIn(List<String> ids);
public List<DriveIndCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(String pid,List<String> codes);
public List<DriveIndCatalog> findByParentId(String pid);
}
package com.keymobile.indicators.persistence.hyindicators;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.keymobile.indicators.model.entity.indicators.DriveIndDefVersionData;
public interface DriveIndDefVersionRepository extends MongoRepository<DriveIndDefVersionData,String>{
}
package com.keymobile.indicators.persistence.hyindicators;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.keymobile.indicators.model.entity.indicators.IndCatalog;
public interface IndCatalogRepository extends MongoRepository<IndCatalog,String>{
public void deleteByIdIn(List<String> ids);
public List<IndCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(String pid,List<String> codes);
public List<IndCatalog> findByParentId(String pid);
}
package com.keymobile.indicators.persistence.hyindicators;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.keymobile.indicators.model.entity.scorecard.IndScorecard;
public interface IndScorecardRepository extends MongoRepository<IndScorecard,String>{
public void deleteByCatalogIdIn(List<String> catalogIds);
public Page<IndScorecard> findByCatalogId(String catalogId,Pageable page);
}
package com.keymobile.indicators.persistence.hyindicators;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.keymobile.indicators.model.entity.objscorerule.ScoreRuleCatalog;
public interface ScoreRuleCatalogRepository extends MongoRepository<ScoreRuleCatalog,String>{
public void deleteByIdIn(List<String> ids);
public List<ScoreRuleCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(String pid,List<String> codes);
public List<ScoreRuleCatalog> findByParentId(String pid);
}
package com.keymobile.indicators.persistence.hyindicators;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.keymobile.indicators.model.entity.objscorerule.ScoreRule;
public interface ScoreRuleRepository extends MongoRepository<ScoreRule,String>{
public List<ScoreRule> findByCode(String code);
public void deleteByCatalogIdIn(List<String> ids);
public Page<ScoreRule> findByCatalogId(String catalogId,Pageable page);
}
package com.keymobile.indicators.persistence.hyindicators;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.keymobile.indicators.model.entity.scorecard.ScorecardCatalog;
public interface ScorecardCatalogRepository extends MongoRepository<ScorecardCatalog,String>{
public void deleteByIdIn(List<String> ids);
public List<ScorecardCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(String pid,List<String> codes);
public List<ScorecardCatalog> findByParentId(String pid);
}
package com.keymobile.indicators.persistence.hyindicators;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.keymobile.indicators.model.entity.shortboard.ShortboardCatalog;
public interface ShortboardCatalogRepository extends MongoRepository<ShortboardCatalog,String>{
public void deleteByIdIn(List<String> ids);
public List<ShortboardCatalog> findByParentIdAndCodeInOrderByLastUpdateTimeDesc(String pid,List<String> codes);
public List<ShortboardCatalog> findByParentId(String pid);
}
package com.keymobile.indicators.persistence.hyindicators;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.keymobile.indicators.model.entity.shortboard.ShortboardDriveIndRel;
public interface ShortboardDriveIndRelRepository extends MongoRepository<ShortboardDriveIndRel,String>{
List<ShortboardDriveIndRel> findByDriveIndDefId(String driveIndDefId);
}
package com.keymobile.indicators.persistence.hyindicators;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.keymobile.indicators.model.entity.shortboard.ShortboardRule;
public interface ShortboardRuleRepository extends MongoRepository<ShortboardRule,String>{
public void deleteByCatalogIdIn(List<String> ids);
public Page<ShortboardRule> findByCatalogId(String catalogId,Pageable page);
}
...@@ -19,7 +19,7 @@ public class BaseIndDefService { ...@@ -19,7 +19,7 @@ public class BaseIndDefService {
@Autowired @Autowired
private BaseIndDefVersionService baseIndDefVersionService; private BaseIndDefVersionService baseIndDefVersionService;
public String saveOrUpdate(BaseIndDef baseIndDef,String catalogId,String catalogIdPath,String user) public String saveOrUpdate(BaseIndDef baseIndDef,Integer catalogId,String catalogIdPath,String user)
throws Exception{ throws Exception{
if(StringUtils.isBlank(baseIndDef.getIndId())) { if(StringUtils.isBlank(baseIndDef.getIndId())) {
return "indId can not be null"; return "indId can not be null";
...@@ -60,15 +60,11 @@ public class BaseIndDefService { ...@@ -60,15 +60,11 @@ public class BaseIndDefService {
baseIndDefMapper.deleteByPrimaryKey(indId); baseIndDefMapper.deleteByPrimaryKey(indId);
} }
public Map<String,Object> getByPageAndKeyword(String catalogId,String keyword, public Map<String,Object> getByPageAndKeyword(Integer catalogId,String keyword,
int page,int rows)throws Exception{ int page,int rows)throws Exception{
Map<String,Object> paramMap = new HashMap<>(); Map<String,Object> paramMap = new HashMap<>();
Map<String,Object> resultMap = new HashMap<>(); Map<String,Object> resultMap = new HashMap<>();
if(StringUtils.isBlank(catalogId)) { paramMap.put("catalogId", catalogId);
paramMap.put("catalogId", null);
}else {
paramMap.put("catalogId", catalogId);
}
if(StringUtils.isBlank(keyword)) { if(StringUtils.isBlank(keyword)) {
paramMap.put("keyword", null); paramMap.put("keyword", null);
}else { }else {
......
...@@ -9,14 +9,14 @@ import com.google.gson.Gson; ...@@ -9,14 +9,14 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.keymobile.indicators.model.entity.indicators.BaseIndDef; import com.keymobile.indicators.model.entity.indicators.BaseIndDef;
import com.keymobile.indicators.model.entity.indicators.BaseIndDefVersionData; import com.keymobile.indicators.model.entity.indicators.BaseIndDefVersionData;
import com.keymobile.indicators.persistence.hyindicators.BaseIndDefVersionRepository; import com.keymobile.indicators.model.mapper.indmapper.BaseIndDefVersionDataMapper;
@Service @Service
public class BaseIndDefVersionService { public class BaseIndDefVersionService {
private Logger logger = LoggerFactory.getLogger(BaseIndDefVersionService.class); private Logger logger = LoggerFactory.getLogger(BaseIndDefVersionService.class);
@Autowired @Autowired
private BaseIndDefVersionRepository baseIndDefVersionRepo; private BaseIndDefVersionDataMapper baseIndDefVersionDataMapper;
public boolean save(BaseIndDef baseIndDef) throws Exception{ public boolean save(BaseIndDef baseIndDef) throws Exception{
BaseIndDefVersionData baseIndDefVersionData = new BaseIndDefVersionData(); BaseIndDefVersionData baseIndDefVersionData = new BaseIndDefVersionData();
...@@ -27,7 +27,7 @@ public class BaseIndDefVersionService { ...@@ -27,7 +27,7 @@ public class BaseIndDefVersionService {
gsonBuilder.setPrettyPrinting(); gsonBuilder.setPrettyPrinting();
Gson gson = gsonBuilder.create(); Gson gson = gsonBuilder.create();
baseIndDefVersionData.setDataJson(gson.toJson(baseIndDef)); baseIndDefVersionData.setDataJson(gson.toJson(baseIndDef));
baseIndDefVersionRepo.save(baseIndDefVersionData); baseIndDefVersionDataMapper.insert(baseIndDefVersionData);
return true; return true;
} }
} }
...@@ -26,13 +26,16 @@ public class DriveIndCalResultService { ...@@ -26,13 +26,16 @@ public class DriveIndCalResultService {
private DriveIndCalResultDefMapper driveIndCalResultDefMapper; private DriveIndCalResultDefMapper driveIndCalResultDefMapper;
public int saveOrUpdate(DriveIndCalResultDef driveIndCalResult) { public int saveOrUpdate(DriveIndCalResultDef driveIndCalResult) {
return driveIndCalResultDefMapper.insert(driveIndCalResult); if(driveIndCalResult.getId()==null) {
driveIndCalResultDefMapper.insert(driveIndCalResult);
}else {
driveIndCalResultDefMapper.updateByPrimaryKey(driveIndCalResult);
}
return driveIndCalResult.getId();
} }
public DriveIndCalResultDef findById(Integer id) { public DriveIndCalResultDef findById(Integer id) {
DriveIndCalResultDef driveCalResultDef = new DriveIndCalResultDef(); return driveIndCalResultDefMapper.selectByPrimaryKey(id);
driveCalResultDef.setId(id);
return driveIndCalResultDefMapper.selectOne(driveCalResultDef);
} }
public DriveIndCalResultDef findCompareObjInfo(String driveIndId,int date,String compareObj) { public DriveIndCalResultDef findCompareObjInfo(String driveIndId,int date,String compareObj) {
......
package com.keymobile.indicators.service.hytobacco; package com.keymobile.indicators.service.hytobacco;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -12,50 +11,50 @@ import org.springframework.stereotype.Service; ...@@ -12,50 +11,50 @@ import org.springframework.stereotype.Service;
import com.keymobile.indicators.model.entity.indicators.DriveIndCatalog; import com.keymobile.indicators.model.entity.indicators.DriveIndCatalog;
import com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper; import com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper;
import com.keymobile.indicators.persistence.hyindicators.DriveIndCatalogRepository; import com.keymobile.indicators.model.mapper.indmapper.DriveIndCatalogMapper;
@Service @Service
public class DriveIndCatalogService { public class DriveIndCatalogService {
private Logger logger = LoggerFactory.getLogger(DriveIndCatalogService.class); private Logger logger = LoggerFactory.getLogger(DriveIndCatalogService.class);
@Autowired @Autowired
private DriveIndCatalogRepository driveIndCatalogRepo; private DriveIndCatalogMapper driveIndCatalogMapper;
@Autowired @Autowired
private DriveIndDefMapper driveIndDefMapper; private DriveIndDefMapper driveIndDefMapper;
public DriveIndCatalog saveOrUpdate(DriveIndCatalog driveIndCatalog) throws Exception{ public DriveIndCatalog saveOrUpdate(DriveIndCatalog driveIndCatalog) throws Exception{
if(StringUtils.isBlank(driveIndCatalog.getId())) {//新增 if(driveIndCatalog.getId()==null) {//新增
//保存 //保存
driveIndCatalog = driveIndCatalogRepo.save(driveIndCatalog); driveIndCatalogMapper.insert(driveIndCatalog);
} }
//获取parentId拼接idPath //获取parentId拼接idPath
String parentId = driveIndCatalog.getParentId(); Integer parentId = driveIndCatalog.getParentId();
if(StringUtils.isBlank(parentId) || "0".equals(parentId)) {//顶层节点 if(parentId==0) {//顶层节点
driveIndCatalog.setIdPath(driveIndCatalog.getId()); driveIndCatalog.setIdPath(String.valueOf(driveIndCatalog.getId())+";");
}else { }else {
Optional<DriveIndCatalog> parentDriveIndCatalog = driveIndCatalogRepo.findById(driveIndCatalog.getParentId()); DriveIndCatalog parentDriveIndCatalog = driveIndCatalogMapper.selectByPrimaryKey(driveIndCatalog.getParentId());
if(!parentDriveIndCatalog.isPresent()) { if(parentDriveIndCatalog==null) {
throw new Exception("父节点不存在:parent catalog is not exist"); throw new Exception("父节点不存在:parent catalog is not exist");
}else { }else {
driveIndCatalog.setIdPath(parentDriveIndCatalog.get().getIdPath()+";"+ driveIndCatalog.setIdPath(parentDriveIndCatalog.getIdPath()+
driveIndCatalog.getId()); driveIndCatalog.getId()+";");
} }
} }
//保存 //保存
driveIndCatalog = driveIndCatalogRepo.save(driveIndCatalog); driveIndCatalogMapper.updateByPrimaryKey(driveIndCatalog);
return driveIndCatalog; return driveIndCatalog;
} }
public void delete(List<String> ids) { public void delete(List<Integer> ids) {
driveIndCatalogRepo.deleteByIdIn(ids); driveIndCatalogMapper.deleteByIdIn(ids);
} }
//递归查找父目录下的子目录 //递归查找父目录下的子目录
public List<String> getDeleteCatalogId(String id){ public List<Integer> getDeleteCatalogId(Integer id){
List<String> result = new ArrayList<>(); List<Integer> result = new ArrayList<>();
result.add(id); result.add(id);
//根据id获取子节点 //根据id获取子节点
List<DriveIndCatalog> children = driveIndCatalogRepo.findByParentId(id); List<DriveIndCatalog> children = driveIndCatalogMapper.findByParentId(id);
if(!children.isEmpty()) { if(!children.isEmpty()) {
for(DriveIndCatalog child : children) { for(DriveIndCatalog child : children) {
result.addAll(getDeleteCatalogId(child.getId())); result.addAll(getDeleteCatalogId(child.getId()));
...@@ -65,9 +64,9 @@ public class DriveIndCatalogService { ...@@ -65,9 +64,9 @@ public class DriveIndCatalogService {
} }
//递归删除 //递归删除
public void recursionDelete(List<String> ids) { public void recursionDelete(List<Integer> ids) {
for(String id : ids) { for(Integer id : ids) {
List<String> result = this.getDeleteCatalogId(id); List<Integer> result = this.getDeleteCatalogId(id);
this.delete(result); this.delete(result);
//删除目录关联的指标 //删除目录关联的指标
driveIndDefMapper.deleteByCatalogIdIn(result); driveIndDefMapper.deleteByCatalogIdIn(result);
...@@ -75,10 +74,10 @@ public class DriveIndCatalogService { ...@@ -75,10 +74,10 @@ public class DriveIndCatalogService {
} }
//获取目录树 //获取目录树
public List<DriveIndCatalog> getCatalog(String parentId,List<String> codes){ public List<DriveIndCatalog> getCatalog(Integer parentId,List<String> codes){
if(StringUtils.isBlank(parentId) || "0".equals(parentId)) { Map<String,Object> paramMap = new HashMap<>();
return driveIndCatalogRepo.findByParentIdAndCodeInOrderByLastUpdateTimeDesc("0", codes); paramMap.put("pid", parentId);
} paramMap.put("codes", codes);
return driveIndCatalogRepo.findByParentIdAndCodeInOrderByLastUpdateTimeDesc(parentId, codes); return driveIndCatalogMapper.findByParentIdAndCodeInOrderByLastUpdateTimeDesc(paramMap);
} }
} }
...@@ -28,7 +28,7 @@ public class DriveIndDefService { ...@@ -28,7 +28,7 @@ public class DriveIndDefService {
@Autowired @Autowired
private BaseIndDataService baseIndDataService; private BaseIndDataService baseIndDataService;
public String saveOrUpdate(DriveIndDef driveIndDef,String catalogId,String catalogIdPath,String user) public String saveOrUpdate(DriveIndDef driveIndDef,Integer catalogId,String catalogIdPath,String user)
throws Exception{ throws Exception{
if(StringUtils.isBlank(driveIndDef.getIndId())) { if(StringUtils.isBlank(driveIndDef.getIndId())) {
return "indId can not be null"; return "indId can not be null";
...@@ -69,15 +69,11 @@ public class DriveIndDefService { ...@@ -69,15 +69,11 @@ public class DriveIndDefService {
driveIndDefMapper.deleteByPrimaryKey(indId); driveIndDefMapper.deleteByPrimaryKey(indId);
} }
public Map<String,Object> getByPageAndKeyword(String catalogId,String keyword, public Map<String,Object> getByPageAndKeyword(Integer catalogId,String keyword,
int page,int rows)throws Exception{ int page,int rows)throws Exception{
Map<String,Object> paramMap = new HashMap<>(); Map<String,Object> paramMap = new HashMap<>();
Map<String,Object> resultMap = new HashMap<>(); Map<String,Object> resultMap = new HashMap<>();
if(StringUtils.isBlank(catalogId)) { paramMap.put("catalogId", catalogId);
paramMap.put("catalogId", null);
}else {
paramMap.put("catalogId", catalogId);
}
if(StringUtils.isBlank(keyword)) { if(StringUtils.isBlank(keyword)) {
paramMap.put("keyword", null); paramMap.put("keyword", null);
}else { }else {
......
...@@ -9,14 +9,14 @@ import com.google.gson.Gson; ...@@ -9,14 +9,14 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.keymobile.indicators.model.entity.indicators.DriveIndDef; import com.keymobile.indicators.model.entity.indicators.DriveIndDef;
import com.keymobile.indicators.model.entity.indicators.DriveIndDefVersionData; import com.keymobile.indicators.model.entity.indicators.DriveIndDefVersionData;
import com.keymobile.indicators.persistence.hyindicators.DriveIndDefVersionRepository; import com.keymobile.indicators.model.mapper.indmapper.DriveIndDefVersionDataMapper;
@Service @Service
public class DriveIndDefVersionService { public class DriveIndDefVersionService {
private Logger logger = LoggerFactory.getLogger(DriveIndDefVersionService.class); private Logger logger = LoggerFactory.getLogger(DriveIndDefVersionService.class);
@Autowired @Autowired
private DriveIndDefVersionRepository driveIndDefVersionRepo; private DriveIndDefVersionDataMapper driveIndDefVersionDataMapper;
public boolean save(DriveIndDef driveIndDef) throws Exception{ public boolean save(DriveIndDef driveIndDef) throws Exception{
DriveIndDefVersionData driveIndDefVersionData = new DriveIndDefVersionData(); DriveIndDefVersionData driveIndDefVersionData = new DriveIndDefVersionData();
...@@ -27,7 +27,7 @@ public class DriveIndDefVersionService { ...@@ -27,7 +27,7 @@ public class DriveIndDefVersionService {
gsonBuilder.setPrettyPrinting(); gsonBuilder.setPrettyPrinting();
Gson gson = gsonBuilder.create(); Gson gson = gsonBuilder.create();
driveIndDefVersionData.setDataJson(gson.toJson(driveIndDef)); driveIndDefVersionData.setDataJson(gson.toJson(driveIndDef));
driveIndDefVersionRepo.save(driveIndDefVersionData); driveIndDefVersionDataMapper.insert(driveIndDefVersionData);
return true; return true;
} }
} }
package com.keymobile.indicators.service.hytobacco; package com.keymobile.indicators.service.hytobacco;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -12,49 +11,49 @@ import org.springframework.stereotype.Service; ...@@ -12,49 +11,49 @@ import org.springframework.stereotype.Service;
import com.keymobile.indicators.model.entity.indicators.IndCatalog; import com.keymobile.indicators.model.entity.indicators.IndCatalog;
import com.keymobile.indicators.model.mapper.indicators.BaseIndDefMapper; import com.keymobile.indicators.model.mapper.indicators.BaseIndDefMapper;
import com.keymobile.indicators.persistence.hyindicators.IndCatalogRepository; import com.keymobile.indicators.model.mapper.indmapper.IndCatalogMapper;
@Service @Service
public class IndCatalogService { public class IndCatalogService {
private Logger logger = LoggerFactory.getLogger(IndCatalogService.class); private Logger logger = LoggerFactory.getLogger(IndCatalogService.class);
@Autowired @Autowired
private IndCatalogRepository indCatalogRepo; private IndCatalogMapper indCatalogMapper;
@Autowired @Autowired
private BaseIndDefMapper baseIndDefMapper; private BaseIndDefMapper baseIndDefMapper;
public IndCatalog saveOrUpdate(IndCatalog indCatalog) throws Exception{ public IndCatalog saveOrUpdate(IndCatalog indCatalog) throws Exception{
if(StringUtils.isBlank(indCatalog.getId())) {//新增 if(indCatalog.getId()==null) {//新增
//保存 //保存
indCatalog = indCatalogRepo.save(indCatalog); indCatalogMapper.insert(indCatalog);
} }
//获取parentId拼接idPath //获取parentId拼接idPath
String parentId = indCatalog.getParentId(); int parentId = indCatalog.getParentId();
if(StringUtils.isBlank(parentId) || "0".equals(parentId)) {//顶层节点 if(parentId==0) {//顶层节点
indCatalog.setIdPath(indCatalog.getId()); indCatalog.setIdPath(String.valueOf(indCatalog.getId())+";");
}else { }else {
Optional<IndCatalog> parentIndCatalog = indCatalogRepo.findById(indCatalog.getParentId()); IndCatalog parentIndCatalog = indCatalogMapper.selectByPrimaryKey(indCatalog.getParentId());
if(!parentIndCatalog.isPresent()) { if(parentIndCatalog==null) {
throw new Exception("父节点不存在:parent catalog is not exist"); throw new Exception("父节点不存在:parent catalog is not exist");
}else { }else {
indCatalog.setIdPath(parentIndCatalog.get().getIdPath()+";"+indCatalog.getId()); indCatalog.setIdPath(parentIndCatalog.getIdPath()+indCatalog.getId()+";");
} }
} }
//保存 //保存
indCatalog = indCatalogRepo.save(indCatalog); indCatalogMapper.updateByPrimaryKey(indCatalog);
return indCatalog; return indCatalog;
} }
public void delete(List<String> ids) { public void delete(List<Integer> ids) {
indCatalogRepo.deleteByIdIn(ids); indCatalogMapper.deleteByIdIn(ids);
} }
//递归查找父目录下的子目录 //递归查找父目录下的子目录
public List<String> getDeleteCatalogId(String id){ public List<Integer> getDeleteCatalogId(int id){
List<String> result = new ArrayList<>(); List<Integer> result = new ArrayList<>();
result.add(id); result.add(id);
//根据id获取子节点 //根据id获取子节点
List<IndCatalog> children = indCatalogRepo.findByParentId(id); List<IndCatalog> children = indCatalogMapper.findByParentId(id);
if(!children.isEmpty()) { if(!children.isEmpty()) {
for(IndCatalog child : children) { for(IndCatalog child : children) {
result.addAll(getDeleteCatalogId(child.getId())); result.addAll(getDeleteCatalogId(child.getId()));
...@@ -64,9 +63,9 @@ public class IndCatalogService { ...@@ -64,9 +63,9 @@ public class IndCatalogService {
} }
//递归删除 //递归删除
public void recursionDelete(List<String> ids) { public void recursionDelete(List<Integer> ids) {
for(String id : ids) { for(Integer id : ids) {
List<String> result = this.getDeleteCatalogId(id); List<Integer> result = this.getDeleteCatalogId(id);
this.delete(result); this.delete(result);
//删除目录关联的指标 //删除目录关联的指标
baseIndDefMapper.deleteByCatalogIdIn(result); baseIndDefMapper.deleteByCatalogIdIn(result);
...@@ -74,10 +73,10 @@ public class IndCatalogService { ...@@ -74,10 +73,10 @@ public class IndCatalogService {
} }
//获取目录树 //获取目录树
public List<IndCatalog> getCatalog(String parentId,List<String> codes){ public List<IndCatalog> getCatalog(Integer parentId,List<String> codes){
if(StringUtils.isBlank(parentId) || "0".equals(parentId)) { Map<String,Object> paramMap = new HashMap<>();
return indCatalogRepo.findByParentIdAndCodeInOrderByLastUpdateTimeDesc("0", codes); paramMap.put("pid", parentId);
} paramMap.put("codes", codes);
return indCatalogRepo.findByParentIdAndCodeInOrderByLastUpdateTimeDesc(parentId, codes); return indCatalogMapper.findByParentIdAndCodeInOrderByLastUpdateTimeDesc(paramMap);
} }
} }
package com.keymobile.indicators.service.hytobacco; package com.keymobile.indicators.service.hytobacco;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.googlecode.aviator.AviatorEvaluator; 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;
...@@ -24,7 +23,7 @@ import com.keymobile.indicators.model.entity.scorecard.ImproveScoreDef; ...@@ -24,7 +23,7 @@ import com.keymobile.indicators.model.entity.scorecard.ImproveScoreDef;
import com.keymobile.indicators.model.entity.scorecard.IndScorecard; import com.keymobile.indicators.model.entity.scorecard.IndScorecard;
import com.keymobile.indicators.model.entity.scorecard.RankScoreDef; import com.keymobile.indicators.model.entity.scorecard.RankScoreDef;
import com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper; import com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper;
import com.keymobile.indicators.persistence.hyindicators.IndScorecardRepository; import com.keymobile.indicators.model.mapper.indmapper.IndScorecardMapper;
import com.keymobile.indicators.utils.CalculateUtils; import com.keymobile.indicators.utils.CalculateUtils;
@Service @Service
...@@ -32,54 +31,85 @@ public class IndScorecardService { ...@@ -32,54 +31,85 @@ public class IndScorecardService {
private Logger logger = LoggerFactory.getLogger(IndScorecardService.class); private Logger logger = LoggerFactory.getLogger(IndScorecardService.class);
@Autowired @Autowired
private IndScorecardRepository indScorecardRepo; private IndScorecardMapper indScorecardMapper;
@Autowired @Autowired
private DriveIndDefService driveIndDefService; private DriveIndDefService driveIndDefService;
@Autowired @Autowired
private DriveIndCalResultDefMapper driveIndCalResultDefMapper; private DriveIndCalResultDefMapper driveIndCalResultDefMapper;
//id不为空为修改,为空为新增 //id不为空为修改,为空为新增
public String saveOrUpdate(IndScorecard indScorecard,String catalogId, public Integer saveOrUpdate(IndScorecard indScorecard,Integer catalogId,
String catalogIdPath,String user) { String catalogIdPath,String user) {
Gson gson = new Gson();
if(!indScorecard.getAddScoreItem().isEmpty()) {
String addScoreItemJson = gson.toJson(indScorecard.getAddScoreItem());
indScorecard.setAddScoreItemJson(addScoreItemJson);
}
if(!indScorecard.getMinusScoreItem().isEmpty()) {
String minusScoreItemJson = gson.toJson(indScorecard.getMinusScoreItem());
indScorecard.setMinusScoreItemJson(minusScoreItemJson);
}
if(!indScorecard.getImproveScoreItem().isEmpty()) {
String improveScoreItemJson = gson.toJson(indScorecard.getImproveScoreItem());
indScorecard.setImproveScoreItemJson(improveScoreItemJson);
}
if(indScorecard.getMoreAverage()==null) {
indScorecard.setMoreAverage(0.0);
}
if(indScorecard.getLessAverage()==null) {
indScorecard.setLessAverage(0.0);
}
indScorecard.setCatalogId(catalogId); indScorecard.setCatalogId(catalogId);
indScorecard.setCatalogIdPath(catalogIdPath); indScorecard.setCatalogIdPath(catalogIdPath);
indScorecard.setLastUpdater(user); indScorecard.setLastUpdater(user);
indScorecard = indScorecardRepo.save(indScorecard); if(indScorecard.getId()==null) {
indScorecardMapper.insert(indScorecard);
}else {
indScorecardMapper.updateByPrimaryKey(indScorecard);
}
return indScorecard.getId(); return indScorecard.getId();
} }
public void delete(List<String> ids) { public void delete(List<Integer> ids) {
for(String id : ids) { for(Integer id : ids) {
indScorecardRepo.deleteById(id); indScorecardMapper.deleteByPrimaryKey(id);
} }
} }
public List<IndScorecard> getAll(){ public List<IndScorecard> getAll(){
return indScorecardRepo.findAll(); return indScorecardMapper.selectAll();
} }
public IndScorecard findById(String id) { public IndScorecard findById(Integer id) {
Optional<IndScorecard> result = indScorecardRepo.findById(id); IndScorecard result = indScorecardMapper.selectByPrimaryKey(id);
if(result.isPresent()) { if(result!=null) {
return result.get(); return result;
} }
return null; return null;
} }
public Page<IndScorecard> getByCatalogId(String catalogId,int page,int rows){ public Map<String,Object> getByCatalogId(Integer catalogId,int page,int rows){
Pageable pageable = PageRequest.of(page - 1, rows); Map<String,Object> result = new HashMap<>();
return indScorecardRepo.findByCatalogId(catalogId,pageable); int count = 0;
//计算start
int start = (page-1)*rows;
count = indScorecardMapper.countByCatalogId(catalogId);
List<IndScorecard> datas = indScorecardMapper.findByCatalogId(catalogId,start,rows);
result.put("count", count);
result.put("data", datas);
return result;
} }
public Map<String,String> calculateIndiScore(String indId,int date,String compareObj, public Map<String,String> calculateIndiScore(String indId,int date,String compareObj,
String indScorecardId,String compareId,List<String> compareObjs) throws Exception{ Integer indScorecardId,String compareId,List<String> compareObjs) throws Exception{
Map<String,String> result = new HashMap<>(); Map<String,String> result = new HashMap<>();
Gson gson = new Gson();
String indScoreValue = "0.0"; String indScoreValue = "0.0";
String indImproveScoreValue = "0.0"; String indImproveScoreValue = "0.0";
result.put("score",indScoreValue); result.put("score",indScoreValue);
result.put("improveScore",indImproveScoreValue); result.put("improveScore",indImproveScoreValue);
if(StringUtils.isNotBlank(indScorecardId)) { if(indScorecardId!=null) {
//根据评分卡id获取评分卡信息 //根据评分卡id获取评分卡信息
IndScorecard scoreCard = this.findById(indScorecardId); IndScorecard scoreCard = this.findById(indScorecardId);
double baseScoreValue = 0; double baseScoreValue = 0;
...@@ -138,8 +168,9 @@ public class IndScorecardService { ...@@ -138,8 +168,9 @@ public class IndScorecardService {
int rank = currentCompareObjResult.getRank();//获取排位 int rank = currentCompareObjResult.getRank();//获取排位
//加分项 //加分项
if(!scoreCard.getAddScoreItem().isEmpty()) { if(StringUtils.isNotBlank(scoreCard.getAddScoreItemJson())) {
List<RankScoreDef> addScoreItem = scoreCard.getAddScoreItem(); List<RankScoreDef> addScoreItem = gson.
fromJson(scoreCard.getAddScoreItemJson(), new TypeToken<List<RankScoreDef>>(){}.getType());
for(RankScoreDef scoreDef : addScoreItem) { for(RankScoreDef scoreDef : addScoreItem) {
if(scoreDef.getRank()==rank) { if(scoreDef.getRank()==rank) {
baseScoreValue += scoreDef.getScore(); baseScoreValue += scoreDef.getScore();
...@@ -148,8 +179,9 @@ public class IndScorecardService { ...@@ -148,8 +179,9 @@ public class IndScorecardService {
} }
} }
//减分项 //减分项
if(!scoreCard.getMinusScoreItem().isEmpty()) { if(StringUtils.isNotBlank(scoreCard.getMinusScoreItemJson())) {
List<RankScoreDef> minusScoreItem = scoreCard.getMinusScoreItem(); List<RankScoreDef> minusScoreItem = gson.
fromJson(scoreCard.getMinusScoreItemJson(), new TypeToken<List<RankScoreDef>>(){}.getType());
rank = currentDriveResultSize-rank+1; rank = currentDriveResultSize-rank+1;
for(RankScoreDef scoreDef : minusScoreItem) { for(RankScoreDef scoreDef : minusScoreItem) {
if(scoreDef.getRank()==rank) { if(scoreDef.getRank()==rank) {
...@@ -180,8 +212,14 @@ public class IndScorecardService { ...@@ -180,8 +212,14 @@ public class IndScorecardService {
DriveIndCalResultDef sameCompareObjResult = driveIndCalResultDefMapper DriveIndCalResultDef sameCompareObjResult = driveIndCalResultDefMapper
.findByIndIdAndDateAndCompareObj(indId, (date-100), compareObj); .findByIndIdAndDateAndCompareObj(indId, (date-100), compareObj);
if(sameCompareObjResult!=null) { if(sameCompareObjResult!=null) {
List<ImproveScoreDef> importScoreDefList = new ArrayList<>();
if(StringUtils.isNotBlank(scoreCard.getImproveScoreItemJson())) {
importScoreDefList = gson.
fromJson(scoreCard.getImproveScoreItemJson(),
new TypeToken<List<ImproveScoreDef>>(){}.getType());
}
double improveScore = this.calImproveValue(acsType, unit, double improveScore = this.calImproveValue(acsType, unit,
scoreCard.getImproveScoreItem(), currentCompareObjResult, importScoreDefList, currentCompareObjResult,
sameCompareObjResult,compareObjs); sameCompareObjResult,compareObjs);
if(scoreCard.getLimitScore()!=0) { if(scoreCard.getLimitScore()!=0) {
if(improveScore>scoreCard.getLimitScore()) { if(improveScore>scoreCard.getLimitScore()) {
......
...@@ -20,7 +20,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; ...@@ -20,7 +20,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.keymobile.indicators.model.entity.DimValue; import com.keymobile.indicators.model.entity.DimValue;
...@@ -42,9 +41,6 @@ public class IndicatorsValueService { ...@@ -42,9 +41,6 @@ public class IndicatorsValueService {
private IndicatorsDataMapper indicatorsDataMapper; private IndicatorsDataMapper indicatorsDataMapper;
@Autowired @Autowired
private DriveIndCalResultDefMapper driveIndCalResultDefMapper; private DriveIndCalResultDefMapper driveIndCalResultDefMapper;
@Value("${mongodb.database}")
private String database;
public void fillExcelXianScore(List<String> indIds,int date, public void fillExcelXianScore(List<String> indIds,int date,
String compareObjString,int groupNum,int type) throws Exception{ String compareObjString,int groupNum,int type) throws Exception{
......
package com.keymobile.indicators.service.hytobacco; package com.keymobile.indicators.service.hytobacco;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.keymobile.indicators.model.entity.objscorerule.ScoreRuleCatalog; import com.keymobile.indicators.model.entity.objscorerule.ScoreRuleCatalog;
import com.keymobile.indicators.persistence.hyindicators.ScoreRuleCatalogRepository; import com.keymobile.indicators.model.mapper.indmapper.ScoreRuleCatalogMapper;
import com.keymobile.indicators.persistence.hyindicators.ScoreRuleRepository; import com.keymobile.indicators.model.mapper.indmapper.ScoreRuleMapper;
@Service @Service
public class ScoreRuleCatalogService { public class ScoreRuleCatalogService {
private Logger logger = LoggerFactory.getLogger(ScoreRuleCatalogService.class); private Logger logger = LoggerFactory.getLogger(ScoreRuleCatalogService.class);
@Autowired @Autowired
private ScoreRuleCatalogRepository scoreRuleCatalogRepo; private ScoreRuleCatalogMapper scoreRuleCatalogMapper;
@Autowired @Autowired
private ScoreRuleRepository scoreRuleRepo; private ScoreRuleMapper scoreRuleMapper;
public ScoreRuleCatalog saveOrUpdate(ScoreRuleCatalog scoreRuleCatalog) throws Exception{ public ScoreRuleCatalog saveOrUpdate(ScoreRuleCatalog scoreRuleCatalog) throws Exception{
if(StringUtils.isBlank(scoreRuleCatalog.getId())) {//新增 if(scoreRuleCatalog.getId()==null) {//新增
//保存 //保存
scoreRuleCatalog = scoreRuleCatalogRepo.save(scoreRuleCatalog); scoreRuleCatalogMapper.insert(scoreRuleCatalog);
} }
//获取parentId拼接idPath //获取parentId拼接idPath
String parentId = scoreRuleCatalog.getParentId(); Integer parentId = scoreRuleCatalog.getParentId();
if(StringUtils.isBlank(parentId) || "0".equals(parentId)) {//顶层节点 if(parentId==0) {//顶层节点
scoreRuleCatalog.setIdPath(scoreRuleCatalog.getId()); scoreRuleCatalog.setIdPath(String.valueOf(scoreRuleCatalog.getId()));
}else { }else {
Optional<ScoreRuleCatalog> parentScoreRuleCatalog = scoreRuleCatalogRepo. ScoreRuleCatalog parentScoreRuleCatalog = scoreRuleCatalogMapper.
findById(scoreRuleCatalog.getParentId()); selectByPrimaryKey(scoreRuleCatalog.getParentId());
if(!parentScoreRuleCatalog.isPresent()) { if(parentScoreRuleCatalog==null) {
throw new Exception("父节点不存在:parent catalog is not exist"); throw new Exception("父节点不存在:parent catalog is not exist");
}else { }else {
scoreRuleCatalog.setIdPath(parentScoreRuleCatalog.get().getIdPath()+";"+scoreRuleCatalog.getId()); scoreRuleCatalog.setIdPath(parentScoreRuleCatalog.getIdPath()+";"+scoreRuleCatalog.getId());
} }
} }
//保存 //保存
scoreRuleCatalog = scoreRuleCatalogRepo.save(scoreRuleCatalog); scoreRuleCatalogMapper.updateByPrimaryKey(scoreRuleCatalog);
return scoreRuleCatalog; return scoreRuleCatalog;
} }
public void delete(List<String> ids) { public void delete(List<Integer> ids) {
scoreRuleCatalogRepo.deleteByIdIn(ids); scoreRuleCatalogMapper.deleteByIdIn(ids);
} }
//递归查找父目录下的子目录 //递归查找父目录下的子目录
public List<String> getDeleteCatalogId(String id){ public List<Integer> getDeleteCatalogId(Integer id){
List<String> result = new ArrayList<>(); List<Integer> result = new ArrayList<>();
result.add(id); result.add(id);
//根据id获取子节点 //根据id获取子节点
List<ScoreRuleCatalog> children = scoreRuleCatalogRepo.findByParentId(id); List<ScoreRuleCatalog> children = scoreRuleCatalogMapper.findByParentId(id);
if(!children.isEmpty()) { if(!children.isEmpty()) {
for(ScoreRuleCatalog child : children) { for(ScoreRuleCatalog child : children) {
result.addAll(getDeleteCatalogId(child.getId())); result.addAll(getDeleteCatalogId(child.getId()));
...@@ -65,20 +65,20 @@ public class ScoreRuleCatalogService { ...@@ -65,20 +65,20 @@ public class ScoreRuleCatalogService {
} }
//递归删除 //递归删除
public void recursionDelete(List<String> ids) { public void recursionDelete(List<Integer> ids) {
for(String id : ids) { for(Integer id : ids) {
List<String> result = this.getDeleteCatalogId(id); List<Integer> result = this.getDeleteCatalogId(id);
this.delete(result); this.delete(result);
//删除目录关联的单位评分规则 //删除目录关联的单位评分规则
scoreRuleRepo.deleteByCatalogIdIn(result); scoreRuleMapper.deleteByCatalogIdIn(result);
} }
} }
//获取目录树 //获取目录树
public List<ScoreRuleCatalog> getCatalog(String parentId,List<String> codes){ public List<ScoreRuleCatalog> getCatalog(Integer parentId,List<String> codes){
if(StringUtils.isBlank(parentId) || "0".equals(parentId)) { Map<String,Object> paramMap = new HashMap<>();
return scoreRuleCatalogRepo.findByParentIdAndCodeInOrderByLastUpdateTimeDesc("0", codes); paramMap.put("pid", parentId);
} paramMap.put("codes", codes);
return scoreRuleCatalogRepo.findByParentIdAndCodeInOrderByLastUpdateTimeDesc(parentId, codes); return scoreRuleCatalogMapper.findByParentIdAndCodeInOrderByLastUpdateTimeDesc(paramMap);
} }
} }
...@@ -4,7 +4,6 @@ import java.util.ArrayList; ...@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -12,11 +11,10 @@ import org.apache.commons.lang.StringUtils; ...@@ -12,11 +11,10 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.googlecode.aviator.AviatorEvaluator; 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;
...@@ -24,7 +22,7 @@ import com.keymobile.indicators.model.entity.objscorerule.IndTypeWeight; ...@@ -24,7 +22,7 @@ import com.keymobile.indicators.model.entity.objscorerule.IndTypeWeight;
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.persistence.hyindicators.ScoreRuleRepository; import com.keymobile.indicators.model.mapper.indmapper.ScoreRuleMapper;
import com.keymobile.indicators.utils.CalculateUtils; import com.keymobile.indicators.utils.CalculateUtils;
@Service @Service
...@@ -32,7 +30,7 @@ public class ScoreRuleService { ...@@ -32,7 +30,7 @@ public class ScoreRuleService {
private Logger logger = LoggerFactory.getLogger(ScoreRuleService.class); private Logger logger = LoggerFactory.getLogger(ScoreRuleService.class);
@Autowired @Autowired
private ScoreRuleRepository scoreRuleRepo; private ScoreRuleMapper scoreRuleMapper;
@Autowired @Autowired
private DriveIndDefMapper driveIndDefMapper; private DriveIndDefMapper driveIndDefMapper;
@Autowired @Autowired
...@@ -40,31 +38,47 @@ public class ScoreRuleService { ...@@ -40,31 +38,47 @@ public class ScoreRuleService {
private static final Pattern P = Pattern.compile("(\\[[^\\]]*\\])"); private static final Pattern P = Pattern.compile("(\\[[^\\]]*\\])");
public String saveOrUpdate(ScoreRule scoreRule,String catalogId,String catalogIdPath,String user) { public Integer saveOrUpdate(ScoreRule scoreRule,Integer catalogId,String catalogIdPath,String user) {
Gson gson = new Gson();
if(!scoreRule.getIndTypeWeights().isEmpty()) {
String indTypeWeightsJson = gson.toJson(scoreRule.getIndTypeWeights());
scoreRule.setIndTypeWeightsJson(indTypeWeightsJson);
}
scoreRule.setCatalogId(catalogId); scoreRule.setCatalogId(catalogId);
scoreRule.setCatalogIdPath(catalogIdPath); scoreRule.setCatalogIdPath(catalogIdPath);
scoreRule.setLastUpdater(user); scoreRule.setLastUpdater(user);
scoreRule = scoreRuleRepo.save(scoreRule); if(scoreRule.getId()==null) {
scoreRuleMapper.insert(scoreRule);
}else {
scoreRuleMapper.updateByPrimaryKey(scoreRule);
}
return scoreRule.getId(); return scoreRule.getId();
} }
public void delete(String id) { public void delete(Integer id) {
scoreRuleRepo.deleteById(id); scoreRuleMapper.deleteByPrimaryKey(id);
} }
public List<ScoreRule> getAll(String code){ public List<ScoreRule> getAll(String code){
return scoreRuleRepo.findByCode(code); return scoreRuleMapper.findByCode(code);
} }
public Page<ScoreRule> getByCatalogId(String catalogId,int page,int rows){ public Map<String,Object> getByCatalogId(Integer catalogId,int page,int rows){
Pageable pageable = PageRequest.of(page - 1, rows); Map<String,Object> result = new HashMap<>();
return scoreRuleRepo.findByCatalogId(catalogId,pageable); int count = 0;
//计算start
int start = (page-1)*rows;
count = scoreRuleMapper.countByCatalogId(catalogId);
List<ScoreRule> datas = scoreRuleMapper.findByCatalogId(catalogId, start, rows);
result.put("count", count);
result.put("data", datas);
return result;
} }
public ScoreRule getById(String id) { public ScoreRule getById(Integer id) {
Optional<ScoreRule> scoreRule = scoreRuleRepo.findById(id); ScoreRule scoreRule = scoreRuleMapper.selectByPrimaryKey(id);
if(scoreRule.isPresent()) { if(scoreRule!=null) {
return scoreRule.get(); return scoreRule;
} }
return null; return null;
} }
...@@ -212,6 +226,7 @@ public class ScoreRuleService { ...@@ -212,6 +226,7 @@ public class ScoreRuleService {
private Map<String,String> calIndCatalogTypeAverage(ScoreRule scoreRule, private Map<String,String> calIndCatalogTypeAverage(ScoreRule scoreRule,
String compareObj,int date){ String compareObj,int date){
Map<String,String> result = new HashMap<>(); Map<String,String> result = new HashMap<>();
Gson gson = new Gson();
result.put("compareObj", compareObj); result.put("compareObj", compareObj);
result.put("scoreValue", "0.0"); result.put("scoreValue", "0.0");
result.put("improveValue", "0.0"); result.put("improveValue", "0.0");
...@@ -222,8 +237,10 @@ public class ScoreRuleService { ...@@ -222,8 +237,10 @@ public class ScoreRuleService {
findByCompareObjAndDate(compareObj, date); findByCompareObjAndDate(compareObj, date);
double scoreValue = 0.0; double scoreValue = 0.0;
double improveValue = 0.0; double improveValue = 0.0;
if(!scoreRule.getIndTypeWeights().isEmpty()) { if(StringUtils.isNotBlank(scoreRule.getIndTypeWeightsJson())) {
for(IndTypeWeight indTypeWeight : scoreRule.getIndTypeWeights()) { List<IndTypeWeight> indTypeWeights = gson.
fromJson(scoreRule.getIndTypeWeightsJson(), new TypeToken<List<IndTypeWeight>>(){}.getType());
for(IndTypeWeight indTypeWeight : indTypeWeights) {
Map<String,Double> calScores = this.calIndTypeScore(scoreRule, indTypeWeight, calResults); Map<String,Double> calScores = this.calIndTypeScore(scoreRule, indTypeWeight, calResults);
scoreValue += (calScores.get("score")*Double.parseDouble(indTypeWeight.getWeight())); scoreValue += (calScores.get("score")*Double.parseDouble(indTypeWeight.getWeight()));
improveValue += (calScores.get("improve")*Double.parseDouble(indTypeWeight.getWeight())); improveValue += (calScores.get("improve")*Double.parseDouble(indTypeWeight.getWeight()));
...@@ -291,7 +308,7 @@ public class ScoreRuleService { ...@@ -291,7 +308,7 @@ public class ScoreRuleService {
//根据单位评分规则计算单位分数 //根据单位评分规则计算单位分数
public List<Map<String,String>> calObjScore(String reportId,String compareId,List<String> indIds, public List<Map<String,String>> calObjScore(String reportId,String compareId,List<String> indIds,
List<String> compareObjs,int date,String scoreRuleId) { List<String> compareObjs,int date,Integer scoreRuleId) {
List<Map<String,String>> results = new ArrayList<>(); List<Map<String,String>> results = new ArrayList<>();
//根据单位得分评分卡id获取评分卡详情 //根据单位得分评分卡id获取评分卡详情
ScoreRule scoreRule = this.getById(scoreRuleId); ScoreRule scoreRule = this.getById(scoreRuleId);
......
package com.keymobile.indicators.service.hytobacco; package com.keymobile.indicators.service.hytobacco;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.keymobile.indicators.model.entity.scorecard.ScorecardCatalog; import com.keymobile.indicators.model.entity.scorecard.ScorecardCatalog;
import com.keymobile.indicators.persistence.hyindicators.IndScorecardRepository; import com.keymobile.indicators.model.mapper.indmapper.IndScorecardMapper;
import com.keymobile.indicators.persistence.hyindicators.ScorecardCatalogRepository; import com.keymobile.indicators.model.mapper.indmapper.ScorecardCatalogMapper;
@Service @Service
public class ScorecardCatalogService { public class ScorecardCatalogService {
private Logger logger = LoggerFactory.getLogger(ScorecardCatalogService.class); private Logger logger = LoggerFactory.getLogger(ScorecardCatalogService.class);
@Autowired @Autowired
private ScorecardCatalogRepository scorecardCatalogRepo; private ScorecardCatalogMapper scorecardCatalogMapper;
@Autowired @Autowired
private IndScorecardRepository indScorecardRepo; private IndScorecardMapper indScorecardMapper;
public ScorecardCatalog saveOrUpdate(ScorecardCatalog scorecardCatalog) throws Exception{ public ScorecardCatalog saveOrUpdate(ScorecardCatalog scorecardCatalog) throws Exception{
if(StringUtils.isBlank(scorecardCatalog.getId())) {//新增 if(scorecardCatalog.getId()==null) {//新增
//保存 //保存
scorecardCatalog = scorecardCatalogRepo.save(scorecardCatalog); scorecardCatalogMapper.insert(scorecardCatalog);
} }
//获取parentId拼接idPath //获取parentId拼接idPath
String parentId = scorecardCatalog.getParentId(); Integer parentId = scorecardCatalog.getParentId();
if(StringUtils.isBlank(parentId) || "0".equals(parentId)) {//顶层节点 if(parentId==0) {//顶层节点
scorecardCatalog.setIdPath(scorecardCatalog.getId()); scorecardCatalog.setIdPath(String.valueOf(scorecardCatalog.getId()));
}else { }else {
Optional<ScorecardCatalog> parentScorecardCatalog = scorecardCatalogRepo. ScorecardCatalog parentScorecardCatalog = scorecardCatalogMapper.
findById(scorecardCatalog.getParentId()); selectByPrimaryKey(scorecardCatalog.getParentId());
if(!parentScorecardCatalog.isPresent()) { if(parentScorecardCatalog==null) {
throw new Exception("父节点不存在:parent catalog is not exist"); throw new Exception("父节点不存在:parent catalog is not exist");
}else { }else {
scorecardCatalog.setIdPath(parentScorecardCatalog.get().getIdPath()+";"+scorecardCatalog.getId()); scorecardCatalog.setIdPath(parentScorecardCatalog.getIdPath()+";"+scorecardCatalog.getId());
} }
} }
//保存 //保存
scorecardCatalog = scorecardCatalogRepo.save(scorecardCatalog); scorecardCatalogMapper.updateByPrimaryKey(scorecardCatalog);
return scorecardCatalog; return scorecardCatalog;
} }
public void delete(List<String> ids) { public void delete(List<Integer> ids) {
scorecardCatalogRepo.deleteByIdIn(ids); scorecardCatalogMapper.deleteByIdIn(ids);
} }
//递归查找父目录下的子目录 //递归查找父目录下的子目录
public List<String> getDeleteCatalogId(String id){ public List<Integer> getDeleteCatalogId(Integer id){
List<String> result = new ArrayList<>(); List<Integer> result = new ArrayList<>();
result.add(id); result.add(id);
//根据id获取子节点 //根据id获取子节点
List<ScorecardCatalog> children = scorecardCatalogRepo.findByParentId(id); List<ScorecardCatalog> children = scorecardCatalogMapper.findByParentId(id);
if(!children.isEmpty()) { if(!children.isEmpty()) {
for(ScorecardCatalog child : children) { for(ScorecardCatalog child : children) {
result.addAll(getDeleteCatalogId(child.getId())); result.addAll(getDeleteCatalogId(child.getId()));
...@@ -65,20 +65,20 @@ public class ScorecardCatalogService { ...@@ -65,20 +65,20 @@ public class ScorecardCatalogService {
} }
//递归删除 //递归删除
public void recursionDelete(List<String> ids) { public void recursionDelete(List<Integer> ids) {
for(String id : ids) { for(Integer id : ids) {
List<String> result = this.getDeleteCatalogId(id); List<Integer> result = this.getDeleteCatalogId(id);
this.delete(result); this.delete(result);
//删除目录关联的评分卡 //删除目录关联的评分卡
indScorecardRepo.deleteByCatalogIdIn(result); indScorecardMapper.deleteByCatalogIdIn(result);
} }
} }
//获取目录树 //获取目录树
public List<ScorecardCatalog> getCatalog(String parentId,List<String> codes){ public List<ScorecardCatalog> getCatalog(Integer parentId,List<String> codes){
if(StringUtils.isBlank(parentId) || "0".equals(parentId)) { Map<String,Object> paramMap = new HashMap<>();
return scorecardCatalogRepo.findByParentIdAndCodeInOrderByLastUpdateTimeDesc("0", codes); paramMap.put("pid", parentId);
} paramMap.put("codes", codes);
return scorecardCatalogRepo.findByParentIdAndCodeInOrderByLastUpdateTimeDesc(parentId, codes); return scorecardCatalogMapper.findByParentIdAndCodeInOrderByLastUpdateTimeDesc(paramMap);
} }
} }
package com.keymobile.indicators.service.hytobacco; package com.keymobile.indicators.service.hytobacco;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.keymobile.indicators.model.entity.shortboard.ShortboardCatalog; import com.keymobile.indicators.model.entity.shortboard.ShortboardCatalog;
import com.keymobile.indicators.persistence.hyindicators.ShortboardCatalogRepository; import com.keymobile.indicators.model.mapper.indmapper.ShortboardCatalogMapper;
import com.keymobile.indicators.persistence.hyindicators.ShortboardRuleRepository; import com.keymobile.indicators.model.mapper.indmapper.ShortboardRuleMapper;
@Service @Service
public class ShortboardCatalogService { public class ShortboardCatalogService {
private Logger logger = LoggerFactory.getLogger(ShortboardCatalogService.class); private Logger logger = LoggerFactory.getLogger(ShortboardCatalogService.class);
@Autowired @Autowired
private ShortboardCatalogRepository shortboardCatalogRepo; private ShortboardCatalogMapper shortboardCatalogMapper;
@Autowired @Autowired
private ShortboardRuleRepository shortboardRuleRepo; private ShortboardRuleMapper shortboardRuleMapper;
public ShortboardCatalog saveOrUpdate(ShortboardCatalog shortboardCatalog) throws Exception{ public ShortboardCatalog saveOrUpdate(ShortboardCatalog shortboardCatalog) throws Exception{
if(StringUtils.isBlank(shortboardCatalog.getId())) {//新增 if(shortboardCatalog.getId()==null) {//新增
//保存 //保存
shortboardCatalog = shortboardCatalogRepo.save(shortboardCatalog); shortboardCatalogMapper.insert(shortboardCatalog);
} }
//获取parentId拼接idPath //获取parentId拼接idPath
String parentId = shortboardCatalog.getParentId(); Integer parentId = shortboardCatalog.getParentId();
if(StringUtils.isBlank(parentId) || "0".equals(parentId)) {//顶层节点 if(parentId==0) {//顶层节点
shortboardCatalog.setIdPath(shortboardCatalog.getId()); shortboardCatalog.setIdPath(String.valueOf(shortboardCatalog.getId()));
}else { }else {
Optional<ShortboardCatalog> parentShortboardCatalog = shortboardCatalogRepo. ShortboardCatalog parentShortboardCatalog = shortboardCatalogMapper.
findById(shortboardCatalog.getParentId()); selectByPrimaryKey(shortboardCatalog.getParentId());
if(!parentShortboardCatalog.isPresent()) { if(parentShortboardCatalog==null) {
throw new Exception("父节点不存在:parent catalog is not exist"); throw new Exception("父节点不存在:parent catalog is not exist");
}else { }else {
shortboardCatalog.setIdPath(parentShortboardCatalog.get().getIdPath()+";"+shortboardCatalog.getId()); shortboardCatalog.setIdPath(parentShortboardCatalog.getIdPath()+";"+shortboardCatalog.getId());
} }
} }
//保存 //保存
shortboardCatalog = shortboardCatalogRepo.save(shortboardCatalog); shortboardCatalogMapper.updateByPrimaryKey(shortboardCatalog);
return shortboardCatalog; return shortboardCatalog;
} }
public void delete(List<String> ids) { public void delete(List<Integer> ids) {
shortboardCatalogRepo.deleteByIdIn(ids); shortboardCatalogMapper.deleteByIdIn(ids);
} }
//递归查找父目录下的子目录 //递归查找父目录下的子目录
public List<String> getDeleteCatalogId(String id){ public List<Integer> getDeleteCatalogId(Integer id){
List<String> result = new ArrayList<>(); List<Integer> result = new ArrayList<>();
result.add(id); result.add(id);
//根据id获取子节点 //根据id获取子节点
List<ShortboardCatalog> children = shortboardCatalogRepo.findByParentId(id); List<ShortboardCatalog> children = shortboardCatalogMapper.findByParentId(id);
if(!children.isEmpty()) { if(!children.isEmpty()) {
for(ShortboardCatalog child : children) { for(ShortboardCatalog child : children) {
result.addAll(getDeleteCatalogId(child.getId())); result.addAll(getDeleteCatalogId(child.getId()));
...@@ -65,20 +64,20 @@ public class ShortboardCatalogService { ...@@ -65,20 +64,20 @@ public class ShortboardCatalogService {
} }
//递归删除 //递归删除
public void recursionDelete(List<String> ids) { public void recursionDelete(List<Integer> ids) {
for(String id : ids) { for(Integer id : ids) {
List<String> result = this.getDeleteCatalogId(id); List<Integer> result = this.getDeleteCatalogId(id);
this.delete(result); this.delete(result);
//删除目录关联的短板筛选规则 //删除目录关联的短板筛选规则
shortboardRuleRepo.deleteByCatalogIdIn(result); shortboardRuleMapper.deleteByCatalogIdIn(result);
} }
} }
//获取目录树 //获取目录树
public List<ShortboardCatalog> getCatalog(String parentId,List<String> codes){ public List<ShortboardCatalog> getCatalog(Integer parentId,List<String> codes){
if(StringUtils.isBlank(parentId) || "0".equals(parentId)) { Map<String,Object> paramMap = new HashMap<>();
return shortboardCatalogRepo.findByParentIdAndCodeInOrderByLastUpdateTimeDesc("0", codes); paramMap.put("pid", parentId);
} paramMap.put("codes", codes);
return shortboardCatalogRepo.findByParentIdAndCodeInOrderByLastUpdateTimeDesc(parentId, codes); return shortboardCatalogMapper.findByParentIdAndCodeInOrderByLastUpdateTimeDesc(paramMap);
} }
} }
...@@ -4,23 +4,22 @@ import java.util.ArrayList; ...@@ -4,23 +4,22 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef; import com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef;
import com.keymobile.indicators.model.entity.shortboard.ShortboardDriveIndRel; import com.keymobile.indicators.model.entity.shortboard.ShortboardDriveIndRel;
import com.keymobile.indicators.model.entity.shortboard.ShortboardItem; import com.keymobile.indicators.model.entity.shortboard.ShortboardItem;
import com.keymobile.indicators.model.entity.shortboard.ShortboardRule; import com.keymobile.indicators.model.entity.shortboard.ShortboardRule;
import com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper; import com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper;
import com.keymobile.indicators.persistence.hyindicators.ShortboardDriveIndRelRepository; import com.keymobile.indicators.model.mapper.indmapper.ShortboardDriveIndRelMapper;
import com.keymobile.indicators.persistence.hyindicators.ShortboardRuleRepository; import com.keymobile.indicators.model.mapper.indmapper.ShortboardRuleMapper;
import com.keymobile.indicators.utils.CalculateUtils; import com.keymobile.indicators.utils.CalculateUtils;
@Service @Service
...@@ -28,34 +27,50 @@ public class ShortboardRuleService { ...@@ -28,34 +27,50 @@ public class ShortboardRuleService {
private Logger logger = LoggerFactory.getLogger(ShortboardRuleService.class); private Logger logger = LoggerFactory.getLogger(ShortboardRuleService.class);
@Autowired @Autowired
private ShortboardRuleRepository shortboardRuleRepo; private ShortboardRuleMapper shortboardRuleMapper;
@Autowired @Autowired
private ShortboardDriveIndRelRepository shortboardDriveIndRelRepo; private ShortboardDriveIndRelMapper shortboardDriveIndRelMapper;
@Autowired @Autowired
private DriveIndCalResultDefMapper driveIndCalResultDefMapper; private DriveIndCalResultDefMapper driveIndCalResultDefMapper;
public String saveOrUpdate(ShortboardRule shortboardRule,String catalogId, public Integer saveOrUpdate(ShortboardRule shortboardRule,Integer catalogId,
String catalogIdPath,String user) { String catalogIdPath,String user) {
Gson gson = new Gson();
if(!shortboardRule.getShortboardItem().isEmpty()) {
String shortboardItemJson = gson.toJson(shortboardRule.getShortboardItem());
shortboardRule.setShortboardItemJson(shortboardItemJson);
}
shortboardRule.setCatalogId(catalogId); shortboardRule.setCatalogId(catalogId);
shortboardRule.setCatalogIdPath(catalogIdPath); shortboardRule.setCatalogIdPath(catalogIdPath);
shortboardRule.setLastUpdater(user); shortboardRule.setLastUpdater(user);
shortboardRule = shortboardRuleRepo.save(shortboardRule); if(shortboardRule.getId()==null) {
shortboardRuleMapper.insert(shortboardRule);
}else {
shortboardRuleMapper.updateByPrimaryKey(shortboardRule);
}
return shortboardRule.getId(); return shortboardRule.getId();
} }
public void delete(String id) { public void delete(Integer id) {
shortboardRuleRepo.deleteById(id); shortboardRuleMapper.deleteByPrimaryKey(id);
} }
public Page<ShortboardRule> getByCatalogId(String catalogId,int page,int rows){ public Map<String,Object> getByCatalogId(Integer catalogId,int page,int rows){
Pageable pageable = PageRequest.of(page - 1, rows); Map<String,Object> result = new HashMap<>();
return shortboardRuleRepo.findByCatalogId(catalogId,pageable); int count = 0;
//计算start
int start = (page-1)*rows;
count = shortboardRuleMapper.countByCatalogId(catalogId);
List<ShortboardRule> datas = shortboardRuleMapper.findByCatalogId(catalogId, start, rows);
result.put("count", count);
result.put("data", datas);
return result;
} }
public ShortboardRule getById(String id) { public ShortboardRule getById(Integer id) {
Optional<ShortboardRule> shortboardRule = shortboardRuleRepo.findById(id); ShortboardRule shortboardRule = shortboardRuleMapper.selectByPrimaryKey(id);
if(shortboardRule.isPresent()) { if(shortboardRule!=null) {
return shortboardRule.get(); return shortboardRule;
} }
return null; return null;
} }
...@@ -64,16 +79,20 @@ public class ShortboardRuleService { ...@@ -64,16 +79,20 @@ public class ShortboardRuleService {
public List<Map<String,String>> getObjShortboard(String compareId,int date, public List<Map<String,String>> getObjShortboard(String compareId,int date,
List<String> compareObjs,List<String> driveIds){ List<String> compareObjs,List<String> driveIds){
List<Map<String,String>> result = new ArrayList<>(); List<Map<String,String>> result = new ArrayList<>();
Gson gson = new Gson();
for(String driveId : driveIds) { for(String driveId : driveIds) {
//根据考核指标id获取关联的短板筛选规则id //根据考核指标id获取关联的短板筛选规则id
List<ShortboardDriveIndRel> relations = shortboardDriveIndRelRepo. List<ShortboardDriveIndRel> relations = shortboardDriveIndRelMapper.
findByDriveIndDefId(driveId); findByDriveIndDefId(driveId);
for(ShortboardDriveIndRel rel : relations) { for(ShortboardDriveIndRel rel : relations) {
ShortboardRule shortboardRule = this.getById(rel.getShortboardRuleId()); ShortboardRule shortboardRule = this.getById(rel.getShortboardRuleId());
if(shortboardRule!=null) { if(shortboardRule!=null) {
List<ShortboardItem> shortboardItems = shortboardRule.getShortboardItem(); if(StringUtils.isNotBlank(shortboardRule.getShortboardItemJson())) {
for(ShortboardItem item : shortboardItems) { List<ShortboardItem> shortboardItems = gson.
fromJson(shortboardRule.getShortboardItemJson(), new TypeToken<List<ShortboardItem>>(){}.getType());
for(ShortboardItem item : shortboardItems) {
}
} }
} }
} }
......
<?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.BaseIndDefVersionDataMapper">
</mapper>
\ No newline at end of file
<?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.DriveIndCatalogMapper">
<delete id="deleteByIdIn" parameterType="java.util.List">
delete
from drive_ind_catalog
where id in
<foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
<select id="findByParentIdAndCodeInOrderByLastUpdateTimeDesc" parameterType="map" resultType="com.keymobile.indicators.model.entity.indicators.DriveIndCatalog" >
select *
from drive_ind_catalog
where parent_id = #{pid} and
code in
<foreach item="id" collection="codes" open="(" close=")" separator=",">
#{id}
</foreach>
order by last_update_time desc
</select>
<select id="findByParentId" resultType="com.keymobile.indicators.model.entity.indicators.DriveIndCatalog" >
select *
from drive_ind_catalog
where parent_id = #{pid}
</select>
</mapper>
\ No newline at end of file
<?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.DriveIndDefVersionDataMapper">
</mapper>
\ No newline at end of file
<?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.IndCatalogMapper">
<delete id="deleteByIdIn" parameterType="java.util.List">
delete
from base_ind_catalog
where id in
<foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
<select id="findByParentIdAndCodeInOrderByLastUpdateTimeDesc" parameterType="map" resultType="com.keymobile.indicators.model.entity.indicators.IndCatalog" >
select *
from base_ind_catalog
where parent_id = #{pid} and
code in
<foreach item="id" collection="codes" open="(" close=")" separator=",">
#{id}
</foreach>
order by last_update_time desc
</select>
<select id="findByParentId" resultType="com.keymobile.indicators.model.entity.indicators.IndCatalog" >
select *
from base_ind_catalog
where parent_id = #{pid}
</select>
</mapper>
\ No newline at end of file
<?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.IndScorecardMapper">
<select id="findByCatalogId" resultType="com.keymobile.indicators.model.entity.scorecard.IndScorecard" >
select *
from drive_ind_score_card
where catalog_id = #{catalogId}
limit #{start},#{end}
</select>
<select id="countByCatalogId" resultType="java.lang.Integer">
select count(1)
from drive_ind_score_card
where catalog_id = #{catalogId}
</select>
<delete id="deleteByCatalogIdIn" parameterType="java.util.List">
delete
from drive_ind_score_card
where catalog_id in
<foreach item="id" collection="catalogIds" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
<?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.ScoreRuleCatalogMapper">
<delete id="deleteByIdIn" parameterType="java.util.List">
delete
from obj_score_rule_catalog
where id in
<foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
<select id="findByParentIdAndCodeInOrderByLastUpdateTimeDesc" parameterType="map" resultType="com.keymobile.indicators.model.entity.objscorerule.ScoreRuleCatalog" >
select *
from obj_score_rule_catalog
where parent_id = #{pid} and
code in
<foreach item="id" collection="codes" open="(" close=")" separator=",">
#{id}
</foreach>
order by last_update_time desc
</select>
<select id="findByParentId" resultType="com.keymobile.indicators.model.entity.objscorerule.ScoreRuleCatalog" >
select *
from obj_score_rule_catalog
where parent_id = #{pid}
</select>
</mapper>
\ No newline at end of file
<?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.ScoreRuleMapper">
<select id="findByCode" resultType="com.keymobile.indicators.model.entity.objscorerule.ScoreRule" >
select *
from obj_score_rule
where code = #{code}
</select>
<select id="findByCatalogId" resultType="com.keymobile.indicators.model.entity.objscorerule.ScoreRule" >
select *
from obj_score_rule
where catalog_id = #{catalogId}
limit #{start},#{end}
</select>
<select id="countByCatalogId" resultType="java.lang.Integer">
select count(1)
from obj_score_rule
where catalog_id = #{catalogId}
</select>
<delete id="deleteByCatalogIdIn" parameterType="java.util.List">
delete
from obj_score_rule
where catalog_id in
<foreach item="id" collection="catalogIds" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
<?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.ScorecardCatalogMapper">
<delete id="deleteByIdIn" parameterType="java.util.List">
delete
from score_card_catalog
where id in
<foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
<select id="findByParentIdAndCodeInOrderByLastUpdateTimeDesc" parameterType="map" resultType="com.keymobile.indicators.model.entity.scorecard.ScorecardCatalog" >
select *
from score_card_catalog
where parent_id = #{pid} and
code in
<foreach item="id" collection="codes" open="(" close=")" separator=",">
#{id}
</foreach>
order by last_update_time desc
</select>
<select id="findByParentId" resultType="com.keymobile.indicators.model.entity.scorecard.ScorecardCatalog" >
select *
from score_card_catalog
where parent_id = #{pid}
</select>
</mapper>
\ No newline at end of file
<?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.ShortboardCatalogMapper">
<delete id="deleteByIdIn" parameterType="java.util.List">
delete
from ind_short_board_catalog
where id in
<foreach item="id" collection="ids" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
<select id="findByParentIdAndCodeInOrderByLastUpdateTimeDesc" parameterType="map" resultType="com.keymobile.indicators.model.entity.shortboard.ShortboardCatalog" >
select *
from ind_short_board_catalog
where parent_id = #{pid} and
code in
<foreach item="id" collection="codes" open="(" close=")" separator=",">
#{id}
</foreach>
order by last_update_time desc
</select>
<select id="findByParentId" resultType="com.keymobile.indicators.model.entity.shortboard.ShortboardCatalog" >
select *
from ind_short_board_catalog
where parent_id = #{pid}
</select>
</mapper>
\ No newline at end of file
<?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.ShortboardDriveIndRelMapper">
<select id="findByDriveIndDefId" resultType="com.keymobile.indicators.model.entity.shortboard.ShortboardDriveIndRel" >
select *
from short_board_drive_ind_rel
where drive_ind_def_id = #{driveIndDefId}
</select>
</mapper>
\ No newline at end of file
<?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.ShortboardRuleMapper">
<select id="findByCatalogId" resultType="com.keymobile.indicators.model.entity.shortboard.ShortboardRule" >
select *
from short_board_rule
where catalog_id = #{catalogId}
limit #{start},#{end}
</select>
<select id="countByCatalogId" resultType="java.lang.Integer">
select count(1)
from short_board_rule
where catalog_id = #{catalogId}
</select>
<delete id="deleteByCatalogIdIn" parameterType="java.util.List">
delete
from short_board_rule
where catalog_id in
<foreach item="id" collection="catalogIds" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>
</mapper>
\ 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