TccExternalService.java
3.96 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package com.bsth.data.schedule.external;
import com.bsth.common.ResponseCode;
import com.bsth.controller.realcontrol.dto.ChangePersonCar;
import com.bsth.controller.realcontrol.dto.DftzAndDestroy;
import com.bsth.data.schedule.DayOfSchedule;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import com.bsth.service.realcontrol.ScheduleRealInfoService;
import com.bsth.websocket.handler.SendUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
/**
* 对停车场开放的班次调度服务
* Created by panzhao on 2018/3/22.
*/
@Component
public class TccExternalService {
Logger logger = LoggerFactory.getLogger(TccExternalService.class);
@Autowired
DayOfSchedule dayOfSchedule;
@Autowired
ScheduleRealInfoService scheduleRealInfoService;
@Autowired
SendUtils sendUtils;
/**
* Departure time adjustment
*
* @param dad
* @return
*/
public Map<String, Object> dftz(DftzAndDestroy dad) {
Map<String, Object> rs = new HashMap();
rs.put("status", ResponseCode.ERROR);
try {
List<ScheduleRealInfo> updateList = new ArrayList<>();//要刷新的班次
ScheduleRealInfo sch = dayOfSchedule.get(dad.getDftzId());
if (null == sch) {
rs.put("msg", "班次已经不存在了!");
return rs;
}
if (!sch.getBcType().equals("out")) {
rs.put("msg", "只能操作出场班次!");
return rs;
}
//调整待发时间
scheduleRealInfoService.outgoAdjust(sch.getId(), dad.getRemarks(), dad.getNewTimeStr(), sch.getBcType(), "4", dad.getUserId());
updateList.add(sch);
//需要烂班的班次
if (StringUtils.isNotEmpty(dad.getDestroyIdx())) {
Map<String, Object> dMap =
scheduleRealInfoService.destroy(dad.getDestroyIdx(), dad.getRemarks(), dad.getReason(), dad.getUserId());
updateList.addAll((Collection<? extends ScheduleRealInfo>) dMap.get("ts"));
}
//通知调度客户端更新班次信息
sendUpdate2Page(updateList);
rs.put("status", ResponseCode.SUCCESS);
rs.put("t", sch);
} catch (Exception e) {
rs.put("msg", "内部调度服务接口出现异常!");
logger.error("", e);
}
return rs;
}
/**
* 换人换车
*
* @param cpcs
* @return
*/
public Map<String, Object> hrhc(List<ChangePersonCar> cpcs,String tccCode, String userId) {
Map<String, Object> rs = new HashMap();
rs.put("status", ResponseCode.ERROR);
try {
rs = scheduleRealInfoService.multi_tzrc(cpcs, userId);
//通知调度客户端更新班次信息
sendUpdate2Page(new ArrayList<ScheduleRealInfo>((Set)rs.get("ts")));
//返回更新结果集中指定停车场的进出场班次
Set<ScheduleRealInfo> ts = (Set<ScheduleRealInfo>) rs.get("ts");
List<ScheduleRealInfo> list = new ArrayList<>();
for(ScheduleRealInfo sch : ts){
if((sch.getBcType().equals("out") && sch.getQdzCode().equals(tccCode))
|| (sch.getBcType().equals("in") && sch.getZdzCode().equals(tccCode)))
list.add(sch);
}
rs.put("list", list);
rs.remove("ts");
} catch (Exception e) {
rs.put("msg", "服务器出现异常!");
logger.error("", e);
}
return rs;
}
public void sendUpdate2Page(List<ScheduleRealInfo> list) {
sendUtils.refreshSch(list);
}
}