Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zhny
Project
Project
Details
Activity
Releases
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
王夏晖
zhny
Commits
6f8f73b2
Commit
6f8f73b2
authored
Apr 13, 2018
by
jichao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用能比较接口
parent
7b11519b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
264 additions
and
35 deletions
+264
-35
OverViewController.java
...soft/business/overview/controller/OverViewController.java
+19
-35
BusProjectAreaStatRepository.java
...t/business/overview/dao/BusProjectAreaStatRepository.java
+24
-0
EnergyCountMRepository.java
...rcisoft/business/overview/dao/EnergyCountMRepository.java
+13
-0
BusProjectAreaStat.java
.../rcisoft/business/overview/entity/BusProjectAreaStat.java
+45
-0
OverViewService.java
...rg/rcisoft/business/overview/service/OverViewService.java
+18
-0
OverViewServiceImpl.java
...t/business/overview/service/impl/OverViewServiceImpl.java
+131
-0
BusProjectAreaStatMapper.xml
...s/mapper/sys/overview.mapper/BusProjectAreaStatMapper.xml
+14
-0
No files found.
src/main/java/org/rcisoft/business/overview/controller/OverViewController.java
View file @
6f8f73b2
...
...
@@ -25,10 +25,6 @@ public class OverViewController {
private
OverViewService
overViewServiceImpl
;
/** --------------用能概况-------------- */
/**
* @param proId 项目主键
* @return
*/
@ApiOperation
(
value
=
"根据项目类型id查询水、电、气24小时的价格"
,
notes
=
"返回水电气三种设备24小时价格"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"项目类型主键"
,
required
=
true
,
dataType
=
"字符串"
)})
@RequestMapping
(
"/getPrice/{proId:\\w+}"
)
...
...
@@ -36,10 +32,6 @@ public class OverViewController {
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
overViewServiceImpl
.
getPrice
(
proId
));
}
/**
* @param proId 项目主键
* @return
*/
@ApiOperation
(
value
=
"用量和费用统计"
,
notes
=
"用量和费用统计"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"项目类型主键"
,
required
=
true
,
dataType
=
"字符串"
)})
@RequestMapping
(
"/getEnergy/{proId:\\w+}"
)
...
...
@@ -47,11 +39,6 @@ public class OverViewController {
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
overViewServiceImpl
.
countAmountAndPrice
(
proId
));
}
/**
* @param proId 项目主键
* @param type 水电气类型,1:水,2:电,3:气
* @return
*/
@ApiOperation
(
value
=
"运行费用统计"
,
notes
=
"运行费用统计"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"项目类型主键"
,
required
=
true
,
dataType
=
"字符串"
),
@ApiImplicitParam
(
name
=
"type"
,
value
=
"水电气类型,1:水,2:电,3:气"
,
required
=
true
,
dataType
=
"数字"
),
...
...
@@ -62,12 +49,6 @@ public class OverViewController {
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
overViewServiceImpl
.
countDailyPrice
(
proId
,
type
,
date
));
}
/**
* @param proId 项目主键
* @param type 水电气类型,1:水,2:电,3:气
* @param date 0:今日,-1:昨日,1:明日
* @return
*/
@ApiOperation
(
value
=
"耗能拆分统计"
,
notes
=
"耗能拆分统计"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"项目类型主键"
,
required
=
true
,
dataType
=
"字符串"
),
@ApiImplicitParam
(
name
=
"type"
,
value
=
"水电气类型,1:水,2:电,3:气"
,
required
=
true
,
dataType
=
"数字"
),
...
...
@@ -78,12 +59,6 @@ public class OverViewController {
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
overViewServiceImpl
.
countEnergySplit
(
proId
,
type
,
date
));
}
/**
* @param proId 项目主键
* @param type 水电气类型,1:水,2:电,3:气
* @param date 0:今日,-1:昨日,1:明日
* @return
*/
@ApiOperation
(
value
=
"运行费用排名"
,
notes
=
"运行费用排名"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"项目类型主键"
,
required
=
true
,
dataType
=
"字符串"
),
@ApiImplicitParam
(
name
=
"type"
,
value
=
"水电气类型,1:水,2:电,3:气"
,
required
=
true
,
dataType
=
"数字"
),
...
...
@@ -98,19 +73,28 @@ public class OverViewController {
@ApiOperation
(
value
=
"建筑单位面积用量标准"
,
notes
=
"水电气的行业标准、建议标准、国家标准"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"项目类型主键"
,
required
=
true
,
dataType
=
"字符串"
)})
@RequestMapping
(
"/getStandard"
)
public
Result
getStandard
(
@
RequestParam
String
proId
)
{
@RequestMapping
(
"/getStandard
/{proId:\\w+}
"
)
public
Result
getStandard
(
@
PathVariable
String
proId
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
overViewServiceImpl
.
getStandard
(
proId
));
}
/**
* @param proId 项目主键
* @return
*/
@ApiOperation
(
value
=
"建筑单位面积用量年度"
,
notes
=
"建筑单位面积用量"
)
@ApiOperation
(
value
=
"建筑单位面积用量年度"
,
notes
=
"建筑单位面积用量年度,三年的数据"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"项目类型主键"
,
required
=
true
,
dataType
=
"字符串"
)})
@RequestMapping
(
"/getUnitArea"
)
public
Result
getUnitArea
(
@RequestParam
String
proId
)
{
return
null
;
@RequestMapping
(
"/getUnitArea/{proId:\\w+}"
)
public
Result
getUnitArea
(
@PathVariable
String
proId
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
overViewServiceImpl
.
getUnitArea
(
proId
));
}
@ApiOperation
(
value
=
"用能比较"
,
notes
=
"返回两组数据"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"项目类型主键"
,
required
=
true
,
dataType
=
"字符串"
),
@ApiImplicitParam
(
name
=
"year"
,
value
=
"年份,如:2018"
,
required
=
true
,
dataType
=
"字符串或数字"
),
@ApiImplicitParam
(
name
=
"month"
,
value
=
"月份,如:6"
,
required
=
true
,
dataType
=
"字符串或数字"
),
@ApiImplicitParam
(
name
=
"type"
,
value
=
"水电气类型,1:水,2:电,3:气"
,
required
=
true
,
dataType
=
"字符串或数字"
),
@ApiImplicitParam
(
name
=
"proId"
,
value
=
"1:同比,2:环比"
,
required
=
true
,
dataType
=
"字符串或数字"
),
})
@RequestMapping
(
"/getEnergyCompare"
)
public
Result
getEnergyCompare
(
@RequestParam
String
proId
,
@RequestParam
String
year
,
@RequestParam
String
month
,
@RequestParam
Integer
type
,
@RequestParam
Integer
cType
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
overViewServiceImpl
.
getEnergyCompare
(
proId
,
year
,
month
,
type
,
cType
));
}
}
src/main/java/org/rcisoft/business/overview/dao/BusProjectAreaStatRepository.java
0 → 100644
View file @
6f8f73b2
package
org
.
rcisoft
.
business
.
overview
.
dao
;
import
org.rcisoft.business.overview.entity.BusProjectAreaStat
;
import
org.rcisoft.core.base.BaseMapper
;
import
org.apache.ibatis.annotations.ResultMap
;
import
org.apache.ibatis.annotations.Select
;
import
org.springframework.stereotype.Repository
;
/**
* Created with on 2018-4-13 15:33:14.
*/
@Repository
public
interface
BusProjectAreaStatRepository
extends
BaseMapper
<
BusProjectAreaStat
>
{
/**
*
* @param busProjectAreaStat
* @return
*/
@Select
(
"<script>select * from bus_project_area_stat where PRO_ID=#{proId} and `YEAR`=#{year}</script>"
)
@ResultMap
(
value
=
"BaseResultMap"
)
BusProjectAreaStat
queryBusProjectAreaStats
(
BusProjectAreaStat
busProjectAreaStat
);
}
src/main/java/org/rcisoft/business/overview/dao/EnergyCountMRepository.java
View file @
6f8f73b2
...
...
@@ -77,4 +77,17 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
@ResultMap
(
"resultMapVo"
)
List
<
EnergyCountMVo
>
getPriceRank
(
EnergyCountMVo
energyCountMVo
);
/**
* 用能比较
* @param energyCountMVo
* @return
*/
@Select
(
"<script>select e.`DAY`,"
+
"<if test=\"type == 1\">sum(e.WATER)</if>"
+
"<if test=\"type == 2\">sum(e.ELEC)</if>"
+
"<if test=\"type == 3\">sum(e.GAS)</if>"
+
" as ENERGY from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} group by e.`DAY`</script>"
)
@ResultMap
(
"resultMapVo"
)
List
<
EnergyCountMVo
>
getEnergyCompare
(
EnergyCountMVo
energyCountMVo
);
}
src/main/java/org/rcisoft/business/overview/entity/BusProjectAreaStat.java
0 → 100644
View file @
6f8f73b2
package
org
.
rcisoft
.
business
.
overview
.
entity
;
import
lombok.*
;
import
org.rcisoft.core.entity.IdNotDataEntity
;
import
javax.persistence.*
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
/**
* Created with on 2018-4-13 15:33:14.
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table
(
name
=
"bus_project_area_stat"
)
public
class
BusProjectAreaStat
implements
Serializable
{
public
BusProjectAreaStat
(
String
year
,
Float
water
,
Float
elec
,
Float
gas
)
{
this
.
year
=
year
;
this
.
water
=
water
;
this
.
elec
=
elec
;
this
.
gas
=
gas
;
}
@Id
private
Integer
id
;
private
String
proId
;
private
String
year
;
private
Float
water
;
private
Float
elec
;
private
Float
gas
;
}
src/main/java/org/rcisoft/business/overview/service/OverViewService.java
View file @
6f8f73b2
...
...
@@ -57,4 +57,22 @@ public interface OverViewService {
*/
Map
<
String
,
Object
>
getStandard
(
String
proId
);
/**
* 建筑单位面积用量年度,三年的数据
* @param proId
* @return
*/
Map
<
String
,
Object
>
getUnitArea
(
String
proId
);
/**
* 用能比较
* @param proId
* @param year
* @param month
* @param type
* @param cType
* @return
*/
Map
<
String
,
Object
>
getEnergyCompare
(
String
proId
,
String
year
,
String
month
,
Integer
type
,
Integer
cType
);
}
src/main/java/org/rcisoft/business/overview/service/impl/OverViewServiceImpl.java
View file @
6f8f73b2
...
...
@@ -3,9 +3,11 @@ package org.rcisoft.business.overview.service.impl;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.rcisoft.business.overview.dao.BusProjectAreaRepository
;
import
org.rcisoft.business.overview.dao.BusProjectAreaStatRepository
;
import
org.rcisoft.business.overview.dao.EnergyCountMRepository
;
import
org.rcisoft.business.overview.dao.EnergyPriceRepository
;
import
org.rcisoft.business.overview.entity.BusProjectArea
;
import
org.rcisoft.business.overview.entity.BusProjectAreaStat
;
import
org.rcisoft.business.overview.entity.EnergyCountM
;
import
org.rcisoft.business.overview.entity.EnergyPrice
;
import
org.rcisoft.business.overview.service.OverViewService
;
...
...
@@ -28,6 +30,8 @@ public class OverViewServiceImpl implements OverViewService {
private
EnergyCountMRepository
energyCountMRepository
;
@Autowired
private
BusProjectAreaRepository
busProjectAreaRepository
;
@Autowired
private
BusProjectAreaStatRepository
busProjectAreaStatRepository
;
private
Calendar
getBeforeDay
(
Calendar
cl
,
int
time
){
int
day
=
cl
.
get
(
Calendar
.
DATE
);
...
...
@@ -46,6 +50,30 @@ public class OverViewServiceImpl implements OverViewService {
return
result
;
}
private
Map
<
String
,
String
>
getTime
(
String
year
,
String
month
,
String
day
,
int
yearVar
,
int
monthVar
,
int
dayVar
){
Calendar
calendar
=
Calendar
.
getInstance
();
if
(
year
!=
null
){
calendar
.
set
(
Calendar
.
YEAR
,
Integer
.
parseInt
(
year
)
+
yearVar
);
}
if
(
month
!=
null
){
calendar
.
set
(
Calendar
.
MONTH
,
Integer
.
parseInt
(
month
)
-
1
+
monthVar
);
}
if
(
day
!=
null
){
calendar
.
set
(
Calendar
.
DATE
,
Integer
.
parseInt
(
day
)
+
dayVar
);
}
Map
<
String
,
String
>
result
=
new
HashMap
<
String
,
String
>();
result
.
put
(
"year"
,
String
.
valueOf
(
calendar
.
get
(
Calendar
.
YEAR
)));
result
.
put
(
"month"
,
String
.
valueOf
(
calendar
.
get
(
Calendar
.
MONTH
)
+
1
));
result
.
put
(
"day"
,
String
.
valueOf
(
calendar
.
get
(
Calendar
.
DAY_OF_MONTH
)));
return
result
;
}
public
static
void
main
(
String
[]
args
){
OverViewServiceImpl
o
=
new
OverViewServiceImpl
();
Map
<
String
,
String
>
time
=
o
.
getTime
(
"2016"
,
"2"
,
"29"
,
2
,
0
,
0
);
System
.
out
.
println
(
time
.
get
(
"year"
)
+
"-"
+
time
.
get
(
"month"
)
+
"-"
+
time
.
get
(
"day"
));
}
private
String
getType
(
String
type
)
{
switch
(
type
)
{
case
"1"
:
//水
...
...
@@ -156,4 +184,107 @@ public class OverViewServiceImpl implements OverViewService {
}
return
result
;
}
@Override
public
Map
<
String
,
Object
>
getUnitArea
(
String
proId
)
{
String
thisY
=
getTime
(
0
).
get
(
"year"
);
int
i
=
Integer
.
parseInt
(
thisY
);
String
lastY
=
String
.
valueOf
(
i
-
1
);
String
beforeY
=
String
.
valueOf
(
i
-
2
);
BusProjectAreaStat
b
=
new
BusProjectAreaStat
();
b
.
setProId
(
proId
);
//查询当年
b
.
setYear
(
thisY
);
BusProjectAreaStat
thisBus
=
busProjectAreaStatRepository
.
queryBusProjectAreaStats
(
b
);
//查询去年
b
.
setYear
(
lastY
);
BusProjectAreaStat
lastBus
=
busProjectAreaStatRepository
.
queryBusProjectAreaStats
(
b
);
//查询前年
b
.
setYear
(
beforeY
);
BusProjectAreaStat
beforeBus
=
busProjectAreaStatRepository
.
queryBusProjectAreaStats
(
b
);
//返回结果
Map
<
String
,
Object
>
result
=
new
HashMap
<
String
,
Object
>();
if
(
beforeBus
==
null
)
{
beforeBus
=
new
BusProjectAreaStat
(
beforeY
,
0
f
,
0
f
,
0
f
);
}
if
(
lastBus
==
null
)
{
lastBus
=
new
BusProjectAreaStat
(
beforeY
,
0
f
,
0
f
,
0
f
);
}
if
(
thisBus
==
null
)
{
thisBus
=
lastBus
;
}
result
.
put
(
"thisY"
,
thisBus
);
result
.
put
(
"lastY"
,
lastBus
);
result
.
put
(
"beforeY"
,
beforeBus
);
return
result
;
}
@Override
public
Map
<
String
,
Object
>
getEnergyCompare
(
String
proId
,
String
year
,
String
month
,
Integer
type
,
Integer
cType
)
{
//返回值
Map
<
String
,
Object
>
result
=
new
HashMap
<
String
,
Object
>();
//添加当前年月
result
.
put
(
"year"
,
year
);
result
.
put
(
"month"
,
month
);
EnergyCountMVo
e
=
new
EnergyCountMVo
();
e
.
setProId
(
proId
);
e
.
setType
(
type
);
e
.
setYear
(
year
);
e
.
setMon
(
month
);
//查找现在的数据
List
<
EnergyCountMVo
>
nowCompare
=
energyCountMRepository
.
getEnergyCompare
(
e
);
//现在数据最后返回的对象
List
<
Float
>
nowReturn
=
this
.
getFloatList
(
nowCompare
);
//查找需要比较的数据
Map
<
String
,
String
>
time
=
null
;
//同比,环比,确定时间
if
(
cType
==
1
){
//同比
time
=
this
.
getTime
(
year
,
month
,
null
,
-
1
,
0
,
0
);
}
else
{
//环比
time
=
this
.
getTime
(
year
,
month
,
null
,
0
,
-
1
,
0
);
}
//新的时间
String
c_year
=
time
.
get
(
"year"
);
String
c_month
=
time
.
get
(
"month"
);
e
.
setYear
(
c_year
);
e
.
setMon
(
c_month
);
//添加当前年月
result
.
put
(
"cYear"
,
c_year
);
result
.
put
(
"cMonth"
,
c_month
);
List
<
EnergyCountMVo
>
lastCompare
=
energyCountMRepository
.
getEnergyCompare
(
e
);
List
<
Float
>
lastReturn
=
this
.
getFloatList
(
lastCompare
);
//差值
List
<
Float
>
diffReturn
=
new
ArrayList
<
Float
>();
for
(
int
i
=
0
;
i
<
nowReturn
.
size
();
i
++)
{
diffReturn
.
add
(
nowReturn
.
get
(
i
)
-
lastReturn
.
get
(
i
));
}
//数据值
result
.
put
(
"nData"
,
nowReturn
);
result
.
put
(
"cData"
,
lastReturn
);
result
.
put
(
"dData"
,
diffReturn
);
return
result
;
}
private
List
<
Float
>
getFloatList
(
List
<
EnergyCountMVo
>
list
){
List
<
Float
>
resultList
=
new
ArrayList
<
Float
>();
if
(
list
!=
null
&&
list
.
size
()
>
0
){
int
size
=
list
.
size
();
Integer
start
=
Integer
.
parseInt
(
list
.
get
(
0
).
getDay
());
Integer
end
=
Integer
.
parseInt
(
list
.
get
(
size
-
1
).
getDay
());
for
(
int
i
=
1
;
i
<
start
;
i
++)
{
resultList
.
add
(
0
f
);
}
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
resultList
.
add
(
list
.
get
(
i
).
getEnergy
());
}
for
(
int
i
=
end
;
i
<
31
;
i
++)
{
resultList
.
add
(
0
f
);
}
}
else
{
for
(
int
i
=
0
;
i
<
31
;
i
++)
{
resultList
.
add
(
0
f
);
}
}
return
resultList
;
}
}
src/main/resources/mapper/sys/overview.mapper/BusProjectAreaStatMapper.xml
0 → 100644
View file @
6f8f73b2
<?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=
"org.rcisoft.business.overview.dao.BusProjectAreaStatRepository"
>
<resultMap
id=
"BaseResultMap"
type=
"org.rcisoft.business.overview.entity.BusProjectAreaStat"
>
<id
column=
"ID"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"PRO_ID"
jdbcType=
"VARCHAR"
property=
"proId"
/>
<result
column=
"YEAR"
jdbcType=
"VARCHAR"
property=
"year"
/>
<result
column=
"WATER"
jdbcType=
"FLOAT"
property=
"water"
/>
<result
column=
"ELEC"
jdbcType=
"FLOAT"
property=
"elec"
/>
<result
column=
"GAS"
jdbcType=
"FLOAT"
property=
"gas"
/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</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