Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
plant
Project
Project
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
qinhu
plant
Commits
21b89d9b
Commit
21b89d9b
authored
4 years ago
by
shulidong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
案例crud
parent
554a8aed
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
299 additions
and
9 deletions
+299
-9
pom.xml
power-bussiness/pom.xml
+10
-4
CaseAnalysisInfoController.java
...plant/business/controller/CaseAnalysisInfoController.java
+77
-0
CaseAnalysisInfo.java
.../energy/power/plant/business/domain/CaseAnalysisInfo.java
+38
-2
CaseAttachment.java
...sc/energy/power/plant/business/domain/CaseAttachment.java
+19
-0
PageQuery.java
...wise/sc/energy/power/plant/business/domain/PageQuery.java
+8
-0
UserInfo.java
.../wise/sc/energy/power/plant/business/domain/UserInfo.java
+0
-2
CaseAnalysisInfoRepository.java
...plant/business/repository/CaseAnalysisInfoRepository.java
+18
-0
UnitInfoRepository.java
...y/power/plant/business/repository/UnitInfoRepository.java
+2
-0
ICaseAnalysisInfoService.java
...ower/plant/business/service/ICaseAnalysisInfoService.java
+19
-0
CaseAnalysisInfoServiceImpl.java
...nt/business/service/impl/CaseAnalysisInfoServiceImpl.java
+80
-0
BeanUtilsExt.java
...se/sc/energy/power/plant/business/utils/BeanUtilsExt.java
+24
-0
application.yml
power-bussiness/src/main/resources/application.yml
+4
-1
No files found.
power-bussiness/pom.xml
View file @
21b89d9b
...
...
@@ -42,6 +42,11 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
</dependency>
<dependency>
<groupId>
com.vladmihalcea
</groupId>
<artifactId>
hibernate-types-52
</artifactId>
<version>
2.4.3
</version>
</dependency>
<!--json模块-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
...
...
@@ -185,11 +190,12 @@
<dependency>
<groupId>
net.oschina.zcx7878
</groupId>
<artifactId>
fastdfs-client-java
</artifactId>
<version>
1.27.0.0
</version>
</dependency>
<dependency>
<groupId>
com.github.tobato
</groupId>
<artifactId>
fastdfs-client
</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>com.github.tobato</groupId>-->
<!--<artifactId>fastdfs-client</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>
com.aspose
</groupId>
<!--自定义-->
<artifactId>
words
</artifactId>
<!--自定义-->
...
...
This diff is collapsed.
Click to expand it.
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/controller/CaseAnalysisInfoController.java
0 → 100644
View file @
21b89d9b
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
controller
;
import
cn.hutool.core.util.StrUtil
;
import
cn.wise.sc.energy.power.plant.business.domain.CaseAnalysisInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.PageQuery
;
import
cn.wise.sc.energy.power.plant.business.domain.UserInfoQuery
;
import
cn.wise.sc.energy.power.plant.business.repository.CaseAnalysisInfoRepository
;
import
cn.wise.sc.energy.power.plant.business.service.ICaseAnalysisInfoService
;
import
cn.wise.sc.energy.power.plant.business.utils.BeanUtilsExt
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.CrossOrigin
;
import
org.springframework.web.bind.annotation.GetMapping
;
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
java.time.LocalDateTime
;
/**
* @author neo.shu
* @since 2020/9/12 15:29
*/
@CrossOrigin
@Validated
@RestController
@RequestMapping
(
"caseanalysis/"
)
public
class
CaseAnalysisInfoController
{
@Autowired
CaseAnalysisInfoRepository
caseRepository
;
@Autowired
ICaseAnalysisInfoService
caseAnalysisInfoService
;
@PostMapping
(
"/page"
)
public
BaseResponse
<
Page
<
CaseAnalysisInfo
>>
page
(
@RequestBody
PageQuery
page
)
{
if
(
StrUtil
.
isBlank
(
page
.
getPlantId
())){
return
BaseResponse
.
errorMsg
(
"电厂id不能为空!"
);
}
return
caseAnalysisInfoService
.
page
(
page
,
page
.
getPlantId
());
}
@PostMapping
(
"/newOrUpdate"
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
)
public
BaseResponse
<
Boolean
>
add
(
@RequestBody
CaseAnalysisInfo
info
)
{
CaseAnalysisInfo
caseAnalysisInfo
;
if
(
info
.
getCaseId
()
==
null
)
{
caseAnalysisInfo
=
caseRepository
.
save
(
info
);
}
else
{
caseAnalysisInfo
=
caseRepository
.
getOne
(
info
.
getCaseId
());
BeanUtils
.
copyProperties
(
info
,
caseAnalysisInfo
,
BeanUtilsExt
.
getNullPropertyNames
(
info
));
caseAnalysisInfo
.
setUpdateTime
(
LocalDateTime
.
now
());
caseAnalysisInfo
=
caseRepository
.
save
(
caseAnalysisInfo
);
}
if
(
caseAnalysisInfo
.
getId
()
!=
null
)
{
return
BaseResponse
.
okData
(
true
);
}
else
{
return
BaseResponse
.
okData
(
false
);
}
}
@PostMapping
(
"/del"
)
public
BaseResponse
<
Boolean
>
del
(
String
id
){
return
null
;
}
}
This diff is collapsed.
Click to expand it.
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/CaseAnalysisInfo.java
View file @
21b89d9b
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
domain
;
import
com.fasterxml.jackson.annotation.JsonValue
;
import
com.sun.xml.internal.ws.api.message.Attachment
;
import
com.vladmihalcea.hibernate.type.json.JsonStringType
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.Type
;
import
org.hibernate.annotations.TypeDef
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
* @author neo.shu
...
...
@@ -15,12 +24,39 @@ import javax.persistence.Table;
@Entity
@Data
@NoArgsConstructor
@Table
(
name
=
"caseAnalysisInfo"
)
@Table
(
name
=
"caseanalysisinfo"
)
@TypeDef
(
name
=
"json"
,
typeClass
=
JsonStringType
.
class
)
public
class
CaseAnalysisInfo
extends
AbstractEntity
<
String
>{
@Id
@Column
(
name
=
"caseid"
)
@Column
(
name
=
"case_id"
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
String
caseId
;
@Column
(
name
=
"plant_id"
)
private
String
plantId
;
@Column
(
name
=
"title"
)
private
String
title
;
@Column
(
name
=
"info"
)
private
String
info
;
@Column
(
name
=
"keywords"
,
columnDefinition
=
"json"
)
@Type
(
type
=
"json"
)
private
List
<
String
>
keywords
;
@Column
(
name
=
"attachments"
,
columnDefinition
=
"json"
)
@Type
(
type
=
"json"
)
private
List
<
CaseAttachment
>
attachments
;
@Column
(
name
=
"create_time"
)
private
LocalDateTime
createTime
=
LocalDateTime
.
now
();
@Column
(
name
=
"update_time"
)
private
LocalDateTime
updateTime
=
LocalDateTime
.
now
();
@Override
public
String
getId
()
{
return
getCaseId
();
...
...
This diff is collapsed.
Click to expand it.
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/CaseAttachment.java
0 → 100644
View file @
21b89d9b
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
domain
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author neo.shu
* @since 2020/9/12 17:31
*/
@Data
public
class
CaseAttachment
implements
Serializable
{
private
String
filePath
;
private
String
showPath
;
private
String
name
;
private
long
size
;
}
This diff is collapsed.
Click to expand it.
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/PageQuery.java
View file @
21b89d9b
...
...
@@ -3,6 +3,7 @@ package cn.wise.sc.energy.power.plant.business.domain;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* @description: 分页参数
...
...
@@ -17,4 +18,11 @@ public class PageQuery implements Serializable {
private
Integer
pageNo
=
0
;
private
Integer
pageSize
=
10
;
private
List
<
String
>
keywords
;
private
String
vaguewords
;
private
String
plantId
;
private
String
startTime
;
private
String
endTime
;
}
This diff is collapsed.
Click to expand it.
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/domain/UserInfo.java
View file @
21b89d9b
...
...
@@ -2,12 +2,10 @@ package cn.wise.sc.energy.power.plant.business.domain;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.hibernate.annotations.GenericGenerator
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.authority.SimpleGrantedAuthority
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
...
...
This diff is collapsed.
Click to expand it.
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/repository/CaseAnalysisInfoRepository.java
0 → 100644
View file @
21b89d9b
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
repository
;
import
cn.wise.sc.energy.power.plant.business.domain.CaseAnalysisInfo
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.stereotype.Repository
;
/**
* @author neo.shu
* @since 2020/9/12 15:20
*/
@Repository
public
interface
CaseAnalysisInfoRepository
extends
JpaRepository
<
CaseAnalysisInfo
,
String
>,
JpaSpecificationExecutor
<
CaseAnalysisInfo
>
{
}
This diff is collapsed.
Click to expand it.
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/repository/UnitInfoRepository.java
View file @
21b89d9b
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
repository
;
import
cn.wise.sc.energy.power.plant.business.domain.UnitInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.UserInfo
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.stereotype.Repository
;
...
...
@@ -13,4 +14,5 @@ import org.springframework.stereotype.Repository;
@Repository
public
interface
UnitInfoRepository
extends
JpaSpecificationExecutor
<
UnitInfo
>,
JpaRepository
<
UnitInfo
,
String
>
{
}
This diff is collapsed.
Click to expand it.
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/ICaseAnalysisInfoService.java
0 → 100644
View file @
21b89d9b
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
;
import
cn.wise.sc.energy.power.plant.business.domain.CaseAnalysisInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.PageQuery
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
org.springframework.data.domain.Page
;
import
java.util.List
;
/**
* @author neo.shu
* @since 2020/9/12 15:21
*/
public
interface
ICaseAnalysisInfoService
{
BaseResponse
<
Page
<
CaseAnalysisInfo
>>
page
(
PageQuery
page
,
String
plantId
);
}
This diff is collapsed.
Click to expand it.
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/service/impl/CaseAnalysisInfoServiceImpl.java
0 → 100644
View file @
21b89d9b
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
service
.
impl
;
import
cn.hutool.core.util.StrUtil
;
import
cn.wise.sc.energy.power.plant.business.domain.CaseAnalysisInfo
;
import
cn.wise.sc.energy.power.plant.business.domain.PageQuery
;
import
cn.wise.sc.energy.power.plant.business.repository.CaseAnalysisInfoRepository
;
import
cn.wise.sc.energy.power.plant.business.service.ICaseAnalysisInfoService
;
import
cn.wise.sc.energy.power.plant.common.core.bean.BaseResponse
;
import
io.jsonwebtoken.lang.Collections
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
javax.persistence.criteria.Expression
;
import
javax.persistence.criteria.Path
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Selection
;
import
javax.persistence.criteria.Subquery
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author neo.shu
* @since 2020/9/12 15:26
*/
@Service
public
class
CaseAnalysisInfoServiceImpl
implements
ICaseAnalysisInfoService
{
@Autowired
CaseAnalysisInfoRepository
caseRepository
;
@Override
public
BaseResponse
<
Page
<
CaseAnalysisInfo
>>
page
(
PageQuery
page
,
String
plantId
)
{
Sort
sort
=
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"caseId"
);
Pageable
pages
=
PageRequest
.
of
(
page
.
getPageNo
(),
page
.
getPageSize
(),
sort
);
Page
<
CaseAnalysisInfo
>
infoPage
;
Specification
<
CaseAnalysisInfo
>
specification
=
(
root
,
query
,
cb
)
->
{
List
<
Predicate
>
list
=
new
ArrayList
<
Predicate
>();
//模糊搜索
if
(!
StringUtils
.
isEmpty
(
page
.
getVaguewords
()))
{
list
.
add
(
cb
.
like
(
root
.
get
(
"title"
).
as
(
String
.
class
),
"%"
+
page
.
getVaguewords
()
+
"%"
));
}
//电厂id必传
if
(!
StringUtils
.
isEmpty
(
plantId
))
{
list
.
add
(
cb
.
equal
(
root
.
get
(
"plantId"
),
plantId
));
}
//匹配关键字
if
(
page
.
getKeywords
().
size
()
>
0
)
{
//包含元素
/* for (String item : page.getKeywords()) {
Expression expression = query.
list.add(cb.isTrue());
}*/
}
//时间选择
Predicate
timePredicate
=
cb
.
conjunction
();
timePredicate
.
in
();
if
(
page
.
getStartTime
()
!=
null
&&
!
page
.
getStartTime
().
trim
().
equals
(
""
))
{
list
.
add
(
cb
.
greaterThanOrEqualTo
(
root
.
get
(
"createTime"
).
as
(
LocalDateTime
.
class
),
LocalDateTime
.
parse
(
page
.
getStartTime
())));
}
//结束日期
if
(
page
.
getEndTime
()
!=
null
&&
!
page
.
getEndTime
().
trim
().
equals
(
""
))
{
list
.
add
(
cb
.
lessThanOrEqualTo
(
root
.
get
(
"createTime"
).
as
(
LocalDateTime
.
class
),
LocalDateTime
.
parse
(
page
.
getEndTime
())));
}
return
cb
.
and
(
list
.
toArray
(
new
Predicate
[
list
.
size
()]));
};
infoPage
=
caseRepository
.
findAll
(
specification
,
pages
);
return
BaseResponse
.
okData
(
infoPage
);
}
}
This diff is collapsed.
Click to expand it.
power-bussiness/src/main/java/cn/wise/sc/energy/power/plant/business/utils/BeanUtilsExt.java
0 → 100644
View file @
21b89d9b
package
cn
.
wise
.
sc
.
energy
.
power
.
plant
.
business
.
utils
;
import
org.springframework.beans.BeanWrapper
;
import
org.springframework.beans.BeanWrapperImpl
;
import
java.util.HashSet
;
import
java.util.Set
;
public
class
BeanUtilsExt
{
public
static
String
[]
getNullPropertyNames
(
Object
source
)
{
final
BeanWrapper
src
=
new
BeanWrapperImpl
(
source
);
java
.
beans
.
PropertyDescriptor
[]
pds
=
src
.
getPropertyDescriptors
();
Set
<
String
>
emptyNames
=
new
HashSet
<
String
>();
for
(
java
.
beans
.
PropertyDescriptor
pd
:
pds
)
{
Object
srcValue
=
src
.
getPropertyValue
(
pd
.
getName
());
if
(
srcValue
==
null
)
emptyNames
.
add
(
pd
.
getName
());
}
String
[]
result
=
new
String
[
emptyNames
.
size
()];
return
emptyNames
.
toArray
(
result
);
}
}
This diff is collapsed.
Click to expand it.
power-bussiness/src/main/resources/application.yml
View file @
21b89d9b
...
...
@@ -96,7 +96,10 @@ spring:
# max-idle-per-key: 10
# #每个key对应的连接池最小空闲连接数
# max_idle_per_key: 5
jpa
:
hibernate
:
naming
:
physical-strategy
:
org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
opentsdb
:
baseUrl
:
http://39.105.86.33:8182
server
:
...
...
This diff is collapsed.
Click to expand it.
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