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
9853dffb
Commit
9853dffb
authored
Jun 11, 2020
by
zhangkb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将mongodb中的集合换成mysql库表部分代码提交
parent
26a34dbc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
276 additions
and
32 deletions
+276
-32
IndiDataDefCtrl.java
...in/java/com/keymobile/indicators/api/IndiDataDefCtrl.java
+10
-0
IndicatorsValueCtrl.java
...ymobile/indicators/api/hytobacco/IndicatorsValueCtrl.java
+0
-30
DriveIndCalResultDef.java
...icators/model/entity/indicators/DriveIndCalResultDef.java
+53
-0
IndicatorsData.java
...le/indicators/model/entity/indicators/IndicatorsData.java
+26
-0
DriveIndCalResultDefMapper.java
...rs/model/mapper/indmapper/DriveIndCalResultDefMapper.java
+18
-0
IndicatorsDataMapper.java
...dicators/model/mapper/indmapper/IndicatorsDataMapper.java
+14
-0
BaseIndDataService.java
...bile/indicators/service/hytobacco/BaseIndDataService.java
+39
-0
DriveIndCalResultDefService.java
...cators/service/hytobacco/DriveIndCalResultDefService.java
+51
-0
DriveIndCalResultService.java
...ndicators/service/hytobacco/DriveIndCalResultService.java
+5
-0
IndiDataDefService.java
...bile/indicators/service/hytobacco/IndiDataDefService.java
+24
-0
IndicatorsValueService.java
.../indicators/service/hytobacco/IndicatorsValueService.java
+0
-0
BaseIndDefMapper.xml
src/main/resources/mybatis/mapping/BaseIndDefMapper.xml
+1
-1
DriveIndCalResultDefMapper.xml
.../resources/mybatis/mapping/DriveIndCalResultDefMapper.xml
+21
-0
DriveIndDefMapper.xml
src/main/resources/mybatis/mapping/DriveIndDefMapper.xml
+1
-1
IndicatorsDataMapper.xml
src/main/resources/mybatis/mapping/IndicatorsDataMapper.xml
+13
-0
No files found.
src/main/java/com/keymobile/indicators/api/IndiDataDefCtrl.java
0 → 100644
View file @
9853dffb
package
com
.
keymobile
.
indicators
.
api
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
value
=
"/indiDataDef"
)
public
class
IndiDataDefCtrl
{
}
src/main/java/com/keymobile/indicators/api/hytobacco/IndicatorsValueCtrl.java
View file @
9853dffb
package
com
.
keymobile
.
indicators
.
api
.
hytobacco
;
import
java.io.InputStream
;
import
java.util.List
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
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
org.springframework.web.multipart.MultipartFile
;
import
com.keymobile.indicators.service.hytobacco.IndicatorsValueService
;
...
...
@@ -24,33 +21,6 @@ public class IndicatorsValueCtrl {
@Autowired
private
IndicatorsValueService
indicatorsValueService
;
@ApiOperation
(
value
=
"上传解析基础指标数据"
,
notes
=
"上传解析基础指标数据"
)
@PostMapping
(
value
=
"/importIndiValue"
)
public
void
importIndicatorsData
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
Exception
{
try
(
InputStream
is
=
file
.
getInputStream
()){
XSSFWorkbook
xssfWorkbook
=
new
XSSFWorkbook
(
is
);
indicatorsValueService
.
importIndicatorsData
(
xssfWorkbook
);
}
}
@ApiOperation
(
value
=
"上传解析县2020第一季度基础指标数据"
,
notes
=
"上传解析县2020第一季度基础指标数据"
)
@PostMapping
(
value
=
"/importXianOneIndiValue"
)
public
void
importXianOneIndiValue
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
Exception
{
try
(
InputStream
is
=
file
.
getInputStream
()){
XSSFWorkbook
xssfWorkbook
=
new
XSSFWorkbook
(
is
);
indicatorsValueService
.
importXianOneIndicatorsData
(
xssfWorkbook
);
}
}
@ApiOperation
(
value
=
"上传解析市基础指标数据"
,
notes
=
"上传解析市基础指标数据"
)
@PostMapping
(
value
=
"/importShiIndiValue"
)
public
void
importShiIndicatorsData
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
Exception
{
try
(
InputStream
is
=
file
.
getInputStream
()){
XSSFWorkbook
xssfWorkbook
=
new
XSSFWorkbook
(
is
);
indicatorsValueService
.
importShiIndicatorsData
(
xssfWorkbook
);
}
}
@ApiOperation
(
value
=
"填充excel file1数据"
,
notes
=
"填充excel file1数据"
)
@PostMapping
(
value
=
"/fillExcelFileOne"
)
public
void
fillExcelFileOne
(
@RequestBody
List
<
String
>
indIds
,
@RequestParam
int
date
,
...
...
src/main/java/com/keymobile/indicators/model/entity/indicators/DriveIndCalResultDef.java
0 → 100644
View file @
9853dffb
package
com
.
keymobile
.
indicators
.
model
.
entity
.
indicators
;
import
java.util.Date
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
com.keymobile.indicators.utils.DateUtils
;
import
lombok.Data
;
/**
* author:zhangkb time:2020-6-11 desc:考核指标结果表
*/
@Data
@Table
(
name
=
"drive_ind_cal_result_def"
)
public
class
DriveIndCalResultDef
{
@Id
private
Integer
id
;
private
String
compareId
;
private
String
indId
;
private
String
compareObj
;
private
Integer
date
;
private
String
value
;
private
String
unit
;
private
String
type
;
//0:季度 1:年度
private
String
isRight
;
//表示考核指标的值是否计算正常得到的 0:计算有误 1:计算正常
private
String
lastUpdateTime
=
DateUtils
.
formatDate
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
);
private
String
lastUpdater
;
private
String
average
;
//组内平均数
private
Integer
rank
;
//同组排名
private
String
score
;
//指标评分分数
private
String
improveScore
;
//改善提升得分
private
String
actualAverage
;
//实际平均数:用于省对市的操作,如果有全省的基础项数据,直接拿全省的基础项数据算考核指标做为其实际平均值
public
DriveIndCalResultDef
()
{
super
();
}
public
DriveIndCalResultDef
(
String
compareId
,
String
indId
,
String
compareObj
,
int
date
,
String
value
,
String
unit
,
String
type
,
String
isRight
,
String
lastUpdater
)
{
this
.
compareId
=
compareId
;
this
.
indId
=
indId
;
this
.
compareObj
=
compareObj
;
this
.
date
=
date
;
this
.
value
=
value
;
this
.
unit
=
unit
;
this
.
type
=
type
;
this
.
isRight
=
isRight
;
this
.
lastUpdater
=
lastUpdater
;
}
}
src/main/java/com/keymobile/indicators/model/entity/indicators/IndicatorsData.java
0 → 100644
View file @
9853dffb
package
com
.
keymobile
.
indicators
.
model
.
entity
.
indicators
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
lombok.Data
;
/**
* author:zhangkb time:2020-6-11 desc:基础项数据表
*/
@Data
@Table
(
name
=
"indi_data_def"
)
public
class
IndicatorsData
{
@Id
private
Integer
id
;
private
String
indId
;
private
String
indDesc
;
private
String
type
;
private
String
batchNo
;
private
String
dataType
;
private
String
unit
;
private
String
dim1
;
private
Integer
dim2
;
private
String
value
;
}
src/main/java/com/keymobile/indicators/model/mapper/indmapper/DriveIndCalResultDefMapper.java
0 → 100644
View file @
9853dffb
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.DriveIndCalResultDef
;
import
feign.Param
;
import
tk.mybatis.mapper.common.BaseMapper
;
@Mapper
public
interface
DriveIndCalResultDefMapper
extends
BaseMapper
<
DriveIndCalResultDef
>{
public
List
<
DriveIndCalResultDef
>
findByIndId
(
@Param
(
"indId"
)
String
indId
);
public
List
<
DriveIndCalResultDef
>
findByIndIdAndDateIn
(
Map
<
String
,
Object
>
param
);
}
src/main/java/com/keymobile/indicators/model/mapper/indmapper/IndicatorsDataMapper.java
0 → 100644
View file @
9853dffb
package
com
.
keymobile
.
indicators
.
model
.
mapper
.
indmapper
;
import
java.util.Map
;
import
org.apache.ibatis.annotations.Mapper
;
import
com.keymobile.indicators.model.entity.indicators.IndicatorsData
;
import
tk.mybatis.mapper.common.BaseMapper
;
@Mapper
public
interface
IndicatorsDataMapper
extends
BaseMapper
<
IndicatorsData
>{
public
IndicatorsData
getDataByDimension
(
Map
<
String
,
Object
>
param
);
}
src/main/java/com/keymobile/indicators/service/hytobacco/BaseIndDataService.java
View file @
9853dffb
package
com
.
keymobile
.
indicators
.
service
.
hytobacco
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -10,6 +12,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
com.keymobile.indicators.conf.MongoDBConfig
;
import
com.keymobile.indicators.model.entity.indicators.IndicatorsData
;
import
com.mongodb.BasicDBObject
;
import
com.mongodb.DB
;
import
com.mongodb.DBCollection
;
...
...
@@ -26,6 +29,42 @@ public class BaseIndDataService {
@Value
(
"${mongodb.database}"
)
private
String
database
;
public
List
<
IndicatorsData
>
getAllIndData
(){
List
<
IndicatorsData
>
result
=
new
ArrayList
<>();
MongoClient
client
=
mongoDbConfig
.
mongoClient
();
/* 新建数据库实例,有则使用已有的数据库,没有则准别新建 */
DB
dataBase
=
client
.
getDB
(
database
);
/* 新建集合命名为user_info,如果该集合存在,则使用。否则新建 */
DBCollection
collection
=
dataBase
.
getCollection
(
"hy_indi_data"
);
DBObject
query
=
new
BasicDBObject
();
try
(
DBCursor
cursor
=
collection
.
find
(
query
))
{
while
(
cursor
.
hasNext
())
{
DBObject
dbo
=
cursor
.
next
();
IndicatorsData
data
=
new
IndicatorsData
();
data
.
setIndId
(
dbo
.
get
(
"indId"
).
toString
());
data
.
setIndDesc
(
dbo
.
get
(
"indDesc"
).
toString
());
data
.
setType
(
dbo
.
get
(
"type"
).
toString
());
data
.
setBatchNo
(
dbo
.
get
(
"batchNo"
).
toString
());
data
.
setDataType
(
dbo
.
get
(
"dataType"
).
toString
());
data
.
setUnit
(
dbo
.
get
(
"unit"
).
toString
());
data
.
setDim1
(
dbo
.
get
(
"dim1"
).
toString
());
data
.
setDim2
(
Integer
.
parseInt
(
dbo
.
get
(
"dim2"
).
toString
()));
if
(
dbo
.
get
(
"value"
)==
null
||
""
.
equals
(
dbo
.
get
(
"value"
)))
{
data
.
setValue
(
""
);
}
else
{
data
.
setValue
(
dbo
.
get
(
"value"
).
toString
());
}
result
.
add
(
data
);
}
}
client
.
close
();
return
result
;
}
public
List
<
String
>
getIndData
(
String
indId
,
int
date
,
List
<
String
>
compareObjs
){
List
<
String
>
result
=
new
ArrayList
<>();
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/DriveIndCalResultDefService.java
0 → 100644
View file @
9853dffb
package
com
.
keymobile
.
indicators
.
service
.
hytobacco
;
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.mapper.indmapper.DriveIndCalResultDefMapper
;
@Service
public
class
DriveIndCalResultDefService
{
@Autowired
private
DriveIndCalResultDefMapper
driveIndCalResultDefMapper
;
public
int
saveOrUpdate
(
DriveIndCalResultDef
driveIndCalResultDef
)
{
return
driveIndCalResultDefMapper
.
insert
(
driveIndCalResultDef
);
}
public
DriveIndCalResultDef
findById
(
Integer
id
)
{
DriveIndCalResultDef
driveCalResultDef
=
new
DriveIndCalResultDef
();
driveCalResultDef
.
setId
(
id
);
return
driveIndCalResultDefMapper
.
selectOne
(
driveCalResultDef
);
}
// @Autowired
// private DriveIndCalResultService driveIndCalService;
//
// public void moveData() {
// List<DriveIndCalResult> datas = driveIndCalService.findAll();
// for(DriveIndCalResult data : datas) {
// DriveIndCalResultDef def = new DriveIndCalResultDef();
// def.setCompareId(data.getCompareId());
// def.setIndId(data.getIndId());
// def.setCompareObj(data.getCompareObj());
// def.setDate(data.getDate());
// def.setValue(data.getValue());
// def.setUnit(data.getUnit());
// def.setType(data.getType());
// def.setIsRight(data.getIsRight());
// def.setLastUpdateTime(data.getLastUpdateTime());
// def.setLastUpdater(data.getLastUpdater());
// def.setAverage(data.getAverage());
// def.setRank(data.getRank());
// def.setScore(data.getScore());
// def.setImproveScore(data.getImproveScore());
// def.setActualAverage(data.getActualAverage());
// driveIndCalResultDefMapper.insert(def);
// }
// }
}
src/main/java/com/keymobile/indicators/service/hytobacco/DriveIndCalResultService.java
View file @
9853dffb
package
com
.
keymobile
.
indicators
.
service
.
hytobacco
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Optional
;
import
org.slf4j.Logger
;
...
...
@@ -36,6 +37,10 @@ public class DriveIndCalResultService {
return
null
;
}
public
List
<
DriveIndCalResult
>
findAll
(){
return
driveIndCalResultRepo
.
findAll
();
}
public
DriveIndCalResult
findCompareObjInfo
(
String
driveIndId
,
int
date
,
String
compareObj
)
{
Optional
<
DriveIndCalResult
>
resultOp
=
driveIndCalResultRepo
.
findByIndIdAndDateAndCompareObj
(
driveIndId
,
date
,
compareObj
);
...
...
src/main/java/com/keymobile/indicators/service/hytobacco/IndiDataDefService.java
0 → 100644
View file @
9853dffb
package
com
.
keymobile
.
indicators
.
service
.
hytobacco
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.keymobile.indicators.model.entity.indicators.IndicatorsData
;
import
com.keymobile.indicators.model.mapper.indmapper.IndicatorsDataMapper
;
@Service
public
class
IndiDataDefService
{
@Autowired
private
IndicatorsDataMapper
indiDataDefMapper
;
@Autowired
private
BaseIndDataService
baseIndDataService
;
public
void
moveData
()
{
List
<
IndicatorsData
>
datas
=
baseIndDataService
.
getAllIndData
();
for
(
IndicatorsData
record
:
datas
)
{
indiDataDefMapper
.
insert
(
record
);
}
}
}
src/main/java/com/keymobile/indicators/service/hytobacco/IndicatorsValueService.java
View file @
9853dffb
This diff is collapsed.
Click to expand it.
src/main/resources/mybatis/mapping/BaseIndDefMapper.xml
View file @
9853dffb
...
...
@@ -30,7 +30,7 @@
delete
from base_ind_def
where catalog_id in
<foreach
item=
"id"
collection=
"
list
"
open=
"("
close=
")"
separator=
","
>
<foreach
item=
"id"
collection=
"
catalogIds
"
open=
"("
close=
")"
separator=
","
>
#{id}
</foreach>
</delete>
...
...
src/main/resources/mybatis/mapping/DriveIndCalResultDefMapper.xml
0 → 100644
View file @
9853dffb
<?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.DriveIndCalResultDefMapper"
>
<select
id=
"findByIndId"
parameterType=
"string"
resultType=
"com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef"
>
select *
from drive_ind_cal_result_def
where ind_id = #{indId}
</select>
<select
id=
"findByIndIdAndDateIn"
parameterType=
"map"
resultType=
"com.keymobile.indicators.model.entity.indicators.DriveIndCalResultDef"
>
select *
from drive_ind_cal_result_def
where
ind_id = #{indId} and
date in
<foreach
item=
"id"
collection=
"dates"
open=
"("
close=
")"
separator=
","
>
#{id}
</foreach>
</select>
</mapper>
\ No newline at end of file
src/main/resources/mybatis/mapping/DriveIndDefMapper.xml
View file @
9853dffb
...
...
@@ -30,7 +30,7 @@
delete
from drive_ind_def
where catalog_id in
<foreach
item=
"id"
collection=
"
list
"
open=
"("
close=
")"
separator=
","
>
<foreach
item=
"id"
collection=
"
catalogIds
"
open=
"("
close=
")"
separator=
","
>
#{id}
</foreach>
</delete>
...
...
src/main/resources/mybatis/mapping/IndicatorsDataMapper.xml
0 → 100644
View file @
9853dffb
<?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.IndicatorsDataMapper"
>
<select
id=
"getDataByDimension"
parameterType=
"map"
resultType=
"com.keymobile.indicators.model.entity.indicators.IndicatorsData"
>
select *
from indi_data_def
where
ind_id=#{indId} and
dim1 = #{dim1} and
dim2= #{dim2}
</select>
</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