|
|
@ -16,6 +16,7 @@ import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.dao.ScheduleJobDao; |
|
|
|
import com.epmet.dto.ScheduleJobDTO; |
|
|
|
import com.epmet.dto.ScheduleJobTypeDTO; |
|
|
|
import com.epmet.entity.ScheduleJobEntity; |
|
|
|
import com.epmet.enums.ScheduleStatusEnum; |
|
|
|
import com.epmet.service.ScheduleJobService; |
|
|
@ -26,9 +27,9 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
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); |
|
|
|
|
|
|
|
entity.setStatus(ScheduleStatusEnum.NORMAL.value()); |
|
|
|
entity.setCreateDate(new Date()); |
|
|
|
this.insert(entity); |
|
|
|
|
|
|
|
ScheduleUtils.createScheduleJob(scheduler, entity); |
|
|
@ -128,4 +130,104 @@ public class ScheduleJobServiceImpl extends BaseServiceImpl<ScheduleJobDao, Sche |
|
|
|
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()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|