|
@@ -2,7 +2,10 @@ package com.management.platform.task;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.*;
|
|
|
|
+import com.management.platform.entity.vo.TisTimeVO;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.mapper.*;
|
|
|
|
+import com.zaxxer.hikari.HikariConfig;
|
|
|
|
+import com.zaxxer.hikari.HikariDataSource;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.core.ParameterizedTypeReference;
|
|
import org.springframework.core.ParameterizedTypeReference;
|
|
import org.springframework.http.*;
|
|
import org.springframework.http.*;
|
|
@@ -14,10 +17,12 @@ import org.springframework.util.CollectionUtils;
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.sql.Connection;
|
|
|
|
+import java.sql.PreparedStatement;
|
|
|
|
+import java.sql.ResultSet;
|
|
|
|
+import java.sql.SQLException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@EnableScheduling
|
|
@EnableScheduling
|
|
@@ -49,6 +54,55 @@ public class DataCollectTask {
|
|
@Resource
|
|
@Resource
|
|
private BustripProjectMapper bustripProjectMapper;
|
|
private BustripProjectMapper bustripProjectMapper;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private ReportMapper reportMapper;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private static HikariDataSource sqlServerDataSource;
|
|
|
|
+
|
|
|
|
+ static {
|
|
|
|
+ HikariConfig sqlServerConfig = new HikariConfig();
|
|
|
|
+ sqlServerConfig.setJdbcUrl("jdbc:sqlserver://172.168.10.84:1433;databaseName=UFDATA_001_2023;encrypt=true;trustServerCertificate=true");
|
|
|
|
+ sqlServerConfig.setUsername("zhangyuhua");
|
|
|
|
+ sqlServerConfig.setPassword("ZC12zyh18");
|
|
|
|
+ sqlServerConfig.setMaximumPoolSize(5);
|
|
|
|
+ sqlServerDataSource = new HikariDataSource(sqlServerConfig);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public void caDayTisTask(){
|
|
|
|
+ SimpleDateFormat sdfYmd = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ String dateStr = sdfYmd.format(date);
|
|
|
|
+ List<TisTimeVO> timeVOList = reportMapper.getTisTimeByDate(specialCompanyId,dateStr);
|
|
|
|
+ for (TisTimeVO tisTimeVO : timeVOList) {
|
|
|
|
+ String sqlQuery = "select top 1 iRealCOID from ca_batchmap where cMOCode = ? and iMOSubSN = ? ";
|
|
|
|
+ try (Connection connection = sqlServerDataSource.getConnection()) {
|
|
|
|
+ PreparedStatement queryStmt = connection.prepareStatement(sqlQuery);
|
|
|
|
+ queryStmt.setString(1,tisTimeVO.getOrderId());
|
|
|
|
+ queryStmt.setInt(2,tisTimeVO.getLine());
|
|
|
|
+ ResultSet queryRs = queryStmt.executeQuery();
|
|
|
|
+ if (queryRs.next()) {
|
|
|
|
+ String iRealCOID = queryRs.getString("iRealCOID");
|
|
|
|
+ String sqlInsert = "insert into CA_DayTiS(cPPID,iRealWkt,dDate) values(?,?,?)";
|
|
|
|
+ PreparedStatement insertStmt = connection.prepareStatement(sqlInsert);
|
|
|
|
+ insertStmt.setString(1,iRealCOID);
|
|
|
|
+ insertStmt.setBigDecimal(2,tisTimeVO.getWorkTime());
|
|
|
|
+ insertStmt.setString(3,dateStr);
|
|
|
|
+ int i = insertStmt.executeUpdate();
|
|
|
|
+ if(i>0){
|
|
|
|
+ System.out.println("执行成功");
|
|
|
|
+ }else{
|
|
|
|
+ System.out.println(iRealCOID+"执行失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (SQLException e) {
|
|
|
|
+ System.err.println("数据库操作错误: " + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
@Scheduled(cron = "0 0 1 * * ?")
|
|
@Scheduled(cron = "0 0 1 * * ?")
|
|
@Async
|
|
@Async
|