|
|
@@ -16,7 +16,6 @@ import org.springblade.client.corps.service.ICorpsTypeService;
|
|
|
import org.springblade.client.entity.CorpsDesc;
|
|
|
import org.springblade.client.entity.CorpsType;
|
|
|
import org.springblade.client.entity.CorpsTypeDesc;
|
|
|
-import org.springblade.client.entity.GoodsDesc;
|
|
|
import org.springblade.client.vo.CorpListVo;
|
|
|
import org.springblade.client.vo.CorpsDescVO;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
@@ -162,9 +161,27 @@ public class CorpsDescController extends BladeController {
|
|
|
throw new SecurityException("存在绑定的财务信息,禁止删除");
|
|
|
}
|
|
|
|
|
|
+ CorpsDesc desc = corpsDescService.getById(corpsDesc.getId());
|
|
|
+ List<String> typeList = Arrays.stream(desc.getCorpType().split(",")).collect(Collectors.toList());
|
|
|
+ if (typeList.size() <= 1) {
|
|
|
+ corpsDesc.setIsDeleted(1);
|
|
|
+ return R.status(corpsDescService.updateById(corpsDesc));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> typeIdList = corpsTypeService.list(new LambdaQueryWrapper<CorpsType>()
|
|
|
+ .eq(CorpsType::getCorpType, corpsDesc.getCorpType())
|
|
|
+ .eq(CorpsType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(CorpsType::getIsDeleted, 0)
|
|
|
+ ).stream().map(CorpsType::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ corpsTypeDescService.remove(new LambdaQueryWrapper<CorpsTypeDesc>()
|
|
|
+ .eq(CorpsTypeDesc::getCorpId, corpsDesc.getId())
|
|
|
+ .in(CorpsTypeDesc::getCorpTypeId, typeIdList)
|
|
|
+ );
|
|
|
|
|
|
- corpsDesc.setIsDeleted(1);
|
|
|
- return R.status(corpsDescService.updateById(corpsDesc));
|
|
|
+ typeList.remove(corpsDesc.getCorpType());
|
|
|
+ desc.setCorpType(String.join(",", typeList));
|
|
|
+ return R.status(corpsDescService.updateById(desc));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -292,33 +309,33 @@ public class CorpsDescController extends BladeController {
|
|
|
}
|
|
|
//获取客户类别及其子类别
|
|
|
List<Long> corpsTypeIdList = new ArrayList<>();
|
|
|
- if (StringUtils.isNotBlank(corpsDesc.getCorpsTypeName())){
|
|
|
+ if (StringUtils.isNotBlank(corpsDesc.getCorpsTypeName())) {
|
|
|
LambdaQueryWrapper<CorpsType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(CorpsType::getCname,corpsDesc.getCorpsTypeName());
|
|
|
- lambdaQueryWrapper.eq(CorpsType::getIsDeleted,0);
|
|
|
- lambdaQueryWrapper.eq(CorpsType::getTenantId,SecureUtil.getTenantId());
|
|
|
+ lambdaQueryWrapper.eq(CorpsType::getCname, corpsDesc.getCorpsTypeName());
|
|
|
+ lambdaQueryWrapper.eq(CorpsType::getIsDeleted, 0);
|
|
|
+ lambdaQueryWrapper.eq(CorpsType::getTenantId, SecureUtil.getTenantId());
|
|
|
List<CorpsType> corpsTypeList = corpsTypeService.list(lambdaQueryWrapper);
|
|
|
- if (CollectionUtils.isNotEmpty(corpsTypeList)){
|
|
|
- corpsTypeList.stream().forEach(item ->{
|
|
|
+ if (CollectionUtils.isNotEmpty(corpsTypeList)) {
|
|
|
+ corpsTypeList.stream().forEach(item -> {
|
|
|
corpsTypeService.selectChildById(item.getId(), corpsTypeIdList);
|
|
|
corpsTypeIdList.add(item.getId());
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
//获取客户类别对应的id
|
|
|
- if (CollectionUtils.isNotEmpty(corpsTypeIdList)){
|
|
|
+ if (CollectionUtils.isNotEmpty(corpsTypeIdList)) {
|
|
|
LambdaQueryWrapper<CorpsTypeDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(CorpsTypeDesc::getTenantId,SecureUtil.getTenantId());
|
|
|
- lambdaQueryWrapper.in(CorpsTypeDesc::getCorpTypeId,corpsTypeIdList);
|
|
|
+ lambdaQueryWrapper.eq(CorpsTypeDesc::getTenantId, SecureUtil.getTenantId());
|
|
|
+ lambdaQueryWrapper.in(CorpsTypeDesc::getCorpTypeId, corpsTypeIdList);
|
|
|
List<CorpsTypeDesc> list = corpsTypeDescService.list(lambdaQueryWrapper);
|
|
|
- if (CollectionUtils.isNotEmpty(list)){
|
|
|
- corpsDesc.setTypeList(list.stream().filter(e ->e.getCorpId() != null).map(CorpsTypeDesc::getCorpId).collect(Collectors.toList()));
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ corpsDesc.setTypeList(list.stream().filter(e -> e.getCorpId() != null).map(CorpsTypeDesc::getCorpId).collect(Collectors.toList()));
|
|
|
}
|
|
|
}
|
|
|
LambdaQueryWrapper<CorpsDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
lambdaQueryWrapper.like(Func.isNotEmpty(corpsDesc.getCname()), CorpsDesc::getCname, corpsDesc.getCname());
|
|
|
lambdaQueryWrapper.like(Func.isNotEmpty(corpsDesc.getCode()), CorpsDesc::getCode, corpsDesc.getCode());
|
|
|
- lambdaQueryWrapper.in(CollectionUtils.isNotEmpty(corpsDesc.getTypeList()),CorpsDesc::getId,corpsDesc.getTypeList());
|
|
|
+ lambdaQueryWrapper.in(CollectionUtils.isNotEmpty(corpsDesc.getTypeList()), CorpsDesc::getId, corpsDesc.getTypeList());
|
|
|
lambdaQueryWrapper.eq(CorpsDesc::getIsDeleted, 0);
|
|
|
lambdaQueryWrapper.eq(CorpsDesc::getTenantId, SecureUtil.getTenantId());
|
|
|
if ("KG".equals(corpsDesc.getCorpType())) {
|
|
|
@@ -326,11 +343,11 @@ public class CorpsDescController extends BladeController {
|
|
|
} else {
|
|
|
lambdaQueryWrapper.like(CorpsDesc::getCorpType, corpsDesc.getCorpType());
|
|
|
}
|
|
|
- if (Func.isNotEmpty(corpsDesc.getAdminProfiles())){
|
|
|
- lambdaQueryWrapper.and(i ->i.like(CorpsDesc::getAdminProfiles,corpsDesc.getAdminProfiles()).or().eq(CorpsDesc::getAdminProfiles,' '));
|
|
|
+ if (Func.isNotEmpty(corpsDesc.getAdminProfiles())) {
|
|
|
+ lambdaQueryWrapper.and(i -> i.like(CorpsDesc::getAdminProfiles, corpsDesc.getAdminProfiles()).or().eq(CorpsDesc::getAdminProfiles, ' '));
|
|
|
}
|
|
|
- if (StringUtils.isNotBlank(corpsDesc.getBelongtocompany())){
|
|
|
- lambdaQueryWrapper.and(i ->i.eq(CorpsDesc::getBelongtocompany,corpsDesc.getBelongtocompany()).or().isNull(CorpsDesc::getBelongtocompany));
|
|
|
+ if (StringUtils.isNotBlank(corpsDesc.getBelongtocompany())) {
|
|
|
+ lambdaQueryWrapper.and(i -> i.eq(CorpsDesc::getBelongtocompany, corpsDesc.getBelongtocompany()).or().isNull(CorpsDesc::getBelongtocompany));
|
|
|
}
|
|
|
List<CorpsDesc> corpsDescList = corpsDescService.list(lambdaQueryWrapper);
|
|
|
|
|
|
@@ -338,7 +355,7 @@ public class CorpsDescController extends BladeController {
|
|
|
voList.forEach(desc -> {
|
|
|
if (StringUtils.isNotBlank(desc.getBelongtocompany())) {
|
|
|
CorpsDesc company = corpsDescService.getById(desc.getBelongtocompany());
|
|
|
- if (company != null){
|
|
|
+ if (company != null) {
|
|
|
desc.setBelongCompany(company.getCname());
|
|
|
}
|
|
|
}
|