ChildTaskPlanServiceImpl.java
1.8 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
package com.bsth.service.realcontrol.impl;
import java.util.Map;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bsth.entity.realcontrol.ChildTaskPlan;
import com.bsth.entity.realcontrol.ScheduleRealInfo;
import com.bsth.repository.realcontrol.ChildTaskPlanRepository;
import com.bsth.service.impl.BaseServiceImpl;
import com.bsth.service.realcontrol.ChildTaskPlanService;
import com.bsth.service.realcontrol.buffer.ScheduleBuffer;
import com.bsth.vehicle.common.CommonMapped;
@Service
public class ChildTaskPlanServiceImpl extends BaseServiceImpl<ChildTaskPlan, Long> implements ChildTaskPlanService{
/*@Autowired
ScheduleRealInfoServiceImpl scheduleRealInfoService;*/
@Autowired
ChildTaskPlanRepository childTaskPlanRepository;
@Transactional
@Override
public Map<String, Object> save(ChildTaskPlan t) {
Map<String, Object> rs;
//保存起终点名称
Map<String, String> map = CommonMapped.stationCodeMap;
t.setStartStationName(map.get(t.getStartStation()));
t.setEndStationName(map.get(t.getEndStation()));
//先持久化子任务
rs = super.save(t);
//再关联主任务
ScheduleRealInfo sch = ScheduleBuffer.findOne(t.getSchedule().getId());
sch.getcTasks().add(t);
//rs = scheduleRealInfoService.save(sch);
rs.put("t", sch);
return rs;
}
@Override
public Map<String, Object> delete(Long id) {
Map<String, Object> rs;
ChildTaskPlan cPlan = childTaskPlanRepository.findOne(id);
//解除和主任务关联
ScheduleRealInfo sch = ScheduleBuffer.findOne(cPlan.getSchedule().getId());
sch.getcTasks().remove(cPlan);
//删除子任务
rs = super.delete(id);
rs.put("t", sch);
return rs;
}
}