|
@@ -5,6 +5,7 @@ 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;
|
|
|
import org.springframework.core.ParameterizedTypeReference;
|
|
|
import org.springframework.http.*;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
@@ -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;
|
|
|
|
|
@@ -39,7 +41,7 @@ public class DataCollectTask {
|
|
|
@Resource
|
|
|
private ProjectCategoryMapper projectCategoryMapper;
|
|
|
|
|
|
- private static final String PREFIX_URL = "http://58.210.104.138:10020";
|
|
|
+ public static final String PREFIX_URL = "http://58.210.104.138:10020";
|
|
|
|
|
|
private static final int specialCompanyId = 7536;
|
|
|
|
|
@@ -53,6 +55,8 @@ public class DataCollectTask {
|
|
|
|
|
|
@Resource
|
|
|
private FmwDetailMapper fmwDetailMapper;
|
|
|
+ @Autowired
|
|
|
+ private FinanceMonthlyWorktimeMapper financeMonthlyWorktimeMapper;
|
|
|
|
|
|
|
|
|
// private static HikariDataSource sqlServerDataSource;
|
|
@@ -66,15 +70,66 @@ 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 dateStr = sdfYmd.format(date);
|
|
|
-// List<TisTimeVO> timeVOList = fmwDetailMapper.getTisTimeByDate(specialCompanyId,dateStr);
|
|
|
- List<TisTimeVO> timeVOList = reportMapper.getTisTimeByDate(specialCompanyId,dateStr);
|
|
|
+ String dateYm = sdfYm.format(date);
|
|
|
+
|
|
|
+ List<FinanceMonthlyWorktime> financeMonthlyWorktimes = financeMonthlyWorktimeMapper.selectList(new LambdaQueryWrapper<FinanceMonthlyWorktime>()
|
|
|
+ .eq(FinanceMonthlyWorktime::getCompanyId, specialCompanyId)
|
|
|
+ .eq(FinanceMonthlyWorktime::getYmonth, dateYm)
|
|
|
+ .eq(FinanceMonthlyWorktime::getStatus, 1)
|
|
|
+ );
|
|
|
+ if(!CollectionUtils.isEmpty(financeMonthlyWorktimes)){
|
|
|
+ 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("插入失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+// List<TisTimeVO> timeVOList = fmwDetailMapper.getTisTimeByDateYm(specialCompanyId,dateStr);
|
|
|
+// List<TisTimeVO> timeVOList = reportMapper.getTisTimeByDate(specialCompanyId,dateStr);
|
|
|
|
|
|
// for (TisTimeVO tisTimeVO : timeVOList) {
|
|
|
// String sqlQuery = "select top 1 iRealCOID from ca_batchmap where cMOCode = ? and iMOSubSN = ? ";
|
|
@@ -91,21 +146,6 @@ public class DataCollectTask {
|
|
|
// System.err.println("数据库操作错误: " + e.getMessage());
|
|
|
// }
|
|
|
// }
|
|
|
- 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 + "插入失败");
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
// for (TisTimeVO tisTimeVO : timeVOList) {
|
|
|
// String sqlQuery = "select top 1 iRealCOID from ca_batchmap where cMOCode = ? and iMOSubSN = ? ";
|