NFDataSyncJob.java
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.skua.modules.job;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.DateUtils;
import com.skua.modules.report.service.IReportDataService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 发送消息任务
*/
@Slf4j
public class NFDataSyncJob implements Job {
@Autowired
private IReportDataService reportDataService;
//水质水量报表
private static final String SZSL = "2119ecbf53a1d2d0708258ff67cfd9e1";
//化验日报
private static final String HYRB = "9bffaf9187093d6e6a4390e8c56acca8";
@Override
public void execute(JobExecutionContext jobExecutionContext) {
log.info("开始同步昨日恩菲的数据入报表");
String yesterday = DateUtils.getYesterday();
JdbcTemplate nfDb = (JdbcTemplate) SpringContextUtils.getBean("nf-db");
String sql = "select * from day_report_data where update_time like '"+yesterday+"%'";
List<Map<String, Object>> dataList = nfDb.queryForList(sql);
if(dataList.size() > 0){
for (Map<String, Object> map : dataList) {
String departId = map.get("depart_id").toString();
String time = map.get("time").toString();
String itemCode = map.get("item_code").toString();
String itemValue = map.get("item_value").toString();
String itemType = map.get("item_type").toString();
Map<String, String> data = new HashMap<>();
data.put(itemCode, itemValue);
data.put("departId", departId);
data.put("time",yesterday);
if("szsl".equals(itemType)){
data.put("reportId", SZSL);
reportDataService.insertOrUpdateReportData(departId, time, data, SZSL);
}else if("hyrb".equals(itemType)){
data.put("reportId", HYRB);
reportDataService.insertOrUpdateReportData(departId, time, data, HYRB);
}else {
log.info("恩菲【"+itemType+"】类型数据未进行数据同步");
}
}
}
log.info("同步昨日恩菲的数据入报表完成");
}
}