供应商管理

This commit is contained in:
2025-12-17 18:03:36 +08:00
parent 9abc415a8a
commit 18a9fa1bf9
9 changed files with 108 additions and 218 deletions

View File

@ -1,25 +1,16 @@
package com.xjrsoft.module.sales.dto;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import com.pictc.annotations.datalog.LogAttrField;
import com.pictc.annotations.datalog.LogField;
import com.pictc.annotations.datalog.LogTable;
import com.xjrsoft.module.system.dto.UpdateLngFileUploadDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalTime;
import java.time.LocalDateTime;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.List;
import com.pictc.annotations.datalog.LogTable;
import com.pictc.annotations.datalog.LogField;
import com.pictc.annotations.datalog.LogJoin;
import com.pictc.annotations.datalog.LogJoinColumn;
import com.pictc.annotations.datalog.JoinCaseType;
import com.pictc.annotations.datalog.JoinType;
import com.pictc.annotations.datalog.LogAttrField;
import com.pictc.annotations.datalog.ValueDirectionType;
import com.xjrsoft.module.system.dto.UpdateLngFileUploadDto;
import com.xjrsoft.module.system.vo.LngFileUploadVo;

View File

@ -1,22 +1,16 @@
package com.xjrsoft.module.supplier.dto;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import com.pictc.annotations.datalog.LogAttrField;
import com.pictc.annotations.datalog.LogField;
import com.pictc.annotations.datalog.LogTable;
import com.xjrsoft.module.system.dto.UpdateLngFileUploadDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalTime;
import java.time.LocalDateTime;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.List;
import com.pictc.annotations.datalog.LogTable;
import com.pictc.annotations.datalog.LogField;
import com.pictc.annotations.datalog.LogJoin;
import com.pictc.annotations.datalog.LogJoinColumn;
import com.pictc.annotations.datalog.JoinCaseType;
import com.pictc.annotations.datalog.JoinType;
import com.pictc.annotations.datalog.ValueDirectionType;
@ -103,5 +97,11 @@ public class UpdateLngSupplierDocDto implements Serializable {
@ApiModelProperty("租户id")
private Long tenantId;
/**
* lngFileUpload
*/
@ApiModelProperty("lngFileUpload子表")
@LogAttrField
private List<UpdateLngFileUploadDto> fileList;
}

View File

@ -6,11 +6,13 @@ import java.util.List;
import com.pictc.annotations.datalog.JoinCaseType;
import com.pictc.annotations.datalog.JoinType;
import com.pictc.annotations.datalog.LogAttrField;
import com.pictc.annotations.datalog.LogField;
import com.pictc.annotations.datalog.LogJoin;
import com.pictc.annotations.datalog.LogJoinColumn;
import com.pictc.annotations.datalog.LogTable;
import com.pictc.annotations.datalog.ValueDirectionType;
import com.xjrsoft.module.system.dto.UpdateLngFileUploadDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -221,4 +223,11 @@ public class UpdateLngSupplierDto implements Serializable {
},
caseType = JoinCaseType.FULL, target = UpdateLngSupplierDocDto.class, type = JoinType.MANY)
private List<UpdateLngSupplierDocDto> lngSupplierDocList;
/**
* lngFileUpload
*/
@ApiModelProperty("lngFileUpload子表")
@LogAttrField
private List<UpdateLngFileUploadDto> lngFileUploadList;
}

View File

@ -8,6 +8,8 @@ import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.util.List;
import com.xjrsoft.module.system.vo.LngFileUploadVo;
/**
* @title: 表单出参
* @Author 管理员
@ -129,7 +131,11 @@ public class LngSupplierDocVo {
private Long ruleUserId;
/**
* lngFileUpload
*/
@ApiModelProperty("lngFileUpload子表")
private List<LngFileUploadVo> fileList;
}

View File

@ -3,6 +3,8 @@ package com.xjrsoft.module.supplier.vo;
import java.time.LocalDateTime;
import java.util.List;
import com.xjrsoft.module.system.vo.LngFileUploadVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -235,5 +237,11 @@ public class LngSupplierVo {
*/
@ApiModelProperty("lngSupplierDoc子表")
private List<LngSupplierDocVo> lngSupplierDocList;
/**
* lngFileUpload
*/
@ApiModelProperty("lngFileUpload子表")
private List<LngFileUploadVo> lngFileUploadList;
}

View File

@ -15,17 +15,10 @@ import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.pictc.datalog.DataOperationContent;
import com.pictc.datalog.DataOperationListener;
import com.pictc.enums.BusinessCode;
import com.pictc.enums.ExceptionCommonCode;
import com.pictc.utils.StringUtils;
import com.xjrsoft.common.exception.BusinessException;
import com.xjrsoft.common.model.result.R;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.utils.VoToColumnUtil;
import com.xjrsoft.module.common.db.utils.CommonCallUtils;
import com.xjrsoft.module.datalog.service.DatalogService;
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
import com.xjrsoft.module.sales.dto.LngCustomerPageDto;
@ -33,11 +26,9 @@ import com.xjrsoft.module.sales.dto.UpdateLngCustomerDto;
import com.xjrsoft.module.sales.entity.LngCustomer;
import com.xjrsoft.module.sales.service.ICustomerService;
import com.xjrsoft.module.sales.vo.LngCustomerPageVo;
import com.xjrsoft.module.sales.vo.LngCustomerVo;
import com.xjrsoft.module.system.client.ICodeRuleClient;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -92,12 +83,6 @@ public class CustomerController {
@ApiOperation(value="根据id查询LngCustomer信息")
@SaCheckPermission("customer:detail")
public R info(@RequestParam Long id){
/**
LngCustomer lngCustomer = customerService.getCustomerById(id);
if (lngCustomer == null) {
return R.error("找不到此数据!");
}
return R.ok(BeanUtil.toBean(lngCustomer, LngCustomerVo.class));**/
return R.ok(customerService.getCustomerById(id));
}
@ -150,24 +135,6 @@ public class CustomerController {
public R update(@Valid @RequestBody UpdateLngCustomerDto dto){
return R.ok(dataService.updateById(dto));
/**
return R.ok(dataService.updateById(dto,new DataOperationListener<UpdateLngCustomerDto>() {
@Override
public UpdateLngCustomerDto before(DataOperationContent<UpdateLngCustomerDto> content) {
return content.getObj();
}
@Override
public UpdateLngCustomerDto after(DataOperationContent<UpdateLngCustomerDto> content) {
String msg = CommonCallUtils.saveAfter(content.getTableName(),content.getIdValue());
if (StringUtils.isNotEmpty(msg)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
}
return content.getObj();
}
}));
**/
}
@DeleteMapping

View File

@ -21,12 +21,14 @@ import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.utils.VoToColumnUtil;
import com.xjrsoft.module.datalog.service.DatalogService;
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
import com.xjrsoft.module.sales.dto.UpdateLngCustomerDto;
import com.xjrsoft.module.supplier.dto.LngSupplierPageDto;
import com.xjrsoft.module.supplier.dto.UpdateLngSupplierDto;
import com.xjrsoft.module.supplier.entity.LngSupplier;
import com.xjrsoft.module.supplier.service.ISupplierService;
import com.xjrsoft.module.supplier.vo.LngSupplierPageVo;
import com.xjrsoft.module.supplier.vo.LngSupplierVo;
import com.xjrsoft.module.system.client.ICodeRuleClient;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.bean.BeanUtil;
@ -50,6 +52,11 @@ public class SupplierController {
private final ISupplierService supplierService;
private final DatalogService dataService;
private final ICodeRuleClient codeRuleClient;
private final String SUPPLIER_CODE = "supplierCode";
@GetMapping(value = "/page")
@ApiOperation(value="LngSupplier列表(分页)")
@ -77,11 +84,7 @@ public class SupplierController {
@ApiOperation(value="根据id查询LngSupplier信息")
@SaCheckPermission("supplier:detail")
public R info(@RequestParam Long id){
LngSupplier lngSupplier = supplierService.getByIdDeep(id);
if (lngSupplier == null) {
return R.error("找不到此数据!");
}
return R.ok(BeanUtil.toBean(lngSupplier, LngSupplierVo.class));
return R.ok(supplierService.getSupplierById(id));
}
@GetMapping(value = "/datalog")
@ -97,8 +100,11 @@ public class SupplierController {
@ApiOperation(value = "新增LngSupplier")
@SaCheckPermission("supplier:add")
public R add(@Valid @RequestBody UpdateLngSupplierDto dto){
String code = codeRuleClient.genEncode(SUPPLIER_CODE);
dto.setSuCode("S"+code);
UpdateLngSupplierDto res = dataService.insert(dto);
return R.ok(res.getId());
codeRuleClient.useEncode(SUPPLIER_CODE);
return R.ok(res);
}
@PutMapping

View File

@ -5,6 +5,8 @@ import com.github.yulichang.base.MPJBaseService;
import com.github.yulichang.extension.mapping.base.MPJDeepService;
import com.github.yulichang.extension.mapping.base.MPJRelationService;
import com.xjrsoft.module.supplier.entity.LngSupplier;
import com.xjrsoft.module.supplier.vo.LngSupplierVo;
import lombok.Data;
import java.util.List;
@ -16,21 +18,7 @@ import java.util.List;
*/
public interface ISupplierService extends MPJBaseService<LngSupplier>, MPJDeepService<LngSupplier>, MPJRelationService<LngSupplier> {
/**
* 新增
*
* @param lngSupplier
* @return
*/
Boolean add(LngSupplier lngSupplier);
/**
* 更新
*
* @param lngSupplier
* @return
*/
Boolean update(LngSupplier lngSupplier);
/**
* 删除
@ -39,4 +27,6 @@ public interface ISupplierService extends MPJBaseService<LngSupplier>, MPJDeepSe
* @return
*/
Boolean delete(List<Long> ids);
LngSupplierVo getSupplierById(Long id);
}

View File

@ -1,23 +1,29 @@
package com.xjrsoft.module.supplier.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.xjrsoft.module.supplier.entity.LngSupplierBank;
import com.xjrsoft.module.supplier.mapper.LngSupplierBankMapper;
import com.xjrsoft.module.supplier.entity.LngSupplierContact;
import com.xjrsoft.module.supplier.mapper.LngSupplierContactMapper;
import com.xjrsoft.module.supplier.entity.LngSupplierDoc;
import com.xjrsoft.module.supplier.mapper.LngSupplierDocMapper;
import com.xjrsoft.module.supplier.entity.LngSupplier;
import com.xjrsoft.module.supplier.mapper.LngSupplierMapper;
import com.xjrsoft.module.supplier.service.ISupplierService;
import lombok.AllArgsConstructor;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.xjrsoft.module.supplier.entity.LngSupplier;
import com.xjrsoft.module.supplier.entity.LngSupplierBank;
import com.xjrsoft.module.supplier.entity.LngSupplierContact;
import com.xjrsoft.module.supplier.entity.LngSupplierDoc;
import com.xjrsoft.module.supplier.mapper.LngSupplierBankMapper;
import com.xjrsoft.module.supplier.mapper.LngSupplierContactMapper;
import com.xjrsoft.module.supplier.mapper.LngSupplierDocMapper;
import com.xjrsoft.module.supplier.mapper.LngSupplierMapper;
import com.xjrsoft.module.supplier.service.ISupplierService;
import com.xjrsoft.module.supplier.vo.LngSupplierDocVo;
import com.xjrsoft.module.supplier.vo.LngSupplierVo;
import com.xjrsoft.module.system.client.IFileClient;
import com.xjrsoft.module.system.vo.LngFileUploadVo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import lombok.AllArgsConstructor;
/**
* @title: service
@ -33,121 +39,8 @@ public class SupplierServiceImpl extends MPJBaseServiceImpl<LngSupplierMapper, L
private final LngSupplierBankMapper supplierLngSupplierBankMapper;
private final LngSupplierContactMapper supplierLngSupplierContactMapper;
private final LngSupplierDocMapper supplierLngSupplierDocMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean add(LngSupplier lngSupplier) {
supplierLngSupplierMapper.insert(lngSupplier);
for (LngSupplierBank lngSupplierBank : lngSupplier.getLngSupplierBankList()) {
lngSupplierBank.setSuCode(lngSupplier.getSuCode());
supplierLngSupplierBankMapper.insert(lngSupplierBank);
}
for (LngSupplierContact lngSupplierContact : lngSupplier.getLngSupplierContactList()) {
lngSupplierContact.setSuCode(lngSupplier.getSuCode());
supplierLngSupplierContactMapper.insert(lngSupplierContact);
}
for (LngSupplierDoc lngSupplierDoc : lngSupplier.getLngSupplierDocList()) {
lngSupplierDoc.setSuCode(lngSupplier.getSuCode());
supplierLngSupplierDocMapper.insert(lngSupplierDoc);
}
return true;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean update(LngSupplier lngSupplier) {
supplierLngSupplierMapper.updateById(lngSupplier);
//********************************* LngSupplierBank 增删改 开始 *******************************************/
{
// 查出所有子级的id
List<LngSupplierBank> lngSupplierBankList = supplierLngSupplierBankMapper.selectList(Wrappers.lambdaQuery(LngSupplierBank.class).eq(LngSupplierBank::getSuCode, lngSupplier.getSuCode()).select(LngSupplierBank::getId));
List<Long> lngSupplierBankIds = lngSupplierBankList.stream().map(LngSupplierBank::getId).collect(Collectors.toList());
//原有子表单 没有被删除的主键
List<Long> lngSupplierBankOldIds = lngSupplier.getLngSupplierBankList().stream().map(LngSupplierBank::getId).filter(Objects::nonNull).collect(Collectors.toList());
//找到需要删除的id
List<Long> lngSupplierBankRemoveIds = lngSupplierBankIds.stream().filter(item -> !lngSupplierBankOldIds.contains(item)).collect(Collectors.toList());
for (LngSupplierBank lngSupplierBank : lngSupplier.getLngSupplierBankList()) {
//如果不等于空则修改
if (lngSupplierBank.getId() != null) {
supplierLngSupplierBankMapper.updateById(lngSupplierBank);
}
//如果等于空 则新增
else {
//已经不存在的id 删除
lngSupplierBank.setSuCode(lngSupplier.getSuCode());
supplierLngSupplierBankMapper.insert(lngSupplierBank);
}
}
//已经不存在的id 删除
if(lngSupplierBankRemoveIds.size() > 0){
supplierLngSupplierBankMapper.deleteBatchIds(lngSupplierBankRemoveIds);
}
}
//********************************* LngSupplierBank 增删改 结束 *******************************************/
//********************************* LngSupplierContact 增删改 开始 *******************************************/
{
// 查出所有子级的id
List<LngSupplierContact> lngSupplierContactList = supplierLngSupplierContactMapper.selectList(Wrappers.lambdaQuery(LngSupplierContact.class).eq(LngSupplierContact::getSuCode, lngSupplier.getSuCode()).select(LngSupplierContact::getId));
List<Long> lngSupplierContactIds = lngSupplierContactList.stream().map(LngSupplierContact::getId).collect(Collectors.toList());
//原有子表单 没有被删除的主键
List<Long> lngSupplierContactOldIds = lngSupplier.getLngSupplierContactList().stream().map(LngSupplierContact::getId).filter(Objects::nonNull).collect(Collectors.toList());
//找到需要删除的id
List<Long> lngSupplierContactRemoveIds = lngSupplierContactIds.stream().filter(item -> !lngSupplierContactOldIds.contains(item)).collect(Collectors.toList());
for (LngSupplierContact lngSupplierContact : lngSupplier.getLngSupplierContactList()) {
//如果不等于空则修改
if (lngSupplierContact.getId() != null) {
supplierLngSupplierContactMapper.updateById(lngSupplierContact);
}
//如果等于空 则新增
else {
//已经不存在的id 删除
lngSupplierContact.setSuCode(lngSupplier.getSuCode());
supplierLngSupplierContactMapper.insert(lngSupplierContact);
}
}
//已经不存在的id 删除
if(lngSupplierContactRemoveIds.size() > 0){
supplierLngSupplierContactMapper.deleteBatchIds(lngSupplierContactRemoveIds);
}
}
//********************************* LngSupplierContact 增删改 结束 *******************************************/
//********************************* LngSupplierDoc 增删改 开始 *******************************************/
{
// 查出所有子级的id
List<LngSupplierDoc> lngSupplierDocList = supplierLngSupplierDocMapper.selectList(Wrappers.lambdaQuery(LngSupplierDoc.class).eq(LngSupplierDoc::getSuCode, lngSupplier.getSuCode()).select(LngSupplierDoc::getId));
List<Long> lngSupplierDocIds = lngSupplierDocList.stream().map(LngSupplierDoc::getId).collect(Collectors.toList());
//原有子表单 没有被删除的主键
List<Long> lngSupplierDocOldIds = lngSupplier.getLngSupplierDocList().stream().map(LngSupplierDoc::getId).filter(Objects::nonNull).collect(Collectors.toList());
//找到需要删除的id
List<Long> lngSupplierDocRemoveIds = lngSupplierDocIds.stream().filter(item -> !lngSupplierDocOldIds.contains(item)).collect(Collectors.toList());
for (LngSupplierDoc lngSupplierDoc : lngSupplier.getLngSupplierDocList()) {
//如果不等于空则修改
if (lngSupplierDoc.getId() != null) {
supplierLngSupplierDocMapper.updateById(lngSupplierDoc);
}
//如果等于空 则新增
else {
//已经不存在的id 删除
lngSupplierDoc.setSuCode(lngSupplier.getSuCode());
supplierLngSupplierDocMapper.insert(lngSupplierDoc);
}
}
//已经不存在的id 删除
if(lngSupplierDocRemoveIds.size() > 0){
supplierLngSupplierDocMapper.deleteBatchIds(lngSupplierDocRemoveIds);
}
}
//********************************* LngSupplierDoc 增删改 结束 *******************************************/
return true;
}
private final IFileClient fileClient;
@Override
@Transactional(rollbackFor = Exception.class)
@ -159,4 +52,24 @@ public class SupplierServiceImpl extends MPJBaseServiceImpl<LngSupplierMapper, L
return true;
}
@Override
public LngSupplierVo getSupplierById(Long id) {
LngSupplier lngSupplier = this.getByIdDeep(id);
if(lngSupplier == null) {
return null;
}
LngSupplierVo vo = BeanUtil.toBean(lngSupplier, LngSupplierVo.class);
if(CollectionUtil.isNotEmpty(vo.getLngSupplierDocList())) {
for(LngSupplierDocVo lngSupplierDoc: vo.getLngSupplierDocList()) {
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_Supplier_doc", "fileList", lngSupplierDoc.getId());
lngSupplierDoc.setFileList(fileList);
}
}
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_Supplier", "lngFileUploadList", vo.getId());
vo.setLngFileUploadList(fileList);
return vo;
}
}