客户管理
This commit is contained in:
@ -4,7 +4,6 @@ import java.util.List;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -16,19 +15,12 @@ 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.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.mdm.dto.UpdateLngBBankDto;
|
||||
import com.xjrsoft.module.sales.dto.LngCustomerPageDto;
|
||||
import com.xjrsoft.module.sales.dto.UpdateLngCustomerDto;
|
||||
import com.xjrsoft.module.sales.entity.LngCustomer;
|
||||
@ -113,7 +105,12 @@ public class CustomerController {
|
||||
@ApiOperation(value = "新增LngCustomer")
|
||||
@SaCheckPermission("customer:add")
|
||||
public R add(@Valid @RequestBody UpdateLngCustomerDto dto){
|
||||
|
||||
String code = codeRuleClient.genEncode(CUSTOMER_CODE);
|
||||
dto.setCuCode("C"+code);
|
||||
customerService.add(dto);
|
||||
codeRuleClient.useEncode(CUSTOMER_CODE);
|
||||
return R.ok();
|
||||
/**
|
||||
return R.ok(dataService.insert(dto,new DataOperationListener<UpdateLngCustomerDto>() {
|
||||
|
||||
@Override
|
||||
@ -133,7 +130,7 @@ public class CustomerController {
|
||||
return content.getObj();
|
||||
}
|
||||
}));
|
||||
|
||||
**/
|
||||
}
|
||||
|
||||
|
||||
@ -141,14 +138,16 @@ public class CustomerController {
|
||||
@ApiOperation(value = "修改LngCustomer")
|
||||
@SaCheckPermission("customer:edit")
|
||||
public R update(@Valid @RequestBody UpdateLngCustomerDto dto){
|
||||
return R.ok(dataService.updateById(dto));
|
||||
// return R.ok(dataService.updateById(dto));
|
||||
customerService.update(dto);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation(value = "删除")
|
||||
@SaCheckPermission("customer:delete")
|
||||
public R delete(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(dataService.deleteByIds(UpdateLngCustomerDto.class, ids));
|
||||
return R.ok(customerService.delete(ids));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
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.sales.dto.UpdateLngCustomerDto;
|
||||
import com.xjrsoft.module.sales.entity.LngCustomer;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
@ -22,7 +23,8 @@ public interface ICustomerService extends MPJBaseService<LngCustomer>, MPJDeepSe
|
||||
* @param lngCustomer
|
||||
* @return
|
||||
*/
|
||||
Boolean add(LngCustomer lngCustomer);
|
||||
|
||||
Boolean add(UpdateLngCustomerDto updateLngCustomerDto);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
@ -30,7 +32,7 @@ public interface ICustomerService extends MPJBaseService<LngCustomer>, MPJDeepSe
|
||||
* @param lngCustomer
|
||||
* @return
|
||||
*/
|
||||
Boolean update(LngCustomer lngCustomer);
|
||||
Boolean update(UpdateLngCustomerDto updateLngCustomerDto);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
@ -39,4 +41,5 @@ public interface ICustomerService extends MPJBaseService<LngCustomer>, MPJDeepSe
|
||||
* @return
|
||||
*/
|
||||
Boolean delete(List<Long> ids);
|
||||
|
||||
}
|
||||
|
||||
@ -10,9 +10,16 @@ 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.dto.UpdateLngCustomerAttrPowerDto;
|
||||
import com.xjrsoft.module.sales.dto.UpdateLngCustomerBankDto;
|
||||
import com.xjrsoft.module.sales.dto.UpdateLngCustomerContactDto;
|
||||
import com.xjrsoft.module.sales.dto.UpdateLngCustomerDocDto;
|
||||
import com.xjrsoft.module.sales.dto.UpdateLngCustomerDto;
|
||||
import com.xjrsoft.module.sales.entity.LngCustomer;
|
||||
import com.xjrsoft.module.sales.mapper.LngCustomerMapper;
|
||||
import com.xjrsoft.module.sales.service.ICustomerService;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -40,22 +47,33 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean add(LngCustomer lngCustomer) {
|
||||
public Boolean add(UpdateLngCustomerDto updateLngCustomerDto) {
|
||||
|
||||
LngCustomer lngCustomer = new LngCustomer();
|
||||
BeanUtil.copyProperties(updateLngCustomerDto, lngCustomer);
|
||||
customerLngCustomerMapper.insert(lngCustomer);
|
||||
for (LngCustomerAttrPower lngCustomerAttrPower : lngCustomer.getLngCustomerAttrPowerList()) {
|
||||
lngCustomerAttrPower.setCuCode(lngCustomer.getCuCode());
|
||||
for (UpdateLngCustomerAttrPowerDto updateLngCustomerAttrPowerDto : updateLngCustomerDto.getLngCustomerAttrPowerList()) {
|
||||
LngCustomerAttrPower lngCustomerAttrPower = new LngCustomerAttrPower();
|
||||
BeanUtil.copyProperties(updateLngCustomerAttrPowerDto, lngCustomerAttrPower);
|
||||
lngCustomerAttrPower.setCuCode(lngCustomer.getCuCode());
|
||||
customerLngCustomerAttrPowerMapper.insert(lngCustomerAttrPower);
|
||||
}
|
||||
for (LngCustomerBank lngCustomerBank : lngCustomer.getLngCustomerBankList()) {
|
||||
lngCustomerBank.setCuCode(lngCustomer.getCuCode());
|
||||
for (UpdateLngCustomerBankDto updateLngCustomerBankDto : updateLngCustomerDto.getLngCustomerBankList()) {
|
||||
LngCustomerBank lngCustomerBank = new LngCustomerBank();
|
||||
BeanUtil.copyProperties(updateLngCustomerBankDto, lngCustomerBank);
|
||||
lngCustomerBank.setCuCode(lngCustomer.getCuCode());
|
||||
customerLngCustomerBankMapper.insert(lngCustomerBank);
|
||||
}
|
||||
for (LngCustomerDoc lngCustomerDoc : lngCustomer.getLngCustomerDocList()) {
|
||||
lngCustomerDoc.setCuCode(lngCustomer.getCuCode());
|
||||
for (UpdateLngCustomerDocDto updateLngCustomerDocDto : updateLngCustomerDto.getLngCustomerDocList()) {
|
||||
LngCustomerDoc lngCustomerDoc = new LngCustomerDoc();
|
||||
BeanUtil.copyProperties(updateLngCustomerDocDto, lngCustomerDoc);
|
||||
lngCustomerDoc.setCuCode(lngCustomer.getCuCode());
|
||||
customerLngCustomerDocMapper.insert(lngCustomerDoc);
|
||||
}
|
||||
for (LngCustomerContact lngCustomerContact : lngCustomer.getLngCustomerContactList()) {
|
||||
lngCustomerContact.setCuCode(lngCustomer.getCuCode());
|
||||
for (UpdateLngCustomerContactDto updateLngCustomerContactDto : updateLngCustomerDto.getLngCustomerContactList()) {
|
||||
LngCustomerContact lngCustomerContact = new LngCustomerContact();
|
||||
BeanUtil.copyProperties(updateLngCustomerContactDto, lngCustomerContact);
|
||||
lngCustomerContact.setCuCode(lngCustomer.getCuCode());
|
||||
customerLngCustomerContactMapper.insert(lngCustomerContact);
|
||||
}
|
||||
|
||||
@ -64,7 +82,9 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean update(LngCustomer lngCustomer) {
|
||||
public Boolean update(UpdateLngCustomerDto updateLngCustomerDto) {
|
||||
LngCustomer lngCustomer = new LngCustomer();
|
||||
BeanUtil.copyProperties(updateLngCustomerDto, lngCustomer);
|
||||
customerLngCustomerMapper.updateById(lngCustomer);
|
||||
//********************************* LngCustomerAttrPower 增删改 开始 *******************************************/
|
||||
{
|
||||
@ -72,13 +92,16 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
|
||||
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());
|
||||
List<Long> lngCustomerAttrPowerOldIds = updateLngCustomerDto.getLngCustomerAttrPowerList().stream().map(UpdateLngCustomerAttrPowerDto::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()) {
|
||||
//如果不等于空则修改
|
||||
for (UpdateLngCustomerAttrPowerDto lngCustomerAttrPowerDto : updateLngCustomerDto.getLngCustomerAttrPowerList()) {
|
||||
LngCustomerAttrPower lngCustomerAttrPower = new LngCustomerAttrPower();
|
||||
BeanUtil.copyProperties(lngCustomerAttrPowerDto, lngCustomerAttrPower);
|
||||
//如果不等于空则修改
|
||||
if (lngCustomerAttrPower.getId() != null) {
|
||||
|
||||
customerLngCustomerAttrPowerMapper.updateById(lngCustomerAttrPower);
|
||||
}
|
||||
//如果等于空 则新增
|
||||
@ -101,11 +124,13 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
|
||||
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());
|
||||
List<Long> lngCustomerBankOldIds = updateLngCustomerDto.getLngCustomerBankList().stream().map(UpdateLngCustomerBankDto::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()) {
|
||||
for (UpdateLngCustomerBankDto lngCustomerBankDto : updateLngCustomerDto.getLngCustomerBankList()) {
|
||||
LngCustomerBank lngCustomerBank = new LngCustomerBank();
|
||||
BeanUtil.copyProperties(lngCustomerBankDto, lngCustomerBank);
|
||||
//如果不等于空则修改
|
||||
if (lngCustomerBank.getId() != null) {
|
||||
customerLngCustomerBankMapper.updateById(lngCustomerBank);
|
||||
@ -130,12 +155,14 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
|
||||
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());
|
||||
List<Long> lngCustomerDocOldIds = updateLngCustomerDto.getLngCustomerDocList().stream().map(UpdateLngCustomerDocDto::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()) {
|
||||
//如果不等于空则修改
|
||||
for (UpdateLngCustomerDocDto lngCustomerDocDto : updateLngCustomerDto.getLngCustomerDocList()) {
|
||||
LngCustomerDoc lngCustomerDoc = new LngCustomerDoc();
|
||||
BeanUtil.copyProperties(lngCustomerDocDto, lngCustomerDoc);
|
||||
//如果不等于空则修改
|
||||
if (lngCustomerDoc.getId() != null) {
|
||||
customerLngCustomerDocMapper.updateById(lngCustomerDoc);
|
||||
}
|
||||
@ -159,12 +186,14 @@ public class CustomerServiceImpl extends MPJBaseServiceImpl<LngCustomerMapper, L
|
||||
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());
|
||||
List<Long> lngCustomerContactOldIds = updateLngCustomerDto.getLngCustomerContactList().stream().map(UpdateLngCustomerContactDto::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()) {
|
||||
//如果不等于空则修改
|
||||
for (UpdateLngCustomerContactDto lngCustomerContactDto : updateLngCustomerDto.getLngCustomerContactList()) {
|
||||
LngCustomerContact lngCustomerContact = new LngCustomerContact();
|
||||
BeanUtil.copyProperties(lngCustomerContactDto, lngCustomerContact);
|
||||
//如果不等于空则修改
|
||||
if (lngCustomerContact.getId() != null) {
|
||||
customerLngCustomerContactMapper.updateById(lngCustomerContact);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user