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
59174d28
Commit
59174d28
authored
May 17, 2018
by
王夏晖
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目能耗价格后台维护
parent
a5caa609
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
301 additions
and
17 deletions
+301
-17
EnergyPriceController.java
...oft/business/manage/controller/EnergyPriceController.java
+44
-0
EnergyPriceService.java
...g/rcisoft/business/manage/service/EnergyPriceService.java
+39
-0
BusProjectServiceImpl.java
...t/business/manage/service/impl/BusProjectServiceImpl.java
+47
-2
EnergyPriceServiceImpl.java
.../business/manage/service/impl/EnergyPriceServiceImpl.java
+106
-0
EnergyPriceList.java
.../java/org/rcisoft/business/manage/vo/EnergyPriceList.java
+15
-0
EnergyPriceVo.java
...in/java/org/rcisoft/business/manage/vo/EnergyPriceVo.java
+29
-0
EnergyPriceRepository.java
.../rcisoft/business/overview/dao/EnergyPriceRepository.java
+14
-5
OverViewService.java
...rg/rcisoft/business/overview/service/OverViewService.java
+1
-1
OverViewServiceImpl.java
...t/business/overview/service/impl/OverViewServiceImpl.java
+2
-5
EnergyPriceMapper.xml
...esources/mapper/sys/overview.mapper/EnergyPriceMapper.xml
+4
-4
No files found.
src/main/java/org/rcisoft/business/manage/controller/EnergyPriceController.java
0 → 100644
View file @
59174d28
package
org
.
rcisoft
.
business
.
manage
.
controller
;
/*固定导入*/
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.rcisoft.business.manage.service.EnergyPriceService
;
import
org.rcisoft.business.manage.vo.EnergyPriceList
;
import
org.rcisoft.business.overview.entity.EnergyPrice
;
import
org.rcisoft.core.controller.PaginationController
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.Result
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Map
;
/**
* Created by on 2018-5-16 14:34:55.
*/
@RestController
@RequestMapping
(
"energyprice"
)
public
class
EnergyPriceController
extends
PaginationController
<
EnergyPrice
>
{
@Autowired
private
EnergyPriceService
energyPriceServiceImpl
;
@ApiOperation
(
value
=
"修改"
,
notes
=
"修改"
)
@PutMapping
(
"/update"
)
public
Result
update
(
@RequestBody
EnergyPriceList
energyPriceList
)
{
PersistModel
data
=
energyPriceServiceImpl
.
merge
(
energyPriceList
);
return
Result
.
builder
(
data
);
}
@ApiOperation
(
value
=
"查看"
,
notes
=
"查看"
)
@GetMapping
(
value
=
"/queryEnergyPrice"
)
public
Map
<
String
,
Object
>
queryEnergyPrice
(
@RequestParam
String
proId
)
{
return
energyPriceServiceImpl
.
queryEnergyPrice
(
proId
);
}
}
src/main/java/org/rcisoft/business/manage/service/EnergyPriceService.java
0 → 100644
View file @
59174d28
package
org
.
rcisoft
.
business
.
manage
.
service
;
import
org.rcisoft.business.manage.vo.EnergyPriceList
;
import
org.rcisoft.core.model.PersistModel
;
import
java.util.Map
;
/**
* Created by on 2018-5-16 14:34:55.
*/
public
interface
EnergyPriceService
{
/**
* 保存
* @return
*/
PersistModel
save
(
EnergyPriceList
energyPriceList
);
/**
* 删除
* @return
*/
PersistModel
delete
(
String
proId
);
/**
* 修改
* @return
*/
PersistModel
merge
(
EnergyPriceList
energyPriceList
);
/**
* @return
*/
Map
<
String
,
Object
>
queryEnergyPrice
(
String
proId
);
}
src/main/java/org/rcisoft/business/manage/service/impl/BusProjectServiceImpl.java
View file @
59174d28
...
...
@@ -4,9 +4,13 @@ import lombok.extern.slf4j.Slf4j;
import
org.rcisoft.business.manage.entity.BusProject
;
import
org.rcisoft.business.manage.service.BusProjectAreaService
;
import
org.rcisoft.business.manage.service.BusProjectService
;
import
org.rcisoft.business.manage.service.EnergyPriceService
;
import
org.rcisoft.business.manage.vo.BusProjectAreaList
;
import
org.rcisoft.business.manage.vo.EnergyPriceList
;
import
org.rcisoft.business.manage.vo.EnergyPriceVo
;
import
org.rcisoft.business.overview.dao.BusProjectRepository
;
import
org.rcisoft.business.overview.entity.BusProjectArea
;
import
org.rcisoft.business.overview.entity.EnergyPrice
;
import
org.rcisoft.core.aop.PageUtil
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.business.manage.dao.ProjectRepository
;
...
...
@@ -33,6 +37,8 @@ public class BusProjectServiceImpl implements BusProjectService {
private
BusProjectRepository
busProjectRepository
;
@Autowired
private
BusProjectAreaService
busProjectAreaService
;
@Autowired
private
EnergyPriceService
energyPriceService
;
/**
...
...
@@ -75,7 +81,38 @@ public class BusProjectServiceImpl implements BusProjectService {
a3
.
setType
(
"3"
);
list
.
add
(
a3
);
busProjectAreaList
.
setBusProjectAreaList
(
list
);
return
busProjectAreaService
.
save
(
busProjectAreaList
);
PersistModel
areaP
=
busProjectAreaService
.
save
(
busProjectAreaList
);
//能耗价格
EnergyPriceList
energyPriceList
=
new
EnergyPriceList
();
List
<
EnergyPriceVo
>
plist
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
24
;
i
++){
EnergyPriceVo
ep_water
=
new
EnergyPriceVo
();
ep_water
.
setId
(
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
));
ep_water
.
setProId
(
busProject
.
getJwnum
());
ep_water
.
setPriceHour
(
String
.
valueOf
(
i
));
ep_water
.
setPriceTp
(
"1"
);
EnergyPriceVo
ep_power
=
new
EnergyPriceVo
();
ep_power
.
setId
(
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
));
ep_power
.
setProId
(
busProject
.
getJwnum
());
ep_power
.
setPriceHour
(
String
.
valueOf
(
i
));
ep_power
.
setPriceTp
(
"2"
);
EnergyPriceVo
ep_gas
=
new
EnergyPriceVo
();
ep_gas
.
setId
(
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
));
ep_gas
.
setProId
(
busProject
.
getJwnum
());
ep_gas
.
setPriceHour
(
String
.
valueOf
(
i
));
ep_gas
.
setPriceTp
(
"3"
);
plist
.
add
(
ep_water
);
plist
.
add
(
ep_power
);
plist
.
add
(
ep_gas
);
}
energyPriceList
.
setEnergyPriceList
(
plist
);
PersistModel
priceP
=
energyPriceService
.
save
(
energyPriceList
);
if
(!
areaP
.
isSuccessBySinglePersist
()){
return
areaP
;
}
if
(!
priceP
.
isSuccessBySinglePersist
()){
return
priceP
;
}
}
return
new
PersistModel
(
line
);
}
...
...
@@ -103,6 +140,7 @@ public class BusProjectServiceImpl implements BusProjectService {
return
new
PersistModel
(
line
,
message
);
}
@Transactional
@Override
public
PersistModel
delete
(
BusProject
busProject
)
{
int
line
=
0
;
...
...
@@ -123,7 +161,14 @@ public class BusProjectServiceImpl implements BusProjectService {
message
=
"ID为空,删除失败"
;
}
if
(
line
>
0
){
return
busProjectAreaService
.
delete
(
busProject
.
getProId
());
PersistModel
areaP
=
busProjectAreaService
.
delete
(
busProject
.
getProId
());
PersistModel
priceP
=
energyPriceService
.
delete
(
busProject
.
getProId
());
if
(!
areaP
.
isSuccessBySinglePersist
()){
return
areaP
;
}
if
(!
priceP
.
isSuccessBySinglePersist
()){
return
priceP
;
}
}
return
new
PersistModel
(
line
,
message
);
}
...
...
src/main/java/org/rcisoft/business/manage/service/impl/EnergyPriceServiceImpl.java
0 → 100644
View file @
59174d28
package
org
.
rcisoft
.
business
.
manage
.
service
.
impl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.rcisoft.business.manage.service.EnergyPriceService
;
import
org.rcisoft.business.manage.vo.EnergyPriceList
;
import
org.rcisoft.business.manage.vo.EnergyPriceVo
;
import
org.rcisoft.business.overview.dao.EnergyPriceRepository
;
import
org.rcisoft.business.overview.entity.EnergyPrice
;
import
org.rcisoft.core.model.PersistModel
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
tk.mybatis.mapper.entity.Example
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* Created by on 2018-5-16 14:34:55.
*/
@Service
@Transactional
(
readOnly
=
true
,
propagation
=
Propagation
.
NOT_SUPPORTED
)
@Slf4j
public
class
EnergyPriceServiceImpl
implements
EnergyPriceService
{
@Autowired
private
EnergyPriceRepository
energyPriceRepository
;
/**
* 批量新增,新建项目时执行
* @param energyPriceList
* @return
*/
@Transactional
@Override
public
PersistModel
save
(
EnergyPriceList
energyPriceList
)
{
int
line
=
0
;
List
<
EnergyPriceVo
>
list
=
energyPriceList
.
getEnergyPriceList
();
for
(
EnergyPriceVo
energyPriceVo
:
list
){
line
=
energyPriceRepository
.
insertSelective
(
energyPriceVo
);
}
return
new
PersistModel
(
line
);
}
@Override
public
PersistModel
delete
(
String
proId
)
{
int
line
=
0
;
String
message
=
""
;
Example
example
=
new
Example
(
EnergyPriceVo
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andEqualTo
(
"proId"
,
proId
);
if
(
proId
!=
null
&&
!
proId
.
equals
(
""
)){
line
=
energyPriceRepository
.
deleteByExample
(
example
);
}
else
{
line
=
0
;
message
=
"项目ID为空,删除失败"
;
}
return
new
PersistModel
(
line
,
message
);
}
@Transactional
@Override
public
PersistModel
merge
(
EnergyPriceList
energyPriceList
)
{
int
line
=
1
;
String
message
=
""
;
List
<
EnergyPriceVo
>
list
=
energyPriceList
.
getEnergyPriceList
();
for
(
EnergyPriceVo
energyPriceVo
:
list
){
Example
example
=
new
Example
(
EnergyPriceVo
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andEqualTo
(
"id"
,
energyPriceVo
.
getId
());
if
(
energyPriceVo
.
getId
()!=
null
&&
!
energyPriceVo
.
getId
().
equals
(
""
)){
line
=
energyPriceRepository
.
updateByExampleSelective
(
energyPriceVo
,
example
);
}
else
{
message
=
"ID为空,更新失败"
;
line
=
0
;
return
new
PersistModel
(
line
,
message
);
}
}
return
new
PersistModel
(
line
,
message
);
}
@Override
public
Map
<
String
,
Object
>
queryEnergyPrice
(
String
proId
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
List
<
Map
<
String
,
Object
>>
list
=
energyPriceRepository
.
queryEnergyPrice
(
proId
);
Map
<
String
,
Object
>
water_map
=
new
HashMap
<>();
Map
<
String
,
Object
>
power_map
=
new
HashMap
<>();
Map
<
String
,
Object
>
gas_map
=
new
HashMap
<>();
for
(
Map
<
String
,
Object
>
mp
:
list
){
if
(
mp
.
get
(
"P_TP"
)!=
null
&&
mp
.
get
(
"P_TP"
).
toString
().
equals
(
"1"
)){
water_map
.
put
(
mp
.
get
(
"P_HOUR"
).
toString
(),
mp
.
get
(
"P_PRICE"
));
}
else
if
(
mp
.
get
(
"P_TP"
)!=
null
&&
mp
.
get
(
"P_TP"
).
toString
().
equals
(
"2"
)){
power_map
.
put
(
mp
.
get
(
"P_HOUR"
).
toString
(),
mp
.
get
(
"P_PRICE"
));
}
else
if
(
mp
.
get
(
"P_TP"
)!=
null
&&
mp
.
get
(
"P_TP"
).
toString
().
equals
(
"3"
)){
gas_map
.
put
(
mp
.
get
(
"P_HOUR"
).
toString
(),
mp
.
get
(
"P_PRICE"
));
}
}
result
.
put
(
"water"
,
water_map
);
result
.
put
(
"power"
,
power_map
);
result
.
put
(
"gas"
,
gas_map
);
return
result
;
}
}
src/main/java/org/rcisoft/business/manage/vo/EnergyPriceList.java
0 → 100644
View file @
59174d28
package
org
.
rcisoft
.
business
.
manage
.
vo
;
import
java.util.List
;
public
class
EnergyPriceList
{
private
List
<
EnergyPriceVo
>
energyPriceList
;
public
List
<
EnergyPriceVo
>
getEnergyPriceList
()
{
return
energyPriceList
;
}
public
void
setEnergyPriceList
(
List
<
EnergyPriceVo
>
energyPriceList
)
{
this
.
energyPriceList
=
energyPriceList
;
}
}
src/main/java/org/rcisoft/business/manage/vo/EnergyPriceVo.java
0 → 100644
View file @
59174d28
package
org
.
rcisoft
.
business
.
manage
.
vo
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.math.BigDecimal
;
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table
(
name
=
"energy_price"
)
public
class
EnergyPriceVo
{
@Id
private
String
id
;
@Column
(
name
=
"pro_id"
)
private
String
proId
;
@Column
(
name
=
"p_hour"
)
private
String
priceHour
;
@Column
(
name
=
"p_price"
)
private
BigDecimal
pricePrice
;
@Column
(
name
=
"p_tp"
)
private
String
priceTp
;
}
src/main/java/org/rcisoft/business/overview/dao/EnergyPriceRepository.java
View file @
59174d28
package
org
.
rcisoft
.
business
.
overview
.
dao
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.ResultMap
;
import
org.apache.ibatis.annotations.Select
;
import
org.rcisoft.business.overview.entity.EnergyPrice
;
import
org.rcisoft.business.overview.vo.EnergyPriceVo
;
import
org.rcisoft.business.manage.vo.EnergyPriceVo
;
import
org.rcisoft.core.base.BaseMapper
;
import
org.springframework.stereotype.Repository
;
import
java.util.List
;
import
java.util.Map
;
/**
* Created by JiChao on 2018/4/11.
* 概览
*/
@Repository
public
interface
EnergyPriceRepository
extends
BaseMapper
<
EnergyPrice
>
{
public
interface
EnergyPriceRepository
extends
BaseMapper
<
EnergyPrice
Vo
>
{
/**
* 根据项目id搜索水电气价格列表
* @param
energyPrice
proId:项目id,pHour:小时
* @param proId:项目id,pHour:小时
* @return
*/
@Select
(
"<script>select e.P_HOUR,SUM(IF(e.P_TP=1, e.P_PRICE, 0)) as WATER,SUM(IF(e.P_TP=2, e.P_PRICE, 0)) as ELEC,SUM(IF(e.P_TP=3, e.P_PRICE, 0)) as GAS from energy_price e where e.PRO_ID=#{proId} and e.P_HOUR=#{pHour}</script>"
)
@ResultMap
(
"vo"
)
EnergyPriceVo
getPrice
(
EnergyPrice
energyPrice
);
EnergyPriceVo
getPrice
(
@Param
(
"proId"
)
String
proId
,
@Param
(
"pHour"
)
String
pHour
);
/**
* 查询项目能耗价格
* @param proId
* @return
*/
@Select
(
"<script>select * from energy_price where pro_id = #{proId}</script>"
)
List
<
Map
<
String
,
Object
>>
queryEnergyPrice
(
@Param
(
"proId"
)
String
proId
);
}
src/main/java/org/rcisoft/business/overview/service/OverViewService.java
View file @
59174d28
package
org
.
rcisoft
.
business
.
overview
.
service
;
import
org.rcisoft.business.manage.vo.EnergyPriceVo
;
import
org.rcisoft.business.overview.entity.EnergyEmissionTotal
;
import
org.rcisoft.business.overview.vo.EnergyCountMVo
;
import
org.rcisoft.business.overview.vo.EnergyPriceVo
;
import
org.rcisoft.core.model.PersistModel
;
import
java.math.BigDecimal
;
...
...
src/main/java/org/rcisoft/business/overview/service/impl/OverViewServiceImpl.java
View file @
59174d28
...
...
@@ -2,12 +2,12 @@ package org.rcisoft.business.overview.service.impl;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.rcisoft.business.manage.vo.EnergyPriceVo
;
import
org.rcisoft.business.overview.dao.*
;
import
org.rcisoft.business.overview.entity.*
;
import
org.rcisoft.business.overview.service.OverViewService
;
import
org.rcisoft.business.overview.vo.BusEnergyPlanVo
;
import
org.rcisoft.business.overview.vo.EnergyCountMVo
;
import
org.rcisoft.business.overview.vo.EnergyPriceVo
;
import
org.rcisoft.core.model.PersistModel
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -294,10 +294,7 @@ public class OverViewServiceImpl implements OverViewService {
@Override
public
EnergyPriceVo
getPrice
(
String
proId
)
{
int
i
=
Calendar
.
getInstance
().
get
(
Calendar
.
HOUR_OF_DAY
);
EnergyPrice
e
=
new
EnergyPrice
();
e
.
setProId
(
proId
);
e
.
setPHour
(
String
.
valueOf
(
i
));
return
overViewRepository
.
getPrice
(
e
);
return
overViewRepository
.
getPrice
(
proId
,
String
.
valueOf
(
i
));
}
@Override
...
...
src/main/resources/mapper/sys/overview.mapper/EnergyPriceMapper.xml
View file @
59174d28
<?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.EnergyPriceRepository"
>
<resultMap
id=
"BaseResultMap"
type=
"org.rcisoft.business.
overview.entity.EnergyPrice
"
>
<resultMap
id=
"BaseResultMap"
type=
"org.rcisoft.business.
manage.vo.EnergyPriceVo
"
>
<id
column=
"ID"
jdbcType=
"VARCHAR"
property=
"id"
/>
<result
column=
"PRO_ID"
jdbcType=
"VARCHAR"
property=
"proId"
/>
<result
column=
"P_HOUR"
jdbcType=
"VARCHAR"
property=
"pHour"
/>
<result
column=
"P_PRICE"
jdbcType=
"DECIMAL"
property=
"pPrice"
/>
<result
column=
"P_TP"
jdbcType=
"CHAR"
property=
"pTp"
/>
<result
column=
"P_HOUR"
jdbcType=
"VARCHAR"
property=
"p
rice
Hour"
/>
<result
column=
"P_PRICE"
jdbcType=
"DECIMAL"
property=
"p
rice
Price"
/>
<result
column=
"P_TP"
jdbcType=
"CHAR"
property=
"p
rice
Tp"
/>
</resultMap>
<resultMap
id=
"vo"
type=
"org.rcisoft.business.overview.vo.EnergyPriceVo"
>
...
...
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