Browse Source

Merge branch 'dev_data_stats' into dev

master
wangchao 5 years ago
parent
commit
bd0c32561a
  1. 2
      epmet-module/data-statistical/data-statistical-server/pom.xml
  2. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java
  3. 45
      epmet-module/epmet-job/epmet-job-client/src/main/java/com/epmet/dto/ScheduleJobTypeDTO.java
  4. 7
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/ScheduleJobController.java
  5. 9
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/dao/ScheduleJobDao.java
  6. 3
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ScheduleJobService.java
  7. 108
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ScheduleJobServiceImpl.java
  8. 9
      epmet-module/epmet-job/epmet-job-server/src/main/resources/mapper/ScheduleJobDao.xml

2
epmet-module/data-statistical/data-statistical-server/pom.xml

@ -159,7 +159,7 @@
<spring.redis.port>6379</spring.redis.port> <spring.redis.port>6379</spring.redis.port>
<spring.redis.password>123456</spring.redis.password> <spring.redis.password>123456</spring.redis.password>
<!-- nacos --> <!-- nacos -->
<nacos.register-enabled>false</nacos.register-enabled> <nacos.register-enabled>true</nacos.register-enabled>
<nacos.server-addr>122.152.200.70:8848</nacos.server-addr> <nacos.server-addr>122.152.200.70:8848</nacos.server-addr>
<nacos.discovery.namespace>fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b</nacos.discovery.namespace> <nacos.discovery.namespace>fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b</nacos.discovery.namespace>
<nacos.config.namespace></nacos.config.namespace> <nacos.config.namespace></nacos.config.namespace>

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/topic/impl/TopicServiceImpl.java

@ -190,17 +190,19 @@ public class TopicServiceImpl implements TopicService {
calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO); calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO);
calendar.set(Calendar.MINUTE, NumConstant.ZERO); calendar.set(Calendar.MINUTE, NumConstant.ZERO);
calendar.set(Calendar.SECOND, NumConstant.ZERO); calendar.set(Calendar.SECOND, NumConstant.ZERO);
//现在的目标日期是[T-1] OR [目标日期]
Date targetDateCheck = null == targetDate ? calendar.getTime() : targetDate; Date targetDateCheck = null == targetDate ? calendar.getTime() : targetDate;
//现在的日历对象是[T-1] OR [目标日期]
calendar.setTime(targetDateCheck); calendar.setTime(targetDateCheck);
//如果目标日期是当月的最后一天 //如果目标日期是当月的最后一天
//if(calendar.get(Calendar.DATE) == calendar.getActualMaximum(Calendar.DAY_OF_MONTH)){ //if(calendar.get(Calendar.DATE) == calendar.getActualMaximum(Calendar.DAY_OF_MONTH)){
//求出这个月的第一天 //求出这个月的第一天
calendar.setTime(new Date());
calendar.set(Calendar.DAY_OF_MONTH, NumConstant.ONE); calendar.set(Calendar.DAY_OF_MONTH, NumConstant.ONE);
calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO); calendar.set(Calendar.HOUR_OF_DAY, NumConstant.ZERO);
calendar.set(Calendar.MINUTE, NumConstant.ZERO); calendar.set(Calendar.MINUTE, NumConstant.ZERO);
calendar.set(Calendar.SECOND, NumConstant.ZERO); calendar.set(Calendar.SECOND, NumConstant.ZERO);
//现在的日历对象是 [T-1]当月的第一天 OR [目标日期]当月的第一天
// isMonthEnd = true; // isMonthEnd = true;
//} //}

45
epmet-module/epmet-job/epmet-job-client/src/main/java/com/epmet/dto/ScheduleJobTypeDTO.java

@ -0,0 +1,45 @@
package com.epmet.dto;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
/**
* @Description
* @ClassName ScheduleJobTypeDTO
* @Auth wangc
* @Date 2020-07-01 11:05
*/
@Data
public class ScheduleJobTypeDTO implements Serializable {
private static final long serialVersionUID = 398827917988646220L;
private Long id;
@NotBlank(message = "{schedule.bean.require}", groups = DefaultGroup.class)
private String beanName;
private String params;
@NotBlank(message = "{schedule.cron.require}", groups = DefaultGroup.class)
private String cronExpression;
@Range(min=0, max=1, message = "{schedule.status.range}", groups = DefaultGroup.class)
private Integer status;
@ApiModelProperty(value = "备注")
private String remark;
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private Date createDate;
private String type;
private Integer order;
}

7
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/ScheduleJobController.java

@ -17,6 +17,7 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.ScheduleJobDTO; import com.epmet.dto.ScheduleJobDTO;
import com.epmet.dto.ScheduleJobTypeDTO;
import com.epmet.service.ScheduleJobService; import com.epmet.service.ScheduleJobService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@ -121,4 +122,10 @@ public class ScheduleJobController {
return new Result(); return new Result();
} }
@GetMapping("pageByType")
public Result<PageData<ScheduleJobTypeDTO>> pageByType(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<ScheduleJobTypeDTO> page = scheduleJobService.pageByType(params);
return new Result<PageData<ScheduleJobTypeDTO>>().ok(page);
}
} }

9
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/dao/ScheduleJobDao.java

@ -9,9 +9,13 @@
package com.epmet.dao; package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.ScheduleJobTypeDTO;
import com.epmet.entity.ScheduleJobEntity; import com.epmet.entity.ScheduleJobEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -26,4 +30,9 @@ public interface ScheduleJobDao extends BaseDao<ScheduleJobEntity> {
* 批量更新状态 * 批量更新状态
*/ */
int updateBatch(Map<String, Object> map); int updateBatch(Map<String, Object> map);
/**
* 拿到所有
* */
List<ScheduleJobTypeDTO> selectAllJobs(@Param("beanName")String beanName);
} }

3
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ScheduleJobService.java

@ -11,6 +11,7 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.ScheduleJobDTO; import com.epmet.dto.ScheduleJobDTO;
import com.epmet.dto.ScheduleJobTypeDTO;
import com.epmet.entity.ScheduleJobEntity; import com.epmet.entity.ScheduleJobEntity;
import java.util.Map; import java.util.Map;
@ -60,4 +61,6 @@ public interface ScheduleJobService extends BaseService<ScheduleJobEntity> {
* 恢复运行 * 恢复运行
*/ */
void resume(Long[] ids); void resume(Long[] ids);
PageData<ScheduleJobTypeDTO> pageByType(Map<String, Object> params);
} }

108
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ScheduleJobServiceImpl.java

@ -16,6 +16,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.ScheduleJobDao; import com.epmet.dao.ScheduleJobDao;
import com.epmet.dto.ScheduleJobDTO; import com.epmet.dto.ScheduleJobDTO;
import com.epmet.dto.ScheduleJobTypeDTO;
import com.epmet.entity.ScheduleJobEntity; import com.epmet.entity.ScheduleJobEntity;
import com.epmet.enums.ScheduleStatusEnum; import com.epmet.enums.ScheduleStatusEnum;
import com.epmet.service.ScheduleJobService; import com.epmet.service.ScheduleJobService;
@ -26,9 +27,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays; import java.util.*;
import java.util.HashMap; import java.util.stream.Collectors;
import java.util.Map;
@Service @Service
public class ScheduleJobServiceImpl extends BaseServiceImpl<ScheduleJobDao, ScheduleJobEntity> implements ScheduleJobService { public class ScheduleJobServiceImpl extends BaseServiceImpl<ScheduleJobDao, ScheduleJobEntity> implements ScheduleJobService {
@ -66,6 +67,7 @@ public class ScheduleJobServiceImpl extends BaseServiceImpl<ScheduleJobDao, Sche
ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class); ScheduleJobEntity entity = ConvertUtils.sourceToTarget(dto, ScheduleJobEntity.class);
entity.setStatus(ScheduleStatusEnum.NORMAL.value()); entity.setStatus(ScheduleStatusEnum.NORMAL.value());
entity.setCreateDate(new Date());
this.insert(entity); this.insert(entity);
ScheduleUtils.createScheduleJob(scheduler, entity); ScheduleUtils.createScheduleJob(scheduler, entity);
@ -128,4 +130,104 @@ public class ScheduleJobServiceImpl extends BaseServiceImpl<ScheduleJobDao, Sche
updateBatch(ids, ScheduleStatusEnum.NORMAL.value()); updateBatch(ids, ScheduleStatusEnum.NORMAL.value());
} }
@Override
public PageData<ScheduleJobTypeDTO> pageByType(Map<String, Object> params) {
List<ScheduleJobTypeDTO> all = baseDao.selectAllJobs((String)params.get("beanName"));
//1 dim
//2 stats
//2.1 publicity : 2.1.1article (daily) 2.1.2tag : 2.1.2.1used(daily monthly QuarterlyAndYearly) 2.1.2.2viewed(daily monthly QuarterlyAndYearly)
//2.2 project (agency grid)
//2.3 issue
//2.4 group : 2.4.1 agency(daily monthly) : 2.4.2 grid(daily)
//2.5 topic
//2.6 user
//3 other
List<String> types = new LinkedList<>();
types.add("DIM");types.add("OTHER");types.add("USER");types.add("GROUP");types.add("TOPIC");types.add("PROJECT");
types.add("ISSUE");types.add("ARTICLE");types.add("TAGUSED");types.add("TAGVIEWED");
int otherOrder = 0;
for(ScheduleJobTypeDTO job : all){
if(job.getBeanName().toUpperCase().contains("DIM")){
job.setType("DIM");
job.setOrder(0);
}else if(job.getBeanName().toUpperCase().contains("TAGUSED")){
job.setType("TAGUSED");
if(job.getBeanName().toUpperCase().contains("DAILY")){
job.setOrder(0);
}else if(job.getBeanName().toUpperCase().contains("MONTHLY")){
job.setOrder(1);
}else{
job.setOrder(2);
}
}else if(job.getBeanName().toUpperCase().contains("TAGVIEWED")){
job.setType("TAGVIEWED");
if(job.getBeanName().toUpperCase().contains("DAILY")){
job.setOrder(0);
}else if(job.getBeanName().toUpperCase().contains("MONTHLY")){
job.setOrder(1);
}else{
job.setOrder(2);
}
}else if(job.getBeanName().toUpperCase().contains("PROJECT")){
job.setType("PROJECT");
if(job.getBeanName().toUpperCase().contains("AGENCY")){
job.setOrder(0);
}else{
job.setOrder(1);
}
}else if(job.getBeanName().toUpperCase().contains("ARTICLE")){
job.setType("ARTICLE");
job.setOrder(1);
}else if(job.getBeanName().toUpperCase().contains("ISSUE")){
job.setType("ISSUE");
job.setOrder(0);
}else if(job.getBeanName().toUpperCase().contains("GROUP")){
job.setType("GROUP");
if(job.getBeanName().toUpperCase().contains("AGENCY")){
if(job.getBeanName().toUpperCase().contains("DAILY")){
job.setOrder(0);
}else{
job.setOrder(1);
}
}else{
job.setOrder(2);
}
}else if(job.getBeanName().toUpperCase().contains("TOPIC")){
job.setType("TOPIC");
job.setOrder(0);
}else if(job.getBeanName().toUpperCase().contains("USER")){
job.setType("USER");
job.setOrder(0);
}else {
//other
job.setType("OTHER");
job.setOrder(otherOrder);
otherOrder++;
}
}
List<ScheduleJobTypeDTO> jobList = new LinkedList<>();
types.forEach(type -> {
jobList.addAll(
all.stream().filter(job -> StringUtils.equals(job.getType(),type)).sorted(Comparator.comparing(ScheduleJobTypeDTO :: getOrder)).collect(Collectors.toList()));
});
Integer page = null == params.get("page") ? 1 : Integer.parseInt((String)params.get("page"));
Integer limit = null == params.get("limit") ? 10 : Integer.parseInt((String)params.get("limit"));
Integer startIndex = (page - 1) * limit;
Integer endIndex = 0;
if(jobList.size() - (page -1) * limit <= limit){
endIndex = jobList.size() ;
}else{
endIndex = startIndex + limit ;
}
return new PageData(jobList.subList(startIndex,endIndex),all.size());
}
} }

9
epmet-module/epmet-job/epmet-job-server/src/main/resources/mapper/ScheduleJobDao.xml

@ -11,4 +11,13 @@
</foreach> </foreach>
</update> </update>
<select id="selectAllJobs" resultType="com.epmet.dto.ScheduleJobTypeDTO">
SELECT * FROM schedule_job
<where>
<if test='null != beanName and beanName != ""'>
BEAN_NAME LIKE CONCAT('%',#{beanName},'%')
</if>
</where>
</select>
</mapper> </mapper>

Loading…
Cancel
Save