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
3543c5b1
Commit
3543c5b1
authored
Aug 03, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加子首页获取特定指标信息接口
parent
b738861d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
144 additions
and
0 deletions
+144
-0
IndexReportCtrl.java
.../com/keymobile/indicators/api/report/IndexReportCtrl.java
+30
-0
DriveIndCalResultDefMapper.java
...rs/model/mapper/indmapper/DriveIndCalResultDefMapper.java
+4
-0
IndexReportService.java
...ymobile/indicators/service/report/IndexReportService.java
+100
-0
DriveIndCalResultDefMapper.xml
.../resources/mybatis/mapping/DriveIndCalResultDefMapper.xml
+10
-0
No files found.
src/main/java/com/keymobile/indicators/api/report/IndexReportCtrl.java
0 → 100644
View file @
3543c5b1
package
com
.
keymobile
.
indicators
.
api
.
report
;
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.service.report.IndexReportService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
@Api
(
tags
={
"子首页-数据接口"
})
@RestController
@RequestMapping
(
value
=
"/indexReport"
)
public
class
IndexReportCtrl
{
@Autowired
private
IndexReportService
indexReportService
;
@ApiOperation
(
value
=
"获取特定指标信息"
,
notes
=
"获取特定指标信息"
)
@PostMapping
(
value
=
"/getIndicatorInfo"
)
public
List
<
Map
<
String
,
Object
>>
dealReportOne
(
@RequestBody
Map
<
String
,
Integer
>
indIdMap
,
@RequestParam
String
compareObj
)
{
return
indexReportService
.
getLatestIndiInfo
(
indIdMap
,
compareObj
);
}
}
src/main/java/com/keymobile/indicators/model/mapper/indmapper/DriveIndCalResultDefMapper.java
View file @
3543c5b1
...
@@ -59,4 +59,8 @@ public interface DriveIndCalResultDefMapper extends BaseMapper<DriveIndCalResult
...
@@ -59,4 +59,8 @@ public interface DriveIndCalResultDefMapper extends BaseMapper<DriveIndCalResult
public
void
batchSave
(
@Param
(
"datas"
)
List
<
DriveIndCalResultDef
>
datas
);
public
void
batchSave
(
@Param
(
"datas"
)
List
<
DriveIndCalResultDef
>
datas
);
//批量修改
//批量修改
public
void
batchUpdate
(
@Param
(
"datas"
)
List
<
DriveIndCalResultDef
>
datas
);
public
void
batchUpdate
(
@Param
(
"datas"
)
List
<
DriveIndCalResultDef
>
datas
);
//根据指标编号和对标单位根据对标时间降序获取指标考核结果
public
List
<
DriveIndCalResultDef
>
findByIndIdAndCompareObjOrderByDateDesc
(
@Param
(
"indId"
)
String
indId
,
@Param
(
"compareObj"
)
String
compareObj
);
}
}
src/main/java/com/keymobile/indicators/service/report/IndexReportService.java
0 → 100644
View file @
3543c5b1
package
com
.
keymobile
.
indicators
.
service
.
report
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndDef
;
import
com.keymobile.indicators.model.mapper.indicators.DriveIndDefMapper
;
import
com.keymobile.indicators.model.mapper.indmapper.DriveIndCalResultDefMapper
;
import
com.keymobile.indicators.utils.CalculateUtils
;
/**
* author:zhangkb time:2020-8-3 desc:提供子首页数据接口服务
*/
@Service
public
class
IndexReportService
{
@Autowired
private
DriveIndCalResultDefMapper
driveIndCalResultDefMapper
;
@Autowired
private
DriveIndDefMapper
driveIndDefMapper
;
//获取省指标信息
public
List
<
Map
<
String
,
Object
>>
getLatestIndiInfo
(
Map
<
String
,
Integer
>
indIdMap
,
String
compareObj
){
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
if
(!
indIdMap
.
isEmpty
())
{
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
indIdMap
.
entrySet
())
{
Map
<
String
,
Object
>
indMap
=
new
HashMap
<>();
//根据指标id获取指标信息
DriveIndDef
driveIndDef
=
driveIndDefMapper
.
selectByPrimaryKey
(
entry
.
getKey
());
if
(
driveIndDef
!=
null
)
{
indMap
.
put
(
"indId"
,
driveIndDef
.
getIndId
());
indMap
.
put
(
"indName"
,
driveIndDef
.
getIndName
());
indMap
.
put
(
"indUnit"
,
driveIndDef
.
getIndUnit
());
//根据指标编号和对标对象获取最新的对标考核数据
List
<
DriveIndCalResultDef
>
calResults
=
driveIndCalResultDefMapper
.
findByIndIdAndCompareObjOrderByDateDesc
(
entry
.
getKey
(),
compareObj
);
int
date
=
0
;
if
(!
calResults
.
isEmpty
())
{
indMap
.
put
(
"value"
,
calResults
.
get
(
0
).
getValue
());
date
=
calResults
.
get
(
0
).
getDate
();
//获取同期值
DriveIndCalResultDef
sameResult
=
driveIndCalResultDefMapper
.
findByIndIdAndDateAndCompareObj
(
entry
.
getKey
(),
date
,
compareObj
);
if
(
sameResult
!=
null
)
{
//获取指标的同比类型以及指标的正反向类型
String
growCalType
=
driveIndDef
.
getGrowCalType
();
String
indRule
=
driveIndDef
.
getIndRule
();
String
rate
=
CalculateUtils
.
calGowth
(
calResults
.
get
(
0
).
getValue
(),
sameResult
.
getValue
(),
growCalType
);
indMap
.
put
(
"rate"
,
rate
);
if
(
StringUtils
.
isNotBlank
(
indRule
)
&&
StringUtils
.
isNotBlank
(
rate
))
{
if
(
"0"
.
equals
(
indRule
))
{
//正向
indMap
.
put
(
"trend"
,
"0"
);
//趋差
if
(
Double
.
parseDouble
(
rate
)>
0
)
{
indMap
.
put
(
"trend"
,
"1"
);
//趋好
}
}
else
{
//反向
indMap
.
put
(
"trend"
,
"0"
);
//趋差
if
(
Double
.
parseDouble
(
rate
)<
0
)
{
indMap
.
put
(
"trend"
,
"1"
);
//趋好
}
}
}
else
{
indMap
.
put
(
"trend"
,
""
);
}
}
else
{
indMap
.
put
(
"rate"
,
""
);
indMap
.
put
(
"trend"
,
""
);
}
}
else
{
indMap
.
put
(
"value"
,
""
);
indMap
.
put
(
"rate"
,
""
);
indMap
.
put
(
"trend"
,
""
);
}
indMap
.
put
(
"index"
,
entry
.
getValue
());
result
.
add
(
indMap
);
}
}
//对list根据map中的index进行排序
Collections
.
sort
(
result
,
new
Comparator
<
Map
<
String
,
Object
>>()
{
@Override
public
int
compare
(
Map
<
String
,
Object
>
o1
,
Map
<
String
,
Object
>
o2
)
{
int
map1value
=
(
Integer
)
o1
.
get
(
"index"
);
int
map2value
=
(
Integer
)
o2
.
get
(
"index"
);
return
map1value
-
map2value
;
}
});
}
return
result
;
}
}
src/main/resources/mybatis/mapping/DriveIndCalResultDefMapper.xml
View file @
3543c5b1
...
@@ -221,4 +221,13 @@
...
@@ -221,4 +221,13 @@
where id = ${val.id}
where id = ${val.id}
</foreach>
</foreach>
</update>
</update>
<select
id=
"findByIndIdAndCompareObjOrderByDateDesc"
resultType=
"com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef"
>
select *
from drive_ind_cal_result_def
where
ind_id=#{indId} and
compare_obj=#{compareObj}
ORDER BY date desc
</select>
</mapper>
</mapper>
\ No newline at end of file
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