CarDeviceServiceImpl.java
1.75 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
package com.bsth.service.schedule.impl;
import com.bsth.entity.CarDevice;
import com.bsth.entity.Cars;
import com.bsth.service.CarsService;
import com.bsth.service.schedule.CarDeviceService;
import com.bsth.service.schedule.ScheduleException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.Map;
/**
* Created by xu on 16/12/15.
*/
@Service(value = "carDeviceServiceImpl_sc")
public class CarDeviceServiceImpl extends BServiceImpl<CarDevice, Long> implements CarDeviceService {
@Autowired
private CarsService carsService;
@Transactional
@Override
public CarDevice save(CarDevice carDevice) {
// 查找对应的车辆基础信息,更新设备编号数据
Cars cars = carsService.findById(carDevice.getCl());
return null;
}
@Transactional
@Override
public void validate_qyrq(CarDevice carDevice) throws ScheduleException {
if (carDevice.getXl() == null) {
throw new ScheduleException("线路未选择");
}
if (carDevice.getCl() == null) {
throw new ScheduleException("车辆未选择");
}
Map<String, Object> param = new HashMap<>();
if (carDevice.getId() != null) {
param.put("id_ne", carDevice.getId());
}
param.put("xl_eq", carDevice.getXl());
param.put("cl_eq", carDevice.getCl());
param.put("qyrq_ne", carDevice.getQyrq());
if (!CollectionUtils.isEmpty(list(param))) {
throw new ScheduleException("启用日期必须比历史的启用日期大");
}
}
}