| | |
| | | import com.moon.server.mapper.show.MarkMapper; |
| | | import com.moon.server.service.data.DownloadService; |
| | | import com.moon.server.helper.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 标绘 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class MarkService implements MarkMapper { |
| | | @Autowired |
| | | @Resource |
| | | MarkMapper markMapper; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | PathHelper pathHelper; |
| | | |
| | | @Autowired |
| | | @Resource |
| | | DownloadService downloadService; |
| | | |
| | | @Override |
| | | public Integer selectCount(Integer uid) { |
| | | return markMapper.selectCount(uid); |
| | | public Integer selectCount(String name, Integer userid) { |
| | | name = StringHelper.getLikeUpperStr(name); |
| | | |
| | | return markMapper.selectCount(name, userid); |
| | | } |
| | | |
| | | @Override |
| | | public List<MarkEntity> selectByPage(Integer uid, Integer limit, Integer offset) { |
| | | return markMapper.selectByPage(uid, limit, offset); |
| | | public List<MarkEntity> selectByPage(String name, Integer userid, Integer limit, Integer offset) { |
| | | name = StringHelper.getLikeUpperStr(name); |
| | | |
| | | return markMapper.selectByPage(name, userid, limit, offset); |
| | | } |
| | | |
| | | @Override |
| | | public List<MarkEntity> selectAll() { |
| | | return markMapper.selectAll(); |
| | | public List<MarkEntity> selectAll(Integer userid) { |
| | | return markMapper.selectAll(userid); |
| | | } |
| | | |
| | | @Override |
| | | public MarkEntity selectById(int id) { |
| | | return markMapper.selectById(id); |
| | | public MarkEntity selectById(int id, Integer userid) { |
| | | return markMapper.selectById(id, userid); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer delete(int id) { |
| | | return markMapper.delete(id); |
| | | public Integer delete(int id, Integer userid) { |
| | | return markMapper.delete(id, userid); |
| | | } |
| | | |
| | | @Override |
| | | public Integer deletes(List<Integer> ids) { |
| | | return markMapper.deletes(ids); |
| | | public Integer deletes(List<Integer> ids, Integer userid) { |
| | | return markMapper.deletes(ids, userid); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return markMapper.updates(list); |
| | | } |
| | | |
| | | /** |
| | | * 下载ShapeFile文件 |
| | | * |
| | | * @param ue 用户实体 |
| | | * @param list 标绘JSON实体类集合 |
| | | * @return GUID |
| | | * @throws Exception 异常 |
| | | */ |
| | | public String downloadShp(UserEntity ue, List<MarkJsonEntity> list) throws Exception { |
| | | String path = pathHelper.getTempPath(); |
| | | createShapeFiles(ue, list, path); |
| | |
| | | return rows > 0 ? de.getGuid() : null; |
| | | } |
| | | |
| | | /** |
| | | * 创建shp文件 |
| | | */ |
| | | private String createShapeFiles(UserEntity ue, List<MarkJsonEntity> list, String path) { |
| | | List<MarkJsonEntity> points = getMarkByType(list, "POINT"); |
| | | if (points.size() > 0) { |
| | |
| | | return path; |
| | | } |
| | | |
| | | /** |
| | | * 获取shp目录 |
| | | */ |
| | | private String getShpDir(UserEntity ue, String parent) { |
| | | String path = parent + File.separator + StringHelper.YMDHMS2_FORMAT.format(new Date()); |
| | | |
| | |
| | | return path; |
| | | } |
| | | |
| | | /** |
| | | * 获取标绘类型 |
| | | */ |
| | | private List<MarkJsonEntity> getMarkByType(List<MarkJsonEntity> list, String type) { |
| | | List<MarkJsonEntity> rs = new ArrayList<>(); |
| | | for (MarkJsonEntity mark : list) { |
| | |
| | | return rs; |
| | | } |
| | | |
| | | /** |
| | | * 获取zip路径 |
| | | */ |
| | | private String getZipPath() { |
| | | String path = pathHelper.getDownloadFullPath() + File.separator + StringHelper.YMDHMS2_FORMAT.format(new Date()) + ".zip"; |
| | | |
| | |
| | | return path; |
| | | } |
| | | |
| | | /** |
| | | * 获取下载实体类 |
| | | */ |
| | | private DownloadEntity getDownloadEntity(UserEntity ue, String file) throws Exception { |
| | | DownloadEntity de = new DownloadEntity(); |
| | | de.setName(FileHelper.getFileName(file)); |
| | |
| | | return de; |
| | | } |
| | | |
| | | /** |
| | | * 获取下载文件路径 |
| | | */ |
| | | public String getDownloadFilePath(DownloadEntity de) { |
| | | return pathHelper.getConfig().getDownloadPath() + File.separator + de.getUrl(); |
| | | } |
| | | |
| | | /** |
| | | * 读取ShapeFile文件获取Mark实体类 |
| | | */ |
| | | public List<MarkJsonEntity> readShpForMarks(List<MetaFileEntity> list) { |
| | | String fileName = null; |
| | | for (MetaFileEntity mf : list) { |