RevertLineThread.java
1.3 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
package com.bsth.vehicle.directive.thread;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.bsth.entity.realcontrol.DeviceRevertLine;
import com.bsth.repository.realcontrol.DeviceRevertLineRepository;
import com.bsth.vehicle.directive.service.DirectiveService;
/**
*
* @ClassName: DeviceRevertLineThread
* @Description: TODO(设备线路还原线程, 将借出的车还原到原线路)
* @author PanZhao
* @date 2016年7月7日 上午11:30:38
*
*/
@Component
public class RevertLineThread extends Thread{
@Autowired
DeviceRevertLineRepository deviceRevertLineRepository;
@Autowired
DirectiveService directiveService;
@Override
public void run() {
Long et = System.currentTimeMillis()
,st = et - (1000 * 60 * 5);
List<DeviceRevertLine> list = deviceRevertLineRepository.findByDateAndStatus(st, et, 0);
if(list.size() == 0)
return;
int code;
for(DeviceRevertLine revertLine : list){
//还车
code = directiveService.lineChange(revertLine.getNbbm(), Integer.parseInt(revertLine.getRevertLine()));
if(code == 0){
//改变状态
revertLine.setStatus(1);
deviceRevertLineRepository.save(revertLine);
}
}
}
}