对比新文件 |
| | |
| | | package com.se.nsl.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.se.nsl.domain.po.Simu; |
| | | import com.se.nsl.domain.vo.SimuResult; |
| | | import com.se.nsl.domain.vo.SimuVo; |
| | | import com.se.nsl.helper.StringHelper; |
| | | import com.se.nsl.mapper.SimuMapper; |
| | | import com.se.nsl.utils.CoordinateTransformer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class SimuService { |
| | | @Resource |
| | | SimuMapper simuMapper; |
| | | |
| | | /** |
| | | * 鍒嗛〉鏌ヨ鎺ㄦ紨妯℃嫙 |
| | | * |
| | | * @param pageNum 椤电爜 |
| | | * @param pageSize 姣忛〉鏁伴噺 |
| | | * @return 鍒嗛〉鍚庣殑鎺ㄦ紨妯℃嫙 |
| | | */ |
| | | public IPage<Simu> selectPage(SimuVo vo, int pageNum, int pageSize) { |
| | | QueryWrapper<Simu> wrapper = getPageWrapper(vo, pageNum, pageSize); |
| | | |
| | | Page<Simu> page = new Page<>(pageNum, pageSize); |
| | | page.addOrder(OrderItem.desc("id")); |
| | | |
| | | IPage<Simu> paged = simuMapper.selectPage(page, wrapper); |
| | | |
| | | return paged; |
| | | } |
| | | |
| | | private QueryWrapper<Simu> getPageWrapper(SimuVo vo, int pageNum, int pageSize) { |
| | | QueryWrapper<Simu> wrapper = new QueryWrapper<>(); |
| | | if (null != vo.getId()) { |
| | | wrapper.eq("id", vo.getId()); |
| | | } |
| | | if (!StringHelper.isEmpty(vo.getName())) { |
| | | wrapper.like("lower(name)", vo.getName().trim().toLowerCase()); |
| | | } |
| | | if (!StringHelper.isEmpty(vo.getServiceName())) { |
| | | wrapper.like("service_name", vo.getServiceName().trim()); |
| | | } |
| | | if (null != vo.getType()) { |
| | | wrapper.eq("type", vo.getType()); |
| | | } |
| | | if (null != vo.getAreaType()) { |
| | | wrapper.eq("area_type", vo.getAreaType()); |
| | | } |
| | | if (null != vo.getStatus()) { |
| | | wrapper.eq("status", vo.getStatus()); |
| | | } |
| | | |
| | | return wrapper; |
| | | } |
| | | |
| | | /** |
| | | * 鏍规嵁ID鎵归噺鍒犻櫎鎺ㄦ紨妯℃嫙 |
| | | * |
| | | * @param ids 瑕佸垹闄ょ殑鍖哄煙ID鍒楄〃 |
| | | * @return 鍒犻櫎鎴愬姛鐨勮褰曟暟 |
| | | */ |
| | | public int deleteByIds(List<Integer> ids) { |
| | | return simuMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | /** |
| | | * 鏂板鎺ㄦ紨妯℃嫙 |
| | | * |
| | | * @param Simu 鎺ㄦ紨妯℃嫙瀵硅薄 |
| | | * @return 鏂板鎴愬姛鐨勮褰曟暟 |
| | | */ |
| | | public int insert(Simu simu) { |
| | | return simuMapper.insert(simu); |
| | | } |
| | | |
| | | public int inserts(List<Simu> list) { |
| | | return simuMapper.inserts(list); |
| | | } |
| | | |
| | | /** |
| | | * 鏍规嵁ID鏌ヨ |
| | | * |
| | | * @param id ID |
| | | * @return Simu |
| | | */ |
| | | public Simu selectById(Integer id) { |
| | | return simuMapper.selectById(id); |
| | | } |
| | | |
| | | /** |
| | | * 淇敼鎺ㄦ紨妯℃嫙 |
| | | * |
| | | * @param Simu 鎺ㄦ紨妯℃嫙瀵硅薄 |
| | | * @return 淇敼鎴愬姛鐨勮褰曟暟 |
| | | */ |
| | | public int updateById(Simu simu) { |
| | | return simuMapper.updates(Arrays.asList(simu)); |
| | | } |
| | | |
| | | public SimuResult queryByPosition(double lon, double lat, String time, String serviceName) { |
| | | //transform coordiante from 4326 to 4548 |
| | | double[] xy = CoordinateTransformer.transform(4326, 4548, lon, lat); |
| | | System.out.println(String.format("杞崲鍓嶇殑鍧愭爣锛歺:%s,y:%s", lon, lat)); |
| | | System.out.println(String.format("杞崲鍚庣殑鍧愭爣锛歺:%s,y:%s", xy[0], xy[1])); |
| | | //read zarr data and compare the data with lon,lat,time |
| | | |
| | | return null; |
| | | } |
| | | |
| | | } |