haungxing
11 months ago
9 changed files with 128 additions and 2 deletions
@ -0,0 +1,21 @@ |
|||||||
|
package com.hnac.hzims.emParam.vo; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class ParamBackupsDetailTreeVO implements Serializable { |
||||||
|
|
||||||
|
@ApiModelProperty("参数分组") |
||||||
|
private Long modelClassifyId; |
||||||
|
|
||||||
|
@ApiModelProperty("参数分组名称") |
||||||
|
private String modelClassifyName; |
||||||
|
|
||||||
|
@ApiModelProperty("分组下的参数") |
||||||
|
private List<ParamBackupsDetailVO> children; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.hnac.hzims.emParam.controller; |
||||||
|
|
||||||
|
|
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||||
|
import com.hnac.hzims.emParam.service.IParamBackupsDetailService; |
||||||
|
import com.hnac.hzims.emParam.vo.ParamBackupsDetailTreeVO; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import io.swagger.annotations.ApiParam; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import org.springblade.core.boot.ctrl.BladeController; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@RestController |
||||||
|
@RequestMapping("/emParam/backups/detail") |
||||||
|
@AllArgsConstructor |
||||||
|
@Api(value = "设备参数备份详情管理",tags = "设备参数备份详情管理") |
||||||
|
public class ParamBackupsDetailController extends BladeController { |
||||||
|
|
||||||
|
private final IParamBackupsDetailService paramBackupsDetailService; |
||||||
|
|
||||||
|
@GetMapping("/getBackupsParamTree") |
||||||
|
@ApiOperation("") |
||||||
|
@ApiOperationSupport(order = 1) |
||||||
|
public R<List<ParamBackupsDetailTreeVO>> getBackupsParamTree(@RequestParam @ApiParam("备份ID") Long backupsId) { |
||||||
|
return R.data(paramBackupsDetailService.getBackupsParamTree(backupsId)); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,8 +1,13 @@ |
|||||||
package com.hnac.hzims.emParam.service; |
package com.hnac.hzims.emParam.service; |
||||||
|
|
||||||
import com.hnac.hzims.emParam.entity.ParamBackupsDetailEntity; |
import com.hnac.hzims.emParam.entity.ParamBackupsDetailEntity; |
||||||
|
import com.hnac.hzims.emParam.vo.ParamBackupsDetailTreeVO; |
||||||
import org.springblade.core.mp.base.BaseService; |
import org.springblade.core.mp.base.BaseService; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
public interface IParamBackupsDetailService extends BaseService<ParamBackupsDetailEntity> { |
public interface IParamBackupsDetailService extends BaseService<ParamBackupsDetailEntity> { |
||||||
|
|
||||||
|
List<ParamBackupsDetailTreeVO> getBackupsParamTree(Long backupsId); |
||||||
|
|
||||||
} |
} |
||||||
|
@ -1,18 +1,51 @@ |
|||||||
package com.hnac.hzims.emParam.service.impl; |
package com.hnac.hzims.emParam.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||||
|
import com.google.common.collect.Lists; |
||||||
import com.hnac.hzims.emParam.entity.ParamBackupsDetailEntity; |
import com.hnac.hzims.emParam.entity.ParamBackupsDetailEntity; |
||||||
import com.hnac.hzims.emParam.mapper.ParamBackupsDetailMapper; |
import com.hnac.hzims.emParam.mapper.ParamBackupsDetailMapper; |
||||||
import com.hnac.hzims.emParam.service.IParamBackupsDetailService; |
import com.hnac.hzims.emParam.service.IParamBackupsDetailService; |
||||||
|
import com.hnac.hzims.emParam.vo.ParamBackupsDetailTreeVO; |
||||||
|
import com.hnac.hzims.emParam.vo.ParamBackupsDetailVO; |
||||||
|
import com.hnac.hzims.emParam.wrapper.ParamBackupsDetailWrapper; |
||||||
import lombok.AllArgsConstructor; |
import lombok.AllArgsConstructor; |
||||||
import lombok.extern.slf4j.Slf4j; |
import lombok.extern.slf4j.Slf4j; |
||||||
import org.springblade.core.mp.base.BaseServiceImpl; |
import org.springblade.core.mp.base.BaseServiceImpl; |
||||||
|
import org.springblade.core.tool.utils.CollectionUtil; |
||||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
@Service |
@Service |
||||||
@AllArgsConstructor |
@AllArgsConstructor |
||||||
@Slf4j |
@Slf4j |
||||||
public class ParamBackupsDetailServiceImpl extends BaseServiceImpl<ParamBackupsDetailMapper, ParamBackupsDetailEntity> implements IParamBackupsDetailService { |
public class ParamBackupsDetailServiceImpl extends BaseServiceImpl<ParamBackupsDetailMapper, ParamBackupsDetailEntity> implements IParamBackupsDetailService { |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public List<ParamBackupsDetailTreeVO> getBackupsParamTree(Long backupsId) { |
||||||
|
LambdaQueryWrapper<ParamBackupsDetailEntity> lqw = Wrappers.<ParamBackupsDetailEntity>lambdaQuery().eq(ParamBackupsDetailEntity::getBackupsId, backupsId); |
||||||
|
List<ParamBackupsDetailEntity> detailList = this.list(lqw); |
||||||
|
if(CollectionUtil.isNotEmpty(detailList)) { |
||||||
|
List<ParamBackupsDetailVO> detailVOList = ParamBackupsDetailWrapper.build().listVO(detailList); |
||||||
|
Map<HashMap, List<ParamBackupsDetailVO>> detailGroup = detailVOList.stream().collect(Collectors.groupingBy(d -> new HashMap() {{ |
||||||
|
put("modelClassifyId", d.getModelClassifyId()); |
||||||
|
put("modelClassifyName", d.getModelClassifyName()); |
||||||
|
}})); |
||||||
|
List<ParamBackupsDetailTreeVO> result = Lists.newArrayList(); |
||||||
|
detailGroup.forEach((classify,list) -> { |
||||||
|
ParamBackupsDetailTreeVO detailTreeVO = new ParamBackupsDetailTreeVO(); |
||||||
|
detailTreeVO.setModelClassifyId((Long) classify.get("modelClassifyId")); |
||||||
|
detailTreeVO.setModelClassifyName((String) classify.get("modelClassifyName")); |
||||||
|
detailTreeVO.setChildren(list); |
||||||
|
result.add(detailTreeVO); |
||||||
|
}); |
||||||
|
return result; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue