|
@@ -4,8 +4,6 @@ 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 com.zaxxer.hikari.HikariConfig;
|
|
|
-import com.zaxxer.hikari.HikariDataSource;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.core.ParameterizedTypeReference;
|
|
|
import org.springframework.http.*;
|
|
@@ -17,10 +15,6 @@ import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-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;
|
|
@@ -61,50 +55,83 @@ public class DataCollectTask {
|
|
|
private FmwDetailMapper fmwDetailMapper;
|
|
|
|
|
|
|
|
|
- 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);
|
|
|
- }
|
|
|
+// 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(){
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ String insertUrl = PREFIX_URL+"/dataCollect/insertCisData";
|
|
|
SimpleDateFormat sdfYmd = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
Date date = new Date();
|
|
|
String dateStr = sdfYmd.format(date);
|
|
|
- //TODO fmwDetail修改,不从report里取
|
|
|
// List<TisTimeVO> timeVOList = fmwDetailMapper.getTisTimeByDate(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 = ? ";
|
|
|
- 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());
|
|
|
+
|
|
|
+// 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()) {
|
|
|
+// tisTimeVO.setCoId(queryRs.getString("iRealCOID"));
|
|
|
+//
|
|
|
+// }
|
|
|
+// } catch (SQLException e) {
|
|
|
+// 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 = ? ";
|
|
|
+// 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());
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
|