From e5145002a4c6161b240266ce58ab9252e003ba6b Mon Sep 17 00:00:00 2001 From: mocheng <3057647414@qq.com> Date: Wed, 25 Jun 2025 09:26:28 +0800 Subject: [PATCH] =?UTF-8?q?asset=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 ++-- .../property/domain/vo/ApplicationVo.java | 19 ++++++++ .../dromara/property/domain/vo/AssetVo.java | 19 +++++++- .../service/impl/ApplicationServiceImpl.java | 45 +++++++++++++++++-- .../service/impl/AssetServiceImpl.java | 45 ++++++++++++++++++- 5 files changed, 126 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 1d8506e..d702f67 100644 --- a/pom.xml +++ b/pom.xml @@ -73,10 +73,10 @@ dev - - - 47.109.37.87:8848 - 47.109.37.87:4560 + 127.0.0.1:8848 + 127.0.0.1:4560 + + DEFAULT_GROUP DEFAULT_GROUP nacos diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/ApplicationVo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/ApplicationVo.java index 4fa7b59..a2567b7 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/ApplicationVo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/ApplicationVo.java @@ -42,12 +42,24 @@ public class ApplicationVo implements Serializable { @ExcelProperty(value = "资产id") private Long assetId; + /** + * 资产名称 + */ + @ExcelProperty(value = "资产名称") + private String assetName; + /** * 领用人id */ @ExcelProperty(value = "领用人id") private Long userId; + /** + * 领用人姓名 + */ + @ExcelProperty(value = "领用人姓名") + private String userName; + /** * 数量 */ @@ -66,6 +78,12 @@ public class ApplicationVo implements Serializable { @ExcelProperty(value = "审批人id") private Long acceptanceUserId; + /** + * 审批人姓名 + */ + @ExcelProperty(value = "审批人姓名") + private String acceptanceUserName; + /** * 审批时间 */ @@ -85,4 +103,5 @@ public class ApplicationVo implements Serializable { private Date createTime; + } diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/AssetVo.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/AssetVo.java index 61c8b5a..b1879e8 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/AssetVo.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/domain/vo/AssetVo.java @@ -48,6 +48,12 @@ public class AssetVo implements Serializable { @ExcelProperty(value = "类型") private String model; + /** + * 类型名称 + */ + @ExcelProperty(value = "类型名称") + private String modelName; + /** * 规格 */ @@ -78,6 +84,12 @@ public class AssetVo implements Serializable { @ExcelProperty(value = "仓库id") private Long depotId; + /** + * 仓库名称 + */ + @ExcelProperty(value = "仓库名称") + private String depotName; + /** * 描述信息 */ @@ -88,8 +100,13 @@ public class AssetVo implements Serializable { * 供应商id */ @ExcelProperty(value = "供应商id") - private Long suppliersId; + private String suppliersId; + /** + * 供应商名称 + */ + @ExcelProperty(value = "供应商名称") + private String suppliersName; /** * 入库时间 */ diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ApplicationServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ApplicationServiceImpl.java index 384b49c..0bed043 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ApplicationServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/ApplicationServiceImpl.java @@ -1,5 +1,7 @@ package org.dromara.property.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.mybatis.core.page.TableDataInfo; @@ -9,6 +11,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.dromara.property.domain.Asset; +import org.dromara.property.domain.vo.AssetVo; +import org.dromara.property.mapper.AssetMapper; +import org.dromara.system.api.RemoteUserService; import org.springframework.stereotype.Service; import org.dromara.property.domain.bo.ApplicationBo; import org.dromara.property.domain.vo.ApplicationVo; @@ -32,6 +38,8 @@ import java.util.Collection; public class ApplicationServiceImpl implements IApplicationService { private final ApplicationMapper baseMapper; + private final AssetMapper assetMapper; + private final RemoteUserService remoteUserService; /** * 查询资产领用 @@ -41,7 +49,12 @@ public class ApplicationServiceImpl implements IApplicationService { */ @Override public ApplicationVo queryById(Long id){ - return baseMapper.selectVoById(id); + ApplicationVo applicationVo = baseMapper.selectVoById(id); + applicationVo.setUserName(remoteUserService.selectUserNameById(applicationVo.getUserId())); + applicationVo.setAcceptanceUserName(remoteUserService.selectUserNameById(applicationVo.getAcceptanceUserId())); + AssetVo assetVo = assetMapper.selectVoById(applicationVo.getAssetId()); + applicationVo.setAssetName(assetVo==null?"资产不存在" : assetVo.getName()); + return applicationVo; } /** @@ -55,6 +68,12 @@ public class ApplicationServiceImpl implements IApplicationService { public TableDataInfo queryPageList(ApplicationBo bo, PageQuery pageQuery) { LambdaQueryWrapper lqw = buildQueryWrapper(bo); Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + result.getRecords().forEach(r -> r.setUserName(remoteUserService.selectUserNameById(r.getUserId()))); + result.getRecords().forEach(r -> r.setAcceptanceUserName(remoteUserService.selectUserNameById(r.getAcceptanceUserId()))); + result.getRecords().forEach(r -> { + AssetVo assetVo = assetMapper.selectVoById(r.getAssetId()); + r.setAssetName(assetVo==null?"资产不存在" : assetVo.getName()); + }); return TableDataInfo.build(result); } @@ -67,7 +86,14 @@ public class ApplicationServiceImpl implements IApplicationService { @Override public List queryList(ApplicationBo bo) { LambdaQueryWrapper lqw = buildQueryWrapper(bo); - return baseMapper.selectVoList(lqw); + List applicationVos = baseMapper.selectVoList(lqw); + applicationVos.forEach(r -> r.setUserName(remoteUserService.selectUserNameById(r.getUserId()))); + applicationVos.forEach(r -> r.setAcceptanceUserName(remoteUserService.selectUserNameById(r.getAcceptanceUserId()))); + applicationVos.forEach(r -> { + AssetVo assetVo = assetMapper.selectVoById(r.getAssetId()); + r.setAssetName(assetVo==null?"资产不存在" : assetVo.getName()); + }); + return applicationVos; } private LambdaQueryWrapper buildQueryWrapper(ApplicationBo bo) { @@ -106,12 +132,25 @@ public class ApplicationServiceImpl implements IApplicationService { * * @param bo 资产领用 * @return 是否修改成功 + * + * */ @Override public Boolean updateByBo(ApplicationBo bo) { Application update = MapstructUtils.convert(bo, Application.class); validEntityBeforeSave(update); - return baseMapper.updateById(update) > 0; + boolean b = baseMapper.updateById(update) > 0; + if (b&&bo.getState()==1){ + Asset asset = assetMapper.selectById(bo.getAssetId()); + if (asset.getStock()>=update.getNumber()) { + UpdateWrapper assetUpdateWrapper = new UpdateWrapper<>(); + assetUpdateWrapper.eq("id",bo.getAssetId()) + .set("stock",assetMapper.selectVoById(bo.getAssetId()).getStock()-update.getNumber()); + assetMapper.update(assetUpdateWrapper); + } + + } + return b; } /** diff --git a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/AssetServiceImpl.java b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/AssetServiceImpl.java index 251b8a7..d431806 100644 --- a/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/AssetServiceImpl.java +++ b/ruoyi-modules/Property/src/main/java/org/dromara/property/service/impl/AssetServiceImpl.java @@ -9,6 +9,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.dromara.property.domain.AssetType; +import org.dromara.property.domain.Depot; +import org.dromara.property.domain.Suppliers; +import org.dromara.property.mapper.AssetTypeMapper; +import org.dromara.property.mapper.DepotMapper; +import org.dromara.property.mapper.SuppliersMapper; import org.springframework.stereotype.Service; import org.dromara.property.domain.bo.AssetBo; import org.dromara.property.domain.vo.AssetVo; @@ -32,6 +38,9 @@ import java.util.Collection; public class AssetServiceImpl implements IAssetService { private final AssetMapper baseMapper; + private final DepotMapper depotMapper; + private final SuppliersMapper suppliersMapper; + private final AssetTypeMapper assetTypeMapper; /** * 查询资产管理 @@ -41,7 +50,14 @@ public class AssetServiceImpl implements IAssetService { */ @Override public AssetVo queryById(Long id){ - return baseMapper.selectVoById(id); + AssetVo assetVo = baseMapper.selectVoById(id); + Depot depot = depotMapper.selectById(assetVo.getDepotId()); + assetVo.setDepotName(depot ==null ? "类型不存在" : depot.getDepotName()); + Suppliers suppliers = suppliersMapper.selectById(assetVo.getSuppliersId()); + assetVo.setSuppliersName(suppliers ==null ? "供应商不存在" : suppliers.getSuppliersName()); + AssetType assetType = assetTypeMapper.selectById(assetVo.getModel()); + assetVo.setModelName(assetType ==null ? "类型不存在" : assetType.getAssetTypeName()); + return assetVo; } /** @@ -55,6 +71,18 @@ public class AssetServiceImpl implements IAssetService { public TableDataInfo queryPageList(AssetBo bo, PageQuery pageQuery) { LambdaQueryWrapper lqw = buildQueryWrapper(bo); Page result = baseMapper.selectVoPage(pageQuery.build(), lqw); + result.getRecords().forEach(r -> { + AssetType assetType = assetTypeMapper.selectById(r.getModel()); + r.setModelName(assetType==null ? "资产类型不存在" : assetType.getAssetTypeName()); + }); + result.getRecords().forEach(r -> { + Suppliers suppliers = suppliersMapper.selectById(r.getSuppliersId()); + r.setSuppliersName(suppliers==null? "供应商不存在" : suppliers.getSuppliersName()); + }); + result.getRecords().forEach(r -> { + Depot depot = depotMapper.selectById(r.getDepotId()); + r.setDepotName(depot==null? "仓库不存在" : depot.getDepotName()); + }); return TableDataInfo.build(result); } @@ -67,7 +95,20 @@ public class AssetServiceImpl implements IAssetService { @Override public List queryList(AssetBo bo) { LambdaQueryWrapper lqw = buildQueryWrapper(bo); - return baseMapper.selectVoList(lqw); + List assetVos = baseMapper.selectVoList(lqw); + assetVos.forEach(r -> { + AssetType assetType = assetTypeMapper.selectById(r.getModel()); + r.setModelName(assetType==null? "类型不存在" : assetType.getAssetTypeName()); + }); + assetVos.forEach(r -> { + Suppliers suppliers = suppliersMapper.selectById(r.getModel()); + r.setSuppliersName(suppliers==null? "供应商不存在" : suppliers.getSuppliersName()); + }); + assetVos.forEach(r -> { + Depot depot = depotMapper.selectById(r.getModel()); + r.setDepotName(depot==null? "仓库不存在" : depot.getDepotName()); + }); + return assetVos; } private LambdaQueryWrapper buildQueryWrapper(AssetBo bo) {