EmployeeConfigInfoServiceImpl.java
2.1 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
package com.bsth.service.schedule;
import com.bsth.common.ResponseCode;
import com.bsth.entity.Line;
import com.bsth.entity.schedule.EmployeeConfigInfo;
import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
import com.bsth.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.*;
/**
* Created by xu on 16/5/10.
*/
@Service
public class EmployeeConfigInfoServiceImpl extends BaseServiceImpl<EmployeeConfigInfo, Long> implements EmployeeConfigInfoService {
@Autowired
private EmployeeConfigInfoRepository employeeConfigInfoRepository;
@Autowired
private ScheduleRule1FlatService scheduleRule1FlatService;
@Override
@Transactional
public Map<String, Object> delete(Long aLong) {
// 获取待作废的人员配置
EmployeeConfigInfo employeeConfigInfo = employeeConfigInfoRepository.findOne(aLong);
// 获取线路
Line xl = employeeConfigInfo.getXl();
// 查找线路的规则,比较人员配置信息
Map<String, Object> param = new HashMap<>();
param.put("xl.id_eq", xl.getId());
Iterator<ScheduleRule1Flat> employeeConfigInfoIterator = scheduleRule1FlatService.list(param).iterator();
List<String> ryConfigIds = new ArrayList<>();
while (employeeConfigInfoIterator.hasNext()) {
ScheduleRule1Flat scheduleRule1Flat = employeeConfigInfoIterator.next();
ryConfigIds.addAll(Arrays.asList(scheduleRule1Flat.getRyConfigIds().split(",")));
}
Map<String, Object> map = new HashMap<>();
if (ryConfigIds.contains(employeeConfigInfo.getId().toString())) {
throw new RuntimeException("人员配置已被规则使用,不能删除,请先修改规则!");
} else {
employeeConfigInfo.setIsCancel(true);
map.put("status", ResponseCode.SUCCESS);
}
return map;
}
}