From 95d8e5f4348497b1eee5884086534c86b1661b4f Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期一, 27 十月 2025 19:56:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AssetStatisticsController.java | 268 +++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 236 insertions(+), 32 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AssetStatisticsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AssetStatisticsController.java
index c88eb73..be6f3ff 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AssetStatisticsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AssetStatisticsController.java
@@ -2,33 +2,32 @@
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.entity.TDept;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.service.TokenService;
-import com.ruoyi.system.dto.asset.AssetTypeDTO;
+import com.ruoyi.system.model.AssetInventoryRecord;
import com.ruoyi.system.model.AssetMain;
+import com.ruoyi.system.model.AssetType;
+import com.ruoyi.system.model.AssetUseRecord;
+import com.ruoyi.system.query.AsseIdleListQuery;
import com.ruoyi.system.query.AssetInventoryListQuery;
import com.ruoyi.system.query.AssetStatisticsListDetailQuery;
import com.ruoyi.system.query.AssetStatisticsListQuery;
-import com.ruoyi.system.query.NotificationListQuery;
-import com.ruoyi.system.service.AssetInventoryRecordService;
-import com.ruoyi.system.service.AssetMainService;
-import com.ruoyi.system.service.AssetTypeService;
-import com.ruoyi.system.service.TDeptService;
-import com.ruoyi.system.vo.AssetInventoryVO;
-import com.ruoyi.system.vo.AssetStatisticsDetailVO;
-import com.ruoyi.system.vo.AssetStatisticsVO;
+import com.ruoyi.system.service.*;
+import com.ruoyi.system.vo.*;
import com.ruoyi.system.vo.asset.AssetTypeTreeVO;
-import com.ruoyi.system.vo.system.NotificationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
+import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
-import javax.validation.Valid;
+import java.math.BigDecimal;
+import java.math.BigInteger;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.util.ArrayList;
@@ -51,13 +50,17 @@
public class AssetStatisticsController {
@Autowired
- private AssetTypeService assetTypeService;
+ private AssetTypeService assetTypeService;
+ @Autowired
+ private AssetUseRecordService assetUseRecordService;
@Autowired
private AssetInventoryRecordService assetInventoryRecordService;
@Autowired
private AssetMainService assetMainService;
@Autowired
private TokenService tokenService;
+ @Autowired
+ private ISysUserService sysUserService;
@Autowired
private TDeptService deptService;
@@ -69,13 +72,13 @@
}
-
public List<Integer> getAllSubDeptIds(Integer parentId) {
List<Integer> allSubIds = new ArrayList<>();
allSubIds.add(parentId);
getSubDeptIdsRecursive(parentId, allSubIds);
return allSubIds.stream().distinct().collect(Collectors.toList());
}
+
private void getSubDeptIdsRecursive(Integer parentId, List<Integer> allSubIds) {
// 查询直接下级
List<Integer> directSubIds = deptService.lambdaQuery().eq(TDept::getParentId, parentId).list()
@@ -87,64 +90,265 @@
getSubDeptIdsRecursive(subId, allSubIds);
}
}
+
@ApiOperation("资产汇总分页列表")
@PostMapping("/pageList")
public R<PageInfo<AssetStatisticsVO>> pageList(@RequestBody AssetStatisticsListQuery query) {
String deptId = tokenService.getLoginUser().getDeptId();
- TDept dept = deptService.getById(tokenService.getLoginUser().getDeptId());
+ TDept dept = deptService.getById(deptId);
List<Integer> deptIds = deptService.getAllSubDeptIds(deptId);
- if (dept.getDeptName().contains("资产管理")){
- // 可以查询所有数据
- }else{
- if (deptIds.isEmpty()){
-
+ Long userId = tokenService.getLoginUser().getUserId();
+ SysUser sysUser = sysUserService.selectUserById(userId);
+ if (!SecurityUtils.isAdmin(userId) || sysUser.getRoleId() != 1) {
+ if (dept.getDeptName().contains("资产管理")||dept.getDeptName().contains("董事长")||dept.getDeptName().contains("总经理")) {
+ // 可以查询所有数据
+ query.setDeptIds(new ArrayList<>());
+ } else {
+ if (deptIds.isEmpty()) {
+ return R.ok(new PageInfo<>());
+ } else {
+ query.setDeptIds(deptIds);
+ }
}
+ }else{
+ List<Integer> deptIdsAll = deptService.list().stream().map(TDept::getId).collect(Collectors.toList());
+ query.setDeptIds(deptIdsAll);
}
+
return R.ok(assetTypeService.pageList(query));
}
+
@ApiOperation("资产明细")
@PostMapping("/pageListDetail")
public R<PageInfo<AssetStatisticsDetailVO>> pageListDetail(@RequestBody AssetStatisticsListDetailQuery query) {
- query.setDeptId(Integer.valueOf(tokenService.getLoginUser().getDeptId()));
+ String deptId = tokenService.getLoginUser().getDeptId();
+ TDept dept = deptService.getById(tokenService.getLoginUser().getDeptId());
+ List<Integer> deptIds = deptService.getAllSubDeptIds(deptId);
+ Long userId = tokenService.getLoginUser().getUserId();
+ SysUser sysUser = sysUserService.selectUserById(userId);
+ if (!SecurityUtils.isAdmin(userId) || sysUser.getRoleId() != 1) {
+ if (dept.getDeptName().contains("资产管理")||dept.getDeptName().contains("董事长")||dept.getDeptName().contains("总经理")) {
+ // 可以查询所有数据
+ query.setDeptIds(new ArrayList<>());
+ } else {
+ if (deptIds.isEmpty()) {
+ return R.ok(new PageInfo<>());
+ } else {
+ query.setDeptIds(deptIds);
+ }
+ }
+ }else{
+ query.setDeptIds(deptService.list().stream().map(TDept::getId).collect(Collectors.toList()));
+ }
PageInfo<AssetStatisticsDetailVO> res = assetTypeService.pageListDetail(query);
return R.ok(res);
}
+
@ApiOperation("资产出入库分页列表")
@PostMapping("/pageListInventory")
public R<PageInfo<AssetInventoryVO>> pageListInventory(@RequestBody AssetInventoryListQuery query) {
- query.setDeptId(Integer.valueOf(tokenService.getLoginUser().getDeptId()));
- String[] dateList = query.getDate().split(",");
+ String deptId = tokenService.getLoginUser().getDeptId();
+ TDept dept = deptService.getById(tokenService.getLoginUser().getDeptId());
+ List<Integer> deptIds = deptService.getAllSubDeptIds(deptId);
+ Long userId = tokenService.getLoginUser().getUserId();
+ SysUser sysUser = sysUserService.selectUserById(userId);
+ if (!SecurityUtils.isAdmin(userId) || sysUser.getRoleId() != 1) {
+ if (dept.getDeptName().contains("资产管理")||dept.getDeptName().contains("董事长")||dept.getDeptName().contains("总经理")) {
+ // 可以查询所有数据
+ query.setDeptIds(new ArrayList<>());
+ } else {
+ if (deptIds.isEmpty()) {
+ return R.ok(new PageInfo<>());
+ } else {
+ query.setDeptIds(deptIds);
+ }
+ }
+ }else{
+ query.setDeptIds(deptService.list().stream().map(TDept::getId).collect(Collectors.toList()));
+
+ }
+ String[] dateList = query.getDate().split("-");
String month = dateList[1];
int monthValue = Integer.parseInt(month);
- int year = LocalDateTime.now().getYear();
+ int year = Integer.parseInt(dateList[0]);
LocalDateTime firstDay = LocalDateTime.of(year, monthValue, 1, 0, 0, 0);
LocalDateTime lastDay = LocalDateTime.of(year, monthValue,
YearMonth.of(year, monthValue).lengthOfMonth(), 23, 59, 59);
query.setDateStart(firstDay);
query.setDateEnd(lastDay);
- if (StringUtils.hasLength(query.getNameOrCode())){
+ List<Integer> assetMainIds = assetInventoryRecordService.lambdaQuery().between(AssetInventoryRecord::getCreateTime, query.getDateStart(), query.getDateEnd())
+ .list().stream().map(AssetInventoryRecord::getAssetMainId).collect(Collectors.toList());
+ if (assetMainIds.isEmpty()) {
+ return R.ok(new PageInfo<>());
+ }
+ if (StringUtils.hasLength(query.getNameOrCode())) {
// 查询出资产名称或者资产编号符合条件的code
- List<Integer> assetTypeIds = assetMainService.lambdaQuery().like(AssetMain::getAssetName, query.getNameOrCode())
- .or()
- .like(AssetMain::getAssetCode, query.getNameOrCode())
+ List<Integer> assetTypeIds = assetMainService.lambdaQuery()
+ .in(AssetMain::getOwnershipDeptId, deptIds)
+ .and(wrapper -> wrapper.like(AssetMain::getAssetName, query.getNameOrCode())
+ .or()
+ .like(AssetMain::getAssetCode, query.getNameOrCode()))
.list()
.stream()
.map(AssetMain::getAssetTypeId)
.collect(Collectors.toList());
- query.setAssetTypeIds(assetTypeIds);
- if (assetTypeIds.isEmpty()){
+ query.setAssetMainIds(assetTypeIds);
+ if (assetTypeIds.isEmpty()) {
return R.ok(new PageInfo<>());
}
+ // 和assetMainIds取交集
+ List<Integer> res = assetMainIds.stream().filter(assetTypeIds::contains).collect(Collectors.toList());
+ if (res.isEmpty()) {
+ return R.ok(new PageInfo<>());
+ }
+ query.setAssetMainIds(res);
}
return R.ok(assetTypeService.pageListInventory(query));
}
+
@ApiOperation("资产出入库明细分页列表")
@PostMapping("/pageListInventoryDetail")
public R<PageInfo<AssetStatisticsDetailVO>> pageListInventoryDetail(@RequestBody AssetStatisticsListDetailQuery query) {
- PageInfo<AssetStatisticsDetailVO> res = assetTypeService.pageListDetail(query);
+ String deptId = tokenService.getLoginUser().getDeptId();
+ TDept dept = deptService.getById(tokenService.getLoginUser().getDeptId());
+ List<Integer> deptIds = deptService.getAllSubDeptIds(deptId);
+ Long userId = tokenService.getLoginUser().getUserId();
+ SysUser sysUser = sysUserService.selectUserById(userId);
+ if (!SecurityUtils.isAdmin(userId) || sysUser.getRoleId() != 1) {
+ if (dept.getDeptName().contains("资产管理")||dept.getDeptName().contains("董事长")||dept.getDeptName().contains("总经理")) {
+ // 可以查询所有数据
+ query.setDeptIds(new ArrayList<>());
+ } else {
+ if (deptIds.isEmpty()) {
+ return R.ok(new PageInfo<>());
+ } else {
+ query.setDeptIds(deptIds);
+ }
+ }
+ }else{
+ query.setDeptIds(deptService.list().stream().map(TDept::getId).collect(Collectors.toList()));
+
+ }
+ String[] dateList = query.getDate().split("-");
+ String month = dateList[1];
+ int monthValue = Integer.parseInt(month);
+ int year = Integer.parseInt(dateList[0]);
+ LocalDateTime firstDay = LocalDateTime.of(year, monthValue, 1, 0, 0, 0);
+ LocalDateTime lastDay = LocalDateTime.of(year, monthValue,
+ YearMonth.of(year, monthValue).lengthOfMonth(), 23, 59, 59);
+ query.setDateStart(firstDay);
+ query.setDateEnd(lastDay);
+ List<Integer> assetMainIds = assetInventoryRecordService.lambdaQuery().between(AssetInventoryRecord::getCreateTime, query.getDateStart(), query.getDateEnd())
+ .list().stream().map(AssetInventoryRecord::getAssetMainId).collect(Collectors.toList());
+ if (assetMainIds.isEmpty()) {
+ return R.ok(new PageInfo<>());
+ }
+ if (StringUtils.hasLength(query.getNameOrCode())) {
+ // 查询出资产名称或者资产编号符合条件的code
+ List<Integer> assetTypeIds = assetMainService.lambdaQuery()
+ .in(AssetMain::getOwnershipDeptId, deptIds)
+ .and(wrapper -> wrapper.like(AssetMain::getAssetName, query.getNameOrCode())
+ .or()
+ .like(AssetMain::getAssetCode, query.getNameOrCode()))
+ .list()
+ .stream()
+ .map(AssetMain::getAssetTypeId)
+ .collect(Collectors.toList());
+ query.setAssetMainIds(assetTypeIds);
+ if (assetTypeIds.isEmpty()) {
+ return R.ok(new PageInfo<>());
+ }
+ // 和assetMainIds取交集
+ List<Integer> res = assetMainIds.stream().filter(assetTypeIds::contains).collect(Collectors.toList());
+ if (res.isEmpty()) {
+ return R.ok(new PageInfo<>());
+ }
+ query.setAssetMainIds(res);
+ }
+ PageInfo<AssetStatisticsDetailVO> res = assetTypeService.pageListInventoryDetail(query);
return R.ok(res);
}
-
+ @ApiOperation("闲置房产")
+ @PostMapping("/pageListIdle")
+ public R<AssetIdleVO> pageListIdle(@RequestBody AsseIdleListQuery query) {
+ AssetType child = assetTypeService.getById(8);
+ AssetType parent = assetTypeService.getById(child.getParentId());
+ AssetIdleVO res = new AssetIdleVO();
+ res.setAssetMainTypeName(parent.getTypeName() + ">" + child.getTypeName());
+ String deptId = tokenService.getLoginUser().getDeptId();
+ TDept dept = deptService.getById(tokenService.getLoginUser().getDeptId());
+ List<Integer> deptIds = new ArrayList<>();
+ Long userId = tokenService.getLoginUser().getUserId();
+ SysUser sysUser = sysUserService.selectUserById(userId);
+ if (!SecurityUtils.isAdmin(userId) || sysUser.getRoleId() != 1) {
+ if (dept.getDeptName().contains("资产管理")||dept.getDeptName().contains("拆迁")||dept.getDeptName().contains("安置")
+ ||dept.getDeptName().contains("董事长")||dept.getDeptName().contains("总经理")) {
+ // 可以查询所有数据
+ deptIds = deptService.list().stream().map(TDept::getId).collect(Collectors.toList());
+ } else {
+ // 查询下级部门
+ deptIds = deptService.getAllSubDeptIds(deptId);
+ if (deptIds.isEmpty()) {
+ deptIds.add(-1);
+ }
+ }
+ }else{
+ deptIds = deptService.list().stream().map(TDept::getId).collect(Collectors.toList());
+ }
+ if (StringUtils.hasLength(query.getNameOrCode())) {
+ // 查询出资产名称或者资产编号符合条件的code
+ List<Integer> assetMainIds = assetMainService.lambdaQuery()
+ .eq(AssetMain::getAssetTypeId, 8)
+ .in(AssetMain::getOwnershipDeptId, deptIds)
+ .and(wrapper -> wrapper.like(AssetMain::getAssetName, query.getNameOrCode())
+ .or()
+ .like(AssetMain::getAssetCode, query.getNameOrCode()))
+ .list()
+ .stream()
+ .map(AssetMain::getId)
+ .collect(Collectors.toList());
+ query.setAssetMainIds(assetMainIds);
+ if (assetMainIds.isEmpty()) {
+ res.setPageList(new PageInfo<>());
+ return R.ok(res);
+ }
+ } else {
+ List<Integer> assetMainIds = assetMainService.lambdaQuery()
+ .eq(AssetMain::getAssetTypeId, 8)
+ .in(AssetMain::getOwnershipDeptId, deptIds)
+ .list()
+ .stream()
+ .map(AssetMain::getId)
+ .collect(Collectors.toList());
+ query.setAssetMainIds(assetMainIds);
+ if (assetMainIds.isEmpty()) {
+ res.setPageList(new PageInfo<>());
+ return R.ok(res);
+ }
+ }
+ PageInfo<AssetIdleListVO> pageList = assetTypeService.pageListIdle(query);
+ List<AssetIdleListVO> noLimit = assetTypeService.pageListIdleNoLimit(query);
+ Integer totalCount = 0;
+ BigDecimal totalValue = new BigDecimal(BigInteger.ZERO);
+ for (AssetIdleListVO assetIdleListVO : noLimit) {
+ totalCount += assetIdleListVO.getQuantity();
+ totalValue = totalValue.add(new BigDecimal(assetIdleListVO.getQuantity()).multiply(assetIdleListVO.getUnitPrice()));
+ }
+ res.setTotalCount(totalCount);
+ res.setTotalValue(totalValue);
+ res.setPageList(pageList);
+ return R.ok(res);
+ }
+
+ @ApiOperation("安置")
+ @PostMapping("/placement")
+ public R<Boolean> placement(@RequestBody AssetUseRecord assetUseRecord) {
+ assetUseRecordService.save(assetUseRecord) ;
+ AssetMain assetMain = assetMainService.getById(assetUseRecord.getAssetMainId());
+ assetMain.setAssetStatus(assetUseRecord.getStatus());
+ assetMainService.updateById(assetMain);
+ return R.ok();
+ }
}
--
Gitblit v1.7.1