|
@@ -3,15 +3,20 @@ package com.management.platform.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.management.platform.entity.CustomerInfo;
|
|
|
+import com.management.platform.entity.User;
|
|
|
+import com.management.platform.entity.WxCorpInfo;
|
|
|
import com.management.platform.mapper.CustomerInfoMapper;
|
|
|
import com.management.platform.mapper.UserMapper;
|
|
|
+import com.management.platform.mapper.WxCorpInfoMapper;
|
|
|
import com.management.platform.service.CustomerInfoService;
|
|
|
+import com.management.platform.service.ExcelExportService;
|
|
|
import com.management.platform.util.ExcelUtil;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
import com.management.platform.util.MessageUtils;
|
|
|
import org.apache.poi.EncryptedDocumentException;
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -39,6 +44,44 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
CustomerInfoMapper customerInfoMapper;
|
|
|
@Resource
|
|
|
UserMapper userMapper;
|
|
|
+ @Resource
|
|
|
+ ExcelExportService excelExportService;
|
|
|
+ @Resource
|
|
|
+ WxCorpInfoMapper wxCorpInfoMapper;
|
|
|
+ @Value(value = "${upload.path}")
|
|
|
+ private String path;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg exportData(HttpServletRequest request) {
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ List<CustomerInfo> customerInfos = customerInfoMapper.selectList(new QueryWrapper<CustomerInfo>().eq("company_id", user.getCompanyId()));
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
+ List<List<String>> dataList=new ArrayList<>();
|
|
|
+ List<String> titleList=new ArrayList<>();
|
|
|
+ titleList.add("客户编号");
|
|
|
+ titleList.add("客户名称");
|
|
|
+ titleList.add("联系人");
|
|
|
+ titleList.add("联系电话");
|
|
|
+ titleList.add("邮箱");
|
|
|
+ titleList.add("地址");
|
|
|
+ dataList.add(titleList);
|
|
|
+ for (CustomerInfo customerInfo : customerInfos) {
|
|
|
+ List<String> item=new ArrayList<>();
|
|
|
+ item.add(customerInfo.getCustomerCode()==null?"":customerInfo.getCustomerCode());
|
|
|
+ item.add(customerInfo.getCustomerName());
|
|
|
+ item.add(customerInfo.getContactName()==null?"":customerInfo.getContactName());
|
|
|
+ item.add(customerInfo.getContactPhone()==null?"":customerInfo.getContactPhone());
|
|
|
+ item.add(customerInfo.getEmail()==null?"":customerInfo.getEmail());
|
|
|
+ item.add(customerInfo.getAddress()==null?"":customerInfo.getAddress());
|
|
|
+ dataList.add(item);
|
|
|
+ }
|
|
|
+ String fileName = "客户管理列表"+System.currentTimeMillis();
|
|
|
+ String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName, dataList, path);
|
|
|
+ msg.setData(resp);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public HttpRespMsg importData(HttpServletRequest request, MultipartFile multipartFile) {
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|