|
|
@ -8,16 +8,22 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.huoran.iasf.common.utils.R; |
|
|
|
import com.huoran.iasf.common.utils.R; |
|
|
|
import com.huoran.iasf.entity.SysColumn; |
|
|
|
import com.huoran.iasf.entity.SysColumn; |
|
|
|
|
|
|
|
import com.huoran.iasf.entity.SysFloatingColumnSchemeScopeOfApplication; |
|
|
|
import com.huoran.iasf.entity.SysFooterSetup; |
|
|
|
import com.huoran.iasf.entity.SysFooterSetup; |
|
|
|
import com.huoran.iasf.entity.SysFooterSetupScopeOfApplication; |
|
|
|
import com.huoran.iasf.entity.SysFooterSetupScopeOfApplication; |
|
|
|
import com.huoran.iasf.mapper.SysColumnMapper; |
|
|
|
import com.huoran.iasf.mapper.SysColumnMapper; |
|
|
|
import com.huoran.iasf.mapper.SysFooterSetupMapper; |
|
|
|
import com.huoran.iasf.mapper.SysFooterSetupMapper; |
|
|
|
import com.huoran.iasf.mapper.SysFooterSetupScopeOfApplicationMapper; |
|
|
|
import com.huoran.iasf.mapper.SysFooterSetupScopeOfApplicationMapper; |
|
|
|
import com.huoran.iasf.service.SysFooterSetupService; |
|
|
|
import com.huoran.iasf.service.SysFooterSetupService; |
|
|
|
|
|
|
|
import com.huoran.iasf.vo.ConflictCheckResultVO; |
|
|
|
import com.huoran.iasf.vo.FooterListVO; |
|
|
|
import com.huoran.iasf.vo.FooterListVO; |
|
|
|
|
|
|
|
import com.huoran.iasf.vo.SysFloatingColumnSchemeScopeOfApplicationWithSiteIdVO; |
|
|
|
|
|
|
|
import com.huoran.iasf.vo.SysPageFooterScopeOfApplicationWithSiteIdVO; |
|
|
|
import com.huoran.iasf.vo.req.SuspensionBarListPagingReq; |
|
|
|
import com.huoran.iasf.vo.req.SuspensionBarListPagingReq; |
|
|
|
|
|
|
|
import org.apache.commons.lang3.math.NumberUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
@ -127,6 +133,80 @@ public class SysFooterSetupServiceImpl extends ServiceImpl<SysFooterSetupMapper, |
|
|
|
return R.success(Collections.emptyList()); |
|
|
|
return R.success(Collections.emptyList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* @Override |
|
|
|
|
|
|
|
public ConflictCheckResultVO preCheckMultiScopeConflictBeforeUpdate(Integer siteId, List<SysFooterSetupScopeOfApplication> updatedScopes, Integer floatingBarSchemeId) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(readOnly = true) |
|
|
|
|
|
|
|
public ConflictCheckResultVO preCheckMultiScopeConflictBeforeUpdate( |
|
|
|
|
|
|
|
Integer siteId, List<SysFooterSetupScopeOfApplication> updatedScopes, Integer floatingBarSchemeId) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 收集待更新方案的ID,用于排除这些方案在冲突检测中的干扰
|
|
|
|
|
|
|
|
List<String> excludeSchemeIds = updatedScopes.stream() |
|
|
|
|
|
|
|
.map(SysFooterSetupScopeOfApplication::getApplicationScopeId) |
|
|
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 从数据库查询该站点下所有启用的悬浮栏方案,但排除掉当前正在更新的那些方案
|
|
|
|
|
|
|
|
List<SysPageFooterScopeOfApplicationWithSiteIdVO> enabledScopes = |
|
|
|
|
|
|
|
baseMapper.selectEnabledScopesForMultiConflictCheck(siteId, excludeSchemeIds,floatingBarSchemeId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化冲突标记为false,并准备一个StringBuilder用于记录冲突信息
|
|
|
|
|
|
|
|
boolean hasConflict = false; |
|
|
|
|
|
|
|
StringBuilder conflictMessageBuilder = new StringBuilder(); |
|
|
|
|
|
|
|
Set<String> conflictColumnNames = new HashSet<>(); // 用于存储所有冲突的栏目名称
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 对比每个待更新的方案与已启用方案,检测应用范围是否有重叠
|
|
|
|
|
|
|
|
for (SysPageFooterScopeOfApplicationWithSiteIdVO existingScope : enabledScopes) { |
|
|
|
|
|
|
|
for (SysFooterSetupScopeOfApplication newScope : updatedScopes) { |
|
|
|
|
|
|
|
// 分割应用范围ID为集合,以便逐个比较
|
|
|
|
|
|
|
|
Set<Integer> existingScopeIds = Arrays.stream(existingScope.getApplicationScopeId().split(",")) |
|
|
|
|
|
|
|
.map(String::trim) |
|
|
|
|
|
|
|
.filter(id -> !id.isEmpty() && NumberUtils.isCreatable(id)) |
|
|
|
|
|
|
|
.map(Integer::parseInt) |
|
|
|
|
|
|
|
.collect(Collectors.toSet()); |
|
|
|
|
|
|
|
Set<Integer> newScopeIds = Arrays.stream(newScope.getApplicationScopeId().split(",")) |
|
|
|
|
|
|
|
.map(String::trim) |
|
|
|
|
|
|
|
.filter(id -> !id.isEmpty() && NumberUtils.isCreatable(id)) |
|
|
|
|
|
|
|
.map(Integer::parseInt) |
|
|
|
|
|
|
|
.collect(Collectors.toSet()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 找出重叠的范围ID
|
|
|
|
|
|
|
|
Set<Integer> overlapIds = new HashSet<>(existingScopeIds); |
|
|
|
|
|
|
|
overlapIds.retainAll(newScopeIds); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 避免重复处理相同的冲突范围
|
|
|
|
|
|
|
|
if (!overlapIds.isEmpty()) { |
|
|
|
|
|
|
|
for (Integer overlapId : overlapIds) { |
|
|
|
|
|
|
|
String columnName = getColumnNameById(String.valueOf(overlapId)); // 假设这是获取栏目名称的方法
|
|
|
|
|
|
|
|
conflictColumnNames.add(columnName); // 收集冲突的栏目名称
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 构建最终的冲突信息,如果存在冲突
|
|
|
|
|
|
|
|
if (!conflictColumnNames.isEmpty()) { |
|
|
|
|
|
|
|
hasConflict = true; |
|
|
|
|
|
|
|
conflictMessageBuilder.append("栏目:"); |
|
|
|
|
|
|
|
boolean isFirst = true; |
|
|
|
|
|
|
|
for (String columnName : conflictColumnNames) { |
|
|
|
|
|
|
|
if (!isFirst) { |
|
|
|
|
|
|
|
conflictMessageBuilder.append("、"); // 使用中文逗号作为分隔符
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
conflictMessageBuilder.append(columnName); |
|
|
|
|
|
|
|
isFirst = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
conflictMessageBuilder.append(" 已设置有页脚,请先移除相关设置再尝试启用。\n"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 4. 根据检测结果创建并返回ConflictCheckResult对象
|
|
|
|
|
|
|
|
return new ConflictCheckResultVO(hasConflict, conflictMessageBuilder.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getColumnNameById(String overlapId) { |
|
|
|
|
|
|
|
return columnMapper.getColumnNamesById(overlapId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 检查当前悬浮栏方案与已启用方案是否有重叠。 |
|
|
|
* 检查当前悬浮栏方案与已启用方案是否有重叠。 |
|
|
|