feat: 体系搜索树接口
This commit is contained in:
+1
-1
@@ -91,7 +91,7 @@ public class SarMenuStandardNewController extends BaseController<SarMenuStandard
|
||||
}
|
||||
|
||||
@ApiOperation("体系搜索三层树")
|
||||
@DeleteMapping("/standardSystemTree")
|
||||
@GetMapping("/standardSystemTree")
|
||||
public ResponseMessage<?> standardSystemTree() {
|
||||
return Result.success(iSarMenuStandardNewService.standardSystemTree());
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,5 +30,5 @@ public interface ISarMenuStandardNewService extends IService<SarMenuStandardNew>
|
||||
|
||||
SarMenuStandard getMenuStandardById(String menuId);
|
||||
|
||||
Object standardSystemTree();
|
||||
List<SarMenuStandard> standardSystemTree();
|
||||
}
|
||||
|
||||
+39
-4
@@ -7,10 +7,13 @@ import com.adc.da.slrs.sarMenuStandard.entity.SarMenuStandardNew;
|
||||
import com.adc.da.slrs.sarMenuStandard.service.ISarMenuStandardNewService;
|
||||
import com.adc.da.slrs.sarResource.dao.TsResourceDao;
|
||||
import com.adc.da.slrs.sarRole.dao.TsRoleDao;
|
||||
import com.adc.da.slrs.sarStandMenu.dao.SarStandMenuDao;
|
||||
import com.adc.da.slrs.sarStandMenu.entity.SarStandMenu;
|
||||
import com.adc.da.slrs.sarStandMenu.service.ISarStandMenuService;
|
||||
import com.adc.da.sys.sarMenuStandard.dao.SarMenuStandardDao;
|
||||
import com.adc.da.sys.sarMenuStandard.entity.SarMenuStandard;
|
||||
import com.adc.da.sys.sarMenuStandard.entity.StandMenuRelation;
|
||||
import com.adc.da.sys.util.BeanCopyUtils;
|
||||
import com.adc.da.util.LoginUserUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -49,6 +52,8 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl<SarMenuStandar
|
||||
private ISarStandMenuService sarStandMenuService;
|
||||
@Resource
|
||||
private ISarBussStandMenuService sarBussStandMenuService;
|
||||
@Resource
|
||||
private SarStandMenuDao sarStandMenuDao;
|
||||
|
||||
@Override
|
||||
public String getTopMenu(SarMenuStandardNew sarMenuStandardNew){
|
||||
@@ -124,11 +129,41 @@ public class SarMenuStandardNewServiceNewImpl extends ServiceImpl<SarMenuStandar
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object standardSystemTree() {
|
||||
// 构造三层数
|
||||
public List<SarMenuStandard> standardSystemTree() {
|
||||
// 构造树
|
||||
List<SarMenuStandard> TsResources;
|
||||
QueryWrapper<SarMenuStandard> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("DIC_ID", "9m4qqqaansxmox5e82zm");
|
||||
queryWrapper.eq("VALID_FLAG", 0);
|
||||
queryWrapper.isNull("PARENT_ID");
|
||||
queryWrapper.orderByAsc("DISPLAY_SEQ");
|
||||
TsResources = dao.selectList(queryWrapper);
|
||||
|
||||
// 查询数据
|
||||
return null;
|
||||
for (SarMenuStandard resource : TsResources) {
|
||||
resource.setTreeType("sarMs");
|
||||
QueryWrapper<SarMenuStandard> TsResourceQueryWrapper = new QueryWrapper<>();
|
||||
TsResourceQueryWrapper.like("PARENT_IDS", resource.getId());
|
||||
TsResourceQueryWrapper.eq("VALID_FLAG", 0);
|
||||
TsResourceQueryWrapper.orderByAsc("DISPLAY_SEQ");
|
||||
List<SarMenuStandard> children = dao.selectList(TsResourceQueryWrapper);
|
||||
resource.setChildren(recursionGetListChildrenStand((resource), (children)));
|
||||
}
|
||||
// 把所有关联表中的数据拉出来
|
||||
// 国标
|
||||
List<SarStandMenu> gbStandMenu = sarStandMenuDao.getGBStandMenu().stream().filter(sarStandMenu -> sarStandMenu.getMenuId().length() > 30).collect(Collectors.toList());
|
||||
List<StandMenuRelation> gbRelations = BeanCopyUtils.copyBeanList(gbStandMenu, StandMenuRelation.class);
|
||||
|
||||
// 外标
|
||||
List<SarStandMenu> fbStandMenu = sarStandMenuDao.getFBStandMenu().stream().filter(sarStandMenu -> sarStandMenu.getMenuId().length() > 30).collect(Collectors.toList());
|
||||
List<StandMenuRelation> fbRelations = BeanCopyUtils.copyBeanList(fbStandMenu, StandMenuRelation.class);
|
||||
|
||||
// 企标
|
||||
List<SarBussStandMenu> esStandMenu = sarBussStandMenuService.list().stream().filter(sarBussStandMenu -> sarBussStandMenu.getMenuId().length() > 30).collect(Collectors.toList());
|
||||
List<StandMenuRelation> esRelations = BeanCopyUtils.copyBeanList(esStandMenu, StandMenuRelation.class);
|
||||
// 计算每个节点的数值
|
||||
TsResources.get(0).calculateAndSetCounts(gbRelations, fbRelations, esRelations);
|
||||
// 拼接返回
|
||||
return TsResources;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,4 +31,8 @@ public interface SarStandMenuDao extends BaseMapper<SarStandMenu> {
|
||||
|
||||
List<SarStandMenu> getMenuByStandId(SarStandMenu sarStandMenu);
|
||||
|
||||
List<SarStandMenu> getGBStandMenu();
|
||||
|
||||
List<SarStandMenu> getFBStandMenu();
|
||||
|
||||
}
|
||||
|
||||
@@ -144,5 +144,17 @@
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getGBStandMenu" resultType="com.adc.da.slrs.sarStandMenu.entity.SarStandMenu">
|
||||
select sm.MENU_ID, sm.STAND_ID from SAR_STAND_MENU AS sm
|
||||
LEFT JOIN sar_standards_info AS stand ON sm.STAND_ID = stand.ID
|
||||
where stand.STAND_TYPE = 'INLAND'
|
||||
</select>
|
||||
|
||||
<select id="getFBStandMenu" resultType="com.adc.da.slrs.sarStandMenu.entity.SarStandMenu">
|
||||
select sm.MENU_ID, sm.STAND_ID from SAR_STAND_MENU AS sm
|
||||
LEFT JOIN sar_standards_info AS stand ON sm.STAND_ID = stand.ID
|
||||
where stand.STAND_TYPE = 'FOREIGN'
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -107,4 +107,38 @@ public class SarMenuStandard extends BaseEntity {
|
||||
@TableField(exist = false)
|
||||
private String treeType;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer gbStandCount;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer fbStandCount;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer esStandCount;
|
||||
|
||||
// 添加用于计算和设置关联关系数量的方法
|
||||
// 添加用于计算和设置关联关系数量的方法
|
||||
public void calculateAndSetCounts(List<StandMenuRelation> gbStandMenu, List<StandMenuRelation> fbStandMenu, List<StandMenuRelation> esStandMenu) {
|
||||
this.gbStandCount = countMatches(gbStandMenu, this.id);
|
||||
this.fbStandCount = countMatches(fbStandMenu, this.id);
|
||||
this.esStandCount = countMatches(esStandMenu, this.id);
|
||||
|
||||
for (SarMenuStandard child : children) {
|
||||
child.calculateAndSetCounts(gbStandMenu, fbStandMenu, esStandMenu);
|
||||
this.gbStandCount += child.gbStandCount;
|
||||
this.fbStandCount += child.fbStandCount;
|
||||
this.esStandCount += child.esStandCount;
|
||||
}
|
||||
}
|
||||
|
||||
private int countMatches(List<StandMenuRelation> standMenuList, String menuId) {
|
||||
int count = 0;
|
||||
// 计算与menuId匹配的项的数量
|
||||
for (StandMenuRelation standMenu : standMenuList) {
|
||||
if (standMenu.getMenuId().equals(menuId)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.adc.da.sys.sarMenuStandard.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: Mzaxd
|
||||
* @Date: 2023/11/14 16:31
|
||||
*/
|
||||
@Data
|
||||
public class StandMenuRelation {
|
||||
|
||||
private String standId;
|
||||
|
||||
private String menuId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.adc.da.sys.util;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
* @since 2022-11-22 15:36
|
||||
*/
|
||||
public class BeanCopyUtils {
|
||||
|
||||
private BeanCopyUtils() {
|
||||
}
|
||||
|
||||
public static <V> V copyBean(Object source, Class<V> clazz){
|
||||
V result = null;
|
||||
//创建目标对象
|
||||
try {
|
||||
result = clazz.newInstance();
|
||||
//实现属性copy
|
||||
BeanUtils.copyProperties(source, result);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//返回结果
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <O,V> List<V> copyBeanList(List<O> list, Class<V> clazz) {
|
||||
return list.stream()
|
||||
.map(o -> copyBean(o, clazz))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user