| | |
| | | import cn.gistack.resource.entity.QieTuEntity; |
| | | import cn.gistack.resource.feign.IOssClient; |
| | | import cn.gistack.sm.skPanorama.entity.ParamEntity; |
| | | import cn.gistack.sm.skPanorama.entity.SkPicCountEntity; |
| | | import cn.gistack.sm.skPanorama.utils.Img4JavaUtil; |
| | | import cn.gistack.sm.skPanorama.utils.PanoramaUtilDict; |
| | | import cn.gistack.sm.skPanoramaState.entity.SkPanoramaStateEntity; |
| | |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import cn.gistack.sm.skPanorama.entity.SkPanoramaEntity; |
| | |
| | | /** |
| | | * 对象存储构建类 |
| | | */ |
| | | @Autowired |
| | | private final IOssClient iOssClient; |
| | | |
| | | |
| | |
| | | */ |
| | | @GetMapping("/page") |
| | | @ApiOperation(value = "分页", notes = "传入skPanorama") |
| | | public R<IPage<SkPanoramaVO>> page(SkPanoramaVO skPanorama, Query query) { |
| | | IPage<SkPanoramaVO> pages = skPanoramaService.selectSkPanoramaPage(Condition.getPage(query), skPanorama); |
| | | public R<IPage<SkPicCountEntity>> page(SkPicCountEntity skPanorama, Query query) { |
| | | Integer current = query.getCurrent(); |
| | | Integer size = query.getSize(); |
| | | IPage<SkPicCountEntity> page = Condition.getPage(query); |
| | | |
| | | // System.err.println("current:"+current); |
| | | // System.err.println("size:"+size); |
| | | Integer startIndex = (current -1) * size; |
| | | Integer endIndex = current * size; |
| | | |
| | | IPage<SkPicCountEntity> pages = skPanoramaService.selectPageR( page,startIndex, endIndex, skPanorama); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | // @GetMapping("/page") |
| | | // @ApiOperation(value = "分页", notes = "传入skPanorama") |
| | | // public R<IPage<SkPanoramaVO>> page2(SkPanoramaVO skPanorama, Query query) { |
| | | // IPage<SkPanoramaVO> pages = skPanoramaService.selectSkPanoramaPage(Condition.getPage(query), skPanorama); |
| | | // return R.data(pages); |
| | | // } |
| | | |
| | | /** |
| | | * 水库全景图 新增 |
| | |
| | | List<SkPanoramaStateEntity> updateList = new ArrayList<>(); |
| | | List<SkPanoramaStateEntity> addList = new ArrayList<>(); |
| | | if (stateLsit != null && stateLsit.size()>0) { |
| | | // for (SkPanoramaStateEntity item :stateLsit) { |
| | | // Long id = item.getId(); |
| | | // if (id != null) { |
| | | // // 更新 |
| | | // updateList.add(item); |
| | | // } else { |
| | | // // 新增 |
| | | // addList.add(item); |
| | | // } |
| | | // } |
| | | // boolean b = true; |
| | | // if (addList != null) { |
| | | // b = skPanoramaStateService.saveBatch(addList); |
| | | // } |
| | | // if (updateList != null) { |
| | | // b = skPanoramaStateService.saveOrUpdateBatch(updateList); |
| | | // } |
| | | |
| | | boolean b =skPanoramaStateService.saveOrUpdateBatch(stateLsit); |
| | | |
| | | return R.status(b); |
| | |
| | | } |
| | | */ |
| | | |
| | | /** |
| | | * 批量切图 |
| | | * @param ids |
| | | * @return |
| | | * @throws IOException |
| | | * @throws InterruptedException |
| | | * @throws IM4JavaException |
| | | * @throws IllegalAccessException |
| | | */ |
| | | @PostMapping("/cutPicBatch") |
| | | public R cutPicBatch(@RequestParam String ids) throws IOException, InterruptedException, IM4JavaException, IllegalAccessException { |
| | | List<Long> idlist = Func.toLongList(ids); |
| | | if (idlist!= null && idlist.size()>0) { |
| | | for (Long id : idlist ) { |
| | | SkPanoramaEntity entity = skPanoramaService.getById(id); |
| | | Integer status = entity.getStatus(); |
| | | String resGuname = entity.getResGuname(); |
| | | String name = entity.getName(); |
| | | if (PanoramaUtilDict.panorama_status_3 == status) continue; |
| | | R r = cutPicture2(entity); |
| | | boolean success = r.isSuccess(); |
| | | if (!success) { |
| | | return R.fail(resGuname+"-"+name+" 切图失败!"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | return R.status(true); |
| | | } |
| | | |
| | | |
| | | private static final String linShiBaseUrl = "/data/panorama/qietu/"; |
| | | @GetMapping("/cutPicture2") |
| | | public R cutPicture2(SkPanoramaEntity skPanorama) |
| | | throws IOException, InterruptedException, IM4JavaException, IllegalAccessException { |
| | | |
| | | SkPanoramaEntity entity = skPanoramaService.getOne(Condition.getQueryWrapper(skPanorama)); |
| | | SkPanoramaEntity entity = skPanoramaService.getById(skPanorama.getId()); |
| | | String picUrl = entity.getPicUrl(); |
| | | String picName = entity.getPicName(); |
| | | String resGuid = entity.getResGuid(); |
| | |
| | | String dirPath = linShiBaseUrl + resGuid + "/"; //临时文件夹路径 |
| | | String lingshiPic = linShiBaseUrl + resGuid + "/" + picName; //临时文件 |
| | | |
| | | File lingshiqjfile = getquanjingFile(dirPath,lingshiPic,entity); |
| | | File lingshiqjfile = getquanjingFile(dirPath,lingshiPic,entity.getId()); |
| | | |
| | | /** |
| | | * 这里开始切图 |
| | |
| | | /************************************切图结束********************************************/ |
| | | |
| | | // 上传切片全景图 |
| | | System.err.println("切图的路径数量"+qietuHashMap.size()); |
| | | System.err.println("水库编码"+resGuid); |
| | | |
| | | QieTuEntity qieTuEntity = new QieTuEntity(); |
| | | qieTuEntity.setQietuHashMap(qietuHashMap); |
| | |
| | | entity.setUrlhead(urlHead); |
| | | entity.setQierow(row); |
| | | entity.setQiecol(col); |
| | | entity.setPicwidth(width); |
| | | entity.setPicheight(height); |
| | | // entity.setPicwidth(width); |
| | | // entity.setPicheight(height); |
| | | entity.setStatus(PanoramaUtilDict.panorama_status_3); |
| | | skPanoramaService.updateById(entity); |
| | | boolean b = skPanoramaService.updateById(entity); |
| | | |
| | | |
| | | return R.status(true); |
| | | return R.status(b); |
| | | } |
| | | |
| | | private File getquanjingFile (String dirPath ,String linshiUrl , SkPanoramaEntity skPanorama) throws IOException { |
| | | SkPanoramaEntity entity = skPanoramaService.getOne(Condition.getQueryWrapper(skPanorama)); |
| | | private File getquanjingFile (String dirPath ,String linshiUrl , Long id) throws IOException { |
| | | |
| | | // SkPanoramaEntity entity = skPanoramaService.getOne(Condition.getQueryWrapper(skPanorama)); |
| | | SkPanoramaEntity entity = skPanoramaService.getById(id); |
| | | String picUrl = entity.getPicUrl(); |
| | | String picName = entity.getPicName(); |
| | | String resGuid = entity.getResGuid(); |
| | |
| | | File dir = new File(dirPath); |
| | | if (dir.isDirectory()) { |
| | | // 清除该目录下的文件及子目录文件而不删除该目录文件夹。该目录不存在会报错 |
| | | FileUtils.cleanDirectory(dir); |
| | | // FileUtils.cleanDirectory(dir); |
| | | } else { |
| | | dir.mkdirs(); |
| | | } |
| | |
| | | private static final String linShiformateBaseUrl = "/data/panorama/formate/"; |
| | | @PostMapping("/formatePic") |
| | | public R formatePic(@RequestParam String ids) throws IOException, InterruptedException, IM4JavaException { |
| | | System.err.println(ids); |
| | | |
| | | List<Long> idlist = Func.toLongList(ids); |
| | | |
| | | |
| | | ArrayList<SkPanoramaEntity> panoramalist = new ArrayList<SkPanoramaEntity>(); |
| | | |
| | | // 已上传的全景图已符合比例,仅用改变数据状态 |
| | | ArrayList<SkPanoramaEntity> justUpdateStatusList = new ArrayList<SkPanoramaEntity>(); |
| | | |
| | | ArrayList<FormateTuEntity> list = new ArrayList<FormateTuEntity>(); |
| | | |
| | | |
| | | if (idlist!= null && idlist.size()>0) { |
| | | for (Long id : idlist ) { |
| | | FormateTuEntity formateTuEntity = new FormateTuEntity(); |
| | | |
| | | SkPanoramaEntity skPanorama = new SkPanoramaEntity(); |
| | | skPanorama.setId(id); |
| | | SkPanoramaEntity entity = skPanoramaService.getOne(Condition.getQueryWrapper(skPanorama)); |
| | | |
| | | SkPanoramaEntity entity = skPanoramaService.getById(id); |
| | | Integer status = entity.getStatus(); |
| | | if (PanoramaUtilDict.panorama_status_2 == status) continue; |
| | | String picUrl = entity.getPicUrl(); |
| | | String picName = entity.getPicName(); |
| | | String resGuid = entity.getResGuid(); |
| | |
| | | String lingshigeshibilipath = linShiformateBaseUrl + resGuid + "/geshibili/" ; |
| | | String lingshigeshibiliPic = lingshigeshibilipath + picName; //格式化后的临时文件 |
| | | |
| | | File lingshiqjfile = getquanjingFile(dirPath,lingshiPic,entity); |
| | | File lingshiqjfile = getquanjingFile(dirPath,lingshiPic,id); |
| | | |
| | | // 创建文件夹 |
| | | File lingshigeshibilidir = new File(lingshigeshibilipath); |
| | | if (lingshigeshibilidir.isDirectory()) { |
| | | // 清除该目录下的文件及子目录文件而不删除该目录文件夹。该目录不存在会报错 |
| | | FileUtils.cleanDirectory(lingshigeshibilidir); |
| | | // FileUtils.cleanDirectory(lingshigeshibilidir); |
| | | // 批量操作不能清空文件夹下的全部文件 |
| | | } else { |
| | | lingshigeshibilidir.mkdirs(); |
| | | } |
| | |
| | | HashMap<String, Integer> imgInfoRT = Img4JavaUtil.getImgInfoRT(lingshiqjfile); |
| | | Integer width = imgInfoRT.get("width"); |
| | | Integer height = imgInfoRT.get("height"); |
| | | System.err.println(id); |
| | | System.err.println("图片分辨率:"+ width +" * " + height); |
| | | if (width == height * 2) { |
| | | System.err.println("符合标准"); |
| | | // 已经符合格式化标准 |
| | | SkPanoramaEntity upEntity = new SkPanoramaEntity(); |
| | | upEntity.setId(id); |
| | | upEntity.setPicheight(height); |
| | | upEntity.setPicwidth(width); |
| | | upEntity.setStatus(PanoramaUtilDict.panorama_status_2); |
| | | justUpdateStatusList.add(upEntity); |
| | | |
| | | // 完成格式化后删除原始临时图片 |
| | | Path qietuPath = Paths.get(lingshiPic); |
| | | File yuanspic = qietuPath.toFile(); |
| | | if (yuanspic.exists()) { |
| | | // 删除指定文件,不存在报异常 |
| | | FileUtils.forceDelete(yuanspic); |
| | | } |
| | | // boolean b = skPanoramaService.updateById(upEntity); |
| | | // return R.status( b); |
| | | } else { |
| | | Integer newWidth = height * 2; |
| | | // 图片格式化 |
| | |
| | | } |
| | | } |
| | | |
| | | boolean b = skPanoramaService.updateBatchById(panoramalist); |
| | | |
| | | return R.status(true); |
| | | System.err.println("panoramalist:"+panoramalist.size()); |
| | | boolean b = false; |
| | | if (panoramalist != null && panoramalist.size()>0) { |
| | | b = skPanoramaService.updateBatchById(panoramalist); |
| | | } else { |
| | | b = true; |
| | | } |
| | | System.err.println("justUpdateStatusList:"+justUpdateStatusList.size()); |
| | | boolean formatB = false; |
| | | // 已上传的全景图已符合比例,仅用改变数据状态 |
| | | if (justUpdateStatusList != null && justUpdateStatusList.size()>0) { |
| | | formatB = skPanoramaService.updateBatchById(justUpdateStatusList); |
| | | } else { |
| | | formatB = true; |
| | | } |
| | | |
| | | |
| | | return R.status((formatB && b)); |
| | | } |
| | | |
| | | |