|
@@ -0,0 +1,95 @@
|
|
|
+package com.fdkankan.fusion.service.impl;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.fdkankan.fusion.common.ResultCode;
|
|
|
+import com.fdkankan.fusion.entity.CaseEntity;
|
|
|
+import com.fdkankan.fusion.entity.CaseLive;
|
|
|
+import com.fdkankan.fusion.entity.CaseNumEntity;
|
|
|
+import com.fdkankan.fusion.exception.BusinessException;
|
|
|
+import com.fdkankan.fusion.httpClient.FdService;
|
|
|
+import com.fdkankan.fusion.httpClient.request.FdRoomAddParam;
|
|
|
+import com.fdkankan.fusion.httpClient.response.FdRoomVo;
|
|
|
+import com.fdkankan.fusion.httpClient.response.FdkkResponse;
|
|
|
+import com.fdkankan.fusion.mapper.ICaseLiveMapper;
|
|
|
+import com.fdkankan.fusion.service.ICaseLiveService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.fusion.service.ICaseNumService;
|
|
|
+import com.fdkankan.fusion.service.ICaseService;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.collections4.ListUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2023-08-10
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CaseLiveServiceImpl extends ServiceImpl<ICaseLiveMapper, CaseLive> implements ICaseLiveService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ FdService fdService;
|
|
|
+ @Autowired
|
|
|
+ ICaseNumService caseNumService;
|
|
|
+ @Autowired
|
|
|
+ ICaseService caseService;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getByCaseId(Integer caseId) {
|
|
|
+
|
|
|
+ CaseEntity caseEntity = caseService.getById(caseId);
|
|
|
+ if(caseEntity == null ){
|
|
|
+ throw new BusinessException(ResultCode.CASE_NOT_EXITS);
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<CaseLive> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(CaseLive::getCaseId,caseId);
|
|
|
+ wrapper.eq(CaseLive::getTmUserId, StpUtil.getLoginId());
|
|
|
+ CaseLive caseLive = this.getOne(wrapper);
|
|
|
+ List<CaseNumEntity> caseNumEntities = caseNumService.getByCaseId(caseId);
|
|
|
+ if(caseNumEntities == null || caseNumEntities.size() <=0 ){
|
|
|
+ throw new BusinessException(ResultCode.PROJECT_SCENE_NOT_EXITS);
|
|
|
+ }
|
|
|
+ List<String> numList = caseNumEntities.stream().map(CaseNumEntity::getNum).collect(Collectors.toList());
|
|
|
+ if(caseLive == null){
|
|
|
+ caseLive = new CaseLive();
|
|
|
+ caseLive.setCaseId(caseId);
|
|
|
+ caseLive.setTmUserId((String)StpUtil.getLoginId() );
|
|
|
+ }
|
|
|
+ Boolean flag = this.getCheckCreateRoom(caseLive.getNumList(),numList);
|
|
|
+ if(flag){
|
|
|
+ FdkkResponse<FdRoomAddParam> fdkkResponse = fdService.fdCreateTakeLookRoom(caseEntity.getCaseTitle(),numList,caseLive.getTakeRoomId());
|
|
|
+ if(fdkkResponse.getCode() != 0){
|
|
|
+ throw new BusinessException(fdkkResponse.getCode(),fdkkResponse.getMsg());
|
|
|
+ }
|
|
|
+ caseLive.setTakeRoomId(fdkkResponse.getData().getRoomId());
|
|
|
+ List<String> numList1 = fdkkResponse.getData().getNumList();
|
|
|
+ caseLive.setNumList(JSONArray.parseArray(JSON.toJSONString(numList1)));
|
|
|
+ this.saveOrUpdate(caseLive);
|
|
|
+ }
|
|
|
+ return caseLive.getTakeRoomId();
|
|
|
+ }
|
|
|
+
|
|
|
+ private Boolean getCheckCreateRoom(JSONArray array,List<String> numList) {
|
|
|
+ if(array == null || array.isEmpty() ){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ //List<String> list = JSONObject.parseArray(array.toJSONString(), String.class);
|
|
|
+ List<String> lists = array.toJavaList(String.class);
|
|
|
+ return CollectionUtils.isEqualCollection(lists,numList);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|