Commit c53cd2b9 by shuyunhu
parents 5346f57e 273cd919
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
#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.fromEmail.new=rays_support@vip.163.com
email.password.new=chubanyun
\ No newline at end of file
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
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
#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.fromEmail.new=rays_support@vip.163.com
email.password.new=chubanyun
\ No newline at end of file
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
......@@ -32,8 +32,8 @@ org.quartz.jobStore.clusterCheckinInterval = 20000
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.user = rays
org.quartz.dataSource.myDS.password = lgsC789
org.quartz.dataSource.myDS.maxConnections = 100
......
......@@ -45,26 +45,12 @@
</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>
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
@ParamLog("发送对外API queue")
public void sendMessageQueue(ExapiMessageDto exapiMessageDto) {
MessageCreator messageCreator = new MessageCreator() {
@Override
public ObjectMessage createMessage(Session session) throws JMSException {
return session.createObjectMessage(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);
}
}
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;
......
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.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.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;
import javax.jms.JMSException;
import javax.jms.ObjectMessage;
import javax.jms.Session;
import javax.annotation.Resource;
/**
* @author Shichunshan
......@@ -20,35 +17,47 @@ import javax.jms.Session;
* @description:
*/
@Component("frontEventBiz")
public class FrontEventBizImpl implements FrontEventBiz{
public class FrontEventBizImpl implements FrontEventBiz {
/**
*
*/
private final static Logger logger= LoggerFactory.getLogger(ConvertQueueBizImpl.class);
private final static Logger LOGGER = LoggerFactory.getLogger(ConvertQueueBizImpl.class);
// @Autowired(required=false)
// @Qualifier("jmsFrontEventTemplate")
// private JmsTemplate jmsFrontEventTemplate;
@Resource
private AmqpTemplate amqpTemplate;
@Autowired(required=false)
@Qualifier("jmsFrontEventTemplate")
private JmsTemplate jmsFrontEventTemplate;
/**
* 发送事件消息
*
* @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 {
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);
LOGGER.info("===大数据埋点===start --> frontEventDto:{}", frontEventDto);
amqpTemplate.convertAndSend(MQQueueConstant.FRONT_EVENT, frontEventDto);
LOGGER.info("===大数据埋点===end --> frontEventDto:{}", frontEventDto);
}
/**
......@@ -57,10 +66,7 @@ public class FrontEventBizImpl implements FrontEventBiz{
* @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();
public static String generatePrefix(String targetClass, String targetType) {
return targetClass.toLowerCase() + "_" + targetType.toLowerCase() + "_";
}
}
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());
}
}
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{
/**
*
*/
private final static Logger logger=LoggerFactory.getLogger(FunnelFlowQueueBizImpl.class);
@Autowired(required=false)
@Qualifier("jmsFunnelFlowTemplate")
private JmsTemplate jmsFunnelFlowTemplate;
public class FunnelFlowQueueBizImpl implements FunnelFlowQueueBiz {
@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,8 +45,10 @@ 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);
}
......@@ -84,8 +56,10 @@ public class FunnelFlowQueueBizImpl implements FunnelFlowQueueBiz{
* 发送队列
*/
@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);
}
......
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{
/**
*
*/
private final static Logger logger = LoggerFactory.getLogger(LabelUsedQueueBizImpl.class);
public class LabelUsedQueueBizImpl implements LabelUsedQueueBiz {
@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);
}
}
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
@ParamLog("动态监控QUEUE")
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;
amqpTemplate.convertAndSend(MQQueueConstant.MERCHANT_DYNAMIC, dynamicDto);
}
logger.info("发送成功,"+dynamicDto);
}
}
......@@ -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;
......@@ -38,4 +39,9 @@ public interface MessageBiz {
*/
void sendSMS(SendMessageDto smsParam);
/**
* 短信推送
*/
void sendAppMessage(SendAppMessageDto sendAppMessageDto);
}
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{
@Component("messageQueueBiz")
public class MessageBizImpl implements MessageBiz {
private final static Logger logger = LoggerFactory.getLogger(MessageBizImpl.class);
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;
@ParamLog("发送短信")
public void sendSMS(SendMessageDto sendMessageDto) {
try {
mqMessage = formateMessage(smsParam);
logger.info("mqMessage+++++++++++" + mqMessage);
} catch (IOException e) {
logger.error("短信发送失败," + smsParam);
return null;
}
return session.createObjectMessage(mqMessage);
}
};
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 {
@Override
@ParamLog("发送APP推送")
public void sendAppMessage(SendAppMessageDto sendAppMessageDto) {
try {
ObjectMapper objectMapper = new ObjectMapper();
String content = objectMapper.writeValueAsString(smsParam);
return new MqMessage(MqMessageTypeEnum.SHORT_MESSAGE, content);
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);
}
}
}
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);
}
}
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);
}
}
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{
/**
*
*/
private final static Logger logger=LoggerFactory.getLogger(UserActionQueueBizImpl.class);
public class UserActionQueueBizImpl implements UserActionQueueBiz {
@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);
}
}
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);
public class WeektaskQueueBizImpl implements WeektaskQueueBiz {
@Autowired(required=false)
@Qualifier("jmsWeektaskTemplate")
private JmsTemplate jmsWeekstaskTemplate;
// @Autowired(required= false)
// @Qualifier("raystask")
// private ActiveMQQueue templateQueue;
@Autowired
private AmqpTemplate amqpTemplate;
/**
* 发送队列
*/
@Override
@ParamLog("红榜任务QUEUE")
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);
amqpTemplate.convertAndSend(MQQueueConstant.WEEK_TASK, weektaskMessageDto);
}
}
......@@ -4,12 +4,8 @@
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 {
......@@ -17,91 +13,95 @@ public enum ConvertEnum {
/**
* 应用转码
*/
APP("APP", "convert2App"),
APP("APP"),
/**
* 资源中心转码
*/
RESOURCE("RESOURCE", "convert2Resource"),
RESOURCE("RESOURCE"),
/**
* 报名时的视频转换
*/
MATCH("MATCH", "convert2Resource"),
MATCH("MATCH"),
/**
* 资源中心即时转换
*/
INSTANT_RESOURCE("INSTANT_RESOURCE", "convert2Resource"),
INSTANT_RESOURCE("INSTANT_RESOURCE"),
/**
* 报名应用
*/
MATCH_APP("MATCH_APP", "convert2MatchApp"),
MATCH_APP("MATCH_APP"),
/**
* 内容中心
*/
CONTENT("CONTENT", "convert2Content"),
CONTENT("CONTENT"),
/**
* 内容中心->题库:文件记忆功能
*/
PRETEST_FILEMEMORY("PRETEST_FILEMEMORY", "convert2PretestFilememory"),
PRETEST_FILEMEMORY("PRETEST_FILEMEMORY"),
/**
* 小游戏
*/
RAYSTASK("RAYSTASK", "convert2Raystask"),
RAYSTASK("RAYSTASK"),
/**
* 圈子应用
*/
GROUP_APP("GROUP_APP", "convert2GroupApp"),
GROUP_APP("GROUP_APP"),
/**
* 投票应用
*/
VOTE_APP("VOTE_APP", "convert2VoteApp"),
VOTE_APP("VOTE_APP"),
/**
* 教育表格应用
*/
EF_APP("EF_APP", "convert2EfApp"),
EF_APP("EF_APP"),
/**
* 测试工具
*/
TEST_APP("TEST_APP", "convert2TestApp"),
TEST_APP("TEST_APP"),
/**
* 直播工具
*/
LIVE_APP("LIVE_APP", "convert2LiveApp"),
LIVE_APP("LIVE_APP"),
/**
* 视频课
*/
VIDEO_LESSON("VIDEO_LESSON", "convert2VideoLesson");
VIDEO_LESSON("VIDEO_LESSON"),
/**
* 值
* 音频课
*/
public final String value;
AUDIO_LESSON("AUDIO_LESSON"),
/**
* 模板名称
* 音频纯听
*/
public final String jmsTemplate;
AUDIO_LISTEN("AUDIO_LISTEN");
/**
* 值
*/
public final String value;
/**
* 构造
*
* @param value
*/
private ConvertEnum(String value, String jmsTemplate) {
private ConvertEnum(String value) {
this.value = value;
this.jmsTemplate = jmsTemplate;
}
}
......@@ -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";
......
......@@ -16,29 +16,255 @@ 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";
/**
* 管理消息
*/
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交换机名称(勿改)
......
......@@ -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};
/**
* 数据平台埋点型作品
......
......@@ -9,7 +9,10 @@ package com.pcloud.common.core.constant;
*/
public enum SceneCode {
/**
* 奖金发放通知
*/
PRIZE_SEND_SCENE("PRIZE_SEND_SCENE"),
/**
* 服务完成通知
......@@ -47,24 +50,9 @@ public enum SceneCode {
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"),
/**
* 退款成功
......@@ -91,33 +79,17 @@ public enum SceneCode {
*/
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,11 +112,7 @@ public enum SceneCode {
/**
* 会员到期提醒
*/
MEMBERSHIP_EXPIRE("MEMBERSHIP_EXPIRE"),
/**
* 奖金发放通知
*/
PRIZE_SEND_SCENE("PRIZE_SEND_SCENE");
MEMBERSHIP_EXPIRE("MEMBERSHIP_EXPIRE");
/**
* 值
......
......@@ -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"),
/**
* 回复图文资讯评论
* 查看纸书数据
*/
W4_ARTICLE_REPLY("w4_article_reply"),
W5_VIEW_BOOK_DATA("w5_view_book_data"),
/**
* 完善纸书问答合集
* 创建视频应用并关联书刊
*/
W4_CREATE_QA("w4_create_qa"),
W5_CREATE_VIDEO_APP_AND_RELATE("w5_create_video_app_and_relate"),
/**
* 建立衍生文本
* 更新PDF应用并发布到读者圈
*/
W4_UPLOAD_PDF("w4_upload_pdf"),
W5_UPDATE_GROUP_BY_PDF("w5_update_group_by_pdf"),
/**
* 创建视听内容
* 创建愿望单应用
*/
W4_UPLOAD_VIDEO("w4_upload_video"),
W5_CREATE_WISHLIST_APP("w5_create_wishlist_app"),
/**
* 让读者听见纸书
* 创建专题问答应用
*/
W4_UPLOAD_AUDIO("w4_upload_audio"),
W5_CREATE_EF_APP("w5_create_ef_app"),
/**
* 配套纸书插画图解
* 更新读者交流圈动态2
*/
W4_UPLOAD_PIC("w4_upload_pic"),
W5_CREATE_GROUP_FOR_PDF("w5_update_group_for_pdf"),
/**
* 呈现纸书全方位资讯
* 配置二维码消息
*/
W4_CREATE_SPECIAL("w4_create_special"),
W5_CONFIG_QRCODE("w5_config_qrcode"),
/**
* 秀出红榜任务排行
*发布直播讲义
*/
W4_SHARE_REPORT("w4_share_report"),
W5_PUBLISH_LECTURE("w5_publish_lecture"),
/**
* app发布语音动态
*体验录播模式
*/
W4_GROUP_VOICE_POST("w4_group_voice_post"),
W5_EXPERIENCE_VIDEO("w5_experience_video"),
/**
* 掌握纸书使用高峰
*审核动态
*/
W4_VIEW_BOOK_TIDE("w4_view_book_tide"),
W5_AUDIT_DYNAM("w5_audit_dynam"),
/**
* 二维码数据分析
*新建直播课应用
*/
W4_VIEW_QRCODE_TIDE("w4_view_qrcode_tide"),
W5_CREATE_SUPER_LIVEAPP("w5_create_super_liveapp"),
/**
* 了解纸书数据
*新建延伸阅读应用
*/
W4_VIEW_ANALYSIS("w4_view_analysis"),
W5_CREATE_PDF("w5_create_pdf"),
/**
* 查看纸书收益
*新建在线题库应用
*/
W4_VIEW_GAINS("w4_view_gains"),
W5_CREATE_QUESTION_BANK("w5_create_question_bank"),
/**
* 建立基于纸书内容的题库
*标准服务预览
*/
W4_UPLOAD_ITEM_BANK("w4_upload_item_bank"),
W5_VIEW_GUIDE("w5_view_guide"),
/**
* 纸书内容读者自测
*创建投票应用
*/
W4_CREATE_ITEM_BANK("w4_create_item_bank"),
W5_CREATE_VOTE_APP("w5_create_vote_app"),
/**
* 本周直播课
*创建抽奖应用
*/
W4_BEGIN_LIVE("w4_begin_live"),
W5_CREATE_DRAW_APP("w5_create_draw_app"),
;
public final String code;
......
......@@ -19,8 +19,7 @@ public interface BaseDao<T> {
/**
* 根据实体对象新增记录.
*
* @param entity
* .
* @param entity .
* @return id .
*/
long insert(T entity);
......@@ -28,8 +27,7 @@ public interface BaseDao<T> {
/**
* 批量保存对象.
*
* @param entity
* .
* @param entity .
* @return id .
*/
long insert(List<T> list);
......@@ -37,8 +35,7 @@ public interface BaseDao<T> {
/**
* 更新实体对应的记录.
*
* @param entity
* .
* @param entity .
* @return
*/
long update(T entity);
......@@ -53,10 +50,19 @@ public interface BaseDao<T> {
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);
......@@ -64,8 +70,7 @@ public interface BaseDao<T> {
/**
* 根据ID查找记录.
*
* @param id
* .
* @param id .
* @return entity .
*/
T getById(long id);
......@@ -73,8 +78,7 @@ public interface BaseDao<T> {
/**
* 根据ID删除记录.
*
* @param id
* .
* @param id .
* @return
*/
long deleteById(long id);
......@@ -82,10 +86,8 @@ public interface BaseDao<T> {
/**
* 分页查询 .
*
* @param pageParam
* 分页参数.
* @param paramMap
* 业务条件查询参数.
* @param pageParam 分页参数.
* @param paramMap 业务条件查询参数.
* @return
*/
PageBean listPage(PageParam pageParam, Map<String, Object> paramMap);
......
......@@ -5,6 +5,7 @@ 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;
......@@ -118,6 +119,27 @@ public abstract class BaseDaoImpl<T extends BaseEntity> implements BaseDao<T> {
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)
......@@ -230,7 +252,7 @@ public abstract class BaseDaoImpl<T extends BaseEntity> implements BaseDao<T> {
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public List<T> listBy(Map<String, Object> paramMap) {
return (List) this.listBy(paramMap, SQL_LIST_BY);
}
......
......@@ -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 + '\'' +
'}';
}
}
......@@ -6,9 +6,10 @@ import java.util.Map;
/**
* 模板消息dto
*
* @author 作者 : lili
* @date 创建时间:2016年11月17日 下午12:03:48
* @version 1.0
* @date 创建时间:2016年11月17日 下午12:03:48
* @return
*/
public class TemplateMessageDto implements Serializable {
......@@ -93,6 +94,18 @@ public class TemplateMessageDto implements Serializable {
*/
private String appType;
/**
* 消息来源分类
*/
private String fromCategory;
public String getFromCategory() {
return fromCategory;
}
public void setFromCategory(String fromCategory) {
this.fromCategory = fromCategory;
}
public Long getAccountSettingId() {
return accountSettingId;
......
......@@ -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"); //经典版视频
/**
* 值
*/
......
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;
}
}
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;
}
}
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;
}
}
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");
}
}
......@@ -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>
......
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;
}
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 +
'}';
}
}
......@@ -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;
}
......
......@@ -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"); //经典版视频
/**
* 枚举转换
......
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);
}
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 +
'}';
}
}
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 + '\'' +
'}';
}
}
......@@ -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,8 +10,6 @@ import org.springframework.beans.BeanUtils;
import com.google.common.collect.Lists;
/**
*
*
* @author:songx
* @date:2018年8月24日,下午2:18:40
*/
......@@ -21,10 +20,8 @@ public class BeanNewUtils {
/**
* 实体类之间的转换
*
* @param source
* 来源
* @param clazz
* 目标对象
* @param source 来源
* @param clazz 目标对象
* @return
*/
public static <T> T copyProperties(Object source, Class<T> clazz) {
......@@ -44,10 +41,8 @@ public class BeanNewUtils {
/**
* 实体类之间的转换
*
* @param sources
* 来源
* @param clazz
* 目标对象
* @param sources 来源
* @param clazz 目标对象
* @return
*/
public static <T> List<T> copyProperties(List<?> sources, Class<T> clazz) {
......@@ -61,4 +56,32 @@ public class BeanNewUtils {
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;
}
}
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);
}
}
}
......@@ -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);
}
/**
......
......@@ -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;
}
}
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);
}
R = R/sum;
G = G/sum;
B = B/sum;
return new Color(R,G,B);
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);
}
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);
// 保存并上传图片
Color color = null;
try {
color = getImagePixel(bookPic);
}catch (Exception e){
color = Color.gray;
}
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(bg, ImageTypeEnum.JPG.value, os);
ImageIO.write(bufferedImage, 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));
// 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{
bookPicImage = ImageIO.read(new File(bookPic));
playPicImage = ImageIO.read(new File(playPic));
defaultBackgroudImage = ImageIO.read(new File(defaultBackgroundPic));
oathI = ImageIO.read(new File(oath));
color = getImagePixel(bookPic);
}
//画一个空的背景
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);
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;
}
g.setColor(new Color(252, 252, 252));
g.fillRect(0, 196, 702, 102);
g.setColor(new Color(221, 221, 221));
//插入书籍图和播放按钮
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");
// g.drawImage(oathI.getScaledInstance(185,252, Image.SCALE_DEFAULT), 258, 33, null);
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));
BufferedImage image = new BufferedImage(157, 200, BufferedImage.TYPE_INT_ARGB);
Graphics2D gs = image.createGraphics();
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 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);
// 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);
g.drawImage(playPicImage.getScaledInstance(80,80, Image.SCALE_DEFAULT), 306, 105, null);
// g.drawRect(265,30,172,238);
//保存图片
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);
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();
}
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());
// }
}
......
package com.pcloud.common.utils.pdf;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
......@@ -9,8 +8,6 @@ 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;
......@@ -45,9 +42,6 @@ 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
......@@ -78,7 +72,12 @@ public class PdfUtils {
* @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);
......@@ -95,48 +94,6 @@ public class PdfUtils {
}
/**
* 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
......@@ -154,8 +111,8 @@ public class PdfUtils {
fi.mkdirs();
}
try {
PdfToImage pImage = new PdfToImage(IMAGE_WITH, IMAGE_HEIGHT, prefix, format);
pImage.convertPagesToHiResImages(b, outPath);
// 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);
......@@ -401,9 +358,12 @@ public class PdfUtils {
/**
* 加水印(字符串)
*
* @param inputFile 需要加水印的PDF路径
* @param outputFile 输出生成PDF的路径
* @param waterMarkName 水印字符
* @param inputFile
* 需要加水印的PDF路径
* @param outputFile
* 输出生成PDF的路径
* @param waterMarkName
* 水印字符
*/
public static void stringWaterMark(String filePath, String waterMarkName) {
PdfReader reader = null;
......
......@@ -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);
......
......@@ -20,6 +20,7 @@ import com.pcloud.common.exceptions.BizException;
* @创建时间:2016年3月10日,上午11:49:07 @版本:1.0
*/
public class StringUtil extends StringUtilParent {
/**
* 判断字符串是否为空
*
......@@ -51,8 +52,7 @@ public class StringUtil extends StringUtilParent {
/**
* 判断字符串是否为空(自动截取首尾空白)
*
* @param str
* 源字符串
* @param str 源字符串
* @return
*/
public static boolean isEmpty(String str) {
......@@ -62,10 +62,8 @@ public class StringUtil extends StringUtilParent {
/**
* 判断字符串是否为空
*
* @param str
* 源字符串
* @param trim
* 是否截取首尾空白
* @param str 源字符串
* @param trim 是否截取首尾空白
* @return
*/
public static boolean isEmpty(String str, boolean trim) {
......@@ -83,12 +81,10 @@ public class StringUtil extends StringUtilParent {
}
/**
* @param str
* the string need to be parsed
* @param delim
* the delimiter to seperate created by zqf at 6/1/2013
* @param str the string need to be parsed
* @param delim the delimiter to seperate created by zqf at 6/1/2013
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public static String[] parseToArray(String str, String delim) {
ArrayList arr = new ArrayList();
StringTokenizer st = new StringTokenizer(str, delim);
......@@ -105,12 +101,9 @@ public class StringUtil extends StringUtilParent {
/**
* 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
* @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) {
......@@ -165,12 +158,9 @@ public class StringUtil extends StringUtilParent {
/**
* 用于字符串替换
*
* @param target
* 目标对象 需要替换的字符串
* @param replacement
* 要替换的字符串
* @param value
* 替换的值
* @param target 目标对象 需要替换的字符串
* @param replacement 要替换的字符串
* @param value 替换的值
* @return
*/
public static String replacement(String target, String replacement, String value) {
......@@ -225,8 +215,8 @@ public class StringUtil extends StringUtilParent {
}
/**
* @description 获取当前服务器日期
* @return
* @description 获取当前服务器日期
*/
public static String getCurrdate(String formatStr) {
Calendar cal = Calendar.getInstance();
......@@ -274,11 +264,24 @@ public class StringUtil extends StringUtilParent {
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
* 被解析字符串
* @param str 被解析字符串
* @return String 解析后的字符串
*/
public static String parse(String str) {
......@@ -344,13 +347,9 @@ public class StringUtil extends StringUtilParent {
}
/**
*
* @param initCode
* 初始化编码
* @param length
* 需要生成编码长度
* @param ind
* 地增量
* @param initCode 初始化编码
* @param length 需要生成编码长度
* @param ind 地增量
* @return 递增后的编码
*/
public static String getNextCode(String initCode, int length, int ind) {
......@@ -414,8 +413,7 @@ public class StringUtil extends StringUtilParent {
/**
* 中文数字转换为阿拉伯数
*
* @param String
* s
* @param String s
*/
public static int cnNumToInt(String s) {
int result = 0;
......@@ -520,9 +518,7 @@ public class StringUtil extends StringUtilParent {
}
/**
*
* @param obj
* 传数值类型的obj
* @param obj 传数值类型的obj
* @param format
* @return
*/
......@@ -534,9 +530,7 @@ public class StringUtil extends StringUtilParent {
}
/**
*
* @param obj
* 传数值类型的obj
* @param obj 传数值类型的obj
* @param format
* @return
*/
......
......@@ -49,7 +49,6 @@
<pcloud-common-core.version>2.1.0-RELEASE</pcloud-common-core.version>
</properties>
</profile>
<!-- 压测环境 -->
<profile>
<id>perf</id>
......@@ -71,8 +70,7 @@
<pcloud-common-core.version>2.1.0-RELEASE</pcloud-common-core.version>
</properties>
</profile>
<!-- 生产环境 RAYS-->
<!-- 生产环境 RAYS -->
<profile>
<id>prod</id>
<build>
......@@ -93,35 +91,13 @@
<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-cloud.version>Dalston.SR3</spring-cloud.version>
<spring.data.solr.version>2.1.7.RELEASE</spring.data.solr.version>
<!-- frameworks -->
......@@ -257,14 +233,6 @@
</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>
......@@ -282,18 +250,14 @@
<version>0.1.2</version>
</dependency>
<!-- Others Begin -->
<dependency>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
<version>3.2.10.Final</version>
</dependency>
<!-- Mysql Driver Begin -->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.15.0</version>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
<!-- Others End -->
<!-- Mysql Driver End -->
<!-- 图片处理工具 added by songx at 2017-05-17 -->
<dependency>
......@@ -321,13 +285,6 @@
<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>
......@@ -344,6 +301,7 @@
<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>
......@@ -351,7 +309,6 @@
<artifactId>spring-data-solr</artifactId>
<version>${spring.data.solr.version}</version>
</dependency>
<!-- end -->
<!-- Jackson Begin -->
<dependency>
......
temp.jpg

1.82 MB

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment