|
@@ -2,6 +2,7 @@ package com.management.platform.task;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.management.platform.entity.*;
|
|
|
+import com.management.platform.entity.vo.TisTimeVO;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -16,6 +17,7 @@ import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -68,11 +70,13 @@ public class DataCollectTask {
|
|
|
// sqlServerDataSource = new HikariDataSource(sqlServerConfig);
|
|
|
// }
|
|
|
|
|
|
-
|
|
|
+ @Scheduled(cron = "0 30 0 L * ?")
|
|
|
+ @Async
|
|
|
public void caDayTisTask(){
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
String insertUrl = PREFIX_URL+"/dataCollect/insertCisData";
|
|
|
- SimpleDateFormat sdfYmd = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String checkUrl = PREFIX_URL+"/dataCollect/checkCisData";
|
|
|
+// SimpleDateFormat sdfYmd = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
SimpleDateFormat sdfYm = new SimpleDateFormat("yyyy-MM");
|
|
|
Date date = new Date();
|
|
|
String dateYm = sdfYm.format(date);
|
|
@@ -83,29 +87,47 @@ public class DataCollectTask {
|
|
|
.eq(FinanceMonthlyWorktime::getStatus, 1)
|
|
|
);
|
|
|
if(!CollectionUtils.isEmpty(financeMonthlyWorktimes)){
|
|
|
-// for (FinanceMonthlyWorktime financeMonthlyWorktime : financeMonthlyWorktimes) {
|
|
|
-//// sdfYmd.format(financeMonthlyWorktime.get)
|
|
|
-// List<TisTimeVO> timeVOList = fmwDetailMapper.getTisTimeByDateYm(financeMonthlyWorktime.getId());
|
|
|
-// if(!CollectionUtils.isEmpty(timeVOList)){
|
|
|
-// timeVOList.forEach(t->t.setDateStr(dateStr));
|
|
|
-// HttpHeaders headers = new HttpHeaders();
|
|
|
-// headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
-// Map<String, Object> requestBody = new HashMap<>();
|
|
|
-// requestBody.put("tisList", timeVOList);
|
|
|
-// HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
|
|
|
-//
|
|
|
-// ResponseEntity<String> tisResponse = restTemplate.exchange(insertUrl, HttpMethod.POST, requestEntity, String.class);
|
|
|
-// if (tisResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
-// System.out.println("插入成功");
|
|
|
-// }else{
|
|
|
-// System.out.println(dateStr + "插入失败");
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
+ List<TisTimeVO> toSendList = new ArrayList<>();
|
|
|
+ for (FinanceMonthlyWorktime financeMonthlyWorktime : financeMonthlyWorktimes) {
|
|
|
+ String ymd = financeMonthlyWorktime.getTimesheetDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ List<TisTimeVO> timeVOList = fmwDetailMapper.getTisTimeByFmwId(financeMonthlyWorktime.getId());
|
|
|
+ if(!CollectionUtils.isEmpty(timeVOList)){
|
|
|
+ timeVOList.forEach(t->t.setDateStr(ymd));
|
|
|
+ toSendList.addAll(timeVOList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!CollectionUtils.isEmpty(toSendList)){
|
|
|
+ //校验cppid
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
+ Map<String, Object> requestBody = new HashMap<>();
|
|
|
+ requestBody.put("toSendList", toSendList);
|
|
|
+ HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
|
|
|
+ ResponseEntity<List<TisTimeVO>> checkResponse = restTemplate.exchange(checkUrl, HttpMethod.POST, requestEntity
|
|
|
+ ,new ParameterizedTypeReference<List<TisTimeVO>>(){});
|
|
|
+ if (checkResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
+ List<TisTimeVO> resList = checkResponse.getBody();
|
|
|
+ List<TisTimeVO> tmpCheck = resList.stream().filter(t -> null != t.getCoId()).collect(Collectors.toList());
|
|
|
+ if(tmpCheck.size() == resList.size()){
|
|
|
+ //执行插入操作
|
|
|
+ HttpHeaders insertHeaders = new HttpHeaders();
|
|
|
+ insertHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
+ Map<String, Object> insertBody = new HashMap<>();
|
|
|
+ insertBody.put("tisList", resList);
|
|
|
+ HttpEntity<Object> insertEntity = new HttpEntity<>(insertBody, insertHeaders);
|
|
|
+ ResponseEntity<String> tisResponse = restTemplate.exchange(insertUrl, HttpMethod.POST, insertEntity, String.class);
|
|
|
+ if (tisResponse.getStatusCode() == HttpStatus.OK) {
|
|
|
+ System.out.println("插入成功");
|
|
|
+ }else{
|
|
|
+ System.out.println("插入失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
- String dateStr = sdfYmd.format(date);
|
|
|
// List<TisTimeVO> timeVOList = fmwDetailMapper.getTisTimeByDateYm(specialCompanyId,dateStr);
|
|
|
// List<TisTimeVO> timeVOList = reportMapper.getTisTimeByDate(specialCompanyId,dateStr);
|
|
|
|