|
@@ -1,13 +1,32 @@
|
|
|
package com.fdkankan.fusion.service.impl;
|
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.fdkankan.fusion.common.FilePath;
|
|
|
+import com.fdkankan.fusion.common.ResultCode;
|
|
|
+import com.fdkankan.fusion.common.util.UploadToOssUtil;
|
|
|
+import com.fdkankan.fusion.config.SecurityUtil;
|
|
|
+import com.fdkankan.fusion.entity.CaseFiles;
|
|
|
import com.fdkankan.fusion.entity.CaseOverview;
|
|
|
+import com.fdkankan.fusion.entity.CaseTabulation;
|
|
|
+import com.fdkankan.fusion.exception.BusinessException;
|
|
|
import com.fdkankan.fusion.mapper.ICaseOverviewMapper;
|
|
|
+import com.fdkankan.fusion.request.ExportOverviewParam;
|
|
|
+import com.fdkankan.fusion.service.ICaseFilesService;
|
|
|
import com.fdkankan.fusion.service.ICaseOverviewService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.fusion.service.ICaseTabulationService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -19,9 +38,16 @@ import java.util.List;
|
|
|
* @since 2025-05-13
|
|
|
*/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class CaseOverviewServiceImpl extends ServiceImpl<ICaseOverviewMapper, CaseOverview> implements ICaseOverviewService {
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ICaseFilesService caseFilesService;
|
|
|
+ @Autowired
|
|
|
+ ICaseTabulationService caseTabulationService;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public List<CaseOverview> getByCaseId(String caseId) {
|
|
|
LambdaQueryWrapper<CaseOverview> wrapper = new LambdaQueryWrapper<>();
|
|
@@ -39,6 +65,22 @@ public class CaseOverviewServiceImpl extends ServiceImpl<ICaseOverviewMapper, Ca
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void updateCaseByIds(List<Integer> overviewIds, Integer caseId) {
|
|
|
+ LambdaUpdateWrapper<CaseOverview> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.in(CaseOverview::getId,overviewIds);
|
|
|
+ wrapper.set(CaseOverview::getCaseId,caseId);
|
|
|
+ this.update(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateListCoverById(Integer overviewId, String listCover) {
|
|
|
+ LambdaUpdateWrapper<CaseOverview> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(CaseOverview::getId,overviewId);
|
|
|
+ wrapper.set(CaseOverview::getListCover,listCover);
|
|
|
+ this.update(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public CaseOverview getByNumAndSubGroup(String num, Integer subGroup) {
|
|
|
LambdaQueryWrapper<CaseOverview> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(CaseOverview::getNum,num);
|
|
@@ -50,4 +92,98 @@ public class CaseOverviewServiceImpl extends ServiceImpl<ICaseOverviewMapper, Ca
|
|
|
return list.get(0);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Long getNo(Integer sysUserId) {
|
|
|
+ LambdaUpdateWrapper<CaseOverview> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(CaseOverview::getSysUserId,sysUserId);
|
|
|
+ return this.count(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void export(ExportOverviewParam param) {
|
|
|
+ if(!param.getOverviewIds().isEmpty()){
|
|
|
+ List<CaseOverview> caseOverviews = this.listByIds(param.getOverviewIds());
|
|
|
+ for (CaseOverview caseOverview : caseOverviews) {
|
|
|
+ Integer tabulationId = null;
|
|
|
+ List<CaseTabulation> byOverviewId = caseTabulationService.getByOverviewId(String.valueOf(caseOverview.getId()));
|
|
|
+ for (CaseTabulation caseTabulation : byOverviewId) {
|
|
|
+ tabulationId = caseTabulation.getId();
|
|
|
+ }
|
|
|
+ CaseFiles caseFiles = new CaseFiles();
|
|
|
+ caseFiles.setCaseId(param.getCaseId());
|
|
|
+ caseFiles.setFilesUrl(caseOverview.getListCover());
|
|
|
+ caseFiles.setFilesTypeId(41);
|
|
|
+ caseFiles.setFilesTitle(caseOverview.getTitle());
|
|
|
+ caseFiles.setOverviewId(caseOverview.getId());
|
|
|
+ caseFiles.setTabulationId(tabulationId);
|
|
|
+ caseFilesService.saveOrUpdate(caseFiles);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!param.getTabulationIds().isEmpty()){
|
|
|
+ List<CaseTabulation> caseTabulationList = caseTabulationService.listByIds(param.getTabulationIds());
|
|
|
+ for (CaseTabulation caseTabulation : caseTabulationList) {
|
|
|
+ CaseFiles caseFiles = new CaseFiles();
|
|
|
+ caseFiles.setCaseId(param.getCaseId());
|
|
|
+ caseFiles.setFilesUrl(caseTabulation.getListCover());
|
|
|
+ caseFiles.setFilesTypeId(42);
|
|
|
+ caseFiles.setFilesTitle(caseTabulation.getTitle());
|
|
|
+ caseFiles.setTabulationId(caseTabulation.getId());
|
|
|
+ caseFilesService.saveOrUpdate(caseFiles);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UploadToOssUtil uploadToOssUtil;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void toMeshEdit(String num, Integer subGroup, String listCover) {
|
|
|
+ String filePath = String.format(FilePath.MESH_SCENE_FLOOR_PNG_PATH,num);
|
|
|
+ String fileName = String.format(FilePath.MESH_SCENE_FLOOR_PNG_PATH_NAME,subGroup);
|
|
|
+ String jsonPathSource = String.format(FilePath.MESH_SCENE_FLOOR_JSON_PATH_SOURCE,num);
|
|
|
+ String jsonPath = String.format(FilePath.MESH_SCENE_FLOOR_JSON_PATH,num);
|
|
|
+ String localPath = String.format(FilePath.MESH_SCENE_FLOOR_JSON_PATH_LOCAL,num);
|
|
|
+ try {
|
|
|
+ uploadToOssUtil.copyFile(uploadToOssUtil.getOssPath(listCover),filePath + fileName);
|
|
|
+
|
|
|
+ String content = uploadToOssUtil.readFile(jsonPathSource);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
+ JSONArray jsonArray = jsonObject.getJSONArray("floors");
|
|
|
+ for (Object object : jsonArray) {
|
|
|
+ JSONObject obj = (JSONObject) object;
|
|
|
+ Integer subgroupjs = obj.getInteger("subgroup");
|
|
|
+ if(subgroupjs.equals(subGroup)){
|
|
|
+ obj.put("filename",fileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ FileUtil.writeString(jsonObject.toJSONString(),new File(localPath), StandardCharsets.UTF_8);
|
|
|
+ uploadToOssUtil.uploadOss(localPath,jsonPath);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.info("同步mesh编辑器失败:{}",e);
|
|
|
+ }finally {
|
|
|
+ FileUtil.del(localPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void checkLoginUser(CaseOverview caseOverview, CaseTabulation caseTabulation) {
|
|
|
+ if(caseOverview == null && caseTabulation == null){
|
|
|
+ throw new BusinessException(ResultCode.RECORD_NOT_EXIST);
|
|
|
+ }
|
|
|
+ Integer loginUserId = Integer.valueOf(StpUtil.getLoginId().toString());
|
|
|
+ if(caseOverview != null){
|
|
|
+ if(!caseOverview.getSysUserId().equals(loginUserId)){
|
|
|
+ throw new BusinessException(ResultCode.NOT_PER);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(caseTabulation != null){
|
|
|
+ if(!caseTabulation.getSysUserId().equals(loginUserId)){
|
|
|
+ throw new BusinessException(ResultCode.NOT_PER);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|