| | |
| | | import com.lf.server.entity.all.BaseEntity; |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.data.*; |
| | | import com.lf.server.entity.sys.DepEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.*; |
| | | 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 com.lf.server.service.sys.DepService; |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Autowired |
| | | MetaService metaService; |
| | | |
| | | @Autowired |
| | | DepService depService; |
| | | |
| | | @Autowired |
| | | DirService dirService; |
| | | |
| | | @Override |
| | | public List<CoordEntity> selectCoords(String zoning) { |
| | |
| | | excelLoader(list, req); |
| | | loadData(list); |
| | | copyFiles(list); |
| | | publishFiles(list); |
| | | insertMetas(list); |
| | | } |
| | | |
| | |
| | | for (MetaFileEntity mf : list) { |
| | | mf.setCreateUser(ue.getId()); |
| | | mf.setCreateTime(createTime); |
| | | mf.setDepid(ue.getDepid()); |
| | | mf.setDepcode(ue.getDepcode()); |
| | | mf.setPath(tempPath + File.separator + mf.getPath()); |
| | | mf.setMsg(null); |
| | | |
| | |
| | | String path = copyXlsFile(xlsBasePath, i, mf); |
| | | if (null != path) { |
| | | pathList.add(path); |
| | | dirList.add(mf.getDirid() + ""); |
| | | dirList.add(mf.getDircode()); |
| | | pidList.add(mf.getEventid()); |
| | | } |
| | | } |
| | | |
| | | MetaFileEntity first = xlsList.get(0); |
| | | MetaFileEntity meta = new MetaFileEntity(); |
| | | meta.setPath(StringHelper.join(pathList, ",")); |
| | | meta.setEpsgCode(xlsList.get(0).getEpsgCode()); |
| | | meta.setEpsgCode(first.getEpsgCode()); |
| | | meta.setName(StringHelper.join(dirList, ";")); |
| | | meta.setDepid(xlsList.get(0).getDepid()); |
| | | meta.setVerid(xlsList.get(0).getVerid()); |
| | | meta.setCreateUser(xlsList.get(0).getCreateUser()); |
| | | meta.setDepcode(first.getDepcode()); |
| | | meta.setVerid(first.getVerid()); |
| | | meta.setCreateUser(first.getCreateUser()); |
| | | meta.setEventid(StringHelper.join(pidList, ";")); |
| | | |
| | | return meta; |
| | |
| | | BaseEntity be = (BaseEntity) t; |
| | | be.setEventid(StringHelper.getGuid()); |
| | | be.setParentid(mf.getEventid()); |
| | | be.setDirid(mf.getDirid()); |
| | | be.setDepid(mf.getDepid()); |
| | | be.setDirid(mf.getDircode()); |
| | | be.setDepid(mf.getDepcode()); |
| | | be.setVerid(mf.getVerid()); |
| | | be.setCreateuser(mf.getCreateUser()); |
| | | be.setCreatetime(mf.getCreateTime()); |
| | |
| | | */ |
| | | private void copyMultiFile(MetaFileEntity mf, List<String> extList) { |
| | | String path = mf.getPath(); |
| | | |
| | | int status = copySingleFile(mf); |
| | | if (status < 1) { |
| | | for (int i = 0, c = extList.size(); i < c; i++) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 发布文件 |
| | | */ |
| | | private void publishFiles(List<MetaFileEntity> list) { |
| | | for (MetaFileEntity mf : list) { |
| | | if (null != mf.getMsg()) { |
| | | continue; |
| | | } |
| | | switch (mf.getExtName()) { |
| | | case StaticData.MPT: |
| | | linkFiles(mf, StaticData.MPT_EXT, pathHelper.getConfig().getPublishMptPath()); |
| | | break; |
| | | case StaticData.D3DML: |
| | | linkFiles(mf, null, pathHelper.getConfig().getPublish3dmlPath()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 链接文件 |
| | | */ |
| | | private void linkFiles(MetaFileEntity mf, List<String> exts, String publishPath) { |
| | | String uploadPath = pathHelper.getConfig().getUploadPath(); |
| | | String source = uploadPath + File.separator + mf.getPath(); |
| | | String target = publishPath + File.separator + mf.getName(); |
| | | |
| | | File sourceFile = new File(source); |
| | | if (!sourceFile.exists() || sourceFile.isDirectory()) { |
| | | return; |
| | | } |
| | | |
| | | createFileLink(source, target); |
| | | if (null == exts) { |
| | | return; |
| | | } |
| | | |
| | | for (String ext : exts) { |
| | | File f=new File(source.replace(mf.getExtName(), ext)); |
| | | if (f.exists()&&!f.isDirectory()) { |
| | | createFileLink(source.replace(mf.getExtName(), ext), target.replace(mf.getExtName(), ext)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建文件链接 |
| | | */ |
| | | private void createFileLink(String source, String target) { |
| | | String cmd = String.format("cmd /c mklink \"%s\" \"%s\"", target, source); |
| | | WebHelper.exec(cmd); |
| | | } |
| | | |
| | | /** |
| | | * 插入元数据 |
| | | */ |
| | | private void insertMetas(List<MetaFileEntity> list) { |
| | |
| | | private MetaEntity createMeta(MetaFileEntity mf) { |
| | | MetaEntity me = new MetaEntity(); |
| | | me.setEventid(mf.getEventid()); |
| | | me.setDirid(mf.getDirid()); |
| | | me.setDepid(mf.getDepid()); |
| | | me.setDircode(mf.getDircode()); |
| | | me.setDepcode(mf.getDepcode()); |
| | | me.setVerid(mf.getVerid()); |
| | | me.setName(mf.getName()); |
| | | me.setType(mf.getType()); |