生成销售管理-客户管理后端代码

This commit is contained in:
2025-11-19 16:56:58 +08:00
parent 3e1ad8abbf
commit 0bbd96f6cf
30 changed files with 2059 additions and 52 deletions

View File

@ -38,12 +38,12 @@ import lombok.AllArgsConstructor;
/**
* @title: 客户
* @Author 管理员
* @Date: 2025-11-18
* @Date: 2025-11-19
* @Version 1.0
*/
@RestController
@RequestMapping("/sales/customer")
@Api(value = "/sales/customer",tags = "客户管理")
@RequestMapping("/sales" + "/customer")
@Api(value = "/sales" + "/customer",tags = "客户代码")
@AllArgsConstructor
public class CustomerController {
@ -67,7 +67,8 @@ public class CustomerController {
.like(StrUtil.isNotBlank(dto.getNatureCode()),LngCustomer::getNatureCode,dto.getNatureCode())
.like(StrUtil.isNotBlank(dto.getValid()),LngCustomer::getValid,dto.getValid())
.like(StrUtil.isNotBlank(dto.getApproCode()),LngCustomer::getApproCode,dto.getApproCode())
.orderByDesc(LngCustomer::getId);
.orderByDesc(LngCustomer::getId)
.select(LngCustomer.class,x -> VoToColumnUtil.fieldsToColumns(LngCustomerPageVo.class).contains(x.getProperty()));
IPage<LngCustomer> page = customerService.page(ConventPage.getPage(dto), queryWrapper);
PageOutput<LngCustomerPageVo> pageOutput = ConventPage.getPageOutput(page, LngCustomerPageVo.class);
return R.ok(pageOutput);
@ -77,7 +78,7 @@ public class CustomerController {
@ApiOperation(value="根据id查询LngCustomer信息")
@SaCheckPermission("customer:detail")
public R info(@RequestParam Long id){
LngCustomer lngCustomer = customerService.getById(id);
LngCustomer lngCustomer = customerService.getByIdDeep(id);
if (lngCustomer == null) {
return R.error("找不到此数据!");
}
@ -112,7 +113,7 @@ public class CustomerController {
@ApiOperation(value = "删除")
@SaCheckPermission("customer:delete")
public R delete(@Valid @RequestBody List<Long> ids){
return R.ok(dataService.deleteByIds(UpdateLngCustomerDto.class, ids));
return R.ok(dataService.deleteByIds(UpdateLngCustomerDto.class, ids));
}
@ -120,7 +121,7 @@ public class CustomerController {
@ApiOperation(value = "启用LngCustomer")
@SaCheckPermission("customer:enable")
public R enable(@Valid @RequestBody List<Long> ids){
return R.ok(dataService.enable(UpdateLngCustomerDto.class,ids));
return R.ok(dataService.enable(UpdateLngCustomerDto.class,ids));
}
@ -128,7 +129,7 @@ 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));
return R.ok(dataService.disable(UpdateLngCustomerDto.class,ids));
}

View File

@ -3,11 +3,13 @@ package com.xjrsoft.module.sales.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.yulichang.annotation.EntityMapping;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -17,7 +19,7 @@ import lombok.Data;
/**
* @title: 客户
* @Author 管理员
* @Date: 2025-11-18
* @Date: 2025-11-19
* @Version 1.0
*/
@Data
@ -257,5 +259,33 @@ public class LngCustomer implements Serializable {
private Long ruleUserId;
/**
* lngCustomerAttrPower
*/
@ApiModelProperty("lngCustomerAttrPower子表")
@TableField(exist = false)
@EntityMapping(thisField = "cuCode", joinField = "cuCode")
private List<LngCustomerAttrPower> lngCustomerAttrPowerList;
/**
* lngCustomerBank
*/
@ApiModelProperty("lngCustomerBank子表")
@TableField(exist = false)
@EntityMapping(thisField = "cuCode", joinField = "cuCode")
private List<LngCustomerBank> lngCustomerBankList;
/**
* lngCustomerDoc
*/
@ApiModelProperty("lngCustomerDoc子表")
@TableField(exist = false)
@EntityMapping(thisField = "cuCode", joinField = "cuCode")
private List<LngCustomerDoc> lngCustomerDocList;
/**
* lngCustomerContact
*/
@ApiModelProperty("lngCustomerContact子表")
@TableField(exist = false)
@EntityMapping(thisField = "cuCode", joinField = "cuCode")
private List<LngCustomerContact> lngCustomerContactList;
}

View File

@ -0,0 +1,111 @@
package com.xjrsoft.module.sales.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @title: 客户
* @Author 管理员
* @Date: 2025-11-19
* @Version 1.0
*/
@Data
@TableName("lng_customer_attr_power")
@ApiModel(value = "客户对象", description = "客户")
public class LngCustomerAttrPower implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ApiModelProperty("主键")
@TableId
private Long id;
/**
* 客户编码
*/
@ApiModelProperty("客户编码")
private String cuCode;
/**
* 管道编码
*/
@ApiModelProperty("管道编码")
private String lineCode;
/**
* 装机量万KW
*/
@ApiModelProperty("装机量万KW")
private BigDecimal capacity;
/**
* 备注
*/
@ApiModelProperty("备注")
private String note;
/**
* 创建人id
*/
@ApiModelProperty("创建人id")
@TableField(fill = FieldFill.INSERT)
private Long createUserId;
/**
* 创建时间
*/
@ApiModelProperty("创建时间")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createDate;
/**
* 修改人id
*/
@ApiModelProperty("修改人id")
@TableField(fill = FieldFill.UPDATE)
private Long modifyUserId;
/**
* 修改时间
*/
@ApiModelProperty("修改时间")
@TableField(fill = FieldFill.UPDATE)
private LocalDateTime modifyDate;
/**
* 租户id
*/
@ApiModelProperty("租户id")
private Long tenantId;
/**
* 部门id
*/
@ApiModelProperty("部门id")
@TableField(fill = FieldFill.INSERT)
private Long deptId;
/**
* 数据权限id
*/
@ApiModelProperty("数据权限id")
@TableField(fill = FieldFill.INSERT)
private Long ruleUserId;
}

View File

@ -0,0 +1,126 @@
package com.xjrsoft.module.sales.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import com.github.yulichang.annotation.EntityMapping;
import io.swagger.annotations.ApiModel;
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 java.util.List;
/**
* @title: 客户
* @Author 管理员
* @Date: 2025-11-19
* @Version 1.0
*/
@Data
@TableName("lng_customer_bank")
@ApiModel(value = "客户对象", description = "客户")
public class LngCustomerBank implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ApiModelProperty("主键")
@TableId
private Long id;
/**
* 客户编码
*/
@ApiModelProperty("客户编码")
private String cuCode;
/**
* 银行
*/
@ApiModelProperty("银行")
private String bankCode;
/**
* 账号名称
*/
@ApiModelProperty("账号名称")
private String accountName;
/**
* 账号
*/
@ApiModelProperty("账号")
private String account;
/**
* 默认账号(Y-是N-否只能有一个Y的有效记录)
*/
@ApiModelProperty("默认账号(Y-是N-否只能有一个Y的有效记录)")
private String defaultSign;
/**
* 备注
*/
@ApiModelProperty("备注")
private String note;
/**
* 创建人id
*/
@ApiModelProperty("创建人id")
@TableField(fill = FieldFill.INSERT)
private Long createUserId;
/**
* 创建时间
*/
@ApiModelProperty("创建时间")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createDate;
/**
* 修改人id
*/
@ApiModelProperty("修改人id")
@TableField(fill = FieldFill.UPDATE)
private Long modifyUserId;
/**
* 修改时间
*/
@ApiModelProperty("修改时间")
@TableField(fill = FieldFill.UPDATE)
private LocalDateTime modifyDate;
/**
* 租户id
*/
@ApiModelProperty("租户id")
private Long tenantId;
/**
* 部门id
*/
@ApiModelProperty("部门id")
@TableField(fill = FieldFill.INSERT)
private Long deptId;
/**
* 数据权限id
*/
@ApiModelProperty("数据权限id")
@TableField(fill = FieldFill.INSERT)
private Long ruleUserId;
}

View File

@ -0,0 +1,132 @@
package com.xjrsoft.module.sales.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import com.github.yulichang.annotation.EntityMapping;
import io.swagger.annotations.ApiModel;
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 java.util.List;
/**
* @title: 客户
* @Author 管理员
* @Date: 2025-11-19
* @Version 1.0
*/
@Data
@TableName("lng_customer_contact")
@ApiModel(value = "客户对象", description = "客户")
public class LngCustomerContact implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ApiModelProperty("主键")
@TableId
private Long id;
/**
* 客户编码
*/
@ApiModelProperty("客户编码")
private String cuCode;
/**
* 姓名
*/
@ApiModelProperty("姓名")
private String contactName;
/**
* 联系电话
*/
@ApiModelProperty("联系电话")
private String tel;
/**
* 通讯地址
*/
@ApiModelProperty("通讯地址")
private String addrMail;
/**
* 电子邮箱
*/
@ApiModelProperty("电子邮箱")
private String email;
/**
* 职位
*/
@ApiModelProperty("职位")
private String position;
/**
* 备注
*/
@ApiModelProperty("备注")
private String note;
/**
* 创建人id
*/
@ApiModelProperty("创建人id")
@TableField(fill = FieldFill.INSERT)
private Long createUserId;
/**
* 创建时间
*/
@ApiModelProperty("创建时间")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createDate;
/**
* 修改人id
*/
@ApiModelProperty("修改人id")
@TableField(fill = FieldFill.UPDATE)
private Long modifyUserId;
/**
* 修改时间
*/
@ApiModelProperty("修改时间")
@TableField(fill = FieldFill.UPDATE)
private LocalDateTime modifyDate;
/**
* 租户id
*/
@ApiModelProperty("租户id")
private Long tenantId;
/**
* 部门id
*/
@ApiModelProperty("部门id")
@TableField(fill = FieldFill.INSERT)
private Long deptId;
/**
* 数据权限id
*/
@ApiModelProperty("数据权限id")
@TableField(fill = FieldFill.INSERT)
private Long ruleUserId;
}

View File

@ -0,0 +1,132 @@
package com.xjrsoft.module.sales.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import com.github.yulichang.annotation.EntityMapping;
import io.swagger.annotations.ApiModel;
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 java.util.List;
/**
* @title: 客户
* @Author 管理员
* @Date: 2025-11-19
* @Version 1.0
*/
@Data
@TableName("lng_customer_doc")
@ApiModel(value = "客户对象", description = "客户")
public class LngCustomerDoc implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ApiModelProperty("主键")
@TableId
private Long id;
/**
* 客户编码
*/
@ApiModelProperty("客户编码")
private String cuCode;
/**
* 资质证书类型
*/
@ApiModelProperty("资质证书类型")
private String docTypeCode;
/**
* 资质证书编号
*/
@ApiModelProperty("资质证书编号")
private String docNo;
/**
* 有效期开始
*/
@ApiModelProperty("有效期开始")
private LocalDateTime dateFrom;
/**
* 有效期结束
*/
@ApiModelProperty("有效期结束")
private LocalDateTime dateTo;
/**
* 显示顺序
*/
@ApiModelProperty("显示顺序")
private Short sort;
/**
* 备注
*/
@ApiModelProperty("备注")
private String note;
/**
* 创建人id
*/
@ApiModelProperty("创建人id")
@TableField(fill = FieldFill.INSERT)
private Long createUserId;
/**
* 创建时间
*/
@ApiModelProperty("创建时间")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createDate;
/**
* 修改人id
*/
@ApiModelProperty("修改人id")
@TableField(fill = FieldFill.UPDATE)
private Long modifyUserId;
/**
* 修改时间
*/
@ApiModelProperty("修改时间")
@TableField(fill = FieldFill.UPDATE)
private LocalDateTime modifyDate;
/**
* 租户id
*/
@ApiModelProperty("租户id")
private Long tenantId;
/**
* 部门id
*/
@ApiModelProperty("部门id")
@TableField(fill = FieldFill.INSERT)
private Long deptId;
/**
* 数据权限id
*/
@ApiModelProperty("数据权限id")
@TableField(fill = FieldFill.INSERT)
private Long ruleUserId;
}

View File

@ -0,0 +1,17 @@
package com.xjrsoft.module.sales.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.xjrsoft.module.sales.entity.LngCustomerAttrPower;
import org.apache.ibatis.annotations.Mapper;
/**
* @title: mapper
* @Author 管理员
* @Date: 2025-11-19
* @Version 1.0
*/
@Mapper
public interface LngCustomerAttrPowerMapper extends MPJBaseMapper<LngCustomerAttrPower> {
}

View File

@ -0,0 +1,17 @@
package com.xjrsoft.module.sales.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.xjrsoft.module.sales.entity.LngCustomerBank;
import org.apache.ibatis.annotations.Mapper;
/**
* @title: mapper
* @Author 管理员
* @Date: 2025-11-19
* @Version 1.0
*/
@Mapper
public interface LngCustomerBankMapper extends MPJBaseMapper<LngCustomerBank> {
}

View File

@ -0,0 +1,17 @@
package com.xjrsoft.module.sales.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.xjrsoft.module.sales.entity.LngCustomerContact;
import org.apache.ibatis.annotations.Mapper;
/**
* @title: mapper
* @Author 管理员
* @Date: 2025-11-19
* @Version 1.0
*/
@Mapper
public interface LngCustomerContactMapper extends MPJBaseMapper<LngCustomerContact> {
}

View File

@ -0,0 +1,17 @@
package com.xjrsoft.module.sales.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.xjrsoft.module.sales.entity.LngCustomerDoc;
import org.apache.ibatis.annotations.Mapper;
/**
* @title: mapper
* @Author 管理员
* @Date: 2025-11-19
* @Version 1.0
*/
@Mapper
public interface LngCustomerDocMapper extends MPJBaseMapper<LngCustomerDoc> {
}

View File

@ -8,10 +8,10 @@ import org.apache.ibatis.annotations.Mapper;
/**
* @title: mapper
* @Author 管理员
* @Date: 2025-11-18
* @Date: 2025-11-19
* @Version 1.0
*/
@Mapper
public interface LngCustomerMapper extends BaseMapper<LngCustomer> {
public interface LngCustomerMapper extends MPJBaseMapper<LngCustomer> {
}

View File

@ -11,9 +11,32 @@ import java.util.List;
/**
* @title: service
* @Author 管理员
* @Date: 2025-11-18
* @Date: 2025-11-19
* @Version 1.0
*/
public interface ICustomerService extends IService<LngCustomer> {
public interface ICustomerService extends MPJBaseService<LngCustomer>, MPJDeepService<LngCustomer>, MPJRelationService<LngCustomer> {
/**
* 新增
*
* @param lngCustomer
* @return
*/
Boolean add(LngCustomer lngCustomer);
/**
* 更新
*
* @param lngCustomer
* @return
*/
Boolean update(LngCustomer lngCustomer);
/**
* 删除
*
* @param ids
* @return
*/
Boolean delete(List<Long> ids);
}

View File

@ -2,6 +2,14 @@ package com.xjrsoft.module.sales.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.xjrsoft.module.sales.entity.LngCustomerAttrPower;
import com.xjrsoft.module.sales.mapper.LngCustomerAttrPowerMapper;
import com.xjrsoft.module.sales.entity.LngCustomerBank;
import com.xjrsoft.module.sales.mapper.LngCustomerBankMapper;
import com.xjrsoft.module.sales.entity.LngCustomerDoc;
import com.xjrsoft.module.sales.mapper.LngCustomerDocMapper;
import com.xjrsoft.module.sales.entity.LngCustomerContact;
import com.xjrsoft.module.sales.mapper.LngCustomerContactMapper;
import com.xjrsoft.module.sales.entity.LngCustomer;
import com.xjrsoft.module.sales.mapper.LngCustomerMapper;
import com.xjrsoft.module.sales.service.ICustomerService;
@ -16,10 +24,176 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
/**
* @title: service
* @Author 管理员
* @Date: 2025-11-18
* @Date: 2025-11-19
* @Version 1.0
*/
@Service
@AllArgsConstructor
public class CustomerServiceImpl extends ServiceImpl<LngCustomerMapper, LngCustomer> implements ICustomerService {
public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, LngCustomer> implements ICustomerService {
private final LngCustomerMapper customerLngCustomerMapper;
private final LngCustomerAttrPowerMapper customerLngCustomerAttrPowerMapper;
private final LngCustomerBankMapper customerLngCustomerBankMapper;
private final LngCustomerDocMapper customerLngCustomerDocMapper;
private final LngCustomerContactMapper customerLngCustomerContactMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean add(LngCustomer lngCustomer) {
customerLngCustomerMapper.insert(lngCustomer);
for (LngCustomerAttrPower lngCustomerAttrPower : lngCustomer.getLngCustomerAttrPowerList()) {
lngCustomerAttrPower.setCuCode(lngCustomer.getCuCode());
customerLngCustomerAttrPowerMapper.insert(lngCustomerAttrPower);
}
for (LngCustomerBank lngCustomerBank : lngCustomer.getLngCustomerBankList()) {
lngCustomerBank.setCuCode(lngCustomer.getCuCode());
customerLngCustomerBankMapper.insert(lngCustomerBank);
}
for (LngCustomerDoc lngCustomerDoc : lngCustomer.getLngCustomerDocList()) {
lngCustomerDoc.setCuCode(lngCustomer.getCuCode());
customerLngCustomerDocMapper.insert(lngCustomerDoc);
}
for (LngCustomerContact lngCustomerContact : lngCustomer.getLngCustomerContactList()) {
lngCustomerContact.setCuCode(lngCustomer.getCuCode());
customerLngCustomerContactMapper.insert(lngCustomerContact);
}
return true;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean update(LngCustomer lngCustomer) {
customerLngCustomerMapper.updateById(lngCustomer);
//********************************* LngCustomerAttrPower 增删改 开始 *******************************************/
{
// 查出所有子级的id
List<LngCustomerAttrPower> lngCustomerAttrPowerList = customerLngCustomerAttrPowerMapper.selectList(Wrappers.lambdaQuery(LngCustomerAttrPower.class).eq(LngCustomerAttrPower::getCuCode, lngCustomer.getCuCode()).select(LngCustomerAttrPower::getId));
List<Long> lngCustomerAttrPowerIds = lngCustomerAttrPowerList.stream().map(LngCustomerAttrPower::getId).collect(Collectors.toList());
//原有子表单 没有被删除的主键
List<Long> lngCustomerAttrPowerOldIds = lngCustomer.getLngCustomerAttrPowerList().stream().map(LngCustomerAttrPower::getId).filter(Objects::nonNull).collect(Collectors.toList());
//找到需要删除的id
List<Long> lngCustomerAttrPowerRemoveIds = lngCustomerAttrPowerIds.stream().filter(item -> !lngCustomerAttrPowerOldIds.contains(item)).collect(Collectors.toList());
for (LngCustomerAttrPower lngCustomerAttrPower : lngCustomer.getLngCustomerAttrPowerList()) {
//如果不等于空则修改
if (lngCustomerAttrPower.getId() != null) {
customerLngCustomerAttrPowerMapper.updateById(lngCustomerAttrPower);
}
//如果等于空 则新增
else {
//已经不存在的id 删除
lngCustomerAttrPower.setCuCode(lngCustomer.getCuCode());
customerLngCustomerAttrPowerMapper.insert(lngCustomerAttrPower);
}
}
//已经不存在的id 删除
if(lngCustomerAttrPowerRemoveIds.size() > 0){
customerLngCustomerAttrPowerMapper.deleteBatchIds(lngCustomerAttrPowerRemoveIds);
}
}
//********************************* LngCustomerAttrPower 增删改 结束 *******************************************/
//********************************* LngCustomerBank 增删改 开始 *******************************************/
{
// 查出所有子级的id
List<LngCustomerBank> lngCustomerBankList = customerLngCustomerBankMapper.selectList(Wrappers.lambdaQuery(LngCustomerBank.class).eq(LngCustomerBank::getCuCode, lngCustomer.getCuCode()).select(LngCustomerBank::getId));
List<Long> lngCustomerBankIds = lngCustomerBankList.stream().map(LngCustomerBank::getId).collect(Collectors.toList());
//原有子表单 没有被删除的主键
List<Long> lngCustomerBankOldIds = lngCustomer.getLngCustomerBankList().stream().map(LngCustomerBank::getId).filter(Objects::nonNull).collect(Collectors.toList());
//找到需要删除的id
List<Long> lngCustomerBankRemoveIds = lngCustomerBankIds.stream().filter(item -> !lngCustomerBankOldIds.contains(item)).collect(Collectors.toList());
for (LngCustomerBank lngCustomerBank : lngCustomer.getLngCustomerBankList()) {
//如果不等于空则修改
if (lngCustomerBank.getId() != null) {
customerLngCustomerBankMapper.updateById(lngCustomerBank);
}
//如果等于空 则新增
else {
//已经不存在的id 删除
lngCustomerBank.setCuCode(lngCustomer.getCuCode());
customerLngCustomerBankMapper.insert(lngCustomerBank);
}
}
//已经不存在的id 删除
if(lngCustomerBankRemoveIds.size() > 0){
customerLngCustomerBankMapper.deleteBatchIds(lngCustomerBankRemoveIds);
}
}
//********************************* LngCustomerBank 增删改 结束 *******************************************/
//********************************* LngCustomerDoc 增删改 开始 *******************************************/
{
// 查出所有子级的id
List<LngCustomerDoc> lngCustomerDocList = customerLngCustomerDocMapper.selectList(Wrappers.lambdaQuery(LngCustomerDoc.class).eq(LngCustomerDoc::getCuCode, lngCustomer.getCuCode()).select(LngCustomerDoc::getId));
List<Long> lngCustomerDocIds = lngCustomerDocList.stream().map(LngCustomerDoc::getId).collect(Collectors.toList());
//原有子表单 没有被删除的主键
List<Long> lngCustomerDocOldIds = lngCustomer.getLngCustomerDocList().stream().map(LngCustomerDoc::getId).filter(Objects::nonNull).collect(Collectors.toList());
//找到需要删除的id
List<Long> lngCustomerDocRemoveIds = lngCustomerDocIds.stream().filter(item -> !lngCustomerDocOldIds.contains(item)).collect(Collectors.toList());
for (LngCustomerDoc lngCustomerDoc : lngCustomer.getLngCustomerDocList()) {
//如果不等于空则修改
if (lngCustomerDoc.getId() != null) {
customerLngCustomerDocMapper.updateById(lngCustomerDoc);
}
//如果等于空 则新增
else {
//已经不存在的id 删除
lngCustomerDoc.setCuCode(lngCustomer.getCuCode());
customerLngCustomerDocMapper.insert(lngCustomerDoc);
}
}
//已经不存在的id 删除
if(lngCustomerDocRemoveIds.size() > 0){
customerLngCustomerDocMapper.deleteBatchIds(lngCustomerDocRemoveIds);
}
}
//********************************* LngCustomerDoc 增删改 结束 *******************************************/
//********************************* LngCustomerContact 增删改 开始 *******************************************/
{
// 查出所有子级的id
List<LngCustomerContact> lngCustomerContactList = customerLngCustomerContactMapper.selectList(Wrappers.lambdaQuery(LngCustomerContact.class).eq(LngCustomerContact::getCuCode, lngCustomer.getCuCode()).select(LngCustomerContact::getId));
List<Long> lngCustomerContactIds = lngCustomerContactList.stream().map(LngCustomerContact::getId).collect(Collectors.toList());
//原有子表单 没有被删除的主键
List<Long> lngCustomerContactOldIds = lngCustomer.getLngCustomerContactList().stream().map(LngCustomerContact::getId).filter(Objects::nonNull).collect(Collectors.toList());
//找到需要删除的id
List<Long> lngCustomerContactRemoveIds = lngCustomerContactIds.stream().filter(item -> !lngCustomerContactOldIds.contains(item)).collect(Collectors.toList());
for (LngCustomerContact lngCustomerContact : lngCustomer.getLngCustomerContactList()) {
//如果不等于空则修改
if (lngCustomerContact.getId() != null) {
customerLngCustomerContactMapper.updateById(lngCustomerContact);
}
//如果等于空 则新增
else {
//已经不存在的id 删除
lngCustomerContact.setCuCode(lngCustomer.getCuCode());
customerLngCustomerContactMapper.insert(lngCustomerContact);
}
}
//已经不存在的id 删除
if(lngCustomerContactRemoveIds.size() > 0){
customerLngCustomerContactMapper.deleteBatchIds(lngCustomerContactRemoveIds);
}
}
//********************************* LngCustomerContact 增删改 结束 *******************************************/
return true;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean delete(List<Long> ids) {
customerLngCustomerMapper.deleteBatchIds(ids);
customerLngCustomerAttrPowerMapper.delete(Wrappers.lambdaQuery(LngCustomerAttrPower.class).in(LngCustomerAttrPower::getCuCode, ids));
customerLngCustomerBankMapper.delete(Wrappers.lambdaQuery(LngCustomerBank.class).in(LngCustomerBank::getCuCode, ids));
customerLngCustomerDocMapper.delete(Wrappers.lambdaQuery(LngCustomerDoc.class).in(LngCustomerDoc::getCuCode, ids));
customerLngCustomerContactMapper.delete(Wrappers.lambdaQuery(LngCustomerContact.class).in(LngCustomerContact::getCuCode, ids));
return true;
}
}