|
@@ -0,0 +1,139 @@
|
|
|
+package com.fdkankan.fusion.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.common.response.PageInfo;
|
|
|
+import com.fdkankan.common.util.JwtUtil;
|
|
|
+import com.fdkankan.fusion.entity.CaseEntity;
|
|
|
+import com.fdkankan.fusion.mapper.ICaseMapper;
|
|
|
+import com.fdkankan.fusion.request.CaseParam;
|
|
|
+import com.fdkankan.fusion.request.ScenePram;
|
|
|
+import com.fdkankan.fusion.response.HotVo;
|
|
|
+import com.fdkankan.fusion.response.SceneVo;
|
|
|
+import com.fdkankan.fusion.service.ICaseNumService;
|
|
|
+import com.fdkankan.fusion.service.ICaseService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.fusion.service.ISceneService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2022-07-27
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CaseServiceImpl extends ServiceImpl<ICaseMapper, CaseEntity> implements ICaseService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ISceneService sceneService;
|
|
|
+ @Autowired
|
|
|
+ ICaseNumService caseNumService;
|
|
|
+ @Autowired
|
|
|
+ FdHotService fdHotService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo pageList(CaseParam param,String token) {
|
|
|
+ String userName = JwtUtil.getUsername(token);
|
|
|
+ LambdaQueryWrapper<CaseEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ if(StringUtils.isNotBlank(param.getCaseTitle())){
|
|
|
+ wrapper.like(CaseEntity::getCaseTitle,param.getCaseTitle());
|
|
|
+ }
|
|
|
+ wrapper.eq(CaseEntity::getUserName,userName);
|
|
|
+ wrapper.orderByDesc(CaseEntity::getCreateTime);
|
|
|
+ Page<CaseEntity> page = this.page( new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
|
|
|
+ return PageInfo.PageInfo(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<SceneVo> sceneList(CaseParam param, String token) {
|
|
|
+ if(param.getCaseId() == null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ HashMap<Integer, List<String>> typeMap = caseNumService.getTypeMap(param.getCaseId());
|
|
|
+ List<SceneVo> listAll = new ArrayList<>();
|
|
|
+ for (Integer type : typeMap.keySet()) {
|
|
|
+ List<String> numList = typeMap.get(type);
|
|
|
+ if(numList ==null || numList.size() <=0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ScenePram scenePram = new ScenePram();
|
|
|
+ scenePram.setType(type);
|
|
|
+ scenePram.setPageNum(1);
|
|
|
+ scenePram.setPageSize(99999);
|
|
|
+ scenePram.setNumList(typeMap.get(type));
|
|
|
+ PageInfo pageInfo = sceneService.pageList(scenePram,token);
|
|
|
+ List<SceneVo> list1 = (List<SceneVo>) pageInfo.getList();
|
|
|
+ listAll.addAll(list1);
|
|
|
+ }
|
|
|
+ return listAll;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addOrUpdate(CaseParam param, String token) {
|
|
|
+ String userName = JwtUtil.getUsername(token);
|
|
|
+ if(StringUtils.isEmpty(param.getCaseTitle())){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ CaseEntity caseEntity ;
|
|
|
+ if(param.getCaseId() == null){
|
|
|
+ caseEntity = new CaseEntity();
|
|
|
+ caseEntity.setUserName(userName);
|
|
|
+ }else {
|
|
|
+ caseEntity = this.getById(param.getCaseId());
|
|
|
+ }
|
|
|
+ caseEntity.setCaseTitle(param.getCaseTitle());
|
|
|
+ caseEntity.setUpdateTime(null);
|
|
|
+ this.saveOrUpdate(caseEntity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addScene(CaseParam param) {
|
|
|
+ if(param.getCaseId() == null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ CaseEntity caseEntity = this.getById(param.getCaseId());
|
|
|
+ if(caseEntity == null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ caseNumService.addBatch(param.getCaseId(),param.getSceneNumParam());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delete(Integer caseId) {
|
|
|
+ if(caseId == null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ //删除关联的场景
|
|
|
+ caseNumService.deleteByCaseId(caseId);
|
|
|
+
|
|
|
+ this.removeById(caseId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<HotVo> hotList(Integer caseId) {
|
|
|
+ HashMap<Integer, List<String>> typeMap = caseNumService.getTypeMap(caseId);
|
|
|
+ List<HotVo> listAll = new ArrayList<>();
|
|
|
+ for (Integer type : typeMap.keySet()) {
|
|
|
+ List<String> numList = typeMap.get(type);
|
|
|
+ if(numList ==null || numList.size() <=0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<HotVo> hotList = fdHotService.getHotList(numList, type);
|
|
|
+ listAll.addAll(hotList);
|
|
|
+ }
|
|
|
+ return listAll;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|