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
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
290 additions
and
341 deletions
+290
-341
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
+14
-309
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
;
package
com
.
keymobile
.
indicators
.
api
.
hytobacco
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.List
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.keymobile.indicators.service.hytobacco.IndicatorsValueService
;
import
com.keymobile.indicators.service.hytobacco.IndicatorsValueService
;
...
@@ -24,33 +21,6 @@ public class IndicatorsValueCtrl {
...
@@ -24,33 +21,6 @@ public class IndicatorsValueCtrl {
@Autowired
@Autowired
private
IndicatorsValueService
indicatorsValueService
;
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数据"
)
@ApiOperation
(
value
=
"填充excel file1数据"
,
notes
=
"填充excel file1数据"
)
@PostMapping
(
value
=
"/fillExcelFileOne"
)
@PostMapping
(
value
=
"/fillExcelFileOne"
)
public
void
fillExcelFileOne
(
@RequestBody
List
<
String
>
indIds
,
@RequestParam
int
date
,
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
;
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.Map
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -10,6 +12,7 @@ import org.springframework.beans.factory.annotation.Value;
...
@@ -10,6 +12,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.keymobile.indicators.conf.MongoDBConfig
;
import
com.keymobile.indicators.conf.MongoDBConfig
;
import
com.keymobile.indicators.model.entity.indicators.IndicatorsData
;
import
com.mongodb.BasicDBObject
;
import
com.mongodb.BasicDBObject
;
import
com.mongodb.DB
;
import
com.mongodb.DB
;
import
com.mongodb.DBCollection
;
import
com.mongodb.DBCollection
;
...
@@ -26,6 +29,42 @@ public class BaseIndDataService {
...
@@ -26,6 +29,42 @@ public class BaseIndDataService {
@Value
(
"${mongodb.database}"
)
@Value
(
"${mongodb.database}"
)
private
String
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
){
public
List
<
String
>
getIndData
(
String
indId
,
int
date
,
List
<
String
>
compareObjs
){
List
<
String
>
result
=
new
ArrayList
<>();
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
;
package
com
.
keymobile
.
indicators
.
service
.
hytobacco
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -36,6 +37,10 @@ public class DriveIndCalResultService {
...
@@ -36,6 +37,10 @@ public class DriveIndCalResultService {
return
null
;
return
null
;
}
}
public
List
<
DriveIndCalResult
>
findAll
(){
return
driveIndCalResultRepo
.
findAll
();
}
public
DriveIndCalResult
findCompareObjInfo
(
String
driveIndId
,
int
date
,
String
compareObj
)
{
public
DriveIndCalResult
findCompareObjInfo
(
String
driveIndId
,
int
date
,
String
compareObj
)
{
Optional
<
DriveIndCalResult
>
resultOp
=
driveIndCalResultRepo
.
findByIndIdAndDateAndCompareObj
(
Optional
<
DriveIndCalResult
>
resultOp
=
driveIndCalResultRepo
.
findByIndIdAndDateAndCompareObj
(
driveIndId
,
date
,
compareObj
);
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
...
@@ -2,7 +2,6 @@ package com.keymobile.indicators.service.hytobacco;
...
@@ -2,7 +2,6 @@ package com.keymobile.indicators.service.hytobacco;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Comparator
;
...
@@ -12,16 +11,10 @@ import java.util.List;
...
@@ -12,16 +11,10 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
java.util.Optional
;
import
java.util.Optional
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.CellStyle
;
import
org.apache.poi.ss.usermodel.CellStyle
;
import
org.apache.poi.ss.usermodel.Font
;
import
org.apache.poi.ss.usermodel.Font
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
...
@@ -32,29 +25,26 @@ import org.springframework.beans.factory.annotation.Value;
...
@@ -32,29 +25,26 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.keymobile.indicators.conf.MongoDBConfig
;
import
com.keymobile.indicators.model.entity.DimValue
;
import
com.keymobile.indicators.model.entity.DimValue
;
import
com.keymobile.indicators.model.entity.DriveIndCalResult
;
import
com.keymobile.indicators.model.entity.DriveIndCalResult
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndDef
;
import
com.keymobile.indicators.model.entity.indicators.DriveIndDef
;
import
com.keymobile.indicators.model.entity.indicators.IndicatorsData
;
import
com.keymobile.indicators.model.mapper.indmapper.IndicatorsDataMapper
;
import
com.keymobile.indicators.persistence.hyindicators.DriveIndCalResultRepository
;
import
com.keymobile.indicators.persistence.hyindicators.DriveIndCalResultRepository
;
import
com.keymobile.indicators.utils.CalculateUtils
;
import
com.keymobile.indicators.utils.CalculateUtils
;
import
com.mongodb.BasicDBObject
;
import
com.mongodb.DB
;
import
com.mongodb.DBCollection
;
import
com.mongodb.DBObject
;
import
com.mongodb.MongoClient
;
@Service
@Service
public
class
IndicatorsValueService
{
public
class
IndicatorsValueService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
IndicatorsValueService
.
class
);
private
Logger
logger
=
LoggerFactory
.
getLogger
(
IndicatorsValueService
.
class
);
@Autowired
@Autowired
private
MongoDBConfig
mongoDbConfig
;
@Autowired
private
DriveIndCalResultRepository
driveIndResultRepo
;
private
DriveIndCalResultRepository
driveIndResultRepo
;
@Autowired
@Autowired
private
DriveIndDefService
driveIndDefService
;
private
DriveIndDefService
driveIndDefService
;
@Autowired
private
IndicatorsDataMapper
indicatorsDataMapper
;
@Value
(
"${mongodb.database}"
)
@Value
(
"${mongodb.database}"
)
private
String
database
;
private
String
database
;
...
@@ -662,311 +652,26 @@ public class IndicatorsValueService {
...
@@ -662,311 +652,26 @@ public class IndicatorsValueService {
}
}
public
Map
<
String
,
Object
>
getIndicatorsValue
(
String
indId
,
List
<
DimValue
>
dimValues
)
{
public
Map
<
String
,
Object
>
getIndicatorsValue
(
String
indId
,
List
<
DimValue
>
dimValues
)
{
MongoClient
client
=
mongoDbConfig
.
mongoClient
();
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
DB
dataBase
=
client
.
getDB
(
database
);
paramMap
.
put
(
"indId"
,
indId
);
DBCollection
collection
=
dataBase
.
getCollection
(
"hy_indi_data"
);
DBObject
query
=
new
BasicDBObject
();
query
.
put
(
"indId"
,
indId
);
for
(
DimValue
dimValue
:
dimValues
)
{
for
(
DimValue
dimValue
:
dimValues
)
{
if
(
"number"
.
equals
(
dimValue
.
getDimvalueType
()))
{
if
(
"number"
.
equals
(
dimValue
.
getDimvalueType
()))
{
query
.
put
(
dimValue
.
getDimName
()
,
Integer
.
parseInt
(
dimValue
.
getDimvalue
().
toString
()));
paramMap
.
put
(
"dim2"
,
Integer
.
parseInt
(
dimValue
.
getDimvalue
().
toString
()));
}
else
{
}
else
{
query
.
put
(
dimValue
.
getDimName
(),
dimValue
.
getDimvalue
());
paramMap
.
put
(
"dim1"
,
dimValue
.
getDimvalue
());
}
}
}
}
IndicatorsData
indicatorsData
=
indicatorsDataMapper
.
getDataByDimension
(
paramMap
);
DBObject
result
=
collection
.
findOne
(
query
);
if
(
indicatorsData
!=
null
)
{
if
(
result
!=
null
)
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
"value"
,
result
.
get
(
"value"
));
resultMap
.
put
(
"value"
,
indicatorsData
.
getValue
(
));
resultMap
.
put
(
"unit"
,
result
.
get
(
"unit"
));
resultMap
.
put
(
"unit"
,
indicatorsData
.
getUnit
(
));
resultMap
.
put
(
"dataType"
,
result
.
get
(
"dataType"
));
resultMap
.
put
(
"dataType"
,
indicatorsData
.
getDataType
(
));
return
resultMap
;
return
resultMap
;
}
}
return
null
;
return
null
;
}
}
public
void
importShiIndicatorsData
(
XSSFWorkbook
xssfWorkbook
)
throws
Exception
{
String
regex
=
"\\((.*?))"
;
Pattern
pattern
=
Pattern
.
compile
(
regex
);
List
<
DBObject
>
datas
=
new
ArrayList
<>();
XSSFSheet
excelSheet
=
xssfWorkbook
.
getSheet
(
"基础表"
);
int
startDataRow
=
0
;
//开始读excel数据的行号
for
(
int
rowNum
=
startDataRow
;
rowNum
<=
excelSheet
.
getLastRowNum
();
rowNum
++)
{
if
(
rowNum
==
0
)
{
for
(
int
i
=
2
;
i
<
32
;
i
=
i
+
2
)
{
String
RegionCellValue
=
this
.
getMergedRegionValue
(
excelSheet
,
rowNum
,
i
);
if
(
StringUtils
.
isNotBlank
(
RegionCellValue
))
{
XSSFRow
xssfRow
=
excelSheet
.
getRow
(
1
);
String
dim2Value1
=
xssfRow
.
getCell
(
i
)==
null
?
""
:
xssfRow
.
getCell
(
i
).
getStringCellValue
();
String
dim2Value2
=
xssfRow
.
getCell
(
i
+
1
)==
null
?
""
:
xssfRow
.
getCell
(
i
+
1
).
getStringCellValue
();
for
(
int
k
=
2
;
k
<
66
;
k
++)
{
XSSFRow
xssfDataRow
=
excelSheet
.
getRow
(
k
);
String
driveIndName
=
xssfDataRow
.
getCell
(
1
).
getStringCellValue
();
if
(
"1-12月"
.
equals
(
driveIndName
))
{
continue
;
}
String
unit
=
""
;
//获取单位
Matcher
matcher
=
pattern
.
matcher
(
driveIndName
);
while
(
matcher
.
find
())
{
unit
=
matcher
.
group
(
1
);
}
if
((
"本期"
.
equals
(
dim2Value1
)
&&
"同期"
.
equals
(
dim2Value2
)))
{
DBObject
doc
=
new
BasicDBObject
();
DBObject
doc1
=
new
BasicDBObject
();
doc
.
put
(
"indId"
,
"S00"
+
k
);
doc1
.
put
(
"indId"
,
"S00"
+
k
);
doc
.
put
(
"indDesc"
,
driveIndName
);
doc1
.
put
(
"indDesc"
,
driveIndName
);
doc
.
put
(
"type"
,
"1"
);
doc1
.
put
(
"type"
,
"1"
);
doc
.
put
(
"batchNo"
,
"B002"
);
doc1
.
put
(
"batchNo"
,
"B002"
);
doc
.
put
(
"dataType"
,
"double"
);
doc1
.
put
(
"dataType"
,
"double"
);
doc
.
put
(
"unit"
,
unit
);
doc1
.
put
(
"unit"
,
unit
);
doc
.
put
(
"dim1"
,
RegionCellValue
);
doc1
.
put
(
"dim1"
,
RegionCellValue
);
if
(
"本期"
.
equals
(
dim2Value1
))
{
doc
.
put
(
"dim2"
,
201912
);
}
if
(
"同期"
.
equals
(
dim2Value2
))
{
doc1
.
put
(
"dim2"
,
201812
);
}
String
indValue1
=
this
.
getCellValue
(
xssfDataRow
,
i
);
String
indValue2
=
this
.
getCellValue
(
xssfDataRow
,
i
+
1
);
doc
.
put
(
"value"
,
indValue1
);
doc1
.
put
(
"value"
,
indValue2
);
datas
.
add
(
doc
);
datas
.
add
(
doc1
);
}
}
}
}
}
break
;
}
//System.out.println(datas);
this
.
addIndicatorData
(
datas
);
}
public
void
importXianOneIndicatorsData
(
XSSFWorkbook
xssfWorkbook
)
throws
Exception
{
Map
<
String
,
String
>
indMappingIndId
=
new
HashMap
<>();
indMappingIndId
.
put
(
"卷烟总销量(箱)"
,
"F002"
);
indMappingIndId
.
put
(
"二类烟销量(箱)"
,
"F004"
);
indMappingIndId
.
put
(
"零售客户进货规格数之和(个)"
,
"F006"
);
indMappingIndId
.
put
(
"零售客户总数(个)"
,
"F008"
);
indMappingIndId
.
put
(
"卷烟销售单箱均价(万元)"
,
"F0010"
);
indMappingIndId
.
put
(
"卷烟营销费用(万元)"
,
"F0016"
);
indMappingIndId
.
put
(
"卷烟管理费用(万元)"
,
"F0018"
);
indMappingIndId
.
put
(
"查获烟叶量(千克)"
,
"F0032"
);
indMappingIndId
.
put
(
"查获烟丝量(千克)"
,
"F0034"
);
indMappingIndId
.
put
(
"查获假私烟量(万支)"
,
"F0036"
);
indMappingIndId
.
put
(
"查获真烟量(万支)"
,
"F0040"
);
indMappingIndId
.
put
(
"查获未当案件卷烟量(万支)"
,
"F0058"
);
indMappingIndId
.
put
(
"专卖线在岗人员数(人)"
,
"F0038"
);
indMappingIndId
.
put
(
"营销线在岗人员数(人)"
,
"F0014"
);
String
regex
=
"\\((.*?))"
;
Pattern
pattern
=
Pattern
.
compile
(
regex
);
List
<
DBObject
>
datas
=
new
ArrayList
<>();
XSSFSheet
excelSheet
=
xssfWorkbook
.
getSheet
(
"县级局对标"
);
int
startDataRow
=
2
;
//开始读excel数据的行号
for
(
int
i
=
2
;
i
<=
28
;
i
=
i
+
2
)
{
String
cellValue
=
this
.
getMergedRegionValue
(
excelSheet
,
startDataRow
,
i
);
if
(
StringUtils
.
isNotBlank
(
cellValue
))
{
List
<
String
>
unitList
=
new
ArrayList
<>();
String
unit
=
""
;
//获取单位
Matcher
matcher
=
pattern
.
matcher
(
cellValue
);
while
(
matcher
.
find
())
{
unitList
.
add
(
matcher
.
group
(
1
));
}
if
(!
unitList
.
isEmpty
())
{
unit
=
unitList
.
get
(
0
);
}
XSSFRow
xssfRow
=
excelSheet
.
getRow
(
3
);
String
dim2Value1
=
xssfRow
.
getCell
(
i
)==
null
?
""
:
xssfRow
.
getCell
(
i
).
getStringCellValue
();
String
dim2Value2
=
xssfRow
.
getCell
(
i
+
1
)==
null
?
""
:
xssfRow
.
getCell
(
i
+
1
).
getStringCellValue
();
if
(
"本期"
.
equals
(
dim2Value1
)
&&
"同期"
.
equals
(
dim2Value2
)){
for
(
int
k
=
4
;
k
<
94
;
k
++)
{
DBObject
doc
=
new
BasicDBObject
();
DBObject
doc1
=
new
BasicDBObject
();
doc
.
put
(
"indId"
,
indMappingIndId
.
get
(
cellValue
));
doc1
.
put
(
"indId"
,
indMappingIndId
.
get
(
cellValue
));
doc
.
put
(
"indDesc"
,
cellValue
);
doc1
.
put
(
"indDesc"
,
cellValue
);
doc
.
put
(
"type"
,
"0"
);
doc1
.
put
(
"type"
,
"0"
);
doc
.
put
(
"batchNo"
,
"B002"
);
doc1
.
put
(
"batchNo"
,
"B002"
);
doc
.
put
(
"dataType"
,
"double"
);
doc1
.
put
(
"dataType"
,
"double"
);
doc
.
put
(
"unit"
,
unit
);
doc1
.
put
(
"unit"
,
unit
);
if
(
"本期"
.
equals
(
dim2Value1
))
{
doc
.
put
(
"dim2"
,
202003
);
}
if
(
"同期"
.
equals
(
dim2Value2
))
{
doc1
.
put
(
"dim2"
,
201903
);
}
XSSFRow
xssfRowRigon
=
excelSheet
.
getRow
(
k
);
String
dim1Value
=
xssfRowRigon
.
getCell
(
1
)==
null
?
""
:
xssfRowRigon
.
getCell
(
1
).
getStringCellValue
();
doc
.
put
(
"dim1"
,
dim1Value
);
doc1
.
put
(
"dim1"
,
dim1Value
);
String
indValue1
=
this
.
getCellValue
(
xssfRowRigon
,
i
);
String
indValue2
=
this
.
getCellValue
(
xssfRowRigon
,
i
+
1
);
doc
.
put
(
"value"
,
indValue1
);
doc1
.
put
(
"value"
,
indValue2
);
datas
.
add
(
doc
);
datas
.
add
(
doc1
);
}
}
}
}
this
.
addIndicatorData
(
datas
);
logger
.
info
(
"导入完成"
);
}
public
void
importIndicatorsData
(
XSSFWorkbook
xssfWorkbook
)
throws
Exception
{
String
regex
=
"\\((.*?))"
;
Pattern
pattern
=
Pattern
.
compile
(
regex
);
List
<
DBObject
>
datas
=
new
ArrayList
<>();
XSSFSheet
excelSheet
=
xssfWorkbook
.
getSheet
(
"原始数据"
);
int
startDataRow
=
1
;
//开始读excel数据的行号
for
(
int
rowNum
=
startDataRow
;
rowNum
<=
excelSheet
.
getLastRowNum
();
rowNum
++)
{
if
(
rowNum
==
1
)
{
for
(
int
i
=
2
;
i
<=
60
;
i
=
i
+
2
)
{
String
cellValue
=
this
.
getMergedRegionValue
(
excelSheet
,
rowNum
,
i
);
if
(
StringUtils
.
isNotBlank
(
cellValue
))
{
List
<
String
>
unitList
=
new
ArrayList
<>();
String
unit
=
""
;
//获取单位
Matcher
matcher
=
pattern
.
matcher
(
cellValue
);
while
(
matcher
.
find
())
{
unitList
.
add
(
matcher
.
group
(
1
));
}
if
(!
unitList
.
isEmpty
()
&&
unitList
.
size
()>=
2
)
{
unit
=
unitList
.
get
(
0
);
}
XSSFRow
xssfRow
=
excelSheet
.
getRow
(
2
);
String
dim2Value1
=
xssfRow
.
getCell
(
i
)==
null
?
""
:
xssfRow
.
getCell
(
i
).
getStringCellValue
();
String
dim2Value2
=
xssfRow
.
getCell
(
i
+
1
)==
null
?
""
:
xssfRow
.
getCell
(
i
+
1
).
getStringCellValue
();
if
((
"本期"
.
equals
(
dim2Value1
)
&&
"同期"
.
equals
(
dim2Value2
))||
(
"本期(专卖处)"
.
equals
(
dim2Value1
)
&&
"同期(人事处)"
.
equals
(
dim2Value2
))||
(
"2018年末"
.
equals
(
dim2Value1
)
&&
"2017年末"
.
equals
(
dim2Value2
)))
{
for
(
int
k
=
3
;
k
<
93
;
k
++)
{
DBObject
doc
=
new
BasicDBObject
();
DBObject
doc1
=
new
BasicDBObject
();
doc
.
put
(
"indId"
,
"F00"
+
i
);
doc1
.
put
(
"indId"
,
"F00"
+
i
);
doc
.
put
(
"indDesc"
,
cellValue
);
doc1
.
put
(
"indDesc"
,
cellValue
);
doc
.
put
(
"type"
,
"1"
);
doc1
.
put
(
"type"
,
"1"
);
doc
.
put
(
"batchNo"
,
"B001"
);
doc1
.
put
(
"batchNo"
,
"B001"
);
doc
.
put
(
"dataType"
,
"double"
);
doc1
.
put
(
"dataType"
,
"double"
);
doc
.
put
(
"unit"
,
unit
);
doc1
.
put
(
"unit"
,
unit
);
if
(
"本期"
.
equals
(
dim2Value1
)||
"本期(专卖处)"
.
equals
(
dim2Value1
)
||
"2018年末"
.
equals
(
dim2Value1
))
{
doc
.
put
(
"dim2"
,
201912
);
}
if
(
"同期"
.
equals
(
dim2Value2
)||
"同期(人事处)"
.
equals
(
dim2Value2
)
||
"2017年末"
.
equals
(
dim2Value2
))
{
doc1
.
put
(
"dim2"
,
201812
);
}
XSSFRow
xssfRowRigon
=
excelSheet
.
getRow
(
k
);
String
dim1Value
=
xssfRowRigon
.
getCell
(
1
)==
null
?
""
:
xssfRowRigon
.
getCell
(
1
).
getStringCellValue
();
doc
.
put
(
"dim1"
,
dim1Value
);
doc1
.
put
(
"dim1"
,
dim1Value
);
String
indValue1
=
this
.
getCellValue
(
xssfRowRigon
,
i
);
String
indValue2
=
this
.
getCellValue
(
xssfRowRigon
,
i
+
1
);
doc
.
put
(
"value"
,
indValue1
);
doc1
.
put
(
"value"
,
indValue2
);
datas
.
add
(
doc
);
datas
.
add
(
doc1
);
}
}
}
}
}
break
;
}
//System.out.println(datas);
this
.
addIndicatorData
(
datas
);
}
private
String
getCellValue
(
Row
row
,
int
column
)
{
String
cellValue
=
null
;
try
{
cellValue
=
row
.
getCell
(
column
)==
null
?
""
:
row
.
getCell
(
column
).
getStringCellValue
();
if
(
"╲"
.
equals
(
cellValue
))
{
cellValue
=
"0"
;
}
}
catch
(
Exception
e
)
{
try
{
cellValue
=
row
.
getCell
(
column
)==
null
?
"0"
:
String
.
format
(
"%.4f"
,
new
BigDecimal
(
row
.
getCell
(
column
).
getNumericCellValue
()));
}
catch
(
Exception
e2
)
{
logger
.
error
(
"error:"
,
e2
);
}
}
return
cellValue
;
}
private
String
getMergedRegionValue
(
Sheet
sheet
,
int
row
,
int
column
){
int
sheetMergeCount
=
sheet
.
getNumMergedRegions
();
for
(
int
i
=
0
;
i
<
sheetMergeCount
;
i
++){
CellRangeAddress
ca
=
sheet
.
getMergedRegion
(
i
);
int
firstColumn
=
ca
.
getFirstColumn
();
int
lastColumn
=
ca
.
getLastColumn
();
int
firstRow
=
ca
.
getFirstRow
();
int
lastRow
=
ca
.
getLastRow
();
if
(
row
>=
firstRow
&&
row
<=
lastRow
){
if
(
column
>=
firstColumn
&&
column
<=
lastColumn
){
Row
fRow
=
sheet
.
getRow
(
firstRow
);
Cell
fCell
=
fRow
.
getCell
(
firstColumn
);
return
fCell
==
null
?
""
:
fCell
.
getStringCellValue
();
}
}
}
return
null
;
}
private
void
addIndicatorData
(
List
<
DBObject
>
datas
)
throws
Exception
{
MongoClient
client
=
mongoDbConfig
.
mongoClient
();
/* 新建数据库实例,有则使用已有的数据库,没有则准别新建 */
DB
dataBase
=
client
.
getDB
(
database
);
/* 新建集合命名为user_info,如果该集合存在,则使用。否则新建 */
DBCollection
collection
=
dataBase
.
getCollection
(
"hy_indi_data"
);
collection
.
insert
(
datas
);
client
.
close
();
}
//计算同期考核指标排名变化
//计算同期考核指标排名变化
private
Map
<
String
,
Integer
>
getSameIndicatorRankChange
(
String
indId
,
int
date
,
String
compareObj
){
private
Map
<
String
,
Integer
>
getSameIndicatorRankChange
(
String
indId
,
int
date
,
String
compareObj
){
Map
<
String
,
Integer
>
result
=
new
HashMap
<>();
Map
<
String
,
Integer
>
result
=
new
HashMap
<>();
...
...
src/main/resources/mybatis/mapping/BaseIndDefMapper.xml
View file @
9853dffb
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
delete
delete
from base_ind_def
from base_ind_def
where catalog_id in
where catalog_id in
<foreach
item=
"id"
collection=
"
list
"
open=
"("
close=
")"
separator=
","
>
<foreach
item=
"id"
collection=
"
catalogIds
"
open=
"("
close=
")"
separator=
","
>
#{id}
#{id}
</foreach>
</foreach>
</delete>
</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 @@
...
@@ -30,7 +30,7 @@
delete
delete
from drive_ind_def
from drive_ind_def
where catalog_id in
where catalog_id in
<foreach
item=
"id"
collection=
"
list
"
open=
"("
close=
")"
separator=
","
>
<foreach
item=
"id"
collection=
"
catalogIds
"
open=
"("
close=
")"
separator=
","
>
#{id}
#{id}
</foreach>
</foreach>
</delete>
</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