|
@@ -18,13 +18,16 @@ import cn.iocoder.yudao.module.employee.api.EmployeeApi;
|
|
import cn.iocoder.yudao.module.employee.api.dto.EmployeeRespDTO;
|
|
import cn.iocoder.yudao.module.employee.api.dto.EmployeeRespDTO;
|
|
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
|
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
+import org.w3c.dom.ls.LSException;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
+import java.util.Collections;
|
|
import java.util.ConcurrentModificationException;
|
|
import java.util.ConcurrentModificationException;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
@@ -74,6 +77,10 @@ public class CustomerContractServiceImpl implements CustomerContractService {
|
|
if (StrUtil.isNotBlank(customerContractCode)) {
|
|
if (StrUtil.isNotBlank(customerContractCode)) {
|
|
validateCustomerContractCode(customerContractCode);
|
|
validateCustomerContractCode(customerContractCode);
|
|
}
|
|
}
|
|
|
|
+ String customerContractName = createReqVO.getCustomerContractName();
|
|
|
|
+ if (StrUtil.isNotBlank(customerContractName)) {
|
|
|
|
+ validateCustomerContractName(customerContractName, createReqVO.getId());
|
|
|
|
+ }
|
|
// 插入
|
|
// 插入
|
|
CustomerContractDO customerContract = BeanUtils.toBean(createReqVO, CustomerContractDO.class);
|
|
CustomerContractDO customerContract = BeanUtils.toBean(createReqVO, CustomerContractDO.class);
|
|
// uuid
|
|
// uuid
|
|
@@ -111,6 +118,17 @@ public class CustomerContractServiceImpl implements CustomerContractService {
|
|
return customerContract.getId();
|
|
return customerContract.getId();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void validateCustomerContractName(String customerContractName, Long id) {
|
|
|
|
+ LambdaQueryWrapper<CustomerContractDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ lambdaQueryWrapper.eq(CustomerContractDO::getCustomerContractName, customerContractName);
|
|
|
|
+ if (Objects.nonNull(id)) {
|
|
|
|
+ lambdaQueryWrapper.ne(CustomerContractDO::getId, id);
|
|
|
|
+ }
|
|
|
|
+ if (customerContractMapper.selectCount(lambdaQueryWrapper) > 0) {
|
|
|
|
+ throw exception(CUSTOMER_CONTRACT_NAME_EXISTS);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private void validateCustomerContractCode(String customerContractCode) {
|
|
private void validateCustomerContractCode(String customerContractCode) {
|
|
Long aLong = customerContractMapper.selectCount(CustomerContractDO::getCustomerContractCode, customerContractCode);
|
|
Long aLong = customerContractMapper.selectCount(CustomerContractDO::getCustomerContractCode, customerContractCode);
|
|
if (aLong > 0) {
|
|
if (aLong > 0) {
|
|
@@ -122,6 +140,10 @@ public class CustomerContractServiceImpl implements CustomerContractService {
|
|
public void updateCustomerContract(CustomerContractSaveReqVO updateReqVO) {
|
|
public void updateCustomerContract(CustomerContractSaveReqVO updateReqVO) {
|
|
// 校验存在
|
|
// 校验存在
|
|
CustomerContractDO customerContractDO = validateCustomerContractExists(updateReqVO.getId());
|
|
CustomerContractDO customerContractDO = validateCustomerContractExists(updateReqVO.getId());
|
|
|
|
+ String customerContractName = updateReqVO.getCustomerContractName();
|
|
|
|
+ if (StrUtil.isNotBlank(customerContractName)) {
|
|
|
|
+ validateCustomerContractName(customerContractName, updateReqVO.getId());
|
|
|
|
+ }
|
|
// 更新
|
|
// 更新
|
|
CustomerContractDO updateObj = BeanUtils.toBean(updateReqVO, CustomerContractDO.class);
|
|
CustomerContractDO updateObj = BeanUtils.toBean(updateReqVO, CustomerContractDO.class);
|
|
// 负责人及部门
|
|
// 负责人及部门
|
|
@@ -190,6 +212,25 @@ public class CustomerContractServiceImpl implements CustomerContractService {
|
|
return new PageResult<>(pageList, pageCount);
|
|
return new PageResult<>(pageList, pageCount);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public List<CustomerContractDO> getCustomerContractList(CustomerContractListVO listVO) {
|
|
|
|
+ // Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
|
|
|
|
+ // EmployeeRespDTO loginEmployee = employeeApi.getEmployeeByUserId(loginUserId);
|
|
|
|
+ // if (loginEmployee == null || loginEmployee.getDeptId() == null) {
|
|
|
|
+ // // 没有员工信息或部门信息,返回空集合
|
|
|
|
+ // return Collections.emptyList();
|
|
|
|
+ // }
|
|
|
|
+ if (listVO.getCustomerId() == null) {
|
|
|
|
+ // 没有客户id,返回空集合
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
+ }
|
|
|
|
+ LambdaQueryWrapper<CustomerContractDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ lambdaQueryWrapper.eq(CustomerContractDO::getCustomerId, listVO.getCustomerId())
|
|
|
|
+ .eq(listVO.getClosed() != null, CustomerContractDO::getClosed, listVO.getClosed());
|
|
|
|
+ return customerContractMapper.selectList(lambdaQueryWrapper);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Integer openCustomerContract(Long id) {
|
|
public Integer openCustomerContract(Long id) {
|
|
CustomerContractDO customerContractDO = validateCustomerContractExists(id);
|
|
CustomerContractDO customerContractDO = validateCustomerContractExists(id);
|