|
@@ -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
|
});
|