NFDataSyncJob.java
2.6 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.skua.modules.job;
import com.skua.common.constant.ReportConstant;
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 org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 发送消息任务
*/
@Slf4j
@Component
public class NFDataSyncJob implements Job {
@Autowired
private IReportDataService reportDataService;
/**
* 若参数变量名修改 QuartzJobController中也需对应修改
*/
private String parameter;
public void setParameter(String parameter) {
this.parameter = parameter;
}
@Override
public void execute(JobExecutionContext jobExecutionContext) {
String yesterday = DateUtils.getYesterday();
if(StringUtils.isNotEmpty(this.parameter)){
yesterday = this.parameter;
}
log.info("开始同步【"+yesterday+"】恩菲的数据入报表");
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("departId", departId);
data.put("time",yesterday);
if("szsl".equals(itemType)){
data.put(itemCode, itemValue);
data.put("reportId", ReportConstant.view2119);
reportDataService.insertOrUpdateReportData(departId, time, data, ReportConstant.view2119);
}else if("hyrb".equals(itemType)){
String indexs = "JSCOD,JSAD,JSPH,JSZD,JSZL,JSSS,CSCOD,CSAD,CSPH,CSTN,CSZL,CSSS";
if(indexs.indexOf(itemCode) > 0){
data.put(itemCode+"HY", itemValue);
}else{
data.put(itemCode, itemValue);
}
data.put("reportId", ReportConstant.view9bff);
reportDataService.insertOrUpdateReportData(departId, time, data, ReportConstant.view9bff);
}else {
log.info("恩菲【"+itemType+"】类型数据未进行数据同步");
}
}
}
log.info("恩菲的数据入报表完成");
}
}