mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-11 03:46:50 +08:00
zcwy-dev
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.xboe.constants;
|
||||
|
||||
/**
|
||||
* @author : civism
|
||||
* @version 1.0
|
||||
* @date 2023/6/17 16:13
|
||||
*/
|
||||
public enum CasesPushStatusEnum {
|
||||
|
||||
/**
|
||||
* 推送状态1未推送2推送中3已推送4推送失败5已撤回
|
||||
*/
|
||||
WAIT_PUSH(1,"未推送"),
|
||||
PUSH_ING(2,"推送中"),
|
||||
PUSH_SUCCESS(3,"已推送"),
|
||||
PUSH_FAIL(4,"推送失败"),
|
||||
PUSH_REVOKE(5,"已撤回"),
|
||||
|
||||
;
|
||||
|
||||
|
||||
CasesPushStatusEnum(Integer status, String desc) {
|
||||
this.status = status;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
private Integer status;
|
||||
|
||||
|
||||
private String desc;
|
||||
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.xboe.module.cases.dao;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.module.cases.entity.CasesRecommend;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class CasesRecommendDao extends BaseDao<CasesRecommend> {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.xboe.module.cases.dao;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.module.cases.entity.CasesRecommendPushRecord;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class CasesRecommendPushRecordDao extends BaseDao<CasesRecommendPushRecord> {
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.xboe.module.cases.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 案例推荐表
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = SysConstant.TABLE_PRE + "cases_recommend")
|
||||
public class CasesRecommend extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 推荐人ID
|
||||
*/
|
||||
@Column(name = "recommend_id", length = 100)
|
||||
private String recommendId;
|
||||
|
||||
/**
|
||||
* 推荐人
|
||||
*/
|
||||
@Column(name = "recommend_by", length = 255)
|
||||
private String recommendBy;
|
||||
|
||||
/**
|
||||
* 推荐时间
|
||||
*/
|
||||
@Column(name = "recommend_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime recommendTime;
|
||||
/**
|
||||
* 案例数
|
||||
*/
|
||||
@Column(name = "case_count", length = 11)
|
||||
private Integer caseCount;
|
||||
/**
|
||||
* 用户数
|
||||
*/
|
||||
@Column(name = "user_count", length = 11)
|
||||
private Integer userCount;
|
||||
/**
|
||||
* 推送进度
|
||||
*/
|
||||
@Column(name = "push_progress")
|
||||
private Integer pushProgress;
|
||||
/**
|
||||
* 查看率
|
||||
*/
|
||||
@Column(name = "view_rate", length = 255)
|
||||
private String viewRate;
|
||||
|
||||
/**
|
||||
* 推荐组织名称
|
||||
*/
|
||||
@Column(name = "recommend_org_name", length = 255)
|
||||
private String recommendOrgName;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.xboe.module.cases.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 案例推荐发起导入
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = SysConstant.TABLE_PRE + "cases_recommend_push_record")
|
||||
public class CasesRecommendPushRecord extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 推送id
|
||||
*/
|
||||
@Column(name = "recommend_id")
|
||||
private String recommendId;
|
||||
|
||||
/**
|
||||
* 案例id
|
||||
*/
|
||||
@Column(name = "case_id")
|
||||
private String caseId;
|
||||
|
||||
|
||||
/**
|
||||
* 案例标题
|
||||
*/
|
||||
@Column(name = "case_title")
|
||||
private String caseTitle;
|
||||
|
||||
|
||||
/**
|
||||
* 推送用户id
|
||||
*/
|
||||
@Column(name = "push_user_id")
|
||||
private String pushUserId;
|
||||
|
||||
|
||||
/**
|
||||
* 推送用户名称
|
||||
*/
|
||||
@Column(name = "push_user_name")
|
||||
private String pushUserName;
|
||||
|
||||
|
||||
/**
|
||||
* 推送状态1未推送2推送中3已推送4推送失败5已撤回
|
||||
*/
|
||||
@Column(name = "push_status")
|
||||
private Integer pushStatus;
|
||||
|
||||
|
||||
/**
|
||||
* 推送时间
|
||||
*/
|
||||
@Column(name = "push_time")
|
||||
private Date pushTime;
|
||||
|
||||
|
||||
/**
|
||||
* 查看标识
|
||||
*/
|
||||
@Column(name = "read_flag")
|
||||
private Integer readFlag;
|
||||
|
||||
/**
|
||||
* 首次查看时间
|
||||
*/
|
||||
@Column(name = "read_start_time")
|
||||
private Date readStartTime;
|
||||
|
||||
/**
|
||||
* 最后查看时间
|
||||
*/
|
||||
@Column(name = "read_end_time")
|
||||
private Date readEndTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Column(name = "remark")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.xboe.module.cases.service;
|
||||
|
||||
import com.xboe.module.cases.entity.CasesRecommendPushRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ICasesRecommendPushRecordService {
|
||||
|
||||
/**
|
||||
* 查询推送纪录通过推送状态
|
||||
*
|
||||
* @param pushStatusList
|
||||
* @return
|
||||
*/
|
||||
List<CasesRecommendPushRecord> queryPushRecordByPushStatus(List<Integer> pushStatusList);
|
||||
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param pushStatus
|
||||
* @return
|
||||
*/
|
||||
boolean updatePushRecordStatus(String id,Integer pushStatus);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.xboe.module.cases.service;
|
||||
|
||||
import com.xboe.module.cases.entity.CasesRecommend;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ICasesRecommendService {
|
||||
|
||||
/**
|
||||
* 通过推送状态查询
|
||||
*
|
||||
* @param pushProgress
|
||||
* @return
|
||||
*/
|
||||
List<CasesRecommend> queryByPushProgress(Integer pushProgress);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param casesRecommend
|
||||
* @return
|
||||
*/
|
||||
public boolean updateProcessStatus(String id, Integer pushProgress);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.xboe.module.cases.service.impl;
|
||||
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.UpdateBuilder;
|
||||
import com.xboe.module.cases.dao.CasesRecommendPushRecordDao;
|
||||
import com.xboe.module.cases.entity.CasesRecommendPushRecord;
|
||||
import com.xboe.module.cases.service.ICasesRecommendPushRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class CasesRecommendPushRecordServiceImpl implements ICasesRecommendPushRecordService {
|
||||
|
||||
@Resource
|
||||
private CasesRecommendPushRecordDao casesRecommendPushRecordDao;
|
||||
|
||||
@Override
|
||||
public List<CasesRecommendPushRecord> queryPushRecordByPushStatus(List<Integer> pushStatusList) {
|
||||
return casesRecommendPushRecordDao.getGenericDao().findList(CasesRecommendPushRecord.class, FieldFilters.in("push_status", pushStatusList));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updatePushRecordStatus(String id, Integer pushStatus) {
|
||||
return casesRecommendPushRecordDao.updateMultiFieldById(id, UpdateBuilder.create("pushStatus", pushStatus), UpdateBuilder.create("pushTime", new Date())) > 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.xboe.module.cases.service.impl;
|
||||
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.UpdateBuilder;
|
||||
import com.xboe.module.cases.dao.CasesRecommendDao;
|
||||
import com.xboe.module.cases.entity.CasesRecommend;
|
||||
import com.xboe.module.cases.service.ICasesRecommendService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class CasesRecommendServiceImpl implements ICasesRecommendService {
|
||||
|
||||
@Resource
|
||||
private CasesRecommendDao casesRecommendDao;
|
||||
|
||||
@Override
|
||||
public List<CasesRecommend> queryByPushProgress(Integer pushProgress) {
|
||||
return casesRecommendDao.getGenericDao().findList(CasesRecommend.class, FieldFilters.eq("pushProgress", pushProgress));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateProcessStatus(String id, Integer pushProgress) {
|
||||
return casesRecommendDao.updateMultiFieldById(id, UpdateBuilder.create("pushProgress", pushProgress)) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.xboe.stat;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.api.TokenProxy;
|
||||
import com.xboe.core.event.IEventDataSender;
|
||||
import com.xboe.core.utils.OkHttpUtil;
|
||||
import com.xboe.standard.BaseConstant;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 事件数据发送实现,如果是云环境,只需要修改此类的实现就可以了
|
||||
* @author seastar
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EventDataSender implements IEventDataSender{
|
||||
|
||||
@Autowired
|
||||
private OkHttpUtil okHttpUtil;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public void send(String title, String eventKey, String content, String objId, String objType, String objInfo,
|
||||
String aid, String aname,String parameters) {
|
||||
String statBaseUrl=SysConstant.getConfigValue("xboe.stat.base.url");
|
||||
if(StringUtils.isBlank(statBaseUrl)) {
|
||||
log.error("发送事件失败:未配置【xboe.stat.base.url】的值");
|
||||
return;
|
||||
}
|
||||
String urlPre="/xboe/m/stat/event/send";
|
||||
//案例同步不需要token
|
||||
if(eventKey.equals("SyncCase")) {
|
||||
urlPre ="/inner/stat/event/send";
|
||||
}
|
||||
|
||||
final String url = statBaseUrl + urlPre;
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("title", title);
|
||||
params.put("source", "all");
|
||||
params.put("content", content);
|
||||
params.put("objId", objId);
|
||||
params.put("key", eventKey);
|
||||
params.put("objType", objType);
|
||||
params.put("objInfo", objInfo);
|
||||
params.put("aid", aid);
|
||||
params.put("aname", aname);
|
||||
params.put("parameters",parameters);
|
||||
String token = TokenProxy.getToken(request);
|
||||
//最后采用异常发送,不影响当前进程
|
||||
|
||||
new Thread(()->{
|
||||
try {
|
||||
ObjectMapper mapper=new ObjectMapper();
|
||||
String json =mapper.writeValueAsString(params);
|
||||
//String[] headers=new String[] {"token",token};
|
||||
String[] headers=new String[] {BaseConstant.HTTP_ACCESS_TOKEN,token};
|
||||
|
||||
String responseStr = okHttpUtil.doPostJson(url, json,headers);
|
||||
if(responseStr.indexOf("\"status\":200")==-1) {
|
||||
log.error("发送事件失败:"+responseStr);
|
||||
log.info("【发送的token】"+headers[0]+": "+headers[1]);
|
||||
}
|
||||
}catch(Exception e) {
|
||||
log.error("发送事件错误",e);
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.xboe.task;
|
||||
|
||||
import com.xboe.constants.CasesPushStatusEnum;
|
||||
import com.xboe.core.event.IEventDataSender;
|
||||
import com.xboe.module.cases.entity.CasesRecommend;
|
||||
import com.xboe.module.cases.entity.CasesRecommendPushRecord;
|
||||
import com.xboe.module.cases.service.ICasesRecommendPushRecordService;
|
||||
import com.xboe.module.cases.service.ICasesRecommendService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : civism
|
||||
* @version 1.0
|
||||
* @date 2023/6/18 10:50
|
||||
*/
|
||||
@EnableScheduling
|
||||
@Component("com.xboe.casetask.CasesRecommendPushSchedule")
|
||||
@Slf4j
|
||||
public class CasesRecommendPushSchedule {
|
||||
|
||||
|
||||
@Resource
|
||||
private ICasesRecommendService casesRecommendService;
|
||||
|
||||
|
||||
@Resource
|
||||
private ICasesRecommendPushRecordService casesRecommendPushRecordService;
|
||||
|
||||
@Autowired(required = false)
|
||||
private IEventDataSender eventDataSender;
|
||||
|
||||
|
||||
/**
|
||||
* 每分钟执行一次
|
||||
*/
|
||||
// @Scheduled(cron = "0 */1 * * * ?")
|
||||
public void execute() {
|
||||
log.info("启动案例推荐定时任务");
|
||||
List<CasesRecommend> casesRecommends = casesRecommendService.queryByPushProgress(CasesPushStatusEnum.WAIT_PUSH.getStatus());
|
||||
if (CollectionUtils.isEmpty(casesRecommends)) {
|
||||
log.warn("没有推送纪录,无需推送");
|
||||
return;
|
||||
}
|
||||
for (CasesRecommend casesRecommend : casesRecommends) {
|
||||
List<Integer> pushStatusList = new ArrayList<>();
|
||||
pushStatusList.add(CasesPushStatusEnum.WAIT_PUSH.getStatus());
|
||||
pushStatusList.add(CasesPushStatusEnum.WAIT_PUSH.getStatus());
|
||||
List<CasesRecommendPushRecord> casesRecommendPushRecords = casesRecommendPushRecordService.queryPushRecordByPushStatus(pushStatusList);
|
||||
if (CollectionUtils.isEmpty(casesRecommendPushRecords)) {
|
||||
//修改为推送完成 --- 无数据 无需推送
|
||||
casesRecommendService.updateProcessStatus(casesRecommend.getId(), CasesPushStatusEnum.PUSH_SUCCESS.getStatus());
|
||||
continue;
|
||||
}
|
||||
//修改为推送中
|
||||
casesRecommendService.updateProcessStatus(casesRecommend.getId(), CasesPushStatusEnum.PUSH_ING.getStatus());
|
||||
|
||||
|
||||
for (CasesRecommendPushRecord casesRecommendPushRecord : casesRecommendPushRecords) {
|
||||
|
||||
Integer pushStatus;
|
||||
try {
|
||||
|
||||
eventDataSender.send("案例推荐", "recommendCases", "案例推荐【" + casesRecommendPushRecord.getCaseTitle() + "】",
|
||||
casesRecommendPushRecord.getCaseId(), "99", casesRecommendPushRecord.getCaseTitle(),
|
||||
casesRecommendPushRecord.getSysCreateAid(), casesRecommendPushRecord.getSysCreateBy(), "");
|
||||
|
||||
pushStatus = CasesPushStatusEnum.PUSH_SUCCESS.getStatus();
|
||||
} catch (Exception e) {
|
||||
log.error("推荐案例失败", e);
|
||||
pushStatus = CasesPushStatusEnum.PUSH_FAIL.getStatus();
|
||||
}
|
||||
casesRecommendPushRecordService.updatePushRecordStatus(casesRecommendPushRecord.getId(), pushStatus);
|
||||
}
|
||||
|
||||
//修改为推送完成 --- 无数据 无需推送
|
||||
casesRecommendService.updateProcessStatus(casesRecommend.getId(), CasesPushStatusEnum.PUSH_SUCCESS.getStatus());
|
||||
log.info("启动案例推荐定时任务----结束");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ spring.datasource.driverClassName=com.mysql.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://192.168.0.10:3306/boe_base1?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=ENC(lAoFOYuc8CAypPtigTNLYg==)
|
||||
#spring.jpa.hibernate.ddl-auto=none
|
||||
|
||||
# logging.level.org.hibernate.SQL=DEBUG
|
||||
# logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
|
||||
@@ -33,6 +34,7 @@ xboe.upload.file.http_path=http://localhost:9090/cdn/upload
|
||||
|
||||
## 外部接口调用地址 旧系统机构及用户数据接口
|
||||
xboe.externalinterface.url.system=http://localhost:9091
|
||||
xboe.stat.base.url=http://127.0.0.1:9080
|
||||
|
||||
#加密盐
|
||||
#jasypt.encryptor.password=jasypt
|
||||
|
||||
Reference in New Issue
Block a user