Browse Source

2023-09-07 plm客户提交

master
杨奉源 3 years ago
parent
commit
e3d4f97d6f
  1. 2
      src/main/java/com/spring/modules/customer/controller/CustomerAddressController.java
  2. 43
      src/main/java/com/spring/modules/customer/service/impl/CustomerAddressServiceImpl.java
  3. 38
      src/main/java/com/spring/modules/customer/service/impl/CustomerContactServiceImpl.java
  4. 89
      src/main/java/com/spring/modules/customer/service/impl/CustomerInformationServiceImpl.java
  5. 4
      src/main/java/com/spring/modules/customer/vo/CustomerInformationVo.java

2
src/main/java/com/spring/modules/customer/controller/CustomerAddressController.java

@ -64,7 +64,7 @@ public class CustomerAddressController {
}
/**
* @description: 客户联系删除
* @description: 客户联系地址删除
* @author: fengyuan_yang
* @date: 2023/9/4 13:29
* @param: [data]

43
src/main/java/com/spring/modules/customer/service/impl/CustomerAddressServiceImpl.java

@ -3,6 +3,7 @@ package com.spring.modules.customer.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spring.modules.customer.entity.CustomerAddressEntity;
import com.spring.modules.customer.entity.CustomerContactEntity;
import com.spring.modules.customer.mapper.CustomerAddressMapper;
import com.spring.modules.customer.service.CustomerAddressService;
import com.spring.modules.customer.vo.CustomerAddressVo;
@ -43,6 +44,12 @@ public class CustomerAddressServiceImpl extends ServiceImpl<CustomerAddressMappe
**/
@Override
public void customerAddressSave(CustomerAddressEntity data) {
// 判断主联系地址
if ("Y".equals(data.getPrimaryAddress())) {
if (queryPrimaryAddress(data)) {
throw new RuntimeException("已存在主联系地址!");
}
}
customerAddressMapper.insert(data);
}
@ -57,20 +64,20 @@ public class CustomerAddressServiceImpl extends ServiceImpl<CustomerAddressMappe
public void customerAddressEdit(CustomerAddressEntity data) {
// 判断主联系地址
if ("Y".equals(data.getPrimaryAddress())) {
QueryWrapper<CustomerAddressEntity> wrapper = new QueryWrapper<>();
wrapper.eq("site", data.getSite());
wrapper.eq("customer_no", data.getCustomerNo());
List<CustomerAddressEntity> list = customerAddressMapper.selectList(wrapper);
boolean bool = list.stream().anyMatch(a -> "Y".equals(a.getPrimaryAddress()));
if (bool){
throw new RuntimeException("已存在主联系地址!");
// 判断之前是否为主联系人
CustomerAddressEntity customerAddress = customerAddressMapper.selectById(data);
// 如果不是就判断是否已存在主联系人
if (!"Y".equals(customerAddress.getPrimaryAddress())) {
if (queryPrimaryAddress(data)){
throw new RuntimeException("已存在主联系地址!");
}
}
}
customerAddressMapper.updateById(data);
}
/**
* @description: 客户联系删除
* @description: 客户联系地址删除
* @author: fengyuan_yang
* @date: 2023/9/4 16:32
* @param: [data]
@ -78,10 +85,28 @@ public class CustomerAddressServiceImpl extends ServiceImpl<CustomerAddressMappe
**/
@Override
public void customerAddressDelete(CustomerAddressEntity data) {
// 获取选中的联系ID然后批量删除
// 获取选中的联系地址ID然后批量删除
List<Long> ids = data.getAddressList().stream()
.map(a -> a.getAddressId())
.collect(Collectors.toList());
customerAddressMapper.deleteBatchIds(ids);
}
/**
* @description: 判断是否已存在主联系地址
* @author: fengyuan_yang
* @date: 2023/9/7 14:12
* @param: [data]
* @return: java.lang.Boolean
**/
public Boolean queryPrimaryAddress(CustomerAddressEntity data) {
// 获取客户的联系地址列表
QueryWrapper<CustomerAddressEntity> wrapper = new QueryWrapper<>();
wrapper.eq("site", data.getSite());
wrapper.eq("customer_no", data.getCustomerNo());
List<CustomerAddressEntity> list = customerAddressMapper.selectList(wrapper);
// 判断是否已有主联系地址
boolean bool = list.stream().anyMatch(a -> "Y".equals(a.getPrimaryAddress()));
return bool;
}
}

38
src/main/java/com/spring/modules/customer/service/impl/CustomerContactServiceImpl.java

@ -43,6 +43,12 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
**/
@Override
public void customerContactSave(CustomerContactEntity data) {
// 判断主联系人
if ("Y".equals(data.getPrimaryContact())) {
if (queryPrimaryContact(data)) {
throw new RuntimeException("已存在主联系人!");
}
}
customerContactMapper.insert(data);
}
@ -57,13 +63,13 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
public void customerContactEdit(CustomerContactEntity data) {
// 判断主联系人
if ("Y".equals(data.getPrimaryContact())) {
QueryWrapper<CustomerContactEntity> wrapper = new QueryWrapper<>();
wrapper.eq("site", data.getSite());
wrapper.eq("customer_no", data.getCustomerNo());
List<CustomerContactEntity> list = customerContactMapper.selectList(wrapper);
boolean bool = list.stream().anyMatch(a -> "Y".equals(a.getPrimaryContact()));
if (bool){
throw new RuntimeException("已存在主联系人!");
// 判断之前是否为主联系人
CustomerContactEntity customerContact = customerContactMapper.selectById(data);
// 如果不是就判断是否已存在主联系人
if (!"Y".equals(customerContact.getPrimaryContact())) {
if (queryPrimaryContact(data)){
throw new RuntimeException("已存在主联系人!");
}
}
}
customerContactMapper.updateById(data);
@ -84,4 +90,22 @@ public class CustomerContactServiceImpl extends ServiceImpl<CustomerContactMappe
.collect(Collectors.toList());
customerContactMapper.deleteBatchIds(ids);
}
/**
* @description: 判断是否已存在主联系人
* @author: fengyuan_yang
* @date: 2023/9/7 14:12
* @param: [data]
* @return: java.lang.Boolean
**/
public Boolean queryPrimaryContact(CustomerContactEntity data) {
// 获取客户的联系人列表
QueryWrapper<CustomerContactEntity> wrapper = new QueryWrapper<>();
wrapper.eq("site", data.getSite());
wrapper.eq("customer_no", data.getCustomerNo());
List<CustomerContactEntity> list = customerContactMapper.selectList(wrapper);
// 判断是否已有主联系人
boolean bool = list.stream().anyMatch(a -> "Y".equals(a.getPrimaryContact()));
return bool;
}
}

89
src/main/java/com/spring/modules/customer/service/impl/CustomerInformationServiceImpl.java

@ -42,24 +42,6 @@ public class CustomerInformationServiceImpl extends ServiceImpl<CustomerInformat
@Autowired
private CustomerAddressMapper customerAddressMapper;
/**
* @description: 获取客户主联系人对象
* @author: fengyuan_yang
* @date: 2023/9/1 14:03
* @param: [data]
* @return: com.spring.modules.customer.entity.CustomerContactEntity
**/
public CustomerContactEntity getCustomerContactData(CustomerInformationVo data){
CustomerContactEntity customerContactEntity = new CustomerContactEntity();
customerContactEntity.setSite(data.getSite());
customerContactEntity.setCustomerNo(data.getCustomerNo());
customerContactEntity.setContactName(data.getContactName());
customerContactEntity.setContactPhoneNumber1(data.getContactPhoneNumber1());
customerContactEntity.setPrimaryContact(data.getPrimaryContact());
customerContactEntity.setContactStatus(data.getContactStatus());
return customerContactEntity;
}
/**
* @description: 客户信息列表
* @author: fengyuan_yang
@ -94,9 +76,9 @@ public class CustomerInformationServiceImpl extends ServiceImpl<CustomerInformat
CustomerAddressEntity customerAddressData = new CustomerAddressEntity();
customerAddressData.setSite(data.getSite());
customerAddressData.setCustomerNo(data.getCustomerNo());
customerAddressData.setPrimaryAddress("Y");
customerAddressData.setAddressStatus("启用");
customerAddressData.setAddressType("类型1");
customerAddressData.setPrimaryAddress(data.getPrimaryAddress());
customerAddressData.setAddressStatus(data.getAddressStatus());
customerAddressData.setAddressType(data.getAddressType());
customerAddressMapper.insert(customerAddressData);
}
}
@ -116,16 +98,43 @@ public class CustomerInformationServiceImpl extends ServiceImpl<CustomerInformat
updateInformationWrapper.eq("site", data.getSite());
updateInformationWrapper.eq("customer_no", data.getCustomerNo());
customerInformationMapper.update(data, updateInformationWrapper);
// 编辑客户主联系人
CustomerContactEntity customerContactData = getCustomerContactData(data);
customerContactData.setUpdateBy(data.getUpdateBy());
UpdateWrapper<CustomerContactEntity> updateContactWrapper = new UpdateWrapper<>();
updateContactWrapper.eq("site", data.getSite());
updateContactWrapper.eq("customer_no", data.getCustomerNo());
updateContactWrapper.eq("primary_contact", data.getPrimaryContact());
customerContactMapper.update(customerContactData, updateContactWrapper);
// 编辑主联系地址
// 1. 编辑客户主联系人
// 1.1 判断联系人姓名是否修改
Map<String,Object> columnMap = new HashMap<>();
columnMap.put("site", data.getSite());
columnMap.put("customer_no", data.getCustomerNo());
columnMap.put("primary_contact", data.getPrimaryContact());
List<CustomerContactEntity> contactList = customerContactMapper.selectByMap(columnMap);
if (contactList.size() > 0 && contactList.get(0) != null && StringUtils.isNotBlank(data.getContactName())) {
// 1.2 修改主联系人
if (!contactList.get(0).getContactName().equals(data.getContactName())) {
CustomerContactEntity customerContactData = getCustomerContactData(data);
customerContactData.setUpdateBy(data.getUpdateBy());
UpdateWrapper<CustomerContactEntity> updateContactWrapper = new UpdateWrapper<>();
updateContactWrapper.eq("site", data.getSite());
updateContactWrapper.eq("customer_no", data.getCustomerNo());
updateContactWrapper.eq("primary_contact", data.getPrimaryContact());
customerContactMapper.update(customerContactData, updateContactWrapper);
}
}
// 2. 编辑主联系地址
// 2.1 判断联系地址姓名是否修改
columnMap.remove("primary_contact");
columnMap.put("primary_address", "Y");
List<CustomerAddressEntity> addressList = customerAddressMapper.selectByMap(columnMap);
if (addressList.size() > 0 && addressList.get(0) != null && StringUtils.isNotBlank(data.getAddressName())) {
// 2.2 修改主联系地址
if (!addressList.get(0).getAddressName().equals(data.getAddressName())) {
CustomerAddressEntity customerAddressData = new CustomerAddressEntity();
customerAddressData.setUpdateBy(data.getUpdateBy());
customerAddressData.setAddressName(data.getAddressName());
UpdateWrapper<CustomerAddressEntity> updateAddressWrapper = new UpdateWrapper<>();
updateAddressWrapper.eq("site", data.getSite());
updateAddressWrapper.eq("customer_no", data.getCustomerNo());
updateAddressWrapper.eq("primary_address", data.getPrimaryAddress());
customerAddressMapper.update(customerAddressData, updateAddressWrapper);
}
}
}
/**
@ -149,4 +158,22 @@ public class CustomerInformationServiceImpl extends ServiceImpl<CustomerInformat
customerContactMapper.deleteByMap(map);
}
}
/**
* @description: 获取客户主联系人对象
* @author: fengyuan_yang
* @date: 2023/9/1 14:03
* @param: [data]
* @return: com.spring.modules.customer.entity.CustomerContactEntity
**/
public CustomerContactEntity getCustomerContactData(CustomerInformationVo data){
CustomerContactEntity customerContactEntity = new CustomerContactEntity();
customerContactEntity.setSite(data.getSite());
customerContactEntity.setCustomerNo(data.getCustomerNo());
customerContactEntity.setContactName(data.getContactName());
customerContactEntity.setContactPhoneNumber1(data.getContactPhoneNumber1());
customerContactEntity.setPrimaryContact(data.getPrimaryContact());
customerContactEntity.setContactStatus(data.getContactStatus());
return customerContactEntity;
}
}

4
src/main/java/com/spring/modules/customer/vo/CustomerInformationVo.java

@ -41,4 +41,8 @@ public class CustomerInformationVo extends CustomerInformationEntity {
* 联系地址状态
**/
private String addressStatus;
/**
* 联系地址类型
**/
private String addressType;
}
Loading…
Cancel
Save