|
@@ -35,7 +35,9 @@ public class DataCollectTask {
|
|
|
|
|
|
@Value("${configEnv.isDev}")
|
|
|
public boolean isDev;
|
|
|
-
|
|
|
+ //是否是私有化部署
|
|
|
+ @Value("${configEnv.isPrivateDeploy}")
|
|
|
+ boolean isPrivateDeploy;
|
|
|
@Resource
|
|
|
private UserFvTimeMapper userFvTimeMapper;
|
|
|
@Resource
|
|
@@ -93,6 +95,7 @@ public class DataCollectTask {
|
|
|
@Async
|
|
|
public void caDayTisTask(){
|
|
|
if(isDev){return;}
|
|
|
+ if(isPrivateDeploy) return;
|
|
|
LocalDate nowDate = LocalDate.now();
|
|
|
int today = nowDate.getMonthValue();
|
|
|
int lastDay = Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH);
|
|
@@ -207,6 +210,7 @@ public class DataCollectTask {
|
|
|
@Async
|
|
|
public void sqlServerTask() {
|
|
|
if(isDev){return;}
|
|
|
+ if(isPrivateDeploy) return;
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getSqlServerDataSum";
|
|
|
String listUrl = PREFIX_URL+"/dataCollect/getSqlServerDataList";
|
|
@@ -291,6 +295,7 @@ public class DataCollectTask {
|
|
|
//@Scheduled(cron = "0 42 16 * * ?")
|
|
|
public void workDayTask(){
|
|
|
if(isDev){return;}
|
|
|
+ if(isPrivateDeploy) return;
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getWorkDayDataSum";
|
|
|
String listUrl = PREFIX_URL+"/dataCollect/getWorkDayDataList";
|
|
@@ -383,6 +388,7 @@ public class DataCollectTask {
|
|
|
@Async
|
|
|
public void leaveSheetTask(){
|
|
|
if(isDev){return;}
|
|
|
+ if(isPrivateDeploy) return;
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
String sumUrl = PREFIX_URL + "/dataCollect/getLeaveSheetDataSum";
|
|
|
String listUrl = PREFIX_URL + "/dataCollect/getLeaveSheetDataList";
|
|
@@ -552,96 +558,12 @@ public class DataCollectTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// @Scheduled(cron = "0 30 2 * * ?")
|
|
|
-//@Scheduled(cron = "0 46 15 * * ?")
|
|
|
-// @Async
|
|
|
- public void sqlServerProjectTypeTask() {
|
|
|
- if(isDev){return;}
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- String sumUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectTypeDataSum";
|
|
|
- String listUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectTypeDataList";
|
|
|
-
|
|
|
- try {
|
|
|
- ResponseEntity<String> sumResponse = restTemplate.exchange(
|
|
|
- sumUrl,
|
|
|
- HttpMethod.GET,
|
|
|
- null,
|
|
|
- String.class
|
|
|
- );
|
|
|
- Integer totalNum = 0;
|
|
|
- if (sumResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- totalNum = Integer.parseInt(sumResponse.getBody());
|
|
|
- } else {
|
|
|
- System.out.println("请求失败,状态码: " + sumResponse.getStatusCode());
|
|
|
- }
|
|
|
- if(totalNum > 0){
|
|
|
- int pageSize = 1000;
|
|
|
- int offset = 0;
|
|
|
- List<ProjectCategory> toAddList = new ArrayList<>();
|
|
|
- List<ProjectCategory> toUpdateList = new ArrayList<>();
|
|
|
- while (offset < totalNum) {
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- Map<String, Object> requestBody = new HashMap<>();
|
|
|
- requestBody.put("pageNo", offset);
|
|
|
- requestBody.put("pageSize", pageSize);
|
|
|
- HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
|
|
|
- ResponseEntity<List<String>> listResponse = restTemplate.exchange(
|
|
|
- listUrl,
|
|
|
- HttpMethod.POST,
|
|
|
- requestEntity,
|
|
|
- new ParameterizedTypeReference<List<String>>(){}
|
|
|
- );
|
|
|
- if (listResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
- List<String> dataList = listResponse.getBody();
|
|
|
- List<ProjectCategory> tmpList = new ArrayList<>();
|
|
|
- if(org.apache.commons.collections.CollectionUtils.isNotEmpty(dataList)){
|
|
|
- List<String> existIds = projectCategoryMapper.getExistIds(dataList,specialCompanyId);
|
|
|
- if(!CollectionUtils.isEmpty(existIds)){
|
|
|
- for (String name : dataList) {
|
|
|
- ProjectCategory tmp = new ProjectCategory();
|
|
|
- tmp.setName(name);
|
|
|
- tmp.setCompanyId(specialCompanyId);
|
|
|
- tmpList.add(tmp);
|
|
|
- }
|
|
|
- toUpdateList.addAll(tmpList.stream().filter(t -> existIds.contains(t.getName())).collect(Collectors.toList()));
|
|
|
- toAddList.addAll(tmpList.stream().filter(t -> !existIds.contains(t.getName())).collect(Collectors.toList()));
|
|
|
- }else{
|
|
|
- for (String name : dataList) {
|
|
|
- ProjectCategory tmp = new ProjectCategory();
|
|
|
- tmp.setName(name);
|
|
|
- tmp.setCompanyId(specialCompanyId);
|
|
|
- tmpList.add(tmp);
|
|
|
- }
|
|
|
- toAddList.addAll(tmpList);
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(toAddList)){
|
|
|
- projectCategoryMapper.batchInsert(toAddList);
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(toUpdateList)){
|
|
|
- for (ProjectCategory projectCategory : toUpdateList) {
|
|
|
- projectCategoryMapper.updateById(projectCategory);
|
|
|
- }
|
|
|
- }
|
|
|
- toUpdateList.clear();
|
|
|
- toAddList.clear();
|
|
|
- }
|
|
|
- }
|
|
|
- offset += pageSize;
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- System.out.println("请求发生异常: " + e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
@Scheduled(cron = "0 30 3 * * ?")
|
|
|
//@Scheduled(cron = "0 12 16 * * ?")
|
|
|
@Async
|
|
|
public void sqlServerProjectTask() {
|
|
|
if(isDev){return;}
|
|
|
+ if(isPrivateDeploy) return;
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectDataSum";
|
|
|
String listUrl = PREFIX_URL+"/dataCollect/getSqlServerProjectDataList";
|
|
@@ -816,6 +738,7 @@ public class DataCollectTask {
|
|
|
@Async
|
|
|
public void businessTripTask(){
|
|
|
if(isDev){return;}
|
|
|
+ if(isPrivateDeploy) return;
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
String sumUrl = PREFIX_URL+"/dataCollect/getBusinessTripDataSum";
|
|
|
String listUrl = PREFIX_URL+"/dataCollect/getBusinessTripDataList";
|