|
|
@@ -1,35 +1,39 @@
|
|
|
package com.xjrsoft.module.asset.controller;
|
|
|
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.xjrsoft.common.constant.GlobalConstant;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
import com.xjrsoft.common.page.PageOutput;
|
|
|
-import com.xjrsoft.common.model.result.RT;
|
|
|
+import com.xjrsoft.common.utils.TreeUtil;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.module.asset.dto.AddWfAssetManageDto;
|
|
|
import com.xjrsoft.module.asset.dto.UpdateWfAssetManageDto;
|
|
|
-import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
-
|
|
|
import com.xjrsoft.module.asset.dto.WfAssetManagePageDto;
|
|
|
import com.xjrsoft.module.asset.entity.WfAssetManage;
|
|
|
import com.xjrsoft.module.asset.service.IWfAssetManageService;
|
|
|
+import com.xjrsoft.module.asset.vo.BaseOfficeBuildVo;
|
|
|
+import com.xjrsoft.module.asset.vo.PlaceTreeVo;
|
|
|
import com.xjrsoft.module.asset.vo.WfAssetManagePageVo;
|
|
|
-
|
|
|
import com.xjrsoft.module.asset.vo.WfAssetManageVo;
|
|
|
+import com.xjrsoft.module.base.entity.BaseClassroom;
|
|
|
+import com.xjrsoft.module.base.entity.BaseOfficeBuild;
|
|
|
+import com.xjrsoft.module.base.service.IBaseClassroomService;
|
|
|
+import com.xjrsoft.module.base.service.IBaseOfficeBuildService;
|
|
|
+import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
-import javax.validation.constraints.NotNull;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @title: 资产管理
|
|
|
@@ -46,16 +50,113 @@ public class WfAssetManageController {
|
|
|
|
|
|
private final IWfAssetManageService wfAssetManageService;
|
|
|
|
|
|
+ private final IBaseOfficeBuildService baseOfficeBuildService;
|
|
|
+
|
|
|
+ private final IBaseClassroomService baseClassroomService;
|
|
|
+
|
|
|
+ @GetMapping(value = "/buildingfloorclassroomtree")
|
|
|
+ @ApiOperation(value = "楼栋楼层教室树")
|
|
|
+ @SaCheckPermission("studentmanager:detail")
|
|
|
+ public RT<List<PlaceTreeVo>> buildingFloorClassroomTree() {
|
|
|
+ List<PlaceTreeVo> voList = new ArrayList<>();
|
|
|
+ long customUniqueId = 101010;
|
|
|
+
|
|
|
+ //获取楼栋信息记录
|
|
|
+ MPJLambdaWrapper<BaseOfficeBuild> baseOfficeBuildMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ baseOfficeBuildMPJLambdaWrapper
|
|
|
+ .select(BaseOfficeBuild::getId)
|
|
|
+ .selectAs(DictionaryDetail::getName, BaseOfficeBuildVo::getBuildTypeCn)
|
|
|
+ .select(BaseOfficeBuild.class,x -> VoToColumnUtil.fieldsToColumns(BaseOfficeBuildVo.class).contains(x.getProperty()))
|
|
|
+ .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, BaseOfficeBuild::getBuildType)
|
|
|
+ ;
|
|
|
+
|
|
|
+ List<BaseOfficeBuildVo> baseOfficeBuildVoList = baseOfficeBuildService.selectJoinList(BaseOfficeBuildVo.class, baseOfficeBuildMPJLambdaWrapper);
|
|
|
+
|
|
|
+ Map<String, List<BaseOfficeBuildVo>> officeBuildByAddress = baseOfficeBuildVoList.stream().collect(Collectors.groupingBy(BaseOfficeBuildVo::getAddress));
|
|
|
+
|
|
|
+ for (Map.Entry<String, List<BaseOfficeBuildVo>> entry : officeBuildByAddress.entrySet()){
|
|
|
+ String key = entry.getKey();
|
|
|
+ List<BaseOfficeBuildVo> value = entry.getValue();
|
|
|
+
|
|
|
+ voList.add(new PlaceTreeVo(){{
|
|
|
+ setId(8888L);
|
|
|
+ setName(key);
|
|
|
+ }});
|
|
|
+
|
|
|
+ if(!value.isEmpty()){
|
|
|
+ Map<String, List<BaseOfficeBuildVo>> officeBuildByType = value.stream().collect(Collectors.groupingBy(BaseOfficeBuildVo::getBuildType));
|
|
|
+ for (Map.Entry<String, List<BaseOfficeBuildVo>> e : officeBuildByType.entrySet()){
|
|
|
+ String k = e.getKey();
|
|
|
+ List<BaseOfficeBuildVo> v = e.getValue();
|
|
|
+
|
|
|
+ PlaceTreeVo placeTreeVo = new PlaceTreeVo();
|
|
|
+ placeTreeVo.setId(customUniqueId);
|
|
|
+ if(!v.isEmpty() && v.get(0) != null){
|
|
|
+ placeTreeVo.setName(v.get(0).getBuildTypeCn());
|
|
|
+ }
|
|
|
+ placeTreeVo.setParentId(8888L);
|
|
|
+ voList.add(placeTreeVo);
|
|
|
+
|
|
|
+ if(!v.isEmpty()){
|
|
|
+ for (BaseOfficeBuildVo baseOfficeBuildVo : v){
|
|
|
+ PlaceTreeVo p = new PlaceTreeVo();
|
|
|
+ p.setId(baseOfficeBuildVo.getId());
|
|
|
+ p.setName(baseOfficeBuildVo.getName());
|
|
|
+ p.setParentId(customUniqueId);
|
|
|
+ voList.add(p);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ customUniqueId++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取教室信息
|
|
|
+ List<BaseClassroom> baseClassroomList = baseClassroomService.list();
|
|
|
+
|
|
|
+ Map<Long, List<BaseClassroom>> baseClassroomMap = baseClassroomList.stream().collect(Collectors.groupingBy(BaseClassroom::getOfficeBuildId));
|
|
|
+ for (Map.Entry<Long, List<BaseClassroom>> entry : baseClassroomMap.entrySet()){
|
|
|
+ Long key = entry.getKey();
|
|
|
+ List<BaseClassroom> value = entry.getValue();
|
|
|
+
|
|
|
+ if(!value.isEmpty()){
|
|
|
+ Map<Integer, List<BaseClassroom>> baseClassroomByFloorNum = value.stream().collect(Collectors.groupingBy(BaseClassroom::getFloorNum));
|
|
|
+ for (Map.Entry<Integer, List<BaseClassroom>> e : baseClassroomByFloorNum.entrySet()){
|
|
|
+ Integer k = e.getKey();
|
|
|
+ List<BaseClassroom> v = e.getValue();
|
|
|
+
|
|
|
+ PlaceTreeVo placeTreeVo = new PlaceTreeVo();
|
|
|
+ placeTreeVo.setId(customUniqueId);
|
|
|
+ placeTreeVo.setName(k + "楼");
|
|
|
+ placeTreeVo.setParentId(key);
|
|
|
+ voList.add(placeTreeVo);
|
|
|
+
|
|
|
+ if(!v.isEmpty()){
|
|
|
+ for (BaseClassroom baseClassroom : v){
|
|
|
+ PlaceTreeVo p = new PlaceTreeVo();
|
|
|
+ p.setId(baseClassroom.getId());
|
|
|
+ p.setName(baseClassroom.getName());
|
|
|
+ p.setParentId(customUniqueId);
|
|
|
+ voList.add(p);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ customUniqueId++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<PlaceTreeVo> treeVoList = TreeUtil.build(voList);
|
|
|
+
|
|
|
+ return RT.ok(treeVoList);
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping(value = "/page")
|
|
|
@ApiOperation(value="资产管理列表(分页)")
|
|
|
@SaCheckPermission("wfassetmanage:detail")
|
|
|
public RT<PageOutput<WfAssetManagePageVo>> page(@Valid WfAssetManagePageDto dto){
|
|
|
-
|
|
|
- LambdaQueryWrapper<WfAssetManage> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper
|
|
|
- .orderByDesc(WfAssetManage::getId)
|
|
|
- .select(WfAssetManage.class,x -> VoToColumnUtil.fieldsToColumns(WfAssetManagePageVo.class).contains(x.getProperty()));
|
|
|
- IPage<WfAssetManage> page = wfAssetManageService.page(ConventPage.getPage(dto), queryWrapper);
|
|
|
+ IPage<WfAssetManagePageVo> page = wfAssetManageService.getPage(dto);
|
|
|
PageOutput<WfAssetManagePageVo> pageOutput = ConventPage.getPageOutput(page, WfAssetManagePageVo.class);
|
|
|
return RT.ok(pageOutput);
|
|
|
}
|