|
@@ -4,38 +4,44 @@ import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.io.unit.DataSizeUtil;
|
|
import cn.hutool.core.io.unit.DataSizeUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.fdkankan.fusion.common.util.DateUtils;
|
|
import com.fdkankan.fusion.common.util.DateUtils;
|
|
|
import com.fdkankan.fusion.entity.*;
|
|
import com.fdkankan.fusion.entity.*;
|
|
|
import com.fdkankan.fusion.service.*;
|
|
import com.fdkankan.fusion.service.*;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
|
|
+import io.netty.util.internal.UnstableApi;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
|
|
|
|
|
+import javax.annotation.Detainted;
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
+import java.io.File;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import static com.fdkankan.fusion.down.CaseDownService.downProcessKey;
|
|
import static com.fdkankan.fusion.down.CaseDownService.downProcessKey;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
|
|
+@Slf4j
|
|
|
public class TaskService {
|
|
public class TaskService {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
ICaseLiveService caseLiveService;
|
|
ICaseLiveService caseLiveService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ ICaseSettingsService caseSettingsService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ ICaseFusionService caseFusionService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ ICaseService caseService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ ITmUserService tmUserService;
|
|
|
|
|
|
|
|
- @Scheduled(initialDelay = 2000, fixedDelay = 1000 * 60)
|
|
|
|
|
- public void run() {
|
|
|
|
|
- List<CaseLive> list = caseLiveService.list();
|
|
|
|
|
- for (CaseLive caseLive : list) {
|
|
|
|
|
- Date hoursTime = DateUtils.getHoursTime(caseLive.getCreateTime());
|
|
|
|
|
- if(hoursTime.getTime() <= new Date().getTime()){
|
|
|
|
|
- caseLiveService.removeById(caseLive);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
RedisUtil redisUtil;
|
|
RedisUtil redisUtil;
|
|
@@ -48,65 +54,135 @@ public class TaskService {
|
|
|
redisUtil.del(key);
|
|
redisUtil.del(key);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- //modelToMedia();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ updateFusion();
|
|
|
|
|
+ updateCaseSetting();
|
|
|
|
|
+ updateHotIcon();
|
|
|
|
|
+ updateCaseTag();
|
|
|
|
|
+ updateGuide();
|
|
|
|
|
+ updatePath();
|
|
|
|
|
+ updateAnimation();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void updateFusion(){
|
|
|
|
|
+ List<CaseFusion> list = caseFusionService.list();
|
|
|
|
|
+ List<CaseFusion> collect = list.stream().filter(e -> e.getSysUserId() == null).collect(Collectors.toList());
|
|
|
|
|
+ for (CaseFusion caseFusion : collect) {
|
|
|
|
|
+ CaseEntity caseEntity = caseService.getById(caseFusion.getCaseId());
|
|
|
|
|
+ if(caseEntity != null){
|
|
|
|
|
+ caseFusion.setFusionTitle(caseEntity.getCaseTitle());
|
|
|
|
|
+ caseFusion.setLatAndLong(caseEntity.getLatAndLong());
|
|
|
|
|
+ TmUser tmUser = tmUserService.getByUserName(caseEntity.getUserName());
|
|
|
|
|
+ if(tmUser != null){
|
|
|
|
|
+ caseFusion.setSysUserId(tmUser.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ caseFusionService.updateById(caseFusion);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- IModelService modelService;
|
|
|
|
|
|
|
+ ICaseFilesTypeService caseFilesTypeService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ IHotIconService hotIconService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ IDictService dictService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
ICommonUploadService commonUploadService;
|
|
ICommonUploadService commonUploadService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
IDictFileService dictFileService;
|
|
IDictFileService dictFileService;
|
|
|
- @Autowired
|
|
|
|
|
- ITmUserService tmUserService;
|
|
|
|
|
|
|
|
|
|
- public void modelToMedia(){
|
|
|
|
|
- LambdaQueryWrapper<Model> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- wrapper.eq(Model::getType,3);
|
|
|
|
|
- wrapper.eq(Model::getCreateStatus,1);
|
|
|
|
|
- wrapper.isNotNull(Model::getModelGlbUrl);
|
|
|
|
|
- wrapper.isNotNull(Model::getUserName);
|
|
|
|
|
- List<Model> list = modelService.list(wrapper);
|
|
|
|
|
|
|
|
|
|
|
|
+ private void updateCaseSetting() {
|
|
|
|
|
+ List<CaseSettings> list = caseSettingsService.list();
|
|
|
|
|
+ List<CaseSettings> collect = list.stream().filter(e -> e.getFusionId() == null).collect(Collectors.toList());
|
|
|
|
|
+ for (CaseSettings caseSettings : collect) {
|
|
|
|
|
+ List<CaseFusion> listByCaseId = caseFusionService.getListByCaseId(caseSettings.getCaseId());
|
|
|
|
|
+ if(!listByCaseId.isEmpty()){
|
|
|
|
|
+ LambdaUpdateWrapper<CaseSettings> wrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ wrapper.eq(CaseSettings::getSettingsId,caseSettings.getSettingsId());
|
|
|
|
|
+ wrapper.set(CaseSettings::getFusionId,listByCaseId.get(0).getFusionId());
|
|
|
|
|
+ caseSettingsService.update(wrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void updateHotIcon() {
|
|
|
|
|
+ List<HotIcon> list = hotIconService.list();
|
|
|
|
|
+ List<HotIcon> collect = list.stream().filter(e -> e.getFusionId() == null).collect(Collectors.toList());
|
|
|
|
|
+ for (HotIcon entity : collect) {
|
|
|
|
|
+ List<CaseFusion> listByCaseId = caseFusionService.getListByCaseId(entity.getCaseId());
|
|
|
|
|
+ if(!listByCaseId.isEmpty()){
|
|
|
|
|
+ LambdaUpdateWrapper<HotIcon> wrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ wrapper.eq(HotIcon::getIconId,entity.getIconId());
|
|
|
|
|
+ wrapper.set(HotIcon::getFusionId,listByCaseId.get(0).getFusionId());
|
|
|
|
|
+ hotIconService.update(wrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ ICaseTagService caseTagService;
|
|
|
|
|
+ private void updateCaseTag() {
|
|
|
|
|
+ List<CaseTag> list = caseTagService.list();
|
|
|
|
|
+ List<CaseTag> collect = list.stream().filter(e -> e.getFusionId() == null).collect(Collectors.toList());
|
|
|
|
|
+ for (CaseTag entity : collect) {
|
|
|
|
|
+ List<CaseFusion> listByCaseId = caseFusionService.getListByCaseId(entity.getCaseId());
|
|
|
|
|
+ if(!listByCaseId.isEmpty()){
|
|
|
|
|
+ LambdaUpdateWrapper<CaseTag> wrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ wrapper.eq(CaseTag::getTagId,entity.getTagId());
|
|
|
|
|
+ wrapper.set(CaseTag::getFusionId,listByCaseId.get(0).getFusionId());
|
|
|
|
|
+ caseTagService.update(wrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- for (Model model : list) {
|
|
|
|
|
- TmUser tmUser = tmUserService.getByUserName(model.getUserName());
|
|
|
|
|
- if(tmUser == null){
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ IFusionGuideService fusionGuideService;
|
|
|
|
|
+ private void updateGuide() {
|
|
|
|
|
+ List<FusionGuide> list = fusionGuideService.list();
|
|
|
|
|
+ List<FusionGuide> collect = list.stream().filter(e -> e.getFusionId() == null).collect(Collectors.toList());
|
|
|
|
|
+ for (FusionGuide entity : collect) {
|
|
|
|
|
+ List<CaseFusion> listByCaseId = caseFusionService.getListByCaseId(entity.getCaseId());
|
|
|
|
|
+ if(!listByCaseId.isEmpty()){
|
|
|
|
|
+ LambdaUpdateWrapper<FusionGuide> wrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ wrapper.eq(FusionGuide::getFusionGuideId,entity.getFusionGuideId());
|
|
|
|
|
+ wrapper.set(FusionGuide::getFusionId,listByCaseId.get(0).getFusionId());
|
|
|
|
|
+ fusionGuideService.update(wrapper);
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- String modelGlbUrl = model.getModelGlbUrl();
|
|
|
|
|
- JSONArray jsonArray = JSONArray.parseArray(modelGlbUrl);
|
|
|
|
|
- String fileUrl = (String) jsonArray.get(0);
|
|
|
|
|
|
|
|
|
|
- LambdaQueryWrapper<CommonUpload> wrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
|
- wrapper1.eq(CommonUpload::getFileUrl,fileUrl);
|
|
|
|
|
- List<CommonUpload> list1 = commonUploadService.list(wrapper1);
|
|
|
|
|
- if(!list1.isEmpty()){
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ ICasePathService casePathService;
|
|
|
|
|
+ private void updatePath() {
|
|
|
|
|
+ List<CasePath> list = casePathService.list();
|
|
|
|
|
+ List<CasePath> collect = list.stream().filter(e -> e.getFusionId() == null).collect(Collectors.toList());
|
|
|
|
|
+ for (CasePath entity : collect) {
|
|
|
|
|
+ List<CaseFusion> listByCaseId = caseFusionService.getListByCaseId(entity.getCaseId());
|
|
|
|
|
+ if(!listByCaseId.isEmpty()){
|
|
|
|
|
+ LambdaUpdateWrapper<CasePath> wrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ wrapper.eq(CasePath::getId,entity.getId());
|
|
|
|
|
+ wrapper.set(CasePath::getFusionId,listByCaseId.get(0).getFusionId());
|
|
|
|
|
+ casePathService.update(wrapper);
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- CommonUpload commonUpload = new CommonUpload();
|
|
|
|
|
- commonUpload.setFileName(model.getModelTitle());
|
|
|
|
|
- commonUpload.setFileUrl(fileUrl);
|
|
|
|
|
- commonUpload.setFileSize(String.valueOf(DataSizeUtil.parse(model.getModelSize())));
|
|
|
|
|
- commonUpload.setNewFileName(model.getModelTitle());
|
|
|
|
|
- commonUpload.setFileType(3);
|
|
|
|
|
- commonUpload.setFileTypeStr("模型");
|
|
|
|
|
- commonUpload.setFileFormat(model.getModelDateType());
|
|
|
|
|
- commonUpload.setResultFileFormat(model.getModelType());
|
|
|
|
|
- commonUpload.setStatus(1);
|
|
|
|
|
- commonUpload.setUseType("ordinary");
|
|
|
|
|
- commonUploadService.save(commonUpload);
|
|
|
|
|
-
|
|
|
|
|
- DictFile dictFile = new DictFile();
|
|
|
|
|
- dictFile.setName(model.getModelTitle());
|
|
|
|
|
- dictFile.setTypeKey("media-library");
|
|
|
|
|
- dictFile.setSysUserId(tmUser.getId());
|
|
|
|
|
- dictFile.setUploadId(commonUpload.getId());
|
|
|
|
|
- dictFile.setUseType("ordinary");
|
|
|
|
|
- dictFileService.save(dictFile);
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ ICaseAnimationService caseAnimationService;
|
|
|
|
|
+ private void updateAnimation() {
|
|
|
|
|
+ List<CaseAnimation> list = caseAnimationService.list();
|
|
|
|
|
+ List<CaseAnimation> collect = list.stream().filter(e -> e.getFusionId() == null).collect(Collectors.toList());
|
|
|
|
|
+ for (CaseAnimation entity : collect) {
|
|
|
|
|
+ List<CaseFusion> listByCaseId = caseFusionService.getListByCaseId(entity.getCaseId());
|
|
|
|
|
+ if(!listByCaseId.isEmpty()){
|
|
|
|
|
+ LambdaUpdateWrapper<CaseAnimation> wrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ wrapper.eq(CaseAnimation::getId,entity.getId());
|
|
|
|
|
+ wrapper.set(CaseAnimation::getFusionId,listByCaseId.get(0).getFusionId());
|
|
|
|
|
+ caseAnimationService.update(wrapper);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
+}
|