ChargerIncomeDiffJob.java
3.45 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.zteits.park.job;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.xiaoleilu.hutool.date.DateUtil;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.context.XxlJobHelper;
import com.zteits.clouds.api.dto.clouds.param.QueryEmployeeRequest;
import com.zteits.clouds.api.dto.park.dto.TpEEmployeeChargeDTO;
import com.zteits.park.dao.TpEEmployeeChargeDao;
import com.zteits.park.service.chargerincomediff.oper.ChargerIncomeDiffOperInnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
/**
* Copyright: Copyright (c) 2019 zteits
*
* @ClassName: com.zteits.park.job
* @Description:
* @version: v1.0.0
* @author: atao
* @date: 2019-01-15 18:56
* Modification History:
* Date Author Version Description
* ---------------------------------------------------------*
* 2019-01-15 atao v1.0.0 创建
*/
@Component
public class ChargerIncomeDiffJob {
@Autowired
private ChargerIncomeDiffOperInnerService chargerIncomeDiffOperInnerService;
@Autowired
private TpEEmployeeChargeDao tpEEmployeeChargeDao;
@XxlJob("ChargerIncomeDiffJob")
public ReturnT<String> execute(String... params) throws Exception {
String param = XxlJobHelper.getJobParam();
if (StringUtils.isNotEmpty(param) && params == null) {
params = param.split(",");
}
Date initDate = DateUtil.yesterday();
if (null != params && params.length > 0) {
initDate = DateUtil.parseDate(params[0]);
}
Date startDate = DateUtil.beginOfDay(initDate);
Date endDate = DateUtil.endOfDay(initDate);
XxlJobHelper.log("开始时间为:" + startDate + "结束时间为:" + endDate);
Integer delNum = chargerIncomeDiffOperInnerService.deleteChargerIncomeDiffByDate(startDate, endDate);
XxlJobHelper.log("删除数据:" + delNum);
QueryEmployeeRequest request = new QueryEmployeeRequest();
request.setEntryStatus(1);
request.setChargerType("0");
request.getBaseRequest().setPageNum(1);
request.getBaseRequest().setPageSize(Integer.MAX_VALUE);
PageInfo<TpEEmployeeChargeDTO> pageInfo = tpEEmployeeChargeDao.queryEmployeesForPage(request);
if (null == pageInfo) {
XxlJobHelper.log("查询收费员失败");
return ReturnT.FAIL;
}
List<TpEEmployeeChargeDTO> chargeDTOS = pageInfo.getList();
if (CollectionUtils.isEmpty(chargeDTOS)) {
XxlJobHelper.log("查询收费员为空");
return ReturnT.FAIL;
}
CountDownLatch countDownLatch = new CountDownLatch(chargeDTOS.size());
Map<String, String> falilMap = new HashMap<>(10);
for (TpEEmployeeChargeDTO dto : chargeDTOS) {
chargerIncomeDiffOperInnerService.handelChargerIncomeDiffByChargerCodeAsync(dto.getChargerCode(), startDate,
endDate, countDownLatch, falilMap);
}
countDownLatch.await();
return new ReturnT<>(JSONObject.toJSONString(falilMap));
}
}