xsr пре 1 недеља
родитељ
комит
00da73ddb2

+ 1 - 1
src/main/java/com/gct/tools/etlcamelhuge/MQ/DiagnoseMessageProducer.java

@@ -49,7 +49,7 @@ public class DiagnoseMessageProducer implements MessageProducer {
49 49
             return;
50 50
         }
51 51
         DiagnoseMsg actualMsg = (DiagnoseMsg) msgBody;
52
-        System.out.println(properties);
52
+//        System.out.println(properties);
53 53
         Message msg = new Message(properties.getTopic(), properties.getTags(), actualMsg.getWellId(), JSONObject.toJSONString(actualMsg).getBytes(StandardCharsets.UTF_8));
54 54
         sendDefault(producer, msg, (MessageBody) actualMsg, failCallBack, successCallBack,0);
55 55
     }

+ 11 - 7
src/main/java/com/gct/tools/etlcamelhuge/quartz/SyncWellSourceTask.java

@@ -4,6 +4,7 @@ import org.quartz.JobExecutionContext;
4 4
 import org.quartz.JobExecutionException;
5 5
 import org.springframework.jdbc.core.JdbcTemplate;
6 6
 import org.springframework.scheduling.quartz.QuartzJobBean;
7
+import org.springframework.transaction.annotation.Transactional;
7 8
 
8 9
 import javax.annotation.Resource;
9 10
 import javax.sql.DataSource;
@@ -20,7 +21,8 @@ public class SyncWellSourceTask extends QuartzJobBean {
20 21
     @Resource(name = "centralbase")
21 22
     DataSource centralbase;
22 23
 
23
-    private void orgUpdate(){
24
+    @Transactional(rollbackFor = Exception.class)
25
+    public void orgUpdate(){
24 26
         JdbcTemplate oracleTemplate = new JdbcTemplate(oracle);
25 27
         final JdbcTemplate centralbaseTemplate = new JdbcTemplate(centralbase);
26 28
         String sql = String.format("select * from zy_dxgw.V_PC_ORGANIZATION_T where CANTON = '重油公司'");
@@ -62,10 +64,9 @@ public class SyncWellSourceTask extends QuartzJobBean {
62 64
             centralbaseTemplate.execute(sqlInsertOrg);  */ //excute finish, unused
63 65
         });
64 66
 
65
-        if(a.get()>1)return;
66 67
         //excute wellsource
67 68
         sql = String.format("select WELL_ID,well_common_name,org_id from " +
68
-                "zy_dxgw.pc_dev_well_attr_info where well_purpose_name='采油井'");
69
+                "zy_dxgw.pc_dev_well_attr_info where well_purpose_name LIKE '%%采油井%%'");
69 70
         results = oracleTemplate.queryForList(sql);
70 71
         results.forEach(rowMap -> {
71 72
             String wellId = rowMap.get("WELL_ID").toString();
@@ -81,14 +82,17 @@ public class SyncWellSourceTask extends QuartzJobBean {
81 82
             if(maps.isEmpty()){
82 83
                 System.out.println("===========> 添加新井: "+wellCommonName);
83 84
                 String  sqlInsertWellSource = String.format("insert into centralbase.cb_cd_well_source(well_id,well_common_name," +
84
-                                "well_legal_name,org_id,station_id) values('%s','%s','%s','%s','%s')",
85
-                        wellId, wellCommonName, wellLegalName, orgIdMapInt, stationId);
85
+                                "well_legal_name,org_id,station_id) select '%s','%s','%s','%s','%s' " +
86
+                                "where not exists (select * from centralbase.cb_cd_well_source where well_id = '%s')",
87
+                        wellId, wellCommonName, wellLegalName, orgIdMapInt, stationId, wellId);
86 88
 //            System.out.println(sqlInsertWellSource);
87 89
                 centralbaseTemplate.execute(sqlInsertWellSource);
88 90
 
89 91
                 String sqlInsertSysWellControl = String.format("insert into centralbase.sys_access_well_control(well_id," +
90
-                        "well_common_name,org_id,access_date,access_status) values('%s','%s','%s','%s,'%s')",
91
-                        wellId, wellCommonName, orgIdMapInt, LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),"1");
92
+                        "well_common_name,org_id,access_date,access_status) select '%s','%s','%s','%s','%s' " +
93
+                                " where not exists (select * from centralbase.sys_access_well_control where well_id = '%s')",
94
+                        wellId, wellCommonName, orgIdMapInt,
95
+                        LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),"1",wellId);
92 96
                 centralbaseTemplate.execute(sqlInsertSysWellControl);
93 97
             }
94 98
         });

+ 1 - 1
src/main/java/com/gct/tools/etlcamelhuge/routeconfig/CamelJDBCCofRealTimeConfiguration.java

@@ -67,7 +67,7 @@ public class CamelJDBCCofRealTimeConfiguration {
67 67
     public void sendDataToRocketMQ(String wellName, String wellId, String prodDate, Double stroke_length, Double stroke_frequency, String sgt) {
68 68
         String orgId = "0";
69 69
         DiagnoseMsg diagnoseMsg = new DiagnoseMsg(wellId, wellName, orgId, prodDate, sgt, LocalDateTime.now().toString(), stroke_length, stroke_frequency);
70
-        System.out.println(diagnoseMsg);
70
+//        System.out.println(diagnoseMsg);
71 71
         sendMsgRunTime++;
72 72
         producer.send(diagnoseMsg);
73 73
     }

+ 4 - 1
src/main/resources/application.yml

@@ -158,4 +158,7 @@ gct:
158 158
 swagger:
159 159
   authorization:
160 160
     key-name: token
161
-  enabled: true
161
+  enabled: true
162
+logging:
163
+  level:
164
+    root: error