asset模块
This commit is contained in:
parent
d4927d2699
commit
e5145002a4
8
pom.xml
8
pom.xml
@ -73,10 +73,10 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
||||||
<profiles.active>dev</profiles.active>
|
<profiles.active>dev</profiles.active>
|
||||||
<!-- <nacos.server>127.0.0.1:8848</nacos.server>-->
|
<nacos.server>127.0.0.1:8848</nacos.server>
|
||||||
<!-- <logstash.address>127.0.0.1:4560</logstash.address>-->
|
<logstash.address>127.0.0.1:4560</logstash.address>
|
||||||
<nacos.server>47.109.37.87:8848</nacos.server>
|
<!-- <nacos.server>47.109.37.87:8848</nacos.server>-->
|
||||||
<logstash.address>47.109.37.87:4560</logstash.address>
|
<!-- <logstash.address>47.109.37.87:4560</logstash.address>-->
|
||||||
<nacos.discovery.group>DEFAULT_GROUP</nacos.discovery.group>
|
<nacos.discovery.group>DEFAULT_GROUP</nacos.discovery.group>
|
||||||
<nacos.config.group>DEFAULT_GROUP</nacos.config.group>
|
<nacos.config.group>DEFAULT_GROUP</nacos.config.group>
|
||||||
<nacos.username>nacos</nacos.username>
|
<nacos.username>nacos</nacos.username>
|
||||||
|
@ -42,12 +42,24 @@ public class ApplicationVo implements Serializable {
|
|||||||
@ExcelProperty(value = "资产id")
|
@ExcelProperty(value = "资产id")
|
||||||
private Long assetId;
|
private Long assetId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资产名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "资产名称")
|
||||||
|
private String assetName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 领用人id
|
* 领用人id
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "领用人id")
|
@ExcelProperty(value = "领用人id")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 领用人姓名
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "领用人姓名")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数量
|
* 数量
|
||||||
*/
|
*/
|
||||||
@ -66,6 +78,12 @@ public class ApplicationVo implements Serializable {
|
|||||||
@ExcelProperty(value = "审批人id")
|
@ExcelProperty(value = "审批人id")
|
||||||
private Long acceptanceUserId;
|
private Long acceptanceUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批人姓名
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "审批人姓名")
|
||||||
|
private String acceptanceUserName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 审批时间
|
* 审批时间
|
||||||
*/
|
*/
|
||||||
@ -85,4 +103,5 @@ public class ApplicationVo implements Serializable {
|
|||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,12 @@ public class AssetVo implements Serializable {
|
|||||||
@ExcelProperty(value = "类型")
|
@ExcelProperty(value = "类型")
|
||||||
private String model;
|
private String model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "类型名称")
|
||||||
|
private String modelName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格
|
* 规格
|
||||||
*/
|
*/
|
||||||
@ -78,6 +84,12 @@ public class AssetVo implements Serializable {
|
|||||||
@ExcelProperty(value = "仓库id")
|
@ExcelProperty(value = "仓库id")
|
||||||
private Long depotId;
|
private Long depotId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仓库名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "仓库名称")
|
||||||
|
private String depotName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述信息
|
* 描述信息
|
||||||
*/
|
*/
|
||||||
@ -88,8 +100,13 @@ public class AssetVo implements Serializable {
|
|||||||
* 供应商id
|
* 供应商id
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "供应商id")
|
@ExcelProperty(value = "供应商id")
|
||||||
private Long suppliersId;
|
private String suppliersId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 供应商名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "供应商名称")
|
||||||
|
private String suppliersName;
|
||||||
/**
|
/**
|
||||||
* 入库时间
|
* 入库时间
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package org.dromara.property.service.impl;
|
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.MapstructUtils;
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
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 com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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.springframework.stereotype.Service;
|
||||||
import org.dromara.property.domain.bo.ApplicationBo;
|
import org.dromara.property.domain.bo.ApplicationBo;
|
||||||
import org.dromara.property.domain.vo.ApplicationVo;
|
import org.dromara.property.domain.vo.ApplicationVo;
|
||||||
@ -32,6 +38,8 @@ import java.util.Collection;
|
|||||||
public class ApplicationServiceImpl implements IApplicationService {
|
public class ApplicationServiceImpl implements IApplicationService {
|
||||||
|
|
||||||
private final ApplicationMapper baseMapper;
|
private final ApplicationMapper baseMapper;
|
||||||
|
private final AssetMapper assetMapper;
|
||||||
|
private final RemoteUserService remoteUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询资产领用
|
* 查询资产领用
|
||||||
@ -41,7 +49,12 @@ public class ApplicationServiceImpl implements IApplicationService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ApplicationVo queryById(Long id){
|
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<ApplicationVo> queryPageList(ApplicationBo bo, PageQuery pageQuery) {
|
public TableDataInfo<ApplicationVo> queryPageList(ApplicationBo bo, PageQuery pageQuery) {
|
||||||
LambdaQueryWrapper<Application> lqw = buildQueryWrapper(bo);
|
LambdaQueryWrapper<Application> lqw = buildQueryWrapper(bo);
|
||||||
Page<ApplicationVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
Page<ApplicationVo> 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);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +86,14 @@ public class ApplicationServiceImpl implements IApplicationService {
|
|||||||
@Override
|
@Override
|
||||||
public List<ApplicationVo> queryList(ApplicationBo bo) {
|
public List<ApplicationVo> queryList(ApplicationBo bo) {
|
||||||
LambdaQueryWrapper<Application> lqw = buildQueryWrapper(bo);
|
LambdaQueryWrapper<Application> lqw = buildQueryWrapper(bo);
|
||||||
return baseMapper.selectVoList(lqw);
|
List<ApplicationVo> 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<Application> buildQueryWrapper(ApplicationBo bo) {
|
private LambdaQueryWrapper<Application> buildQueryWrapper(ApplicationBo bo) {
|
||||||
@ -106,12 +132,25 @@ public class ApplicationServiceImpl implements IApplicationService {
|
|||||||
*
|
*
|
||||||
* @param bo 资产领用
|
* @param bo 资产领用
|
||||||
* @return 是否修改成功
|
* @return 是否修改成功
|
||||||
|
*
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateByBo(ApplicationBo bo) {
|
public Boolean updateByBo(ApplicationBo bo) {
|
||||||
Application update = MapstructUtils.convert(bo, Application.class);
|
Application update = MapstructUtils.convert(bo, Application.class);
|
||||||
validEntityBeforeSave(update);
|
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<Asset> assetUpdateWrapper = new UpdateWrapper<>();
|
||||||
|
assetUpdateWrapper.eq("id",bo.getAssetId())
|
||||||
|
.set("stock",assetMapper.selectVoById(bo.getAssetId()).getStock()-update.getNumber());
|
||||||
|
assetMapper.update(assetUpdateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,6 +9,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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.springframework.stereotype.Service;
|
||||||
import org.dromara.property.domain.bo.AssetBo;
|
import org.dromara.property.domain.bo.AssetBo;
|
||||||
import org.dromara.property.domain.vo.AssetVo;
|
import org.dromara.property.domain.vo.AssetVo;
|
||||||
@ -32,6 +38,9 @@ import java.util.Collection;
|
|||||||
public class AssetServiceImpl implements IAssetService {
|
public class AssetServiceImpl implements IAssetService {
|
||||||
|
|
||||||
private final AssetMapper baseMapper;
|
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
|
@Override
|
||||||
public AssetVo queryById(Long id){
|
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<AssetVo> queryPageList(AssetBo bo, PageQuery pageQuery) {
|
public TableDataInfo<AssetVo> queryPageList(AssetBo bo, PageQuery pageQuery) {
|
||||||
LambdaQueryWrapper<Asset> lqw = buildQueryWrapper(bo);
|
LambdaQueryWrapper<Asset> lqw = buildQueryWrapper(bo);
|
||||||
Page<AssetVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
Page<AssetVo> 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);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +95,20 @@ public class AssetServiceImpl implements IAssetService {
|
|||||||
@Override
|
@Override
|
||||||
public List<AssetVo> queryList(AssetBo bo) {
|
public List<AssetVo> queryList(AssetBo bo) {
|
||||||
LambdaQueryWrapper<Asset> lqw = buildQueryWrapper(bo);
|
LambdaQueryWrapper<Asset> lqw = buildQueryWrapper(bo);
|
||||||
return baseMapper.selectVoList(lqw);
|
List<AssetVo> 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<Asset> buildQueryWrapper(AssetBo bo) {
|
private LambdaQueryWrapper<Asset> buildQueryWrapper(AssetBo bo) {
|
||||||
|
Loading…
Reference in New Issue
Block a user