|
@@ -2,6 +2,7 @@ package com.usky.iot.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -12,12 +13,15 @@ import com.usky.iot.domain.CrmCustomInfo;
|
|
|
import com.usky.iot.mapper.CrmCustomInfoMapper;
|
|
|
import com.usky.iot.service.CrmCustomInfoService;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
+import com.usky.iot.service.vo.CrmCustomInfoExportVO;
|
|
|
import com.usky.iot.service.vo.CrmCustomInfoRequestVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Optional;
|
|
|
|
|
@@ -43,8 +47,8 @@ public class CrmCustomInfoServiceImpl extends AbstractCrudService<CrmCustomInfoM
|
|
|
}else{
|
|
|
crmCustomInfo.setMaintainStatus(1);
|
|
|
}
|
|
|
- crmCustomInfo.setCreatedBy(SecurityUtils.getUsername());
|
|
|
- crmCustomInfo.setCreatedTime(LocalDateTime.now());
|
|
|
+ crmCustomInfo.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ crmCustomInfo.setCreateTime(LocalDateTime.now());
|
|
|
crmCustomInfo.setTenantId(SecurityUtils.getTenantId());
|
|
|
this.save(crmCustomInfo);
|
|
|
|
|
@@ -55,8 +59,13 @@ public class CrmCustomInfoServiceImpl extends AbstractCrudService<CrmCustomInfoM
|
|
|
if(checkNameUnique(crmCustomInfo)){
|
|
|
throw new BusinessException("修改客户管理信息失败,项目名称"+crmCustomInfo.getProjectName()+"已经存在");
|
|
|
}
|
|
|
- crmCustomInfo.setUpdatedBy(SecurityUtils.getUsername());
|
|
|
- crmCustomInfo.setUpdatedTime(LocalDateTime.now());
|
|
|
+ if(crmCustomInfo.getExpireTime().compareTo(LocalDateTime.now())<0){
|
|
|
+ crmCustomInfo.setMaintainStatus(2);
|
|
|
+ }else{
|
|
|
+ crmCustomInfo.setMaintainStatus(1);
|
|
|
+ }
|
|
|
+ crmCustomInfo.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+ crmCustomInfo.setUpdateTime(LocalDateTime.now());
|
|
|
this.updateById(crmCustomInfo);
|
|
|
}
|
|
|
|
|
@@ -84,6 +93,38 @@ public class CrmCustomInfoServiceImpl extends AbstractCrudService<CrmCustomInfoM
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<CrmCustomInfoExportVO> recordListExport(CrmCustomInfoRequestVO cus){
|
|
|
+ List<CrmCustomInfoExportVO> list = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<CrmCustomInfo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.like(StringUtils.isNotBlank(cus.getProjectName()),CrmCustomInfo::getProjectName,cus.getProjectName())
|
|
|
+ .like(StringUtils.isNotBlank(cus.getCompanyName()),CrmCustomInfo::getCompanyName,cus.getCompanyName())
|
|
|
+ .eq(cus.getMaintainStatus() != null,CrmCustomInfo::getMaintainStatus,cus.getMaintainStatus())
|
|
|
+ .between(StringUtils.isNotBlank(cus.getStartTime())&&StringUtils.isNotBlank(cus.getEndTime()),CrmCustomInfo::getExpireTime,cus.getStartTime(),cus.getEndTime())
|
|
|
+ .eq(CrmCustomInfo::getDeleteFlag,0)
|
|
|
+ .orderByDesc(CrmCustomInfo::getId);
|
|
|
+ List<CrmCustomInfo> list1 = this.list(queryWrapper);
|
|
|
+ if(CollectionUtils.isNotEmpty(list1)){
|
|
|
+ for(int i=0;i<list1.size();i++){
|
|
|
+ CrmCustomInfoExportVO exportVO = new CrmCustomInfoExportVO();
|
|
|
+ exportVO.setProjectId(list1.get(i).getProjectId());
|
|
|
+ exportVO.setProjectName(list1.get(i).getProjectName());
|
|
|
+ exportVO.setCompanyName(list1.get(i).getCompanyName());
|
|
|
+ exportVO.setCustomPerson(list1.get(i).getCustomPerson());
|
|
|
+ exportVO.setPhone(list1.get(i).getPhone());
|
|
|
+ exportVO.setMaintainAmount(list1.get(i).getMaintainAmount());
|
|
|
+ exportVO.setEmail(list1.get(i).getEmail());
|
|
|
+ exportVO.setSalePerson(list1.get(i).getSalePerson());
|
|
|
+ exportVO.setMaintainStatus(list1.get(i).getMaintainStatus());
|
|
|
+ exportVO.setExpireTime(list1.get(i).getExpireTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
|
|
+ exportVO.setCustomAddress(list1.get(i).getCustomAddress());
|
|
|
+
|
|
|
+ list.add(exportVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public boolean checkNameUnique(CrmCustomInfo crmCustomInfo){
|
|
|
Integer id = null == crmCustomInfo.getId()?-1:crmCustomInfo.getId();
|
|
@@ -95,4 +136,28 @@ public class CrmCustomInfoServiceImpl extends AbstractCrudService<CrmCustomInfoM
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void updateStatus(){
|
|
|
+ LambdaQueryWrapper<CrmCustomInfo> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(CrmCustomInfo::getDeleteFlag,0);
|
|
|
+ List<CrmCustomInfo> list = this.list(queryWrapper);
|
|
|
+ if(CollectionUtils.isNotEmpty(list)){
|
|
|
+ for(int i=0;i<list.size();i++){
|
|
|
+ CrmCustomInfo info = list.get(i);
|
|
|
+ if(list.get(i).getExpireTime().compareTo(LocalDateTime.now())<0){
|
|
|
+ if(info.getMaintainStatus()!=2){
|
|
|
+ info.setMaintainStatus(2);
|
|
|
+ this.updateById(info);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(info.getMaintainStatus()!=1){
|
|
|
+ info.setMaintainStatus(1);
|
|
|
+ this.updateById(info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|