package com.stylefeng.guns.modular.system.service.impl;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
import com.stylefeng.guns.modular.system.dao.LineMapper;
|
import com.stylefeng.guns.modular.system.model.Dispatch;
|
import com.stylefeng.guns.modular.system.model.Line;
|
import com.stylefeng.guns.modular.system.service.IDispatchService;
|
import com.stylefeng.guns.modular.system.service.ILineService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
|
|
@Service
|
public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements ILineService {
|
|
@Resource
|
private LineMapper lineMapper;
|
|
@Autowired
|
private IDispatchService dispatchService;
|
|
|
/**
|
* 获取企业拥有的所有线路
|
* @param uid
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public List<Map<String, Object>> queryLine(Integer uid) throws Exception {
|
Integer companyId = null;
|
Dispatch dispatch = dispatchService.selectById(uid);
|
if(dispatch.getFranchiseeId() == null || dispatch.getFranchiseeId().compareTo(0) == 0){
|
companyId = dispatch.getCompanyId();
|
}else{
|
companyId = dispatch.getFranchiseeId();
|
}
|
return lineMapper.queryLine(companyId);
|
}
|
|
|
/**
|
* 根据站点id获取线路
|
* @param startId
|
* @param endId
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public List<Map<String, Object>> queryLines(Integer startId, Integer endId, Integer uid) throws Exception {
|
Integer companyId = null;
|
Dispatch dispatch = dispatchService.selectById(uid);
|
if(dispatch.getFranchiseeId() == null || dispatch.getFranchiseeId().compareTo(0) == 0){
|
companyId = dispatch.getCompanyId();
|
}else{
|
companyId = dispatch.getFranchiseeId();
|
}
|
List<Map<String, Object>> list1 = lineMapper.queryLines(startId, 1, companyId);
|
List<Map<String, Object>> list2 = lineMapper.queryLines(endId, 2, companyId);
|
List<Map<String, Object>> list = new ArrayList<>();
|
for(Map<String, Object> map1 : list1){
|
Integer id1 = Integer.valueOf(map1.get("id").toString());
|
for(Map<String, Object> map2 : list2){
|
Integer id2 = Integer.valueOf(map2.get("id").toString());
|
if(id1 == id2){
|
list.add(map1);
|
}
|
}
|
}
|
return list;
|
}
|
}
|