ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AssetStatisticsController.java
@@ -4,12 +4,11 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.entity.TDept; 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.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; @@ -18,17 +17,14 @@ import com.ruoyi.system.vo.AssetStatisticsDetailVO; import com.ruoyi.system.vo.AssetStatisticsVO; 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 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.time.LocalDateTime; import java.time.YearMonth; import java.util.ArrayList; @@ -95,9 +91,12 @@ List<Integer> deptIds = deptService.getAllSubDeptIds(deptId); if (dept.getDeptName().contains("资产管理")){ // 可以查询所有数据 query.setDeptIds(new ArrayList<>()); }else{ if (deptIds.isEmpty()){ return R.ok(new PageInfo<>()); }else{ query.setDeptIds(deptIds); } } return R.ok(assetTypeService.pageList(query)); @@ -105,14 +104,38 @@ @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); if (dept.getDeptName().contains("资产管理")){ // 可以查询所有数据 query.setDeptIds(new ArrayList<>()); }else{ if (deptIds.isEmpty()){ return R.ok(new PageInfo<>()); }else{ query.setDeptIds(deptIds); } } 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 deptId = tokenService.getLoginUser().getDeptId(); TDept dept = deptService.getById(tokenService.getLoginUser().getDeptId()); List<Integer> deptIds = deptService.getAllSubDeptIds(deptId); if (dept.getDeptName().contains("资产管理")){ // 可以查询所有数据 query.setDeptIds(new ArrayList<>()); }else{ if (deptIds.isEmpty()){ return R.ok(new PageInfo<>()); }else{ query.setDeptIds(deptIds); } } String[] dateList = query.getDate().split(","); String month = dateList[1]; int monthValue = Integer.parseInt(month); @@ -122,26 +145,88 @@ 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().like(AssetMain::getAssetName, 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()) .like(AssetMain::getAssetCode, query.getNameOrCode())) .list() .stream() .map(AssetMain::getAssetTypeId) .collect(Collectors.toList()); query.setAssetTypeIds(assetTypeIds); 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<>()); } return R.ok(); 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); if (dept.getDeptName().contains("资产管理")){ // 可以查询所有数据 query.setDeptIds(new ArrayList<>()); }else{ if (deptIds.isEmpty()){ return R.ok(new PageInfo<>()); }else{ query.setDeptIds(deptIds); } } String[] dateList = query.getDate().split(","); String month = dateList[1]; int monthValue = Integer.parseInt(month); int year = LocalDateTime.now().getYear(); 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); } ruoyi-system/src/main/java/com/ruoyi/system/mapper/AssetTypeMapper.java
@@ -3,8 +3,10 @@ import com.ruoyi.common.basic.PageInfo; import com.ruoyi.system.model.AssetType; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.system.query.AssetInventoryListQuery; import com.ruoyi.system.query.AssetStatisticsListDetailQuery; import com.ruoyi.system.query.AssetStatisticsListQuery; import com.ruoyi.system.vo.AssetInventoryVO; import com.ruoyi.system.vo.AssetStatisticsDetailVO; import com.ruoyi.system.vo.AssetStatisticsVO; import org.apache.ibatis.annotations.Param; @@ -27,4 +29,10 @@ List<AssetStatisticsDetailVO> pageListDetail(@Param("query")AssetStatisticsListDetailQuery query, @Param("pageInfo")PageInfo<AssetStatisticsDetailVO> pageInfo); List<AssetInventoryVO> pageListInventory(@Param("query")AssetInventoryListQuery query,@Param("pageInfo") PageInfo<AssetInventoryVO> pageInfo); List<AssetStatisticsDetailVO> pageListInventoryDetail(@Param("query")AssetStatisticsListDetailQuery query,@Param("pageInfo") PageInfo<AssetStatisticsDetailVO> pageInfo); } ruoyi-system/src/main/java/com/ruoyi/system/query/AssetInventoryListQuery.java
@@ -11,16 +11,19 @@ @Data @ApiModel(value = "资产出入库分页列表query") public class AssetInventoryListQuery extends BasePage { @ApiModelProperty(value = "部门id 前端忽略") private Integer deptId; @ApiModelProperty(value = "年月 yy-MM") private String date; @ApiModelProperty(value = "部门ids 前端忽略") private List<Integer> deptIds; @ApiModelProperty(value = "资产名称或编号") private String nameOrCode; @ApiModelProperty(value = "资产分类id") private Integer assetTypeId; @ApiModelProperty(value = "资产分类ids 前端忽略") @ApiModelProperty(value = "资产分类ids ") private List<Integer> assetTypeIds; @ApiModelProperty(value = "资产ids 前端忽略") private List<Integer> assetMainIds; @ApiModelProperty(value = "年月 yy-MM") private String date; @ApiModelProperty(value = "开始时间前端忽略") private LocalDateTime dateStart; @ApiModelProperty(value = "结束时间前端忽略") ruoyi-system/src/main/java/com/ruoyi/system/query/AssetStatisticsListDetailQuery.java
@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDateTime; import java.util.List; @Data @@ -17,8 +18,16 @@ private Integer assetTypeIdSecond; @ApiModelProperty(value = "资产状态") private String assetStatus; @ApiModelProperty(value = "资产类别") private String category; @ApiModelProperty(value = "资产ids 前端忽略") private List<Integer> assetMainIds; @ApiModelProperty(value = "部门id 前端忽略") private Integer deptId; @ApiModelProperty(value = "部门ids 前端忽略") private List<Integer> deptIds; @ApiModelProperty(value = "年月 yy-MM") private String date; @ApiModelProperty(value = "开始时间前端忽略") private LocalDateTime dateStart; @ApiModelProperty(value = "结束时间前端忽略") private LocalDateTime dateEnd; } ruoyi-system/src/main/java/com/ruoyi/system/query/AssetStatisticsListQuery.java
@@ -17,6 +17,8 @@ private Integer assetTypeId; @ApiModelProperty(value = "资产分类ids 前端忽略") private List<Integer> assetTypeIds; @ApiModelProperty(value = "资产ids 前端忽略") private List<Integer> assetMainIds; @ApiModelProperty(value = "部门id 前端忽略") private Integer deptId; private List<Integer> deptIds; } ruoyi-system/src/main/java/com/ruoyi/system/service/AssetTypeService.java
@@ -4,8 +4,10 @@ import com.ruoyi.common.basic.PageInfo; import com.ruoyi.system.dto.asset.AssetTypeDTO; import com.ruoyi.system.model.AssetType; import com.ruoyi.system.query.AssetInventoryListQuery; import com.ruoyi.system.query.AssetStatisticsListDetailQuery; import com.ruoyi.system.query.AssetStatisticsListQuery; import com.ruoyi.system.vo.AssetInventoryVO; import com.ruoyi.system.vo.AssetStatisticsDetailVO; import com.ruoyi.system.vo.AssetStatisticsVO; import com.ruoyi.system.vo.asset.AssetTypeTreeVO; @@ -62,4 +64,9 @@ PageInfo<AssetStatisticsVO> pageList(AssetStatisticsListQuery query); PageInfo<AssetStatisticsDetailVO> pageListDetail(AssetStatisticsListDetailQuery query); PageInfo<AssetInventoryVO> pageListInventory(AssetInventoryListQuery query); PageInfo<AssetStatisticsDetailVO> pageListInventoryDetail(AssetStatisticsListDetailQuery query); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/AssetTypeServiceImpl.java
@@ -11,17 +11,22 @@ import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.system.dto.asset.AssetTypeDTO; import com.ruoyi.system.mapper.AssetTypeMapper; import com.ruoyi.system.model.AssetInventoryRecord; import com.ruoyi.system.model.AssetMain; import com.ruoyi.system.model.AssetType; import com.ruoyi.system.query.AssetInventoryListQuery; import com.ruoyi.system.query.AssetStatisticsListDetailQuery; import com.ruoyi.system.query.AssetStatisticsListQuery; import com.ruoyi.system.service.AssetInventoryRecordService; import com.ruoyi.system.service.AssetMainService; import com.ruoyi.system.service.AssetTypeService; import com.ruoyi.system.vo.AssetInventoryVO; import com.ruoyi.system.vo.AssetStatisticsDetailVO; import com.ruoyi.system.vo.AssetStatisticsVO; import com.ruoyi.system.vo.asset.AssetTypeTreeVO; import com.ruoyi.system.vo.system.NotificationVO; import io.swagger.annotations.ApiModelProperty; import io.swagger.models.auth.In; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -30,11 +35,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.*; import java.util.stream.Collectors; /** @@ -51,6 +52,7 @@ private final AssetMainService assetMainService; private final AssetTypeService assetTypeService; private final AssetInventoryRecordService assetInventoryRecordService; @Override public List<AssetTypeTreeVO> getAssetTypeTree() { @@ -310,7 +312,7 @@ .stream() .map(AssetMain::getAssetTypeId) .collect(Collectors.toList()); query.setAssetTypeIds(assetTypeIds); query.setAssetMainIds(assetTypeIds); if (assetTypeIds.isEmpty()){ return new PageInfo<>(); } @@ -323,7 +325,7 @@ return new PageInfo<>(); } Map<Integer, List<AssetMain>> assetMainMap = assetMainService.lambdaQuery() .eq(AssetMain::getOwnershipDeptId, query.getDeptId()) .in(!query.getDeptIds().isEmpty(),AssetMain::getOwnershipDeptId, query.getDeptIds()) .in(AssetMain::getAssetTypeId, assetTypeIds).list() .stream() .collect(Collectors.groupingBy(AssetMain::getAssetTypeId)); @@ -396,4 +398,97 @@ return pageInfo; } @Override public PageInfo<AssetInventoryVO> pageListInventory(AssetInventoryListQuery query) { AssetType assetType = this.baseMapper.selectById(query.getAssetTypeId()); if (assetType.getParentId()==0){ List<Integer> assetTypeChild = this.baseMapper.selectList(new LambdaQueryWrapper<AssetType>() .eq(AssetType::getParentId, assetType.getId())).stream().map(AssetType::getId) .collect(Collectors.toList()); List<Integer> list = new ArrayList<>(assetTypeChild); list.add(assetType.getId()); query.setAssetTypeIds( list); }else{ query.setAssetTypeIds(Collections.singletonList(assetType.getId())); } PageInfo<AssetInventoryVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<AssetInventoryVO> list = this.baseMapper.pageListInventory(query,pageInfo); Map<Integer, List<AssetMain>> assetMainMap = assetMainService.lambdaQuery().in(AssetMain::getId, query.getAssetMainIds()).list() .stream().collect(Collectors.groupingBy(AssetMain::getAssetTypeId)); List<AssetInventoryRecord> assetInventoryRecords = assetInventoryRecordService.lambdaQuery().in(AssetInventoryRecord::getAssetMainId, query.getAssetMainIds()).list(); for (AssetInventoryVO assetInventoryVO : list) { int inCount = 0; int outCount = 0; int inStockCount = 0; BigDecimal inStockMoney = new BigDecimal("0"); BigDecimal inMoney = new BigDecimal("0"); BigDecimal outMoney = new BigDecimal("0"); List<AssetMain> assetMains = assetMainMap.get(assetInventoryVO.getAssetTypeIdSecond()); for (AssetInventoryRecord assetInventoryRecord : assetInventoryRecords) { if (assetInventoryRecord.getType()==0){ AssetMain assetMain = assetMains.stream().filter(e -> e.getId().equals(assetInventoryRecord.getAssetMainId())) .findFirst().orElse(null); if (assetMain!=null){ inCount+=assetMain.getQuantity(); inMoney = inMoney.add(new BigDecimal(assetMain.getQuantity()) .multiply(assetMain.getUnitPrice()).setScale(2, RoundingMode.HALF_DOWN)); } }else{ AssetMain assetMain = assetMains.stream().filter(e -> e.getId().equals(assetInventoryRecord.getAssetMainId())) .findFirst().orElse(null); if (assetMain!=null){ outCount+=assetMain.getQuantity(); outMoney = outMoney.add(new BigDecimal(assetMain.getQuantity()) .multiply(assetMain.getUnitPrice()).setScale(2, RoundingMode.HALF_DOWN)); } } } assetInventoryVO.setInCount(inCount); assetInventoryVO.setOutCount(outCount); assetInventoryVO.setInMoney(inMoney); assetInventoryVO.setOutMoney(outMoney); List<AssetMain> inStorage = assetMains.stream().filter(e -> e.getDisposed() == 0 && e.getInUse() == 0 && e.getBorrowed() == 0).collect(Collectors.toList()); for (AssetMain assetMain : inStorage) { inStockCount+=assetMain.getQuantity(); inStockMoney = inStockMoney.add(new BigDecimal(assetMain.getQuantity()) .multiply(assetMain.getUnitPrice()).setScale(2, RoundingMode.HALF_DOWN)); } assetInventoryVO.setInStockCount(inStockCount); assetInventoryVO.setInStockMoney(inStockMoney); } pageInfo.setRecords(list); return pageInfo; } @Override public PageInfo<AssetStatisticsDetailVO> pageListInventoryDetail(AssetStatisticsListDetailQuery query) { PageInfo<AssetStatisticsDetailVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); List<AssetStatisticsDetailVO> list = this.baseMapper.pageListInventoryDetail(query,pageInfo); List<AssetType> assetTypes = assetTypeService.list(); for (AssetStatisticsDetailVO assetStatisticsDetailVO : list) { Integer type = assetStatisticsDetailVO.getType(); if (type==0){ String typeName = "入库"; AssetType assetType = assetTypes.stream().filter(e -> e.getId().equals(assetStatisticsDetailVO.getAssetTypeId())) .findFirst().orElse(null); if (assetType!=null){ typeName =typeName+"("+assetType.getTypeName()+")"; } assetStatisticsDetailVO.setTypeName(typeName); }else{ String typeName = "出库"; AssetType assetType = assetTypes.stream().filter(e -> e.getId().equals(assetStatisticsDetailVO.getAssetTypeId())) .findFirst().orElse(null); if (assetType!=null){ typeName =typeName+"("+assetType.getTypeName()+")"; } assetStatisticsDetailVO.setTypeName(typeName); } } pageInfo.setRecords(list); return pageInfo; } } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDeptServiceImpl.java
@@ -37,7 +37,6 @@ @Override public List<Integer> getAllSubDeptIds(String deptId) { List<Integer> allSubIds = new ArrayList<>(); allSubIds.add(Integer.valueOf(deptId)); getSubDeptIdsRecursive(Integer.valueOf(deptId), allSubIds); return allSubIds.stream().distinct().collect(Collectors.toList()); } @@ -50,6 +49,8 @@ // 递归查询下级的下级 getSubDeptIdsRecursive(subId, allSubIds); } allSubIds.add(Integer.valueOf(parentId)); } /** * 构建部门树结构 ruoyi-system/src/main/java/com/ruoyi/system/vo/AssetStatisticsDetailVO.java
@@ -11,13 +11,18 @@ @Data @ApiModel(value = "资产汇总分页返回VO") public class AssetStatisticsDetailVO implements Serializable { @ApiModelProperty(value = "出入库类型") private String typeName; @ApiModelProperty(value = "出入库类型 0-入库,1-出库") private Integer type; @ApiModelProperty(value = "资产名称") private String assetName; @ApiModelProperty(value = "规格型号") private String specificationModel; @ApiModelProperty(value = "资产类型") private String assetTypeName; @ApiModelProperty(value = "资产类型id") private Integer assetTypeId; @ApiModelProperty(value = "资产类别") private String category; @ApiModelProperty(value = "计量单位") ruoyi-system/src/main/resources/mapper/system/AssetTypeMapper.xml
@@ -18,7 +18,8 @@ <!-- 通用查询结果列 --> <sql id="Base_Column_List"> id, type_name, type_code, parent_id, level, create_time, create_by, update_time, update_by, disabled id , type_name, type_code, parent_id, level, create_time, create_by, update_time, update_by, disabled </sql> <select id="pageList" resultType="com.ruoyi.system.vo.AssetStatisticsVO"> select t1.id as assetTypeIdSecond,t1.type_name as assetTypeNameSecond, @@ -28,8 +29,14 @@ where 1=1 and t1.parent_id != 0 <if test="query.assetTypeIds != null and query.assetTypeIds.size()>0"> <if test="query.assetMainIds != null and query.assetMainIds.size()>0"> AND t1.id IN <foreach collection="query.assetMainIds" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> <if test="query.assetTypeIds != null and query.assetTypeIds.size()>0"> AND t1.asset_type_id IN <foreach collection="query.assetTypeIds" item="item" open="(" separator="," close=")"> #{item} </foreach> @@ -62,14 +69,14 @@ when t1.address is not null and t1.address != '' then t1.address when t1.warehouse_name is not null and t1.warehouse_name != '' then t1.warehouse_name else null end as useName from asset_main end as useName from asset_main t1 left join asset_type t2 on t2.id = t1.asset_type_id left join t_dept t3 on t3.id = t1.use_dept_id left join t_dept t4 on t4.id = t1.ownership_dept_id where 1=1 <if test="query.assetTypeIdSecond != null"> AND t1.asset_type_id = #{query.assetTypeIdSecond} <if test="query.category != null"> AND t1.category = #{query.category} </if> <if test="query.deptId != null"> AND t1.asset_type_id = #{query.assetTypeIdSecond} @@ -81,9 +88,65 @@ #{item} </foreach> </if> <if test="query.deptIds != null and query.deptIds.size()>0"> AND t1.ownership_dept_id IN <foreach collection="query.deptIds" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> order by t1.create_time desc </select> <select id="pageListInventory" resultType="com.ruoyi.system.vo.AssetInventoryVO"> select t1.name as assetTypeNameSecond,t1.id as assetTypeIdSecond, t2.name as assetTypeNameFirst,t2.id as assetTypeIdFirst from asset_type t1 left join asset_type t2 on t1.parent_id = t2.id where t1.parent_id != 0 <if test="query.assetTypeIds != null and query.assetTypeIds.size()>0"> AND t1.id IN <foreach collection="query.assetTypeIds" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> and t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} and t2.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} </select> <select id="pageListInventoryDetail" resultType="com.ruoyi.system.vo.AssetStatisticsDetailVO"> select t1.*,t2.*,case when t1.use_dept_id is not null and t1.use_dept_id != '' then t3.dept_name when t1.address is not null and t1.address != '' then t1.address when t1.warehouse_name is not null and t1.warehouse_name != '' then t1.warehouse_name else null end as useName, from asset_inventory_record t1 left join asset_main t2 on t1.asset_main_id = t2.id left join t_dept t3 on t3.id = t1.use_dept_id left join t_dept t4 on t4.id = t1.ownership_dept_id where 1=1 <if test="query.category != null and query.category!=''"> AND t2.category = #{query.category} </if> <if test="query.assetStatus != null and query.assetStatus!=''"> and t2.asset_status like concat('%',#{query.assetStatus},'%') </if> <if test="query.deptIds != null and query.deptIds.size()>0"> AND t2.ownership_dept_id IN <foreach collection="query.deptIds" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> <if test="query.assetMainIds != null and query.assetMainIds.size()>0"> AND t2.id IN <foreach collection="query.assetMainIds" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> order by t1.create_time desc </select> </mapper>