| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.modules.dispatcher.entity.DispatcherUnit; |
| | | import org.springblade.modules.dispatcher.service.IDispatcherUnitService; |
| | | import org.springblade.modules.electronrail.entity.ElectronRail; |
| | | import org.springblade.modules.electronrail.mapper.ElectronRailMapper; |
| | | import org.springblade.modules.electronrail.service.ElectronRailService; |
| | | import org.springblade.modules.electronrail.vo.ElectronRailVO; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 电子围栏服务实现类 |
| | |
| | | @Service |
| | | public class ElectronRailServiceImpl extends ServiceImpl<ElectronRailMapper, ElectronRail> implements ElectronRailService { |
| | | |
| | | @Autowired |
| | | private IDeptService deptService; |
| | | |
| | | @Autowired |
| | | private IDispatcherUnitService dispatcherUnitService; |
| | | |
| | | /** |
| | | * 自定义分页查询电子围栏数据 |
| | | * @param page |
| | |
| | | */ |
| | | @Override |
| | | public IPage<ElectronRailVO> selectElectronRailPage(IPage<ElectronRailVO> page, ElectronRailVO electronRail) { |
| | | return page.setRecords(baseMapper.selectElectronRailPage(page, electronRail)); |
| | | List<ElectronRailVO> railVOS = baseMapper.selectElectronRailPage(page, electronRail); |
| | | //遍历 |
| | | if (railVOS.size()>0){ |
| | | railVOS.forEach(electronRailVO -> { |
| | | //根据类型查询单位名称 |
| | | if (electronRailVO.getType().equals(1) || electronRailVO.getType().equals(2)){ |
| | | //本单位 |
| | | Dept dept = deptService.getById(electronRailVO.getCompanyId()); |
| | | if (null!=dept){ |
| | | electronRailVO.setCompanyName(dept.getDeptName()); |
| | | } |
| | | } |
| | | if (electronRailVO.getType().equals(3)){ |
| | | //服务单位 |
| | | DispatcherUnit dispatcherUnit = dispatcherUnitService.getById(electronRailVO.getCompanyId()); |
| | | if (null!=dispatcherUnit){ |
| | | electronRailVO.setCompanyName(dispatcherUnit.getName()); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | return page.setRecords(railVOS); |
| | | } |
| | | |
| | | /** |
| | | * 自定义新增电子围栏信息 |
| | | * @param electronRail |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean saveElectRailInfo(ElectronRail electronRail) { |
| | | return baseMapper.saveElectRailInfo(electronRail); |
| | | } |
| | | |
| | | /** |
| | | * 自定义修改电子围栏信息 |
| | | * @param electronRail |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean updateElectronRailInfo(ElectronRail electronRail) { |
| | | return baseMapper.updateElectronRailInfo(electronRail); |
| | | } |
| | | |
| | | /** |
| | | * 判断一个点是否在区域内 |
| | | * @param electronRail |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean isOnArea(ElectronRailVO electronRail) { |
| | | int i = baseMapper.isOnArea(electronRail); |
| | | if (i>0){ |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | } |