供应商管理

This commit is contained in:
PQZ 2024-09-12 11:09:14 +08:00
parent 7ba03242d0
commit 3516465c9d
13 changed files with 232 additions and 116 deletions

View File

@ -3,11 +3,15 @@ package cn.iocoder.yudao.module.supplier.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.label.vo.LabelPageReqVO;
import cn.iocoder.yudao.module.label.vo.LabelRespVO;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplier;
import cn.iocoder.yudao.module.supplier.service.BaseSupplierService;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierPageReqVO;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierSaveReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -61,6 +65,14 @@ public class BaseSupplierController {
return success(true);
}
/**
* 删除供应商
*
* @param id 供应商id
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
* @author PQZ
* @date 10:04 2024/9/12
**/
@DeleteMapping("/delete")
@Operation(summary = "删除供应商")
@Parameter(name = "id", description = "编号", required = true)
@ -70,6 +82,14 @@ public class BaseSupplierController {
return success(true);
}
/**
* 获取供应商
*
* @param id 供应商id
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO>
* @author PQZ
* @date 10:04 2024/9/12
**/
@GetMapping("/get")
@Operation(summary = "获得供应商")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@ -79,12 +99,21 @@ public class BaseSupplierController {
return success(BeanUtils.toBean(baseSupplier, BaseSupplierRespVO.class));
}
/**
*
* @author PQZ
* @date 10:05 2024/9/12
* @param pageReqVO BaseSupplierPageReqVO 实体
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<cn.iocoder.yudao.framework.common.pojo.PageResult<cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO>>
**/
@GetMapping("/page")
@Operation(summary = "获得供应商分页")
@PreAuthorize("@ss.hasPermission('supplier:base-supplier:query')")
public CommonResult<PageResult<BaseSupplierRespVO>> getBaseSupplierPage(@Valid BaseSupplierPageReqVO pageReqVO) {
PageResult<BaseSupplier> pageResult = baseSupplierService.getBaseSupplierPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, BaseSupplierRespVO.class));
public CommonResult<IPage<?>> getBaseSupplierPage(BaseSupplierPageReqVO pageReqVO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<BaseSupplierRespVO> page = new Page<>(pageNo, pageSize);
return success(baseSupplierService.queryListPage(pageReqVO,page));
}

View File

@ -25,7 +25,7 @@ public class BaseSupplierAccount extends TenantBaseDO {
/**
* 主键标识
*/
@TableId(type = IdType.INPUT)
@TableId(type = IdType.ASSIGN_UUID)
private String id;
/**
* 供应商id

View File

@ -1,8 +1,13 @@
package cn.iocoder.yudao.module.supplier.mapper;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplier;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierPageReqVO;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 供应商 Mapper
@ -12,4 +17,15 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface BaseSupplierMapper extends BaseMapper<BaseSupplier> {
/**
* 分页查询供应商信息
*
* @param pageReqVO BaseSupplierPageReqVO实体
* @param page 分页参数
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO>
* @author PQZ
* @date 10:12 2024/9/12
**/
IPage<BaseSupplierRespVO> selectListPage(@Param("entity") BaseSupplierPageReqVO pageReqVO, Page<BaseSupplierRespVO> page);
}

View File

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.supplier.service;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplierAccount;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* 供应商关联账户 Service 接口
*
@ -10,5 +12,29 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface BaseSupplierAccountService extends IService<BaseSupplierAccount> {
/**
*
* @author PQZ
* @date 9:45 2024/9/12
* @param supplierId 供应商id
* @param list List<BaseSupplierAccount> 实体
**/
void saveBaseSupplierAccount(String supplierId, List<BaseSupplierAccount> list);
/**
* 通过供应商id删除供应商
* @author PQZ
* @date 9:54 2024/9/12
* @param supplierId 供应商id
**/
void removeBySupplierId(String supplierId);
/**
* 根据供应商id查询银行账户
* @author PQZ
* @date 9:59 2024/9/12
* @param supplierId 供应商id
* @return java.util.List<cn.iocoder.yudao.module.supplier.entity.BaseSupplierAccount>
**/
List<BaseSupplierAccount> listBySupplierId(String supplierId);
}

View File

@ -3,7 +3,10 @@ package cn.iocoder.yudao.module.supplier.service;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplier;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierPageReqVO;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierSaveReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
@ -18,33 +21,43 @@ public interface BaseSupplierService extends IService<BaseSupplier> {
/**
* 保存供应商
*
* @param saveReqVO BaseSupplierSaveReqVO
* @author PQZ
* @date 11:00 2024/9/11
* @param saveReqVO BaseSupplierSaveReqVO
**/
**/
void saveBaseSupplier(BaseSupplierSaveReqVO saveReqVO);
/**
* 删除供应商
* 删除供应商信息
*
* @param id 编号
*/
* @param id 供应商id
* @author PQZ
* @date 9:56 2024/9/12
**/
void deleteBaseSupplier(String id);
/**
* 获得供应商
*
* @param id 编号
* @return 供应商
*/
BaseSupplier getBaseSupplier(String id);
/**
* 获得供应商分页
* 通过供应商id查询供应商
*
* @param pageReqVO 分页查询
* @return 供应商分页
*/
PageResult<BaseSupplier> getBaseSupplierPage(BaseSupplierPageReqVO pageReqVO);
* @param id 供应商id
* @return cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO
* @author PQZ
* @date 10:02 2024/9/12
**/
BaseSupplierRespVO getBaseSupplier(String id);
/**
* 分页查询供应商信息
*
* @param pageReqVO BaseSupplierPageReqVO实体
* @param page 分页参数
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO>
* @author PQZ
* @date 10:09 2024/9/12
**/
IPage<BaseSupplierRespVO> queryListPage(BaseSupplierPageReqVO pageReqVO, Page<BaseSupplierRespVO> page);
}

View File

@ -3,10 +3,13 @@ package cn.iocoder.yudao.module.supplier.service.impl;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplierAccount;
import cn.iocoder.yudao.module.supplier.mapper.BaseSupplierAccountMapper;
import cn.iocoder.yudao.module.supplier.service.BaseSupplierAccountService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
/**
* 供应商关联账户 Service 实现类
*
@ -17,4 +20,51 @@ import org.springframework.validation.annotation.Validated;
public class BaseSupplierAccountServiceImpl extends ServiceImpl<BaseSupplierAccountMapper, BaseSupplierAccount> implements BaseSupplierAccountService {
/**
* @param supplierId 供应商id
* @param list List<BaseSupplierAccount> 实体
* @return void
* @author PQZ
* @date 9:45 2024/9/12
**/
@Override
public void saveBaseSupplierAccount(String supplierId, List<BaseSupplierAccount> list) {
/*1、删除原有供应商银行账户*/
removeBySupplierId(supplierId);
/*2、保存新账户*/
list.forEach(item -> {
item.setId(null);
item.setSupplierId(supplierId);
});
saveBatch(list);
}
/**
* 通过供应商id删除供应商
*
* @param supplierId 供应商id
* @author PQZ
* @date 9:54 2024/9/12
**/
@Override
public void removeBySupplierId(String supplierId) {
LambdaQueryWrapper<BaseSupplierAccount> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(BaseSupplierAccount::getSupplierId,supplierId);
remove(lambdaQueryWrapper);
}
/**
* 根据供应商id查询银行账户
*
* @param supplierId 供应商id
* @return java.util.List<cn.iocoder.yudao.module.supplier.entity.BaseSupplierAccount>
* @author PQZ
* @date 9:59 2024/9/12
**/
@Override
public List<BaseSupplierAccount> listBySupplierId(String supplierId) {
LambdaQueryWrapper<BaseSupplierAccount> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(BaseSupplierAccount::getSupplierId,supplierId);
return list(lambdaQueryWrapper);
}
}

View File

@ -3,15 +3,23 @@ package cn.iocoder.yudao.module.supplier.service.impl;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplier;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplierAccount;
import cn.iocoder.yudao.module.supplier.mapper.BaseSupplierMapper;
import cn.iocoder.yudao.module.supplier.service.BaseSupplierAccountService;
import cn.iocoder.yudao.module.supplier.service.BaseSupplierService;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierPageReqVO;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierSaveReqVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
/**
* 供应商 Service 实现类
@ -24,6 +32,8 @@ public class BaseSupplierServiceImpl extends ServiceImpl<BaseSupplierMapper, Bas
@Resource
private BaseSupplierMapper baseSupplierMapper;
@Resource
private BaseSupplierAccountService baseSupplierAccountService;
/**
* 保存供应商
@ -34,27 +44,62 @@ public class BaseSupplierServiceImpl extends ServiceImpl<BaseSupplierMapper, Bas
**/
@Override
public void saveBaseSupplier(BaseSupplierSaveReqVO saveReqVO) {
//保存主表信息
BaseSupplier baseSupplier = BeanUtils.toBean(saveReqVO, BaseSupplier.class);
saveOrUpdate(baseSupplier);
//保存子表信息
baseSupplierAccountService.saveBaseSupplierAccount(baseSupplier.getId(),saveReqVO.getAccountList());
}
/**
* 删除供应商信息
* @author PQZ
* @date 9:56 2024/9/12
* @param id 供应商id
**/
@Override
public void deleteBaseSupplier(String id) {
// 校验存在
baseSupplierMapper.deleteById(id);
//删除主表信息
removeById(id);
//删除子表信息
baseSupplierAccountService.removeBySupplierId(id);
}
/**
* 通过供应商id查询供应商
* @author PQZ
* @date 10:02 2024/9/12
* @param id 供应商id
* @return cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO
**/
@Override
public BaseSupplier getBaseSupplier(String id) {
return baseSupplierMapper.selectById(id);
public BaseSupplierRespVO getBaseSupplier(String id) {
//主表内容
BaseSupplier baseSupplier = getById(id);
BaseSupplierRespVO respVO = BeanUtils.toBean(baseSupplier, BaseSupplierRespVO.class);
//银行账户内容
List<BaseSupplierAccount> list = baseSupplierAccountService.listBySupplierId(id);
respVO.setAccountList(list);
//关联子公司转换
if (StringUtils.isNotBlank(respVO.getCorpId())) {
respVO.setCorpIds(Arrays.asList(respVO.getCorpId().split(",")));
}
return respVO;
}
/**
* 分页查询供应商信息
*
* @param pageReqVO BaseSupplierPageReqVO实体
* @param page 分页参数
* @return com.baomidou.mybatisplus.core.metadata.IPage<cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO>
* @author PQZ
* @date 10:09 2024/9/12
**/
@Override
public PageResult<BaseSupplier> getBaseSupplierPage(BaseSupplierPageReqVO pageReqVO) {
return null;
public IPage<BaseSupplierRespVO> queryListPage(BaseSupplierPageReqVO pageReqVO, Page<BaseSupplierRespVO> page) {
return baseSupplierMapper.selectListPage(pageReqVO,page);
}
}

View File

@ -1,34 +0,0 @@
package cn.iocoder.yudao.module.supplier.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 供应商关联账户分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BaseSupplierAccountPageReqVO extends PageParam {
@Schema(description = "供应商id", example = "9583")
private String supplierId;
@Schema(description = "开户行", example = "王五")
private String bankName;
@Schema(description = "开户名", example = "李四")
private String countName;
@Schema(description = "银行卡号")
private String countNo;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -1,35 +0,0 @@
package cn.iocoder.yudao.module.supplier.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 供应商关联账户 Response VO")
@Data
@ExcelIgnoreUnannotated
public class BaseSupplierAccountRespVO {
@Schema(description = "供应商id", example = "9583")
@ExcelProperty("供应商id")
private String supplierId;
@Schema(description = "开户行", example = "王五")
@ExcelProperty("开户行")
private String bankName;
@Schema(description = "开户名", example = "李四")
@ExcelProperty("开户名")
private String countName;
@Schema(description = "银行卡号")
@ExcelProperty("银行卡号")
private String countNo;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -1,12 +0,0 @@
package cn.iocoder.yudao.module.supplier.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 供应商关联账户新增/修改 Request VO")
@Data
public class BaseSupplierAccountSaveReqVO {
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.supplier.vo;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplier;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplierAccount;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -10,5 +11,9 @@ import com.alibaba.excel.annotation.*;
@Data
@ExcelIgnoreUnannotated
public class BaseSupplierRespVO extends BaseSupplier {
/**关联子公司*/
List<String> corpIds = new ArrayList<>();
/**供应商银行账户*/
List<BaseSupplierAccount> accountList;
}

View File

@ -1,16 +1,16 @@
package cn.iocoder.yudao.module.supplier.vo;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplier;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplierAccount;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 供应商新增/修改 Request VO")
@Data
public class BaseSupplierSaveReqVO extends BaseSupplier {
/**供应商银行账户*/
List<BaseSupplierAccount> accountList;
}

View File

@ -9,4 +9,17 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectListPage" resultType="cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO">
select dbs.* from dl_base_supplier dbs
<where>
dbs.deleted = 0
<if test="entity.name != null and entity.name != ''">
and dbs.name like concat('%', #{entity.name}, '%')
</if>
<if test="entity.name != null and entity.name != ''">
and dbs.corp_id like concat('%', #{entity.corpId}, '%')
</if>
</where>
ORDER BY dbs.create_time DESC
</select>
</mapper>