Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
indicators
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangkb
indicators
Commits
6f24a6d1
Commit
6f24a6d1
authored
Jun 09, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增指标评分卡目录接口和单位评分规则目录接口
parent
bd88399b
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
400 additions
and
14 deletions
+400
-14
IndScorecardCtrl.java
.../keymobile/indicators/api/hytobacco/IndScorecardCtrl.java
+29
-11
ObjScoreRuleCtrl.java
.../keymobile/indicators/api/hytobacco/ObjScoreRuleCtrl.java
+82
-0
ScoreRule.java
...obile/indicators/model/entity/objscorerule/ScoreRule.java
+2
-0
ScoreRuleCatalog.java
...ndicators/model/entity/objscorerule/ScoreRuleCatalog.java
+33
-0
IndScorecard.java
...obile/indicators/model/entity/scorecard/IndScorecard.java
+3
-0
ScorecardCatalog.java
...e/indicators/model/entity/scorecard/ScorecardCatalog.java
+33
-0
IndScorecardRepository.java
...tors/persistence/hyindicators/IndScorecardRepository.java
+4
-0
ScoreRuleCatalogRepository.java
.../persistence/hyindicators/ScoreRuleCatalogRepository.java
+15
-0
ScoreRuleRepository.java
...icators/persistence/hyindicators/ScoreRuleRepository.java
+5
-1
ScorecardCatalogRepository.java
.../persistence/hyindicators/ScorecardCatalogRepository.java
+14
-0
IndScorecardService.java
...ile/indicators/service/hytobacco/IndScorecardService.java
+4
-0
ScoreRuleCatalogService.java
...indicators/service/hytobacco/ScoreRuleCatalogService.java
+84
-0
ScoreRuleService.java
...mobile/indicators/service/hytobacco/ScoreRuleService.java
+8
-2
ScorecardCatalogService.java
...indicators/service/hytobacco/ScorecardCatalogService.java
+84
-0
No files found.
src/main/java/com/keymobile/indicators/api/hytobacco/IndScorecardCtrl.java
View file @
6f24a6d1
...
@@ -11,8 +11,9 @@ import org.springframework.web.bind.annotation.RequestParam;
...
@@ -11,8 +11,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.keymobile.indicators.model.entity.scorecard.IndScorecard
;
import
com.keymobile.indicators.model.entity.scorecard.IndScorecard
;
import
com.keymobile.indicators.model.entity.scorecard.ScorecardCatalog
;
import
com.keymobile.indicators.service.hytobacco.IndScorecardService
;
import
com.keymobile.indicators.service.hytobacco.IndScorecardService
;
import
com.keymobile.indicators.service.hytobacco.Score
Rule
Service
;
import
com.keymobile.indicators.service.hytobacco.Score
cardCatalog
Service
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
@@ -24,7 +25,27 @@ public class IndScorecardCtrl {
...
@@ -24,7 +25,27 @@ public class IndScorecardCtrl {
@Autowired
@Autowired
private
IndScorecardService
indScorecardService
;
private
IndScorecardService
indScorecardService
;
@Autowired
@Autowired
private
ScoreRuleService
scoreRuleService
;
private
ScorecardCatalogService
scorecardCatalogService
;
@ApiOperation
(
value
=
"新增/修改评分卡目录"
,
notes
=
"新增/修改评分卡目录"
)
@PostMapping
(
value
=
"/saveOrUpdateCatalog"
)
public
String
saveOrUpdateCatalog
(
@RequestBody
ScorecardCatalog
scorecardCatalog
)
throws
Exception
{
scorecardCatalog
=
scorecardCatalogService
.
saveOrUpdate
(
scorecardCatalog
);
return
scorecardCatalog
.
getId
();
}
@ApiOperation
(
value
=
"批量级联删除评分卡目录"
,
notes
=
"批量级联删除评分卡目录"
)
@PostMapping
(
value
=
"/deleteCatalog"
)
public
void
deleteCatalog
(
@RequestParam
List
<
String
>
ids
)
throws
Exception
{
scorecardCatalogService
.
recursionDelete
(
ids
);
}
@ApiOperation
(
value
=
"获取评分卡目录"
,
notes
=
"获取评分卡目录"
)
@PostMapping
(
value
=
"/getCatalog"
)
public
List
<
ScorecardCatalog
>
getCatalog
(
@RequestParam
(
required
=
false
)
String
parentId
,
@RequestParam
List
<
String
>
codes
){
return
scorecardCatalogService
.
getCatalog
(
parentId
,
codes
);
}
@ApiOperation
(
value
=
"新增/修改"
,
notes
=
"新增/修改"
)
@ApiOperation
(
value
=
"新增/修改"
,
notes
=
"新增/修改"
)
@PostMapping
(
value
=
"/saveOrUpdate"
)
@PostMapping
(
value
=
"/saveOrUpdate"
)
...
@@ -44,6 +65,12 @@ public class IndScorecardCtrl {
...
@@ -44,6 +65,12 @@ public class IndScorecardCtrl {
return
indScorecardService
.
getAll
();
return
indScorecardService
.
getAll
();
}
}
@ApiOperation
(
value
=
"根据评分卡目录获取评分卡"
,
notes
=
"根据评分卡目录获取评分卡"
)
@PostMapping
(
value
=
"/getByCatalogId"
)
public
List
<
IndScorecard
>
getByCatalogId
(
@RequestParam
String
catalogId
){
return
indScorecardService
.
getByCatalogId
(
catalogId
);
}
@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
String
id
)
{
...
@@ -58,13 +85,4 @@ public class IndScorecardCtrl {
...
@@ -58,13 +85,4 @@ public class IndScorecardCtrl {
return
indScorecardService
.
calculateIndiScore
(
indId
,
date
,
compareObj
,
return
indScorecardService
.
calculateIndiScore
(
indId
,
date
,
compareObj
,
indScorecardId
,
compareId
,
compareObjs
);
indScorecardId
,
compareId
,
compareObjs
);
}
}
@ApiOperation
(
value
=
"根据单位评分规则计算单位评分"
,
notes
=
"根据单位评分规则计算单位评分"
)
@PostMapping
(
value
=
"/calculateObjectScore"
)
public
List
<
Map
<
String
,
String
>>
calculateObjectScore
(
@RequestParam
String
reportId
,
@RequestParam
String
compareId
,
@RequestParam
List
<
String
>
indIds
,
@RequestParam
List
<
String
>
compareObjs
,
@RequestParam
int
date
,
@RequestParam
String
scoreRuleId
){
return
scoreRuleService
.
calObjScore
(
reportId
,
compareId
,
indIds
,
compareObjs
,
date
,
scoreRuleId
);
};
}
}
src/main/java/com/keymobile/indicators/api/hytobacco/ObjScoreRuleCtrl.java
0 → 100644
View file @
6f24a6d1
package
com
.
keymobile
.
indicators
.
api
.
hytobacco
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.keymobile.indicators.model.entity.objscorerule.ScoreRule
;
import
com.keymobile.indicators.model.entity.objscorerule.ScoreRuleCatalog
;
import
com.keymobile.indicators.service.hytobacco.ScoreRuleCatalogService
;
import
com.keymobile.indicators.service.hytobacco.ScoreRuleService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
@Api
(
tags
={
"单位评分规则CRUD"
})
@RestController
@RequestMapping
(
value
=
"/objScoreRule"
)
public
class
ObjScoreRuleCtrl
{
@Autowired
private
ScoreRuleService
scoreRuleService
;
@Autowired
private
ScoreRuleCatalogService
scoreRuleCatalogService
;
@ApiOperation
(
value
=
"新增/修改单位规则目录"
,
notes
=
"新增/修改单位规则目录"
)
@PostMapping
(
value
=
"/saveOrUpdateCatalog"
)
public
String
saveOrUpdateCatalog
(
@RequestBody
ScoreRuleCatalog
scoreRuleCatalog
)
throws
Exception
{
scoreRuleCatalog
=
scoreRuleCatalogService
.
saveOrUpdate
(
scoreRuleCatalog
);
return
scoreRuleCatalog
.
getId
();
}
@ApiOperation
(
value
=
"批量级联删除单位规则目录"
,
notes
=
"批量级联删除单位规则目录"
)
@PostMapping
(
value
=
"/deleteCatalog"
)
public
void
deleteCatalog
(
@RequestParam
List
<
String
>
ids
)
throws
Exception
{
scoreRuleCatalogService
.
recursionDelete
(
ids
);
}
@ApiOperation
(
value
=
"获取单位规则目录"
,
notes
=
"获取单位规则目录"
)
@PostMapping
(
value
=
"/getCatalog"
)
public
List
<
ScoreRuleCatalog
>
getCatalog
(
@RequestParam
(
required
=
false
)
String
parentId
,
@RequestParam
List
<
String
>
codes
){
return
scoreRuleCatalogService
.
getCatalog
(
parentId
,
codes
);
}
@ApiOperation
(
value
=
"新增/修改"
,
notes
=
"新增/修改"
)
@PostMapping
(
value
=
"/saveOrUpdate"
)
public
String
saveOrUpdate
(
@RequestBody
ScoreRule
scoreRule
)
{
return
scoreRuleService
.
save
(
scoreRule
);
}
@ApiOperation
(
value
=
"删除"
,
notes
=
"删除"
)
@PostMapping
(
value
=
"/delete"
)
public
void
delete
(
@RequestParam
String
id
)
{
scoreRuleService
.
delete
(
id
);
}
@ApiOperation
(
value
=
"根据单位评分规则目录获取单位评分规则"
,
notes
=
"根据单位评分规则目录获取单位评分规则"
)
@PostMapping
(
value
=
"/getByCatalogId"
)
public
List
<
ScoreRule
>
getByCatalogId
(
@RequestParam
String
catalogId
){
return
scoreRuleService
.
getByCatalogId
(
catalogId
);
}
@ApiOperation
(
value
=
"根据id获取单位评分规则"
,
notes
=
"根据id获取单位评分规则"
)
@PostMapping
(
value
=
"/findById"
)
public
ScoreRule
findById
(
@RequestParam
String
id
)
{
return
scoreRuleService
.
getById
(
id
);
}
@ApiOperation
(
value
=
"根据单位评分规则计算单位评分"
,
notes
=
"根据单位评分规则计算单位评分"
)
@PostMapping
(
value
=
"/calculateObjectScore"
)
public
List
<
Map
<
String
,
String
>>
calculateObjectScore
(
@RequestParam
String
reportId
,
@RequestParam
String
compareId
,
@RequestParam
List
<
String
>
indIds
,
@RequestParam
List
<
String
>
compareObjs
,
@RequestParam
int
date
,
@RequestParam
String
scoreRuleId
){
return
scoreRuleService
.
calObjScore
(
reportId
,
compareId
,
indIds
,
compareObjs
,
date
,
scoreRuleId
);
}
}
src/main/java/com/keymobile/indicators/model/entity/objscorerule/ScoreRule.java
View file @
6f24a6d1
...
@@ -28,6 +28,8 @@ public class ScoreRule implements Serializable{
...
@@ -28,6 +28,8 @@ public class ScoreRule implements Serializable{
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
String
catalogIdPath
;
//单位得分计算目录idPath
private
String
code
;
//标识编码
private
String
code
;
//标识编码
public
List
<
IndTypeWeight
>
getIndTypeWeights
(){
public
List
<
IndTypeWeight
>
getIndTypeWeights
(){
...
...
src/main/java/com/keymobile/indicators/model/entity/objscorerule/ScoreRuleCatalog.java
0 → 100644
View file @
6f24a6d1
package
com
.
keymobile
.
indicators
.
model
.
entity
.
objscorerule
;
import
java.io.Serializable
;
import
java.util.Date
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
com.keymobile.indicators.utils.DateUtils
;
import
lombok.Data
;
/**
*author:zhangkb time:2020-6-9 desc:单位评分规则目录实体
*/
@Data
@Document
(
collection
=
"obj_score_rule_catalog"
)
public
class
ScoreRuleCatalog
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
@Id
private
String
id
;
private
String
catalogName
;
private
String
catalogType
;
private
String
parentId
;
//顶层节点parentId为0
private
String
idPath
;
private
String
code
;
//目录编码
private
String
lastUpdater
;
private
String
lastUpdateTime
=
DateUtils
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
);
}
src/main/java/com/keymobile/indicators/model/entity/scorecard/IndScorecard.java
View file @
6f24a6d1
...
@@ -43,6 +43,9 @@ public class IndScorecard implements Serializable{
...
@@ -43,6 +43,9 @@ public class IndScorecard implements Serializable{
private
double
limitScore
;
//上限分数
private
double
limitScore
;
//上限分数
private
List
<
ImproveScoreDef
>
improveScoreItem
=
new
ArrayList
<>();
//改善提升分数
private
List
<
ImproveScoreDef
>
improveScoreItem
=
new
ArrayList
<>();
//改善提升分数
private
String
catalogId
;
//评分卡目录id
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
;
...
...
src/main/java/com/keymobile/indicators/model/entity/scorecard/ScorecardCatalog.java
0 → 100644
View file @
6f24a6d1
package
com
.
keymobile
.
indicators
.
model
.
entity
.
scorecard
;
import
java.io.Serializable
;
import
java.util.Date
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
com.keymobile.indicators.utils.DateUtils
;
import
lombok.Data
;
/**
*author:zhangkb time:2020-6-9 desc:指标评分卡目录实体
*/
@Data
@Document
(
collection
=
"score_card_catalog"
)
public
class
ScorecardCatalog
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
@Id
private
String
id
;
private
String
catalogName
;
private
String
catalogType
;
private
String
parentId
;
//顶层节点parentId为0
private
String
idPath
;
private
String
code
;
//目录编码
private
String
lastUpdater
;
private
String
lastUpdateTime
=
DateUtils
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
);
}
src/main/java/com/keymobile/indicators/persistence/hyindicators/IndScorecardRepository.java
View file @
6f24a6d1
package
com
.
keymobile
.
indicators
.
persistence
.
hyindicators
;
package
com
.
keymobile
.
indicators
.
persistence
.
hyindicators
;
import
java.util.List
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.keymobile.indicators.model.entity.scorecard.IndScorecard
;
import
com.keymobile.indicators.model.entity.scorecard.IndScorecard
;
public
interface
IndScorecardRepository
extends
MongoRepository
<
IndScorecard
,
String
>{
public
interface
IndScorecardRepository
extends
MongoRepository
<
IndScorecard
,
String
>{
public
void
deleteByCatalogIdIn
(
List
<
String
>
catalogIds
);
public
List
<
IndScorecard
>
findByCatalogId
(
String
catalogId
);
}
}
src/main/java/com/keymobile/indicators/persistence/hyindicators/ScoreRuleCatalogRepository.java
0 → 100644
View file @
6f24a6d1
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
);
}
src/main/java/com/keymobile/indicators/persistence/hyindicators/ScoreRuleRepository.java
View file @
6f24a6d1
...
@@ -7,5 +7,9 @@ import org.springframework.data.mongodb.repository.MongoRepository;
...
@@ -7,5 +7,9 @@ import org.springframework.data.mongodb.repository.MongoRepository;
import
com.keymobile.indicators.model.entity.objscorerule.ScoreRule
;
import
com.keymobile.indicators.model.entity.objscorerule.ScoreRule
;
public
interface
ScoreRuleRepository
extends
MongoRepository
<
ScoreRule
,
String
>{
public
interface
ScoreRuleRepository
extends
MongoRepository
<
ScoreRule
,
String
>{
List
<
ScoreRule
>
findByCode
(
String
code
);
public
List
<
ScoreRule
>
findByCode
(
String
code
);
public
void
deleteByCatalogIdIn
(
List
<
String
>
ids
);
public
List
<
ScoreRule
>
findByCatalogId
(
String
catalogId
);
}
}
src/main/java/com/keymobile/indicators/persistence/hyindicators/ScorecardCatalogRepository.java
0 → 100644
View file @
6f24a6d1
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
);
}
src/main/java/com/keymobile/indicators/service/hytobacco/IndScorecardService.java
View file @
6f24a6d1
...
@@ -60,6 +60,10 @@ public class IndScorecardService {
...
@@ -60,6 +60,10 @@ public class IndScorecardService {
return
null
;
return
null
;
}
}
public
List
<
IndScorecard
>
getByCatalogId
(
String
catalogId
){
return
indScorecardRepo
.
findByCatalogId
(
catalogId
);
}
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
{
String
indScorecardId
,
String
compareId
,
List
<
String
>
compareObjs
)
throws
Exception
{
Map
<
String
,
String
>
result
=
new
HashMap
<>();
Map
<
String
,
String
>
result
=
new
HashMap
<>();
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/ScoreRuleCatalogService.java
0 → 100644
View file @
6f24a6d1
package
com
.
keymobile
.
indicators
.
service
.
hytobacco
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.keymobile.indicators.model.entity.objscorerule.ScoreRuleCatalog
;
import
com.keymobile.indicators.persistence.hyindicators.ScoreRuleCatalogRepository
;
import
com.keymobile.indicators.persistence.hyindicators.ScoreRuleRepository
;
@Service
public
class
ScoreRuleCatalogService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
ScoreRuleCatalogService
.
class
);
@Autowired
private
ScoreRuleCatalogRepository
scoreRuleCatalogRepo
;
@Autowired
private
ScoreRuleRepository
scoreRuleRepo
;
public
ScoreRuleCatalog
saveOrUpdate
(
ScoreRuleCatalog
scoreRuleCatalog
)
throws
Exception
{
if
(
StringUtils
.
isBlank
(
scoreRuleCatalog
.
getId
()))
{
//新增
//保存
scoreRuleCatalog
=
scoreRuleCatalogRepo
.
save
(
scoreRuleCatalog
);
}
//获取parentId拼接idPath
String
parentId
=
scoreRuleCatalog
.
getParentId
();
if
(
StringUtils
.
isBlank
(
parentId
)
||
"0"
.
equals
(
parentId
))
{
//顶层节点
scoreRuleCatalog
.
setIdPath
(
scoreRuleCatalog
.
getId
());
}
else
{
Optional
<
ScoreRuleCatalog
>
parentScoreRuleCatalog
=
scoreRuleCatalogRepo
.
findById
(
scoreRuleCatalog
.
getParentId
());
if
(!
parentScoreRuleCatalog
.
isPresent
())
{
throw
new
Exception
(
"父节点不存在:parent catalog is not exist"
);
}
else
{
scoreRuleCatalog
.
setIdPath
(
parentScoreRuleCatalog
.
get
().
getIdPath
()+
";"
+
scoreRuleCatalog
.
getId
());
}
}
//保存
scoreRuleCatalog
=
scoreRuleCatalogRepo
.
save
(
scoreRuleCatalog
);
return
scoreRuleCatalog
;
}
public
void
delete
(
List
<
String
>
ids
)
{
scoreRuleCatalogRepo
.
deleteByIdIn
(
ids
);
}
//递归查找父目录下的子目录
public
List
<
String
>
getDeleteCatalogId
(
String
id
){
List
<
String
>
result
=
new
ArrayList
<>();
result
.
add
(
id
);
//根据id获取子节点
List
<
ScoreRuleCatalog
>
children
=
scoreRuleCatalogRepo
.
findByParentId
(
id
);
if
(!
children
.
isEmpty
())
{
for
(
ScoreRuleCatalog
child
:
children
)
{
result
.
addAll
(
getDeleteCatalogId
(
child
.
getId
()));
}
}
return
result
;
}
//递归删除
public
void
recursionDelete
(
List
<
String
>
ids
)
{
for
(
String
id
:
ids
)
{
List
<
String
>
result
=
this
.
getDeleteCatalogId
(
id
);
this
.
delete
(
result
);
//删除目录关联的单位评分规则
scoreRuleRepo
.
deleteByCatalogIdIn
(
result
);
}
}
//获取目录树
public
List
<
ScoreRuleCatalog
>
getCatalog
(
String
parentId
,
List
<
String
>
codes
){
if
(
StringUtils
.
isBlank
(
parentId
)
||
"0"
.
equals
(
parentId
))
{
return
scoreRuleCatalogRepo
.
findByParentIdAndCodeInOrderByLastUpdateTimeDesc
(
"0"
,
codes
);
}
return
scoreRuleCatalogRepo
.
findByParentIdAndCodeInOrderByLastUpdateTimeDesc
(
parentId
,
codes
);
}
}
src/main/java/com/keymobile/indicators/service/hytobacco/ScoreRuleService.java
View file @
6f24a6d1
...
@@ -50,6 +50,10 @@ public class ScoreRuleService {
...
@@ -50,6 +50,10 @@ public class ScoreRuleService {
return
scoreRuleRepo
.
findByCode
(
code
);
return
scoreRuleRepo
.
findByCode
(
code
);
}
}
public
List
<
ScoreRule
>
getByCatalogId
(
String
catalogId
){
return
scoreRuleRepo
.
findByCatalogId
(
catalogId
);
}
public
ScoreRule
getById
(
String
id
)
{
public
ScoreRule
getById
(
String
id
)
{
Optional
<
ScoreRule
>
scoreRule
=
scoreRuleRepo
.
findById
(
id
);
Optional
<
ScoreRule
>
scoreRule
=
scoreRuleRepo
.
findById
(
id
);
if
(
scoreRule
.
isPresent
())
{
if
(
scoreRule
.
isPresent
())
{
...
@@ -77,7 +81,8 @@ public class ScoreRuleService {
...
@@ -77,7 +81,8 @@ public class ScoreRuleService {
DriveIndDef
driveIndDef
=
driveIndDefMapper
.
selectByPrimaryKey
(
calResult
.
getIndId
());
DriveIndDef
driveIndDef
=
driveIndDefMapper
.
selectByPrimaryKey
(
calResult
.
getIndId
());
if
(
driveIndDef
!=
null
)
{
if
(
driveIndDef
!=
null
)
{
//如果考核指标是参与单位计分的
//如果考核指标是参与单位计分的
if
(
"1"
.
equals
(
driveIndDef
.
getIsUnitCalScore
()))
{
if
(
StringUtils
.
isBlank
(
driveIndDef
.
getIsUnitCalScore
())
||
"1"
.
equals
(
driveIndDef
.
getIsUnitCalScore
()))
{
//得分类型:0 指标值直接参与计算
//得分类型:0 指标值直接参与计算
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
()))
{
if
(
"0"
.
equals
(
scoreRule
.
getScoreType
()))
{
values
.
add
(
calResult
.
getValue
());
values
.
add
(
calResult
.
getValue
());
...
@@ -219,7 +224,8 @@ public class ScoreRuleService {
...
@@ -219,7 +224,8 @@ public class ScoreRuleService {
DriveIndDef
driveIndDef
=
driveIndDefMapper
.
selectByPrimaryKey
(
calResult
.
getIndId
());
DriveIndDef
driveIndDef
=
driveIndDefMapper
.
selectByPrimaryKey
(
calResult
.
getIndId
());
if
(
driveIndDef
!=
null
)
{
if
(
driveIndDef
!=
null
)
{
//如果考核指标是参与单位计分的
//如果考核指标是参与单位计分的
if
(
"1"
.
equals
(
driveIndDef
.
getIsUnitCalScore
()))
{
if
(
StringUtils
.
isBlank
(
driveIndDef
.
getIsUnitCalScore
())
||
"1"
.
equals
(
driveIndDef
.
getIsUnitCalScore
()))
{
//如果指标是该指标分类下的
//如果指标是该指标分类下的
if
(
indTypeWeight
.
getCatalogIdPath
().
indexOf
(
catalogIdPath
)>=
0
)
{
if
(
indTypeWeight
.
getCatalogIdPath
().
indexOf
(
catalogIdPath
)>=
0
)
{
//得分类型:0 指标值直接参与计算
//得分类型:0 指标值直接参与计算
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/ScorecardCatalogService.java
0 → 100644
View file @
6f24a6d1
package
com
.
keymobile
.
indicators
.
service
.
hytobacco
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.keymobile.indicators.model.entity.scorecard.ScorecardCatalog
;
import
com.keymobile.indicators.persistence.hyindicators.IndScorecardRepository
;
import
com.keymobile.indicators.persistence.hyindicators.ScorecardCatalogRepository
;
@Service
public
class
ScorecardCatalogService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
ScorecardCatalogService
.
class
);
@Autowired
private
ScorecardCatalogRepository
scorecardCatalogRepo
;
@Autowired
private
IndScorecardRepository
indScorecardRepo
;
public
ScorecardCatalog
saveOrUpdate
(
ScorecardCatalog
scorecardCatalog
)
throws
Exception
{
if
(
StringUtils
.
isBlank
(
scorecardCatalog
.
getId
()))
{
//新增
//保存
scorecardCatalog
=
scorecardCatalogRepo
.
save
(
scorecardCatalog
);
}
//获取parentId拼接idPath
String
parentId
=
scorecardCatalog
.
getParentId
();
if
(
StringUtils
.
isBlank
(
parentId
)
||
"0"
.
equals
(
parentId
))
{
//顶层节点
scorecardCatalog
.
setIdPath
(
scorecardCatalog
.
getId
());
}
else
{
Optional
<
ScorecardCatalog
>
parentScorecardCatalog
=
scorecardCatalogRepo
.
findById
(
scorecardCatalog
.
getParentId
());
if
(!
parentScorecardCatalog
.
isPresent
())
{
throw
new
Exception
(
"父节点不存在:parent catalog is not exist"
);
}
else
{
scorecardCatalog
.
setIdPath
(
parentScorecardCatalog
.
get
().
getIdPath
()+
";"
+
scorecardCatalog
.
getId
());
}
}
//保存
scorecardCatalog
=
scorecardCatalogRepo
.
save
(
scorecardCatalog
);
return
scorecardCatalog
;
}
public
void
delete
(
List
<
String
>
ids
)
{
scorecardCatalogRepo
.
deleteByIdIn
(
ids
);
}
//递归查找父目录下的子目录
public
List
<
String
>
getDeleteCatalogId
(
String
id
){
List
<
String
>
result
=
new
ArrayList
<>();
result
.
add
(
id
);
//根据id获取子节点
List
<
ScorecardCatalog
>
children
=
scorecardCatalogRepo
.
findByParentId
(
id
);
if
(!
children
.
isEmpty
())
{
for
(
ScorecardCatalog
child
:
children
)
{
result
.
addAll
(
getDeleteCatalogId
(
child
.
getId
()));
}
}
return
result
;
}
//递归删除
public
void
recursionDelete
(
List
<
String
>
ids
)
{
for
(
String
id
:
ids
)
{
List
<
String
>
result
=
this
.
getDeleteCatalogId
(
id
);
this
.
delete
(
result
);
//删除目录关联的评分卡
indScorecardRepo
.
deleteByCatalogIdIn
(
result
);
}
}
//获取目录树
public
List
<
ScorecardCatalog
>
getCatalog
(
String
parentId
,
List
<
String
>
codes
){
if
(
StringUtils
.
isBlank
(
parentId
)
||
"0"
.
equals
(
parentId
))
{
return
scorecardCatalogRepo
.
findByParentIdAndCodeInOrderByLastUpdateTimeDesc
(
"0"
,
codes
);
}
return
scorecardCatalogRepo
.
findByParentIdAndCodeInOrderByLastUpdateTimeDesc
(
parentId
,
codes
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment