|
@@ -10,6 +10,7 @@ import com.management.platform.service.TaskService;
|
|
import com.management.platform.util.MessageUtils;
|
|
import com.management.platform.util.MessageUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.core.ParameterizedTypeReference;
|
|
import org.springframework.core.ParameterizedTypeReference;
|
|
import org.springframework.http.*;
|
|
import org.springframework.http.*;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
@@ -30,6 +31,9 @@ import java.util.stream.Collectors;
|
|
@Component
|
|
@Component
|
|
public class DataCollectTask {
|
|
public class DataCollectTask {
|
|
|
|
|
|
|
|
+ @Value("${configEnv.isDev}")
|
|
|
|
+ public boolean isDev;
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private UserFvTimeMapper userFvTimeMapper;
|
|
private UserFvTimeMapper userFvTimeMapper;
|
|
@Resource
|
|
@Resource
|
|
@@ -80,6 +84,7 @@ public class DataCollectTask {
|
|
@Scheduled(cron = "0 30 0 28-31 * ?")
|
|
@Scheduled(cron = "0 30 0 28-31 * ?")
|
|
@Async
|
|
@Async
|
|
public void caDayTisTask(){
|
|
public void caDayTisTask(){
|
|
|
|
+ if(isDev){return;}
|
|
LocalDate nowDate = LocalDate.now();
|
|
LocalDate nowDate = LocalDate.now();
|
|
int today = nowDate.getMonthValue();
|
|
int today = nowDate.getMonthValue();
|
|
int lastDay = Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH);
|
|
int lastDay = Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH);
|
|
@@ -190,8 +195,10 @@ public class DataCollectTask {
|
|
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 0 1 * * ?")
|
|
@Scheduled(cron = "0 0 1 * * ?")
|
|
|
|
+// @Scheduled(cron = "0 05 16 * * ?")
|
|
@Async
|
|
@Async
|
|
public void sqlServerTask() {
|
|
public void sqlServerTask() {
|
|
|
|
+ if(isDev){return;}
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getSqlServerDataSum";
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getSqlServerDataSum";
|
|
String listUrl = PREFIX_URL+"/dataCollect/getSqlServerDataList";
|
|
String listUrl = PREFIX_URL+"/dataCollect/getSqlServerDataList";
|
|
@@ -262,7 +269,9 @@ public class DataCollectTask {
|
|
}
|
|
}
|
|
|
|
|
|
@Scheduled(cron = "0 30 1 * * ?")
|
|
@Scheduled(cron = "0 30 1 * * ?")
|
|
|
|
+//@Scheduled(cron = "0 33 16 * * ?")
|
|
public void workDayTask(){
|
|
public void workDayTask(){
|
|
|
|
+ if(isDev){return;}
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getWorkDayDataSum";
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getWorkDayDataSum";
|
|
String listUrl = PREFIX_URL+"/dataCollect/getWorkDayDataList";
|
|
String listUrl = PREFIX_URL+"/dataCollect/getWorkDayDataList";
|
|
@@ -305,18 +314,24 @@ public class DataCollectTask {
|
|
List<UserFvTime> dataList = listResponse.getBody();
|
|
List<UserFvTime> dataList = listResponse.getBody();
|
|
if(org.apache.commons.collections.CollectionUtils.isNotEmpty(dataList)){
|
|
if(org.apache.commons.collections.CollectionUtils.isNotEmpty(dataList)){
|
|
for (UserFvTime userFvTime : dataList) {
|
|
for (UserFvTime userFvTime : dataList) {
|
|
|
|
+ if(StringUtils.isBlank(userFvTime.getProcinstId())){
|
|
|
|
+ System.out.println(userFvTime);
|
|
|
|
+ }
|
|
User tmp = userMap.get(userFvTime.getUserId());
|
|
User tmp = userMap.get(userFvTime.getUserId());
|
|
|
|
+ if(null == tmp){
|
|
|
|
+ System.out.println("缺失id=== "+userFvTime.getUserId()+",缺失名字=== "+userFvTime.getName());
|
|
|
|
+ }
|
|
userFvTime.setUserId(null==tmp?null:tmp.getId());
|
|
userFvTime.setUserId(null==tmp?null:tmp.getId());
|
|
}
|
|
}
|
|
- List<UserFvTime> realDataList = dataList.stream().filter(t -> null != t.getUserId()).collect(Collectors.toList());
|
|
|
|
|
|
+ List<UserFvTime> realDataList = dataList.stream().filter(t -> StringUtils.isNotBlank(t.getUserId())).collect(Collectors.toList());
|
|
if(!CollectionUtils.isEmpty(realDataList)){
|
|
if(!CollectionUtils.isEmpty(realDataList)){
|
|
- List<String> collect = dataList.stream().map(UserFvTime::getProcinstId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
+ List<String> collect = realDataList.stream().map(UserFvTime::getProcinstId).distinct().collect(Collectors.toList());
|
|
List<String> existIds = userFvTimeMapper.getExistIds(collect,specialCompanyId);
|
|
List<String> existIds = userFvTimeMapper.getExistIds(collect,specialCompanyId);
|
|
if(!CollectionUtils.isEmpty(existIds)){
|
|
if(!CollectionUtils.isEmpty(existIds)){
|
|
- toUpdateList.addAll(dataList.stream().filter(t -> existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
|
- toAddList.addAll(dataList.stream().filter(t -> !existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
|
|
|
+ toUpdateList.addAll(realDataList.stream().filter(t -> existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
|
+ toAddList.addAll(realDataList.stream().filter(t -> !existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
}else{
|
|
}else{
|
|
- toAddList.addAll(dataList);
|
|
|
|
|
|
+ toAddList.addAll(realDataList);
|
|
}
|
|
}
|
|
if(!CollectionUtils.isEmpty(toAddList)){
|
|
if(!CollectionUtils.isEmpty(toAddList)){
|
|
userFvTimeMapper.batchInsertCollect(toAddList);
|
|
userFvTimeMapper.batchInsertCollect(toAddList);
|
|
@@ -342,8 +357,10 @@ public class DataCollectTask {
|
|
}
|
|
}
|
|
|
|
|
|
@Scheduled(cron = "0 0 2 * * ?")
|
|
@Scheduled(cron = "0 0 2 * * ?")
|
|
|
|
+//@Scheduled(cron = "0 43 16 * * ?")
|
|
@Async
|
|
@Async
|
|
public void leaveSheetTask(){
|
|
public void leaveSheetTask(){
|
|
|
|
+ if(isDev){return;}
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
String sumUrl = PREFIX_URL + "/dataCollect/getLeaveSheetDataSum";
|
|
String sumUrl = PREFIX_URL + "/dataCollect/getLeaveSheetDataSum";
|
|
String listUrl = PREFIX_URL + "/dataCollect/getLeaveSheetDataList";
|
|
String listUrl = PREFIX_URL + "/dataCollect/getLeaveSheetDataList";
|
|
@@ -390,23 +407,31 @@ public class DataCollectTask {
|
|
User opTmp = userMap.get(leaveSheet.getOperatorId());
|
|
User opTmp = userMap.get(leaveSheet.getOperatorId());
|
|
leaveSheet.setOwnerId(null==ownerTmp?null:ownerTmp.getId());
|
|
leaveSheet.setOwnerId(null==ownerTmp?null:ownerTmp.getId());
|
|
leaveSheet.setOperatorId(null==opTmp?null:opTmp.getId());
|
|
leaveSheet.setOperatorId(null==opTmp?null:opTmp.getId());
|
|
|
|
+ if(null != ownerTmp && null == opTmp){
|
|
|
|
+ leaveSheet.setOperatorId(ownerTmp.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
- List<String> collect = dataList.stream().map(LeaveSheet::getProcinstId).distinct().collect(Collectors.toList());
|
|
|
|
- List<String> existIds = leaveSheetMapper.getExistIds(collect,specialCompanyId);
|
|
|
|
- if(!CollectionUtils.isEmpty(existIds)){
|
|
|
|
- toUpdateList.addAll(dataList.stream().filter(t -> existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
|
- toAddList.addAll(dataList.stream().filter(t -> !existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
|
- }else{
|
|
|
|
- toAddList.addAll(dataList);
|
|
|
|
- }
|
|
|
|
- if(!CollectionUtils.isEmpty(toAddList)){
|
|
|
|
- leaveSheetMapper.batchInsert(toAddList);
|
|
|
|
- }
|
|
|
|
- if(!CollectionUtils.isEmpty(toUpdateList)){
|
|
|
|
- for (LeaveSheet tmp : toUpdateList) {
|
|
|
|
- leaveSheetMapper.updateById(tmp);
|
|
|
|
|
|
+ List<LeaveSheet> realDataList = dataList.stream().filter(t -> StringUtils.isNotBlank(t.getOwnerId())).collect(Collectors.toList());
|
|
|
|
+ if(!CollectionUtils.isEmpty(realDataList)){
|
|
|
|
+ List<String> collect = realDataList.stream().map(LeaveSheet::getProcinstId).distinct().collect(Collectors.toList());
|
|
|
|
+ List<String> existIds = leaveSheetMapper.getExistIds(collect,specialCompanyId);
|
|
|
|
+ if(!CollectionUtils.isEmpty(existIds)){
|
|
|
|
+ toUpdateList.addAll(realDataList.stream().filter(t -> existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
|
+ toAddList.addAll(realDataList.stream().filter(t -> !existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
|
+ }else{
|
|
|
|
+ toAddList.addAll(realDataList);
|
|
|
|
+ }
|
|
|
|
+ if(!CollectionUtils.isEmpty(toAddList)){
|
|
|
|
+ leaveSheetMapper.batchInsert(toAddList);
|
|
|
|
+ }
|
|
|
|
+ if(!CollectionUtils.isEmpty(toUpdateList)){
|
|
|
|
+ for (LeaveSheet tmp : toUpdateList) {
|
|
|
|
+ leaveSheetMapper.updateById(tmp);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
toUpdateList.clear();
|
|
toUpdateList.clear();
|
|
toAddList.clear();
|
|
toAddList.clear();
|
|
}
|
|
}
|
|
@@ -422,8 +447,10 @@ public class DataCollectTask {
|
|
}
|
|
}
|
|
|
|
|
|
@Scheduled(cron = "0 30 2 * * ?")
|
|
@Scheduled(cron = "0 30 2 * * ?")
|
|
|
|
+//@Scheduled(cron = "0 46 16 * * ?")
|
|
@Async
|
|
@Async
|
|
public void sqlServerProjectTypeTask() {
|
|
public void sqlServerProjectTypeTask() {
|
|
|
|
+ if(isDev){return;}
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectTypeDataSum";
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectTypeDataSum";
|
|
String listUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectTypeDataList";
|
|
String listUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectTypeDataList";
|
|
@@ -505,8 +532,10 @@ public class DataCollectTask {
|
|
}
|
|
}
|
|
|
|
|
|
@Scheduled(cron = "0 0 3 * * ?")
|
|
@Scheduled(cron = "0 0 3 * * ?")
|
|
|
|
+//@Scheduled(cron = "0 48 16 * * ?")
|
|
@Async
|
|
@Async
|
|
public void sqlServerProjectTask() {
|
|
public void sqlServerProjectTask() {
|
|
|
|
+ if(isDev){return;}
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectDataSum";
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectDataSum";
|
|
String listUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectDataList";
|
|
String listUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectDataList";
|
|
@@ -655,8 +684,10 @@ public class DataCollectTask {
|
|
}
|
|
}
|
|
|
|
|
|
@Scheduled(cron = "0 30 3 * * ?")
|
|
@Scheduled(cron = "0 30 3 * * ?")
|
|
|
|
+//@Scheduled(cron = "0 20 17 * * ?")
|
|
@Async
|
|
@Async
|
|
public void businessTripTask(){
|
|
public void businessTripTask(){
|
|
|
|
+ if(isDev){return;}
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getBusinessTripDataSum";
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getBusinessTripDataSum";
|
|
String listUrl = PREFIX_URL+"/dataCollect/getBusinessTripDataList";
|
|
String listUrl = PREFIX_URL+"/dataCollect/getBusinessTripDataList";
|
|
@@ -704,32 +735,36 @@ public class DataCollectTask {
|
|
User ownerTmp = userMap.get(businessTrip.getOwnerId());
|
|
User ownerTmp = userMap.get(businessTrip.getOwnerId());
|
|
businessTrip.setOwnerId(null==ownerTmp?null:ownerTmp.getId());
|
|
businessTrip.setOwnerId(null==ownerTmp?null:ownerTmp.getId());
|
|
}
|
|
}
|
|
- List<String> collect = dataList.stream().map(BusinessTrip::getProcinstId).distinct().collect(Collectors.toList());
|
|
|
|
- List<String> existIds = businessTripMapper.getExistIds(collect,specialCompanyId);
|
|
|
|
- if(!CollectionUtils.isEmpty(existIds)){
|
|
|
|
- toUpdateList.addAll(dataList.stream().filter(t -> existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
|
- toAddList.addAll(dataList.stream().filter(t -> !existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
|
- }else{
|
|
|
|
- toAddList.addAll(dataList);
|
|
|
|
- }
|
|
|
|
- if(!CollectionUtils.isEmpty(toAddList)){
|
|
|
|
|
|
+ List<BusinessTrip> realDataList = dataList.stream().filter(t -> StringUtils.isNotBlank(t.getOwnerId())).collect(Collectors.toList());
|
|
|
|
+ if(!CollectionUtils.isEmpty(realDataList)){
|
|
|
|
+ List<String> collect = realDataList.stream().map(BusinessTrip::getProcinstId).distinct().collect(Collectors.toList());
|
|
|
|
+ List<String> existIds = businessTripMapper.getExistIds(collect,specialCompanyId);
|
|
|
|
+ if(!CollectionUtils.isEmpty(existIds)){
|
|
|
|
+ toUpdateList.addAll(realDataList.stream().filter(t -> existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
|
+ toAddList.addAll(realDataList.stream().filter(t -> !existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
|
+ }else{
|
|
|
|
+ toAddList.addAll(realDataList);
|
|
|
|
+ }
|
|
|
|
+ if(!CollectionUtils.isEmpty(toAddList)){
|
|
// businessTripMapper.batchInsert(toAddList);
|
|
// businessTripMapper.batchInsert(toAddList);
|
|
- for (BusinessTrip businessTrip : toAddList) {
|
|
|
|
- businessTripMapper.insert(businessTrip);
|
|
|
|
- BustripProject bustripProject = new BustripProject();
|
|
|
|
- bustripProject.setBustripId(businessTrip.getId());
|
|
|
|
- Project project = projectCodeMap.get(businessTrip.getCCcxmNo());
|
|
|
|
- bustripProject.setProjectId(null == project?null:project.getId());
|
|
|
|
- bustripProject.setStartDate(businessTrip.getStartDate());
|
|
|
|
- bustripProject.setEndDate(businessTrip.getEndDate());
|
|
|
|
- bustripProjectMapper.insert(bustripProject);
|
|
|
|
|
|
+ for (BusinessTrip businessTrip : toAddList) {
|
|
|
|
+ businessTripMapper.insert(businessTrip);
|
|
|
|
+ BustripProject bustripProject = new BustripProject();
|
|
|
|
+ bustripProject.setBustripId(businessTrip.getId());
|
|
|
|
+ Project project = projectCodeMap.get(businessTrip.getCCcxmNo());
|
|
|
|
+ bustripProject.setProjectId(null == project?null:project.getId());
|
|
|
|
+ bustripProject.setStartDate(businessTrip.getStartDate());
|
|
|
|
+ bustripProject.setEndDate(businessTrip.getEndDate());
|
|
|
|
+ bustripProjectMapper.insert(bustripProject);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if(!CollectionUtils.isEmpty(toUpdateList)){
|
|
|
|
- for (BusinessTrip tmp : toUpdateList) {
|
|
|
|
- businessTripMapper.updateById(tmp);
|
|
|
|
|
|
+ if(!CollectionUtils.isEmpty(toUpdateList)){
|
|
|
|
+ for (BusinessTrip tmp : toUpdateList) {
|
|
|
|
+ businessTripMapper.updateById(tmp);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
toUpdateList.clear();
|
|
toUpdateList.clear();
|
|
toAddList.clear();
|
|
toAddList.clear();
|
|
}
|
|
}
|