修复bug
This commit is contained in:
@ -163,7 +163,7 @@ public class CustomerController {
|
||||
@ApiOperation(value = "删除")
|
||||
@SaCheckPermission("customer:delete")
|
||||
public R delete(@Valid @RequestBody List<Long> ids){
|
||||
//return R.ok(customerService.delete(ids));
|
||||
|
||||
return R.ok(dataService.deleteByIds(UpdateLngCustomerDto.class,ids, new DataOperationListener<UpdateLngCustomerDto>() {
|
||||
@Override
|
||||
public UpdateLngCustomerDto before(DataOperationContent<UpdateLngCustomerDto> content) {
|
||||
@ -182,7 +182,10 @@ public class CustomerController {
|
||||
@ApiOperation(value = "启用LngCustomer")
|
||||
@SaCheckPermission("customer:enable")
|
||||
public R enable(@Valid @RequestBody List<Long> ids){
|
||||
|
||||
Long count = customerService.countDisableByIds(ids);
|
||||
if(count != null && count > 0) {
|
||||
throw new BusinessException(BusinessCode.of(10500, "只能对已审批的客户才能进行启用操作"));
|
||||
}
|
||||
return R.ok(dataService.enable(UpdateLngCustomerDto.class,ids, new DataOperationListener<UpdateLngCustomerDto>() {
|
||||
@Override
|
||||
public UpdateLngCustomerDto before(DataOperationContent<UpdateLngCustomerDto> content) {
|
||||
@ -201,7 +204,10 @@ public class CustomerController {
|
||||
@ApiOperation(value = "禁用LngCustomer")
|
||||
@SaCheckPermission("customer:disable")
|
||||
public R disable(@Valid @RequestBody List<Long> ids){
|
||||
//return R.ok(dataService.disable(UpdateLngCustomerDto.class,ids));
|
||||
Long count = customerService.countDisableByIds(ids);
|
||||
if(count != null && count > 0) {
|
||||
throw new BusinessException(BusinessCode.of(10500, "只能对已审批的客户才能进行作废操作"));
|
||||
}
|
||||
return R.ok(dataService.disable(UpdateLngCustomerDto.class,ids, new DataOperationListener<UpdateLngCustomerDto>() {
|
||||
@Override
|
||||
public UpdateLngCustomerDto before(DataOperationContent<UpdateLngCustomerDto> content) {
|
||||
|
||||
@ -17,16 +17,12 @@ import com.xjrsoft.module.sales.vo.LngCustomerVo;
|
||||
|
||||
public interface ICustomerService extends MPJBaseService<LngCustomer>, MPJDeepService<LngCustomer>, MPJRelationService<LngCustomer> {
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
Boolean delete(List<Long> ids);
|
||||
|
||||
|
||||
LngCustomerVo getCustomerById(Long id);
|
||||
|
||||
LngCustomer getByCode(String code);
|
||||
|
||||
Long countDisableByIds(List<Long> ids);
|
||||
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.pictc.enums.ApproveCodeEnum;
|
||||
import com.pictc.enums.BusinessCode;
|
||||
import com.xjrsoft.common.exception.BusinessException;
|
||||
import com.xjrsoft.module.mdm.client.ILngBankClient;
|
||||
@ -46,34 +47,16 @@ import lombok.AllArgsConstructor;
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, LngCustomer> implements ICustomerService {
|
||||
private final LngCustomerMapper lngCustomerMapper;
|
||||
|
||||
private final LngCustomerMapper lngCustomerMapper;
|
||||
|
||||
private final LngCustomerAttrPowerMapper lngCustomerAttrPowerMapper;
|
||||
private final LngCustomerBankMapper lngCustomerBankMapper;
|
||||
private final LngCustomerDocMapper lngCustomerDocMapper;
|
||||
private final LngCustomerContactMapper lngCustomerContactMapper;
|
||||
|
||||
private final IFileClient fileClient;
|
||||
|
||||
private final ILngBankClient bankClient;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean delete(List<Long> ids) {
|
||||
List<LngCustomer> customerList = lngCustomerMapper.selectList(Wrappers.lambdaQuery(LngCustomer.class).in(LngCustomer::getId, ids));
|
||||
List<String> cuCodeList = customerList.stream().map(LngCustomer::getCuCode).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
lngCustomerMapper.deleteBatchIds(ids);
|
||||
if(CollectionUtil.isNotEmpty(cuCodeList)) {
|
||||
lngCustomerAttrPowerMapper.delete(Wrappers.lambdaQuery(LngCustomerAttrPower.class).in(LngCustomerAttrPower::getCuCode, cuCodeList));
|
||||
lngCustomerBankMapper.delete(Wrappers.lambdaQuery(LngCustomerBank.class).in(LngCustomerBank::getCuCode, cuCodeList));
|
||||
lngCustomerDocMapper.delete(Wrappers.lambdaQuery(LngCustomerDoc.class).in(LngCustomerDoc::getCuCode, cuCodeList));
|
||||
lngCustomerContactMapper.delete(Wrappers.lambdaQuery(LngCustomerContact.class).in(LngCustomerContact::getCuCode, cuCodeList));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public LngCustomerVo getCustomerById(Long id) {
|
||||
|
||||
@ -115,4 +98,12 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
|
||||
queryWrapper.eq(LngCustomer::getCuCode,code);
|
||||
return baseMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countDisableByIds(List<Long> ids) {
|
||||
LambdaQueryWrapper<LngCustomer> queryWrapper = new LambdaQueryWrapper<LngCustomer>();
|
||||
queryWrapper.in(LngCustomer::getId,ids);
|
||||
queryWrapper.ne(LngCustomer::getApproCode, ApproveCodeEnum.YSP.getCode());
|
||||
return baseMapper.selectCount(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +178,10 @@ public class SupplierController {
|
||||
@ApiOperation(value = "启用LngSupplier")
|
||||
@SaCheckPermission("supplier:enable")
|
||||
public R enable(@Valid @RequestBody List<Long> ids){
|
||||
//return R.ok(dataService.enable(UpdateLngSupplierDto.class,ids));
|
||||
Long count = supplierService.countDisableByIds(ids);
|
||||
if(count != null && count > 0) {
|
||||
throw new BusinessException(BusinessCode.of(10500, "只能对已审批的供应商才能进行启用操作"));
|
||||
}
|
||||
return R.ok(dataService.enable(UpdateLngSupplierDto.class,ids, new DataOperationListener<UpdateLngSupplierDto>() {
|
||||
@Override
|
||||
public UpdateLngSupplierDto before(DataOperationContent<UpdateLngSupplierDto> content) {
|
||||
@ -197,7 +200,10 @@ public class SupplierController {
|
||||
@ApiOperation(value = "禁用LngSupplier")
|
||||
@SaCheckPermission("supplier:disable")
|
||||
public R disable(@Valid @RequestBody List<Long> ids){
|
||||
//return R.ok(dataService.disable(UpdateLngSupplierDto.class,ids));
|
||||
Long count = supplierService.countDisableByIds(ids);
|
||||
if(count != null && count > 0) {
|
||||
throw new BusinessException(BusinessCode.of(10500, "只能对已审批的供应商才能进行作废操作"));
|
||||
}
|
||||
return R.ok(dataService.disable(UpdateLngSupplierDto.class,ids, new DataOperationListener<UpdateLngSupplierDto>() {
|
||||
@Override
|
||||
public UpdateLngSupplierDto before(DataOperationContent<UpdateLngSupplierDto> content) {
|
||||
|
||||
@ -11,6 +11,8 @@ import com.xjrsoft.module.supplier.vo.LngSupplierVo;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @title: service
|
||||
* @Author 管理员
|
||||
@ -33,4 +35,6 @@ public interface ISupplierService extends MPJBaseService<LngSupplier>, MPJDeepSe
|
||||
|
||||
LngSupplier getByCode(String code);
|
||||
|
||||
Long countDisableByIds(@Valid List<Long> ids);
|
||||
|
||||
}
|
||||
|
||||
@ -4,15 +4,17 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.pictc.enums.ApproveCodeEnum;
|
||||
import com.xjrsoft.module.mdm.client.ILngBankClient;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBBankDto;
|
||||
import com.xjrsoft.module.sales.vo.LngCustomerBankVo;
|
||||
import com.xjrsoft.module.supplier.entity.LngSupplier;
|
||||
import com.xjrsoft.module.supplier.entity.LngSupplierBank;
|
||||
import com.xjrsoft.module.supplier.entity.LngSupplierContact;
|
||||
@ -101,6 +103,14 @@ public class SupplierServiceImpl extends MPJBaseServiceImpl<LngSupplierMapper, L
|
||||
queryWrapper.eq(LngSupplier::getSuCode,code);
|
||||
return baseMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countDisableByIds(@Valid List<Long> ids) {
|
||||
LambdaQueryWrapper<LngSupplier> queryWrapper = new LambdaQueryWrapper<LngSupplier>();
|
||||
queryWrapper.in(LngSupplier::getId,ids);
|
||||
queryWrapper.ne(LngSupplier::getApproCode, ApproveCodeEnum.YSP.getCode());
|
||||
return baseMapper.selectCount(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user