瀏覽代碼

'开发客户管理信息表-导出接口和新增定时任务每天一次更新客户管理信息表中状态字段值'

james 1 年之前
父節點
當前提交
cecaf2a54e

+ 16 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/controller/web/CrmCustomInfoController.java

@@ -1,16 +1,23 @@
 package com.usky.iot.controller.web;
 
 
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
 import com.usky.common.core.bean.ApiResult;
 import com.usky.common.core.bean.CommonPage;
 import com.usky.iot.domain.CrmCustomInfo;
 import com.usky.iot.service.CrmCustomInfoService;
+import com.usky.iot.service.vo.CrmCustomInfoExportVO;
 import com.usky.iot.service.vo.CrmCustomInfoRequestVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import org.springframework.stereotype.Controller;
 
+import javax.rmi.CORBA.Util;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+
 /**
  * <p>
  * 客户管理信息表 前端控制器
@@ -69,5 +76,14 @@ public class CrmCustomInfoController {
         return ApiResult.success(crmCustomInfoService.page(crmCustomInfoRequestVO));
     }
 
+
+    @PostMapping("export")
+    public void export(@RequestBody CrmCustomInfoRequestVO crmCustomInfoRequestVO, HttpServletResponse response)throws IOException {
+        List<CrmCustomInfoExportVO> list = crmCustomInfoService.recordListExport(crmCustomInfoRequestVO);
+        ExcelUtil<CrmCustomInfoExportVO> util = new ExcelUtil<CrmCustomInfoExportVO>(CrmCustomInfoExportVO.class);
+        util.exportExcel(response,list,"客户管理信息","客户管理信息");
+
+    }
+
 }
 

+ 10 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/controller/web/TaskController.java

@@ -1,5 +1,6 @@
 package com.usky.iot.controller.web;
 
+import com.usky.iot.service.CrmCustomInfoService;
 import com.usky.iot.service.DmpDeviceStatusService;
 import com.usky.iot.service.job.DmpDataOverviewJob;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +21,9 @@ public class TaskController {
     @Autowired
     private DmpDeviceStatusService dmpDeviceStatusService;
 
+    @Autowired
+    private CrmCustomInfoService crmCustomInfoService;
+
     @Scheduled(cron = "0 0 1 * * ? ") //每天凌晨1点执行
     public void task() {
         System.out.println(Thread.currentThread().getName() + "定时任务执行中");
@@ -31,4 +35,10 @@ public class TaskController {
 //        dmpDeviceStatusService.status();
 //    }
 
+    @Scheduled(cron = "0 30 * * * ? ") //每天凌晨0点30分执行
+    public void task2() {
+        System.out.println(Thread.currentThread().getName() + "定时任务执行中");
+        crmCustomInfoService.updateStatus();
+    }
+
 }

+ 4 - 4
service-iot/service-iot-biz/src/main/java/com/usky/iot/domain/CrmCustomInfo.java

@@ -100,22 +100,22 @@ public class CrmCustomInfo implements Serializable {
     /**
      * 创建人
      */
-    private String createdBy;
+    private String createBy;
 
     /**
      * 创建时间
      */
-    private LocalDateTime createdTime;
+    private LocalDateTime createTime;
 
     /**
      * 更新人
      */
-    private String updatedBy;
+    private String updateBy;
 
     /**
      * 更新时间
      */
-    private LocalDateTime updatedTime;
+    private LocalDateTime updateTime;
 
     /**
      * 租户号

+ 7 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/CrmCustomInfoService.java

@@ -3,8 +3,12 @@ package com.usky.iot.service;
 import com.usky.common.core.bean.CommonPage;
 import com.usky.iot.domain.CrmCustomInfo;
 import com.usky.common.mybatis.core.CrudService;
+import com.usky.iot.service.vo.CrmCustomInfoExportVO;
 import com.usky.iot.service.vo.CrmCustomInfoRequestVO;
 
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
 /**
  * <p>
  * 客户管理信息表 服务类
@@ -24,4 +28,7 @@ public interface CrmCustomInfoService extends CrudService<CrmCustomInfo> {
 
     boolean checkNameUnique(CrmCustomInfo crmCustomInfo);
 
+    List<CrmCustomInfoExportVO> recordListExport(CrmCustomInfoRequestVO crmCustomInfoRequestVO);
+
+    void updateStatus();
 }

+ 69 - 4
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/CrmCustomInfoServiceImpl.java

@@ -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);
+                    }
+                }
+            }
+        }
+
+    }
+
 }

+ 99 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/vo/CrmCustomInfoExportVO.java

@@ -0,0 +1,99 @@
+package com.usky.iot.service.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+
+import com.ruoyi.common.core.annotation.Excel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 客户管理信息表-导出
+ * </p>
+ *
+ * @author han
+ * @since 2023-06-26
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class CrmCustomInfoExportVO implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 项目编号
+     */
+    @Excel(name = "项目编号")
+    private String projectId;
+
+    /**
+     * 项目名称
+     */
+    @Excel(name = "项目名称")
+    private String projectName;
+
+    /**
+     * 单位名称
+     */
+    @Excel(name = "单位名称")
+    private String companyName;
+
+    /**
+     * 客户负责人
+     */
+    @Excel(name = "客户负责人")
+    private String customPerson;
+
+    /**
+     * 客户电话
+     */
+    @Excel(name = "客户电话")
+    private String phone;
+
+    /**
+     * 维保费
+     */
+    @Excel(name = "维保费")
+    private Double maintainAmount;
+
+    /**
+     * 客户邮箱
+     */
+    @Excel(name = "客户邮箱")
+    private String email;
+
+    /**
+     * 销售负责人
+     */
+    @Excel(name = "销售负责人")
+    private String salePerson;
+
+    /**
+     * 状态;1:使用中,2:已到期
+     */
+    @Excel(name = "状态", readConverterExp = "1=使用中,2=已到期")
+    private Integer maintainStatus;
+
+    /**
+     * 到期时间
+     */
+    @Excel(name = "到期时间")
+    private String expireTime;
+
+    /**
+     * 客户地址
+     */
+    @Excel(name = "客户地址")
+    private String customAddress;
+}