|
@@ -10,11 +10,20 @@ import cn.iocoder.yudao.module.asset.controller.admin.assetinfo.vo.AssetInfoPage
|
|
import cn.iocoder.yudao.module.asset.controller.admin.assetinfo.vo.AssetInfoRespVO;
|
|
import cn.iocoder.yudao.module.asset.controller.admin.assetinfo.vo.AssetInfoRespVO;
|
|
import cn.iocoder.yudao.module.asset.controller.admin.assetinfo.vo.AssetInfoSaveReqVO;
|
|
import cn.iocoder.yudao.module.asset.controller.admin.assetinfo.vo.AssetInfoSaveReqVO;
|
|
import cn.iocoder.yudao.module.asset.dal.dataobject.assetinfo.AssetInfoDO;
|
|
import cn.iocoder.yudao.module.asset.dal.dataobject.assetinfo.AssetInfoDO;
|
|
|
|
+import cn.iocoder.yudao.module.asset.enums.AssetStateEnum;
|
|
|
|
+import cn.iocoder.yudao.module.asset.enums.AssetStatusEnum;
|
|
import cn.iocoder.yudao.module.asset.service.assetinfo.AssetInfoService;
|
|
import cn.iocoder.yudao.module.asset.service.assetinfo.AssetInfoService;
|
|
|
|
+import cn.iocoder.yudao.module.employee.api.EmployeeApi;
|
|
|
|
+import cn.iocoder.yudao.module.employee.api.dto.EmployeeRespDTO;
|
|
|
|
+import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
|
|
|
+import cn.iocoder.yudao.module.infra.api.file.dto.FileDTO;
|
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
+import org.springdoc.api.annotations.ParameterObject;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@@ -22,7 +31,11 @@ import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+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.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
@@ -36,6 +49,15 @@ public class AssetInfoController {
|
|
@Resource
|
|
@Resource
|
|
private AssetInfoService infoService;
|
|
private AssetInfoService infoService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private EmployeeApi employeeApi;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private FileApi fileApi;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private DeptApi deptApi;
|
|
|
|
+
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
@Operation(summary = "创建固定资产信息")
|
|
@Operation(summary = "创建固定资产信息")
|
|
@ApiOperationSupport(order = 1)
|
|
@ApiOperationSupport(order = 1)
|
|
@@ -70,15 +92,38 @@ public class AssetInfoController {
|
|
// @PreAuthorize("@ss.hasPermission('asset:info:query')")
|
|
// @PreAuthorize("@ss.hasPermission('asset:info:query')")
|
|
public CommonResult<AssetInfoRespVO> getInfo(@RequestParam("id") Long id) {
|
|
public CommonResult<AssetInfoRespVO> getInfo(@RequestParam("id") Long id) {
|
|
AssetInfoDO info = infoService.getInfo(id);
|
|
AssetInfoDO info = infoService.getInfo(id);
|
|
- return success(BeanUtils.toBean(info, AssetInfoRespVO.class));
|
|
|
|
|
|
+ AssetInfoRespVO assetInfoRespVO = BeanUtils.toBean(info, AssetInfoRespVO.class);
|
|
|
|
+ // 归属部门名称
|
|
|
|
+ DeptRespDTO dept = deptApi.getDept(info.getAssetDeptId());
|
|
|
|
+ if (Objects.nonNull(dept)) {
|
|
|
|
+ assetInfoRespVO.setAssetDeptName(dept.getName());
|
|
|
|
+ }
|
|
|
|
+ // 资产负责人名称
|
|
|
|
+ EmployeeRespDTO employee = employeeApi.getEmployeeById(info.getAssetManagerEmployeeId());
|
|
|
|
+ if (Objects.nonNull(employee)) {
|
|
|
|
+ assetInfoRespVO.setAssetManagerEmployeeName(employee.getName());
|
|
|
|
+ }
|
|
|
|
+ // 资产状态
|
|
|
|
+ Map<String, String> assetStateMap = Arrays.stream(AssetStateEnum.values())
|
|
|
|
+ .collect(Collectors.toMap(AssetStateEnum::getState, AssetStateEnum::getDesc));
|
|
|
|
+ assetInfoRespVO.setAssetStateDesc(assetStateMap.getOrDefault(assetInfoRespVO.getAssetState(), "未知"));
|
|
|
|
+ // 单据状态
|
|
|
|
+ Map<String, String> assetStatusMap = Arrays.stream(AssetStatusEnum.values())
|
|
|
|
+ .collect(Collectors.toMap(AssetStatusEnum::getStatus, AssetStatusEnum::getDesc));
|
|
|
|
+ assetInfoRespVO.setStatusDesc(assetStatusMap.getOrDefault(assetInfoRespVO.getStatus(), "未知"));
|
|
|
|
+ // 附件
|
|
|
|
+ List<FileDTO> fileDTOListByBiz = fileApi.getFileDTOListByBiz(info.getAssetInfoUuid());
|
|
|
|
+ assetInfoRespVO.setFileList(fileDTOListByBiz);
|
|
|
|
+
|
|
|
|
+ return success(assetInfoRespVO);
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/page")
|
|
@GetMapping("/page")
|
|
@Operation(summary = "获得固定资产信息分页")
|
|
@Operation(summary = "获得固定资产信息分页")
|
|
@ApiOperationSupport(order = 5)
|
|
@ApiOperationSupport(order = 5)
|
|
// @PreAuthorize("@ss.hasPermission('asset:info:query')")
|
|
// @PreAuthorize("@ss.hasPermission('asset:info:query')")
|
|
- public CommonResult<PageResult<AssetInfoRespVO>> getInfoPage(@Valid AssetInfoPageReqVO pageReqVO) {
|
|
|
|
- PageResult<AssetInfoDO> pageResult = infoService.getInfoPage(pageReqVO);
|
|
|
|
|
|
+ public CommonResult<PageResult<AssetInfoRespVO>> getInfoPage(@Valid @ParameterObject AssetInfoPageReqVO pageReqVO) {
|
|
|
|
+ PageResult<AssetInfoRespVO> pageResult = infoService.getInfoPage(pageReqVO);
|
|
return success(BeanUtils.toBean(pageResult, AssetInfoRespVO.class));
|
|
return success(BeanUtils.toBean(pageResult, AssetInfoRespVO.class));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -87,13 +132,13 @@ public class AssetInfoController {
|
|
@ApiOperationSupport(order = 6)
|
|
@ApiOperationSupport(order = 6)
|
|
// @PreAuthorize("@ss.hasPermission('asset:info:export')")
|
|
// @PreAuthorize("@ss.hasPermission('asset:info:export')")
|
|
@ApiAccessLog(operateType = EXPORT)
|
|
@ApiAccessLog(operateType = EXPORT)
|
|
- public void exportInfoExcel(@Valid AssetInfoPageReqVO pageReqVO,
|
|
|
|
- HttpServletResponse response) throws IOException {
|
|
|
|
|
|
+ public void exportInfoExcel(@Valid @ParameterObject AssetInfoPageReqVO pageReqVO,
|
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
- List<AssetInfoDO> list = infoService.getInfoPage(pageReqVO).getList();
|
|
|
|
|
|
+ List<AssetInfoRespVO> list = infoService.getInfoPage(pageReqVO).getList();
|
|
// 导出 Excel
|
|
// 导出 Excel
|
|
ExcelUtils.write(response, "固定资产信息.xls", "数据", AssetInfoRespVO.class,
|
|
ExcelUtils.write(response, "固定资产信息.xls", "数据", AssetInfoRespVO.class,
|
|
- BeanUtils.toBean(list, AssetInfoRespVO.class));
|
|
|
|
|
|
+ list);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|