|
@@ -4,17 +4,27 @@ import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
import cn.iocoder.yudao.module.asset.controller.admin.assetreceiveinfo.vo.AssetReceiveInfoPageReqVO;
|
|
|
import cn.iocoder.yudao.module.asset.controller.admin.assetreceiveinfo.vo.AssetReceiveInfoRespVO;
|
|
|
import cn.iocoder.yudao.module.asset.controller.admin.assetreceiveinfo.vo.AssetReceiveInfoSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.asset.controller.admin.assetreceiveinfo.vo.AssetReceiveInfoUpdateReqVO;
|
|
|
import cn.iocoder.yudao.module.asset.dal.dataobject.assetreceiveinfo.AssetReceiveInfoDO;
|
|
|
+import cn.iocoder.yudao.module.asset.enums.AssetReturnStateEnum;
|
|
|
import cn.iocoder.yudao.module.asset.service.assetreceiveinfo.AssetReceiveInfoService;
|
|
|
+import cn.iocoder.yudao.module.employee.api.EmployeeApi;
|
|
|
+import cn.iocoder.yudao.module.employee.api.dto.EmployeeRespDTO;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.PostApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
|
+import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springdoc.api.annotations.ParameterObject;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -22,12 +32,16 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+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;
|
|
|
|
|
|
-@Tag(name = "管理后台 - 固定资产领用信息")
|
|
|
+@Tag(name = "管理后台 - 固定资产领用、归还信息")
|
|
|
@RestController
|
|
|
@RequestMapping("/asset/receive-info")
|
|
|
@Validated
|
|
@@ -36,8 +50,17 @@ public class AssetReceiveInfoController {
|
|
|
@Resource
|
|
|
private AssetReceiveInfoService receiveInfoService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private EmployeeApi employeeApi;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DeptApi deptApi;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PostApi postApi;
|
|
|
+
|
|
|
@PostMapping("/create")
|
|
|
- @Operation(summary = "创建固定资产领用信息")
|
|
|
+ @Operation(summary = "领用固定资产")
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
|
|
|
public CommonResult<Long> createReceiveInfo(@Valid @RequestBody AssetReceiveInfoSaveReqVO createReqVO) {
|
|
@@ -45,17 +68,17 @@ public class AssetReceiveInfoController {
|
|
|
}
|
|
|
|
|
|
@PutMapping("/update")
|
|
|
- @Operation(summary = "更新固定资产领用信息")
|
|
|
+ @Operation(summary = "归还固定资产")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
|
|
|
- public CommonResult<Boolean> updateReceiveInfo(@Valid @RequestBody AssetReceiveInfoSaveReqVO updateReqVO) {
|
|
|
+ public CommonResult<Boolean> updateReceiveInfo(@Valid @RequestBody AssetReceiveInfoUpdateReqVO updateReqVO) {
|
|
|
receiveInfoService.updateReceiveInfo(updateReqVO);
|
|
|
return success(true);
|
|
|
}
|
|
|
|
|
|
@DeleteMapping("/delete")
|
|
|
@Operation(summary = "删除固定资产领用信息")
|
|
|
- @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
@Parameter(name = "id", description = "编号", required = true)
|
|
|
|
|
|
public CommonResult<Boolean> deleteReceiveInfo(@RequestParam("id") Long id) {
|
|
@@ -65,7 +88,7 @@ public class AssetReceiveInfoController {
|
|
|
|
|
|
@GetMapping("/get")
|
|
|
@Operation(summary = "获得固定资产领用信息")
|
|
|
- @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
|
|
public CommonResult<AssetReceiveInfoRespVO> getReceiveInfo(@RequestParam("id") Long id) {
|
|
@@ -74,12 +97,55 @@ public class AssetReceiveInfoController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/page")
|
|
|
- @Operation(summary = "获得固定资产领用信息分页")
|
|
|
- @ApiOperationSupport(order = 5)
|
|
|
+ @Operation(summary = "获得固定资产流转分页信息")
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
|
|
|
- public CommonResult<PageResult<AssetReceiveInfoRespVO>> getReceiveInfoPage(@Valid AssetReceiveInfoPageReqVO pageReqVO) {
|
|
|
+ public CommonResult<PageResult<AssetReceiveInfoRespVO>> getReceiveInfoPage(@Valid @ParameterObject AssetReceiveInfoPageReqVO pageReqVO) {
|
|
|
PageResult<AssetReceiveInfoDO> pageResult = receiveInfoService.getReceiveInfoPage(pageReqVO);
|
|
|
- return success(BeanUtils.toBean(pageResult, AssetReceiveInfoRespVO.class));
|
|
|
+ PageResult<AssetReceiveInfoRespVO> voPageResult = BeanUtils.toBean(pageResult, AssetReceiveInfoRespVO.class);
|
|
|
+ List<AssetReceiveInfoRespVO> list = voPageResult.getList();
|
|
|
+
|
|
|
+
|
|
|
+ Set<Long> employeeIdSet = list.stream().map(AssetReceiveInfoRespVO::getEmployeeId).collect(Collectors.toSet());
|
|
|
+ List<EmployeeRespDTO> employeeRespDTOList = employeeApi.getEmployeeListByIds(employeeIdSet);
|
|
|
+ Map<Long, EmployeeRespDTO> employeeMap = CollectionUtils.convertMap(employeeRespDTOList, EmployeeRespDTO::getId);
|
|
|
+
|
|
|
+ Set<Long> deptIdSet = list.stream().map(AssetReceiveInfoRespVO::getDeptId).collect(Collectors.toSet());
|
|
|
+ List<DeptRespDTO> deptList = deptApi.getDeptList(deptIdSet);
|
|
|
+ Map<Long, DeptRespDTO> deptMap = CollectionUtils.convertMap(deptList, DeptRespDTO::getId);
|
|
|
+
|
|
|
+ Set<Long> postIdSet = list.stream().map(AssetReceiveInfoRespVO::getPostId).collect(Collectors.toSet());
|
|
|
+ List<PostRespDTO> postList = postApi.getPostList(postIdSet);
|
|
|
+ Map<Long, PostRespDTO> postMap = CollectionUtils.convertMap(postList, PostRespDTO::getId);
|
|
|
+
|
|
|
+ Set<Long> updaterIdSet = list.stream().map(AssetReceiveInfoRespVO::getUpdater).collect(Collectors.toSet());
|
|
|
+ List<EmployeeRespDTO> updaterList = employeeApi.getEmployeeListByIds(updaterIdSet);
|
|
|
+ Map<Long, EmployeeRespDTO> updaterMap = CollectionUtils.convertMap(updaterList, EmployeeRespDTO::getId);
|
|
|
+
|
|
|
+ Map<Integer, String> returnStateMap = Arrays.stream(AssetReturnStateEnum.values()).collect(Collectors.toMap(AssetReturnStateEnum::getState, AssetReturnStateEnum::getDesc));
|
|
|
+
|
|
|
+ for (AssetReceiveInfoRespVO assetReceiveInfoRespVO : list) {
|
|
|
+ EmployeeRespDTO employeeRespDTO = employeeMap.get(assetReceiveInfoRespVO.getEmployeeId());
|
|
|
+ if (employeeRespDTO != null) {
|
|
|
+ assetReceiveInfoRespVO.setEmployeeName(employeeRespDTO.getName());
|
|
|
+ assetReceiveInfoRespVO.setEmployeePhone(employeeRespDTO.getPhone());
|
|
|
+ }
|
|
|
+ DeptRespDTO deptRespDTO = deptMap.get(assetReceiveInfoRespVO.getDeptId());
|
|
|
+ if (deptRespDTO != null) {
|
|
|
+ assetReceiveInfoRespVO.setDeptName(deptRespDTO.getName());
|
|
|
+ }
|
|
|
+ PostRespDTO postRespDTO = postMap.get(assetReceiveInfoRespVO.getPostId());
|
|
|
+ if (postRespDTO != null) {
|
|
|
+ assetReceiveInfoRespVO.setPosition(postRespDTO.getName());
|
|
|
+ }
|
|
|
+ EmployeeRespDTO updaterRespDTO = updaterMap.get(assetReceiveInfoRespVO.getUpdater());
|
|
|
+ if (updaterRespDTO != null) {
|
|
|
+ assetReceiveInfoRespVO.setOperatorName(updaterRespDTO.getName());
|
|
|
+ }
|
|
|
+ String returnStateDesc = returnStateMap.getOrDefault(assetReceiveInfoRespVO.getReturned(), "未知");
|
|
|
+ assetReceiveInfoRespVO.setReturnedDesc(returnStateDesc);
|
|
|
+ }
|
|
|
+ return success(voPageResult);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|