Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
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
徐少华
midjourney-proxy
Commits
c53cd2b9
Commit
c53cd2b9
authored
Nov 26, 2018
by
shuyunhu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://begitlab.chubanyun.me/rays/pcloud-common-parent
parents
5346f57e
273cd919
Hide whitespace changes
Inline
Side-by-side
Showing
50 changed files
with
4213 additions
and
3871 deletions
+4213
-3871
email.properties
...ud-common-config/src/main/resources.prod/email.properties
+19
-11
email.properties
pcloud-common-config/src/main/resources.uat/email.properties
+17
-11
quartz.properties
...ud-common-config/src/main/resources.uat/quartz.properties
+46
-46
pom.xml
pcloud-common-core/pom.xml
+56
-70
ExapiQueueBizImpl.java
...in/java/com/pcloud/common/core/biz/ExapiQueueBizImpl.java
+12
-31
FrontEventBiz.java
...c/main/java/com/pcloud/common/core/biz/FrontEventBiz.java
+6
-7
FrontEventBizImpl.java
...in/java/com/pcloud/common/core/biz/FrontEventBizImpl.java
+72
-66
FundQueueBizImpl.java
...ain/java/com/pcloud/common/core/biz/FundQueueBizImpl.java
+9
-23
FunnelFlowQueueBizImpl.java
...va/com/pcloud/common/core/biz/FunnelFlowQueueBizImpl.java
+25
-51
LabelUsedQueueBizImpl.java
...ava/com/pcloud/common/core/biz/LabelUsedQueueBizImpl.java
+9
-39
MerchantDynamicQueueBizImpl.java
...m/pcloud/common/core/biz/MerchantDynamicQueueBizImpl.java
+14
-37
MessageBiz.java
.../src/main/java/com/pcloud/common/core/biz/MessageBiz.java
+6
-0
MessageBizImpl.java
.../main/java/com/pcloud/common/core/biz/MessageBizImpl.java
+47
-117
OperationLogQueueBizImpl.java
.../com/pcloud/common/core/biz/OperationLogQueueBizImpl.java
+7
-33
TemplateQueueBizImpl.java
...java/com/pcloud/common/core/biz/TemplateQueueBizImpl.java
+9
-33
UserActionQueueBizImpl.java
...va/com/pcloud/common/core/biz/UserActionQueueBizImpl.java
+10
-36
WeektaskQueueBizImpl.java
...java/com/pcloud/common/core/biz/WeektaskQueueBizImpl.java
+18
-42
ConvertEnum.java
...ain/java/com/pcloud/common/core/constant/ConvertEnum.java
+95
-95
MQQueueConstant.java
...java/com/pcloud/common/core/constant/MQQueueConstant.java
+5
-0
MQTopicProducer.java
...java/com/pcloud/common/core/constant/MQTopicProducer.java
+232
-6
ProductTypeConstant.java
.../com/pcloud/common/core/constant/ProductTypeConstant.java
+16
-1
SceneCode.java
.../main/java/com/pcloud/common/core/constant/SceneCode.java
+30
-62
WeektaskCode.java
...in/java/com/pcloud/common/core/constant/WeektaskCode.java
+135
-34
BaseDao.java
...ore/src/main/java/com/pcloud/common/core/dao/BaseDao.java
+133
-131
BaseDaoImpl.java
...src/main/java/com/pcloud/common/core/dao/BaseDaoImpl.java
+332
-310
SendNotifyDto.java
...c/main/java/com/pcloud/common/core/dto/SendNotifyDto.java
+34
-0
TemplateMessageDto.java
...n/java/com/pcloud/common/core/dto/TemplateMessageDto.java
+240
-227
AppTypeEnum.java
...c/main/java/com/pcloud/common/core/enums/AppTypeEnum.java
+5
-2
NotifyOriginTypeEnum.java
...va/com/pcloud/common/core/enums/NotifyOriginTypeEnum.java
+37
-0
ActiveMqFactory.java
.../main/java/com/pcloud/common/core/mq/ActiveMqFactory.java
+0
-75
ActiveMqProducer.java
...main/java/com/pcloud/common/core/mq/ActiveMqProducer.java
+0
-275
ActiveMqQueue.java
...rc/main/java/com/pcloud/common/core/mq/ActiveMqQueue.java
+0
-170
pom.xml
pcloud-common/pom.xml
+30
-26
OrderParamForApp.java
...src/main/java/com/pcloud/common/dto/OrderParamForApp.java
+13
-0
OrderParamForLive.java
...rc/main/java/com/pcloud/common/dto/OrderParamForLive.java
+28
-0
BaseEntity.java
...on/src/main/java/com/pcloud/common/entity/BaseEntity.java
+13
-0
AppTypeEnum.java
...on/src/main/java/com/pcloud/common/enums/AppTypeEnum.java
+6
-2
TradeCommonService.java
...a/com/pcloud/common/trade/service/TradeCommonService.java
+30
-0
PayParamVO.java
.../src/main/java/com/pcloud/common/trade/vo/PayParamVO.java
+317
-0
TargetIdAndTypeVO.java
...in/java/com/pcloud/common/trade/vo/TargetIdAndTypeVO.java
+143
-0
BeanNewUtils.java
...n/src/main/java/com/pcloud/common/utils/BeanNewUtils.java
+67
-44
HttpKit.java
...common/src/main/java/com/pcloud/common/utils/HttpKit.java
+56
-0
LocalDateUtils.java
...src/main/java/com/pcloud/common/utils/LocalDateUtils.java
+41
-5
PictureUtil.java
...on/src/main/java/com/pcloud/common/utils/PictureUtil.java
+263
-136
ResultUtils.java
...on/src/main/java/com/pcloud/common/utils/ResultUtils.java
+59
-59
PdfUtils.java
...n/src/main/java/com/pcloud/common/utils/pdf/PdfUtils.java
+486
-526
SolrUtils.java
...src/main/java/com/pcloud/common/utils/solr/SolrUtils.java
+2
-0
StringUtil.java
.../main/java/com/pcloud/common/utils/string/StringUtil.java
+594
-600
pom.xml
pom.xml
+389
-432
temp.jpg
temp.jpg
+0
-0
No files found.
pcloud-common-config/src/main/resources.prod/email.properties
View file @
c53cd2b9
email.fromEmail
=
rays_support@vip.163.com
email.password
=
chubanyun
email.reviewFromEmail
=
rays_review@vip.163.com
email.reviewPassword
=
lgsz2017
email.saysEmail
=
says_support@vip.163.com
email.saysPassword
=
2017sayschuban
## \u81EA\u5B9A\u4E49\u90AE\u7BB1
email.fromEmail.new
=
rays_support@vip.163.com
email.password.new
=
chubanyun
\ No newline at end of file
#email.fromEmail=rays_support@vip.163.com
#email.password=chubanyun
#email.reviewFromEmail=rays_review@vip.163.com
#email.reviewPassword=lgsz2017
#email.reviewFromEmail=review@5rs.me
#email.reviewPassword=reviewlgsc
## \u81EA\u5B9A\u4E49\u90AE\u7BB1
email.user
=
support
email.name
=
support@5rs.me
email.password
=
supportlgsc
email.review.user
=
review
email.review.name
=
review@5rs.me
email.review.password
=
reviewlgsc
mail.smtp.host
=
smtp.5rs.me
mail.imap.host
=
imap.5rs.me
mail.pop.host
=
pop.5rs.me
\ No newline at end of file
pcloud-common-config/src/main/resources.uat/email.properties
View file @
c53cd2b9
email.fromEmail
=
rays_support@vip.163.com
email.password
=
chubanyun
email.reviewFromEmail
=
rays_review@vip.163.com
email.reviewPassword
=
lgsz2017
email.saysEmail
=
says_support@vip.163.com
email.saysPassword
=
2017sayschuban
## \u81EA\u5B9A\u4E49\u90AE\u7BB1
email.fromEmail.new
=
rays_support@vip.163.com
email.password.new
=
chubanyun
\ No newline at end of file
#email.fromEmail=rays_support@vip.163.com
#email.password=chubanyun
#email.reviewFromEmail=rays_review@vip.163.com
#email.reviewPassword=lgsz2017
## \u81EA\u5B9A\u4E49\u90AE\u7BB1
email.user
=
admin
email.name
=
admin@raysyun.com
email.password
=
lgsc2018!
email.review.user
=
admin
email.review.name
=
admin@raysyun.com
email.review.password
=
lgsc2018!
mail.smtp.host
=
smtp.raysyun.com
mail.imap.host
=
imap.raysyun.com
mail.pop.host
=
pop.raysyun.com
\ No newline at end of file
pcloud-common-config/src/main/resources.uat/quartz.properties
View file @
c53cd2b9
org.quartz.scheduler.instanceName
=
MyClusteredScheduler
org.quartz.scheduler.instanceId
=
AUTO
org.quartz.scheduler.idleWaitTime
=
30000
#============================================================================
# Configure ThreadPool
#============================================================================
org.quartz.threadPool.class
=
org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount
=
2
org.quartz.threadPool.threadPriority
=
5
org.quartz.scheduler.batchTriggerAcquisitionMaxCount
=
1000
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread
=
true
#============================================================================
# Configure JobStore
#============================================================================
org.quartz.jobStore.misfireThreshold
=
60000
org.quartz.jobStore.class
=
org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass
=
org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties
=
false
org.quartz.jobStore.dataSource
=
myDS
org.quartz.jobStore.tablePrefix
=
QRTZ_
org.quartz.jobStore.isClustered
=
true
org.quartz.jobStore.maxMisfiresToHandleAtATime
=
20
org.quartz.jobStore.clusterCheckinInterval
=
20000
#============================================================================
# Configure Datasources
#============================================================================
org.quartz.dataSource.myDS.driver
=
com.mysql.jdbc.Driver
org.quartz.dataSource.myDS.URL
=
jdbc:mysql://192.168.92.42:3306/quartz?useUnicode=true&characterEncoding=utf-8&useSSL=false
org.quartz.dataSource.myDS.user
=
quartz
org.quartz.dataSource.myDS.password
=
quartz123
org.quartz.dataSource.myDS.maxConnections
=
100
#============================================================================
# Configure Provider Ip , Port
#============================================================================
org.quartz.scheduler.instanceName
=
MyClusteredScheduler
org.quartz.scheduler.instanceId
=
AUTO
org.quartz.scheduler.idleWaitTime
=
30000
#============================================================================
# Configure ThreadPool
#============================================================================
org.quartz.threadPool.class
=
org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount
=
2
org.quartz.threadPool.threadPriority
=
5
org.quartz.scheduler.batchTriggerAcquisitionMaxCount
=
1000
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread
=
true
#============================================================================
# Configure JobStore
#============================================================================
org.quartz.jobStore.misfireThreshold
=
60000
org.quartz.jobStore.class
=
org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass
=
org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties
=
false
org.quartz.jobStore.dataSource
=
myDS
org.quartz.jobStore.tablePrefix
=
QRTZ_
org.quartz.jobStore.isClustered
=
true
org.quartz.jobStore.maxMisfiresToHandleAtATime
=
20
org.quartz.jobStore.clusterCheckinInterval
=
20000
#============================================================================
# Configure Datasources
#============================================================================
org.quartz.dataSource.myDS.driver
=
com.mysql.jdbc.Driver
org.quartz.dataSource.myDS.URL
=
jdbc:mysql://192.168.92.42:3306/quartz?useUnicode=true&characterEncoding=utf-8&useSSL=false
org.quartz.dataSource.myDS.user
=
rays
org.quartz.dataSource.myDS.password
=
lgsC789
org.quartz.dataSource.myDS.maxConnections
=
100
#============================================================================
# Configure Provider Ip , Port
#============================================================================
pcloud-common-core/pom.xml
View file @
c53cd2b9
<project
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common-parent
</artifactId>
<version>
2.1.0-RELEASE
</version>
</parent>
<artifactId>
pcloud-common-core
</artifactId>
<packaging>
jar
</packaging>
<version>
${pcloud-common-core.version}
</version>
<name>
pcloud-common-core
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common
</artifactId>
<version>
${pcloud-common.version}
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<scope>
test
</scope>
</dependency>
<!-- Database connect Begin -->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
</dependency>
<!-- Database connect End -->
<!-- Mysql Driver Begin -->
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<!-- Mysql Driver End -->
<!-- ActiveMq Begin -->
<dependency>
<groupId>
org.apache.activemq
</groupId>
<artifactId>
activemq-all
</artifactId>
</dependency>
<!-- ActiveMq End -->
<!-- Jackson Begin -->
<dependency>
<groupId>
org.codehaus.jackson
</groupId>
<artifactId>
jackson-mapper-asl
</artifactId>
</dependency>
<!-- Jackson End -->
<!-- Redis Begin -->
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
</dependency>
<!-- Redis End -->
</dependencies>
</project>
<project
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common-parent
</artifactId>
<version>
2.1.0-RELEASE
</version>
</parent>
<artifactId>
pcloud-common-core
</artifactId>
<packaging>
jar
</packaging>
<version>
${pcloud-common-core.version}
</version>
<name>
pcloud-common-core
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common
</artifactId>
<version>
${pcloud-common.version}
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<scope>
test
</scope>
</dependency>
<!-- Database connect Begin -->
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
</dependency>
<!-- Database connect End -->
<!-- Mysql Driver Begin -->
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<!-- Mysql Driver End -->
<!-- Jackson Begin -->
<dependency>
<groupId>
org.codehaus.jackson
</groupId>
<artifactId>
jackson-mapper-asl
</artifactId>
</dependency>
<!-- Jackson End -->
</dependencies>
</project>
pcloud-common-core/src/main/java/com/pcloud/common/core/biz/ExapiQueueBizImpl.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
biz
;
import
com.pcloud.common.core.dto.ExapiMessageDto
;
import
com.pcloud.common.exceptions.BizException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.MessageCreator
;
import
org.springframework.stereotype.Component
;
import
javax.jms.JMSException
;
import
javax.jms.ObjectMessage
;
import
javax.jms.Session
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.constant.MQQueueConstant
;
import
com.pcloud.common.core.dto.ExapiMessageDto
;
@Component
(
"exapiQueueBiz"
)
public
class
ExapiQueueBizImpl
implements
ExapiQueueBiz
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ExapiQueueBiz
.
class
);
public
class
ExapiQueueBizImpl
implements
ExapiQueueBiz
{
@Autowired
(
required
=
false
)
@Qualifier
(
"jmsExapiTemplate"
)
private
JmsTemplate
jmsExapiTemplate
;
@Autowired
private
AmqpTemplate
amqpTemplate
;
@Override
public
void
sendMessageQueue
(
ExapiMessageDto
exapiMessageDto
)
{
MessageCreator
messageCreator
=
new
MessageCreator
()
{
@Override
public
ObjectMessage
createMessage
(
Session
session
)
throws
JMSException
{
return
session
.
createObjectMessage
(
exapiMessageDto
);
}
};
@Override
@ParamLog
(
"发送对外API queue"
)
public
void
sendMessageQueue
(
ExapiMessageDto
exapiMessageDto
)
{
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
EXAPI
,
exapiMessageDto
);
}
try
{
jmsExapiTemplate
.
send
(
messageCreator
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"发送失败,"
+
e
.
getMessage
()
+
","
+
exapiMessageDto
,
e
);
throw
BizException
.
SEND_QUEUE_FAIL
;
}
LOGGER
.
info
(
"发送成功,"
+
exapiMessageDto
);
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/biz/FrontEventBiz.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
biz
;
import
com.pcloud.common.core.dto.ConvertQueueDto
;
import
com.pcloud.common.core.dto.FrontEventDto
;
import
com.pcloud.common.exceptions.BizException
;
...
...
@@ -10,10 +9,10 @@ import com.pcloud.common.exceptions.BizException;
* @description:
*/
public
interface
FrontEventBiz
{
/**
* 发送事件消息
*
* @param frontEventDto
*/
public
void
sendFrontEventQueue
(
FrontEventDto
frontEventDto
)
throws
BizException
;
/**
* 发送事件消息
*
* @param frontEventDto
*/
public
void
sendFrontEventQueue
(
FrontEventDto
frontEventDto
)
throws
BizException
;
}
pcloud-common-core/src/main/java/com/pcloud/common/core/biz/FrontEventBizImpl.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
biz
;
import
com.pcloud.common.core.dto.FrontEventDto
;
import
com.pcloud.common.exceptions.BizException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.MessageCreator
;
import
org.springframework.stereotype.Component
;
import
javax.jms.JMSException
;
import
javax.jms.ObjectMessage
;
import
javax.jms.Session
;
/**
* @author Shichunshan
* @date: Created in 2018/4/17 11:09
* @description:
*/
@Component
(
"frontEventBiz"
)
public
class
FrontEventBizImpl
implements
FrontEventBiz
{
/**
*
*/
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ConvertQueueBizImpl
.
class
);
@Autowired
(
required
=
false
)
@Qualifier
(
"jmsFrontEventTemplate"
)
private
JmsTemplate
jmsFrontEventTemplate
;
/**
* 发送事件消息
*
* @param frontEventDto
*/
@Override
public
void
sendFrontEventQueue
(
FrontEventDto
frontEventDto
)
throws
BizException
{
MessageCreator
messageCreator
=
new
MessageCreator
()
{
@Override
public
ObjectMessage
createMessage
(
Session
session
)
throws
JMSException
{
return
session
.
createObjectMessage
(
frontEventDto
);
}
};
try
{
jmsFrontEventTemplate
.
send
(
messageCreator
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送失败,"
+
e
.
getMessage
()
+
","
+
frontEventDto
,
e
);
throw
BizException
.
SEND_QUEUE_FAIL
;
}
logger
.
info
(
"发送成功,"
+
frontEventDto
);
}
/**
* 生成(事件ID/漏斗ID)前缀
*
* @param targetClass
* @param targetType
*/
public
static
String
generatePrefix
(
String
targetClass
,
String
targetType
){
StringBuilder
prefix
=
new
StringBuilder
();
prefix
.
append
(
targetClass
.
toLowerCase
()+
"_"
);
prefix
.
append
(
targetType
.
toLowerCase
()+
"_"
);
return
prefix
.
toString
();
}
}
package
com
.
pcloud
.
common
.
core
.
biz
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.constant.MQQueueConstant
;
import
com.pcloud.common.core.dto.FrontEventDto
;
import
com.pcloud.common.exceptions.BizException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
/**
* @author Shichunshan
* @date: Created in 2018/4/17 11:09
* @description:
*/
@Component
(
"frontEventBiz"
)
public
class
FrontEventBizImpl
implements
FrontEventBiz
{
/**
*
*/
private
final
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ConvertQueueBizImpl
.
class
);
// @Autowired(required=false)
// @Qualifier("jmsFrontEventTemplate")
// private JmsTemplate jmsFrontEventTemplate;
@Resource
private
AmqpTemplate
amqpTemplate
;
/**
* 发送事件消息
*
* @param frontEventDto
*/
// @Override
// public void sendFrontEventQueue(FrontEventDto frontEventDto) throws
// BizException {
// MessageCreator messageCreator = session ->
// session.createObjectMessage(frontEventDto);
// try {
// jmsFrontEventTemplate.send(messageCreator);
// } catch (Exception e) {
// logger.error("发送失败," + e.getMessage() + "," + frontEventDto, e);
// throw BizException.SEND_QUEUE_FAIL;
// }
// logger.info("发送成功," + frontEventDto);
// }
/**
* 文件转码QUEUE
*/
@Override
@ParamLog
(
description
=
"大数据埋点QUEUE"
)
public
void
sendFrontEventQueue
(
FrontEventDto
frontEventDto
)
throws
BizException
{
LOGGER
.
info
(
"===大数据埋点===start --> frontEventDto:{}"
,
frontEventDto
);
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
FRONT_EVENT
,
frontEventDto
);
LOGGER
.
info
(
"===大数据埋点===end --> frontEventDto:{}"
,
frontEventDto
);
}
/**
* 生成(事件ID/漏斗ID)前缀
*
* @param targetClass
* @param targetType
*/
public
static
String
generatePrefix
(
String
targetClass
,
String
targetType
)
{
return
targetClass
.
toLowerCase
()
+
"_"
+
targetType
.
toLowerCase
()
+
"_"
;
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/biz/FundQueueBizImpl.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
biz
;
import
javax.jms.JMSException
;
import
javax.jms.ObjectMessage
;
import
javax.jms.Session
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.MessageCreator
;
import
org.springframework.stereotype.Component
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.constant.MQQueueConstant
;
import
com.pcloud.common.core.dto.FundMessageDto
;
import
com.pcloud.common.exceptions.BizException
;
/**
* @description 基金资源变更记录消息队列实现类
* @author PENG
* @date 2017年10月18日 下午2:11:52
* @version 1.0
* @description 基金资源变更记录消息队列实现类
* @date 2017年10月18日 下午2:11:52
*/
@Component
(
"fundQueueBiz"
)
public
class
FundQueueBizImpl
implements
FundQueueBiz
{
...
...
@@ -29,29 +24,20 @@ public class FundQueueBizImpl implements FundQueueBiz {
*/
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
FundQueueBizImpl
.
class
);
@Autowired
(
required
=
false
)
@Qualifier
(
"jmsFundTemplate"
)
private
JmsTemplate
jmsFundTemplate
;
@Autowired
private
AmqpTemplate
amqpTemplate
;
/**
* 发送队列
*/
@Override
@ParamLog
(
"发送基金资源变更记录消息QUEUE"
)
public
void
sendFundMessage
(
FundMessageDto
fundMessageDto
)
throws
BizException
{
MessageCreator
messageCreator
=
new
MessageCreator
()
{
@Override
public
ObjectMessage
createMessage
(
Session
session
)
throws
JMSException
{
return
session
.
createObjectMessage
(
fundMessageDto
);
}
};
try
{
jmsFundTemplate
.
send
(
messageCreator
);
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
FUND
,
fundMessageDto
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送失败,"
+
e
.
getMessage
()
+
","
+
fundMessageDto
.
toString
(),
e
);
throw
BizException
.
SEND_QUEUE_FAIL
;
}
logger
.
info
(
"发送成功,"
+
fundMessageDto
.
toString
());
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/biz/FunnelFlowQueueBizImpl.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
biz
;
import
javax.jms.JMSException
;
import
javax.jms.ObjectMessage
;
import
javax.jms.Session
;
import
org.apache.activemq.command.ActiveMQQueue
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.MessageCreator
;
import
org.springframework.stereotype.Component
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.constant.FunnelFlowStruct.FlowNode
;
import
com.pcloud.common.core.constant.FunnelFlowStruct.TargetRoleType
;
import
com.pcloud.common.core.constant.FunnelFlowStruct.TargetType
;
import
com.pcloud.common.core.constant.MQQueueConstant
;
import
com.pcloud.common.core.dto.FunnelFlowQueueDto
;
import
com.pcloud.common.exceptions.BizException
;
/**
* @描述: 发送模板消息队列实现类
* @作者: shuyh
* @创建时间: 2018年1月9日
* @版本:1.0
* @描述: 发送模板消息队列实现类 @作者: shuyh @创建时间: 2018年1月9日 @版本:1.0
*/
@Component
(
"funnelFlowQueueBiz"
)
public
class
FunnelFlowQueueBizImpl
implements
FunnelFlowQueueBiz
{
public
class
FunnelFlowQueueBizImpl
implements
FunnelFlowQueueBiz
{
/**
*
*/
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
FunnelFlowQueueBizImpl
.
class
);
@Autowired
(
required
=
false
)
@Qualifier
(
"jmsFunnelFlowTemplate"
)
private
JmsTemplate
jmsFunnelFlowTemplate
;
@Autowired
(
required
=
false
)
@Qualifier
(
"funnelFlowQueue"
)
private
ActiveMQQueue
funnelFlowQueue
;
@Autowired
private
AmqpTemplate
amqpTemplate
;
/**
*
发送队列
*
用户漏斗QUEUE
*/
@Override
@ParamLog
(
"用户漏斗QUEUE"
)
public
void
sendMessageQueue
(
FunnelFlowQueueDto
funnelFlowQueueDto
)
throws
BizException
{
MessageCreator
messageCreator
=
new
MessageCreator
()
{
@Override
public
ObjectMessage
createMessage
(
Session
session
)
throws
JMSException
{
return
session
.
createObjectMessage
(
funnelFlowQueueDto
);
}
};
try
{
jmsFunnelFlowTemplate
.
send
(
funnelFlowQueue
,
messageCreator
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送失败,"
+
e
.
getMessage
()
+
","
+
funnelFlowQueueDto
,
e
);
throw
BizException
.
SEND_QUEUE_FAIL
;
}
logger
.
info
(
"发送成功,"
+
funnelFlowQueueDto
);
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
FUNNEL_FLOW
,
funnelFlowQueueDto
);
}
/**
* 发送队列
*/
@Override
public
void
sendMessageQueue
(
TargetType
targetType
,
TargetRoleType
targetRoleType
,
FlowNode
flowNode
,
String
ip
,
String
userAgent
)
throws
BizException
{
FunnelFlowQueueDto
funnelFlowQueueDto
=
new
FunnelFlowQueueDto
(
targetType
,
targetRoleType
,
flowNode
,
ip
,
userAgent
);
public
void
sendMessageQueue
(
TargetType
targetType
,
TargetRoleType
targetRoleType
,
FlowNode
flowNode
,
String
ip
,
String
userAgent
)
throws
BizException
{
FunnelFlowQueueDto
funnelFlowQueueDto
=
new
FunnelFlowQueueDto
(
targetType
,
targetRoleType
,
flowNode
,
ip
,
userAgent
);
sendMessageQueue
(
funnelFlowQueueDto
);
}
...
...
@@ -75,18 +45,22 @@ public class FunnelFlowQueueBizImpl implements FunnelFlowQueueBiz{
* 发送队列
*/
@Override
public
void
sendMessageQueue
(
TargetType
targetType
,
Long
targetId
,
TargetRoleType
targetRoleType
,
Long
targetRoleId
,
FlowNode
flowNode
)
throws
BizException
{
FunnelFlowQueueDto
funnelFlowQueueDto
=
new
FunnelFlowQueueDto
(
targetType
,
targetId
,
targetRoleType
,
targetRoleId
,
flowNode
);
public
void
sendMessageQueue
(
TargetType
targetType
,
Long
targetId
,
TargetRoleType
targetRoleType
,
Long
targetRoleId
,
FlowNode
flowNode
)
throws
BizException
{
FunnelFlowQueueDto
funnelFlowQueueDto
=
new
FunnelFlowQueueDto
(
targetType
,
targetId
,
targetRoleType
,
targetRoleId
,
flowNode
);
sendMessageQueue
(
funnelFlowQueueDto
);
}
/**
* 发送队列
*/
@Override
public
void
sendMessageQueue
(
TargetType
targetType
,
Long
targetId
,
String
subtypeCode
,
TargetRoleType
targetRoleType
,
Long
targetRoleId
,
FlowNode
flowNode
)
throws
BizException
{
FunnelFlowQueueDto
funnelFlowQueueDto
=
new
FunnelFlowQueueDto
(
targetType
,
targetId
,
subtypeCode
,
targetRoleType
,
targetRoleId
,
flowNode
);
public
void
sendMessageQueue
(
TargetType
targetType
,
Long
targetId
,
String
subtypeCode
,
TargetRoleType
targetRoleType
,
Long
targetRoleId
,
FlowNode
flowNode
)
throws
BizException
{
FunnelFlowQueueDto
funnelFlowQueueDto
=
new
FunnelFlowQueueDto
(
targetType
,
targetId
,
subtypeCode
,
targetRoleType
,
targetRoleId
,
flowNode
);
sendMessageQueue
(
funnelFlowQueueDto
);
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/biz/LabelUsedQueueBizImpl.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
biz
;
import
javax.jms.JMSException
;
import
javax.jms.ObjectMessage
;
import
javax.jms.Session
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.MessageCreator
;
import
org.springframework.stereotype.Component
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.constant.MQQueueConstant
;
import
com.pcloud.common.core.dto.LabelUsedMessageDto
;
import
com.pcloud.common.exceptions.BizException
;
/**
* @描述: 标签使用队列实现类
* @作者: shuyh
* @创建时间: 2017年5月23日
* @版本:1.0
* @描述: 标签使用队列实现类 @作者: shuyh @创建时间: 2017年5月23日 @版本:1.0
*/
@Component
(
"labelUsedQueueBiz"
)
public
class
LabelUsedQueueBizImpl
implements
LabelUsedQueueBiz
{
public
class
LabelUsedQueueBizImpl
implements
LabelUsedQueueBiz
{
/**
*
*/
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
LabelUsedQueueBizImpl
.
class
);
@Autowired
(
required
=
false
)
@Qualifier
(
"jmsLabelUsedTemplate"
)
private
JmsTemplate
jmsLabelUsedTemplate
;
@Autowired
private
AmqpTemplate
amqpTemplate
;
/**
* 发送队列
*/
@Override
@ParamLog
(
"标签使用QUEUE"
)
public
void
sendMessageQueue
(
LabelUsedMessageDto
labelUsedMessageDto
)
throws
BizException
{
MessageCreator
messageCreator
=
new
MessageCreator
()
{
@Override
public
ObjectMessage
createMessage
(
Session
session
)
throws
JMSException
{
return
session
.
createObjectMessage
(
labelUsedMessageDto
);
}
};
try
{
jmsLabelUsedTemplate
.
send
(
messageCreator
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送失败,"
+
e
.
getMessage
()
+
","
+
labelUsedMessageDto
,
e
);
throw
BizException
.
SEND_QUEUE_FAIL
;
}
logger
.
info
(
"发送成功,"
+
labelUsedMessageDto
);
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
LABEL_USED
,
labelUsedMessageDto
);
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/biz/MerchantDynamicQueueBizImpl.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
biz
;
import
com.pcloud.common.core.dto.DynamicDto
;
import
com.pcloud.common.exceptions.BizException
;
import
org.apache.activemq.command.ActiveMQQueue
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.MessageCreator
;
import
org.springframework.stereotype.Component
;
import
javax.jms.JMSException
;
import
javax.jms.ObjectMessage
;
import
javax.jms.Session
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.constant.MQQueueConstant
;
import
com.pcloud.common.core.dto.DynamicDto
;
import
com.pcloud.common.exceptions.BizException
;
/**
* @描述:
* @作者:lucas
* @创建时间:2017年12月14日,15:58
* @版本:1.0
*
* @作者:lucas @创建时间:2017年12月14日,15:58 @版本:1.0
*/
@Component
(
"merchantDynamicQueueBiz"
)
public
class
MerchantDynamicQueueBizImpl
implements
MerchantDynamicQueueBiz
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
MerchantDynamicQueueBizImpl
.
class
);
/**
* 消息模板
*/
@Autowired
(
required
=
false
)
@Qualifier
(
"jmsDynamicTemplate"
)
private
JmsTemplate
jmsDynamicTemplate
;
@Autowired
private
AmqpTemplate
amqpTemplate
;
@Override
public
void
send
(
DynamicDto
dynamicDto
)
throws
BizException
{
MessageCreator
messageCreator
=
new
MessageCreator
()
{
@Override
public
ObjectMessage
createMessage
(
Session
session
)
throws
JMSException
{
return
session
.
createObjectMessage
(
dynamicDto
);
}
};
try
{
jmsDynamicTemplate
.
send
(
messageCreator
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送失败,"
+
e
.
getMessage
()+
","
+
dynamicDto
,
e
);
throw
BizException
.
SEND_QUEUE_FAIL
;
}
@Override
@ParamLog
(
"动态监控QUEUE"
)
public
void
send
(
DynamicDto
dynamicDto
)
throws
BizException
{
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
MERCHANT_DYNAMIC
,
dynamicDto
);
}
logger
.
info
(
"发送成功,"
+
dynamicDto
);
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/biz/MessageBiz.java
View file @
c53cd2b9
...
...
@@ -2,6 +2,7 @@ package com.pcloud.common.core.biz;
import
com.pcloud.common.core.dto.SendAppMessageDto
;
import
com.pcloud.common.core.dto.SendEmailDto
;
import
com.pcloud.common.core.dto.SendMessageDto
;
import
com.pcloud.common.core.dto.SendNotifyDto
;
...
...
@@ -37,5 +38,10 @@ public interface MessageBiz {
* @param sendSMSDto
*/
void
sendSMS
(
SendMessageDto
smsParam
);
/**
* 短信推送
*/
void
sendAppMessage
(
SendAppMessageDto
sendAppMessageDto
);
}
pcloud-common-core/src/main/java/com/pcloud/common/core/biz/MessageBizImpl.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
biz
;
import
java.io.IOException
;
import
javax.jms.JMSException
;
import
javax.jms.Message
;
import
javax.jms.Session
;
import
org.codehaus.jackson.map.ObjectMapper
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.MessageCreator
;
import
org.springframework.stereotype.Component
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.constant.MQQueueConstant
;
import
com.pcloud.common.core.dto.SendAppMessageDto
;
import
com.pcloud.common.core.dto.SendEmailDto
;
import
com.pcloud.common.core.dto.SendMessageDto
;
import
com.pcloud.common.core.dto.SendNotifyDto
;
...
...
@@ -20,148 +16,82 @@ import com.pcloud.common.utils.mq.MqMessage;
import
com.pcloud.common.utils.mq.MqMessageTypeEnum
;
/**
*
* @描述:邮件业务实现
* @作者:shichunshan
* @创建时间:2016年6月24日,下午2:19:27
* @版本:1.0
* @创建时间:2016年6月24日,下午2:19:27 @版本:1.0
*/
@Component
(
"mailBiz"
)
public
class
MessageBizImpl
implements
MessageBiz
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
MessageBizImpl
.
class
);
@Component
(
"messageQueueBiz"
)
public
class
MessageBizImpl
implements
MessageBiz
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
MessageBizImpl
.
class
);
@Autowired
private
AmqpTemplate
amqpTemplate
;
/**
* 消息模板
* 发送邮件
*
* @param sendEmailDto
*/
@Autowired
(
required
=
false
)
@Qualifier
(
"jmsMessageTemplate"
)
private
JmsTemplate
jmsMessageTemplate
;
@Override
@ParamLog
(
"发送邮件"
)
public
void
sendEmail
(
SendEmailDto
sendEmailDto
)
{
MessageCreator
messageCreator
=
new
MessageCreator
()
{
@Override
public
Message
createMessage
(
Session
session
)
throws
JMSException
{
MqMessage
mqMessage
=
null
;
try
{
mqMessage
=
formateMessage
(
sendEmailDto
);
logger
.
info
(
"mqMessage+++++++++++"
+
mqMessage
);
}
catch
(
IOException
e
)
{
logger
.
error
(
"邮件发送失败,"
+
sendEmailDto
);
return
null
;
}
return
session
.
createObjectMessage
(
mqMessage
);
}
};
try
{
jmsMessageTemplate
.
send
(
messageCreator
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
String
content
=
objectMapper
.
writeValueAsString
(
sendEmailDto
);
MqMessage
mqMessage
=
new
MqMessage
(
MqMessageTypeEnum
.
EMAIL
,
content
);
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
MESSAGE
,
mqMessage
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"邮件发送失败,"
+
e
.
getMessage
()
+
","
+
sendEmailDto
,
e
);
return
;
}
logger
.
info
(
"邮件发送成功,"
+
sendEmailDto
);
}
/**
* 格式化邮件内容
*
* @param mailParam
* 邮件参数
* @return 队列消息
* @throws IOException
* 序列化为json错误
* 发送站内信
*/
private
MqMessage
formateMessage
(
SendEmailDto
sendEmailDto
)
throws
IOException
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
String
content
=
objectMapper
.
writeValueAsString
(
sendEmailDto
);
return
new
MqMessage
(
MqMessageTypeEnum
.
EMAIL
,
content
);
}
@Override
@ParamLog
(
"发送站内信"
)
public
void
sendLetter
(
SendNotifyDto
sendNotifyDto
)
{
MessageCreator
messageCreator
=
new
MessageCreator
()
{
@Override
public
Message
createMessage
(
Session
session
)
throws
JMSException
{
MqMessage
mqMessage
=
null
;
try
{
mqMessage
=
formateMessage
(
sendNotifyDto
);
logger
.
info
(
"mqMessage+++++++++++"
+
mqMessage
);
}
catch
(
IOException
e
)
{
logger
.
error
(
"站内信发送失败,"
+
sendNotifyDto
);
return
null
;
}
return
session
.
createObjectMessage
(
mqMessage
);
}
};
try
{
jmsMessageTemplate
.
send
(
messageCreator
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
String
content
=
objectMapper
.
writeValueAsString
(
sendNotifyDto
);
MqMessage
mqMessage
=
new
MqMessage
(
MqMessageTypeEnum
.
LETTER
,
content
);
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
MESSAGE
,
mqMessage
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"站内信发送失败,"
+
e
.
getMessage
()
+
","
+
sendNotifyDto
,
e
);
return
;
}
logger
.
info
(
"站内信发送成功,"
+
sendNotifyDto
);
}
/**
* 格式化站内信内容
*
* @param sendNotifyDto
* 站内信参数
* @return 队列消息
* @throws IOException
* 序列化为json错误
* 发送短信
*/
private
MqMessage
formateMessage
(
SendNotifyDto
sendNotifyDto
)
throws
IOException
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
String
content
=
objectMapper
.
writeValueAsString
(
sendNotifyDto
);
return
new
MqMessage
(
MqMessageTypeEnum
.
LETTER
,
content
);
}
@Override
public
void
sendSMS
(
SendMessageDto
smsParam
)
{
MessageCreator
messageCreator
=
new
MessageCreator
()
{
@Override
public
Message
createMessage
(
Session
session
)
throws
JMSException
{
MqMessage
mqMessage
=
null
;
try
{
mqMessage
=
formateMessage
(
smsParam
);
logger
.
info
(
"mqMessage+++++++++++"
+
mqMessage
);
}
catch
(
IOException
e
)
{
logger
.
error
(
"短信发送失败,"
+
smsParam
);
return
null
;
}
return
session
.
createObjectMessage
(
mqMessage
);
}
};
@ParamLog
(
"发送短信"
)
public
void
sendSMS
(
SendMessageDto
sendMessageDto
)
{
try
{
jmsMessageTemplate
.
send
(
messageCreator
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
String
content
=
objectMapper
.
writeValueAsString
(
sendMessageDto
);
MqMessage
mqMessage
=
new
MqMessage
(
MqMessageTypeEnum
.
SHORT_MESSAGE
,
content
);
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
MESSAGE
,
mqMessage
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"短信发送失败,"
+
e
.
getMessage
()
+
","
+
smsParam
,
e
);
return
;
logger
.
error
(
"短信发送失败,"
+
e
.
getMessage
()
+
","
+
sendMessageDto
,
e
);
}
logger
.
info
(
"短信发送成功,"
+
smsParam
);
}
/**
* 格式化内容
*
* @param sendSMSDto
* 邮件参数
* @return 队列消息
* @throws IOException
* 序列化为json错误
* 发送app推送
*/
private
MqMessage
formateMessage
(
SendMessageDto
smsParam
)
throws
IOException
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
String
content
=
objectMapper
.
writeValueAsString
(
smsParam
);
return
new
MqMessage
(
MqMessageTypeEnum
.
SHORT_MESSAGE
,
content
);
@Override
@ParamLog
(
"发送APP推送"
)
public
void
sendAppMessage
(
SendAppMessageDto
sendAppMessageDto
)
{
try
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
String
content
=
objectMapper
.
writeValueAsString
(
sendAppMessageDto
);
MqMessage
mqMessage
=
new
MqMessage
(
MqMessageTypeEnum
.
APP_MESSAGE
,
content
);
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
MESSAGE
,
mqMessage
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"APP推送发送失败,"
+
e
.
getMessage
()
+
","
+
sendAppMessageDto
,
e
);
}
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/biz/OperationLogQueueBizImpl.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
biz
;
import
javax.jms.JMSException
;
import
javax.jms.ObjectMessage
;
import
javax.jms.Session
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.MessageCreator
;
import
org.springframework.stereotype.Service
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.constant.MQQueueConstant
;
import
com.pcloud.common.core.dto.OperationLogDto
;
import
com.pcloud.common.exceptions.BizException
;
@Service
(
"operationLogQueueBiz"
)
public
class
OperationLogQueueBizImpl
implements
OperationLogQueueBiz
{
/**
*
*/
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
OperationLogQueueBizImpl
.
class
);
/**
* 消息模板
*/
@Autowired
(
required
=
false
)
@Qualifier
(
"jmsLogTemplate"
)
private
JmsTemplate
jmsLogTemplate
;
@Autowired
private
AmqpTemplate
amqpTemplate
;
@Override
@ParamLog
(
"日志记录QUEUE"
)
public
void
send
(
OperationLogDto
operationLog
)
throws
BizException
{
MessageCreator
messageCreator
=
new
MessageCreator
()
{
@Override
public
ObjectMessage
createMessage
(
Session
session
)
throws
JMSException
{
return
session
.
createObjectMessage
(
operationLog
);
}
};
try
{
jmsLogTemplate
.
send
(
messageCreator
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送失败,"
+
e
.
getMessage
()
+
","
+
operationLog
,
e
);
throw
BizException
.
SEND_QUEUE_FAIL
;
}
logger
.
info
(
"发送成功,"
+
operationLog
);
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
LOG
,
operationLog
);
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/biz/TemplateQueueBizImpl.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
biz
;
import
javax.jms.JMSException
;
import
javax.jms.ObjectMessage
;
import
javax.jms.Session
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.MessageCreator
;
import
org.springframework.stereotype.Component
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.constant.MQQueueConstant
;
import
com.pcloud.common.core.dto.TemplateMessageDto
;
import
com.pcloud.common.exceptions.BizException
;
...
...
@@ -19,39 +13,21 @@ import com.pcloud.common.exceptions.BizException;
*
* @描述:发送模板消息队列实现类
* @作者:songx
* @创建时间:2016年11月23日,下午4:53:43
* @版本:1.0
* @创建时间:2016年11月23日,下午4:53:43 @版本:1.0
*/
@Component
(
"templateQueueBiz"
)
public
class
TemplateQueueBizImpl
implements
TemplateQueueBiz
{
/**
*
*/
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
TemplateQueueBizImpl
.
class
);
@Autowired
(
required
=
false
)
@Qualifier
(
"jmsTemplateTemplate"
)
private
JmsTemplate
jmsTemplateTemplate
;
@Autowired
private
AmqpTemplate
amqpTemplate
;
/**
* 发送
队列
* 发送
模板消息
*/
@Override
@ParamLog
(
"发送模板消息QUEUE"
)
public
void
sendMessageQueue
(
TemplateMessageDto
templateMessageDto
)
throws
BizException
{
MessageCreator
messageCreator
=
new
MessageCreator
()
{
@Override
public
ObjectMessage
createMessage
(
Session
session
)
throws
JMSException
{
return
session
.
createObjectMessage
(
templateMessageDto
);
}
};
try
{
jmsTemplateTemplate
.
send
(
messageCreator
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送失败,"
+
e
.
getMessage
()
+
","
+
templateMessageDto
,
e
);
throw
BizException
.
SEND_QUEUE_FAIL
;
}
logger
.
info
(
"发送成功,"
+
templateMessageDto
);
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
TEMPLATE
,
templateMessageDto
);
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/biz/UserActionQueueBizImpl.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
biz
;
import
javax.jms.JMSException
;
import
javax.jms.ObjectMessage
;
import
javax.jms.Session
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.MessageCreator
;
import
org.springframework.stereotype.Service
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.constant.MQQueueConstant
;
import
com.pcloud.common.core.dto.UserActionMessageDto
;
import
com.pcloud.common.exceptions.BizException
;
/**
* @描述: 发送模板消息队列实现类
* @作者: shuyh
* @创建时间: 2017年5月23日
* @版本:1.0
* @描述: 发送模板消息队列实现类 @作者: shuyh @创建时间: 2017年5月23日 @版本:1.0
*/
@Service
(
"userActionQueueBiz"
)
public
class
UserActionQueueBizImpl
implements
UserActionQueueBiz
{
public
class
UserActionQueueBizImpl
implements
UserActionQueueBiz
{
/**
*
*/
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
UserActionQueueBizImpl
.
class
);
@Autowired
(
required
=
false
)
@Qualifier
(
"jmsUserActionTemplate"
)
private
JmsTemplate
jmsUserActionTemplate
;
@Autowired
private
AmqpTemplate
amqpTemplate
;
/**
*
发送队列
*
用户行为QUEUE
*/
@Override
@ParamLog
(
"用户行为QUEUE"
)
public
void
sendMessageQueue
(
UserActionMessageDto
userActionMessageDto
)
throws
BizException
{
MessageCreator
messageCreator
=
new
MessageCreator
()
{
@Override
public
ObjectMessage
createMessage
(
Session
session
)
throws
JMSException
{
return
session
.
createObjectMessage
(
userActionMessageDto
);
}
};
try
{
jmsUserActionTemplate
.
send
(
messageCreator
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送失败,"
+
e
.
getMessage
()
+
","
+
userActionMessageDto
,
e
);
throw
BizException
.
SEND_QUEUE_FAIL
;
}
logger
.
info
(
"发送成功,"
+
userActionMessageDto
);
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
USER_ACTION
,
userActionMessageDto
);
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/biz/WeektaskQueueBizImpl.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
biz
;
import
com.pcloud.common.core.dto.WeektaskMessageDto
;
import
com.pcloud.common.exceptions.BizException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.jms.core.JmsTemplate
;
import
org.springframework.jms.core.MessageCreator
;
import
org.springframework.stereotype.Component
;
import
javax.jms.JMSException
;
import
javax.jms.ObjectMessage
;
import
javax.jms.Session
;
import
com.pcloud.common.core.aspect.ParamLog
;
import
com.pcloud.common.core.constant.MQQueueConstant
;
import
com.pcloud.common.core.dto.WeektaskMessageDto
;
import
com.pcloud.common.exceptions.BizException
;
/**
* 编辑周任务队列实现
...
...
@@ -21,37 +16,18 @@ import javax.jms.Session;
* @create 2017-09-21 09:33
**/
@Component
(
"weektaskQueueBiz"
)
public
class
WeektaskQueueBizImpl
implements
WeektaskQueueBiz
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
WeektaskQueueBizImpl
.
class
);
@Autowired
(
required
=
false
)
@Qualifier
(
"jmsWeektaskTemplate"
)
private
JmsTemplate
jmsWeekstaskTemplate
;
// @Autowired(required= false)
// @Qualifier("raystask")
// private ActiveMQQueue templateQueue;
/**
* 发送队列
*/
@Override
public
void
sendMessageQueue
(
WeektaskMessageDto
weektaskMessageDto
)
throws
BizException
{
MessageCreator
messageCreator
=
new
MessageCreator
()
{
@Override
public
ObjectMessage
createMessage
(
Session
session
)
throws
JMSException
{
return
session
.
createObjectMessage
(
weektaskMessageDto
);
}
};
try
{
jmsWeekstaskTemplate
.
send
(
messageCreator
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送失败,"
+
e
.
getMessage
()
+
","
+
weektaskMessageDto
,
e
);
throw
BizException
.
SEND_QUEUE_FAIL
;
}
logger
.
info
(
"发送成功,"
+
weektaskMessageDto
);
}
public
class
WeektaskQueueBizImpl
implements
WeektaskQueueBiz
{
@Autowired
private
AmqpTemplate
amqpTemplate
;
/**
* 发送队列
*/
@Override
@ParamLog
(
"红榜任务QUEUE"
)
public
void
sendMessageQueue
(
WeektaskMessageDto
weektaskMessageDto
)
throws
BizException
{
amqpTemplate
.
convertAndSend
(
MQQueueConstant
.
WEEK_TASK
,
weektaskMessageDto
);
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/constant/ConvertEnum.java
View file @
c53cd2b9
/**
*
*
*/
package
com
.
pcloud
.
common
.
core
.
constant
;
/**
*
*
* @author:songx
* @date:2017年2月27日,下午4:29:06
*
* 使用RabbitMQ需要去MqQueueConstant中声明队列名称,枚举的第二个值将不再使用,第一个值正常使用
* @date:2017年2月27日,下午4:29:06 使用RabbitMQ需要去MqQueueConstant中声明队列名称,枚举的第二个值将不再使用,第一个值正常使用
* modify by songx at 2018-08-22
*/
public
enum
ConvertEnum
{
/**
* 应用转码
*/
APP
(
"APP"
,
"convert2App"
),
/**
* 资源中心转码
*/
RESOURCE
(
"RESOURCE"
,
"convert2Resource"
),
/**
* 报名时的视频转换
*/
MATCH
(
"MATCH"
,
"convert2Resource"
),
/**
* 资源中心即时转换
*/
INSTANT_RESOURCE
(
"INSTANT_RESOURCE"
,
"convert2Resource"
),
/**
* 报名应用
*/
MATCH_APP
(
"MATCH_APP"
,
"convert2MatchApp"
),
/**
* 内容中心
*/
CONTENT
(
"CONTENT"
,
"convert2Content"
),
/**
* 内容中心->题库:文件记忆功能
*/
PRETEST_FILEMEMORY
(
"PRETEST_FILEMEMORY"
,
"convert2PretestFilememory"
),
/**
* 小游戏
*/
RAYSTASK
(
"RAYSTASK"
,
"convert2Raystask"
),
/**
* 圈子应用
*/
GROUP_APP
(
"GROUP_APP"
,
"convert2GroupApp"
),
/**
* 投票应用
*/
VOTE_APP
(
"VOTE_APP"
,
"convert2VoteApp"
),
/**
* 教育表格应用
*/
EF_APP
(
"EF_APP"
,
"convert2EfApp"
),
/**
* 测试工具
*/
TEST_APP
(
"TEST_APP"
,
"convert2TestApp"
),
/**
* 直播工具
*/
LIVE_APP
(
"LIVE_APP"
,
"convert2LiveApp"
),
/**
* 视频课
*/
VIDEO_LESSON
(
"VIDEO_LESSON"
,
"convert2VideoLesson"
);
/**
* 值
*/
public
final
String
value
;
/**
* 模板名称
*/
public
final
String
jmsTemplate
;
/**
* 构造
*
* @param value
*/
private
ConvertEnum
(
String
value
,
String
jmsTemplate
)
{
this
.
value
=
value
;
this
.
jmsTemplate
=
jmsTemplate
;
}
/**
* 应用转码
*/
APP
(
"APP"
),
/**
* 资源中心转码
*/
RESOURCE
(
"RESOURCE"
),
/**
* 报名时的视频转换
*/
MATCH
(
"MATCH"
),
/**
* 资源中心即时转换
*/
INSTANT_RESOURCE
(
"INSTANT_RESOURCE"
),
/**
* 报名应用
*/
MATCH_APP
(
"MATCH_APP"
),
/**
* 内容中心
*/
CONTENT
(
"CONTENT"
),
/**
* 内容中心->题库:文件记忆功能
*/
PRETEST_FILEMEMORY
(
"PRETEST_FILEMEMORY"
),
/**
* 小游戏
*/
RAYSTASK
(
"RAYSTASK"
),
/**
* 圈子应用
*/
GROUP_APP
(
"GROUP_APP"
),
/**
* 投票应用
*/
VOTE_APP
(
"VOTE_APP"
),
/**
* 教育表格应用
*/
EF_APP
(
"EF_APP"
),
/**
* 测试工具
*/
TEST_APP
(
"TEST_APP"
),
/**
* 直播工具
*/
LIVE_APP
(
"LIVE_APP"
),
/**
* 视频课
*/
VIDEO_LESSON
(
"VIDEO_LESSON"
),
/**
* 音频课
*/
AUDIO_LESSON
(
"AUDIO_LESSON"
),
/**
* 音频纯听
*/
AUDIO_LISTEN
(
"AUDIO_LISTEN"
);
/**
* 值
*/
public
final
String
value
;
/**
* 构造
*
* @param value
*/
private
ConvertEnum
(
String
value
)
{
this
.
value
=
value
;
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/constant/MQQueueConstant.java
View file @
c53cd2b9
...
...
@@ -81,6 +81,11 @@ public class MQQueueConstant {
public
static
final
String
CONVERT_TO_VOTEAPP
=
"convert2VoteAppQueue"
;
/**
* 文件转码结束(音视频)->音频课/纯听
*/
public
static
final
String
CONVERT_TO_AUDIOLESSON
=
"convert2AudioLessonQueue"
;
/**
* 数据埋点
*/
public
static
final
String
FRONT_EVENT
=
"frontEventQueue"
;
...
...
pcloud-common-core/src/main/java/com/pcloud/common/core/constant/MQTopicProducer.java
View file @
c53cd2b9
...
...
@@ -16,34 +16,260 @@ public class MQTopicProducer {
*/
public
static
final
String
FILE_TRANSCODE
=
"topic.fileTranscode"
;
/**
* 报名新增用户
*/
public
static
final
String
BM_ADD_USER
=
"topic.bmAddUser"
;
/**
* 应用新增
*/
public
static
final
String
APP_ADD
=
"topic.appAdd"
;
/**
* 应用修改
*/
public
static
final
String
APP_UPDATE
=
"topic.appUpdate"
;
/**
* 应用删除
*/
public
static
final
String
APP_DELETE
=
"topic.appDelete"
;
/**
* 应用删除(新)
*/
public
static
final
String
APP_DELETE_NEW
=
"topic.appDeleteNew"
;
/**
* 应用审核
*/
public
static
final
String
APP_AUDIT
=
"topic.appAudit"
;
/**
* 选择默认渠道
*/
public
static
final
String
CHOOSE_DEFAULT_CHANNEL
=
"topic.chooseDefaultChannel"
;
/**
* 删除视频
*/
public
static
final
String
DELETE_VIDEO
=
"topic.deleteVideo"
;
/**
* 标签修改
*/
public
static
final
String
LABEL_UPDATE
=
"topic.labelUpdate"
;
/**
* 支付
*/
public
static
final
String
PAYMENT
=
"topic.payment"
;
/**
* TIP
*/
public
static
final
String
TIP
=
"topic.tip"
;
/**
* 订单完成
*/
public
static
final
String
FINISH_ORDER
=
"topic.finishOrder"
;
/**
* 资源修改
*/
public
static
final
String
RESOURCE_UPDATE
=
"topic.resourceUpdate"
;
/**
* 资源删除
*/
public
static
final
String
RESOURCE_DELETE
=
"topic.resourceDelete"
;
/**
* 扫码记录
*/
public
static
final
String
SCAN_RECORD
=
"topic.scanRecord"
;
/**
* 图书删除
*/
public
static
final
String
BOOK_DELETE
=
"topic.bookDelete"
;
/**
* BOOKTHAW
*/
public
static
final
String
BOOK_THAW
=
"topic.bookThaw"
;
/**
* TEMPLETAPPCREATE
*/
public
static
final
String
TEMPLET_APP_CREATE
=
"topic.templetAppCreate"
;
/**
* PERMISSION
*/
public
static
final
String
PERMISSION
=
"topic.permission"
;
/**
* PROMOTION_EXPIRE
*/
public
static
final
String
PROMOTION_EXPIRE
=
"topic.promotionExpire"
;
/**
* 商品修改
*/
public
static
final
String
PRODUCT_UPDATE
=
"topic.productUpdate"
;
/**
* 商品删除
*/
public
static
final
String
PRODUCT_DELETE
=
"topic.productDelete"
;
/**
* 商品审核
*/
public
static
final
String
PRODUCT_AUDIT
=
"topic.productAudit"
;
/**
* 商品图片1修改
*/
public
static
final
String
PRODUCT_PIC1_UPDATE
=
"topic.productPic1Update"
;
/**
* 用户注册
*/
public
static
final
String
REGISTER_PARTY
=
"topic.registerParty"
;
/**
* 用户修改
*/
public
static
final
String
UPDATE_PARTY
=
"topic.updateParty"
;
/**
* 问答确认
*/
public
static
final
String
QA_ASK
=
"topic.qaAsk"
;
/**
* 问答完成
*/
public
static
final
String
QA_FINISH
=
"topic.qaFinish"
;
/**
* 问答答案
*/
public
static
final
String
QA_ANSWER
=
"topic.qaAnswer"
;
/**
* 问答取消
*/
public
static
final
String
QA_REFUSE
=
"topic.qaRefuse"
;
/**
* QR_MESSAGE_UPDATE
*/
public
static
final
String
QR_MESSAGE_UPDATE
=
"topic.qrMessageUpdate"
;
/**
* GIVE_GIFT
*/
public
static
final
String
GIVE_GIFT
=
"topic.giveGift"
;
/**
* 修改密码
*/
public
static
final
String
UPDATE_PWD
=
"topic.updatePwd"
;
/**
* topic交换机名称(勿改)
*/
public
static
final
String
EXCHAGE
=
"rays.topic"
;
/**
* 管理消息
*/
public
static
final
String
MANAGE_MESSAGE
=
"topic.manageMessage"
;
/**
* RETURN_4_ADVISER
*/
public
static
final
String
RETURN_4_ADVISER
=
"topic.return4adviser"
;
/**
* 退款
*/
public
static
final
String
REFUND
=
"topic.refund"
;
/**
* 退货
*/
public
static
final
String
REFUND_PRODUCT
=
"topic.refundProduct"
;
/**
* 发货
*/
public
static
final
String
SEND_PRODUCT
=
"topic.sendProduct"
;
/**
* 确认收货
*/
public
static
final
String
CONFIRM_ORDER
=
"topic.confirmOrder"
;
/**
* 申请退货
*/
public
static
final
String
APPLY_REFUND_PRODUCT
=
"topic.applyRefundProduct"
;
/**
* 取消订单
*/
public
static
final
String
CANCEL_ORDER
=
"topic.cancelOrder"
;
/**
* 模板二维码扫描
*/
public
static
final
String
TEMP_QRCODE_SCAN
=
"topic.tempQrcodeScan"
;
/**
* 删除二维码
*/
public
static
final
String
DELETE_QRCODE
=
"topic.deleteQrcode"
;
/**
* 二维码图书修改
*/
public
static
final
String
QRCODE_BOOK_UPDATE
=
"topic.qrcodeBookUpdate"
;
/**
* 重置
*/
public
static
final
String
RECHARGE
=
"topic.recharge"
;
/**
* 改变显示状态
*/
public
static
final
String
CHANGE_SHOW_STATE
=
"topic.changeShowState"
;
/**
* 删除合作出版社
*/
public
static
final
String
DELETE_COOPERATIVE_AGENT
=
"topic.deleteCooperativeAgent"
;
/**
* TASK_BONUS
*/
public
static
final
String
TASK_BONUS
=
"topic.taskBonus"
;
/**
* 读者消息
*/
public
static
final
String
READER_MESSAGE
=
"topic.readerMessage"
;
/**
* 记录用户习惯
*/
public
static
final
String
RECORD_USER_HABIT
=
"topic.recordUserHabit"
;
/**
* topic交换机名称(勿改)
*/
public
static
final
String
EXCHAGE
=
"rays.topic"
;
/**
* 更新图书封面图
...
...
pcloud-common-core/src/main/java/com/pcloud/common/core/constant/ProductTypeConstant.java
View file @
c53cd2b9
...
...
@@ -208,6 +208,21 @@ public class ProductTypeConstant {
public
static
final
String
PRETESTAPP
=
"PRETESTAPP"
;
/**
* 音频
*/
public
static
final
String
AUDIO_RESOURCE
=
"AUDIO_RESOURCE"
;
/**
* 问答
*/
public
static
final
String
QA_APP
=
"QA_APP"
;
/**
* 电子书
*/
public
static
final
String
EBOOK_APP
=
"EBOOK_APP"
;
/**
* 热门作品类型
*/
public
static
final
String
[]
HOT_PRODUCT_TYPE
=
{
QA
,
PDF
,
VIDEO
,
PRETEST
};
...
...
@@ -233,7 +248,7 @@ public class ProductTypeConstant {
* 应用型作品(伴随应用使用)
*/
public
static
final
String
[]
APP_PRODUCT
=
{
LOOK
,
LIVE
,
TUTOR
,
GROUP
,
ZSCORE
,
VOTE
,
CLOCK
,
TEST
,
AUDIOAPP
,
ANSWER
,
EF
,
MUSIC
,
VIDEO_COURSE
,
PRETESTAPP
};
EF
,
MUSIC
,
VIDEO_COURSE
,
PRETESTAPP
,
AUDIO_RESOURCE
,
QA_APP
,
EBOOK_APP
};
/**
* 数据平台埋点型作品
...
...
pcloud-common-core/src/main/java/com/pcloud/common/core/constant/SceneCode.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
constant
;
/**
* 场景值
* @author 作者 : lili
* @date 创建时间:2016年12月2日 上午9:10:49
* @version 1.0
* @return
*/
* 场景值
* @author 作者 : lili
* @date 创建时间:2016年12月2日 上午9:10:49
* @version 1.0
* @return
*/
public
enum
SceneCode
{
/**
* 奖金发放通知
*/
PRIZE_SEND_SCENE
(
"PRIZE_SEND_SCENE"
),
/**
* 服务完成通知
*/
SERVICE_FINISH_SCENE
(
"SERVICE_FINISH_SCENE"
),
/**
* 新订单通知
*/
NEW_ORDER_SCENE
(
"NEW_ORDER_SCENE"
),
/**
* 订单支付成功
*/
PAY_SUCCESS_SCENE
(
"PAY_SUCCESS_SCENE"
),
/**
* 报名成功提醒
*/
BM_SUCCESS_SCENE
(
"BM_SUCCESS_SCENE"
),
/**
* 商家回复提醒
*/
REPLY_SCENE
(
"REPLY_SCENE"
),
/**
* 拒绝提醒
*/
REFUSE_SCENE
(
"REFUSE_SCENE"
),
/**
* 用户提问通知
*/
USER_QUESTION_SCENE
(
"USER_QUESTION_SCENE"
),
/**
* 退货申请提醒
*/
REFUND_APPLICATION_SCENE
(
"REFUND_APPLICATION_SCENE"
),
/**
* 退货失败通知
*/
REFUND_REFUSE_SCENE
(
"REFUND_REFUSE_SCENE"
),
/**
* 退货确认通知
*/
REFUND_CONFIRM_SCENE
(
"REFUND_CONFIRM_SCENE"
),
/**
*
订单确认收货
通知
*
退货完成
通知
*/
CONFIRM_GOODS_SCENE
(
"CONFIRM_GOODS
_SCENE"
),
REFUND_FINISH_SCENE
(
"REFUND_FINISH
_SCENE"
),
/**
* 退款成功
*/
REFUND_SUCCESS_SCENE
(
"REFUND_SUCCESS_SCENE"
),
/**
* 订单发货提醒
*/
SIPPING_SCENE
(
"SIPPING_SCENE"
),
/**
* 审核结果通知
*/
AUDIT_RESULT_SCENE
(
"AUDIT_RESULT_SCENE"
),
/**
* 任务处理结果提醒
*/
TASK_HANDLE_RESULT_SCENE
(
"TASK_HANDLE_RESULT_SCENE"
),
/**
* 订单消息通知
*/
ORDER_MESSAGE_SCENE
(
"ORDER_MESSAGE_SCENE"
),
/**
* 退货申请结果通知
*/
REFUND_APPLICATION_RESULT_SCENE
(
"REFUND_APPLICATION_RESULT_SCENE"
),
/**
* 确认登录提醒
*/
CONFIRM_LOGIN_SCENE
(
"CONFIRM_LOGIN_SCENE"
),
/**
* 成功报名付费通知
*/
ENROLL_SUCCESS_SCENE
(
"ENROLL_SUCCESS_SCENE"
),
/**
* 预约提醒
*/
APPOINT_SCENE
(
"APPOINT_SCENE"
),
/**
* 排名通知
*/
RANK_SCENE
(
"RANK_SCENE"
),
/**
* 学习进度提醒
*/
LEARN_PROGRESS_SCENE
(
"LEARN_PROGRESS_SCENE"
),
/**
* 项目任务提醒
*/
...
...
@@ -140,12 +112,8 @@ public enum SceneCode {
/**
* 会员到期提醒
*/
MEMBERSHIP_EXPIRE
(
"MEMBERSHIP_EXPIRE"
),
/**
* 奖金发放通知
*/
PRIZE_SEND_SCENE
(
"PRIZE_SEND_SCENE"
);
MEMBERSHIP_EXPIRE
(
"MEMBERSHIP_EXPIRE"
);
/**
* 值
*/
...
...
@@ -153,7 +121,7 @@ public enum SceneCode {
/**
* 构造
*
*
* @param value
*/
private
SceneCode
(
String
value
)
{
...
...
pcloud-common-core/src/main/java/com/pcloud/common/core/constant/WeektaskCode.java
View file @
c53cd2b9
...
...
@@ -36,7 +36,18 @@ public enum WeektaskCode {
CLICK_VIEW_GAINS
(
"click_view_gains"
),
//做书应用→创建音频应用→最后一步点击保存
CLICK_SAVE_AUDIO_APP
(
"click_save_audio_app"
),
//关联应用到二维码
RELATE_APP_TO_QRCODE
(
"relate_app_to_qrcode"
),
//查看案例不少于三个 并且提留时间高于90S
VIEW_SHARE_CASE
(
"view_share_case"
),
//点击进入编创大赛
CLICK_NECIS_MATCH
(
"click_necis_match"
),
//扫描二维码进入直播课
SCAN_WATCH_LIVEAPP
(
"scan_watch_liveapp"
),
//修改书刊信息
UPDATE_BOOK_INFO
(
"update_book_info"
),
//调整应用顺序
SET_STEP
(
"set_step"
),
/**
* -------通用埋点------
*/
...
...
@@ -98,6 +109,36 @@ public enum WeektaskCode {
ADD_SUPERMERCHANT_COURSE
(
"add_supermerchant_course"
),
//开始直播
START_LIVE
(
"start_live"
),
//新增课程
ADD_TO_TABLE
(
"add_to_table"
),
//APP端开始直播
START_LIVEAPP
(
"start_liveapp"
),
//互动区发言
SPEAK_LIVEAPP
(
"speak_liveapp"
),
//退出直播
END_LIVEAPP
(
"end_liveapp"
),
//发布动态
POST_NOTE_APP
(
"post_note_app"
),
//发布动态图片动态
POST_PIC_NOTE_AND_TOP
(
"post_pic_note_and_top"
),
//建立营销机制
CREATE_MARKETING
(
"create_marketing"
),
//配置押题宝典
CONFIG_TREASURE
(
"config_treasure"
),
//读者圈发布PDF动态
W_POST_PDF_NOTE
(
"w_post_pdf_note"
),
//周任务配置二维码消息
CONFIG_WEEK_QRCODE
(
"config_week_qrcode"
),
//发布直播讲义
MODIFY_WORK
(
"modify_work"
),
//体验录播模式
EXPERIENCE_VIDEO
(
"experience_video"
),
//勾选超级作者作品
ADD_SUPER_COURSE
(
"add_super_course"
),
//读者端发布动态
C_PUBLISH_DYNAMIC
(
"c_publish_dynamic"
),
//专题问答设置免费
SET_FREE
(
"set_free"
),
//----------------------------------成就任务-------------------
/**
* 读者在读者圈中发动态
...
...
@@ -485,71 +526,131 @@ public enum WeektaskCode {
/**
* 与读者交互
*/
W4_GROUP_COMMENT
(
"w4_group_comment"
),
W5_CREATE_BOOK
(
"w5_create_book"
),
/**
* 新增二维码
*/
W5_CREATE_QRCODE
(
"w5_create_qrcode"
),
/**
* 创建直播课应用
*/
W5_CREATE_LIVEAPP
(
"w5_create_liveapp"
),
/**
* 完成手机直播
*/
W5_FINISH_LIVEAPP
(
"w5_finish_liveapp"
),
/**
* 创建读者圈应用
*/
W5_CREATE_GROUP
(
"w5_create_group"
),
/**
* 更新读者圈应用
*/
W5_UPDATE_GROUP
(
"w5_update_group"
),
/**
* 创建答案应用
*/
W5_CREATE_ANSWER_APP
(
"w5_create_answer_app"
),
/**
* 创建视频应用
*/
W5_CREATE_VIDEO_APP
(
"w5_create_video_app"
),
/**
* 建立营销机制
*/
W5_CREATE_MARKETING
(
"w5_create_marketing"
),
/**
* 打造大IP图书
*/
W5_MAKE_IP_BOOK
(
"w5_make_ip_book"
),
/**
* 修改书刊信息
*/
W5_UPDATE_BOOK_INFO
(
"w5_update_book_info"
),
/**
* 创建音频应用
*/
W5_CREATE_AUDIO_APP
(
"w5_create_audio_app"
),
/**
* 创建打卡应用
*/
W5_CREATE_CLOCK_APP
(
"w5_create_clock_app"
),
/**
* 创建精品文章应用
*/
W5_CREATE_ARTICLE_APP
(
"w5_create_article_app"
),
/**
* 创建趣味测试应用
*/
W5_CREATE_TASTETEST_APP
(
"w5_create_tastetest_app"
),
/**
* 调整应用呈现顺序
*/
W5_SORT_APP
(
"w5_sort_app"
),
/**
*
回复图文资讯评论
*
查看纸书数据
*/
W
4_ARTICLE_REPLY
(
"w4_article_reply
"
),
W
5_VIEW_BOOK_DATA
(
"w5_view_book_data
"
),
/**
*
完善纸书问答合集
*
创建视频应用并关联书刊
*/
W
4_CREATE_QA
(
"w4_create_qa
"
),
W
5_CREATE_VIDEO_APP_AND_RELATE
(
"w5_create_video_app_and_relate
"
),
/**
*
建立衍生文本
*
更新PDF应用并发布到读者圈
*/
W
4_UPLOAD_PDF
(
"w4_upload
_pdf"
),
W
5_UPDATE_GROUP_BY_PDF
(
"w5_update_group_by
_pdf"
),
/**
* 创建
视听内容
* 创建
愿望单应用
*/
W
4_UPLOAD_VIDEO
(
"w4_upload_video
"
),
W
5_CREATE_WISHLIST_APP
(
"w5_create_wishlist_app
"
),
/**
*
让读者听见纸书
*
创建专题问答应用
*/
W4_UPLOAD_AUDIO
(
"w4_upload_audio
"
),
W5_CREATE_EF_APP
(
"w5_create_ef_app
"
),
/**
*
配套纸书插画图解
*
更新读者交流圈动态2
*/
W
4_UPLOAD_PIC
(
"w4_upload_pic
"
),
W
5_CREATE_GROUP_FOR_PDF
(
"w5_update_group_for_pdf
"
),
/**
*
呈现纸书全方位资讯
*
配置二维码消息
*/
W
4_CREATE_SPECIAL
(
"w4_create_special
"
),
W
5_CONFIG_QRCODE
(
"w5_config_qrcode
"
),
/**
*
秀出红榜任务排行
*
发布直播讲义
*/
W
4_SHARE_REPORT
(
"w4_share_report
"
),
W
5_PUBLISH_LECTURE
(
"w5_publish_lecture
"
),
/**
*
app发布语音动态
*
体验录播模式
*/
W
4_GROUP_VOICE_POST
(
"w4_group_voice_post
"
),
W
5_EXPERIENCE_VIDEO
(
"w5_experience_video
"
),
/**
*
掌握纸书使用高峰
*
审核动态
*/
W
4_VIEW_BOOK_TIDE
(
"w4_view_book_tide
"
),
W
5_AUDIT_DYNAM
(
"w5_audit_dynam
"
),
/**
*
二维码数据分析
*
新建直播课应用
*/
W
4_VIEW_QRCODE_TIDE
(
"w4_view_qrcode_tide
"
),
W
5_CREATE_SUPER_LIVEAPP
(
"w5_create_super_liveapp
"
),
/**
*
了解纸书数据
*
新建延伸阅读应用
*/
W
4_VIEW_ANALYSIS
(
"w4_view_analysis
"
),
W
5_CREATE_PDF
(
"w5_create_pdf
"
),
/**
*
查看纸书收益
*
新建在线题库应用
*/
W
4_VIEW_GAINS
(
"w4_view_gains
"
),
W
5_CREATE_QUESTION_BANK
(
"w5_create_question_bank
"
),
/**
*
建立基于纸书内容的题库
*
标准服务预览
*/
W4_UPLOAD_ITEM_BANK
(
"w4_upload_item_bank
"
),
W5_VIEW_GUIDE
(
"w5_view_guide
"
),
/**
*
纸书内容读者自测
*
创建投票应用
*/
W
4_CREATE_ITEM_BANK
(
"w4_create_item_bank
"
),
W
5_CREATE_VOTE_APP
(
"w5_create_vote_app
"
),
/**
*
本周直播课
*
创建抽奖应用
*/
W
4_BEGIN_LIVE
(
"w4_begin_live
"
),
W
5_CREATE_DRAW_APP
(
"w5_create_draw_app
"
),
;
public
final
String
code
;
...
...
pcloud-common-core/src/main/java/com/pcloud/common/core/dao/BaseDao.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
dao
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.ibatis.session.SqlSession
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
com.pcloud.common.page.PageBean
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
/**
* @描述:数据访问层基础支撑接口. @作者:DiSeng.H
* @创建时间:2016年3月11日,下午4:02:32 @版本:1.0
*/
public
interface
BaseDao
<
T
>
{
/**
* 根据实体对象新增记录.
*
* @param entity
* .
* @return id .
*/
long
insert
(
T
entity
);
/**
* 批量保存对象.
*
* @param entity
* .
* @return id .
*/
long
insert
(
List
<
T
>
list
);
/**
* 更新实体对应的记录.
*
* @param entity
* .
* @return
*/
long
update
(
T
entity
);
/**
* 更新实体对应的记录.
*
* @param entity
* @param sqlId
* @return
*/
long
update
(
T
entity
,
String
sqlId
);
/**
* 批量更新对象.
*
* @param entity
* .
* @return int .
*/
long
update
(
List
<
T
>
list
);
/**
* 根据ID查找记录.
*
* @param id
* .
* @return entity .
*/
T
getById
(
long
id
);
/**
* 根据ID删除记录.
*
* @param id
* .
* @return
*/
long
deleteById
(
long
id
);
/**
* 分页查询 .
*
* @param pageParam
* 分页参数.
* @param paramMap
* 业务条件查询参数.
* @return
*/
PageBean
listPage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
);
PageBean
listSimplePage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
);
PageBean
listPage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
);
<
C
>
PageBeanNew
<
C
>
listPageNew
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
);
PageBean
listPage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
,
String
countSqlId
);
/**
* 根据条件查询 listBy: <br/>
*
* @param paramMap
* @return 返回集合
*/
List
<
T
>
listBy
(
Map
<
String
,
Object
>
paramMap
);
List
<
Object
>
listBy
(
Map
<
String
,
Object
>
paramMap
,
String
sqlId
);
/**
* 根据条件查询 listBy: <br/>
*
* @param paramMap
* @return 返回实体
*/
T
getBy
(
Map
<
String
,
Object
>
paramMap
);
Object
getBy
(
Map
<
String
,
Object
>
paramMap
,
String
sqlId
);
/**
* 根据序列名称获取下一个值
*
* @return
*/
String
getSeqNextValue
(
String
seqName
);
SqlSessionTemplate
getSessionTemplate
();
SqlSession
getSqlSession
();
}
package
com
.
pcloud
.
common
.
core
.
dao
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.ibatis.session.SqlSession
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
com.pcloud.common.page.PageBean
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
/**
* @描述:数据访问层基础支撑接口. @作者:DiSeng.H
* @创建时间:2016年3月11日,下午4:02:32 @版本:1.0
*/
public
interface
BaseDao
<
T
>
{
/**
* 根据实体对象新增记录.
*
* @param entity .
* @return id .
*/
long
insert
(
T
entity
);
/**
* 批量保存对象.
*
* @param entity .
* @return id .
*/
long
insert
(
List
<
T
>
list
);
/**
* 更新实体对应的记录.
*
* @param entity .
* @return
*/
long
update
(
T
entity
);
/**
* 更新实体对应的记录.
*
* @param entity
* @param sqlId
* @return
*/
long
update
(
T
entity
,
String
sqlId
);
/**
* 更新实体对应的记录.
*
* @param entity
* @param sqlId
* @param errorMessage 错误消息
* @return
*/
long
update
(
T
entity
,
String
sqlId
,
String
errorMessage
);
/**
* 批量更新对象.
*
* @param entity .
* @return int .
*/
long
update
(
List
<
T
>
list
);
/**
* 根据ID查找记录.
*
* @param id .
* @return entity .
*/
T
getById
(
long
id
);
/**
* 根据ID删除记录.
*
* @param id .
* @return
*/
long
deleteById
(
long
id
);
/**
* 分页查询 .
*
* @param pageParam 分页参数.
* @param paramMap 业务条件查询参数.
* @return
*/
PageBean
listPage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
);
PageBean
listSimplePage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
);
PageBean
listPage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
);
<
C
>
PageBeanNew
<
C
>
listPageNew
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
);
PageBean
listPage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
,
String
countSqlId
);
/**
* 根据条件查询 listBy: <br/>
*
* @param paramMap
* @return 返回集合
*/
List
<
T
>
listBy
(
Map
<
String
,
Object
>
paramMap
);
List
<
Object
>
listBy
(
Map
<
String
,
Object
>
paramMap
,
String
sqlId
);
/**
* 根据条件查询 listBy: <br/>
*
* @param paramMap
* @return 返回实体
*/
T
getBy
(
Map
<
String
,
Object
>
paramMap
);
Object
getBy
(
Map
<
String
,
Object
>
paramMap
,
String
sqlId
);
/**
* 根据序列名称获取下一个值
*
* @return
*/
String
getSeqNextValue
(
String
seqName
);
SqlSessionTemplate
getSessionTemplate
();
SqlSession
getSqlSession
();
}
pcloud-common-core/src/main/java/com/pcloud/common/core/dao/BaseDaoImpl.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
dao
;
import
java.sql.Connection
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.ibatis.jdbc.SqlRunner
;
import
org.apache.ibatis.session.RowBounds
;
import
org.apache.ibatis.session.SqlSession
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.pcloud.common.core.mybatis.interceptor.ExecutorInterceptor
;
import
com.pcloud.common.entity.BaseEntity
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.page.PageBean
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
/**
* @描述:数据访问层基础支撑类. @作者:DiSeng.H
* @创建时间:2016年3月11日,下午4:03:36 @版本:1.0
*/
public
abstract
class
BaseDaoImpl
<
T
extends
BaseEntity
>
implements
BaseDao
<
T
>
{
protected
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
BaseDaoImpl
.
class
);
public
static
final
String
SQL_INSERT
=
"insert"
;
public
static
final
String
SQL_BATCH_INSERT
=
"batchInsert"
;
public
static
final
String
SQL_UPDATE
=
"update"
;
public
static
final
String
SQL_GET_BY_ID
=
"getById"
;
public
static
final
String
SQL_DELETE_BY_ID
=
"deleteById"
;
public
static
final
String
SQL_LIST_PAGE
=
"listPage"
;
public
static
final
String
SQL_LIST_BY
=
"listBy"
;
public
static
final
String
SQL_COUNT_BY_PAGE_PARAM
=
"countByPageParam"
;
// 根据当前分页参数进行统计
/**
* 注入SqlSessionTemplate实例(要求Spring中进行SqlSessionTemplate的配置).<br/>
* 可以调用sessionTemplate完成数据库操作.
*/
@Autowired
protected
SqlSessionTemplate
sqlSessionTemplate
;
@Autowired
protected
SqlSessionFactory
sqlSessionFactory
;
@Autowired
private
DruidDataSource
druidDataSource
;
public
SqlSessionTemplate
getSessionTemplate
()
{
return
sqlSessionTemplate
;
}
public
SqlSession
getSqlSession
()
{
return
sqlSessionTemplate
;
}
public
long
insert
(
T
t
)
{
if
(
t
==
null
)
throw
new
RuntimeException
(
"T is null"
);
int
result
=
sqlSessionTemplate
.
insert
(
getStatement
(
SQL_INSERT
),
t
);
if
(
result
<=
0
)
throw
BizException
.
DB_INSERT_RESULT_0
;
if
(
t
!=
null
&&
t
.
getId
()
!=
null
&&
result
>
0
)
return
t
.
getId
();
return
result
;
}
public
long
insert
(
List
<
T
>
list
)
{
if
(
list
==
null
||
list
.
size
()
<=
0
)
return
0
;
int
result
=
sqlSessionTemplate
.
insert
(
getStatement
(
SQL_BATCH_INSERT
),
list
);
if
(
result
<=
0
)
throw
BizException
.
DB_INSERT_RESULT_0
;
return
result
;
}
public
long
update
(
T
t
)
{
if
(
t
==
null
)
throw
new
RuntimeException
(
"T is null"
);
int
result
=
sqlSessionTemplate
.
update
(
getStatement
(
SQL_UPDATE
),
t
);
if
(
result
<=
0
)
throw
BizException
.
DB_UPDATE_RESULT_0
;
return
result
;
}
public
long
update
(
T
t
,
String
sqlId
)
{
if
(
t
==
null
)
throw
new
RuntimeException
(
"T is null"
);
int
result
=
0
;
try
{
result
=
sqlSessionTemplate
.
update
(
getStatement
(
sqlId
),
t
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"update fail["
+
sqlId
+
"]:"
+
e
.
getMessage
(),
e
);
throw
BizException
.
DB_DML_FAIL
;
}
if
(
result
<=
0
)
throw
BizException
.
DB_UPDATE_RESULT_0
;
return
result
;
}
public
long
update
(
List
<
T
>
list
)
{
if
(
list
==
null
||
list
.
size
()
<=
0
)
return
0
;
int
result
=
0
;
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
this
.
update
(
list
.
get
(
i
));
result
+=
1
;
}
if
(
result
<=
0
)
throw
BizException
.
DB_UPDATE_RESULT_0
;
return
result
;
}
public
T
getById
(
long
id
)
{
return
sqlSessionTemplate
.
selectOne
(
getStatement
(
SQL_GET_BY_ID
),
id
);
}
public
long
deleteById
(
long
id
)
{
return
(
long
)
sqlSessionTemplate
.
delete
(
getStatement
(
SQL_DELETE_BY_ID
),
id
);
}
public
PageBean
listPage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
)
{
if
(
paramMap
==
null
)
paramMap
=
new
HashMap
<
String
,
Object
>();
// 获取分页数据集 , 注切勿换成 sessionTemplate 对象
List
<
Object
>
list
=
getSqlSession
().
selectList
(
getStatement
(
sqlId
),
paramMap
,
new
RowBounds
(
pageParam
.
getPageNum
()
*
pageParam
.
getNumPerPage
(),
pageParam
.
getNumPerPage
()));
// 统计总记录数
Object
countObject
=
(
Object
)
getSqlSession
().
selectOne
(
getStatement
(
sqlId
),
new
ExecutorInterceptor
.
CountParameter
(
paramMap
));
Long
count
=
Long
.
valueOf
(
countObject
.
toString
());
return
new
PageBean
(
pageParam
.
getPageNum
(),
pageParam
.
getNumPerPage
(),
count
.
intValue
(),
list
);
}
public
<
C
>
PageBeanNew
<
C
>
listPageNew
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
)
{
if
(
paramMap
==
null
)
paramMap
=
new
HashMap
<
String
,
Object
>();
// 获取分页数据集 , 注切勿换成 sessionTemplate 对象
List
<
C
>
list
=
getSqlSession
().
selectList
(
getStatement
(
sqlId
),
paramMap
,
new
RowBounds
(
pageParam
.
getPageNum
()
*
pageParam
.
getNumPerPage
(),
pageParam
.
getNumPerPage
()));
// 统计总记录数
Integer
count
=
getSqlSession
().
selectOne
(
getStatement
(
sqlId
),
new
ExecutorInterceptor
.
CountParameter
(
paramMap
));
return
new
PageBeanNew
<
C
>(
pageParam
.
getPageNum
(),
pageParam
.
getNumPerPage
(),
count
,
list
);
}
public
PageBean
listPage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
,
String
countSqlId
)
{
if
(
paramMap
==
null
)
paramMap
=
new
HashMap
<
String
,
Object
>();
// 获取分页数据集 , 注切勿换成 sessionTemplate 对象
List
<
Object
>
list
=
getSqlSession
().
selectList
(
getStatement
(
sqlId
),
paramMap
,
new
RowBounds
(
pageParam
.
getPageNum
()
*
pageParam
.
getNumPerPage
(),
pageParam
.
getNumPerPage
()));
// 统计总记录数
Object
countObject
=
getSqlSession
().
selectOne
(
getStatement
(
countSqlId
),
paramMap
);
Long
count
=
Long
.
valueOf
(
countObject
.
toString
());
return
new
PageBean
(
pageParam
.
getPageNum
(),
pageParam
.
getNumPerPage
(),
count
.
intValue
(),
list
);
}
public
PageBean
listSimplePage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
)
{
if
(
paramMap
==
null
)
paramMap
=
new
HashMap
<
String
,
Object
>();
// 获取分页数据集 , 注切勿换成 sessionTemplate 对象
List
<
Object
>
list
=
getSqlSession
().
selectList
(
getStatement
(
sqlId
),
paramMap
,
new
RowBounds
(
pageParam
.
getPageNum
()
*
pageParam
.
getNumPerPage
(),
pageParam
.
getNumPerPage
()
+
1
));
return
new
PageBean
(
pageParam
.
getPageNum
(),
pageParam
.
getNumPerPage
(),
list
);
}
public
PageBean
listPage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
)
{
if
(
paramMap
==
null
)
paramMap
=
new
HashMap
<
String
,
Object
>();
// 获取分页数据集 , 注切勿换成 sessionTemplate 对象
List
<
Object
>
list
=
getSqlSession
().
selectList
(
getStatement
(
SQL_LIST_PAGE
),
paramMap
,
new
RowBounds
(
pageParam
.
getPageNum
()
*
pageParam
.
getNumPerPage
(),
pageParam
.
getNumPerPage
()));
// 统计总记录数
Object
countObject
=
(
Object
)
getSqlSession
().
selectOne
(
getStatement
(
SQL_LIST_PAGE
),
new
ExecutorInterceptor
.
CountParameter
(
paramMap
));
Long
count
=
Long
.
valueOf
(
countObject
.
toString
());
// 是否统计当前分页条件下的数据:1:是,其他为否
Object
isCount
=
paramMap
.
get
(
"isCount"
);
if
(
isCount
!=
null
&&
"1"
.
equals
(
isCount
.
toString
()))
{
Map
<
String
,
Object
>
countResultMap
=
sqlSessionTemplate
.
selectOne
(
getStatement
(
SQL_COUNT_BY_PAGE_PARAM
),
paramMap
);
return
new
PageBean
(
pageParam
.
getPageNum
(),
pageParam
.
getNumPerPage
(),
count
.
intValue
(),
list
,
countResultMap
);
}
else
{
return
new
PageBean
(
pageParam
.
getPageNum
(),
pageParam
.
getNumPerPage
(),
count
.
intValue
(),
list
);
}
}
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
public
List
<
T
>
listBy
(
Map
<
String
,
Object
>
paramMap
)
{
return
(
List
)
this
.
listBy
(
paramMap
,
SQL_LIST_BY
);
}
public
List
<
Object
>
listBy
(
Map
<
String
,
Object
>
paramMap
,
String
sqlId
)
{
if
(
paramMap
==
null
)
paramMap
=
new
HashMap
<
String
,
Object
>();
return
sqlSessionTemplate
.
selectList
(
getStatement
(
sqlId
),
paramMap
);
}
@SuppressWarnings
(
"unchecked"
)
public
T
getBy
(
Map
<
String
,
Object
>
paramMap
)
{
return
(
T
)
this
.
getBy
(
paramMap
,
SQL_LIST_BY
);
}
public
Object
getBy
(
Map
<
String
,
Object
>
paramMap
,
String
sqlId
)
{
if
(
paramMap
==
null
||
paramMap
.
isEmpty
())
return
null
;
return
this
.
getSqlSession
().
selectOne
(
getStatement
(
sqlId
),
paramMap
);
}
public
String
getStatement
(
String
sqlId
)
{
String
name
=
this
.
getClass
().
getName
();
StringBuffer
sb
=
new
StringBuffer
().
append
(
name
).
append
(
"."
).
append
(
sqlId
);
return
sb
.
toString
();
}
/**
* 根据序列名称,获取序列值
*/
public
String
getSeqNextValue
(
String
seqName
)
{
boolean
isClosedConn
=
false
;
// 获取当前线程的连接
Connection
connection
=
this
.
sqlSessionTemplate
.
getConnection
();
// 获取Mybatis的SQLRunner类
SqlRunner
sqlRunner
=
null
;
try
{
// 要执行的SQL
String
sql
=
""
;
// 数据库驱动类
String
driverClass
=
druidDataSource
.
getDriver
().
getClass
().
getName
();
// 不同的数据库,拼接SQL语句
if
(
driverClass
.
equals
(
"com.ibm.db2.jcc.DB2Driver"
))
{
sql
=
" VALUES "
+
seqName
.
toUpperCase
()
+
".NEXTVAL"
;
}
if
(
driverClass
.
equals
(
"oracle.jdbc.OracleDriver"
))
{
sql
=
"SELECT "
+
seqName
.
toUpperCase
()
+
".NEXTVAL FROM DUAL"
;
}
if
(
driverClass
.
equals
(
"com.mysql.jdbc.Driver"
))
{
sql
=
"SELECT FUN_SEQ('"
+
seqName
.
toUpperCase
()
+
"')"
;
}
// 如果状态为关闭,则需要从新打开一个连接
if
(
connection
.
isClosed
())
{
connection
=
sqlSessionFactory
.
openSession
().
getConnection
();
isClosedConn
=
true
;
}
sqlRunner
=
new
SqlRunner
(
connection
);
Object
[]
args
=
{};
// 执行SQL语句
Map
<
String
,
Object
>
params
=
sqlRunner
.
selectOne
(
sql
,
args
);
for
(
Object
o
:
params
.
values
())
{
return
o
.
toString
();
}
return
null
;
}
catch
(
Exception
e
)
{
throw
BizException
.
DB_GET_SEQ_NEXT_VALUE_ERROR
.
newInstance
(
"获取序列出现错误!序列名称:{%s}"
,
seqName
);
}
finally
{
if
(
isClosedConn
)
{
sqlRunner
.
closeConnection
();
}
}
}
}
package
com
.
pcloud
.
common
.
core
.
dao
;
import
java.sql.Connection
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.pcloud.common.utils.string.StringUtil
;
import
org.apache.ibatis.jdbc.SqlRunner
;
import
org.apache.ibatis.session.RowBounds
;
import
org.apache.ibatis.session.SqlSession
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.pcloud.common.core.mybatis.interceptor.ExecutorInterceptor
;
import
com.pcloud.common.entity.BaseEntity
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.page.PageBean
;
import
com.pcloud.common.page.PageBeanNew
;
import
com.pcloud.common.page.PageParam
;
/**
* @描述:数据访问层基础支撑类. @作者:DiSeng.H
* @创建时间:2016年3月11日,下午4:03:36 @版本:1.0
*/
public
abstract
class
BaseDaoImpl
<
T
extends
BaseEntity
>
implements
BaseDao
<
T
>
{
protected
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
BaseDaoImpl
.
class
);
public
static
final
String
SQL_INSERT
=
"insert"
;
public
static
final
String
SQL_BATCH_INSERT
=
"batchInsert"
;
public
static
final
String
SQL_UPDATE
=
"update"
;
public
static
final
String
SQL_GET_BY_ID
=
"getById"
;
public
static
final
String
SQL_DELETE_BY_ID
=
"deleteById"
;
public
static
final
String
SQL_LIST_PAGE
=
"listPage"
;
public
static
final
String
SQL_LIST_BY
=
"listBy"
;
public
static
final
String
SQL_COUNT_BY_PAGE_PARAM
=
"countByPageParam"
;
// 根据当前分页参数进行统计
/**
* 注入SqlSessionTemplate实例(要求Spring中进行SqlSessionTemplate的配置).<br/>
* 可以调用sessionTemplate完成数据库操作.
*/
@Autowired
protected
SqlSessionTemplate
sqlSessionTemplate
;
@Autowired
protected
SqlSessionFactory
sqlSessionFactory
;
@Autowired
private
DruidDataSource
druidDataSource
;
public
SqlSessionTemplate
getSessionTemplate
()
{
return
sqlSessionTemplate
;
}
public
SqlSession
getSqlSession
()
{
return
sqlSessionTemplate
;
}
public
long
insert
(
T
t
)
{
if
(
t
==
null
)
throw
new
RuntimeException
(
"T is null"
);
int
result
=
sqlSessionTemplate
.
insert
(
getStatement
(
SQL_INSERT
),
t
);
if
(
result
<=
0
)
throw
BizException
.
DB_INSERT_RESULT_0
;
if
(
t
!=
null
&&
t
.
getId
()
!=
null
&&
result
>
0
)
return
t
.
getId
();
return
result
;
}
public
long
insert
(
List
<
T
>
list
)
{
if
(
list
==
null
||
list
.
size
()
<=
0
)
return
0
;
int
result
=
sqlSessionTemplate
.
insert
(
getStatement
(
SQL_BATCH_INSERT
),
list
);
if
(
result
<=
0
)
throw
BizException
.
DB_INSERT_RESULT_0
;
return
result
;
}
public
long
update
(
T
t
)
{
if
(
t
==
null
)
throw
new
RuntimeException
(
"T is null"
);
int
result
=
sqlSessionTemplate
.
update
(
getStatement
(
SQL_UPDATE
),
t
);
if
(
result
<=
0
)
throw
BizException
.
DB_UPDATE_RESULT_0
;
return
result
;
}
public
long
update
(
T
t
,
String
sqlId
)
{
if
(
t
==
null
)
throw
new
RuntimeException
(
"T is null"
);
int
result
=
0
;
try
{
result
=
sqlSessionTemplate
.
update
(
getStatement
(
sqlId
),
t
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"update fail["
+
sqlId
+
"]:"
+
e
.
getMessage
(),
e
);
throw
BizException
.
DB_DML_FAIL
;
}
if
(
result
<=
0
)
throw
BizException
.
DB_UPDATE_RESULT_0
;
return
result
;
}
public
long
update
(
T
t
,
String
sqlId
,
String
errorMessage
)
{
if
(
t
==
null
)
throw
new
RuntimeException
(
"T is null"
);
int
result
=
0
;
try
{
result
=
sqlSessionTemplate
.
update
(
getStatement
(
sqlId
),
t
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"update fail["
+
sqlId
+
"]:"
+
e
.
getMessage
(),
e
);
throw
BizException
.
DB_DML_FAIL
;
}
if
(
result
<=
0
)
{
if
(
StringUtil
.
isEmpty
(
errorMessage
))
throw
BizException
.
DB_UPDATE_RESULT_0
;
else
throw
new
BizException
(
10000
,
errorMessage
);
}
return
result
;
}
public
long
update
(
List
<
T
>
list
)
{
if
(
list
==
null
||
list
.
size
()
<=
0
)
return
0
;
int
result
=
0
;
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
this
.
update
(
list
.
get
(
i
));
result
+=
1
;
}
if
(
result
<=
0
)
throw
BizException
.
DB_UPDATE_RESULT_0
;
return
result
;
}
public
T
getById
(
long
id
)
{
return
sqlSessionTemplate
.
selectOne
(
getStatement
(
SQL_GET_BY_ID
),
id
);
}
public
long
deleteById
(
long
id
)
{
return
(
long
)
sqlSessionTemplate
.
delete
(
getStatement
(
SQL_DELETE_BY_ID
),
id
);
}
public
PageBean
listPage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
)
{
if
(
paramMap
==
null
)
paramMap
=
new
HashMap
<
String
,
Object
>();
// 获取分页数据集 , 注切勿换成 sessionTemplate 对象
List
<
Object
>
list
=
getSqlSession
().
selectList
(
getStatement
(
sqlId
),
paramMap
,
new
RowBounds
(
pageParam
.
getPageNum
()
*
pageParam
.
getNumPerPage
(),
pageParam
.
getNumPerPage
()));
// 统计总记录数
Object
countObject
=
(
Object
)
getSqlSession
().
selectOne
(
getStatement
(
sqlId
),
new
ExecutorInterceptor
.
CountParameter
(
paramMap
));
Long
count
=
Long
.
valueOf
(
countObject
.
toString
());
return
new
PageBean
(
pageParam
.
getPageNum
(),
pageParam
.
getNumPerPage
(),
count
.
intValue
(),
list
);
}
public
<
C
>
PageBeanNew
<
C
>
listPageNew
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
)
{
if
(
paramMap
==
null
)
paramMap
=
new
HashMap
<
String
,
Object
>();
// 获取分页数据集 , 注切勿换成 sessionTemplate 对象
List
<
C
>
list
=
getSqlSession
().
selectList
(
getStatement
(
sqlId
),
paramMap
,
new
RowBounds
(
pageParam
.
getPageNum
()
*
pageParam
.
getNumPerPage
(),
pageParam
.
getNumPerPage
()));
// 统计总记录数
Integer
count
=
getSqlSession
().
selectOne
(
getStatement
(
sqlId
),
new
ExecutorInterceptor
.
CountParameter
(
paramMap
));
return
new
PageBeanNew
<
C
>(
pageParam
.
getPageNum
(),
pageParam
.
getNumPerPage
(),
count
,
list
);
}
public
PageBean
listPage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
,
String
countSqlId
)
{
if
(
paramMap
==
null
)
paramMap
=
new
HashMap
<
String
,
Object
>();
// 获取分页数据集 , 注切勿换成 sessionTemplate 对象
List
<
Object
>
list
=
getSqlSession
().
selectList
(
getStatement
(
sqlId
),
paramMap
,
new
RowBounds
(
pageParam
.
getPageNum
()
*
pageParam
.
getNumPerPage
(),
pageParam
.
getNumPerPage
()));
// 统计总记录数
Object
countObject
=
getSqlSession
().
selectOne
(
getStatement
(
countSqlId
),
paramMap
);
Long
count
=
Long
.
valueOf
(
countObject
.
toString
());
return
new
PageBean
(
pageParam
.
getPageNum
(),
pageParam
.
getNumPerPage
(),
count
.
intValue
(),
list
);
}
public
PageBean
listSimplePage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
,
String
sqlId
)
{
if
(
paramMap
==
null
)
paramMap
=
new
HashMap
<
String
,
Object
>();
// 获取分页数据集 , 注切勿换成 sessionTemplate 对象
List
<
Object
>
list
=
getSqlSession
().
selectList
(
getStatement
(
sqlId
),
paramMap
,
new
RowBounds
(
pageParam
.
getPageNum
()
*
pageParam
.
getNumPerPage
(),
pageParam
.
getNumPerPage
()
+
1
));
return
new
PageBean
(
pageParam
.
getPageNum
(),
pageParam
.
getNumPerPage
(),
list
);
}
public
PageBean
listPage
(
PageParam
pageParam
,
Map
<
String
,
Object
>
paramMap
)
{
if
(
paramMap
==
null
)
paramMap
=
new
HashMap
<
String
,
Object
>();
// 获取分页数据集 , 注切勿换成 sessionTemplate 对象
List
<
Object
>
list
=
getSqlSession
().
selectList
(
getStatement
(
SQL_LIST_PAGE
),
paramMap
,
new
RowBounds
(
pageParam
.
getPageNum
()
*
pageParam
.
getNumPerPage
(),
pageParam
.
getNumPerPage
()));
// 统计总记录数
Object
countObject
=
(
Object
)
getSqlSession
().
selectOne
(
getStatement
(
SQL_LIST_PAGE
),
new
ExecutorInterceptor
.
CountParameter
(
paramMap
));
Long
count
=
Long
.
valueOf
(
countObject
.
toString
());
// 是否统计当前分页条件下的数据:1:是,其他为否
Object
isCount
=
paramMap
.
get
(
"isCount"
);
if
(
isCount
!=
null
&&
"1"
.
equals
(
isCount
.
toString
()))
{
Map
<
String
,
Object
>
countResultMap
=
sqlSessionTemplate
.
selectOne
(
getStatement
(
SQL_COUNT_BY_PAGE_PARAM
),
paramMap
);
return
new
PageBean
(
pageParam
.
getPageNum
(),
pageParam
.
getNumPerPage
(),
count
.
intValue
(),
list
,
countResultMap
);
}
else
{
return
new
PageBean
(
pageParam
.
getPageNum
(),
pageParam
.
getNumPerPage
(),
count
.
intValue
(),
list
);
}
}
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
public
List
<
T
>
listBy
(
Map
<
String
,
Object
>
paramMap
)
{
return
(
List
)
this
.
listBy
(
paramMap
,
SQL_LIST_BY
);
}
public
List
<
Object
>
listBy
(
Map
<
String
,
Object
>
paramMap
,
String
sqlId
)
{
if
(
paramMap
==
null
)
paramMap
=
new
HashMap
<
String
,
Object
>();
return
sqlSessionTemplate
.
selectList
(
getStatement
(
sqlId
),
paramMap
);
}
@SuppressWarnings
(
"unchecked"
)
public
T
getBy
(
Map
<
String
,
Object
>
paramMap
)
{
return
(
T
)
this
.
getBy
(
paramMap
,
SQL_LIST_BY
);
}
public
Object
getBy
(
Map
<
String
,
Object
>
paramMap
,
String
sqlId
)
{
if
(
paramMap
==
null
||
paramMap
.
isEmpty
())
return
null
;
return
this
.
getSqlSession
().
selectOne
(
getStatement
(
sqlId
),
paramMap
);
}
public
String
getStatement
(
String
sqlId
)
{
String
name
=
this
.
getClass
().
getName
();
StringBuffer
sb
=
new
StringBuffer
().
append
(
name
).
append
(
"."
).
append
(
sqlId
);
return
sb
.
toString
();
}
/**
* 根据序列名称,获取序列值
*/
public
String
getSeqNextValue
(
String
seqName
)
{
boolean
isClosedConn
=
false
;
// 获取当前线程的连接
Connection
connection
=
this
.
sqlSessionTemplate
.
getConnection
();
// 获取Mybatis的SQLRunner类
SqlRunner
sqlRunner
=
null
;
try
{
// 要执行的SQL
String
sql
=
""
;
// 数据库驱动类
String
driverClass
=
druidDataSource
.
getDriver
().
getClass
().
getName
();
// 不同的数据库,拼接SQL语句
if
(
driverClass
.
equals
(
"com.ibm.db2.jcc.DB2Driver"
))
{
sql
=
" VALUES "
+
seqName
.
toUpperCase
()
+
".NEXTVAL"
;
}
if
(
driverClass
.
equals
(
"oracle.jdbc.OracleDriver"
))
{
sql
=
"SELECT "
+
seqName
.
toUpperCase
()
+
".NEXTVAL FROM DUAL"
;
}
if
(
driverClass
.
equals
(
"com.mysql.jdbc.Driver"
))
{
sql
=
"SELECT FUN_SEQ('"
+
seqName
.
toUpperCase
()
+
"')"
;
}
// 如果状态为关闭,则需要从新打开一个连接
if
(
connection
.
isClosed
())
{
connection
=
sqlSessionFactory
.
openSession
().
getConnection
();
isClosedConn
=
true
;
}
sqlRunner
=
new
SqlRunner
(
connection
);
Object
[]
args
=
{};
// 执行SQL语句
Map
<
String
,
Object
>
params
=
sqlRunner
.
selectOne
(
sql
,
args
);
for
(
Object
o
:
params
.
values
())
{
return
o
.
toString
();
}
return
null
;
}
catch
(
Exception
e
)
{
throw
BizException
.
DB_GET_SEQ_NEXT_VALUE_ERROR
.
newInstance
(
"获取序列出现错误!序列名称:{%s}"
,
seqName
);
}
finally
{
if
(
isClosedConn
)
{
sqlRunner
.
closeConnection
();
}
}
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/dto/SendNotifyDto.java
View file @
c53cd2b9
...
...
@@ -94,6 +94,18 @@ public class SendNotifyDto implements Serializable{
*/
private
String
jsonString
;
/**
* 来源ID
* @return
*/
private
String
originId
;
/**
* 来源类型
* @return
*/
private
String
originType
;
public
Long
getFromId
()
{
return
fromId
;
}
...
...
@@ -222,6 +234,26 @@ public class SendNotifyDto implements Serializable{
this
.
jsonString
=
jsonString
;
}
public
static
long
getSerialVersionUID
()
{
return
serialVersionUID
;
}
public
String
getOriginType
()
{
return
originType
;
}
public
void
setOriginType
(
String
originType
)
{
this
.
originType
=
originType
;
}
public
String
getOriginId
()
{
return
originId
;
}
public
void
setOriginId
(
String
originId
)
{
this
.
originId
=
originId
;
}
@Override
public
String
toString
()
{
return
"SendNotifyDto{"
+
...
...
@@ -244,6 +276,8 @@ public class SendNotifyDto implements Serializable{
", pic='"
+
pic
+
'\''
+
", frquency="
+
frquency
+
", jsonString='"
+
jsonString
+
'\''
+
", originId='"
+
originId
+
'\''
+
", originType='"
+
originType
+
'\''
+
'}'
;
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/dto/TemplateMessageDto.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
dto
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Map
;
/**
* 模板消息dto
* @author 作者 : lili
* @date 创建时间:2016年11月17日 下午12:03:48
* @version 1.0
* @return
*/
public
class
TemplateMessageDto
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
4132417523244980195L
;
/**
* 场景编码值
*/
private
String
sceneCode
;
/**
* 接收消息的当事人ID
*/
private
Long
receivePartyId
;
/**
* 成员账号接收人
*/
private
List
<
Long
>
receiveMemberPartyIds
;
/**
* 接收消息角色(CHANNEL/AGENT/MERCHANT/ADVISER)
*/
private
String
receivePartyRole
;
/**
* 公众号所属当事人ID
*/
private
Long
sendPartyId
;
/**
* 公众号所属当事人角色(CHANNEL/AGENT)
*/
private
String
sendPartyRole
;
/**
* 微信用户
*/
private
Long
wechatUserId
;
/**
* openId
*/
private
String
openId
;
/**
* 昵称
*/
private
String
nickName
;
/**
* url
*/
private
String
url
;
/**
* 参数
*/
private
Map
<
String
,
String
>
temParam
;
/**
* 发送类型(0: 通过wechatUserId 1 :通过openId 及昵称 2.通过当事人标识)
*/
private
String
sendType
;
/**
* 公众号标识
*/
private
Long
accountSettingId
;
/**
* 是否为应用
*/
private
Boolean
isApp
;
/**
* 应用类型
*/
private
String
appType
;
public
Long
getAccountSettingId
()
{
return
accountSettingId
;
}
public
void
setAccountSettingId
(
Long
accountSettingId
)
{
this
.
accountSettingId
=
accountSettingId
;
}
public
String
getSceneCode
()
{
return
sceneCode
;
}
public
void
setSceneCode
(
String
sceneCode
)
{
this
.
sceneCode
=
sceneCode
;
}
public
Long
getWechatUserId
()
{
return
wechatUserId
;
}
public
void
setWechatUserId
(
Long
wechatUserId
)
{
this
.
wechatUserId
=
wechatUserId
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
Map
<
String
,
String
>
getTemParam
()
{
return
temParam
;
}
public
void
setTemParam
(
Map
<
String
,
String
>
temParam
)
{
this
.
temParam
=
temParam
;
}
public
String
getOpenId
()
{
return
openId
;
}
public
void
setOpenId
(
String
openId
)
{
this
.
openId
=
openId
;
}
public
String
getSendType
()
{
return
sendType
;
}
public
void
setSendType
(
String
sendType
)
{
this
.
sendType
=
sendType
;
}
public
Long
getReceivePartyId
()
{
return
receivePartyId
;
}
public
void
setReceivePartyId
(
Long
receivePartyId
)
{
this
.
receivePartyId
=
receivePartyId
;
}
public
String
getReceivePartyRole
()
{
return
receivePartyRole
;
}
public
void
setReceivePartyRole
(
String
receivePartyRole
)
{
this
.
receivePartyRole
=
receivePartyRole
;
}
public
Long
getSendPartyId
()
{
return
sendPartyId
;
}
public
void
setSendPartyId
(
Long
sendPartyId
)
{
this
.
sendPartyId
=
sendPartyId
;
}
public
String
getSendPartyRole
()
{
return
sendPartyRole
;
}
public
void
setSendPartyRole
(
String
sendPartyRole
)
{
this
.
sendPartyRole
=
sendPartyRole
;
}
public
String
getNickName
()
{
return
nickName
;
}
public
void
setNickName
(
String
nickName
)
{
this
.
nickName
=
nickName
;
}
public
Boolean
getIsApp
()
{
return
isApp
;
}
public
void
setIsApp
(
Boolean
isApp
)
{
this
.
isApp
=
isApp
;
}
public
String
getAppType
()
{
return
appType
;
}
public
void
setAppType
(
String
appType
)
{
this
.
appType
=
appType
;
}
public
List
<
Long
>
getReceiveMemberPartyIds
()
{
return
receiveMemberPartyIds
;
}
public
void
setReceiveMemberPartyIds
(
List
<
Long
>
receiveMemberPartyIds
)
{
this
.
receiveMemberPartyIds
=
receiveMemberPartyIds
;
}
@Override
public
String
toString
()
{
return
"TemplateMessageDto [sceneCode="
+
sceneCode
+
", receivePartyId="
+
receivePartyId
+
", receiveMemberPartyIds="
+
receiveMemberPartyIds
+
", receivePartyRole="
+
receivePartyRole
+
", sendPartyId="
+
sendPartyId
+
", sendPartyRole="
+
sendPartyRole
+
", wechatUserId="
+
wechatUserId
+
", openId="
+
openId
+
", nickName="
+
nickName
+
", url="
+
url
+
", temParam="
+
temParam
+
", sendType="
+
sendType
+
", accountSettingId="
+
accountSettingId
+
", isApp="
+
isApp
+
", appType="
+
appType
+
"]"
;
}
}
package
com
.
pcloud
.
common
.
core
.
dto
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Map
;
/**
* 模板消息dto
*
* @author 作者 : lili
* @version 1.0
* @date 创建时间:2016年11月17日 下午12:03:48
* @return
*/
public
class
TemplateMessageDto
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
-
4132417523244980195L
;
/**
* 场景编码值
*/
private
String
sceneCode
;
/**
* 接收消息的当事人ID
*/
private
Long
receivePartyId
;
/**
* 成员账号接收人
*/
private
List
<
Long
>
receiveMemberPartyIds
;
/**
* 接收消息角色(CHANNEL/AGENT/MERCHANT/ADVISER)
*/
private
String
receivePartyRole
;
/**
* 公众号所属当事人ID
*/
private
Long
sendPartyId
;
/**
* 公众号所属当事人角色(CHANNEL/AGENT)
*/
private
String
sendPartyRole
;
/**
* 微信用户
*/
private
Long
wechatUserId
;
/**
* openId
*/
private
String
openId
;
/**
* 昵称
*/
private
String
nickName
;
/**
* url
*/
private
String
url
;
/**
* 参数
*/
private
Map
<
String
,
String
>
temParam
;
/**
* 发送类型(0: 通过wechatUserId 1 :通过openId 及昵称 2.通过当事人标识)
*/
private
String
sendType
;
/**
* 公众号标识
*/
private
Long
accountSettingId
;
/**
* 是否为应用
*/
private
Boolean
isApp
;
/**
* 应用类型
*/
private
String
appType
;
/**
* 消息来源分类
*/
private
String
fromCategory
;
public
String
getFromCategory
()
{
return
fromCategory
;
}
public
void
setFromCategory
(
String
fromCategory
)
{
this
.
fromCategory
=
fromCategory
;
}
public
Long
getAccountSettingId
()
{
return
accountSettingId
;
}
public
void
setAccountSettingId
(
Long
accountSettingId
)
{
this
.
accountSettingId
=
accountSettingId
;
}
public
String
getSceneCode
()
{
return
sceneCode
;
}
public
void
setSceneCode
(
String
sceneCode
)
{
this
.
sceneCode
=
sceneCode
;
}
public
Long
getWechatUserId
()
{
return
wechatUserId
;
}
public
void
setWechatUserId
(
Long
wechatUserId
)
{
this
.
wechatUserId
=
wechatUserId
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
Map
<
String
,
String
>
getTemParam
()
{
return
temParam
;
}
public
void
setTemParam
(
Map
<
String
,
String
>
temParam
)
{
this
.
temParam
=
temParam
;
}
public
String
getOpenId
()
{
return
openId
;
}
public
void
setOpenId
(
String
openId
)
{
this
.
openId
=
openId
;
}
public
String
getSendType
()
{
return
sendType
;
}
public
void
setSendType
(
String
sendType
)
{
this
.
sendType
=
sendType
;
}
public
Long
getReceivePartyId
()
{
return
receivePartyId
;
}
public
void
setReceivePartyId
(
Long
receivePartyId
)
{
this
.
receivePartyId
=
receivePartyId
;
}
public
String
getReceivePartyRole
()
{
return
receivePartyRole
;
}
public
void
setReceivePartyRole
(
String
receivePartyRole
)
{
this
.
receivePartyRole
=
receivePartyRole
;
}
public
Long
getSendPartyId
()
{
return
sendPartyId
;
}
public
void
setSendPartyId
(
Long
sendPartyId
)
{
this
.
sendPartyId
=
sendPartyId
;
}
public
String
getSendPartyRole
()
{
return
sendPartyRole
;
}
public
void
setSendPartyRole
(
String
sendPartyRole
)
{
this
.
sendPartyRole
=
sendPartyRole
;
}
public
String
getNickName
()
{
return
nickName
;
}
public
void
setNickName
(
String
nickName
)
{
this
.
nickName
=
nickName
;
}
public
Boolean
getIsApp
()
{
return
isApp
;
}
public
void
setIsApp
(
Boolean
isApp
)
{
this
.
isApp
=
isApp
;
}
public
String
getAppType
()
{
return
appType
;
}
public
void
setAppType
(
String
appType
)
{
this
.
appType
=
appType
;
}
public
List
<
Long
>
getReceiveMemberPartyIds
()
{
return
receiveMemberPartyIds
;
}
public
void
setReceiveMemberPartyIds
(
List
<
Long
>
receiveMemberPartyIds
)
{
this
.
receiveMemberPartyIds
=
receiveMemberPartyIds
;
}
@Override
public
String
toString
()
{
return
"TemplateMessageDto [sceneCode="
+
sceneCode
+
", receivePartyId="
+
receivePartyId
+
", receiveMemberPartyIds="
+
receiveMemberPartyIds
+
", receivePartyRole="
+
receivePartyRole
+
", sendPartyId="
+
sendPartyId
+
", sendPartyRole="
+
sendPartyRole
+
", wechatUserId="
+
wechatUserId
+
", openId="
+
openId
+
", nickName="
+
nickName
+
", url="
+
url
+
", temParam="
+
temParam
+
", sendType="
+
sendType
+
", accountSettingId="
+
accountSettingId
+
", isApp="
+
isApp
+
", appType="
+
appType
+
"]"
;
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/enums/AppTypeEnum.java
View file @
c53cd2b9
...
...
@@ -41,8 +41,11 @@ public enum AppTypeEnum {
ZSCORE
(
"ZSCORE"
),
// 标准分
RECITE_WORD
(
"RECITE_WORD"
),
// 背单词
INTERACT
(
"INTERACT"
),
// 互动墙
SPECIAL
(
"SPECIAL"
);
// 专题
SPECIAL
(
"SPECIAL"
),
// 专题
LIVEAPP
(
"LIVEAPP"
),
//直播3.0
CLOCK
(
"CLOCK"
),
//打卡
TASTETEST
(
"TASTETEST"
),
//趣味测试
VIDEO_CLASSIC
(
"VIDEO_CLASSIC"
);
//经典版视频
/**
* 值
*/
...
...
pcloud-common-core/src/main/java/com/pcloud/common/core/enums/NotifyOriginTypeEnum.java
0 → 100644
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
core
.
enums
;
/**
* Description 站内信中originType枚举类
* @author HZK
* @date 2018/10/18
*/
public
enum
NotifyOriginTypeEnum
{
/**
* 应用ID
*/
APP
(
"APP"
),
/**
* 作品ID
*/
PRODUCT
(
"PRODUCT"
),
/**
* 订单
*/
ORDERNUM
(
"ORDERNUM"
);
/**
* 值
*/
public
final
String
value
;
/**
* 构造
* @param value
*/
NotifyOriginTypeEnum
(
String
value
)
{
this
.
value
=
value
;
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/mq/ActiveMqFactory.java
deleted
100644 → 0
View file @
5346f57e
package
com
.
pcloud
.
common
.
core
.
mq
;
import
org.apache.activemq.ActiveMQConnectionFactory
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.jms.connection.CachingConnectionFactory
;
import
org.springframework.jms.connection.SingleConnectionFactory
;
/**
* @描述:
* @作者:songx
* @创建时间:2017年9月14日,上午10:48:02
* @版本:1.0
*/
@Configuration
@PropertySource
(
value
=
"classpath:public_system.properties"
)
public
class
ActiveMqFactory
{
/**
*
*/
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ActiveMqFactory
.
class
);
@Value
(
"${mq.brokerURL}"
)
private
String
brokerURL
;
/**
* 初始化Mq连接
*
* @return
*/
@Bean
(
name
=
"connectionFactory"
)
public
ActiveMQConnectionFactory
getMqConnection
()
{
LOGGER
.
info
(
"【ActiveMq】初始化MQ链接.<START>"
);
ActiveMQConnectionFactory
mqConnection
=
new
ActiveMQConnectionFactory
();
mqConnection
.
setBrokerURL
(
brokerURL
);
mqConnection
.
setTrustAllPackages
(
true
);
return
mqConnection
;
}
/**
* 初始化JMS连接池
*
* @return
*/
@Autowired
@Bean
(
"cachingConnectionFactory"
)
public
CachingConnectionFactory
getCachingConnectionFactory
(
ActiveMQConnectionFactory
connectionFactory
)
{
CachingConnectionFactory
cachingConnectionFactory
=
new
CachingConnectionFactory
(
connectionFactory
);
cachingConnectionFactory
.
setReconnectOnException
(
true
);
cachingConnectionFactory
.
setCacheConsumers
(
false
);
cachingConnectionFactory
.
setCacheProducers
(
false
);
cachingConnectionFactory
.
setSessionCacheSize
(
50
);
return
cachingConnectionFactory
;
}
/**
* Spring用于管理真正的ConnectionFactory的ConnectionFactory
*
* @return
*/
@Autowired
@Bean
(
name
=
"singleConnectionFactory"
)
public
SingleConnectionFactory
getSingleConnection
(
CachingConnectionFactory
cachingConnectionFactory
)
{
LOGGER
.
info
(
"【ActiveMq】初始化spring管理JMS链接.<START>"
);
SingleConnectionFactory
singleConnection
=
new
SingleConnectionFactory
();
singleConnection
.
setTargetConnectionFactory
(
cachingConnectionFactory
);
return
singleConnection
;
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/mq/ActiveMqProducer.java
deleted
100644 → 0
View file @
5346f57e
package
com
.
pcloud
.
common
.
core
.
mq
;
import
org.apache.activemq.command.ActiveMQQueue
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jms.connection.CachingConnectionFactory
;
import
org.springframework.jms.core.JmsTemplate
;
/**
* @描述:
*
* @作者:songx
* @创建时间:2017年9月14日,上午11:40:25 @版本:1.0
*/
@Configuration
public
class
ActiveMqProducer
{
@Autowired
private
CachingConnectionFactory
cachingConnectionFactory
;
@Autowired
(
required
=
false
)
@Qualifier
(
"convertQueue"
)
private
ActiveMQQueue
convertQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"labelUsedQueue"
)
private
ActiveMQQueue
labelUsedQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"logQueue"
)
private
ActiveMQQueue
logQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"messageQueue"
)
private
ActiveMQQueue
messageQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"weektaskQueue"
)
private
ActiveMQQueue
weektaskQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"templateQueue"
)
private
ActiveMQQueue
templateQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"userActionQueue"
)
private
ActiveMQQueue
userActionQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"funnelFlowQueue"
)
private
ActiveMQQueue
funnelFlowQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"fundQueue"
)
private
ActiveMQQueue
fundQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"dynamicQueue"
)
private
ActiveMQQueue
dynamicQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"exapiQueue"
)
private
ActiveMQQueue
exapiQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"frontEventQueue"
)
private
ActiveMQQueue
frontEventQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"transcodeQueue"
)
private
ActiveMQQueue
transcodeQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"promotionTaskQueue"
)
private
ActiveMQQueue
promotionTaskQueue
;
@Autowired
(
required
=
false
)
@Qualifier
(
"promotionTerminateQueue"
)
private
ActiveMQQueue
promotionTerminateQueue
;
/**
* 获取音视频转码JMS
*
* @return
*/
@Bean
(
name
=
"jmsConvertTemplate"
)
public
JmsTemplate
getConvertTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
convertQueue
);
return
jmsTemplate
;
}
/**
* 获取标签使用JMS
*
* @return
*/
@Bean
(
name
=
"jmsLabelUsedTemplate"
)
public
JmsTemplate
getLabelUsedTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
labelUsedQueue
);
return
jmsTemplate
;
}
/**
* 获取日志JMS
*
* @return
*/
@Bean
(
name
=
"jmsLogTemplate"
)
public
JmsTemplate
getLogTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
logQueue
);
return
jmsTemplate
;
}
/**
* 获取消息JMS
*
* @return
*/
@Bean
(
name
=
"jmsMessageTemplate"
)
public
JmsTemplate
getMessageTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
messageQueue
);
return
jmsTemplate
;
}
/**
* 获取编辑任务JMS
*
* @return
*/
@Bean
(
name
=
"jmsWeektaskTemplate"
)
public
JmsTemplate
getWeektaskTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
weektaskQueue
);
return
jmsTemplate
;
}
/**
* 获取模板消息JMS
*
* @return
*/
@Bean
(
name
=
"jmsTemplateTemplate"
)
public
JmsTemplate
getTemplateTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
templateQueue
);
return
jmsTemplate
;
}
/**
* 获取用户行为JMS
*
* @return
*/
@Bean
(
name
=
"jmsUserActionTemplate"
)
public
JmsTemplate
getUserActionTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
userActionQueue
);
return
jmsTemplate
;
}
/**
* 获取漏斗流程JMS
*
* @return
*/
@Bean
(
name
=
"jmsFunnelFlowTemplate"
)
public
JmsTemplate
getFunnelFlowTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
funnelFlowQueue
);
return
jmsTemplate
;
}
/**
* 基金修改监控JMS
*
* @return
*/
@Bean
(
name
=
"jmsFundTemplate"
)
public
JmsTemplate
getJmsFundTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
fundQueue
);
return
jmsTemplate
;
}
/**
* 作者动态监控JMS
*
* @return
*/
@Bean
(
name
=
"jmsDynamicTemplate"
)
public
JmsTemplate
getJmsDynamicTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
dynamicQueue
);
return
jmsTemplate
;
}
/**
* 收集事件
*
* @return
*/
@Bean
(
name
=
"jmsFrontEventTemplate"
)
public
JmsTemplate
getJmsFrontEventTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
frontEventQueue
);
return
jmsTemplate
;
}
/**
* 对外api监控JMS
*
* @author wangrui
* @date 10:40 2018/4/13
*/
@Bean
(
name
=
"jmsExapiTemplate"
)
public
JmsTemplate
getJmsExapiTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
exapiQueue
);
return
jmsTemplate
;
}
/**
* 文件转码JMS
*
* @return
*/
@Bean
(
name
=
"jmsTranscodeTemplate"
)
public
JmsTemplate
getJmsTranscodeTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
transcodeQueue
);
return
jmsTemplate
;
}
/**
* 获取促销任务JMS
*
* @return
*/
@Bean
(
name
=
"jmsPromotionTaskTemplate"
)
public
JmsTemplate
getJmsPromotionTaskTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
promotionTaskQueue
);
return
jmsTemplate
;
}
/**
* 获取促销终止JMS
*
* @return
*/
@Bean
(
name
=
"jmsPromotionTerminateTemplate"
)
public
JmsTemplate
getJmsPromotionTerminateTemplate
()
{
JmsTemplate
jmsTemplate
=
getJmsTemplate
();
jmsTemplate
.
setDefaultDestination
(
promotionTerminateQueue
);
return
jmsTemplate
;
}
/**
* 获取JMS模板
*
* @return
*/
private
JmsTemplate
getJmsTemplate
()
{
JmsTemplate
jmsTemplate
=
new
JmsTemplate
(
cachingConnectionFactory
);
jmsTemplate
.
setReceiveTimeout
(
10000
);
return
jmsTemplate
;
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/mq/ActiveMqQueue.java
deleted
100644 → 0
View file @
5346f57e
package
com
.
pcloud
.
common
.
core
.
mq
;
import
org.apache.activemq.command.ActiveMQQueue
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
com.pcloud.common.core.enums.MqQueueEnum
;
/**
*
* @描述:
*
* @作者:songx
* @创建时间:2017年11月14日,上午10:59:55 @版本:1.0
*/
@Configuration
public
class
ActiveMqQueue
{
/**
* 音视频转换消息队列
*
* @return
*/
@Bean
(
name
=
"convertQueue"
)
public
ActiveMQQueue
getConvertQueue
()
{
return
new
ActiveMQQueue
(
"convert"
);
}
/**
* 标签使用量消息队列
*
* @return
*/
@Bean
(
name
=
"labelUsedQueue"
)
public
ActiveMQQueue
getLabelUsedQueue
()
{
return
new
ActiveMQQueue
(
"labelUsed"
);
}
/**
* 日志消息队列
*
* @return
*/
@Bean
(
name
=
"logQueue"
)
public
ActiveMQQueue
getLogQueue
()
{
return
new
ActiveMQQueue
(
"log"
);
}
/**
* 系统消息消息队列
*
* @return
*/
@Bean
(
name
=
"messageQueue"
)
public
ActiveMQQueue
getMessageQueue
()
{
return
new
ActiveMQQueue
(
"message"
);
}
/**
* 周任务消息队列
*
* @return
*/
@Bean
(
name
=
"weektaskQueue"
)
public
ActiveMQQueue
getWeektaskQueue
()
{
return
new
ActiveMQQueue
(
"weektask"
);
}
/**
* 模板消息消息队列
*
* @return
*/
@Bean
(
name
=
"templateQueue"
)
public
ActiveMQQueue
getTemplateQueue
()
{
return
new
ActiveMQQueue
(
"template"
);
}
/**
* 用户行为消息队列
*
* @return
*/
@Bean
(
name
=
"userActionQueue"
)
public
ActiveMQQueue
getUserActionQueue
()
{
return
new
ActiveMQQueue
(
"userAction"
);
}
/**
* 用户漏斗流程队列
*
* @return
*/
@Bean
(
name
=
"funnelFlowQueue"
)
public
ActiveMQQueue
getFunnelFlowQueue
()
{
return
new
ActiveMQQueue
(
"funnelFlow"
);
}
/**
* 基金监控消息队列
*
* @return
*/
@Bean
(
name
=
"fundQueue"
)
public
ActiveMQQueue
getFundQueue
()
{
return
new
ActiveMQQueue
(
"fund"
);
}
/**
* 动态监控消息队列
*
* @return
*/
@Bean
(
name
=
"dynamicQueue"
)
public
ActiveMQQueue
getDynamicQueue
()
{
return
new
ActiveMQQueue
(
"merchantDynamic"
);
}
/**
* 事件分析埋点
*
* @return
*/
@Bean
(
name
=
"frontEventQueue"
)
public
ActiveMQQueue
getFrontEventQueue
()
{
return
new
ActiveMQQueue
(
"frontEvent"
);
}
/**
* 对外api队列
*
* @author wangrui
* @date 10:28 2018/4/13
*/
@Bean
(
name
=
"exapiQueue"
)
public
ActiveMQQueue
getExapiQueue
()
{
return
new
ActiveMQQueue
(
"exapi"
);
}
/**
* 文件转码(非音视频转码)
*
* @return
*/
@Bean
(
name
=
"transcodeQueue"
)
public
ActiveMQQueue
getTranscodeQueue
()
{
return
new
ActiveMQQueue
(
MqQueueEnum
.
TRANSCODE
.
queueName
);
}
/**
* 促销任务
*
* @return
*/
@Bean
(
name
=
"promotionTaskQueue"
)
public
ActiveMQQueue
getPromotionTaskQueue
()
{
return
new
ActiveMQQueue
(
"promotionTask"
);
}
/**
* 促销终止
*
* @return
*/
@Bean
(
name
=
"promotionTerminateQueue"
)
public
ActiveMQQueue
getPromotionTerminateQueue
()
{
return
new
ActiveMQQueue
(
"promotionTerminate"
);
}
}
pcloud-common/pom.xml
View file @
c53cd2b9
...
...
@@ -53,6 +53,22 @@
<artifactId>
spring-cloud-starter-feign
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-ribbon
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-turbine
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-hystrix
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-hystrix-dashboard
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.retry
</groupId>
<artifactId>
spring-retry
</artifactId>
</dependency>
...
...
@@ -82,14 +98,6 @@
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-sleuth
</artifactId>
</dependency>
<!--<dependency> -->
<!--<groupId>org.springframework.cloud</groupId> -->
<!--<artifactId>spring-cloud-starter-hystrix</artifactId> -->
<!--</dependency> -->
<!--<dependency> -->
<!--<groupId>org.springframework.cloud</groupId> -->
<!--<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId> -->
<!--</dependency> -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-stream-rabbit
</artifactId>
...
...
@@ -147,6 +155,12 @@
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
</dependency>
<dependency>
<groupId>
com.squareup.okhttp3
</groupId>
<artifactId>
okhttp
</artifactId>
</dependency>
<dependency>
<groupId>
commons-codec
</groupId>
<artifactId>
commons-codec
</artifactId>
...
...
@@ -189,6 +203,13 @@
</dependency>
<!-- sftp end -->
<!-- google Begin -->
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</dependency>
<!-- google End -->
<!-- ftp begin -->
<dependency>
<groupId>
commons-net
</groupId>
...
...
@@ -227,12 +248,6 @@
<artifactId>
freemarker
</artifactId>
</dependency>
<!-- PDF解析工具 -->
<dependency>
<groupId>
pcloud.tools
</groupId>
<artifactId>
tools
</artifactId>
</dependency>
<!-- 图片处理工具 added by songx at 2017-05-17 -->
<dependency>
<groupId>
net.coobird
</groupId>
...
...
@@ -283,12 +298,6 @@
</dependency>
<!-- end -->
<!-- google 工具包 -->
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</dependency>
<!-- Jackson Begin -->
<dependency>
<groupId>
org.codehaus.jackson
</groupId>
...
...
@@ -364,12 +373,7 @@
<version>
1.5.2
</version>
</dependency>
<!--PDF转图片 -->
<dependency>
<groupId>
org.apache.pdfbox
</groupId>
<artifactId>
pdfbox
</artifactId>
<version>
2.0.9
</version>
</dependency>
<dependency>
<groupId>
com.github.jai-imageio
</groupId>
...
...
pcloud-common/src/main/java/com/pcloud/common/dto/OrderParamForApp.java
0 → 100644
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
dto
;
/**
* Created by ${user} on ${date}
*/
import
java.io.Serializable
;
/**
* @author TianChao
* @date 2018/6/22 11:04
*/
public
class
OrderParamForApp
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
8010969876295649975L
;
}
pcloud-common/src/main/java/com/pcloud/common/dto/OrderParamForLive.java
0 → 100644
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
dto
;
/**
* Created by ${user} on ${date}
*/
/**
* @author TianChao
* @date 2018/6/22 11:04
*/
public
class
OrderParamForLive
extends
OrderParamForApp
{
private
static
final
long
serialVersionUID
=
-
2221916506871980562L
;
private
Integer
isSuperMerchant
;
public
Integer
getIsSuperMerchant
()
{
return
isSuperMerchant
;
}
public
void
setIsSuperMerchant
(
Integer
isSuperMerchant
)
{
this
.
isSuperMerchant
=
isSuperMerchant
;
}
@Override
public
String
toString
()
{
return
"OrderParamForLive{"
+
"isSuperMerchant="
+
isSuperMerchant
+
'}'
;
}
}
pcloud-common/src/main/java/com/pcloud/common/entity/BaseEntity.java
View file @
c53cd2b9
...
...
@@ -27,6 +27,11 @@ public class BaseEntity implements Serializable {
private
Long
id
;
/**
* 用户ID
*/
private
Long
userId
;
/**
* IP地址
*/
private
String
ipAddress
;
...
...
@@ -49,6 +54,14 @@ public class BaseEntity implements Serializable {
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
protected
Date
updateTime
;
public
Long
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
Long
userId
)
{
this
.
userId
=
userId
;
}
public
String
getIpAddress
()
{
return
ipAddress
;
}
...
...
pcloud-common/src/main/java/com/pcloud/common/enums/AppTypeEnum.java
View file @
c53cd2b9
...
...
@@ -47,10 +47,14 @@ public enum AppTypeEnum {
INTERACT
(
"INTERACT"
),
// 互动墙
SPECIAL
(
"SPECIAL"
),
// 专题
CLOCK
(
"CLOCK"
),
// 打卡
TEST
(
"TEST"
),
// 测试
TEST
(
"TEST"
),
// 趣味测试(测试工具)
EBOOK
(
"EBOOK"
),
// 电子书
LIVE_TIMETABLE
(
"LIVE_TIMETABLE"
),
// 直播课表
DRAW
(
"DRAW"
),
// 抽奖
WISH
(
"WISH"
);
// 愿望单
WISH
(
"WISH"
),
// 愿望单
LIVEAPP
(
"LIVEAPP"
),
//直播3.0
TASTETEST
(
"TASTETEST"
),
//趣味测试
VIDEO_CLASSIC
(
"VIDEO_CLASSIC"
);
//经典版视频
/**
* 枚举转换
...
...
pcloud-common/src/main/java/com/pcloud/common/trade/service/TradeCommonService.java
0 → 100644
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
trade
.
service
;
import
java.util.List
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
com.pcloud.common.dto.ResponseDto
;
import
com.pcloud.common.trade.vo.PayParamVO
;
import
com.pcloud.common.trade.vo.TargetIdAndTypeVO
;
/**
* 交易公用接口
* Created by ${user} on ${date}
*/
public
interface
TradeCommonService
{
@RequestMapping
(
value
=
"/getPayParam"
,
method
=
RequestMethod
.
POST
)
ResponseEntity
<
ResponseDto
<
List
<
PayParamVO
>>>
getPayParam
(
@RequestBody
TargetIdAndTypeVO
targetIdAndTypeVO
);
@RequestMapping
(
value
=
"getProductIdByAppId"
,
method
=
RequestMethod
.
GET
)
ResponseEntity
<
ResponseDto
<
Long
>>
getProductIdByAppId
(
@RequestParam
(
"appId"
)
Long
appId
);
}
pcloud-common/src/main/java/com/pcloud/common/trade/vo/PayParamVO.java
0 → 100644
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
trade
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.util.Map
;
/**
* @描述:问答支付dto
* @作者:TianChao
* @创建时间:2016年10月19日 上午10:26:11
* @版本:1.0
*/
@ApiModel
(
description
=
"立即付款dto"
)
public
class
PayParamVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1424201849099702707L
;
@ApiModelProperty
(
value
=
"商户id"
,
dataType
=
"Long"
)
private
Long
merchantId
;
/**
* 商品标识
*/
@ApiModelProperty
(
value
=
"商品标识"
,
dataType
=
"Long"
)
private
Long
productId
;
/**
* 商品数量
*/
@ApiModelProperty
(
value
=
"商品数量"
,
dataType
=
"Integer"
)
private
Integer
quantity
;
/**
* 规格id
*/
@ApiModelProperty
(
value
=
"规格id"
,
dataType
=
"Long"
)
private
Long
specId
;
@ApiModelProperty
(
value
=
"应用id"
,
dataType
=
"Long"
)
private
Long
appId
;
@ApiModelProperty
(
value
=
"地址id"
,
dataType
=
"Long"
)
private
Long
addressId
;
@ApiModelProperty
(
value
=
"isInvoice"
,
dataType
=
"int"
)
private
int
isInvoice
;
@ApiModelProperty
(
value
=
"发票内容"
,
dataType
=
"String"
)
private
String
invoiceContent
;
@ApiModelProperty
(
value
=
"发票抬头"
,
dataType
=
"String"
)
private
String
invoiceHeader
;
/**
* 发票抬头类型(0是个人,1是企业)
*/
@ApiModelProperty
(
value
=
"发票抬头类型(0是个人,1是企业)"
,
dataType
=
"Integer"
)
private
Integer
invoiceHeaderType
;
/**
* 证件号(公司为企业税号,个人为身份证号)
*/
@ApiModelProperty
(
value
=
"证件号(公司为企业税号,个人为身份证号)"
,
dataType
=
"String"
)
private
String
invoiceCredentialNum
;
@ApiModelProperty
(
value
=
"购物码"
,
dataType
=
"String"
)
private
String
buyCode
;
@ApiModelProperty
(
value
=
"电话"
,
dataType
=
"String"
)
private
String
phone
;
@ApiModelProperty
(
value
=
"isAskMore"
,
dataType
=
"int"
)
private
int
isAskMore
;
/**
* 购买服务人
*/
@ApiModelProperty
(
value
=
"购买服务人"
,
dataType
=
"String"
)
private
String
serviceName
;
/**
* 服务电话
*/
@ApiModelProperty
(
value
=
"服务电话"
,
dataType
=
"String"
)
private
String
servicePhone
;
/**
* 服务者邮箱
*/
@ApiModelProperty
(
value
=
"服务者邮箱"
,
dataType
=
"String"
)
private
String
email
;
private
BigDecimal
price
;
private
Long
adviserId
;
private
Long
sceneId
;
private
Map
<
String
,
Object
>
paramForApp
;
private
int
hasOwnPrice
;
private
BigDecimal
dealPrice
;
private
Integer
paymentSource
;
public
Integer
getPaymentSource
()
{
return
paymentSource
;
}
public
void
setPaymentSource
(
Integer
paymentSource
)
{
this
.
paymentSource
=
paymentSource
;
}
public
BigDecimal
getDealPrice
()
{
return
dealPrice
;
}
public
void
setDealPrice
(
BigDecimal
dealPrice
)
{
this
.
dealPrice
=
dealPrice
;
}
public
int
getHasOwnPrice
()
{
return
hasOwnPrice
;
}
public
void
setHasOwnPrice
(
int
hasOwnPrice
)
{
this
.
hasOwnPrice
=
hasOwnPrice
;
}
public
Map
<
String
,
Object
>
getParamForApp
()
{
return
paramForApp
;
}
public
void
setParamForApp
(
Map
<
String
,
Object
>
paramForApp
)
{
this
.
paramForApp
=
paramForApp
;
}
public
Long
getAdviserId
()
{
return
adviserId
;
}
public
void
setAdviserId
(
Long
adviserId
)
{
this
.
adviserId
=
adviserId
;
}
public
Long
getSceneId
()
{
return
sceneId
;
}
public
void
setSceneId
(
Long
sceneId
)
{
this
.
sceneId
=
sceneId
;
}
public
BigDecimal
getPrice
()
{
return
price
;
}
public
void
setPrice
(
BigDecimal
price
)
{
this
.
price
=
price
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
String
getServiceName
()
{
return
serviceName
;
}
public
void
setServiceName
(
String
serviceName
)
{
this
.
serviceName
=
serviceName
;
}
public
String
getServicePhone
()
{
return
servicePhone
;
}
public
void
setServicePhone
(
String
servicePhone
)
{
this
.
servicePhone
=
servicePhone
;
}
public
int
getIsAskMore
()
{
return
isAskMore
;
}
public
void
setIsAskMore
(
int
isAskMore
)
{
this
.
isAskMore
=
isAskMore
;
}
public
Integer
getInvoiceHeaderType
()
{
return
invoiceHeaderType
;
}
public
void
setInvoiceHeaderType
(
Integer
invoiceHeaderType
)
{
this
.
invoiceHeaderType
=
invoiceHeaderType
;
}
public
String
getInvoiceCredentialNum
()
{
return
invoiceCredentialNum
;
}
public
void
setInvoiceCredentialNum
(
String
invoiceCredentialNum
)
{
this
.
invoiceCredentialNum
=
invoiceCredentialNum
;
}
public
String
getPhone
()
{
return
phone
;
}
public
void
setPhone
(
String
phone
)
{
this
.
phone
=
phone
;
}
public
String
getBuyCode
()
{
return
buyCode
;
}
public
void
setBuyCode
(
String
buyCode
)
{
this
.
buyCode
=
buyCode
;
}
public
int
getIsInvoice
()
{
return
isInvoice
;
}
public
void
setIsInvoice
(
int
isInvoice
)
{
this
.
isInvoice
=
isInvoice
;
}
public
String
getInvoiceContent
()
{
return
invoiceContent
;
}
public
void
setInvoiceContent
(
String
invoiceContent
)
{
this
.
invoiceContent
=
invoiceContent
;
}
public
String
getInvoiceHeader
()
{
return
invoiceHeader
;
}
public
void
setInvoiceHeader
(
String
invoiceHeader
)
{
this
.
invoiceHeader
=
invoiceHeader
;
}
public
Long
getAddressId
()
{
return
addressId
;
}
public
void
setAddressId
(
Long
addressId
)
{
this
.
addressId
=
addressId
;
}
public
Long
getAppId
()
{
return
appId
;
}
public
void
setAppId
(
Long
appId
)
{
this
.
appId
=
appId
;
}
public
Long
getMerchantId
()
{
return
merchantId
;
}
public
void
setMerchantId
(
Long
merchantId
)
{
this
.
merchantId
=
merchantId
;
}
public
Long
getProductId
()
{
return
productId
;
}
public
void
setProductId
(
Long
productId
)
{
this
.
productId
=
productId
;
}
public
Integer
getQuantity
()
{
return
quantity
;
}
public
void
setQuantity
(
Integer
quantity
)
{
this
.
quantity
=
quantity
;
}
public
Long
getSpecId
()
{
return
specId
;
}
public
void
setSpecId
(
Long
specId
)
{
this
.
specId
=
specId
;
}
@Override
public
String
toString
()
{
return
"PayParamVO{"
+
"merchantId="
+
merchantId
+
", productId="
+
productId
+
", quantity="
+
quantity
+
", specId="
+
specId
+
", appId="
+
appId
+
", addressId="
+
addressId
+
", isInvoice="
+
isInvoice
+
", invoiceContent='"
+
invoiceContent
+
'\''
+
", invoiceHeader='"
+
invoiceHeader
+
'\''
+
", invoiceHeaderType="
+
invoiceHeaderType
+
", invoiceCredentialNum='"
+
invoiceCredentialNum
+
'\''
+
", buyCode='"
+
buyCode
+
'\''
+
", phone='"
+
phone
+
'\''
+
", isAskMore="
+
isAskMore
+
", serviceName='"
+
serviceName
+
'\''
+
", servicePhone='"
+
servicePhone
+
'\''
+
", email='"
+
email
+
'\''
+
", price="
+
price
+
", adviserId="
+
adviserId
+
", sceneId="
+
sceneId
+
", paramForApp="
+
paramForApp
+
", hasOwnPrice="
+
hasOwnPrice
+
", dealPrice="
+
dealPrice
+
", paymentSource="
+
paymentSource
+
'}'
;
}
}
pcloud-common/src/main/java/com/pcloud/common/trade/vo/TargetIdAndTypeVO.java
0 → 100644
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
trade
.
vo
;
/**
* Created by ${user} on ${date}
*/
import
java.io.Serializable
;
/**
* @author TianChao
* @date 2018/10/23 10:43
*/
public
class
TargetIdAndTypeVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1581040394497248116L
;
private
Long
targetId
;
private
String
targetType
;
private
Long
wechatUserId
;
private
boolean
buyOneBook
;
private
int
paymentSource
;
private
Long
channelId
;
private
Long
appId
;
private
Long
officialAccountsId
;
private
Long
adviserId
;
private
Long
sceneId
;
private
String
ipAddress
;
public
String
getIpAddress
()
{
return
ipAddress
;
}
public
void
setIpAddress
(
String
ipAddress
)
{
this
.
ipAddress
=
ipAddress
;
}
public
Long
getAdviserId
()
{
return
adviserId
;
}
public
void
setAdviserId
(
Long
adviserId
)
{
this
.
adviserId
=
adviserId
;
}
public
Long
getSceneId
()
{
return
sceneId
;
}
public
void
setSceneId
(
Long
sceneId
)
{
this
.
sceneId
=
sceneId
;
}
public
Long
getOfficialAccountsId
()
{
return
officialAccountsId
;
}
public
void
setOfficialAccountsId
(
Long
officialAccountsId
)
{
this
.
officialAccountsId
=
officialAccountsId
;
}
public
Long
getChannelId
()
{
return
channelId
;
}
public
void
setChannelId
(
Long
channelId
)
{
this
.
channelId
=
channelId
;
}
public
Long
getAppId
()
{
return
appId
;
}
public
void
setAppId
(
Long
appId
)
{
this
.
appId
=
appId
;
}
public
int
getPaymentSource
()
{
return
paymentSource
;
}
public
void
setPaymentSource
(
int
paymentSource
)
{
this
.
paymentSource
=
paymentSource
;
}
public
Long
getWechatUserId
()
{
return
wechatUserId
;
}
public
void
setWechatUserId
(
Long
wechatUserId
)
{
this
.
wechatUserId
=
wechatUserId
;
}
public
boolean
isBuyOneBook
()
{
return
buyOneBook
;
}
public
void
setBuyOneBook
(
boolean
buyOneBook
)
{
this
.
buyOneBook
=
buyOneBook
;
}
public
Long
getTargetId
()
{
return
targetId
;
}
public
void
setTargetId
(
Long
targetId
)
{
this
.
targetId
=
targetId
;
}
public
String
getTargetType
()
{
return
targetType
;
}
public
void
setTargetType
(
String
targetType
)
{
this
.
targetType
=
targetType
;
}
@Override
public
String
toString
()
{
return
"TargetIdAndTypeVO{"
+
"targetId="
+
targetId
+
", targetType='"
+
targetType
+
'\''
+
", wechatUserId="
+
wechatUserId
+
", buyOneBook="
+
buyOneBook
+
", paymentSource="
+
paymentSource
+
", channelId="
+
channelId
+
", appId="
+
appId
+
", officialAccountsId="
+
officialAccountsId
+
", adviserId="
+
adviserId
+
", sceneId="
+
sceneId
+
", ipAddress='"
+
ipAddress
+
'\''
+
'}'
;
}
}
pcloud-common/src/main/java/com/pcloud/common/utils/BeanNewUtils.java
View file @
c53cd2b9
...
...
@@ -2,6 +2,7 @@ package com.pcloud.common.utils;
import
java.util.List
;
import
com.pcloud.common.page.PageBeanNew
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -9,56 +10,78 @@ import org.springframework.beans.BeanUtils;
import
com.google.common.collect.Lists
;
/**
*
*
* @author:songx
* @date:2018年8月24日,下午2:18:40
*/
public
class
BeanNewUtils
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
BeanNewUtils
.
class
);
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
BeanNewUtils
.
class
);
/**
* 实体类之间的转换
*
* @param source
* 来源
* @param clazz
* 目标对象
* @return
*/
public
static
<
T
>
T
copyProperties
(
Object
source
,
Class
<
T
>
clazz
)
{
if
(
source
==
null
)
{
return
null
;
}
T
t
=
null
;
try
{
t
=
clazz
.
newInstance
();
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"clazz newInstance is error:"
+
e
.
getMessage
(),
e
);
}
BeanUtils
.
copyProperties
(
source
,
t
);
return
t
;
}
/**
* 实体类之间的转换
*
* @param source 来源
* @param clazz 目标对象
* @return
*/
public
static
<
T
>
T
copyProperties
(
Object
source
,
Class
<
T
>
clazz
)
{
if
(
source
==
null
)
{
return
null
;
}
T
t
=
null
;
try
{
t
=
clazz
.
newInstance
();
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"clazz newInstance is error:"
+
e
.
getMessage
(),
e
);
}
BeanUtils
.
copyProperties
(
source
,
t
);
return
t
;
}
/**
* 实体类之间的转换
*
* @param sources
* 来源
* @param clazz
* 目标对象
* @return
*/
public
static
<
T
>
List
<
T
>
copyProperties
(
List
<?>
sources
,
Class
<
T
>
clazz
)
{
if
(
ListUtils
.
isEmpty
(
sources
))
{
return
null
;
}
List
<
T
>
results
=
Lists
.
newArrayList
();
for
(
Object
source
:
sources
)
{
results
.
add
(
copyProperties
(
source
,
clazz
));
}
return
results
;
}
/**
* 实体类之间的转换
*
* @param sources 来源
* @param clazz 目标对象
* @return
*/
public
static
<
T
>
List
<
T
>
copyProperties
(
List
<?>
sources
,
Class
<
T
>
clazz
)
{
if
(
ListUtils
.
isEmpty
(
sources
))
{
return
null
;
}
List
<
T
>
results
=
Lists
.
newArrayList
();
for
(
Object
source
:
sources
)
{
results
.
add
(
copyProperties
(
source
,
clazz
));
}
return
results
;
}
/**
* 分页结果的实体类之间的转换
*
* @param source
* @param clazz
* @param <T>
* @return
*/
public
static
<
T
>
PageBeanNew
<
T
>
copyProperties
(
PageBeanNew
<?>
source
,
Class
<
T
>
clazz
)
{
if
(
source
==
null
)
{
return
null
;
}
List
<?>
recordList
=
source
.
getRecordList
();
PageBeanNew
<
T
>
result
=
new
PageBeanNew
<
T
>();
result
.
setCurrentPage
(
source
.
getCurrentPage
());
result
.
setNumPerPage
(
source
.
getNumPerPage
());
result
.
setPageCount
(
source
.
getPageCount
());
result
.
setTotalCount
(
source
.
getTotalCount
());
source
.
setBeginPageIndex
(
source
.
getBeginPageIndex
());
source
.
setEndPageIndex
(
source
.
getEndPageIndex
());
if
(
ListUtils
.
isEmpty
(
recordList
))
{
result
.
setRecordList
(
Lists
.
newArrayList
());
return
result
;
}
result
.
setRecordList
(
copyProperties
(
recordList
,
clazz
));
return
result
;
}
}
pcloud-common/src/main/java/com/pcloud/common/utils/HttpKit.java
0 → 100644
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
utils
;
import
okhttp3.MediaType
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.Response
;
import
java.io.IOException
;
import
java.util.concurrent.TimeUnit
;
public
final
class
HttpKit
{
private
HttpKit
()
{
}
private
static
OkHttpClient
httpClient
=
new
OkHttpClient
().
newBuilder
()
.
connectTimeout
(
10
,
TimeUnit
.
SECONDS
)
.
writeTimeout
(
10
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
30
,
TimeUnit
.
SECONDS
).
build
();
private
static
final
MediaType
CONTENT_TYPE_FORM
=
MediaType
.
parse
(
"application/json"
);
protected
static
String
post
(
String
url
,
String
data
)
{
okhttp3
.
RequestBody
body
=
okhttp3
.
RequestBody
.
create
(
CONTENT_TYPE_FORM
,
data
);
okhttp3
.
Request
request
=
new
okhttp3
.
Request
.
Builder
().
url
(
url
)
.
post
(
body
).
build
();
return
exec
(
request
);
}
public
static
String
get
(
String
url
)
throws
IOException
{
Request
request
=
new
Request
.
Builder
()
.
url
(
url
).
addHeader
(
"token"
,
"0Id4baiRH818SVJjC2qjhdMwQh5DSfCJ"
)
.
build
();
Response
response
=
httpClient
.
newCall
(
request
).
execute
();
return
response
.
body
().
string
();
// 返回的是string 类型
}
private
static
String
exec
(
Request
request
)
{
try
{
Response
response
=
httpClient
.
newCall
(
request
)
.
execute
();
if
(!
response
.
isSuccessful
())
throw
new
RuntimeException
(
"Unexpected code "
+
response
);
return
response
.
body
().
string
();
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
pcloud-common/src/main/java/com/pcloud/common/utils/LocalDateUtils.java
View file @
c53cd2b9
...
...
@@ -20,13 +20,38 @@ import com.pcloud.common.utils.string.StringUtil;
*/
public
class
LocalDateUtils
{
private
static
final
DateTimeFormatter
TIME
=
DateTimeFormatter
.
ofPattern
(
"HHmmss"
);
private
static
final
DateTimeFormatter
SHORT_MILLISECOND
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmssSSS"
);
private
static
final
DateTimeFormatter
SHORT_DATETIME
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmss"
);
private
static
final
DateTimeFormatter
DATETIME
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
private
static
final
DateTimeFormatter
SHORT_DATE
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMdd"
);
private
static
final
DateTimeFormatter
DATE
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
/**
* 获取当前的日期字符串(yyyy-MM-dd)
*
* @return
*/
public
static
String
getDateNow
()
{
return
LocalDate
.
now
().
toString
();
return
LocalDate
.
now
().
format
(
DATE
);
}
/**
* 获取当前的日期字符串(yyyyMMdd)
*
* @return
*/
public
static
String
getShortDateNow
()
{
return
LocalDate
.
now
().
format
(
SHORT_DATE
);
}
/**
* 获取当前的时间字符串(HHmmss)
*
* @return
*/
public
static
String
getShortTimeNow
()
{
return
LocalDateTime
.
now
().
format
(
TIME
);
}
/**
...
...
@@ -35,7 +60,16 @@ public class LocalDateUtils {
* @return
*/
public
static
String
getDateTimeNow
()
{
return
LocalDateTime
.
now
().
withNano
(
0
).
toString
().
replace
(
"T"
,
" "
);
return
LocalDateTime
.
now
().
format
(
DATETIME
);
}
/**
* 获取当前的日期字符串(yyyyMMddHHmmss)
*
* @return
*/
public
static
String
getShortDateTimeNow
()
{
return
LocalDateTime
.
now
().
format
(
SHORT_DATETIME
);
}
/**
...
...
@@ -44,8 +78,7 @@ public class LocalDateUtils {
* @return
*/
public
static
String
getYmdhmss
()
{
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMddHHmmssSSS"
);
return
LocalDateTime
.
now
().
format
(
formatter
);
return
LocalDateTime
.
now
().
format
(
SHORT_MILLISECOND
);
}
/**
...
...
@@ -65,7 +98,10 @@ public class LocalDateUtils {
* @return
*/
public
static
String
convertToString
(
LocalDateTime
localDateTime
)
{
return
localDateTime
.
withNano
(
0
).
toString
().
replace
(
"T"
,
" "
);
if
(
localDateTime
==
null
)
{
return
null
;
}
return
localDateTime
.
format
(
DATETIME
);
}
/**
...
...
pcloud-common/src/main/java/com/pcloud/common/utils/PictureUtil.java
View file @
c53cd2b9
...
...
@@ -2,22 +2,23 @@ package com.pcloud.common.utils;/**
* Created by ${user} on ${date}
*/
import
com.alibaba.fastjson.JSON
;
import
com.pcloud.common.entity.UploadResultInfo
;
import
com.pcloud.common.enums.ImageTypeEnum
;
import
com.pcloud.common.utils.aliyun.OssUtils
;
import
com.pcloud.common.utils.httpclient.SimpleHttpUtils
;
import
com.pcloud.common.utils.json.JSONUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.imageio.ImageIO
;
import
java.awt.*
;
import
java.awt.geom.RoundRectangle2D
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.OutputStream
;
import
java.io.*
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -33,18 +34,15 @@ public class PictureUtil {
private
static
String
playPic
=
"https://file.5rs.me/oss/uploadfe/png/3c687bffac4d885ecfff8517d6c3f9c2.png"
;
private
static
String
defaultBackgroundPic
=
"https://oss.5rs.me/oss/uploadfe/png/3003b8978e85052f96ababdf7d46f70a.png"
;
private
static
String
borderPic
=
"C:\\Users\\LiHao\\Desktop\\封面图\\书本背景.png"
;
public
static
Color
getImagePixel
(
String
imgFile
)
{
BufferedImage
bi
=
null
;
try
{
if
(
imgFile
.
contains
(
"http"
)){
bi
=
ImageIO
.
read
(
new
URL
(
imgFile
));
}
else
{
bi
=
ImageIO
.
read
(
new
File
(
imgFile
));
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
public
static
Color
getImagePixel
(
BufferedImage
bi
)
{
if
(
bi
.
getWidth
()*
bi
.
getHeight
()>
500000
)
{
BufferedImage
pic1
=
new
BufferedImage
(
157
,
224
,
BufferedImage
.
SCALE_SMOOTH
);
Graphics
graphics
=
pic1
.
getGraphics
();
graphics
.
drawImage
(
bi
.
getScaledInstance
(
157
,
224
,
Image
.
SCALE_SMOOTH
),
0
,
0
,
null
);
graphics
.
dispose
();
bi
=
pic1
;
}
int
width
=
bi
.
getWidth
();
int
height
=
bi
.
getHeight
();
...
...
@@ -54,72 +52,174 @@ public class PictureUtil {
int
R
=
0
;
int
G
=
0
;
int
B
=
0
;
List
<
String
>
list
=
new
ArrayList
<>();
for
(
int
i
=
minx
;
i
<
width
;
i
++)
{
for
(
int
j
=
miny
;
j
<
height
;
j
++)
{
int
pixel
=
bi
.
getRGB
(
i
,
j
);
R
+=(
pixel
&
0xff0000
)
>>
16
;
G
+=(
pixel
&
0xff00
)
>>
8
;
B
+=(
pixel
&
0xff
);
if
(
pixel
==
Color
.
white
.
getRGB
()
||
pixel
==
Color
.
black
.
getRGB
()){
continue
;
}
R
=(
pixel
&
0xff0000
)
>>
16
;
G
=(
pixel
&
0xff00
)
>>
8
;
B
=(
pixel
&
0xff
);
if
((
R
>
230
&&
G
>
230
&&
B
>
230
)
||(
R
<
30
&&
G
<
30
&&
B
<
30
)){
continue
;
}
list
.
add
(
R
+
"-"
+
G
+
"-"
+
B
);
}
}
// R = R/sum;
// G = G/sum;
// B = B/sum;
// return new Color(R,G,B);
return
getMaxCount
(
list
);
}
public
static
Color
getMaxCount
(
List
<
String
>
s
)
{
List
<
String
>
list
=
s
;
Map
<
String
,
Integer
>
map
=
new
HashMap
<
String
,
Integer
>();
for
(
String
c
:
list
)
{
Integer
l
=
map
.
get
(
c
);
if
(
l
==
null
)
l
=
1
;
else
l
++;
map
.
put
(
c
,
l
);
}
String
max
=
null
;
long
num
=
0
;
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
map
.
entrySet
())
{
String
key
=
entry
.
getKey
();
Integer
temp
=
entry
.
getValue
();
if
(
max
==
null
||
temp
>
num
)
{
max
=
key
;
num
=
temp
;
}
}
R
=
R
/
sum
;
G
=
G
/
sum
;
B
=
B
/
sum
;
return
new
Color
(
R
,
G
,
B
);
String
str
[]
=
max
.
split
(
"\\-"
);
if
(
str
.
length
==
3
)
{
return
new
Color
(
Integer
.
parseInt
(
str
[
0
]),
Integer
.
parseInt
(
str
[
1
]),
Integer
.
parseInt
(
str
[
2
]));
}
return
Color
.
gray
;
}
public
static
String
getB16
(
int
R
,
int
G
,
int
B
){
String
[]
h
=
new
String
[
256
];
h
[
0
]=
"00"
;
h
[
1
]=
"01"
;
h
[
2
]=
"02"
;
h
[
3
]=
"03"
;
h
[
4
]=
"04"
;
h
[
5
]=
"05"
;
h
[
6
]=
"06"
;
h
[
7
]=
"07"
;
h
[
8
]=
"08"
;
h
[
9
]=
"09"
;
h
[
10
]=
"0A"
;
h
[
11
]=
"0B"
;
h
[
12
]=
"0C"
;
h
[
13
]=
"0D"
;
h
[
14
]=
"0E"
;
h
[
15
]=
"0F"
;
h
[
16
]=
"10"
;
h
[
17
]=
"11"
;
h
[
18
]=
"12"
;
h
[
19
]=
"13"
;
h
[
20
]=
"14"
;
h
[
21
]=
"15"
;
h
[
22
]=
"16"
;
h
[
23
]=
"17"
;
h
[
24
]=
"18"
;
h
[
25
]=
"19"
;
h
[
26
]=
"1A"
;
h
[
27
]=
"1B"
;
h
[
28
]=
"1C"
;
h
[
29
]=
"1D"
;
h
[
30
]=
"1E"
;
h
[
31
]=
"1F"
;
h
[
32
]=
"20"
;
h
[
33
]=
"21"
;
h
[
34
]=
"22"
;
h
[
35
]=
"23"
;
h
[
36
]=
"24"
;
h
[
37
]=
"25"
;
h
[
38
]=
"26"
;
h
[
39
]=
"27"
;
h
[
40
]=
"28"
;
h
[
41
]=
"29"
;
h
[
42
]=
"2A"
;
h
[
43
]=
"2B"
;
h
[
44
]=
"2C"
;
h
[
45
]=
"2D"
;
h
[
46
]=
"2E"
;
h
[
47
]=
"2F"
;
h
[
48
]=
"30"
;
h
[
49
]=
"31"
;
h
[
50
]=
"32"
;
h
[
51
]=
"33"
;
h
[
52
]=
"34"
;
h
[
53
]=
"35"
;
h
[
54
]=
"36"
;
h
[
55
]=
"37"
;
h
[
56
]=
"38"
;
h
[
57
]=
"39"
;
h
[
58
]=
"3A"
;
h
[
59
]=
"3B"
;
h
[
60
]=
"3C"
;
h
[
61
]=
"3D"
;
h
[
62
]=
"3E"
;
h
[
63
]=
"3F"
;
h
[
64
]=
"40"
;
h
[
65
]=
"41"
;
h
[
66
]=
"42"
;
h
[
67
]=
"43"
;
h
[
68
]=
"44"
;
h
[
69
]=
"45"
;
h
[
70
]=
"46"
;
h
[
71
]=
"47"
;
h
[
72
]=
"48"
;
h
[
73
]=
"49"
;
h
[
74
]=
"4A"
;
h
[
75
]=
"4B"
;
h
[
76
]=
"4C"
;
h
[
77
]=
"4D"
;
h
[
78
]=
"4E"
;
h
[
79
]=
"4F"
;
h
[
80
]=
"50"
;
h
[
81
]=
"51"
;
h
[
82
]=
"52"
;
h
[
83
]=
"53"
;
h
[
84
]=
"54"
;
h
[
85
]=
"55"
;
h
[
86
]=
"56"
;
h
[
87
]=
"57"
;
h
[
88
]=
"58"
;
h
[
89
]=
"59"
;
h
[
90
]=
"5A"
;
h
[
91
]=
"5B"
;
h
[
92
]=
"5C"
;
h
[
93
]=
"5D"
;
h
[
94
]=
"5E"
;
h
[
95
]=
"6F"
;
h
[
96
]=
"60"
;
h
[
97
]=
"61"
;
h
[
98
]=
"62"
;
h
[
99
]=
"63"
;
h
[
100
]=
"64"
;
h
[
101
]=
"65"
;
h
[
102
]=
"66"
;
h
[
103
]=
"67"
;
h
[
104
]=
"68"
;
h
[
105
]=
"69"
;
h
[
106
]=
"6A"
;
h
[
107
]=
"6B"
;
h
[
108
]=
"6C"
;
h
[
109
]=
"6D"
;
h
[
110
]=
"6E"
;
h
[
111
]=
"6F"
;
h
[
112
]=
"70"
;
h
[
113
]=
"71"
;
h
[
114
]=
"72"
;
h
[
115
]=
"73"
;
h
[
116
]=
"74"
;
h
[
117
]=
"75"
;
h
[
118
]=
"76"
;
h
[
119
]=
"77"
;
h
[
120
]=
"78"
;
h
[
121
]=
"79"
;
h
[
122
]=
"7A"
;
h
[
123
]=
"7B"
;
h
[
124
]=
"7C"
;
h
[
125
]=
"7D"
;
h
[
126
]=
"7E"
;
h
[
127
]=
"7F"
;
h
[
128
]=
"80"
;
h
[
129
]=
"81"
;
h
[
130
]=
"82"
;
h
[
131
]=
"83"
;
h
[
132
]=
"84"
;
h
[
133
]=
"85"
;
h
[
134
]=
"86"
;
h
[
135
]=
"87"
;
h
[
136
]=
"88"
;
h
[
137
]=
"89"
;
h
[
138
]=
"8A"
;
h
[
139
]=
"8B"
;
h
[
140
]=
"8C"
;
h
[
141
]=
"8D"
;
h
[
142
]=
"8E"
;
h
[
143
]=
"8F"
;
h
[
144
]=
"90"
;
h
[
145
]=
"91"
;
h
[
146
]=
"92"
;
h
[
147
]=
"93"
;
h
[
148
]=
"94"
;
h
[
149
]=
"95"
;
h
[
150
]=
"96"
;
h
[
151
]=
"97"
;
h
[
152
]=
"98"
;
h
[
153
]=
"99"
;
h
[
154
]=
"9A"
;
h
[
155
]=
"9B"
;
h
[
156
]=
"9C"
;
h
[
157
]=
"9D"
;
h
[
158
]=
"9E"
;
h
[
159
]=
"9F"
;
h
[
160
]=
"A0"
;
h
[
161
]=
"A1"
;
h
[
162
]=
"A2"
;
h
[
163
]=
"A3"
;
h
[
164
]=
"A4"
;
h
[
165
]=
"A5"
;
h
[
166
]=
"A6"
;
h
[
167
]=
"A7"
;
h
[
168
]=
"A8"
;
h
[
169
]=
"A9"
;
h
[
170
]=
"AA"
;
h
[
171
]=
"AB"
;
h
[
172
]=
"AC"
;
h
[
173
]=
"AD"
;
h
[
174
]=
"AE"
;
h
[
175
]=
"AF"
;
h
[
176
]=
"B0"
;
h
[
177
]=
"B1"
;
h
[
178
]=
"B2"
;
h
[
179
]=
"B3"
;
h
[
180
]=
"B4"
;
h
[
181
]=
"B5"
;
h
[
182
]=
"B6"
;
h
[
183
]=
"B7"
;
h
[
184
]=
"B8"
;
h
[
185
]=
"B9"
;
h
[
186
]=
"BA"
;
h
[
187
]=
"BB"
;
h
[
188
]=
"BC"
;
h
[
189
]=
"BD"
;
h
[
190
]=
"BE"
;
h
[
191
]=
"BF"
;
h
[
192
]=
"C0"
;
h
[
193
]=
"C1"
;
h
[
194
]=
"C2"
;
h
[
195
]=
"C3"
;
h
[
196
]=
"C4"
;
h
[
197
]=
"C5"
;
h
[
198
]=
"C6"
;
h
[
199
]=
"C7"
;
h
[
200
]=
"C8"
;
h
[
201
]=
"C9"
;
h
[
202
]=
"CA"
;
h
[
203
]=
"CB"
;
h
[
204
]=
"CC"
;
h
[
205
]=
"CD"
;
h
[
206
]=
"CE"
;
h
[
207
]=
"CF"
;
h
[
208
]=
"D0"
;
h
[
209
]=
"D1"
;
h
[
210
]=
"D2"
;
h
[
211
]=
"D3"
;
h
[
212
]=
"D4"
;
h
[
213
]=
"D5"
;
h
[
214
]=
"D6"
;
h
[
215
]=
"D7"
;
h
[
216
]=
"D8"
;
h
[
217
]=
"D9"
;
h
[
218
]=
"DA"
;
h
[
219
]=
"DB"
;
h
[
220
]=
"DC"
;
h
[
221
]=
"DD"
;
h
[
222
]=
"DE"
;
h
[
223
]=
"DF"
;
h
[
224
]=
"E0"
;
h
[
225
]=
"E1"
;
h
[
226
]=
"E2"
;
h
[
227
]=
"E3"
;
h
[
228
]=
"E4"
;
h
[
229
]=
"E5"
;
h
[
230
]=
"E6"
;
h
[
231
]=
"E7"
;
h
[
232
]=
"E8"
;
h
[
233
]=
"E9"
;
h
[
234
]=
"EA"
;
h
[
235
]=
"EB"
;
h
[
236
]=
"EC"
;
h
[
237
]=
"ED"
;
h
[
238
]=
"EE"
;
h
[
239
]=
"EF"
;
h
[
240
]=
"F0"
;
h
[
241
]=
"F1"
;
h
[
242
]=
"F2"
;
h
[
243
]=
"F3"
;
h
[
244
]=
"F4"
;
h
[
245
]=
"F5"
;
h
[
246
]=
"F6"
;
h
[
247
]=
"F7"
;
h
[
248
]=
"F8"
;
h
[
249
]=
"F9"
;
h
[
250
]=
"FA"
;
h
[
251
]=
"FB"
;
h
[
252
]=
"FC"
;
h
[
253
]=
"FD"
;
h
[
254
]=
"FE"
;
h
[
255
]=
"FF"
;
return
"#"
+
h
[
R
]
+
h
[
G
]
+
h
[
B
];
}
public
static
Color
getImagePixel
(
String
imgFile
)
{
BufferedImage
bi
=
null
;
Color
imagePixel
;
try
{
if
(
imgFile
.
contains
(
"http"
)){
bi
=
ImageIO
.
read
(
new
URL
(
imgFile
));
}
else
{
bi
=
ImageIO
.
read
(
new
File
(
imgFile
));
}
imagePixel
=
getImagePixel
(
bi
);
}
catch
(
Exception
e
)
{
imagePixel
=
Color
.
gray
;
LOGGER
.
warn
(
"生成图片失败,图片="
+
imgFile
+
","
+
e
.
getMessage
(),
e
);
}
return
imagePixel
;
}
public
static
String
toBrowserHexValue
(
int
number
)
{
StringBuilder
builder
=
new
StringBuilder
(
Integer
.
toHexString
(
number
&
0xff
));
while
(
builder
.
length
()
<
2
)
{
builder
.
append
(
"0"
);
builder
=
new
StringBuilder
(
"0"
).
append
(
builder
);
}
return
builder
.
toString
().
toUpperCase
();
}
public
static
Color
toColorFromString
(
String
colorStr
){
colorStr
=
colorStr
.
substring
(
2
);
Color
color
=
new
Color
(
Integer
.
parseInt
(
colorStr
,
16
))
;
return
color
;
}
private
static
BufferedImage
subPicByWhite
(
BufferedImage
picImage
){
return
picImage
.
getSubimage
(
9
,
9
,
699
,
300
);
}
public
static
String
getQrCover
(
String
bookPic
,
boolean
isDefault
){
String
resultPath
=
""
;
try
{
int
backWidth
=
702
;
int
backHeight
=
299
;
int
splitPoint
=
196
;
int
bookWidth
=
157
;
int
bookHeight
=
224
;
int
borderWidth
=
185
;
int
borderHeight
=
252
;
int
playButtonSize
=
80
;
//取书封面和播放按钮图
BufferedImage
bookPicImage
;
BufferedImage
playPicImage
;
BufferedImage
defaultBackgroundImage
;
bookPicImage
=
ImageIO
.
read
(
new
URL
(
bookPic
));
playPicImage
=
ImageIO
.
read
(
new
URL
(
playPic
));
defaultBackgroundImage
=
ImageIO
.
read
(
new
URL
(
defaultBackgroundPic
));
//画一个空的背景
BufferedImage
bg
=
new
BufferedImage
(
backWidth
,
backHeight
,
BufferedImage
.
TYPE_3BYTE_BGR
);
Graphics2D
g
=
bg
.
createGraphics
();
//获取主题色
Color
c
=
getImagePixel
(
bookPic
);
//画纯色的背景或者默认背景图
g
.
setColor
(
c
);
if
(
isDefault
){
g
.
drawImage
(
defaultBackgroundImage
.
getScaledInstance
(
backWidth
,
splitPoint
,
Image
.
SCALE_DEFAULT
),
0
,
0
,
null
);
}
else
{
g
.
fillRect
(
0
,
0
,
backWidth
,
splitPoint
);
Color
color
=
null
;
try
{
color
=
getImagePixel
(
bookPic
);
}
catch
(
Exception
e
){
color
=
Color
.
gray
;
}
g
.
setColor
(
defaultColor
);
g
.
fillRect
(
0
,
splitPoint
,
backWidth
,
backHeight
-
splitPoint
);
//插入书籍图和播放按钮
g
.
drawImage
(
bookPicImage
.
getScaledInstance
(
bookWidth
,
bookHeight
,
Image
.
SCALE_DEFAULT
),
(
backWidth
-
bookWidth
)/
2
,
(
backHeight
-
bookHeight
)/
2
,
null
);
g
.
drawImage
(
playPicImage
.
getScaledInstance
(
playButtonSize
,
playButtonSize
,
Image
.
SCALE_DEFAULT
),
(
backWidth
-
playButtonSize
)/
2
,
(
backHeight
-
playButtonSize
)/
2
,
null
);
//画边框
g
.
setColor
(
borderColor
);
g
.
drawRect
((
backWidth
-
bookWidth
)/
2
,
(
backHeight
-
bookHeight
)/
2
,
bookWidth
,
bookHeight
);
// 保存并上传图片
String
lightIcon
=
"https://oss.5rs.me/oss/uploadfe/png/12dcbc38528d926912c444765d786a9a.png"
;
String
deepIcon
=
"https://oss.5rs.me/oss/uploadfe/png/60612a7415bdac8533568ae0c21a94b6.png"
;
String
icon
;
if
(
color
!=
null
&&
(
color
.
getRed
()<
180
||
color
.
getBlue
()<
180
||
color
.
getGreen
()<
180
)){
icon
=
lightIcon
;
}
else
{
icon
=
deepIcon
;
}
String
html
=
"<div style = \"position: relative;width: 700px;height: 300px;border: 0px solid green;background-color: #fcfcfc;text-align: center;\"> <div style = \"position: absolute;width: 100%;height: 66%;background-color: rgb("
+
color
.
getRed
()+
","
+
color
.
getGreen
()+
","
+
color
.
getBlue
()+
");overflow: hidden;\"> <div style = \"position: absolute;top: 20px;right: -20px;background-image: url('"
+
icon
+
"');background-size: 100%;width: 219px;height: 149px;\"> </div> </div><div style=\"position: relative;display: inline-block;width: 158px;height: 225px;box-shadow: 0px 4px 14px 2px rgba(14, 47, 70, 0.2);border-radius: 4px;border: solid 1px #ddd; margin-top: 35px;background: url('"
+
bookPic
+
"') no-repeat;background-size: cover;background-position: center;\"></div></div>"
;
Map
<
String
,
String
>
header
=
new
HashMap
<>();
header
.
put
(
"Content-Type"
,
"application/json"
);
Map
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"htmlCode"
,
html
);
String
postResult
=
HttpKit
.
post
(
"http://192.168.92.111:8214/transcode/htm2img/jpg"
,
JSON
.
toJSONString
(
param
));
Map
map
=
JSONUtils
.
jsonToMap
(
postResult
,
String
.
class
,
String
.
class
);
String
pic
=
(
String
)
map
.
get
(
"data"
);
BufferedImage
bookPicImage
=
ImageIO
.
read
(
new
URL
(
pic
));
BufferedImage
bufferedImage
=
subPicByWhite
(
bookPicImage
);
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
();
ImageIO
.
write
(
b
g
,
ImageTypeEnum
.
JPG
.
value
,
os
);
ImageIO
.
write
(
b
ufferedImage
,
ImageTypeEnum
.
JPG
.
value
,
os
);
UploadResultInfo
uploadResultInfo
=
OssUtils
.
uploadFileByte
(
os
.
toByteArray
(),
UUIDUitl
.
taskName
(),
ImageTypeEnum
.
JPG
.
value
);
os
.
close
();
resultPath
=
uploadResultInfo
==
null
?
null
:
uploadResultInfo
.
getUrl
();
...
...
@@ -128,99 +228,126 @@ public class PictureUtil {
}
return
resultPath
;
}
public
static
void
main
(
String
[]
args
)
{
// String bookPic = "https://file.5rs.me/oss/upload/image/jpg/c2c7f0b85f9f4eb683cd86a2945bc5e5.jpg";
String
s
=
""
;
String
bookPic
=
"C:\\Users\\LiHao\\Desktop\\封面图\\aa.jpg"
;
String
playPic
=
"C:\\Users\\LiHao\\Desktop\\封面图\\播放按钮.png"
;
String
defaultBackgroundPic
=
"C:\\Users\\LiHao\\Desktop\\封面图\\默认图背景.png"
;
String
resultPath
=
"C:\\Users\\LiHao\\Desktop\\封面图\\result.jpg"
;
String
oath
=
"C:\\Users\\LiHao\\Desktop\\封面图\\书本背景.png"
;
Boolean
isDefalut
=
false
;
try
{
//取书封面和播放按钮图
BufferedImage
bookPicImage
;
BufferedImage
playPicImage
;
BufferedImage
defaultBackgroudImage
;
BufferedImage
oathI
;
if
(
bookPic
.
contains
(
"https:"
)){
bookPicImage
=
ImageIO
.
read
(
new
URL
(
bookPic
));
playPicImage
=
ImageIO
.
read
(
new
URL
(
playPic
));
defaultBackgroudImage
=
ImageIO
.
read
(
new
URL
(
defaultBackgroundPic
));
oathI
=
ImageIO
.
read
(
new
URL
(
oath
));
}
else
{
bookPicImage
=
ImageIO
.
read
(
new
File
(
bookPic
));
playPicImage
=
ImageIO
.
read
(
new
File
(
playPic
));
defaultBackgroudImage
=
ImageIO
.
read
(
new
File
(
defaultBackgroundPic
));
oathI
=
ImageIO
.
read
(
new
File
(
oath
));
}
//画一个空的背景
BufferedImage
bg
=
new
BufferedImage
(
702
,
299
,
BufferedImage
.
TYPE_3BYTE_BGR
);
Graphics2D
g
=
bg
.
createGraphics
();
//获取主题色
Color
c
=
getImagePixel
(
bookPic
);
//画纯色的背景或者默认背景图
g
.
setColor
(
c
);
if
(
isDefalut
){
g
.
drawImage
(
defaultBackgroudImage
.
getScaledInstance
(
702
,
196
,
Image
.
SCALE_DEFAULT
),
0
,
0
,
null
);
}
else
{
g
.
fillRect
(
0
,
0
,
702
,
196
);
}
g
.
setColor
(
new
Color
(
252
,
252
,
252
));
g
.
fillRect
(
0
,
196
,
702
,
102
);
g
.
setColor
(
new
Color
(
221
,
221
,
221
));
//插入书籍图和播放按钮
// g.drawImage(oathI.getScaledInstance(185,252, Image.SCALE_DEFAULT), 258, 33, null);
// String bookPic = "https://file.5rs.me/oss/upload/image/jpg/c2c7f0b85f9f4eb683cd86a2945bc5e5.jpg";
String
bookPic
=
"https://oss.5rs.me/oss/uploadfe/jpg/e88c2f608fe4365f5c0efd7dda0eb59e.jpg"
;
Color
color
;
if
(
bookPic
.
contains
(
"/oss/"
)){
String
s
=
SimpleHttpUtils
.
httpGet
(
bookPic
+
"?x-oss-process=image/average-hue"
,
null
);
System
.
out
.
println
(
s
);
Map
map
=
JSONUtils
.
jsonToMap
(
s
,
String
.
class
,
String
.
class
);
String
rgb
=
(
String
)
map
.
get
(
"RGB"
);
color
=
toColorFromString
(
rgb
);
}
else
{
color
=
getImagePixel
(
bookPic
);
}
String
lightIcon
=
"https://oss.5rs.me/oss/uploadfe/png/12dcbc38528d926912c444765d786a9a.png"
;
String
deepIcon
=
"https://oss.5rs.me/oss/uploadfe/png/60612a7415bdac8533568ae0c21a94b6.png"
;
String
icon
;
if
(
color
!=
null
&&
(
color
.
getRed
()<
180
||
color
.
getBlue
()<
180
||
color
.
getGreen
()<
180
)){
icon
=
lightIcon
;
}
else
{
icon
=
deepIcon
;
}
String
html
=
"<div style = \"position: relative;width: 700px;height: 300px;border: 0px solid green;background-color: #fcfcfc;text-align: center;\"> <div style = \"position: absolute;width: 100%;height: 66%;background-color: rgb("
+
color
.
getRed
()+
","
+
color
.
getGreen
()+
","
+
color
.
getBlue
()+
");overflow: hidden;\"> <div style = \"position: absolute;top: 20px;right: -20px;background-image: url('"
+
icon
+
"');background-size: 100%;width: 219px;height: 149px;\"> </div> </div><div style=\"position: relative;display: inline-block;width: 158px;height: 225px;box-shadow: 0px 4px 14px 2px rgba(14, 47, 70, 0.2);border-radius: 4px;border: solid 1px #ddd; margin-top: 35px;background: url('"
+
bookPic
+
"') no-repeat;background-size: cover;background-position: center;\"></div></div>"
;
Map
<
String
,
String
>
header
=
new
HashMap
<>();
header
.
put
(
"Content-Type"
,
"application/json"
);
BufferedImage
image
=
new
BufferedImage
(
157
,
200
,
BufferedImage
.
TYPE_INT_ARGB
);
Graphics2D
gs
=
image
.
createGraphics
(
);
Map
<
String
,
String
>
param
=
new
HashMap
<>(
);
param
.
put
(
"htmlCode"
,
html
);
Map
mapH
=
new
HashMap
();
mapH
.
put
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
//抗锯齿 (抗锯齿总开关)
mapH
.
put
(
RenderingHints
.
KEY_TEXT_ANTIALIASING
,
RenderingHints
.
VALUE_TEXT_ANTIALIAS_ON
);
gs
.
setRenderingHints
(
mapH
);
String
postResult
=
HttpKit
.
post
(
"http://192.168.92.111:8214/transcode/htm2img/jpg"
,
JSON
.
toJSONString
(
param
));
// gs.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
gs
.
setClip
(
new
RoundRectangle2D
.
Double
(
0
,
0
,
157
,
224
,
12
,
12
));
gs
.
drawImage
(
bookPicImage
.
getScaledInstance
(
157
,
224
,
Image
.
SCALE_DEFAULT
),
0
,
0
,
null
);
g
.
drawImage
(
image
.
getScaledInstance
(
157
,
224
,
Image
.
SCALE_DEFAULT
),
272
,
38
,
null
);
// String s = SimpleHttpUtils.httpRequest("http://localhost:8214/transcode/htm2img/jpg", param,"POST","utf-8",header);
Map
map
=
JSONUtils
.
jsonToMap
(
postResult
,
String
.
class
,
String
.
class
);
String
pic
=
(
String
)
map
.
get
(
"data"
);
System
.
out
.
println
(
pic
);
g
.
drawImage
(
playPicImage
.
getScaledInstance
(
80
,
80
,
Image
.
SCALE_DEFAULT
),
306
,
105
,
null
);
// g.drawRect(265,30,172,238);
try
{
BufferedImage
bookPicImage
=
ImageIO
.
read
(
new
URL
(
pic
));
BufferedImage
bufferedImage
=
subPicByWhite
(
bookPicImage
);
OutputStream
os
=
new
FileOutputStream
(
"C:\\Users\\LiHao\\Desktop\\封面图\\result.jpg"
);
ImageIO
.
write
(
bufferedImage
,
ImageTypeEnum
.
JPG
.
value
,
os
);
os
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
//保存图片
if
(
bookPic
.
contains
(
"https:"
))
{
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
();
ImageIO
.
write
(
bg
,
ImageTypeEnum
.
JPG
.
value
,
os
);
UploadResultInfo
uploadResultInfo
=
OssUtils
.
uploadFileByte
(
os
.
toByteArray
(),
UUIDUitl
.
taskName
(),
ImageTypeEnum
.
JPG
.
value
);
os
.
close
();
s
=
uploadResultInfo
==
null
?
null
:
uploadResultInfo
.
getUrl
();
}
else
{
OutputStream
os
=
new
FileOutputStream
(
resultPath
);
ImageIO
.
write
(
bg
,
ImageTypeEnum
.
JPG
.
value
,
os
);
os
.
close
();
}
System
.
out
.
println
(
s
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
}
// String bookPic = "C:\\Users\\LiHao\\Desktop\\封面图\\aa.jpg";
// String playPic = "C:\\Users\\LiHao\\Desktop\\封面图\\播放按钮.png";
// String defaultBackgroundPic = "C:\\Users\\LiHao\\Desktop\\封面图\\默认图背景.png";
// String resultPath = "C:\\Users\\LiHao\\Desktop\\封面图\\result.jpg";
// Boolean isDefalut = false;
// try {
// //取书封面和播放按钮图
// BufferedImage bookPicImage;
// BufferedImage playPicImage;
// BufferedImage defaultBackgroudImage;
// if(bookPic.contains("https:")){
// bookPicImage = ImageIO.read(new URL(bookPic));
// playPicImage = ImageIO.read(new URL(playPic));
// defaultBackgroudImage = ImageIO.read(new URL(defaultBackgroundPic));
// }else{
// bookPicImage = ImageIO.read(new File(bookPic));
// playPicImage = ImageIO.read(new File(playPic));
// defaultBackgroudImage = ImageIO.read(new File(defaultBackgroundPic));
// }
//
// //画一个空的背景
// BufferedImage bg = new BufferedImage(702, 299, BufferedImage.TYPE_3BYTE_BGR);
// Graphics2D g = bg.createGraphics();
// //获取主题色
// Color c = getImagePixel(bookPic);
//
//
// //画纯色的背景或者默认背景图
// g.setColor(c);
// if(isDefalut){
// g.drawImage(defaultBackgroudImage.getScaledInstance(702,196, Image.SCALE_DEFAULT), 0, 0, null);
// }else {
// g.fillRect(0, 0, 702, 196);
// }
// g.setColor(new Color(252, 252, 252));
// g.fillRect(0, 196, 702, 102);
//
// g.setColor(new Color(221, 221, 221));
// //插入书籍图和播放按钮
// g.drawImage(bookPicImage.getScaledInstance(172,238, Image.SCALE_DEFAULT), 265, 30, null);
// g.drawImage(playPicImage.getScaledInstance(80,80, Image.SCALE_DEFAULT), 306, 105, null);
// g.drawRect(265,30,172,238);
//
// for(int i=0;i<3;i++){
//
// }
//
// //保存图片
// if(bookPic.contains("https:")) {
// ByteArrayOutputStream os = new ByteArrayOutputStream();
// ImageIO.write(bg, ImageTypeEnum.JPG.value, os);
// UploadResultInfo uploadResultInfo = OssUtils.uploadFileByte(os.toByteArray(), UUIDUitl.taskName(), ImageTypeEnum.JPG.value);
// os.close();
// s = uploadResultInfo == null ? null : uploadResultInfo.getUrl();
// }else{
// OutputStream os = new FileOutputStream(resultPath);
// ImageIO.write(bg, ImageTypeEnum.JPG.value, os);
// os.close();
// }
// System.out.println(s);
// } catch (Exception e) {
// System.out.println(e.getMessage());
// }
}
...
...
pcloud-common/src/main/java/com/pcloud/common/utils/ResultUtils.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
utils
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.collections.MapUtils
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.pcloud.common.page.PageBeanNew
;
/**
* 返回结果工具类
*
* @author:songx
* @date:2018年8月8日,下午2:09:16
*/
public
class
ResultUtils
{
/**
* 集合查询结果判断
*
* @param lists
* @return
*/
public
static
<
T
>
List
<
T
>
list
(
List
<
T
>
lists
)
{
if
(!
ListUtils
.
isEmpty
(
lists
))
{
return
lists
;
}
return
Lists
.
newArrayList
();
}
/**
* map查询结果判断
*
* @param lists
* @return
*/
public
static
<
K
,
V
>
Map
<
K
,
V
>
map
(
Map
<
K
,
V
>
map
)
{
if
(!
MapUtils
.
isEmpty
(
map
))
{
return
map
;
}
return
Maps
.
newHashMap
();
}
/**
* 分页查询结果判断
*
* @param pageBeanNew
* @return
*/
public
static
<
T
>
PageBeanNew
<
T
>
pageBeanNew
(
PageBeanNew
<
T
>
pageBeanNew
,
Integer
currentPage
,
Integer
numPerPage
)
{
if
(
pageBeanNew
!=
null
)
{
return
pageBeanNew
;
}
return
new
PageBeanNew
<
T
>(
currentPage
,
numPerPage
,
0
,
Lists
.
newArrayList
());
}
}
package
com
.
pcloud
.
common
.
utils
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.collections.MapUtils
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.pcloud.common.page.PageBeanNew
;
/**
* 返回结果工具类
*
* @author:songx
* @date:2018年8月8日,下午2:09:16
*/
public
class
ResultUtils
{
/**
* 集合查询结果判断
*
* @param lists
* @return
*/
public
static
<
T
>
List
<
T
>
list
(
List
<
T
>
lists
)
{
if
(!
ListUtils
.
isEmpty
(
lists
))
{
return
lists
;
}
return
Lists
.
newArrayList
();
}
/**
* map查询结果判断
*
* @param lists
* @return
*/
public
static
<
K
,
V
>
Map
<
K
,
V
>
map
(
Map
<
K
,
V
>
map
)
{
if
(!
MapUtils
.
isEmpty
(
map
))
{
return
map
;
}
return
Maps
.
newHashMap
();
}
/**
* 分页查询结果判断
*
* @param pageBeanNew
* @return
*/
public
static
<
T
>
PageBeanNew
<
T
>
pageBeanNew
(
PageBeanNew
<
T
>
pageBeanNew
,
Integer
currentPage
,
Integer
numPerPage
)
{
if
(
pageBeanNew
!=
null
)
{
return
pageBeanNew
;
}
return
new
PageBeanNew
<
T
>(
currentPage
,
numPerPage
,
0
,
Lists
.
newArrayList
());
}
}
pcloud-common/src/main/java/com/pcloud/common/utils/pdf/PdfUtils.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
utils
.
pdf
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.List
;
import
org.apache.pdfbox.pdmodel.PDDocument
;
import
org.apache.pdfbox.rendering.PDFRenderer
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
com.google.common.collect.Lists
;
import
com.itextpdf.text.Chunk
;
import
com.itextpdf.text.Document
;
import
com.itextpdf.text.DocumentException
;
import
com.itextpdf.text.Font
;
import
com.itextpdf.text.Image
;
import
com.itextpdf.text.PageSize
;
import
com.itextpdf.text.Paragraph
;
import
com.itextpdf.text.Phrase
;
import
com.itextpdf.text.Rectangle
;
import
com.itextpdf.text.pdf.BaseFont
;
import
com.itextpdf.text.pdf.PdfContentByte
;
import
com.itextpdf.text.pdf.PdfPCell
;
import
com.itextpdf.text.pdf.PdfPTable
;
import
com.itextpdf.text.pdf.PdfReader
;
import
com.itextpdf.text.pdf.PdfStamper
;
import
com.itextpdf.text.pdf.PdfWriter
;
import
com.pcloud.common.constant.FilePathConst
;
import
com.pcloud.common.entity.UploadResultInfo
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.exceptions.FileException
;
import
com.pcloud.common.utils.FileUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.UUIDUitl
;
import
com.pcloud.common.utils.aliyun.OssUtils
;
import
com.pcloud.common.utils.pdf.po.PdfChunkPO
;
import
com.pcloud.common.utils.pdf.po.PdfImagePO
;
import
com.pcloud.common.utils.pdf.po.PdfPO
;
import
com.pcloud.common.utils.pdf.po.PdfTablePO
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.tools.pdf.convert.image.PdfToImage
;
import
javax.imageio.ImageIO
;
/**
* @author Administrator
*/
@Component
(
"pdfUtils"
)
public
class
PdfUtils
{
/**
*
*/
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
PdfUtils
.
class
);
/**
* PDF转换图片的宽度
*/
public
static
final
Integer
IMAGE_WITH
=
1654
;
/**
* PDF转换图片的高度
*/
public
static
final
Integer
IMAGE_HEIGHT
=
2399
;
/**
* PDF文件转换图片
*
* @param fileUrl
* @param format
* @return
* @throws Exception
*/
public
static
List
<
UploadResultInfo
>
pdfToImage
(
String
fileUrl
,
String
format
)
throws
FileException
{
String
fileName
=
FileUtils
.
getFileName
(
fileUrl
);
// 下载PDF文件
byte
[]
bytes
=
FileUtils
.
downloadByteFromUrl
(
fileUrl
);
if
(
bytes
==
null
)
{
throw
new
FileException
(
FileException
.
FILE_DOWNLOAD_FAILURE
,
"下载文件失败"
);
}
if
(
bytes
.
length
==
0
)
{
return
Lists
.
newArrayList
();
}
// 解析PDF文件
String
outPath
=
pdfConvert
(
bytes
,
fileName
,
""
,
format
);
// 上传图片文件
return
pdfImageUpload
(
outPath
,
fileName
,
format
);
}
/**
* PDF文件转换图片
*
* @param fileUrl
* @param format
* @return
*/
public
static
List
<
UploadResultInfo
>
pdf2Image
(
String
fileUrl
,
String
format
)
{
String
fileName
=
FileUtils
.
getFileName
(
fileUrl
);
String
filePath
=
FilePathConst
.
DOWNLOAD_PATH
+
fileName
+
"_"
+
UUIDUitl
.
generateString
(
12
);
String
outputPath
=
FilePathConst
.
PDF_PATH
+
fileName
+
"_"
+
UUIDUitl
.
generateString
(
12
);
try
{
FileUtils
.
downloadFileFromUrl
(
fileUrl
,
filePath
);
File
outputDir
=
new
File
(
outputPath
);
if
(!
outputDir
.
exists
())
{
outputDir
.
mkdir
();
}
File
file
=
new
File
(
filePath
);
if
(!
file
.
exists
())
{
LOGGER
.
error
(
fileUrl
+
" download error"
);
throw
new
FileException
(
FileException
.
FILE_DOWNLOAD_FAILURE
,
"下载文件失败"
);
}
LOGGER
.
info
(
"pdf downloaded to Folder: "
+
outputDir
.
getName
());
PDDocument
document
=
PDDocument
.
load
(
new
File
(
filePath
));
int
total
=
document
.
getNumberOfPages
();
LOGGER
.
info
(
"Total images to be converted: "
+
total
);
PDFRenderer
render
=
new
PDFRenderer
(
document
);
for
(
int
i
=
0
;
i
<
total
;
i
++)
{
BufferedImage
image
=
render
.
renderImage
(
i
,
2.0f
);
File
outputfile
=
new
File
(
outputPath
+
"page"
+
(
i
+
1
)
+
"."
+
format
);
ImageIO
.
write
(
image
,
format
,
outputfile
);
}
document
.
close
();
LOGGER
.
info
(
"Converted Images are saved at: "
+
outputDir
.
getAbsolutePath
());
return
pdfImageUpload
(
outputPath
,
fileName
,
format
);
}
catch
(
Exception
e
)
{
LOGGER
.
warn
(
"pdf convert error"
,
e
);
return
pdfToImage
(
fileUrl
,
format
);
}
}
/**
* PDF转换文件
*
* @param b
* @param fileName
* @param prefix
* @param format
* @return
* @throws Exception
*/
private
static
String
pdfConvert
(
byte
[]
b
,
String
fileName
,
String
prefix
,
String
format
)
throws
FileException
{
// 解析PDF文件
String
outPath
=
FilePathConst
.
PDF_PATH
+
fileName
+
"_"
+
UUIDUitl
.
generateString
(
12
);
File
fi
=
new
File
(
outPath
);
if
(!
fi
.
exists
())
{
fi
.
mkdirs
();
}
try
{
PdfToImage
pImage
=
new
PdfToImage
(
IMAGE_WITH
,
IMAGE_HEIGHT
,
prefix
,
format
);
pImage
.
convertPagesToHiResImages
(
b
,
outPath
);
}
catch
(
Exception
e
)
{
FileUtils
.
deleteDirectory
(
outPath
);
LOGGER
.
error
(
"【PDF】PDF转换图片失败:"
+
e
.
getMessage
(),
e
);
throw
new
FileException
(
FileException
.
FILE_CONTENT_ERROR
,
"PDF转换图片失败"
);
}
return
outPath
;
}
/**
* PDF图片上传
*
* @param outPath
* @param format
* @return
* @throws Exception
*/
private
static
List
<
UploadResultInfo
>
pdfImageUpload
(
String
outPath
,
String
fileName
,
String
format
)
throws
FileException
{
List
<
UploadResultInfo
>
list
=
Lists
.
newArrayList
();
try
{
File
[]
fileArray
=
new
File
(
outPath
).
listFiles
();
for
(
int
i
=
0
;
i
<
fileArray
.
length
;
i
++)
{
// modify by songx at 2017-05-19
// PDF工具包生成的图片已pageXXX命名,所以取XXX为文件的页数
String
childDileName
=
FileUtils
.
getFileName
(
fileArray
[
i
].
getName
());
int
page
=
Integer
.
valueOf
(
childDileName
.
replace
(
"page"
,
""
));
UploadResultInfo
uploadResultInfo
=
OssUtils
.
uploadLocalFile4CustomName
(
fileArray
[
i
].
getPath
(),
fileName
+
"_"
+
page
);
if
(
uploadResultInfo
==
null
)
{
throw
new
FileException
(
FileException
.
FILE_CONTENT_ERROR
,
"PDF转换图片上传失败:第"
+
i
+
"张"
);
}
uploadResultInfo
.
setFileName
(
childDileName
);
uploadResultInfo
.
setFileType
(
format
);
uploadResultInfo
.
setPage
(
page
);
list
.
add
(
uploadResultInfo
);
}
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"【PDF】PDF转换图片上传失败:"
+
e
.
getMessage
(),
e
);
throw
new
FileException
(
FileException
.
FILE_UPLOAD_FAILURE
,
"PDF转换图片上传失败"
);
}
finally
{
FileUtils
.
deleteDirectory
(
outPath
);
}
return
list
;
}
/**
* 创建PDF
*
* @param pdfChunkDOs
* @return
* @throws Exception
*/
public
static
String
create
(
List
<
PdfPO
>
pdfPOs
)
throws
FileException
{
LOGGER
.
info
(
"【PDF】创建PDF文档,<START>"
);
if
(
ListUtils
.
isEmpty
(
pdfPOs
))
{
return
null
;
}
String
outPath
=
null
;
PdfWriter
pdfWriter
=
null
;
Document
document
=
null
;
OutputStream
os
=
null
;
try
{
// 输出路径
outPath
=
FilePathConst
.
PDF_PATH
+
UUIDUitl
.
taskName
()
+
".pdf"
;
FileUtils
.
creatFiles
(
outPath
);
// 创建输出流
os
=
new
FileOutputStream
(
new
File
(
outPath
));
// 初始化文档
// 设置纸张
Rectangle
rect
=
new
Rectangle
(
PageSize
.
A4
);
// 创建文档实例
document
=
new
Document
(
rect
,
50
,
50
,
50
,
50
);
pdfWriter
=
PdfWriter
.
getInstance
(
document
,
os
);
document
.
open
();
document
.
newPage
();
// 添加内容添加PDF实例中
addChunks
(
pdfPOs
,
document
);
}
catch
(
Exception
e
)
{
FileUtils
.
deleteFile
(
outPath
);
LOGGER
.
error
(
"【PDF】创建PDF文档失败:"
+
e
.
getMessage
(),
e
);
throw
new
FileException
(
FileException
.
FILE_CONTENT_ERROR
,
e
.
getMessage
());
}
finally
{
close
(
document
,
os
,
pdfWriter
);
}
LOGGER
.
info
(
"【PDF】创建PDF文档,<END>"
);
return
outPath
;
}
/**
* 添加内容到PDF中
*
* @param pdfPOs
* @param document
* @throws BizException
* @throws DocumentException
* @throws MalformedURLException
* @throws IOException
*/
private
static
void
addChunks
(
List
<
PdfPO
>
pdfPOs
,
Document
document
)
throws
BizException
,
DocumentException
,
MalformedURLException
,
IOException
{
for
(
PdfPO
pdfPO
:
pdfPOs
)
{
if
(
pdfPO
instanceof
PdfChunkPO
)
{
addChunk
(
pdfPO
,
document
);
}
else
if
(
pdfPO
instanceof
PdfTablePO
)
{
addTable
(
pdfPO
,
document
);
}
else
if
(
pdfPO
instanceof
PdfImagePO
)
{
addImage
(
pdfPO
,
document
);
}
}
}
/**
* 添加块
*
* @param pdfPO
* @throws BizException
* @throws DocumentException
*/
private
static
void
addChunk
(
PdfPO
pdfPO
,
Document
document
)
throws
BizException
,
DocumentException
{
PdfChunkPO
pdfChunkPO
=
(
PdfChunkPO
)
pdfPO
;
// 段落
Paragraph
paragraph
=
null
;
Font
font
=
PdfFontUtils
.
getByType
(
pdfChunkPO
.
getPdfFontEnum
());
if
(
pdfChunkPO
.
isLeanding
())
{
paragraph
=
new
Paragraph
(
pdfChunkPO
.
getText
(),
font
);
paragraph
.
setLeading
(
pdfChunkPO
.
getLeading
()
>
0
?
pdfChunkPO
.
getLeading
()
:
Float
.
NaN
);
}
else
{
paragraph
=
new
Paragraph
();
// 短语
Phrase
phrase
=
new
Phrase
();
// 短语中的某一块
Chunk
chunk
=
new
Chunk
(
StringUtil
.
isEmpty
(
pdfChunkPO
.
getText
())
?
""
:
pdfChunkPO
.
getText
(),
font
);
// skew大于0 的时候生效.字体倾斜角度
if
(
pdfChunkPO
.
getSkew
()
>
0
)
{
chunk
.
setSkew
(
0
,
pdfChunkPO
.
getSkew
());
}
// 将块添加到短语
phrase
.
add
(
chunk
);
// 将短语添加到段落
paragraph
.
add
(
phrase
);
}
// 段落前间距
paragraph
.
setSpacingBefore
(
pdfChunkPO
.
getSpacingBefore
()
>
0
?
pdfChunkPO
.
getSpacingBefore
()
:
Float
.
NaN
);
// 段落后间距
paragraph
.
setSpacingAfter
(
pdfChunkPO
.
getSpacingAfter
()
>
0
?
pdfChunkPO
.
getSpacingAfter
()
:
Float
.
NaN
);
// 段落位置
paragraph
.
setAlignment
(
pdfChunkPO
.
getPdfAlignEnum
().
value
);
// 将段落添加到文档
document
.
add
(
paragraph
);
}
/**
* 添加表格
*
* @param pdfPO
* @throws BizException
* @throws DocumentException
*/
private
static
void
addTable
(
PdfPO
pdfPO
,
Document
document
)
throws
BizException
,
DocumentException
{
PdfTablePO
pdfTablePO
=
(
PdfTablePO
)
pdfPO
;
String
[][]
contents
=
pdfTablePO
.
getContents
();
if
(
contents
==
null
||
contents
.
length
<
1
)
{
return
;
}
int
rowNum
=
contents
.
length
;
// 总行数
int
colNum
=
pdfTablePO
.
getColumnWidths
().
length
;
// 总列数
if
(
colNum
<
1
)
{
throw
new
FileException
(
FileException
.
FILE_CONTENT_ERROR
,
"表格列数与内容列数不一致"
);
}
// 字体
Font
font
=
PdfFontUtils
.
getByType
(
pdfTablePO
.
getPdfFontEnum
());
// 创建表格
PdfPTable
table
=
new
PdfPTable
(
colNum
);
table
.
setTotalWidth
(
pdfTablePO
.
getColumnWidths
());
// 设置列宽
table
.
setLockedWidth
(
true
);
// 锁定列宽
// 设置行和列
for
(
int
i
=
0
;
i
<
rowNum
;
i
++)
{
String
[]
cols
=
contents
[
i
];
for
(
int
j
=
0
;
j
<
colNum
;
j
++)
{
String
text
=
(
j
>=
cols
.
length
||
StringUtil
.
isEmpty
(
cols
[
j
]))
?
""
:
cols
[
j
];
// 填充单元格内容
PdfPCell
cell
=
new
PdfPCell
(
new
Phrase
(
text
,
font
));
// 设置上边的边框宽度
cell
.
setBorderWidthTop
(
1
);
// 设置左边的边框宽度
cell
.
setBorderWidthLeft
(
1
);
// 设置右边的边框宽度
if
(
j
==
(
colNum
-
1
))
{
cell
.
setBorderWidthRight
(
1
);
}
// 设置底部的边框宽度
if
(
i
==
(
rowNum
-
1
))
{
cell
.
setBorderWidthBottom
(
1
);
}
// 设置单元格高度
cell
.
setMinimumHeight
(
pdfTablePO
.
getMinimumHeight
()
>
0
?
pdfTablePO
.
getMinimumHeight
()
:
Float
.
NaN
);
// 设置可以居中
cell
.
setUseAscender
(
true
);
// 设置水平居中
cell
.
setHorizontalAlignment
(
pdfTablePO
.
getPdfAlignEnum
().
value
);
// 设置垂直居中
cell
.
setVerticalAlignment
(
PdfPCell
.
ALIGN_MIDDLE
);
table
.
addCell
(
cell
);
}
}
// 将表格添加到文档
document
.
add
(
table
);
}
/**
* 添加图片
*
* @param pdfPO
* @param document
* @throws MalformedURLException
* @throws IOException
* @throws DocumentException
*/
private
static
void
addImage
(
PdfPO
pdfPO
,
Document
document
)
throws
MalformedURLException
,
IOException
,
DocumentException
{
PdfImagePO
pdfImagePO
=
(
PdfImagePO
)
pdfPO
;
Image
image
=
null
;
if
(!
StringUtil
.
isEmpty
(
pdfImagePO
.
getImageUrl
()))
{
if
(
pdfImagePO
.
getImageUrl
().
startsWith
(
"http"
))
{
image
=
Image
.
getInstance
(
new
URL
(
pdfImagePO
.
getImageUrl
()));
}
else
{
image
=
Image
.
getInstance
(
pdfImagePO
.
getImageUrl
());
}
image
.
setAlignment
(
pdfImagePO
.
getPdfAlignEnum
().
value
);
if
(
pdfImagePO
.
getHeight
()
>
0
||
pdfImagePO
.
getWidth
()
>
0
)
{
image
.
scaleAbsolute
(
pdfImagePO
.
getHeight
(),
pdfImagePO
.
getWidth
());
}
}
else
if
(
pdfImagePO
.
getImageByte
()
!=
null
)
{
image
=
Image
.
getInstance
(
pdfImagePO
.
getImageByte
());
}
else
{
return
;
}
// 将表格添加到文档
document
.
add
(
image
);
}
/**
* 加水印(字符串)
*
* @param inputFile 需要加水印的PDF路径
* @param outputFile 输出生成PDF的路径
* @param waterMarkName 水印字符
*/
public
static
void
stringWaterMark
(
String
filePath
,
String
waterMarkName
)
{
PdfReader
reader
=
null
;
PdfStamper
stamper
=
null
;
OutputStream
os
=
null
;
try
{
reader
=
new
PdfReader
(
filePath
);
os
=
new
FileOutputStream
(
filePath
);
stamper
=
new
PdfStamper
(
reader
,
os
);
// 添加中文字体
BaseFont
bfChinese
=
BaseFont
.
createFont
(
"STSong-Light"
,
"UniGB-UCS2-H"
,
BaseFont
.
NOT_EMBEDDED
);
int
total
=
reader
.
getNumberOfPages
()
+
1
;
PdfContentByte
under
;
int
j
=
waterMarkName
.
length
();
char
c
=
0
;
int
rise
=
0
;
// 给每一页加水印
for
(
int
i
=
1
;
i
<
total
;
i
++)
{
rise
=
400
;
under
=
stamper
.
getUnderContent
(
i
);
under
.
beginText
();
under
.
setFontAndSize
(
bfChinese
,
30
);
under
.
setTextMatrix
(
200
,
120
);
for
(
int
k
=
0
;
k
<
j
;
k
++)
{
under
.
setTextRise
(
rise
);
c
=
waterMarkName
.
charAt
(
k
);
under
.
showText
(
c
+
""
);
}
// 添加水印文字
under
.
endText
();
}
stamper
.
close
();
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"【PDF】添加水印字符串失败:"
+
e
.
getMessage
(),
e
);
}
finally
{
try
{
if
(
os
!=
null
)
{
os
.
close
();
}
if
(
reader
!=
null
)
{
reader
.
close
();
}
if
(
stamper
!=
null
)
{
stamper
.
close
();
}
}
catch
(
Exception
e
)
{
}
}
}
/**
* 加水印(图片)
*
* @param inputFile
* 需要加水印的PDF路径
* @param outputFile
* 输出生成PDF的路径
* @param imageFile
* 水印图片路径
*/
// public static void imageWaterMark(String inputFile, String imageFile) {
// try {
// String[] spe = separatePath(inputFile);
// String outputFile = spe[0] + "_WM." + spe[1];
//
// PdfReader reader = new PdfReader(inputFile);
// PdfStamper stamper = new PdfStamper(reader, new
// FileOutputStream(outputFile));
//
// int total = reader.getNumberOfPages() + 1;
//
// Image image = Image.getInstance(imageFile);
// image.setAbsolutePosition(-100, 0);// 坐标
// image.scaleAbsolute(800, 1000);// 自定义大小
// // image.setRotation(-20);//旋转 弧度
// // image.setRotationDegrees(-45);//旋转 角度
// // image.scalePercent(50);//依照比例缩放
// PdfGState gs = new PdfGState();
// gs.setFillOpacity(0.2f);// 设置透明度为0.2
// PdfContentByte under;
// // 给每一页加水印
// for (int i = 1; i < total; i++) {
// under = stamper.getUnderContent(i);
// under.beginText();
// // 添加水印图片
// under.addImage(image);
// under.setGState(gs);
// }
// stamper.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
/**
* 结束关闭文件流
*
* @param document
* @param os
*/
private
static
void
close
(
Document
document
,
OutputStream
os
,
PdfWriter
pdfWriter
)
{
try
{
if
(
document
!=
null
)
{
document
.
close
();
document
=
null
;
}
if
(
os
!=
null
)
{
os
.
close
();
os
=
null
;
}
if
(
pdfWriter
!=
null
)
{
pdfWriter
.
close
();
}
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"【PDF】PDF文件流关闭失败:"
+
e
.
getMessage
(),
e
);
}
}
}
package
com
.
pcloud
.
common
.
utils
.
pdf
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
com.google.common.collect.Lists
;
import
com.itextpdf.text.Chunk
;
import
com.itextpdf.text.Document
;
import
com.itextpdf.text.DocumentException
;
import
com.itextpdf.text.Font
;
import
com.itextpdf.text.Image
;
import
com.itextpdf.text.PageSize
;
import
com.itextpdf.text.Paragraph
;
import
com.itextpdf.text.Phrase
;
import
com.itextpdf.text.Rectangle
;
import
com.itextpdf.text.pdf.BaseFont
;
import
com.itextpdf.text.pdf.PdfContentByte
;
import
com.itextpdf.text.pdf.PdfPCell
;
import
com.itextpdf.text.pdf.PdfPTable
;
import
com.itextpdf.text.pdf.PdfReader
;
import
com.itextpdf.text.pdf.PdfStamper
;
import
com.itextpdf.text.pdf.PdfWriter
;
import
com.pcloud.common.constant.FilePathConst
;
import
com.pcloud.common.entity.UploadResultInfo
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.exceptions.FileException
;
import
com.pcloud.common.utils.FileUtils
;
import
com.pcloud.common.utils.ListUtils
;
import
com.pcloud.common.utils.UUIDUitl
;
import
com.pcloud.common.utils.aliyun.OssUtils
;
import
com.pcloud.common.utils.pdf.po.PdfChunkPO
;
import
com.pcloud.common.utils.pdf.po.PdfImagePO
;
import
com.pcloud.common.utils.pdf.po.PdfPO
;
import
com.pcloud.common.utils.pdf.po.PdfTablePO
;
import
com.pcloud.common.utils.string.StringUtil
;
/**
* @author Administrator
*/
@Component
(
"pdfUtils"
)
public
class
PdfUtils
{
/**
*
*/
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
PdfUtils
.
class
);
/**
* PDF转换图片的宽度
*/
public
static
final
Integer
IMAGE_WITH
=
1654
;
/**
* PDF转换图片的高度
*/
public
static
final
Integer
IMAGE_HEIGHT
=
2399
;
/**
* PDF文件转换图片
*
* @param fileUrl
* @param format
* @return
* @throws Exception
*/
@Deprecated
public
static
List
<
UploadResultInfo
>
pdfToImage
(
String
fileUrl
,
String
format
)
throws
FileException
{
if
(
StringUtil
.
isEmpty
(
fileUrl
))
return
null
;
if
(!
StringUtil
.
isEmpty
(
fileUrl
))
return
null
;
String
fileName
=
FileUtils
.
getFileName
(
fileUrl
);
// 下载PDF文件
byte
[]
bytes
=
FileUtils
.
downloadByteFromUrl
(
fileUrl
);
if
(
bytes
==
null
)
{
throw
new
FileException
(
FileException
.
FILE_DOWNLOAD_FAILURE
,
"下载文件失败"
);
}
if
(
bytes
.
length
==
0
)
{
return
Lists
.
newArrayList
();
}
// 解析PDF文件
String
outPath
=
pdfConvert
(
bytes
,
fileName
,
""
,
format
);
// 上传图片文件
return
pdfImageUpload
(
outPath
,
fileName
,
format
);
}
/**
* PDF转换文件
*
* @param b
* @param fileName
* @param prefix
* @param format
* @return
* @throws Exception
*/
private
static
String
pdfConvert
(
byte
[]
b
,
String
fileName
,
String
prefix
,
String
format
)
throws
FileException
{
// 解析PDF文件
String
outPath
=
FilePathConst
.
PDF_PATH
+
fileName
+
"_"
+
UUIDUitl
.
generateString
(
12
);
File
fi
=
new
File
(
outPath
);
if
(!
fi
.
exists
())
{
fi
.
mkdirs
();
}
try
{
// PdfToImage pImage = new PdfToImage(IMAGE_WITH, IMAGE_HEIGHT, prefix, format);
// pImage.convertPagesToHiResImages(b, outPath);
}
catch
(
Exception
e
)
{
FileUtils
.
deleteDirectory
(
outPath
);
LOGGER
.
error
(
"【PDF】PDF转换图片失败:"
+
e
.
getMessage
(),
e
);
throw
new
FileException
(
FileException
.
FILE_CONTENT_ERROR
,
"PDF转换图片失败"
);
}
return
outPath
;
}
/**
* PDF图片上传
*
* @param outPath
* @param format
* @return
* @throws Exception
*/
private
static
List
<
UploadResultInfo
>
pdfImageUpload
(
String
outPath
,
String
fileName
,
String
format
)
throws
FileException
{
List
<
UploadResultInfo
>
list
=
Lists
.
newArrayList
();
try
{
File
[]
fileArray
=
new
File
(
outPath
).
listFiles
();
for
(
int
i
=
0
;
i
<
fileArray
.
length
;
i
++)
{
// modify by songx at 2017-05-19
// PDF工具包生成的图片已pageXXX命名,所以取XXX为文件的页数
String
childDileName
=
FileUtils
.
getFileName
(
fileArray
[
i
].
getName
());
int
page
=
Integer
.
valueOf
(
childDileName
.
replace
(
"page"
,
""
));
UploadResultInfo
uploadResultInfo
=
OssUtils
.
uploadLocalFile4CustomName
(
fileArray
[
i
].
getPath
(),
fileName
+
"_"
+
page
);
if
(
uploadResultInfo
==
null
)
{
throw
new
FileException
(
FileException
.
FILE_CONTENT_ERROR
,
"PDF转换图片上传失败:第"
+
i
+
"张"
);
}
uploadResultInfo
.
setFileName
(
childDileName
);
uploadResultInfo
.
setFileType
(
format
);
uploadResultInfo
.
setPage
(
page
);
list
.
add
(
uploadResultInfo
);
}
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"【PDF】PDF转换图片上传失败:"
+
e
.
getMessage
(),
e
);
throw
new
FileException
(
FileException
.
FILE_UPLOAD_FAILURE
,
"PDF转换图片上传失败"
);
}
finally
{
FileUtils
.
deleteDirectory
(
outPath
);
}
return
list
;
}
/**
* 创建PDF
*
* @param pdfChunkDOs
* @return
* @throws Exception
*/
public
static
String
create
(
List
<
PdfPO
>
pdfPOs
)
throws
FileException
{
LOGGER
.
info
(
"【PDF】创建PDF文档,<START>"
);
if
(
ListUtils
.
isEmpty
(
pdfPOs
))
{
return
null
;
}
String
outPath
=
null
;
PdfWriter
pdfWriter
=
null
;
Document
document
=
null
;
OutputStream
os
=
null
;
try
{
// 输出路径
outPath
=
FilePathConst
.
PDF_PATH
+
UUIDUitl
.
taskName
()
+
".pdf"
;
FileUtils
.
creatFiles
(
outPath
);
// 创建输出流
os
=
new
FileOutputStream
(
new
File
(
outPath
));
// 初始化文档
// 设置纸张
Rectangle
rect
=
new
Rectangle
(
PageSize
.
A4
);
// 创建文档实例
document
=
new
Document
(
rect
,
50
,
50
,
50
,
50
);
pdfWriter
=
PdfWriter
.
getInstance
(
document
,
os
);
document
.
open
();
document
.
newPage
();
// 添加内容添加PDF实例中
addChunks
(
pdfPOs
,
document
);
}
catch
(
Exception
e
)
{
FileUtils
.
deleteFile
(
outPath
);
LOGGER
.
error
(
"【PDF】创建PDF文档失败:"
+
e
.
getMessage
(),
e
);
throw
new
FileException
(
FileException
.
FILE_CONTENT_ERROR
,
e
.
getMessage
());
}
finally
{
close
(
document
,
os
,
pdfWriter
);
}
LOGGER
.
info
(
"【PDF】创建PDF文档,<END>"
);
return
outPath
;
}
/**
* 添加内容到PDF中
*
* @param pdfPOs
* @param document
* @throws BizException
* @throws DocumentException
* @throws MalformedURLException
* @throws IOException
*/
private
static
void
addChunks
(
List
<
PdfPO
>
pdfPOs
,
Document
document
)
throws
BizException
,
DocumentException
,
MalformedURLException
,
IOException
{
for
(
PdfPO
pdfPO
:
pdfPOs
)
{
if
(
pdfPO
instanceof
PdfChunkPO
)
{
addChunk
(
pdfPO
,
document
);
}
else
if
(
pdfPO
instanceof
PdfTablePO
)
{
addTable
(
pdfPO
,
document
);
}
else
if
(
pdfPO
instanceof
PdfImagePO
)
{
addImage
(
pdfPO
,
document
);
}
}
}
/**
* 添加块
*
* @param pdfPO
* @throws BizException
* @throws DocumentException
*/
private
static
void
addChunk
(
PdfPO
pdfPO
,
Document
document
)
throws
BizException
,
DocumentException
{
PdfChunkPO
pdfChunkPO
=
(
PdfChunkPO
)
pdfPO
;
// 段落
Paragraph
paragraph
=
null
;
Font
font
=
PdfFontUtils
.
getByType
(
pdfChunkPO
.
getPdfFontEnum
());
if
(
pdfChunkPO
.
isLeanding
())
{
paragraph
=
new
Paragraph
(
pdfChunkPO
.
getText
(),
font
);
paragraph
.
setLeading
(
pdfChunkPO
.
getLeading
()
>
0
?
pdfChunkPO
.
getLeading
()
:
Float
.
NaN
);
}
else
{
paragraph
=
new
Paragraph
();
// 短语
Phrase
phrase
=
new
Phrase
();
// 短语中的某一块
Chunk
chunk
=
new
Chunk
(
StringUtil
.
isEmpty
(
pdfChunkPO
.
getText
())
?
""
:
pdfChunkPO
.
getText
(),
font
);
// skew大于0 的时候生效.字体倾斜角度
if
(
pdfChunkPO
.
getSkew
()
>
0
)
{
chunk
.
setSkew
(
0
,
pdfChunkPO
.
getSkew
());
}
// 将块添加到短语
phrase
.
add
(
chunk
);
// 将短语添加到段落
paragraph
.
add
(
phrase
);
}
// 段落前间距
paragraph
.
setSpacingBefore
(
pdfChunkPO
.
getSpacingBefore
()
>
0
?
pdfChunkPO
.
getSpacingBefore
()
:
Float
.
NaN
);
// 段落后间距
paragraph
.
setSpacingAfter
(
pdfChunkPO
.
getSpacingAfter
()
>
0
?
pdfChunkPO
.
getSpacingAfter
()
:
Float
.
NaN
);
// 段落位置
paragraph
.
setAlignment
(
pdfChunkPO
.
getPdfAlignEnum
().
value
);
// 将段落添加到文档
document
.
add
(
paragraph
);
}
/**
* 添加表格
*
* @param pdfPO
* @throws BizException
* @throws DocumentException
*/
private
static
void
addTable
(
PdfPO
pdfPO
,
Document
document
)
throws
BizException
,
DocumentException
{
PdfTablePO
pdfTablePO
=
(
PdfTablePO
)
pdfPO
;
String
[][]
contents
=
pdfTablePO
.
getContents
();
if
(
contents
==
null
||
contents
.
length
<
1
)
{
return
;
}
int
rowNum
=
contents
.
length
;
// 总行数
int
colNum
=
pdfTablePO
.
getColumnWidths
().
length
;
// 总列数
if
(
colNum
<
1
)
{
throw
new
FileException
(
FileException
.
FILE_CONTENT_ERROR
,
"表格列数与内容列数不一致"
);
}
// 字体
Font
font
=
PdfFontUtils
.
getByType
(
pdfTablePO
.
getPdfFontEnum
());
// 创建表格
PdfPTable
table
=
new
PdfPTable
(
colNum
);
table
.
setTotalWidth
(
pdfTablePO
.
getColumnWidths
());
// 设置列宽
table
.
setLockedWidth
(
true
);
// 锁定列宽
// 设置行和列
for
(
int
i
=
0
;
i
<
rowNum
;
i
++)
{
String
[]
cols
=
contents
[
i
];
for
(
int
j
=
0
;
j
<
colNum
;
j
++)
{
String
text
=
(
j
>=
cols
.
length
||
StringUtil
.
isEmpty
(
cols
[
j
]))
?
""
:
cols
[
j
];
// 填充单元格内容
PdfPCell
cell
=
new
PdfPCell
(
new
Phrase
(
text
,
font
));
// 设置上边的边框宽度
cell
.
setBorderWidthTop
(
1
);
// 设置左边的边框宽度
cell
.
setBorderWidthLeft
(
1
);
// 设置右边的边框宽度
if
(
j
==
(
colNum
-
1
))
{
cell
.
setBorderWidthRight
(
1
);
}
// 设置底部的边框宽度
if
(
i
==
(
rowNum
-
1
))
{
cell
.
setBorderWidthBottom
(
1
);
}
// 设置单元格高度
cell
.
setMinimumHeight
(
pdfTablePO
.
getMinimumHeight
()
>
0
?
pdfTablePO
.
getMinimumHeight
()
:
Float
.
NaN
);
// 设置可以居中
cell
.
setUseAscender
(
true
);
// 设置水平居中
cell
.
setHorizontalAlignment
(
pdfTablePO
.
getPdfAlignEnum
().
value
);
// 设置垂直居中
cell
.
setVerticalAlignment
(
PdfPCell
.
ALIGN_MIDDLE
);
table
.
addCell
(
cell
);
}
}
// 将表格添加到文档
document
.
add
(
table
);
}
/**
* 添加图片
*
* @param pdfPO
* @param document
* @throws MalformedURLException
* @throws IOException
* @throws DocumentException
*/
private
static
void
addImage
(
PdfPO
pdfPO
,
Document
document
)
throws
MalformedURLException
,
IOException
,
DocumentException
{
PdfImagePO
pdfImagePO
=
(
PdfImagePO
)
pdfPO
;
Image
image
=
null
;
if
(!
StringUtil
.
isEmpty
(
pdfImagePO
.
getImageUrl
()))
{
if
(
pdfImagePO
.
getImageUrl
().
startsWith
(
"http"
))
{
image
=
Image
.
getInstance
(
new
URL
(
pdfImagePO
.
getImageUrl
()));
}
else
{
image
=
Image
.
getInstance
(
pdfImagePO
.
getImageUrl
());
}
image
.
setAlignment
(
pdfImagePO
.
getPdfAlignEnum
().
value
);
if
(
pdfImagePO
.
getHeight
()
>
0
||
pdfImagePO
.
getWidth
()
>
0
)
{
image
.
scaleAbsolute
(
pdfImagePO
.
getHeight
(),
pdfImagePO
.
getWidth
());
}
}
else
if
(
pdfImagePO
.
getImageByte
()
!=
null
)
{
image
=
Image
.
getInstance
(
pdfImagePO
.
getImageByte
());
}
else
{
return
;
}
// 将表格添加到文档
document
.
add
(
image
);
}
/**
* 加水印(字符串)
*
* @param inputFile
* 需要加水印的PDF路径
* @param outputFile
* 输出生成PDF的路径
* @param waterMarkName
* 水印字符
*/
public
static
void
stringWaterMark
(
String
filePath
,
String
waterMarkName
)
{
PdfReader
reader
=
null
;
PdfStamper
stamper
=
null
;
OutputStream
os
=
null
;
try
{
reader
=
new
PdfReader
(
filePath
);
os
=
new
FileOutputStream
(
filePath
);
stamper
=
new
PdfStamper
(
reader
,
os
);
// 添加中文字体
BaseFont
bfChinese
=
BaseFont
.
createFont
(
"STSong-Light"
,
"UniGB-UCS2-H"
,
BaseFont
.
NOT_EMBEDDED
);
int
total
=
reader
.
getNumberOfPages
()
+
1
;
PdfContentByte
under
;
int
j
=
waterMarkName
.
length
();
char
c
=
0
;
int
rise
=
0
;
// 给每一页加水印
for
(
int
i
=
1
;
i
<
total
;
i
++)
{
rise
=
400
;
under
=
stamper
.
getUnderContent
(
i
);
under
.
beginText
();
under
.
setFontAndSize
(
bfChinese
,
30
);
under
.
setTextMatrix
(
200
,
120
);
for
(
int
k
=
0
;
k
<
j
;
k
++)
{
under
.
setTextRise
(
rise
);
c
=
waterMarkName
.
charAt
(
k
);
under
.
showText
(
c
+
""
);
}
// 添加水印文字
under
.
endText
();
}
stamper
.
close
();
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"【PDF】添加水印字符串失败:"
+
e
.
getMessage
(),
e
);
}
finally
{
try
{
if
(
os
!=
null
)
{
os
.
close
();
}
if
(
reader
!=
null
)
{
reader
.
close
();
}
if
(
stamper
!=
null
)
{
stamper
.
close
();
}
}
catch
(
Exception
e
)
{
}
}
}
/**
* 加水印(图片)
*
* @param inputFile
* 需要加水印的PDF路径
* @param outputFile
* 输出生成PDF的路径
* @param imageFile
* 水印图片路径
*/
// public static void imageWaterMark(String inputFile, String imageFile) {
// try {
// String[] spe = separatePath(inputFile);
// String outputFile = spe[0] + "_WM." + spe[1];
//
// PdfReader reader = new PdfReader(inputFile);
// PdfStamper stamper = new PdfStamper(reader, new
// FileOutputStream(outputFile));
//
// int total = reader.getNumberOfPages() + 1;
//
// Image image = Image.getInstance(imageFile);
// image.setAbsolutePosition(-100, 0);// 坐标
// image.scaleAbsolute(800, 1000);// 自定义大小
// // image.setRotation(-20);//旋转 弧度
// // image.setRotationDegrees(-45);//旋转 角度
// // image.scalePercent(50);//依照比例缩放
// PdfGState gs = new PdfGState();
// gs.setFillOpacity(0.2f);// 设置透明度为0.2
// PdfContentByte under;
// // 给每一页加水印
// for (int i = 1; i < total; i++) {
// under = stamper.getUnderContent(i);
// under.beginText();
// // 添加水印图片
// under.addImage(image);
// under.setGState(gs);
// }
// stamper.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
/**
* 结束关闭文件流
*
* @param document
* @param os
*/
private
static
void
close
(
Document
document
,
OutputStream
os
,
PdfWriter
pdfWriter
)
{
try
{
if
(
document
!=
null
)
{
document
.
close
();
document
=
null
;
}
if
(
os
!=
null
)
{
os
.
close
();
os
=
null
;
}
if
(
pdfWriter
!=
null
)
{
pdfWriter
.
close
();
}
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"【PDF】PDF文件流关闭失败:"
+
e
.
getMessage
(),
e
);
}
}
}
pcloud-common/src/main/java/com/pcloud/common/utils/solr/SolrUtils.java
View file @
c53cd2b9
...
...
@@ -19,6 +19,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.stereotype.Component
;
import
com.pcloud.common.utils.DateUtils
;
import
com.pcloud.common.utils.ListUtils
;
...
...
@@ -29,6 +30,7 @@ import com.pcloud.common.utils.ListUtils;
* @date 2018/4/23
*/
@Component
(
"solrUtils"
)
@PropertySource
(
value
=
"classpath:public_system.properties"
)
public
class
SolrUtils
{
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
SolrUtils
.
class
);
...
...
pcloud-common/src/main/java/com/pcloud/common/utils/string/StringUtil.java
View file @
c53cd2b9
package
com
.
pcloud
.
common
.
utils
.
string
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormatSymbols
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.StringTokenizer
;
import
java.util.UUID
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
com.pcloud.common.exceptions.BizException
;
/**
* @描述:字符串工具类
* @作者:DiSeng.H
* @创建时间:2016年3月10日,上午11:49:07 @版本:1.0
*/
public
class
StringUtil
extends
StringUtilParent
{
/**
* 判断字符串是否为空
*
* @param str
* @return
*/
public
static
boolean
isNotNull
(
String
str
)
{
if
(
str
!=
null
&&
!
""
.
equals
(
str
.
trim
()))
{
return
true
;
}
else
{
return
false
;
}
}
/**
* 判断对象是否为空
*
* @param str
* @return
*/
public
static
boolean
isNotNull
(
Object
obj
)
{
if
(
obj
!=
null
&&
obj
.
toString
()
!=
null
&&
!
""
.
equals
(
obj
.
toString
().
trim
()))
{
return
true
;
}
else
{
return
false
;
}
}
/**
* 判断字符串是否为空(自动截取首尾空白)
*
* @param str
* 源字符串
* @return
*/
public
static
boolean
isEmpty
(
String
str
)
{
return
isEmpty
(
str
,
true
);
}
/**
* 判断字符串是否为空
*
* @param str
* 源字符串
* @param trim
* 是否截取首尾空白
* @return
*/
public
static
boolean
isEmpty
(
String
str
,
boolean
trim
)
{
return
str
==
null
?
true
:
(
""
.
equals
(
str
.
trim
())
||
"null"
.
equals
(
str
.
trim
()));
}
/**
* 判断数组是否为空
*
* @param str
* @return
*/
public
static
boolean
isEmpty
(
String
[]
strs
)
{
return
strs
==
null
?
true
:
strs
.
length
==
0
;
}
/**
* @param str
* the string need to be parsed
* @param delim
* the delimiter to seperate created by zqf at 6/1/2013
*/
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
public
static
String
[]
parseToArray
(
String
str
,
String
delim
)
{
ArrayList
arr
=
new
ArrayList
();
StringTokenizer
st
=
new
StringTokenizer
(
str
,
delim
);
while
(
st
.
hasMoreTokens
())
{
arr
.
add
(
st
.
nextToken
());
}
String
[]
ret
=
new
String
[
arr
.
size
()];
for
(
int
i
=
0
;
i
<
arr
.
size
();
i
++)
{
ret
[
i
]
=
(
String
)
arr
.
get
(
i
);
}
return
ret
;
}
/**
* replace a old substring with rep in str
*
* @param str
* the string need to be replaced
* @param old
* the string need to be removed
* @param rep
* the string to be inserted
* @return string replaced
*/
public
static
String
replace
(
String
str
,
String
old
,
String
rep
)
{
if
((
str
==
null
)
||
(
old
==
null
)
||
(
rep
==
null
))
{
// if one is null
// return ""
return
""
;
}
int
index
=
str
.
indexOf
(
old
);
if
((
index
<
0
)
||
""
.
equals
(
old
))
{
// if no old string found or
// nothing to replace,return the
// origin
return
str
;
}
StringBuffer
strBuf
=
new
StringBuffer
(
str
);
while
(
index
>=
0
)
{
// found old part
strBuf
.
delete
(
index
,
index
+
old
.
length
());
strBuf
.
insert
(
index
,
rep
);
index
=
strBuf
.
toString
().
indexOf
(
old
);
}
return
strBuf
.
toString
();
}
/**
* 带逗号分隔的数字转换为NUMBER类型
*
* @param str
* @return
* @throws ParseException
*/
public
static
Number
stringToNumber
(
String
str
)
throws
ParseException
{
if
(
str
==
null
||
""
.
equals
(
str
))
{
return
null
;
}
DecimalFormatSymbols
dfs
=
new
DecimalFormatSymbols
();
dfs
.
setDecimalSeparator
(
'.'
);
dfs
.
setGroupingSeparator
(
','
);
dfs
.
setMonetaryDecimalSeparator
(
'.'
);
DecimalFormat
df
=
new
DecimalFormat
(
"###,###,###,###.##"
,
dfs
);
return
df
.
parse
(
str
);
}
public
static
String
getExtensionName
(
String
filename
)
{
if
((
filename
!=
null
)
&&
(
filename
.
length
()
>
0
))
{
int
dot
=
filename
.
lastIndexOf
(
'.'
);
if
((
dot
>
-
1
)
&&
(
dot
<
(
filename
.
length
()
-
1
)))
{
return
filename
.
substring
(
dot
+
1
);
}
}
return
filename
;
}
/**
* 用于字符串替换
*
* @param target
* 目标对象 需要替换的字符串
* @param replacement
* 要替换的字符串
* @param value
* 替换的值
* @return
*/
public
static
String
replacement
(
String
target
,
String
replacement
,
String
value
)
{
if
(
target
!=
null
)
return
target
.
replace
(
replacement
,
value
);
return
null
;
}
/**
* 判断字符串是否为数字
*
* @param str
* @return
*/
public
static
boolean
isNumeric
(
String
str
)
{
if
(
str
==
null
||
str
.
length
()
==
0
)
{
return
false
;
}
for
(
int
i
=
0
;
i
<
str
.
length
();
i
++)
{
if
(!
Character
.
isDigit
(
str
.
charAt
(
i
)))
{
return
false
;
}
}
return
true
;
}
/**
* 计算指定时间与当前时间的差
*
* @param date
* @return
*/
public
static
String
convDateToString
(
Date
date
)
{
Long
time
=
new
Date
().
getTime
()
-
date
.
getTime
();
Long
min
=
time
/
1000
/
60
;
if
(
min
<
5
)
{
return
"刚刚"
;
}
else
if
(
min
>=
5
&&
min
<
60
)
{
return
min
+
"分钟之前"
;
}
else
if
(
min
>=
60
&&
min
<
1440
)
{
return
min
/
60
+
"小时之前"
;
}
else
if
(
min
>=
1440
&&
min
<
10080
)
{
return
min
/
60
/
24
+
"天之前"
;
}
else
if
(
min
>=
10080
&&
min
<
40320
)
{
return
min
/
60
/
24
/
7
+
"周之前"
;
}
else
if
(
min
>=
40320
&&
min
<
525600
)
{
return
min
/
60
/
24
/
7
/
4
+
"月之前"
;
}
else
if
(
min
>=
525600
)
{
return
min
/
60
/
24
/
365
+
"年之前"
;
}
return
null
;
}
/**
* @description 获取当前服务器日期
* @return
*/
public
static
String
getCurrdate
(
String
formatStr
)
{
Calendar
cal
=
Calendar
.
getInstance
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
formatStr
);
String
mDateTime
=
formatter
.
format
(
cal
.
getTime
());
return
mDateTime
;
}
/**
* 将Object值转换成Double类型
*
* @param value
* @return
*/
public
static
double
getDoubleByObj
(
Object
value
)
{
if
(
value
==
null
)
{
return
0
;
}
return
Double
.
valueOf
(
String
.
valueOf
(
value
));
}
/**
* 将Object值转换成Float类型
*
* @param value
* @return
*/
public
static
float
getFloatByObj
(
Object
value
)
{
if
(
value
==
null
)
{
return
0
;
}
return
Float
.
valueOf
(
String
.
valueOf
(
value
));
}
/**
* 将Object值转换成Integer类型
*
* @param value
* @return
*/
public
static
Integer
getIntegerByObj
(
Object
value
)
{
if
(
value
==
null
)
{
return
0
;
}
return
Integer
.
valueOf
(
String
.
valueOf
(
value
));
}
/**
* 解析字符串 ---> 去掉字符串中回车、换行、空格
*
* @param str
* 被解析字符串
* @return String 解析后的字符串
*/
public
static
String
parse
(
String
str
)
{
return
str
.
replaceAll
(
"\n"
,
""
).
replaceAll
(
"chr(13)"
,
""
).
replaceAll
(
" "
,
""
);
}
public
static
Integer
[]
Str2Integers
(
String
value
)
{
if
(
null
==
value
||
!
org
.
springframework
.
util
.
StringUtils
.
hasText
(
value
))
{
return
null
;
}
String
[]
values
=
value
.
split
(
","
);
Integer
[]
v
=
new
Integer
[
values
.
length
];
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
v
[
i
]
=
Integer
.
parseInt
(
values
[
i
]);
}
return
v
;
}
public
static
String
[]
Str2Strings
(
String
value
)
{
if
(
null
==
value
||
!
org
.
springframework
.
util
.
StringUtils
.
hasText
(
value
))
{
return
null
;
}
String
[]
values
=
value
.
split
(
","
);
String
[]
v
=
new
String
[
values
.
length
];
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
v
[
i
]
=
values
[
i
];
}
return
v
;
}
public
static
int
strFormateInt
(
Object
obj
)
{
if
(
isNotNull
(
obj
))
{
return
"是"
.
equals
(
obj
)
?
1
:
0
;
}
else
{
return
0
;
}
}
/**
* 获取UUID
*
* @return UUID
*/
public
static
String
getUUID
()
{
return
(
UUID
.
randomUUID
()
+
""
).
replaceAll
(
"-"
,
""
);
}
/**
* 将字符串转移为ASCII码
*
* @param cnStr
* @return
*/
public
static
String
getCnASCII
(
String
cnStr
)
{
StringBuffer
strBuf
=
new
StringBuffer
();
byte
[]
bGBK
=
cnStr
.
getBytes
();
for
(
int
i
=
0
;
i
<
bGBK
.
length
;
i
++)
{
// System.out.println(Integer.toHexString(bGBK[i]&0xff));
strBuf
.
append
(
Integer
.
toHexString
(
bGBK
[
i
]
&
0xff
));
}
return
strBuf
.
toString
();
}
/**
*
* @param initCode
* 初始化编码
* @param length
* 需要生成编码长度
* @param ind
* 地增量
* @return 递增后的编码
*/
public
static
String
getNextCode
(
String
initCode
,
int
length
,
int
ind
)
{
Integer
temp
=
Integer
.
parseInt
(
initCode
);
temp
=
temp
+
ind
;
String
tempCode
=
temp
.
toString
();
int
tempLen
=
0
;
if
(
tempCode
.
length
()
<
length
)
{
tempLen
=
length
-
tempCode
.
length
();
}
for
(
int
i
=
0
;
i
<
tempLen
;
i
++)
{
tempCode
=
"0"
+
tempCode
;
}
return
tempCode
;
}
public
static
int
switchNumber
(
String
str
)
{
char
c
=
str
.
charAt
(
0
);
int
temp
=
0
;
switch
(
c
)
{
// 数值
case
'〇'
:
case
'零'
:
temp
=
0
;
break
;
case
'一'
:
temp
=
1
;
break
;
case
'二'
:
temp
=
2
;
break
;
case
'三'
:
temp
=
3
;
break
;
case
'四'
:
temp
=
4
;
break
;
case
'五'
:
temp
=
5
;
break
;
case
'六'
:
temp
=
6
;
break
;
case
'七'
:
temp
=
7
;
break
;
case
'八'
:
temp
=
8
;
break
;
case
'九'
:
temp
=
9
;
break
;
// 单位,前缀是单数字
case
'十'
:
temp
=
10
;
break
;
}
return
temp
;
}
/**
* 中文数字转换为阿拉伯数
*
* @param String
* s
*/
public
static
int
cnNumToInt
(
String
s
)
{
int
result
=
0
;
int
yi
=
1
;
// 记录高级单位
int
wan
=
1
;
// 记录高级单位
int
ge
=
1
;
// 记录单位
char
c
=
s
.
charAt
(
0
);
int
temp
=
0
;
// 记录数值
switch
(
c
)
{
// 数值
case
'〇'
:
case
'零'
:
temp
=
0
;
break
;
case
'一'
:
temp
=
1
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'二'
:
temp
=
2
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'三'
:
temp
=
3
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'四'
:
temp
=
4
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'五'
:
temp
=
5
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'六'
:
temp
=
6
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'七'
:
temp
=
7
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'八'
:
temp
=
8
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'九'
:
temp
=
9
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
// 单位,前缀是单数字
case
'十'
:
ge
=
10
;
break
;
case
'百'
:
ge
=
100
;
break
;
case
'千'
:
ge
=
1000
;
break
;
// 高级单位,前缀可以是多个数字
case
'万'
:
wan
=
10000
;
ge
=
1
;
break
;
case
'亿'
:
yi
=
100000000
;
wan
=
1
;
ge
=
1
;
break
;
default
:
return
-
1
;
}
result
+=
temp
;
if
(
ge
>
1
)
{
result
+=
1
*
ge
*
wan
*
yi
;
}
return
result
;
}
public
static
String
geneStrAry
(
String
str
,
String
splits
)
{
if
(
StringUtil
.
isEmpty
(
str
))
return
""
;
String
[]
ary
=
str
.
split
(
splits
);
StringBuffer
sb
=
new
StringBuffer
(
""
);
for
(
int
i
=
0
;
i
<
ary
.
length
;
i
++)
{
sb
.
append
(
"'"
);
sb
.
append
(
ary
[
i
]);
sb
.
append
(
"'"
);
if
(
i
<
ary
.
length
-
1
)
sb
.
append
(
","
);
}
return
sb
.
toString
();
}
public
static
boolean
equals
(
String
str1
,
String
str2
)
{
return
str1
==
null
?
false
:
str2
==
null
?
true
:
str1
.
equals
(
str2
);
}
public
static
boolean
equalsIgnoreCase
(
String
str1
,
String
str2
)
{
return
str1
==
null
?
false
:
str2
==
null
?
true
:
str1
.
equalsIgnoreCase
(
str2
);
}
/**
*
* @param obj
* 传数值类型的obj
* @param format
* @return
*/
public
static
String
decimalFormat
(
Object
obj
)
{
if
(
null
==
obj
)
return
""
;
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
return
df
.
format
(
obj
);
}
/**
*
* @param obj
* 传数值类型的obj
* @param format
* @return
*/
public
static
String
decimalFormat
(
Object
obj
,
String
format
)
{
if
(
null
==
obj
)
return
""
;
DecimalFormat
df
=
new
DecimalFormat
(
format
);
return
df
.
format
(
obj
);
}
/**
* 字符串两端增加书名号
*
* @param str
* @return
*/
public
static
String
addBracket
(
String
str
)
{
if
(
null
==
str
)
return
""
;
if
(!
str
.
startsWith
(
"《"
)
||
!
str
.
endsWith
(
"》"
))
{
str
=
"《"
+
str
+
"》"
;
}
return
str
;
}
/**
* 字符串两端增加书名号,且名称控制在30个字符之内
*
* @param str
* @return
*/
public
static
String
addBracket2Short
(
String
str
)
{
if
(
null
==
str
)
return
""
;
if
(!
str
.
startsWith
(
"《"
)
||
!
str
.
endsWith
(
"》"
))
{
str
=
"《"
+
(
str
.
length
()
>
30
?
str
.
substring
(
0
,
10
)
+
"..."
+
str
.
substring
(
str
.
length
()
-
10
)
:
str
)
+
"》"
;
}
return
str
;
}
/**
* 校验特殊字符
*
* @param productId
* @throws BizException
*/
public
static
boolean
checkCharacter
(
String
str
)
throws
BizException
{
if
(
StringUtil
.
isEmpty
(
str
))
{
return
false
;
}
String
regEx
=
"[\\\\\"%/]"
;
Pattern
p
=
Pattern
.
compile
(
regEx
);
Matcher
m
=
p
.
matcher
(
str
);
if
(
m
.
find
())
{
return
true
;
}
return
false
;
}
}
package
com
.
pcloud
.
common
.
utils
.
string
;
import
java.text.DecimalFormat
;
import
java.text.DecimalFormatSymbols
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.StringTokenizer
;
import
java.util.UUID
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
com.pcloud.common.exceptions.BizException
;
/**
* @描述:字符串工具类
* @作者:DiSeng.H
* @创建时间:2016年3月10日,上午11:49:07 @版本:1.0
*/
public
class
StringUtil
extends
StringUtilParent
{
/**
* 判断字符串是否为空
*
* @param str
* @return
*/
public
static
boolean
isNotNull
(
String
str
)
{
if
(
str
!=
null
&&
!
""
.
equals
(
str
.
trim
()))
{
return
true
;
}
else
{
return
false
;
}
}
/**
* 判断对象是否为空
*
* @param str
* @return
*/
public
static
boolean
isNotNull
(
Object
obj
)
{
if
(
obj
!=
null
&&
obj
.
toString
()
!=
null
&&
!
""
.
equals
(
obj
.
toString
().
trim
()))
{
return
true
;
}
else
{
return
false
;
}
}
/**
* 判断字符串是否为空(自动截取首尾空白)
*
* @param str 源字符串
* @return
*/
public
static
boolean
isEmpty
(
String
str
)
{
return
isEmpty
(
str
,
true
);
}
/**
* 判断字符串是否为空
*
* @param str 源字符串
* @param trim 是否截取首尾空白
* @return
*/
public
static
boolean
isEmpty
(
String
str
,
boolean
trim
)
{
return
str
==
null
?
true
:
(
""
.
equals
(
str
.
trim
())
||
"null"
.
equals
(
str
.
trim
()));
}
/**
* 判断数组是否为空
*
* @param str
* @return
*/
public
static
boolean
isEmpty
(
String
[]
strs
)
{
return
strs
==
null
?
true
:
strs
.
length
==
0
;
}
/**
* @param str the string need to be parsed
* @param delim the delimiter to seperate created by zqf at 6/1/2013
*/
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
public
static
String
[]
parseToArray
(
String
str
,
String
delim
)
{
ArrayList
arr
=
new
ArrayList
();
StringTokenizer
st
=
new
StringTokenizer
(
str
,
delim
);
while
(
st
.
hasMoreTokens
())
{
arr
.
add
(
st
.
nextToken
());
}
String
[]
ret
=
new
String
[
arr
.
size
()];
for
(
int
i
=
0
;
i
<
arr
.
size
();
i
++)
{
ret
[
i
]
=
(
String
)
arr
.
get
(
i
);
}
return
ret
;
}
/**
* replace a old substring with rep in str
*
* @param str the string need to be replaced
* @param old the string need to be removed
* @param rep the string to be inserted
* @return string replaced
*/
public
static
String
replace
(
String
str
,
String
old
,
String
rep
)
{
if
((
str
==
null
)
||
(
old
==
null
)
||
(
rep
==
null
))
{
// if one is null
// return ""
return
""
;
}
int
index
=
str
.
indexOf
(
old
);
if
((
index
<
0
)
||
""
.
equals
(
old
))
{
// if no old string found or
// nothing to replace,return the
// origin
return
str
;
}
StringBuffer
strBuf
=
new
StringBuffer
(
str
);
while
(
index
>=
0
)
{
// found old part
strBuf
.
delete
(
index
,
index
+
old
.
length
());
strBuf
.
insert
(
index
,
rep
);
index
=
strBuf
.
toString
().
indexOf
(
old
);
}
return
strBuf
.
toString
();
}
/**
* 带逗号分隔的数字转换为NUMBER类型
*
* @param str
* @return
* @throws ParseException
*/
public
static
Number
stringToNumber
(
String
str
)
throws
ParseException
{
if
(
str
==
null
||
""
.
equals
(
str
))
{
return
null
;
}
DecimalFormatSymbols
dfs
=
new
DecimalFormatSymbols
();
dfs
.
setDecimalSeparator
(
'.'
);
dfs
.
setGroupingSeparator
(
','
);
dfs
.
setMonetaryDecimalSeparator
(
'.'
);
DecimalFormat
df
=
new
DecimalFormat
(
"###,###,###,###.##"
,
dfs
);
return
df
.
parse
(
str
);
}
public
static
String
getExtensionName
(
String
filename
)
{
if
((
filename
!=
null
)
&&
(
filename
.
length
()
>
0
))
{
int
dot
=
filename
.
lastIndexOf
(
'.'
);
if
((
dot
>
-
1
)
&&
(
dot
<
(
filename
.
length
()
-
1
)))
{
return
filename
.
substring
(
dot
+
1
);
}
}
return
filename
;
}
/**
* 用于字符串替换
*
* @param target 目标对象 需要替换的字符串
* @param replacement 要替换的字符串
* @param value 替换的值
* @return
*/
public
static
String
replacement
(
String
target
,
String
replacement
,
String
value
)
{
if
(
target
!=
null
)
return
target
.
replace
(
replacement
,
value
);
return
null
;
}
/**
* 判断字符串是否为数字
*
* @param str
* @return
*/
public
static
boolean
isNumeric
(
String
str
)
{
if
(
str
==
null
||
str
.
length
()
==
0
)
{
return
false
;
}
for
(
int
i
=
0
;
i
<
str
.
length
();
i
++)
{
if
(!
Character
.
isDigit
(
str
.
charAt
(
i
)))
{
return
false
;
}
}
return
true
;
}
/**
* 计算指定时间与当前时间的差
*
* @param date
* @return
*/
public
static
String
convDateToString
(
Date
date
)
{
Long
time
=
new
Date
().
getTime
()
-
date
.
getTime
();
Long
min
=
time
/
1000
/
60
;
if
(
min
<
5
)
{
return
"刚刚"
;
}
else
if
(
min
>=
5
&&
min
<
60
)
{
return
min
+
"分钟之前"
;
}
else
if
(
min
>=
60
&&
min
<
1440
)
{
return
min
/
60
+
"小时之前"
;
}
else
if
(
min
>=
1440
&&
min
<
10080
)
{
return
min
/
60
/
24
+
"天之前"
;
}
else
if
(
min
>=
10080
&&
min
<
40320
)
{
return
min
/
60
/
24
/
7
+
"周之前"
;
}
else
if
(
min
>=
40320
&&
min
<
525600
)
{
return
min
/
60
/
24
/
7
/
4
+
"月之前"
;
}
else
if
(
min
>=
525600
)
{
return
min
/
60
/
24
/
365
+
"年之前"
;
}
return
null
;
}
/**
* @return
* @description 获取当前服务器日期
*/
public
static
String
getCurrdate
(
String
formatStr
)
{
Calendar
cal
=
Calendar
.
getInstance
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
formatStr
);
String
mDateTime
=
formatter
.
format
(
cal
.
getTime
());
return
mDateTime
;
}
/**
* 将Object值转换成Double类型
*
* @param value
* @return
*/
public
static
double
getDoubleByObj
(
Object
value
)
{
if
(
value
==
null
)
{
return
0
;
}
return
Double
.
valueOf
(
String
.
valueOf
(
value
));
}
/**
* 将Object值转换成Float类型
*
* @param value
* @return
*/
public
static
float
getFloatByObj
(
Object
value
)
{
if
(
value
==
null
)
{
return
0
;
}
return
Float
.
valueOf
(
String
.
valueOf
(
value
));
}
/**
* 将Object值转换成Integer类型
*
* @param value
* @return
*/
public
static
Integer
getIntegerByObj
(
Object
value
)
{
if
(
value
==
null
)
{
return
0
;
}
return
Integer
.
valueOf
(
String
.
valueOf
(
value
));
}
/**
* 将Object值转换成String类型
*
* @param value
* @return
*/
public
static
String
getByObj
(
Object
value
)
{
if
(
value
==
null
)
{
return
null
;
}
return
value
.
toString
();
}
/**
* 解析字符串 ---> 去掉字符串中回车、换行、空格
*
* @param str 被解析字符串
* @return String 解析后的字符串
*/
public
static
String
parse
(
String
str
)
{
return
str
.
replaceAll
(
"\n"
,
""
).
replaceAll
(
"chr(13)"
,
""
).
replaceAll
(
" "
,
""
);
}
public
static
Integer
[]
Str2Integers
(
String
value
)
{
if
(
null
==
value
||
!
org
.
springframework
.
util
.
StringUtils
.
hasText
(
value
))
{
return
null
;
}
String
[]
values
=
value
.
split
(
","
);
Integer
[]
v
=
new
Integer
[
values
.
length
];
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
v
[
i
]
=
Integer
.
parseInt
(
values
[
i
]);
}
return
v
;
}
public
static
String
[]
Str2Strings
(
String
value
)
{
if
(
null
==
value
||
!
org
.
springframework
.
util
.
StringUtils
.
hasText
(
value
))
{
return
null
;
}
String
[]
values
=
value
.
split
(
","
);
String
[]
v
=
new
String
[
values
.
length
];
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
v
[
i
]
=
values
[
i
];
}
return
v
;
}
public
static
int
strFormateInt
(
Object
obj
)
{
if
(
isNotNull
(
obj
))
{
return
"是"
.
equals
(
obj
)
?
1
:
0
;
}
else
{
return
0
;
}
}
/**
* 获取UUID
*
* @return UUID
*/
public
static
String
getUUID
()
{
return
(
UUID
.
randomUUID
()
+
""
).
replaceAll
(
"-"
,
""
);
}
/**
* 将字符串转移为ASCII码
*
* @param cnStr
* @return
*/
public
static
String
getCnASCII
(
String
cnStr
)
{
StringBuffer
strBuf
=
new
StringBuffer
();
byte
[]
bGBK
=
cnStr
.
getBytes
();
for
(
int
i
=
0
;
i
<
bGBK
.
length
;
i
++)
{
// System.out.println(Integer.toHexString(bGBK[i]&0xff));
strBuf
.
append
(
Integer
.
toHexString
(
bGBK
[
i
]
&
0xff
));
}
return
strBuf
.
toString
();
}
/**
* @param initCode 初始化编码
* @param length 需要生成编码长度
* @param ind 地增量
* @return 递增后的编码
*/
public
static
String
getNextCode
(
String
initCode
,
int
length
,
int
ind
)
{
Integer
temp
=
Integer
.
parseInt
(
initCode
);
temp
=
temp
+
ind
;
String
tempCode
=
temp
.
toString
();
int
tempLen
=
0
;
if
(
tempCode
.
length
()
<
length
)
{
tempLen
=
length
-
tempCode
.
length
();
}
for
(
int
i
=
0
;
i
<
tempLen
;
i
++)
{
tempCode
=
"0"
+
tempCode
;
}
return
tempCode
;
}
public
static
int
switchNumber
(
String
str
)
{
char
c
=
str
.
charAt
(
0
);
int
temp
=
0
;
switch
(
c
)
{
// 数值
case
'〇'
:
case
'零'
:
temp
=
0
;
break
;
case
'一'
:
temp
=
1
;
break
;
case
'二'
:
temp
=
2
;
break
;
case
'三'
:
temp
=
3
;
break
;
case
'四'
:
temp
=
4
;
break
;
case
'五'
:
temp
=
5
;
break
;
case
'六'
:
temp
=
6
;
break
;
case
'七'
:
temp
=
7
;
break
;
case
'八'
:
temp
=
8
;
break
;
case
'九'
:
temp
=
9
;
break
;
// 单位,前缀是单数字
case
'十'
:
temp
=
10
;
break
;
}
return
temp
;
}
/**
* 中文数字转换为阿拉伯数
*
* @param String s
*/
public
static
int
cnNumToInt
(
String
s
)
{
int
result
=
0
;
int
yi
=
1
;
// 记录高级单位
int
wan
=
1
;
// 记录高级单位
int
ge
=
1
;
// 记录单位
char
c
=
s
.
charAt
(
0
);
int
temp
=
0
;
// 记录数值
switch
(
c
)
{
// 数值
case
'〇'
:
case
'零'
:
temp
=
0
;
break
;
case
'一'
:
temp
=
1
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'二'
:
temp
=
2
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'三'
:
temp
=
3
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'四'
:
temp
=
4
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'五'
:
temp
=
5
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'六'
:
temp
=
6
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'七'
:
temp
=
7
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'八'
:
temp
=
8
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
case
'九'
:
temp
=
9
*
ge
*
wan
*
yi
;
ge
=
1
;
break
;
// 单位,前缀是单数字
case
'十'
:
ge
=
10
;
break
;
case
'百'
:
ge
=
100
;
break
;
case
'千'
:
ge
=
1000
;
break
;
// 高级单位,前缀可以是多个数字
case
'万'
:
wan
=
10000
;
ge
=
1
;
break
;
case
'亿'
:
yi
=
100000000
;
wan
=
1
;
ge
=
1
;
break
;
default
:
return
-
1
;
}
result
+=
temp
;
if
(
ge
>
1
)
{
result
+=
1
*
ge
*
wan
*
yi
;
}
return
result
;
}
public
static
String
geneStrAry
(
String
str
,
String
splits
)
{
if
(
StringUtil
.
isEmpty
(
str
))
return
""
;
String
[]
ary
=
str
.
split
(
splits
);
StringBuffer
sb
=
new
StringBuffer
(
""
);
for
(
int
i
=
0
;
i
<
ary
.
length
;
i
++)
{
sb
.
append
(
"'"
);
sb
.
append
(
ary
[
i
]);
sb
.
append
(
"'"
);
if
(
i
<
ary
.
length
-
1
)
sb
.
append
(
","
);
}
return
sb
.
toString
();
}
public
static
boolean
equals
(
String
str1
,
String
str2
)
{
return
str1
==
null
?
false
:
str2
==
null
?
true
:
str1
.
equals
(
str2
);
}
public
static
boolean
equalsIgnoreCase
(
String
str1
,
String
str2
)
{
return
str1
==
null
?
false
:
str2
==
null
?
true
:
str1
.
equalsIgnoreCase
(
str2
);
}
/**
* @param obj 传数值类型的obj
* @param format
* @return
*/
public
static
String
decimalFormat
(
Object
obj
)
{
if
(
null
==
obj
)
return
""
;
DecimalFormat
df
=
new
DecimalFormat
(
"0.00"
);
return
df
.
format
(
obj
);
}
/**
* @param obj 传数值类型的obj
* @param format
* @return
*/
public
static
String
decimalFormat
(
Object
obj
,
String
format
)
{
if
(
null
==
obj
)
return
""
;
DecimalFormat
df
=
new
DecimalFormat
(
format
);
return
df
.
format
(
obj
);
}
/**
* 字符串两端增加书名号
*
* @param str
* @return
*/
public
static
String
addBracket
(
String
str
)
{
if
(
null
==
str
)
return
""
;
if
(!
str
.
startsWith
(
"《"
)
||
!
str
.
endsWith
(
"》"
))
{
str
=
"《"
+
str
+
"》"
;
}
return
str
;
}
/**
* 字符串两端增加书名号,且名称控制在30个字符之内
*
* @param str
* @return
*/
public
static
String
addBracket2Short
(
String
str
)
{
if
(
null
==
str
)
return
""
;
if
(!
str
.
startsWith
(
"《"
)
||
!
str
.
endsWith
(
"》"
))
{
str
=
"《"
+
(
str
.
length
()
>
30
?
str
.
substring
(
0
,
10
)
+
"..."
+
str
.
substring
(
str
.
length
()
-
10
)
:
str
)
+
"》"
;
}
return
str
;
}
/**
* 校验特殊字符
*
* @param productId
* @throws BizException
*/
public
static
boolean
checkCharacter
(
String
str
)
throws
BizException
{
if
(
StringUtil
.
isEmpty
(
str
))
{
return
false
;
}
String
regEx
=
"[\\\\\"%/]"
;
Pattern
p
=
Pattern
.
compile
(
regEx
);
Matcher
m
=
p
.
matcher
(
str
);
if
(
m
.
find
())
{
return
true
;
}
return
false
;
}
}
pom.xml
View file @
c53cd2b9
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
1.5.4.RELEASE
</version>
<relativePath
/>
<!-- lookup parent from repository -->
</parent>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common-parent
</artifactId>
<version>
2.1.0-RELEASE
</version>
<modules>
<module>
pcloud-common-config
</module>
<module>
pcloud-common
</module>
<module>
pcloud-common-core
</module>
</modules>
<packaging>
pom
</packaging>
<name>
pcloud-common-parent
</name>
<url>
http://maven.apache.org
</url>
<profiles>
<!-- UAT -->
<profile>
<id>
uat
</id>
<activation>
<activeByDefault>
true
</activeByDefault>
</activation>
<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
<resource>
<directory>
src/main/resources.uat
</directory>
</resource>
</resources>
</build>
<properties>
<!-- 部署环境(对应配置文件版本) -->
<env>
uat
</env>
<pcloud-common.version>
2.1.0-RELEASE
</pcloud-common.version>
<pcloud-common-config.version>
2.1.0-RELEASE
</pcloud-common-config.version>
<pcloud-common-core.version>
2.1.0-RELEASE
</pcloud-common-core.version>
</properties>
</profile>
<!-- 压测环境 -->
<profile>
<id>
perf
</id>
<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
<resource>
<directory>
src/main/resources.perf
</directory>
</resource>
</resources>
</build>
<properties>
<!-- 部署环境(对应配置文件版本) -->
<env>
perf
</env>
<pcloud-common.version>
2.1.0-RELEASE
</pcloud-common.version>
<pcloud-common-config.version>
2.1.0-RELEASE
</pcloud-common-config.version>
<pcloud-common-core.version>
2.1.0-RELEASE
</pcloud-common-core.version>
</properties>
</profile>
<!-- 生产环境 RAYS-->
<profile>
<id>
prod
</id>
<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
<resource>
<directory>
src/main/resources.prod
</directory>
</resource>
</resources>
</build>
<properties>
<!-- 部署环境(对应配置文件版本) -->
<env>
prod
</env>
<pcloud-common.version>
2.1.1-RELEASE
</pcloud-common.version>
<pcloud-common-config.version>
2.1.1-RELEASE
</pcloud-common-config.version>
<pcloud-common-core.version>
2.1.1-RELEASE
</pcloud-common-core.version>
</properties>
</profile>
<!-- 生产环境 SAYS-->
<profile>
<id>
prodsays
</id>
<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
<resource>
<directory>
src/main/resources.prodsays
</directory>
</resource>
</resources>
</build>
<properties>
<!-- 部署环境(对应配置文件版本) -->
<env>
prodsays
</env>
<pcloud-common.version>
2.2.1-RELEASE
</pcloud-common.version>
<pcloud-common-config.version>
2.2.1-RELEASE
</pcloud-common-config.version>
<pcloud-common-core.version>
2.2.1-RELEASE
</pcloud-common-core.version>
</properties>
</profile>
</profiles>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<java.version>
1.8
</java.version>
<spring-cloud.version>
Dalston.SR1
</spring-cloud.version>
<spring.data.solr.version>
2.1.7.RELEASE
</spring.data.solr.version>
<!-- frameworks -->
<slf4j.version>
1.7.18
</slf4j.version>
</properties>
<dependencies>
<!-- Test Dependency Begin -->
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
</dependency>
<!-- Test Dependency End -->
</dependencies>
<dependencyManagement>
<dependencies>
<!-- Spring begin -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-dependencies
</artifactId>
<version>
${spring-cloud.version}
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
<version>
1.3.0
</version>
</dependency>
<!-- spring end -->
<!-- Common Dependency Begin -->
<dependency>
<groupId>
cglib
</groupId>
<artifactId>
cglib
</artifactId>
<version>
3.2.1
</version>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
<version>
${slf4j.version}
</version>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
jcl-over-slf4j
</artifactId>
<version>
${slf4j.version}
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-classic
</artifactId>
<version>
1.1.6
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-core
</artifactId>
<version>
1.1.6
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-access
</artifactId>
<version>
1.1.6
</version>
</dependency>
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
<version>
2.6
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
<version>
3.4
</version>
</dependency>
<dependency>
<groupId>
commons-codec
</groupId>
<artifactId>
commons-codec
</artifactId>
<version>
1.9
</version>
</dependency>
<dependency>
<groupId>
commons-beanutils
</groupId>
<artifactId>
commons-beanutils
</artifactId>
<version>
1.9.2
</version>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<version>
2.4
</version>
</dependency>
<dependency>
<groupId>
commons-logging
</groupId>
<artifactId>
commons-logging
</artifactId>
<version>
1.2
</version>
</dependency>
<dependency>
<groupId>
commons-collections
</groupId>
<artifactId>
commons-collections
</artifactId>
<version>
3.2.2
</version>
</dependency>
<dependency>
<groupId>
net.sourceforge.jexcelapi
</groupId>
<artifactId>
jxl
</artifactId>
<version>
2.6.12
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
<version>
1.0.15
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.38
</version>
</dependency>
<dependency>
<groupId>
org.jdom
</groupId>
<artifactId>
jdom2
</artifactId>
<version>
2.0.6
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.3
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpcore
</artifactId>
<version>
4.4.6
</version>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
<version>
2.9.0
</version>
</dependency>
<!-- Common Dependency End -->
<!-- Mysql Driver Begin -->
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
6.0.6
</version>
</dependency>
<!-- Mysql Driver End -->
<!-- logback-json -->
<dependency>
<groupId>
ch.qos.logback.contrib
</groupId>
<artifactId>
logback-json-core
</artifactId>
<version>
0.1.2
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback.contrib
</groupId>
<artifactId>
logback-json-classic
</artifactId>
<version>
0.1.2
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback.contrib
</groupId>
<artifactId>
logback-jackson
</artifactId>
<version>
0.1.2
</version>
</dependency>
<!-- Others Begin -->
<dependency>
<groupId>
org.jboss.netty
</groupId>
<artifactId>
netty
</artifactId>
<version>
3.2.10.Final
</version>
</dependency>
<dependency>
<groupId>
org.apache.activemq
</groupId>
<artifactId>
activemq-all
</artifactId>
<version>
5.15.0
</version>
</dependency>
<!-- Others End -->
<!-- 图片处理工具 added by songx at 2017-05-17 -->
<dependency>
<groupId>
net.coobird
</groupId>
<artifactId>
thumbnailator
</artifactId>
<version>
0.4.8
</version>
</dependency>
<!-- 压缩工具 added by songx at 2017-05-24 -->
<dependency>
<groupId>
com.github.junrar
</groupId>
<artifactId>
junrar
</artifactId>
<version>
0.7
</version>
</dependency>
<!-- 二维码 added by songx at 2017-05-24 -->
<dependency>
<groupId>
com.google.zxing
</groupId>
<artifactId>
core
</artifactId>
<version>
3.0.0
</version>
</dependency>
<dependency>
<groupId>
com.google.zxing
</groupId>
<artifactId>
javase
</artifactId>
<version>
3.0.0
</version>
</dependency>
<!-- PDF解析工具 added by songx at 2017-06-13 -->
<dependency>
<groupId>
pcloud.tools
</groupId>
<artifactId>
tools
</artifactId>
<version>
18.03.22
</version>
</dependency>
<!-- 阿里云媒体转码SDK包 added by songx at 2017-06-22 -->
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
<version>
3.3.1
</version>
</dependency>
<dependency>
<groupId>
com.aliyun.oss
</groupId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
2.7.0
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-mts
</artifactId>
<version>
2.1.7
</version>
</dependency>
<!-- solr add by gaop at 2018-4-23 11:33:47 -->
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-solr
</artifactId>
<version>
${spring.data.solr.version}
</version>
</dependency>
<!-- end -->
<!-- Jackson Begin -->
<dependency>
<groupId>
org.codehaus.jackson
</groupId>
<artifactId>
jackson-mapper-asl
</artifactId>
<version>
1.9.13
</version>
</dependency>
<!-- Jackson End -->
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
<id>
public
</id>
<name>
public repositories
</name>
<url>
http://192.168.83.20:8081/nexus/content/groups/public/
</url>
</repository>
<repository>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
<id>
jboss
</id>
<name>
public jboss
</name>
<url>
http://192.168.83.20:8081/nexus/content/repositories/jboss
</url>
</repository>
<repository>
<id>
sonatype-nexus-staging
</id>
<name>
Sonatype Nexus Staging
</name>
<url>
https://oss.sonatype.org/service/local/staging/deploy/maven2/
</url>
<releases>
<enabled>
true
</enabled>
</releases>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>
public
</id>
<name>
public repositories
</name>
<url>
http://192.168.83.20:8081/nexus/content/groups/public/
</url>
</pluginRepository>
<pluginRepository>
<releases>
<updatePolicy>
never
</updatePolicy>
</releases>
<snapshots>
<enabled>
false
</enabled>
</snapshots>
<id>
central
</id>
<name>
Central Repository
</name>
<url>
http://repo.maven.apache.org/maven2
</url>
</pluginRepository>
<pluginRepository>
<id>
Codehaus repository
</id>
<url>
http://repository.codehaus.org/
</url>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>
nexus-releases
</id>
<name>
Nexus Release Repository
</name>
<url>
http://192.168.83.20:8081/nexus/content/repositories/releases/
</url>
</repository>
<snapshotRepository>
<id>
nexus-snapshots
</id>
<name>
Nexus Snapshot Repository
</name>
<url>
http://192.168.83.20:8081/nexus/content/repositories/snapshots/
</url>
</snapshotRepository>
</distributionManagement>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
1.5.4.RELEASE
</version>
<relativePath
/>
<!-- lookup parent from repository -->
</parent>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common-parent
</artifactId>
<version>
2.1.0-RELEASE
</version>
<modules>
<module>
pcloud-common-config
</module>
<module>
pcloud-common
</module>
<module>
pcloud-common-core
</module>
</modules>
<packaging>
pom
</packaging>
<name>
pcloud-common-parent
</name>
<url>
http://maven.apache.org
</url>
<profiles>
<!-- UAT -->
<profile>
<id>
uat
</id>
<activation>
<activeByDefault>
true
</activeByDefault>
</activation>
<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
<resource>
<directory>
src/main/resources.uat
</directory>
</resource>
</resources>
</build>
<properties>
<!-- 部署环境(对应配置文件版本) -->
<env>
uat
</env>
<pcloud-common.version>
2.1.0-RELEASE
</pcloud-common.version>
<pcloud-common-config.version>
2.1.0-RELEASE
</pcloud-common-config.version>
<pcloud-common-core.version>
2.1.0-RELEASE
</pcloud-common-core.version>
</properties>
</profile>
<!-- 压测环境 -->
<profile>
<id>
perf
</id>
<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
<resource>
<directory>
src/main/resources.perf
</directory>
</resource>
</resources>
</build>
<properties>
<!-- 部署环境(对应配置文件版本) -->
<env>
perf
</env>
<pcloud-common.version>
2.1.0-RELEASE
</pcloud-common.version>
<pcloud-common-config.version>
2.1.0-RELEASE
</pcloud-common-config.version>
<pcloud-common-core.version>
2.1.0-RELEASE
</pcloud-common-core.version>
</properties>
</profile>
<!-- 生产环境 RAYS -->
<profile>
<id>
prod
</id>
<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
<resource>
<directory>
src/main/resources.prod
</directory>
</resource>
</resources>
</build>
<properties>
<!-- 部署环境(对应配置文件版本) -->
<env>
prod
</env>
<pcloud-common.version>
2.1.1-RELEASE
</pcloud-common.version>
<pcloud-common-config.version>
2.1.1-RELEASE
</pcloud-common-config.version>
<pcloud-common-core.version>
2.1.1-RELEASE
</pcloud-common-core.version>
</properties>
</profile>
</profiles>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<java.version>
1.8
</java.version>
<spring-cloud.version>
Dalston.SR3
</spring-cloud.version>
<spring.data.solr.version>
2.1.7.RELEASE
</spring.data.solr.version>
<!-- frameworks -->
<slf4j.version>
1.7.18
</slf4j.version>
</properties>
<dependencies>
<!-- Test Dependency Begin -->
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
</dependency>
<!-- Test Dependency End -->
</dependencies>
<dependencyManagement>
<dependencies>
<!-- Spring begin -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-dependencies
</artifactId>
<version>
${spring-cloud.version}
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
<version>
1.3.0
</version>
</dependency>
<!-- spring end -->
<!-- Common Dependency Begin -->
<dependency>
<groupId>
cglib
</groupId>
<artifactId>
cglib
</artifactId>
<version>
3.2.1
</version>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
<version>
${slf4j.version}
</version>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
jcl-over-slf4j
</artifactId>
<version>
${slf4j.version}
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-classic
</artifactId>
<version>
1.1.6
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-core
</artifactId>
<version>
1.1.6
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-access
</artifactId>
<version>
1.1.6
</version>
</dependency>
<dependency>
<groupId>
commons-lang
</groupId>
<artifactId>
commons-lang
</artifactId>
<version>
2.6
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
<version>
3.4
</version>
</dependency>
<dependency>
<groupId>
commons-codec
</groupId>
<artifactId>
commons-codec
</artifactId>
<version>
1.9
</version>
</dependency>
<dependency>
<groupId>
commons-beanutils
</groupId>
<artifactId>
commons-beanutils
</artifactId>
<version>
1.9.2
</version>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<version>
2.4
</version>
</dependency>
<dependency>
<groupId>
commons-logging
</groupId>
<artifactId>
commons-logging
</artifactId>
<version>
1.2
</version>
</dependency>
<dependency>
<groupId>
commons-collections
</groupId>
<artifactId>
commons-collections
</artifactId>
<version>
3.2.2
</version>
</dependency>
<dependency>
<groupId>
net.sourceforge.jexcelapi
</groupId>
<artifactId>
jxl
</artifactId>
<version>
2.6.12
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
<version>
1.0.15
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.38
</version>
</dependency>
<dependency>
<groupId>
org.jdom
</groupId>
<artifactId>
jdom2
</artifactId>
<version>
2.0.6
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.3
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpcore
</artifactId>
<version>
4.4.6
</version>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
<version>
2.9.0
</version>
</dependency>
<!-- Common Dependency End -->
<!-- logback-json -->
<dependency>
<groupId>
ch.qos.logback.contrib
</groupId>
<artifactId>
logback-json-core
</artifactId>
<version>
0.1.2
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback.contrib
</groupId>
<artifactId>
logback-json-classic
</artifactId>
<version>
0.1.2
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback.contrib
</groupId>
<artifactId>
logback-jackson
</artifactId>
<version>
0.1.2
</version>
</dependency>
<!-- Mysql Driver Begin -->
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
6.0.6
</version>
</dependency>
<!-- Mysql Driver End -->
<!-- 图片处理工具 added by songx at 2017-05-17 -->
<dependency>
<groupId>
net.coobird
</groupId>
<artifactId>
thumbnailator
</artifactId>
<version>
0.4.8
</version>
</dependency>
<!-- 压缩工具 added by songx at 2017-05-24 -->
<dependency>
<groupId>
com.github.junrar
</groupId>
<artifactId>
junrar
</artifactId>
<version>
0.7
</version>
</dependency>
<!-- 二维码 added by songx at 2017-05-24 -->
<dependency>
<groupId>
com.google.zxing
</groupId>
<artifactId>
core
</artifactId>
<version>
3.0.0
</version>
</dependency>
<dependency>
<groupId>
com.google.zxing
</groupId>
<artifactId>
javase
</artifactId>
<version>
3.0.0
</version>
</dependency>
<!-- 阿里云媒体转码SDK包 added by songx at 2017-06-22 -->
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
<version>
3.3.1
</version>
</dependency>
<dependency>
<groupId>
com.aliyun.oss
</groupId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
2.7.0
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-mts
</artifactId>
<version>
2.1.7
</version>
</dependency>
<!-- end -->
<!-- solr add by gaop at 2018-4-23 11:33:47 -->
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-solr
</artifactId>
<version>
${spring.data.solr.version}
</version>
</dependency>
<!-- Jackson Begin -->
<dependency>
<groupId>
org.codehaus.jackson
</groupId>
<artifactId>
jackson-mapper-asl
</artifactId>
<version>
1.9.13
</version>
</dependency>
<!-- Jackson End -->
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
<id>
public
</id>
<name>
public repositories
</name>
<url>
http://192.168.83.20:8081/nexus/content/groups/public/
</url>
</repository>
<repository>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
<id>
jboss
</id>
<name>
public jboss
</name>
<url>
http://192.168.83.20:8081/nexus/content/repositories/jboss
</url>
</repository>
<repository>
<id>
sonatype-nexus-staging
</id>
<name>
Sonatype Nexus Staging
</name>
<url>
https://oss.sonatype.org/service/local/staging/deploy/maven2/
</url>
<releases>
<enabled>
true
</enabled>
</releases>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>
public
</id>
<name>
public repositories
</name>
<url>
http://192.168.83.20:8081/nexus/content/groups/public/
</url>
</pluginRepository>
<pluginRepository>
<releases>
<updatePolicy>
never
</updatePolicy>
</releases>
<snapshots>
<enabled>
false
</enabled>
</snapshots>
<id>
central
</id>
<name>
Central Repository
</name>
<url>
http://repo.maven.apache.org/maven2
</url>
</pluginRepository>
<pluginRepository>
<id>
Codehaus repository
</id>
<url>
http://repository.codehaus.org/
</url>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>
nexus-releases
</id>
<name>
Nexus Release Repository
</name>
<url>
http://192.168.83.20:8081/nexus/content/repositories/releases/
</url>
</repository>
<snapshotRepository>
<id>
nexus-snapshots
</id>
<name>
Nexus Snapshot Repository
</name>
<url>
http://192.168.83.20:8081/nexus/content/repositories/snapshots/
</url>
</snapshotRepository>
</distributionManagement>
</project>
temp.jpg
0 → 100644
View file @
c53cd2b9
1.82 MB
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