Quellcode durchsuchen

定时拉取数据修改

zhouyy vor 3 Wochen
Ursprung
Commit
d7db1ddcb7

+ 34 - 15
fhKeeper/formulahousekeeper/collectdata/src/main/java/com/management/collectdata/controller/DataCollectController.java

@@ -68,9 +68,9 @@ public class DataCollectController {
 //    private ErpOrderInfoMapper erpOrderInfoMapper;
 
     @RequestMapping("/checkCisData")
-    public List<TisTimeVO> checkCisData(@RequestBody List<TisTimeVO> tisList) {
-        if(!CollectionUtils.isEmpty(tisList)){
-            for (TisTimeVO tisTimeVO : tisList) {
+    public List<TisTimeVO> checkCisData(@RequestBody List<TisTimeVO> toSendList) {
+        if(!CollectionUtils.isEmpty(toSendList)){
+            for (TisTimeVO tisTimeVO : toSendList) {
                 String sqlQuery = "select top 1 iRealCOID from ca_batchmap where cMOCode = ? and iMOSubSN = ? ";
                 try (Connection connection = sqlServerDataSource.getConnection()) {
                     PreparedStatement queryStmt = connection.prepareStatement(sqlQuery);
@@ -85,32 +85,51 @@ public class DataCollectController {
                 }
             }
         }
-        return tisList;
+        return toSendList;
     }
 
     @RequestMapping("/insertCisData")
     public String insertCisData(@RequestBody List<TisTimeVO> tisList) {
         if(!CollectionUtils.isEmpty(tisList)){
-            int count = 0;
+            int insertCount = 0;
+            int updateCount = 0;
             for (TisTimeVO tisTimeVO : tisList) {
+                String sqlQuery = "select count(*) from CA_DayTiS where cPPID = ? and dDate = ? ";
                 String sqlInsert = "insert into CA_DayTiS(cPPID,iRealWkt,dDate) values(?,?,?)";
+                String sqlUpdate = "update CA_DayTiS set iRealWkt = ? where cPPID = ? and dDate = ? ";
                 try (Connection connection = sqlServerDataSource.getConnection()) {
-                    PreparedStatement insertStmt = connection.prepareStatement(sqlInsert);
-                    insertStmt.setString(1,tisTimeVO.getCoId());
-                    insertStmt.setBigDecimal(2,tisTimeVO.getWorkTime());
-                    insertStmt.setString(3,tisTimeVO.getDateStr());
-                    int i = insertStmt.executeUpdate();
-                    if(i>0){
-                        count++;
-//                        System.out.println("执行成功");
+                    PreparedStatement queryStmt = connection.prepareStatement(sqlQuery);
+                    queryStmt.setString(1, tisTimeVO.getCoId());
+                    queryStmt.setString(2, tisTimeVO.getDateStr());
+                    ResultSet queryRs = queryStmt.executeQuery();
+                    if(queryRs.next() && queryRs.getInt(1) > 0){
+                        //更新
+                        PreparedStatement updateStmt = connection.prepareStatement(sqlUpdate);
+                        queryStmt.setString(1, tisTimeVO.getCoId());
+                        queryStmt.setString(2, tisTimeVO.getDateStr());
+                        int i = updateStmt.executeUpdate();
+                        if(i>0){
+                            updateCount++;
+                        }else{
+                            System.out.println(tisTimeVO.getCoId()+"执行失败");
+                        }
                     }else{
-                        System.out.println(tisTimeVO.getCoId()+"执行失败");
+                        PreparedStatement insertStmt = connection.prepareStatement(sqlInsert);
+                        insertStmt.setString(1,tisTimeVO.getCoId());
+                        insertStmt.setBigDecimal(2,tisTimeVO.getWorkTime());
+                        insertStmt.setString(3,tisTimeVO.getDateStr());
+                        int i = insertStmt.executeUpdate();
+                        if(i>0){
+                            insertCount++;
+                        }else{
+                            System.out.println(tisTimeVO.getCoId()+"执行失败");
+                        }
                     }
                 } catch (SQLException e) {
                     System.err.println("数据库操作错误: " + e.getMessage());
                 }
             }
-            System.out.println("本批次总数量:"+tisList.size()+",成功插入条数:"+count);
+            System.out.println("本批次总数量:"+tisList.size()+",成功插入条数:"+insertCount+",成功更新条数:"+updateCount);
         }
 //        List<TisTimeVO> tisTimeVOS = JSONArray.parseArray(jsonarray, TisTimeVO.class);
 //        if(!CollectionUtils.isEmpty(tisList)){

+ 6 - 0
fhKeeper/formulahousekeeper/management-platform/pom.xml

@@ -15,6 +15,12 @@
 
     <dependencies>
 
+        <dependency>
+            <groupId>com.github.wechatpay-apiv3</groupId>
+            <artifactId>wechatpay-java</artifactId>
+            <version>0.2.17</version>
+        </dependency>
+
         <dependency>
             <groupId>com.microsoft.sqlserver</groupId>
             <artifactId>mssql-jdbc</artifactId>

+ 8 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceMonthlyWorktimeServiceImpl.java

@@ -88,9 +88,10 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
         if(!CollectionUtils.isEmpty(timeVOList)){
             HttpHeaders headers = new HttpHeaders();
             headers.setContentType(MediaType.APPLICATION_JSON);
-            Map<String, Object> requestBody = new HashMap<>();
-            requestBody.put("toSendList", timeVOList);
-            HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
+//            Map<String, Object> requestBody = new HashMap<>();
+//            requestBody.put("tisList", timeVOList);
+//            HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
+            HttpEntity<List<TisTimeVO>> requestEntity = new HttpEntity<>(timeVOList, headers);
             ResponseEntity<List<TisTimeVO>> checkResponse = restTemplate.exchange(checkUrl, HttpMethod.POST, requestEntity
                     ,new  ParameterizedTypeReference<List<TisTimeVO>>(){});
             if(checkResponse.getStatusCode() == HttpStatus.OK){
@@ -103,9 +104,10 @@ public class FinanceMonthlyWorktimeServiceImpl extends ServiceImpl<FinanceMonthl
                 timeVOList.forEach(t->t.setDateStr(timesheetDate));
                 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);
+//                Map<String, Object> insertBody = new HashMap<>();
+//                insertBody.put("tisList", resList);
+//                HttpEntity<Object> insertEntity = new HttpEntity<>(insertBody, insertHeaders);
+                HttpEntity<List<TisTimeVO>> insertEntity = new HttpEntity<>(resList, headers);
                 ResponseEntity<String> tisResponse = restTemplate.exchange(insertUrl, HttpMethod.POST, insertEntity, String.class);
                 if (tisResponse.getStatusCode() == HttpStatus.OK) {
                     System.out.println("插入成功");