|
|
@@ -1,20 +1,28 @@
|
|
|
package com.mokamrp.privates.service.impl;
|
|
|
|
|
|
+import com.aliyun.oss.OSS;
|
|
|
+import com.aliyun.oss.model.PutObjectRequest;
|
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
|
+import com.mokamrp.privates.config.OSSConfiguration;
|
|
|
import com.mokamrp.privates.mapper.CorpMapper;
|
|
|
+import com.mokamrp.privates.mapper.DownfileMapper;
|
|
|
+import com.mokamrp.privates.mapper.pojo.Downfile;
|
|
|
import com.mokamrp.privates.mapper.pojo.WorkContactEmployee;
|
|
|
import com.mokamrp.privates.mapper.WorkContactEmployeeMapper;
|
|
|
import com.mokamrp.privates.mapper.vo.WorkContactEmployeeVo;
|
|
|
import com.mokamrp.privates.service.WorkContactEmployeeService;
|
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
+import com.mokamrp.privates.utils.OssFile;
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
+import org.apache.tomcat.util.bcel.Const;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
@@ -29,6 +37,15 @@ public class WorkContactEmployeeServiceImpl extends ServiceImpl<WorkContactEmplo
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
+ private OSS ossClient;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DownfileMapper downfileMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OSSConfiguration ossConfiguration;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private WorkContactEmployeeMapper mapperObj ;
|
|
|
|
|
|
@Override
|
|
|
@@ -92,4 +109,109 @@ public class WorkContactEmployeeServiceImpl extends ServiceImpl<WorkContactEmplo
|
|
|
return resMap;
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+ @Async
|
|
|
+ @Override
|
|
|
+ public void export(Integer gender, Integer status, String name,
|
|
|
+ Integer start_deleted_at, Integer end_deleted_at,
|
|
|
+ Integer start_created_at, Integer end_created_at,
|
|
|
+ Integer group_id,
|
|
|
+ Integer corp_id, List employee_id, List tag_id , Integer channel_code_id){
|
|
|
+
|
|
|
+ EntityWrapper<WorkContactEmployee> obj = new EntityWrapper<WorkContactEmployee>();
|
|
|
+
|
|
|
+ if(name != ""){
|
|
|
+ obj.like("c.name",name);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(gender != null){
|
|
|
+ obj.eq("c.gender",gender);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(status != null) {
|
|
|
+ obj.eq("a.`status`", status);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(channel_code_id != null) {
|
|
|
+ obj.eq("a.channel_code_id", channel_code_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(start_deleted_at != null) {
|
|
|
+ obj.ge("c.deleted_at", start_deleted_at);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(end_created_at != null) {
|
|
|
+ obj.le("c.deleted_at", end_deleted_at);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(start_created_at != null) {
|
|
|
+ obj.ge("c.created_at", start_created_at);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(end_created_at != null) {
|
|
|
+ obj.le("c.created_at", end_created_at);
|
|
|
+ }
|
|
|
+ if(corp_id != null) {
|
|
|
+ obj.eq("a.corp_id", corp_id);
|
|
|
+ }
|
|
|
+ if(employee_id !=null) {
|
|
|
+ obj.in("a.employee_id", employee_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<WorkContactEmployeeVo> list = mapperObj.getAllVoList(obj);
|
|
|
+
|
|
|
+ //实现下载
|
|
|
+ List<List<Object>> resList = new ArrayList<List<Object>>();
|
|
|
+ Object[] head = { "id", "客户昵称", "状态","渠道码id","渠道名称","客户删除时间","客户创建时间","unionid","客服名称","公司名称" };
|
|
|
+ List<Object> headList = Arrays.asList(head);
|
|
|
+ resList.add(headList);
|
|
|
+
|
|
|
+ List<Object> tempObj;
|
|
|
+ if(list.size() >=1){
|
|
|
+ for (WorkContactEmployeeVo o: list){
|
|
|
+ tempObj = new ArrayList<Object>() {//这个大括号 就相当于我们 new 接口
|
|
|
+ {//这个大括号 就是 构造代码块 会在构造函数前 调用
|
|
|
+ this.add(o.getId());
|
|
|
+ this.add(o.getClientName());
|
|
|
+ this.add(o.getClientStatus());
|
|
|
+ this.add(o.getChannelCodeId());
|
|
|
+ this.add(o.getChannelCodeName());
|
|
|
+ this.add(o.getClientDeletedAt());
|
|
|
+ this.add(o.getClientCreatedAt());
|
|
|
+ this.add(o.getClientUnionid());
|
|
|
+ this.add(o.getEmployeeName());
|
|
|
+ this.add(o.getCompanyName());
|
|
|
+ }
|
|
|
+ };
|
|
|
+ resList.add(tempObj);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuffer content = OssFile.createCSV(resList);
|
|
|
+
|
|
|
+
|
|
|
+ /*上传到oss*/
|
|
|
+ Downfile file = new Downfile();
|
|
|
+
|
|
|
+ Date currentTime = new Date();
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String dateString = formatter.format(currentTime);
|
|
|
+
|
|
|
+
|
|
|
+ String filePath = OSSConfiguration.DOWN_DIR+dateString+"/"+Downfile.WORK_CONTACT_EMPLOYEE;
|
|
|
+
|
|
|
+ file.setTitle(Downfile.WORK_CONTACT_EMPLOYEE);
|
|
|
+ file.setDownUrl(ossConfiguration.getHost()+filePath);
|
|
|
+ file.setStatus(1);
|
|
|
+ System.out.println(ossConfiguration.getHost()+filePath);
|
|
|
+
|
|
|
+ PutObjectRequest putObjectRequest = new PutObjectRequest(ossConfiguration.getBucketName(), filePath, new ByteArrayInputStream(content.toString().getBytes()));
|
|
|
+ ossClient.putObject(putObjectRequest);
|
|
|
+
|
|
|
+
|
|
|
+ downfileMapper.insert(file);
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|