| | |
| | | package com.lf.server.service.data; |
| | | |
| | | import com.lf.server.entity.all.BaseEntity; |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.data.CoordEntity; |
| | | import com.lf.server.entity.data.DirEntity; |
| | | import com.lf.server.entity.data.FmeLogEntity; |
| | | import com.lf.server.entity.data.MetaFileEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.ClassHelper; |
| | | import com.lf.server.helper.GdbHelper; |
| | | import com.lf.server.helper.ShpHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.mapper.all.BasicMapper; |
| | | import com.lf.server.mapper.data.UploadMapper; |
| | | import com.lf.server.service.all.BaseQueryService; |
| | | import com.lf.server.service.all.BaseUploadService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 装载数据 |
| | | * |
| | | * @param list |
| | | * 加载数据 |
| | | */ |
| | | private void dataLoader(List<MetaFileEntity> list) { |
| | | loadData(list); |
| | | copyFiles(list); |
| | | } |
| | | |
| | | /** |
| | | * 加载数据 |
| | | */ |
| | | private void loadData(List<MetaFileEntity> list) { |
| | | for (MetaFileEntity mf : list) { |
| | | if (StaticData.SHP.equals(mf.getExtName()) || StaticData.GDB.equals(mf.getExtName())) { |
| | | loadSpatialData(mf); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 加载空间数据 |
| | | */ |
| | | private void loadSpatialData(MetaFileEntity mf) { |
| | | BasicMapper basicMapper = ClassHelper.getBasicMapper(mf.getEntity()); |
| | | if (null == basicMapper) { |
| | | return; |
| | | } |
| | | |
| | | String tabName = BaseQueryService.getTabName(basicMapper); |
| | | String className = ClassHelper.getClassName(basicMapper); |
| | | Class clazz = ClassHelper.getEntityClass(className); |
| | | if (null == clazz || null == tabName) { |
| | | return; |
| | | } |
| | | |
| | | List<?> list = null; |
| | | if (StaticData.SHP.equals(mf.getExtName())) { |
| | | list = ShpHelper.readData(clazz, mf.getPath()); |
| | | } else { |
| | | GdbHelper.readData(clazz, mf.getPath(), mf.getTab()); |
| | | } |
| | | if (null == list || list.isEmpty()) { |
| | | return; |
| | | } |
| | | setCreateInfo(list, mf); |
| | | |
| | | int rows = basicMapper.insertBatch(list); |
| | | mf.setTab(tabName); |
| | | mf.setRows(rows); |
| | | } |
| | | |
| | | /** |
| | | * 设置创建信息 |
| | | */ |
| | | private <T> void setCreateInfo(List<T> list, MetaFileEntity mf) { |
| | | try { |
| | | if (!(list.get(0) instanceof BaseEntity)) { |
| | | return; |
| | | } |
| | | |
| | | for (T t : list) { |
| | | BaseEntity be = (BaseEntity) t; |
| | | be.setEventid(StringHelper.getGuid()); |
| | | be.setParentid(mf.getEventid()); |
| | | be.setCreateuser(mf.getCreateUser()); |
| | | be.setCreatetime(mf.getCreatetime()); |
| | | be.setDirid(mf.getDirid()); |
| | | be.setDepid(mf.getDepid()); |
| | | be.setVerid(mf.getVerid()); |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 复制文件 |
| | | */ |
| | | private void copyFiles(List<MetaFileEntity> list) { |
| | | |
| | | } |
| | | |
| | |
| | | */ |
| | | private void checkMetaFiles(UserEntity ue, List<MetaFileEntity> list) { |
| | | String tempPath = pathHelper.getConfig().getTempPath(); |
| | | |
| | | for (MetaFileEntity mf : list) { |
| | | mf.setCreateUser(ue.getId()); |
| | | mf.setDepid(ue.getDepid()); |
| | | mf.setPath(tempPath + File.separator + mf.getPath()); |
| | | |
| | | File f = new File(tempPath + File.separator + mf.getPath()); |
| | | File f = new File(mf.getPath()); |
| | | if (!f.exists()) { |
| | | mf.setRows(-1); |
| | | mf.setMsg("文件不存在"); |
| | |
| | | List<String> dirList = new ArrayList<>(); |
| | | List<String> pidList = new ArrayList<>(); |
| | | |
| | | String tempPath = pathHelper.getConfig().getTempPath(); |
| | | for (MetaFileEntity mf : xlsList) { |
| | | pathList.add(tempPath + File.separator + mf.getPath()); |
| | | pathList.add(mf.getPath()); |
| | | dirList.add(mf.getDirid() + ""); |
| | | pidList.add(mf.getEventid()); |
| | | } |