|
@@ -10,11 +10,17 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotInfoDO;
|
|
|
+import cn.iocoder.yudao.module.pms.service.IotDeviceService;
|
|
|
import cn.iocoder.yudao.module.pms.service.IotInfoService;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+import com.xingyuv.captcha.util.StringUtils;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -24,6 +30,8 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
@@ -37,6 +45,10 @@ public class IotInfoController {
|
|
|
|
|
|
@Resource
|
|
|
private IotInfoService iotInfoService;
|
|
|
+ @Autowired
|
|
|
+ private IotDeviceService iotDeviceService;
|
|
|
+ @Autowired
|
|
|
+ private DeptApi deptApi;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建资料")
|
|
@@ -86,10 +98,40 @@ public class IotInfoController {
|
|
|
@Operation(summary = "获得资料分页")
|
|
|
@PreAuthorize("@ss.hasPermission('rq:iot-info:query')")
|
|
|
public CommonResult<PageResult<IotInfoRespVO>> getIotInfoFilePage(@Valid IotInfoPageReqVO pageReqVO) {
|
|
|
-// Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
-// pageReqVO.setCreator(String.valueOf(loginUserId));
|
|
|
PageResult<IotInfoDO> pageResult = iotInfoService.getIotInfoFilePage(pageReqVO);
|
|
|
- return success(BeanUtils.toBean(pageResult, IotInfoRespVO.class));
|
|
|
+ List<IotInfoDO> list = pageResult.getList();
|
|
|
+ List<IotInfoRespVO> collect = list.stream().map(e -> {
|
|
|
+ IotInfoRespVO vo = BeanUtils.toBean(e, IotInfoRespVO.class);
|
|
|
+ if (Objects.nonNull(e.getDeviceId())) {
|
|
|
+ IotDeviceDO iotDevice = iotDeviceService.getIotDevice(e.getDeviceId());
|
|
|
+ if (Objects.nonNull(iotDevice)) {
|
|
|
+ vo.setDeviceName(iotDevice.getDeviceName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(e.getDeptId())) {
|
|
|
+ DeptRespDTO dept = deptApi.getDept(e.getDeptId());
|
|
|
+ if (Objects.nonNull(dept)) {
|
|
|
+ vo.setDeptName(dept.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return success(new PageResult<>(collect, pageResult.getTotal()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/child/content-file")
|
|
|
+ @Operation(summary = "获得资料库的分类目录及文件")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-info:query')")
|
|
|
+ public CommonResult<List<IotInfoRespVO>> getChildContentFile(@Valid IotInfoPageReqVO pageReqVO) {
|
|
|
+ Long classId = pageReqVO.getClassId();
|
|
|
+ List<IotInfoRespVO> contentFiles = iotInfoService.getChildContentFile(classId).stream().filter(e ->{
|
|
|
+ if (StringUtils.isNotBlank(pageReqVO.getFilename())) {
|
|
|
+ return e.getFilename().contains(pageReqVO.getFilename());
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return success(contentFiles);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|